feat: separate puppeteer and puppeteer-core (#9023)

This PR moves the puppeteer source code into separate mono-repo packages:

- `puppeteer` and `puppeteer-core` are now separated into their own
packages.
- `puppeteer-core` has a new exports called `puppeteer-core/internal`
for internal usage.

Tests and various tools have been updated to accommodate the migration.
This commit is contained in:
jrandolf 2022-10-05 14:17:03 +02:00 committed by GitHub
parent 3aee641c3d
commit f42336cf83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
193 changed files with 2022 additions and 10548 deletions

View File

@ -8,8 +8,8 @@ lib/
# Generated files # Generated files
**/*.tsbuildinfo **/*.tsbuildinfo
puppeteer.api.json *.api.json
puppeteer*.tgz *.tgz
yarn.lock yarn.lock
.docusaurus/ .docusaurus/
.cache-loader .cache-loader
@ -18,7 +18,9 @@ yarn.lock
test/output-*/ test/output-*/
.dev_profile* .dev_profile*
coverage/ coverage/
src/generated generated/
.eslintcache
/.cache/
# IDE Artifacts # IDE Artifacts
.vscode .vscode
@ -35,6 +37,8 @@ npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
# Wireit
.wireit
## [END] Keep in sync with .gitignore ## [END] Keep in sync with .gitignore
# ESLint ignores. # ESLint ignores.

View File

@ -60,7 +60,7 @@ jobs:
- name: Setup cache for Chromium binary - name: Setup cache for Chromium binary
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: .local-chromium path: packages/puppeteer-core/.local-chromium
key: ${{ runner.os }}-chromium-${{ hashFiles('src/revisions.ts') }} key: ${{ runner.os }}-chromium-${{ hashFiles('src/revisions.ts') }}
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
@ -226,23 +226,25 @@ jobs:
- name: Setup cache for Firefox binary - name: Setup cache for Firefox binary
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: .local-firefox path: packages/puppeteer-core/.local-firefox
key: ${{ runner.os }}-firefox-${{ hashFiles('src/revisions.ts') }} key: ${{ runner.os }}-firefox-${{ hashFiles('src/revisions.ts') }}
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@v3.4.1 uses: actions/setup-node@v3.4.1
with: with:
node-version: ${{ matrix.spec.node }} node-version: ${{ matrix.spec.node }}
- name: Update NPM
run: npm install -g npm@latest
- name: Install dependencies with Chromium - name: Install dependencies with Chromium
run: npm install run: npm ci
- name: Install Firefox - name: Install Firefox
env: env:
PUPPETEER_PRODUCT: firefox PUPPETEER_PRODUCT: firefox
run: npm install run: npm ci
- name: Install linux dependencies. - name: Install linux dependencies.
if: ${{ matrix.spec.xvfb }} if: ${{ matrix.spec.xvfb }}
run: sudo apt-get install xvfb run: sudo apt-get install xvfb
- name: Build - name: Build
run: npm run build:dev run: npm run build:test
- name: Test types - name: Test types
run: npm run test:types run: npm run test:types
- name: Run all tests with xvfb - name: Run all tests with xvfb
@ -278,7 +280,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
npm install npm install
ls .local-chromium ls packages/puppeteer-core/.local-chromium
- name: Build - name: Build
run: | run: |
npm run build npm run build

View File

@ -27,7 +27,7 @@ jobs:
working-directory: ./website working-directory: ./website
run: | run: |
npm install npm install
npm run docusaurus docs:version $(jq -r .version ../package.json) npm run docusaurus docs:version $(jq -r .version ../packages/puppeteer/package.json)
npm run archive npm run archive
- name: Re-build docs after versioning - name: Re-build docs after versioning
env: env:

View File

@ -16,24 +16,12 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Install dependencies - name: Install dependencies
run: npm install run: npm install
- name: Build puppeteer - name: Build packages
run: npm run build run: npm run build
- name: Publish puppeteer - name: Publish packages
env: env:
NPM_TOKEN: ${{secrets.NPM_TOKEN_PUPPETEER}} NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN_RELEASE}}
run: | run: |
npm config set registry 'https://wombat-dressing-room.appspot.com/' npm config set registry 'https://wombat-dressing-room.appspot.com/'
npm config set '//wombat-dressing-room.appspot.com/:_authToken' '${NPM_TOKEN}' npm config set '//wombat-dressing-room.appspot.com/:_authToken' $NODE_AUTH_TOKEN
echo "Publishing puppeteer" npm publish --workspaces
npm publish
# DEPRECATED_RANGE=$(node utils/get_deprecated_version_range.js)
# echo "Deprecating old puppeteer versions: $DEPRECATED_RANGE"
# npm deprecate puppeteer@$DEPRECATED_RANGE "Version no longer supported. Upgrade to @latest"
- name: Publish puppeteer-core
env:
NPM_TOKEN: ${{secrets.NPM_TOKEN_PUPPETEER_CORE}}
run: |
utils/prepare_puppeteer_core.js
npm config set registry 'https://wombat-dressing-room.appspot.com/'
npm config set '//wombat-dressing-room.appspot.com/:_authToken' '${NPM_TOKEN}'
npm publish

