From da6e6c00e50d4421c7bf79921b85185a7c2d0f10 Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Tue, 28 Apr 2020 17:45:34 +0100 Subject: [PATCH] chore: migrate src/EmulationManager to TypeScript (#5766) --- ...mulationManager.js => EmulationManager.ts} | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) rename src/{EmulationManager.js => EmulationManager.ts} (68%) diff --git a/src/EmulationManager.js b/src/EmulationManager.ts similarity index 68% rename from src/EmulationManager.js rename to src/EmulationManager.ts index d3e1f15dde6..07a78a2b719 100644 --- a/src/EmulationManager.js +++ b/src/EmulationManager.ts @@ -13,32 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import {CDPSession} from './Connection'; -// Used as a TypeDef -// eslint-disable-next-line no-unused-vars -const {CDPSession} = require('./Connection'); +export class EmulationManager { + _client: CDPSession; + _emulatingMobile = false; + _hasTouch = false; -class EmulationManager { - /** - * @param {!CDPSession} client - */ - constructor(client) { + constructor(client: CDPSession) { this._client = client; - this._emulatingMobile = false; - this._hasTouch = false; } - /** - * @param {!Puppeteer.Viewport} viewport - * @return {Promise} - */ - async emulateViewport(viewport) { + async emulateViewport(viewport: Puppeteer.Viewport): Promise { const mobile = viewport.isMobile || false; const width = viewport.width; const height = viewport.height; const deviceScaleFactor = viewport.deviceScaleFactor || 1; - /** @type {Protocol.Emulation.ScreenOrientation} */ - const screenOrientation = viewport.isLandscape ? {angle: 90, type: 'landscapePrimary'} : {angle: 0, type: 'portraitPrimary'}; + const screenOrientation: Protocol.Emulation.ScreenOrientation = viewport.isLandscape ? {angle: 90, type: 'landscapePrimary'} : {angle: 0, type: 'portraitPrimary'}; const hasTouch = viewport.hasTouch || false; await Promise.all([ @@ -54,5 +45,3 @@ class EmulationManager { return reloadNeeded; } } - -module.exports = {EmulationManager};