use-monaco
Version:
[](https://npm.im/use-monaco)
1,376 lines (1,368 loc) • 401 kB
JavaScript
"use strict"; function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __create = Object.create;
var __defProp = Object.defineProperty;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
var __commonJS = (callback, module) => () => {
if (!module) {
module = {exports: {}};
callback(module.exports, module);
}
return module.exports;
};
var __export = (target, all) => {
__markAsModule(target);
for (var name in all)
__defProp(target, name, {get: all[name], enumerable: true});
};
var __exportStar = (target, module, desc) => {
__markAsModule(target);
if (module && typeof module === "object" || typeof module === "function") {
for (let key of __getOwnPropNames(module))
if (!__hasOwnProp.call(target, key) && key !== "default")
__defProp(target, key, {get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable});
}
return target;
};
var __toModule = (module) => {
if (module && module.__esModule)
return module;
return __exportStar(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", {value: module, enumerable: true}), module);
};
// node_modules/is-plain-obj/index.js
var require_is_plain_obj = __commonJS((exports, module) => {
"use strict";
var toString = Object.prototype.toString;
module.exports = function(x) {
var prototype;
return toString.call(x) === "[object Object]" && (prototype = Object.getPrototypeOf(x), prototype === null || prototype === Object.getPrototypeOf({}));
};
});
// node_modules/arrify/index.js
var require_arrify = __commonJS((exports, module) => {
"use strict";
module.exports = function(val) {
if (val === null || val === void 0) {
return [];
}
return Array.isArray(val) ? val : [val];
};
});
// node_modules/kind-of/index.js
var require_kind_of = __commonJS((exports, module) => {
var toString = Object.prototype.toString;
module.exports = 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;
}
});
// node_modules/minimist-options/index.js
var require_minimist_options = __commonJS((exports, module) => {
"use strict";
var isPlainObject = require_is_plain_obj();
var arrify = require_arrify();
var kindOf = require_kind_of();
var push = (obj, prop, value) => {
if (!obj[prop]) {
obj[prop] = [];
}
obj[prop].push(value);
};
var insert = (obj, prop, key, value) => {
if (!obj[prop]) {
obj[prop] = {};
}
obj[prop][key] = value;
};
var prettyPrint = (output) => {
return Array.isArray(output) ? `[${output.map(prettyPrint).join(", ")}]` : kindOf(output) === "string" ? JSON.stringify(output) : output;
};
var resolveType = (value) => {
if (Array.isArray(value) && value.length > 0) {
const [element] = value;
return `${kindOf(element)}-array`;
}
return kindOf(value);
};
var normalizeExpectedType = (type, defaultValue) => {
const inferredType = type === "array" ? "string-array" : type;
if (arrayTypes.includes(inferredType) && Array.isArray(defaultValue) && defaultValue.length === 0) {
return "array";
}
return inferredType;
};
var passthroughOptions = ["stopEarly", "unknown", "--"];
var primitiveTypes = ["string", "boolean", "number"];
var arrayTypes = primitiveTypes.map((t) => `${t}-array`);
var availableTypes = [...primitiveTypes, "array", ...arrayTypes];
var 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;
};
module.exports = buildOptions;
module.exports.default = buildOptions;
});
// node_modules/yargs-parser/build/index.cjs
var require_build = __commonJS((exports, module) => {
"use strict";
var util = require("util");
var fs = require("fs");
var path = require("path");
function camelCase(str) {
str = str.toLocaleLowerCase();
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.toLocaleUpperCase();
}
if (i !== 0 && (chr === "-" || chr === "_")) {
nextChrUpper = true;
continue;
} else if (chr !== "-" && chr !== "_") {
camelcase += chr;
}
}
return camelcase;
}
}
function decamelize(str, joinString) {
const lowercase = str.toLocaleLowerCase();
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 === void 0)
return false;
if (typeof x === "number")
return true;
if (/^0x[0-9a-f]+$/i.test(x))
return true;
if (x.length > 1 && x[0] === "0")
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 mixin;
var YargsParser = class {
constructor(_mixin) {
mixin = _mixin;
}
parse(argsInput, options) {
const opts = Object.assign({
alias: void 0,
array: void 0,
boolean: void 0,
config: void 0,
configObjects: void 0,
configuration: void 0,
coerce: void 0,
count: void 0,
default: void 0,
envPrefix: void 0,
narg: void 0,
normalize: void 0,
string: void 0,
number: void 0,
__: void 0,
key: void 0
}, options);
const args = tokenizeArgString(argsInput);
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(key2) {
const arrayFlagKeys = {
boolean: "bools",
string: "strings",
number: "numbers"
};
return arrayFlagKeys[key2];
}).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];
let broken;
let key;
let letters;
let m;
let next;
let value;
if (arg !== "--" && isUnknownOptionAsArg(arg)) {
pushPositional(arg);
} 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]);
}
}
} 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 !== void 0 && (!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 !== void 0 && !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 !== void 0 && (!/^(-|--)[^-]/.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(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, args2, 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 (args2.length - (i + 1) + available < toEat) {
error = Error(__("Not enough arguments following: %s", key));
}
available = toEat;
} else {
for (ii = i + 1; ii < args2.length; ii++) {
if (!args2[ii].match(/^-[^0-9]/) || args2[ii].match(negative) || isUnknownOptionAsArg(args2[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, args2[ii]);
}
return i + consumed;
}
function eatArray(i, key, args2, argAfterEqualSign) {
let argsToSet = [];
let next = argAfterEqualSign || args2[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] !== void 0) {
const defVal = defaults[key];
argsToSet = Array.isArray(defVal) ? defVal : [defVal];
}
} else {
if (!isUndefined(argAfterEqualSign)) {
argsToSet.push(processValue(key, argAfterEqualSign));
}
for (let ii = i + 1; ii < args2.length; ii++) {
if (!configuration["greedy-arrays"] && argsToSet.length > 0 || nargsCount && typeof nargsCount === "number" && argsToSet.length >= nargsCount)
break;
next = args2[ii];
if (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next))
break;
i = ii;
argsToSet.push(processValue(key, next));
}
}
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) {
if (/-/.test(key) && configuration["camel-case-expansion"]) {
const alias = key.split(".").map(function(prop) {
return camelCase(prop);
}).join(".");
addNewAlias(key, alias);
}
const value = processValue(key, val);
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(key2) {
Object.defineProperty(argvReturn, key2, {
enumerable: true,
get() {
return val;
},
set(value2) {
val = typeof value2 === "string" ? mixin.normalize(value2) : value2;
}
});
});
}
}
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) {
if (typeof val === "string" && (val[0] === "'" || val[0] === '"') && val[val.length - 1] === val[0]) {
val = val.substring(1, val.length - 1);
}
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((val2) => {
return mixin.normalize(val2);
});
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(argv2) {
const configLookup = Object.create(null);
applyDefaultsAndAliases(configLookup, flags.aliases, defaults);
Object.keys(flags.configs).forEach(function(configKey) {
const configPath = argv2[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 (argv2[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(argv2, configOnly) {
if (typeof envPrefix === "undefined")
return;
const prefix = typeof envPrefix === "string" ? envPrefix : "";
const env2 = mixin.env();
Object.keys(env2).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(key);
});
if ((configOnly && flags.configs[keys.join(".")] || !configOnly) && !hasKey(argv2, keys)) {
setArg(keys.join("."), env2[envVar]);
}
}
});
}
function applyCoercions(argv2) {
let coerce;
const applied = new Set();
Object.keys(argv2).forEach(function(key) {
if (!applied.has(key)) {
coerce = checkAllAliases(key, flags.coercions);
if (typeof coerce === "function") {
try {
const value = maybeCoerceNumber(key, coerce(argv2[key]));
[].concat(flags.aliases[key] || [], key).forEach((ali) => {
applied.add(ali);
argv2[ali] = value;
});
} catch (err) {
error = err;
}
}
}
});
}
function setPlaceholderKeys(argv2) {
flags.keys.forEach((key) => {
if (~key.indexOf("."))
return;
if (typeof argv2[key] === "undefined")
argv2[key] = void 0;
});
return argv2;
}
function applyDefaultsAndAliases(obj, aliases2, defaults2, canLog = false) {
Object.keys(defaults2).forEach(function(key) {
if (!hasKey(obj, key.split("."))) {
setKey(obj, key.split("."), defaults2[key]);
if (canLog)
defaulted[key] = true;
(aliases2[key] || []).forEach(function(x) {
if (hasKey(obj, x.split(".")))
return;
setKey(obj, x.split("."), defaults2[key]);
});
}
});
}
function hasKey(obj, keys) {
let o = obj;
if (!configuration["dot-notation"])
keys = [keys.join(".")];
keys.slice(0, -1).forEach(function(key2) {
o = o[key2] || {};
});
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(key2) {
key2 = sanitizeKey(key2);
if (typeof o === "object" && o[key2] === void 0) {
o[key2] = {};
}
if (typeof o[key2] !== "object" || Array.isArray(o[key2])) {
if (Array.isArray(o[key2])) {
o[key2].push({});
} else {
o[key2] = [o[key2], {}];
}
o = o[key2][o[key2].length - 1];
} else {
o = o[key2];
}
});
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] = void 0;
}
}
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] === void 0 && isTypeArray) {
o[key] = isValueArray ? value : [value];
} else if (duplicate && !(o[key] === void 0 || checkAllAliases(key, flags.counts) || checkAllAliases(key, flags.bools))) {
o[key] = [o[key], value];
} else {
o[key] = value;
}
}
function extendAliases(...args2) {
args2.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(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(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((key2) => keys.includes(key2));
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) {
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 = {
boolean: true,
string: "",
number: void 0,
array: []
};
return def[type];
}
function guessType(key) {
let type = "boolean";
if (checkAllAliases(key, flags.strings))
type = "string";
else if (checkAllAliases(key, flags.numbers))
type = "number";
else if (checkAllAliases(key, flags.bools))
type = "boolean";
else if (checkAllAliases(key, flags.arrays))
type = "array";
return type;
}
function isUndefined(num) {
return num === void 0;
}
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,
defaulted: Object.assign({}, defaulted),
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 !== void 0 && typeof lastAlias === "string") {
combined[lastAlias] = aliasArray;
}
});
return combined;
}
function increment(orig) {
return orig !== void 0 ? orig + 1 : 1;
}
function sanitizeKey(key) {
if (key === "__proto__")
return "___proto___";
return key;
}
var minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 10;
if (process && process.version) {
const major = Number(process.version.match(/v([^.]+)/)[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`);
}
}
var env = process ? process.env : {};
var parser = new YargsParser({
cwd: process.cwd,
env: () => {
return env;
},
format: util.format,
normalize: path.normalize,
resolve: path.resolve,
require: (path2) => {
if (true) {
return require(path2);
} else if (path2.match(/\.json$/)) {
return fs.readFileSync(path2, "utf8");
} else {
throw Error("only .json config files are supported in ESM");
}
}
});
var 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;
yargsParser.decamelize = decamelize;
yargsParser.looksLikeNumber = looksLikeNumber;
module.exports = yargsParser;
});
// node_modules/camelcase-keys/node_modules/map-obj/index.js
var require_map_obj = __commonJS((exports, module) => {
"use strict";
var isObject = (value) => typeof value === "object" && value !== null;
var isObjectCustom = (value) => isObject(value) && !(value instanceof RegExp) && !(value instanceof Error) && !(value instanceof Date);
var 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)) {
let [newKey, newValue] = mapper(key, value, object);
if (options.deep && isObjectCustom(newValue)) {
newValue = Array.isArray(newValue) ? mapArray(newValue) : mapObject(newValue, mapper, options, isSeen);
}
target[newKey] = newValue;
}
return target;
};
module.exports = (object, mapper, options) => {
if (!isObject(object)) {
throw new TypeError(`Expected an object, got \`${object}\` (${typeof object})`);
}
return mapObject(object, mapper, options);
};
});
// node_modules/camelcase/index.js
var require_camelcase = __commonJS((exports, module) => {
"use strict";
var preserveCamelCase = (string) => {
let isLastCharLower = false;
let isLastCharUpper = false;
let isLastLastCharUpper = false;
for (let i = 0; i < string.length; i++) {
const character = string[i];
if (isLastCharLower && /[a-zA-Z]/.test(character) && character.toUpperCase() === character) {
string = string.slice(0, i) + "-" + string.slice(i);
isLastCharLower = false;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = true;
i++;
} else if (isLastCharUpper && isLastLastCharUpper && /[a-zA-Z]/.test(character) && character.toLowerCase() === character) {
string = string.slice(0, i - 1) + "-" + string.slice(i - 1);
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = false;
isLastCharLower = true;
} else {
isLastCharLower = character.toLowerCase() === character && character.toUpperCase() !== character;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = character.toUpperCase() === character && character.toLowerCase() !== character;
}
}
return string;
};
var camelCase = (input, options) => {
if (!(typeof input === "string" || Array.isArray(input))) {
throw new TypeError("Expected the input to be `string | string[]`");
}
options = Object.assign({
pascalCase: false
}, options);
const postProcess = (x) => options.pascalCase ? x.charAt(0).toUpperCase() + x.slice(1) : x;
if (Array.isArray(input)) {
input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
} else {
input = input.trim();
}
if (input.length === 0) {
return "";
}
if (input.length === 1) {
return options.pascalCase ? input.toUpperCase() : input.toLowerCase();
}
const hasUpperCase = input !== input.toLowerCase();
if (hasUpperCase) {
input = preserveCamelCase(input);
}
input = input.replace(/^[_.\- ]+/, "").toLowerCase().replace(/[_.\- ]+(\w|$)/g, (_, p1) => p1.toUpperCase()).replace(/\d+(\w|$)/g, (m) => m.toUpperCase());
return postProcess(input);
};
module.exports = camelCase;
module.exports.default = camelCase;
});
// node_modules/quick-lru/index.js
var require_quick_lru = __commonJS((exports, module) => {
"use strict";
var QuickLRU = class {
constructor(options = {}) {
if (!(options.maxSize && options.maxSize > 0)) {
throw new TypeError("`maxSize` must be a number greater than 0");
}
this.maxSize = options.maxSize;
this.cache = new Map();
this.oldCache = new Map();
this._size = 0;
}
_set(key, value) {
this.cache.set(key, value);
this._size++;
if (this._size >= this.maxSize) {
this._size = 0;
this.oldCache = this.cache;
this.cache = new Map();
}
}
get(key) {
if (this.cache.has(key)) {
return this.cache.get(key);
}
if (this.oldCache.has(key)) {
const value = this.oldCache.get(key);
this.oldCache.delete(key);
this._set(key, value);
return value;
}
}
set(key, value) {
if (this.cache.has(key)) {
this.cache.set(key, value);
} else {
this._set(key, value);
}
return this;
}
has(key) {
return this.cache.has(key) || this.oldCache.has(key);
}
peek(key) {
if (this.cache.has(key)) {
return this.cache.get(key);
}
if (this.oldCache.has(key)) {
return this.oldCache.get(key);
}
}
delete(key) {
const deleted = this.cache.delete(key);
if (deleted) {
this