View File

@ -43,7 +43,7 @@ jobs:
echo "Installing revision $REV" echo "Installing revision $REV"
cat src/revisions.ts | sed "s/[0-9]\{6,\}/$REV/" > src/revisions.ts.replaced cat src/revisions.ts | sed "s/[0-9]\{6,\}/$REV/" > src/revisions.ts.replaced
mv src/revisions.ts.replaced src/revisions.ts mv src/revisions.ts.replaced src/revisions.ts
npm run build:dev npm run build:test
npm install npm install
- name: Run unit tests in headless - name: Run unit tests in headless
@ -81,7 +81,7 @@ jobs:
echo "Installing revision $REV" echo "Installing revision $REV"
cat src/revisions.ts | sed "s/[0-9]\{6,\}/$REV/" > src/revisions.ts.replaced cat src/revisions.ts | sed "s/[0-9]\{6,\}/$REV/" > src/revisions.ts.replaced
mv src/revisions.ts.replaced src/revisions.ts mv src/revisions.ts.replaced src/revisions.ts
npm run build:dev npm run build:test
npm install npm install
- name: Run unit tests in headful - name: Run unit tests in headful
@ -119,7 +119,7 @@ jobs:
echo "Installing revision $REV" echo "Installing revision $REV"
cat src/revisions.ts | sed "s/[0-9]\{6,\}/$REV/" > src/revisions.ts.replaced cat src/revisions.ts | sed "s/[0-9]\{6,\}/$REV/" > src/revisions.ts.replaced
mv src/revisions.ts.replaced src/revisions.ts mv src/revisions.ts.replaced src/revisions.ts
npm run build:dev npm run build:test
npm install npm install
- name: Run unit tests in chrome headless - name: Run unit tests in chrome headless

11
.gitignore vendored
View File

@ -7,8 +7,8 @@ lib/
# Generated files # Generated files
**/*.tsbuildinfo **/*.tsbuildinfo
puppeteer.api.json *.api.json
puppeteer*.tgz *.tgz
yarn.lock yarn.lock
.docusaurus/ .docusaurus/
.cache-loader .cache-loader
@ -17,7 +17,9 @@ yarn.lock
test/output-*/ test/output-*/
.dev_profile* .dev_profile*
coverage/ coverage/
src/generated generated/
.eslintcache
/.cache/
# IDE Artifacts # IDE Artifacts
.vscode .vscode
@ -33,3 +35,6 @@ src/generated
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
# Wireit
.wireit

View File

@ -8,8 +8,8 @@ lib/
# Generated files # Generated files
**/*.tsbuildinfo **/*.tsbuildinfo
puppeteer.api.json *.api.json
puppeteer*.tgz *.tgz
yarn.lock yarn.lock
.docusaurus/ .docusaurus/
.cache-loader .cache-loader
@ -18,7 +18,9 @@ yarn.lock
test/output-*/ test/output-*/
.dev_profile* .dev_profile*
coverage/ coverage/
src/generated generated/
.eslintcache
/.cache/
# IDE Artifacts # IDE Artifacts
.vscode .vscode
@ -34,13 +36,15 @@ src/generated
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
# Wireit
.wireit
## [END] Keep in sync with .gitignore ## [END] Keep in sync with .gitignore
# Prettier-only ignores. # Prettier-only ignores.
assets/ assets/
CHANGELOG.md CHANGELOG.md
package-lock.json package-lock.json
package.json
test/assets/ test/assets/
docs/ docs/
versioned_*/ versioned_*/

