Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
Add puppeteer 15.5 and chromium 105
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparticuz committed Jul 27, 2022
2 parents 869a523 + 0da7138 commit aa8410a
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test:
%.zip:
npm install --no-fund --no-package-lock --no-shrinkwrap
mkdir -p nodejs/
npm install --prefix nodejs/ tar-fs@2.1.1 puppeteer-core@14.4.1 --no-bin-links --no-fund --no-optional --no-package-lock --no-save --no-shrinkwrap
npm install --prefix nodejs/ tar-fs@2.1.1 puppeteer-core@15.5.0 --no-bin-links --no-fund --no-optional --no-package-lock --no-save --no-shrinkwrap
npm pack
mkdir -p nodejs/node_modules/@sparticuz/chrome-aws-lambda/
tar --directory nodejs/node_modules/@sparticuz/chrome-aws-lambda/ --extract --file sparticuz-chrome-aws-lambda-*.tgz --strip-components=1
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ This package is versioned based on the underlying `puppeteer` minor version:

| `puppeteer` Version | `chrome-aws-lambda` Version | Chromium Revision |
| ------------------- | --------------------------------------------- | ------------------------------------------------------- |
| `15.4.*` | `npm i @sparticuz/chrome-aws-lambda@~15.5.0` | [`1022525`](https://crrev.com/1011831) (`105.0.5173.0`) |
| `14.4.*` | `npm i @sparticuz/chrome-aws-lambda@~14.4.1` | [`1002410`](https://crrev.com/1002410) (`103.0.5058.0`) |
| `14.3.*` | `npm i @sparticuz/chrome-aws-lambda@~14.3.0` | [`1002410`](https://crrev.com/1002410) (`103.0.5058.0`) |
| `14.2.*` | `npm i @sparticuz/chrome-aws-lambda@~14.2.0` | [`1002410`](https://crrev.com/1002410) (`103.0.5058.0`) |
Expand Down
2 changes: 1 addition & 1 deletion _/ansible/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: ansible chromium

ansible:
sudo pip3 install ansible boto boto3
pip install ansible boto boto3

chromium:
ansible-playbook plays/chromium.yml -i inventory.ini
4 changes: 2 additions & 2 deletions _/ansible/inventory.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[localhost:vars]
ansible_connection=local
ansible_python_interpreter=python
image=ami-03425aeb2f345b9a9
image=ami-0e7375e22561b4d0a
region=us-east-1

[aws]
Expand All @@ -13,4 +13,4 @@ region=us-east-1
ansible_connection=ssh
ansible_python_interpreter=auto_silent
ansible_ssh_private_key_file=ansible.pem
puppeteer_version=v14.4.1
puppeteer_version=v15.5.0
17 changes: 12 additions & 5 deletions _/ansible/plays/chromium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@
PATH: "{{ ansible_env.PATH }}:/srv/source/depot_tools"

tasks:
- name: Update system
become: true
become_user: root
shell: |
dnf update --releasever=2022.0.20220719 -y
- name: Installing Packages
become: true
become_user: root
Expand All @@ -93,7 +99,7 @@
- atk-devel
- bc
- bluez-libs-devel
- brlapi-devel
# - brlapi-devel
- bzip2-devel
- cairo-devel
- cmake
Expand All @@ -102,16 +108,16 @@
- dbus-glib-devel
- dbus-x11
- expat-devel
- glibc.i686
- glibc
- glibc-langpack-en
- gperf
- gtk3-devel
- httpd
- java-11-openjdk-devel
- java-latest-openjdk-devel
- libatomic
- libcap-devel
- libjpeg-devel
- libstdc++.i686
- libstdc++
- libXScrnSaver-devel
- libxkbcommon-x11-devel
- mod_ssl
Expand All @@ -129,7 +135,7 @@
- python-setuptools
- ruby
- xorg-x11-server-Xvfb
- zlib.i686
- zlib
state: latest
update_cache: true

Expand Down Expand Up @@ -300,6 +306,7 @@
symbol_level = 0
target_cpu = "x64"
target_os = "linux"
use_brlapi = 0
use_sysroot = true
v8_symbol_level = 0
v8_target_cpu = "x64"
Expand Down
Binary file modified bin/chromium.br
Binary file not shown.
Binary file modified bin/swiftshader.tar.br
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
"preversion": "npm run build"
},
"devDependencies": {
"@types/node": "^16.11.40",
"@types/node": "^16.11.45",
"@types/tar-fs": "^2.0.1",
"puppeteer-core": "14.4.1",
"puppeteer-core": "15.5.0",
"typescript": "^4.6.4"
},
"peerDependencies": {
"puppeteer-core": "14.4.1"
"puppeteer-core": "15.5.0"
},
"bugs": {
"url": "https://github.com/Sparticuz/chrome-aws-lambda/issues"
Expand Down
30 changes: 15 additions & 15 deletions source/puppeteer/lib/ElementHandle.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ElementHandle, EvaluateFn, HTTPRequest, HTTPResponse, Page, WaitForOptions, WaitTimeoutOptions } from 'puppeteer-core';
import { KeysOfType, Prototype } from '../../../typings/chrome-aws-lambda';
import { ElementHandle, EvaluateFunc, HTTPRequest, HTTPResponse, Page, WaitForOptions, WaitTimeoutOptions } from 'puppeteer-core';
import { Prototype } from '../../../typings/chrome-aws-lambda';

let Super: Prototype<ElementHandle> = null;

try {
Super = require('puppeteer/lib/cjs/puppeteer/common/JSHandle.js').ElementHandle;
Super = require('puppeteer/lib/cjs/puppeteer/common/ElementHandle.js').ElementHandle;
} catch (error) {
Super = require('puppeteer-core/lib/cjs/puppeteer/common/JSHandle.js').ElementHandle;
Super = require('puppeteer-core/lib/cjs/puppeteer/common/ElementHandle.js').ElementHandle;
}

Super.prototype.clear = function () {
Expand Down Expand Up @@ -171,7 +171,7 @@ Super.prototype.fillFormByLabel = function <T extends Record<string, boolean | s
return result;
};

return this.evaluate(callback as unknown as EvaluateFn<Element>, data) as any;
return this.evaluate(callback as unknown as EvaluateFunc<[ElementHandle<Element>, T]>, data) as any;
};

Super.prototype.fillFormByName = function <T extends Record<string, boolean | string | string[]>>(data: T) {
Expand Down Expand Up @@ -262,7 +262,7 @@ Super.prototype.fillFormByName = function <T extends Record<string, boolean | st
return result;
};

return this.evaluate(callback as unknown as EvaluateFn<Element>, data) as any;
return this.evaluate(callback as unknown as EvaluateFunc<[ElementHandle<Element>, T]>, data) as any;
};

Super.prototype.fillFormBySelector = function <T extends Record<string, boolean | string | string[]>>(data: T) {
Expand Down Expand Up @@ -353,7 +353,7 @@ Super.prototype.fillFormBySelector = function <T extends Record<string, boolean
return result;
};

return this.evaluate(callback as unknown as EvaluateFn<Element>, data) as any;
return this.evaluate(callback as unknown as EvaluateFunc<[ElementHandle<Element>, T]>, data) as any;
};

