@module-federation/devtools 2.3.3 → 2.5.0

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 (48) hide show
  1. package/README.md +3 -0
  2. package/dist/es/App.js +17 -2
  3. package/dist/es/App_module.css +3 -3
  4. package/dist/es/component/LoadingTrace/index.js +944 -0
  5. package/dist/es/component/LoadingTrace/index.module.js +5 -0
  6. package/dist/es/component/LoadingTrace/index_module.css +876 -0
  7. package/dist/es/i18n/index.js +178 -0
  8. package/dist/es/utils/chrome/fast-refresh.js +297 -173
  9. package/dist/es/utils/chrome/index.js +3 -4
  10. package/dist/es/utils/chrome/messages.js +7 -1
  11. package/dist/es/utils/chrome/observability-plugin.js +93 -0
  12. package/dist/es/utils/chrome/observability-shared.js +99 -0
  13. package/dist/es/utils/chrome/observability.js +208 -0
  14. package/dist/es/utils/chrome/override-remote.js +2 -42
  15. package/dist/es/utils/chrome/post-message-listener.js +14 -0
  16. package/dist/es/utils/chrome/snapshot-plugin.js +2 -36
  17. package/dist/es/utils/data/index.js +5 -25
  18. package/dist/es/vendor/basic-proxy-core.js +155 -0
  19. package/dist/es/worker/index.js +27 -8
  20. package/dist/lib/App.js +17 -2
  21. package/dist/lib/App_module.css +3 -3
  22. package/dist/lib/component/LoadingTrace/index.js +954 -0
  23. package/dist/lib/component/LoadingTrace/index.module.js +25 -0
  24. package/dist/lib/component/LoadingTrace/index_module.css +876 -0
  25. package/dist/lib/i18n/index.js +178 -0
  26. package/dist/lib/utils/chrome/fast-refresh.js +250 -135
  27. package/dist/lib/utils/chrome/index.js +3 -4
  28. package/dist/lib/utils/chrome/messages.js +11 -2
  29. package/dist/lib/utils/chrome/observability-plugin.js +86 -0
  30. package/dist/lib/utils/chrome/observability-shared.js +126 -0
  31. package/dist/lib/utils/chrome/observability.js +234 -0
  32. package/dist/lib/utils/chrome/override-remote.js +5 -52
  33. package/dist/lib/utils/chrome/post-message-listener.js +11 -0
  34. package/dist/lib/utils/chrome/snapshot-plugin.js +5 -46
  35. package/dist/lib/utils/data/index.js +6 -28
  36. package/dist/lib/vendor/basic-proxy-core.js +147 -0
  37. package/dist/lib/worker/index.js +27 -8
  38. package/dist/types/src/component/LoadingTrace/index.d.ts +6 -0
  39. package/dist/types/src/utils/chrome/messages.d.ts +3 -0
  40. package/dist/types/src/utils/chrome/observability-plugin.d.ts +1 -0
  41. package/dist/types/src/utils/chrome/observability-shared.d.ts +41 -0
  42. package/dist/types/src/utils/chrome/observability.d.ts +110 -0
  43. package/dist/types/src/utils/chrome/snapshot-plugin.d.ts +0 -3
  44. package/dist/types/src/utils/data/index.d.ts +0 -1
  45. package/package.json +4 -3
  46. package/dist/es/utils/data/snapshot.js +0 -82
  47. package/dist/lib/utils/data/snapshot.js +0 -107
  48. package/dist/types/src/utils/data/snapshot.d.ts +0 -3
@@ -19,13 +19,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var messages_exports = {};
20
20
  __export(messages_exports, {
21
21
  MESSAGE_ACTIVE_TAB_CHANGED: () => MESSAGE_ACTIVE_TAB_CHANGED,
22
- MESSAGE_OPEN_SIDE_PANEL: () => MESSAGE_OPEN_SIDE_PANEL
22
+ MESSAGE_OBSERVABILITY_DEVTOOLS_EVENT: () => MESSAGE_OBSERVABILITY_DEVTOOLS_EVENT,
23
+ MESSAGE_OPEN_SIDE_PANEL: () => MESSAGE_OPEN_SIDE_PANEL,
24
+ OBSERVABILITY_DEVTOOLS_SOURCE: () => OBSERVABILITY_DEVTOOLS_SOURCE,
25
+ OBSERVABILITY_DEVTOOLS_STORAGE_KEY: () => OBSERVABILITY_DEVTOOLS_STORAGE_KEY
23
26
  });
24
27
  module.exports = __toCommonJS(messages_exports);
25
28
  const MESSAGE_OPEN_SIDE_PANEL = "mf-devtools/open-side-panel";
26
29
  const MESSAGE_ACTIVE_TAB_CHANGED = "mf-devtools/active-tab-changed";
30
+ const MESSAGE_OBSERVABILITY_DEVTOOLS_EVENT = "mf-devtools/observability-event";
31
+ const OBSERVABILITY_DEVTOOLS_SOURCE = "module-federation/observability";
32
+ const OBSERVABILITY_DEVTOOLS_STORAGE_KEY = "__MF_DEVTOOLS_OBSERVABILITY_CONFIG__";
27
33
  // Annotate the CommonJS export names for ESM import in node:
