@mt-kit/vue-config
Version:
524 lines (499 loc) • 18.4 kB
JavaScript
var A = Object.defineProperty, z = (e, t, r) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, b = (e, t, r) => z(e, typeof t != "symbol" ? t + "" : t, r), E = function() {
if (typeof Map < "u")
return Map;
function e(t, r) {
var n = -1;
return t.some(function(o, i) {
return o[0] === r ? (n = i, !0) : !1;
}), n;
}
return (
/** @class */
function() {
function t() {
this.__entries__ = [];
}
return Object.defineProperty(t.prototype, "size", {
/**
* @returns {boolean}
*/
get: function() {
return this.__entries__.length;
},
enumerable: !0,
configurable: !0
}), t.prototype.get = function(r) {
var n = e(this.__entries__, r), o = this.__entries__[n];
return o && o[1];
}, t.prototype.set = function(r, n) {
var o = e(this.__entries__, r);
~o ? this.__entries__[o][1] = n : this.__entries__.push([r, n]);
}, t.prototype.delete = function(r) {
var n = this.__entries__, o = e(n, r);
~o && n.splice(o, 1);
}, t.prototype.has = function(r) {
return !!~e(this.__entries__, r);
}, t.prototype.clear = function() {
this.__entries__.splice(0);
}, t.prototype.forEach = function(r, n) {
n === void 0 && (n = null);
for (var o = 0, i = this.__entries__; o < i.length; o++) {
var s = i[o];
r.call(n, s[1], s[0]);
}
}, t;
}()
);
}(), m = typeof window < "u" && typeof document < "u" && window.document === document, d = function() {
return typeof global < "u" && global.Math === Math ? global : typeof self < "u" && self.Math === Math ? self : typeof window < "u" && window.Math === Math ? window : Function("return this")();
}(), L = function() {
return typeof requestAnimationFrame == "function" ? requestAnimationFrame.bind(d) : function(e) {
return setTimeout(function() {
return e(Date.now());
}, 1e3 / 60);
};
}(), $ = 2;
function C(e, t) {
var r = !1, n = !1, o = 0;
function i() {
r && (r = !1, e()), n && c();
}
function s() {
L(i);
}
function c() {
var a = Date.now();
if (r) {
if (a - o < $)
return;
n = !0;
} else
r = !0, n = !1, setTimeout(s, t);
o = a;
}
return c;
}
var R = 20, S = ["top", "right", "bottom", "left", "width", "height", "size", "weight"], D = typeof MutationObserver < "u", H = (
/** @class */
function() {
function e() {
this.connected_ = !1, this.mutationEventsAdded_ = !1, this.mutationsObserver_ = null, this.observers_ = [], this.onTransitionEnd_ = this.onTransitionEnd_.bind(this), this.refresh = C(this.refresh.bind(this), R);
}
return e.prototype.addObserver = function(t) {
~this.observers_.indexOf(t) || this.observers_.push(t), this.connected_ || this.connect_();
}, e.prototype.removeObserver = function(t) {
var r = this.observers_, n = r.indexOf(t);
~n && r.splice(n, 1), !r.length && this.connected_ && this.disconnect_();
}, e.prototype.refresh = function() {
var t = this.updateObservers_();
t && this.refresh();
}, e.prototype.updateObservers_ = function() {
var t = this.observers_.filter(function(r) {
return r.gatherActive(), r.hasActive();
});
return t.forEach(function(r) {
return r.broadcastActive();
}), t.length > 0;
}, e.prototype.connect_ = function() {
!m || this.connected_ || (document.addEventListener("transitionend", this.onTransitionEnd_), window.addEventListener("resize", this.refresh), D ? (this.mutationsObserver_ = new MutationObserver(this.refresh), this.mutationsObserver_.observe(document, {
attributes: !0,
childList: !0,
characterData: !0,
subtree: !0
})) : (document.addEventListener("DOMSubtreeModified", this.refresh), this.mutationEventsAdded_ = !0), this.connected_ = !0);
}, e.prototype.disconnect_ = function() {
!m || !this.connected_ || (document.removeEventListener("transitionend", this.onTransitionEnd_), window.removeEventListener("resize", this.refresh), this.mutationsObserver_ && this.mutationsObserver_.disconnect(), this.mutationEventsAdded_ && document.removeEventListener("DOMSubtreeModified", this.refresh), this.mutationsObserver_ = null, this.mutationEventsAdded_ = !1, this.connected_ = !1);
}, e.prototype.onTransitionEnd_ = function(t) {
var r = t.propertyName, n = r === void 0 ? "" : r, o = S.some(function(i) {
return !!~n.indexOf(i);
});
o && this.refresh();
}, e.getInstance = function() {
return this.instance_ || (this.instance_ = new e()), this.instance_;
}, e.instance_ = null, e;
}()
), k = function(e, t) {
for (var r = 0, n = Object.keys(t); r < n.length; r++) {
var o = n[r];
Object.defineProperty(e, o, {
value: t[o],
enumerable: !1,
writable: !1,
configurable: !0
});
}
return e;
}, h = function(e) {
var t = e && e.ownerDocument && e.ownerDocument.defaultView;
return t || d;
}, O = p(0, 0, 0, 0);
function f(e) {
return parseFloat(e) || 0;
}
function _(e) {
for (var t = [], r = 1; r < arguments.length; r++)
t[r - 1] = arguments[r];
return t.reduce(function(n, o) {
var i = e["border-" + o + "-width"];
return n + f(i);
}, 0);
}
function j(e) {
for (var t = ["top", "right", "bottom", "left"], r = {}, n = 0, o = t; n < o.length; n++) {
var i = o[n], s = e["padding-" + i];
r[i] = f(s);
}
return r;
}
function q(e) {
var t = e.getBBox();
return p(0, 0, t.width, t.height);
}
function N(e) {
var t = e.clientWidth, r = e.clientHeight;
if (!t && !r)
return O;
var n = h(e).getComputedStyle(e), o = j(n), i = o.left + o.right, s = o.top + o.bottom, c = f(n.width), a = f(n.height);
if (n.boxSizing === "border-box" && (Math.round(c + i) !== t && (c -= _(n, "left", "right") + i), Math.round(a + s) !== r && (a -= _(n, "top", "bottom") + s)), !B(e)) {
var l = Math.round(c + i) - t, u = Math.round(a + s) - r;
Math.abs(l) !== 1 && (c -= l), Math.abs(u) !== 1 && (a -= u);
}
return p(o.left, o.top, c, a);
}
var W = /* @__PURE__ */ function() {
return typeof SVGGraphicsElement < "u" ? function(e) {
return e instanceof h(e).SVGGraphicsElement;
} : function(e) {
return e instanceof h(e).SVGElement && typeof e.getBBox == "function";
};
}();
function B(e) {
return e === h(e).document.documentElement;
}
function F(e) {
return m ? W(e) ? q(e) : N(e) : O;
}
function G(e) {
var t = e.x, r = e.y, n = e.width, o = e.height, i = typeof DOMRectReadOnly < "u" ? DOMRectReadOnly : Object, s = Object.create(i.prototype);
return k(s, {
x: t,
y: r,
width: n,
height: o,
top: r,
right: t + n,
bottom: o + r,
left: t
}), s;
}
function p(e, t, r, n) {
return { x: e, y: t, width: r, height: n };
}
var I = (
/** @class */
function() {
function e(t) {
this.broadcastWidth = 0, this.broadcastHeight = 0, this.contentRect_ = p(0, 0, 0, 0), this.target = t;
}
return e.prototype.isActive = function() {
var t = F(this.target);
return this.contentRect_ = t, t.width !== this.broadcastWidth || t.height !== this.broadcastHeight;
}, e.prototype.broadcastRect = function() {
var t = this.contentRect_;
return this.broadcastWidth = t.width, this.broadcastHeight = t.height, t;
}, e;
}()
), P = (
/** @class */
/* @__PURE__ */ function() {
function e(t, r) {
var n = G(r);
k(this, { target: t, contentRect: n });
}
return e;
}()
), V = (
/** @class */
function() {
function e(t, r, n) {
if (this.activeObservations_ = [], this.observations_ = new E(), typeof t != "function")
throw new TypeError("The callback provided as parameter 1 is not a function.");
this.callback_ = t, this.controller_ = r, this.callbackCtx_ = n;
}
return e.prototype.observe = function(t) {
if (!arguments.length)
throw new TypeError("1 argument required, but only 0 present.");
if (!(typeof Element > "u" || !(Element instanceof Object))) {
if (!(t instanceof h(t).Element))
throw new TypeError('parameter 1 is not of type "Element".');
var r = this.observations_;
r.has(t) || (r.set(t, new I(t)), this.controller_.addObserver(this), this.controller_.refresh());
}
}, e.prototype.unobserve = function(t) {
if (!arguments.length)
throw new TypeError("1 argument required, but only 0 present.");
if (!(typeof Element > "u" || !(Element instanceof Object))) {
if (!(t instanceof h(t).Element))
throw new TypeError('parameter 1 is not of type "Element".');
var r = this.observations_;
r.has(t) && (r.delete(t), r.size || this.controller_.removeObserver(this));
}
}, e.prototype.disconnect = function() {
this.clearActive(), this.observations_.clear(), this.controller_.removeObserver(this);
}, e.prototype.gatherActive = function() {
var t = this;
this.clearActive(), this.observations_.forEach(function(r) {
r.isActive() && t.activeObservations_.push(r);
});
}, e.prototype.broadcastActive = function() {
if (this.hasActive()) {
var t = this.callbackCtx_, r = this.activeObservations_.map(function(n) {
return new P(n.target, n.broadcastRect());
});
this.callback_.call(t, r, t), this.clearActive();
}
}, e.prototype.clearActive = function() {
this.activeObservations_.splice(0);
}, e.prototype.hasActive = function() {
return this.activeObservations_.length > 0;
}, e;
}()
), M = typeof WeakMap < "u" ? /* @__PURE__ */ new WeakMap() : new E(), T = (
/** @class */
/* @__PURE__ */ function() {
function e(t) {
if (!(this instanceof e))
throw new TypeError("Cannot call a class as a function.");
if (!arguments.length)
throw new TypeError("1 argument required, but only 0 present.");
var r = H.getInstance(), n = new V(t, r, this);
M.set(this, n);
}
return e;
}()
);
[
"observe",
"unobserve",
"disconnect"
].forEach(function(e) {
T.prototype[e] = function() {
var t;
return (t = M.get(this))[e].apply(t, arguments);
};
});
(function() {
return typeof d.ResizeObserver < "u" ? d.ResizeObserver : T;
})();
function J(e = !1) {
return `
<style>
:host {
${e ? `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 99999;` : ""}
--monospace: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
--red: #ff5555;
--yellow: #e2aa53;
--purple: #cfa4ff;
--cyan: #2dd9da;
--dim: #c9c9c9;
${e ? `
--window-background: #181818;
--window-color: #d8d8d8;` : ""}
}
.backdrop {
${e ? `
position: fixed;
z-index: 99999;
top: 0;
left: 0;` : ""}
width: 100%;
height: 100%;
overflow-y: scroll;
margin: 0;
${e ? "background: rgba(0, 0, 0, 0.66);" : ""}
background: rgba(0, 0, 0, 0.66);
}
.window {
font-family: var(--monospace);
line-height: 1.5;
${e ? "width: 800px;" : "width: 100%"}
color: var(--window-color);
${e ? "margin: 30px auto;" : ""}
padding: 25px 40px;
position: relative;
background: var(--window-background);
border-radius: 6px 6px 8px 8px;
overflow: hidden;
border-top: 8px solid var(--red);
direction: ltr;
text-align: left;
}
pre {
font-family: var(--monospace);
font-size: 16px;
margin-top: 0;
margin-bottom: 1em;
overflow-x: scroll;
scrollbar-width: none;
}
pre::-webkit-scrollbar {
display: none;
}
pre.frame::-webkit-scrollbar {
display: block;
height: 5px;
}
pre.frame::-webkit-scrollbar-thumb {
background: #999;
border-radius: 5px;
}
pre.frame {
scrollbar-width: thin;
}
.message {
line-height: 1.3;
font-weight: 600;
white-space: pre-wrap;
}
.message-body {
color: var(--red);
}
.plugin {
color: var(--purple);
}
.file {
color: var(--cyan);
margin-bottom: 0;
white-space: pre-wrap;
word-break: break-all;
}
.frame {
color: var(--yellow);
}
.stack {
font-size: 13px;
color: var(--dim);
}
.tip {
font-size: 13px;
color: #999;
border-top: 1px dotted #999;
padding-top: 13px;
line-height: 1.8;
}
code {
font-size: 13px;
font-family: var(--monospace);
color: var(--yellow);
}
.file-link {
text-decoration: underline;
cursor: pointer;
}
a {
color: var(--dim);
}
kbd {
line-height: 1.5;
font-family: ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 0.75rem;
font-weight: 700;
background-color: rgb(38, 40, 44);
color: rgb(166, 167, 171);
padding: 0.15rem 0.3rem;
border-radius: 0.25rem;
border-width: 0.0625rem 0.0625rem 0.1875rem;
border-style: solid;
border-color: rgb(54, 57, 64);
border-image: initial;
}
</style>
<div class="backdrop" part="backdrop">
<div class="window" part="window">
<pre class="message" part="message"><span class="plugin" part="plugin"></span><span class="message-body" part="message-body"></span></pre>
<pre class="file" part="file"></pre>
<pre class="frame" part="frame"></pre>
<pre class="stack" part="stack"></pre>
<div class="tip" part="tip">
Click outside, press <kbd>Esc</kbd> key, or fix the code to dismiss.
</div>
</div>
</div>
`;
}
const w = /(?:[a-z]:\\|\/).*?:\d+:\d+/gi, v = /^(?:>?\s*\d+\s+\|.*|\s+\|\s*\^.*)\r?\n/gm, {
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
HTMLElement: K = class {
}
} = globalThis;
let Q = class extends K {
constructor(e, t = !1, r = !0) {
var n, o, i;
super(), b(this, "root"), b(this, "closeOnEsc"), b(this, "dialog"), this.root = this.attachShadow({
mode: "open"
}), this.root.innerHTML = J(t), this.dialog = t, t || this.closeText(), v.lastIndex = 0;
const s = e.frame && v.test(e.frame), c = s ? e.message.replaceAll(v, "") : e.message;
e.plugin && this.text(".plugin", `[plugin:${e.plugin}] `), this.text(".message-body", c.trim());
const [a] = (((n = e.loc) == null ? void 0 : n.file) || e.id || "unknown file").split("?");
e.loc ? this.text(".file", `${a}:${e.loc.line}:${e.loc.column}`, r) : e.id && this.text(".file", a), s && this.text(".frame", ((o = e.frame) == null ? void 0 : o.trim()) || ""), this.text(".stack", e.stack, r), (i = this.root.querySelector(".window")) == null || i.addEventListener("click", (l) => {
l.stopPropagation();
}), this.addEventListener("click", () => {
this.close();
}), this.closeOnEsc = (l) => {
(l.key === "Escape" || l.code === "Escape") && this.close();
}, document.addEventListener("keydown", this.closeOnEsc);
}
text(e, t, r = !1) {
const n = this.root.querySelector(e);
if (r) {
let o = 0, i;
for (w.lastIndex = 0; i = w.exec(t); ) {
const {
0: s,
index: c
} = i;
if (c != null) {
const a = t.slice(o, c), l = document.location.protocol + s;
n.append(document.createTextNode(a));
const u = document.createElement("a");
u.textContent = s, u.className = "file-link", u.href = l, u.target = "_blank", n.append(u), o += a.length + s.length;
}
}
} else
n.textContent = t;
}
closeText() {
const e = this.root.querySelector(".tip");
e.style.display = "none";
}
close() {
var e;
this.dialog && ((e = this.parentNode) == null || e.removeChild(this), document.removeEventListener("keydown", this.closeOnEsc));
}
};
const y = "imitation-vue-error", {
customElements: g
} = globalThis;
g && !g.get(y) && g.define(y, Q);
const U = customElements.get("imitation-vue-error");
function x(e, t) {
return new U(e, t);
}
function X(e, t, r) {
t == null || t.$nextTick(() => {
if ((t == null ? void 0 : t.$el.childNodes.length) > 0) {
(t == null ? void 0 : t.$el).innerHTML = "", (t == null ? void 0 : t.$el).append(x(e));
return;
}
(t == null ? void 0 : t.$el).textContent = `${r}: ${e}`, document.body.append(x(e, !0));
});
}
export {
X as configErrorHandler
};