@module-federation/devtools 0.0.0-next-20250926024003 → 0.0.0-perf-devtools-20260106124142

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 (92) hide show
  1. package/dist/es/App.js +328 -22
  2. package/dist/es/App.module.js +1 -1
  3. package/dist/es/App_module.css +291 -5
  4. package/dist/es/component/DependencyGraph/index.js +205 -0
  5. package/dist/es/component/DependencyGraph/index.module.js +5 -0
  6. package/dist/es/component/DependencyGraph/index_module.css +97 -0
  7. package/dist/es/component/{GraphItem → DependencyGraphItem}/index.js +15 -6
  8. package/dist/es/component/DependencyGraphItem/index.module.js +5 -0
  9. package/dist/es/component/DependencyGraphItem/index_module.css +95 -0
  10. package/dist/es/component/Form/index.js +191 -109
  11. package/dist/es/component/Form/index.module.js +1 -1
  12. package/dist/es/component/Form/index_module.css +179 -25
  13. package/dist/es/component/Layout/index.js +288 -51
  14. package/dist/es/component/Layout/index.module.js +1 -1
  15. package/dist/es/component/Layout/index_module.css +52 -32
  16. package/dist/es/component/ModuleInfo/index.js +289 -0
  17. package/dist/es/component/ModuleInfo/index.module.js +5 -0
  18. package/dist/es/component/ModuleInfo/index_module.css +183 -0
  19. package/dist/es/component/SharedDepsExplorer/FocusResultDisplay.js +39 -0
  20. package/dist/es/component/SharedDepsExplorer/index.js +505 -0
  21. package/dist/es/component/SharedDepsExplorer/share-utils.js +206 -0
  22. package/dist/es/index.css +15 -0
  23. package/dist/es/template/constant.js +5 -19
  24. package/dist/es/utils/chrome/fast-refresh.js +80 -7
  25. package/dist/es/utils/chrome/index.js +91 -38
  26. package/dist/es/utils/chrome/messages.js +6 -0
  27. package/dist/es/utils/chrome/post-message-listener.js +2 -1
  28. package/dist/es/utils/chrome/post-message-start.js +10 -2
  29. package/dist/es/utils/chrome/storage.js +6 -1
  30. package/dist/es/utils/sdk/graph.js +25 -4
  31. package/dist/es/utils/sdk/index.js +9 -0
  32. package/dist/es/worker/index.js +168 -1
  33. package/dist/lib/App.js +318 -17
  34. package/dist/lib/App.module.js +1 -1
  35. package/dist/lib/App_module.css +291 -5
  36. package/dist/lib/component/DependencyGraph/index.js +227 -0
  37. package/dist/lib/component/{GraphItem → DependencyGraph}/index.module.js +1 -1
  38. package/dist/lib/component/DependencyGraph/index_module.css +97 -0
  39. package/dist/lib/component/{GraphItem → DependencyGraphItem}/index.js +18 -9
  40. package/dist/lib/component/{Graph → DependencyGraphItem}/index.module.js +1 -1
  41. package/dist/lib/component/DependencyGraphItem/index_module.css +95 -0
  42. package/dist/lib/component/Form/index.js +188 -107
  43. package/dist/lib/component/Form/index.module.js +1 -1
  44. package/dist/lib/component/Form/index_module.css +179 -25
  45. package/dist/lib/component/Layout/index.js +280 -48
  46. package/dist/lib/component/Layout/index.module.js +1 -1
  47. package/dist/lib/component/Layout/index_module.css +52 -32
  48. package/dist/lib/component/ModuleInfo/index.js +319 -0
  49. package/dist/lib/component/ModuleInfo/index.module.js +25 -0
  50. package/dist/lib/component/ModuleInfo/index_module.css +183 -0
  51. package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.js +59 -0
  52. package/dist/lib/component/SharedDepsExplorer/index.js +512 -0
  53. package/dist/lib/component/SharedDepsExplorer/share-utils.js +237 -0
  54. package/dist/lib/index.css +15 -0
  55. package/dist/lib/template/constant.js +7 -17
  56. package/dist/lib/utils/chrome/fast-refresh.js +77 -8
  57. package/dist/lib/utils/chrome/index.js +94 -38
  58. package/dist/lib/utils/chrome/messages.js +31 -0
  59. package/dist/lib/utils/chrome/post-message-listener.js +2 -1
  60. package/dist/lib/utils/chrome/post-message-start.js +10 -2
  61. package/dist/lib/utils/chrome/storage.js +5 -0
  62. package/dist/lib/utils/sdk/graph.js +25 -4
  63. package/dist/lib/utils/sdk/index.js +10 -0
  64. package/dist/lib/worker/index.js +156 -1
  65. package/dist/types/src/App.d.ts +0 -1
  66. package/dist/types/src/component/{Graph → DependencyGraph}/index.d.ts +0 -1
  67. package/dist/types/src/component/{GraphItem → DependencyGraphItem}/index.d.ts +0 -1
  68. package/dist/types/src/component/Form/index.d.ts +2 -0
  69. package/dist/types/src/component/Layout/index.d.ts +0 -1
  70. package/dist/types/src/component/ModuleInfo/index.d.ts +8 -0
  71. package/dist/types/src/component/SharedDepsExplorer/FocusResultDisplay.d.ts +15 -0
  72. package/dist/types/src/component/SharedDepsExplorer/index.d.ts +6 -0
  73. package/dist/types/src/component/SharedDepsExplorer/share-utils.d.ts +44 -0
  74. package/dist/types/src/index.d.ts +2 -1
  75. package/dist/types/src/init.d.ts +0 -1
  76. package/dist/types/src/template/constant.d.ts +3 -5
  77. package/dist/types/src/utils/chrome/index.d.ts +5 -3
  78. package/dist/types/src/utils/chrome/messages.d.ts +2 -0
  79. package/dist/types/src/utils/chrome/storage.d.ts +5 -4
  80. package/dist/types/src/utils/sdk/graph.d.ts +2 -1
  81. package/dist/types/src/utils/sdk/index.d.ts +1 -0
  82. package/dist/types/src/utils/types/common.d.ts +4 -0
  83. package/dist/types/src/worker/index.d.ts +1 -0
  84. package/package.json +18 -14
  85. package/dist/es/component/Graph/index.js +0 -127
  86. package/dist/es/component/Graph/index.module.js +0 -5
  87. package/dist/es/component/Graph/index_module.css +0 -12
  88. package/dist/es/component/GraphItem/index.module.js +0 -5
  89. package/dist/es/component/GraphItem/index_module.css +0 -61
  90. package/dist/lib/component/Graph/index.js +0 -149
  91. package/dist/lib/component/Graph/index_module.css +0 -12
  92. package/dist/lib/component/GraphItem/index_module.css +0 -61
