UNPKG

miniflare

Version:

Fun, full-featured, fully-local simulator for Cloudflare Workers

1,482 lines (1,475 loc) • 4.45 MB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __esm = (fn, res, err) => function __init() { if (err) throw err[0]; try { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; } catch (e) { throw err = [e], e; } }; var __commonJS = (cb, mod) => function __require2() { try { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; } catch (e) { throw mod = 0, e; } }; var __export = (target, all2) => { for (var name in all2) __defProp(target, name, { get: all2[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // ../workers-utils/dist/chunk-Q72B4Q5Z.mjs var __create2, __defProp2, __getOwnPropDesc2, __getOwnPropNames2, __getProtoOf2, __hasOwnProp2, __name, __require, __commonJS2, __export2, __copyProps2, __toESM2; var init_chunk_Q72B4Q5Z = __esm({ "../workers-utils/dist/chunk-Q72B4Q5Z.mjs"() { "use strict"; __create2 = Object.create; __defProp2 = Object.defineProperty; __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; __getOwnPropNames2 = Object.getOwnPropertyNames; __getProtoOf2 = Object.getPrototypeOf; __hasOwnProp2 = Object.prototype.hasOwnProperty; __name = (target, value) => __defProp2(target, "name", { value, configurable: true }); __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) { if (typeof require !== "undefined") return require.apply(this, arguments); throw Error('Dynamic require of "' + x + '" is not supported'); }); __commonJS2 = (cb, mod) => function __require2() { return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; __export2 = (target, all2) => { for (var name in all2) __defProp2(target, name, { get: all2[name], enumerable: true }); }; __copyProps2 = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames2(from)) if (!__hasOwnProp2.call(to, key) && key !== except) __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); } return to; }; __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, mod )); } }); // ../workers-utils/dist/open-PBXRGS4R.mjs var open_PBXRGS4R_exports = {}; __export(open_PBXRGS4R_exports, { apps: () => apps, default: () => open_default, openApp: () => openApp }); function hasDockerEnv() { try { import_node_fs3.default.statSync("/.dockerenv"); return true; } catch { return false; } } function hasDockerCGroup() { try { return import_node_fs3.default.readFileSync("/proc/self/cgroup", "utf8").includes("docker"); } catch { return false; } } function isDocker() { if (isDockerCached === void 0) { isDockerCached = hasDockerEnv() || hasDockerCGroup(); } return isDockerCached; } function isInsideContainer() { if (cachedResult === void 0) { cachedResult = hasContainerEnv() || isDocker(); } return cachedResult; } function parseMountPointFromConfig(content) { for (const line of content.split("\n")) { if (/^\s*#/.test(line)) { continue; } const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line); if (!match) { continue; } return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, ""); } } function defineLazyProperty(object2, propertyName, valueGetter) { const define2 = /* @__PURE__ */ __name((value) => Object.defineProperty(object2, propertyName, { value, enumerable: true, writable: true }), "define"); Object.defineProperty(object2, propertyName, { configurable: true, enumerable: true, get() { const result = valueGetter(); define2(result); return result; }, set(value) { define2(value); } }); return object2; } async function defaultBrowserId() { if (import_node_process2.default.platform !== "darwin") { throw new Error("macOS only"); } const { stdout: stdout2 } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]); const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout2); const browserId = match?.groups.id ?? "com.apple.Safari"; if (browserId === "com.apple.safari") { return "com.apple.Safari"; } return browserId; } async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) { if (import_node_process2.default.platform !== "darwin") { throw new Error("macOS only"); } const outputArguments = humanReadableOutput ? [] : ["-ss"]; const execOptions = {}; if (signal) { execOptions.signal = signal; } const { stdout: stdout2 } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions); return stdout2.trim(); } async function bundleName(bundleId) { return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`); } async function defaultBrowser(_execFileAsync = execFileAsync3) { const { stdout: stdout2 } = await _execFileAsync("reg", [ "QUERY", " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice", "/v", "ProgId" ]); const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout2); if (!match) { throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout2)}`); } const { id } = match.groups; const browser = windowsBrowserProgIds[id]; if (!browser) { throw new UnknownBrowserError(`Unknown browser ID: ${id}`); } return browser; } async function defaultBrowser2() { if (import_node_process2.default.platform === "darwin") { const id = await defaultBrowserId(); const name = await bundleName(id); return { name, id }; } if (import_node_process2.default.platform === "linux") { const { stdout: stdout2 } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]); const id = stdout2.trim(); const name = titleize(id.replace(/.desktop$/, "").replace("-", " ")); return { name, id }; } if (import_node_process2.default.platform === "win32") { return defaultBrowser(); } throw new Error("Only macOS, Linux, and Windows are supported"); } function detectArchBinary(binary) { if (typeof binary === "string" || Array.isArray(binary)) { return binary; } const { [arch]: archBinary } = binary; if (!archBinary) { throw new Error(`${arch} is not supported`); } return archBinary; } function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) { if (wsl && is_wsl_default) { return detectArchBinary(wsl); } if (!platformBinary) { throw new Error(`${platform} is not supported`); } return detectArchBinary(platformBinary); } var import_node_process2, import_node_path3, import_node_url, import_node_child_process, import_promises, import_node_util, import_node_os3, import_node_fs3, import_node_buffer, import_meta, isDockerCached, cachedResult, hasContainerEnv, isWsl, is_wsl_default, execFile, powerShellPath, executePowerShell, execFile2, wslDrivesMountPoint, powerShellPathFromWsl, powerShellPath2, canAccessPowerShellPromise, canAccessPowerShell, wslDefaultBrowser, convertWslPathToWindows, execFileAsync, execFileAsync2, execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError, execFileAsync4, titleize, isInSsh, is_in_ssh_default, fallbackAttemptSymbol, __dirname2, localXdgOpenPath, platform, arch, tryEachApp, baseOpen, open, openApp, apps, open_default; var init_open_PBXRGS4R = __esm({ "../workers-utils/dist/open-PBXRGS4R.mjs"() { "use strict"; init_chunk_Q72B4Q5Z(); import_node_process2 = __toESM(require("node:process"), 1); import_node_path3 = __toESM(require("node:path"), 1); import_node_url = require("node:url"); import_node_child_process = __toESM(require("node:child_process"), 1); import_promises = __toESM(require("node:fs/promises"), 1); import_node_util = require("node:util"); import_node_os3 = __toESM(require("node:os"), 1); import_node_fs3 = __toESM(require("node:fs"), 1); import_node_buffer = require("node:buffer"); import_meta = {}; __name(hasDockerEnv, "hasDockerEnv"); __name(hasDockerCGroup, "hasDockerCGroup"); __name(isDocker, "isDocker"); hasContainerEnv = /* @__PURE__ */ __name(() => { try { import_node_fs3.default.statSync("/run/.containerenv"); return true; } catch { return false; } }, "hasContainerEnv"); __name(isInsideContainer, "isInsideContainer"); isWsl = /* @__PURE__ */ __name(() => { if (import_node_process2.default.platform !== "linux") { return false; } if (import_node_os3.default.release().toLowerCase().includes("microsoft")) { if (isInsideContainer()) { return false; } return true; } try { return import_node_fs3.default.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false; } catch { return false; } }, "isWsl"); is_wsl_default = import_node_process2.default.env.__IS_WSL_TEST__ ? isWsl : isWsl(); execFile = (0, import_node_util.promisify)(import_node_child_process.default.execFile); powerShellPath = /* @__PURE__ */ __name(() => `${import_node_process2.default.env.SYSTEMROOT || import_node_process2.default.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, "powerShellPath"); executePowerShell = /* @__PURE__ */ __name(async (command, options = {}) => { const { powerShellPath: psPath, ...execFileOptions } = options; const encodedCommand = executePowerShell.encodeCommand(command); return execFile( psPath ?? powerShellPath(), [ ...executePowerShell.argumentsPrefix, encodedCommand ], { encoding: "utf8", ...execFileOptions } ); }, "executePowerShell"); executePowerShell.argumentsPrefix = [ "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-EncodedCommand" ]; executePowerShell.encodeCommand = (command) => import_node_buffer.Buffer.from(command, "utf16le").toString("base64"); executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`; __name(parseMountPointFromConfig, "parseMountPointFromConfig"); execFile2 = (0, import_node_util.promisify)(import_node_child_process.default.execFile); wslDrivesMountPoint = /* @__PURE__ */ (() => { const defaultMountPoint = "/mnt/"; let mountPoint; return async function() { if (mountPoint) { return mountPoint; } const configFilePath = "/etc/wsl.conf"; let isConfigFileExists = false; try { await import_promises.default.access(configFilePath, import_promises.constants.F_OK); isConfigFileExists = true; } catch { } if (!isConfigFileExists) { return defaultMountPoint; } const configContent = await import_promises.default.readFile(configFilePath, { encoding: "utf8" }); const parsedMountPoint = parseMountPointFromConfig(configContent); if (parsedMountPoint === void 0) { return defaultMountPoint; } mountPoint = parsedMountPoint; mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`; return mountPoint; }; })(); powerShellPathFromWsl = /* @__PURE__ */ __name(async () => { const mountPoint = await wslDrivesMountPoint(); return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`; }, "powerShellPathFromWsl"); powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath; canAccessPowerShell = /* @__PURE__ */ __name(async () => { canAccessPowerShellPromise ??= (async () => { try { const psPath = await powerShellPath2(); await import_promises.default.access(psPath, import_promises.constants.X_OK); return true; } catch { return false; } })(); return canAccessPowerShellPromise; }, "canAccessPowerShell"); wslDefaultBrowser = /* @__PURE__ */ __name(async () => { const psPath = await powerShellPath2(); const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`; const { stdout: stdout2 } = await executePowerShell(command, { powerShellPath: psPath }); return stdout2.trim(); }, "wslDefaultBrowser"); convertWslPathToWindows = /* @__PURE__ */ __name(async (path210) => { if (/^[a-z]+:\/\//i.test(path210)) { return path210; } try { const { stdout: stdout2 } = await execFile2("wslpath", ["-aw", path210], { encoding: "utf8" }); return stdout2.trim(); } catch { return path210; } }, "convertWslPathToWindows"); __name(defineLazyProperty, "defineLazyProperty"); execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile); __name(defaultBrowserId, "defaultBrowserId"); execFileAsync2 = (0, import_node_util.promisify)(import_node_child_process.execFile); __name(runAppleScript, "runAppleScript"); __name(bundleName, "bundleName"); execFileAsync3 = (0, import_node_util.promisify)(import_node_child_process.execFile); windowsBrowserProgIds = { MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" }, // The missing `L` is correct. MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" }, MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" }, AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" }, ChromeHTML: { name: "Chrome", id: "com.google.chrome" }, ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" }, ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" }, ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" }, BraveHTML: { name: "Brave", id: "com.brave.Browser" }, BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" }, BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" }, BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" }, FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" }, OperaStable: { name: "Opera", id: "com.operasoftware.Opera" }, VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" }, "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" } }; _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds)); UnknownBrowserError = class extends Error { static { __name(this, "UnknownBrowserError"); } }; __name(defaultBrowser, "defaultBrowser"); execFileAsync4 = (0, import_node_util.promisify)(import_node_child_process.execFile); titleize = /* @__PURE__ */ __name((string4) => string4.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase()), "titleize"); __name(defaultBrowser2, "defaultBrowser"); isInSsh = Boolean(import_node_process2.default.env.SSH_CONNECTION || import_node_process2.default.env.SSH_CLIENT || import_node_process2.default.env.SSH_TTY); is_in_ssh_default = isInSsh; fallbackAttemptSymbol = /* @__PURE__ */ Symbol("fallbackAttempt"); __dirname2 = import_meta.url ? import_node_path3.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)) : ""; localXdgOpenPath = import_node_path3.default.join(__dirname2, "xdg-open"); ({ platform, arch } = import_node_process2.default); tryEachApp = /* @__PURE__ */ __name(async (apps2, opener) => { if (apps2.length === 0) { return; } const errors = []; for (const app of apps2) { try { return await opener(app); } catch (error51) { errors.push(error51); } } throw new AggregateError(errors, "Failed to open in all supported apps"); }, "tryEachApp"); baseOpen = /* @__PURE__ */ __name(async (options) => { options = { wait: false, background: false, newInstance: false, allowNonzeroExitCode: false, ...options }; const isFallbackAttempt = options[fallbackAttemptSymbol] === true; delete options[fallbackAttemptSymbol]; if (Array.isArray(options.app)) { return tryEachApp(options.app, (singleApp) => baseOpen({ ...options, app: singleApp, [fallbackAttemptSymbol]: true })); } let { name: app, arguments: appArguments = [] } = options.app ?? {}; appArguments = [...appArguments]; if (Array.isArray(app)) { return tryEachApp(app, (appName) => baseOpen({ ...options, app: { name: appName, arguments: appArguments }, [fallbackAttemptSymbol]: true })); } if (app === "browser" || app === "browserPrivate") { const ids = { "com.google.chrome": "chrome", "google-chrome.desktop": "chrome", "com.brave.browser": "brave", "org.mozilla.firefox": "firefox", "firefox.desktop": "firefox", "com.microsoft.msedge": "edge", "com.microsoft.edge": "edge", "com.microsoft.edgemac": "edge", "microsoft-edge.desktop": "edge", "com.apple.safari": "safari" }; const flags = { chrome: "--incognito", brave: "--incognito", firefox: "--private-window", edge: "--inPrivate" // Safari doesn't support private mode via command line }; let browser; if (is_wsl_default) { const progId = await wslDefaultBrowser(); const browserInfo = _windowsBrowserProgIdMap.get(progId); browser = browserInfo ?? {}; } else { browser = await defaultBrowser2(); } if (browser.id in ids) { const browserName = ids[browser.id.toLowerCase()]; if (app === "browserPrivate") { if (browserName === "safari") { throw new Error("Safari doesn't support opening in private mode via command line"); } appArguments.push(flags[browserName]); } return baseOpen({ ...options, app: { name: apps[browserName], arguments: appArguments } }); } throw new Error(`${browser.name} is not supported as a default browser`); } let command; const cliArguments = []; const childProcessOptions = {}; let shouldUseWindowsInWsl = false; if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) { shouldUseWindowsInWsl = await canAccessPowerShell(); } if (platform === "darwin") { command = "open"; if (options.wait) { cliArguments.push("--wait-apps"); } if (options.background) { cliArguments.push("--background"); } if (options.newInstance) { cliArguments.push("--new"); } if (app) { cliArguments.push("-a", app); } } else if (platform === "win32" || shouldUseWindowsInWsl) { command = await powerShellPath2(); cliArguments.push(...executePowerShell.argumentsPrefix); if (!is_wsl_default) { childProcessOptions.windowsVerbatimArguments = true; } if (is_wsl_default && options.target) { options.target = await convertWslPathToWindows(options.target); } const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"]; if (options.wait) { encodedArguments.push("-Wait"); } if (app) { encodedArguments.push(executePowerShell.escapeArgument(app)); if (options.target) { appArguments.push(options.target); } } else if (options.target) { encodedArguments.push(executePowerShell.escapeArgument(options.target)); } if (appArguments.length > 0) { appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument)); encodedArguments.push("-ArgumentList", appArguments.join(",")); } options.target = executePowerShell.encodeCommand(encodedArguments.join(" ")); if (!options.wait) { childProcessOptions.stdio = "ignore"; } } else { if (app) { command = app; } else { const isBundled = !__dirname2 || __dirname2 === "/"; let exeLocalXdgOpen = false; try { await import_promises.default.access(localXdgOpenPath, import_promises.constants.X_OK); exeLocalXdgOpen = true; } catch { } const useSystemXdgOpen = import_node_process2.default.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen); command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath; } if (appArguments.length > 0) { cliArguments.push(...appArguments); } if (!options.wait) { childProcessOptions.stdio = "ignore"; childProcessOptions.detached = true; } } if (platform === "darwin" && appArguments.length > 0) { cliArguments.push("--args", ...appArguments); } if (options.target) { cliArguments.push(options.target); } const subprocess = import_node_child_process.default.spawn(command, cliArguments, childProcessOptions); if (options.wait) { return new Promise((resolve7, reject) => { subprocess.once("error", reject); subprocess.once("close", (exitCode) => { if (!options.allowNonzeroExitCode && exitCode !== 0) { reject(new Error(`Exited with code ${exitCode}`)); return; } resolve7(subprocess); }); }); } if (isFallbackAttempt) { return new Promise((resolve7, reject) => { subprocess.once("error", reject); subprocess.once("spawn", () => { subprocess.once("close", (exitCode) => { subprocess.off("error", reject); if (exitCode !== 0) { reject(new Error(`Exited with code ${exitCode}`)); return; } subprocess.unref(); resolve7(subprocess); }); }); }); } subprocess.unref(); return new Promise((resolve7, reject) => { subprocess.once("error", reject); subprocess.once("spawn", () => { subprocess.off("error", reject); resolve7(subprocess); }); }); }, "baseOpen"); open = /* @__PURE__ */ __name((target, options) => { if (typeof target !== "string") { throw new TypeError("Expected a `target`"); } return baseOpen({ ...options, target }); }, "open"); openApp = /* @__PURE__ */ __name((name, options) => { if (typeof name !== "string" && !Array.isArray(name)) { throw new TypeError("Expected a valid `name`"); } const { arguments: appArguments = [] } = options ?? {}; if (appArguments !== void 0 && appArguments !== null && !Array.isArray(appArguments)) { throw new TypeError("Expected `appArguments` as Array type"); } return baseOpen({ ...options, app: { name, arguments: appArguments } }); }, "openApp"); __name(detectArchBinary, "detectArchBinary"); __name(detectPlatformBinary, "detectPlatformBinary"); apps = { browser: "browser", browserPrivate: "browserPrivate" }; defineLazyProperty(apps, "chrome", () => detectPlatformBinary({ darwin: "google chrome", win32: "chrome", // `chromium-browser` is the older deb package name used by Ubuntu/Debian before snap. linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"] }, { wsl: { ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe", x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"] } })); defineLazyProperty(apps, "brave", () => detectPlatformBinary({ darwin: "brave browser", win32: "brave", linux: ["brave-browser", "brave"] }, { wsl: { ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe", x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"] } })); defineLazyProperty(apps, "firefox", () => detectPlatformBinary({ darwin: "firefox", win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`, linux: "firefox" }, { wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe" })); defineLazyProperty(apps, "edge", () => detectPlatformBinary({ darwin: "microsoft edge", win32: "msedge", linux: ["microsoft-edge", "microsoft-edge-dev"] }, { wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" })); defineLazyProperty(apps, "safari", () => detectPlatformBinary({ darwin: "Safari" })); open_default = open; } }); // ../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/vendors.json var require_vendors2 = __commonJS({ "../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/vendors.json"(exports2, module2) { module2.exports = [ { name: "Agola CI", constant: "AGOLA", env: "AGOLA_GIT_REF", pr: "AGOLA_PULL_REQUEST_ID" }, { name: "Alpic", constant: "ALPIC", env: "ALPIC_HOST" }, { name: "Appcircle", constant: "APPCIRCLE", env: "AC_APPCIRCLE", pr: { env: "AC_GIT_PR", ne: "false" } }, { name: "AppVeyor", constant: "APPVEYOR", env: "APPVEYOR", pr: "APPVEYOR_PULL_REQUEST_NUMBER" }, { name: "AWS CodeBuild", constant: "CODEBUILD", env: "CODEBUILD_BUILD_ARN", pr: { env: "CODEBUILD_WEBHOOK_EVENT", any: [ "PULL_REQUEST_CREATED", "PULL_REQUEST_UPDATED", "PULL_REQUEST_REOPENED" ] } }, { name: "Azure Pipelines", constant: "AZURE_PIPELINES", env: "TF_BUILD", pr: { BUILD_REASON: "PullRequest" } }, { name: "Bamboo", constant: "BAMBOO", env: "bamboo_planKey" }, { name: "Bitbucket Pipelines", constant: "BITBUCKET", env: "BITBUCKET_COMMIT", pr: "BITBUCKET_PR_ID" }, { name: "Bitrise", constant: "BITRISE", env: "BITRISE_IO", pr: "BITRISE_PULL_REQUEST" }, { name: "Buddy", constant: "BUDDY", env: "BUDDY_WORKSPACE_ID", pr: "BUDDY_EXECUTION_PULL_REQUEST_ID" }, { name: "Buildkite", constant: "BUILDKITE", env: "BUILDKITE", pr: { env: "BUILDKITE_PULL_REQUEST", ne: "false" } }, { name: "CircleCI", constant: "CIRCLE", env: "CIRCLECI", pr: "CIRCLE_PULL_REQUEST" }, { name: "Cirrus CI", constant: "CIRRUS", env: "CIRRUS_CI", pr: "CIRRUS_PR" }, { name: "Cloudflare Pages", constant: "CLOUDFLARE_PAGES", env: "CF_PAGES" }, { name: "Cloudflare Workers", constant: "CLOUDFLARE_WORKERS", env: "WORKERS_CI" }, { name: "Codefresh", constant: "CODEFRESH", env: "CF_BUILD_ID", pr: { any: [ "CF_PULL_REQUEST_NUMBER", "CF_PULL_REQUEST_ID" ] } }, { name: "Codemagic", constant: "CODEMAGIC", env: "CM_BUILD_ID", pr: "CM_PULL_REQUEST" }, { name: "Codeship", constant: "CODESHIP", env: { CI_NAME: "codeship" } }, { name: "Drone", constant: "DRONE", env: "DRONE", pr: { DRONE_BUILD_EVENT: "pull_request" } }, { name: "dsari", constant: "DSARI", env: "DSARI" }, { name: "Earthly", constant: "EARTHLY", env: "EARTHLY_CI" }, { name: "Expo Application Services", constant: "EAS", env: "EAS_BUILD" }, { name: "Gerrit", constant: "GERRIT", env: "GERRIT_PROJECT" }, { name: "Gitea Actions", constant: "GITEA_ACTIONS", env: "GITEA_ACTIONS" }, { name: "GitHub Actions", constant: "GITHUB_ACTIONS", env: "GITHUB_ACTIONS", pr: { GITHUB_EVENT_NAME: "pull_request" } }, { name: "GitLab CI", constant: "GITLAB", env: "GITLAB_CI", pr: "CI_MERGE_REQUEST_ID" }, { name: "GoCD", constant: "GOCD", env: "GO_PIPELINE_LABEL" }, { name: "Google Cloud Build", constant: "GOOGLE_CLOUD_BUILD", env: "BUILDER_OUTPUT" }, { name: "Harness CI", constant: "HARNESS", env: "HARNESS_BUILD_ID" }, { name: "Heroku", constant: "HEROKU", env: { env: "NODE", includes: "/app/.heroku/node/bin/node" } }, { name: "Hudson", constant: "HUDSON", env: "HUDSON_URL" }, { name: "Jenkins", constant: "JENKINS", env: [ "JENKINS_URL", "BUILD_ID" ], pr: { any: [ "ghprbPullId", "CHANGE_ID" ] } }, { name: "LayerCI", constant: "LAYERCI", env: "LAYERCI", pr: "LAYERCI_PULL_REQUEST" }, { name: "Magnum CI", constant: "MAGNUM", env: "MAGNUM" }, { name: "Netlify CI", constant: "NETLIFY", env: "NETLIFY", pr: { env: "PULL_REQUEST", ne: "false" } }, { name: "Nevercode", constant: "NEVERCODE", env: "NEVERCODE", pr: { env: "NEVERCODE_PULL_REQUEST", ne: "false" } }, { name: "Prow", constant: "PROW", env: "PROW_JOB_ID" }, { name: "ReleaseHub", constant: "RELEASEHUB", env: "RELEASE_BUILD_ID" }, { name: "Render", constant: "RENDER", env: "RENDER", pr: { IS_PULL_REQUEST: "true" } }, { name: "Sail CI", constant: "SAIL", env: "SAILCI", pr: "SAIL_PULL_REQUEST_NUMBER" }, { name: "Screwdriver", constant: "SCREWDRIVER", env: "SCREWDRIVER", pr: { env: "SD_PULL_REQUEST", ne: "false" } }, { name: "Semaphore", constant: "SEMAPHORE", env: "SEMAPHORE", pr: "PULL_REQUEST_NUMBER" }, { name: "Sourcehut", constant: "SOURCEHUT", env: { CI_NAME: "sourcehut" } }, { name: "Strider CD", constant: "STRIDER", env: "STRIDER" }, { name: "TaskCluster", constant: "TASKCLUSTER", env: [ "TASK_ID", "RUN_ID" ] }, { name: "TeamCity", constant: "TEAMCITY", env: "TEAMCITY_VERSION" }, { name: "Travis CI", constant: "TRAVIS", env: "TRAVIS", pr: { env: "TRAVIS_PULL_REQUEST", ne: "false" } }, { name: "Vela", constant: "VELA", env: "VELA", pr: { VELA_PULL_REQUEST: "1" } }, { name: "Vercel", constant: "VERCEL", env: { any: [ "NOW_BUILDER", "VERCEL" ] }, pr: "VERCEL_GIT_PULL_REQUEST_ID" }, { name: "Visual Studio App Center", constant: "APPCENTER", env: "APPCENTER_BUILD_ID" }, { name: "Woodpecker", constant: "WOODPECKER", env: { CI: "woodpecker" }, pr: { CI_BUILD_EVENT: "pull_request" } }, { name: "Xcode Cloud", constant: "XCODE_CLOUD", env: "CI_XCODE_PROJECT", pr: "CI_PULL_REQUEST_NUMBER" }, { name: "Xcode Server", constant: "XCODE_SERVER", env: "XCS" } ]; } }); // ../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/index.js var require_ci_info2 = __commonJS({ "../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/index.js"(exports2) { "use strict"; var vendors = require_vendors2(); var env3 = process.env; Object.defineProperty(exports2, "_vendors", { value: vendors.map(function(v) { return v.constant; }) }); exports2.name = null; exports2.isPR = null; exports2.id = null; if (env3.CI !== "false") { vendors.forEach(function(vendor) { const envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env]; const isCI2 = envs.every(function(obj) { return checkEnv(obj); }); exports2[vendor.constant] = isCI2; if (!isCI2) { return; } exports2.name = vendor.name; exports2.isPR = checkPR(vendor); exports2.id = vendor.constant; }); } exports2.isCI = !!(env3.CI !== "false" && // Bypass all checks if CI env is explicitly set to 'false' (env3.BUILD_ID || // Jenkins, Cloudbees env3.BUILD_NUMBER || // Jenkins, TeamCity env3.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari, Cloudflare Pages/Workers env3.CI_APP_ID || // Appflow env3.CI_BUILD_ID || // Appflow env3.CI_BUILD_NUMBER || // Appflow env3.CI_NAME || // Codeship and others env3.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI env3.RUN_ID || // TaskCluster, dsari exports2.name || false)); function checkEnv(obj) { if (typeof obj === "string") return !!env3[obj]; if ("env" in obj) { return env3[obj.env] && env3[obj.env].includes(obj.includes); } if ("any" in obj) { return obj.any.some(function(k) { return !!env3[k]; }); } return Object.keys(obj).every(function(k) { return env3[k] === obj[k]; }); } function checkPR(vendor) { switch (typeof vendor.pr) { case "string": return !!env3[vendor.pr]; case "object": if ("env" in vendor.pr) { if ("any" in vendor.pr) { return vendor.pr.any.some(function(key) { return env3[vendor.pr.env] === key; }); } else { return vendor.pr.env in env3 && env3[vendor.pr.env] !== vendor.pr.ne; } } else if ("any" in vendor.pr) { return vendor.pr.any.some(function(key) { return !!env3[key]; }); } else { return checkEnv(vendor.pr); } default: return null; } } } }); // ../../node_modules/.pnpm/stoppable@1.1.0/node_modules/stoppable/lib/stoppable.js var require_stoppable = __commonJS({ "../../node_modules/.pnpm/stoppable@1.1.0/node_modules/stoppable/lib/stoppable.js"(exports2, module2) { "use strict"; var https2 = require("https"); module2.exports = (server, grace) => { grace = typeof grace === "undefined" ? Infinity : grace; const reqsPerSocket = /* @__PURE__ */ new Map(); let stopped = false; let gracefully = true; if (server instanceof https2.Server) { server.on("secureConnection", onConnection); } else { server.on("connection", onConnection); } server.on("request", onRequest); server.stop = stop; server._pendingSockets = reqsPerSocket; return server; function onConnection(socket) { reqsPerSocket.set(socket, 0); socket.once("close", () => reqsPerSocket.delete(socket)); } function onRequest(req, res) { reqsPerSocket.set(req.socket, reqsPerSocket.get(req.socket) + 1); res.once("finish", () => { const pending = reqsPerSocket.get(req.socket) - 1; reqsPerSocket.set(req.socket, pending); if (stopped && pending === 0) { req.socket.end(); } }); } function stop(callback) { setImmediate(() => { stopped = true; if (grace < Infinity) { setTimeout(destroyAll, grace).unref(); } server.close((e) => { if (callback) { callback(e, gracefully); } }); reqsPerSocket.forEach(endIfIdle); }); } function endIfIdle(requests, socket) { if (requests === 0) socket.end(); } function destroyAll() { gracefully = false; reqsPerSocket.forEach((reqs, socket) => socket.end()); setImmediate(() => { reqsPerSocket.forEach((reqs, socket) => socket.destroy()); }); } }; } }); // ../../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js var require_glob_to_regexp = __commonJS({ "../../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js"(exports2, module2) { "use strict"; module2.exports = function(glob, opts) { if (typeof glob !== "string") { throw new TypeError("Expected a string"); } var str = String(glob); var reStr = ""; var extended = opts ? !!opts.extended : false; var globstar = opts ? !!opts.globstar : false; var inGroup = false; var flags = opts && typeof opts.flags === "string" ? opts.flags : ""; var c2; for (var i2 = 0, len = str.length; i2 < len; i2++) { c2 = str[i2]; switch (c2) { case "/": case "$": case "^": case "+": case ".": case "(": case ")": case "=": case "!": case "|": reStr += "\\" + c2; break; case "?": if (extended) { reStr += "."; break; } case "[": case "]": if (extended) { reStr += c2; break; } case "{": if (extended) { inGroup = true; reStr += "("; break; } case "}": if (extended) { inGroup = false; reStr += ")"; break; } case ",": if (inGroup) { reStr += "|"; break; } reStr += "\\" + c2; break; case "*": var prevChar = str[i2 - 1]; var starCount = 1; while (str[i2 + 1] === "*") { starCount++; i2++; } var nextChar = str[i2 + 1]; if (!globstar) { reStr += ".*"; } else { var isGlobstar = starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0); if (isGlobstar) { reStr += "((?:[^/]*(?:/|$))*)"; i2++; } else { reStr += "([^/]*)"; } } break; default: reStr += c2; } } if (!flags || !~flags.indexOf("g")) { reStr = "^" + reStr + "$"; } return new RegExp(reStr, flags); }; } }); // ../../node_modules/.pnpm/ignore@5.3.1/node_modules/ignore/index.js var require_ignore = __commonJS({ "../../node_modules/.pnpm/ignore@5.3.1/node_modules/ignore/index.js"(exports2, module2) { "use strict"; function makeArray(subject) { return Array.isArray(subject) ? subject : [subject]; } var EMPTY = ""; var SPACE = " "; var ESCAPE = "\\"; var REGEX_TEST_BLANK_LINE = /^\s+$/; var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/; var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/; var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/; var REGEX_SPLITALL_CRLF = /\r?\n/g; var REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/; var SLASH2 = "/"; var TMP_KEY_IGNORE = "node-ignore"; if (typeof Symbol !== "undefined") { TMP_KEY_IGNORE = /* @__PURE__ */ Symbol.for("node-ignore"); } var KEY_IGNORE = TMP_KEY_IGNORE; var define2 = (object2, key, value) => Object.defineProperty(object2, key, { value }); var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; var RETURN_FALSE = () => false; var sanitizeRange = (range) => range.replace( REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY ); var cleanRangeBackSlash = (slashes) => { const { length } = slashes; return slashes.slice(0, length - length % 2); }; var REPLACERS = [ [ // remove BOM // TODO: // Other similar zero-width characters? /^\uFEFF/, () => EMPTY ], // > Trailing spaces are ignored unless they are quoted with backslash ("\") [ // (a\ ) -> (a ) // (a ) -> (a) // (a \ ) -> (a ) /\\?\s+$/, (match) => match.indexOf("\\") === 0 ? SPACE : EMPTY ], // replace (\ ) with ' ' [ /\\\s/g, () => SPACE ], // Escape metacharacters // which is written down by users but means special for regular expressions. // > There are 12 characters with special meanings: // > - the backslash \, // > - the caret ^, // > - the dollar sign $, // > - the period or dot ., // > - the vertical bar or pipe symbol |, // > - the question mark ?, // > - the asterisk or star *, // > - the plus sign +, // > - the opening parenthesis (, // > - the closing parenthesis ), // > - and the opening square bracket [, // > - the opening curly brace {, // > These special characters are often called "metacharacters". [ /[\\$.|*+(){^]/g, (match) => `\\${match}` ], [ // > a question mark (?) matches a single character /(?!\\)\?/g, () => "[^/]" ], // leading slash [ // > A leading slash matches the beginning of the pathname. // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". // A leading slash matches the beginning of the pathname /^\//, () => "^" ], // replace special metacharacter slash after the leading slash [ /\//g, () => "\\/" ], [ // > A leading "**" followed by a slash means match in all directories. // > For example, "**/foo" matches file or directory "foo" anywhere, // > the same as pattern "foo". // > "**/foo/bar" matches file or directory "bar" anywhere that is directly // > under directory "foo". // Notice that the '*'s have been replaced as '\\*' /^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo' () => "^(?:.*\\/)?" ], // starting [ // there will be no leading '/' // (which has been replaced by section "leading slash") // If starts with '**', adding a '^' to the regular expression also works /^(?=[^^])/, function startingReplacer() { return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^"; } ], // two globstars [ // Use lookahead assertions so that we could match more than one `'/**'` /\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories // should not use '*', or it will be replaced by the next replacer // Check if it is not the last `'/**'` (_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+" ], // normal intermediate wildcards [ // Never replace escaped '*' // ignore rule '\*' will match the path '*' // 'abc.*/' -> go // 'abc.*' -> skip this rule, // coz trailing single wildcard will be handed by [trailing wildcard] /(^|[^\\]+)(\\\*)+(?=.+)/g, // '*.js' matches '.js' // '*.js' doesn't match 'abc' (_, p1, p2) => { const unescaped = p2.replace(/\\\*/g, "[^\\/]*"); return p1 + unescaped; } ], [ // unescape, revert step 3 except for back slash // For example, if a user escape a '\\*', // after step 3, the result will be '\\\\\\*' /\\\\\\(?=[$.|*+(){^])/g, () => ESCAPE ], [ // '\\\\' -> '\\' /\\\\/g, () => ESCAPE ], [ // > The range notation, e.g. [a-zA-Z], // > can be used to match one of the characters in a range. // `\` is escaped by step 3 /(\\)?\[([^\]/]*?)(\\*)($|\])/g, (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]" ], // ending [ // 'js' will not match 'js.' // 'ab' will not match 'abc' /(?:[^*])$/, // WTF! // https://git-scm.com/docs/gitignore // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1) // which re-fixes #24, #38 // > If there is a separator at the end of the pattern then the pattern // > will only match directories, otherwise the pattern can match both // > files and directories. // 'js*' will not match 'a.js' // 'js/' will not match 'a.js' // 'js' will match 'a.js' and 'a.js/' (match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)` ], // trailing wildcard [ /(\^|\\\/)?\\\*$/, (_, p1) => { const prefix = p1 ? `${p1}[^/]+` : "[^/]*"; return `${prefix}(?=$|\\/$)`; } ] ]; var regexCache = /* @__PURE__ */ Object.create(null); var makeRegex = (pattern, ignoreCase) => { let source = regexCache[pattern]; if (!source) { source = REPLACERS.reduce( (prev, current2) => prev.replace(current2[0], current2[1].bind(pattern)), pattern ); regexCache[pattern] = sourc