mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(electron): fix electron types, move source to src/server/electron (#3583)
This commit is contained in:
parent
53ac35a613
commit
77f803140a
29
.npmignore
29
.npmignore
@ -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
|
||||
2
index.js
2
index.js
@ -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');
|
||||
|
||||
|
||||
@ -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'],
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
35
packages/common/.npmignore
Normal file
35
packages/common/.npmignore
Normal 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
|
||||
@ -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"
|
||||
|
||||
6
packages/playwright-electron/index.d.ts
vendored
6
packages/playwright-electron/index.d.ts
vendored
@ -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;
|
||||
|
||||
@ -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']);
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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';
|
||||
|
||||
|
||||
@ -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[],
|
||||
Loading…
x
Reference in New Issue
Block a user