Socket
Socket
Sign inDemoInstall

@csstools/css-color-parser

Package Overview
Dependencies
Maintainers
3
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@csstools/css-color-parser - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

98

CHANGELOG.md
# Changes to CSS Color Parser
### 1.5.0
_December 15, 2023_
- Add the `Experimental` syntax flag, to be used in future features.
- Add a `serializeHSL` function.
- Fix type definitions
- Improve JS Doc comments
- Updated [`@csstools/color-helpers`](https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers) to [`4.0.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers/CHANGELOG.md#400) (major)
- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#222) (patch)
- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.4.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#240) (minor)
- Updated [`@csstools/css-calc`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc) to [`1.1.5`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc/CHANGELOG.md#115) (patch)
### 1.4.0

@@ -15,85 +28,2 @@

### 1.3.2
_September 24, 2023_
- Small performance improvements
- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#221) (patch)
- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.3.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#232) (patch)
- Updated [`@csstools/css-calc`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc) to [`1.1.4`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc/CHANGELOG.md#114) (patch)
### 1.3.1
_September 2, 2023_
- Fix clipping of values in `hsl`, `hwb` and `rgb` color notations.
- Updated [`@csstools/color-helpers`](https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers) to [`3.0.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers/CHANGELOG.md#302) (patch)
### 1.3.0
_August 28, 2023_
- Add a `serializeOKLCH` function.
- Always convert to the target color space, even when the input color is already in that specific color space.
- Correctly apply the hue interpolation method when either angle is missing.
- Updated [`@csstools/color-helpers`](https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers) to [`3.0.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers/CHANGELOG.md#301) (patch)
### 1.2.3
_July 24, 2023_
- Allow number values in `hwb`.
- Fix value calculation for `s`, `l` (`hsl`) and `w`, `b` (`hwb`) components in relative color syntax.
- `a` and `b` components in `lab` and `oklab` are analogous.
- Powerless components are limited to achromatic colors and only affect `hue` unless otherwise specified.
- Fix value normalization.
- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#220) (minor)
- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#231) (patch)
- Updated [`@csstools/css-calc`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc) to [`1.1.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc/CHANGELOG.md#113) (patch)
### 1.2.2
_July 3, 2023_
- Updated [`@csstools/color-helpers`](https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers) to [`3.0.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers/CHANGELOG.md#300) (major)
- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.3.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#230) (minor)
- Updated [`@csstools/css-calc`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc) to [`1.1.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc/CHANGELOG.md#112) (patch)
### 1.2.1
_June 14, 2023_
- Fix value calculation for `hue` components in relative color syntax.
### 1.2.0
_May 19, 2023_
- Add support for relative color syntax.
- Updated `@csstools/color-helpers` to `2.1.0` (minor)
### 1.1.2
_April 10, 2023_
- Updated `@csstools/css-tokenizer` to `2.1.1` (patch)
- Updated `@csstools/css-parser-algorithms` to `2.1.1` (patch)
- Updated `@csstools/css-calc` to `1.1.1` (patch)
### 1.1.1
_April 10, 2023_
- Improve the detection of math function in color notations.
### 1.1.0
_March 28, 2023_
- Add a flag to `serializeP3` and `serializeRGB` to skip gamut mapping.
### 1.0.0
_March 25, 2023_
- Initial version
[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md)

143

dist/index.d.ts

@@ -1,10 +0,137 @@

import type { ColorData } from './color-data';
import type { Color } from '@csstools/color-helpers';
import type { ComponentValue } from '@csstools/css-parser-algorithms';
export type { ColorData } from './color-data';
export { ColorNotation } from './color-notation';
export { SyntaxFlag } from './color-data';
export { colorDataTo, colorDataFitsRGB_Gamut, colorDataFitsDisplayP3_Gamut } from './color-data';
export { serializeP3 } from './serialize/p3';
export { serializeRGB } from './serialize/rgb';
export { serializeOKLCH } from './serialize/oklch';
import { FunctionNode } from '@csstools/css-parser-algorithms';
/**
* Convert a color function to a `ColorData` object.
*
* @param {ComponentValue} colorNode - The color function to be converted.
* @returns {ColorData|false} The color function as a `ColorData` object or `false` if it could not be converted.
*/
export declare function color(colorNode: ComponentValue): ColorData | false;
export declare type ColorData = {
colorNotation: ColorNotation;
channels: Color;
alpha: number | ComponentValue;
syntaxFlags: Set<SyntaxFlag>;
};
/**
* Check if a color data object fits the `display-p3` gamut.
*
* @param {ColorData} x - The color data to be checked.
* @returns {boolean} Whether the color data fits the `display-p3` gamut.
*/
export declare function colorDataFitsDisplayP3_Gamut(x: ColorData): boolean;
/**
* Check if a color data object fits the `sRGB` gamut.
*
* @param {ColorData} x - The color data to be checked.
* @returns {boolean} Whether the color data fits the `sRGB` gamut.
*/
export declare function colorDataFitsRGB_Gamut(x: ColorData): boolean;
export declare function colorDataTo(colorData: ColorData, toNotation: ColorNotation): ColorData;
export declare enum ColorNotation {
/** Adobe 1999, expressed through `color(a98-rgb 0 0 0)` */
A98_RGB = "a98-rgb",
/** Display P3, expressed through `color(display-p3 0 0 0)` */
Display_P3 = "display-p3",
/** Hex, expressed through `#000` */
HEX = "hex",
/** HSL, expressed through `hsl(0 0% 0%)` */
HSL = "hsl",
/** HWB, expressed through `hwb(0 0% 0%)` */
HWB = "hwb",
/** LCH, expressed through `lch(0 0% 0deg)` */
LCH = "lch",
/** Lab, expressed through `lab(0 0 0)` */
Lab = "lab",
/** Linear sRGB, expressed through `color(linear-srgb 0 0 0)` */
Linear_sRGB = "srgb-linear",
/** Oklch, expressed through `oklch(0 0% 0deg)` */
OKLCH = "oklch",
/** Oklab, expressed through `oklab(0 0 0)` */
OKLab = "oklab",
/** ProPhoto RGB, expressed through `color(prophoto-rgb 0 0 0)` */
ProPhoto_RGB = "prophoto-rgb",
/** RGB, expressed through `rgb(0 0 0)` */
RGB = "rgb",
/** sRGB, expressed through `color(srgb 0 0 0)` */
sRGB = "srgb",
/** Rec. 2020, expressed through `color(rec2020 0 0 0)` */
Rec2020 = "rec2020",
/** XYZ, expressed through `color(xyz-d50 0 0 0)` */
XYZ_D50 = "xyz-d50",
/** XYZ, expressed through `color(xyz-d65 0 0 0)` */
XYZ_D65 = "xyz-d65"
}
export declare function serializeHSL(color: ColorData, gamutMapping?: boolean): FunctionNode;
/**
* Convert color data to component values in the OKLCH color space.
* The return value can be converted to a string by calling `toString()` on it.
*
* @param {ColorData} color - The color data to be serialized.
* @returns {FunctionNode} The serialized color data as a FunctionNode object.
*/
export declare function serializeOKLCH(color: ColorData): FunctionNode;
/**
* Convert color data to component values in the display-p3 color space.
* The return value can be converted to a string by calling `toString()` on it.
*
* @param {ColorData} color - The color data to be serialized.
* @param {boolean} gamutMapping - Whether to perform gamut mapping, defaults to `true`.
* @returns {FunctionNode} The serialized color data as a FunctionNode object.
*/
export declare function serializeP3(color: ColorData, gamutMapping?: boolean): FunctionNode;
/**
* Convert color data to component values in the srgb color space.
* The return value can be converted to a string by calling `toString()` on it.
*
* @param {ColorData} color - The color data to be serialized.
* @param {boolean} gamutMapping - Whether to perform gamut mapping, defaults to `true`.
* @returns {FunctionNode} The serialized color data as a FunctionNode object.
*/
export declare function serializeRGB(color: ColorData, gamutMapping?: boolean): FunctionNode;
export declare enum SyntaxFlag {
/** Is a color keyword, e.g. `transparent`, `currentColor`, ... */
ColorKeyword = "color-keyword",
/** Has an explicit alpha channel */
HasAlpha = "has-alpha",
/** Has a channel with a dimension value, e.g. `50deg` */
HasDimensionValues = "has-dimension-values",
/** Has a channel with the `none` keyword */
HasNoneKeywords = "has-none-keywords",
/** Has a channel with a number value */
HasNumberValues = "has-number-values",
/** Has an alpha channel with a percentage value */
HasPercentageAlpha = "has-percentage-alpha",
/** Has a channel with a percentage value */
HasPercentageValues = "has-percentage-values",
/** Has an alpha channel with a `var()` function value */
HasVariableAlpha = "has-variable-alpha",
/** Is Hex notation */
Hex = "hex",
/** Is legacy HSL, e.g. `hsl(50deg, 0%, 0%)` */
LegacyHSL = "legacy-hsl",
/** Is legacy RGB, e.g. `rgb(0, 0, 0)` */
LegacyRGB = "legacy-rgb",
/** Is a named color, e.g. `red`, `blue` */
NamedColor = "named-color",
/** Is a relative color syntax, e.g. `rgb(from purple r g b)` */
RelativeColorSyntax = "relative-color-syntax",
/** Is a mixed color, e.g. `color-mix(in oklch, red, blue)` */
ColorMix = "color-mix",
/** Is an experimental color syntax */
Experimental = "experimental"
}
export { }
{
"name": "@csstools/css-color-parser",
"description": "Parse CSS color values",
"version": "1.4.0",
"version": "1.5.0",
"contributors": [

@@ -30,11 +30,14 @@ {

},
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"default": "./dist/index.mjs"
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
},
"require": {
"default": "./dist/index.cjs"
}
}

@@ -49,16 +52,9 @@ },

"dependencies": {
"@csstools/color-helpers": "^3.0.2",
"@csstools/css-calc": "^1.1.4"
"@csstools/color-helpers": "^4.0.0",
"@csstools/css-calc": "^1.1.5"
},
"peerDependencies": {
"@csstools/css-parser-algorithms": "^2.3.2",
"@csstools/css-tokenizer": "^2.2.1"
"@csstools/css-parser-algorithms": "^2.4.0",
"@csstools/css-tokenizer": "^2.2.2"
},
"scripts": {
"build": "rollup -c ../../rollup/default.mjs",
"lint": "node ../../.github/bin/format-package-json.mjs",
"prepublishOnly": "npm run build && npm run test",
"stryker": "stryker run --logLevel error",
"test": "node ./test/test.mjs && node ./test/_import.mjs && node ./test/_require.cjs"
},
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser#readme",

@@ -75,6 +71,3 @@ "repository": {

"parser"
],
"volta": {
"extends": "../../package.json"
}
]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc