chrome-devtools-frontend 1.0.1672557 → 1.0.1675430

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 (177) hide show
  1. package/.agents/skills/devtools-ux-writing-refactor/SKILL.md +26 -9
  2. package/front_end/core/common/ParsedURL.ts +5 -1
  3. package/front_end/core/common/SettingRegistration.ts +30 -34
  4. package/front_end/core/common/Settings.ts +4 -64
  5. package/front_end/core/host/UserMetrics.ts +127 -117
  6. package/front_end/core/protocol_client/PuppeteerDevToolsConnection.ts +42 -9
  7. package/front_end/core/root/Runtime.ts +14 -0
  8. package/front_end/core/sdk/NetworkManager.ts +0 -35
  9. package/front_end/core/sdk/SourceMap.ts +1 -19
  10. package/front_end/core/sdk/SourceMapManager.ts +75 -48
  11. package/front_end/core/sdk/SourceMapScopesInfo.ts +0 -62
  12. package/front_end/core/sdk/TargetManager.ts +18 -0
  13. package/front_end/devtools_compatibility.js +1 -1
  14. package/front_end/entrypoints/main/MainImpl.ts +1 -0
  15. package/front_end/foundation/Universe.ts +44 -29
  16. package/front_end/generated/InspectorBackendCommands.ts +4 -3
  17. package/front_end/generated/SupportedCSSProperties.ts +16 -1
  18. package/front_end/generated/protocol-mapping.d.ts +8 -0
  19. package/front_end/generated/protocol-proxy-api.d.ts +6 -0
  20. package/front_end/generated/protocol.ts +16 -2
  21. package/front_end/models/ai_assistance/AiSetting.ts +66 -3
  22. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +15 -5
  23. package/front_end/models/bindings/CompilerScriptMapping.ts +1 -1
  24. package/front_end/models/emulation/DeviceModeModel.ts +82 -102
  25. package/front_end/models/emulation/EmulatedDevices.ts +18 -66
  26. package/front_end/models/javascript_metadata/NativeFunctions.js +4 -4
  27. package/front_end/models/persistence/AutomaticFileSystemManager.ts +2 -2
  28. package/front_end/models/persistence/IsolatedFileSystemManager.ts +20 -29
  29. package/front_end/models/trace/ModelImpl.ts +5 -0
  30. package/front_end/models/trace/Processor.ts +5 -0
  31. package/front_end/models/trace/handlers/LayoutShiftsHandler.ts +7 -1
  32. package/front_end/models/trace/handlers/MetaHandler.ts +8 -4
  33. package/front_end/models/trace/handlers/PageLoadMetricsHandler.ts +11 -0
  34. package/front_end/models/workspace/FileManager.ts +13 -6
  35. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +11 -10
  36. package/front_end/panels/ai_assistance/ai_assistance-meta.ts +3 -45
  37. package/front_end/panels/application/BackgroundServiceView.ts +42 -40
  38. package/front_end/panels/application/KeyValueStorageItemsView.ts +1 -0
  39. package/front_end/panels/application/WebMCPView.ts +13 -5
  40. package/front_end/panels/application/components/AdsView.ts +24 -1
  41. package/front_end/panels/application/components/adsView.css +27 -21
  42. package/front_end/panels/autofill/AutofillView.ts +12 -12
  43. package/front_end/panels/autofill/autofill-meta.ts +2 -2
  44. package/front_end/panels/common/ExtensionServer.ts +7 -1
  45. package/front_end/panels/common/common.ts +0 -1
  46. package/front_end/panels/console/ConsoleInsightTeaser.ts +7 -6
  47. package/front_end/panels/console/ConsoleViewMessage.ts +1 -1
  48. package/front_end/panels/elements/ClassesPaneWidget.ts +2 -2
  49. package/front_end/panels/elements/ElementsTreeElement.ts +602 -327
  50. package/front_end/panels/elements/ElementsTreeOutline.ts +1 -1
  51. package/front_end/panels/elements/StylesSidebarPane.ts +1 -1
  52. package/front_end/panels/elements/components/AdornerManager.ts +1 -0
  53. package/front_end/panels/emulation/AdvancedApp.ts +3 -3
  54. package/front_end/panels/emulation/DeviceModeToolbar.ts +2 -11
  55. package/front_end/panels/emulation/DeviceModeView.ts +234 -75
  56. package/front_end/panels/emulation/InspectedPagePlaceholder.ts +1 -1
  57. package/front_end/panels/emulation/deviceModeView.css +4 -21
  58. package/front_end/panels/emulation/emulation-meta.ts +4 -30
  59. package/front_end/panels/emulation/emulation.ts +0 -3
  60. package/front_end/panels/explain/components/ConsoleInsight.ts +11 -7
  61. package/front_end/panels/js_timeline/js_timeline-meta.ts +8 -8
  62. package/front_end/panels/layer_viewer/LayerDetailsView.ts +30 -30
  63. package/front_end/panels/layer_viewer/LayerTreeOutline.ts +6 -6
  64. package/front_end/panels/layer_viewer/LayerViewHost.ts +1 -1
  65. package/front_end/panels/layer_viewer/Layers3DView.ts +11 -11
  66. package/front_end/panels/layer_viewer/PaintProfilerView.ts +8 -8
  67. package/front_end/panels/layer_viewer/TransformController.ts +3 -3
  68. package/front_end/panels/layer_viewer/layer_viewer-meta.ts +11 -11
  69. package/front_end/panels/layers/LayersPanel.ts +2 -2
  70. package/front_end/panels/layers/layers-meta.ts +2 -2
  71. package/front_end/panels/lighthouse/LighthouseController.ts +3 -7
  72. package/front_end/panels/mobile_throttling/CPUThrottlingSelector.ts +313 -0
  73. package/front_end/panels/mobile_throttling/NetworkPanelIndicator.ts +0 -10
  74. package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +21 -10
  75. package/front_end/panels/mobile_throttling/ThrottlingManager.ts +1 -58
  76. package/front_end/panels/mobile_throttling/mobile_throttling.ts +2 -9
  77. package/front_end/panels/network/NetworkConfigView.ts +1 -71
  78. package/front_end/panels/network/networkConfigView.css +1 -2
  79. package/front_end/panels/profiler/HeapDetachedElementsDataGrid.ts +3 -3
  80. package/front_end/panels/profiler/HeapDetachedElementsView.ts +5 -5
  81. package/front_end/panels/profiler/HeapProfileView.ts +32 -32
  82. package/front_end/panels/profiler/HeapProfilerPanel.ts +2 -2
  83. package/front_end/panels/profiler/HeapSnapshotDataGrids.ts +33 -37
  84. package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +26 -27
  85. package/front_end/panels/profiler/HeapSnapshotView.ts +48 -48
  86. package/front_end/panels/profiler/IsolateSelector.ts +10 -10
  87. package/front_end/panels/profiler/ModuleUIStrings.ts +25 -25
  88. package/front_end/panels/profiler/ProfileLauncherView.ts +6 -6
  89. package/front_end/panels/profiler/ProfilesPanel.ts +6 -6
  90. package/front_end/panels/profiler/WritableProfileHeader.ts +6 -6
  91. package/front_end/panels/profiler/profiler-meta.ts +7 -7
  92. package/front_end/panels/protocol_monitor/ProtocolMonitor.ts +7 -0
  93. package/front_end/panels/recorder/RecorderPanel.ts +1 -1
  94. package/front_end/panels/settings/AISettingsTab.ts +27 -23
  95. package/front_end/panels/settings/emulation/DevicesSettingsTab.ts +1 -2
  96. package/front_end/panels/timeline/TimelineFlameChartNetworkDataProvider.ts +12 -17
  97. package/front_end/panels/timeline/TimelinePanel.ts +20 -35
  98. package/front_end/panels/timeline/components/LiveMetricsView.ts +27 -6
  99. package/front_end/panels/timeline/components/NetworkTrackWidget.ts +1 -1
  100. package/front_end/panels/timeline/components/components.ts +0 -4
  101. package/front_end/panels/timeline/components/liveMetricsView.css +7 -0
  102. package/front_end/third_party/chromium/README.chromium +1 -1
  103. package/front_end/third_party/source-map-scopes-codec/package/CONTRIBUTING.md +0 -0
  104. package/front_end/third_party/source-map-scopes-codec/package/LICENSE +0 -0
  105. package/front_end/third_party/source-map-scopes-codec/package/README.md +0 -0
  106. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts +0 -0
  107. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts.map +1 -1
  108. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts +0 -0
  109. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts.map +0 -0
  110. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts +0 -0
  111. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts.map +0 -0
  112. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts +0 -0
  113. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts.map +0 -0
  114. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts +0 -0
  115. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts.map +0 -0
  116. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/scopes.d.ts +0 -0
  117. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/scopes.d.ts.map +0 -0
  118. package/front_end/third_party/source-map-scopes-codec/package/deno.json +1 -1
  119. package/front_end/third_party/source-map-scopes-codec/package/package.json +1 -1
  120. package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js +2 -0
  121. package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js.map +1 -1
  122. package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.ts +2 -0
  123. package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js +0 -0
  124. package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js.map +0 -0
  125. package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.ts +0 -0
  126. package/front_end/third_party/source-map-scopes-codec/package/src/codec.js +0 -0
  127. package/front_end/third_party/source-map-scopes-codec/package/src/codec.js.map +0 -0
  128. package/front_end/third_party/source-map-scopes-codec/package/src/codec.ts +0 -0
  129. package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js +0 -0
  130. package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js.map +0 -0
  131. package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.ts +0 -0
  132. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js +0 -0
  133. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js.map +0 -0
  134. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.ts +0 -0
  135. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js +0 -0
  136. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js.map +0 -0
  137. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.ts +0 -0
  138. package/front_end/third_party/source-map-scopes-codec/package/src/mod.js +0 -0
  139. package/front_end/third_party/source-map-scopes-codec/package/src/mod.js.map +0 -0
  140. package/front_end/third_party/source-map-scopes-codec/package/src/mod.ts +0 -0
  141. package/front_end/third_party/source-map-scopes-codec/package/src/scopes.js +0 -0
  142. package/front_end/third_party/source-map-scopes-codec/package/src/scopes.js.map +0 -0
  143. package/front_end/third_party/source-map-scopes-codec/package/src/scopes.ts +0 -0
  144. package/front_end/third_party/source-map-scopes-codec/package/src/util.js +0 -0
  145. package/front_end/third_party/source-map-scopes-codec/package/src/util.js.map +0 -0
  146. package/front_end/third_party/source-map-scopes-codec/package/src/util.ts +0 -0
  147. package/front_end/third_party/source-map-scopes-codec/package/src/vlq.js +0 -0
  148. package/front_end/third_party/source-map-scopes-codec/package/src/vlq.js.map +0 -0
  149. package/front_end/third_party/source-map-scopes-codec/package/src/vlq.ts +0 -0
  150. package/front_end/ui/comments/CommentAnchorResolver.ts +132 -0
  151. package/front_end/ui/comments/comments.ts +9 -0
  152. package/front_end/ui/components/dialogs/ShortcutDialog.ts +2 -0
  153. package/front_end/ui/components/settings/SettingCheckbox.ts +4 -12
  154. package/front_end/ui/components/settings/settingCheckbox.css +0 -7
  155. package/front_end/ui/legacy/Treeoutline.ts +14 -14
  156. package/front_end/ui/legacy/UIUtils.ts +2 -47
  157. package/front_end/ui/legacy/Widget.ts +10 -2
  158. package/front_end/ui/legacy/components/data_grid/DataGridElement.ts +40 -0
  159. package/front_end/ui/legacy/components/settings_ui/SettingsUI.ts +1 -1
  160. package/front_end/ui/legacy/components/utils/Linkifier.ts +1 -0
  161. package/front_end/ui/lit/Directives.ts +80 -0
  162. package/front_end/ui/lit/lit.ts +1 -0
  163. package/front_end/ui/lit/render.ts +8 -0
  164. package/front_end/ui/settings/SettingUIRegistration.ts +4 -0
  165. package/front_end/ui/visual_logging/Debugging.ts +1 -5
  166. package/front_end/ui/visual_logging/KnownContextValues.ts +3 -0
  167. package/front_end/ui/visual_logging/LoggingConfig.ts +21 -0
  168. package/front_end/ui/visual_logging/visual_logging.ts +9 -0
  169. package/mcp/mcp.ts +1 -0
  170. package/package.json +1 -1
  171. package/front_end/panels/common/ThrottlingUtils.ts +0 -51
  172. package/front_end/panels/emulation/DeviceModeWrapper.ts +0 -248
  173. package/front_end/panels/mobile_throttling/MobileThrottlingSelector.ts +0 -92
  174. package/front_end/panels/timeline/components/CPUThrottlingSelector.ts +0 -235
  175. package/front_end/panels/timeline/components/NetworkThrottlingSelector.ts +0 -245
  176. package/front_end/panels/timeline/components/cpuThrottlingSelector.css +0 -30
  177. package/front_end/panels/timeline/components/networkThrottlingSelector.css +0 -24
