@design-edito/tools 0.3.2 → 0.3.4
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/agnostic/arrays/dedupe/index.js +0 -2
- package/agnostic/arrays/find-duplicates/index.js +0 -2
- package/agnostic/arrays/is-array-of/index.js +2 -4
- package/agnostic/arrays/make/index.js +0 -2
- package/agnostic/arrays/random-pick/index.js +20 -5
- package/agnostic/arrays/shuffle/index.js +0 -2
- package/agnostic/booleans/is-falsy/index.js +10 -7
- package/agnostic/colors/channels/index.js +194 -12
- package/agnostic/colors/contrast/index.js +2 -13
- package/agnostic/colors/convert/index.js +553 -25
- package/agnostic/colors/distance/index.js +1 -10
- package/agnostic/colors/grayscale/index.js +6 -13
- package/agnostic/colors/invert/index.js +2 -14
- package/agnostic/colors/lerp/index.js +12 -19
- package/agnostic/colors/luminance/index.js +16 -10
- package/agnostic/colors/palette/index.js +1 -12
- package/agnostic/colors/rotate/index.js +36 -11
- package/agnostic/colors/tidy/index.js +55 -9
- package/agnostic/colors/typechecks/index.js +90 -14
- package/agnostic/colors/types.js +151 -4
- package/agnostic/css/bem/index.js +2 -9
- package/agnostic/css/generate-nice-color/index.js +0 -2
- package/agnostic/css/is-valid-css-class-name/index.js +5 -5
- package/agnostic/css/scale/index.js +2 -8
- package/agnostic/css/styles-set/index.js +1 -6
- package/agnostic/errors/register/index.js +0 -2
- package/agnostic/errors/unknown-to-string/index.js +7 -4
- package/agnostic/html/get-node-ancestors/index.js +18 -5
- package/agnostic/html/get-position-inside-parent/index.js +0 -2
- package/agnostic/html/hyper-json/cast/index.js +105 -22
- package/agnostic/html/hyper-json/index.js +16 -43
- package/agnostic/html/hyper-json/method/index.js +11 -4
- package/agnostic/html/hyper-json/serialize/index.js +67 -8
- package/agnostic/html/hyper-json/smart-tags/coalesced/add/index.js +17 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/addclass/index.js +31 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/and/index.js +16 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/append/index.js +39 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/at/index.js +41 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/call/index.js +31 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/clone/index.js +12 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/deleteproperties/index.js +42 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/equals/index.js +28 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/getattribute/index.js +26 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/getproperties/index.js +21 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/getproperty/index.js +55 -23
- package/agnostic/html/hyper-json/smart-tags/coalesced/hjparse/index.js +23 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/hjstringify/index.js +68 -24
- package/agnostic/html/hyper-json/smart-tags/coalesced/if/index.js +21 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/initialize/index.js +34 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/join/index.js +18 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/length/index.js +19 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/map/index.js +33 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/negate/index.js +12 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/notrailing/index.js +35 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/or/index.js +16 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/pickrandom/index.js +19 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/populate/index.js +68 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/print/index.js +24 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/push/index.js +12 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/pusheach/index.js +32 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/recordtoarray/index.js +12 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/removeattribute/index.js +48 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/removeclass/index.js +31 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/renameproperty/index.js +40 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/replace/index.js +48 -23
- package/agnostic/html/hyper-json/smart-tags/coalesced/select/index.js +34 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/set/index.js +28 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/setattribute/index.js +48 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/setproperty/index.js +170 -23
- package/agnostic/html/hyper-json/smart-tags/coalesced/sorton/index.js +78 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/split/index.js +20 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/spread/index.js +22 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/toarray/index.js +13 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/toboolean/index.js +13 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/toelement/index.js +18 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/toggleclass/index.js +31 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/tonodelist/index.js +13 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/tonull/index.js +12 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/tonumber/index.js +13 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/torecord/index.js +13 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/toref/index.js +14 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/tostring/index.js +13 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/totext/index.js +13 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/transformselected/index.js +78 -22
- package/agnostic/html/hyper-json/smart-tags/coalesced/trim/index.js +15 -22
- package/agnostic/html/hyper-json/smart-tags/index.js +28 -7
- package/agnostic/html/hyper-json/smart-tags/isolated/any/index.js +14 -8
- package/agnostic/html/hyper-json/smart-tags/isolated/array/index.js +11 -8
- package/agnostic/html/hyper-json/smart-tags/isolated/boolean/index.js +13 -22
- package/agnostic/html/hyper-json/smart-tags/isolated/element/index.js +24 -22
- package/agnostic/html/hyper-json/smart-tags/isolated/get/index.js +20 -22
- package/agnostic/html/hyper-json/smart-tags/isolated/global/index.js +15 -22
- package/agnostic/html/hyper-json/smart-tags/isolated/guess/index.js +47 -22
- package/agnostic/html/hyper-json/smart-tags/isolated/nodelist/index.js +22 -22
- package/agnostic/html/hyper-json/smart-tags/isolated/null/index.js +11 -8
- package/agnostic/html/hyper-json/smart-tags/isolated/number/index.js +19 -22
- package/agnostic/html/hyper-json/smart-tags/isolated/record/index.js +15 -22
- package/agnostic/html/hyper-json/smart-tags/isolated/ref/index.js +38 -23
- package/agnostic/html/hyper-json/smart-tags/isolated/string/index.js +19 -22
- package/agnostic/html/hyper-json/smart-tags/isolated/text/index.js +19 -22
- package/agnostic/html/hyper-json/transformer/index.js +124 -6
- package/agnostic/html/hyper-json/tree/index.js +423 -22
- package/agnostic/html/hyper-json/types/index.js +16 -4
- package/agnostic/html/hyper-json/utils/index.js +426 -22
- package/agnostic/html/insert-node/index.js +14 -4
- package/agnostic/html/placeholders/index.js +0 -2
- package/agnostic/html/replace-in-element/index.js +1 -6
- package/agnostic/html/selector-to-element/index.js +2 -6
- package/agnostic/html/string-to-nodes/index.js +2 -6
- package/agnostic/misc/assert/index.js +8 -15
- package/agnostic/misc/cast/index.js +1 -6
- package/agnostic/misc/connection/index.js +2 -6
- package/agnostic/misc/crawler/index.d.ts +51 -27
- package/agnostic/misc/crawler/index.js +14 -8
- package/agnostic/misc/crossenv/detect-runtime/index.js +8 -10
- package/agnostic/misc/crossenv/types.js +11 -4
- package/agnostic/misc/crossenv/window/index.js +22 -7
- package/agnostic/misc/data-size/index.js +0 -2
- package/agnostic/misc/is-constructor-function/index.js +4 -4
- package/agnostic/misc/is-nullish/index.js +8 -6
- package/agnostic/misc/logs/logger/index.js +0 -2
- package/agnostic/misc/logs/make-text-block/index.js +11 -4
- package/agnostic/misc/logs/styles/index.js +18 -5
- package/agnostic/misc/lorem-ipsum/index.js +2 -8
- package/agnostic/misc/normalize-extension/index.js +0 -2
- package/agnostic/misc/outcome/index.js +10 -6
- package/agnostic/numbers/absolute-modulo/index.js +4 -4
- package/agnostic/numbers/approximate-rational/index.js +0 -2
- package/agnostic/numbers/clamp/index.js +6 -4
- package/agnostic/numbers/geometric-progressions/index.js +14 -4
- package/agnostic/numbers/interpolate/index.js +0 -2
- package/agnostic/numbers/round/index.js +13 -6
- package/agnostic/objects/deep-get-property/index.js +1 -5
- package/agnostic/objects/enums/is-in-enum/index.js +9 -4
- package/agnostic/objects/flatten-getters/index.js +0 -2
- package/agnostic/objects/is-object/index.js +7 -5
- package/agnostic/objects/is-record/index.js +5 -4
- package/agnostic/objects/record-format/index.js +0 -2
- package/agnostic/objects/record-map/index.js +10 -4
- package/agnostic/objects/validation/index.js +0 -2
- package/agnostic/optim/memoize/index.js +0 -2
- package/agnostic/optim/throttle-debounce/index.js +0 -2
- package/agnostic/random/hex-char/index.js +7 -5
- package/agnostic/random/random/index.js +12 -5
- package/agnostic/random/uuid/index.js +11 -7
- package/agnostic/regexps/index.js +0 -2
- package/agnostic/sanitization/file-name/index.js +6 -4
- package/agnostic/sanitization/html/index.js +3 -7
- package/agnostic/sanitization/path/index.js +1 -5
- package/agnostic/sanitization/user-input/index.js +0 -2
- package/agnostic/strings/char-codes/index.js +0 -2
- package/agnostic/strings/matches/index.js +14 -6
- package/agnostic/strings/normalize-indent/index.js +0 -2
- package/agnostic/strings/parse-table/index.js +6 -11
- package/agnostic/strings/replace-all/index.js +13 -4
- package/agnostic/strings/to-alphanum/index.js +0 -2
- package/agnostic/strings/trim/index.js +7 -5
- package/agnostic/time/dates/format-date/index.js +0 -2
- package/agnostic/time/duration/index.js +0 -2
- package/agnostic/time/timeout/index.js +0 -2
- package/agnostic/time/transitions/index.js +1 -5
- package/agnostic/time/wait/index.js +6 -4
- package/components/Comp/index.js +0 -2
- package/node/@aws-s3/storage/directory/copy-dir/index.js +53 -5
- package/node/@aws-s3/storage/directory/list/index.js +22 -5
- package/node/@aws-s3/storage/directory/move-dir/index.js +66 -5
- package/node/@aws-s3/storage/directory/remove-dir/index.js +49 -5
- package/node/@aws-s3/storage/file/copy/index.js +34 -5
- package/node/@aws-s3/storage/file/download/index.js +20 -5
- package/node/@aws-s3/storage/file/exists/index.js +25 -5
- package/node/@aws-s3/storage/file/move/index.js +45 -5
- package/node/@aws-s3/storage/file/remove/index.js +25 -5
- package/node/@aws-s3/storage/file/stat/index.js +27 -5
- package/node/@aws-s3/storage/file/upload/index.js +45 -5
- package/node/@express/@multer/index.js +5 -12
- package/node/@google-cloud/storage/bucket/get-metadata/index.js +4 -11
- package/node/@google-cloud/storage/directory/copy-dir/index.js +26 -6
- package/node/@google-cloud/storage/directory/list/index.js +18 -6
- package/node/@google-cloud/storage/directory/move-dir/index.js +26 -6
- package/node/@google-cloud/storage/directory/remove-dir/index.js +22 -6
- package/node/@google-cloud/storage/file/copy/index.js +24 -6
- package/node/@google-cloud/storage/file/download/index.js +17 -6
- package/node/@google-cloud/storage/file/exists/index.js +14 -6
- package/node/@google-cloud/storage/file/generate-signed-url/index.js +4 -11
- package/node/@google-cloud/storage/file/get-metadata/index.js +4 -11
- package/node/@google-cloud/storage/file/get-permissions/index.js +4 -11
- package/node/@google-cloud/storage/file/move/index.js +26 -6
- package/node/@google-cloud/storage/file/remove/index.js +19 -6
- package/node/@google-cloud/storage/file/revoke-signed-urls/index.js +5 -16
- package/node/@google-cloud/storage/file/stat/index.js +21 -6
- package/node/@google-cloud/storage/file/update-metadata/index.js +4 -11
- package/node/@google-cloud/storage/file/upload/index.js +31 -6
- package/node/cloud-storage/clients/index.js +9 -7
- package/node/cloud-storage/operations/copy-dir/index.js +21 -26
- package/node/cloud-storage/operations/copy-file/index.js +12 -25
- package/node/cloud-storage/operations/download-file/index.js +12 -25
- package/node/cloud-storage/operations/exists-file/index.js +12 -25
- package/node/cloud-storage/operations/list-dir/index.js +12 -25
- package/node/cloud-storage/operations/move-dir/index.js +14 -27
- package/node/cloud-storage/operations/move-file/index.js +12 -25
- package/node/cloud-storage/operations/remove-dir/index.js +14 -27
- package/node/cloud-storage/operations/remove-file/index.js +12 -25
- package/node/cloud-storage/operations/stat-file/index.js +12 -25
- package/node/cloud-storage/operations/upload-file/index.js +12 -25
- package/node/encryption/@aes-256-gcm/buffer/index.js +7 -12
- package/node/encryption/@aes-256-gcm/uint8-array/index.js +36 -7
- package/node/encryption/key/index.js +0 -2
- package/node/files/is-in-directory/index.js +0 -2
- package/node/files/read-write/index.js +0 -2
- package/node/files/subpaths/index.js +3 -7
- package/node/ftps/directory/copy-dir/index.js +45 -6
- package/node/ftps/directory/list/index.js +12 -6
- package/node/ftps/directory/move-dir/index.js +25 -6
- package/node/ftps/directory/remove-dir/index.js +27 -6
- package/node/ftps/file/copy/index.js +30 -6
- package/node/ftps/file/download/index.js +15 -6
- package/node/ftps/file/exists/index.js +17 -6
- package/node/ftps/file/move/index.js +29 -6
- package/node/ftps/file/remove/index.js +25 -6
- package/node/ftps/file/stat/index.js +21 -6
- package/node/ftps/file/upload/index.js +30 -6
- package/node/images/create/index.js +1 -11
- package/node/images/format/index.js +87 -104
- package/node/images/metadata/index.js +1 -11
- package/node/images/transform/index.js +73 -130
- package/node/images/transform/operations/blur/index.js +12 -7
- package/node/images/transform/operations/brighten/index.js +12 -7
- package/node/images/transform/operations/extend/index.js +24 -14
- package/node/images/transform/operations/extract/index.js +17 -7
- package/node/images/transform/operations/flatten/index.js +19 -14
- package/node/images/transform/operations/flip/index.js +4 -4
- package/node/images/transform/operations/flop/index.js +4 -4
- package/node/images/transform/operations/hue/index.js +14 -7
- package/node/images/transform/operations/level/index.js +18 -7
- package/node/images/transform/operations/lighten/index.js +14 -7
- package/node/images/transform/operations/normalize/index.js +15 -7
- package/node/images/transform/operations/overlay/index.js +87 -14
- package/node/images/transform/operations/resize/index.js +45 -14
- package/node/images/transform/operations/rotate/index.js +19 -14
- package/node/images/transform/operations/saturate/index.js +16 -7
- package/node/images/types.js +27 -5
- package/node/images/utils/index.js +35 -13
- package/node/process/on-exit/index.js +0 -2
- package/node/process/prompt-continue/index.js +2 -1667
- package/node/process/spawner/index.js +8 -20
- package/node/sftp/directory/copy-dir/index.js +43 -6
- package/node/sftp/directory/list/index.js +12 -6
- package/node/sftp/directory/move-dir/index.js +22 -6
- package/node/sftp/directory/remove-dir/index.js +27 -6
- package/node/sftp/file/copy/index.js +28 -6
- package/node/sftp/file/download/index.js +15 -6
- package/node/sftp/file/exists/index.js +12 -6
- package/node/sftp/file/move/index.js +25 -6
- package/node/sftp/file/remove/index.js +18 -6
- package/node/sftp/file/stat/index.js +21 -6
- package/node/sftp/file/upload/index.js +22 -6
- package/package.json +1 -1
- package/chunks/chunk-2OGNVG5X.js +0 -56
- package/chunks/chunk-3MPXVP4L.js +0 -25
- package/chunks/chunk-4ARE376R.js +0 -36
- package/chunks/chunk-4CIS3R7T.js +0 -10
- package/chunks/chunk-4WE2WEXL.js +0 -12
- package/chunks/chunk-4WO4M2HE.js +0 -38
- package/chunks/chunk-5CFQCSKJ.js +0 -23
- package/chunks/chunk-5DJBOYRY.js +0 -29
- package/chunks/chunk-5H3IRSOB.js +0 -8
- package/chunks/chunk-5LCPENF6.js +0 -40
- package/chunks/chunk-5NTPCRFH.js +0 -32
- package/chunks/chunk-65BFQP3T.js +0 -25
- package/chunks/chunk-6652JQFX.js +0 -47
- package/chunks/chunk-6GINUDWK.js +0 -36
- package/chunks/chunk-6KOJFWH3.js +0 -47
- package/chunks/chunk-6XL25OZX.js +0 -12
- package/chunks/chunk-75BICI4L.js +0 -20
- package/chunks/chunk-7OWHDBUD.js +0 -31
- package/chunks/chunk-AFQ6FUT2.js +0 -36
- package/chunks/chunk-AKNR3U25.js +0 -20
- package/chunks/chunk-ASWI3EO6.js +0 -25
- package/chunks/chunk-ASXK7XCC.js +0 -18
- package/chunks/chunk-AYGAQQXD.js +0 -27
- package/chunks/chunk-B4BXEVMI.js +0 -22
- package/chunks/chunk-BOI2VKM7.js +0 -31
- package/chunks/chunk-CDIXAYVL.js +0 -40
- package/chunks/chunk-D3ERTRDW.js +0 -17
- package/chunks/chunk-D3J6JAJW.js +0 -31
- package/chunks/chunk-DNIOWD7K.js +0 -8
- package/chunks/chunk-DUCLFPGE.js +0 -78
- package/chunks/chunk-E6MSDKON.js +0 -13
- package/chunks/chunk-EPUHVR7J.js +0 -17
- package/chunks/chunk-EZVE2V6Z.js +0 -37
- package/chunks/chunk-FBWBGFRA.js +0 -35
- package/chunks/chunk-FENXVJYO.js +0 -11
- package/chunks/chunk-FML7BURX.js +0 -38
- package/chunks/chunk-FXISVWGE.js +0 -60
- package/chunks/chunk-GDSDQ3UB.js +0 -27
- package/chunks/chunk-GFYAOPTP.js +0 -60
- package/chunks/chunk-GICC2TWR.js +0 -22
- package/chunks/chunk-GOKDRSAD.js +0 -22
- package/chunks/chunk-H4PP6AHP.js +0 -15
- package/chunks/chunk-HC6ZOHCS.js +0 -14
- package/chunks/chunk-HEY7J6GI.js +0 -37
- package/chunks/chunk-HMPY32F7.js +0 -34
- package/chunks/chunk-HQLRJ7XW.js +0 -12
- package/chunks/chunk-HYPEWMYZ.js +0 -10
- package/chunks/chunk-IK2S6ZYP.js +0 -29
- package/chunks/chunk-ISJONMNA.js +0 -16
- package/chunks/chunk-IV6JXJNW.js +0 -25
- package/chunks/chunk-J45Y3CWM.js +0 -39
- package/chunks/chunk-JCXDI6AD.js +0 -56
- package/chunks/chunk-JDINERKY.js +0 -107
- package/chunks/chunk-JPNVNAO4.js +0 -36
- package/chunks/chunk-JVMFT3IT.js +0 -134
- package/chunks/chunk-K5UF634H.js +0 -25
- package/chunks/chunk-KEGTGEAM.js +0 -55
- package/chunks/chunk-KRYJVBO5.js +0 -155
- package/chunks/chunk-L3OCRR3V.js +0 -25
- package/chunks/chunk-LBK4TBXP.js +0 -31
- package/chunks/chunk-LFHDJTZJ.js +0 -12552
- package/chunks/chunk-MFL7PQWJ.js +0 -64
- package/chunks/chunk-MHNUCHPP.js +0 -26
- package/chunks/chunk-MSAAQTCE.js +0 -207
- package/chunks/chunk-MZYCKOLN.js +0 -103
- package/chunks/chunk-NONFIHGT.js +0 -33
- package/chunks/chunk-NR7STUY3.js +0 -28
- package/chunks/chunk-OCDUURXM.js +0 -28
- package/chunks/chunk-OGBUSUE6.js +0 -12
- package/chunks/chunk-OSAXBA7G.js +0 -10
- package/chunks/chunk-PA6C6P2W.js +0 -36
- package/chunks/chunk-PTJO2TGI.js +0 -23
- package/chunks/chunk-Q6Y27PHJ.js +0 -27
- package/chunks/chunk-QD6KZUTV.js +0 -41
- package/chunks/chunk-QEKI6WGQ.js +0 -27
- package/chunks/chunk-QFBVETGF.js +0 -34
- package/chunks/chunk-QHEWBOQI.js +0 -19
- package/chunks/chunk-QXAJXTXV.js +0 -19
- package/chunks/chunk-R3AWQXMY.js +0 -20
- package/chunks/chunk-RC7TRCNX.js +0 -53
- package/chunks/chunk-RNXRHCHQ.js +0 -633
- package/chunks/chunk-ROWPCMQY.js +0 -29
- package/chunks/chunk-RW7VAKJW.js +0 -15
- package/chunks/chunk-S2YRVCQ4.js +0 -32
- package/chunks/chunk-SJ54QLKA.js +0 -2684
- package/chunks/chunk-SNB7HA6G.js +0 -32
- package/chunks/chunk-T3F3S6XV.js +0 -35
- package/chunks/chunk-TKAWYSFV.js +0 -34
- package/chunks/chunk-TLWVLCIQ.js +0 -39
- package/chunks/chunk-TTJXJX4E.js +0 -48
- package/chunks/chunk-UR5BUIPU.js +0 -26
- package/chunks/chunk-USIYKRNX.js +0 -20
- package/chunks/chunk-UVYVJF5Q.js +0 -45
- package/chunks/chunk-VRVBSI2L.js +0 -28
- package/chunks/chunk-VYVVS4LW.js +0 -24
- package/chunks/chunk-W5A2TON3.js +0 -10
- package/chunks/chunk-W7VDFL7P.js +0 -77
- package/chunks/chunk-WNDMYNDU.js +0 -8
- package/chunks/chunk-XA4HVHJ4.js +0 -18
- package/chunks/chunk-XCBH6NLF.js +0 -42
- package/chunks/chunk-XEQ2PBT2.js +0 -20
- package/chunks/chunk-XIIJYVJZ.js +0 -15
- package/chunks/chunk-XKELYCHB.js +0 -32
- package/chunks/chunk-XNF5MLCQ.js +0 -14
- package/chunks/chunk-XVH447XG.js +0 -35
- package/chunks/chunk-YA2YCZUF.js +0 -8
- package/chunks/chunk-YDIBNEGA.js +0 -9
- package/chunks/chunk-Z352FGUT.js +0 -25
- package/chunks/chunk-ZE5QOQM6.js +0 -37
- package/chunks/chunk-ZKIQ753F.js +0 -23
|
@@ -1,29 +1,557 @@
|
|
|
1
|
+
// src/agnostic/colors/convert/index.ts
|
|
2
|
+
import { absoluteModulo } from "../../numbers/absolute-modulo/index.js";
|
|
3
|
+
import { tidy } from "../tidy/index.js";
|
|
1
4
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
cssColors
|
|
6
|
+
} from "../types.js";
|
|
7
|
+
import {
|
|
8
|
+
isHex,
|
|
9
|
+
isRgb,
|
|
10
|
+
isHsl,
|
|
11
|
+
isHsb,
|
|
12
|
+
isCmyk,
|
|
13
|
+
isCssColor,
|
|
14
|
+
isXyz,
|
|
15
|
+
isLab,
|
|
16
|
+
isLch
|
|
17
|
+
} from "../typechecks/index.js";
|
|
18
|
+
function _hex2rgb(hex) {
|
|
19
|
+
if (!isHex(hex)) throw new Error(`invalid hex color ${hex}`);
|
|
20
|
+
let hexString = hex;
|
|
21
|
+
const inputHex = hexString;
|
|
22
|
+
const startsWithHash = hexString.startsWith("#");
|
|
23
|
+
if (!startsWithHash) throw new Error(`invalid hex color ${inputHex}`);
|
|
24
|
+
hexString = hexString.slice(1);
|
|
25
|
+
if (hexString.length === 3) {
|
|
26
|
+
hexString = hexString.split("").map((c) => c + c).join("") + "ff";
|
|
27
|
+
} else if (hexString.length === 4) {
|
|
28
|
+
hexString = hexString.split("").map((c) => c + c).join("");
|
|
29
|
+
} else if (hexString.length === 6) {
|
|
30
|
+
hexString = hexString + "ff";
|
|
31
|
+
} else if (hexString.length === 8) {
|
|
32
|
+
hexString = hexString;
|
|
33
|
+
} else throw new Error(`invalid hex color ${inputHex}`);
|
|
34
|
+
const r = parseInt(hexString.slice(0, 2), 16);
|
|
35
|
+
const g = parseInt(hexString.slice(2, 4), 16);
|
|
36
|
+
const b = parseInt(hexString.slice(4, 6), 16);
|
|
37
|
+
const a = parseInt(hexString.slice(6, 8), 16) / 255;
|
|
38
|
+
return { r, g, b, a };
|
|
39
|
+
}
|
|
40
|
+
function _rgb2hex(rgb) {
|
|
41
|
+
const { r, g, b, a = 1 } = rgb;
|
|
42
|
+
const rHex = Math.round(r).toString(16).padStart(2, "0");
|
|
43
|
+
const gHex = Math.round(g).toString(16).padStart(2, "0");
|
|
44
|
+
const bHex = Math.round(b).toString(16).padStart(2, "0");
|
|
45
|
+
const aHex = Math.round(a * 255).toString(16).padStart(2, "0");
|
|
46
|
+
const returned = `#${rHex}${gHex}${bHex}${aHex}`;
|
|
47
|
+
if (!isHex(returned)) {
|
|
48
|
+
throw new Error(`invalid hex color output ${returned}`);
|
|
49
|
+
}
|
|
50
|
+
return returned;
|
|
51
|
+
}
|
|
52
|
+
function _css2rgb(color) {
|
|
53
|
+
if (color in cssColors) return cssColors[color];
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
var cssColorsWithHex = Object.entries(cssColors).map(([cssColor, rgba]) => ({
|
|
57
|
+
name: cssColor,
|
|
58
|
+
hex: _rgb2hex(rgba),
|
|
59
|
+
rgba
|
|
60
|
+
}));
|
|
61
|
+
function _rgb2css(rgb) {
|
|
62
|
+
const hexTarget = _rgb2hex(rgb);
|
|
63
|
+
return cssColorsWithHex.find((c) => c.hex === hexTarget)?.name;
|
|
64
|
+
}
|
|
65
|
+
function _hsl2rgb(hsl) {
|
|
66
|
+
const { h, s, l, a = 1 } = hsl;
|
|
67
|
+
const H = absoluteModulo(h, 360) / 360;
|
|
68
|
+
const S = Math.max(0, Math.min(1, s / 100));
|
|
69
|
+
const L = Math.max(0, Math.min(1, l / 100));
|
|
70
|
+
const A = Math.max(0, Math.min(1, a));
|
|
71
|
+
const hue2rgb = (p, q, t) => {
|
|
72
|
+
if (t < 0) t += 1;
|
|
73
|
+
if (t > 1) t -= 1;
|
|
74
|
+
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
75
|
+
if (t < 1 / 2) return q;
|
|
76
|
+
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
77
|
+
return p;
|
|
78
|
+
};
|
|
79
|
+
let r;
|
|
80
|
+
let g;
|
|
81
|
+
let b;
|
|
82
|
+
if (S === 0) {
|
|
83
|
+
r = g = b = L;
|
|
84
|
+
} else {
|
|
85
|
+
const q = L < 0.5 ? L * (1 + S) : L + S - L * S;
|
|
86
|
+
const p = 2 * L - q;
|
|
87
|
+
r = hue2rgb(p, q, H + 1 / 3);
|
|
88
|
+
g = hue2rgb(p, q, H);
|
|
89
|
+
b = hue2rgb(p, q, H - 1 / 3);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
r: Math.round(r * 255),
|
|
93
|
+
g: Math.round(g * 255),
|
|
94
|
+
b: Math.round(b * 255),
|
|
95
|
+
a: A
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function _rgb2hsl(rgb) {
|
|
99
|
+
const { r, g, b, a = 1 } = rgb;
|
|
100
|
+
const R = r / 255;
|
|
101
|
+
const G = g / 255;
|
|
102
|
+
const B = b / 255;
|
|
103
|
+
const max = Math.max(R, G, B);
|
|
104
|
+
const min = Math.min(R, G, B);
|
|
105
|
+
const delta = max - min;
|
|
106
|
+
let h = 0;
|
|
107
|
+
let s = 0;
|
|
108
|
+
const l = (max + min) / 2;
|
|
109
|
+
if (delta !== 0) {
|
|
110
|
+
s = l > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
|
111
|
+
if (max === R) {
|
|
112
|
+
h = ((G - B) / delta + (G < B ? 6 : 0)) / 6;
|
|
113
|
+
} else if (max === G) {
|
|
114
|
+
h = ((B - R) / delta + 2) / 6;
|
|
115
|
+
} else {
|
|
116
|
+
h = ((R - G) / delta + 4) / 6;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
h: Math.round(h * 360),
|
|
121
|
+
s: Math.round(s * 100),
|
|
122
|
+
l: Math.round(l * 100),
|
|
123
|
+
a
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function _hsb2rgb(hsb) {
|
|
127
|
+
const { h, s, b, a = 1 } = hsb;
|
|
128
|
+
const H = absoluteModulo(h, 360) / 360;
|
|
129
|
+
const S = Math.max(0, Math.min(1, s / 100));
|
|
130
|
+
const B = Math.max(0, Math.min(1, b / 100));
|
|
131
|
+
const A = Math.max(0, Math.min(1, a));
|
|
132
|
+
const i = Math.floor(H * 6);
|
|
133
|
+
const f = H * 6 - i;
|
|
134
|
+
const p = B * (1 - S);
|
|
135
|
+
const q = B * (1 - f * S);
|
|
136
|
+
const t = B * (1 - (1 - f) * S);
|
|
137
|
+
let r;
|
|
138
|
+
let g;
|
|
139
|
+
let blue;
|
|
140
|
+
switch (absoluteModulo(i, 6)) {
|
|
141
|
+
case 0:
|
|
142
|
+
r = B;
|
|
143
|
+
g = t;
|
|
144
|
+
blue = p;
|
|
145
|
+
break;
|
|
146
|
+
case 1:
|
|
147
|
+
r = q;
|
|
148
|
+
g = B;
|
|
149
|
+
blue = p;
|
|
150
|
+
break;
|
|
151
|
+
case 2:
|
|
152
|
+
r = p;
|
|
153
|
+
g = B;
|
|
154
|
+
blue = t;
|
|
155
|
+
break;
|
|
156
|
+
case 3:
|
|
157
|
+
r = p;
|
|
158
|
+
g = q;
|
|
159
|
+
blue = B;
|
|
160
|
+
break;
|
|
161
|
+
case 4:
|
|
162
|
+
r = t;
|
|
163
|
+
g = p;
|
|
164
|
+
blue = B;
|
|
165
|
+
break;
|
|
166
|
+
case 5:
|
|
167
|
+
r = B;
|
|
168
|
+
g = p;
|
|
169
|
+
blue = q;
|
|
170
|
+
break;
|
|
171
|
+
default:
|
|
172
|
+
r = g = blue = 0;
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
r: Math.round(r * 255),
|
|
176
|
+
g: Math.round(g * 255),
|
|
177
|
+
b: Math.round(blue * 255),
|
|
178
|
+
a: A
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function _rgb2hsb(rgb) {
|
|
182
|
+
const { r, g, b, a = 1 } = rgb;
|
|
183
|
+
const R = r / 255;
|
|
184
|
+
const G = g / 255;
|
|
185
|
+
const B = b / 255;
|
|
186
|
+
const max = Math.max(R, G, B);
|
|
187
|
+
const min = Math.min(R, G, B);
|
|
188
|
+
const delta = max - min;
|
|
189
|
+
let h = 0;
|
|
190
|
+
let s = 0;
|
|
191
|
+
const brightness = max;
|
|
192
|
+
if (max !== 0) {
|
|
193
|
+
s = delta / max;
|
|
194
|
+
}
|
|
195
|
+
if (delta !== 0) {
|
|
196
|
+
if (max === R) {
|
|
197
|
+
h = ((G - B) / delta + (G < B ? 6 : 0)) / 6;
|
|
198
|
+
} else if (max === G) {
|
|
199
|
+
h = ((B - R) / delta + 2) / 6;
|
|
200
|
+
} else {
|
|
201
|
+
h = ((R - G) / delta + 4) / 6;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
h: Math.round(h * 360),
|
|
206
|
+
s: Math.round(s * 100),
|
|
207
|
+
b: Math.round(brightness * 100),
|
|
208
|
+
a
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function _cmyk2rgb(cmyka) {
|
|
212
|
+
const { c, m, y, k, a = 1 } = cmyka;
|
|
213
|
+
const C = Math.max(0, Math.min(100, c)) / 100;
|
|
214
|
+
const M = Math.max(0, Math.min(100, m)) / 100;
|
|
215
|
+
const Y = Math.max(0, Math.min(100, y)) / 100;
|
|
216
|
+
const K = Math.max(0, Math.min(100, k)) / 100;
|
|
217
|
+
const A = Math.max(0, Math.min(1, a));
|
|
218
|
+
const R = 1 - Math.min(1, C * (1 - K) + K);
|
|
219
|
+
const G = 1 - Math.min(1, M * (1 - K) + K);
|
|
220
|
+
const B = 1 - Math.min(1, Y * (1 - K) + K);
|
|
221
|
+
return {
|
|
222
|
+
r: Math.round(R * 255),
|
|
223
|
+
g: Math.round(G * 255),
|
|
224
|
+
b: Math.round(B * 255),
|
|
225
|
+
a: A
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function _rgb2cmyk(rgb) {
|
|
229
|
+
const { r, g, b, a = 1 } = rgb;
|
|
230
|
+
const R = Math.max(0, Math.min(1, r / 255));
|
|
231
|
+
const G = Math.max(0, Math.min(1, g / 255));
|
|
232
|
+
const B = Math.max(0, Math.min(1, b / 255));
|
|
233
|
+
const A = Math.max(0, Math.min(1, a));
|
|
234
|
+
const K = 1 - Math.max(R, G, B);
|
|
235
|
+
const denom = 1 - K || 1;
|
|
236
|
+
const C = (1 - R - K) / denom;
|
|
237
|
+
const M = (1 - G - K) / denom;
|
|
238
|
+
const Y = (1 - B - K) / denom;
|
|
239
|
+
return {
|
|
240
|
+
c: Math.round(C * 100),
|
|
241
|
+
m: Math.round(M * 100),
|
|
242
|
+
y: Math.round(Y * 100),
|
|
243
|
+
k: Math.round(K * 100),
|
|
244
|
+
a: A
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function _xyz2rgb(xyza) {
|
|
248
|
+
const { x, y, z, a = 1 } = xyza;
|
|
249
|
+
const X = x / 100;
|
|
250
|
+
const Y = y / 100;
|
|
251
|
+
const Z = z / 100;
|
|
252
|
+
const A = Math.max(0, Math.min(1, a));
|
|
253
|
+
let R = X * 3.2404542 + Y * -1.5371385 + Z * -0.4985314;
|
|
254
|
+
let G = X * -0.969266 + Y * 1.8760108 + Z * 0.041556;
|
|
255
|
+
let B = X * 0.0556434 + Y * -0.2040259 + Z * 1.0572252;
|
|
256
|
+
const GAMMA_THRESHOLD = 31308e-7;
|
|
257
|
+
const GAMMA_EXPONENT = 1 / 2.4;
|
|
258
|
+
const GAMMA_MULT = 1.055;
|
|
259
|
+
const GAMMA_OFFSET = 0.055;
|
|
260
|
+
const LINEAR_DIVISOR = 12.92;
|
|
261
|
+
const gammaCorrect = (c) => c <= GAMMA_THRESHOLD ? c * LINEAR_DIVISOR : GAMMA_MULT * Math.pow(c, GAMMA_EXPONENT) - GAMMA_OFFSET;
|
|
262
|
+
R = gammaCorrect(R);
|
|
263
|
+
G = gammaCorrect(G);
|
|
264
|
+
B = gammaCorrect(B);
|
|
265
|
+
return {
|
|
266
|
+
r: Math.round(Math.max(0, Math.min(1, R)) * 255),
|
|
267
|
+
g: Math.round(Math.max(0, Math.min(1, G)) * 255),
|
|
268
|
+
b: Math.round(Math.max(0, Math.min(1, B)) * 255),
|
|
269
|
+
a: A
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function _rgb2xyz(rgb) {
|
|
273
|
+
const { r, g, b, a = 1 } = rgb;
|
|
274
|
+
let R = Math.max(0, Math.min(1, r / 255));
|
|
275
|
+
let G = Math.max(0, Math.min(1, g / 255));
|
|
276
|
+
let B = Math.max(0, Math.min(1, b / 255));
|
|
277
|
+
const A = Math.max(0, Math.min(1, a));
|
|
278
|
+
const SRGB_THRESHOLD = 0.04045;
|
|
279
|
+
const SRGB_OFFSET = 0.055;
|
|
280
|
+
const SRGB_DIVISOR = 1.055;
|
|
281
|
+
const SRGB_EXPONENT = 2.4;
|
|
282
|
+
const SRGB_LINEAR_DIVISOR = 12.92;
|
|
283
|
+
const linearize = (c) => c > SRGB_THRESHOLD ? Math.pow((c + SRGB_OFFSET) / SRGB_DIVISOR, SRGB_EXPONENT) : c / SRGB_LINEAR_DIVISOR;
|
|
284
|
+
R = linearize(R);
|
|
285
|
+
G = linearize(G);
|
|
286
|
+
B = linearize(B);
|
|
287
|
+
const X = R * 0.4124564 + G * 0.3575761 + B * 0.1804375;
|
|
288
|
+
const Y = R * 0.2126729 + G * 0.7151522 + B * 0.072175;
|
|
289
|
+
const Z = R * 0.0193339 + G * 0.119192 + B * 0.9503041;
|
|
290
|
+
return {
|
|
291
|
+
x: X * 100,
|
|
292
|
+
y: Y * 100,
|
|
293
|
+
z: Z * 100,
|
|
294
|
+
a: A
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function _lab2xyz(lab) {
|
|
298
|
+
const { l, a: A = 0, b: B = 0, al: alpha = 1 } = lab;
|
|
299
|
+
const REF_X = 95.047;
|
|
300
|
+
const REF_Y = 100;
|
|
301
|
+
const REF_Z = 108.883;
|
|
302
|
+
const fy = (l + 16) / 116;
|
|
303
|
+
const fx = fy + A / 500;
|
|
304
|
+
const fz = fy - B / 200;
|
|
305
|
+
const fx3 = Math.pow(fx, 3);
|
|
306
|
+
const fz3 = Math.pow(fz, 3);
|
|
307
|
+
const fy3 = Math.pow(fy, 3);
|
|
308
|
+
const epsilon = 8856e-6;
|
|
309
|
+
const kappa = 903.3;
|
|
310
|
+
const X = fx3 > epsilon ? fx3 : (116 * fx - 16) / kappa;
|
|
311
|
+
const Y = l > kappa * epsilon ? fy3 : l / kappa;
|
|
312
|
+
const Z = fz3 > epsilon ? fz3 : (116 * fz - 16) / kappa;
|
|
313
|
+
return {
|
|
314
|
+
x: X * REF_X,
|
|
315
|
+
y: Y * REF_Y,
|
|
316
|
+
z: Z * REF_Z,
|
|
317
|
+
a: Math.max(0, Math.min(1, alpha))
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function _xyz2lab(xyza) {
|
|
321
|
+
const { x, y, z, a: alpha = 1 } = xyza;
|
|
322
|
+
const REF_X = 95.047;
|
|
323
|
+
const REF_Y = 100;
|
|
324
|
+
const REF_Z = 108.883;
|
|
325
|
+
const X = x / REF_X;
|
|
326
|
+
const Y = y / REF_Y;
|
|
327
|
+
const Z = z / REF_Z;
|
|
328
|
+
const epsilon = 8856e-6;
|
|
329
|
+
const kappa = 903.3;
|
|
330
|
+
const fx = X > epsilon ? Math.cbrt(X) : (kappa * X + 16) / 116;
|
|
331
|
+
const fy = Y > epsilon ? Math.cbrt(Y) : (kappa * Y + 16) / 116;
|
|
332
|
+
const fz = Z > epsilon ? Math.cbrt(Z) : (kappa * Z + 16) / 116;
|
|
333
|
+
const L = 116 * fy - 16;
|
|
334
|
+
const A = 500 * (fx - fy);
|
|
335
|
+
const B = 200 * (fy - fz);
|
|
336
|
+
return {
|
|
337
|
+
l: L,
|
|
338
|
+
a: A,
|
|
339
|
+
b: B,
|
|
340
|
+
al: Math.max(0, Math.min(1, alpha))
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function _lab2lch(lab) {
|
|
344
|
+
const { l, a, b, al = 1 } = lab;
|
|
345
|
+
const c = Math.sqrt(a * a + b * b);
|
|
346
|
+
let h = Math.atan2(b, a) * (180 / Math.PI);
|
|
347
|
+
if (h < 0) h += 360;
|
|
348
|
+
return { l, c, h, a: al };
|
|
349
|
+
}
|
|
350
|
+
function _lch2lab(lch) {
|
|
351
|
+
const { l, c, h, a = 1 } = lch;
|
|
352
|
+
const hRad = h * Math.PI / 180;
|
|
353
|
+
const A = c * Math.cos(hRad);
|
|
354
|
+
const B = c * Math.sin(hRad);
|
|
355
|
+
return { l, a: A, b: B, al: a };
|
|
356
|
+
}
|
|
357
|
+
function toRgb(color) {
|
|
358
|
+
if (isRgb(color)) return color;
|
|
359
|
+
if (isHsl(color)) return _hsl2rgb(color);
|
|
360
|
+
if (isHsb(color)) return _hsb2rgb(color);
|
|
361
|
+
if (isCmyk(color)) return _cmyk2rgb(color);
|
|
362
|
+
if (isCssColor(color)) return _css2rgb(color);
|
|
363
|
+
if (isHex(color)) return _hex2rgb(color);
|
|
364
|
+
if (isXyz(color)) return _xyz2rgb(color);
|
|
365
|
+
if (isLab(color)) return _xyz2rgb(_lab2xyz(color));
|
|
366
|
+
if (isLch(color)) return _xyz2rgb(_lab2xyz(_lch2lab(color)));
|
|
367
|
+
throw new Error(`Invalid color input: ${color}`);
|
|
368
|
+
}
|
|
369
|
+
function toXyz(color) {
|
|
370
|
+
if (isXyz(color)) return color;
|
|
371
|
+
if (isLab(color)) return _lab2xyz(color);
|
|
372
|
+
if (isLch(color)) return _lab2xyz(_lch2lab(color));
|
|
373
|
+
if (isRgb(color)) return _rgb2xyz(color);
|
|
374
|
+
if (isHsl(color)) return _rgb2xyz(_hsl2rgb(color));
|
|
375
|
+
if (isHsb(color)) return _rgb2xyz(_hsb2rgb(color));
|
|
376
|
+
if (isCmyk(color)) return _rgb2xyz(_cmyk2rgb(color));
|
|
377
|
+
if (isCssColor(color)) return _rgb2xyz(_css2rgb(color));
|
|
378
|
+
if (isHex(color)) return _rgb2xyz(_hex2rgb(color));
|
|
379
|
+
throw new Error(`Invalid color input: ${color}`);
|
|
380
|
+
}
|
|
381
|
+
function toLab(color) {
|
|
382
|
+
if (isLab(color)) return color;
|
|
383
|
+
if (isLch(color)) return _lch2lab(color);
|
|
384
|
+
const xyzColor = toXyz(color);
|
|
385
|
+
return _xyz2lab(xyzColor);
|
|
386
|
+
}
|
|
387
|
+
function toLch(color) {
|
|
388
|
+
if (isLch(color)) return color;
|
|
389
|
+
const labColor = toLab(color);
|
|
390
|
+
return _lab2lch(labColor);
|
|
391
|
+
}
|
|
392
|
+
function toHsl(color) {
|
|
393
|
+
if (isHsl(color)) return color;
|
|
394
|
+
const rgbColor = toRgb(color);
|
|
395
|
+
return _rgb2hsl(rgbColor);
|
|
396
|
+
}
|
|
397
|
+
function toHsb(color) {
|
|
398
|
+
if (isHsb(color)) return color;
|
|
399
|
+
const rgbColor = toRgb(color);
|
|
400
|
+
return _rgb2hsb(rgbColor);
|
|
401
|
+
}
|
|
402
|
+
function toCmyk(color) {
|
|
403
|
+
if (isCmyk(color)) return color;
|
|
404
|
+
const rgbColor = toRgb(color);
|
|
405
|
+
return _rgb2cmyk(rgbColor);
|
|
406
|
+
}
|
|
407
|
+
function toCss(color) {
|
|
408
|
+
if (isCssColor(color)) return color;
|
|
409
|
+
const rgbColor = toRgb(color);
|
|
410
|
+
return _rgb2css(rgbColor);
|
|
411
|
+
}
|
|
412
|
+
function toHex(color) {
|
|
413
|
+
if (isHex(color)) return color;
|
|
414
|
+
const rgbColor = toRgb(color);
|
|
415
|
+
return _rgb2hex(rgbColor);
|
|
416
|
+
}
|
|
417
|
+
function viaRgb(color, transformer) {
|
|
418
|
+
const _color = color;
|
|
419
|
+
const rgb = toRgb(_color);
|
|
420
|
+
const transformedRgb = transformer(rgb);
|
|
421
|
+
if (isRgb(_color)) return transformedRgb;
|
|
422
|
+
if (isHsl(_color)) return toHsl(transformedRgb);
|
|
423
|
+
if (isHsb(_color)) return toHsb(transformedRgb);
|
|
424
|
+
if (isCmyk(_color)) return toCmyk(transformedRgb);
|
|
425
|
+
if (isXyz(_color)) return toXyz(transformedRgb);
|
|
426
|
+
if (isLab(_color)) return toLab(transformedRgb);
|
|
427
|
+
if (isLch(_color)) return toLch(transformedRgb);
|
|
428
|
+
if (isHex(_color)) return toRgb(transformedRgb);
|
|
429
|
+
if (isCssColor(_color)) return transformedRgb;
|
|
430
|
+
const _typecheck = true;
|
|
431
|
+
throw new Error(`Invalid color input: ${_color}`);
|
|
432
|
+
}
|
|
433
|
+
function viaHsl(color, transformer) {
|
|
434
|
+
const _color = color;
|
|
435
|
+
const hsl = toHsl(_color);
|
|
436
|
+
const transformedHsl = transformer(hsl);
|
|
437
|
+
if (isHsl(_color)) return transformedHsl;
|
|
438
|
+
if (isRgb(_color)) return toRgb(transformedHsl);
|
|
439
|
+
if (isHsb(_color)) return toHsb(transformedHsl);
|
|
440
|
+
if (isCmyk(_color)) return toCmyk(transformedHsl);
|
|
441
|
+
if (isXyz(_color)) return toXyz(transformedHsl);
|
|
442
|
+
if (isLab(_color)) return toLab(transformedHsl);
|
|
443
|
+
if (isLch(_color)) return toLch(transformedHsl);
|
|
444
|
+
if (isHex(_color)) return toHex(transformedHsl);
|
|
445
|
+
if (isCssColor(_color)) return transformedHsl;
|
|
446
|
+
const _typecheck = true;
|
|
447
|
+
throw new Error(`Invalid color input: ${_color}`);
|
|
448
|
+
}
|
|
449
|
+
function viaHsb(color, transformer) {
|
|
450
|
+
const _color = color;
|
|
451
|
+
const hsb = toHsb(_color);
|
|
452
|
+
const transformedHsb = transformer(hsb);
|
|
453
|
+
if (isHsb(_color)) return transformedHsb;
|
|
454
|
+
if (isRgb(_color)) return toRgb(transformedHsb);
|
|
455
|
+
if (isHsl(_color)) return toHsl(transformedHsb);
|
|
456
|
+
if (isCmyk(_color)) return toCmyk(transformedHsb);
|
|
457
|
+
if (isXyz(_color)) return toXyz(transformedHsb);
|
|
458
|
+
if (isLab(_color)) return toLab(transformedHsb);
|
|
459
|
+
if (isLch(_color)) return toLch(transformedHsb);
|
|
460
|
+
if (isHex(_color)) return toHex(transformedHsb);
|
|
461
|
+
if (isCssColor(_color)) return transformedHsb;
|
|
462
|
+
const _typecheck = true;
|
|
463
|
+
throw new Error(`Invalid color input: ${_color}`);
|
|
464
|
+
}
|
|
465
|
+
function viaCmyk(color, transformer) {
|
|
466
|
+
const _color = color;
|
|
467
|
+
const cmyk = toCmyk(_color);
|
|
468
|
+
const transformedCmyk = transformer(cmyk);
|
|
469
|
+
if (isHsb(_color)) return transformedCmyk;
|
|
470
|
+
if (isRgb(_color)) return toRgb(transformedCmyk);
|
|
471
|
+
if (isHsl(_color)) return toHsl(transformedCmyk);
|
|
472
|
+
if (isCmyk(_color)) return toCmyk(transformedCmyk);
|
|
473
|
+
if (isXyz(_color)) return toXyz(transformedCmyk);
|
|
474
|
+
if (isLab(_color)) return toLab(transformedCmyk);
|
|
475
|
+
if (isLch(_color)) return toLch(transformedCmyk);
|
|
476
|
+
if (isHex(_color)) return toHex(transformedCmyk);
|
|
477
|
+
if (isCssColor(_color)) return transformedCmyk;
|
|
478
|
+
const _typecheck = true;
|
|
479
|
+
throw new Error(`Invalid color input: ${_color}`);
|
|
480
|
+
}
|
|
481
|
+
function viaXyz(color, transformer) {
|
|
482
|
+
const _color = color;
|
|
483
|
+
const xyz = toXyz(_color);
|
|
484
|
+
const transformedXyz = transformer(xyz);
|
|
485
|
+
if (isHsb(_color)) return transformedXyz;
|
|
486
|
+
if (isRgb(_color)) return toRgb(transformedXyz);
|
|
487
|
+
if (isHsl(_color)) return toHsl(transformedXyz);
|
|
488
|
+
if (isCmyk(_color)) return toCmyk(transformedXyz);
|
|
489
|
+
if (isXyz(_color)) return toXyz(transformedXyz);
|
|
490
|
+
if (isLab(_color)) return toLab(transformedXyz);
|
|
491
|
+
if (isLch(_color)) return toLch(transformedXyz);
|
|
492
|
+
if (isHex(_color)) return toHex(transformedXyz);
|
|
493
|
+
if (isCssColor(_color)) return transformedXyz;
|
|
494
|
+
const _typecheck = true;
|
|
495
|
+
throw new Error(`Invalid color input: ${_color}`);
|
|
496
|
+
}
|
|
497
|
+
function viaLab(color, transformer) {
|
|
498
|
+
const _color = color;
|
|
499
|
+
const lab = toLab(_color);
|
|
500
|
+
const transformedLab = transformer(lab);
|
|
501
|
+
if (isHsb(_color)) return transformedLab;
|
|
502
|
+
if (isRgb(_color)) return toRgb(transformedLab);
|
|
503
|
+
if (isHsl(_color)) return toHsl(transformedLab);
|
|
504
|
+
if (isCmyk(_color)) return toCmyk(transformedLab);
|
|
505
|
+
if (isXyz(_color)) return toXyz(transformedLab);
|
|
506
|
+
if (isLab(_color)) return toLab(transformedLab);
|
|
507
|
+
if (isLch(_color)) return toLch(transformedLab);
|
|
508
|
+
if (isHex(_color)) return toHex(transformedLab);
|
|
509
|
+
if (isCssColor(_color)) return transformedLab;
|
|
510
|
+
const _typecheck = true;
|
|
511
|
+
throw new Error(`Invalid color input: ${_color}`);
|
|
512
|
+
}
|
|
513
|
+
function viaLch(color, transformer) {
|
|
514
|
+
const _color = color;
|
|
515
|
+
const lch = toLch(_color);
|
|
516
|
+
const transformedLch = transformer(lch);
|
|
517
|
+
if (isHsb(_color)) return transformedLch;
|
|
518
|
+
if (isRgb(_color)) return toRgb(transformedLch);
|
|
519
|
+
if (isHsl(_color)) return toHsl(transformedLch);
|
|
520
|
+
if (isCmyk(_color)) return toCmyk(transformedLch);
|
|
521
|
+
if (isXyz(_color)) return toXyz(transformedLch);
|
|
522
|
+
if (isLab(_color)) return toLab(transformedLch);
|
|
523
|
+
if (isLch(_color)) return toLch(transformedLch);
|
|
524
|
+
if (isHex(_color)) return toHex(transformedLch);
|
|
525
|
+
if (isCssColor(_color)) return transformedLch;
|
|
526
|
+
const _typecheck = true;
|
|
527
|
+
throw new Error(`Invalid color input: ${_color}`);
|
|
528
|
+
}
|
|
529
|
+
function linearizeToSRgb(rgb) {
|
|
530
|
+
const cleanRgb = tidy(rgb);
|
|
531
|
+
const linearChannel = (v) => {
|
|
532
|
+
const n = v / 255;
|
|
533
|
+
if (n <= 0.04045) return n / 12.92;
|
|
534
|
+
else return Math.pow((n + 0.055) / 1.055, 2.4);
|
|
535
|
+
};
|
|
536
|
+
return {
|
|
537
|
+
linearR: linearChannel(cleanRgb.r),
|
|
538
|
+
linearG: linearChannel(cleanRgb.g),
|
|
539
|
+
linearB: linearChannel(cleanRgb.b),
|
|
540
|
+
a: cleanRgb.a
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
function delinearizeToRgb(srgb) {
|
|
544
|
+
const gammaChannel = (v) => {
|
|
545
|
+
if (v <= 31308e-7) return v * 12.92;
|
|
546
|
+
else return 1.055 * Math.pow(v, 1 / 2.4) - 0.055;
|
|
547
|
+
};
|
|
548
|
+
return tidy({
|
|
549
|
+
r: gammaChannel(srgb.linearR) * 255,
|
|
550
|
+
g: gammaChannel(srgb.linearG) * 255,
|
|
551
|
+
b: gammaChannel(srgb.linearB) * 255,
|
|
552
|
+
a: srgb.a
|
|
553
|
+
});
|
|
554
|
+
}
|
|
27
555
|
export {
|
|
28
556
|
delinearizeToRgb,
|
|
29
557
|
linearizeToSRgb,
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
toLab
|
|
3
|
-
} from "../../../chunks/chunk-RNXRHCHQ.js";
|
|
4
|
-
import "../../../chunks/chunk-DNIOWD7K.js";
|
|
5
|
-
import "../../../chunks/chunk-OSAXBA7G.js";
|
|
6
|
-
import "../../../chunks/chunk-JDINERKY.js";
|
|
7
|
-
import "../../../chunks/chunk-HQLRJ7XW.js";
|
|
8
|
-
import "../../../chunks/chunk-KRYJVBO5.js";
|
|
9
|
-
import "../../../chunks/chunk-XCBH6NLF.js";
|
|
10
|
-
|
|
11
1
|
// src/agnostic/colors/distance/index.ts
|
|
2
|
+
import { toLab } from "../convert/index.js";
|
|
12
3
|
function distanceCiede2000(c1, c2) {
|
|
13
4
|
const deg2rad = (deg) => Math.PI / 180 * deg;
|
|
14
5
|
const rad2deg = (rad) => 180 / Math.PI * rad;
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
+
// src/agnostic/colors/grayscale/index.ts
|
|
1
2
|
import {
|
|
3
|
+
viaRgb,
|
|
2
4
|
viaCmyk,
|
|
3
|
-
viaHsb,
|
|
4
5
|
viaHsl,
|
|
6
|
+
viaHsb,
|
|
7
|
+
viaXyz,
|
|
5
8
|
viaLab,
|
|
6
|
-
viaLch
|
|
7
|
-
|
|
8
|
-
viaXyz
|
|
9
|
-
} from "../../../chunks/chunk-RNXRHCHQ.js";
|
|
10
|
-
import "../../../chunks/chunk-DNIOWD7K.js";
|
|
11
|
-
import "../../../chunks/chunk-OSAXBA7G.js";
|
|
12
|
-
import "../../../chunks/chunk-JDINERKY.js";
|
|
13
|
-
import "../../../chunks/chunk-HQLRJ7XW.js";
|
|
14
|
-
import "../../../chunks/chunk-KRYJVBO5.js";
|
|
15
|
-
import "../../../chunks/chunk-XCBH6NLF.js";
|
|
16
|
-
|
|
17
|
-
// src/agnostic/colors/grayscale/index.ts
|
|
9
|
+
viaLch
|
|
10
|
+
} from "../convert/index.js";
|
|
18
11
|
function avgGrayscaleRgb(rgb) {
|
|
19
12
|
const { r, g, b } = rgb;
|
|
20
13
|
const avg = (r + g + b) / 3;
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
viaLab,
|
|
3
|
-
viaLch,
|
|
4
|
-
viaRgb
|
|
5
|
-
} from "../../../chunks/chunk-RNXRHCHQ.js";
|
|
6
|
-
import {
|
|
7
|
-
absoluteModulo
|
|
8
|
-
} from "../../../chunks/chunk-DNIOWD7K.js";
|
|
9
|
-
import "../../../chunks/chunk-OSAXBA7G.js";
|
|
10
|
-
import "../../../chunks/chunk-JDINERKY.js";
|
|
11
|
-
import "../../../chunks/chunk-HQLRJ7XW.js";
|
|
12
|
-
import "../../../chunks/chunk-KRYJVBO5.js";
|
|
13
|
-
import "../../../chunks/chunk-XCBH6NLF.js";
|
|
14
|
-
|
|
15
1
|
// src/agnostic/colors/invert/index.ts
|
|
2
|
+
import { viaRgb, viaLab, viaLch } from "../convert/index.js";
|
|
3
|
+
import { absoluteModulo } from "../../numbers/absolute-modulo/index.js";
|
|
16
4
|
function invertRgb(color) {
|
|
17
5
|
return viaRgb(color, (rgb) => ({
|
|
18
6
|
...rgb,
|
|
@@ -1,25 +1,18 @@
|
|
|
1
|
+
// src/agnostic/colors/lerp/index.ts
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
toHsl,
|
|
4
|
-
toLab,
|
|
5
|
-
toLch,
|
|
6
|
-
toRgb,
|
|
7
|
-
toXyz,
|
|
8
|
-
viaHsb,
|
|
9
|
-
viaHsl,
|
|
3
|
+
viaRgb,
|
|
10
4
|
viaLab,
|
|
11
5
|
viaLch,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// src/agnostic/colors/lerp/index.ts
|
|
6
|
+
viaHsl,
|
|
7
|
+
viaHsb,
|
|
8
|
+
viaXyz,
|
|
9
|
+
toRgb,
|
|
10
|
+
toLab,
|
|
11
|
+
toLch,
|
|
12
|
+
toHsl,
|
|
13
|
+
toHsb,
|
|
14
|
+
toXyz
|
|
15
|
+
} from "../convert/index.js";
|
|
23
16
|
function lerpRgb(rgb1, rgb2, amount) {
|
|
24
17
|
const r = rgb1.r + (rgb2.r - rgb1.r) * amount;
|
|
25
18
|
const g = rgb1.g + (rgb2.g - rgb1.g) * amount;
|