chrome-devtools-frontend 1.0.1009019 → 1.0.1009515

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.
@@ -172,7 +172,8 @@ export namespace Chrome {
172
172
  }
173
173
 
174
174
  export interface RecorderExtensionPlugin {
175
- stringify(obj: Record<string, any>): Promise<string>;
175
+ stringify(recording: Record<string, any>): Promise<string>;
176
+ stringifyStep(step: Record<string, any>): Promise<string>;
176
177
  }
177
178
 
178
179
  export interface LanguageExtensionPlugin {
@@ -278,7 +279,8 @@ export namespace Chrome {
278
279
  }
279
280
 
280
281
  export interface RecorderExtensions {
281
- registerRecorderExtensionPlugin(plugin: RecorderExtensionPlugin, pluginName: string): Promise<void>;
282
+ registerRecorderExtensionPlugin(plugin: RecorderExtensionPlugin, pluginName: string, mimeType: string):
283
+ Promise<void>;
282
284
  unregisterRecorderExtensionPlugin(plugin: RecorderExtensionPlugin): Promise<void>;
283
285
  }
284
286
 
@@ -14,7 +14,7 @@ import {DebuggerWorkspaceBinding} from './DebuggerWorkspaceBinding.js';
14
14
  import {NetworkProject} from './NetworkProject.js';
15
15
  import {resourceMetadata} from './ResourceUtils.js';
16
16
 
17
- let resourceMappingInstance: ResourceMapping;
17
+ let resourceMappingInstance: ResourceMapping|undefined;
18
18
 
19
19
  const styleSheetOffsetMap = new WeakMap<SDK.CSSStyleSheetHeader.CSSStyleSheetHeader, TextUtils.TextRange.TextRange>();
20
20
  const scriptOffsetMap = new WeakMap<SDK.Script.Script, TextUtils.TextRange.TextRange>();
@@ -47,6 +47,10 @@ export class ResourceMapping implements SDK.TargetManager.SDKModelObserver<SDK.R
47
47
  return resourceMappingInstance;
48
48
  }
49
49
 
