@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.
Files changed (206) hide show
  1. package/caseName.js +11 -0
  2. package/className.js +5 -0
  3. package/clipboardCopy.js +6 -0
  4. package/constant.js +4 -0
  5. package/contentDisposition.js +7 -0
  6. package/cookie.js +7 -0
  7. package/date/convertTime.js +61 -0
  8. package/date/index.js +22 -0
  9. package/date.js +9 -0
  10. package/decimal.js +5 -0
  11. package/eventEmitter.js +4 -0
  12. package/file.js +6 -0
  13. package/filesize.js +8 -0
  14. package/index.js +56 -46
  15. package/invariant.js +4 -0
  16. package/is.js +92 -0
  17. package/lunar/index.js +36 -0
  18. package/lunar/lib/Holiday.js +42 -0
  19. package/lunar/lib/HolidayUtil.js +128 -0
  20. package/lunar/lib/I18n.js +1005 -0
  21. package/lunar/lib/JieQi.js +40 -0
  22. package/lunar/lib/Lunar.js +1035 -0
  23. package/lunar/lib/LunarMonth.js +150 -0
  24. package/lunar/lib/LunarTime.js +138 -0
  25. package/lunar/lib/LunarUtil.js +1752 -0
  26. package/lunar/lib/LunarYear.js +616 -0
  27. package/lunar/lib/ShouXingUtil.js +6915 -0
  28. package/lunar/lib/Solar.js +311 -0
  29. package/lunar/lib/SolarHalfYear.js +45 -0
  30. package/lunar/lib/SolarMonth.js +55 -0
  31. package/lunar/lib/SolarSeason.js +42 -0
  32. package/lunar/lib/SolarUtil.js +256 -0
  33. package/lunar/lib/SolarWeek.js +153 -0
  34. package/lunar/lib/SolarYear.js +35 -0
  35. package/lunar/lib/index.js +35 -0
  36. package/lunar.js +36 -0
  37. package/math.js +9 -0
  38. package/md5.js +4 -0
  39. package/mock.js +8 -0
  40. package/normalizeWheel.js +6 -0
  41. package/number-to-chinese/index.js +72 -0
  42. package/numberToChinese.js +4 -0
  43. package/nzh.js +4 -0
  44. package/object-keys-sort/index.js +7 -0
  45. package/objectKeysSort.js +2 -5
  46. package/package.json +1 -1
  47. package/random.js +15 -0
  48. package/screenfull.js +4 -0
  49. package/snapdom/src/api/preCache.js +26 -36
  50. package/snapdom/src/api/snapdom.js +78 -61
  51. package/snapdom/src/core/capture.js +54 -54
  52. package/snapdom/src/core/prepare.js +46 -37
  53. package/snapdom/src/modules/fonts.js +90 -92
  54. package/snapdom/src/modules/iconFonts.js +28 -0
  55. package/snapdom/src/modules/images.js +6 -6
  56. package/snapdom/src/modules/pseudo.js +51 -49
  57. package/snapdom/src/modules/styles.js +27 -7
  58. package/snapdom/src/modules/svgDefs.js +26 -0
  59. package/snapdom/src/utils/helpers.js +150 -103
  60. package/snapdom.js +6 -0
  61. package/tinycolor/index.js +46 -0
  62. package/tinycolor/src/conversion.js +143 -0
  63. package/tinycolor/src/css-color-names.js +153 -0
  64. package/tinycolor/src/format-input.js +77 -0
  65. package/tinycolor/src/from-ratio.js +21 -0
  66. package/tinycolor/src/index.js +404 -0
  67. package/tinycolor/src/random.js +221 -0
  68. package/tinycolor/src/readability.js +37 -0
  69. package/tinycolor/src/to-ms-filter.js +15 -0
  70. package/tinycolor/src/util.js +32 -0
  71. package/tinycolor.js +46 -0
  72. package/tree/index.js +10 -8
  73. package/tree/searchTree.js +54 -0
  74. package/tree.js +13 -0
  75. package/turboStream.js +6 -0
  76. package/types/case-name/index.d.ts +11 -0
  77. package/types/class-name/index.d.ts +2 -0
  78. package/types/clipboard-copy/index.d.ts +2 -0
  79. package/types/constant/address.d.ts +14 -0
  80. package/types/constant/chineseCharacters.d.ts +2 -0
  81. package/types/constant/constellations.d.ts +2 -0
  82. package/types/constant/domain.d.ts +2 -0
  83. package/types/constant/identity.d.ts +2 -0
  84. package/types/constant/index.d.ts +1 -0
  85. package/types/constant/keyboardCode.d.ts +158 -0
  86. package/types/constant/licensePlate.d.ts +2 -0
  87. package/types/constant/name.d.ts +4 -0
  88. package/types/constant/platform.d.ts +11 -0
  89. package/types/constant/protocol.d.ts +2 -0
  90. package/types/constant/ui.d.ts +14 -0
  91. package/types/content-disposition/index.d.ts +10 -0
  92. package/types/cookie/index.d.ts +4 -0
  93. package/types/cookie/src/index.d.ts +114 -0
  94. package/types/date/convertTime.d.ts +32 -0
  95. package/types/date/index.d.ts +4 -0
  96. package/types/decimal/decimal.d.ts +4 -0
  97. package/types/decimal/index.d.ts +1 -0
  98. package/types/event-emitter/index.d.ts +17 -0
  99. package/types/file/fileToURL.d.ts +2 -0
  100. package/types/file/index.d.ts +3 -0
  101. package/types/file/saveAs.d.ts +2 -0
  102. package/types/filesize/index.d.ts +2 -0
  103. package/types/filesize/src/constants.d.ts +42 -0
  104. package/types/filesize/src/filesize.d.ts +47 -0
  105. package/types/index.d.ts +25 -0
  106. package/types/invariant/index.d.ts +2 -0
  107. package/types/is/index.d.ts +53 -0
  108. package/types/lunar/index.d.ts +3 -0
  109. package/types/lunar/lib/Holiday.d.ts +17 -0
  110. package/types/lunar/lib/HolidayUtil.d.ts +23 -0
  111. package/types/lunar/lib/I18n.d.ts +23 -0
  112. package/types/lunar/lib/JieQi.d.ts +15 -0
  113. package/types/lunar/lib/Lunar.d.ts +245 -0
  114. package/types/lunar/lib/LunarMonth.d.ts +35 -0
  115. package/types/lunar/lib/LunarTime.d.ts +40 -0
  116. package/types/lunar/lib/LunarUtil.d.ts +128 -0
  117. package/types/lunar/lib/LunarYear.d.ts +61 -0
  118. package/types/lunar/lib/ShouXingUtil.d.ts +38 -0
  119. package/types/lunar/lib/Solar.d.ts +51 -0
  120. package/types/lunar/lib/SolarHalfYear.d.ts +15 -0
  121. package/types/lunar/lib/SolarMonth.d.ts +16 -0
  122. package/types/lunar/lib/SolarSeason.d.ts +15 -0
  123. package/types/lunar/lib/SolarUtil.d.ts +20 -0
  124. package/types/lunar/lib/SolarWeek.d.ts +23 -0
  125. package/types/lunar/lib/SolarYear.d.ts +12 -0
  126. package/types/lunar/lib/index.d.ts +17 -0
  127. package/types/math/index.d.ts +11 -0
  128. package/types/md5/index.d.ts +2 -0
  129. package/types/mock/MockWebSocket.d.ts +17 -0
  130. package/types/mock/MockXMLHttpRequest.d.ts +17 -0
  131. package/types/mock/index.d.ts +2 -0
  132. package/types/normalize-wheel/ExecutionEnvironment.d.ts +9 -0
  133. package/types/normalize-wheel/UserAgent_DEPRECATED.d.ts +86 -0
  134. package/types/normalize-wheel/index.d.ts +115 -0
  135. package/types/normalize-wheel/isEventSupported.d.ts +16 -0
  136. package/types/number-to-chinese/index.d.ts +11 -0
  137. package/types/nzh/cn.d.ts +8 -0
  138. package/types/nzh/hk.d.ts +8 -0
  139. package/types/nzh/index.d.ts +1 -0
  140. package/types/nzh/nzh.d.ts +36 -0
  141. package/types/nzh/src/autoGet.d.ts +8 -0
  142. package/types/nzh/src/index.d.ts +34 -0
  143. package/types/nzh/src/langs/cn_b.d.ts +10 -0
  144. package/types/nzh/src/langs/cn_s.d.ts +7 -0
  145. package/types/nzh/src/langs/hk_b.d.ts +10 -0
  146. package/types/nzh/src/langs/hk_s.d.ts +7 -0
  147. package/types/nzh/src/utils.d.ts +65 -0
  148. package/types/object-keys-sort/index.d.ts +4 -0
  149. package/types/random/address.d.ts +8 -0
  150. package/types/random/constellation.d.ts +2 -0
  151. package/types/random/image.d.ts +5 -0
  152. package/types/random/index.d.ts +40 -0
  153. package/types/random/licensePlate.d.ts +2 -0
  154. package/types/random/name.d.ts +9 -0
  155. package/types/random/number.d.ts +6 -0
  156. package/types/random/text.d.ts +13 -0
  157. package/types/random/time.d.ts +2 -0
  158. package/types/random/web.d.ts +11 -0
  159. package/types/screenfull/index.d.ts +10 -0
  160. package/types/snapdom/index.d.ts +1 -0
  161. package/types/snapdom/src/api/preCache.d.ts +8 -0
  162. package/types/snapdom/src/api/snapdom.d.ts +26 -0
  163. package/types/snapdom/src/core/cache.d.ts +11 -0
  164. package/types/snapdom/src/core/capture.d.ts +17 -0
  165. package/types/snapdom/src/core/clone.d.ts +11 -0
  166. package/types/snapdom/src/core/prepare.d.ts +8 -0
  167. package/types/snapdom/src/index.browser.d.ts +1 -0
  168. package/types/snapdom/src/index.d.ts +2 -0
  169. package/types/snapdom/src/modules/background.d.ts +10 -0
  170. package/types/snapdom/src/modules/fonts.d.ts +23 -0
  171. package/types/snapdom/src/modules/iconFonts.d.ts +2 -0
  172. package/types/snapdom/src/modules/images.d.ts +8 -0
  173. package/types/snapdom/src/modules/pseudo.d.ts +12 -0
  174. package/types/snapdom/src/modules/styles.d.ts +1 -0
  175. package/types/snapdom/src/modules/svgDefs.d.ts +19 -0
  176. package/types/snapdom/src/utils/cssTools.d.ts +38 -0
  177. package/types/snapdom/src/utils/helpers.d.ts +71 -0
  178. package/types/tinycolor/index.d.ts +2 -0
  179. package/types/tinycolor/src/conversion.d.ts +79 -0
  180. package/types/tinycolor/src/css-color-names.d.ts +4 -0
  181. package/types/tinycolor/src/format-input.d.ts +38 -0
  182. package/types/tinycolor/src/from-ratio.d.ts +14 -0
  183. package/types/tinycolor/src/index.d.ts +214 -0
  184. package/types/tinycolor/src/interfaces.d.ts +57 -0
  185. package/types/tinycolor/src/public_api.d.ts +10 -0
  186. package/types/tinycolor/src/random.d.ts +24 -0
  187. package/types/tinycolor/src/readability.d.ts +46 -0
  188. package/types/tinycolor/src/to-ms-filter.d.ts +5 -0
  189. package/types/tinycolor/src/umd_api.d.ts +22 -0
  190. package/types/tinycolor/src/util.d.ts +36 -0
  191. package/types/tree/index.d.ts +9 -0
  192. package/types/tree/searchTree.d.ts +20 -0
  193. package/types/turbo-stream/index.d.ts +1 -0
  194. package/types/turbo-stream/src/decode.d.ts +7 -0
  195. package/types/turbo-stream/src/encode.d.ts +27 -0
  196. package/types/turbo-stream/src/shared.d.ts +107 -0
  197. package/types/turbo-stream/src/turbo-stream.d.ts +4 -0
  198. package/types/ui-color/compareColorByRange.d.ts +2 -0
  199. package/types/ui-color/index.d.ts +183 -0
  200. package/types/url-toolkit/index.d.ts +2 -0
  201. package/types/url-toolkit/src/url-toolkit.d.ts +18 -0
  202. package/ui-color/compareColorByRange.js +9 -0
  203. package/ui-color/index.js +155 -0
  204. package/uiColor.js +28 -0
  205. package/urlToolkit.js +8 -0
  206. package/dayjs/index.js +0 -15
