dozy 1.0.50 → 1.0.51

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.
@@ -0,0 +1,117 @@
1
+ # Color Module
2
+
3
+ A powerful color manipulation module built on top of [culori](https://github.com/Evercoder/culori). It supports all CSS color spaces (RGB, HSL, OKLCH, etc.), smart parsing, and custom aliases.
4
+
5
+ ## Features
6
+
7
+ - **Universal Support**: Works with Hex, RGB, HSL, OKLCH, P3, and named colors.
8
+ - **Smart Parsing**:
9
+ - Auto-detects Hex codes without `#` (e.g., `ff0000` -> `#ff0000`).
10
+ - Supports 3, 4, 6, and 8-digit Hex codes.
11
+ - Accepts `Color` objects directly (passthrough).
12
+ - **Custom Aliases**: Pre-defined short codes for common colors.
13
+ - **Flexible Inputs**: All functions accept `string | Color | any`.
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import {
19
+ smartParse,
20
+ smartString,
21
+ toHexString,
22
+ toRgbaArray,
23
+ getBrightness,
24
+ registerCustomColor,
25
+ } from 'dozy'
26
+
27
+ // Smart Parsing
28
+ smartParse('ff0000') // -> Color object for red
29
+ smartParse('abc') // -> Color object for #aabbcc (via auto-hex or custom alias)
30
+ smartParse('oklch(60% 0.15 50)') // -> Color object
31
+
32
+ // Smart String (returns CSS string)
33
+ smartString('ff0000') // -> "#ff0000"
34
+ smartString('red') // -> "red"
35
+
36
+ // Conversions
37
+ toHexString('rgb(255, 0, 0)') // -> "#ff0000"
38
+ toRgbString('#f00') // -> "rgb(255, 0, 0)"
39
+ toHslString('blue') // -> "hsl(240, 100%, 50%)"
40
+
41
+ // Brightness (0-1)
42
+ getBrightness('#000') // -> 0
43
+ getBrightness('#fff') // -> 1
44
+ ```
45
+
46
+ ## Pre-defined Aliases
47
+
48
+ | Alias | Color | Hex |
49
+ | ----- | ------------ | --------- |
50
+ | `v` | Black | `#000000` |
51
+ | `w` | White | `#FFFFFF` |
52
+ | `V` | Dark Grey | `#555555` |
53
+ | `W` | Light Grey | `#AAAAAA` |
54
+ | `R` | Dark Red | `#AA0000` |
55
+ | `r` | Light Red | `#FF5555` |
56
+ | `G` | Dark Green | `#00AA00` |
57
+ | `g` | Light Green | `#55FF55` |
58
+ | `B` | Dark Blue | `#0000AA` |
59
+ | `b` | Light Blue | `#5555FF` |
60
+ | `Y` | Dark Yellow | `#FFAA00` |
61
+ | `y` | Light Yellow | `#FFFF55` |
62
+ | `A` | Dark Cyan | `#00AAAA` |
63
+ | `a` | Light Cyan | `#55FFFF` |
64
+ | `P` | Dark Purple | `#AA00AA` |
65
+ | `p` | Light Purple | `#FF55FF` |
66
+ | `i` | Pink | `#FfC0CB` |
67
+
68
+ ## API Reference
69
+
70
+ ### `smartParse(input: string | Color | any, fallback?: string): Color | undefined`
71
+
72
+ Smartly parses a color string or object.
73
+
74
+ - **input**: The color string (e.g., `'#fff'`, `'ff0000'`, `'red'`) or a `Color` object.
75
+ - **fallback**: Optional color to return if parsing fails.
76
+
77
+ ### `smartString(input: string | Color | any, fallback?: string): string | undefined`
78
+
79
+ Parses a color and returns a valid CSS string (Hex for sRGB, functional notation for others).
80
+
81
+ ### `isValidColor(input: string | Color | any): boolean`
82
+
83
+ Checks if the input is a valid color.
84
+
85
+ ### `getBrightness(input: string | Color | any): number`
86
+
87
+ Calculates brightness using Rec. 601 luma formula: `(R*299 + G*587 + B*114) / 1000`.
88
+
89
+ - Returns: `0` (black) to `1` (white).
90
+
91
+ ### `toHexString(input: string | Color | any): string | undefined`
92
+
93
+ Converts input to a Hex string (e.g., `#ff0000`).
94
+
95
+ ### `toRgbString(input: string | Color | any): string | undefined`
96
+
97
+ Converts input to `rgb()` or `rgba()` string.
98
+
99
+ ### `toHslString(input: string | Color | any): string | undefined`
100
+
101
+ Converts input to `hsl()` or `hsla()` string.
102
+
103
+ ### `toRgbaArray(input: string | Color | any): [number, number, number, number] | undefined`
104
+
105
+ Returns an array `[r, g, b, a]`.
106
+
107
+ - `r, g, b`: 0-255
108
+ - `a`: 0-1
109
+
110
+ ### `registerCustomColor(name: string, color: string): void`
111
+
112
+ Registers a new global alias.
113
+
114
+ ```typescript
115
+ registerCustomColor('myBrand', '#123456')
116
+ smartParse('myBrand') // -> Color object for #123456
117
+ ```
@@ -0,0 +1,2 @@
1
+ var i=Object.create;var f=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var g=a=>{throw TypeError(a)};var o=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var p=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports),q=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0})},n=(a,b,c,d)=>{if(b&&typeof b=="object"||typeof b=="function")for(let e of k(b))!m.call(a,e)&&e!==c&&f(a,e,{get:()=>b[e],enumerable:!(d=j(b,e))||d.enumerable});return a};var r=(a,b,c)=>(c=a!=null?i(l(a)):{},n(b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c,a));var h=(a,b,c)=>b.has(a)||g("Cannot "+c);var s=(a,b,c)=>(h(a,b,"read from private field"),c?c.call(a):b.get(a)),t=(a,b,c)=>b.has(a)?g("Cannot add the same private member more than once"):b instanceof WeakSet?b.add(a):b.set(a,c),u=(a,b,c,d)=>(h(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c);export{o as a,p as b,q as c,r as d,s as e,t as f,u as g};
2
+ //# sourceMappingURL=chunk-7Q6CTFBS.js.map
package/dist/index.d.ts CHANGED
@@ -9,8 +9,7 @@ export { default as axios } from 'axios';
9
9
  import * as lodashEs from 'lodash-es';
10
10
  export { lodashEs as l };
11
11
  export { default as Cryptojs } from 'crypto-js';
12
- export * from 'zod';
13
- export { default as z } from 'zod';
12
+ export { customAlphabet, nanoid, urlAlphabet } from 'nanoid';
14
13
 
15
14
  type DozyConfigItem = {};
16
15
  type DozyConfig = Partial<DozyConfigItem>;
@@ -315,6 +314,6 @@ declare function toRgbString(input: string | Color | any): string | undefined;
315
314
  */
316
315
  declare function toHslString(input: string | Color | any): string | undefined;
317
316
 
318
- declare const DOZY = "1.0.50";
317
+ declare const DOZY = "1.0.51";
319
318
 
320
319
  export { $Headers, $Request, $Response, $URL, $URLSearchParams, $arrayFrom, $arrayIsArray, $assign, $capitalize, $checkValidEmailWithUnicode, $clamp, $clearInterval, $clearTimeout, $clone, $compressImage, $copy, $crypto, $date, $decodeBase64ToBinary, $decodeBase64ToUnicode, $deepClone, $defineProperty, $document, $encodeUnicodeToBase64, $entries, $escapeHTML, $fallbackCopy, $fetch, $fileToBase64, $formatDate, $formatWithCommas, $freeze, $genSSF, $getFileType, $getTimeString, $hasKey, $if, $inRange, $inRange2, $is, $isObject, $isPlainClass, $isValidEmailWithUnicode, $isValidOrBriefURL, $jsonParse, $jsonStringify, $keys, $lastIndex, $lindex, $loadOpt, $location, $log, $lplus, $magic, $math, $now, $numberIsFinite, $numberIsNaN, $oc, $open, $parseParams, $promise, $pureText, $randomByte, $replaceHolesWithUndefined, $rmvSlash, $rsValue, $rsetValue, $rvalue, $s, $sc, $setInterval, $setRange, $setTimeout, $stringFromCharCode, $stringFromCodePoint, $stringToRange, $strings, $validName, $values, $window, DOZY, type DozyConfig, type DozyConfigItem, type FileType, Gens, type Items, RainbowGen, type ScaleComputer, type ScaleIniter, StringObfuscator, __GensDirectives, _res, boxShadow, dozy, enableScaler, errMsg, errToString, getBrightness, getColorMap, isValidColor, maybeString, registerCustomColor, s, smallChance, smartParse, smartString, standardIniter, textShadow, toHexString, toHslString, toRgbString, toRgbaArray, web$enableHttpsRedirect, web$enableProdProtector, web$encodeURI, web$pathStartData, web$redirectToDomain, web$setPathTarget, xtrim };