@sparticuz/chromium
Advanced tools
Comparing version 132.0.0 to 133.0.0
@@ -17,5 +17,6 @@ /** | ||
* AWS_LAMBDA_JS_RUNTIME is for netlify instances | ||
* VERCEL for Vercel Functions (Node 18 enables an AL2-compatible environment) | ||
* @returns boolean indicating if the running instance is inside a Lambda container | ||
*/ | ||
export declare const isRunningInAwsLambda: () => boolean; | ||
export declare const isRunningInAwsLambda: (nodeMajorVersion: number) => boolean; | ||
/** | ||
@@ -27,5 +28,6 @@ * Determines if the running instance is inside an AWS Lambda container, | ||
* CODEBUILD_BUILD_IMAGE is for CodeBuild instances | ||
* VERCEL is for Vercel Functions (Node 20 or later enables an AL2023-compatible environment). | ||
* @returns boolean indicating if the running instance is inside a Lambda container with nodejs20 | ||
*/ | ||
export declare const isRunningInAwsLambdaNode20: () => boolean; | ||
export declare const isRunningInAwsLambdaNode20: (nodeMajorVersion: number) => boolean; | ||
export declare const downloadAndExtract: (url: string) => Promise<string>; |
@@ -46,5 +46,6 @@ "use strict"; | ||
* AWS_LAMBDA_JS_RUNTIME is for netlify instances | ||
* VERCEL for Vercel Functions (Node 18 enables an AL2-compatible environment) | ||
* @returns boolean indicating if the running instance is inside a Lambda container | ||
*/ | ||
const isRunningInAwsLambda = () => { | ||
const isRunningInAwsLambda = (nodeMajorVersion) => { | ||
if (process.env["AWS_EXECUTION_ENV"] && | ||
@@ -62,2 +63,5 @@ process.env["AWS_EXECUTION_ENV"].includes("AWS_Lambda_nodejs") && | ||
} | ||
else if (process.env["VERCEL"] && nodeMajorVersion == 18) { | ||
return true; | ||
} | ||
return false; | ||
@@ -72,5 +76,6 @@ }; | ||
* CODEBUILD_BUILD_IMAGE is for CodeBuild instances | ||
* VERCEL is for Vercel Functions (Node 20 or later enables an AL2023-compatible environment). | ||
* @returns boolean indicating if the running instance is inside a Lambda container with nodejs20 | ||
*/ | ||
const isRunningInAwsLambdaNode20 = () => { | ||
const isRunningInAwsLambdaNode20 = (nodeMajorVersion) => { | ||
if ((process.env["AWS_EXECUTION_ENV"] && | ||
@@ -87,3 +92,4 @@ process.env["AWS_EXECUTION_ENV"].includes("20.x")) || | ||
(process.env["CODEBUILD_BUILD_IMAGE"] && | ||
process.env["CODEBUILD_BUILD_IMAGE"].includes("nodejs22"))) { | ||
process.env["CODEBUILD_BUILD_IMAGE"].includes("nodejs22")) || | ||
(process.env["VERCEL"] && nodeMajorVersion >= 20)) { | ||
return true; | ||
@@ -90,0 +96,0 @@ } |
@@ -64,3 +64,3 @@ /** Viewport taken from https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.viewport.md */ | ||
*/ | ||
static get headless(): string; | ||
static get headless(): "shell"; | ||
/** | ||
@@ -83,3 +83,2 @@ * Sets the headless mode. | ||
* @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 | ||
@@ -86,0 +85,0 @@ */ |
@@ -11,7 +11,8 @@ "use strict"; | ||
const helper_1 = require("./helper"); | ||
const nodeMajorVersion = parseInt(process.versions.node.split(".")[0] ?? ""); | ||
// Setup the lambda environment | ||
if ((0, helper_1.isRunningInAwsLambda)()) { | ||
if ((0, helper_1.isRunningInAwsLambda)(nodeMajorVersion)) { | ||
(0, helper_1.setupLambdaEnvironment)("/tmp/al2/lib"); | ||
} | ||
else if ((0, helper_1.isRunningInAwsLambdaNode20)()) { | ||
else if ((0, helper_1.isRunningInAwsLambdaNode20)(nodeMajorVersion)) { | ||
(0, helper_1.setupLambdaEnvironment)("/tmp/al2023/lib"); | ||
@@ -149,7 +150,7 @@ } | ||
// https://chromium.googlesource.com/chromium/src/+/main/docs/gpu/swiftshader.md | ||
// Blocked by https://github.com/Sparticuz/chromium/issues/247 | ||
//this.graphics | ||
// ? graphicsFlags.push("--use-gl=angle", "--use-angle=swiftshader") | ||
// : graphicsFlags.push("--disable-webgl"); | ||
graphicsFlags.push("--use-gl=angle", "--use-angle=swiftshader"); | ||
this.graphics | ||
? graphicsFlags.push( | ||
// As the unsafe WebGL fallback, SwANGLE (ANGLE + SwiftShader Vulkan) | ||
"--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader") | ||
: graphicsFlags.push("--disable-webgl"); | ||
const insecureFlags = [ | ||
@@ -231,12 +232,9 @@ "--allow-running-insecure-content", // https://source.chromium.org/search?q=lang:cpp+symbol:kAllowRunningInsecureContent&ss=chromium | ||
lambdafs_1.default.inflate(`${input}/fonts.tar.br`), | ||
lambdafs_1.default.inflate(`${input}/swiftshader.tar.br`), | ||
]; | ||
if (this.graphics) { | ||
// Only inflate graphics stack if needed | ||
promises.push(lambdafs_1.default.inflate(`${input}/swiftshader.tar.br`)); | ||
} | ||
if ((0, helper_1.isRunningInAwsLambda)()) { | ||
if ((0, helper_1.isRunningInAwsLambda)(nodeMajorVersion)) { | ||
// If running in AWS Lambda, extract more required files | ||
promises.push(lambdafs_1.default.inflate(`${input}/al2.tar.br`)); | ||
} | ||
if ((0, helper_1.isRunningInAwsLambdaNode20)()) { | ||
if ((0, helper_1.isRunningInAwsLambdaNode20)(nodeMajorVersion)) { | ||
promises.push(lambdafs_1.default.inflate(`${input}/al2023.tar.br`)); | ||
@@ -278,3 +276,2 @@ } | ||
* @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 | ||
@@ -286,8 +283,5 @@ */ | ||
} | ||
// Disabling 'disabling the gpu' | ||
// Blocked by https://github.com/Sparticuz/chromium/issues/247 | ||
// this.graphicsMode = value; | ||
this.graphicsMode = true; | ||
this.graphicsMode = value; | ||
} | ||
} | ||
module.exports = Chromium; |
{ | ||
"name": "@sparticuz/chromium", | ||
"version": "132.0.0", | ||
"version": "133.0.0", | ||
"description": "Chromium Binary for Serverless Platforms", | ||
@@ -46,6 +46,6 @@ "keywords": [ | ||
"@types/follow-redirects": "^1.14.4", | ||
"@types/node": "^20.17.16", | ||
"@types/node": "^20.17.23", | ||
"@types/tar-fs": "^2.0.4", | ||
"clean-modules": "^3.1.1", | ||
"typescript": "^5.7.3" | ||
"typescript": "^5.8.2" | ||
}, | ||
@@ -52,0 +52,0 @@ "engines": { |
@@ -233,2 +233,6 @@ # @sparticuz/chromium | ||
### Do I need to use @sparticuz/chromium? | ||
This package is designed to be run on a vanilla Lambda instance. If you are using a dockerfile to publish your code to Lambda, it may be a better idea to install `chromium` and it's dependencies from the distribution's repositories. | ||
### I need Accessible pdf files | ||
@@ -440,2 +444,3 @@ | ||
[](https://github.com/munawwar) | ||
[](https://github.com/syntaxfm) | ||
@@ -450,3 +455,3 @@ [](https://github.com/th3madhack3r) | ||
 | ||
[](https://github.com/azymnis) | ||
 | ||
 | ||
@@ -453,0 +458,0 @@  |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
66125082
584
463
32