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