@unicom-cloud/utils 0.1.11 → 0.1.13
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/date/index.js +22 -0
- package/date.js +9 -0
- package/filesize/src/constants.js +22 -22
- package/filesize/src/filesize.js +32 -33
- package/index.js +56 -54
- package/lunar/index.js +36 -0
- package/lunar/lib/Holiday.js +42 -0
- package/lunar/lib/HolidayUtil.js +128 -0
- package/lunar/lib/I18n.js +1005 -0
- package/lunar/lib/JieQi.js +40 -0
- package/lunar/lib/Lunar.js +1035 -0
- package/lunar/lib/LunarMonth.js +150 -0
- package/lunar/lib/LunarTime.js +138 -0
- package/lunar/lib/LunarUtil.js +1752 -0
- package/lunar/lib/LunarYear.js +616 -0
- package/lunar/lib/ShouXingUtil.js +6915 -0
- package/lunar/lib/Solar.js +311 -0
- package/lunar/lib/SolarHalfYear.js +45 -0
- package/lunar/lib/SolarMonth.js +55 -0
- package/lunar/lib/SolarSeason.js +42 -0
- package/lunar/lib/SolarUtil.js +256 -0
- package/lunar/lib/SolarWeek.js +153 -0
- package/lunar/lib/SolarYear.js +35 -0
- package/lunar/lib/index.js +35 -0
- package/lunar.js +36 -0
- package/package.json +1 -1
- package/snapdom/src/api/preCache.js +27 -37
- package/snapdom/src/api/snapdom.js +75 -58
- package/snapdom/src/core/cache.js +19 -8
- package/snapdom/src/core/capture.js +49 -48
- package/snapdom/src/core/clone.js +96 -31
- package/snapdom/src/core/prepare.js +43 -37
- package/snapdom/src/modules/background.js +29 -20
- package/snapdom/src/modules/fonts.js +94 -104
- package/snapdom/src/modules/iconFonts.js +28 -0
- package/snapdom/src/modules/images.js +6 -6
- package/snapdom/src/modules/pseudo.js +52 -50
- package/snapdom/src/modules/styles.js +26 -6
- package/snapdom/src/modules/svgDefs.js +26 -0
- package/snapdom/src/utils/cssTools.js +41 -41
- package/snapdom/src/utils/helpers.js +128 -84
- package/tinycolor/index.js +46 -0
- package/tinycolor/src/conversion.js +143 -0
- package/tinycolor/src/css-color-names.js +153 -0
- package/tinycolor/src/format-input.js +77 -0
- package/tinycolor/src/from-ratio.js +21 -0
- package/tinycolor/src/index.js +404 -0
- package/tinycolor/src/random.js +221 -0
- package/tinycolor/src/readability.js +37 -0
- package/tinycolor/src/to-ms-filter.js +15 -0
- package/tinycolor/src/util.js +32 -0
- package/tinycolor.js +46 -0
- package/tree/index.js +10 -8
- package/tree/search/index.js +90 -0
- package/tree.js +9 -7
- package/types/date/index.d.ts +4 -0
- package/types/filesize/src/constants.d.ts +12 -12
- package/types/filesize/src/filesize.d.ts +63 -22
- package/types/index.d.ts +4 -3
- package/types/lunar/index.d.ts +3 -0
- package/types/lunar/lib/Holiday.d.ts +17 -0
- package/types/lunar/lib/HolidayUtil.d.ts +23 -0
- package/types/lunar/lib/I18n.d.ts +23 -0
- package/types/lunar/lib/JieQi.d.ts +15 -0
- package/types/lunar/lib/Lunar.d.ts +245 -0
- package/types/lunar/lib/LunarMonth.d.ts +35 -0
- package/types/lunar/lib/LunarTime.d.ts +40 -0
- package/types/lunar/lib/LunarUtil.d.ts +128 -0
- package/types/lunar/lib/LunarYear.d.ts +61 -0
- package/types/lunar/lib/ShouXingUtil.d.ts +38 -0
- package/types/lunar/lib/Solar.d.ts +51 -0
- package/types/lunar/lib/SolarHalfYear.d.ts +15 -0
- package/types/lunar/lib/SolarMonth.d.ts +16 -0
- package/types/lunar/lib/SolarSeason.d.ts +15 -0
- package/types/lunar/lib/SolarUtil.d.ts +20 -0
- package/types/lunar/lib/SolarWeek.d.ts +23 -0
- package/types/lunar/lib/SolarYear.d.ts +12 -0
- package/types/lunar/lib/index.d.ts +17 -0
- package/types/snapdom/src/core/cache.d.ts +17 -11
- package/types/snapdom/src/core/capture.d.ts +4 -0
- package/types/snapdom/src/core/clone.d.ts +4 -5
- package/types/snapdom/src/core/prepare.d.ts +8 -1
- package/types/snapdom/src/modules/background.d.ts +1 -2
- package/types/snapdom/src/modules/fonts.d.ts +1 -3
- package/types/snapdom/src/modules/iconFonts.d.ts +2 -0
- package/types/snapdom/src/modules/pseudo.d.ts +1 -3
- package/types/snapdom/src/modules/styles.d.ts +1 -10
- package/types/snapdom/src/modules/svgDefs.d.ts +19 -0
- package/types/snapdom/src/utils/cssTools.d.ts +1 -2
- package/types/snapdom/src/utils/helpers.d.ts +1 -1
- package/types/tinycolor/index.d.ts +2 -0
- package/types/tinycolor/src/conversion.d.ts +79 -0
- package/types/tinycolor/src/css-color-names.d.ts +4 -0
- package/types/tinycolor/src/format-input.d.ts +38 -0
- package/types/tinycolor/src/from-ratio.d.ts +14 -0
- package/types/tinycolor/src/index.d.ts +214 -0
- package/types/tinycolor/src/interfaces.d.ts +57 -0
- package/types/tinycolor/src/public_api.d.ts +10 -0
- package/types/tinycolor/src/random.d.ts +24 -0
- package/types/tinycolor/src/readability.d.ts +46 -0
- package/types/tinycolor/src/to-ms-filter.d.ts +5 -0
- package/types/tinycolor/src/umd_api.d.ts +22 -0
- package/types/tinycolor/src/util.d.ts +36 -0
- package/types/tree/index.d.ts +1 -0
- package/types/tree/search/index.d.ts +80 -0
- package/types/ui-color/compareColorByRange.d.ts +2 -0
- package/types/ui-color/index.d.ts +208 -0
- package/ui-color/compareColorByRange.js +9 -0
- package/ui-color/index.js +162 -0
- package/uiColor.js +29 -0
- package/convertTime.js +0 -4
- package/dayjs/index.js +0 -15
- package/dayjs.js +0 -5
- package/lunar-converter/index.js +0 -641
- package/lunarConverter.js +0 -4
- package/search-tree/index.js +0 -54
- package/searchTree.js +0 -4
- package/types/dayjs/index.d.ts +0 -1
- package/types/lunar-converter/index.d.ts +0 -113
- package/types/search-tree/index.d.ts +0 -20
- /package/{convert-time/index.js → date/convertTime.js} +0 -0
- /package/types/{convert-time/index.d.ts → date/convertTime.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cache as r } from "../core/cache.js";
|
|
2
2
|
const d = [
|
|
3
3
|
"div",
|
|
4
4
|
"span",
|
|
@@ -39,12 +39,12 @@ const d = [
|
|
|
39
39
|
"th"
|
|
40
40
|
];
|
|
41
41
|
function u() {
|
|
42
|
-
for (let
|
|
43
|
-
c(
|
|
42
|
+
for (let e of d)
|
|
43
|
+
c(e);
|
|
44
44
|
}
|
|
45
|
-
function c(
|
|
46
|
-
if (r.has(
|
|
47
|
-
return r.get(
|
|
45
|
+
function c(e) {
|
|
46
|
+
if (r.defaultStyle.has(e))
|
|
47
|
+
return r.defaultStyle.get(e);
|
|
48
48
|
if ((/* @__PURE__ */ new Set([
|
|
49
49
|
"script",
|
|
50
50
|
"style",
|
|
@@ -52,54 +52,54 @@ function c(t) {
|
|
|
52
52
|
"link",
|
|
53
53
|
"noscript",
|
|
54
54
|
"template"
|
|
55
|
-
])).has(
|
|
55
|
+
])).has(e)) {
|
|
56
56
|
const o = {};
|
|
57
|
-
return r.set(
|
|
57
|
+
return r.defaultStyle.set(e, o), o;
|
|
58
58
|
}
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
const n = document.createElement(
|
|
62
|
-
n.style.all = "initial",
|
|
63
|
-
const
|
|
64
|
-
for (let o of
|
|
65
|
-
|
|
66
|
-
return
|
|
59
|
+
let t = document.getElementById("snapdom-sandbox");
|
|
60
|
+
t || (t = document.createElement("div"), t.id = "snapdom-sandbox", t.style.position = "absolute", t.style.left = "-9999px", t.style.top = "-9999px", t.style.width = "0", t.style.height = "0", t.style.overflow = "hidden", document.body.appendChild(t));
|
|
61
|
+
const n = document.createElement(e);
|
|
62
|
+
n.style.all = "initial", t.appendChild(n);
|
|
63
|
+
const a = getComputedStyle(n), l = {};
|
|
64
|
+
for (let o of a)
|
|
65
|
+
l[o] = a.getPropertyValue(o);
|
|
66
|
+
return t.removeChild(n), r.defaultStyle.set(e, l), l;
|
|
67
67
|
}
|
|
68
|
-
function p(
|
|
69
|
-
const n = [],
|
|
70
|
-
for (let [
|
|
71
|
-
if (!
|
|
72
|
-
o && n.push(`${
|
|
68
|
+
function p(e, s, t = !1) {
|
|
69
|
+
const n = [], a = c(s);
|
|
70
|
+
for (let [l, o] of Object.entries(e))
|
|
71
|
+
if (!t)
|
|
72
|
+
o && n.push(`${l}:${o}`);
|
|
73
73
|
else {
|
|
74
|
-
const i = l
|
|
75
|
-
o && o !== i && n.push(`${
|
|
74
|
+
const i = a[l];
|
|
75
|
+
o && o !== i && n.push(`${l}:${o}`);
|
|
76
76
|
}
|
|
77
77
|
return n.sort().join(";");
|
|
78
78
|
}
|
|
79
|
-
function y(
|
|
79
|
+
function y(e) {
|
|
80
80
|
const s = /* @__PURE__ */ new Set();
|
|
81
|
-
return
|
|
81
|
+
return e.nodeType !== Node.ELEMENT_NODE && e.nodeType !== Node.DOCUMENT_FRAGMENT_NODE ? [] : (e.tagName && s.add(e.tagName.toLowerCase()), typeof e.querySelectorAll == "function" && e.querySelectorAll("*").forEach((t) => s.add(t.tagName.toLowerCase())), Array.from(s));
|
|
82
82
|
}
|
|
83
|
-
function h(
|
|
83
|
+
function h(e) {
|
|
84
84
|
const s = /* @__PURE__ */ new Map();
|
|
85
|
-
for (let n of
|
|
86
|
-
const
|
|
87
|
-
if (!
|
|
88
|
-
const
|
|
89
|
-
s.has(
|
|
85
|
+
for (let n of e) {
|
|
86
|
+
const a = r.defaultStyle.get(n);
|
|
87
|
+
if (!a) continue;
|
|
88
|
+
const l = Object.entries(a).map(([o, i]) => `${o}:${i};`).sort().join("");
|
|
89
|
+
s.has(l) || s.set(l, []), s.get(l).push(n);
|
|
90
90
|
}
|
|
91
|
-
let
|
|
92
|
-
for (let [n,
|
|
93
|
-
|
|
91
|
+
let t = "";
|
|
92
|
+
for (let [n, a] of s.entries())
|
|
93
|
+
t += `${a.join(",")} { ${n} }
|
|
94
94
|
`;
|
|
95
|
-
return
|
|
95
|
+
return t;
|
|
96
96
|
}
|
|
97
|
-
function m(
|
|
98
|
-
const
|
|
99
|
-
let
|
|
100
|
-
for (const
|
|
101
|
-
|
|
102
|
-
return
|
|
97
|
+
function m() {
|
|
98
|
+
const e = new Set(r.preStyleMap.values()), s = /* @__PURE__ */ new Map();
|
|
99
|
+
let t = 1;
|
|
100
|
+
for (const n of e)
|
|
101
|
+
s.set(n, `c${t++}`);
|
|
102
|
+
return s;
|
|
103
103
|
}
|
|
104
104
|
export {
|
|
105
105
|
y as collectUsedTagNames,
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
async function
|
|
3
|
-
const n = t
|
|
1
|
+
import { cache as s } from "../core/cache.js";
|
|
2
|
+
async function R(t, e = {}) {
|
|
3
|
+
const n = p(t), i = /^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(
|
|
4
4
|
t
|
|
5
5
|
);
|
|
6
6
|
if (n) {
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
if (u.has(i))
|
|
11
|
-
return e.skipInline ? void 0 : `url(${u.get(i)})`;
|
|
7
|
+
const a = h(n);
|
|
8
|
+
if (s.background.has(a))
|
|
9
|
+
return e.skipInline ? void 0 : `url(${s.background.get(a)})`;
|
|
12
10
|
{
|
|
13
|
-
const
|
|
14
|
-
|
|
11
|
+
const c = await w(a, {
|
|
12
|
+
useProxy: e.useProxy
|
|
13
|
+
});
|
|
14
|
+
return s.background.set(a, c), e.skipInline ? void 0 : `url("${c}")`;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
return t;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function S(t, { fast: e = !1 } = {}) {
|
|
20
20
|
if (e) return t();
|
|
21
21
|
"requestIdleCallback" in window ? requestIdleCallback(t, { timeout: 50 }) : setTimeout(t, 1);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function U(t, e = null) {
|
|
24
24
|
if (!(t instanceof Element))
|
|
25
25
|
return window.getComputedStyle(t, e);
|
|
26
|
-
let n =
|
|
27
|
-
if (n || (n = /* @__PURE__ */ new Map(),
|
|
28
|
-
const
|
|
29
|
-
n.set(e,
|
|
26
|
+
let n = s.computedStyle.get(t);
|
|
27
|
+
if (n || (n = /* @__PURE__ */ new Map(), s.computedStyle.set(t, n)), !n.has(e)) {
|
|
28
|
+
const i = window.getComputedStyle(t, e);
|
|
29
|
+
n.set(e, i);
|
|
30
30
|
}
|
|
31
31
|
return n.get(e);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function k(t) {
|
|
34
34
|
let e = t.replace(/^['"]|['"]$/g, "");
|
|
35
35
|
if (e.startsWith("\\"))
|
|
36
36
|
try {
|
|
@@ -40,73 +40,118 @@ function C(t) {
|
|
|
40
40
|
}
|
|
41
41
|
return e;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
const e = t.
|
|
45
|
-
if (e
|
|
46
|
-
|
|
47
|
-
return n.
|
|
48
|
-
}
|
|
49
|
-
function S(t) {
|
|
50
|
-
return [
|
|
51
|
-
/font\s*awesome/i,
|
|
52
|
-
/material\s*icons/i,
|
|
53
|
-
/ionicons/i,
|
|
54
|
-
/glyphicons/i,
|
|
55
|
-
/feather/i,
|
|
56
|
-
/bootstrap\s*icons/i,
|
|
57
|
-
/remix\s*icons/i,
|
|
58
|
-
/heroicons/i,
|
|
59
|
-
/lucide/i
|
|
60
|
-
].some((n) => n.test(t));
|
|
43
|
+
function p(t) {
|
|
44
|
+
const e = t.match(/url\((['"]?)(.*?)(\1)\)/);
|
|
45
|
+
if (!e) return null;
|
|
46
|
+
const n = e[2].trim();
|
|
47
|
+
return n.startsWith("#") ? null : n;
|
|
61
48
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
49
|
+
function w(t, { timeout: e = 3e3, useProxy: n = "" } = {}) {
|
|
50
|
+
function i(l) {
|
|
51
|
+
try {
|
|
52
|
+
return new URL(l, window.location.href).origin === window.location.origin ? "use-credentials" : "anonymous";
|
|
53
|
+
} catch {
|
|
54
|
+
return "anonymous";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function a(l) {
|
|
58
|
+
const u = (d) => fetch(d, {
|
|
59
|
+
mode: "cors",
|
|
60
|
+
credentials: i(d) === "use-credentials" ? "include" : "omit"
|
|
61
|
+
}).then((o) => o.blob()).then(
|
|
62
|
+
(o) => new Promise((r, g) => {
|
|
63
|
+
const m = new FileReader();
|
|
64
|
+
m.onloadend = () => {
|
|
65
|
+
const f = m.result;
|
|
66
|
+
if (typeof f != "string" || !f.startsWith("data:image/")) {
|
|
67
|
+
g(new Error("Invalid image data URL"));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
r(f);
|
|
71
|
+
}, m.onerror = () => g(new Error("FileReader error")), m.readAsDataURL(o);
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
try {
|
|
75
|
+
return await u(l);
|
|
76
|
+
} catch {
|
|
77
|
+
if (n && typeof n == "string") {
|
|
78
|
+
const o = n.replace(/\/$/, "") + h(l);
|
|
73
79
|
try {
|
|
74
|
-
|
|
75
|
-
l.set(t, c), a(c);
|
|
80
|
+
return await u(o);
|
|
76
81
|
} catch {
|
|
77
|
-
|
|
82
|
+
throw new Error(
|
|
83
|
+
"[SnapDOM - fetchImage] CORS restrictions prevented image capture (even via proxy)"
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
} else
|
|
87
|
+
throw new Error(
|
|
88
|
+
"[SnapDOM - fetchImage] Fetch fallback failed and no proxy provided"
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const c = i(t);
|
|
93
|
+
return s.image.has(t) ? Promise.resolve(s.image.get(t)) : t.startsWith("data:image/") ? (s.image.set(t, t), Promise.resolve(t)) : /\.svg(\?.*)?$/i.test(t) ? (async () => {
|
|
94
|
+
try {
|
|
95
|
+
const u = await (await fetch(t, {
|
|
96
|
+
mode: "cors",
|
|
97
|
+
credentials: c === "use-credentials" ? "include" : "omit"
|
|
98
|
+
})).text(), d = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(u)}`;
|
|
99
|
+
return s.image.set(t, d), d;
|
|
100
|
+
} catch {
|
|
101
|
+
return a(t);
|
|
102
|
+
}
|
|
103
|
+
})() : new Promise((l, u) => {
|
|
104
|
+
const d = setTimeout(() => {
|
|
105
|
+
u(new Error("[SnapDOM - fetchImage] Image load timed out"));
|
|
106
|
+
}, e), o = new Image();
|
|
107
|
+
o.crossOrigin = c, o.onload = async () => {
|
|
108
|
+
clearTimeout(d);
|
|
109
|
+
try {
|
|
110
|
+
await o.decode();
|
|
111
|
+
const r = document.createElement("canvas");
|
|
112
|
+
r.width = o.width, r.height = o.height, r.getContext("2d").drawImage(o, 0, 0, r.width, r.height);
|
|
113
|
+
const m = r.toDataURL("image/png");
|
|
114
|
+
s.image.set(t, m), l(m);
|
|
115
|
+
} catch {
|
|
116
|
+
try {
|
|
117
|
+
const r = await a(t);
|
|
118
|
+
s.image.set(t, r), l(r);
|
|
119
|
+
} catch (r) {
|
|
120
|
+
u(r);
|
|
78
121
|
}
|
|
79
|
-
} catch (o) {
|
|
80
|
-
r(o);
|
|
81
122
|
}
|
|
82
|
-
},
|
|
83
|
-
clearTimeout(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
123
|
+
}, o.onerror = async () => {
|
|
124
|
+
clearTimeout(d), console.error(`[SnapDOM - fetchImage] Image failed to load: ${t}`);
|
|
125
|
+
try {
|
|
126
|
+
const r = await a(t);
|
|
127
|
+
s.image.set(t, r), l(r);
|
|
128
|
+
} catch (r) {
|
|
129
|
+
u(r);
|
|
130
|
+
}
|
|
131
|
+
}, o.src = t;
|
|
87
132
|
});
|
|
88
133
|
}
|
|
89
|
-
function
|
|
134
|
+
function C(t) {
|
|
90
135
|
const e = {};
|
|
91
136
|
for (let n of t)
|
|
92
137
|
e[n] = t.getPropertyValue(n);
|
|
93
138
|
return e;
|
|
94
139
|
}
|
|
95
|
-
function
|
|
140
|
+
function v() {
|
|
96
141
|
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
97
142
|
}
|
|
98
|
-
function
|
|
143
|
+
function D(t) {
|
|
99
144
|
if (!t || t === "none") return "";
|
|
100
145
|
let e = t.replace(/translate[XY]?\([^)]*\)/g, "");
|
|
101
|
-
return e = e.replace(/matrix\(([^)]+)\)/g, (n,
|
|
102
|
-
const
|
|
103
|
-
return
|
|
104
|
-
}), e = e.replace(/matrix3d\(([^)]+)\)/g, (n,
|
|
105
|
-
const
|
|
106
|
-
return
|
|
146
|
+
return e = e.replace(/matrix\(([^)]+)\)/g, (n, i) => {
|
|
147
|
+
const a = i.split(",").map((c) => c.trim());
|
|
148
|
+
return a.length !== 6 ? `matrix(${i})` : (a[4] = "0", a[5] = "0", `matrix(${a.join(", ")})`);
|
|
149
|
+
}), e = e.replace(/matrix3d\(([^)]+)\)/g, (n, i) => {
|
|
150
|
+
const a = i.split(",").map((c) => c.trim());
|
|
151
|
+
return a.length !== 16 ? `matrix3d(${i})` : (a[12] = "0", a[13] = "0", `matrix3d(${a.join(", ")})`);
|
|
107
152
|
}), e.trim().replace(/\s{2,}/g, " ");
|
|
108
153
|
}
|
|
109
|
-
function
|
|
154
|
+
function h(t) {
|
|
110
155
|
if (/%[0-9A-Fa-f]{2}/.test(t)) return t;
|
|
111
156
|
try {
|
|
112
157
|
return encodeURI(t);
|
|
@@ -114,26 +159,25 @@ function g(t) {
|
|
|
114
159
|
return t;
|
|
115
160
|
}
|
|
116
161
|
}
|
|
117
|
-
function
|
|
162
|
+
function $(t) {
|
|
118
163
|
const e = [];
|
|
119
|
-
let n = 0,
|
|
120
|
-
for (let
|
|
121
|
-
const
|
|
122
|
-
|
|
164
|
+
let n = 0, i = 0;
|
|
165
|
+
for (let a = 0; a < t.length; a++) {
|
|
166
|
+
const c = t[a];
|
|
167
|
+
c === "(" && n++, c === ")" && n--, c === "," && n === 0 && (e.push(t.slice(i, a).trim()), i = a + 1);
|
|
123
168
|
}
|
|
124
|
-
return e.push(t.slice(
|
|
169
|
+
return e.push(t.slice(i).trim()), e;
|
|
125
170
|
}
|
|
126
171
|
export {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
k as stripTranslate
|
|
172
|
+
p as extractURL,
|
|
173
|
+
w as fetchImage,
|
|
174
|
+
U as getStyle,
|
|
175
|
+
S as idle,
|
|
176
|
+
R as inlineSingleBackgroundEntry,
|
|
177
|
+
v as isSafari,
|
|
178
|
+
k as parseContent,
|
|
179
|
+
h as safeEncodeURI,
|
|
180
|
+
C as snapshotComputedStyle,
|
|
181
|
+
$ as splitBackgroundImage,
|
|
182
|
+
D as stripTranslate
|
|
139
183
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { cmykToRgb as e, convertDecimalToHex as t, convertHexToDecimal as a, hslToRgb as n, hsvToRgb as b, numberInputToObject as m, parseIntFromHex as T, rgbToCmyk as i, rgbToHex as g, rgbToHsl as p, rgbToHsv as l, rgbToRgb as s, rgbaToArgbHex as x, rgbaToHex as c } from "./src/conversion.js";
|
|
2
|
+
import { names as f } from "./src/css-color-names.js";
|
|
3
|
+
import { inputToRGB as u, isValidCSSUnit as H, stringInputToObject as y } from "./src/format-input.js";
|
|
4
|
+
import { fromRatio as C, legacyRandom as h } from "./src/from-ratio.js";
|
|
5
|
+
import { TinyColor as O, TinyColor as P } from "./src/index.js";
|
|
6
|
+
import { bounds as k, random as A } from "./src/random.js";
|
|
7
|
+
import { isReadable as F, mostReadable as S, readability as B } from "./src/readability.js";
|
|
8
|
+
import { toMsFilter as M } from "./src/to-ms-filter.js";
|
|
9
|
+
import { bound01 as V, boundAlpha as Z, clamp01 as q, convertToPercentage as w, isOnePointZero as z, isPercentage as E, pad2 as J } from "./src/util.js";
|
|
10
|
+
export {
|
|
11
|
+
O as TinyColor,
|
|
12
|
+
V as bound01,
|
|
13
|
+
Z as boundAlpha,
|
|
14
|
+
k as bounds,
|
|
15
|
+
q as clamp01,
|
|
16
|
+
e as cmykToRgb,
|
|
17
|
+
t as convertDecimalToHex,
|
|
18
|
+
a as convertHexToDecimal,
|
|
19
|
+
w as convertToPercentage,
|
|
20
|
+
P as default,
|
|
21
|
+
C as fromRatio,
|
|
22
|
+
n as hslToRgb,
|
|
23
|
+
b as hsvToRgb,
|
|
24
|
+
u as inputToRGB,
|
|
25
|
+
z as isOnePointZero,
|
|
26
|
+
E as isPercentage,
|
|
27
|
+
F as isReadable,
|
|
28
|
+
H as isValidCSSUnit,
|
|
29
|
+
h as legacyRandom,
|
|
30
|
+
S as mostReadable,
|
|
31
|
+
f as names,
|
|
32
|
+
m as numberInputToObject,
|
|
33
|
+
J as pad2,
|
|
34
|
+
T as parseIntFromHex,
|
|
35
|
+
A as random,
|
|
36
|
+
B as readability,
|
|
37
|
+
i as rgbToCmyk,
|
|
38
|
+
g as rgbToHex,
|
|
39
|
+
p as rgbToHsl,
|
|
40
|
+
l as rgbToHsv,
|
|
41
|
+
s as rgbToRgb,
|
|
42
|
+
x as rgbaToArgbHex,
|
|
43
|
+
c as rgbaToHex,
|
|
44
|
+
y as stringInputToObject,
|
|
45
|
+
M as toMsFilter
|
|
46
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { bound01 as s, pad2 as h } from "./util.js";
|
|
2
|
+
function A(n, r, t) {
|
|
3
|
+
return {
|
|
4
|
+
r: s(n, 255) * 255,
|
|
5
|
+
g: s(r, 255) * 255,
|
|
6
|
+
b: s(t, 255) * 255
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function T(n, r, t) {
|
|
10
|
+
n = s(n, 255), r = s(r, 255), t = s(t, 255);
|
|
11
|
+
const e = Math.max(n, r, t), c = Math.min(n, r, t);
|
|
12
|
+
let o = 0, a = 0;
|
|
13
|
+
const i = (e + c) / 2;
|
|
14
|
+
if (e === c)
|
|
15
|
+
a = 0, o = 0;
|
|
16
|
+
else {
|
|
17
|
+
const u = e - c;
|
|
18
|
+
switch (a = i > 0.5 ? u / (2 - e - c) : u / (e + c), e) {
|
|
19
|
+
case n:
|
|
20
|
+
o = (r - t) / u + (r < t ? 6 : 0);
|
|
21
|
+
break;
|
|
22
|
+
case r:
|
|
23
|
+
o = (t - n) / u + 2;
|
|
24
|
+
break;
|
|
25
|
+
case t:
|
|
26
|
+
o = (n - r) / u + 4;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
o /= 6;
|
|
30
|
+
}
|
|
31
|
+
return { h: o, s: a, l: i };
|
|
32
|
+
}
|
|
33
|
+
function M(n, r, t) {
|
|
34
|
+
return t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? n + (r - n) * (6 * t) : t < 1 / 2 ? r : t < 2 / 3 ? n + (r - n) * (2 / 3 - t) * 6 : n;
|
|
35
|
+
}
|
|
36
|
+
function k(n, r, t) {
|
|
37
|
+
let e, c, o;
|
|
38
|
+
if (n = s(n, 360), r = s(r, 100), t = s(t, 100), r === 0)
|
|
39
|
+
c = t, o = t, e = t;
|
|
40
|
+
else {
|
|
41
|
+
const a = t < 0.5 ? t * (1 + r) : t + r - t * r, i = 2 * t - a;
|
|
42
|
+
e = M(i, a, n + 1 / 3), c = M(i, a, n), o = M(i, a, n - 1 / 3);
|
|
43
|
+
}
|
|
44
|
+
return { r: e * 255, g: c * 255, b: o * 255 };
|
|
45
|
+
}
|
|
46
|
+
function l(n, r, t) {
|
|
47
|
+
n = s(n, 255), r = s(r, 255), t = s(t, 255);
|
|
48
|
+
const e = Math.max(n, r, t), c = Math.min(n, r, t);
|
|
49
|
+
let o = 0;
|
|
50
|
+
const a = e, i = e - c, u = e === 0 ? 0 : i / e;
|
|
51
|
+
if (e === c)
|
|
52
|
+
o = 0;
|
|
53
|
+
else {
|
|
54
|
+
switch (e) {
|
|
55
|
+
case n:
|
|
56
|
+
o = (r - t) / i + (r < t ? 6 : 0);
|
|
57
|
+
break;
|
|
58
|
+
case r:
|
|
59
|
+
o = (t - n) / i + 2;
|
|
60
|
+
break;
|
|
61
|
+
case t:
|
|
62
|
+
o = (n - r) / i + 4;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
o /= 6;
|
|
66
|
+
}
|
|
67
|
+
return { h: o, s: u, v: a };
|
|
68
|
+
}
|
|
69
|
+
function S(n, r, t) {
|
|
70
|
+
n = s(n, 360) * 6, r = s(r, 100), t = s(t, 100);
|
|
71
|
+
const e = Math.floor(n), c = n - e, o = t * (1 - r), a = t * (1 - c * r), i = t * (1 - (1 - c) * r), u = e % 6, f = [t, a, o, o, i, t][u], m = [i, t, t, a, o, o][u], g = [o, o, i, t, t, a][u];
|
|
72
|
+
return { r: f * 255, g: m * 255, b: g * 255 };
|
|
73
|
+
}
|
|
74
|
+
function H(n, r, t, e) {
|
|
75
|
+
const c = [
|
|
76
|
+
h(Math.round(n).toString(16)),
|
|
77
|
+
h(Math.round(r).toString(16)),
|
|
78
|
+
h(Math.round(t).toString(16))
|
|
79
|
+
];
|
|
80
|
+
return e && c[0].startsWith(c[0].charAt(1)) && c[1].startsWith(c[1].charAt(1)) && c[2].startsWith(c[2].charAt(1)) ? c[0].charAt(0) + c[1].charAt(0) + c[2].charAt(0) : c.join("");
|
|
81
|
+
}
|
|
82
|
+
function W(n, r, t, e, c) {
|
|
83
|
+
const o = [
|
|
84
|
+
h(Math.round(n).toString(16)),
|
|
85
|
+
h(Math.round(r).toString(16)),
|
|
86
|
+
h(Math.round(t).toString(16)),
|
|
87
|
+
h(d(e))
|
|
88
|
+
];
|
|
89
|
+
return c && o[0].startsWith(o[0].charAt(1)) && o[1].startsWith(o[1].charAt(1)) && o[2].startsWith(o[2].charAt(1)) && o[3].startsWith(o[3].charAt(1)) ? o[0].charAt(0) + o[1].charAt(0) + o[2].charAt(0) + o[3].charAt(0) : o.join("");
|
|
90
|
+
}
|
|
91
|
+
function p(n, r, t, e) {
|
|
92
|
+
return [
|
|
93
|
+
h(d(e)),
|
|
94
|
+
h(Math.round(n).toString(16)),
|
|
95
|
+
h(Math.round(r).toString(16)),
|
|
96
|
+
h(Math.round(t).toString(16))
|
|
97
|
+
].join("");
|
|
98
|
+
}
|
|
99
|
+
function y(n, r, t, e) {
|
|
100
|
+
const c = n / 100, o = r / 100, a = t / 100, i = e / 100, u = 255 * (1 - c) * (1 - i), f = 255 * (1 - o) * (1 - i), m = 255 * (1 - a) * (1 - i);
|
|
101
|
+
return { r: u, g: f, b: m };
|
|
102
|
+
}
|
|
103
|
+
function C(n, r, t) {
|
|
104
|
+
let e = 1 - n / 255, c = 1 - r / 255, o = 1 - t / 255, a = Math.min(e, c, o);
|
|
105
|
+
return a === 1 ? (e = 0, c = 0, o = 0) : (e = (e - a) / (1 - a) * 100, c = (c - a) / (1 - a) * 100, o = (o - a) / (1 - a) * 100), a *= 100, {
|
|
106
|
+
c: Math.round(e),
|
|
107
|
+
m: Math.round(c),
|
|
108
|
+
y: Math.round(o),
|
|
109
|
+
k: Math.round(a)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function d(n) {
|
|
113
|
+
return Math.round(parseFloat(n) * 255).toString(16);
|
|
114
|
+
}
|
|
115
|
+
function j(n) {
|
|
116
|
+
return b(n) / 255;
|
|
117
|
+
}
|
|
118
|
+
function b(n) {
|
|
119
|
+
return parseInt(n, 16);
|
|
120
|
+
}
|
|
121
|
+
function R(n) {
|
|
122
|
+
return {
|
|
123
|
+
r: n >> 16,
|
|
124
|
+
g: (n & 65280) >> 8,
|
|
125
|
+
b: n & 255
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export {
|
|
129
|
+
y as cmykToRgb,
|
|
130
|
+
d as convertDecimalToHex,
|
|
131
|
+
j as convertHexToDecimal,
|
|
132
|
+
k as hslToRgb,
|
|
133
|
+
S as hsvToRgb,
|
|
134
|
+
R as numberInputToObject,
|
|
135
|
+
b as parseIntFromHex,
|
|
136
|
+
C as rgbToCmyk,
|
|
137
|
+
H as rgbToHex,
|
|
138
|
+
T as rgbToHsl,
|
|
139
|
+
l as rgbToHsv,
|
|
140
|
+
A as rgbToRgb,
|
|
141
|
+
p as rgbaToArgbHex,
|
|
142
|
+
W as rgbaToHex
|
|
143
|
+
};
|