50
+ static removeInstance(): void {
51
+ resourceMappingInstance = undefined;
52
+ }
53
+
50
54
  modelAdded(resourceTreeModel: SDK.ResourceTreeModel.ResourceTreeModel): void {
51
55
  const info = new ModelInfo(this.#workspace, resourceTreeModel);
52
56
  this.#modelToInfo.set(resourceTreeModel, info);
@@ -97,17 +101,27 @@ export class ResourceMapping implements SDK.TargetManager.SDKModelObserver<SDK.R
97
101
  if (!info) {
98
102
  return null;
99
103
  }
100
- const uiSourceCode = info.getProject().uiSourceCodeForURL(script.sourceURL);
104
+ const embedderName = script.embedderName();
105
+ if (!embedderName) {
106
+ return null;
107
+ }
108
+ const uiSourceCode = info.getProject().uiSourceCodeForURL(embedderName);
101
109
  if (!uiSourceCode) {
102
110
  return null;
103
111
  }
104
112
  const offset = scriptOffsetMap.get(script) ||
105
113
  TextUtils.TextRange.TextRange.createFromLocation(script.lineOffset, script.columnOffset);
106
- const lineNumber = jsLocation.lineNumber + offset.startLine - script.lineOffset;
114
+ let lineNumber = jsLocation.lineNumber + offset.startLine - script.lineOffset;
107
115
  let columnNumber = jsLocation.columnNumber;
108
116
  if (jsLocation.lineNumber === script.lineOffset) {
109
117
  columnNumber += offset.startColumn - script.columnOffset;
110
118
  }
119
+ if (script.hasSourceURL) {
120
+ if (lineNumber === 0) {
121
+ columnNumber += script.columnOffset;
122
+ }
123
+ lineNumber += script.lineOffset;
124
+ }
111
125
  return uiSourceCode.uiLocation(lineNumber, columnNumber);
112
126
  }
113
127
 
@@ -124,14 +138,33 @@ export class ResourceMapping implements SDK.TargetManager.SDKModelObserver<SDK.R
124
138
  if (!debuggerModel) {
125
139
  return [];
126
140
  }
127
- const location = debuggerModel.createRawLocationByURL(uiSourceCode.url(), lineNumber, columnNumber);
128
- if (location) {
129
- const script = location.script();
130
- if (script && script.containsLocation(lineNumber, columnNumber)) {
131
- return [location];
141
+ const locations = [];
142
+ for (const script of debuggerModel.scripts()) {
143
+ if (script.embedderName() !== uiSourceCode.url()) {
144
+ continue;
145
+ }
146
+ const {startLine, startColumn} = scriptOffsetMap.get(script) ||
147
+ TextUtils.TextRange.TextRange.createFromLocation(script.lineOffset, script.columnOffset);
148
+ if (lineNumber < startLine || (lineNumber === startLine && columnNumber < startColumn)) {
149
+ continue;
150
+ }
151
+ const endLine = startLine + (script.endLine - script.lineOffset);
152
+ const endColumn =
153
+ startLine === endLine ? startColumn + (script.endColumn - script.columnOffset) : script.endColumn;
154
+ if (lineNumber > endLine || (lineNumber === endLine && columnNumber > endColumn)) {
155
+ continue;
156
+ }
157
+ let scriptLineNumber = lineNumber;
158
+ let scriptColumnNumber = columnNumber;
159
+ if (script.hasSourceURL) {
160
+ scriptLineNumber -= startLine;
161
+ if (scriptLineNumber === 0) {
162
+ scriptColumnNumber -= startColumn;
163
+ }
132
164
  }
165
+ locations.push(debuggerModel.createRawLocation(script, scriptLineNumber, scriptColumnNumber));
133
166
  }
134
- return [];
167
+ return locations;
135
168
  }
136
169
 
137
170
  uiLocationToCSSLocations(uiLocation: Workspace.UISourceCode.UILocation): SDK.CSSModel.CSSLocation[] {
@@ -341,7 +374,7 @@ class Binding implements TextUtils.ContentProvider.ContentProvider {
341
374
  if (!debuggerModel) {
342
375
  return [];
343
376
  }
344
- return debuggerModel.scriptsForSourceURL(this.#uiSourceCode.url());
377
+ return debuggerModel.scripts().filter(script => script.embedderName() === this.#uiSourceCode.url());
345
378
  }
346
379
 
347
380
  async styleSheetChanged(stylesheet: SDK.CSSStyleSheetHeader.CSSStyleSheetHeader, edit: SDK.CSSModel.Edit|null):
@@ -132,6 +132,7 @@ export namespace PrivateAPI {
132
132
  type RegisterRecorderExtensionPluginRequest = {
133
133
  command: Commands.RegisterRecorderExtensionPlugin,
134
134
  pluginName: string,
135
+ mimeType: string,
135
136
  port: MessagePort,
136
137
  };
137
138
  type SubscribeRequest = {command: Commands.Subscribe, type: string};
@@ -705,8 +706,8 @@ self.injectedExtensionAPI = function(
705
706
  (RecorderServicesAPIImpl.prototype as
706
707
  Pick<APIImpl.RecorderExtensions, 'registerRecorderExtensionPlugin'|'unregisterRecorderExtensionPlugin'>) = {
707
708
  registerRecorderExtensionPlugin: async function(
708
- this: APIImpl.RecorderExtensions, plugin: PublicAPI.Chrome.DevTools.RecorderExtensionPlugin,
709
- pluginName: string): Promise<void> {
709
+ this: APIImpl.RecorderExtensions, plugin: PublicAPI.Chrome.DevTools.RecorderExtensionPlugin, pluginName: string,
710
+ mimeType: string): Promise<void> {
710
711
  if (this._plugins.has(plugin)) {
711
712
  throw new Error(`Tried to register plugin '${pluginName}' twice`);
712
713
  }
@@ -734,6 +735,7 @@ self.injectedExtensionAPI = function(
734
735
  {
735
736
  command: PrivateAPI.Commands.RegisterRecorderExtensionPlugin,
736
737
  pluginName,
738
+ mimeType,
737
739
  port: channel.port2,
738
740
  },
739
741
  () => resolve(), [channel.port2]);
@@ -222,10 +222,10 @@ export class ExtensionServer extends Common.ObjectWrapper.ObjectWrapper<EventTyp
222
222
  private registerRecorderExtensionEndpoint(
223
223
  message: PrivateAPI.ExtensionServerRequestMessage, _shared_port: MessagePort): Record {
224
224
  if (message.command !== PrivateAPI.Commands.RegisterRecorderExtensionPlugin) {
225
- return this.status.E_BADARG('command', `expected ${PrivateAPI.Commands.Subscribe}`);
225
+ return this.status.E_BADARG('command', `expected ${PrivateAPI.Commands.RegisterRecorderExtensionPlugin}`);
226
226
  }
227
- const {pluginName, port} = message;
228
- RecorderPluginManager.instance().addPlugin(new RecorderExtensionEndpoint(pluginName, port));
227
+ const {pluginName, mimeType, port} = message;
228
+ RecorderPluginManager.instance().addPlugin(new RecorderExtensionEndpoint(pluginName, mimeType, port));
229
229
  return this.status.OK();
230
230
  }
231
231
 
@@ -8,16 +8,22 @@ import {RecorderPluginManager} from './RecorderPluginManager.js';
8
8
 
9
9
  export class RecorderExtensionEndpoint extends ExtensionEndpoint {
10
10
  private readonly name: string;
11
+ private readonly mimeType: string;
11
12
 
12
- constructor(name: string, port: MessagePort) {
13
+ constructor(name: string, mimeType: string, port: MessagePort) {
13
14
  super(port);
14
15
  this.name = name;
16
+ this.mimeType = mimeType;
15
17
  }
16
18
 
17
19
  getName(): string {
18
20
  return this.name;
19
21
  }
20
22
 
23
+ getMimeType(): string {
24
+ return this.mimeType;
25
+ }
26
+
21
27
  protected handleEvent({event}: {event: string}): void {
22
28
  switch (event) {
23
29
  case PrivateAPI.RecorderExtensionPluginEvents.UnregisteredRecorderExtensionPlugin: {
package/package.json CHANGED
@@ -55,5 +55,5 @@
55
55
  "unittest": "scripts/test/run_unittests.py --no-text-coverage",
56
56
  "watch": "vpython third_party/node/node.py --output scripts/watch_build.js"
57
57
  },
58
- "version": "1.0.1009019"
58
+ "version": "1.0.1009515"
59
59
  }