mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-10 13:44:39 +08:00
Enable TypeScript in ScreenCaptureModel
This patch also adds empty Dispatcher interfaces to TypeScript that are compatible with closure to unblock the TypeScript work. Bug: chromium:1011811, chromium:1079233, chromium:1081686 Change-Id: I9487f8c5b51098267ede176fc18171923c757442 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2196383 Commit-Queue: Jan Scheffler <janscheffler@chromium.org> Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
This commit is contained in:
committed by
Commit Bot
parent
892d5ae337
commit
aa0100504b
@@ -765,6 +765,13 @@ export class TargetBase {
|
||||
throw new Error('Implemented in InspectorBackend.js');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!ProtocolProxyApi.PageDispatcher} dispatcher
|
||||
*/
|
||||
registerPageDispatcher(dispatcher) {
|
||||
throw new Error('Implemented in InspectorBackend.js');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!ProtocolProxyApi.StorageDispatcher} dispatcher
|
||||
*/
|
||||
|
||||
@@ -894,7 +894,7 @@ export class ResourceTreeFrame {
|
||||
}
|
||||
|
||||
/**
|
||||
* @implements {Protocol.PageDispatcher}
|
||||
* @implements {ProtocolProxyApiWorkaround_PageDispatcher}
|
||||
* @unrestricted
|
||||
*/
|
||||
export class PageDispatcher {
|
||||
@@ -906,101 +906,101 @@ export class PageDispatcher {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {number} time
|
||||
* @return {!Protocol.UsesObjectNotation}
|
||||
*/
|
||||
domContentEventFired(time) {
|
||||
this._resourceTreeModel.dispatchEventToListeners(Events.DOMContentLoaded, time);
|
||||
usesObjectNotation() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {number} time
|
||||
* @param {!Protocol.Page.DomContentEventFiredEvent} event
|
||||
*/
|
||||
loadEventFired(time) {
|
||||
domContentEventFired({timestamp}) {
|
||||
this._resourceTreeModel.dispatchEventToListeners(Events.DOMContentLoaded, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.LoadEventFiredEvent} event
|
||||
*/
|
||||
loadEventFired({timestamp}) {
|
||||
this._resourceTreeModel.dispatchEventToListeners(
|
||||
Events.Load, {resourceTreeModel: this._resourceTreeModel, loadTime: time});
|
||||
Events.Load, {resourceTreeModel: this._resourceTreeModel, loadTime: timestamp});
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Network.LoaderId} loaderId
|
||||
* @param {string} name
|
||||
* @param {number} time
|
||||
* @param {!Protocol.Page.LifecycleEventEvent} event
|
||||
*/
|
||||
lifecycleEvent(frameId, loaderId, name, time) {
|
||||
lifecycleEvent({frameId, loaderId, name, timestamp}) {
|
||||
this._resourceTreeModel.dispatchEventToListeners(Events.LifecycleEvent, {frameId, name});
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Page.FrameId} parentFrameId
|
||||
* @param {!Protocol.Runtime.StackTrace=} stackTrace
|
||||
* @param {!Protocol.Page.FrameAttachedEvent} event
|
||||
*/
|
||||
frameAttached(frameId, parentFrameId, stackTrace) {
|
||||
this._resourceTreeModel._frameAttached(frameId, parentFrameId, stackTrace);
|
||||
frameAttached({frameId, parentFrameId, stack}) {
|
||||
this._resourceTreeModel._frameAttached(frameId, parentFrameId, stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.Frame} frame
|
||||
* @param {!Protocol.Page.FrameNavigatedEvent} event
|
||||
*/
|
||||
frameNavigated(frame) {
|
||||
frameNavigated({frame}) {
|
||||
this._resourceTreeModel._frameNavigated(frame);
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Page.FrameDetachedEvent} event
|
||||
*/
|
||||
frameDetached(frameId) {
|
||||
frameDetached({frameId}) {
|
||||
this._resourceTreeModel._frameDetached(frameId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Page.FrameStartedLoadingEvent} event
|
||||
*/
|
||||
frameStartedLoading(frameId) {
|
||||
frameStartedLoading({frameId}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Page.FrameStoppedLoadingEvent} event
|
||||
*/
|
||||
frameStoppedLoading(frameId) {
|
||||
frameStoppedLoading({frameId}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Page.FrameRequestedNavigationEvent} event
|
||||
*/
|
||||
frameRequestedNavigation(frameId) {
|
||||
frameRequestedNavigation({frameId}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {number} delay
|
||||
* @param {!Protocol.Page.FrameScheduledNavigationEvent} event
|
||||
*/
|
||||
frameScheduledNavigation(frameId, delay) {
|
||||
frameScheduledNavigation({frameId, delay}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Page.FrameClearedScheduledNavigationEvent} event
|
||||
*/
|
||||
frameClearedScheduledNavigation(frameId) {
|
||||
frameClearedScheduledNavigation({frameId}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {string} url
|
||||
* @param {!Protocol.Page.NavigatedWithinDocumentEvent} event
|
||||
*/
|
||||
navigatedWithinDocument(frameId, url) {
|
||||
navigatedWithinDocument({frameId, url}) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1012,13 +1012,9 @@ export class PageDispatcher {
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {string} url
|
||||
* @param {string} message
|
||||
* @param {string} dialogType
|
||||
* @param {boolean} hasBrowserHandler
|
||||
* @param {string=} prompt
|
||||
* @param {!Protocol.Page.JavascriptDialogOpeningEvent} event
|
||||
*/
|
||||
javascriptDialogOpening(url, message, dialogType, hasBrowserHandler, prompt) {
|
||||
javascriptDialogOpening({url, message, type, hasBrowserHandler, defaultPrompt}) {
|
||||
if (!hasBrowserHandler) {
|
||||
this._resourceTreeModel._agent.handleJavaScriptDialog(false);
|
||||
}
|
||||
@@ -1026,26 +1022,23 @@ export class PageDispatcher {
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {boolean} result
|
||||
* @param {string} userInput
|
||||
* @param {!Protocol.Page.JavascriptDialogClosedEvent} event
|
||||
*/
|
||||
javascriptDialogClosed(result, userInput) {
|
||||
javascriptDialogClosed({result, userInput}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {string} data
|
||||
* @param {!Protocol.Page.ScreencastFrameMetadata} metadata
|
||||
* @param {number} sessionId
|
||||
* @param {!Protocol.Page.ScreencastFrameEvent} event
|
||||
*/
|
||||
screencastFrame(data, metadata, sessionId) {
|
||||
screencastFrame({data, metadata, sessionId}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {boolean} visible
|
||||
* @param {!Protocol.Page.ScreencastVisibilityChangedEvent} event
|
||||
*/
|
||||
screencastVisibilityChanged(visible) {
|
||||
screencastVisibilityChanged({visible}) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1066,35 +1059,30 @@ export class PageDispatcher {
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {string} url
|
||||
* @param {string} windowName
|
||||
* @param {!Array<string>} windowFeatures
|
||||
* @param {boolean} userGesture
|
||||
* @param {!Protocol.Page.WindowOpenEvent} event
|
||||
*/
|
||||
windowOpen(url, windowName, windowFeatures, userGesture) {
|
||||
windowOpen({url, windowName, windowFeatures, userGesture}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {string} url
|
||||
* @param {string} data
|
||||
* @param {!Protocol.Page.CompilationCacheProducedEvent} event
|
||||
*/
|
||||
compilationCacheProduced(url, data) {
|
||||
compilationCacheProduced({url, data}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {string} mode
|
||||
* @param {!Protocol.Page.FileChooserOpenedEvent} event
|
||||
*/
|
||||
fileChooserOpened(mode) {
|
||||
fileChooserOpened({mode}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {string} url
|
||||
* @param {!Protocol.Page.DownloadWillBeginEvent} event
|
||||
*/
|
||||
downloadWillBegin(frameId, url) {
|
||||
downloadWillBegin({frameId, url}) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,16 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @ts-nocheck
|
||||
// TODO(crbug.com/1011811): Enable TypeScript compiler checks
|
||||
|
||||
import * as ProtocolClient from '../protocol_client/protocol_client.js';
|
||||
|
||||
import {OverlayModel} from './OverlayModel.js';
|
||||
import {Capability, SDKModel, Target} from './SDKModel.js'; // eslint-disable-line no-unused-vars
|
||||
|
||||
/**
|
||||
* @implements {Protocol.PageDispatcher}
|
||||
* @implements {ProtocolProxyApiWorkaround_PageDispatcher}
|
||||
*/
|
||||
export class ScreenCaptureModel extends SDKModel {
|
||||
/**
|
||||
@@ -20,53 +15,60 @@ export class ScreenCaptureModel extends SDKModel {
|
||||
constructor(target) {
|
||||
super(target);
|
||||
this._agent = target.pageAgent();
|
||||
/** @type {?function(string, !Protocol.Page.ScreencastFrameMetadata):void} */
|
||||
/** @type {?function(!Protocol.binary, !Protocol.Page.ScreencastFrameMetadata):void} */
|
||||
this._onScreencastFrame = null;
|
||||
/** @type {?function(boolean):void} */
|
||||
this._onScreencastVisibilityChanged = null;
|
||||
target.registerPageDispatcher(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {!Protocol.UsesObjectNotation}
|
||||
*/
|
||||
usesObjectNotation() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!Protocol.Page.StartScreencastRequestFormat} format
|
||||
* @param {number} quality
|
||||
* @param {number|undefined} width
|
||||
* @param {number|undefined} height
|
||||
* @param {number|undefined} maxWidth
|
||||
* @param {number|undefined} maxHeight
|
||||
* @param {number|undefined} everyNthFrame
|
||||
* @param {function(string, !Protocol.Page.ScreencastFrameMetadata):void} onFrame
|
||||
* @param {function(boolean):void} onVisibilityChanged
|
||||
* @param {function(!Protocol.binary, !Protocol.Page.ScreencastFrameMetadata): void} onFrame
|
||||
* @param {function(boolean): void} onVisibilityChanged
|
||||
*/
|
||||
startScreencast(format, quality, width, height, everyNthFrame, onFrame, onVisibilityChanged) {
|
||||
startScreencast(format, quality, maxWidth, maxHeight, everyNthFrame, onFrame, onVisibilityChanged) {
|
||||
this._onScreencastFrame = onFrame;
|
||||
this._onScreencastVisibilityChanged = onVisibilityChanged;
|
||||
this._agent.startScreencast(format, quality, width, height, everyNthFrame);
|
||||
this._agent.invoke_startScreencast({format, quality, maxWidth, maxHeight, everyNthFrame});
|
||||
}
|
||||
|
||||
stopScreencast() {
|
||||
this._onScreencastFrame = null;
|
||||
this._onScreencastVisibilityChanged = null;
|
||||
this._agent.stopScreencast();
|
||||
this._agent.invoke_stopScreencast();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!Protocol.Page.CaptureScreenshotRequestFormat} format
|
||||
* @param {number} quality
|
||||
* @param {!Protocol.Page.Viewport=} clip
|
||||
* @return {!Promise<?string>}
|
||||
* @return {!Promise<?Protocol.binary>}
|
||||
*/
|
||||
async captureScreenshot(format, quality, clip) {
|
||||
await OverlayModel.muteHighlight();
|
||||
const result = await this._agent.captureScreenshot(format, quality, clip, true);
|
||||
const result = await this._agent.invoke_captureScreenshot({format, quality, clip, fromSurface: true});
|
||||
await OverlayModel.unmuteHighlight();
|
||||
return result;
|
||||
return result.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {!Promise<?{viewportX: number, viewportY: number, viewportScale: number, contentWidth: number, contentHeight: number}>}
|
||||
*/
|
||||
async fetchLayoutMetrics() {
|
||||
const response = await this._agent.invoke_getLayoutMetrics({});
|
||||
if (response[ProtocolClient.InspectorBackend.ProtocolError]) {
|
||||
const response = await this._agent.invoke_getLayoutMetrics();
|
||||
if (response.getError()) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
@@ -80,12 +82,10 @@ export class ScreenCaptureModel extends SDKModel {
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {string} data
|
||||
* @param {!Protocol.Page.ScreencastFrameMetadata} metadata
|
||||
* @param {number} sessionId
|
||||
* @param {!Protocol.Page.ScreencastFrameEvent} _
|
||||
*/
|
||||
screencastFrame(data, metadata, sessionId) {
|
||||
this._agent.screencastFrameAck(sessionId);
|
||||
screencastFrame({data, metadata, sessionId}) {
|
||||
this._agent.invoke_screencastFrameAck({sessionId});
|
||||
if (this._onScreencastFrame) {
|
||||
this._onScreencastFrame.call(null, data, metadata);
|
||||
}
|
||||
@@ -93,9 +93,9 @@ export class ScreenCaptureModel extends SDKModel {
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {boolean} visible
|
||||
* @param {!Protocol.Page.ScreencastVisibilityChangedEvent} _
|
||||
*/
|
||||
screencastVisibilityChanged(visible) {
|
||||
screencastVisibilityChanged({visible}) {
|
||||
if (this._onScreencastVisibilityChanged) {
|
||||
this._onScreencastVisibilityChanged.call(null, visible);
|
||||
}
|
||||
@@ -103,93 +103,87 @@ export class ScreenCaptureModel extends SDKModel {
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {number} time
|
||||
* @param {!Protocol.Page.DomContentEventFiredEvent} params
|
||||
*/
|
||||
domContentEventFired(time) {
|
||||
domContentEventFired(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {number} time
|
||||
* @param {!Protocol.Page.LoadEventFiredEvent} params
|
||||
*/
|
||||
loadEventFired(time) {
|
||||
loadEventFired(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Network.LoaderId} loaderId
|
||||
* @param {string} name
|
||||
* @param {number} time
|
||||
* @param {!Protocol.Page.LifecycleEventEvent} params
|
||||
*/
|
||||
lifecycleEvent(frameId, loaderId, name, time) {
|
||||
lifecycleEvent(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {string} url
|
||||
* @param {!Protocol.Page.NavigatedWithinDocumentEvent} params
|
||||
*/
|
||||
navigatedWithinDocument(frameId, url) {
|
||||
navigatedWithinDocument(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Page.FrameId} parentFrameId
|
||||
* @param {!Protocol.Page.FrameAttachedEvent} params
|
||||
*/
|
||||
frameAttached(frameId, parentFrameId) {
|
||||
frameAttached(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.Frame} frame
|
||||
* @param {!Protocol.Page.FrameNavigatedEvent} params
|
||||
*/
|
||||
frameNavigated(frame) {
|
||||
frameNavigated(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Page.FrameDetachedEvent} params
|
||||
*/
|
||||
frameDetached(frameId) {
|
||||
frameDetached(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Page.FrameStartedLoadingEvent} params
|
||||
*/
|
||||
frameStartedLoading(frameId) {
|
||||
frameStartedLoading(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Page.FrameStoppedLoadingEvent} params
|
||||
*/
|
||||
frameStoppedLoading(frameId) {
|
||||
frameStoppedLoading(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Page.FrameRequestedNavigationEvent} params
|
||||
*/
|
||||
frameRequestedNavigation(frameId) {
|
||||
frameRequestedNavigation(params) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {number} delay
|
||||
* @param {!Protocol.Page.FrameScheduledNavigationEvent} params
|
||||
*/
|
||||
frameScheduledNavigation(frameId, delay) {
|
||||
frameScheduledNavigation(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {!Protocol.Page.FrameClearedScheduledNavigationEvent} params
|
||||
*/
|
||||
frameClearedScheduledNavigation(frameId) {
|
||||
frameClearedScheduledNavigation(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,21 +194,16 @@ export class ScreenCaptureModel extends SDKModel {
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {string} url
|
||||
* @param {string} message
|
||||
* @param {string} dialogType
|
||||
* @param {boolean} hasBrowserHandler
|
||||
* @param {string=} prompt
|
||||
* @param {!Protocol.Page.JavascriptDialogOpeningEvent} params
|
||||
*/
|
||||
javascriptDialogOpening(url, message, dialogType, hasBrowserHandler, prompt) {
|
||||
javascriptDialogOpening(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {boolean} result
|
||||
* @param {string} userInput
|
||||
* @param {!Protocol.Page.JavascriptDialogClosedEvent} params
|
||||
*/
|
||||
javascriptDialogClosed(result, userInput) {
|
||||
javascriptDialogClosed(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,35 +220,30 @@ export class ScreenCaptureModel extends SDKModel {
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {string} url
|
||||
* @param {string} windowName
|
||||
* @param {!Array<string>} windowFeatures
|
||||
* @param {boolean} userGesture
|
||||
* @param {!Protocol.Page.WindowOpenEvent} params
|
||||
*/
|
||||
windowOpen(url, windowName, windowFeatures, userGesture) {
|
||||
windowOpen(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {string} mode
|
||||
* @param {!Protocol.Page.FileChooserOpenedEvent} params
|
||||
*/
|
||||
fileChooserOpened(mode) {
|
||||
fileChooserOpened(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {string} url
|
||||
* @param {string} data
|
||||
* @param {!Protocol.Page.CompilationCacheProducedEvent} params
|
||||
*/
|
||||
compilationCacheProduced(url, data) {
|
||||
compilationCacheProduced(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
* @param {string} url
|
||||
* @param {!Protocol.Page.DownloadWillBeginEvent} params
|
||||
*/
|
||||
downloadWillBegin(frameId, url) {
|
||||
downloadWillBegin(params) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user