@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,91 +1,91 @@
|
|
|
1
1
|
import { captureDOM as v } from "../core/capture.js";
|
|
2
2
|
import { isSafari as R } from "../utils/helpers.js";
|
|
3
|
-
async function
|
|
4
|
-
const
|
|
5
|
-
return
|
|
3
|
+
async function x(e, { dpr: t = 1, scale: c = 1 }) {
|
|
4
|
+
const a = new Image();
|
|
5
|
+
return a.src = e, await a.decode(), R ? (a.width = a.width * c, a.height = a.height * c) : (a.width = a.width / c, a.height = a.height / c), a;
|
|
6
6
|
}
|
|
7
|
-
async function
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const s =
|
|
13
|
-
return s.scale(
|
|
7
|
+
async function p(e, { dpr: t = 1, scale: c = 1 } = {}) {
|
|
8
|
+
const a = new Image();
|
|
9
|
+
a.src = e, await a.decode();
|
|
10
|
+
const n = document.createElement("canvas"), o = a.width * c, g = a.height * c;
|
|
11
|
+
n.width = Math.ceil(o * t), n.height = Math.ceil(g * t);
|
|
12
|
+
const s = n.getContext("2d");
|
|
13
|
+
return s.scale(t, t), s.drawImage(a, 0, 0, o, g), n.style.width = `${o}px`, n.style.height = `${g}px`, n;
|
|
14
14
|
}
|
|
15
|
-
async function
|
|
16
|
-
const t = decodeURIComponent(
|
|
15
|
+
async function u(e) {
|
|
16
|
+
const t = decodeURIComponent(e.split(",")[1]);
|
|
17
17
|
return new Blob([t], { type: "image/svg+xml" });
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
19
|
+
async function l(e, { dpr: t = 1, scale: c = 1 }, a) {
|
|
20
|
+
const n = await p(e, { dpr: t, scale: c });
|
|
21
|
+
if (!a) return n;
|
|
22
22
|
const o = document.createElement("canvas");
|
|
23
|
-
o.width =
|
|
23
|
+
o.width = n.width, o.height = n.height;
|
|
24
24
|
const g = o.getContext("2d");
|
|
25
|
-
return g.fillStyle =
|
|
25
|
+
return g.fillStyle = a, g.fillRect(0, 0, o.width, o.height), g.drawImage(n, 0, 0), o;
|
|
26
26
|
}
|
|
27
|
-
async function d(
|
|
28
|
-
const g = await
|
|
29
|
-
return s.src = g.toDataURL(`image/${o}`,
|
|
27
|
+
async function d(e, { dpr: t = 1, scale: c = 1, backgroundColor: a = "#fff", quality: n }, o = "png") {
|
|
28
|
+
const g = await l(e, { dpr: t, scale: c }, a), s = new Image();
|
|
29
|
+
return s.src = g.toDataURL(`image/${o}`, n), await s.decode(), s.style.width = `${g.width / t}px`, s.style.height = `${g.height / t}px`, s;
|
|
30
30
|
}
|
|
31
|
-
async function
|
|
31
|
+
async function I(e, {
|
|
32
32
|
dpr: t = 1,
|
|
33
|
-
scale:
|
|
34
|
-
backgroundColor:
|
|
35
|
-
format:
|
|
33
|
+
scale: c = 1,
|
|
34
|
+
backgroundColor: a = "#fff",
|
|
35
|
+
format: n = "png",
|
|
36
36
|
filename: o = "capture"
|
|
37
37
|
} = {}) {
|
|
38
|
-
if (
|
|
39
|
-
const b = await
|
|
40
|
-
w.href =
|
|
38
|
+
if (n === "svg") {
|
|
39
|
+
const b = await u(e), h = URL.createObjectURL(b), w = document.createElement("a");
|
|
40
|
+
w.href = h, w.download = `${o}.svg`, w.click(), URL.revokeObjectURL(h);
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
const g = ["jpg", "jpeg", "webp"].includes(
|
|
43
|
+
const g = ["jpg", "jpeg", "webp"].includes(n) ? "#fff" : void 0, m = await l(e, { dpr: t, scale: c }, a ?? g), f = {
|
|
44
44
|
jpg: "image/jpeg",
|
|
45
45
|
jpeg: "image/jpeg",
|
|
46
46
|
png: "image/png",
|
|
47
47
|
webp: "image/webp"
|
|
48
|
-
}[
|
|
49
|
-
r.href = y, r.download = `${o}.${
|
|
48
|
+
}[n] || "image/png", y = m.toDataURL(f), r = document.createElement("a");
|
|
49
|
+
r.href = y, r.download = `${o}.${n}`, r.click();
|
|
50
50
|
}
|
|
51
|
-
async function i(
|
|
52
|
-
if (t = { scale: 1, ...t }, !
|
|
53
|
-
return await i.capture(
|
|
51
|
+
async function i(e, t = {}) {
|
|
52
|
+
if (t = { scale: 1, ...t }, !e) throw new Error("Element cannot be null or undefined");
|
|
53
|
+
return await i.capture(e, t);
|
|
54
54
|
}
|
|
55
|
-
i.capture = async (
|
|
56
|
-
const
|
|
55
|
+
i.capture = async (e, t = {}) => {
|
|
56
|
+
const c = await v(e, t), a = window.devicePixelRatio || 1, n = t.scale || 1;
|
|
57
57
|
return {
|
|
58
|
-
url:
|
|
58
|
+
url: c,
|
|
59
59
|
options: t,
|
|
60
|
-
toRaw: () =>
|
|
61
|
-
toImg: () =>
|
|
62
|
-
toCanvas: () =>
|
|
63
|
-
toBlob: () =>
|
|
64
|
-
toPng: (o) => d(
|
|
65
|
-
toJpg: (o) => d(
|
|
66
|
-
toWebp: (o) => d(
|
|
60
|
+
toRaw: () => c,
|
|
61
|
+
toImg: () => x(c, { dpr: a, scale: n }),
|
|
62
|
+
toCanvas: () => p(c, { dpr: a, scale: n }),
|
|
63
|
+
toBlob: () => u(c),
|
|
64
|
+
toPng: (o) => d(c, { dpr: a, scale: n, ...o }, "png"),
|
|
65
|
+
toJpg: (o) => d(c, { dpr: a, scale: n, ...o }, "jpeg"),
|
|
66
|
+
toWebp: (o) => d(c, { dpr: a, scale: n, ...o }, "webp"),
|
|
67
67
|
download: ({
|
|
68
68
|
format: o = "png",
|
|
69
69
|
filename: g = "capture",
|
|
70
70
|
backgroundColor: s
|
|
71
|
-
} = {}) =>
|
|
71
|
+
} = {}) => I(c, { dpr: a, scale: n, backgroundColor: s, format: o, filename: g })
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
|
-
i.toRaw = async (
|
|
75
|
-
i.toImg = async (
|
|
76
|
-
i.toCanvas = async (
|
|
77
|
-
i.toBlob = async (
|
|
78
|
-
i.toPng = async (
|
|
79
|
-
i.toJpg = async (
|
|
80
|
-
i.toWebp = async (
|
|
81
|
-
i.download = async (
|
|
74
|
+
i.toRaw = async (e, t) => (await i.capture(e, t)).toRaw();
|
|
75
|
+
i.toImg = async (e, t) => (await i.capture(e, t)).toImg();
|
|
76
|
+
i.toCanvas = async (e, t) => (await i.capture(e, t)).toCanvas();
|
|
77
|
+
i.toBlob = async (e, t) => (await i.capture(e, t)).toBlob();
|
|
78
|
+
i.toPng = async (e, t) => (await i.capture(e, t)).toPng(t);
|
|
79
|
+
i.toJpg = async (e, t) => (await i.capture(e, t)).toJpg(t);
|
|
80
|
+
i.toWebp = async (e, t) => (await i.capture(e, t)).toWebp(t);
|
|
81
|
+
i.download = async (e, t = {}) => {
|
|
82
82
|
const {
|
|
83
|
-
format:
|
|
84
|
-
filename:
|
|
85
|
-
backgroundColor:
|
|
83
|
+
format: c = "png",
|
|
84
|
+
filename: a = "capture",
|
|
85
|
+
backgroundColor: n,
|
|
86
86
|
...o
|
|
87
87
|
} = t;
|
|
88
|
-
return await (await i.capture(
|
|
88
|
+
return await (await i.capture(e, o)).download({ format: c, filename: a, backgroundColor: n });
|
|
89
89
|
};
|
|
90
90
|
export {
|
|
91
91
|
i as snapdom
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
const e = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(),
|
|
1
|
+
const e = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new Set();
|
|
2
2
|
export {
|
|
3
3
|
t as baseCSSCache,
|
|
4
4
|
a as bgCache,
|
|
5
|
-
|
|
5
|
+
s as computedStyleCache,
|
|
6
6
|
n as defaultStylesCache,
|
|
7
7
|
e as imageCache,
|
|
8
|
+
o as processedFontURLs,
|
|
8
9
|
c as resourceCache
|
|
9
10
|
};
|
|
@@ -1,73 +1,84 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { prepareClone as
|
|
8
|
-
async function
|
|
9
|
-
if (!
|
|
1
|
+
import { baseCSSCache as S } from "./cache.js";
|
|
2
|
+
import { inlineBackgroundImages as P } from "../modules/background.js";
|
|
3
|
+
import { embedCustomFonts as z } from "../modules/fonts.js";
|
|
4
|
+
import { inlineImages as H } from "../modules/images.js";
|
|
5
|
+
import { collectUsedTagNames as A, generateDedupedBaseCSS as D } from "../utils/cssTools.js";
|
|
6
|
+
import { idle as l, isSafari as R } from "../utils/helpers.js";
|
|
7
|
+
import { prepareClone as U } from "./prepare.js";
|
|
8
|
+
async function Q(r, n = {}) {
|
|
9
|
+
if (!r) throw new Error("Element cannot be null or undefined");
|
|
10
|
+
if (!(r instanceof Element))
|
|
11
|
+
throw new Error("captureDOM: Only Element nodes are supported");
|
|
10
12
|
const {
|
|
11
|
-
compress:
|
|
12
|
-
embedFonts:
|
|
13
|
-
fast:
|
|
14
|
-
scale:
|
|
15
|
-
} =
|
|
16
|
-
let t,
|
|
17
|
-
if ({ clone: t, classCSS:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
), await new Promise((
|
|
22
|
-
|
|
13
|
+
compress: b = !0,
|
|
14
|
+
embedFonts: h = !1,
|
|
15
|
+
fast: o = !0,
|
|
16
|
+
scale: f = 1
|
|
17
|
+
} = n;
|
|
18
|
+
let t, y, v, C = "", m = "", $, x;
|
|
19
|
+
if ({ clone: t, classCSS: y, styleCache: v } = await U(
|
|
20
|
+
r,
|
|
21
|
+
b,
|
|
22
|
+
h
|
|
23
|
+
), await new Promise((s) => {
|
|
24
|
+
l(
|
|
23
25
|
async () => {
|
|
24
|
-
await
|
|
26
|
+
await H(t, n), s();
|
|
25
27
|
},
|
|
26
|
-
{ fast:
|
|
28
|
+
{ fast: o }
|
|
27
29
|
);
|
|
28
|
-
}), await new Promise((
|
|
29
|
-
|
|
30
|
+
}), await new Promise((s) => {
|
|
31
|
+
l(
|
|
30
32
|
async () => {
|
|
31
|
-
await
|
|
33
|
+
await P(r, t, v, n), s();
|
|
32
34
|
},
|
|
33
|
-
{ fast:
|
|
35
|
+
{ fast: o }
|
|
34
36
|
);
|
|
35
|
-
}),
|
|
36
|
-
|
|
37
|
+
}), h && await new Promise((s) => {
|
|
38
|
+
l(
|
|
37
39
|
async () => {
|
|
38
|
-
|
|
40
|
+
C = await z({ ignoreIconFonts: !h }), s();
|
|
39
41
|
},
|
|
40
|
-
{ fast:
|
|
42
|
+
{ fast: o }
|
|
41
43
|
);
|
|
42
|
-
}),
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
}), b) {
|
|
45
|
+
const s = A(t).sort(), i = s.join(",");
|
|
46
|
+
S.has(i) ? m = S.get(i) : await new Promise((e) => {
|
|
47
|
+
l(
|
|
46
48
|
() => {
|
|
47
|
-
|
|
49
|
+
m = D(s), S.set(i, m), e();
|
|
48
50
|
},
|
|
49
|
-
{ fast:
|
|
51
|
+
{ fast: o }
|
|
50
52
|
);
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
|
-
await new Promise((
|
|
54
|
-
|
|
55
|
+
await new Promise((s) => {
|
|
56
|
+
l(
|
|
55
57
|
() => {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
const i = r.getBoundingClientRect();
|
|
59
|
+
let e = i.width, a = i.height;
|
|
60
|
+
const d = Number.isFinite(n.width), u = Number.isFinite(n.height), p = typeof f == "number" && f !== 1;
|
|
61
|
+
if (!p) {
|
|
62
|
+
const g = i.width / i.height;
|
|
63
|
+
d && u ? (e = n.width, a = n.height) : d ? (e = n.width, a = e / g) : u && (a = n.height, e = a * g);
|
|
64
|
+
}
|
|
65
|
+
if (e = Math.ceil(e), a = Math.ceil(a), t.setAttribute("xmlns", "http://www.w3.org/1999/xhtml"), t.style.transformOrigin = "top left", !p && (d || u)) {
|
|
66
|
+
const g = i.width, B = i.height, I = e / g, M = a / B, N = t.style.transform || "", O = `scale(${I}, ${M})`;
|
|
67
|
+
t.style.transform = `${O} ${N}`.trim();
|
|
68
|
+
} else p && R() && (t.style.scale = `${f}`);
|
|
69
|
+
const E = "http://www.w3.org/2000/svg", c = document.createElementNS(E, "foreignObject");
|
|
70
|
+
c.setAttribute("width", "100%"), c.setAttribute("height", "100%");
|
|
71
|
+
const F = document.createElement("style");
|
|
72
|
+
F.textContent = m + C + "svg{overflow:visible;}" + y, c.appendChild(F), c.appendChild(t);
|
|
73
|
+
const T = new XMLSerializer().serializeToString(c);
|
|
74
|
+
x = `<svg xmlns="${E}" width="${e}" height="${a}" viewBox="0 0 ${e} ${a}">` + T + "</svg>", $ = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(x)}`, s();
|
|
64
75
|
},
|
|
65
|
-
{ fast:
|
|
76
|
+
{ fast: o }
|
|
66
77
|
);
|
|
67
78
|
});
|
|
68
|
-
const
|
|
69
|
-
return
|
|
79
|
+
const w = document.getElementById("snapdom-sandbox");
|
|
80
|
+
return w && w.style.position === "absolute" && w.remove(), $;
|
|
70
81
|
}
|
|
71
82
|
export {
|
|
72
|
-
|
|
83
|
+
Q as captureDOM
|
|
73
84
|
};
|
|
@@ -1,49 +1,50 @@
|
|
|
1
|
-
import { inlineAllStyles as
|
|
2
|
-
function f(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return i.style.cssText = `display: inline-block; width: ${e.width}px; height: ${e.height}px; visibility: hidden;`, i;
|
|
1
|
+
import { inlineAllStyles as o } from "../modules/styles.js";
|
|
2
|
+
function f(e, c, r, n, s) {
|
|
3
|
+
if (e.nodeType === Node.ELEMENT_NODE && e.getAttribute("data-capture") === "exclude") {
|
|
4
|
+
const t = document.createElement("div"), i = e.getBoundingClientRect();
|
|
5
|
+
return t.style.cssText = `display: inline-block; width: ${i.width}px; height: ${i.height}px; visibility: hidden;`, t;
|
|
7
6
|
}
|
|
8
|
-
if (
|
|
9
|
-
const
|
|
10
|
-
return
|
|
7
|
+
if (e.tagName === "IFRAME") {
|
|
8
|
+
const t = document.createElement("div");
|
|
9
|
+
return t.textContent = "", t.style.cssText = `width: ${e.offsetWidth}px; height: ${e.offsetHeight}px; background-image: repeating-linear-gradient(45deg, #ddd, #ddd 5px, #f9f9f9 5px, #f9f9f9 10px);display: flex;align-items: center;justify-content: center;font-size: 12px;color: #555; border: 1px solid #aaa;`, t;
|
|
11
10
|
}
|
|
12
|
-
if (
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
return
|
|
11
|
+
if (e.nodeType === Node.ELEMENT_NODE && e.getAttribute("data-capture") === "placeholder") {
|
|
12
|
+
const t = e.cloneNode(!1);
|
|
13
|
+
n.set(t, e), o(e, t, c, r, s);
|
|
14
|
+
const i = document.createElement("div");
|
|
15
|
+
return i.textContent = e.getAttribute("data-placeholder-text") || "", i.style.cssText = "color: #666;font-size: 12px;text-align: center;line-height: 1.4;padding: 0.5em;box-sizing: border-box;", t.appendChild(i), t;
|
|
17
16
|
}
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
return
|
|
17
|
+
if (e.tagName === "CANVAS") {
|
|
18
|
+
const t = e.toDataURL(), i = document.createElement("img");
|
|
19
|
+
return i.src = t, i.width = e.width, i.height = e.height, i.style.display = "inline-block", i.style.width = e.style.width || `${e.width}px`, i.style.height = e.style.height || `${e.height}px`, i;
|
|
21
20
|
}
|
|
22
|
-
if (
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
25
|
-
if (customElements.get(
|
|
21
|
+
if (e.nodeType === Node.TEXT_NODE) {
|
|
22
|
+
if (e.parentElement?.shadowRoot) {
|
|
23
|
+
const t = e.parentElement.tagName.toLowerCase();
|
|
24
|
+
if (customElements.get(t)) return null;
|
|
26
25
|
}
|
|
27
|
-
return
|
|
26
|
+
return e.cloneNode(!0);
|
|
28
27
|
}
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
if (e.nodeType !== Node.ELEMENT_NODE) return e.cloneNode(!0);
|
|
29
|
+
const l = e.cloneNode(!1);
|
|
30
|
+
n.set(l, e), e instanceof HTMLInputElement ? (l.value = e.value, l.setAttribute("value", e.value), e.checked !== void 0 && (l.checked = e.checked, e.checked && l.setAttribute("checked", ""))) : e instanceof HTMLTextAreaElement ? (l.value = e.value, l.textContent = e.value) : e instanceof HTMLSelectElement && (l.value = e.value, Array.from(l.options).forEach((t) => {
|
|
31
|
+
t.value === e.value ? t.setAttribute("selected", "") : t.removeAttribute("selected");
|
|
32
|
+
})), o(e, l, c, r, s);
|
|
33
|
+
const h = document.createDocumentFragment();
|
|
34
|
+
if (e.childNodes.forEach((t) => {
|
|
35
|
+
const i = f(
|
|
36
|
+
t,
|
|
38
37
|
c,
|
|
39
|
-
|
|
38
|
+
r,
|
|
39
|
+
n,
|
|
40
|
+
s
|
|
40
41
|
);
|
|
41
|
-
|
|
42
|
-
}),
|
|
43
|
-
const
|
|
44
|
-
|
|
42
|
+
i && h.appendChild(i);
|
|
43
|
+
}), l.appendChild(h), e.shadowRoot) {
|
|
44
|
+
const t = Array.from(e.shadowRoot.children).filter((a) => a.tagName !== "STYLE").map((a) => f(a, c, r, n)).filter(Boolean), i = document.createDocumentFragment();
|
|
45
|
+
t.forEach((a) => i.appendChild(a)), l.appendChild(i);
|
|
45
46
|
}
|
|
46
|
-
return
|
|
47
|
+
return l;
|
|
47
48
|
}
|
|
48
49
|
export {
|
|
49
50
|
f as deepClone
|
|
@@ -1,53 +1,59 @@
|
|
|
1
|
-
import { inlinePseudoElements as
|
|
1
|
+
import { inlinePseudoElements as m } from "../modules/pseudo.js";
|
|
2
2
|
import { generateCSSClasses as g } from "../utils/cssTools.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
let
|
|
3
|
+
import { stripTranslate as u } from "../utils/helpers.js";
|
|
4
|
+
import { deepClone as h } from "./clone.js";
|
|
5
|
+
async function k(s, f = !1, p = !1) {
|
|
6
|
+
const a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new Map();
|
|
7
|
+
let t;
|
|
8
8
|
try {
|
|
9
|
-
|
|
9
|
+
t = h(s, a, r, y, f);
|
|
10
10
|
} catch (e) {
|
|
11
11
|
throw console.warn("deepClone failed:", e), e;
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
|
-
await
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
i,
|
|
14
|
+
await m(
|
|
15
|
+
s,
|
|
16
|
+
t,
|
|
17
|
+
a,
|
|
19
18
|
r,
|
|
20
|
-
|
|
19
|
+
f,
|
|
20
|
+
p
|
|
21
21
|
);
|
|
22
22
|
} catch (e) {
|
|
23
23
|
console.warn("inlinePseudoElements failed:", e);
|
|
24
24
|
}
|
|
25
|
-
let
|
|
26
|
-
if (
|
|
27
|
-
const e = g(
|
|
28
|
-
|
|
29
|
-
for (const [
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
25
|
+
let d = "";
|
|
26
|
+
if (f) {
|
|
27
|
+
const e = g(a);
|
|
28
|
+
d = Array.from(e.entries()).map(([o, n]) => `.${n}{${o}}`).join("");
|
|
29
|
+
for (const [o, n] of a.entries()) {
|
|
30
|
+
if (o.tagName === "STYLE") continue;
|
|
31
|
+
const i = e.get(n);
|
|
32
|
+
i && o.classList.add(i);
|
|
33
|
+
const c = o.style?.backgroundImage;
|
|
34
|
+
o.removeAttribute("style"), c && c !== "none" && (o.style.backgroundImage = c);
|
|
35
35
|
}
|
|
36
36
|
} else
|
|
37
|
-
for (const [e,
|
|
38
|
-
e.tagName !== "STYLE" && e.setAttribute("style",
|
|
39
|
-
for (const [e,
|
|
40
|
-
const n =
|
|
41
|
-
if ((n ||
|
|
37
|
+
for (const [e, o] of a.entries())
|
|
38
|
+
e.tagName !== "STYLE" && e.setAttribute("style", o.replace(/;/g, "; "));
|
|
39
|
+
for (const [e, o] of y.entries()) {
|
|
40
|
+
const n = o.scrollLeft, i = o.scrollTop;
|
|
41
|
+
if ((n || i) && e instanceof HTMLElement) {
|
|
42
42
|
e.style.overflow = "hidden", e.style.scrollbarWidth = "none", e.style.msOverflowStyle = "none";
|
|
43
|
-
const
|
|
44
|
-
for (
|
|
45
|
-
|
|
46
|
-
e.appendChild(
|
|
43
|
+
const l = document.createElement("div");
|
|
44
|
+
for (l.style.transform = `translate(${-n}px, ${-i}px)`, l.style.willChange = "transform", l.style.display = "inline-block", l.style.width = "100%"; e.firstChild; )
|
|
45
|
+
l.appendChild(e.firstChild);
|
|
46
|
+
e.appendChild(l);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
if (s === y.get(t)) {
|
|
50
|
+
const e = r.get(s) || window.getComputedStyle(s);
|
|
51
|
+
r.set(s, e);
|
|
52
|
+
const o = u(e.transform);
|
|
53
|
+
t.style.margin = "0", t.style.position = "static", t.style.top = "auto", t.style.left = "auto", t.style.right = "auto", t.style.bottom = "auto", t.style.zIndex = "auto", t.style.float = "none", t.style.clear = "none", t.style.transform = o || "";
|
|
54
|
+
}
|
|
55
|
+
return { clone: t, classCSS: d, styleCache: r };
|
|
50
56
|
}
|
|
51
57
|
export {
|
|
52
|
-
|
|
58
|
+
k as prepareClone
|
|
53
59
|
};
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const n = e[1];
|
|
14
|
-
let r;
|
|
15
|
-
a.has(n) ? r = a.get(n) : (r = await m(n), a.set(n, r)), l.style.backgroundImage = `url(${r})`;
|
|
16
|
-
} catch {
|
|
17
|
-
l.style.backgroundImage = "none";
|
|
18
|
-
}
|
|
1
|
+
import { getStyle as b, splitBackgroundImage as p, inlineSingleBackgroundEntry as k } from "../utils/helpers.js";
|
|
2
|
+
async function B(u, m, l, f = {}) {
|
|
3
|
+
const r = [[u, m]];
|
|
4
|
+
for (; r.length; ) {
|
|
5
|
+
const [e, o] = r.shift(), s = l.get(e) || b(e);
|
|
6
|
+
l.has(e) || l.set(e, s);
|
|
7
|
+
const c = s.getPropertyValue("background-image"), t = s.getPropertyValue("background-color");
|
|
8
|
+
if (!c || c === "none") {
|
|
9
|
+
const n = Array.from(e.children), h = Array.from(o.children);
|
|
10
|
+
for (let i = 0; i < Math.min(n.length, h.length); i++)
|
|
11
|
+
r.push([n[i], h[i]]);
|
|
12
|
+
continue;
|
|
19
13
|
}
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
const y = p(c), a = await Promise.all(
|
|
15
|
+
y.map((n) => k(n, f))
|
|
16
|
+
);
|
|
17
|
+
a.some((n) => n && n !== "none" && !/^url\(undefined\)/.test(n)) && (o.style.backgroundImage = a.join(", ")), t && t !== "transparent" && t !== "rgba(0, 0, 0, 0)" && (o.style.backgroundColor = t);
|
|
18
|
+
const g = Array.from(e.children), d = Array.from(o.children);
|
|
19
|
+
for (let n = 0; n < Math.min(g.length, d.length); n++)
|
|
20
|
+
r.push([g[n], d[n]]);
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
export {
|
|
26
|
-
|
|
24
|
+
B as inlineBackgroundImages
|
|
27
25
|
};
|