Skip to content

Commit

Permalink
move interfaces back into original files
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed May 13, 2020
1 parent 233cbbf commit 5ae1b1c
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 103 deletions.
12 changes: 11 additions & 1 deletion src/LifecycleWatcher.ts
Expand Up @@ -19,7 +19,17 @@ import { Events } from './Events';
import { TimeoutError } from './Errors';
import { FrameManager, Frame } from './FrameManager';
import { Request, Response } from './NetworkManager';
import { PuppeteerLifeCycleEvent, ProtocolLifeCycleEvent } from './types'

export type PuppeteerLifeCycleEvent =
| 'load'
| 'domcontentloaded'
| 'networkidle0'
| 'networkidle2';
type ProtocolLifeCycleEvent =
| 'load'
| 'DOMContentLoaded'
| 'networkIdle'
| 'networkAlmostIdle';

const puppeteerToProtocolLifecycle = new Map<
PuppeteerLifeCycleEvent,
Expand Down
78 changes: 73 additions & 5 deletions src/Page.ts
Expand Up @@ -39,14 +39,82 @@ import {
import { Accessibility } from './Accessibility';
import { TimeoutSettings } from './TimeoutSettings';
import { FileChooser } from './FileChooser';
import { ConsoleMessage } from './ConsoleMessage'
import {
ScreenshotOptions, PaperFormat, Metrics, WaitForOptions, MediaFeature,
ScreenshotClip, PDFOptions
} from './types'
import { ConsoleMessage } from './ConsoleMessage';
import { PuppeteerLifeCycleEvent } from './LifecycleWatcher';

const writeFileAsync = helper.promisify(fs.writeFile);

interface Metrics {
Timestamp?: number;
Documents?: number;
Frames?: number;
JSEventListeners?: number;
Nodes?: number;
LayoutCount?: number;
RecalcStyleCount?: number;
LayoutDuration?: number;
RecalcStyleDuration?: number;
ScriptDuration?: number;
TaskDuration?: number;
JSHeapUsedSize?: number;
JSHeapTotalSize?: number;
}

interface WaitForOptions {
timeout?: number;
waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
}

interface MediaFeature {
name: string;
value: string;
}

interface ScreenshotClip {
x: number;
y: number;
width: number;
height: number;
}

interface ScreenshotOptions {
type?: 'png' | 'jpeg';
path?: string;
fullPage?: boolean;
clip?: ScreenshotClip;
quality?: number;
omitBackground?: boolean;
encoding?: string;
}

interface PDFMargin {
top?: string | number;
bottom?: string | number;
left?: string | number;
right?: string | number;
}

interface PDFOptions {
scale?: number;
displayHeaderFooter?: boolean;
headerTemplate?: string;
footerTemplate?: string;
printBackground?: boolean;
landscape?: boolean;
pageRanges?: string;
format?: string;
width?: string | number;
height?: string | number;
preferCSSPageSize?: boolean;
margin?: PDFMargin;
path?: string;
}

interface PaperFormat {
width: number;
height: number;
}

const paperFormats: Record<string, PaperFormat> = {
letter: { width: 8.5, height: 11 },
legal: { width: 8.5, height: 14 },
Expand Down
97 changes: 0 additions & 97 deletions src/types.ts

This file was deleted.

0 comments on commit 5ae1b1c

Please sign in to comment.