Compare commits
No commits in common. "master" and "v122.0.0" have entirely different histories.
|
|
@ -12,4 +12,3 @@ _/amazon/.aws-sam
|
||||||
*.tgz
|
*.tgz
|
||||||
examples/**/package-lock.json
|
examples/**/package-lock.json
|
||||||
examples/**/.serverless
|
examples/**/.serverless
|
||||||
docker
|
|
||||||
|
|
|
||||||
8
Makefile
8
Makefile
|
|
@ -10,17 +10,11 @@ pretest:
|
||||||
test:
|
test:
|
||||||
sam local invoke --template _/amazon/template.yml --event _/amazon/events/example.com.json node20
|
sam local invoke --template _/amazon/template.yml --event _/amazon/events/example.com.json node20
|
||||||
|
|
||||||
test16:
|
|
||||||
sam local invoke --template _/amazon/template.yml --event _/amazon/events/example.com.json node16
|
|
||||||
|
|
||||||
test18:
|
|
||||||
sam local invoke --template _/amazon/template.yml --event _/amazon/events/example.com.json node18
|
|
||||||
|
|
||||||
%.zip:
|
%.zip:
|
||||||
npm install --fund=false --package-lock=false
|
npm install --fund=false --package-lock=false
|
||||||
npm run build
|
npm run build
|
||||||
mkdir -p nodejs
|
mkdir -p nodejs
|
||||||
npm install --prefix nodejs/ tar-fs@3.0.6 follow-redirects@1.15.9 --bin-links=false --fund=false --omit=optional --omit=dev --package-lock=false --save=false
|
npm install --prefix nodejs/ tar-fs@3.0.5 follow-redirects@1.15.5 --bin-links=false --fund=false --omit=optional --omit=dev --package-lock=false --save=false
|
||||||
npm pack
|
npm pack
|
||||||
mkdir -p nodejs/node_modules/@sparticuz/chromium/
|
mkdir -p nodejs/node_modules/@sparticuz/chromium/
|
||||||
tar --directory nodejs/node_modules/@sparticuz/chromium/ --extract --file sparticuz-chromium-*.tgz --strip-components=1
|
tar --directory nodejs/node_modules/@sparticuz/chromium/ --extract --file sparticuz-chromium-*.tgz --strip-components=1
|
||||||
|
|
|
||||||
52
README.md
52
README.md
|
|
@ -50,8 +50,8 @@ const test = require("node:test");
|
||||||
const puppeteer = require("puppeteer-core");
|
const puppeteer = require("puppeteer-core");
|
||||||
const chromium = require("@sparticuz/chromium");
|
const chromium = require("@sparticuz/chromium");
|
||||||
|
|
||||||
// Optional: If you'd like to use the new headless mode. "shell" is the default.
|
// Optional: If you'd like to use the new headless mode. "chrome-headless-shell" is the default.
|
||||||
// NOTE: Because we build the shell binary, this option does not work.
|
// NOTE: Because we build the chrome-headless-shell binary, this option does not work.
|
||||||
// However, this option will stay so when we migrate to full chromium it will work.
|
// However, this option will stay so when we migrate to full chromium it will work.
|
||||||
chromium.setHeadlessMode = true;
|
chromium.setHeadlessMode = true;
|
||||||
|
|
||||||
|
|
@ -204,50 +204,6 @@ From what I can tell, `headless_shell` does not seem to include support for the
|
||||||
|
|
||||||
Try marking this package as an external. Ref: https://webpack.js.org/configuration/externals/
|
Try marking this package as an external. Ref: https://webpack.js.org/configuration/externals/
|
||||||
|
|
||||||
### I'm experiencing timeouts or failures closing Chromium
|
|
||||||
|
|
||||||
This is a common issue. Chromium sometimes opens up more pages than you ask for. You can try the following
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
for (const page of await browser.pages()) {
|
|
||||||
await page.close();
|
|
||||||
}
|
|
||||||
await browser.close();
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also try the following if one of the calls is hanging for some reason.
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
await Promise.race([browser.close(), browser.close(), browser.close()]);
|
|
||||||
```
|
|
||||||
|
|
||||||
Always `await browser.close()`, even if your script is returning an error.
|
|
||||||
|
|
||||||
### I need Accessible pdf files
|
|
||||||
|
|
||||||
This is due to the way @sparticuz/chromium is built. If you require accessible pdf's, you'll need to
|
|
||||||
recompile chromium yourself with the following patch. You can then use that binary with @sparticuz/chromium-min.
|
|
||||||
|
|
||||||
_Note_: This will increase the time required to generate a PDF.
|
|
||||||
|
|
||||||
```patch
|
|
||||||
diff --git a/_/ansible/plays/chromium.yml b/_/ansible/plays/chromium.yml
|
|
||||||
index b42c740..49111d7 100644
|
|
||||||
--- a/_/ansible/plays/chromium.yml
|
|
||||||
+++ b/_/ansible/plays/chromium.yml
|
|
||||||
@@ -249,8 +249,9 @@
|
|
||||||
blink_symbol_level = 0
|
|
||||||
dcheck_always_on = false
|
|
||||||
disable_histogram_support = false
|
|
||||||
- enable_basic_print_dialog = false
|
|
||||||
enable_basic_printing = true
|
|
||||||
+ enable_pdf = true
|
|
||||||
+ enable_tagged_pdf = true
|
|
||||||
enable_keystone_registration_framework = false
|
|
||||||
enable_linux_installer = false
|
|
||||||
enable_media_remoting = false
|
|
||||||
```
|
|
||||||
|
|
||||||
## Fonts
|
## Fonts
|
||||||
|
|
||||||
The Amazon Linux 2 AWS Lambda runtime is not provisioned with any font faces.
|
The Amazon Linux 2 AWS Lambda runtime is not provisioned with any font faces.
|
||||||
|
|
@ -304,8 +260,8 @@ By default, this package uses `swiftshader`/`angle` to do CPU acceleration for W
|
||||||
| `args` | `Array<string>` | Provides a list of recommended additional [Chromium flags](https://github.com/GoogleChrome/chrome-launcher/blob/master/docs/chrome-flags-for-tools.md). |
|
| `args` | `Array<string>` | Provides a list of recommended additional [Chromium flags](https://github.com/GoogleChrome/chrome-launcher/blob/master/docs/chrome-flags-for-tools.md). |
|
||||||
| `defaultViewport` | `Object` | Returns a sensible default viewport for serverless. |
|
| `defaultViewport` | `Object` | Returns a sensible default viewport for serverless. |
|
||||||
| `executablePath(location?: string)` | `Promise<string>` | Returns the path the Chromium binary was extracted to. |
|
| `executablePath(location?: string)` | `Promise<string>` | Returns the path the Chromium binary was extracted to. |
|
||||||
| `setHeadlessMode` | `void` | Sets the headless mode to either `true` or `"shell"` |
|
| `setHeadlessMode` | `void` | Sets the headless mode to either `true` or `"chrome-headless-shell"` |
|
||||||
| `headless` | `true \| "shell"` | Returns `true` or `"shell"` depending on what version of chrome's headless you are running |
|
| `headless` | `true \| "chrome-headless-shell"` | Returns `true` or `"chrome-headless-shell"` depending on what version of chrome's headless you are running |
|
||||||
| `setGraphicsMode` | `void` | Sets the graphics mode to either `true` or `false` |
|
| `setGraphicsMode` | `void` | Sets the graphics mode to either `true` or `false` |
|
||||||
| `graphics` | `boolean` | Returns a boolean depending on whether webgl is enabled or disabled |
|
| `graphics` | `boolean` | Returns a boolean depending on whether webgl is enabled or disabled |
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@
|
||||||
"url": "https://example.com",
|
"url": "https://example.com",
|
||||||
"expected": {
|
"expected": {
|
||||||
"title": "Example Domain",
|
"title": "Example Domain",
|
||||||
"screenshot": "e610a8be5568f23c453b08928460aae3ae0b4b0a"
|
"screenshot": "835f3ccc8fdbcb3a4a067666f1e9648e9e513570"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "https://get.webgl.org",
|
"url": "https://get.webgl.org",
|
||||||
"expected": {
|
"expected": {
|
||||||
"remove": "logo-container",
|
"remove": "logo-container",
|
||||||
"screenshot": "ec6c79a571b4cb5727c6fc23f9da30de3868138c"
|
"screenshot": "7b4110af7294ae55452d636dd8e900574b21ea2d"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const { ok } = require("node:assert");
|
const { ok } = require("assert");
|
||||||
const { createHash } = require("node:crypto");
|
const { createHash } = require("crypto");
|
||||||
const puppeteer = require("puppeteer-core");
|
const puppeteer = require("puppeteer-core");
|
||||||
const chromium = require("@sparticuz/chromium");
|
const chromium = require("@sparticuz/chromium");
|
||||||
|
|
||||||
|
|
@ -13,13 +13,20 @@ exports.handler = async (event, context) => {
|
||||||
dumpio: true,
|
dumpio: true,
|
||||||
executablePath: await chromium.executablePath(),
|
executablePath: await chromium.executablePath(),
|
||||||
headless: chromium.headless,
|
headless: chromium.headless,
|
||||||
acceptInsecureCerts: true,
|
ignoreHTTPSErrors: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("Chromium version", await browser.version());
|
console.log("Chromium version", await browser.version());
|
||||||
|
|
||||||
for (let job of event) {
|
const contexts = [browser.defaultBrowserContext()];
|
||||||
const page = await browser.newPage();
|
|
||||||
|
while (contexts.length < event.length) {
|
||||||
|
contexts.push(await browser.createBrowserContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let context of contexts) {
|
||||||
|
const job = event.shift();
|
||||||
|
const page = await context.newPage();
|
||||||
|
|
||||||
if (job.hasOwnProperty("url") === true) {
|
if (job.hasOwnProperty("url") === true) {
|
||||||
await page.goto(job.url, { waitUntil: ["domcontentloaded", "load"] });
|
await page.goto(job.url, { waitUntil: ["domcontentloaded", "load"] });
|
||||||
|
|
@ -38,7 +45,7 @@ exports.handler = async (event, context) => {
|
||||||
document.getElementById(selector).remove();
|
document.getElementById(selector).remove();
|
||||||
}, job.expected.remove);
|
}, job.expected.remove);
|
||||||
}
|
}
|
||||||
const screenshot = Buffer.from(await page.screenshot());
|
const screenshot = await page.screenshot();
|
||||||
/*
|
/*
|
||||||
console.log(
|
console.log(
|
||||||
`data:image/png;base64,${screenshot.toString("base64")}`,
|
`data:image/png;base64,${screenshot.toString("base64")}`,
|
||||||
|
|
@ -61,9 +68,6 @@ exports.handler = async (event, context) => {
|
||||||
throw error.message;
|
throw error.message;
|
||||||
} finally {
|
} finally {
|
||||||
if (browser !== null) {
|
if (browser !== null) {
|
||||||
for (const page of await browser.pages()) {
|
|
||||||
await page.close();
|
|
||||||
}
|
|
||||||
await browser.close();
|
await browser.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
[localhost:vars]
|
[localhost:vars]
|
||||||
ansible_connection=local
|
ansible_connection=local
|
||||||
ansible_python_interpreter=python
|
ansible_python_interpreter=python
|
||||||
image=ami-06c68f701d8090592
|
image=ami-08d090f841c8435e9
|
||||||
region=us-east-1
|
region=us-east-1
|
||||||
instance_size=c7i.12xlarge
|
instance_size=c6i.12xlarge
|
||||||
|
|
||||||
[aws]
|
[aws]
|
||||||
|
|
||||||
|
|
@ -14,4 +14,4 @@ instance_size=c7i.12xlarge
|
||||||
ansible_connection=ssh
|
ansible_connection=ssh
|
||||||
ansible_python_interpreter=auto_silent
|
ansible_python_interpreter=auto_silent
|
||||||
ansible_ssh_private_key_file=ansible.pem
|
ansible_ssh_private_key_file=ansible.pem
|
||||||
chromium_revision=1343869
|
chromium_revision=1250580
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,12 @@
|
||||||
path: /srv/source/chromium/src/out/Headless
|
path: /srv/source/chromium/src/out/Headless
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
|
- name: Mounting Build Directory in Memory
|
||||||
|
become: true
|
||||||
|
become_user: root
|
||||||
|
shell: |
|
||||||
|
mount --types tmpfs --options size=24G,nr_inodes=128k,mode=1777 tmpfs /srv/source/chromium/src/out/Headless
|
||||||
|
|
||||||
- name: Creating Headless Chromium Configuration
|
- name: Creating Headless Chromium Configuration
|
||||||
copy:
|
copy:
|
||||||
content: |
|
content: |
|
||||||
|
|
|
||||||
BIN
bin/chromium.br
BIN
bin/chromium.br
Binary file not shown.
Binary file not shown.
|
|
@ -1,40 +1,40 @@
|
||||||
{
|
{
|
||||||
"name": "@sparticuz/chromium",
|
"name": "@sparticuz/chromium",
|
||||||
"version": "130.0.0",
|
"version": "122.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@sparticuz/chromium",
|
"name": "@sparticuz/chromium",
|
||||||
"version": "130.0.0",
|
"version": "122.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.15.9",
|
"follow-redirects": "^1.15.5",
|
||||||
"tar-fs": "^3.0.6"
|
"tar-fs": "^3.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tsconfig/node20": "^20.1.4",
|
"@tsconfig/node16": "^16.1.1",
|
||||||
"@tsconfig/strictest": "^2.0.5",
|
"@tsconfig/strictest": "^2.0.3",
|
||||||
"@types/follow-redirects": "^1.14.4",
|
"@types/follow-redirects": "^1.14.4",
|
||||||
"@types/node": "^20.16.10",
|
"@types/node": "^20.11.19",
|
||||||
"@types/tar-fs": "^2.0.4",
|
"@types/tar-fs": "^2.0.4",
|
||||||
"clean-modules": "^3.1.1",
|
"clean-modules": "^3.0.4",
|
||||||
"typescript": "^5.6.2"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 16"
|
"node": ">= 16"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@tsconfig/node20": {
|
"node_modules/@tsconfig/node16": {
|
||||||
"version": "20.1.4",
|
"version": "16.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@tsconfig/node20/-/node20-20.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-16.1.1.tgz",
|
||||||
"integrity": "sha512-sqgsT69YFeLWf5NtJ4Xq/xAF8p4ZQHlmGW74Nu2tD4+g5fAsposc4ZfaaPixVu4y01BEiDCWLRDCvDM5JOsRxg==",
|
"integrity": "sha512-+pio93ejHN4nINX4pXqfnR/fPLRtJBaT4ORaa5RH0Oc1zoYmo2B2koG+M328CQhHKn1Wj6FcOxCDFXAot9NhvA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@tsconfig/strictest": {
|
"node_modules/@tsconfig/strictest": {
|
||||||
"version": "2.0.5",
|
"version": "2.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@tsconfig/strictest/-/strictest-2.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/@tsconfig/strictest/-/strictest-2.0.3.tgz",
|
||||||
"integrity": "sha512-ec4tjL2Rr0pkZ5hww65c+EEPYwxOi4Ryv+0MtjeaSQRJyq322Q27eOQiFbuNgw2hpL4hB1/W/HBGk3VKS43osg==",
|
"integrity": "sha512-MroLvRhMbqtXI5WBSwoomro6OQS4xnCoudUrMb20JO0vLKUs0bAaCEcvM/immEBSJjFAK1l6jW1oAO8q3Ancrg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/follow-redirects": {
|
"node_modules/@types/follow-redirects": {
|
||||||
|
|
@ -47,13 +47,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "20.16.10",
|
"version": "20.11.19",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.10.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.19.tgz",
|
||||||
"integrity": "sha512-vQUKgWTjEIRFCvK6CyriPH3MZYiYlNy0fKiEYHWbcoWLEgs4opurGGKlebrTLqdSMIbXImH6XExNiIyNUv3WpA==",
|
"integrity": "sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~6.19.2"
|
"undici-types": "~5.26.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/tar-fs": {
|
"node_modules/@types/tar-fs": {
|
||||||
|
|
@ -114,11 +113,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/clean-modules": {
|
"node_modules/clean-modules": {
|
||||||
"version": "3.1.1",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/clean-modules/-/clean-modules-3.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/clean-modules/-/clean-modules-3.0.4.tgz",
|
||||||
"integrity": "sha512-t/7dNtn6vQYxujYxdwZeLa0NsLE92KQ0XeV3CDJ2TXgLTvn3ijmjlQN0Dm9wjYQgC0miZiF66ClTQzgIeYw96A==",
|
"integrity": "sha512-UtidYdwZScv7TEmPuNBU1IDh2UrLH9FNYnhKYterm3jTtOGtSOa02J5aKHvnauqS/TKqJGPpC4bmuRDAXk61EQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"clipanion": "^3.2.1",
|
"clipanion": "^3.2.1",
|
||||||
"picomatch": "^2.3.0",
|
"picomatch": "^2.3.0",
|
||||||
|
|
@ -159,16 +157,15 @@
|
||||||
"integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw=="
|
"integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw=="
|
||||||
},
|
},
|
||||||
"node_modules/follow-redirects": {
|
"node_modules/follow-redirects": {
|
||||||
"version": "1.15.9",
|
"version": "1.15.5",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz",
|
||||||
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
|
"integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4.0"
|
"node": ">=4.0"
|
||||||
},
|
},
|
||||||
|
|
@ -273,9 +270,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tar-fs": {
|
"node_modules/tar-fs": {
|
||||||
"version": "3.0.6",
|
"version": "3.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.5.tgz",
|
||||||
"integrity": "sha512-iokBDQQkUyeXhgPYaZxmczGPhnhXZ0CmrqI+MOb/WFGS9DW5wnfrLgtjUJBvz50vQ3qfRwJ62QVoCFu8mPVu5w==",
|
"integrity": "sha512-JOgGAmZyMgbqpLwct7ZV8VzkEB6pxXFBVErLtb+XCOqzc6w1xiWKI9GVd6bwk68EX7eJ4DWmfXVmq8K2ziZTGg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pump": "^3.0.0",
|
"pump": "^3.0.0",
|
||||||
"tar-stream": "^3.1.5"
|
"tar-stream": "^3.1.5"
|
||||||
|
|
@ -302,11 +299,10 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "5.6.2",
|
"version": "5.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
|
||||||
"integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==",
|
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
"tsserver": "bin/tsserver"
|
"tsserver": "bin/tsserver"
|
||||||
|
|
@ -316,11 +312,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici-types": {
|
"node_modules/undici-types": {
|
||||||
"version": "6.19.6",
|
"version": "5.26.5",
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.6.tgz",
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
||||||
"integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==",
|
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"license": "MIT"
|
|
||||||
},
|
},
|
||||||
"node_modules/wrappy": {
|
"node_modules/wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
|
|
|
||||||
16
package.json
16
package.json
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sparticuz/chromium",
|
"name": "@sparticuz/chromium",
|
||||||
"version": "130.0.0",
|
"version": "122.0.0",
|
||||||
"description": "Chromium Binary for Serverless Platforms",
|
"description": "Chromium Binary for Serverless Platforms",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"aws",
|
"aws",
|
||||||
|
|
@ -36,17 +36,17 @@
|
||||||
"test": "make clean && make && make pretest && make test"
|
"test": "make clean && make && make pretest && make test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.15.9",
|
"follow-redirects": "^1.15.5",
|
||||||
"tar-fs": "^3.0.6"
|
"tar-fs": "^3.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tsconfig/node20": "^20.1.4",
|
"@tsconfig/node16": "^16.1.1",
|
||||||
"@tsconfig/strictest": "^2.0.5",
|
"@tsconfig/strictest": "^2.0.3",
|
||||||
"@types/follow-redirects": "^1.14.4",
|
"@types/follow-redirects": "^1.14.4",
|
||||||
"@types/node": "^20.16.10",
|
"@types/node": "^20.11.19",
|
||||||
"@types/tar-fs": "^2.0.4",
|
"@types/tar-fs": "^2.0.4",
|
||||||
"clean-modules": "^3.1.1",
|
"clean-modules": "^3.0.4",
|
||||||
"typescript": "^5.6.2"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 16"
|
"node": ">= 16"
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ class Chromium {
|
||||||
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
|
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
|
||||||
* @values true or "new"
|
* @values true or "new"
|
||||||
*/
|
*/
|
||||||
private static headlessMode: true | "shell" = "shell";
|
private static headlessMode: true | "chrome-headless-shell" = "chrome-headless-shell";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true, the graphics stack and webgl is enabled,
|
* If true, the graphics stack and webgl is enabled,
|
||||||
|
|
@ -240,11 +240,9 @@ class Chromium {
|
||||||
];
|
];
|
||||||
|
|
||||||
// https://chromium.googlesource.com/chromium/src/+/main/docs/gpu/swiftshader.md
|
// https://chromium.googlesource.com/chromium/src/+/main/docs/gpu/swiftshader.md
|
||||||
// Blocked by https://github.com/Sparticuz/chromium/issues/247
|
this.graphics
|
||||||
//this.graphics
|
? graphicsFlags.push("--use-gl=angle", "--use-angle=swiftshader")
|
||||||
// ? graphicsFlags.push("--use-gl=angle", "--use-angle=swiftshader")
|
: graphicsFlags.push("--disable-webgl");
|
||||||
// : graphicsFlags.push("--disable-webgl");
|
|
||||||
graphicsFlags.push("--use-gl=angle", "--use-angle=swiftshader");
|
|
||||||
|
|
||||||
const insecureFlags = [
|
const insecureFlags = [
|
||||||
"--allow-running-insecure-content", // https://source.chromium.org/search?q=lang:cpp+symbol:kAllowRunningInsecureContent&ss=chromium
|
"--allow-running-insecure-content", // https://source.chromium.org/search?q=lang:cpp+symbol:kAllowRunningInsecureContent&ss=chromium
|
||||||
|
|
@ -256,7 +254,7 @@ class Chromium {
|
||||||
];
|
];
|
||||||
|
|
||||||
const headlessFlags = [
|
const headlessFlags = [
|
||||||
this.headless === "shell" ? "--headless='shell'" : "--headless",
|
this.headless === "chrome-headless-shell" ? "--headless='chrome-headless-shell'" : "--headless",
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
@ -351,10 +349,10 @@ class Chromium {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the headless mode.
|
* Returns the headless mode.
|
||||||
* "shell" means the 'old' (legacy, chromium < 112) headless mode.
|
* "chrome-headless-shell" means the 'old' (legacy, chromium < 112) headless mode.
|
||||||
* `true` means the 'new' headless mode.
|
* `true` means the 'new' headless mode.
|
||||||
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
|
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
|
||||||
* @returns true | "shell"
|
* @returns true | "chrome-headless-shell"
|
||||||
*/
|
*/
|
||||||
public static get headless() {
|
public static get headless() {
|
||||||
return this.headlessMode;
|
return this.headlessMode;
|
||||||
|
|
@ -362,18 +360,18 @@ class Chromium {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the headless mode.
|
* Sets the headless mode.
|
||||||
* "shell" means the 'old' (legacy, chromium < 112) headless mode.
|
* "chrome-headless-shell" means the 'old' (legacy, chromium < 112) headless mode.
|
||||||
* `true` means the 'new' headless mode.
|
* `true` means the 'new' headless mode.
|
||||||
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
|
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
|
||||||
* @default "shell"
|
* @default "chrome-headless-shell"
|
||||||
*/
|
*/
|
||||||
public static set setHeadlessMode(value: true | "shell") {
|
public static set setHeadlessMode(value: true | "chrome-headless-shell") {
|
||||||
if (
|
if (
|
||||||
(typeof value === "string" && value !== "shell") ||
|
(typeof value === "string" && value !== "chrome-headless-shell") ||
|
||||||
(typeof value === "boolean" && value !== true)
|
(typeof value === "boolean" && value !== true)
|
||||||
) {
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Headless mode must be either \`true\` or 'shell', you entered '${value}'`
|
`Headless mode must be either \`true\` or 'chrome-headless-shell', you entered '${value}'`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.headlessMode = value;
|
this.headlessMode = value;
|
||||||
|
|
@ -400,11 +398,7 @@ class Chromium {
|
||||||
`Graphics mode must be a boolean, you entered '${value}'`
|
`Graphics mode must be a boolean, you entered '${value}'`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
this.graphicsMode = value;
|
||||||
// Disabling 'disabling the gpu'
|
|
||||||
// Blocked by https://github.com/Sparticuz/chromium/issues/247
|
|
||||||
// this.graphicsMode = value;
|
|
||||||
this.graphicsMode = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,4 +72,4 @@ class LambdaFS {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default LambdaFS;
|
export = LambdaFS;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": ["@tsconfig/node20/tsconfig", "@tsconfig/strictest"],
|
"extends": ["@tsconfig/node16/tsconfig", "@tsconfig/strictest"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"lib": ["dom", "ES2023"],
|
"lib": ["dom", "ES2021"],
|
||||||
"module": "NodeNext",
|
"module": "Node16",
|
||||||
"moduleResolution": "NodeNext",
|
"moduleResolution": "Node16",
|
||||||
"outDir": "build"
|
"outDir": "build"
|
||||||
},
|
},
|
||||||
"include": ["source"]
|
"include": ["source"]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue