Skip to content

🎥 Make videos programmatically with React

delete emulation manager

Jonny Burger7c5b2be704d9
diff --git a/packages/renderer/src/browser/EmulationManager.ts b/packages/renderer/src/browser/EmulationManager.ts
deleted file mode 100644
index cfeff64fa9..0000000000
--- a/packages/renderer/src/browser/EmulationManager.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright 2017 Google Inc. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import type {Protocol} from 'devtools-protocol';
-import {CDPSession} from './Connection';
-import {Viewport} from './PuppeteerViewport';
-
-export class EmulationManager {
- #client: CDPSession;
-
- constructor(client: CDPSession) {
- this.#client = client;
- }
-
- async emulateViewport(viewport: Viewport): Promise<void> {
- const {height, width} = viewport;
- const {deviceScaleFactor} = viewport;
- const screenOrientation: Protocol.Emulation.ScreenOrientation = {
- angle: 0,
- type: 'portraitPrimary',
- };
-
- await Promise.all([
- this.#client.send('Emulation.setDeviceMetricsOverride', {
- mobile: false,
- width,
- height,
- deviceScaleFactor,
- screenOrientation,
- }),
- ]);
- }
-}
diff --git a/packages/renderer/src/browser/Page.ts b/packages/renderer/src/browser/Page.ts
index a218fe0514..42aaf2b0ea 100644
--- a/packages/renderer/src/browser/Page.ts
+++ b/packages/renderer/src/browser/Page.ts
@@ -18,7 +18,6 @@ import type {Protocol} from 'devtools-protocol';
import {assert} from './assert';
import {CDPSession} from './Connection';
import {ConsoleMessage, ConsoleMessageType} from './ConsoleMessage';
-import {EmulationManager} from './EmulationManager';
import {
EvaluateFn,
EvaluateFnReturnType,
@@ -78,7 +77,6 @@ export class Page extends EventEmitter {
#target: Target;
#timeoutSettings = new TimeoutSettings();
#frameManager: FrameManager;
- #emulationManager: EmulationManager;
#pageBindings = new Map<string, Function>();
screenshotTaskQueue: TaskQueue;
@@ -87,7 +85,6 @@ export class Page extends EventEmitter {
this.#client = client;
this.#target = target;
this.#frameManager = new FrameManager(client, this, this.#timeoutSettings);
- this.#emulationManager = new EmulationManager(client);
this.screenshotTaskQueue = new TaskQueue();
client.on(
@@ -210,8 +207,17 @@ export class Page extends EventEmitter {
return this.#frameManager.mainFrame();
}
- async setViewport(viewport: Viewport): Promise<void> {
- await this.#emulationManager.emulateViewport(viewport);
+ setViewport(viewport: Viewport): Promise<void> {
+ return this.#client.send('Emulation.setDeviceMetricsOverride', {
+ mobile: false,
+ width: viewport.width,
+ height: viewport.height,
+ deviceScaleFactor: viewport.deviceScaleFactor,
+ screenOrientation: {
+ angle: 0,
+ type: 'portraitPrimary',
+ },
+ });
}
setDefaultNavigationTimeout(timeout: number): void {