prettier
Version:
Prettier is an opinionated code formatter
1,481 lines (1,466 loc) • 230 kB
JavaScript
import { createRequire as __prettierCreateRequire } from "module";
import { fileURLToPath as __prettierFileUrlToPath } from "url";
import { dirname as __prettierDirname } from "path";
const require = __prettierCreateRequire(import.meta.url);
const __filename = __prettierFileUrlToPath(import.meta.url);
const __dirname = __prettierDirname(__filename);
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined")
return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __commonJS = (cb, mod) => function __require2() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateSet = (obj, member, value, setter) => {
__accessCheck(obj, member, "write to private field");
setter ? setter.call(obj, value) : member.set(obj, value);
return value;
};
var __privateWrapper = (obj, member, setter, getter) => ({
set _(value) {
__privateSet(obj, member, value, setter);
},
get _() {
return __privateGet(obj, member, getter);
}
});
// node_modules/clone/clone.js
var require_clone = __commonJS({
"node_modules/clone/clone.js"(exports, module) {
var clone = function() {
"use strict";
function clone2(parent, circular, depth, prototype) {
var filter;
if (typeof circular === "object") {
depth = circular.depth;
prototype = circular.prototype;
filter = circular.filter;
circular = circular.circular;
}
var allParents = [];
var allChildren = [];
var useBuffer = typeof Buffer != "undefined";
if (typeof circular == "undefined")
circular = true;
if (typeof depth == "undefined")
depth = Infinity;
function _clone(parent2, depth2) {
if (parent2 === null)
return null;
if (depth2 == 0)
return parent2;
var child;
var proto2;
if (typeof parent2 != "object") {
return parent2;
}
if (clone2.__isArray(parent2)) {
child = [];
} else if (clone2.__isRegExp(parent2)) {
child = new RegExp(parent2.source, __getRegExpFlags(parent2));
if (parent2.lastIndex)
child.lastIndex = parent2.lastIndex;
} else if (clone2.__isDate(parent2)) {
child = new Date(parent2.getTime());
} else if (useBuffer && Buffer.isBuffer(parent2)) {
if (Buffer.allocUnsafe) {
child = Buffer.allocUnsafe(parent2.length);
} else {
child = new Buffer(parent2.length);
}
parent2.copy(child);
return child;
} else {
if (typeof prototype == "undefined") {
proto2 = Object.getPrototypeOf(parent2);
child = Object.create(proto2);
} else {
child = Object.create(prototype);
proto2 = prototype;
}
}
if (circular) {
var index = allParents.indexOf(parent2);
if (index != -1) {
return allChildren[index];
}
allParents.push(parent2);
allChildren.push(child);
}
for (var i in parent2) {
var attrs;
if (proto2) {
attrs = Object.getOwnPropertyDescriptor(proto2, i);
}
if (attrs && attrs.set == null) {
continue;
}
child[i] = _clone(parent2[i], depth2 - 1);
}
return child;
}
return _clone(parent, depth);
}
clone2.clonePrototype = function clonePrototype(parent) {
if (parent === null)
return null;
var c = function() {
};
c.prototype = parent;
return new c();
};
function __objToStr(o) {
return Object.prototype.toString.call(o);
}
;
clone2.__objToStr = __objToStr;
function __isDate(o) {
return typeof o === "object" && __objToStr(o) === "[object Date]";
}
;
clone2.__isDate = __isDate;
function __isArray(o) {
return typeof o === "object" && __objToStr(o) === "[object Array]";
}
;
clone2.__isArray = __isArray;
function __isRegExp(o) {
return typeof o === "object" && __objToStr(o) === "[object RegExp]";
}
;
clone2.__isRegExp = __isRegExp;
function __getRegExpFlags(re) {
var flags = "";
if (re.global)
flags += "g";
if (re.ignoreCase)
flags += "i";
if (re.multiline)
flags += "m";
return flags;
}
;
clone2.__getRegExpFlags = __getRegExpFlags;
return clone2;
}();
if (typeof module === "object" && module.exports) {
module.exports = clone;
}
}
});
// node_modules/defaults/index.js
var require_defaults = __commonJS({
"node_modules/defaults/index.js"(exports, module) {
var clone = require_clone();
module.exports = function(options, defaults) {
options = options || {};
Object.keys(defaults).forEach(function(key) {
if (typeof options[key] === "undefined") {
options[key] = clone(defaults[key]);
}
});
return options;
};
}
});
// node_modules/wcwidth/combining.js
var require_combining = __commonJS({
"node_modules/wcwidth/combining.js"(exports, module) {
module.exports = [
[768, 879],
[1155, 1158],
[1160, 1161],
[1425, 1469],
[1471, 1471],
[1473, 1474],
[1476, 1477],
[1479, 1479],
[1536, 1539],
[1552, 1557],
[1611, 1630],
[1648, 1648],
[1750, 1764],
[1767, 1768],
[1770, 1773],
[1807, 1807],
[1809, 1809],
[1840, 1866],
[1958, 1968],
[2027, 2035],
[2305, 2306],
[2364, 2364],
[2369, 2376],
[2381, 2381],
[2385, 2388],
[2402, 2403],
[2433, 2433],
[2492, 2492],
[2497, 2500],
[2509, 2509],
[2530, 2531],
[2561, 2562],
[2620, 2620],
[2625, 2626],
[2631, 2632],
[2635, 2637],
[2672, 2673],
[2689, 2690],
[2748, 2748],
[2753, 2757],
[2759, 2760],
[2765, 2765],
[2786, 2787],
[2817, 2817],
[2876, 2876],
[2879, 2879],
[2881, 2883],
[2893, 2893],
[2902, 2902],
[2946, 2946],
[3008, 3008],
[3021, 3021],
[3134, 3136],
[3142, 3144],
[3146, 3149],
[3157, 3158],
[3260, 3260],
[3263, 3263],
[3270, 3270],
[3276, 3277],
[3298, 3299],
[3393, 3395],
[3405, 3405],
[3530, 3530],
[3538, 3540],
[3542, 3542],
[3633, 3633],
[3636, 3642],
[3655, 3662],
[3761, 3761],
[3764, 3769],
[3771, 3772],
[3784, 3789],
[3864, 3865],
[3893, 3893],
[3895, 3895],
[3897, 3897],
[3953, 3966],
[3968, 3972],
[3974, 3975],
[3984, 3991],
[3993, 4028],
[4038, 4038],
[4141, 4144],
[4146, 4146],
[4150, 4151],
[4153, 4153],
[4184, 4185],
[4448, 4607],
[4959, 4959],
[5906, 5908],
[5938, 5940],
[5970, 5971],
[6002, 6003],
[6068, 6069],
[6071, 6077],
[6086, 6086],
[6089, 6099],
[6109, 6109],
[6155, 6157],
[6313, 6313],
[6432, 6434],
[6439, 6440],
[6450, 6450],
[6457, 6459],
[6679, 6680],
[6912, 6915],
[6964, 6964],
[6966, 6970],
[6972, 6972],
[6978, 6978],
[7019, 7027],
[7616, 7626],
[7678, 7679],
[8203, 8207],
[8234, 8238],
[8288, 8291],
[8298, 8303],
[8400, 8431],
[12330, 12335],
[12441, 12442],
[43014, 43014],
[43019, 43019],
[43045, 43046],
[64286, 64286],
[65024, 65039],
[65056, 65059],
[65279, 65279],
[65529, 65531],
[68097, 68099],
[68101, 68102],
[68108, 68111],
[68152, 68154],
[68159, 68159],
[119143, 119145],
[119155, 119170],
[119173, 119179],
[119210, 119213],
[119362, 119364],
[917505, 917505],
[917536, 917631],
[917760, 917999]
];
}
});
// node_modules/wcwidth/index.js
var require_wcwidth = __commonJS({
"node_modules/wcwidth/index.js"(exports, module) {
"use strict";
var defaults = require_defaults();
var combining = require_combining();
var DEFAULTS = {
nul: 0,
control: 0
};
module.exports = function wcwidth3(str) {
return wcswidth(str, DEFAULTS);
};
module.exports.config = function(opts) {
opts = defaults(opts || {}, DEFAULTS);
return function wcwidth3(str) {
return wcswidth(str, opts);
};
};
function wcswidth(str, opts) {
if (typeof str !== "string")
return wcwidth2(str, opts);
var s = 0;
for (var i = 0; i < str.length; i++) {
var n = wcwidth2(str.charCodeAt(i), opts);
if (n < 0)
return -1;
s += n;
}
return s;
}
function wcwidth2(ucs, opts) {
if (ucs === 0)
return opts.nul;
if (ucs < 32 || ucs >= 127 && ucs < 160)
return opts.control;
if (bisearch(ucs))
return 0;
return 1 + (ucs >= 4352 && (ucs <= 4447 || // Hangul Jamo init. consonants
ucs == 9001 || ucs == 9002 || ucs >= 11904 && ucs <= 42191 && ucs != 12351 || // CJK ... Yi
ucs >= 44032 && ucs <= 55203 || // Hangul Syllables
ucs >= 63744 && ucs <= 64255 || // CJK Compatibility Ideographs
ucs >= 65040 && ucs <= 65049 || // Vertical forms
ucs >= 65072 && ucs <= 65135 || // CJK Compatibility Forms
ucs >= 65280 && ucs <= 65376 || // Fullwidth Forms
ucs >= 65504 && ucs <= 65510 || ucs >= 131072 && ucs <= 196605 || ucs >= 196608 && ucs <= 262141));
}
function bisearch(ucs) {
var min = 0;
var max = combining.length - 1;
var mid;
if (ucs < combining[0][0] || ucs > combining[max][1])
return false;
while (max >= min) {
mid = Math.floor((min + max) / 2);
if (ucs > combining[mid][1])
min = mid + 1;
else if (ucs < combining[mid][0])
max = mid - 1;
else
return true;
}
return false;
}
}
});
// node_modules/dashify/index.js
var require_dashify = __commonJS({
"node_modules/dashify/index.js"(exports, module) {
"use strict";
module.exports = (str, options) => {
if (typeof str !== "string")
throw new TypeError("expected a string");
return str.trim().replace(/([a-z])([A-Z])/g, "$1-$2").replace(/\W/g, (m) => /[À-ž]/.test(m) ? m : "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, (m) => options && options.condense ? "-" : m).toLowerCase();
};
}
});
// node_modules/minimist/index.js
var require_minimist = __commonJS({
"node_modules/minimist/index.js"(exports, module) {
"use strict";
function hasKey(obj, keys) {
var o = obj;
keys.slice(0, -1).forEach(function(key2) {
o = o[key2] || {};
});
var key = keys[keys.length - 1];
return key in o;
}
function isNumber(x) {
if (typeof x === "number") {
return true;
}
if (/^0x[0-9a-f]+$/i.test(x)) {
return true;
}
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
}
function isConstructorOrProto(obj, key) {
return key === "constructor" && typeof obj[key] === "function" || key === "__proto__";
}
module.exports = function(args, opts) {
if (!opts) {
opts = {};
}
var flags = {
bools: {},
strings: {},
unknownFn: null
};
if (typeof opts.unknown === "function") {
flags.unknownFn = opts.unknown;
}
if (typeof opts.boolean === "boolean" && opts.boolean) {
flags.allBools = true;
} else {
[].concat(opts.boolean).filter(Boolean).forEach(function(key2) {
flags.bools[key2] = true;
});
}
var aliases = {};
function aliasIsBoolean(key2) {
return aliases[key2].some(function(x) {
return flags.bools[x];
});
}
Object.keys(opts.alias || {}).forEach(function(key2) {
aliases[key2] = [].concat(opts.alias[key2]);
aliases[key2].forEach(function(x) {
aliases[x] = [key2].concat(aliases[key2].filter(function(y) {
return x !== y;
}));
});
});
[].concat(opts.string).filter(Boolean).forEach(function(key2) {
flags.strings[key2] = true;
if (aliases[key2]) {
[].concat(aliases[key2]).forEach(function(k) {
flags.strings[k] = true;
});
}
});
var defaults = opts.default || {};
var argv = { _: [] };
function argDefined(key2, arg2) {
return flags.allBools && /^--[^=]+$/.test(arg2) || flags.strings[key2] || flags.bools[key2] || aliases[key2];
}
function setKey(obj, keys, value2) {
var o = obj;
for (var i2 = 0; i2 < keys.length - 1; i2++) {
var key2 = keys[i2];
if (isConstructorOrProto(o, key2)) {
return;
}
if (o[key2] === void 0) {
o[key2] = {};
}
if (o[key2] === Object.prototype || o[key2] === Number.prototype || o[key2] === String.prototype) {
o[key2] = {};
}
if (o[key2] === Array.prototype) {
o[key2] = [];
}
o = o[key2];
}
var lastKey = keys[keys.length - 1];
if (isConstructorOrProto(o, lastKey)) {
return;
}
if (o === Object.prototype || o === Number.prototype || o === String.prototype) {
o = {};
}
if (o === Array.prototype) {
o = [];
}
if (o[lastKey] === void 0 || flags.bools[lastKey] || typeof o[lastKey] === "boolean") {
o[lastKey] = value2;
} else if (Array.isArray(o[lastKey])) {
o[lastKey].push(value2);
} else {
o[lastKey] = [o[lastKey], value2];
}
}
function setArg(key2, val, arg2) {
if (arg2 && flags.unknownFn && !argDefined(key2, arg2)) {
if (flags.unknownFn(arg2) === false) {
return;
}
}
var value2 = !flags.strings[key2] && isNumber(val) ? Number(val) : val;
setKey(argv, key2.split("."), value2);
(aliases[key2] || []).forEach(function(x) {
setKey(argv, x.split("."), value2);
});
}
Object.keys(flags.bools).forEach(function(key2) {
setArg(key2, defaults[key2] === void 0 ? false : defaults[key2]);
});
var notFlags = [];
if (args.indexOf("--") !== -1) {
notFlags = args.slice(args.indexOf("--") + 1);
args = args.slice(0, args.indexOf("--"));
}
for (var i = 0; i < args.length; i++) {
var arg = args[i];
var key;
var next;
if (/^--.+=/.test(arg)) {
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
key = m[1];
var value = m[2];
if (flags.bools[key]) {
value = value !== "false";
}
setArg(key, value, arg);
} else if (/^--no-.+/.test(arg)) {
key = arg.match(/^--no-(.+)/)[1];
setArg(key, false, arg);
} else if (/^--.+/.test(arg)) {
key = arg.match(/^--(.+)/)[1];
next = args[i + 1];
if (next !== void 0 && !/^(-|--)[^-]/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) {
setArg(key, next, arg);
i += 1;
} else if (/^(true|false)$/.test(next)) {
setArg(key, next === "true", arg);
i += 1;
} else {
setArg(key, flags.strings[key] ? "" : true, arg);
}
} else if (/^-[^-]+/.test(arg)) {
var letters = arg.slice(1, -1).split("");
var broken = false;
for (var j = 0; j < letters.length; j++) {
next = arg.slice(j + 2);
if (next === "-") {
setArg(letters[j], next, arg);
continue;
}
if (/[A-Za-z]/.test(letters[j]) && next[0] === "=") {
setArg(letters[j], next.slice(1), arg);
broken = true;
break;
}
if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
setArg(letters[j], next, arg);
broken = true;
break;
}
if (letters[j + 1] && letters[j + 1].match(/\W/)) {
setArg(letters[j], arg.slice(j + 2), arg);
broken = true;
break;
} else {
setArg(letters[j], flags.strings[letters[j]] ? "" : true, arg);
}
}
key = arg.slice(-1)[0];
if (!broken && key !== "-") {
if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) {
setArg(key, args[i + 1], arg);
i += 1;
} else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
setArg(key, args[i + 1] === "true", arg);
i += 1;
} else {
setArg(key, flags.strings[key] ? "" : true, arg);
}
}
} else {
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
}
if (opts.stopEarly) {
argv._.push.apply(argv._, args.slice(i + 1));
break;
}
}
}
Object.keys(defaults).forEach(function(k) {
if (!hasKey(argv, k.split("."))) {
setKey(argv, k.split("."), defaults[k]);
(aliases[k] || []).forEach(function(x) {
setKey(argv, x.split("."), defaults[k]);
});
}
});
if (opts["--"]) {
argv["--"] = notFlags.slice();
} else {
notFlags.forEach(function(k) {
argv._.push(k);
});
}
return argv;
};
}
});
// node_modules/diff/lib/diff/base.js
var require_base = __commonJS({
"node_modules/diff/lib/diff/base.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = Diff;
function Diff() {
}
Diff.prototype = {
/*istanbul ignore start*/
/*istanbul ignore end*/
diff: function diff2(oldString, newString) {
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
var callback = options.callback;
if (typeof options === "function") {
callback = options;
options = {};
}
this.options = options;
var self = this;
function done(value) {
if (callback) {
setTimeout(function() {
callback(void 0, value);
}, 0);
return true;
} else {
return value;
}
}
oldString = this.castInput(oldString);
newString = this.castInput(newString);
oldString = this.removeEmpty(this.tokenize(oldString));
newString = this.removeEmpty(this.tokenize(newString));
var newLen = newString.length, oldLen = oldString.length;
var editLength = 1;
var maxEditLength = newLen + oldLen;
if (options.maxEditLength) {
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
}
var bestPath = [{
newPos: -1,
components: []
}];
var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
return done([{
value: this.join(newString),
count: newString.length
}]);
}
function execEditLength() {
for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
var basePath = (
/*istanbul ignore start*/
void 0
);
var addPath = bestPath[diagonalPath - 1], removePath = bestPath[diagonalPath + 1], _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
if (addPath) {
bestPath[diagonalPath - 1] = void 0;
}
var canAdd = addPath && addPath.newPos + 1 < newLen, canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
if (!canAdd && !canRemove) {
bestPath[diagonalPath] = void 0;
continue;
}
if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
basePath = clonePath(removePath);
self.pushComponent(basePath.components, void 0, true);
} else {
basePath = addPath;
basePath.newPos++;
self.pushComponent(basePath.components, true, void 0);
}
_oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
} else {
bestPath[diagonalPath] = basePath;
}
}
editLength++;
}
if (callback) {
(function exec() {
setTimeout(function() {
if (editLength > maxEditLength) {
return callback();
}
if (!execEditLength()) {
exec();
}
}, 0);
})();
} else {
while (editLength <= maxEditLength) {
var ret = execEditLength();
if (ret) {
return ret;
}
}
}
},
/*istanbul ignore start*/
/*istanbul ignore end*/
pushComponent: function pushComponent(components, added, removed) {
var last = components[components.length - 1];
if (last && last.added === added && last.removed === removed) {
components[components.length - 1] = {
count: last.count + 1,
added,
removed
};
} else {
components.push({
count: 1,
added,
removed
});
}
},
/*istanbul ignore start*/
/*istanbul ignore end*/
extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
var newLen = newString.length, oldLen = oldString.length, newPos = basePath.newPos, oldPos = newPos - diagonalPath, commonCount = 0;
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
newPos++;
oldPos++;
commonCount++;
}
if (commonCount) {
basePath.components.push({
count: commonCount
});
}
basePath.newPos = newPos;
return oldPos;
},
/*istanbul ignore start*/
/*istanbul ignore end*/
equals: function equals(left, right) {
if (this.options.comparator) {
return this.options.comparator(left, right);
} else {
return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
}
},
/*istanbul ignore start*/
/*istanbul ignore end*/
removeEmpty: function removeEmpty(array2) {
var ret = [];
for (var i = 0; i < array2.length; i++) {
if (array2[i]) {
ret.push(array2[i]);
}
}
return ret;
},
/*istanbul ignore start*/
/*istanbul ignore end*/
castInput: function castInput(value) {
return value;
},
/*istanbul ignore start*/
/*istanbul ignore end*/
tokenize: function tokenize(value) {
return value.split("");
},
/*istanbul ignore start*/
/*istanbul ignore end*/
join: function join(chars) {
return chars.join("");
}
};
function buildValues(diff2, components, newString, oldString, useLongestToken) {
var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0;
for (; componentPos < componentLen; componentPos++) {
var component = components[componentPos];
if (!component.removed) {
if (!component.added && useLongestToken) {
var value = newString.slice(newPos, newPos + component.count);
value = value.map(function(value2, i) {
var oldValue = oldString[oldPos + i];
return oldValue.length > value2.length ? oldValue : value2;
});
component.value = diff2.join(value);
} else {
component.value = diff2.join(newString.slice(newPos, newPos + component.count));
}
newPos += component.count;
if (!component.added) {
oldPos += component.count;
}
} else {
component.value = diff2.join(oldString.slice(oldPos, oldPos + component.count));
oldPos += component.count;
if (componentPos && components[componentPos - 1].added) {
var tmp = components[componentPos - 1];
components[componentPos - 1] = components[componentPos];
components[componentPos] = tmp;
}
}
}
var lastComponent = components[componentLen - 1];
if (componentLen > 1 && typeof lastComponent.value === "string" && (lastComponent.added || lastComponent.removed) && diff2.equals("", lastComponent.value)) {
components[componentLen - 2].value += lastComponent.value;
components.pop();
}
return components;
}
function clonePath(path10) {
return {
newPos: path10.newPos,
components: path10.components.slice(0)
};
}
}
});
// node_modules/diff/lib/util/params.js
var require_params = __commonJS({
"node_modules/diff/lib/util/params.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.generateOptions = generateOptions;
function generateOptions(options, defaults) {
if (typeof options === "function") {
defaults.callback = options;
} else if (options) {
for (var name in options) {
if (options.hasOwnProperty(name)) {
defaults[name] = options[name];
}
}
}
return defaults;
}
}
});
// node_modules/diff/lib/diff/line.js
var require_line = __commonJS({
"node_modules/diff/lib/diff/line.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.diffLines = diffLines;
exports.diffTrimmedLines = diffTrimmedLines;
exports.lineDiff = void 0;
var _base = _interopRequireDefault(require_base());
var _params = require_params();
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { "default": obj };
}
var lineDiff = new /*istanbul ignore start*/
_base[
/*istanbul ignore start*/
"default"
/*istanbul ignore end*/
]();
exports.lineDiff = lineDiff;
lineDiff.tokenize = function(value) {
var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
linesAndNewlines.pop();
}
for (var i = 0; i < linesAndNewlines.length; i++) {
var line = linesAndNewlines[i];
if (i % 2 && !this.options.newlineIsToken) {
retLines[retLines.length - 1] += line;
} else {
if (this.options.ignoreWhitespace) {
line = line.trim();
}
retLines.push(line);
}
}
return retLines;
};
function diffLines(oldStr, newStr, callback) {
return lineDiff.diff(oldStr, newStr, callback);
}
function diffTrimmedLines(oldStr, newStr, callback) {
var options = (
/*istanbul ignore start*/
(0, /*istanbul ignore end*/
/*istanbul ignore start*/
_params.generateOptions)(callback, {
ignoreWhitespace: true
})
);
return lineDiff.diff(oldStr, newStr, options);
}
}
});
// node_modules/diff/lib/patch/create.js
var require_create = __commonJS({
"node_modules/diff/lib/patch/create.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.structuredPatch = structuredPatch;
exports.formatPatch = formatPatch;
exports.createTwoFilesPatch = createTwoFilesPatch2;
exports.createPatch = createPatch;
var _line = require_line();
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray(o, minLen) {
if (!o)
return;
if (typeof o === "string")
return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor)
n = o.constructor.name;
if (n === "Map" || n === "Set")
return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
return _arrayLikeToArray(o, minLen);
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter))
return Array.from(iter);
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr))
return _arrayLikeToArray(arr);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length)
len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) {
arr2[i] = arr[i];
}
return arr2;
}
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
if (!options) {
options = {};
}
if (typeof options.context === "undefined") {
options.context = 4;
}
var diff2 = (
/*istanbul ignore start*/
(0, /*istanbul ignore end*/
/*istanbul ignore start*/
_line.diffLines)(oldStr, newStr, options)
);
if (!diff2) {
return;
}
diff2.push({
value: "",
lines: []
});
function contextLines(lines) {
return lines.map(function(entry) {
return " " + entry;
});
}
var hunks = [];
var oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
var _loop = function _loop2(i2) {
var current = diff2[i2], lines = current.lines || current.value.replace(/\n$/, "").split("\n");
current.lines = lines;
if (current.added || current.removed) {
var _curRange;
if (!oldRangeStart) {
var prev = diff2[i2 - 1];
oldRangeStart = oldLine;
newRangeStart = newLine;
if (prev) {
curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
oldRangeStart -= curRange.length;
newRangeStart -= curRange.length;
}
}
(_curRange = /*istanbul ignore end*/
curRange).push.apply(
/*istanbul ignore start*/
_curRange,
/*istanbul ignore start*/
_toConsumableArray(
/*istanbul ignore end*/
lines.map(function(entry) {
return (current.added ? "+" : "-") + entry;
})
)
);
if (current.added) {
newLine += lines.length;
} else {
oldLine += lines.length;
}
} else {
if (oldRangeStart) {
if (lines.length <= options.context * 2 && i2 < diff2.length - 2) {
var _curRange2;
(_curRange2 = /*istanbul ignore end*/
curRange).push.apply(
/*istanbul ignore start*/
_curRange2,
/*istanbul ignore start*/
_toConsumableArray(
/*istanbul ignore end*/
contextLines(lines)
)
);
} else {
var _curRange3;
var contextSize = Math.min(lines.length, options.context);
(_curRange3 = /*istanbul ignore end*/
curRange).push.apply(
/*istanbul ignore start*/
_curRange3,
/*istanbul ignore start*/
_toConsumableArray(
/*istanbul ignore end*/
contextLines(lines.slice(0, contextSize))
)
);
var hunk = {
oldStart: oldRangeStart,
oldLines: oldLine - oldRangeStart + contextSize,
newStart: newRangeStart,
newLines: newLine - newRangeStart + contextSize,
lines: curRange
};
if (i2 >= diff2.length - 2 && lines.length <= options.context) {
var oldEOFNewline = /\n$/.test(oldStr);
var newEOFNewline = /\n$/.test(newStr);
var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) {
curRange.splice(hunk.oldLines, 0, "\\ No newline at end of file");
}
if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
curRange.push("\\ No newline at end of file");
}
}
hunks.push(hunk);
oldRangeStart = 0;
newRangeStart = 0;
curRange = [];
}
}
oldLine += lines.length;
newLine += lines.length;
}
};
for (var i = 0; i < diff2.length; i++) {
_loop(
/*istanbul ignore end*/
i
);
}
return {
oldFileName,
newFileName,
oldHeader,
newHeader,
hunks
};
}
function formatPatch(diff2) {
var ret = [];
if (diff2.oldFileName == diff2.newFileName) {
ret.push("Index: " + diff2.oldFileName);
}
ret.push("===================================================================");
ret.push("--- " + diff2.oldFileName + (typeof diff2.oldHeader === "undefined" ? "" : " " + diff2.oldHeader));
ret.push("+++ " + diff2.newFileName + (typeof diff2.newHeader === "undefined" ? "" : " " + diff2.newHeader));
for (var i = 0; i < diff2.hunks.length; i++) {
var hunk = diff2.hunks[i];
if (hunk.oldLines === 0) {
hunk.oldStart -= 1;
}
if (hunk.newLines === 0) {
hunk.newStart -= 1;
}
ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
ret.push.apply(ret, hunk.lines);
}
return ret.join("\n") + "\n";
}
function createTwoFilesPatch2(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options));
}
function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
return createTwoFilesPatch2(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
}
}
});
// node_modules/common-path-prefix/index.js
var require_common_path_prefix = __commonJS({
"node_modules/common-path-prefix/index.js"(exports, module) {
"use strict";
var { sep: DEFAULT_SEPARATOR } = __require("path");
var determineSeparator = (paths) => {
for (const path10 of paths) {
const match = /(\/|\\)/.exec(path10);
if (match !== null)
return match[0];
}
return DEFAULT_SEPARATOR;
};
module.exports = function commonPathPrefix2(paths, sep = determineSeparator(paths)) {
const [first = "", ...remaining] = paths;
if (first === "" || remaining.length === 0)
return "";
const parts = first.split(sep);
let endOfPrefix = parts.length;
for (const path10 of remaining) {
const compare = path10.split(sep);
for (let i = 0; i < endOfPrefix; i++) {
if (compare[i] !== parts[i]) {
endOfPrefix = i;
}
}
if (endOfPrefix === 0)
return "";
}
const prefix = parts.slice(0, endOfPrefix).join(sep);
return prefix.endsWith(sep) ? prefix : prefix + sep;
};
}
});
// node_modules/json-buffer/index.js
var require_json_buffer = __commonJS({
"node_modules/json-buffer/index.js"(exports) {
exports.stringify = function stringify4(o) {
if ("undefined" == typeof o)
return o;
if (o && Buffer.isBuffer(o))
return JSON.stringify(":base64:" + o.toString("base64"));
if (o && o.toJSON)
o = o.toJSON();
if (o && "object" === typeof o) {
var s = "";
var array2 = Array.isArray(o);
s = array2 ? "[" : "{";
var first = true;
for (var k in o) {
var ignore = "function" == typeof o[k] || !array2 && "undefined" === typeof o[k];
if (Object.hasOwnProperty.call(o, k) && !ignore) {
if (!first)
s += ",";
first = false;
if (array2) {
if (o[k] == void 0)
s += "null";
else
s += stringify4(o[k]);
} else if (o[k] !== void 0) {
s += stringify4(k) + ":" + stringify4(o[k]);
}
}
}
s += array2 ? "]" : "}";
return s;
} else if ("string" === typeof o) {
return JSON.stringify(/^:/.test(o) ? ":" + o : o);
} else if ("undefined" === typeof o) {
return "null";
} else
return JSON.stringify(o);
};
exports.parse = function(s) {
return JSON.parse(s, function(key, value) {
if ("string" === typeof value) {
if (/^:base64:/.test(value))
return Buffer.from(value.substring(8), "base64");
else
return /^:/.test(value) ? value.substring(1) : value;
}
return value;
});
};
}
});
// node_modules/keyv/src/index.js
var require_src = __commonJS({
"node_modules/keyv/src/index.js"(exports, module) {
"use strict";
var EventEmitter = __require("events");
var JSONB = require_json_buffer();
var loadStore = (options) => {
const adapters = {
redis: "@keyv/redis",
rediss: "@keyv/redis",
mongodb: "@keyv/mongo",
mongo: "@keyv/mongo",
sqlite: "@keyv/sqlite",
postgresql: "@keyv/postgres",
postgres: "@keyv/postgres",
mysql: "@keyv/mysql",
etcd: "@keyv/etcd",
offline: "@keyv/offline",
tiered: "@keyv/tiered"
};
if (options.adapter || options.uri) {
const adapter = options.adapter || /^[^:+]*/.exec(options.uri)[0];
return new (__require(adapters[adapter]))(options);
}
return /* @__PURE__ */ new Map();
};
var iterableAdapters = [
"sqlite",
"postgres",
"mysql",
"mongo",
"redis",
"tiered"
];
var Keyv = class extends EventEmitter {
constructor(uri, { emitErrors = true, ...options } = {}) {
super();
this.opts = {
namespace: "keyv",
serialize: JSONB.stringify,
deserialize: JSONB.parse,
...typeof uri === "string" ? { uri } : uri,
...options
};
if (!this.opts.store) {
const adapterOptions = { ...this.opts };
this.opts.store = loadStore(adapterOptions);
}
if (this.opts.compression) {
const compression = this.opts.compression;
this.opts.serialize = compression.serialize.bind(compression);
this.opts.deserialize = compression.deserialize.bind(compression);
}
if (typeof this.opts.store.on === "function" && emitErrors) {
this.opts.store.on("error", (error) => this.emit("error", error));
}
this.opts.store.namespace = this.opts.namespace;
const generateIterator = (iterator) => async function* () {
for await (const [key, raw] of typeof iterator === "function" ? iterator(this.opts.store.namespace) : iterator) {
const data = await this.opts.deserialize(raw);
if (this.opts.store.namespace && !key.includes(this.opts.store.namespace)) {
continue;
}
if (typeof data.expires === "number" && Date.now() > data.expires) {
this.delete(key);
continue;
}
yield [this._getKeyUnprefix(key), data.value];
}
};
if (typeof this.opts.store[Symbol.iterator] === "function" && this.opts.store instanceof Map) {
this.iterator = generateIterator(this.opts.store);
} else if (typeof this.opts.store.iterator === "function" && this.opts.store.opts && this._checkIterableAdaptar()) {
this.iterator = generateIterator(this.opts.store.iterator.bind(this.opts.store));
}
}
_checkIterableAdaptar() {
return iterableAdapters.includes(this.opts.store.opts.dialect) || iterableAdapters.findIndex((element) => this.opts.store.opts.url.includes(element)) >= 0;
}
_getKeyPrefix(key) {
return `${this.opts.namespace}:${key}`;
}
_getKeyPrefixArray(keys) {
return keys.map((key) => `${this.opts.namespace}:${key}`);
}
_getKeyUnprefix(key) {
return key.split(":").splice(1).join(":");
}
get(key, options) {
const { store } = this.opts;
const isArray = Array.isArray(key);
const keyPrefixed = isArray ? this._getKeyPrefixArray(key) : this._getKeyPrefix(key);
if (isArray && store.getMany === void 0) {
const promises = [];
for (const key2 of keyPrefixed) {
promises.push(
Promise.resolve().then(() => store.get(key2)).then((data) => typeof data === "string" ? this.opts.deserialize(data) : this.opts.compression ? this.opts.deserialize(data) : data).then((data) => {
if (data === void 0 || data === null) {
return void 0;
}
if (typeof data.expires === "number" && Date.now() > data.expires) {
return this.delete(key2).then(() => void 0);
}
return options && options.raw ? data : data.value;
})
);
}
return Promise.allSettled(promises).then((values) => {
const data = [];
for (const value of values) {
data.push(value.value);
}
return data;
});
}
return Promise.resolve().then(() => isArray ? store.getMany(keyPrefixed) : store.get(keyPrefixed)).then((data) => typeof data === "string" ? this.opts.deserialize(data) : this.opts.compression ? this.opts.deserialize(data) : data).then((data) => {
if (data === void 0 || data === null) {
return void 0;
}
if (isArray) {
const result = [];
for (let row of data) {
if (typeof row === "string") {
row = this.opts.deserialize(row);
}
if (row === void 0 || row === null) {
result.push(void 0);
continue;
}
if (typeof row.expires === "number" && Date.now() > row.expires) {
this.delete(key).then(() => void 0);
result.push(void 0);
} else {
result.push(options && options.raw ? row : row.value);
}
}
return result;
}
if (typeof data.expires === "number" && Date.now() > data.expires) {
return this.delete(key).then(() => void 0);
}
return options && options.raw ? data : data.value;
});
}
set(key, value, ttl) {
const keyPrefixed = this._getKeyPrefix(key);
if (typeof ttl === "undefined") {
ttl = this.opts.ttl;
}
if (ttl === 0) {
ttl = void 0;
}
const { store } = this.opts;
return Promise.resolve().then(() => {
const expires = typeof ttl === "number" ? Date.now() + ttl : null;
if (typeof value === "symbol") {
this.emit("error", "symbol cannot be serialized");
}
value = { value, expires };
return this.opts.serialize(value);
}).then((value2) => store.set(keyPrefixed, value2, ttl)).then(() => true);
}
delete(key) {
const { store } = this.opts;
if (Array.isArray(key)) {
const keyPrefixed2 = this._getKeyPrefixArray(key);
if (store.deleteMany === void 0) {
const promises = [];
for (const key2 of keyPrefixed2) {
promises.push(store.delete(key2));
}
return Promise.allSettled(promises).then((values) => values.every((x) => x.value === true));
}
return Promise.resolve().then(() => store.deleteMany(keyPrefixed2));
}
const keyPrefixed = this._getKeyPrefix(key);
return Promise.resolve().then(() => store.delete(keyPrefixed));
}
clear() {
const { store } = this.opts;
return Promise.resolve().then(() => store.clear());
}
has(key) {
const keyPrefixed = this._getKeyPrefix(key);
const { store } = this.opts;
return Promise.resolve().then(async () => {
if (typeof store.has === "function") {
return store.has(keyPrefixed);
}
const value = await store.get(keyPrefixed);
return value !== void 0;
});
}
disconnect() {
const { store } = this.opts;
if (typeof store.disconnect === "function") {
return store.disconnect();
}
}
};
module.exports = Keyv;
}
});
// node_modules/flatted/cjs/index.js
var require_cjs = __commonJS({
"node_modules/flatted/cjs/index.js"(exports) {
"use strict";
var { parse: $parse, stringify: $stringify } = JSON;
var { keys } = Object;
var Primitive = String;
var primitive = "string";
var ignore = {};
var object = "object";
var noop = (_, value) => value;
var primitives = (value) => value instanceof Primitive ? Primitive(value) : value;
var Primitives = (_, value) => typeof value === primitive ? new Primitive(value) : value;
var revive = (input, parsed, output, $) => {
const lazy = [];
for (let ke = keys(output), { length } = ke, y = 0; y < length; y++) {
const k = ke[y];
const value = output[k];
if (value instanceof Primitive) {
const tmp = input[value];
if (typeof tmp === object && !parsed.has(tmp)) {
parsed.add(tmp);
output[k] = ignore;
la