@unicom-cloud/utils 0.1.16 → 0.1.18
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/class-name/index.js +5 -5
- package/constant/index.js +24 -2
- package/constant/platform.js +13 -12
- package/constant.js +24 -2
- package/content-disposition/index.js +3 -3
- package/date/convertTime.js +4 -4
- package/diff/index.js +7 -0
- package/diff/src/diff.d.ts +21 -0
- package/diff/src/diff.js +381 -0
- package/diff.js +7 -0
- package/filesize/types/constants.d.ts +81 -0
- package/filesize/types/filesize.d.ts +97 -0
- package/index.js +68 -58
- package/js-cookie/index.d.ts +116 -0
- package/js-cookie/index.js +4 -0
- package/js-cookie/src/api.js +56 -0
- package/js-cookie/src/assign.js +11 -0
- package/js-cookie/src/converter.js +14 -0
- package/jsCookie.js +4 -0
- package/lunar/lib/HolidayUtil.js +48 -49
- package/mitt/index.js +4 -0
- package/mitt/src/index.js +37 -0
- package/mitt.js +4 -0
- package/nzh/nzh.d.ts +74 -0
- package/package.json +1 -1
- package/pinyin/index.js +4 -0
- package/pinyin/simplified.js +4 -0
- package/pinyin/src/core.js +143 -0
- package/pinyin/src/simplified.js +8 -0
- package/pinyin/src/simplified_dict.js +410 -0
- package/pinyin/src/traditional.js +8 -0
- package/pinyin/src/traditional_dict.js +403 -0
- package/pinyin/traditional.js +4 -0
- package/pinyin.js +4 -0
- package/query-string/base.d.ts +717 -0
- package/query-string/base.js +268 -0
- package/query-string/index.d.ts +16 -0
- package/query-string/index.js +4 -0
- package/query-string/splitOnFirst.js +14 -0
- package/queryString.js +4 -0
- package/random/index.js +56 -35
- package/snapdom/src/api/preCache.js +51 -28
- package/snapdom/src/core/cache.js +1 -4
- package/snapdom/src/core/capture.js +45 -44
- package/snapdom/src/core/clone.js +82 -66
- package/snapdom/src/core/prepare.js +167 -45
- package/snapdom/src/modules/background.js +29 -19
- package/snapdom/src/modules/fonts.js +158 -111
- package/snapdom/src/modules/images.js +14 -9
- package/snapdom/src/modules/pseudo.js +52 -47
- package/snapdom/src/modules/styles.js +22 -22
- package/snapdom/src/modules/svgDefs.js +39 -20
- package/snapdom/src/utils/cssTools.js +58 -51
- package/snapdom/src/utils/helpers.js +197 -140
- package/snapdom/types/snapdom.d.ts +101 -0
- package/types/constant/index.d.ts +11 -0
- package/types/constant/platform.d.ts +1 -0
- package/types/diff/index.d.ts +2 -0
- package/types/diff/src/diff.d.ts +40 -0
- package/types/index.d.ts +6 -1
- package/types/js-cookie/index.d.ts +1 -0
- package/types/js-cookie/src/api.d.mts +2 -0
- package/types/js-cookie/src/assign.d.mts +1 -0
- package/types/js-cookie/src/converter.d.mts +5 -0
- package/types/mitt/index.d.ts +2 -0
- package/types/mitt/src/index.d.ts +29 -0
- package/types/pinyin/index.d.ts +1 -0
- package/types/pinyin/simplified.d.ts +1 -0
- package/types/pinyin/src/core.d.ts +3 -0
- package/types/pinyin/src/simplified.d.ts +4 -0
- package/types/pinyin/src/simplified_dict.d.ts +408 -0
- package/types/pinyin/src/traditional.d.ts +4 -0
- package/types/pinyin/src/traditional_dict.d.ts +401 -0
- package/types/pinyin/traditional.d.ts +1 -0
- package/types/query-string/base.d.ts +11 -0
- package/types/query-string/index.d.ts +2 -0
- package/types/query-string/splitOnFirst.d.ts +1 -0
- package/types/random/index.d.ts +14 -23
- package/types/snapdom/src/api/preCache.d.ts +2 -5
- package/types/snapdom/src/core/cache.d.ts +0 -3
- package/types/snapdom/src/core/clone.d.ts +1 -1
- package/types/snapdom/src/modules/background.d.ts +16 -6
- package/types/snapdom/src/modules/fonts.d.ts +5 -1
- package/types/snapdom/src/modules/pseudo.d.ts +1 -1
- package/types/snapdom/src/modules/styles.d.ts +1 -1
- package/types/snapdom/src/modules/svgDefs.d.ts +13 -13
- package/types/snapdom/src/utils/cssTools.d.ts +2 -10
- package/types/snapdom/src/utils/helpers.d.ts +13 -7
- package/types/turbo-stream/src/shared.d.ts +3 -3
- package/url-toolkit/src/url-toolkit.d.ts +22 -0
- package/event-emitter/index.js +0 -48
- package/eventEmitter.js +0 -4
- package/types/event-emitter/index.d.ts +0 -17
|
@@ -1,114 +1,130 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { inlineAllStyles as g } from "../modules/styles.js";
|
|
2
|
+
function p(t, n) {
|
|
3
|
+
try {
|
|
4
|
+
const l = t.currentSrc || t.src || "";
|
|
5
|
+
if (!l) return;
|
|
6
|
+
n.setAttribute("src", l), n.removeAttribute("srcset"), n.removeAttribute("sizes"), n.loading = "eager", n.decoding = "sync";
|
|
7
|
+
} catch {
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function m(t, n, l, o, s, a = {}, h) {
|
|
11
|
+
if (!t) throw new Error("Invalid node");
|
|
12
|
+
const x = /* @__PURE__ */ new Set();
|
|
6
13
|
let d = null;
|
|
7
|
-
if (
|
|
8
|
-
return
|
|
9
|
-
if (
|
|
10
|
-
const
|
|
11
|
-
return
|
|
14
|
+
if (t.nodeType === Node.TEXT_NODE || t.nodeType !== Node.ELEMENT_NODE)
|
|
15
|
+
return t.cloneNode(!0);
|
|
16
|
+
if (t.getAttribute("data-capture") === "exclude") {
|
|
17
|
+
const e = document.createElement("div"), i = t.getBoundingClientRect();
|
|
18
|
+
return e.style.cssText = `display:inline-block;width:${i.width}px;height:${i.height}px;visibility:hidden;`, e;
|
|
12
19
|
}
|
|
13
20
|
if (a.exclude && Array.isArray(a.exclude))
|
|
14
|
-
for (const
|
|
21
|
+
for (const e of a.exclude)
|
|
15
22
|
try {
|
|
16
|
-
if (
|
|
17
|
-
const i = document.createElement("div"),
|
|
18
|
-
return i.style.cssText = `display:inline-block;width:${
|
|
23
|
+
if (t.matches?.(e)) {
|
|
24
|
+
const i = document.createElement("div"), r = t.getBoundingClientRect();
|
|
25
|
+
return i.style.cssText = `display:inline-block;width:${r.width}px;height:${r.height}px;visibility:hidden;`, i;
|
|
19
26
|
}
|
|
20
27
|
} catch (i) {
|
|
21
|
-
console.warn(`Invalid selector in exclude option: ${
|
|
28
|
+
console.warn(`Invalid selector in exclude option: ${e}`, i);
|
|
22
29
|
}
|
|
23
30
|
if (typeof a.filter == "function")
|
|
24
31
|
try {
|
|
25
|
-
if (!a.filter(
|
|
26
|
-
const
|
|
27
|
-
return
|
|
32
|
+
if (!a.filter(t, h || t)) {
|
|
33
|
+
const e = document.createElement("div"), i = t.getBoundingClientRect();
|
|
34
|
+
return e.style.cssText = `display:inline-block;width:${i.width}px;height:${i.height}px;visibility:hidden;`, e;
|
|
28
35
|
}
|
|
29
|
-
} catch (
|
|
30
|
-
console.warn("Error in filter function:",
|
|
36
|
+
} catch (e) {
|
|
37
|
+
console.warn("Error in filter function:", e);
|
|
31
38
|
}
|
|
32
|
-
if (
|
|
33
|
-
const
|
|
34
|
-
return
|
|
39
|
+
if (t.tagName === "IFRAME") {
|
|
40
|
+
const e = document.createElement("div");
|
|
41
|
+
return e.style.cssText = `width:${t.offsetWidth}px;height:${t.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;`, e;
|
|
35
42
|
}
|
|
36
|
-
if (
|
|
37
|
-
const
|
|
38
|
-
|
|
43
|
+
if (t.getAttribute("data-capture") === "placeholder") {
|
|
44
|
+
const e = t.cloneNode(!1);
|
|
45
|
+
o.set(e, t), g(t, e, n, l, s);
|
|
39
46
|
const i = document.createElement("div");
|
|
40
|
-
return i.textContent =
|
|
47
|
+
return i.textContent = t.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;", e.appendChild(i), e;
|
|
41
48
|
}
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
return i.src =
|
|
49
|
+
if (t.tagName === "CANVAS") {
|
|
50
|
+
const e = t.toDataURL(), i = document.createElement("img");
|
|
51
|
+
return i.src = e, i.width = t.width, i.height = t.height, o.set(i, t), g(t, i, n, l, s), i;
|
|
45
52
|
}
|
|
46
53
|
let c;
|
|
47
54
|
try {
|
|
48
|
-
c =
|
|
49
|
-
} catch (
|
|
50
|
-
throw console.error("[Snapdom] Failed to clone node:",
|
|
55
|
+
c = t.cloneNode(!1), o.set(c, t), t.tagName === "IMG" && p(t, c);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
throw console.error("[Snapdom] Failed to clone node:", t, e), e;
|
|
51
58
|
}
|
|
52
|
-
if (
|
|
53
|
-
c.textContent =
|
|
54
|
-
const
|
|
55
|
-
return c.style.width = `${
|
|
59
|
+
if (t instanceof HTMLTextAreaElement) {
|
|
60
|
+
c.textContent = t.value, c.value = t.value;
|
|
61
|
+
const e = t.getBoundingClientRect();
|
|
62
|
+
return c.style.width = `${e.width}px`, c.style.height = `${e.height}px`, c;
|
|
56
63
|
}
|
|
57
|
-
if (
|
|
58
|
-
if (Array.from(
|
|
59
|
-
for (const i of
|
|
64
|
+
if (t instanceof HTMLInputElement && (c.value = t.value, c.setAttribute("value", t.value), t.checked !== void 0 && (c.checked = t.checked, t.checked && c.setAttribute("checked", ""), t.indeterminate && (c.indeterminate = t.indeterminate))), t instanceof HTMLSelectElement && (d = t.value), g(t, c, n, l, s), t.shadowRoot)
|
|
65
|
+
if (Array.from(t.shadowRoot.querySelectorAll("slot")).length > 0) {
|
|
66
|
+
for (const i of t.shadowRoot.childNodes)
|
|
60
67
|
if (i.nodeType === Node.ELEMENT_NODE && i.tagName === "STYLE") {
|
|
61
|
-
const
|
|
62
|
-
|
|
68
|
+
const r = i.textContent || "";
|
|
69
|
+
r.trim() && s && l.set(i, r);
|
|
63
70
|
}
|
|
64
71
|
} else {
|
|
65
72
|
const i = document.createDocumentFragment();
|
|
66
|
-
for (const
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
|
|
73
|
+
for (const r of t.shadowRoot.childNodes) {
|
|
74
|
+
if (r.nodeType === Node.ELEMENT_NODE && r.tagName === "STYLE") {
|
|
75
|
+
const f = r.textContent || "";
|
|
76
|
+
f.trim() && s && l.set(r, f);
|
|
70
77
|
continue;
|
|
71
78
|
}
|
|
72
|
-
const
|
|
73
|
-
|
|
79
|
+
const u = m(
|
|
80
|
+
r,
|
|
74
81
|
n,
|
|
82
|
+
l,
|
|
83
|
+
o,
|
|
84
|
+
s,
|
|
75
85
|
a,
|
|
76
|
-
|
|
86
|
+
h || t
|
|
77
87
|
);
|
|
78
|
-
|
|
88
|
+
u && i.appendChild(u);
|
|
79
89
|
}
|
|
80
90
|
c.appendChild(i);
|
|
81
91
|
}
|
|
82
|
-
if (
|
|
83
|
-
const
|
|
84
|
-
for (const
|
|
85
|
-
const
|
|
86
|
-
|
|
92
|
+
if (t.tagName === "SLOT") {
|
|
93
|
+
const e = t.assignedNodes?.({ flatten: !0 }) || [], i = e.length > 0 ? e : Array.from(t.childNodes), r = document.createDocumentFragment();
|
|
94
|
+
for (const u of i) {
|
|
95
|
+
const f = m(
|
|
96
|
+
u,
|
|
87
97
|
n,
|
|
98
|
+
l,
|
|
99
|
+
o,
|
|
100
|
+
s,
|
|
88
101
|
a,
|
|
89
|
-
|
|
102
|
+
h || t
|
|
90
103
|
);
|
|
91
|
-
|
|
104
|
+
f && r.appendChild(f);
|
|
92
105
|
}
|
|
93
|
-
return
|
|
106
|
+
return r;
|
|
94
107
|
}
|
|
95
|
-
for (const
|
|
96
|
-
if (
|
|
97
|
-
const i =
|
|
98
|
-
|
|
108
|
+
for (const e of t.childNodes) {
|
|
109
|
+
if (x.has(e)) continue;
|
|
110
|
+
const i = m(
|
|
111
|
+
e,
|
|
99
112
|
n,
|
|
113
|
+
l,
|
|
114
|
+
o,
|
|
115
|
+
s,
|
|
100
116
|
a,
|
|
101
|
-
|
|
117
|
+
h || t
|
|
102
118
|
);
|
|
103
119
|
i && c.appendChild(i);
|
|
104
120
|
}
|
|
105
121
|
if (d !== null && c instanceof HTMLSelectElement) {
|
|
106
122
|
c.value = d;
|
|
107
|
-
for (const
|
|
108
|
-
|
|
123
|
+
for (const e of c.options)
|
|
124
|
+
e.value === d ? e.setAttribute("selected", "") : e.removeAttribute("selected");
|
|
109
125
|
}
|
|
110
126
|
return c;
|
|
111
127
|
}
|
|
112
128
|
export {
|
|
113
|
-
|
|
129
|
+
m as deepClone
|
|
114
130
|
};
|
|
@@ -1,65 +1,187 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let o,
|
|
1
|
+
import { inlinePseudoElements as w } from "../modules/pseudo.js";
|
|
2
|
+
import { inlineExternalDefsAndSymbols as S } from "../modules/svgDefs.js";
|
|
3
|
+
import { generateCSSClasses as A } from "../utils/cssTools.js";
|
|
4
|
+
import { stripTranslate as C } from "../utils/helpers.js";
|
|
5
|
+
import { deepClone as N } from "./clone.js";
|
|
6
|
+
async function x(t, n = !1, l = !1, a = {}) {
|
|
7
|
+
const i = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new Map();
|
|
8
|
+
let o, c = "";
|
|
9
|
+
E(t);
|
|
9
10
|
try {
|
|
10
|
-
|
|
11
|
+
S(t);
|
|
11
12
|
} catch (e) {
|
|
12
|
-
|
|
13
|
+
console.warn("inlineExternal defs or symbol failed:", e);
|
|
13
14
|
}
|
|
14
15
|
try {
|
|
15
|
-
|
|
16
|
+
o = N(
|
|
17
|
+
t,
|
|
18
|
+
i,
|
|
19
|
+
f,
|
|
20
|
+
r,
|
|
16
21
|
n,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
y,
|
|
20
|
-
f.useProxy
|
|
22
|
+
a,
|
|
23
|
+
t
|
|
21
24
|
);
|
|
22
25
|
} catch (e) {
|
|
23
|
-
console.warn("
|
|
26
|
+
throw console.warn("deepClone failed:", e), e;
|
|
24
27
|
}
|
|
25
28
|
try {
|
|
26
|
-
|
|
29
|
+
await w(
|
|
30
|
+
t,
|
|
31
|
+
o,
|
|
32
|
+
i,
|
|
33
|
+
f,
|
|
34
|
+
n,
|
|
35
|
+
l,
|
|
36
|
+
a.useProxy
|
|
37
|
+
);
|
|
27
38
|
} catch (e) {
|
|
28
|
-
console.warn("
|
|
39
|
+
console.warn("inlinePseudoElements failed:", e);
|
|
29
40
|
}
|
|
30
|
-
if (
|
|
31
|
-
const e =
|
|
32
|
-
|
|
33
|
-
for (const [
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
if (await L(o), n) {
|
|
42
|
+
const e = A(i);
|
|
43
|
+
c = Array.from(e.entries()).map(([s, u]) => `.${u}{${s}}`).join("");
|
|
44
|
+
for (const [s, u] of i.entries()) {
|
|
45
|
+
if (s.tagName === "STYLE") continue;
|
|
46
|
+
if (s.getRootNode && s.getRootNode() instanceof ShadowRoot) {
|
|
47
|
+
s.setAttribute("style", u.replace(/;/g, "; "));
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const d = e.get(u);
|
|
51
|
+
d && s.classList.add(d);
|
|
52
|
+
const p = s.style?.backgroundImage, y = s.dataset?.snapdomHasIcon;
|
|
53
|
+
p && p !== "none" && (s.style.backgroundImage = p), y && (s.style.verticalAlign = "middle", s.style.display = "inline");
|
|
39
54
|
}
|
|
40
55
|
} else
|
|
41
|
-
for (const [e,
|
|
42
|
-
e.tagName !== "STYLE" && e.setAttribute("style",
|
|
43
|
-
for (const [e,
|
|
44
|
-
const
|
|
45
|
-
if ((
|
|
56
|
+
for (const [e, s] of i.entries())
|
|
57
|
+
e.tagName !== "STYLE" && e.setAttribute("style", s.replace(/;/g, "; "));
|
|
58
|
+
for (const [e, s] of r.entries()) {
|
|
59
|
+
const u = s.scrollLeft, d = s.scrollTop;
|
|
60
|
+
if ((u || d) && e instanceof HTMLElement) {
|
|
46
61
|
e.style.overflow = "hidden", e.style.scrollbarWidth = "none", e.style.msOverflowStyle = "none";
|
|
47
|
-
const
|
|
48
|
-
for (
|
|
49
|
-
|
|
50
|
-
e.appendChild(
|
|
62
|
+
const y = document.createElement("div");
|
|
63
|
+
for (y.style.transform = `translate(${-u}px, ${-d}px)`, y.style.willChange = "transform", y.style.display = "inline-block", y.style.width = "100%"; e.firstChild; )
|
|
64
|
+
y.appendChild(e.firstChild);
|
|
65
|
+
e.appendChild(y);
|
|
51
66
|
}
|
|
52
67
|
}
|
|
53
|
-
if (
|
|
54
|
-
const e =
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
o.style.margin = "0", o.style.position = "static", o.style.top = "auto", o.style.left = "auto", o.style.right = "auto", o.style.bottom = "auto", o.style.zIndex = "auto", o.style.float = "none", o.style.clear = "none", o.style.transform =
|
|
68
|
+
if (t === r.get(o)) {
|
|
69
|
+
const e = f.get(t) || window.getComputedStyle(t);
|
|
70
|
+
f.set(t, e);
|
|
71
|
+
const s = C(e.transform);
|
|
72
|
+
o.style.margin = "0", o.style.position = "static", o.style.top = "auto", o.style.left = "auto", o.style.right = "auto", o.style.bottom = "auto", o.style.zIndex = "auto", o.style.float = "none", o.style.clear = "none", o.style.transform = s || "";
|
|
73
|
+
}
|
|
74
|
+
for (const [e, s] of r.entries())
|
|
75
|
+
s.tagName === "PRE" && (e.style.marginTop = "0", e.style.marginBlockStart = "0");
|
|
76
|
+
return { clone: o, classCSS: c, styleCache: f };
|
|
77
|
+
}
|
|
78
|
+
function E(t) {
|
|
79
|
+
const n = getComputedStyle(t), l = n.outlineStyle, a = n.outlineWidth, i = n.borderStyle, f = n.borderWidth, r = l !== "none" && parseFloat(a) > 0, o = i === "none" || parseFloat(f) === 0;
|
|
80
|
+
r && o && (t.style.border = `${a} solid transparent`);
|
|
81
|
+
}
|
|
82
|
+
var h = /* @__PURE__ */ new Map();
|
|
83
|
+
async function b(t) {
|
|
84
|
+
if (h.has(t)) return h.get(t);
|
|
85
|
+
const n = await fetch(t);
|
|
86
|
+
if (!n.ok)
|
|
87
|
+
throw new Error(`[SnapDOM] HTTP ${n.status} on blob fetch (${t})`);
|
|
88
|
+
const l = await n.blob(), a = await new Promise((i, f) => {
|
|
89
|
+
const r = new FileReader();
|
|
90
|
+
r.onloadend = () => {
|
|
91
|
+
const o = r.result;
|
|
92
|
+
typeof o == "string" && o.startsWith("data:") ? i(o) : f(new Error("[SnapDOM] Invalid data URL from blob"));
|
|
93
|
+
}, r.onerror = () => f(new Error("[SnapDOM] FileReader error")), r.readAsDataURL(l);
|
|
94
|
+
});
|
|
95
|
+
return h.set(t, a), a;
|
|
96
|
+
}
|
|
97
|
+
var v = /\bblob:[^)"'\s]+/g;
|
|
98
|
+
async function m(t) {
|
|
99
|
+
if (!t || t.indexOf("blob:") === -1) return t;
|
|
100
|
+
const n = Array.from(new Set(t.match(v) || []));
|
|
101
|
+
if (n.length === 0) return t;
|
|
102
|
+
let l = t;
|
|
103
|
+
for (const a of n)
|
|
104
|
+
try {
|
|
105
|
+
const i = await b(a);
|
|
106
|
+
l = l.split(a).join(i);
|
|
107
|
+
} catch {
|
|
108
|
+
}
|
|
109
|
+
return l;
|
|
110
|
+
}
|
|
111
|
+
function g(t) {
|
|
112
|
+
return typeof t == "string" && t.startsWith("blob:");
|
|
113
|
+
}
|
|
114
|
+
function q(t) {
|
|
115
|
+
return (t || "").split(",").map((n) => n.trim()).filter(Boolean).map((n) => {
|
|
116
|
+
const l = n.match(/^(\S+)(\s+.+)?$/);
|
|
117
|
+
return l ? { url: l[1], desc: l[2] || "" } : null;
|
|
118
|
+
}).filter(Boolean);
|
|
119
|
+
}
|
|
120
|
+
function I(t) {
|
|
121
|
+
return t.map((n) => n.desc ? `${n.url} ${n.desc.trim()}` : n.url).join(", ");
|
|
122
|
+
}
|
|
123
|
+
async function L(t) {
|
|
124
|
+
if (!t) return;
|
|
125
|
+
const n = t.querySelectorAll ? t.querySelectorAll("img") : [];
|
|
126
|
+
for (const r of n)
|
|
127
|
+
try {
|
|
128
|
+
const c = r.getAttribute("src") || r.currentSrc || "";
|
|
129
|
+
if (g(c)) {
|
|
130
|
+
const s = await b(c);
|
|
131
|
+
r.setAttribute("src", s);
|
|
132
|
+
}
|
|
133
|
+
const e = r.getAttribute("srcset");
|
|
134
|
+
if (e && e.includes("blob:")) {
|
|
135
|
+
const s = q(e);
|
|
136
|
+
let u = !1;
|
|
137
|
+
for (const d of s)
|
|
138
|
+
if (g(d.url))
|
|
139
|
+
try {
|
|
140
|
+
d.url = await b(d.url), u = !0;
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
u && r.setAttribute("srcset", I(s));
|
|
144
|
+
}
|
|
145
|
+
} catch {
|
|
146
|
+
}
|
|
147
|
+
const l = t.querySelectorAll ? t.querySelectorAll("image") : [];
|
|
148
|
+
for (const r of l)
|
|
149
|
+
try {
|
|
150
|
+
const o = "http://www.w3.org/1999/xlink", c = r.getAttribute("href") || r.getAttributeNS?.(o, "href");
|
|
151
|
+
if (g(c)) {
|
|
152
|
+
const e = await b(c);
|
|
153
|
+
r.setAttribute("href", e), r.removeAttributeNS?.(o, "href");
|
|
154
|
+
}
|
|
155
|
+
} catch {
|
|
156
|
+
}
|
|
157
|
+
const a = t.querySelectorAll ? t.querySelectorAll("[style*='blob:']") : [];
|
|
158
|
+
for (const r of a)
|
|
159
|
+
try {
|
|
160
|
+
const o = r.getAttribute("style");
|
|
161
|
+
if (o && o.includes("blob:")) {
|
|
162
|
+
const c = await m(o);
|
|
163
|
+
r.setAttribute("style", c);
|
|
164
|
+
}
|
|
165
|
+
} catch {
|
|
166
|
+
}
|
|
167
|
+
const i = t.querySelectorAll ? t.querySelectorAll("style") : [];
|
|
168
|
+
for (const r of i)
|
|
169
|
+
try {
|
|
170
|
+
const o = r.textContent || "";
|
|
171
|
+
o.includes("blob:") && (r.textContent = await m(o));
|
|
172
|
+
} catch {
|
|
173
|
+
}
|
|
174
|
+
const f = ["poster"];
|
|
175
|
+
for (const r of f) {
|
|
176
|
+
const o = t.querySelectorAll ? t.querySelectorAll(`[${r}^='blob:']`) : [];
|
|
177
|
+
for (const c of o)
|
|
178
|
+
try {
|
|
179
|
+
const e = c.getAttribute(r);
|
|
180
|
+
g(e) && c.setAttribute(r, await b(e));
|
|
181
|
+
} catch {
|
|
182
|
+
}
|
|
58
183
|
}
|
|
59
|
-
for (const [e, t] of s.preNodeMap.entries())
|
|
60
|
-
t.tagName === "PRE" && (e.style.marginTop = "0", e.style.marginBlockStart = "0");
|
|
61
|
-
return { clone: o, classCSS: d };
|
|
62
184
|
}
|
|
63
185
|
export {
|
|
64
|
-
|
|
186
|
+
x as prepareClone
|
|
65
187
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const n = [[d, u]], p = [
|
|
1
|
+
import { getStyle as h, splitBackgroundImage as y, inlineSingleBackgroundEntry as P } from "../utils/helpers.js";
|
|
2
|
+
async function B(l, u, a, b = {}) {
|
|
3
|
+
const s = [[l, u]], k = [
|
|
5
4
|
"background-image",
|
|
6
5
|
"mask",
|
|
7
6
|
"mask-image",
|
|
@@ -17,24 +16,35 @@ async function S(d, u, b = {}) {
|
|
|
17
16
|
"border-image-outset",
|
|
18
17
|
"border-image-repeat"
|
|
19
18
|
];
|
|
20
|
-
for (;
|
|
21
|
-
const [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
for (; s.length; ) {
|
|
20
|
+
const [o, g] = s.shift(), n = a.get(o) || h(o);
|
|
21
|
+
a.has(o) || a.set(o, n);
|
|
22
|
+
const p = (() => {
|
|
23
|
+
const e = n.getPropertyValue("border-image"), r = n.getPropertyValue("border-image-source");
|
|
24
|
+
return e && e !== "none" || r && r !== "none";
|
|
25
|
+
})();
|
|
26
|
+
for (const e of k) {
|
|
27
|
+
if ([
|
|
28
|
+
"border-image-slice",
|
|
29
|
+
"border-image-width",
|
|
30
|
+
"border-image-outset",
|
|
31
|
+
"border-image-repeat"
|
|
32
|
+
].includes(e) && !p)
|
|
33
|
+
continue;
|
|
34
|
+
const r = n.getPropertyValue(e);
|
|
35
|
+
if (!r || r === "none") continue;
|
|
36
|
+
const f = y(r), d = await Promise.all(
|
|
37
|
+
f.map((t) => P(t, b))
|
|
28
38
|
);
|
|
29
|
-
|
|
39
|
+
d.some((t) => t && t !== "none" && !/^url\(undefined/.test(t)) && g.style.setProperty(e, d.join(", "));
|
|
30
40
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
for (let e = 0; e < Math.min(
|
|
35
|
-
|
|
41
|
+
const i = n.getPropertyValue("background-color");
|
|
42
|
+
i && i !== "transparent" && i !== "rgba(0, 0, 0, 0)" && (g.style.backgroundColor = i);
|
|
43
|
+
const c = Array.from(o.children), m = Array.from(g.children);
|
|
44
|
+
for (let e = 0; e < Math.min(c.length, m.length); e++)
|
|
45
|
+
s.push([c[e], m[e]]);
|
|
36
46
|
}
|
|
37
47
|
}
|
|
38
48
|
export {
|
|
39
|
-
|
|
49
|
+
B as inlineBackgroundImages
|
|
40
50
|
};
|