chore: migrate src/timeoutsettings
to typescript (#5691)
This commit is contained in:
parent
ad6c57aeb9
commit
6638a24346
@ -18,6 +18,11 @@ const fs = require('fs');
|
|||||||
const {helper, assert} = require('./helper');
|
const {helper, assert} = require('./helper');
|
||||||
const {LifecycleWatcher} = require('./LifecycleWatcher');
|
const {LifecycleWatcher} = require('./LifecycleWatcher');
|
||||||
const {TimeoutError} = require('./Errors');
|
const {TimeoutError} = require('./Errors');
|
||||||
|
|
||||||
|
// Used as a TypeDef
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
const {TimeoutSettings} = require('./TimeoutSettings');
|
||||||
|
|
||||||
const readFileAsync = helper.promisify(fs.readFile);
|
const readFileAsync = helper.promisify(fs.readFile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +32,7 @@ class DOMWorld {
|
|||||||
/**
|
/**
|
||||||
* @param {!Puppeteer.FrameManager} frameManager
|
* @param {!Puppeteer.FrameManager} frameManager
|
||||||
* @param {!Puppeteer.Frame} frame
|
* @param {!Puppeteer.Frame} frame
|
||||||
* @param {!Puppeteer.TimeoutSettings} timeoutSettings
|
* @param {!TimeoutSettings} timeoutSettings
|
||||||
*/
|
*/
|
||||||
constructor(frameManager, frame, timeoutSettings) {
|
constructor(frameManager, frame, timeoutSettings) {
|
||||||
this._frameManager = frameManager;
|
this._frameManager = frameManager;
|
||||||
|
@ -21,6 +21,9 @@ const {ExecutionContext, EVALUATION_SCRIPT_URL} = require('./ExecutionContext');
|
|||||||
const {LifecycleWatcher} = require('./LifecycleWatcher');
|
const {LifecycleWatcher} = require('./LifecycleWatcher');
|
||||||
const {DOMWorld} = require('./DOMWorld');
|
const {DOMWorld} = require('./DOMWorld');
|
||||||
const {NetworkManager} = require('./NetworkManager');
|
const {NetworkManager} = require('./NetworkManager');
|
||||||
|
// Used as a TypeDef
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
const {TimeoutSettings} = require('./TimeoutSettings');
|
||||||
|
|
||||||
const UTILITY_WORLD_NAME = '__puppeteer_utility_world__';
|
const UTILITY_WORLD_NAME = '__puppeteer_utility_world__';
|
||||||
|
|
||||||
@ -29,7 +32,7 @@ class FrameManager extends EventEmitter {
|
|||||||
* @param {!Puppeteer.CDPSession} client
|
* @param {!Puppeteer.CDPSession} client
|
||||||
* @param {!Puppeteer.Page} page
|
* @param {!Puppeteer.Page} page
|
||||||
* @param {boolean} ignoreHTTPSErrors
|
* @param {boolean} ignoreHTTPSErrors
|
||||||
* @param {!Puppeteer.TimeoutSettings} timeoutSettings
|
* @param {!TimeoutSettings} timeoutSettings
|
||||||
*/
|
*/
|
||||||
constructor(client, page, ignoreHTTPSErrors, timeoutSettings) {
|
constructor(client, page, ignoreHTTPSErrors, timeoutSettings) {
|
||||||
super();
|
super();
|
||||||
|
@ -17,29 +17,26 @@
|
|||||||
const DEFAULT_TIMEOUT = 30000;
|
const DEFAULT_TIMEOUT = 30000;
|
||||||
|
|
||||||
class TimeoutSettings {
|
class TimeoutSettings {
|
||||||
|
_defaultTimeout: number | null;
|
||||||
|
_defaultNavigationTimeout: number | null;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._defaultTimeout = null;
|
this._defaultTimeout = null;
|
||||||
this._defaultNavigationTimeout = null;
|
this._defaultNavigationTimeout = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
setDefaultTimeout(timeout: number): void {
|
||||||
* @param {number} timeout
|
|
||||||
*/
|
|
||||||
setDefaultTimeout(timeout) {
|
|
||||||
this._defaultTimeout = timeout;
|
this._defaultTimeout = timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} timeout
|
* @param {number} timeout
|
||||||
*/
|
*/
|
||||||
setDefaultNavigationTimeout(timeout) {
|
setDefaultNavigationTimeout(timeout: number): void {
|
||||||
this._defaultNavigationTimeout = timeout;
|
this._defaultNavigationTimeout = timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
navigationTimeout(): number {
|
||||||
* @return {number}
|
|
||||||
*/
|
|
||||||
navigationTimeout() {
|
|
||||||
if (this._defaultNavigationTimeout !== null)
|
if (this._defaultNavigationTimeout !== null)
|
||||||
return this._defaultNavigationTimeout;
|
return this._defaultNavigationTimeout;
|
||||||
if (this._defaultTimeout !== null)
|
if (this._defaultTimeout !== null)
|
||||||
@ -47,11 +44,11 @@ class TimeoutSettings {
|
|||||||
return DEFAULT_TIMEOUT;
|
return DEFAULT_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout() {
|
timeout(): number {
|
||||||
if (this._defaultTimeout !== null)
|
if (this._defaultTimeout !== null)
|
||||||
return this._defaultTimeout;
|
return this._defaultTimeout;
|
||||||
return DEFAULT_TIMEOUT;
|
return DEFAULT_TIMEOUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {TimeoutSettings};
|
export = {TimeoutSettings};
|
2
src/externs.d.ts
vendored
2
src/externs.d.ts
vendored
@ -6,7 +6,6 @@ import {Mouse as RealMouse, Keyboard as RealKeyboard, Touchscreen as RealTouchsc
|
|||||||
import {Frame as RealFrame, FrameManager as RealFrameManager} from './FrameManager.js';
|
import {Frame as RealFrame, FrameManager as RealFrameManager} from './FrameManager.js';
|
||||||
import {JSHandle as RealJSHandle, ElementHandle as RealElementHandle} from './JSHandle.js';
|
import {JSHandle as RealJSHandle, ElementHandle as RealElementHandle} from './JSHandle.js';
|
||||||
import {DOMWorld as RealDOMWorld} from './DOMWorld.js';
|
import {DOMWorld as RealDOMWorld} from './DOMWorld.js';
|
||||||
import {TimeoutSettings as RealTimeoutSettings} from './TimeoutSettings.js';
|
|
||||||
import {ExecutionContext as RealExecutionContext} from './ExecutionContext.js';
|
import {ExecutionContext as RealExecutionContext} from './ExecutionContext.js';
|
||||||
import { NetworkManager as RealNetworkManager, Request as RealRequest, Response as RealResponse } from './NetworkManager.js';
|
import { NetworkManager as RealNetworkManager, Request as RealRequest, Response as RealResponse } from './NetworkManager.js';
|
||||||
import * as child_process from 'child_process';
|
import * as child_process from 'child_process';
|
||||||
@ -29,7 +28,6 @@ declare global {
|
|||||||
export class ElementHandle extends RealElementHandle {}
|
export class ElementHandle extends RealElementHandle {}
|
||||||
export class JSHandle extends RealJSHandle {}
|
export class JSHandle extends RealJSHandle {}
|
||||||
export class DOMWorld extends RealDOMWorld {}
|
export class DOMWorld extends RealDOMWorld {}
|
||||||
export class TimeoutSettings extends RealTimeoutSettings {}
|
|
||||||
export class ExecutionContext extends RealExecutionContext {}
|
export class ExecutionContext extends RealExecutionContext {}
|
||||||
export class Page extends RealPage { }
|
export class Page extends RealPage { }
|
||||||
export class Response extends RealResponse { }
|
export class Response extends RealResponse { }
|
||||||
|
Loading…
Reference in New Issue
Block a user