yxuse 3.0.16 → 3.0.17
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/lib/index.cjs2.js +4 -4
- package/lib/index.cjs2.js.gz +0 -0
- package/lib/index.cjs3.js +1 -1
- package/lib/index.es2.js +221 -221
- package/lib/index.es2.js.gz +0 -0
- package/lib/index.es3.js +93 -74
- package/lib/utils.cjs.js +1 -1
- package/lib/utils.es.js +6 -5
- package/package.json +1 -1
- package/types/utils/common/index.d.ts +1 -0
package/lib/index.es2.js.gz
CHANGED
|
Binary file
|
package/lib/index.es3.js
CHANGED
|
@@ -1,112 +1,131 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { h as
|
|
5
|
-
const B = (
|
|
6
|
-
new BroadcastChannel("YXUSE_BC").postMessage(
|
|
7
|
-
},
|
|
1
|
+
var M = Object.defineProperty;
|
|
2
|
+
var w = (n, s, t) => s in n ? M(n, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[s] = t;
|
|
3
|
+
var d = (n, s, t) => (w(n, typeof s != "symbol" ? s + "" : s, t), t);
|
|
4
|
+
import { h as y } from "./index.es6.js";
|
|
5
|
+
const B = (n) => {
|
|
6
|
+
new BroadcastChannel("YXUSE_BC").postMessage(n);
|
|
7
|
+
}, S = (n) => {
|
|
8
8
|
const s = new BroadcastChannel("YXUSE_BC");
|
|
9
9
|
s.onmessage = () => {
|
|
10
|
-
|
|
10
|
+
n();
|
|
11
11
|
};
|
|
12
|
-
},
|
|
13
|
-
label:
|
|
14
|
-
value:
|
|
15
|
-
})) : [], x = (
|
|
12
|
+
}, F = (n, s, t, u) => Array.isArray(n) ? n.map((a) => ({
|
|
13
|
+
label: a == null ? void 0 : a[s],
|
|
14
|
+
value: u ? +a[t] : a[t]
|
|
15
|
+
})) : [], x = (n) => {
|
|
16
16
|
const s = [];
|
|
17
|
-
for (const
|
|
18
|
-
isNaN(Number(
|
|
17
|
+
for (const t in n)
|
|
18
|
+
isNaN(Number(t)) && s.push({ label: t, value: n[t] });
|
|
19
19
|
return s;
|
|
20
|
-
},
|
|
21
|
-
const
|
|
22
|
-
let
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
else if (
|
|
27
|
-
|
|
20
|
+
}, W = (n) => {
|
|
21
|
+
const t = ((i) => {
|
|
22
|
+
let o = 0, C = 0, I = 0, m = 1;
|
|
23
|
+
if (i.startsWith("#"))
|
|
24
|
+
if (i = i.slice(1), i.length === 3)
|
|
25
|
+
o = parseInt(i[0] + i[0], 16), C = parseInt(i[1] + i[1], 16), I = parseInt(i[2] + i[2], 16);
|
|
26
|
+
else if (i.length === 6)
|
|
27
|
+
o = parseInt(i.slice(0, 2), 16), C = parseInt(i.slice(2, 4), 16), I = parseInt(i.slice(4, 6), 16);
|
|
28
28
|
else
|
|
29
29
|
return null;
|
|
30
|
-
else if (
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
|
|
30
|
+
else if (i.startsWith("rgb")) {
|
|
31
|
+
const c = i.match(/(\d+(\.\d+)?)/g);
|
|
32
|
+
if (c)
|
|
33
|
+
o = parseFloat(c[0]), C = parseFloat(c[1]), I = parseFloat(c[2]), c.length > 3 && (m = parseFloat(c[3]));
|
|
34
34
|
else
|
|
35
35
|
return null;
|
|
36
36
|
} else
|
|
37
37
|
return null;
|
|
38
|
-
return [
|
|
39
|
-
})(
|
|
40
|
-
if (!
|
|
38
|
+
return [o, C, I, m];
|
|
39
|
+
})(n);
|
|
40
|
+
if (!t)
|
|
41
41
|
return null;
|
|
42
|
-
const [
|
|
43
|
-
return (
|
|
44
|
-
},
|
|
45
|
-
const
|
|
46
|
-
let
|
|
47
|
-
if (
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
else if (
|
|
51
|
-
|
|
42
|
+
const [u, a, r, p] = t, e = u / 255, b = a / 255, l = r / 255, g = Math.max(e, b, l), f = Math.min(e, b, l);
|
|
43
|
+
return (g + f) / 2 < 0.5;
|
|
44
|
+
}, _ = (n, s, t = 100) => {
|
|
45
|
+
const u = (e) => {
|
|
46
|
+
let b, l, g, f = 1;
|
|
47
|
+
if (e.startsWith("#"))
|
|
48
|
+
if (e = e.slice(1), e.length === 3)
|
|
49
|
+
b = parseInt(e[0] + e[0], 16), l = parseInt(e[1] + e[1], 16), g = parseInt(e[2] + e[2], 16);
|
|
50
|
+
else if (e.length === 6)
|
|
51
|
+
b = parseInt(e.slice(0, 2), 16), l = parseInt(e.slice(2, 4), 16), g = parseInt(e.slice(4, 6), 16);
|
|
52
52
|
else
|
|
53
53
|
return null;
|
|
54
|
-
else if (
|
|
55
|
-
const h =
|
|
56
|
-
|
|
54
|
+
else if (e.startsWith("rgb")) {
|
|
55
|
+
const h = e.match(/(\d+(\.\d+)?)/g);
|
|
56
|
+
b = parseFloat(h[0]), l = parseFloat(h[1]), g = parseFloat(h[2]), h.length > 3 && (f = parseFloat(h[3]));
|
|
57
57
|
} else
|
|
58
58
|
return null;
|
|
59
|
-
return [
|
|
60
|
-
},
|
|
61
|
-
if (!
|
|
59
|
+
return [b, l, g, f];
|
|
60
|
+
}, a = u(n), r = u(s);
|
|
61
|
+
if (!a || !r)
|
|
62
62
|
return !1;
|
|
63
|
-
const
|
|
64
|
-
Math.pow(
|
|
63
|
+
const p = Math.sqrt(
|
|
64
|
+
Math.pow(a[0] - r[0], 2) + Math.pow(a[1] - r[1], 2) + Math.pow(a[2] - r[2], 2) + Math.pow(a[3] - r[3], 2)
|
|
65
65
|
);
|
|
66
|
-
return console.log(
|
|
66
|
+
return console.log(p), p <= t;
|
|
67
|
+
}, $ = (n, s) => {
|
|
68
|
+
function t(r) {
|
|
69
|
+
if (r.toLowerCase().startsWith("rgba"))
|
|
70
|
+
return r.toLowerCase();
|
|
71
|
+
if (r.toLowerCase().startsWith("rgb"))
|
|
72
|
+
return r.replace("rgb", "rgba").replace(")", ", 1)");
|
|
73
|
+
if (r.length === 7) {
|
|
74
|
+
const p = parseInt(r.substring(1, 3), 16), e = parseInt(r.substring(3, 5), 16), b = parseInt(r.substring(5, 7), 16);
|
|
75
|
+
return `rgba(${p}, ${e}, ${b}, 1)`;
|
|
76
|
+
} else if (r.length === 9 && r.toLowerCase().startsWith("rrggbbaa")) {
|
|
77
|
+
const p = parseInt(r.substring(1, 3), 16), e = parseInt(r.substring(3, 5), 16), b = parseInt(r.substring(5, 7), 16), l = Math.round(parseInt(r.substring(7, 9), 16) / 255 * 100) / 100;
|
|
78
|
+
return `rgba(${p}, ${e}, ${b}, ${l})`;
|
|
79
|
+
} else
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const u = t(n), a = t(s);
|
|
83
|
+
return !u || !a ? !1 : u === a;
|
|
67
84
|
};
|
|
68
|
-
class
|
|
85
|
+
class z {
|
|
69
86
|
constructor() {
|
|
70
|
-
|
|
87
|
+
d(this, "subscribers");
|
|
71
88
|
this.subscribers = {};
|
|
72
89
|
}
|
|
73
|
-
subscribe(s,
|
|
74
|
-
this.subscribers[s] || (this.subscribers[s] = []), this.subscribers[s].push(
|
|
90
|
+
subscribe(s, t) {
|
|
91
|
+
this.subscribers[s] || (this.subscribers[s] = []), this.subscribers[s].push(t);
|
|
75
92
|
}
|
|
76
|
-
unsubscribe(s,
|
|
77
|
-
const
|
|
78
|
-
if (!
|
|
93
|
+
unsubscribe(s, t) {
|
|
94
|
+
const u = this.subscribers[s];
|
|
95
|
+
if (!t)
|
|
79
96
|
return this.subscribers[s] = [];
|
|
80
|
-
if (
|
|
81
|
-
const
|
|
82
|
-
|
|
97
|
+
if (u) {
|
|
98
|
+
const a = u.indexOf(t);
|
|
99
|
+
a !== -1 && u.splice(a, 1);
|
|
83
100
|
}
|
|
84
101
|
}
|
|
85
102
|
publish(s) {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
103
|
+
const t = this.subscribers[s.type];
|
|
104
|
+
t && t.forEach((u) => {
|
|
105
|
+
u(s.data);
|
|
89
106
|
});
|
|
90
107
|
}
|
|
91
108
|
}
|
|
92
|
-
const
|
|
109
|
+
const A = new z(), v = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
93
110
|
__proto__: null,
|
|
94
|
-
areColorsSimilar:
|
|
111
|
+
areColorsSimilar: _,
|
|
95
112
|
enumToArray: x,
|
|
96
|
-
getSelectOptions:
|
|
97
|
-
http:
|
|
98
|
-
|
|
113
|
+
getSelectOptions: F,
|
|
114
|
+
http: y,
|
|
115
|
+
isColorEqual: $,
|
|
116
|
+
isDarkColor: W,
|
|
99
117
|
notifyMessageToSystems: B,
|
|
100
|
-
receiveMessage:
|
|
101
|
-
yxSubscribe:
|
|
118
|
+
receiveMessage: S,
|
|
119
|
+
yxSubscribe: A
|
|
102
120
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
103
121
|
export {
|
|
104
|
-
|
|
122
|
+
W as a,
|
|
123
|
+
_ as b,
|
|
105
124
|
x as e,
|
|
106
|
-
|
|
107
|
-
|
|
125
|
+
F as g,
|
|
126
|
+
$ as i,
|
|
108
127
|
B as n,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
128
|
+
S as r,
|
|
129
|
+
v as u,
|
|
130
|
+
A as y
|
|
112
131
|
};
|
package/lib/utils.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index.cjs6.js"),e=require("./index.cjs3.js");require("element-plus");exports.http=r.http;exports.areColorsSimilar=e.areColorsSimilar;exports.enumToArray=e.enumToArray;exports.getSelectOptions=e.getSelectOptions;exports.isDarkColor=e.isDarkColor;exports.notifyMessageToSystems=e.notifyMessageToSystems;exports.receiveMessage=e.receiveMessage;exports.yxSubscribe=e.yxSubscribe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index.cjs6.js"),e=require("./index.cjs3.js");require("element-plus");exports.http=r.http;exports.areColorsSimilar=e.areColorsSimilar;exports.enumToArray=e.enumToArray;exports.getSelectOptions=e.getSelectOptions;exports.isColorEqual=e.isColorEqual;exports.isDarkColor=e.isDarkColor;exports.notifyMessageToSystems=e.notifyMessageToSystems;exports.receiveMessage=e.receiveMessage;exports.yxSubscribe=e.yxSubscribe;
|
package/lib/utils.es.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { h as r } from "./index.es6.js";
|
|
2
|
-
import {
|
|
2
|
+
import { b as i, e as t, g as l, i as m, a as p, n as y, r as g, y as n } from "./index.es3.js";
|
|
3
3
|
import "element-plus";
|
|
4
4
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
i as areColorsSimilar,
|
|
6
|
+
t as enumToArray,
|
|
7
|
+
l as getSelectOptions,
|
|
8
8
|
r as http,
|
|
9
|
+
m as isColorEqual,
|
|
9
10
|
p as isDarkColor,
|
|
10
11
|
y as notifyMessageToSystems,
|
|
11
12
|
g as receiveMessage,
|
|
12
|
-
|
|
13
|
+
n as yxSubscribe
|
|
13
14
|
};
|
package/package.json
CHANGED
|
@@ -42,4 +42,5 @@ export declare const isDarkColor: (color: string) => boolean | null;
|
|
|
42
42
|
* @param threshold 阈值,用于判断两个颜色是否相近
|
|
43
43
|
*/
|
|
44
44
|
export declare const areColorsSimilar: (color1: string, color2: string, threshold?: number) => boolean;
|
|
45
|
+
export declare const isColorEqual: (color1: any, color2: any) => boolean;
|
|
45
46
|
export {};
|