Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1"use strict";2var __create = Object.create;3var __defProp = Object.defineProperty;4var __getOwnPropDesc = Object.getOwnPropertyDescriptor;5var __getOwnPropNames = Object.getOwnPropertyNames;6var __getProtoOf = Object.getPrototypeOf;7var __hasOwnProp = Object.prototype.hasOwnProperty;8var __export = (target, all) => {9 for (var name in all)10 __defProp(target, name, { get: all[name], enumerable: true });11};12var __copyProps = (to, from, except, desc) => {13 if (from && typeof from === "object" || typeof from === "function") {14 for (let key of __getOwnPropNames(from))15 if (!__hasOwnProp.call(to, key) && key !== except)16 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });17 }18 return to;19};20var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(21 // If the importer is in node compatibility mode or this is not an ESM22 // file that has been converted to a CommonJS file using a Babel-23 // compatible transform (i.e. "__esModule" has not been set), then set24 // "default" to the CommonJS "module.exports" for node compatibility.25 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,26 mod27));28var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);29var program_exports = {};30__export(program_exports, {31 program: () => import_utilsBundle2.program32});33module.exports = __toCommonJS(program_exports);34var import_fs = __toESM(require("fs"));35var import_os = __toESM(require("os"));36var import_path = __toESM(require("path"));37var playwright = __toESM(require("../.."));38var import_driver = require("./driver");39var import_server = require("../server");40var import_utils = require("../utils");41var import_traceViewer = require("../server/trace/viewer/traceViewer");42var import_utils2 = require("../utils");43var import_ascii = require("../server/utils/ascii");44var import_utilsBundle = require("../utilsBundle");45var import_utilsBundle2 = require("../utilsBundle");46const packageJSON = require("../../package.json");47import_utilsBundle.program.version("Version " + (process.env.PW_CLI_DISPLAY_VERSION || packageJSON.version)).name(buildBasePlaywrightCLICommand(process.env.PW_LANG_NAME));48import_utilsBundle.program.command("mark-docker-image [dockerImageNameTemplate]", { hidden: true }).description("mark docker image").allowUnknownOption(true).action(function(dockerImageNameTemplate) {49 (0, import_utils2.assert)(dockerImageNameTemplate, "dockerImageNameTemplate is required");50 (0, import_server.writeDockerVersion)(dockerImageNameTemplate).catch(logErrorAndExit);51});52commandWithOpenOptions("open [url]", "open page in browser specified via -b, --browser", []).action(function(url, options) {53 open(options, url).catch(logErrorAndExit);54}).addHelpText("afterAll", `55Examples:56 57 $ open58 $ open -b webkit https://example.com`);59commandWithOpenOptions(60 "codegen [url]",61 "open page and generate code for user actions",62 [63 ["-o, --output <file name>", "saves the generated script to a file"],64 ["--target <language>", `language to generate, one of javascript, playwright-test, python, python-async, python-pytest, csharp, csharp-mstest, csharp-nunit, java, java-junit`, codegenId()],65 ["--test-id-attribute <attributeName>", "use the specified attribute to generate data test ID selectors"]66 ]67).action(async function(url, options) {68 await codegen(options, url);69}).addHelpText("afterAll", `70Examples:71 72 $ codegen73 $ codegen --target=python74 $ codegen -b webkit https://example.com`);75function suggestedBrowsersToInstall() {76 return import_server.registry.executables().filter((e) => e.installType !== "none" && e.type !== "tool").map((e) => e.name).join(", ");77}78function defaultBrowsersToInstall(options) {79 let executables = import_server.registry.defaultExecutables();80 if (options.noShell)81 executables = executables.filter((e) => e.name !== "chromium-headless-shell");82 if (options.onlyShell)83 executables = executables.filter((e) => e.name !== "chromium");84 return executables;85}86function checkBrowsersToInstall(args, options) {87 if (options.noShell && options.onlyShell)88 throw new Error(`Only one of --no-shell and --only-shell can be specified`);89 const faultyArguments = [];90 const executables = [];91 const handleArgument = (arg) => {92 const executable = import_server.registry.findExecutable(arg);93 if (!executable || executable.installType === "none")94 faultyArguments.push(arg);95 else96 executables.push(executable);97 if (executable?.browserName === "chromium")98 executables.push(import_server.registry.findExecutable("ffmpeg"));99 };100 for (const arg of args) {101 if (arg === "chromium") {102 if (!options.onlyShell)103 handleArgument("chromium");104 if (!options.noShell)105 handleArgument("chromium-headless-shell");106 } else {107 handleArgument(arg);108 }109 }110 if (process.platform === "win32")111 executables.push(import_server.registry.findExecutable("winldd"));112 if (faultyArguments.length)113 throw new Error(`Invalid installation targets: ${faultyArguments.map((name) => `'${name}'`).join(", ")}. Expecting one of: ${suggestedBrowsersToInstall()}`);114 return executables;115}116function printInstalledBrowsers(browsers2) {117 const browserPaths = /* @__PURE__ */ new Set();118 for (const browser of browsers2)119 browserPaths.add(browser.browserPath);120 console.log(` Browsers:`);121 for (const browserPath of [...browserPaths].sort())122 console.log(` ${browserPath}`);123 console.log(` References:`);124 const references = /* @__PURE__ */ new Set();125 for (const browser of browsers2)126 references.add(browser.referenceDir);127 for (const reference of [...references].sort())128 console.log(` ${reference}`);129}130function printGroupedByPlaywrightVersion(browsers2) {131 const dirToVersion = /* @__PURE__ */ new Map();132 for (const browser of browsers2) {133 if (dirToVersion.has(browser.referenceDir))134 continue;135 const packageJSON2 = require(import_path.default.join(browser.referenceDir, "package.json"));136 const version = packageJSON2.version;137 dirToVersion.set(browser.referenceDir, version);138 }139 const groupedByPlaywrightMinorVersion = /* @__PURE__ */ new Map();140 for (const browser of browsers2) {141 const version = dirToVersion.get(browser.referenceDir);142 let entries = groupedByPlaywrightMinorVersion.get(version);143 if (!entries) {144 entries = [];145 groupedByPlaywrightMinorVersion.set(version, entries);146 }147 entries.push(browser);148 }149 const sortedVersions = [...groupedByPlaywrightMinorVersion.keys()].sort((a, b) => {150 const aComponents = a.split(".");151 const bComponents = b.split(".");152 const aMajor = parseInt(aComponents[0], 10);153 const bMajor = parseInt(bComponents[0], 10);154 if (aMajor !== bMajor)155 return aMajor - bMajor;156 const aMinor = parseInt(aComponents[1], 10);157 const bMinor = parseInt(bComponents[1], 10);158 if (aMinor !== bMinor)159 return aMinor - bMinor;160 return aComponents.slice(2).join(".").localeCompare(bComponents.slice(2).join("."));161 });162 for (const version of sortedVersions) {163 console.log(`164Playwright version: ${version}`);165 printInstalledBrowsers(groupedByPlaywrightMinorVersion.get(version));166 }167}168import_utilsBundle.program.command("install [browser...]").description("ensure browsers necessary for this version of Playwright are installed").option("--with-deps", "install system dependencies for browsers").option("--dry-run", "do not execute installation, only print information").option("--list", "prints list of browsers from all playwright installations").option("--force", "force reinstall of stable browser channels").option("--only-shell", "only install headless shell when installing chromium").option("--no-shell", "do not install chromium headless shell").action(async function(args, options) {169 if (options.shell === false)170 options.noShell = true;171 if ((0, import_utils.isLikelyNpxGlobal)()) {172 console.error((0, import_ascii.wrapInASCIIBox)([173 `WARNING: It looks like you are running 'npx playwright install' without first`,174 `installing your project's dependencies.`,175 ``,176 `To avoid unexpected behavior, please install your dependencies first, and`,177 `then run Playwright's install command:`,178 ``,179 ` npm install`,180 ` npx playwright install`,181 ``,182 `If your project does not yet depend on Playwright, first install the`,183 `applicable npm package (most commonly @playwright/test), and`,184 `then run Playwright's install command to download the browsers:`,185 ``,186 ` npm install @playwright/test`,187 ` npx playwright install`,188 ``189 ].join("\n"), 1));190 }191 try {192 const hasNoArguments = !args.length;193 const executables = hasNoArguments ? defaultBrowsersToInstall(options) : checkBrowsersToInstall(args, options);194 if (options.withDeps)195 await import_server.registry.installDeps(executables, !!options.dryRun);196 if (options.dryRun && options.list)197 throw new Error(`Only one of --dry-run and --list can be specified`);198 if (options.dryRun) {199 for (const executable of executables) {200 const version = executable.browserVersion ? `version ` + executable.browserVersion : "";201 console.log(`browser: ${executable.name}${version ? " " + version : ""}`);202 console.log(` Install location: ${executable.directory ?? "<system>"}`);203 if (executable.downloadURLs?.length) {204 const [url, ...fallbacks] = executable.downloadURLs;205 console.log(` Download url: ${url}`);206 for (let i = 0; i < fallbacks.length; ++i)207 console.log(` Download fallback ${i + 1}: ${fallbacks[i]}`);208 }209 console.log(``);210 }211 } else if (options.list) {212 const browsers2 = await import_server.registry.listInstalledBrowsers();213 printGroupedByPlaywrightVersion(browsers2);214 } else {215 const forceReinstall = hasNoArguments ? false : !!options.force;216 await import_server.registry.install(executables, forceReinstall);217 await import_server.registry.validateHostRequirementsForExecutablesIfNeeded(executables, process.env.PW_LANG_NAME || "javascript").catch((e) => {218 e.name = "Playwright Host validation warning";219 console.error(e);220 });221 }222 } catch (e) {223 console.log(`Failed to install browsers224${e}`);225 (0, import_utils.gracefullyProcessExitDoNotHang)(1);226 }227}).addHelpText("afterAll", `228 229Examples:230 - $ install231 Install default browsers.232 233 - $ install chrome firefox234 Install custom browsers, supports ${suggestedBrowsersToInstall()}.`);235import_utilsBundle.program.command("uninstall").description("Removes browsers used by this installation of Playwright from the system (chromium, firefox, webkit, ffmpeg). This does not include branded channels.").option("--all", "Removes all browsers used by any Playwright installation from the system.").action(async (options) => {236 delete process.env.PLAYWRIGHT_SKIP_BROWSER_GC;237 await import_server.registry.uninstall(!!options.all).then(({ numberOfBrowsersLeft }) => {238 if (!options.all && numberOfBrowsersLeft > 0) {239 console.log("Successfully uninstalled Playwright browsers for the current Playwright installation.");240 console.log(`There are still ${numberOfBrowsersLeft} browsers left, used by other Playwright installations.241To uninstall Playwright browsers for all installations, re-run with --all flag.`);242 }243 }).catch(logErrorAndExit);244});245import_utilsBundle.program.command("install-deps [browser...]").description("install dependencies necessary to run browsers (will ask for sudo permissions)").option("--dry-run", "Do not execute installation commands, only print them").action(async function(args, options) {246 try {247 if (!args.length)248 await import_server.registry.installDeps(defaultBrowsersToInstall({}), !!options.dryRun);249 else250 await import_server.registry.installDeps(checkBrowsersToInstall(args, {}), !!options.dryRun);251 } catch (e) {252 console.log(`Failed to install browser dependencies253${e}`);254 (0, import_utils.gracefullyProcessExitDoNotHang)(1);255 }256}).addHelpText("afterAll", `257Examples:258 - $ install-deps259 Install dependencies for default browsers.260 261 - $ install-deps chrome firefox262 Install dependencies for specific browsers, supports ${suggestedBrowsersToInstall()}.`);263const browsers = [264 { alias: "cr", name: "Chromium", type: "chromium" },265 { alias: "ff", name: "Firefox", type: "firefox" },266 { alias: "wk", name: "WebKit", type: "webkit" }267];268for (const { alias, name, type } of browsers) {269 commandWithOpenOptions(`${alias} [url]`, `open page in ${name}`, []).action(function(url, options) {270 open({ ...options, browser: type }, url).catch(logErrorAndExit);271 }).addHelpText("afterAll", `272Examples:273 274 $ ${alias} https://example.com`);275}276commandWithOpenOptions(277 "screenshot <url> <filename>",278 "capture a page screenshot",279 [280 ["--wait-for-selector <selector>", "wait for selector before taking a screenshot"],281 ["--wait-for-timeout <timeout>", "wait for timeout in milliseconds before taking a screenshot"],282 ["--full-page", "whether to take a full page screenshot (entire scrollable area)"]283 ]284).action(function(url, filename, command) {285 screenshot(command, command, url, filename).catch(logErrorAndExit);286}).addHelpText("afterAll", `287Examples:288 289 $ screenshot -b webkit https://example.com example.png`);290commandWithOpenOptions(291 "pdf <url> <filename>",292 "save page as pdf",293 [294 ["--paper-format <format>", "paper format: Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6"],295 ["--wait-for-selector <selector>", "wait for given selector before saving as pdf"],296 ["--wait-for-timeout <timeout>", "wait for given timeout in milliseconds before saving as pdf"]297 ]298).action(function(url, filename, options) {299 pdf(options, options, url, filename).catch(logErrorAndExit);300}).addHelpText("afterAll", `301Examples:302 303 $ pdf https://example.com example.pdf`);304import_utilsBundle.program.command("run-driver", { hidden: true }).action(function(options) {305 (0, import_driver.runDriver)();306});307import_utilsBundle.program.command("run-server").option("--port <port>", "Server port").option("--host <host>", "Server host").option("--path <path>", "Endpoint Path", "/").option("--max-clients <maxClients>", "Maximum clients").option("--mode <mode>", 'Server mode, either "default" or "extension"').action(function(options) {308 (0, import_driver.runServer)({309 port: options.port ? +options.port : void 0,310 host: options.host,311 path: options.path,312 maxConnections: options.maxClients ? +options.maxClients : Infinity,313 extension: options.mode === "extension" || !!process.env.PW_EXTENSION_MODE314 }).catch(logErrorAndExit);315});316import_utilsBundle.program.command("print-api-json", { hidden: true }).action(function(options) {317 (0, import_driver.printApiJson)();318});319import_utilsBundle.program.command("launch-server", { hidden: true }).requiredOption("--browser <browserName>", 'Browser name, one of "chromium", "firefox" or "webkit"').option("--config <path-to-config-file>", "JSON file with launchServer options").action(function(options) {320 (0, import_driver.launchBrowserServer)(options.browser, options.config);321});322import_utilsBundle.program.command("show-trace [trace...]").option("-b, --browser <browserType>", "browser to use, one of cr, chromium, ff, firefox, wk, webkit", "chromium").option("-h, --host <host>", "Host to serve trace on; specifying this option opens trace in a browser tab").option("-p, --port <port>", "Port to serve trace on, 0 for any free port; specifying this option opens trace in a browser tab").option("--stdin", "Accept trace URLs over stdin to update the viewer").description("show trace viewer").action(function(traces, options) {323 if (options.browser === "cr")324 options.browser = "chromium";325 if (options.browser === "ff")326 options.browser = "firefox";327 if (options.browser === "wk")328 options.browser = "webkit";329 const openOptions = {330 host: options.host,331 port: +options.port,332 isServer: !!options.stdin333 };334 if (options.port !== void 0 || options.host !== void 0)335 (0, import_traceViewer.runTraceInBrowser)(traces, openOptions).catch(logErrorAndExit);336 else337 (0, import_traceViewer.runTraceViewerApp)(traces, options.browser, openOptions, true).catch(logErrorAndExit);338}).addHelpText("afterAll", `339Examples:340 341 $ show-trace https://example.com/trace.zip`);342async function launchContext(options, extraOptions) {343 validateOptions(options);344 const browserType = lookupBrowserType(options);345 const launchOptions = extraOptions;346 if (options.channel)347 launchOptions.channel = options.channel;348 launchOptions.handleSIGINT = false;349 const contextOptions = (350 // Copy the device descriptor since we have to compare and modify the options.351 options.device ? { ...playwright.devices[options.device] } : {}352 );353 if (!extraOptions.headless)354 contextOptions.deviceScaleFactor = import_os.default.platform() === "darwin" ? 2 : 1;355 if (browserType.name() === "webkit" && process.platform === "linux") {356 delete contextOptions.hasTouch;357 delete contextOptions.isMobile;358 }359 if (contextOptions.isMobile && browserType.name() === "firefox")360 contextOptions.isMobile = void 0;361 if (options.blockServiceWorkers)362 contextOptions.serviceWorkers = "block";363 if (options.proxyServer) {364 launchOptions.proxy = {365 server: options.proxyServer366 };367 if (options.proxyBypass)368 launchOptions.proxy.bypass = options.proxyBypass;369 }370 if (options.viewportSize) {371 try {372 const [width, height] = options.viewportSize.split(",").map((n) => +n);373 if (isNaN(width) || isNaN(height))374 throw new Error("bad values");375 contextOptions.viewport = { width, height };376 } catch (e) {377 throw new Error('Invalid viewport size format: use "width,height", for example --viewport-size="800,600"');378 }379 }380 if (options.geolocation) {381 try {382 const [latitude, longitude] = options.geolocation.split(",").map((n) => parseFloat(n.trim()));383 contextOptions.geolocation = {384 latitude,385 longitude386 };387 } catch (e) {388 throw new Error('Invalid geolocation format, should be "lat,long". For example --geolocation="37.819722,-122.478611"');389 }390 contextOptions.permissions = ["geolocation"];391 }392 if (options.userAgent)393 contextOptions.userAgent = options.userAgent;394 if (options.lang)395 contextOptions.locale = options.lang;396 if (options.colorScheme)397 contextOptions.colorScheme = options.colorScheme;398 if (options.timezone)399 contextOptions.timezoneId = options.timezone;400 if (options.loadStorage)401 contextOptions.storageState = options.loadStorage;402 if (options.ignoreHttpsErrors)403 contextOptions.ignoreHTTPSErrors = true;404 if (options.saveHar) {405 contextOptions.recordHar = { path: import_path.default.resolve(process.cwd(), options.saveHar), mode: "minimal" };406 if (options.saveHarGlob)407 contextOptions.recordHar.urlFilter = options.saveHarGlob;408 contextOptions.serviceWorkers = "block";409 }410 let browser;411 let context;412 if (options.userDataDir) {413 context = await browserType.launchPersistentContext(options.userDataDir, { ...launchOptions, ...contextOptions });414 browser = context.browser();415 } else {416 browser = await browserType.launch(launchOptions);417 context = await browser.newContext(contextOptions);418 }419 let closingBrowser = false;420 async function closeBrowser() {421 if (closingBrowser)422 return;423 closingBrowser = true;424 if (options.saveStorage)425 await context.storageState({ path: options.saveStorage }).catch((e) => null);426 if (options.saveHar)427 await context.close();428 await browser.close();429 }430 context.on("page", (page) => {431 page.on("dialog", () => {432 });433 page.on("close", () => {434 const hasPage = browser.contexts().some((context2) => context2.pages().length > 0);435 if (hasPage)436 return;437 closeBrowser().catch(() => {438 });439 });440 });441 process.on("SIGINT", async () => {442 await closeBrowser();443 (0, import_utils.gracefullyProcessExitDoNotHang)(130);444 });445 const timeout = options.timeout ? parseInt(options.timeout, 10) : 0;446 context.setDefaultTimeout(timeout);447 context.setDefaultNavigationTimeout(timeout);448 delete launchOptions.headless;449 delete launchOptions.executablePath;450 delete launchOptions.handleSIGINT;451 delete contextOptions.deviceScaleFactor;452 return { browser, browserName: browserType.name(), context, contextOptions, launchOptions, closeBrowser };453}454async function openPage(context, url) {455 let page = context.pages()[0];456 if (!page)457 page = await context.newPage();458 if (url) {459 if (import_fs.default.existsSync(url))460 url = "file://" + import_path.default.resolve(url);461 else if (!url.startsWith("http") && !url.startsWith("file://") && !url.startsWith("about:") && !url.startsWith("data:"))462 url = "http://" + url;463 await page.goto(url);464 }465 return page;466}467async function open(options, url) {468 const { context } = await launchContext(options, { headless: !!process.env.PWTEST_CLI_HEADLESS, executablePath: process.env.PWTEST_CLI_EXECUTABLE_PATH });469 await openPage(context, url);470}471async function codegen(options, url) {472 const { target: language, output: outputFile, testIdAttribute: testIdAttributeName } = options;473 const tracesDir = import_path.default.join(import_os.default.tmpdir(), `playwright-recorder-trace-${Date.now()}`);474 const { context, browser, launchOptions, contextOptions, closeBrowser } = await launchContext(options, {475 headless: !!process.env.PWTEST_CLI_HEADLESS,476 executablePath: process.env.PWTEST_CLI_EXECUTABLE_PATH,477 tracesDir478 });479 const donePromise = new import_utils.ManualPromise();480 maybeSetupTestHooks(browser, closeBrowser, donePromise);481 import_utilsBundle.dotenv.config({ path: "playwright.env" });482 await context._enableRecorder({483 language,484 launchOptions,485 contextOptions,486 device: options.device,487 saveStorage: options.saveStorage,488 mode: "recording",489 testIdAttributeName,490 outputFile: outputFile ? import_path.default.resolve(outputFile) : void 0,491 handleSIGINT: false492 });493 await openPage(context, url);494 donePromise.resolve();495}496async function maybeSetupTestHooks(browser, closeBrowser, donePromise) {497 if (!process.env.PWTEST_CLI_IS_UNDER_TEST)498 return;499 const logs = [];500 require("playwright-core/lib/utilsBundle").debug.log = (...args) => {501 const line = require("util").format(...args) + "\n";502 logs.push(line);503 process.stderr.write(line);504 };505 browser.on("disconnected", () => {506 const hasCrashLine = logs.some((line) => line.includes("process did exit:") && !line.includes("process did exit: exitCode=0, signal=null"));507 if (hasCrashLine) {508 process.stderr.write("Detected browser crash.\n");509 (0, import_utils.gracefullyProcessExitDoNotHang)(1);510 }511 });512 const close = async () => {513 await donePromise;514 await closeBrowser();515 };516 if (process.env.PWTEST_CLI_EXIT_AFTER_TIMEOUT) {517 setTimeout(close, +process.env.PWTEST_CLI_EXIT_AFTER_TIMEOUT);518 return;519 }520 let stdin = "";521 process.stdin.on("data", (data) => {522 stdin += data.toString();523 if (stdin.startsWith("exit")) {524 process.stdin.destroy();525 close();526 }527 });528}529async function waitForPage(page, captureOptions) {530 if (captureOptions.waitForSelector) {531 console.log(`Waiting for selector ${captureOptions.waitForSelector}...`);532 await page.waitForSelector(captureOptions.waitForSelector);533 }534 if (captureOptions.waitForTimeout) {535 console.log(`Waiting for timeout ${captureOptions.waitForTimeout}...`);536 await page.waitForTimeout(parseInt(captureOptions.waitForTimeout, 10));537 }538}539async function screenshot(options, captureOptions, url, path2) {540 const { context } = await launchContext(options, { headless: true });541 console.log("Navigating to " + url);542 const page = await openPage(context, url);543 await waitForPage(page, captureOptions);544 console.log("Capturing screenshot into " + path2);545 await page.screenshot({ path: path2, fullPage: !!captureOptions.fullPage });546 await page.close();547}548async function pdf(options, captureOptions, url, path2) {549 if (options.browser !== "chromium")550 throw new Error("PDF creation is only working with Chromium");551 const { context } = await launchContext({ ...options, browser: "chromium" }, { headless: true });552 console.log("Navigating to " + url);553 const page = await openPage(context, url);554 await waitForPage(page, captureOptions);555 console.log("Saving as pdf into " + path2);556 await page.pdf({ path: path2, format: captureOptions.paperFormat });557 await page.close();558}559function lookupBrowserType(options) {560 let name = options.browser;561 if (options.device) {562 const device = playwright.devices[options.device];563 name = device.defaultBrowserType;564 }565 let browserType;566 switch (name) {567 case "chromium":568 browserType = playwright.chromium;569 break;570 case "webkit":571 browserType = playwright.webkit;572 break;573 case "firefox":574 browserType = playwright.firefox;575 break;576 case "cr":577 browserType = playwright.chromium;578 break;579 case "wk":580 browserType = playwright.webkit;581 break;582 case "ff":583 browserType = playwright.firefox;584 break;585 }586 if (browserType)587 return browserType;588 import_utilsBundle.program.help();589}590function validateOptions(options) {591 if (options.device && !(options.device in playwright.devices)) {592 const lines = [`Device descriptor not found: '${options.device}', available devices are:`];593 for (const name in playwright.devices)594 lines.push(` "${name}"`);595 throw new Error(lines.join("\n"));596 }597 if (options.colorScheme && !["light", "dark"].includes(options.colorScheme))598 throw new Error('Invalid color scheme, should be one of "light", "dark"');599}600function logErrorAndExit(e) {601 if (process.env.PWDEBUGIMPL)602 console.error(e);603 else604 console.error(e.name + ": " + e.message);605 (0, import_utils.gracefullyProcessExitDoNotHang)(1);606}607function codegenId() {608 return process.env.PW_LANG_NAME || "playwright-test";609}610function commandWithOpenOptions(command, description, options) {611 let result = import_utilsBundle.program.command(command).description(description);612 for (const option of options)613 result = result.option(option[0], ...option.slice(1));614 return result.option("-b, --browser <browserType>", "browser to use, one of cr, chromium, ff, firefox, wk, webkit", "chromium").option("--block-service-workers", "block service workers").option("--channel <channel>", 'Chromium distribution channel, "chrome", "chrome-beta", "msedge-dev", etc').option("--color-scheme <scheme>", 'emulate preferred color scheme, "light" or "dark"').option("--device <deviceName>", 'emulate device, for example "iPhone 11"').option("--geolocation <coordinates>", 'specify geolocation coordinates, for example "37.819722,-122.478611"').option("--ignore-https-errors", "ignore https errors").option("--load-storage <filename>", "load context storage state from the file, previously saved with --save-storage").option("--lang <language>", 'specify language / locale, for example "en-GB"').option("--proxy-server <proxy>", 'specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"').option("--proxy-bypass <bypass>", 'comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"').option("--save-har <filename>", "save HAR file with all network activity at the end").option("--save-har-glob <glob pattern>", "filter entries in the HAR by matching url against this glob pattern").option("--save-storage <filename>", "save context storage state at the end, for later use with --load-storage").option("--timezone <time zone>", 'time zone to emulate, for example "Europe/Rome"').option("--timeout <timeout>", "timeout for Playwright actions in milliseconds, no timeout by default").option("--user-agent <ua string>", "specify user agent string").option("--user-data-dir <directory>", "use the specified user data directory instead of a new context").option("--viewport-size <size>", 'specify browser viewport size in pixels, for example "1280, 720"');615}616function buildBasePlaywrightCLICommand(cliTargetLang) {617 switch (cliTargetLang) {618 case "python":619 return `playwright`;620 case "java":621 return `mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="...options.."`;622 case "csharp":623 return `pwsh bin/Debug/netX/playwright.ps1`;624 default: {625 const packageManagerCommand = (0, import_utils2.getPackageManagerExecCommand)();626 return `${packageManagerCommand} playwright`;627 }628 }629}630// Annotate the CommonJS export names for ESM import in node:6310 && (module.exports = {632 program633});634 