@anoki/fse-ui
Version:
FSE UI components library
58 lines (56 loc) • 2.36 kB
JavaScript
import { __require as q } from "./index.es704.js";
import L from "./index.es705.js";
var m, S;
function w() {
if (S) return m;
S = 1;
let f = /* @__PURE__ */ q(), d = L;
class h extends Error {
constructor(t, n, i, r, l, a) {
super(t), this.name = "CssSyntaxError", this.reason = t, l && (this.file = l), r && (this.source = r), a && (this.plugin = a), typeof n < "u" && typeof i < "u" && (typeof n == "number" ? (this.line = n, this.column = i) : (this.line = n.line, this.column = n.column, this.endLine = i.line, this.endColumn = i.column)), this.setMessage(), Error.captureStackTrace && Error.captureStackTrace(this, h);
}
setMessage() {
this.message = this.plugin ? this.plugin + ": " : "", this.message += this.file ? this.file : "<css input>", typeof this.line < "u" && (this.message += ":" + this.line + ":" + this.column), this.message += ": " + this.reason;
}
showSourceCode(t) {
if (!this.source) return "";
let n = this.source;
t == null && (t = f.isColorSupported);
let i = (e) => e, r = (e) => e, l = (e) => e;
if (t) {
let { bold: e, gray: c, red: o } = f.createColors(!0);
r = (s) => e(o(s)), i = (s) => c(s), d && (l = (s) => d(s));
}
let a = n.split(/\r?\n/), g = Math.max(this.line - 3, 0), p = Math.min(this.line + 2, a.length), x = String(p).length;
return a.slice(g, p).map((e, c) => {
let o = g + 1 + c, s = " " + (" " + o).slice(-x) + " | ";
if (o === this.line) {
if (e.length > 160) {
let u = 20, C = Math.max(0, this.column - u), E = Math.max(
this.column + u,
this.endColumn + u
), b = e.slice(C, E), M = i(s.replace(/\d/g, " ")) + e.slice(0, Math.min(this.column - 1, u - 1)).replace(/[^\t]/g, " ");
return r(">") + i(s) + l(b) + `
` + M + r("^");
}
let y = i(s.replace(/\d/g, " ")) + e.slice(0, this.column - 1).replace(/[^\t]/g, " ");
return r(">") + i(s) + l(e) + `
` + y + r("^");
}
return " " + i(s) + l(e);
}).join(`
`);
}
toString() {
let t = this.showSourceCode();
return t && (t = `
` + t + `
`), this.name + ": " + this.message + t;
}
}
return m = h, h.default = h, m;
}
export {
w as __require
};
//# sourceMappingURL=index.es688.js.map