fix(electron): fix electron types, move source to src/server/electron (#3583)

This commit is contained in:
Dmitry Gozman 2020-08-23 13:46:40 -07:00 committed by GitHub
parent 53ac35a613
commit 77f803140a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 69 additions and 52 deletions

View File

@ -1,29 +0,0 @@
# NOTE: .npmignore is copied over to every subpackage in //packages when NPM packages
# are built.
#
# this ignores everything by default, except for package.json and LICENSE and README.md
# see https://docs.npmjs.com/misc/developers
**/*
# include sources from lib except for injected, but not map files
!lib/**/*.js
# Include Windows dependency checker executable.
!bin/PrintDeps.exe
# Injected files are included via lib/generated, see src/injected/README.md
lib/injected/
#types
!types/*
!index.d.ts
!electron-types.d.ts
!index.js
!index.mjs
!install.js
!README.md
!LICENSE
!NOTICE
!api.md
!protocol.yml
# browser descriptor
!browsers.json

View File

@ -15,7 +15,7 @@
*/
const { Playwright } = require('./lib/server/playwright');
const { Electron } = require('./lib/server/electron');
const { Electron } = require('./lib/server/electron/electron');
const { setupInProcess } = require('./lib/rpc/inprocess');
const path = require('path');

View File

@ -28,7 +28,7 @@ const cpAsync = util.promisify(ncp);
const SCRIPT_NAME = path.basename(__filename);
const ROOT_PATH = path.join(__dirname, '..');
const PLAYWRIGHT_CORE_FILES = ['bin', 'lib', 'types', 'NOTICE', 'LICENSE', '.npmignore'];
const PLAYWRIGHT_CORE_FILES = ['bin', 'lib', 'types', 'NOTICE', 'LICENSE'];
const PACKAGES = {
'playwright': {
@ -61,7 +61,7 @@ const PACKAGES = {
version: '0.4.0', // Manually manage playwright-electron version.
description: 'A high-level API to automate Electron',
browsers: [],
files: PLAYWRIGHT_CORE_FILES,
files: [...PLAYWRIGHT_CORE_FILES, 'electron-types.d.ts'],
},
};

View File

@ -0,0 +1,35 @@
# NOTE: theoretically, we can remove this file, because we always create
# a directory for each package and only copy necessary files there.
# However, we keep it to double check the list of files.
#
# This ignores everything by default, except for package.json and LICENSE and README.md.
# See https://docs.npmjs.com/misc/developers
**/*
# Include sources from lib, but not map files.
!lib/**/*.js
# Exclude injected files. A preprocessed version of these is included via lib/generated.
# See src/injected/README.md.
lib/injected/
# Include Windows dependency checker executable.
!bin/PrintDeps.exe
# Include generated types and entrypoint.
!types/*
!index.d.ts
# Include separate electron types.
!electron-types.d.ts
# Include main entrypoint.
!index.js
# Include main entrypoint for ES Modules.
!index.mjs
# Include installer.
!install.js
# Include essentials.
!README.md
!LICENSE
!NOTICE
# Include protocol and api docs, so that dependent packages can consume them.
!api.md
!protocol.yml
# Include browser descriptors.
!browsers.json

View File

@ -49,6 +49,7 @@ function run_tests {
test_playwright_global_installation
test_playwright_global_installation_cross_package
test_playwright_electron_should_work
test_electron_types
}
function test_typescript_types {
@ -241,6 +242,16 @@ function test_playwright_electron_should_work {
xvfb-run --auto-servernum -- bash -c "node sanity-electron.js"
}
function test_electron_types {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_ELECTRON_TGZ}
npm install electron@9.0
npm install -D typescript@3.8
npm install -D @types/node@10.17
echo "import { Page, electron, ElectronApplication, ElectronLauncher } from 'playwright-electron';" > "test.ts"
npx tsc "test.ts"
}
function initialize_test {
cd ${TEST_ROOT}
local TEST_NAME="./$1"

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { ElectronLauncher } from 'playwright-core/electron-types';
export * from 'playwright-core/types/types';
export * from 'playwright-core/electron-types';
import { ElectronLauncher } from './electron-types';
export * from './types/types';
export * from './electron-types';
export const electron: ElectronLauncher;

View File

@ -15,7 +15,7 @@
*/
const { Playwright } = require('./lib/server/playwright');
const { Electron } = require('./lib/server/electron');
const { Electron } = require('./lib/server/electron/electron');
const { setupInProcess } = require('./lib/rpc/inprocess');
const playwright = new Playwright(__dirname, require('./browsers.json')['browsers']);

View File

@ -18,7 +18,7 @@ import { Transport } from '../protocol/transport';
import { DispatcherConnection } from './server/dispatcher';
import { Playwright } from '../server/playwright';
import { PlaywrightDispatcher } from './server/playwrightDispatcher';
import { Electron } from '../server/electron';
import { Electron } from '../server/electron/electron';
import { gracefullyCloseAll } from '../server/processLauncher';
const dispatcherConnection = new DispatcherConnection();

View File

@ -15,7 +15,7 @@
*/
import { Dispatcher, DispatcherScope, lookupDispatcher } from './dispatcher';
import { Electron, ElectronApplication, ElectronPage } from '../../server/electron';
import { Electron, ElectronApplication, ElectronPage } from '../../server/electron/electron';
import * as channels from '../../protocol/channels';
import { BrowserContextDispatcher } from './browserContextDispatcher';
import { PageDispatcher } from './pageDispatcher';

View File

@ -19,7 +19,7 @@ import * as channels from '../../protocol/channels';
import { BrowserTypeDispatcher } from './browserTypeDispatcher';
import { Dispatcher, DispatcherScope } from './dispatcher';
import { SelectorsDispatcher } from './selectorsDispatcher';
import { Electron } from '../../server/electron';
import { Electron } from '../../server/electron/electron';
import { ElectronDispatcher } from './electronDispatcher';
import { DeviceDescriptors } from '../../deviceDescriptors';

View File

@ -15,21 +15,21 @@
*/
import * as path from 'path';
import { CRBrowser, CRBrowserContext } from './chromium/crBrowser';
import { CRConnection, CRSession } from './chromium/crConnection';
import { CRExecutionContext } from './chromium/crExecutionContext';
import * as js from '../javascript';
import { Page } from '../page';
import { TimeoutSettings } from '../utils/timeoutSettings';
import { WebSocketTransport } from '../transport';
import * as types from '../types';
import { launchProcess, waitForLine, envArrayToObject } from './processLauncher';
import { BrowserContext } from '../browserContext';
import { CRBrowser, CRBrowserContext } from '../chromium/crBrowser';
import { CRConnection, CRSession } from '../chromium/crConnection';
import { CRExecutionContext } from '../chromium/crExecutionContext';
import * as js from '../../javascript';
import { Page } from '../../page';
import { TimeoutSettings } from '../../utils/timeoutSettings';
import { WebSocketTransport } from '../../transport';
import * as types from '../../types';
import { launchProcess, waitForLine, envArrayToObject } from '../processLauncher';
import { BrowserContext } from '../../browserContext';
import type {BrowserWindow} from 'electron';
import { runAbortableTask, ProgressController } from '../progress';
import { runAbortableTask, ProgressController } from '../../progress';
import { EventEmitter } from 'events';
import { helper } from '../helper';
import { BrowserProcess } from '../browser';
import { helper } from '../../helper';
import { BrowserProcess } from '../../browser';
export type ElectronLaunchOptionsBase = {
args?: string[],