🎥 Make videos programmatically with React
remove some code
Jonny Burgerfe0ee82807f7
diff --git a/packages/renderer/src/browser/BrowserConnector.ts b/packages/renderer/src/browser/BrowserConnector.tsindex 9bfcd9b641..fe195811b8 100644--- a/packages/renderer/src/browser/BrowserConnector.ts+++ b/packages/renderer/src/browser/BrowserConnector.ts@@ -23,6 +23,7 @@ import {import {Connection} from './Connection.js';import {ConnectionTransport} from './ConnectionTransport.js';import {getFetch} from './fetch.js';+import {NodeWebSocketTransport} from './NodeWebSocketTransport';import {Viewport} from './PuppeteerViewport.js';import {debugError, isErrorLike} from './util.js';@@ -57,7 +58,7 @@ export interface BrowserConnectOptions {}const getWebSocketTransportClass = async () => {- return (await import('./NodeWebSocketTransport.js')).NodeWebSocketTransport;+ return NodeWebSocketTransport;};/**diff --git a/packages/renderer/src/browser/DOMWorld.ts b/packages/renderer/src/browser/DOMWorld.tsindex 4fbd41e37b..09b75ded45 100644--- a/packages/renderer/src/browser/DOMWorld.ts+++ b/packages/renderer/src/browser/DOMWorld.ts@@ -229,7 +229,7 @@ export class DOMWorld {}async content(): Promise<string> {- return await this.evaluate(() => {+ return this.evaluate(() => {let retVal = '';if (document.doctype) {retVal = new XMLSerializer().serializeToString(document.doctype);@@ -256,9 +256,9 @@ export class DOMWorld {} = options;// We rely upon the fact that document.open() will reset frame lifecycle with "init"// lifecycle event. @see https://crrev.com/608658- await this.evaluate<(x: string) => void>((html) => {+ await this.evaluate<(x: string) => void>((_html) => {document.open();- document.write(html);+ document.write(_html);document.close();}, html);const watcher = new LifecycleWatcher(@@ -277,150 +277,6 @@ export class DOMWorld {}}- /**- * Adds a script tag into the current context.- *- * @remarks- *- * You can pass a URL, filepath or string of contents. Note that when running Puppeteer- * in a browser environment you cannot pass a filepath and should use either- * `url` or `content`.- */- async addScriptTag(options: {- url?: string;- path?: string;- content?: string;- id?: string;- type?: string;- }): Promise<ElementHandle> {- const {- url = null,- path = null,- content = null,- id = '',- type = '',- } = options;- if (url !== null) {- try {- const context = await this.executionContext();- const handle = await context.evaluateHandle(- addScriptUrl,- url,- id,- type- );- const elementHandle = handle.asElement();- if (elementHandle === null) {- throw new Error('Script element is not found');- }-- return elementHandle;- } catch (error) {- throw new Error(`Loading script from ${url} failed`);- }- }-- if (path !== null) {- let fs;- try {- fs = (await import('fs')).promises;- } catch (error) {- if (error instanceof TypeError) {- throw new Error(- 'Can only pass a filepath to addScriptTag in a Node-like environment.'- );- }-- throw error;- }-- let contents = await fs.readFile(path, 'utf8');- contents += '//# sourceURL=' + path.replace(/\n/g, '');- const context = await this.executionContext();- const handle = await context.evaluateHandle(- addScriptContent,- contents,- id,- type- );- const elementHandle = handle.asElement();- if (elementHandle === null) {- throw new Error('Script element is not found');- }-- return elementHandle;- }-- if (content !== null) {- const context = await this.executionContext();- const handle = await context.evaluateHandle(- addScriptContent,- content,- id,- type- );- const elementHandle = handle.asElement();- if (elementHandle === null) {- throw new Error('Script element is not found');- }-- return elementHandle;- }-- throw new Error(- 'Provide an object with a `url`, `path` or `content` property'- );-- async function addScriptUrl(- url: string,- id: string,- type: string- ): Promise<HTMLElement> {- const script = document.createElement('script');- script.src = url;- if (id) {- script.id = id;- }-- if (type) {- script.type = type;- }-- const promise = new Promise((res, rej) => {- script.onload = res;- script.onerror = rej;- });- document.head.appendChild(script);- await promise;- return script;- }-- function addScriptContent(- content: string,- id: string,- type = 'text/javascript'- ): HTMLElement {- const script = document.createElement('script');- script.type = type;- script.text = content;- if (id) {- script.id = id;- }-- let error = null;- script.onerror = (e) => {- return (error = e);- };-- document.head.appendChild(script);- if (error) {- throw error;- }-- return script;- }- }-/*** Adds a style tag into the current context.*diff --git a/packages/renderer/src/browser/FrameManager.ts b/packages/renderer/src/browser/FrameManager.tsindex 5c27b94cf8..4193ca9aa8 100644--- a/packages/renderer/src/browser/FrameManager.ts+++ b/packages/renderer/src/browser/FrameManager.ts@@ -1008,21 +1008,6 @@ export class Frame {return this.#detached;}- /**- * Adds a `<script>` tag into the page with the desired url or content.- *- * @param options - configure the script to add to the page.- *- * @returns a promise that resolves to the added tag when the script's- * `onload` event fires or when the script content was injected into the- * frame.- */- async addScriptTag(- options: FrameAddScriptTagOptions- ): Promise<ElementHandle> {- return this._mainWorld.addScriptTag(options);- }-/*** Adds a `<link rel="stylesheet">` tag into the page with the desired url or* a `<style type="text/css">` tag with the content.diff --git a/packages/renderer/src/browser/Page.ts b/packages/renderer/src/browser/Page.tsindex f96d630535..3dc3bf7444 100644--- a/packages/renderer/src/browser/Page.ts+++ b/packages/renderer/src/browser/Page.ts@@ -1164,23 +1164,6 @@ export class Page extends EventEmitter {}}- /**- * Adds a `<script>` tag into the page with the desired URL or content.- * @remarks- * Shortcut for {@link Frame.addScriptTag | page.mainFrame().addScriptTag(options) }.- * @returns Promise which resolves to the added tag when the script's onload fires or- * when the script content was injected into frame.- */- async addScriptTag(options: {- url?: string;- path?: string;- content?: string;- type?: string;- id?: string;- }): Promise<ElementHandle> {- return this.mainFrame().addScriptTag(options);- }-/*** Adds a `<link rel="stylesheet">` tag into the page with the desired URL or a* `<style type="text/css">` tag with the content.