Compare commits
No commits in common. "master" and "v111.0.0" have entirely different histories.
|
|
@ -12,11 +12,10 @@ For Playwright-specific bugs, please refer to: https://github.com/microsoft/play
|
||||||
-->
|
-->
|
||||||
|
|
||||||
## Environment
|
## Environment
|
||||||
|
* `chromium` Version:
|
||||||
- `chromium` Version:
|
* `puppeteer` / `puppeteer-core` Version:
|
||||||
- `puppeteer` / `puppeteer-core` Version:
|
* Node.js Version: <!-- 14.x | 16.x -->
|
||||||
- Node.js Version: <!-- 16.x | 18.x -->
|
* Lambda / GCF Runtime: <!-- `nodejs8.10` | `nodejs10.x` | `nodejs12.x` -->
|
||||||
- Lambda / GCF Runtime: <!-- `nodejs16` | `nodejs18.x` -->
|
|
||||||
|
|
||||||
## Expected Behavior
|
## Expected Behavior
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,37 +2,37 @@ name: AWS Lambda CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [master]
|
branches: [ master ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [master]
|
branches: [ master ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build Lambda Layer
|
name: Build Lambda Layer
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 18.x
|
||||||
|
|
||||||
- name: Install Packages
|
- name: Install Packages
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Compile Typescript
|
- name: Compile Typescript
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: Create Lambda Layer
|
- name: Create Lambda Layer
|
||||||
run: make chromium.zip
|
run: make chromium.zip
|
||||||
|
|
||||||
- name: Upload Layer Artifact
|
- name: Upload Layer Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: chromium
|
name: chromium
|
||||||
path: chromium.zip
|
path: chromium.zip
|
||||||
|
|
||||||
execute:
|
execute:
|
||||||
name: Lambda (Node ${{ matrix.version }}.x)
|
name: Lambda (Node ${{ matrix.version }}.x)
|
||||||
|
|
@ -43,31 +43,31 @@ jobs:
|
||||||
event:
|
event:
|
||||||
- example.com
|
- example.com
|
||||||
version:
|
version:
|
||||||
|
- 14
|
||||||
- 16
|
- 16
|
||||||
- 18
|
- 18
|
||||||
- 20
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.x"
|
python-version: '3.x'
|
||||||
|
|
||||||
- name: Setup AWS SAM CLI
|
- name: Setup AWS SAM CLI
|
||||||
uses: aws-actions/setup-sam@v2
|
uses: aws-actions/setup-sam@v2
|
||||||
|
|
||||||
- name: Download Layer Artifact
|
- name: Download Layer Artifact
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: chromium
|
name: chromium
|
||||||
|
|
||||||
- name: Provision Layer
|
- name: Provision Layer
|
||||||
run: unzip chromium.zip -d _/amazon/code
|
run: unzip chromium.zip -d _/amazon/code
|
||||||
|
|
||||||
- name: Install test dependencies
|
- name: Install test dependencies
|
||||||
run: npm install --prefix _/amazon/handlers puppeteer-core --bin-links=false --fund=false --omit=optional --omit=dev --package-lock=false --save=false
|
run: npm install --prefix _/amazon/handlers puppeteer-core --bin-links=false --fund=false --omit=optional --omit=dev --package-lock=false --save=false
|
||||||
|
|
||||||
- name: Invoke Lambda on SAM
|
- name: Invoke Lambda on SAM
|
||||||
run: sam local invoke --template _/amazon/template.yml --event _/amazon/events/${{ matrix.event }}.json node${{ matrix.version }} 2>&1 | (grep 'Error' && exit 1 || exit 0)
|
run: sam local invoke --template _/amazon/template.yml --event _/amazon/events/${{ matrix.event }}.json node${{ matrix.version }} 2>&1 | (grep 'Error' && exit 1 || exit 0)
|
||||||
|
|
|
||||||
|
|
@ -10,70 +10,71 @@ jobs:
|
||||||
name: Build and release
|
name: Build and release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
# Install jq so I can edit package.json from the command line
|
# Install jq so I can edit package.json from the command line
|
||||||
- run: sudo apt-get install jq -y
|
- run: sudo apt-get install jq -y
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 18.x
|
||||||
registry-url: https://registry.npmjs.org/
|
registry-url: https://registry.npmjs.org/
|
||||||
|
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
|
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
|
|
||||||
- name: Release chromium on npmjs
|
- name: Release chromium on npmjs
|
||||||
run: npm publish
|
run: npm publish
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
||||||
|
|
||||||
- name: Create Lambda Layer
|
- name: Create Lambda Layer
|
||||||
run: make chromium-${{ github.ref_name }}-layer.zip
|
run: make chromium-${{ github.ref_name }}-layer.zip
|
||||||
|
|
||||||
# Change the package name to chromium-min,
|
# Change the package name to chromium-min,
|
||||||
# delete the bin folder from the files array
|
# delete the bin folder from the files array
|
||||||
# so that it doesn't publish the binaries to -min
|
# so that it doesn't publish the binaries to -min
|
||||||
- name: Cleanup and prepare for chromium-min
|
- name: Cleanup and prepare for chromium-min
|
||||||
run: |
|
run: |
|
||||||
jq '.name="@sparticuz/chromium-min"' package.json > .package.json
|
jq '.name="@sparticuz/chromium-min"' package.json > .package.json
|
||||||
jq 'del(.files[] | select(. == "bin"))' .package.json > package.json
|
jq 'del(.files[] | select(. == "bin"))' .package.json > package.json
|
||||||
jq '.homepage="https://github.com/Sparticuz/chromium#-min-package"' package.json > .package.json
|
jq '.homepage="https://github.com/Sparticuz/chromium#-min-package"' package.json > .package.json
|
||||||
mv .package.json package.json
|
mv .package.json package.json
|
||||||
rm package-lock.json
|
rm package-lock.json
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
- name: Release chromium-min on npmjs
|
- name: Release chromium-min on npmjs
|
||||||
run: npm publish
|
run: npm publish
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
||||||
|
|
||||||
- name: Create Chromium Pack
|
- name: Create Chromium Pack
|
||||||
run: |
|
run: |
|
||||||
cd bin
|
cd bin
|
||||||
tar -cvf chromium-${{ github.ref_name }}-pack.tar *
|
tar -cvf chromium-${{ github.ref_name }}-pack.tar *
|
||||||
mv chromium-${{ github.ref_name }}-pack.tar ..
|
mv chromium-${{ github.ref_name }}-pack.tar ..
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Upload items to Github Release
|
- name: Upload items to Github Release
|
||||||
uses: ncipollo/release-action@v1.14.0
|
uses: ncipollo/release-action@v1.12.0
|
||||||
with:
|
with:
|
||||||
tag: ${{ github.ref_name }}
|
tag: ${{ github.ref_name }}
|
||||||
body: |
|
body: |
|
||||||
# [@sparticuz/chromium ${{ github.ref_name }}](https://www.npmjs.com/package/@sparticuz/chromium), [@sparticuz/chromium-min ${{ github.ref_name }}](https://www.npmjs.com/package/@sparticuz/chromium-min)
|
# [@sparticuz/chromium ${{ github.ref_name }}](https://www.npmjs.com/package/@sparticuz/chromium), [@sparticuz/chromium-min ${{ github.ref_name }}](https://www.npmjs.com/package/@sparticuz/chromium-min)
|
||||||
The `chromium-${{ github.ref_name }}-layer.zip` file may be uploaded directly as a layer in AWS Lambda using the following code
|
The `chromium-${{ github.ref_name }}-layer.zip` file may be uploaded directly as a layer in AWS Lambda using the following code
|
||||||
```
|
```
|
||||||
bucketName="chromiumUploadBucket" && \
|
bucketName="chromiumUploadBucket" && \
|
||||||
aws s3 cp chromium-${{ github.ref_name }}-layer.zip "s3://${bucketName}/chromiumLayers/chromium-${{ github.ref_name }}-layer.zip" && \
|
aws s3 cp chromium-${{ github.ref_name }}-layer.zip "s3://${bucketName}/chromiumLayers/chromium-${{ github.ref_name }}-layer.zip" && \
|
||||||
aws lambda publish-layer-version --layer-name chromium --description "Chromium ${{ github.ref_name }}" --content "S3Bucket=${bucketName},S3Key=chromiumLayers/chromium-${{ github.ref_name }}-layer.zip" --compatible-runtimes nodejs --compatible-architectures x86_64
|
aws lambda publish-layer-version --layer-name chromium --description "Chromium ${{ github.ref_name }}" --content "S3Bucket=${bucketName},S3Key=chromiumLayers/chromium-${{ github.ref_name }}-layer.zip" --compatible-runtimes nodejs --compatible-architectures x86_64
|
||||||
```
|
```
|
||||||
The `chromium-${{ github.ref_name }}-pack.tar` file may be uploaded to any https endpoint and the remote location may be used as the `input` variable in the `chromium.executablePath(input)` function.
|
The `chromium-${{ github.ref_name }}-pack.tar` file may be uploaded to any https endpoint and the remote location may be used as the `input` variable in the `chromium.executablePath(input)` function.
|
||||||
artifacts: "chromium-${{ github.ref_name }}-layer.zip,chromium-${{ github.ref_name }}-pack.tar"
|
artifacts: "chromium-${{ github.ref_name }}-layer.zip,chromium-${{ github.ref_name }}-pack.tar"
|
||||||
prerelease: false
|
prerelease: false
|
||||||
draft: true
|
draft: true
|
||||||
generateReleaseNotes: true
|
generateReleaseNotes: true
|
||||||
token: ${{ github.token }}
|
token: ${{ github.token }}
|
||||||
owner: Sparticuz
|
owner: Sparticuz
|
||||||
repo: chromium
|
repo: chromium
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,3 @@ _/amazon/.aws-sam
|
||||||
*.tgz
|
*.tgz
|
||||||
examples/**/package-lock.json
|
examples/**/package-lock.json
|
||||||
examples/**/.serverless
|
examples/**/.serverless
|
||||||
docker
|
|
||||||
|
|
|
||||||
13
Makefile
13
Makefile
|
|
@ -8,23 +8,20 @@ pretest:
|
||||||
npm install --prefix _/amazon/handlers puppeteer-core@latest --bin-links=false --fund=false --omit=optional --omit=dev --package-lock=false --save=false
|
npm install --prefix _/amazon/handlers puppeteer-core@latest --bin-links=false --fund=false --omit=optional --omit=dev --package-lock=false --save=false
|
||||||
|
|
||||||
test:
|
test:
|
||||||
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
|
sam local invoke --template _/amazon/template.yml --event _/amazon/events/example.com.json node18
|
||||||
|
|
||||||
|
.fonts.zip:
|
||||||
|
zip -9 --filesync --move --recurse-paths .fonts.zip .fonts/
|
||||||
|
|
||||||
%.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@2.1.1 follow-redirects@1.15.2 --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
|
||||||
npx clean-modules --directory nodejs "**/*.d.ts" "**/@types/**" "**/*.@(yaml|yml)" --yes
|
npx clean-modules --directory nodejs --include "**/*.d.ts" "**/@types/**" "**/*.@(yaml|yml)" --yes
|
||||||
rm sparticuz-chromium-*.tgz
|
rm sparticuz-chromium-*.tgz
|
||||||
mkdir -p $(dir $@)
|
mkdir -p $(dir $@)
|
||||||
zip -9 --filesync --move --recurse-paths $@ nodejs
|
zip -9 --filesync --move --recurse-paths $@ nodejs
|
||||||
|
|
|
||||||
200
README.md
200
README.md
|
|
@ -1,21 +1,24 @@
|
||||||
# @sparticuz/chromium
|
# @sparticuz/chromium
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/@sparticuz/chromium)
|
[](https://www.npmjs.com/package/@sparticuz/chromium)
|
||||||
[](bin/)
|
[](https://www.typescriptlang.org/dt/search?search=chromium)
|
||||||
[](https://www.npmjs.com/package/@sparticuz/chromium)
|
[](bin/)
|
||||||
[](https://www.npmjs.com/package/@sparticuz/chromium-min)
|
|
||||||
[](https://paypal.me/sparticuz)
|
[](https://paypal.me/sparticuz)
|
||||||
|
|
||||||
## Chromium for Serverless platforms
|
## Chromium for Serverless platforms
|
||||||
|
|
||||||
[sparticuz/chrome-aws-lambda](https://github.com/sparticuz/chrome-aws-lambda) was originally forked from [alixaxel/chrome-aws-lambda#264](https://github.com/alixaxel/chrome-aws-lambda/pull/264).
|
This package was originally forked from [alixaxel/chrome-aws-lambda#264](https://github.com/alixaxel/chrome-aws-lambda/pull/264).
|
||||||
The biggest difference, besides the chromium version, is the inclusion of some code from https://github.com/alixaxel/lambdafs, as well as dropping that as a dependency. Due to some changes in WebGL, the files in bin/swiftshader.tar.br need to be extracted to `/tmp` instead of `/tmp/swiftshader`. This necessitated changes in lambdafs.
|
The biggest difference, besides the chromium version, is the inclusion of some code from https://github.com/alixaxel/lambdafs,
|
||||||
|
as well as dropping that as a dependency. Due to some changes in WebGL, the files in bin/swiftshader.tar.br need to
|
||||||
|
be extracted to `/tmp` instead of `/tmp/swiftshader`. This necessitated changes in lambdafs.
|
||||||
|
|
||||||
However, it quickly became difficult to maintain because of the pace of `puppeteer` updates. This package, `@sparticuz/chromium`, is not chained to `puppeteer` versions, but also does not include the overrides and hooks that the original package contained. It is only `chromium`, as well as the special code needed to decompress the brotli package, and a set of predefined arguments tailored to serverless usage.
|
However, it quickly became difficult to maintain because of the pace of `puppeteer` updates. This package, `@sparticuz/chromium`,
|
||||||
|
is not chained to `puppeteer` versions, but also does not include the overrides and hooks that the original package contained. It is only `chromium`, as well as the special code needed to decompress the brotli package.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
[`puppeteer` ships with a preferred version of `chromium`](https://pptr.dev/faq/#q-why-doesnt-puppeteer-vxxx-work-with-chromium-vyyy). In order to figure out what version of `@sparticuz/chromium` you will need, please visit [Puppeteer's Chromium Support page](https://pptr.dev/chromium-support).
|
[`puppeteer` ships with a prefered version of `chromium`](https://pptr.dev/faq/#q-why-doesnt-puppeteer-vxxx-work-with-chromium-vyyy).
|
||||||
|
In order to figure out what version of `@sparticuz/chromium` you will need, please visit [Puppeteer's Chromium Support page](https://pptr.dev/chromium-support).
|
||||||
|
|
||||||
> For example, as of today, the latest version of `puppeteer` is `18.0.5`. The latest version of `chromium` stated on `puppeteer`'s support page is `106.0.5249.0`. So you need to install `@sparticuz/chromium@106`.
|
> For example, as of today, the latest version of `puppeteer` is `18.0.5`. The latest version of `chromium` stated on `puppeteer`'s support page is `106.0.5249.0`. So you need to install `@sparticuz/chromium@106`.
|
||||||
|
|
||||||
|
|
@ -26,8 +29,7 @@ npm install --save puppeteer-core@$PUPPETEER_VERSION
|
||||||
npm install --save-dev @sparticuz/chromium@$CHROMIUM_VERSION
|
npm install --save-dev @sparticuz/chromium@$CHROMIUM_VERSION
|
||||||
```
|
```
|
||||||
|
|
||||||
If your vendor does not allow large deploys (`chromium.br` is 50+ MB), you'll need to host the `chromium-v#-pack.tar` separately and use the [`@sparticuz/chromium-min` package](https://github.com/Sparticuz/chromium#-min-package).
|
If your vendor does not allow large deploys (`chromium.br` is 50+ MB), you'll need to host the `chromium-v#-pack.tar` separatly and use the [`@sparticuz/chromium-min` package](https://github.com/Sparticuz/chromium#-min-package).
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
npm install --save @sparticuz/chromium-min@$CHROMIUM_VERSION
|
npm install --save @sparticuz/chromium-min@$CHROMIUM_VERSION
|
||||||
```
|
```
|
||||||
|
|
@ -39,8 +41,6 @@ If you wish to install an older version of Chromium, take a look at [@sparticuz/
|
||||||
The @sparticuz/chromium version schema is as follows:
|
The @sparticuz/chromium version schema is as follows:
|
||||||
`MajorChromiumVersion.MinorChromiumIncrement.@Sparticuz/chromiumPatchLevel`
|
`MajorChromiumVersion.MinorChromiumIncrement.@Sparticuz/chromiumPatchLevel`
|
||||||
|
|
||||||
Because this package follows Chromium's releases, it does NOT follow semantic versioning. **Breaking changes can occur with the 'patch' level.** Please check the release notes for information on breaking changes.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
This package works with all the currently supported AWS Lambda Node.js runtimes out of the box.
|
This package works with all the currently supported AWS Lambda Node.js runtimes out of the box.
|
||||||
|
|
@ -50,25 +50,13 @@ 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.
|
|
||||||
// NOTE: Because we build the shell binary, this option does not work.
|
|
||||||
// However, this option will stay so when we migrate to full chromium it will work.
|
|
||||||
chromium.setHeadlessMode = true;
|
|
||||||
|
|
||||||
// Optional: If you'd like to disable webgl, true is the default.
|
|
||||||
chromium.setGraphicsMode = false;
|
|
||||||
|
|
||||||
// Optional: Load any fonts you need. Open Sans is included by default in AWS Lambda instances
|
|
||||||
await chromium.font(
|
|
||||||
"https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf"
|
|
||||||
);
|
|
||||||
|
|
||||||
test("Check the page title of example.com", async (t) => {
|
test("Check the page title of example.com", async (t) => {
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
args: chromium.args,
|
args: chromium.args,
|
||||||
defaultViewport: chromium.defaultViewport,
|
defaultViewport: chromium.defaultViewport,
|
||||||
executablePath: await chromium.executablePath(),
|
executablePath: await chromium.executablePath(),
|
||||||
headless: chromium.headless,
|
headless: chromium.headless,
|
||||||
|
ignoreHTTPSErrors: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
|
|
@ -85,8 +73,8 @@ test("Check the page title of example.com", async (t) => {
|
||||||
```javascript
|
```javascript
|
||||||
const test = require("node:test");
|
const test = require("node:test");
|
||||||
// Need to rename playwright's chromium object to something else
|
// Need to rename playwright's chromium object to something else
|
||||||
const { chromium: playwright } = require("playwright-core");
|
const { chromium: playwright } = require('playwright-core');
|
||||||
const chromium = require("@sparticuz/chromium");
|
const chromium = require('@sparticuz/chromium');
|
||||||
|
|
||||||
test("Check the page title of example.com", async (t) => {
|
test("Check the page title of example.com", async (t) => {
|
||||||
const browser = await playwright.launch({
|
const browser = await playwright.launch({
|
||||||
|
|
@ -104,19 +92,18 @@ test("Check the page title of example.com", async (t) => {
|
||||||
assert.strictEqual(pageTitle, "Example Domain");
|
assert.strictEqual(pageTitle, "Example Domain");
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
You should allocate at least 512 MB of RAM to your Lambda, however 1600 MB (or more) is recommended.
|
||||||
You should allocate at least 512 MB of RAM to your instance, however 1600 MB (or more) is recommended.
|
|
||||||
|
|
||||||
### -min package
|
### -min package
|
||||||
|
|
||||||
The -min package DOES NOT include the chromium brotli files. There are a few instances where this is useful. Primarily, this is useful when your host has file size limits.
|
The -min package DOES NOT include the chromium brotli files. There are a few instances where this
|
||||||
|
is useful. Primarily, this is useful when you have file size limits.
|
||||||
|
|
||||||
To use the -min package please install the `@sparticuz/chromium-min` package.
|
To use the -min package please install the `@sparticuz/chromium-min` package.
|
||||||
|
|
||||||
When using the -min package, you need to specify the location of the brotli files.
|
When using the -min package, you need to specify the location of the brotli files.
|
||||||
|
|
||||||
In this example, /opt/chromium contains all the brotli files
|
In this example, /opt/chromium contains all the brotli files
|
||||||
|
|
||||||
```
|
```
|
||||||
/opt
|
/opt
|
||||||
/chromium
|
/chromium
|
||||||
|
|
@ -124,19 +111,22 @@ In this example, /opt/chromium contains all the brotli files
|
||||||
/chromium.br
|
/chromium.br
|
||||||
/swiftshader.tar.br
|
/swiftshader.tar.br
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
args: chromium.args,
|
args: chromium.args,
|
||||||
defaultViewport: chromium.defaultViewport,
|
defaultViewport: chromium.defaultViewport,
|
||||||
executablePath: await chromium.executablePath("/opt/chromium"),
|
executablePath: await chromium.executablePath("/opt/chromium"),
|
||||||
headless: chromium.headless,
|
headless: chromium.headless,
|
||||||
|
ignoreHTTPSErrors: true,
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
In the following example, https://www.example.com/chromiumPack.tar contains all the brotli files.
|
||||||
|
Generally, this would be a location on S3, or another very fast downloadable location,
|
||||||
|
that is close to your function's execution location.
|
||||||
|
|
||||||
In the following example, https://www.example.com/chromiumPack.tar contains all the brotli files. Generally, this would be a location on S3, or another very fast downloadable location, that is in close proximity to your function's execution location.
|
@sparticuz/chromium will download the pack tar file, untar the files to /tmp/chromium-pack,
|
||||||
|
then will un-brotli the files to /tmp/chromium. The next iteration will have /tmp/chromium exist
|
||||||
On the initial iteration, `@sparticuz/chromium` will download the pack tar file, untar the files to `/tmp/chromium-pack`, then will un-brotli the `chromium` binary to `/tmp/chromium`. The following iterations will see that `/tmp/chromium` exists and will use the already downloaded files.
|
and will use the already downloaded files.
|
||||||
|
|
||||||
The latest chromium-pack.tar file will be on the latest [release](https://github.com/Sparticuz/chromium/releases).
|
The latest chromium-pack.tar file will be on the latest [release](https://github.com/Sparticuz/chromium/releases).
|
||||||
|
|
||||||
|
|
@ -144,128 +134,51 @@ The latest chromium-pack.tar file will be on the latest [release](https://github
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
args: chromium.args,
|
args: chromium.args,
|
||||||
defaultViewport: chromium.defaultViewport,
|
defaultViewport: chromium.defaultViewport,
|
||||||
executablePath: await chromium.executablePath(
|
executablePath: await chromium.executablePath("https://www.example.com/chromiumPack.tar"),
|
||||||
"https://www.example.com/chromiumPack.tar"
|
|
||||||
),
|
|
||||||
headless: chromium.headless,
|
headless: chromium.headless,
|
||||||
|
ignoreHTTPSErrors: true,
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
Here are some example projects and help with other services
|
Here are some example projects and help with other services
|
||||||
|
|
||||||
- [Production Dependency](https://github.com/Sparticuz/chromium/tree/master/examples/production-dependency)
|
- [Production Dependency](https://github.com/Sparticuz/chromium/tree/master/examples/production-dependency)
|
||||||
- [Serverless Framework with Lambda Layer](https://github.com/Sparticuz/chromium/tree/master/examples/serverless-with-lambda-layer)
|
- [Serverless Framework with Lambda Layer](https://github.com/Sparticuz/chromium/tree/master/examples/serverless-with-lambda-layer)
|
||||||
- [Serverless Framework with Pre-existing Lambda Layer](https://github.com/Sparticuz/chromium/tree/master/examples/serverless-with-preexisting-lambda-layer)
|
|
||||||
- [Chromium-min](https://github.com/Sparticuz/chromium/tree/master/examples/remote-min-binary)
|
- [Chromium-min](https://github.com/Sparticuz/chromium/tree/master/examples/remote-min-binary)
|
||||||
- [AWS SAM](https://github.com/Sparticuz/chromium/tree/master/examples/aws-sam)
|
- AWS SAM *TODO*
|
||||||
- [Webpack](https://github.com/Sparticuz/chromium/issues/24#issuecomment-1343196897)
|
- [Webpack](https://github.com/Sparticuz/chromium/issues/24#issuecomment-1343196897)
|
||||||
- [Netlify](https://github.com/Sparticuz/chromium/issues/24#issuecomment-1414107620)
|
- [Netlify](https://github.com/Sparticuz/chromium/issues/24#issuecomment-1414107620)
|
||||||
|
|
||||||
### Running Locally & Headless/Headful mode
|
### Running Locally
|
||||||
|
|
||||||
This version of `chromium` is built using the `headless.gn` build variables, which does not appear to even include a GUI. [Also, at this point, AWS Lambda 2 does not support a modern version of `glibc`](https://github.com/aws/aws-lambda-base-images/issues/59), so this package does not include an ARM version yet, which means it will not work on any M Series Apple products. If you need to test your code using a headful or ARM version, please use your locally installed version of `chromium/chrome`, or you may use the `puppeteer` provided version. Users have reported installing `rosetta` on MacOS will also work.
|
This package will run in headless mode when `NODE_ENV = "test"`. If you want to run using your own local binary, set `IS_LOCAL` to anything.
|
||||||
|
|
||||||
```shell
|
## API
|
||||||
npx @puppeteer/browsers install chromium@latest --path /tmp/localChromium
|
|
||||||
```
|
|
||||||
|
|
||||||
For more information on installing a specific version of `chromium`, checkout [@puppeteer/browsers](https://www.npmjs.com/package/@puppeteer/browsers).
|
| Method / Property | Returns | Description |
|
||||||
|
| --------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
For example, you can set your code to use an ENV variable such as `IS_LOCAL`, then use if/else statements to direct puppeteer to the correct environment.
|
| `font(url)` | `{?Promise<string>}` | Provisions a custom font and returns its basename. |
|
||||||
|
| `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). |
|
||||||
```javascript
|
| `defaultViewport` | `{!Object}` | Returns more sensible default viewport settings. |
|
||||||
const browser = await puppeteer.launch({
|
| `executablePath(location)` | `{?Promise<string>}` | Returns the path the Chromium binary was extracted to. |
|
||||||
args: process.env.IS_LOCAL ? puppeteer.defaultArgs() : chromium.args,
|
| `headless` | `{!boolean}` | Returns `true` if we are running on AWS Lambda or GCF. |
|
||||||
defaultViewport: chromium.defaultViewport,
|
|
||||||
executablePath: process.env.IS_LOCAL
|
|
||||||
? "/tmp/localChromium/chromium/linux-1122391/chrome-linux/chrome"
|
|
||||||
: await chromium.executablePath(),
|
|
||||||
headless: process.env.IS_LOCAL ? false : chromium.headless,
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Frequently asked questions
|
|
||||||
|
|
||||||
### Can I use ARM or Graviton instances?
|
|
||||||
|
|
||||||
Amazon's default Lambda base image is quite old at this point and does not support newer versions of `glibc` that chromium requires. When Amazon Linux 2023 comes to Lambda as the default base image, ARM support should be possible. Ref: https://github.com/Sparticuz/chrome-aws-lambda/pull/11, https://github.com/aws/aws-lambda-base-images/issues/59
|
|
||||||
|
|
||||||
### Can I use Google Chrome or Chrome for Testing, what is headless_shell?
|
|
||||||
|
|
||||||
`headless_shell` is a purpose built version of `chromium` specific for headless purposes. It does not include the GUI at all and only works via remote debugging connection. Ref: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md, https://source.chromium.org/chromium/chromium/src/+/main:headless/app/headless_shell.cc
|
|
||||||
|
|
||||||
### Can I use the "new" Headless mode?
|
|
||||||
|
|
||||||
From what I can tell, `headless_shell` does not seem to include support for the "new" headless mode.
|
|
||||||
|
|
||||||
### It doesn't work with Webpack!?!
|
|
||||||
|
|
||||||
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 no longer provisioned with any font faces.
|
||||||
|
|
||||||
Because of this, this package ships with [Open Sans](https://fonts.google.com/specimen/Open+Sans), which supports the following scripts:
|
Because of this, this package ships with [Open Sans](https://fonts.google.com/specimen/Open+Sans), which supports the following scripts:
|
||||||
|
|
||||||
- Latin
|
* Latin
|
||||||
- Greek
|
* Greek
|
||||||
- Cyrillic
|
* Cyrillic
|
||||||
|
|
||||||
To provision additional fonts, simply call the `font()` method with an absolute path or URL:
|
To provision additional fonts, simply call the `font()` method with an absolute path or URL:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
await chromium.font("/var/task/fonts/NotoColorEmoji.ttf");
|
await chromium.font('/var/task/fonts/NotoColorEmoji.ttf');
|
||||||
// or
|
// or
|
||||||
await chromium.font(
|
await chromium.font('https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf');
|
||||||
"https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf"
|
|
||||||
);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> `Noto Color Emoji` (or similar) is needed if you want to [render emojis](https://getemoji.com/).
|
> `Noto Color Emoji` (or similar) is needed if you want to [render emojis](https://getemoji.com/).
|
||||||
|
|
@ -274,11 +187,13 @@ await chromium.font(
|
||||||
|
|
||||||
This method should be invoked _before_ launching Chromium.
|
This method should be invoked _before_ launching Chromium.
|
||||||
|
|
||||||
|
> On non-serverless environments, the `font()` method is a no-op to avoid polluting the user space.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Alternatively, it's also possible to provision fonts via AWS Lambda Layers.
|
Alternatively, it's also possible to provision fonts via AWS Lambda Layers.
|
||||||
|
|
||||||
Simply create a directory named `.fonts` or `fonts` and place any font faces you want there:
|
Simply create a directory named `.fonts` and place any font faces you want there:
|
||||||
|
|
||||||
```
|
```
|
||||||
.fonts
|
.fonts
|
||||||
|
|
@ -289,26 +204,8 @@ Simply create a directory named `.fonts` or `fonts` and place any font faces you
|
||||||
Afterwards, you just need to ZIP the directory and upload it as a AWS Lambda Layer:
|
Afterwards, you just need to ZIP the directory and upload it as a AWS Lambda Layer:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
zip -9 --filesync --move --recurse-paths fonts.zip fonts/
|
zip -9 --filesync --move --recurse-paths .fonts.zip .fonts/
|
||||||
```
|
```
|
||||||
|
|
||||||
## Graphics
|
|
||||||
|
|
||||||
By default, this package uses `swiftshader`/`angle` to do CPU acceleration for WebGL. This is the only known way to enable WebGL on a serverless platform. You can disable WebGL by setting `chromium.setGraphiceMode = false;` _before_ launching Chromium. Disabling this will also skip the extract of the `bin/swiftshader.tar.br` file, which saves about a second of initial execution time. Disabling graphics is recommended if you know you are not using any WebGL.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
| Method / Property | Returns | Description |
|
|
||||||
| ----------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| `font(url)` | `Promise<string>` | Provisions a custom font and returns its basename. |
|
|
||||||
| `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. |
|
|
||||||
| `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"` |
|
|
||||||
| `headless` | `true \| "shell"` | Returns `true` or `"shell"` depending on what version of chrome's headless you are running |
|
|
||||||
| `setGraphicsMode` | `void` | Sets the graphics mode to either `true` or `false` |
|
|
||||||
| `graphics` | `boolean` | Returns a boolean depending on whether webgl is enabled or disabled |
|
|
||||||
|
|
||||||
## Compiling
|
## Compiling
|
||||||
|
|
||||||
To compile your own version of Chromium check the [Ansible playbook instructions](_/ansible).
|
To compile your own version of Chromium check the [Ansible playbook instructions](_/ansible).
|
||||||
|
|
@ -326,7 +223,6 @@ make chromium.zip
|
||||||
```
|
```
|
||||||
|
|
||||||
The above will create a `chromium.zip` file, which can be uploaded to your Layers console. You can and should upload using the `aws cli`. (Replace the variables with your own values)
|
The above will create a `chromium.zip` file, which can be uploaded to your Layers console. You can and should upload using the `aws cli`. (Replace the variables with your own values)
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
bucketName="chromiumUploadBucket" && \
|
bucketName="chromiumUploadBucket" && \
|
||||||
versionNumber="107" && \
|
versionNumber="107" && \
|
||||||
|
|
@ -344,7 +240,6 @@ According to our benchmarks, it's 40% to 50% faster than using the off-the-shelf
|
||||||
- Add the import or require for `puppeteer-core`
|
- Add the import or require for `puppeteer-core`
|
||||||
- Change the browser launch to use the native `puppeteer.launch()` function
|
- Change the browser launch to use the native `puppeteer.launch()` function
|
||||||
- Change the `executablePath` to be a function.
|
- Change the `executablePath` to be a function.
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
-const chromium = require('@sparticuz/chrome-aws-lambda');
|
-const chromium = require('@sparticuz/chrome-aws-lambda');
|
||||||
+const chromium = require("@sparticuz/chromium");
|
+const chromium = require("@sparticuz/chromium");
|
||||||
|
|
@ -381,7 +276,6 @@ exports.handler = async (event, context, callback) => {
|
||||||
return callback(null, result);
|
return callback(null, result);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
## Compression
|
## Compression
|
||||||
|
|
||||||
The Chromium binary is compressed using the Brotli algorithm.
|
The Chromium binary is compressed using the Brotli algorithm.
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,21 @@
|
||||||
"url": "https://example.com",
|
"url": "https://example.com",
|
||||||
"expected": {
|
"expected": {
|
||||||
"title": "Example Domain",
|
"title": "Example Domain",
|
||||||
"screenshot": "e610a8be5568f23c453b08928460aae3ae0b4b0a"
|
"screenshot": "fdd55bf210cb00e00cadf3098055611d11293d02"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://example.com",
|
||||||
|
"expected": {
|
||||||
|
"title": "Example Domain",
|
||||||
|
"screenshot": "fdd55bf210cb00e00cadf3098055611d11293d02"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "https://get.webgl.org",
|
"url": "https://get.webgl.org",
|
||||||
"expected": {
|
"expected": {
|
||||||
"remove": "logo-container",
|
"remove": "logo-container",
|
||||||
"screenshot": "ec6c79a571b4cb5727c6fc23f9da30de3868138c"
|
"screenshot": "7a63a9a18f32dcdad78e1e0a03364fade25c85a8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
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');
|
||||||
|
|
||||||
exports.handler = async (event, context) => {
|
exports.handler = async (event, context) => {
|
||||||
let browser = null;
|
let browser = null;
|
||||||
|
|
@ -10,49 +10,40 @@ exports.handler = async (event, context) => {
|
||||||
browser = await puppeteer.launch({
|
browser = await puppeteer.launch({
|
||||||
args: chromium.args,
|
args: chromium.args,
|
||||||
defaultViewport: chromium.defaultViewport,
|
defaultViewport: chromium.defaultViewport,
|
||||||
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());
|
const contexts = [
|
||||||
|
browser.defaultBrowserContext(),
|
||||||
|
];
|
||||||
|
|
||||||
for (let job of event) {
|
while (contexts.length < event.length) {
|
||||||
const page = await browser.newPage();
|
contexts.push(await browser.createIncognitoBrowserContext());
|
||||||
|
}
|
||||||
|
|
||||||
if (job.hasOwnProperty("url") === true) {
|
for (let context of contexts) {
|
||||||
await page.goto(job.url, { waitUntil: ["domcontentloaded", "load"] });
|
const job = event.shift();
|
||||||
|
const page = await context.newPage();
|
||||||
|
|
||||||
if (job.hasOwnProperty("expected") === true) {
|
if (job.hasOwnProperty('url') === true) {
|
||||||
if (job.expected.hasOwnProperty("title") === true) {
|
await page.goto(job.url, { waitUntil: ['domcontentloaded', 'load'] });
|
||||||
ok(
|
|
||||||
(await page.title()) === job.expected.title,
|
if (job.hasOwnProperty('expected') === true) {
|
||||||
`Title assertion failed.`
|
if (job.expected.hasOwnProperty('title') === true) {
|
||||||
);
|
ok(await page.title() === job.expected.title, `Title assertion failed.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (job.expected.hasOwnProperty("screenshot") === true) {
|
if (job.expected.hasOwnProperty('screenshot') === true) {
|
||||||
if (job.expected.hasOwnProperty("remove") === true) {
|
if (job.expected.hasOwnProperty('remove') === true ) {
|
||||||
await page.evaluate((selector) => {
|
await page.evaluate((selector) => {
|
||||||
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(screenshot.toString('base64'), createHash('sha1').update(screenshot.toString('base64')).digest('hex'));
|
||||||
console.log(
|
ok(createHash('sha1').update(screenshot.toString('base64')).digest('hex') === job.expected.screenshot, `Screenshot assertion failed.`);
|
||||||
`data:image/png;base64,${screenshot.toString("base64")}`,
|
|
||||||
createHash("sha1")
|
|
||||||
.update(screenshot.toString("base64"))
|
|
||||||
.digest("hex")
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
ok(
|
|
||||||
createHash("sha1")
|
|
||||||
.update(screenshot.toString("base64"))
|
|
||||||
.digest("hex") === job.expected.screenshot,
|
|
||||||
`Screenshot assertion failed.`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -61,9 +52,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,24 @@ Resources:
|
||||||
layer:
|
layer:
|
||||||
Type: AWS::Serverless::LayerVersion
|
Type: AWS::Serverless::LayerVersion
|
||||||
Properties:
|
Properties:
|
||||||
LayerName: sparticuz-chromium
|
LayerName: sparticuz-chromium
|
||||||
ContentUri: code/
|
ContentUri: code/
|
||||||
CompatibleRuntimes:
|
CompatibleRuntimes:
|
||||||
- nodejs16.x
|
- nodejs14.x
|
||||||
- nodejs18.x
|
- nodejs16.x
|
||||||
- nodejs20.x
|
- nodejs18.x
|
||||||
|
|
||||||
|
node14:
|
||||||
|
Type: AWS::Serverless::Function
|
||||||
|
Properties:
|
||||||
|
Layers:
|
||||||
|
- !Ref layer
|
||||||
|
Handler: handlers/index.handler
|
||||||
|
Runtime: nodejs14.x
|
||||||
|
Policies:
|
||||||
|
- AWSLambdaBasicExecutionRole
|
||||||
|
- AWSXRayDaemonWriteAccess
|
||||||
|
Tracing: Active
|
||||||
node16:
|
node16:
|
||||||
Type: AWS::Serverless::Function
|
Type: AWS::Serverless::Function
|
||||||
Properties:
|
Properties:
|
||||||
|
|
@ -38,14 +49,3 @@ Resources:
|
||||||
- AWSLambdaBasicExecutionRole
|
- AWSLambdaBasicExecutionRole
|
||||||
- AWSXRayDaemonWriteAccess
|
- AWSXRayDaemonWriteAccess
|
||||||
Tracing: Active
|
Tracing: Active
|
||||||
node20:
|
|
||||||
Type: AWS::Serverless::Function
|
|
||||||
Properties:
|
|
||||||
Layers:
|
|
||||||
- !Ref layer
|
|
||||||
Handler: handlers/index.handler
|
|
||||||
Runtime: nodejs20.x
|
|
||||||
Policies:
|
|
||||||
- AWSLambdaBasicExecutionRole
|
|
||||||
- AWSXRayDaemonWriteAccess
|
|
||||||
Tracing: Active
|
|
||||||
|
|
|
||||||
|
|
@ -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=1095492
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
ebs:
|
ebs:
|
||||||
delete_on_termination: true
|
delete_on_termination: true
|
||||||
volume_type: io2
|
volume_type: io2
|
||||||
volume_size: 256
|
volume_size: 128
|
||||||
iops: 3000
|
iops: 3000
|
||||||
register: ec2
|
register: ec2
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@
|
||||||
wait_for:
|
wait_for:
|
||||||
host: "{{ ec2.instances[0].public_ip_address }}"
|
host: "{{ ec2.instances[0].public_ip_address }}"
|
||||||
port: 22
|
port: 22
|
||||||
timeout: 320
|
timeout: 240
|
||||||
state: started
|
state: started
|
||||||
|
|
||||||
- name: AWS
|
- name: AWS
|
||||||
|
|
@ -142,7 +142,8 @@
|
||||||
- name: Checking for Directory Structure
|
- name: Checking for Directory Structure
|
||||||
stat:
|
stat:
|
||||||
path: /srv/source/chromium
|
path: /srv/source/chromium
|
||||||
register: structure
|
register:
|
||||||
|
structure
|
||||||
|
|
||||||
- name: Creating Directory Structure
|
- name: Creating Directory Structure
|
||||||
become: true
|
become: true
|
||||||
|
|
@ -171,7 +172,7 @@
|
||||||
dest: /srv/source/chromium/.gclient
|
dest: /srv/source/chromium/.gclient
|
||||||
owner: ec2-user
|
owner: ec2-user
|
||||||
group: ec2-user
|
group: ec2-user
|
||||||
mode: "0664"
|
mode: '0664'
|
||||||
|
|
||||||
- name: Checking for Chromium
|
- name: Checking for Chromium
|
||||||
stat:
|
stat:
|
||||||
|
|
@ -186,8 +187,8 @@
|
||||||
|
|
||||||
- name: Parse Result
|
- name: Parse Result
|
||||||
set_fact:
|
set_fact:
|
||||||
gitsha: >
|
gitsha: >
|
||||||
{{ revision.content | regex_search('"git_sha":"([a-zA-Z0-9_]*)"', '\1') | trim }}
|
{{ revision.content | regex_search('"git_sha":"([a-zA-Z0-9_]*)"', '\1') | trim }}
|
||||||
|
|
||||||
- name: Checking Out Chromium revision
|
- name: Checking Out Chromium revision
|
||||||
shell: |
|
shell: |
|
||||||
|
|
@ -210,22 +211,22 @@
|
||||||
backrefs: yes
|
backrefs: yes
|
||||||
with_items:
|
with_items:
|
||||||
- {
|
- {
|
||||||
path: "sandbox_ipc_linux.cc",
|
path: 'sandbox_ipc_linux.cc',
|
||||||
line: '\1PLOG(WARNING) << "poll"; failed_polls = 0;',
|
line: '\1PLOG(WARNING) << "poll"; failed_polls = 0;',
|
||||||
regexp: '^(\s+)PLOG[(]WARNING[)] << "poll";$',
|
regexp: '^(\s+)PLOG[(]WARNING[)] << "poll";$',
|
||||||
}
|
}
|
||||||
- {
|
- {
|
||||||
path: "renderer_host/render_process_host_impl.cc",
|
path: 'renderer_host/render_process_host_impl.cc',
|
||||||
line: '\1// \2\3',
|
line: '\1// \2\3',
|
||||||
regexp: '^( )(\s*)(CHECK[(]render_process_host->InSameStoragePartition[(])$',
|
regexp: '^( )(\s*)(CHECK[(]render_process_host->InSameStoragePartition[(])$',
|
||||||
}
|
}
|
||||||
- {
|
- {
|
||||||
path: "renderer_host/render_process_host_impl.cc",
|
path: 'renderer_host/render_process_host_impl.cc',
|
||||||
line: '\1// \2\3',
|
line: '\1// \2\3',
|
||||||
regexp: '^( )(\s*)(browser_context->GetStoragePartition[(]site_instance,)$',
|
regexp: '^( )(\s*)(browser_context->GetStoragePartition[(]site_instance,)$',
|
||||||
}
|
}
|
||||||
- {
|
- {
|
||||||
path: "renderer_host/render_process_host_impl.cc",
|
path: 'renderer_host/render_process_host_impl.cc',
|
||||||
line: '\1// \2\3',
|
line: '\1// \2\3',
|
||||||
regexp: '^( )(\s*)(false /[*] can_create [*]/[)][)][)];)$',
|
regexp: '^( )(\s*)(false /[*] can_create [*]/[)][)][)];)$',
|
||||||
}
|
}
|
||||||
|
|
@ -236,6 +237,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: |
|
||||||
|
|
@ -333,7 +340,7 @@
|
||||||
amazon.aws.ec2_instance:
|
amazon.aws.ec2_instance:
|
||||||
wait: yes
|
wait: yes
|
||||||
state: absent
|
state: absent
|
||||||
instance_ids: "{{ ec2.instance_ids }}"
|
instance_ids: '{{ ec2.instance_ids }}'
|
||||||
region: "{{ region }}"
|
region: "{{ region }}"
|
||||||
|
|
||||||
- name: Deleting Security Group
|
- name: Deleting Security Group
|
||||||
|
|
|
||||||
BIN
bin/al2.tar.br
BIN
bin/al2.tar.br
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/fonts.tar.br
BIN
bin/fonts.tar.br
Binary file not shown.
Binary file not shown.
|
|
@ -1 +0,0 @@
|
||||||
.aws-sam
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
# Chromium as a Layer for AWS SAM
|
|
||||||
|
|
||||||
1. Install AWS SAM CLI: https://github.com/aws/aws-sam-cli/
|
|
||||||
|
|
||||||
1. Ensure Docker is installed and running: https://www.docker.com/
|
|
||||||
|
|
||||||
1. Build the project:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sam build
|
|
||||||
```
|
|
||||||
|
|
||||||
1. Invoke the AWS Lambda Function locally with:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sam local invoke ExampleFunction
|
|
||||||
```
|
|
||||||
|
|
||||||
This example connects to https://www.example.com and outputs the page's title as the function result. See the source code in [`app.mjs`](functions/exampleFunction/app.mjs) for more details.
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
import chromium from '@sparticuz/chromium';
|
|
||||||
import puppeteer from 'puppeteer-core';
|
|
||||||
|
|
||||||
export const lambdaHandler = async (event, context) => {
|
|
||||||
const browser = await puppeteer.launch({
|
|
||||||
args: chromium.args,
|
|
||||||
defaultViewport: chromium.defaultViewport,
|
|
||||||
executablePath: await chromium.executablePath(),
|
|
||||||
headless: chromium.headless,
|
|
||||||
});
|
|
||||||
|
|
||||||
const page = await browser.newPage();
|
|
||||||
|
|
||||||
await page.goto("https://www.example.com", { waitUntil: "networkidle0" });
|
|
||||||
|
|
||||||
const browserVersion = await browser.version();
|
|
||||||
const pageTitle = await page.title();
|
|
||||||
|
|
||||||
await page.close();
|
|
||||||
|
|
||||||
await browser.close();
|
|
||||||
|
|
||||||
return { result: 'success', browserVersion, pageTitle };
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"name": "ExampleFunction",
|
|
||||||
"private": true,
|
|
||||||
"version": "0.1.0",
|
|
||||||
"description": "AWS Lambda Function that loads Chromium. Refer to https://github.com/Sparticuz/chromium#install for compatible versions.",
|
|
||||||
"main": "app.mjs",
|
|
||||||
"devDependencies": {
|
|
||||||
"@sparticuz/chromium": "^119.0.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"puppeteer-core": "^21.5.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"name": "ChromiumLayer",
|
|
||||||
"private": true,
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "Chromium layer for AWS Lambda",
|
|
||||||
"dependencies": {
|
|
||||||
"@sparticuz/chromium": "^119.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
AWSTemplateFormatVersion: "2010-09-09"
|
|
||||||
Transform: AWS::Serverless-2016-10-31
|
|
||||||
Description: Example configuration for AWS SAM and Chromium
|
|
||||||
|
|
||||||
Resources:
|
|
||||||
ChromiumLayer:
|
|
||||||
Type: AWS::Serverless::LayerVersion
|
|
||||||
Properties:
|
|
||||||
Description: Chromium with Node.js integration for AWS Lambda
|
|
||||||
ContentUri: layers/chromium
|
|
||||||
CompatibleRuntimes:
|
|
||||||
- &nodejsRuntime nodejs18.x
|
|
||||||
# Chromium doesn't currently have ARM support; see https://github.com/Sparticuz/chromium#can-i-use-arm-or-graviton-instances
|
|
||||||
CompatibleArchitectures:
|
|
||||||
- &chromiumArch x86_64
|
|
||||||
RetentionPolicy: Delete
|
|
||||||
Metadata:
|
|
||||||
BuildMethod: *nodejsRuntime
|
|
||||||
BuildArchitecture: *chromiumArch
|
|
||||||
|
|
||||||
ExampleFunction:
|
|
||||||
Type: AWS::Serverless::Function
|
|
||||||
Properties:
|
|
||||||
CodeUri: functions/exampleFunction
|
|
||||||
Handler: app.lambdaHandler
|
|
||||||
Runtime: *nodejsRuntime
|
|
||||||
Architectures:
|
|
||||||
- *chromiumArch
|
|
||||||
Layers:
|
|
||||||
- !Ref ChromiumLayer
|
|
||||||
# Adjust as necessary
|
|
||||||
Timeout: 30
|
|
||||||
MemorySize: 1024
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
## Upload Lambda layer to AWS
|
|
||||||
|
|
||||||
1. Download the layer zip from Github Releases
|
|
||||||

|
|
||||||
2. Create a S3 bucket, or use a pre-existing bucket, upload the zip, and copy the URL
|
|
||||||

|
|
||||||
3. Create a new layer or use a pre-existing layer. (If using a pre-existing layer, Create a new verion)
|
|
||||||

|
|
||||||
4. Use the S3 file to load into to AWS Lambda Layers
|
|
||||||

|
|
||||||
5. Add the layer to your serverless function
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
service: sls-with-preexisting-layer
|
|
||||||
|
|
||||||
provider:
|
|
||||||
name: aws
|
|
||||||
runtime: nodejs18.x
|
|
||||||
stage: dev
|
|
||||||
region: us-east-1
|
|
||||||
timeout: 300
|
|
||||||
|
|
||||||
functions:
|
|
||||||
chromium-test:
|
|
||||||
handler: index.handler
|
|
||||||
layers:
|
|
||||||
- arn:aws:lambda:us-east-1:************:layer:chromium:*
|
|
||||||
```
|
|
||||||
|
|
||||||
# BONUS
|
|
||||||
|
|
||||||
These steps can easily be automated using the following code:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ chromiumVersion="112.0.0"
|
|
||||||
$ bucketName="chromiumUploadBucket"
|
|
||||||
$ wget "https://github.com/Sparticuz/chromium/releases/download/v${chromiumVersion}/chromium-v${chromiumVersion}-layer.zip"
|
|
||||||
$ aws s3 cp "chromium-v${chromiumVersion}-layer.zip" "s3://${bucketName}/chromiumLayers/chromium-v${chromiumVersion}-layer.zip"
|
|
||||||
$ aws lambda publish-layer-version --layer-name chromium --description "Chromium v${chromiumVersion}" --content "S3Bucket=${bucketName},S3Key=chromiumLayers/chromium-v${chromiumVersion}-layer.zip" --compatible-runtimes nodejs --compatible-architectures x86_64
|
|
||||||
```
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 117 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 58 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 48 KiB |
|
|
@ -1,29 +0,0 @@
|
||||||
const puppeteer = require("puppeteer-core");
|
|
||||||
const chromium = require("@sparticuz/chromium");
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
handler: async () => {
|
|
||||||
try {
|
|
||||||
const browser = await puppeteer.launch({
|
|
||||||
args: chromium.args,
|
|
||||||
defaultViewport: chromium.defaultViewport,
|
|
||||||
executablePath: await chromium.executablePath(),
|
|
||||||
headless: chromium.headless,
|
|
||||||
ignoreHTTPSErrors: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const page = await browser.newPage();
|
|
||||||
|
|
||||||
await page.goto("https://www.example.com", { waitUntil: "networkidle0" });
|
|
||||||
|
|
||||||
console.log("Chromium:", await browser.version());
|
|
||||||
console.log("Page Title:", await page.title());
|
|
||||||
|
|
||||||
await page.close();
|
|
||||||
|
|
||||||
await browser.close();
|
|
||||||
} catch (error) {
|
|
||||||
throw new Error(error.message);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
"name": "serverless-with-lambda-layer",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"description": "This package demonstrates using @sparticuz/chromium as a devDependency with a layer that contains the binaries",
|
|
||||||
"license": "ISC",
|
|
||||||
"author": {
|
|
||||||
"name": "Kyle McNally"
|
|
||||||
},
|
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
|
||||||
"deploy": "sls deploy",
|
|
||||||
"test": "sls invoke --function chromium-test --log"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"puppeteer-core": "19.6.3"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@sparticuz/chromium": "110.0.0",
|
|
||||||
"serverless": "^3.27.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
service: sls-with-layer
|
|
||||||
|
|
||||||
provider:
|
|
||||||
name: aws
|
|
||||||
runtime: nodejs18.x
|
|
||||||
stage: dev
|
|
||||||
region: us-east-1
|
|
||||||
timeout: 300
|
|
||||||
|
|
||||||
functions:
|
|
||||||
chromium-test:
|
|
||||||
handler: index.handler
|
|
||||||
layers:
|
|
||||||
- arn:aws:lambda:us-east-1:************:layer:chromium:*
|
|
||||||
|
|
@ -1,65 +1,54 @@
|
||||||
{
|
{
|
||||||
"name": "@sparticuz/chromium",
|
"name": "@sparticuz/chromium",
|
||||||
"version": "130.0.0",
|
"version": "111.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@sparticuz/chromium",
|
"name": "@sparticuz/chromium",
|
||||||
"version": "130.0.0",
|
"version": "111.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.15.9",
|
"follow-redirects": "^1.15.2",
|
||||||
"tar-fs": "^3.0.6"
|
"tar-fs": "^2.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tsconfig/node20": "^20.1.4",
|
"@tsconfig/node14": "^1.0.3",
|
||||||
"@tsconfig/strictest": "^2.0.5",
|
"@types/follow-redirects": "^1.14.1",
|
||||||
"@types/follow-redirects": "^1.14.4",
|
"@types/node": "^18.11.18",
|
||||||
"@types/node": "^20.16.10",
|
"@types/tar-fs": "^2.0.1",
|
||||||
"@types/tar-fs": "^2.0.4",
|
"clean-modules": "^2.0.6",
|
||||||
"clean-modules": "^3.1.1",
|
"typescript": "^4.9.4"
|
||||||
"typescript": "^5.6.2"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 16"
|
"node": ">= 14.18.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@tsconfig/node20": {
|
"node_modules/@tsconfig/node14": {
|
||||||
"version": "20.1.4",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@tsconfig/node20/-/node20-20.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
|
||||||
"integrity": "sha512-sqgsT69YFeLWf5NtJ4Xq/xAF8p4ZQHlmGW74Nu2tD4+g5fAsposc4ZfaaPixVu4y01BEiDCWLRDCvDM5JOsRxg==",
|
"integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/@tsconfig/strictest": {
|
|
||||||
"version": "2.0.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tsconfig/strictest/-/strictest-2.0.5.tgz",
|
|
||||||
"integrity": "sha512-ec4tjL2Rr0pkZ5hww65c+EEPYwxOi4Ryv+0MtjeaSQRJyq322Q27eOQiFbuNgw2hpL4hB1/W/HBGk3VKS43osg==",
|
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/follow-redirects": {
|
"node_modules/@types/follow-redirects": {
|
||||||
"version": "1.14.4",
|
"version": "1.14.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/follow-redirects/-/follow-redirects-1.14.4.tgz",
|
"resolved": "https://registry.npmjs.org/@types/follow-redirects/-/follow-redirects-1.14.1.tgz",
|
||||||
"integrity": "sha512-GWXfsD0Jc1RWiFmMuMFCpXMzi9L7oPDVwxUnZdg89kDNnqsRfUKXEtUYtA98A6lig1WXH/CYY/fvPW9HuN5fTA==",
|
"integrity": "sha512-THBEFwqsLuU/K62B5JRwab9NW97cFmL4Iy34NTMX0bMycQVzq2q7PKOkhfivIwxdpa/J72RppgC42vCHfwKJ0Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "20.16.10",
|
"version": "18.14.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.10.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.0.tgz",
|
||||||
"integrity": "sha512-vQUKgWTjEIRFCvK6CyriPH3MZYiYlNy0fKiEYHWbcoWLEgs4opurGGKlebrTLqdSMIbXImH6XExNiIyNUv3WpA==",
|
"integrity": "sha512-5EWrvLmglK+imbCJY0+INViFWUHg1AHel1sq4ZVSfdcNqGy9Edv3UB9IIzzg+xPaUcAgZYcfVs2fBcwDeZzU0A==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"undici-types": "~6.19.2"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"node_modules/@types/tar-fs": {
|
"node_modules/@types/tar-fs": {
|
||||||
"version": "2.0.4",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/tar-fs/-/tar-fs-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@types/tar-fs/-/tar-fs-2.0.1.tgz",
|
||||||
"integrity": "sha512-ipPec0CjTmVDWE+QKr9cTmIIoTl7dFG/yARCM5MqK8i6CNLIG1P8x4kwDsOQY1ChZOZjH0wO9nvfgBvWl4R3kA==",
|
"integrity": "sha512-qlsQyIY9sN7p221xHuXKNoMfUenOcvEBN4zI8dGsYbYCqHtTarXOEXSIgUnK+GcR0fZDse6pAIc5pIrCh9NefQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
|
|
@ -75,76 +64,151 @@
|
||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/b4a": {
|
"node_modules/ansi-regex": {
|
||||||
"version": "1.6.4",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.4.tgz",
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||||
"integrity": "sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw=="
|
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||||
},
|
"dev": true,
|
||||||
"node_modules/bare-events": {
|
"engines": {
|
||||||
"version": "2.2.0",
|
"node": ">=8"
|
||||||
"resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.2.0.tgz",
|
|
||||||
"integrity": "sha512-Yyyqff4PIFfSuthCZqLlPISTWHmnQxoPuAvkmgzsJEmG3CesdIv6Xweayl0JkCZJSB2yYIdJyEz97tpxNhgjbg==",
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"node_modules/bare-fs": {
|
|
||||||
"version": "2.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-2.1.5.tgz",
|
|
||||||
"integrity": "sha512-5t0nlecX+N2uJqdxe9d18A98cp2u9BETelbjKpiVgQqzzmVNFYWEAjQHqS+2Khgto1vcwhik9cXucaj5ve2WWA==",
|
|
||||||
"optional": true,
|
|
||||||
"dependencies": {
|
|
||||||
"bare-events": "^2.0.0",
|
|
||||||
"bare-os": "^2.0.0",
|
|
||||||
"bare-path": "^2.0.0",
|
|
||||||
"streamx": "^2.13.0"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/bare-os": {
|
"node_modules/ansi-styles": {
|
||||||
"version": "2.2.0",
|
"version": "4.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/bare-os/-/bare-os-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||||
"integrity": "sha512-hD0rOPfYWOMpVirTACt4/nK8mC55La12K5fY1ij8HAdfQakD62M+H4o4tpfKzVGLgRDTuk3vjA4GqGXXCeFbag==",
|
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||||
"optional": true
|
"dev": true,
|
||||||
},
|
|
||||||
"node_modules/bare-path": {
|
|
||||||
"version": "2.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/bare-path/-/bare-path-2.1.0.tgz",
|
|
||||||
"integrity": "sha512-DIIg7ts8bdRKwJRJrUMy/PICEaQZaPGZ26lsSx9MJSwIhSrcdHn7/C8W+XmnG/rKi6BaRcz+JO00CjZteybDtw==",
|
|
||||||
"optional": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bare-os": "^2.1.0"
|
"color-convert": "^2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/arg": {
|
||||||
|
"version": "5.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz",
|
||||||
|
"integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/base64-js": {
|
||||||
|
"version": "1.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||||
|
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/bl": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==",
|
||||||
|
"dependencies": {
|
||||||
|
"buffer": "^5.5.0",
|
||||||
|
"inherits": "^2.0.4",
|
||||||
|
"readable-stream": "^3.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/buffer": {
|
||||||
|
"version": "5.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
|
||||||
|
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"base64-js": "^1.3.1",
|
||||||
|
"ieee754": "^1.1.13"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/chownr": {
|
||||||
|
"version": "1.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",
|
||||||
|
"integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg=="
|
||||||
|
},
|
||||||
"node_modules/clean-modules": {
|
"node_modules/clean-modules": {
|
||||||
"version": "3.1.1",
|
"version": "2.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/clean-modules/-/clean-modules-3.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/clean-modules/-/clean-modules-2.0.6.tgz",
|
||||||
"integrity": "sha512-t/7dNtn6vQYxujYxdwZeLa0NsLE92KQ0XeV3CDJ2TXgLTvn3ijmjlQN0Dm9wjYQgC0miZiF66ClTQzgIeYw96A==",
|
"integrity": "sha512-e3R40CfLfzS3tlBWO5RcIMZYsIecEERklMln5qb4HvvujyvLLTi2lPEhhCGtH5gJL+4t0lVguiynMHXNkNdoDA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"clipanion": "^3.2.1",
|
"arg": "^5.0.1",
|
||||||
"picomatch": "^2.3.0",
|
"picomatch": "^2.3.0",
|
||||||
"pretty-bytes": "^6.1.0",
|
"pretty-bytes": "^5.6.0",
|
||||||
"pretty-ms": "^8.0.0",
|
"pretty-ms": "^7.0.1",
|
||||||
"supports-color": "^9.4.0"
|
"supports-color": "^8.1.1",
|
||||||
|
"yargs": "^17.1.1"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"clean-modules": "bin/cli.js"
|
"clean-modules": "bin/cli.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14"
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/clipanion": {
|
"node_modules/cliui": {
|
||||||
"version": "3.2.1",
|
"version": "8.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/clipanion/-/clipanion-3.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
|
||||||
"integrity": "sha512-dYFdjLb7y1ajfxQopN05mylEpK9ZX0sO1/RfMXdfmwjlIsPkbh4p7A682x++zFPLDCo1x3p82dtljHf5cW2LKA==",
|
"integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"typanion": "^3.8.0"
|
"string-width": "^4.2.0",
|
||||||
|
"strip-ansi": "^6.0.1",
|
||||||
|
"wrap-ansi": "^7.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"engines": {
|
||||||
"typanion": "*"
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/color-convert": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"color-name": "~1.1.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/color-name": {
|
||||||
|
"version": "1.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||||
|
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/emoji-regex": {
|
||||||
|
"version": "8.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||||
|
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/end-of-stream": {
|
"node_modules/end-of-stream": {
|
||||||
"version": "1.4.4",
|
"version": "1.4.4",
|
||||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
|
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
|
||||||
|
|
@ -153,22 +217,25 @@
|
||||||
"once": "^1.4.0"
|
"once": "^1.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fast-fifo": {
|
"node_modules/escalade": {
|
||||||
"version": "1.3.0",
|
"version": "3.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
|
||||||
"integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw=="
|
"integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/follow-redirects": {
|
"node_modules/follow-redirects": {
|
||||||
"version": "1.15.9",
|
"version": "1.15.2",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
||||||
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
|
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
|
||||||
"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"
|
||||||
},
|
},
|
||||||
|
|
@ -178,6 +245,67 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/fs-constants": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow=="
|
||||||
|
},
|
||||||
|
"node_modules/get-caller-file": {
|
||||||
|
"version": "2.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
||||||
|
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": "6.* || 8.* || >= 10.*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/has-flag": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ieee754": {
|
||||||
|
"version": "1.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
|
||||||
|
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/inherits": {
|
||||||
|
"version": "2.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||||
|
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||||
|
},
|
||||||
|
"node_modules/is-fullwidth-code-point": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mkdirp-classic": {
|
||||||
|
"version": "0.5.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
|
||||||
|
"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A=="
|
||||||
|
},
|
||||||
"node_modules/once": {
|
"node_modules/once": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||||
|
|
@ -187,15 +315,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/parse-ms": {
|
"node_modules/parse-ms": {
|
||||||
"version": "3.0.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz",
|
||||||
"integrity": "sha512-Tpb8Z7r7XbbtBTrM9UhpkzzaMrqA2VXMT3YChzYltwV3P3pM6t8wl7TvpMnSTosz1aQAdVib7kdoys7vYOPerw==",
|
"integrity": "sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=6"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/picomatch": {
|
"node_modules/picomatch": {
|
||||||
|
|
@ -211,27 +336,27 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/pretty-bytes": {
|
"node_modules/pretty-bytes": {
|
||||||
"version": "6.1.1",
|
"version": "5.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-6.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz",
|
||||||
"integrity": "sha512-mQUvGU6aUFQ+rNvTIAcZuWGRT9a6f6Yrg9bHs4ImKF+HZCEK+plBvnAZYSIQztknZF2qnzNtr6F8s0+IuptdlQ==",
|
"integrity": "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^14.13.1 || >=16.0.0"
|
"node": ">=6"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/pretty-ms": {
|
"node_modules/pretty-ms": {
|
||||||
"version": "8.0.0",
|
"version": "7.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-8.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz",
|
||||||
"integrity": "sha512-ASJqOugUF1bbzI35STMBUpZqdfYKlJugy6JBziGi2EE+AL5JPJGSzvpeVXojxrr0ViUYoToUjb5kjSEGf7Y83Q==",
|
"integrity": "sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"parse-ms": "^3.0.0"
|
"parse-ms": "^2.1.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.16"
|
"node": ">=10"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
|
@ -246,86 +371,197 @@
|
||||||
"once": "^1.3.1"
|
"once": "^1.3.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/queue-tick": {
|
"node_modules/readable-stream": {
|
||||||
"version": "1.0.1",
|
"version": "3.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/queue-tick/-/queue-tick-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
|
||||||
"integrity": "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag=="
|
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
|
||||||
},
|
|
||||||
"node_modules/streamx": {
|
|
||||||
"version": "2.15.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/streamx/-/streamx-2.15.1.tgz",
|
|
||||||
"integrity": "sha512-fQMzy2O/Q47rgwErk/eGeLu/roaFWV0jVsogDmrszM9uIw8L5OA+t+V93MgYlufNptfjmYR1tOMWhei/Eh7TQA==",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fast-fifo": "^1.1.0",
|
"inherits": "^2.0.3",
|
||||||
"queue-tick": "^1.0.1"
|
"string_decoder": "^1.1.1",
|
||||||
|
"util-deprecate": "^1.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/require-directory": {
|
||||||
|
"version": "2.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||||
|
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/safe-buffer": {
|
||||||
|
"version": "5.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||||
|
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/string_decoder": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
|
||||||
|
"dependencies": {
|
||||||
|
"safe-buffer": "~5.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/string-width": {
|
||||||
|
"version": "4.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||||
|
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"emoji-regex": "^8.0.0",
|
||||||
|
"is-fullwidth-code-point": "^3.0.0",
|
||||||
|
"strip-ansi": "^6.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/strip-ansi": {
|
||||||
|
"version": "6.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||||
|
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-regex": "^5.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/supports-color": {
|
"node_modules/supports-color": {
|
||||||
"version": "9.4.0",
|
"version": "8.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
|
||||||
"integrity": "sha512-VL+lNrEoIXww1coLPOmiEmK/0sGigko5COxI09KzHc2VJXJsQ37UaQ+8quuxjDeA7+KnLGTWRyOXSLLR2Wb4jw==",
|
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"has-flag": "^4.0.0"
|
||||||
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=10"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/chalk/supports-color?sponsor=1"
|
"url": "https://github.com/chalk/supports-color?sponsor=1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tar-fs": {
|
"node_modules/tar-fs": {
|
||||||
"version": "3.0.6",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz",
|
||||||
"integrity": "sha512-iokBDQQkUyeXhgPYaZxmczGPhnhXZ0CmrqI+MOb/WFGS9DW5wnfrLgtjUJBvz50vQ3qfRwJ62QVoCFu8mPVu5w==",
|
"integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"chownr": "^1.1.1",
|
||||||
|
"mkdirp-classic": "^0.5.2",
|
||||||
"pump": "^3.0.0",
|
"pump": "^3.0.0",
|
||||||
"tar-stream": "^3.1.5"
|
"tar-stream": "^2.1.4"
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"bare-fs": "^2.1.1",
|
|
||||||
"bare-path": "^2.1.0"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tar-stream": {
|
"node_modules/tar-stream": {
|
||||||
"version": "3.1.6",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz",
|
||||||
"integrity": "sha512-B/UyjYwPpMBv+PaFSWAmtYjwdrlEaZQEhMIBFNC5oEG8lpiW8XjcSdmEaClj28ArfKScKHs2nshz3k2le6crsg==",
|
"integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"b4a": "^1.6.4",
|
"bl": "^4.0.3",
|
||||||
"fast-fifo": "^1.2.0",
|
"end-of-stream": "^1.4.1",
|
||||||
"streamx": "^2.15.0"
|
"fs-constants": "^1.0.0",
|
||||||
|
"inherits": "^2.0.3",
|
||||||
|
"readable-stream": "^3.1.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/typanion": {
|
|
||||||
"version": "3.14.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/typanion/-/typanion-3.14.0.tgz",
|
|
||||||
"integrity": "sha512-ZW/lVMRabETuYCd9O9ZvMhAh8GslSqaUjxmK/JLPCh6l73CvLBiuXswj/+7LdnWOgYsQ130FqLzFz5aGT4I3Ug==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "5.6.2",
|
"version": "4.9.5",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
||||||
"integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==",
|
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
"tsserver": "bin/tsserver"
|
"tsserver": "bin/tsserver"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.17"
|
"node": ">=4.2.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici-types": {
|
"node_modules/util-deprecate": {
|
||||||
"version": "6.19.6",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.6.tgz",
|
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||||
"integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==",
|
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
|
||||||
|
},
|
||||||
|
"node_modules/wrap-ansi": {
|
||||||
|
"version": "7.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
||||||
|
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"dependencies": {
|
||||||
|
"ansi-styles": "^4.0.0",
|
||||||
|
"string-width": "^4.1.0",
|
||||||
|
"strip-ansi": "^6.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/wrappy": {
|
"node_modules/wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="
|
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="
|
||||||
|
},
|
||||||
|
"node_modules/y18n": {
|
||||||
|
"version": "5.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
||||||
|
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/yargs": {
|
||||||
|
"version": "17.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.2.tgz",
|
||||||
|
"integrity": "sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"cliui": "^8.0.1",
|
||||||
|
"escalade": "^3.1.1",
|
||||||
|
"get-caller-file": "^2.0.5",
|
||||||
|
"require-directory": "^2.1.1",
|
||||||
|
"string-width": "^4.2.3",
|
||||||
|
"y18n": "^5.0.5",
|
||||||
|
"yargs-parser": "^21.1.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/yargs-parser": {
|
||||||
|
"version": "21.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
|
||||||
|
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
21
package.json
21
package.json
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sparticuz/chromium",
|
"name": "@sparticuz/chromium",
|
||||||
"version": "130.0.0",
|
"version": "111.0.0",
|
||||||
"description": "Chromium Binary for Serverless Platforms",
|
"description": "Chromium Binary for Serverless Platforms",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"aws",
|
"aws",
|
||||||
|
|
@ -36,19 +36,18 @@
|
||||||
"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.2",
|
||||||
"tar-fs": "^3.0.6"
|
"tar-fs": "^2.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tsconfig/node20": "^20.1.4",
|
"@tsconfig/node14": "^1.0.3",
|
||||||
"@tsconfig/strictest": "^2.0.5",
|
"@types/follow-redirects": "^1.14.1",
|
||||||
"@types/follow-redirects": "^1.14.4",
|
"@types/node": "^18.11.18",
|
||||||
"@types/node": "^20.16.10",
|
"@types/tar-fs": "^2.0.1",
|
||||||
"@types/tar-fs": "^2.0.4",
|
"clean-modules": "^2.0.6",
|
||||||
"clean-modules": "^3.1.1",
|
"typescript": "^4.9.4"
|
||||||
"typescript": "^5.6.2"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 16"
|
"node": ">= 14.18.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,67 +10,27 @@ interface FollowRedirOptions extends UrlWithStringQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isValidUrl = (input: string) => {
|
export const isValidUrl = (input: string) => {
|
||||||
try {
|
try {
|
||||||
return !!new URL(input);
|
return !!new URL(input);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines if the running instance is inside an AWS Lambda container.
|
|
||||||
* AWS_EXECUTION_ENV is for native Lambda instances
|
|
||||||
* AWS_LAMBDA_JS_RUNTIME is for netlify instances
|
|
||||||
* @returns boolean indicating if the running instance is inside a Lambda container
|
|
||||||
*/
|
|
||||||
export const isRunningInAwsLambda = () => {
|
|
||||||
if (
|
|
||||||
process.env["AWS_EXECUTION_ENV"] &&
|
|
||||||
process.env["AWS_EXECUTION_ENV"].includes("AWS_Lambda_nodejs") &&
|
|
||||||
!process.env["AWS_EXECUTION_ENV"].includes("20.x")
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
} else if (
|
|
||||||
process.env["AWS_LAMBDA_JS_RUNTIME"] &&
|
|
||||||
process.env["AWS_LAMBDA_JS_RUNTIME"].includes("nodejs") &&
|
|
||||||
!process.env["AWS_LAMBDA_JS_RUNTIME"].includes("20.x")
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const isRunningInAwsLambdaNode20 = () => {
|
|
||||||
if (
|
|
||||||
process.env["AWS_EXECUTION_ENV"] &&
|
|
||||||
process.env["AWS_EXECUTION_ENV"].includes("20.x")
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
} else if (
|
|
||||||
process.env["AWS_LAMBDA_JS_RUNTIME"] &&
|
|
||||||
process.env["AWS_LAMBDA_JS_RUNTIME"].includes("20.x")
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const downloadAndExtract = async (url: string) =>
|
export const downloadAndExtract = async (url: string) =>
|
||||||
new Promise<string>((resolve, reject) => {
|
new Promise<string>((resolve, reject) => {
|
||||||
const getOptions = parse(url) as FollowRedirOptions;
|
const getOptions = parse(url) as FollowRedirOptions;
|
||||||
getOptions.maxBodyLength = 60 * 1024 * 1024; // 60mb
|
getOptions.maxBodyLength = 60 * 1024 * 1024; // 60mb
|
||||||
const destDir = `${tmpdir()}/chromium-pack`;
|
const destDir = `${tmpdir()}/chromium-pack`
|
||||||
const extractObj = extract(destDir);
|
const extractObj = extract(destDir)
|
||||||
https
|
https.get(url, (response) => {
|
||||||
.get(url, (response) => {
|
response.pipe(extractObj);
|
||||||
response.pipe(extractObj);
|
extractObj.on('finish', () => {
|
||||||
extractObj.on("finish", () => {
|
resolve(destDir);
|
||||||
resolve(destDir);
|
});
|
||||||
|
}).on('error', (err) => {
|
||||||
|
unlink(destDir, (_) => {
|
||||||
|
reject(err)
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.on("error", (err) => {
|
|
||||||
unlink(destDir, (_) => {
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
|
||||||
358
source/index.ts
358
source/index.ts
|
|
@ -1,20 +1,9 @@
|
||||||
import {
|
import { access, createWriteStream, existsSync, mkdirSync, symlink } from 'node:fs';
|
||||||
access,
|
import { IncomingMessage } from 'node:http';
|
||||||
createWriteStream,
|
import LambdaFS from './lambdafs';
|
||||||
existsSync,
|
import { join } from 'node:path';
|
||||||
mkdirSync,
|
import { URL } from 'node:url';
|
||||||
symlink,
|
import { downloadAndExtract, isValidUrl } from './helper';
|
||||||
} from "node:fs";
|
|
||||||
import { https } from "follow-redirects";
|
|
||||||
import LambdaFS from "./lambdafs";
|
|
||||||
import { join } from "node:path";
|
|
||||||
import { URL } from "node:url";
|
|
||||||
import {
|
|
||||||
downloadAndExtract,
|
|
||||||
isRunningInAwsLambda,
|
|
||||||
isValidUrl,
|
|
||||||
isRunningInAwsLambdaNode20,
|
|
||||||
} from "./helper";
|
|
||||||
|
|
||||||
/** Viewport taken from https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.viewport.md */
|
/** Viewport taken from https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.viewport.md */
|
||||||
interface Viewport {
|
interface Viewport {
|
||||||
|
|
@ -29,89 +18,56 @@ interface Viewport {
|
||||||
/**
|
/**
|
||||||
* Specify device scale factor.
|
* Specify device scale factor.
|
||||||
* See {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio | devicePixelRatio} for more info.
|
* See {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio | devicePixelRatio} for more info.
|
||||||
* @default 1
|
* @defaultValue 1
|
||||||
*/
|
*/
|
||||||
deviceScaleFactor?: number;
|
deviceScaleFactor?: number;
|
||||||
/**
|
/**
|
||||||
* Whether the `meta viewport` tag is taken into account.
|
* Whether the `meta viewport` tag is taken into account.
|
||||||
* @default false
|
* @defaultValue false
|
||||||
*/
|
*/
|
||||||
isMobile?: boolean;
|
isMobile?: boolean;
|
||||||
/**
|
/**
|
||||||
* Specifies if the viewport is in landscape mode.
|
* Specifies if the viewport is in landscape mode.
|
||||||
* @default false
|
* @defaultValue false
|
||||||
*/
|
*/
|
||||||
isLandscape?: boolean;
|
isLandscape?: boolean;
|
||||||
/**
|
/**
|
||||||
* Specify if the viewport supports touch events.
|
* Specify if the viewport supports touch events.
|
||||||
* @default false
|
* @defaultValue false
|
||||||
*/
|
*/
|
||||||
hasTouch?: boolean;
|
hasTouch?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRunningInAwsLambda()) {
|
if ( process.env.AWS_EXECUTION_ENV !== undefined && /^AWS_Lambda_nodejs(?:14|16|18)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
|
||||||
if (process.env["FONTCONFIG_PATH"] === undefined) {
|
if (process.env.FONTCONFIG_PATH === undefined) {
|
||||||
process.env["FONTCONFIG_PATH"] = "/tmp/fonts";
|
process.env.FONTCONFIG_PATH = '/tmp/aws';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env["LD_LIBRARY_PATH"] === undefined) {
|
if (process.env.LD_LIBRARY_PATH === undefined) {
|
||||||
process.env["LD_LIBRARY_PATH"] = "/tmp/al2/lib";
|
process.env.LD_LIBRARY_PATH = '/tmp/aws/lib';
|
||||||
} else if (
|
} else if (process.env.LD_LIBRARY_PATH.startsWith('/tmp/aws/lib') !== true) {
|
||||||
process.env["LD_LIBRARY_PATH"].startsWith("/tmp/al2/lib") !== true
|
process.env.LD_LIBRARY_PATH = [...new Set(['/tmp/aws/lib', ...process.env.LD_LIBRARY_PATH.split(':')])].join(':');
|
||||||
) {
|
|
||||||
process.env["LD_LIBRARY_PATH"] = [
|
|
||||||
...new Set([
|
|
||||||
"/tmp/al2/lib",
|
|
||||||
...process.env["LD_LIBRARY_PATH"].split(":"),
|
|
||||||
]),
|
|
||||||
].join(":");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRunningInAwsLambdaNode20()) {
|
|
||||||
if (process.env["FONTCONFIG_PATH"] === undefined) {
|
|
||||||
process.env["FONTCONFIG_PATH"] = "/tmp/fonts";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.env["LD_LIBRARY_PATH"] === undefined) {
|
|
||||||
process.env["LD_LIBRARY_PATH"] = "/tmp/al2023/lib";
|
|
||||||
} else if (
|
|
||||||
process.env["LD_LIBRARY_PATH"].startsWith("/tmp/al2023/lib") !== true
|
|
||||||
) {
|
|
||||||
process.env["LD_LIBRARY_PATH"] = [
|
|
||||||
...new Set([
|
|
||||||
"/tmp/al2023/lib",
|
|
||||||
...process.env["LD_LIBRARY_PATH"].split(":"),
|
|
||||||
]),
|
|
||||||
].join(":");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Chromium {
|
class Chromium {
|
||||||
/**
|
|
||||||
* Determines the headless mode that chromium will run at
|
|
||||||
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
|
|
||||||
* @values true or "new"
|
|
||||||
*/
|
|
||||||
private static headlessMode: true | "shell" = "shell";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If true, the graphics stack and webgl is enabled,
|
|
||||||
* If false, webgl will be disabled.
|
|
||||||
* (If false, the swiftshader.tar.br file will also not extract)
|
|
||||||
*/
|
|
||||||
private static graphicsMode: boolean = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads or symlinks a custom font and returns its basename, patching the environment so that Chromium can find it.
|
* Downloads or symlinks a custom font and returns its basename, patching the environment so that Chromium can find it.
|
||||||
|
* If headless is not true, `null` is returned instead.
|
||||||
*/
|
*/
|
||||||
static font(input: string): Promise<string> {
|
static font(input: string): Promise<string | null> {
|
||||||
if (process.env["HOME"] === undefined) {
|
if (Chromium.headless !== true) {
|
||||||
process.env["HOME"] = "/tmp";
|
return new Promise((resolve) => {
|
||||||
|
return resolve(null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existsSync(`${process.env["HOME"]}/.fonts`) !== true) {
|
if (process.env.HOME === undefined) {
|
||||||
mkdirSync(`${process.env["HOME"]}/.fonts`);
|
process.env.HOME = '/tmp';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existsSync(`${process.env.HOME}/.fonts`) !== true) {
|
||||||
|
mkdirSync(`${process.env.HOME}/.fonts`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
@ -120,45 +76,43 @@ class Chromium {
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = new URL(input);
|
const url = new URL(input);
|
||||||
const output = `${process.env["HOME"]}/.fonts/${url.pathname
|
const output = `${process.env.HOME}/.fonts/${url.pathname.split('/').pop()}`;
|
||||||
.split("/")
|
|
||||||
.pop()}`;
|
|
||||||
|
|
||||||
if (existsSync(output) === true) {
|
if (existsSync(output) === true) {
|
||||||
return resolve(output.split("/").pop() as string);
|
return resolve(output.split('/').pop() as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url.protocol === "file:") {
|
if (url.protocol === 'file:') {
|
||||||
access(url.pathname, (error) => {
|
access(url.pathname, (error) => {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return reject(error);
|
return reject(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
symlink(url.pathname, output, (error) => {
|
symlink(url.pathname, output, (error) => {
|
||||||
return error != null
|
return error != null ? reject(error) : resolve(url.pathname.split('/').pop() as string);
|
||||||
? reject(error)
|
|
||||||
: resolve(url.pathname.split("/").pop() as string);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
https.get(input, (response) => {
|
let handler = url.protocol === 'http:' ? require('http').get : require('https').get;
|
||||||
|
|
||||||
|
handler(input, (response: IncomingMessage) => {
|
||||||
if (response.statusCode !== 200) {
|
if (response.statusCode !== 200) {
|
||||||
return reject(`Unexpected status code: ${response.statusCode}.`);
|
return reject(`Unexpected status code: ${response.statusCode}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const stream = createWriteStream(output);
|
const stream = createWriteStream(output);
|
||||||
|
|
||||||
stream.once("error", (error) => {
|
stream.once('error', (error) => {
|
||||||
return reject(error);
|
return reject(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
response.on("data", (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
stream.write(chunk);
|
stream.write(chunk);
|
||||||
});
|
});
|
||||||
|
|
||||||
response.once("end", () => {
|
response.once('end', () => {
|
||||||
stream.end(() => {
|
stream.end(() => {
|
||||||
return resolve(url.pathname.split("/").pop() as string);
|
return resolve(url.pathname.split('/').pop() as string);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -171,113 +125,47 @@ class Chromium {
|
||||||
* The canonical list of flags can be found on https://peter.sh/experiments/chromium-command-line-switches/.
|
* The canonical list of flags can be found on https://peter.sh/experiments/chromium-command-line-switches/.
|
||||||
*/
|
*/
|
||||||
static get args(): string[] {
|
static get args(): string[] {
|
||||||
/**
|
const result = [
|
||||||
* These are the default args in puppeteer.
|
'--allow-running-insecure-content', // https://source.chromium.org/search?q=lang:cpp+symbol:kAllowRunningInsecureContent&ss=chromium
|
||||||
* https://github.com/puppeteer/puppeteer/blob/3a31070d054fa3cd8116ca31c578807ed8d6f987/packages/puppeteer-core/src/node/ChromeLauncher.ts#L185
|
'--autoplay-policy=user-gesture-required', // https://source.chromium.org/search?q=lang:cpp+symbol:kAutoplayPolicy&ss=chromium
|
||||||
*/
|
'--disable-background-timer-throttling',
|
||||||
const puppeteerFlags = [
|
'--disable-component-update', // https://source.chromium.org/search?q=lang:cpp+symbol:kDisableComponentUpdate&ss=chromium
|
||||||
"--allow-pre-commit-input",
|
'--disable-domain-reliability', // https://source.chromium.org/search?q=lang:cpp+symbol:kDisableDomainReliability&ss=chromium
|
||||||
"--disable-background-networking",
|
'--disable-features=AudioServiceOutOfProcess,IsolateOrigins,site-per-process', // https://source.chromium.org/search?q=file:content_features.cc&ss=chromium
|
||||||
"--disable-background-timer-throttling",
|
'--disable-ipc-flooding-protection',
|
||||||
"--disable-backgrounding-occluded-windows",
|
'--disable-print-preview', // https://source.chromium.org/search?q=lang:cpp+symbol:kDisablePrintPreview&ss=chromium
|
||||||
"--disable-breakpad",
|
'--disable-dev-shm-usage',
|
||||||
"--disable-client-side-phishing-detection",
|
'--disable-setuid-sandbox', // https://source.chromium.org/search?q=lang:cpp+symbol:kDisableSetuidSandbox&ss=chromium
|
||||||
"--disable-component-extensions-with-background-pages",
|
'--disable-site-isolation-trials', // https://source.chromium.org/search?q=lang:cpp+symbol:kDisableSiteIsolation&ss=chromium
|
||||||
"--disable-component-update",
|
'--disable-speech-api', // https://source.chromium.org/search?q=lang:cpp+symbol:kDisableSpeechAPI&ss=chromium
|
||||||
"--disable-default-apps",
|
'--disable-web-security', // https://source.chromium.org/search?q=lang:cpp+symbol:kDisableWebSecurity&ss=chromium
|
||||||
"--disable-dev-shm-usage",
|
'--disk-cache-size=33554432', // https://source.chromium.org/search?q=lang:cpp+symbol:kDiskCacheSize&ss=chromium
|
||||||
"--disable-extensions",
|
'--enable-features=SharedArrayBuffer', // https://source.chromium.org/search?q=file:content_features.cc&ss=chromium
|
||||||
"--disable-hang-monitor",
|
'--hide-scrollbars', // https://source.chromium.org/search?q=lang:cpp+symbol:kHideScrollbars&ss=chromium
|
||||||
"--disable-ipc-flooding-protection",
|
'--ignore-gpu-blocklist', // https://source.chromium.org/search?q=lang:cpp+symbol:kIgnoreGpuBlocklist&ss=chromium
|
||||||
"--disable-popup-blocking",
|
'--in-process-gpu', // https://source.chromium.org/search?q=lang:cpp+symbol:kInProcessGPU&ss=chromium
|
||||||
"--disable-prompt-on-repost",
|
'--mute-audio', // https://source.chromium.org/search?q=lang:cpp+symbol:kMuteAudio&ss=chromium
|
||||||
"--disable-renderer-backgrounding",
|
'--no-default-browser-check', // https://source.chromium.org/search?q=lang:cpp+symbol:kNoDefaultBrowserCheck&ss=chromium
|
||||||
"--disable-sync",
|
'--no-first-run',
|
||||||
"--enable-automation",
|
'--no-pings', // https://source.chromium.org/search?q=lang:cpp+symbol:kNoPings&ss=chromium
|
||||||
// TODO(sadym): remove '--enable-blink-features=IdleDetection' once
|
'--no-sandbox', // https://source.chromium.org/search?q=lang:cpp+symbol:kNoSandbox&ss=chromium
|
||||||
// IdleDetection is turned on by default.
|
'--no-zygote', // https://source.chromium.org/search?q=lang:cpp+symbol:kNoZygote&ss=chromium
|
||||||
"--enable-blink-features=IdleDetection",
|
'--use-gl=angle', // https://chromium.googlesource.com/chromium/src/+/main/docs/gpu/swiftshader.md
|
||||||
"--export-tagged-pdf",
|
'--use-angle=swiftshader', // https://chromium.googlesource.com/chromium/src/+/main/docs/gpu/swiftshader.md
|
||||||
"--force-color-profile=srgb",
|
'--window-size=1920,1080', // https://source.chromium.org/search?q=lang:cpp+symbol:kWindowSize&ss=chromium
|
||||||
"--metrics-recording-only",
|
|
||||||
"--no-first-run",
|
|
||||||
"--password-store=basic",
|
|
||||||
"--use-mock-keychain",
|
|
||||||
];
|
|
||||||
const puppeteerDisableFeatures = [
|
|
||||||
"Translate",
|
|
||||||
"BackForwardCache",
|
|
||||||
// AcceptCHFrame disabled because of crbug.com/1348106.
|
|
||||||
"AcceptCHFrame",
|
|
||||||
"MediaRouter",
|
|
||||||
"OptimizationHints",
|
|
||||||
];
|
|
||||||
const puppeteerEnableFeatures = ["NetworkServiceInProcess2"];
|
|
||||||
|
|
||||||
const chromiumFlags = [
|
|
||||||
"--disable-domain-reliability", // https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md#background-networking
|
|
||||||
"--disable-print-preview", // https://source.chromium.org/search?q=lang:cpp+symbol:kDisablePrintPreview&ss=chromium
|
|
||||||
"--disable-speech-api", // https://source.chromium.org/search?q=lang:cpp+symbol:kDisableSpeechAPI&ss=chromium
|
|
||||||
"--disk-cache-size=33554432", // https://source.chromium.org/search?q=lang:cpp+symbol:kDiskCacheSize&ss=chromium
|
|
||||||
"--mute-audio", // https://source.chromium.org/search?q=lang:cpp+symbol:kMuteAudio&ss=chromium
|
|
||||||
"--no-default-browser-check", // https://source.chromium.org/search?q=lang:cpp+symbol:kNoDefaultBrowserCheck&ss=chromium
|
|
||||||
"--no-pings", // https://source.chromium.org/search?q=lang:cpp+symbol:kNoPings&ss=chromium
|
|
||||||
"--single-process", // Needs to be single-process to avoid `prctl(PR_SET_NO_NEW_PRIVS) failed` error
|
|
||||||
"--font-render-hinting=none", // https://github.com/puppeteer/puppeteer/issues/2410#issuecomment-560573612
|
|
||||||
];
|
|
||||||
const chromiumDisableFeatures = [
|
|
||||||
"AudioServiceOutOfProcess",
|
|
||||||
"IsolateOrigins",
|
|
||||||
"site-per-process",
|
|
||||||
];
|
|
||||||
const chromiumEnableFeatures = ["SharedArrayBuffer"];
|
|
||||||
|
|
||||||
const graphicsFlags = [
|
|
||||||
"--hide-scrollbars", // https://source.chromium.org/search?q=lang:cpp+symbol:kHideScrollbars&ss=chromium
|
|
||||||
"--ignore-gpu-blocklist", // https://source.chromium.org/search?q=lang:cpp+symbol:kIgnoreGpuBlocklist&ss=chromium
|
|
||||||
"--in-process-gpu", // https://source.chromium.org/search?q=lang:cpp+symbol:kInProcessGPU&ss=chromium
|
|
||||||
"--window-size=1920,1080", // https://source.chromium.org/search?q=lang:cpp+symbol:kWindowSize&ss=chromium
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// https://chromium.googlesource.com/chromium/src/+/main/docs/gpu/swiftshader.md
|
if (Chromium.headless === true) {
|
||||||
// Blocked by https://github.com/Sparticuz/chromium/issues/247
|
result.push('--single-process'); // https://source.chromium.org/search?q=lang:cpp+symbol:kSingleProcess&ss=chromium
|
||||||
//this.graphics
|
} else {
|
||||||
// ? graphicsFlags.push("--use-gl=angle", "--use-angle=swiftshader")
|
result.push('--start-maximized'); // https://source.chromium.org/search?q=lang:cpp+symbol:kStartMaximized&ss=chromium
|
||||||
// : graphicsFlags.push("--disable-webgl");
|
}
|
||||||
graphicsFlags.push("--use-gl=angle", "--use-angle=swiftshader");
|
|
||||||
|
|
||||||
const insecureFlags = [
|
return result;
|
||||||
"--allow-running-insecure-content", // https://source.chromium.org/search?q=lang:cpp+symbol:kAllowRunningInsecureContent&ss=chromium
|
|
||||||
"--disable-setuid-sandbox", // https://source.chromium.org/search?q=lang:cpp+symbol:kDisableSetuidSandbox&ss=chromium
|
|
||||||
"--disable-site-isolation-trials", // https://source.chromium.org/search?q=lang:cpp+symbol:kDisableSiteIsolation&ss=chromium
|
|
||||||
"--disable-web-security", // https://source.chromium.org/search?q=lang:cpp+symbol:kDisableWebSecurity&ss=chromium
|
|
||||||
"--no-sandbox", // https://source.chromium.org/search?q=lang:cpp+symbol:kNoSandbox&ss=chromium
|
|
||||||
"--no-zygote", // https://source.chromium.org/search?q=lang:cpp+symbol:kNoZygote&ss=chromium
|
|
||||||
];
|
|
||||||
|
|
||||||
const headlessFlags = [
|
|
||||||
this.headless === "shell" ? "--headless='shell'" : "--headless",
|
|
||||||
];
|
|
||||||
|
|
||||||
return [
|
|
||||||
...puppeteerFlags,
|
|
||||||
...chromiumFlags,
|
|
||||||
`--disable-features=${[
|
|
||||||
...puppeteerDisableFeatures,
|
|
||||||
...chromiumDisableFeatures,
|
|
||||||
].join(",")}`,
|
|
||||||
`--enable-features=${[
|
|
||||||
...puppeteerEnableFeatures,
|
|
||||||
...chromiumEnableFeatures,
|
|
||||||
].join(",")}`,
|
|
||||||
...graphicsFlags,
|
|
||||||
...insecureFlags,
|
|
||||||
...headlessFlags,
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns sensible default viewport settings for serverless environments.
|
* Returns sensible default viewport settings.
|
||||||
*/
|
*/
|
||||||
static get defaultViewport(): Required<Viewport> {
|
static get defaultViewport(): Required<Viewport> {
|
||||||
return {
|
return {
|
||||||
|
|
@ -299,25 +187,19 @@ class Chromium {
|
||||||
/**
|
/**
|
||||||
* If the `chromium` binary already exists in /tmp/chromium, return it.
|
* If the `chromium` binary already exists in /tmp/chromium, return it.
|
||||||
*/
|
*/
|
||||||
if (existsSync("/tmp/chromium") === true) {
|
if (existsSync('/tmp/chromium') === true) {
|
||||||
return Promise.resolve("/tmp/chromium");
|
return Promise.resolve('/tmp/chromium');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* If input is a valid URL, download and extract the file. It will extract to /tmp/chromium-pack
|
|
||||||
* and executablePath will be recursively called on that location, which will then extract
|
|
||||||
* the brotli files to the correct locations
|
|
||||||
*/
|
|
||||||
if (input && isValidUrl(input)) {
|
if (input && isValidUrl(input)) {
|
||||||
return this.executablePath(await downloadAndExtract(input));
|
return this.executablePath(await downloadAndExtract(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If input is defined, use that as the location of the brotli files,
|
* If input is defined, use that as the location of the brotli files,
|
||||||
* otherwise, the default location is ../bin.
|
* otherwise, the default location is ../bin.
|
||||||
* A custom location is needed for workflows that using custom packaging.
|
* A custom location is needed for workflows that using custom packaging.
|
||||||
*/
|
*/
|
||||||
input ??= join(__dirname, "..", "bin");
|
input ??= join(__dirname, '..', 'bin');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the input directory doesn't exist, throw an error.
|
* If the input directory doesn't exist, throw an error.
|
||||||
|
|
@ -326,85 +208,39 @@ class Chromium {
|
||||||
throw new Error(`The input directory "${input}" does not exist.`);
|
throw new Error(`The input directory "${input}" does not exist.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the required files
|
|
||||||
const promises = [
|
const promises = [
|
||||||
LambdaFS.inflate(`${input}/chromium.br`),
|
LambdaFS.inflate(`${input}/chromium.br`),
|
||||||
LambdaFS.inflate(`${input}/fonts.tar.br`),
|
LambdaFS.inflate(`${input}/swiftshader.tar.br`),
|
||||||
];
|
];
|
||||||
if (this.graphics) {
|
|
||||||
// Only inflate graphics stack if needed
|
if (process.env.AWS_EXECUTION_ENV !== undefined && /^AWS_Lambda_nodejs(?:14|16|18)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
|
||||||
promises.push(LambdaFS.inflate(`${input}/swiftshader.tar.br`));
|
promises.push(LambdaFS.inflate(`${input}/aws.tar.br`));
|
||||||
}
|
|
||||||
if (isRunningInAwsLambda()) {
|
|
||||||
// If running in AWS Lambda, extract more required files
|
|
||||||
promises.push(LambdaFS.inflate(`${input}/al2.tar.br`));
|
|
||||||
}
|
|
||||||
if (isRunningInAwsLambdaNode20()) {
|
|
||||||
promises.push(LambdaFS.inflate(`${input}/al2023.tar.br`));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Await all extractions
|
|
||||||
const result = await Promise.all(promises);
|
const result = await Promise.all(promises);
|
||||||
// Returns the first result of the promise, which is the location of the `chromium` binary
|
|
||||||
return result.shift() as string;
|
return result.shift() as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the headless mode.
|
* Returns a boolean indicating if we are running on AWS Lambda or Google Cloud Functions.
|
||||||
* "shell" means the 'old' (legacy, chromium < 112) headless mode.
|
* True is returned if the NODE_ENV is set to 'test' for easier integration testing.
|
||||||
* `true` means the 'new' headless mode.
|
* False is returned if Serverless environment variables `IS_LOCAL` or `IS_OFFLINE` are set.
|
||||||
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
|
|
||||||
* @returns true | "shell"
|
|
||||||
*/
|
*/
|
||||||
public static get headless() {
|
static get headless() {
|
||||||
return this.headlessMode;
|
if (process.env.IS_LOCAL !== undefined || process.env.IS_OFFLINE !== undefined) {
|
||||||
}
|
return false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the headless mode.
|
|
||||||
* "shell" means the 'old' (legacy, chromium < 112) headless mode.
|
|
||||||
* `true` means the 'new' headless mode.
|
|
||||||
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
|
|
||||||
* @default "shell"
|
|
||||||
*/
|
|
||||||
public static set setHeadlessMode(value: true | "shell") {
|
|
||||||
if (
|
|
||||||
(typeof value === "string" && value !== "shell") ||
|
|
||||||
(typeof value === "boolean" && value !== true)
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Headless mode must be either \`true\` or 'shell', you entered '${value}'`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
this.headlessMode = value;
|
if (process.env.NODE_ENV === "test") {
|
||||||
}
|
return true;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the graphics stack is enabled or disabled
|
|
||||||
* @returns boolean
|
|
||||||
*/
|
|
||||||
public static get graphics() {
|
|
||||||
return this.graphicsMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets whether the graphics stack is enabled or disabled.
|
|
||||||
* @param true means the stack is enabled. WebGL will work.
|
|
||||||
* @param false means that the stack is disabled. WebGL will not work.
|
|
||||||
* `false` will also skip the extract of the graphics driver, saving about a second during initial extract
|
|
||||||
* @default true
|
|
||||||
*/
|
|
||||||
public static set setGraphicsMode(value: boolean) {
|
|
||||||
if (typeof value !== "boolean") {
|
|
||||||
throw new Error(
|
|
||||||
`Graphics mode must be a boolean, you entered '${value}'`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
const environments = [
|
||||||
|
'AWS_LAMBDA_FUNCTION_NAME',
|
||||||
|
'FUNCTION_NAME',
|
||||||
|
'FUNCTION_TARGET',
|
||||||
|
'FUNCTIONS_EMULATOR',
|
||||||
|
];
|
||||||
|
|
||||||
// Disabling 'disabling the gpu'
|
return environments.some((key) => process.env[key] !== undefined);
|
||||||
// Blocked by https://github.com/Sparticuz/chromium/issues/247
|
|
||||||
// this.graphicsMode = value;
|
|
||||||
this.graphicsMode = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { createReadStream, createWriteStream, existsSync } from "node:fs";
|
import { createReadStream, createWriteStream, existsSync } from 'node:fs';
|
||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from 'node:os';
|
||||||
import { basename, join } from "node:path";
|
import { basename, join } from 'node:path';
|
||||||
import { extract } from "tar-fs";
|
import { extract } from 'tar-fs';
|
||||||
import { createBrotliDecompress, createUnzip } from "node:zlib";
|
import { createBrotliDecompress, createUnzip } from 'node:zlib';
|
||||||
|
|
||||||
class LambdaFS {
|
class LambdaFS {
|
||||||
/**
|
/**
|
||||||
|
|
@ -11,15 +11,7 @@ class LambdaFS {
|
||||||
* @param filePath Path of the file to decompress.
|
* @param filePath Path of the file to decompress.
|
||||||
*/
|
*/
|
||||||
static inflate(filePath: string): Promise<string> {
|
static inflate(filePath: string): Promise<string> {
|
||||||
const output = filePath.includes("swiftshader")
|
const output = filePath.includes("swiftshader") ? tmpdir() : join(tmpdir(), basename(filePath).replace(/[.](?:t(?:ar(?:[.](?:br|gz))?|br|gz)|br|gz)$/i, ''));
|
||||||
? tmpdir()
|
|
||||||
: join(
|
|
||||||
tmpdir(),
|
|
||||||
basename(filePath).replace(
|
|
||||||
/[.](?:t(?:ar(?:[.](?:br|gz))?|br|gz)|br|gz)$/i,
|
|
||||||
""
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (filePath.includes("swiftshader")) {
|
if (filePath.includes("swiftshader")) {
|
||||||
|
|
@ -38,33 +30,27 @@ class LambdaFS {
|
||||||
if (/[.](?:t(?:ar(?:[.](?:br|gz))?|br|gz))$/i.test(filePath) === true) {
|
if (/[.](?:t(?:ar(?:[.](?:br|gz))?|br|gz))$/i.test(filePath) === true) {
|
||||||
target = extract(output);
|
target = extract(output);
|
||||||
|
|
||||||
target.once("finish", () => {
|
target.once('finish', () => {
|
||||||
return resolve(output);
|
return resolve(output);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
target = createWriteStream(output, { mode: 0o700 });
|
target = createWriteStream(output, { mode: 0o700 });
|
||||||
}
|
}
|
||||||
|
|
||||||
source.once("error", (error: Error) => {
|
source.once('error', (error: Error) => {
|
||||||
return reject(error);
|
return reject(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
target.once("error", (error: Error) => {
|
target.once('error', (error: Error) => {
|
||||||
return reject(error);
|
return reject(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
target.once("close", () => {
|
target.once('close', () => {
|
||||||
return resolve(output);
|
return resolve(output);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (/(?:br|gz)$/i.test(filePath) === true) {
|
if (/(?:br|gz)$/i.test(filePath) === true) {
|
||||||
source
|
source.pipe(/br$/i.test(filePath) ? createBrotliDecompress({ chunkSize: 2 ** 21 }) : createUnzip({ chunkSize: 2 ** 21 })).pipe(target);
|
||||||
.pipe(
|
|
||||||
/br$/i.test(filePath)
|
|
||||||
? createBrotliDecompress({ chunkSize: 2 ** 21 })
|
|
||||||
: createUnzip({ chunkSize: 2 ** 21 })
|
|
||||||
)
|
|
||||||
.pipe(target);
|
|
||||||
} else {
|
} else {
|
||||||
source.pipe(target);
|
source.pipe(target);
|
||||||
}
|
}
|
||||||
|
|
@ -72,4 +58,4 @@ class LambdaFS {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default LambdaFS;
|
export = LambdaFS;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
{
|
{
|
||||||
"extends": ["@tsconfig/node20/tsconfig", "@tsconfig/strictest"],
|
"extends": "@tsconfig/node14/tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"lib": ["dom", "ES2023"],
|
"lib": ["dom"],
|
||||||
"module": "NodeNext",
|
"outDir": "build",
|
||||||
"moduleResolution": "NodeNext",
|
|
||||||
"outDir": "build"
|
|
||||||
},
|
},
|
||||||
"include": ["source"]
|
"include": ["source"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue