swc/crates/swc_bundler/tests/fixture/deno-9591/output/entry.ts

6348 lines
344 KiB
TypeScript
Raw Normal View History

class DenoStdInternalError extends Error {
constructor(message){
super(message);
this.name = "DenoStdInternalError";
}
}
function assert(expr, msg = "") {
if (!expr) {
throw new DenoStdInternalError(msg);
}
}
function get(obj, key) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
return obj[key];
}
}
function getForce(obj, key) {
const v = get(obj, key);
assert(v != null);
return v;
}
function isNumber(x) {
if (typeof x === "number") return true;
if (/^0x[0-9a-f]+$/i.test(String(x))) return true;
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));
}
function hasKey(obj, keys) {
let o = obj;
keys.slice(0, -1).forEach((key)=>{
o = get(o, key) ?? {};
});
const key1 = keys[keys.length - 1];
return key1 in o;
}
function parse(args, { "--": doubleDash = false , alias: alias3 = {} , boolean: __boolean = false , default: defaults = {} , stopEarly =false , string =[] , unknown =(i1)=>i1
} = {}) {
const flags = {
bools: {},
strings: {},
unknownFn: unknown,
allBools: false
};
if (__boolean !== undefined) {
if (typeof __boolean === "boolean") {
flags.allBools = !!__boolean;
} else {
const booleanArgs = typeof __boolean === "string" ? [
__boolean
] : __boolean;
for (const key of booleanArgs.filter(Boolean)){
flags.bools[key] = true;
}
}
}
const aliases = {};
if (alias3 !== undefined) {
for(const key in alias3){
const val = getForce(alias3, key);
if (typeof val === "string") {
aliases[key] = [
val
];
} else {
aliases[key] = val;
}
for (const alias1 of getForce(aliases, key)){
aliases[alias1] = [
key
].concat(aliases[key].filter((y)=>alias1 !== y
));
}
}
}
if (string !== undefined) {
const stringArgs = typeof string === "string" ? [
string
] : string;
for (const key of stringArgs.filter(Boolean)){
flags.strings[key] = true;
const alias = get(aliases, key);
if (alias) {
for (const al of alias){
flags.strings[al] = true;
}
}
}
}
const argv = {
_: []
};
function argDefined(key, arg) {
return flags.allBools && /^--[^=]+$/.test(arg) || get(flags.bools, key) || !!get(flags.strings, key) || !!get(aliases, key);
}
function setKey(obj, keys, value) {
let o = obj;
keys.slice(0, -1).forEach(function(key) {
if (get(o, key) === undefined) {
o[key] = {};
}
o = get(o, key);
});
const key4 = keys[keys.length - 1];
if (get(o, key4) === undefined || get(flags.bools, key4) || typeof get(o, key4) === "boolean") {
o[key4] = value;
} else if (Array.isArray(get(o, key4))) {
o[key4].push(value);
} else {
o[key4] = [
get(o, key4),
value
];
}
}
function setArg(key, val, arg = undefined) {
if (arg && flags.unknownFn && !argDefined(key, arg)) {
if (flags.unknownFn(arg, key, val) === false) return;
}
const value = !get(flags.strings, key) && isNumber(val) ? Number(val) : val;
setKey(argv, key.split("."), value);
const alias = get(aliases, key);
if (alias) {
for (const x of alias){
setKey(argv, x.split("."), value);
}
}
}
function aliasIsBoolean(key) {
return getForce(aliases, key).some((x)=>typeof get(flags.bools, x) === "boolean"
);
}
for (const key3 of Object.keys(flags.bools)){
setArg(key3, defaults[key3] === undefined ? false : defaults[key3]);
}
let notFlags = [];
if (args.includes("--")) {
notFlags = args.slice(args.indexOf("--") + 1);
args = args.slice(0, args.indexOf("--"));
}
for(let i2 = 0; i2 < args.length; i2++){
const arg = args[i2];
if (/^--.+=/.test(arg)) {
const m = arg.match(/^--([^=]+)=(.*)$/s);
assert(m != null);
const [, key, value] = m;
if (flags.bools[key]) {
const booleanValue = value !== "false";
setArg(key, booleanValue, arg);
} else {
setArg(key, value, arg);
}
} else if (/^--no-.+/.test(arg)) {
const m = arg.match(/^--no-(.+)/);
assert(m != null);
setArg(m[1], false, arg);
} else if (/^--.+/.test(arg)) {
const m = arg.match(/^--(.+)/);
assert(m != null);
const [, key] = m;
const next = args[i2 + 1];
if (next !== undefined && !/^-/.test(next) && !get(flags.bools, key) && !flags.allBools && (get(aliases, key) ? !aliasIsBoolean(key) : true)) {
setArg(key, next, arg);
i2++;
} else if (/^(true|false)$/.test(next)) {
setArg(key, next === "true", arg);
i2++;
} else {
setArg(key, get(flags.strings, key) ? "" : true, arg);
}
} else if (/^-[^-]+/.test(arg)) {
const letters = arg.slice(1, -1).split("");
let broken = false;
for(let j = 0; j < letters.length; j++){
const next = arg.slice(j + 2);
if (next === "-") {
setArg(letters[j], next, arg);
continue;
}
if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
setArg(letters[j], next.split(/=(.+)/)[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], get(flags.strings, letters[j]) ? "" : true, arg);
}
}
const [key] = arg.slice(-1);
if (!broken && key !== "-") {
if (args[i2 + 1] && !/^(-|--)[^-]/.test(args[i2 + 1]) && !get(flags.bools, key) && (get(aliases, key) ? !aliasIsBoolean(key) : true)) {
setArg(key, args[i2 + 1], arg);
i2++;
} else if (args[i2 + 1] && /^(true|false)$/.test(args[i2 + 1])) {
setArg(key, args[i2 + 1] === "true", arg);
i2++;
} else {
setArg(key, get(flags.strings, key) ? "" : true, arg);
}
}
} else {
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
argv._.push(flags.strings["_"] ?? !isNumber(arg) ? arg : Number(arg));
}
if (stopEarly) {
argv._.push(...args.slice(i2 + 1));
break;
}
}
}
for (const key2 of Object.keys(defaults)){
if (!hasKey(argv, key2.split("."))) {
setKey(argv, key2.split("."), defaults[key2]);
if (aliases[key2]) {
for (const x of aliases[key2]){
setKey(argv, x.split("."), defaults[key2]);
}
}
}
}
if (doubleDash) {
argv["--"] = [];
for (const key of notFlags){
argv["--"].push(key);
}
} else {
for (const key of notFlags){
argv._.push(key);
}
}
return argv;
}
const mod = {
parse: parse
};
const CHAR_UPPERCASE_A = 65;
const CHAR_LOWERCASE_A = 97;
const CHAR_UPPERCASE_Z = 90;
const CHAR_LOWERCASE_Z = 122;
const CHAR_DOT = 46;
const CHAR_FORWARD_SLASH = 47;
const CHAR_BACKWARD_SLASH = 92;
const CHAR_COLON = 58;
const CHAR_QUESTION_MARK = 63;
let NATIVE_OS = "linux";
const navigator = globalThis.navigator;
if (globalThis.Deno != null) {
NATIVE_OS = Deno.build.os;
} else if (navigator?.appVersion?.includes?.("Win") ?? false) {
NATIVE_OS = "windows";
}
const isWindows = NATIVE_OS == "windows";
const SEP = isWindows ? "\\" : "/";
const SEP_PATTERN = isWindows ? /[\\/]+/ : /\/+/;
function assertPath(path1) {
if (typeof path1 !== "string") {
throw new TypeError(`Path must be a string. Received ${JSON.stringify(path1)}`);
}
}
function isPosixPathSeparator(code1) {
return code1 === CHAR_FORWARD_SLASH;
}
function isPathSeparator(code2) {
return isPosixPathSeparator(code2) || code2 === CHAR_BACKWARD_SLASH;
}
function isWindowsDeviceRoot(code3) {
return code3 >= CHAR_LOWERCASE_A && code3 <= CHAR_LOWERCASE_Z || code3 >= CHAR_UPPERCASE_A && code3 <= CHAR_UPPERCASE_Z;
}
function normalizeString(path2, allowAboveRoot, separator, isPathSeparator1) {
let res = "";
let lastSegmentLength = 0;
let lastSlash = -1;
let dots = 0;
let code4;
for(let i3 = 0, len = path2.length; i3 <= len; ++i3){
if (i3 < len) code4 = path2.charCodeAt(i3);
else if (isPathSeparator1(code4)) break;
else code4 = CHAR_FORWARD_SLASH;
if (isPathSeparator1(code4)) {
if (lastSlash === i3 - 1 || dots === 1) {} else if (lastSlash !== i3 - 1 && dots === 2) {
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== CHAR_DOT || res.charCodeAt(res.length - 2) !== CHAR_DOT) {
if (res.length > 2) {
const lastSlashIndex = res.lastIndexOf(separator);
if (lastSlashIndex === -1) {
res = "";
lastSegmentLength = 0;
} else {
res = res.slice(0, lastSlashIndex);
lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
}
lastSlash = i3;
dots = 0;
continue;
} else if (res.length === 2 || res.length === 1) {
res = "";
lastSegmentLength = 0;
lastSlash = i3;
dots = 0;
continue;
}
}
if (allowAboveRoot) {
if (res.length > 0) res += `${separator}..`;
else res = "..";
lastSegmentLength = 2;
}
} else {
if (res.length > 0) res += separator + path2.slice(lastSlash + 1, i3);
else res = path2.slice(lastSlash + 1, i3);
lastSegmentLength = i3 - lastSlash - 1;
}
lastSlash = i3;
dots = 0;
} else if (code4 === CHAR_DOT && dots !== -1) {
++dots;
} else {
dots = -1;
}
}
return res;
}
function _format(sep3, pathObject) {
const dir = pathObject.dir || pathObject.root;
const base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
if (!dir) return base;
if (dir === pathObject.root) return dir + base;
return dir + sep3 + base;
}
const sep = "\\";
const delimiter = ";";
function resolve(...pathSegments) {
let resolvedDevice = "";
let resolvedTail = "";
let resolvedAbsolute = false;
for(let i4 = pathSegments.length - 1; i4 >= -1; i4--){
let path3;
if (i4 >= 0) {
path3 = pathSegments[i4];
} else if (!resolvedDevice) {
if (globalThis.Deno == null) {
throw new TypeError("Resolved a drive-letter-less path without a CWD.");
}
path3 = Deno.cwd();
} else {
if (globalThis.Deno == null) {
throw new TypeError("Resolved a relative path without a CWD.");
}
path3 = Deno.env.get(`=${resolvedDevice}`) || Deno.cwd();
if (path3 === undefined || path3.slice(0, 3).toLowerCase() !== `${resolvedDevice.toLowerCase()}\\`) {
path3 = `${resolvedDevice}\\`;
}
}
assertPath(path3);
const len = path3.length;
if (len === 0) continue;
let rootEnd = 0;
let device = "";
let isAbsolute3 = false;
const code5 = path3.charCodeAt(0);
if (len > 1) {
if (isPathSeparator(code5)) {
isAbsolute3 = true;
if (isPathSeparator(path3.charCodeAt(1))) {
let j = 2;
let last = j;
for(; j < len; ++j){
if (isPathSeparator(path3.charCodeAt(j))) break;
}
if (j < len && j !== last) {
const firstPart = path3.slice(last, j);
last = j;
for(; j < len; ++j){
if (!isPathSeparator(path3.charCodeAt(j))) break;
}
if (j < len && j !== last) {
last = j;
for(; j < len; ++j){
if (isPathSeparator(path3.charCodeAt(j))) break;
}
if (j === len) {
device = `\\\\${firstPart}\\${path3.slice(last)}`;
rootEnd = j;
} else if (j !== last) {
device = `\\\\${firstPart}\\${path3.slice(last, j)}`;
rootEnd = j;
}
}
}
} else {
rootEnd = 1;
}
} else if (isWindowsDeviceRoot(code5)) {
if (path3.charCodeAt(1) === CHAR_COLON) {
device = path3.slice(0, 2);
rootEnd = 2;
if (len > 2) {
if (isPathSeparator(path3.charCodeAt(2))) {
isAbsolute3 = true;
rootEnd = 3;
}
}
}
}
} else if (isPathSeparator(code5)) {
rootEnd = 1;
isAbsolute3 = true;
}
if (device.length > 0 && resolvedDevice.length > 0 && device.toLowerCase() !== resolvedDevice.toLowerCase()) {
continue;
}
if (resolvedDevice.length === 0 && device.length > 0) {
resolvedDevice = device;
}
if (!resolvedAbsolute) {
resolvedTail = `${path3.slice(rootEnd)}\\${resolvedTail}`;
resolvedAbsolute = isAbsolute3;
}
if (resolvedAbsolute && resolvedDevice.length > 0) break;
}
resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, "\\", isPathSeparator);
return resolvedDevice + (resolvedAbsolute ? "\\" : "") + resolvedTail || ".";
}
function normalize(path4) {
assertPath(path4);
const len = path4.length;
if (len === 0) return ".";
let rootEnd = 0;
let device;
let isAbsolute4 = false;
const code6 = path4.charCodeAt(0);
if (len > 1) {
if (isPathSeparator(code6)) {
isAbsolute4 = true;
if (isPathSeparator(path4.charCodeAt(1))) {
let j = 2;
let last = j;
for(; j < len; ++j){
if (isPathSeparator(path4.charCodeAt(j))) break;
}
if (j < len && j !== last) {
const firstPart = path4.slice(last, j);
last = j;
for(; j < len; ++j){
if (!isPathSeparator(path4.charCodeAt(j))) break;
}
if (j < len && j !== last) {
last = j;
for(; j < len; ++j){
if (isPathSeparator(path4.charCodeAt(j))) break;
}
if (j === len) {
return `\\\\${firstPart}\\${path4.slice(last)}\\`;
} else if (j !== last) {
device = `\\\\${firstPart}\\${path4.slice(last, j)}`;
rootEnd = j;
}
}
}
} else {
rootEnd = 1;
}
} else if (isWindowsDeviceRoot(code6)) {
if (path4.charCodeAt(1) === CHAR_COLON) {
device = path4.slice(0, 2);
rootEnd = 2;
if (len > 2) {
if (isPathSeparator(path4.charCodeAt(2))) {
isAbsolute4 = true;
rootEnd = 3;
}
}
}
}
} else if (isPathSeparator(code6)) {
return "\\";
}
let tail;
if (rootEnd < len) {
tail = normalizeString(path4.slice(rootEnd), !isAbsolute4, "\\", isPathSeparator);
} else {
tail = "";
}
if (tail.length === 0 && !isAbsolute4) tail = ".";
if (tail.length > 0 && isPathSeparator(path4.charCodeAt(len - 1))) {
tail += "\\";
}
if (device === undefined) {
if (isAbsolute4) {
if (tail.length > 0) return `\\${tail}`;
else return "\\";
} else if (tail.length > 0) {
return tail;
} else {
return "";
}
} else if (isAbsolute4) {
if (tail.length > 0) return `${device}\\${tail}`;
else return `${device}\\`;
} else if (tail.length > 0) {
return device + tail;
} else {
return device;
}
}
function isAbsolute(path5) {
assertPath(path5);
const len = path5.length;
if (len === 0) return false;
const code7 = path5.charCodeAt(0);
if (isPathSeparator(code7)) {
return true;
} else if (isWindowsDeviceRoot(code7)) {
if (len > 2 && path5.charCodeAt(1) === CHAR_COLON) {
if (isPathSeparator(path5.charCodeAt(2))) return true;
}
}
return false;
}
function join(...paths) {
const pathsCount = paths.length;
if (pathsCount === 0) return ".";
let joined;
let firstPart = null;
for(let i5 = 0; i5 < pathsCount; ++i5){
const path6 = paths[i5];
assertPath(path6);
if (path6.length > 0) {
if (joined === undefined) joined = firstPart = path6;
else joined += `\\${path6}`;
}
}
if (joined === undefined) return ".";
let needsReplace = true;
let slashCount = 0;
assert(firstPart != null);
if (isPathSeparator(firstPart.charCodeAt(0))) {
++slashCount;
const firstLen = firstPart.length;
if (firstLen > 1) {
if (isPathSeparator(firstPart.charCodeAt(1))) {
++slashCount;
if (firstLen > 2) {
if (isPathSeparator(firstPart.charCodeAt(2))) ++slashCount;
else {
needsReplace = false;
}
}
}
}
}
if (needsReplace) {
for(; slashCount < joined.length; ++slashCount){
if (!isPathSeparator(joined.charCodeAt(slashCount))) break;
}
if (slashCount >= 2) joined = `\\${joined.slice(slashCount)}`;
}
return normalize(joined);
}
function relative(from, to) {
assertPath(from);
assertPath(to);
if (from === to) return "";
const fromOrig = resolve(from);
const toOrig = resolve(to);
if (fromOrig === toOrig) return "";
from = fromOrig.toLowerCase();
to = toOrig.toLowerCase();
if (from === to) return "";
let fromStart = 0;
let fromEnd = from.length;
for(; fromStart < fromEnd; ++fromStart){
if (from.charCodeAt(fromStart) !== CHAR_BACKWARD_SLASH) break;
}
for(; fromEnd - 1 > fromStart; --fromEnd){
if (from.charCodeAt(fromEnd - 1) !== CHAR_BACKWARD_SLASH) break;
}
const fromLen = fromEnd - fromStart;
let toStart = 0;
let toEnd = to.length;
for(; toStart < toEnd; ++toStart){
if (to.charCodeAt(toStart) !== CHAR_BACKWARD_SLASH) break;
}
for(; toEnd - 1 > toStart; --toEnd){
if (to.charCodeAt(toEnd - 1) !== CHAR_BACKWARD_SLASH) break;
}
const toLen = toEnd - toStart;
const length = fromLen < toLen ? fromLen : toLen;
let lastCommonSep = -1;
let i6 = 0;
for(; i6 <= length; ++i6){
if (i6 === length) {
if (toLen > length) {
if (to.charCodeAt(toStart + i6) === CHAR_BACKWARD_SLASH) {
return toOrig.slice(toStart + i6 + 1);
} else if (i6 === 2) {
return toOrig.slice(toStart + i6);
}
}
if (fromLen > length) {
if (from.charCodeAt(fromStart + i6) === CHAR_BACKWARD_SLASH) {
lastCommonSep = i6;
} else if (i6 === 2) {
lastCommonSep = 3;
}
}
break;
}
const fromCode = from.charCodeAt(fromStart + i6);
const toCode = to.charCodeAt(toStart + i6);
if (fromCode !== toCode) break;
else if (fromCode === CHAR_BACKWARD_SLASH) lastCommonSep = i6;
}
if (i6 !== length && lastCommonSep === -1) {
return toOrig;
}
let out = "";
if (lastCommonSep === -1) lastCommonSep = 0;
for(i6 = fromStart + lastCommonSep + 1; i6 <= fromEnd; ++i6){
if (i6 === fromEnd || from.charCodeAt(i6) === CHAR_BACKWARD_SLASH) {
if (out.length === 0) out += "..";
else out += "\\..";
}
}
if (out.length > 0) {
return out + toOrig.slice(toStart + lastCommonSep, toEnd);
} else {
toStart += lastCommonSep;
if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) ++toStart;
return toOrig.slice(toStart, toEnd);
}
}
function toNamespacedPath(path7) {
if (typeof path7 !== "string") return path7;
if (path7.length === 0) return "";
const resolvedPath = resolve(path7);
if (resolvedPath.length >= 3) {
if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) {
const code8 = resolvedPath.charCodeAt(2);
if (code8 !== CHAR_QUESTION_MARK && code8 !== CHAR_DOT) {
return `\\\\?\\UNC\\${resolvedPath.slice(2)}`;
}
}
} else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0))) {
if (resolvedPath.charCodeAt(1) === CHAR_COLON && resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
return `\\\\?\\${resolvedPath}`;
}
}
}
return path7;
}
function dirname(path8) {
assertPath(path8);
const len = path8.length;
if (len === 0) return ".";
let rootEnd = -1;
let end = -1;
let matchedSlash = true;
let offset = 0;
const code9 = path8.charCodeAt(0);
if (len > 1) {
if (isPathSeparator(code9)) {
rootEnd = offset = 1;
if (isPathSeparator(path8.charCodeAt(1))) {
let j = 2;
let last = j;
for(; j < len; ++j){
if (isPathSeparator(path8.charCodeAt(j))) break;
}
if (j < len && j !== last) {
last = j;
for(; j < len; ++j){
if (!isPathSeparator(path8.charCodeAt(j))) break;
}
if (j < len && j !== last) {
last = j;
for(; j < len; ++j){
if (isPathSeparator(path8.charCodeAt(j))) break;
}
if (j === len) {
return path8;
}
if (j !== last) {
rootEnd = offset = j + 1;
}
}
}
}
} else if (isWindowsDeviceRoot(code9)) {
if (path8.charCodeAt(1) === CHAR_COLON) {
rootEnd = offset = 2;
if (len > 2) {
if (isPathSeparator(path8.charCodeAt(2))) rootEnd = offset = 3;
}
}
}
} else if (isPathSeparator(code9)) {
return path8;
}
for(let i7 = len - 1; i7 >= offset; --i7){
if (isPathSeparator(path8.charCodeAt(i7))) {
if (!matchedSlash) {
end = i7;
break;
}
} else {
matchedSlash = false;
}
}
if (end === -1) {
if (rootEnd === -1) return ".";
else end = rootEnd;
}
return path8.slice(0, end);
}
function basename(path9, ext = "") {
if (ext !== undefined && typeof ext !== "string") {
throw new TypeError('"ext" argument must be a string');
}
assertPath(path9);
let start = 0;
let end = -1;
let matchedSlash = true;
let i8;
if (path9.length >= 2) {
const drive = path9.charCodeAt(0);
if (isWindowsDeviceRoot(drive)) {
if (path9.charCodeAt(1) === CHAR_COLON) start = 2;
}
}
if (ext !== undefined && ext.length > 0 && ext.length <= path9.length) {
if (ext.length === path9.length && ext === path9) return "";
let extIdx = ext.length - 1;
let firstNonSlashEnd = -1;
for(i8 = path9.length - 1; i8 >= start; --i8){
const code10 = path9.charCodeAt(i8);
if (isPathSeparator(code10)) {
if (!matchedSlash) {
start = i8 + 1;
break;
}
} else {
if (firstNonSlashEnd === -1) {
matchedSlash = false;
firstNonSlashEnd = i8 + 1;
}
if (extIdx >= 0) {
if (code10 === ext.charCodeAt(extIdx)) {
if (--extIdx === -1) {
end = i8;
}
} else {
extIdx = -1;
end = firstNonSlashEnd;
}
}
}
}
if (start === end) end = firstNonSlashEnd;
else if (end === -1) end = path9.length;
return path9.slice(start, end);
} else {
for(i8 = path9.length - 1; i8 >= start; --i8){
if (isPathSeparator(path9.charCodeAt(i8))) {
if (!matchedSlash) {
start = i8 + 1;
break;
}
} else if (end === -1) {
matchedSlash = false;
end = i8 + 1;
}
}
if (end === -1) return "";
return path9.slice(start, end);
}
}
function extname(path10) {
assertPath(path10);
let start = 0;
let startDot = -1;
let startPart = 0;
let end = -1;
let matchedSlash = true;
let preDotState = 0;
if (path10.length >= 2 && path10.charCodeAt(1) === CHAR_COLON && isWindowsDeviceRoot(path10.charCodeAt(0))) {
start = startPart = 2;
}
for(let i9 = path10.length - 1; i9 >= start; --i9){
const code11 = path10.charCodeAt(i9);
if (isPathSeparator(code11)) {
if (!matchedSlash) {
startPart = i9 + 1;
break;
}
continue;
}
if (end === -1) {
matchedSlash = false;
end = i9 + 1;
}
if (code11 === CHAR_DOT) {
if (startDot === -1) startDot = i9;
else if (preDotState !== 1) preDotState = 1;
} else if (startDot !== -1) {
preDotState = -1;
}
}
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
return "";
}
return path10.slice(startDot, end);
}
function format(pathObject) {
if (pathObject === null || typeof pathObject !== "object") {
throw new TypeError(`The "pathObject" argument must be of type Object. Received type ${typeof pathObject}`);
}
return _format("\\", pathObject);
}
function parse1(path11) {
assertPath(path11);
const ret = {
root: "",
dir: "",
base: "",
ext: "",
name: ""
};
const len = path11.length;
if (len === 0) return ret;
let rootEnd = 0;
let code12 = path11.charCodeAt(0);
if (len > 1) {
if (isPathSeparator(code12)) {
rootEnd = 1;
if (isPathSeparator(path11.charCodeAt(1))) {
let j = 2;
let last = j;
for(; j < len; ++j){
if (isPathSeparator(path11.charCodeAt(j))) break;
}
if (j < len && j !== last) {
last = j;
for(; j < len; ++j){
if (!isPathSeparator(path11.charCodeAt(j))) break;
}
if (j < len && j !== last) {
last = j;
for(; j < len; ++j){
if (isPathSeparator(path11.charCodeAt(j))) break;
}
if (j === len) {
rootEnd = j;
} else if (j !== last) {
rootEnd = j + 1;
}
}
}
}
} else if (isWindowsDeviceRoot(code12)) {
if (path11.charCodeAt(1) === CHAR_COLON) {
rootEnd = 2;
if (len > 2) {
if (isPathSeparator(path11.charCodeAt(2))) {
if (len === 3) {
ret.root = ret.dir = path11;
return ret;
}
rootEnd = 3;
}
} else {
ret.root = ret.dir = path11;
return ret;
}
}
}
} else if (isPathSeparator(code12)) {
ret.root = ret.dir = path11;
return ret;
}
if (rootEnd > 0) ret.root = path11.slice(0, rootEnd);
let startDot = -1;
let startPart = rootEnd;
let end = -1;
let matchedSlash = true;
let i10 = path11.length - 1;
let preDotState = 0;
for(; i10 >= rootEnd; --i10){
code12 = path11.charCodeAt(i10);
if (isPathSeparator(code12)) {
if (!matchedSlash) {
startPart = i10 + 1;
break;
}
continue;
}
if (end === -1) {
matchedSlash = false;
end = i10 + 1;
}
if (code12 === CHAR_DOT) {
if (startDot === -1) startDot = i10;
else if (preDotState !== 1) preDotState = 1;
} else if (startDot !== -1) {
preDotState = -1;
}
}
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
if (end !== -1) {
ret.base = ret.name = path11.slice(startPart, end);
}
} else {
ret.name = path11.slice(startPart, startDot);
ret.base = path11.slice(startPart, end);
ret.ext = path11.slice(startDot, end);
}
if (startPart > 0 && startPart !== rootEnd) {
ret.dir = path11.slice(0, startPart - 1);
} else ret.dir = ret.root;
return ret;
}
function fromFileUrl(url) {
url = url instanceof URL ? url : new URL(url);
if (url.protocol != "file:") {
throw new TypeError("Must be a file URL.");
}
let path12 = decodeURIComponent(url.pathname.replace(/\//g, "\\").replace(/%(?![0-9A-Fa-f]{2})/g, "%25")).replace(/^\\*([A-Za-z]:)(\\|$)/, "$1\\");
if (url.hostname != "") {
path12 = `\\\\${url.hostname}${path12}`;
}
return path12;
}
function toFileUrl(path13) {
if (!isAbsolute(path13)) {
throw new TypeError("Must be an absolute path.");
}
const [, hostname, pathname] = path13.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\][^/\\]))?(.*)/);
const url = new URL("file:///");
url.pathname = pathname.replace(/%/g, "%25");
if (hostname != null) {
url.hostname = hostname;
if (!url.hostname) {
throw new TypeError("Invalid hostname.");
}
}
return url;
}
const mod1 = {
sep: sep,
delimiter: delimiter,
resolve: resolve,
normalize: normalize,
isAbsolute: isAbsolute,
join: join,
relative: relative,
toNamespacedPath: toNamespacedPath,
dirname: dirname,
basename: basename,
extname: extname,
format: format,
parse: parse1,
fromFileUrl: fromFileUrl,
toFileUrl: toFileUrl
};
const sep1 = "/";
const delimiter1 = ":";
function resolve1(...pathSegments) {
let resolvedPath = "";
let resolvedAbsolute = false;
for(let i11 = pathSegments.length - 1; i11 >= -1 && !resolvedAbsolute; i11--){
let path14;
if (i11 >= 0) path14 = pathSegments[i11];
else {
if (globalThis.Deno == null) {
throw new TypeError("Resolved a relative path without a CWD.");
}
path14 = Deno.cwd();
}
assertPath(path14);
if (path14.length === 0) {
continue;
}
resolvedPath = `${path14}/${resolvedPath}`;
resolvedAbsolute = path14.charCodeAt(0) === CHAR_FORWARD_SLASH;
}
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, "/", isPosixPathSeparator);
if (resolvedAbsolute) {
if (resolvedPath.length > 0) return `/${resolvedPath}`;
else return "/";
} else if (resolvedPath.length > 0) return resolvedPath;
else return ".";
}
function normalize1(path15) {
assertPath(path15);
if (path15.length === 0) return ".";
const isAbsolute5 = path15.charCodeAt(0) === CHAR_FORWARD_SLASH;
const trailingSeparator = path15.charCodeAt(path15.length - 1) === CHAR_FORWARD_SLASH;
path15 = normalizeString(path15, !isAbsolute5, "/", isPosixPathSeparator);
if (path15.length === 0 && !isAbsolute5) path15 = ".";
if (path15.length > 0 && trailingSeparator) path15 += "/";
if (isAbsolute5) return `/${path15}`;
return path15;
}
function isAbsolute1(path16) {
assertPath(path16);
return path16.length > 0 && path16.charCodeAt(0) === CHAR_FORWARD_SLASH;
}
function join1(...paths) {
if (paths.length === 0) return ".";
let joined;
for(let i12 = 0, len = paths.length; i12 < len; ++i12){
const path17 = paths[i12];
assertPath(path17);
if (path17.length > 0) {
if (!joined) joined = path17;
else joined += `/${path17}`;
}
}
if (!joined) return ".";
return normalize1(joined);
}
function relative1(from, to) {
assertPath(from);
assertPath(to);
if (from === to) return "";
from = resolve1(from);
to = resolve1(to);
if (from === to) return "";
let fromStart = 1;
const fromEnd = from.length;
for(; fromStart < fromEnd; ++fromStart){
if (from.charCodeAt(fromStart) !== CHAR_FORWARD_SLASH) break;
}
const fromLen = fromEnd - fromStart;
let toStart = 1;
const toEnd = to.length;
for(; toStart < toEnd; ++toStart){
if (to.charCodeAt(toStart) !== CHAR_FORWARD_SLASH) break;
}
const toLen = toEnd - toStart;
const length = fromLen < toLen ? fromLen : toLen;
let lastCommonSep = -1;
let i13 = 0;
for(; i13 <= length; ++i13){
if (i13 === length) {
if (toLen > length) {
if (to.charCodeAt(toStart + i13) === CHAR_FORWARD_SLASH) {
return to.slice(toStart + i13 + 1);
} else if (i13 === 0) {
return to.slice(toStart + i13);
}
} else if (fromLen > length) {
if (from.charCodeAt(fromStart + i13) === CHAR_FORWARD_SLASH) {
lastCommonSep = i13;
} else if (i13 === 0) {
lastCommonSep = 0;
}
}
break;
}
const fromCode = from.charCodeAt(fromStart + i13);
const toCode = to.charCodeAt(toStart + i13);
if (fromCode !== toCode) break;
else if (fromCode === CHAR_FORWARD_SLASH) lastCommonSep = i13;
}
let out = "";
for(i13 = fromStart + lastCommonSep + 1; i13 <= fromEnd; ++i13){
if (i13 === fromEnd || from.charCodeAt(i13) === CHAR_FORWARD_SLASH) {
if (out.length === 0) out += "..";
else out += "/..";
}
}
if (out.length > 0) return out + to.slice(toStart + lastCommonSep);
else {
toStart += lastCommonSep;
if (to.charCodeAt(toStart) === CHAR_FORWARD_SLASH) ++toStart;
return to.slice(toStart);
}
}
function toNamespacedPath1(path18) {
return path18;
}
function dirname1(path19) {
assertPath(path19);
if (path19.length === 0) return ".";
const hasRoot = path19.charCodeAt(0) === CHAR_FORWARD_SLASH;
let end = -1;
let matchedSlash = true;
for(let i14 = path19.length - 1; i14 >= 1; --i14){
if (path19.charCodeAt(i14) === CHAR_FORWARD_SLASH) {
if (!matchedSlash) {
end = i14;
break;
}
} else {
matchedSlash = false;
}
}
if (end === -1) return hasRoot ? "/" : ".";
if (hasRoot && end === 1) return "//";
return path19.slice(0, end);
}
function basename1(path20, ext = "") {
if (ext !== undefined && typeof ext !== "string") {
throw new TypeError('"ext" argument must be a string');
}
assertPath(path20);
let start = 0;
let end = -1;
let matchedSlash = true;
let i15;
if (ext !== undefined && ext.length > 0 && ext.length <= path20.length) {
if (ext.length === path20.length && ext === path20) return "";
let extIdx = ext.length - 1;
let firstNonSlashEnd = -1;
for(i15 = path20.length - 1; i15 >= 0; --i15){
const code13 = path20.charCodeAt(i15);
if (code13 === CHAR_FORWARD_SLASH) {
if (!matchedSlash) {
start = i15 + 1;
break;
}
} else {
if (firstNonSlashEnd === -1) {
matchedSlash = false;
firstNonSlashEnd = i15 + 1;
}
if (extIdx >= 0) {
if (code13 === ext.charCodeAt(extIdx)) {
if (--extIdx === -1) {
end = i15;
}
} else {
extIdx = -1;
end = firstNonSlashEnd;
}
}
}
}
if (start === end) end = firstNonSlashEnd;
else if (end === -1) end = path20.length;
return path20.slice(start, end);
} else {
for(i15 = path20.length - 1; i15 >= 0; --i15){
if (path20.charCodeAt(i15) === CHAR_FORWARD_SLASH) {
if (!matchedSlash) {
start = i15 + 1;
break;
}
} else if (end === -1) {
matchedSlash = false;
end = i15 + 1;
}
}
if (end === -1) return "";
return path20.slice(start, end);
}
}
function extname1(path21) {
assertPath(path21);
let startDot = -1;
let startPart = 0;
let end = -1;
let matchedSlash = true;
let preDotState = 0;
for(let i16 = path21.length - 1; i16 >= 0; --i16){
const code14 = path21.charCodeAt(i16);
if (code14 === CHAR_FORWARD_SLASH) {
if (!matchedSlash) {
startPart = i16 + 1;
break;
}
continue;
}
if (end === -1) {
matchedSlash = false;
end = i16 + 1;
}
if (code14 === CHAR_DOT) {
if (startDot === -1) startDot = i16;
else if (preDotState !== 1) preDotState = 1;
} else if (startDot !== -1) {
preDotState = -1;
}
}
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
return "";
}
return path21.slice(startDot, end);
}
function format1(pathObject) {
if (pathObject === null || typeof pathObject !== "object") {
throw new TypeError(`The "pathObject" argument must be of type Object. Received type ${typeof pathObject}`);
}
return _format("/", pathObject);
}
function parse2(path22) {
assertPath(path22);
const ret = {
root: "",
dir: "",
base: "",
ext: "",
name: ""
};
if (path22.length === 0) return ret;
const isAbsolute6 = path22.charCodeAt(0) === CHAR_FORWARD_SLASH;
let start;
if (isAbsolute6) {
ret.root = "/";
start = 1;
} else {
start = 0;
}
let startDot = -1;
let startPart = 0;
let end = -1;
let matchedSlash = true;
let i17 = path22.length - 1;
let preDotState = 0;
for(; i17 >= start; --i17){
const code15 = path22.charCodeAt(i17);
if (code15 === CHAR_FORWARD_SLASH) {
if (!matchedSlash) {
startPart = i17 + 1;
break;
}
continue;
}
if (end === -1) {
matchedSlash = false;
end = i17 + 1;
}
if (code15 === CHAR_DOT) {
if (startDot === -1) startDot = i17;
else if (preDotState !== 1) preDotState = 1;
} else if (startDot !== -1) {
preDotState = -1;
}
}
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
if (end !== -1) {
if (startPart === 0 && isAbsolute6) {
ret.base = ret.name = path22.slice(1, end);
} else {
ret.base = ret.name = path22.slice(startPart, end);
}
}
} else {
if (startPart === 0 && isAbsolute6) {
ret.name = path22.slice(1, startDot);
ret.base = path22.slice(1, end);
} else {
ret.name = path22.slice(startPart, startDot);
ret.base = path22.slice(startPart, end);
}
ret.ext = path22.slice(startDot, end);
}
if (startPart > 0) ret.dir = path22.slice(0, startPart - 1);
else if (isAbsolute6) ret.dir = "/";
return ret;
}
function fromFileUrl1(url) {
url = url instanceof URL ? url : new URL(url);
if (url.protocol != "file:") {
throw new TypeError("Must be a file URL.");
}
return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"));
}
function toFileUrl1(path23) {
if (!isAbsolute1(path23)) {
throw new TypeError("Must be an absolute path.");
}
const url = new URL("file:///");
url.pathname = path23.replace(/%/g, "%25").replace(/\\/g, "%5C");
return url;
}
const mod2 = {
sep: sep1,
delimiter: delimiter1,
resolve: resolve1,
normalize: normalize1,
isAbsolute: isAbsolute1,
join: join1,
relative: relative1,
toNamespacedPath: toNamespacedPath1,
dirname: dirname1,
basename: basename1,
extname: extname1,
format: format1,
parse: parse2,
fromFileUrl: fromFileUrl1,
toFileUrl: toFileUrl1
};
function common(paths, sep4 = SEP) {
const [first = "", ...remaining] = paths;
if (first === "" || remaining.length === 0) {
return first.substring(0, first.lastIndexOf(sep4) + 1);
}
const parts = first.split(sep4);
let endOfPrefix = parts.length;
for (const path24 of remaining){
const compare1 = path24.split(sep4);
for(let i18 = 0; i18 < endOfPrefix; i18++){
if (compare1[i18] !== parts[i18]) {
endOfPrefix = i18;
}
}
if (endOfPrefix === 0) {
return "";
}
}
const prefix = parts.slice(0, endOfPrefix).join(sep4);
return prefix.endsWith(sep4) ? prefix : `${prefix}${sep4}`;
}
const path = isWindows ? mod1 : mod2;
const regExpEscapeChars = [
"!",
"$",
"(",
")",
"*",
"+",
".",
"=",
"?",
"[",
"\\",
"^",
"{",
"|"
];
const win32 = mod1;
const posix = mod2;
const { basename: basename2 , delimiter: delimiter2 , dirname: dirname2 , extname: extname2 , format: format2 , fromFileUrl: fromFileUrl2 , isAbsolute: isAbsolute2 , join: join2 , normalize: normalize2 , parse: parse3 , relative: relative2 , resolve: resolve2 , sep: sep2 , toFileUrl: toFileUrl2 , toNamespacedPath: toNamespacedPath2 , } = path;
const rangeEscapeChars = [
"-",
"\\",
"]"
];
function globToRegExp(glob, { extended =true , globstar: globstarOption = true , os =NATIVE_OS } = {}) {
if (glob == "") {
return /(?!)/;
}
const sep5 = os == "windows" ? "(?:\\\\|/)+" : "/+";
const sepMaybe = os == "windows" ? "(?:\\\\|/)*" : "/*";
const seps = os == "windows" ? [
"\\",
"/"
] : [
"/"
];
const globstar = os == "windows" ? "(?:[^\\\\/]*(?:\\\\|/|$)+)*" : "(?:[^/]*(?:/|$)+)*";
const wildcard = os == "windows" ? "[^\\\\/]*" : "[^/]*";
const escapePrefix = os == "windows" ? "`" : "\\";
let newLength = glob.length;
for(; newLength > 1 && seps.includes(glob[newLength - 1]); newLength--);
glob = glob.slice(0, newLength);
let regExpString = "";
for(let j = 0; j < glob.length;){
let segment = "";
const groupStack = [];
let inRange = false;
let inEscape = false;
let endsWithSep = false;
let i19 = j;
for(; i19 < glob.length && !seps.includes(glob[i19]); i19++){
if (inEscape) {
inEscape = false;
const escapeChars = inRange ? rangeEscapeChars : regExpEscapeChars;
segment += escapeChars.includes(glob[i19]) ? `\\${glob[i19]}` : glob[i19];
continue;
}
if (glob[i19] == escapePrefix) {
inEscape = true;
continue;
}
if (glob[i19] == "[") {
if (!inRange) {
inRange = true;
segment += "[";
if (glob[i19 + 1] == "!") {
i19++;
segment += "^";
} else if (glob[i19 + 1] == "^") {
i19++;
segment += "\\^";
}
continue;
} else if (glob[i19 + 1] == ":") {
let k = i19 + 1;
let value = "";
while(glob[k + 1] != null && glob[k + 1] != ":"){
value += glob[k + 1];
k++;
}
if (glob[k + 1] == ":" && glob[k + 2] == "]") {
i19 = k + 2;
if (value == "alnum") segment += "\\dA-Za-z";
else if (value == "alpha") segment += "A-Za-z";
else if (value == "ascii") segment += "\x00-\x7F";
else if (value == "blank") segment += "\t ";
else if (value == "cntrl") segment += "\x00-\x1F\x7F";
else if (value == "digit") segment += "\\d";
else if (value == "graph") segment += "\x21-\x7E";
else if (value == "lower") segment += "a-z";
else if (value == "print") segment += "\x20-\x7E";
else if (value == "punct") {
segment += "!\"#$%&'()*+,\\-./:;<=>?@[\\\\\\]^_{|}~";
} else if (value == "space") segment += "\\s\v";
else if (value == "upper") segment += "A-Z";
else if (value == "word") segment += "\\w";
else if (value == "xdigit") segment += "\\dA-Fa-f";
continue;
}
}
}
if (glob[i19] == "]" && inRange) {
inRange = false;
segment += "]";
continue;
}
if (inRange) {
if (glob[i19] == "\\") {
segment += `\\\\`;
} else {
segment += glob[i19];
}
continue;
}
if (glob[i19] == ")" && groupStack.length > 0 && groupStack[groupStack.length - 1] != "BRACE") {
segment += ")";
const type = groupStack.pop();
if (type == "!") {
segment += wildcard;
} else if (type != "@") {
segment += type;
}
continue;
}
if (glob[i19] == "|" && groupStack.length > 0 && groupStack[groupStack.length - 1] != "BRACE") {
segment += "|";
continue;
}
if (glob[i19] == "+" && extended && glob[i19 + 1] == "(") {
i19++;
groupStack.push("+");
segment += "(?:";
continue;
}
if (glob[i19] == "@" && extended && glob[i19 + 1] == "(") {
i19++;
groupStack.push("@");
segment += "(?:";
continue;
}
if (glob[i19] == "?") {
if (extended && glob[i19 + 1] == "(") {
i19++;
groupStack.push("?");
segment += "(?:";
} else {
segment += ".";
}
continue;
}
if (glob[i19] == "!" && extended && glob[i19 + 1] == "(") {
i19++;
groupStack.push("!");
segment += "(?!";
continue;
}
if (glob[i19] == "{") {
groupStack.push("BRACE");
segment += "(?:";
continue;
}
if (glob[i19] == "}" && groupStack[groupStack.length - 1] == "BRACE") {
groupStack.pop();
segment += ")";
continue;
}
if (glob[i19] == "," && groupStack[groupStack.length - 1] == "BRACE") {
segment += "|";
continue;
}
if (glob[i19] == "*") {
if (extended && glob[i19 + 1] == "(") {
i19++;
groupStack.push("*");
segment += "(?:";
} else {
const prevChar = glob[i19 - 1];
let numStars = 1;
while(glob[i19 + 1] == "*"){
i19++;
numStars++;
}
const nextChar = glob[i19 + 1];
if (globstarOption && numStars == 2 && [
...seps,
undefined
].includes(prevChar) && [
...seps,
undefined
].includes(nextChar)) {
segment += globstar;
endsWithSep = true;
} else {
segment += wildcard;
}
}
continue;
}
segment += regExpEscapeChars.includes(glob[i19]) ? `\\${glob[i19]}` : glob[i19];
}
if (groupStack.length > 0 || inRange || inEscape) {
segment = "";
for (const c of glob.slice(j, i19)){
segment += regExpEscapeChars.includes(c) ? `\\${c}` : c;
endsWithSep = false;
}
}
regExpString += segment;
if (!endsWithSep) {
regExpString += i19 < glob.length ? sep5 : sepMaybe;
endsWithSep = true;
}
while(seps.includes(glob[i19]))i19++;
if (!(i19 > j)) {
throw new Error("Assertion failure: i > j (potential infinite loop)");
}
j = i19;
}
regExpString = `^${regExpString}$`;
return new RegExp(regExpString);
}
function isGlob(str) {
const chars = {
"{": "}",
"(": ")",
"[": "]"
};
const regex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
if (str === "") {
return false;
}
let match;
while(match = regex.exec(str)){
if (match[2]) return true;
let idx = match.index + match[0].length;
const open = match[1];
const close = open ? chars[open] : null;
if (open && close) {
const n = str.indexOf(close, idx);
if (n !== -1) {
idx = n + 1;
}
}
str = str.slice(idx);
}
return false;
}
function normalizeGlob(glob, { globstar =false } = {}) {
if (glob.match(/\0/g)) {
throw new Error(`Glob contains invalid characters: "${glob}"`);
}
if (!globstar) {
return normalize2(glob);
}
const s = SEP_PATTERN.source;
const badParentPattern = new RegExp(`(?<=(${s}|^)\\*\\*${s})\\.\\.(?=${s}|$)`, "g");
return normalize2(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
}
function joinGlobs(globs, { extended =false , globstar =false } = {}) {
if (!globstar || globs.length == 0) {
return join2(...globs);
}
if (globs.length === 0) return ".";
let joined;
for (const glob of globs){
const path25 = glob;
if (path25.length > 0) {
if (!joined) joined = path25;
else joined += `${SEP}${path25}`;
}
}
if (!joined) return ".";
return normalizeGlob(joined, {
extended,
globstar
});
}
const mod3 = {
SEP: SEP,
SEP_PATTERN: SEP_PATTERN,
win32: win32,
posix: posix,
basename: basename2,
delimiter: delimiter2,
dirname: dirname2,
extname: extname2,
format: format2,
fromFileUrl: fromFileUrl2,
isAbsolute: isAbsolute2,
join: join2,
normalize: normalize2,
parse: parse3,
relative: relative2,
resolve: resolve2,
sep: sep2,
toFileUrl: toFileUrl2,
toNamespacedPath: toNamespacedPath2,
common,
globToRegExp,
isGlob,
normalizeGlob,
joinGlobs
};
var LogLevels;
(function(LogLevels1) {
LogLevels1[LogLevels1["NOTSET"] = 0] = "NOTSET";
LogLevels1[LogLevels1["DEBUG"] = 10] = "DEBUG";
LogLevels1[LogLevels1["INFO"] = 20] = "INFO";
LogLevels1[LogLevels1["WARNING"] = 30] = "WARNING";
LogLevels1[LogLevels1["ERROR"] = 40] = "ERROR";
LogLevels1[LogLevels1["CRITICAL"] = 50] = "CRITICAL";
})(LogLevels || (LogLevels = {}));
Object.keys(LogLevels).filter((key)=>isNaN(Number(key))
);
const byLevel = {
[String(LogLevels.NOTSET)]: "NOTSET",
[String(LogLevels.DEBUG)]: "DEBUG",
[String(LogLevels.INFO)]: "INFO",
[String(LogLevels.WARNING)]: "WARNING",
[String(LogLevels.ERROR)]: "ERROR",
[String(LogLevels.CRITICAL)]: "CRITICAL"
};
function getLevelByName(name) {
switch(name){
case "NOTSET":
return LogLevels.NOTSET;
case "DEBUG":
return LogLevels.DEBUG;
case "INFO":
return LogLevels.INFO;
case "WARNING":
return LogLevels.WARNING;
case "ERROR":
return LogLevels.ERROR;
case "CRITICAL":
return LogLevels.CRITICAL;
default:
throw new Error(`no log level found for "${name}"`);
}
}
function getLevelName(level) {
const levelName = byLevel[level];
if (levelName) {
return levelName;
}
throw new Error(`no level name found for level: ${level}`);
}
class LogRecord {
#args;
#datetime;
constructor(options){
this.msg = options.msg;
this.#args = [
...options.args
];
this.level = options.level;
this.loggerName = options.loggerName;
this.#datetime = new Date();
this.levelName = getLevelName(options.level);
}
get args() {
return [
...this.#args
];
}
get datetime() {
return new Date(this.#datetime.getTime());
}
}
class Logger {
#level;
#handlers;
#loggerName;
constructor(loggerName, levelName, options = {}){
this.#loggerName = loggerName;
this.#level = getLevelByName(levelName);
this.#handlers = options.handlers || [];
}
get level() {
return this.#level;
}
set level(level) {
this.#level = level;
}
get levelName() {
return getLevelName(this.#level);
}
set levelName(levelName) {
this.#level = getLevelByName(levelName);
}
get loggerName() {
return this.#loggerName;
}
set handlers(hndls) {
this.#handlers = hndls;
}
get handlers() {
return this.#handlers;
}
_log(level, msg, ...args) {
if (this.level > level) {
return msg instanceof Function ? undefined : msg;
}
let fnResult;
let logMessage;
if (msg instanceof Function) {
fnResult = msg();
logMessage = this.asString(fnResult);
} else {
logMessage = this.asString(msg);
}
const record = new LogRecord({
msg: logMessage,
args: args,
level: level,
loggerName: this.loggerName
});
this.#handlers.forEach((handler)=>{
handler.handle(record);
});
return msg instanceof Function ? fnResult : msg;
}
asString(data) {
if (typeof data === "string") {
return data;
} else if (data === null || typeof data === "number" || typeof data === "bigint" || typeof data === "boolean" || typeof data === "undefined" || typeof data === "symbol") {
return String(data);
} else if (typeof data === "object") {
return JSON.stringify(data);
}
return "undefined";
}
debug(msg, ...args) {
return this._log(LogLevels.DEBUG, msg, ...args);
}
info(msg, ...args) {
return this._log(LogLevels.INFO, msg, ...args);
}
warning(msg, ...args) {
return this._log(LogLevels.WARNING, msg, ...args);
}
error(msg, ...args) {
return this._log(LogLevels.ERROR, msg, ...args);
}
critical(msg, ...args) {
return this._log(LogLevels.CRITICAL, msg, ...args);
}
}
const noColor = globalThis.Deno?.noColor ?? true;
let enabled = !noColor;
function code(open, close) {
return {
open: `\x1b[${open.join(";")}m`,
close: `\x1b[${close}m`,
regexp: new RegExp(`\\x1b\\[${close}m`, "g")
};
}
function run(str, code16) {
return enabled ? `${code16.open}${str.replace(code16.regexp, code16.open)}${code16.close}` : str;
}
function bold(str) {
return run(str, code([
1
], 22));
}
function red(str) {
return run(str, code([
31
], 39));
}
function yellow(str) {
return run(str, code([
33
], 39));
}
function blue(str) {
return run(str, code([
34
], 39));
}
new RegExp([
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))",
].join("|"), "g");
async function exists(filePath) {
try {
await Deno.lstat(filePath);
return true;
} catch (err) {
if (err instanceof Deno.errors.NotFound) {
return false;
}
throw err;
}
}
function existsSync(filePath) {
try {
Deno.lstatSync(filePath);
return true;
} catch (err) {
if (err instanceof Deno.errors.NotFound) {
return false;
}
throw err;
}
}
function copyBytes(src1, dst, off = 0) {
off = Math.max(0, Math.min(off, dst.byteLength));
const dstBytesAvailable = dst.byteLength - off;
if (src1.byteLength > dstBytesAvailable) {
src1 = src1.subarray(0, dstBytesAvailable);
}
dst.set(src1, off);
return src1.byteLength;
}
const DEFAULT_BUF_SIZE = 4096;
const MIN_BUF_SIZE = 16;
const MAX_CONSECUTIVE_EMPTY_READS = 100;
const CR = "\r".charCodeAt(0);
const LF = "\n".charCodeAt(0);
class BufferFullError extends Error {
constructor(partial){
super("Buffer full");
this.partial = partial;
this.name = "BufferFullError";
}
}
class PartialReadError extends Deno.errors.UnexpectedEof {
constructor(){
super("Encountered UnexpectedEof, data only partially read");
this.name = "PartialReadError";
}
}
class BufReader {
static create(r, size = DEFAULT_BUF_SIZE) {
return r instanceof BufReader ? r : new BufReader(r, size);
}
constructor(rd, size = DEFAULT_BUF_SIZE){
this.r = 0;
this.w = 0;
this.eof = false;
if (size < MIN_BUF_SIZE) {
size = MIN_BUF_SIZE;
}
this._reset(new Uint8Array(size), rd);
}
size() {
return this.buf.byteLength;
}
buffered() {
return this.w - this.r;
}
async _fill() {
if (this.r > 0) {
this.buf.copyWithin(0, this.r, this.w);
this.w -= this.r;
this.r = 0;
}
if (this.w >= this.buf.byteLength) {
throw Error("bufio: tried to fill full buffer");
}
for(let i20 = MAX_CONSECUTIVE_EMPTY_READS; i20 > 0; i20--){
const rr = await this.rd.read(this.buf.subarray(this.w));
if (rr === null) {
this.eof = true;
return;
}
assert(rr >= 0, "negative read");
this.w += rr;
if (rr > 0) {
return;
}
}
throw new Error(`No progress after ${MAX_CONSECUTIVE_EMPTY_READS} read() calls`);
}
reset(r) {
this._reset(this.buf, r);
}
_reset(buf, rd) {
this.buf = buf;
this.rd = rd;
this.eof = false;
}
async read(p) {
let rr = p.byteLength;
if (p.byteLength === 0) return rr;
if (this.r === this.w) {
if (p.byteLength >= this.buf.byteLength) {
const rr = await this.rd.read(p);
const nread = rr ?? 0;
assert(nread >= 0, "negative read");
return rr;
}
this.r = 0;
this.w = 0;
rr = await this.rd.read(this.buf);
if (rr === 0 || rr === null) return rr;
assert(rr >= 0, "negative read");
this.w += rr;
}
const copied = copyBytes(this.buf.subarray(this.r, this.w), p, 0);
this.r += copied;
return copied;
}
async readFull(p) {
let bytesRead = 0;
while(bytesRead < p.length){
try {
const rr = await this.read(p.subarray(bytesRead));
if (rr === null) {
if (bytesRead === 0) {
return null;
} else {
throw new PartialReadError();
}
}
bytesRead += rr;
} catch (err) {
err.partial = p.subarray(0, bytesRead);
throw err;
}
}
return p;
}
async readByte() {
while(this.r === this.w){
if (this.eof) return null;
await this._fill();
}
const c = this.buf[this.r];
this.r++;
return c;
}
async readString(delim) {
if (delim.length !== 1) {
throw new Error("Delimiter should be a single character");
}
const buffer = await this.readSlice(delim.charCodeAt(0));
if (buffer === null) return null;
return new TextDecoder().decode(buffer);
}
async readLine() {
let line;
try {
line = await this.readSlice(LF);
} catch (err) {
let { partial } = err;
assert(partial instanceof Uint8Array, "bufio: caught error from `readSlice()` without `partial` property");
if (!(err instanceof BufferFullError)) {
throw err;
}
if (!this.eof && partial.byteLength > 0 && partial[partial.byteLength - 1] === CR) {
assert(this.r > 0, "bufio: tried to rewind past start of buffer");
this.r--;
partial = partial.subarray(0, partial.byteLength - 1);
}
return {
line: partial,
more: !this.eof
};
}
if (line === null) {
return null;
}
if (line.byteLength === 0) {
return {
line,
more: false
};
}
if (line[line.byteLength - 1] == LF) {
let drop = 1;
if (line.byteLength > 1 && line[line.byteLength - 2] === CR) {
drop = 2;
}
line = line.subarray(0, line.byteLength - drop);
}
return {
line,
more: false
};
}
async readSlice(delim) {
let s = 0;
let slice;
while(true){
let i21 = this.buf.subarray(this.r + s, this.w).indexOf(delim);
if (i21 >= 0) {
i21 += s;
slice = this.buf.subarray(this.r, this.r + i21 + 1);
this.r += i21 + 1;
break;
}
if (this.eof) {
if (this.r === this.w) {
return null;
}
slice = this.buf.subarray(this.r, this.w);
this.r = this.w;
break;
}
if (this.buffered() >= this.buf.byteLength) {
this.r = this.w;
const oldbuf = this.buf;
const newbuf = this.buf.slice(0);
this.buf = newbuf;
throw new BufferFullError(oldbuf);
}
s = this.w - this.r;
try {
await this._fill();
} catch (err) {
err.partial = slice;
throw err;
}
}
return slice;
}
async peek(n) {
if (n < 0) {
throw Error("negative count");
}
let avail = this.w - this.r;
while(avail < n && avail < this.buf.byteLength && !this.eof){
try {
await this._fill();
} catch (err) {
err.partial = this.buf.subarray(this.r, this.w);
throw err;
}
avail = this.w - this.r;
}
if (avail === 0 && this.eof) {
return null;
} else if (avail < n && this.eof) {
return this.buf.subarray(this.r, this.r + avail);
} else if (avail < n) {
throw new BufferFullError(this.buf.subarray(this.r, this.w));
}
return this.buf.subarray(this.r, this.r + n);
}
}
class AbstractBufBase {
size() {
return this.buf.byteLength;
}
available() {
return this.buf.byteLength - this.usedBufferBytes;
}
buffered() {
return this.usedBufferBytes;
}
constructor(){
this.usedBufferBytes = 0;
this.err = null;
}
}
class BufWriter extends AbstractBufBase {
static create(writer, size = DEFAULT_BUF_SIZE) {
return writer instanceof BufWriter ? writer : new BufWriter(writer, size);
}
constructor(writer, size = DEFAULT_BUF_SIZE){
super();
this.writer = writer;
if (size <= 0) {
size = DEFAULT_BUF_SIZE;
}
this.buf = new Uint8Array(size);
}
reset(w) {
this.err = null;
this.usedBufferBytes = 0;
this.writer = w;
}
async flush() {
if (this.err !== null) throw this.err;
if (this.usedBufferBytes === 0) return;
try {
await Deno.writeAll(this.writer, this.buf.subarray(0, this.usedBufferBytes));
} catch (e) {
this.err = e;
throw e;
}
this.buf = new Uint8Array(this.buf.length);
this.usedBufferBytes = 0;
}
async write(data) {
if (this.err !== null) throw this.err;
if (data.length === 0) return 0;
let totalBytesWritten = 0;
let numBytesWritten = 0;
while(data.byteLength > this.available()){
if (this.buffered() === 0) {
try {
numBytesWritten = await this.writer.write(data);
} catch (e) {
this.err = e;
throw e;
}
} else {
numBytesWritten = copyBytes(data, this.buf, this.usedBufferBytes);
this.usedBufferBytes += numBytesWritten;
await this.flush();
}
totalBytesWritten += numBytesWritten;
data = data.subarray(numBytesWritten);
}
numBytesWritten = copyBytes(data, this.buf, this.usedBufferBytes);
this.usedBufferBytes += numBytesWritten;
totalBytesWritten += numBytesWritten;
return totalBytesWritten;
}
}
class BufWriterSync extends AbstractBufBase {
static create(writer, size = DEFAULT_BUF_SIZE) {
return writer instanceof BufWriterSync ? writer : new BufWriterSync(writer, size);
}
constructor(writer, size = DEFAULT_BUF_SIZE){
super();
this.writer = writer;
if (size <= 0) {
size = DEFAULT_BUF_SIZE;
}
this.buf = new Uint8Array(size);
}
reset(w) {
this.err = null;
this.usedBufferBytes = 0;
this.writer = w;
}
flush() {
if (this.err !== null) throw this.err;
if (this.usedBufferBytes === 0) return;
try {
Deno.writeAllSync(this.writer, this.buf.subarray(0, this.usedBufferBytes));
} catch (e) {
this.err = e;
throw e;
}
this.buf = new Uint8Array(this.buf.length);
this.usedBufferBytes = 0;
}
writeSync(data) {
if (this.err !== null) throw this.err;
if (data.length === 0) return 0;
let totalBytesWritten = 0;
let numBytesWritten = 0;
while(data.byteLength > this.available()){
if (this.buffered() === 0) {
try {
numBytesWritten = this.writer.writeSync(data);
} catch (e) {
this.err = e;
throw e;
}
} else {
numBytesWritten = copyBytes(data, this.buf, this.usedBufferBytes);
this.usedBufferBytes += numBytesWritten;
this.flush();
}
totalBytesWritten += numBytesWritten;
data = data.subarray(numBytesWritten);
}
numBytesWritten = copyBytes(data, this.buf, this.usedBufferBytes);
this.usedBufferBytes += numBytesWritten;
totalBytesWritten += numBytesWritten;
return totalBytesWritten;
}
}
const DEFAULT_FORMATTER = "{levelName} {msg}";
class BaseHandler {
constructor(levelName, options = {}){
this.level = getLevelByName(levelName);
this.levelName = levelName;
this.formatter = options.formatter || DEFAULT_FORMATTER;
}
handle(logRecord) {
if (this.level > logRecord.level) return;
const msg = this.format(logRecord);
return this.log(msg);
}
format(logRecord) {
if (this.formatter instanceof Function) {
return this.formatter(logRecord);
}
return this.formatter.replace(/{(\S+)}/g, (match, p1)=>{
const value = logRecord[p1];
if (value == null) {
return match;
}
return String(value);
});
}
log(_msg) {}
async setup() {}
async destroy() {}
}
class ConsoleHandler extends BaseHandler {
format(logRecord) {
let msg = super.format(logRecord);
switch(logRecord.level){
case LogLevels.INFO:
msg = blue(msg);
break;
case LogLevels.WARNING:
msg = yellow(msg);
break;
case LogLevels.ERROR:
msg = red(msg);
break;
case LogLevels.CRITICAL:
msg = bold(red(msg));
break;
default:
break;
}
return msg;
}
log(msg) {
console.log(msg);
}
}
class WriterHandler extends BaseHandler {
#encoder = new TextEncoder();
}
class FileHandler extends WriterHandler {
#unloadCallback = ()=>this.destroy()
;
constructor(levelName, options){
super(levelName, options);
this._encoder = new TextEncoder();
this._filename = options.filename;
this._mode = options.mode ? options.mode : "a";
this._openOptions = {
createNew: this._mode === "x",
create: this._mode !== "x",
append: this._mode === "a",
truncate: this._mode !== "a",
write: true
};
}
async setup() {
this._file = await Deno.open(this._filename, this._openOptions);
this._writer = this._file;
this._buf = new BufWriterSync(this._file);
addEventListener("unload", this.#unloadCallback);
}
handle(logRecord) {
super.handle(logRecord);
if (logRecord.level > LogLevels.ERROR) {
this.flush();
}
}
log(msg) {
this._buf.writeSync(this._encoder.encode(msg + "\n"));
}
flush() {
if (this._buf?.buffered() > 0) {
this._buf.flush();
}
}
destroy() {
this.flush();
this._file?.close();
this._file = undefined;
removeEventListener("unload", this.#unloadCallback);
return Promise.resolve();
}
}
class RotatingFileHandler extends FileHandler {
#maxBytes;
#maxBackupCount;
#currentFileSize = 0;
constructor(levelName, options){
super(levelName, options);
this.#maxBytes = options.maxBytes;
this.#maxBackupCount = options.maxBackupCount;
}
async setup() {
if (this.#maxBytes < 1) {
this.destroy();
throw new Error("maxBytes cannot be less than 1");
}
if (this.#maxBackupCount < 1) {
this.destroy();
throw new Error("maxBackupCount cannot be less than 1");
}
await super.setup();
if (this._mode === "w") {
for(let i22 = 1; i22 <= this.#maxBackupCount; i22++){
if (await exists(this._filename + "." + i22)) {
await Deno.remove(this._filename + "." + i22);
}
}
} else if (this._mode === "x") {
for(let i23 = 1; i23 <= this.#maxBackupCount; i23++){
if (await exists(this._filename + "." + i23)) {
this.destroy();
throw new Deno.errors.AlreadyExists("Backup log file " + this._filename + "." + i23 + " already exists");
}
}
} else {
this.#currentFileSize = (await Deno.stat(this._filename)).size;
}
}
log(msg) {
const msgByteLength = this._encoder.encode(msg).byteLength + 1;
if (this.#currentFileSize + msgByteLength > this.#maxBytes) {
this.rotateLogFiles();
this.#currentFileSize = 0;
}
this._buf.writeSync(this._encoder.encode(msg + "\n"));
this.#currentFileSize += msgByteLength;
}
rotateLogFiles() {
this._buf.flush();
Deno.close(this._file.rid);
for(let i24 = this.#maxBackupCount - 1; i24 >= 0; i24--){
const source1 = this._filename + (i24 === 0 ? "" : "." + i24);
const dest = this._filename + "." + (i24 + 1);
if (existsSync(source1)) {
Deno.renameSync(source1, dest);
}
}
this._file = Deno.openSync(this._filename, this._openOptions);
this._writer = this._file;
this._buf = new BufWriterSync(this._file);
}
}
class LoggerConfig {
}
const DEFAULT_LEVEL = "INFO";
const DEFAULT_CONFIG = {
handlers: {
default: new ConsoleHandler(DEFAULT_LEVEL)
},
loggers: {
default: {
level: DEFAULT_LEVEL,
handlers: [
"default"
]
}
}
};
const state = {
handlers: new Map(),
loggers: new Map(),
config: DEFAULT_CONFIG
};
const handlers = {
BaseHandler,
ConsoleHandler,
WriterHandler,
FileHandler,
RotatingFileHandler
};
function getLogger(name) {
if (!name) {
const d = state.loggers.get("default");
assert(d != null, `"default" logger must be set for getting logger without name`);
return d;
}
const result = state.loggers.get(name);
if (!result) {
const logger = new Logger(name, "NOTSET", {
handlers: []
});
state.loggers.set(name, logger);
return logger;
}
return result;
}
function debug(msg, ...args) {
if (msg instanceof Function) {
return getLogger("default").debug(msg, ...args);
}
return getLogger("default").debug(msg, ...args);
}
function info(msg, ...args) {
if (msg instanceof Function) {
return getLogger("default").info(msg, ...args);
}
return getLogger("default").info(msg, ...args);
}
function warning(msg, ...args) {
if (msg instanceof Function) {
return getLogger("default").warning(msg, ...args);
}
return getLogger("default").warning(msg, ...args);
}
function error(msg, ...args) {
if (msg instanceof Function) {
return getLogger("default").error(msg, ...args);
}
return getLogger("default").error(msg, ...args);
}
function critical(msg, ...args) {
if (msg instanceof Function) {
return getLogger("default").critical(msg, ...args);
}
return getLogger("default").critical(msg, ...args);
}
async function setup(config) {
state.config = {
handlers: {
...DEFAULT_CONFIG.handlers,
...config.handlers
},
loggers: {
...DEFAULT_CONFIG.loggers,
...config.loggers
}
};
state.handlers.forEach((handler)=>{
handler.destroy();
});
state.handlers.clear();
const handlers1 = state.config.handlers || {};
for(const handlerName1 in handlers1){
const handler = handlers1[handlerName1];
await handler.setup();
state.handlers.set(handlerName1, handler);
}
state.loggers.clear();
const loggers = state.config.loggers || {};
for(const loggerName in loggers){
const loggerConfig = loggers[loggerName];
const handlerNames = loggerConfig.handlers || [];
const handlers2 = [];
handlerNames.forEach((handlerName)=>{
const handler = state.handlers.get(handlerName);
if (handler) {
handlers2.push(handler);
}
});
const levelName = loggerConfig.level || DEFAULT_LEVEL;
const logger = new Logger(loggerName, levelName, {
handlers: handlers2
});
state.loggers.set(loggerName, logger);
}
}
await setup(DEFAULT_CONFIG);
const mod4 = await async function() {
return {
LogLevels: LogLevels,
Logger: Logger,
LoggerConfig: LoggerConfig,
handlers: handlers,
getLogger: getLogger,
debug: debug,
info: info,
warning: warning,
error: error,
critical: critical,
setup: setup
};
}();
async function emptyDir(dir) {
try {
const items = [];
for await (const dirEntry of Deno.readDir(dir)){
items.push(dirEntry);
}
while(items.length){
const item = items.shift();
if (item && item.name) {
const filepath = join2(dir, item.name);
await Deno.remove(filepath, {
recursive: true
});
}
}
} catch (err) {
if (!(err instanceof Deno.errors.NotFound)) {
throw err;
}
await Deno.mkdir(dir, {
recursive: true
});
}
}
function emptyDirSync(dir) {
try {
const items = [
...Deno.readDirSync(dir)
];
while(items.length){
const item = items.shift();
if (item && item.name) {
const filepath = join2(dir, item.name);
Deno.removeSync(filepath, {
recursive: true
});
}
}
} catch (err) {
if (!(err instanceof Deno.errors.NotFound)) {
throw err;
}
Deno.mkdirSync(dir, {
recursive: true
});
return;
}
}
function isSubdir(src2, dest, sep6 = sep2) {
if (src2 === dest) {
return false;
}
const srcArray = src2.split(sep6);
const destArray = dest.split(sep6);
return srcArray.every((current, i25)=>destArray[i25] === current
);
}
function getFileInfoType(fileInfo) {
return fileInfo.isFile ? "file" : fileInfo.isDirectory ? "dir" : fileInfo.isSymlink ? "symlink" : undefined;
}
async function ensureDir(dir) {
try {
const fileInfo = await Deno.lstat(dir);
if (!fileInfo.isDirectory) {
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
}
} catch (err) {
if (err instanceof Deno.errors.NotFound) {
await Deno.mkdir(dir, {
recursive: true
});
return;
}
throw err;
}
}
function ensureDirSync(dir) {
try {
const fileInfo = Deno.lstatSync(dir);
if (!fileInfo.isDirectory) {
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
}
} catch (err) {
if (err instanceof Deno.errors.NotFound) {
Deno.mkdirSync(dir, {
recursive: true
});
return;
}
throw err;
}
}
async function ensureFile(filePath) {
try {
const stat = await Deno.lstat(filePath);
if (!stat.isFile) {
throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`);
}
} catch (err) {
if (err instanceof Deno.errors.NotFound) {
await ensureDir(dirname2(filePath));
await Deno.writeFile(filePath, new Uint8Array());
return;
}
throw err;
}
}
function ensureFileSync(filePath) {
try {
const stat = Deno.lstatSync(filePath);
if (!stat.isFile) {
throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`);
}
} catch (err) {
if (err instanceof Deno.errors.NotFound) {
ensureDirSync(dirname2(filePath));
Deno.writeFileSync(filePath, new Uint8Array());
return;
}
throw err;
}
}
async function ensureLink(src3, dest) {
if (await exists(dest)) {
const destStatInfo = await Deno.lstat(dest);
const destFilePathType = getFileInfoType(destStatInfo);
if (destFilePathType !== "file") {
throw new Error(`Ensure path exists, expected 'file', got '${destFilePathType}'`);
}
return;
}
await ensureDir(dirname2(dest));
await Deno.link(src3, dest);
}
function ensureLinkSync(src4, dest) {
if (existsSync(dest)) {
const destStatInfo = Deno.lstatSync(dest);
const destFilePathType = getFileInfoType(destStatInfo);
if (destFilePathType !== "file") {
throw new Error(`Ensure path exists, expected 'file', got '${destFilePathType}'`);
}
return;
}
ensureDirSync(dirname2(dest));
Deno.linkSync(src4, dest);
}
async function ensureSymlink(src5, dest) {
const srcStatInfo = await Deno.lstat(src5);
const srcFilePathType = getFileInfoType(srcStatInfo);
if (await exists(dest)) {
const destStatInfo = await Deno.lstat(dest);
const destFilePathType = getFileInfoType(destStatInfo);
if (destFilePathType !== "symlink") {
throw new Error(`Ensure path exists, expected 'symlink', got '${destFilePathType}'`);
}
return;
}
await ensureDir(dirname2(dest));
if (Deno.build.os === "windows") {
await Deno.symlink(src5, dest, {
type: srcFilePathType === "dir" ? "dir" : "file"
});
} else {
await Deno.symlink(src5, dest);
}
}
function ensureSymlinkSync(src6, dest) {
const srcStatInfo = Deno.lstatSync(src6);
const srcFilePathType = getFileInfoType(srcStatInfo);
if (existsSync(dest)) {
const destStatInfo = Deno.lstatSync(dest);
const destFilePathType = getFileInfoType(destStatInfo);
if (destFilePathType !== "symlink") {
throw new Error(`Ensure path exists, expected 'symlink', got '${destFilePathType}'`);
}
return;
}
ensureDirSync(dirname2(dest));
if (Deno.build.os === "windows") {
Deno.symlinkSync(src6, dest, {
type: srcFilePathType === "dir" ? "dir" : "file"
});
} else {
Deno.symlinkSync(src6, dest);
}
}
function _createWalkEntrySync(path26) {
path26 = normalize2(path26);
const name = basename2(path26);
const info1 = Deno.statSync(path26);
return {
path: path26,
name,
isFile: info1.isFile,
isDirectory: info1.isDirectory,
isSymlink: info1.isSymlink
};
}
async function _createWalkEntry(path27) {
path27 = normalize2(path27);
const name = basename2(path27);
const info2 = await Deno.stat(path27);
return {
path: path27,
name,
isFile: info2.isFile,
isDirectory: info2.isDirectory,
isSymlink: info2.isSymlink
};
}
function include(path28, exts, match, skip) {
if (exts && !exts.some((ext)=>path28.endsWith(ext)
)) {
return false;
}
if (match && !match.some((pattern)=>!!path28.match(pattern)
)) {
return false;
}
if (skip && skip.some((pattern)=>!!path28.match(pattern)
)) {
return false;
}
return true;
}
async function* walk(root, { maxDepth =Infinity , includeFiles =true , includeDirs =true , followSymlinks =false , exts =undefined , match =undefined , skip =undefined } = {}) {
if (maxDepth < 0) {
return;
}
if (includeDirs && include(root, exts, match, skip)) {
yield await _createWalkEntry(root);
}
if (maxDepth < 1 || !include(root, undefined, undefined, skip)) {
return;
}
for await (const entry of Deno.readDir(root)){
if (entry.isSymlink) {
if (followSymlinks) {
throw new Error("unimplemented");
} else {
continue;
}
}
assert(entry.name != null);
const path29 = join2(root, entry.name);
if (entry.isFile) {
if (includeFiles && include(path29, exts, match, skip)) {
yield {
path: path29,
...entry
};
}
} else {
yield* walk(path29, {
maxDepth: maxDepth - 1,
includeFiles,
includeDirs,
followSymlinks,
exts,
match,
skip
});
}
}
}
function* walkSync(root, { maxDepth =Infinity , includeFiles =true , includeDirs =true , followSymlinks =false , exts =undefined , match =undefined , skip =undefined } = {}) {
if (maxDepth < 0) {
return;
}
if (includeDirs && include(root, exts, match, skip)) {
yield _createWalkEntrySync(root);
}
if (maxDepth < 1 || !include(root, undefined, undefined, skip)) {
return;
}
for (const entry of Deno.readDirSync(root)){
if (entry.isSymlink) {
if (followSymlinks) {
throw new Error("unimplemented");
} else {
continue;
}
}
assert(entry.name != null);
const path30 = join2(root, entry.name);
if (entry.isFile) {
if (includeFiles && include(path30, exts, match, skip)) {
yield {
path: path30,
...entry
};
}
} else {
yield* walkSync(path30, {
maxDepth: maxDepth - 1,
includeFiles,
includeDirs,
followSymlinks,
exts,
match,
skip
});
}
}
}
const isWindows1 = Deno.build.os == "windows";
function split(path31) {
const s = SEP_PATTERN.source;
const segments = path31.replace(new RegExp(`^${s}|${s}$`, "g"), "").split(SEP_PATTERN);
const isAbsolute_ = isAbsolute2(path31);
return {
segments,
isAbsolute: isAbsolute_,
hasTrailingSep: !!path31.match(new RegExp(`${s}$`)),
winRoot: isWindows1 && isAbsolute_ ? segments.shift() : undefined
};
}
function throwUnlessNotFound(error1) {
if (!(error1 instanceof Deno.errors.NotFound)) {
throw error1;
}
}
function comparePath(a, b) {
if (a.path < b.path) return -1;
if (a.path > b.path) return 1;
return 0;
}
async function* expandGlob(glob, { root =Deno.cwd() , exclude =[] , includeDirs =true , extended =false , globstar =false } = {}) {
const globOptions = {
extended,
globstar
};
const absRoot = isAbsolute2(root) ? normalize2(root) : joinGlobs([
Deno.cwd(),
root
], globOptions);
const resolveFromRoot = (path32)=>isAbsolute2(path32) ? normalize2(path32) : joinGlobs([
absRoot,
path32
], globOptions)
;
const excludePatterns = exclude.map(resolveFromRoot).map((s)=>globToRegExp(s, globOptions)
);
const shouldInclude = (path33)=>!excludePatterns.some((p)=>!!path33.match(p)
)
;
const { segments , hasTrailingSep , winRoot } = split(resolveFromRoot(glob));
let fixedRoot = winRoot != undefined ? winRoot : "/";
while(segments.length > 0 && !isGlob(segments[0])){
const seg = segments.shift();
assert(seg != null);
fixedRoot = joinGlobs([
fixedRoot,
seg
], globOptions);
}
let fixedRootInfo;
try {
fixedRootInfo = await _createWalkEntry(fixedRoot);
} catch (error2) {
return throwUnlessNotFound(error2);
}
async function* advanceMatch(walkInfo, globSegment) {
if (!walkInfo.isDirectory) {
return;
} else if (globSegment == "..") {
const parentPath = joinGlobs([
walkInfo.path,
".."
], globOptions);
try {
if (shouldInclude(parentPath)) {
return yield await _createWalkEntry(parentPath);
}
} catch (error3) {
throwUnlessNotFound(error3);
}
return;
} else if (globSegment == "**") {
return yield* walk(walkInfo.path, {
includeFiles: false,
skip: excludePatterns
});
}
yield* walk(walkInfo.path, {
maxDepth: 1,
match: [
globToRegExp(joinGlobs([
walkInfo.path,
globSegment
], globOptions), globOptions),
],
skip: excludePatterns
});
}
let currentMatches = [
fixedRootInfo
];
for (const segment of segments){
const nextMatchMap = new Map();
for (const currentMatch of currentMatches){
for await (const nextMatch of advanceMatch(currentMatch, segment)){
nextMatchMap.set(nextMatch.path, nextMatch);
}
}
currentMatches = [
...nextMatchMap.values()
].sort(comparePath);
}
if (hasTrailingSep) {
currentMatches = currentMatches.filter((entry)=>entry.isDirectory
);
}
if (!includeDirs) {
currentMatches = currentMatches.filter((entry)=>!entry.isDirectory
);
}
yield* currentMatches;
}
function* expandGlobSync(glob, { root =Deno.cwd() , exclude =[] , includeDirs =true , extended =false , globstar =false } = {}) {
const globOptions = {
extended,
globstar
};
const absRoot = isAbsolute2(root) ? normalize2(root) : joinGlobs([
Deno.cwd(),
root
], globOptions);
const resolveFromRoot = (path34)=>isAbsolute2(path34) ? normalize2(path34) : joinGlobs([
absRoot,
path34
], globOptions)
;
const excludePatterns = exclude.map(resolveFromRoot).map((s)=>globToRegExp(s, globOptions)
);
const shouldInclude = (path35)=>!excludePatterns.some((p)=>!!path35.match(p)
)
;
const { segments , hasTrailingSep , winRoot } = split(resolveFromRoot(glob));
let fixedRoot = winRoot != undefined ? winRoot : "/";
while(segments.length > 0 && !isGlob(segments[0])){
const seg = segments.shift();
assert(seg != null);
fixedRoot = joinGlobs([
fixedRoot,
seg
], globOptions);
}
let fixedRootInfo;
try {
fixedRootInfo = _createWalkEntrySync(fixedRoot);
} catch (error4) {
return throwUnlessNotFound(error4);
}
function* advanceMatch(walkInfo, globSegment) {
if (!walkInfo.isDirectory) {
return;
} else if (globSegment == "..") {
const parentPath = joinGlobs([
walkInfo.path,
".."
], globOptions);
try {
if (shouldInclude(parentPath)) {
return yield _createWalkEntrySync(parentPath);
}
} catch (error5) {
throwUnlessNotFound(error5);
}
return;
} else if (globSegment == "**") {
return yield* walkSync(walkInfo.path, {
includeFiles: false,
skip: excludePatterns
});
}
yield* walkSync(walkInfo.path, {
maxDepth: 1,
match: [
globToRegExp(joinGlobs([
walkInfo.path,
globSegment
], globOptions), globOptions),
],
skip: excludePatterns
});
}
let currentMatches = [
fixedRootInfo
];
for (const segment of segments){
const nextMatchMap = new Map();
for (const currentMatch of currentMatches){
for (const nextMatch of advanceMatch(currentMatch, segment)){
nextMatchMap.set(nextMatch.path, nextMatch);
}
}
currentMatches = [
...nextMatchMap.values()
].sort(comparePath);
}
if (hasTrailingSep) {
currentMatches = currentMatches.filter((entry)=>entry.isDirectory
);
}
if (!includeDirs) {
currentMatches = currentMatches.filter((entry)=>!entry.isDirectory
);
}
yield* currentMatches;
}
async function move(src7, dest, { overwrite =false } = {}) {
const srcStat = await Deno.stat(src7);
if (srcStat.isDirectory && isSubdir(src7, dest)) {
throw new Error(`Cannot move '${src7}' to a subdirectory of itself, '${dest}'.`);
}
if (overwrite) {
if (await exists(dest)) {
await Deno.remove(dest, {
recursive: true
});
}
await Deno.rename(src7, dest);
} else {
if (await exists(dest)) {
throw new Error("dest already exists.");
}
await Deno.rename(src7, dest);
}
return;
}
function moveSync(src8, dest, { overwrite =false } = {}) {
const srcStat = Deno.statSync(src8);
if (srcStat.isDirectory && isSubdir(src8, dest)) {
throw new Error(`Cannot move '${src8}' to a subdirectory of itself, '${dest}'.`);
}
if (overwrite) {
if (existsSync(dest)) {
Deno.removeSync(dest, {
recursive: true
});
}
Deno.renameSync(src8, dest);
} else {
if (existsSync(dest)) {
throw new Error("dest already exists.");
}
Deno.renameSync(src8, dest);
}
}
const isWindows2 = Deno.build.os === "windows";
async function ensureValidCopy(src9, dest, options, isCopyFolder = false) {
let destStat;
try {
destStat = await Deno.lstat(dest);
} catch (err) {
if (err instanceof Deno.errors.NotFound) {
return;
}
throw err;
}
if (isCopyFolder && !destStat.isDirectory) {
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src9}'.`);
}
if (!options.overwrite) {
throw new Error(`'${dest}' already exists.`);
}
return destStat;
}
function ensureValidCopySync(src10, dest, options, isCopyFolder = false) {
let destStat;
try {
destStat = Deno.lstatSync(dest);
} catch (err) {
if (err instanceof Deno.errors.NotFound) {
return;
}
throw err;
}
if (isCopyFolder && !destStat.isDirectory) {
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src10}'.`);
}
if (!options.overwrite) {
throw new Error(`'${dest}' already exists.`);
}
return destStat;
}
async function copyFile(src11, dest, options) {
await ensureValidCopy(src11, dest, options);
await Deno.copyFile(src11, dest);
if (options.preserveTimestamps) {
const statInfo = await Deno.stat(src11);
assert(statInfo.atime instanceof Date, `statInfo.atime is unavailable`);
assert(statInfo.mtime instanceof Date, `statInfo.mtime is unavailable`);
await Deno.utime(dest, statInfo.atime, statInfo.mtime);
}
}
function copyFileSync(src12, dest, options) {
ensureValidCopySync(src12, dest, options);
Deno.copyFileSync(src12, dest);
if (options.preserveTimestamps) {
const statInfo = Deno.statSync(src12);
assert(statInfo.atime instanceof Date, `statInfo.atime is unavailable`);
assert(statInfo.mtime instanceof Date, `statInfo.mtime is unavailable`);
Deno.utimeSync(dest, statInfo.atime, statInfo.mtime);
}
}
async function copySymLink(src13, dest, options) {
await ensureValidCopy(src13, dest, options);
const originSrcFilePath = await Deno.readLink(src13);
const type = getFileInfoType(await Deno.lstat(src13));
if (isWindows2) {
await Deno.symlink(originSrcFilePath, dest, {
type: type === "dir" ? "dir" : "file"
});
} else {
await Deno.symlink(originSrcFilePath, dest);
}
if (options.preserveTimestamps) {
const statInfo = await Deno.lstat(src13);
assert(statInfo.atime instanceof Date, `statInfo.atime is unavailable`);
assert(statInfo.mtime instanceof Date, `statInfo.mtime is unavailable`);
await Deno.utime(dest, statInfo.atime, statInfo.mtime);
}
}
function copySymlinkSync(src14, dest, options) {
ensureValidCopySync(src14, dest, options);
const originSrcFilePath = Deno.readLinkSync(src14);
const type = getFileInfoType(Deno.lstatSync(src14));
if (isWindows2) {
Deno.symlinkSync(originSrcFilePath, dest, {
type: type === "dir" ? "dir" : "file"
});
} else {
Deno.symlinkSync(originSrcFilePath, dest);
}
if (options.preserveTimestamps) {
const statInfo = Deno.lstatSync(src14);
assert(statInfo.atime instanceof Date, `statInfo.atime is unavailable`);
assert(statInfo.mtime instanceof Date, `statInfo.mtime is unavailable`);
Deno.utimeSync(dest, statInfo.atime, statInfo.mtime);
}
}
async function copyDir(src15, dest, options) {
const destStat = await ensureValidCopy(src15, dest, options, true);
if (!destStat) {
await ensureDir(dest);
}
if (options.preserveTimestamps) {
const srcStatInfo = await Deno.stat(src15);
assert(srcStatInfo.atime instanceof Date, `statInfo.atime is unavailable`);
assert(srcStatInfo.mtime instanceof Date, `statInfo.mtime is unavailable`);
await Deno.utime(dest, srcStatInfo.atime, srcStatInfo.mtime);
}
for await (const entry of Deno.readDir(src15)){
const srcPath = join2(src15, entry.name);
const destPath = join2(dest, basename2(srcPath));
if (entry.isSymlink) {
await copySymLink(srcPath, destPath, options);
} else if (entry.isDirectory) {
await copyDir(srcPath, destPath, options);
} else if (entry.isFile) {
await copyFile(srcPath, destPath, options);
}
}
}
function copyDirSync(src16, dest, options) {
const destStat = ensureValidCopySync(src16, dest, options, true);
if (!destStat) {
ensureDirSync(dest);
}
if (options.preserveTimestamps) {
const srcStatInfo = Deno.statSync(src16);
assert(srcStatInfo.atime instanceof Date, `statInfo.atime is unavailable`);
assert(srcStatInfo.mtime instanceof Date, `statInfo.mtime is unavailable`);
Deno.utimeSync(dest, srcStatInfo.atime, srcStatInfo.mtime);
}
for (const entry of Deno.readDirSync(src16)){
assert(entry.name != null, "file.name must be set");
const srcPath = join2(src16, entry.name);
const destPath = join2(dest, basename2(srcPath));
if (entry.isSymlink) {
copySymlinkSync(srcPath, destPath, options);
} else if (entry.isDirectory) {
copyDirSync(srcPath, destPath, options);
} else if (entry.isFile) {
copyFileSync(srcPath, destPath, options);
}
}
}
async function copy(src17, dest, options = {}) {
src17 = resolve2(src17);
dest = resolve2(dest);
if (src17 === dest) {
throw new Error("Source and destination cannot be the same.");
}
const srcStat = await Deno.lstat(src17);
if (srcStat.isDirectory && isSubdir(src17, dest)) {
throw new Error(`Cannot copy '${src17}' to a subdirectory of itself, '${dest}'.`);
}
if (srcStat.isSymlink) {
await copySymLink(src17, dest, options);
} else if (srcStat.isDirectory) {
await copyDir(src17, dest, options);
} else if (srcStat.isFile) {
await copyFile(src17, dest, options);
}
}
function copySync(src18, dest, options = {}) {
src18 = resolve2(src18);
dest = resolve2(dest);
if (src18 === dest) {
throw new Error("Source and destination cannot be the same.");
}
const srcStat = Deno.lstatSync(src18);
if (srcStat.isDirectory && isSubdir(src18, dest)) {
throw new Error(`Cannot copy '${src18}' to a subdirectory of itself, '${dest}'.`);
}
if (srcStat.isSymlink) {
copySymlinkSync(src18, dest, options);
} else if (srcStat.isDirectory) {
copyDirSync(src18, dest, options);
} else if (srcStat.isFile) {
copyFileSync(src18, dest, options);
}
}
var EOL;
(function(EOL1) {
EOL1["LF"] = "\n";
EOL1["CRLF"] = "\r\n";
})(EOL || (EOL = {}));
const regDetect = /(?:\r?\n)/g;
function detect(content) {
const d = content.match(regDetect);
if (!d || d.length === 0) {
return null;
}
const crlf = d.filter((x)=>x === EOL.CRLF
);
if (crlf.length > 0) {
return EOL.CRLF;
} else {
return EOL.LF;
}
}
function format3(content, eol) {
return content.replace(regDetect, eol);
}
const mod5 = {
exists,
existsSync,
emptyDir,
emptyDirSync,
ensureDir,
ensureDirSync,
ensureFile,
ensureFileSync,
ensureLink,
ensureLinkSync,
ensureSymlink,
ensureSymlinkSync,
expandGlob,
expandGlobSync,
_createWalkEntrySync,
_createWalkEntry,
walk,
walkSync,
move,
moveSync,
copy,
copySync,
EOL,
detect,
format: format3
};
const base64abc = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"+",
"/"
];
function encode(data) {
const uint8 = typeof data === "string" ? new TextEncoder().encode(data) : data instanceof Uint8Array ? data : new Uint8Array(data);
let result = "", i26;
const l = uint8.length;
for(i26 = 2; i26 < l; i26 += 3){
result += base64abc[uint8[i26 - 2] >> 2];
result += base64abc[(uint8[i26 - 2] & 3) << 4 | uint8[i26 - 1] >> 4];
result += base64abc[(uint8[i26 - 1] & 15) << 2 | uint8[i26] >> 6];
result += base64abc[uint8[i26] & 63];
}
if (i26 === l + 1) {
result += base64abc[uint8[i26 - 2] >> 2];
result += base64abc[(uint8[i26 - 2] & 3) << 4];
result += "==";
}
if (i26 === l) {
result += base64abc[uint8[i26 - 2] >> 2];
result += base64abc[(uint8[i26 - 2] & 3) << 4 | uint8[i26 - 1] >> 4];
result += base64abc[(uint8[i26 - 1] & 15) << 2];
result += "=";
}
return result;
}
function decode(b64) {
const binString = atob(b64);
const size = binString.length;
const bytes = new Uint8Array(size);
for(let i27 = 0; i27 < size; i27++){
bytes[i27] = binString.charCodeAt(i27);
}
return bytes;
}
const importMeta = {
url: "<https://deno.land/std@0.77.0/hash/_wasm/wasm.js>",
main: false
};
const source = decode("AGFzbQEAAAABSQxgAn9/AGACf38Bf2ADf39/AGADf39/AX9gAX8AYAF/AX9gAABgBH9/f38Bf2AFf39/f38AYAV/f39/fwF/YAJ+fwF/YAF/AX4CTQMDd2JnFV9fd2JpbmRnZW5fc3RyaW5nX25ldwABA3diZxBfX3diaW5kZ2VuX3Rocm93AAADd2JnEl9fd2JpbmRnZW5fcmV0aHJvdwAEA6sBqQEAAgEAAAIFAAACAAQABAADAAAAAQcJAAAAAAAAAAAAAAAAAAAAAAICAgIAAAAAAAAAAAAAAAAAAAACAgICBAAAAgAAAQAAAAAAAAAAAAAAAAAECgEEAQIAAAAAAgIAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAQEAgICAAEGAAMEAgcEAgQEAwMFBAQAAwQDAQEBAQQABwYBBgYBAAELBQUFBQUFBQAEBAUBcAFpaQUDAQARBgkBfwFBgIDAAAsHoQEJBm1lbW9yeQIAE19fd2JnX2Rlbm9oYXNoX2ZyZWUAhAELY3JlYXRlX2hhc2gABQt1cGRhdGVfaGFzaACFAQtkaWdlc3RfaGFzaACCARFfX3diaW5kZ2VuX21hbGxvYwCNARJfX3diaW5kZ2VuX3JlYWxsb2MAkwETX193YmluZGdlbl9leHBvcnRfMgMAD19fd2JpbmRnZW5fZnJlZQCZAQmPAQEAQQELaJcBqgGcAZYBnwFYqwFDDy5XowE3PEFIkgGjAWA/QkliPi9EjgGlAVI9GSiHAaQBR2EwRY8BU18nOooBqAFQIS2JAakBUVkTHnunAUsVJnqmAUoqNjiYAagBcSkyNJgBqQF1LBocmAGnAXQrIiSYAaYBdzU5cDEzeBsddiMlc4wBVoABlQGiAZQBCsixBqkBjEwBVn4gACABKQN4IgIgASkDSCIaIAEpAwAiFyABKQMIIgtCOIkgC0IHiIUgC0I/iYV8fCABKQNwIgNCA4kgA0IGiIUgA0ItiYV8IgRCOIkgBEIHiIUgBEI/iYV8IAEpA1AiPiABKQMQIglCOIkgCUIHiIUgCUI/iYUgC3x8IAJCBoggAkIDiYUgAkItiYV8IgcgASkDQCITIBpCB4ggGkI4iYUgGkI/iYV8fCABKQMwIhQgASkDOCJCQjiJIEJCB4iFIEJCP4mFfCACfCABKQNoIkQgASkDICIVIAEpAygiQ0I4iSBDQgeIhSBDQj+JhXx8IAEpA1giPyABKQMYIgpCOIkgCkIHiIUgCkI/iYUgCXx8IARCBoggBEIDiYUgBEItiYV8IgZCA4kgBkIGiIUgBkItiYV8IgVCA4kgBUIGiIUgBUItiYV8IghCA4kgCEIGiIUgCEItiYV8Igx8IANCB4ggA0I4iYUgA0I/iYUgRHwgCHwgASkDYCJAQjiJIEBCB4iFIEBCP4mFID98IAV8ID5CB4ggPkI4iYUgPkI/iYUgGnwgBnwgE0IHiCATQjiJhSATQj+JhSBCfCAEfCAUQgeIIBRCOImFIBRCP4mFIEN8IAN8IBVCB4ggFUI4iYUgFUI/iYUgCnwgQHwgB0IGiCAHQgOJhSAHQi2JhXwiDUIDiSANQgaIhSANQi2JhXwiDkIDiSAOQgaIhSAOQi2JhXwiEEIDiSAQQgaIhSAQQi2JhXwiEUIDiSARQgaIhSARQi2JhXwiFkIDiSAWQgaIhSAWQi2JhXwiGEIDiSAYQgaIhSAYQi2JhXwiGUI4iSAZQgeIhSAZQj+JhSACQgeIIAJCOImFIAJCP4mFIAN8IBB8IERCB4ggREI4iYUgREI/iYUgQHwgDnwgP0IHiCA/QjiJhSA/Qj+JhSA+fCANfCAMQgaIIAxCA4mFIAxCLYmFfCIbQgOJIBtCBoiFIBtCLYmFfCIcQgOJIBxCBoiFIBxCLYmFfCIdfCAHQgeIIAdCOImFIAdCP4mFIAR8IBF8IB1CBoggHUIDiYUgHUItiYV8Ih4gDEIHiCAMQjiJhSAMQj+JhSAQfHwgCEIHiCAIQjiJhSAIQj+JhSAOfCAdfCAFQgeIIAVCOImFIAVCP4mFIA18IBx8IAZCB4ggBkI4iYUgBkI/iYUgB3wgG3wgGUIGiCAZQgOJhSAZQi2JhXwiH0IDiSAfQgaIhSAfQi2JhXwiIEIDiSAgQgaIhSAgQi2JhXwiIUIDiSAhQgaIhSAhQi2JhXwiInwgGEIHiCAYQjiJhSAYQj+JhSAcfCAhfCAWQgeIIBZCOImFIBZCP4mFIBt8ICB8IBFCB4ggEUI4iYUgEUI/iYUgDHwgH3wgEEIHiCAQQjiJhSAQQj+JhSAIfCAZfCAOQgeIIA5COImFIA5CP4mFIAV8IBh8IA1CB4ggDUI4iYUgDUI/iYUgBnwgFnwgHkIGiCAeQgOJhSAeQi2JhXwiI0IDiSAjQgaIhSAjQi2JhXwiJEIDiSAkQgaIhSAkQi2JhXwiJUIDiSAlQgaIhSAlQi2JhXwiJkIDiSAmQgaIhSAmQi2JhXwiJ0IDiSAnQgaIhSAnQi2JhXwiKEIDiSAoQgaIhSAoQi2JhXwiKUI4iSApQgeIhSApQj+JhSAdQgeIIB1COImFIB1CP4mFIBh8ICV8IBxCB4ggHEI4iYUgHEI/iYUgFnwgJHwgG0IHiCAbQjiJhSAbQj+JhSARfCAjfCAiQgaIICJCA4mFICJCLYmFfCIqQgOJICpCBoiFICpCLYmFfCIrQgOJICtCBoiFICtCLYmFfCIsfCAeQgeIIB5COImFIB5CP4mFIBl8ICZ8ICxCBoggLEIDiYUgLEItiYV8Ii0gIkIHiCAiQjiJhSAiQj+JhSAlfHwgIUIHiCAhQjiJhSAhQj+JhSAkfCAsfCAgQgeIICBCOImFICBCP4mFICN8ICt8IB9CB4ggH0I4iYUgH0I/iYUgHnwgKnwgKUIGiCApQgOJhSApQi2JhXwiLkIDiSAuQgaIhSAuQi2JhXwiL0IDiSAvQgaIhSAvQi2JhXwiMEIDiSAwQgaIhSAwQi2JhXwiMXwgKEIHiCAoQjiJhSAoQj+JhSArfCAwfCAnQgeIICdCOImFICdCP4mFICp8IC98ICZCB4ggJkI4iYUgJkI/iYUgInwgLnwgJUIHiCAlQjiJhSAlQj+JhSAhfCApfCAkQgeIICRCOImFICRCP4mFICB8ICh8ICNCB4ggI0I4iYUgI0I/iYUgH3wgJ3wgLUIGiCAtQgOJhSAtQi2JhXwiMkIDiSAyQgaIhSAyQi2JhXwiM0IDiSAzQgaIhSAzQi2JhXwiNEIDiSA0QgaIhSA0Qi2JhXwiNUIDiSA1QgaIhSA1Qi2JhXwiNkIDiSA2QgaIhSA2Qi2JhXwiN0IDiSA3QgaIhSA3Qi2JhXwiOEI4iSA4QgeIhSA4Qj+JhSAsQgeIICxCOImFICxCP4mFICh8IDR8ICtCB4ggK0I4iYUgK0I/iYUgJ3wgM3wgKkIHiCAqQjiJhSAqQj+JhSAmfCAyfCAxQgaIIDFCA4mFIDFCLYmFfCI5QgOJIDlCBoiFIDlCLYmFfCI6QgOJIDpCBoiFIDpCLYmFfCI7fCAtQgeIIC1COImFIC1CP4mFICl8IDV8IDtCBoggO0IDiYUgO0ItiYV8IjwgMUIHiCAxQjiJhSAxQj+JhSA0fHwgMEIHiCAwQjiJhSAwQj+JhSAzfCA7fCAvQgeIIC9COImFIC9CP4mFIDJ8IDp8IC5CB4ggLkI4iYUgLkI/iYUgLXwgOXwgOEIGiCA4QgOJhSA4Qi2JhXwiPUIDiSA9QgaIhSA9Qi2JhXwiRkIDiSBGQgaIhSBGQi2JhXwiR0IDiSBHQgaIhSBHQi2JhXwiSHwgN0IHiCA3QjiJhSA3Qj+JhSA6fCBHfCA2QgeIIDZCOImFIDZCP4mFIDl8IEZ8IDVCB4ggNUI4iYUgNUI/iYUgMXwgPXwgNEIHiCA0QjiJhSA0Qj+JhSAwfCA4fCAzQgeIIDNCOImFIDNCP4mFIC98IDd8IDJCB4ggMkI4iYUgMkI/iYUgLnwgNnwgPEIGiCA8QgOJhSA8Qi2JhXwiQUIDiSBBQgaIhSBBQi2JhXwiSUID
let wasm;
let cachedTextDecoder = new TextDecoder('utf-8', {
ignoreBOM: true,
fatal: true
});
cachedTextDecoder.decode();
let cachegetUint8Memory0 = null;
function getUint8Memory0() {
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachegetUint8Memory0;
}
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
const heap = new Array(32).fill(undefined);
heap.push(undefined, null, true, false);
let heap_next = heap.length;
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
function getObject(idx) {
return heap[idx];
}
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
let WASM_VECTOR_LEN = 0;
let cachedTextEncoder = new TextEncoder('utf-8');
const encodeString = typeof cachedTextEncoder.encodeInto === 'function' ? function(arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
} : function(arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
};
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length);
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len);
const mem = getUint8Memory0();
let offset = 0;
for(; offset < len; offset++){
const code17 = arg.charCodeAt(offset);
if (code17 > 127) break;
mem[ptr + offset] = code17;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3);
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
function create_hash(algorithm) {
var ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ret = wasm.create_hash(ptr0, len0);
return DenoHash.__wrap(ret);
}
function _assertClass(instance, klass) {
if (!(instance instanceof klass)) {
throw new Error(`expected instance of ${klass.name}`);
}
return instance.ptr;
}
function passArray8ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 1);
getUint8Memory0().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
function update_hash(hash, data) {
_assertClass(hash, DenoHash);
var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
var len0 = WASM_VECTOR_LEN;
wasm.update_hash(hash.ptr, ptr0, len0);
}
let cachegetInt32Memory0 = null;
function getInt32Memory0() {
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
}
return cachegetInt32Memory0;
}
function getArrayU8FromWasm0(ptr, len) {
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
}
function digest_hash(hash) {
try {
const retptr = wasm.__wbindgen_export_2.value - 16;
wasm.__wbindgen_export_2.value = retptr;
_assertClass(hash, DenoHash);
wasm.digest_hash(retptr, hash.ptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var v0 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
return v0;
} finally{
wasm.__wbindgen_export_2.value += 16;
}
}
class DenoHash {
static __wrap(ptr) {
const obj = Object.create(DenoHash.prototype);
obj.ptr = ptr;
return obj;
}
free() {
const ptr = this.ptr;
this.ptr = 0;
wasm.__wbg_denohash_free(ptr);
}
}
async function load(module, imports) {
if (typeof Response === 'function' && module instanceof Response) {
if (typeof WebAssembly.instantiateStreaming === 'function') {
try {
return await WebAssembly.instantiateStreaming(module, imports);
} catch (e) {
if (module.headers.get('Content-Type') != 'application/wasm') {
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
} else {
throw e;
}
}
}
const bytes = await module.arrayBuffer();
return await WebAssembly.instantiate(bytes, imports);
} else {
const instance = await WebAssembly.instantiate(module, imports);
if (instance instanceof WebAssembly.Instance) {
return {
instance,
module
};
} else {
return instance;
}
}
}
async function init(input) {
if (typeof input === 'undefined') {
input = importMeta.url.replace(/\.js$/, '_bg.wasm');
}
const imports = {};
imports.wbg = {};
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
var ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};
imports.wbg.__wbindgen_rethrow = function(arg0) {
throw takeObject(arg0);
};
if (typeof input === 'string' || typeof Request === 'function' && input instanceof Request || typeof URL === 'function' && input instanceof URL) {
input = fetch(input);
}
const { instance , module } = await load(await input, imports);
wasm = instance.exports;
init.__wbindgen_wasm_module = module;
return wasm;
}
const hextable = new TextEncoder().encode("0123456789abcdef");
function encodedLen(n) {
return n * 2;
}
function encode1(src19) {
const dst = new Uint8Array(encodedLen(src19.length));
for(let i28 = 0; i28 < dst.length; i28++){
const v = src19[i28];
dst[i28 * 2] = hextable[v >> 4];
dst[i28 * 2 + 1] = hextable[v & 15];
}
return dst;
}
function encodeToString(src20) {
return new TextDecoder().decode(encode1(src20));
}
await init(source);
const TYPE_ERROR_MSG = "hash: `data` is invalid type";
class Hash {
#hash;
#digested;
constructor(algorithm){
this.#hash = create_hash(algorithm);
this.#digested = false;
}
update(data) {
let msg;
if (typeof data === "string") {
msg = new TextEncoder().encode(data);
} else if (typeof data === "object") {
if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) {
msg = new Uint8Array(data);
} else {
throw new Error(TYPE_ERROR_MSG);
}
} else {
throw new Error(TYPE_ERROR_MSG);
}
update_hash(this.#hash, msg);
return this;
}
digest() {
if (this.#digested) throw new Error("hash: already digested");
this.#digested = true;
return digest_hash(this.#hash);
}
toString(format4 = "hex") {
const finalized = new Uint8Array(this.digest());
switch(format4){
case "hex":
return encodeToString(finalized);
case "base64":
return encode(finalized);
default:
throw new Error("hash: invalid format");
}
}
}
function createHash(algorithm) {
return new Hash(algorithm);
}
const mod6 = {
createHash: createHash
};
const SEMVER_SPEC_VERSION = "2.0.0";
const MAX_LENGTH = 256;
const MAX_SAFE_COMPONENT_LENGTH = 16;
const re = [];
const src = [];
let R = 0;
const NUMERICIDENTIFIER = R++;
src[NUMERICIDENTIFIER] = "0|[1-9]\\d*";
const NUMERICIDENTIFIERLOOSE = R++;
src[NUMERICIDENTIFIERLOOSE] = "[0-9]+";
const NONNUMERICIDENTIFIER = R++;
src[NONNUMERICIDENTIFIER] = "\\d*[a-zA-Z-][a-zA-Z0-9-]*";
const MAINVERSION = R++;
const nid = src[NUMERICIDENTIFIER];
src[MAINVERSION] = `(${nid})\\.(${nid})\\.(${nid})`;
const MAINVERSIONLOOSE = R++;
const nidl = src[NUMERICIDENTIFIERLOOSE];
src[MAINVERSIONLOOSE] = `(${nidl})\\.(${nidl})\\.(${nidl})`;
const PRERELEASEIDENTIFIER = R++;
src[PRERELEASEIDENTIFIER] = "(?:" + src[NUMERICIDENTIFIER] + "|" + src[NONNUMERICIDENTIFIER] + ")";
const PRERELEASEIDENTIFIERLOOSE = R++;
src[PRERELEASEIDENTIFIERLOOSE] = "(?:" + src[NUMERICIDENTIFIERLOOSE] + "|" + src[NONNUMERICIDENTIFIER] + ")";
const PRERELEASE = R++;
src[PRERELEASE] = "(?:-(" + src[PRERELEASEIDENTIFIER] + "(?:\\." + src[PRERELEASEIDENTIFIER] + ")*))";
const PRERELEASELOOSE = R++;
src[PRERELEASELOOSE] = "(?:-?(" + src[PRERELEASEIDENTIFIERLOOSE] + "(?:\\." + src[PRERELEASEIDENTIFIERLOOSE] + ")*))";
const BUILDIDENTIFIER = R++;
src[BUILDIDENTIFIER] = "[0-9A-Za-z-]+";
const BUILD = R++;
src[BUILD] = "(?:\\+(" + src[BUILDIDENTIFIER] + "(?:\\." + src[BUILDIDENTIFIER] + ")*))";
const FULL = R++;
const FULLPLAIN = "v?" + src[MAINVERSION] + src[PRERELEASE] + "?" + src[BUILD] + "?";
src[FULL] = "^" + FULLPLAIN + "$";
const LOOSEPLAIN = "[v=\\s]*" + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + "?" + src[BUILD] + "?";
const LOOSE = R++;
src[LOOSE] = "^" + LOOSEPLAIN + "$";
const GTLT = R++;
src[GTLT] = "((?:<|>)?=?)";
const XRANGEIDENTIFIERLOOSE = R++;
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + "|x|X|\\*";
const XRANGEIDENTIFIER = R++;
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + "|x|X|\\*";
const XRANGEPLAIN = R++;
src[XRANGEPLAIN] = "[v=\\s]*(" + src[XRANGEIDENTIFIER] + ")" + "(?:\\.(" + src[XRANGEIDENTIFIER] + ")" + "(?:\\.(" + src[XRANGEIDENTIFIER] + ")" + "(?:" + src[PRERELEASE] + ")?" + src[BUILD] + "?" + ")?)?";
const XRANGEPLAINLOOSE = R++;
src[XRANGEPLAINLOOSE] = "[v=\\s]*(" + src[XRANGEIDENTIFIERLOOSE] + ")" + "(?:\\.(" + src[XRANGEIDENTIFIERLOOSE] + ")" + "(?:\\.(" + src[XRANGEIDENTIFIERLOOSE] + ")" + "(?:" + src[PRERELEASELOOSE] + ")?" + src[BUILD] + "?" + ")?)?";
const XRANGE = R++;
src[XRANGE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAIN] + "$";
const XRANGELOOSE = R++;
src[XRANGELOOSE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAINLOOSE] + "$";
const COERCE = R++;
src[COERCE] = "(?:^|[^\\d])" + "(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "})" + "(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?" + "(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?" + "(?:$|[^\\d])";
const LONETILDE = R++;
src[LONETILDE] = "(?:~>?)";
const TILDETRIM = R++;
src[TILDETRIM] = "(\\s*)" + src[LONETILDE] + "\\s+";
re[TILDETRIM] = new RegExp(src[TILDETRIM], "g");
const tildeTrimReplace = "$1~";
const TILDE = R++;
src[TILDE] = "^" + src[LONETILDE] + src[XRANGEPLAIN] + "$";
const TILDELOOSE = R++;
src[TILDELOOSE] = "^" + src[LONETILDE] + src[XRANGEPLAINLOOSE] + "$";
const LONECARET = R++;
src[LONECARET] = "(?:\\^)";
const CARETTRIM = R++;
src[CARETTRIM] = "(\\s*)" + src[LONECARET] + "\\s+";
re[CARETTRIM] = new RegExp(src[CARETTRIM], "g");
const caretTrimReplace = "$1^";
const CARET = R++;
src[CARET] = "^" + src[LONECARET] + src[XRANGEPLAIN] + "$";
const CARETLOOSE = R++;
src[CARETLOOSE] = "^" + src[LONECARET] + src[XRANGEPLAINLOOSE] + "$";
const COMPARATORLOOSE = R++;
src[COMPARATORLOOSE] = "^" + src[GTLT] + "\\s*(" + LOOSEPLAIN + ")$|^$";
const COMPARATOR = R++;
src[COMPARATOR] = "^" + src[GTLT] + "\\s*(" + FULLPLAIN + ")$|^$";
const COMPARATORTRIM = R++;
src[COMPARATORTRIM] = "(\\s*)" + src[GTLT] + "\\s*(" + LOOSEPLAIN + "|" + src[XRANGEPLAIN] + ")";
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], "g");
const comparatorTrimReplace = "$1$2$3";
const HYPHENRANGE = R++;
src[HYPHENRANGE] = "^\\s*(" + src[XRANGEPLAIN] + ")" + "\\s+-\\s+" + "(" + src[XRANGEPLAIN] + ")" + "\\s*$";
const HYPHENRANGELOOSE = R++;
src[HYPHENRANGELOOSE] = "^\\s*(" + src[XRANGEPLAINLOOSE] + ")" + "\\s+-\\s+" + "(" + src[XRANGEPLAINLOOSE] + ")" + "\\s*$";
const STAR = R++;
src[STAR] = "(<|>)?=?\\s*\\*";
for(let i = 0; i < R; i++){
if (!re[i]) {
re[i] = new RegExp(src[i]);
}
}
function parse4(version1, optionsOrLoose) {
if (!optionsOrLoose || typeof optionsOrLoose !== "object") {
optionsOrLoose = {
loose: !!optionsOrLoose,
includePrerelease: false
};
}
if (version1 instanceof SemVer) {
return version1;
}
if (typeof version1 !== "string") {
return null;
}
if (version1.length > MAX_LENGTH) {
return null;
}
const r = optionsOrLoose.loose ? re[LOOSE] : re[FULL];
if (!r.test(version1)) {
return null;
}
try {
return new SemVer(version1, optionsOrLoose);
} catch (er) {
return null;
}
}
function valid(version2, optionsOrLoose) {
if (version2 === null) return null;
const v = parse4(version2, optionsOrLoose);
return v ? v.version : null;
}
function clean(version3, optionsOrLoose) {
const s = parse4(version3.trim().replace(/^[=v]+/, ""), optionsOrLoose);
return s ? s.version : null;
}
class SemVer {
constructor(version4, optionsOrLoose){
if (!optionsOrLoose || typeof optionsOrLoose !== "object") {
optionsOrLoose = {
loose: !!optionsOrLoose,
includePrerelease: false
};
}
if (version4 instanceof SemVer) {
if (version4.loose === optionsOrLoose.loose) {
return version4;
} else {
version4 = version4.version;
}
} else if (typeof version4 !== "string") {
throw new TypeError("Invalid Version: " + version4);
}
if (version4.length > MAX_LENGTH) {
throw new TypeError("version is longer than " + MAX_LENGTH + " characters");
}
if (!(this instanceof SemVer)) {
return new SemVer(version4, optionsOrLoose);
}
this.options = optionsOrLoose;
this.loose = !!optionsOrLoose.loose;
const m = version4.trim().match(optionsOrLoose.loose ? re[LOOSE] : re[FULL]);
if (!m) {
throw new TypeError("Invalid Version: " + version4);
}
this.raw = version4;
this.major = +m[1];
this.minor = +m[2];
this.patch = +m[3];
if (this.major > Number.MAX_SAFE_INTEGER || this.major < 0) {
throw new TypeError("Invalid major version");
}
if (this.minor > Number.MAX_SAFE_INTEGER || this.minor < 0) {
throw new TypeError("Invalid minor version");
}
if (this.patch > Number.MAX_SAFE_INTEGER || this.patch < 0) {
throw new TypeError("Invalid patch version");
}
if (!m[4]) {
this.prerelease = [];
} else {
this.prerelease = m[4].split(".").map((id)=>{
if (/^[0-9]+$/.test(id)) {
const num = +id;
if (num >= 0 && num < Number.MAX_SAFE_INTEGER) {
return num;
}
}
return id;
});
}
this.build = m[5] ? m[5].split(".") : [];
this.format();
}
format() {
this.version = this.major + "." + this.minor + "." + this.patch;
if (this.prerelease.length) {
this.version += "-" + this.prerelease.join(".");
}
return this.version;
}
compare(other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
return this.compareMain(other) || this.comparePre(other);
}
compareMain(other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
}
comparePre(other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
if (this.prerelease.length && !other.prerelease.length) {
return -1;
} else if (!this.prerelease.length && other.prerelease.length) {
return 1;
} else if (!this.prerelease.length && !other.prerelease.length) {
return 0;
}
let i29 = 0;
do {
const a = this.prerelease[i29];
const b = other.prerelease[i29];
if (a === undefined && b === undefined) {
return 0;
} else if (b === undefined) {
return 1;
} else if (a === undefined) {
return -1;
} else if (a === b) {
continue;
} else {
return compareIdentifiers(a, b);
}
}while (++i29)
return 1;
}
compareBuild(other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
let i30 = 0;
do {
const a = this.build[i30];
const b = other.build[i30];
if (a === undefined && b === undefined) {
return 0;
} else if (b === undefined) {
return 1;
} else if (a === undefined) {
return -1;
} else if (a === b) {
continue;
} else {
return compareIdentifiers(a, b);
}
}while (++i30)
return 1;
}
inc(release, identifier) {
switch(release){
case "premajor":
this.prerelease.length = 0;
this.patch = 0;
this.minor = 0;
this.major++;
this.inc("pre", identifier);
break;
case "preminor":
this.prerelease.length = 0;
this.patch = 0;
this.minor++;
this.inc("pre", identifier);
break;
case "prepatch":
this.prerelease.length = 0;
this.inc("patch", identifier);
this.inc("pre", identifier);
break;
case "prerelease":
if (this.prerelease.length === 0) {
this.inc("patch", identifier);
}
this.inc("pre", identifier);
break;
case "major":
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
this.major++;
}
this.minor = 0;
this.patch = 0;
this.prerelease = [];
break;
case "minor":
if (this.patch !== 0 || this.prerelease.length === 0) {
this.minor++;
}
this.patch = 0;
this.prerelease = [];
break;
case "patch":
if (this.prerelease.length === 0) {
this.patch++;
}
this.prerelease = [];
break;
case "pre":
if (this.prerelease.length === 0) {
this.prerelease = [
0
];
} else {
let i31 = this.prerelease.length;
while(--i31 >= 0){
if (typeof this.prerelease[i31] === "number") {
this.prerelease[i31]++;
i31 = -2;
}
}
if (i31 === -1) {
this.prerelease.push(0);
}
}
if (identifier) {
if (this.prerelease[0] === identifier) {
if (isNaN(this.prerelease[1])) {
this.prerelease = [
identifier,
0
];
}
} else {
this.prerelease = [
identifier,
0
];
}
}
break;
default:
throw new Error("invalid increment argument: " + release);
}
this.format();
this.raw = this.version;
return this;
}
toString() {
return this.version;
}
}
function inc(version5, release, optionsOrLoose, identifier) {
if (typeof optionsOrLoose === "string") {
identifier = optionsOrLoose;
optionsOrLoose = undefined;
}
try {
return new SemVer(version5, optionsOrLoose).inc(release, identifier).version;
} catch (er) {
return null;
}
}
function diff(version1, version2, optionsOrLoose) {
if (eq(version1, version2, optionsOrLoose)) {
return null;
} else {
const v1 = parse4(version1);
const v2 = parse4(version2);
let prefix = "";
let defaultResult = null;
if (v1 && v2) {
if (v1.prerelease.length || v2.prerelease.length) {
prefix = "pre";
defaultResult = "prerelease";
}
for(const key in v1){
if (key === "major" || key === "minor" || key === "patch") {
if (v1[key] !== v2[key]) {
return prefix + key;
}
}
}
}
return defaultResult;
}
}
const numeric = /^[0-9]+$/;
function compareIdentifiers(a, b) {
const anum = numeric.test(a);
const bnum = numeric.test(b);
if (a === null || b === null) throw "Comparison against null invalid";
if (anum && bnum) {
a = +a;
b = +b;
}
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
}
function rcompareIdentifiers(a, b) {
return compareIdentifiers(b, a);
}
function major(v, optionsOrLoose) {
return new SemVer(v, optionsOrLoose).major;
}
function minor(v, optionsOrLoose) {
return new SemVer(v, optionsOrLoose).minor;
}
function patch(v, optionsOrLoose) {
return new SemVer(v, optionsOrLoose).patch;
}
function compare(v1, v2, optionsOrLoose) {
return new SemVer(v1, optionsOrLoose).compare(new SemVer(v2, optionsOrLoose));
}
function compareLoose(a, b) {
return compare(a, b, true);
}
function compareBuild(a, b, loose) {
var versionA = new SemVer(a, loose);
var versionB = new SemVer(b, loose);
return versionA.compare(versionB) || versionA.compareBuild(versionB);
}
function rcompare(v1, v2, optionsOrLoose) {
return compare(v2, v1, optionsOrLoose);
}
function sort(list, optionsOrLoose) {
return list.sort((a, b)=>{
return compareBuild(a, b, optionsOrLoose);
});
}
function rsort(list, optionsOrLoose) {
return list.sort((a, b)=>{
return compareBuild(b, a, optionsOrLoose);
});
}
function gt(v1, v2, optionsOrLoose) {
return compare(v1, v2, optionsOrLoose) > 0;
}
function lt(v1, v2, optionsOrLoose) {
return compare(v1, v2, optionsOrLoose) < 0;
}
function eq(v1, v2, optionsOrLoose) {
return compare(v1, v2, optionsOrLoose) === 0;
}
function neq(v1, v2, optionsOrLoose) {
return compare(v1, v2, optionsOrLoose) !== 0;
}
function gte(v1, v2, optionsOrLoose) {
return compare(v1, v2, optionsOrLoose) >= 0;
}
function lte(v1, v2, optionsOrLoose) {
return compare(v1, v2, optionsOrLoose) <= 0;
}
function cmp(v1, operator, v2, optionsOrLoose) {
switch(operator){
case "===":
if (typeof v1 === "object") v1 = v1.version;
if (typeof v2 === "object") v2 = v2.version;
return v1 === v2;
case "!==":
if (typeof v1 === "object") v1 = v1.version;
if (typeof v2 === "object") v2 = v2.version;
return v1 !== v2;
case "":
case "=":
case "==":
return eq(v1, v2, optionsOrLoose);
case "!=":
return neq(v1, v2, optionsOrLoose);
case ">":
return gt(v1, v2, optionsOrLoose);
case ">=":
return gte(v1, v2, optionsOrLoose);
case "<":
return lt(v1, v2, optionsOrLoose);
case "<=":
return lte(v1, v2, optionsOrLoose);
default:
throw new TypeError("Invalid operator: " + operator);
}
}
const ANY = {};
class Comparator {
constructor(comp, optionsOrLoose){
if (!optionsOrLoose || typeof optionsOrLoose !== "object") {
optionsOrLoose = {
loose: !!optionsOrLoose,
includePrerelease: false
};
}
if (comp instanceof Comparator) {
if (comp.loose === !!optionsOrLoose.loose) {
return comp;
} else {
comp = comp.value;
}
}
if (!(this instanceof Comparator)) {
return new Comparator(comp, optionsOrLoose);
}
this.options = optionsOrLoose;
this.loose = !!optionsOrLoose.loose;
this.parse(comp);
if (this.semver === ANY) {
this.value = "";
} else {
this.value = this.operator + this.semver.version;
}
}
parse(comp) {
const r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
const m = comp.match(r);
if (!m) {
throw new TypeError("Invalid comparator: " + comp);
}
const m1 = m[1];
this.operator = m1 !== undefined ? m1 : "";
if (this.operator === "=") {
this.operator = "";
}
if (!m[2]) {
this.semver = ANY;
} else {
this.semver = new SemVer(m[2], this.options.loose);
}
}
test(version6) {
if (this.semver === ANY || version6 === ANY) {
return true;
}
if (typeof version6 === "string") {
version6 = new SemVer(version6, this.options);
}
return cmp(version6, this.operator, this.semver, this.options);
}
intersects(comp, optionsOrLoose) {
if (!(comp instanceof Comparator)) {
throw new TypeError("a Comparator is required");
}
if (!optionsOrLoose || typeof optionsOrLoose !== "object") {
optionsOrLoose = {
loose: !!optionsOrLoose,
includePrerelease: false
};
}
let rangeTmp;
if (this.operator === "") {
if (this.value === "") {
return true;
}
rangeTmp = new Range(comp.value, optionsOrLoose);
return satisfies(this.value, rangeTmp, optionsOrLoose);
} else if (comp.operator === "") {
if (comp.value === "") {
return true;
}
rangeTmp = new Range(this.value, optionsOrLoose);
return satisfies(comp.semver, rangeTmp, optionsOrLoose);
}
const sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") && (comp.operator === ">=" || comp.operator === ">");
const sameDirectionDecreasing = (this.operator === "<=" || this.operator === "<") && (comp.operator === "<=" || comp.operator === "<");
const sameSemVer = this.semver.version === comp.semver.version;
const differentDirectionsInclusive = (this.operator === ">=" || this.operator === "<=") && (comp.operator === ">=" || comp.operator === "<=");
const oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver, optionsOrLoose) && (this.operator === ">=" || this.operator === ">") && (comp.operator === "<=" || comp.operator === "<");
const oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver, optionsOrLoose) && (this.operator === "<=" || this.operator === "<") && (comp.operator === ">=" || comp.operator === ">");
return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
}
toString() {
return this.value;
}
}
class Range {
constructor(range1, optionsOrLoose){
if (!optionsOrLoose || typeof optionsOrLoose !== "object") {
optionsOrLoose = {
loose: !!optionsOrLoose,
includePrerelease: false
};
}
if (range1 instanceof Range) {
if (range1.loose === !!optionsOrLoose.loose && range1.includePrerelease === !!optionsOrLoose.includePrerelease) {
return range1;
} else {
return new Range(range1.raw, optionsOrLoose);
}
}
if (range1 instanceof Comparator) {
return new Range(range1.value, optionsOrLoose);
}
if (!(this instanceof Range)) {
return new Range(range1, optionsOrLoose);
}
this.options = optionsOrLoose;
this.loose = !!optionsOrLoose.loose;
this.includePrerelease = !!optionsOrLoose.includePrerelease;
this.raw = range1;
this.set = range1.split(/\s*\|\|\s*/).map((range)=>this.parseRange(range.trim())
).filter((c)=>{
return c.length;
});
if (!this.set.length) {
throw new TypeError("Invalid SemVer Range: " + range1);
}
this.format();
}
format() {
this.range = this.set.map((comps)=>comps.join(" ").trim()
).join("||").trim();
return this.range;
}
parseRange(range) {
const loose = this.options.loose;
range = range.trim();
const hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
range = range.replace(hr, hyphenReplace);
range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
range = range.replace(re[TILDETRIM], tildeTrimReplace);
range = range.replace(re[CARETTRIM], caretTrimReplace);
range = range.split(/\s+/).join(" ");
const compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
let set = range.split(" ").map((comp)=>parseComparator(comp, this.options)
).join(" ").split(/\s+/);
if (this.options.loose) {
set = set.filter((comp)=>{
return !!comp.match(compRe);
});
}
return set.map((comp)=>new Comparator(comp, this.options)
);
}
test(version7) {
if (typeof version7 === "string") {
version7 = new SemVer(version7, this.options);
}
for(var i32 = 0; i32 < this.set.length; i32++){
if (testSet(this.set[i32], version7, this.options)) {
return true;
}
}
return false;
}
intersects(range, optionsOrLoose) {
if (!(range instanceof Range)) {
throw new TypeError("a Range is required");
}
return this.set.some((thisComparators)=>{
return isSatisfiable(thisComparators, optionsOrLoose) && range.set.some((rangeComparators)=>{
return isSatisfiable(rangeComparators, optionsOrLoose) && thisComparators.every((thisComparator)=>{
return rangeComparators.every((rangeComparator)=>{
return thisComparator.intersects(rangeComparator, optionsOrLoose);
});
});
});
});
}
toString() {
return this.range;
}
}
function testSet(set, version8, options) {
for(let i33 = 0; i33 < set.length; i33++){
if (!set[i33].test(version8)) {
return false;
}
}
if (version8.prerelease.length && !options.includePrerelease) {
for(let i34 = 0; i34 < set.length; i34++){
if (set[i34].semver === ANY) {
continue;
}
if (set[i34].semver.prerelease.length > 0) {
const allowed = set[i34].semver;
if (allowed.major === version8.major && allowed.minor === version8.minor && allowed.patch === version8.patch) {
return true;
}
}
}
return false;
}
return true;
}
function isSatisfiable(comparators, options) {
let result = true;
const remainingComparators = comparators.slice();
let testComparator = remainingComparators.pop();
while(result && remainingComparators.length){
result = remainingComparators.every((otherComparator)=>{
return testComparator?.intersects(otherComparator, options);
});
testComparator = remainingComparators.pop();
}
return result;
}
function toComparators(range, optionsOrLoose) {
return new Range(range, optionsOrLoose).set.map((comp)=>{
return comp.map((c)=>c.value
).join(" ").trim().split(" ");
});
}
function parseComparator(comp, options) {
comp = replaceCarets(comp, options);
comp = replaceTildes(comp, options);
comp = replaceXRanges(comp, options);
comp = replaceStars(comp, options);
return comp;
}
function isX(id) {
return !id || id.toLowerCase() === "x" || id === "*";
}
function replaceTildes(comp1, options) {
return comp1.trim().split(/\s+/).map((comp)=>replaceTilde(comp, options)
).join(" ");
}
function replaceTilde(comp, options) {
const r = options.loose ? re[TILDELOOSE] : re[TILDE];
return comp.replace(r, (_, M, m, p, pr)=>{
let ret;
if (isX(M)) {
ret = "";
} else if (isX(m)) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (isX(p)) {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
} else if (pr) {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
} else {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
}
return ret;
});
}
function replaceCarets(comp2, options) {
return comp2.trim().split(/\s+/).map((comp)=>replaceCaret(comp, options)
).join(" ");
}
function replaceCaret(comp, options) {
const r = options.loose ? re[CARETLOOSE] : re[CARET];
return comp.replace(r, (_, M, m, p, pr)=>{
let ret;
if (isX(M)) {
ret = "";
} else if (isX(m)) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (isX(p)) {
if (M === "0") {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
} else {
ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
}
} else if (pr) {
if (M === "0") {
if (m === "0") {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1);
} else {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
}
} else {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0";
}
} else {
if (M === "0") {
if (m === "0") {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1);
} else {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
}
} else {
ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
}
}
return ret;
});
}
function replaceXRanges(comp3, options) {
return comp3.split(/\s+/).map((comp)=>replaceXRange(comp, options)
).join(" ");
}
function replaceXRange(comp, options) {
comp = comp.trim();
const r = options.loose ? re[XRANGELOOSE] : re[XRANGE];
return comp.replace(r, (ret, gtlt, M, m, p, pr)=>{
const xM = isX(M);
const xm = xM || isX(m);
const xp = xm || isX(p);
const anyX = xp;
if (gtlt === "=" && anyX) {
gtlt = "";
}
if (xM) {
if (gtlt === ">" || gtlt === "<") {
ret = "<0.0.0";
} else {
ret = "*";
}
} else if (gtlt && anyX) {
if (xm) {
m = 0;
}
p = 0;
if (gtlt === ">") {
gtlt = ">=";
if (xm) {
M = +M + 1;
m = 0;
p = 0;
} else {
m = +m + 1;
p = 0;
}
} else if (gtlt === "<=") {
gtlt = "<";
if (xm) {
M = +M + 1;
} else {
m = +m + 1;
}
}
ret = gtlt + M + "." + m + "." + p;
} else if (xm) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (xp) {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
}
return ret;
});
}
function replaceStars(comp, options) {
return comp.trim().replace(re[STAR], "");
}
function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
if (isX(fM)) {
from = "";
} else if (isX(fm)) {
from = ">=" + fM + ".0.0";
} else if (isX(fp)) {
from = ">=" + fM + "." + fm + ".0";
} else {
from = ">=" + from;
}
if (isX(tM)) {
to = "";
} else if (isX(tm)) {
to = "<" + (+tM + 1) + ".0.0";
} else if (isX(tp)) {
to = "<" + tM + "." + (+tm + 1) + ".0";
} else if (tpr) {
to = "<=" + tM + "." + tm + "." + tp + "-" + tpr;
} else {
to = "<=" + to;
}
return (from + " " + to).trim();
}
function satisfies(version9, range, optionsOrLoose) {
try {
range = new Range(range, optionsOrLoose);
} catch (er) {
return false;
}
return range.test(version9);
}
function maxSatisfying(versions, range, optionsOrLoose) {
var max = null;
var maxSV = null;
try {
var rangeObj = new Range(range, optionsOrLoose);
} catch (er) {
return null;
}
versions.forEach((v)=>{
if (rangeObj.test(v)) {
if (!max || maxSV && maxSV.compare(v) === -1) {
max = v;
maxSV = new SemVer(max, optionsOrLoose);
}
}
});
return max;
}
function minSatisfying(versions, range, optionsOrLoose) {
var min = null;
var minSV = null;
try {
var rangeObj = new Range(range, optionsOrLoose);
} catch (er) {
return null;
}
versions.forEach((v)=>{
if (rangeObj.test(v)) {
if (!min || minSV.compare(v) === 1) {
min = v;
minSV = new SemVer(min, optionsOrLoose);
}
}
});
return min;
}
function minVersion(range, optionsOrLoose) {
range = new Range(range, optionsOrLoose);
var minver = new SemVer("0.0.0");
if (range.test(minver)) {
return minver;
}
minver = new SemVer("0.0.0-0");
if (range.test(minver)) {
return minver;
}
minver = null;
for(var i35 = 0; i35 < range.set.length; ++i35){
var comparators = range.set[i35];
comparators.forEach((comparator)=>{
var compver = new SemVer(comparator.semver.version);
switch(comparator.operator){
case ">":
if (compver.prerelease.length === 0) {
compver.patch++;
} else {
compver.prerelease.push(0);
}
compver.raw = compver.format();
case "":
case ">=":
if (!minver || gt(minver, compver)) {
minver = compver;
}
break;
case "<":
case "<=":
break;
default:
throw new Error("Unexpected operation: " + comparator.operator);
}
});
}
if (minver && range.test(minver)) {
return minver;
}
return null;
}
function validRange(range, optionsOrLoose) {
try {
if (range === null) return null;
return new Range(range, optionsOrLoose).range || "*";
} catch (er) {
return null;
}
}
function ltr(version10, range, optionsOrLoose) {
return outside(version10, range, "<", optionsOrLoose);
}
function gtr(version11, range, optionsOrLoose) {
return outside(version11, range, ">", optionsOrLoose);
}
function outside(version12, range, hilo, optionsOrLoose) {
version12 = new SemVer(version12, optionsOrLoose);
range = new Range(range, optionsOrLoose);
let gtfn;
let ltefn;
let ltfn;
let comp;
let ecomp;
switch(hilo){
case ">":
gtfn = gt;
ltefn = lte;
ltfn = lt;
comp = ">";
ecomp = ">=";
break;
case "<":
gtfn = lt;
ltefn = gte;
ltfn = gt;
comp = "<";
ecomp = "<=";
break;
default:
throw new TypeError('Must provide a hilo val of "<" or ">"');
}
if (satisfies(version12, range, optionsOrLoose)) {
return false;
}
for(let i36 = 0; i36 < range.set.length; ++i36){
const comparators = range.set[i36];
let high = null;
let low = null;
comparators.forEach((comparator)=>{
if (comparator.semver === ANY) {
comparator = new Comparator(">=0.0.0");
}
high = high || comparator;
low = low || comparator;
if (gtfn(comparator.semver, high.semver, optionsOrLoose)) {
high = comparator;
} else if (ltfn(comparator.semver, low.semver, optionsOrLoose)) {
low = comparator;
}
});
if (high === null || low === null) return true;
if (high.operator === comp || high.operator === ecomp) {
return false;
}
if ((!low.operator || low.operator === comp) && ltefn(version12, low.semver)) {
return false;
} else if (low.operator === ecomp && ltfn(version12, low.semver)) {
return false;
}
}
return true;
}
function prerelease(version13, optionsOrLoose) {
var parsed = parse4(version13, optionsOrLoose);
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
}
function intersects(range1, range2, optionsOrLoose) {
range1 = new Range(range1, optionsOrLoose);
range2 = new Range(range2, optionsOrLoose);
return range1.intersects(range2);
}
function coerce(version14, optionsOrLoose) {
if (version14 instanceof SemVer) {
return version14;
}
if (typeof version14 !== "string") {
return null;
}
const match = version14.match(re[COERCE]);
if (match == null) {
return null;
}
return parse4(match[1] + "." + (match[2] || "0") + "." + (match[3] || "0"), optionsOrLoose);
}
const mod7 = {
SEMVER_SPEC_VERSION: SEMVER_SPEC_VERSION,
parse: parse4,
valid: valid,
clean: clean,
SemVer: SemVer,
inc: inc,
diff: diff,
compareIdentifiers: compareIdentifiers,
rcompareIdentifiers: rcompareIdentifiers,
major: major,
minor: minor,
patch: patch,
compare: compare,
compareLoose: compareLoose,
compareBuild: compareBuild,
rcompare: rcompare,
sort: sort,
rsort: rsort,
gt: gt,
lt: lt,
eq: eq,
neq: neq,
gte: gte,
lte: lte,
cmp: cmp,
Comparator: Comparator,
Range: Range,
toComparators: toComparators,
satisfies: satisfies,
maxSatisfying: maxSatisfying,
minSatisfying: minSatisfying,
minVersion: minVersion,
validRange: validRange,
ltr: ltr,
gtr: gtr,
outside: outside,
prerelease: prerelease,
intersects: intersects,
coerce: coerce,
default: SemVer
};
const version = "1.11.0";
const TaskName_AST = {
"moduleName": "dnit.manifest",
"decl": {
"annotations": [],
"type_": {
"kind": "newtype_",
"value": {
"typeParams": [],
"default": {
"kind": "nothing"
},
"typeExpr": {
"typeRef": {
"kind": "primitive",
"value": "String"
},
"parameters": []
}
}
},
"name": "TaskName",
"version": {
"kind": "nothing"
}
}
};
const TrackedFileName_AST = {
"moduleName": "dnit.manifest",
"decl": {
"annotations": [],
"type_": {
"kind": "newtype_",
"value": {
"typeParams": [],
"default": {
"kind": "nothing"
},
"typeExpr": {
"typeRef": {
"kind": "primitive",
"value": "String"
},
"parameters": []
}
}
},
"name": "TrackedFileName",
"version": {
"kind": "nothing"
}
}
};
const TrackedFileHash_AST = {
"moduleName": "dnit.manifest",
"decl": {
"annotations": [],
"type_": {
"kind": "newtype_",
"value": {
"typeParams": [],
"default": {
"kind": "nothing"
},
"typeExpr": {
"typeRef": {
"kind": "primitive",
"value": "String"
},
"parameters": []
}
}
},
"name": "TrackedFileHash",
"version": {
"kind": "nothing"
}
}
};
const Timestamp_AST = {
"moduleName": "dnit.manifest",
"decl": {
"annotations": [],
"type_": {
"kind": "newtype_",
"value": {
"typeParams": [],
"default": {
"kind": "nothing"
},
"typeExpr": {
"typeRef": {
"kind": "primitive",
"value": "String"
},
"parameters": []
}
}
},
"name": "Timestamp",
"version": {
"kind": "nothing"
}
}
};
const TaskData_AST = {
"moduleName": "dnit.manifest",
"decl": {
"annotations": [],
"type_": {
"kind": "struct_",
"value": {
"typeParams": [],
"fields": [
{
"annotations": [],
"serializedName": "lastExecution",
"default": {
"kind": "just",
"value": null
},
"name": "lastExecution",
"typeExpr": {
"typeRef": {
"kind": "primitive",
"value": "Nullable"
},
"parameters": [
{
"typeRef": {
"kind": "reference",
"value": {
"moduleName": "dnit.manifest",
"name": "Timestamp"
}
},
"parameters": []
}
]
}
},
{
"annotations": [],
"serializedName": "trackedFiles",
"default": {
"kind": "nothing"
},
"name": "trackedFiles",
"typeExpr": {
"typeRef": {
"kind": "reference",
"value": {
"moduleName": "sys.types",
"name": "Map"
}
},
"parameters": [
{
"typeRef": {
"kind": "reference",
"value": {
"moduleName": "dnit.manifest",
"name": "TrackedFileName"
}
},
"parameters": []
},
{
"typeRef": {
"kind": "reference",
"value": {
"moduleName": "dnit.manifest",
"name": "TrackedFileData"
}
},
"parameters": []
}
]
}
}
]
}
},
"name": "TaskData",
"version": {
"kind": "nothing"
}
}
};
const TrackedFileData_AST = {
"moduleName": "dnit.manifest",
"decl": {
"annotations": [],
"type_": {
"kind": "struct_",
"value": {
"typeParams": [],
"fields": [
{
"annotations": [],
"serializedName": "hash",
"default": {
"kind": "nothing"
},
"name": "hash",
"typeExpr": {
"typeRef": {
"kind": "reference",
"value": {
"moduleName": "dnit.manifest",
"name": "TrackedFileHash"
}
},
"parameters": []
}
},
{
"annotations": [],
"serializedName": "timestamp",
"default": {
"kind": "nothing"
},
"name": "timestamp",
"typeExpr": {
"typeRef": {
"kind": "reference",
"value": {
"moduleName": "dnit.manifest",
"name": "Timestamp"
}
},
"parameters": []
}
}
]
}
},
"name": "TrackedFileData",
"version": {
"kind": "nothing"
}
}
};
const Manifest_AST = {
"moduleName": "dnit.manifest",
"decl": {
"annotations": [],
"type_": {
"kind": "struct_",
"value": {
"typeParams": [],
"fields": [
{
"annotations": [],
"serializedName": "tasks",
"default": {
"kind": "just",
"value": []
},
"name": "tasks",
"typeExpr": {
"typeRef": {
"kind": "reference",
"value": {
"moduleName": "sys.types",
"name": "Map"
}
},
"parameters": [
{
"typeRef": {
"kind": "reference",
"value": {
"moduleName": "dnit.manifest",
"name": "TaskName"
}
},
"parameters": []
},
{
"typeRef": {
"kind": "reference",
"value": {
"moduleName": "dnit.manifest",
"name": "TaskData"
}
},
"parameters": []
}
]
}
}
]
}
},
"name": "Manifest",
"version": {
"kind": "nothing"
}
}
};
const _AST_MAP = {
"dnit.manifest.TaskName": TaskName_AST,
"dnit.manifest.TrackedFileName": TrackedFileName_AST,
"dnit.manifest.TrackedFileHash": TrackedFileHash_AST,
"dnit.manifest.Timestamp": Timestamp_AST,
"dnit.manifest.TaskData": TaskData_AST,
"dnit.manifest.TrackedFileData": TrackedFileData_AST,
"dnit.manifest.Manifest": Manifest_AST
};
function isEnum(union) {
for (let field of union.fields){
if (!isVoid(field.typeExpr)) {
return false;
}
}
return true;
}
function isVoid(texpr) {
if (texpr.typeRef.kind === "primitive") {
return texpr.typeRef.value === "Void";
}
return false;
}
Symbol();
Symbol();
Symbol();
Symbol();
function asJsonObject(jv) {
if (jv instanceof Object && !(jv instanceof Array)) {
return jv;
}
return undefined;
}
function asJsonArray(jv) {
if (jv instanceof Array) {
return jv;
}
return undefined;
}
function jsonParseException(message) {
const context = [];
let createContextString = ()=>{
const rcontext = context.slice(0);
rcontext.push('$');
rcontext.reverse();
return rcontext.join('.');
};
return {
kind: 'JsonParseException',
getMessage () {
return message + ' at ' + createContextString();
},
pushField (fieldName) {
context.push(fieldName);
},
pushIndex (index) {
context.push('[' + index + ']');
},
toString () {
return this.getMessage();
}
};
}
function isJsonParseException(exception) {
return exception.kind === 'JsonParseException';
}
function buildJsonBinding(dresolver, texpr, boundTypeParams) {
if (texpr.typeRef.kind === "primitive") {
return primitiveJsonBinding(dresolver, texpr.typeRef.value, texpr.parameters, boundTypeParams);
} else if (texpr.typeRef.kind === "reference") {
const ast = dresolver(texpr.typeRef.value);
if (ast.decl.type_.kind === "struct_") {
return structJsonBinding(dresolver, ast.decl.type_.value, texpr.parameters, boundTypeParams);
} else if (ast.decl.type_.kind === "union_") {
const union = ast.decl.type_.value;
if (isEnum(union)) {
return enumJsonBinding(dresolver, union, texpr.parameters, boundTypeParams);
} else {
return unionJsonBinding(dresolver, union, texpr.parameters, boundTypeParams);
}
} else if (ast.decl.type_.kind === "newtype_") {
return newtypeJsonBinding(dresolver, ast.decl.type_.value, texpr.parameters, boundTypeParams);
} else if (ast.decl.type_.kind === "type_") {
return typedefJsonBinding(dresolver, ast.decl.type_.value, texpr.parameters, boundTypeParams);
}
} else if (texpr.typeRef.kind === "typeParam") {
return boundTypeParams[texpr.typeRef.value];
}
throw new Error("buildJsonBinding : unimplemented ADL type");
}
function primitiveJsonBinding(dresolver, ptype, params, boundTypeParams) {
if (ptype === "String") {
return identityJsonBinding("a string", (v)=>typeof v === 'string'
);
} else if (ptype === "Int8") {
return identityJsonBinding("a number", (v)=>typeof v === 'number'
);
} else if (ptype === "Void") {
return identityJsonBinding("a null", (v)=>v === null
);
} else if (ptype === "Bool") {
return identityJsonBinding("a bool", (v)=>typeof v === 'boolean'
);
} else if (ptype === "Int8") {
return identityJsonBinding("a number", (v)=>typeof v === 'number'
);
} else if (ptype === "Int16") {
return identityJsonBinding("a number", (v)=>typeof v === 'number'
);
} else if (ptype === "Int32") {
return identityJsonBinding("a number", (v)=>typeof v === 'number'
);
} else if (ptype === "Int64") {
return identityJsonBinding("a number", (v)=>typeof v === 'number'
);
} else if (ptype === "Word8") {
return identityJsonBinding("a number", (v)=>typeof v === 'number'
);
} else if (ptype === "Word16") {
return identityJsonBinding("a number", (v)=>typeof v === 'number'
);
} else if (ptype === "Word32") {
return identityJsonBinding("a number", (v)=>typeof v === 'number'
);
} else if (ptype === "Word64") {
return identityJsonBinding("a number", (v)=>typeof v === 'number'
);
} else if (ptype === "Float") {
return identityJsonBinding("a number", (v)=>typeof v === 'number'
);
} else if (ptype === "Double") {
return identityJsonBinding("a number", (v)=>typeof v === 'number'
);
} else if (ptype === "Json") {
return identityJsonBinding("a json value", (_v)=>true
);
} else if (ptype === "Bytes") {
return bytesJsonBinding();
} else if (ptype === "Vector") {
return vectorJsonBinding(dresolver, params[0], boundTypeParams);
} else if (ptype === "StringMap") {
return stringMapJsonBinding(dresolver, params[0], boundTypeParams);
} else if (ptype === "Nullable") {
return nullableJsonBinding(dresolver, params[0], boundTypeParams);
} else throw new Error("Unimplemented json binding for primitive " + ptype);
}
function identityJsonBinding(expected, predicate) {
function toJson(v) {
return v;
}
function fromJson(json) {
if (!predicate(json)) {
throw jsonParseException("expected " + expected);
}
return json;
}
return {
toJson,
fromJson
};
}
function bytesJsonBinding() {
function toJson(v) {
throw new Error("bytesJsonBinding not implemented");
}
function fromJson(json) {
if (typeof json != 'string') {
throw jsonParseException('expected a string');
}
throw new Error("bytesJsonBinding not implemented");
}
return {
toJson,
fromJson
};
}
function vectorJsonBinding(dresolver, texpr, boundTypeParams) {
const elementBinding = once(()=>buildJsonBinding(dresolver, texpr, boundTypeParams)
);
function toJson(v) {
return v.map(elementBinding().toJson);
}
function fromJson(json) {
const jarr = asJsonArray(json);
if (jarr == undefined) {
throw jsonParseException('expected an array');
}
let result = [];
jarr.forEach((eljson, i37)=>{
try {
result.push(elementBinding().fromJson(eljson));
} catch (e) {
if (isJsonParseException(e)) {
e.pushIndex(i37);
}
throw e;
}
});
return result;
}
return {
toJson,
fromJson
};
}
function stringMapJsonBinding(dresolver, texpr, boundTypeParams) {
const elementBinding = once(()=>buildJsonBinding(dresolver, texpr, boundTypeParams)
);
function toJson(v) {
const result = {};
for(let k in v){
result[k] = elementBinding().toJson(v[k]);
}
return result;
}
function fromJson(json) {
const jobj = asJsonObject(json);
if (!jobj) {
throw jsonParseException('expected an object');
}
let result = {};
for(let k in jobj){
try {
result[k] = elementBinding().fromJson(jobj[k]);
} catch (e) {
if (isJsonParseException(e)) {
e.pushField(k);
}
}
}
return result;
}
return {
toJson,
fromJson
};
}
function nullableJsonBinding(dresolver, texpr, boundTypeParams) {
const elementBinding = once(()=>buildJsonBinding(dresolver, texpr, boundTypeParams)
);
function toJson(v) {
if (v === null) {
return null;
}
return elementBinding().toJson(v);
}
function fromJson(json) {
if (json === null) {
return null;
}
return elementBinding().fromJson(json);
}
return {
toJson,
fromJson
};
}
function structJsonBinding(dresolver, struct, params, boundTypeParams) {
const newBoundTypeParams = createBoundTypeParams(dresolver, struct.typeParams, params, boundTypeParams);
const fieldDetails = [];
struct.fields.forEach((field)=>{
let buildDefault = once(()=>{
if (field.default.kind === "just") {
const json = field.default.value;
return {
'value': buildJsonBinding(dresolver, field.typeExpr, newBoundTypeParams).fromJson(json)
};
} else {
return null;
}
});
fieldDetails.push({
field: field,
jsonBinding: once(()=>buildJsonBinding(dresolver, field.typeExpr, newBoundTypeParams)
),
buildDefault: buildDefault
});
});
function toJson(v0) {
const v = v0;
const json = {};
fieldDetails.forEach((fd)=>{
json[fd.field.serializedName] = fd.jsonBinding().toJson(v && v[fd.field.name]);
});
return json;
}
function fromJson(json) {
const jobj = asJsonObject(json);
if (!jobj) {
throw jsonParseException("expected an object");
}
const v = {};
fieldDetails.forEach((fd)=>{
if (jobj[fd.field.serializedName] === undefined) {
const defaultv = fd.buildDefault();
if (defaultv === null) {
throw jsonParseException("missing struct field " + fd.field.serializedName);
} else {
v[fd.field.name] = defaultv.value;
}
} else {
try {
v[fd.field.name] = fd.jsonBinding().fromJson(jobj[fd.field.serializedName]);
} catch (e) {
if (isJsonParseException(e)) {
e.pushField(fd.field.serializedName);
}
throw e;
}
}
});
return v;
}
return {
toJson,
fromJson
};
}
function enumJsonBinding(_dresolver, union, _params, _boundTypeParams) {
const fieldSerializedNames = [];
const fieldNumbers = {};
union.fields.forEach((field, i38)=>{
fieldSerializedNames.push(field.serializedName);
fieldNumbers[field.serializedName] = i38;
});
function toJson(v) {
return fieldSerializedNames[v];
}
function fromJson(json) {
if (typeof json !== 'string') {
throw jsonParseException("expected a string for enum");
}
const result = fieldNumbers[json];
if (result === undefined) {
throw jsonParseException("invalid string for enum: " + json);
}
return result;
}
return {
toJson,
fromJson
};
}
function unionJsonBinding(dresolver, union, params, boundTypeParams) {
const newBoundTypeParams = createBoundTypeParams(dresolver, union.typeParams, params, boundTypeParams);
const detailsByName = {};
const detailsBySerializedName = {};
union.fields.forEach((field)=>{
const details = {
field: field,
isVoid: isVoid(field.typeExpr),
jsonBinding: once(()=>buildJsonBinding(dresolver, field.typeExpr, newBoundTypeParams)
)
};
detailsByName[field.name] = details;
detailsBySerializedName[field.serializedName] = details;
});
function toJson(v0) {
const v = v0;
const details = detailsByName[v.kind];
if (details.isVoid) {
return details.field.serializedName;
} else {
const result = {};
result[details.field.serializedName] = details.jsonBinding().toJson(v.value);
return result;
}
}
function lookupDetails(serializedName) {
let details = detailsBySerializedName[serializedName];
if (details === undefined) {
throw jsonParseException("invalid union field " + serializedName);
}
return details;
}
function fromJson(json) {
if (typeof json === "string") {
let details = lookupDetails(json);
if (!details.isVoid) {
throw jsonParseException("union field " + json + "needs an associated value");
}
return {
kind: details.field.name
};
}
const jobj = asJsonObject(json);
if (jobj) {
for(let k in jobj){
let details = lookupDetails(k);
try {
return {
kind: details.field.name,
value: details.jsonBinding().fromJson(jobj[k])
};
} catch (e) {
if (isJsonParseException(e)) {
e.pushField(k);
}
throw e;
}
}
throw jsonParseException("union without a property");
} else {
throw jsonParseException("expected an object or string");
}
}
return {
toJson,
fromJson
};
}
function newtypeJsonBinding(dresolver, newtype, params, boundTypeParams) {
const newBoundTypeParams = createBoundTypeParams(dresolver, newtype.typeParams, params, boundTypeParams);
return buildJsonBinding(dresolver, newtype.typeExpr, newBoundTypeParams);
}
function typedefJsonBinding(dresolver, typedef, params, boundTypeParams) {
const newBoundTypeParams = createBoundTypeParams(dresolver, typedef.typeParams, params, boundTypeParams);
return buildJsonBinding(dresolver, typedef.typeExpr, newBoundTypeParams);
}
function createBoundTypeParams(dresolver, paramNames, paramTypes, boundTypeParams) {
let result = {};
paramNames.forEach((paramName, i39)=>{
result[paramName] = buildJsonBinding(dresolver, paramTypes[i39], boundTypeParams);
});
return result;
}
function once(run1) {
let result = null;
return ()=>{
if (result === null) {
result = run1();
}
return result;
};
}
function declResolver(...astMaps) {
const astMap = {};
for (let map of astMaps){
for(let scopedName in map){
astMap[scopedName] = map[scopedName];
}
}
function resolver(scopedName) {
const scopedNameStr = scopedName.moduleName + "." + scopedName.name;
const result = astMap[scopedNameStr];
if (result === undefined) {
throw new Error("Unable to resolve ADL type " + scopedNameStr);
}
return result;
}
return resolver;
}
const Pair_AST = {
"moduleName": "sys.types",
"decl": {
"annotations": [],
"type_": {
"kind": "struct_",
"value": {
"typeParams": [
"T1",
"T2"
],
"fields": [
{
"annotations": [],
"serializedName": "v1",
"default": {
"kind": "nothing"
},
"name": "v1",
"typeExpr": {
"typeRef": {
"kind": "typeParam",
"value": "T1"
},
"parameters": []
}
},
{
"annotations": [],
"serializedName": "v2",
"default": {
"kind": "nothing"
},
"name": "v2",
"typeExpr": {
"typeRef": {
"kind": "typeParam",
"value": "T2"
},
"parameters": []
}
}
]
}
},
"name": "Pair",
"version": {
"kind": "nothing"
}
}
};
const Either_AST = {
"moduleName": "sys.types",
"decl": {
"annotations": [],
"type_": {
"kind": "union_",
"value": {
"typeParams": [
"T1",
"T2"
],
"fields": [
{
"annotations": [],
"serializedName": "left",
"default": {
"kind": "nothing"
},
"name": "left",
"typeExpr": {
"typeRef": {
"kind": "typeParam",
"value": "T1"
},
"parameters": []
}
},
{
"annotations": [],
"serializedName": "right",
"default": {
"kind": "nothing"
},
"name": "right",
"typeExpr": {
"typeRef": {
"kind": "typeParam",
"value": "T2"
},
"parameters": []
}
}
]
}
},
"name": "Either",
"version": {
"kind": "nothing"
}
}
};
const Maybe_AST = {
"moduleName": "sys.types",
"decl": {
"annotations": [],
"type_": {
"kind": "union_",
"value": {
"typeParams": [
"T"
],
"fields": [
{
"annotations": [],
"serializedName": "nothing",
"default": {
"kind": "nothing"
},
"name": "nothing",
"typeExpr": {
"typeRef": {
"kind": "primitive",
"value": "Void"
},
"parameters": []
}
},
{
"annotations": [],
"serializedName": "just",
"default": {
"kind": "nothing"
},
"name": "just",
"typeExpr": {
"typeRef": {
"kind": "typeParam",
"value": "T"
},
"parameters": []
}
}
]
}
},
"name": "Maybe",
"version": {
"kind": "nothing"
}
}
};
const Error_AST = {
"moduleName": "sys.types",
"decl": {
"annotations": [],
"type_": {
"kind": "union_",
"value": {
"typeParams": [
"T"
],
"fields": [
{
"annotations": [],
"serializedName": "value",
"default": {
"kind": "nothing"
},
"name": "value",
"typeExpr": {
"typeRef": {
"kind": "typeParam",
"value": "T"
},
"parameters": []
}
},
{
"annotations": [],
"serializedName": "error",
"default": {
"kind": "nothing"
},
"name": "error",
"typeExpr": {
"typeRef": {
"kind": "primitive",
"value": "String"
},
"parameters": []
}
}
]
}
},
"name": "Error",
"version": {
"kind": "nothing"
}
}
};
const MapEntry_AST = {
"moduleName": "sys.types",
"decl": {
"annotations": [],
"type_": {
"kind": "struct_",
"value": {
"typeParams": [
"K",
"V"
],
"fields": [
{
"annotations": [],
"serializedName": "k",
"default": {
"kind": "nothing"
},
"name": "key",
"typeExpr": {
"typeRef": {
"kind": "typeParam",
"value": "K"
},
"parameters": []
}
},
{
"annotations": [],
"serializedName": "v",
"default": {
"kind": "nothing"
},
"name": "value",
"typeExpr": {
"typeRef": {
"kind": "typeParam",
"value": "V"
},
"parameters": []
}
}
]
}
},
"name": "MapEntry",
"version": {
"kind": "nothing"
}
}
};
const Map_AST = {
"moduleName": "sys.types",
"decl": {
"annotations": [],
"type_": {
"kind": "newtype_",
"value": {
"typeParams": [
"K",
"V"
],
"default": {
"kind": "nothing"
},
"typeExpr": {
"typeRef": {
"kind": "primitive",
"value": "Vector"
},
"parameters": [
{
"typeRef": {
"kind": "reference",
"value": {
"moduleName": "sys.types",
"name": "Pair"
}
},
"parameters": [
{
"typeRef": {
"kind": "typeParam",
"value": "K"
},
"parameters": []
},
{
"typeRef": {
"kind": "typeParam",
"value": "V"
},
"parameters": []
}
]
}
]
}
}
},
"name": "Map",
"version": {
"kind": "nothing"
}
}
};
const Set_AST = {
"moduleName": "sys.types",
"decl": {
"annotations": [],
"type_": {
"kind": "newtype_",
"value": {
"typeParams": [
"T"
],
"default": {
"kind": "nothing"
},
"typeExpr": {
"typeRef": {
"kind": "primitive",
"value": "Vector"
},
"parameters": [
{
"typeRef": {
"kind": "typeParam",
"value": "T"
},
"parameters": []
}
]
}
}
},
"name": "Set",
"version": {
"kind": "nothing"
}
}
};
const _AST_MAP1 = {
"sys.types.Pair": Pair_AST,
"sys.types.Either": Either_AST,
"sys.types.Maybe": Maybe_AST,
"sys.types.Error": Error_AST,
"sys.types.MapEntry": MapEntry_AST,
"sys.types.Map": Map_AST,
"sys.types.Set": Set_AST
};
const ADL = {
..._AST_MAP,
..._AST_MAP1
};
declResolver(ADL);
class ADLMap {
constructor(data, isEqual){
this.data = data;
this.isEqual = isEqual;
}
has(k) {
return this.findIndex(k) !== -1;
}
get(k) {
const ind = this.findIndex(k);
if (ind === -1) {
return undefined;
}
return this.data[ind].v2;
}
getOrInsert(k, v) {
const existing = this.get(k);
if (existing === undefined) {
this.set(k, v);
return v;
}
return existing;
}
set(k, v) {
const ind = this.findIndex(k);
if (ind === -1) {
this.data.push({
v1: k,
v2: v
});
}
this.data[ind] = {
v1: k,
v2: v
};
return this;
}
keys() {
return this.data.map((p)=>p.v1
);
}
values() {
return this.data.map((p)=>p.v2
);
}
entries() {
return this.data.map((p)=>[
p.v1,
p.v2
]
);
}
toData() {
return this.data;
}
findIndex(k) {
return this.data.findIndex((p)=>this.isEqual(p.v1, k)
);
}
}
class TaskManifest {
constructor(data){
this.lastExecution = null;
this.trackedFiles = new ADLMap([], (k1, k2)=>k1 === k2
);
this.trackedFiles = new ADLMap(data.trackedFiles, (k1, k2)=>k1 === k2
);
this.lastExecution = data.lastExecution;
}
getFileData(fn) {
return this.trackedFiles.get(fn);
}
setFileData(fn, d) {
this.trackedFiles.set(fn, d);
}
setExecutionTimestamp() {
this.lastExecution = new Date().toISOString();
}
toData() {
return {
lastExecution: this.lastExecution,
trackedFiles: this.trackedFiles.toData()
};
}
}
function taskContext(ctx, task) {
return {
logger: ctx.taskLogger,
task,
args: ctx.args
};
}
function isTask(dep) {
return dep instanceof Task;
}
function isTrackedFile(dep) {
return dep instanceof TrackedFile;
}
function isTrackedFileAsync(dep) {
return dep instanceof TrackedFilesAsync;
}
async function statPath(path36) {
try {
const fileInfo = await Deno.stat(path36);
return {
kind: 'fileInfo',
fileInfo
};
} catch (err) {
if (err instanceof Deno.errors.NotFound) {
return {
kind: 'nonExistent'
};
}
throw err;
}
}
class Task {
constructor(taskParams){
this.taskManifest = null;
this.name = taskParams.name;
this.action = taskParams.action;
this.description = taskParams.description;
this.task_deps = new Set(this.getTaskDeps(taskParams.deps || []));
this.file_deps = new Set(this.getTrackedFiles(taskParams.deps || []));
this.async_files_deps = new Set(this.getTrackedFilesAsync(taskParams.deps || []));
this.targets = new Set(taskParams.targets || []);
this.uptodate = taskParams.uptodate;
for (const f of this.targets){
f.setTask(this);
}
}
getTaskDeps(deps) {
return deps.filter(isTask);
}
getTrackedFiles(deps) {
return deps.filter(isTrackedFile);
}
getTrackedFilesAsync(deps) {
return deps.filter(isTrackedFileAsync);
}
async setup(ctx) {
if (this.taskManifest === null) {
for (const t of this.targets){
ctx.targetRegister.set(t.path, this);
}
this.taskManifest = ctx.manifest.tasks.getOrInsert(this.name, new TaskManifest({
lastExecution: null,
trackedFiles: []
}));
for (const taskDep of this.task_deps){
await taskDep.setup(ctx);
}
for (const fDep of this.file_deps){
const fDepTask = fDep.getTask();
if (fDepTask !== null) {
await fDepTask.setup(ctx);
}
}
}
}
async exec(ctx) {
if (ctx.doneTasks.has(this)) {
return;
}
if (ctx.inprogressTasks.has(this)) {
return;
}
ctx.inprogressTasks.add(this);
for (const afd of this.async_files_deps){
const file_deps = await afd.getTrackedFiles();
for (const fd of file_deps){
this.file_deps.add(fd);
}
}
for (const fd of this.file_deps){
const t = ctx.targetRegister.get(fd.path);
if (t !== undefined) {
this.task_deps.add(t);
}
}
await this.execDependencies(ctx);
let actualUpToDate = true;
actualUpToDate = actualUpToDate && await this.checkFileDeps(ctx);
ctx.internalLogger.info(`${this.name} checkFileDeps ${actualUpToDate}`);
actualUpToDate = actualUpToDate && await this.targetsExist(ctx);
ctx.internalLogger.info(`${this.name} targetsExist ${actualUpToDate}`);
if (this.uptodate !== undefined) {
actualUpToDate = actualUpToDate && await this.uptodate(taskContext(ctx, this));
}
ctx.internalLogger.info(`${this.name} uptodate ${actualUpToDate}`);
if (actualUpToDate) {
ctx.taskLogger.info(`--- ${this.name}`);
} else {
ctx.taskLogger.info(`... ${this.name}`);
await this.action(taskContext(ctx, this));
ctx.taskLogger.info(`=== ${this.name}`);
{
this.taskManifest?.setExecutionTimestamp();
let promisesInProgress = [];
for (const fdep of this.file_deps){
promisesInProgress.push(ctx.asyncQueue.schedule(async ()=>{
const trackedFileData = await fdep.getFileData(ctx);
this.taskManifest?.setFileData(fdep.path, trackedFileData);
}));
}
await Promise.all(promisesInProgress);
}
}
ctx.doneTasks.add(this);
ctx.inprogressTasks.delete(this);
}
async targetsExist(ctx) {
const tex = await Promise.all(Array.from(this.targets).map(async (tf)=>ctx.asyncQueue.schedule(()=>tf.exists()
)
));
return !tex.some((t)=>!t
);
}
async checkFileDeps(ctx) {
let fileDepsUpToDate = true;
let promisesInProgress = [];
const taskManifest = this.taskManifest;
if (taskManifest === null) {
throw new Error(`Invalid null taskManifest on ${this.name}`);
}
for (const fdep of this.file_deps){
promisesInProgress.push(ctx.asyncQueue.schedule(async ()=>{
const r = await fdep.getFileDataOrCached(ctx, taskManifest.getFileData(fdep.path));
taskManifest.setFileData(fdep.path, r.tData);
fileDepsUpToDate = fileDepsUpToDate && r.upToDate;
}));
}
await Promise.all(promisesInProgress);
promisesInProgress = [];
return fileDepsUpToDate;
}
async execDependencies(ctx) {
for (const dep of this.task_deps){
if (!ctx.doneTasks.has(dep) && !ctx.inprogressTasks.has(dep)) {
await dep.exec(ctx);
}
}
}
}
class TrackedFile {
#getHash;
#getTimestamp;
constructor(fileParams){
this.path = "";
this.fromTask = null;
this.path = mod3.posix.resolve(fileParams.path);
this.#getHash = fileParams.getHash || getFileSha1Sum;
this.#getTimestamp = fileParams.getTimestamp || getFileTimestamp;
}
async stat() {
mod4.getLogger('internal').info(`checking file ${this.path}`);
return await statPath(this.path);
}
async exists(statInput) {
let statResult = statInput;
if (statResult === undefined) {
statResult = await this.stat();
}
return statResult.kind === 'fileInfo';
}
async getHash(statInput) {
let statResult = statInput;
if (statResult === undefined) {
statResult = await this.stat();
}
if (statResult.kind !== 'fileInfo') {
return "";
}
mod4.getLogger('internal').info(`checking hash on ${this.path}`);
return this.#getHash(this.path, statResult.fileInfo);
}
async getTimestamp(statInput) {
let statResult = statInput;
if (statResult === undefined) {
statResult = await this.stat();
}
if (statResult.kind !== 'fileInfo') {
return "";
}
return this.#getTimestamp(this.path, statResult.fileInfo);
}
async isUpToDate(ctx, tData, statInput) {
if (tData === undefined) {
return false;
}
let statResult = statInput;
if (statResult === undefined) {
statResult = await this.stat();
}
const mtime = await this.getTimestamp(statResult);
if (mtime === tData.timestamp) {
return true;
}
const hash = await this.getHash(statResult);
return hash === tData.hash;
}
async getFileData(ctx, statInput) {
let statResult = statInput;
if (statResult === undefined) {
statResult = await this.stat();
}
return {
hash: await this.getHash(statResult),
timestamp: await this.getTimestamp(statResult)
};
}
async getFileDataOrCached(ctx, tData, statInput) {
let statResult = statInput;
if (statResult === undefined) {
statResult = await this.stat();
}
if (tData !== undefined && await this.isUpToDate(ctx, tData, statResult)) {
return {
tData,
upToDate: true
};
}
return {
tData: await this.getFileData(ctx, statResult),
upToDate: false
};
}
setTask(t) {
if (this.fromTask === null) {
this.fromTask = t;
} else {
throw new Error("Duplicate tasks generating TrackedFile as target - " + this.path);
}
}
getTask() {
return this.fromTask;
}
}
class TrackedFilesAsync {
constructor(gen){
this.gen = gen;
this.kind = 'trackedfilesasync';
}
async getTrackedFiles() {
return this.gen();
}
}
async function getFileSha1Sum(filename) {
const data = await Deno.readFile(filename);
const hashsha1 = mod6.createHash("sha1");
hashsha1.update(data);
const hashInHex = hashsha1.toString();
return hashInHex;
}
async function getFileTimestamp(filename, stat) {
const mtime = stat.mtime;
return mtime?.toISOString() || "";
}
class StdErrPlainHandler extends mod4.handlers.BaseHandler {
constructor(levelName){
super(levelName, {
formatter: "{msg}"
});
}
log(msg) {
Deno.stderr.writeSync(new TextEncoder().encode(msg + "\n"));
}
}
class StdErrHandler extends mod4.handlers.ConsoleHandler {
log(msg) {
Deno.stderr.writeSync(new TextEncoder().encode(msg + "\n"));
}
}
async function setupLogging() {
await mod4.setup({
handlers: {
stderr: new StdErrHandler("DEBUG"),
stderrPlain: new StdErrPlainHandler("DEBUG")
},
loggers: {
internal: {
level: "WARNING",
handlers: [
"stderrPlain"
]
},
task: {
level: "INFO",
handlers: [
"stderrPlain"
]
},
user: {
level: "INFO",
handlers: [
"stderrPlain"
]
}
}
});
}
function findUserSourceContext(dir) {
dir.split(mod3.SEP);
return {
path: dir,
stat: Deno.lstatSync(dir)
};
}
function findUserSource(dir, startCtxArg) {
const startCtx = startCtxArg === null ? findUserSourceContext(dir) : startCtxArg;
const dirStat = Deno.lstatSync(dir);
if (dirStat.dev !== startCtx.stat.dev) {
return null;
}
if (mod3.resolve(mod3.join(dir, "..")) === dir) {
return null;
}
const subdirs = [
"dnit"
];
const defaultSources = [
"main.ts",
"dnit.ts",
];
const importmaps = [
"import_map.json",
".import_map.json"
];
for (const subdir of subdirs){
for (const sourceName of defaultSources){
const res = {
baseDir: mod3.resolve(dir),
dnitDir: mod3.resolve(mod3.join(dir, subdir)),
mainSrc: mod3.resolve(mod3.join(dir, subdir, sourceName))
};
if (mod5.existsSync(res.mainSrc)) {
for (const importMapFile of importmaps){
const importmap = mod3.resolve(mod3.join(dir, subdir, importMapFile));
if (mod5.existsSync(importmap)) {
return {
...res,
importmap
};
}
}
return {
...res,
importmap: null
};
}
}
}
return findUserSource(mod3.join(dir, ".."), startCtx);
}
async function parseDotDenoVersionFile(fname) {
const denoReqSemverRange = await Deno.readTextFile(fname);
return denoReqSemverRange;
}
async function getDenoVersion() {
const proc = Deno.run({
cmd: [
"deno",
"--version"
],
stdout: 'piped'
});
const [status, output] = await Promise.all([
proc.status(),
proc.output()
]);
const decoder = new TextDecoder();
const denoVersionStr = decoder.decode(output);
const regmatch = denoVersionStr.match(/deno[ ]+([0-9.]+)/);
if (regmatch) {
return regmatch[1];
}
throw new Error("Invalid parse of deno version output");
}
function checkValidDenoVersion(denoVersion, denoReqSemverRange) {
return mod7.satisfies(denoVersion, denoReqSemverRange);
}
async function launch(logger) {
const userSource = findUserSource(Deno.cwd(), null);
if (userSource !== null) {
logger.info("running source:" + userSource.mainSrc);
logger.info("running wd:" + userSource.baseDir);
logger.info("running importmap:" + userSource.importmap);
logger.info("running dnitDir:" + userSource.dnitDir);
const denoVersion = await getDenoVersion();
logger.info("deno version:" + denoVersion);
const dotDenoVersionFile = mod3.join(userSource.dnitDir, '.denoversion');
if (mod5.existsSync(dotDenoVersionFile)) {
const reqDenoVerStr = await parseDotDenoVersionFile(dotDenoVersionFile);
const validDenoVer = checkValidDenoVersion(denoVersion, reqDenoVerStr);
if (!validDenoVer) {
throw new Error("Requires deno version " + reqDenoVerStr);
}
logger.info("deno version ok:" + denoVersion + " for " + reqDenoVerStr);
}
Deno.chdir(userSource.baseDir);
const permissions = [
"--allow-read",
"--allow-write",
"--allow-run",
"--allow-env",
"--allow-net",
];
const flags = [
"--quiet",
"--unstable",
];
const importmap = userSource.importmap ? [
"--importmap",
userSource.importmap,
] : [];
const proc = Deno.run({
cmd: [
"deno",
"run"
].concat(flags).concat(permissions).concat(importmap).concat([
userSource.mainSrc
]).concat([
"--dnitDir",
userSource.dnitDir
]).concat(Deno.args)
});
const status = await proc.status();
return status;
} else {
logger.error("No dnit.ts or dnit directory found");
return {
success: false,
code: 1
};
}
}
async function main() {
const args = mod.parse(Deno.args);
if (args["version"] === true) {
console.log(`dnit ${version}`);
Deno.exit(0);
}
await setupLogging();
const internalLogger = mod4.getLogger("internal");
if (args["verbose"] !== undefined) {
internalLogger.levelName = "INFO";
}
internalLogger.info(`starting dnit launch using version: ${version}`);
launch(internalLogger).then((st)=>{
Deno.exit(st.code);
});
}
main();
export { main as main };