@unicom-cloud/utils 0.1.15 → 0.1.16
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/lunar/lib/Holiday.js +2 -6
- package/lunar/lib/HolidayUtil.js +113 -99
- package/lunar/lib/I18n.js +395 -975
- package/lunar/lib/JieQi.js +12 -16
- package/lunar/lib/Lunar.js +224 -672
- package/lunar/lib/LunarMonth.js +35 -98
- package/lunar/lib/LunarTime.js +24 -103
- package/lunar/lib/LunarUtil.js +426 -1728
- package/lunar/lib/LunarYear.js +473 -566
- package/lunar/lib/ShouXingUtil.js +6714 -6690
- package/lunar/lib/Solar.js +24 -49
- package/lunar/lib/SolarHalfYear.js +0 -2
- package/lunar/lib/SolarMonth.js +4 -6
- package/lunar/lib/SolarSeason.js +0 -2
- package/lunar/lib/SolarUtil.js +238 -226
- package/lunar/lib/SolarWeek.js +7 -11
- package/lunar/lib/SolarYear.js +0 -1
- package/package.json +1 -1
- package/snapdom/src/core/prepare.js +21 -21
- package/snapdom/src/modules/fonts.js +99 -91
- package/snapdom/src/modules/pseudo.js +58 -66
- package/tinycolor/src/conversion.js +1 -1
- package/tinycolor/src/index.js +2 -19
- package/turbo-stream/src/encode.js +5 -8
- package/turbo-stream/src/shared.js +117 -119
- package/types/lunar/lib/Lunar.d.ts +0 -98
- package/types/lunar/lib/LunarMonth.d.ts +0 -12
- package/types/lunar/lib/LunarTime.d.ts +0 -22
- package/types/lunar/lib/LunarUtil.d.ts +0 -90
- package/types/lunar/lib/LunarYear.d.ts +0 -30
- package/types/lunar/lib/Solar.d.ts +0 -5
- package/types/snapdom/src/modules/pseudo.d.ts +1 -1
- package/types/tinycolor/src/conversion.d.ts +1 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { cache as
|
|
1
|
+
import { cache as s } from "./cache.js";
|
|
2
2
|
import { inlinePseudoElements as p } from "../modules/pseudo.js";
|
|
3
3
|
import { inlineExternalDef as m } from "../modules/svgDefs.js";
|
|
4
4
|
import { generateCSSClasses as g } from "../utils/cssTools.js";
|
|
5
5
|
import { stripTranslate as u } from "../utils/helpers.js";
|
|
6
6
|
import { deepClone as h } from "./clone.js";
|
|
7
|
-
async function k(
|
|
8
|
-
let o,
|
|
7
|
+
async function k(n, c = !1, y = !1, f = {}) {
|
|
8
|
+
let o, d = "";
|
|
9
9
|
try {
|
|
10
|
-
o = h(
|
|
10
|
+
o = h(n, c, f, n);
|
|
11
11
|
} catch (e) {
|
|
12
12
|
throw console.warn("deepClone failed:", e), e;
|
|
13
13
|
}
|
|
14
14
|
try {
|
|
15
15
|
await p(
|
|
16
|
-
|
|
16
|
+
n,
|
|
17
17
|
o,
|
|
18
18
|
c,
|
|
19
|
-
|
|
19
|
+
y,
|
|
20
20
|
f.useProxy
|
|
21
21
|
);
|
|
22
22
|
} catch (e) {
|
|
@@ -29,36 +29,36 @@ async function k(l, c = !1, d = !1, f = {}) {
|
|
|
29
29
|
}
|
|
30
30
|
if (c) {
|
|
31
31
|
const e = g();
|
|
32
|
-
|
|
33
|
-
for (const [t, r] of
|
|
32
|
+
d = Array.from(e.entries()).map(([t, r]) => `.${r}{${t}}`).join("");
|
|
33
|
+
for (const [t, r] of s.preStyleMap.entries()) {
|
|
34
34
|
if (t.tagName === "STYLE") continue;
|
|
35
35
|
const a = e.get(r);
|
|
36
36
|
a && t.classList.add(a);
|
|
37
|
-
const i = t.style?.backgroundImage;
|
|
38
|
-
t.removeAttribute("style"), i && i !== "none" && (t.style.backgroundImage = i);
|
|
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");
|
|
39
39
|
}
|
|
40
40
|
} else
|
|
41
|
-
for (const [e, t] of
|
|
41
|
+
for (const [e, t] of s.preStyleMap.entries())
|
|
42
42
|
e.tagName !== "STYLE" && e.setAttribute("style", t.replace(/;/g, "; "));
|
|
43
|
-
for (const [e, t] of
|
|
43
|
+
for (const [e, t] of s.preNodeMap.entries()) {
|
|
44
44
|
const r = t.scrollLeft, a = t.scrollTop;
|
|
45
45
|
if ((r || a) && e instanceof HTMLElement) {
|
|
46
46
|
e.style.overflow = "hidden", e.style.scrollbarWidth = "none", e.style.msOverflowStyle = "none";
|
|
47
|
-
const
|
|
48
|
-
for (
|
|
49
|
-
|
|
50
|
-
e.appendChild(
|
|
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);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
if (
|
|
54
|
-
const e =
|
|
55
|
-
|
|
53
|
+
if (n === s.preNodeMap.get(o)) {
|
|
54
|
+
const e = s.preStyle.get(n) || window.getComputedStyle(n);
|
|
55
|
+
s.preStyle.set(n, e);
|
|
56
56
|
const t = u(e.transform);
|
|
57
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 || "";
|
|
58
58
|
}
|
|
59
|
-
for (const [e, t] of
|
|
59
|
+
for (const [e, t] of s.preNodeMap.entries())
|
|
60
60
|
t.tagName === "PRE" && (e.style.marginTop = "0", e.style.marginBlockStart = "0");
|
|
61
|
-
return { clone: o, classCSS:
|
|
61
|
+
return { clone: o, classCSS: d };
|
|
62
62
|
}
|
|
63
63
|
export {
|
|
64
64
|
k as prepareClone
|
|
@@ -1,139 +1,147 @@
|
|
|
1
|
-
import { cache as
|
|
2
|
-
import { isIconFont as
|
|
3
|
-
import { extractURL as
|
|
4
|
-
async function E(m, i,
|
|
1
|
+
import { cache as n } from "../core/cache.js";
|
|
2
|
+
import { isIconFont as h } from "./iconFonts.js";
|
|
3
|
+
import { extractURL as U } from "../utils/helpers.js";
|
|
4
|
+
async function E(m, i, l, y = 32, u = "#000") {
|
|
5
5
|
i = i.replace(/^['"]+|['"]+$/g, "");
|
|
6
|
-
const t = window.devicePixelRatio || 1
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
e.
|
|
10
|
-
const
|
|
11
|
-
|
|
6
|
+
const t = window.devicePixelRatio || 1;
|
|
7
|
+
await document.fonts.ready;
|
|
8
|
+
const e = document.createElement("span");
|
|
9
|
+
e.textContent = m, e.style.position = "absolute", e.style.visibility = "hidden", e.style.fontFamily = `"${i}"`, e.style.fontWeight = l || "normal", e.style.fontSize = `${y}px`, e.style.lineHeight = "1", e.style.whiteSpace = "nowrap", e.style.padding = "0", e.style.margin = "0", document.body.appendChild(e);
|
|
10
|
+
const r = e.getBoundingClientRect(), d = Math.ceil(r.width), f = Math.ceil(r.height);
|
|
11
|
+
document.body.removeChild(e);
|
|
12
|
+
const c = document.createElement("canvas");
|
|
13
|
+
c.width = d * t, c.height = f * t;
|
|
14
|
+
const s = c.getContext("2d");
|
|
15
|
+
return s.scale(t, t), s.font = l ? `${l} ${y}px "${i}"` : `${y}px "${i}"`, s.textAlign = "left", s.textBaseline = "top", s.fillStyle = u, s.fillText(m, 0, 0), {
|
|
16
|
+
dataUrl: c.toDataURL(),
|
|
17
|
+
width: d,
|
|
18
|
+
height: f
|
|
19
|
+
};
|
|
12
20
|
}
|
|
13
|
-
function
|
|
21
|
+
function x(m) {
|
|
14
22
|
return Array.from(document.styleSheets).some((i) => i.href === m);
|
|
15
23
|
}
|
|
16
|
-
function
|
|
24
|
+
function L(m) {
|
|
17
25
|
return new Promise((i) => {
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
|
|
26
|
+
if (x(m)) return i(null);
|
|
27
|
+
const l = document.createElement("link");
|
|
28
|
+
l.rel = "stylesheet", l.href = m, l.setAttribute("data-snapdom", "injected-import"), l.onload = () => i(l), l.onerror = () => i(null), document.head.appendChild(l);
|
|
21
29
|
});
|
|
22
30
|
}
|
|
23
|
-
async function
|
|
24
|
-
if (
|
|
31
|
+
async function k({ preCached: m = !1 } = {}) {
|
|
32
|
+
if (n.resource.has("fonts-embed-css")) {
|
|
25
33
|
if (m) {
|
|
26
34
|
const t = document.createElement("style");
|
|
27
|
-
t.setAttribute("data-snapdom", "embedFonts"), t.textContent =
|
|
35
|
+
t.setAttribute("data-snapdom", "embedFonts"), t.textContent = n.resource.get("fonts-embed-css"), document.head.appendChild(t);
|
|
28
36
|
}
|
|
29
|
-
return
|
|
37
|
+
return n.resource.get("fonts-embed-css");
|
|
30
38
|
}
|
|
31
|
-
const i = /@import\s+url\(["']?([^"')]+)["']?\)/g,
|
|
39
|
+
const i = /@import\s+url\(["']?([^"')]+)["']?\)/g, l = [];
|
|
32
40
|
for (const t of document.querySelectorAll("style")) {
|
|
33
|
-
const
|
|
34
|
-
for (const
|
|
35
|
-
const
|
|
36
|
-
|
|
41
|
+
const e = t.textContent || "", r = Array.from(e.matchAll(i));
|
|
42
|
+
for (const d of r) {
|
|
43
|
+
const f = d[1];
|
|
44
|
+
h(f) || x(f) || l.push(f);
|
|
37
45
|
}
|
|
38
46
|
}
|
|
39
|
-
await Promise.all(
|
|
40
|
-
const
|
|
47
|
+
await Promise.all(l.map(L));
|
|
48
|
+
const y = Array.from(
|
|
41
49
|
document.querySelectorAll('link[rel="stylesheet"]')
|
|
42
50
|
).filter((t) => t.href);
|
|
43
51
|
let u = "";
|
|
44
|
-
for (const t of
|
|
52
|
+
for (const t of y)
|
|
45
53
|
try {
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
const
|
|
49
|
-
Array.from(
|
|
50
|
-
let
|
|
51
|
-
if (!
|
|
52
|
-
let
|
|
53
|
-
if (!
|
|
54
|
-
if (
|
|
55
|
-
return
|
|
56
|
-
original:
|
|
57
|
-
inlined: `url(${
|
|
54
|
+
const r = await (await fetch(t.href)).text();
|
|
55
|
+
if (h(t.href) || h(r)) continue;
|
|
56
|
+
const d = /url\((["']?)([^"')]+)\1\)/g, f = await Promise.all(
|
|
57
|
+
Array.from(r.matchAll(d)).map(async (s) => {
|
|
58
|
+
let b = U(s[0]);
|
|
59
|
+
if (!b) return null;
|
|
60
|
+
let o = b;
|
|
61
|
+
if (!o.startsWith("http") && !o.startsWith("data:") && (o = new URL(o, t.href).href), h(o)) return null;
|
|
62
|
+
if (n.resource.has(o))
|
|
63
|
+
return n.font.add(o), {
|
|
64
|
+
original: s[0],
|
|
65
|
+
inlined: `url(${n.resource.get(o)})`
|
|
58
66
|
};
|
|
59
|
-
if (
|
|
67
|
+
if (n.font.has(o)) return null;
|
|
60
68
|
try {
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
69
|
+
const p = await (await fetch(o)).blob(), w = await new Promise((a) => {
|
|
70
|
+
const g = new FileReader();
|
|
71
|
+
g.onload = () => a(g.result), g.readAsDataURL(p);
|
|
64
72
|
});
|
|
65
|
-
return
|
|
73
|
+
return n.resource.set(o, w), n.font.add(o), { original: s[0], inlined: `url(${w})` };
|
|
66
74
|
} catch {
|
|
67
|
-
return console.warn("[snapdom] Failed to fetch font resource:",
|
|
75
|
+
return console.warn("[snapdom] Failed to fetch font resource:", o), null;
|
|
68
76
|
}
|
|
69
77
|
})
|
|
70
78
|
);
|
|
71
|
-
let
|
|
72
|
-
for (const
|
|
73
|
-
|
|
74
|
-
u +=
|
|
79
|
+
let c = r;
|
|
80
|
+
for (const s of f)
|
|
81
|
+
s && (c = c.replace(s.original, s.inlined));
|
|
82
|
+
u += c + `
|
|
75
83
|
`;
|
|
76
84
|
} catch {
|
|
77
85
|
console.warn("[snapdom] Failed to fetch CSS:", t.href);
|
|
78
86
|
}
|
|
79
87
|
for (const t of document.styleSheets)
|
|
80
88
|
try {
|
|
81
|
-
if (!t.href ||
|
|
82
|
-
for (const
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
85
|
-
if (!
|
|
86
|
-
const
|
|
87
|
-
if (!
|
|
88
|
-
u += `@font-face{font-family:${
|
|
89
|
+
if (!t.href || y.every((e) => e.href !== t.href)) {
|
|
90
|
+
for (const e of t.cssRules)
|
|
91
|
+
if (e.type === CSSRule.FONT_FACE_RULE) {
|
|
92
|
+
const r = e.style.getPropertyValue("src"), d = e.style.getPropertyValue("font-family");
|
|
93
|
+
if (!r || h(d)) continue;
|
|
94
|
+
const f = /url\((["']?)([^"')]+)\1\)/g, c = /local\((["']?)[^)]+?\1\)/g, s = !!r.match(f), b = !!r.match(c);
|
|
95
|
+
if (!s && b) {
|
|
96
|
+
u += `@font-face{font-family:${d};src:${r};font-style:${e.style.getPropertyValue("font-style") || "normal"};font-weight:${e.style.getPropertyValue("font-weight") || "normal"};}`;
|
|
89
97
|
continue;
|
|
90
98
|
}
|
|
91
|
-
let
|
|
92
|
-
const
|
|
93
|
-
for (const
|
|
94
|
-
let
|
|
95
|
-
if (!
|
|
96
|
-
let
|
|
97
|
-
if (!
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
`url(${
|
|
99
|
+
let o = r;
|
|
100
|
+
const S = Array.from(r.matchAll(f));
|
|
101
|
+
for (const p of S) {
|
|
102
|
+
let w = p[2].trim();
|
|
103
|
+
if (!w) continue;
|
|
104
|
+
let a = w;
|
|
105
|
+
if (!a.startsWith("http") && !a.startsWith("data:") && (a = new URL(a, t.href || location.href).href), !h(a)) {
|
|
106
|
+
if (n.resource.has(a)) {
|
|
107
|
+
n.font.add(a), o = o.replace(
|
|
108
|
+
p[0],
|
|
109
|
+
`url(${n.resource.get(a)})`
|
|
102
110
|
);
|
|
103
111
|
continue;
|
|
104
112
|
}
|
|
105
|
-
if (!
|
|
113
|
+
if (!n.font.has(a))
|
|
106
114
|
try {
|
|
107
|
-
const A = await (await fetch(
|
|
108
|
-
const
|
|
109
|
-
|
|
115
|
+
const A = await (await fetch(a)).blob(), R = await new Promise((C) => {
|
|
116
|
+
const $ = new FileReader();
|
|
117
|
+
$.onload = () => C($.result), $.readAsDataURL(A);
|
|
110
118
|
});
|
|
111
|
-
|
|
119
|
+
n.resource.set(a, R), n.font.add(a), o = o.replace(p[0], `url(${R})`);
|
|
112
120
|
} catch {
|
|
113
|
-
console.warn("[snapdom] Failed to fetch font URL:",
|
|
121
|
+
console.warn("[snapdom] Failed to fetch font URL:", a);
|
|
114
122
|
}
|
|
115
123
|
}
|
|
116
124
|
}
|
|
117
|
-
u += `@font-face{font-family:${
|
|
125
|
+
u += `@font-face{font-family:${d};src:${o};font-style:${e.style.getPropertyValue("font-style") || "normal"};font-weight:${e.style.getPropertyValue("font-weight") || "normal"};}`;
|
|
118
126
|
}
|
|
119
127
|
}
|
|
120
|
-
} catch (
|
|
121
|
-
console.warn("[snapdom] Cannot access stylesheet", t.href,
|
|
128
|
+
} catch (e) {
|
|
129
|
+
console.warn("[snapdom] Cannot access stylesheet", t.href, e);
|
|
122
130
|
}
|
|
123
131
|
for (const t of document.fonts)
|
|
124
132
|
if (t.family && t.status === "loaded" && t._snapdomSrc) {
|
|
125
|
-
if (
|
|
126
|
-
let
|
|
127
|
-
if (!
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
else if (!
|
|
133
|
+
if (h(t.family)) continue;
|
|
134
|
+
let e = t._snapdomSrc;
|
|
135
|
+
if (!e.startsWith("data:")) {
|
|
136
|
+
if (n.resource.has(t._snapdomSrc))
|
|
137
|
+
e = n.resource.get(t._snapdomSrc), n.font.add(t._snapdomSrc);
|
|
138
|
+
else if (!n.font.has(t._snapdomSrc))
|
|
131
139
|
try {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
}),
|
|
140
|
+
const d = await (await fetch(t._snapdomSrc)).blob();
|
|
141
|
+
e = await new Promise((f) => {
|
|
142
|
+
const c = new FileReader();
|
|
143
|
+
c.onload = () => f(c.result), c.readAsDataURL(d);
|
|
144
|
+
}), n.resource.set(t._snapdomSrc, e), n.font.add(t._snapdomSrc);
|
|
137
145
|
} catch {
|
|
138
146
|
console.warn(
|
|
139
147
|
"[snapdom] Failed to fetch dynamic font src:",
|
|
@@ -142,15 +150,15 @@ async function T({ preCached: m = !1 } = {}) {
|
|
|
142
150
|
continue;
|
|
143
151
|
}
|
|
144
152
|
}
|
|
145
|
-
u += `@font-face{font-family:'${t.family}';src:url(${
|
|
153
|
+
u += `@font-face{font-family:'${t.family}';src:url(${e});font-style:${t.style || "normal"};font-weight:${t.weight || "normal"};}`;
|
|
146
154
|
}
|
|
147
|
-
if (u && (
|
|
155
|
+
if (u && (n.resource.set("fonts-embed-css", u), m)) {
|
|
148
156
|
const t = document.createElement("style");
|
|
149
157
|
t.setAttribute("data-snapdom", "embedFonts"), t.textContent = u, document.head.appendChild(t);
|
|
150
158
|
}
|
|
151
159
|
return u;
|
|
152
160
|
}
|
|
153
161
|
export {
|
|
154
|
-
|
|
162
|
+
k as embedCustomFonts,
|
|
155
163
|
E as iconToImage
|
|
156
164
|
};
|
|
@@ -1,86 +1,78 @@
|
|
|
1
|
-
import { cache as
|
|
2
|
-
import { iconToImage as
|
|
3
|
-
import { isIconFont as
|
|
1
|
+
import { cache as T } from "../core/cache.js";
|
|
2
|
+
import { iconToImage as O } from "./fonts.js";
|
|
3
|
+
import { isIconFont as X } from "./iconFonts.js";
|
|
4
4
|
import { getStyleKey as $ } from "../utils/cssTools.js";
|
|
5
|
-
import { getStyle as
|
|
6
|
-
async function
|
|
7
|
-
if (!(
|
|
8
|
-
for (const
|
|
5
|
+
import { getStyle as _, snapshotComputedStyle as M, parseContent as q, extractURL as G, fetchImage as J, safeEncodeURI as Q, splitBackgroundImage as Y, inlineSingleBackgroundEntry as Z } from "../utils/helpers.js";
|
|
6
|
+
async function tt(i, r, d) {
|
|
7
|
+
if (!(i instanceof Element) || !(r instanceof Element)) return;
|
|
8
|
+
for (const e of ["::before", "::after", "::first-letter"])
|
|
9
9
|
try {
|
|
10
|
-
const t =
|
|
10
|
+
const t = _(i, e);
|
|
11
11
|
if (!t || typeof t[Symbol.iterator] != "function" || t.content === "none" && t.backgroundImage === "none" && t.backgroundColor === "transparent" && (t.borderStyle === "none" || parseFloat(t.borderWidth) === 0) && (!t.transform || t.transform === "none") && t.display === "inline") continue;
|
|
12
|
-
if (
|
|
13
|
-
const
|
|
14
|
-
if (!(t.color !==
|
|
15
|
-
const
|
|
16
|
-
(
|
|
12
|
+
if (e === "::first-letter") {
|
|
13
|
+
const o = getComputedStyle(i);
|
|
14
|
+
if (!(t.color !== o.color || t.fontSize !== o.fontSize || t.fontWeight !== o.fontWeight)) continue;
|
|
15
|
+
const a = Array.from(r.childNodes).find(
|
|
16
|
+
(W) => W.nodeType === Node.TEXT_NODE && W.textContent?.trim().length > 0
|
|
17
17
|
);
|
|
18
|
-
if (!
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const P = document.createTextNode(
|
|
26
|
-
|
|
18
|
+
if (!a) continue;
|
|
19
|
+
const l = a.textContent, h = l.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u)?.[0], v = l.slice(h?.length || 0);
|
|
20
|
+
if (!h || /[\uD800-\uDFFF]/.test(h)) continue;
|
|
21
|
+
const p = document.createElement("span");
|
|
22
|
+
p.textContent = h, p.dataset.snapdomPseudo = "::first-letter";
|
|
23
|
+
const H = M(t), K = $(H, "span", d);
|
|
24
|
+
T.preStyleMap.set(p, K);
|
|
25
|
+
const P = document.createTextNode(v);
|
|
26
|
+
r.replaceChild(P, a), r.insertBefore(p, P);
|
|
27
27
|
continue;
|
|
28
28
|
}
|
|
29
|
-
const
|
|
30
|
-
if (!(
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
S,
|
|
29
|
+
const g = t.content, c = /counter\s*\(|counters\s*\(/.test(g) ? "- " : q(g), u = t.backgroundImage, f = t.backgroundColor, x = t.fontFamily, m = parseInt(t.fontSize) || 32, U = parseInt(t.fontWeight) || !1, z = t.color || "#000", A = t.display, R = parseFloat(t.width), j = parseFloat(t.height), S = t.borderStyle, D = parseFloat(t.borderWidth), w = t.transform, F = X(x), I = g !== "none" && c !== "", y = u && u !== "none", b = f && f !== "transparent" && f !== "rgba(0, 0, 0, 0)", k = A !== "inline" && (R > 0 || j > 0), B = S && S !== "none" && D > 0, N = w && w !== "none";
|
|
30
|
+
if (!(I || y || b || k || B || N)) continue;
|
|
31
|
+
const n = document.createElement("span");
|
|
32
|
+
n.dataset.snapdomPseudo = e, n.style.verticalAlign = "middle";
|
|
33
|
+
const L = M(t), V = $(L, "span", d);
|
|
34
|
+
if (T.preStyleMap.set(n, V), F && c.length === 1) {
|
|
35
|
+
const { dataUrl: o, width: s, height: a } = await O(
|
|
36
|
+
c,
|
|
37
|
+
x,
|
|
39
38
|
U,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
m,
|
|
40
|
+
z
|
|
41
|
+
), l = document.createElement("img");
|
|
42
|
+
l.src = o, l.style = `height:${m}px;width:${s / a * m}px;object-fit:contain;`, n.appendChild(l), r.dataset.snapdomHasIcon = "true";
|
|
43
|
+
} else if (c.startsWith("url(")) {
|
|
44
|
+
const o = G(c);
|
|
45
|
+
if (o?.trim())
|
|
46
46
|
try {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} catch (r) {
|
|
52
|
-
console.error(`[snapdom] Error in pseudo ${n} for`, a, r);
|
|
47
|
+
const s = document.createElement("img"), a = await J(Q(o), d);
|
|
48
|
+
s.src = a, s.style = `width:${m}px;height:auto;object-fit:contain;`, n.appendChild(s);
|
|
49
|
+
} catch (s) {
|
|
50
|
+
console.error(`[snapdom] Error in pseudo ${e} for`, i, s);
|
|
53
51
|
}
|
|
54
|
-
} else !
|
|
55
|
-
if (
|
|
52
|
+
} else !F && I && (n.textContent = c);
|
|
53
|
+
if (y)
|
|
56
54
|
try {
|
|
57
|
-
const
|
|
58
|
-
|
|
55
|
+
const o = Y(u), s = await Promise.all(
|
|
56
|
+
o.map(Z)
|
|
59
57
|
);
|
|
60
|
-
|
|
61
|
-
} catch (
|
|
58
|
+
n.style.backgroundImage = s.join(", ");
|
|
59
|
+
} catch (o) {
|
|
62
60
|
console.warn(
|
|
63
|
-
`[snapdom] Failed to inline background-image for ${
|
|
64
|
-
|
|
61
|
+
`[snapdom] Failed to inline background-image for ${e}`,
|
|
62
|
+
o
|
|
65
63
|
);
|
|
66
64
|
}
|
|
67
|
-
if (
|
|
68
|
-
|
|
65
|
+
if (b && (n.style.backgroundColor = f), !(n.childNodes.length > 0 || n.textContent?.trim() !== "" || y || b || k || B || N)) continue;
|
|
66
|
+
e === "::before" ? r.insertBefore(n, r.firstChild) : r.appendChild(n);
|
|
69
67
|
} catch (t) {
|
|
70
|
-
console.warn(`[snapdom] Failed to capture ${
|
|
68
|
+
console.warn(`[snapdom] Failed to capture ${e} for`, i, t);
|
|
71
69
|
}
|
|
72
|
-
const C = Array.from(
|
|
73
|
-
(
|
|
70
|
+
const C = Array.from(i.children), E = Array.from(r.children).filter(
|
|
71
|
+
(e) => !e.dataset.snapdomPseudo
|
|
74
72
|
);
|
|
75
|
-
for (let
|
|
76
|
-
await
|
|
77
|
-
C[n],
|
|
78
|
-
E[n],
|
|
79
|
-
m,
|
|
80
|
-
R,
|
|
81
|
-
b
|
|
82
|
-
);
|
|
73
|
+
for (let e = 0; e < Math.min(C.length, E.length); e++)
|
|
74
|
+
await tt(C[e], E[e], d);
|
|
83
75
|
}
|
|
84
76
|
export {
|
|
85
|
-
|
|
77
|
+
tt as inlinePseudoElements
|
|
86
78
|
};
|
|
@@ -43,7 +43,7 @@ function k(n, r, t) {
|
|
|
43
43
|
}
|
|
44
44
|
return { r: e * 255, g: c * 255, b: o * 255 };
|
|
45
45
|
}
|
|
46
|
-
function l(n, r, t) {
|
|
46
|
+
function l(n = 0, r = 0, t = 0) {
|
|
47
47
|
n = s(n, 255), r = s(r, 255), t = s(t, 255);
|
|
48
48
|
const e = Math.max(n, r, t), c = Math.min(n, r, t);
|
|
49
49
|
let o = 0;
|
package/tinycolor/src/index.js
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
1
|
import { numberInputToObject as d, rgbToHsv as g, rgbToHsl as u, rgbToHex as b, rgbaToHex as m, rgbToCmyk as c } from "./conversion.js";
|
|
2
2
|
import { names as $ } from "./css-color-names.js";
|
|
3
3
|
import { inputToRGB as f } from "./format-input.js";
|
|
4
|
-
import { boundAlpha as
|
|
4
|
+
import { boundAlpha as M, clamp01 as a, bound01 as l } from "./util.js";
|
|
5
5
|
class n {
|
|
6
|
-
/** red */
|
|
7
|
-
r;
|
|
8
|
-
/** green */
|
|
9
|
-
g;
|
|
10
|
-
/** blue */
|
|
11
|
-
b;
|
|
12
|
-
/** alpha */
|
|
13
|
-
a;
|
|
14
|
-
/** the format used to create the tinycolor instance */
|
|
15
|
-
format;
|
|
16
|
-
/** input passed into the constructer used to create the tinycolor instance */
|
|
17
|
-
originalInput;
|
|
18
|
-
/** the color was successfully parsed */
|
|
19
|
-
isValid;
|
|
20
|
-
gradientType;
|
|
21
|
-
/** rounded alpha */
|
|
22
|
-
roundA;
|
|
23
6
|
constructor(t = "", s = {}) {
|
|
24
7
|
if (t instanceof n)
|
|
25
8
|
return t;
|
|
@@ -64,7 +47,7 @@ class n {
|
|
|
64
47
|
* @param alpha - The new alpha value. The accepted range is 0-1.
|
|
65
48
|
*/
|
|
66
49
|
setAlpha(t) {
|
|
67
|
-
return this.a =
|
|
50
|
+
return this.a = M(t), this.roundA = Math.round(100 * this.a) / 100, this;
|
|
68
51
|
}
|
|
69
52
|
/**
|
|
70
53
|
* Returns whether the color is monochrome.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { WaitGroup as
|
|
2
|
-
const { NEGATIVE_INFINITY: ye, POSITIVE_INFINITY: ce, isNaN: Te } = Number,
|
|
1
|
+
import { WaitGroup as v, STR_UNDEFINED as h, STR_NULL as M, STR_TRUE as B, STR_FALSE as C, STR_PROMISE as b, STR_READABLE_STREAM as O, STR_ASYNC_ITERABLE as F, STR_REFERENCE_SYMBOL as $, STR_DATE as x, STR_REGEXP as G, STR_URL as J, STR_ARRAY_BUFFER as V, STR_INT_8_ARRAY as j, STR_UINT_8_ARRAY as q, STR_UINT_8_ARRAY_CLAMPED as z, STR_INT_16_ARRAY as W, STR_UINT_16_ARRAY as K, STR_INT_32_ARRAY as X, STR_UINT_32_ARRAY as Z, STR_FLOAT_32_ARRAY as H, STR_FLOAT_64_ARRAY as Q, STR_BIG_INT_64_ARRAY as k, STR_BIG_UINT_64_ARRAY as ee, STR_DATA_VIEW as te, STR_FORM_DATA as ie, SUPPORTS_FILE as ne, STR_FILE as oe, STR_BLOB as se, STR_ERROR as re, STR_SET as ae, STR_MAP as fe, STR_PLUGIN as Y, STR_NaN as pe, STR_INFINITY as Re, STR_NEGATIVE_INFINITY as _e, STR_NEGATIVE_ZERO as le, STR_BIGINT as ue, STR_SYMBOL as Se, STR_REDACTED as Ae, STR_SUCCESS as L, STR_FAILURE as U } from "./shared.js";
|
|
2
|
+
const { NEGATIVE_INFINITY: ye, POSITIVE_INFINITY: ce, isNaN: Te } = Number, P = 1, D = 2;
|
|
3
3
|
function Ne(f, { plugins: t = [], redactErrors: _ = !0, signal: p } = {}) {
|
|
4
4
|
const y = () => p?.aborted ?? !1, c = new Promise((a, E) => {
|
|
5
5
|
p?.addEventListener("abort", (r) => {
|
|
@@ -8,7 +8,7 @@ function Ne(f, { plugins: t = [], redactErrors: _ = !0, signal: p } = {}) {
|
|
|
8
8
|
});
|
|
9
9
|
return new ReadableStream({
|
|
10
10
|
async start(a) {
|
|
11
|
-
const E = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), I = { refId: 0, promiseId: 0 }, T = new
|
|
11
|
+
const E = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), I = { refId: 0, promiseId: 0 }, T = new v(), e = [], u = (o) => {
|
|
12
12
|
de(
|
|
13
13
|
o,
|
|
14
14
|
e,
|
|
@@ -27,7 +27,7 @@ function Ne(f, { plugins: t = [], redactErrors: _ = !0, signal: p } = {}) {
|
|
|
27
27
|
}, s = {
|
|
28
28
|
push: (...o) => {
|
|
29
29
|
for (const [S, d, w] of o)
|
|
30
|
-
T.add(), S ===
|
|
30
|
+
T.add(), S === P ? Promise.race([w, c]).then(
|
|
31
31
|
i.bind(null, d),
|
|
32
32
|
n.bind(null, d)
|
|
33
33
|
) : (async () => {
|
|
@@ -64,9 +64,6 @@ function Ne(f, { plugins: t = [], redactErrors: _ = !0, signal: p } = {}) {
|
|
|
64
64
|
}
|
|
65
65
|
const A = 1, m = 2;
|
|
66
66
|
class l {
|
|
67
|
-
type;
|
|
68
|
-
prefix;
|
|
69
|
-
value;
|
|
70
67
|
constructor(t, _, p) {
|
|
71
68
|
this.type = t, this.prefix = _, this.value = p;
|
|
72
69
|
}
|
|
@@ -112,7 +109,7 @@ function de(f, t, _, p, y, c, a, E) {
|
|
|
112
109
|
}
|
|
113
110
|
const n = c.promiseId++;
|
|
114
111
|
p.set(e, n), t.push(b, n.toString()), y.push([
|
|
115
|
-
|
|
112
|
+
P,
|
|
116
113
|
n,
|
|
117
114
|
e
|
|
118
115
|
]);
|