blob: 11796497f4fc7ff54bf5350156241a0cb8ffb1f4 [file] [edit]
import require$$0$2, { format } from 'util';
import { resolve, normalize } from 'path';
import { readFileSync } from 'fs';
import require$$5, { createRequire } from 'node:module';
import path from 'node:path';
import process$1 from 'node:process';
import require$$0$1, { fileURLToPath } from 'node:url';
import fs from 'node:fs';
import require$$0 from 'url';
import { promisify } from 'node:util';
import { execFile } from 'node:child_process';
function camelCase$1(str) {
const isCamelCase = str !== str.toLowerCase() && str !== str.toUpperCase();
if (!isCamelCase) {
str = str.toLowerCase();
}
if (str.indexOf('-') === -1 && str.indexOf('_') === -1) {
return str;
}
else {
let camelcase = '';
let nextChrUpper = false;
const leadingHyphens = str.match(/^-+/);
for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str.length; i++) {
let chr = str.charAt(i);
if (nextChrUpper) {
nextChrUpper = false;
chr = chr.toUpperCase();
}
if (i !== 0 && (chr === '-' || chr === '_')) {
nextChrUpper = true;
}
else if (chr !== '-' && chr !== '_') {
camelcase += chr;
}
}
return camelcase;
}
}
function decamelize$1(str, joinString) {
const lowercase = str.toLowerCase();
joinString = joinString || '-';
let notCamelcase = '';
for (let i = 0; i < str.length; i++) {
const chrLower = lowercase.charAt(i);
const chrString = str.charAt(i);
if (chrLower !== chrString && i > 0) {
notCamelcase += `${joinString}${lowercase.charAt(i)}`;
}
else {
notCamelcase += chrString;
}
}
return notCamelcase;
}
function looksLikeNumber(x) {
if (x === null || x === undefined)
return false;
if (typeof x === 'number')
return true;
if (/^0x[0-9a-f]+$/i.test(x))
return true;
if (/^0[^.]/.test(x))
return false;
return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
}
function tokenizeArgString(argString) {
if (Array.isArray(argString)) {
return argString.map(e => typeof e !== 'string' ? e + '' : e);
}
argString = argString.trim();
let i = 0;
let prevC = null;
let c = null;
let opening = null;
const args = [];
for (let ii = 0; ii < argString.length; ii++) {
prevC = c;
c = argString.charAt(ii);
if (c === ' ' && !opening) {
if (!(prevC === ' ')) {
i++;
}
continue;
}
if (c === opening) {
opening = null;
}
else if ((c === "'" || c === '"') && !opening) {
opening = c;
}
if (!args[i])
args[i] = '';
args[i] += c;
}
return args;
}
var DefaultValuesForTypeKey;
(function (DefaultValuesForTypeKey) {
DefaultValuesForTypeKey["BOOLEAN"] = "boolean";
DefaultValuesForTypeKey["STRING"] = "string";
DefaultValuesForTypeKey["NUMBER"] = "number";
DefaultValuesForTypeKey["ARRAY"] = "array";
})(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {}));
let mixin;
class YargsParser {
constructor(_mixin) {
mixin = _mixin;
}
parse(argsInput, options) {
const opts = Object.assign({
alias: undefined,
array: undefined,
boolean: undefined,
config: undefined,
configObjects: undefined,
configuration: undefined,
coerce: undefined,
count: undefined,
default: undefined,
envPrefix: undefined,
narg: undefined,
normalize: undefined,
string: undefined,
number: undefined,
__: undefined,
key: undefined
}, options);
const args = tokenizeArgString(argsInput);
const inputIsString = typeof argsInput === 'string';
const aliases = combineAliases(Object.assign(Object.create(null), opts.alias));
const configuration = Object.assign({
'boolean-negation': true,
'camel-case-expansion': true,
'combine-arrays': false,
'dot-notation': true,
'duplicate-arguments-array': true,
'flatten-duplicate-arrays': true,
'greedy-arrays': true,
'halt-at-non-option': false,
'nargs-eats-options': false,
'negation-prefix': 'no-',
'parse-numbers': true,
'parse-positional-numbers': true,
'populate--': false,
'set-placeholder-key': false,
'short-option-groups': true,
'strip-aliased': false,
'strip-dashed': false,
'unknown-options-as-args': false
}, opts.configuration);
const defaults = Object.assign(Object.create(null), opts.default);
const configObjects = opts.configObjects || [];
const envPrefix = opts.envPrefix;
const notFlagsOption = configuration['populate--'];
const notFlagsArgv = notFlagsOption ? '--' : '_';
const newAliases = Object.create(null);
const defaulted = Object.create(null);
const __ = opts.__ || mixin.format;
const flags = {
aliases: Object.create(null),
arrays: Object.create(null),
bools: Object.create(null),
strings: Object.create(null),
numbers: Object.create(null),
counts: Object.create(null),
normalize: Object.create(null),
configs: Object.create(null),
nargs: Object.create(null),
coercions: Object.create(null),
keys: []
};
const negative = /^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/;
const negatedBoolean = new RegExp('^--' + configuration['negation-prefix'] + '(.+)');
[].concat(opts.array || []).filter(Boolean).forEach(function (opt) {
const key = typeof opt === 'object' ? opt.key : opt;
const assignment = Object.keys(opt).map(function (key) {
const arrayFlagKeys = {
boolean: 'bools',
string: 'strings',
number: 'numbers'
};
return arrayFlagKeys[key];
}).filter(Boolean).pop();
if (assignment) {
flags[assignment][key] = true;
}
flags.arrays[key] = true;
flags.keys.push(key);
});
[].concat(opts.boolean || []).filter(Boolean).forEach(function (key) {
flags.bools[key] = true;
flags.keys.push(key);
});
[].concat(opts.string || []).filter(Boolean).forEach(function (key) {
flags.strings[key] = true;
flags.keys.push(key);
});
[].concat(opts.number || []).filter(Boolean).forEach(function (key) {
flags.numbers[key] = true;
flags.keys.push(key);
});
[].concat(opts.count || []).filter(Boolean).forEach(function (key) {
flags.counts[key] = true;
flags.keys.push(key);
});
[].concat(opts.normalize || []).filter(Boolean).forEach(function (key) {
flags.normalize[key] = true;
flags.keys.push(key);
});
if (typeof opts.narg === 'object') {
Object.entries(opts.narg).forEach(([key, value]) => {
if (typeof value === 'number') {
flags.nargs[key] = value;
flags.keys.push(key);
}
});
}
if (typeof opts.coerce === 'object') {
Object.entries(opts.coerce).forEach(([key, value]) => {
if (typeof value === 'function') {
flags.coercions[key] = value;
flags.keys.push(key);
}
});
}
if (typeof opts.config !== 'undefined') {
if (Array.isArray(opts.config) || typeof opts.config === 'string') {
[].concat(opts.config).filter(Boolean).forEach(function (key) {
flags.configs[key] = true;
});
}
else if (typeof opts.config === 'object') {
Object.entries(opts.config).forEach(([key, value]) => {
if (typeof value === 'boolean' || typeof value === 'function') {
flags.configs[key] = value;
}
});
}
}
extendAliases(opts.key, aliases, opts.default, flags.arrays);
Object.keys(defaults).forEach(function (key) {
(flags.aliases[key] || []).forEach(function (alias) {
defaults[alias] = defaults[key];
});
});
let error = null;
checkConfiguration();
let notFlags = [];
const argv = Object.assign(Object.create(null), { _: [] });
const argvReturn = {};
for (let i = 0; i < args.length; i++) {
const arg = args[i];
const truncatedArg = arg.replace(/^-{3,}/, '---');
let broken;
let key;
let letters;
let m;
let next;
let value;
if (arg !== '--' && /^-/.test(arg) && isUnknownOptionAsArg(arg)) {
pushPositional(arg);
}
else if (truncatedArg.match(/^---+(=|$)/)) {
pushPositional(arg);
continue;
}
else if (arg.match(/^--.+=/) || (!configuration['short-option-groups'] && arg.match(/^-.+=/))) {
m = arg.match(/^--?([^=]+)=([\s\S]*)$/);
if (m !== null && Array.isArray(m) && m.length >= 3) {
if (checkAllAliases(m[1], flags.arrays)) {
i = eatArray(i, m[1], args, m[2]);
}
else if (checkAllAliases(m[1], flags.nargs) !== false) {
i = eatNargs(i, m[1], args, m[2]);
}
else {
setArg(m[1], m[2], true);
}
}
}
else if (arg.match(negatedBoolean) && configuration['boolean-negation']) {
m = arg.match(negatedBoolean);
if (m !== null && Array.isArray(m) && m.length >= 2) {
key = m[1];
setArg(key, checkAllAliases(key, flags.arrays) ? [false] : false);
}
}
else if (arg.match(/^--.+/) || (!configuration['short-option-groups'] && arg.match(/^-[^-]+/))) {
m = arg.match(/^--?(.+)/);
if (m !== null && Array.isArray(m) && m.length >= 2) {
key = m[1];
if (checkAllAliases(key, flags.arrays)) {
i = eatArray(i, key, args);
}
else if (checkAllAliases(key, flags.nargs) !== false) {
i = eatNargs(i, key, args);
}
else {
next = args[i + 1];
if (next !== undefined && (!next.match(/^-/) ||
next.match(negative)) &&
!checkAllAliases(key, flags.bools) &&
!checkAllAliases(key, flags.counts)) {
setArg(key, next);
i++;
}
else if (/^(true|false)$/.test(next)) {
setArg(key, next);
i++;
}
else {
setArg(key, defaultValue(key));
}
}
}
}
else if (arg.match(/^-.\..+=/)) {
m = arg.match(/^-([^=]+)=([\s\S]*)$/);
if (m !== null && Array.isArray(m) && m.length >= 3) {
setArg(m[1], m[2]);
}
}
else if (arg.match(/^-.\..+/) && !arg.match(negative)) {
next = args[i + 1];
m = arg.match(/^-(.\..+)/);
if (m !== null && Array.isArray(m) && m.length >= 2) {
key = m[1];
if (next !== undefined && !next.match(/^-/) &&
!checkAllAliases(key, flags.bools) &&
!checkAllAliases(key, flags.counts)) {
setArg(key, next);
i++;
}
else {
setArg(key, defaultValue(key));
}
}
}
else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {
letters = arg.slice(1, -1).split('');
broken = false;
for (let j = 0; j < letters.length; j++) {
next = arg.slice(j + 2);
if (letters[j + 1] && letters[j + 1] === '=') {
value = arg.slice(j + 3);
key = letters[j];
if (checkAllAliases(key, flags.arrays)) {
i = eatArray(i, key, args, value);
}
else if (checkAllAliases(key, flags.nargs) !== false) {
i = eatNargs(i, key, args, value);
}
else {
setArg(key, value);
}
broken = true;
break;
}
if (next === '-') {
setArg(letters[j], next);
continue;
}
if (/[A-Za-z]/.test(letters[j]) &&
/^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) &&
checkAllAliases(next, flags.bools) === false) {
setArg(letters[j], next);
broken = true;
break;
}
if (letters[j + 1] && letters[j + 1].match(/\W/)) {
setArg(letters[j], next);
broken = true;
break;
}
else {
setArg(letters[j], defaultValue(letters[j]));
}
}
key = arg.slice(-1)[0];
if (!broken && key !== '-') {
if (checkAllAliases(key, flags.arrays)) {
i = eatArray(i, key, args);
}
else if (checkAllAliases(key, flags.nargs) !== false) {
i = eatNargs(i, key, args);
}
else {
next = args[i + 1];
if (next !== undefined && (!/^(-|--)[^-]/.test(next) ||
next.match(negative)) &&
!checkAllAliases(key, flags.bools) &&
!checkAllAliases(key, flags.counts)) {
setArg(key, next);
i++;
}
else if (/^(true|false)$/.test(next)) {
setArg(key, next);
i++;
}
else {
setArg(key, defaultValue(key));
}
}
}
}
else if (arg.match(/^-[0-9]$/) &&
arg.match(negative) &&
checkAllAliases(arg.slice(1), flags.bools)) {
key = arg.slice(1);
setArg(key, defaultValue(key));
}
else if (arg === '--') {
notFlags = args.slice(i + 1);
break;
}
else if (configuration['halt-at-non-option']) {
notFlags = args.slice(i);
break;
}
else {
pushPositional(arg);
}
}
applyEnvVars(argv, true);
applyEnvVars(argv, false);
setConfig(argv);
setConfigObjects();
applyDefaultsAndAliases(argv, flags.aliases, defaults, true);
applyCoercions(argv);
if (configuration['set-placeholder-key'])
setPlaceholderKeys(argv);
Object.keys(flags.counts).forEach(function (key) {
if (!hasKey(argv, key.split('.')))
setArg(key, 0);
});
if (notFlagsOption && notFlags.length)
argv[notFlagsArgv] = [];
notFlags.forEach(function (key) {
argv[notFlagsArgv].push(key);
});
if (configuration['camel-case-expansion'] && configuration['strip-dashed']) {
Object.keys(argv).filter(key => key !== '--' && key.includes('-')).forEach(key => {
delete argv[key];
});
}
if (configuration['strip-aliased']) {
[].concat(...Object.keys(aliases).map(k => aliases[k])).forEach(alias => {
if (configuration['camel-case-expansion'] && alias.includes('-')) {
delete argv[alias.split('.').map(prop => camelCase$1(prop)).join('.')];
}
delete argv[alias];
});
}
function pushPositional(arg) {
const maybeCoercedNumber = maybeCoerceNumber('_', arg);
if (typeof maybeCoercedNumber === 'string' || typeof maybeCoercedNumber === 'number') {
argv._.push(maybeCoercedNumber);
}
}
function eatNargs(i, key, args, argAfterEqualSign) {
let ii;
let toEat = checkAllAliases(key, flags.nargs);
toEat = typeof toEat !== 'number' || isNaN(toEat) ? 1 : toEat;
if (toEat === 0) {
if (!isUndefined(argAfterEqualSign)) {
error = Error(__('Argument unexpected for: %s', key));
}
setArg(key, defaultValue(key));
return i;
}
let available = isUndefined(argAfterEqualSign) ? 0 : 1;
if (configuration['nargs-eats-options']) {
if (args.length - (i + 1) + available < toEat) {
error = Error(__('Not enough arguments following: %s', key));
}
available = toEat;
}
else {
for (ii = i + 1; ii < args.length; ii++) {
if (!args[ii].match(/^-[^0-9]/) || args[ii].match(negative) || isUnknownOptionAsArg(args[ii]))
available++;
else
break;
}
if (available < toEat)
error = Error(__('Not enough arguments following: %s', key));
}
let consumed = Math.min(available, toEat);
if (!isUndefined(argAfterEqualSign) && consumed > 0) {
setArg(key, argAfterEqualSign);
consumed--;
}
for (ii = i + 1; ii < (consumed + i + 1); ii++) {
setArg(key, args[ii]);
}
return (i + consumed);
}
function eatArray(i, key, args, argAfterEqualSign) {
let argsToSet = [];
let next = argAfterEqualSign || args[i + 1];
const nargsCount = checkAllAliases(key, flags.nargs);
if (checkAllAliases(key, flags.bools) && !(/^(true|false)$/.test(next))) {
argsToSet.push(true);
}
else if (isUndefined(next) ||
(isUndefined(argAfterEqualSign) && /^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next))) {
if (defaults[key] !== undefined) {
const defVal = defaults[key];
argsToSet = Array.isArray(defVal) ? defVal : [defVal];
}
}
else {
if (!isUndefined(argAfterEqualSign)) {
argsToSet.push(processValue(key, argAfterEqualSign, true));
}
for (let ii = i + 1; ii < args.length; ii++) {
if ((!configuration['greedy-arrays'] && argsToSet.length > 0) ||
(nargsCount && typeof nargsCount === 'number' && argsToSet.length >= nargsCount))
break;
next = args[ii];
if (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next))
break;
i = ii;
argsToSet.push(processValue(key, next, inputIsString));
}
}
if (typeof nargsCount === 'number' && ((nargsCount && argsToSet.length < nargsCount) ||
(isNaN(nargsCount) && argsToSet.length === 0))) {
error = Error(__('Not enough arguments following: %s', key));
}
setArg(key, argsToSet);
return i;
}
function setArg(key, val, shouldStripQuotes = inputIsString) {
if (/-/.test(key) && configuration['camel-case-expansion']) {
const alias = key.split('.').map(function (prop) {
return camelCase$1(prop);
}).join('.');
addNewAlias(key, alias);
}
const value = processValue(key, val, shouldStripQuotes);
const splitKey = key.split('.');
setKey(argv, splitKey, value);
if (flags.aliases[key]) {
flags.aliases[key].forEach(function (x) {
const keyProperties = x.split('.');
setKey(argv, keyProperties, value);
});
}
if (splitKey.length > 1 && configuration['dot-notation']) {
(flags.aliases[splitKey[0]] || []).forEach(function (x) {
let keyProperties = x.split('.');
const a = [].concat(splitKey);
a.shift();
keyProperties = keyProperties.concat(a);
if (!(flags.aliases[key] || []).includes(keyProperties.join('.'))) {
setKey(argv, keyProperties, value);
}
});
}
if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) {
const keys = [key].concat(flags.aliases[key] || []);
keys.forEach(function (key) {
Object.defineProperty(argvReturn, key, {
enumerable: true,
get() {
return val;
},
set(value) {
val = typeof value === 'string' ? mixin.normalize(value) : value;
}
});
});
}
}
function addNewAlias(key, alias) {
if (!(flags.aliases[key] && flags.aliases[key].length)) {
flags.aliases[key] = [alias];
newAliases[alias] = true;
}
if (!(flags.aliases[alias] && flags.aliases[alias].length)) {
addNewAlias(alias, key);
}
}
function processValue(key, val, shouldStripQuotes) {
if (shouldStripQuotes) {
val = stripQuotes(val);
}
if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
if (typeof val === 'string')
val = val === 'true';
}
let value = Array.isArray(val)
? val.map(function (v) { return maybeCoerceNumber(key, v); })
: maybeCoerceNumber(key, val);
if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === 'boolean')) {
value = increment();
}
if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) {
if (Array.isArray(val))
value = val.map((val) => { return mixin.normalize(val); });
else
value = mixin.normalize(val);
}
return value;
}
function maybeCoerceNumber(key, value) {
if (!configuration['parse-positional-numbers'] && key === '_')
return value;
if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !Array.isArray(value)) {
const shouldCoerceNumber = looksLikeNumber(value) && configuration['parse-numbers'] && (Number.isSafeInteger(Math.floor(parseFloat(`${value}`))));
if (shouldCoerceNumber || (!isUndefined(value) && checkAllAliases(key, flags.numbers))) {
value = Number(value);
}
}
return value;
}
function setConfig(argv) {
const configLookup = Object.create(null);
applyDefaultsAndAliases(configLookup, flags.aliases, defaults);
Object.keys(flags.configs).forEach(function (configKey) {
const configPath = argv[configKey] || configLookup[configKey];
if (configPath) {
try {
let config = null;
const resolvedConfigPath = mixin.resolve(mixin.cwd(), configPath);
const resolveConfig = flags.configs[configKey];
if (typeof resolveConfig === 'function') {
try {
config = resolveConfig(resolvedConfigPath);
}
catch (e) {
config = e;
}
if (config instanceof Error) {
error = config;
return;
}
}
else {
config = mixin.require(resolvedConfigPath);
}
setConfigObject(config);
}
catch (ex) {
if (ex.name === 'PermissionDenied')
error = ex;
else if (argv[configKey])
error = Error(__('Invalid JSON config file: %s', configPath));
}
}
});
}
function setConfigObject(config, prev) {
Object.keys(config).forEach(function (key) {
const value = config[key];
const fullKey = prev ? prev + '.' + key : key;
if (typeof value === 'object' && value !== null && !Array.isArray(value) && configuration['dot-notation']) {
setConfigObject(value, fullKey);
}
else {
if (!hasKey(argv, fullKey.split('.')) || (checkAllAliases(fullKey, flags.arrays) && configuration['combine-arrays'])) {
setArg(fullKey, value);
}
}
});
}
function setConfigObjects() {
if (typeof configObjects !== 'undefined') {
configObjects.forEach(function (configObject) {
setConfigObject(configObject);
});
}
}
function applyEnvVars(argv, configOnly) {
if (typeof envPrefix === 'undefined')
return;
const prefix = typeof envPrefix === 'string' ? envPrefix : '';
const env = mixin.env();
Object.keys(env).forEach(function (envVar) {
if (prefix === '' || envVar.lastIndexOf(prefix, 0) === 0) {
const keys = envVar.split('__').map(function (key, i) {
if (i === 0) {
key = key.substring(prefix.length);
}
return camelCase$1(key);
});
if (((configOnly && flags.configs[keys.join('.')]) || !configOnly) && !hasKey(argv, keys)) {
setArg(keys.join('.'), env[envVar]);
}
}
});
}
function applyCoercions(argv) {
let coerce;
const applied = new Set();
Object.keys(argv).forEach(function (key) {
if (!applied.has(key)) {
coerce = checkAllAliases(key, flags.coercions);
if (typeof coerce === 'function') {
try {
const value = maybeCoerceNumber(key, coerce(argv[key]));
([].concat(flags.aliases[key] || [], key)).forEach(ali => {
applied.add(ali);
argv[ali] = value;
});
}
catch (err) {
error = err;
}
}
}
});
}
function setPlaceholderKeys(argv) {
flags.keys.forEach((key) => {
if (~key.indexOf('.'))
return;
if (typeof argv[key] === 'undefined')
argv[key] = undefined;
});
return argv;
}
function applyDefaultsAndAliases(obj, aliases, defaults, canLog = false) {
Object.keys(defaults).forEach(function (key) {
if (!hasKey(obj, key.split('.'))) {
setKey(obj, key.split('.'), defaults[key]);
if (canLog)
defaulted[key] = true;
(aliases[key] || []).forEach(function (x) {
if (hasKey(obj, x.split('.')))
return;
setKey(obj, x.split('.'), defaults[key]);
});
}
});
}
function hasKey(obj, keys) {
let o = obj;
if (!configuration['dot-notation'])
keys = [keys.join('.')];
keys.slice(0, -1).forEach(function (key) {
o = (o[key] || {});
});
const key = keys[keys.length - 1];
if (typeof o !== 'object')
return false;
else
return key in o;
}
function setKey(obj, keys, value) {
let o = obj;
if (!configuration['dot-notation'])
keys = [keys.join('.')];
keys.slice(0, -1).forEach(function (key) {
key = sanitizeKey(key);
if (typeof o === 'object' && o[key] === undefined) {
o[key] = {};
}
if (typeof o[key] !== 'object' || Array.isArray(o[key])) {
if (Array.isArray(o[key])) {
o[key].push({});
}
else {
o[key] = [o[key], {}];
}
o = o[key][o[key].length - 1];
}
else {
o = o[key];
}
});
const key = sanitizeKey(keys[keys.length - 1]);
const isTypeArray = checkAllAliases(keys.join('.'), flags.arrays);
const isValueArray = Array.isArray(value);
let duplicate = configuration['duplicate-arguments-array'];
if (!duplicate && checkAllAliases(key, flags.nargs)) {
duplicate = true;
if ((!isUndefined(o[key]) && flags.nargs[key] === 1) || (Array.isArray(o[key]) && o[key].length === flags.nargs[key])) {
o[key] = undefined;
}
}
if (value === increment()) {
o[key] = increment(o[key]);
}
else if (Array.isArray(o[key])) {
if (duplicate && isTypeArray && isValueArray) {
o[key] = configuration['flatten-duplicate-arrays'] ? o[key].concat(value) : (Array.isArray(o[key][0]) ? o[key] : [o[key]]).concat([value]);
}
else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) {
o[key] = value;
}
else {
o[key] = o[key].concat([value]);
}
}
else if (o[key] === undefined && isTypeArray) {
o[key] = isValueArray ? value : [value];
}
else if (duplicate && !(o[key] === undefined ||
checkAllAliases(key, flags.counts) ||
checkAllAliases(key, flags.bools))) {
o[key] = [o[key], value];
}
else {
o[key] = value;
}
}
function extendAliases(...args) {
args.forEach(function (obj) {
Object.keys(obj || {}).forEach(function (key) {
if (flags.aliases[key])
return;
flags.aliases[key] = [].concat(aliases[key] || []);
flags.aliases[key].concat(key).forEach(function (x) {
if (/-/.test(x) && configuration['camel-case-expansion']) {
const c = camelCase$1(x);
if (c !== key && flags.aliases[key].indexOf(c) === -1) {
flags.aliases[key].push(c);
newAliases[c] = true;
}
}
});
flags.aliases[key].concat(key).forEach(function (x) {
if (x.length > 1 && /[A-Z]/.test(x) && configuration['camel-case-expansion']) {
const c = decamelize$1(x, '-');
if (c !== key && flags.aliases[key].indexOf(c) === -1) {
flags.aliases[key].push(c);
newAliases[c] = true;
}
}
});
flags.aliases[key].forEach(function (x) {
flags.aliases[x] = [key].concat(flags.aliases[key].filter(function (y) {
return x !== y;
}));
});
});
});
}
function checkAllAliases(key, flag) {
const toCheck = [].concat(flags.aliases[key] || [], key);
const keys = Object.keys(flag);
const setAlias = toCheck.find(key => keys.includes(key));
return setAlias ? flag[setAlias] : false;
}
function hasAnyFlag(key) {
const flagsKeys = Object.keys(flags);
const toCheck = [].concat(flagsKeys.map(k => flags[k]));
return toCheck.some(function (flag) {
return Array.isArray(flag) ? flag.includes(key) : flag[key];
});
}
function hasFlagsMatching(arg, ...patterns) {
const toCheck = [].concat(...patterns);
return toCheck.some(function (pattern) {
const match = arg.match(pattern);
return match && hasAnyFlag(match[1]);
});
}
function hasAllShortFlags(arg) {
if (arg.match(negative) || !arg.match(/^-[^-]+/)) {
return false;
}
let hasAllFlags = true;
let next;
const letters = arg.slice(1).split('');
for (let j = 0; j < letters.length; j++) {
next = arg.slice(j + 2);
if (!hasAnyFlag(letters[j])) {
hasAllFlags = false;
break;
}
if ((letters[j + 1] && letters[j + 1] === '=') ||
next === '-' ||
(/[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) ||
(letters[j + 1] && letters[j + 1].match(/\W/))) {
break;
}
}
return hasAllFlags;
}
function isUnknownOptionAsArg(arg) {
return configuration['unknown-options-as-args'] && isUnknownOption(arg);
}
function isUnknownOption(arg) {
arg = arg.replace(/^-{3,}/, '--');
if (arg.match(negative)) {
return false;
}
if (hasAllShortFlags(arg)) {
return false;
}
const flagWithEquals = /^-+([^=]+?)=[\s\S]*$/;
const normalFlag = /^-+([^=]+?)$/;
const flagEndingInHyphen = /^-+([^=]+?)-$/;
const flagEndingInDigits = /^-+([^=]+?\d+)$/;
const flagEndingInNonWordCharacters = /^-+([^=]+?)\W+.*$/;
return !hasFlagsMatching(arg, flagWithEquals, negatedBoolean, normalFlag, flagEndingInHyphen, flagEndingInDigits, flagEndingInNonWordCharacters);
}
function defaultValue(key) {
if (!checkAllAliases(key, flags.bools) &&
!checkAllAliases(key, flags.counts) &&
`${key}` in defaults) {
return defaults[key];
}
else {
return defaultForType(guessType(key));
}
}
function defaultForType(type) {
const def = {
[DefaultValuesForTypeKey.BOOLEAN]: true,
[DefaultValuesForTypeKey.STRING]: '',
[DefaultValuesForTypeKey.NUMBER]: undefined,
[DefaultValuesForTypeKey.ARRAY]: []
};
return def[type];
}
function guessType(key) {
let type = DefaultValuesForTypeKey.BOOLEAN;
if (checkAllAliases(key, flags.strings))
type = DefaultValuesForTypeKey.STRING;
else if (checkAllAliases(key, flags.numbers))
type = DefaultValuesForTypeKey.NUMBER;
else if (checkAllAliases(key, flags.bools))
type = DefaultValuesForTypeKey.BOOLEAN;
else if (checkAllAliases(key, flags.arrays))
type = DefaultValuesForTypeKey.ARRAY;
return type;
}
function isUndefined(num) {
return num === undefined;
}
function checkConfiguration() {
Object.keys(flags.counts).find(key => {
if (checkAllAliases(key, flags.arrays)) {
error = Error(__('Invalid configuration: %s, opts.count excludes opts.array.', key));
return true;
}
else if (checkAllAliases(key, flags.nargs)) {
error = Error(__('Invalid configuration: %s, opts.count excludes opts.narg.', key));
return true;
}
return false;
});
}
return {
aliases: Object.assign({}, flags.aliases),
argv: Object.assign(argvReturn, argv),
configuration: configuration,
defaulted: Object.assign({}, defaulted),
error: error,
newAliases: Object.assign({}, newAliases)
};
}
}
function combineAliases(aliases) {
const aliasArrays = [];
const combined = Object.create(null);
let change = true;
Object.keys(aliases).forEach(function (key) {
aliasArrays.push([].concat(aliases[key], key));
});
while (change) {
change = false;
for (let i = 0; i < aliasArrays.length; i++) {
for (let ii = i + 1; ii < aliasArrays.length; ii++) {
const intersect = aliasArrays[i].filter(function (v) {
return aliasArrays[ii].indexOf(v) !== -1;
});
if (intersect.length) {
aliasArrays[i] = aliasArrays[i].concat(aliasArrays[ii]);
aliasArrays.splice(ii, 1);
change = true;
break;
}
}
}
}
aliasArrays.forEach(function (aliasArray) {
aliasArray = aliasArray.filter(function (v, i, self) {
return self.indexOf(v) === i;
});
const lastAlias = aliasArray.pop();
if (lastAlias !== undefined && typeof lastAlias === 'string') {
combined[lastAlias] = aliasArray;
}
});
return combined;
}
function increment(orig) {
return orig !== undefined ? orig + 1 : 1;
}
function sanitizeKey(key) {
if (key === '__proto__')
return '___proto___';
return key;
}
function stripQuotes(val) {
return (typeof val === 'string' &&
(val[0] === "'" || val[0] === '"') &&
val[val.length - 1] === val[0])
? val.substring(1, val.length - 1)
: val;
}
var _a, _b, _c;
const minNodeVersion = (process && process.env && process.env.YARGS_MIN_NODE_VERSION)
? Number(process.env.YARGS_MIN_NODE_VERSION)
: 20;
const nodeVersion = (_b = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) !== null && _b !== void 0 ? _b : (_c = process === null || process === void 0 ? void 0 : process.version) === null || _c === void 0 ? void 0 : _c.slice(1);
if (nodeVersion) {
const major = Number(nodeVersion.match(/^([^.]+)/)[1]);
if (major < minNodeVersion) {
throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
}
}
const env = process ? process.env : {};
const require$1 = createRequire ? createRequire(import.meta.url) : undefined;
const parser = new YargsParser({
cwd: process.cwd,
env: () => {
return env;
},
format,
normalize,
resolve,
require: (path) => {
if (typeof require$1 !== 'undefined') {
return require$1(path);
}
else if (path.match(/\.json$/)) {
return JSON.parse(readFileSync(path, 'utf8'));
}
else {
throw Error('only .json config files are supported in ESM');
}
}
});
const yargsParser = function Parser(args, opts) {
const result = parser.parse(args.slice(), opts);
return result.argv;
};
yargsParser.detailed = function (args, opts) {
return parser.parse(args.slice(), opts);
};
yargsParser.camelCase = camelCase$1;
yargsParser.decamelize = decamelize$1;
yargsParser.looksLikeNumber = looksLikeNumber;
const isObject$2 = value => typeof value === 'object' && value !== null;
const isObjectCustom = value => {
if (!isObject$2(value)) {
return false;
}
if (
value instanceof RegExp
|| value instanceof Error
|| value instanceof Date
|| value instanceof Map
|| value instanceof Set
|| value instanceof WeakMap
|| value instanceof WeakSet
|| value instanceof Promise
|| value instanceof ArrayBuffer
|| value instanceof DataView
|| ArrayBuffer.isView(value)
|| (globalThis.Blob && value instanceof globalThis.Blob)
) {
return false;
}
if (typeof value.$$typeof === 'symbol' || typeof value.asymmetricMatch === 'function') {
return false;
}
return true;
};
const mapObjectSkip = Symbol('mapObjectSkip');
const getEnumerableKeys = (object, includeSymbols) => {
if (includeSymbols) {
const stringKeys = Object.keys(object);
const symbolKeys = Object.getOwnPropertySymbols(object).filter(symbol => Object.getOwnPropertyDescriptor(object, symbol)?.enumerable);
return [...stringKeys, ...symbolKeys];
}
return Object.keys(object);
};
const _mapObject = (object, mapper, options, isSeen = new WeakMap()) => {
const {
target = {},
...processOptions
} = {
deep: false,
includeSymbols: false,
...options,
};
if (isSeen.has(object)) {
return isSeen.get(object);
}
isSeen.set(object, target);
const mapArray = array => array.map(element => isObjectCustom(element) ? _mapObject(element, mapper, processOptions, isSeen) : element);
if (Array.isArray(object)) {
return mapArray(object);
}
for (const key of getEnumerableKeys(object, processOptions.includeSymbols)) {
const value = object[key];
const mapResult = mapper(key, value);
if (mapResult === mapObjectSkip) {
continue;
}
if (!Array.isArray(mapResult)) {
throw new TypeError(`Mapper must return an array or mapObjectSkip, got ${mapResult === null ? 'null' : typeof mapResult}`);
}
if (mapResult.length < 2) {
throw new TypeError(`Mapper must return an array with at least 2 elements [key, value], got ${mapResult.length} elements`);
}
let [newKey, newValue, {shouldRecurse = true} = {}] = mapResult;
if (newKey === '__proto__') {
continue;
}
if (processOptions.deep && shouldRecurse && isObjectCustom(newValue)) {
newValue = Array.isArray(newValue)
? mapArray(newValue)
: _mapObject(newValue, mapper, processOptions, isSeen);
}
try {
target[newKey] = newValue;
} catch (error) {
if (error.name === 'TypeError' && error.message.includes('read only')) {
continue;
}
throw error;
}
}
return target;
};
function mapObject$1(object, mapper, options) {
if (!isObject$2(object)) {
throw new TypeError(`Expected an object, got \`${object}\` (${typeof object})`);
}
if (Array.isArray(object)) {
throw new TypeError('Expected an object, got an array');
}
const mapperWithRoot = (key, value) => mapper(key, value, object);
return _mapObject(object, mapperWithRoot, options);
}
const UPPERCASE = /[\p{Lu}]/u;
const LOWERCASE = /[\p{Ll}]/u;
const LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/u;
const SEPARATORS = /[_.\- ]+/;
const IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
const LEADING_SEPARATORS = new RegExp('^' + SEPARATORS.source);
const SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, 'gu');
const NUMBERS_AND_IDENTIFIER = new RegExp(String.raw`\d+` + IDENTIFIER.source, 'gu');
const preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase) => {
let isLastCharLower = false;
let isLastCharUpper = false;
let isLastLastCharUpper = false;
let isLastLastCharPreserved = false;
for (let index = 0; index < string.length; index++) {
const character = string[index];
isLastLastCharPreserved = index > 2 ? string[index - 3] === '-' : true;
if (isLastCharLower && UPPERCASE.test(character)) {
string = string.slice(0, index) + '-' + string.slice(index);
isLastCharLower = false;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = true;
index++;
} else if (
isLastCharUpper
&& isLastLastCharUpper
&& LOWERCASE.test(character)
&& (!isLastLastCharPreserved || preserveConsecutiveUppercase)
) {
string = string.slice(0, index - 1) + '-' + string.slice(index - 1);
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = false;
isLastCharLower = true;
} else {
isLastCharLower
= toLowerCase(character) === character
&& toUpperCase(character) !== character;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper
= toUpperCase(character) === character
&& toLowerCase(character) !== character;
}
}
return string;
};
const preserveConsecutiveUppercase = (input, toLowerCase) => input.replace(LEADING_CAPITAL, match => toLowerCase(match));
const processWithCasePreservation = (input, toLowerCase, preserveConsecutiveUppercase) => {
let result = '';
let previousWasNumber = false;
let previousWasUppercase = false;
const characters = [...input];
for (let index = 0; index < characters.length; index++) {
const character = characters[index];
const isUpperCase = UPPERCASE.test(character);
const nextCharIsUpperCase = index + 1 < characters.length && UPPERCASE.test(characters[index + 1]);
if (previousWasNumber && /[\p{Alpha}]/u.test(character)) {
result += character;
previousWasNumber = false;
previousWasUppercase = isUpperCase;
} else if (preserveConsecutiveUppercase && isUpperCase && (previousWasUppercase || nextCharIsUpperCase)) {
result += character;
previousWasUppercase = true;
} else if (/\d/.test(character)) {
result += character;
previousWasNumber = true;
previousWasUppercase = false;
} else if (SEPARATORS.test(character)) {
result += character;
previousWasUppercase = false;
} else {
result += toLowerCase(character);
previousWasNumber = false;
previousWasUppercase = false;
}
}
return result;
};
const postProcess = (input, toUpperCase, {capitalizeAfterNumber}) => {
const transformNumericIdentifier = capitalizeAfterNumber
? (match, identifier, offset, string) => {
const nextCharacter = string.charAt(offset + match.length);
if (SEPARATORS.test(nextCharacter)) {
return match;
}
return identifier ? match.slice(0, -identifier.length) + toUpperCase(identifier) : match;
}
: match => match;
return input
.replaceAll(NUMBERS_AND_IDENTIFIER, transformNumericIdentifier)
.replaceAll(
SEPARATORS_AND_IDENTIFIER,
(_, identifier) => toUpperCase(identifier),
);
};
function camelCase(input, options) {
if (!(typeof input === 'string' || Array.isArray(input))) {
throw new TypeError('Expected the input to be `string | string[]`');
}
options = {
pascalCase: false,
preserveConsecutiveUppercase: false,
capitalizeAfterNumber: true,
...options,
};
if (Array.isArray(input)) {
input = input
.map(element => element.trim())
.filter(element => element.length > 0)
.join('-');
} else {
input = input.trim();
}
if (input.length === 0) {
return '';
}
const leadingPrefix = input.match(/^[_$]*/)[0];
input = input.slice(leadingPrefix.length);
if (input.length === 0) {
return leadingPrefix;
}
const toLowerCase = options.locale === false
? string => string.toLowerCase()
: string => string.toLocaleLowerCase(options.locale);
const toUpperCase = options.locale === false
? string => string.toUpperCase()
: string => string.toLocaleUpperCase(options.locale);
if (input.length === 1) {
if (SEPARATORS.test(input)) {
return leadingPrefix;
}
return leadingPrefix + (options.pascalCase
? toUpperCase(input)
: toLowerCase(input));
}
const hasUpperCase = input !== toLowerCase(input);
if (hasUpperCase) {
input = preserveCamelCase(
input,
toLowerCase,
toUpperCase,
options.preserveConsecutiveUppercase,
);
}
input = input.replace(LEADING_SEPARATORS, '');
if (options.capitalizeAfterNumber) {
input = options.preserveConsecutiveUppercase
? preserveConsecutiveUppercase(input, toLowerCase)
: toLowerCase(input);
} else {
input = processWithCasePreservation(input, toLowerCase, options.preserveConsecutiveUppercase);
}
if (options.pascalCase && input.length > 0) {
input = toUpperCase(input[0]) + input.slice(1);
}
return leadingPrefix + postProcess(input, toUpperCase, options);
}
let QuickLRU$1 = class QuickLRU extends Map {
#size = 0;
#cache = new Map();
#oldCache = new Map();
#maxSize;
#maxAge;
#onEviction;
constructor(options = {}) {
super();
if (!(options.maxSize && options.maxSize > 0)) {
throw new TypeError('`maxSize` must be a number greater than 0');
}
if (typeof options.maxAge === 'number' && options.maxAge === 0) {
throw new TypeError('`maxAge` must be a number greater than 0');
}
this.#maxSize = options.maxSize;
this.#maxAge = options.maxAge || Number.POSITIVE_INFINITY;
this.#onEviction = options.onEviction;
}
get __oldCache() {
return this.#oldCache;
}
#emitEvictions(cache) {
if (typeof this.#onEviction !== 'function') {
return;
}
for (const [key, item] of cache) {
this.#onEviction(key, item.value);
}
}
#deleteIfExpired(key, item) {
if (typeof item.expiry === 'number' && item.expiry <= Date.now()) {
if (typeof this.#onEviction === 'function') {
this.#onEviction(key, item.value);
}
return this.delete(key);
}
return false;
}
#getOrDeleteIfExpired(key, item) {
const deleted = this.#deleteIfExpired(key, item);
if (deleted === false) {
return item.value;
}
}
#getItemValue(key, item) {
return item.expiry ? this.#getOrDeleteIfExpired(key, item) : item.value;
}
#peek(key, cache) {
const item = cache.get(key);
return this.#getItemValue(key, item);
}
#set(key, value) {
this.#cache.set(key, value);
this.#size++;
if (this.#size >= this.#maxSize) {
this.#size = 0;
this.#emitEvictions(this.#oldCache);
this.#oldCache = this.#cache;
this.#cache = new Map();
}
}
#moveToRecent(key, item) {
this.#oldCache.delete(key);
this.#set(key, item);
}
* #entriesAscending() {
for (const item of this.#oldCache) {
const [key, value] = item;
if (!this.#cache.has(key)) {
const deleted = this.#deleteIfExpired(key, value);
if (deleted === false) {
yield item;
}
}
}
for (const item of this.#cache) {
const [key, value] = item;
const deleted = this.#deleteIfExpired(key, value);
if (deleted === false) {
yield item;
}
}
}
get(key) {
if (this.#cache.has(key)) {
const item = this.#cache.get(key);
return this.#getItemValue(key, item);
}
if (this.#oldCache.has(key)) {
const item = this.#oldCache.get(key);
if (this.#deleteIfExpired(key, item) === false) {
this.#moveToRecent(key, item);
return item.value;
}
}
}
set(key, value, {maxAge = this.#maxAge} = {}) {
const expiry = typeof maxAge === 'number' && maxAge !== Number.POSITIVE_INFINITY
? (Date.now() + maxAge)
: undefined;
if (this.#cache.has(key)) {
this.#cache.set(key, {
value,
expiry,
});
} else {
this.#set(key, {value, expiry});
}
return this;
}
has(key) {
if (this.#cache.has(key)) {
return !this.#deleteIfExpired(key, this.#cache.get(key));
}
if (this.#oldCache.has(key)) {
return !this.#deleteIfExpired(key, this.#oldCache.get(key));
}
return false;
}
peek(key) {
if (this.#cache.has(key)) {
return this.#peek(key, this.#cache);
}
if (this.#oldCache.has(key)) {
return this.#peek(key, this.#oldCache);
}
}
expiresIn(key) {
const item = this.#cache.get(key) ?? this.#oldCache.get(key);
if (item) {
return item.expiry ? item.expiry - Date.now() : Number.POSITIVE_INFINITY;
}
}
delete(key) {
const deleted = this.#cache.delete(key);
if (deleted) {
this.#size--;
}
return this.#oldCache.delete(key) || deleted;
}
clear() {
this.#cache.clear();
this.#oldCache.clear();
this.#size = 0;
}
resize(newSize) {
if (!(newSize && newSize > 0)) {
throw new TypeError('`maxSize` must be a number greater than 0');
}
const items = [...this.#entriesAscending()];
const removeCount = items.length - newSize;
if (removeCount < 0) {
this.#cache = new Map(items);
this.#oldCache = new Map();
this.#size = items.length;
} else {
if (removeCount > 0) {
this.#emitEvictions(items.slice(0, removeCount));
}
this.#oldCache = new Map(items.slice(removeCount));
this.#cache = new Map();
this.#size = 0;
}
this.#maxSize = newSize;
}
evict(count = 1) {
const requested = Number(count);
if (!requested || requested <= 0) {
return;
}
const items = [...this.#entriesAscending()];
const evictCount = Math.trunc(Math.min(requested, Math.max(items.length - 1, 0)));
if (evictCount <= 0) {
return;
}
this.#emitEvictions(items.slice(0, evictCount));
this.#oldCache = new Map(items.slice(evictCount));
this.#cache = new Map();
this.#size = 0;
}
* keys() {
for (const [key] of this) {
yield key;
}
}
* values() {
for (const [, value] of this) {
yield value;
}
}
* [Symbol.iterator]() {
for (const item of this.#cache) {
const [key, value] = item;
const deleted = this.#deleteIfExpired(key, value);
if (deleted === false) {
yield [key, value.value];
}
}
for (const item of this.#oldCache) {
const [key, value] = item;
if (!this.#cache.has(key)) {
const deleted = this.#deleteIfExpired(key, value);
if (deleted === false) {
yield [key, value.value];
}
}
}
}
* entriesDescending() {
let items = [...this.#cache];
for (let i = items.length - 1; i >= 0; --i) {
const item = items[i];
const [key, value] = item;
const deleted = this.#deleteIfExpired(key, value);
if (deleted === false) {
yield [key, value.value];
}
}
items = [...this.#oldCache];
for (let i = items.length - 1; i >= 0; --i) {
const item = items[i];
const [key, value] = item;
if (!this.#cache.has(key)) {
const deleted = this.#deleteIfExpired(key, value);
if (deleted === false) {
yield [key, value.value];
}
}
}
}
* entriesAscending() {
for (const [key, value] of this.#entriesAscending()) {
yield [key, value.value];
}
}
get size() {
if (!this.#size) {
return this.#oldCache.size;
}
let oldCacheSize = 0;
for (const key of this.#oldCache.keys()) {
if (!this.#cache.has(key)) {
oldCacheSize++;
}
}
return Math.min(this.#size + oldCacheSize, this.#maxSize);
}
get maxSize() {
return this.#maxSize;
}
get maxAge() {
return this.#maxAge;
}
entries() {
return this.entriesAscending();
}
forEach(callbackFunction, thisArgument = this) {
for (const [key, value] of this.entriesAscending()) {
callbackFunction.call(thisArgument, value, key, this);
}
}
get [Symbol.toStringTag]() {
return 'QuickLRU';
}
toString() {
return `QuickLRU(${this.size}/${this.maxSize})`;
}
[Symbol.for('nodejs.util.inspect.custom')]() {
return this.toString();
}
};
const has$1 = (array, key) => array.some(element => {
if (typeof element === 'string') {
return element === key;
}
element.lastIndex = 0;
return element.test(key);
});
const isNumericKey = key => key.trim() !== '' && !Number.isNaN(Number(key));
const cache$1 = new QuickLRU$1({maxSize: 100_000});
const isBuiltIn = value =>
ArrayBuffer.isView(value)
|| value instanceof Date
|| value instanceof RegExp
|| value instanceof Error
|| value instanceof Map
|| value instanceof Set
|| value instanceof WeakMap
|| value instanceof WeakSet
|| value instanceof Promise;
const isObject$1 = value =>
typeof value === 'object'
&& value !== null
&& !isBuiltIn(value);
const transform$1 = (input, options = {}, isSeen = new WeakMap(), parentPath) => {
if (!isObject$1(input)) {
return input;
}
if (isSeen.has(input)) {
return isSeen.get(input);
}
const {
exclude,
pascalCase = false,
stopPaths,
deep = false,
preserveConsecutiveUppercase = false,
} = options;
const stopPathsSet = new Set(stopPaths);
if (Array.isArray(input)) {
const result = [];
isSeen.set(input, result);
for (const item of input) {
result.push(isObject$1(item) ? transform$1(item, options, isSeen, parentPath) : item);
}
return result;
}
const result = {};
isSeen.set(input, result);
const makeMapper = currentParentPath => (key, value) => {
if (deep && isObject$1(value)) {
const path = currentParentPath === undefined ? key : `${currentParentPath}.${key}`;
if (!stopPathsSet.has(path)) {
value = Array.isArray(value)
? value.map(item => isObject$1(item) ? transform$1(item, options, isSeen, path) : item)
: transform$1(value, options, isSeen, path);
}
}
if (typeof key === 'string' && !isNumericKey(key) && !(exclude && has$1(exclude, key))) {
const cacheKey = pascalCase ? `${key}_` : key;
if (cache$1.has(cacheKey)) {
key = cache$1.get(cacheKey);
} else {
key = camelCase(key, {pascalCase, locale: false, preserveConsecutiveUppercase});
if (key.length < 100) {
cache$1.set(cacheKey, key);
}
}
}
return [key, value];
};
const mappedResult = mapObject$1(input, makeMapper(parentPath), {deep: false});
Object.assign(result, mappedResult);
const symbols = Object.getOwnPropertySymbols(input);
for (const symbol of symbols) {
result[symbol] = deep && isObject$1(input[symbol])
? transform$1(input[symbol], options, isSeen, parentPath)
: input[symbol];
}
return result;
};
function camelcaseKeys(input, options) {
const isSeen = new WeakMap();
if (Array.isArray(input)) {
return input.map(item =>
isObject$1(item)
? transform$1(item, options, isSeen, undefined)
: item);
}
return transform$1(input, options, isSeen);
}
function trimNewlines(string) {
let start = 0;
let end = string.length;
while (start < end && (string[start] === '\r' || string[start] === '\n')) {
start++;
}
while (end > start && (string[end - 1] === '\r' || string[end - 1] === '\n')) {
end--;
}
return (start > 0 || end < string.length) ? string.slice(start, end) : string;
}
function stripIndent(string) {
const match = string.match(/^[ \t]*(?=\S)/gm);
if (!match) {
return string;
}
let minIndent = Number.POSITIVE_INFINITY;
for (const indent of match) {
minIndent = Math.min(minIndent, indent.length);
}
if (minIndent === 0 || minIndent === Number.POSITIVE_INFINITY) {
return string;
}
return string.replace(new RegExp(`^[ \\t]{${minIndent}}`, 'gm'), '');
}
function indentString(string, count = 1, options = {}) {
const {
indent = ' ',
includeEmptyLines = false
} = options;
if (typeof string !== 'string') {
throw new TypeError(
`Expected \`input\` to be a \`string\`, got \`${typeof string}\``
);
}
if (typeof count !== 'number') {
throw new TypeError(
`Expected \`count\` to be a \`number\`, got \`${typeof count}\``
);
}
if (count < 0) {
throw new RangeError(
`Expected \`count\` to be at least 0, got \`${count}\``
);
}
if (typeof indent !== 'string') {
throw new TypeError(
`Expected \`options.indent\` to be a \`string\`, got \`${typeof indent}\``
);
}
if (count === 0) {
return string;
}
const regex = includeEmptyLines ? /^/gm : /^(?!\s*$)/gm;
return string.replace(regex, indent.repeat(count));
}
function redent(string, count = 0, options = {}) {
return indentString(stripIndent(string), count, options);
}
const toPath$1 = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
function findUpSync(name, {
cwd = process$1.cwd(),
type = 'file',
stopAt,
} = {}) {
let directory = path.resolve(toPath$1(cwd) ?? '');
const {root} = path.parse(directory);
stopAt = path.resolve(directory, toPath$1(stopAt) ?? root);
const isAbsoluteName = path.isAbsolute(name);
while (directory) {
const filePath = isAbsoluteName ? name : path.join(directory, name);
try {
const stats = fs.statSync(filePath, {throwIfNoEntry: false});
if ((type === 'file' && stats?.isFile()) || (type === 'directory' && stats?.isDirectory())) {
return filePath;
}
} catch {}
if (directory === stopAt || directory === root) {
break;
}
directory = path.dirname(directory);
}
}
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
var lib$2 = {};
var picocolors = {exports: {}};
var hasRequiredPicocolors;
function requirePicocolors () {
if (hasRequiredPicocolors) return picocolors.exports;
hasRequiredPicocolors = 1;
let p = process || {}, argv = p.argv || [], env = p.env || {};
let 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);
let formatter = (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
};
let replaceClose = (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)
};
let createColors = (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"),
}
};
picocolors.exports = createColors();
picocolors.exports.createColors = createColors;
return picocolors.exports;
}
var jsTokens = {};
var hasRequiredJsTokens;
function requireJsTokens () {
if (hasRequiredJsTokens) return jsTokens;
hasRequiredJsTokens = 1;
Object.defineProperty(jsTokens, "__esModule", {
value: true
});
jsTokens.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;
jsTokens.matchToToken = function(match) {
var token = {type: "invalid", value: match[0], closed: undefined};
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
};
return jsTokens;
}
var lib$1 = {};
var identifier = {};
var hasRequiredIdentifier;
function requireIdentifier () {
if (hasRequiredIdentifier) return identifier;
hasRequiredIdentifier = 1;
Object.defineProperty(identifier, "__esModule", {
value: true
});
identifier.isIdentifierChar = isIdentifierChar;
identifier.isIdentifierName = isIdentifierName;
identifier.isIdentifierStart = isIdentifierStart;
let 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";
let 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";
const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
const 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];
const 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 = 0x10000;
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;
}
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 <= 0xffff) {
return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
}
return isInAstralSet(code, astralIdentifierStartCodes);
}
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 <= 0xffff) {
return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
}
return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
}
function isIdentifierName(name) {
let isFirst = true;
for (let i = 0; i < name.length; i++) {
let cp = name.charCodeAt(i);
if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) {
const trail = name.charCodeAt(++i);
if ((trail & 0xfc00) === 0xdc00) {
cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
}
}
if (isFirst) {
isFirst = false;
if (!isIdentifierStart(cp)) {
return false;
}
} else if (!isIdentifierChar(cp)) {
return false;
}
}
return !isFirst;
}
return identifier;
}
var keyword = {};
var hasRequiredKeyword;
function requireKeyword () {
if (hasRequiredKeyword) return keyword;
hasRequiredKeyword = 1;
Object.defineProperty(keyword, "__esModule", {
value: true
});
keyword.isKeyword = isKeyword;
keyword.isReservedWord = isReservedWord;
keyword.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
keyword.isStrictBindReservedWord = isStrictBindReservedWord;
keyword.isStrictReservedWord = isStrictReservedWord;
const 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"]
};
const keywords = new Set(reservedWords.keyword);
const reservedWordsStrictSet = new Set(reservedWords.strict);
const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
function isReservedWord(word, inModule) {
return inModule && word === "await" || word === "enum";
}
function isStrictReservedWord(word, inModule) {
return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
}
function isStrictBindOnlyReservedWord(word) {
return reservedWordsStrictBindSet.has(word);
}
function isStrictBindReservedWord(word, inModule) {
return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
}
function isKeyword(word) {
return keywords.has(word);
}
return keyword;
}
var hasRequiredLib$2;
function requireLib$2 () {
if (hasRequiredLib$2) return lib$1;
hasRequiredLib$2 = 1;
(function (exports$1) {
Object.defineProperty(exports$1, "__esModule", {
value: true
});
Object.defineProperty(exports$1, "isIdentifierChar", {
enumerable: true,
get: function () {
return _identifier.isIdentifierChar;
}
});
Object.defineProperty(exports$1, "isIdentifierName", {
enumerable: true,
get: function () {
return _identifier.isIdentifierName;
}
});
Object.defineProperty(exports$1, "isIdentifierStart", {
enumerable: true,
get: function () {
return _identifier.isIdentifierStart;
}
});
Object.defineProperty(exports$1, "isKeyword", {
enumerable: true,
get: function () {
return _keyword.isKeyword;
}
});
Object.defineProperty(exports$1, "isReservedWord", {
enumerable: true,
get: function () {
return _keyword.isReservedWord;
}
});
Object.defineProperty(exports$1, "isStrictBindOnlyReservedWord", {
enumerable: true,
get: function () {
return _keyword.isStrictBindOnlyReservedWord;
}
});
Object.defineProperty(exports$1, "isStrictBindReservedWord", {
enumerable: true,
get: function () {
return _keyword.isStrictBindReservedWord;
}
});
Object.defineProperty(exports$1, "isStrictReservedWord", {
enumerable: true,
get: function () {
return _keyword.isStrictReservedWord;
}
});
var _identifier = requireIdentifier();
var _keyword = requireKeyword();
} (lib$1));
return lib$1;
}
var hasRequiredLib$1;
function requireLib$1 () {
if (hasRequiredLib$1) return lib$2;
hasRequiredLib$1 = 1;
Object.defineProperty(lib$2, '__esModule', { value: true });
var picocolors = requirePicocolors();
var jsTokens = requireJsTokens();
var helperValidatorIdentifier = requireLib$2();
function isColorSupported() {
return (typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? false : picocolors.isColorSupported
);
}
const compose = (f, g) => v => f(g(v));
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
};
}
const defsOn = buildDefs(picocolors.createColors(true));
const defsOff = buildDefs(picocolors.createColors(false));
function getDefs(enabled) {
return enabled ? defsOn : defsOff;
}
const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);
const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
const BRACKET = /^[()[\]{}]$/;
let tokenize;
{
const JSX_TAG = /^[a-z][\w-]*$/i;
const getTokenType = 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;
};
tokenize = 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
};
}
};
}
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;
}
let deprecationWarningShown = false;
const 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
};
}
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, index) => {
const number = start + 1 + index;
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}\n${frame}`;
}
if (shouldHighlight) {
return defs.reset(frame);
} else {
return frame;
}
}
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);
}
lib$2.codeFrameColumns = codeFrameColumns;
lib$2.default = index;
lib$2.highlight = highlight;
return lib$2;
}
var libExports = requireLib$1();
const getOffsets = ({
oneBased,
oneBasedLine = oneBased,
oneBasedColumn = oneBased,
} = {}) => [oneBasedLine ? 1 : 0, oneBasedColumn ? 1 : 0];
function getPosition(text, textIndex, options) {
const lineBreakBefore = textIndex === 0 ? -1 : text.lastIndexOf('\n', textIndex - 1);
const [lineOffset, columnOffset] = getOffsets(options);
return {
line: lineBreakBefore === -1
? lineOffset
: text.slice(0, lineBreakBefore + 1).match(/\n/g).length + lineOffset,
column: textIndex - lineBreakBefore - 1 + columnOffset,
};
}
function indexToPosition(text, textIndex, options) {
if (typeof text !== 'string') {
throw new TypeError('Text parameter should be a string');
}
if (!Number.isInteger(textIndex)) {
throw new TypeError('Index parameter should be an integer');
}
if (textIndex < 0 || textIndex > text.length) {
throw new RangeError('Index out of bounds');
}
return getPosition(text, textIndex, options);
}
const getCodePoint = character => `\\u{${character.codePointAt(0).toString(16)}}`;
class JSONError extends Error {
name = 'JSONError';
fileName;
#input;
#jsonParseError;
#message;
#codeFrame;
#rawCodeFrame;
constructor(messageOrOptions) {
if (typeof messageOrOptions === 'string') {
super();
this.#message = messageOrOptions;
} else {
const {jsonParseError, fileName, input} = messageOrOptions;
super(undefined, {cause: jsonParseError});
this.#input = input;
this.#jsonParseError = jsonParseError;
this.fileName = fileName;
}
Error.captureStackTrace?.(this, JSONError);
}
get message() {
this.#message ??= `${addCodePointToUnexpectedToken(this.#jsonParseError.message)}${this.#input === '' ? ' while parsing empty string' : ''}`;
const {codeFrame} = this;
return `${this.#message}${this.fileName ? ` in ${this.fileName}` : ''}${codeFrame ? `\n\n${codeFrame}\n` : ''}`;
}
set message(message) {
this.#message = message;
}
#getCodeFrame(highlightCode) {
if (!this.#jsonParseError) {
return;
}
const input = this.#input;
const location = getErrorLocation(input, this.#jsonParseError.message);
if (!location) {
return;
}
return libExports.codeFrameColumns(input, {start: location}, {highlightCode});
}
get codeFrame() {
this.#codeFrame ??= this.#getCodeFrame( true);
return this.#codeFrame;
}
get rawCodeFrame() {
this.#rawCodeFrame ??= this.#getCodeFrame( false);
return this.#rawCodeFrame;
}
}
const getErrorLocation = (string, message) => {
const match = message.match(/in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/);
if (!match) {
return;
}
const {index, line, column} = match.groups;
if (line && column) {
return {line: Number(line), column: Number(column)};
}
return indexToPosition(string, Number(index), {oneBased: true});
};
const addCodePointToUnexpectedToken = message => message.replace(
/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,
(_, _quote, token) => `"${token}"(${getCodePoint(token)})`,
);
function parseJson(string, reviver, fileName) {
try {
return JSON.parse(string, reviver);
} catch (error) {
throw new JSONError({
jsonParseError: error,
fileName,
input: string,
});
}
}
var debug_1;
var hasRequiredDebug;
function requireDebug () {
if (hasRequiredDebug) return debug_1;
hasRequiredDebug = 1;
const debug = (
typeof process === 'object' &&
process.env &&
process.env.NODE_DEBUG &&
/\bsemver\b/i.test(process.env.NODE_DEBUG)
) ? (...args) => console.error('SEMVER', ...args)
: () => {};
debug_1 = debug;
return debug_1;
}
var constants;
var hasRequiredConstants;
function requireConstants () {
if (hasRequiredConstants) return constants;
hasRequiredConstants = 1;
// Note: this is the semver.org version of the spec that it implements
// Not necessarily the package version of this code.
const SEMVER_SPEC_VERSION = '2.0.0';
const MAX_LENGTH = 256;
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
/* istanbul ignore next */ 9007199254740991;
// Max safe segment length for coercion.
const MAX_SAFE_COMPONENT_LENGTH = 16;
// Max safe length for a build identifier. The max length minus 6 characters for
// the shortest version with a build 0.0.0+BUILD.
const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
const RELEASE_TYPES = [
'major',
'premajor',
'minor',
'preminor',
'patch',
'prepatch',
'prerelease',
];
constants = {
MAX_LENGTH,
MAX_SAFE_COMPONENT_LENGTH,
MAX_SAFE_BUILD_LENGTH,
MAX_SAFE_INTEGER,
RELEASE_TYPES,
SEMVER_SPEC_VERSION,
FLAG_INCLUDE_PRERELEASE: 0b001,
FLAG_LOOSE: 0b010,
};
return constants;
}
var re = {exports: {}};
var hasRequiredRe;
function requireRe () {
if (hasRequiredRe) return re.exports;
hasRequiredRe = 1;
(function (module, exports$1) {
const {
MAX_SAFE_COMPONENT_LENGTH,
MAX_SAFE_BUILD_LENGTH,
MAX_LENGTH,
} = requireConstants();
const debug = requireDebug();
exports$1 = module.exports = {};
// The actual regexps go on exports.re
const re = exports$1.re = [];
const safeRe = exports$1.safeRe = [];
const src = exports$1.src = [];
const safeSrc = exports$1.safeSrc = [];
const t = exports$1.t = {};
let R = 0;
const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
// Replace some greedy regex tokens to prevent regex dos issues. These regex are
// used internally via the safeRe object since all inputs in this library get
// normalized first to trim and collapse all extra whitespace. The original
// regexes are exported for userland consumption and lower level usage. A
// future breaking change could export the safer regex only with a note that
// all input should have extra whitespace removed.
const safeRegexReplacements = [
['\\s', 1],
['\\d', MAX_LENGTH],
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
];
const makeSafeRegex = (value) => {
for (const [token, max] of safeRegexReplacements) {
value = value
.split(`${token}*`).join(`${token}{0,${max}}`)
.split(`${token}+`).join(`${token}{1,${max}}`);
}
return value
};
const createToken = (name, value, isGlobal) => {
const safe = makeSafeRegex(value);
const index = R++;
debug(name, index, value);
t[name] = index;
src[index] = value;
safeSrc[index] = safe;
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined);
};
// The following Regular Expressions can be used for tokenizing,
// validating, and parsing SemVer version strings.
// ## Numeric Identifier
// A single `0`, or a non-zero digit followed by zero or more digits.
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
createToken('NUMERICIDENTIFIERLOOSE', '\\d+');
// ## Non-numeric Identifier
// Zero or more digits, followed by a letter or hyphen, and then zero or
// more letters, digits, or hyphens.
createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
// ## Main Version
// Three dot-separated numeric identifiers.
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
`(${src[t.NUMERICIDENTIFIER]})\\.` +
`(${src[t.NUMERICIDENTIFIER]})`);
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
`(${src[t.NUMERICIDENTIFIERLOOSE]})`);
// ## Pre-release Version Identifier
// A numeric identifier, or a non-numeric identifier.
// Non-numberic identifiers include numberic identifiers but can be longer.
// Therefore non-numberic identifiers must go first.
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]
}|${src[t.NUMERICIDENTIFIER]})`);
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]
}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
// ## Pre-release Version
// Hyphen, followed by one or more dot-separated pre-release version
// identifiers.
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
// ## Build Metadata Identifier
// Any combination of digits, letters, or hyphens.
createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`);
// ## Build Metadata
// Plus sign, followed by one or more period-separated build metadata
// identifiers.
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
// ## Full Version String
// A main version, followed optionally by a pre-release version and
// build metadata.
// Note that the only major, minor, patch, and pre-release sections of
// the version string are capturing groups. The build metadata is not a
// capturing group, because it should not ever be used in version
// comparison.
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
}${src[t.PRERELEASE]}?${
src[t.BUILD]}?`);
createToken('FULL', `^${src[t.FULLPLAIN]}$`);
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
// common in the npm registry.
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
}${src[t.PRERELEASELOOSE]}?${
src[t.BUILD]}?`);
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
createToken('GTLT', '((?:<|>)?=?)');
// Something like "2.*" or "1.2.x".
// Note that "x.x" is a valid xRange identifer, meaning "any version"
// Only the first item is strictly required.
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
`(?:${src[t.PRERELEASE]})?${
src[t.BUILD]}?` +
`)?)?`);
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
`(?:${src[t.PRERELEASELOOSE]})?${
src[t.BUILD]}?` +
`)?)?`);
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
// Coercion.
// Extract anything that could conceivably be a part of a valid semver
createToken('COERCEPLAIN', `${'(^|[^\\d])' +
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
createToken('COERCEFULL', src[t.COERCEPLAIN] +
`(?:${src[t.PRERELEASE]})?` +
`(?:${src[t.BUILD]})?` +
`(?:$|[^\\d])`);
createToken('COERCERTL', src[t.COERCE], true);
createToken('COERCERTLFULL', src[t.COERCEFULL], true);
// Tilde ranges.
// Meaning is "reasonably at or greater than"
createToken('LONETILDE', '(?:~>?)');
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
exports$1.tildeTrimReplace = '$1~';
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
// Caret ranges.
// Meaning is "at least and backwards compatible with"
createToken('LONECARET', '(?:\\^)');
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
exports$1.caretTrimReplace = '$1^';
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
// A simple gt/lt/eq thing, or just "" to indicate "any version"
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
// An expression to strip any whitespace between the gtlt and the thing
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
exports$1.comparatorTrimReplace = '$1$2$3';
// Something like `1.2.3 - 1.2.4`
// Note that these all use the loose form, because they'll be
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
`\\s+-\\s+` +
`(${src[t.XRANGEPLAIN]})` +
`\\s*$`);
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
`\\s+-\\s+` +
`(${src[t.XRANGEPLAINLOOSE]})` +
`\\s*$`);
createToken('STAR', '(<|>)?=?\\s*\\*');
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
} (re, re.exports));
return re.exports;
}
var parseOptions_1;
var hasRequiredParseOptions;
function requireParseOptions () {
if (hasRequiredParseOptions) return parseOptions_1;
hasRequiredParseOptions = 1;
const looseOption = Object.freeze({ loose: true });
const emptyOpts = Object.freeze({ });
const parseOptions = options => {
if (!options) {
return emptyOpts
}
if (typeof options !== 'object') {
return looseOption
}
return options
};
parseOptions_1 = parseOptions;
return parseOptions_1;
}
var identifiers;
var hasRequiredIdentifiers;
function requireIdentifiers () {
if (hasRequiredIdentifiers) return identifiers;
hasRequiredIdentifiers = 1;
const numeric = /^[0-9]+$/;
const compareIdentifiers = (a, b) => {
const anum = numeric.test(a);
const 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
};
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
identifiers = {
compareIdentifiers,
rcompareIdentifiers,
};
return identifiers;
}
var semver;
var hasRequiredSemver;
function requireSemver () {
if (hasRequiredSemver) return semver;
hasRequiredSemver = 1;
const debug = requireDebug();
const { MAX_LENGTH, MAX_SAFE_INTEGER } = requireConstants();
const { safeRe: re, t } = requireRe();
const parseOptions = requireParseOptions();
const { compareIdentifiers } = requireIdentifiers();
class SemVer {
constructor (version, options) {
options = parseOptions(options);
if (version instanceof SemVer) {
if (version.loose === !!options.loose &&
version.includePrerelease === !!options.includePrerelease) {
return version
} else {
version = version.version;
}
} else if (typeof version !== 'string') {
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
}
if (version.length > MAX_LENGTH) {
throw new TypeError(
`version is longer than ${MAX_LENGTH} characters`
)
}
debug('SemVer', version, options);
this.options = options;
this.loose = !!options.loose;
this.includePrerelease = !!options.includePrerelease;
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.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((id) => {
if (/^[0-9]+$/.test(id)) {
const num = +id;
if (num >= 0 && num < MAX_SAFE_INTEGER) {
return num
}
}
return id
});
}
this.build = m[5] ? m[5].split('.') : [];
this.format();
}
format () {
this.version = `${this.major}.${this.minor}.${this.patch}`;
if (this.prerelease.length) {
this.version += `-${this.prerelease.join('.')}`;
}
return this.version
}
toString () {
return this.version
}
compare (other) {
debug('SemVer.compare', this.version, this.options, other);
if (!(other instanceof SemVer)) {
if (typeof other === 'string' && other === this.version) {
return 0
}
other = new SemVer(other, this.options);
}
if (other.version === this.version) {
return 0
}
return this.compareMain(other) || this.comparePre(other)
}
compareMain (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)
)
}
comparePre (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
}
let i = 0;
do {
const a = this.prerelease[i];
const b = other.prerelease[i];
debug('prerelease compare', i, a, b);
if (a === undefined && b === undefined) {
return 0
} else if (b === undefined) {
return 1
} else if (a === undefined) {
return -1
} else if (a === b) {
continue
} else {
return compareIdentifiers(a, b)
}
} while (++i)
}
compareBuild (other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
let i = 0;
do {
const a = this.build[i];
const b = other.build[i];
debug('build compare', i, a, b);
if (a === undefined && b === undefined) {
return 0
} else if (b === undefined) {
return 1
} else if (a === undefined) {
return -1
} else if (a === b) {
continue
} else {
return compareIdentifiers(a, b)
}
} while (++i)
}
inc (release, identifier, identifierBase) {
if (release.startsWith('pre')) {
if (!identifier && identifierBase === false) {
throw new Error('invalid increment argument: identifier is empty')
}
if (identifier) {
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
if (!match || match[1] !== identifier) {
throw new Error(`invalid identifier: ${identifier}`)
}
}
}
switch (release) {
case 'premajor':
this.prerelease.length = 0;
this.patch = 0;
this.minor = 0;
this.major++;
this.inc('pre', identifier, identifierBase);
break
case 'preminor':
this.prerelease.length = 0;
this.patch = 0;
this.minor++;
this.inc('pre', identifier, identifierBase);
break
case 'prepatch':
this.prerelease.length = 0;
this.inc('patch', identifier, identifierBase);
this.inc('pre', identifier, identifierBase);
break
case 'prerelease':
if (this.prerelease.length === 0) {
this.inc('patch', identifier, identifierBase);
}
this.inc('pre', identifier, identifierBase);
break
case 'release':
if (this.prerelease.length === 0) {
throw new Error(`version ${this.raw} is not a prerelease`)
}
this.prerelease.length = 0;
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': {
const base = Number(identifierBase) ? 1 : 0;
if (this.prerelease.length === 0) {
this.prerelease = [base];
} else {
let i = this.prerelease.length;
while (--i >= 0) {
if (typeof this.prerelease[i] === 'number') {
this.prerelease[i]++;
i = -2;
}
}
if (i === -1) {
if (identifier === this.prerelease.join('.') && identifierBase === false) {
throw new Error('invalid increment argument: identifier already exists')
}
this.prerelease.push(base);
}
}
if (identifier) {
let prerelease = [identifier, base];
if (identifierBase === false) {
prerelease = [identifier];
}
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
if (isNaN(this.prerelease[1])) {
this.prerelease = prerelease;
}
} else {
this.prerelease = prerelease;
}
}
break
}
default:
throw new Error(`invalid increment argument: ${release}`)
}
this.raw = this.format();
if (this.build.length) {
this.raw += `+${this.build.join('.')}`;
}
return this
}
}
semver = SemVer;
return semver;
}
var parse_1;
var hasRequiredParse$1;
function requireParse$1 () {
if (hasRequiredParse$1) return parse_1;
hasRequiredParse$1 = 1;
const SemVer = requireSemver();
const parse = (version, options, throwErrors = false) => {
if (version instanceof SemVer) {
return version
}
try {
return new SemVer(version, options)
} catch (er) {
if (!throwErrors) {
return null
}
throw er
}
};
parse_1 = parse;
return parse_1;
}
var valid_1;
var hasRequiredValid;
function requireValid () {
if (hasRequiredValid) return valid_1;
hasRequiredValid = 1;
const parse = requireParse$1();
const valid = (version, options) => {
const v = parse(version, options);
return v ? v.version : null
};
valid_1 = valid;
return valid_1;
}
var clean_1;
var hasRequiredClean;
function requireClean () {
if (hasRequiredClean) return clean_1;
hasRequiredClean = 1;
const parse = requireParse$1();
const clean = (version, options) => {
const s = parse(version.trim().replace(/^[=v]+/, ''), options);
return s ? s.version : null
};
clean_1 = clean;
return clean_1;
}
const require$$1$2 = [
"0BSD",
"3D-Slicer-1.0",
"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",
"AMD-newlib",
"AMDPLPA",
"AML",
"AML-glslang",
"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-Display-PostScript",
"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",
"Artistic-dist",
"Aspell-RU",
"BSD-1-Clause",
"BSD-2-Clause",
"BSD-2-Clause-Darwin",
"BSD-2-Clause-Patent",
"BSD-2-Clause-Views",
"BSD-2-Clause-first-lines",
"BSD-2-Clause-pkgconf-disclaimer",
"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-acpica",
"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-Source-beginning-file",
"BSD-Systemics",
"BSD-Systemics-W3Works",
"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",
"Boehm-GC-without-fee",
"Borceux",
"Brian-Gladman-2-Clause",
"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-AU",
"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",
"CC-PDM-1.0",
"CC-SA-1.0",
"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",
"CMU-Mach-nodoc",
"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",
"Caldera-no-preamble",
"Catharon",
"ClArtistic",
"Clips",
"Community-Spec-1.0",
"Condor-1.1",
"Cornell-Lossless-JPEG",
"Cronyx",
"Crossword",
"CryptoSwift",
"CrystalStacker",
"Cube",
"D-FSL-1.0",
"DEC-3-Clause",
"DL-DE-BY-2.0",
"DL-DE-ZERO-2.0",
"DOC",
"DRL-1.0",
"DRL-1.1",
"DSDP",
"DocBook-DTD",
"DocBook-Schema",
"DocBook-Stylesheet",
"DocBook-XML",
"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",
"FSFAP-no-warranty-disclaimer",
"FSFUL",
"FSFULLR",
"FSFULLRSD",
"FSFULLRWD",
"FSL-1.1-ALv2",
"FSL-1.1-MIT",
"FTL",
"Fair",
"Ferguson-Twofish",
"Frameworx-1.0",
"FreeBSD-DOC",
"FreeImage",
"Furuseth",
"GCR-docs",
"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",
"Game-Programming-Gems",
"Giftware",
"Glide",
"Glulxe",
"Graphics-Gems",
"Gutmann",
"HDF5",
"HIDAPI",
"HP-1986",
"HP-1989",
"HPND",
"HPND-DEC",
"HPND-Fenneberg-Livingston",
"HPND-INRIA-IMAG",
"HPND-Intel",
"HPND-Kevlin-Henney",
"HPND-MIT-disclaimer",
"HPND-Markus-Kuhn",
"HPND-Netrek",
"HPND-Pbmplus",
"HPND-UC",
"HPND-UC-export-US",
"HPND-doc",
"HPND-doc-sell",
"HPND-export-US",
"HPND-export-US-acknowledgement",
"HPND-export-US-modify",
"HPND-export2-US",
"HPND-merchantability-variant",
"HPND-sell-MIT-disclaimer-xserver",
"HPND-sell-regexpr",
"HPND-sell-variant",
"HPND-sell-variant-MIT-disclaimer",
"HPND-sell-variant-MIT-disclaimer-rev",
"HTMLTIDY",
"HaskellReport",
"Hippocratic-2.1",
"IBM-pibs",
"ICU",
"IEC-Code-Components-EULA",
"IJG",
"IJG-short",
"IPA",
"IPL-1.0",
"ISC",
"ISC-Veillard",
"ImageMagick",
"Imlib2",
"Info-ZIP",
"Inner-Net-2.0",
"InnoSetup",
"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",
"LPD-document",
"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",
"MIPS",
"MIT",
"MIT-0",
"MIT-CMU",
"MIT-Click",
"MIT-Festival",
"MIT-Khronos-old",
"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",
"Mackerras-3-Clause",
"Mackerras-3-Clause-acknowledgment",
"MakeIndex",
"Martin-Birgmeier",
"McPhee-slideshow",
"Minpack",
"MirOS",
"Motosoto",
"MulanPSL-1.0",
"MulanPSL-2.0",
"Multics",
"Mup",
"NAIST-2003",
"NASA-1.3",
"NBPL-1.0",
"NCBI-PD",
"NCGL-UK-2.0",
"NCL",
"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",
"NTIA-PD",
"NTP",
"NTP-0",
"Naumen",
"NetCDF",
"Newsletr",
"Nokia",
"Noweb",
"O-UDA-1.0",
"OAR",
"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",
"OpenSSL-standalone",
"OpenVision",
"PADL",
"PDDL-1.0",
"PHP-3.0",
"PHP-3.01",
"PPL",
"PSF-2.0",
"Parity-6.0.0",
"Parity-7.0.0",
"Pixar",
"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",
"Ruby-pty",
"SAX-PD",
"SAX-PD-2.0",
"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",
"SMAIL-GPL",
"SMLNJ",
"SMPPL",
"SNIA",
"SOFA",
"SPL-1.0",
"SSH-OpenSSH",
"SSH-short",
"SSLeay-standalone",
"SSPL-1.0",
"SUL-1.0",
"SWL",
"Saxpath",
"SchemeReport",
"Sendmail",
"Sendmail-8.23",
"Sendmail-Open-Source-1.1",
"SimPL-2.0",
"Sleepycat",
"Soundex",
"Spencer-86",
"Spencer-94",
"Spencer-99",
"SugarCRM-1.1.3",
"Sun-PPP",
"Sun-PPP-2000",
"SunPro",
"Symlinks",
"TAPR-OHL-1.0",
"TCL",
"TCP-wrappers",
"TGPPL-1.0",
"TMate",
"TORQUE-1.1",
"TOSL",
"TPDL",
"TPL-1.0",
"TTWL",
"TTYP0",
"TU-Berlin-1.0",
"TU-Berlin-2.0",
"TermReadKey",
"ThirdEye",
"TrustedQSL",
"UCAR",
"UCL-1.0",
"UMich-Merit",
"UPL-1.0",
"URT-RLE",
"Ubuntu-font-1.0",
"Unicode-3.0",
"Unicode-DFS-2015",
"Unicode-DFS-2016",
"Unicode-TOU",
"UnixCrypt",
"Unlicense",
"Unlicense-libtelnet",
"Unlicense-libwhirlpool",
"VOSTROM",
"VSL-1.0",
"Vim",
"W3C",
"W3C-19980720",
"W3C-20150513",
"WTFPL",
"Watcom-1.0",
"Widget-Workshop",
"Wsuipa",
"X11",
"X11-distribute-modifications-variant",
"X11-swapped",
"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",
"any-OSI",
"any-OSI-perl-modules",
"bcrypt-Solar-Designer",
"blessing",
"bzip2-1.0.6",
"check-cvs",
"checkmk",
"copyleft-next-0.3.0",
"copyleft-next-0.3.1",
"curl",
"cve-tou",
"diffmark",
"dtoa",
"dvipdfm",
"eGenix",
"etalab-2.0",
"fwlw",
"gSOAP-1.3b",
"generic-xts",
"gnuplot",
"gtkbook",
"hdparm",
"iMatix",
"jove",
"libpng-1.6.35",
"libpng-2.0",
"libselinux-1.0",
"libtiff",
"libutil-David-Nugent",
"lsof",
"magaz",
"mailprio",
"man2html",
"metamail",
"mpi-permissive",
"mpich2",
"mplus",
"ngrep",
"pkgconf",
"pnmstitch",
"psfrag",
"psutils",
"python-ldap",
"radvd",
"snprintf",
"softSurfer",
"ssh-keyscan",
"swrule",
"threeparttable",
"ulem",
"w3m",
"wwl",
"xinetd",
"xkeyboard-config-Zinoviev",
"xlock",
"xpp",
"xzoom",
"zlib-acknowledgement"
];
const require$$1$1 = [
"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-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-with-GCC-exception",
"GPL-3.0-with-autoconf-exception",
"LGPL-2.0",
"LGPL-2.1",
"LGPL-3.0",
"Net-SNMP",
"Nunit",
"StandardML-NJ",
"bzip2-1.0.5",
"eCos-2.0",
"wxWindows"
];
const require$$2 = [
"389-exception",
"Asterisk-exception",
"Autoconf-exception-2.0",
"Autoconf-exception-3.0",
"Autoconf-exception-generic",
"Autoconf-exception-generic-3.0",
"Autoconf-exception-macro",
"Bison-exception-1.24",
"Bison-exception-2.2",
"Bootloader-exception",
"Classpath-exception-2.0",
"CLISP-exception-2.0",
"cryptsetup-OpenSSL-exception",
"DigiRule-FOSS-exception",
"eCos-exception-2.0",
"Fawkes-Runtime-exception",
"FLTK-exception",
"fmt-exception",
"Font-exception-2.0",
"freertos-exception-2.0",
"GCC-exception-2.0",
"GCC-exception-2.0-note",
"GCC-exception-3.1",
"Gmsh-exception",
"GNAT-exception",
"GNOME-examples-exception",
"GNU-compiler-exception",
"gnu-javamail-exception",
"GPL-3.0-interface-exception",
"GPL-3.0-linking-exception",
"GPL-3.0-linking-source-exception",
"GPL-CC-1.0",
"GStreamer-exception-2005",
"GStreamer-exception-2008",
"i2p-gpl-java-exception",
"KiCad-libraries-exception",
"LGPL-3.0-linking-exception",
"libpri-OpenH323-exception",
"Libtool-exception",
"Linux-syscall-note",
"LLGPL",
"LLVM-exception",
"LZMA-exception",
"mif-exception",
"OCaml-LGPL-linking-exception",
"OCCT-exception-1.0",
"OpenJDK-assembly-exception-1.0",
"openvpn-openssl-exception",
"PS-or-PDF-font-exception-20170817",
"QPL-1.0-INRIA-2004-exception",
"Qt-GPL-exception-1.0",
"Qt-LGPL-exception-1.1",
"Qwt-exception-1.0",
"SANE-exception",
"SHL-2.0",
"SHL-2.1",
"stunnel-exception",
"SWI-exception",
"Swift-exception",
"Texinfo-exception",
"u-boot-exception-2.0",
"UBDL-exception",
"Universal-FOSS-exception-1.0",
"vsftpd-openssl-exception",
"WxWindows-exception-3.1",
"x11vnc-openssl-exception"
];
var scan;
var hasRequiredScan;
function requireScan () {
if (hasRequiredScan) return scan;
hasRequiredScan = 1;
var licenses = []
.concat(require$$1$2)
.concat(require$$1$1);
var exceptions = require$$2;
scan = function (source) {
var index = 0;
function hasMore () {
return index < source.length
}
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
}
}
}
function skipWhitespace () {
read(/[ ]*/);
}
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: string
}
}
function idstring () {
return read(/[A-Za-z0-9-.]+/)
}
function expectIdstring () {
var string = idstring();
if (!string) {
throw new Error('Expected idstring at offset ' + index)
}
return string
}
function documentRef () {
if (read('DocumentRef-')) {
var string = expectIdstring();
return { type: 'DOCUMENTREF', string: string }
}
}
function licenseRef () {
if (read('LicenseRef-')) {
var string = expectIdstring();
return { type: 'LICENSEREF', string: string }
}
}
function identifier () {
var begin = index;
var string = idstring();
if (licenses.indexOf(string) !== -1) {
return {
type: 'LICENSE',
string: string
}
} else if (exceptions.indexOf(string) !== -1) {
return {
type: 'EXCEPTION',
string: string
}
}
index = begin;
}
function parseToken () {
return (
operator() ||
documentRef() ||
licenseRef() ||
identifier()
)
}
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
};
return scan;
}
var parse;
var hasRequiredParse;
function requireParse () {
if (hasRequiredParse) return parse;
hasRequiredParse = 1;
parse = function (tokens) {
var index = 0;
function hasMore () {
return index < tokens.length
}
function token () {
return hasMore() ? tokens[index] : null
}
function next () {
if (!hasMore()) {
throw new Error()
}
index++;
}
function parseOperator (operator) {
var t = token();
if (t && t.type === 'OPERATOR' && operator === t.string) {
next();
return t.string
}
}
function parseWith () {
if (parseOperator('WITH')) {
var t = token();
if (t && t.type === 'EXCEPTION') {
next();
return t.string
}
throw new Error('Expected exception after `WITH`')
}
}
function parseLicenseRef () {
var begin = index;
var string = '';
var t = token();
if (t.type === 'DOCUMENTREF') {
next();
string += 'DocumentRef-' + t.string + ':';
if (!parseOperator(':')) {
throw new Error('Expected `:` after `DocumentRef-...`')
}
}
t = token();
if (t.type === 'LICENSEREF') {
next();
string += 'LicenseRef-' + t.string;
return { license: string }
}
index = begin;
}
function parseLicense () {
var t = token();
if (t && t.type === 'LICENSE') {
next();
var node = { license: t.string };
if (parseOperator('+')) {
node.plus = true;
}
var exception = parseWith();
if (exception) {
node.exception = exception;
}
return node
}
}
function parseParenthesizedExpression () {
var left = parseOperator('(');
if (!left) {
return
}
var expr = parseExpression();
if (!parseOperator(')')) {
throw new Error('Expected `)`')
}
return expr
}
function parseAtom () {
return (
parseParenthesizedExpression() ||
parseLicenseRef() ||
parseLicense()
)
}
function makeBinaryOpParser (operator, nextParser) {
return 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: left,
conjunction: operator.toLowerCase(),
right: right
}
}
}
var parseAnd = makeBinaryOpParser('AND', parseAtom);
var parseExpression = makeBinaryOpParser('OR', parseAnd);
var node = parseExpression();
if (!node || hasMore()) {
throw new Error('Syntax error')
}
return node
};
return parse;
}
var spdxExpressionParse;
var hasRequiredSpdxExpressionParse;
function requireSpdxExpressionParse () {
if (hasRequiredSpdxExpressionParse) return spdxExpressionParse;
hasRequiredSpdxExpressionParse = 1;
var scan = requireScan();
var parse = requireParse();
spdxExpressionParse = function (source) {
return parse(scan(source))
};
return spdxExpressionParse;
}
var spdxCorrect;
var hasRequiredSpdxCorrect;
function requireSpdxCorrect () {
if (hasRequiredSpdxCorrect) return spdxCorrect;
hasRequiredSpdxCorrect = 1;
var parse = requireSpdxExpressionParse();
var spdxLicenseIds = require$$1$2;
function valid (string) {
try {
parse(string);
return true
} catch (error) {
return false
}
}
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())
}
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 = [
function (argument) {
return argument.toUpperCase()
},
function (argument) {
return argument.trim()
},
function (argument) {
return argument.replace(/\./g, '')
},
function (argument) {
return argument.replace(/\s+/g, '')
},
function (argument) {
return argument.replace(/\s+/g, '-')
},
function (argument) {
return argument.replace('v', '-')
},
function (argument) {
return argument.replace(/,?\s*(\d)/, '-$1')
},
function (argument) {
return argument.replace(/,?\s*(\d)/, '-$1.0')
},
function (argument) {
return argument
.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/, '-$2')
},
function (argument) {
return argument
.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/, '-$2.0')
},
function (argument) {
return argument[0].toUpperCase() + argument.slice(1)
},
function (argument) {
return argument.replace('/', '-')
},
function (argument) {
return argument
.replace(/\s*V\s*(\d)/, '-$1')
.replace(/(\d)$/, '$1.0')
},
function (argument) {
if (argument.indexOf('3.0') !== -1) {
return argument + '-or-later'
} else {
return argument + '-only'
}
},
function (argument) {
return argument + 'only'
},
function (argument) {
return argument.replace(/(\d)$/, '-$1.0')
},
function (argument) {
return argument.replace(/(-| )?(\d)$/, '-$2-Clause')
},
function (argument) {
return argument.replace(/(-| )clause(-| )(\d)/, '-$3-Clause')
},
function (argument) {
return argument.replace(/\b(Modified|New|Revised)(-| )?BSD((-| )License)?/i, 'BSD-3-Clause')
},
function (argument) {
return argument.replace(/\bSimplified(-| )?BSD((-| )License)?/i, 'BSD-2-Clause')
},
function (argument) {
return argument.replace(/\b(Free|Net)(-| )?BSD((-| )License)?/i, 'BSD-2-Clause-$1BSD')
},
function (argument) {
return argument.replace(/\bClear(-| )?BSD((-| )License)?/i, 'BSD-3-Clause-Clear')
},
function (argument) {
return argument.replace(/\b(Old|Original)(-| )?BSD((-| )License)?/i, 'BSD-4-Clause')
},
function (argument) {
return 'CC-' + argument
},
function (argument) {
return 'CC-' + argument + '-4.0'
},
function (argument) {
return argument
.replace('Attribution', 'BY')
.replace('NonCommercial', 'NC')
.replace('NoDerivatives', 'ND')
.replace(/ (\d)/, '-$1')
.replace(/ ?International/, '')
},
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(function makeEntries (key) {
return [key, licensesWithVersions[key]]
})
.filter(function identifySoleVersions (item) {
return (
item[1].length === 1 &&
item[0] !== null &&
item[0] !== 'APL'
)
})
.map(function createLastResorts (item) {
return [item[0], item[1][0]]
});
licensesWithVersions = undefined;
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 = function (identifier) {
for (var i = 0; i < transforms.length; i++) {
var transformed = transforms[i](identifier).trim();
if (transformed !== identifier && valid(transformed)) {
return transformed
}
}
return null
};
var validLastResort = function (identifier) {
var upperCased = identifier.toUpperCase();
for (var i = 0; i < lastResorts.length; i++) {
var lastResort = lastResorts[i];
if (upperCased.indexOf(lastResort[SUBSTRING]) > -1) {
return lastResort[IDENTIFIER]
}
}
return null
};
var anyCorrection = function (identifier, check) {
for (var i = 0; i < transpositions.length; i++) {
var transposition = transpositions[i];
var transposed = transposition[TRANSPOSED];
if (identifier.indexOf(transposed) > -1) {
var corrected = identifier.replace(
transposed,
transposition[CORRECT]
);
var checked = check(corrected);
if (checked !== null) {
return checked
}
}
}
return null
};
spdxCorrect = function (identifier, options) {
options = options || {};
var upgrade = options.upgrade === undefined ? true : !!options.upgrade;
function postprocess (value) {
return upgrade ? upgradeGPLs(value) : value
}
var validArugment = (
typeof identifier === 'string' &&
identifier.trim().length !== 0
);
if (!validArugment) {
throw Error('Invalid argument. Expected non-empty string.')
}
identifier = identifier.trim();
if (valid(identifier)) {
return postprocess(identifier)
}
var noPlus = identifier.replace(/\+$/, '').trim();
if (valid(noPlus)) {
return postprocess(noPlus)
}
var transformed = validTransformation(identifier);
if (transformed !== null) {
return postprocess(transformed)
}
transformed = anyCorrection(identifier, function (argument) {
if (valid(argument)) {
return argument
}
return validTransformation(argument)
});
if (transformed !== null) {
return postprocess(transformed)
}
transformed = validLastResort(identifier);
if (transformed !== null) {
return postprocess(transformed)
}
transformed = anyCorrection(identifier, 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
}
}
return spdxCorrect;
}
var validateNpmPackageLicense;
var hasRequiredValidateNpmPackageLicense;
function requireValidateNpmPackageLicense () {
if (hasRequiredValidateNpmPackageLicense) return validateNpmPackageLicense;
hasRequiredValidateNpmPackageLicense = 1;
var parse = requireSpdxExpressionParse();
var correct = requireSpdxCorrect();
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;
}
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)
);
}
}
validateNpmPackageLicense = 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
};
}
};
return validateNpmPackageLicense;
}
var commonjs = {};
var hasRequiredCommonjs;
function requireCommonjs () {
if (hasRequiredCommonjs) return commonjs;
hasRequiredCommonjs = 1;
Object.defineProperty(commonjs, "__esModule", { value: true });
commonjs.LRUCache = void 0;
const defaultPerf = (typeof performance === 'object' &&
performance &&
typeof performance.now === 'function') ?
performance
: Date;
const warned = new Set();
const PROCESS = (typeof process === 'object' && !!process ?
process
: {});
const emitWarning = (msg, type, code, fn) => {
typeof PROCESS.emitWarning === 'function' ?
PROCESS.emitWarning(msg, type, code, fn)
: console.error(`[${code}] ${type}: ${msg}`);
};
let AC = globalThis.AbortController;
let AS = globalThis.AbortSignal;
if (typeof AC === 'undefined') {
AS = class AbortSignal {
onabort;
_onabort = [];
reason;
aborted = false;
addEventListener(_, fn) {
this._onabort.push(fn);
}
};
AC = class AbortController {
constructor() {
warnACPolyfill();
}
signal = new AS();
abort(reason) {
if (this.signal.aborted)
return;
this.signal.reason = reason;
this.signal.aborted = true;
for (const fn of this.signal._onabort) {
fn(reason);
}
this.signal.onabort?.(reason);
}
};
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
const warnACPolyfill = () => {
if (!printACPolyfillWarning)
return;
printACPolyfillWarning = false;
emitWarning('AbortController is not defined. If using lru-cache in ' +
'node 14, load an AbortController polyfill from the ' +
'`node-abort-controller` package. A minimal polyfill is ' +
'provided for use by LRUCache.fetch(), but it should not be ' +
'relied upon in other contexts (eg, passing it to other APIs that ' +
'use AbortController/AbortSignal might have undesirable effects). ' +
'You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.', 'NO_ABORT_CONTROLLER', 'ENOTSUP', warnACPolyfill);
};
}
const shouldWarn = (code) => !warned.has(code);
const isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
const getUintArray = (max) => !isPosInt(max) ? null
: max <= Math.pow(2, 8) ? Uint8Array
: max <= Math.pow(2, 16) ? Uint16Array
: max <= Math.pow(2, 32) ? Uint32Array
: max <= Number.MAX_SAFE_INTEGER ? ZeroArray
: null;
class ZeroArray extends Array {
constructor(size) {
super(size);
this.fill(0);
}
}
class Stack {
heap;
length;
static #constructing = false;
static create(max) {
const HeapCls = getUintArray(max);
if (!HeapCls)
return [];
Stack.#constructing = true;
const s = new Stack(max, HeapCls);
Stack.#constructing = false;
return s;
}
constructor(max, HeapCls) {
if (!Stack.#constructing) {
throw new TypeError('instantiate Stack using Stack.create(n)');
}
this.heap = new HeapCls(max);
this.length = 0;
}
push(n) {
this.heap[this.length++] = n;
}
pop() {
return this.heap[--this.length];
}
}
class LRUCache {
#max;
#maxSize;
#dispose;
#onInsert;
#disposeAfter;
#fetchMethod;
#memoMethod;
#perf;
get perf() {
return this.#perf;
}
ttl;
ttlResolution;
ttlAutopurge;
updateAgeOnGet;
updateAgeOnHas;
allowStale;
noDisposeOnSet;
noUpdateTTL;
maxEntrySize;
sizeCalculation;
noDeleteOnFetchRejection;
noDeleteOnStaleGet;
allowStaleOnFetchAbort;
allowStaleOnFetchRejection;
ignoreFetchAbort;
#size;
#calculatedSize;
#keyMap;
#keyList;
#valList;
#next;
#prev;
#head;
#tail;
#free;
#disposed;
#sizes;
#starts;
#ttls;
#hasDispose;
#hasFetchMethod;
#hasDisposeAfter;
#hasOnInsert;
static unsafeExposeInternals(c) {
return {
starts: c.#starts,
ttls: c.#ttls,
sizes: c.#sizes,
keyMap: c.#keyMap,
keyList: c.#keyList,
valList: c.#valList,
next: c.#next,
prev: c.#prev,
get head() {
return c.#head;
},
get tail() {
return c.#tail;
},
free: c.#free,
isBackgroundFetch: (p) => c.#isBackgroundFetch(p),
backgroundFetch: (k, index, options, context) => c.#backgroundFetch(k, index, options, context),
moveToTail: (index) => c.#moveToTail(index),
indexes: (options) => c.#indexes(options),
rindexes: (options) => c.#rindexes(options),
isStale: (index) => c.#isStale(index),
};
}
get max() {
return this.#max;
}
get maxSize() {
return this.#maxSize;
}
get calculatedSize() {
return this.#calculatedSize;
}
get size() {
return this.#size;
}
get fetchMethod() {
return this.#fetchMethod;
}
get memoMethod() {
return this.#memoMethod;
}
get dispose() {
return this.#dispose;
}
get onInsert() {
return this.#onInsert;
}
get disposeAfter() {
return this.#disposeAfter;
}
constructor(options) {
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, perf, } = options;
if (perf !== undefined) {
if (typeof perf?.now !== 'function') {
throw new TypeError('perf option must have a now() method if specified');
}
}
this.#perf = perf ?? defaultPerf;
if (max !== 0 && !isPosInt(max)) {
throw new TypeError('max option must be a nonnegative integer');
}
const UintArray = max ? getUintArray(max) : Array;
if (!UintArray) {
throw new Error('invalid max value: ' + max);
}
this.#max = max;
this.#maxSize = maxSize;
this.maxEntrySize = maxEntrySize || this.#maxSize;
this.sizeCalculation = sizeCalculation;
if (this.sizeCalculation) {
if (!this.#maxSize && !this.maxEntrySize) {
throw new TypeError('cannot set sizeCalculation without setting maxSize or maxEntrySize');
}
if (typeof this.sizeCalculation !== 'function') {
throw new TypeError('sizeCalculation set to non-function');
}
}
if (memoMethod !== undefined &&
typeof memoMethod !== 'function') {
throw new TypeError('memoMethod must be a function if defined');
}
this.#memoMethod = memoMethod;
if (fetchMethod !== undefined &&
typeof fetchMethod !== 'function') {
throw new TypeError('fetchMethod must be a function if specified');
}
this.#fetchMethod = fetchMethod;
this.#hasFetchMethod = !!fetchMethod;
this.#keyMap = new Map();
this.#keyList = new Array(max).fill(undefined);
this.#valList = new Array(max).fill(undefined);
this.#next = new UintArray(max);
this.#prev = new UintArray(max);
this.#head = 0;
this.#tail = 0;
this.#free = Stack.create(max);
this.#size = 0;
this.#calculatedSize = 0;
if (typeof dispose === 'function') {
this.#dispose = dispose;
}
if (typeof onInsert === 'function') {
this.#onInsert = onInsert;
}
if (typeof disposeAfter === 'function') {
this.#disposeAfter = disposeAfter;
this.#disposed = [];
}
else {
this.#disposeAfter = undefined;
this.#disposed = undefined;
}
this.#hasDispose = !!this.#dispose;
this.#hasOnInsert = !!this.#onInsert;
this.#hasDisposeAfter = !!this.#disposeAfter;
this.noDisposeOnSet = !!noDisposeOnSet;
this.noUpdateTTL = !!noUpdateTTL;
this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
this.ignoreFetchAbort = !!ignoreFetchAbort;
if (this.maxEntrySize !== 0) {
if (this.#maxSize !== 0) {
if (!isPosInt(this.#maxSize)) {
throw new TypeError('maxSize must be a positive integer if specified');
}
}
if (!isPosInt(this.maxEntrySize)) {
throw new TypeError('maxEntrySize must be a positive integer if specified');
}
this.#initializeSizeTracking();
}
this.allowStale = !!allowStale;
this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
this.updateAgeOnGet = !!updateAgeOnGet;
this.updateAgeOnHas = !!updateAgeOnHas;
this.ttlResolution =
isPosInt(ttlResolution) || ttlResolution === 0 ?
ttlResolution
: 1;
this.ttlAutopurge = !!ttlAutopurge;
this.ttl = ttl || 0;
if (this.ttl) {
if (!isPosInt(this.ttl)) {
throw new TypeError('ttl must be a positive integer if specified');
}
this.#initializeTTLTracking();
}
if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) {
throw new TypeError('At least one of max, maxSize, or ttl is required');
}
if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
const code = 'LRU_CACHE_UNBOUNDED';
if (shouldWarn(code)) {
warned.add(code);
const msg = 'TTL caching without ttlAutopurge, max, or maxSize can ' +
'result in unbounded memory consumption.';
emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache);
}
}
}
getRemainingTTL(key) {
return this.#keyMap.has(key) ? Infinity : 0;
}
#initializeTTLTracking() {
const ttls = new ZeroArray(this.#max);
const starts = new ZeroArray(this.#max);
this.#ttls = ttls;
this.#starts = starts;
this.#setItemTTL = (index, ttl, start = this.#perf.now()) => {
starts[index] = ttl !== 0 ? start : 0;
ttls[index] = ttl;
if (ttl !== 0 && this.ttlAutopurge) {
const t = setTimeout(() => {
if (this.#isStale(index)) {
this.#delete(this.#keyList[index], 'expire');
}
}, ttl + 1);
if (t.unref) {
t.unref();
}
}
};
this.#updateItemAge = index => {
starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0;
};
this.#statusTTL = (status, index) => {
if (ttls[index]) {
const ttl = ttls[index];
const start = starts[index];
if (!ttl || !start)
return;
status.ttl = ttl;
status.start = start;
status.now = cachedNow || getNow();
const age = status.now - start;
status.remainingTTL = ttl - age;
}
};
let cachedNow = 0;
const getNow = () => {
const n = this.#perf.now();
if (this.ttlResolution > 0) {
cachedNow = n;
const t = setTimeout(() => (cachedNow = 0), this.ttlResolution);
if (t.unref) {
t.unref();
}
}
return n;
};
this.getRemainingTTL = key => {
const index = this.#keyMap.get(key);
if (index === undefined) {
return 0;
}
const ttl = ttls[index];
const start = starts[index];
if (!ttl || !start) {
return Infinity;
}
const age = (cachedNow || getNow()) - start;
return ttl - age;
};
this.#isStale = index => {
const s = starts[index];
const t = ttls[index];
return !!t && !!s && (cachedNow || getNow()) - s > t;
};
}
#updateItemAge = () => { };
#statusTTL = () => { };
#setItemTTL = () => { };
#isStale = () => false;
#initializeSizeTracking() {
const sizes = new ZeroArray(this.#max);
this.#calculatedSize = 0;
this.#sizes = sizes;
this.#removeItemSize = index => {
this.#calculatedSize -= sizes[index];
sizes[index] = 0;
};
this.#requireSize = (k, v, size, sizeCalculation) => {
if (this.#isBackgroundFetch(v)) {
return 0;
}
if (!isPosInt(size)) {
if (sizeCalculation) {
if (typeof sizeCalculation !== 'function') {
throw new TypeError('sizeCalculation must be a function');
}
size = sizeCalculation(v, k);
if (!isPosInt(size)) {
throw new TypeError('sizeCalculation return invalid (expect positive integer)');
}
}
else {
throw new TypeError('invalid size value (must be positive integer). ' +
'When maxSize or maxEntrySize is used, sizeCalculation ' +
'or size must be set.');
}
}
return size;
};
this.#addItemSize = (index, size, status) => {
sizes[index] = size;
if (this.#maxSize) {
const maxSize = this.#maxSize - sizes[index];
while (this.#calculatedSize > maxSize) {
this.#evict(true);
}
}
this.#calculatedSize += sizes[index];
if (status) {
status.entrySize = size;
status.totalCalculatedSize = this.#calculatedSize;
}
};
}
#removeItemSize = _i => { };
#addItemSize = (_i, _s, _st) => { };
#requireSize = (_k, _v, size, sizeCalculation) => {
if (size || sizeCalculation) {
throw new TypeError('cannot set size without setting maxSize or maxEntrySize on cache');
}
return 0;
};
*#indexes({ allowStale = this.allowStale } = {}) {
if (this.#size) {
for (let i = this.#tail; true;) {
if (!this.#isValidIndex(i)) {
break;
}
if (allowStale || !this.#isStale(i)) {
yield i;
}
if (i === this.#head) {
break;
}
else {
i = this.#prev[i];
}
}
}
}
*#rindexes({ allowStale = this.allowStale } = {}) {
if (this.#size) {
for (let i = this.#head; true;) {
if (!this.#isValidIndex(i)) {
break;
}
if (allowStale || !this.#isStale(i)) {
yield i;
}
if (i === this.#tail) {
break;
}
else {
i = this.#next[i];
}
}
}
}
#isValidIndex(index) {
return (index !== undefined &&
this.#keyMap.get(this.#keyList[index]) === index);
}
*entries() {
for (const i of this.#indexes()) {
if (this.#valList[i] !== undefined &&
this.#keyList[i] !== undefined &&
!this.#isBackgroundFetch(this.#valList[i])) {
yield [this.#keyList[i], this.#valList[i]];
}
}
}
*rentries() {
for (const i of this.#rindexes()) {
if (this.#valList[i] !== undefined &&
this.#keyList[i] !== undefined &&
!this.#isBackgroundFetch(this.#valList[i])) {
yield [this.#keyList[i], this.#valList[i]];
}
}
}
*keys() {
for (const i of this.#indexes()) {
const k = this.#keyList[i];
if (k !== undefined &&
!this.#isBackgroundFetch(this.#valList[i])) {
yield k;
}
}
}
*rkeys() {
for (const i of this.#rindexes()) {
const k = this.#keyList[i];
if (k !== undefined &&
!this.#isBackgroundFetch(this.#valList[i])) {
yield k;
}
}
}
*values() {
for (const i of this.#indexes()) {
const v = this.#valList[i];
if (v !== undefined &&
!this.#isBackgroundFetch(this.#valList[i])) {
yield this.#valList[i];
}
}
}
*rvalues() {
for (const i of this.#rindexes()) {
const v = this.#valList[i];
if (v !== undefined &&
!this.#isBackgroundFetch(this.#valList[i])) {
yield this.#valList[i];
}
}
}
[Symbol.iterator]() {
return this.entries();
}
[Symbol.toStringTag] = 'LRUCache';
find(fn, getOptions = {}) {
for (const i of this.#indexes()) {
const v = this.#valList[i];
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
if (value === undefined)
continue;
if (fn(value, this.#keyList[i], this)) {
return this.get(this.#keyList[i], getOptions);
}
}
}
forEach(fn, thisp = this) {
for (const i of this.#indexes()) {
const v = this.#valList[i];
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
if (value === undefined)
continue;
fn.call(thisp, value, this.#keyList[i], this);
}
}
rforEach(fn, thisp = this) {
for (const i of this.#rindexes()) {
const v = this.#valList[i];
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
if (value === undefined)
continue;
fn.call(thisp, value, this.#keyList[i], this);
}
}
purgeStale() {
let deleted = false;
for (const i of this.#rindexes({ allowStale: true })) {
if (this.#isStale(i)) {
this.#delete(this.#keyList[i], 'expire');
deleted = true;
}
}
return deleted;
}
info(key) {
const i = this.#keyMap.get(key);
if (i === undefined)
return undefined;
const v = this.#valList[i];
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
if (value === undefined)
return undefined;
const entry = { value };
if (this.#ttls && this.#starts) {
const ttl = this.#ttls[i];
const start = this.#starts[i];
if (ttl && start) {
const remain = ttl - (this.#perf.now() - start);
entry.ttl = remain;
entry.start = Date.now();
}
}
if (this.#sizes) {
entry.size = this.#sizes[i];
}
return entry;
}
dump() {
const arr = [];
for (const i of this.#indexes({ allowStale: true })) {
const key = this.#keyList[i];
const v = this.#valList[i];
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
if (value === undefined || key === undefined)
continue;
const entry = { value };
if (this.#ttls && this.#starts) {
entry.ttl = this.#ttls[i];
const age = this.#perf.now() - this.#starts[i];
entry.start = Math.floor(Date.now() - age);
}
if (this.#sizes) {
entry.size = this.#sizes[i];
}
arr.unshift([key, entry]);
}
return arr;
}
load(arr) {
this.clear();
for (const [key, entry] of arr) {
if (entry.start) {
const age = Date.now() - entry.start;
entry.start = this.#perf.now() - age;
}
this.set(key, entry.value, entry);
}
}
set(k, v, setOptions = {}) {
if (v === undefined) {
this.delete(k);
return this;
}
const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status, } = setOptions;
let { noUpdateTTL = this.noUpdateTTL } = setOptions;
const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
if (this.maxEntrySize && size > this.maxEntrySize) {
if (status) {
status.set = 'miss';
status.maxEntrySizeExceeded = true;
}
this.#delete(k, 'set');
return this;
}
let index = this.#size === 0 ? undefined : this.#keyMap.get(k);
if (index === undefined) {
index = (this.#size === 0 ? this.#tail
: this.#free.length !== 0 ? this.#free.pop()
: this.#size === this.#max ? this.#evict(false)
: this.#size);
this.#keyList[index] = k;
this.#valList[index] = v;
this.#keyMap.set(k, index);
this.#next[this.#tail] = index;
this.#prev[index] = this.#tail;
this.#tail = index;
this.#size++;
this.#addItemSize(index, size, status);
if (status)
status.set = 'add';
noUpdateTTL = false;
if (this.#hasOnInsert) {
this.#onInsert?.(v, k, 'add');
}
}
else {
this.#moveToTail(index);
const oldVal = this.#valList[index];
if (v !== oldVal) {
if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
oldVal.__abortController.abort(new Error('replaced'));
const { __staleWhileFetching: s } = oldVal;
if (s !== undefined && !noDisposeOnSet) {
if (this.#hasDispose) {
this.#dispose?.(s, k, 'set');
}
if (this.#hasDisposeAfter) {
this.#disposed?.push([s, k, 'set']);
}
}
}
else if (!noDisposeOnSet) {
if (this.#hasDispose) {
this.#dispose?.(oldVal, k, 'set');
}
if (this.#hasDisposeAfter) {
this.#disposed?.push([oldVal, k, 'set']);
}
}
this.#removeItemSize(index);
this.#addItemSize(index, size, status);
this.#valList[index] = v;
if (status) {
status.set = 'replace';
const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ?
oldVal.__staleWhileFetching
: oldVal;
if (oldValue !== undefined)
status.oldValue = oldValue;
}
}
else if (status) {
status.set = 'update';
}
if (this.#hasOnInsert) {
this.onInsert?.(v, k, v === oldVal ? 'update' : 'replace');
}
}
if (ttl !== 0 && !this.#ttls) {
this.#initializeTTLTracking();
}
if (this.#ttls) {
if (!noUpdateTTL) {
this.#setItemTTL(index, ttl, start);
}
if (status)
this.#statusTTL(status, index);
}
if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
const dt = this.#disposed;
let task;
while ((task = dt?.shift())) {
this.#disposeAfter?.(...task);
}
}
return this;
}
pop() {
try {
while (this.#size) {
const val = this.#valList[this.#head];
this.#evict(true);
if (this.#isBackgroundFetch(val)) {
if (val.__staleWhileFetching) {
return val.__staleWhileFetching;
}
}
else if (val !== undefined) {
return val;
}
}
}
finally {
if (this.#hasDisposeAfter && this.#disposed) {
const dt = this.#disposed;
let task;
while ((task = dt?.shift())) {
this.#disposeAfter?.(...task);
}
}
}
}
#evict(free) {
const head = this.#head;
const k = this.#keyList[head];
const v = this.#valList[head];
if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) {
v.__abortController.abort(new Error('evicted'));
}
else if (this.#hasDispose || this.#hasDisposeAfter) {
if (this.#hasDispose) {
this.#dispose?.(v, k, 'evict');
}
if (this.#hasDisposeAfter) {
this.#disposed?.push([v, k, 'evict']);
}
}
this.#removeItemSize(head);
if (free) {
this.#keyList[head] = undefined;
this.#valList[head] = undefined;
this.#free.push(head);
}
if (this.#size === 1) {
this.#head = this.#tail = 0;
this.#free.length = 0;
}
else {
this.#head = this.#next[head];
}
this.#keyMap.delete(k);
this.#size--;
return head;
}
has(k, hasOptions = {}) {
const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
const index = this.#keyMap.get(k);
if (index !== undefined) {
const v = this.#valList[index];
if (this.#isBackgroundFetch(v) &&
v.__staleWhileFetching === undefined) {
return false;
}
if (!this.#isStale(index)) {
if (updateAgeOnHas) {
this.#updateItemAge(index);
}
if (status) {
status.has = 'hit';
this.#statusTTL(status, index);
}
return true;
}
else if (status) {
status.has = 'stale';
this.#statusTTL(status, index);
}
}
else if (status) {
status.has = 'miss';
}
return false;
}
peek(k, peekOptions = {}) {
const { allowStale = this.allowStale } = peekOptions;
const index = this.#keyMap.get(k);
if (index === undefined ||
(!allowStale && this.#isStale(index))) {
return;
}
const v = this.#valList[index];
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
}
#backgroundFetch(k, index, options, context) {
const v = index === undefined ? undefined : this.#valList[index];
if (this.#isBackgroundFetch(v)) {
return v;
}
const ac = new AC();
const { signal } = options;
signal?.addEventListener('abort', () => ac.abort(signal.reason), {
signal: ac.signal,
});
const fetchOpts = {
signal: ac.signal,
options,
context,
};
const cb = (v, updateCache = false) => {
const { aborted } = ac.signal;
const ignoreAbort = options.ignoreFetchAbort && v !== undefined;
if (options.status) {
if (aborted && !updateCache) {
options.status.fetchAborted = true;
options.status.fetchError = ac.signal.reason;
if (ignoreAbort)
options.status.fetchAbortIgnored = true;
}
else {
options.status.fetchResolved = true;
}
}
if (aborted && !ignoreAbort && !updateCache) {
return fetchFail(ac.signal.reason);
}
const bf = p;
if (this.#valList[index] === p) {
if (v === undefined) {
if (bf.__staleWhileFetching !== undefined) {
this.#valList[index] = bf.__staleWhileFetching;
}
else {
this.#delete(k, 'fetch');
}
}
else {
if (options.status)
options.status.fetchUpdated = true;
this.set(k, v, fetchOpts.options);
}
}
return v;
};
const eb = (er) => {
if (options.status) {
options.status.fetchRejected = true;
options.status.fetchError = er;
}
return fetchFail(er);
};
const fetchFail = (er) => {
const { aborted } = ac.signal;
const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
const noDelete = allowStale || options.noDeleteOnFetchRejection;
const bf = p;
if (this.#valList[index] === p) {
const del = !noDelete || bf.__staleWhileFetching === undefined;
if (del) {
this.#delete(k, 'fetch');
}
else if (!allowStaleAborted) {
this.#valList[index] = bf.__staleWhileFetching;
}
}
if (allowStale) {
if (options.status && bf.__staleWhileFetching !== undefined) {
options.status.returnedStale = true;
}
return bf.__staleWhileFetching;
}
else if (bf.__returned === bf) {
throw er;
}
};
const pcall = (res, rej) => {
const fmp = this.#fetchMethod?.(k, v, fetchOpts);
if (fmp && fmp instanceof Promise) {
fmp.then(v => res(v === undefined ? undefined : v), rej);
}
ac.signal.addEventListener('abort', () => {
if (!options.ignoreFetchAbort ||
options.allowStaleOnFetchAbort) {
res(undefined);
if (options.allowStaleOnFetchAbort) {
res = v => cb(v, true);
}
}
});
};
if (options.status)
options.status.fetchDispatched = true;
const p = new Promise(pcall).then(cb, eb);
const bf = Object.assign(p, {
__abortController: ac,
__staleWhileFetching: v,
__returned: undefined,
});
if (index === undefined) {
this.set(k, bf, { ...fetchOpts.options, status: undefined });
index = this.#keyMap.get(k);
}
else {
this.#valList[index] = bf;
}
return bf;
}
#isBackgroundFetch(p) {
if (!this.#hasFetchMethod)
return false;
const b = p;
return (!!b &&
b instanceof Promise &&
b.hasOwnProperty('__staleWhileFetching') &&
b.__abortController instanceof AC);
}
async fetch(k, fetchOptions = {}) {
const {
allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet,
ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL,
noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context, forceRefresh = false, status, signal, } = fetchOptions;
if (!this.#hasFetchMethod) {
if (status)
status.fetch = 'get';
return this.get(k, {
allowStale,
updateAgeOnGet,
noDeleteOnStaleGet,
status,
});
}
const options = {
allowStale,
updateAgeOnGet,
noDeleteOnStaleGet,
ttl,
noDisposeOnSet,
size,
sizeCalculation,
noUpdateTTL,
noDeleteOnFetchRejection,
allowStaleOnFetchRejection,
allowStaleOnFetchAbort,
ignoreFetchAbort,
status,
signal,
};
let index = this.#keyMap.get(k);
if (index === undefined) {
if (status)
status.fetch = 'miss';
const p = this.#backgroundFetch(k, index, options, context);
return (p.__returned = p);
}
else {
const v = this.#valList[index];
if (this.#isBackgroundFetch(v)) {
const stale = allowStale && v.__staleWhileFetching !== undefined;
if (status) {
status.fetch = 'inflight';
if (stale)
status.returnedStale = true;
}
return stale ? v.__staleWhileFetching : (v.__returned = v);
}
const isStale = this.#isStale(index);
if (!forceRefresh && !isStale) {
if (status)
status.fetch = 'hit';
this.#moveToTail(index);
if (updateAgeOnGet) {
this.#updateItemAge(index);
}
if (status)
this.#statusTTL(status, index);
return v;
}
const p = this.#backgroundFetch(k, index, options, context);
const hasStale = p.__staleWhileFetching !== undefined;
const staleVal = hasStale && allowStale;
if (status) {
status.fetch = isStale ? 'stale' : 'refresh';
if (staleVal && isStale)
status.returnedStale = true;
}
return staleVal ? p.__staleWhileFetching : (p.__returned = p);
}
}
async forceFetch(k, fetchOptions = {}) {
const v = await this.fetch(k, fetchOptions);
if (v === undefined)
throw new Error('fetch() returned undefined');
return v;
}
memo(k, memoOptions = {}) {
const memoMethod = this.#memoMethod;
if (!memoMethod) {
throw new Error('no memoMethod provided to constructor');
}
const { context, forceRefresh, ...options } = memoOptions;
const v = this.get(k, options);
if (!forceRefresh && v !== undefined)
return v;
const vv = memoMethod(k, v, {
options,
context,
});
this.set(k, vv, options);
return vv;
}
get(k, getOptions = {}) {
const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status, } = getOptions;
const index = this.#keyMap.get(k);
if (index !== undefined) {
const value = this.#valList[index];
const fetching = this.#isBackgroundFetch(value);
if (status)
this.#statusTTL(status, index);
if (this.#isStale(index)) {
if (status)
status.get = 'stale';
if (!fetching) {
if (!noDeleteOnStaleGet) {
this.#delete(k, 'expire');
}
if (status && allowStale)
status.returnedStale = true;
return allowStale ? value : undefined;
}
else {
if (status &&
allowStale &&
value.__staleWhileFetching !== undefined) {
status.returnedStale = true;
}
return allowStale ? value.__staleWhileFetching : undefined;
}
}
else {
if (status)
status.get = 'hit';
if (fetching) {
return value.__staleWhileFetching;
}
this.#moveToTail(index);
if (updateAgeOnGet) {
this.#updateItemAge(index);
}
return value;
}
}
else if (status) {
status.get = 'miss';
}
}
#connect(p, n) {
this.#prev[n] = p;
this.#next[p] = n;
}
#moveToTail(index) {
if (index !== this.#tail) {
if (index === this.#head) {
this.#head = this.#next[index];
}
else {
this.#connect(this.#prev[index], this.#next[index]);
}
this.#connect(this.#tail, index);
this.#tail = index;
}
}
delete(k) {
return this.#delete(k, 'delete');
}
#delete(k, reason) {
let deleted = false;
if (this.#size !== 0) {
const index = this.#keyMap.get(k);
if (index !== undefined) {
deleted = true;
if (this.#size === 1) {
this.#clear(reason);
}
else {
this.#removeItemSize(index);
const v = this.#valList[index];
if (this.#isBackgroundFetch(v)) {
v.__abortController.abort(new Error('deleted'));
}
else if (this.#hasDispose || this.#hasDisposeAfter) {
if (this.#hasDispose) {
this.#dispose?.(v, k, reason);
}
if (this.#hasDisposeAfter) {
this.#disposed?.push([v, k, reason]);
}
}
this.#keyMap.delete(k);
this.#keyList[index] = undefined;
this.#valList[index] = undefined;
if (index === this.#tail) {
this.#tail = this.#prev[index];
}
else if (index === this.#head) {
this.#head = this.#next[index];
}
else {
const pi = this.#prev[index];
this.#next[pi] = this.#next[index];
const ni = this.#next[index];
this.#prev[ni] = this.#prev[index];
}
this.#size--;
this.#free.push(index);
}
}
}
if (this.#hasDisposeAfter && this.#disposed?.length) {
const dt = this.#disposed;
let task;
while ((task = dt?.shift())) {
this.#disposeAfter?.(...task);
}
}
return deleted;
}
clear() {
return this.#clear('delete');
}
#clear(reason) {
for (const index of this.#rindexes({ allowStale: true })) {
const v = this.#valList[index];
if (this.#isBackgroundFetch(v)) {
v.__abortController.abort(new Error('deleted'));
}
else {
const k = this.#keyList[index];
if (this.#hasDispose) {
this.#dispose?.(v, k, reason);
}
if (this.#hasDisposeAfter) {
this.#disposed?.push([v, k, reason]);
}
}
}
this.#keyMap.clear();
this.#valList.fill(undefined);
this.#keyList.fill(undefined);
if (this.#ttls && this.#starts) {
this.#ttls.fill(0);
this.#starts.fill(0);
}
if (this.#sizes) {
this.#sizes.fill(0);
}
this.#head = 0;
this.#tail = 0;
this.#free.length = 0;
this.#calculatedSize = 0;
this.#size = 0;
if (this.#hasDisposeAfter && this.#disposed) {
const dt = this.#disposed;
let task;
while ((task = dt?.shift())) {
this.#disposeAfter?.(...task);
}
}
}
}
commonjs.LRUCache = LRUCache;
return commonjs;
}
var hosts_1;
var hasRequiredHosts;
function requireHosts () {
if (hasRequiredHosts) return hosts_1;
hasRequiredHosts = 1;
const maybeJoin = (...args) => args.every(arg => arg) ? args.join('') : '';
const maybeEncode = (arg) => arg ? encodeURIComponent(arg) : '';
const formatHashFragment = (f) => f.toLowerCase()
.replace(/^\W+/g, '')
.replace(/(?<!\W)\W+$/, '')
.replace(/\//g, '')
.replace(/\W+/g, '-');
const defaults = {
sshtemplate: ({ domain, user, project, committish }) =>
`git@${domain}:${user}/${project}.git${maybeJoin('#', committish)}`,
sshurltemplate: ({ domain, user, project, committish }) =>
`git+ssh://git@${domain}/${user}/${project}.git${maybeJoin('#', committish)}`,
edittemplate: ({ domain, user, project, committish, editpath, path }) =>
`https://${domain}/${user}/${project}${maybeJoin('/', editpath, '/', maybeEncode(committish || 'HEAD'), '/', path)}`,
browsetemplate: ({ domain, user, project, committish, treepath }) =>
`https://${domain}/${user}/${project}${maybeJoin('/', treepath, '/', maybeEncode(committish))}`,
browsetreetemplate: ({ domain, user, project, committish, treepath, path, fragment, hashformat }) =>
`https://${domain}/${user}/${project}/${treepath}/${maybeEncode(committish || 'HEAD')}/${path}${maybeJoin('#', hashformat(fragment || ''))}`,
browseblobtemplate: ({ domain, user, project, committish, blobpath, path, fragment, hashformat }) =>
`https://${domain}/${user}/${project}/${blobpath}/${maybeEncode(committish || 'HEAD')}/${path}${maybeJoin('#', hashformat(fragment || ''))}`,
docstemplate: ({ domain, user, project, treepath, committish }) =>
`https://${domain}/${user}/${project}${maybeJoin('/', treepath, '/', maybeEncode(committish))}#readme`,
httpstemplate: ({ auth, domain, user, project, committish }) =>
`git+https://${maybeJoin(auth, '@')}${domain}/${user}/${project}.git${maybeJoin('#', committish)}`,
filetemplate: ({ domain, user, project, committish, path }) =>
`https://${domain}/${user}/${project}/raw/${maybeEncode(committish || 'HEAD')}/${path}`,
shortcuttemplate: ({ type, user, project, committish }) =>
`${type}:${user}/${project}${maybeJoin('#', committish)}`,
pathtemplate: ({ user, project, committish }) =>
`${user}/${project}${maybeJoin('#', committish)}`,
bugstemplate: ({ domain, user, project }) =>
`https://${domain}/${user}/${project}/issues`,
hashformat: formatHashFragment,
};
const hosts = {};
hosts.github = {
protocols: ['git:', 'http:', 'git+ssh:', 'git+https:', 'ssh:', 'https:'],
domain: 'github.com',
treepath: 'tree',
blobpath: 'blob',
editpath: 'edit',
filetemplate: ({ auth, user, project, committish, path }) =>
`https://${maybeJoin(auth, '@')}raw.githubusercontent.com/${user}/${project}/${maybeEncode(committish || 'HEAD')}/${path}`,
gittemplate: ({ auth, domain, user, project, committish }) =>
`git://${maybeJoin(auth, '@')}${domain}/${user}/${project}.git${maybeJoin('#', committish)}`,
tarballtemplate: ({ domain, user, project, committish }) =>
`https://codeload.${domain}/${user}/${project}/tar.gz/${maybeEncode(committish || 'HEAD')}`,
extract: (url) => {
let [, user, project, type, committish] = url.pathname.split('/', 5);
if (type && type !== 'tree') {
return
}
if (!type) {
committish = url.hash.slice(1);
}
if (project && project.endsWith('.git')) {
project = project.slice(0, -4);
}
if (!user || !project) {
return
}
return { user, project, committish }
},
};
hosts.bitbucket = {
protocols: ['git+ssh:', 'git+https:', 'ssh:', 'https:'],
domain: 'bitbucket.org',
treepath: 'src',
blobpath: 'src',
editpath: '?mode=edit',
edittemplate: ({ domain, user, project, committish, treepath, path, editpath }) =>
`https://${domain}/${user}/${project}${maybeJoin('/', treepath, '/', maybeEncode(committish || 'HEAD'), '/', path, editpath)}`,
tarballtemplate: ({ domain, user, project, committish }) =>
`https://${domain}/${user}/${project}/get/${maybeEncode(committish || 'HEAD')}.tar.gz`,
extract: (url) => {
let [, user, project, aux] = url.pathname.split('/', 4);
if (['get'].includes(aux)) {
return
}
if (project && project.endsWith('.git')) {
project = project.slice(0, -4);
}
if (!user || !project) {
return
}
return { user, project, committish: url.hash.slice(1) }
},
};
hosts.gitlab = {
protocols: ['git+ssh:', 'git+https:', 'ssh:', 'https:'],
domain: 'gitlab.com',
treepath: 'tree',
blobpath: 'tree',
editpath: '-/edit',
httpstemplate: ({ auth, domain, user, project, committish }) =>
`git+https://${maybeJoin(auth, '@')}${domain}/${user}/${project}.git${maybeJoin('#', committish)}`,
tarballtemplate: ({ domain, user, project, committish }) =>
`https://${domain}/${user}/${project}/repository/archive.tar.gz?ref=${maybeEncode(committish || 'HEAD')}`,
extract: (url) => {
const path = url.pathname.slice(1);
if (path.includes('/-/') || path.includes('/archive.tar.gz')) {
return
}
const segments = path.split('/');
let project = segments.pop();
if (project.endsWith('.git')) {
project = project.slice(0, -4);
}
const user = segments.join('/');
if (!user || !project) {
return
}
return { user, project, committish: url.hash.slice(1) }
},
};
hosts.gist = {
protocols: ['git:', 'git+ssh:', 'git+https:', 'ssh:', 'https:'],
domain: 'gist.github.com',
editpath: 'edit',
sshtemplate: ({ domain, project, committish }) =>
`git@${domain}:${project}.git${maybeJoin('#', committish)}`,
sshurltemplate: ({ domain, project, committish }) =>
`git+ssh://git@${domain}/${project}.git${maybeJoin('#', committish)}`,
edittemplate: ({ domain, user, project, committish, editpath }) =>
`https://${domain}/${user}/${project}${maybeJoin('/', maybeEncode(committish))}/${editpath}`,
browsetemplate: ({ domain, project, committish }) =>
`https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}`,
browsetreetemplate: ({ domain, project, committish, path, hashformat }) =>
`https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}${maybeJoin('#', hashformat(path))}`,
browseblobtemplate: ({ domain, project, committish, path, hashformat }) =>
`https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}${maybeJoin('#', hashformat(path))}`,
docstemplate: ({ domain, project, committish }) =>
`https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}`,
httpstemplate: ({ domain, project, committish }) =>
`git+https://${domain}/${project}.git${maybeJoin('#', committish)}`,
filetemplate: ({ user, project, committish, path }) =>
`https://gist.githubusercontent.com/${user}/${project}/raw${maybeJoin('/', maybeEncode(committish))}/${path}`,
shortcuttemplate: ({ type, project, committish }) =>
`${type}:${project}${maybeJoin('#', committish)}`,
pathtemplate: ({ project, committish }) =>
`${project}${maybeJoin('#', committish)}`,
bugstemplate: ({ domain, project }) =>
`https://${domain}/${project}`,
gittemplate: ({ domain, project, committish }) =>
`git://${domain}/${project}.git${maybeJoin('#', committish)}`,
tarballtemplate: ({ project, committish }) =>
`https://codeload.github.com/gist/${project}/tar.gz/${maybeEncode(committish || 'HEAD')}`,
extract: (url) => {
let [, user, project, aux] = url.pathname.split('/', 4);
if (aux === 'raw') {
return
}
if (!project) {
if (!user) {
return
}
project = user;
user = null;
}
if (project.endsWith('.git')) {
project = project.slice(0, -4);
}
return { user, project, committish: url.hash.slice(1) }
},
hashformat: function (fragment) {
return fragment && 'file-' + formatHashFragment(fragment)
},
};
hosts.sourcehut = {
protocols: ['git+ssh:', 'https:'],
domain: 'git.sr.ht',
treepath: 'tree',
blobpath: 'tree',
filetemplate: ({ domain, user, project, committish, path }) =>
`https://${domain}/${user}/${project}/blob/${maybeEncode(committish) || 'HEAD'}/${path}`,
httpstemplate: ({ domain, user, project, committish }) =>
`https://${domain}/${user}/${project}.git${maybeJoin('#', committish)}`,
tarballtemplate: ({ domain, user, project, committish }) =>
`https://${domain}/${user}/${project}/archive/${maybeEncode(committish) || 'HEAD'}.tar.gz`,
bugstemplate: () => null,
extract: (url) => {
let [, user, project, aux] = url.pathname.split('/', 4);
if (['archive'].includes(aux)) {
return
}
if (project && project.endsWith('.git')) {
project = project.slice(0, -4);
}
if (!user || !project) {
return
}
return { user, project, committish: url.hash.slice(1) }
},
};
for (const [name, host] of Object.entries(hosts)) {
hosts[name] = Object.assign({}, defaults, host);
}
hosts_1 = hosts;
return hosts_1;
}
var parseUrl;
var hasRequiredParseUrl;
function requireParseUrl () {
if (hasRequiredParseUrl) return parseUrl;
hasRequiredParseUrl = 1;
const url = require$$0;
const lastIndexOfBefore = (str, char, beforeChar) => {
const startPosition = str.indexOf(beforeChar);
return str.lastIndexOf(char, startPosition > -1 ? startPosition : Infinity)
};
const safeUrl = (u) => {
try {
return new url.URL(u)
} catch {
}
};
const correctProtocol = (arg, protocols) => {
const firstColon = arg.indexOf(':');
const proto = arg.slice(0, firstColon + 1);
if (Object.prototype.hasOwnProperty.call(protocols, proto)) {
return arg
}
const firstAt = arg.indexOf('@');
if (firstAt > -1) {
if (firstAt > firstColon) {
return `git+ssh://${arg}`
} else {
return arg
}
}
const doubleSlash = arg.indexOf('//');
if (doubleSlash === firstColon + 1) {
return arg
}
return `${arg.slice(0, firstColon + 1)}//${arg.slice(firstColon + 1)}`
};
const correctUrl = (giturl) => {
const firstAt = lastIndexOfBefore(giturl, '@', '#');
const lastColonBeforeHash = lastIndexOfBefore(giturl, ':', '#');
if (lastColonBeforeHash > firstAt) {
giturl = giturl.slice(0, lastColonBeforeHash) + '/' + giturl.slice(lastColonBeforeHash + 1);
}
if (lastIndexOfBefore(giturl, ':', '#') === -1 && giturl.indexOf('//') === -1) {
giturl = `git+ssh://${giturl}`;
}
return giturl
};
parseUrl = (giturl, protocols) => {
const withProtocol = protocols ? correctProtocol(giturl, protocols) : giturl;
return safeUrl(withProtocol) || safeUrl(correctUrl(withProtocol))
};
return parseUrl;
}
var fromUrl;
var hasRequiredFromUrl;
function requireFromUrl () {
if (hasRequiredFromUrl) return fromUrl;
hasRequiredFromUrl = 1;
const parseUrl = requireParseUrl();
const isGitHubShorthand = (arg) => {
const firstHash = arg.indexOf('#');
const firstSlash = arg.indexOf('/');
const secondSlash = arg.indexOf('/', firstSlash + 1);
const firstColon = arg.indexOf(':');
const firstSpace = /\s/.exec(arg);
const firstAt = arg.indexOf('@');
const spaceOnlyAfterHash = !firstSpace || (firstHash > -1 && firstSpace.index > firstHash);
const atOnlyAfterHash = firstAt === -1 || (firstHash > -1 && firstAt > firstHash);
const colonOnlyAfterHash = firstColon === -1 || (firstHash > -1 && firstColon > firstHash);
const secondSlashOnlyAfterHash = secondSlash === -1 || (firstHash > -1 && secondSlash > firstHash);
const hasSlash = firstSlash > 0;
const doesNotEndWithSlash = firstHash > -1 ? arg[firstHash - 1] !== '/' : !arg.endsWith('/');
const doesNotStartWithDot = !arg.startsWith('.');
return spaceOnlyAfterHash && hasSlash && doesNotEndWithSlash &&
doesNotStartWithDot && atOnlyAfterHash && colonOnlyAfterHash &&
secondSlashOnlyAfterHash
};
fromUrl = (giturl, opts, { gitHosts, protocols }) => {
if (!giturl) {
return
}
const correctedUrl = isGitHubShorthand(giturl) ? `github:${giturl}` : giturl;
const parsed = parseUrl(correctedUrl, protocols);
if (!parsed) {
return
}
const gitHostShortcut = gitHosts.byShortcut[parsed.protocol];
const gitHostDomain = gitHosts.byDomain[parsed.hostname.startsWith('www.')
? parsed.hostname.slice(4)
: parsed.hostname];
const gitHostName = gitHostShortcut || gitHostDomain;
if (!gitHostName) {
return
}
const gitHostInfo = gitHosts[gitHostShortcut || gitHostDomain];
let auth = null;
if (protocols[parsed.protocol]?.auth && (parsed.username || parsed.password)) {
auth = `${parsed.username}${parsed.password ? ':' + parsed.password : ''}`;
}
let committish = null;
let user = null;
let project = null;
let defaultRepresentation = null;
try {
if (gitHostShortcut) {
let pathname = parsed.pathname.startsWith('/') ? parsed.pathname.slice(1) : parsed.pathname;
const firstAt = pathname.indexOf('@');
if (firstAt > -1) {
pathname = pathname.slice(firstAt + 1);
}
const lastSlash = pathname.lastIndexOf('/');
if (lastSlash > -1) {
user = decodeURIComponent(pathname.slice(0, lastSlash));
if (!user) {
user = null;
}
project = decodeURIComponent(pathname.slice(lastSlash + 1));
} else {
project = decodeURIComponent(pathname);
}
if (project.endsWith('.git')) {
project = project.slice(0, -4);
}
if (parsed.hash) {
committish = decodeURIComponent(parsed.hash.slice(1));
}
defaultRepresentation = 'shortcut';
} else {
if (!gitHostInfo.protocols.includes(parsed.protocol)) {
return
}
const segments = gitHostInfo.extract(parsed);
if (!segments) {
return
}
user = segments.user && decodeURIComponent(segments.user);
project = decodeURIComponent(segments.project);
committish = decodeURIComponent(segments.committish);
defaultRepresentation = protocols[parsed.protocol]?.name || parsed.protocol.slice(0, -1);
}
} catch (err) {
if (err instanceof URIError) {
return
} else {
throw err
}
}
return [gitHostName, user, auth, project, committish, defaultRepresentation, opts]
};
return fromUrl;
}
var lib;
var hasRequiredLib;
function requireLib () {
if (hasRequiredLib) return lib;
hasRequiredLib = 1;
const { LRUCache } = requireCommonjs();
const hosts = requireHosts();
const fromUrl = requireFromUrl();
const parseUrl = requireParseUrl();
const cache = new LRUCache({ max: 1000 });
function unknownHostedUrl (url) {
try {
const {
protocol,
hostname,
pathname,
} = new URL(url);
if (!hostname) {
return null
}
const proto = /(?:git\+)http:$/.test(protocol) ? 'http:' : 'https:';
const path = pathname.replace(/\.git$/, '');
return `${proto}//${hostname}${path}`
} catch {
return null
}
}
class GitHost {
constructor (type, user, auth, project, committish, defaultRepresentation, opts = {}) {
Object.assign(this, GitHost.#gitHosts[type], {
type,
user,
auth,
project,
committish,
default: defaultRepresentation,
opts,
});
}
static #gitHosts = { byShortcut: {}, byDomain: {} }
static #protocols = {
'git+ssh:': { name: 'sshurl' },
'ssh:': { name: 'sshurl' },
'git+https:': { name: 'https', auth: true },
'git:': { auth: true },
'http:': { auth: true },
'https:': { auth: true },
'git+http:': { auth: true },
}
static addHost (name, host) {
GitHost.#gitHosts[name] = host;
GitHost.#gitHosts.byDomain[host.domain] = name;
GitHost.#gitHosts.byShortcut[`${name}:`] = name;
GitHost.#protocols[`${name}:`] = { name };
}
static fromUrl (giturl, opts) {
if (typeof giturl !== 'string') {
return
}
const key = giturl + JSON.stringify(opts || {});
if (!cache.has(key)) {
const hostArgs = fromUrl(giturl, opts, {
gitHosts: GitHost.#gitHosts,
protocols: GitHost.#protocols,
});
cache.set(key, hostArgs ? new GitHost(...hostArgs) : undefined);
}
return cache.get(key)
}
static fromManifest (manifest, opts = {}) {
if (!manifest || typeof manifest !== 'object') {
return
}
const r = manifest.repository;
const rurl = r && (
typeof r === 'string'
? r
: typeof r === 'object' && typeof r.url === 'string'
? r.url
: null
);
if (!rurl) {
throw new Error('no repository')
}
const info = (rurl && GitHost.fromUrl(rurl.replace(/^git\+/, ''), opts)) || null;
if (info) {
return info
}
const unk = unknownHostedUrl(rurl);
return GitHost.fromUrl(unk, opts) || unk
}
static parseUrl (url) {
return parseUrl(url)
}
#fill (template, opts) {
if (typeof template !== 'function') {
return null
}
const options = { ...this, ...this.opts, ...opts };
if (!options.path) {
options.path = '';
}
if (options.path.startsWith('/')) {
options.path = options.path.slice(1);
}
if (options.noCommittish) {
options.committish = null;
}
const result = template(options);
return options.noGitPlus && result.startsWith('git+') ? result.slice(4) : result
}
hash () {
return this.committish ? `#${this.committish}` : ''
}
ssh (opts) {
return this.#fill(this.sshtemplate, opts)
}
sshurl (opts) {
return this.#fill(this.sshurltemplate, opts)
}
browse (path, ...args) {
if (typeof path !== 'string') {
return this.#fill(this.browsetemplate, path)
}
if (typeof args[0] !== 'string') {
return this.#fill(this.browsetreetemplate, { ...args[0], path })
}
return this.#fill(this.browsetreetemplate, { ...args[1], fragment: args[0], path })
}
browseFile (path, ...args) {
if (typeof args[0] !== 'string') {
return this.#fill(this.browseblobtemplate, { ...args[0], path })
}
return this.#fill(this.browseblobtemplate, { ...args[1], fragment: args[0], path })
}
docs (opts) {
return this.#fill(this.docstemplate, opts)
}
bugs (opts) {
return this.#fill(this.bugstemplate, opts)
}
https (opts) {
return this.#fill(this.httpstemplate, opts)
}
git (opts) {
return this.#fill(this.gittemplate, opts)
}
shortcut (opts) {
return this.#fill(this.shortcuttemplate, opts)
}
path (opts) {
return this.#fill(this.pathtemplate, opts)
}
tarball (opts) {
return this.#fill(this.tarballtemplate, { ...opts, noCommittish: false })
}
file (path, opts) {
return this.#fill(this.filetemplate, { ...opts, path })
}
edit (path, opts) {
return this.#fill(this.edittemplate, { ...opts, path })
}
getDefaultRepresentation () {
return this.default
}
toString (opts) {
if (this.default && typeof this[this.default] === 'function') {
return this[this.default](opts)
}
return this.sshurl(opts)
}
}
for (const [name, host] of Object.entries(hosts)) {
GitHost.addHost(name, host);
}
lib = GitHost;
return lib;
}
var extract_description;
var hasRequiredExtract_description;
function requireExtract_description () {
if (hasRequiredExtract_description) return extract_description;
hasRequiredExtract_description = 1;
extract_description = extractDescription;
function extractDescription (d) {
if (!d) {
return
}
if (d === 'ERROR: No README data found!') {
return
}
d = d.trim().split('\n');
let s = 0;
while (d[s] && d[s].trim().match(/^(#|$)/)) {
s++;
}
const l = d.length;
let e = s + 1;
while (e < l && d[e].trim()) {
e++;
}
return d.slice(s, e).join(' ').trim()
}
return extract_description;
}
var 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"
};
var bugs = {
web: "url",
name: "url"
};
var script = {
server: "start",
tests: "test"
};
const require$$7 = {
topLevel: topLevel,
bugs: bugs,
script: script
};
var fixer;
var hasRequiredFixer;
function requireFixer () {
if (hasRequiredFixer) return fixer;
hasRequiredFixer = 1;
var { URL } = require$$0$1;
var isValidSemver = requireValid();
var cleanSemver = requireClean();
var validateLicense = requireValidateNpmPackageLicense();
var hostedGitInfo = requireLib();
var { isBuiltin } = require$$5;
var depTypes = ['dependencies', 'devDependencies', 'optionalDependencies'];
var extractDescription = requireExtract_description();
var typos = require$$7;
var isEmail = str => str.includes('@') && (str.indexOf('@') < str.lastIndexOf('.'));
fixer = {
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 (Object.prototype.hasOwnProperty.call(data, 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 (filtered) {
if (!filtered || typeof filtered !== 'string') {
this.warn('nonStringBundleDependency', filtered);
return false
} else {
if (!data.dependencies) {
data.dependencies = {};
}
if (!Object.prototype.hasOwnProperty.call(data.dependencies, filtered)) {
this.warn('nonDependencyBundleDependency', filtered);
data.dependencies[filtered] = '*';
}
return true
}
}, this);
}
},
fixDependencies: function (data) {
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 (!isValidSemver(data.version, loose)) {
throw new Error('Invalid version: "' + data.version + '"')
}
data.version = cleanSemver(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 (isBuiltin(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 === undefined) {
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) {
if (typeof data.bugs === 'string') {
if (isEmail(data.bugs)) {
data.bugs = { email: data.bugs };
} else if (URL.canParse(data.bugs)) {
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 (URL.canParse(oldBugs.url)) {
data.bugs.url = oldBugs.url;
} else {
this.warn('nonUrlBugsUrlField');
}
}
if (oldBugs.email) {
if (typeof (oldBugs.email) === 'string' && isEmail(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.canParse(data.homepage)) {
data.homepage = 'http://' + data.homepage;
}
},
fixLicenseField: function (data) {
const license = data.license || data.licence;
if (!license) {
return this.warn('missingLicense')
}
if (
typeof (license) !== 'string' ||
license.length < 1 ||
license.trim() === ''
) {
return this.warn('invalidLicense')
}
if (!validateLicense(license).validForNewPackages) {
return 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])
}
function isCorrectlyEncodedName (spec) {
return !spec.match(/[/@\s+%:]/) &&
spec === encodeURIComponent(spec)
}
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))
}
}
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
}
function unParsePerson (person) {
if (typeof person === 'string') {
return person
}
var name = person.name || '';
var u = person.url || person.web;
var wrappedUrl = u ? (' (' + u + ')') : '';
var e = person.email || person.mail;
var wrappedEmail = e ? (' <' + e + '>') : '';
return name + wrappedEmail + wrappedUrl
}
function parsePerson (person) {
if (typeof person !== 'string') {
return person
}
var matchedName = person.match(/^([^(<]+)/);
var matchedUrl = person.match(/\(([^()]+)\)/);
var matchedEmail = person.match(/<([^<>]+)>/);
var obj = {};
if (matchedName && matchedName[0].trim()) {
obj.name = matchedName[0].trim();
}
if (matchedEmail) {
obj.email = matchedEmail[1];
}
if (matchedUrl) {
obj.url = matchedUrl[1];
}
return obj
}
function addOptionalDepsToDeps (data) {
var o = data.optionalDependencies;
if (!o) {
return
}
var d = data.dependencies || {};
Object.keys(o).forEach(function (k) {
d[k] = o[k];
});
data.dependencies = d;
}
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
}
function objectifyDeps (data, warn) {
depTypes.forEach(function (type) {
if (!data[type]) {
return
}
data[type] = depObjectify(data[type], type, warn);
});
}
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];
}
});
}
return fixer;
}
var repositories = "'repositories' (plural) Not supported. Please pick one as the 'repository' field";
var missingRepository = "No repository field.";
var brokenGitUrl = "Probably broken git url: %s";
var nonObjectScripts = "scripts must be an object";
var nonStringScript = "script values must be string commands";
var nonArrayFiles = "Invalid 'files' member";
var invalidFilename = "Invalid filename in 'files' list: %s";
var nonArrayBundleDependencies = "Invalid 'bundleDependencies' list. Must be array of package names";
var nonStringBundleDependency = "Invalid bundleDependencies member: %s";
var nonDependencyBundleDependency = "Non-dependency in bundleDependencies: %s";
var nonObjectDependencies = "%s field must be an object";
var nonStringDependency = "Invalid dependency: %s %s";
var deprecatedArrayDependencies = "specifying %s as array is deprecated";
var deprecatedModules = "modules field is deprecated";
var nonArrayKeywords = "keywords should be an array of strings";
var nonStringKeyword = "keywords should be an array of strings";
var conflictingName = "%s is also the name of a node core module.";
var nonStringDescription = "'description' field should be a string";
var missingDescription = "No description";
var missingReadme = "No README data";
var missingLicense = "No license field.";
var nonEmailUrlBugsString = "Bug string field must be url, email, or {email,url}";
var nonUrlBugsUrlField = "bugs.url field must be a string url. Deleted.";
var nonEmailBugsEmailField = "bugs.email field must be a string email. Deleted.";
var emptyNormalizedBugs = "Normalized value of bugs field is an empty object. Deleted.";
var nonUrlHomepage = "homepage field must be a string url. Deleted.";
var invalidLicense = "license should be a valid SPDX license expression";
var typo = "%s should probably be %s.";
const require$$1 = {
repositories: repositories,
missingRepository: missingRepository,
brokenGitUrl: brokenGitUrl,
nonObjectScripts: nonObjectScripts,
nonStringScript: nonStringScript,
nonArrayFiles: nonArrayFiles,
invalidFilename: invalidFilename,
nonArrayBundleDependencies: nonArrayBundleDependencies,
nonStringBundleDependency: nonStringBundleDependency,
nonDependencyBundleDependency: nonDependencyBundleDependency,
nonObjectDependencies: nonObjectDependencies,
nonStringDependency: nonStringDependency,
deprecatedArrayDependencies: deprecatedArrayDependencies,
deprecatedModules: deprecatedModules,
nonArrayKeywords: nonArrayKeywords,
nonStringKeyword: nonStringKeyword,
conflictingName: conflictingName,
nonStringDescription: nonStringDescription,
missingDescription: missingDescription,
missingReadme: missingReadme,
missingLicense: missingLicense,
nonEmailUrlBugsString: nonEmailUrlBugsString,
nonUrlBugsUrlField: nonUrlBugsUrlField,
nonEmailBugsEmailField: nonEmailBugsEmailField,
emptyNormalizedBugs: emptyNormalizedBugs,
nonUrlHomepage: nonUrlHomepage,
invalidLicense: invalidLicense,
typo: typo
};
var make_warning;
var hasRequiredMake_warning;
function requireMake_warning () {
if (hasRequiredMake_warning) return make_warning;
hasRequiredMake_warning = 1;
var util = require$$0$2;
var messages = require$$1;
make_warning = 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)
}
return make_warning;
}
var normalize_1;
var hasRequiredNormalize;
function requireNormalize () {
if (hasRequiredNormalize) return normalize_1;
hasRequiredNormalize = 1;
normalize_1 = normalize;
var fixer = requireFixer();
normalize.fixer = fixer;
var makeWarning = requireMake_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 = function () { };
}
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;
}
function ucFirst (string) {
return string.charAt(0).toUpperCase() + string.slice(1)
}
return normalize_1;
}
var normalizeExports = requireNormalize();
const normalizePackageData = getDefaultExportFromCjs(normalizeExports);
promisify(execFile);
function toPath(urlOrPath) {
return urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
}
const getPackagePath = cwd => path.resolve(toPath(cwd) ?? '.', 'package.json');
const _readPackage = (file, normalize) => {
const json = typeof file === 'string'
? parseJson(file)
: file;
if (normalize) {
normalizePackageData(json);
}
return json;
};
function readPackageSync({cwd, normalize = true} = {}) {
const packageFile = fs.readFileSync(getPackagePath(cwd), 'utf8');
return _readPackage(packageFile, normalize);
}
function readPackageUpSync(options) {
const filePath = findUpSync('package.json', options);
if (!filePath) {
return;
}
return {
packageJson: readPackageSync({...options, cwd: path.dirname(filePath)}),
path: filePath,
};
}
const handlePreserveConsecutiveUppercase = (decamelized, separator) => {
decamelized = decamelized.replace(
/((?<![\p{Uppercase_Letter}\d])[\p{Uppercase_Letter}\d](?![\p{Uppercase_Letter}\d]))/gu,
$0 => $0.toLowerCase(),
);
return decamelized.replace(
/(?<!\p{Uppercase_Letter})(\p{Uppercase_Letter}+)(\p{Uppercase_Letter}\p{Lowercase_Letter}+)/gu,
(_, $1, $2) => $1 + separator + $2.toLowerCase(),
);
};
function decamelize(
text,
{
separator = '_',
preserveConsecutiveUppercase = false,
} = {},
) {
if (!(typeof text === 'string' && typeof separator === 'string')) {
throw new TypeError(
'The `text` and `separator` arguments should be of type `string`',
);
}
if (text.length < 2) {
return preserveConsecutiveUppercase ? text : text.toLowerCase();
}
const replacement = `$1${separator}$2`;
const decamelized = text.replace(
/([\p{Lowercase_Letter}\d])(\p{Uppercase_Letter})/gu,
replacement,
);
if (preserveConsecutiveUppercase) {
return handlePreserveConsecutiveUppercase(decamelized, separator);
}
return decamelized
.replace(
/(\p{Uppercase_Letter})(\p{Uppercase_Letter}\p{Lowercase_Letter}+)/gu,
replacement,
)
.toLowerCase();
}
var minimistOptions = {exports: {}};
var isPlainObj;
var hasRequiredIsPlainObj;
function requireIsPlainObj () {
if (hasRequiredIsPlainObj) return isPlainObj;
hasRequiredIsPlainObj = 1;
var toString = Object.prototype.toString;
isPlainObj = function (x) {
var prototype;
return toString.call(x) === '[object Object]' && (prototype = Object.getPrototypeOf(x), prototype === null || prototype === Object.getPrototypeOf({}));
};
return isPlainObj;
}
var arrify;
var hasRequiredArrify;
function requireArrify () {
if (hasRequiredArrify) return arrify;
hasRequiredArrify = 1;
arrify = function (val) {
if (val === null || val === undefined) {
return [];
}
return Array.isArray(val) ? val : [val];
};
return arrify;
}
var kindOf;
var hasRequiredKindOf;
function requireKindOf () {
if (hasRequiredKindOf) return kindOf;
hasRequiredKindOf = 1;
var toString = Object.prototype.toString;
kindOf = function kindOf(val) {
if (val === void 0) return 'undefined';
if (val === null) return 'null';
var type = typeof val;
if (type === 'boolean') return 'boolean';
if (type === 'string') return 'string';
if (type === 'number') return 'number';
if (type === 'symbol') return 'symbol';
if (type === 'function') {
return isGeneratorFn(val) ? 'generatorfunction' : 'function';
}
if (isArray(val)) return 'array';
if (isBuffer(val)) return 'buffer';
if (isArguments(val)) return 'arguments';
if (isDate(val)) return 'date';
if (isError(val)) return 'error';
if (isRegexp(val)) return 'regexp';
switch (ctorName(val)) {
case 'Symbol': return 'symbol';
case 'Promise': return 'promise';
case 'WeakMap': return 'weakmap';
case 'WeakSet': return 'weakset';
case 'Map': return 'map';
case 'Set': return 'set';
case 'Int8Array': return 'int8array';
case 'Uint8Array': return 'uint8array';
case 'Uint8ClampedArray': return 'uint8clampedarray';
case 'Int16Array': return 'int16array';
case 'Uint16Array': return 'uint16array';
case 'Int32Array': return 'int32array';
case 'Uint32Array': return 'uint32array';
case 'Float32Array': return 'float32array';
case 'Float64Array': return 'float64array';
}
if (isGeneratorObj(val)) {
return 'generator';
}
type = toString.call(val);
switch (type) {
case '[object Object]': return 'object';
case '[object Map Iterator]': return 'mapiterator';
case '[object Set Iterator]': return 'setiterator';
case '[object String Iterator]': return 'stringiterator';
case '[object Array Iterator]': return 'arrayiterator';
}
return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
};
function ctorName(val) {
return typeof val.constructor === 'function' ? val.constructor.name : null;
}
function isArray(val) {
if (Array.isArray) return Array.isArray(val);
return val instanceof Array;
}
function isError(val) {
return val instanceof Error || (typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number');
}
function isDate(val) {
if (val instanceof Date) return true;
return typeof val.toDateString === 'function'
&& typeof val.getDate === 'function'
&& typeof val.setDate === 'function';
}
function isRegexp(val) {
if (val instanceof RegExp) return true;
return typeof val.flags === 'string'
&& typeof val.ignoreCase === 'boolean'
&& typeof val.multiline === 'boolean'
&& typeof val.global === 'boolean';
}
function isGeneratorFn(name, val) {
return ctorName(name) === 'GeneratorFunction';
}
function isGeneratorObj(val) {
return typeof val.throw === 'function'
&& typeof val.return === 'function'
&& typeof val.next === 'function';
}
function isArguments(val) {
try {
if (typeof val.length === 'number' && typeof val.callee === 'function') {
return true;
}
} catch (err) {
if (err.message.indexOf('callee') !== -1) {
return true;
}
}
return false;
}
function isBuffer(val) {
if (val.constructor && typeof val.constructor.isBuffer === 'function') {
return val.constructor.isBuffer(val);
}
return false;
}
return kindOf;
}
var hasRequiredMinimistOptions;
function requireMinimistOptions () {
if (hasRequiredMinimistOptions) return minimistOptions.exports;
hasRequiredMinimistOptions = 1;
const isPlainObject = requireIsPlainObj();
const arrify = requireArrify();
const kindOf = requireKindOf();
const push = (obj, prop, value) => {
if (!obj[prop]) {
obj[prop] = [];
}
obj[prop].push(value);
};
const insert = (obj, prop, key, value) => {
if (!obj[prop]) {
obj[prop] = {};
}
obj[prop][key] = value;
};
const prettyPrint = output => {
return Array.isArray(output) ?
`[${output.map(prettyPrint).join(', ')}]` :
kindOf(output) === 'string' ? JSON.stringify(output) : output;
};
const resolveType = value => {
if (Array.isArray(value) && value.length > 0) {
const [element] = value;
return `${kindOf(element)}-array`;
}
return kindOf(value);
};
const normalizeExpectedType = (type, defaultValue) => {
const inferredType = type === 'array' ? 'string-array' : type;
if (arrayTypes.includes(inferredType) && Array.isArray(defaultValue) && defaultValue.length === 0) {
return 'array';
}
return inferredType;
};
const passthroughOptions = ['stopEarly', 'unknown', '--'];
const primitiveTypes = ['string', 'boolean', 'number'];
const arrayTypes = primitiveTypes.map(t => `${t}-array`);
const availableTypes = [...primitiveTypes, 'array', ...arrayTypes];
const buildOptions = options => {
options = options || {};
const result = {};
passthroughOptions.forEach(key => {
if (options[key]) {
result[key] = options[key];
}
});
Object.keys(options).forEach(key => {
let value = options[key];
if (key === 'arguments') {
key = '_';
}
if (typeof value === 'string') {
value = {type: value};
}
if (isPlainObject(value)) {
const props = value;
const {type} = props;
if (type) {
if (!availableTypes.includes(type)) {
throw new TypeError(`Expected type of "${key}" to be one of ${prettyPrint(availableTypes)}, got ${prettyPrint(type)}`);
}
if (arrayTypes.includes(type)) {
const [elementType] = type.split('-');
push(result, 'array', {key, [elementType]: true});
} else {
push(result, type, key);
}
}
if ({}.hasOwnProperty.call(props, 'default')) {
const {default: defaultValue} = props;
const defaultType = resolveType(defaultValue);
const expectedType = normalizeExpectedType(type, defaultValue);
if (expectedType && expectedType !== defaultType) {
throw new TypeError(`Expected "${key}" default value to be of type "${expectedType}", got ${prettyPrint(defaultType)}`);
}
insert(result, 'default', key, defaultValue);
}
arrify(props.alias).forEach(alias => {
insert(result, 'alias', alias, key);
});
}
});
return result;
};
minimistOptions.exports = buildOptions;
minimistOptions.exports.default = buildOptions;
return minimistOptions.exports;
}
var minimistOptionsExports = requireMinimistOptions();
const constructParserOptions = getDefaultExportFromCjs(minimistOptionsExports);
var mapObj = {exports: {}};
var hasRequiredMapObj;
function requireMapObj () {
if (hasRequiredMapObj) return mapObj.exports;
hasRequiredMapObj = 1;
const isObject = value => typeof value === 'object' && value !== null;
const mapObjectSkip = Symbol('skip');
const isObjectCustom = value =>
isObject(value) &&
!(value instanceof RegExp) &&
!(value instanceof Error) &&
!(value instanceof Date);
const mapObject = (object, mapper, options, isSeen = new WeakMap()) => {
options = {
deep: false,
target: {},
...options
};
if (isSeen.has(object)) {
return isSeen.get(object);
}
isSeen.set(object, options.target);
const {target} = options;
delete options.target;
const mapArray = array => array.map(element => isObjectCustom(element) ? mapObject(element, mapper, options, isSeen) : element);
if (Array.isArray(object)) {
return mapArray(object);
}
for (const [key, value] of Object.entries(object)) {
const mapResult = mapper(key, value, object);
if (mapResult === mapObjectSkip) {
continue;
}
let [newKey, newValue, {shouldRecurse = true} = {}] = mapResult;
if (newKey === '__proto__') {
continue;
}
if (options.deep && shouldRecurse && isObjectCustom(newValue)) {
newValue = Array.isArray(newValue) ?
mapArray(newValue) :
mapObject(newValue, mapper, options, isSeen);
}
target[newKey] = newValue;
}
return target;
};
mapObj.exports = (object, mapper, options) => {
if (!isObject(object)) {
throw new TypeError(`Expected an object, got \`${object}\` (${typeof object})`);
}
return mapObject(object, mapper, options);
};
mapObj.exports.mapObjectSkip = mapObjectSkip;
return mapObj.exports;
}
var mapObjExports = requireMapObj();
const mapObject = getDefaultExportFromCjs(mapObjExports);
class QuickLRU extends Map {
constructor(options = {}) {
super();
if (!(options.maxSize && options.maxSize > 0)) {
throw new TypeError('`maxSize` must be a number greater than 0');
}
if (typeof options.maxAge === 'number' && options.maxAge === 0) {
throw new TypeError('`maxAge` must be a number greater than 0');
}
this.maxSize = options.maxSize;
this.maxAge = options.maxAge || Number.POSITIVE_INFINITY;
this.onEviction = options.onEviction;
this.cache = new Map();
this.oldCache = new Map();
this._size = 0;
}
_emitEvictions(cache) {
if (typeof this.onEviction !== 'function') {
return;
}
for (const [key, item] of cache) {
this.onEviction(key, item.value);
}
}
_deleteIfExpired(key, item) {
if (typeof item.expiry === 'number' && item.expiry <= Date.now()) {
if (typeof this.onEviction === 'function') {
this.onEviction(key, item.value);
}
return this.delete(key);
}
return false;
}
_getOrDeleteIfExpired(key, item) {
const deleted = this._deleteIfExpired(key, item);
if (deleted === false) {
return item.value;
}
}
_getItemValue(key, item) {
return item.expiry ? this._getOrDeleteIfExpired(key, item) : item.value;
}
_peek(key, cache) {
const item = cache.get(key);
return this._getItemValue(key, item);
}
_set(key, value) {
this.cache.set(key, value);
this._size++;
if (this._size >= this.maxSize) {
this._size = 0;
this._emitEvictions(this.oldCache);
this.oldCache = this.cache;
this.cache = new Map();
}
}
_moveToRecent(key, item) {
this.oldCache.delete(key);
this._set(key, item);
}
* _entriesAscending() {
for (const item of this.oldCache) {
const [key, value] = item;
if (!this.cache.has(key)) {
const deleted = this._deleteIfExpired(key, value);
if (deleted === false) {
yield item;
}
}
}
for (const item of this.cache) {
const [key, value] = item;
const deleted = this._deleteIfExpired(key, value);
if (deleted === false) {
yield item;
}
}
}
get(key) {
if (this.cache.has(key)) {
const item = this.cache.get(key);
return this._getItemValue(key, item);
}
if (this.oldCache.has(key)) {
const item = this.oldCache.get(key);
if (this._deleteIfExpired(key, item) === false) {
this._moveToRecent(key, item);
return item.value;
}
}
}
set(key, value, {maxAge = this.maxAge} = {}) {
const expiry =
typeof maxAge === 'number' && maxAge !== Number.POSITIVE_INFINITY ?
Date.now() + maxAge :
undefined;
if (this.cache.has(key)) {
this.cache.set(key, {
value,
expiry
});
} else {
this._set(key, {value, expiry});
}
return this;
}
has(key) {
if (this.cache.has(key)) {
return !this._deleteIfExpired(key, this.cache.get(key));
}
if (this.oldCache.has(key)) {
return !this._deleteIfExpired(key, this.oldCache.get(key));
}
return false;
}
peek(key) {
if (this.cache.has(key)) {
return this._peek(key, this.cache);
}
if (this.oldCache.has(key)) {
return this._peek(key, this.oldCache);
}
}
delete(key) {
const deleted = this.cache.delete(key);
if (deleted) {
this._size--;
}
return this.oldCache.delete(key) || deleted;
}
clear() {
this.cache.clear();
this.oldCache.clear();
this._size = 0;
}
resize(newSize) {
if (!(newSize && newSize > 0)) {
throw new TypeError('`maxSize` must be a number greater than 0');
}
const items = [...this._entriesAscending()];
const removeCount = items.length - newSize;
if (removeCount < 0) {
this.cache = new Map(items);
this.oldCache = new Map();
this._size = items.length;
} else {
if (removeCount > 0) {
this._emitEvictions(items.slice(0, removeCount));
}
this.oldCache = new Map(items.slice(removeCount));
this.cache = new Map();
this._size = 0;
}
this.maxSize = newSize;
}
* keys() {
for (const [key] of this) {
yield key;
}
}
* values() {
for (const [, value] of this) {
yield value;
}
}
* [Symbol.iterator]() {
for (const item of this.cache) {
const [key, value] = item;
const deleted = this._deleteIfExpired(key, value);
if (deleted === false) {
yield [key, value.value];
}
}
for (const item of this.oldCache) {
const [key, value] = item;
if (!this.cache.has(key)) {
const deleted = this._deleteIfExpired(key, value);
if (deleted === false) {
yield [key, value.value];
}
}
}
}
* entriesDescending() {
let items = [...this.cache];
for (let i = items.length - 1; i >= 0; --i) {
const item = items[i];
const [key, value] = item;
const deleted = this._deleteIfExpired(key, value);
if (deleted === false) {
yield [key, value.value];
}
}
items = [...this.oldCache];
for (let i = items.length - 1; i >= 0; --i) {
const item = items[i];
const [key, value] = item;
if (!this.cache.has(key)) {
const deleted = this._deleteIfExpired(key, value);
if (deleted === false) {
yield [key, value.value];
}
}
}
}
* entriesAscending() {
for (const [key, value] of this._entriesAscending()) {
yield [key, value.value];
}
}
get size() {
if (!this._size) {
return this.oldCache.size;
}
let oldCacheSize = 0;
for (const key of this.oldCache.keys()) {
if (!this.cache.has(key)) {
oldCacheSize++;
}
}
return Math.min(this._size + oldCacheSize, this.maxSize);
}
entries() {
return this.entriesAscending();
}
forEach(callbackFunction, thisArgument = this) {
for (const [key, value] of this.entriesAscending()) {
callbackFunction.call(thisArgument, value, key, this);
}
}
get [Symbol.toStringTag]() {
return JSON.stringify([...this.entriesAscending()]);
}
}
const has = (array, key) => array.some(element => {
if (typeof element === 'string') {
return element === key;
}
element.lastIndex = 0;
return element.test(key);
});
const cache = new QuickLRU({maxSize: 100_000});
const isObject = value =>
typeof value === 'object'
&& value !== null
&& !(value instanceof RegExp)
&& !(value instanceof Error)
&& !(value instanceof Date);
const transform = (input, options = {}) => {
if (!isObject(input)) {
return input;
}
const {
separator = '_',
exclude,
deep = false,
} = options;
const makeMapper = parentPath => (key, value) => {
if (deep && isObject(value)) {
value = mapObject(value, makeMapper());
}
if (!(exclude && has(exclude, key))) {
const cacheKey = `${separator}${key}`;
if (cache.has(cacheKey)) {
key = cache.get(cacheKey);
} else {
const returnValue = decamelize(key, {separator});
if (key.length < 100) {
cache.set(cacheKey, returnValue);
}
key = returnValue;
}
}
return [key, value];
};
return mapObject(input, makeMapper());
};
function decamelizeKeys(input, options) {
if (Array.isArray(input)) {
return Object.keys(input).map(key => transform(input[key], options));
}
return transform(input, options);
}
export { readPackageUpSync as a, constructParserOptions as b, camelcaseKeys as c, decamelizeKeys as d, decamelize as e, normalizePackageData as n, redent as r, trimNewlines as t, yargsParser as y };