@anoki/fse-ui
Version:
FSE UI components library
94 lines (93 loc) • 3.26 kB
JavaScript
import s from "./index.es705.js";
var u, m;
function w() {
if (m) return u;
m = 1;
let { existsSync: p, readFileSync: d } = s, { dirname: r, join: g } = s, { SourceMapConsumer: l, SourceMapGenerator: f } = s;
function M(o) {
return Buffer ? Buffer.from(o, "base64").toString() : window.atob(o);
}
class a {
constructor(t, e) {
if (e.map === !1) return;
this.loadAnnotation(t), this.inline = this.startWith(this.annotation, "data:");
let i = e.map ? e.map.prev : void 0, n = this.loadMap(e.from, i);
!this.mapFile && e.from && (this.mapFile = e.from), this.mapFile && (this.root = r(this.mapFile)), n && (this.text = n);
}
consumer() {
return this.consumerCache || (this.consumerCache = new l(this.text)), this.consumerCache;
}
decodeInline(t) {
let e = /^data:application\/json;charset=utf-?8;base64,/, i = /^data:application\/json;base64,/, n = /^data:application\/json;charset=utf-?8,/, b = /^data:application\/json,/, h = t.match(n) || t.match(b);
if (h)
return decodeURIComponent(t.substr(h[0].length));
let c = t.match(e) || t.match(i);
if (c)
return M(t.substr(c[0].length));
let S = t.match(/data:application\/json;([^,]+),/)[1];
throw new Error("Unsupported source map encoding " + S);
}
getAnnotationURL(t) {
return t.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
}
isMap(t) {
return typeof t != "object" ? !1 : typeof t.mappings == "string" || typeof t._mappings == "string" || Array.isArray(t.sections);
}
loadAnnotation(t) {
let e = t.match(/\/\*\s*# sourceMappingURL=/g);
if (!e) return;
let i = t.lastIndexOf(e.pop()), n = t.indexOf("*/", i);
i > -1 && n > -1 && (this.annotation = this.getAnnotationURL(t.substring(i, n)));
}
loadFile(t) {
if (this.root = r(t), p(t))
return this.mapFile = t, d(t, "utf-8").toString().trim();
}
loadMap(t, e) {
if (e === !1) return !1;
if (e) {
if (typeof e == "string")
return e;
if (typeof e == "function") {
let i = e(t);
if (i) {
let n = this.loadFile(i);
if (!n)
throw new Error(
"Unable to load previous source map: " + i.toString()
);
return n;
}
} else {
if (e instanceof l)
return f.fromSourceMap(e).toString();
if (e instanceof f)
return e.toString();
if (this.isMap(e))
return JSON.stringify(e);
throw new Error(
"Unsupported previous source map format: " + e.toString()
);
}
} else {
if (this.inline)
return this.decodeInline(this.annotation);
if (this.annotation) {
let i = this.annotation;
return t && (i = g(r(t), i)), this.loadFile(i);
}
}
}
startWith(t, e) {
return t ? t.substr(0, e.length) === e : !1;
}
withContent() {
return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
}
}
return u = a, a.default = a, u;
}
export {
w as __require
};
//# sourceMappingURL=index.es706.js.map