mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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 {LifecycleWatcher} = require('./LifecycleWatcher');
|
||||
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);
|
||||
|
||||
/**
|
||||
@ -27,7 +32,7 @@ class DOMWorld {
|
||||
/**
|
||||
* @param {!Puppeteer.FrameManager} frameManager
|
||||
* @param {!Puppeteer.Frame} frame
|
||||
* @param {!Puppeteer.TimeoutSettings} timeoutSettings
|
||||
* @param {!TimeoutSettings} timeoutSettings
|
||||
*/
|
||||
constructor(frameManager, frame, timeoutSettings) {
|
||||
this._frameManager = frameManager;
|
||||
|
@ -21,6 +21,9 @@ const {ExecutionContext, EVALUATION_SCRIPT_URL} = require('./ExecutionContext');
|
||||
const {LifecycleWatcher} = require('./LifecycleWatcher');
|
||||
const {DOMWorld} = require('./DOMWorld');
|
||||
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__';
|
||||
|
||||
@ -29,7 +32,7 @@ class FrameManager extends EventEmitter {
|
||||
* @param {!Puppeteer.CDPSession} client
|
||||
* @param {!Puppeteer.Page} page
|
||||
* @param {boolean} ignoreHTTPSErrors
|
||||
* @param {!Puppeteer.TimeoutSettings} timeoutSettings
|
||||
* @param {!TimeoutSettings} timeoutSettings
|
||||
*/
|
||||
constructor(client, page, ignoreHTTPSErrors, timeoutSettings) {
|
||||
super();
|
||||
|
@ -17,29 +17,26 @@
|
||||
const DEFAULT_TIMEOUT = 30000;
|
||||
|
||||
class TimeoutSettings {
|
||||
_defaultTimeout: number | null;
|
||||
_defaultNavigationTimeout: number | null;
|
||||
|
||||
constructor() {
|
||||
this._defaultTimeout = null;
|
||||
this._defaultNavigationTimeout = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} timeout
|
||||
*/
|
||||
setDefaultTimeout(timeout) {
|
||||
setDefaultTimeout(timeout: number): void {
|
||||
this._defaultTimeout = timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} timeout
|
||||
*/
|
||||
setDefaultNavigationTimeout(timeout) {
|
||||
setDefaultNavigationTimeout(timeout: number): void {
|
||||
this._defaultNavigationTimeout = timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
navigationTimeout() {
|
||||
navigationTimeout(): number {
|
||||
if (this._defaultNavigationTimeout !== null)
|
||||
return this._defaultNavigationTimeout;
|
||||
if (this._defaultTimeout !== null)
|
||||
@ -47,11 +44,11 @@ class TimeoutSettings {
|
||||
return DEFAULT_TIMEOUT;
|
||||
}
|
||||
|
||||
timeout() {
|
||||
timeout(): number {
|
||||
if (this._defaultTimeout !== null)
|
||||
return this._defaultTimeout;
|
||||
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 {JSHandle as RealJSHandle, ElementHandle as RealElementHandle} from './JSHandle.js';
|
||||
import {DOMWorld as RealDOMWorld} from './DOMWorld.js';
|
||||
import {TimeoutSettings as RealTimeoutSettings} from './TimeoutSettings.js';
|
||||
import {ExecutionContext as RealExecutionContext} from './ExecutionContext.js';
|
||||
import { NetworkManager as RealNetworkManager, Request as RealRequest, Response as RealResponse } from './NetworkManager.js';
|
||||
import * as child_process from 'child_process';
|
||||
@ -29,7 +28,6 @@ declare global {
|
||||
export class ElementHandle extends RealElementHandle {}
|
||||
export class JSHandle extends RealJSHandle {}
|
||||
export class DOMWorld extends RealDOMWorld {}
|
||||
export class TimeoutSettings extends RealTimeoutSettings {}
|
||||
export class ExecutionContext extends RealExecutionContext {}
|
||||
export class Page extends RealPage { }
|
||||
export class Response extends RealResponse { }
|
||||
|
Loading…
Reference in New Issue
Block a user