@module-federation/devtools 0.0.0-perf-devtools-20260107043700 → 0.0.0-perf-website-code-usage-20260914033703

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 (203) hide show
  1. package/README.md +3 -0
  2. package/dist/es/App.css +6 -5
  3. package/dist/es/App.js +211 -63
  4. package/dist/es/App.module.js +1 -1
  5. package/dist/es/App_module.css +41 -39
  6. package/dist/es/component/DependencyGraph/index.js +11 -12
  7. package/dist/es/component/DependencyGraph/index_module.css +20 -17
  8. package/dist/es/component/DependencyGraphItem/index.js +23 -10
  9. package/dist/es/component/DependencyGraphItem/index_module.css +7 -7
  10. package/dist/es/component/Form/index.js +24 -31
  11. package/dist/es/component/Form/index.module.js +1 -1
  12. package/dist/es/component/Form/index_module.css +22 -25
  13. package/dist/es/component/LanguageSwitch.js +50 -0
  14. package/dist/es/component/Layout/index.js +27 -10
  15. package/dist/es/component/Layout/index_module.css +7 -7
  16. package/dist/es/component/LoadingTrace/index.js +944 -0
  17. package/dist/es/component/LoadingTrace/index.module.js +5 -0
  18. package/dist/es/component/LoadingTrace/index_module.css +876 -0
  19. package/dist/es/component/ModuleInfo/index.js +65 -41
  20. package/dist/es/component/ModuleInfo/index_module.css +12 -11
  21. package/dist/es/component/SharedDepsExplorer/FocusResultDisplay.js +5 -3
  22. package/dist/es/component/SharedDepsExplorer/FocusResultDisplay_module.css +5 -5
  23. package/dist/es/component/SharedDepsExplorer/index.js +223 -96
  24. package/dist/es/component/SharedDepsExplorer/index_module.css +12 -2
  25. package/dist/es/component/SharedDepsExplorer/share-utils.js +21 -5
  26. package/dist/es/component/ThemeToggle.js +19 -0
  27. package/dist/es/component/ThemeToggle.module.js +5 -0
  28. package/dist/es/component/ThemeToggle_module.css +12 -0
  29. package/dist/es/hooks/useDevtoolsTheme.js +77 -0
  30. package/dist/es/i18n/index.js +688 -0
  31. package/dist/es/utils/chrome/fast-refresh.js +297 -173
  32. package/dist/es/utils/chrome/index.js +42 -22
  33. package/dist/es/utils/chrome/messages.js +7 -1
  34. package/dist/es/utils/chrome/observability-plugin.js +93 -0
  35. package/dist/es/utils/chrome/observability-shared.js +99 -0
  36. package/dist/es/utils/chrome/observability.js +208 -0
  37. package/dist/es/utils/chrome/override-remote.js +7 -0
  38. package/dist/es/utils/chrome/post-message-listener.js +22 -4
  39. package/dist/es/utils/chrome/post-message-start.js +4 -10
  40. package/dist/es/utils/chrome/post-message.js +12 -3
  41. package/dist/es/utils/chrome/resolve-basic-proxy-core.js +4 -0
  42. package/dist/es/utils/chrome/safe-post-message.js +124 -0
  43. package/dist/es/utils/chrome/snapshot-plugin.js +2 -36
  44. package/dist/es/utils/data/index.js +5 -25
  45. package/dist/es/utils/sdk/graph.js +25 -11
  46. package/dist/es/vendor/basic-proxy-core.js +155 -0
  47. package/dist/es/worker/index.js +27 -8
  48. package/dist/lib/App.css +6 -5
  49. package/dist/lib/App.js +208 -64
  50. package/dist/lib/App.module.js +1 -2
  51. package/dist/lib/App_module.css +41 -39
  52. package/dist/lib/component/DependencyGraph/index.js +11 -13
  53. package/dist/lib/component/DependencyGraph/index.module.js +0 -1
  54. package/dist/lib/component/DependencyGraph/index_module.css +20 -17
  55. package/dist/lib/component/DependencyGraphItem/index.js +23 -11
  56. package/dist/lib/component/DependencyGraphItem/index.module.js +0 -1
  57. package/dist/lib/component/DependencyGraphItem/index_module.css +7 -7
  58. package/dist/lib/component/Form/index.js +24 -32
  59. package/dist/lib/component/Form/index.module.js +1 -2
  60. package/dist/lib/component/Form/index_module.css +22 -25
  61. package/dist/lib/component/LanguageSwitch.js +79 -0
  62. package/dist/lib/component/Layout/index.js +27 -11
  63. package/dist/lib/component/Layout/index.module.js +0 -1
  64. package/dist/lib/component/Layout/index_module.css +7 -7
  65. package/dist/lib/component/LoadingTrace/index.js +953 -0
  66. package/dist/lib/component/LoadingTrace/index.module.js +24 -0
  67. package/dist/lib/component/LoadingTrace/index_module.css +876 -0
  68. package/dist/lib/component/ModuleInfo/index.js +65 -42
  69. package/dist/lib/component/ModuleInfo/index.module.js +0 -1
  70. package/dist/lib/component/ModuleInfo/index_module.css +12 -11
  71. package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.js +5 -4
  72. package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay.module.js +0 -1
  73. package/dist/lib/component/SharedDepsExplorer/FocusResultDisplay_module.css +5 -5
  74. package/dist/lib/component/SharedDepsExplorer/index.js +217 -95
  75. package/dist/lib/component/SharedDepsExplorer/index.module.js +0 -1
  76. package/dist/lib/component/SharedDepsExplorer/index_module.css +12 -2
  77. package/dist/lib/component/SharedDepsExplorer/share-utils.js +21 -6
  78. package/dist/lib/component/ThemeToggle.js +48 -0
  79. package/dist/lib/component/ThemeToggle.module.js +24 -0
  80. package/dist/lib/component/ThemeToggle_module.css +12 -0
  81. package/dist/lib/hooks/useDevtoolsTheme.js +100 -0
  82. package/dist/lib/i18n/index.js +721 -0
  83. package/dist/lib/init.js +0 -1
  84. package/dist/lib/template/constant.js +0 -1
  85. package/dist/lib/template/index.js +0 -1
  86. package/dist/lib/utils/chrome/fast-refresh.js +250 -136
  87. package/dist/lib/utils/chrome/index.js +43 -23
  88. package/dist/lib/utils/chrome/messages.js +11 -3
  89. package/dist/lib/utils/chrome/observability-plugin.js +85 -0
  90. package/dist/lib/utils/chrome/observability-shared.js +125 -0
  91. package/dist/lib/utils/chrome/observability.js +233 -0
  92. package/dist/lib/utils/chrome/override-remote.js +20 -0
  93. package/dist/lib/utils/chrome/post-message-init.js +0 -1
  94. package/dist/lib/utils/chrome/post-message-listener.js +19 -5
  95. package/dist/lib/utils/chrome/post-message-start.js +4 -11
  96. package/dist/lib/utils/chrome/post-message.js +12 -4
  97. package/dist/lib/utils/chrome/resolve-basic-proxy-core.js +27 -0
  98. package/dist/lib/utils/chrome/safe-post-message.js +147 -0
  99. package/dist/lib/utils/chrome/snapshot-plugin.js +5 -47
  100. package/dist/lib/utils/chrome/storage.js +0 -1
  101. package/dist/lib/utils/data/index.js +6 -29
  102. package/dist/lib/utils/index.js +0 -1
  103. package/dist/lib/utils/sdk/graph.js +25 -12
  104. package/dist/lib/utils/sdk/index.js +0 -1
  105. package/dist/lib/utils/types/common.js +0 -1
  106. package/dist/lib/utils/types/index.js +0 -1
  107. package/dist/lib/vendor/basic-proxy-core.js +147 -0
  108. package/dist/lib/worker/index.js +27 -9
  109. package/dist/types/App.css +13 -0
  110. package/dist/types/App.js +519 -0
  111. package/dist/types/App.module.js +24 -0
  112. package/dist/types/App_module.css +307 -0
  113. package/dist/types/component/DependencyGraph/index.js +225 -0
  114. package/dist/types/component/DependencyGraph/index.module.js +24 -0
  115. package/dist/types/component/DependencyGraph/index_module.css +100 -0
  116. package/dist/types/component/DependencyGraphItem/index.js +124 -0
  117. package/dist/types/component/DependencyGraphItem/index.module.js +24 -0
  118. package/dist/types/component/DependencyGraphItem/index_module.css +95 -0
  119. package/dist/types/component/Form/index.js +372 -0
  120. package/dist/types/component/Form/index.module.js +24 -0
  121. package/dist/types/component/Form/index_module.css +198 -0
  122. package/dist/types/component/LanguageSwitch.js +79 -0
  123. package/dist/types/component/Layout/index.js +471 -0
  124. package/dist/types/component/Layout/index.module.js +24 -0
  125. package/dist/types/component/Layout/index_module.css +68 -0
  126. package/dist/types/component/LoadingTrace/index.js +953 -0
  127. package/dist/types/component/LoadingTrace/index.module.js +24 -0
  128. package/dist/types/component/LoadingTrace/index_module.css +876 -0
  129. package/dist/types/component/ModuleInfo/index.js +342 -0
  130. package/dist/types/component/ModuleInfo/index.module.js +24 -0
  131. package/dist/types/component/ModuleInfo/index_module.css +184 -0
  132. package/dist/types/component/SharedDepsExplorer/FocusResultDisplay.js +64 -0
  133. package/dist/types/component/SharedDepsExplorer/FocusResultDisplay.module.js +24 -0
  134. package/dist/types/component/SharedDepsExplorer/FocusResultDisplay_module.css +45 -0
  135. package/dist/types/component/SharedDepsExplorer/index.js +635 -0
  136. package/dist/types/component/SharedDepsExplorer/index.module.js +24 -0
  137. package/dist/types/component/SharedDepsExplorer/index_module.css +467 -0
  138. package/dist/types/component/SharedDepsExplorer/share-utils.js +252 -0
  139. package/dist/types/component/ThemeToggle.js +48 -0
  140. package/dist/types/component/ThemeToggle.module.js +24 -0
  141. package/dist/types/component/ThemeToggle_module.css +12 -0
  142. package/dist/types/hooks/useDevtoolsTheme.js +100 -0
  143. package/dist/types/i18n/index.js +721 -0
  144. package/dist/types/init.js +8 -0
  145. package/dist/types/src/App.d.ts +1 -1
  146. package/dist/types/src/component/DependencyGraph/index.d.ts +1 -1
  147. package/dist/types/src/component/DependencyGraphItem/index.d.ts +1 -1
  148. package/dist/types/src/component/Form/index.d.ts +1 -1
  149. package/dist/types/src/component/LanguageSwitch.d.ts +2 -0
  150. package/dist/types/src/component/Layout/index.d.ts +1 -1
  151. package/dist/types/src/component/LoadingTrace/index.d.ts +6 -0
  152. package/dist/types/src/component/ModuleInfo/index.d.ts +1 -1
  153. package/dist/types/src/component/SharedDepsExplorer/index.d.ts +1 -1
  154. package/dist/types/src/component/SharedDepsExplorer/share-utils.d.ts +3 -2
  155. package/dist/types/src/component/ThemeToggle.d.ts +8 -0
  156. package/dist/types/src/hooks/useDevtoolsTheme.d.ts +2 -0
  157. package/dist/types/src/i18n/index.d.ts +5 -0
  158. package/dist/types/src/template/constant.d.ts +1 -1
  159. package/dist/types/src/utils/chrome/index.d.ts +2 -1
  160. package/dist/types/src/utils/chrome/messages.d.ts +3 -0
  161. package/dist/types/src/utils/chrome/observability-plugin.d.ts +1 -0
  162. package/dist/types/src/utils/chrome/observability-shared.d.ts +41 -0
  163. package/dist/types/src/utils/chrome/observability.d.ts +110 -0
  164. package/dist/types/src/utils/chrome/override-remote.d.ts +1 -0
  165. package/dist/types/src/utils/chrome/post-message-listener.d.ts +1 -0
  166. package/dist/types/src/utils/chrome/post-message-start.d.ts +1 -1
  167. package/dist/types/src/utils/chrome/resolve-basic-proxy-core.d.ts +6 -0
  168. package/dist/types/src/utils/chrome/safe-post-message.d.ts +1 -0
  169. package/dist/types/src/utils/chrome/snapshot-plugin.d.ts +0 -3
  170. package/dist/types/src/utils/data/index.d.ts +1 -2
  171. package/dist/types/src/utils/sdk/graph.d.ts +1 -1
  172. package/dist/types/src/utils/sdk/index.d.ts +2 -2
  173. package/dist/types/stories/index.stories.d.ts +2 -1
  174. package/dist/types/template/constant.js +84 -0
  175. package/dist/types/template/index.js +21 -0
  176. package/dist/types/utils/chrome/fast-refresh.js +329 -0
  177. package/dist/types/utils/chrome/index.js +321 -0
  178. package/dist/types/utils/chrome/messages.js +39 -0
  179. package/dist/types/utils/chrome/observability-plugin.js +85 -0
  180. package/dist/types/utils/chrome/observability-shared.js +125 -0
  181. package/dist/types/utils/chrome/observability.js +233 -0
  182. package/dist/types/utils/chrome/override-remote.js +20 -0
  183. package/dist/types/utils/chrome/post-message-init.js +5 -0
  184. package/dist/types/utils/chrome/post-message-listener.js +36 -0
  185. package/dist/types/utils/chrome/post-message-start.js +10 -0
  186. package/dist/types/utils/chrome/post-message.js +91 -0
  187. package/dist/types/utils/chrome/resolve-basic-proxy-core.js +27 -0
  188. package/dist/types/utils/chrome/safe-post-message.js +147 -0
  189. package/dist/types/utils/chrome/snapshot-plugin.js +17 -0
  190. package/dist/types/utils/chrome/storage.js +71 -0
  191. package/dist/types/utils/data/index.js +83 -0
  192. package/dist/types/utils/index.js +27 -0
  193. package/dist/types/utils/sdk/graph.js +213 -0
  194. package/dist/types/utils/sdk/index.js +104 -0
  195. package/dist/types/utils/types/common.js +15 -0
  196. package/dist/types/utils/types/index.js +21 -0
  197. package/dist/types/vendor/basic-proxy-core.js +147 -0
  198. package/dist/types/worker/index.js +175 -0
  199. package/install-deps.bash +7 -3
  200. package/package.json +47 -28
  201. package/dist/es/utils/data/snapshot.js +0 -82
  202. package/dist/lib/utils/data/snapshot.js +0 -107
  203. package/dist/types/src/utils/data/snapshot.d.ts +0 -3
