@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.
Files changed (93) hide show
  1. package/class-name/index.js +5 -5
  2. package/constant/index.js +24 -2
  3. package/constant/platform.js +13 -12
  4. package/constant.js +24 -2
  5. package/content-disposition/index.js +3 -3
  6. package/date/convertTime.js +4 -4
  7. package/diff/index.js +7 -0
  8. package/diff/src/diff.d.ts +21 -0
  9. package/diff/src/diff.js +381 -0
  10. package/diff.js +7 -0
  11. package/filesize/types/constants.d.ts +81 -0
  12. package/filesize/types/filesize.d.ts +97 -0
  13. package/index.js +68 -58
  14. package/js-cookie/index.d.ts +116 -0
  15. package/js-cookie/index.js +4 -0
  16. package/js-cookie/src/api.js +56 -0
  17. package/js-cookie/src/assign.js +11 -0
  18. package/js-cookie/src/converter.js +14 -0
  19. package/jsCookie.js +4 -0
  20. package/lunar/lib/HolidayUtil.js +48 -49
  21. package/mitt/index.js +4 -0
  22. package/mitt/src/index.js +37 -0
  23. package/mitt.js +4 -0
  24. package/nzh/nzh.d.ts +74 -0
  25. package/package.json +1 -1
  26. package/pinyin/index.js +4 -0
  27. package/pinyin/simplified.js +4 -0
  28. package/pinyin/src/core.js +143 -0
  29. package/pinyin/src/simplified.js +8 -0
  30. package/pinyin/src/simplified_dict.js +410 -0
  31. package/pinyin/src/traditional.js +8 -0
  32. package/pinyin/src/traditional_dict.js +403 -0
  33. package/pinyin/traditional.js +4 -0
  34. package/pinyin.js +4 -0
  35. package/query-string/base.d.ts +717 -0
  36. package/query-string/base.js +268 -0
  37. package/query-string/index.d.ts +16 -0
  38. package/query-string/index.js +4 -0
  39. package/query-string/splitOnFirst.js +14 -0
  40. package/queryString.js +4 -0
  41. package/random/index.js +56 -35
  42. package/snapdom/src/api/preCache.js +51 -28
  43. package/snapdom/src/core/cache.js +1 -4
  44. package/snapdom/src/core/capture.js +45 -44
  45. package/snapdom/src/core/clone.js +82 -66
  46. package/snapdom/src/core/prepare.js +167 -45
  47. package/snapdom/src/modules/background.js +29 -19
  48. package/snapdom/src/modules/fonts.js +158 -111
  49. package/snapdom/src/modules/images.js +14 -9
  50. package/snapdom/src/modules/pseudo.js +52 -47
  51. package/snapdom/src/modules/styles.js +22 -22
  52. package/snapdom/src/modules/svgDefs.js +39 -20
  53. package/snapdom/src/utils/cssTools.js +58 -51
  54. package/snapdom/src/utils/helpers.js +197 -140
  55. package/snapdom/types/snapdom.d.ts +101 -0
  56. package/types/constant/index.d.ts +11 -0
  57. package/types/constant/platform.d.ts +1 -0
  58. package/types/diff/index.d.ts +2 -0
  59. package/types/diff/src/diff.d.ts +40 -0
  60. package/types/index.d.ts +6 -1
  61. package/types/js-cookie/index.d.ts +1 -0
  62. package/types/js-cookie/src/api.d.mts +2 -0
  63. package/types/js-cookie/src/assign.d.mts +1 -0
  64. package/types/js-cookie/src/converter.d.mts +5 -0
  65. package/types/mitt/index.d.ts +2 -0
  66. package/types/mitt/src/index.d.ts +29 -0
  67. package/types/pinyin/index.d.ts +1 -0
  68. package/types/pinyin/simplified.d.ts +1 -0
  69. package/types/pinyin/src/core.d.ts +3 -0
  70. package/types/pinyin/src/simplified.d.ts +4 -0
  71. package/types/pinyin/src/simplified_dict.d.ts +408 -0
  72. package/types/pinyin/src/traditional.d.ts +4 -0
  73. package/types/pinyin/src/traditional_dict.d.ts +401 -0
  74. package/types/pinyin/traditional.d.ts +1 -0
  75. package/types/query-string/base.d.ts +11 -0
  76. package/types/query-string/index.d.ts +2 -0
  77. package/types/query-string/splitOnFirst.d.ts +1 -0
  78. package/types/random/index.d.ts +14 -23
  79. package/types/snapdom/src/api/preCache.d.ts +2 -5
  80. package/types/snapdom/src/core/cache.d.ts +0 -3
  81. package/types/snapdom/src/core/clone.d.ts +1 -1
  82. package/types/snapdom/src/modules/background.d.ts +16 -6
  83. package/types/snapdom/src/modules/fonts.d.ts +5 -1
  84. package/types/snapdom/src/modules/pseudo.d.ts +1 -1
  85. package/types/snapdom/src/modules/styles.d.ts +1 -1
  86. package/types/snapdom/src/modules/svgDefs.d.ts +13 -13
  87. package/types/snapdom/src/utils/cssTools.d.ts +2 -10
  88. package/types/snapdom/src/utils/helpers.d.ts +13 -7
  89. package/types/turbo-stream/src/shared.d.ts +3 -3
  90. package/url-toolkit/src/url-toolkit.d.ts +22 -0
  91. package/event-emitter/index.js +0 -48
  92. package/eventEmitter.js +0 -4
  93. package/types/event-emitter/index.d.ts +0 -17
