@unicom-cloud/utils 0.1.10 → 0.1.12
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/caseName.js +11 -0
- package/className.js +5 -0
- package/clipboardCopy.js +6 -0
- package/constant.js +4 -0
- package/contentDisposition.js +7 -0
- package/cookie.js +7 -0
- package/date/convertTime.js +61 -0
- package/date/index.js +22 -0
- package/date.js +9 -0
- package/decimal.js +5 -0
- package/eventEmitter.js +4 -0
- package/file.js +6 -0
- package/filesize.js +8 -0
- package/index.js +56 -46
- package/invariant.js +4 -0
- package/is.js +92 -0
- 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/math.js +9 -0
- package/md5.js +4 -0
- package/mock.js +8 -0
- package/normalizeWheel.js +6 -0
- package/number-to-chinese/index.js +72 -0
- package/numberToChinese.js +4 -0
- package/nzh.js +4 -0
- package/object-keys-sort/index.js +7 -0
- package/objectKeysSort.js +2 -5
- package/package.json +1 -1
- package/random.js +15 -0
- package/screenfull.js +4 -0
- package/snapdom/src/api/preCache.js +26 -36
- package/snapdom/src/api/snapdom.js +78 -61
- package/snapdom/src/core/capture.js +54 -54
- package/snapdom/src/core/prepare.js +46 -37
- package/snapdom/src/modules/fonts.js +90 -92
- package/snapdom/src/modules/iconFonts.js +28 -0
- package/snapdom/src/modules/images.js +6 -6
- package/snapdom/src/modules/pseudo.js +51 -49
- package/snapdom/src/modules/styles.js +27 -7
- package/snapdom/src/modules/svgDefs.js +26 -0
- package/snapdom/src/utils/helpers.js +150 -103
- package/snapdom.js +6 -0
- 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/searchTree.js +54 -0
- package/tree.js +13 -0
- package/turboStream.js +6 -0
- package/types/case-name/index.d.ts +11 -0
- package/types/class-name/index.d.ts +2 -0
- package/types/clipboard-copy/index.d.ts +2 -0
- package/types/constant/address.d.ts +14 -0
- package/types/constant/chineseCharacters.d.ts +2 -0
- package/types/constant/constellations.d.ts +2 -0
- package/types/constant/domain.d.ts +2 -0
- package/types/constant/identity.d.ts +2 -0
- package/types/constant/index.d.ts +1 -0
- package/types/constant/keyboardCode.d.ts +158 -0
- package/types/constant/licensePlate.d.ts +2 -0
- package/types/constant/name.d.ts +4 -0
- package/types/constant/platform.d.ts +11 -0
- package/types/constant/protocol.d.ts +2 -0
- package/types/constant/ui.d.ts +14 -0
- package/types/content-disposition/index.d.ts +10 -0
- package/types/cookie/index.d.ts +4 -0
- package/types/cookie/src/index.d.ts +114 -0
- package/types/date/convertTime.d.ts +32 -0
- package/types/date/index.d.ts +4 -0
- package/types/decimal/decimal.d.ts +4 -0
- package/types/decimal/index.d.ts +1 -0
- package/types/event-emitter/index.d.ts +17 -0
- package/types/file/fileToURL.d.ts +2 -0
- package/types/file/index.d.ts +3 -0
- package/types/file/saveAs.d.ts +2 -0
- package/types/filesize/index.d.ts +2 -0
- package/types/filesize/src/constants.d.ts +42 -0
- package/types/filesize/src/filesize.d.ts +47 -0
- package/types/index.d.ts +25 -0
- package/types/invariant/index.d.ts +2 -0
- package/types/is/index.d.ts +53 -0
- 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/math/index.d.ts +11 -0
- package/types/md5/index.d.ts +2 -0
- package/types/mock/MockWebSocket.d.ts +17 -0
- package/types/mock/MockXMLHttpRequest.d.ts +17 -0
- package/types/mock/index.d.ts +2 -0
- package/types/normalize-wheel/ExecutionEnvironment.d.ts +9 -0
- package/types/normalize-wheel/UserAgent_DEPRECATED.d.ts +86 -0
- package/types/normalize-wheel/index.d.ts +115 -0
- package/types/normalize-wheel/isEventSupported.d.ts +16 -0
- package/types/number-to-chinese/index.d.ts +11 -0
- package/types/nzh/cn.d.ts +8 -0
- package/types/nzh/hk.d.ts +8 -0
- package/types/nzh/index.d.ts +1 -0
- package/types/nzh/nzh.d.ts +36 -0
- package/types/nzh/src/autoGet.d.ts +8 -0
- package/types/nzh/src/index.d.ts +34 -0
- package/types/nzh/src/langs/cn_b.d.ts +10 -0
- package/types/nzh/src/langs/cn_s.d.ts +7 -0
- package/types/nzh/src/langs/hk_b.d.ts +10 -0
- package/types/nzh/src/langs/hk_s.d.ts +7 -0
- package/types/nzh/src/utils.d.ts +65 -0
- package/types/object-keys-sort/index.d.ts +4 -0
- package/types/random/address.d.ts +8 -0
- package/types/random/constellation.d.ts +2 -0
- package/types/random/image.d.ts +5 -0
- package/types/random/index.d.ts +40 -0
- package/types/random/licensePlate.d.ts +2 -0
- package/types/random/name.d.ts +9 -0
- package/types/random/number.d.ts +6 -0
- package/types/random/text.d.ts +13 -0
- package/types/random/time.d.ts +2 -0
- package/types/random/web.d.ts +11 -0
- package/types/screenfull/index.d.ts +10 -0
- package/types/snapdom/index.d.ts +1 -0
- package/types/snapdom/src/api/preCache.d.ts +8 -0
- package/types/snapdom/src/api/snapdom.d.ts +26 -0
- package/types/snapdom/src/core/cache.d.ts +11 -0
- package/types/snapdom/src/core/capture.d.ts +17 -0
- package/types/snapdom/src/core/clone.d.ts +11 -0
- package/types/snapdom/src/core/prepare.d.ts +8 -0
- package/types/snapdom/src/index.browser.d.ts +1 -0
- package/types/snapdom/src/index.d.ts +2 -0
- package/types/snapdom/src/modules/background.d.ts +10 -0
- package/types/snapdom/src/modules/fonts.d.ts +23 -0
- package/types/snapdom/src/modules/iconFonts.d.ts +2 -0
- package/types/snapdom/src/modules/images.d.ts +8 -0
- package/types/snapdom/src/modules/pseudo.d.ts +12 -0
- package/types/snapdom/src/modules/styles.d.ts +1 -0
- package/types/snapdom/src/modules/svgDefs.d.ts +19 -0
- package/types/snapdom/src/utils/cssTools.d.ts +38 -0
- package/types/snapdom/src/utils/helpers.d.ts +71 -0
- 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 +9 -0
- package/types/tree/searchTree.d.ts +20 -0
- package/types/turbo-stream/index.d.ts +1 -0
- package/types/turbo-stream/src/decode.d.ts +7 -0
- package/types/turbo-stream/src/encode.d.ts +27 -0
- package/types/turbo-stream/src/shared.d.ts +107 -0
- package/types/turbo-stream/src/turbo-stream.d.ts +4 -0
- package/types/ui-color/compareColorByRange.d.ts +2 -0
- package/types/ui-color/index.d.ts +183 -0
- package/types/url-toolkit/index.d.ts +2 -0
- package/types/url-toolkit/src/url-toolkit.d.ts +18 -0
- package/ui-color/compareColorByRange.js +9 -0
- package/ui-color/index.js +155 -0
- package/uiColor.js +28 -0
- package/urlToolkit.js +8 -0
- package/dayjs/index.js +0 -15
|
@@ -1,139 +1,186 @@
|
|
|
1
|
-
import { imageCache as
|
|
2
|
-
async function
|
|
3
|
-
const
|
|
4
|
-
|
|
1
|
+
import { imageCache as f, computedStyleCache as p, bgCache as m } from "../core/cache.js";
|
|
2
|
+
async function x(e, t = {}) {
|
|
3
|
+
const r = e.startsWith("url("), i = /^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(
|
|
4
|
+
e
|
|
5
5
|
);
|
|
6
|
-
if (
|
|
7
|
-
const
|
|
8
|
-
if (!
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
11
|
-
return
|
|
6
|
+
if (r) {
|
|
7
|
+
const n = I(e);
|
|
8
|
+
if (!n) return e;
|
|
9
|
+
const a = w(n);
|
|
10
|
+
if (m.has(a))
|
|
11
|
+
return t.skipInline ? void 0 : `url(${m.get(a)})`;
|
|
12
12
|
{
|
|
13
|
-
const s =
|
|
14
|
-
|
|
13
|
+
const s = await y(a, {
|
|
14
|
+
useProxy: t.useProxy
|
|
15
|
+
});
|
|
16
|
+
return m.set(a, s), t.skipInline ? void 0 : `url(${s})`;
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
|
-
return
|
|
19
|
+
return e;
|
|
18
20
|
}
|
|
19
|
-
function
|
|
20
|
-
if (
|
|
21
|
-
"requestIdleCallback" in window ? requestIdleCallback(
|
|
21
|
+
function $(e, { fast: t = !1 } = {}) {
|
|
22
|
+
if (t) return e();
|
|
23
|
+
"requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 50 }) : setTimeout(e, 1);
|
|
22
24
|
}
|
|
23
|
-
function
|
|
24
|
-
if (!(
|
|
25
|
-
return window.getComputedStyle(
|
|
26
|
-
let
|
|
27
|
-
if (
|
|
28
|
-
const
|
|
29
|
-
|
|
25
|
+
function O(e, t = null) {
|
|
26
|
+
if (!(e instanceof Element))
|
|
27
|
+
return window.getComputedStyle(e, t);
|
|
28
|
+
let r = p.get(e);
|
|
29
|
+
if (r || (r = /* @__PURE__ */ new Map(), p.set(e, r)), !r.has(t)) {
|
|
30
|
+
const i = window.getComputedStyle(e, t);
|
|
31
|
+
r.set(t, i);
|
|
30
32
|
}
|
|
31
|
-
return
|
|
33
|
+
return r.get(t);
|
|
32
34
|
}
|
|
33
|
-
function C(
|
|
34
|
-
let
|
|
35
|
-
if (
|
|
35
|
+
function C(e) {
|
|
36
|
+
let t = e.replace(/^['"]|['"]$/g, "");
|
|
37
|
+
if (t.startsWith("\\"))
|
|
36
38
|
try {
|
|
37
|
-
return String.fromCharCode(parseInt(
|
|
39
|
+
return String.fromCharCode(parseInt(t.replace("\\", ""), 16));
|
|
38
40
|
} catch {
|
|
39
|
-
return
|
|
41
|
+
return t;
|
|
40
42
|
}
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
function d(t) {
|
|
44
|
-
const e = t.indexOf("url(");
|
|
45
|
-
if (e === -1) return null;
|
|
46
|
-
let n = t.slice(e + 4).trim();
|
|
47
|
-
return n.endsWith(")") && (n = n.slice(0, -1).trim()), (n.startsWith('"') && n.endsWith('"') || n.startsWith("'") && n.endsWith("'")) && (n = n.slice(1, -1)), n;
|
|
43
|
+
return t;
|
|
48
44
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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));
|
|
45
|
+
function I(e) {
|
|
46
|
+
const t = e.indexOf("url(");
|
|
47
|
+
if (t === -1) return null;
|
|
48
|
+
let r = e.slice(t + 4).trim();
|
|
49
|
+
return r.endsWith(")") && (r = r.slice(0, -1).trim()), (r.startsWith('"') && r.endsWith('"') || r.startsWith("'") && r.endsWith("'")) && (r = r.slice(1, -1)), r;
|
|
61
50
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
function y(e, { timeout: t = 3e3, useProxy: r = "" }) {
|
|
52
|
+
function i(a) {
|
|
53
|
+
try {
|
|
54
|
+
return new URL(a, window.location.href).origin === window.location.origin ? "use-credentials" : "anonymous";
|
|
55
|
+
} catch {
|
|
56
|
+
return "anonymous";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const n = i(e);
|
|
60
|
+
return console.log(
|
|
61
|
+
`[SnapDOM - fetchImage] Start loading image: ${e} with crossOrigin=${n}`
|
|
62
|
+
), f.has(e) ? (console.log(`[SnapDOM - fetchImage] Cache hit for: ${e}`), Promise.resolve(f.get(e))) : new Promise((a, s) => {
|
|
63
|
+
const h = setTimeout(() => {
|
|
64
|
+
console.log(
|
|
65
|
+
`[SnapDOM - fetchImage] Timeout after ${t}ms for image: ${e}`
|
|
66
|
+
), s(new Error("Image load timed out"));
|
|
67
|
+
}, t), g = () => {
|
|
68
|
+
console.warn(`[SnapDOM - fetchImage] Trying fetch fallback for: ${e}`), fetch(e, {
|
|
69
|
+
mode: "cors",
|
|
70
|
+
credentials: n === "use-credentials" ? "include" : "omit"
|
|
71
|
+
}).then((o) => (console.log(
|
|
72
|
+
`[SnapDOM - fetchImage] Fetch response received for: ${e}`
|
|
73
|
+
), o.blob())).then((o) => {
|
|
74
|
+
const d = new FileReader();
|
|
75
|
+
d.onloadend = () => {
|
|
76
|
+
const c = d.result;
|
|
77
|
+
if (typeof c == "string" && c.startsWith("data:application/octet-stream")) {
|
|
78
|
+
s(new Error("Image response was empty or blocked"));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
f.set(e, c), a(c);
|
|
82
|
+
}, d.readAsDataURL(o);
|
|
83
|
+
}).catch(() => {
|
|
84
|
+
if (console.warn(
|
|
85
|
+
`[SnapDOM - fetchImage] Fetch fallback failed for: ${e}`
|
|
86
|
+
), r !== "") {
|
|
87
|
+
const o = typeof r == "string" ? r.replace(/\/$/, "") + w(e) : null;
|
|
88
|
+
o ? (console.log(
|
|
89
|
+
`[SnapDOM - fetchImage] Trying proxy fallback: ${o}`
|
|
90
|
+
), fetch(o).then((d) => d.blob()).then((d) => {
|
|
91
|
+
const c = new FileReader();
|
|
92
|
+
c.onloadend = () => {
|
|
93
|
+
const u = c.result;
|
|
94
|
+
if (typeof u == "string" && u.startsWith("data:application/octet-stream")) {
|
|
95
|
+
s(new Error("Image response was empty or blocked"));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
f.set(e, u), a(u);
|
|
99
|
+
}, c.readAsDataURL(d);
|
|
100
|
+
}).catch(() => {
|
|
101
|
+
console.error(
|
|
102
|
+
`[SnapDOM - fetchImage] Proxy fallback failed for: ${e}`
|
|
103
|
+
), s(
|
|
104
|
+
new Error(
|
|
105
|
+
"CORS restrictions prevented image capture (even via proxy)"
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
})) : console.error(
|
|
109
|
+
`[SnapDOM - fetchImage] Provide a valid proxy url: ${e}`
|
|
110
|
+
);
|
|
111
|
+
} else
|
|
112
|
+
console.error(
|
|
113
|
+
'[SnapDOM - fetchImage] You may try add a proxy "useProxy: url" '
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
}, l = new Image();
|
|
117
|
+
l.crossOrigin = n, l.onload = async () => {
|
|
118
|
+
clearTimeout(h);
|
|
69
119
|
try {
|
|
70
|
-
await
|
|
120
|
+
await l.decode();
|
|
71
121
|
const o = document.createElement("canvas");
|
|
72
|
-
o.width =
|
|
122
|
+
o.width = l.width, o.height = l.height, o.getContext("2d").drawImage(l, 0, 0, o.width, o.height);
|
|
73
123
|
try {
|
|
74
124
|
const c = o.toDataURL("image/png");
|
|
75
|
-
|
|
125
|
+
f.set(e, c), a(c);
|
|
76
126
|
} catch {
|
|
77
|
-
|
|
127
|
+
g();
|
|
78
128
|
}
|
|
79
|
-
} catch
|
|
80
|
-
|
|
129
|
+
} catch {
|
|
130
|
+
g();
|
|
81
131
|
}
|
|
82
|
-
},
|
|
83
|
-
clearTimeout(
|
|
84
|
-
|
|
85
|
-
);
|
|
86
|
-
}, s.src = t;
|
|
132
|
+
}, l.onerror = (o) => {
|
|
133
|
+
clearTimeout(h), console.error(`[SnapDOM - fetchImage] Image failed to load: ${e}`, o), g();
|
|
134
|
+
}, l.src = e;
|
|
87
135
|
});
|
|
88
136
|
}
|
|
89
|
-
function
|
|
90
|
-
const
|
|
91
|
-
for (let
|
|
92
|
-
|
|
93
|
-
return
|
|
137
|
+
function D(e) {
|
|
138
|
+
const t = {};
|
|
139
|
+
for (let r of e)
|
|
140
|
+
t[r] = e.getPropertyValue(r);
|
|
141
|
+
return t;
|
|
94
142
|
}
|
|
95
|
-
function
|
|
143
|
+
function b() {
|
|
96
144
|
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
97
145
|
}
|
|
98
|
-
function k(
|
|
99
|
-
if (!
|
|
100
|
-
let
|
|
101
|
-
return
|
|
102
|
-
const
|
|
103
|
-
return
|
|
104
|
-
}),
|
|
105
|
-
const
|
|
106
|
-
return
|
|
107
|
-
}),
|
|
146
|
+
function k(e) {
|
|
147
|
+
if (!e || e === "none") return "";
|
|
148
|
+
let t = e.replace(/translate[XY]?\([^)]*\)/g, "");
|
|
149
|
+
return t = t.replace(/matrix\(([^)]+)\)/g, (r, i) => {
|
|
150
|
+
const n = i.split(",").map((a) => a.trim());
|
|
151
|
+
return n.length !== 6 ? `matrix(${i})` : (n[4] = "0", n[5] = "0", `matrix(${n.join(", ")})`);
|
|
152
|
+
}), t = t.replace(/matrix3d\(([^)]+)\)/g, (r, i) => {
|
|
153
|
+
const n = i.split(",").map((a) => a.trim());
|
|
154
|
+
return n.length !== 16 ? `matrix3d(${i})` : (n[12] = "0", n[13] = "0", `matrix3d(${n.join(", ")})`);
|
|
155
|
+
}), t.trim().replace(/\s{2,}/g, " ");
|
|
108
156
|
}
|
|
109
|
-
function
|
|
110
|
-
if (/%[0-9A-Fa-f]{2}/.test(
|
|
157
|
+
function w(e) {
|
|
158
|
+
if (/%[0-9A-Fa-f]{2}/.test(e)) return e;
|
|
111
159
|
try {
|
|
112
|
-
return encodeURI(
|
|
160
|
+
return encodeURI(e);
|
|
113
161
|
} catch {
|
|
114
|
-
return
|
|
162
|
+
return e;
|
|
115
163
|
}
|
|
116
164
|
}
|
|
117
|
-
function
|
|
118
|
-
const
|
|
119
|
-
let
|
|
120
|
-
for (let
|
|
121
|
-
const
|
|
122
|
-
|
|
165
|
+
function M(e) {
|
|
166
|
+
const t = [];
|
|
167
|
+
let r = 0, i = 0;
|
|
168
|
+
for (let n = 0; n < e.length; n++) {
|
|
169
|
+
const a = e[n];
|
|
170
|
+
a === "(" && r++, a === ")" && r--, a === "," && r === 0 && (t.push(e.slice(i, n).trim()), i = n + 1);
|
|
123
171
|
}
|
|
124
|
-
return
|
|
172
|
+
return t.push(e.slice(i).trim()), t;
|
|
125
173
|
}
|
|
126
174
|
export {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
y as isSafari,
|
|
175
|
+
I as extractURL,
|
|
176
|
+
y as fetchImage,
|
|
177
|
+
O as getStyle,
|
|
178
|
+
$ as idle,
|
|
179
|
+
x as inlineSingleBackgroundEntry,
|
|
180
|
+
b as isSafari,
|
|
134
181
|
C as parseContent,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
182
|
+
w as safeEncodeURI,
|
|
183
|
+
D as snapshotComputedStyle,
|
|
184
|
+
M as splitBackgroundImage,
|
|
138
185
|
k as stripTranslate
|
|
139
186
|
};
|
package/snapdom.js
ADDED
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
aliceblue: "#f0f8ff",
|
|
3
|
+
antiquewhite: "#faebd7",
|
|
4
|
+
aqua: "#00ffff",
|
|
5
|
+
aquamarine: "#7fffd4",
|
|
6
|
+
azure: "#f0ffff",
|
|
7
|
+
beige: "#f5f5dc",
|
|
8
|
+
bisque: "#ffe4c4",
|
|
9
|
+
black: "#000000",
|
|
10
|
+
blanchedalmond: "#ffebcd",
|
|
11
|
+
blue: "#0000ff",
|
|
12
|
+
blueviolet: "#8a2be2",
|
|
13
|
+
brown: "#a52a2a",
|
|
14
|
+
burlywood: "#deb887",
|
|
15
|
+
cadetblue: "#5f9ea0",
|
|
16
|
+
chartreuse: "#7fff00",
|
|
17
|
+
chocolate: "#d2691e",
|
|
18
|
+
coral: "#ff7f50",
|
|
19
|
+
cornflowerblue: "#6495ed",
|
|
20
|
+
cornsilk: "#fff8dc",
|
|
21
|
+
crimson: "#dc143c",
|
|
22
|
+
cyan: "#00ffff",
|
|
23
|
+
darkblue: "#00008b",
|
|
24
|
+
darkcyan: "#008b8b",
|
|
25
|
+
darkgoldenrod: "#b8860b",
|
|
26
|
+
darkgray: "#a9a9a9",
|
|
27
|
+
darkgreen: "#006400",
|
|
28
|
+
darkgrey: "#a9a9a9",
|
|
29
|
+
darkkhaki: "#bdb76b",
|
|
30
|
+
darkmagenta: "#8b008b",
|
|
31
|
+
darkolivegreen: "#556b2f",
|
|
32
|
+
darkorange: "#ff8c00",
|
|
33
|
+
darkorchid: "#9932cc",
|
|
34
|
+
darkred: "#8b0000",
|
|
35
|
+
darksalmon: "#e9967a",
|
|
36
|
+
darkseagreen: "#8fbc8f",
|
|
37
|
+
darkslateblue: "#483d8b",
|
|
38
|
+
darkslategray: "#2f4f4f",
|
|
39
|
+
darkslategrey: "#2f4f4f",
|
|
40
|
+
darkturquoise: "#00ced1",
|
|
41
|
+
darkviolet: "#9400d3",
|
|
42
|
+
deeppink: "#ff1493",
|
|
43
|
+
deepskyblue: "#00bfff",
|
|
44
|
+
dimgray: "#696969",
|
|
45
|
+
dimgrey: "#696969",
|
|
46
|
+
dodgerblue: "#1e90ff",
|
|
47
|
+
firebrick: "#b22222",
|
|
48
|
+
floralwhite: "#fffaf0",
|
|
49
|
+
forestgreen: "#228b22",
|
|
50
|
+
fuchsia: "#ff00ff",
|
|
51
|
+
gainsboro: "#dcdcdc",
|
|
52
|
+
ghostwhite: "#f8f8ff",
|
|
53
|
+
goldenrod: "#daa520",
|
|
54
|
+
gold: "#ffd700",
|
|
55
|
+
gray: "#808080",
|
|
56
|
+
green: "#008000",
|
|
57
|
+
greenyellow: "#adff2f",
|
|
58
|
+
grey: "#808080",
|
|
59
|
+
honeydew: "#f0fff0",
|
|
60
|
+
hotpink: "#ff69b4",
|
|
61
|
+
indianred: "#cd5c5c",
|
|
62
|
+
indigo: "#4b0082",
|
|
63
|
+
ivory: "#fffff0",
|
|
64
|
+
khaki: "#f0e68c",
|
|
65
|
+
lavenderblush: "#fff0f5",
|
|
66
|
+
lavender: "#e6e6fa",
|
|
67
|
+
lawngreen: "#7cfc00",
|
|
68
|
+
lemonchiffon: "#fffacd",
|
|
69
|
+
lightblue: "#add8e6",
|
|
70
|
+
lightcoral: "#f08080",
|
|
71
|
+
lightcyan: "#e0ffff",
|
|
72
|
+
lightgoldenrodyellow: "#fafad2",
|
|
73
|
+
lightgray: "#d3d3d3",
|
|
74
|
+
lightgreen: "#90ee90",
|
|
75
|
+
lightgrey: "#d3d3d3",
|
|
76
|
+
lightpink: "#ffb6c1",
|
|
77
|
+
lightsalmon: "#ffa07a",
|
|
78
|
+
lightseagreen: "#20b2aa",
|
|
79
|
+
lightskyblue: "#87cefa",
|
|
80
|
+
lightslategray: "#778899",
|
|
81
|
+
lightslategrey: "#778899",
|
|
82
|
+
lightsteelblue: "#b0c4de",
|
|
83
|
+
lightyellow: "#ffffe0",
|
|
84
|
+
lime: "#00ff00",
|
|
85
|
+
limegreen: "#32cd32",
|
|
86
|
+
linen: "#faf0e6",
|
|
87
|
+
magenta: "#ff00ff",
|
|
88
|
+
maroon: "#800000",
|
|
89
|
+
mediumaquamarine: "#66cdaa",
|
|
90
|
+
mediumblue: "#0000cd",
|
|
91
|
+
mediumorchid: "#ba55d3",
|
|
92
|
+
mediumpurple: "#9370db",
|
|
93
|
+
mediumseagreen: "#3cb371",
|
|
94
|
+
mediumslateblue: "#7b68ee",
|
|
95
|
+
mediumspringgreen: "#00fa9a",
|
|
96
|
+
mediumturquoise: "#48d1cc",
|
|
97
|
+
mediumvioletred: "#c71585",
|
|
98
|
+
midnightblue: "#191970",
|
|
99
|
+
mintcream: "#f5fffa",
|
|
100
|
+
mistyrose: "#ffe4e1",
|
|
101
|
+
moccasin: "#ffe4b5",
|
|
102
|
+
navajowhite: "#ffdead",
|
|
103
|
+
navy: "#000080",
|
|
104
|
+
oldlace: "#fdf5e6",
|
|
105
|
+
olive: "#808000",
|
|
106
|
+
olivedrab: "#6b8e23",
|
|
107
|
+
orange: "#ffa500",
|
|
108
|
+
orangered: "#ff4500",
|
|
109
|
+
orchid: "#da70d6",
|
|
110
|
+
palegoldenrod: "#eee8aa",
|
|
111
|
+
palegreen: "#98fb98",
|
|
112
|
+
paleturquoise: "#afeeee",
|
|
113
|
+
palevioletred: "#db7093",
|
|
114
|
+
papayawhip: "#ffefd5",
|
|
115
|
+
peachpuff: "#ffdab9",
|
|
116
|
+
peru: "#cd853f",
|
|
117
|
+
pink: "#ffc0cb",
|
|
118
|
+
plum: "#dda0dd",
|
|
119
|
+
powderblue: "#b0e0e6",
|
|
120
|
+
purple: "#800080",
|
|
121
|
+
rebeccapurple: "#663399",
|
|
122
|
+
red: "#ff0000",
|
|
123
|
+
rosybrown: "#bc8f8f",
|
|
124
|
+
royalblue: "#4169e1",
|
|
125
|
+
saddlebrown: "#8b4513",
|
|
126
|
+
salmon: "#fa8072",
|
|
127
|
+
sandybrown: "#f4a460",
|
|
128
|
+
seagreen: "#2e8b57",
|
|
129
|
+
seashell: "#fff5ee",
|
|
130
|
+
sienna: "#a0522d",
|
|
131
|
+
silver: "#c0c0c0",
|
|
132
|
+
skyblue: "#87ceeb",
|
|
133
|
+
slateblue: "#6a5acd",
|
|
134
|
+
slategray: "#708090",
|
|
135
|
+
slategrey: "#708090",
|
|
136
|
+
snow: "#fffafa",
|
|
137
|
+
springgreen: "#00ff7f",
|
|
138
|
+
steelblue: "#4682b4",
|
|
139
|
+
tan: "#d2b48c",
|
|
140
|
+
teal: "#008080",
|
|
141
|
+
thistle: "#d8bfd8",
|
|
142
|
+
tomato: "#ff6347",
|
|
143
|
+
turquoise: "#40e0d0",
|
|
144
|
+
violet: "#ee82ee",
|
|
145
|
+
wheat: "#f5deb3",
|
|
146
|
+
white: "#ffffff",
|
|
147
|
+
whitesmoke: "#f5f5f5",
|
|
148
|
+
yellow: "#ffff00",
|
|
149
|
+
yellowgreen: "#9acd32"
|
|
150
|
+
};
|
|
151
|
+
export {
|
|
152
|
+
e as names
|
|
153
|
+
};
|