@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.
Files changed (122) hide show
  1. package/date/index.js +22 -0
  2. package/date.js +9 -0
  3. package/filesize/src/constants.js +22 -22
  4. package/filesize/src/filesize.js +32 -33
  5. package/index.js +56 -54
  6. package/lunar/index.js +36 -0
  7. package/lunar/lib/Holiday.js +42 -0
  8. package/lunar/lib/HolidayUtil.js +128 -0
  9. package/lunar/lib/I18n.js +1005 -0
  10. package/lunar/lib/JieQi.js +40 -0
  11. package/lunar/lib/Lunar.js +1035 -0
  12. package/lunar/lib/LunarMonth.js +150 -0
  13. package/lunar/lib/LunarTime.js +138 -0
  14. package/lunar/lib/LunarUtil.js +1752 -0
  15. package/lunar/lib/LunarYear.js +616 -0
  16. package/lunar/lib/ShouXingUtil.js +6915 -0
  17. package/lunar/lib/Solar.js +311 -0
  18. package/lunar/lib/SolarHalfYear.js +45 -0
  19. package/lunar/lib/SolarMonth.js +55 -0
  20. package/lunar/lib/SolarSeason.js +42 -0
  21. package/lunar/lib/SolarUtil.js +256 -0
  22. package/lunar/lib/SolarWeek.js +153 -0
  23. package/lunar/lib/SolarYear.js +35 -0
  24. package/lunar/lib/index.js +35 -0
  25. package/lunar.js +36 -0
  26. package/package.json +1 -1
  27. package/snapdom/src/api/preCache.js +27 -37
  28. package/snapdom/src/api/snapdom.js +75 -58
  29. package/snapdom/src/core/cache.js +19 -8
  30. package/snapdom/src/core/capture.js +49 -48
  31. package/snapdom/src/core/clone.js +96 -31
  32. package/snapdom/src/core/prepare.js +43 -37
  33. package/snapdom/src/modules/background.js +29 -20
  34. package/snapdom/src/modules/fonts.js +94 -104
  35. package/snapdom/src/modules/iconFonts.js +28 -0
  36. package/snapdom/src/modules/images.js +6 -6
  37. package/snapdom/src/modules/pseudo.js +52 -50
  38. package/snapdom/src/modules/styles.js +26 -6
  39. package/snapdom/src/modules/svgDefs.js +26 -0
  40. package/snapdom/src/utils/cssTools.js +41 -41
  41. package/snapdom/src/utils/helpers.js +128 -84
  42. package/tinycolor/index.js +46 -0
  43. package/tinycolor/src/conversion.js +143 -0
  44. package/tinycolor/src/css-color-names.js +153 -0
  45. package/tinycolor/src/format-input.js +77 -0
  46. package/tinycolor/src/from-ratio.js +21 -0
  47. package/tinycolor/src/index.js +404 -0
  48. package/tinycolor/src/random.js +221 -0
  49. package/tinycolor/src/readability.js +37 -0
  50. package/tinycolor/src/to-ms-filter.js +15 -0
  51. package/tinycolor/src/util.js +32 -0
  52. package/tinycolor.js +46 -0
  53. package/tree/index.js +10 -8
  54. package/tree/search/index.js +90 -0
  55. package/tree.js +9 -7
  56. package/types/date/index.d.ts +4 -0
  57. package/types/filesize/src/constants.d.ts +12 -12
  58. package/types/filesize/src/filesize.d.ts +63 -22
  59. package/types/index.d.ts +4 -3
  60. package/types/lunar/index.d.ts +3 -0
  61. package/types/lunar/lib/Holiday.d.ts +17 -0
  62. package/types/lunar/lib/HolidayUtil.d.ts +23 -0
  63. package/types/lunar/lib/I18n.d.ts +23 -0
  64. package/types/lunar/lib/JieQi.d.ts +15 -0
  65. package/types/lunar/lib/Lunar.d.ts +245 -0
  66. package/types/lunar/lib/LunarMonth.d.ts +35 -0
  67. package/types/lunar/lib/LunarTime.d.ts +40 -0
  68. package/types/lunar/lib/LunarUtil.d.ts +128 -0
  69. package/types/lunar/lib/LunarYear.d.ts +61 -0
  70. package/types/lunar/lib/ShouXingUtil.d.ts +38 -0
  71. package/types/lunar/lib/Solar.d.ts +51 -0
  72. package/types/lunar/lib/SolarHalfYear.d.ts +15 -0
  73. package/types/lunar/lib/SolarMonth.d.ts +16 -0
  74. package/types/lunar/lib/SolarSeason.d.ts +15 -0
  75. package/types/lunar/lib/SolarUtil.d.ts +20 -0
  76. package/types/lunar/lib/SolarWeek.d.ts +23 -0
  77. package/types/lunar/lib/SolarYear.d.ts +12 -0
  78. package/types/lunar/lib/index.d.ts +17 -0
  79. package/types/snapdom/src/core/cache.d.ts +17 -11
  80. package/types/snapdom/src/core/capture.d.ts +4 -0
  81. package/types/snapdom/src/core/clone.d.ts +4 -5
  82. package/types/snapdom/src/core/prepare.d.ts +8 -1
  83. package/types/snapdom/src/modules/background.d.ts +1 -2
  84. package/types/snapdom/src/modules/fonts.d.ts +1 -3
  85. package/types/snapdom/src/modules/iconFonts.d.ts +2 -0
  86. package/types/snapdom/src/modules/pseudo.d.ts +1 -3
  87. package/types/snapdom/src/modules/styles.d.ts +1 -10
  88. package/types/snapdom/src/modules/svgDefs.d.ts +19 -0
  89. package/types/snapdom/src/utils/cssTools.d.ts +1 -2
  90. package/types/snapdom/src/utils/helpers.d.ts +1 -1
  91. package/types/tinycolor/index.d.ts +2 -0
  92. package/types/tinycolor/src/conversion.d.ts +79 -0
  93. package/types/tinycolor/src/css-color-names.d.ts +4 -0
  94. package/types/tinycolor/src/format-input.d.ts +38 -0
  95. package/types/tinycolor/src/from-ratio.d.ts +14 -0
  96. package/types/tinycolor/src/index.d.ts +214 -0
  97. package/types/tinycolor/src/interfaces.d.ts +57 -0
  98. package/types/tinycolor/src/public_api.d.ts +10 -0
  99. package/types/tinycolor/src/random.d.ts +24 -0
  100. package/types/tinycolor/src/readability.d.ts +46 -0
  101. package/types/tinycolor/src/to-ms-filter.d.ts +5 -0
  102. package/types/tinycolor/src/umd_api.d.ts +22 -0
  103. package/types/tinycolor/src/util.d.ts +36 -0
  104. package/types/tree/index.d.ts +1 -0
  105. package/types/tree/search/index.d.ts +80 -0
  106. package/types/ui-color/compareColorByRange.d.ts +2 -0
  107. package/types/ui-color/index.d.ts +208 -0
  108. package/ui-color/compareColorByRange.js +9 -0
  109. package/ui-color/index.js +162 -0
  110. package/uiColor.js +29 -0
  111. package/convertTime.js +0 -4
  112. package/dayjs/index.js +0 -15
  113. package/dayjs.js +0 -5
  114. package/lunar-converter/index.js +0 -641
  115. package/lunarConverter.js +0 -4
  116. package/search-tree/index.js +0 -54
  117. package/searchTree.js +0 -4
  118. package/types/dayjs/index.d.ts +0 -1
  119. package/types/lunar-converter/index.d.ts +0 -113
  120. package/types/search-tree/index.d.ts +0 -20
  121. /package/{convert-time/index.js → date/convertTime.js} +0 -0
  122. /package/types/{convert-time/index.d.ts → date/convertTime.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { defaultStylesCache as r } from "../core/cache.js";
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 t of d)
43
- c(t);
42
+ for (let e of d)
43
+ c(e);
44
44
  }
