@unicom-cloud/utils 0.1.4 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constant/keyboardCode.js +41 -40
- package/constant/platform.js +14 -16
- package/content-disposition/index.js +56 -0
- package/cookie/src/index.js +46 -46
- package/dayjs/index.js +15 -0
- package/decimal/decimal.js +56 -56
- package/event-emitter/index.js +14 -23
- package/file/fileToURL.js +8 -9
- package/file/saveAs.js +1 -1
- package/index.js +42 -37
- package/mock/MockWebSocket.js +67 -90
- package/mock/MockXMLHttpRequest.js +51 -61
- package/package.json +1 -1
- package/random/address.js +10 -10
- package/screenfull/index.js +43 -43
- package/snapdom/src/api/preCache.js +39 -25
- package/snapdom/src/api/snapdom.js +56 -56
- package/snapdom/src/core/cache.js +3 -2
- package/snapdom/src/core/capture.js +62 -51
- package/snapdom/src/core/clone.js +38 -37
- package/snapdom/src/core/prepare.js +40 -34
- package/snapdom/src/modules/background.js +20 -22
- package/snapdom/src/modules/fonts.js +148 -45
- package/snapdom/src/modules/images.js +7 -7
- package/snapdom/src/modules/pseudo.js +77 -48
- package/snapdom/src/modules/styles.js +7 -8
- package/snapdom/src/utils/helpers.js +90 -38
- package/tree/index.js +31 -32
- package/turbo-stream/src/encode.js +149 -152
- package/turbo-stream/src/shared.js +155 -173
|
@@ -1,63 +1,166 @@
|
|
|
1
|
-
import { resourceCache as
|
|
2
|
-
import { isIconFont as
|
|
3
|
-
async function
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
return
|
|
1
|
+
import { resourceCache as c, processedFontURLs as h } from "../core/cache.js";
|
|
2
|
+
import { isIconFont as b, extractURL as $ } from "../utils/helpers.js";
|
|
3
|
+
async function _(f, a, l, p = 32, g = "#000") {
|
|
4
|
+
a = a.replace(/^['"]+|['"]+$/g, "");
|
|
5
|
+
const i = window.devicePixelRatio || 1, n = document.createElement("canvas").getContext("2d");
|
|
6
|
+
n.font = l ? `${l} ${p}px "${a}"` : `${p}px "${a}"`;
|
|
7
|
+
const o = n.measureText(f), m = o.actualBoundingBoxAscent || p * 0.8, s = o.actualBoundingBoxDescent || p * 0.2, d = m + s, r = o.width, u = document.createElement("canvas");
|
|
8
|
+
u.width = Math.ceil(r * i), u.height = Math.ceil(d * i);
|
|
9
|
+
const e = u.getContext("2d");
|
|
10
|
+
return e.scale(i, i), e.font = n.font, e.textAlign = "left", e.textBaseline = "alphabetic", e.fillStyle = g, e.fillText(f, 0, m), u.toDataURL();
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
function A(f) {
|
|
13
|
+
return Array.from(document.styleSheets).some((a) => a.href === f);
|
|
14
|
+
}
|
|
15
|
+
function C(f) {
|
|
16
|
+
return new Promise((a) => {
|
|
17
|
+
if (A(f)) return a(null);
|
|
18
|
+
const l = document.createElement("link");
|
|
19
|
+
l.rel = "stylesheet", l.href = f, l.setAttribute("data-snapdom", "injected-import"), l.onload = () => a(l), l.onerror = () => a(null), document.head.appendChild(l);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async function P({
|
|
23
|
+
ignoreIconFonts: f = !0,
|
|
24
|
+
preCached: a = !1
|
|
25
|
+
} = {}) {
|
|
26
|
+
if (c.has("fonts-embed-css")) {
|
|
27
|
+
if (a) {
|
|
28
|
+
const t = document.createElement("style");
|
|
29
|
+
t.setAttribute("data-snapdom", "embedFonts"), t.textContent = c.get("fonts-embed-css"), document.head.appendChild(t);
|
|
30
|
+
}
|
|
31
|
+
return c.get("fonts-embed-css");
|
|
32
|
+
}
|
|
33
|
+
const l = /@import\s+url\(["']?([^"')]+)["']?\)/g, p = [];
|
|
34
|
+
for (const t of document.querySelectorAll("style")) {
|
|
35
|
+
const n = t.textContent || "", o = Array.from(n.matchAll(l));
|
|
36
|
+
for (const m of o) {
|
|
37
|
+
const s = m[1];
|
|
38
|
+
A(s) || p.push(s);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
await Promise.all(p.map(C));
|
|
42
|
+
const g = Array.from(
|
|
17
43
|
document.querySelectorAll('link[rel="stylesheet"]')
|
|
18
|
-
).filter((
|
|
19
|
-
let
|
|
20
|
-
for (const
|
|
44
|
+
).filter((t) => t.href);
|
|
45
|
+
let i = "";
|
|
46
|
+
for (const t of g)
|
|
21
47
|
try {
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
48
|
+
const o = await (await fetch(t.href)).text();
|
|
49
|
+
if (f && (b(t.href) || b(o)))
|
|
24
50
|
continue;
|
|
25
|
-
const
|
|
26
|
-
Array.from(
|
|
27
|
-
let
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
51
|
+
const m = /url\((["']?)([^"')]+)\1\)/g, s = await Promise.all(
|
|
52
|
+
Array.from(o.matchAll(m)).map(async (r) => {
|
|
53
|
+
let u = $(r[0]);
|
|
54
|
+
if (!u) return null;
|
|
55
|
+
let e = u;
|
|
56
|
+
if (!e.startsWith("http") && !e.startsWith("data:") && (e = new URL(e, t.href).href), f && b(e)) return null;
|
|
57
|
+
if (c.has(e))
|
|
58
|
+
return h.add(e), {
|
|
59
|
+
original: r[0],
|
|
60
|
+
inlined: `url(${c.get(e)})`
|
|
34
61
|
};
|
|
62
|
+
if (h.has(e)) return null;
|
|
35
63
|
try {
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
64
|
+
const S = await (await fetch(e)).blob(), w = await new Promise((R) => {
|
|
65
|
+
const y = new FileReader();
|
|
66
|
+
y.onload = () => R(y.result), y.readAsDataURL(S);
|
|
39
67
|
});
|
|
40
|
-
return
|
|
68
|
+
return c.set(e, w), h.add(e), { original: r[0], inlined: `url(${w})` };
|
|
41
69
|
} catch {
|
|
42
|
-
return console.warn("
|
|
70
|
+
return console.warn("[snapdom] Failed to fetch font resource:", e), null;
|
|
43
71
|
}
|
|
44
72
|
})
|
|
45
73
|
);
|
|
46
|
-
let
|
|
47
|
-
for (const
|
|
48
|
-
|
|
49
|
-
|
|
74
|
+
let d = o;
|
|
75
|
+
for (const r of s)
|
|
76
|
+
r && (d = d.replace(r.original, r.inlined));
|
|
77
|
+
i += d + `
|
|
50
78
|
`;
|
|
51
79
|
} catch {
|
|
52
|
-
console.warn("
|
|
80
|
+
console.warn("[snapdom] Failed to fetch CSS:", t.href);
|
|
81
|
+
}
|
|
82
|
+
for (const t of document.styleSheets)
|
|
83
|
+
try {
|
|
84
|
+
if (!t.href || g.every((n) => n.href !== t.href)) {
|
|
85
|
+
for (const n of t.cssRules)
|
|
86
|
+
if (n.type === CSSRule.FONT_FACE_RULE) {
|
|
87
|
+
const o = n.style.getPropertyValue("src");
|
|
88
|
+
if (!o) continue;
|
|
89
|
+
const m = /url\((["']?)([^"')]+)\1\)/g;
|
|
90
|
+
let s = o;
|
|
91
|
+
const d = Array.from(o.matchAll(m));
|
|
92
|
+
for (const r of d) {
|
|
93
|
+
let u = r[2].trim();
|
|
94
|
+
if (!u) continue;
|
|
95
|
+
let e = u;
|
|
96
|
+
if (!e.startsWith("http") && !e.startsWith("data:") && (e = new URL(e, t.href || location.href).href), !(f && b(e))) {
|
|
97
|
+
if (c.has(e)) {
|
|
98
|
+
h.add(e), s = s.replace(
|
|
99
|
+
r[0],
|
|
100
|
+
`url(${c.get(e)})`
|
|
101
|
+
);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (!h.has(e))
|
|
105
|
+
try {
|
|
106
|
+
const S = await (await fetch(e)).blob(), w = await new Promise((R) => {
|
|
107
|
+
const y = new FileReader();
|
|
108
|
+
y.onload = () => R(y.result), y.readAsDataURL(S);
|
|
109
|
+
});
|
|
110
|
+
c.set(e, w), h.add(e), s = s.replace(r[0], `url(${w})`);
|
|
111
|
+
} catch {
|
|
112
|
+
console.warn("[snapdom] Failed to fetch font URL:", e);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
i += `@font-face {
|
|
117
|
+
font-family: ${n.style.getPropertyValue("font-family")};
|
|
118
|
+
src: ${s};
|
|
119
|
+
font-style: ${n.style.getPropertyValue("font-style") || "normal"};
|
|
120
|
+
font-weight: ${n.style.getPropertyValue("font-weight") || "normal"};
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
} catch (n) {
|
|
126
|
+
console.warn("[snapdom] Cannot access stylesheet", t.href, n);
|
|
127
|
+
}
|
|
128
|
+
for (const t of document.fonts)
|
|
129
|
+
if (t.family && t.status === "loaded" && t._snapdomSrc) {
|
|
130
|
+
let n = t._snapdomSrc;
|
|
131
|
+
if (!n.startsWith("data:")) {
|
|
132
|
+
if (c.has(t._snapdomSrc))
|
|
133
|
+
n = c.get(t._snapdomSrc), h.add(t._snapdomSrc);
|
|
134
|
+
else if (!h.has(t._snapdomSrc))
|
|
135
|
+
try {
|
|
136
|
+
const m = await (await fetch(t._snapdomSrc)).blob();
|
|
137
|
+
n = await new Promise((s) => {
|
|
138
|
+
const d = new FileReader();
|
|
139
|
+
d.onload = () => s(d.result), d.readAsDataURL(m);
|
|
140
|
+
}), c.set(t._snapdomSrc, n), h.add(t._snapdomSrc);
|
|
141
|
+
} catch {
|
|
142
|
+
console.warn(
|
|
143
|
+
"[snapdom] Failed to fetch dynamic font src:",
|
|
144
|
+
t._snapdomSrc
|
|
145
|
+
);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
i += `@font-face {
|
|
150
|
+
font-family: '${t.family}';
|
|
151
|
+
src: url(${n});
|
|
152
|
+
font-style: ${t.style || "normal"};
|
|
153
|
+
font-weight: ${t.weight || "normal"};
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
53
156
|
}
|
|
54
|
-
if (
|
|
55
|
-
const
|
|
56
|
-
|
|
157
|
+
if (i && (c.set("fonts-embed-css", i), a)) {
|
|
158
|
+
const t = document.createElement("style");
|
|
159
|
+
t.setAttribute("data-snapdom", "embedFonts"), t.textContent = i, document.head.appendChild(t);
|
|
57
160
|
}
|
|
58
|
-
return
|
|
161
|
+
return i;
|
|
59
162
|
}
|
|
60
163
|
export {
|
|
61
|
-
|
|
62
|
-
|
|
164
|
+
P as embedCustomFonts,
|
|
165
|
+
_ as iconToImage
|
|
63
166
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { fetchImage as
|
|
2
|
-
async function h(
|
|
3
|
-
const
|
|
1
|
+
import { fetchImage as o } from "../utils/helpers.js";
|
|
2
|
+
async function h(i, n = {}) {
|
|
3
|
+
const r = Array.from(i.querySelectorAll("img")), s = async (t) => {
|
|
4
4
|
const c = t.src;
|
|
5
5
|
try {
|
|
6
|
-
const e = await
|
|
7
|
-
t.src =
|
|
6
|
+
const e = n.crossOrigin ? n.crossOrigin(c) : "anonymous", a = await o(c, 3e3, e);
|
|
7
|
+
t.src = a, t.width || (t.width = t.naturalWidth || 100), t.height || (t.height = t.naturalHeight || 100);
|
|
8
8
|
} catch {
|
|
9
9
|
const e = document.createElement("div");
|
|
10
10
|
e.style = `width: ${t.width || 100}px; height: ${t.height || 100}px; background: #ccc; display: inline-block; text-align: center; line-height: ${t.height || 100}px; color: #666; font-size: 12px;`, e.innerText = "img", t.replaceWith(e);
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
-
for (let t = 0; t <
|
|
14
|
-
const c =
|
|
13
|
+
for (let t = 0; t < r.length; t += 4) {
|
|
14
|
+
const c = r.slice(t, t + 4).map(s);
|
|
15
15
|
await Promise.allSettled(c);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1,63 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
async function
|
|
5
|
-
if (!(
|
|
6
|
-
for (const
|
|
1
|
+
import { iconToImage as z } from "./fonts.js";
|
|
2
|
+
import { getStyleKey as V } from "../utils/cssTools.js";
|
|
3
|
+
import { getStyle as U, snapshotComputedStyle as I, parseContent as W, extractURL as j, fetchImage as A, safeEncodeURI as D, splitBackgroundImage as L, inlineSingleBackgroundEntry as $ } from "../utils/helpers.js";
|
|
4
|
+
async function R(l, i, g, F, h, w = !1) {
|
|
5
|
+
if (!(l instanceof Element) || !(i instanceof Element)) return;
|
|
6
|
+
for (const n of ["::before", "::after", "::first-letter"])
|
|
7
7
|
try {
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
f.set(o, V);
|
|
16
|
-
const I = l && /font.*awesome|material|bootstrap|glyphicons|ionicons|remixicon|simple-line-icons|octicons|feather|typicons|weathericons/i.test(
|
|
17
|
-
l
|
|
8
|
+
const t = U(l, n);
|
|
9
|
+
if (!t || typeof t[Symbol.iterator] != "function") continue;
|
|
10
|
+
if (n === "::first-letter") {
|
|
11
|
+
const a = getComputedStyle(l);
|
|
12
|
+
if (!(t.color !== a.color || t.fontSize !== a.fontSize || t.fontWeight !== a.fontWeight)) continue;
|
|
13
|
+
const d = Array.from(i.childNodes).find(
|
|
14
|
+
(e) => e.nodeType === Node.TEXT_NODE && e.textContent && e.textContent.trim().length > 0
|
|
18
15
|
);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
if (!d) continue;
|
|
17
|
+
const p = d.textContent, f = p.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u)?.[0], b = p.slice(f?.length || 0);
|
|
18
|
+
if (!f || /[\uD800-\uDFFF]/.test(f)) continue;
|
|
19
|
+
const r = document.createElement("span");
|
|
20
|
+
r.textContent = f, r.dataset.snapdomPseudo = "::first-letter";
|
|
21
|
+
const s = I(t), N = V(s, "span", h);
|
|
22
|
+
g.set(r, N);
|
|
23
|
+
const x = document.createTextNode(b);
|
|
24
|
+
i.replaceChild(x, d), i.insertBefore(r, x);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const S = t.getPropertyValue("content"), u = t.getPropertyValue("background-image"), m = t.getPropertyValue("background-color"), T = S !== "none", y = u && u !== "none", C = m && m !== "transparent" && m !== "rgba(0, 0, 0, 0)";
|
|
28
|
+
if (T || y || C) {
|
|
29
|
+
const a = t.getPropertyValue("font-family"), B = parseInt(t.getPropertyValue("font-size")) || 32, d = parseInt(t.getPropertyValue("font-weight")) || !1, p = t.getPropertyValue("color") || "#000", o = document.createElement("span");
|
|
30
|
+
o.dataset.snapdomPseudo = n;
|
|
31
|
+
const f = I(t), b = V(f, "span", h);
|
|
32
|
+
g.set(o, b);
|
|
33
|
+
const r = a && /font.*awesome|material|bootstrap|glyphicons|ionicons|remixicon|simple-line-icons|octicons|feather|typicons|weathericons|lucide/i.test(
|
|
34
|
+
a
|
|
35
|
+
), s = W(S);
|
|
36
|
+
if (!w && r && s.length === 1) {
|
|
37
|
+
const e = document.createElement("img");
|
|
38
|
+
e.src = await z(
|
|
39
|
+
s,
|
|
40
|
+
a,
|
|
41
|
+
d,
|
|
42
|
+
B,
|
|
43
|
+
p
|
|
44
|
+
), e.style = "display:block;width:100%;height:100%;object-fit:contain;", o.appendChild(e);
|
|
45
|
+
} else if (s.startsWith("url(")) {
|
|
46
|
+
const e = j(s);
|
|
47
|
+
if (e && e.trim() !== "")
|
|
32
48
|
try {
|
|
33
|
-
const c = document.createElement("img"),
|
|
34
|
-
c.src =
|
|
49
|
+
const c = document.createElement("img"), E = await A(D(e));
|
|
50
|
+
c.src = E, c.style = "display:block;width:100%;height:100%;object-fit:contain;", o.appendChild(c);
|
|
35
51
|
} catch (c) {
|
|
36
52
|
console.error(
|
|
37
|
-
`[snapdom] Error in pseudo ${
|
|
38
|
-
|
|
53
|
+
`[snapdom] Error in pseudo ${n} for`,
|
|
54
|
+
l,
|
|
39
55
|
c
|
|
40
56
|
);
|
|
41
57
|
}
|
|
42
|
-
} else
|
|
43
|
-
|
|
58
|
+
} else !r && s && s !== "none" && (o.textContent = s);
|
|
59
|
+
if (y)
|
|
60
|
+
try {
|
|
61
|
+
const e = L(u), c = await Promise.all(
|
|
62
|
+
e.map((E) => $(E))
|
|
63
|
+
);
|
|
64
|
+
o.style.backgroundImage = c.join(", ");
|
|
65
|
+
} catch (e) {
|
|
66
|
+
console.warn(
|
|
67
|
+
`[snapdom] Failed to inline background-image for ${n}`,
|
|
68
|
+
e
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
if (C && (o.style.backgroundColor = m), !(o.childNodes.length > 0 || o.textContent && o.textContent.trim() !== "" || y || C)) continue;
|
|
72
|
+
n === "::before" ? i.insertBefore(o, i.firstChild) : i.appendChild(o);
|
|
44
73
|
}
|
|
45
|
-
} catch (
|
|
46
|
-
console.warn(`[snapdom] Failed to capture ${
|
|
74
|
+
} catch (t) {
|
|
75
|
+
console.warn(`[snapdom] Failed to capture ${n} for`, l, t);
|
|
47
76
|
}
|
|
48
|
-
const
|
|
49
|
-
(
|
|
77
|
+
const P = Array.from(l.children), k = Array.from(i.children).filter(
|
|
78
|
+
(n) => !n.dataset.snapdomPseudo
|
|
50
79
|
);
|
|
51
|
-
for (let
|
|
52
|
-
await
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
80
|
+
for (let n = 0; n < Math.min(P.length, k.length); n++)
|
|
81
|
+
await R(
|
|
82
|
+
P[n],
|
|
83
|
+
k[n],
|
|
84
|
+
g,
|
|
85
|
+
F,
|
|
86
|
+
h,
|
|
87
|
+
w
|
|
59
88
|
);
|
|
60
89
|
}
|
|
61
90
|
export {
|
|
62
|
-
|
|
91
|
+
R as inlinePseudoElements
|
|
63
92
|
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { getStyleKey as
|
|
2
|
-
import { getStyle as
|
|
3
|
-
function
|
|
4
|
-
var n;
|
|
1
|
+
import { getStyleKey as y } from "../utils/cssTools.js";
|
|
2
|
+
import { getStyle as g, snapshotComputedStyle as p } from "../utils/helpers.js";
|
|
3
|
+
function r(t, n, o, e, s) {
|
|
5
4
|
if (t.tagName === "STYLE") return;
|
|
6
|
-
e.has(t) || e.set(t,
|
|
7
|
-
const
|
|
8
|
-
|
|
5
|
+
e.has(t) || e.set(t, g(t));
|
|
6
|
+
const a = e.get(t), i = p(a), l = t.tagName?.toLowerCase() || "div", m = y(i, l, s);
|
|
7
|
+
o.set(n, m);
|
|
9
8
|
}
|
|
10
9
|
export {
|
|
11
|
-
|
|
10
|
+
r as inlineAllStyles
|
|
12
11
|
};
|
|
@@ -1,19 +1,36 @@
|
|
|
1
|
-
import { imageCache as
|
|
2
|
-
function
|
|
1
|
+
import { imageCache as l, computedStyleCache as m, bgCache as u } from "../core/cache.js";
|
|
2
|
+
async function w(t, e = {}) {
|
|
3
|
+
const n = t.startsWith("url("), a = /^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(
|
|
4
|
+
t
|
|
5
|
+
);
|
|
6
|
+
if (n) {
|
|
7
|
+
const r = d(t);
|
|
8
|
+
if (!r) return t;
|
|
9
|
+
const i = g(r);
|
|
10
|
+
if (u.has(i))
|
|
11
|
+
return e.skipInline ? void 0 : `url(${u.get(i)})`;
|
|
12
|
+
{
|
|
13
|
+
const s = e.crossOrigin ? e.crossOrigin(i) : "anonymous", o = await f(i, 3e3, s);
|
|
14
|
+
return u.set(i, o), e.skipInline ? void 0 : `url(${o})`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
18
|
+
}
|
|
19
|
+
function I(t, { fast: e = !1 } = {}) {
|
|
3
20
|
if (e) return t();
|
|
4
21
|
"requestIdleCallback" in window ? requestIdleCallback(t, { timeout: 50 }) : setTimeout(t, 1);
|
|
5
22
|
}
|
|
6
|
-
function
|
|
23
|
+
function x(t, e = null) {
|
|
7
24
|
if (!(t instanceof Element))
|
|
8
25
|
return window.getComputedStyle(t, e);
|
|
9
26
|
let n = m.get(t);
|
|
10
27
|
if (n || (n = /* @__PURE__ */ new Map(), m.set(t, n)), !n.has(e)) {
|
|
11
|
-
const
|
|
12
|
-
n.set(e,
|
|
28
|
+
const a = window.getComputedStyle(t, e);
|
|
29
|
+
n.set(e, a);
|
|
13
30
|
}
|
|
14
31
|
return n.get(e);
|
|
15
32
|
}
|
|
16
|
-
function
|
|
33
|
+
function C(t) {
|
|
17
34
|
let e = t.replace(/^['"]|['"]$/g, "");
|
|
18
35
|
if (e.startsWith("\\"))
|
|
19
36
|
try {
|
|
@@ -23,11 +40,13 @@ function f(t) {
|
|
|
23
40
|
}
|
|
24
41
|
return e;
|
|
25
42
|
}
|
|
26
|
-
function
|
|
27
|
-
const e = t.
|
|
28
|
-
|
|
43
|
+
function d(t) {
|
|
44
|
+
const e = t.indexOf("url(");
|
|
45
|
+
if (e === -1) return null;
|
|
46
|
+
let n = t.slice(e + 4).trim();
|
|
47
|
+
return n.endsWith(")") && (n = n.slice(0, -1).trim()), (n.startsWith('"') && n.endsWith('"') || n.startsWith("'") && n.endsWith("'")) && (n = n.slice(1, -1)), n;
|
|
29
48
|
}
|
|
30
|
-
function
|
|
49
|
+
function S(t) {
|
|
31
50
|
return [
|
|
32
51
|
/font\s*awesome/i,
|
|
33
52
|
/material\s*icons/i,
|
|
@@ -36,37 +55,38 @@ function p(t) {
|
|
|
36
55
|
/feather/i,
|
|
37
56
|
/bootstrap\s*icons/i,
|
|
38
57
|
/remix\s*icons/i,
|
|
39
|
-
/heroicons/i
|
|
58
|
+
/heroicons/i,
|
|
59
|
+
/lucide/i
|
|
40
60
|
].some((n) => n.test(t));
|
|
41
61
|
}
|
|
42
|
-
function
|
|
43
|
-
return
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
}, e),
|
|
47
|
-
|
|
48
|
-
clearTimeout(
|
|
62
|
+
function f(t, e = 3e3, n = "anonymous") {
|
|
63
|
+
return l.has(t) ? Promise.resolve(l.get(t)) : new Promise((a, r) => {
|
|
64
|
+
const i = setTimeout(() => {
|
|
65
|
+
r(new Error("Image load timed out"));
|
|
66
|
+
}, e), s = new Image();
|
|
67
|
+
s.crossOrigin = n, s.onload = async () => {
|
|
68
|
+
clearTimeout(i);
|
|
49
69
|
try {
|
|
50
|
-
await
|
|
51
|
-
const
|
|
52
|
-
|
|
70
|
+
await s.decode();
|
|
71
|
+
const o = document.createElement("canvas");
|
|
72
|
+
o.width = s.width, o.height = s.height, o.getContext("2d").drawImage(s, 0, 0, o.width, o.height);
|
|
53
73
|
try {
|
|
54
|
-
const
|
|
55
|
-
|
|
74
|
+
const c = o.toDataURL("image/png");
|
|
75
|
+
l.set(t, c), a(c);
|
|
56
76
|
} catch {
|
|
57
|
-
|
|
77
|
+
r(new Error("CORS restrictions prevented image capture"));
|
|
58
78
|
}
|
|
59
|
-
} catch (
|
|
60
|
-
|
|
79
|
+
} catch (o) {
|
|
80
|
+
r(o);
|
|
61
81
|
}
|
|
62
|
-
},
|
|
63
|
-
clearTimeout(
|
|
64
|
-
new Error("Failed to load image: " + (
|
|
82
|
+
}, s.onerror = (o) => {
|
|
83
|
+
clearTimeout(i), r(
|
|
84
|
+
new Error("Failed to load image: " + (o.message || "Unknown error"))
|
|
65
85
|
);
|
|
66
|
-
},
|
|
86
|
+
}, s.src = t;
|
|
67
87
|
});
|
|
68
88
|
}
|
|
69
|
-
function
|
|
89
|
+
function U(t) {
|
|
70
90
|
const e = {};
|
|
71
91
|
for (let n of t)
|
|
72
92
|
e[n] = t.getPropertyValue(n);
|
|
@@ -75,13 +95,45 @@ function C(t) {
|
|
|
75
95
|
function y() {
|
|
76
96
|
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
77
97
|
}
|
|
98
|
+
function k(t) {
|
|
99
|
+
if (!t || t === "none") return "";
|
|
100
|
+
let e = t.replace(/translate[XY]?\([^)]*\)/g, "");
|
|
101
|
+
return e = e.replace(/matrix\(([^)]+)\)/g, (n, a) => {
|
|
102
|
+
const r = a.split(",").map((i) => i.trim());
|
|
103
|
+
return r.length !== 6 ? `matrix(${a})` : (r[4] = "0", r[5] = "0", `matrix(${r.join(", ")})`);
|
|
104
|
+
}), e = e.replace(/matrix3d\(([^)]+)\)/g, (n, a) => {
|
|
105
|
+
const r = a.split(",").map((i) => i.trim());
|
|
106
|
+
return r.length !== 16 ? `matrix3d(${a})` : (r[12] = "0", r[13] = "0", `matrix3d(${r.join(", ")})`);
|
|
107
|
+
}), e.trim().replace(/\s{2,}/g, " ");
|
|
108
|
+
}
|
|
109
|
+
function g(t) {
|
|
110
|
+
if (/%[0-9A-Fa-f]{2}/.test(t)) return t;
|
|
111
|
+
try {
|
|
112
|
+
return encodeURI(t);
|
|
113
|
+
} catch {
|
|
114
|
+
return t;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function E(t) {
|
|
118
|
+
const e = [];
|
|
119
|
+
let n = 0, a = 0;
|
|
120
|
+
for (let r = 0; r < t.length; r++) {
|
|
121
|
+
const i = t[r];
|
|
122
|
+
i === "(" && n++, i === ")" && n--, i === "," && n === 0 && (e.push(t.slice(a, r).trim()), a = r + 1);
|
|
123
|
+
}
|
|
124
|
+
return e.push(t.slice(a).trim()), e;
|
|
125
|
+
}
|
|
78
126
|
export {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
127
|
+
d as extractURL,
|
|
128
|
+
f as fetchImage,
|
|
129
|
+
x as getStyle,
|
|
130
|
+
I as idle,
|
|
131
|
+
w as inlineSingleBackgroundEntry,
|
|
132
|
+
S as isIconFont,
|
|
84
133
|
y as isSafari,
|
|
85
|
-
|
|
86
|
-
|
|
134
|
+
C as parseContent,
|
|
135
|
+
g as safeEncodeURI,
|
|
136
|
+
U as snapshotComputedStyle,
|
|
137
|
+
E as splitBackgroundImage,
|
|
138
|
+
k as stripTranslate
|
|
87
139
|
};
|