chore: create node directory for Node-only files (#6041)

This is another step towards making Puppeteer agnostic of environment
and being able to run in Node or a browser.

The files in the `node` directory are ones that would only be needed in
the Node build - e.g. the code that downloads and launches a local
browser instance.

The long term vision here is to have three folders:

* node - Node only code
* web - Web only code
* common - code that is shared

But rather than do that in one PR I'm going to split it up to make it
easier to review and deal with.
This commit is contained in:
Jack Franklin 2020-06-18 13:49:59 +01:00 committed by GitHub
parent ce34c0a4ff
commit 90b0934f85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 21 additions and 22 deletions

View File

@ -54,7 +54,6 @@ export class Browser extends EventEmitter {
_closeCallback: BrowserCloseCallback;
_defaultContext: BrowserContext;
_contexts: Map<string, BrowserContext>;
// TODO: once Target is in TypeScript we can type this properly.
_targets: Map<string, Target>;
constructor(

View File

@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Launcher from './Launcher';
import Launcher from './node/Launcher';
import {
LaunchOptions,
ChromeArgOptions,
BrowserOptions,
} from './launcher/LaunchOptions';
import { ProductLauncher } from './Launcher';
import { BrowserFetcher, BrowserFetcherOptions } from './BrowserFetcher';
} from './node/LaunchOptions';
import { ProductLauncher } from './node/Launcher';
import { BrowserFetcher, BrowserFetcherOptions } from './node/BrowserFetcher';
import { puppeteerErrors, PuppeteerErrors } from './Errors';
import { ConnectionTransport } from './ConnectionTransport';

View File

@ -25,7 +25,7 @@
*/
export * from './Accessibility';
export * from './Browser';
export * from './BrowserFetcher';
export * from './node/BrowserFetcher';
export * from './Connection';
export * from './ConsoleMessage';
export * from './Coverage';

View File

@ -22,7 +22,7 @@ module.exports = {
Accessibility: require('./Accessibility').Accessibility,
Browser: require('./Browser').Browser,
BrowserContext: require('./Browser').BrowserContext,
BrowserFetcher: require('./BrowserFetcher').BrowserFetcher,
BrowserFetcher: require('./node/BrowserFetcher').BrowserFetcher,
CDPSession: require('./Connection').CDPSession,
ConsoleMessage: require('./ConsoleMessage').ConsoleMessage,
Coverage: require('./Coverage').Coverage,

View File

@ -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 '../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 '../assert';
import { helper } from '../helper';
const debugFetcher = debug(`puppeteer:fetcher`);
const downloadURLs = {

View File

@ -23,7 +23,7 @@ import { helper, debugError } from '../helper';
import { LaunchOptions } from './LaunchOptions';
import { Connection } from '../Connection';
import { WebSocketTransport } from '../WebSocketTransport';
import { PipeTransport } from '../PipeTransport';
import { PipeTransport } from './PipeTransport';
import * as readline from 'readline';
import { TimeoutError } from '../Errors';

View File

@ -21,13 +21,13 @@ 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 { BrowserRunner } from './launcher/BrowserRunner';
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 { BrowserRunner } from './BrowserRunner';
const mkdtempAsync = helper.promisify(fs.mkdtemp);
const writeFileAsync = helper.promisify(fs.writeFile);
@ -36,7 +36,7 @@ import {
ChromeArgOptions,
LaunchOptions,
BrowserOptions,
} from './launcher/LaunchOptions';
} from './LaunchOptions';
export interface ProductLauncher {
launch(object);

View File

@ -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 '../helper';
import { ConnectionTransport } from '../ConnectionTransport';
export class PipeTransport implements ConnectionTransport {
_pipeWrite: NodeJS.WritableStream;

View File

@ -61,7 +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', 'launcher'), 'ts')),
...(await Source.readdir(path.join(PROJECT_DIR, 'src', 'node'), 'ts')),
];
const tsSourcesNoDefinitions = tsSources.filter(