@@ -0,0 +1,206 @@
1
+ function isRecord(value) {
2
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
3
+ }
4
+ function computeLoadedStatus(entry) {
5
+ if (entry.loaded === true) {
6
+ return "loaded";
7
+ }
8
+ if (entry.loading) {
9
+ return "loading";
10
+ }
11
+ return "not-loaded";
12
+ }
13
+ function computeReuseStatus(entry) {
14
+ const useIn = Array.isArray(entry.useIn) ? entry.useIn : [];
15
+ const { from } = entry;
16
+ const reused = useIn.some((consumer) => consumer && consumer !== from);
17
+ return reused;
18
+ }
19
+ function normalizeEntry({
20
+ provider,
21
+ scope,
22
+ packageName,
23
+ versionKey,
24
+ entry
25
+ }) {
26
+ var _a;
27
+ if (!isRecord(entry)) {
28
+ return null;
29
+ }
30
+ const sharedEntry = entry;
31
+ const loadedStatus = computeLoadedStatus(sharedEntry);
32
+ const reuseStatus = computeReuseStatus(sharedEntry);
33
+ const useIn = Array.isArray(sharedEntry.useIn) ? sharedEntry.useIn : [];
34
+ return {
35
+ id: `${provider}::${scope}::${packageName}::${versionKey}`,
36
+ provider,
37
+ scope,
38
+ packageName,
39
+ version: sharedEntry.version || versionKey,
40
+ from: sharedEntry.from,
41
+ useIn,
42
+ shareConfig: (_a = sharedEntry.shareConfig) != null ? _a : {},
43
+ strategy: sharedEntry.strategy,
44
+ loaded: sharedEntry.loaded,
45
+ loading: sharedEntry.loading,
46
+ loadedStatus,
47
+ reuseStatus
48
+ };
49
+ }
50
+ function normalizeShareData(raw) {
51
+ if (!raw || !isRecord(raw)) {
52
+ return [];
53
+ }
54
+ const items = [];
55
+ Object.entries(raw).forEach(([topKey, topValue]) => {
56
+ if (!isRecord(topValue)) {
57
+ return;
58
+ }
59
+ if (topKey === "default") {
60
+ const provider2 = "default";
61
+ const scope = "default";
62
+ const packagesObj = topValue;
63
+ Object.entries(packagesObj).forEach(([pkgName, versions]) => {
64
+ if (pkgName === "version" || !isRecord(versions)) {
65
+ return;
66
+ }
67
+ Object.entries(versions).forEach(([versionKey, entry]) => {
68
+ const normalized = normalizeEntry({
69
+ provider: provider2,
70
+ scope,
71
+ packageName: pkgName,
72
+ versionKey,
73
+ entry
74
+ });
75
+ if (normalized) {
76
+ items.push(normalized);
77
+ }
78
+ });
79
+ });
80
+ return;
81
+ }
82
+ const provider = topKey;
83
+ const scopesObj = topValue;
84
+ Object.entries(scopesObj).forEach(([scopeName, scopeValue]) => {
85
+ if (scopeName === "version" || !isRecord(scopeValue)) {
86
+ return;
87
+ }
88
+ const packagesObj = scopeValue;
89
+ Object.entries(packagesObj).forEach(([pkgName, versions]) => {
90
+ if (pkgName === "version" || !isRecord(versions)) {
91
+ return;
92
+ }
93
+ Object.entries(versions).forEach(([versionKey, entry]) => {
94
+ const normalized = normalizeEntry({
95
+ provider,
96
+ scope: scopeName,
97
+ packageName: pkgName,
98
+ versionKey,
99
+ entry
100
+ });
101
+ if (normalized) {
102
+ items.push(normalized);
103
+ }
104
+ });
105
+ });
106
+ });
107
+ });
108
+ return items;
109
+ }
110
+ function computeShareStats(versions) {
111
+ const providerSet = /* @__PURE__ */ new Set();
112
+ const scopeSet = /* @__PURE__ */ new Set();
113
+ const packageSet = /* @__PURE__ */ new Set();
114
+ let loadedCount = 0;
115
+ let reusedCount = 0;
116
+ versions.forEach((v) => {
117
+ providerSet.add(v.provider);
118
+ scopeSet.add(v.scope);
119
+ packageSet.add(v.packageName);
120
+ if (v.loadedStatus === "loaded") {
121
+ loadedCount += 1;
122
+ }
123
+ if (v.reuseStatus) {
124
+ reusedCount += 1;
125
+ }
126
+ });
127
+ return {
128
+ totalProviders: providerSet.size,
129
+ totalScopes: scopeSet.size,
130
+ totalPackages: packageSet.size,
131
+ totalVersions: versions.length,
132
+ loadedCount,
133
+ reusedCount
134
+ };
135
+ }
136
+ function groupByProviderScopePackage(versions) {
137
+ const tree = {};
138
+ versions.forEach((v) => {
139
+ if (!tree[v.provider]) {
140
+ tree[v.provider] = {};
141
+ }
142
+ if (!tree[v.provider][v.scope]) {
143
+ tree[v.provider][v.scope] = {};
144
+ }
145
+ if (!tree[v.provider][v.scope][v.packageName]) {
146
+ tree[v.provider][v.scope][v.packageName] = [];
147
+ }
148
+ tree[v.provider][v.scope][v.packageName].push(v);
149
+ });
150
+ return tree;
151
+ }
152
+ function getFilterOptions(versions) {
153
+ const providerSet = /* @__PURE__ */ new Set();
154
+ const scopeSet = /* @__PURE__ */ new Set();
155
+ const packageSet = /* @__PURE__ */ new Set();
156
+ const versionSet = /* @__PURE__ */ new Set();
157
+ versions.forEach((v) => {
158
+ providerSet.add(v.provider);
159
+ scopeSet.add(v.scope);
160
+ packageSet.add(v.packageName);
161
+ versionSet.add(v.version);
162
+ });
163
+ return {
164
+ providers: Array.from(providerSet).sort(),
165
+ scopes: Array.from(scopeSet).sort(),
166
+ packages: Array.from(packageSet).sort(),
167
+ versions: Array.from(versionSet).sort()
168
+ };
169
+ }
170
+ function findPackageProvider(versions, packageName, version) {
171
+ var _a;
172
+ const candidates = versions.filter(
173
+ (v) => v.packageName === packageName && (!version || v.version === version)
174
+ );
175
+ if (!candidates.length) {
176
+ return null;
177
+ }
178
+ const providers = Array.from(new Set(candidates.map((v) => v.from))).sort();
179
+ const hasLoaded = candidates.some((v) => v.loadedStatus === "loaded");
180
+ const hasLoading = !hasLoaded && candidates.some((v) => v.loadedStatus === "loading");
181
+ let status = "not-loaded";
182
+ if (hasLoaded) {
183
+ status = "loaded";
184
+ } else if (hasLoading) {
185
+ status = "loading";
186
+ }
187
+ return {
188
+ packageName,
189
+ version: version || ((_a = candidates[0]) == null ? void 0 : _a.version),
190
+ providers,
191
+ status
192
+ };
193
+ }
194
+ function getReusedVersions(versions) {
195
+ return versions.filter((v) => v.reuseStatus === true);
196
+ }
197
+ export {
198
+ computeLoadedStatus,
199
+ computeReuseStatus,
200
+ computeShareStats,
201
+ findPackageProvider,
202
+ getFilterOptions,
203
+ getReusedVersions,
204
+ groupByProviderScopePackage,
205
+ normalizeShareData
206
+ };
@@ -0,0 +1,15 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+ .loaded-status-tag {
5
+ color: white !important;
6
+ background-color: black !important;
7
+ }
8
+ .reused-status-tag {
9
+ background-color: greenyellow !important;
10
+ }
11
+ .common-tag {
12
+ color: rgb(113 113 122 / var(--tw-text-opacity)) !important;
13
+ background-color: #fff !important;
14
+ border-color: rgba(228, 228, 231, 0.5) !important;
15
+ }
@@ -1,21 +1,6 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
1
  const FormID = "FormID";
