How to use the chrome-aws-lambda.args function in chrome-aws-lambda

To help you get started, we’ve selected a few chrome-aws-lambda examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tensult / cloud-reports / src / reporters / pdf / index.ts View on Github external
const getPuppeteer = async () => {
    try {
        const puppeteer = require('puppeteer');
        return await puppeteer.launch();
    } catch (error) {
        if (error.code === 'MODULE_NOT_FOUND') {
            console.log('Error(This package is used for local development) ', JSON.stringify(error, null, 2));
            try {
                const chromium = require('chrome-aws-lambda')
                return await chromium.puppeteer.launch({
                    args: chromium.args,
                    defaultViewport: chromium.defaultViewport,
                    executablePath: await chromium.executablePath,
                    headless: chromium.headless
                });
            } catch (_error) {
                throw error;
            }
        }
    }
}
github zeit / og-image / api / _lib / options.ts View on Github external
export async function getOptions(isDev: boolean) {
    let options: Options;
    if (isDev) {
        options = {
            args: [],
            executablePath: exePath,
            headless: true
        };
    } else {
        options = {
            args: chrome.args,
            executablePath: await chrome.executablePath,
            headless: chrome.headless,
        };
    }
    return options;
}
github styfle / screenshot-v2 / chromium.js View on Github external
async function getScreenshot(url, type, quality, fullPage) {
    const browser = await puppeteer.launch({
        args: chrome.args,
        executablePath: await chrome.executablePath,
        headless: chrome.headless,
    });

    const page = await browser.newPage();
    await page.goto(url);
    const file = await page.screenshot({ type,  quality, fullPage });
    await browser.close();
    return file;
}
github ireade / caniuse-embed / functions / screenshot / screenshot.js View on Github external
const takeScreenshot = async (feature, periods, accessibleColours) => {

  const browser = await chromium.puppeteer.launch({
    args: chromium.args,
    defaultViewport: {
        width: 800,
        height: 600,
        isLandscape: true
    },
    executablePath: await chromium.executablePath,
    headless: chromium.headless,
  });

	const page = await browser.newPage();

	await page.goto(
		`https://caniuse.bitsofco.de/embed/index.html?feat=${feature}&periods=${periods}&accessible-colours=${accessibleColours}&screenshot=true`,
		{ waitUntil: 'networkidle2' }
	);
github luisfarzati / chromda / src / captureScreenshot.js View on Github external
executablePath =>
    new MrPuppetshot(
      {
        executablePath,
        args: [...chromeLambda.args, ...CHROMIUM_ARGS],
        headless: true,
        defaultViewport,
        ignoreHTTPSErrors: IGNORE_HTTPS_ERRORS,
        timeout: TIMEOUT
      },
      chromeLambda.puppeteer
    )
);
github iann0036 / amazon-connect-cfn / lambda / index.js View on Github external
}

        return macro_response;
    } else {
        var response_object = {
            "Status": "SUCCESS",
            "PhysicalResourceId": event.LogicalResourceId,
            "StackId": event.StackId,
            "RequestId": event.RequestId,
            "LogicalResourceId": event.LogicalResourceId,
            "Data": {}
        };

        try {
            browser = await puppeteer.launch({
                args: chromium.args,
                defaultViewport: chromium.defaultViewport,
                executablePath: await chromium.executablePath,
                headless: chromium.headless,
            });

            let page = await browser.newPage();

            if (event.RequestType == "Create" && event.ResourceType == "Custom::AWS_Connect_Instance") {
                await login(page);
                response_object.Data = await createinstance(page, event.ResourceProperties);
            } else if (event.RequestType == "Create" && event.ResourceType == "Custom::AWS_Connect_ContactFlow") {
                await login(page);
                await open(page, event.ResourceProperties);
                response_object.Data = await createflow(page, event.ResourceProperties);
            } else if (event.RequestType == "Create" && event.ResourceType == "Custom::AWS_Connect_PhoneNumber") {
                await login(page);
github tophat / sanity-runner / service / src / jestSetup / puppeteer / setup.js View on Github external
module.exports = async () => {
    const config = {
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        executablePath: await chromium.executablePath,
        headless: chromium.headless,
    }
    const browser = await chromium.puppeteer.launch(config)
    global.__BROWSER__ = browser
    await fs.mkdirs(DIR)
    await fs.writeFile(path.join(DIR, 'wsEndpoint'), browser.wsEndpoint())
}
github faastjs / examples / aws-puppeteer-ts / functions.ts View on Github external
export async function runPuppeteer(url: string) {
    const browser = await puppeteer.launch({
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        executablePath: await chromium.executablePath,
        headless: chromium.headless
    });
    try {
        let page = await browser.newPage();
        await page.goto(url);
        const title = await page.title();
        const screenshot = await page.screenshot({ encoding: "binary" });
        return { title, screenshot };
    } finally {
        if (browser !== null) {
            await browser.close();
        }
    }
}
github TimoSta / sprite / packages / api / util / screenshot.ts View on Github external
const getScreenshot = async (pageContent: string, targetId: string) => {
  const browser = await puppeteer.launch({
    args: chrome.args,
    executablePath: await chrome.executablePath,
    headless: chrome.headless
  })

  const page = await browser.newPage()
  await page.setContent(pageContent)

  const rect = await page.evaluate(targetId => {
    const element = document.getElementById(targetId)
    const {x, y, width, height} = element.getBoundingClientRect() as DOMRect
    return {left: x, top: y, width, height, id: element.id}
  }, targetId)

  const file = await page.screenshot({
    type: 'png',
    omitBackground: true,
github sthobis / site-palette / api / get-palette.js View on Github external
const getOptions = async () => {
  return process.env.NOW_REGION === "dev1"
    ? {
        args: [],
        executablePath: exePath,
        headless: true,
    }
    : {
      args: chrome.args,
      executablePath: await chrome.executablePath,
      headless: chrome.headless
    }
}

chrome-aws-lambda

Chromium Binary for AWS Lambda and Google Cloud Functions

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis