vite-uni-dev-tool
Version:
vite-uni-dev-tool, debug, uni-app, 一处编写,到处调试
115 lines (114 loc) • 2.64 kB
JavaScript
function g(e = "", t = "") {
if (!e)
return "";
if (!t)
return e;
const n = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), o = new RegExp(n, "g");
return e.replace(
o,
`<span style="color:#fff; background-color: var(--dev-tool-main-color);">${t}</span>`
);
}
function s(e) {
if (!e)
return "";
const t = {
"&": "&",
'"': """,
"'": "'",
">": ">",
"<": "<",
"=": "=",
"+": "+",
"-": "-",
"(": "(",
")": ")",
"[": "[",
"]": "]",
"{": "{",
"}": "}",
".": ".",
"?": "?",
"/": "/",
":": ":"
};
return e.replace(
/[&"'><=+\-().?\/:[\]{}]/g,
(n) => t[n] || n
);
}
const u = /https?:\/\/[^\s/$.?#](?:(?!\s|\)).)*/g;
function d(e) {
const t = e.match(u);
return t ? t[0] : "";
}
const c = /:(\d+)(?::(\d+))?\)?$/;
function x(e) {
const t = e.match(c);
if (t) {
const n = t[1], o = t[2];
return {
row: parseInt(n) - 1,
col: parseInt(o) - 1
};
}
return {
row: -1,
col: -1
};
}
const i = /at\s+(?:([^(]+)\s+\()?((?:[^:\/\s]+(?:\/[^:\/\s]+)*\.[^:\/\s]+)|(?:[^:]+:\/\/[^:\/\s]+(?::\d+)?(?:\/[^:\s]*)*)):(\d+)(?::(\d+))?(?:\s*\)?)?$/;
function h(e) {
const t = e == null ? void 0 : e.match(i);
return {
info: (t == null ? void 0 : t[1]) ?? "",
path: (t == null ? void 0 : t[2]) ?? "",
row: t != null && t[3] ? parseInt(t == null ? void 0 : t[3]) - 1 : -1,
col: t != null && t[4] ? parseInt(t == null ? void 0 : t[4]) - 1 : -1
};
}
const p = /https?:\/\/usr/;
function w(e) {
return p.test(e);
}
function v(e = "", t = 16, n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
let o = "";
for (let r = 0; r < t; r++)
o += n.charAt(Math.floor(Math.random() * n.length));
return e + o;
}
const a = /(https?:\/\/|www\.)([^\s<>"'`)]*)/g;
function y(e) {
let t = [], n = 0, o;
for (; (o = a.exec(e)) !== null; ) {
if (o.index > n) {
const l = e.slice(n, o.index);
l && t.push({ type: "string", value: l });
}
const r = o[0];
t.push({ type: "link", value: r }), n = o.index + r.length;
}
if (n < e.length) {
const r = e.slice(n);
r && t.push({ type: "string", value: r });
}
return t = t.map((r) => ({
...r,
value: r.type === "string" ? s(r.value) : r.value
})), t;
}
const f = /(https?:\/\/|www\.)/;
function I(e) {
return f.test(e);
}
export {
s as escapeHTML,
x as extractRowAndCol,
d as extractUrl,
I as hasUrl,
g as hightLight,
w as isMockWX,
h as parseStock,
y as splitStrByUrl,
v as uniqueId
};