@unicom-cloud/utils 0.1.12 → 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/filesize/src/constants.js +22 -22
- package/filesize/src/filesize.js +32 -33
- package/package.json +1 -1
- package/snapdom/src/api/preCache.js +23 -23
- package/snapdom/src/api/snapdom.js +42 -42
- package/snapdom/src/core/cache.js +19 -8
- package/snapdom/src/core/capture.js +60 -59
- package/snapdom/src/core/clone.js +96 -31
- package/snapdom/src/core/prepare.js +35 -38
- package/snapdom/src/modules/background.js +29 -20
- package/snapdom/src/modules/fonts.js +97 -105
- package/snapdom/src/modules/pseudo.js +32 -32
- package/snapdom/src/modules/styles.js +22 -22
- package/snapdom/src/utils/cssTools.js +41 -41
- package/snapdom/src/utils/helpers.js +143 -146
- package/tree/index.js +1 -1
- package/tree/search/index.js +90 -0
- package/tree.js +1 -1
- package/types/filesize/src/constants.d.ts +12 -12
- package/types/filesize/src/filesize.d.ts +63 -22
- 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/pseudo.d.ts +1 -3
- package/types/snapdom/src/modules/styles.d.ts +1 -1
- package/types/snapdom/src/utils/cssTools.d.ts +1 -2
- package/types/tree/index.d.ts +1 -1
- package/types/tree/search/index.d.ts +80 -0
- package/types/ui-color/index.d.ts +28 -3
- package/ui-color/index.js +70 -63
- package/uiColor.js +19 -18
- package/tree/searchTree.js +0 -54
- package/types/tree/searchTree.d.ts +0 -20
package/ui-color/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { TinyColor as e } from "../tinycolor/src/index.js";
|
|
2
2
|
import { default as Q } from "./compareColorByRange.js";
|
|
3
|
-
const c = 10,
|
|
3
|
+
const c = 10, f = {
|
|
4
4
|
name: { zh: "浪漫红", en: "red" },
|
|
5
5
|
value: "#F53F3F"
|
|
6
|
-
},
|
|
6
|
+
}, B = {
|
|
7
7
|
name: { zh: "晚秋红", en: "orangered" },
|
|
8
8
|
value: "#FF702E"
|
|
9
|
-
},
|
|
9
|
+
}, D = {
|
|
10
10
|
name: { zh: "活力橙", en: "orange" },
|
|
11
11
|
value: "#FFA500"
|
|
12
12
|
}, C = {
|
|
@@ -21,42 +21,42 @@ const c = 10, A = {
|
|
|
21
21
|
}, M = {
|
|
22
22
|
name: { zh: "仙野绿", en: "green" },
|
|
23
23
|
value: "#00B82B"
|
|
24
|
-
},
|
|
24
|
+
}, P = {
|
|
25
25
|
name: { zh: "碧涛青", en: "cyan" },
|
|
26
26
|
value: "#0BD0D0"
|
|
27
|
-
},
|
|
27
|
+
}, x = {
|
|
28
28
|
name: { zh: "海蔚蓝", en: "blue" },
|
|
29
29
|
value: "#2E8FFF"
|
|
30
|
-
},
|
|
30
|
+
}, R = {
|
|
31
31
|
name: { zh: "主题色(极致蓝)", en: "primary" },
|
|
32
32
|
value: "#1A5EFF"
|
|
33
|
-
},
|
|
33
|
+
}, G = {
|
|
34
34
|
name: { zh: "暗夜紫", en: "purple" },
|
|
35
35
|
value: "#7126D9"
|
|
36
|
-
},
|
|
36
|
+
}, L = {
|
|
37
37
|
name: { zh: "青春紫", en: "pinkpurple" },
|
|
38
38
|
value: "#D91AD9"
|
|
39
|
-
},
|
|
39
|
+
}, H = {
|
|
40
40
|
name: { zh: "品红", en: "magenta" },
|
|
41
41
|
value: "#FF299F"
|
|
42
42
|
}, s = {
|
|
43
43
|
name: { zh: "中性灰", en: "gray" },
|
|
44
44
|
value: "#6B6C6D"
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
}, I = [
|
|
46
|
+
f,
|
|
47
|
+
B,
|
|
48
|
+
D,
|
|
49
49
|
C,
|
|
50
50
|
b,
|
|
51
51
|
_,
|
|
52
52
|
M,
|
|
53
|
+
P,
|
|
53
54
|
x,
|
|
55
|
+
R,
|
|
54
56
|
G,
|
|
55
|
-
H,
|
|
56
57
|
L,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
], R = {
|
|
58
|
+
H
|
|
59
|
+
], N = {
|
|
60
60
|
key: s.name?.en ?? s.name?.zh ?? s.name,
|
|
61
61
|
name: s.name,
|
|
62
62
|
primary: s.value,
|
|
@@ -84,72 +84,79 @@ const c = 10, A = {
|
|
|
84
84
|
new e("#E4E6E8"),
|
|
85
85
|
new e("#E8EBEE")
|
|
86
86
|
]
|
|
87
|
-
},
|
|
88
|
-
const
|
|
87
|
+
}, S = I.map((n, l, h) => {
|
|
88
|
+
const t = n.name, a = t?.en ?? t?.zh ?? t, r = n.value;
|
|
89
89
|
return {
|
|
90
90
|
key: a,
|
|
91
|
-
name:
|
|
92
|
-
primary:
|
|
93
|
-
light:
|
|
94
|
-
dark:
|
|
91
|
+
name: t,
|
|
92
|
+
primary: r,
|
|
93
|
+
light: T({ color: r, length: c }),
|
|
94
|
+
dark: Y({ color: r, length: c })
|
|
95
95
|
};
|
|
96
|
-
}).concat([
|
|
97
|
-
function
|
|
98
|
-
const { length: l, color:
|
|
99
|
-
let u = new e(
|
|
100
|
-
const w = u.toHsv(),
|
|
101
|
-
let
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
let
|
|
105
|
-
return
|
|
106
|
-
h:
|
|
107
|
-
s:
|
|
108
|
-
v
|
|
96
|
+
}).concat([N]);
|
|
97
|
+
function z(n = {}) {
|
|
98
|
+
const { length: l, color: h, level: t } = n, a = (l ?? c) / 2 + 1, r = t ?? a;
|
|
99
|
+
let u = new e(h);
|
|
100
|
+
const w = u.toHsv(), F = w.h, o = w.s, m = w.v, y = F === 0 && o === 0, E = r < a, g = Math.abs(a - r), A = 1, p = 0.1;
|
|
101
|
+
let i = o;
|
|
102
|
+
i > p && (E ? i = o - (o - p) / (a - 1) * g : i = o + (A - o) / (a - 1) * g), y && (i = o);
|
|
103
|
+
const d = y ? 0.97 : 1, k = 0.1;
|
|
104
|
+
let v = m;
|
|
105
|
+
return v > k && (E ? v = m + (d - m) / (a - 1) * g : v = m - (m - k) / (a - 1) * g), u = new e({
|
|
106
|
+
h: F,
|
|
107
|
+
s: i,
|
|
108
|
+
v
|
|
109
109
|
}), n.dark && (u = u.darken(n.amount ?? 10)), u;
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
return
|
|
111
|
+
function O(n = {}) {
|
|
112
|
+
return z({ ...n, dark: !0 });
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function T(n = {}) {
|
|
115
115
|
const { length: l } = n;
|
|
116
|
-
return Array.from(new Array(l ?? c), (
|
|
117
|
-
const
|
|
118
|
-
return
|
|
116
|
+
return Array.from(new Array(l ?? c), (t, a) => {
|
|
117
|
+
const r = a + 1;
|
|
118
|
+
return z({ ...n, level: r });
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function Y(n = {}) {
|
|
122
122
|
const { length: l } = n;
|
|
123
|
-
return Array.from(new Array(l ?? c), (
|
|
124
|
-
const
|
|
125
|
-
return
|
|
123
|
+
return Array.from(new Array(l ?? c), (t, a) => {
|
|
124
|
+
const r = a + 1;
|
|
125
|
+
return O({
|
|
126
126
|
...n,
|
|
127
|
-
level: c -
|
|
127
|
+
level: c - r + 1
|
|
128
128
|
});
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
+
const j = {
|
|
132
|
+
primary: { label: "主色", key: "primary" },
|
|
133
|
+
success: { label: "成功色", key: "green" },
|
|
134
|
+
warning: { label: "警示色", key: "orange" },
|
|
135
|
+
danger: { label: "错误色", key: "red" }
|
|
136
|
+
};
|
|
131
137
|
export {
|
|
132
138
|
c as LENGTH,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
139
|
+
j as PRIMARY_COLOR_KEY_MAPPING,
|
|
140
|
+
x as blue,
|
|
141
|
+
S as colorPresets,
|
|
142
|
+
I as colors,
|
|
136
143
|
Q as compareColorByRange,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
P as cyan,
|
|
145
|
+
T as generate,
|
|
146
|
+
Y as generateDark,
|
|
140
147
|
C as gold,
|
|
141
148
|
s as gray,
|
|
142
|
-
|
|
149
|
+
N as grayPresets,
|
|
143
150
|
M as green,
|
|
144
151
|
_ as lime,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
H as magenta,
|
|
153
|
+
D as orange,
|
|
154
|
+
B as orangered,
|
|
155
|
+
z as palette,
|
|
156
|
+
O as paletteDark,
|
|
157
|
+
L as pinkpurple,
|
|
158
|
+
R as primary,
|
|
159
|
+
G as purple,
|
|
160
|
+
f as red,
|
|
154
161
|
b as yellow
|
|
155
162
|
};
|
package/uiColor.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import "./tinycolor/src/index.js";
|
|
2
2
|
import { default as o } from "./ui-color/compareColorByRange.js";
|
|
3
|
-
import { LENGTH as t,
|
|
3
|
+
import { LENGTH as t, PRIMARY_COLOR_KEY_MAPPING as p, blue as g, colorPresets as n, colors as m, cyan as s, generate as y, generateDark as P, gold as c, gray as d, grayPresets as i, green as u, lime as R, magenta as f, orange as k, orangered as _, palette as x, paletteDark as A, pinkpurple as C, primary as D, purple as E, red as G, yellow as I } from "./ui-color/index.js";
|
|
4
4
|
export {
|
|
5
5
|
t as LENGTH,
|
|
6
|
-
p as
|
|
7
|
-
g as
|
|
8
|
-
n as
|
|
6
|
+
p as PRIMARY_COLOR_KEY_MAPPING,
|
|
7
|
+
g as blue,
|
|
8
|
+
n as colorPresets,
|
|
9
|
+
m as colors,
|
|
9
10
|
o as compareColorByRange,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
s as cyan,
|
|
12
|
+
y as generate,
|
|
13
|
+
P as generateDark,
|
|
13
14
|
c as gold,
|
|
14
15
|
d as gray,
|
|
15
16
|
i as grayPresets,
|
|
16
17
|
u as green,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
R as lime,
|
|
19
|
+
f as magenta,
|
|
20
|
+
k as orange,
|
|
21
|
+
_ as orangered,
|
|
22
|
+
x as palette,
|
|
23
|
+
A as paletteDark,
|
|
24
|
+
C as pinkpurple,
|
|
25
|
+
D as primary,
|
|
26
|
+
E as purple,
|
|
27
|
+
G as red,
|
|
28
|
+
I as yellow
|
|
28
29
|
};
|
package/tree/searchTree.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
function p(o, i, a = {}) {
|
|
2
|
-
const {
|
|
3
|
-
strategy: f = "BFS",
|
|
4
|
-
childrenKey: c = "children",
|
|
5
|
-
strict: u = !1
|
|
6
|
-
} = a;
|
|
7
|
-
if (!Array.isArray(o))
|
|
8
|
-
throw new TypeError("treeData must be an array");
|
|
9
|
-
if (typeof i != "object" || i === null)
|
|
10
|
-
throw new TypeError("searchCondition must be an object");
|
|
11
|
-
const t = [...o], l = (e) => {
|
|
12
|
-
for (const r in i) {
|
|
13
|
-
if (!Object.prototype.hasOwnProperty.call(e, r))
|
|
14
|
-
return !1;
|
|
15
|
-
const n = i[r], s = e[r];
|
|
16
|
-
if (u) {
|
|
17
|
-
if (s !== n)
|
|
18
|
-
return !1;
|
|
19
|
-
} else if (n instanceof RegExp) {
|
|
20
|
-
if (typeof s != "string" || !n.test(s))
|
|
21
|
-
return !1;
|
|
22
|
-
} else if (typeof n == "function") {
|
|
23
|
-
if (!n(s))
|
|
24
|
-
return !1;
|
|
25
|
-
} else if (s != n)
|
|
26
|
-
return !1;
|
|
27
|
-
}
|
|
28
|
-
return !0;
|
|
29
|
-
};
|
|
30
|
-
if (f === "BFS")
|
|
31
|
-
for (; t.length > 0; ) {
|
|
32
|
-
const e = t.shift();
|
|
33
|
-
if (!e) continue;
|
|
34
|
-
if (l(e))
|
|
35
|
-
return e;
|
|
36
|
-
const r = e[c];
|
|
37
|
-
Array.isArray(r) && t.push(...r);
|
|
38
|
-
}
|
|
39
|
-
else if (f === "DFS")
|
|
40
|
-
for (; t.length > 0; ) {
|
|
41
|
-
const e = t.pop();
|
|
42
|
-
if (!e) continue;
|
|
43
|
-
if (l(e))
|
|
44
|
-
return e;
|
|
45
|
-
const r = e[c];
|
|
46
|
-
Array.isArray(r) && t.push(...r.slice().reverse());
|
|
47
|
-
}
|
|
48
|
-
else
|
|
49
|
-
throw new Error('Invalid strategy. Use "BFS" or "DFS"');
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
export {
|
|
53
|
-
p as default
|
|
54
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
type Primitive = string | number | boolean | symbol | null | undefined;
|
|
2
|
-
type ConditionValue<T = unknown> = Primitive | ((value: T) => boolean) | RegExp;
|
|
3
|
-
interface SearchOptions {
|
|
4
|
-
strategy?: 'BFS' | 'DFS';
|
|
5
|
-
childrenKey?: string;
|
|
6
|
-
strict?: boolean;
|
|
7
|
-
}
|
|
8
|
-
interface TreeNode {
|
|
9
|
-
[key: string]: unknown;
|
|
10
|
-
children?: TreeNode[];
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* 非递归树搜索算法
|
|
14
|
-
* @param {TreeNode[]} treeData - 树数据
|
|
15
|
-
* @param {Record<string, ConditionValue>} searchCondition - 搜索条件对象
|
|
16
|
-
* @param {SearchOptions} [options={}] - 配置选项
|
|
17
|
-
* @returns {TreeNode | null} 找到的节点或null
|
|
18
|
-
*/
|
|
19
|
-
declare function searchTree(treeData: TreeNode[], searchCondition: Record<string, ConditionValue>, options?: SearchOptions): TreeNode | null;
|
|
20
|
-
export default searchTree;
|