mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: create common
directory (#6042)
These files will be used by both the web and node versions of Puppeteer. Another name for this might be "core" but I don't want to cause confusion with the puppeteer-core package that we publish at the moment.
This commit is contained in:
parent
f6af7b8df0
commit
9522f80116
@ -14,4 +14,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
module.exports = require('./lib/DeviceDescriptors');
|
||||
module.exports = require('./lib/common/DeviceDescriptors');
|
||||
|
@ -14,4 +14,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
module.exports = require('./lib/Errors');
|
||||
module.exports = require('./lib/common/Errors');
|
||||
|
@ -23,26 +23,25 @@
|
||||
*
|
||||
* Once we have migrated to API Extractor and removed DocLint we can remove the duplication and use this file.
|
||||
*/
|
||||
export * from './Accessibility';
|
||||
export * from './Browser';
|
||||
export * from './common/Accessibility';
|
||||
export * from './common/Browser';
|
||||
export * from './node/BrowserFetcher';
|
||||
export * from './Connection';
|
||||
export * from './ConsoleMessage';
|
||||
export * from './Coverage';
|
||||
export * from './Dialog';
|
||||
export * from './JSHandle';
|
||||
export * from './ExecutionContext';
|
||||
export * from './EventEmitter';
|
||||
export * from './FileChooser';
|
||||
export * from './FrameManager';
|
||||
export * from './JSHandle';
|
||||
export * from './Input';
|
||||
export * from './Page';
|
||||
export * from './Puppeteer';
|
||||
export * from './HTTPRequest';
|
||||
export * from './HTTPResponse';
|
||||
export * from './SecurityDetails';
|
||||
export * from './Target';
|
||||
export * from './Errors';
|
||||
export * from './Tracing';
|
||||
export * from './WebWorker';
|
||||
export * from './common/Connection';
|
||||
export * from './common/ConsoleMessage';
|
||||
export * from './common/Coverage';
|
||||
export * from './common/Dialog';
|
||||
export * from './common/JSHandle';
|
||||
export * from './common/ExecutionContext';
|
||||
export * from './common/EventEmitter';
|
||||
export * from './common/FileChooser';
|
||||
export * from './common/FrameManager';
|
||||
export * from './common/Input';
|
||||
export * from './common/Page';
|
||||
export * from './common/Puppeteer';
|
||||
export * from './common/HTTPRequest';
|
||||
export * from './common/HTTPResponse';
|
||||
export * from './common/SecurityDetails';
|
||||
export * from './common/Target';
|
||||
export * from './common/Errors';
|
||||
export * from './common/Tracing';
|
||||
export * from './common/WebWorker';
|
||||
|
50
src/api.ts
50
src/api.ts
@ -19,30 +19,30 @@
|
||||
* 2) index.js uses it to iterate through all methods and call helper.installAsyncStackHooks on
|
||||
*/
|
||||
module.exports = {
|
||||
Accessibility: require('./Accessibility').Accessibility,
|
||||
Browser: require('./Browser').Browser,
|
||||
BrowserContext: require('./Browser').BrowserContext,
|
||||
Accessibility: require('./common/Accessibility').Accessibility,
|
||||
Browser: require('./common/Browser').Browser,
|
||||
BrowserContext: require('./common/Browser').BrowserContext,
|
||||
BrowserFetcher: require('./node/BrowserFetcher').BrowserFetcher,
|
||||
CDPSession: require('./Connection').CDPSession,
|
||||
ConsoleMessage: require('./ConsoleMessage').ConsoleMessage,
|
||||
Coverage: require('./Coverage').Coverage,
|
||||
Dialog: require('./Dialog').Dialog,
|
||||
ElementHandle: require('./JSHandle').ElementHandle,
|
||||
ExecutionContext: require('./ExecutionContext').ExecutionContext,
|
||||
EventEmitter: require('./EventEmitter').EventEmitter,
|
||||
FileChooser: require('./FileChooser').FileChooser,
|
||||
Frame: require('./FrameManager').Frame,
|
||||
JSHandle: require('./JSHandle').JSHandle,
|
||||
Keyboard: require('./Input').Keyboard,
|
||||
Mouse: require('./Input').Mouse,
|
||||
Page: require('./Page').Page,
|
||||
Puppeteer: require('./Puppeteer').Puppeteer,
|
||||
HTTPRequest: require('./HTTPRequest').HTTPRequest,
|
||||
HTTPResponse: require('./HTTPResponse').HTTPResponse,
|
||||
SecurityDetails: require('./SecurityDetails').SecurityDetails,
|
||||
Target: require('./Target').Target,
|
||||
TimeoutError: require('./Errors').TimeoutError,
|
||||
Touchscreen: require('./Input').Touchscreen,
|
||||
Tracing: require('./Tracing').Tracing,
|
||||
WebWorker: require('./WebWorker').WebWorker,
|
||||
CDPSession: require('./common/Connection').CDPSession,
|
||||
ConsoleMessage: require('./common/ConsoleMessage').ConsoleMessage,
|
||||
Coverage: require('./common/Coverage').Coverage,
|
||||
Dialog: require('./common/Dialog').Dialog,
|
||||
ElementHandle: require('./common/JSHandle').ElementHandle,
|
||||
ExecutionContext: require('./common/ExecutionContext').ExecutionContext,
|
||||
EventEmitter: require('./common/EventEmitter').EventEmitter,
|
||||
FileChooser: require('./common/FileChooser').FileChooser,
|
||||
Frame: require('./common/FrameManager').Frame,
|
||||
JSHandle: require('./common/JSHandle').JSHandle,
|
||||
Keyboard: require('./common/Input').Keyboard,
|
||||
Mouse: require('./common/Input').Mouse,
|
||||
Page: require('./common/Page').Page,
|
||||
Puppeteer: require('./common/Puppeteer').Puppeteer,
|
||||
HTTPRequest: require('./common/HTTPRequest').HTTPRequest,
|
||||
HTTPResponse: require('./common/HTTPResponse').HTTPResponse,
|
||||
SecurityDetails: require('./common/SecurityDetails').SecurityDetails,
|
||||
Target: require('./common/Target').Target,
|
||||
TimeoutError: require('./common/Errors').TimeoutError,
|
||||
Touchscreen: require('./common/Input').Touchscreen,
|
||||
Tracing: require('./common/Tracing').Tracing,
|
||||
WebWorker: require('./common/WebWorker').WebWorker,
|
||||
};
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import { CDPSession } from './Connection';
|
||||
import { ElementHandle } from './JSHandle';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
|
||||
/**
|
||||
* Represents a Node and the properties of it that are relevant to Accessibility.
|
@ -19,7 +19,7 @@ import { helper } from './helper';
|
||||
import { Target } from './Target';
|
||||
import { EventEmitter } from './EventEmitter';
|
||||
import { Events } from './Events';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
import { Connection } from './Connection';
|
||||
import { Page } from './Page';
|
||||
import { ChildProcess } from 'child_process';
|
@ -19,7 +19,7 @@ import { debug } from './Debug';
|
||||
const debugProtocolSend = debug('puppeteer:protocol:SEND ►');
|
||||
const debugProtocolReceive = debug('puppeteer:protocol:RECV ◀');
|
||||
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
import { ConnectionTransport } from './ConnectionTransport';
|
||||
import { EventEmitter } from './EventEmitter';
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import { assert } from './assert';
|
||||
import { helper, debugError, PuppeteerEventListener } from './helper';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
import { CDPSession } from './Connection';
|
||||
|
||||
import { EVALUATION_SCRIPT_URL } from './ExecutionContext';
|
@ -16,7 +16,7 @@
|
||||
|
||||
import { assert } from './assert';
|
||||
import { CDPSession } from './Connection';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
|
||||
/**
|
||||
* Dialog instances are dispatched by the {@link Page} via the `dialog` event.
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
import { CDPSession } from './Connection';
|
||||
import { Viewport } from './PuppeteerViewport';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
|
||||
export class EmulationManager {
|
||||
_client: CDPSession;
|
@ -20,7 +20,7 @@ import { createJSHandle, JSHandle, ElementHandle } from './JSHandle';
|
||||
import { CDPSession } from './Connection';
|
||||
import { DOMWorld } from './DOMWorld';
|
||||
import { Frame } from './FrameManager';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
|
||||
export const EVALUATION_SCRIPT_URL = '__puppeteer_evaluation_script__';
|
||||
const SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import { ElementHandle } from './JSHandle';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
import { assert } from './assert';
|
||||
|
||||
export class FileChooser {
|
@ -28,7 +28,7 @@ import { JSHandle, ElementHandle } from './JSHandle';
|
||||
import { MouseButtonInput } from './Input';
|
||||
import { Page } from './Page';
|
||||
import { HTTPResponse } from './HTTPResponse';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
|
||||
const UTILITY_WORLD_NAME = '__puppeteer_utility_world__';
|
||||
|
@ -18,7 +18,7 @@ import { Frame } from './FrameManager';
|
||||
import { HTTPResponse } from './HTTPResponse';
|
||||
import { assert } from './assert';
|
||||
import { helper, debugError } from './helper';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
|
||||
export class HTTPRequest {
|
||||
_requestId: string;
|
@ -17,7 +17,7 @@ import { CDPSession } from './Connection';
|
||||
import { Frame } from './FrameManager';
|
||||
import { HTTPRequest } from './HTTPRequest';
|
||||
import { SecurityDetails } from './SecurityDetails';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
|
||||
interface RemoteAddress {
|
||||
ip: string;
|
@ -22,7 +22,7 @@ import { CDPSession } from './Connection';
|
||||
import { KeyInput } from './USKeyboardLayout';
|
||||
import { FrameManager, Frame } from './FrameManager';
|
||||
import { getQueryHandlerAndSelector } from './QueryHandler';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
|
||||
interface BoxModel {
|
||||
content: Array<{ x: number; y: number }>;
|
@ -16,7 +16,7 @@
|
||||
import { EventEmitter } from './EventEmitter';
|
||||
import { assert } from './assert';
|
||||
import { helper, debugError } from './helper';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
import { Events } from './Events';
|
||||
import { CDPSession } from './Connection';
|
||||
import { FrameManager } from './FrameManager';
|
@ -40,7 +40,7 @@ import { TimeoutSettings } from './TimeoutSettings';
|
||||
import { FileChooser } from './FileChooser';
|
||||
import { ConsoleMessage } from './ConsoleMessage';
|
||||
import { PuppeteerLifeCycleEvent } from './LifecycleWatcher';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
|
||||
const writeFileAsync = helper.promisify(fs.writeFile);
|
||||
|
@ -13,19 +13,19 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import Launcher from './node/Launcher';
|
||||
import Launcher from '../node/Launcher';
|
||||
import {
|
||||
LaunchOptions,
|
||||
ChromeArgOptions,
|
||||
BrowserOptions,
|
||||
} from './node/LaunchOptions';
|
||||
import { ProductLauncher } from './node/Launcher';
|
||||
import { BrowserFetcher, BrowserFetcherOptions } from './node/BrowserFetcher';
|
||||
} from '../node/LaunchOptions';
|
||||
import { ProductLauncher } from '../node/Launcher';
|
||||
import { BrowserFetcher, BrowserFetcherOptions } from '../node/BrowserFetcher';
|
||||
import { puppeteerErrors, PuppeteerErrors } from './Errors';
|
||||
import { ConnectionTransport } from './ConnectionTransport';
|
||||
|
||||
import { devicesMap } from './DeviceDescriptors';
|
||||
import { DevicesMap } from './/DeviceDescriptors';
|
||||
import { DevicesMap } from './DeviceDescriptors';
|
||||
import { Browser } from './Browser';
|
||||
import {
|
||||
registerCustomQueryHandler,
|
||||
@ -102,7 +102,7 @@ export class Puppeteer {
|
||||
) {
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const packageJson = require('../package.json');
|
||||
const packageJson = require('../../package.json');
|
||||
switch (this._productName) {
|
||||
case 'firefox':
|
||||
this._preferredRevision = packageJson.puppeteer.firefox_revision;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
|
||||
export class SecurityDetails {
|
||||
private _subjectName: string;
|
@ -20,7 +20,7 @@ import { WebWorker } from './WebWorker';
|
||||
import { CDPSession } from './Connection';
|
||||
import { Browser, BrowserContext } from './Browser';
|
||||
import { Viewport } from './PuppeteerViewport';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
|
||||
export class Target {
|
||||
_targetInfo: Protocol.Target.TargetInfo;
|
@ -18,7 +18,7 @@ import { debugError } from './helper';
|
||||
import { ExecutionContext } from './ExecutionContext';
|
||||
import { JSHandle } from './JSHandle';
|
||||
import { CDPSession } from './Connection';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
|
||||
type ConsoleAPICalledCallback = (
|
||||
eventType: string,
|
@ -18,7 +18,7 @@ import { debug } from './Debug';
|
||||
import * as fs from 'fs';
|
||||
import { CDPSession } from './Connection';
|
||||
import { promisify } from 'util';
|
||||
import Protocol from './protocol';
|
||||
import Protocol from '../protocol';
|
||||
import { CommonEventEmitter } from './EventEmitter';
|
||||
import { assert } from './assert';
|
||||
|
@ -19,9 +19,9 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const api = require('./api');
|
||||
|
||||
import { helper } from './helper';
|
||||
import { Page } from './Page';
|
||||
import { Puppeteer } from './Puppeteer';
|
||||
import { helper } from './common/helper';
|
||||
import { Page } from './common/Page';
|
||||
import { Puppeteer } from './common/Puppeteer';
|
||||
|
||||
interface InitOptions {
|
||||
packageJson: {
|
||||
|
@ -23,13 +23,13 @@ import * as https from 'https';
|
||||
import * as http from 'http';
|
||||
|
||||
import extractZip from 'extract-zip';
|
||||
import { debug } from '../Debug';
|
||||
import { debug } from '../common/Debug';
|
||||
import removeRecursive from 'rimraf';
|
||||
import * as URL from 'url';
|
||||
import ProxyAgent from 'https-proxy-agent';
|
||||
import { getProxyForUrl } from 'proxy-from-env';
|
||||
import { assert } from '../assert';
|
||||
import { helper } from '../helper';
|
||||
import { assert } from '../common/assert';
|
||||
import { helper } from '../common/helper';
|
||||
const debugFetcher = debug(`puppeteer:fetcher`);
|
||||
|
||||
const downloadURLs = {
|
||||
|
@ -14,18 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { debug } from '../Debug';
|
||||
import { debug } from '../common/Debug';
|
||||
|
||||
import removeFolder from 'rimraf';
|
||||
import * as childProcess from 'child_process';
|
||||
import { assert } from '../assert';
|
||||
import { helper, debugError } from '../helper';
|
||||
import { assert } from '../common/assert';
|
||||
import { helper, debugError } from '../common/helper';
|
||||
import { LaunchOptions } from './LaunchOptions';
|
||||
import { Connection } from '../Connection';
|
||||
import { WebSocketTransport } from '../WebSocketTransport';
|
||||
import { Connection } from '../common/Connection';
|
||||
import { WebSocketTransport } from '../common/WebSocketTransport';
|
||||
import { PipeTransport } from './PipeTransport';
|
||||
import * as readline from 'readline';
|
||||
import { TimeoutError } from '../Errors';
|
||||
import { TimeoutError } from '../common/Errors';
|
||||
|
||||
const removeFolderAsync = helper.promisify(removeFolder);
|
||||
const debugLauncher = debug('puppeteer:launcher');
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Viewport } from '../PuppeteerViewport';
|
||||
import { Viewport } from '../common/PuppeteerViewport';
|
||||
|
||||
export interface ChromeArgOptions {
|
||||
headless?: boolean;
|
||||
|
@ -21,12 +21,12 @@ import * as URL from 'url';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import { BrowserFetcher } from './BrowserFetcher';
|
||||
import { Connection } from '../Connection';
|
||||
import { Browser } from '../Browser';
|
||||
import { assert } from '../assert';
|
||||
import { helper, debugError } from '../helper';
|
||||
import { ConnectionTransport } from '../ConnectionTransport';
|
||||
import { WebSocketTransport } from '../WebSocketTransport';
|
||||
import { Connection } from '../common/Connection';
|
||||
import { Browser } from '../common/Browser';
|
||||
import { assert } from '../common/assert';
|
||||
import { helper, debugError } from '../common/helper';
|
||||
import { ConnectionTransport } from '../common/ConnectionTransport';
|
||||
import { WebSocketTransport } from '../common/WebSocketTransport';
|
||||
import { BrowserRunner } from './BrowserRunner';
|
||||
|
||||
const mkdtempAsync = helper.promisify(fs.mkdtemp);
|
||||
|
@ -13,8 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { helper, debugError, PuppeteerEventListener } from '../helper';
|
||||
import { ConnectionTransport } from '../ConnectionTransport';
|
||||
import { helper, debugError, PuppeteerEventListener } from '../common/helper';
|
||||
import { ConnectionTransport } from '../common/ConnectionTransport';
|
||||
|
||||
export class PipeTransport implements ConnectionTransport {
|
||||
_pipeWrite: NodeJS.WritableStream;
|
||||
|
@ -1,4 +1,4 @@
|
||||
const { EventEmitter } = require('../lib/EventEmitter');
|
||||
const { EventEmitter } = require('../lib/common/EventEmitter');
|
||||
const sinon = require('sinon');
|
||||
const expect = require('expect');
|
||||
|
||||
|
@ -104,7 +104,7 @@ const trackCoverage = () => {
|
||||
|
||||
before(() => {
|
||||
const api = require('../lib/api');
|
||||
const events = require('../lib/Events');
|
||||
const events = require('../lib/common/Events');
|
||||
for (const [className, classType] of Object.entries(api))
|
||||
traceAPICoverage(coverageMap, events, className, classType);
|
||||
});
|
||||
|
@ -17,7 +17,7 @@ const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const sinon = require('sinon');
|
||||
const { helper } = require('../lib/helper');
|
||||
const { helper } = require('../lib/common/helper');
|
||||
const rmAsync = helper.promisify(require('rimraf'));
|
||||
const mkdtempAsync = helper.promisify(fs.mkdtemp);
|
||||
const readFileAsync = helper.promisify(fs.readFile);
|
||||
|
@ -61,6 +61,7 @@ async function run() {
|
||||
* we'll just list the directories manually.
|
||||
*/
|
||||
...(await Source.readdir(path.join(PROJECT_DIR, 'src'), 'ts')),
|
||||
...(await Source.readdir(path.join(PROJECT_DIR, 'src', 'common'), 'ts')),
|
||||
...(await Source.readdir(path.join(PROJECT_DIR, 'src', 'node'), 'ts')),
|
||||
];
|
||||
|
||||
@ -68,7 +69,11 @@ async function run() {
|
||||
(source) => !source.filePath().endsWith('.d.ts')
|
||||
);
|
||||
|
||||
const jsSources = await Source.readdir(path.join(PROJECT_DIR, 'lib'));
|
||||
const jsSources = [
|
||||
...(await Source.readdir(path.join(PROJECT_DIR, 'lib'))),
|
||||
...(await Source.readdir(path.join(PROJECT_DIR, 'lib', 'common'))),
|
||||
...(await Source.readdir(path.join(PROJECT_DIR, 'lib', 'node'))),
|
||||
];
|
||||
const allSrcCode = [...jsSources, ...tsSourcesNoDefinitions];
|
||||
messages.push(...(await checkPublicAPI(page, mdSources, allSrcCode)));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user