-
-
Notifications
You must be signed in to change notification settings - Fork 737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite in Typescript #21
Comments
@outlabeau I'm gonna create a |
@berstend that's great! Can't wait for the d.ts. |
What is the status for this intend? |
Apologies, got swamped with $work related things. Given that I love TS and my documentation system seems to be supporting TS now (this was the main blocker) I'll be rewriting the puppeteer-extra core in TS now after some hygiene tasks (updating deps, etc) :) |
Current workarounds are mentioned here: I'm currently checking that documentation.js will work with TypeScript as advertised (auto-generated docs are super important 😄). In case that doesn't work I'll whip up a custom |
The heavy lifting is done and the TypeScript version makes all tests go green. The auto-completion support in JS is a game changer, even for non-TS users. I ended up finding a way to stay backwards compatible with the current default export/behaviour: // existing simple case: defaults to require "puppeteer" or "puppeteer-core"
const puppeteer = require('puppeteer-extra')
puppeteer.use(...)
// new: optionally provide a puppeteer instance to patch
const { addExtra } = require('puppeteer-extra')
const puppeteer = addExtra(require('puppeteer-firefox'))
puppeteer.use(...) Using this opportunity to cleanup and overhaul some other things as well before pushing this release. |
First class TypeScript support has just landed! import puppeteer from 'puppeteer-extra'
import RecaptchaPlugin from 'puppeteer-extra-plugin-recaptcha'
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
puppeteer.use(RecaptchaPlugin()).use(StealthPlugin())
puppeteer.launch({ headless: false }).then(async browser => {
const page = await browser.newPage()
await page.setViewport({ width: 800, height: 600 })
await page.goto('https://bot.sannysoft.com')
await page.waitFor(5000)
await page.screenshot({ path: 'stealth.png', fullPage: true })
await browser.close()
}) cc @outlabeau @NikoMontana They only thing I haven't figured out yet is how plugins could automatically extend built-in Puppeteer types (e.g. Not sure if that's even possible. But that's not too critical and can be overridden by the user easily ( |
Found a way to have plugins extend Puppeteer types (e.g. page.solveCaptchas()) fully type safe for consumers by shipping an ambient d.ts file. :) Closing this for now. |
Current progress (28 Nov - not pushed yet!) 📚
puppeteer-extra
in TypeScript 🎉addExtra
export to support non-standard or multiple puppeteer instancespage.solveCaptchas()
)(initial comment)
I started this repo before noticing how awesome typescript is. 😄
Whenever I find the time I shall refactor this project into typescript.
Potential issues:
Update
Parts have been rewritten in TypeScript 🎉
Before I can rewrite the rest I need to improve the generated typedoc output.
We're using
typedoc-plugin-markdown
(the current best thing) and the output looks like this, compared to the previous documentation.js based docs. 😢I'm really close to start developing my own minimal
typedoc-plugin-readme
plugin. 😅The text was updated successfully, but these errors were encountered: