@vef-framework/shared 2.0.11 → 2.1.0
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/_internal/_rolldown/runtime.cjs +1 -0
- package/dist/cjs/color/color-ops.cjs +1 -1
- package/dist/cjs/color/index.cjs +1 -1
- package/dist/cjs/color/name.cjs +1 -1
- package/dist/cjs/color/palette.cjs +1 -1
- package/dist/cjs/constants/color-names.cjs +1 -1
- package/dist/cjs/constants/color-palettes.cjs +1 -1
- package/dist/cjs/constants/index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/types/color.cjs +0 -1
- package/dist/cjs/types/common.cjs +0 -1
- package/dist/cjs/types/deep-keys.cjs +0 -1
- package/dist/cjs/types/index.cjs +0 -1
- package/dist/cjs/utils/chrono.cjs +1 -1
- package/dist/cjs/utils/equal.cjs +1 -1
- package/dist/cjs/utils/error.cjs +2 -3
- package/dist/cjs/utils/event.cjs +1 -1
- package/dist/cjs/utils/format.cjs +1 -1
- package/dist/cjs/utils/function.cjs +1 -1
- package/dist/cjs/utils/id.cjs +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/cjs/utils/key.cjs +1 -1
- package/dist/cjs/utils/lib.cjs +1 -1
- package/dist/cjs/utils/object.cjs +1 -1
- package/dist/cjs/utils/path.cjs +1 -1
- package/dist/cjs/utils/pinyin.cjs +1 -1
- package/dist/cjs/utils/security.cjs +1 -1
- package/dist/cjs/utils/string.cjs +1 -1
- package/dist/cjs/utils/table.cjs +1 -1
- package/dist/cjs/utils/task.cjs +1 -1
- package/dist/cjs/utils/tree.cjs +1 -1
- package/dist/cjs/utils/zod.cjs +1 -1
- package/dist/es/color/color-ops.js +55 -68
- package/dist/es/color/index.js +4 -18
- package/dist/es/color/name.js +25 -27
- package/dist/es/color/palette.js +70 -82
- package/dist/es/constants/color-names.js +1572 -1572
- package/dist/es/constants/color-palettes.js +1085 -360
- package/dist/es/constants/index.js +3 -8
- package/dist/es/index.js +25 -167
- 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 +1 -3
- package/dist/es/utils/chrono.js +77 -92
- package/dist/es/utils/equal.js +83 -118
- package/dist/es/utils/error.js +27 -29
- package/dist/es/utils/event.js +27 -51
- package/dist/es/utils/format.js +27 -18
- package/dist/es/utils/function.js +26 -36
- package/dist/es/utils/id.js +21 -21
- package/dist/es/utils/index.js +18 -81
- package/dist/es/utils/key.js +17 -23
- package/dist/es/utils/lib.js +8 -64
- package/dist/es/utils/object.js +12 -12
- package/dist/es/utils/path.js +37 -58
- package/dist/es/utils/pinyin.js +41 -43
- package/dist/es/utils/security.js +73 -31
- package/dist/es/utils/string.js +19 -7
- package/dist/es/utils/table.js +13 -13
- package/dist/es/utils/task.js +6 -7
- package/dist/es/utils/tree.js +159 -181
- package/dist/es/utils/zod.js +7 -7
- package/dist/types/constants/color-names.d.ts +2 -2
- package/dist/types/constants/color-palettes.d.ts +2 -2
- package/dist/types/src/color/color-ops.d.ts +84 -0
- package/dist/types/src/color/index.d.ts +3 -0
- package/dist/types/src/color/name.d.ts +7 -0
- package/dist/types/src/color/palette.d.ts +8 -0
- package/dist/types/src/constants/color-names.d.ts +11 -0
- package/dist/types/src/constants/color-palettes.d.ts +823 -0
- package/dist/types/src/constants/index.d.ts +2 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/types/color.d.ts +25 -0
- package/dist/types/src/types/common.d.ts +29 -0
- package/dist/types/src/types/deep-keys.d.ts +37 -0
- package/dist/types/src/types/index.d.ts +3 -0
- package/dist/types/src/utils/chrono.d.ts +152 -0
- package/dist/types/src/utils/equal.d.ts +16 -0
- package/dist/types/src/utils/error.d.ts +22 -0
- package/dist/types/src/utils/event.d.ts +46 -0
- package/dist/types/src/utils/format.d.ts +31 -0
- package/dist/types/src/utils/function.d.ts +27 -0
- package/dist/types/src/utils/id.d.ts +6 -0
- package/dist/types/src/utils/index.d.ts +18 -0
- package/dist/types/src/utils/key.d.ts +5 -0
- package/dist/types/src/utils/lib.d.ts +5 -0
- package/dist/types/src/utils/object.d.ts +9 -0
- package/dist/types/src/utils/path.d.ts +13 -0
- package/dist/types/src/utils/pinyin.d.ts +40 -0
- package/dist/types/src/utils/security.d.ts +60 -0
- package/dist/types/src/utils/string.d.ts +15 -0
- package/dist/types/src/utils/table.d.ts +25 -0
- package/dist/types/src/utils/task.d.ts +4 -0
- package/dist/types/src/utils/tree.d.ts +216 -0
- package/dist/types/src/utils/zod.d.ts +2 -0
- package/dist/types/types/color.d.ts +1 -49
- package/dist/types/types/common.d.ts +7 -3
- package/dist/types/types/deep-keys.d.ts +28 -0
- package/dist/types/utils/chrono.d.ts +3 -13
- package/dist/types/utils/error.d.ts +5 -21
- package/dist/types/utils/event.d.ts +9 -31
- package/dist/types/utils/format.d.ts +0 -2
- package/dist/types/utils/function.d.ts +4 -36
- package/dist/types/utils/id.d.ts +2 -2
- package/dist/types/utils/key.d.ts +2 -4
- package/dist/types/utils/path.d.ts +7 -70
- package/dist/types/utils/pinyin.d.ts +2 -3
- package/dist/types/utils/security.d.ts +44 -2
- package/dist/types/utils/string.d.ts +8 -0
- package/dist/types/utils/table.d.ts +1 -0
- package/dist/types/utils/task.d.ts +1 -3
- package/dist/types/utils/tree.d.ts +8 -0
- package/dist/types/utils/zod.d.ts +1 -0
- package/package.json +13 -13
package/dist/cjs/utils/lib.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require(`../_internal/_rolldown/runtime.cjs`);let e=require(`radashi`);require(`klona`),require(`qs`);var t=(0,e.always)(!0),n=(0,e.always)(!1);exports.alwaysFalse=n,exports.alwaysTrue=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require(`../_internal/_rolldown/runtime.cjs`);let e=require(`radashi`);function t(t,n,r=!1){for(let[i,a]of Object.entries(n)){if((0,e.isUndefined)(a))continue;let n=i;(r||(0,e.isUndefined)(t[n]))&&(t[n]=a)}return t}exports.mergeWith=t;
|
package/dist/cjs/utils/path.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`../_internal/_rolldown/runtime.cjs`);let t=require(`path-browserify`);t=e.__toESM(t);function n(e,n=!0){let r=n?void 0:t.default.extname(e);return t.default.basename(e,r)}function r(e){return t.default.extname(e)}function i(e){return t.default.dirname(e)}function a(...e){return t.default.join(...e)}function o(e){return t.default.isAbsolute(e)}function s(e){return t.default.normalize(e)}function c(e){return t.default.parse(e)}function l(e){return t.default.format(e)}function u(e,n){return t.default.relative(e,n)}function d(...e){return t.default.resolve(...e)}var f=t.default.sep;exports.formatPath=l,exports.getBaseName=n,exports.getDirName=i,exports.getExtName=r,exports.getRelativePath=u,exports.isAbsolutePath=o,exports.joinPaths=a,exports.normalizePath=s,exports.parsePath=c,exports.pathSeparator=f,exports.resolvePath=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`../_internal/_rolldown/runtime.cjs`);let t=require(`@pinyin-pro/data/modern`);t=e.__toESM(t);let n=require(`pinyin-pro`),r=require(`radashi`);(0,n.addDict)(t.default);var i={type:`array`,toneType:`none`,multiple:!1,nonZh:`consecutive`,surname:`head`},a=new Map,o=new Map;function s(e){let t=a.get(e);if(t)return t;let r=(0,n.pinyin)(e,{...i,pattern:`pinyin`});return a.set(e,r),r}function c(e){let t=o.get(e);if(t)return t;let r=(0,n.pinyin)(e,{...i,pattern:`first`});return o.set(e,r),r}function l(e,...t){let n={...e};for(let i of t){let t=e[i];if((0,r.isString)(t)){let e=`${i}Pinyin`,r=`${i}PinyinInitials`;n[e]=s(t).join(``),n[r]=c(t).join(``)}}return n}exports.getPinyin=s,exports.getPinyinInitials=c,exports.withPinyin=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`../_internal/_rolldown/runtime.cjs`);let t=require(`jsencrypt`);t=e.__toESM(t);let n=require(`radashi`);var r=new Uint8Array([90,75,60,45,30,15,154,139,124,109,94,79,58,43,28,13]);function i(e){if(!e)return new Uint8Array;let t=new TextEncoder().encode(e),n=new Uint8Array(t.length);for(let[e,i]of t.entries())n[e]=i^r[e%r.length];return n}function a(e){if(!e?.length)return``;let t=e instanceof Uint8Array?e:new Uint8Array(e),n=new Uint8Array(t.length);for(let[e,i]of t.entries())n[e]=i^r[e%r.length];return new TextDecoder(`utf-8`).decode(n)}function o(e){return[...i(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}function s(e){if(!e)return``;let t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=Number.parseInt(e.slice(n,n+2),16);return a(t)}function c(e){let t=i(e);if(t.length===0)return``;let n=String.fromCodePoint(...t);return btoa(n)}function l(e){if(!e)return``;let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.codePointAt(e);return a(n)}function u(e,r){if((0,n.isNullish)(e)||!r?.trim())throw Error(`Failed to encrypt data using RSA: invalid input`);let i=new t.default;i.setPublicKey(r);let a=i.encrypt(e);if(!a)throw console.error(`Failed to encrypt data using RSA`),Error(`Failed to encrypt data using RSA`);return a}function d(e,r){if((0,n.isNullish)(e)||!r?.trim())throw Error(`Failed to decrypt data using RSA: invalid input`);let i=new t.default;i.setPrivateKey(r);let a=i.decrypt(e);if(!a)throw console.error(`Failed to decrypt data using RSA`),Error(`Failed to decrypt data using RSA`);return a}exports.decryptUsingRSA=d,exports.encryptUsingRSA=u,exports.obfuscateDecode=a,exports.obfuscateDecodeFromBase64=l,exports.obfuscateDecodeFromHex=s,exports.obfuscateEncode=i,exports.obfuscateEncodeToBase64=c,exports.obfuscateEncodeToHex=o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require(`../_internal/_rolldown/runtime.cjs`);let e=require(`radashi`);function t(t){return(0,e.snake)(t).toUpperCase()}function n(e,t=!0){if(e===null)return t?``:`null`;if(e===void 0)return t?``:`undefined`;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);if(typeof e==`symbol`||typeof e==`function`)return e.toString();try{return JSON.stringify(e)}catch{return String(e)}}exports.constantCase=t,exports.stringify=n;
|
package/dist/cjs/utils/table.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require(`../_internal/_rolldown/runtime.cjs`);const e=require(`./equal.cjs`);let t=require(`radashi`);var n={reference:(e,t)=>e===t,shallow:e.isShallowEqual,deep:e.isDeepEqual};function r(e,...r){let i=(0,t.isPlainObject)(e)&&`compare`in e,a=i?e:{},o=i?r:[e,...r],s=n[a.compare??`reference`];return(e,t)=>o.some(n=>!s(e?.[n],t?.[n]))}exports.shouldUpdateByKeys=r;
|
package/dist/cjs/utils/task.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e){typeof queueMicrotask==`function`?queueMicrotask(e):Promise.resolve().then(e)}exports.scheduleMicrotask=e;
|
package/dist/cjs/utils/tree.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require(`../_internal/_rolldown/runtime.cjs`);let e=require(`radashi`);function t(t,n={}){let{childrenKey:r=`children`,includeParent:i=!1,includeLevel:a=!1,transform:o,filter:s}=n,c=[];function l(t,n,u=0){if((0,e.isArray)(t))for(let d of t){let t={parent:n,level:u};if((0,e.isFunction)(s)&&!s(d,t)){let t=d[r];(0,e.isArray)(t)&&l(t,d,u+1);continue}let f=d;if((0,e.isFunction)(o))f=o(d,t);else if(i||a){let e={data:d};i&&(e.parent=n),a&&(e.level=u),f=e}c.push(f);let p=d[r];(0,e.isArray)(p)&&l(p,d,u+1)}}return l(t),c}function n(t,n){return(0,e.isFunction)(n)?n(t):t[n]}function r(t,r={}){let{idKey:i=`id`,parentIdKey:a=`parentId`,childrenKey:o=`children`,rootValue:s,transform:c}=r;if(!(0,e.isArray)(t)||t.length===0)return[];let l=new Map,u=[];for(let e of t){let t=n(e,i);l.set(t,{...e})}for(let r of t){let t=n(r,i),c=n(r,a),d=l.get(t);if((0,e.isFunction)(s)?s(r):c===s||(0,e.isNullish)(c))u.push(d);else{let t=l.get(c);t?((0,e.isArray)(t[o])||(t[o]=[]),t[o].push(d)):u.push(d)}}if((0,e.isFunction)(c)){let t=c;function n(r,i=0){let a=r[o],s=t(r,{children:a,level:i});return(0,e.isArray)(a)&&(s[o]=a.map(e=>n(e,i+1))),s}return u.map(e=>n(e))}return u}function i(t,n,r=`children`){function i(t,a,o=0){if((0,e.isArray)(t))for(let s of t){if(n(s,{parent:a,level:o}))return s;let t=s[r];if((0,e.isArray)(t)){let e=i(t,s,o+1);if(e)return e}}}return i(t)}function a(t,n,r={}){let{strategy:i=`dfs`,childrenKey:a=`children`}=r;if((0,e.isArray)(t))if(i===`bfs`){let r=t.map((e,t)=>({node:e,level:0,index:t})),i=0;for(;i<r.length;){let t=r[i++];n(t.node,{parent:t.parent,level:t.level,index:t.index});let o=t.node[a];if((0,e.isArray)(o))for(let[e,n]of o.entries())r.push({node:n,parent:t.node,level:t.level+1,index:e})}}else{function r(t,i,o=0){if((0,e.isArray)(t))for(let[s,c]of t.entries()){n(c,{parent:i,level:o,index:s});let t=c[a];(0,e.isArray)(t)&&r(t,c,o+1)}}r(t)}}function o(t,n,r=`children`){function i(t,a,o=0){return(0,e.isArray)(t)?t.map((t,s)=>{let c=n(t,{parent:a,level:o,index:s}),l=t[r];return(0,e.isArray)(l)&&(c[r]=i(l,t,o+1)),c}):[]}return i(t)}function s(t,n,r=`children`){function i(t,a,o=0){return(0,e.isArray)(t)?t.reduce((t,s,c)=>{if(!n(s,{parent:a,level:o,index:c}))return t;let l=s[r],u={...s};if(l&&(0,e.isArray)(l)){let e=i(l,s,o+1);e.length>0?u[r]=e:delete u[r]}return t.push(u),t},[]):[]}return i(t)}function c(t,n,r=`children`){function i(t,a,o=0){if(!(0,e.isArray)(t))return[];let s=[];for(let[c,l]of t.entries()){let t=n(l,{parent:a,level:o,index:c}),u=l[r],d=(0,e.isArray)(u)?i(u,l,o+1):[];if(t||d.length>0){let e={...l};d.length>0?e[r]=d:delete e[r],s.push(e)}}return s}return i(t)}exports.buildTree=r,exports.filterTree=s,exports.filterTreeWithAncestors=c,exports.findNodeInTree=i,exports.flattenTree=t,exports.mapTree=o,exports.traverseTree=a;
|
package/dist/cjs/utils/zod.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require(`../_internal/_rolldown/runtime.cjs`);let e=require(`zod`),t=require(`zod/locales`);e.z.config((0,t.zhCN)());
|
|
@@ -1,68 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
export {
|
|
57
|
-
G as convertHslToHex,
|
|
58
|
-
A as convertTransparentToOpaque,
|
|
59
|
-
E as getColorDifference,
|
|
60
|
-
O as isValidColor,
|
|
61
|
-
D as isWhiteColor,
|
|
62
|
-
W as mixColor,
|
|
63
|
-
R as setColorAlpha,
|
|
64
|
-
P as toHexColor,
|
|
65
|
-
q as toHslColor,
|
|
66
|
-
B as toHsvColor,
|
|
67
|
-
k as toRgbColor
|
|
68
|
-
};
|
|
1
|
+
/*! @vef-framework/shared v2.1.0 made by Venus | 2026-03-27T07:12:59.574Z */
|
|
2
|
+
import { colord as e, extend as t } from "colord";
|
|
3
|
+
import n from "colord/plugins/lab";
|
|
4
|
+
import r from "colord/plugins/mix";
|
|
5
|
+
import i from "colord/plugins/names";
|
|
6
|
+
//#region src/color/color-ops.ts
|
|
7
|
+
t([
|
|
8
|
+
i,
|
|
9
|
+
r,
|
|
10
|
+
n
|
|
11
|
+
]);
|
|
12
|
+
var a = "#ffffff";
|
|
13
|
+
function o(t) {
|
|
14
|
+
return e(t).isValid();
|
|
15
|
+
}
|
|
16
|
+
function s(t) {
|
|
17
|
+
return e(t).toHex();
|
|
18
|
+
}
|
|
19
|
+
function c(t) {
|
|
20
|
+
return e(t).toRgb();
|
|
21
|
+
}
|
|
22
|
+
function l(t) {
|
|
23
|
+
return e(t).toHsl();
|
|
24
|
+
}
|
|
25
|
+
function u(t) {
|
|
26
|
+
return e(t).toHsv();
|
|
27
|
+
}
|
|
28
|
+
function d(t, n) {
|
|
29
|
+
return e(t).delta(n);
|
|
30
|
+
}
|
|
31
|
+
function f(t) {
|
|
32
|
+
return e(t).toHex();
|
|
33
|
+
}
|
|
34
|
+
function p(t, n) {
|
|
35
|
+
return e(t).alpha(n).toHex();
|
|
36
|
+
}
|
|
37
|
+
function m(t, n, r) {
|
|
38
|
+
return e(t).mix(n, r).toHex();
|
|
39
|
+
}
|
|
40
|
+
function h(t, n, r = a) {
|
|
41
|
+
let i = e(p(t, n)).toRgb(), o = e(r).toRgb();
|
|
42
|
+
return e({
|
|
43
|
+
r: _(i.r, o.r, n),
|
|
44
|
+
g: _(i.g, o.g, n),
|
|
45
|
+
b: _(i.b, o.b, n)
|
|
46
|
+
}).toHex();
|
|
47
|
+
}
|
|
48
|
+
function g(t) {
|
|
49
|
+
return e(t).isEqual(a);
|
|
50
|
+
}
|
|
51
|
+
function _(e, t, n) {
|
|
52
|
+
return t + (e - t) * n;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { f as convertHslToHex, h as convertTransparentToOpaque, d as getColorDifference, o as isValidColor, g as isWhiteColor, m as mixColor, p as setColorAlpha, s as toHexColor, l as toHslColor, u as toHsvColor, c as toRgbColor };
|
package/dist/es/color/index.js
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
e as convertHslToHex,
|
|
6
|
-
t as convertTransparentToOpaque,
|
|
7
|
-
l as getColorDifference,
|
|
8
|
-
H as getColorName,
|
|
9
|
-
c as getColorPalette,
|
|
10
|
-
C as isValidColor,
|
|
11
|
-
a as isWhiteColor,
|
|
12
|
-
s as mixColor,
|
|
13
|
-
i as setColorAlpha,
|
|
14
|
-
p as toHexColor,
|
|
15
|
-
x as toHslColor,
|
|
16
|
-
f as toHsvColor,
|
|
17
|
-
m as toRgbColor
|
|
18
|
-
};
|
|
1
|
+
/*! @vef-framework/shared v2.1.0 made by Venus | 2026-03-27T07:12:59.574Z */
|
|
2
|
+
import "./color-ops.js";
|
|
3
|
+
import "./name.js";
|
|
4
|
+
import "./palette.js";
|
package/dist/es/color/name.js
CHANGED
|
@@ -1,32 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
import { toHexColor as
|
|
3
|
-
import { colorEntries as i } from "../constants/color-names.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/*! @vef-framework/shared v2.1.0 made by Venus | 2026-03-27T07:12:59.574Z */
|
|
2
|
+
import { toHexColor as e, toHslColor as t, toRgbColor as n } from "./color-ops.js";
|
|
3
|
+
import { colorEntries as r, colorNameMap as i } from "../constants/color-names.js";
|
|
4
|
+
//#region src/color/name.ts
|
|
5
|
+
var a = {
|
|
6
|
+
RGB: 1,
|
|
7
|
+
HSL: 2
|
|
7
8
|
};
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return e || i[s]?.[1] || "Unknown";
|
|
9
|
+
function o(a) {
|
|
10
|
+
let o = e(a), s = i.get(o);
|
|
11
|
+
if (s) return s;
|
|
12
|
+
let c = n(a), u = t(a), d = "Unknown", f = Infinity;
|
|
13
|
+
for (let [e, t] of r) {
|
|
14
|
+
let n = l(c, u, e);
|
|
15
|
+
n < f && (f = n, d = t);
|
|
16
|
+
}
|
|
17
|
+
return d;
|
|
19
18
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
19
|
+
function s(e, t) {
|
|
20
|
+
return (e.r - t.r) ** 2 + (e.g - t.g) ** 2 + (e.b - t.b) ** 2;
|
|
22
21
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
22
|
+
function c(e, t) {
|
|
23
|
+
return (e.h - t.h) ** 2 + (e.s - t.s) ** 2 + (e.l - t.l) ** 2;
|
|
25
24
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
function l(e, r, i) {
|
|
26
|
+
let o = n(i), l = t(i), u = s(e, o), d = c(r, l);
|
|
27
|
+
return u * a.RGB + d * a.HSL;
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { o as getColorName };
|
package/dist/es/color/palette.js
CHANGED
|
@@ -1,89 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
import "
|
|
3
|
-
import {
|
|
4
|
-
import { getColorName as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/*! @vef-framework/shared v2.1.0 made by Venus | 2026-03-27T07:12:59.574Z */
|
|
2
|
+
import { convertHslToHex as e, getColorDifference as t, isValidColor as n, toHslColor as r } from "./color-ops.js";
|
|
3
|
+
import { colorPalettes as i } from "../constants/color-palettes.js";
|
|
4
|
+
import { getColorName as a } from "./name.js";
|
|
5
|
+
import { lru as o } from "tiny-lru";
|
|
6
|
+
//#region src/color/palette.ts
|
|
7
|
+
var s = 500, c = o(100);
|
|
8
|
+
function l(e) {
|
|
9
|
+
if (c.has(e)) return c.get(e);
|
|
10
|
+
let { colorMap: t } = u(e);
|
|
11
|
+
return c.set(e, t), t;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
...t,
|
|
25
|
-
colorMap: r,
|
|
26
|
-
main: s,
|
|
27
|
-
matched: c
|
|
28
|
-
};
|
|
13
|
+
function u(e) {
|
|
14
|
+
let t = d(e), n = new Map(t.swatches.map((e) => [e.number, e.hex])), r = t.swatches.find((e) => e.number === s), i = t.swatches.find((t) => t.hex === e);
|
|
15
|
+
if (!r) throw Error(`Main color swatch (${s}) not found in palette`);
|
|
16
|
+
if (!i) throw Error("Matched color swatch not found in generated palette");
|
|
17
|
+
return {
|
|
18
|
+
...t,
|
|
19
|
+
colorMap: n,
|
|
20
|
+
main: r,
|
|
21
|
+
matched: i
|
|
22
|
+
};
|
|
29
23
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
24
|
+
function d(e) {
|
|
25
|
+
if (!n(e)) throw Error(`Invalid color format: "${e}". Please provide a valid color value.`);
|
|
26
|
+
let t = f(a(e)), o = r(e), { nearestLightnessSwatch: s, swatches: c } = h(e, i), l = p(o, s);
|
|
27
|
+
return {
|
|
28
|
+
name: t,
|
|
29
|
+
swatches: c.map((t) => s.number === t.number ? {
|
|
30
|
+
hex: e,
|
|
31
|
+
number: t.number
|
|
32
|
+
} : {
|
|
33
|
+
hex: m(t.hex, l),
|
|
34
|
+
number: t.number
|
|
35
|
+
})
|
|
36
|
+
};
|
|
44
37
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
38
|
+
function f(e) {
|
|
39
|
+
return e.toLowerCase().replaceAll(/\s+/g, "-");
|
|
47
40
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
function p(e, t) {
|
|
42
|
+
let n = r(t.hex);
|
|
43
|
+
return {
|
|
44
|
+
hueDelta: e.h - n.h,
|
|
45
|
+
saturationRatio: n.s > 0 ? e.s / n.s : 1
|
|
46
|
+
};
|
|
54
47
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
h: a,
|
|
63
|
-
s: n,
|
|
64
|
-
l: r
|
|
65
|
-
});
|
|
48
|
+
function m(t, n) {
|
|
49
|
+
let { h: i, s: a, l: o } = r(t);
|
|
50
|
+
return e({
|
|
51
|
+
h: i + n.hueDelta,
|
|
52
|
+
s: a * n.saturationRatio,
|
|
53
|
+
l: o
|
|
54
|
+
});
|
|
66
55
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
56
|
+
function h(e, n) {
|
|
57
|
+
let i = n.map((n) => {
|
|
58
|
+
let r = n.swatches.map((n) => ({
|
|
59
|
+
...n,
|
|
60
|
+
delta: t(e, n.hex)
|
|
61
|
+
})), i = r.reduce((e, t) => t.delta < e.delta ? t : e);
|
|
62
|
+
return {
|
|
63
|
+
...n,
|
|
64
|
+
swatches: r,
|
|
65
|
+
nearestSwatch: i
|
|
66
|
+
};
|
|
67
|
+
}).reduce((e, t) => t.nearestSwatch.delta < e.nearestSwatch.delta ? t : e), a = r(e).l, o = i.swatches.reduce((e, t) => {
|
|
68
|
+
let n = Math.abs(r(e.hex).l - a);
|
|
69
|
+
return Math.abs(r(t.hex).l - a) < n ? t : e;
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
...i,
|
|
73
|
+
nearestLightnessSwatch: o
|
|
74
|
+
};
|
|
86
75
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
};
|
|
76
|
+
//#endregion
|
|
77
|
+
export { l as getColorPalette };
|