@@ -0,0 +1,85 @@
1
+ var import_chrome_devtool = require("@module-federation/observability-plugin/chrome-devtool");
2
+ var import_messages = require("./messages");
3
+ var import_observability_shared = require("./observability-shared");
4
+ const DEVTOOLS_PLUGIN_NAME = "observability-plugin:chrome-extension";
5
+ const LEGACY_DEVTOOLS_PLUGIN_NAME = "observability-plugin-devtools";
6
+ const getFederationWindow = () => window;
7
+ const safeReadStoredConfig = () => {
8
+ var _a;
9
+ try {
10
+ const raw = (_a = window.localStorage) == null ? void 0 : _a.getItem(
11
+ import_messages.OBSERVABILITY_DEVTOOLS_STORAGE_KEY
12
+ );
13
+ if (!raw) {
14
+ return void 0;
15
+ }
16
+ return (0, import_observability_shared.normalizeObservabilityDevtoolsConfig)(JSON.parse(raw));
17
+ } catch (e) {
18
+ return void 0;
19
+ }
20
+ };
21
+ const defineWritableGlobal = (key, value) => {
22
+ const targetWindow = getFederationWindow();
23
+ try {
24
+ Object.defineProperty(targetWindow, key, {
25
+ value,
26
+ configurable: true,
27
+ writable: true
28
+ });
29
+ } catch (e) {
30
+ targetWindow[key] = value;
31
+ }
32
+ };
33
+ const ensureFederationGlobal = () => {
34
+ var _a;
35
+ const targetWindow = getFederationWindow();
36
+ const federation = targetWindow.__FEDERATION__ || targetWindow.__VMOK__ || {};
37
+ if (!targetWindow.__FEDERATION__) {
38
+ defineWritableGlobal("__FEDERATION__", federation);
39
+ }
40
+ if (!targetWindow.__VMOK__) {
41
+ defineWritableGlobal("__VMOK__", targetWindow.__FEDERATION__);
42
+ }
43
+ if (!((_a = targetWindow.__FEDERATION__) == null ? void 0 : _a.__GLOBAL_PLUGIN__)) {
44
+ targetWindow.__FEDERATION__ = targetWindow.__FEDERATION__ || federation;
45
+ targetWindow.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
46
+ }
47
+ return targetWindow.__FEDERATION__;
48
+ };
49
+ const notifyInstalled = (status, reason, config) => {
50
+ try {
51
+ window.postMessage(
52
+ {
53
+ schemaVersion: 1,
54
+ source: import_messages.OBSERVABILITY_DEVTOOLS_SOURCE,
55
+ kind: status,
56
+ reason,
57
+ config,
58
+ createdAt: Date.now()
59
+ },
60
+ "*"
61
+ );
62
+ } catch (e) {
63
+ }
64
+ };
65
+ const install = () => {
66
+ const config = safeReadStoredConfig();
67
+ if (!(config == null ? void 0 : config.enabled)) {
68
+ return;
69
+ }
70
+ const federation = ensureFederationGlobal();
71
+ const globalPlugins = (federation == null ? void 0 : federation.__GLOBAL_PLUGIN__) || [];
72
+ if (globalPlugins.some(
73
+ (plugin2) => (plugin2 == null ? void 0 : plugin2.name) === DEVTOOLS_PLUGIN_NAME || (plugin2 == null ? void 0 : plugin2.name) === LEGACY_DEVTOOLS_PLUGIN_NAME
74
+ )) {
75
+ notifyInstalled("skipped", "already-installed", config);
76
+ return;
77
+ }
78
+ const plugin = (0, import_chrome_devtool.ChromeObservabilityPlugin)(
79
+ (0, import_observability_shared.createObservabilityPluginOptions)(config)
80
+ );
81
+ globalPlugins.push(plugin);
82
+ federation.__GLOBAL_PLUGIN__ = globalPlugins;
83
+ notifyInstalled("installed", void 0, config);
84
+ };
85
+ install();
@@ -0,0 +1,125 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var observability_shared_exports = {};
19
+ __export(observability_shared_exports, {
20
+ CHROME_OBSERVABILITY_SCOPE: () => CHROME_OBSERVABILITY_SCOPE,
21
+ DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG: () => DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG,
22
+ createObservabilityPluginOptions: () => createObservabilityPluginOptions,
23
+ normalizeObservabilityDevtoolsConfig: () => normalizeObservabilityDevtoolsConfig
24
+ });
25
+ module.exports = __toCommonJS(observability_shared_exports);
26
+ var import_messages = require("./messages");
27
+ const CHROME_OBSERVABILITY_SCOPE = "chrome_extension";
28
+ const MIN_EVENTS = 10;
29
+ const MAX_EVENTS = 1e3;
30
+ const DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG = {
31
+ enabled: true,
32
+ level: "verbose",
33
+ maxEvents: 300,
34
+ console: true,
35
+ browser: {
36
+ enabled: true,
37
+ scope: CHROME_OBSERVABILITY_SCOPE,
38
+ mode: "development"
39
+ },
40
+ trace: {
41
+ printStart: true
42
+ },
43
+ react: {
44
+ injectLoadedCallback: false,
45
+ remoteIds: []
46
+ }
47
+ };
48
+ const isObject = (value) => typeof value === "object" && value !== null;
49
+ const normalizeBoolean = (value, fallback) => typeof value === "boolean" ? value : fallback;
50
+ const normalizeLevel = (value) => value === "error" || value === "summary" || value === "verbose" ? value : DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.level;
51
+ const normalizeMode = (value) => value === "production" || value === "development" ? value : DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.browser.mode;
52
+ const normalizeMaxEvents = (value) => {
53
+ const parsed = Number(value);
54
+ if (!Number.isFinite(parsed)) {
55
+ return DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.maxEvents;
56
+ }
57
+ return Math.max(MIN_EVENTS, Math.min(MAX_EVENTS, Math.floor(parsed)));
58
+ };
59
+ const normalizeScope = (value) => {
60
+ if (typeof value !== "string") {
61
+ return CHROME_OBSERVABILITY_SCOPE;
62
+ }
63
+ const trimmed = value.trim().replace(/[^\w:@.-]+/g, "-");
64
+ return trimmed || CHROME_OBSERVABILITY_SCOPE;
65
+ };
66
+ const normalizeObservabilityDevtoolsConfig = (value) => {
67
+ const source = isObject(value) ? value : {};
68
+ const browser = isObject(source.browser) ? source.browser : {};
69
+ const trace = isObject(source.trace) ? source.trace : {};
70
+ return {
71
+ enabled: normalizeBoolean(
72
+ source.enabled,
73
+ DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.enabled
74
+ ),
75
+ level: normalizeLevel(source.level),
76
+ maxEvents: normalizeMaxEvents(source.maxEvents),
77
+ console: normalizeBoolean(
78
+ source.console,
79
+ DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.console
80
+ ),
81
+ browser: {
82
+ enabled: normalizeBoolean(
83
+ browser.enabled,
84
+ DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.browser.enabled
85
+ ),
86
+ scope: normalizeScope(browser.scope),
87
+ mode: normalizeMode(browser.mode)
88
+ },
89
+ trace: {
90
+ printStart: normalizeBoolean(
91
+ trace.printStart,
92
+ DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG.trace.printStart
93
+ )
94
+ },
95
+ react: {
96
+ injectLoadedCallback: false,
97
+ remoteIds: []
98
+ }
99
+ };
100
+ };
101
+ const createObservabilityPluginOptions = (config) => ({
102
+ enabled: config.enabled,
103
+ level: config.level,
104
+ maxEvents: config.maxEvents,
105
+ console: config.console,
106
+ browser: {
107
+ enabled: config.browser.enabled,
108
+ scope: config.browser.scope,
109
+ mode: config.browser.mode
110
+ },
111
+ trace: {
112
+ printStart: config.trace.printStart
113
+ },
114
+ devtools: {
115
+ enabled: true,
116
+ source: import_messages.OBSERVABILITY_DEVTOOLS_SOURCE
117
+ }
118
+ });
119
+ // Annotate the CommonJS export names for ESM import in node:
120
+ 0 && (module.exports = {
121
+ CHROME_OBSERVABILITY_SCOPE,
122
+ DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG,
123
+ createObservabilityPluginOptions,
124
+ normalizeObservabilityDevtoolsConfig
125
+ });
@@ -0,0 +1,233 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __async = (__this, __arguments, generator) => {
19
+ return new Promise((resolve, reject) => {
20
+ var fulfilled = (value) => {
21
+ try {
22
+ step(generator.next(value));
23
+ } catch (e) {
24
+ reject(e);
25
+ }
26
+ };
27
+ var rejected = (value) => {
28
+ try {
29
+ step(generator.throw(value));
30
+ } catch (e) {
31
+ reject(e);
32
+ }
33
+ };
34
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
35
+ step((generator = generator.apply(__this, __arguments)).next());
36
+ });
37
+ };
38
+ var observability_exports = {};
39
+ __export(observability_exports, {
40
+ applyObservabilityConfig: () => applyObservabilityConfig,
41
+ disableObservabilityConfig: () => disableObservabilityConfig,
42
+ getObservabilityReportScopeLabel: () => getObservabilityReportScopeLabel,
43
+ mergeObservabilityReports: () => mergeObservabilityReports,
44
+ readObservabilityConfig: () => readObservabilityConfig,
45
+ readObservabilitySnapshot: () => readObservabilitySnapshot,
46
+ reloadInspectedPage: () => reloadInspectedPage
47
+ });
48
+ module.exports = __toCommonJS(observability_exports);
49
+ var import_index = require("./index");
50
+ var import_messages = require("./messages");
51
+ var import_observability_shared = require("./observability-shared");
52
+ const USER_OBSERVABILITY_PLUGIN_NAME = "observability-plugin";
53
+ const CHROME_OBSERVABILITY_PLUGIN_NAME = "observability-plugin:chrome-extension";
54
+ const LEGACY_CHROME_OBSERVABILITY_PLUGIN_NAME = "observability-plugin-devtools";
55
+ const OBSERVABILITY_SNAPSHOT_CONTEXT = {
56
+ chromeScope: import_observability_shared.CHROME_OBSERVABILITY_SCOPE,
57
+ userPluginName: USER_OBSERVABILITY_PLUGIN_NAME,
58
+ chromePluginNames: [
59
+ CHROME_OBSERVABILITY_PLUGIN_NAME,
60
+ LEGACY_CHROME_OBSERVABILITY_PLUGIN_NAME
61
+ ]
62
+ };
63
+ const readConfigFromPage = (storageKey) => {
64
+ var _a;
65
+ try {
66
+ const raw = (_a = window.localStorage) == null ? void 0 : _a.getItem(storageKey);
67
+ return raw ? JSON.parse(raw) : null;
68
+ } catch (e) {
69
+ return null;
70
+ }
71
+ };
72
+ const writeConfigToPage = (storageKey, config) => {
73
+ var _a;
74
+ (_a = window.localStorage) == null ? void 0 : _a.setItem(storageKey, JSON.stringify(config));
75
+ return config;
76
+ };
77
+ const removeConfigFromPage = (storageKey) => {
78
+ var _a;
79
+ (_a = window.localStorage) == null ? void 0 : _a.removeItem(storageKey);
80
+ return true;
81
+ };
82
+ const reloadPage = () => {
83
+ var _a;
84
+ (_a = globalThis.location) == null ? void 0 : _a.reload();
85
+ };
86
+ const readSnapshotFromPage = (storageKey, context) => {
87
+ const chromeScope = typeof (context == null ? void 0 : context.chromeScope) === "string" ? context.chromeScope : "chrome_extension";
88
+ const userPluginName = typeof (context == null ? void 0 : context.userPluginName) === "string" ? context.userPluginName : "observability-plugin";
89
+ const chromePluginNames = Array.isArray(context == null ? void 0 : context.chromePluginNames) ? context.chromePluginNames : [
90
+ "observability-plugin:chrome-extension",
91
+ "observability-plugin-devtools"
92
+ ];
93
+ const safeCopy = (value) => {
94
+ try {
95
+ return JSON.parse(JSON.stringify(value));
96
+ } catch (e) {
97
+ return void 0;
98
+ }
99
+ };
100
+ const rawConfig = (() => {
101
+ var _a;
102
+ try {
103
+ const raw = (_a = window.localStorage) == null ? void 0 : _a.getItem(storageKey);
104
+ return raw ? JSON.parse(raw) : null;
105
+ } catch (e) {
106
+ return null;
107
+ }
108
+ })();
109
+ const federation = window.__FEDERATION__ || window.__VMOK__;
110
+ const readers = (federation == null ? void 0 : federation.__OBSERVABILITY__) || {};
111
+ const reports = [];
112
+ const scopes = Object.keys(readers);
113
+ const isChromeObservabilityPluginName = (name) => chromePluginNames.includes(String(name));
114
+ const hasUserObservabilityPluginFromInstances = Array.isArray(
115
+ federation == null ? void 0 : federation.__INSTANCES__
116
+ ) ? federation.__INSTANCES__.some((instance) => {
117
+ var _a;
118
+ const plugins = (_a = instance == null ? void 0 : instance.options) == null ? void 0 : _a.plugins;
119
+ if (!Array.isArray(plugins)) {
120
+ return false;
121
+ }
122
+ return plugins.some(
123
+ (plugin) => (plugin == null ? void 0 : plugin.name) === userPluginName && !isChromeObservabilityPluginName(plugin == null ? void 0 : plugin.name)
124
+ );
125
+ }) : false;
126
+ const hasUserObservabilityPluginFromReaders = scopes.some(
127
+ (scope) => scope !== chromeScope
128
+ );
129
+ scopes.forEach((scope) => {
130
+ const reader = readers[scope];
131
+ if (!reader || typeof reader.getReports !== "function") {
132
+ return;
133
+ }
134
+ try {
135
+ const scopeReports = reader.getReports({ limit: 100 });
136
+ if (!Array.isArray(scopeReports)) {
137
+ return;
138
+ }
139
+ scopeReports.forEach((report) => {
140
+ const copied = safeCopy(report);
141
+ if (copied == null ? void 0 : copied.traceId) {
142
+ copied.__scope = scope;
143
+ reports.push(copied);
144
+ }
145
+ });
146
+ } catch (e) {
147
+ }
148
+ });
149
+ return {
150
+ config: rawConfig,
151
+ stored: Boolean(rawConfig),
152
+ scopes,
153
+ reports,
154
+ hasUserObservabilityPlugin: hasUserObservabilityPluginFromInstances || hasUserObservabilityPluginFromReaders
155
+ };
156
+ };
157
+ const readObservabilityConfig = () => __async(void 0, null, function* () {
158
+ const config = yield (0, import_index.injectScript)(
159
+ readConfigFromPage,
160
+ false,
161
+ import_messages.OBSERVABILITY_DEVTOOLS_STORAGE_KEY
162
+ );
163
+ return (0, import_observability_shared.normalizeObservabilityDevtoolsConfig)(
164
+ config || import_observability_shared.DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG
165
+ );
166
+ });
167
+ const applyObservabilityConfig = (config) => __async(void 0, null, function* () {
168
+ return (0, import_index.injectScript)(
169
+ writeConfigToPage,
170
+ false,
171
+ import_messages.OBSERVABILITY_DEVTOOLS_STORAGE_KEY,
172
+ (0, import_observability_shared.normalizeObservabilityDevtoolsConfig)(config)
173
+ );
174
+ });
175
+ const disableObservabilityConfig = () => __async(void 0, null, function* () {
176
+ return (0, import_index.injectScript)(removeConfigFromPage, false, import_messages.OBSERVABILITY_DEVTOOLS_STORAGE_KEY);
177
+ });
178
+ const reloadInspectedPage = () => __async(void 0, null, function* () {
179
+ return (0, import_index.injectScript)(reloadPage, false);
180
+ });
181
+ const readObservabilitySnapshot = () => __async(void 0, null, function* () {
182
+ const snapshot = yield (0, import_index.injectScript)(
183
+ readSnapshotFromPage,
184
+ true,
185
+ import_messages.OBSERVABILITY_DEVTOOLS_STORAGE_KEY,
186
+ OBSERVABILITY_SNAPSHOT_CONTEXT
187
+ );
188
+ return {
189
+ config: (0, import_observability_shared.normalizeObservabilityDevtoolsConfig)(
190
+ (snapshot == null ? void 0 : snapshot.config) || import_observability_shared.DEFAULT_OBSERVABILITY_DEVTOOLS_CONFIG
191
+ ),
192
+ stored: Boolean(snapshot == null ? void 0 : snapshot.stored),
193
+ scopes: Array.isArray(snapshot == null ? void 0 : snapshot.scopes) ? snapshot.scopes : [],
194
+ reports: Array.isArray(snapshot == null ? void 0 : snapshot.reports) ? snapshot.reports : [],
195
+ hasUserObservabilityPlugin: Boolean(snapshot == null ? void 0 : snapshot.hasUserObservabilityPlugin)
196
+ };
197
+ });
198
+ const mergeObservabilityReports = (currentReports, incomingReports) => {
199
+ const merged = /* @__PURE__ */ new Map();
200
+ currentReports.forEach((report) => {
201
+ if (report.traceId) {
202
+ merged.set(report.traceId, report);
203
+ }
204
+ });
205
+ incomingReports.forEach((report) => {
206
+ if (report.traceId) {
207
+ merged.set(report.traceId, report);
208
+ }
209
+ });
210
+ return Array.from(merged.values()).sort((left, right) => {
211
+ if ((right.updatedAt || 0) !== (left.updatedAt || 0)) {
212
+ return (right.updatedAt || 0) - (left.updatedAt || 0);
213
+ }
214
+ return (right.startedAt || 0) - (left.startedAt || 0);
215
+ });
216
+ };
217
+ const getObservabilityReportScopeLabel = (report) => {
218
+ const scope = report.__scope;
219
+ if (!scope || scope === import_observability_shared.CHROME_OBSERVABILITY_SCOPE) {
220
+ return void 0;
221
+ }
222
+ return `custom: ${scope}`;
223
+ };
224
+ // Annotate the CommonJS export names for ESM import in node:
225
+ 0 && (module.exports = {
226
+ applyObservabilityConfig,
227
+ disableObservabilityConfig,
228
+ getObservabilityReportScopeLabel,
229
+ mergeObservabilityReports,
230
+ readObservabilityConfig,
231
+ readObservabilitySnapshot,
232
+ reloadInspectedPage
233
+ });
@@ -0,0 +1,20 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var override_remote_exports = {};
15
+ module.exports = __toCommonJS(override_remote_exports);
16
+ var import_resolve_basic_proxy_core = require("./resolve-basic-proxy-core");
17
+ const basicProxyCore = (0, import_resolve_basic_proxy_core.resolveBasicProxyCore)(
18
+ require("../../vendor/basic-proxy-core.js")
19
+ );
20
+ basicProxyCore.registerOverridePlugin(globalThis);
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var import_index = require("./index");
3
2
  const postMessageUrl = (0, import_index.getUrl)("post-message.js");
