@module-federation/devtools 2.4.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/es/App.js +17 -2
- package/dist/es/App_module.css +3 -3
- package/dist/es/component/LoadingTrace/index.js +944 -0
- package/dist/es/component/LoadingTrace/index.module.js +5 -0
- package/dist/es/component/LoadingTrace/index_module.css +876 -0
- package/dist/es/i18n/index.js +178 -0
- package/dist/es/utils/chrome/index.js +3 -4
- package/dist/es/utils/chrome/messages.js +7 -1
- package/dist/es/utils/chrome/observability-plugin.js +93 -0
- package/dist/es/utils/chrome/observability-shared.js +99 -0
- package/dist/es/utils/chrome/observability.js +208 -0
- package/dist/es/utils/chrome/override-remote.js +2 -42
- package/dist/es/utils/chrome/post-message-listener.js +14 -0
- package/dist/es/utils/chrome/snapshot-plugin.js +2 -36
- package/dist/es/utils/data/index.js +5 -25
- package/dist/es/vendor/basic-proxy-core.js +155 -0
- package/dist/es/worker/index.js +27 -8
- package/dist/lib/App.js +17 -2
- package/dist/lib/App_module.css +3 -3
- package/dist/lib/component/LoadingTrace/index.js +954 -0
- package/dist/lib/component/LoadingTrace/index.module.js +25 -0
- package/dist/lib/component/LoadingTrace/index_module.css +876 -0
- package/dist/lib/i18n/index.js +178 -0
- package/dist/lib/utils/chrome/index.js +3 -4
- package/dist/lib/utils/chrome/messages.js +11 -2
- package/dist/lib/utils/chrome/observability-plugin.js +86 -0
- package/dist/lib/utils/chrome/observability-shared.js +126 -0
- package/dist/lib/utils/chrome/observability.js +234 -0
- package/dist/lib/utils/chrome/override-remote.js +5 -52
- package/dist/lib/utils/chrome/post-message-listener.js +11 -0
- package/dist/lib/utils/chrome/snapshot-plugin.js +5 -46
- package/dist/lib/utils/data/index.js +6 -28
- package/dist/lib/vendor/basic-proxy-core.js +147 -0
- package/dist/lib/worker/index.js +27 -8
- package/dist/types/src/component/LoadingTrace/index.d.ts +6 -0
- package/dist/types/src/utils/chrome/messages.d.ts +3 -0
- package/dist/types/src/utils/chrome/observability-plugin.d.ts +1 -0
- package/dist/types/src/utils/chrome/observability-shared.d.ts +41 -0
- package/dist/types/src/utils/chrome/observability.d.ts +110 -0
- package/dist/types/src/utils/chrome/snapshot-plugin.d.ts +0 -3
- package/dist/types/src/utils/data/index.d.ts +0 -1
- package/package.json +4 -3
- package/dist/es/utils/data/snapshot.js +0 -82
- package/dist/lib/utils/data/snapshot.js +0 -107
- package/dist/types/src/utils/data/snapshot.d.ts +0 -3
package/dist/lib/i18n/index.js
CHANGED
|
@@ -45,6 +45,7 @@ const resources = {
|
|
|
45
45
|
proxy: "Proxy",
|
|
46
46
|
dependency: "Dependency graph",
|
|
47
47
|
share: "Shared",
|
|
48
|
+
loadingTrace: "Loading trace",
|
|
48
49
|
performance: "Performance"
|
|
49
50
|
},
|
|
50
51
|
header: {
|
|
@@ -263,6 +264,94 @@ const resources = {
|
|
|
263
264
|
shared: "Shared",
|
|
264
265
|
entry: "Entry",
|
|
265
266
|
version: "Version"
|
|
267
|
+
},
|
|
268
|
+
loadingTrace: {
|
|
269
|
+
title: "Loading Trace",
|
|
270
|
+
empty: "No loading report yet",
|
|
271
|
+
emptyEnableChrome: "No observability plugin was detected on the page. Enable Chrome observability to start collecting loading reports.",
|
|
272
|
+
status: {
|
|
273
|
+
enabled: "Observability is enabled for the current page.",
|
|
274
|
+
disabled: "Observability is not enabled for the current page.",
|
|
275
|
+
unavailable: "Current page is unavailable.",
|
|
276
|
+
reloading: "Configuration saved. Reloading current page.",
|
|
277
|
+
synced: "Reports synced.",
|
|
278
|
+
noReports: "No report found on the current page.",
|
|
279
|
+
userPlugin: "Application observability plugin detected. Syncing existing reports."
|
|
280
|
+
},
|
|
281
|
+
confirm: {
|
|
282
|
+
observeTitle: "Start observability?",
|
|
283
|
+
updateTitle: "Update configuration?",
|
|
284
|
+
content: "The current tab will reload after the configuration is saved."
|
|
285
|
+
},
|
|
286
|
+
actions: {
|
|
287
|
+
observeNow: "Observe now",
|
|
288
|
+
updateConfig: "Update config",
|
|
289
|
+
config: "Configuration",
|
|
290
|
+
disable: "Disable",
|
|
291
|
+
refresh: "Sync",
|
|
292
|
+
export: "Export",
|
|
293
|
+
confirm: "Confirm",
|
|
294
|
+
cancel: "Cancel"
|
|
295
|
+
},
|
|
296
|
+
config: {
|
|
297
|
+
level: "Level",
|
|
298
|
+
levelTip: "Controls how much event detail is kept. Verbose keeps the full timeline, summary keeps key results, and error focuses on failures.",
|
|
299
|
+
verbose: "Verbose",
|
|
300
|
+
summary: "Summary",
|
|
301
|
+
error: "Error",
|
|
302
|
+
console: "Console hints",
|
|
303
|
+
consoleTip: "Prints lightweight hints in the inspected page console. Turn it off when the page console should stay clean."
|
|
304
|
+
},
|
|
305
|
+
stats: {
|
|
306
|
+
state: "State",
|
|
307
|
+
reports: "Reports",
|
|
308
|
+
events: "Events",
|
|
309
|
+
latest: "Latest outcome",
|
|
310
|
+
customTip: "Custom means the inspected page already registered its own observability plugin, so reports are read from the page instead of only from the Chrome collection plugin."
|
|
311
|
+
},
|
|
312
|
+
reports: {
|
|
313
|
+
search: "Filter reports",
|
|
314
|
+
noMatch: "No matching report",
|
|
315
|
+
success: "Success",
|
|
316
|
+
failed: "Failed",
|
|
317
|
+
pending: "Pending",
|
|
318
|
+
recovered: "Recovered",
|
|
319
|
+
eventRecovered: "Recovered",
|
|
320
|
+
limited: "Basic observability",
|
|
321
|
+
lowVersionTip: "The current MF runtime version is too low, so only basic loading events can be collected. Fine-grained remoteEntry, init, expose, factory, and shared phases may be missing. Upgrade to 2.5.0+ for the full loading trace.",
|
|
322
|
+
unknownVersionTip: "The current MF runtime version cannot be detected, so Chrome observability may only collect basic loading events. Fine-grained remoteEntry, init, expose, factory, and shared phases may be missing."
|
|
323
|
+
},
|
|
324
|
+
currentLoad: {
|
|
325
|
+
title: "Current loading",
|
|
326
|
+
remoteReport: "Remote",
|
|
327
|
+
sharedReport: "Shared dependency",
|
|
328
|
+
consumer: "Current consumer",
|
|
329
|
+
request: "Request",
|
|
330
|
+
producer: "Producer",
|
|
331
|
+
remoteName: "Remote name",
|
|
332
|
+
expose: "Expose",
|
|
333
|
+
shared: "Shared dependency",
|
|
334
|
+
provider: "Provider",
|
|
335
|
+
requiredVersion: "Required version",
|
|
336
|
+
selectedVersion: "Selected version",
|
|
337
|
+
availableVersions: "Available versions"
|
|
338
|
+
},
|
|
339
|
+
loadedBefore: {
|
|
340
|
+
title: "Other consumer loading records",
|
|
341
|
+
consumerCount: "{{count}} consumer(s)",
|
|
342
|
+
producerLoaded: "Same producer was loaded before",
|
|
343
|
+
exposeLoaded: "Current expose was loaded before",
|
|
344
|
+
exposeNotLoaded: "Current expose was not loaded before",
|
|
345
|
+
consumer: "Consumer",
|
|
346
|
+
status: "Status",
|
|
347
|
+
exposes: "Loaded exposes",
|
|
348
|
+
unknownConsumer: "Unknown consumer",
|
|
349
|
+
entryReady: "remoteEntry is available",
|
|
350
|
+
entryMissing: "remoteEntry is not available",
|
|
351
|
+
initReady: "container was initialized",
|
|
352
|
+
initMissing: "container was not initialized",
|
|
353
|
+
noExposes: "No expose record"
|
|
354
|
+
}
|
|
266
355
|
}
|
|
267
356
|
}
|
|
268
357
|
},
|
|
@@ -274,6 +363,7 @@ const resources = {
|
|
|
274
363
|
proxy: "代理配置",
|
|
275
364
|
dependency: "依赖关系图",
|
|
276
365
|
share: "共享依赖",
|
|
366
|
+
loadingTrace: "加载追踪",
|
|
277
367
|
performance: "性能"
|
|
278
368
|
},
|
|
279
369
|
header: {
|
|
@@ -492,6 +582,94 @@ const resources = {
|
|
|
492
582
|
shared: "共享依赖",
|
|
493
583
|
entry: "入口",
|
|
494
584
|
version: "版本"
|
|
585
|
+
},
|
|
586
|
+
loadingTrace: {
|
|
587
|
+
title: "加载追踪",
|
|
588
|
+
empty: "暂无加载报告",
|
|
589
|
+
emptyEnableChrome: "当前页面未检测到观测插件。可以开启 Chrome 采集来收集加载报告。",
|
|
590
|
+
status: {
|
|
591
|
+
enabled: "当前页面已开启加载追踪。",
|
|
592
|
+
disabled: "当前页面未开启加载追踪。",
|
|
593
|
+
unavailable: "当前页面暂不可用。",
|
|
594
|
+
reloading: "配置已保存,正在刷新当前页面。",
|
|
595
|
+
synced: "报告已同步。",
|
|
596
|
+
noReports: "当前页面还没有报告。",
|
|
597
|
+
userPlugin: "已检测到页面自带观测插件,正在同步已有报告。"
|
|
598
|
+
},
|
|
599
|
+
confirm: {
|
|
600
|
+
observeTitle: "开启加载追踪?",
|
|
601
|
+
updateTitle: "更新配置?",
|
|
602
|
+
content: "保存配置后会刷新当前标签页。"
|
|
603
|
+
},
|
|
604
|
+
actions: {
|
|
605
|
+
observeNow: "开启采集",
|
|
606
|
+
updateConfig: "更新配置",
|
|
607
|
+
config: "配置",
|
|
608
|
+
disable: "关闭",
|
|
609
|
+
refresh: "同步",
|
|
610
|
+
export: "导出",
|
|
611
|
+
confirm: "确认",
|
|
612
|
+
cancel: "取消"
|
|
613
|
+
},
|
|
614
|
+
config: {
|
|
615
|
+
level: "记录级别",
|
|
616
|
+
levelTip: "控制保留多少事件细节。完整会保留完整链路,摘要只保留关键结果,错误只关注失败。",
|
|
617
|
+
verbose: "完整",
|
|
618
|
+
summary: "摘要",
|
|
619
|
+
error: "错误",
|
|
620
|
+
console: "控制台提示",
|
|
621
|
+
consoleTip: "在被调试页面的控制台打印轻量提示。如果想保持页面控制台干净,可以关闭。"
|
|
622
|
+
},
|
|
623
|
+
stats: {
|
|
624
|
+
state: "状态",
|
|
625
|
+
reports: "报告",
|
|
626
|
+
events: "事件",
|
|
627
|
+
latest: "最新结果",
|
|
628
|
+
customTip: "Custom 表示当前页面已经自己注册了观测插件,报告会从页面已有插件中读取,不只依赖 Chrome 插件注入采集。"
|
|
629
|
+
},
|
|
630
|
+
reports: {
|
|
631
|
+
search: "过滤报告",
|
|
632
|
+
noMatch: "没有匹配的报告",
|
|
633
|
+
success: "成功",
|
|
634
|
+
failed: "失败",
|
|
635
|
+
pending: "进行中",
|
|
636
|
+
recovered: "兜底成功",
|
|
637
|
+
eventRecovered: "兜底",
|
|
638
|
+
limited: "基础观测",
|
|
639
|
+
lowVersionTip: "当前 MF 运行时版本较低,只能采集基础加载事件。remoteEntry、init、expose、factory、shared 等细阶段可能缺失。升级到 2.5.0+ 后可获得完整链路。",
|
|
640
|
+
unknownVersionTip: "当前 MF 运行时版本无法识别,Chrome 观测可能只能采集基础加载事件。remoteEntry、init、expose、factory、shared 等细阶段可能缺失。"
|
|
641
|
+
},
|
|
642
|
+
currentLoad: {
|
|
643
|
+
title: "当前加载",
|
|
644
|
+
remoteReport: "远程模块",
|
|
645
|
+
sharedReport: "共享依赖",
|
|
646
|
+
consumer: "当前消费方",
|
|
647
|
+
request: "请求",
|
|
648
|
+
producer: "生产者",
|
|
649
|
+
remoteName: "生产者名称",
|
|
650
|
+
expose: "Expose",
|
|
651
|
+
shared: "共享依赖",
|
|
652
|
+
provider: "提供方",
|
|
653
|
+
requiredVersion: "要求版本",
|
|
654
|
+
selectedVersion: "实际版本",
|
|
655
|
+
availableVersions: "可用版本"
|
|
656
|
+
},
|
|
657
|
+
loadedBefore: {
|
|
658
|
+
title: "其他消费方加载记录",
|
|
659
|
+
consumerCount: "{{count}} 个消费方",
|
|
660
|
+
producerLoaded: "同一生产者之前已被加载",
|
|
661
|
+
exposeLoaded: "当前 expose 之前已被加载",
|
|
662
|
+
exposeNotLoaded: "当前 expose 之前未被加载",
|
|
663
|
+
consumer: "消费方",
|
|
664
|
+
status: "状态",
|
|
665
|
+
exposes: "已加载 expose",
|
|
666
|
+
unknownConsumer: "未知消费方",
|
|
667
|
+
entryReady: "remoteEntry 已拿到",
|
|
668
|
+
entryMissing: "remoteEntry 未拿到",
|
|
669
|
+
initReady: "容器已初始化",
|
|
670
|
+
initMissing: "容器未初始化",
|
|
671
|
+
noExposes: "暂无导出记录"
|
|
672
|
+
}
|
|
495
673
|
}
|
|
496
674
|
}
|
|
497
675
|
}
|
|
@@ -105,10 +105,11 @@ const syncActiveTab = (tabId) => __async(void 0, null, function* () {
|
|
|
105
105
|
setTargetTab(tab);
|
|
106
106
|
return tab;
|
|
107
107
|
}
|
|
108
|
-
const
|
|
108
|
+
const tabs = yield getTabs({
|
|
109
109
|
active: true,
|
|
110
110
|
lastFocusedWindow: true
|
|
111
111
|
});
|
|
112
|
+
const activeTab = Array.isArray(tabs) ? tabs[0] : void 0;
|
|
112
113
|
setTargetTab(activeTab);
|
|
113
114
|
return activeTab;
|
|
114
115
|
} catch (error) {
|
|
@@ -131,9 +132,7 @@ function getInspectWindowTabId() {
|
|
|
131
132
|
function(info, error) {
|
|
132
133
|
const { tabId } = chrome.devtools.inspectedWindow;
|
|
133
134
|
getTabs().then((tabs) => {
|
|
134
|
-
const target = tabs.find(
|
|
135
|
-
(tab) => tab.id === tabId
|
|
136
|
-
);
|
|
135
|
+
const target = Array.isArray(tabs) ? tabs.find((tab) => tab.id === tabId) : void 0;
|
|
137
136
|
setTargetTab(target);
|
|
138
137
|
});
|
|
139
138
|
console.log(
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
+
});
|