prettier
Version:
Prettier is an opinionated code formatter
1,427 lines (1,412 loc) • 224 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;
};
// 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/fast-json-stable-stringify/index.js
var require_fast_json_stable_stringify = __commonJS({
"node_modules/fast-json-stable-stringify/index.js"(exports, module) {
"use strict";
module.exports = function(data, opts) {
if (!opts)
opts = {};
if (typeof opts === "function")
opts = { cmp: opts };
var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
var cmp = opts.cmp && /* @__PURE__ */ function(f) {
return function(node) {
return function(a, b) {
var aobj = { key: a, value: node[a] };
var bobj = { key: b, value: node[b] };
return f(aobj, bobj);
};
};
}(opts.cmp);
var seen = [];
return function stringify4(node) {
if (node && node.toJSON && typeof node.toJSON === "function") {
node = node.toJSON();
}
if (node === void 0)
return;
if (typeof node == "number")
return isFinite(node) ? "" + node : "null";
if (typeof node !== "object")
return JSON.stringify(node);
var i, out;
if (Array.isArray(node)) {
out = "[";
for (i = 0; i < node.length; i++) {
if (i)
out += ",";
out += stringify4(node[i]) || "null";
}
return out + "]";
}
if (node === null)
return "null";
if (seen.indexOf(node) !== -1) {
if (cycles)
return JSON.stringify("__cycle__");
throw new TypeError("Converting circular structure to JSON");
}
var seenIndex = seen.push(node) - 1;
var keys = Object.keys(node).sort(cmp && cmp(node));
out = "";
for (i = 0; i < keys.length; i++) {
var key = keys[i];
var value = stringify4(node[key]);
if (!value)
continue;
if (out)
out += ",";
out += JSON.stringify(key) + ":" + value;
}
seen.splice(seenIndex, 1);
return "{" + out + "}";
}(data);
};
}
});
// 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) {
return data.map((row, index) => {
if (typeof row === "string") {
row = this.opts.deserialize(row);
}
if (row === void 0 || row === null) {
return void 0;
}
if (typeof row.expires === "number" && Date.now() > row.expires) {
this.delete(key[index]).then(() => void 0);
return void 0;
}
return options && options.raw ? row : row.value;
});
}
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;
lazy.push({ k, a: [input, parsed, tmp, $] });
} else
output[k] = $.call(output, k, tmp);
} else if (output[k] !== ignore)
output[k] = $.call(output, k, value);
}
for (let { length } = lazy, i = 0; i < length; i++) {
const { k, a } = lazy[i];
output[k] = $.call(output, k, revive.apply(null, a));
}
return output;
};
var set = (known, input, value) => {
const index = Primitive(input.push(value) - 1);
known.set(value, index);
return index;
};
var parse = (text, reviver) => {
const input = $parse(text, Primitives).map(primitives);
const value = input[0];
const $ = reviver || noop;
const tmp = typeof value === object && value ? revive(input, /* @__PURE__ */ new Set(), value, $) : value;
return $.call({ "": tmp }, "", tmp);
};
exports.parse = parse;
var stringify4 = (value, replacer, space) => {
const $ = replacer && typeof replacer === object ? (k, v) => k === "" || -1 < replacer.indexOf(k) ? v : void 0 : replacer || noop;
const known = /* @__PURE__ */ new Map();
const input = [];
const output = [];
let i = +set(known, input, $.call({ "": value }, "", value));
let firstRun = !i;
while (i < input.length) {
firstRun = true;
output[i] = $stringify(input[i++], replace, space);
}
return "[" + output.join(",") + "]";
function replace(key, value2) {
if (firstRun) {
firstRun = !firstRun;
return value2;
}
const after = $.call(this, key, value2);
switch (typeof after) {
case object:
if (after === null)
return after;
case primitive:
return known.get(after) || set(known, input, after);
}
return after;
}
};
exports.stringify = stringify4;
var toJSON = (any) => $parse(stringify4(any));
exports.toJSON = toJSON;
var fromJSON = (any) => parse($stringify(any));
exports.fromJSON = fromJSON;
}
});
// node_modules/flat-cache/src/utils.js
var require_utils = __commonJS({
"node_modules/flat-cache/src/utils.js"(exports, module) {
var fs6 = __require("fs");
var path10 = __require("path");
var flatted = require_cjs();
module.exports = {
tryParse: function(filePath, defaultValue) {
var result;
try {
result = this.readJSON(filePath);
} catch (ex) {
result = defaultValue;
}
return result;
},
/**
* Read json file synchronously using flatted
*
* @method readJSON
* @param {String} filePath Json filepath
* @returns {*} parse result
*/
readJSON: function(filePath) {
return flatted.parse(
fs6.readFileSync(filePath, {
encoding: "utf8"
})
);
},
/**
* Write json file synchronously using circular-json
*
* @method writeJSON
* @param {String} filePath Json filepath
* @param {*} data Object to serialize
*/
writeJSON: function(filePath, data) {
fs6.mkdirSync(path10.dirname(filePath), {
recursive: true
});
fs6.writeFileSync(filePath, flatted.stringify(data));
}
};
}
});
// node_modules/fs.realpath/old.js
var require_old = __commonJS({
"node_modules/fs.realpath/old.js"(exports) {
var pathModule = __require("path");
var isWindows = process.platform === "win32";
var fs6 = __require("fs");
var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
function rethrow() {
var callback;
if (DEBUG) {
var backtrace = new Error();
callback = debugCallback;
} else
callback = missingCallback;
return callback;
function debugCallback(err) {
if (err) {
backtrace.message = err.message;
err = backtrace;
missingCallback(err);
}
}
function missingCallback(err) {
if (err) {
if (process.throwDeprecation)
throw err;
else if (!process.noDeprecation) {
var msg = "fs: missing callback " + (err.stack || err.message);
if (process.traceDeprecation)
console.trace(msg);
else
console.error(msg);
}
}
}
}
function maybeCallback(cb) {
return typeof cb === "function" ? cb : rethrow();
}
var normalize = pathModule.normalize;
if (isWindows) {
nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
} else {
nextPartRe = /(.*?)(?:[\/]+|$)/g;
}
var nextPartRe;
if (isWindows) {
splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
} else {
splitRootRe = /^[\/]*/;
}
var splitRootRe;
exports.realpathSync = function realpathSync(p, cache) {
p = pathModule.resolve(p);
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
return cache[p];
}
var original = p, seenLinks = {}, knownHard = {};
var pos;
var current;
var base;
var previous;
start();
function start() {
var m = splitRootRe.exec(p);
pos = m[0].length;
current = m[0];
base = m[0];
previous = "";
if (isWindows && !knownHard[base]) {
fs6.lstatSync(base);
knownHard[base] = true;
}
}
while (pos < p.length) {
nextPartRe.lastIndex = pos;
var result = nextPartRe.exec(p);
previous = current;
current += result[0];
base = previous + result[1];
pos = nextPartRe.lastIndex;
if (knownHard[base] || cache && cache[base] === base) {
continue;
}
var resolvedLink;
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
resolvedLink = cache[base];
} else {
var stat = fs6.lstatSync(base);
if (!stat.isSymbolicLink()) {
knownHard[base] = true;
if (cache)
cache[base] = base;
continue;
}
var linkTarget = null;
if (!isWindows) {
var id = stat.dev.toString(32) + ":" + stat.ino.toString(32);
if (seenLinks.hasOwnProperty(id)) {
linkTarget = seenLinks[id];
}
}
if (linkTarget === null) {
fs6.statSync(base);
linkTarget = fs6.readlinkSync(base);
}
resolvedLink = pathModule.resolve(previous, linkTarget);
if (cache)
cache[base] = resolvedLink;
if (!isWindows)
seenLinks[id] = linkTarget;
}
p = pathModule.resolve(resolvedLink, p.slice(pos));
start();
}
if (cache)
cache[original] = p;
return p;
};
exports.realpath = function realpath(p, cache, cb) {
if (typeof cb !== "function") {
cb = maybeCallback(cache);
cache = null;
}
p = pathModule.resolve(p);
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
return process.nextTick(cb.bind(null, null, cache[p]));
}
var original = p, seenLinks = {}, knownHard = {};
var pos;
var current;
var base;
var previous;
start();
function start() {
var m = splitRootRe.exec(p);
pos = m[0].length;
current = m[0];
base = m[0];
previous = "";
if (isWindows && !knownHard[base]) {
fs6.lstat(base, function(err) {