UNPKG

setup-cpp

Version:

Install all the tools required for building and testing C++/C projects.

1,264 lines (1,263 loc) 88.2 kB
import * as path from "path"; import path__default, { join } from "path"; import { fileURLToPath } from "url"; import { r as requireParse$1, a as requireSemver$1, b as requireCompare, c as requireRange, d as requireGt, e as requireComparator, f as requireSatisfies, g as requireLt, h as requireLte, i as requireGte, j as requireRe, k as requireConstants, l as requireIdentifiers, m as requireValid$1, n as requireMajor, o as requireEq, p as requireNeq, q as requireCmp, s as requireCoerce, t as commonjsGlobal, u as coreExports, v as execExports, w as toolCacheExports, H as HttpClient, info, x as ciInfo, y as pathExists, warning } from "../lib.mjs"; import require$$0$2 from "fs"; import require$$0$1 from "stream"; import * as require$$0 from "os"; import "crypto"; import "http"; import "https"; import "net"; import "tls"; import "events"; import "util"; import "string_decoder"; import "child_process"; import "assert"; import "timers"; import "node:buffer"; import "node:path"; import "node:child_process"; import "node:process"; import "node:url"; import "node:os"; import "node:fs"; import "buffer"; import "node:util"; import "fs/promises"; import "constants"; import "console"; import "process"; var clean_1, hasRequiredClean; function requireClean() { if (hasRequiredClean) return clean_1; hasRequiredClean = 1; const e = requireParse$1(); return clean_1 = (i, r) => { const s = e(i.trim().replace(/^[=v]+/, ""), r); return s ? s.version : null; }, clean_1; } var inc_1, hasRequiredInc; function requireInc() { if (hasRequiredInc) return inc_1; hasRequiredInc = 1; const e = requireSemver$1(); return inc_1 = (i, r, s, n, a) => { typeof s == "string" && (a = n, n = s, s = void 0); try { return new e( i instanceof e ? i.version : i, s ).inc(r, n, a).version; } catch { return null; } }, inc_1; } var diff_1, hasRequiredDiff; function requireDiff() { if (hasRequiredDiff) return diff_1; hasRequiredDiff = 1; const e = requireParse$1(); return diff_1 = (i, r) => { const s = e(i, null, !0), n = e(r, null, !0), a = s.compare(n); if (a === 0) return null; const h = a > 0, f = h ? s : n, u = h ? n : s, d = !!f.prerelease.length; if (!!u.prerelease.length && !d) { if (!u.patch && !u.minor) return "major"; if (u.compareMain(f) === 0) return u.minor && !u.patch ? "minor" : "patch"; } const p = d ? "pre" : ""; return s.major !== n.major ? p + "major" : s.minor !== n.minor ? p + "minor" : s.patch !== n.patch ? p + "patch" : "prerelease"; }, diff_1; } var minor_1, hasRequiredMinor; function requireMinor() { if (hasRequiredMinor) return minor_1; hasRequiredMinor = 1; const e = requireSemver$1(); return minor_1 = (i, r) => new e(i, r).minor, minor_1; } var patch_1, hasRequiredPatch; function requirePatch() { if (hasRequiredPatch) return patch_1; hasRequiredPatch = 1; const e = requireSemver$1(); return patch_1 = (i, r) => new e(i, r).patch, patch_1; } var prerelease_1, hasRequiredPrerelease; function requirePrerelease() { if (hasRequiredPrerelease) return prerelease_1; hasRequiredPrerelease = 1; const e = requireParse$1(); return prerelease_1 = (i, r) => { const s = e(i, r); return s && s.prerelease.length ? s.prerelease : null; }, prerelease_1; } var rcompare_1, hasRequiredRcompare; function requireRcompare() { if (hasRequiredRcompare) return rcompare_1; hasRequiredRcompare = 1; const e = requireCompare(); return rcompare_1 = (i, r, s) => e(r, i, s), rcompare_1; } var compareLoose_1, hasRequiredCompareLoose; function requireCompareLoose() { if (hasRequiredCompareLoose) return compareLoose_1; hasRequiredCompareLoose = 1; const e = requireCompare(); return compareLoose_1 = (i, r) => e(i, r, !0), compareLoose_1; } var compareBuild_1, hasRequiredCompareBuild; function requireCompareBuild() { if (hasRequiredCompareBuild) return compareBuild_1; hasRequiredCompareBuild = 1; const e = requireSemver$1(); return compareBuild_1 = (i, r, s) => { const n = new e(i, s), a = new e(r, s); return n.compare(a) || n.compareBuild(a); }, compareBuild_1; } var sort_1, hasRequiredSort; function requireSort() { if (hasRequiredSort) return sort_1; hasRequiredSort = 1; const e = requireCompareBuild(); return sort_1 = (i, r) => i.sort((s, n) => e(s, n, r)), sort_1; } var rsort_1, hasRequiredRsort; function requireRsort() { if (hasRequiredRsort) return rsort_1; hasRequiredRsort = 1; const e = requireCompareBuild(); return rsort_1 = (i, r) => i.sort((s, n) => e(n, s, r)), rsort_1; } var toComparators_1, hasRequiredToComparators; function requireToComparators() { if (hasRequiredToComparators) return toComparators_1; hasRequiredToComparators = 1; const e = requireRange(); return toComparators_1 = (i, r) => new e(i, r).set.map((s) => s.map((n) => n.value).join(" ").trim().split(" ")), toComparators_1; } var maxSatisfying_1, hasRequiredMaxSatisfying; function requireMaxSatisfying() { if (hasRequiredMaxSatisfying) return maxSatisfying_1; hasRequiredMaxSatisfying = 1; const e = requireSemver$1(), t = requireRange(); return maxSatisfying_1 = (r, s, n) => { let a = null, h = null, f = null; try { f = new t(s, n); } catch { return null; } return r.forEach((u) => { f.test(u) && (!a || h.compare(u) === -1) && (a = u, h = new e(a, n)); }), a; }, maxSatisfying_1; } var minSatisfying_1, hasRequiredMinSatisfying; function requireMinSatisfying() { if (hasRequiredMinSatisfying) return minSatisfying_1; hasRequiredMinSatisfying = 1; const e = requireSemver$1(), t = requireRange(); return minSatisfying_1 = (r, s, n) => { let a = null, h = null, f = null; try { f = new t(s, n); } catch { return null; } return r.forEach((u) => { f.test(u) && (!a || h.compare(u) === 1) && (a = u, h = new e(a, n)); }), a; }, minSatisfying_1; } var minVersion_1, hasRequiredMinVersion; function requireMinVersion() { if (hasRequiredMinVersion) return minVersion_1; hasRequiredMinVersion = 1; const e = requireSemver$1(), t = requireRange(), i = requireGt(); return minVersion_1 = (s, n) => { s = new t(s, n); let a = new e("0.0.0"); if (s.test(a) || (a = new e("0.0.0-0"), s.test(a))) return a; a = null; for (let h = 0; h < s.set.length; ++h) { const f = s.set[h]; let u = null; f.forEach((d) => { const l = new e(d.semver.version); switch (d.operator) { case ">": l.prerelease.length === 0 ? l.patch++ : l.prerelease.push(0), l.raw = l.format(); /* fallthrough */ case "": case ">=": (!u || i(l, u)) && (u = l); break; case "<": case "<=": break; /* istanbul ignore next */ default: throw new Error(`Unexpected operation: ${d.operator}`); } }), u && (!a || i(a, u)) && (a = u); } return a && s.test(a) ? a : null; }, minVersion_1; } var valid, hasRequiredValid; function requireValid() { if (hasRequiredValid) return valid; hasRequiredValid = 1; const e = requireRange(); return valid = (i, r) => { try { return new e(i, r).range || "*"; } catch { return null; } }, valid; } var outside_1, hasRequiredOutside; function requireOutside() { if (hasRequiredOutside) return outside_1; hasRequiredOutside = 1; const e = requireSemver$1(), t = requireComparator(), { ANY: i } = t, r = requireRange(), s = requireSatisfies(), n = requireGt(), a = requireLt(), h = requireLte(), f = requireGte(); return outside_1 = (d, l, p, c) => { d = new e(d, c), l = new r(l, c); let g, _, C, w, I; switch (p) { case ">": g = n, _ = h, C = a, w = ">", I = ">="; break; case "<": g = a, _ = f, C = n, w = "<", I = "<="; break; default: throw new TypeError('Must provide a hilo val of "<" or ">"'); } if (s(d, l, c)) return !1; for (let N = 0; N < l.set.length; ++N) { const H = l.set[N]; let S = null, x = null; if (H.forEach((E) => { E.semver === i && (E = new t(">=0.0.0")), S = S || E, x = x || E, g(E.semver, S.semver, c) ? S = E : C(E.semver, x.semver, c) && (x = E); }), S.operator === w || S.operator === I || (!x.operator || x.operator === w) && _(d, x.semver)) return !1; if (x.operator === I && C(d, x.semver)) return !1; } return !0; }, outside_1; } var gtr_1, hasRequiredGtr; function requireGtr() { if (hasRequiredGtr) return gtr_1; hasRequiredGtr = 1; const e = requireOutside(); return gtr_1 = (i, r, s) => e(i, r, ">", s), gtr_1; } var ltr_1, hasRequiredLtr; function requireLtr() { if (hasRequiredLtr) return ltr_1; hasRequiredLtr = 1; const e = requireOutside(); return ltr_1 = (i, r, s) => e(i, r, "<", s), ltr_1; } var intersects_1, hasRequiredIntersects; function requireIntersects() { if (hasRequiredIntersects) return intersects_1; hasRequiredIntersects = 1; const e = requireRange(); return intersects_1 = (i, r, s) => (i = new e(i, s), r = new e(r, s), i.intersects(r, s)), intersects_1; } var simplify, hasRequiredSimplify; function requireSimplify() { if (hasRequiredSimplify) return simplify; hasRequiredSimplify = 1; const e = requireSatisfies(), t = requireCompare(); return simplify = (i, r, s) => { const n = []; let a = null, h = null; const f = i.sort((p, c) => t(p, c, s)); for (const p of f) e(p, r, s) ? (h = p, a || (a = p)) : (h && n.push([a, h]), h = null, a = null); a && n.push([a, null]); const u = []; for (const [p, c] of n) p === c ? u.push(p) : !c && p === f[0] ? u.push("*") : c ? p === f[0] ? u.push(`<=${c}`) : u.push(`${p} - ${c}`) : u.push(`>=${p}`); const d = u.join(" || "), l = typeof r.raw == "string" ? r.raw : String(r); return d.length < l.length ? d : r; }, simplify; } var subset_1, hasRequiredSubset; function requireSubset() { if (hasRequiredSubset) return subset_1; hasRequiredSubset = 1; const e = requireRange(), t = requireComparator(), { ANY: i } = t, r = requireSatisfies(), s = requireCompare(), n = (l, p, c = {}) => { if (l === p) return !0; l = new e(l, c), p = new e(p, c); let g = !1; e: for (const _ of l.set) { for (const C of p.set) { const w = f(_, C, c); if (g = g || w !== null, w) continue e; } if (g) return !1; } return !0; }, a = [new t(">=0.0.0-0")], h = [new t(">=0.0.0")], f = (l, p, c) => { if (l === p) return !0; if (l.length === 1 && l[0].semver === i) { if (p.length === 1 && p[0].semver === i) return !0; c.includePrerelease ? l = a : l = h; } if (p.length === 1 && p[0].semver === i) { if (c.includePrerelease) return !0; p = h; } const g = /* @__PURE__ */ new Set(); let _, C; for (const y of l) y.operator === ">" || y.operator === ">=" ? _ = u(_, y, c) : y.operator === "<" || y.operator === "<=" ? C = d(C, y, c) : g.add(y.semver); if (g.size > 1) return null; let w; if (_ && C) { if (w = s(_.semver, C.semver, c), w > 0) return null; if (w === 0 && (_.operator !== ">=" || C.operator !== "<=")) return null; } for (const y of g) { if (_ && !r(y, String(_), c) || C && !r(y, String(C), c)) return null; for (const o of p) if (!r(y, String(o), c)) return !1; return !0; } let I, N, H, S, x = C && !c.includePrerelease && C.semver.prerelease.length ? C.semver : !1, E = _ && !c.includePrerelease && _.semver.prerelease.length ? _.semver : !1; x && x.prerelease.length === 1 && C.operator === "<" && x.prerelease[0] === 0 && (x = !1); for (const y of p) { if (S = S || y.operator === ">" || y.operator === ">=", H = H || y.operator === "<" || y.operator === "<=", _) { if (E && y.semver.prerelease && y.semver.prerelease.length && y.semver.major === E.major && y.semver.minor === E.minor && y.semver.patch === E.patch && (E = !1), y.operator === ">" || y.operator === ">=") { if (I = u(_, y, c), I === y && I !== _) return !1; } else if (_.operator === ">=" && !r(_.semver, String(y), c)) return !1; } if (C) { if (x && y.semver.prerelease && y.semver.prerelease.length && y.semver.major === x.major && y.semver.minor === x.minor && y.semver.patch === x.patch && (x = !1), y.operator === "<" || y.operator === "<=") { if (N = d(C, y, c), N === y && N !== C) return !1; } else if (C.operator === "<=" && !r(C.semver, String(y), c)) return !1; } if (!y.operator && (C || _) && w !== 0) return !1; } return !(_ && H && !C && w !== 0 || C && S && !_ && w !== 0 || E || x); }, u = (l, p, c) => { if (!l) return p; const g = s(l.semver, p.semver, c); return g > 0 ? l : g < 0 || p.operator === ">" && l.operator === ">=" ? p : l; }, d = (l, p, c) => { if (!l) return p; const g = s(l.semver, p.semver, c); return g < 0 ? l : g > 0 || p.operator === "<" && l.operator === "<=" ? p : l; }; return subset_1 = n, subset_1; } var semver, hasRequiredSemver; function requireSemver() { if (hasRequiredSemver) return semver; hasRequiredSemver = 1; const e = requireRe(), t = requireConstants(), i = requireSemver$1(), r = requireIdentifiers(), s = requireParse$1(), n = requireValid$1(), a = requireClean(), h = requireInc(), f = requireDiff(), u = requireMajor(), d = requireMinor(), l = requirePatch(), p = requirePrerelease(), c = requireCompare(), g = requireRcompare(), _ = requireCompareLoose(), C = requireCompareBuild(), w = requireSort(), I = requireRsort(), N = requireGt(), H = requireLt(), S = requireEq(), x = requireNeq(), E = requireGte(), y = requireLte(), o = requireCmp(), m = requireCoerce(), R = requireComparator(), T = requireRange(), A = requireSatisfies(), P = requireToComparators(), b = requireMaxSatisfying(), q = requireMinSatisfying(), O = requireMinVersion(), L = requireValid(), v = requireOutside(), D = requireGtr(), M = requireLtr(), $ = requireIntersects(), F = requireSimplify(), U = requireSubset(); return semver = { parse: s, valid: n, clean: a, inc: h, diff: f, major: u, minor: d, patch: l, prerelease: p, compare: c, rcompare: g, compareLoose: _, compareBuild: C, sort: w, rsort: I, gt: N, lt: H, eq: S, neq: x, gte: E, lte: y, cmp: o, coerce: m, Comparator: R, Range: T, satisfies: A, toComparators: P, maxSatisfying: b, minSatisfying: q, minVersion: O, validRange: L, outside: v, gtr: D, ltr: M, intersects: $, simplifyRange: F, subset: U, SemVer: i, re: e.re, src: e.src, tokens: e.t, SEMVER_SPEC_VERSION: t.SEMVER_SPEC_VERSION, RELEASE_TYPES: t.RELEASE_TYPES, compareIdentifiers: r.compareIdentifiers, rcompareIdentifiers: r.rcompareIdentifiers }, semver; } var semverExports = requireSemver(), toml = {}, parse = { exports: {} }, tomlParser = { exports: {} }, parser, hasRequiredParser; function requireParser() { if (hasRequiredParser) return parser; hasRequiredParser = 1; const e = 1114112; class t extends Error { /* istanbul ignore next */ constructor(n, a, h) { super("[ParserError] " + n, a, h), this.name = "ParserError", this.code = "ParserError", Error.captureStackTrace && Error.captureStackTrace(this, t); } } class i { constructor(n) { this.parser = n, this.buf = "", this.returned = null, this.result = null, this.resultTable = null, this.resultArr = null; } } class r { constructor() { this.pos = 0, this.col = 0, this.line = 0, this.obj = {}, this.ctx = this.obj, this.stack = [], this._buf = "", this.char = null, this.ii = 0, this.state = new i(this.parseStart); } parse(n) { if (n.length === 0 || n.length == null) return; this._buf = String(n), this.ii = -1, this.char = -1; let a; for (; a === !1 || this.nextChar(); ) a = this.runOne(); this._buf = null; } nextChar() { return this.char === 10 && (++this.line, this.col = -1), ++this.ii, this.char = this._buf.codePointAt(this.ii), ++this.pos, ++this.col, this.haveBuffer(); } haveBuffer() { return this.ii < this._buf.length; } runOne() { return this.state.parser.call(this, this.state.returned); } finish() { this.char = e; let n; do n = this.state.parser, this.runOne(); while (this.state.parser !== n); return this.ctx = null, this.state = null, this._buf = null, this.obj; } next(n) { if (typeof n != "function") throw new t("Tried to set state to non-existent state: " + JSON.stringify(n)); this.state.parser = n; } goto(n) { return this.next(n), this.runOne(); } call(n, a) { a && this.next(a), this.stack.push(this.state), this.state = new i(n); } callNow(n, a) { return this.call(n, a), this.runOne(); } return(n) { if (this.stack.length === 0) throw this.error(new t("Stack underflow")); n === void 0 && (n = this.state.buf), this.state = this.stack.pop(), this.state.returned = n; } returnNow(n) { return this.return(n), this.runOne(); } consume() { if (this.char === e) throw this.error(new t("Unexpected end-of-buffer")); this.state.buf += this._buf[this.ii]; } error(n) { return n.line = this.line, n.col = this.col, n.pos = this.pos, n; } /* istanbul ignore next */ parseStart() { throw new t("Must declare a parseStart method"); } } return r.END = e, r.Error = t, parser = r, parser; } var createDatetime, hasRequiredCreateDatetime; function requireCreateDatetime() { return hasRequiredCreateDatetime || (hasRequiredCreateDatetime = 1, createDatetime = (e) => { const t = new Date(e); if (isNaN(t)) throw new TypeError("Invalid Datetime"); return t; }), createDatetime; } var formatNum, hasRequiredFormatNum; function requireFormatNum() { return hasRequiredFormatNum || (hasRequiredFormatNum = 1, formatNum = (e, t) => { for (t = String(t); t.length < e; ) t = "0" + t; return t; }), formatNum; } var createDatetimeFloat, hasRequiredCreateDatetimeFloat; function requireCreateDatetimeFloat() { if (hasRequiredCreateDatetimeFloat) return createDatetimeFloat; hasRequiredCreateDatetimeFloat = 1; const e = requireFormatNum(); class t extends Date { constructor(r) { super(r + "Z"), this.isFloating = !0; } toISOString() { const r = `${this.getUTCFullYear()}-${e(2, this.getUTCMonth() + 1)}-${e(2, this.getUTCDate())}`, s = `${e(2, this.getUTCHours())}:${e(2, this.getUTCMinutes())}:${e(2, this.getUTCSeconds())}.${e(3, this.getUTCMilliseconds())}`; return `${r}T${s}`; } } return createDatetimeFloat = (i) => { const r = new t(i); if (isNaN(r)) throw new TypeError("Invalid Datetime"); return r; }, createDatetimeFloat; } var createDate, hasRequiredCreateDate; function requireCreateDate() { if (hasRequiredCreateDate) return createDate; hasRequiredCreateDate = 1; const e = requireFormatNum(), t = commonjsGlobal.Date; class i extends t { constructor(s) { super(s), this.isDate = !0; } toISOString() { return `${this.getUTCFullYear()}-${e(2, this.getUTCMonth() + 1)}-${e(2, this.getUTCDate())}`; } } return createDate = (r) => { const s = new i(r); if (isNaN(s)) throw new TypeError("Invalid Datetime"); return s; }, createDate; } var createTime, hasRequiredCreateTime; function requireCreateTime() { if (hasRequiredCreateTime) return createTime; hasRequiredCreateTime = 1; const e = requireFormatNum(); class t extends Date { constructor(r) { super(`0000-01-01T${r}Z`), this.isTime = !0; } toISOString() { return `${e(2, this.getUTCHours())}:${e(2, this.getUTCMinutes())}:${e(2, this.getUTCSeconds())}.${e(3, this.getUTCMilliseconds())}`; } } return createTime = (i) => { const r = new t(i); if (isNaN(r)) throw new TypeError("Invalid Datetime"); return r; }, createTime; } var hasRequiredTomlParser; function requireTomlParser() { if (hasRequiredTomlParser) return tomlParser.exports; hasRequiredTomlParser = 1, tomlParser.exports = makeParserClass(requireParser()), tomlParser.exports.makeParserClass = makeParserClass; class TomlError extends Error { constructor(t) { super(t), this.name = "TomlError", Error.captureStackTrace && Error.captureStackTrace(this, TomlError), this.fromTOML = !0, this.wrapped = null; } } TomlError.wrap = (e) => { const t = new TomlError(e.message); return t.code = e.code, t.wrapped = e, t; }, tomlParser.exports.TomlError = TomlError; const createDateTime = requireCreateDatetime(), createDateTimeFloat = requireCreateDatetimeFloat(), createDate = requireCreateDate(), createTime = requireCreateTime(), CTRL_I = 9, CTRL_J = 10, CTRL_M = 13, CTRL_CHAR_BOUNDARY = 31, CHAR_SP = 32, CHAR_QUOT = 34, CHAR_NUM = 35, CHAR_APOS = 39, CHAR_PLUS = 43, CHAR_COMMA = 44, CHAR_HYPHEN = 45, CHAR_PERIOD = 46, CHAR_0 = 48, CHAR_1 = 49, CHAR_7 = 55, CHAR_9 = 57, CHAR_COLON = 58, CHAR_EQUALS = 61, CHAR_A = 65, CHAR_E = 69, CHAR_F = 70, CHAR_T = 84, CHAR_U = 85, CHAR_Z = 90, CHAR_LOWBAR = 95, CHAR_a = 97, CHAR_b = 98, CHAR_e = 101, CHAR_f = 102, CHAR_i = 105, CHAR_l = 108, CHAR_n = 110, CHAR_o = 111, CHAR_r = 114, CHAR_s = 115, CHAR_t = 116, CHAR_u = 117, CHAR_x = 120, CHAR_z = 122, CHAR_LCUB = 123, CHAR_RCUB = 125, CHAR_LSQB = 91, CHAR_BSOL = 92, CHAR_RSQB = 93, CHAR_DEL = 127, SURROGATE_FIRST = 55296, SURROGATE_LAST = 57343, escapes = { [CHAR_b]: "\b", [CHAR_t]: " ", [CHAR_n]: ` `, [CHAR_f]: "\f", [CHAR_r]: "\r", [CHAR_QUOT]: '"', [CHAR_BSOL]: "\\" }; function isDigit(e) { return e >= CHAR_0 && e <= CHAR_9; } function isHexit(e) { return e >= CHAR_A && e <= CHAR_F || e >= CHAR_a && e <= CHAR_f || e >= CHAR_0 && e <= CHAR_9; } function isBit(e) { return e === CHAR_1 || e === CHAR_0; } function isOctit(e) { return e >= CHAR_0 && e <= CHAR_7; } function isAlphaNumQuoteHyphen(e) { return e >= CHAR_A && e <= CHAR_Z || e >= CHAR_a && e <= CHAR_z || e >= CHAR_0 && e <= CHAR_9 || e === CHAR_APOS || e === CHAR_QUOT || e === CHAR_LOWBAR || e === CHAR_HYPHEN; } function isAlphaNumHyphen(e) { return e >= CHAR_A && e <= CHAR_Z || e >= CHAR_a && e <= CHAR_z || e >= CHAR_0 && e <= CHAR_9 || e === CHAR_LOWBAR || e === CHAR_HYPHEN; } const _type = Symbol("type"), _declared = Symbol("declared"), hasOwnProperty = Object.prototype.hasOwnProperty, defineProperty = Object.defineProperty, descriptor = { configurable: !0, enumerable: !0, writable: !0, value: void 0 }; function hasKey(e, t) { return hasOwnProperty.call(e, t) ? !0 : (t === "__proto__" && defineProperty(e, "__proto__", descriptor), !1); } const INLINE_TABLE = Symbol("inline-table"); function InlineTable() { return Object.defineProperties({}, { [_type]: { value: INLINE_TABLE } }); } function isInlineTable(e) { return e === null || typeof e != "object" ? !1 : e[_type] === INLINE_TABLE; } const TABLE = Symbol("table"); function Table() { return Object.defineProperties({}, { [_type]: { value: TABLE }, [_declared]: { value: !1, writable: !0 } }); } function isTable(e) { return e === null || typeof e != "object" ? !1 : e[_type] === TABLE; } const _contentType = Symbol("content-type"), INLINE_LIST = Symbol("inline-list"); function InlineList(e) { return Object.defineProperties([], { [_type]: { value: INLINE_LIST }, [_contentType]: { value: e } }); } function isInlineList(e) { return e === null || typeof e != "object" ? !1 : e[_type] === INLINE_LIST; } const LIST = Symbol("list"); function List() { return Object.defineProperties([], { [_type]: { value: LIST } }); } function isList(e) { return e === null || typeof e != "object" ? !1 : e[_type] === LIST; } let _custom; try { const utilInspect = eval("require('util').inspect"); _custom = utilInspect.custom; } catch (e) { } const _inspect = _custom || "inspect"; class BoxedBigInt { constructor(t) { try { this.value = commonjsGlobal.BigInt.asIntN(64, t); } catch { this.value = null; } Object.defineProperty(this, _type, { value: INTEGER }); } isNaN() { return this.value === null; } /* istanbul ignore next */ toString() { return String(this.value); } /* istanbul ignore next */ [_inspect]() { return `[BigInt: ${this.toString()}]}`; } valueOf() { return this.value; } } const INTEGER = Symbol("integer"); function Integer(e) { let t = Number(e); return Object.is(t, -0) && (t = 0), commonjsGlobal.BigInt && !Number.isSafeInteger(t) ? new BoxedBigInt(e) : Object.defineProperties(new Number(t), { isNaN: { value: function() { return isNaN(this); } }, [_type]: { value: INTEGER }, [_inspect]: { value: () => `[Integer: ${e}]` } }); } function isInteger(e) { return e === null || typeof e != "object" ? !1 : e[_type] === INTEGER; } const FLOAT = Symbol("float"); function Float(e) { return Object.defineProperties(new Number(e), { [_type]: { value: FLOAT }, [_inspect]: { value: () => `[Float: ${e}]` } }); } function isFloat(e) { return e === null || typeof e != "object" ? !1 : e[_type] === FLOAT; } function tomlType(e) { const t = typeof e; if (t === "object") { if (e === null) return "null"; if (e instanceof Date) return "datetime"; if (_type in e) switch (e[_type]) { case INLINE_TABLE: return "inline-table"; case INLINE_LIST: return "inline-list"; /* istanbul ignore next */ case TABLE: return "table"; /* istanbul ignore next */ case LIST: return "list"; case FLOAT: return "float"; case INTEGER: return "integer"; } } return t; } function makeParserClass(e) { class t extends e { constructor() { super(), this.ctx = this.obj = Table(); } /* MATCH HELPER */ atEndOfWord() { return this.char === CHAR_NUM || this.char === CTRL_I || this.char === CHAR_SP || this.atEndOfLine(); } atEndOfLine() { return this.char === e.END || this.char === CTRL_J || this.char === CTRL_M; } parseStart() { if (this.char === e.END) return null; if (this.char === CHAR_LSQB) return this.call(this.parseTableOrList); if (this.char === CHAR_NUM) return this.call(this.parseComment); if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) return null; if (isAlphaNumQuoteHyphen(this.char)) return this.callNow(this.parseAssignStatement); throw this.error(new TomlError(`Unknown character "${this.char}"`)); } // HELPER, this strips any whitespace and comments to the end of the line // then RETURNS. Last state in a production. parseWhitespaceToEOL() { if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) return null; if (this.char === CHAR_NUM) return this.goto(this.parseComment); if (this.char === e.END || this.char === CTRL_J) return this.return(); throw this.error(new TomlError("Unexpected character, expected only whitespace or comments till end of line")); } /* ASSIGNMENT: key = value */ parseAssignStatement() { return this.callNow(this.parseAssign, this.recordAssignStatement); } recordAssignStatement(r) { let s = this.ctx, n = r.key.pop(); for (let a of r.key) { if (hasKey(s, a) && !isTable(s[a])) throw this.error(new TomlError("Can't redefine existing key")); s = s[a] = s[a] || Table(); } if (hasKey(s, n)) throw this.error(new TomlError("Can't redefine existing key")); return s[_declared] = !0, isInteger(r.value) || isFloat(r.value) ? s[n] = r.value.valueOf() : s[n] = r.value, this.goto(this.parseWhitespaceToEOL); } /* ASSSIGNMENT expression, key = value possibly inside an inline table */ parseAssign() { return this.callNow(this.parseKeyword, this.recordAssignKeyword); } recordAssignKeyword(r) { return this.state.resultTable ? this.state.resultTable.push(r) : this.state.resultTable = [r], this.goto(this.parseAssignKeywordPreDot); } parseAssignKeywordPreDot() { if (this.char === CHAR_PERIOD) return this.next(this.parseAssignKeywordPostDot); if (this.char !== CHAR_SP && this.char !== CTRL_I) return this.goto(this.parseAssignEqual); } parseAssignKeywordPostDot() { if (this.char !== CHAR_SP && this.char !== CTRL_I) return this.callNow(this.parseKeyword, this.recordAssignKeyword); } parseAssignEqual() { if (this.char === CHAR_EQUALS) return this.next(this.parseAssignPreValue); throw this.error(new TomlError('Invalid character, expected "="')); } parseAssignPreValue() { return this.char === CHAR_SP || this.char === CTRL_I ? null : this.callNow(this.parseValue, this.recordAssignValue); } recordAssignValue(r) { return this.returnNow({ key: this.state.resultTable, value: r }); } /* COMMENTS: #...eol */ parseComment() { do { if (this.char === e.END || this.char === CTRL_J) return this.return(); if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) throw this.errorControlCharIn("comments"); } while (this.nextChar()); } /* TABLES AND LISTS, [foo] and [[foo]] */ parseTableOrList() { if (this.char === CHAR_LSQB) this.next(this.parseList); else return this.goto(this.parseTable); } /* TABLE [foo.bar.baz] */ parseTable() { return this.ctx = this.obj, this.goto(this.parseTableNext); } parseTableNext() { return this.char === CHAR_SP || this.char === CTRL_I ? null : this.callNow(this.parseKeyword, this.parseTableMore); } parseTableMore(r) { if (this.char === CHAR_SP || this.char === CTRL_I) return null; if (this.char === CHAR_RSQB) { if (hasKey(this.ctx, r) && (!isTable(this.ctx[r]) || this.ctx[r][_declared])) throw this.error(new TomlError("Can't redefine existing key")); return this.ctx = this.ctx[r] = this.ctx[r] || Table(), this.ctx[_declared] = !0, this.next(this.parseWhitespaceToEOL); } else if (this.char === CHAR_PERIOD) { if (!hasKey(this.ctx, r)) this.ctx = this.ctx[r] = Table(); else if (isTable(this.ctx[r])) this.ctx = this.ctx[r]; else if (isList(this.ctx[r])) this.ctx = this.ctx[r][this.ctx[r].length - 1]; else throw this.error(new TomlError("Can't redefine existing key")); return this.next(this.parseTableNext); } else throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]")); } /* LIST [[a.b.c]] */ parseList() { return this.ctx = this.obj, this.goto(this.parseListNext); } parseListNext() { return this.char === CHAR_SP || this.char === CTRL_I ? null : this.callNow(this.parseKeyword, this.parseListMore); } parseListMore(r) { if (this.char === CHAR_SP || this.char === CTRL_I) return null; if (this.char === CHAR_RSQB) { if (hasKey(this.ctx, r) || (this.ctx[r] = List()), isInlineList(this.ctx[r])) throw this.error(new TomlError("Can't extend an inline array")); if (isList(this.ctx[r])) { const s = Table(); this.ctx[r].push(s), this.ctx = s; } else throw this.error(new TomlError("Can't redefine an existing key")); return this.next(this.parseListEnd); } else if (this.char === CHAR_PERIOD) { if (!hasKey(this.ctx, r)) this.ctx = this.ctx[r] = Table(); else { if (isInlineList(this.ctx[r])) throw this.error(new TomlError("Can't extend an inline array")); if (isInlineTable(this.ctx[r])) throw this.error(new TomlError("Can't extend an inline table")); if (isList(this.ctx[r])) this.ctx = this.ctx[r][this.ctx[r].length - 1]; else if (isTable(this.ctx[r])) this.ctx = this.ctx[r]; else throw this.error(new TomlError("Can't redefine an existing key")); } return this.next(this.parseListNext); } else throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]")); } parseListEnd(r) { if (this.char === CHAR_RSQB) return this.next(this.parseWhitespaceToEOL); throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]")); } /* VALUE string, number, boolean, inline list, inline object */ parseValue() { if (this.char === e.END) throw this.error(new TomlError("Key without value")); if (this.char === CHAR_QUOT) return this.next(this.parseDoubleString); if (this.char === CHAR_APOS) return this.next(this.parseSingleString); if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) return this.goto(this.parseNumberSign); if (this.char === CHAR_i) return this.next(this.parseInf); if (this.char === CHAR_n) return this.next(this.parseNan); if (isDigit(this.char)) return this.goto(this.parseNumberOrDateTime); if (this.char === CHAR_t || this.char === CHAR_f) return this.goto(this.parseBoolean); if (this.char === CHAR_LSQB) return this.call(this.parseInlineList, this.recordValue); if (this.char === CHAR_LCUB) return this.call(this.parseInlineTable, this.recordValue); throw this.error(new TomlError("Unexpected character, expecting string, number, datetime, boolean, inline array or inline table")); } recordValue(r) { return this.returnNow(r); } parseInf() { if (this.char === CHAR_n) return this.next(this.parseInf2); throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"')); } parseInf2() { if (this.char === CHAR_f) return this.state.buf === "-" ? this.return(-1 / 0) : this.return(1 / 0); throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"')); } parseNan() { if (this.char === CHAR_a) return this.next(this.parseNan2); throw this.error(new TomlError('Unexpected character, expected "nan"')); } parseNan2() { if (this.char === CHAR_n) return this.return(NaN); throw this.error(new TomlError('Unexpected character, expected "nan"')); } /* KEYS, barewords or basic, literal, or dotted */ parseKeyword() { return this.char === CHAR_QUOT ? this.next(this.parseBasicString) : this.char === CHAR_APOS ? this.next(this.parseLiteralString) : this.goto(this.parseBareKey); } /* KEYS: barewords */ parseBareKey() { do { if (this.char === e.END) throw this.error(new TomlError("Key ended without value")); if (isAlphaNumHyphen(this.char)) this.consume(); else { if (this.state.buf.length === 0) throw this.error(new TomlError("Empty bare keys are not allowed")); return this.returnNow(); } } while (this.nextChar()); } /* STRINGS, single quoted (literal) */ parseSingleString() { return this.char === CHAR_APOS ? this.next(this.parseLiteralMultiStringMaybe) : this.goto(this.parseLiteralString); } parseLiteralString() { do { if (this.char === CHAR_APOS) return this.return(); if (this.atEndOfLine()) throw this.error(new TomlError("Unterminated string")); if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) throw this.errorControlCharIn("strings"); this.consume(); } while (this.nextChar()); } parseLiteralMultiStringMaybe() { return this.char === CHAR_APOS ? this.next(this.parseLiteralMultiString) : this.returnNow(); } parseLiteralMultiString() { return this.char === CTRL_M ? null : this.char === CTRL_J ? this.next(this.parseLiteralMultiStringContent) : this.goto(this.parseLiteralMultiStringContent); } parseLiteralMultiStringContent() { do { if (this.char === CHAR_APOS) return this.next(this.parseLiteralMultiEnd); if (this.char === e.END) throw this.error(new TomlError("Unterminated multi-line string")); if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) throw this.errorControlCharIn("strings"); this.consume(); } while (this.nextChar()); } parseLiteralMultiEnd() { return this.char === CHAR_APOS ? this.next(this.parseLiteralMultiEnd2) : (this.state.buf += "'", this.goto(this.parseLiteralMultiStringContent)); } parseLiteralMultiEnd2() { return this.char === CHAR_APOS ? this.next(this.parseLiteralMultiEnd3) : (this.state.buf += "''", this.goto(this.parseLiteralMultiStringContent)); } parseLiteralMultiEnd3() { return this.char === CHAR_APOS ? (this.state.buf += "'", this.next(this.parseLiteralMultiEnd4)) : this.returnNow(); } parseLiteralMultiEnd4() { return this.char === CHAR_APOS ? (this.state.buf += "'", this.return()) : this.returnNow(); } /* STRINGS double quoted */ parseDoubleString() { return this.char === CHAR_QUOT ? this.next(this.parseMultiStringMaybe) : this.goto(this.parseBasicString); } parseBasicString() { do { if (this.char === CHAR_BSOL) return this.call(this.parseEscape, this.recordEscapeReplacement); if (this.char === CHAR_QUOT) return this.return(); if (this.atEndOfLine()) throw this.error(new TomlError("Unterminated string")); if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) throw this.errorControlCharIn("strings"); this.consume(); } while (this.nextChar()); } recordEscapeReplacement(r) { return this.state.buf += r, this.goto(this.parseBasicString); } parseMultiStringMaybe() { return this.char === CHAR_QUOT ? this.next(this.parseMultiString) : this.returnNow(); } parseMultiString() { return this.char === CTRL_M ? null : this.char === CTRL_J ? this.next(this.parseMultiStringContent) : this.goto(this.parseMultiStringContent); } parseMultiStringContent() { do { if (this.char === CHAR_BSOL) return this.call(this.parseMultiEscape, this.recordMultiEscapeReplacement); if (this.char === CHAR_QUOT) return this.next(this.parseMultiEnd); if (this.char === e.END) throw this.error(new TomlError("Unterminated multi-line string")); if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) throw this.errorControlCharIn("strings"); this.consume(); } while (this.nextChar()); } errorControlCharIn(r) { let s = "\\u00"; return this.char < 16 && (s += "0"), s += this.char.toString(16), this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in ${r}, use ${s} instead`)); } recordMultiEscapeReplacement(r) { return this.state.buf += r, this.goto(this.parseMultiStringContent); } parseMultiEnd() { return this.char === CHAR_QUOT ? this.next(this.parseMultiEnd2) : (this.state.buf += '"', this.goto(this.parseMultiStringContent)); } parseMultiEnd2() { return this.char === CHAR_QUOT ? this.next(this.parseMultiEnd3) : (this.state.buf += '""', this.goto(this.parseMultiStringContent)); } parseMultiEnd3() { return this.char === CHAR_QUOT ? (this.state.buf += '"', this.next(this.parseMultiEnd4)) : this.returnNow(); } parseMultiEnd4() { return this.char === CHAR_QUOT ? (this.state.buf += '"', this.return()) : this.returnNow(); } parseMultiEscape() { return this.char === CTRL_M || this.char === CTRL_J ? this.next(this.parseMultiTrim) : this.char === CHAR_SP || this.char === CTRL_I ? this.next(this.parsePreMultiTrim) : this.goto(this.parseEscape); } parsePreMultiTrim() { if (this.char === CHAR_SP || this.char === CTRL_I) return null; if (this.char === CTRL_M || this.char === CTRL_J) return this.next(this.parseMultiTrim); throw this.error(new TomlError("Can't escape whitespace")); } parseMultiTrim() { return this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M ? null : this.returnNow(); } parseEscape() { if (this.char in escapes) return this.return(escapes[this.char]); if (this.char === CHAR_u) return this.call(this.parseSmallUnicode, this.parseUnicodeReturn); if (this.char === CHAR_U) return this.call(this.parseLargeUnicode, this.parseUnicodeReturn); throw this.error(new TomlError("Unknown escape character: " + this.char)); } parseUnicodeReturn(r) { try { const s = parseInt(r, 16); if (s >= SURROGATE_FIRST && s <= SURROGATE_LAST) throw this.error(new TomlError("Invalid unicode, character in range 0xD800 - 0xDFFF is reserved")); return this.returnNow(String.fromCodePoint(s)); } catch (s) { throw this.error(TomlError.wrap(s)); } } parseSmallUnicode() { if (isHexit(this.char)) { if (this.consume(), this.state.buf.length >= 4) return this.return(); } else throw this.error(new TomlError("Invalid character in unicode sequence, expected hex")); } parseLargeUnicode() { if (isHexit(this.char)) { if (this.consume(), this.state.buf.length >= 8) return this.return(); } else throw this.error(new TomlError("Invalid character in unicode sequence, expected hex")); } /* NUMBERS */ parseNumberSign() { return this.consume(), this.next(this.parseMaybeSignedInfOrNan); } parseMaybeSignedInfOrNan() { return this.char === CHAR_i ? this.next(this.parseInf) : this.char === CHAR_n ? this.next(this.parseNan) : this.callNow(this.parseNoUnder, this.parseNumberIntegerStart); } parseNumberIntegerStart() { return this.char === CHAR_0 ? (this.consume(), this.next(this.parseNumberIntegerExponentOrDecimal)) : this.goto(this.parseNumberInteger); } parseNumberIntegerExponentOrDecimal() { return this.char === CHAR_PERIOD ? (this.consume(), this.call(this.parseNoUnder, this.parseNumberFloat)) : this.char === CHAR_E || this.char === CHAR_e ? (this.consume(), this.next(this.parseNumberExponentSign)) : this.returnNow(Integer(this.state.buf)); } parseNumberInteger() { if (isDigit(this.char)) this.consume(); else { if (this.char === CHAR_LOWBAR) return this.call(this.parseNoUnder); if (this.char === CHAR_E || this.char === CHAR_e) return this.consume(), this.next(this.parseNumberExponentSign); if (this.char === CHAR_PERIOD) return this.consume(), this.call(this.parseNoUnder, this.parseNumberFloat); { const r = Integer(this.state.buf); if (r.isNaN()) throw this.error(new TomlError("Invalid number")); return this.returnNow(r); } } } parseNoUnder() { if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD || this.char === CHAR_E || this.char === CHAR_e) throw this.error(new TomlError("Unexpected character, expected digit")); if (this.atEndOfWord()) throw this.error(new TomlError("Incomplete number")); return this.returnNow(); } parseNoUnderHexOctBinLiteral() { if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD) throw this.error(new TomlError("Unexpected character, expected digit")); if (this.atEndOfWord()) throw this.error(new TomlError("Incomplete number")); return this.returnNow(); } parseNumberFloat() { if (this.char === CHAR_LOWBAR) return this.call(this.parseNoUnder, this.parseNumberFloat); if (isDigit(this.char)) this.consume(); else return this.char === CHAR_E || this.char === CHAR_e ? (this.consume(), this.next(this.parseNumberExponentSign)) : this.returnNow(Float(this.state.buf)); } parseNumberExponentSign() { if (isDigit(this.char)) return this.goto(this.parseNumberExponent); if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) this.consume(), this.call(this.parseNoUnder, this.parseNumberExponent); else throw this.error(new TomlError("Unexpected character, expected -, + or digit")); } parseNumberExponent() { if (isDigit(this.char)) this.consume(); else return this.char === CHAR_LOWBAR ? this.call(this.parseNoUnder) : this.returnNow(Float(this.state.buf)); } /* NUMBERS or DATETIMES */ parseNumberOrDateTime() { return this.char === CHAR_0 ? (this.consume(), this.next(this.parseNumberBaseOrDateTime)) : this.goto(this.parseNumberOrDateTimeOnly); } parseNumberOrDateTimeOnly() { if (this.char === CHAR_LOWBAR) return this.call(this.parseNoUnder, this.parseNumberInteger); if (isDigit(this.char)) this.consume(), this.state.buf.length > 4 && this.next(this.parseNumberInteger); else return this.char === CHAR_E || this.char === CHAR_e ? (this.consume(), this.next(this.parseNumberExponentSign)) : this.char === CHAR_PERIOD ? (this.consume(), this.call(this.parseNoUnder, this.parseNumberFloat)) : this.char === CHAR_HYPHEN ? this.goto(this.parseDateTime) : this.char === CHAR_COLON ? this.goto(this.parseOnlyTimeHour) : this.returnNow(Integer(this.state.buf)); } parseDateTimeOnly() { if (this.state.buf.length < 4) { if (isDigit(this.char)) return this.consume(); if (this.char === CHAR_COLON) return this.goto(this.parseOnlyTimeHour); throw this.error(new TomlError("Expected digit while parsing year part of a date")); } else { if (this.char === CHAR_HYPHEN) return this.goto(this.parseDateTime); throw this.error(new TomlError("Expected hyphen (-) while parsing year part of date")); } } parseNumberBaseOrDateTime() { return this.char === CHAR_b ? (this.consume(), this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerBin)) : this.char === CHAR_o ? (this.consume(), this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerOct)) : this.char === CHAR_x ? (this.consume(), this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerHex)) : this.char === CHAR_PERIOD ? this.goto(this.parseNumberInteger) : isDigit(this.char) ? this.goto(this.parseDateTimeOnly) : this.returnNow(Integer(this.state.buf)); } parseIntegerHex() { if (isHexit(this.char)) this.consume(); else { if (this.char === CHAR_LOWBAR) return this.call(this.parseNoUnderHexOctBinLiteral); { const r = Integer(this.state.buf); if (r.isNaN()) throw this.error(new TomlError("Invalid number")); return this.returnNow(r); } } } parseIntegerOct() { if (isOctit(this.char)) this.consume(); else { if (this.char === CHAR_LOWBAR) return this.call(this.parseNoUnderHexOctBinLiteral); { const r = Integer(this.state.buf); if (r.isNaN()) throw this.error(new TomlError("Invalid number")); return this.returnNow(r); } } } parseIntegerBin() { if (isBit(this.char)) this.consume(); else { if (this.char === CHAR_LOWBAR)