View File

@ -1,3 +1,5 @@
{ {
".": "18.1.0" "puppeteer": "18.1.0",
"puppeteer-core": "18.1.0",
"testserver": "0.5.0"
} }

View File

@ -1,8 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "../../lib/cjs/puppeteer",
"module": "CommonJS"
}
}

View File

@ -1,8 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "../../lib/esm/puppeteer",
"module": "esnext"
}
}

View File

@ -15,10 +15,11 @@ RUN apt-get update \
WORKDIR /home/pptruser WORKDIR /home/pptruser
COPY puppeteer-latest.tgz /home/pptruser/puppeteer-latest.tgz COPY puppeteer-latest.tgz /home/pptruser/puppeteer-latest.tgz
COPY puppeteer-core-latest.tgz /home/pptruser/puppeteer-core-latest.tgz
# Install puppeteer into /home/pptruser/node_modules. # Install puppeteer and puppeteer-core into /home/pptruser/node_modules.
RUN npm i ./puppeteer-latest.tgz \ RUN npm i ./puppeteer-core-latest.tgz ./puppeteer-latest.tgz \
&& rm puppeteer-latest.tgz \ && rm ./puppeteer-core-latest.tgz ./puppeteer-latest.tgz \
# Add user so we don't need --no-sandbox. # Add user so we don't need --no-sandbox.
# same layer as npm install to keep re-chowned files from using up several hundred MBs more space # same layer as npm install to keep re-chowned files from using up several hundred MBs more space
&& groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \ && groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \

View File

@ -4,10 +4,13 @@
# Expected cwd: project root directory. # Expected cwd: project root directory.
set -e set -e
set +x
FILENAME=$(npm pack) cd docker
echo $FILENAME npm pack --workspace puppeteer --workspace puppeteer-core --pack-destination .
mv $FILENAME docker/puppeteer-latest.tgz rm -f puppeteer-core-latest.tgz
rm -f puppeteer-latest.tgz
mv puppeteer-core-*.tgz puppeteer-core-latest.tgz
mv puppeteer-[0-9]*.tgz puppeteer-latest.tgz

View File

@ -7,6 +7,6 @@ sidebar_label: connect
**Signature:** **Signature:**
```typescript ```typescript
connect: (options: import('./types.js').ConnectOptions) => connect: (options: import('./types').ConnectOptions) =>
Promise<import('./types.js').Browser>; Promise<import('./types').Browser>;
``` ```

View File

@ -7,6 +7,7 @@ sidebar_label: createBrowserFetcher
**Signature:** **Signature:**
```typescript ```typescript
createBrowserFetcher: (options: import('./types.js').BrowserFetcherOptions) => createBrowserFetcher: (
import('./types.js').BrowserFetcher; options: import('puppeteer-core/internal/node/BrowserFetcher.js').BrowserFetcherOptions
) => import('puppeteer-core/internal/node/BrowserFetcher.js').BrowserFetcher;
``` ```

View File

@ -7,5 +7,5 @@ sidebar_label: defaultArgs
**Signature:** **Signature:**
```typescript ```typescript
defaultArgs: (options?: import("./types.js").BrowserLaunchArgumentOptions) => string[] defaultArgs: (options?: import("puppeteer-core/internal/node/LaunchOptions.js").BrowserLaunchArgumentOptions | undefined) => string[]
``` ```

View File

@ -7,6 +7,9 @@ sidebar_label: launch
**Signature:** **Signature:**
```typescript ```typescript
launch: (options?: import('./types.js').PuppeteerLaunchOptions) => launch: (
Promise<import('./types.js').Browser>; options?:
| import('puppeteer-core/internal/node/PuppeteerNode.js').PuppeteerLaunchOptions
| undefined
) => Promise<import('./types').Browser>;
``` ```

View File