28
34
  0 && (module.exports = {
29
35
  MESSAGE_ACTIVE_TAB_CHANGED,
30
- MESSAGE_OPEN_SIDE_PANEL
36
+ MESSAGE_OBSERVABILITY_DEVTOOLS_EVENT,
37
+ MESSAGE_OPEN_SIDE_PANEL,
38
+ OBSERVABILITY_DEVTOOLS_SOURCE,
39
+ OBSERVABILITY_DEVTOOLS_STORAGE_KEY
31
40
  });
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var import_chrome_devtool = require("@module-federation/observability-plugin/chrome-devtool");
3
+ var import_messages = require("./messages");
4
+ var import_observability_shared = require("./observability-shared");
5
+ const DEVTOOLS_PLUGIN_NAME = "observability-plugin:chrome-extension";
6
+ const LEGACY_DEVTOOLS_PLUGIN_NAME = "observability-plugin-devtools";
7
+ const getFederationWindow = () => window;
8
+ const safeReadStoredConfig = () => {
9
+ var _a;
10
+ try {
11
+ const raw = (_a = window.localStorage) == null ? void 0 : _a.getItem(
12
+ import_messages.OBSERVABILITY_DEVTOOLS_STORAGE_KEY
13
+ );
14
+ if (!raw) {
15
+ return void 0;
16
+ }
17
+ return (0, import_observability_shared.normalizeObservabilityDevtoolsConfig)(JSON.parse(raw));
18
+ } catch (e) {
19
+ return void 0;
20
+ }
21
+ };
22
+ const defineWritableGlobal = (key, value) => {
23
+ const targetWindow = getFederationWindow();
24
+ try {
25
+ Object.defineProperty(targetWindow, key, {
26
+ value,
27
+ configurable: true,
28
+ writable: true
29
+ });
30
+ } catch (e) {
31
+ targetWindow[key] = value;
32
+ }
33
+ };
34
+ const ensureFederationGlobal = () => {
35
+ var _a;
36
+ const targetWindow = getFederationWindow();
37
+ const federation = targetWindow.__FEDERATION__ || targetWindow.__VMOK__ || {};
38
+ if (!targetWindow.__FEDERATION__) {
39
+ defineWritableGlobal("__FEDERATION__", federation);
40
+ }
41
+ if (!targetWindow.__VMOK__) {
42
+ defineWritableGlobal("__VMOK__", targetWindow.__FEDERATION__);
43
+ }
44
+ if (!((_a = targetWindow.__FEDERATION__) == null ? void 0 : _a.__GLOBAL_PLUGIN__)) {
45
+ targetWindow.__FEDERATION__ = targetWindow.__FEDERATION__ || federation;
46
+ targetWindow.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
47
+ }
48
+ return targetWindow.__FEDERATION__;
49
+ };
50
+ const notifyInstalled = (status, reason, config) => {
51
+ try {
52
+ window.postMessage(
53
+ {
54
+ schemaVersion: 1,
55
+ source: import_messages.OBSERVABILITY_DEVTOOLS_SOURCE,
56
+ kind: status,
57
+ reason,
58
+ config,
59
+ createdAt: Date.now()
60
+ },
61
+ "*"
62
+ );
63
+ } catch (e) {
64
+ }
65
+ };
66
+ const install = () => {
67
+ const config = safeReadStoredConfig();
68
+ if (!(config == null ? void 0 : config.enabled)) {
69
+ return;
70
+ }
71
+ const federation = ensureFederationGlobal();
72
+ const globalPlugins = (federation == null ? void 0 : federation.__GLOBAL_PLUGIN__) || [];
73
+ if (globalPlugins.some(
74
+ (plugin2) => (plugin2 == null ? void 0 : plugin2.name) === DEVTOOLS_PLUGIN_NAME || (plugin2 == null ? void 0 : plugin2.name) === LEGACY_DEVTOOLS_PLUGIN_NAME
75
+ )) {
76
+ notifyInstalled("skipped", "already-installed", config);
77
+ return;
78
+ }
79
+ const plugin = (0, import_chrome_devtool.ChromeObservabilityPlugin)(
80
+ (0, import_observability_shared.createObservabilityPluginOptions)(config)
81
+ );
82
+ globalPlugins.push(plugin);
83
+ federation.__GLOBAL_PLUGIN__ = globalPlugins;
84
+ notifyInstalled("installed", void 0, config);
85
+ };
86
+ install();
@@ -0,0 +1,126 @@
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 observability_shared_exports = {};
20
+ __export(observability_shared_exports, {
21
+ CHROME_OBSERVABILITY_SCOPE: () => CHROME_OBSERVABILITY_SCOPE,
22
+ DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG: () => DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG,
23
+ createObservabilityPluginOptions: () => createObservabilityPluginOptions,
24
+ normalizeObservabilityDevtoolsConfig: () => normalizeObservabilityDevtoolsConfig
25
+ });
26
+ module.exports = __toCommonJS(observability_shared_exports);
27
+ var import_messages = require("./messages");
28
+ const CHROME_OBSERVABILITY_SCOPE = "chrome_extension";
29
+ const MIN_EVENTS = 10;
30
+ const MAX_EVENTS = 1e3;
31
+ const DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG = {
32
+ enabled: true,
33
+ level: "verbose",
34
+ maxEvents: 300,
35
+ console: true,
36
+ browser: {
37
+ enabled: true,
38
+ scope: CHROME_OBSERVABILITY_SCOPE,
39
+ mode: "development"
40
+ },
41
+ trace: {
42
+ printStart: true
43
+ },
44
+ react: {
45
+ injectLoadedCallback: false,
46
+ remoteIds: []
47
+ }
48
+ };
49
+ const isObject = (value) => typeof value === "object" && value !== null;
50
+ const normalizeBoolean = (value, fallback) => typeof value === "boolean" ? value : fallback;
51
+ const normalizeLevel = (value) => value === "error" || value === "summary" || value === "verbose" ? value : DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.level;
52
+ const normalizeMode = (value) => value === "production" || value === "development" ? value : DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.browser.mode;
53
+ const normalizeMaxEvents = (value) => {
54
+ const parsed = Number(value);
55
+ if (!Number.isFinite(parsed)) {
56
+ return DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.maxEvents;
57
+ }
58
+ return Math.max(MIN_EVENTS, Math.min(MAX_EVENTS, Math.floor(parsed)));
59
+ };
60
+ const normalizeScope = (value) => {
61
+ if (typeof value !== "string") {
62
+ return CHROME_OBSERVABILITY_SCOPE;
63
+ }
64
+ const trimmed = value.trim().replace(/[^\w:@.-]+/g, "-");
65
+ return trimmed || CHROME_OBSERVABILITY_SCOPE;
66
+ };
67
+ const normalizeObservabilityDevtoolsConfig = (value) => {
68
+ const source = isObject(value) ? value : {};
69
+ const browser = isObject(source.browser) ? source.browser : {};
70
+ const trace = isObject(source.trace) ? source.trace : {};
71
+ return {
72
+ enabled: normalizeBoolean(
73
+ source.enabled,
74
+ DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.enabled
75
+ ),
76
+ level: normalizeLevel(source.level),
77
+ maxEvents: normalizeMaxEvents(source.maxEvents),
78
+ console: normalizeBoolean(
79
+ source.console,
80
+ DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.console
81
+ ),
82
+ browser: {
83
+ enabled: normalizeBoolean(
84
+ browser.enabled,
85
+ DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.browser.enabled
86
+ ),
87
+ scope: normalizeScope(browser.scope),
88
+ mode: normalizeMode(browser.mode)
89
+ },
90
+ trace: {
91
+ printStart: normalizeBoolean(
92
+ trace.printStart,
93
+ DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.trace.printStart
94
+ )
95
+ },
96
+ react: {
97
+ injectLoadedCallback: false,
98
+ remoteIds: []
99
+ }
100
+ };
101
+ };
102
+ const createObservabilityPluginOptions = (config) => ({
103
+ enabled: config.enabled,
104
+ level: config.level,
105
+ maxEvents: config.maxEvents,
106
+ console: config.console,
107
+ browser: {
108
+ enabled: config.browser.enabled,
109
+ scope: config.browser.scope,
110
+ mode: config.browser.mode
111
+ },
112
+ trace: {
113
+ printStart: config.trace.printStart
114
+ },
115
+ devtools: {
116
+ enabled: true,
117
+ source: import_messages.OBSERVABILITY_DEVTOOLS_SOURCE
118
+ }
119
+ });
120
+ // Annotate the CommonJS export names for ESM import in node:
121
+ 0 && (module.exports = {
122
+ CHROME_OBSERVABILITY_SCOPE,
123
+ DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG,
124
+ createObservabilityPluginOptions,
125
+ normalizeObservabilityDevtoolsConfig
126
+ });
@@ -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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var import_helpers = __toESM(require("@module-federation/runtime/helpers"));
25
- var import_sdk = require("../sdk");
26
- var import_template = require("../../template");
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_template.__FEDERATION_DEVTOOLS__
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_sdk.definePropertyGlobalVal)(window, "__FEDERATION__", {});
60
- (0, import_sdk.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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var import_sdk = require("@module-federation/sdk");
25
- var import_helpers = __toESM(require("@module-federation/runtime/helpers"));
26
- var import_sdk2 = require("../sdk");
27
- var _a;
28
- const chromeDevtoolsPlugin = function() {
29
- return {
30
- name: "mf-chrome-devtools-inject-snapshot-plugin",
31
- beforeLoadRemoteSnapshot({ options }) {
32
- const { nativeGlobal } = import_helpers.default.global;
33
- if (!options || 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
- var import_snapshot = require("./snapshot");
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
- let freshModuleInfo;
78
- const { moduleInfo } = window.__FEDERATION__;
79
- const { consumers } = separateType(moduleInfo);
80
- const overrides = {};
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
  });