Super.prototype.fillFormByXPath = function <T extends Record<string, boolean | string | string[]>>(data: T) {
Expand Down Expand Up @@ -450,7 +450,7 @@ Super.prototype.fillFormByXPath = function <T extends Record<string, boolean | s
return result;
};

return this.evaluate(callback as unknown as EvaluateFn<Element>, data) as any;
return this.evaluate(callback as unknown as EvaluateFunc<[ElementHandle<Element>, T]>, data) as any;
};

Super.prototype.getInnerHTML = function () {
Expand All @@ -465,8 +465,8 @@ Super.prototype.getInnerText = function () {
});
};

Super.prototype.number = function <T = HTMLElement>(decimal: string = '.', property: KeysOfType<T, string> = 'textContent' as any) {
let callback = (node: T, decimal: string, property: KeysOfType<T, string>) => {
Super.prototype.number = function (decimal: string = '.', property: any) {
let callback = (node: any, decimal: string, property: any) => {
let data = (node[property] as unknown) as string;

if (typeof data === 'string') {
Expand All @@ -486,7 +486,7 @@ Super.prototype.number = function <T = HTMLElement>(decimal: string = '.', prope
return null;
};

return this.evaluate(callback as unknown as EvaluateFn<Element>, decimal, property as any);
return this.evaluate(callback, decimal, property as any);
};

Super.prototype.selectByLabel = function (...values: string[]) {
Expand Down Expand Up @@ -523,11 +523,11 @@ Super.prototype.selectByLabel = function (...values: string[]) {
return result;
};

return this.evaluate(callback as unknown as EvaluateFn<Element>, values);
return this.evaluate(callback as any, values);
};

Super.prototype.string = function <T = HTMLElement>(property: KeysOfType<T, string> = 'textContent' as any) {
let callback = (node: T, property: KeysOfType<T, string>) => {
Super.prototype.string = function (property: any) {
let callback = (node: any, property: any) => {
let data = (node[property] as unknown) as string;

if (typeof data === 'string') {
Expand All @@ -553,5 +553,5 @@ Super.prototype.string = function <T = HTMLElement>(property: KeysOfType<T, stri
return null;
};

return this.evaluate(callback as unknown as EvaluateFn<Element>, property as any);
return this.evaluate(callback, property as any);
};
6 changes: 3 additions & 3 deletions source/puppeteer/lib/FrameManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Frame, HTTPRequest, HTTPResponse, Page, WaitForOptions, WaitTimeoutOptions } from 'puppeteer-core';
import { Frame, HTTPRequest, HTTPResponse, WaitForOptions, WaitTimeoutOptions } from 'puppeteer-core';
import { KeysOfType, Prototype } from '../../../typings/chrome-aws-lambda';

let Super: Prototype<Frame> = null;
Expand Down Expand Up @@ -44,7 +44,7 @@ Super.prototype.clickAndWaitForRequest = function (selector: string, predicate:
};

let promises: [Promise<HTTPRequest>, Promise<void>] = [
((this._frameManager as any)._page as Page).waitForRequest((typeof predicate === 'function') ? predicate : callback, options),
this.page().waitForRequest((typeof predicate === 'function') ? predicate : callback, options),
this.click(selector),
];

Expand All @@ -67,7 +67,7 @@ Super.prototype.clickAndWaitForResponse = function (selector: string, predicate:
};

let promises: [Promise<HTTPResponse>, Promise<void>] = [
((this._frameManager as any)._page as Page).waitForResponse((typeof predicate === 'function') ? predicate : callback, options),
this.page().waitForResponse((typeof predicate === 'function') ? predicate : callback, options),
this.click(selector),
];

Expand Down
16 changes: 8 additions & 8 deletions typings/chrome-aws-lambda.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ declare module 'puppeteer-core' {
* @param decimal - Decimal separator to use, defaults to `.`.
* @param property - Element property to extract content from, defaults to `textContent`.
*/
number<T = HTMLElement>(decimal?: string, property?: KeysOfType<T, string>): Promise<number[]>;
number(decimal?: string, property?: any): Promise<number[]>;

/**
* Selects multiple `select` options by label and returns the values of the actual selection.
Expand All @@ -141,7 +141,7 @@ declare module 'puppeteer-core' {
*
* @param property - Element property to extract content from, defaults to `textContent`.
*/
string<T = HTMLElement>(property?: KeysOfType<T, string>): Promise<string>;
string(property?: any): Promise<string>;
}

interface Frame {
Expand Down Expand Up @@ -273,23 +273,23 @@ declare module 'puppeteer-core' {
* @param predicate - String to wait for.
* @param options - Optional waiting parameters.
*/
waitForText(predicate: string, options?: WaitTimeoutOptions): Promise<ElementHandle>;
waitForText(predicate: string, options?: WaitTimeoutOptions): Promise<ElementHandle<Node>>;

/**
* Waits for element to be present in DOM and to be visible.
*
* @param selector - Selector to query for.
* @param options - Optional waiting parameters.
*/
waitUntilVisible(selector: string, options?: WaitTimeoutOptions): Promise<ElementHandle>;
waitUntilVisible(selector: string, options?: WaitTimeoutOptions): Promise<ElementHandle<Node>>;

/**
* Waits for element to not be found in the DOM or to be hidden.
*
* @param selector - Selector to query for.
* @param options - Optional waiting parameters.
*/
waitWhileVisible(selector: string, options?: WaitTimeoutOptions): Promise<ElementHandle>;
waitWhileVisible(selector: string, options?: WaitTimeoutOptions): Promise<ElementHandle<Node>>;
}

interface Page {
Expand Down Expand Up @@ -442,23 +442,23 @@ declare module 'puppeteer-core' {
* @param predicate - String to wait for.
* @param options - Optional waiting parameters.
*/
waitForText(predicate: string, options?: WaitTimeoutOptions): Promise<ElementHandle>;
waitForText(predicate: string, options?: WaitTimeoutOptions): Promise<ElementHandle<Node>>;

/**
* Waits for element to be present in DOM and to be visible.
*
* @param selector - Selector to query for.
* @param options - Optional waiting parameters.
*/
waitUntilVisible(selector: string, options?: WaitTimeoutOptions): Promise<ElementHandle>;
waitUntilVisible(selector: string, options?: WaitTimeoutOptions): Promise<ElementHandle<Node>>;

/**
* Waits for element to not be found in the DOM or to be hidden.
*
* @param selector - Selector to query for.
* @param options - Optional waiting parameters.
*/
waitWhileVisible(selector: string, options?: WaitTimeoutOptions): Promise<ElementHandle>;
waitWhileVisible(selector: string, options?: WaitTimeoutOptions): Promise<ElementHandle<Node>>;

/**
* Encapsulates the callback execution in a tracing session.
Expand Down

0 comments on commit aa8410a

Please sign in to comment.