@ -24,8 +24,8 @@ class Mouse {
| Parameter | Type | Description | | Parameter | Type | Description |
| --------- | ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --------- | ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| start | [Point](./puppeteer.point.md) | | | start | [Point](./puppeteer.point.md) | point to drag from |
| target | [Point](./puppeteer.point.md) | point to drag from | | target | [Point](./puppeteer.point.md) | point to drop on |
| options | { delay?: number; } | <i>(Optional)</i> An object of options. Accepts delay which, if specified, is the time to wait between <code>dragover</code> and <code>drop</code> in milliseconds. Defaults to 0. | | options | { delay?: number; } | <i>(Optional)</i> An object of options. Accepts delay which, if specified, is the time to wait between <code>dragover</code> and <code>drop</code> in milliseconds. Defaults to 0. |
**Returns:** **Returns:**

View File

@ -42,7 +42,7 @@ Puppeteer has two configurations for building:
- `npm run build` (or `npm run build:prod`) - Builds Puppeteer and artifacts - `npm run build` (or `npm run build:prod`) - Builds Puppeteer and artifacts
used in production. used in production.
- `npm run build:dev` - Builds Puppeteer, test runner, tests, and artifacts used in - `npm run build:test` - Builds Puppeteer, test runner, tests, and artifacts used in
production. production.
## Testing Puppeteer ## Testing Puppeteer
@ -50,7 +50,7 @@ Puppeteer has two configurations for building:
For browser testing, you can run For browser testing, you can run
```bash ```bash
npm run build:dev && npm run test npm run build:test && npm run test
``` ```
We also have other tests such as `test:types` that tests types and We also have other tests such as `test:types` that tests types and
@ -274,7 +274,7 @@ The following steps are needed to update the Chromium version.
1. Update `versions.js` with the new Chromium-to-Puppeteer version mapping and update `lastMaintainedChromiumVersion` with the latest stable Chrome version. 1. Update `versions.js` with the new Chromium-to-Puppeteer version mapping and update `lastMaintainedChromiumVersion` with the latest stable Chrome version.
1. Run `npm run check:protocol-revision`. 1. Run `npm run check:protocol-revision`.
If it fails, update `package.json` with the expected `devtools-protocol` version. If it fails, update `package.json` with the expected `devtools-protocol` version.
1. Run `npm run build && npm run build:dev` and `npm install`. 1. Run `npm run build && npm run build:test` and `npm install`.
1. Run `npm test` and ensure that all tests pass. If a test fails, [bisect](#bisecting-upstream-changes) the upstream cause of the failure, and either update the test expectations accordingly (if it was an intended change) or work around the changes in Puppeteer (if its not desirable to change Puppeteers observable behavior). 1. Run `npm test` and ensure that all tests pass. If a test fails, [bisect](#bisecting-upstream-changes) the upstream cause of the failure, and either update the test expectations accordingly (if it was an intended change) or work around the changes in Puppeteer (if its not desirable to change Puppeteers observable behavior).
1. Commit and push your changes and open a pull request. 1. Commit and push your changes and open a pull request.
The commit message must contain the version in `Chromium <version> (<revision>)` format to ensure that [pptr.dev](https://pptr.dev/) can parse it correctly, e.g. `'feat(chromium): roll to Chromium 90.0.4427.0 (r856583)'`. The commit message must contain the version in `Chromium <version> (<revision>)` format to ensure that [pptr.dev](https://pptr.dev/) can parse it correctly, e.g. `'feat(chromium): roll to Chromium 90.0.4427.0 (r856583)'`.

View File

@ -1,6 +0,0 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useNx": true,
"useWorkspaces": true,
"version": "0.0.0"
}

10779
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,88 +1,56 @@
{ {
"name": "puppeteer", "name": "puppeteer-repo",
"version": "18.1.0", "private": true,
"description": "A high-level API to control headless Chrome over the DevTools Protocol", "repository": {
"keywords": [ "type": "git",
"puppeteer", "url": "https://github.com/puppeteer/puppeteer"
"chrome",
"headless",
"automation"
],
"type": "commonjs",
"main": "./lib/cjs/puppeteer/puppeteer.js",
"exports": {
".": {
"types": "./lib/types.d.ts",
"import": "./lib/esm/puppeteer/puppeteer.js",
"require": "./lib/cjs/puppeteer/puppeteer.js"
},
"./*": {
"import": "./*",
"require": "./*"
}
},
"types": "lib/types.d.ts",
"repository": "github:puppeteer/puppeteer",
"engines": {
"node": ">=14.1.0"
}, },
"scripts": { "scripts": {
"test": "cross-env PUPPETEER_DEFERRED_PROMISE_DEBUG_TIMEOUT=20000 node utils/mochaRunner/lib/main.js", "build:test": "wireit",
"test:types": "tsd", "build": "npm run build --workspaces --if-present",
"test:install": "scripts/test-install.sh",
"test:firefox": "run-s test:firefox:*",
"test:firefox:headless": "npm run test -- --test-suite firefox-headless",
"test:firefox:headful": "npm run test -- --test-suite firefox-headful",
"test:chrome": "run-s test:chrome:*",
"test:chrome:headless": "npm run test -- --test-suite chrome-headless",
"test:chrome:headless-chrome": "npm run test -- --test-suite chrome-new-headless",
"test:chrome:headful": "npm run test -- --test-suite chrome-headful",
"prepublishOnly": "npm run build",
"prepare": "node typescript-if-required.js && husky install",
"lint": "run-s lint:prettier lint:eslint",
"lint:prettier": "prettier --check .",
"lint:eslint": "([ \"$CI\" = true ] && eslint --ext js --ext ts --quiet -f codeframe . || eslint --ext js --ext ts .)",
"install": "node install.js",
"generate:sources": "tsx utils/generate_sources.ts",
"generate:artifacts": "tsx utils/generate_artifacts.ts",
"generate:markdown": "tsx utils/generate_docs.ts",
"format": "run-s format:*",
"format:prettier": "prettier --write .",
"format:eslint": "eslint --ext js --ext ts --fix .",
"docs": "run-s build generate:markdown",
"debug": "npm run build:dev && mocha --inspect-brk",
"commitlint": "commitlint --from=HEAD~1",
"clean": "rimraf lib && rimraf test/build",
"check": "run-p check:*",
"check:protocol-revision": "tsx scripts/ensure-correct-devtools-protocol-package",
"check:pinned-deps": "tsx scripts/ensure-pinned-deps", "check:pinned-deps": "tsx scripts/ensure-pinned-deps",
"build": "npm run build:prod", "check": "npm run check --workspaces --if-present && run-p check:*",
"build:dev": "run-s generate:sources build:tsc:dev && run-p bundle:third_party generate:artifacts", "clean": "npm run clean --workspaces --if-present && rimraf **/.wireit",
"build:prod": "run-s generate:sources build:tsc:prod && run-p bundle:third_party generate:artifacts", "commitlint": "commitlint --from=HEAD~1",
"build:tsc:dev": "tsc -b test", "debug": "npm run build:test && mocha --inspect-brk",
"build:tsc:prod": "tsc -b tsconfig.lib.json", "docs": "run-s build generate:markdown",
"bundle:third_party": "rollup --config rollup.third_party.config.js" "format:eslint": "eslint --ext js --ext ts --fix .",
"format:prettier": "prettier --write .",
"format": "run-s format:*",
"generate:markdown": "tsx utils/generate_docs.ts",
"lint:eslint": "([ \"$CI\" = true ] && eslint --ext js --ext ts --quiet -f codeframe . || eslint --ext js --ext ts .)",
"lint:prettier": "prettier --check .",
"lint": "run-s lint:prettier lint:eslint",
"postinstall": "npm run postinstall --workspaces --if-present",
"prepare": "husky install",
"test:chrome:headful": "npm run test -- --test-suite chrome-headful",
"test:chrome:headless-chrome": "npm run test -- --test-suite chrome-new-headless",
"test:chrome:headless": "npm run test -- --test-suite chrome-headless",
"test:chrome": "run-s test:chrome:*",
"test:firefox:headful": "npm run test -- --test-suite firefox-headful",
"test:firefox:headless": "npm run test -- --test-suite firefox-headless",
"test:firefox": "run-s test:firefox:*",
"test:install": "test/test-install.sh",
"test:types": "tsd -t packages/puppeteer",
"test": "cross-env PUPPETEER_DEFERRED_PROMISE_DEBUG_TIMEOUT=20000 node utils/mochaRunner/lib/main.js"
}, },
"files": [ "wireit": {
"lib", "build:test": {
"install.js", "command": "tsc -b test",
"typescript-if-required.js", "clean": "if-file-deleted",
"!**/*.tsbuildinfo" "dependencies": [
], "./packages/puppeteer:build",
"author": "The Chromium Authors", "./packages/puppeteer-core:build",
"license": "Apache-2.0", "./packages/testserver:build"
"dependencies": { ],
"cross-fetch": "3.1.5", "files": [
"debug": "4.3.4", "test/src/**"
"devtools-protocol": "0.0.1045489", ],
"extract-zip": "2.0.1", "output": [
"https-proxy-agent": "5.0.1", "test/build/**",
"progress": "2.0.3", "test/tsconfig.tsbuildinfo"
"proxy-from-env": "1.1.0", ]
"rimraf": "3.0.2", }
"tar-fs": "2.1.1",
"unbzip2-stream": "1.4.3",
"ws": "8.9.0"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "17.1.2", "@commitlint/cli": "17.1.2",
@ -90,7 +58,7 @@
"@microsoft/api-documenter": "7.19.14", "@microsoft/api-documenter": "7.19.14",
"@microsoft/api-extractor": "7.31.2", "@microsoft/api-extractor": "7.31.2",
"@microsoft/api-extractor-model": "7.24.2", "@microsoft/api-extractor-model": "7.24.2",
"@pptr/testserver": "*", "@pptr/testserver": "0.5.0",
"@types/debug": "4.1.7", "@types/debug": "4.1.7",
"@types/diff": "5.0.2", "@types/diff": "5.0.2",
"@types/glob": "8.0.0", "@types/glob": "8.0.0",
@ -129,7 +97,6 @@
"gts": "4.0.0", "gts": "4.0.0",
"husky": "8.0.1", "husky": "8.0.1",
"jpeg-js": "0.4.4", "jpeg-js": "0.4.4",
"lerna": "5.5.2",
"mime": "3.0.0", "mime": "3.0.0",
"minimist": "1.2.6", "minimist": "1.2.6",
"mitt": "2.1.0", "mitt": "2.1.0",
@ -139,6 +106,7 @@
"pixelmatch": "5.3.0", "pixelmatch": "5.3.0",
"pngjs": "6.0.0", "pngjs": "6.0.0",
"prettier": "2.7.1", "prettier": "2.7.1",
"puppeteer": "18.1.0",
"rollup": "2.79.1", "rollup": "2.79.1",
"rollup-plugin-dts": "4.2.2", "rollup-plugin-dts": "4.2.2",
"rollup-plugin-node-resolve": "5.2.0", "rollup-plugin-node-resolve": "5.2.0",
@ -149,6 +117,7 @@
"tsd": "0.24.1", "tsd": "0.24.1",
"tsx": "3.9.0", "tsx": "3.9.0",
"typescript": "4.8.3", "typescript": "4.8.3",
"wireit": "0.7.2",
"zod": "3.19.1" "zod": "3.19.1"
}, },
"workspaces": [ "workspaces": [

View File

@ -9,7 +9,7 @@
"docModel": { "docModel": {
"enabled": true, "enabled": true,
"apiJsonFilePath": "<projectFolder>/docs/<unscopedPackageName>.api.json" "apiJsonFilePath": "<projectFolder>/../../docs/<unscopedPackageName>.api.json"
}, },
"dtsRollup": { "dtsRollup": {

View File

@ -0,0 +1,7 @@
{
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "../../lib/cjs/puppeteer"
}
}

View File

@ -0,0 +1,6 @@
{
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../lib/esm/puppeteer"
}
}

View File

@ -0,0 +1,154 @@
{
"name": "puppeteer-core",
"version": "18.1.0",
"description": "A high-level API to control headless Chrome over the DevTools Protocol",
"keywords": [
"puppeteer",
"chrome",
"headless",
"automation"
],
"type": "commonjs",
"main": "./lib/cjs/puppeteer/puppeteer-core.js",
"types": "./lib/types.d.ts",
"exports": {
".": {
"types": "./lib/types.d.ts",
"import": "./lib/esm/puppeteer/puppeteer-core.js",
"require": "./lib/cjs/puppeteer/puppeteer-core.js"
},
"./internal/*": {
"import": "./lib/esm/puppeteer/*",
"require": "./lib/cjs/puppeteer/*"
},
"./*": {
"import": "./*",
"require": "./*"
}
},
"repository": {
"type": "git",
"url": "https://github.com/puppeteer/puppeteer/tree/main/packages/puppeteer-core"
},
"engines": {
"node": ">=14.1.0"
},
"scripts": {
"build:third_party": "wireit",
"build:tsc": "wireit",
"build:types": "wireit",
"build": "wireit",
"check": "tsx tools/ensure-correct-devtools-protocol-package",
"clean": "tsc -b --clean && rimraf lib src/generated",
"format:types": "wireit",
"generate:package-json": "wireit",
"generate:sources": "wireit"
},
"wireit": {
"build": {
"dependencies": [
"build:third_party",
"format:types",
"generate:package-json"
]
},
"generate:sources": {
"command": "tsx tools/generate_sources.ts",
"files": [
"tools/generate_sources.ts",
"src/templates/**"
],
"output": [
"src/generated/**",
"src/types.ts"
]
},
"build:third_party": {
"command": "rollup --config rollup.third_party.config.js",
"dependencies": [
"build:tsc"
],
"clean": false,
"files": [
"lib/esm/third_party/**",
"lib/cjs/third_party/**"
],
"output": [
"lib/esm/third_party/**",
"lib/cjs/third_party/**"
]
},
"generate:package-json": {
"command": "echo '{\"type\": \"module\"}' > lib/esm/package.json",
"clean": "if-file-deleted",
"dependencies": [
"build:tsc"
],
"output": [
"lib/esm/package.json"
]
},
"build:types": {
"command": "api-extractor run --local",
"dependencies": [
"build:tsc"
],
"files": [
"tsconfig.json",
"api-extractor.json",
"lib/esm/puppeteer/types.d.ts"
],
"output": [
"lib/types.d.ts"
]
},
"format:types": {
"command": "eslint --cache-location .eslintcache --cache --ext=ts --no-ignore --no-eslintrc -c=../../.eslintrc.types.cjs --fix lib/types.d.ts",
"dependencies": [
"build:types"
],
"clean": false,
"files": [
"lib/types.d.ts",
"../../.eslintrc.types.cjs"
],
"output": [
"lib/types.d.ts"
]
},
"build:tsc": {
"command": "tsc -b",
"clean": "if-file-deleted",
"dependencies": [
"generate:sources"
],
"files": [
"src/**",
"compat/**",
"**/tsconfig.*.json"
],
"output": [
"lib/esm/**",
"lib/cjs/**"
]
}
},
"files": [
"lib",
"!*.tsbuildinfo"
],
"author": "The Chromium Authors",
"license": "Apache-2.0",
"dependencies": {
"cross-fetch": "3.1.5",
"debug": "4.3.4",
"devtools-protocol": "0.0.1045489",
"extract-zip": "2.0.1",
"https-proxy-agent": "5.0.1",
"proxy-from-env": "1.1.0",
"rimraf": "3.0.2",
"tar-fs": "2.1.1",
"unbzip2-stream": "1.4.3",
"ws": "8.9.0"
}
}

View File

@ -25,7 +25,7 @@ export default ['cjs', 'esm'].flatMap(outputType => {
for (const jsFile of glob.sync(`${thirdPartyPath}/**/*.js`)) { for (const jsFile of glob.sync(`${thirdPartyPath}/**/*.js`)) {
configs.push({ configs.push({
input: jsFile, input: jsFile,
output: {file: jsFile, exports: 'auto', format: outputType}, output: {file: jsFile, format: outputType},
plugins: [resolve()], plugins: [resolve()],
}); });
} }

View File

@ -61,7 +61,7 @@ export interface BrowserConnectOptions {
const getWebSocketTransportClass = async () => { const getWebSocketTransportClass = async () => {
return isNode return isNode
? (await import('../node/NodeWebSocketTransport.js')).NodeWebSocketTransport ? (await import('./NodeWebSocketTransport.js')).NodeWebSocketTransport
: (await import('./BrowserWebSocketTransport.js')) : (await import('./BrowserWebSocketTransport.js'))
.BrowserWebSocketTransport; .BrowserWebSocketTransport;
}; };

View File

@ -615,7 +615,7 @@ export class Mouse {
/** /**
* Performs a drag, dragenter, dragover, and drop in sequence. * Performs a drag, dragenter, dragover, and drop in sequence.
* @param target - point to drag from * @param start - point to drag from
* @param target - point to drop on * @param target - point to drop on
* @param options - An object of options. Accepts delay which, * @param options - An object of options. Accepts delay which,
* if specified, is the time to wait between `dragover` and `drop` in milliseconds. * if specified, is the time to wait between `dragover` and `drop` in milliseconds.

View File

@ -14,6 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
/**
* @internal
*/
declare const puppeteerDirname: string; declare const puppeteerDirname: string;
export {puppeteerDirname}; export {puppeteerDirname};

View File

@ -14,29 +14,27 @@
* limitations under the License. * limitations under the License.
*/ */
import * as os from 'os';
import * as fs from 'fs';
import * as path from 'path';
import * as util from 'util';
import * as childProcess from 'child_process'; import * as childProcess from 'child_process';
import * as https from 'https';
import * as http from 'http';
import {Product} from '../common/Product.js';
import extractZip from 'extract-zip'; import extractZip from 'extract-zip';
import {debug} from '../common/Debug.js'; import * as fs from 'fs';
import {promisify} from 'util'; import * as http from 'http';
import removeRecursive from 'rimraf'; import * as https from 'https';
import * as URL from 'url';
import createHttpsProxyAgent, { import createHttpsProxyAgent, {
HttpsProxyAgent, HttpsProxyAgent,
HttpsProxyAgentOptions, HttpsProxyAgentOptions,
} from 'https-proxy-agent'; } from 'https-proxy-agent';
import * as os from 'os';
import * as path from 'path';
import {getProxyForUrl} from 'proxy-from-env'; import {getProxyForUrl} from 'proxy-from-env';
import {assert} from '../util/assert.js'; import removeRecursive from 'rimraf';
import tar from 'tar-fs'; import tar from 'tar-fs';
import bzip from 'unbzip2-stream'; import bzip from 'unbzip2-stream';
import * as URL from 'url';
import * as util from 'util';
import {promisify} from 'util';
import {debug} from '../common/Debug.js';
import {Product} from '../common/Product.js';
import {assert} from '../util/assert.js';
const experimentalChromiumMacArm = const experimentalChromiumMacArm =
process.env['PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM'] || process.env['PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM'] ||

View File

@ -20,20 +20,20 @@ import * as path from 'path';
import * as readline from 'readline'; import * as readline from 'readline';
import removeFolder from 'rimraf'; import removeFolder from 'rimraf';
import {promisify} from 'util'; import {promisify} from 'util';
import {assert} from '../util/assert.js';
import {Connection} from '../common/Connection.js';
import {Connection as BiDiConnection} from '../common/bidi/Connection.js'; import {Connection as BiDiConnection} from '../common/bidi/Connection.js';
import {Connection} from '../common/Connection.js';
import {debug} from '../common/Debug.js'; import {debug} from '../common/Debug.js';
import {TimeoutError} from '../common/Errors.js'; import {TimeoutError} from '../common/Errors.js';
import {NodeWebSocketTransport as WebSocketTransport} from '../common/NodeWebSocketTransport.js';
import {Product} from '../common/Product.js';
import { import {
debugError,
addEventListener, addEventListener,
debugError,
PuppeteerEventListener, PuppeteerEventListener,
removeEventListeners, removeEventListeners,
} from '../common/util.js'; } from '../common/util.js';
import {assert} from '../util/assert.js';
import {isErrnoException, isErrorLike} from '../util/ErrorLike.js'; import {isErrnoException, isErrorLike} from '../util/ErrorLike.js';
import {Product} from '../common/Product.js';
import {NodeWebSocketTransport as WebSocketTransport} from '../node/NodeWebSocketTransport.js';
import {LaunchOptions} from './LaunchOptions.js'; import {LaunchOptions} from './LaunchOptions.js';
import {PipeTransport} from './PipeTransport.js'; import {PipeTransport} from './PipeTransport.js';

Some files were not shown because too many files have changed in this diff Show More