@vef-framework/shared 2.0.3 → 2.0.5
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/dist/cjs/color/color-ops.cjs +1 -76
- package/dist/cjs/color/index.cjs +1 -24
- package/dist/cjs/color/name.cjs +1 -49
- package/dist/cjs/color/palette.cjs +1 -126
- package/dist/cjs/constants/color-names.cjs +1 -1580
- package/dist/cjs/constants/color-palettes.cjs +1 -372
- package/dist/cjs/constants/index.cjs +1 -14
- package/dist/cjs/index.cjs +1 -339
- package/dist/cjs/types/color.cjs +1 -3
- package/dist/cjs/types/common.cjs +1 -3
- package/dist/cjs/types/deep-keys.cjs +1 -3
- package/dist/cjs/types/index.cjs +1 -7
- package/dist/cjs/utils/chrono.cjs +1 -139
- package/dist/cjs/utils/equal.cjs +1 -175
- package/dist/cjs/utils/error.cjs +3 -60
- package/dist/cjs/utils/event.cjs +1 -62
- package/dist/cjs/utils/format.cjs +1 -31
- package/dist/cjs/utils/function.cjs +1 -49
- package/dist/cjs/utils/id.cjs +1 -38
- package/dist/cjs/utils/index.cjs +1 -86
- package/dist/cjs/utils/key.cjs +1 -34
- package/dist/cjs/utils/lib.cjs +1 -234
- package/dist/cjs/utils/object.cjs +1 -20
- package/dist/cjs/utils/path.cjs +1 -63
- package/dist/cjs/utils/pinyin.cjs +1 -53
- package/dist/cjs/utils/security.cjs +1 -44
- package/dist/cjs/utils/string.cjs +1 -13
- package/dist/cjs/utils/task.cjs +1 -17
- package/dist/cjs/utils/tree.cjs +1 -262
- package/dist/cjs/utils/zod.cjs +1 -14
- package/dist/es/color/color-ops.js +64 -58
- package/dist/es/color/index.js +18 -4
- package/dist/es/color/name.js +24 -37
- package/dist/es/color/palette.js +67 -100
- package/dist/es/constants/color-names.js +6 -9
- package/dist/es/constants/color-palettes.js +8 -15
- package/dist/es/constants/index.js +8 -3
- package/dist/es/index.js +165 -30
- package/dist/es/types/color.js +1 -1
- package/dist/es/types/common.js +1 -1
- package/dist/es/types/deep-keys.js +1 -1
- package/dist/es/types/index.js +3 -4
- package/dist/es/utils/chrono.js +71 -88
- package/dist/es/utils/equal.js +111 -161
- package/dist/es/utils/error.js +28 -25
- package/dist/es/utils/event.js +18 -23
- package/dist/es/utils/format.js +16 -22
- package/dist/es/utils/function.js +32 -32
- package/dist/es/utils/id.js +18 -27
- package/dist/es/utils/index.js +80 -18
- package/dist/es/utils/key.js +19 -25
- package/dist/es/utils/lib.js +64 -10
- package/dist/es/utils/object.js +11 -14
- package/dist/es/utils/path.js +57 -48
- package/dist/es/utils/pinyin.js +28 -29
- package/dist/es/utils/security.js +29 -37
- package/dist/es/utils/string.js +7 -8
- package/dist/es/utils/task.js +7 -12
- package/dist/es/utils/tree.js +156 -219
- package/dist/es/utils/zod.js +7 -6
- package/package.json +1 -1
package/dist/es/utils/task.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function scheduleMicrotask(task) {
|
|
6
|
-
if (isFunction(queueMicrotask)) {
|
|
7
|
-
queueMicrotask(task);
|
|
8
|
-
} else {
|
|
9
|
-
Promise.resolve().then(task);
|
|
10
|
-
}
|
|
1
|
+
import "./lib.js";
|
|
2
|
+
import { isFunction as o } from "radashi";
|
|
3
|
+
function t(e) {
|
|
4
|
+
o(queueMicrotask) ? queueMicrotask(e) : Promise.resolve().then(e);
|
|
11
5
|
}
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
export {
|
|
7
|
+
t as scheduleMicrotask
|
|
8
|
+
};
|
package/dist/es/utils/tree.js
CHANGED
|
@@ -1,252 +1,189 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function flattenTree(tree, options = {}) {
|
|
1
|
+
import "./lib.js";
|
|
2
|
+
import { isArray as a, isFunction as g, isNullish as I } from "radashi";
|
|
3
|
+
function y(s, l = {}) {
|
|
6
4
|
const {
|
|
7
|
-
childrenKey = "children",
|
|
8
|
-
includeParent =
|
|
9
|
-
includeLevel =
|
|
10
|
-
transform,
|
|
11
|
-
filter
|
|
12
|
-
} =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const children2 = node[childrenKey];
|
|
22
|
-
if (isArray(children2)) {
|
|
23
|
-
traverse(children2, node, level + 1);
|
|
24
|
-
}
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
let newNode = node;
|
|
28
|
-
if (isFunction(transform)) {
|
|
29
|
-
newNode = transform(node, context);
|
|
30
|
-
} else if (includeParent || includeLevel) {
|
|
31
|
-
const flattenedNode = { data: node };
|
|
32
|
-
if (includeParent) {
|
|
33
|
-
flattenedNode.parent = parent;
|
|
5
|
+
childrenKey: d = "children",
|
|
6
|
+
includeParent: h = !1,
|
|
7
|
+
includeLevel: o = !1,
|
|
8
|
+
transform: c,
|
|
9
|
+
filter: n
|
|
10
|
+
} = l, e = [];
|
|
11
|
+
function r(t, u, i = 0) {
|
|
12
|
+
if (a(t))
|
|
13
|
+
for (const f of t) {
|
|
14
|
+
const p = { parent: u, level: i };
|
|
15
|
+
if (g(n) && !n(f, p)) {
|
|
16
|
+
const N = f[d];
|
|
17
|
+
a(N) && r(N, f, i + 1);
|
|
18
|
+
continue;
|
|
34
19
|
}
|
|
35
|
-
|
|
36
|
-
|
|
20
|
+
let m = f;
|
|
21
|
+
if (g(c))
|
|
22
|
+
m = c(f, p);
|
|
23
|
+
else if (h || o) {
|
|
24
|
+
const N = { data: f };
|
|
25
|
+
h && (N.parent = u), o && (N.level = i), m = N;
|
|
37
26
|
}
|
|
38
|
-
|
|
27
|
+
e.push(m);
|
|
28
|
+
const x = f[d];
|
|
29
|
+
a(x) && r(x, f, i + 1);
|
|
39
30
|
}
|
|
40
|
-
result.push(newNode);
|
|
41
|
-
const children = node[childrenKey];
|
|
42
|
-
if (isArray(children)) {
|
|
43
|
-
traverse(children, node, level + 1);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
31
|
}
|
|
47
|
-
|
|
48
|
-
return result;
|
|
32
|
+
return r(s), e;
|
|
49
33
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
34
|
+
function T(s, l) {
|
|
35
|
+
return g(l) ? l(s) : s[l];
|
|
52
36
|
}
|
|
53
|
-
function
|
|
37
|
+
function A(s, l = {}) {
|
|
54
38
|
const {
|
|
55
|
-
idKey = "id",
|
|
56
|
-
parentIdKey = "parentId",
|
|
57
|
-
childrenKey = "children",
|
|
58
|
-
rootValue,
|
|
59
|
-
transform
|
|
60
|
-
} =
|
|
61
|
-
if (!
|
|
39
|
+
idKey: d = "id",
|
|
40
|
+
parentIdKey: h = "parentId",
|
|
41
|
+
childrenKey: o = "children",
|
|
42
|
+
rootValue: c,
|
|
43
|
+
transform: n
|
|
44
|
+
} = l;
|
|
45
|
+
if (!a(s) || s.length === 0)
|
|
62
46
|
return [];
|
|
47
|
+
const e = /* @__PURE__ */ new Map(), r = [];
|
|
48
|
+
for (const t of s) {
|
|
49
|
+
const u = T(t, d);
|
|
50
|
+
e.set(u, { ...t });
|
|
63
51
|
}
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const nodeId = getNodeValue(originalNode, idKey);
|
|
72
|
-
const parentId = getNodeValue(originalNode, parentIdKey);
|
|
73
|
-
const node = nodeMap.get(nodeId);
|
|
74
|
-
const isRoot = isFunction(rootValue) ? rootValue(originalNode) : parentId === rootValue || isNullish(parentId);
|
|
75
|
-
if (isRoot) {
|
|
76
|
-
rootNodes.push(node);
|
|
77
|
-
} else {
|
|
78
|
-
const parentNode = nodeMap.get(parentId);
|
|
79
|
-
if (parentNode) {
|
|
80
|
-
if (!isArray(parentNode[childrenKey])) {
|
|
81
|
-
parentNode[childrenKey] = [];
|
|
82
|
-
}
|
|
83
|
-
parentNode[childrenKey].push(node);
|
|
84
|
-
} else {
|
|
85
|
-
rootNodes.push(node);
|
|
86
|
-
}
|
|
52
|
+
for (const t of s) {
|
|
53
|
+
const u = T(t, d), i = T(t, h), f = e.get(u);
|
|
54
|
+
if (g(c) ? c(t) : i === c || I(i))
|
|
55
|
+
r.push(f);
|
|
56
|
+
else {
|
|
57
|
+
const m = e.get(i);
|
|
58
|
+
m ? (a(m[o]) || (m[o] = []), m[o].push(f)) : r.push(f);
|
|
87
59
|
}
|
|
88
60
|
}
|
|
89
|
-
if (
|
|
90
|
-
let
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
if (isArray(children)) {
|
|
94
|
-
transformedNode[childrenKey] = children.map((child) => transformNode(child, level + 1));
|
|
95
|
-
}
|
|
96
|
-
return transformedNode;
|
|
61
|
+
if (g(n)) {
|
|
62
|
+
let t = function(i, f = 0) {
|
|
63
|
+
const p = i[o], m = u(i, { children: p, level: f });
|
|
64
|
+
return a(p) && (m[o] = p.map((x) => t(x, f + 1))), m;
|
|
97
65
|
};
|
|
98
|
-
const
|
|
99
|
-
return
|
|
66
|
+
const u = n;
|
|
67
|
+
return r.map((i) => t(i));
|
|
100
68
|
}
|
|
101
|
-
return
|
|
69
|
+
return r;
|
|
102
70
|
}
|
|
103
|
-
function
|
|
104
|
-
function
|
|
105
|
-
if (
|
|
106
|
-
for (const
|
|
107
|
-
if (
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return found;
|
|
115
|
-
}
|
|
71
|
+
function C(s, l, d = "children") {
|
|
72
|
+
function h(o, c, n = 0) {
|
|
73
|
+
if (a(o))
|
|
74
|
+
for (const e of o) {
|
|
75
|
+
if (l(e, { parent: c, level: n }))
|
|
76
|
+
return e;
|
|
77
|
+
const r = e[d];
|
|
78
|
+
if (a(r)) {
|
|
79
|
+
const t = h(r, e, n + 1);
|
|
80
|
+
if (t)
|
|
81
|
+
return t;
|
|
116
82
|
}
|
|
117
83
|
}
|
|
118
|
-
}
|
|
119
84
|
}
|
|
120
|
-
return
|
|
85
|
+
return h(s);
|
|
121
86
|
}
|
|
122
|
-
function
|
|
123
|
-
const { strategy = "dfs", childrenKey = "children" } =
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const queue = tree.map((node, index) => {
|
|
129
|
-
return {
|
|
130
|
-
node,
|
|
87
|
+
function F(s, l, d = {}) {
|
|
88
|
+
const { strategy: h = "dfs", childrenKey: o = "children" } = d;
|
|
89
|
+
if (a(s))
|
|
90
|
+
if (h === "bfs") {
|
|
91
|
+
const c = s.map((n, e) => ({
|
|
92
|
+
node: n,
|
|
131
93
|
level: 0,
|
|
132
|
-
index
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
index: item.index
|
|
141
|
-
});
|
|
142
|
-
const children = item.node[childrenKey];
|
|
143
|
-
if (isArray(children)) {
|
|
144
|
-
for (const [index, child] of children.entries()) {
|
|
145
|
-
queue.push({
|
|
146
|
-
node: child,
|
|
147
|
-
parent: item.node,
|
|
148
|
-
level: item.level + 1,
|
|
149
|
-
index
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
let traverse = function(nodes, parent, level = 0) {
|
|
156
|
-
if (!isArray(nodes)) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
for (const [index, node] of nodes.entries()) {
|
|
160
|
-
callback(node, {
|
|
161
|
-
parent,
|
|
162
|
-
level,
|
|
163
|
-
index
|
|
94
|
+
index: e
|
|
95
|
+
}));
|
|
96
|
+
for (; c.length > 0; ) {
|
|
97
|
+
const n = c.shift();
|
|
98
|
+
l(n.node, {
|
|
99
|
+
parent: n.parent,
|
|
100
|
+
level: n.level,
|
|
101
|
+
index: n.index
|
|
164
102
|
});
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
103
|
+
const e = n.node[o];
|
|
104
|
+
if (a(e))
|
|
105
|
+
for (const [r, t] of e.entries())
|
|
106
|
+
c.push({
|
|
107
|
+
node: t,
|
|
108
|
+
parent: n.node,
|
|
109
|
+
level: n.level + 1,
|
|
110
|
+
index: r
|
|
111
|
+
});
|
|
169
112
|
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
113
|
+
} else {
|
|
114
|
+
let c = function(n, e, r = 0) {
|
|
115
|
+
if (a(n))
|
|
116
|
+
for (const [t, u] of n.entries()) {
|
|
117
|
+
l(u, {
|
|
118
|
+
parent: e,
|
|
119
|
+
level: r,
|
|
120
|
+
index: t
|
|
121
|
+
});
|
|
122
|
+
const i = u[o];
|
|
123
|
+
a(i) && c(i, u, r + 1);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
c(s);
|
|
178
127
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
});
|
|
128
|
+
}
|
|
129
|
+
function R(s, l, d = "children") {
|
|
130
|
+
function h(o, c, n = 0) {
|
|
131
|
+
return a(o) ? o.map((e, r) => {
|
|
132
|
+
const t = l(e, {
|
|
133
|
+
parent: c,
|
|
134
|
+
level: n,
|
|
135
|
+
index: r
|
|
136
|
+
}), u = e[d];
|
|
137
|
+
return a(u) && (t[d] = h(u, e, n + 1)), t;
|
|
138
|
+
}) : [];
|
|
191
139
|
}
|
|
192
|
-
return
|
|
140
|
+
return h(s);
|
|
193
141
|
}
|
|
194
|
-
function
|
|
195
|
-
function
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
142
|
+
function V(s, l, d = "children") {
|
|
143
|
+
function h(o, c, n = 0) {
|
|
144
|
+
return a(o) ? o.reduce((e, r, t) => {
|
|
145
|
+
if (!l(r, {
|
|
146
|
+
parent: c,
|
|
147
|
+
level: n,
|
|
148
|
+
index: t
|
|
149
|
+
}))
|
|
150
|
+
return e;
|
|
151
|
+
const u = r[d], i = { ...r };
|
|
152
|
+
if (u && a(u)) {
|
|
153
|
+
const f = h(u, r, n + 1);
|
|
154
|
+
f.length > 0 ? i[d] = f : delete i[d];
|
|
206
155
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (children && isArray(children)) {
|
|
210
|
-
const filteredChildren = filter(children, node, level + 1);
|
|
211
|
-
if (filteredChildren.length > 0) {
|
|
212
|
-
newNode[childrenKey] = filteredChildren;
|
|
213
|
-
} else {
|
|
214
|
-
delete newNode[childrenKey];
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
acc.push(newNode);
|
|
218
|
-
return acc;
|
|
219
|
-
}, []);
|
|
156
|
+
return e.push(i), e;
|
|
157
|
+
}, []) : [];
|
|
220
158
|
}
|
|
221
|
-
return
|
|
159
|
+
return h(s);
|
|
222
160
|
}
|
|
223
|
-
function
|
|
224
|
-
function
|
|
225
|
-
if (!
|
|
161
|
+
function b(s, l, d = "children") {
|
|
162
|
+
function h(o, c, n = 0) {
|
|
163
|
+
if (!a(o))
|
|
226
164
|
return [];
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (nodeMatches || filteredChildren.length > 0) {
|
|
238
|
-
const newNode = { ...node };
|
|
239
|
-
if (filteredChildren.length > 0) {
|
|
240
|
-
newNode[childrenKey] = filteredChildren;
|
|
241
|
-
} else {
|
|
242
|
-
delete newNode[childrenKey];
|
|
243
|
-
}
|
|
244
|
-
result.push(newNode);
|
|
165
|
+
const e = [];
|
|
166
|
+
for (const [r, t] of o.entries()) {
|
|
167
|
+
const u = l(t, {
|
|
168
|
+
parent: c,
|
|
169
|
+
level: n,
|
|
170
|
+
index: r
|
|
171
|
+
}), i = t[d], f = a(i) ? h(i, t, n + 1) : [];
|
|
172
|
+
if (u || f.length > 0) {
|
|
173
|
+
const p = { ...t };
|
|
174
|
+
f.length > 0 ? p[d] = f : delete p[d], e.push(p);
|
|
245
175
|
}
|
|
246
176
|
}
|
|
247
|
-
return
|
|
177
|
+
return e;
|
|
248
178
|
}
|
|
249
|
-
return
|
|
179
|
+
return h(s);
|
|
250
180
|
}
|
|
251
|
-
|
|
252
|
-
|
|
181
|
+
export {
|
|
182
|
+
A as buildTree,
|
|
183
|
+
V as filterTree,
|
|
184
|
+
b as filterTreeWithAncestors,
|
|
185
|
+
C as findNodeInTree,
|
|
186
|
+
y as flattenTree,
|
|
187
|
+
R as mapTree,
|
|
188
|
+
F as traverseTree
|
|
189
|
+
};
|
package/dist/es/utils/zod.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { z } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
z
|
|
1
|
+
import { z as o } from "zod";
|
|
2
|
+
import { z as t } from "zod";
|
|
3
|
+
import { zhCN as r } from "zod/locales";
|
|
4
|
+
o.config(r());
|
|
5
|
+
export {
|
|
6
|
+
t as z
|
|
7
|
+
};
|