@storybook/test-runner
Version:
Test runner for Storybook stories
10,958 lines • 351 kB
JavaScript
"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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[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);
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateSet = (obj, member, value, setter) => {
__accessCheck(obj, member, "write to private field");
setter ? setter.call(obj, value) : member.set(obj, value);
return value;
};
var __privateWrapper = (obj, member, setter, getter) => ({
set _(value) {
__privateSet(obj, member, value, setter);
},
get _() {
return __privateGet(obj, member, getter);
}
});
// node_modules/find-up/node_modules/p-try/index.js
var require_p_try = __commonJS({
"node_modules/find-up/node_modules/p-try/index.js"(exports, module2) {
"use strict";
var pTry = /* @__PURE__ */ __name((fn, ...arguments_) => new Promise((resolve3) => {
resolve3(fn(...arguments_));
}), "pTry");
module2.exports = pTry;
module2.exports.default = pTry;
}
});
// node_modules/find-up/node_modules/p-limit/index.js
var require_p_limit = __commonJS({
"node_modules/find-up/node_modules/p-limit/index.js"(exports, module2) {
"use strict";
var pTry = require_p_try();
var pLimit2 = /* @__PURE__ */ __name((concurrency) => {
if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
return Promise.reject(new TypeError("Expected `concurrency` to be a number from 1 and up"));
}
const queue = [];
let activeCount = 0;
const next = /* @__PURE__ */ __name(() => {
activeCount--;
if (queue.length > 0) {
queue.shift()();
}
}, "next");
const run = /* @__PURE__ */ __name((fn, resolve3, ...args) => {
activeCount++;
const result = pTry(fn, ...args);
resolve3(result);
result.then(next, next);
}, "run");
const enqueue = /* @__PURE__ */ __name((fn, resolve3, ...args) => {
if (activeCount < concurrency) {
run(fn, resolve3, ...args);
} else {
queue.push(run.bind(null, fn, resolve3, ...args));
}
}, "enqueue");
const generator = /* @__PURE__ */ __name((fn, ...args) => new Promise((resolve3) => enqueue(fn, resolve3, ...args)), "generator");
Object.defineProperties(generator, {
activeCount: {
get: () => activeCount
},
pendingCount: {
get: () => queue.length
},
clearQueue: {
value: () => {
queue.length = 0;
}
}
});
return generator;
}, "pLimit");
module2.exports = pLimit2;
module2.exports.default = pLimit2;
}
});
// node_modules/find-up/node_modules/p-locate/index.js
var require_p_locate = __commonJS({
"node_modules/find-up/node_modules/p-locate/index.js"(exports, module2) {
"use strict";
var pLimit2 = require_p_limit();
var EndError3 = /* @__PURE__ */ __name(class EndError extends Error {
constructor(value) {
super();
this.value = value;
}
}, "EndError");
var testElement2 = /* @__PURE__ */ __name(async (element, tester) => tester(await element), "testElement");
var finder2 = /* @__PURE__ */ __name(async (element) => {
const values = await Promise.all(element);
if (values[1] === true) {
throw new EndError3(values[0]);
}
return false;
}, "finder");
var pLocate2 = /* @__PURE__ */ __name(async (iterable, tester, options) => {
options = {
concurrency: Infinity,
preserveOrder: true,
...options
};
const limit = pLimit2(options.concurrency);
const items = [
...iterable
].map((element) => [
element,
limit(testElement2, element, tester)
]);
const checkLimit = pLimit2(options.preserveOrder ? 1 : Infinity);
try {
await Promise.all(items.map((element) => checkLimit(finder2, element)));
} catch (error) {
if (error instanceof EndError3) {
return error.value;
}
throw error;
}
}, "pLocate");
module2.exports = pLocate2;
module2.exports.default = pLocate2;
}
});
// node_modules/find-up/node_modules/locate-path/index.js
var require_locate_path = __commonJS({
"node_modules/find-up/node_modules/locate-path/index.js"(exports, module2) {
"use strict";
var path5 = require("path");
var fs3 = require("fs");
var { promisify } = require("util");
var pLocate2 = require_p_locate();
var fsStat = promisify(fs3.stat);
var fsLStat = promisify(fs3.lstat);
var typeMappings2 = {
directory: "isDirectory",
file: "isFile"
};
function checkType2({ type }) {
if (type in typeMappings2) {
return;
}
throw new Error(`Invalid type specified: ${type}`);
}
__name(checkType2, "checkType");
var matchType2 = /* @__PURE__ */ __name((type, stat) => type === void 0 || stat[typeMappings2[type]](), "matchType");
module2.exports = async (paths, options) => {
options = {
cwd: process.cwd(),
type: "file",
allowSymlinks: true,
...options
};
checkType2(options);
const statFn = options.allowSymlinks ? fsStat : fsLStat;
return pLocate2(paths, async (path_) => {
try {
const stat = await statFn(path5.resolve(options.cwd, path_));
return matchType2(options.type, stat);
} catch (_) {
return false;
}
}, options);
};
module2.exports.sync = (paths, options) => {
options = {
cwd: process.cwd(),
allowSymlinks: true,
type: "file",
...options
};
checkType2(options);
const statFn = options.allowSymlinks ? fs3.statSync : fs3.lstatSync;
for (const path_ of paths) {
try {
const stat = statFn(path5.resolve(options.cwd, path_));
if (matchType2(options.type, stat)) {
return path_;
}
} catch (_) {
}
}
};
}
});
// node_modules/path-exists/index.js
var require_path_exists = __commonJS({
"node_modules/path-exists/index.js"(exports, module2) {
"use strict";
var fs3 = require("fs");
var { promisify } = require("util");
var pAccess = promisify(fs3.access);
module2.exports = async (path5) => {
try {
await pAccess(path5);
return true;
} catch (_) {
return false;
}
};
module2.exports.sync = (path5) => {
try {
fs3.accessSync(path5);
return true;
} catch (_) {
return false;
}
};
}
});
// node_modules/find-up/index.js
var require_find_up = __commonJS({
"node_modules/find-up/index.js"(exports, module2) {
"use strict";
var path5 = require("path");
var locatePath2 = require_locate_path();
var pathExists2 = require_path_exists();
var stop = Symbol("findUp.stop");
module2.exports = async (name, options = {}) => {
let directory = path5.resolve(options.cwd || "");
const { root } = path5.parse(directory);
const paths = [].concat(name);
const runMatcher = /* @__PURE__ */ __name(async (locateOptions) => {
if (typeof name !== "function") {
return locatePath2(paths, locateOptions);
}
const foundPath = await name(locateOptions.cwd);
if (typeof foundPath === "string") {
return locatePath2([
foundPath
], locateOptions);
}
return foundPath;
}, "runMatcher");
while (true) {
const foundPath = await runMatcher({
...options,
cwd: directory
});
if (foundPath === stop) {
return;
}
if (foundPath) {
return path5.resolve(directory, foundPath);
}
if (directory === root) {
return;
}
directory = path5.dirname(directory);
}
};
module2.exports.sync = (name, options = {}) => {
let directory = path5.resolve(options.cwd || "");
const { root } = path5.parse(directory);
const paths = [].concat(name);
const runMatcher = /* @__PURE__ */ __name((locateOptions) => {
if (typeof name !== "function") {
return locatePath2.sync(paths, locateOptions);
}
const foundPath = name(locateOptions.cwd);
if (typeof foundPath === "string") {
return locatePath2.sync([
foundPath
], locateOptions);
}
return foundPath;
}, "runMatcher");
while (true) {
const foundPath = runMatcher({
...options,
cwd: directory
});
if (foundPath === stop) {
return;
}
if (foundPath) {
return path5.resolve(directory, foundPath);
}
if (directory === root) {
return;
}
directory = path5.dirname(directory);
}
};
module2.exports.exists = pathExists2;
module2.exports.sync.exists = pathExists2.sync;
module2.exports.stop = stop;
}
});
// node_modules/is-arrayish/index.js
var require_is_arrayish = __commonJS({
"node_modules/is-arrayish/index.js"(exports, module2) {
"use strict";
module2.exports = /* @__PURE__ */ __name(function isArrayish(obj) {
if (!obj) {
return false;
}
return obj instanceof Array || Array.isArray(obj) || obj.length >= 0 && obj.splice instanceof Function;
}, "isArrayish");
}
});
// node_modules/error-ex/index.js
var require_error_ex = __commonJS({
"node_modules/error-ex/index.js"(exports, module2) {
"use strict";
var util = require("util");
var isArrayish = require_is_arrayish();
var errorEx = /* @__PURE__ */ __name(function errorEx2(name, properties) {
if (!name || name.constructor !== String) {
properties = name || {};
name = Error.name;
}
var errorExError = /* @__PURE__ */ __name(function ErrorEXError(message) {
if (!this) {
return new ErrorEXError(message);
}
message = message instanceof Error ? message.message : message || this.message;
Error.call(this, message);
Error.captureStackTrace(this, errorExError);
this.name = name;
Object.defineProperty(this, "message", {
configurable: true,
enumerable: false,
get: function() {
var newMessage = message.split(/\r?\n/g);
for (var key in properties) {
if (!properties.hasOwnProperty(key)) {
continue;
}
var modifier = properties[key];
if ("message" in modifier) {
newMessage = modifier.message(this[key], newMessage) || newMessage;
if (!isArrayish(newMessage)) {
newMessage = [
newMessage
];
}
}
}
return newMessage.join("\n");
},
set: function(v) {
message = v;
}
});
var overwrittenStack = null;
var stackDescriptor = Object.getOwnPropertyDescriptor(this, "stack");
var stackGetter = stackDescriptor.get;
var stackValue = stackDescriptor.value;
delete stackDescriptor.value;
delete stackDescriptor.writable;
stackDescriptor.set = function(newstack) {
overwrittenStack = newstack;
};
stackDescriptor.get = function() {
var stack = (overwrittenStack || (stackGetter ? stackGetter.call(this) : stackValue)).split(/\r?\n+/g);
if (!overwrittenStack) {
stack[0] = this.name + ": " + this.message;
}
var lineCount = 1;
for (var key in properties) {
if (!properties.hasOwnProperty(key)) {
continue;
}
var modifier = properties[key];
if ("line" in modifier) {
var line = modifier.line(this[key]);
if (line) {
stack.splice(lineCount++, 0, " " + line);
}
}
if ("stack" in modifier) {
modifier.stack(this[key], stack);
}
}
return stack.join("\n");
};
Object.defineProperty(this, "stack", stackDescriptor);
}, "ErrorEXError");
if (Object.setPrototypeOf) {
Object.setPrototypeOf(errorExError.prototype, Error.prototype);
Object.setPrototypeOf(errorExError, Error);
} else {
util.inherits(errorExError, Error);
}
return errorExError;
}, "errorEx");
errorEx.append = function(str, def) {
return {
message: function(v, message) {
v = v || def;
if (v) {
message[0] += " " + str.replace("%s", v.toString());
}
return message;
}
};
};
errorEx.line = function(str, def) {
return {
line: function(v) {
v = v || def;
if (v) {
return str.replace("%s", v.toString());
}
return null;
}
};
};
module2.exports = errorEx;
}
});
// node_modules/json-parse-even-better-errors/index.js
var require_json_parse_even_better_errors = __commonJS({
"node_modules/json-parse-even-better-errors/index.js"(exports, module2) {
"use strict";
var hexify = /* @__PURE__ */ __name((char) => {
const h = char.charCodeAt(0).toString(16).toUpperCase();
return "0x" + (h.length % 2 ? "0" : "") + h;
}, "hexify");
var parseError = /* @__PURE__ */ __name((e, txt, context) => {
if (!txt) {
return {
message: e.message + " while parsing empty string",
position: 0
};
}
const badToken = e.message.match(/^Unexpected token (.) .*position\s+(\d+)/i);
const errIdx = badToken ? +badToken[2] : e.message.match(/^Unexpected end of JSON.*/i) ? txt.length - 1 : null;
const msg = badToken ? e.message.replace(/^Unexpected token ./, `Unexpected token ${JSON.stringify(badToken[1])} (${hexify(badToken[1])})`) : e.message;
if (errIdx !== null && errIdx !== void 0) {
const start = errIdx <= context ? 0 : errIdx - context;
const end = errIdx + context >= txt.length ? txt.length : errIdx + context;
const slice = (start === 0 ? "" : "...") + txt.slice(start, end) + (end === txt.length ? "" : "...");
const near = txt === slice ? "" : "near ";
return {
message: msg + ` while parsing ${near}${JSON.stringify(slice)}`,
position: errIdx
};
} else {
return {
message: msg + ` while parsing '${txt.slice(0, context * 2)}'`,
position: 0
};
}
}, "parseError");
var JSONParseError = /* @__PURE__ */ __name(class JSONParseError extends SyntaxError {
constructor(er, txt, context, caller) {
context = context || 20;
const metadata = parseError(er, txt, context);
super(metadata.message);
Object.assign(this, metadata);
this.code = "EJSONPARSE";
this.systemError = er;
Error.captureStackTrace(this, caller || this.constructor);
}
get name() {
return this.constructor.name;
}
set name(n) {
}
get [Symbol.toStringTag]() {
return this.constructor.name;
}
}, "JSONParseError");
var kIndent = Symbol.for("indent");
var kNewline = Symbol.for("newline");
var formatRE = /^\s*[{\[]((?:\r?\n)+)([\s\t]*)/;
var emptyRE = /^(?:\{\}|\[\])((?:\r?\n)+)?$/;
var parseJson = /* @__PURE__ */ __name((txt, reviver, context) => {
const parseText = stripBOM(txt);
context = context || 20;
try {
const [, newline = "\n", indent = " "] = parseText.match(emptyRE) || parseText.match(formatRE) || [
,
"",
""
];
const result = JSON.parse(parseText, reviver);
if (result && typeof result === "object") {
result[kNewline] = newline;
result[kIndent] = indent;
}
return result;
} catch (e) {
if (typeof txt !== "string" && !Buffer.isBuffer(txt)) {
const isEmptyArray = Array.isArray(txt) && txt.length === 0;
throw Object.assign(new TypeError(`Cannot parse ${isEmptyArray ? "an empty array" : String(txt)}`), {
code: "EJSONPARSE",
systemError: e
});
}
throw new JSONParseError(e, parseText, context, parseJson);
}
}, "parseJson");
var stripBOM = /* @__PURE__ */ __name((txt) => String(txt).replace(/^\uFEFF/, ""), "stripBOM");
module2.exports = parseJson;
parseJson.JSONParseError = JSONParseError;
parseJson.noExceptions = (txt, reviver) => {
try {
return JSON.parse(stripBOM(txt), reviver);
} catch (e) {
}
};
}
});
// node_modules/lines-and-columns/build/index.js
var require_build = __commonJS({
"node_modules/lines-and-columns/build/index.js"(exports) {
"use strict";
exports.__esModule = true;
exports.LinesAndColumns = void 0;
var LF = "\n";
var CR = "\r";
var LinesAndColumns = (
/** @class */
function() {
function LinesAndColumns2(string) {
this.string = string;
var offsets = [
0
];
for (var offset = 0; offset < string.length; ) {
switch (string[offset]) {
case LF:
offset += LF.length;
offsets.push(offset);
break;
case CR:
offset += CR.length;
if (string[offset] === LF) {
offset += LF.length;
}
offsets.push(offset);
break;
default:
offset++;
break;
}
}
this.offsets = offsets;
}
__name(LinesAndColumns2, "LinesAndColumns");
LinesAndColumns2.prototype.locationForIndex = function(index) {
if (index < 0 || index > this.string.length) {
return null;
}
var line = 0;
var offsets = this.offsets;
while (offsets[line + 1] <= index) {
line++;
}
var column = index - offsets[line];
return {
line,
column
};
};
LinesAndColumns2.prototype.indexForLocation = function(location) {
var line = location.line, column = location.column;
if (line < 0 || line >= this.offsets.length) {
return null;
}
if (column < 0 || column > this.lengthOfLine(line)) {
return null;
}
return this.offsets[line] + column;
};
LinesAndColumns2.prototype.lengthOfLine = function(line) {
var offset = this.offsets[line];
var nextOffset = line === this.offsets.length - 1 ? this.string.length : this.offsets[line + 1];
return nextOffset - offset;
};
return LinesAndColumns2;
}()
);
exports.LinesAndColumns = LinesAndColumns;
exports["default"] = LinesAndColumns;
}
});
// node_modules/picocolors/picocolors.js
var require_picocolors = __commonJS({
"node_modules/picocolors/picocolors.js"(exports, module2) {
var p = process || {};
var argv = p.argv || [];
var env = p.env || {};
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
var formatter = /* @__PURE__ */ __name((open, close, replace = open) => (input) => {
let string = "" + input, index = string.indexOf(close, open.length);
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
}, "formatter");
var replaceClose = /* @__PURE__ */ __name((string, close, replace, index) => {
let result = "", cursor = 0;
do {
result += string.substring(cursor, index) + replace;
cursor = index + close.length;
index = string.indexOf(close, cursor);
} while (~index);
return result + string.substring(cursor);
}, "replaceClose");
var createColors = /* @__PURE__ */ __name((enabled = isColorSupported) => {
let f = enabled ? formatter : () => String;
return {
isColorSupported: enabled,
reset: f("\x1B[0m", "\x1B[0m"),
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
italic: f("\x1B[3m", "\x1B[23m"),
underline: f("\x1B[4m", "\x1B[24m"),
inverse: f("\x1B[7m", "\x1B[27m"),
hidden: f("\x1B[8m", "\x1B[28m"),
strikethrough: f("\x1B[9m", "\x1B[29m"),
black: f("\x1B[30m", "\x1B[39m"),
red: f("\x1B[31m", "\x1B[39m"),
green: f("\x1B[32m", "\x1B[39m"),
yellow: f("\x1B[33m", "\x1B[39m"),
blue: f("\x1B[34m", "\x1B[39m"),
magenta: f("\x1B[35m", "\x1B[39m"),
cyan: f("\x1B[36m", "\x1B[39m"),
white: f("\x1B[37m", "\x1B[39m"),
gray: f("\x1B[90m", "\x1B[39m"),
bgBlack: f("\x1B[40m", "\x1B[49m"),
bgRed: f("\x1B[41m", "\x1B[49m"),
bgGreen: f("\x1B[42m", "\x1B[49m"),
bgYellow: f("\x1B[43m", "\x1B[49m"),
bgBlue: f("\x1B[44m", "\x1B[49m"),
bgMagenta: f("\x1B[45m", "\x1B[49m"),
bgCyan: f("\x1B[46m", "\x1B[49m"),
bgWhite: f("\x1B[47m", "\x1B[49m"),
blackBright: f("\x1B[90m", "\x1B[39m"),
redBright: f("\x1B[91m", "\x1B[39m"),
greenBright: f("\x1B[92m", "\x1B[39m"),
yellowBright: f("\x1B[93m", "\x1B[39m"),
blueBright: f("\x1B[94m", "\x1B[39m"),
magentaBright: f("\x1B[95m", "\x1B[39m"),
cyanBright: f("\x1B[96m", "\x1B[39m"),
whiteBright: f("\x1B[97m", "\x1B[39m"),
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
bgRedBright: f("\x1B[101m", "\x1B[49m"),
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
};
}, "createColors");
module2.exports = createColors();
module2.exports.createColors = createColors;
}
});
// node_modules/js-tokens/index.js
var require_js_tokens = __commonJS({
"node_modules/js-tokens/index.js"(exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g;
exports.matchToToken = function(match) {
var token = {
type: "invalid",
value: match[0],
closed: void 0
};
if (match[1])
token.type = "string", token.closed = !!(match[3] || match[4]);
else if (match[5])
token.type = "comment";
else if (match[6])
token.type = "comment", token.closed = !!match[7];
else if (match[8])
token.type = "regex";
else if (match[9])
token.type = "number";
else if (match[10])
token.type = "name";
else if (match[11])
token.type = "punctuator";
else if (match[12])
token.type = "whitespace";
return token;
};
}
});
// node_modules/@babel/helper-validator-identifier/lib/identifier.js
var require_identifier = __commonJS({
"node_modules/@babel/helper-validator-identifier/lib/identifier.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isIdentifierChar = isIdentifierChar;
exports.isIdentifierName = isIdentifierName;
exports.isIdentifierStart = isIdentifierStart;
var nonASCIIidentifierStartChars = "\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC";
var nonASCIIidentifierChars = "\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65";
var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
var astralIdentifierStartCodes = [
0,
11,
2,
25,
2,
18,
2,
1,
2,
14,
3,
13,
35,
122,
70,
52,
268,
28,
4,
48,
48,
31,
14,
29,
6,
37,
11,
29,
3,
35,
5,
7,
2,
4,
43,
157,
19,
35,
5,
35,
5,
39,
9,
51,
13,
10,
2,
14,
2,
6,
2,
1,
2,
10,
2,
14,
2,
6,
2,
1,
4,
51,
13,
310,
10,
21,
11,
7,
25,
5,
2,
41,
2,
8,
70,
5,
3,
0,
2,
43,
2,
1,
4,
0,
3,
22,
11,
22,
10,
30,
66,
18,
2,
1,
11,
21,
11,
25,
71,
55,
7,
1,
65,
0,
16,
3,
2,
2,
2,
28,
43,
28,
4,
28,
36,
7,
2,
27,
28,
53,
11,
21,
11,
18,
14,
17,
111,
72,
56,
50,
14,
50,
14,
35,
39,
27,
10,
22,
251,
41,
7,
1,
17,
2,
60,
28,
11,
0,
9,
21,
43,
17,
47,
20,
28,
22,
13,
52,
58,
1,
3,
0,
14,
44,
33,
24,
27,
35,
30,
0,
3,
0,
9,
34,
4,
0,
13,
47,
15,
3,
22,
0,
2,
0,
36,
17,
2,
24,
20,
1,
64,
6,
2,
0,
2,
3,
2,
14,
2,
9,
8,
46,
39,
7,
3,
1,
3,
21,
2,
6,
2,
1,
2,
4,
4,
0,
19,
0,
13,
4,
31,
9,
2,
0,
3,
0,
2,
37,
2,
0,
26,
0,
2,
0,
45,
52,
19,
3,
21,
2,
31,
47,
21,
1,
2,
0,
185,
46,
42,
3,
37,
47,
21,
0,
60,
42,
14,
0,
72,
26,
38,
6,
186,
43,
117,
63,
32,
7,
3,
0,
3,
7,
2,
1,
2,
23,
16,
0,
2,
0,
95,
7,
3,
38,
17,
0,
2,
0,
29,
0,
11,
39,
8,
0,
22,
0,
12,
45,
20,
0,
19,
72,
200,
32,
32,
8,
2,
36,
18,
0,
50,
29,
113,
6,
2,
1,
2,
37,
22,
0,
26,
5,
2,
1,
2,
31,
15,
0,
328,
18,
16,
0,
2,
12,
2,
33,
125,
0,
80,
921,
103,
110,
18,
195,
2637,
96,
16,
1071,
18,
5,
26,
3994,
6,
582,
6842,
29,
1763,
568,
8,
30,
18,
78,
18,
29,
19,
47,
17,
3,
32,
20,
6,
18,
433,
44,
212,
63,
129,
74,
6,
0,
67,
12,
65,
1,
2,
0,
29,
6135,
9,
1237,
42,
9,
8936,
3,
2,
6,
2,
1,
2,
290,
16,
0,
30,
2,
3,
0,
15,
3,
9,
395,
2309,
106,
6,
12,
4,
8,
8,
9,
5991,
84,
2,
70,
2,
1,
3,
0,
3,
1,
3,
3,
2,
11,
2,
0,
2,
6,
2,
64,
2,
3,
3,
7,
2,
6,
2,
27,
2,
3,
2,
4,
2,
0,
4,
6,
2,
339,
3,
24,
2,
24,
2,
30,
2,
24,
2,
30,
2,
24,
2,
30,
2,
24,
2,
30,
2,
24,
2,
7,
1845,
30,
7,
5,
262,
61,
147,
44,
11,
6,
17,
0,
322,
29,
19,
43,
485,
27,
229,
29,
3,
0,
496,
6,
2,
3,
2,
1,
2,
14,
2,
196,
60,
67,
8,
0,
1205,
3,
2,
26,
2,
1,
2,
0,
3,
0,
2,
9,
2,
3,
2,
0,
2,
0,
7,
0,
5,
0,
2,
0,
2,
0,
2,
2,
2,
1,
2,
0,
3,
0,
2,
0,
2,
0,
2,
0,
2,
0,
2,
1,
2,
0,
3,
3,
2,
6,
2,
3,
2,
3,
2,
0,
2,
9,
2,
16,
6,
2,
2,
4,
2,
16,
4421,
42719,
33,
4153,
7,
221,
3,
5761,
15,
7472,
16,
621,
2467,
541,
1507,
4938,
6,
4191
];
var astralIdentifierCodes = [
509,
0,
227,
0,
150,
4,
294,
9,
1368,
2,
2,
1,
6,
3,
41,
2,
5,
0,
166,
1,
574,
3,
9,
9,
7,
9,
32,
4,
318,
1,
80,
3,
71,
10,
50,
3,
123,
2,
54,
14,
32,
10,
3,
1,
11,
3,
46,
10,
8,
0,
46,
9,
7,
2,
37,
13,
2,
9,
6,
1,
45,
0,
13,
2,
49,
13,
9,
3,
2,
11,
83,
11,
7,
0,
3,
0,
158,
11,
6,
9,
7,
3,
56,
1,
2,
6,
3,
1,
3,
2,
10,
0,
11,
1,
3,
6,
4,
4,
68,
8,
2,
0,
3,
0,
2,
3,
2,
4,
2,
0,
15,
1,
83,
17,
10,
9,
5,
0,
82,
19,
13,
9,
214,
6,
3,
8,
28,
1,
83,
16,
16,
9,
82,
12,
9,
9,
7,
19,
58,
14,
5,
9,
243,
14,
166,
9,
71,
5,
2,
1,
3,
3,
2,
0,
2,
1,
13,
9,
120,
6,
3,
6,
4,
0,
29,
9,
41,
6,
2,
3,
9,
0,
10,
10,
47,
15,
343,
9,
54,
7,
2,
7,
17,
9,
57,
21,
2,
13,
123,
5,
4,
0,
2,
1,
2,
6,
2,
0,
9,
9,
49,
4,
2,
1,
2,
4,
9,
9,
330,
3,
10,
1,
2,
0,
49,
6,
4,
4,
14,
10,
5350,
0,
7,
14,
11465,
27,
2343,
9,
87,
9,
39,
4,
60,
6,
26,
9,
535,
9,
470,
0,
2,
54,
8,
3,
82,
0,
12,
1,
19628,
1,
4178,
9,
519,
45,
3,
22,
543,
4,
4,
5,
9,
7,
3,
6,
31,
3,
149,
2,
1418,
49,
513,
54,
5,
49,
9,
0,
15,
0,
23,
4,
2,
14,
1361,
6,
2,
16,
3,
6,
2,
1,
2,
4,
101,
0,
161,
6,
10,
9,
357,
0,
62,
13,
499,
13,
245,
1,
2,
9,
726,
6,
110,
6,
6,
9,
4759,
9,
787719,
239
];
function isInAstralSet(code, set) {
let pos = 65536;
for (let i = 0, length = set.length; i < length; i += 2) {
pos += set[i];
if (pos > code)
return false;
pos += set[i + 1];
if (pos >= code)
return true;
}
return false;
}
__name(isInAstralSet, "isInAstralSet");
function isIdentifierStart(code) {
if (code < 65)
return code === 36;
if (code <= 90)
return true;
if (code < 97)
return code === 95;
if (code <= 122)
return true;
if (code <= 65535) {
return code >= 170 && nonASCIIidentifierStart.test(String.fromCharCode(code));
}
return isInAstralSet(code, astralIdentifierStartCodes);
}
__name(isIdentifierStart, "isIdentifierStart");
function isIdentifierChar(code) {
if (code < 48)
return code === 36;
if (code < 58)
return true;
if (code < 65)
return false;
if (code <= 90)
return true;
if (code < 97)
return code === 95;
if (code <= 122)
return true;
if (code <= 65535) {
return code >= 170 && nonASCIIidentifier.test(String.fromCharCode(code));
}
return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
}
__name(isIdentifierChar, "isIdentifierChar");
function isIdentifierName(name) {
let isFirst = true;
for (let i = 0; i < name.length; i++) {
let cp = name.charCodeAt(i);
if ((cp & 64512) === 55296 && i + 1 < name.length) {
const trail = name.charCodeAt(++i);
if ((trail & 64512) === 56320) {
cp = 65536 + ((cp & 1023) << 10) + (trail & 1023);
}
}
if (isFirst) {
isFirst = false;
if (!isIdentifierStart(cp)) {
return false;
}
} else if (!isIdentifierChar(cp)) {
return false;
}
}
return !isFirst;
}
__name(isIdentifierName, "isIdentifierName");
}
});
// node_modules/@babel/helper-validator-identifier/lib/keyword.js
var require_keyword = __commonJS({
"node_modules/@babel/helper-validator-identifier/lib/keyword.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isKeyword = isKeyword;
exports.isReservedWord = isReservedWord;
exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
exports.isStrictBindReservedWord = isStrictBindReservedWord;
exports.isStrictReservedWord = isStrictReservedWord;
var reservedWords = {
keyword: [
"break",
"case",
"catch",
"continue",
"debugger",
"default",
"do",
"else",
"finally",
"for",
"function",
"if",
"return",
"switch",
"throw",
"try",
"var",
"const",
"while",
"with",
"new",
"this",
"super",
"class",
"extends",
"export",
"import",
"null",
"true",
"false",
"in",
"instanceof",
"typeof",
"void",
"delete"
],
strict: [
"implements",
"interface",
"let",
"package",
"private",
"protected",
"public",
"static",
"yield"
],
strictBind: [
"eval",
"arguments"
]
};
var keywords = new Set(reservedWords.keyword);
var reservedWordsStrictSet = new Set(reservedWords.strict);
var reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
function isReservedWord(word, inModule) {
return inModule && word === "await" || word === "enum";
}
__name(isReservedWord, "isReservedWord");
function isStrictReservedWord(word, inModule) {
return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
}
__name(isStrictReservedWord, "isStrictReservedWord");
function isStrictBindOnlyReservedWord(word) {
return reservedWordsStrictBindSet.has(word);
}
__name(isStrictBindOnlyReservedWord, "isStrictBindOnlyReservedWord");
function isStrictBindReservedWord(word, inModule) {
return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
}
__name(isStrictBindReservedWord, "isStrictBindReservedWord");
function isKeyword(word) {
return keywords.has(word);
}
__name(isKeyword, "isKeyword");
}
});
// node_modules/@babel/helper-validator-identifier/lib/index.js
var require_lib = __commonJS({
"node_modules/@babel/helper-validator-identifier/lib/index.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "isIdentifierChar", {
enumerable: true,
get: function() {
return _identifier.isIdentifierChar;
}
});
Object.defineProperty(exports, "isIdentifierName", {
enumerable: true,
get: function() {
return _identifier.isIdentifierName;
}
});
Object.defineProperty(exports, "isIdentifierStart", {
enumerable: true,
get: function() {
return _identifier.isIdentifierStart;
}
});
Object.defineProperty(exports, "isKeyword", {
enumerable: true,
get: function() {
return _keyword.isKeyword;
}
});
Object.defineProperty(exports, "isReservedWord", {
enumerable: true,
get: function() {
return _keyword.isReservedWord;
}
});
Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
enumerable: true,
get: function() {
return _keyword.isStrictBindOnlyReservedWord;
}
});
Object.defineProperty(exports, "isStrictBindReservedWord", {
enumerable: true,
get: function() {
return _keyword.isStrictBindReservedWord;
}
});
Object.defineProperty(exports, "isStrictReservedWord", {
enumerable: true,
get: function() {
return _keyword.isStrictReservedWord;
}
});
var _identifier = require_identifier();
var _keyword = require_keyword();
}
});
// node_modules/@babel/code-frame/lib/index.js
var require_lib2 = __commonJS({
"node_modules/@babel/code-frame/lib/index.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var picocolors = require_picocolors();
var jsTokens = require_js_tokens();
var helperValidatorIdentifier = require_lib();
function isColorSupported() {
return typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? false : picocolors.isColorSupported;
}
__name(isColorSupported, "isColorSupported");
var compose = /* @__PURE__ */ __name((f, g) => (v) => f(g(v)), "compose");
function buildDefs(colors) {
return {
keyword: colors.cyan,
capitalized: colors.yellow,
jsxIdentifier: colors.yellow,
punctuator: colors.yellow,
number: colors.magenta,
string: colors.green,
regex: colors.magenta,
comment: colors.gray,
invalid: compose(compose(colors.white, colors.bgRed), colors.bold),
gutter: colors.gray,
marker: compose(colors.red, colors.bold),
message: compose(colors.red, colors.bold),
reset: colors.reset
};
}
__name(buildDefs, "buildDefs");
var defsOn = buildDefs(picocolors.createColors(true));
var defsOff = buildDefs(picocolors.createColors(false));
function getDefs(enabled) {
return enabled ? defsOn : defsOff;
}
__name(getDefs, "getDefs");
var sometimesKeywords = /* @__PURE__ */ new Set([
"as",
"async",
"from",
"get",
"of",
"set"
]);
var NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
var BRACKET = /^[()[\]{}]$/;
var tokenize;
{
const JSX_TAG = /^[a-z][\w-]*$/i;
const getTokenType = /* @__PURE__ */ __name(function(token, offset, text) {
if (token.type === "name") {
if (helperValidatorIdentifier.isKeyword(token.value) || helperValidatorIdentifier.isStrictReservedWord(token.value, true) || sometimesKeywords.has(token.value)) {
return "keyword";
}
if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.slice(offset - 2, offset) === "</")) {
return "jsxIdentifier";
}
if (token.value[0] !== token.value[0].toLowerCase()) {
return "capitalized";
}
}
if (token.type === "punctuator" && BRACKET.test(token.value)) {
return "bracket";
}
if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
return "punctuator";
}
return token.type;
}, "getTokenType");
tokenize = /* @__PURE__ */ __name(function* (text) {
let match;
while (match = jsTokens.default.exec(text)) {
const token = jsTokens.matchToToken(match);
yield {
type: getTokenType(token, match.index, text),
value: token.value
};
}
}, "tokenize");
}
function highlight(text) {
if (text === "")
return "";
const defs = getDefs(true);
let highlighted = "";
for (const { type, value } of tokenize(text)) {
if (type in defs) {
highlighted += value.split(NEWLINE$1).map((str) => defs[type](str)).join("\n");
} else {
highlighted += value;
}
}
return highlighted;
}
__name(highlight, "highlight");
var deprecationWarningShown = false;
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
function getMarkerLines(loc, source, opts) {
const startLoc = Object.assign({
column: 0,
line: -1
}, loc.start);
const endLoc = Object.assign({}, startLoc, loc.end);
const { linesAbove = 2, linesBelow = 3 } = opts || {};
const startLine = startLoc.line;
const startColumn = startLoc.column;
const endLine = endLoc.line;
const endColumn = endLoc.column;
let start = Math.max(startLine - (linesAbove + 1), 0);
let end = Math.min(source.length, endLine + linesBelow);
if (startLine === -1) {
start = 0;
}
if (endLine === -1) {
end = source.length;
}
const lineDiff = endLine - startLine;
const markerLines = {};
if (lineDiff) {
for (let i = 0; i <= lineDiff; i++) {
const lineNumber = i + startLine;
if (!startColumn) {
markerLines[lineNumber] = true;
} else if (i === 0) {
const sourceLength = source[lineNumber - 1].length;
markerLines[lineNumber] = [
startColumn,
sourceLength - startColumn + 1
];
} else if (i === lineDiff) {
markerLines[lineNumber] = [
0,
endColumn
];
} else {
const sourceLength = source[lineNumber - i].length;
markerLines[lineNumber] = [
0,
sourceLength
];
}
}
} else {
if (startColumn === endColumn) {
if (startColumn) {
markerLines[startLine] = [
startColumn,
0
];
} else {
markerLines[startLine] = true;
}
} else {
markerLines[startLine] = [
startColumn,
endColumn - startColumn
];
}
}
return {
start,
end,
markerLines
};
}
__name(getMarkerLines, "getMarkerLines");
function codeFrameColumns(rawLines, loc, opts = {}) {
const shouldHighlight = opts.forceColor || isColorSupported() && opts.highlightCode;
const defs = getDefs(shouldHighlight);
const lines = rawLines.split(NEWLINE);
const { start, end, markerLines } = getMarkerLines(loc, lines, opts);
const hasColumns = loc.start && typeof loc.start.column === "number";
const numberMaxWidth = String(end).length;
const highlightedLines = shouldHighlight ? highlight(rawLines) : rawLines;
let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index2) => {
const number = start + 1 + index2;
const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
const gutter = ` ${paddedNumber} |`;
const hasMarker = markerLines[number];
const lastMarkerLine = !markerLines[number + 1];
if (hasMarker) {
let markerLine = "";
if (Array.isArray(hasMarker)) {
const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
const numberOfMarkers = hasMarker[1] || 1;
markerLine = [
"\n ",
defs.gutter(gutter.replace(/\d/g, " ")),
" ",
markerSpacing,
defs.marker("^").repeat(numberOfMarkers)
].join("");
if (lastMarkerLine && opts.message) {
markerLine += " " + defs.message(opts.message);
}
}
return [
defs.marker(">"),
defs.gutter(gutter),
line.length > 0 ? ` ${line}` : "",
markerLine
].join("");
} else {
return ` ${defs.gutter(gutter)}${line.length > 0 ? ` ${line}` : ""}`;
}
}).join("\n");
if (opts.message && !hasColumns) {
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}
${frame}`;
}
if (shouldHighlight) {
return defs.reset(frame);
} else {
return frame;
}
}
__name(codeFrameColumns, "codeFrameColumns");
function index(rawLines, lineNumber, colNumber, opts = {}) {
if (!deprecationWarningShown) {
deprecationWarningShown = true;
const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
if (process.emitWarning) {
process.emitWarning(message, "DeprecationWarning");
} else {
const deprecationError = new Error(message);
deprecationError.name = "DeprecationWarning";
console.warn(new Error(message));
}
}
colNumber = Math.max(colNumber, 0);
const location = {
start: {
column: colNumber,
line: lineNumber
}
};
return codeFrameColumns(rawLines, location, opts);
}
__name(index, "index");
exports.codeFrameColumns = codeFrameColumns;
exports.default = index;
exports.highlight = highlight;
}
});
// node_modules/parse-json/index.js
var require_parse_json = __commonJS({
"node_modules/parse-json/index.js"(exports, module2) {
"use strict";
var errorEx = require_error_ex();
var fallback = require_json_parse_even_better_errors();
var { default: LinesAndColumns } = require_build();
var { codeFrameColumns } = require_lib2();
var JSONError = errorEx("JSONError", {
fileName: errorEx.append("in %s"),
codeFrame: errorEx.append("\n\n%s\n")
});
var parseJson = /* @__PURE__ */ __name((string, reviver, filename) => {
if (typeof reviver === "string") {
filename = reviver;
reviver = null;
}
try {
try {
return JSON.parse(string, reviver);
} catch (error) {
fallback(string, reviver);
throw error;
}
} catch (error) {
error.message = error.message.replace(/\n/g, "");
const indexMatch = error.message.match(/in JSON at position (\d+) while parsing/);
const jsonError = new JSONError(error);
if (filename) {
jsonError.fileName = filename;
}
if (indexMatch && indexMatch.length > 0) {
const lines = new LinesAndColumns(string);
const index = Number(indexMatch[1]);
const location = lines.locationForIndex(index);
const codeFrame = codeFrameColumns(string, {
start: {
line: location.line + 1,
column: location.column + 1
}
}, {
highlightCode: true
});
jsonError.codeFrame = codeFrame;
}
throw jsonError;
}
}, "parseJson");
parseJson.JSONError = JSONError;
module2.exports = parseJson;
}
});
// node_modules/normalize-package-data/node_modules/semver/semver.js
var require_semver = __commonJS({
"node_modules/normalize-package-data/node_modules/semver/semver.js"(exports, module2) {
exports = module2.exports = SemVer;
var debug;
if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
debug = /* @__PURE__ */ __name(function() {
var args = Array.prototype.slice.call(arguments, 0);
args.unshift("SEMVER");
console.log.apply(console, args);
}, "debug");
} else {
debug = /* @__PURE__ */ __name(function() {
}, "debug");
}
exports.SEMVER_SPEC_VERSION = "2.0.0";
var MAX_LENGTH = 256;
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
9007199254740991;
var MAX_SAFE_COMPONENT_LENGTH = 16;
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
var re = exports.re = [];
var safeRe = exports.safeRe = [];
var src = exports.src = [];
var R = 0;
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
var safeRegexReplacements = [
[
"\\s",
1
],
[
"\\d",
MAX_LENGTH
],
[
LETTERDASHNUMBER,
MAX_SAFE_BUILD_LENGTH
]
];
function makeSafeRe(value) {
for (var i2 = 0; i2 < safeRegexReplacements.length; i2++) {
var token = safeRegexReplacements[i2][0];
var max = safeRegexReplacements[i2][1];
value = value.split(token + "*").join(token + "{0," + max + "}").split(token + "+").join(token + "{1," + max + "}");
}
return value;
}
__name(makeSafeRe, "makeSafeRe");
var NUMERICIDENTIFIER = R++;
src[NUMERICIDENTIFIER] = "0|[1-9]\\d*";
var NUMERICIDENTIFIERLOOSE = R++;
src[NUMERICIDENTIFIERLOOSE] = "\\d+";
var NONNUMERICIDENTIFIER = R++;
src[NONNUMERICIDENTIFIER] = "\\d*[a-zA-Z-]" + LETTERDASHNUMBER + "*";
var MAINVERSION = R++;
src[MAINVERSION] = "(" + src[NUMERICIDENTIFIER] + ")\\.(" + src[NUMERICIDENTIFIER] + ")\\.(" + src[NUMERICIDENTIFIER] + ")";
var MAINVERSIONLOOSE = R++;
src[MAINVERSIONLOOSE] = "(" + src[NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[NUMERICIDENTIFIERLOOSE] + ")";
var PRERELEASEIDENTIFIER = R++;
src[PRERELEASEIDENTIFIER] = "(?:" + src[NUMERICIDENTIFIER] + "|" + src[NONNUMERICIDENTIFIER] + ")";
var PRERELEASEIDENTIFIERLOOSE = R++;
src[PRERELEASEIDENTIFIERLOOSE] = "(?:" + src[NUMERICIDENTIFIERLOOSE] + "|" + src[NONNUMERICIDENTIFIER] + ")";
var PRERELEASE = R++;
src[PRERELEASE] = "(?:-(" + src[PRERELEASEIDENTIFIER] + "(?:\\." + src[PRERELEASEIDENTIFIER] + ")*))";
var PRERELEASELOOSE = R++;
src[PRERELEASELOOSE] = "(?:-?(" + src[PRERELEASEIDENTIFIERLOOSE] + "(?:\\." + src[PRERELEASEIDENTIFIERLOOSE] + ")*))";
var BUILDIDENTIFIER = R++;
src[BUILDIDENTIFIER] = LETTERDASHNUMBER + "+";
var BUILD = R++;
src[BUILD] = "(?:\\+(" + src[BUILDIDENTIFIER] + "(?:\\." + src[BUILDIDENTIFIER] + ")*))";
var FULL = R++;
var FULLPLAIN = "v?" + src[MAINVERSION] + src[PRERELEASE] + "?" + src[BUILD] + "?";
src[FULL] = "^" + FULLPLAIN + "$";
var LOOSEPLAIN = "[v=\\s]*" + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + "?" + src[BUILD] + "?";
var LOOSE = R++;
src[LOOSE] = "^" + LOOSEPLAIN + "$";
var GTLT = R++;
src[GTLT] = "((?:<|>)?=?)";
var XRANGEIDENTIFIERLOOSE = R++;
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + "|x|X|\\*";
var XRANGEIDENTIFIER = R++;
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + "|x|X|\\*";
var XRANGEPLAIN = R++;
src[XRANGEPLAIN] = "[v=\\s]*(" + src[XRANGEIDENTIFIER] + ")(?:\\.(" + src[XRANGEIDENTIFIER] + ")(?:\\.(" + src[XRANGEIDENTIFIER] + ")(?:" + src[PRERELEASE] + ")?" + src[BUILD] + "?)?)?";
var XRANGEPLAINLOOSE = R++;
src[XRANGEPLAINLOOSE] = "[v=\\s]*(" + src[XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[XRANGEIDENTIFIERLOOSE] + ")(?:" + src[PRERELEASELOOSE] + ")?" + src[BUILD] + "?)?)?";
var XRANGE = R++;
src[XRANGE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAIN] + "$";
var XRANGELOOSE = R++;
src[XRANGELOOSE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAINLOOSE] + "$";
var COERCE = R++;
src[COERCE] = "(?:^|[^\\d])(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "})(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:$|[^\\d])";
var LONETILDE = R++;
src[LONETILDE] = "(?:~>?)";
var TILDETRIM = R++;
src[TILDETRIM] = "(\\s*)" + src[LONETILDE] + "\\s+";
re[TILDETRIM] = new RegExp(src[TILDETRIM], "g");
safeRe[TILDETRIM] = new RegExp(makeSafeRe(src[TILDETRIM]), "g");
var tildeTrimReplace = "$1~";
var TILDE = R++;
src[TILDE] = "^" + src[LONETILDE] + src[XRANGEPLAIN] + "$";
var TILDELOOSE = R++;
src[TILDELOOSE] = "^" + src[LONETILDE] + src[XRANGEPLAINLOOSE] + "$";
var LONECARET = R++;
src[LONECARET] = "(?:\\^)";
var CARETTRIM = R++;
src[CARETTRIM] = "(\\s*)" + src[LONECARET] + "\\s+";
re[CARETTRIM] = new RegExp(src[CARETTRIM], "g");
safeRe[CARETTRIM] = new RegExp(makeSafeRe(src[CARETTRIM]), "g");
var caretTrimReplace = "$1^";
var CARET = R++;
src[CARET] = "^" + src[LONECARET] + src[XRANGEPLAIN] + "$";
var CARETLOOSE = R++;
src[CARETLOOSE] = "^" + src[LONECARET] + src[XRANGEPLAINLOOSE] + "$";
var COMPARATORLOOSE = R++;
src[COMPARATORLOOSE] = "^" + src[GTLT] + "\\s*(" + LOOSEPLAIN + ")$|^$";
var COMPARATOR = R++;
src[COMPARATOR] = "^" + src[GTLT] + "\\s*(" + FULLPLAIN + ")$|^$";
var COMPARATORTRIM = R++;
src[COMPARATORTRIM] = "(\\s*)" + src[GTLT] + "\\s*(" + LOOSEPLAIN + "|" + src[XRANGEPLAIN] + ")";
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], "g");
safeRe[COMPARATORTRIM] = new RegExp(makeSafeRe(src[COMPARATORTRIM]), "g");
var comparatorTrimReplace = "$1$2$3";
var HYPHENRANGE = R++;
src[HYPHENRANGE] = "^\\s*(" + src[XRANGEPLAIN] + ")\\s+-\\s+(" + src[XRANGEPLAIN] + ")\\s*$";
var HYPHENRANGELOOSE = R++;
src[HYPHENRANGELOOSE] = "^\\s*(" + src[XRANGEPLAINLOOSE] + ")\\s+-\\s+(" + src[XRANGEPLAINLOOSE] + ")\\s*$";
var STAR = R++;
src[STAR] = "(<|>)?=?\\s*\\*";
for (i = 0; i < R; i++) {
debug(i, src[i]);
if (!re[i]) {
re[i] = new RegExp(src[i]);
safeRe[i] = new RegExp(makeSafeRe(src[i]));
}
}
var i;
exports.parse = parse;
function parse(version, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (version instanceof SemVer) {
return version;
}
if (typeof version !== "string") {
return null;
}
if (version.length > MAX_LENGTH) {
return null;
}
var r = options.loose ? safeRe[LOOSE] : safeRe[FULL];
if (!r.test(version)) {
return null;
}
try {
return new SemVer(version, options);
} catch (er) {
return null;
}
}
__name(parse, "parse");
exports.valid = valid;
function valid(version, options) {
var v = parse(version, options);
return v ? v.version : null;
}
__name(valid, "valid");
exports.clean = clean;
function clean(version, options) {
var s = parse(version.trim().replace(/^[=v]+/, ""), options);
return s ? s.version : null;
}
__name(clean, "clean");
exports.SemVer = SemVer;
function SemVer(version, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (version instanceof SemVer) {
if (version.loose === options.loose) {
return version;
} else {
version = version.version;
}
} else if (typeof version !== "string") {
throw new TypeError("Invalid Version: " + version);
}
if (version.length > MAX_LENGTH) {
throw new TypeError("version is longer than " + MAX_LENGTH + " characters");
}
if (!(this instanceof SemVer)) {
return new SemVer(version, options);
}
debug("SemVer", version, options);
this.options = options;
this.loose = !!options.loose;
var m = version.trim().match(options.loose ? safeRe[LOOSE] : safeRe[FULL]);
if (!m) {
throw new TypeError("Invalid Version: " + version);
}
this.raw = version;
this.major = +m[1];
this.minor = +m[2];
this.patch = +m[3];
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
throw new TypeError("Invalid major version");
}
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
throw new TypeError("Invalid minor version");
}
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
throw new TypeError("Invalid patch version");
}
if (!m[4]) {
this.prerelease = [];
} else {
this.prerelease = m[4].split(".").map(function(id) {
if (/^[0-9]+$/.test(id)) {
var num = +id;
if (num >= 0 && num < MAX_SAFE_INTEGER) {
return num;
}
}
return id;
});
}
this.build = m[5] ? m[5].split(".") : [];
this.format();
}
__name(SemVer, "SemVer");
SemVer.prototype.format = function() {
this.version = this.major + "." + this.minor + "." + this.patch;
if (this.prerelease.length) {
this.version += "-" + this.prerelease.join(".");
}
return this.version;
};
SemVer.prototype.toString = function() {
return this.version;
};
SemVer.prototype.compare = function(other) {
debug("SemVer.compare", this.version, this.options, other);
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
return this.compareMain(other) || this.comparePre(other);
};
SemVer.prototype.compareMain = function(other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
};
SemVer.prototype.comparePre = function(other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
if (this.prerelease.length && !other.prerelease.length) {
return -1;
} else if (!this.prerelease.length && other.prerelease.length) {
return 1;
} else if (!this.prerelease.length && !other.prerelease.length) {
return 0;
}
var i2 = 0;
do {
var a = this.prerelease[i2];
var b = other.prerelease[i2];
debug("prerelease compare", i2, a, b);
if (a === void 0 && b === void 0) {
return 0;
} else if (b === void 0) {
return 1;
} else if (a === void 0) {
return -1;
} else if (a === b) {
continue;
} else {
return compareIdentifiers(a, b);
}
} while (++i2);
};
SemVer.prototype.inc = function(release, identifier2) {
switch (release) {
case "premajor":
this.prerelease.length = 0;
this.patch = 0;
this.minor = 0;
this.major++;
this.inc("pre", identifier2);
break;
case "preminor":
this.prerelease.length = 0;
this.patch = 0;
this.minor++;
this.inc("pre", identifier2);
break;
case "prepatch":
this.prerelease.length = 0;
this.inc("patch", identifier2);
this.inc("pre", identifier2);
break;
case "prerelease":
if (this.prerelease.length === 0) {
this.inc("patch", identifier2);
}
this.inc("pre", identifier2);
break;
case "major":
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
this.major++;
}
this.minor = 0;
this.patch = 0;
this.prerelease = [];
break;
case "minor":
if (this.patch !== 0 || this.prerelease.length === 0) {
this.minor++;
}
this.patch = 0;
this.prerelease = [];
break;
case "patch":
if (this.prerelease.length === 0) {
this.patch++;
}
this.prerelease = [];
break;
case "pre":
if (this.prerelease.length === 0) {
this.prerelease = [
0
];
} else {
var i2 = this.prerelease.length;
while (--i2 >= 0) {
if (typeof this.prerelease[i2] === "number") {
this.prerelease[i2]++;
i2 = -2;
}
}
if (i2 === -1) {
this.prerelease.push(0);
}
}
if (identifier2) {
if (this.prerelease[0] === identifier2) {
if (isNaN(this.prerelease[1])) {
this.prerelease = [
identifier2,
0
];
}
} else {
this.prerelease = [
identifier2,
0
];
}
}
break;
default:
throw new Error("invalid increment argument: " + release);
}
this.format();
this.raw = this.version;
return this;
};
exports.inc = inc;
function inc(version, release, loose, identifier2) {
if (typeof loose === "string") {
identifier2 = loose;
loose = void 0;
}
try {
return new SemVer(version, loose).inc(release, identifier2).version;
} catch (er) {
return null;
}
}
__name(inc, "inc");
exports.diff = diff;
function diff(version1, version2) {
if (eq(version1, version2)) {
return null;
} else {
var v1 = parse(version1);
var v2 = parse(version2);
var prefix = "";
if (v1.prerelease.length || v2.prerelease.length) {
prefix = "pre";
var defaultResult = "prerelease";
}
for (var key in v1) {
if (key === "major" || key === "minor" || key === "patch") {
if (v1[key] !== v2[key]) {
return prefix + key;
}
}
}
return defaultResult;
}
}
__name(diff, "diff");
exports.compareIdentifiers = compareIdentifiers;
var numeric = /^[0-9]+$/;
function compareIdentifiers(a, b) {
var anum = numeric.test(a);
var bnum = numeric.test(b);
if (anum && bnum) {
a = +a;
b = +b;
}
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
}
__name(compareIdentifiers, "compareIdentifiers");
exports.rcompareIdentifiers = rcompareIdentifiers;
function rcompareIdentifiers(a, b) {
return compareIdentifiers(b, a);
}
__name(rcompareIdentifiers, "rcompareIdentifiers");
exports.major = major;
function major(a, loose) {
return new SemVer(a, loose).major;
}
__name(major, "major");
exports.minor = minor;
function minor(a, loose) {
return new SemVer(a, loose).minor;
}
__name(minor, "minor");
exports.patch = patch;
function patch(a, loose) {
return new SemVer(a, loose).patch;
}
__name(patch, "patch");
exports.compare = compare;
function compare(a, b, loose) {
return new SemVer(a, loose).compare(new SemVer(b, loose));
}
__name(compare, "compare");
exports.compareLoose = compareLoose;
function compareLoose(a, b) {
return compare(a, b, true);
}
__name(compareLoose, "compareLoose");
exports.rcompare = rcompare;
function rcompare(a, b, loose) {
return compare(b, a, loose);
}
__name(rcompare, "rcompare");
exports.sort = sort;
function sort(list, loose) {
return list.sort(function(a, b) {
return exports.compare(a, b, loose);
});
}
__name(sort, "sort");
exports.rsort = rsort;
function rsort(list, loose) {
return list.sort(function(a, b) {
return exports.rcompare(a, b, loose);
});
}
__name(rsort, "rsort");
exports.gt = gt;
function gt(a, b, loose) {
return compare(a, b, loose) > 0;
}
__name(gt, "gt");
exports.lt = lt;
function lt(a, b, loose) {
return compare(a, b, loose) < 0;
}
__name(lt, "lt");
exports.eq = eq;
function eq(a, b, loose) {
return compare(a, b, loose) === 0;
}
__name(eq, "eq");
exports.neq = neq;
function neq(a, b, loose) {
return compare(a, b, loose) !== 0;
}
__name(neq, "neq");
exports.gte = gte;
function gte(a, b, loose) {
return compare(a, b, loose) >= 0;
}
__name(gte, "gte");
exports.lte = lte;
function lte(a, b, loose) {
return compare(a, b, loose) <= 0;
}
__name(lte, "lte");
exports.cmp = cmp;
function cmp(a, op, b, loose) {
switch (op) {
case "===":
if (typeof a === "object")
a = a.version;
if (typeof b === "object")
b = b.version;
return a === b;
case "!==":
if (typeof a === "object")
a = a.version;
if (typeof b === "object")
b = b.version;
return a !== b;
case "":
case "=":
case "==":
return eq(a, b, loose);
case "!=":
return neq(a, b, loose);
case ">":
return gt(a, b, loose);
case ">=":
return gte(a, b, loose);
case "<":
return lt(a, b, loose);
case "<=":
return lte(a, b, loose);
default:
throw new TypeError("Invalid operator: " + op);
}
}
__name(cmp, "cmp");
exports.Comparator = Comparator;
function Comparator(comp, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (comp instanceof Comparator) {
if (comp.loose === !!options.loose) {
return comp;
} else {
comp = comp.value;
}
}
if (!(this instanceof Comparator)) {
return new Comparator(comp, options);
}
comp = comp.trim().split(/\s+/).join(" ");
debug("comparator", comp, options);
this.options = options;
this.loose = !!options.loose;
this.parse(comp);
if (this.semver === ANY) {
this.value = "";
} else {
this.value = this.operator + this.semver.version;
}
debug("comp", this);
}
__name(Comparator, "Comparator");
var ANY = {};
Comparator.prototype.parse = function(comp) {
var r = this.options.loose ? safeRe[COMPARATORLOOSE] : safeRe[COMPARATOR];
var m = comp.match(r);
if (!m) {
throw new TypeError("Invalid comparator: " + comp);
}
this.operator = m[1];
if (this.operator === "=") {
this.operator = "";
}
if (!m[2]) {
this.semver = ANY;
} else {
this.semver = new SemVer(m[2], this.options.loose);
}
};
Comparator.prototype.toString = function() {
return this.value;
};
Comparator.prototype.test = function(version) {
debug("Comparator.test", version, this.options.loose);
if (this.semver === ANY) {
return true;
}
if (typeof version === "string") {
version = new SemVer(version, this.options);
}
return cmp(version, this.operator, this.semver, this.options);
};
Comparator.prototype.intersects = function(comp, options) {
if (!(comp instanceof Comparator)) {
throw new TypeError("a Comparator is required");
}
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
var rangeTmp;
if (this.operator === "") {
rangeTmp = new Range(comp.value, options);
return satisfies(this.value, rangeTmp, options);
} else if (comp.operator === "") {
rangeTmp = new Range(this.value, options);
return satisfies(comp.semver, rangeTmp, options);
}
var sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") && (comp.operator === ">=" || comp.operator === ">");
var sameDirectionDecreasing = (this.operator === "<=" || this.operator === "<") && (comp.operator === "<=" || comp.operator === "<");
var sameSemVer = this.semver.version === comp.semver.version;
var differentDirectionsInclusive = (this.operator === ">=" || this.operator === "<=") && (comp.operator === ">=" || comp.operator === "<=");
var oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver, options) && (this.operator === ">=" || this.operator === ">") && (comp.operator === "<=" || comp.operator === "<");
var oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver, options) && (this.operator === "<=" || this.operator === "<") && (comp.operator === ">=" || comp.operator === ">");
return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
};
exports.Range = Range;
function Range(range, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (range instanceof Range) {
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
return range;
} else {
return new Range(range.raw, options);
}
}
if (range instanceof Comparator) {
return new Range(range.value, options);
}
if (!(this instanceof Range)) {
return new Range(range, options);
}
this.options = options;
this.loose = !!options.loose;
this.includePrerelease = !!options.includePrerelease;
this.raw = range.trim().split(/\s+/).join(" ");
this.set = this.raw.split("||").map(function(range2) {
return this.parseRange(range2.trim());
}, this).filter(function(c) {
return c.length;
});
if (!this.set.length) {
throw new TypeError("Invalid SemVer Range: " + this.raw);
}
this.format();
}
__name(Range, "Range");
Range.prototype.format = function() {
this.range = this.set.map(function(comps) {
return comps.join(" ").trim();
}).join("||").trim();
return this.range;
};
Range.prototype.toString = function() {
return this.range;
};
Range.prototype.parseRange = function(range) {
var loose = this.options.loose;
var hr = loose ? safeRe[HYPHENRANGELOOSE] : safeRe[HYPHENRANGE];
range = range.replace(hr, hyphenReplace);
debug("hyphen replace", range);
range = range.replace(safeRe[COMPARATORTRIM], comparatorTrimReplace);
debug("comparator trim", range, safeRe[COMPARATORTRIM]);
range = range.replace(safeRe[TILDETRIM], tildeTrimReplace);
range = range.replace(safeRe[CARETTRIM], caretTrimReplace);
var compRe = loose ? safeRe[COMPARATORLOOSE] : safeRe[COMPARATOR];
var set = range.split(" ").map(function(comp) {
return parseComparator(comp, this.options);
}, this).join(" ").split(/\s+/);
if (this.options.loose) {
set = set.filter(function(comp) {
return !!comp.match(compRe);
});
}
set = set.map(function(comp) {
return new Comparator(comp, this.options);
}, this);
return set;
};
Range.prototype.intersects = function(range, options) {
if (!(range instanceof Range)) {
throw new TypeError("a Range is required");
}
return this.set.some(function(thisComparators) {
return thisComparators.every(function(thisComparator) {
return range.set.some(function(rangeComparators) {
return rangeComparators.every(function(rangeComparator) {
return thisComparator.intersects(rangeComparator, options);
});
});
});
});
};
exports.toComparators = toComparators;
function toComparators(range, options) {
return new Range(range, options).set.map(function(comp) {
return comp.map(function(c) {
return c.value;
}).join(" ").trim().split(" ");
});
}
__name(toComparators, "toComparators");
function parseComparator(comp, options) {
debug("comp", comp, options);
comp = replaceCarets(comp, options);
debug("caret", comp);
comp = replaceTildes(comp, options);
debug("tildes", comp);
comp = replaceXRanges(comp, options);
debug("xrange", comp);
comp = replaceStars(comp, options);
debug("stars", comp);
return comp;
}
__name(parseComparator, "parseComparator");
function isX(id) {
return !id || id.toLowerCase() === "x" || id === "*";
}
__name(isX, "isX");
function replaceTildes(comp, options) {
return comp.trim().split(/\s+/).map(function(comp2) {
return replaceTilde(comp2, options);
}).join(" ");
}
__name(replaceTildes, "replaceTildes");
function replaceTilde(comp, options) {
var r = options.loose ? safeRe[TILDELOOSE] : safeRe[TILDE];
return comp.replace(r, function(_, M, m, p, pr) {
debug("tilde", comp, _, M, m, p, pr);
var ret;
if (isX(M)) {
ret = "";
} else if (isX(m)) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (isX(p)) {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
} else if (pr) {
debug("replaceTilde pr", pr);
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
} else {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
}
debug("tilde return", ret);
return ret;
});
}
__name(replaceTilde, "replaceTilde");
function replaceCarets(comp, options) {
return comp.trim().split(/\s+/).map(function(comp2) {
return replaceCaret(comp2, options);
}).join(" ");
}
__name(replaceCarets, "replaceCarets");
function replaceCaret(comp, options) {
debug("caret", comp, options);
var r = options.loose ? safeRe[CARETLOOSE] : safeRe[CARET];
return comp.replace(r, function(_, M, m, p, pr) {
debug("caret", comp, _, M, m, p, pr);
var ret;
if (isX(M)) {
ret = "";
} else if (isX(m)) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (isX(p)) {
if (M === "0") {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
} else {
ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
}
} else if (pr) {
debug("replaceCaret pr", pr);
if (M === "0") {
if (m === "0") {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1);
} else {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
}
} else {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0";
}
} else {
debug("no pr");
if (M === "0") {
if (m === "0") {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1);
} else {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
}
} else {
ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
}
}
debug("caret return", ret);
return ret;
});
}
__name(replaceCaret, "replaceCaret");
function replaceXRanges(comp, options) {
debug("replaceXRanges", comp, options);
return comp.split(/\s+/).map(function(comp2) {
return replaceXRange(comp2, options);
}).join(" ");
}
__name(replaceXRanges, "replaceXRanges");
function replaceXRange(comp, options) {
comp = comp.trim();
var r = options.loose ? safeRe[XRANGELOOSE] : safeRe[XRANGE];
return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
debug("xRange", comp, ret, gtlt, M, m, p, pr);
var xM = isX(M);
var xm = xM || isX(m);
var xp = xm || isX(p);
var anyX = xp;
if (gtlt === "=" && anyX) {
gtlt = "";
}
if (xM) {
if (gtlt === ">" || gtlt === "<") {
ret = "<0.0.0";
} else {
ret = "*";
}
} else if (gtlt && anyX) {
if (xm) {
m = 0;
}
p = 0;
if (gtlt === ">") {
gtlt = ">=";
if (xm) {
M = +M + 1;
m = 0;
p = 0;
} else {
m = +m + 1;
p = 0;
}
} else if (gtlt === "<=") {
gtlt = "<";
if (xm) {
M = +M + 1;
} else {
m = +m + 1;
}
}
ret = gtlt + M + "." + m + "." + p;
} else if (xm) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (xp) {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
}
debug("xRange return", ret);
return ret;
});
}
__name(replaceXRange, "replaceXRange");
function replaceStars(comp, options) {
debug("replaceStars", comp, options);
return comp.trim().replace(safeRe[STAR], "");
}
__name(replaceStars, "replaceStars");
function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
if (isX(fM)) {
from = "";
} else if (isX(fm)) {
from = ">=" + fM + ".0.0";
} else if (isX(fp)) {
from = ">=" + fM + "." + fm + ".0";
} else {
from = ">=" + from;
}
if (isX(tM)) {
to = "";
} else if (isX(tm)) {
to = "<" + (+tM + 1) + ".0.0";
} else if (isX(tp)) {
to = "<" + tM + "." + (+tm + 1) + ".0";
} else if (tpr) {
to = "<=" + tM + "." + tm + "." + tp + "-" + tpr;
} else {
to = "<=" + to;
}
return (from + " " + to).trim();
}
__name(hyphenReplace, "hyphenReplace");
Range.prototype.test = function(version) {
if (!version) {
return false;
}
if (typeof version === "string") {
version = new SemVer(version, this.options);
}
for (var i2 = 0; i2 < this.set.length; i2++) {
if (testSet(this.set[i2], version, this.options)) {
return true;
}
}
return false;
};
function testSet(set, version, options) {
for (var i2 = 0; i2 < set.length; i2++) {
if (!set[i2].test(version)) {
return false;
}
}
if (version.prerelease.length && !options.includePrerelease) {
for (i2 = 0; i2 < set.length; i2++) {
debug(set[i2].semver);
if (set[i2].semver === ANY) {
continue;
}
if (set[i2].semver.prerelease.length > 0) {
var allowed = set[i2].semver;
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
return true;
}
}
}
return false;
}
return true;
}
__name(testSet, "testSet");
exports.satisfies = satisfies;
function satisfies(version, range, options) {
try {
range = new Range(range, options);
} catch (er) {
return false;
}
return range.test(version);
}
__name(satisfies, "satisfies");
exports.maxSatisfying = maxSatisfying;
function maxSatisfying(versions, range, options) {
var max = null;
var maxSV = null;
try {
var rangeObj = new Range(range, options);
} catch (er) {
return null;
}
versions.forEach(function(v) {
if (rangeObj.test(v)) {
if (!max || maxSV.compare(v) === -1) {
max = v;
maxSV = new SemVer(max, options);
}
}
});
return max;
}
__name(maxSatisfying, "maxSatisfying");
exports.minSatisfying = minSatisfying;
function minSatisfying(versions, range, options) {
var min = null;
var minSV = null;
try {
var rangeObj = new Range(range, options);
} catch (er) {
return null;
}
versions.forEach(function(v) {
if (rangeObj.test(v)) {
if (!min || minSV.compare(v) === 1) {
min = v;
minSV = new SemVer(min, options);
}
}
});
return min;
}
__name(minSatisfying, "minSatisfying");
exports.minVersion = minVersion;
function minVersion(range, loose) {
range = new Range(range, loose);
var minver = new SemVer("0.0.0");
if (range.test(minver)) {
return minver;
}
minver = new SemVer("0.0.0-0");
if (range.test(minver)) {
return minver;
}
minver = null;
for (var i2 = 0; i2 < range.set.length; ++i2) {
var comparators = range.set[i2];
comparators.forEach(function(comparator) {
var compver = new SemVer(comparator.semver.version);
switch (comparator.operator) {
case ">":
if (compver.prerelease.length === 0) {
compver.patch++;
} else {
compver.prerelease.push(0);
}
compver.raw = compver.format();
case "":
case ">=":
if (!minver || gt(minver, compver)) {
minver = compver;
}
break;
case "<":
case "<=":
break;
default:
throw new Error("Unexpected operation: " + comparator.operator);
}
});
}
if (minver && range.test(minver)) {
return minver;
}
return null;
}
__name(minVersion, "minVersion");
exports.validRange = validRange;
function validRange(range, options) {
try {
return new Range(range, options).range || "*";
} catch (er) {
return null;
}
}
__name(validRange, "validRange");
exports.ltr = ltr;
function ltr(version, range, options) {
return outside(version, range, "<", options);
}
__name(ltr, "ltr");
exports.gtr = gtr;
function gtr(version, range, options) {
return outside(version, range, ">", options);
}
__name(gtr, "gtr");
exports.outside = outside;
function outside(version, range, hilo, options) {
version = new SemVer(version, options);
range = new Range(range, options);
var gtfn, ltefn, ltfn, comp, ecomp;
switch (hilo) {
case ">":
gtfn = gt;
ltefn = lte;
ltfn = lt;
comp = ">";
ecomp = ">=";
break;
case "<":
gtfn = lt;
ltefn = gte;
ltfn = gt;
comp = "<";
ecomp = "<=";
break;
default:
throw new TypeError('Must provide a hilo val of "<" or ">"');
}
if (satisfies(version, range, options)) {
return false;
}
for (var i2 = 0; i2 < range.set.length; ++i2) {
var comparators = range.set[i2];
var high = null;
var low = null;
comparators.forEach(function(comparator) {
if (comparator.semver === ANY) {
comparator = new Comparator(">=0.0.0");
}
high = high || comparator;
low = low || comparator;
if (gtfn(comparator.semver, high.semver, options)) {
high = comparator;
} else if (ltfn(comparator.semver, low.semver, options)) {
low = comparator;
}
});
if (high.operator === comp || high.operator === ecomp) {
return false;
}
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
return false;
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
return false;
}
}
return true;
}
__name(outside, "outside");
exports.prerelease = prerelease;
function prerelease(version, options) {
var parsed = parse(version, options);
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
}
__name(prerelease, "prerelease");
exports.intersects = intersects;
function intersects(r1, r2, options) {
r1 = new Range(r1, options);
r2 = new Range(r2, options);
return r1.intersects(r2);
}
__name(intersects, "intersects");
exports.coerce = coerce;
function coerce(version) {
if (version instanceof SemVer) {
return version;
}
if (typeof version !== "string") {
return null;
}
var match = version.match(safeRe[COERCE]);
if (match == null) {
return null;
}
return parse(match[1] + "." + (match[2] || "0") + "." + (match[3] || "0"));
}
__name(coerce, "coerce");
}
});
// node_modules/spdx-license-ids/index.json
var require_spdx_license_ids = __commonJS({
"node_modules/spdx-license-ids/index.json"(exports, module2) {
module2.exports = [
"0BSD",
"AAL",
"ADSL",
"AFL-1.1",
"AFL-1.2",
"AFL-2.0",
"AFL-2.1",
"AFL-3.0",
"AGPL-1.0-only",
"AGPL-1.0-or-later",
"AGPL-3.0-only",
"AGPL-3.0-or-later",
"AMDPLPA",
"AML",
"AMPAS",
"ANTLR-PD",
"ANTLR-PD-fallback",
"APAFML",
"APL-1.0",
"APSL-1.0",
"APSL-1.1",
"APSL-1.2",
"APSL-2.0",
"ASWF-Digital-Assets-1.0",
"ASWF-Digital-Assets-1.1",
"Abstyles",
"AdaCore-doc",
"Adobe-2006",
"Adobe-Glyph",
"Adobe-Utopia",
"Afmparse",
"Aladdin",
"Apache-1.0",
"Apache-1.1",
"Apache-2.0",
"App-s2p",
"Arphic-1999",
"Artistic-1.0",
"Artistic-1.0-Perl",
"Artistic-1.0-cl8",
"Artistic-2.0",
"BSD-1-Clause",
"BSD-2-Clause",
"BSD-2-Clause-Patent",
"BSD-2-Clause-Views",
"BSD-3-Clause",
"BSD-3-Clause-Attribution",
"BSD-3-Clause-Clear",
"BSD-3-Clause-HP",
"BSD-3-Clause-LBNL",
"BSD-3-Clause-Modification",
"BSD-3-Clause-No-Military-License",
"BSD-3-Clause-No-Nuclear-License",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause-No-Nuclear-Warranty",
"BSD-3-Clause-Open-MPI",
"BSD-3-Clause-Sun",
"BSD-3-Clause-flex",
"BSD-4-Clause",
"BSD-4-Clause-Shortened",
"BSD-4-Clause-UC",
"BSD-4.3RENO",
"BSD-4.3TAHOE",
"BSD-Advertising-Acknowledgement",
"BSD-Attribution-HPND-disclaimer",
"BSD-Inferno-Nettverk",
"BSD-Protection",
"BSD-Source-Code",
"BSD-Systemics",
"BSL-1.0",
"BUSL-1.1",
"Baekmuk",
"Bahyph",
"Barr",
"Beerware",
"BitTorrent-1.0",
"BitTorrent-1.1",
"Bitstream-Charter",
"Bitstream-Vera",
"BlueOak-1.0.0",
"Boehm-GC",
"Borceux",
"Brian-Gladman-3-Clause",
"C-UDA-1.0",
"CAL-1.0",
"CAL-1.0-Combined-Work-Exception",
"CATOSL-1.1",
"CC-BY-1.0",
"CC-BY-2.0",
"CC-BY-2.5",
"CC-BY-2.5-AU",
"CC-BY-3.0",
"CC-BY-3.0-AT",
"CC-BY-3.0-DE",
"CC-BY-3.0-IGO",
"CC-BY-3.0-NL",
"CC-BY-3.0-US",
"CC-BY-4.0",
"CC-BY-NC-1.0",
"CC-BY-NC-2.0",
"CC-BY-NC-2.5",
"CC-BY-NC-3.0",
"CC-BY-NC-3.0-DE",
"CC-BY-NC-4.0",
"CC-BY-NC-ND-1.0",
"CC-BY-NC-ND-2.0",
"CC-BY-NC-ND-2.5",
"CC-BY-NC-ND-3.0",
"CC-BY-NC-ND-3.0-DE",
"CC-BY-NC-ND-3.0-IGO",
"CC-BY-NC-ND-4.0",
"CC-BY-NC-SA-1.0",
"CC-BY-NC-SA-2.0",
"CC-BY-NC-SA-2.0-DE",
"CC-BY-NC-SA-2.0-FR",
"CC-BY-NC-SA-2.0-UK",
"CC-BY-NC-SA-2.5",
"CC-BY-NC-SA-3.0",
"CC-BY-NC-SA-3.0-DE",
"CC-BY-NC-SA-3.0-IGO",
"CC-BY-NC-SA-4.0",
"CC-BY-ND-1.0",
"CC-BY-ND-2.0",
"CC-BY-ND-2.5",
"CC-BY-ND-3.0",
"CC-BY-ND-3.0-DE",
"CC-BY-ND-4.0",
"CC-BY-SA-1.0",
"CC-BY-SA-2.0",
"CC-BY-SA-2.0-UK",
"CC-BY-SA-2.1-JP",
"CC-BY-SA-2.5",
"CC-BY-SA-3.0",
"CC-BY-SA-3.0-AT",
"CC-BY-SA-3.0-DE",
"CC-BY-SA-3.0-IGO",
"CC-BY-SA-4.0",
"CC-PDDC",
"CC0-1.0",
"CDDL-1.0",
"CDDL-1.1",
"CDL-1.0",
"CDLA-Permissive-1.0",
"CDLA-Permissive-2.0",
"CDLA-Sharing-1.0",
"CECILL-1.0",
"CECILL-1.1",
"CECILL-2.0",
"CECILL-2.1",
"CECILL-B",
"CECILL-C",
"CERN-OHL-1.1",
"CERN-OHL-1.2",
"CERN-OHL-P-2.0",
"CERN-OHL-S-2.0",
"CERN-OHL-W-2.0",
"CFITSIO",
"CMU-Mach",
"CNRI-Jython",
"CNRI-Python",
"CNRI-Python-GPL-Compatible",
"COIL-1.0",
"CPAL-1.0",
"CPL-1.0",
"CPOL-1.02",
"CUA-OPL-1.0",
"Caldera",
"ClArtistic",
"Clips",
"Community-Spec-1.0",
"Condor-1.1",
"Cornell-Lossless-JPEG",
"Cronyx",
"Crossword",
"CrystalStacker",
"Cube",
"D-FSL-1.0",
"DL-DE-BY-2.0",
"DL-DE-ZERO-2.0",
"DOC",
"DRL-1.0",
"DSDP",
"Dotseqn",
"ECL-1.0",
"ECL-2.0",
"EFL-1.0",
"EFL-2.0",
"EPICS",
"EPL-1.0",
"EPL-2.0",
"EUDatagrid",
"EUPL-1.0",
"EUPL-1.1",
"EUPL-1.2",
"Elastic-2.0",
"Entessa",
"ErlPL-1.1",
"Eurosym",
"FBM",
"FDK-AAC",
"FSFAP",
"FSFUL",
"FSFULLR",
"FSFULLRWD",
"FTL",
"Fair",
"Ferguson-Twofish",
"Frameworx-1.0",
"FreeBSD-DOC",
"FreeImage",
"Furuseth",
"GD",
"GFDL-1.1-invariants-only",
"GFDL-1.1-invariants-or-later",
"GFDL-1.1-no-invariants-only",
"GFDL-1.1-no-invariants-or-later",
"GFDL-1.1-only",
"GFDL-1.1-or-later",
"GFDL-1.2-invariants-only",
"GFDL-1.2-invariants-or-later",
"GFDL-1.2-no-invariants-only",
"GFDL-1.2-no-invariants-or-later",
"GFDL-1.2-only",
"GFDL-1.2-or-later",
"GFDL-1.3-invariants-only",
"GFDL-1.3-invariants-or-later",
"GFDL-1.3-no-invariants-only",
"GFDL-1.3-no-invariants-or-later",
"GFDL-1.3-only",
"GFDL-1.3-or-later",
"GL2PS",
"GLWTPL",
"GPL-1.0-only",
"GPL-1.0-or-later",
"GPL-2.0-only",
"GPL-2.0-or-later",
"GPL-3.0-only",
"GPL-3.0-or-later",
"Giftware",
"Glide",
"Glulxe",
"Graphics-Gems",
"HP-1986",
"HP-1989",
"HPND",
"HPND-DEC",
"HPND-Markus-Kuhn",
"HPND-Pbmplus",
"HPND-UC",
"HPND-doc",
"HPND-doc-sell",
"HPND-export-US",
"HPND-export-US-modify",
"HPND-sell-regexpr",
"HPND-sell-variant",
"HPND-sell-variant-MIT-disclaimer",
"HTMLTIDY",
"HaskellReport",
"Hippocratic-2.1",
"IBM-pibs",
"ICU",
"IEC-Code-Components-EULA",
"IJG",
"IJG-short",
"IPA",
"IPL-1.0",
"ISC",
"ImageMagick",
"Imlib2",
"Info-ZIP",
"Inner-Net-2.0",
"Intel",
"Intel-ACPI",
"Interbase-1.0",
"JPL-image",
"JPNIC",
"JSON",
"Jam",
"JasPer-2.0",
"Kastrup",
"Kazlib",
"Knuth-CTAN",
"LAL-1.2",
"LAL-1.3",
"LGPL-2.0-only",
"LGPL-2.0-or-later",
"LGPL-2.1-only",
"LGPL-2.1-or-later",
"LGPL-3.0-only",
"LGPL-3.0-or-later",
"LGPLLR",
"LOOP",
"LPL-1.0",
"LPL-1.02",
"LPPL-1.0",
"LPPL-1.1",
"LPPL-1.2",
"LPPL-1.3a",
"LPPL-1.3c",
"LZMA-SDK-9.11-to-9.20",
"LZMA-SDK-9.22",
"Latex2e",
"Latex2e-translated-notice",
"Leptonica",
"LiLiQ-P-1.1",
"LiLiQ-R-1.1",
"LiLiQ-Rplus-1.1",
"Libpng",
"Linux-OpenIB",
"Linux-man-pages-1-para",
"Linux-man-pages-copyleft",
"Linux-man-pages-copyleft-2-para",
"Linux-man-pages-copyleft-var",
"Lucida-Bitmap-Fonts",
"MIT",
"MIT-0",
"MIT-CMU",
"MIT-Festival",
"MIT-Modern-Variant",
"MIT-Wu",
"MIT-advertising",
"MIT-enna",
"MIT-feh",
"MIT-open-group",
"MIT-testregex",
"MITNFA",
"MMIXware",
"MPEG-SSG",
"MPL-1.0",
"MPL-1.1",
"MPL-2.0",
"MPL-2.0-no-copyleft-exception",
"MS-LPL",
"MS-PL",
"MS-RL",
"MTLL",
"MakeIndex",
"Martin-Birgmeier",
"McPhee-slideshow",
"Minpack",
"MirOS",
"Motosoto",
"MulanPSL-1.0",
"MulanPSL-2.0",
"Multics",
"Mup",
"NAIST-2003",
"NASA-1.3",
"NBPL-1.0",
"NCGL-UK-2.0",
"NCSA",
"NGPL",
"NICTA-1.0",
"NIST-PD",
"NIST-PD-fallback",
"NIST-Software",
"NLOD-1.0",
"NLOD-2.0",
"NLPL",
"NOSL",
"NPL-1.0",
"NPL-1.1",
"NPOSL-3.0",
"NRL",
"NTP",
"NTP-0",
"Naumen",
"Net-SNMP",
"NetCDF",
"Newsletr",
"Nokia",
"Noweb",
"O-UDA-1.0",
"OCCT-PL",
"OCLC-2.0",
"ODC-By-1.0",
"ODbL-1.0",
"OFFIS",
"OFL-1.0",
"OFL-1.0-RFN",
"OFL-1.0-no-RFN",
"OFL-1.1",
"OFL-1.1-RFN",
"OFL-1.1-no-RFN",
"OGC-1.0",
"OGDL-Taiwan-1.0",
"OGL-Canada-2.0",
"OGL-UK-1.0",
"OGL-UK-2.0",
"OGL-UK-3.0",
"OGTSL",
"OLDAP-1.1",
"OLDAP-1.2",
"OLDAP-1.3",
"OLDAP-1.4",
"OLDAP-2.0",
"OLDAP-2.0.1",
"OLDAP-2.1",
"OLDAP-2.2",
"OLDAP-2.2.1",
"OLDAP-2.2.2",
"OLDAP-2.3",
"OLDAP-2.4",
"OLDAP-2.5",
"OLDAP-2.6",
"OLDAP-2.7",
"OLDAP-2.8",
"OLFL-1.3",
"OML",
"OPL-1.0",
"OPL-UK-3.0",
"OPUBL-1.0",
"OSET-PL-2.1",
"OSL-1.0",
"OSL-1.1",
"OSL-2.0",
"OSL-2.1",
"OSL-3.0",
"OpenPBS-2.3",
"OpenSSL",
"PADL",
"PDDL-1.0",
"PHP-3.0",
"PHP-3.01",
"PSF-2.0",
"Parity-6.0.0",
"Parity-7.0.0",
"Plexus",
"PolyForm-Noncommercial-1.0.0",
"PolyForm-Small-Business-1.0.0",
"PostgreSQL",
"Python-2.0",
"Python-2.0.1",
"QPL-1.0",
"QPL-1.0-INRIA-2004",
"Qhull",
"RHeCos-1.1",
"RPL-1.1",
"RPL-1.5",
"RPSL-1.0",
"RSA-MD",
"RSCPL",
"Rdisc",
"Ruby",
"SAX-PD",
"SCEA",
"SGI-B-1.0",
"SGI-B-1.1",
"SGI-B-2.0",
"SGI-OpenGL",
"SGP4",
"SHL-0.5",
"SHL-0.51",
"SISSL",
"SISSL-1.2",
"SL",
"SMLNJ",
"SMPPL",
"SNIA",
"SPL-1.0",
"SSH-OpenSSH",
"SSH-short",
"SSPL-1.0",
"SWL",
"Saxpath",
"SchemeReport",
"Sendmail",
"Sendmail-8.23",
"SimPL-2.0",
"Sleepycat",
"Soundex",
"Spencer-86",
"Spencer-94",
"Spencer-99",
"SugarCRM-1.1.3",
"SunPro",
"Symlinks",
"TAPR-OHL-1.0",
"TCL",
"TCP-wrappers",
"TMate",
"TORQUE-1.1",
"TOSL",
"TPDL",
"TPL-1.0",
"TTWL",
"TTYP0",
"TU-Berlin-1.0",
"TU-Berlin-2.0",
"TermReadKey",
"UCAR",
"UCL-1.0",
"UPL-1.0",
"URT-RLE",
"Unicode-DFS-2015",
"Unicode-DFS-2016",
"Unicode-TOU",
"UnixCrypt",
"Unlicense",
"VOSTROM",
"VSL-1.0",
"Vim",
"W3C",
"W3C-19980720",
"W3C-20150513",
"WTFPL",
"Watcom-1.0",
"Widget-Workshop",
"Wsuipa",
"X11",
"X11-distribute-modifications-variant",
"XFree86-1.1",
"XSkat",
"Xdebug-1.03",
"Xerox",
"Xfig",
"Xnet",
"YPL-1.0",
"YPL-1.1",
"ZPL-1.1",
"ZPL-2.0",
"ZPL-2.1",
"Zed",
"Zeeff",
"Zend-2.0",
"Zimbra-1.3",
"Zimbra-1.4",
"Zlib",
"blessing",
"bzip2-1.0.6",
"check-cvs",
"checkmk",
"copyleft-next-0.3.0",
"copyleft-next-0.3.1",
"curl",
"diffmark",
"dtoa",
"dvipdfm",
"eGenix",
"etalab-2.0",
"fwlw",
"gSOAP-1.3b",
"gnuplot",
"iMatix",
"libpng-2.0",
"libselinux-1.0",
"libtiff",
"libutil-David-Nugent",
"lsof",
"magaz",
"metamail",
"mpi-permissive",
"mpich2",
"mplus",
"pnmstitch",
"psfrag",
"psutils",
"python-ldap",
"snprintf",
"ssh-keyscan",
"swrule",
"ulem",
"w3m",
"xinetd",
"xlock",
"xpp",
"zlib-acknowledgement"
];
}
});
// node_modules/spdx-license-ids/deprecated.json
var require_deprecated = __commonJS({
"node_modules/spdx-license-ids/deprecated.json"(exports, module2) {
module2.exports = [
"AGPL-1.0",
"AGPL-3.0",
"BSD-2-Clause-FreeBSD",
"BSD-2-Clause-NetBSD",
"GFDL-1.1",
"GFDL-1.2",
"GFDL-1.3",
"GPL-1.0",
"GPL-1.0+",
"GPL-2.0",
"GPL-2.0+",
"GPL-2.0-with-GCC-exception",
"GPL-2.0-with-autoconf-exception",
"GPL-2.0-with-bison-exception",
"GPL-2.0-with-classpath-exception",
"GPL-2.0-with-font-exception",
"GPL-3.0",
"GPL-3.0+",
"GPL-3.0-with-GCC-exception",
"GPL-3.0-with-autoconf-exception",
"LGPL-2.0",
"LGPL-2.0+",
"LGPL-2.1",
"LGPL-2.1+",
"LGPL-3.0",
"LGPL-3.0+",
"Nunit",
"StandardML-NJ",
"bzip2-1.0.5",
"eCos-2.0",
"wxWindows"
];
}
});
// node_modules/spdx-exceptions/index.json
var require_spdx_exceptions = __commonJS({
"node_modules/spdx-exceptions/index.json"(exports, module2) {
module2.exports = [
"389-exception",
"Autoconf-exception-2.0",
"Autoconf-exception-3.0",
"Bison-exception-2.2",
"Bootloader-exception",
"Classpath-exception-2.0",
"CLISP-exception-2.0",
"DigiRule-FOSS-exception",
"eCos-exception-2.0",
"Fawkes-Runtime-exception",
"FLTK-exception",
"Font-exception-2.0",
"freertos-exception-2.0",
"GCC-exception-2.0",
"GCC-exception-3.1",
"gnu-javamail-exception",
"GPL-3.0-linking-exception",
"GPL-3.0-linking-source-exception",
"GPL-CC-1.0",
"i2p-gpl-java-exception",
"Libtool-exception",
"Linux-syscall-note",
"LLVM-exception",
"LZMA-exception",
"mif-exception",
"Nokia-Qt-exception-1.1",
"OCaml-LGPL-linking-exception",
"OCCT-exception-1.0",
"OpenJDK-assembly-exception-1.0",
"openvpn-openssl-exception",
"PS-or-PDF-font-exception-20170817",
"Qt-GPL-exception-1.0",
"Qt-LGPL-exception-1.1",
"Qwt-exception-1.0",
"Swift-exception",
"u-boot-exception-2.0",
"Universal-FOSS-exception-1.0",
"WxWindows-exception-3.1"
];
}
});
// node_modules/spdx-expression-parse/scan.js
var require_scan = __commonJS({
"node_modules/spdx-expression-parse/scan.js"(exports, module2) {
"use strict";
var licenses = [].concat(require_spdx_license_ids()).concat(require_deprecated());
var exceptions = require_spdx_exceptions();
module2.exports = function(source) {
var index = 0;
function hasMore() {
return index < source.length;
}
__name(hasMore, "hasMore");
function read(value) {
if (value instanceof RegExp) {
var chars = source.slice(index);
var match = chars.match(value);
if (match) {
index += match[0].length;
return match[0];
}
} else {
if (source.indexOf(value, index) === index) {
index += value.length;
return value;
}
}
}
__name(read, "read");
function skipWhitespace() {
read(/[ ]*/);
}
__name(skipWhitespace, "skipWhitespace");
function operator() {
var string;
var possibilities = [
"WITH",
"AND",
"OR",
"(",
")",
":",
"+"
];
for (var i = 0; i < possibilities.length; i++) {
string = read(possibilities[i]);
if (string) {
break;
}
}
if (string === "+" && index > 1 && source[index - 2] === " ") {
throw new Error("Space before `+`");
}
return string && {
type: "OPERATOR",
string
};
}
__name(operator, "operator");
function idstring() {
return read(/[A-Za-z0-9-.]+/);
}
__name(idstring, "idstring");
function expectIdstring() {
var string = idstring();
if (!string) {
throw new Error("Expected idstring at offset " + index);
}
return string;
}
__name(expectIdstring, "expectIdstring");
function documentRef() {
if (read("DocumentRef-")) {
var string = expectIdstring();
return {
type: "DOCUMENTREF",
string
};
}
}
__name(documentRef, "documentRef");
function licenseRef() {
if (read("LicenseRef-")) {
var string = expectIdstring();
return {
type: "LICENSEREF",
string
};
}
}
__name(licenseRef, "licenseRef");
function identifier2() {
var begin = index;
var string = idstring();
if (licenses.indexOf(string) !== -1) {
return {
type: "LICENSE",
string
};
} else if (exceptions.indexOf(string) !== -1) {
return {
type: "EXCEPTION",
string
};
}
index = begin;
}
__name(identifier2, "identifier");
function parseToken() {
return operator() || documentRef() || licenseRef() || identifier2();
}
__name(parseToken, "parseToken");
var tokens = [];
while (hasMore()) {
skipWhitespace();
if (!hasMore()) {
break;
}
var token = parseToken();
if (!token) {
throw new Error("Unexpected `" + source[index] + "` at offset " + index);
}
tokens.push(token);
}
return tokens;
};
}
});
// node_modules/spdx-expression-parse/parse.js
var require_parse = __commonJS({
"node_modules/spdx-expression-parse/parse.js"(exports, module2) {
"use strict";
module2.exports = function(tokens) {
var index = 0;
function hasMore() {
return index < tokens.length;
}
__name(hasMore, "hasMore");
function token() {
return hasMore() ? tokens[index] : null;
}
__name(token, "token");
function next() {
if (!hasMore()) {
throw new Error();
}
index++;
}
__name(next, "next");
function parseOperator(operator) {
var t2 = token();
if (t2 && t2.type === "OPERATOR" && operator === t2.string) {
next();
return t2.string;
}
}
__name(parseOperator, "parseOperator");
function parseWith() {
if (parseOperator("WITH")) {
var t2 = token();
if (t2 && t2.type === "EXCEPTION") {
next();
return t2.string;
}
throw new Error("Expected exception after `WITH`");
}
}
__name(parseWith, "parseWith");
function parseLicenseRef() {
var begin = index;
var string = "";
var t2 = token();
if (t2.type === "DOCUMENTREF") {
next();
string += "DocumentRef-" + t2.string + ":";
if (!parseOperator(":")) {
throw new Error("Expected `:` after `DocumentRef-...`");
}
}
t2 = token();
if (t2.type === "LICENSEREF") {
next();
string += "LicenseRef-" + t2.string;
return {
license: string
};
}
index = begin;
}
__name(parseLicenseRef, "parseLicenseRef");
function parseLicense() {
var t2 = token();
if (t2 && t2.type === "LICENSE") {
next();
var node2 = {
license: t2.string
};
if (parseOperator("+")) {
node2.plus = true;
}
var exception = parseWith();
if (exception) {
node2.exception = exception;
}
return node2;
}
}
__name(parseLicense, "parseLicense");
function parseParenthesizedExpression() {
var left = parseOperator("(");
if (!left) {
return;
}
var expr = parseExpression();
if (!parseOperator(")")) {
throw new Error("Expected `)`");
}
return expr;
}
__name(parseParenthesizedExpression, "parseParenthesizedExpression");
function parseAtom() {
return parseParenthesizedExpression() || parseLicenseRef() || parseLicense();
}
__name(parseAtom, "parseAtom");
function makeBinaryOpParser(operator, nextParser) {
return /* @__PURE__ */ __name(function parseBinaryOp() {
var left = nextParser();
if (!left) {
return;
}
if (!parseOperator(operator)) {
return left;
}
var right = parseBinaryOp();
if (!right) {
throw new Error("Expected expression");
}
return {
left,
conjunction: operator.toLowerCase(),
right
};
}, "parseBinaryOp");
}
__name(makeBinaryOpParser, "makeBinaryOpParser");
var parseAnd = makeBinaryOpParser("AND", parseAtom);
var parseExpression = makeBinaryOpParser("OR", parseAnd);
var node = parseExpression();
if (!node || hasMore()) {
throw new Error("Syntax error");
}
return node;
};
}
});
// node_modules/spdx-expression-parse/index.js
var require_spdx_expression_parse = __commonJS({
"node_modules/spdx-expression-parse/index.js"(exports, module2) {
"use strict";
var scan = require_scan();
var parse = require_parse();
module2.exports = function(source) {
return parse(scan(source));
};
}
});
// node_modules/spdx-correct/index.js
var require_spdx_correct = __commonJS({
"node_modules/spdx-correct/index.js"(exports, module2) {
var parse = require_spdx_expression_parse();
var spdxLicenseIds = require_spdx_license_ids();
function valid(string) {
try {
parse(string);
return true;
} catch (error) {
return false;
}
}
__name(valid, "valid");
function sortTranspositions(a, b) {
var length = b[0].length - a[0].length;
if (length !== 0)
return length;
return a[0].toUpperCase().localeCompare(b[0].toUpperCase());
}
__name(sortTranspositions, "sortTranspositions");
var transpositions = [
[
"APGL",
"AGPL"
],
[
"Gpl",
"GPL"
],
[
"GLP",
"GPL"
],
[
"APL",
"Apache"
],
[
"ISD",
"ISC"
],
[
"GLP",
"GPL"
],
[
"IST",
"ISC"
],
[
"Claude",
"Clause"
],
[
" or later",
"+"
],
[
" International",
""
],
[
"GNU",
"GPL"
],
[
"GUN",
"GPL"
],
[
"+",
""
],
[
"GNU GPL",
"GPL"
],
[
"GNU LGPL",
"LGPL"
],
[
"GNU/GPL",
"GPL"
],
[
"GNU GLP",
"GPL"
],
[
"GNU LESSER GENERAL PUBLIC LICENSE",
"LGPL"
],
[
"GNU Lesser General Public License",
"LGPL"
],
[
"GNU LESSER GENERAL PUBLIC LICENSE",
"LGPL-2.1"
],
[
"GNU Lesser General Public License",
"LGPL-2.1"
],
[
"LESSER GENERAL PUBLIC LICENSE",
"LGPL"
],
[
"Lesser General Public License",
"LGPL"
],
[
"LESSER GENERAL PUBLIC LICENSE",
"LGPL-2.1"
],
[
"Lesser General Public License",
"LGPL-2.1"
],
[
"GNU General Public License",
"GPL"
],
[
"Gnu public license",
"GPL"
],
[
"GNU Public License",
"GPL"
],
[
"GNU GENERAL PUBLIC LICENSE",
"GPL"
],
[
"MTI",
"MIT"
],
[
"Mozilla Public License",
"MPL"
],
[
"Universal Permissive License",
"UPL"
],
[
"WTH",
"WTF"
],
[
"WTFGPL",
"WTFPL"
],
[
"-License",
""
]
].sort(sortTranspositions);
var TRANSPOSED = 0;
var CORRECT = 1;
var transforms = [
// e.g. 'mit'
function(argument) {
return argument.toUpperCase();
},
// e.g. 'MIT '
function(argument) {
return argument.trim();
},
// e.g. 'M.I.T.'
function(argument) {
return argument.replace(/\./g, "");
},
// e.g. 'Apache- 2.0'
function(argument) {
return argument.replace(/\s+/g, "");
},
// e.g. 'CC BY 4.0''
function(argument) {
return argument.replace(/\s+/g, "-");
},
// e.g. 'LGPLv2.1'
function(argument) {
return argument.replace("v", "-");
},
// e.g. 'Apache 2.0'
function(argument) {
return argument.replace(/,?\s*(\d)/, "-$1");
},
// e.g. 'GPL 2'
function(argument) {
return argument.replace(/,?\s*(\d)/, "-$1.0");
},
// e.g. 'Apache Version 2.0'
function(argument) {
return argument.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/, "-$2");
},
// e.g. 'Apache Version 2'
function(argument) {
return argument.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/, "-$2.0");
},
// e.g. 'ZLIB'
function(argument) {
return argument[0].toUpperCase() + argument.slice(1);
},
// e.g. 'MPL/2.0'
function(argument) {
return argument.replace("/", "-");
},
// e.g. 'Apache 2'
function(argument) {
return argument.replace(/\s*V\s*(\d)/, "-$1").replace(/(\d)$/, "$1.0");
},
// e.g. 'GPL-2.0', 'GPL-3.0'
function(argument) {
if (argument.indexOf("3.0") !== -1) {
return argument + "-or-later";
} else {
return argument + "-only";
}
},
// e.g. 'GPL-2.0-'
function(argument) {
return argument + "only";
},
// e.g. 'GPL2'
function(argument) {
return argument.replace(/(\d)$/, "-$1.0");
},
// e.g. 'BSD 3'
function(argument) {
return argument.replace(/(-| )?(\d)$/, "-$2-Clause");
},
// e.g. 'BSD clause 3'
function(argument) {
return argument.replace(/(-| )clause(-| )(\d)/, "-$3-Clause");
},
// e.g. 'New BSD license'
function(argument) {
return argument.replace(/\b(Modified|New|Revised)(-| )?BSD((-| )License)?/i, "BSD-3-Clause");
},
// e.g. 'Simplified BSD license'
function(argument) {
return argument.replace(/\bSimplified(-| )?BSD((-| )License)?/i, "BSD-2-Clause");
},
// e.g. 'Free BSD license'
function(argument) {
return argument.replace(/\b(Free|Net)(-| )?BSD((-| )License)?/i, "BSD-2-Clause-$1BSD");
},
// e.g. 'Clear BSD license'
function(argument) {
return argument.replace(/\bClear(-| )?BSD((-| )License)?/i, "BSD-3-Clause-Clear");
},
// e.g. 'Old BSD License'
function(argument) {
return argument.replace(/\b(Old|Original)(-| )?BSD((-| )License)?/i, "BSD-4-Clause");
},
// e.g. 'BY-NC-4.0'
function(argument) {
return "CC-" + argument;
},
// e.g. 'BY-NC'
function(argument) {
return "CC-" + argument + "-4.0";
},
// e.g. 'Attribution-NonCommercial'
function(argument) {
return argument.replace("Attribution", "BY").replace("NonCommercial", "NC").replace("NoDerivatives", "ND").replace(/ (\d)/, "-$1").replace(/ ?International/, "");
},
// e.g. 'Attribution-NonCommercial'
function(argument) {
return "CC-" + argument.replace("Attribution", "BY").replace("NonCommercial", "NC").replace("NoDerivatives", "ND").replace(/ (\d)/, "-$1").replace(/ ?International/, "") + "-4.0";
}
];
var licensesWithVersions = spdxLicenseIds.map(function(id) {
var match = /^(.*)-\d+\.\d+$/.exec(id);
return match ? [
match[0],
match[1]
] : [
id,
null
];
}).reduce(function(objectMap, item) {
var key = item[1];
objectMap[key] = objectMap[key] || [];
objectMap[key].push(item[0]);
return objectMap;
}, {});
var licensesWithOneVersion = Object.keys(licensesWithVersions).map(/* @__PURE__ */ __name(function makeEntries(key) {
return [
key,
licensesWithVersions[key]
];
}, "makeEntries")).filter(/* @__PURE__ */ __name(function identifySoleVersions(item) {
return (
// Licenses has just one valid version suffix.
item[1].length === 1 && item[0] !== null && // APL will be considered Apache, rather than APL-1.0
item[0] !== "APL"
);
}, "identifySoleVersions")).map(/* @__PURE__ */ __name(function createLastResorts(item) {
return [
item[0],
item[1][0]
];
}, "createLastResorts"));
licensesWithVersions = void 0;
var lastResorts = [
[
"UNLI",
"Unlicense"
],
[
"WTF",
"WTFPL"
],
[
"2 CLAUSE",
"BSD-2-Clause"
],
[
"2-CLAUSE",
"BSD-2-Clause"
],
[
"3 CLAUSE",
"BSD-3-Clause"
],
[
"3-CLAUSE",
"BSD-3-Clause"
],
[
"AFFERO",
"AGPL-3.0-or-later"
],
[
"AGPL",
"AGPL-3.0-or-later"
],
[
"APACHE",
"Apache-2.0"
],
[
"ARTISTIC",
"Artistic-2.0"
],
[
"Affero",
"AGPL-3.0-or-later"
],
[
"BEER",
"Beerware"
],
[
"BOOST",
"BSL-1.0"
],
[
"BSD",
"BSD-2-Clause"
],
[
"CDDL",
"CDDL-1.1"
],
[
"ECLIPSE",
"EPL-1.0"
],
[
"FUCK",
"WTFPL"
],
[
"GNU",
"GPL-3.0-or-later"
],
[
"LGPL",
"LGPL-3.0-or-later"
],
[
"GPLV1",
"GPL-1.0-only"
],
[
"GPL-1",
"GPL-1.0-only"
],
[
"GPLV2",
"GPL-2.0-only"
],
[
"GPL-2",
"GPL-2.0-only"
],
[
"GPL",
"GPL-3.0-or-later"
],
[
"MIT +NO-FALSE-ATTRIBS",
"MITNFA"
],
[
"MIT",
"MIT"
],
[
"MPL",
"MPL-2.0"
],
[
"X11",
"X11"
],
[
"ZLIB",
"Zlib"
]
].concat(licensesWithOneVersion).sort(sortTranspositions);
var SUBSTRING = 0;
var IDENTIFIER = 1;
var validTransformation = /* @__PURE__ */ __name(function(identifier2) {
for (var i = 0; i < transforms.length; i++) {
var transformed = transforms[i](identifier2).trim();
if (transformed !== identifier2 && valid(transformed)) {
return transformed;
}
}
return null;
}, "validTransformation");
var validLastResort = /* @__PURE__ */ __name(function(identifier2) {
var upperCased = identifier2.toUpperCase();
for (var i = 0; i < lastResorts.length; i++) {
var lastResort = lastResorts[i];
if (upperCased.indexOf(lastResort[SUBSTRING]) > -1) {
return lastResort[IDENTIFIER];
}
}
return null;
}, "validLastResort");
var anyCorrection = /* @__PURE__ */ __name(function(identifier2, check) {
for (var i = 0; i < transpositions.length; i++) {
var transposition = transpositions[i];
var transposed = transposition[TRANSPOSED];
if (identifier2.indexOf(transposed) > -1) {
var corrected = identifier2.replace(transposed, transposition[CORRECT]);
var checked = check(corrected);
if (checked !== null) {
return checked;
}
}
}
return null;
}, "anyCorrection");
module2.exports = function(identifier2, options) {
options = options || {};
var upgrade = options.upgrade === void 0 ? true : !!options.upgrade;
function postprocess(value) {
return upgrade ? upgradeGPLs(value) : value;
}
__name(postprocess, "postprocess");
var validArugment = typeof identifier2 === "string" && identifier2.trim().length !== 0;
if (!validArugment) {
throw Error("Invalid argument. Expected non-empty string.");
}
identifier2 = identifier2.trim();
if (valid(identifier2)) {
return postprocess(identifier2);
}
var noPlus = identifier2.replace(/\+$/, "").trim();
if (valid(noPlus)) {
return postprocess(noPlus);
}
var transformed = validTransformation(identifier2);
if (transformed !== null) {
return postprocess(transformed);
}
transformed = anyCorrection(identifier2, function(argument) {
if (valid(argument)) {
return argument;
}
return validTransformation(argument);
});
if (transformed !== null) {
return postprocess(transformed);
}
transformed = validLastResort(identifier2);
if (transformed !== null) {
return postprocess(transformed);
}
transformed = anyCorrection(identifier2, validLastResort);
if (transformed !== null) {
return postprocess(transformed);
}
return null;
};
function upgradeGPLs(value) {
if ([
"GPL-1.0",
"LGPL-1.0",
"AGPL-1.0",
"GPL-2.0",
"LGPL-2.0",
"AGPL-2.0",
"LGPL-2.1"
].indexOf(value) !== -1) {
return value + "-only";
} else if ([
"GPL-1.0+",
"GPL-2.0+",
"GPL-3.0+",
"LGPL-2.0+",
"LGPL-2.1+",
"LGPL-3.0+",
"AGPL-1.0+",
"AGPL-3.0+"
].indexOf(value) !== -1) {
return value.replace(/\+$/, "-or-later");
} else if ([
"GPL-3.0",
"LGPL-3.0",
"AGPL-3.0"
].indexOf(value) !== -1) {
return value + "-or-later";
} else {
return value;
}
}
__name(upgradeGPLs, "upgradeGPLs");
}
});
// node_modules/validate-npm-package-license/index.js
var require_validate_npm_package_license = __commonJS({
"node_modules/validate-npm-package-license/index.js"(exports, module2) {
var parse = require_spdx_expression_parse();
var correct = require_spdx_correct();
var genericWarning = 'license should be a valid SPDX license expression (without "LicenseRef"), "UNLICENSED", or "SEE LICENSE IN <filename>"';
var fileReferenceRE = /^SEE LICEN[CS]E IN (.+)$/;
function startsWith(prefix, string) {
return string.slice(0, prefix.length) === prefix;
}
__name(startsWith, "startsWith");
function usesLicenseRef(ast) {
if (ast.hasOwnProperty("license")) {
var license = ast.license;
return startsWith("LicenseRef", license) || startsWith("DocumentRef", license);
} else {
return usesLicenseRef(ast.left) || usesLicenseRef(ast.right);
}
}
__name(usesLicenseRef, "usesLicenseRef");
module2.exports = function(argument) {
var ast;
try {
ast = parse(argument);
} catch (e) {
var match;
if (argument === "UNLICENSED" || argument === "UNLICENCED") {
return {
validForOldPackages: true,
validForNewPackages: true,
unlicensed: true
};
} else if (match = fileReferenceRE.exec(argument)) {
return {
validForOldPackages: true,
validForNewPackages: true,
inFile: match[1]
};
} else {
var result = {
validForOldPackages: false,
validForNewPackages: false,
warnings: [
genericWarning
]
};
if (argument.trim().length !== 0) {
var corrected = correct(argument);
if (corrected) {
result.warnings.push('license is similar to the valid expression "' + corrected + '"');
}
}
return result;
}
}
if (usesLicenseRef(ast)) {
return {
validForNewPackages: false,
validForOldPackages: false,
spdx: true,
warnings: [
genericWarning
]
};
} else {
return {
validForNewPackages: true,
validForOldPackages: true,
spdx: true
};
}
};
}
});
// node_modules/hosted-git-info/git-host-info.js
var require_git_host_info = __commonJS({
"node_modules/hosted-git-info/git-host-info.js"(exports, module2) {
"use strict";
var gitHosts = module2.exports = {
github: {
// First two are insecure and generally shouldn't be used any more, but
// they are still supported.
"protocols": [
"git",
"http",
"git+ssh",
"git+https",
"ssh",
"https"
],
"domain": "github.com",
"treepath": "tree",
"filetemplate": "https://{auth@}raw.githubusercontent.com/{user}/{project}/{committish}/{path}",
"bugstemplate": "https://{domain}/{user}/{project}/issues",
"gittemplate": "git://{auth@}{domain}/{user}/{project}.git{#committish}",
"tarballtemplate": "https://codeload.{domain}/{user}/{project}/tar.gz/{committish}"
},
bitbucket: {
"protocols": [
"git+ssh",
"git+https",
"ssh",
"https"
],
"domain": "bitbucket.org",
"treepath": "src",
"tarballtemplate": "https://{domain}/{user}/{project}/get/{committish}.tar.gz"
},
gitlab: {
"protocols": [
"git+ssh",
"git+https",
"ssh",
"https"
],
"domain": "gitlab.com",
"treepath": "tree",
"bugstemplate": "https://{domain}/{user}/{project}/issues",
"httpstemplate": "git+https://{auth@}{domain}/{user}/{projectPath}.git{#committish}",
"tarballtemplate": "https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}",
"pathmatch": /^[/]([^/]+)[/]((?!.*(\/-\/|\/repository\/archive\.tar\.gz\?=.*|\/repository\/[^/]+\/archive.tar.gz$)).*?)(?:[.]git|[/])?$/
},
gist: {
"protocols": [
"git",
"git+ssh",
"git+https",
"ssh",
"https"
],
"domain": "gist.github.com",
"pathmatch": /^[/](?:([^/]+)[/])?([a-z0-9]{32,})(?:[.]git)?$/,
"filetemplate": "https://gist.githubusercontent.com/{user}/{project}/raw{/committish}/{path}",
"bugstemplate": "https://{domain}/{project}",
"gittemplate": "git://{domain}/{project}.git{#committish}",
"sshtemplate": "git@{domain}:/{project}.git{#committish}",
"sshurltemplate": "git+ssh://git@{domain}/{project}.git{#committish}",
"browsetemplate": "https://{domain}/{project}{/committish}",
"browsefiletemplate": "https://{domain}/{project}{/committish}{#path}",
"docstemplate": "https://{domain}/{project}{/committish}",
"httpstemplate": "git+https://{domain}/{project}.git{#committish}",
"shortcuttemplate": "{type}:{project}{#committish}",
"pathtemplate": "{project}{#committish}",
"tarballtemplate": "https://codeload.github.com/gist/{project}/tar.gz/{committish}",
"hashformat": function(fragment) {
return "file-" + formatHashFragment(fragment);
}
}
};
var gitHostDefaults = {
"sshtemplate": "git@{domain}:{user}/{project}.git{#committish}",
"sshurltemplate": "git+ssh://git@{domain}/{user}/{project}.git{#committish}",
"browsetemplate": "https://{domain}/{user}/{project}{/tree/committish}",
"browsefiletemplate": "https://{domain}/{user}/{project}/{treepath}/{committish}/{path}{#fragment}",
"docstemplate": "https://{domain}/{user}/{project}{/tree/committish}#readme",
"httpstemplate": "git+https://{auth@}{domain}/{user}/{project}.git{#committish}",
"filetemplate": "https://{domain}/{user}/{project}/raw/{committish}/{path}",
"shortcuttemplate": "{type}:{user}/{project}{#committish}",
"pathtemplate": "{user}/{project}{#committish}",
"pathmatch": /^[/]([^/]+)[/]([^/]+?)(?:[.]git|[/])?$/,
"hashformat": formatHashFragment
};
Object.keys(gitHosts).forEach(function(name) {
Object.keys(gitHostDefaults).forEach(function(key) {
if (gitHosts[name][key])
return;
gitHosts[name][key] = gitHostDefaults[key];
});
gitHosts[name].protocols_re = RegExp("^(" + gitHosts[name].protocols.map(function(protocol) {
return protocol.replace(/([\\+*{}()[\]$^|])/g, "\\$1");
}).join("|") + "):$");
});
function formatHashFragment(fragment) {
return fragment.toLowerCase().replace(/^\W+|\/|\W+$/g, "").replace(/\W+/g, "-");
}
__name(formatHashFragment, "formatHashFragment");
}
});
// node_modules/hosted-git-info/git-host.js
var require_git_host = __commonJS({
"node_modules/hosted-git-info/git-host.js"(exports, module2) {
"use strict";
var gitHosts = require_git_host_info();
var extend = Object.assign || /* @__PURE__ */ __name(function _extend(target, source) {
if (source === null || typeof source !== "object")
return target;
var keys = Object.keys(source);
var i = keys.length;
while (i--) {
target[keys[i]] = source[keys[i]];
}
return target;
}, "_extend");
module2.exports = GitHost;
function GitHost(type, user, auth, project, committish, defaultRepresentation, opts) {
var gitHostInfo = this;
gitHostInfo.type = type;
Object.keys(gitHosts[type]).forEach(function(key) {
gitHostInfo[key] = gitHosts[type][key];
});
gitHostInfo.user = user;
gitHostInfo.auth = auth;
gitHostInfo.project = project;
gitHostInfo.committish = committish;
gitHostInfo.default = defaultRepresentation;
gitHostInfo.opts = opts || {};
}
__name(GitHost, "GitHost");
GitHost.prototype.hash = function() {
return this.committish ? "#" + this.committish : "";
};
GitHost.prototype._fill = function(template2, opts) {
if (!template2)
return;
var vars = extend({}, opts);
vars.path = vars.path ? vars.path.replace(/^[/]+/g, "") : "";
opts = extend(extend({}, this.opts), opts);
var self = this;
Object.keys(this).forEach(function(key) {
if (self[key] != null && vars[key] == null)
vars[key] = self[key];
});
var rawAuth = vars.auth;
var rawcommittish = vars.committish;
var rawFragment = vars.fragment;
var rawPath = vars.path;
var rawProject = vars.project;
Object.keys(vars).forEach(function(key) {
var value = vars[key];
if ((key === "path" || key === "project") && typeof value === "string") {
vars[key] = value.split("/").map(function(pathComponent) {
return encodeURIComponent(pathComponent);
}).join("/");
} else {
vars[key] = encodeURIComponent(value);
}
});
vars["auth@"] = rawAuth ? rawAuth + "@" : "";
vars["#fragment"] = rawFragment ? "#" + this.hashformat(rawFragment) : "";
vars.fragment = vars.fragment ? vars.fragment : "";
vars["#path"] = rawPath ? "#" + this.hashformat(rawPath) : "";
vars["/path"] = vars.path ? "/" + vars.path : "";
vars.projectPath = rawProject.split("/").map(encodeURIComponent).join("/");
if (opts.noCommittish) {
vars["#committish"] = "";
vars["/tree/committish"] = "";
vars["/committish"] = "";
vars.committish = "";
} else {
vars["#committish"] = rawcommittish ? "#" + rawcommittish : "";
vars["/tree/committish"] = vars.committish ? "/" + vars.treepath + "/" + vars.committish : "";
vars["/committish"] = vars.committish ? "/" + vars.committish : "";
vars.committish = vars.committish || "master";
}
var res = template2;
Object.keys(vars).forEach(function(key) {
res = res.replace(new RegExp("[{]" + key + "[}]", "g"), vars[key]);
});
if (opts.noGitPlus) {
return res.replace(/^git[+]/, "");
} else {
return res;
}
};
GitHost.prototype.ssh = function(opts) {
return this._fill(this.sshtemplate, opts);
};
GitHost.prototype.sshurl = function(opts) {
return this._fill(this.sshurltemplate, opts);
};
GitHost.prototype.browse = function(P, F, opts) {
if (typeof P === "string") {
if (typeof F !== "string") {
opts = F;
F = null;
}
return this._fill(this.browsefiletemplate, extend({
fragment: F,
path: P
}, opts));
} else {
return this._fill(this.browsetemplate, P);
}
};
GitHost.prototype.docs = function(opts) {
return this._fill(this.docstemplate, opts);
};
GitHost.prototype.bugs = function(opts) {
return this._fill(this.bugstemplate, opts);
};
GitHost.prototype.https = function(opts) {
return this._fill(this.httpstemplate, opts);
};
GitHost.prototype.git = function(opts) {
return this._fill(this.gittemplate, opts);
};
GitHost.prototype.shortcut = function(opts) {
return this._fill(this.shortcuttemplate, opts);
};
GitHost.prototype.path = function(opts) {
return this._fill(this.pathtemplate, opts);
};
GitHost.prototype.tarball = function(opts_) {
var opts = extend({}, opts_, {
noCommittish: false
});
return this._fill(this.tarballtemplate, opts);
};
GitHost.prototype.file = function(P, opts) {
return this._fill(this.filetemplate, extend({
path: P
}, opts));
};
GitHost.prototype.getDefaultRepresentation = function() {
return this.default;
};
GitHost.prototype.toString = function(opts) {
if (this.default && typeof this[this.default] === "function")
return this[this.default](opts);
return this.sshurl(opts);
};
}
});
// node_modules/hosted-git-info/index.js
var require_hosted_git_info = __commonJS({
"node_modules/hosted-git-info/index.js"(exports, module2) {
"use strict";
var url = require("url");
var gitHosts = require_git_host_info();
var GitHost = module2.exports = require_git_host();
var protocolToRepresentationMap = {
"git+ssh:": "sshurl",
"git+https:": "https",
"ssh:": "sshurl",
"git:": "git"
};
function protocolToRepresentation(protocol) {
return protocolToRepresentationMap[protocol] || protocol.slice(0, -1);
}
__name(protocolToRepresentation, "protocolToRepresentation");
var authProtocols = {
"git:": true,
"https:": true,
"git+https:": true,
"http:": true,
"git+http:": true
};
var cache = {};
module2.exports.fromUrl = function(giturl, opts) {
if (typeof giturl !== "string")
return;
var key = giturl + JSON.stringify(opts || {});
if (!(key in cache)) {
cache[key] = fromUrl(giturl, opts);
}
return cache[key];
};
function fromUrl(giturl, opts) {
if (giturl == null || giturl === "")
return;
var url2 = fixupUnqualifiedGist(isGitHubShorthand(giturl) ? "github:" + giturl : giturl);
var parsed = parseGitUrl(url2);
var shortcutMatch = url2.match(/^([^:]+):(?:[^@]+@)?(?:([^/]*)\/)?([^#]+)/);
var matches = Object.keys(gitHosts).map(function(gitHostName) {
try {
var gitHostInfo = gitHosts[gitHostName];
var auth = null;
if (parsed.auth && authProtocols[parsed.protocol]) {
auth = parsed.auth;
}
var committish = parsed.hash ? decodeURIComponent(parsed.hash.substr(1)) : null;
var user = null;
var project = null;
var defaultRepresentation = null;
if (shortcutMatch && shortcutMatch[1] === gitHostName) {
user = shortcutMatch[2] && decodeURIComponent(shortcutMatch[2]);
project = decodeURIComponent(shortcutMatch[3].replace(/\.git$/, ""));
defaultRepresentation = "shortcut";
} else {
if (parsed.host && parsed.host !== gitHostInfo.domain && parsed.host.replace(/^www[.]/, "") !== gitHostInfo.domain)
return;
if (!gitHostInfo.protocols_re.test(parsed.protocol))
return;
if (!parsed.path)
return;
var pathmatch = gitHostInfo.pathmatch;
var matched = parsed.path.match(pathmatch);
if (!matched)
return;
if (matched[1] !== null && matched[1] !== void 0) {
user = decodeURIComponent(matched[1].replace(/^:/, ""));
}
project = decodeURIComponent(matched[2]);
defaultRepresentation = protocolToRepresentation(parsed.protocol);
}
return new GitHost(gitHostName, user, auth, project, committish, defaultRepresentation, opts);
} catch (ex) {
if (ex instanceof URIError) {
} else
throw ex;
}
}).filter(function(gitHostInfo) {
return gitHostInfo;
});
if (matches.length !== 1)
return;
return matches[0];
}
__name(fromUrl, "fromUrl");
function isGitHubShorthand(arg) {
return /^[^:@%/\s.-][^:@%/\s]*[/][^:@\s/%]+(?:#.*)?$/.test(arg);
}
__name(isGitHubShorthand, "isGitHubShorthand");
function fixupUnqualifiedGist(giturl) {
var parsed = url.parse(giturl);
if (parsed.protocol === "gist:" && parsed.host && !parsed.path) {
return parsed.protocol + "/" + parsed.host;
} else {
return giturl;
}
}
__name(fixupUnqualifiedGist, "fixupUnqualifiedGist");
function parseGitUrl(giturl) {
var matched = giturl.match(/^([^@]+)@([^:/]+):[/]?((?:[^/]+[/])?[^/]+?)(?:[.]git)?(#.*)?$/);
if (!matched) {
var legacy = url.parse(giturl);
if (legacy.auth && typeof url.URL === "function") {
var authmatch = giturl.match(/[^@]+@[^:/]+/);
if (authmatch) {
var whatwg = new url.URL(authmatch[0]);
legacy.auth = whatwg.username || "";
if (whatwg.password)
legacy.auth += ":" + whatwg.password;
}
}
return legacy;
}
return {
protocol: "git+ssh:",
slashes: true,
auth: matched[1],
host: matched[2],
port: null,
hostname: matched[2],
hash: matched[4],
search: null,
query: null,
pathname: "/" + matched[3],
path: "/" + matched[3],
href: "git+ssh://" + matched[1] + "@" + matched[2] + "/" + matched[3] + (matched[4] || "")
};
}
__name(parseGitUrl, "parseGitUrl");
}
});
// node_modules/resolve/lib/homedir.js
var require_homedir = __commonJS({
"node_modules/resolve/lib/homedir.js"(exports, module2) {
"use strict";
var os = require("os");
module2.exports = os.homedir || /* @__PURE__ */ __name(function homedir() {
var home = process.env.HOME;
var user = process.env.LOGNAME || process.env.USER || process.env.LNAME || process.env.USERNAME;
if (process.platform === "win32") {
return process.env.USERPROFILE || process.env.HOMEDRIVE + process.env.HOMEPATH || home || null;
}
if (process.platform === "darwin") {
return home || (user ? "/Users/" + user : null);
}
if (process.platform === "linux") {
return home || (process.getuid() === 0 ? "/root" : user ? "/home/" + user : null);
}
return home || null;
}, "homedir");
}
});
// node_modules/resolve/lib/caller.js
var require_caller = __commonJS({
"node_modules/resolve/lib/caller.js"(exports, module2) {
module2.exports = function() {
var origPrepareStackTrace = Error.prepareStackTrace;
Error.prepareStackTrace = function(_, stack2) {
return stack2;
};
var stack = new Error().stack;
Error.prepareStackTrace = origPrepareStackTrace;
return stack[2].getFileName();
};
}
});
// node_modules/path-parse/index.js
var require_path_parse = __commonJS({
"node_modules/path-parse/index.js"(exports, module2) {
"use strict";
var isWindows = process.platform === "win32";
var splitWindowsRe = /^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/;
var win32 = {};
function win32SplitPath(filename) {
return splitWindowsRe.exec(filename).slice(1);
}
__name(win32SplitPath, "win32SplitPath");
win32.parse = function(pathString) {
if (typeof pathString !== "string") {
throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
}
var allParts = win32SplitPath(pathString);
if (!allParts || allParts.length !== 5) {
throw new TypeError("Invalid path '" + pathString + "'");
}
return {
root: allParts[1],
dir: allParts[0] === allParts[1] ? allParts[0] : allParts[0].slice(0, -1),
base: allParts[2],
ext: allParts[4],
name: allParts[3]
};
};
var splitPathRe = /^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/;
var posix = {};
function posixSplitPath(filename) {
return splitPathRe.exec(filename).slice(1);
}
__name(posixSplitPath, "posixSplitPath");
posix.parse = function(pathString) {
if (typeof pathString !== "string") {
throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
}
var allParts = posixSplitPath(pathString);
if (!allParts || allParts.length !== 5) {
throw new TypeError("Invalid path '" + pathString + "'");
}
return {
root: allParts[1],
dir: allParts[0].slice(0, -1),
base: allParts[2],
ext: allParts[4],
name: allParts[3]
};
};
if (isWindows)
module2.exports = win32.parse;
else
module2.exports = posix.parse;
module2.exports.posix = posix.parse;
module2.exports.win32 = win32.parse;
}
});
// node_modules/resolve/lib/node-modules-paths.js
var require_node_modules_paths = __commonJS({
"node_modules/resolve/lib/node-modules-paths.js"(exports, module2) {
var path5 = require("path");
var parse = path5.parse || require_path_parse();
var getNodeModulesDirs = /* @__PURE__ */ __name(function getNodeModulesDirs2(absoluteStart, modules) {
var prefix = "/";
if (/^([A-Za-z]:)/.test(absoluteStart)) {
prefix = "";
} else if (/^\\\\/.test(absoluteStart)) {
prefix = "\\\\";
}
var paths = [
absoluteStart
];
var parsed = parse(absoluteStart);
while (parsed.dir !== paths[paths.length - 1]) {
paths.push(parsed.dir);
parsed = parse(parsed.dir);
}
return paths.reduce(function(dirs, aPath) {
return dirs.concat(modules.map(function(moduleDir) {
return path5.resolve(prefix, aPath, moduleDir);
}));
}, []);
}, "getNodeModulesDirs");
module2.exports = /* @__PURE__ */ __name(function nodeModulesPaths(start, opts, request) {
var modules = opts && opts.moduleDirectory ? [].concat(opts.moduleDirectory) : [
"node_modules"
];
if (opts && typeof opts.paths === "function") {
return opts.paths(request, start, function() {
return getNodeModulesDirs(start, modules);
}, opts);
}
var dirs = getNodeModulesDirs(start, modules);
return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
}, "nodeModulesPaths");
}
});
// node_modules/resolve/lib/normalize-options.js
var require_normalize_options = __commonJS({
"node_modules/resolve/lib/normalize-options.js"(exports, module2) {
var path5 = require("path");
module2.exports = function(_, opts) {
opts = opts || {};
if (opts.forceNodeResolution || !process.versions.pnp)
return opts;
const { findPnpApi } = require("module");
const runPnpResolution = /* @__PURE__ */ __name((request, basedir) => {
const parts = request.match(/^((?:@[^/]+\/)?[^/]+)(\/.*)?/);
if (!parts)
throw new Error(`Assertion failed: Expected the "resolve" package to call the "paths" callback with package names only (got "${request}")`);
if (basedir.charAt(basedir.length - 1) !== `/`)
basedir = path5.join(basedir, `/`);
const api = findPnpApi(basedir);
if (api === null)
return void 0;
let manifestPath;
try {
manifestPath = api.resolveToUnqualified(`${parts[1]}/package.json`, basedir, {
considerBuiltins: false
});
} catch (err) {
return null;
}
if (manifestPath === null)
throw new Error(`Assertion failed: The resolution thinks that "${parts[1]}" is a Node builtin`);
const packagePath = path5.dirname(manifestPath);
const unqualifiedPath = typeof parts[2] !== `undefined` ? path5.join(packagePath, parts[2]) : packagePath;
return {
packagePath,
unqualifiedPath
};
}, "runPnpResolution");
const runPnpResolutionOnArray = /* @__PURE__ */ __name((request, paths2) => {
for (let i = 0; i < paths2.length; i++) {
const resolution = runPnpResolution(request, paths2[i]);
if (resolution || i === paths2.length - 1) {
return resolution;
}
}
return null;
}, "runPnpResolutionOnArray");
const originalPaths = Array.isArray(opts.paths) ? opts.paths : [];
const packageIterator = /* @__PURE__ */ __name((request, basedir, getCandidates, opts2) => {
const pathsToTest = [
basedir
].concat(originalPaths);
const resolution = runPnpResolutionOnArray(request, pathsToTest);
if (resolution == null)
return getCandidates();
return [
resolution.unqualifiedPath
];
}, "packageIterator");
const paths = /* @__PURE__ */ __name((request, basedir, getNodeModulePaths, opts2) => {
const pathsToTest = [
basedir
].concat(originalPaths);
const resolution = runPnpResolutionOnArray(request, pathsToTest);
if (resolution == null)
return getNodeModulePaths().concat(originalPaths);
let nodeModules = path5.dirname(resolution.packagePath);
if (request.match(/^@[^/]+\//))
nodeModules = path5.dirname(nodeModules);
return [
nodeModules
];
}, "paths");
let isInsideIterator = false;
if (!opts.__skipPackageIterator) {
opts.packageIterator = function(request, basedir, getCandidates, opts2) {
isInsideIterator = true;
try {
return packageIterator(request, basedir, getCandidates, opts2);
} finally {
isInsideIterator = false;
}
};
}
opts.paths = function(request, basedir, getNodeModulePaths, opts2) {
if (isInsideIterator)
return getNodeModulePaths().concat(originalPaths);
return paths(request, basedir, getNodeModulePaths, opts2);
};
return opts;
};
}
});
// node_modules/function-bind/implementation.js
var require_implementation = __commonJS({
"node_modules/function-bind/implementation.js"(exports, module2) {
"use strict";
var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
var toStr = Object.prototype.toString;
var max = Math.max;
var funcType = "[object Function]";
var concatty = /* @__PURE__ */ __name(function concatty2(a, b) {
var arr = [];
for (var i = 0; i < a.length; i += 1) {
arr[i] = a[i];
}
for (var j = 0; j < b.length; j += 1) {
arr[j + a.length] = b[j];
}
return arr;
}, "concatty");
var slicy = /* @__PURE__ */ __name(function slicy2(arrLike, offset) {
var arr = [];
for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) {
arr[j] = arrLike[i];
}
return arr;
}, "slicy");
var joiny = /* @__PURE__ */ __name(function(arr, joiner) {
var str = "";
for (var i = 0; i < arr.length; i += 1) {
str += arr[i];
if (i + 1 < arr.length) {
str += joiner;
}
}
return str;
}, "joiny");
module2.exports = /* @__PURE__ */ __name(function bind(that) {
var target = this;
if (typeof target !== "function" || toStr.apply(target) !== funcType) {
throw new TypeError(ERROR_MESSAGE + target);
}
var args = slicy(arguments, 1);
var bound;
var binder = /* @__PURE__ */ __name(function() {
if (this instanceof bound) {
var result = target.apply(this, concatty(args, arguments));
if (Object(result) === result) {
return result;
}
return this;
}
return target.apply(that, concatty(args, arguments));
}, "binder");
var boundLength = max(0, target.length - args.length);
var boundArgs = [];
for (var i = 0; i < boundLength; i++) {
boundArgs[i] = "$" + i;
}
bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
if (target.prototype) {
var Empty = /* @__PURE__ */ __name(function Empty2() {
}, "Empty");
Empty.prototype = target.prototype;
bound.prototype = new Empty();
Empty.prototype = null;
}
return bound;
}, "bind");
}
});
// node_modules/function-bind/index.js
var require_function_bind = __commonJS({
"node_modules/function-bind/index.js"(exports, module2) {
"use strict";
var implementation = require_implementation();
module2.exports = Function.prototype.bind || implementation;
}
});
// node_modules/hasown/index.js
var require_hasown = __commonJS({
"node_modules/hasown/index.js"(exports, module2) {
"use strict";
var call = Function.prototype.call;
var $hasOwn = Object.prototype.hasOwnProperty;
var bind = require_function_bind();
module2.exports = bind.call(call, $hasOwn);
}
});
// node_modules/is-core-module/core.json
var require_core = __commonJS({
"node_modules/is-core-module/core.json"(exports, module2) {
module2.exports = {
assert: true,
"node:assert": [">= 14.18 && < 15", ">= 16"],
"assert/strict": ">= 15",
"node:assert/strict": ">= 16",
async_hooks: ">= 8",
"node:async_hooks": [">= 14.18 && < 15", ">= 16"],
buffer_ieee754: ">= 0.5 && < 0.9.7",
buffer: true,
"node:buffer": [">= 14.18 && < 15", ">= 16"],
child_process: true,
"node:child_process": [">= 14.18 && < 15", ">= 16"],
cluster: ">= 0.5",
"node:cluster": [">= 14.18 && < 15", ">= 16"],
console: true,
"node:console": [">= 14.18 && < 15", ">= 16"],
constants: true,
"node:constants": [">= 14.18 && < 15", ">= 16"],
crypto: true,
"node:crypto": [">= 14.18 && < 15", ">= 16"],
_debug_agent: ">= 1 && < 8",
_debugger: "< 8",
dgram: true,
"node:dgram": [">= 14.18 && < 15", ">= 16"],
diagnostics_channel: [">= 14.17 && < 15", ">= 15.1"],
"node:diagnostics_channel": [">= 14.18 && < 15", ">= 16"],
dns: true,
"node:dns": [">= 14.18 && < 15", ">= 16"],
"dns/promises": ">= 15",
"node:dns/promises": ">= 16",
domain: ">= 0.7.12",
"node:domain": [">= 14.18 && < 15", ">= 16"],
events: true,
"node:events": [">= 14.18 && < 15", ">= 16"],
freelist: "< 6",
fs: true,
"node:fs": [">= 14.18 && < 15", ">= 16"],
"fs/promises": [">= 10 && < 10.1", ">= 14"],
"node:fs/promises": [">= 14.18 && < 15", ">= 16"],
_http_agent: ">= 0.11.1",
"node:_http_agent": [">= 14.18 && < 15", ">= 16"],
_http_client: ">= 0.11.1",
"node:_http_client": [">= 14.18 && < 15", ">= 16"],
_http_common: ">= 0.11.1",
"node:_http_common": [">= 14.18 && < 15", ">= 16"],
_http_incoming: ">= 0.11.1",
"node:_http_incoming": [">= 14.18 && < 15", ">= 16"],
_http_outgoing: ">= 0.11.1",
"node:_http_outgoing": [">= 14.18 && < 15", ">= 16"],
_http_server: ">= 0.11.1",
"node:_http_server": [">= 14.18 && < 15", ">= 16"],
http: true,
"node:http": [">= 14.18 && < 15", ">= 16"],
http2: ">= 8.8",
"node:http2": [">= 14.18 && < 15", ">= 16"],
https: true,
"node:https": [">= 14.18 && < 15", ">= 16"],
inspector: ">= 8",
"node:inspector": [">= 14.18 && < 15", ">= 16"],
"inspector/promises": [">= 19"],
"node:inspector/promises": [">= 19"],
_linklist: "< 8",
module: true,
"node:module": [">= 14.18 && < 15", ">= 16"],
net: true,
"node:net": [">= 14.18 && < 15", ">= 16"],
"node-inspect/lib/_inspect": ">= 7.6 && < 12",
"node-inspect/lib/internal/inspect_client": ">= 7.6 && < 12",
"node-inspect/lib/internal/inspect_repl": ">= 7.6 && < 12",
os: true,
"node:os": [">= 14.18 && < 15", ">= 16"],
path: true,
"node:path": [">= 14.18 && < 15", ">= 16"],
"path/posix": ">= 15.3",
"node:path/posix": ">= 16",
"path/win32": ">= 15.3",
"node:path/win32": ">= 16",
perf_hooks: ">= 8.5",
"node:perf_hooks": [">= 14.18 && < 15", ">= 16"],
process: ">= 1",
"node:process": [">= 14.18 && < 15", ">= 16"],
punycode: ">= 0.5",
"node:punycode": [">= 14.18 && < 15", ">= 16"],
querystring: true,
"node:querystring": [">= 14.18 && < 15", ">= 16"],
readline: true,
"node:readline": [">= 14.18 && < 15", ">= 16"],
"readline/promises": ">= 17",
"node:readline/promises": ">= 17",
repl: true,
"node:repl": [">= 14.18 && < 15", ">= 16"],
smalloc: ">= 0.11.5 && < 3",
_stream_duplex: ">= 0.9.4",
"node:_stream_duplex": [">= 14.18 && < 15", ">= 16"],
_stream_transform: ">= 0.9.4",
"node:_stream_transform": [">= 14.18 && < 15", ">= 16"],
_stream_wrap: ">= 1.4.1",
"node:_stream_wrap": [">= 14.18 && < 15", ">= 16"],
_stream_passthrough: ">= 0.9.4",
"node:_stream_passthrough": [">= 14.18 && < 15", ">= 16"],
_stream_readable: ">= 0.9.4",
"node:_stream_readable": [">= 14.18 && < 15", ">= 16"],
_stream_writable: ">= 0.9.4",
"node:_stream_writable": [">= 14.18 && < 15", ">= 16"],
stream: true,
"node:stream": [">= 14.18 && < 15", ">= 16"],
"stream/consumers": ">= 16.7",
"node:stream/consumers": ">= 16.7",
"stream/promises": ">= 15",
"node:stream/promises": ">= 16",
"stream/web": ">= 16.5",
"node:stream/web": ">= 16.5",
string_decoder: true,
"node:string_decoder": [">= 14.18 && < 15", ">= 16"],
sys: [">= 0.4 && < 0.7", ">= 0.8"],
"node:sys": [">= 14.18 && < 15", ">= 16"],
"test/reporters": ">= 19.9 && < 20.2",
"node:test/reporters": [">= 18.17 && < 19", ">= 19.9", ">= 20"],
"node:test": [">= 16.17 && < 17", ">= 18"],
timers: true,
"node:timers": [">= 14.18 && < 15", ">= 16"],
"timers/promises": ">= 15",
"node:timers/promises": ">= 16",
_tls_common: ">= 0.11.13",
"node:_tls_common": [">= 14.18 && < 15", ">= 16"],
_tls_legacy: ">= 0.11.3 && < 10",
_tls_wrap: ">= 0.11.3",
"node:_tls_wrap": [">= 14.18 && < 15", ">= 16"],
tls: true,
"node:tls": [">= 14.18 && < 15", ">= 16"],
trace_events: ">= 10",
"node:trace_events": [">= 14.18 && < 15", ">= 16"],
tty: true,
"node:tty": [">= 14.18 && < 15", ">= 16"],
url: true,
"node:url": [">= 14.18 && < 15", ">= 16"],
util: true,
"node:util": [">= 14.18 && < 15", ">= 16"],
"util/types": ">= 15.3",
"node:util/types": ">= 16",
"v8/tools/arguments": ">= 10 && < 12",
"v8/tools/codemap": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/consarray": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/csvparser": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/logreader": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/profile_view": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/splaytree": [">= 4.4 && < 5", ">= 5.2 && < 12"],
v8: ">= 1",
"node:v8": [">= 14.18 && < 15", ">= 16"],
vm: true,
"node:vm": [">= 14.18 && < 15", ">= 16"],
wasi: [">= 13.4 && < 13.5", ">= 18.17 && < 19", ">= 20"],
"node:wasi": [">= 18.17 && < 19", ">= 20"],
worker_threads: ">= 11.7",
"node:worker_threads": [">= 14.18 && < 15", ">= 16"],
zlib: ">= 0.5",
"node:zlib": [">= 14.18 && < 15", ">= 16"]
};
}
});
// node_modules/is-core-module/index.js
var require_is_core_module = __commonJS({
"node_modules/is-core-module/index.js"(exports, module2) {
"use strict";
var hasOwn = require_hasown();
function specifierIncluded(current, specifier) {
var nodeParts = current.split(".");
var parts = specifier.split(" ");
var op = parts.length > 1 ? parts[0] : "=";
var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split(".");
for (var i = 0; i < 3; ++i) {
var cur = parseInt(nodeParts[i] || 0, 10);
var ver = parseInt(versionParts[i] || 0, 10);
if (cur === ver) {
continue;
}
if (op === "<") {
return cur < ver;
}
if (op === ">=") {
return cur >= ver;
}
return false;
}
return op === ">=";
}
__name(specifierIncluded, "specifierIncluded");
function matchesRange(current, range) {
var specifiers = range.split(/ ?&& ?/);
if (specifiers.length === 0) {
return false;
}
for (var i = 0; i < specifiers.length; ++i) {
if (!specifierIncluded(current, specifiers[i])) {
return false;
}
}
return true;
}
__name(matchesRange, "matchesRange");
function versionIncluded(nodeVersion, specifierValue) {
if (typeof specifierValue === "boolean") {
return specifierValue;
}
var current = typeof nodeVersion === "undefined" ? process.versions && process.versions.node : nodeVersion;
if (typeof current !== "string") {
throw new TypeError(typeof nodeVersion === "undefined" ? "Unable to determine current node version" : "If provided, a valid node version is required");
}
if (specifierValue && typeof specifierValue === "object") {
for (var i = 0; i < specifierValue.length; ++i) {
if (matchesRange(current, specifierValue[i])) {
return true;
}
}
return false;
}
return matchesRange(current, specifierValue);
}
__name(versionIncluded, "versionIncluded");
var data = require_core();
module2.exports = /* @__PURE__ */ __name(function isCore(x, nodeVersion) {
return hasOwn(data, x) && versionIncluded(nodeVersion, data[x]);
}, "isCore");
}
});
// node_modules/resolve/lib/async.js
var require_async = __commonJS({
"node_modules/resolve/lib/async.js"(exports, module2) {
var fs3 = require("fs");
var getHomedir = require_homedir();
var path5 = require("path");
var caller = require_caller();
var nodeModulesPaths = require_node_modules_paths();
var normalizeOptions = require_normalize_options();
var isCore = require_is_core_module();
var realpathFS = process.platform !== "win32" && fs3.realpath && typeof fs3.realpath.native === "function" ? fs3.realpath.native : fs3.realpath;
var homedir = getHomedir();
var defaultPaths = /* @__PURE__ */ __name(function() {
return [
path5.join(homedir, ".node_modules"),
path5.join(homedir, ".node_libraries")
];
}, "defaultPaths");
var defaultIsFile = /* @__PURE__ */ __name(function isFile(file, cb) {
fs3.stat(file, function(err, stat) {
if (!err) {
return cb(null, stat.isFile() || stat.isFIFO());
}
if (err.code === "ENOENT" || err.code === "ENOTDIR")
return cb(null, false);
return cb(err);
});
}, "isFile");
var defaultIsDir = /* @__PURE__ */ __name(function isDirectory(dir, cb) {
fs3.stat(dir, function(err, stat) {
if (!err) {
return cb(null, stat.isDirectory());
}
if (err.code === "ENOENT" || err.code === "ENOTDIR")
return cb(null, false);
return cb(err);
});
}, "isDirectory");
var defaultRealpath = /* @__PURE__ */ __name(function realpath(x, cb) {
realpathFS(x, function(realpathErr, realPath) {
if (realpathErr && realpathErr.code !== "ENOENT")
cb(realpathErr);
else
cb(null, realpathErr ? x : realPath);
});
}, "realpath");
var maybeRealpath = /* @__PURE__ */ __name(function maybeRealpath2(realpath, x, opts, cb) {
if (opts && opts.preserveSymlinks === false) {
realpath(x, cb);
} else {
cb(null, x);
}
}, "maybeRealpath");
var defaultReadPackage = /* @__PURE__ */ __name(function defaultReadPackage2(readFile2, pkgfile, cb) {
readFile2(pkgfile, function(readFileErr, body) {
if (readFileErr)
cb(readFileErr);
else {
try {
var pkg = JSON.parse(body);
cb(null, pkg);
} catch (jsonErr) {
cb(null);
}
}
});
}, "defaultReadPackage");
var getPackageCandidates = /* @__PURE__ */ __name(function getPackageCandidates2(x, start, opts) {
var dirs = nodeModulesPaths(start, opts, x);
for (var i = 0; i < dirs.length; i++) {
dirs[i] = path5.join(dirs[i], x);
}
return dirs;
}, "getPackageCandidates");
module2.exports = /* @__PURE__ */ __name(function resolve3(x, options, callback) {
var cb = callback;
var opts = options;
if (typeof options === "function") {
cb = opts;
opts = {};
}
if (typeof x !== "string") {
var err = new TypeError("Path must be a string.");
return process.nextTick(function() {
cb(err);
});
}
opts = normalizeOptions(x, opts);
var isFile = opts.isFile || defaultIsFile;
var isDirectory = opts.isDirectory || defaultIsDir;
var readFile2 = opts.readFile || fs3.readFile;
var realpath = opts.realpath || defaultRealpath;
var readPackage = opts.readPackage || defaultReadPackage;
if (opts.readFile && opts.readPackage) {
var conflictErr = new TypeError("`readFile` and `readPackage` are mutually exclusive.");
return process.nextTick(function() {
cb(conflictErr);
});
}
var packageIterator = opts.packageIterator;
var extensions = opts.extensions || [
".js"
];
var includeCoreModules = opts.includeCoreModules !== false;
var basedir = opts.basedir || path5.dirname(caller());
var parent = opts.filename || basedir;
opts.paths = opts.paths || defaultPaths();
var absoluteStart = path5.resolve(basedir);
maybeRealpath(realpath, absoluteStart, opts, function(err2, realStart) {
if (err2)
cb(err2);
else
init(realStart);
});
var res;
function init(basedir2) {
if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
res = path5.resolve(basedir2, x);
if (x === "." || x === ".." || x.slice(-1) === "/")
res += "/";
if (/\/$/.test(x) && res === basedir2) {
loadAsDirectory(res, opts.package, onfile);
} else
loadAsFile(res, opts.package, onfile);
} else if (includeCoreModules && isCore(x)) {
return cb(null, x);
} else
loadNodeModules(x, basedir2, function(err2, n, pkg) {
if (err2)
cb(err2);
else if (n) {
return maybeRealpath(realpath, n, opts, function(err3, realN) {
if (err3) {
cb(err3);
} else {
cb(null, realN, pkg);
}
});
} else {
var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
moduleError.code = "MODULE_NOT_FOUND";
cb(moduleError);
}
});
}
__name(init, "init");
function onfile(err2, m, pkg) {
if (err2)
cb(err2);
else if (m)
cb(null, m, pkg);
else
loadAsDirectory(res, function(err3, d, pkg2) {
if (err3)
cb(err3);
else if (d) {
maybeRealpath(realpath, d, opts, function(err4, realD) {
if (err4) {
cb(err4);
} else {
cb(null, realD, pkg2);
}
});
} else {
var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
moduleError.code = "MODULE_NOT_FOUND";
cb(moduleError);
}
});
}
__name(onfile, "onfile");
function loadAsFile(x2, thePackage, callback2) {
var loadAsFilePackage = thePackage;
var cb2 = callback2;
if (typeof loadAsFilePackage === "function") {
cb2 = loadAsFilePackage;
loadAsFilePackage = void 0;
}
var exts = [
""
].concat(extensions);
load(exts, x2, loadAsFilePackage);
function load(exts2, x3, loadPackage) {
if (exts2.length === 0)
return cb2(null, void 0, loadPackage);
var file = x3 + exts2[0];
var pkg = loadPackage;
if (pkg)
onpkg(null, pkg);
else
loadpkg(path5.dirname(file), onpkg);
function onpkg(err2, pkg_, dir) {
pkg = pkg_;
if (err2)
return cb2(err2);
if (dir && pkg && opts.pathFilter) {
var rfile = path5.relative(dir, file);
var rel = rfile.slice(0, rfile.length - exts2[0].length);
var r = opts.pathFilter(pkg, x3, rel);
if (r)
return load([
""
].concat(extensions.slice()), path5.resolve(dir, r), pkg);
}
isFile(file, onex);
}
__name(onpkg, "onpkg");
function onex(err2, ex) {
if (err2)
return cb2(err2);
if (ex)
return cb2(null, file, pkg);
load(exts2.slice(1), x3, pkg);
}
__name(onex, "onex");
}
__name(load, "load");
}
__name(loadAsFile, "loadAsFile");
function loadpkg(dir, cb2) {
if (dir === "" || dir === "/")
return cb2(null);
if (process.platform === "win32" && /^\w:[/\\]*$/.test(dir)) {
return cb2(null);
}
if (/[/\\]node_modules[/\\]*$/.test(dir))
return cb2(null);
maybeRealpath(realpath, dir, opts, function(unwrapErr, pkgdir) {
if (unwrapErr)
return loadpkg(path5.dirname(dir), cb2);
var pkgfile = path5.join(pkgdir, "package.json");
isFile(pkgfile, function(err2, ex) {
if (!ex)
return loadpkg(path5.dirname(dir), cb2);
readPackage(readFile2, pkgfile, function(err3, pkgParam) {
if (err3)
cb2(err3);
var pkg = pkgParam;
if (pkg && opts.packageFilter) {
pkg = opts.packageFilter(pkg, pkgfile);
}
cb2(null, pkg, dir);
});
});
});
}
__name(loadpkg, "loadpkg");
function loadAsDirectory(x2, loadAsDirectoryPackage, callback2) {
var cb2 = callback2;
var fpkg = loadAsDirectoryPackage;
if (typeof fpkg === "function") {
cb2 = fpkg;
fpkg = opts.package;
}
maybeRealpath(realpath, x2, opts, function(unwrapErr, pkgdir) {
if (unwrapErr)
return cb2(unwrapErr);
var pkgfile = path5.join(pkgdir, "package.json");
isFile(pkgfile, function(err2, ex) {
if (err2)
return cb2(err2);
if (!ex)
return loadAsFile(path5.join(x2, "index"), fpkg, cb2);
readPackage(readFile2, pkgfile, function(err3, pkgParam) {
if (err3)
return cb2(err3);
var pkg = pkgParam;
if (pkg && opts.packageFilter) {
pkg = opts.packageFilter(pkg, pkgfile);
}
if (pkg && pkg.main) {
if (typeof pkg.main !== "string") {
var mainError = new TypeError("package \u201C" + pkg.name + "\u201D `main` must be a string");
mainError.code = "INVALID_PACKAGE_MAIN";
return cb2(mainError);
}
if (pkg.main === "." || pkg.main === "./") {
pkg.main = "index";
}
loadAsFile(path5.resolve(x2, pkg.main), pkg, function(err4, m, pkg2) {
if (err4)
return cb2(err4);
if (m)
return cb2(null, m, pkg2);
if (!pkg2)
return loadAsFile(path5.join(x2, "index"), pkg2, cb2);
var dir = path5.resolve(x2, pkg2.main);
loadAsDirectory(dir, pkg2, function(err5, n, pkg3) {
if (err5)
return cb2(err5);
if (n)
return cb2(null, n, pkg3);
loadAsFile(path5.join(x2, "index"), pkg3, cb2);
});
});
return;
}
loadAsFile(path5.join(x2, "/index"), pkg, cb2);
});
});
});
}
__name(loadAsDirectory, "loadAsDirectory");
function processDirs(cb2, dirs) {
if (dirs.length === 0)
return cb2(null, void 0);
var dir = dirs[0];
isDirectory(path5.dirname(dir), isdir);
function isdir(err2, isdir2) {
if (err2)
return cb2(err2);
if (!isdir2)
return processDirs(cb2, dirs.slice(1));
loadAsFile(dir, opts.package, onfile2);
}
__name(isdir, "isdir");
function onfile2(err2, m, pkg) {
if (err2)
return cb2(err2);
if (m)
return cb2(null, m, pkg);
loadAsDirectory(dir, opts.package, ondir);
}
__name(onfile2, "onfile");
function ondir(err2, n, pkg) {
if (err2)
return cb2(err2);
if (n)
return cb2(null, n, pkg);
processDirs(cb2, dirs.slice(1));
}
__name(ondir, "ondir");
}
__name(processDirs, "processDirs");
function loadNodeModules(x2, start, cb2) {
var thunk = /* @__PURE__ */ __name(function() {
return getPackageCandidates(x2, start, opts);
}, "thunk");
processDirs(cb2, packageIterator ? packageIterator(x2, start, thunk, opts) : thunk());
}
__name(loadNodeModules, "loadNodeModules");
}, "resolve");
}
});
// node_modules/resolve/lib/core.json
var require_core2 = __commonJS({
"node_modules/resolve/lib/core.json"(exports, module2) {
module2.exports = {
assert: true,
"node:assert": [">= 14.18 && < 15", ">= 16"],
"assert/strict": ">= 15",
"node:assert/strict": ">= 16",
async_hooks: ">= 8",
"node:async_hooks": [">= 14.18 && < 15", ">= 16"],
buffer_ieee754: ">= 0.5 && < 0.9.7",
buffer: true,
"node:buffer": [">= 14.18 && < 15", ">= 16"],
child_process: true,
"node:child_process": [">= 14.18 && < 15", ">= 16"],
cluster: ">= 0.5",
"node:cluster": [">= 14.18 && < 15", ">= 16"],
console: true,
"node:console": [">= 14.18 && < 15", ">= 16"],
constants: true,
"node:constants": [">= 14.18 && < 15", ">= 16"],
crypto: true,
"node:crypto": [">= 14.18 && < 15", ">= 16"],
_debug_agent: ">= 1 && < 8",
_debugger: "< 8",
dgram: true,
"node:dgram": [">= 14.18 && < 15", ">= 16"],
diagnostics_channel: [">= 14.17 && < 15", ">= 15.1"],
"node:diagnostics_channel": [">= 14.18 && < 15", ">= 16"],
dns: true,
"node:dns": [">= 14.18 && < 15", ">= 16"],
"dns/promises": ">= 15",
"node:dns/promises": ">= 16",
domain: ">= 0.7.12",
"node:domain": [">= 14.18 && < 15", ">= 16"],
events: true,
"node:events": [">= 14.18 && < 15", ">= 16"],
freelist: "< 6",
fs: true,
"node:fs": [">= 14.18 && < 15", ">= 16"],
"fs/promises": [">= 10 && < 10.1", ">= 14"],
"node:fs/promises": [">= 14.18 && < 15", ">= 16"],
_http_agent: ">= 0.11.1",
"node:_http_agent": [">= 14.18 && < 15", ">= 16"],
_http_client: ">= 0.11.1",
"node:_http_client": [">= 14.18 && < 15", ">= 16"],
_http_common: ">= 0.11.1",
"node:_http_common": [">= 14.18 && < 15", ">= 16"],
_http_incoming: ">= 0.11.1",
"node:_http_incoming": [">= 14.18 && < 15", ">= 16"],
_http_outgoing: ">= 0.11.1",
"node:_http_outgoing": [">= 14.18 && < 15", ">= 16"],
_http_server: ">= 0.11.1",
"node:_http_server": [">= 14.18 && < 15", ">= 16"],
http: true,
"node:http": [">= 14.18 && < 15", ">= 16"],
http2: ">= 8.8",
"node:http2": [">= 14.18 && < 15", ">= 16"],
https: true,
"node:https": [">= 14.18 && < 15", ">= 16"],
inspector: ">= 8",
"node:inspector": [">= 14.18 && < 15", ">= 16"],
"inspector/promises": [">= 19"],
"node:inspector/promises": [">= 19"],
_linklist: "< 8",
module: true,
"node:module": [">= 14.18 && < 15", ">= 16"],
net: true,
"node:net": [">= 14.18 && < 15", ">= 16"],
"node-inspect/lib/_inspect": ">= 7.6 && < 12",
"node-inspect/lib/internal/inspect_client": ">= 7.6 && < 12",
"node-inspect/lib/internal/inspect_repl": ">= 7.6 && < 12",
os: true,
"node:os": [">= 14.18 && < 15", ">= 16"],
path: true,
"node:path": [">= 14.18 && < 15", ">= 16"],
"path/posix": ">= 15.3",
"node:path/posix": ">= 16",
"path/win32": ">= 15.3",
"node:path/win32": ">= 16",
perf_hooks: ">= 8.5",
"node:perf_hooks": [">= 14.18 && < 15", ">= 16"],
process: ">= 1",
"node:process": [">= 14.18 && < 15", ">= 16"],
punycode: ">= 0.5",
"node:punycode": [">= 14.18 && < 15", ">= 16"],
querystring: true,
"node:querystring": [">= 14.18 && < 15", ">= 16"],
readline: true,
"node:readline": [">= 14.18 && < 15", ">= 16"],
"readline/promises": ">= 17",
"node:readline/promises": ">= 17",
repl: true,
"node:repl": [">= 14.18 && < 15", ">= 16"],
smalloc: ">= 0.11.5 && < 3",
_stream_duplex: ">= 0.9.4",
"node:_stream_duplex": [">= 14.18 && < 15", ">= 16"],
_stream_transform: ">= 0.9.4",
"node:_stream_transform": [">= 14.18 && < 15", ">= 16"],
_stream_wrap: ">= 1.4.1",
"node:_stream_wrap": [">= 14.18 && < 15", ">= 16"],
_stream_passthrough: ">= 0.9.4",
"node:_stream_passthrough": [">= 14.18 && < 15", ">= 16"],
_stream_readable: ">= 0.9.4",
"node:_stream_readable": [">= 14.18 && < 15", ">= 16"],
_stream_writable: ">= 0.9.4",
"node:_stream_writable": [">= 14.18 && < 15", ">= 16"],
stream: true,
"node:stream": [">= 14.18 && < 15", ">= 16"],
"stream/consumers": ">= 16.7",
"node:stream/consumers": ">= 16.7",
"stream/promises": ">= 15",
"node:stream/promises": ">= 16",
"stream/web": ">= 16.5",
"node:stream/web": ">= 16.5",
string_decoder: true,
"node:string_decoder": [">= 14.18 && < 15", ">= 16"],
sys: [">= 0.4 && < 0.7", ">= 0.8"],
"node:sys": [">= 14.18 && < 15", ">= 16"],
"test/reporters": ">= 19.9 && < 20.2",
"node:test/reporters": [">= 18.17 && < 19", ">= 19.9", ">= 20"],
"node:test": [">= 16.17 && < 17", ">= 18"],
timers: true,
"node:timers": [">= 14.18 && < 15", ">= 16"],
"timers/promises": ">= 15",
"node:timers/promises": ">= 16",
_tls_common: ">= 0.11.13",
"node:_tls_common": [">= 14.18 && < 15", ">= 16"],
_tls_legacy: ">= 0.11.3 && < 10",
_tls_wrap: ">= 0.11.3",
"node:_tls_wrap": [">= 14.18 && < 15", ">= 16"],
tls: true,
"node:tls": [">= 14.18 && < 15", ">= 16"],
trace_events: ">= 10",
"node:trace_events": [">= 14.18 && < 15", ">= 16"],
tty: true,
"node:tty": [">= 14.18 && < 15", ">= 16"],
url: true,
"node:url": [">= 14.18 && < 15", ">= 16"],
util: true,
"node:util": [">= 14.18 && < 15", ">= 16"],
"util/types": ">= 15.3",
"node:util/types": ">= 16",
"v8/tools/arguments": ">= 10 && < 12",
"v8/tools/codemap": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/consarray": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/csvparser": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/logreader": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/profile_view": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/splaytree": [">= 4.4 && < 5", ">= 5.2 && < 12"],
v8: ">= 1",
"node:v8": [">= 14.18 && < 15", ">= 16"],
vm: true,
"node:vm": [">= 14.18 && < 15", ">= 16"],
wasi: [">= 13.4 && < 13.5", ">= 18.17 && < 19", ">= 20"],
"node:wasi": [">= 18.17 && < 19", ">= 20"],
worker_threads: ">= 11.7",
"node:worker_threads": [">= 14.18 && < 15", ">= 16"],
zlib: ">= 0.5",
"node:zlib": [">= 14.18 && < 15", ">= 16"]
};
}
});
// node_modules/resolve/lib/core.js
var require_core3 = __commonJS({
"node_modules/resolve/lib/core.js"(exports, module2) {
"use strict";
var isCoreModule = require_is_core_module();
var data = require_core2();
var core = {};
for (mod in data) {
if (Object.prototype.hasOwnProperty.call(data, mod)) {
core[mod] = isCoreModule(mod);
}
}
var mod;
module2.exports = core;
}
});
// node_modules/resolve/lib/is-core.js
var require_is_core = __commonJS({
"node_modules/resolve/lib/is-core.js"(exports, module2) {
var isCoreModule = require_is_core_module();
module2.exports = /* @__PURE__ */ __name(function isCore(x) {
return isCoreModule(x);
}, "isCore");
}
});
// node_modules/resolve/lib/sync.js
var require_sync = __commonJS({
"node_modules/resolve/lib/sync.js"(exports, module2) {
var isCore = require_is_core_module();
var fs3 = require("fs");
var path5 = require("path");
var getHomedir = require_homedir();
var caller = require_caller();
var nodeModulesPaths = require_node_modules_paths();
var normalizeOptions = require_normalize_options();
var realpathFS = process.platform !== "win32" && fs3.realpathSync && typeof fs3.realpathSync.native === "function" ? fs3.realpathSync.native : fs3.realpathSync;
var homedir = getHomedir();
var defaultPaths = /* @__PURE__ */ __name(function() {
return [
path5.join(homedir, ".node_modules"),
path5.join(homedir, ".node_libraries")
];
}, "defaultPaths");
var defaultIsFile = /* @__PURE__ */ __name(function isFile(file) {
try {
var stat = fs3.statSync(file, {
throwIfNoEntry: false
});
} catch (e) {
if (e && (e.code === "ENOENT" || e.code === "ENOTDIR"))
return false;
throw e;
}
return !!stat && (stat.isFile() || stat.isFIFO());
}, "isFile");
var defaultIsDir = /* @__PURE__ */ __name(function isDirectory(dir) {
try {
var stat = fs3.statSync(dir, {
throwIfNoEntry: false
});
} catch (e) {
if (e && (e.code === "ENOENT" || e.code === "ENOTDIR"))
return false;
throw e;
}
return !!stat && stat.isDirectory();
}, "isDirectory");
var defaultRealpathSync = /* @__PURE__ */ __name(function realpathSync(x) {
try {
return realpathFS(x);
} catch (realpathErr) {
if (realpathErr.code !== "ENOENT") {
throw realpathErr;
}
}
return x;
}, "realpathSync");
var maybeRealpathSync = /* @__PURE__ */ __name(function maybeRealpathSync2(realpathSync, x, opts) {
if (opts && opts.preserveSymlinks === false) {
return realpathSync(x);
}
return x;
}, "maybeRealpathSync");
var defaultReadPackageSync = /* @__PURE__ */ __name(function defaultReadPackageSync2(readFileSync, pkgfile) {
var body = readFileSync(pkgfile);
try {
var pkg = JSON.parse(body);
return pkg;
} catch (jsonErr) {
}
}, "defaultReadPackageSync");
var getPackageCandidates = /* @__PURE__ */ __name(function getPackageCandidates2(x, start, opts) {
var dirs = nodeModulesPaths(start, opts, x);
for (var i = 0; i < dirs.length; i++) {
dirs[i] = path5.join(dirs[i], x);
}
return dirs;
}, "getPackageCandidates");
module2.exports = /* @__PURE__ */ __name(function resolveSync(x, options) {
if (typeof x !== "string") {
throw new TypeError("Path must be a string.");
}
var opts = normalizeOptions(x, options);
var isFile = opts.isFile || defaultIsFile;
var readFileSync = opts.readFileSync || fs3.readFileSync;
var isDirectory = opts.isDirectory || defaultIsDir;
var realpathSync = opts.realpathSync || defaultRealpathSync;
var readPackageSync = opts.readPackageSync || defaultReadPackageSync;
if (opts.readFileSync && opts.readPackageSync) {
throw new TypeError("`readFileSync` and `readPackageSync` are mutually exclusive.");
}
var packageIterator = opts.packageIterator;
var extensions = opts.extensions || [
".js"
];
var includeCoreModules = opts.includeCoreModules !== false;
var basedir = opts.basedir || path5.dirname(caller());
var parent = opts.filename || basedir;
opts.paths = opts.paths || defaultPaths();
var absoluteStart = maybeRealpathSync(realpathSync, path5.resolve(basedir), opts);
if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
var res = path5.resolve(absoluteStart, x);
if (x === "." || x === ".." || x.slice(-1) === "/")
res += "/";
var m = loadAsFileSync(res) || loadAsDirectorySync(res);
if (m)
return maybeRealpathSync(realpathSync, m, opts);
} else if (includeCoreModules && isCore(x)) {
return x;
} else {
var n = loadNodeModulesSync(x, absoluteStart);
if (n)
return maybeRealpathSync(realpathSync, n, opts);
}
var err = new Error("Cannot find module '" + x + "' from '" + parent + "'");
err.code = "MODULE_NOT_FOUND";
throw err;
function loadAsFileSync(x2) {
var pkg = loadpkg(path5.dirname(x2));
if (pkg && pkg.dir && pkg.pkg && opts.pathFilter) {
var rfile = path5.relative(pkg.dir, x2);
var r = opts.pathFilter(pkg.pkg, x2, rfile);
if (r) {
x2 = path5.resolve(pkg.dir, r);
}
}
if (isFile(x2)) {
return x2;
}
for (var i = 0; i < extensions.length; i++) {
var file = x2 + extensions[i];
if (isFile(file)) {
return file;
}
}
}
__name(loadAsFileSync, "loadAsFileSync");
function loadpkg(dir) {
if (dir === "" || dir === "/")
return;
if (process.platform === "win32" && /^\w:[/\\]*$/.test(dir)) {
return;
}
if (/[/\\]node_modules[/\\]*$/.test(dir))
return;
var pkgfile = path5.join(maybeRealpathSync(realpathSync, dir, opts), "package.json");
if (!isFile(pkgfile)) {
return loadpkg(path5.dirname(dir));
}
var pkg = readPackageSync(readFileSync, pkgfile);
if (pkg && opts.packageFilter) {
pkg = opts.packageFilter(
pkg,
/*pkgfile,*/
dir
);
}
return {
pkg,
dir
};
}
__name(loadpkg, "loadpkg");
function loadAsDirectorySync(x2) {
var pkgfile = path5.join(maybeRealpathSync(realpathSync, x2, opts), "/package.json");
if (isFile(pkgfile)) {
try {
var pkg = readPackageSync(readFileSync, pkgfile);
} catch (e) {
}
if (pkg && opts.packageFilter) {
pkg = opts.packageFilter(
pkg,
/*pkgfile,*/
x2
);
}
if (pkg && pkg.main) {
if (typeof pkg.main !== "string") {
var mainError = new TypeError("package \u201C" + pkg.name + "\u201D `main` must be a string");
mainError.code = "INVALID_PACKAGE_MAIN";
throw mainError;
}
if (pkg.main === "." || pkg.main === "./") {
pkg.main = "index";
}
try {
var m2 = loadAsFileSync(path5.resolve(x2, pkg.main));
if (m2)
return m2;
var n2 = loadAsDirectorySync(path5.resolve(x2, pkg.main));
if (n2)
return n2;
} catch (e) {
}
}
}
return loadAsFileSync(path5.join(x2, "/index"));
}
__name(loadAsDirectorySync, "loadAsDirectorySync");
function loadNodeModulesSync(x2, start) {
var thunk = /* @__PURE__ */ __name(function() {
return getPackageCandidates(x2, start, opts);
}, "thunk");
var dirs = packageIterator ? packageIterator(x2, start, thunk, opts) : thunk();
for (var i = 0; i < dirs.length; i++) {
var dir = dirs[i];
if (isDirectory(path5.dirname(dir))) {
var m2 = loadAsFileSync(dir);
if (m2)
return m2;
var n2 = loadAsDirectorySync(dir);
if (n2)
return n2;
}
}
}
__name(loadNodeModulesSync, "loadNodeModulesSync");
}, "resolveSync");
}
});
// node_modules/resolve/index.js
var require_resolve = __commonJS({
"node_modules/resolve/index.js"(exports, module2) {
var async = require_async();
async.core = require_core3();
async.isCore = require_is_core();
async.sync = require_sync();
module2.exports = async;
}
});
// node_modules/normalize-package-data/lib/extract_description.js
var require_extract_description = __commonJS({
"node_modules/normalize-package-data/lib/extract_description.js"(exports, module2) {
module2.exports = extractDescription;
function extractDescription(d) {
if (!d)
return;
if (d === "ERROR: No README data found!")
return;
d = d.trim().split("\n");
for (var s = 0; d[s] && d[s].trim().match(/^(#|$)/); s++)
;
var l = d.length;
for (var e = s + 1; e < l && d[e].trim(); e++)
;
return d.slice(s, e).join(" ").trim();
}
__name(extractDescription, "extractDescription");
}
});
// node_modules/normalize-package-data/lib/typos.json
var require_typos = __commonJS({
"node_modules/normalize-package-data/lib/typos.json"(exports, module2) {
module2.exports = {
topLevel: {
dependancies: "dependencies",
dependecies: "dependencies",
depdenencies: "dependencies",
devEependencies: "devDependencies",
depends: "dependencies",
"dev-dependencies": "devDependencies",
devDependences: "devDependencies",
devDepenencies: "devDependencies",
devdependencies: "devDependencies",
repostitory: "repository",
repo: "repository",
prefereGlobal: "preferGlobal",
hompage: "homepage",
hampage: "homepage",
autohr: "author",
autor: "author",
contributers: "contributors",
publicationConfig: "publishConfig",
script: "scripts"
},
bugs: { web: "url", name: "url" },
script: { server: "start", tests: "test" }
};
}
});
// node_modules/normalize-package-data/lib/fixer.js
var require_fixer = __commonJS({
"node_modules/normalize-package-data/lib/fixer.js"(exports, module2) {
var semver = require_semver();
var validateLicense = require_validate_npm_package_license();
var hostedGitInfo = require_hosted_git_info();
var isBuiltinModule = require_resolve().isCore;
var depTypes = [
"dependencies",
"devDependencies",
"optionalDependencies"
];
var extractDescription = require_extract_description();
var url = require("url");
var typos = require_typos();
var fixer = module2.exports = {
// default warning function
warn: function() {
},
fixRepositoryField: function(data) {
if (data.repositories) {
this.warn("repositories");
data.repository = data.repositories[0];
}
if (!data.repository)
return this.warn("missingRepository");
if (typeof data.repository === "string") {
data.repository = {
type: "git",
url: data.repository
};
}
var r = data.repository.url || "";
if (r) {
var hosted = hostedGitInfo.fromUrl(r);
if (hosted) {
r = data.repository.url = hosted.getDefaultRepresentation() == "shortcut" ? hosted.https() : hosted.toString();
}
}
if (r.match(/github.com\/[^\/]+\/[^\/]+\.git\.git$/)) {
this.warn("brokenGitUrl", r);
}
},
fixTypos: function(data) {
Object.keys(typos.topLevel).forEach(function(d) {
if (data.hasOwnProperty(d)) {
this.warn("typo", d, typos.topLevel[d]);
}
}, this);
},
fixScriptsField: function(data) {
if (!data.scripts)
return;
if (typeof data.scripts !== "object") {
this.warn("nonObjectScripts");
delete data.scripts;
return;
}
Object.keys(data.scripts).forEach(function(k) {
if (typeof data.scripts[k] !== "string") {
this.warn("nonStringScript");
delete data.scripts[k];
} else if (typos.script[k] && !data.scripts[typos.script[k]]) {
this.warn("typo", k, typos.script[k], "scripts");
}
}, this);
},
fixFilesField: function(data) {
var files = data.files;
if (files && !Array.isArray(files)) {
this.warn("nonArrayFiles");
delete data.files;
} else if (data.files) {
data.files = data.files.filter(function(file) {
if (!file || typeof file !== "string") {
this.warn("invalidFilename", file);
return false;
} else {
return true;
}
}, this);
}
},
fixBinField: function(data) {
if (!data.bin)
return;
if (typeof data.bin === "string") {
var b = {};
var match;
if (match = data.name.match(/^@[^/]+[/](.*)$/)) {
b[match[1]] = data.bin;
} else {
b[data.name] = data.bin;
}
data.bin = b;
}
},
fixManField: function(data) {
if (!data.man)
return;
if (typeof data.man === "string") {
data.man = [
data.man
];
}
},
fixBundleDependenciesField: function(data) {
var bdd = "bundledDependencies";
var bd = "bundleDependencies";
if (data[bdd] && !data[bd]) {
data[bd] = data[bdd];
delete data[bdd];
}
if (data[bd] && !Array.isArray(data[bd])) {
this.warn("nonArrayBundleDependencies");
delete data[bd];
} else if (data[bd]) {
data[bd] = data[bd].filter(function(bd2) {
if (!bd2 || typeof bd2 !== "string") {
this.warn("nonStringBundleDependency", bd2);
return false;
} else {
if (!data.dependencies) {
data.dependencies = {};
}
if (!data.dependencies.hasOwnProperty(bd2)) {
this.warn("nonDependencyBundleDependency", bd2);
data.dependencies[bd2] = "*";
}
return true;
}
}, this);
}
},
fixDependencies: function(data, strict) {
var loose = !strict;
objectifyDeps(data, this.warn);
addOptionalDepsToDeps(data, this.warn);
this.fixBundleDependenciesField(data);
[
"dependencies",
"devDependencies"
].forEach(function(deps) {
if (!(deps in data))
return;
if (!data[deps] || typeof data[deps] !== "object") {
this.warn("nonObjectDependencies", deps);
delete data[deps];
return;
}
Object.keys(data[deps]).forEach(function(d) {
var r = data[deps][d];
if (typeof r !== "string") {
this.warn("nonStringDependency", d, JSON.stringify(r));
delete data[deps][d];
}
var hosted = hostedGitInfo.fromUrl(data[deps][d]);
if (hosted)
data[deps][d] = hosted.toString();
}, this);
}, this);
},
fixModulesField: function(data) {
if (data.modules) {
this.warn("deprecatedModules");
delete data.modules;
}
},
fixKeywordsField: function(data) {
if (typeof data.keywords === "string") {
data.keywords = data.keywords.split(/,\s+/);
}
if (data.keywords && !Array.isArray(data.keywords)) {
delete data.keywords;
this.warn("nonArrayKeywords");
} else if (data.keywords) {
data.keywords = data.keywords.filter(function(kw) {
if (typeof kw !== "string" || !kw) {
this.warn("nonStringKeyword");
return false;
} else {
return true;
}
}, this);
}
},
fixVersionField: function(data, strict) {
var loose = !strict;
if (!data.version) {
data.version = "";
return true;
}
if (!semver.valid(data.version, loose)) {
throw new Error('Invalid version: "' + data.version + '"');
}
data.version = semver.clean(data.version, loose);
return true;
},
fixPeople: function(data) {
modifyPeople(data, unParsePerson);
modifyPeople(data, parsePerson);
},
fixNameField: function(data, options) {
if (typeof options === "boolean")
options = {
strict: options
};
else if (typeof options === "undefined")
options = {};
var strict = options.strict;
if (!data.name && !strict) {
data.name = "";
return;
}
if (typeof data.name !== "string") {
throw new Error("name field must be a string.");
}
if (!strict)
data.name = data.name.trim();
ensureValidName(data.name, strict, options.allowLegacyCase);
if (isBuiltinModule(data.name))
this.warn("conflictingName", data.name);
},
fixDescriptionField: function(data) {
if (data.description && typeof data.description !== "string") {
this.warn("nonStringDescription");
delete data.description;
}
if (data.readme && !data.description)
data.description = extractDescription(data.readme);
if (data.description === void 0)
delete data.description;
if (!data.description)
this.warn("missingDescription");
},
fixReadmeField: function(data) {
if (!data.readme) {
this.warn("missingReadme");
data.readme = "ERROR: No README data found!";
}
},
fixBugsField: function(data) {
if (!data.bugs && data.repository && data.repository.url) {
var hosted = hostedGitInfo.fromUrl(data.repository.url);
if (hosted && hosted.bugs()) {
data.bugs = {
url: hosted.bugs()
};
}
} else if (data.bugs) {
var emailRe = /^.+@.*\..+$/;
if (typeof data.bugs == "string") {
if (emailRe.test(data.bugs))
data.bugs = {
email: data.bugs
};
else if (url.parse(data.bugs).protocol)
data.bugs = {
url: data.bugs
};
else
this.warn("nonEmailUrlBugsString");
} else {
bugsTypos(data.bugs, this.warn);
var oldBugs = data.bugs;
data.bugs = {};
if (oldBugs.url) {
if (typeof oldBugs.url == "string" && url.parse(oldBugs.url).protocol)
data.bugs.url = oldBugs.url;
else
this.warn("nonUrlBugsUrlField");
}
if (oldBugs.email) {
if (typeof oldBugs.email == "string" && emailRe.test(oldBugs.email))
data.bugs.email = oldBugs.email;
else
this.warn("nonEmailBugsEmailField");
}
}
if (!data.bugs.email && !data.bugs.url) {
delete data.bugs;
this.warn("emptyNormalizedBugs");
}
}
},
fixHomepageField: function(data) {
if (!data.homepage && data.repository && data.repository.url) {
var hosted = hostedGitInfo.fromUrl(data.repository.url);
if (hosted && hosted.docs())
data.homepage = hosted.docs();
}
if (!data.homepage)
return;
if (typeof data.homepage !== "string") {
this.warn("nonUrlHomepage");
return delete data.homepage;
}
if (!url.parse(data.homepage).protocol) {
data.homepage = "http://" + data.homepage;
}
},
fixLicenseField: function(data) {
if (!data.license) {
return this.warn("missingLicense");
} else {
if (typeof data.license !== "string" || data.license.length < 1 || data.license.trim() === "") {
this.warn("invalidLicense");
} else {
if (!validateLicense(data.license).validForNewPackages)
this.warn("invalidLicense");
}
}
}
};
function isValidScopedPackageName(spec) {
if (spec.charAt(0) !== "@")
return false;
var rest = spec.slice(1).split("/");
if (rest.length !== 2)
return false;
return rest[0] && rest[1] && rest[0] === encodeURIComponent(rest[0]) && rest[1] === encodeURIComponent(rest[1]);
}
__name(isValidScopedPackageName, "isValidScopedPackageName");
function isCorrectlyEncodedName(spec) {
return !spec.match(/[\/@\s\+%:]/) && spec === encodeURIComponent(spec);
}
__name(isCorrectlyEncodedName, "isCorrectlyEncodedName");
function ensureValidName(name, strict, allowLegacyCase) {
if (name.charAt(0) === "." || !(isValidScopedPackageName(name) || isCorrectlyEncodedName(name)) || strict && !allowLegacyCase && name !== name.toLowerCase() || name.toLowerCase() === "node_modules" || name.toLowerCase() === "favicon.ico") {
throw new Error("Invalid name: " + JSON.stringify(name));
}
}
__name(ensureValidName, "ensureValidName");
function modifyPeople(data, fn) {
if (data.author)
data.author = fn(data.author);
[
"maintainers",
"contributors"
].forEach(function(set) {
if (!Array.isArray(data[set]))
return;
data[set] = data[set].map(fn);
});
return data;
}
__name(modifyPeople, "modifyPeople");
function unParsePerson(person) {
if (typeof person === "string")
return person;
var name = person.name || "";
var u = person.url || person.web;
var url2 = u ? " (" + u + ")" : "";
var e = person.email || person.mail;
var email = e ? " <" + e + ">" : "";
return name + email + url2;
}
__name(unParsePerson, "unParsePerson");
function parsePerson(person) {
if (typeof person !== "string")
return person;
var name = person.match(/^([^\(<]+)/);
var url2 = person.match(/\(([^\)]+)\)/);
var email = person.match(/<([^>]+)>/);
var obj = {};
if (name && name[0].trim())
obj.name = name[0].trim();
if (email)
obj.email = email[1];
if (url2)
obj.url = url2[1];
return obj;
}
__name(parsePerson, "parsePerson");
function addOptionalDepsToDeps(data, warn) {
var o = data.optionalDependencies;
if (!o)
return;
var d = data.dependencies || {};
Object.keys(o).forEach(function(k) {
d[k] = o[k];
});
data.dependencies = d;
}
__name(addOptionalDepsToDeps, "addOptionalDepsToDeps");
function depObjectify(deps, type, warn) {
if (!deps)
return {};
if (typeof deps === "string") {
deps = deps.trim().split(/[\n\r\s\t ,]+/);
}
if (!Array.isArray(deps))
return deps;
warn("deprecatedArrayDependencies", type);
var o = {};
deps.filter(function(d) {
return typeof d === "string";
}).forEach(function(d) {
d = d.trim().split(/(:?[@\s><=])/);
var dn = d.shift();
var dv = d.join("");
dv = dv.trim();
dv = dv.replace(/^@/, "");
o[dn] = dv;
});
return o;
}
__name(depObjectify, "depObjectify");
function objectifyDeps(data, warn) {
depTypes.forEach(function(type) {
if (!data[type])
return;
data[type] = depObjectify(data[type], type, warn);
});
}
__name(objectifyDeps, "objectifyDeps");
function bugsTypos(bugs, warn) {
if (!bugs)
return;
Object.keys(bugs).forEach(function(k) {
if (typos.bugs[k]) {
warn("typo", k, typos.bugs[k], "bugs");
bugs[typos.bugs[k]] = bugs[k];
delete bugs[k];
}
});
}
__name(bugsTypos, "bugsTypos");
}
});
// node_modules/normalize-package-data/lib/warning_messages.json
var require_warning_messages = __commonJS({
"node_modules/normalize-package-data/lib/warning_messages.json"(exports, module2) {
module2.exports = {
repositories: "'repositories' (plural) Not supported. Please pick one as the 'repository' field",
missingRepository: "No repository field.",
brokenGitUrl: "Probably broken git url: %s",
nonObjectScripts: "scripts must be an object",
nonStringScript: "script values must be string commands",
nonArrayFiles: "Invalid 'files' member",
invalidFilename: "Invalid filename in 'files' list: %s",
nonArrayBundleDependencies: "Invalid 'bundleDependencies' list. Must be array of package names",
nonStringBundleDependency: "Invalid bundleDependencies member: %s",
nonDependencyBundleDependency: "Non-dependency in bundleDependencies: %s",
nonObjectDependencies: "%s field must be an object",
nonStringDependency: "Invalid dependency: %s %s",
deprecatedArrayDependencies: "specifying %s as array is deprecated",
deprecatedModules: "modules field is deprecated",
nonArrayKeywords: "keywords should be an array of strings",
nonStringKeyword: "keywords should be an array of strings",
conflictingName: "%s is also the name of a node core module.",
nonStringDescription: "'description' field should be a string",
missingDescription: "No description",
missingReadme: "No README data",
missingLicense: "No license field.",
nonEmailUrlBugsString: "Bug string field must be url, email, or {email,url}",
nonUrlBugsUrlField: "bugs.url field must be a string url. Deleted.",
nonEmailBugsEmailField: "bugs.email field must be a string email. Deleted.",
emptyNormalizedBugs: "Normalized value of bugs field is an empty object. Deleted.",
nonUrlHomepage: "homepage field must be a string url. Deleted.",
invalidLicense: "license should be a valid SPDX license expression",
typo: "%s should probably be %s."
};
}
});
// node_modules/normalize-package-data/lib/make_warning.js
var require_make_warning = __commonJS({
"node_modules/normalize-package-data/lib/make_warning.js"(exports, module2) {
var util = require("util");
var messages = require_warning_messages();
module2.exports = function() {
var args = Array.prototype.slice.call(arguments, 0);
var warningName = args.shift();
if (warningName == "typo") {
return makeTypoWarning.apply(null, args);
} else {
var msgTemplate = messages[warningName] ? messages[warningName] : warningName + ": '%s'";
args.unshift(msgTemplate);
return util.format.apply(null, args);
}
};
function makeTypoWarning(providedName, probableName, field) {
if (field) {
providedName = field + "['" + providedName + "']";
probableName = field + "['" + probableName + "']";
}
return util.format(messages.typo, providedName, probableName);
}
__name(makeTypoWarning, "makeTypoWarning");
}
});
// node_modules/normalize-package-data/lib/normalize.js
var require_normalize = __commonJS({
"node_modules/normalize-package-data/lib/normalize.js"(exports, module2) {
module2.exports = normalize;
var fixer = require_fixer();
normalize.fixer = fixer;
var makeWarning = require_make_warning();
var fieldsToFix = [
"name",
"version",
"description",
"repository",
"modules",
"scripts",
"files",
"bin",
"man",
"bugs",
"keywords",
"readme",
"homepage",
"license"
];
var otherThingsToFix = [
"dependencies",
"people",
"typos"
];
var thingsToFix = fieldsToFix.map(function(fieldName) {
return ucFirst(fieldName) + "Field";
});
thingsToFix = thingsToFix.concat(otherThingsToFix);
function normalize(data, warn, strict) {
if (warn === true)
warn = null, strict = true;
if (!strict)
strict = false;
if (!warn || data.private)
warn = /* @__PURE__ */ __name(function(msg) {
}, "warn");
if (data.scripts && data.scripts.install === "node-gyp rebuild" && !data.scripts.preinstall) {
data.gypfile = true;
}
fixer.warn = function() {
warn(makeWarning.apply(null, arguments));
};
thingsToFix.forEach(function(thingName) {
fixer["fix" + ucFirst(thingName)](data, strict);
});
data._id = data.name + "@" + data.version;
}
__name(normalize, "normalize");
function ucFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
__name(ucFirst, "ucFirst");
}
});
// node_modules/read-pkg/index.js
var require_read_pkg = __commonJS({
"node_modules/read-pkg/index.js"(exports, module2) {
"use strict";
var { promisify } = require("util");
var fs3 = require("fs");
var path5 = require("path");
var parseJson = require_parse_json();
var readFileAsync = promisify(fs3.readFile);
module2.exports = async (options) => {
options = {
cwd: process.cwd(),
normalize: true,
...options
};
const filePath = path5.resolve(options.cwd, "package.json");
const json = parseJson(await readFileAsync(filePath, "utf8"));
if (options.normalize) {
require_normalize()(json);
}
return json;
};
module2.exports.sync = (options) => {
options = {
cwd: process.cwd(),
normalize: true,
...options
};
const filePath = path5.resolve(options.cwd, "package.json");
const json = parseJson(fs3.readFileSync(filePath, "utf8"));
if (options.normalize) {
require_normalize()(json);
}
return json;
};
}
});
// node_modules/read-pkg-up/index.js
var require_read_pkg_up = __commonJS({
"node_modules/read-pkg-up/index.js"(exports, module2) {
"use strict";
var path5 = require("path");
var findUp2 = require_find_up();
var readPkg = require_read_pkg();
module2.exports = async (options) => {
const filePath = await findUp2("package.json", options);
if (!filePath) {
return;
}
return {
packageJson: await readPkg({
...options,
cwd: path5.dirname(filePath)
}),
path: filePath
};
};
module2.exports.sync = (options) => {
const filePath = findUp2.sync("package.json", options);
if (!filePath) {
return;
}
return {
packageJson: readPkg.sync({
...options,
cwd: path5.dirname(filePath)
}),
path: filePath
};
};
}
});
// node_modules/commander/lib/error.js
var require_error = __commonJS({
"node_modules/commander/lib/error.js"(exports) {
var CommanderError2 = /* @__PURE__ */ __name(class CommanderError extends Error {
/**
* Constructs the CommanderError class
* @param {number} exitCode suggested exit code which could be used with process.exit
* @param {string} code an id string representing the error
* @param {string} message human-readable description of the error
* @constructor
*/
constructor(exitCode, code, message) {
super(message);
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.code = code;
this.exitCode = exitCode;
this.nestedError = void 0;
}
}, "CommanderError");
var InvalidArgumentError2 = /* @__PURE__ */ __name(class InvalidArgumentError extends CommanderError2 {
/**
* Constructs the InvalidArgumentError class
* @param {string} [message] explanation of why argument is invalid
* @constructor
*/
constructor(message) {
super(1, "commander.invalidArgument", message);
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
}
}, "InvalidArgumentError");
exports.CommanderError = CommanderError2;
exports.InvalidArgumentError = InvalidArgumentError2;
}
});
// node_modules/commander/lib/argument.js
var require_argument = __commonJS({
"node_modules/commander/lib/argument.js"(exports) {
var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
var Argument2 = /* @__PURE__ */ __name(class Argument {
/**
* Initialize a new command argument with the given name and description.
* The default is that the argument is required, and you can explicitly
* indicate this with <> around the name. Put [] around the name for an optional argument.
*
* @param {string} name
* @param {string} [description]
*/
constructor(name, description) {
this.description = description || "";
this.variadic = false;
this.parseArg = void 0;
this.defaultValue = void 0;
this.defaultValueDescription = void 0;
this.argChoices = void 0;
switch (name[0]) {
case "<":
this.required = true;
this._name = name.slice(1, -1);
break;
case "[":
this.required = false;
this._name = name.slice(1, -1);
break;
default:
this.required = true;
this._name = name;
break;
}
if (this._name.length > 3 && this._name.slice(-3) === "...") {
this.variadic = true;
this._name = this._name.slice(0, -3);
}
}
/**
* Return argument name.
*
* @return {string}
*/
name() {
return this._name;
}
/**
* @api private
*/
_concatValue(value, previous) {
if (previous === this.defaultValue || !Array.isArray(previous)) {
return [
value
];
}
return previous.concat(value);
}
/**
* Set the default value, and optionally supply the description to be displayed in the help.
*
* @param {any} value
* @param {string} [description]
* @return {Argument}
*/
default(value, description) {
this.defaultValue = value;
this.defaultValueDescription = description;
return this;
}
/**
* Set the custom handler for processing CLI command arguments into argument values.
*
* @param {Function} [fn]
* @return {Argument}
*/
argParser(fn) {
this.parseArg = fn;
return this;
}
/**
* Only allow argument value to be one of choices.
*
* @param {string[]} values
* @return {Argument}
*/
choices(values) {
this.argChoices = values.slice();
this.parseArg = (arg, previous) => {
if (!this.argChoices.includes(arg)) {
throw new InvalidArgumentError2(`Allowed choices are ${this.argChoices.join(", ")}.`);
}
if (this.variadic) {
return this._concatValue(arg, previous);
}
return arg;
};
return this;
}
/**
* Make argument required.
*/
argRequired() {
this.required = true;
return this;
}
/**
* Make argument optional.
*/
argOptional() {
this.required = false;
return this;
}
}, "Argument");
function humanReadableArgName(arg) {
const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
}
__name(humanReadableArgName, "humanReadableArgName");
exports.Argument = Argument2;
exports.humanReadableArgName = humanReadableArgName;
}
});
// node_modules/commander/lib/help.js
var require_help = __commonJS({
"node_modules/commander/lib/help.js"(exports) {
var { humanReadableArgName } = require_argument();
var Help2 = /* @__PURE__ */ __name(class Help {
constructor() {
this.helpWidth = void 0;
this.sortSubcommands = false;
this.sortOptions = false;
this.showGlobalOptions = false;
}
/**
* Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
*
* @param {Command} cmd
* @returns {Command[]}
*/
visibleCommands(cmd) {
const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
if (cmd._hasImplicitHelpCommand()) {
const [, helpName, helpArgs] = cmd._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);
const helpCommand = cmd.createCommand(helpName).helpOption(false);
helpCommand.description(cmd._helpCommandDescription);
if (helpArgs)
helpCommand.arguments(helpArgs);
visibleCommands.push(helpCommand);
}
if (this.sortSubcommands) {
visibleCommands.sort((a, b) => {
return a.name().localeCompare(b.name());
});
}
return visibleCommands;
}
/**
* Compare options for sort.
*
* @param {Option} a
* @param {Option} b
* @returns number
*/
compareOptions(a, b) {
const getSortKey = /* @__PURE__ */ __name((option) => {
return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
}, "getSortKey");
return getSortKey(a).localeCompare(getSortKey(b));
}
/**
* Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
*
* @param {Command} cmd
* @returns {Option[]}
*/
visibleOptions(cmd) {
const visibleOptions = cmd.options.filter((option) => !option.hidden);
const showShortHelpFlag = cmd._hasHelpOption && cmd._helpShortFlag && !cmd._findOption(cmd._helpShortFlag);
const showLongHelpFlag = cmd._hasHelpOption && !cmd._findOption(cmd._helpLongFlag);
if (showShortHelpFlag || showLongHelpFlag) {
let helpOption;
if (!showShortHelpFlag) {
helpOption = cmd.createOption(cmd._helpLongFlag, cmd._helpDescription);
} else if (!showLongHelpFlag) {
helpOption = cmd.createOption(cmd._helpShortFlag, cmd._helpDescription);
} else {
helpOption = cmd.createOption(cmd._helpFlags, cmd._helpDescription);
}
visibleOptions.push(helpOption);
}
if (this.sortOptions) {
visibleOptions.sort(this.compareOptions);
}
return visibleOptions;
}
/**
* Get an array of the visible global options. (Not including help.)
*
* @param {Command} cmd
* @returns {Option[]}
*/
visibleGlobalOptions(cmd) {
if (!this.showGlobalOptions)
return [];
const globalOptions = [];
for (let parentCmd = cmd.parent; parentCmd; parentCmd = parentCmd.parent) {
const visibleOptions = parentCmd.options.filter((option) => !option.hidden);
globalOptions.push(...visibleOptions);
}
if (this.sortOptions) {
globalOptions.sort(this.compareOptions);
}
return globalOptions;
}
/**
* Get an array of the arguments if any have a description.
*
* @param {Command} cmd
* @returns {Argument[]}
*/
visibleArguments(cmd) {
if (cmd._argsDescription) {
cmd._args.forEach((argument) => {
argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
});
}
if (cmd._args.find((argument) => argument.description)) {
return cmd._args;
}
return [];
}
/**
* Get the command term to show in the list of subcommands.
*
* @param {Command} cmd
* @returns {string}
*/
subcommandTerm(cmd) {
const args = cmd._args.map((arg) => humanReadableArgName(arg)).join(" ");
return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + // simplistic check for non-help option
(args ? " " + args : "");
}
/**
* Get the option term to show in the list of options.
*
* @param {Option} option
* @returns {string}
*/
optionTerm(option) {
return option.flags;
}
/**
* Get the argument term to show in the list of arguments.
*
* @param {Argument} argument
* @returns {string}
*/
argumentTerm(argument) {
return argument.name();
}
/**
* Get the longest command term length.
*
* @param {Command} cmd
* @param {Help} helper
* @returns {number}
*/
longestSubcommandTermLength(cmd, helper) {
return helper.visibleCommands(cmd).reduce((max, command) => {
return Math.max(max, helper.subcommandTerm(command).length);
}, 0);
}
/**
* Get the longest option term length.
*
* @param {Command} cmd
* @param {Help} helper
* @returns {number}
*/
longestOptionTermLength(cmd, helper) {
return helper.visibleOptions(cmd).reduce((max, option) => {
return Math.max(max, helper.optionTerm(option).length);
}, 0);
}
/**
* Get the longest global option term length.
*
* @param {Command} cmd
* @param {Help} helper
* @returns {number}
*/
longestGlobalOptionTermLength(cmd, helper) {
return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
return Math.max(max, helper.optionTerm(option).length);
}, 0);
}
/**
* Get the longest argument term length.
*
* @param {Command} cmd
* @param {Help} helper
* @returns {number}
*/
longestArgumentTermLength(cmd, helper) {
return helper.visibleArguments(cmd).reduce((max, argument) => {
return Math.max(max, helper.argumentTerm(argument).length);
}, 0);
}
/**
* Get the command usage to be displayed at the top of the built-in help.
*
* @param {Command} cmd
* @returns {string}
*/
commandUsage(cmd) {
let cmdName = cmd._name;
if (cmd._aliases[0]) {
cmdName = cmdName + "|" + cmd._aliases[0];
}
let parentCmdNames = "";
for (let parentCmd = cmd.parent; parentCmd; parentCmd = parentCmd.parent) {
parentCmdNames = parentCmd.name() + " " + parentCmdNames;
}
return parentCmdNames + cmdName + " " + cmd.usage();
}
/**
* Get the description for the command.
*
* @param {Command} cmd
* @returns {string}
*/
commandDescription(cmd) {
return cmd.description();
}
/**
* Get the subcommand summary to show in the list of subcommands.
* (Fallback to description for backwards compatibility.)
*
* @param {Command} cmd
* @returns {string}
*/
subcommandDescription(cmd) {
return cmd.summary() || cmd.description();
}
/**
* Get the option description to show in the list of options.
*
* @param {Option} option
* @return {string}
*/
optionDescription(option) {
const extraInfo = [];
if (option.argChoices) {
extraInfo.push(
// use stringify to match the display of the default value
`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
);
}
if (option.defaultValue !== void 0) {
const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
if (showDefault) {
extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
}
}
if (option.presetArg !== void 0 && option.optional) {
extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
}
if (option.envVar !== void 0) {
extraInfo.push(`env: ${option.envVar}`);
}
if (extraInfo.length > 0) {
return `${option.description} (${extraInfo.join(", ")})`;
}
return option.description;
}
/**
* Get the argument description to show in the list of arguments.
*
* @param {Argument} argument
* @return {string}
*/
argumentDescription(argument) {
const extraInfo = [];
if (argument.argChoices) {
extraInfo.push(
// use stringify to match the display of the default value
`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
);
}
if (argument.defaultValue !== void 0) {
extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
}
if (extraInfo.length > 0) {
const extraDescripton = `(${extraInfo.join(", ")})`;
if (argument.description) {
return `${argument.description} ${extraDescripton}`;
}
return extraDescripton;
}
return argument.description;
}
/**
* Generate the built-in help text.
*
* @param {Command} cmd
* @param {Help} helper
* @returns {string}
*/
formatHelp(cmd, helper) {
const termWidth = helper.padWidth(cmd, helper);
const helpWidth = helper.helpWidth || 80;
const itemIndentWidth = 2;
const itemSeparatorWidth = 2;
function formatItem(term, description) {
if (description) {
const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
}
return term;
}
__name(formatItem, "formatItem");
function formatList(textArray) {
return textArray.join("\n").replace(/^/gm, " ".repeat(itemIndentWidth));
}
__name(formatList, "formatList");
let output = [
`Usage: ${helper.commandUsage(cmd)}`,
""
];
const commandDescription = helper.commandDescription(cmd);
if (commandDescription.length > 0) {
output = output.concat([
commandDescription,
""
]);
}
const argumentList = helper.visibleArguments(cmd).map((argument) => {
return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
});
if (argumentList.length > 0) {
output = output.concat([
"Arguments:",
formatList(argumentList),
""
]);
}
const optionList = helper.visibleOptions(cmd).map((option) => {
return formatItem(helper.optionTerm(option), helper.optionDescription(option));
});
if (optionList.length > 0) {
output = output.concat([
"Options:",
formatList(optionList),
""
]);
}
if (this.showGlobalOptions) {
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
return formatItem(helper.optionTerm(option), helper.optionDescription(option));
});
if (globalOptionList.length > 0) {
output = output.concat([
"Global Options:",
formatList(globalOptionList),
""
]);
}
}
const commandList = helper.visibleCommands(cmd).map((cmd2) => {
return formatItem(helper.subcommandTerm(cmd2), helper.subcommandDescription(cmd2));
});
if (commandList.length > 0) {
output = output.concat([
"Commands:",
formatList(commandList),
""
]);
}
return output.join("\n");
}
/**
* Calculate the pad width from the maximum term length.
*
* @param {Command} cmd
* @param {Help} helper
* @returns {number}
*/
padWidth(cmd, helper) {
return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
}
/**
* Wrap the given string to width characters per line, with lines after the first indented.
* Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
*
* @param {string} str
* @param {number} width
* @param {number} indent
* @param {number} [minColumnWidth=40]
* @return {string}
*
*/
wrap(str, width, indent, minColumnWidth = 40) {
if (str.match(/[\n]\s+/))
return str;
const columnWidth = width - indent;
if (columnWidth < minColumnWidth)
return str;
const leadingStr = str.slice(0, indent);
const columnText = str.slice(indent);
const indentString = " ".repeat(indent);
const regex = new RegExp(".{1," + (columnWidth - 1) + "}([\\s\u200B]|$)|[^\\s\u200B]+?([\\s\u200B]|$)", "g");
const lines = columnText.match(regex) || [];
return leadingStr + lines.map((line, i) => {
if (line.slice(-1) === "\n") {
line = line.slice(0, line.length - 1);
}
return (i > 0 ? indentString : "") + line.trimRight();
}).join("\n");
}
}, "Help");
exports.Help = Help2;
}
});
// node_modules/commander/lib/option.js
var require_option = __commonJS({
"node_modules/commander/lib/option.js"(exports) {
var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
var Option2 = /* @__PURE__ */ __name(class Option {
/**
* Initialize a new `Option` with the given `flags` and `description`.
*
* @param {string} flags
* @param {string} [description]
*/
constructor(flags, description) {
this.flags = flags;
this.description = description || "";
this.required = flags.includes("<");
this.optional = flags.includes("[");
this.variadic = /\w\.\.\.[>\]]$/.test(flags);
this.mandatory = false;
const optionFlags = splitOptionFlags(flags);
this.short = optionFlags.shortFlag;
this.long = optionFlags.longFlag;
this.negate = false;
if (this.long) {
this.negate = this.long.startsWith("--no-");
}
this.defaultValue = void 0;
this.defaultValueDescription = void 0;
this.presetArg = void 0;
this.envVar = void 0;
this.parseArg = void 0;
this.hidden = false;
this.argChoices = void 0;
this.conflictsWith = [];
this.implied = void 0;
}
/**
* Set the default value, and optionally supply the description to be displayed in the help.
*
* @param {any} value
* @param {string} [description]
* @return {Option}
*/
default(value, description) {
this.defaultValue = value;
this.defaultValueDescription = description;
return this;
}
/**
* Preset to use when option used without option-argument, especially optional but also boolean and negated.
* The custom processing (parseArg) is called.
*
* @example
* new Option('--color').default('GREYSCALE').preset('RGB');
* new Option('--donate [amount]').preset('20').argParser(parseFloat);
*
* @param {any} arg
* @return {Option}
*/
preset(arg) {
this.presetArg = arg;
return this;
}
/**
* Add option name(s) that conflict with this option.
* An error will be displayed if conflicting options are found during parsing.
*
* @example
* new Option('--rgb').conflicts('cmyk');
* new Option('--js').conflicts(['ts', 'jsx']);
*
* @param {string | string[]} names
* @return {Option}
*/
conflicts(names) {
this.conflictsWith = this.conflictsWith.concat(names);
return this;
}
/**
* Specify implied option values for when this option is set and the implied options are not.
*
* The custom processing (parseArg) is not called on the implied values.
*
* @example
* program
* .addOption(new Option('--log', 'write logging information to file'))
* .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
*
* @param {Object} impliedOptionValues
* @return {Option}
*/
implies(impliedOptionValues) {
this.implied = Object.assign(this.implied || {}, impliedOptionValues);
return this;
}
/**
* Set environment variable to check for option value.
*
* An environment variable is only used if when processed the current option value is
* undefined, or the source of the current value is 'default' or 'config' or 'env'.
*
* @param {string} name
* @return {Option}
*/
env(name) {
this.envVar = name;
return this;
}
/**
* Set the custom handler for processing CLI option arguments into option values.
*
* @param {Function} [fn]
* @return {Option}
*/
argParser(fn) {
this.parseArg = fn;
return this;
}
/**
* Whether the option is mandatory and must have a value after parsing.
*
* @param {boolean} [mandatory=true]
* @return {Option}
*/
makeOptionMandatory(mandatory = true) {
this.mandatory = !!mandatory;
return this;
}
/**
* Hide option in help.
*
* @param {boolean} [hide=true]
* @return {Option}
*/
hideHelp(hide = true) {
this.hidden = !!hide;
return this;
}
/**
* @api private
*/
_concatValue(value, previous) {
if (previous === this.defaultValue || !Array.isArray(previous)) {
return [
value
];
}
return previous.concat(value);
}
/**
* Only allow option value to be one of choices.
*
* @param {string[]} values
* @return {Option}
*/
choices(values) {
this.argChoices = values.slice();
this.parseArg = (arg, previous) => {
if (!this.argChoices.includes(arg)) {
throw new InvalidArgumentError2(`Allowed choices are ${this.argChoices.join(", ")}.`);
}
if (this.variadic) {
return this._concatValue(arg, previous);
}
return arg;
};
return this;
}
/**
* Return option name.
*
* @return {string}
*/
name() {
if (this.long) {
return this.long.replace(/^--/, "");
}
return this.short.replace(/^-/, "");
}
/**
* Return option name, in a camelcase format that can be used
* as a object attribute key.
*
* @return {string}
* @api private
*/
attributeName() {
return camelcase(this.name().replace(/^no-/, ""));
}
/**
* Check if `arg` matches the short or long flag.
*
* @param {string} arg
* @return {boolean}
* @api private
*/
is(arg) {
return this.short === arg || this.long === arg;
}
/**
* Return whether a boolean option.
*
* Options are one of boolean, negated, required argument, or optional argument.
*
* @return {boolean}
* @api private
*/
isBoolean() {
return !this.required && !this.optional && !this.negate;
}
}, "Option");
var DualOptions = /* @__PURE__ */ __name(class DualOptions {
/**
* @param {Option[]} options
*/
constructor(options) {
this.positiveOptions = /* @__PURE__ */ new Map();
this.negativeOptions = /* @__PURE__ */ new Map();
this.dualOptions = /* @__PURE__ */ new Set();
options.forEach((option) => {
if (option.negate) {
this.negativeOptions.set(option.attributeName(), option);
} else {
this.positiveOptions.set(option.attributeName(), option);
}
});
this.negativeOptions.forEach((value, key) => {
if (this.positiveOptions.has(key)) {
this.dualOptions.add(key);
}
});
}
/**
* Did the value come from the option, and not from possible matching dual option?
*
* @param {any} value
* @param {Option} option
* @returns {boolean}
*/
valueFromOption(value, option) {
const optionKey = option.attributeName();
if (!this.dualOptions.has(optionKey))
return true;
const preset = this.negativeOptions.get(optionKey).presetArg;
const negativeValue = preset !== void 0 ? preset : false;
return option.negate === (negativeValue === value);
}
}, "DualOptions");
function camelcase(str) {
return str.split("-").reduce((str2, word) => {
return str2 + word[0].toUpperCase() + word.slice(1);
});
}
__name(camelcase, "camelcase");
function splitOptionFlags(flags) {
let shortFlag;
let longFlag;
const flagParts = flags.split(/[ |,]+/);
if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
shortFlag = flagParts.shift();
longFlag = flagParts.shift();
if (!shortFlag && /^-[^-]$/.test(longFlag)) {
shortFlag = longFlag;
longFlag = void 0;
}
return {
shortFlag,
longFlag
};
}
__name(splitOptionFlags, "splitOptionFlags");
exports.Option = Option2;
exports.splitOptionFlags = splitOptionFlags;
exports.DualOptions = DualOptions;
}
});
// node_modules/commander/lib/suggestSimilar.js
var require_suggestSimilar = __commonJS({
"node_modules/commander/lib/suggestSimilar.js"(exports) {
var maxDistance = 3;
function editDistance(a, b) {
if (Math.abs(a.length - b.length) > maxDistance)
return Math.max(a.length, b.length);
const d = [];
for (let i = 0; i <= a.length; i++) {
d[i] = [
i
];
}
for (let j = 0; j <= b.length; j++) {
d[0][j] = j;
}
for (let j = 1; j <= b.length; j++) {
for (let i = 1; i <= a.length; i++) {
let cost = 1;
if (a[i - 1] === b[j - 1]) {
cost = 0;
} else {
cost = 1;
}
d[i][j] = Math.min(
d[i - 1][j] + 1,
d[i][j - 1] + 1,
d[i - 1][j - 1] + cost
// substitution
);
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
}
}
}
return d[a.length][b.length];
}
__name(editDistance, "editDistance");
function suggestSimilar(word, candidates) {
if (!candidates || candidates.length === 0)
return "";
candidates = Array.from(new Set(candidates));
const searchingOptions = word.startsWith("--");
if (searchingOptions) {
word = word.slice(2);
candidates = candidates.map((candidate) => candidate.slice(2));
}
let similar = [];
let bestDistance = maxDistance;
const minSimilarity = 0.4;
candidates.forEach((candidate) => {
if (candidate.length <= 1)
return;
const distance = editDistance(word, candidate);
const length = Math.max(word.length, candidate.length);
const similarity = (length - distance) / length;
if (similarity > minSimilarity) {
if (distance < bestDistance) {
bestDistance = distance;
similar = [
candidate
];
} else if (distance === bestDistance) {
similar.push(candidate);
}
}
});
similar.sort((a, b) => a.localeCompare(b));
if (searchingOptions) {
similar = similar.map((candidate) => `--${candidate}`);
}
if (similar.length > 1) {
return `
(Did you mean one of ${similar.join(", ")}?)`;
}
if (similar.length === 1) {
return `
(Did you mean ${similar[0]}?)`;
}
return "";
}
__name(suggestSimilar, "suggestSimilar");
exports.suggestSimilar = suggestSimilar;
}
});
// node_modules/commander/lib/command.js
var require_command = __commonJS({
"node_modules/commander/lib/command.js"(exports) {
var EventEmitter = require("events").EventEmitter;
var childProcess = require("child_process");
var path5 = require("path");
var fs3 = require("fs");
var process3 = require("process");
var { Argument: Argument2, humanReadableArgName } = require_argument();
var { CommanderError: CommanderError2 } = require_error();
var { Help: Help2 } = require_help();
var { Option: Option2, splitOptionFlags, DualOptions } = require_option();
var { suggestSimilar } = require_suggestSimilar();
var Command2 = /* @__PURE__ */ __name(class Command3 extends EventEmitter {
/**
* Initialize a new `Command`.
*
* @param {string} [name]
*/
constructor(name) {
super();
this.commands = [];
this.options = [];
this.parent = null;
this._allowUnknownOption = false;
this._allowExcessArguments = true;
this._args = [];
this.args = [];
this.rawArgs = [];
this.processedArgs = [];
this._scriptPath = null;
this._name = name || "";
this._optionValues = {};
this._optionValueSources = {};
this._storeOptionsAsProperties = false;
this._actionHandler = null;
this._executableHandler = false;
this._executableFile = null;
this._executableDir = null;
this._defaultCommandName = null;
this._exitCallback = null;
this._aliases = [];
this._combineFlagAndOptionalValue = true;
this._description = "";
this._summary = "";
this._argsDescription = void 0;
this._enablePositionalOptions = false;
this._passThroughOptions = false;
this._lifeCycleHooks = {};
this._showHelpAfterError = false;
this._showSuggestionAfterError = true;
this._outputConfiguration = {
writeOut: (str) => process3.stdout.write(str),
writeErr: (str) => process3.stderr.write(str),
getOutHelpWidth: () => process3.stdout.isTTY ? process3.stdout.columns : void 0,
getErrHelpWidth: () => process3.stderr.isTTY ? process3.stderr.columns : void 0,
outputError: (str, write) => write(str)
};
this._hidden = false;
this._hasHelpOption = true;
this._helpFlags = "-h, --help";
this._helpDescription = "display help for command";
this._helpShortFlag = "-h";
this._helpLongFlag = "--help";
this._addImplicitHelpCommand = void 0;
this._helpCommandName = "help";
this._helpCommandnameAndArgs = "help [command]";
this._helpCommandDescription = "display help for command";
this._helpConfiguration = {};
}
/**
* Copy settings that are useful to have in common across root command and subcommands.
*
* (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
*
* @param {Command} sourceCommand
* @return {Command} `this` command for chaining
*/
copyInheritedSettings(sourceCommand) {
this._outputConfiguration = sourceCommand._outputConfiguration;
this._hasHelpOption = sourceCommand._hasHelpOption;
this._helpFlags = sourceCommand._helpFlags;
this._helpDescription = sourceCommand._helpDescription;
this._helpShortFlag = sourceCommand._helpShortFlag;
this._helpLongFlag = sourceCommand._helpLongFlag;
this._helpCommandName = sourceCommand._helpCommandName;
this._helpCommandnameAndArgs = sourceCommand._helpCommandnameAndArgs;
this._helpCommandDescription = sourceCommand._helpCommandDescription;
this._helpConfiguration = sourceCommand._helpConfiguration;
this._exitCallback = sourceCommand._exitCallback;
this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
this._allowExcessArguments = sourceCommand._allowExcessArguments;
this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
this._showHelpAfterError = sourceCommand._showHelpAfterError;
this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
return this;
}
/**
* Define a command.
*
* There are two styles of command: pay attention to where to put the description.
*
* @example
* // Command implemented using action handler (description is supplied separately to `.command`)
* program
* .command('clone <source> [destination]')
* .description('clone a repository into a newly created directory')
* .action((source, destination) => {
* console.log('clone command called');
* });
*
* // Command implemented using separate executable file (description is second parameter to `.command`)
* program
* .command('start <service>', 'start named service')
* .command('stop [service]', 'stop named service, or all if no name supplied');
*
* @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
* @param {Object|string} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
* @param {Object} [execOpts] - configuration options (for executable)
* @return {Command} returns new command for action handler, or `this` for executable command
*/
command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
let desc = actionOptsOrExecDesc;
let opts = execOpts;
if (typeof desc === "object" && desc !== null) {
opts = desc;
desc = null;
}
opts = opts || {};
const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
const cmd = this.createCommand(name);
if (desc) {
cmd.description(desc);
cmd._executableHandler = true;
}
if (opts.isDefault)
this._defaultCommandName = cmd._name;
cmd._hidden = !!(opts.noHelp || opts.hidden);
cmd._executableFile = opts.executableFile || null;
if (args)
cmd.arguments(args);
this.commands.push(cmd);
cmd.parent = this;
cmd.copyInheritedSettings(this);
if (desc)
return this;
return cmd;
}
/**
* Factory routine to create a new unattached command.
*
* See .command() for creating an attached subcommand, which uses this routine to
* create the command. You can override createCommand to customise subcommands.
*
* @param {string} [name]
* @return {Command} new command
*/
createCommand(name) {
return new Command3(name);
}
/**
* You can customise the help with a subclass of Help by overriding createHelp,
* or by overriding Help properties using configureHelp().
*
* @return {Help}
*/
createHelp() {
return Object.assign(new Help2(), this.configureHelp());
}
/**
* You can customise the help by overriding Help properties using configureHelp(),
* or with a subclass of Help by overriding createHelp().
*
* @param {Object} [configuration] - configuration options
* @return {Command|Object} `this` command for chaining, or stored configuration
*/
configureHelp(configuration) {
if (configuration === void 0)
return this._helpConfiguration;
this._helpConfiguration = configuration;
return this;
}
/**
* The default output goes to stdout and stderr. You can customise this for special
* applications. You can also customise the display of errors by overriding outputError.
*
* The configuration properties are all functions:
*
* // functions to change where being written, stdout and stderr
* writeOut(str)
* writeErr(str)
* // matching functions to specify width for wrapping help
* getOutHelpWidth()
* getErrHelpWidth()
* // functions based on what is being written out
* outputError(str, write) // used for displaying errors, and not used for displaying help
*
* @param {Object} [configuration] - configuration options
* @return {Command|Object} `this` command for chaining, or stored configuration
*/
configureOutput(configuration) {
if (configuration === void 0)
return this._outputConfiguration;
Object.assign(this._outputConfiguration, configuration);
return this;
}
/**
* Display the help or a custom message after an error occurs.
*
* @param {boolean|string} [displayHelp]
* @return {Command} `this` command for chaining
*/
showHelpAfterError(displayHelp = true) {
if (typeof displayHelp !== "string")
displayHelp = !!displayHelp;
this._showHelpAfterError = displayHelp;
return this;
}
/**
* Display suggestion of similar commands for unknown commands, or options for unknown options.
*
* @param {boolean} [displaySuggestion]
* @return {Command} `this` command for chaining
*/
showSuggestionAfterError(displaySuggestion = true) {
this._showSuggestionAfterError = !!displaySuggestion;
return this;
}
/**
* Add a prepared subcommand.
*
* See .command() for creating an attached subcommand which inherits settings from its parent.
*
* @param {Command} cmd - new subcommand
* @param {Object} [opts] - configuration options
* @return {Command} `this` command for chaining
*/
addCommand(cmd, opts) {
if (!cmd._name) {
throw new Error(`Command passed to .addCommand() must have a name
- specify the name in Command constructor or using .name()`);
}
opts = opts || {};
if (opts.isDefault)
this._defaultCommandName = cmd._name;
if (opts.noHelp || opts.hidden)
cmd._hidden = true;
this.commands.push(cmd);
cmd.parent = this;
return this;
}
/**
* Factory routine to create a new unattached argument.
*
* See .argument() for creating an attached argument, which uses this routine to
* create the argument. You can override createArgument to return a custom argument.
*
* @param {string} name
* @param {string} [description]
* @return {Argument} new argument
*/
createArgument(name, description) {
return new Argument2(name, description);
}
/**
* Define argument syntax for command.
*
* The default is that the argument is required, and you can explicitly
* indicate this with <> around the name. Put [] around the name for an optional argument.
*
* @example
* program.argument('<input-file>');
* program.argument('[output-file]');
*
* @param {string} name
* @param {string} [description]
* @param {Function|*} [fn] - custom argument processing function
* @param {*} [defaultValue]
* @return {Command} `this` command for chaining
*/
argument(name, description, fn, defaultValue) {
const argument = this.createArgument(name, description);
if (typeof fn === "function") {
argument.default(defaultValue).argParser(fn);
} else {
argument.default(fn);
}
this.addArgument(argument);
return this;
}
/**
* Define argument syntax for command, adding multiple at once (without descriptions).
*
* See also .argument().
*
* @example
* program.arguments('<cmd> [env]');
*
* @param {string} names
* @return {Command} `this` command for chaining
*/
arguments(names) {
names.split(/ +/).forEach((detail) => {
this.argument(detail);
});
return this;
}
/**
* Define argument syntax for command, adding a prepared argument.
*
* @param {Argument} argument
* @return {Command} `this` command for chaining
*/
addArgument(argument) {
const previousArgument = this._args.slice(-1)[0];
if (previousArgument && previousArgument.variadic) {
throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
}
if (argument.required && argument.defaultValue !== void 0 && argument.parseArg === void 0) {
throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
}
this._args.push(argument);
return this;
}
/**
* Override default decision whether to add implicit help command.
*
* addHelpCommand() // force on
* addHelpCommand(false); // force off
* addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details
*
* @return {Command} `this` command for chaining
*/
addHelpCommand(enableOrNameAndArgs, description) {
if (enableOrNameAndArgs === false) {
this._addImplicitHelpCommand = false;
} else {
this._addImplicitHelpCommand = true;
if (typeof enableOrNameAndArgs === "string") {
this._helpCommandName = enableOrNameAndArgs.split(" ")[0];
this._helpCommandnameAndArgs = enableOrNameAndArgs;
}
this._helpCommandDescription = description || this._helpCommandDescription;
}
return this;
}
/**
* @return {boolean}
* @api private
*/
_hasImplicitHelpCommand() {
if (this._addImplicitHelpCommand === void 0) {
return this.commands.length && !this._actionHandler && !this._findCommand("help");
}
return this._addImplicitHelpCommand;
}
/**
* Add hook for life cycle event.
*
* @param {string} event
* @param {Function} listener
* @return {Command} `this` command for chaining
*/
hook(event, listener) {
const allowedValues = [
"preSubcommand",
"preAction",
"postAction"
];
if (!allowedValues.includes(event)) {
throw new Error(`Unexpected value for event passed to hook : '${event}'.
Expecting one of '${allowedValues.join("', '")}'`);
}
if (this._lifeCycleHooks[event]) {
this._lifeCycleHooks[event].push(listener);
} else {
this._lifeCycleHooks[event] = [
listener
];
}
return this;
}
/**
* Register callback to use as replacement for calling process.exit.
*
* @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing
* @return {Command} `this` command for chaining
*/
exitOverride(fn) {
if (fn) {
this._exitCallback = fn;
} else {
this._exitCallback = (err) => {
if (err.code !== "commander.executeSubCommandAsync") {
throw err;
} else {
}
};
}
return this;
}
/**
* Call process.exit, and _exitCallback if defined.
*
* @param {number} exitCode exit code for using with process.exit
* @param {string} code an id string representing the error
* @param {string} message human-readable description of the error
* @return never
* @api private
*/
_exit(exitCode, code, message) {
if (this._exitCallback) {
this._exitCallback(new CommanderError2(exitCode, code, message));
}
process3.exit(exitCode);
}
/**
* Register callback `fn` for the command.
*
* @example
* program
* .command('serve')
* .description('start service')
* .action(function() {
* // do work here
* });
*
* @param {Function} fn
* @return {Command} `this` command for chaining
*/
action(fn) {
const listener = /* @__PURE__ */ __name((args) => {
const expectedArgsCount = this._args.length;
const actionArgs = args.slice(0, expectedArgsCount);
if (this._storeOptionsAsProperties) {
actionArgs[expectedArgsCount] = this;
} else {
actionArgs[expectedArgsCount] = this.opts();
}
actionArgs.push(this);
return fn.apply(this, actionArgs);
}, "listener");
this._actionHandler = listener;
return this;
}
/**
* Factory routine to create a new unattached option.
*
* See .option() for creating an attached option, which uses this routine to
* create the option. You can override createOption to return a custom option.
*
* @param {string} flags
* @param {string} [description]
* @return {Option} new option
*/
createOption(flags, description) {
return new Option2(flags, description);
}
/**
* Add an option.
*
* @param {Option} option
* @return {Command} `this` command for chaining
*/
addOption(option) {
const oname = option.name();
const name = option.attributeName();
if (option.negate) {
const positiveLongFlag = option.long.replace(/^--no-/, "--");
if (!this._findOption(positiveLongFlag)) {
this.setOptionValueWithSource(name, option.defaultValue === void 0 ? true : option.defaultValue, "default");
}
} else if (option.defaultValue !== void 0) {
this.setOptionValueWithSource(name, option.defaultValue, "default");
}
this.options.push(option);
const handleOptionValue = /* @__PURE__ */ __name((val, invalidValueMessage, valueSource) => {
if (val == null && option.presetArg !== void 0) {
val = option.presetArg;
}
const oldValue = this.getOptionValue(name);
if (val !== null && option.parseArg) {
try {
val = option.parseArg(val, oldValue);
} catch (err) {
if (err.code === "commander.invalidArgument") {
const message = `${invalidValueMessage} ${err.message}`;
this.error(message, {
exitCode: err.exitCode,
code: err.code
});
}
throw err;
}
} else if (val !== null && option.variadic) {
val = option._concatValue(val, oldValue);
}
if (val == null) {
if (option.negate) {
val = false;
} else if (option.isBoolean() || option.optional) {
val = true;
} else {
val = "";
}
}
this.setOptionValueWithSource(name, val, valueSource);
}, "handleOptionValue");
this.on("option:" + oname, (val) => {
const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
handleOptionValue(val, invalidValueMessage, "cli");
});
if (option.envVar) {
this.on("optionEnv:" + oname, (val) => {
const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
handleOptionValue(val, invalidValueMessage, "env");
});
}
return this;
}
/**
* Internal implementation shared by .option() and .requiredOption()
*
* @api private
*/
_optionEx(config, flags, description, fn, defaultValue) {
if (typeof flags === "object" && flags instanceof Option2) {
throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");
}
const option = this.createOption(flags, description);
option.makeOptionMandatory(!!config.mandatory);
if (typeof fn === "function") {
option.default(defaultValue).argParser(fn);
} else if (fn instanceof RegExp) {
const regex = fn;
fn = /* @__PURE__ */ __name((val, def) => {
const m = regex.exec(val);
return m ? m[0] : def;
}, "fn");
option.default(defaultValue).argParser(fn);
} else {
option.default(fn);
}
return this.addOption(option);
}
/**
* Define option with `flags`, `description` and optional
* coercion `fn`.
*
* The `flags` string contains the short and/or long flags,
* separated by comma, a pipe or space. The following are all valid
* all will output this way when `--help` is used.
*
* "-p, --pepper"
* "-p|--pepper"
* "-p --pepper"
*
* @example
* // simple boolean defaulting to undefined
* program.option('-p, --pepper', 'add pepper');
*
* program.pepper
* // => undefined
*
* --pepper
* program.pepper
* // => true
*
* // simple boolean defaulting to true (unless non-negated option is also defined)
* program.option('-C, --no-cheese', 'remove cheese');
*
* program.cheese
* // => true
*
* --no-cheese
* program.cheese
* // => false
*
* // required argument
* program.option('-C, --chdir <path>', 'change the working directory');
*
* --chdir /tmp
* program.chdir
* // => "/tmp"
*
* // optional argument
* program.option('-c, --cheese [type]', 'add cheese [marble]');
*
* @param {string} flags
* @param {string} [description]
* @param {Function|*} [fn] - custom option processing function or default value
* @param {*} [defaultValue]
* @return {Command} `this` command for chaining
*/
option(flags, description, fn, defaultValue) {
return this._optionEx({}, flags, description, fn, defaultValue);
}
/**
* Add a required option which must have a value after parsing. This usually means
* the option must be specified on the command line. (Otherwise the same as .option().)
*
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
*
* @param {string} flags
* @param {string} [description]
* @param {Function|*} [fn] - custom option processing function or default value
* @param {*} [defaultValue]
* @return {Command} `this` command for chaining
*/
requiredOption(flags, description, fn, defaultValue) {
return this._optionEx({
mandatory: true
}, flags, description, fn, defaultValue);
}
/**
* Alter parsing of short flags with optional values.
*
* @example
* // for `.option('-f,--flag [value]'):
* program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour
* program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
*
* @param {Boolean} [combine=true] - if `true` or omitted, an optional value can be specified directly after the flag.
*/
combineFlagAndOptionalValue(combine = true) {
this._combineFlagAndOptionalValue = !!combine;
return this;
}
/**
* Allow unknown options on the command line.
*
* @param {Boolean} [allowUnknown=true] - if `true` or omitted, no error will be thrown
* for unknown options.
*/
allowUnknownOption(allowUnknown = true) {
this._allowUnknownOption = !!allowUnknown;
return this;
}
/**
* Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
*
* @param {Boolean} [allowExcess=true] - if `true` or omitted, no error will be thrown
* for excess arguments.
*/
allowExcessArguments(allowExcess = true) {
this._allowExcessArguments = !!allowExcess;
return this;
}
/**
* Enable positional options. Positional means global options are specified before subcommands which lets
* subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
* The default behaviour is non-positional and global options may appear anywhere on the command line.
*
* @param {Boolean} [positional=true]
*/
enablePositionalOptions(positional = true) {
this._enablePositionalOptions = !!positional;
return this;
}
/**
* Pass through options that come after command-arguments rather than treat them as command-options,
* so actual command-options come before command-arguments. Turning this on for a subcommand requires
* positional options to have been enabled on the program (parent commands).
* The default behaviour is non-positional and options may appear before or after command-arguments.
*
* @param {Boolean} [passThrough=true]
* for unknown options.
*/
passThroughOptions(passThrough = true) {
this._passThroughOptions = !!passThrough;
if (!!this.parent && passThrough && !this.parent._enablePositionalOptions) {
throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");
}
return this;
}
/**
* Whether to store option values as properties on command object,
* or store separately (specify false). In both cases the option values can be accessed using .opts().
*
* @param {boolean} [storeAsProperties=true]
* @return {Command} `this` command for chaining
*/
storeOptionsAsProperties(storeAsProperties = true) {
this._storeOptionsAsProperties = !!storeAsProperties;
if (this.options.length) {
throw new Error("call .storeOptionsAsProperties() before adding options");
}
return this;
}
/**
* Retrieve option value.
*
* @param {string} key
* @return {Object} value
*/
getOptionValue(key) {
if (this._storeOptionsAsProperties) {
return this[key];
}
return this._optionValues[key];
}
/**
* Store option value.
*
* @param {string} key
* @param {Object} value
* @return {Command} `this` command for chaining
*/
setOptionValue(key, value) {
return this.setOptionValueWithSource(key, value, void 0);
}
/**
* Store option value and where the value came from.
*
* @param {string} key
* @param {Object} value
* @param {string} source - expected values are default/config/env/cli/implied
* @return {Command} `this` command for chaining
*/
setOptionValueWithSource(key, value, source) {
if (this._storeOptionsAsProperties) {
this[key] = value;
} else {
this._optionValues[key] = value;
}
this._optionValueSources[key] = source;
return this;
}
/**
* Get source of option value.
* Expected values are default | config | env | cli | implied
*
* @param {string} key
* @return {string}
*/
getOptionValueSource(key) {
return this._optionValueSources[key];
}
/**
* Get source of option value. See also .optsWithGlobals().
* Expected values are default | config | env | cli | implied
*
* @param {string} key
* @return {string}
*/
getOptionValueSourceWithGlobals(key) {
let source;
getCommandAndParents(this).forEach((cmd) => {
if (cmd.getOptionValueSource(key) !== void 0) {
source = cmd.getOptionValueSource(key);
}
});
return source;
}
/**
* Get user arguments from implied or explicit arguments.
* Side-effects: set _scriptPath if args included script. Used for default program name, and subcommand searches.
*
* @api private
*/
_prepareUserArgs(argv, parseOptions) {
if (argv !== void 0 && !Array.isArray(argv)) {
throw new Error("first parameter to parse must be array or undefined");
}
parseOptions = parseOptions || {};
if (argv === void 0) {
argv = process3.argv;
if (process3.versions && process3.versions.electron) {
parseOptions.from = "electron";
}
}
this.rawArgs = argv.slice();
let userArgs;
switch (parseOptions.from) {
case void 0:
case "node":
this._scriptPath = argv[1];
userArgs = argv.slice(2);
break;
case "electron":
if (process3.defaultApp) {
this._scriptPath = argv[1];
userArgs = argv.slice(2);
} else {
userArgs = argv.slice(1);
}
break;
case "user":
userArgs = argv.slice(0);
break;
default:
throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
}
if (!this._name && this._scriptPath)
this.nameFromFilename(this._scriptPath);
this._name = this._name || "program";
return userArgs;
}
/**
* Parse `argv`, setting options and invoking commands when defined.
*
* The default expectation is that the arguments are from node and have the application as argv[0]
* and the script being run in argv[1], with user parameters after that.
*
* @example
* program.parse(process.argv);
* program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
*
* @param {string[]} [argv] - optional, defaults to process.argv
* @param {Object} [parseOptions] - optionally specify style of options with from: node/user/electron
* @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
* @return {Command} `this` command for chaining
*/
parse(argv, parseOptions) {
const userArgs = this._prepareUserArgs(argv, parseOptions);
this._parseCommand([], userArgs);
return this;
}
/**
* Parse `argv`, setting options and invoking commands when defined.
*
* Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
*
* The default expectation is that the arguments are from node and have the application as argv[0]
* and the script being run in argv[1], with user parameters after that.
*
* @example
* await program.parseAsync(process.argv);
* await program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
* await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
*
* @param {string[]} [argv]
* @param {Object} [parseOptions]
* @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
* @return {Promise}
*/
async parseAsync(argv, parseOptions) {
const userArgs = this._prepareUserArgs(argv, parseOptions);
await this._parseCommand([], userArgs);
return this;
}
/**
* Execute a sub-command executable.
*
* @api private
*/
_executeSubCommand(subcommand, args) {
args = args.slice();
let launchWithNode = false;
const sourceExt = [
".js",
".ts",
".tsx",
".mjs",
".cjs"
];
function findFile(baseDir, baseName) {
const localBin = path5.resolve(baseDir, baseName);
if (fs3.existsSync(localBin))
return localBin;
if (sourceExt.includes(path5.extname(baseName)))
return void 0;
const foundExt = sourceExt.find((ext) => fs3.existsSync(`${localBin}${ext}`));
if (foundExt)
return `${localBin}${foundExt}`;
return void 0;
}
__name(findFile, "findFile");
this._checkForMissingMandatoryOptions();
this._checkForConflictingOptions();
let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
let executableDir = this._executableDir || "";
if (this._scriptPath) {
let resolvedScriptPath;
try {
resolvedScriptPath = fs3.realpathSync(this._scriptPath);
} catch (err) {
resolvedScriptPath = this._scriptPath;
}
executableDir = path5.resolve(path5.dirname(resolvedScriptPath), executableDir);
}
if (executableDir) {
let localFile = findFile(executableDir, executableFile);
if (!localFile && !subcommand._executableFile && this._scriptPath) {
const legacyName = path5.basename(this._scriptPath, path5.extname(this._scriptPath));
if (legacyName !== this._name) {
localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
}
}
executableFile = localFile || executableFile;
}
launchWithNode = sourceExt.includes(path5.extname(executableFile));
let proc;
if (process3.platform !== "win32") {
if (launchWithNode) {
args.unshift(executableFile);
args = incrementNodeInspectorPort(process3.execArgv).concat(args);
proc = childProcess.spawn(process3.argv[0], args, {
stdio: "inherit"
});
} else {
proc = childProcess.spawn(executableFile, args, {
stdio: "inherit"
});
}
} else {
args.unshift(executableFile);
args = incrementNodeInspectorPort(process3.execArgv).concat(args);
proc = childProcess.spawn(process3.execPath, args, {
stdio: "inherit"
});
}
if (!proc.killed) {
const signals = [
"SIGUSR1",
"SIGUSR2",
"SIGTERM",
"SIGINT",
"SIGHUP"
];
signals.forEach((signal) => {
process3.on(signal, () => {
if (proc.killed === false && proc.exitCode === null) {
proc.kill(signal);
}
});
});
}
const exitCallback = this._exitCallback;
if (!exitCallback) {
proc.on("close", process3.exit.bind(process3));
} else {
proc.on("close", () => {
exitCallback(new CommanderError2(process3.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
});
}
proc.on("error", (err) => {
if (err.code === "ENOENT") {
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
const executableMissing = `'${executableFile}' does not exist
- if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
- ${executableDirMessage}`;
throw new Error(executableMissing);
} else if (err.code === "EACCES") {
throw new Error(`'${executableFile}' not executable`);
}
if (!exitCallback) {
process3.exit(1);
} else {
const wrappedError = new CommanderError2(1, "commander.executeSubCommandAsync", "(error)");
wrappedError.nestedError = err;
exitCallback(wrappedError);
}
});
this.runningCommand = proc;
}
/**
* @api private
*/
_dispatchSubcommand(commandName, operands, unknown) {
const subCommand = this._findCommand(commandName);
if (!subCommand)
this.help({
error: true
});
let hookResult;
hookResult = this._chainOrCallSubCommandHook(hookResult, subCommand, "preSubcommand");
hookResult = this._chainOrCall(hookResult, () => {
if (subCommand._executableHandler) {
this._executeSubCommand(subCommand, operands.concat(unknown));
} else {
return subCommand._parseCommand(operands, unknown);
}
});
return hookResult;
}
/**
* Check this.args against expected this._args.
*
* @api private
*/
_checkNumberOfArguments() {
this._args.forEach((arg, i) => {
if (arg.required && this.args[i] == null) {
this.missingArgument(arg.name());
}
});
if (this._args.length > 0 && this._args[this._args.length - 1].variadic) {
return;
}
if (this.args.length > this._args.length) {
this._excessArguments(this.args);
}
}
/**
* Process this.args using this._args and save as this.processedArgs!
*
* @api private
*/
_processArguments() {
const myParseArg = /* @__PURE__ */ __name((argument, value, previous) => {
let parsedValue = value;
if (value !== null && argument.parseArg) {
try {
parsedValue = argument.parseArg(value, previous);
} catch (err) {
if (err.code === "commander.invalidArgument") {
const message = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'. ${err.message}`;
this.error(message, {
exitCode: err.exitCode,
code: err.code
});
}
throw err;
}
}
return parsedValue;
}, "myParseArg");
this._checkNumberOfArguments();
const processedArgs = [];
this._args.forEach((declaredArg, index) => {
let value = declaredArg.defaultValue;
if (declaredArg.variadic) {
if (index < this.args.length) {
value = this.args.slice(index);
if (declaredArg.parseArg) {
value = value.reduce((processed, v) => {
return myParseArg(declaredArg, v, processed);
}, declaredArg.defaultValue);
}
} else if (value === void 0) {
value = [];
}
} else if (index < this.args.length) {
value = this.args[index];
if (declaredArg.parseArg) {
value = myParseArg(declaredArg, value, declaredArg.defaultValue);
}
}
processedArgs[index] = value;
});
this.processedArgs = processedArgs;
}
/**
* Once we have a promise we chain, but call synchronously until then.
*
* @param {Promise|undefined} promise
* @param {Function} fn
* @return {Promise|undefined}
* @api private
*/
_chainOrCall(promise, fn) {
if (promise && promise.then && typeof promise.then === "function") {
return promise.then(() => fn());
}
return fn();
}
/**
*
* @param {Promise|undefined} promise
* @param {string} event
* @return {Promise|undefined}
* @api private
*/
_chainOrCallHooks(promise, event) {
let result = promise;
const hooks = [];
getCommandAndParents(this).reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== void 0).forEach((hookedCommand) => {
hookedCommand._lifeCycleHooks[event].forEach((callback) => {
hooks.push({
hookedCommand,
callback
});
});
});
if (event === "postAction") {
hooks.reverse();
}
hooks.forEach((hookDetail) => {
result = this._chainOrCall(result, () => {
return hookDetail.callback(hookDetail.hookedCommand, this);
});
});
return result;
}
/**
*
* @param {Promise|undefined} promise
* @param {Command} subCommand
* @param {string} event
* @return {Promise|undefined}
* @api private
*/
_chainOrCallSubCommandHook(promise, subCommand, event) {
let result = promise;
if (this._lifeCycleHooks[event] !== void 0) {
this._lifeCycleHooks[event].forEach((hook) => {
result = this._chainOrCall(result, () => {
return hook(this, subCommand);
});
});
}
return result;
}
/**
* Process arguments in context of this command.
* Returns action result, in case it is a promise.
*
* @api private
*/
_parseCommand(operands, unknown) {
const parsed = this.parseOptions(unknown);
this._parseOptionsEnv();
this._parseOptionsImplied();
operands = operands.concat(parsed.operands);
unknown = parsed.unknown;
this.args = operands.concat(unknown);
if (operands && this._findCommand(operands[0])) {
return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
}
if (this._hasImplicitHelpCommand() && operands[0] === this._helpCommandName) {
if (operands.length === 1) {
this.help();
}
return this._dispatchSubcommand(operands[1], [], [
this._helpLongFlag
]);
}
if (this._defaultCommandName) {
outputHelpIfRequested(this, unknown);
return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
}
if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
this.help({
error: true
});
}
outputHelpIfRequested(this, parsed.unknown);
this._checkForMissingMandatoryOptions();
this._checkForConflictingOptions();
const checkForUnknownOptions = /* @__PURE__ */ __name(() => {
if (parsed.unknown.length > 0) {
this.unknownOption(parsed.unknown[0]);
}
}, "checkForUnknownOptions");
const commandEvent = `command:${this.name()}`;
if (this._actionHandler) {
checkForUnknownOptions();
this._processArguments();
let actionResult;
actionResult = this._chainOrCallHooks(actionResult, "preAction");
actionResult = this._chainOrCall(actionResult, () => this._actionHandler(this.processedArgs));
if (this.parent) {
actionResult = this._chainOrCall(actionResult, () => {
this.parent.emit(commandEvent, operands, unknown);
});
}
actionResult = this._chainOrCallHooks(actionResult, "postAction");
return actionResult;
}
if (this.parent && this.parent.listenerCount(commandEvent)) {
checkForUnknownOptions();
this._processArguments();
this.parent.emit(commandEvent, operands, unknown);
} else if (operands.length) {
if (this._findCommand("*")) {
return this._dispatchSubcommand("*", operands, unknown);
}
if (this.listenerCount("command:*")) {
this.emit("command:*", operands, unknown);
} else if (this.commands.length) {
this.unknownCommand();
} else {
checkForUnknownOptions();
this._processArguments();
}
} else if (this.commands.length) {
checkForUnknownOptions();
this.help({
error: true
});
} else {
checkForUnknownOptions();
this._processArguments();
}
}
/**
* Find matching command.
*
* @api private
*/
_findCommand(name) {
if (!name)
return void 0;
return this.commands.find((cmd) => cmd._name === name || cmd._aliases.includes(name));
}
/**
* Return an option matching `arg` if any.
*
* @param {string} arg
* @return {Option}
* @api private
*/
_findOption(arg) {
return this.options.find((option) => option.is(arg));
}
/**
* Display an error message if a mandatory option does not have a value.
* Called after checking for help flags in leaf subcommand.
*
* @api private
*/
_checkForMissingMandatoryOptions() {
for (let cmd = this; cmd; cmd = cmd.parent) {
cmd.options.forEach((anOption) => {
if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === void 0) {
cmd.missingMandatoryOptionValue(anOption);
}
});
}
}
/**
* Display an error message if conflicting options are used together in this.
*
* @api private
*/
_checkForConflictingLocalOptions() {
const definedNonDefaultOptions = this.options.filter((option) => {
const optionKey = option.attributeName();
if (this.getOptionValue(optionKey) === void 0) {
return false;
}
return this.getOptionValueSource(optionKey) !== "default";
});
const optionsWithConflicting = definedNonDefaultOptions.filter((option) => option.conflictsWith.length > 0);
optionsWithConflicting.forEach((option) => {
const conflictingAndDefined = definedNonDefaultOptions.find((defined) => option.conflictsWith.includes(defined.attributeName()));
if (conflictingAndDefined) {
this._conflictingOption(option, conflictingAndDefined);
}
});
}
/**
* Display an error message if conflicting options are used together.
* Called after checking for help flags in leaf subcommand.
*
* @api private
*/
_checkForConflictingOptions() {
for (let cmd = this; cmd; cmd = cmd.parent) {
cmd._checkForConflictingLocalOptions();
}
}
/**
* Parse options from `argv` removing known options,
* and return argv split into operands and unknown arguments.
*
* Examples:
*
* argv => operands, unknown
* --known kkk op => [op], []
* op --known kkk => [op], []
* sub --unknown uuu op => [sub], [--unknown uuu op]
* sub -- --unknown uuu op => [sub --unknown uuu op], []
*
* @param {String[]} argv
* @return {{operands: String[], unknown: String[]}}
*/
parseOptions(argv) {
const operands = [];
const unknown = [];
let dest = operands;
const args = argv.slice();
function maybeOption(arg) {
return arg.length > 1 && arg[0] === "-";
}
__name(maybeOption, "maybeOption");
let activeVariadicOption = null;
while (args.length) {
const arg = args.shift();
if (arg === "--") {
if (dest === unknown)
dest.push(arg);
dest.push(...args);
break;
}
if (activeVariadicOption && !maybeOption(arg)) {
this.emit(`option:${activeVariadicOption.name()}`, arg);
continue;
}
activeVariadicOption = null;
if (maybeOption(arg)) {
const option = this._findOption(arg);
if (option) {
if (option.required) {
const value = args.shift();
if (value === void 0)
this.optionMissingArgument(option);
this.emit(`option:${option.name()}`, value);
} else if (option.optional) {
let value = null;
if (args.length > 0 && !maybeOption(args[0])) {
value = args.shift();
}
this.emit(`option:${option.name()}`, value);
} else {
this.emit(`option:${option.name()}`);
}
activeVariadicOption = option.variadic ? option : null;
continue;
}
}
if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
const option = this._findOption(`-${arg[1]}`);
if (option) {
if (option.required || option.optional && this._combineFlagAndOptionalValue) {
this.emit(`option:${option.name()}`, arg.slice(2));
} else {
this.emit(`option:${option.name()}`);
args.unshift(`-${arg.slice(2)}`);
}
continue;
}
}
if (/^--[^=]+=/.test(arg)) {
const index = arg.indexOf("=");
const option = this._findOption(arg.slice(0, index));
if (option && (option.required || option.optional)) {
this.emit(`option:${option.name()}`, arg.slice(index + 1));
continue;
}
}
if (maybeOption(arg)) {
dest = unknown;
}
if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
if (this._findCommand(arg)) {
operands.push(arg);
if (args.length > 0)
unknown.push(...args);
break;
} else if (arg === this._helpCommandName && this._hasImplicitHelpCommand()) {
operands.push(arg);
if (args.length > 0)
operands.push(...args);
break;
} else if (this._defaultCommandName) {
unknown.push(arg);
if (args.length > 0)
unknown.push(...args);
break;
}
}
if (this._passThroughOptions) {
dest.push(arg);
if (args.length > 0)
dest.push(...args);
break;
}
dest.push(arg);
}
return {
operands,
unknown
};
}
/**
* Return an object containing local option values as key-value pairs.
*
* @return {Object}
*/
opts() {
if (this._storeOptionsAsProperties) {
const result = {};
const len = this.options.length;
for (let i = 0; i < len; i++) {
const key = this.options[i].attributeName();
result[key] = key === this._versionOptionName ? this._version : this[key];
}
return result;
}
return this._optionValues;
}
/**
* Return an object containing merged local and global option values as key-value pairs.
*
* @return {Object}
*/
optsWithGlobals() {
return getCommandAndParents(this).reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {});
}
/**
* Display error message and exit (or call exitOverride).
*
* @param {string} message
* @param {Object} [errorOptions]
* @param {string} [errorOptions.code] - an id string representing the error
* @param {number} [errorOptions.exitCode] - used with process.exit
*/
error(message, errorOptions) {
this._outputConfiguration.outputError(`${message}
`, this._outputConfiguration.writeErr);
if (typeof this._showHelpAfterError === "string") {
this._outputConfiguration.writeErr(`${this._showHelpAfterError}
`);
} else if (this._showHelpAfterError) {
this._outputConfiguration.writeErr("\n");
this.outputHelp({
error: true
});
}
const config = errorOptions || {};
const exitCode = config.exitCode || 1;
const code = config.code || "commander.error";
this._exit(exitCode, code, message);
}
/**
* Apply any option related environment variables, if option does
* not have a value from cli or client code.
*
* @api private
*/
_parseOptionsEnv() {
this.options.forEach((option) => {
if (option.envVar && option.envVar in process3.env) {
const optionKey = option.attributeName();
if (this.getOptionValue(optionKey) === void 0 || [
"default",
"config",
"env"
].includes(this.getOptionValueSource(optionKey))) {
if (option.required || option.optional) {
this.emit(`optionEnv:${option.name()}`, process3.env[option.envVar]);
} else {
this.emit(`optionEnv:${option.name()}`);
}
}
}
});
}
/**
* Apply any implied option values, if option is undefined or default value.
*
* @api private
*/
_parseOptionsImplied() {
const dualHelper = new DualOptions(this.options);
const hasCustomOptionValue = /* @__PURE__ */ __name((optionKey) => {
return this.getOptionValue(optionKey) !== void 0 && ![
"default",
"implied"
].includes(this.getOptionValueSource(optionKey));
}, "hasCustomOptionValue");
this.options.filter((option) => option.implied !== void 0 && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)).forEach((option) => {
Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], "implied");
});
});
}
/**
* Argument `name` is missing.
*
* @param {string} name
* @api private
*/
missingArgument(name) {
const message = `error: missing required argument '${name}'`;
this.error(message, {
code: "commander.missingArgument"
});
}
/**
* `Option` is missing an argument.
*
* @param {Option} option
* @api private
*/
optionMissingArgument(option) {
const message = `error: option '${option.flags}' argument missing`;
this.error(message, {
code: "commander.optionMissingArgument"
});
}
/**
* `Option` does not have a value, and is a mandatory option.
*
* @param {Option} option
* @api private
*/
missingMandatoryOptionValue(option) {
const message = `error: required option '${option.flags}' not specified`;
this.error(message, {
code: "commander.missingMandatoryOptionValue"
});
}
/**
* `Option` conflicts with another option.
*
* @param {Option} option
* @param {Option} conflictingOption
* @api private
*/
_conflictingOption(option, conflictingOption) {
const findBestOptionFromValue = /* @__PURE__ */ __name((option2) => {
const optionKey = option2.attributeName();
const optionValue = this.getOptionValue(optionKey);
const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
if (negativeOption && (negativeOption.presetArg === void 0 && optionValue === false || negativeOption.presetArg !== void 0 && optionValue === negativeOption.presetArg)) {
return negativeOption;
}
return positiveOption || option2;
}, "findBestOptionFromValue");
const getErrorMessage = /* @__PURE__ */ __name((option2) => {
const bestOption = findBestOptionFromValue(option2);
const optionKey = bestOption.attributeName();
const source = this.getOptionValueSource(optionKey);
if (source === "env") {
return `environment variable '${bestOption.envVar}'`;
}
return `option '${bestOption.flags}'`;
}, "getErrorMessage");
const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
this.error(message, {
code: "commander.conflictingOption"
});
}
/**
* Unknown option `flag`.
*
* @param {string} flag
* @api private
*/
unknownOption(flag) {
if (this._allowUnknownOption)
return;
let suggestion = "";
if (flag.startsWith("--") && this._showSuggestionAfterError) {
let candidateFlags = [];
let command = this;
do {
const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long);
candidateFlags = candidateFlags.concat(moreFlags);
command = command.parent;
} while (command && !command._enablePositionalOptions);
suggestion = suggestSimilar(flag, candidateFlags);
}
const message = `error: unknown option '${flag}'${suggestion}`;
this.error(message, {
code: "commander.unknownOption"
});
}
/**
* Excess arguments, more than expected.
*
* @param {string[]} receivedArgs
* @api private
*/
_excessArguments(receivedArgs) {
if (this._allowExcessArguments)
return;
const expected = this._args.length;
const s = expected === 1 ? "" : "s";
const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
this.error(message, {
code: "commander.excessArguments"
});
}
/**
* Unknown command.
*
* @api private
*/
unknownCommand() {
const unknownName = this.args[0];
let suggestion = "";
if (this._showSuggestionAfterError) {
const candidateNames = [];
this.createHelp().visibleCommands(this).forEach((command) => {
candidateNames.push(command.name());
if (command.alias())
candidateNames.push(command.alias());
});
suggestion = suggestSimilar(unknownName, candidateNames);
}
const message = `error: unknown command '${unknownName}'${suggestion}`;
this.error(message, {
code: "commander.unknownCommand"
});
}
/**
* Set the program version to `str`.
*
* This method auto-registers the "-V, --version" flag
* which will print the version number when passed.
*
* You can optionally supply the flags and description to override the defaults.
*
* @param {string} str
* @param {string} [flags]
* @param {string} [description]
* @return {this | string} `this` command for chaining, or version string if no arguments
*/
version(str, flags, description) {
if (str === void 0)
return this._version;
this._version = str;
flags = flags || "-V, --version";
description = description || "output the version number";
const versionOption = this.createOption(flags, description);
this._versionOptionName = versionOption.attributeName();
this.options.push(versionOption);
this.on("option:" + versionOption.name(), () => {
this._outputConfiguration.writeOut(`${str}
`);
this._exit(0, "commander.version", str);
});
return this;
}
/**
* Set the description.
*
* @param {string} [str]
* @param {Object} [argsDescription]
* @return {string|Command}
*/
description(str, argsDescription) {
if (str === void 0 && argsDescription === void 0)
return this._description;
this._description = str;
if (argsDescription) {
this._argsDescription = argsDescription;
}
return this;
}
/**
* Set the summary. Used when listed as subcommand of parent.
*
* @param {string} [str]
* @return {string|Command}
*/
summary(str) {
if (str === void 0)
return this._summary;
this._summary = str;
return this;
}
/**
* Set an alias for the command.
*
* You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
*
* @param {string} [alias]
* @return {string|Command}
*/
alias(alias) {
if (alias === void 0)
return this._aliases[0];
let command = this;
if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
command = this.commands[this.commands.length - 1];
}
if (alias === command._name)
throw new Error("Command alias can't be the same as its name");
command._aliases.push(alias);
return this;
}
/**
* Set aliases for the command.
*
* Only the first alias is shown in the auto-generated help.
*
* @param {string[]} [aliases]
* @return {string[]|Command}
*/
aliases(aliases) {
if (aliases === void 0)
return this._aliases;
aliases.forEach((alias) => this.alias(alias));
return this;
}
/**
* Set / get the command usage `str`.
*
* @param {string} [str]
* @return {String|Command}
*/
usage(str) {
if (str === void 0) {
if (this._usage)
return this._usage;
const args = this._args.map((arg) => {
return humanReadableArgName(arg);
});
return [].concat(this.options.length || this._hasHelpOption ? "[options]" : [], this.commands.length ? "[command]" : [], this._args.length ? args : []).join(" ");
}
this._usage = str;
return this;
}
/**
* Get or set the name of the command.
*
* @param {string} [str]
* @return {string|Command}
*/
name(str) {
if (str === void 0)
return this._name;
this._name = str;
return this;
}
/**
* Set the name of the command from script filename, such as process.argv[1],
* or require.main.filename, or __filename.
*
* (Used internally and public although not documented in README.)
*
* @example
* program.nameFromFilename(require.main.filename);
*
* @param {string} filename
* @return {Command}
*/
nameFromFilename(filename) {
this._name = path5.basename(filename, path5.extname(filename));
return this;
}
/**
* Get or set the directory for searching for executable subcommands of this command.
*
* @example
* program.executableDir(__dirname);
* // or
* program.executableDir('subcommands');
*
* @param {string} [path]
* @return {string|Command}
*/
executableDir(path6) {
if (path6 === void 0)
return this._executableDir;
this._executableDir = path6;
return this;
}
/**
* Return program help documentation.
*
* @param {{ error: boolean }} [contextOptions] - pass {error:true} to wrap for stderr instead of stdout
* @return {string}
*/
helpInformation(contextOptions) {
const helper = this.createHelp();
if (helper.helpWidth === void 0) {
helper.helpWidth = contextOptions && contextOptions.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
}
return helper.formatHelp(this, helper);
}
/**
* @api private
*/
_getHelpContext(contextOptions) {
contextOptions = contextOptions || {};
const context = {
error: !!contextOptions.error
};
let write;
if (context.error) {
write = /* @__PURE__ */ __name((arg) => this._outputConfiguration.writeErr(arg), "write");
} else {
write = /* @__PURE__ */ __name((arg) => this._outputConfiguration.writeOut(arg), "write");
}
context.write = contextOptions.write || write;
context.command = this;
return context;
}
/**
* Output help information for this command.
*
* Outputs built-in help, and custom text added using `.addHelpText()`.
*
* @param {{ error: boolean } | Function} [contextOptions] - pass {error:true} to write to stderr instead of stdout
*/
outputHelp(contextOptions) {
let deprecatedCallback;
if (typeof contextOptions === "function") {
deprecatedCallback = contextOptions;
contextOptions = void 0;
}
const context = this._getHelpContext(contextOptions);
getCommandAndParents(this).reverse().forEach((command) => command.emit("beforeAllHelp", context));
this.emit("beforeHelp", context);
let helpInformation = this.helpInformation(context);
if (deprecatedCallback) {
helpInformation = deprecatedCallback(helpInformation);
if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
throw new Error("outputHelp callback must return a string or a Buffer");
}
}
context.write(helpInformation);
this.emit(this._helpLongFlag);
this.emit("afterHelp", context);
getCommandAndParents(this).forEach((command) => command.emit("afterAllHelp", context));
}
/**
* You can pass in flags and a description to override the help
* flags and help description for your command. Pass in false to
* disable the built-in help option.
*
* @param {string | boolean} [flags]
* @param {string} [description]
* @return {Command} `this` command for chaining
*/
helpOption(flags, description) {
if (typeof flags === "boolean") {
this._hasHelpOption = flags;
return this;
}
this._helpFlags = flags || this._helpFlags;
this._helpDescription = description || this._helpDescription;
const helpFlags = splitOptionFlags(this._helpFlags);
this._helpShortFlag = helpFlags.shortFlag;
this._helpLongFlag = helpFlags.longFlag;
return this;
}
/**
* Output help information and exit.
*
* Outputs built-in help, and custom text added using `.addHelpText()`.
*
* @param {{ error: boolean }} [contextOptions] - pass {error:true} to write to stderr instead of stdout
*/
help(contextOptions) {
this.outputHelp(contextOptions);
let exitCode = process3.exitCode || 0;
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
exitCode = 1;
}
this._exit(exitCode, "commander.help", "(outputHelp)");
}
/**
* Add additional text to be displayed with the built-in help.
*
* Position is 'before' or 'after' to affect just this command,
* and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
*
* @param {string} position - before or after built-in help
* @param {string | Function} text - string to add, or a function returning a string
* @return {Command} `this` command for chaining
*/
addHelpText(position, text) {
const allowedValues = [
"beforeAll",
"before",
"after",
"afterAll"
];
if (!allowedValues.includes(position)) {
throw new Error(`Unexpected value for position to addHelpText.
Expecting one of '${allowedValues.join("', '")}'`);
}
const helpEvent = `${position}Help`;
this.on(helpEvent, (context) => {
let helpStr;
if (typeof text === "function") {
helpStr = text({
error: context.error,
command: context.command
});
} else {
helpStr = text;
}
if (helpStr) {
context.write(`${helpStr}
`);
}
});
return this;
}
}, "Command");
function outputHelpIfRequested(cmd, args) {
const helpOption = cmd._hasHelpOption && args.find((arg) => arg === cmd._helpLongFlag || arg === cmd._helpShortFlag);
if (helpOption) {
cmd.outputHelp();
cmd._exit(0, "commander.helpDisplayed", "(outputHelp)");
}
}
__name(outputHelpIfRequested, "outputHelpIfRequested");
function incrementNodeInspectorPort(args) {
return args.map((arg) => {
if (!arg.startsWith("--inspect")) {
return arg;
}
let debugOption;
let debugHost = "127.0.0.1";
let debugPort = "9229";
let match;
if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
debugOption = match[1];
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
debugOption = match[1];
if (/^\d+$/.test(match[3])) {
debugPort = match[3];
} else {
debugHost = match[3];
}
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
debugOption = match[1];
debugHost = match[3];
debugPort = match[4];
}
if (debugOption && debugPort !== "0") {
return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
}
return arg;
});
}
__name(incrementNodeInspectorPort, "incrementNodeInspectorPort");
function getCommandAndParents(startCommand) {
const result = [];
for (let command = startCommand; command; command = command.parent) {
result.push(command);
}
return result;
}
__name(getCommandAndParents, "getCommandAndParents");
exports.Command = Command2;
}
});
// node_modules/commander/index.js
var require_commander = __commonJS({
"node_modules/commander/index.js"(exports, module2) {
var { Argument: Argument2 } = require_argument();
var { Command: Command2 } = require_command();
var { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error();
var { Help: Help2 } = require_help();
var { Option: Option2 } = require_option();
exports = module2.exports = new Command2();
exports.program = exports;
exports.Argument = Argument2;
exports.Command = Command2;
exports.CommanderError = CommanderError2;
exports.Help = Help2;
exports.InvalidArgumentError = InvalidArgumentError2;
exports.InvalidOptionArgumentError = InvalidArgumentError2;
exports.Option = Option2;
}
});
// src/index.ts
var src_exports = {};
__export(src_exports, {
getJestConfig: () => getJestConfig,
getStoryContext: () => getStoryContext,
getTestRunnerConfig: () => getTestRunnerConfig,
setPostVisit: () => setPostVisit,
setPreVisit: () => setPreVisit,
setupPage: () => setupPage,
testPrefixer: () => testPrefixer,
transformPlaywright: () => transformPlaywright,
waitForPageReady: () => waitForPageReady
});
module.exports = __toCommonJS(src_exports);
// src/playwright/hooks.ts
var setPreVisit = /* @__PURE__ */ __name((preVisit) => {
globalThis.__sbPreVisit = preVisit;
}, "setPreVisit");
var setPostVisit = /* @__PURE__ */ __name((postVisit) => {
globalThis.__sbPostVisit = postVisit;
}, "setPostVisit");
var getStoryContext = /* @__PURE__ */ __name(async (page, context) => {
return page.evaluate(({ storyId }) => globalThis.__getContext(storyId), {
storyId: context.id
});
}, "getStoryContext");
var waitForPageReady = /* @__PURE__ */ __name(async (page) => {
await page.waitForLoadState("domcontentloaded");
await page.waitForLoadState("load");
await page.waitForLoadState("networkidle");
await page.evaluate(() => document.fonts.ready);
}, "waitForPageReady");
// src/config/jest-playwright.ts
var import_path = __toESM(require("path"));
var import_common = require("storybook/internal/common");
var getTestRunnerPath = /* @__PURE__ */ __name(() => process.env.STORYBOOK_TEST_RUNNER_PATH ?? "@storybook/test-runner", "getTestRunnerPath");
var getJestPlaywrightConfig = /* @__PURE__ */ __name(() => {
const TEST_RUNNER_PATH = getTestRunnerPath();
const presetBasePath = import_path.default.dirname(require.resolve("jest-playwright-preset", {
paths: [
import_path.default.join(__dirname, "../node_modules")
]
}));
const expectPlaywrightPath = import_path.default.dirname(require.resolve("expect-playwright", {
paths: [
import_path.default.join(__dirname, "../node_modules")
]
}));
return {
runner: import_path.default.join(presetBasePath, "runner.js"),
globalSetup: require.resolve(`${TEST_RUNNER_PATH}/playwright/global-setup.js`),
globalTeardown: require.resolve(`${TEST_RUNNER_PATH}/playwright/global-teardown.js`),
testEnvironment: require.resolve(`${TEST_RUNNER_PATH}/playwright/custom-environment.js`),
setupFilesAfterEnv: [
require.resolve(`${TEST_RUNNER_PATH}/playwright/jest-setup.js`),
expectPlaywrightPath,
import_path.default.join(presetBasePath, "lib", "extends.js")
]
};
}, "getJestPlaywrightConfig");
var getJestConfig = /* @__PURE__ */ __name(() => {
const { TEST_ROOT, TEST_MATCH, STORYBOOK_STORIES_PATTERN, TEST_BROWSERS, STORYBOOK_COLLECT_COVERAGE, STORYBOOK_JUNIT } = process.env;
const jestJunitPath = import_path.default.dirname(require.resolve("jest-junit", {
paths: [
import_path.default.join(__dirname, "../node_modules")
]
}));
const jestSerializerHtmlPath = import_path.default.dirname(require.resolve("jest-serializer-html", {
paths: [
import_path.default.join(__dirname, "../node_modules")
]
}));
const swcJestPath = import_path.default.dirname(require.resolve("@swc/jest", {
paths: [
import_path.default.join(__dirname, "../node_modules")
]
}));
const reporters = STORYBOOK_JUNIT ? [
"default",
jestJunitPath
] : [
"default"
];
const testMatch = STORYBOOK_STORIES_PATTERN?.split(";") ?? [];
const TEST_RUNNER_PATH = getTestRunnerPath();
const config = {
rootDir: (0, import_common.getProjectRoot)(),
roots: TEST_ROOT ? [
TEST_ROOT
] : void 0,
reporters,
testMatch,
transform: {
"^.+\\.(story|stories)\\.[jt]sx?$": require.resolve(`${TEST_RUNNER_PATH}/playwright/transform`),
"^.+\\.[jt]sx?$": swcJestPath
},
snapshotSerializers: [
jestSerializerHtmlPath
],
testEnvironmentOptions: {
"jest-playwright": {
browsers: TEST_BROWSERS?.split(",").map((p) => p.trim().toLowerCase()).filter(Boolean),
collectCoverage: STORYBOOK_COLLECT_COVERAGE === "true",
exitOnPageError: false
}
},
watchPlugins: [
require.resolve("jest-watch-typeahead/filename"),
require.resolve("jest-watch-typeahead/testname")
],
watchPathIgnorePatterns: [
"coverage",
".nyc_output",
".cache"
],
...getJestPlaywrightConfig()
};
if (TEST_MATCH) {
config.testMatch = [
TEST_MATCH
];
}
return config;
}, "getJestConfig");
// src/setup-page.ts
var import_read_pkg_up = __toESM(require_read_pkg_up());
// node_modules/pkg-up/node_modules/find-up/index.js
var import_node_path2 = __toESM(require("path"), 1);
var import_node_url2 = require("url");
// node_modules/pkg-up/node_modules/locate-path/index.js
var import_node_process = __toESM(require("process"), 1);
var import_node_path = __toESM(require("path"), 1);
var import_node_fs = __toESM(require("fs"), 1);
var import_node_url = require("url");
// node_modules/pkg-up/node_modules/yocto-queue/index.js
var Node = /* @__PURE__ */ __name(class Node2 {
constructor(value) {
__publicField(this, "value");
__publicField(this, "next");
this.value = value;
}
}, "Node");
var _head, _tail, _size;
var Queue = class {
constructor() {
__privateAdd(this, _head, void 0);
__privateAdd(this, _tail, void 0);
__privateAdd(this, _size, void 0);
this.clear();
}
enqueue(value) {
const node = new Node(value);
if (__privateGet(this, _head)) {
__privateGet(this, _tail).next = node;
__privateSet(this, _tail, node);
} else {
__privateSet(this, _head, node);
__privateSet(this, _tail, node);
}
__privateWrapper(this, _size)._++;
}
dequeue() {
const current = __privateGet(this, _head);
if (!current) {
return;
}
__privateSet(this, _head, __privateGet(this, _head).next);
__privateWrapper(this, _size)._--;
return current.value;
}
peek() {
if (!__privateGet(this, _head)) {
return;
}
return __privateGet(this, _head).value;
}
clear() {
__privateSet(this, _head, void 0);
__privateSet(this, _tail, void 0);
__privateSet(this, _size, 0);
}
get size() {
return __privateGet(this, _size);
}
*[Symbol.iterator]() {
let current = __privateGet(this, _head);
while (current) {
yield current.value;
current = current.next;
}
}
};
__name(Queue, "Queue");
_head = new WeakMap();
_tail = new WeakMap();
_size = new WeakMap();
// node_modules/pkg-up/node_modules/p-limit/index.js
function pLimit(concurrency) {
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
}
const queue = new Queue();
let activeCount = 0;
const next = /* @__PURE__ */ __name(() => {
activeCount--;
if (queue.size > 0) {
queue.dequeue()();
}
}, "next");
const run = /* @__PURE__ */ __name(async (fn, resolve3, args) => {
activeCount++;
const result = (async () => fn(...args))();
resolve3(result);
try {
await result;
} catch {
}
next();
}, "run");
const enqueue = /* @__PURE__ */ __name((fn, resolve3, args) => {
queue.enqueue(run.bind(void 0, fn, resolve3, args));
(async () => {
await Promise.resolve();
if (activeCount < concurrency && queue.size > 0) {
queue.dequeue()();
}
})();
}, "enqueue");
const generator = /* @__PURE__ */ __name((fn, ...args) => new Promise((resolve3) => {
enqueue(fn, resolve3, args);
}), "generator");
Object.defineProperties(generator, {
activeCount: {
get: () => activeCount
},
pendingCount: {
get: () => queue.size
},
clearQueue: {
value: () => {
queue.clear();
}
}
});
return generator;
}
__name(pLimit, "pLimit");
// node_modules/pkg-up/node_modules/p-locate/index.js
var EndError = /* @__PURE__ */ __name(class EndError2 extends Error {
constructor(value) {
super();
this.value = value;
}
}, "EndError");
var testElement = /* @__PURE__ */ __name(async (element, tester) => tester(await element), "testElement");
var finder = /* @__PURE__ */ __name(async (element) => {
const values = await Promise.all(element);
if (values[1] === true) {
throw new EndError(values[0]);
}
return false;
}, "finder");
async function pLocate(iterable, tester, { concurrency = Number.POSITIVE_INFINITY, preserveOrder = true } = {}) {
const limit = pLimit(concurrency);
const items = [
...iterable
].map((element) => [
element,
limit(testElement, element, tester)
]);
const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
try {
await Promise.all(items.map((element) => checkLimit(finder, element)));
} catch (error) {
if (error instanceof EndError) {
return error.value;
}
throw error;
}
}
__name(pLocate, "pLocate");
// node_modules/pkg-up/node_modules/locate-path/index.js
var typeMappings = {
directory: "isDirectory",
file: "isFile"
};
function checkType(type) {
if (Object.hasOwnProperty.call(typeMappings, type)) {
return;
}
throw new Error(`Invalid type specified: ${type}`);
}
__name(checkType, "checkType");
var matchType = /* @__PURE__ */ __name((type, stat) => stat[typeMappings[type]](), "matchType");
var toPath = /* @__PURE__ */ __name((urlOrPath) => urlOrPath instanceof URL ? (0, import_node_url.fileURLToPath)(urlOrPath) : urlOrPath, "toPath");
async function locatePath(paths, { cwd = import_node_process.default.cwd(), type = "file", allowSymlinks = true, concurrency, preserveOrder } = {}) {
checkType(type);
cwd = toPath(cwd);
const statFunction = allowSymlinks ? import_node_fs.promises.stat : import_node_fs.promises.lstat;
return pLocate(paths, async (path_) => {
try {
const stat = await statFunction(import_node_path.default.resolve(cwd, path_));
return matchType(type, stat);
} catch {
return false;
}
}, {
concurrency,
preserveOrder
});
}
__name(locatePath, "locatePath");
// node_modules/pkg-up/node_modules/path-exists/index.js
var import_node_fs2 = __toESM(require("fs"), 1);
// node_modules/pkg-up/node_modules/find-up/index.js
var toPath2 = /* @__PURE__ */ __name((urlOrPath) => urlOrPath instanceof URL ? (0, import_node_url2.fileURLToPath)(urlOrPath) : urlOrPath, "toPath");
var findUpStop = Symbol("findUpStop");
async function findUpMultiple(name, options = {}) {
let directory = import_node_path2.default.resolve(toPath2(options.cwd) || "");
const { root } = import_node_path2.default.parse(directory);
const stopAt = import_node_path2.default.resolve(directory, options.stopAt || root);
const limit = options.limit || Number.POSITIVE_INFINITY;
const paths = [
name
].flat();
const runMatcher = /* @__PURE__ */ __name(async (locateOptions) => {
if (typeof name !== "function") {
return locatePath(paths, locateOptions);
}
const foundPath = await name(locateOptions.cwd);
if (typeof foundPath === "string") {
return locatePath([
foundPath
], locateOptions);
}
return foundPath;
}, "runMatcher");
const matches = [];
while (true) {
const foundPath = await runMatcher({
...options,
cwd: directory
});
if (foundPath === findUpStop) {
break;
}
if (foundPath) {
matches.push(import_node_path2.default.resolve(directory, foundPath));
}
if (directory === stopAt || matches.length >= limit) {
break;
}
directory = import_node_path2.default.dirname(directory);
}
return matches;
}
__name(findUpMultiple, "findUpMultiple");
async function findUp(name, options = {}) {
const matches = await findUpMultiple(name, {
...options,
limit: 1
});
return matches[0];
}
__name(findUp, "findUp");
// node_modules/pkg-up/index.js
async function pkgUp({ cwd } = {}) {
return findUp("package.json", {
cwd
});
}
__name(pkgUp, "pkgUp");
// src/util/getTestRunnerConfig.ts
var import_path2 = require("path");
var import_common2 = require("storybook/internal/common");
var testRunnerConfig;
var loaded = false;
var getTestRunnerConfig = /* @__PURE__ */ __name((configDir = process.env.STORYBOOK_CONFIG_DIR ?? ".storybook") => {
if (loaded) {
return testRunnerConfig;
}
testRunnerConfig = (0, import_common2.serverRequire)((0, import_path2.join)((0, import_path2.resolve)(configDir), "test-runner"));
loaded = true;
return testRunnerConfig;
}, "getTestRunnerConfig");
// src/setup-page.ts
var import_promises = require("fs/promises");
var import_node_path3 = __toESM(require("path"));
var defaultPrepare = /* @__PURE__ */ __name(async ({ page, browserContext, testRunnerConfig: testRunnerConfig2 }) => {
const targetURL = process.env.TARGET_URL;
const iframeURL = new URL("iframe.html", targetURL).toString();
if (testRunnerConfig2?.getHttpHeaders) {
const headers = await testRunnerConfig2.getHttpHeaders(iframeURL);
await browserContext.setExtraHTTPHeaders(headers);
}
await page.goto(iframeURL, {
waitUntil: "load"
}).catch((err) => {
if (err.message?.includes("ERR_CONNECTION_REFUSED")) {
const errorMessage = `Could not access the Storybook instance at ${targetURL}. Are you sure it's running?
${err.message}`;
throw new Error(errorMessage);
}
throw err;
});
}, "defaultPrepare");
var setupPage = /* @__PURE__ */ __name(async (page, browserContext) => {
const targetURL = process.env.TARGET_URL;
const failOnConsole = process.env.TEST_CHECK_CONSOLE;
const viewMode = process.env.VIEW_MODE ?? "story";
const renderedEvent = viewMode === "docs" ? "globalThis.__STORYBOOK_MODULE_CORE_EVENTS__.DOCS_RENDERED" : "globalThis.__STORYBOOK_MODULE_CORE_EVENTS__.STORY_FINISHED ?? globalThis.__STORYBOOK_MODULE_CORE_EVENTS__.STORY_RENDERED";
const { packageJson } = await (0, import_read_pkg_up.default)();
const { version: testRunnerVersion } = packageJson;
const referenceURL = process.env.REFERENCE_URL;
const debugPrintLimit = process.env.DEBUG_PRINT_LIMIT ? Number(process.env.DEBUG_PRINT_LIMIT) : 1e3;
if ("TARGET_URL" in process.env && !process.env.TARGET_URL) {
console.warn(`Received TARGET_URL but with a falsy value: ${process.env.TARGET_URL}. Please fix it.`);
}
const testRunnerConfig2 = getTestRunnerConfig() || {};
if (testRunnerConfig2?.prepare) {
await testRunnerConfig2.prepare({
page,
browserContext,
testRunnerConfig: testRunnerConfig2
});
} else {
await defaultPrepare({
page,
browserContext,
testRunnerConfig: testRunnerConfig2
});
}
await page.exposeBinding("logToPage", (_, message) => console.log(message));
await page.exposeBinding("testRunner_errorMessageFormatter", (_, message) => {
if (testRunnerConfig2.errorMessageFormatter) {
return testRunnerConfig2.errorMessageFormatter(message);
}
return message;
});
const finalStorybookUrl = referenceURL ?? targetURL ?? "";
const testRunnerPackageLocation = await pkgUp({
cwd: __dirname
});
if (!testRunnerPackageLocation)
throw new Error("Could not find test-runner package location");
const scriptLocation = import_node_path3.default.join(import_node_path3.default.dirname(testRunnerPackageLocation), "dist", "setup-page-script.mjs");
const content = (await (0, import_promises.readFile)(scriptLocation, "utf-8")).replaceAll("{{storybookUrl}}", finalStorybookUrl).replaceAll("{{failOnConsole}}", failOnConsole ?? "false").replaceAll('"{{renderedEvent}}"', renderedEvent).replaceAll("{{testRunnerVersion}}", testRunnerVersion).replaceAll("{{logLevel}}", testRunnerConfig2.logLevel ?? "info").replaceAll("{{debugPrintLimit}}", debugPrintLimit.toString());
await page.addScriptTag({
content
});
}, "setupPage");
// src/playwright/transformPlaywright.ts
var import_path5 = require("path");
var import_template = __toESM(require("@babel/template"));
var import_preview_api = require("storybook/internal/preview-api");
// node_modules/ts-dedent/esm/index.js
function dedent(templ) {
var values = [];
for (var _i = 1; _i < arguments.length; _i++) {
values[_i - 1] = arguments[_i];
}
var strings = Array.from(typeof templ === "string" ? [
templ
] : templ);
strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, "");
var indentLengths = strings.reduce(function(arr, str) {
var matches = str.match(/\n([\t ]+|(?!\s).)/g);
if (matches) {
return arr.concat(matches.map(function(match) {
var _a, _b;
return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
}));
}
return arr;
}, []);
if (indentLengths.length) {
var pattern_1 = new RegExp("\n[ ]{" + Math.min.apply(Math, indentLengths) + "}", "g");
strings = strings.map(function(str) {
return str.replace(pattern_1, "\n");
});
}
strings[0] = strings[0].replace(/^\r?\n/, "");
var string = strings[0];
values.forEach(function(value, i) {
var endentations = string.match(/(?:^|\n)( *)$/);
var endentation = endentations ? endentations[1] : "";
var indentedValue = value;
if (typeof value === "string" && value.includes("\n")) {
indentedValue = String(value).split("\n").map(function(str, i2) {
return i2 === 0 ? str : "" + endentation + str;
}).join("\n");
}
string += indentedValue + strings[i + 1];
});
return string;
}
__name(dedent, "dedent");
var esm_default = dedent;
// node_modules/commander/esm.mjs
var import_index = __toESM(require_commander(), 1);
var {
program,
createCommand,
createArgument,
createOption,
CommanderError,
InvalidArgumentError,
InvalidOptionArgumentError,
// deprecated old name
Command,
Argument,
Option,
Help
} = import_index.default;
// src/util/getStorybookMain.ts
var import_path3 = require("path");
var import_common3 = require("storybook/internal/common");
var storybookMainConfig = /* @__PURE__ */ new Map();
var getStorybookMain = /* @__PURE__ */ __name((configDir = ".storybook") => {
if (storybookMainConfig.has(configDir)) {
return storybookMainConfig.get(configDir);
} else {
storybookMainConfig.set(configDir, (0, import_common3.serverRequire)((0, import_path3.join)((0, import_path3.resolve)(configDir), "main")));
}
const mainConfig = storybookMainConfig.get(configDir);
if (!mainConfig) {
throw new Error(`Could not load main.js in ${configDir}. Is the "${configDir}" config directory correct? You can change it by using --config-dir <path-to-dir>`);
}
if (!mainConfig.stories || mainConfig.stories.length === 0) {
throw new Error(esm_default`
Could not find stories in main.js in "${configDir}".
If you are using a mono-repository, please run the test-runner only against your sub-package, which contains a .storybook folder with "stories" defined in main.js.
You can change the config directory by using --config-dir <path-to-dir>
`);
}
return mainConfig;
}, "getStorybookMain");
// src/util/getStorybookMetadata.ts
var import_path4 = require("path");
var import_common4 = require("storybook/internal/common");
var getStorybookMetadata = /* @__PURE__ */ __name(() => {
const workingDir = (0, import_common4.getProjectRoot)();
const configDir = process.env.STORYBOOK_CONFIG_DIR ?? ".storybook";
const main = getStorybookMain(configDir);
const normalizedStoriesEntries = (0, import_common4.normalizeStories)(main.stories, {
configDir,
workingDir
}).map((specifier) => ({
...specifier,
importPathMatcher: new RegExp(specifier.importPathMatcher)
}));
const storiesPaths = normalizedStoriesEntries.map((entry) => `${entry.directory}/${entry.files}`).map((dir) => (0, import_path4.join)(workingDir, dir)).join(";");
const lazyCompilation = !!main.core?.builder?.options?.lazyCompilation;
return {
configDir,
workingDir,
storiesPaths,
normalizedStoriesEntries,
lazyCompilation
};
}, "getStorybookMetadata");
// src/csf/transformCsf.ts
var import_csf = require("@storybook/csf");
var import_csf_tools = require("storybook/internal/csf-tools");
var t = __toESM(require("@babel/types"));
var import_generator = __toESM(require("@babel/generator"));
// src/util/getTagOptions.ts
function getTagOptions() {
const config = getTestRunnerConfig();
let tagOptions = {
includeTags: config?.tags?.include || [
"test"
],
excludeTags: config?.tags?.exclude || [],
skipTags: config?.tags?.skip || []
};
if (process.env.STORYBOOK_INCLUDE_TAGS) {
tagOptions.includeTags = process.env.STORYBOOK_INCLUDE_TAGS.split(",").map((s) => s.trim());
}
if (process.env.STORYBOOK_EXCLUDE_TAGS) {
tagOptions.excludeTags = process.env.STORYBOOK_EXCLUDE_TAGS.split(",").map((s) => s.trim());
}
if (process.env.STORYBOOK_SKIP_TAGS) {
tagOptions.skipTags = process.env.STORYBOOK_SKIP_TAGS.split(",").map((s) => s.trim());
}
return tagOptions;
}
__name(getTagOptions, "getTagOptions");
// src/csf/transformCsf.ts
var prefixFunction = /* @__PURE__ */ __name(({ key, testPrefixer: testPrefixer2, title, id }) => {
const name = (0, import_csf.storyNameFromExport)(key);
const context = {
storyExport: t.identifier(key),
name: t.stringLiteral(name),
title: t.stringLiteral(title),
id: t.stringLiteral((0, import_csf.toId)(id ?? title, name))
};
const result = makeArray(testPrefixer2(context));
const stmt = result[1];
return stmt.expression;
}, "prefixFunction");
var makePlayTest = /* @__PURE__ */ __name(({ key, metaOrStoryPlay, title, id, testPrefix, shouldSkip }) => {
return [
t.expressionStatement(t.callExpression(shouldSkip ? t.identifier("it.skip") : t.identifier("it"), [
t.stringLiteral(metaOrStoryPlay ? "play-test" : "smoke-test"),
prefixFunction({
key,
title,
testPrefixer: testPrefix,
id
})
]))
];
}, "makePlayTest");
var makeDescribe = /* @__PURE__ */ __name((key, tests, beforeEachBlock) => {
const blockStatements = beforeEachBlock ? [
beforeEachBlock,
...tests
] : tests;
return t.expressionStatement(t.callExpression(t.identifier("describe"), [
t.stringLiteral(key),
t.arrowFunctionExpression([], t.blockStatement(blockStatements))
]));
}, "makeDescribe");
var makeBeforeEach = /* @__PURE__ */ __name((beforeEachPrefixer) => {
const stmt = beforeEachPrefixer();
return t.expressionStatement(t.callExpression(t.identifier("beforeEach"), [
stmt.expression
]));
}, "makeBeforeEach");
var makeArray = /* @__PURE__ */ __name((templateResult) => Array.isArray(templateResult) ? templateResult : [
templateResult
], "makeArray");
var transformCsf = /* @__PURE__ */ __name((code, { clearBody = false, testPrefixer: testPrefixer2, beforeEachPrefixer, insertTestIfEmpty, makeTitle, previewAnnotations = {
tags: []
} }) => {
const { includeTags, excludeTags, skipTags } = getTagOptions();
const csf = (0, import_csf_tools.loadCsf)(code, {
makeTitle: makeTitle ?? ((userTitle) => userTitle)
});
csf.parse();
const storyExports = Object.keys(csf._stories);
const title = csf.meta?.title;
const storyAnnotations = storyExports.reduce((acc, key) => {
const annotations = csf._storyAnnotations[key];
acc[key] = {};
if (annotations?.play) {
acc[key].play = annotations.play;
}
acc[key].tags = (0, import_csf.combineTags)("test", "dev", ...previewAnnotations.tags, ...csf.meta?.tags || [], ...csf._stories[key].tags || []);
return acc;
}, {});
const allTests = storyExports.filter((key) => {
const isIncluded = includeTags.length === 0 || includeTags.some((tag) => storyAnnotations[key].tags?.includes(tag));
const isNotExcluded = excludeTags.every((tag) => !storyAnnotations[key].tags?.includes(tag));
return isIncluded && isNotExcluded;
}).map((key) => {
let tests = [];
const shouldSkip = skipTags.some((tag) => storyAnnotations[key].tags?.includes(tag));
if (title) {
tests = [
...tests,
...makePlayTest({
key,
title,
id: csf.meta.id,
metaOrStoryPlay: !!storyAnnotations[key]?.play,
testPrefix: testPrefixer2,
shouldSkip
})
];
}
if (tests.length) {
return makeDescribe(key, tests);
}
}).filter(Boolean);
let result = "";
if (!clearBody)
result = `${result}${code}
`;
if (allTests.length) {
const describe = makeDescribe(csf.meta?.title, allTests, beforeEachPrefixer ? makeBeforeEach(beforeEachPrefixer) : void 0);
const { code: describeCode } = (0, import_generator.default)(describe, {});
result = esm_default`
${result}
if (!require.main) {
${describeCode}
}
`;
} else if (insertTestIfEmpty) {
result = `describe.skip('${csf.meta?.title}', () => { it('no-op', () => {}) });`;
}
return result;
}, "transformCsf");
// src/playwright/transformPlaywright.ts
var coverageErrorMessage = esm_default`
[Test runner] An error occurred when evaluating code coverage:
The code in this story is not instrumented, which means the coverage setup is likely not correct.
More info: https://github.com/storybookjs/test-runner#setting-up-code-coverage
`;
var testPrefixer = /* @__PURE__ */ __name((context) => {
return (0, import_template.default)(`
console.log({ id: %%id%%, title: %%title%%, name: %%name%%, storyExport: %%storyExport%% });
async () => {
const testFn = async() => {
const context = { id: %%id%%, title: %%title%%, name: %%name%% };
if(globalThis.__sbPreVisit) {
await globalThis.__sbPreVisit(page, context);
}
let result;
try {
result = await page.evaluate(({ id, hasPlayFn }) => __test(id, hasPlayFn), {
id: %%id%%,
});
} catch(err) {
if(err.toString().includes('Execution context was destroyed')) {
// Retry the test, possible Vite dep optimization flake
throw err;
} else {
if(globalThis.__sbPostVisit) {
await globalThis.__sbPostVisit(page, {...context, hasFailure: true });
}
throw err;
}
}
if(globalThis.__sbPostVisit) {
await globalThis.__sbPostVisit(page, context);
}
if(globalThis.__sbCollectCoverage) {
const isCoverageSetupCorrectly = await page.evaluate(() => '__coverage__' in window);
if (!isCoverageSetupCorrectly) {
throw new Error(\`${coverageErrorMessage}\`);
}
await jestPlaywright.saveCoverage(page);
}
return result;
};
try {
await testFn();
} catch(err) {
if(err.toString().includes('Execution context was destroyed')) {
console.log(\`An error occurred in the following story, most likely because of a navigation: "\${%%title%%}/\${%%name%%}". Retrying...\`);
await jestPlaywright.resetPage();
await globalThis.__sbSetupPage(globalThis.page, globalThis.context);
await testFn();
} else {
throw err;
}
}
}
`, {
plugins: [
"jsx"
]
})({
...context
});
}, "testPrefixer");
var makeTitleFactory = /* @__PURE__ */ __name((filename) => {
const { workingDir, normalizedStoriesEntries } = getStorybookMetadata();
const filePath = `./${(0, import_path5.relative)(workingDir, filename)}`;
return (userTitle) => (0, import_preview_api.userOrAutoTitle)(filePath, normalizedStoriesEntries, userTitle);
}, "makeTitleFactory");
var transformPlaywright = /* @__PURE__ */ __name((src, filename) => {
const tags = process.env.STORYBOOK_PREVIEW_TAGS?.split(",") ?? [];
const transformOptions = {
testPrefixer,
insertTestIfEmpty: true,
clearBody: true,
makeTitle: makeTitleFactory(filename),
previewAnnotations: {
tags
}
};
const result = transformCsf(src, transformOptions);
return result;
}, "transformPlaywright");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
getJestConfig,
getStoryContext,
getTestRunnerConfig,
setPostVisit,
setPreVisit,
setupPage,
testPrefixer,
transformPlaywright,
waitForPageReady
});