@@ -0,0 +1,155 @@
1
+ import { TinyColor as e } from "../tinycolor/src/index.js";
2
+ import { default as Q } from "./compareColorByRange.js";
3
+ const c = 10, A = {
4
+ name: { zh: "浪漫红", en: "red" },
5
+ value: "#F53F3F"
6
+ }, d = {
7
+ name: { zh: "晚秋红", en: "orangered" },
8
+ value: "#FF702E"
9
+ }, k = {
10
+ name: { zh: "活力橙", en: "orange" },
11
+ value: "#FFA500"
12
+ }, C = {
13
+ name: { zh: "黄昏", en: "gold" },
14
+ value: "#FFBD14"
15
+ }, b = {
16
+ name: { zh: "柠檬黄", en: "yellow" },
17
+ value: "#FFE014"
18
+ }, _ = {
19
+ name: { zh: "新生绿", en: "lime" },
20
+ value: "#A1E619"
21
+ }, M = {
22
+ name: { zh: "仙野绿", en: "green" },
23
+ value: "#00B82B"
24
+ }, x = {
25
+ name: { zh: "碧涛青", en: "cyan" },
26
+ value: "#0BD0D0"
27
+ }, G = {
28
+ name: { zh: "海蔚蓝", en: "blue" },
29
+ value: "#2E8FFF"
30
+ }, H = {
31
+ name: { zh: "主题色(极致蓝)", en: "primary" },
32
+ value: "#1A5EFF"
33
+ }, L = {
34
+ name: { zh: "暗夜紫", en: "purple" },
35
+ value: "#7126D9"
36
+ }, P = {
37
+ name: { zh: "青春紫", en: "pinkpurple" },
38
+ value: "#D91AD9"
39
+ }, T = {
40
+ name: { zh: "品红", en: "magenta" },
41
+ value: "#FF299F"
42
+ }, s = {
43
+ name: { zh: "中性灰", en: "gray" },
44
+ value: "#6B6C6D"
45
+ }, N = [
46
+ A,
47
+ d,
48
+ k,
49
+ C,
50
+ b,
51
+ _,
52
+ M,
53
+ x,
54
+ G,
55
+ H,
56
+ L,
57
+ P,
58
+ T
59
+ ], R = {
60
+ key: s.name?.en ?? s.name?.zh ?? s.name,
61
+ name: s.name,
62
+ primary: s.value,
63
+ light: [
64
+ new e("#F7F8F9"),
65
+ new e("#F2F3F4"),
66
+ new e("#E5E6E7"),
67
+ new e("#C9CACB"),
68
+ new e("#A9ABAC"),
69
+ new e("#868788"),
70
+ new e(s.value),
71
+ new e("#4D4E4F"),
72
+ new e("#28292A"),
73
+ new e("#1E1F20")
74
+ ],
75
+ dark: [
76
+ new e("#121213"),
77
+ new e("#1C1C1D"),
78
+ new e("#404142"),
79
+ new e("#5E5F60"),
80
+ new e("#797A7B"),
81
+ new e("#9C9E9F"),
82
+ new e("#BCBDBE"),
83
+ new e("#D8D9DB"),
84
+ new e("#E4E6E8"),
85
+ new e("#E8EBEE")
86
+ ]
87
+ }, J = N.map((n, l, i) => {
88
+ const r = n.name, a = r?.en ?? r?.zh ?? r, t = n.value;
89
+ return {
90
+ key: a,
91
+ name: r,
92
+ primary: t,
93
+ light: j({ color: t, length: c }),
94
+ dark: q({ color: t, length: c })
95
+ };
96
+ }).concat([R]);
97
+ function f(n = {}) {
98
+ const { length: l, color: i, level: r } = n, a = (l ?? c) / 2 + 1, t = r ?? a;
99
+ let u = new e(i);
100
+ const w = u.toHsv(), g = w.h, o = w.s, m = w.v, y = g === 0 && o === 0, E = t < a, v = Math.abs(a - t), B = 1, p = 0.1;
101
+ let h = o;
102
+ h > p && (E ? h = o - (o - p) / (a - 1) * v : h = o + (B - o) / (a - 1) * v), y && (h = o);
103
+ const D = y ? 0.97 : 1, z = 0.1;
104
+ let F = m;
105
+ return F > z && (E ? F = m + (D - m) / (a - 1) * v : F = m - (m - z) / (a - 1) * v), u = new e({
106
+ h: g,
107
+ s: h,
108
+ v: F
109
+ }), n.dark && (u = u.darken(n.amount ?? 10)), u;
110
+ }
111
+ function S(n = {}) {
112
+ return f({ ...n, dark: !0 });
113
+ }
114
+ function j(n = {}) {
115
+ const { length: l } = n;
116
+ return Array.from(new Array(l ?? c), (r, a) => {
117
+ const t = a + 1;
118
+ return f({ ...n, level: t });
119
+ });
120
+ }
121
+ function q(n = {}) {
122
+ const { length: l } = n;
123
+ return Array.from(new Array(l ?? c), (r, a) => {
124
+ const t = a + 1;
125
+ return S({
126
+ ...n,
127
+ level: c - t + 1
128
+ });
129
+ });
130
+ }
131
+ export {
132
+ c as LENGTH,
133
+ G as blue,
134
+ J as colorPresets,
135
+ N as colors,
136
+ Q as compareColorByRange,
137
+ x as cyan,
138
+ j as generate,
139
+ q as generateDark,
140
+ C as gold,
141
+ s as gray,
142
+ R as grayPresets,
143
+ M as green,
144
+ _ as lime,
145
+ T as magenta,
146
+ k as orange,
147
+ d as orangered,
148
+ f as palette,
149
+ S as paletteDark,
150
+ P as pinkpurple,
151
+ H as primary,
152
+ L as purple,
153
+ A as red,
154
+ b as yellow
155
+ };
package/uiColor.js ADDED
@@ -0,0 +1,28 @@
1
+ import "./tinycolor/src/index.js";
2
+ import { default as o } from "./ui-color/compareColorByRange.js";
3
+ import { LENGTH as t, blue as p, colorPresets as g, colors as n, cyan as m, generate as s, generateDark as y, gold as c, gray as d, grayPresets as i, green as u, lime as f, magenta as k, orange as x, orangered as D, palette as P, paletteDark as b, pinkpurple as w, primary as B, purple as C, red as E, yellow as G } from "./ui-color/index.js";
4
+ export {
5
+ t as LENGTH,
6
+ p as blue,
7
+ g as colorPresets,
8
+ n as colors,
9
+ o as compareColorByRange,
10
+ m as cyan,
11
+ s as generate,
12
+ y as generateDark,
13
+ c as gold,
14
+ d as gray,
15
+ i as grayPresets,
16
+ u as green,
17
+ f as lime,
18
+ k as magenta,
19
+ x as orange,
20
+ D as orangered,
21
+ P as palette,
22
+ b as paletteDark,
23
+ w as pinkpurple,
24
+ B as primary,
25
+ C as purple,
26
+ E as red,
27
+ G as yellow
28
+ };
package/urlToolkit.js ADDED
@@ -0,0 +1,8 @@
1
+ import { buildAbsoluteURL as e, buildURLFromParts as l, default as o, normalizePath as t, parseURL as u } from "./url-toolkit/src/url-toolkit.js";
2
+ export {
3
+ e as buildAbsoluteURL,
4
+ l as buildURLFromParts,
5
+ o as default,
6
+ t as normalizePath,
7
+ u as parseURL
8
+ };
package/dayjs/index.js DELETED
@@ -1,15 +0,0 @@
1
- import a from "dayjs";
2
- function s(e, n) {
3
- let t = a.duration(e, n || "minutes");
4
- return [
5
- { value: t.years(), unit: "年" },
6
- { value: t.months(), unit: "个月" },
7
- { value: t.days(), unit: "天" },
8
- { value: t.hours(), unit: "小时" },
9
- { value: t.minutes(), unit: "分钟" },
10
- { value: t.seconds(), unit: "秒" }
11
- ].filter((u) => u.value > 0).map((u, o, r) => Math.floor(u.value) + u.unit).join("");
12
- }
13
- export {
14
- s as convertToDurationBasedOnTimeUnits
15
- };