4
3
  const script = document.createElement("script");
@@ -1,19 +1,33 @@
1
- "use strict";
1
+ var import_safe_post_message = require("./safe-post-message");
2
+ var import_messages = require("./messages");
3
+ const isModuleInfoPayload = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
4
+ const getMessageData = (data) => Boolean(data) && typeof data === "object" ? data : {};
2
5
  if (window.moduleHandler) {
3
6
  window.removeEventListener("message", window.moduleHandler);
4
7
  } else {
5
8
  window.moduleHandler = (event) => {
6
- const { origin, data } = event;
7
- if (!data.moduleInfo) {
9
+ const { origin } = event;
10
+ const data = getMessageData(event.data);
11
+ if ((data == null ? void 0 : data.source) === import_messages.OBSERVABILITY_DEVTOOLS_SOURCE) {
12
+ chrome.runtime.sendMessage({
13
+ type: import_messages.MESSAGE_OBSERVABILITY_DEVTOOLS_EVENT,
14
+ origin,
15
+ data: (0, import_safe_post_message.sanitizePostMessagePayload)(data)
16
+ }).catch(() => {
17
+ return false;
18
+ });
19
+ return;
20
+ }
21
+ if (!isModuleInfoPayload(data.moduleInfo)) {
8
22
  return;
9
23
  }
10
24
  chrome.runtime.sendMessage({
11
25
  origin,
12
- data: {
26
+ data: (0, import_safe_post_message.sanitizePostMessagePayload)({
13
27
  moduleInfo: data.moduleInfo,
14
28
  updateModule: data.updateModule,
15
29
  share: data.share
16
- }
30
+ })
17
31
  }).catch(() => {
18
32
  return false;
19
33
  });
@@ -1,17 +1,10 @@
1
- "use strict";
1
+ var import_safe_post_message = require("./safe-post-message");
2
2
  var _a, _b;
3
3
  const moduleInfo = (_a = window == null ? void 0 : window.__FEDERATION__) == null ? void 0 : _a.moduleInfo;
4
4
  window.postMessage(
5
- {
5
+ (0, import_safe_post_message.sanitizePostMessagePayload)({
6
6
  moduleInfo,
7
- share: JSON.parse(
8
- JSON.stringify((_b = window == null ? void 0 : window.__FEDERATION__) == null ? void 0 : _b.__SHARE__, (_key, value) => {
9
- if (typeof value === "function") {
10
- return "Function";
11
- }
12
- return value;
13
- })
14
- )
15
- },
7
+ share: (_b = window == null ? void 0 : window.__FEDERATION__) == null ? void 0 : _b.__SHARE__
8
+ }),
16
9
  "*"
17
10
  );
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -49,19 +48,28 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
49
48
  ));
50
49
  var import_helpers = __toESM(require("@module-federation/runtime/helpers"));
51
50
  var import_sdk = require("../sdk");
51
+ var import_safe_post_message = require("./safe-post-message");
52
52
  var _a;
53
53
  const getModuleInfo = () => {
54
54
  return {
55
55
  name: "mf-devtool-getModuleInfo-plugin",
56
56
  loadRemoteSnapshot(_a2) {
57
- var _b = _a2, { options, moduleInfo, remoteSnapshot } = _b, res = __objRest(_b, ["options", "moduleInfo", "remoteSnapshot"]);
57
+ var _b = _a2, {
58
+ options,
59
+ moduleInfo,
60
+ remoteSnapshot
61
+ } = _b, res = __objRest(_b, [
62
+ "options",
63
+ "moduleInfo",
64
+ "remoteSnapshot"
65
+ ]);
58
66
  const globalSnapshot = import_helpers.default.global.getGlobalSnapshot();
59
67
  if (!options || options.inBrowser) {
60
68
  window.postMessage(
61
- {
69
+ (0, import_safe_post_message.sanitizePostMessagePayload)({
62
70
  moduleInfo: globalSnapshot,
63
71
  updateModule: moduleInfo
64
- },
72
+ }),
65
73
  "*"
66
74
  );
67
75
  }
@@ -0,0 +1,27 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var resolve_basic_proxy_core_exports = {};
19
+ __export(resolve_basic_proxy_core_exports, {
20
+ resolveBasicProxyCore: () => resolveBasicProxyCore
21
+ });
22
+ module.exports = __toCommonJS(resolve_basic_proxy_core_exports);
23
+ const resolveBasicProxyCore = (basicProxyCoreModule) => "default" in basicProxyCoreModule ? basicProxyCoreModule.default : basicProxyCoreModule;
24
+ // Annotate the CommonJS export names for ESM import in node:
25
+ 0 && (module.exports = {
26
+ resolveBasicProxyCore
27
+ });