UNPKG

miniflare

Version:

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

1,475 lines (1,463 loc) • 3.96 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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); 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); // ../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/vendors.json var require_vendors = __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_info = __commonJS({ "../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/index.js"(exports2) { "use strict"; var vendors = require_vendors(); 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 isCI = envs.every(function(obj) { return checkEnv(obj); }); exports2[vendor.constant] = isCI; if (!isCI) { 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 = (object, key, value) => Object.defineProperty(object, 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 `'/**'` (_2, 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' (_2, 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 [ /(\^|\\\/)?\\\*$/, (_2, 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] = source; } return ignoreCase ? new RegExp(source, "i") : new RegExp(source); }; var isString2 = (subject) => typeof subject === "string"; var checkPattern = (pattern) => pattern && isString2(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0; var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF); var IgnoreRule = class { constructor(origin, pattern, negative, regex2) { this.origin = origin; this.pattern = pattern; this.negative = negative; this.regex = regex2; } }; var createRule = (pattern, ignoreCase) => { const origin = pattern; let negative = false; if (pattern.indexOf("!") === 0) { negative = true; pattern = pattern.substr(1); } pattern = pattern.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#"); const regex2 = makeRegex(pattern, ignoreCase); return new IgnoreRule( origin, pattern, negative, regex2 ); }; var throwError = (message, Ctor) => { throw new Ctor(message); }; var checkPath = (path64, originalPath, doThrow) => { if (!isString2(path64)) { return doThrow( `path must be a string, but got \`${originalPath}\``, TypeError ); } if (!path64) { return doThrow(`path must not be empty`, TypeError); } if (checkPath.isNotRelative(path64)) { const r = "`path.relative()`d"; return doThrow( `path should be a ${r} string, but got "${originalPath}"`, RangeError ); } return true; }; var isNotRelative = (path64) => REGEX_TEST_INVALID_PATH.test(path64); checkPath.isNotRelative = isNotRelative; checkPath.convert = (p2) => p2; var Ignore = class { constructor({ ignorecase = true, ignoreCase = ignorecase, allowRelativePaths = false } = {}) { define2(this, KEY_IGNORE, true); this._rules = []; this._ignoreCase = ignoreCase; this._allowRelativePaths = allowRelativePaths; this._initCache(); } _initCache() { this._ignoreCache = /* @__PURE__ */ Object.create(null); this._testCache = /* @__PURE__ */ Object.create(null); } _addPattern(pattern) { if (pattern && pattern[KEY_IGNORE]) { this._rules = this._rules.concat(pattern._rules); this._added = true; return; } if (checkPattern(pattern)) { const rule = createRule(pattern, this._ignoreCase); this._added = true; this._rules.push(rule); } } // @param {Array<string> | string | Ignore} pattern add(pattern) { this._added = false; makeArray( isString2(pattern) ? splitPattern(pattern) : pattern ).forEach(this._addPattern, this); if (this._added) { this._initCache(); } return this; } // legacy addPattern(pattern) { return this.add(pattern); } // | ignored : unignored // negative | 0:0 | 0:1 | 1:0 | 1:1 // -------- | ------- | ------- | ------- | -------- // 0 | TEST | TEST | SKIP | X // 1 | TESTIF | SKIP | TEST | X // - SKIP: always skip // - TEST: always test // - TESTIF: only test if checkUnignored // - X: that never happen // @param {boolean} whether should check if the path is unignored, // setting `checkUnignored` to `false` could reduce additional // path matching. // @returns {TestResult} true if a file is ignored _testOne(path64, checkUnignored) { let ignored2 = false; let unignored = false; this._rules.forEach((rule) => { const { negative } = rule; if (unignored === negative && ignored2 !== unignored || negative && !ignored2 && !unignored && !checkUnignored) { return; } const matched = rule.regex.test(path64); if (matched) { ignored2 = !negative; unignored = negative; } }); return { ignored: ignored2, unignored }; } // @returns {TestResult} _test(originalPath, cache, checkUnignored, slices) { const path64 = originalPath && checkPath.convert(originalPath); checkPath( path64, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError ); return this._t(path64, cache, checkUnignored, slices); } _t(path64, cache, checkUnignored, slices) { if (path64 in cache) { return cache[path64]; } if (!slices) { slices = path64.split(SLASH2); } slices.pop(); if (!slices.length) { return cache[path64] = this._testOne(path64, checkUnignored); } const parent = this._t( slices.join(SLASH2) + SLASH2, cache, checkUnignored, slices ); return cache[path64] = parent.ignored ? parent : this._testOne(path64, checkUnignored); } ignores(path64) { return this._test(path64, this._ignoreCache, false).ignored; } createFilter() { return (path64) => !this.ignores(path64); } filter(paths) { return makeArray(paths).filter(this.createFilter()); } // @returns {TestResult} test(path64) { return this._test(path64, this._testCache, true); } }; var factory = (options) => new Ignore(options); var isPathValid = (path64) => checkPath(path64 && checkPath.convert(path64), path64, RETURN_FALSE); factory.isPathValid = isPathValid; factory.default = factory; module2.exports = factory; if ( // Detect `process` so that it can run in browsers. typeof process !== "undefined" && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === "win32") ) { const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/"); checkPath.convert = makePosix; const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i; checkPath.isNotRelative = (path64) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path64) || isNotRelative(path64); } } }); // ../../node_modules/.pnpm/acorn-import-phases@1.0.4_acorn@8.16.0/node_modules/acorn-import-phases/src/plugin.cjs var require_plugin = __commonJS({ "../../node_modules/.pnpm/acorn-import-phases@1.0.4_acorn@8.16.0/node_modules/acorn-import-phases/src/plugin.cjs"(exports2) { "use strict"; exports2.plugin = function acornImportPhase(options, Parser3, tt) { return class extends Parser3 { parseImport(node) { this._phase = null; const result = super.parseImport(node); if (this._phase) { node.phase = this._phase; } return result; } parseImportSpecifiers() { let phase = options.defer !== false && this.isContextual("defer") ? "defer" : options.source !== false && this.isContextual("source") ? "source" : null; if (!phase) return super.parseImportSpecifiers(); const phaseId = this.parseIdent(); if (this.isContextual("from") || this.type === tt.comma) { const defaultSpecifier = this.startNodeAt(phaseId.start, phaseId.loc && phaseId.loc.start); defaultSpecifier.local = phaseId; this.checkLValSimple( phaseId, /* BIND_LEXICAL */ 2 ); const nodes = [this.finishNode(defaultSpecifier, "ImportDefaultSpecifier")]; if (this.eat(tt.comma)) { if (this.type !== tt.star && this.type !== tt.braceL) { this.unexpected(); } nodes.push(...super.parseImportSpecifiers()); } return nodes; } this._phase = phase; if (phase === "defer") { if (this.type !== tt.star) { this.raiseRecoverable( phaseId.start, "'import defer' can only be used with namespace imports ('import defer * as identifierName from ...')." ); } } else if (phase === "source") { if (this.type !== tt.name) { this.raiseRecoverable( phaseId.start, "'import source' can only be used with direct identifier specifier imports." ); } } const specifiers = super.parseImportSpecifiers(); if (phase === "source" && specifiers.some((s) => s.type !== "ImportDefaultSpecifier")) { this.raiseRecoverable( phaseId.start, `'import source' can only be used with direct identifier specifier imports ('import source identifierName from ...').` ); } return specifiers; } parseExprImport(forNew) { const node = super.parseExprImport(forNew); if (node.type === "MetaProperty" && (node.property.name === "defer" || node.property.name === "source")) { if (this.type === tt.parenL) { const dynImport = this.parseDynamicImport(this.startNodeAt(node.start, node.loc && node.loc.start)); dynImport.phase = node.property.name; return dynImport; } else { this.raiseRecoverable( node.start, `'import.${node.property.name}' can only be used in a dynamic import.` ); } } return node; } parseImportMeta(node) { this.next(); var containsEsc = this.containsEsc; node.property = this.parseIdent(true); const { name } = node.property; if (name !== "meta" && name !== "defer" && name !== "source") { this.raiseRecoverable( node.property.start, "The only valid meta property for import is 'import.meta'" ); } if (containsEsc) { this.raiseRecoverable( node.start, `'import.${name}' must not contain escaped characters` ); } if (name === "meta" && this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere) { this.raiseRecoverable( node.start, "Cannot use 'import.meta' outside a module" ); } return this.finishNode(node, "MetaProperty"); } }; }; } }); // ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js var require_src = __commonJS({ "../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports2, module2) { "use strict"; var ESC2 = "\x1B"; var CSI = `${ESC2}[`; var beep = "\x07"; var cursor = { to(x, y) { if (!y) return `${CSI}${x + 1}G`; return `${CSI}${y + 1};${x + 1}H`; }, move(x, y) { let ret = ""; if (x < 0) ret += `${CSI}${-x}D`; else if (x > 0) ret += `${CSI}${x}C`; if (y < 0) ret += `${CSI}${-y}A`; else if (y > 0) ret += `${CSI}${y}B`; return ret; }, up: (count = 1) => `${CSI}${count}A`, down: (count = 1) => `${CSI}${count}B`, forward: (count = 1) => `${CSI}${count}C`, backward: (count = 1) => `${CSI}${count}D`, nextLine: (count = 1) => `${CSI}E`.repeat(count), prevLine: (count = 1) => `${CSI}F`.repeat(count), left: `${CSI}G`, hide: `${CSI}?25l`, show: `${CSI}?25h`, save: `${ESC2}7`, restore: `${ESC2}8` }; var scroll = { up: (count = 1) => `${CSI}S`.repeat(count), down: (count = 1) => `${CSI}T`.repeat(count) }; var erase2 = { screen: `${CSI}2J`, up: (count = 1) => `${CSI}1J`.repeat(count), down: (count = 1) => `${CSI}J`.repeat(count), line: `${CSI}2K`, lineEnd: `${CSI}K`, lineStart: `${CSI}1K`, lines(count) { let clear = ""; for (let i2 = 0; i2 < count; i2++) clear += this.line + (i2 < count - 1 ? cursor.up() : ""); if (count) clear += cursor.left; return clear; } }; module2.exports = { cursor, scroll, erase: erase2, beep }; } }); // ../../node_modules/.pnpm/mimic-fn@2.1.0/node_modules/mimic-fn/index.js var require_mimic_fn = __commonJS({ "../../node_modules/.pnpm/mimic-fn@2.1.0/node_modules/mimic-fn/index.js"(exports2, module2) { "use strict"; var mimicFn = (to, from) => { for (const prop of Reflect.ownKeys(from)) { Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop)); } return to; }; module2.exports = mimicFn; module2.exports.default = mimicFn; } }); // ../../node_modules/.pnpm/onetime@5.1.2/node_modules/onetime/index.js var require_onetime = __commonJS({ "../../node_modules/.pnpm/onetime@5.1.2/node_modules/onetime/index.js"(exports2, module2) { "use strict"; var mimicFn = require_mimic_fn(); var calledFunctions = /* @__PURE__ */ new WeakMap(); var onetime2 = (function_, options = {}) => { if (typeof function_ !== "function") { throw new TypeError("Expected a function"); } let returnValue; let callCount = 0; const functionName = function_.displayName || function_.name || "<anonymous>"; const onetime3 = function(...arguments_) { calledFunctions.set(onetime3, ++callCount); if (callCount === 1) { returnValue = function_.apply(this, arguments_); function_ = null; } else if (options.throw === true) { throw new Error(`Function \`${functionName}\` can only be called once`); } return returnValue; }; mimicFn(onetime3, function_); calledFunctions.set(onetime3, callCount); return onetime3; }; module2.exports = onetime2; module2.exports.default = onetime2; module2.exports.callCount = (function_) => { if (!calledFunctions.has(function_)) { throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`); } return calledFunctions.get(function_); }; } }); // ../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js var require_signals2 = __commonJS({ "../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js"(exports2, module2) { "use strict"; module2.exports = [ "SIGABRT", "SIGALRM", "SIGHUP", "SIGINT", "SIGTERM" ]; if (process.platform !== "win32") { module2.exports.push( "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT" // should detect profiler and enable/disable accordingly. // see #21 // 'SIGPROF' ); } if (process.platform === "linux") { module2.exports.push( "SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT", "SIGUNUSED" ); } } }); // ../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js var require_signal_exit2 = __commonJS({ "../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js"(exports2, module2) { "use strict"; var process7 = global.process; var processOk = function(process8) { return process8 && typeof process8 === "object" && typeof process8.removeListener === "function" && typeof process8.emit === "function" && typeof process8.reallyExit === "function" && typeof process8.listeners === "function" && typeof process8.kill === "function" && typeof process8.pid === "number" && typeof process8.on === "function"; }; if (!processOk(process7)) { module2.exports = function() { return function() { }; }; } else { assert25 = require("assert"); signals = require_signals2(); isWin = /^win/i.test(process7.platform); EE = require("events"); if (typeof EE !== "function") { EE = EE.EventEmitter; } if (process7.__signal_exit_emitter__) { emitter = process7.__signal_exit_emitter__; } else { emitter = process7.__signal_exit_emitter__ = new EE(); emitter.count = 0; emitter.emitted = {}; } if (!emitter.infinite) { emitter.setMaxListeners(Infinity); emitter.infinite = true; } module2.exports = function(cb, opts) { if (!processOk(global.process)) { return function() { }; } assert25.equal(typeof cb, "function", "a callback must be provided for exit handler"); if (loaded === false) { load(); } var ev = "exit"; if (opts && opts.alwaysLast) { ev = "afterexit"; } var remove = function() { emitter.removeListener(ev, cb); if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) { unload(); } }; emitter.on(ev, cb); return remove; }; unload = function unload2() { if (!loaded || !processOk(global.process)) { return; } loaded = false; signals.forEach(function(sig) { try { process7.removeListener(sig, sigListeners[sig]); } catch (er) { } }); process7.emit = originalProcessEmit; process7.reallyExit = originalProcessReallyExit; emitter.count -= 1; }; module2.exports.unload = unload; emit = function emit2(event, code, signal) { if (emitter.emitted[event]) { return; } emitter.emitted[event] = true; emitter.emit(event, code, signal); }; sigListeners = {}; signals.forEach(function(sig) { sigListeners[sig] = function listener() { if (!processOk(global.process)) { return; } var listeners = process7.listeners(sig); if (listeners.length === emitter.count) { unload(); emit("exit", null, sig); emit("afterexit", null, sig); if (isWin && sig === "SIGHUP") { sig = "SIGINT"; } process7.kill(process7.pid, sig); } }; }); module2.exports.signals = function() { return signals; }; loaded = false; load = function load2() { if (loaded || !processOk(global.process)) { return; } loaded = true; emitter.count += 1; signals = signals.filter(function(sig) { try { process7.on(sig, sigListeners[sig]); return true; } catch (er) { return false; } }); process7.emit = processEmit; process7.reallyExit = processReallyExit; }; module2.exports.load = load; originalProcessReallyExit = process7.reallyExit; processReallyExit = function processReallyExit2(code) { if (!processOk(global.process)) { return; } process7.exitCode = code || /* istanbul ignore next */ 0; emit("exit", process7.exitCode, null); emit("afterexit", process7.exitCode, null); originalProcessReallyExit.call(process7, process7.exitCode); }; originalProcessEmit = process7.emit; processEmit = function processEmit2(ev, arg) { if (ev === "exit" && processOk(global.process)) { if (arg !== void 0) { process7.exitCode = arg; } var ret = originalProcessEmit.apply(this, arguments); emit("exit", process7.exitCode, null); emit("afterexit", process7.exitCode, null); return ret; } else { return originalProcessEmit.apply(this, arguments); } }; } var assert25; var signals; var isWin; var EE; var emitter; var unload; var emit; var sigListeners; var loaded; var load; var originalProcessReallyExit; var processReallyExit; var originalProcessEmit; var processEmit; } }); // ../../node_modules/.pnpm/eastasianwidth@0.2.0/node_modules/eastasianwidth/eastasianwidth.js var require_eastasianwidth = __commonJS({ "../../node_modules/.pnpm/eastasianwidth@0.2.0/node_modules/eastasianwidth/eastasianwidth.js"(exports2, module2) { "use strict"; var eaw = {}; if ("undefined" == typeof module2) { window.eastasianwidth = eaw; } else { module2.exports = eaw; } eaw.eastAsianWidth = function(character) { var x = character.charCodeAt(0); var y = character.length == 2 ? character.charCodeAt(1) : 0; var codePoint = x; if (55296 <= x && x <= 56319 && (56320 <= y && y <= 57343)) { x &= 1023; y &= 1023; codePoint = x << 10 | y; codePoint += 65536; } if (12288 == codePoint || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510) { return "F"; } if (8361 == codePoint || 65377 <= codePoint && codePoint <= 65470 || 65474 <= codePoint && codePoint <= 65479 || 65482 <= codePoint && codePoint <= 65487 || 65490 <= codePoint && codePoint <= 65495 || 65498 <= codePoint && codePoint <= 65500 || 65512 <= codePoint && codePoint <= 65518) { return "H"; } if (4352 <= codePoint && codePoint <= 4447 || 4515 <= codePoint && codePoint <= 4519 || 4602 <= codePoint && codePoint <= 4607 || 9001 <= codePoint && codePoint <= 9002 || 11904 <= codePoint && codePoint <= 11929 || 11931 <= codePoint && codePoint <= 12019 || 12032 <= codePoint && codePoint <= 12245 || 12272 <= codePoint && codePoint <= 12283 || 12289 <= codePoint && codePoint <= 12350 || 12353 <= codePoint && codePoint <= 12438 || 12441 <= codePoint && codePoint <= 12543 || 12549 <= codePoint && codePoint <= 12589 || 12593 <= codePoint && codePoint <= 12686 || 12688 <= codePoint && codePoint <= 12730 || 12736 <= codePoint && codePoint <= 12771 || 12784 <= codePoint && codePoint <= 12830 || 12832 <= codePoint && codePoint <= 12871 || 12880 <= codePoint && codePoint <= 13054 || 13056 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42124 || 42128 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 55216 <= codePoint && codePoint <= 55238 || 55243 <= codePoint && codePoint <= 55291 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65106 || 65108 <= codePoint && codePoint <= 65126 || 65128 <= codePoint && codePoint <= 65131 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127490 || 127504 <= codePoint && codePoint <= 127546 || 127552 <= codePoint && codePoint <= 127560 || 127568 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 194367 || 177984 <= codePoint && codePoint <= 196605 || 196608 <= codePoint && codePoint <= 262141) { return "W"; } if (32 <= codePoint && codePoint <= 126 || 162 <= codePoint && codePoint <= 163 || 165 <= codePoint && codePoint <= 166 || 172 == codePoint || 175 == codePoint || 10214 <= codePoint && codePoint <= 10221 || 10629 <= codePoint && codePoint <= 10630) { return "Na"; } if (161 == codePoint || 164 == codePoint || 167 <= codePoint && codePoint <= 168 || 170 == codePoint || 173 <= codePoint && codePoint <= 174 || 176 <= codePoint && codePoint <= 180 || 182 <= codePoint && codePoint <= 186 || 188 <= codePoint && codePoint <= 191 || 198 == codePoint || 208 == codePoint || 215 <= codePoint && codePoint <= 216 || 222 <= codePoint && codePoint <= 225 || 230 == codePoint || 232 <= codePoint && codePoint <= 234 || 236 <= codePoint && codePoint <= 237 || 240 == codePoint || 242 <= codePoint && codePoint <= 243 || 247 <= codePoint && codePoint <= 250 || 252 == codePoint || 254 == codePoint || 257 == codePoint || 273 == codePoint || 275 == codePoint || 283 == codePoint || 294 <= codePoint && codePoint <= 295 || 299 == codePoint || 305 <= codePoint && codePoint <= 307 || 312 == codePoint || 319 <= codePoint && codePoint <= 322 || 324 == codePoint || 328 <= codePoint && codePoint <= 331 || 333 == codePoint || 338 <= codePoint && codePoint <= 339 || 358 <= codePoint && codePoint <= 359 || 363 == codePoint || 462 == codePoint || 464 == codePoint || 466 == codePoint || 468 == codePoint || 470 == codePoint || 472 == codePoint || 474 == codePoint || 476 == codePoint || 593 == codePoint || 609 == codePoint || 708 == codePoint || 711 == codePoint || 713 <= codePoint && codePoint <= 715 || 717 == codePoint || 720 == codePoint || 728 <= codePoint && codePoint <= 731 || 733 == codePoint || 735 == codePoint || 768 <= codePoint && codePoint <= 879 || 913 <= codePoint && codePoint <= 929 || 931 <= codePoint && codePoint <= 937 || 945 <= codePoint && codePoint <= 961 || 963 <= codePoint && codePoint <= 969 || 1025 == codePoint || 1040 <= codePoint && codePoint <= 1103 || 1105 == codePoint || 8208 == codePoint || 8211 <= codePoint && codePoint <= 8214 || 8216 <= codePoint && codePoint <= 8217 || 8220 <= codePoint && codePoint <= 8221 || 8224 <= codePoint && codePoint <= 8226 || 8228 <= codePoint && codePoint <= 8231 || 8240 == codePoint || 8242 <= codePoint && codePoint <= 8243 || 8245 == codePoint || 8251 == codePoint || 8254 == code