45
- function c(t) {
46
- if (r.has(t))
47
- return r.get(t);
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(t)) {
55
+ ])).has(e)) {
56
56
  const o = {};
57
- return r.set(t, o), o;
57
+ return r.defaultStyle.set(e, o), o;
58
58
  }
59
- let e = document.getElementById("snapdom-sandbox");
60
- e || (e = document.createElement("div"), e.id = "snapdom-sandbox", e.style.position = "absolute", e.style.left = "-9999px", e.style.top = "-9999px", e.style.width = "0", e.style.height = "0", e.style.overflow = "hidden", document.body.appendChild(e));
61
- const n = document.createElement(t);
62
- n.style.all = "initial", e.appendChild(n);
63
- const l = getComputedStyle(n), a = {};
64
- for (let o of l)
65
- a[o] = l.getPropertyValue(o);
66
- return e.removeChild(n), r.set(t, a), a;
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(t, s, e = !1) {
69
- const n = [], l = c(s);
70
- for (let [a, o] of Object.entries(t))
71
- if (!e)
72
- o && n.push(`${a}:${o}`);
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[a];
75
- o && o !== i && n.push(`${a}:${o}`);
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(t) {
79
+ function y(e) {
80
80
  const s = /* @__PURE__ */ new Set();
81
- return t.nodeType !== Node.ELEMENT_NODE && t.nodeType !== Node.DOCUMENT_FRAGMENT_NODE ? [] : (t.tagName && s.add(t.tagName.toLowerCase()), typeof t.querySelectorAll == "function" && t.querySelectorAll("*").forEach((e) => s.add(e.tagName.toLowerCase())), Array.from(s));
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(t) {
83
+ function h(e) {
84
84
  const s = /* @__PURE__ */ new Map();
85
- for (let n of t) {
86
- const l = r.get(n);
87
- if (!l) continue;
88
- const a = Object.entries(l).map(([o, i]) => `${o}:${i};`).sort().join("");
89
- s.has(a) || s.set(a, []), s.get(a).push(n);
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 e = "";
92
- for (let [n, l] of s.entries())
93
- e += `${l.join(",")} { ${n} }
91
+ let t = "";
92
+ for (let [n, a] of s.entries())
93
+ t += `${a.join(",")} { ${n} }
94
94
  `;
95
- return e;
95
+ return t;
96
96
  }
97
- function m(t) {
98
- const s = new Set(t.values()), e = /* @__PURE__ */ new Map();
99
- let n = 1;
100
- for (const l of s)
101
- e.set(l, `c${n++}`);
102
- return e;
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 { imageCache as l, computedStyleCache as m, bgCache as u } from "../core/cache.js";
2
- async function w(t, e = {}) {
3
- const n = t.startsWith("url("), a = /^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(
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 r = d(t);
8
- if (!r) return t;
9
- const i = g(r);
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 s = e.crossOrigin ? e.crossOrigin(i) : "anonymous", o = await f(i, 3e3, s);
14
- return u.set(i, o), e.skipInline ? void 0 : `url(${o})`;
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 I(t, { fast: e = !1 } = {}) {
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 x(t, e = null) {
23
+ function U(t, e = null) {
24
24
  if (!(t instanceof Element))
25
25
  return window.getComputedStyle(t, e);
26
- let n = m.get(t);
27
- if (n || (n = /* @__PURE__ */ new Map(), m.set(t, n)), !n.has(e)) {
28
- const a = window.getComputedStyle(t, e);
29
- n.set(e, a);
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 C(t) {
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 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;
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 f(t, e = 3e3, n = "anonymous") {
63
- return l.has(t) ? Promise.resolve(l.get(t)) : new Promise((a, r) => {
64
- const i = setTimeout(() => {
65
- r(new Error("Image load timed out"));
66
- }, e), s = new Image();
67
- s.crossOrigin = n, s.onload = async () => {
68
- clearTimeout(i);
69
- try {
70
- await s.decode();
71
- const o = document.createElement("canvas");
72
- o.width = s.width, o.height = s.height, o.getContext("2d").drawImage(s, 0, 0, o.width, o.height);
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
- const c = o.toDataURL("image/png");
75
- l.set(t, c), a(c);
80
+ return await u(o);
76
81
  } catch {
77
- r(new Error("CORS restrictions prevented image capture"));
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
- }, s.onerror = (o) => {
83
- clearTimeout(i), r(
84
- new Error("Failed to load image: " + (o.message || "Unknown error"))
85
- );
86
- }, s.src = t;
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 U(t) {
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 y() {
140
+ function v() {
96
141
  return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
97
142
  }
98
- function k(t) {
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, a) => {
102
- const r = a.split(",").map((i) => i.trim());
103
- return r.length !== 6 ? `matrix(${a})` : (r[4] = "0", r[5] = "0", `matrix(${r.join(", ")})`);
104
- }), e = e.replace(/matrix3d\(([^)]+)\)/g, (n, a) => {
105
- const r = a.split(",").map((i) => i.trim());
106
- return r.length !== 16 ? `matrix3d(${a})` : (r[12] = "0", r[13] = "0", `matrix3d(${r.join(", ")})`);
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 g(t) {
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 E(t) {
162
+ function $(t) {
118
163
  const e = [];
119
- let n = 0, a = 0;
120
- for (let r = 0; r < t.length; r++) {
121
- const i = t[r];
122
- i === "(" && n++, i === ")" && n--, i === "," && n === 0 && (e.push(t.slice(a, r).trim()), a = r + 1);
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(a).trim()), e;
169
+ return e.push(t.slice(i).trim()), e;
125
170
  }
126
171
  export {
127
- d as extractURL,
128
- f as fetchImage,
129
- x as getStyle,
130
- I as idle,
131
- w as inlineSingleBackgroundEntry,
132
- S as isIconFont,
133
- y as isSafari,
134
- C as parseContent,
135
- g as safeEncodeURI,
136
- U as snapshotComputedStyle,
137
- E as splitBackgroundImage,
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
+ };