18
2
  const ENABLEHMR = "enableHMR";
3
+ const ENABLE_CLIP = "enableClip";
19
4
  const proxyFormField = "proxyFormField";
20
5
  const defaultDataItem = {
21
6
  key: "",
@@ -23,9 +8,7 @@ const defaultDataItem = {
23
8
  checked: true
24
9
  };
25
10
  const defaultModuleData = {
26
- proxyFormField: [
27
- __spreadValues({}, defaultDataItem)
28
- ]
11
+ proxyFormField: []
29
12
  };
30
13
  const statusInfo = {
31
14
  noProxy: {
@@ -50,12 +33,15 @@ const statusInfo = {
50
33
  }
51
34
  };
52
35
  const __ENABLE_FAST_REFRESH__ = "enableFastRefresh";
36
+ const __EAGER_SHARE__ = "eagerShare";
53
37
  const BROWSER_ENV_KEY = "MF_ENV";
54
38
  const __FEDERATION_DEVTOOLS__ = "__MF_DEVTOOLS__";
55
39
  export {
56
40
  BROWSER_ENV_KEY,
57
41
  ENABLEHMR,
42
+ ENABLE_CLIP,
58
43
  FormID,
44
+ __EAGER_SHARE__,
59
45
  __ENABLE_FAST_REFRESH__,
60
46
  __FEDERATION_DEVTOOLS__,
61
47
  defaultDataItem,
@@ -50,7 +50,48 @@ var _a;
50
50
  import { loadScript } from "@module-federation/sdk";
51
51
  import { isObject, getUnpkgUrl } from "../index";
52
52
  import { definePropertyGlobalVal } from "../sdk";
53
- import { __FEDERATION_DEVTOOLS__ } from "../../template";
53
+ import {
54
+ __FEDERATION_DEVTOOLS__,
55
+ __EAGER_SHARE__,
56
+ __ENABLE_FAST_REFRESH__
57
+ } from "../../template/constant";
58
+ const SUPPORT_PKGS = ["react", "react-dom"];
59
+ const fetchAndExecuteUmdSync = (url) => {
60
+ try {
61
+ const response = new XMLHttpRequest();
62
+ response.open("GET", url, false);
63
+ response.overrideMimeType("text/plain");
64
+ response.send();
65
+ if (response.status === 200) {
66
+ const scriptContent = response.responseText;
67
+ const moduleFunction = new Function(scriptContent);
68
+ return moduleFunction(window);
69
+ } else {
70
+ throw new Error(
71
+ `Failed to load module from ${url}: HTTP ${response.status}`
72
+ );
73
+ }
74
+ } catch (error) {
75
+ throw new Error(`Failed to fetch module from ${url}: ${error.message}`);
76
+ }
77
+ };
78
+ const getDevtoolsMessage = () => {
79
+ const devtoolsMessageStr = localStorage.getItem(__FEDERATION_DEVTOOLS__);
80
+ if (devtoolsMessageStr) {
81
+ try {
82
+ return JSON.parse(devtoolsMessageStr);
83
+ } catch (e) {
84
+ console.debug("Fast Refresh Plugin Error: ", e);
85
+ }
86
+ }
87
+ return null;
88
+ };
89
+ const devtoolsMessage = getDevtoolsMessage();
90
+ if ((devtoolsMessage == null ? void 0 : devtoolsMessage[__ENABLE_FAST_REFRESH__]) && (devtoolsMessage == null ? void 0 : devtoolsMessage[__EAGER_SHARE__])) {
91
+ const [_name, version] = devtoolsMessage[__EAGER_SHARE__];
92
+ fetchAndExecuteUmdSync(getUnpkgUrl("react", version));
93
+ fetchAndExecuteUmdSync(getUnpkgUrl("react-dom", version));
94
+ }
54
95
  const fastRefreshPlugin = () => {
55
96
  return {
56
97
  name: "mf-fast-refresh-plugin",
@@ -58,17 +99,22 @@ const fastRefreshPlugin = () => {
58
99
  var _b = _a2, { userOptions } = _b, args = __objRest(_b, ["userOptions"]);
59
100
  const shareInfo = userOptions.shared;
60
101
  const twinsShareInfo = args.shareInfo;
61
- let enableFastRefresh;
62
- let devtoolsMessage;
102
+ let enableFastRefresh = false;
103
+ let devtoolsMessage2 = {};
63
104
  const devtoolsMessageStr = localStorage.getItem(__FEDERATION_DEVTOOLS__);
64
105
  if (devtoolsMessageStr) {
65
106
  try {
66
- devtoolsMessage = JSON.parse(devtoolsMessageStr);
67
- enableFastRefresh = devtoolsMessage == null ? void 0 : devtoolsMessage.enableFastRefresh;
107
+ devtoolsMessage2 = JSON.parse(devtoolsMessageStr);
108
+ enableFastRefresh = devtoolsMessage2 == null ? void 0 : devtoolsMessage2[__ENABLE_FAST_REFRESH__];
68
109
  } catch (e) {
69
110
  console.debug("Fast Refresh Plugin Error: ", e);
70
111
  }
71
112
  }
113
+ if (!enableFastRefresh) {
114
+ return __spreadValues({
115
+ userOptions
116
+ }, args);
117
+ }
72
118
  if (shareInfo && isObject(shareInfo)) {
73
119
  let orderResolve;
74
120
  const orderPromise = new Promise((resolve) => {
@@ -81,10 +127,37 @@ const fastRefreshPlugin = () => {
81
127
  twinsSharedArr = Array.isArray(twinsShareInfo[share]) ? twinsShareInfo[share] : [twinsShareInfo[share]];
82
128
  }
83
129
  sharedArr.forEach((shared, idx) => {
130
+ var _a3;
131
+ if (!SUPPORT_PKGS.includes(share)) {
132
+ return;
133
+ }
134
+ if ((_a3 = shared.shareConfig) == null ? void 0 : _a3.eager) {
135
+ if (!(devtoolsMessage2 == null ? void 0 : devtoolsMessage2[__EAGER_SHARE__])) {
136
+ const eagerShare = [];
137
+ eagerShare.push(share, shared.version);
138
+ devtoolsMessage2[__EAGER_SHARE__] = eagerShare;
139
+ localStorage.setItem(
140
+ __FEDERATION_DEVTOOLS__,
141
+ JSON.stringify(devtoolsMessage2)
142
+ );
143
+ window.location.reload();
144
+ }
145
+ if (share === "react-dom") {
146
+ shared.lib = () => window.ReactDOM;
147
+ }
148
+ if (share === "react") {
149
+ shared.lib = () => window.React;
150
+ }
151
+ return;
152
+ }
84
153
  let get;
85
154
  if (share === "react") {
86
155
  get = () => loadScript(getUnpkgUrl(share, shared.version), {
87
- attrs: { defer: true, async: false }
156
+ attrs: {
157
+ defer: false,
158
+ async: false,
159
+ "data-mf-injected": "true"
160
+ }
88
161
  }).then(() => {
89
162
  orderResolve();
90
163
  });
@@ -96,7 +169,7 @@ const fastRefreshPlugin = () => {
96
169
  })
97
170
  );
98
171
  }
99
- if (enableFastRefresh && typeof get === "function") {
172
+ if (typeof get === "function") {
100
173
  if (share === "react") {
101
174
  shared.get = () => __async(this, null, function* () {
102
175
  if (!window.React) {
@@ -55,12 +55,37 @@ const injectPostMessage = (postMessageUrl) => {
55
55
  const TabInfo = {
56
56
  currentTabId: 0
57
57
  };
58
+ const setTargetTab = (tab) => {
59
+ if (!tab || typeof tab.id !== "number") {
60
+ return;
61
+ }
62
+ window.targetTab = tab;
63
+ TabInfo.currentTabId = tab.id;
64
+ };
65
+ const syncActiveTab = (tabId) => __async(void 0, null, function* () {
66
+ try {
67
+ if (typeof tabId === "number") {
68
+ const tab = yield chrome.tabs.get(tabId);
69
+ setTargetTab(tab);
70
+ return tab;
71
+ }
72
+ const [activeTab] = yield getTabs({
73
+ active: true,
74
+ lastFocusedWindow: true
75
+ });
76
+ setTargetTab(activeTab);
77
+ return activeTab;
78
+ } catch (error) {
79
+ console.warn("[Module Federation Devtools] syncActiveTab failed", error);
80
+ return void 0;
81
+ }
82
+ });
58
83
  function getCurrentTabId() {
59
84
  return TabInfo.currentTabId;
60
85
  }
61
86
  function getInspectWindowTabId() {
62
87
  return new Promise((resolve, reject) => {
63
- var _a;
88
+ var _a, _b;
64
89
  if ((_a = chrome == null ? void 0 : chrome.devtools) == null ? void 0 : _a.inspectedWindow) {
65
90
  if (chrome.isDevMode) {
66
91
  resolve(0);
@@ -73,7 +98,7 @@ function getInspectWindowTabId() {
73
98
  const target = tabs.find(
74
99
  (tab) => tab.id === tabId
75
100
  );
76
- window.targetTab = target;
101
+ setTargetTab(target);
77
102
  });
78
103
  console.log(
79
104
  "chrome.devtools.inspectedWindow.tabId",
@@ -87,7 +112,7 @@ function getInspectWindowTabId() {
87
112
  }
88
113
  );
89
114
  } else {
90
- if (window.targetTab && window.targetTab.id) {
115
+ if ((_b = window.targetTab) == null ? void 0 : _b.id) {
91
116
  const tabId = window.targetTab.id;
92
117
  TabInfo.currentTabId = tabId;
93
118
  resolve(tabId);
@@ -97,48 +122,67 @@ function getInspectWindowTabId() {
97
122
  }
98
123
  });
99
124
  }
125
+ const refreshModuleInfo = () => __async(void 0, null, function* () {
126
+ var _a;
127
+ if (typeof window !== "undefined" && ((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo)) {
128
+ }
129
+ yield sleep(50);
130
+ const postMessageStartUrl = getUrl("post-message-start.js");
131
+ yield injectScript(injectPostMessage, false, postMessageStartUrl);
132
+ });
100
133
  const getGlobalModuleInfo = (callback) => __async(void 0, null, function* () {
134
+ var _a, _b;
135
+ if (typeof window !== "undefined" && ((_a = window.__FEDERATION__) == null ? void 0 : _a.moduleInfo)) {
136
+ callback(
137
+ JSON.parse(
138
+ JSON.stringify((_b = window.__FEDERATION__) == null ? void 0 : _b.moduleInfo)
139
+ )
140
+ );
141
+ }
101
142
  yield sleep(300);
102
- chrome.runtime.onMessage.addListener(
103
- (message) => {
104
- const { origin, data } = message;
105
- if (!data || (data == null ? void 0 : data.appInfos)) {
106
- return;
107
- }
108
- if (!(window == null ? void 0 : window.__FEDERATION__)) {
109
- definePropertyGlobalVal(window, "__FEDERATION__", {});
110
- definePropertyGlobalVal(window, "__VMOK__", window.__FEDERATION__);
111
- }
112
- window.__FEDERATION__.originModuleInfo = JSON.parse(
113
- JSON.stringify(data == null ? void 0 : data.moduleInfo)
143
+ const listener = (message) => {
144
+ const { data } = message;
145
+ if (!data || (data == null ? void 0 : data.appInfos)) {
146
+ return;
147
+ }
148
+ if (!(window == null ? void 0 : window.__FEDERATION__)) {
149
+ definePropertyGlobalVal(window, "__FEDERATION__", {});
150
+ definePropertyGlobalVal(window, "__VMOK__", window.__FEDERATION__);
151
+ }
152
+ window.__FEDERATION__.originModuleInfo = JSON.parse(
153
+ JSON.stringify(data == null ? void 0 : data.moduleInfo)
154
+ );
155
+ if (data == null ? void 0 : data.updateModule) {
156
+ const moduleIds = Object.keys(window.__FEDERATION__.originModuleInfo);
157
+ const shouldUpdate = !moduleIds.some(
158
+ (id) => id.includes(data.updateModule.name)
114
159
  );
115
- if (data == null ? void 0 : data.updateModule) {
116
- const moduleIds = Object.keys(window.__FEDERATION__.originModuleInfo);
117
- const shouldUpdate = !moduleIds.some(
118
- (id) => id.includes(data.updateModule.name)
119
- );
120
- if (shouldUpdate) {
121
- const destination = data.updateModule.entry || data.updateModule.version;
122
- window.__FEDERATION__.originModuleInfo[`${data.updateModule.name}:${destination}`] = {
123
- remoteEntry: destination,
124
- version: destination
125
- };
126
- }
160
+ if (shouldUpdate) {
161
+ const destination = data.updateModule.entry || data.updateModule.version;
162
+ window.__FEDERATION__.originModuleInfo[`${data.updateModule.name}:${destination}`] = {
163
+ remoteEntry: destination,
164
+ version: destination
165
+ };
127
166
  }
128
- window.__FEDERATION__.moduleInfo = JSON.parse(
129
- JSON.stringify(window.__FEDERATION__.originModuleInfo)
130
- );
131
- callback(window.__FEDERATION__.moduleInfo);
132
167
  }
133
- );
134
- const postMessageStartUrl = getUrl("post-message-start.js");
135
- yield injectScript(injectPostMessage, false, postMessageStartUrl);
168
+ if (data == null ? void 0 : data.share) {
169
+ window.__FEDERATION__.__SHARE__ = data.share;
170
+ }
171
+ window.__FEDERATION__.moduleInfo = JSON.parse(
172
+ JSON.stringify(window.__FEDERATION__.originModuleInfo)
173
+ );
174
+ console.log("getGlobalModuleInfo window", window.__FEDERATION__);
175
+ callback(window.__FEDERATION__.moduleInfo);
176
+ };
177
+ chrome.runtime.onMessage.addListener(listener);
178
+ yield refreshModuleInfo();
179
+ return () => chrome.runtime.onMessage.removeListener(listener);
136
180
  });
137
181
  const getTabs = (queryOptions = {}) => chrome.tabs.query(queryOptions);
138
182
  const getScope = () => __async(void 0, null, function* () {
139
183
  const activeTab = window.targetTab;
140
- const favIconUrl = activeTab == null ? void 0 : activeTab.favIconUrl;
141
- return favIconUrl || "noScope";
184
+ const tabId = activeTab == null ? void 0 : activeTab.id;
185
+ return tabId ? String(tabId) : "noScope";
142
186
  });
143
187
  const injectScript = (excuteScript, world = false, ...args) => __async(void 0, null, function* () {
144
188
  yield getInspectWindowTabId();
@@ -149,10 +193,16 @@ const injectScript = (excuteScript, world = false, ...args) => __async(void 0, n
149
193
  func: excuteScript,
150
194
  world: world ? "MAIN" : "ISOLATED",
151
195
  args
152
- }).then(() => {
196
+ }).then((results) => {
197
+ var _a;
153
198
  console.log("InjectScript success, excuteScript:", args);
199
+ if (Array.isArray(results) && results.length) {
200
+ return (_a = results[0]) == null ? void 0 : _a.result;
201
+ }
202
+ return void 0;
154
203
  }).catch((e) => {
155
204
  console.log(e, "InjectScript fail, excuteScript:", args);
205
+ return void 0;
156
206
  });
157
207
  });
158
208
  const getUrl = (file) => {
@@ -207,5 +257,8 @@ export {
207
257
  injectPostMessage,
208
258
  injectScript,
209
259
  injectToast,
210
- setChromeStorage
260
+ refreshModuleInfo,
261
+ setChromeStorage,
262
+ setTargetTab,
263
+ syncActiveTab
211
264
  };
@@ -0,0 +1,6 @@
1
+ const MESSAGE_OPEN_SIDE_PANEL = "mf-devtools/open-side-panel";
2
+ const MESSAGE_ACTIVE_TAB_CHANGED = "mf-devtools/active-tab-changed";
3
+ export {
4
+ MESSAGE_ACTIVE_TAB_CHANGED,
5
+ MESSAGE_OPEN_SIDE_PANEL
6
+ };
@@ -10,7 +10,8 @@ if (window.moduleHandler) {
10
10
  origin,
11
11
  data: {
12
12
  moduleInfo: data.moduleInfo,
13
- updateModule: data.updateModule
13
+ updateModule: data.updateModule,
14
+ share: data.share
14
15
  }
15
16
  }).catch(() => {
16
17
  return false;
@@ -1,8 +1,16 @@
1
- var _a;
1
+ var _a, _b;
2
2
  const moduleInfo = (_a = window == null ? void 0 : window.__FEDERATION__) == null ? void 0 : _a.moduleInfo;
3
3
  window.postMessage(
4
4
  {
5
- moduleInfo
5
+ moduleInfo,
6
+ share: JSON.parse(
7
+ JSON.stringify((_b = window == null ? void 0 : window.__FEDERATION__) == null ? void 0 : _b.__SHARE__, (_key, value) => {
8
+ if (typeof value === "function") {
9
+ return "Function";
10
+ }
11
+ return value;
12
+ })
13
+ )
6
14
  },
7
15
  "*"
8
16
  );
@@ -22,7 +22,8 @@ import {
22
22
  mergeLocalStorage,
23
23
  removeLocalStorageKey,
24
24
  removeLocalStorage,
25
- setLocalStorage
25
+ setLocalStorage,
26
+ getLocalStorage
26
27
  } from "../sdk";
27
28
  import { injectScript } from "./index";
28
29
  const mergeStorage = (...args) => __async(void 0, null, function* () {
@@ -37,7 +38,11 @@ const removeStorage = (...args) => __async(void 0, null, function* () {
37
38
  const setStorage = (...args) => __async(void 0, null, function* () {
38
39
  return injectScript(setLocalStorage, false, ...args);
39
40
  });
41
+ const getStorageValue = (...args) => __async(void 0, null, function* () {
42
+ return injectScript(getLocalStorage, false, ...args);
43
+ });
40
44
  export {
45
+ getStorageValue,
41
46
  mergeStorage,
42
47
  removeStorage,
43
48
  removeStorageKey,