@@ -1,114 +1,130 @@
1
- import { cache as r } from "./cache.js";
2
- import { inlineAllStyles as f } from "../modules/styles.js";
3
- function u(e, n, a = {}, o) {
4
- if (!e) throw new Error("Invalid node");
5
- const p = /* @__PURE__ */ new Set();
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 (e.nodeType === Node.TEXT_NODE || e.nodeType !== Node.ELEMENT_NODE)
8
- return e.cloneNode(!0);
9
- if (e.getAttribute("data-capture") === "exclude") {
10
- const t = document.createElement("div"), i = e.getBoundingClientRect();
11
- return t.style.cssText = `display:inline-block;width:${i.width}px;height:${i.height}px;visibility:hidden;`, t;
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 t of a.exclude)
21
+ for (const e of a.exclude)
15
22
  try {
16
- if (e.matches?.(t)) {
17
- const i = document.createElement("div"), l = e.getBoundingClientRect();
18
- return i.style.cssText = `display:inline-block;width:${l.width}px;height:${l.height}px;visibility:hidden;`, i;
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: ${t}`, i);
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(e, o || e)) {
26
- const t = document.createElement("div"), i = e.getBoundingClientRect();
27
- return t.style.cssText = `display:inline-block;width:${i.width}px;height:${i.height}px;visibility:hidden;`, t;
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 (t) {
30
- console.warn("Error in filter function:", t);
36
+ } catch (e) {
37
+ console.warn("Error in filter function:", e);
31
38
  }
32
- if (e.tagName === "IFRAME") {
33
- const t = document.createElement("div");
34
- return 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;
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 (e.getAttribute("data-capture") === "placeholder") {
37
- const t = e.cloneNode(!1);
38
- r.preNodeMap.set(t, e), f(e, t, n);
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 = 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;
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 (e.tagName === "CANVAS") {
43
- const t = e.toDataURL(), i = document.createElement("img");
44
- return i.src = t, i.width = e.width, i.height = e.height, r.preNodeMap.set(i, e), f(e, i, n), i;
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 = e.cloneNode(!1), r.preNodeMap.set(c, e);
49
- } catch (t) {
50
- throw console.error("[Snapdom] Failed to clone node:", e, t), t;
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 (e instanceof HTMLTextAreaElement) {
53
- c.textContent = e.value, c.value = e.value;
54
- const t = e.getBoundingClientRect();
55
- return c.style.width = `${t.width}px`, c.style.height = `${t.height}px`, c;
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 (e instanceof HTMLInputElement && (c.value = e.value, c.setAttribute("value", e.value), e.checked !== void 0 && (c.checked = e.checked, e.checked && c.setAttribute("checked", ""), e.indeterminate && (c.indeterminate = e.indeterminate))), e instanceof HTMLSelectElement && (d = e.value), f(e, c, n), e.shadowRoot)
58
- if (Array.from(e.shadowRoot.querySelectorAll("slot")).length > 0) {
59
- for (const i of e.shadowRoot.childNodes)
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 l = i.textContent || "";
62
- l.trim() && n && (r.preStyle || (r.preStyle = /* @__PURE__ */ new WeakMap()), r.preStyle.set(i, l));
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 l of e.shadowRoot.childNodes) {
67
- if (l.nodeType === Node.ELEMENT_NODE && l.tagName === "STYLE") {
68
- const s = l.textContent || "";
69
- s.trim() && n && (r.preStyle || (r.preStyle = /* @__PURE__ */ new WeakMap()), r.preStyle.set(l, s));
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 h = u(
73
- l,
79
+ const u = m(
80
+ r,
74
81
  n,
82
+ l,
83
+ o,
84
+ s,
75
85
  a,
76
- o || e
86
+ h || t
77
87
  );
78
- h && i.appendChild(h);
88
+ u && i.appendChild(u);
79
89
  }
80
90
  c.appendChild(i);
81
91
  }
82
- if (e.tagName === "SLOT") {
83
- const t = e.assignedNodes?.({ flatten: !0 }) || [], i = t.length > 0 ? t : Array.from(e.childNodes), l = document.createDocumentFragment();
84
- for (const h of i) {
85
- const s = u(
86
- h,
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
- o || e
102
+ h || t
90
103
  );
91
- s && l.appendChild(s);
104
+ f && r.appendChild(f);
92
105
  }
93
- return l;
106
+ return r;
94
107
  }
95
- for (const t of e.childNodes) {
96
- if (p.has(t)) continue;
97
- const i = u(
98
- t,
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
- o || e
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 t of c.options)
108
- t.value === d ? t.setAttribute("selected", "") : t.removeAttribute("selected");
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
- u as deepClone
129
+ m as deepClone
114
130
  };
@@ -1,65 +1,187 @@
1
- import { cache as s } from "./cache.js";
2
- import { inlinePseudoElements as p } from "../modules/pseudo.js";
3
- import { inlineExternalDef as m } from "../modules/svgDefs.js";
4
- import { generateCSSClasses as g } from "../utils/cssTools.js";
5
- import { stripTranslate as u } from "../utils/helpers.js";
6
- import { deepClone as h } from "./clone.js";
7
- async function k(n, c = !1, y = !1, f = {}) {
8
- let o, d = "";
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
- o = h(n, c, f, n);
11
+ S(t);
11
12
  } catch (e) {
12
- throw console.warn("deepClone failed:", e), e;
13
+ console.warn("inlineExternal defs or symbol failed:", e);
13
14
  }
14
15
  try {
15
- await p(
16
+ o = N(
17
+ t,
18
+ i,
19
+ f,
20
+ r,
16
21
  n,
17
- o,
18
- c,
19
- y,
20
- f.useProxy
22
+ a,
23
+ t
21
24
  );
22
25
  } catch (e) {
23
- console.warn("inlinePseudoElements failed:", e);
26
+ throw console.warn("deepClone failed:", e), e;
24
27
  }
25
28
  try {
26
- m(o);
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("inlineExternalDef failed:", e);
39
+ console.warn("inlinePseudoElements failed:", e);
29
40
  }
30
- if (c) {
31
- const e = g();
32
- d = Array.from(e.entries()).map(([t, r]) => `.${r}{${t}}`).join("");
33
- for (const [t, r] of s.preStyleMap.entries()) {
34
- if (t.tagName === "STYLE") continue;
35
- const a = e.get(r);
36
- a && t.classList.add(a);
37
- const i = t.style?.backgroundImage, l = t.dataset?.snapdomHasIcon;
38
- t.removeAttribute("style"), i && i !== "none" && (t.style.backgroundImage = i), l && (t.style.verticalAlign = "middle", t.style.display = "inline");
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, t] of s.preStyleMap.entries())
42
- e.tagName !== "STYLE" && e.setAttribute("style", t.replace(/;/g, "; "));
43
- for (const [e, t] of s.preNodeMap.entries()) {
44
- const r = t.scrollLeft, a = t.scrollTop;
45
- if ((r || a) && e instanceof HTMLElement) {
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 l = document.createElement("div");
48
- for (l.style.transform = `translate(${-r}px, ${-a}px)`, l.style.willChange = "transform", l.style.display = "inline-block", l.style.width = "100%"; e.firstChild; )
49
- l.appendChild(e.firstChild);
50
- e.appendChild(l);
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 (n === s.preNodeMap.get(o)) {
54
- const e = s.preStyle.get(n) || window.getComputedStyle(n);
55
- s.preStyle.set(n, e);
56
- const t = u(e.transform);
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 = t || "";
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
- k as prepareClone
186
+ x as prepareClone
65
187
  };
@@ -1,7 +1,6 @@
1
- import { cache as c } from "../core/cache.js";
2
- import { getStyle as f, splitBackgroundImage as h, inlineSingleBackgroundEntry as y } from "../utils/helpers.js";
3
- async function S(d, u, b = {}) {
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 (; n.length; ) {
21
- const [r, i] = n.shift(), s = c.preStyle.get(r) || f(r);
22
- c.preStyle.has(r) || c.preStyle.set(r, s);
23
- for (const e of p) {
24
- const a = s.getPropertyValue(e);
25
- if (!a || a === "none") continue;
26
- const k = h(a), g = await Promise.all(
27
- k.map((o) => y(o, b))
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
- g.some((o) => o && o !== "none" && !/^url\(undefined/.test(o)) && i.style.setProperty(e, g.join(", "));
39
+ d.some((t) => t && t !== "none" && !/^url\(undefined/.test(t)) && g.style.setProperty(e, d.join(", "));
30
40
  }
31
- const t = s.getPropertyValue("background-color");
32
- t && t !== "transparent" && t !== "rgba(0, 0, 0, 0)" && (i.style.backgroundColor = t);
33
- const l = Array.from(r.children), m = Array.from(i.children);
34
- for (let e = 0; e < Math.min(l.length, m.length); e++)
35
- n.push([l[e], m[e]]);
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
- S as inlineBackgroundImages
49
+ B as inlineBackgroundImages
40
50
  };