@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
|
@@ -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
|
-
};
|