UNPKG

@storybook/test-runner

Version:
1,509 lines (1,486 loc) • 634 kB
#!/usr/bin/env node import ESM_COMPAT_Module from "node:module"; import { fileURLToPath as ESM_COMPAT_fileURLToPath } from 'node:url'; const __filename = ESM_COMPAT_fileURLToPath(import.meta.url); const require = ESM_COMPAT_Module.createRequire(import.meta.url); 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 __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __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'); }); var __commonJS = (cb, mod) => function __require2() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; 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 )); // node_modules/can-bind-to-host/dist/index.js var require_dist = __commonJS({ "node_modules/can-bind-to-host/dist/index.js"(exports) { "use strict"; var __importDefault = exports && exports.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.canBindToHost = void 0; var net_1 = __importDefault(__require("net")); var canBindToHost2 = /* @__PURE__ */ __name(function(host, port) { if (host === void 0) { host = "0.0.0.0"; } if (port === void 0) { port = 0; } return new Promise(function(res) { if (port >= 0 && port <= 65535) { var server_1 = net_1.default.createServer().listen({ host, port }).addListener("error", function() { return res(false); }).addListener("listening", function() { server_1.close(); res(true); }); } else res(false); }); }, "canBindToHost"); exports.canBindToHost = canBindToHost2; exports.default = canBindToHost2; } }); // node_modules/balanced-match/index.js var require_balanced_match = __commonJS({ "node_modules/balanced-match/index.js"(exports, module) { "use strict"; module.exports = balanced; function balanced(a, b, str) { if (a instanceof RegExp) a = maybeMatch(a, str); if (b instanceof RegExp) b = maybeMatch(b, str); var r = range(a, b, str); return r && { start: r[0], end: r[1], pre: str.slice(0, r[0]), body: str.slice(r[0] + a.length, r[1]), post: str.slice(r[1] + b.length) }; } __name(balanced, "balanced"); function maybeMatch(reg, str) { var m = str.match(reg); return m ? m[0] : null; } __name(maybeMatch, "maybeMatch"); balanced.range = range; function range(a, b, str) { var begs, beg, left, right, result; var ai = str.indexOf(a); var bi = str.indexOf(b, ai + 1); var i = ai; if (ai >= 0 && bi > 0) { if (a === b) { return [ ai, bi ]; } begs = []; left = str.length; while (i >= 0 && !result) { if (i == ai) { begs.push(i); ai = str.indexOf(a, i + 1); } else if (begs.length == 1) { result = [ begs.pop(), bi ]; } else { beg = begs.pop(); if (beg < left) { left = beg; right = bi; } bi = str.indexOf(b, i + 1); } i = ai < bi && ai >= 0 ? ai : bi; } if (begs.length) { result = [ left, right ]; } } return result; } __name(range, "range"); } }); // node_modules/brace-expansion/index.js var require_brace_expansion = __commonJS({ "node_modules/brace-expansion/index.js"(exports, module) { "use strict"; var balanced = require_balanced_match(); module.exports = expandTop; var escSlash = "\0SLASH" + Math.random() + "\0"; var escOpen = "\0OPEN" + Math.random() + "\0"; var escClose = "\0CLOSE" + Math.random() + "\0"; var escComma = "\0COMMA" + Math.random() + "\0"; var escPeriod = "\0PERIOD" + Math.random() + "\0"; function numeric(str) { return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0); } __name(numeric, "numeric"); function escapeBraces(str) { return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod); } __name(escapeBraces, "escapeBraces"); function unescapeBraces(str) { return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join("."); } __name(unescapeBraces, "unescapeBraces"); function parseCommaParts(str) { if (!str) return [ "" ]; var parts = []; var m = balanced("{", "}", str); if (!m) return str.split(","); var pre = m.pre; var body = m.body; var post = m.post; var p = pre.split(","); p[p.length - 1] += "{" + body + "}"; var postParts = parseCommaParts(post); if (post.length) { p[p.length - 1] += postParts.shift(); p.push.apply(p, postParts); } parts.push.apply(parts, p); return parts; } __name(parseCommaParts, "parseCommaParts"); function expandTop(str) { if (!str) return []; if (str.substr(0, 2) === "{}") { str = "\\{\\}" + str.substr(2); } return expand2(escapeBraces(str), true).map(unescapeBraces); } __name(expandTop, "expandTop"); function embrace(str) { return "{" + str + "}"; } __name(embrace, "embrace"); function isPadded(el) { return /^-?0\d/.test(el); } __name(isPadded, "isPadded"); function lte(i, y) { return i <= y; } __name(lte, "lte"); function gte(i, y) { return i >= y; } __name(gte, "gte"); function expand2(str, isTop) { var expansions = []; var m = balanced("{", "}", str); if (!m) return [ str ]; var pre = m.pre; var post = m.post.length ? expand2(m.post, false) : [ "" ]; if (/\$$/.test(m.pre)) { for (var k = 0; k < post.length; k++) { var expansion = pre + "{" + m.body + "}" + post[k]; expansions.push(expansion); } } else { var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); var isSequence = isNumericSequence || isAlphaSequence; var isOptions = m.body.indexOf(",") >= 0; if (!isSequence && !isOptions) { if (m.post.match(/,.*\}/)) { str = m.pre + "{" + m.body + escClose + m.post; return expand2(str); } return [ str ]; } var n; if (isSequence) { n = m.body.split(/\.\./); } else { n = parseCommaParts(m.body); if (n.length === 1) { n = expand2(n[0], false).map(embrace); if (n.length === 1) { return post.map(function(p) { return m.pre + n[0] + p; }); } } } var N; if (isSequence) { var x = numeric(n[0]); var y = numeric(n[1]); var width = Math.max(n[0].length, n[1].length); var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1; var test = lte; var reverse = y < x; if (reverse) { incr *= -1; test = gte; } var pad = n.some(isPadded); N = []; for (var i = x; test(i, y); i += incr) { var c; if (isAlphaSequence) { c = String.fromCharCode(i); if (c === "\\") c = ""; } else { c = String(i); if (pad) { var need = width - c.length; if (need > 0) { var z = new Array(need + 1).join("0"); if (i < 0) c = "-" + z + c.slice(1); else c = z + c; } } } N.push(c); } } else { N = []; for (var j = 0; j < n.length; j++) { N.push.apply(N, expand2(n[j], false)); } } for (var j = 0; j < N.length; j++) { for (var k = 0; k < post.length; k++) { var expansion = pre + N[j] + post[k]; if (!isTop || isSequence || expansion) expansions.push(expansion); } } } return expansions; } __name(expand2, "expand"); } }); // node_modules/crypto-random-string/index.js var require_crypto_random_string = __commonJS({ "node_modules/crypto-random-string/index.js"(exports, module) { "use strict"; var crypto = __require("crypto"); module.exports = (length) => { if (!Number.isFinite(length)) { throw new TypeError("Expected a finite number"); } return crypto.randomBytes(Math.ceil(length / 2)).toString("hex").slice(0, length); }; } }); // node_modules/unique-string/index.js var require_unique_string = __commonJS({ "node_modules/unique-string/index.js"(exports, module) { "use strict"; var cryptoRandomString = require_crypto_random_string(); module.exports = () => cryptoRandomString(32); } }); // node_modules/temp-dir/index.js var require_temp_dir = __commonJS({ "node_modules/temp-dir/index.js"(exports, module) { "use strict"; var fs2 = __require("fs"); var os = __require("os"); var tempDirectorySymbol = Symbol.for("__RESOLVED_TEMP_DIRECTORY__"); if (!global[tempDirectorySymbol]) { Object.defineProperty(global, tempDirectorySymbol, { value: fs2.realpathSync(os.tmpdir()) }); } module.exports = global[tempDirectorySymbol]; } }); // node_modules/is-stream/index.js var require_is_stream = __commonJS({ "node_modules/is-stream/index.js"(exports, module) { "use strict"; var isStream2 = /* @__PURE__ */ __name((stream2) => stream2 !== null && typeof stream2 === "object" && typeof stream2.pipe === "function", "isStream"); isStream2.writable = (stream2) => isStream2(stream2) && stream2.writable !== false && typeof stream2._write === "function" && typeof stream2._writableState === "object"; isStream2.readable = (stream2) => isStream2(stream2) && stream2.readable !== false && typeof stream2._read === "function" && typeof stream2._readableState === "object"; isStream2.duplex = (stream2) => isStream2.writable(stream2) && isStream2.readable(stream2); isStream2.transform = (stream2) => isStream2.duplex(stream2) && typeof stream2._transform === "function"; module.exports = isStream2; } }); // node_modules/globby/node_modules/array-union/index.js var require_array_union = __commonJS({ "node_modules/globby/node_modules/array-union/index.js"(exports, module) { "use strict"; module.exports = (...arguments_) => { return [ ...new Set([].concat(...arguments_)) ]; }; } }); // node_modules/merge2/index.js var require_merge2 = __commonJS({ "node_modules/merge2/index.js"(exports, module) { "use strict"; var Stream2 = __require("stream"); var PassThrough = Stream2.PassThrough; var slice = Array.prototype.slice; module.exports = merge2; function merge2() { const streamsQueue = []; const args = slice.call(arguments); let merging = false; let options = args[args.length - 1]; if (options && !Array.isArray(options) && options.pipe == null) { args.pop(); } else { options = {}; } const doEnd = options.end !== false; const doPipeError = options.pipeError === true; if (options.objectMode == null) { options.objectMode = true; } if (options.highWaterMark == null) { options.highWaterMark = 64 * 1024; } const mergedStream = PassThrough(options); function addStream() { for (let i = 0, len = arguments.length; i < len; i++) { streamsQueue.push(pauseStreams(arguments[i], options)); } mergeStream(); return this; } __name(addStream, "addStream"); function mergeStream() { if (merging) { return; } merging = true; let streams = streamsQueue.shift(); if (!streams) { process.nextTick(endStream); return; } if (!Array.isArray(streams)) { streams = [ streams ]; } let pipesCount = streams.length + 1; function next() { if (--pipesCount > 0) { return; } merging = false; mergeStream(); } __name(next, "next"); function pipe(stream2) { function onend() { stream2.removeListener("merge2UnpipeEnd", onend); stream2.removeListener("end", onend); if (doPipeError) { stream2.removeListener("error", onerror); } next(); } __name(onend, "onend"); function onerror(err) { mergedStream.emit("error", err); } __name(onerror, "onerror"); if (stream2._readableState.endEmitted) { return next(); } stream2.on("merge2UnpipeEnd", onend); stream2.on("end", onend); if (doPipeError) { stream2.on("error", onerror); } stream2.pipe(mergedStream, { end: false }); stream2.resume(); } __name(pipe, "pipe"); for (let i = 0; i < streams.length; i++) { pipe(streams[i]); } next(); } __name(mergeStream, "mergeStream"); function endStream() { merging = false; mergedStream.emit("queueDrain"); if (doEnd) { mergedStream.end(); } } __name(endStream, "endStream"); mergedStream.setMaxListeners(0); mergedStream.add = addStream; mergedStream.on("unpipe", function(stream2) { stream2.emit("merge2UnpipeEnd"); }); if (args.length) { addStream.apply(null, args); } return mergedStream; } __name(merge2, "merge2"); function pauseStreams(streams, options) { if (!Array.isArray(streams)) { if (!streams._readableState && streams.pipe) { streams = streams.pipe(PassThrough(options)); } if (!streams._readableState || !streams.pause || !streams.pipe) { throw new Error("Only readable stream can be merged."); } streams.pause(); } else { for (let i = 0, len = streams.length; i < len; i++) { streams[i] = pauseStreams(streams[i], options); } } return streams; } __name(pauseStreams, "pauseStreams"); } }); // node_modules/fast-glob/out/utils/array.js var require_array = __commonJS({ "node_modules/fast-glob/out/utils/array.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.splitWhen = exports.flatten = void 0; function flatten(items) { return items.reduce((collection, item) => [].concat(collection, item), []); } __name(flatten, "flatten"); exports.flatten = flatten; function splitWhen(items, predicate) { const result = [ [] ]; let groupIndex = 0; for (const item of items) { if (predicate(item)) { groupIndex++; result[groupIndex] = []; } else { result[groupIndex].push(item); } } return result; } __name(splitWhen, "splitWhen"); exports.splitWhen = splitWhen; } }); // node_modules/fast-glob/out/utils/errno.js var require_errno = __commonJS({ "node_modules/fast-glob/out/utils/errno.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isEnoentCodeError = void 0; function isEnoentCodeError(error2) { return error2.code === "ENOENT"; } __name(isEnoentCodeError, "isEnoentCodeError"); exports.isEnoentCodeError = isEnoentCodeError; } }); // node_modules/fast-glob/out/utils/fs.js var require_fs = __commonJS({ "node_modules/fast-glob/out/utils/fs.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createDirentFromStats = void 0; var DirentFromStats = class DirentFromStats { static { __name(this, "DirentFromStats"); } constructor(name, stats) { this.name = name; this.isBlockDevice = stats.isBlockDevice.bind(stats); this.isCharacterDevice = stats.isCharacterDevice.bind(stats); this.isDirectory = stats.isDirectory.bind(stats); this.isFIFO = stats.isFIFO.bind(stats); this.isFile = stats.isFile.bind(stats); this.isSocket = stats.isSocket.bind(stats); this.isSymbolicLink = stats.isSymbolicLink.bind(stats); } }; function createDirentFromStats(name, stats) { return new DirentFromStats(name, stats); } __name(createDirentFromStats, "createDirentFromStats"); exports.createDirentFromStats = createDirentFromStats; } }); // node_modules/fast-glob/out/utils/path.js var require_path = __commonJS({ "node_modules/fast-glob/out/utils/path.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertPosixPathToPattern = exports.convertWindowsPathToPattern = exports.convertPathToPattern = exports.escapePosixPath = exports.escapeWindowsPath = exports.escape = exports.removeLeadingDotSegment = exports.makeAbsolute = exports.unixify = void 0; var os = __require("os"); var path2 = __require("path"); var IS_WINDOWS_PLATFORM = os.platform() === "win32"; var LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; var POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g; var WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()[\]{}]|^!|[!+@](?=\())/g; var DOS_DEVICE_PATH_RE = /^\\\\([.?])/; var WINDOWS_BACKSLASHES_RE = /\\(?![!()+@[\]{}])/g; function unixify(filepath) { return filepath.replace(/\\/g, "/"); } __name(unixify, "unixify"); exports.unixify = unixify; function makeAbsolute(cwd2, filepath) { return path2.resolve(cwd2, filepath); } __name(makeAbsolute, "makeAbsolute"); exports.makeAbsolute = makeAbsolute; function removeLeadingDotSegment(entry) { if (entry.charAt(0) === ".") { const secondCharactery = entry.charAt(1); if (secondCharactery === "/" || secondCharactery === "\\") { return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT); } } return entry; } __name(removeLeadingDotSegment, "removeLeadingDotSegment"); exports.removeLeadingDotSegment = removeLeadingDotSegment; exports.escape = IS_WINDOWS_PLATFORM ? escapeWindowsPath : escapePosixPath; function escapeWindowsPath(pattern) { return pattern.replace(WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE, "\\$2"); } __name(escapeWindowsPath, "escapeWindowsPath"); exports.escapeWindowsPath = escapeWindowsPath; function escapePosixPath(pattern) { return pattern.replace(POSIX_UNESCAPED_GLOB_SYMBOLS_RE, "\\$2"); } __name(escapePosixPath, "escapePosixPath"); exports.escapePosixPath = escapePosixPath; exports.convertPathToPattern = IS_WINDOWS_PLATFORM ? convertWindowsPathToPattern : convertPosixPathToPattern; function convertWindowsPathToPattern(filepath) { return escapeWindowsPath(filepath).replace(DOS_DEVICE_PATH_RE, "//$1").replace(WINDOWS_BACKSLASHES_RE, "/"); } __name(convertWindowsPathToPattern, "convertWindowsPathToPattern"); exports.convertWindowsPathToPattern = convertWindowsPathToPattern; function convertPosixPathToPattern(filepath) { return escapePosixPath(filepath); } __name(convertPosixPathToPattern, "convertPosixPathToPattern"); exports.convertPosixPathToPattern = convertPosixPathToPattern; } }); // node_modules/is-extglob/index.js var require_is_extglob = __commonJS({ "node_modules/is-extglob/index.js"(exports, module) { "use strict"; module.exports = /* @__PURE__ */ __name(function isExtglob(str) { if (typeof str !== "string" || str === "") { return false; } var match2; while (match2 = /(\\).|([@?!+*]\(.*\))/g.exec(str)) { if (match2[2]) return true; str = str.slice(match2.index + match2[0].length); } return false; }, "isExtglob"); } }); // node_modules/is-glob/index.js var require_is_glob = __commonJS({ "node_modules/is-glob/index.js"(exports, module) { "use strict"; var isExtglob = require_is_extglob(); var chars = { "{": "}", "(": ")", "[": "]" }; var strictCheck = /* @__PURE__ */ __name(function(str) { if (str[0] === "!") { return true; } var index = 0; var pipeIndex = -2; var closeSquareIndex = -2; var closeCurlyIndex = -2; var closeParenIndex = -2; var backSlashIndex = -2; while (index < str.length) { if (str[index] === "*") { return true; } if (str[index + 1] === "?" && /[\].+)]/.test(str[index])) { return true; } if (closeSquareIndex !== -1 && str[index] === "[" && str[index + 1] !== "]") { if (closeSquareIndex < index) { closeSquareIndex = str.indexOf("]", index); } if (closeSquareIndex > index) { if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) { return true; } backSlashIndex = str.indexOf("\\", index); if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) { return true; } } } if (closeCurlyIndex !== -1 && str[index] === "{" && str[index + 1] !== "}") { closeCurlyIndex = str.indexOf("}", index); if (closeCurlyIndex > index) { backSlashIndex = str.indexOf("\\", index); if (backSlashIndex === -1 || backSlashIndex > closeCurlyIndex) { return true; } } } if (closeParenIndex !== -1 && str[index] === "(" && str[index + 1] === "?" && /[:!=]/.test(str[index + 2]) && str[index + 3] !== ")") { closeParenIndex = str.indexOf(")", index); if (closeParenIndex > index) { backSlashIndex = str.indexOf("\\", index); if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) { return true; } } } if (pipeIndex !== -1 && str[index] === "(" && str[index + 1] !== "|") { if (pipeIndex < index) { pipeIndex = str.indexOf("|", index); } if (pipeIndex !== -1 && str[pipeIndex + 1] !== ")") { closeParenIndex = str.indexOf(")", pipeIndex); if (closeParenIndex > pipeIndex) { backSlashIndex = str.indexOf("\\", pipeIndex); if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) { return true; } } } } if (str[index] === "\\") { var open = str[index + 1]; index += 2; var close = chars[open]; if (close) { var n = str.indexOf(close, index); if (n !== -1) { index = n + 1; } } if (str[index] === "!") { return true; } } else { index++; } } return false; }, "strictCheck"); var relaxedCheck = /* @__PURE__ */ __name(function(str) { if (str[0] === "!") { return true; } var index = 0; while (index < str.length) { if (/[*?{}()[\]]/.test(str[index])) { return true; } if (str[index] === "\\") { var open = str[index + 1]; index += 2; var close = chars[open]; if (close) { var n = str.indexOf(close, index); if (n !== -1) { index = n + 1; } } if (str[index] === "!") { return true; } } else { index++; } } return false; }, "relaxedCheck"); module.exports = /* @__PURE__ */ __name(function isGlob(str, options) { if (typeof str !== "string" || str === "") { return false; } if (isExtglob(str)) { return true; } var check = strictCheck; if (options && options.strict === false) { check = relaxedCheck; } return check(str); }, "isGlob"); } }); // node_modules/glob-parent/index.js var require_glob_parent = __commonJS({ "node_modules/glob-parent/index.js"(exports, module) { "use strict"; var isGlob = require_is_glob(); var pathPosixDirname = __require("path").posix.dirname; var isWin32 = __require("os").platform() === "win32"; var slash = "/"; var backslash = /\\/g; var enclosure = /[\{\[].*[\}\]]$/; var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/; var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g; module.exports = /* @__PURE__ */ __name(function globParent(str, opts) { var options = Object.assign({ flipBackslashes: true }, opts); if (options.flipBackslashes && isWin32 && str.indexOf(slash) < 0) { str = str.replace(backslash, slash); } if (enclosure.test(str)) { str += slash; } str += "a"; do { str = pathPosixDirname(str); } while (isGlob(str) || globby.test(str)); return str.replace(escaped, "$1"); }, "globParent"); } }); // node_modules/braces/lib/utils.js var require_utils = __commonJS({ "node_modules/braces/lib/utils.js"(exports) { "use strict"; exports.isInteger = (num) => { if (typeof num === "number") { return Number.isInteger(num); } if (typeof num === "string" && num.trim() !== "") { return Number.isInteger(Number(num)); } return false; }; exports.find = (node, type) => node.nodes.find((node2) => node2.type === type); exports.exceedsLimit = (min, max, step = 1, limit) => { if (limit === false) return false; if (!exports.isInteger(min) || !exports.isInteger(max)) return false; return (Number(max) - Number(min)) / Number(step) >= limit; }; exports.escapeNode = (block, n = 0, type) => { const node = block.nodes[n]; if (!node) return; if (type && node.type === type || node.type === "open" || node.type === "close") { if (node.escaped !== true) { node.value = "\\" + node.value; node.escaped = true; } } }; exports.encloseBrace = (node) => { if (node.type !== "brace") return false; if (node.commas >> 0 + node.ranges >> 0 === 0) { node.invalid = true; return true; } return false; }; exports.isInvalidBrace = (block) => { if (block.type !== "brace") return false; if (block.invalid === true || block.dollar) return true; if (block.commas >> 0 + block.ranges >> 0 === 0) { block.invalid = true; return true; } if (block.open !== true || block.close !== true) { block.invalid = true; return true; } return false; }; exports.isOpenOrClose = (node) => { if (node.type === "open" || node.type === "close") { return true; } return node.open === true || node.close === true; }; exports.reduce = (nodes) => nodes.reduce((acc, node) => { if (node.type === "text") acc.push(node.value); if (node.type === "range") node.type = "text"; return acc; }, []); exports.flatten = (...args) => { const result = []; const flat = /* @__PURE__ */ __name((arr) => { for (let i = 0; i < arr.length; i++) { const ele = arr[i]; if (Array.isArray(ele)) { flat(ele); continue; } if (ele !== void 0) { result.push(ele); } } return result; }, "flat"); flat(args); return result; }; } }); // node_modules/braces/lib/stringify.js var require_stringify = __commonJS({ "node_modules/braces/lib/stringify.js"(exports, module) { "use strict"; var utils = require_utils(); module.exports = (ast, options = {}) => { const stringify = /* @__PURE__ */ __name((node, parent = {}) => { const invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent); const invalidNode = node.invalid === true && options.escapeInvalid === true; let output = ""; if (node.value) { if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) { return "\\" + node.value; } return node.value; } if (node.value) { return node.value; } if (node.nodes) { for (const child of node.nodes) { output += stringify(child); } } return output; }, "stringify"); return stringify(ast); }; } }); // node_modules/is-number/index.js var require_is_number = __commonJS({ "node_modules/is-number/index.js"(exports, module) { "use strict"; module.exports = function(num) { if (typeof num === "number") { return num - num === 0; } if (typeof num === "string" && num.trim() !== "") { return Number.isFinite ? Number.isFinite(+num) : isFinite(+num); } return false; }; } }); // node_modules/to-regex-range/index.js var require_to_regex_range = __commonJS({ "node_modules/to-regex-range/index.js"(exports, module) { "use strict"; var isNumber = require_is_number(); var toRegexRange = /* @__PURE__ */ __name((min, max, options) => { if (isNumber(min) === false) { throw new TypeError("toRegexRange: expected the first argument to be a number"); } if (max === void 0 || min === max) { return String(min); } if (isNumber(max) === false) { throw new TypeError("toRegexRange: expected the second argument to be a number."); } let opts = { relaxZeros: true, ...options }; if (typeof opts.strictZeros === "boolean") { opts.relaxZeros = opts.strictZeros === false; } let relax = String(opts.relaxZeros); let shorthand = String(opts.shorthand); let capture = String(opts.capture); let wrap = String(opts.wrap); let cacheKey = min + ":" + max + "=" + relax + shorthand + capture + wrap; if (toRegexRange.cache.hasOwnProperty(cacheKey)) { return toRegexRange.cache[cacheKey].result; } let a = Math.min(min, max); let b = Math.max(min, max); if (Math.abs(a - b) === 1) { let result = min + "|" + max; if (opts.capture) { return `(${result})`; } if (opts.wrap === false) { return result; } return `(?:${result})`; } let isPadded = hasPadding(min) || hasPadding(max); let state = { min, max, a, b }; let positives = []; let negatives = []; if (isPadded) { state.isPadded = isPadded; state.maxLen = String(state.max).length; } if (a < 0) { let newMin = b < 0 ? Math.abs(b) : 1; negatives = splitToPatterns(newMin, Math.abs(a), state, opts); a = state.a = 0; } if (b >= 0) { positives = splitToPatterns(a, b, state, opts); } state.negatives = negatives; state.positives = positives; state.result = collatePatterns(negatives, positives, opts); if (opts.capture === true) { state.result = `(${state.result})`; } else if (opts.wrap !== false && positives.length + negatives.length > 1) { state.result = `(?:${state.result})`; } toRegexRange.cache[cacheKey] = state; return state.result; }, "toRegexRange"); function collatePatterns(neg, pos, options) { let onlyNegative = filterPatterns(neg, pos, "-", false, options) || []; let onlyPositive = filterPatterns(pos, neg, "", false, options) || []; let intersected = filterPatterns(neg, pos, "-?", true, options) || []; let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive); return subpatterns.join("|"); } __name(collatePatterns, "collatePatterns"); function splitToRanges(min, max) { let nines = 1; let zeros = 1; let stop = countNines(min, nines); let stops = /* @__PURE__ */ new Set([ max ]); while (min <= stop && stop <= max) { stops.add(stop); nines += 1; stop = countNines(min, nines); } stop = countZeros(max + 1, zeros) - 1; while (min < stop && stop <= max) { stops.add(stop); zeros += 1; stop = countZeros(max + 1, zeros) - 1; } stops = [ ...stops ]; stops.sort(compare); return stops; } __name(splitToRanges, "splitToRanges"); function rangeToPattern(start, stop, options) { if (start === stop) { return { pattern: start, count: [], digits: 0 }; } let zipped = zip(start, stop); let digits = zipped.length; let pattern = ""; let count = 0; for (let i = 0; i < digits; i++) { let [startDigit, stopDigit] = zipped[i]; if (startDigit === stopDigit) { pattern += startDigit; } else if (startDigit !== "0" || stopDigit !== "9") { pattern += toCharacterClass(startDigit, stopDigit, options); } else { count++; } } if (count) { pattern += options.shorthand === true ? "\\d" : "[0-9]"; } return { pattern, count: [ count ], digits }; } __name(rangeToPattern, "rangeToPattern"); function splitToPatterns(min, max, tok, options) { let ranges = splitToRanges(min, max); let tokens = []; let start = min; let prev; for (let i = 0; i < ranges.length; i++) { let max2 = ranges[i]; let obj = rangeToPattern(String(start), String(max2), options); let zeros = ""; if (!tok.isPadded && prev && prev.pattern === obj.pattern) { if (prev.count.length > 1) { prev.count.pop(); } prev.count.push(obj.count[0]); prev.string = prev.pattern + toQuantifier(prev.count); start = max2 + 1; continue; } if (tok.isPadded) { zeros = padZeros(max2, tok, options); } obj.string = zeros + obj.pattern + toQuantifier(obj.count); tokens.push(obj); start = max2 + 1; prev = obj; } return tokens; } __name(splitToPatterns, "splitToPatterns"); function filterPatterns(arr, comparison, prefix, intersection, options) { let result = []; for (let ele of arr) { let { string } = ele; if (!intersection && !contains(comparison, "string", string)) { result.push(prefix + string); } if (intersection && contains(comparison, "string", string)) { result.push(prefix + string); } } return result; } __name(filterPatterns, "filterPatterns"); function zip(a, b) { let arr = []; for (let i = 0; i < a.length; i++) arr.push([ a[i], b[i] ]); return arr; } __name(zip, "zip"); function compare(a, b) { return a > b ? 1 : b > a ? -1 : 0; } __name(compare, "compare"); function contains(arr, key, val) { return arr.some((ele) => ele[key] === val); } __name(contains, "contains"); function countNines(min, len) { return Number(String(min).slice(0, -len) + "9".repeat(len)); } __name(countNines, "countNines"); function countZeros(integer, zeros) { return integer - integer % Math.pow(10, zeros); } __name(countZeros, "countZeros"); function toQuantifier(digits) { let [start = 0, stop = ""] = digits; if (stop || start > 1) { return `{${start + (stop ? "," + stop : "")}}`; } return ""; } __name(toQuantifier, "toQuantifier"); function toCharacterClass(a, b, options) { return `[${a}${b - a === 1 ? "" : "-"}${b}]`; } __name(toCharacterClass, "toCharacterClass"); function hasPadding(str) { return /^-?(0+)\d/.test(str); } __name(hasPadding, "hasPadding"); function padZeros(value, tok, options) { if (!tok.isPadded) { return value; } let diff = Math.abs(tok.maxLen - String(value).length); let relax = options.relaxZeros !== false; switch (diff) { case 0: return ""; case 1: return relax ? "0?" : "0"; case 2: return relax ? "0{0,2}" : "00"; default: { return relax ? `0{0,${diff}}` : `0{${diff}}`; } } } __name(padZeros, "padZeros"); toRegexRange.cache = {}; toRegexRange.clearCache = () => toRegexRange.cache = {}; module.exports = toRegexRange; } }); // node_modules/fill-range/index.js var require_fill_range = __commonJS({ "node_modules/fill-range/index.js"(exports, module) { "use strict"; var util = __require("util"); var toRegexRange = require_to_regex_range(); var isObject = /* @__PURE__ */ __name((val) => val !== null && typeof val === "object" && !Array.isArray(val), "isObject"); var transform = /* @__PURE__ */ __name((toNumber) => { return (value) => toNumber === true ? Number(value) : String(value); }, "transform"); var isValidValue = /* @__PURE__ */ __name((value) => { return typeof value === "number" || typeof value === "string" && value !== ""; }, "isValidValue"); var isNumber = /* @__PURE__ */ __name((num) => Number.isInteger(+num), "isNumber"); var zeros = /* @__PURE__ */ __name((input) => { let value = `${input}`; let index = -1; if (value[0] === "-") value = value.slice(1); if (value === "0") return false; while (value[++index] === "0") ; return index > 0; }, "zeros"); var stringify = /* @__PURE__ */ __name((start, end, options) => { if (typeof start === "string" || typeof end === "string") { return true; } return options.stringify === true; }, "stringify"); var pad = /* @__PURE__ */ __name((input, maxLength, toNumber) => { if (maxLength > 0) { let dash = input[0] === "-" ? "-" : ""; if (dash) input = input.slice(1); input = dash + input.padStart(dash ? maxLength - 1 : maxLength, "0"); } if (toNumber === false) { return String(input); } return input; }, "pad"); var toMaxLen = /* @__PURE__ */ __name((input, maxLength) => { let negative = input[0] === "-" ? "-" : ""; if (negative) { input = input.slice(1); maxLength--; } while (input.length < maxLength) input = "0" + input; return negative ? "-" + input : input; }, "toMaxLen"); var toSequence = /* @__PURE__ */ __name((parts, options, maxLen) => { parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0); parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0); let prefix = options.capture ? "" : "?:"; let positives = ""; let negatives = ""; let result; if (parts.positives.length) { positives = parts.positives.map((v) => toMaxLen(String(v), maxLen)).join("|"); } if (parts.negatives.length) { negatives = `-(${prefix}${parts.negatives.map((v) => toMaxLen(String(v), maxLen)).join("|")})`; } if (positives && negatives) { result = `${positives}|${negatives}`; } else { result = positives || negatives; } if (options.wrap) { return `(${prefix}${result})`; } return result; }, "toSequence"); var toRange = /* @__PURE__ */ __name((a, b, isNumbers, options) => { if (isNumbers) { return toRegexRange(a, b, { wrap: false, ...options }); } let start = String.fromCharCode(a); if (a === b) return start; let stop = String.fromCharCode(b); return `[${start}-${stop}]`; }, "toRange"); var toRegex = /* @__PURE__ */ __name((start, end, options) => { if (Array.isArray(start)) { let wrap = options.wrap === true; let prefix = options.capture ? "" : "?:"; return wrap ? `(${prefix}${start.join("|")})` : start.join("|"); } return toRegexRange(start, end, options); }, "toRegex"); var rangeError = /* @__PURE__ */ __name((...args) => { return new RangeError("Invalid range arguments: " + util.inspect(...args)); }, "rangeError"); var invalidRange = /* @__PURE__ */ __name((start, end, options) => { if (options.strictRanges === true) throw rangeError([ start, end ]); return []; }, "invalidRange"); var invalidStep = /* @__PURE__ */ __name((step, options) => { if (options.strictRanges === true) { throw new TypeError(`Expected step "${step}" to be a number`); } return []; }, "invalidStep"); var fillNumbers = /* @__PURE__ */ __name((start, end, step = 1, options = {}) => { let a = Number(start); let b = Number(end); if (!Number.isInteger(a) || !Number.isInteger(b)) { if (options.strictRanges === true) throw rangeError([ start, end ]); return []; } if (a === 0) a = 0; if (b === 0) b = 0; let descending = a > b; let startString = String(start); let endString = String(end); let stepString = String(step); step = Math.max(Math.abs(step), 1); let padded = zeros(startString) || zeros(endString) || zeros(stepString); let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0; let toNumber = padded === false && stringify(start, end, options) === false; let format2 = options.transform || transform(toNumber); if (options.toRegex && step === 1) { return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options); } let parts = { negatives: [], positives: [] }; let push = /* @__PURE__ */ __name((num) => parts[num < 0 ? "negatives" : "positives"].push(Math.abs(num)), "push"); let range = []; let index = 0; while (descending ? a >= b : a <= b) { if (options.toRegex === true && step > 1) { push(a); } else { range.push(pad(format2(a, index), maxLen, toNumber)); } a = descending ? a - step : a + step; index++; } if (options.toRegex === true) { return step > 1 ? toSequence(parts, options, maxLen) : toRegex(range, null, { wrap: false, ...options }); } return range; }, "fillNumbers"); var fillLetters = /* @__PURE__ */ __name((start, end, step = 1, options = {}) => { if (!isNumber(start) && start.length > 1 || !isNumber(end) && end.length > 1) { return invalidRange(start, end, options); } let format2 = options.transform || ((val) => String.fromCharCode(val)); let a = `${start}`.charCodeAt(0); let b = `${end}`.charCodeAt(0); let descending = a > b; let min = Math.min(a, b); let max = Math.max(a, b); if (options.toRegex && step === 1) { return toRange(min, max, false, options); } let range = []; let index = 0; while (descending ? a >= b : a <= b) { range.push(format2(a, index)); a = descending ? a - step : a + step; index++; } if (options.toRegex === true) { return toRegex(range, null, { wrap: false, options }); } return range; }, "fillLetters"); var fill = /* @__PURE__ */ __name((start, end, step, options = {}) => { if (end == null && isValidValue(start)) { return [ start ]; } if (!isValidValue(start) || !isValidValue(end)) { return invalidRange(start, end, options); } if (typeof step === "function") { return fill(start, end, 1, { transform: step }); } if (isObject(step)) { return fill(start, end, 0, step); } let opts = { ...options }; if (opts.capture === true) opts.wrap = true; step = step || opts.step || 1; if (!isNumber(step)) { if (step != null && !isObject(step)) return invalidStep(step, opts); return fill(start, end, 1, step); } if (isNumber(start) && isNumber(end)) { return fillNumbers(start, end, step, opts); } return fillLetters(start, end, Math.max(Math.abs(step), 1), opts); }, "fill"); module.exports = fill; } }); // node_modules/braces/lib/compile.js var require_compile = __commonJS({ "node_modules/braces/lib/compile.js"(exports, module) { "use strict"; var fill = require_fill_range(); var utils = require_utils(); var compile = /* @__PURE__ */ __name((ast, options = {}) => { const walk = /* @__PURE__ */ __name((node, parent = {}) => { const invalidBlock = utils.isInvalidBrace(parent); const invalidNode = node.invalid === true && options.escapeInvalid === true; const invalid = invalidBlock === true || invalidNode === true; const prefix = options.escapeInvalid === true ? "\\" : ""; let output = ""; if (node.isOpen === true) { return prefix + node.value; } if (node.isClose === true) { console.log("node.isClose", prefix, node.value); return prefix + node.value; } if (node.type === "open") { return invalid ? prefix + node.value : "("; } if (node.type === "close") { return invalid ? prefix + node.value : ")"; } if (node.type === "comma") { return node.prev.type === "comma" ? "" : invalid ? node.value : "|"; } if (node.value) { return node.value; } if (node.nodes && node.ranges > 0) { const args = utils.reduce(node.nodes); const range = fill(...args, { ...options, wrap: false, toRegex: true, strictZeros: true }); if (range.length !== 0) { return args.length > 1 && range.length > 1 ? `(${range})` : range; } } if (node.nodes) { for (const child of node.nodes) { output += walk(child, node); } } return output; }, "walk"); return walk(ast); }, "compile"); module.exports = compile; } }); // node_modules/braces/lib/expand.js var require_expand = __commonJS({ "node_modules/braces/lib/expand.js"(exports, module) { "use strict"; var fill = require_fill_range(); var stringify = require_stringify(); var utils = require_utils(); var append = /* @__PURE__ */ __name((queue = "", stash = "", enclose = false) => { const result = []; queue = [].concat(queue); stash = [].concat(stash); if (!stash.length) return queue; if (!queue.length) { return enclose ? utils.flatten(stash).map((ele) => `{${ele}}`) : stash; } for (const item of queue) { if (Array.isArray(item)) { for (const value of item) { result.push(append(value, stash, enclose)); } } else { for (let