@@ -449,10 +449,18 @@ export interface HostConfigJpegXlImageFormat {
449
449
  enabled: boolean;
450
450
  }
451
451
 
452
+ export interface HostConfigSourceMapScopesInSourcesPanel {
453
+ enabled: boolean;
454
+ }
455
+
452
456
  interface AiGeneratedTimelineLabels {
453
457
  enabled: boolean;
454
458
  }
455
459
 
460
+ interface AllowInterestForcing {
461
+ enabled: boolean;
462
+ }
463
+
456
464
  interface GlobalAiButton {
457
465
  enabled: boolean;
458
466
  promotionEnabled: boolean;
@@ -532,6 +540,9 @@ interface DevToolsPlusButton {
532
540
  interface DevToolsInstrumentationBreakpoints {
533
541
  enabled: boolean;
534
542
  }
543
+ interface HostConfigDevToolsComments {
544
+ enabled: boolean;
545
+ }
535
546
 
536
547
  /**
537
548
  * The host configuration that we expect from the DevTools back-end.
@@ -571,7 +582,9 @@ export type HostConfig = Platform.TypeScriptUtilities.RecursivePartial<{
571
582
  devToolsEnableOriginBoundCookies: HostConfigEnableOriginBoundCookies,
572
583
  devToolsAnimationStylesInStylesTab: HostConfigAnimationStylesInStylesTab,
573
584
  devToolsJpegXlImageFormat: HostConfigJpegXlImageFormat,
585
+ devToolsSourceMapScopesInSourcesPanel: HostConfigSourceMapScopesInSourcesPanel,
574
586
  devToolsAiGeneratedTimelineLabels: AiGeneratedTimelineLabels,
587
+ devToolsAllowInterestForcing: AllowInterestForcing,
575
588
  devToolsGlobalAiButton: GlobalAiButton,
576
589
  devToolsGdpProfiles: GdpProfiles,
577
590
  devToolsGdpProfilesAvailability: GdpProfilesAvailability,
@@ -589,6 +602,7 @@ export type HostConfig = Platform.TypeScriptUtilities.RecursivePartial<{
589
602
  devToolsPlusButton: DevToolsPlusButton,
590
603
  devToolsInstrumentationBreakpoints: DevToolsInstrumentationBreakpoints,
591
604
  extensionsOnChromeUrls: ExtensionsOnChromeUrls,
605
+ devToolsComments: HostConfigDevToolsComments,
592
606
  }>;
593
607
 
594
608
  /**
@@ -2180,7 +2180,6 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
2180
2180
  readonly #targetManager: TargetManager;
2181
2181
  #userAgentOverride = '';
2182
2182
  #userAgentMetadataOverride: Protocol.Emulation.UserAgentMetadata|null = null;
2183
- #customAcceptedEncodings: Protocol.Network.ContentEncoding[]|null = null;
2184
2183
  readonly #networkAgents = new Set<ProtocolProxyApi.NetworkApi>();
2185
2184
  readonly #fetchAgents = new Set<ProtocolProxyApi.FetchApi>();
2186
2185
  readonly inflightMainResourceRequests = new Map<string, NetworkRequest>();
@@ -2283,11 +2282,6 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
2283
2282
  if (this.isIntercepting()) {
2284
2283
  void fetchAgent.invoke_enable({patterns: this.#urlsForRequestInterceptor.valuesArray()});
2285
2284
  }
2286
- if (this.#customAcceptedEncodings === null) {
2287
- void networkAgent.invoke_clearAcceptedEncodingsOverride();
2288
- } else {
2289
- void networkAgent.invoke_setAcceptedEncodings({encodings: this.#customAcceptedEncodings});
2290
- }
2291
2285
  this.#networkAgents.add(networkAgent);
2292
2286
  this.#fetchAgents.add(fetchAgent);
2293
2287
  }
@@ -2388,33 +2382,6 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
2388
2382
  this.updateUserAgentOverride();
2389
2383
  }
2390
2384
 
2391
- setCustomAcceptedEncodingsOverride(acceptedEncodings: Protocol.Network.ContentEncoding[]): void {
2392
- this.#customAcceptedEncodings = acceptedEncodings;
2393
- this.updateAcceptedEncodingsOverride();
2394
- this.dispatchEventToListeners(MultitargetNetworkManager.Events.ACCEPTED_ENCODINGS_CHANGED);
2395
- }
2396
-
2397
- clearCustomAcceptedEncodingsOverride(): void {
2398
- this.#customAcceptedEncodings = null;
2399
- this.updateAcceptedEncodingsOverride();
2400
- this.dispatchEventToListeners(MultitargetNetworkManager.Events.ACCEPTED_ENCODINGS_CHANGED);
2401
- }
2402
-
2403
- isAcceptedEncodingOverrideSet(): boolean {
2404
- return this.#customAcceptedEncodings !== null;
2405
- }
2406
-
2407
- private updateAcceptedEncodingsOverride(): void {
2408
- const customAcceptedEncodings = this.#customAcceptedEncodings;
2409
- for (const agent of this.#networkAgents) {
2410
- if (customAcceptedEncodings === null) {
2411
- void agent.invoke_clearAcceptedEncodingsOverride();
2412
- } else {
2413
- void agent.invoke_setAcceptedEncodings({encodings: customAcceptedEncodings});
2414
- }
2415
- }
2416
- }
2417
-
2418
2385
  get requestConditions(): RequestConditions {
2419
2386
  return this.#requestConditions;
2420
2387
  }
@@ -2516,7 +2483,6 @@ export namespace MultitargetNetworkManager {
2516
2483
  CONDITIONS_CHANGED = 'ConditionsChanged',
2517
2484
  USER_AGENT_CHANGED = 'UserAgentChanged',
2518
2485
  INTERCEPTORS_CHANGED = 'InterceptorsChanged',
2519
- ACCEPTED_ENCODINGS_CHANGED = 'AcceptedEncodingsChanged',
2520
2486
  REQUEST_INTERCEPTED = 'RequestIntercepted',
2521
2487
  REQUEST_FULFILLED = 'RequestFulfilled',
2522
2488
  }
@@ -2526,7 +2492,6 @@ export namespace MultitargetNetworkManager {
2526
2492
  [Events.CONDITIONS_CHANGED]: void;
2527
2493
  [Events.USER_AGENT_CHANGED]: void;
2528
2494
  [Events.INTERCEPTORS_CHANGED]: void;
2529
- [Events.ACCEPTED_ENCODINGS_CHANGED]: void;
2530
2495
  [Events.REQUEST_INTERCEPTED]: string;
2531
2496
  [Events.REQUEST_FULFILLED]: Platform.DevToolsPath.UrlString;
2532
2497
  }
@@ -231,26 +231,8 @@ export class SourceMap {
231
231
  return this.#scopesFallbackPromise ?? Promise.resolve();
232
232
  }
233
233
 
234
- findEntry(lineNumber: number, columnNumber: number, inlineFrameIndex?: number): SourceMapEntry|null {
234
+ findEntry(lineNumber: number, columnNumber: number): SourceMapEntry|null {
235
235
  this.#ensureSourceMapProcessed();
236
- if (inlineFrameIndex && this.#scopesInfo !== null) {
237
- // For inlineFrameIndex != 0 we use the callsite info for the corresponding inlining site.
238
- // Note that the callsite for "inlineFrameIndex" is actually in the previous frame.
239
- const {inlinedFunctions} = this.#scopesInfo.findInlinedFunctions(lineNumber, columnNumber);
240
- const {callsite} = inlinedFunctions[inlineFrameIndex - 1];
241
- if (!callsite) {
242
- console.error('Malformed source map. Expected to have a callsite info for index', inlineFrameIndex);
243
- return null;
244
- }
245
- return {
246
- lineNumber,
247
- columnNumber,
248
- sourceIndex: callsite.sourceIndex,
249
- sourceURL: this.sourceURLs()[callsite.sourceIndex],
250
- sourceLineNumber: callsite.line,
251
- sourceColumnNumber: callsite.column,
252
- };
253
- }
254
236
  const mappings = this.mappings();
255
237
  const index = Platform.ArrayUtilities.upperBound(
256
238
  mappings, undefined, (_, entry) => lineNumber - entry.lineNumber || columnNumber - entry.columnNumber);
@@ -15,9 +15,17 @@ export type SourceMapFactory<T> =
15
15
  (compiledURL: Platform.DevToolsPath.UrlString, sourceMappingURL: Platform.DevToolsPath.UrlString,
16
16
  payload: SourceMapV3, client: T) => SourceMap;
17
17
 
18
+ export const lazyLoadingSettingDescriptor: Common.Settings.SettingDescriptor<boolean> = {
19
+ name: 'source-maps-lazy-loading',
20
+ type: Common.Settings.SettingType.BOOLEAN,
21
+ defaultValue: false,
22
+ storageType: Common.Settings.SettingStorageType.LOCAL,
23
+ };
24
+
18
25
  export class SourceMapManager<T extends FrameAssociated> extends Common.ObjectWrapper.ObjectWrapper<EventTypes<T>> {
19
26
  readonly #target: Target;
20
27
  readonly #factory: SourceMapFactory<T>;
28
+ readonly #lazyLoadingSetting: Common.Settings.Setting<boolean>;
21
29
  #isEnabled = true;
22
30
  readonly #clientData = new Map<T, ClientData>();
23
31
  readonly #sourceMaps = new Map<SourceMap, T>();
@@ -31,6 +39,12 @@ export class SourceMapManager<T extends FrameAssociated> extends Common.ObjectWr
31
39
  this.#factory = factory ??
32
40
  ((compiledURL, sourceMappingURL, payload) =>
33
41
  new SourceMap(compiledURL, sourceMappingURL, payload, this.#target.targetManager().getConsole()));
42
+ const settings = target.targetManager().settings;
43
+ this.#lazyLoadingSetting = settings.resolve(lazyLoadingSettingDescriptor);
44
+ }
45
+
46
+ isLazyLoadEnabled(): boolean {
47
+ return this.#lazyLoadingSetting.get();
34
48
  }
35
49
 
36
50
  setEnabled(isEnabled: boolean): void {
@@ -75,7 +89,7 @@ export class SourceMapManager<T extends FrameAssociated> extends Common.ObjectWr
75
89
  return Promise.resolve(undefined);
76
90
  }
77
91
 
78
- return clientData.sourceMapPromise;
92
+ return clientData.getSourceMap();
79
93
  }
80
94
 
81
95
  clientForSourceMap(sourceMap: SourceMap): T|undefined {
@@ -92,65 +106,78 @@ export class SourceMapManager<T extends FrameAssociated> extends Common.ObjectWr
92
106
  return;
93
107
  }
94
108
 
95
- let clientData: ClientData|null = {
109
+ const clientData: ClientData = {
96
110
  relativeSourceURL,
97
111
  relativeSourceMapURL,
98
- sourceMapPromise: Promise.resolve(undefined),
112
+ getSourceMap: () => Promise.resolve(undefined),
99
113
  };
114
+ this.#clientData.set(client, clientData);
115
+
100
116
  if (this.#isEnabled) {
101
117
  // The `// #sourceURL=foo` can be a random string, but is generally an absolute path.
102
118
  // Complete it to inspected page url for relative links.
103
119
  const sourceURL = SourceMapManager.resolveRelativeSourceURL(this.#target, relativeSourceURL);
104
120
  const sourceMapURL = Common.ParsedURL.ParsedURL.completeURL(sourceURL, relativeSourceMapURL);
105
121
  if (sourceMapURL) {
106
- if (this.#attachingClient) {
107
- // This should not happen
108
- console.error('Attaching source map may cancel previously attaching source map');
109
- }
110
- this.#attachingClient = client;
111
- this.dispatchEventToListeners(Events.SourceMapWillAttach, {client});
112
-
113
- if (this.#attachingClient === client) {
114
- this.#attachingClient = null;
115
- const initiator = client.createPageResourceLoadInitiator();
116
- // TODO(crbug.com/458180550): Pass PageResourceLoader via constructor.
117
- // The reason we grab it here lazily from the context is that otherwise every
118
- // unit test using `createTarget` would need to set up a `PageResourceLoader`, as
119
- // CSSModel and DebuggerModel are autostarted by default, and they create a
120
- // SourceMapManager in their respective constructors.
121
- const resourceLoader = this.#target.targetManager().context.get(PageResourceLoader);
122
- clientData.sourceMapPromise =
123
- loadSourceMap(resourceLoader, this.#sourceMapCache, sourceMapURL, client.debugId(), initiator)
124
- .then(
125
- payload => {
126
- const sourceMap = this.#factory(sourceURL, sourceMapURL, payload, client);
127
- if (this.#clientData.get(client) === clientData) {
128
- clientData.sourceMap = sourceMap;
129
- this.#sourceMaps.set(sourceMap, client);
130
- this.dispatchEventToListeners(Events.SourceMapAttached, {client, sourceMap});
131
- }
132
- return sourceMap;
133
- },
134
- () => {
135
- if (this.#clientData.get(client) === clientData) {
136
- this.dispatchEventToListeners(Events.SourceMapFailedToAttach, {client});
137
- }
138
- return undefined;
139
- });
140
- } else {
141
- // Assume cancelAttachSourceMap was called.
142
- if (this.#attachingClient) {
143
- // This should not happen
144
- console.error('Cancelling source map attach because another source map is attaching');
122
+ let sourceMapPromise: Promise<SourceMap|undefined>|undefined;
123
+ const doLoad = (): Promise<SourceMap|undefined> => {
124
+ if (!sourceMapPromise) {
125
+ if (this.#attachingClient) {
126
+ // This should not happen
127
+ console.error('Attaching source map may cancel previously attaching source map');
128
+ }
129
+ this.#attachingClient = client;
130
+ this.dispatchEventToListeners(Events.SourceMapWillAttach, {client});
131
+
132
+ if (this.#attachingClient === client) {
133
+ this.#attachingClient = null;
134
+ const initiator = client.createPageResourceLoadInitiator();
135
+ // TODO(crbug.com/458180550): Pass PageResourceLoader via constructor.
136
+ // The reason we grab it here lazily from the context is that otherwise every
137
+ // unit test using `createTarget` would need to set up a `PageResourceLoader`, as
138
+ // CSSModel and DebuggerModel are autostarted by default, and they create a
139
+ // SourceMapManager in their respective constructors.
140
+ const resourceLoader = this.#target.targetManager().context.get(PageResourceLoader);
141
+ sourceMapPromise =
142
+ loadSourceMap(resourceLoader, this.#sourceMapCache, sourceMapURL, client.debugId(), initiator)
143
+ .then(
144
+ payload => {
145
+ const sourceMap = this.#factory(sourceURL, sourceMapURL, payload, client);
146
+ if (this.#clientData.get(client) === clientData) {
147
+ clientData.sourceMap = sourceMap;
148
+ this.#sourceMaps.set(sourceMap, client);
149
+ this.dispatchEventToListeners(Events.SourceMapAttached, {client, sourceMap});
150
+ }
151
+ return sourceMap;
152
+ },
153
+ () => {
154
+ if (this.#clientData.get(client) === clientData) {
155
+ this.dispatchEventToListeners(Events.SourceMapFailedToAttach, {client});
156
+ }
157
+ return undefined;
158
+ });
159
+ } else {
160
+ // Assume cancelAttachSourceMap was called.
161
+ if (this.#attachingClient) {
162
+ // This should not happen
163
+ console.error('Cancelling source map attach because another source map is attaching');
164
+ }
165
+ this.#clientData.delete(client);
166
+ this.dispatchEventToListeners(Events.SourceMapFailedToAttach, {client});
167
+ sourceMapPromise = Promise.resolve(undefined);
168
+ }
145
169
  }
146
- clientData = null;
147
- this.dispatchEventToListeners(Events.SourceMapFailedToAttach, {client});
170
+ return sourceMapPromise;
171
+ };
172
+
173
+ if (this.isLazyLoadEnabled()) {
174
+ clientData.getSourceMap = doLoad;
175
+ } else {
176
+ const promise = doLoad();
177
+ clientData.getSourceMap = () => promise;
148
178
  }
149
179
  }
150
180
  }
151
- if (clientData) {
152
- this.#clientData.set(client, clientData);
153
- }
154
181
  }
155
182
 
156
183
  cancelAttachSourceMap(client: T): void {
@@ -231,7 +258,7 @@ interface ClientData {
231
258
  // be valid URLs and will be checked and resolved once `attachSourceMap` is called.
232
259
  relativeSourceMapURL: string;
233
260
  sourceMap?: SourceMap;
234
- sourceMapPromise: Promise<SourceMap|undefined>;
261
+ getSourceMap: () => Promise<SourceMap|undefined>;
235
262
  }
236
263
 
237
264
  export enum Events {
@@ -267,46 +267,6 @@ export class SourceMapScopesInfo {
267
267
  return false;
268
268
  }
269
269
 
270
- /**
271
- * Given a generated position, returns the original name of the surrounding function as well as
272
- * all the original function names that got inlined into the surrounding generated function and their
273
- * respective callsites in the original code (ordered from inner to outer).
274
- *
275
- * @returns a list with inlined functions. Every entry in the list has a callsite in the orignal code,
276
- * except the last function (since the last function didn't get inlined).
277
- */
278
- findInlinedFunctions(generatedLine: number, generatedColumn: number): InlineInfo {
279
- const rangeChain = this.#findGeneratedRangeChain(generatedLine, generatedColumn);
280
- const result: InlineInfo = {
281
- inlinedFunctions: [],
282
- originalFunctionName: '',
283
- };
284
-
285
- // Walk the generated ranges from the innermost containing range outwards as long as we don't
286
- // encounter a range that is a scope in the generated code and a function scope originally.
287
- for (let i = rangeChain.length - 1; i >= 0; --i) {
288
- const range = rangeChain[i];
289
-
290
- if (range.callSite) {
291
- // Record the name and call-site if the range corresponds to an inlined function.
292
- result.inlinedFunctions.push({
293
- name: range.originalScope?.name ?? '',
294
- callsite: {...range.callSite, sourceURL: this.#sourceMap.sourceURLForSourceIndex(range.callSite.sourceIndex)},
295
- });
296
- }
297
- if (range.isStackFrame) {
298
- // We arrived at an actual generated JS function, don't go further.
299
- // The corresponding original scope could not actually be a function
300
- // (e.g. a block scope transpiled down to a JS function), but we'll
301
- // filter that out later.
302
- result.originalFunctionName = range.originalScope?.name ?? '';
303
- break;
304
- }
305
- }
306
-
307
- return result;
308
- }
309
-
310
270
  /**
311
271
  * Given a generated position, this returns all the surrounding generated ranges from outer
312
272
  * to inner.
@@ -608,28 +568,6 @@ export interface TranslatedFrame {
608
568
  url?: Platform.DevToolsPath.UrlString;
609
569
  }
610
570
 
611
- /**
612
- * Represents the inlining information for a given generated position.
613
- *
614
- * It contains a list of all the inlined original functions at the generated position
615
- * as well as the original function name of the generated position's surrounding
616
- * function.
617
- *
618
- * The inlined functions are sorted from inner to outer (or top to bottom on the stack).
619
- */
620
- export interface InlineInfo {
621
- inlinedFunctions: Array<{
622
- name: string,
623
- callsite: {
624
- line: number,
625
- column: number,
626
- sourceIndex: number,
627
- sourceURL?: Platform.DevToolsPath.UrlString,
628
- },
629
- }>;
630
- originalFunctionName: string;
631
- }
632
-
633
571
  export function contains(
634
572
  range: Pick<ScopesCodec.GeneratedRange, 'start'|'end'>, line: number, column: number): boolean {
635
573
  if (range.start.line > line || (range.start.line === line && range.start.column > column)) {
@@ -122,6 +122,24 @@ export class TargetManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes
122
122
  Root.DevToolsContext.globalInstance().delete(TargetManager);
123
123
  }
124
124
 
125
+ // TODO(crbug.com/542394587): Should be `Symbol.dispose`
126
+ dispose(): void {
127
+ for (const target of this.targets()) {
128
+ target.dispose('TargetManager disposed');
129
+ }
130
+ if (this.#browserTarget) {
131
+ this.#browserTarget.dispose('TargetManager disposed');
132
+ this.#browserTarget = null;
133
+ }
134
+ this.#targets.clear();
135
+ this.#observers.clear();
136
+ this.#modelObservers.clear();
137
+ this.#modelListeners.clear();
138
+ this.#scopeChangeListeners.clear();
139
+ this.#scopeTarget = null;
140
+ this.#scopedObservers = new WeakSet();
141
+ }
142
+
125
143
  onInspectedURLChange(target: Target): void {
126
144
  if (target !== this.#scopeTarget) {
127
145
  return;
@@ -1290,7 +1290,7 @@
1290
1290
  MAX_VALUE: 16,
1291
1291
  },
1292
1292
  };
1293
- // LINT.ThenChange(/front_end/core/host/UserMetricsEnums.d.ts)
1293
+ // LINT.ThenChange(/front_end/core/host/UserMetricsEnums.ts)
1294
1294
 
1295
1295
  // InspectorFrontendHostImpl --------------------------------------------------
1296
1296
 
@@ -209,6 +209,7 @@ export class MainImpl {
209
209
  hostConfig: Root.Runtime.hostConfig,
210
210
  inspectorFrontendHost: Host.InspectorFrontendHost.InspectorFrontendHostInstance,
211
211
  supportsEmulation: this.#supportsEmulation,
212
+ initAutomaticFilesystem: true,
212
213
  };
213
214
  this.#universe = new Foundation.Universe.Universe(creationOptions);
214
215
  Root.DevToolsContext.setGlobalInstance(this.#universe.context as Root.DevToolsContext.WritableDevToolsContext);
@@ -28,6 +28,7 @@ export interface CreationOptions {
28
28
  hostConfig: Root.Runtime.HostConfig;
29
29
  inspectorFrontendHost: Host.InspectorFrontendHostAPI.InspectorFrontendHostAPI;
30
30
  supportsEmulation: boolean;
31
+ initAutomaticFilesystem?: boolean;
31
32
  }
32
33
 
33
34
  export class Universe {
@@ -37,6 +38,7 @@ export class Universe {
37
38
  readonly context: Root.DevToolsContext.DevToolsContext;
38
39
  readonly autofillManager: AutofillManager.AutofillManager.AutofillManager;
39
40
  readonly supportsEmulation: boolean;
41
+ readonly initAutomaticFilesystem: boolean;
40
42
  readonly fileSystemWorkspaceBinding: Persistence.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding;
41
43
 
42
44
  constructor(options: CreationOptions) {
@@ -78,11 +80,17 @@ export class Universe {
78
80
  const multitargetNetworkManager = new SDK.NetworkManager.MultitargetNetworkManager(targetManager);
79
81
  context.set(SDK.NetworkManager.MultitargetNetworkManager, multitargetNetworkManager);
80
82
 
83
+ const workspace = new Workspace.Workspace.WorkspaceImpl();
84
+ context.set(Workspace.Workspace.WorkspaceImpl, workspace);
85
+
86
+ const fileManager = new Workspace.FileManager.FileManager();
87
+ context.set(Workspace.FileManager.FileManager, fileManager);
88
+
81
89
  this.supportsEmulation = options.supportsEmulation;
82
90
  let deviceModeModel = null;
83
91
  if (options.supportsEmulation) {
84
- deviceModeModel =
85
- new Emulation.DeviceModeModel.DeviceModeModel(targetManager, settings, multitargetNetworkManager);
92
+ deviceModeModel = new Emulation.DeviceModeModel.DeviceModeModel(targetManager, settings,
93
+ multitargetNetworkManager, fileManager);
86
94
  context.set(Emulation.DeviceModeModel.DeviceModeModel, deviceModeModel);
87
95
  }
88
96
 
@@ -90,15 +98,20 @@ export class Universe {
90
98
  new SDK.PageResourceLoader.PageResourceLoader(targetManager, settings, multitargetNetworkManager, null);
91
99
  context.set(SDK.PageResourceLoader.PageResourceLoader, pageResourceLoader);
92
100
 
93
- const projectSettingsModel = new ProjectSettings.ProjectSettingsModel.ProjectSettingsModel(
94
- pageResourceLoader,
95
- targetManager,
96
- );
97
- context.set(ProjectSettings.ProjectSettingsModel.ProjectSettingsModel, projectSettingsModel);
98
-
99
- const automaticFileSystemManager = new Persistence.AutomaticFileSystemManager.AutomaticFileSystemManager(
100
- options.inspectorFrontendHost, projectSettingsModel);
101
- context.set(Persistence.AutomaticFileSystemManager.AutomaticFileSystemManager, automaticFileSystemManager);
101
+ this.initAutomaticFilesystem = options.initAutomaticFilesystem ?? false;
102
+ let automaticFileSystemManager = null;
103
+ let projectSettingsModel = null;
104
+ if (this.initAutomaticFilesystem) {
105
+ projectSettingsModel = new ProjectSettings.ProjectSettingsModel.ProjectSettingsModel(
106
+ pageResourceLoader,
107
+ targetManager,
108
+ );
109
+ context.set(ProjectSettings.ProjectSettingsModel.ProjectSettingsModel, projectSettingsModel);
110
+
111
+ automaticFileSystemManager = new Persistence.AutomaticFileSystemManager.AutomaticFileSystemManager(
112
+ options.inspectorFrontendHost, projectSettingsModel);
113
+ context.set(Persistence.AutomaticFileSystemManager.AutomaticFileSystemManager, automaticFileSystemManager);
114
+ }
102
115
 
103
116
  const cpuThrottlingManager = new SDK.CPUThrottlingManager.CPUThrottlingManager(settings, targetManager);
104
117
  context.set(SDK.CPUThrottlingManager.CPUThrottlingManager, cpuThrottlingManager);
@@ -117,22 +130,18 @@ export class Universe {
117
130
  const domModelUndoStack = new SDK.DOMModel.DOMModelUndoStack();
118
131
  context.set(SDK.DOMModel.DOMModelUndoStack, domModelUndoStack);
119
132
 
120
- const workspace = new Workspace.Workspace.WorkspaceImpl();
121
- context.set(Workspace.Workspace.WorkspaceImpl, workspace);
122
-
123
- const fileManager = new Workspace.FileManager.FileManager();
124
- context.set(Workspace.FileManager.FileManager, fileManager);
125
-
126
- const automaticFileSystemWorkspaceBinding =
127
- new Persistence.AutomaticFileSystemWorkspaceBinding.AutomaticFileSystemWorkspaceBinding(
128
- automaticFileSystemManager,
129
- isolatedFileSystemManager,
130
- workspace,
131
- );
132
- context.set(
133
- Persistence.AutomaticFileSystemWorkspaceBinding.AutomaticFileSystemWorkspaceBinding,
134
- automaticFileSystemWorkspaceBinding,
135
- );
133
+ if (automaticFileSystemManager) {
134
+ const automaticFileSystemWorkspaceBinding =
135
+ new Persistence.AutomaticFileSystemWorkspaceBinding.AutomaticFileSystemWorkspaceBinding(
136
+ automaticFileSystemManager,
137
+ isolatedFileSystemManager,
138
+ workspace,
139
+ );
140
+ context.set(
141
+ Persistence.AutomaticFileSystemWorkspaceBinding.AutomaticFileSystemWorkspaceBinding,
142
+ automaticFileSystemWorkspaceBinding,
143
+ );
144
+ }
136
145
 
137
146
  this.fileSystemWorkspaceBinding =
138
147
  new Persistence.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding(isolatedFileSystemManager, workspace);
@@ -226,6 +235,11 @@ export class Universe {
226
235
  dispose(): void {
227
236
  // TODO(crbug.com/542394587): Track these in a DisposableStack.
228
237
  this.context.get(Persistence.IsolatedFileSystemManager.IsolatedFileSystemManager).dispose();
238
+ if (this.initAutomaticFilesystem) {
239
+ this.context.get(Persistence.AutomaticFileSystemManager.AutomaticFileSystemManager).dispose();
240
+ }
241
+ this.context.get(Workspace.FileManager.FileManager).dispose();
242
+ this.context.get(SDK.TargetManager.TargetManager).dispose();
229
243
  }
230
244
 
231
245
  get automaticFileSystemManager(): Persistence.AutomaticFileSystemManager.AutomaticFileSystemManager {
@@ -338,8 +352,9 @@ export class Universe {
338
352
  return this.context.get(Bindings.PresentationConsoleMessageHelper.PresentationConsoleMessageManager);
339
353
  }
340
354
 
341
- get projectSettingsModel(): ProjectSettings.ProjectSettingsModel.ProjectSettingsModel {
342
- return this.context.get(ProjectSettings.ProjectSettingsModel.ProjectSettingsModel);
355
+ get projectSettingsModel(): ProjectSettings.ProjectSettingsModel.ProjectSettingsModel|null {
356
+ return this.initAutomaticFilesystem ? this.context.get(ProjectSettings.ProjectSettingsModel.ProjectSettingsModel) :
357
+ null;
343
358
  }
344
359
 
345
360
  get settings(): Common.Settings.Settings {