Commit Graph

1910 Commits

Author SHA1 Message Date
Jack Franklin
3effcafcd1
chore: generate docs for the protocol (#6213) 2020-07-13 14:01:35 +01:00
Jack Franklin
ffec2475d0
chore: enforce file extensions on imports (#6202)
* chore: enforce file extensions on imports

To make our output agnostic it should include file extensions in the
output, as per the ESM spec. It's a bit odd for Node packages but makes
it easier to publish a browser build.
2020-07-13 10:22:26 +01:00
Changhao Han
8d6e0d8a79
chore: mark version to v5.1.0-post (#6208) 2020-07-13 10:43:46 +02:00
Changhao Han
8fa18aef99
chore: mark version v5.1.0 (#6206)
Co-authored-by: Changhao Han <changhaohan@chromium.org>
2020-07-13 10:25:14 +02:00
Changhao Han
790c277f0e
feat(chromium): roll Chromium to r768783 (#6201)
* feat(chromium): roll Chromium to r768783

* fix: update unit test for crrev:2135046

* chore: update devtools-protocol revision

Co-authored-by: Changhao Han <changhaohan@chromium.org>
2020-07-10 15:32:44 +02:00
Jack Franklin
9b3005c105
feat(types): improve page.evaluate types (#6193) 2020-07-10 11:52:13 +01:00
Jack Franklin
31309b0e20
chore: use devtools-protocol package (#6172)
* chore: Use devtools-protocol package

Rather than maintain our own protocol we can instead use the devtools-protocol package and pin it to the version of Chromium that Puppeteer is shipping with.

The only changes are naming changes between the bespoke protocol that Puppeteer created and the devtools-protocol one.
2020-07-10 11:51:52 +01:00
Jack Franklin
f666be3f5f
chore: remove src/api.ts (#6191)
Now the async hooks helper is gone api.ts was only used by the coverage
tools and by doclint.

DocLint is nearing the end of its lifespan with the TSDoc work, so I
focused on how best to define a list of modules for the coverage
tooling. They define an object of classes, and the path to that module.
They need the full path because we also check if the module exports any
events that need to be emitted - the coverage tool asserts that the
emitting of those events is also tested.

It's not _great_ that DocLint relies on a constant defined in the
coverage utils, but it should only be this way for a short period of
time and no one is actively working on DocLint (bar the effort to remove
it) so I don't think this is worth worrying about.

This change also broke the DocLint tests; based on the fact that DocLint is on its way out it doesn't feel worth fixing the tests, so this commit also removes them.
2020-07-10 10:07:28 +01:00
Jack Franklin
03a87e814d
chore(docs): tidy Puppeteer class docs (#6181)
* Mark properties as `private` or `@internal` so they don't get
  documented.
* Fix the `@returns` on a getter which gets ignored.
2020-07-09 14:49:27 +01:00
Jack Franklin
24cb6a28ad
chore(docs): document Frame class (#6188)
* chore: document Frame class
2020-07-09 14:22:58 +01:00
Jack Franklin
b9667f9331
chore: document browser install breakage on Node 14.0.0 (#6187) 2020-07-09 12:32:49 +01:00
Jack Franklin
12434663e2
chore: remove installAsyncStackHooks helper (#6186)
* chore: remove `installAsyncStackHooks` helper

This code was written when browsers/Node didn't support errors in async
functions very well. They now do a much better job of this, so we can
lose the additonal complexity from our codebase and leave it to the host
environment :)

* lazy launcher is private

* remove async stack test
2020-07-09 11:38:25 +01:00
Jack Franklin
19f188a852
chore: forbid importing src/common/Events.ts (#6183)
This file is now deprecated and only used by the coverage tool and
DocLint - these tools will be updated to not rely on it in the future.

We now have events defined per class - e.g. all the events that `Page`
can emit are defined in the `PageEmittedEvents` enum, and similar. We
have to keep `Events.ts` around for the aforementioned tools, but don't
want its usage creeping back into our source code.
2020-07-08 16:03:16 +01:00
Jack Franklin
0e938803ef
chore(docs): migrate Connection + CDP event defs (#6180) 2020-07-08 11:11:01 +01:00
Jack Franklin
74cb2ce7c2
chore: migrate FrameManager events from Events.ts (#6179) 2020-07-08 11:00:11 +01:00
Jack Franklin
6ee7139704
chore(docs): fix incorrect @returns on getter (#6175)
On a getter function you don't use `@returns` (as that's just for
methods). Instead we can just add to the general remarks to explain what
the property is providing.
2020-07-08 10:29:58 +01:00
Jack Franklin
12ee70f2cf
chore: migrate NetworkManager events (#6174)
This is part of the effort to remove `Events.ts` in favour of defining
events next to the class that emits them. In this case these events are
internal, so there's no docs changes, but it's still worth doing such
that we can remove the Events.ts file in the long term once all the
different events are migrated.
2020-07-07 16:43:55 +01:00
kgosselinCoe
022495ba97
chore: fix broken link in docs to DeviceDescriptors (#6170) 2020-07-07 16:39:23 +01:00
Jack Franklin
2256b8d7d7
chore(docs): migrate BrowserContext events (#6168) 2020-07-07 11:21:14 +02:00
Jack Franklin
e2e050259f
chore(docs): fix DOMWorld doc warnings (#6166)
I noticed that DOMWorld was spitting a lot of warnings out when we
generated the docs. It was mostly easy tidy-ups and removing old JSDoc
comments and now the warnings are gone :)
2020-07-06 12:37:16 +01:00
Jack Franklin
782c1d4873
chore(docs): define events enum for Browser (#6165) 2020-07-06 12:23:40 +01:00
Jack Franklin
ba7624a6df
chore(docs): migrate & document all Page events (#6154)
* chore(docs): migrate & document all Page events

Rather than a generic `Events.ts` file we can instead document events as
an enum within each individual class. It's easier to document and work
with, and it's clearer where events originate from.
2020-07-06 11:34:55 +01:00
Christian Bromann
e67a860eb0
feat: add Mouse#wheel (#6141) 2020-07-06 09:27:17 +02:00
Jack Franklin
5049b83186
feat(types): add types for page.$$eval (#6139)
* feat(types): add types for `page.$$eval`

* Add new-docs for $$eval

* fix example

* linting
2020-07-03 15:23:51 +01:00
Jack Franklin
f7857d27c4
chore(docs): document HTTPRequest with TSDoc (#6146)
* chore(docs): document HTTPRequest with TSDoc

* doclint

* example
2020-07-03 14:28:45 +01:00
Changhao Han
4ebf117116
docs: migrating Page.ts to TSDoc (#6152)
* docs: a small batch of page TSdoc migration

Co-authored-by: Changhao Han <changhaohan@chromium.org>
2020-07-03 13:12:59 +01:00
DAOUDI Soufian
d9bb52eab1
docs: fix sandboxing documentation link (#5288) 2020-07-03 14:10:52 +02:00
Wojciech Maj
aee8fda98a
fix: make Node.js environment detection robust w.r.t. JSDOM (#6148)
Previously Node.js was detected by the lack of `global.document` which doesn’t work in case JSDOM is being used in Node.js. Instead, we now detect `process.versions.node`, like here: 426943ae93 (diff-168726dbe96b3ce427e7fedce31bb0bc).

Fixes #6147.
2020-07-03 10:56:28 +02:00
Jack Franklin
054fa2e45d
chore(docs): fix more documentation warnings (#6145) 2020-07-02 16:13:22 +01:00
Jack Franklin
928924ed36
chore: mark v5.0.0-post (#6144) 2020-07-02 16:13:04 +01:00
Jack Franklin
6d06adea10
chore: mark v5.0.0 (#6143) 2020-07-02 14:32:43 +01:00
Jack Franklin
29f7e161b1
chore(docs): reduce warnings when generating docs (#6138)
* chore(docs): reduce warnings when generating docs

This is a bunch of small miscellaneous fixes that reduce the amount of
warnings logged when generating our new docs. The long term goal is to
get this list down to 0 warnings, but I'll do it in multiple PRs.

* satisfy doclint
2020-07-02 12:15:39 +01:00
Jack Franklin
221d172843
chore: add typecheck command (#6140)
If you want to run TypeScript only to verify that it's typechecking correctly, this command is quicker as it doesn't output CJS and ESM to disk. Useful for checking during development.
2020-07-02 13:04:55 +02:00
Jack Franklin
6474edb9ba
feat(types): add types for $eval (#6135)
This pulls in the types (based on the DefinitelyTyped repo) for
`page.$eval` (and the `$eval` method on other classes). The `$eval`
method is quite hard to type due to the way we wrap and unwrap
ElementHandles that are passed to / returned from the `pageFunction`
that users provide.

Longer term we can improve the types by providing type overloads as
DefinitelyTyped does but I've deferred that for now (see the `TODO` in
the code for more details).
2020-07-02 10:09:34 +01:00
Jack Franklin
8370ec88ae
feat(types): add (and fix) evaluateHandle types (#6130)
This change started as a small change to pull types from DefinitelyTyped over to
Puppeteer for the `evaluateHandle` function but instead ended up also fixing
what looks to be a long standing issue with our existing documentation.

`evaluateHandle` can in fact return an `ElementHandle` rather than a `JSHandle`.
Note that `ElementHandle` extends `JSHandle` so whilst the docs are technically
correct (all ElementHandles are JSHandles) it's confusing because JSHandles
don't have methods like `click` on them, but ElementHandles do.

if you return something that is an HTML element:

```
const button = page.evaluateHandle(() => document.querySelector('button'));
// this is an ElementHandle, not a JSHandle
```

Therefore I've updated the original docs and added a large explanation to the
TSDoc for `page.evaluateHandle`.

In TypeScript land we'll assume the function will return a `JSHandle` but you
can tell TS otherwise via the generic argument, which can only be `JSHandle`
(the default) or `ElementHandle`:

```
const button = page.evaluateHandle<ElementHandle>(() => document.querySelector('button'));
```
2020-07-01 12:44:08 +01:00
Jack Franklin
3c0dc45e47
chore: update Windows skipped tests. (#6133)
The headful one I'm permanently skipping as I don't know what the issue is and I can't debug without getting my hands on a Windows machine. If anyone has one or is able to help, that'd be great!

The other I'm deferring another month and will ping the FF folks :)
2020-07-01 11:28:13 +01:00
Jack Franklin
9f198626f8
chore(docs): mark JSHandle properties as internal (#6126) 2020-06-30 15:56:37 +01:00
Mathias Bynens
8026ca9514
docs(api): fix overview diagram for pptr.dev (#6128)
We need to serve the image from user-images.githubusercontent.com for it to work properly on pptr.dev. This broke when merging #5947.

Fixes #6127.
2020-06-30 15:56:26 +01:00
Jack Franklin
9d79cc89cb
chore: fix Firefox install checker (#6129)
I think when the FF version changes this check breaks - let's just make
it check that a version installed rather than the specific version else
this will happen on a continuing basis.
2020-06-30 15:52:53 +01:00
Jack Franklin
1f5e333f00
chore: Don't store revisions in package.json (#6109)
* chore: Don't store revisions in `package.json`

It's quite messy to have to require the `package.json` file in multiple
places purely to find out what revision of a given browser we want to
use. We can also achieve better type safety by placing it in an actual
source file.

This commit makes that change and also tidies up our reliance on
`package.json` within the source code generally; we now only use it to
find the location of the Puppeteer root such that we know where to
install downloaded browsers to.

To avoid using `package.json` to parse the name of the module, we also
now explicitly have an entry point for the Puppeteer module and the
Puppeter Core module. This will make it easier in the future to ship
less code as part of core (e.g. core never needs to download a browser,
so why ship that code?). Core can also then not have any revisions based
info contained in it.

The test install script has also been updated to ensure that
puppeteer-core can be installed correctly too.

Finally, the `install` script has been moved to TypeScript for nicer
typechecking and safety. The functionality of it has not changed.
2020-06-29 16:13:24 +01:00
Yang Guo
123c377512
docs(new): Add TSDoc to Coverage class (#6106) 2020-06-29 09:53:28 +01:00
Toideng
3760302dfe
docs(api): fix broken links in api.md (#6113)
Fix broken cross-links to classes HTTPRequest and HTTPResponse.
2020-06-26 11:51:08 +02:00
Changhao Han
adeffbaac1
docs(new): migrate Page.ts to TSDoc (part 0 / 2) (#6104)
* docs(new): migrate Page.ts to TSDoc (part 0 / 2)

Co-authored-by: Changhao Han <changhaohan@chromium.org>
2020-06-26 09:24:56 +02:00
Mathias Bynens
df96f16921
docs(new): migrate JSHandle docs to TSDoc (#6102) 2020-06-25 15:49:35 +01:00
Jack Franklin
1c0009d2c0
chore(agnostic): ship CJS and ESM builds (#6095)
* chore(agnostic): ship CJS and ESM builds

For our work to enable Puppeteer in other environments (e.g. a browser)
we need to ship an ESM build. This commit changes our config to ship to
`lib/cjs` and `lib/esm` accordingly. The majority of our code stays the
same, with one small fix for the CJS build to ensure that we ship a
version that lets you `require('puppeteer')` rather than have to
`require('puppeteer').default`. We do this with the `cjs-entry.js` which
is what the `main` field in our `package.json` points to.

We also swap to `read-pkg-up` to find the `package.json` file. This is
because the folder structure of `lib/` does not match `src/` now we ship
to `cjs` and `esm`, so you cannot rely on exact paths. This module works
up from the file to find the nearest `package.json` so it will always
find Puppeteer's `package.json`.

Note that we *do not* point any users to the ESM build. We happen to
ship those files so people who know about them can get at them but it's
not expected (nor will we actively support) that people will rely on
them. The CommonJS build is considered our main build.

We may make breaking changes to the structure of the ESM build which we
will do without requiring new major versions. For example the ESM build
currently ships all files that the CJS build does, but given we are
working on the ESM build being able to run in the browser this may
change over time.

Long term once the Node versions catch up we can ditch CJS and ship
exclusively ESM but we are not there yet.
2020-06-25 14:24:46 +01:00
Jack Franklin
46fc6ca41a
feat(types): improve typing of .evaluate() (#6096)
* feat(types): improve typing of `.evaluate()`

This is the start of the work to take the types from the
`@types/puppeteer` repository and port them into our repo so we can ship
our built-in types out the box.

This change types the `evaluate` function properly. It takes a generic
type which is the type of the function you're passing, and the arguments
and the return that you get back from the `evaluate` call are typed
correctly.
2020-06-25 13:38:01 +01:00
Jack Franklin
a4d12a2b21 chore: remove helper.promisify (#6100)
It was just re-exporting the built-in Node module so let's just import
from that directly.
2020-06-25 13:01:46 +02:00
Jack Franklin
5b6d2bfb0e docs(new): add TSDoc comments to Keyboard (#6099)
Co-authored-by: Tim van der Lippe <tvanderlippe@google.com>
2020-06-25 13:01:46 +02:00
Changhao Han
4696f7abda docs(new): migrate HTTPResponse docs to TSDoc (#6085)
Co-authored-by: Changhao Han <changhaohan@chromium.org>
2020-06-25 13:01:46 +02:00
Jack Franklin
b993adb468 chore(agnostic): Migrate DOMWorld (#6054)
DOMWorld only needs to use Node's `fs` module if you're adding a
filepath as a script/style tag. We can detect this case and run the
`require` inline such that in a browser this code won't execute.
2020-06-25 13:01:46 +02:00