diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2023-10-14 15:05:55 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2023-10-14 15:05:55 +0800 |
| commit | c06f7ee0a40255214c477e13d9b956a7e07c2900 (patch) | |
| tree | f5982a568ef8fab865d0142e71c7494fea3e4c1b /node_modules/@csstools | |
| parent | 3fd9400d4dccc25aa29b5702216732e0b7542073 (diff) | |
postcss,(plugins): nanocss, postcss-preset-env
Diffstat (limited to 'node_modules/@csstools')
531 files changed, 13475 insertions, 0 deletions
diff --git a/node_modules/@csstools/cascade-layer-name-parser/CHANGELOG.md b/node_modules/@csstools/cascade-layer-name-parser/CHANGELOG.md new file mode 100644 index 00000000..d822b088 --- /dev/null +++ b/node_modules/@csstools/cascade-layer-name-parser/CHANGELOG.md @@ -0,0 +1,42 @@ +# Changes to Cascade Layer Name Parser + +### 1.0.5 + +_September 24, 2023_ + +- 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) + +### 1.0.4 + +_July 24, 2023_ + +- 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) + +### 1.0.3 + +_July 3, 2023_ + +- 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) + +### 1.0.2 + +_April 10, 2023_ + +- Updated `@csstools/css-tokenizer` to `2.1.1` (patch) +- Updated `@csstools/css-parser-algorithms` to `2.1.1` (patch) + + + +### 1.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 1.0.0 + +_January 19, 2023_ + +- Initial version diff --git a/node_modules/@csstools/cascade-layer-name-parser/LICENSE.md b/node_modules/@csstools/cascade-layer-name-parser/LICENSE.md new file mode 100644 index 00000000..af5411fa --- /dev/null +++ b/node_modules/@csstools/cascade-layer-name-parser/LICENSE.md @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright 2022 Romain Menke, Antonio Laguna <antonio@laguna.es> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/@csstools/cascade-layer-name-parser/README.md b/node_modules/@csstools/cascade-layer-name-parser/README.md new file mode 100644 index 00000000..44e2111e --- /dev/null +++ b/node_modules/@csstools/cascade-layer-name-parser/README.md @@ -0,0 +1,32 @@ +# Cascade Layer Name Parser + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/cascade-layer-name-parser.svg" height="20">][npm-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +## Usage + +Add [Cascade Layer Name Parser] to your project: + +```bash +npm install @csstools/cascade-layer-name-parser @csstools/css-parser-algorithms @csstools/css-tokenizer --save-dev +``` + +[Cascade Layer Name Parser] depends on our CSS tokenizer and parser algorithms. +It must be used together with `@csstools/css-tokenizer` and `@csstools/css-parser-algorithms`. + +```ts +import { parse } from '@csstools/cascade-layer-name-parser'; + +const layerNames = parse('layer-name, foo.bar'); +layerNames.forEach((layerName) => { + console.log(layerName.name()) // "foo.bar" + console.log(layerName.segments()) // ["foo", "bar"] +}); +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/cascade-layer-name-parser + +[Cascade Layer Name Parser]: https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser diff --git a/node_modules/@csstools/cascade-layer-name-parser/dist/index.cjs b/node_modules/@csstools/cascade-layer-name-parser/dist/index.cjs new file mode 100644 index 00000000..08d61378 --- /dev/null +++ b/node_modules/@csstools/cascade-layer-name-parser/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/css-tokenizer"),n=require("@csstools/css-parser-algorithms");class LayerName{parts;constructor(e){this.parts=e}tokens(){return[...this.parts]}slice(n,r){const t=[];for(let n=0;n<this.parts.length;n++)this.parts[n][0]===e.TokenType.Ident&&t.push(n);const a=t.slice(n,r);return new LayerName(this.parts.slice(a[0],a[a.length-1]+1))}concat(n){const r=[e.TokenType.Delim,".",-1,-1,{value:"."}];return new LayerName([...this.parts.filter((n=>n[0]===e.TokenType.Ident||n[0]===e.TokenType.Delim)),r,...n.parts.filter((n=>n[0]===e.TokenType.Ident||n[0]===e.TokenType.Delim))])}segments(){return this.parts.filter((n=>n[0]===e.TokenType.Ident)).map((e=>e[4].value))}name(){return this.parts.filter((n=>n[0]===e.TokenType.Ident||n[0]===e.TokenType.Delim)).map((e=>e[1])).join("")}equal(e){const n=this.segments(),r=e.segments();if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++){if(n[e]!==r[e])return!1}return!0}toString(){return e.stringify(...this.parts)}toJSON(){return{parts:this.parts,segments:this.segments(),name:this.name()}}}function parseFromTokens(r,t){const a=n.parseCommaSeparatedListOfComponentValues(r,{onParseError:null==t?void 0:t.onParseError}),s=(null==t?void 0:t.onParseError)??(()=>{}),o=["6.4.2. Layer Naming and Nesting","Layer name syntax","<layer-name> = <ident> [ '.' <ident> ]*"],i=r[0][2],l=r[r.length-1][3],p=[];for(let r=0;r<a.length;r++){const t=a[r];for(let r=0;r<t.length;r++){const a=t[r];if(!n.isTokenNode(a)&&!n.isCommentNode(a)&&!n.isWhitespaceNode(a))return s(new e.ParseError(`Invalid cascade layer name. Invalid layer name part "${a.toString()}"`,i,l,o)),[]}const m=t.flatMap((e=>e.tokens()));let c=!1,T=!1,y=null;for(let n=0;n<m.length;n++){const r=m[n];if(r[0]!==e.TokenType.Comment&&r[0]!==e.TokenType.Whitespace&&r[0]!==e.TokenType.Ident&&(r[0]!==e.TokenType.Delim||"."!==r[4].value))return s(new e.ParseError(`Invalid cascade layer name. Invalid character "${r[1]}"`,i,l,o)),[];if(!c&&r[0]===e.TokenType.Delim)return s(new e.ParseError("Invalid cascade layer name. Layer names can not start with a dot.",i,l,o)),[];if(c){if(r[0]===e.TokenType.Whitespace){T=!0;continue}if(T&&r[0]===e.TokenType.Comment)continue;if(T)return s(new e.ParseError("Invalid cascade layer name. Encountered unexpected whitespace between layer name parts.",i,l,o)),[];if(y&&y[0]===e.TokenType.Ident&&r[0]===e.TokenType.Ident)return s(new e.ParseError("Invalid cascade layer name. Layer name parts must be separated by dots.",i,l,o)),[];if(y&&y[0]===e.TokenType.Delim&&r[0]===e.TokenType.Delim)return s(new e.ParseError("Invalid cascade layer name. Layer name parts must not be empty.",i,l,o)),[]}r[0]===e.TokenType.Ident&&(c=!0),r[0]!==e.TokenType.Ident&&r[0]!==e.TokenType.Delim||(y=r)}if(!y)return s(new e.ParseError("Invalid cascade layer name. Empty layer name.",i,l,o)),[];if(y[0]===e.TokenType.Delim)return s(new e.ParseError("Invalid cascade layer name. Layer name must not end with a dot.",i,l,o)),[];p.push(new LayerName(m))}return p}exports.LayerName=LayerName,exports.addLayerToModel=function addLayerToModel(e,n){return n.forEach((n=>{const r=n.segments();e:for(let t=0;t<r.length;t++){const r=n.slice(0,t+1),a=r.segments();let s=-1,o=0;for(let n=0;n<e.length;n++){const r=e[n].segments();let t=0;n:for(let e=0;e<r.length;e++){const n=r[e],s=a[e];if(s===n&&e+1===a.length)continue e;if(s!==n){if(s!==n)break n}else t++}t>=o&&(s=n,o=t)}-1===s?e.push(r):e.splice(s+1,0,r)}})),e},exports.parse=function parse(n,r){const t=e.tokenizer({css:n},{onParseError:null==r?void 0:r.onParseError}),a=[];for(;!t.endOfFile();)a.push(t.nextToken());return a.push(t.nextToken()),parseFromTokens(a,r)},exports.parseFromTokens=parseFromTokens; diff --git a/node_modules/@csstools/cascade-layer-name-parser/dist/index.d.ts b/node_modules/@csstools/cascade-layer-name-parser/dist/index.d.ts new file mode 100644 index 00000000..2592bc2e --- /dev/null +++ b/node_modules/@csstools/cascade-layer-name-parser/dist/index.d.ts @@ -0,0 +1,3 @@ +export { LayerName } from './nodes/layer-name'; +export { addLayerToModel } from './util/model'; +export { parse, parseFromTokens } from './parser/parse'; diff --git a/node_modules/@csstools/cascade-layer-name-parser/dist/index.mjs b/node_modules/@csstools/cascade-layer-name-parser/dist/index.mjs new file mode 100644 index 00000000..e9cc05e9 --- /dev/null +++ b/node_modules/@csstools/cascade-layer-name-parser/dist/index.mjs @@ -0,0 +1 @@ +import{TokenType as e,stringify as t,ParseError as n,tokenizer as r}from"@csstools/css-tokenizer";import{parseCommaSeparatedListOfComponentValues as a,isTokenNode as s,isCommentNode as l,isWhitespaceNode as i}from"@csstools/css-parser-algorithms";class LayerName{parts;constructor(e){this.parts=e}tokens(){return[...this.parts]}slice(t,n){const r=[];for(let t=0;t<this.parts.length;t++)this.parts[t][0]===e.Ident&&r.push(t);const a=r.slice(t,n);return new LayerName(this.parts.slice(a[0],a[a.length-1]+1))}concat(t){const n=[e.Delim,".",-1,-1,{value:"."}];return new LayerName([...this.parts.filter((t=>t[0]===e.Ident||t[0]===e.Delim)),n,...t.parts.filter((t=>t[0]===e.Ident||t[0]===e.Delim))])}segments(){return this.parts.filter((t=>t[0]===e.Ident)).map((e=>e[4].value))}name(){return this.parts.filter((t=>t[0]===e.Ident||t[0]===e.Delim)).map((e=>e[1])).join("")}equal(e){const t=this.segments(),n=e.segments();if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++){if(t[e]!==n[e])return!1}return!0}toString(){return t(...this.parts)}toJSON(){return{parts:this.parts,segments:this.segments(),name:this.name()}}}function addLayerToModel(e,t){return t.forEach((t=>{const n=t.segments();e:for(let r=0;r<n.length;r++){const n=t.slice(0,r+1),a=n.segments();let s=-1,l=0;for(let t=0;t<e.length;t++){const n=e[t].segments();let r=0;t:for(let e=0;e<n.length;e++){const t=n[e],s=a[e];if(s===t&&e+1===a.length)continue e;if(s!==t){if(s!==t)break t}else r++}r>=l&&(s=t,l=r)}-1===s?e.push(n):e.splice(s+1,0,n)}})),e}function parseFromTokens(t,r){const o=a(t,{onParseError:null==r?void 0:r.onParseError}),m=(null==r?void 0:r.onParseError)??(()=>{}),c=["6.4.2. Layer Naming and Nesting","Layer name syntax","<layer-name> = <ident> [ '.' <ident> ]*"],d=t[0][2],u=t[t.length-1][3],p=[];for(let t=0;t<o.length;t++){const r=o[t];for(let e=0;e<r.length;e++){const t=r[e];if(!s(t)&&!l(t)&&!i(t))return m(new n(`Invalid cascade layer name. Invalid layer name part "${t.toString()}"`,d,u,c)),[]}const a=r.flatMap((e=>e.tokens()));let h=!1,f=!1,y=null;for(let t=0;t<a.length;t++){const r=a[t];if(r[0]!==e.Comment&&r[0]!==e.Whitespace&&r[0]!==e.Ident&&(r[0]!==e.Delim||"."!==r[4].value))return m(new n(`Invalid cascade layer name. Invalid character "${r[1]}"`,d,u,c)),[];if(!h&&r[0]===e.Delim)return m(new n("Invalid cascade layer name. Layer names can not start with a dot.",d,u,c)),[];if(h){if(r[0]===e.Whitespace){f=!0;continue}if(f&&r[0]===e.Comment)continue;if(f)return m(new n("Invalid cascade layer name. Encountered unexpected whitespace between layer name parts.",d,u,c)),[];if(y&&y[0]===e.Ident&&r[0]===e.Ident)return m(new n("Invalid cascade layer name. Layer name parts must be separated by dots.",d,u,c)),[];if(y&&y[0]===e.Delim&&r[0]===e.Delim)return m(new n("Invalid cascade layer name. Layer name parts must not be empty.",d,u,c)),[]}r[0]===e.Ident&&(h=!0),r[0]!==e.Ident&&r[0]!==e.Delim||(y=r)}if(!y)return m(new n("Invalid cascade layer name. Empty layer name.",d,u,c)),[];if(y[0]===e.Delim)return m(new n("Invalid cascade layer name. Layer name must not end with a dot.",d,u,c)),[];p.push(new LayerName(a))}return p}function parse(e,t){const n=r({css:e},{onParseError:null==t?void 0:t.onParseError}),a=[];for(;!n.endOfFile();)a.push(n.nextToken());return a.push(n.nextToken()),parseFromTokens(a,t)}export{LayerName,addLayerToModel,parse,parseFromTokens}; diff --git a/node_modules/@csstools/cascade-layer-name-parser/dist/nodes/layer-name.d.ts b/node_modules/@csstools/cascade-layer-name-parser/dist/nodes/layer-name.d.ts new file mode 100644 index 00000000..94d956f5 --- /dev/null +++ b/node_modules/@csstools/cascade-layer-name-parser/dist/nodes/layer-name.d.ts @@ -0,0 +1,17 @@ +import { CSSToken } from '@csstools/css-tokenizer'; +export declare class LayerName { + parts: Array<CSSToken>; + constructor(parts: Array<CSSToken>); + tokens(): Array<CSSToken>; + slice(start: number, end: number): LayerName; + concat(other: LayerName): LayerName; + segments(): Array<string>; + name(): string; + equal(other: LayerName): boolean; + toString(): string; + toJSON(): { + parts: CSSToken[]; + segments: string[]; + name: string; + }; +} diff --git a/node_modules/@csstools/cascade-layer-name-parser/dist/parser/parse.d.ts b/node_modules/@csstools/cascade-layer-name-parser/dist/parser/parse.d.ts new file mode 100644 index 00000000..2f068c4c --- /dev/null +++ b/node_modules/@csstools/cascade-layer-name-parser/dist/parser/parse.d.ts @@ -0,0 +1,7 @@ +import { CSSToken, ParseError } from '@csstools/css-tokenizer'; +import { LayerName } from '../nodes/layer-name'; +export type Options = { + onParseError?: (error: ParseError) => void; +}; +export declare function parseFromTokens(tokens: Array<CSSToken>, options?: Options): LayerName[]; +export declare function parse(source: string, options?: Options): LayerName[]; diff --git a/node_modules/@csstools/cascade-layer-name-parser/dist/util/model.d.ts b/node_modules/@csstools/cascade-layer-name-parser/dist/util/model.d.ts new file mode 100644 index 00000000..7347ce26 --- /dev/null +++ b/node_modules/@csstools/cascade-layer-name-parser/dist/util/model.d.ts @@ -0,0 +1,2 @@ +import { LayerName } from '../nodes/layer-name'; +export declare function addLayerToModel(layers: Array<LayerName>, currentLayerNames: Array<LayerName>): LayerName[]; diff --git a/node_modules/@csstools/cascade-layer-name-parser/package.json b/node_modules/@csstools/cascade-layer-name-parser/package.json new file mode 100644 index 00000000..e244cb90 --- /dev/null +++ b/node_modules/@csstools/cascade-layer-name-parser/package.json @@ -0,0 +1,74 @@ +{ + "name": "@csstools/cascade-layer-name-parser", + "description": "Parse CSS Cascade Layer names.", + "version": "1.0.5", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "peerDependencies": { + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1" + }, + "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", + "test:rewrite-expects": "REWRITE_EXPECTS=true node ./test/test.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "packages/cascade-layer-name-parser" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "cascade-layer", + "css", + "parser" + ], + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/color-helpers/CHANGELOG.md b/node_modules/@csstools/color-helpers/CHANGELOG.md new file mode 100644 index 00000000..032f0578 --- /dev/null +++ b/node_modules/@csstools/color-helpers/CHANGELOG.md @@ -0,0 +1,40 @@ +# Changes to Color Helpers + +### 3.0.2 + +_September 2, 2023_ + +- Undo the changes from `3.0.1`. + +### 3.0.1 + +_August 28, 2023_ + +- Clamp negative saturation in `hsl` to `0`. + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) + +### 2.1.0 + +_May 19, 2023_ + +- Fix gamut mapping +- Fix `XYZ_D50_to_ProPhoto` +- Export `sRGB_to_HWB` + +### 2.0.0 + +_March 25, 2023_ + +- Removed certain implementation specific helpers. Keeping this package more focussed on general purpose color transformations. +- Added `xyz` specific helpers. These make it easy to transform to and from `xyz-d50` and any other color space. + +### 1.0.0 + +_February 2, 2023_ + +- Initial version diff --git a/node_modules/@csstools/color-helpers/LICENSE.md b/node_modules/@csstools/color-helpers/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/color-helpers/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/color-helpers/README.md b/node_modules/@csstools/color-helpers/README.md new file mode 100644 index 00000000..18358022 --- /dev/null +++ b/node_modules/@csstools/color-helpers/README.md @@ -0,0 +1,32 @@ +# Color Helpers + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/color-helpers.svg" height="20">][npm-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +## Usage + +Add [Color Helpers] to your project: + +```bash +npm install @csstools/color-helpers --save-dev +``` + +This package exists to join all the different color functions scattered among the Colors 4 and Colors 5 plugins we maintain such as: + +* [PostCSS Color Function] +* [PostCSS Lab Function] +* [PostCSS OKLab Function] + +## Copyright + +This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/tree/main/css-color-4. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/color-helpers + +[Color Helpers]: https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers +[PostCSS Color Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-function +[PostCSS Lab Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-lab-functionw +[PostCSS OKLab Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-oklab-function diff --git a/node_modules/@csstools/color-helpers/dist/calculations/binary-search-gamut.d.ts b/node_modules/@csstools/color-helpers/dist/calculations/binary-search-gamut.d.ts new file mode 100644 index 00000000..a6569f95 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/calculations/binary-search-gamut.d.ts @@ -0,0 +1,2 @@ +import type { Color } from 'types/color'; +export declare function binarySearchGamut(startOKLCH: Color, toDestination: (x: Color) => Color, fromDestination: (x: Color) => Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/calculations/contrast.d.ts b/node_modules/@csstools/color-helpers/dist/calculations/contrast.d.ts new file mode 100644 index 00000000..fee9456e --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/calculations/contrast.d.ts @@ -0,0 +1,2 @@ +import type { Color } from 'types/color'; +export declare function contrast(RGB1: Color, RGB2: Color): number; diff --git a/node_modules/@csstools/color-helpers/dist/calculations/delta-EOK.d.ts b/node_modules/@csstools/color-helpers/dist/calculations/delta-EOK.d.ts new file mode 100644 index 00000000..ad7878ba --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/calculations/delta-EOK.d.ts @@ -0,0 +1,14 @@ +import type { Color } from 'types/color'; +/** + * @description Calculate deltaE OK which is the simple root sum of squares + * @param {number[]} reference - Array of OKLab values: L as 0..1, a and b as -1..1 + * @param {number[]} sample - Array of OKLab values: L as 0..1, a and b as -1..1 + * @return {number} How different a color sample is from reference + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/deltaEOK.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/deltaEOK.js + */ +export declare function deltaEOK(reference: Color, sample: Color): number; diff --git a/node_modules/@csstools/color-helpers/dist/calculations/index.d.ts b/node_modules/@csstools/color-helpers/dist/calculations/index.d.ts new file mode 100644 index 00000000..86e5f357 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/calculations/index.d.ts @@ -0,0 +1,5 @@ +export * from './binary-search-gamut'; +export * from './map-gamut'; +export * from './delta-EOK'; +export * from './contrast'; +export * from './multiply-matrices'; diff --git a/node_modules/@csstools/color-helpers/dist/calculations/map-gamut.d.ts b/node_modules/@csstools/color-helpers/dist/calculations/map-gamut.d.ts new file mode 100644 index 00000000..7bf8f709 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/calculations/map-gamut.d.ts @@ -0,0 +1,2 @@ +import type { Color } from 'types/color'; +export declare function mapGamut(startOKLCH: Color, toDestination: (x: Color) => Color, fromDestination: (x: Color) => Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/calculations/multiply-matrices.d.ts b/node_modules/@csstools/color-helpers/dist/calculations/multiply-matrices.d.ts new file mode 100644 index 00000000..b78e13fd --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/calculations/multiply-matrices.d.ts @@ -0,0 +1,12 @@ +/** + * Simple matrix (and vector) multiplication + * Warning: No error handling for incompatible dimensions! + * @author Lea Verou 2020 MIT License + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/multiply-matrices.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/multiply-matrices.js + */ +export declare function multiplyMatrices(a: Array<Array<number>> | Array<number>, b: Array<Array<number>> | Array<number>): Array<Array<number>> | Array<number>; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/constants.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/constants.d.ts new file mode 100644 index 00000000..4d2e7a1e --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/constants.d.ts @@ -0,0 +1,2 @@ +export declare const D50: number[]; +export declare const D65: number[]; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/d50-to-d65.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/d50-to-d65.d.ts new file mode 100644 index 00000000..7afb26ae --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/d50-to-d65.d.ts @@ -0,0 +1,9 @@ +import type { Color } from 'types/color'; +/** + * Bradford chromatic adaptation from D50 to D65 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function D50_to_D65(XYZ: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/d65-to-d50.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/d65-to-d50.d.ts new file mode 100644 index 00000000..5409797a --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/d65-to-d50.d.ts @@ -0,0 +1,10 @@ +import type { Color } from 'types/color'; +/** + * Bradford chromatic adaptation from D65 to D50 + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html + */ +export declare function D65_to_D50(XYZ: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/gam-2020.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/gam-2020.d.ts new file mode 100644 index 00000000..a4327761 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/gam-2020.d.ts @@ -0,0 +1,10 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of linear-light rec2020 RGB in the range 0.0-1.0 + * to gamma corrected form ITU-R BT.2020-2 p.4 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function gam_2020(RGB: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/gam-a98rgb.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/gam-a98rgb.d.ts new file mode 100644 index 00000000..87727af7 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/gam-a98rgb.d.ts @@ -0,0 +1,10 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of linear-light a98-rgb in the range 0.0-1.0 + * to gamma corrected form. Negative values are also now accepted + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function gam_a98rgb(RGB: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/gam-p3.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/gam-p3.d.ts new file mode 100644 index 00000000..60d31f14 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/gam-p3.d.ts @@ -0,0 +1,10 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of linear-light display-p3 RGB in the range 0.0-1.0 + * to gamma corrected form + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function gam_P3(RGB: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/gam-pro-photo.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/gam-pro-photo.d.ts new file mode 100644 index 00000000..fe2aba29 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/gam-pro-photo.d.ts @@ -0,0 +1,11 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of linear-light prophoto-rgb in the range 0.0-1.0 + * to gamma corrected form. + * Transfer curve is gamma 1.8 with a small linear portion. + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function gam_ProPhoto(RGB: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/gam-srgb.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/gam-srgb.d.ts new file mode 100644 index 00000000..c7cfba5f --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/gam-srgb.d.ts @@ -0,0 +1,14 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of linear-light sRGB values in the range 0.0-1.0 to gamma corrected form + * Extended transfer function: + * For negative values, linear portion extends on reflection + * of axis, then uses reflected pow below that + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://en.wikipedia.org/wiki/SRGB + */ +export declare function gam_sRGB(RGB: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/hsl-to-srgb.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/hsl-to-srgb.d.ts new file mode 100644 index 00000000..1366bc00 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/hsl-to-srgb.d.ts @@ -0,0 +1,14 @@ +import type { Color } from 'types/color'; +/** + * @param {number} hue - Hue as degrees 0..360 + * @param {number} sat - Saturation as percentage 0..100 + * @param {number} light - Lightness as percentage 0..100 + * @return {number[]} Array of RGB components 0..1 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js + */ +export declare function HSL_to_sRGB(HSL: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/hue-to-rgb.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/hue-to-rgb.d.ts new file mode 100644 index 00000000..8cb5ff7c --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/hue-to-rgb.d.ts @@ -0,0 +1,8 @@ +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */ +export declare function hueToRGB(t1: number, t2: number, hue: number): number; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/hwb-to-srgb.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/hwb-to-srgb.d.ts new file mode 100644 index 00000000..e359a498 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/hwb-to-srgb.d.ts @@ -0,0 +1,14 @@ +import type { Color } from 'types/color'; +/** + * @param {number} hue - Hue as degrees 0..360 + * @param {number} white - Whiteness as percentage 0..100 + * @param {number} black - Blackness as percentage 0..100 + * @return {number[]} Array of RGB components 0..1 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js + */ +export declare function HWB_to_sRGB(HWB: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/index.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/index.d.ts new file mode 100644 index 00000000..9a2ed427 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/index.d.ts @@ -0,0 +1,40 @@ +export * from './constants'; +export * from './d50-to-d65'; +export * from './d65-to-d50'; +export * from './gam-2020'; +export * from './gam-a98rgb'; +export * from './gam-p3'; +export * from './gam-pro-photo'; +export * from './gam-srgb'; +export * from './hsl-to-srgb'; +export * from './hue-to-rgb'; +export * from './hwb-to-srgb'; +export * from './lab-to-lch'; +export * from './lab-to-xyz'; +export * from './lch-to-lab'; +export * from './lin-2020'; +export * from './lin-2020-to-xyz'; +export * from './lin-a98rgb'; +export * from './lin-a98rgb-to-xyz'; +export * from './lin-p3'; +export * from './lin-p3-to-xyz'; +export * from './lin-pro-photo'; +export * from './lin-pro-photo-to-xyz'; +export * from './lin-srgb'; +export * from './lin-srgb-to-xyz'; +export * from './naive-cmyk-to-srgb'; +export * from './oklab-to-oklch'; +export * from './oklab-to-xyz'; +export * from './oklch-to-oklab'; +export * from './srgb-to-hsl'; +export * from './srgb-to-hwb'; +export * from './srgb-to-luminance'; +export * from './xyz-to-lab'; +export * from './xyz-to-lin-2020'; +export * from './xyz-to-lin-a98rgb'; +export * from './xyz-to-lin-p3'; +export * from './xyz-to-lin-pro-photo'; +export * from './xyz-to-lin-srgb'; +export * from './xyz-to-oklab'; +export * from './xyz-to-uv'; +export * from './xyz-to-xy'; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/lab-to-lch.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/lab-to-lch.d.ts new file mode 100644 index 00000000..8ecc0b61 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/lab-to-lch.d.ts @@ -0,0 +1,7 @@ +import type { Color } from 'types/color'; +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function Lab_to_LCH(Lab: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/lab-to-xyz.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/lab-to-xyz.d.ts new file mode 100644 index 00000000..dea458fe --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/lab-to-xyz.d.ts @@ -0,0 +1,2 @@ +import type { Color } from 'types/color'; +export declare function Lab_to_XYZ(Lab: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/lch-to-lab.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/lch-to-lab.d.ts new file mode 100644 index 00000000..107b5148 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/lch-to-lab.d.ts @@ -0,0 +1,7 @@ +import type { Color } from 'types/color'; +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function LCH_to_Lab(LCH: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/lin-2020-to-xyz.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/lin-2020-to-xyz.d.ts new file mode 100644 index 00000000..f9116c4a --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/lin-2020-to-xyz.d.ts @@ -0,0 +1,12 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of linear-light rec2020 values to CIE XYZ + * using D65 (no chromatic adaptation) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */ +export declare function lin_2020_to_XYZ(rgb: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/lin-2020.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/lin-2020.d.ts new file mode 100644 index 00000000..03a5a29d --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/lin-2020.d.ts @@ -0,0 +1,11 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of rec2020 RGB values in the range 0.0 - 1.0 + * to linear light (un-companded) form. + * ITU-R BT.2020-2 p.4 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function lin_2020(RGB: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/lin-a98rgb-to-xyz.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/lin-a98rgb-to-xyz.d.ts new file mode 100644 index 00000000..e73f04f2 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/lin-a98rgb-to-xyz.d.ts @@ -0,0 +1,18 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of linear-light a98-rgb values to CIE XYZ + * http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + * has greater numerical precision than section 4.3.5.3 of + * https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf + * but the values below were calculated from first principles + * from the chromaticity coordinates of R G B W + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + * @see https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/matrixmaker.html + */ +export declare function lin_a98rgb_to_XYZ(rgb: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/lin-a98rgb.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/lin-a98rgb.d.ts new file mode 100644 index 00000000..ae9c470e --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/lin-a98rgb.d.ts @@ -0,0 +1,10 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of a98-rgb values in the range 0.0 - 1.0 + * to linear light (un-companded) form. Negative values are also now accepted + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function lin_a98rgb(RGB: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/lin-p3-to-xyz.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/lin-p3-to-xyz.d.ts new file mode 100644 index 00000000..ed542c25 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/lin-p3-to-xyz.d.ts @@ -0,0 +1,12 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of linear-light display-p3 values to CIE XYZ + * using D65 (no chromatic adaptation) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */ +export declare function lin_P3_to_XYZ(rgb: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/lin-p3.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/lin-p3.d.ts new file mode 100644 index 00000000..2475231c --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/lin-p3.d.ts @@ -0,0 +1,10 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of display-p3 RGB values in the range 0.0 - 1.0 + * to linear light (un-companded) form. + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function lin_P3(RGB: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/lin-pro-photo-to-xyz.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/lin-pro-photo-to-xyz.d.ts new file mode 100644 index 00000000..a857852d --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/lin-pro-photo-to-xyz.d.ts @@ -0,0 +1,12 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of linear-light prophoto-rgb values to CIE XYZ + * using D50 (so no chromatic adaptation needed afterwards) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */ +export declare function lin_ProPhoto_to_XYZ(rgb: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/lin-pro-photo.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/lin-pro-photo.d.ts new file mode 100644 index 00000000..3ecf2893 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/lin-pro-photo.d.ts @@ -0,0 +1,11 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of prophoto-rgb values where in-gamut Colors are in the + * range [0.0 - 1.0] to linear light (un-companded) form. Transfer curve is + * gamma 1.8 with a small linear portion. Extended transfer function + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function lin_ProPhoto(RGB: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/lin-srgb-to-xyz.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/lin-srgb-to-xyz.d.ts new file mode 100644 index 00000000..81384165 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/lin-srgb-to-xyz.d.ts @@ -0,0 +1,10 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of linear-light sRGB values to CIE XYZ + * using sRGB's own white, D65 (no chromatic adaptation) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function lin_sRGB_to_XYZ(rgb: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/lin-srgb.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/lin-srgb.d.ts new file mode 100644 index 00000000..4365c9b0 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/lin-srgb.d.ts @@ -0,0 +1,15 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of of sRGB values where in-gamut values are in the range + * [0 - 1] to linear light (un-companded) form. + * Extended transfer function: + * For negative values, linear portion is extended on reflection of axis, + * then reflected power function is used. + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://en.wikipedia.org/wiki/SRGB + */ +export declare function lin_sRGB(RGB: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/naive-cmyk-to-srgb.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/naive-cmyk-to-srgb.d.ts new file mode 100644 index 00000000..9584f125 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/naive-cmyk-to-srgb.d.ts @@ -0,0 +1,14 @@ +import type { Color } from 'types/color'; +/** + * CMYK is an array of four values in the range [0.0, 1.0] the output is an + * array of [RGB] also in the [0.0, 1.0] range because the naive algorithm + * does not generate out of gamut colors neither does it generate accurate + * simulations of practical CMYK colors + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */ +export declare function naive_CMYK_to_sRGB(CMYK: [number, number, number, number]): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/oklab-to-oklch.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/oklab-to-oklch.d.ts new file mode 100644 index 00000000..0c75e2e5 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/oklab-to-oklch.d.ts @@ -0,0 +1,9 @@ +import type { Color } from 'types/color'; +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js + */ +export declare function OKLab_to_OKLCH(OKLab: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/oklab-to-xyz.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/oklab-to-xyz.d.ts new file mode 100644 index 00000000..c42206d0 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/oklab-to-xyz.d.ts @@ -0,0 +1,2 @@ +import type { Color } from 'types/color'; +export declare function OKLab_to_XYZ(OKLab: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/oklch-to-oklab.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/oklch-to-oklab.d.ts new file mode 100644 index 00000000..9ba9533d --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/oklch-to-oklab.d.ts @@ -0,0 +1,9 @@ +import type { Color } from 'types/color'; +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js + */ +export declare function OKLCH_to_OKLab(OKLCH: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/srgb-to-hsl.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/srgb-to-hsl.d.ts new file mode 100644 index 00000000..0159a182 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/srgb-to-hsl.d.ts @@ -0,0 +1,16 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of gamma-corrected sRGB values in the 0.0 to 1.0 range to HSL. + * + * @param {Color} RGB [r, g, b] + * - Red component 0..1 + * - Green component 0..1 + * - Blue component 0..1 + * @return {number[]} Array of HSL values: Hue as degrees 0..360, Saturation and Lightness as percentages 0..100 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/rgbToHsl.js + */ +export declare function sRGB_to_HSL(RGB: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/srgb-to-hwb.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/srgb-to-hwb.d.ts new file mode 100644 index 00000000..9a79caf7 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/srgb-to-hwb.d.ts @@ -0,0 +1,11 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of gamma-corrected sRGB values in the 0.0 to 1.0 range to HWB. + * + * @param {Color} RGB [r, g, b] + * - Red component 0..1 + * - Green component 0..1 + * - Blue component 0..1 + * @return {number[]} Array of HWB values + */ +export declare function sRGB_to_HWB(RGB: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/srgb-to-luminance.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/srgb-to-luminance.d.ts new file mode 100644 index 00000000..681feb09 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/srgb-to-luminance.d.ts @@ -0,0 +1,12 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of gamma-corrected sRGB values in the 0.0 to 1.0 range + * to linear-light sRGB, then to CIE XYZ and return luminance (the Y value) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */ +export declare function sRGB_to_luminance(RGB: Color): number; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lab.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lab.d.ts new file mode 100644 index 00000000..65a3ecfe --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lab.d.ts @@ -0,0 +1,2 @@ +import type { Color } from 'types/color'; +export declare function XYZ_to_Lab(XYZ: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-2020.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-2020.d.ts new file mode 100644 index 00000000..cae6c260 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-2020.d.ts @@ -0,0 +1,9 @@ +import type { Color } from 'types/color'; +/** + * Convert XYZ to linear-light rec2020 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function XYZ_to_lin_2020(XYZ: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-a98rgb.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-a98rgb.d.ts new file mode 100644 index 00000000..26353878 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-a98rgb.d.ts @@ -0,0 +1,9 @@ +import type { Color } from 'types/color'; +/** + * Convert XYZ to linear-light a98-rgb + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function XYZ_to_lin_a98rgb(XYZ: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-p3.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-p3.d.ts new file mode 100644 index 00000000..e52917c7 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-p3.d.ts @@ -0,0 +1,9 @@ +import type { Color } from 'types/color'; +/** + * Convert XYZ to linear-light P3 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function XYZ_to_lin_P3(XYZ: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-pro-photo.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-pro-photo.d.ts new file mode 100644 index 00000000..bf163166 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-pro-photo.d.ts @@ -0,0 +1,11 @@ +import type { Color } from 'types/color'; +/** + * Convert XYZ to linear-light prophoto-rgb + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */ +export declare function XYZ_to_lin_ProPhoto(XYZ: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-srgb.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-srgb.d.ts new file mode 100644 index 00000000..104891ff --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-lin-srgb.d.ts @@ -0,0 +1,7 @@ +import type { Color } from 'types/color'; +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function XYZ_to_lin_sRGB(XYZ: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-oklab.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-oklab.d.ts new file mode 100644 index 00000000..5d190539 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-oklab.d.ts @@ -0,0 +1,10 @@ +import type { Color } from 'types/color'; +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * XYZ <-> LMS matrices recalculated for consistent reference white + * @see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484 + */ +export declare function XYZ_to_OKLab(XYZ: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-uv.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-uv.d.ts new file mode 100644 index 00000000..ab9a978e --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-uv.d.ts @@ -0,0 +1,11 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of three XYZ values to u*,v* chromaticity coordinates + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */ +export declare function XYZ_to_uv(XYZ: Color): [number, number]; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-xy.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-xy.d.ts new file mode 100644 index 00000000..ab662176 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/xyz-to-xy.d.ts @@ -0,0 +1,11 @@ +import type { Color } from 'types/color'; +/** + * Convert an array of three XYZ values to x,y chromaticity coordinates + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */ +export declare function XYZ_to_xy(XYZ: Color): [number, number]; diff --git a/node_modules/@csstools/color-helpers/dist/conversions/xyz/index.d.ts b/node_modules/@csstools/color-helpers/dist/conversions/xyz/index.d.ts new file mode 100644 index 00000000..f9e446f5 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/conversions/xyz/index.d.ts @@ -0,0 +1,253 @@ +import type { Color } from 'types/color'; +/** + * @param {Color} color [r, g, b] + * - Red as number 0..1; + * - Green as number 0..1; + * - Blue as number 0..1; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function sRGB_to_XYZ_D50(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} sRGB [r, g, b] + * - Red as number 0..1; + * - Green as number 0..1; + * - Blue as number 0..1; + */ +export declare function XYZ_D50_to_sRGB(x: Color): Color; +/** + * @param {Color} color [h, s, l] + * - Hue as degrees 0..360; + * - Saturation as number 0..100; + * - Lightness as number 0..100; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function HSL_to_XYZ_D50(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} HSL [r, g, b] + * - Hue as degrees 0..360; + * - Saturation as number 0..100; + * - Lightness as number 0..100; + */ +export declare function XYZ_D50_to_HSL(x: Color): Color; +/** + * @param {Color} color [h, w, b] + * - Hue as degrees 0..360; + * - Whiteness as number 0..100; + * - Blackness as number 0..100; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function HWB_to_XYZ_D50(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} HWB [r, g, b] + * - Hue as degrees 0..360; + * - Whiteness as number 0..100; + * - Blackness as number 0..100; + */ +export declare function XYZ_D50_to_HWB(x: Color): Color; +/** + * @param {Color} color [l, a, b] + * - Lightness as number 0..100; + * - a as number -160..160; + * - b as number -160..160; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function Lab_to_XYZ_D50(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} Lab [r, g, b] + * - Lightness as number 0..100; + * - a as number -160..160; + * - b as number -160..160; + */ +export declare function XYZ_D50_to_Lab(x: Color): Color; +/** + * @param {Color} color [l, c, h] + * - Lightness as number 0..100; + * - Chroma as number 0..230; + * - Hue as degrees 0..360; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function LCH_to_XYZ_D50(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} LCH [r, g, b] + * - Lightness as number 0..100; + * - Chroma as number 0..230; + * - Hue as degrees 0..360; + */ +export declare function XYZ_D50_to_LCH(x: Color): Color; +/** + * @param {Color} color [l, a, b] + * - Lightness as number 0..1; + * - a as number 0..0.5; + * - b as number 0..0.5; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function OKLab_to_XYZ_D50(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} OKLab [r, g, b] + * - Lightness as number 0..1; + * - a as number 0..0.5; + * - b as number 0..0.5; + */ +export declare function XYZ_D50_to_OKLab(x: Color): Color; +/** + * @param {Color} color [l, c, h] + * - Lightness as number 0..1; + * - Chroma as number 0..0.5; + * - Hue as degrees 0..360; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function OKLCH_to_XYZ_D50(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} OKLCH [r, g, b] + * - Lightness as number 0..1; + * - Chroma as number 0..0.5; + * - Hue as degrees 0..360; + */ +export declare function XYZ_D50_to_OKLCH(x: Color): Color; +/** + * @param {Color} color [r, g, b] + * - Red as number 0..1; + * - Green as number 0..1; + * - Blue as number 0..1; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function lin_sRGB_to_XYZ_D50(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} linear sRGB [r, g, b] + * - Red as number 0..1; + * - Green as number 0..1; + * - Blue as number 0..1; + */ +export declare function XYZ_D50_to_lin_sRGB(x: Color): Color; +/** + * @param {Color} color [r, g, b] + * - Red as number 0..1; + * - Green as number 0..1; + * - Blue as number 0..1; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function a98_RGB_to_XYZ_D50(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} a98 sRGB [r, g, b] + * - Red as number 0..1; + * - Green as number 0..1; + * - Blue as number 0..1; + */ +export declare function XYZ_D50_to_a98_RGB(x: Color): Color; +/** + * @param {Color} color [r, g, b] + * - Red as number 0..1; + * - Green as number 0..1; + * - Blue as number 0..1; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function P3_to_XYZ_D50(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} P3 [r, g, b] + * - R as number 0..1; + * - G as number 0..1; + * - B as number 0..1; + */ +export declare function XYZ_D50_to_P3(x: Color): Color; +/** + * @param {Color} color [r, g, b] + * - Red as number 0..1; + * - Green as number 0..1; + * - Blue as number 0..1; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function rec_2020_to_XYZ_D50(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} rec 2020 [r, g, b] + * - Red as number 0..1; + * - Green as number 0..1; + * - Blue as number 0..1; + */ +export declare function XYZ_D50_to_rec_2020(x: Color): Color; +/** + * @param {Color} color [r, g, b] + * - Red as number 0..1; + * - Green as number 0..1; + * - Blue as number 0..1; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function ProPhoto_RGB_to_XYZ_D50(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} ProPhoto [r, g, b] + * - Red as number 0..1; + * - Green as number 0..1; + * - Blue as number 0..1; + */ +export declare function XYZ_D50_to_ProPhoto(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function XYZ_D65_to_XYZ_D50(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} D65 XYZ [x, y, z] + */ +export declare function XYZ_D50_to_XYZ_D65(x: Color): Color; +/** + * @param {Color} color [x, y, z] + * - X as number 0..1; + * - Y as number 0..1; + * - Z as number 0..1; + * @return {Color} D50 XYZ [x, y, z] + */ +export declare function XYZ_D50_to_XYZ_D50(x: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/index.cjs b/node_modules/@csstools/color-helpers/dist/index.cjs new file mode 100644 index 00000000..cf3e4310 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/index.cjs @@ -0,0 +1,388 @@ +"use strict"; +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/map-gamut.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function clip(t){return t.map((t=>t<0?0:t>1?1:t))} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js + */function OKLCH_to_OKLab(t){return[t[0],t[1]*Math.cos(t[2]*Math.PI/180),t[1]*Math.sin(t[2]*Math.PI/180)]} +/** + * @description Calculate deltaE OK which is the simple root sum of squares + * @param {number[]} reference - Array of OKLab values: L as 0..1, a and b as -1..1 + * @param {number[]} sample - Array of OKLab values: L as 0..1, a and b as -1..1 + * @return {number} How different a color sample is from reference + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/deltaEOK.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/deltaEOK.js + */function deltaEOK(t,_){const[o,n,r]=t,[e,a,i]=_,l=o-e,u=n-a,c=r-i;return Math.sqrt(l**2+u**2+c**2)} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/map-gamut.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function inGamut(t){const[_,o,n]=t;return _>=-1e-4&&_<=1.0001&&o>=-1e-4&&o<=1.0001&&n>=-1e-4&&n<=1.0001}var t=Object.freeze({__proto__:null,clip:clip,inGamut:inGamut});const _=.02,o=1e-5;function binarySearchGamut(t,n,r){const e=t;let a=0,i=e[1];for(;i-a>o;){const t=(a+i)/2;e[1]=t;const o=n(e);if(inGamut(o)){a=t;continue}const l=clip(o);if(deltaEOK(OKLCH_to_OKLab(r(l)),OKLCH_to_OKLab(e))<_)return l;i=t}return clip(n([...e]))} +/** + * Convert an array of of sRGB values where in-gamut values are in the range + * [0 - 1] to linear light (un-companded) form. + * Extended transfer function: + * For negative values, linear portion is extended on reflection of axis, + * then reflected power function is used. + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://en.wikipedia.org/wiki/SRGB + */ +function lin_sRGB(t){return t.map((function(t){const _=t<0?-1:1,o=Math.abs(t);return o<.04045?t/12.92:_*Math.pow((o+.055)/1.055,2.4)}))} +/** + * Simple matrix (and vector) multiplication + * Warning: No error handling for incompatible dimensions! + * @author Lea Verou 2020 MIT License + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/multiply-matrices.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/multiply-matrices.js + */function multiplyMatrices(t,_){const o=t.length;let n,r;n=Array.isArray(t[0])?t:[t],r=Array.isArray(_[0])?_:_.map((t=>[t]));const e=r[0].length,a=r[0].map(((t,_)=>r.map((t=>t[_]))));let i=n.map((t=>a.map((_=>Array.isArray(t)?t.reduce(((t,o,n)=>t+o*(_[n]||0)),0):_.reduce(((_,o)=>_+o*t),0)))));return 1===o&&(i=i[0]),1===e?i.map((t=>t[0])):i} +/** + * Convert an array of linear-light sRGB values to CIE XYZ + * using sRGB's own white, D65 (no chromatic adaptation) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function lin_sRGB_to_XYZ(t){return multiplyMatrices([[506752/1228815,87881/245763,12673/70218],[87098/409605,175762/245763,12673/175545],[7918/409605,87881/737289,1001167/1053270]],t)} +/** + * Convert an array of gamma-corrected sRGB values in the 0.0 to 1.0 range + * to linear-light sRGB, then to CIE XYZ and return luminance (the Y value) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */function sRGB_to_luminance(t){return lin_sRGB_to_XYZ(lin_sRGB(t))[1]} +/** + * Return WCAG 2.1 contrast ratio for two sRGB values given as arrays + * + * of 0.0 to 1.0 + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + * @see https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio + */var n=Object.freeze({__proto__:null,binarySearchGamut:binarySearchGamut,contrast:function contrast(t,_){const o=sRGB_to_luminance(t),n=sRGB_to_luminance(_);return o>n?(o+.05)/(n+.05):(n+.05)/(o+.05)},deltaEOK:deltaEOK,mapGamut:function mapGamut(t,_,o){return binarySearchGamut(t,_,o)},multiplyMatrices:multiplyMatrices});const r=[.3457/.3585,1,.2958/.3585]; +/** + * Bradford chromatic adaptation from D50 to D65 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +function D50_to_D65(t){return multiplyMatrices([[.9554734527042182,-.023098536874261423,.0632593086610217],[-.028369706963208136,1.0099954580058226,.021041398966943008],[.012314001688319899,-.020507696433477912,1.3303659366080753]],t)} +/** + * Bradford chromatic adaptation from D65 to D50 + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html + */function D65_to_D50(t){return multiplyMatrices([[1.0479298208405488,.022946793341019088,-.05019222954313557],[.029627815688159344,.990434484573249,-.01707382502938514],[-.009243058152591178,.015055144896577895,.7518742899580008]],t)} +/** + * Convert an array of linear-light rec2020 RGB in the range 0.0-1.0 + * to gamma corrected form ITU-R BT.2020-2 p.4 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function gam_2020(t){const _=1.09929682680944;return t.map((function(t){const o=t<0?-1:1,n=Math.abs(t);return n>.018053968510807?o*(_*Math.pow(n,.45)-(_-1)):4.5*t}))} +/** + * Convert an array of linear-light a98-rgb in the range 0.0-1.0 + * to gamma corrected form. Negative values are also now accepted + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function gam_a98rgb(t){return t.map((function(t){const _=t<0?-1:1,o=Math.abs(t);return _*Math.pow(o,256/563)}))} +/** + * Convert an array of linear-light sRGB values in the range 0.0-1.0 to gamma corrected form + * Extended transfer function: + * For negative values, linear portion extends on reflection + * of axis, then uses reflected pow below that + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://en.wikipedia.org/wiki/SRGB + */function gam_sRGB(t){return t.map((function(t){const _=t<0?-1:1,o=Math.abs(t);return o>.0031308?_*(1.055*Math.pow(o,1/2.4)-.055):12.92*t}))} +/** + * Convert an array of linear-light display-p3 RGB in the range 0.0-1.0 + * to gamma corrected form + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function gam_P3(t){return gam_sRGB(t)} +/** + * Convert an array of linear-light prophoto-rgb in the range 0.0-1.0 + * to gamma corrected form. + * Transfer curve is gamma 1.8 with a small linear portion. + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function gam_ProPhoto(t){return t.map((function(t){const _=t<0?-1:1,o=Math.abs(t);return o>=.001953125?_*Math.pow(o,1/1.8):16*t}))} +/** + * @param {number} hue - Hue as degrees 0..360 + * @param {number} sat - Saturation as percentage 0..100 + * @param {number} light - Lightness as percentage 0..100 + * @return {number[]} Array of RGB components 0..1 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js + */function HSL_to_sRGB(t){let _=t[0],o=t[1],n=t[2];function f(t){const r=(t+_/30)%12,e=o*Math.min(n,1-n);return n-e*Math.max(-1,Math.min(r-3,9-r,1))}return _%=360,_<0&&(_+=360),o/=100,n/=100,[f(0),f(8),f(4)]} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */ +/** + * @param {number} hue - Hue as degrees 0..360 + * @param {number} white - Whiteness as percentage 0..100 + * @param {number} black - Blackness as percentage 0..100 + * @return {number[]} Array of RGB components 0..1 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js + */ +function HWB_to_sRGB(t){const _=t[0];let o=t[1],n=t[2];if(o/=100,n/=100,o+n>=1){const t=o/(o+n);return[t,t,t]}const r=HSL_to_sRGB([_,100,50]);for(let t=0;t<3;t++)r[t]*=1-o-n,r[t]+=o;return r} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function Lab_to_LCH(t){const _=180*Math.atan2(t[2],t[1])/Math.PI;return[t[0],Math.sqrt(Math.pow(t[1],2)+Math.pow(t[2],2)),_>=0?_:_+360]} +/** + * Convert Lab to D50-adapted XYZ + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */function Lab_to_XYZ(t){const _=24389/27,o=216/24389,n=[];n[1]=(t[0]+16)/116,n[0]=t[1]/500+n[1],n[2]=n[1]-t[2]/200;return[Math.pow(n[0],3)>o?Math.pow(n[0],3):(116*n[0]-16)/_,t[0]>8?Math.pow((t[0]+16)/116,3):t[0]/_,Math.pow(n[2],3)>o?Math.pow(n[2],3):(116*n[2]-16)/_].map(((t,_)=>t*r[_]))} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function LCH_to_Lab(t){return[t[0],t[1]*Math.cos(t[2]*Math.PI/180),t[1]*Math.sin(t[2]*Math.PI/180)]} +/** + * Convert an array of rec2020 RGB values in the range 0.0 - 1.0 + * to linear light (un-companded) form. + * ITU-R BT.2020-2 p.4 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function lin_2020(t){const _=1.09929682680944;return t.map((function(t){const o=t<0?-1:1,n=Math.abs(t);return n<.08124285829863151?t/4.5:o*Math.pow((n+_-1)/_,1/.45)}))} +/** + * Convert an array of linear-light rec2020 values to CIE XYZ + * using D65 (no chromatic adaptation) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */function lin_2020_to_XYZ(t){return multiplyMatrices([[63426534/99577255,20160776/139408157,47086771/278816314],[26158966/99577255,.677998071518871,8267143/139408157],[0,19567812/697040785,1.0609850577107909]],t)} +/** + * Convert an array of a98-rgb values in the range 0.0 - 1.0 + * to linear light (un-companded) form. Negative values are also now accepted + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function lin_a98rgb(t){return t.map((function(t){const _=t<0?-1:1,o=Math.abs(t);return _*Math.pow(o,563/256)}))} +/** + * Convert an array of linear-light a98-rgb values to CIE XYZ + * http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + * has greater numerical precision than section 4.3.5.3 of + * https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf + * but the values below were calculated from first principles + * from the chromaticity coordinates of R G B W + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + * @see https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/matrixmaker.html + */function lin_a98rgb_to_XYZ(t){return multiplyMatrices([[573536/994567,263643/1420810,187206/994567],[591459/1989134,6239551/9945670,374412/4972835],[53769/1989134,351524/4972835,4929758/4972835]],t)} +/** + * Convert an array of display-p3 RGB values in the range 0.0 - 1.0 + * to linear light (un-companded) form. + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function lin_P3(t){return lin_sRGB(t)} +/** + * Convert an array of linear-light display-p3 values to CIE XYZ + * using D65 (no chromatic adaptation) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */function lin_P3_to_XYZ(t){return multiplyMatrices([[608311/1250200,189793/714400,198249/1000160],[35783/156275,247089/357200,198249/2500400],[0,32229/714400,5220557/5000800]],t)} +/** + * Convert an array of prophoto-rgb values where in-gamut Colors are in the + * range [0.0 - 1.0] to linear light (un-companded) form. Transfer curve is + * gamma 1.8 with a small linear portion. Extended transfer function + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function lin_ProPhoto(t){return t.map((function(t){const _=t<0?-1:1,o=Math.abs(t);return o<=.03125?t/16:_*Math.pow(o,1.8)}))} +/** + * Convert an array of linear-light prophoto-rgb values to CIE XYZ + * using D50 (so no chromatic adaptation needed afterwards) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */function lin_ProPhoto_to_XYZ(t){return multiplyMatrices([[.7977604896723027,.13518583717574031,.0313493495815248],[.2880711282292934,.7118432178101014,8565396060525902e-20],[0,0,.8251046025104601]],t)} +/** + * CMYK is an array of four values in the range [0.0, 1.0] the output is an + * array of [RGB] also in the [0.0, 1.0] range because the naive algorithm + * does not generate out of gamut colors neither does it generate accurate + * simulations of practical CMYK colors + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */ +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js + */ +function OKLab_to_OKLCH(t){const _=180*Math.atan2(t[2],t[1])/Math.PI;return[t[0],Math.sqrt(t[1]**2+t[2]**2),_>=0?_:_+360]} +/** + * Given OKLab, convert to XYZ relative to D65 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js + */function OKLab_to_XYZ(t){const _=multiplyMatrices([[.9999999984505198,.39633779217376786,.2158037580607588],[1.0000000088817609,-.10556134232365635,-.06385417477170591],[1.0000000546724108,-.08948418209496575,-1.2914855378640917]],t);return multiplyMatrices([[1.2268798733741557,-.5578149965554813,.28139105017721583],[-.04057576262431372,1.1122868293970594,-.07171106666151701],[-.07637294974672142,-.4214933239627914,1.5869240244272418]],_.map((t=>t**3)))} +/** + * Convert an array of gamma-corrected sRGB values in the 0.0 to 1.0 range to HSL. + * + * @param {Color} RGB [r, g, b] + * - Red component 0..1 + * - Green component 0..1 + * - Blue component 0..1 + * @return {number[]} Array of HSL values: Hue as degrees 0..360, Saturation and Lightness as percentages 0..100 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/rgbToHsl.js + */function sRGB_to_HSL(t){const _=t[0],o=t[1],n=t[2],r=Math.max(_,o,n),e=Math.min(_,o,n),a=(e+r)/2,i=r-e;let l=NaN,u=0;if(0!==Math.round(1e5*i)){switch(u=0===Math.round(1e5*a)||1e5===Math.round(1e5*a)?0:(r-a)/Math.min(a,1-a),r){case _:l=(o-n)/i+(o<n?6:0);break;case o:l=(n-_)/i+2;break;case n:l=(_-o)/i+4}l*=60}return[l,100*u,100*a]} +/** + * Assuming XYZ is relative to D50, convert to CIE Lab + * from CIE standard, which now defines these as a rational fraction + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +function XYZ_to_Lab(t){const _=t.map(((t,_)=>t/r[_])).map((t=>t>.008856451679035631?Math.cbrt(t):(903.2962962962963*t+16)/116));return[116*_[1]-16,500*(_[0]-_[1]),200*(_[1]-_[2])]} +/** + * Convert XYZ to linear-light rec2020 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function XYZ_to_lin_2020(t){return multiplyMatrices([[30757411/17917100,-6372589/17917100,-4539589/17917100],[-.666684351832489,1.616481236634939,467509/29648200],[792561/44930125,-1921689/44930125,.942103121235474]],t)} +/** + * Convert XYZ to linear-light a98-rgb + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function XYZ_to_lin_a98rgb(t){return multiplyMatrices([[1829569/896150,-506331/896150,-308931/896150],[-851781/878810,1648619/878810,36519/878810],[16779/1248040,-147721/1248040,1266979/1248040]],t)} +/** + * Convert XYZ to linear-light P3 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function XYZ_to_lin_P3(t){return multiplyMatrices([[446124/178915,-333277/357830,-72051/178915],[-14852/17905,63121/35810,423/17905],[11844/330415,-50337/660830,316169/330415]],t)} +/** + * Convert XYZ to linear-light prophoto-rgb + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */function XYZ_to_lin_ProPhoto(t){return multiplyMatrices([[1.3457989731028281,-.25558010007997534,-.05110628506753401],[-.5446224939028347,1.5082327413132781,.02053603239147973],[0,0,1.2119675456389454]],t)} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function XYZ_to_lin_sRGB(t){return multiplyMatrices([[12831/3959,-329/214,-1974/3959],[-851781/878810,1648619/878810,36519/878810],[705/12673,-2585/12673,705/667]],t)} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * XYZ <-> LMS matrices recalculated for consistent reference white + * @see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484 + */function XYZ_to_OKLab(t){const _=multiplyMatrices([[.8190224432164319,.3619062562801221,-.12887378261216414],[.0329836671980271,.9292868468965546,.03614466816999844],[.048177199566046255,.26423952494422764,.6335478258136937]],t);return multiplyMatrices([[.2104542553,.793617785,-.0040720468],[1.9779984951,-2.428592205,.4505937099],[.0259040371,.7827717662,-.808675766]],_.map((t=>Math.cbrt(t))))} +/** + * Convert an array of three XYZ values to u*,v* chromaticity coordinates + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */var e=Object.freeze({__proto__:null,D50:r,D50_to_D65:D50_to_D65,D65:[.3127/.329,1,.3583/.329],D65_to_D50:D65_to_D50,HSL_to_sRGB:HSL_to_sRGB,HWB_to_sRGB:HWB_to_sRGB,LCH_to_Lab:LCH_to_Lab,Lab_to_LCH:Lab_to_LCH,Lab_to_XYZ:Lab_to_XYZ,OKLCH_to_OKLab:OKLCH_to_OKLab,OKLab_to_OKLCH:OKLab_to_OKLCH,OKLab_to_XYZ:OKLab_to_XYZ,XYZ_to_Lab:XYZ_to_Lab,XYZ_to_OKLab:XYZ_to_OKLab,XYZ_to_lin_2020:XYZ_to_lin_2020,XYZ_to_lin_P3:XYZ_to_lin_P3,XYZ_to_lin_ProPhoto:XYZ_to_lin_ProPhoto,XYZ_to_lin_a98rgb:XYZ_to_lin_a98rgb,XYZ_to_lin_sRGB:XYZ_to_lin_sRGB,XYZ_to_uv:function XYZ_to_uv(t){const _=t[0],o=t[1],n=_+15*o+3*t[2];return[4*_/n,9*o/n]} +/** + * Convert an array of three XYZ values to x,y chromaticity coordinates + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */,XYZ_to_xy:function XYZ_to_xy(t){const _=t[0],o=t[1],n=_+o+t[2];return[_/n,o/n]},gam_2020:gam_2020,gam_P3:gam_P3,gam_ProPhoto:gam_ProPhoto,gam_a98rgb:gam_a98rgb,gam_sRGB:gam_sRGB,hueToRGB:function hueToRGB(t,_,o){return o<0&&(o+=6),o>=6&&(o-=6),o<1?(_-t)*o+t:o<3?_:o<4?(_-t)*(4-o)+t:t},lin_2020:lin_2020,lin_2020_to_XYZ:lin_2020_to_XYZ,lin_P3:lin_P3,lin_P3_to_XYZ:lin_P3_to_XYZ,lin_ProPhoto:lin_ProPhoto,lin_ProPhoto_to_XYZ:lin_ProPhoto_to_XYZ,lin_a98rgb:lin_a98rgb,lin_a98rgb_to_XYZ:lin_a98rgb_to_XYZ,lin_sRGB:lin_sRGB,lin_sRGB_to_XYZ:lin_sRGB_to_XYZ,naive_CMYK_to_sRGB:function naive_CMYK_to_sRGB(t){const _=t[0],o=t[1],n=t[2],r=t[3];return[1-Math.min(1,_*(1-r)+r),1-Math.min(1,o*(1-r)+r),1-Math.min(1,n*(1-r)+r)]},sRGB_to_HSL:sRGB_to_HSL,sRGB_to_HWB:function sRGB_to_HWB(t){const _=sRGB_to_HSL(t),o=Math.min(t[0],t[1],t[2]),n=1-Math.max(t[0],t[1],t[2]);return[_[0],100*o,100*n]},sRGB_to_luminance:sRGB_to_luminance});var a=Object.freeze({__proto__:null,HSL_to_XYZ_D50:function HSL_to_XYZ_D50(t){let _=t;return _=HSL_to_sRGB(_),_=lin_sRGB(_),_=lin_sRGB_to_XYZ(_),_=D65_to_D50(_),_},HWB_to_XYZ_D50:function HWB_to_XYZ_D50(t){let _=t;return _=HWB_to_sRGB(_),_=lin_sRGB(_),_=lin_sRGB_to_XYZ(_),_=D65_to_D50(_),_},LCH_to_XYZ_D50:function LCH_to_XYZ_D50(t){let _=t;return _=LCH_to_Lab(_),_=Lab_to_XYZ(_),_},Lab_to_XYZ_D50:function Lab_to_XYZ_D50(t){let _=t;return _=Lab_to_XYZ(_),_},OKLCH_to_XYZ_D50:function OKLCH_to_XYZ_D50(t){let _=t;return _=OKLCH_to_OKLab(_),_=OKLab_to_XYZ(_),_=D65_to_D50(_),_},OKLab_to_XYZ_D50:function OKLab_to_XYZ_D50(t){let _=t;return _=OKLab_to_XYZ(_),_=D65_to_D50(_),_},P3_to_XYZ_D50:function P3_to_XYZ_D50(t){let _=t;return _=lin_P3(_),_=lin_P3_to_XYZ(_),_=D65_to_D50(_),_},ProPhoto_RGB_to_XYZ_D50:function ProPhoto_RGB_to_XYZ_D50(t){let _=t;return _=lin_ProPhoto(_),_=lin_ProPhoto_to_XYZ(_),_},XYZ_D50_to_HSL:function XYZ_D50_to_HSL(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_sRGB(_),_=gam_sRGB(_),_=sRGB_to_HSL(_),_},XYZ_D50_to_HWB:function XYZ_D50_to_HWB(t){let _=t;_=D50_to_D65(_),_=XYZ_to_lin_sRGB(_);const o=gam_sRGB(_);_=sRGB_to_HSL(o);const n=Math.min(o[0],o[1],o[2]),r=1-Math.max(o[0],o[1],o[2]);return[_[0],100*n,100*r]},XYZ_D50_to_LCH:function XYZ_D50_to_LCH(t){let _=t;return _=XYZ_to_Lab(_),_=Lab_to_LCH(_),_},XYZ_D50_to_Lab:function XYZ_D50_to_Lab(t){let _=t;return _=XYZ_to_Lab(_),_},XYZ_D50_to_OKLCH:function XYZ_D50_to_OKLCH(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_OKLab(_),_=OKLab_to_OKLCH(_),_},XYZ_D50_to_OKLab:function XYZ_D50_to_OKLab(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_OKLab(_),_},XYZ_D50_to_P3:function XYZ_D50_to_P3(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_P3(_),_=gam_P3(_),_},XYZ_D50_to_ProPhoto:function XYZ_D50_to_ProPhoto(t){let _=t;return _=XYZ_to_lin_ProPhoto(_),_=gam_ProPhoto(_),_},XYZ_D50_to_XYZ_D50:function XYZ_D50_to_XYZ_D50(t){return t},XYZ_D50_to_XYZ_D65:function XYZ_D50_to_XYZ_D65(t){let _=t;return _=D50_to_D65(_),_},XYZ_D50_to_a98_RGB:function XYZ_D50_to_a98_RGB(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_a98rgb(_),_=gam_a98rgb(_),_},XYZ_D50_to_lin_sRGB:function XYZ_D50_to_lin_sRGB(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_sRGB(_),_},XYZ_D50_to_rec_2020:function XYZ_D50_to_rec_2020(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_2020(_),_=gam_2020(_),_},XYZ_D50_to_sRGB:function XYZ_D50_to_sRGB(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_sRGB(_),_=gam_sRGB(_),_},XYZ_D65_to_XYZ_D50:function XYZ_D65_to_XYZ_D50(t){let _=t;return _=D65_to_D50(_),_},a98_RGB_to_XYZ_D50:function a98_RGB_to_XYZ_D50(t){let _=t;return _=lin_a98rgb(_),_=lin_a98rgb_to_XYZ(_),_=D65_to_D50(_),_},lin_sRGB_to_XYZ_D50:function lin_sRGB_to_XYZ_D50(t){let _=t;return _=lin_sRGB_to_XYZ(_),_=D65_to_D50(_),_},rec_2020_to_XYZ_D50:function rec_2020_to_XYZ_D50(t){let _=t;return _=lin_2020(_),_=lin_2020_to_XYZ(_),_=D65_to_D50(_),_},sRGB_to_XYZ_D50:function sRGB_to_XYZ_D50(t){let _=t;return _=lin_sRGB(_),_=lin_sRGB_to_XYZ(_),_=D65_to_D50(_),_}});exports.calculations=n,exports.conversions=e,exports.namedColors={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},exports.utils=t,exports.xyz=a; diff --git a/node_modules/@csstools/color-helpers/dist/index.d.ts b/node_modules/@csstools/color-helpers/dist/index.d.ts new file mode 100644 index 00000000..15af8c66 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/index.d.ts @@ -0,0 +1,6 @@ +export * as calculations from './calculations'; +export * as conversions from './conversions'; +export * as utils from './utils'; +export * as xyz from './conversions/xyz'; +export type { Color } from './types/color'; +export { namedColors } from './named-colors'; diff --git a/node_modules/@csstools/color-helpers/dist/index.mjs b/node_modules/@csstools/color-helpers/dist/index.mjs new file mode 100644 index 00000000..9a1bb789 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/index.mjs @@ -0,0 +1,388 @@ +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/map-gamut.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +function clip(t){return t.map((t=>t<0?0:t>1?1:t))} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js + */function OKLCH_to_OKLab(t){return[t[0],t[1]*Math.cos(t[2]*Math.PI/180),t[1]*Math.sin(t[2]*Math.PI/180)]} +/** + * @description Calculate deltaE OK which is the simple root sum of squares + * @param {number[]} reference - Array of OKLab values: L as 0..1, a and b as -1..1 + * @param {number[]} sample - Array of OKLab values: L as 0..1, a and b as -1..1 + * @return {number} How different a color sample is from reference + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/deltaEOK.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/deltaEOK.js + */function deltaEOK(t,_){const[o,n,r]=t,[e,a,i]=_,l=o-e,u=n-a,c=r-i;return Math.sqrt(l**2+u**2+c**2)} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/map-gamut.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function inGamut(t){const[_,o,n]=t;return _>=-1e-4&&_<=1.0001&&o>=-1e-4&&o<=1.0001&&n>=-1e-4&&n<=1.0001}var t=Object.freeze({__proto__:null,clip:clip,inGamut:inGamut});const _=.02,o=1e-5;function binarySearchGamut(t,n,r){const e=t;let a=0,i=e[1];for(;i-a>o;){const t=(a+i)/2;e[1]=t;const o=n(e);if(inGamut(o)){a=t;continue}const l=clip(o);if(deltaEOK(OKLCH_to_OKLab(r(l)),OKLCH_to_OKLab(e))<_)return l;i=t}return clip(n([...e]))} +/** + * Convert an array of of sRGB values where in-gamut values are in the range + * [0 - 1] to linear light (un-companded) form. + * Extended transfer function: + * For negative values, linear portion is extended on reflection of axis, + * then reflected power function is used. + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://en.wikipedia.org/wiki/SRGB + */ +function lin_sRGB(t){return t.map((function(t){const _=t<0?-1:1,o=Math.abs(t);return o<.04045?t/12.92:_*Math.pow((o+.055)/1.055,2.4)}))} +/** + * Simple matrix (and vector) multiplication + * Warning: No error handling for incompatible dimensions! + * @author Lea Verou 2020 MIT License + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/multiply-matrices.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/multiply-matrices.js + */function multiplyMatrices(t,_){const o=t.length;let n,r;n=Array.isArray(t[0])?t:[t],r=Array.isArray(_[0])?_:_.map((t=>[t]));const e=r[0].length,a=r[0].map(((t,_)=>r.map((t=>t[_]))));let i=n.map((t=>a.map((_=>Array.isArray(t)?t.reduce(((t,o,n)=>t+o*(_[n]||0)),0):_.reduce(((_,o)=>_+o*t),0)))));return 1===o&&(i=i[0]),1===e?i.map((t=>t[0])):i} +/** + * Convert an array of linear-light sRGB values to CIE XYZ + * using sRGB's own white, D65 (no chromatic adaptation) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function lin_sRGB_to_XYZ(t){return multiplyMatrices([[506752/1228815,87881/245763,12673/70218],[87098/409605,175762/245763,12673/175545],[7918/409605,87881/737289,1001167/1053270]],t)} +/** + * Convert an array of gamma-corrected sRGB values in the 0.0 to 1.0 range + * to linear-light sRGB, then to CIE XYZ and return luminance (the Y value) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */function sRGB_to_luminance(t){return lin_sRGB_to_XYZ(lin_sRGB(t))[1]} +/** + * Return WCAG 2.1 contrast ratio for two sRGB values given as arrays + * + * of 0.0 to 1.0 + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + * @see https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio + */var n=Object.freeze({__proto__:null,binarySearchGamut:binarySearchGamut,contrast:function contrast(t,_){const o=sRGB_to_luminance(t),n=sRGB_to_luminance(_);return o>n?(o+.05)/(n+.05):(n+.05)/(o+.05)},deltaEOK:deltaEOK,mapGamut:function mapGamut(t,_,o){return binarySearchGamut(t,_,o)},multiplyMatrices:multiplyMatrices});const r=[.3457/.3585,1,.2958/.3585]; +/** + * Bradford chromatic adaptation from D50 to D65 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +function D50_to_D65(t){return multiplyMatrices([[.9554734527042182,-.023098536874261423,.0632593086610217],[-.028369706963208136,1.0099954580058226,.021041398966943008],[.012314001688319899,-.020507696433477912,1.3303659366080753]],t)} +/** + * Bradford chromatic adaptation from D65 to D50 + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html + */function D65_to_D50(t){return multiplyMatrices([[1.0479298208405488,.022946793341019088,-.05019222954313557],[.029627815688159344,.990434484573249,-.01707382502938514],[-.009243058152591178,.015055144896577895,.7518742899580008]],t)} +/** + * Convert an array of linear-light rec2020 RGB in the range 0.0-1.0 + * to gamma corrected form ITU-R BT.2020-2 p.4 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function gam_2020(t){const _=1.09929682680944;return t.map((function(t){const o=t<0?-1:1,n=Math.abs(t);return n>.018053968510807?o*(_*Math.pow(n,.45)-(_-1)):4.5*t}))} +/** + * Convert an array of linear-light a98-rgb in the range 0.0-1.0 + * to gamma corrected form. Negative values are also now accepted + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function gam_a98rgb(t){return t.map((function(t){const _=t<0?-1:1,o=Math.abs(t);return _*Math.pow(o,256/563)}))} +/** + * Convert an array of linear-light sRGB values in the range 0.0-1.0 to gamma corrected form + * Extended transfer function: + * For negative values, linear portion extends on reflection + * of axis, then uses reflected pow below that + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://en.wikipedia.org/wiki/SRGB + */function gam_sRGB(t){return t.map((function(t){const _=t<0?-1:1,o=Math.abs(t);return o>.0031308?_*(1.055*Math.pow(o,1/2.4)-.055):12.92*t}))} +/** + * Convert an array of linear-light display-p3 RGB in the range 0.0-1.0 + * to gamma corrected form + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function gam_P3(t){return gam_sRGB(t)} +/** + * Convert an array of linear-light prophoto-rgb in the range 0.0-1.0 + * to gamma corrected form. + * Transfer curve is gamma 1.8 with a small linear portion. + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function gam_ProPhoto(t){return t.map((function(t){const _=t<0?-1:1,o=Math.abs(t);return o>=.001953125?_*Math.pow(o,1/1.8):16*t}))} +/** + * @param {number} hue - Hue as degrees 0..360 + * @param {number} sat - Saturation as percentage 0..100 + * @param {number} light - Lightness as percentage 0..100 + * @return {number[]} Array of RGB components 0..1 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js + */function HSL_to_sRGB(t){let _=t[0],o=t[1],n=t[2];function f(t){const r=(t+_/30)%12,e=o*Math.min(n,1-n);return n-e*Math.max(-1,Math.min(r-3,9-r,1))}return _%=360,_<0&&(_+=360),o/=100,n/=100,[f(0),f(8),f(4)]} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */ +/** + * @param {number} hue - Hue as degrees 0..360 + * @param {number} white - Whiteness as percentage 0..100 + * @param {number} black - Blackness as percentage 0..100 + * @return {number[]} Array of RGB components 0..1 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js + */ +function HWB_to_sRGB(t){const _=t[0];let o=t[1],n=t[2];if(o/=100,n/=100,o+n>=1){const t=o/(o+n);return[t,t,t]}const r=HSL_to_sRGB([_,100,50]);for(let t=0;t<3;t++)r[t]*=1-o-n,r[t]+=o;return r} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function Lab_to_LCH(t){const _=180*Math.atan2(t[2],t[1])/Math.PI;return[t[0],Math.sqrt(Math.pow(t[1],2)+Math.pow(t[2],2)),_>=0?_:_+360]} +/** + * Convert Lab to D50-adapted XYZ + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */function Lab_to_XYZ(t){const _=24389/27,o=216/24389,n=[];n[1]=(t[0]+16)/116,n[0]=t[1]/500+n[1],n[2]=n[1]-t[2]/200;return[Math.pow(n[0],3)>o?Math.pow(n[0],3):(116*n[0]-16)/_,t[0]>8?Math.pow((t[0]+16)/116,3):t[0]/_,Math.pow(n[2],3)>o?Math.pow(n[2],3):(116*n[2]-16)/_].map(((t,_)=>t*r[_]))} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function LCH_to_Lab(t){return[t[0],t[1]*Math.cos(t[2]*Math.PI/180),t[1]*Math.sin(t[2]*Math.PI/180)]} +/** + * Convert an array of rec2020 RGB values in the range 0.0 - 1.0 + * to linear light (un-companded) form. + * ITU-R BT.2020-2 p.4 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function lin_2020(t){const _=1.09929682680944;return t.map((function(t){const o=t<0?-1:1,n=Math.abs(t);return n<.08124285829863151?t/4.5:o*Math.pow((n+_-1)/_,1/.45)}))} +/** + * Convert an array of linear-light rec2020 values to CIE XYZ + * using D65 (no chromatic adaptation) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */function lin_2020_to_XYZ(t){return multiplyMatrices([[63426534/99577255,20160776/139408157,47086771/278816314],[26158966/99577255,.677998071518871,8267143/139408157],[0,19567812/697040785,1.0609850577107909]],t)} +/** + * Convert an array of a98-rgb values in the range 0.0 - 1.0 + * to linear light (un-companded) form. Negative values are also now accepted + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function lin_a98rgb(t){return t.map((function(t){const _=t<0?-1:1,o=Math.abs(t);return _*Math.pow(o,563/256)}))} +/** + * Convert an array of linear-light a98-rgb values to CIE XYZ + * http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + * has greater numerical precision than section 4.3.5.3 of + * https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf + * but the values below were calculated from first principles + * from the chromaticity coordinates of R G B W + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + * @see https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/matrixmaker.html + */function lin_a98rgb_to_XYZ(t){return multiplyMatrices([[573536/994567,263643/1420810,187206/994567],[591459/1989134,6239551/9945670,374412/4972835],[53769/1989134,351524/4972835,4929758/4972835]],t)} +/** + * Convert an array of display-p3 RGB values in the range 0.0 - 1.0 + * to linear light (un-companded) form. + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function lin_P3(t){return lin_sRGB(t)} +/** + * Convert an array of linear-light display-p3 values to CIE XYZ + * using D65 (no chromatic adaptation) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */function lin_P3_to_XYZ(t){return multiplyMatrices([[608311/1250200,189793/714400,198249/1000160],[35783/156275,247089/357200,198249/2500400],[0,32229/714400,5220557/5000800]],t)} +/** + * Convert an array of prophoto-rgb values where in-gamut Colors are in the + * range [0.0 - 1.0] to linear light (un-companded) form. Transfer curve is + * gamma 1.8 with a small linear portion. Extended transfer function + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function lin_ProPhoto(t){return t.map((function(t){const _=t<0?-1:1,o=Math.abs(t);return o<=.03125?t/16:_*Math.pow(o,1.8)}))} +/** + * Convert an array of linear-light prophoto-rgb values to CIE XYZ + * using D50 (so no chromatic adaptation needed afterwards) + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */function lin_ProPhoto_to_XYZ(t){return multiplyMatrices([[.7977604896723027,.13518583717574031,.0313493495815248],[.2880711282292934,.7118432178101014,8565396060525902e-20],[0,0,.8251046025104601]],t)} +/** + * CMYK is an array of four values in the range [0.0, 1.0] the output is an + * array of [RGB] also in the [0.0, 1.0] range because the naive algorithm + * does not generate out of gamut colors neither does it generate accurate + * simulations of practical CMYK colors + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */ +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js + */ +function OKLab_to_OKLCH(t){const _=180*Math.atan2(t[2],t[1])/Math.PI;return[t[0],Math.sqrt(t[1]**2+t[2]**2),_>=0?_:_+360]} +/** + * Given OKLab, convert to XYZ relative to D65 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js + */function OKLab_to_XYZ(t){const _=multiplyMatrices([[.9999999984505198,.39633779217376786,.2158037580607588],[1.0000000088817609,-.10556134232365635,-.06385417477170591],[1.0000000546724108,-.08948418209496575,-1.2914855378640917]],t);return multiplyMatrices([[1.2268798733741557,-.5578149965554813,.28139105017721583],[-.04057576262431372,1.1122868293970594,-.07171106666151701],[-.07637294974672142,-.4214933239627914,1.5869240244272418]],_.map((t=>t**3)))} +/** + * Convert an array of gamma-corrected sRGB values in the 0.0 to 1.0 range to HSL. + * + * @param {Color} RGB [r, g, b] + * - Red component 0..1 + * - Green component 0..1 + * - Blue component 0..1 + * @return {number[]} Array of HSL values: Hue as degrees 0..360, Saturation and Lightness as percentages 0..100 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/rgbToHsl.js + */function sRGB_to_HSL(t){const _=t[0],o=t[1],n=t[2],r=Math.max(_,o,n),e=Math.min(_,o,n),a=(e+r)/2,i=r-e;let l=NaN,u=0;if(0!==Math.round(1e5*i)){switch(u=0===Math.round(1e5*a)||1e5===Math.round(1e5*a)?0:(r-a)/Math.min(a,1-a),r){case _:l=(o-n)/i+(o<n?6:0);break;case o:l=(n-_)/i+2;break;case n:l=(_-o)/i+4}l*=60}return[l,100*u,100*a]} +/** + * Assuming XYZ is relative to D50, convert to CIE Lab + * from CIE standard, which now defines these as a rational fraction + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +function XYZ_to_Lab(t){const _=t.map(((t,_)=>t/r[_])).map((t=>t>.008856451679035631?Math.cbrt(t):(903.2962962962963*t+16)/116));return[116*_[1]-16,500*(_[0]-_[1]),200*(_[1]-_[2])]} +/** + * Convert XYZ to linear-light rec2020 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function XYZ_to_lin_2020(t){return multiplyMatrices([[30757411/17917100,-6372589/17917100,-4539589/17917100],[-.666684351832489,1.616481236634939,467509/29648200],[792561/44930125,-1921689/44930125,.942103121235474]],t)} +/** + * Convert XYZ to linear-light a98-rgb + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function XYZ_to_lin_a98rgb(t){return multiplyMatrices([[1829569/896150,-506331/896150,-308931/896150],[-851781/878810,1648619/878810,36519/878810],[16779/1248040,-147721/1248040,1266979/1248040]],t)} +/** + * Convert XYZ to linear-light P3 + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function XYZ_to_lin_P3(t){return multiplyMatrices([[446124/178915,-333277/357830,-72051/178915],[-14852/17905,63121/35810,423/17905],[11844/330415,-50337/660830,316169/330415]],t)} +/** + * Convert XYZ to linear-light prophoto-rgb + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + */function XYZ_to_lin_ProPhoto(t){return multiplyMatrices([[1.3457989731028281,-.25558010007997534,-.05110628506753401],[-.5446224939028347,1.5082327413132781,.02053603239147973],[0,0,1.2119675456389454]],t)} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */function XYZ_to_lin_sRGB(t){return multiplyMatrices([[12831/3959,-329/214,-1974/3959],[-851781/878810,1648619/878810,36519/878810],[705/12673,-2585/12673,705/667]],t)} +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * XYZ <-> LMS matrices recalculated for consistent reference white + * @see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484 + */function XYZ_to_OKLab(t){const _=multiplyMatrices([[.8190224432164319,.3619062562801221,-.12887378261216414],[.0329836671980271,.9292868468965546,.03614466816999844],[.048177199566046255,.26423952494422764,.6335478258136937]],t);return multiplyMatrices([[.2104542553,.793617785,-.0040720468],[1.9779984951,-2.428592205,.4505937099],[.0259040371,.7827717662,-.808675766]],_.map((t=>Math.cbrt(t))))} +/** + * Convert an array of three XYZ values to u*,v* chromaticity coordinates + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */var e=Object.freeze({__proto__:null,D50:r,D50_to_D65:D50_to_D65,D65:[.3127/.329,1,.3583/.329],D65_to_D50:D65_to_D50,HSL_to_sRGB:HSL_to_sRGB,HWB_to_sRGB:HWB_to_sRGB,LCH_to_Lab:LCH_to_Lab,Lab_to_LCH:Lab_to_LCH,Lab_to_XYZ:Lab_to_XYZ,OKLCH_to_OKLab:OKLCH_to_OKLab,OKLab_to_OKLCH:OKLab_to_OKLCH,OKLab_to_XYZ:OKLab_to_XYZ,XYZ_to_Lab:XYZ_to_Lab,XYZ_to_OKLab:XYZ_to_OKLab,XYZ_to_lin_2020:XYZ_to_lin_2020,XYZ_to_lin_P3:XYZ_to_lin_P3,XYZ_to_lin_ProPhoto:XYZ_to_lin_ProPhoto,XYZ_to_lin_a98rgb:XYZ_to_lin_a98rgb,XYZ_to_lin_sRGB:XYZ_to_lin_sRGB,XYZ_to_uv:function XYZ_to_uv(t){const _=t[0],o=t[1],n=_+15*o+3*t[2];return[4*_/n,9*o/n]} +/** + * Convert an array of three XYZ values to x,y chromaticity coordinates + * + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + * + * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js + */,XYZ_to_xy:function XYZ_to_xy(t){const _=t[0],o=t[1],n=_+o+t[2];return[_/n,o/n]},gam_2020:gam_2020,gam_P3:gam_P3,gam_ProPhoto:gam_ProPhoto,gam_a98rgb:gam_a98rgb,gam_sRGB:gam_sRGB,hueToRGB:function hueToRGB(t,_,o){return o<0&&(o+=6),o>=6&&(o-=6),o<1?(_-t)*o+t:o<3?_:o<4?(_-t)*(4-o)+t:t},lin_2020:lin_2020,lin_2020_to_XYZ:lin_2020_to_XYZ,lin_P3:lin_P3,lin_P3_to_XYZ:lin_P3_to_XYZ,lin_ProPhoto:lin_ProPhoto,lin_ProPhoto_to_XYZ:lin_ProPhoto_to_XYZ,lin_a98rgb:lin_a98rgb,lin_a98rgb_to_XYZ:lin_a98rgb_to_XYZ,lin_sRGB:lin_sRGB,lin_sRGB_to_XYZ:lin_sRGB_to_XYZ,naive_CMYK_to_sRGB:function naive_CMYK_to_sRGB(t){const _=t[0],o=t[1],n=t[2],r=t[3];return[1-Math.min(1,_*(1-r)+r),1-Math.min(1,o*(1-r)+r),1-Math.min(1,n*(1-r)+r)]},sRGB_to_HSL:sRGB_to_HSL,sRGB_to_HWB:function sRGB_to_HWB(t){const _=sRGB_to_HSL(t),o=Math.min(t[0],t[1],t[2]),n=1-Math.max(t[0],t[1],t[2]);return[_[0],100*o,100*n]},sRGB_to_luminance:sRGB_to_luminance});var a=Object.freeze({__proto__:null,HSL_to_XYZ_D50:function HSL_to_XYZ_D50(t){let _=t;return _=HSL_to_sRGB(_),_=lin_sRGB(_),_=lin_sRGB_to_XYZ(_),_=D65_to_D50(_),_},HWB_to_XYZ_D50:function HWB_to_XYZ_D50(t){let _=t;return _=HWB_to_sRGB(_),_=lin_sRGB(_),_=lin_sRGB_to_XYZ(_),_=D65_to_D50(_),_},LCH_to_XYZ_D50:function LCH_to_XYZ_D50(t){let _=t;return _=LCH_to_Lab(_),_=Lab_to_XYZ(_),_},Lab_to_XYZ_D50:function Lab_to_XYZ_D50(t){let _=t;return _=Lab_to_XYZ(_),_},OKLCH_to_XYZ_D50:function OKLCH_to_XYZ_D50(t){let _=t;return _=OKLCH_to_OKLab(_),_=OKLab_to_XYZ(_),_=D65_to_D50(_),_},OKLab_to_XYZ_D50:function OKLab_to_XYZ_D50(t){let _=t;return _=OKLab_to_XYZ(_),_=D65_to_D50(_),_},P3_to_XYZ_D50:function P3_to_XYZ_D50(t){let _=t;return _=lin_P3(_),_=lin_P3_to_XYZ(_),_=D65_to_D50(_),_},ProPhoto_RGB_to_XYZ_D50:function ProPhoto_RGB_to_XYZ_D50(t){let _=t;return _=lin_ProPhoto(_),_=lin_ProPhoto_to_XYZ(_),_},XYZ_D50_to_HSL:function XYZ_D50_to_HSL(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_sRGB(_),_=gam_sRGB(_),_=sRGB_to_HSL(_),_},XYZ_D50_to_HWB:function XYZ_D50_to_HWB(t){let _=t;_=D50_to_D65(_),_=XYZ_to_lin_sRGB(_);const o=gam_sRGB(_);_=sRGB_to_HSL(o);const n=Math.min(o[0],o[1],o[2]),r=1-Math.max(o[0],o[1],o[2]);return[_[0],100*n,100*r]},XYZ_D50_to_LCH:function XYZ_D50_to_LCH(t){let _=t;return _=XYZ_to_Lab(_),_=Lab_to_LCH(_),_},XYZ_D50_to_Lab:function XYZ_D50_to_Lab(t){let _=t;return _=XYZ_to_Lab(_),_},XYZ_D50_to_OKLCH:function XYZ_D50_to_OKLCH(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_OKLab(_),_=OKLab_to_OKLCH(_),_},XYZ_D50_to_OKLab:function XYZ_D50_to_OKLab(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_OKLab(_),_},XYZ_D50_to_P3:function XYZ_D50_to_P3(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_P3(_),_=gam_P3(_),_},XYZ_D50_to_ProPhoto:function XYZ_D50_to_ProPhoto(t){let _=t;return _=XYZ_to_lin_ProPhoto(_),_=gam_ProPhoto(_),_},XYZ_D50_to_XYZ_D50:function XYZ_D50_to_XYZ_D50(t){return t},XYZ_D50_to_XYZ_D65:function XYZ_D50_to_XYZ_D65(t){let _=t;return _=D50_to_D65(_),_},XYZ_D50_to_a98_RGB:function XYZ_D50_to_a98_RGB(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_a98rgb(_),_=gam_a98rgb(_),_},XYZ_D50_to_lin_sRGB:function XYZ_D50_to_lin_sRGB(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_sRGB(_),_},XYZ_D50_to_rec_2020:function XYZ_D50_to_rec_2020(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_2020(_),_=gam_2020(_),_},XYZ_D50_to_sRGB:function XYZ_D50_to_sRGB(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_sRGB(_),_=gam_sRGB(_),_},XYZ_D65_to_XYZ_D50:function XYZ_D65_to_XYZ_D50(t){let _=t;return _=D65_to_D50(_),_},a98_RGB_to_XYZ_D50:function a98_RGB_to_XYZ_D50(t){let _=t;return _=lin_a98rgb(_),_=lin_a98rgb_to_XYZ(_),_=D65_to_D50(_),_},lin_sRGB_to_XYZ_D50:function lin_sRGB_to_XYZ_D50(t){let _=t;return _=lin_sRGB_to_XYZ(_),_=D65_to_D50(_),_},rec_2020_to_XYZ_D50:function rec_2020_to_XYZ_D50(t){let _=t;return _=lin_2020(_),_=lin_2020_to_XYZ(_),_=D65_to_D50(_),_},sRGB_to_XYZ_D50:function sRGB_to_XYZ_D50(t){let _=t;return _=lin_sRGB(_),_=lin_sRGB_to_XYZ(_),_=D65_to_D50(_),_}});const i={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};export{n as calculations,e as conversions,i as namedColors,t as utils,a as xyz}; diff --git a/node_modules/@csstools/color-helpers/dist/named-colors/index.d.ts b/node_modules/@csstools/color-helpers/dist/named-colors/index.d.ts new file mode 100644 index 00000000..4d1a7edd --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/named-colors/index.d.ts @@ -0,0 +1,2 @@ +import type { Color } from 'types/color'; +export declare const namedColors: Record<string, Color>; diff --git a/node_modules/@csstools/color-helpers/dist/types/color.d.ts b/node_modules/@csstools/color-helpers/dist/types/color.d.ts new file mode 100644 index 00000000..4d390a28 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/types/color.d.ts @@ -0,0 +1 @@ +export type Color = [number, number, number]; diff --git a/node_modules/@csstools/color-helpers/dist/utils/clip.d.ts b/node_modules/@csstools/color-helpers/dist/utils/clip.d.ts new file mode 100644 index 00000000..c5ed70f0 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/utils/clip.d.ts @@ -0,0 +1,7 @@ +import type { Color } from 'types/color'; +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/map-gamut.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function clip(color: Color): Color; diff --git a/node_modules/@csstools/color-helpers/dist/utils/in-gamut.d.ts b/node_modules/@csstools/color-helpers/dist/utils/in-gamut.d.ts new file mode 100644 index 00000000..b2217eb1 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/utils/in-gamut.d.ts @@ -0,0 +1,7 @@ +import type { Color } from 'types/color'; +/** + * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/map-gamut.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + */ +export declare function inGamut(x: Color): boolean; diff --git a/node_modules/@csstools/color-helpers/dist/utils/index.d.ts b/node_modules/@csstools/color-helpers/dist/utils/index.d.ts new file mode 100644 index 00000000..b73e4598 --- /dev/null +++ b/node_modules/@csstools/color-helpers/dist/utils/index.d.ts @@ -0,0 +1,2 @@ +export * from './clip'; +export * from './in-gamut'; diff --git a/node_modules/@csstools/color-helpers/package.json b/node_modules/@csstools/color-helpers/package.json new file mode 100644 index 00000000..9f8a26c8 --- /dev/null +++ b/node_modules/@csstools/color-helpers/package.json @@ -0,0 +1,73 @@ +{ + "name": "@csstools/color-helpers", + "description": "Color helpers to ease transformation between formats, gamut, etc", + "version": "3.0.2", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "main": "dist/index.cjs", + "module": "dist/index.mjs", + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.cjs", + "default": "./dist/index.mjs" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "check-sources-integrity": "node ./scripts/check-changes.mjs", + "check-sources-integrity:rewrite": "REWRITE_HASHES=true node ./scripts/check-changes.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node ./test/_import.mjs && node ./test/_require.cjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "packages/color-helpers" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "colors", + "css" + ], + "volta": { + "extends": "../../package.json" + }, + "eslintConfig": { + "rules": { + "@typescript-eslint/no-loss-of-precision": "off" + } + } +} diff --git a/node_modules/@csstools/css-calc/CHANGELOG.md b/node_modules/@csstools/css-calc/CHANGELOG.md new file mode 100644 index 00000000..78d8a5e1 --- /dev/null +++ b/node_modules/@csstools/css-calc/CHANGELOG.md @@ -0,0 +1,47 @@ +# Changes to CSS Calc + +### 1.1.4 + +_September 24, 2023_ + +- 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) + +### 1.1.3 + +_July 24, 2023_ + +- Correctly serialize negative zero `-0` values as `calc(-1 * 0px)` +- 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) + +### 1.1.2 + +_July 3, 2023_ + +- 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) + +### 1.1.1 + +_April 10, 2023_ + +- Updated `@csstools/css-tokenizer` to `2.1.1` (patch) +- Updated `@csstools/css-parser-algorithms` to `2.1.1` (patch) + +### 1.1.0 + +_April 10, 2023_ + +- Expose the list of supported math functions. + +### 1.0.1 + +_March 25, 2023_ + +- Improve case insensitive string matching. + +### 1.0.0 + +_February 21, 2023_ + +- Initial version diff --git a/node_modules/@csstools/css-calc/LICENSE.md b/node_modules/@csstools/css-calc/LICENSE.md new file mode 100644 index 00000000..af5411fa --- /dev/null +++ b/node_modules/@csstools/css-calc/LICENSE.md @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright 2022 Romain Menke, Antonio Laguna <antonio@laguna.es> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/@csstools/css-calc/README.md b/node_modules/@csstools/css-calc/README.md new file mode 100644 index 00000000..bae425a5 --- /dev/null +++ b/node_modules/@csstools/css-calc/README.md @@ -0,0 +1,132 @@ +# CSS Calc + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/css-calc.svg" height="20">][npm-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +Implemented from : https://drafts.csswg.org/css-values-4/ on 2023-02-17 + +## Usage + +Add [CSS calc] to your project: + +```bash +npm install @csstools/css-calc @csstools/css-parser-algorithms @csstools/css-tokenizer --save-dev +``` + +### With string values : + +```mjs +import { calc } from '@csstools/css-calc'; + +// '20' +console.log(calc('calc(10 * 2)')); +``` + +### With component values : + +```mjs +import { stringify, tokenizer } from '@csstools/css-tokenizer'; +import { parseCommaSeparatedListOfComponentValues } from '@csstools/css-parser-algorithms'; +import { calcFromComponentValues } from '@csstools/css-calc'; + +const t = tokenizer({ + css: 'calc(10 * 2)', +}); + +const tokens = []; + +{ + while (!t.endOfFile()) { + tokens.push(t.nextToken()); + } + + tokens.push(t.nextToken()); // EOF-token +} + +const result = parseCommaSeparatedListOfComponentValues(tokens, {}); + +// filter or mutate the component values + +const calcResult = calcFromComponentValues(result, { precision: 5, toCanonicalUnits: true }); + +// filter or mutate the component values even further + +const calcResultStr = calcResult.map((componentValues) => { + return componentValues.map((x) => stringify(...x.tokens())).join(''); +}).join(','); + +// '20' +console.log(calcResultStr); +``` + +### Options + +#### `precision` : + +The default precision is fairly high. +It aims to be high enough to make rounding unnoticeable in the browser. + +You can set it to a lower number to suit your needs. + +```mjs +import { calc } from '@csstools/css-calc'; + +// '0.3' +console.log(calc('calc(1 / 3)', { precision: 1 })); +// '0.33' +console.log(calc('calc(1 / 3)', { precision: 2 })); +``` + +#### `globals` : + +Pass global values as a map of key value pairs. + +> Example : Relative color syntax (`lch(from pink calc(l / 2) c h)`) exposes color channel information as ident tokens. +> By passing globals for `l`, `c` and `h` it is possible to solve nested `calc()`'s. + +```mjs +import { calc } from '@csstools/css-calc'; + +const globals = new Map([ + ['a', '10px'], + ['b', '2rem'], +]); + +// '20px' +console.log(calc('calc(a * 2)', { globals: globals })); +// '6rem' +console.log(calc('calc(b * 3)', { globals: globals })); +``` + +#### `toCanonicalUnits` : + +By default this package will try to preserve units. +The heuristic to do this is very simplistic. +We take the first unit we encounter and try to convert other dimensions to that unit. + +This better matches what users expect from a CSS dev tool. + +If you want to have outputs that are closes to CSS serialized values you can pass `toCanonicalUnits: true`. + +```mjs +import { calc } from '@csstools/css-calc'; + +// '20hz' +console.log(calc('calc(0.01khz + 10hz)', { toCanonicalUnits: true })); + +// '20hz' +console.log(calc('calc(10hz + 0.01khz)', { toCanonicalUnits: true })); + +// '0.02khz' !!! +console.log(calc('calc(0.01khz + 10hz)', { toCanonicalUnits: false })); + +// '20hz' +console.log(calc('calc(10hz + 0.01khz)', { toCanonicalUnits: false })); +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/css-calc + +[CSS calc]: https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc diff --git a/node_modules/@csstools/css-calc/dist/calculation.d.ts b/node_modules/@csstools/css-calc/dist/calculation.d.ts new file mode 100644 index 00000000..963a3854 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/calculation.d.ts @@ -0,0 +1,8 @@ +import type { Operation } from './operation/operation'; +import type { TokenNode } from '@csstools/css-parser-algorithms'; +export type Calculation = { + inputs: Array<Calculation | TokenNode>; + operation: Operation; +}; +export declare function isCalculation(x: unknown): x is Calculation; +export declare function solve(calculation: Calculation | -1): TokenNode | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/abs.d.ts b/node_modules/@csstools/css-calc/dist/functions/abs.d.ts new file mode 100644 index 00000000..e8971e3b --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/abs.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveAbs(absNode: FunctionNode, a: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/acos.d.ts b/node_modules/@csstools/css-calc/dist/functions/acos.d.ts new file mode 100644 index 00000000..964f7470 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/acos.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveACos(acosNode: FunctionNode, a: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/asin.d.ts b/node_modules/@csstools/css-calc/dist/functions/asin.d.ts new file mode 100644 index 00000000..a1465cb7 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/asin.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveASin(asinNode: FunctionNode, a: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/atan.d.ts b/node_modules/@csstools/css-calc/dist/functions/atan.d.ts new file mode 100644 index 00000000..f800a7bf --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/atan.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveATan(atanNode: FunctionNode, a: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/atan2.d.ts b/node_modules/@csstools/css-calc/dist/functions/atan2.d.ts new file mode 100644 index 00000000..651308f6 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/atan2.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveATan2(atan2Node: FunctionNode, a: TokenNode, b: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/calc.d.ts b/node_modules/@csstools/css-calc/dist/functions/calc.d.ts new file mode 100644 index 00000000..aa2f0dd4 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/calc.d.ts @@ -0,0 +1,29 @@ +import type { Calculation } from '../calculation'; +import type { ComponentValue, SimpleBlockNode, TokenNode } from '@csstools/css-parser-algorithms'; +import type { Globals } from '../util/globals'; +import { FunctionNode } from '@csstools/css-parser-algorithms'; +export declare const mathFunctions: Map<string, typeof abs>; +export declare function calc(calcNode: FunctionNode | SimpleBlockNode, globals: Globals): Calculation | -1; +export declare function singleNodeSolver(fnNode: FunctionNode, globals: Globals, solveFn: (node: FunctionNode, a: TokenNode) => Calculation | -1): Calculation | -1; +export declare function twoCommaSeparatedNodesSolver(fnNode: FunctionNode, globals: Globals, solveFn: (node: FunctionNode, a: TokenNode, b: TokenNode) => Calculation | -1): Calculation | -1; +export declare function variadicNodesSolver(fnNode: FunctionNode, globals: Globals, solveFn: (node: FunctionNode, x: Array<ComponentValue>) => Calculation | -1): Calculation | -1; +export declare function clamp(clampNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function max(maxNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function min(minNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function round(roundNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function mod(modNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function rem(remNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function abs(absNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function sign(signNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function sin(sinNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function cos(codNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function tan(tanNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function asin(asinNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function acos(acosNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function atan(atanNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function atan2(atan2Node: FunctionNode, globals: Globals): Calculation | -1; +export declare function exp(expNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function sqrt(sqrtNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function pow(powNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function hypot(hypotNode: FunctionNode, globals: Globals): Calculation | -1; +export declare function log(logNode: FunctionNode, globals: Globals): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/clamp.d.ts b/node_modules/@csstools/css-calc/dist/functions/clamp.d.ts new file mode 100644 index 00000000..19a49c4b --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/clamp.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveClamp(clampNode: FunctionNode, minimum: TokenNode | -1, central: TokenNode | -1, maximum: TokenNode | -1): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/cos.d.ts b/node_modules/@csstools/css-calc/dist/functions/cos.d.ts new file mode 100644 index 00000000..74359259 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/cos.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveCos(cosNode: FunctionNode, a: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/exp.d.ts b/node_modules/@csstools/css-calc/dist/functions/exp.d.ts new file mode 100644 index 00000000..0d1a64d9 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/exp.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveExp(expNode: FunctionNode, a: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/globals-and-constants.d.ts b/node_modules/@csstools/css-calc/dist/functions/globals-and-constants.d.ts new file mode 100644 index 00000000..d968bd11 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/globals-and-constants.d.ts @@ -0,0 +1,3 @@ +import { ComponentValue } from '@csstools/css-parser-algorithms'; +import { Globals } from '../util/globals'; +export declare function resolveGlobalsAndConstants(nodes: Array<ComponentValue>, globals: Globals): Array<ComponentValue>; diff --git a/node_modules/@csstools/css-calc/dist/functions/hypot.d.ts b/node_modules/@csstools/css-calc/dist/functions/hypot.d.ts new file mode 100644 index 00000000..9d22357f --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/hypot.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { ComponentValue, FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function solveHypot(hypotNode: FunctionNode, solvedNodes: Array<ComponentValue>): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/log.d.ts b/node_modules/@csstools/css-calc/dist/functions/log.d.ts new file mode 100644 index 00000000..9ed69293 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/log.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { ComponentValue, FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function solveLog(logNode: FunctionNode, solvedNodes: Array<ComponentValue>): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/max.d.ts b/node_modules/@csstools/css-calc/dist/functions/max.d.ts new file mode 100644 index 00000000..4181d6e5 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/max.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { ComponentValue, FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function solveMax(maxNode: FunctionNode, solvedNodes: Array<ComponentValue>): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/min.d.ts b/node_modules/@csstools/css-calc/dist/functions/min.d.ts new file mode 100644 index 00000000..9f76b07c --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/min.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { ComponentValue, FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function solveMin(minNode: FunctionNode, solvedNodes: Array<ComponentValue>): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/mod.d.ts b/node_modules/@csstools/css-calc/dist/functions/mod.d.ts new file mode 100644 index 00000000..0a6172e1 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/mod.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveMod(modNode: FunctionNode, a: TokenNode, b: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/pow.d.ts b/node_modules/@csstools/css-calc/dist/functions/pow.d.ts new file mode 100644 index 00000000..33efc20c --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/pow.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solvePow(powNode: FunctionNode, a: TokenNode, b: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/rem.d.ts b/node_modules/@csstools/css-calc/dist/functions/rem.d.ts new file mode 100644 index 00000000..ebaacfd1 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/rem.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveRem(remNode: FunctionNode, a: TokenNode, b: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/result-to-calculation.d.ts b/node_modules/@csstools/css-calc/dist/functions/result-to-calculation.d.ts new file mode 100644 index 00000000..1f79cf4e --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/result-to-calculation.d.ts @@ -0,0 +1,7 @@ +import { CSSToken } from '@csstools/css-tokenizer'; +import { FunctionNode } from '@csstools/css-parser-algorithms'; +import { Calculation } from '../calculation'; +export declare function resultToCalculation(node: FunctionNode, aToken: CSSToken, result: number): Calculation | -1; +export declare function dimensionToCalculation(node: FunctionNode, unit: string, result: number): Calculation | -1; +export declare function percentageToCalculation(node: FunctionNode, result: number): Calculation | -1; +export declare function numberToCalculation(node: FunctionNode, result: number): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/round.d.ts b/node_modules/@csstools/css-calc/dist/functions/round.d.ts new file mode 100644 index 00000000..87b8d78f --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/round.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveRound(roundNode: FunctionNode, roundingStrategy: string, a: TokenNode, b: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/sign.d.ts b/node_modules/@csstools/css-calc/dist/functions/sign.d.ts new file mode 100644 index 00000000..391f3b56 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/sign.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveSign(signNode: FunctionNode, a: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/sin.d.ts b/node_modules/@csstools/css-calc/dist/functions/sin.d.ts new file mode 100644 index 00000000..9a0f484b --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/sin.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveSin(sinNode: FunctionNode, a: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/sqrt.d.ts b/node_modules/@csstools/css-calc/dist/functions/sqrt.d.ts new file mode 100644 index 00000000..a9a43a69 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/sqrt.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveSqrt(sqrtNode: FunctionNode, a: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/functions/tan.d.ts b/node_modules/@csstools/css-calc/dist/functions/tan.d.ts new file mode 100644 index 00000000..6294895d --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/functions/tan.d.ts @@ -0,0 +1,3 @@ +import type { Calculation } from '../calculation'; +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function solveTan(tanNode: FunctionNode, a: TokenNode): Calculation | -1; diff --git a/node_modules/@csstools/css-calc/dist/index.cjs b/node_modules/@csstools/css-calc/dist/index.cjs new file mode 100644 index 00000000..a9163530 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/css-parser-algorithms"),n=require("@csstools/css-tokenizer");const o=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(o,(e=>String.fromCharCode(e.charCodeAt(0)+32)))}const t={cm:"px",in:"px",mm:"px",pc:"px",pt:"px",px:"px",q:"px",deg:"deg",grad:"deg",rad:"deg",turn:"deg",ms:"s",s:"s",hz:"hz",khz:"hz"},r=new Map([["cm",e=>e],["mm",e=>10*e],["q",e=>40*e],["in",e=>e/2.54],["pc",e=>e/2.54*6],["pt",e=>e/2.54*72],["px",e=>e/2.54*96]]),u=new Map([["deg",e=>e],["grad",e=>e/.9],["rad",e=>e/180*Math.PI],["turn",e=>e/360]]),i=new Map([["deg",e=>.9*e],["grad",e=>e],["rad",e=>.9*e/180*Math.PI],["turn",e=>.9*e/360]]),a=new Map([["hz",e=>e],["khz",e=>e/1e3]]),l=new Map([["cm",e=>2.54*e],["mm",e=>25.4*e],["q",e=>25.4*e*4],["in",e=>e],["pc",e=>6*e],["pt",e=>72*e],["px",e=>96*e]]),s=new Map([["hz",e=>1e3*e],["khz",e=>e]]),c=new Map([["cm",e=>e/10],["mm",e=>e],["q",e=>4*e],["in",e=>e/25.4],["pc",e=>e/25.4*6],["pt",e=>e/25.4*72],["px",e=>e/25.4*96]]),T=new Map([["ms",e=>e],["s",e=>e/1e3]]),p=new Map([["cm",e=>e/6*2.54],["mm",e=>e/6*25.4],["q",e=>e/6*25.4*4],["in",e=>e/6],["pc",e=>e],["pt",e=>e/6*72],["px",e=>e/6*96]]),v=new Map([["cm",e=>e/72*2.54],["mm",e=>e/72*25.4],["q",e=>e/72*25.4*4],["in",e=>e/72],["pc",e=>e/72*6],["pt",e=>e],["px",e=>e/72*96]]),m=new Map([["cm",e=>e/96*2.54],["mm",e=>e/96*25.4],["q",e=>e/96*25.4*4],["in",e=>e/96],["pc",e=>e/96*6],["pt",e=>e/96*72],["px",e=>e]]),N=new Map([["cm",e=>e/4/10],["mm",e=>e/4],["q",e=>e],["in",e=>e/4/25.4],["pc",e=>e/4/25.4*6],["pt",e=>e/4/25.4*72],["px",e=>e/4/25.4*96]]),f=new Map([["deg",e=>180*e/Math.PI],["grad",e=>180*e/Math.PI/.9],["rad",e=>e],["turn",e=>180*e/Math.PI/360]]),y=new Map([["ms",e=>1e3*e],["s",e=>e]]),k=new Map([["deg",e=>360*e],["grad",e=>360*e/.9],["rad",e=>360*e/180*Math.PI],["turn",e=>e]]),d=new Map([["cm",r],["mm",c],["q",N],["in",l],["pc",p],["pt",v],["px",m],["ms",T],["s",y],["deg",u],["grad",i],["rad",f],["turn",k],["hz",a],["khz",s]]);function convertUnit(e,o){if(e[0]!==n.TokenType.Dimension)return o;if(o[0]!==n.TokenType.Dimension)return o;const t=toLowerCaseAZ(e[4].unit),r=toLowerCaseAZ(o[4].unit);if(t===r)return o;const u=d.get(r);if(!u)return o;const i=u.get(t);if(!i)return o;const a=i(o[4].value);return[n.TokenType.Dimension,a.toString()+e[4].unit,o[2],o[3],{value:a,unit:e[4].unit,type:Number.isInteger(a)?n.NumberType.Integer:n.NumberType.Number}]}function toCanonicalUnit(e){if(e[0]!==n.TokenType.Dimension)return e;const o=toLowerCaseAZ(e[4].unit),r=t[o];if(o===r)return e;const u=d.get(o);if(!u)return e;const i=u.get(r);if(!i)return e;const a=i(e[4].value);return[n.TokenType.Dimension,a.toString()+r,e[2],e[3],{value:a,unit:r,type:Number.isInteger(a)?n.NumberType.Integer:n.NumberType.Number}]}function addition(o){if(2!==o.length)return-1;const t=o[0].value;let r=o[1].value;if(t[0]===n.TokenType.Number&&r[0]===n.TokenType.Number){const o=t[4].value+r[4].value;return new e.TokenNode([n.TokenType.Number,o.toString(),t[2],r[3],{value:o,type:t[4].type===n.NumberType.Integer&&r[4].type===n.NumberType.Integer?n.NumberType.Integer:n.NumberType.Number}])}if(t[0]===n.TokenType.Percentage&&r[0]===n.TokenType.Percentage){const o=t[4].value+r[4].value;return new e.TokenNode([n.TokenType.Percentage,o.toString()+"%",t[2],r[3],{value:o}])}if(t[0]===n.TokenType.Dimension&&r[0]===n.TokenType.Dimension&&(r=convertUnit(t,r),toLowerCaseAZ(t[4].unit)===toLowerCaseAZ(r[4].unit))){const o=t[4].value+r[4].value;return new e.TokenNode([n.TokenType.Dimension,o.toString()+t[4].unit,t[2],r[3],{value:o,type:t[4].type===n.NumberType.Integer&&r[4].type===n.NumberType.Integer?n.NumberType.Integer:n.NumberType.Number,unit:t[4].unit}])}return-1}function division(o){if(2!==o.length)return-1;const t=o[0].value,r=o[1].value;if(t[0]===n.TokenType.Number&&r[0]===n.TokenType.Number){const o=t[4].value/r[4].value;return new e.TokenNode([n.TokenType.Number,o.toString(),t[2],r[3],{value:o,type:Number.isInteger(o)?n.NumberType.Integer:n.NumberType.Number}])}if(t[0]===n.TokenType.Percentage&&r[0]===n.TokenType.Number){const o=t[4].value/r[4].value;return new e.TokenNode([n.TokenType.Percentage,o.toString()+"%",t[2],r[3],{value:o}])}if(t[0]===n.TokenType.Dimension&&r[0]===n.TokenType.Number){const o=t[4].value/r[4].value;return new e.TokenNode([n.TokenType.Dimension,o.toString()+t[4].unit,t[2],r[3],{value:o,type:Number.isInteger(o)?n.NumberType.Integer:n.NumberType.Number,unit:t[4].unit}])}return-1}function isCalculation(e){return!!e&&"object"==typeof e&&"inputs"in e&&Array.isArray(e.inputs)&&"operation"in e}function solve(n){if(-1===n)return-1;const o=[];for(let t=0;t<n.inputs.length;t++){const r=n.inputs[t];if(e.isTokenNode(r)){o.push(r);continue}const u=solve(r);if(-1===u)return-1;o.push(u)}return n.operation(o)}function multiplication(o){if(2!==o.length)return-1;const t=o[0].value,r=o[1].value;if(t[0]===n.TokenType.Number&&r[0]===n.TokenType.Number){const o=t[4].value*r[4].value;return new e.TokenNode([n.TokenType.Number,o.toString(),t[2],r[3],{value:o,type:t[4].type===n.NumberType.Integer&&r[4].type===n.NumberType.Integer?n.NumberType.Integer:n.NumberType.Number}])}if(t[0]===n.TokenType.Percentage&&r[0]===n.TokenType.Number){const o=t[4].value*r[4].value;return new e.TokenNode([n.TokenType.Percentage,o.toString()+"%",t[2],r[3],{value:o}])}if(t[0]===n.TokenType.Number&&r[0]===n.TokenType.Percentage){const o=t[4].value*r[4].value;return new e.TokenNode([n.TokenType.Percentage,o.toString()+"%",t[2],r[3],{value:o}])}if(t[0]===n.TokenType.Dimension&&r[0]===n.TokenType.Number){const o=t[4].value*r[4].value;return new e.TokenNode([n.TokenType.Dimension,o.toString()+t[4].unit,t[2],r[3],{value:o,type:t[4].type===n.NumberType.Integer&&r[4].type===n.NumberType.Integer?n.NumberType.Integer:n.NumberType.Number,unit:t[4].unit}])}if(t[0]===n.TokenType.Number&&r[0]===n.TokenType.Dimension){const o=t[4].value*r[4].value;return new e.TokenNode([n.TokenType.Dimension,o.toString()+r[4].unit,t[2],r[3],{value:o,type:t[4].type===n.NumberType.Integer&&r[4].type===n.NumberType.Integer?n.NumberType.Integer:n.NumberType.Number,unit:r[4].unit}])}return-1}function resolveGlobalsAndConstants(o,t){for(let r=0;r<o.length;r++){const u=o[r];if(!e.isTokenNode(u))continue;const i=u.value;if(i[0]!==n.TokenType.Ident)continue;const a=toLowerCaseAZ(i[4].value);switch(a){case"e":o.splice(r,1,new e.TokenNode([n.TokenType.Number,Math.E.toString(),i[2],i[3],{value:Math.E,type:n.NumberType.Number}]));break;case"pi":o.splice(r,1,new e.TokenNode([n.TokenType.Number,Math.PI.toString(),i[2],i[3],{value:Math.PI,type:n.NumberType.Number}]));break;case"infinity":o.splice(r,1,new e.TokenNode([n.TokenType.Number,"infinity",i[2],i[3],{value:1/0,type:n.NumberType.Number}]));break;case"-infinity":o.splice(r,1,new e.TokenNode([n.TokenType.Number,"-infinity",i[2],i[3],{value:-1/0,type:n.NumberType.Number}]));break;case"nan":o.splice(r,1,new e.TokenNode([n.TokenType.Number,"NaN",i[2],i[3],{value:Number.NaN,type:n.NumberType.Number}]));break;default:if(t.has(a)){const n=t.get(a);o.splice(r,1,new e.TokenNode(n))}}}return o}function isNumeric(e){return e[0]===n.TokenType.Dimension||(e[0]===n.TokenType.Percentage||e[0]===n.TokenType.Number)}function isDimensionOrNumber(e){return e[0]===n.TokenType.Dimension||e[0]===n.TokenType.Number}function arrayOfSameNumeric(e){if(0===e.length)return!0;const o=e[0];if(!isNumeric(o))return!1;if(1===e.length)return!0;if(o[0]===n.TokenType.Dimension){const n=toLowerCaseAZ(o[4].unit);for(let t=1;t<e.length;t++){const r=e[t];if(o[0]!==r[0])return!1;if(n!==toLowerCaseAZ(r[4].unit))return!1}return!0}for(let n=1;n<e.length;n++){const t=e[n];if(o[0]!==t[0])return!1}return!0}function twoOfSameNumeric(e,o){return!!isNumeric(e)&&(e[0]===n.TokenType.Dimension?e[0]===o[0]&&toLowerCaseAZ(e[4].unit)===toLowerCaseAZ(o[4].unit):e[0]===o[0])}function unary(e){if(1!==e.length)return-1;return isNumeric(e[0].value)?e[0]:-1}function resultToCalculation(e,o,t){return o[0]===n.TokenType.Dimension?dimensionToCalculation(e,o[4].unit,t):o[0]===n.TokenType.Percentage?percentageToCalculation(e,t):o[0]===n.TokenType.Number?numberToCalculation(e,t):-1}function dimensionToCalculation(o,t,r){const u=o.tokens();return{inputs:[new e.TokenNode([n.TokenType.Dimension,r.toString()+t,u[0][2],u[u.length-1][3],{value:r,type:Number.isInteger(r)?n.NumberType.Integer:n.NumberType.Number,unit:t}])],operation:unary}}function percentageToCalculation(o,t){const r=o.tokens();return{inputs:[new e.TokenNode([n.TokenType.Percentage,t.toString()+"%",r[0][2],r[r.length-1][3],{value:t}])],operation:unary}}function numberToCalculation(o,t){const r=o.tokens();return{inputs:[new e.TokenNode([n.TokenType.Number,t.toString(),r[0][2],r[r.length-1][3],{value:t,type:Number.isInteger(t)?n.NumberType.Integer:n.NumberType.Number}])],operation:unary}}function solveACos(e,o){const t=o.value;if(t[0]!==n.TokenType.Number)return-1;return dimensionToCalculation(e,"rad",Math.acos(t[4].value))}function solveASin(e,o){const t=o.value;if(t[0]!==n.TokenType.Number)return-1;return dimensionToCalculation(e,"rad",Math.asin(t[4].value))}function solveATan(e,o){const t=o.value;if(t[0]!==n.TokenType.Number)return-1;return dimensionToCalculation(e,"rad",Math.atan(t[4].value))}function solveATan2(e,n,o){const t=n.value;if(!isDimensionOrNumber(t))return-1;const r=convertUnit(t,o.value);if(!twoOfSameNumeric(t,r))return-1;return dimensionToCalculation(e,"rad",Math.atan2(t[4].value,r[4].value))}function solveAbs(e,n){const o=n.value;if(!isDimensionOrNumber(o))return-1;return resultToCalculation(e,o,Math.abs(o[4].value))}function solveClamp(n,o,t,r){if(!e.isTokenNode(o)||!e.isTokenNode(t)||!e.isTokenNode(r))return-1;const u=o.value;if(!isNumeric(u))return-1;const i=convertUnit(u,t.value);if(!twoOfSameNumeric(u,i))return-1;const a=convertUnit(u,r.value);if(!twoOfSameNumeric(u,a))return-1;return resultToCalculation(n,u,Math.max(u[4].value,Math.min(i[4].value,a[4].value)))}function solveCos(e,o){const t=o.value;if(!isDimensionOrNumber(t))return-1;let r=t[4].value;if(t[0]===n.TokenType.Dimension)switch(toLowerCaseAZ(t[4].unit)){case"rad":break;case"deg":r=u.get("rad")(t[4].value);break;case"grad":r=i.get("rad")(t[4].value);break;case"turn":r=k.get("rad")(t[4].value);break;default:return-1}return r=Math.cos(r),numberToCalculation(e,r)}function solveExp(e,o){const t=o.value;if(t[0]!==n.TokenType.Number)return-1;return numberToCalculation(e,Math.exp(t[4].value))}function solveHypot(n,o){const t=o[0];if(!t||!e.isTokenNode(t))return-1;if(1!==new Set(o.map((e=>e.type))).size)return-1;const r=t.value;if(!isNumeric(r))return-1;const u=o.map((e=>convertUnit(r,e.value)));if(!arrayOfSameNumeric(u))return-1;const i=u.map((e=>e[4].value)),a=Math.hypot(...i);return resultToCalculation(n,r,a)}function solveMax(n,o){const t=o[0];if(!t||!e.isTokenNode(t))return-1;if(1!==new Set(o.map((e=>e.type))).size)return-1;const r=t.value;if(!isNumeric(r))return-1;const u=o.map((e=>convertUnit(r,e.value)));if(!arrayOfSameNumeric(u))return-1;const i=u.map((e=>e[4].value)),a=Math.max(...i);return resultToCalculation(n,r,a)}function solveMin(n,o){const t=o[0];if(!t||!e.isTokenNode(t))return-1;if(1!==new Set(o.map((e=>e.type))).size)return-1;const r=t.value;if(!isNumeric(r))return-1;const u=o.map((e=>convertUnit(r,e.value)));if(!arrayOfSameNumeric(u))return-1;const i=u.map((e=>e[4].value)),a=Math.min(...i);return resultToCalculation(n,r,a)}function solveMod(e,n,o){const t=n.value;if(!isNumeric(t))return-1;const r=convertUnit(t,o.value);if(!twoOfSameNumeric(t,r))return-1;let u;return u=0===r[4].value?Number.NaN:Number.isFinite(t[4].value)&&(Number.isFinite(r[4].value)||(r[4].value!==Number.POSITIVE_INFINITY||t[4].value!==Number.NEGATIVE_INFINITY&&!Object.is(0*t[4].value,-0))&&(r[4].value!==Number.NEGATIVE_INFINITY||t[4].value!==Number.POSITIVE_INFINITY&&!Object.is(0*t[4].value,0)))?Number.isFinite(r[4].value)?(t[4].value%r[4].value+r[4].value)%r[4].value:t[4].value:Number.NaN,resultToCalculation(e,t,u)}function solvePow(e,o,t){const r=o.value,u=t.value;if(r[0]!==n.TokenType.Number)return-1;if(!twoOfSameNumeric(r,u))return-1;return numberToCalculation(e,Math.pow(r[4].value,u[4].value))}function solveRem(e,n,o){const t=n.value;if(!isNumeric(t))return-1;const r=convertUnit(t,o.value);if(!twoOfSameNumeric(t,r))return-1;let u;return u=0===r[4].value?Number.NaN:Number.isFinite(t[4].value)?Number.isFinite(r[4].value)?t[4].value%r[4].value:t[4].value:Number.NaN,resultToCalculation(e,t,u)}function solveRound(e,n,o,t){const r=o.value;if(!isNumeric(r))return-1;const u=convertUnit(r,t.value);if(!twoOfSameNumeric(r,u))return-1;let i;if(0===u[4].value)i=Number.NaN;else if(Number.isFinite(r[4].value)||Number.isFinite(u[4].value))if(!Number.isFinite(r[4].value)&&Number.isFinite(u[4].value))i=r[4].value;else if(Number.isFinite(r[4].value)&&!Number.isFinite(u[4].value))switch(n){case"down":i=r[4].value<0?-1/0:Object.is(-0,0*r[4].value)?-0:0;break;case"up":i=r[4].value>0?1/0:Object.is(0,0*r[4].value)?0:-0;break;default:i=Object.is(0,0*r[4].value)?0:-0}else if(Number.isFinite(u[4].value))switch(n){case"down":i=Math.floor(r[4].value/u[4].value)*u[4].value;break;case"up":i=Math.ceil(r[4].value/u[4].value)*u[4].value;break;case"to-zero":i=Math.trunc(r[4].value/u[4].value)*u[4].value;break;default:{let e=Math.floor(r[4].value/u[4].value)*u[4].value,n=Math.ceil(r[4].value/u[4].value)*u[4].value;if(e>n){const o=e;e=n,n=o}const o=Math.abs(r[4].value-e),t=Math.abs(r[4].value-n);i=o===t?n:o<t?e:n;break}}else i=r[4].value;else i=Number.NaN;return resultToCalculation(e,r,i)}function solveSign(e,n){const o=n.value;if(!isDimensionOrNumber(o))return-1;return numberToCalculation(e,Math.sign(o[4].value))}function solveSin(e,o){const t=o.value;if(!isDimensionOrNumber(t))return-1;let r=t[4].value;if(t[0]===n.TokenType.Dimension)switch(toLowerCaseAZ(t[4].unit)){case"rad":break;case"deg":r=u.get("rad")(t[4].value);break;case"grad":r=i.get("rad")(t[4].value);break;case"turn":r=k.get("rad")(t[4].value);break;default:return-1}return r=Math.sin(r),numberToCalculation(e,r)}function solveSqrt(e,o){const t=o.value;if(t[0]!==n.TokenType.Number)return-1;return numberToCalculation(e,Math.sqrt(t[4].value))}function solveTan(e,o){const t=o.value;if(!isDimensionOrNumber(t))return-1;const r=t[4].value;let a=0,l=t[4].value;if(t[0]===n.TokenType.Dimension)switch(toLowerCaseAZ(t[4].unit)){case"rad":a=f.get("deg")(r);break;case"deg":a=r,l=u.get("rad")(r);break;case"grad":a=i.get("deg")(r),l=i.get("rad")(r);break;case"turn":a=k.get("deg")(r),l=k.get("rad")(r);break;default:return-1}const s=a/90;return l=a%90==0&&s%2!=0?s>0?1/0:-1/0:Math.tan(l),numberToCalculation(e,l)}function subtraction(o){if(2!==o.length)return-1;const t=o[0].value;let r=o[1].value;if(t[0]===n.TokenType.Number&&r[0]===n.TokenType.Number){const o=t[4].value-r[4].value;return new e.TokenNode([n.TokenType.Number,o.toString(),t[2],r[3],{value:o,type:t[4].type===n.NumberType.Integer&&r[4].type===n.NumberType.Integer?n.NumberType.Integer:n.NumberType.Number}])}if(t[0]===n.TokenType.Percentage&&r[0]===n.TokenType.Percentage){const o=t[4].value-r[4].value;return new e.TokenNode([n.TokenType.Percentage,o.toString()+"%",t[2],r[3],{value:o}])}if(t[0]===n.TokenType.Dimension&&r[0]===n.TokenType.Dimension&&(r=convertUnit(t,r),toLowerCaseAZ(t[4].unit)===toLowerCaseAZ(r[4].unit))){const o=t[4].value-r[4].value;return new e.TokenNode([n.TokenType.Dimension,o.toString()+t[4].unit,t[2],r[3],{value:o,type:t[4].type===n.NumberType.Integer&&r[4].type===n.NumberType.Integer?n.NumberType.Integer:n.NumberType.Number,unit:t[4].unit}])}return-1}function solveLog(o,t){if(1===t.length){const r=t[0];if(!r||!e.isTokenNode(r))return-1;const u=r.value;if(u[0]!==n.TokenType.Number)return-1;return numberToCalculation(o,Math.log(u[4].value))}if(2===t.length){const r=t[0];if(!r||!e.isTokenNode(r))return-1;const u=r.value;if(u[0]!==n.TokenType.Number)return-1;const i=t[1];if(!i||!e.isTokenNode(i))return-1;const a=i.value;if(a[0]!==n.TokenType.Number)return-1;return numberToCalculation(o,Math.log(u[4].value)/Math.log(a[4].value))}return-1}const b=new Map([["abs",function abs(e,n){return singleNodeSolver(e,n,solveAbs)}],["acos",function acos(e,n){return singleNodeSolver(e,n,solveACos)}],["asin",function asin(e,n){return singleNodeSolver(e,n,solveASin)}],["atan",function atan(e,n){return singleNodeSolver(e,n,solveATan)}],["atan2",function atan2(e,n){return twoCommaSeparatedNodesSolver(e,n,solveATan2)}],["calc",calc$1],["clamp",function clamp(o,t){const r=resolveGlobalsAndConstants([...o.value.filter((n=>!e.isCommentNode(n)&&!e.isWhitespaceNode(n)))],t),u=[],i=[],a=[];{let o=u;for(let t=0;t<r.length;t++){const l=r[t];if(e.isTokenNode(l)&&l.value[0]===n.TokenType.Comma){if(o===a)return-1;if(o===i){o=a;continue}if(o===u){o=i;continue}return-1}o.push(l)}}const l=solve(calc$1(new e.FunctionNode([n.TokenType.Function,"calc(",-1,-1,{value:"calc"}],[n.TokenType.CloseParen,")",-1,-1,void 0],u),t));if(-1===l)return-1;const s=solve(calc$1(new e.FunctionNode([n.TokenType.Function,"calc(",-1,-1,{value:"calc"}],[n.TokenType.CloseParen,")",-1,-1,void 0],i),t));if(-1===s)return-1;const c=solve(calc$1(new e.FunctionNode([n.TokenType.Function,"calc(",-1,-1,{value:"calc"}],[n.TokenType.CloseParen,")",-1,-1,void 0],a),t));if(-1===c)return-1;return solveClamp(o,l,s,c)}],["cos",function cos(e,n){return singleNodeSolver(e,n,solveCos)}],["exp",function exp(e,n){return singleNodeSolver(e,n,solveExp)}],["hypot",function hypot(e,n){return variadicNodesSolver(e,n,solveHypot)}],["log",function log(e,n){return variadicNodesSolver(e,n,solveLog)}],["max",function max(e,n){return variadicNodesSolver(e,n,solveMax)}],["min",function min(e,n){return variadicNodesSolver(e,n,solveMin)}],["mod",function mod(e,n){return twoCommaSeparatedNodesSolver(e,n,solveMod)}],["pow",function pow(e,n){return twoCommaSeparatedNodesSolver(e,n,solvePow)}],["rem",function rem(e,n){return twoCommaSeparatedNodesSolver(e,n,solveRem)}],["round",function round(o,t){const r=resolveGlobalsAndConstants([...o.value.filter((n=>!e.isCommentNode(n)&&!e.isWhitespaceNode(n)))],t);let u="";const i=[],a=[];{let o=i;for(let t=0;t<r.length;t++){const l=r[t];if(!u&&0===i.length&&0===a.length&&e.isTokenNode(l)&&l.value[0]===n.TokenType.Ident){const e=toLowerCaseAZ(l.value[4].value);if(g.has(e)){u=e;continue}}if(e.isTokenNode(l)&&l.value[0]===n.TokenType.Comma){if(o===a)return-1;if(o===i&&u&&0===i.length)continue;if(o===i){o=a;continue}return-1}o.push(l)}}const l=solve(calc$1(new e.FunctionNode([n.TokenType.Function,"calc(",-1,-1,{value:"calc"}],[n.TokenType.CloseParen,")",-1,-1,void 0],i),t));if(-1===l)return-1;const s=solve(calc$1(new e.FunctionNode([n.TokenType.Function,"calc(",-1,-1,{value:"calc"}],[n.TokenType.CloseParen,")",-1,-1,void 0],a),t));if(-1===s)return-1;u||(u="nearest");return solveRound(o,u,l,s)}],["sign",function sign(e,n){return singleNodeSolver(e,n,solveSign)}],["sin",function sin(e,n){return singleNodeSolver(e,n,solveSin)}],["sqrt",function sqrt(e,n){return singleNodeSolver(e,n,solveSqrt)}],["tan",function tan(e,n){return singleNodeSolver(e,n,solveTan)}]]);function calc$1(o,t){const r=resolveGlobalsAndConstants([...o.value.filter((n=>!e.isCommentNode(n)&&!e.isWhitespaceNode(n)))],t);if(1===r.length&&e.isTokenNode(r[0]))return{inputs:[r[0]],operation:unary};let u=0;for(;u<r.length;){const o=r[u];if(e.isSimpleBlockNode(o)&&o.startToken[0]===n.TokenType.OpenParen){const e=calc$1(o,t);if(-1===e)return-1;r.splice(u,1,e)}else if(e.isFunctionNode(o)){const e=b.get(toLowerCaseAZ(o.getName()));if(!e)return-1;{const n=e(o,t);if(-1===n)return-1;r.splice(u,1,n)}}else u++}if(u=0,1===r.length&&isCalculation(r[0]))return r[0];for(;u<r.length;){const o=r[u];if(!o||!e.isTokenNode(o)&&!isCalculation(o)){u++;continue}const t=r[u+1];if(!t||!e.isTokenNode(t)){u++;continue}const i=t.value;if(i[0]!==n.TokenType.Delim||"*"!==i[4].value&&"/"!==i[4].value){u++;continue}const a=r[u+2];if(!a||!e.isTokenNode(a)&&!isCalculation(a))return-1;"*"!==i[4].value?"/"!==i[4].value?u++:r.splice(u,3,{inputs:[o,a],operation:division}):r.splice(u,3,{inputs:[o,a],operation:multiplication})}if(u=0,1===r.length&&isCalculation(r[0]))return r[0];for(;u<r.length;){const o=r[u];if(!o||!e.isTokenNode(o)&&!isCalculation(o)){u++;continue}const t=r[u+1];if(!t||!e.isTokenNode(t)){u++;continue}const i=t.value;if(i[0]!==n.TokenType.Delim||"+"!==i[4].value&&"-"!==i[4].value){u++;continue}const a=r[u+2];if(!a||!e.isTokenNode(a)&&!isCalculation(a))return-1;"+"!==i[4].value?"-"!==i[4].value?u++:r.splice(u,3,{inputs:[o,a],operation:subtraction}):r.splice(u,3,{inputs:[o,a],operation:addition})}return 1===r.length&&isCalculation(r[0])?r[0]:-1}function singleNodeSolver(o,t,r){const u=resolveGlobalsAndConstants([...o.value.filter((n=>!e.isCommentNode(n)&&!e.isWhitespaceNode(n)))],t),i=solve(calc$1(new e.FunctionNode([n.TokenType.Function,"calc(",-1,-1,{value:"calc"}],[n.TokenType.CloseParen,")",-1,-1,void 0],u),t));return-1===i?-1:r(o,i)}function twoCommaSeparatedNodesSolver(o,t,r){const u=resolveGlobalsAndConstants([...o.value.filter((n=>!e.isCommentNode(n)&&!e.isWhitespaceNode(n)))],t),i=[],a=[];{let o=i;for(let t=0;t<u.length;t++){const r=u[t];if(e.isTokenNode(r)&&r.value[0]===n.TokenType.Comma){if(o===a)return-1;if(o===i){o=a;continue}return-1}o.push(r)}}const l=solve(calc$1(new e.FunctionNode([n.TokenType.Function,"calc(",-1,-1,{value:"calc"}],[n.TokenType.CloseParen,")",-1,-1,void 0],i),t));if(-1===l)return-1;const s=solve(calc$1(new e.FunctionNode([n.TokenType.Function,"calc(",-1,-1,{value:"calc"}],[n.TokenType.CloseParen,")",-1,-1,void 0],a),t));return-1===s?-1:r(o,l,s)}function variadicNodesSolver(o,t,r){const u=resolveGlobalsAndConstants([...o.value.filter((n=>!e.isCommentNode(n)&&!e.isWhitespaceNode(n)))],t),i=[];{const o=[];let r=[];for(let t=0;t<u.length;t++){const i=u[t];e.isTokenNode(i)&&i.value[0]===n.TokenType.Comma?(o.push(r),r=[]):r.push(i)}o.push(r);for(let r=0;r<o.length;r++){if(0===o[r].length)return-1;const u=solve(calc$1(new e.FunctionNode([n.TokenType.Function,"calc(",-1,-1,{value:"calc"}],[n.TokenType.CloseParen,")",-1,-1,void 0],o[r]),t));if(-1===u)return-1;i.push(u)}}return r(o,i)}const g=new Set(["nearest","up","down","to-zero"]);function patchNaN(o){if(-1===o)return-1;if(e.isFunctionNode(o))return o;const t=o.value;return t[0]!==n.TokenType.Number&&t[0]!==n.TokenType.Percentage&&t[0]!==n.TokenType.Dimension?o:Number.isNaN(t[4].value)?t[0]===n.TokenType.Number?new e.FunctionNode([n.TokenType.Function,"calc(",t[2],t[3],{value:"calc"}],[n.TokenType.CloseParen,")",t[2],t[3],void 0],[new e.TokenNode([n.TokenType.Ident,"NaN",t[2],t[3],{value:"NaN"}])]):t[0]===n.TokenType.Dimension?new e.FunctionNode([n.TokenType.Function,"calc(",t[2],t[3],{value:"calc"}],[n.TokenType.CloseParen,")",t[2],t[3],void 0],[new e.TokenNode([n.TokenType.Ident,"NaN",t[2],t[3],{value:"NaN"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",t[2],t[3],void 0]]),new e.TokenNode([n.TokenType.Delim,"*",t[2],t[3],{value:"*"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",t[2],t[3],void 0]]),new e.TokenNode([n.TokenType.Dimension,"1"+t[4].unit,t[2],t[3],{value:1,type:n.NumberType.Integer,unit:t[4].unit}])]):t[0]===n.TokenType.Percentage?new e.FunctionNode([n.TokenType.Function,"calc(",t[2],t[3],{value:"calc"}],[n.TokenType.CloseParen,")",t[2],t[3],void 0],[new e.TokenNode([n.TokenType.Ident,"NaN",t[2],t[3],{value:"NaN"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",t[2],t[3],void 0]]),new e.TokenNode([n.TokenType.Delim,"*",t[2],t[3],{value:"*"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",t[2],t[3],void 0]]),new e.TokenNode([n.TokenType.Percentage,"1%",t[2],t[3],{value:1}])]):-1:o}function patchInfinity(o){if(-1===o)return-1;if(e.isFunctionNode(o))return o;const t=o.value;if(t[0]!==n.TokenType.Number&&t[0]!==n.TokenType.Percentage&&t[0]!==n.TokenType.Dimension)return o;if(Number.isFinite(t[4].value))return o;let r="";return Number.NEGATIVE_INFINITY===t[4].value&&(r="-"),t[0]===n.TokenType.Number?new e.FunctionNode([n.TokenType.Function,"calc(",t[2],t[3],{value:"calc"}],[n.TokenType.CloseParen,")",t[2],t[3],void 0],[new e.TokenNode([n.TokenType.Ident,r+"infinity",t[2],t[3],{value:r+"infinity"}])]):t[0]===n.TokenType.Dimension?new e.FunctionNode([n.TokenType.Function,"calc(",t[2],t[3],{value:"calc"}],[n.TokenType.CloseParen,")",t[2],t[3],void 0],[new e.TokenNode([n.TokenType.Ident,r+"infinity",t[2],t[3],{value:r+"infinity"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",t[2],t[3],void 0]]),new e.TokenNode([n.TokenType.Delim,"*",t[2],t[3],{value:"*"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",t[2],t[3],void 0]]),new e.TokenNode([n.TokenType.Dimension,"1"+t[4].unit,t[2],t[3],{value:1,type:n.NumberType.Integer,unit:t[4].unit}])]):t[0]===n.TokenType.Percentage?new e.FunctionNode([n.TokenType.Function,"calc(",t[2],t[3],{value:"calc"}],[n.TokenType.CloseParen,")",t[2],t[3],void 0],[new e.TokenNode([n.TokenType.Ident,r+"infinity",t[2],t[3],{value:r+"infinity"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",t[2],t[3],void 0]]),new e.TokenNode([n.TokenType.Delim,"*",t[2],t[3],{value:"*"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",t[2],t[3],void 0]]),new e.TokenNode([n.TokenType.Percentage,"1%",t[2],t[3],{value:1}])]):-1}function patchMinusZero(o){if(-1===o)return-1;if(e.isFunctionNode(o))return o;const t=o.value;return t[0]!==n.TokenType.Number&&t[0]!==n.TokenType.Percentage&&t[0]!==n.TokenType.Dimension?o:Object.is(-0,t[4].value)?("-0"===t[1]||(t[1]=`calc(-1 * ${t[1]})`),o):o}function patchPrecision(o,t=13){if(-1===o)return-1;if(e.isFunctionNode(o))return o;const r=o.value;if(r[0]!==n.TokenType.Number&&r[0]!==n.TokenType.Percentage&&r[0]!==n.TokenType.Dimension)return o;if(Number.isInteger(r[4].value))return o;const u=Number(r[4].value.toFixed(t)).toString();return r[0]===n.TokenType.Number?r[1]=u:r[0]===n.TokenType.Percentage?r[1]=u+"%":r[0]===n.TokenType.Dimension&&(r[1]=u+r[4].unit),o}function patchCanonicalUnit(o){return-1===o?-1:(e.isFunctionNode(o)||o.value[0]!==n.TokenType.Dimension||(o.value=toCanonicalUnit(o.value)),o)}function patchCalcResult(e,n){let o;return o=patchNaN(e),o=patchInfinity(o),null!=n&&n.toCanonicalUnits&&(o=patchCanonicalUnit(o)),o=patchPrecision(o,null==n?void 0:n.precision),o=patchMinusZero(o),o}function tokenizeGlobals(e){const o=new Map;if(!e)return o;for(const[t,r]of e)if(n.isToken(r))o.set(t,r);else if("string"!=typeof r);else{const e=n.tokenizer({css:r}),u=e.nextToken();if(e.nextToken(),!e.endOfFile())continue;if(!u)continue;if(u[0]!==n.TokenType.Number&&u[0]!==n.TokenType.Dimension&&u[0]!==n.TokenType.Percentage)continue;o.set(t,u)}return o}function calcFromComponentValues(n,o){const t=tokenizeGlobals(null==o?void 0:o.globals);return e.replaceComponentValues(n,(n=>{if(e.isFunctionNode(n)){const e=b.get(toLowerCaseAZ(n.getName()));if(e){const r=patchCalcResult(solve(e(n,t)),o);if(-1!==r)return r}}}))}const h=new Set(b.keys());exports.calc=function calc(o,t){return calcFromComponentValues(e.parseCommaSeparatedListOfComponentValues(n.tokenize({css:o}),{}),t).map((e=>e.map((e=>n.stringify(...e.tokens()))).join(""))).join(",")},exports.calcFromComponentValues=calcFromComponentValues,exports.mathFunctionNames=h; diff --git a/node_modules/@csstools/css-calc/dist/index.d.ts b/node_modules/@csstools/css-calc/dist/index.d.ts new file mode 100644 index 00000000..b7e6856b --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/index.d.ts @@ -0,0 +1,6 @@ +export type { conversionOptions } from './options'; +import type { conversionOptions } from './options'; +import { ComponentValue } from '@csstools/css-parser-algorithms'; +export declare function calc(css: string, options?: conversionOptions): string; +export declare function calcFromComponentValues(componentValuesList: Array<Array<ComponentValue>>, options?: conversionOptions): ComponentValue[][]; +export declare const mathFunctionNames: Set<string>; diff --git a/node_modules/@csstools/css-calc/dist/index.mjs b/node_modules/@csstools/css-calc/dist/index.mjs new file mode 100644 index 00000000..0bf6b70e --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/index.mjs @@ -0,0 +1 @@ +import{TokenNode as e,isTokenNode as n,isCommentNode as t,isWhitespaceNode as r,isSimpleBlockNode as u,isFunctionNode as i,FunctionNode as a,WhitespaceNode as o,parseCommaSeparatedListOfComponentValues as l,replaceComponentValues as c}from"@csstools/css-parser-algorithms";import{TokenType as s,NumberType as v,isToken as m,tokenizer as f,tokenize as p,stringify as N}from"@csstools/css-tokenizer";const g=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(g,(e=>String.fromCharCode(e.charCodeAt(0)+32)))}const b={cm:"px",in:"px",mm:"px",pc:"px",pt:"px",px:"px",q:"px",deg:"deg",grad:"deg",rad:"deg",turn:"deg",ms:"s",s:"s",hz:"hz",khz:"hz"},d=new Map([["cm",e=>e],["mm",e=>10*e],["q",e=>40*e],["in",e=>e/2.54],["pc",e=>e/2.54*6],["pt",e=>e/2.54*72],["px",e=>e/2.54*96]]),w=new Map([["deg",e=>e],["grad",e=>e/.9],["rad",e=>e/180*Math.PI],["turn",e=>e/360]]),h=new Map([["deg",e=>.9*e],["grad",e=>e],["rad",e=>.9*e/180*Math.PI],["turn",e=>.9*e/360]]),C=new Map([["hz",e=>e],["khz",e=>e/1e3]]),I=new Map([["cm",e=>2.54*e],["mm",e=>25.4*e],["q",e=>25.4*e*4],["in",e=>e],["pc",e=>6*e],["pt",e=>72*e],["px",e=>96*e]]),S=new Map([["hz",e=>1e3*e],["khz",e=>e]]),y=new Map([["cm",e=>e/10],["mm",e=>e],["q",e=>4*e],["in",e=>e/25.4],["pc",e=>e/25.4*6],["pt",e=>e/25.4*72],["px",e=>e/25.4*96]]),M=new Map([["ms",e=>e],["s",e=>e/1e3]]),P=new Map([["cm",e=>e/6*2.54],["mm",e=>e/6*25.4],["q",e=>e/6*25.4*4],["in",e=>e/6],["pc",e=>e],["pt",e=>e/6*72],["px",e=>e/6*96]]),D=new Map([["cm",e=>e/72*2.54],["mm",e=>e/72*25.4],["q",e=>e/72*25.4*4],["in",e=>e/72],["pc",e=>e/72*6],["pt",e=>e],["px",e=>e/72*96]]),T=new Map([["cm",e=>e/96*2.54],["mm",e=>e/96*25.4],["q",e=>e/96*25.4*4],["in",e=>e/96],["pc",e=>e/96*6],["pt",e=>e/96*72],["px",e=>e]]),A=new Map([["cm",e=>e/4/10],["mm",e=>e/4],["q",e=>e],["in",e=>e/4/25.4],["pc",e=>e/4/25.4*6],["pt",e=>e/4/25.4*72],["px",e=>e/4/25.4*96]]),k=new Map([["deg",e=>180*e/Math.PI],["grad",e=>180*e/Math.PI/.9],["rad",e=>e],["turn",e=>180*e/Math.PI/360]]),F=new Map([["ms",e=>1e3*e],["s",e=>e]]),x=new Map([["deg",e=>360*e],["grad",e=>360*e/.9],["rad",e=>360*e/180*Math.PI],["turn",e=>e]]),O=new Map([["cm",d],["mm",y],["q",A],["in",I],["pc",P],["pt",D],["px",T],["ms",M],["s",F],["deg",w],["grad",h],["rad",k],["turn",x],["hz",C],["khz",S]]);function convertUnit(e,n){if(e[0]!==s.Dimension)return n;if(n[0]!==s.Dimension)return n;const t=toLowerCaseAZ(e[4].unit),r=toLowerCaseAZ(n[4].unit);if(t===r)return n;const u=O.get(r);if(!u)return n;const i=u.get(t);if(!i)return n;const a=i(n[4].value);return[s.Dimension,a.toString()+e[4].unit,n[2],n[3],{value:a,unit:e[4].unit,type:Number.isInteger(a)?v.Integer:v.Number}]}function toCanonicalUnit(e){if(e[0]!==s.Dimension)return e;const n=toLowerCaseAZ(e[4].unit),t=b[n];if(n===t)return e;const r=O.get(n);if(!r)return e;const u=r.get(t);if(!u)return e;const i=u(e[4].value);return[s.Dimension,i.toString()+t,e[2],e[3],{value:i,unit:t,type:Number.isInteger(i)?v.Integer:v.Number}]}function addition(n){if(2!==n.length)return-1;const t=n[0].value;let r=n[1].value;if(t[0]===s.Number&&r[0]===s.Number){const n=t[4].value+r[4].value;return new e([s.Number,n.toString(),t[2],r[3],{value:n,type:t[4].type===v.Integer&&r[4].type===v.Integer?v.Integer:v.Number}])}if(t[0]===s.Percentage&&r[0]===s.Percentage){const n=t[4].value+r[4].value;return new e([s.Percentage,n.toString()+"%",t[2],r[3],{value:n}])}if(t[0]===s.Dimension&&r[0]===s.Dimension&&(r=convertUnit(t,r),toLowerCaseAZ(t[4].unit)===toLowerCaseAZ(r[4].unit))){const n=t[4].value+r[4].value;return new e([s.Dimension,n.toString()+t[4].unit,t[2],r[3],{value:n,type:t[4].type===v.Integer&&r[4].type===v.Integer?v.Integer:v.Number,unit:t[4].unit}])}return-1}function division(n){if(2!==n.length)return-1;const t=n[0].value,r=n[1].value;if(t[0]===s.Number&&r[0]===s.Number){const n=t[4].value/r[4].value;return new e([s.Number,n.toString(),t[2],r[3],{value:n,type:Number.isInteger(n)?v.Integer:v.Number}])}if(t[0]===s.Percentage&&r[0]===s.Number){const n=t[4].value/r[4].value;return new e([s.Percentage,n.toString()+"%",t[2],r[3],{value:n}])}if(t[0]===s.Dimension&&r[0]===s.Number){const n=t[4].value/r[4].value;return new e([s.Dimension,n.toString()+t[4].unit,t[2],r[3],{value:n,type:Number.isInteger(n)?v.Integer:v.Number,unit:t[4].unit}])}return-1}function isCalculation(e){return!!e&&"object"==typeof e&&"inputs"in e&&Array.isArray(e.inputs)&&"operation"in e}function solve(e){if(-1===e)return-1;const t=[];for(let r=0;r<e.inputs.length;r++){const u=e.inputs[r];if(n(u)){t.push(u);continue}const i=solve(u);if(-1===i)return-1;t.push(i)}return e.operation(t)}function multiplication(n){if(2!==n.length)return-1;const t=n[0].value,r=n[1].value;if(t[0]===s.Number&&r[0]===s.Number){const n=t[4].value*r[4].value;return new e([s.Number,n.toString(),t[2],r[3],{value:n,type:t[4].type===v.Integer&&r[4].type===v.Integer?v.Integer:v.Number}])}if(t[0]===s.Percentage&&r[0]===s.Number){const n=t[4].value*r[4].value;return new e([s.Percentage,n.toString()+"%",t[2],r[3],{value:n}])}if(t[0]===s.Number&&r[0]===s.Percentage){const n=t[4].value*r[4].value;return new e([s.Percentage,n.toString()+"%",t[2],r[3],{value:n}])}if(t[0]===s.Dimension&&r[0]===s.Number){const n=t[4].value*r[4].value;return new e([s.Dimension,n.toString()+t[4].unit,t[2],r[3],{value:n,type:t[4].type===v.Integer&&r[4].type===v.Integer?v.Integer:v.Number,unit:t[4].unit}])}if(t[0]===s.Number&&r[0]===s.Dimension){const n=t[4].value*r[4].value;return new e([s.Dimension,n.toString()+r[4].unit,t[2],r[3],{value:n,type:t[4].type===v.Integer&&r[4].type===v.Integer?v.Integer:v.Number,unit:r[4].unit}])}return-1}function resolveGlobalsAndConstants(t,r){for(let u=0;u<t.length;u++){const i=t[u];if(!n(i))continue;const a=i.value;if(a[0]!==s.Ident)continue;const o=toLowerCaseAZ(a[4].value);switch(o){case"e":t.splice(u,1,new e([s.Number,Math.E.toString(),a[2],a[3],{value:Math.E,type:v.Number}]));break;case"pi":t.splice(u,1,new e([s.Number,Math.PI.toString(),a[2],a[3],{value:Math.PI,type:v.Number}]));break;case"infinity":t.splice(u,1,new e([s.Number,"infinity",a[2],a[3],{value:1/0,type:v.Number}]));break;case"-infinity":t.splice(u,1,new e([s.Number,"-infinity",a[2],a[3],{value:-1/0,type:v.Number}]));break;case"nan":t.splice(u,1,new e([s.Number,"NaN",a[2],a[3],{value:Number.NaN,type:v.Number}]));break;default:if(r.has(o)){const n=r.get(o);t.splice(u,1,new e(n))}}}return t}function isNumeric(e){return e[0]===s.Dimension||(e[0]===s.Percentage||e[0]===s.Number)}function isDimensionOrNumber(e){return e[0]===s.Dimension||e[0]===s.Number}function arrayOfSameNumeric(e){if(0===e.length)return!0;const n=e[0];if(!isNumeric(n))return!1;if(1===e.length)return!0;if(n[0]===s.Dimension){const t=toLowerCaseAZ(n[4].unit);for(let r=1;r<e.length;r++){const u=e[r];if(n[0]!==u[0])return!1;if(t!==toLowerCaseAZ(u[4].unit))return!1}return!0}for(let t=1;t<e.length;t++){const r=e[t];if(n[0]!==r[0])return!1}return!0}function twoOfSameNumeric(e,n){return!!isNumeric(e)&&(e[0]===s.Dimension?e[0]===n[0]&&toLowerCaseAZ(e[4].unit)===toLowerCaseAZ(n[4].unit):e[0]===n[0])}function unary(e){if(1!==e.length)return-1;return isNumeric(e[0].value)?e[0]:-1}function resultToCalculation(e,n,t){return n[0]===s.Dimension?dimensionToCalculation(e,n[4].unit,t):n[0]===s.Percentage?percentageToCalculation(e,t):n[0]===s.Number?numberToCalculation(e,t):-1}function dimensionToCalculation(n,t,r){const u=n.tokens();return{inputs:[new e([s.Dimension,r.toString()+t,u[0][2],u[u.length-1][3],{value:r,type:Number.isInteger(r)?v.Integer:v.Number,unit:t}])],operation:unary}}function percentageToCalculation(n,t){const r=n.tokens();return{inputs:[new e([s.Percentage,t.toString()+"%",r[0][2],r[r.length-1][3],{value:t}])],operation:unary}}function numberToCalculation(n,t){const r=n.tokens();return{inputs:[new e([s.Number,t.toString(),r[0][2],r[r.length-1][3],{value:t,type:Number.isInteger(t)?v.Integer:v.Number}])],operation:unary}}function solveACos(e,n){const t=n.value;if(t[0]!==s.Number)return-1;return dimensionToCalculation(e,"rad",Math.acos(t[4].value))}function solveASin(e,n){const t=n.value;if(t[0]!==s.Number)return-1;return dimensionToCalculation(e,"rad",Math.asin(t[4].value))}function solveATan(e,n){const t=n.value;if(t[0]!==s.Number)return-1;return dimensionToCalculation(e,"rad",Math.atan(t[4].value))}function solveATan2(e,n,t){const r=n.value;if(!isDimensionOrNumber(r))return-1;const u=convertUnit(r,t.value);if(!twoOfSameNumeric(r,u))return-1;return dimensionToCalculation(e,"rad",Math.atan2(r[4].value,u[4].value))}function solveAbs(e,n){const t=n.value;if(!isDimensionOrNumber(t))return-1;return resultToCalculation(e,t,Math.abs(t[4].value))}function solveClamp(e,t,r,u){if(!n(t)||!n(r)||!n(u))return-1;const i=t.value;if(!isNumeric(i))return-1;const a=convertUnit(i,r.value);if(!twoOfSameNumeric(i,a))return-1;const o=convertUnit(i,u.value);if(!twoOfSameNumeric(i,o))return-1;return resultToCalculation(e,i,Math.max(i[4].value,Math.min(a[4].value,o[4].value)))}function solveCos(e,n){const t=n.value;if(!isDimensionOrNumber(t))return-1;let r=t[4].value;if(t[0]===s.Dimension)switch(toLowerCaseAZ(t[4].unit)){case"rad":break;case"deg":r=w.get("rad")(t[4].value);break;case"grad":r=h.get("rad")(t[4].value);break;case"turn":r=x.get("rad")(t[4].value);break;default:return-1}return r=Math.cos(r),numberToCalculation(e,r)}function solveExp(e,n){const t=n.value;if(t[0]!==s.Number)return-1;return numberToCalculation(e,Math.exp(t[4].value))}function solveHypot(e,t){const r=t[0];if(!r||!n(r))return-1;if(1!==new Set(t.map((e=>e.type))).size)return-1;const u=r.value;if(!isNumeric(u))return-1;const i=t.map((e=>convertUnit(u,e.value)));if(!arrayOfSameNumeric(i))return-1;const a=i.map((e=>e[4].value)),o=Math.hypot(...a);return resultToCalculation(e,u,o)}function solveMax(e,t){const r=t[0];if(!r||!n(r))return-1;if(1!==new Set(t.map((e=>e.type))).size)return-1;const u=r.value;if(!isNumeric(u))return-1;const i=t.map((e=>convertUnit(u,e.value)));if(!arrayOfSameNumeric(i))return-1;const a=i.map((e=>e[4].value)),o=Math.max(...a);return resultToCalculation(e,u,o)}function solveMin(e,t){const r=t[0];if(!r||!n(r))return-1;if(1!==new Set(t.map((e=>e.type))).size)return-1;const u=r.value;if(!isNumeric(u))return-1;const i=t.map((e=>convertUnit(u,e.value)));if(!arrayOfSameNumeric(i))return-1;const a=i.map((e=>e[4].value)),o=Math.min(...a);return resultToCalculation(e,u,o)}function solveMod(e,n,t){const r=n.value;if(!isNumeric(r))return-1;const u=convertUnit(r,t.value);if(!twoOfSameNumeric(r,u))return-1;let i;return i=0===u[4].value?Number.NaN:Number.isFinite(r[4].value)&&(Number.isFinite(u[4].value)||(u[4].value!==Number.POSITIVE_INFINITY||r[4].value!==Number.NEGATIVE_INFINITY&&!Object.is(0*r[4].value,-0))&&(u[4].value!==Number.NEGATIVE_INFINITY||r[4].value!==Number.POSITIVE_INFINITY&&!Object.is(0*r[4].value,0)))?Number.isFinite(u[4].value)?(r[4].value%u[4].value+u[4].value)%u[4].value:r[4].value:Number.NaN,resultToCalculation(e,r,i)}function solvePow(e,n,t){const r=n.value,u=t.value;if(r[0]!==s.Number)return-1;if(!twoOfSameNumeric(r,u))return-1;return numberToCalculation(e,Math.pow(r[4].value,u[4].value))}function solveRem(e,n,t){const r=n.value;if(!isNumeric(r))return-1;const u=convertUnit(r,t.value);if(!twoOfSameNumeric(r,u))return-1;let i;return i=0===u[4].value?Number.NaN:Number.isFinite(r[4].value)?Number.isFinite(u[4].value)?r[4].value%u[4].value:r[4].value:Number.NaN,resultToCalculation(e,r,i)}function solveRound(e,n,t,r){const u=t.value;if(!isNumeric(u))return-1;const i=convertUnit(u,r.value);if(!twoOfSameNumeric(u,i))return-1;let a;if(0===i[4].value)a=Number.NaN;else if(Number.isFinite(u[4].value)||Number.isFinite(i[4].value))if(!Number.isFinite(u[4].value)&&Number.isFinite(i[4].value))a=u[4].value;else if(Number.isFinite(u[4].value)&&!Number.isFinite(i[4].value))switch(n){case"down":a=u[4].value<0?-1/0:Object.is(-0,0*u[4].value)?-0:0;break;case"up":a=u[4].value>0?1/0:Object.is(0,0*u[4].value)?0:-0;break;default:a=Object.is(0,0*u[4].value)?0:-0}else if(Number.isFinite(i[4].value))switch(n){case"down":a=Math.floor(u[4].value/i[4].value)*i[4].value;break;case"up":a=Math.ceil(u[4].value/i[4].value)*i[4].value;break;case"to-zero":a=Math.trunc(u[4].value/i[4].value)*i[4].value;break;default:{let e=Math.floor(u[4].value/i[4].value)*i[4].value,n=Math.ceil(u[4].value/i[4].value)*i[4].value;if(e>n){const t=e;e=n,n=t}const t=Math.abs(u[4].value-e),r=Math.abs(u[4].value-n);a=t===r?n:t<r?e:n;break}}else a=u[4].value;else a=Number.NaN;return resultToCalculation(e,u,a)}function solveSign(e,n){const t=n.value;if(!isDimensionOrNumber(t))return-1;return numberToCalculation(e,Math.sign(t[4].value))}function solveSin(e,n){const t=n.value;if(!isDimensionOrNumber(t))return-1;let r=t[4].value;if(t[0]===s.Dimension)switch(toLowerCaseAZ(t[4].unit)){case"rad":break;case"deg":r=w.get("rad")(t[4].value);break;case"grad":r=h.get("rad")(t[4].value);break;case"turn":r=x.get("rad")(t[4].value);break;default:return-1}return r=Math.sin(r),numberToCalculation(e,r)}function solveSqrt(e,n){const t=n.value;if(t[0]!==s.Number)return-1;return numberToCalculation(e,Math.sqrt(t[4].value))}function solveTan(e,n){const t=n.value;if(!isDimensionOrNumber(t))return-1;const r=t[4].value;let u=0,i=t[4].value;if(t[0]===s.Dimension)switch(toLowerCaseAZ(t[4].unit)){case"rad":u=k.get("deg")(r);break;case"deg":u=r,i=w.get("rad")(r);break;case"grad":u=h.get("deg")(r),i=h.get("rad")(r);break;case"turn":u=x.get("deg")(r),i=x.get("rad")(r);break;default:return-1}const a=u/90;return i=u%90==0&&a%2!=0?a>0?1/0:-1/0:Math.tan(i),numberToCalculation(e,i)}function subtraction(n){if(2!==n.length)return-1;const t=n[0].value;let r=n[1].value;if(t[0]===s.Number&&r[0]===s.Number){const n=t[4].value-r[4].value;return new e([s.Number,n.toString(),t[2],r[3],{value:n,type:t[4].type===v.Integer&&r[4].type===v.Integer?v.Integer:v.Number}])}if(t[0]===s.Percentage&&r[0]===s.Percentage){const n=t[4].value-r[4].value;return new e([s.Percentage,n.toString()+"%",t[2],r[3],{value:n}])}if(t[0]===s.Dimension&&r[0]===s.Dimension&&(r=convertUnit(t,r),toLowerCaseAZ(t[4].unit)===toLowerCaseAZ(r[4].unit))){const n=t[4].value-r[4].value;return new e([s.Dimension,n.toString()+t[4].unit,t[2],r[3],{value:n,type:t[4].type===v.Integer&&r[4].type===v.Integer?v.Integer:v.Number,unit:t[4].unit}])}return-1}function solveLog(e,t){if(1===t.length){const r=t[0];if(!r||!n(r))return-1;const u=r.value;if(u[0]!==s.Number)return-1;return numberToCalculation(e,Math.log(u[4].value))}if(2===t.length){const r=t[0];if(!r||!n(r))return-1;const u=r.value;if(u[0]!==s.Number)return-1;const i=t[1];if(!i||!n(i))return-1;const a=i.value;if(a[0]!==s.Number)return-1;return numberToCalculation(e,Math.log(u[4].value)/Math.log(a[4].value))}return-1}const Z=new Map([["abs",function abs(e,n){return singleNodeSolver(e,n,solveAbs)}],["acos",function acos(e,n){return singleNodeSolver(e,n,solveACos)}],["asin",function asin(e,n){return singleNodeSolver(e,n,solveASin)}],["atan",function atan(e,n){return singleNodeSolver(e,n,solveATan)}],["atan2",function atan2(e,n){return twoCommaSeparatedNodesSolver(e,n,solveATan2)}],["calc",calc$1],["clamp",function clamp(e,u){const i=resolveGlobalsAndConstants([...e.value.filter((e=>!t(e)&&!r(e)))],u),o=[],l=[],c=[];{let e=o;for(let t=0;t<i.length;t++){const r=i[t];if(n(r)&&r.value[0]===s.Comma){if(e===c)return-1;if(e===l){e=c;continue}if(e===o){e=l;continue}return-1}e.push(r)}}const v=solve(calc$1(new a([s.Function,"calc(",-1,-1,{value:"calc"}],[s.CloseParen,")",-1,-1,void 0],o),u));if(-1===v)return-1;const m=solve(calc$1(new a([s.Function,"calc(",-1,-1,{value:"calc"}],[s.CloseParen,")",-1,-1,void 0],l),u));if(-1===m)return-1;const f=solve(calc$1(new a([s.Function,"calc(",-1,-1,{value:"calc"}],[s.CloseParen,")",-1,-1,void 0],c),u));if(-1===f)return-1;return solveClamp(e,v,m,f)}],["cos",function cos(e,n){return singleNodeSolver(e,n,solveCos)}],["exp",function exp(e,n){return singleNodeSolver(e,n,solveExp)}],["hypot",function hypot(e,n){return variadicNodesSolver(e,n,solveHypot)}],["log",function log(e,n){return variadicNodesSolver(e,n,solveLog)}],["max",function max(e,n){return variadicNodesSolver(e,n,solveMax)}],["min",function min(e,n){return variadicNodesSolver(e,n,solveMin)}],["mod",function mod(e,n){return twoCommaSeparatedNodesSolver(e,n,solveMod)}],["pow",function pow(e,n){return twoCommaSeparatedNodesSolver(e,n,solvePow)}],["rem",function rem(e,n){return twoCommaSeparatedNodesSolver(e,n,solveRem)}],["round",function round(e,u){const i=resolveGlobalsAndConstants([...e.value.filter((e=>!t(e)&&!r(e)))],u);let o="";const l=[],c=[];{let e=l;for(let t=0;t<i.length;t++){const r=i[t];if(!o&&0===l.length&&0===c.length&&n(r)&&r.value[0]===s.Ident){const e=toLowerCaseAZ(r.value[4].value);if(L.has(e)){o=e;continue}}if(n(r)&&r.value[0]===s.Comma){if(e===c)return-1;if(e===l&&o&&0===l.length)continue;if(e===l){e=c;continue}return-1}e.push(r)}}const v=solve(calc$1(new a([s.Function,"calc(",-1,-1,{value:"calc"}],[s.CloseParen,")",-1,-1,void 0],l),u));if(-1===v)return-1;const m=solve(calc$1(new a([s.Function,"calc(",-1,-1,{value:"calc"}],[s.CloseParen,")",-1,-1,void 0],c),u));if(-1===m)return-1;o||(o="nearest");return solveRound(e,o,v,m)}],["sign",function sign(e,n){return singleNodeSolver(e,n,solveSign)}],["sin",function sin(e,n){return singleNodeSolver(e,n,solveSin)}],["sqrt",function sqrt(e,n){return singleNodeSolver(e,n,solveSqrt)}],["tan",function tan(e,n){return singleNodeSolver(e,n,solveTan)}]]);function calc$1(e,a){const o=resolveGlobalsAndConstants([...e.value.filter((e=>!t(e)&&!r(e)))],a);if(1===o.length&&n(o[0]))return{inputs:[o[0]],operation:unary};let l=0;for(;l<o.length;){const e=o[l];if(u(e)&&e.startToken[0]===s.OpenParen){const n=calc$1(e,a);if(-1===n)return-1;o.splice(l,1,n)}else if(i(e)){const n=Z.get(toLowerCaseAZ(e.getName()));if(!n)return-1;{const t=n(e,a);if(-1===t)return-1;o.splice(l,1,t)}}else l++}if(l=0,1===o.length&&isCalculation(o[0]))return o[0];for(;l<o.length;){const e=o[l];if(!e||!n(e)&&!isCalculation(e)){l++;continue}const t=o[l+1];if(!t||!n(t)){l++;continue}const r=t.value;if(r[0]!==s.Delim||"*"!==r[4].value&&"/"!==r[4].value){l++;continue}const u=o[l+2];if(!u||!n(u)&&!isCalculation(u))return-1;"*"!==r[4].value?"/"!==r[4].value?l++:o.splice(l,3,{inputs:[e,u],operation:division}):o.splice(l,3,{inputs:[e,u],operation:multiplication})}if(l=0,1===o.length&&isCalculation(o[0]))return o[0];for(;l<o.length;){const e=o[l];if(!e||!n(e)&&!isCalculation(e)){l++;continue}const t=o[l+1];if(!t||!n(t)){l++;continue}const r=t.value;if(r[0]!==s.Delim||"+"!==r[4].value&&"-"!==r[4].value){l++;continue}const u=o[l+2];if(!u||!n(u)&&!isCalculation(u))return-1;"+"!==r[4].value?"-"!==r[4].value?l++:o.splice(l,3,{inputs:[e,u],operation:subtraction}):o.splice(l,3,{inputs:[e,u],operation:addition})}return 1===o.length&&isCalculation(o[0])?o[0]:-1}function singleNodeSolver(e,n,u){const i=resolveGlobalsAndConstants([...e.value.filter((e=>!t(e)&&!r(e)))],n),o=solve(calc$1(new a([s.Function,"calc(",-1,-1,{value:"calc"}],[s.CloseParen,")",-1,-1,void 0],i),n));return-1===o?-1:u(e,o)}function twoCommaSeparatedNodesSolver(e,u,i){const o=resolveGlobalsAndConstants([...e.value.filter((e=>!t(e)&&!r(e)))],u),l=[],c=[];{let e=l;for(let t=0;t<o.length;t++){const r=o[t];if(n(r)&&r.value[0]===s.Comma){if(e===c)return-1;if(e===l){e=c;continue}return-1}e.push(r)}}const v=solve(calc$1(new a([s.Function,"calc(",-1,-1,{value:"calc"}],[s.CloseParen,")",-1,-1,void 0],l),u));if(-1===v)return-1;const m=solve(calc$1(new a([s.Function,"calc(",-1,-1,{value:"calc"}],[s.CloseParen,")",-1,-1,void 0],c),u));return-1===m?-1:i(e,v,m)}function variadicNodesSolver(e,u,i){const o=resolveGlobalsAndConstants([...e.value.filter((e=>!t(e)&&!r(e)))],u),l=[];{const e=[];let t=[];for(let r=0;r<o.length;r++){const u=o[r];n(u)&&u.value[0]===s.Comma?(e.push(t),t=[]):t.push(u)}e.push(t);for(let n=0;n<e.length;n++){if(0===e[n].length)return-1;const t=solve(calc$1(new a([s.Function,"calc(",-1,-1,{value:"calc"}],[s.CloseParen,")",-1,-1,void 0],e[n]),u));if(-1===t)return-1;l.push(t)}}return i(e,l)}const L=new Set(["nearest","up","down","to-zero"]);function patchNaN(n){if(-1===n)return-1;if(i(n))return n;const t=n.value;return t[0]!==s.Number&&t[0]!==s.Percentage&&t[0]!==s.Dimension?n:Number.isNaN(t[4].value)?t[0]===s.Number?new a([s.Function,"calc(",t[2],t[3],{value:"calc"}],[s.CloseParen,")",t[2],t[3],void 0],[new e([s.Ident,"NaN",t[2],t[3],{value:"NaN"}])]):t[0]===s.Dimension?new a([s.Function,"calc(",t[2],t[3],{value:"calc"}],[s.CloseParen,")",t[2],t[3],void 0],[new e([s.Ident,"NaN",t[2],t[3],{value:"NaN"}]),new o([[s.Whitespace," ",t[2],t[3],void 0]]),new e([s.Delim,"*",t[2],t[3],{value:"*"}]),new o([[s.Whitespace," ",t[2],t[3],void 0]]),new e([s.Dimension,"1"+t[4].unit,t[2],t[3],{value:1,type:v.Integer,unit:t[4].unit}])]):t[0]===s.Percentage?new a([s.Function,"calc(",t[2],t[3],{value:"calc"}],[s.CloseParen,")",t[2],t[3],void 0],[new e([s.Ident,"NaN",t[2],t[3],{value:"NaN"}]),new o([[s.Whitespace," ",t[2],t[3],void 0]]),new e([s.Delim,"*",t[2],t[3],{value:"*"}]),new o([[s.Whitespace," ",t[2],t[3],void 0]]),new e([s.Percentage,"1%",t[2],t[3],{value:1}])]):-1:n}function patchInfinity(n){if(-1===n)return-1;if(i(n))return n;const t=n.value;if(t[0]!==s.Number&&t[0]!==s.Percentage&&t[0]!==s.Dimension)return n;if(Number.isFinite(t[4].value))return n;let r="";return Number.NEGATIVE_INFINITY===t[4].value&&(r="-"),t[0]===s.Number?new a([s.Function,"calc(",t[2],t[3],{value:"calc"}],[s.CloseParen,")",t[2],t[3],void 0],[new e([s.Ident,r+"infinity",t[2],t[3],{value:r+"infinity"}])]):t[0]===s.Dimension?new a([s.Function,"calc(",t[2],t[3],{value:"calc"}],[s.CloseParen,")",t[2],t[3],void 0],[new e([s.Ident,r+"infinity",t[2],t[3],{value:r+"infinity"}]),new o([[s.Whitespace," ",t[2],t[3],void 0]]),new e([s.Delim,"*",t[2],t[3],{value:"*"}]),new o([[s.Whitespace," ",t[2],t[3],void 0]]),new e([s.Dimension,"1"+t[4].unit,t[2],t[3],{value:1,type:v.Integer,unit:t[4].unit}])]):t[0]===s.Percentage?new a([s.Function,"calc(",t[2],t[3],{value:"calc"}],[s.CloseParen,")",t[2],t[3],void 0],[new e([s.Ident,r+"infinity",t[2],t[3],{value:r+"infinity"}]),new o([[s.Whitespace," ",t[2],t[3],void 0]]),new e([s.Delim,"*",t[2],t[3],{value:"*"}]),new o([[s.Whitespace," ",t[2],t[3],void 0]]),new e([s.Percentage,"1%",t[2],t[3],{value:1}])]):-1}function patchMinusZero(e){if(-1===e)return-1;if(i(e))return e;const n=e.value;return n[0]!==s.Number&&n[0]!==s.Percentage&&n[0]!==s.Dimension?e:Object.is(-0,n[4].value)?("-0"===n[1]||(n[1]=`calc(-1 * ${n[1]})`),e):e}function patchPrecision(e,n=13){if(-1===e)return-1;if(i(e))return e;const t=e.value;if(t[0]!==s.Number&&t[0]!==s.Percentage&&t[0]!==s.Dimension)return e;if(Number.isInteger(t[4].value))return e;const r=Number(t[4].value.toFixed(n)).toString();return t[0]===s.Number?t[1]=r:t[0]===s.Percentage?t[1]=r+"%":t[0]===s.Dimension&&(t[1]=r+t[4].unit),e}function patchCanonicalUnit(e){return-1===e?-1:(i(e)||e.value[0]!==s.Dimension||(e.value=toCanonicalUnit(e.value)),e)}function patchCalcResult(e,n){let t;return t=patchNaN(e),t=patchInfinity(t),null!=n&&n.toCanonicalUnits&&(t=patchCanonicalUnit(t)),t=patchPrecision(t,null==n?void 0:n.precision),t=patchMinusZero(t),t}function tokenizeGlobals(e){const n=new Map;if(!e)return n;for(const[t,r]of e)if(m(r))n.set(t,r);else if("string"!=typeof r);else{const e=f({css:r}),u=e.nextToken();if(e.nextToken(),!e.endOfFile())continue;if(!u)continue;if(u[0]!==s.Number&&u[0]!==s.Dimension&&u[0]!==s.Percentage)continue;n.set(t,u)}return n}function calc(e,n){return calcFromComponentValues(l(p({css:e}),{}),n).map((e=>e.map((e=>N(...e.tokens()))).join(""))).join(",")}function calcFromComponentValues(e,n){const t=tokenizeGlobals(null==n?void 0:n.globals);return c(e,(e=>{if(i(e)){const r=Z.get(toLowerCaseAZ(e.getName()));if(r){const u=patchCalcResult(solve(r(e,t)),n);if(-1!==u)return u}}}))}const z=new Set(Z.keys());export{calc,calcFromComponentValues,z as mathFunctionNames}; diff --git a/node_modules/@csstools/css-calc/dist/operation/addition.d.ts b/node_modules/@csstools/css-calc/dist/operation/addition.d.ts new file mode 100644 index 00000000..70e02cfd --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/operation/addition.d.ts @@ -0,0 +1,2 @@ +import { TokenNode } from '@csstools/css-parser-algorithms'; +export declare function addition(inputs: Array<TokenNode>): TokenNode | -1; diff --git a/node_modules/@csstools/css-calc/dist/operation/division.d.ts b/node_modules/@csstools/css-calc/dist/operation/division.d.ts new file mode 100644 index 00000000..5d6b01fd --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/operation/division.d.ts @@ -0,0 +1,2 @@ +import { TokenNode } from '@csstools/css-parser-algorithms'; +export declare function division(inputs: Array<TokenNode>): TokenNode | -1; diff --git a/node_modules/@csstools/css-calc/dist/operation/multiplication.d.ts b/node_modules/@csstools/css-calc/dist/operation/multiplication.d.ts new file mode 100644 index 00000000..d48978d6 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/operation/multiplication.d.ts @@ -0,0 +1,2 @@ +import { TokenNode } from '@csstools/css-parser-algorithms'; +export declare function multiplication(inputs: Array<TokenNode>): TokenNode | -1; diff --git a/node_modules/@csstools/css-calc/dist/operation/operation.d.ts b/node_modules/@csstools/css-calc/dist/operation/operation.d.ts new file mode 100644 index 00000000..aed9e0e3 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/operation/operation.d.ts @@ -0,0 +1,2 @@ +import type { TokenNode } from '@csstools/css-parser-algorithms'; +export type Operation = (inputs: Array<TokenNode>) => TokenNode | -1; diff --git a/node_modules/@csstools/css-calc/dist/operation/subtraction.d.ts b/node_modules/@csstools/css-calc/dist/operation/subtraction.d.ts new file mode 100644 index 00000000..0ac3f6be --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/operation/subtraction.d.ts @@ -0,0 +1,2 @@ +import { TokenNode } from '@csstools/css-parser-algorithms'; +export declare function subtraction(inputs: Array<TokenNode>): TokenNode | -1; diff --git a/node_modules/@csstools/css-calc/dist/operation/unary.d.ts b/node_modules/@csstools/css-calc/dist/operation/unary.d.ts new file mode 100644 index 00000000..b27463ec --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/operation/unary.d.ts @@ -0,0 +1,2 @@ +import type { TokenNode } from '@csstools/css-parser-algorithms'; +export declare function unary(inputs: Array<TokenNode>): TokenNode | -1; diff --git a/node_modules/@csstools/css-calc/dist/options.d.ts b/node_modules/@csstools/css-calc/dist/options.d.ts new file mode 100644 index 00000000..f24a05fd --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/options.d.ts @@ -0,0 +1,23 @@ +import { GlobalsWithStrings } from './util/globals'; +export type conversionOptions = { + /** + * Pass global values as a map of key value pairs. + */ + globals?: GlobalsWithStrings; + /** + * The default precision is fairly high. + * It aims to be high enough to make rounding unnoticeable in the browser. + * You can set it to a lower number to suite your needs. + */ + precision?: number; + /** + * By default this package will try to preserve units. + * The heuristic to do this is very simplistic. + * We take the first unit we encounter and try to convert other dimensions to that unit. + * + * This better matches what users expect from a CSS dev tool. + * + * If you want to have outputs that are closes to CSS serialized values you can set `true`. + */ + toCanonicalUnits?: boolean; +}; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/canonical.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/canonical.d.ts new file mode 100644 index 00000000..1c593d50 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/canonical.d.ts @@ -0,0 +1 @@ +export declare const canonicalUnits: Record<string, string>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/cm.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/cm.d.ts new file mode 100644 index 00000000..030a42d8 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/cm.d.ts @@ -0,0 +1 @@ +export declare const convert_cm: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/deg.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/deg.d.ts new file mode 100644 index 00000000..7e0fb6c0 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/deg.d.ts @@ -0,0 +1 @@ +export declare const convert_deg: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/grad.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/grad.d.ts new file mode 100644 index 00000000..9423ffcf --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/grad.d.ts @@ -0,0 +1 @@ +export declare const convert_grad: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/hz.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/hz.d.ts new file mode 100644 index 00000000..9957a80e --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/hz.d.ts @@ -0,0 +1 @@ +export declare const convert_hz: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/in.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/in.d.ts new file mode 100644 index 00000000..5bf4ed81 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/in.d.ts @@ -0,0 +1 @@ +export declare const convert_in: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/index.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/index.d.ts new file mode 100644 index 00000000..e9a5468b --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/index.d.ts @@ -0,0 +1,4 @@ +import type { CSSToken } from '@csstools/css-tokenizer'; +export declare const conversions: Map<string, Map<string, (number: number) => number>>; +export declare function convertUnit<T extends CSSToken>(a: CSSToken, b: T): T; +export declare function toCanonicalUnit<T extends CSSToken>(a: T): T; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/khz.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/khz.d.ts new file mode 100644 index 00000000..c1df1229 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/khz.d.ts @@ -0,0 +1 @@ +export declare const convert_khz: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/mm.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/mm.d.ts new file mode 100644 index 00000000..570b2447 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/mm.d.ts @@ -0,0 +1 @@ +export declare const convert_mm: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/ms.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/ms.d.ts new file mode 100644 index 00000000..68d9231d --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/ms.d.ts @@ -0,0 +1 @@ +export declare const convert_ms: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/pc.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/pc.d.ts new file mode 100644 index 00000000..d13b7da9 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/pc.d.ts @@ -0,0 +1 @@ +export declare const convert_pc: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/pt.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/pt.d.ts new file mode 100644 index 00000000..09407c95 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/pt.d.ts @@ -0,0 +1 @@ +export declare const convert_pt: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/px.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/px.d.ts new file mode 100644 index 00000000..641ea77f --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/px.d.ts @@ -0,0 +1 @@ +export declare const convert_px: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/q.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/q.d.ts new file mode 100644 index 00000000..5862e51d --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/q.d.ts @@ -0,0 +1 @@ +export declare const convert_q: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/rad.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/rad.d.ts new file mode 100644 index 00000000..70faf8e9 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/rad.d.ts @@ -0,0 +1 @@ +export declare const convert_rad: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/s.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/s.d.ts new file mode 100644 index 00000000..8240e359 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/s.d.ts @@ -0,0 +1 @@ +export declare const convert_s: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/unit-conversions/turn.d.ts b/node_modules/@csstools/css-calc/dist/unit-conversions/turn.d.ts new file mode 100644 index 00000000..e721ff8e --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/unit-conversions/turn.d.ts @@ -0,0 +1 @@ +export declare const convert_turn: Map<string, (number: number) => number>; diff --git a/node_modules/@csstools/css-calc/dist/util/canonical-unit.d.ts b/node_modules/@csstools/css-calc/dist/util/canonical-unit.d.ts new file mode 100644 index 00000000..49f5e457 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/util/canonical-unit.d.ts @@ -0,0 +1,2 @@ +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function patchCanonicalUnit(x: TokenNode | FunctionNode | -1): TokenNode | FunctionNode | -1; diff --git a/node_modules/@csstools/css-calc/dist/util/globals.d.ts b/node_modules/@csstools/css-calc/dist/util/globals.d.ts new file mode 100644 index 00000000..c9e43b74 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/util/globals.d.ts @@ -0,0 +1,4 @@ +import type { TokenDimension, TokenNumber, TokenPercentage } from '@csstools/css-tokenizer'; +export type Globals = Map<string, TokenDimension | TokenNumber | TokenPercentage>; +export type GlobalsWithStrings = Map<string, TokenDimension | TokenNumber | TokenPercentage | string>; +export declare function tokenizeGlobals(x: GlobalsWithStrings | undefined): Globals; diff --git a/node_modules/@csstools/css-calc/dist/util/infinity.d.ts b/node_modules/@csstools/css-calc/dist/util/infinity.d.ts new file mode 100644 index 00000000..588d3e13 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/util/infinity.d.ts @@ -0,0 +1,2 @@ +import { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function patchInfinity(x: TokenNode | FunctionNode | -1): TokenNode | FunctionNode | -1; diff --git a/node_modules/@csstools/css-calc/dist/util/kind-of-number.d.ts b/node_modules/@csstools/css-calc/dist/util/kind-of-number.d.ts new file mode 100644 index 00000000..dac78981 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/util/kind-of-number.d.ts @@ -0,0 +1,5 @@ +import { CSSToken, TokenDimension, TokenNumber, TokenPercentage } from '@csstools/css-tokenizer'; +export declare function isNumeric(x: CSSToken): x is TokenDimension | TokenPercentage | TokenNumber; +export declare function isDimensionOrNumber(x: CSSToken): x is TokenDimension | TokenNumber; +export declare function arrayOfSameNumeric<T extends TokenDimension | TokenPercentage | TokenNumber>(x: Array<CSSToken>): x is Array<T>; +export declare function twoOfSameNumeric<T extends TokenDimension | TokenPercentage | TokenNumber>(x: T, y: CSSToken): y is T; diff --git a/node_modules/@csstools/css-calc/dist/util/minus-zero.d.ts b/node_modules/@csstools/css-calc/dist/util/minus-zero.d.ts new file mode 100644 index 00000000..67b9e553 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/util/minus-zero.d.ts @@ -0,0 +1,2 @@ +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function patchMinusZero(x: TokenNode | FunctionNode | -1): TokenNode | FunctionNode | -1; diff --git a/node_modules/@csstools/css-calc/dist/util/nan.d.ts b/node_modules/@csstools/css-calc/dist/util/nan.d.ts new file mode 100644 index 00000000..a7e03354 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/util/nan.d.ts @@ -0,0 +1,2 @@ +import { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function patchNaN(x: TokenNode | FunctionNode | -1): TokenNode | FunctionNode | -1; diff --git a/node_modules/@csstools/css-calc/dist/util/patch-result.d.ts b/node_modules/@csstools/css-calc/dist/util/patch-result.d.ts new file mode 100644 index 00000000..03330b3e --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/util/patch-result.d.ts @@ -0,0 +1,3 @@ +import { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +import { conversionOptions } from '../options'; +export declare function patchCalcResult(x: TokenNode | FunctionNode | -1, options?: conversionOptions): TokenNode | FunctionNode | -1; diff --git a/node_modules/@csstools/css-calc/dist/util/precision.d.ts b/node_modules/@csstools/css-calc/dist/util/precision.d.ts new file mode 100644 index 00000000..424909c1 --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/util/precision.d.ts @@ -0,0 +1,2 @@ +import type { FunctionNode, TokenNode } from '@csstools/css-parser-algorithms'; +export declare function patchPrecision(x: TokenNode | FunctionNode | -1, precision?: number): TokenNode | FunctionNode | -1; diff --git a/node_modules/@csstools/css-calc/dist/util/to-lower-case-a-z.d.ts b/node_modules/@csstools/css-calc/dist/util/to-lower-case-a-z.d.ts new file mode 100644 index 00000000..396b252e --- /dev/null +++ b/node_modules/@csstools/css-calc/dist/util/to-lower-case-a-z.d.ts @@ -0,0 +1 @@ +export declare function toLowerCaseAZ(x: string): string; diff --git a/node_modules/@csstools/css-calc/package.json b/node_modules/@csstools/css-calc/package.json new file mode 100644 index 00000000..3744fe1e --- /dev/null +++ b/node_modules/@csstools/css-calc/package.json @@ -0,0 +1,72 @@ +{ + "name": "@csstools/css-calc", + "description": "Solve CSS math expressions", + "version": "1.1.4", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "peerDependencies": { + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1" + }, + "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-calc#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "packages/css-calc" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "calc", + "css" + ], + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/css-color-parser/CHANGELOG.md b/node_modules/@csstools/css-color-parser/CHANGELOG.md new file mode 100644 index 00000000..e0536567 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/CHANGELOG.md @@ -0,0 +1,98 @@ +# Changes to CSS Color Parser + +### 1.4.0 + +_October 9, 2023_ + +- Add utility to determine if a color is in the Display P3 gamut. + +### 1.3.3 + +_October 2, 2023_ + +- Fix interpolation of `hue` when either or both components are `none` and `longer` is the interpolation method. + +### 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 diff --git a/node_modules/@csstools/css-color-parser/LICENSE.md b/node_modules/@csstools/css-color-parser/LICENSE.md new file mode 100644 index 00000000..af5411fa --- /dev/null +++ b/node_modules/@csstools/css-color-parser/LICENSE.md @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright 2022 Romain Menke, Antonio Laguna <antonio@laguna.es> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/@csstools/css-color-parser/README.md b/node_modules/@csstools/css-color-parser/README.md new file mode 100644 index 00000000..da0bd404 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/README.md @@ -0,0 +1,37 @@ +# CSS Color Parser + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/css-color-parser.svg" height="20">][npm-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +## Usage + +Add [CSS Color Parser] to your project: + +```bash +npm install @csstools/css-color-parser @csstools/css-parser-algorithms @csstools/css-tokenizer --save-dev +``` + +```ts +import { color } from '@csstools/css-color-parser'; +import { isFunctionNode, parseComponentValue } from '@csstools/css-parser-algorithms'; +import { serializeRGB } from '@csstools/css-color-parser'; +import { tokenize } from '@csstools/css-tokenizer'; + +// color() expects a parsed component value. +const hwbComponentValue = parseComponentValue(tokenize({ css: 'hwb(10deg 10% 20%)' })); +const colorData = color(hwbComponentValue); +if (colorData) { + console.log(colorData); + + // serializeRGB() returns a component value. + const rgbComponentValue = serializeRGB(colorData); + console.log(rgbComponentValue.toString()); +} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/css-color-parser + +[CSS Color Parser]: https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser diff --git a/node_modules/@csstools/css-color-parser/dist/color-data.d.ts b/node_modules/@csstools/css-color-parser/dist/color-data.d.ts new file mode 100644 index 00000000..9fa6a335 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/color-data.d.ts @@ -0,0 +1,34 @@ +import type { Color } from '@csstools/color-helpers'; +import type { ComponentValue } from '@csstools/css-parser-algorithms'; +import { ColorNotation } from './color-notation'; +import { TokenNumber } from '@csstools/css-tokenizer'; +export type ColorData = { + colorNotation: ColorNotation; + channels: Color; + alpha: number | ComponentValue; + syntaxFlags: Set<SyntaxFlag>; +}; +export declare enum SyntaxFlag { + ColorKeyword = "color-keyword", + HasAlpha = "has-alpha", + HasDimensionValues = "has-dimension-values", + HasNoneKeywords = "has-none-keywords", + HasNumberValues = "has-number-values", + HasPercentageAlpha = "has-percentage-alpha", + HasPercentageValues = "has-percentage-values", + HasVariableAlpha = "has-variable-alpha", + Hex = "hex", + LegacyHSL = "legacy-hsl", + LegacyRGB = "legacy-rgb", + NamedColor = "named-color", + RelativeColorSyntax = "relative-color-syntax", + ColorMix = "color-mix" +} +export declare function colorData_to_XYZ_D50(colorData: ColorData): ColorData; +export declare function colorDataTo(colorData: ColorData, toNotation: ColorNotation): ColorData; +export declare function convertPowerlessComponentsToMissingComponents(a: Color, colorNotation: ColorNotation): Color; +export declare function convertPowerlessComponentsToZeroValuesForDisplay(a: Color, colorNotation: ColorNotation): Color; +export declare function normalizeRelativeColorDataChannels(x: ColorData): Map<string, TokenNumber>; +export declare function noneToZeroInRelativeColorDataChannels(x: Map<string, TokenNumber>): Map<string, TokenNumber>; +export declare function colorDataFitsRGB_Gamut(x: ColorData): boolean; +export declare function colorDataFitsDisplayP3_Gamut(x: ColorData): boolean; diff --git a/node_modules/@csstools/css-color-parser/dist/color-notation.d.ts b/node_modules/@csstools/css-color-parser/dist/color-notation.d.ts new file mode 100644 index 00000000..242ebfb8 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/color-notation.d.ts @@ -0,0 +1,18 @@ +export declare enum ColorNotation { + A98_RGB = "a98-rgb", + Display_P3 = "display-p3", + HEX = "hex", + HSL = "hsl", + HWB = "hwb", + LCH = "lch", + Lab = "lab", + Linear_sRGB = "srgb-linear", + OKLCH = "oklch", + OKLab = "oklab", + ProPhoto_RGB = "prophoto-rgb", + RGB = "rgb", + sRGB = "srgb", + Rec2020 = "rec2020", + XYZ_D50 = "xyz-d50", + XYZ_D65 = "xyz-d65" +} diff --git a/node_modules/@csstools/css-color-parser/dist/color-parser.d.ts b/node_modules/@csstools/css-color-parser/dist/color-parser.d.ts new file mode 100644 index 00000000..325c0657 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/color-parser.d.ts @@ -0,0 +1,3 @@ +import type { ColorData } from './color-data'; +import type { ComponentValue } from '@csstools/css-parser-algorithms'; +export type ColorParser = (x: ComponentValue) => ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/color-keyword.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/color-keyword.d.ts new file mode 100644 index 00000000..6652208f --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/color-keyword.d.ts @@ -0,0 +1,2 @@ +import type { ColorData } from '../color-data'; +export declare function colorKeyword(name: string): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/color-mix.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/color-mix.d.ts new file mode 100644 index 00000000..8fc6aeda --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/color-mix.d.ts @@ -0,0 +1,4 @@ +import type { ColorData } from '../color-data'; +import type { ColorParser } from '../color-parser'; +import type { FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function colorMix(colorMixNode: FunctionNode, colorParser: ColorParser): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/color-normalize-channel-values.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/color-normalize-channel-values.d.ts new file mode 100644 index 00000000..51b6624d --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/color-normalize-channel-values.d.ts @@ -0,0 +1,3 @@ +import type { ColorData } from '../color-data'; +import { CSSToken } from '@csstools/css-tokenizer'; +export declare function normalize_Color_ChannelValues(token: CSSToken, index: number, colorData: ColorData): CSSToken | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/color.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/color.d.ts new file mode 100644 index 00000000..34b95e2c --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/color.d.ts @@ -0,0 +1,4 @@ +import { ColorData } from '../color-data'; +import type { ColorParser } from '../color-parser'; +import { FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function color(colorFunctionNode: FunctionNode, colorParser: ColorParser): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/hex.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/hex.d.ts new file mode 100644 index 00000000..8b66473e --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/hex.d.ts @@ -0,0 +1,3 @@ +import type { ColorData } from '../color-data'; +import type { TokenHash } from '@csstools/css-tokenizer'; +export declare function hex(hexToken: TokenHash): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/hsl-normalize-channel-values.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/hsl-normalize-channel-values.d.ts new file mode 100644 index 00000000..068bcae7 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/hsl-normalize-channel-values.d.ts @@ -0,0 +1,4 @@ +import type { ColorData } from '../color-data'; +import { CSSToken } from '@csstools/css-tokenizer'; +export declare function normalize_legacy_HSL_ChannelValues(token: CSSToken, index: number, colorData: ColorData): CSSToken | false; +export declare function normalize_modern_HSL_ChannelValues(token: CSSToken, index: number, colorData: ColorData): CSSToken | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/hsl.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/hsl.d.ts new file mode 100644 index 00000000..919acdda --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/hsl.d.ts @@ -0,0 +1,4 @@ +import type { ColorData } from '../color-data'; +import type { ColorParser } from '../color-parser'; +import { FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function hsl(hslNode: FunctionNode, colorParser: ColorParser): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/hue-normalize-channel-value.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/hue-normalize-channel-value.d.ts new file mode 100644 index 00000000..41a96c64 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/hue-normalize-channel-value.d.ts @@ -0,0 +1,3 @@ +import type { TokenNumber } from '@csstools/css-tokenizer'; +import { CSSToken } from '@csstools/css-tokenizer'; +export declare function normalizeHue(token: CSSToken): TokenNumber | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/hwb-normalize-channel-values.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/hwb-normalize-channel-values.d.ts new file mode 100644 index 00000000..81da6aac --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/hwb-normalize-channel-values.d.ts @@ -0,0 +1,3 @@ +import type { ColorData } from '../color-data'; +import { CSSToken } from '@csstools/css-tokenizer'; +export declare function normalize_HWB_ChannelValues(token: CSSToken, index: number, colorData: ColorData): CSSToken | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/hwb.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/hwb.d.ts new file mode 100644 index 00000000..1ddffe98 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/hwb.d.ts @@ -0,0 +1,4 @@ +import type { ColorData } from '../color-data'; +import type { ColorParser } from '../color-parser'; +import type { FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function hwb(hwbNode: FunctionNode, colorParser: ColorParser): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/lab-normalize-channel-values.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/lab-normalize-channel-values.d.ts new file mode 100644 index 00000000..73587504 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/lab-normalize-channel-values.d.ts @@ -0,0 +1,3 @@ +import type { ColorData } from '../color-data'; +import { CSSToken } from '@csstools/css-tokenizer'; +export declare function normalize_Lab_ChannelValues(token: CSSToken, index: number, colorData: ColorData): CSSToken | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/lab.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/lab.d.ts new file mode 100644 index 00000000..fbbf35aa --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/lab.d.ts @@ -0,0 +1,4 @@ +import type { ColorData } from '../color-data'; +import type { ColorParser } from '../color-parser'; +import type { FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function lab(labNode: FunctionNode, colorParser: ColorParser): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/lch-normalize-channel-values.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/lch-normalize-channel-values.d.ts new file mode 100644 index 00000000..a2227e44 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/lch-normalize-channel-values.d.ts @@ -0,0 +1,3 @@ +import type { ColorData } from '../color-data'; +import { CSSToken } from '@csstools/css-tokenizer'; +export declare function normalize_LCH_ChannelValues(token: CSSToken, index: number, colorData: ColorData): CSSToken | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/lch.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/lch.d.ts new file mode 100644 index 00000000..91788903 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/lch.d.ts @@ -0,0 +1,4 @@ +import type { ColorData } from '../color-data'; +import type { ColorParser } from '../color-parser'; +import type { FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function lch(lchNode: FunctionNode, colorParser: ColorParser): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/named-color.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/named-color.d.ts new file mode 100644 index 00000000..376a093a --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/named-color.d.ts @@ -0,0 +1,2 @@ +import type { ColorData } from '../color-data'; +export declare function namedColor(name: string): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/normalize-channel-values.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/normalize-channel-values.d.ts new file mode 100644 index 00000000..c32172fd --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/normalize-channel-values.d.ts @@ -0,0 +1,3 @@ +import type { ColorData } from '../color-data'; +import { CSSToken } from '@csstools/css-tokenizer'; +export type normalizeChannelValuesFn = (token: CSSToken, index: number, colorData: ColorData) => CSSToken | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/normalize.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/normalize.d.ts new file mode 100644 index 00000000..0b57af5e --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/normalize.d.ts @@ -0,0 +1 @@ +export declare function normalize(x: number, scale: number, min: number, max: number): number; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/oklab-normalize-channel-values.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/oklab-normalize-channel-values.d.ts new file mode 100644 index 00000000..97b82792 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/oklab-normalize-channel-values.d.ts @@ -0,0 +1,3 @@ +import type { ColorData } from '../color-data'; +import { CSSToken } from '@csstools/css-tokenizer'; +export declare function normalize_OKLab_ChannelValues(token: CSSToken, index: number, colorData: ColorData): CSSToken | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/oklab.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/oklab.d.ts new file mode 100644 index 00000000..96e03847 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/oklab.d.ts @@ -0,0 +1,4 @@ +import type { ColorData } from '../color-data'; +import type { ColorParser } from '../color-parser'; +import type { FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function oklab(oklabNode: FunctionNode, colorParser: ColorParser): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/oklch-normalize-channel-values.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/oklch-normalize-channel-values.d.ts new file mode 100644 index 00000000..afd514b3 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/oklch-normalize-channel-values.d.ts @@ -0,0 +1,3 @@ +import type { ColorData } from '../color-data'; +import { CSSToken } from '@csstools/css-tokenizer'; +export declare function normalize_OKLCH_ChannelValues(token: CSSToken, index: number, colorData: ColorData): CSSToken | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/oklch.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/oklch.d.ts new file mode 100644 index 00000000..d70197e7 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/oklch.d.ts @@ -0,0 +1,4 @@ +import type { ColorData } from '../color-data'; +import type { ColorParser } from '../color-parser'; +import type { FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function oklch(oklchNode: FunctionNode, colorParser: ColorParser): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/rgb-normalize-channel-values.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/rgb-normalize-channel-values.d.ts new file mode 100644 index 00000000..eb3e89bc --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/rgb-normalize-channel-values.d.ts @@ -0,0 +1,4 @@ +import type { ColorData } from '../color-data'; +import { CSSToken } from '@csstools/css-tokenizer'; +export declare function normalize_legacy_sRGB_ChannelValues(token: CSSToken, index: number, colorData: ColorData): CSSToken | false; +export declare function normalize_modern_sRGB_ChannelValues(token: CSSToken, index: number, colorData: ColorData): CSSToken | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/rgb.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/rgb.d.ts new file mode 100644 index 00000000..c4aacca1 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/rgb.d.ts @@ -0,0 +1,4 @@ +import type { ColorData } from '../color-data'; +import type { ColorParser } from '../color-parser'; +import { FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function rgb(rgbNode: FunctionNode, colorParser: ColorParser): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/three-channel-legacy-syntax.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/three-channel-legacy-syntax.d.ts new file mode 100644 index 00000000..5bfe8c38 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/three-channel-legacy-syntax.d.ts @@ -0,0 +1,6 @@ +import type { ColorData } from '../color-data'; +import type { FunctionNode } from '@csstools/css-parser-algorithms'; +import { ColorNotation } from '../color-notation'; +import { SyntaxFlag } from '../color-data'; +import { normalizeChannelValuesFn } from './normalize-channel-values'; +export declare function threeChannelLegacySyntax(colorFunctionNode: FunctionNode, normalizeChannelValues: normalizeChannelValuesFn, colorNotation: ColorNotation, syntaxFlags: Array<SyntaxFlag>): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/functions/three-channel-space-separated.d.ts b/node_modules/@csstools/css-color-parser/dist/functions/three-channel-space-separated.d.ts new file mode 100644 index 00000000..8fb7e41b --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/functions/three-channel-space-separated.d.ts @@ -0,0 +1,7 @@ +import { ColorData } from '../color-data'; +import { FunctionNode } from '@csstools/css-parser-algorithms'; +import { ColorNotation } from '../color-notation'; +import { SyntaxFlag } from '../color-data'; +import { normalizeChannelValuesFn } from './normalize-channel-values'; +import { ColorParser } from '../color-parser'; +export declare function threeChannelSpaceSeparated(colorFunctionNode: FunctionNode, normalizeChannelValues: normalizeChannelValuesFn, colorNotation: ColorNotation, syntaxFlags: Array<SyntaxFlag>, colorParser: ColorParser): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/gamut-mapping/p3.d.ts b/node_modules/@csstools/css-color-parser/dist/gamut-mapping/p3.d.ts new file mode 100644 index 00000000..d0130b52 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/gamut-mapping/p3.d.ts @@ -0,0 +1,2 @@ +import { Color } from '@csstools/color-helpers'; +export declare function XYZ_D50_to_P3_Gamut(color: Color): Color; diff --git a/node_modules/@csstools/css-color-parser/dist/gamut-mapping/srgb.d.ts b/node_modules/@csstools/css-color-parser/dist/gamut-mapping/srgb.d.ts new file mode 100644 index 00000000..87b3ad80 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/gamut-mapping/srgb.d.ts @@ -0,0 +1,2 @@ +import { Color } from '@csstools/color-helpers'; +export declare function XYZ_D50_to_sRGB_Gamut(color: Color): Color; diff --git a/node_modules/@csstools/css-color-parser/dist/index.cjs b/node_modules/@csstools/css-color-parser/dist/index.cjs new file mode 100644 index 00000000..8cd9b2be --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e,o,n=require("@csstools/css-tokenizer"),a=require("@csstools/color-helpers"),t=require("@csstools/css-parser-algorithms"),r=require("@csstools/css-calc");function colorData_to_XYZ_D50(e){switch(e.colorNotation){case exports.ColorNotation.HEX:case exports.ColorNotation.RGB:case exports.ColorNotation.sRGB:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.sRGB_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case exports.ColorNotation.Linear_sRGB:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.lin_sRGB_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case exports.ColorNotation.Display_P3:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.P3_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case exports.ColorNotation.Rec2020:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.rec_2020_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case exports.ColorNotation.A98_RGB:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.a98_RGB_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case exports.ColorNotation.ProPhoto_RGB:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.ProPhoto_RGB_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case exports.ColorNotation.HSL:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.HSL_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case exports.ColorNotation.HWB:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.HWB_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case exports.ColorNotation.Lab:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.Lab_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case exports.ColorNotation.OKLab:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.OKLab_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case exports.ColorNotation.LCH:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.LCH_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case exports.ColorNotation.OKLCH:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.OKLCH_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case exports.ColorNotation.XYZ_D50:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.XYZ_D50_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case exports.ColorNotation.XYZ_D65:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:a.xyz.XYZ_D65_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};default:throw new Error("Unsupported color notation")}}exports.ColorNotation=void 0,(e=exports.ColorNotation||(exports.ColorNotation={})).A98_RGB="a98-rgb",e.Display_P3="display-p3",e.HEX="hex",e.HSL="hsl",e.HWB="hwb",e.LCH="lch",e.Lab="lab",e.Linear_sRGB="srgb-linear",e.OKLCH="oklch",e.OKLab="oklab",e.ProPhoto_RGB="prophoto-rgb",e.RGB="rgb",e.sRGB="srgb",e.Rec2020="rec2020",e.XYZ_D50="xyz-d50",e.XYZ_D65="xyz-d65",exports.SyntaxFlag=void 0,(o=exports.SyntaxFlag||(exports.SyntaxFlag={})).ColorKeyword="color-keyword",o.HasAlpha="has-alpha",o.HasDimensionValues="has-dimension-values",o.HasNoneKeywords="has-none-keywords",o.HasNumberValues="has-number-values",o.HasPercentageAlpha="has-percentage-alpha",o.HasPercentageValues="has-percentage-values",o.HasVariableAlpha="has-variable-alpha",o.Hex="hex",o.LegacyHSL="legacy-hsl",o.LegacyRGB="legacy-rgb",o.NamedColor="named-color",o.RelativeColorSyntax="relative-color-syntax",o.ColorMix="color-mix";const s=new Set([exports.ColorNotation.A98_RGB,exports.ColorNotation.Display_P3,exports.ColorNotation.HEX,exports.ColorNotation.Linear_sRGB,exports.ColorNotation.ProPhoto_RGB,exports.ColorNotation.RGB,exports.ColorNotation.sRGB,exports.ColorNotation.Rec2020,exports.ColorNotation.XYZ_D50,exports.ColorNotation.XYZ_D65]);function colorDataTo(e,o){const n={...e};if(e.colorNotation!==o){const e=colorData_to_XYZ_D50(n);switch(o){case exports.ColorNotation.HEX:case exports.ColorNotation.RGB:n.colorNotation=exports.ColorNotation.RGB,n.channels=a.xyz.XYZ_D50_to_sRGB(e.channels);break;case exports.ColorNotation.sRGB:n.colorNotation=exports.ColorNotation.sRGB,n.channels=a.xyz.XYZ_D50_to_sRGB(e.channels);break;case exports.ColorNotation.Linear_sRGB:n.colorNotation=exports.ColorNotation.Linear_sRGB,n.channels=a.xyz.XYZ_D50_to_lin_sRGB(e.channels);break;case exports.ColorNotation.Display_P3:n.colorNotation=exports.ColorNotation.Display_P3,n.channels=a.xyz.XYZ_D50_to_P3(e.channels);break;case exports.ColorNotation.Rec2020:n.colorNotation=exports.ColorNotation.Rec2020,n.channels=a.xyz.XYZ_D50_to_rec_2020(e.channels);break;case exports.ColorNotation.ProPhoto_RGB:n.colorNotation=exports.ColorNotation.ProPhoto_RGB,n.channels=a.xyz.XYZ_D50_to_ProPhoto(e.channels);break;case exports.ColorNotation.A98_RGB:n.colorNotation=exports.ColorNotation.A98_RGB,n.channels=a.xyz.XYZ_D50_to_a98_RGB(e.channels);break;case exports.ColorNotation.HSL:n.colorNotation=exports.ColorNotation.HSL,n.channels=a.xyz.XYZ_D50_to_HSL(e.channels);break;case exports.ColorNotation.HWB:n.colorNotation=exports.ColorNotation.HWB,n.channels=a.xyz.XYZ_D50_to_HWB(e.channels);break;case exports.ColorNotation.Lab:n.colorNotation=exports.ColorNotation.Lab,n.channels=a.xyz.XYZ_D50_to_Lab(e.channels);break;case exports.ColorNotation.LCH:n.colorNotation=exports.ColorNotation.LCH,n.channels=a.xyz.XYZ_D50_to_LCH(e.channels);break;case exports.ColorNotation.OKLCH:n.colorNotation=exports.ColorNotation.OKLCH,n.channels=a.xyz.XYZ_D50_to_OKLCH(e.channels);break;case exports.ColorNotation.OKLab:n.colorNotation=exports.ColorNotation.OKLab,n.channels=a.xyz.XYZ_D50_to_OKLab(e.channels);break;case exports.ColorNotation.XYZ_D50:n.colorNotation=exports.ColorNotation.XYZ_D50,n.channels=a.xyz.XYZ_D50_to_XYZ_D50(e.channels);break;case exports.ColorNotation.XYZ_D65:n.colorNotation=exports.ColorNotation.XYZ_D65,n.channels=a.xyz.XYZ_D50_to_XYZ_D65(e.channels);break;default:throw new Error("Unsupported color notation")}}else n.channels=e.channels.map((e=>Number.isNaN(e)?0:e));if(o===e.colorNotation)n.channels=carryForwardMissingComponents(e.channels,[0,1,2],n.channels,[0,1,2]);else if(s.has(o)&&s.has(e.colorNotation))n.channels=carryForwardMissingComponents(e.channels,[0,1,2],n.channels,[0,1,2]);else switch(o){case exports.ColorNotation.HSL:switch(e.colorNotation){case exports.ColorNotation.HWB:n.channels=carryForwardMissingComponents(e.channels,[0],n.channels,[0]);break;case exports.ColorNotation.Lab:case exports.ColorNotation.OKLab:n.channels=carryForwardMissingComponents(e.channels,[2],n.channels,[0]);break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:n.channels=carryForwardMissingComponents(e.channels,[0,1,2],n.channels,[2,1,0])}break;case exports.ColorNotation.HWB:switch(e.colorNotation){case exports.ColorNotation.HSL:n.channels=carryForwardMissingComponents(e.channels,[0],n.channels,[0]);break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:n.channels=carryForwardMissingComponents(e.channels,[0],n.channels,[2])}break;case exports.ColorNotation.Lab:case exports.ColorNotation.OKLab:switch(e.colorNotation){case exports.ColorNotation.HSL:n.channels=carryForwardMissingComponents(e.channels,[0],n.channels,[2]);break;case exports.ColorNotation.Lab:case exports.ColorNotation.OKLab:n.channels=carryForwardMissingComponents(e.channels,[0,1,2],n.channels,[0,1,2]);break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:n.channels=carryForwardMissingComponents(e.channels,[0],n.channels,[0])}break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:switch(e.colorNotation){case exports.ColorNotation.HSL:n.channels=carryForwardMissingComponents(e.channels,[0,1,2],n.channels,[2,1,0]);break;case exports.ColorNotation.HWB:n.channels=carryForwardMissingComponents(e.channels,[0],n.channels,[2]);break;case exports.ColorNotation.Lab:case exports.ColorNotation.OKLab:n.channels=carryForwardMissingComponents(e.channels,[0],n.channels,[0]);break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:n.channels=carryForwardMissingComponents(e.channels,[0,1,2],n.channels,[0,1,2])}}return n.channels=convertPowerlessComponentsToMissingComponents(n.channels,o),n}function convertPowerlessComponentsToMissingComponents(e,o){const n=[...e];switch(o){case exports.ColorNotation.HSL:reducePrecision(n[1],4)<=0&&(n[0]=NaN);break;case exports.ColorNotation.HWB:Math.max(0,reducePrecision(n[1],4))+Math.max(0,reducePrecision(n[2],4))>=100&&(n[0]=NaN);break;case exports.ColorNotation.LCH:reducePrecision(n[1],4)<=0&&(n[2]=NaN);break;case exports.ColorNotation.OKLCH:reducePrecision(n[1],6)<=0&&(n[2]=NaN)}return n}function convertPowerlessComponentsToZeroValuesForDisplay(e,o){const n=[...e];switch(o){case exports.ColorNotation.HSL:(reducePrecision(n[2])<=0||reducePrecision(n[2])>=100)&&(n[0]=NaN,n[1]=NaN),reducePrecision(n[1])<=0&&(n[0]=NaN);break;case exports.ColorNotation.HWB:Math.max(0,reducePrecision(n[1]))+Math.max(0,reducePrecision(n[2]))>=100&&(n[0]=NaN);break;case exports.ColorNotation.Lab:(reducePrecision(n[0])<=0||reducePrecision(n[0])>=100)&&(n[1]=NaN,n[2]=NaN);break;case exports.ColorNotation.LCH:reducePrecision(n[1])<=0&&(n[2]=NaN),(reducePrecision(n[0])<=0||reducePrecision(n[0])>=100)&&(n[1]=NaN,n[2]=NaN);break;case exports.ColorNotation.OKLab:(reducePrecision(n[0])<=0||reducePrecision(n[0])>=1)&&(n[1]=NaN,n[2]=NaN);break;case exports.ColorNotation.OKLCH:reducePrecision(n[1])<=0&&(n[2]=NaN),(reducePrecision(n[0])<=0||reducePrecision(n[0])>=1)&&(n[1]=NaN,n[2]=NaN)}return n}function carryForwardMissingComponents(e,o,n,a){const t=[...n];for(const n of o)Number.isNaN(e[o[n]])&&(t[a[n]]=NaN);return t}function normalizeRelativeColorDataChannels(e){const o=new Map;switch(e.colorNotation){case exports.ColorNotation.RGB:case exports.ColorNotation.HEX:o.set("r",dummyNumberToken(255*e.channels[0])),o.set("g",dummyNumberToken(255*e.channels[1])),o.set("b",dummyNumberToken(255*e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha));break;case exports.ColorNotation.HSL:o.set("h",dummyNumberToken(e.channels[0])),o.set("s",dummyNumberToken(e.channels[1])),o.set("l",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha));break;case exports.ColorNotation.HWB:o.set("h",dummyNumberToken(e.channels[0])),o.set("w",dummyNumberToken(e.channels[1])),o.set("b",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha));break;case exports.ColorNotation.Lab:case exports.ColorNotation.OKLab:o.set("l",dummyNumberToken(e.channels[0])),o.set("a",dummyNumberToken(e.channels[1])),o.set("b",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha));break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:o.set("l",dummyNumberToken(e.channels[0])),o.set("c",dummyNumberToken(e.channels[1])),o.set("h",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha));break;case exports.ColorNotation.sRGB:case exports.ColorNotation.A98_RGB:case exports.ColorNotation.Display_P3:case exports.ColorNotation.Rec2020:case exports.ColorNotation.Linear_sRGB:case exports.ColorNotation.ProPhoto_RGB:o.set("r",dummyNumberToken(e.channels[0])),o.set("g",dummyNumberToken(e.channels[1])),o.set("b",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha));break;case exports.ColorNotation.XYZ_D50:case exports.ColorNotation.XYZ_D65:o.set("x",dummyNumberToken(e.channels[0])),o.set("y",dummyNumberToken(e.channels[1])),o.set("z",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha))}return o}function noneToZeroInRelativeColorDataChannels(e){const o=new Map(e);for(const[n,a]of e)Number.isNaN(a[4].value)&&o.set(n,dummyNumberToken(0));return o}function dummyNumberToken(e){return[n.TokenType.Number,e.toString(),-1,-1,{value:e,type:n.NumberType.Number}]}function reducePrecision(e,o=7){if(Number.isNaN(e))return 0;const n=Math.pow(10,o);return Math.round(e*n)/n}function normalize(e,o,n,a){return Math.min(Math.max(e/o,n),a)}const l=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(l,(e=>String.fromCharCode(e.charCodeAt(0)+32)))}function normalize_Color_ChannelValues(e,o,a){if(e[0]===n.TokenType.Ident&&"none"===toLowerCaseAZ(e[4].value))return a.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[n.TokenType.Number,"none",e[2],e[3],{value:NaN,type:n.NumberType.Number}];if(e[0]===n.TokenType.Percentage){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,100,-1/0,1/0);return 3===o&&(t=normalize(e[4].value,100,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}if(e[0]===n.TokenType.Number){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,1,-1/0,1/0);return 3===o&&(t=normalize(e[4].value,1,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}return!1}const i=new Set(["srgb","srgb-linear","display-p3","a98-rgb","prophoto-rgb","rec2020","xyz","xyz-d50","xyz-d65"]);function color$1(e,o){const a=[],s=[],l=[],u=[];let c,p,N=!1,m=!1;const h={colorNotation:exports.ColorNotation.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])};let y=a;for(let x=0;x<e.value.length;x++){let T=e.value[x];if(t.isWhitespaceNode(T)||t.isCommentNode(T))for(;t.isWhitespaceNode(e.value[x+1])||t.isCommentNode(e.value[x+1]);)x++;else if(y===a&&a.length&&(y=s),y===s&&s.length&&(y=l),t.isTokenNode(T)&&T.value[0]===n.TokenType.Delim&&"/"===T.value[4].value){if(y===u)return!1;y=u}else{if(t.isFunctionNode(T)){if(y===u&&"var"===toLowerCaseAZ(T.getName())){h.syntaxFlags.add(exports.SyntaxFlag.HasVariableAlpha),y.push(T);continue}if(!r.mathFunctionNames.has(toLowerCaseAZ(T.getName())))return!1;const[[e]]=r.calcFromComponentValues([[T]],{toCanonicalUnits:!0,precision:100,globals:p});if(!e||!t.isTokenNode(e)||(e.value[0]===n.TokenType.Percentage||e.value[0]===n.TokenType.Number||e.value[0]===n.TokenType.Dimension)&&Number.isNaN(e.value[4].value))return!1;T=e}if(y===a&&0===a.length&&t.isTokenNode(T)&&T.value[0]===n.TokenType.Ident&&i.has(toLowerCaseAZ(T.value[4].value))){if(N)return!1;N=toLowerCaseAZ(T.value[4].value),h.colorNotation=colorSpaceNameToColorNotation(N),m&&(m.colorNotation!==h.colorNotation&&(m=colorDataTo(m,h.colorNotation)),c=normalizeRelativeColorDataChannels(m),p=noneToZeroInRelativeColorDataChannels(c))}else if(y===a&&0===a.length&&t.isTokenNode(T)&&T.value[0]===n.TokenType.Ident&&"from"===toLowerCaseAZ(T.value[4].value)){if(m)return!1;if(N)return!1;for(;t.isWhitespaceNode(e.value[x+1])||t.isCommentNode(e.value[x+1]);)x++;if(x++,T=e.value[x],m=o(T),!1===m)return!1;h.syntaxFlags.add(exports.SyntaxFlag.RelativeColorSyntax)}else{if(!t.isTokenNode(T))return!1;if(T.value[0]===n.TokenType.Ident&&c&&c.has(toLowerCaseAZ(T.value[4].value))){y.push(new t.TokenNode(c.get(toLowerCaseAZ(T.value[4].value))));continue}y.push(T)}}}if(!N)return!1;if(1!==y.length)return!1;if(1!==a.length||1!==s.length||1!==l.length)return!1;if(!t.isTokenNode(a[0])||!t.isTokenNode(s[0])||!t.isTokenNode(l[0]))return!1;if(c&&!c.has("alpha"))return!1;const x=normalize_Color_ChannelValues(a[0].value,0,h);if(!x||x[0]!==n.TokenType.Number)return!1;const T=normalize_Color_ChannelValues(s[0].value,1,h);if(!T||T[0]!==n.TokenType.Number)return!1;const b=normalize_Color_ChannelValues(l[0].value,2,h);if(!b||b[0]!==n.TokenType.Number)return!1;const C=[x,T,b];if(1===u.length)if(h.syntaxFlags.add(exports.SyntaxFlag.HasAlpha),t.isTokenNode(u[0])){const e=normalize_Color_ChannelValues(u[0].value,3,h);if(!e||e[0]!==n.TokenType.Number)return!1;C.push(e)}else h.alpha=u[0];else if(c&&c.has("alpha")){const e=normalize_Color_ChannelValues(c.get("alpha"),3,h);if(!e||e[0]!==n.TokenType.Number)return!1;C.push(e)}return h.channels=[C[0][4].value,C[1][4].value,C[2][4].value],4===C.length&&(h.alpha=C[3][4].value),h}function colorSpaceNameToColorNotation(e){switch(e){case"srgb":return exports.ColorNotation.sRGB;case"srgb-linear":return exports.ColorNotation.Linear_sRGB;case"display-p3":return exports.ColorNotation.Display_P3;case"a98-rgb":return exports.ColorNotation.A98_RGB;case"prophoto-rgb":return exports.ColorNotation.ProPhoto_RGB;case"rec2020":return exports.ColorNotation.Rec2020;case"xyz":case"xyz-d65":return exports.ColorNotation.XYZ_D65;case"xyz-d50":return exports.ColorNotation.XYZ_D50;default:throw new Error("Unknown color space name: "+e)}}const u=new Set(["srgb","srgb-linear","lab","oklab","xyz","xyz-d50","xyz-d65"]),c=new Set(["hsl","hwb","lch","oklch"]),p=new Set(["shorter","longer","increasing","decreasing"]);function colorMix(e,o){let a=null,r=null,s=null,l=!1;for(let i=0;i<e.value.length;i++){const N=e.value[i];if(!t.isWhitespaceNode(N)&&!t.isCommentNode(N)){if(t.isTokenNode(N)&&N.value[0]===n.TokenType.Ident){if(!a&&"in"===toLowerCaseAZ(N.value[4].value)){a=N;continue}if(a&&!r){r=toLowerCaseAZ(N.value[4].value);continue}if(a&&r&&!s&&c.has(r)){s=toLowerCaseAZ(N.value[4].value);continue}if(a&&r&&s&&!l&&"hue"===toLowerCaseAZ(N.value[4].value)){l=!0;continue}return!1}return!(!t.isTokenNode(N)||N.value[0]!==n.TokenType.Comma)&&(!!r&&(s||l?!!(r&&s&&l&&c.has(r)&&p.has(s))&&colorMixPolar(r,s,colorMixComponents(e.value.slice(i+1),o)):u.has(r)?colorMixRectangular(r,colorMixComponents(e.value.slice(i+1),o)):!!c.has(r)&&colorMixPolar(r,"shorter",colorMixComponents(e.value.slice(i+1),o))))}}return!1}function colorMixComponents(e,o){const a=[];let s=1,l=!1,i=!1;for(let s=0;s<e.length;s++){let u=e[s];if(!t.isWhitespaceNode(u)&&!t.isCommentNode(u)){if(!t.isTokenNode(u)||u.value[0]!==n.TokenType.Comma){if(!l){const e=o(u);if(e){l=e;continue}}if(!i){if(t.isFunctionNode(u)&&r.mathFunctionNames.has(toLowerCaseAZ(u.getName()))&&([[u]]=r.calcFromComponentValues([[u]],{toCanonicalUnits:!0,precision:100}),!u||!t.isTokenNode(u)||(u.value[0]===n.TokenType.Percentage||u.value[0]===n.TokenType.Number||u.value[0]===n.TokenType.Dimension)&&Number.isNaN(u.value[4].value)))return!1;if(t.isTokenNode(u)&&u.value[0]===n.TokenType.Percentage&&u.value[4].value>=0){i=u.value[4].value;continue}}return!1}if(!l)return!1;a.push({color:l,percentage:i}),l=!1,i=!1}}if(l&&a.push({color:l,percentage:i}),2!==a.length)return!1;let u=a[0].percentage,c=a[1].percentage;return(!1===u||!(u<0||u>100))&&((!1===c||!(c<0||c>100))&&(!1===u&&!1===c?(u=50,c=50):!1!==u&&!1===c?c=100-u:!1===u&&!1!==c&&(u=100-c),(0!==u||0!==c)&&(!1!==u&&!1!==c&&(u+c>100&&(u=u/(u+c)*100,c=c/(u+c)*100),u+c<100&&(s=(u+c)/100,u=u/(u+c)*100,c=c/(u+c)*100),{a:{color:a[0].color,percentage:u},b:{color:a[1].color,percentage:c},alphaMultiplier:s}))))}function colorMixRectangular(e,o){if(!o)return!1;const n=o.a.color,a=o.b.color,t=o.a.percentage/100;let r=n.channels,s=a.channels,l=exports.ColorNotation.RGB,i=n.alpha;if("number"!=typeof i)return!1;let u=a.alpha;if("number"!=typeof u)return!1;switch(i=Number.isNaN(i)?u:i,u=Number.isNaN(u)?i:u,e){case"srgb":l=exports.ColorNotation.RGB;break;case"srgb-linear":l=exports.ColorNotation.Linear_sRGB;break;case"lab":l=exports.ColorNotation.Lab;break;case"oklab":l=exports.ColorNotation.OKLab;break;case"xyz-d50":l=exports.ColorNotation.XYZ_D50;break;case"xyz":case"xyz-d65":l=exports.ColorNotation.XYZ_D65}r=colorDataTo(n,l).channels,s=colorDataTo(a,l).channels,r[0]=fillInMissingComponent(r[0],s[0]),s[0]=fillInMissingComponent(s[0],r[0]),r[1]=fillInMissingComponent(r[1],s[1]),s[1]=fillInMissingComponent(s[1],r[1]),r[2]=fillInMissingComponent(r[2],s[2]),s[2]=fillInMissingComponent(s[2],r[2]),r[0]=premultiply(r[0],i),r[1]=premultiply(r[1],i),r[2]=premultiply(r[2],i),s[0]=premultiply(s[0],u),s[1]=premultiply(s[1],u),s[2]=premultiply(s[2],u);const c=interpolate(i,u,t);return{colorNotation:l,channels:[un_premultiply(interpolate(r[0],s[0],t),c),un_premultiply(interpolate(r[1],s[1],t),c),un_premultiply(interpolate(r[2],s[2],t),c)],alpha:c*o.alphaMultiplier,syntaxFlags:new Set([exports.SyntaxFlag.ColorMix])}}function colorMixPolar(e,o,n){if(!n)return!1;const a=n.a.color,t=n.b.color,r=n.a.percentage/100;let s=a.channels,l=t.channels,i=0,u=0,c=0,p=0,N=0,m=0,h=exports.ColorNotation.RGB,y=a.alpha;if("number"!=typeof y)return!1;let x=t.alpha;if("number"!=typeof x)return!1;switch(y=Number.isNaN(y)?x:y,x=Number.isNaN(x)?y:x,e){case"hsl":h=exports.ColorNotation.HSL;break;case"hwb":h=exports.ColorNotation.HWB;break;case"lch":h=exports.ColorNotation.LCH;break;case"oklch":h=exports.ColorNotation.OKLCH}switch(s=colorDataTo(a,h).channels,l=colorDataTo(t,h).channels,e){case"hsl":case"hwb":i=s[0],u=l[0],c=s[1],p=l[1],N=s[2],m=l[2];break;case"lch":case"oklch":c=s[0],p=l[0],N=s[1],m=l[1],i=s[2],u=l[2]}i=fillInMissingComponent(i,u),Number.isNaN(i)&&(i=0),u=fillInMissingComponent(u,i),Number.isNaN(u)&&(u=0),c=fillInMissingComponent(c,p),p=fillInMissingComponent(p,c),N=fillInMissingComponent(N,m),m=fillInMissingComponent(m,N);const T=u-i;switch(o){case"shorter":T>180?i+=360:T<-180&&(u+=360);break;case"longer":-180<T&&T<180&&(T>0?i+=360:u+=360);break;case"increasing":T<0&&(u+=360);break;case"decreasing":T>0&&(i+=360);break;default:throw new Error("Unknown hue interpolation method")}c=premultiply(c,y),N=premultiply(N,y),p=premultiply(p,x),m=premultiply(m,x);let b=[0,0,0];const C=interpolate(y,x,r);switch(e){case"hsl":case"hwb":b=[interpolate(i,u,r),un_premultiply(interpolate(c,p,r),C),un_premultiply(interpolate(N,m,r),C)];break;case"lch":case"oklch":b=[un_premultiply(interpolate(c,p,r),C),un_premultiply(interpolate(N,m,r),C),interpolate(i,u,r)]}return{colorNotation:h,channels:b,alpha:C*n.alphaMultiplier,syntaxFlags:new Set([exports.SyntaxFlag.ColorMix])}}function fillInMissingComponent(e,o){return Number.isNaN(e)?o:e}function interpolate(e,o,n){return e*n+o*(1-n)}function premultiply(e,o){return Number.isNaN(o)?e:Number.isNaN(e)?NaN:e*o}function un_premultiply(e,o){return 0===o||Number.isNaN(o)?e:Number.isNaN(e)?NaN:e/o}function hex(e){const o=toLowerCaseAZ(e[4].value);if(o.match(/[^a-f0-9]/))return!1;const n={colorNotation:exports.ColorNotation.HEX,channels:[0,0,0],alpha:1,syntaxFlags:new Set([exports.SyntaxFlag.Hex])},a=o.length;if(3===a){const e=o[0],a=o[1],t=o[2];return n.channels=[parseInt(e+e,16)/255,parseInt(a+a,16)/255,parseInt(t+t,16)/255],n}if(6===a){const e=o[0]+o[1],a=o[2]+o[3],t=o[4]+o[5];return n.channels=[parseInt(e,16)/255,parseInt(a,16)/255,parseInt(t,16)/255],n}if(4===a){const e=o[0],a=o[1],t=o[2],r=o[3];return n.channels=[parseInt(e+e,16)/255,parseInt(a+a,16)/255,parseInt(t+t,16)/255],n.alpha=parseInt(r+r,16)/255,n.syntaxFlags.add(exports.SyntaxFlag.HasAlpha),n}if(8===a){const e=o[0]+o[1],a=o[2]+o[3],t=o[4]+o[5],r=o[6]+o[7];return n.channels=[parseInt(e,16)/255,parseInt(a,16)/255,parseInt(t,16)/255],n.alpha=parseInt(r,16)/255,n.syntaxFlags.add(exports.SyntaxFlag.HasAlpha),n}return!1}function normalizeHue(e){if(e[0]===n.TokenType.Number)return e[4].value=e[4].value%360,e[1]=e[4].value.toString(),e;if(e[0]===n.TokenType.Dimension){let o=e[4].value;switch(toLowerCaseAZ(e[4].unit)){case"deg":break;case"rad":o=180*e[4].value/Math.PI;break;case"grad":o=.9*e[4].value;break;case"turn":o=360*e[4].value;break;default:return!1}return o%=360,[n.TokenType.Number,o.toString(),e[2],e[3],{value:o,type:n.NumberType.Number}]}return!1}function normalize_legacy_HSL_ChannelValues(e,o,a){if(0===o){const o=normalizeHue(e);return!1!==o&&(e[0]===n.TokenType.Dimension&&a.syntaxFlags.add(exports.SyntaxFlag.HasDimensionValues),o)}if(e[0]===n.TokenType.Percentage){3===o?a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageAlpha):a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,1,0,100);return 3===o&&(t=normalize(e[4].value,100,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}if(e[0]===n.TokenType.Number){if(3!==o)return!1;let a=normalize(e[4].value,1,0,100);return 3===o&&(a=normalize(e[4].value,1,0,1)),[n.TokenType.Number,a.toString(),e[2],e[3],{value:a,type:n.NumberType.Number}]}return!1}function normalize_modern_HSL_ChannelValues(e,o,a){if(e[0]===n.TokenType.Ident&&"none"===toLowerCaseAZ(e[4].value))return a.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[n.TokenType.Number,"none",e[2],e[3],{value:NaN,type:n.NumberType.Number}];if(0===o){const o=normalizeHue(e);return!1!==o&&(e[0]===n.TokenType.Dimension&&a.syntaxFlags.add(exports.SyntaxFlag.HasDimensionValues),o)}if(e[0]===n.TokenType.Percentage){3===o?a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageAlpha):a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=e[4].value;return 3===o&&(t=normalize(e[4].value,100,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}if(e[0]===n.TokenType.Number){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=e[4].value;return 3===o&&(t=normalize(e[4].value,1,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}return!1}function threeChannelLegacySyntax(e,o,a,s){const l=[],i=[],u=[],c=[],p={colorNotation:a,channels:[0,0,0],alpha:1,syntaxFlags:new Set(s)};let N=l;for(let o=0;o<e.value.length;o++){let a=e.value[o];if(!t.isWhitespaceNode(a)&&!t.isCommentNode(a)){if(t.isTokenNode(a)&&a.value[0]===n.TokenType.Comma){if(N===l){N=i;continue}if(N===i){N=u;continue}if(N===u){N=c;continue}if(N===c)return!1}if(t.isFunctionNode(a)){if(N===c&&"var"===toLowerCaseAZ(a.getName())){p.syntaxFlags.add(exports.SyntaxFlag.HasVariableAlpha),N.push(a);continue}if(!r.mathFunctionNames.has(toLowerCaseAZ(a.getName())))return!1;const[[e]]=r.calcFromComponentValues([[a]],{toCanonicalUnits:!0,precision:100});if(!e||!t.isTokenNode(e)||(e.value[0]===n.TokenType.Percentage||e.value[0]===n.TokenType.Number||e.value[0]===n.TokenType.Dimension)&&Number.isNaN(e.value[4].value))return!1;a=e}if(!t.isTokenNode(a))return!1;N.push(a)}}if(1!==N.length)return!1;if(1!==l.length||1!==i.length||1!==u.length)return!1;if(!t.isTokenNode(l[0])||!t.isTokenNode(i[0])||!t.isTokenNode(u[0]))return!1;const m=o(l[0].value,0,p);if(!m||m[0]!==n.TokenType.Number)return!1;const h=o(i[0].value,1,p);if(!h||h[0]!==n.TokenType.Number)return!1;const y=o(u[0].value,2,p);if(!y||y[0]!==n.TokenType.Number)return!1;const x=[m,h,y];if(1===c.length)if(p.syntaxFlags.add(exports.SyntaxFlag.HasAlpha),t.isTokenNode(c[0])){const e=o(c[0].value,3,p);if(!e||e[0]!==n.TokenType.Number)return!1;x.push(e)}else p.alpha=c[0];return p.channels=[x[0][4].value,x[1][4].value,x[2][4].value],4===x.length&&(p.alpha=x[3][4].value),p}function threeChannelSpaceSeparated(e,o,a,s,l){const i=toLowerCaseAZ(e.getName()),u=[],c=[],p=[],N=[];let m,h,y=!1;const x={colorNotation:a,channels:[0,0,0],alpha:1,syntaxFlags:new Set(s)};let T=u;for(let o=0;o<e.value.length;o++){let s=e.value[o];if(t.isWhitespaceNode(s)||t.isCommentNode(s))for(;t.isWhitespaceNode(e.value[o+1])||t.isCommentNode(e.value[o+1]);)o++;else if(T===u&&u.length&&(T=c),T===c&&c.length&&(T=p),t.isTokenNode(s)&&s.value[0]===n.TokenType.Delim&&"/"===s.value[4].value){if(T===N)return!1;T=N}else{if(t.isFunctionNode(s)){if(T===N&&"var"===toLowerCaseAZ(s.getName())){x.syntaxFlags.add(exports.SyntaxFlag.HasVariableAlpha),T.push(s);continue}if(!r.mathFunctionNames.has(toLowerCaseAZ(s.getName())))return!1;const[[e]]=r.calcFromComponentValues([[s]],{toCanonicalUnits:!0,precision:100,globals:h});if(!e||!t.isTokenNode(e)||(e.value[0]===n.TokenType.Percentage||e.value[0]===n.TokenType.Number||e.value[0]===n.TokenType.Dimension)&&Number.isNaN(e.value[4].value))return!1;s=e}if(T===u&&0===u.length&&t.isTokenNode(s)&&s.value[0]===n.TokenType.Ident&&"from"===toLowerCaseAZ(s.value[4].value)&&"hsla"!==i&&"rgba"!==i){if(y)return!1;for(;t.isWhitespaceNode(e.value[o+1])||t.isCommentNode(e.value[o+1]);)o++;if(o++,s=e.value[o],y=l(s),!1===y)return!1;x.syntaxFlags.add(exports.SyntaxFlag.RelativeColorSyntax),y.colorNotation!==a&&(y=colorDataTo(y,a)),m=normalizeRelativeColorDataChannels(y),h=noneToZeroInRelativeColorDataChannels(m)}else{if(!t.isTokenNode(s))return!1;if(s.value[0]===n.TokenType.Ident&&m&&m.has(toLowerCaseAZ(s.value[4].value))){T.push(new t.TokenNode(m.get(toLowerCaseAZ(s.value[4].value))));continue}T.push(s)}}}if(1!==T.length)return!1;if(1!==u.length||1!==c.length||1!==p.length)return!1;if(!t.isTokenNode(u[0])||!t.isTokenNode(c[0])||!t.isTokenNode(p[0]))return!1;if(m&&!m.has("alpha"))return!1;const b=o(u[0].value,0,x);if(!b||b[0]!==n.TokenType.Number)return!1;const C=o(c[0].value,1,x);if(!C||C[0]!==n.TokenType.Number)return!1;const d=o(p[0].value,2,x);if(!d||d[0]!==n.TokenType.Number)return!1;const g=[b,C,d];if(1===N.length)if(x.syntaxFlags.add(exports.SyntaxFlag.HasAlpha),t.isTokenNode(N[0])){const e=o(N[0].value,3,x);if(!e||e[0]!==n.TokenType.Number)return!1;g.push(e)}else x.alpha=N[0];else if(m&&m.has("alpha")){const e=o(m.get("alpha"),3,x);if(!e||e[0]!==n.TokenType.Number)return!1;g.push(e)}return x.channels=[g[0][4].value,g[1][4].value,g[2][4].value],4===g.length&&(x.alpha=g[3][4].value),x}function hsl(e,o){if(e.value.some((e=>t.isTokenNode(e)&&e.value[0]===n.TokenType.Comma))){const o=hslCommaSeparated(e);if(!1!==o)return o}{const n=hslSpaceSeparated(e,o);if(!1!==n)return n}return!1}function hslCommaSeparated(e){return threeChannelLegacySyntax(e,normalize_legacy_HSL_ChannelValues,exports.ColorNotation.HSL,[exports.SyntaxFlag.LegacyHSL])}function hslSpaceSeparated(e,o){return threeChannelSpaceSeparated(e,normalize_modern_HSL_ChannelValues,exports.ColorNotation.HSL,[],o)}function normalize_HWB_ChannelValues(e,o,a){if(e[0]===n.TokenType.Ident&&"none"===toLowerCaseAZ(e[4].value))return a.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[n.TokenType.Number,"none",e[2],e[3],{value:NaN,type:n.NumberType.Number}];if(0===o){const o=normalizeHue(e);return!1!==o&&(e[0]===n.TokenType.Dimension&&a.syntaxFlags.add(exports.SyntaxFlag.HasDimensionValues),o)}if(e[0]===n.TokenType.Percentage){3===o?a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageAlpha):a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=e[4].value;return 3===o&&(t=normalize(e[4].value,100,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}if(e[0]===n.TokenType.Number){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=e[4].value;return 3===o&&(t=normalize(e[4].value,1,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}return!1}function normalize_Lab_ChannelValues(e,o,a){if(e[0]===n.TokenType.Ident&&"none"===toLowerCaseAZ(e[4].value))return a.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[n.TokenType.Number,"none",e[2],e[3],{value:NaN,type:n.NumberType.Number}];if(e[0]===n.TokenType.Percentage){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,1,0,100);return 1===o||2===o?t=normalize(e[4].value,.8,-1/0,1/0):3===o&&(t=normalize(e[4].value,100,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}if(e[0]===n.TokenType.Number){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,1,0,100);return 1===o||2===o?t=normalize(e[4].value,1,-1/0,1/0):3===o&&(t=normalize(e[4].value,1,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}return!1}function lab(e,o){return threeChannelSpaceSeparated(e,normalize_Lab_ChannelValues,exports.ColorNotation.Lab,[],o)}function normalize_LCH_ChannelValues(e,o,a){if(e[0]===n.TokenType.Ident&&"none"===toLowerCaseAZ(e[4].value))return a.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[n.TokenType.Number,"none",e[2],e[3],{value:NaN,type:n.NumberType.Number}];if(2===o){const o=normalizeHue(e);return!1!==o&&(e[0]===n.TokenType.Dimension&&a.syntaxFlags.add(exports.SyntaxFlag.HasDimensionValues),o)}if(e[0]===n.TokenType.Percentage){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,1,0,100);return 1===o?t=normalize(e[4].value,100/150,0,1/0):3===o&&(t=normalize(e[4].value,100,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}if(e[0]===n.TokenType.Number){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,1,0,100);return 1===o?t=normalize(e[4].value,1,0,1/0):3===o&&(t=normalize(e[4].value,1,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}return!1}function lch(e,o){return threeChannelSpaceSeparated(e,normalize_LCH_ChannelValues,exports.ColorNotation.LCH,[],o)}const N=new Map;for(const[e,o]of Object.entries(a.namedColors))N.set(e,o);function namedColor(e){const o=N.get(toLowerCaseAZ(e));return!!o&&{colorNotation:exports.ColorNotation.RGB,channels:[o[0]/255,o[1]/255,o[2]/255],alpha:1,syntaxFlags:new Set([exports.SyntaxFlag.ColorKeyword,exports.SyntaxFlag.NamedColor])}}function normalize_OKLab_ChannelValues(e,o,a){if(e[0]===n.TokenType.Ident&&"none"===toLowerCaseAZ(e[4].value))return a.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[n.TokenType.Number,"none",e[2],e[3],{value:NaN,type:n.NumberType.Number}];if(e[0]===n.TokenType.Percentage){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,100,0,1);return 1===o||2===o?t=normalize(e[4].value,250,-1/0,1/0):3===o&&(t=normalize(e[4].value,100,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}if(e[0]===n.TokenType.Number){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,1,0,1);return 1===o||2===o?t=normalize(e[4].value,1,-1/0,1/0):3===o&&(t=normalize(e[4].value,1,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}return!1}function oklab(e,o){return threeChannelSpaceSeparated(e,normalize_OKLab_ChannelValues,exports.ColorNotation.OKLab,[],o)}function normalize_OKLCH_ChannelValues(e,o,a){if(e[0]===n.TokenType.Ident&&"none"===toLowerCaseAZ(e[4].value))return a.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[n.TokenType.Number,"none",e[2],e[3],{value:NaN,type:n.NumberType.Number}];if(2===o){const o=normalizeHue(e);return!1!==o&&(e[0]===n.TokenType.Dimension&&a.syntaxFlags.add(exports.SyntaxFlag.HasDimensionValues),o)}if(e[0]===n.TokenType.Percentage){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,100,0,1);return 1===o?t=normalize(e[4].value,250,0,1/0):3===o&&(t=normalize(e[4].value,100,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}if(e[0]===n.TokenType.Number){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,1,0,1);return 1===o?t=normalize(e[4].value,1,0,1/0):3===o&&(t=normalize(e[4].value,1,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}return!1}function oklch(e,o){return threeChannelSpaceSeparated(e,normalize_OKLCH_ChannelValues,exports.ColorNotation.OKLCH,[],o)}function normalize_legacy_sRGB_ChannelValues(e,o,a){if(e[0]===n.TokenType.Percentage){3===o?a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageAlpha):a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);const t=normalize(e[4].value,100,0,1);return[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}if(e[0]===n.TokenType.Number){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,255,0,1);return 3===o&&(t=normalize(e[4].value,1,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}return!1}function normalize_modern_sRGB_ChannelValues(e,o,a){if(e[0]===n.TokenType.Ident&&"none"===toLowerCaseAZ(e[4].value))return a.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[n.TokenType.Number,"none",e[2],e[3],{value:NaN,type:n.NumberType.Number}];if(e[0]===n.TokenType.Percentage){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,100,-1/0,1/0);return 3===o&&(t=normalize(e[4].value,100,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}if(e[0]===n.TokenType.Number){3!==o&&a.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,255,-1/0,1/0);return 3===o&&(t=normalize(e[4].value,1,0,1)),[n.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:n.NumberType.Number}]}return!1}function rgb(e,o){if(e.value.some((e=>t.isTokenNode(e)&&e.value[0]===n.TokenType.Comma))){const o=rgbCommaSeparated(e);if(!1!==o)return(!o.syntaxFlags.has(exports.SyntaxFlag.HasNumberValues)||!o.syntaxFlags.has(exports.SyntaxFlag.HasPercentageValues))&&o}else{const n=rgbSpaceSeparated(e,o);if(!1!==n)return n}return!1}function rgbCommaSeparated(e){return threeChannelLegacySyntax(e,normalize_legacy_sRGB_ChannelValues,exports.ColorNotation.RGB,[exports.SyntaxFlag.LegacyRGB])}function rgbSpaceSeparated(e,o){return threeChannelSpaceSeparated(e,normalize_modern_sRGB_ChannelValues,exports.ColorNotation.RGB,[],o)}function toPrecision(e,o=7){e=+e,o=+o;const n=(Math.floor(e)+"").length;if(o>n)return+e.toFixed(o-n);{const a=10**(n-o);return Math.round(e/a)*a}}function XYZ_D50_to_P3_Gamut(e){const o=a.xyz.XYZ_D50_to_P3(e);if(a.utils.inGamut(o))return a.utils.clip(o);let n=e.slice();return n=a.conversions.D50_to_D65(n),n=a.conversions.XYZ_to_OKLab(n),n=a.conversions.OKLab_to_OKLCH(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),a.calculations.mapGamut(n,(e=>(e=a.conversions.OKLCH_to_OKLab(e),e=a.conversions.OKLab_to_XYZ(e),e=a.conversions.XYZ_to_lin_P3(e),a.conversions.gam_P3(e))),(e=>(e=a.conversions.lin_P3(e),e=a.conversions.lin_P3_to_XYZ(e),e=a.conversions.XYZ_to_OKLab(e),a.conversions.OKLab_to_OKLCH(e))))}function serializeWithAlpha(e,o,a,r){const s=[n.TokenType.CloseParen,")",-1,-1,void 0];if("number"==typeof e.alpha){const l=Math.min(1,Math.max(0,toPrecision(Number.isNaN(e.alpha)?0:e.alpha)));return 1===toPrecision(l,4)?new t.FunctionNode(o,s,r):new t.FunctionNode(o,s,[...r,new t.WhitespaceNode([a]),new t.TokenNode([n.TokenType.Delim,"/",-1,-1,{value:"/"}]),new t.WhitespaceNode([a]),new t.TokenNode([n.TokenType.Number,toPrecision(l,4).toString(),-1,-1,{value:e.alpha,type:n.NumberType.Integer}])])}return new t.FunctionNode(o,s,[...r,new t.WhitespaceNode([a]),new t.TokenNode([n.TokenType.Delim,"/",-1,-1,{value:"/"}]),new t.WhitespaceNode([a]),e.alpha])}function XYZ_D50_to_sRGB_Gamut(e){const o=a.xyz.XYZ_D50_to_sRGB(e);if(a.utils.inGamut(o))return a.utils.clip(o);let n=e.slice();return n=a.conversions.D50_to_D65(n),n=a.conversions.XYZ_to_OKLab(n),n=a.conversions.OKLab_to_OKLCH(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),a.calculations.mapGamut(n,(e=>(e=a.conversions.OKLCH_to_OKLab(e),e=a.conversions.OKLab_to_XYZ(e),e=a.conversions.XYZ_to_lin_sRGB(e),a.conversions.gam_sRGB(e))),(e=>(e=a.conversions.lin_sRGB(e),e=a.conversions.lin_sRGB_to_XYZ(e),e=a.conversions.XYZ_to_OKLab(e),a.conversions.OKLab_to_OKLCH(e))))}exports.color=function color(e){if(t.isFunctionNode(e)){switch(toLowerCaseAZ(e.getName())){case"rgb":case"rgba":return rgb(e,color);case"hsl":case"hsla":return hsl(e,color);case"hwb":return o=color,threeChannelSpaceSeparated(e,normalize_HWB_ChannelValues,exports.ColorNotation.HWB,[],o);case"lab":return lab(e,color);case"lch":return lch(e,color);case"oklab":return oklab(e,color);case"oklch":return oklch(e,color);case"color":return color$1(e,color);case"color-mix":return colorMix(e,color)}}var o;if(t.isTokenNode(e)){if(e.value[0]===n.TokenType.Hash)return hex(e.value);if(e.value[0]===n.TokenType.Ident){const o=namedColor(e.value[4].value);return!1!==o?o:"transparent"===toLowerCaseAZ(e.value[4].value)&&{colorNotation:exports.ColorNotation.RGB,channels:[0,0,0],alpha:0,syntaxFlags:new Set([exports.SyntaxFlag.ColorKeyword])}}}return!1},exports.colorDataFitsDisplayP3_Gamut=function colorDataFitsDisplayP3_Gamut(e){const o={...e,channels:[...e.channels]};return o.channels=convertPowerlessComponentsToZeroValuesForDisplay(o.channels,o.colorNotation),!colorDataTo(o,exports.ColorNotation.Display_P3).channels.find((e=>e<-1e-5||e>1.00001))},exports.colorDataFitsRGB_Gamut=function colorDataFitsRGB_Gamut(e){const o={...e,channels:[...e.channels]};return o.channels=convertPowerlessComponentsToZeroValuesForDisplay(o.channels,o.colorNotation),!colorDataTo(o,exports.ColorNotation.RGB).channels.find((e=>e<-1e-5||e>1.00001))},exports.colorDataTo=colorDataTo,exports.serializeOKLCH=function serializeOKLCH(e){e.channels=convertPowerlessComponentsToZeroValuesForDisplay(e.channels,e.colorNotation);let o=e.channels.map((e=>Number.isNaN(e)?0:e));e.colorNotation!==exports.ColorNotation.OKLCH&&(o=a.xyz.XYZ_D50_to_OKLCH(colorData_to_XYZ_D50(e).channels));const r=toPrecision(o[0],6),s=toPrecision(o[1],6),l=toPrecision(o[2],6),i=[n.TokenType.Function,"oklch(",-1,-1,{value:"oklch"}],u=[n.TokenType.Whitespace," ",-1,-1,void 0];return serializeWithAlpha(e,i,u,[new t.TokenNode([n.TokenType.Number,r.toString(),-1,-1,{value:o[0],type:n.NumberType.Number}]),new t.WhitespaceNode([u]),new t.TokenNode([n.TokenType.Number,s.toString(),-1,-1,{value:o[1],type:n.NumberType.Number}]),new t.WhitespaceNode([u]),new t.TokenNode([n.TokenType.Number,l.toString(),-1,-1,{value:o[2],type:n.NumberType.Number}])])},exports.serializeP3=function serializeP3(e,o=!0){e.channels=convertPowerlessComponentsToZeroValuesForDisplay(e.channels,e.colorNotation);let r=e.channels.map((e=>Number.isNaN(e)?0:e));e.colorNotation!==exports.ColorNotation.Display_P3&&(r=o?XYZ_D50_to_P3_Gamut(colorData_to_XYZ_D50(e).channels):a.xyz.XYZ_D50_to_P3(colorData_to_XYZ_D50(e).channels));const s=toPrecision(r[0],6),l=toPrecision(r[1],6),i=toPrecision(r[2],6),u=[n.TokenType.Function,"color(",-1,-1,{value:"color"}],c=[n.TokenType.Whitespace," ",-1,-1,void 0];return serializeWithAlpha(e,u,c,[new t.TokenNode([n.TokenType.Ident,"display-p3",-1,-1,{value:"display-p3"}]),new t.WhitespaceNode([c]),new t.TokenNode([n.TokenType.Number,s.toString(),-1,-1,{value:r[0],type:n.NumberType.Number}]),new t.WhitespaceNode([c]),new t.TokenNode([n.TokenType.Number,l.toString(),-1,-1,{value:r[1],type:n.NumberType.Number}]),new t.WhitespaceNode([c]),new t.TokenNode([n.TokenType.Number,i.toString(),-1,-1,{value:r[2],type:n.NumberType.Number}])])},exports.serializeRGB=function serializeRGB(e,o=!0){e.channels=convertPowerlessComponentsToZeroValuesForDisplay(e.channels,e.colorNotation);let r=e.channels.map((e=>Number.isNaN(e)?0:e));r=o?XYZ_D50_to_sRGB_Gamut(colorData_to_XYZ_D50(e).channels):a.xyz.XYZ_D50_to_sRGB(colorData_to_XYZ_D50(e).channels);const s=Math.min(255,Math.max(0,Math.round(255*toPrecision(r[0])))),l=Math.min(255,Math.max(0,Math.round(255*toPrecision(r[1])))),i=Math.min(255,Math.max(0,Math.round(255*toPrecision(r[2])))),u=[n.TokenType.CloseParen,")",-1,-1,void 0],c=[n.TokenType.Whitespace," ",-1,-1,void 0],p=[n.TokenType.Comma,",",-1,-1,void 0],N=[new t.TokenNode([n.TokenType.Number,s.toString(),-1,-1,{value:r[0],type:n.NumberType.Integer}]),new t.TokenNode(p),new t.WhitespaceNode([c]),new t.TokenNode([n.TokenType.Number,l.toString(),-1,-1,{value:r[1],type:n.NumberType.Integer}]),new t.TokenNode(p),new t.WhitespaceNode([c]),new t.TokenNode([n.TokenType.Number,i.toString(),-1,-1,{value:r[2],type:n.NumberType.Integer}])];if("number"==typeof e.alpha){const o=Math.min(1,Math.max(0,toPrecision(Number.isNaN(e.alpha)?0:e.alpha)));return 1===toPrecision(o,4)?new t.FunctionNode([n.TokenType.Function,"rgb(",-1,-1,{value:"rgb"}],u,N):new t.FunctionNode([n.TokenType.Function,"rgba(",-1,-1,{value:"rgba"}],u,[...N,new t.TokenNode(p),new t.WhitespaceNode([c]),new t.TokenNode([n.TokenType.Number,toPrecision(o,4).toString(),-1,-1,{value:e.alpha,type:n.NumberType.Number}])])}return new t.FunctionNode([n.TokenType.Function,"rgba(",-1,-1,{value:"rgba"}],u,[...N,new t.TokenNode(p),new t.WhitespaceNode([c]),e.alpha])}; diff --git a/node_modules/@csstools/css-color-parser/dist/index.d.ts b/node_modules/@csstools/css-color-parser/dist/index.d.ts new file mode 100644 index 00000000..94de2a86 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/index.d.ts @@ -0,0 +1,10 @@ +import type { ColorData } from './color-data'; +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'; +export declare function color(colorNode: ComponentValue): ColorData | false; diff --git a/node_modules/@csstools/css-color-parser/dist/index.mjs b/node_modules/@csstools/css-color-parser/dist/index.mjs new file mode 100644 index 00000000..950bcf13 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/index.mjs @@ -0,0 +1 @@ +import{TokenType as e,NumberType as a}from"@csstools/css-tokenizer";import{xyz as n,namedColors as r,utils as o,conversions as t,calculations as l}from"@csstools/color-helpers";import{isWhitespaceNode as s,isCommentNode as u,isTokenNode as i,isFunctionNode as c,TokenNode as m,FunctionNode as h,WhitespaceNode as N}from"@csstools/css-parser-algorithms";import{mathFunctionNames as p,calcFromComponentValues as b}from"@csstools/css-calc";var _,g;function colorData_to_XYZ_D50(e){switch(e.colorNotation){case _.HEX:case _.RGB:case _.sRGB:return{...e,colorNotation:_.XYZ_D50,channels:n.sRGB_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case _.Linear_sRGB:return{...e,colorNotation:_.XYZ_D50,channels:n.lin_sRGB_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case _.Display_P3:return{...e,colorNotation:_.XYZ_D50,channels:n.P3_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case _.Rec2020:return{...e,colorNotation:_.XYZ_D50,channels:n.rec_2020_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case _.A98_RGB:return{...e,colorNotation:_.XYZ_D50,channels:n.a98_RGB_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case _.ProPhoto_RGB:return{...e,colorNotation:_.XYZ_D50,channels:n.ProPhoto_RGB_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case _.HSL:return{...e,colorNotation:_.XYZ_D50,channels:n.HSL_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case _.HWB:return{...e,colorNotation:_.XYZ_D50,channels:n.HWB_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case _.Lab:return{...e,colorNotation:_.XYZ_D50,channels:n.Lab_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case _.OKLab:return{...e,colorNotation:_.XYZ_D50,channels:n.OKLab_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case _.LCH:return{...e,colorNotation:_.XYZ_D50,channels:n.LCH_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case _.OKLCH:return{...e,colorNotation:_.XYZ_D50,channels:n.OKLCH_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case _.XYZ_D50:return{...e,colorNotation:_.XYZ_D50,channels:n.XYZ_D50_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};case _.XYZ_D65:return{...e,colorNotation:_.XYZ_D50,channels:n.XYZ_D65_to_XYZ_D50(e.channels.map((e=>Number.isNaN(e)?0:e)))};default:throw new Error("Unsupported color notation")}}!function(e){e.A98_RGB="a98-rgb",e.Display_P3="display-p3",e.HEX="hex",e.HSL="hsl",e.HWB="hwb",e.LCH="lch",e.Lab="lab",e.Linear_sRGB="srgb-linear",e.OKLCH="oklch",e.OKLab="oklab",e.ProPhoto_RGB="prophoto-rgb",e.RGB="rgb",e.sRGB="srgb",e.Rec2020="rec2020",e.XYZ_D50="xyz-d50",e.XYZ_D65="xyz-d65"}(_||(_={})),function(e){e.ColorKeyword="color-keyword",e.HasAlpha="has-alpha",e.HasDimensionValues="has-dimension-values",e.HasNoneKeywords="has-none-keywords",e.HasNumberValues="has-number-values",e.HasPercentageAlpha="has-percentage-alpha",e.HasPercentageValues="has-percentage-values",e.HasVariableAlpha="has-variable-alpha",e.Hex="hex",e.LegacyHSL="legacy-hsl",e.LegacyRGB="legacy-rgb",e.NamedColor="named-color",e.RelativeColorSyntax="relative-color-syntax",e.ColorMix="color-mix"}(g||(g={}));const f=new Set([_.A98_RGB,_.Display_P3,_.HEX,_.Linear_sRGB,_.ProPhoto_RGB,_.RGB,_.sRGB,_.Rec2020,_.XYZ_D50,_.XYZ_D65]);function colorDataTo(e,a){const r={...e};if(e.colorNotation!==a){const e=colorData_to_XYZ_D50(r);switch(a){case _.HEX:case _.RGB:r.colorNotation=_.RGB,r.channels=n.XYZ_D50_to_sRGB(e.channels);break;case _.sRGB:r.colorNotation=_.sRGB,r.channels=n.XYZ_D50_to_sRGB(e.channels);break;case _.Linear_sRGB:r.colorNotation=_.Linear_sRGB,r.channels=n.XYZ_D50_to_lin_sRGB(e.channels);break;case _.Display_P3:r.colorNotation=_.Display_P3,r.channels=n.XYZ_D50_to_P3(e.channels);break;case _.Rec2020:r.colorNotation=_.Rec2020,r.channels=n.XYZ_D50_to_rec_2020(e.channels);break;case _.ProPhoto_RGB:r.colorNotation=_.ProPhoto_RGB,r.channels=n.XYZ_D50_to_ProPhoto(e.channels);break;case _.A98_RGB:r.colorNotation=_.A98_RGB,r.channels=n.XYZ_D50_to_a98_RGB(e.channels);break;case _.HSL:r.colorNotation=_.HSL,r.channels=n.XYZ_D50_to_HSL(e.channels);break;case _.HWB:r.colorNotation=_.HWB,r.channels=n.XYZ_D50_to_HWB(e.channels);break;case _.Lab:r.colorNotation=_.Lab,r.channels=n.XYZ_D50_to_Lab(e.channels);break;case _.LCH:r.colorNotation=_.LCH,r.channels=n.XYZ_D50_to_LCH(e.channels);break;case _.OKLCH:r.colorNotation=_.OKLCH,r.channels=n.XYZ_D50_to_OKLCH(e.channels);break;case _.OKLab:r.colorNotation=_.OKLab,r.channels=n.XYZ_D50_to_OKLab(e.channels);break;case _.XYZ_D50:r.colorNotation=_.XYZ_D50,r.channels=n.XYZ_D50_to_XYZ_D50(e.channels);break;case _.XYZ_D65:r.colorNotation=_.XYZ_D65,r.channels=n.XYZ_D50_to_XYZ_D65(e.channels);break;default:throw new Error("Unsupported color notation")}}else r.channels=e.channels.map((e=>Number.isNaN(e)?0:e));if(a===e.colorNotation)r.channels=carryForwardMissingComponents(e.channels,[0,1,2],r.channels,[0,1,2]);else if(f.has(a)&&f.has(e.colorNotation))r.channels=carryForwardMissingComponents(e.channels,[0,1,2],r.channels,[0,1,2]);else switch(a){case _.HSL:switch(e.colorNotation){case _.HWB:r.channels=carryForwardMissingComponents(e.channels,[0],r.channels,[0]);break;case _.Lab:case _.OKLab:r.channels=carryForwardMissingComponents(e.channels,[2],r.channels,[0]);break;case _.LCH:case _.OKLCH:r.channels=carryForwardMissingComponents(e.channels,[0,1,2],r.channels,[2,1,0])}break;case _.HWB:switch(e.colorNotation){case _.HSL:r.channels=carryForwardMissingComponents(e.channels,[0],r.channels,[0]);break;case _.LCH:case _.OKLCH:r.channels=carryForwardMissingComponents(e.channels,[0],r.channels,[2])}break;case _.Lab:case _.OKLab:switch(e.colorNotation){case _.HSL:r.channels=carryForwardMissingComponents(e.channels,[0],r.channels,[2]);break;case _.Lab:case _.OKLab:r.channels=carryForwardMissingComponents(e.channels,[0,1,2],r.channels,[0,1,2]);break;case _.LCH:case _.OKLCH:r.channels=carryForwardMissingComponents(e.channels,[0],r.channels,[0])}break;case _.LCH:case _.OKLCH:switch(e.colorNotation){case _.HSL:r.channels=carryForwardMissingComponents(e.channels,[0,1,2],r.channels,[2,1,0]);break;case _.HWB:r.channels=carryForwardMissingComponents(e.channels,[0],r.channels,[2]);break;case _.Lab:case _.OKLab:r.channels=carryForwardMissingComponents(e.channels,[0],r.channels,[0]);break;case _.LCH:case _.OKLCH:r.channels=carryForwardMissingComponents(e.channels,[0,1,2],r.channels,[0,1,2])}}return r.channels=convertPowerlessComponentsToMissingComponents(r.channels,a),r}function convertPowerlessComponentsToMissingComponents(e,a){const n=[...e];switch(a){case _.HSL:reducePrecision(n[1],4)<=0&&(n[0]=NaN);break;case _.HWB:Math.max(0,reducePrecision(n[1],4))+Math.max(0,reducePrecision(n[2],4))>=100&&(n[0]=NaN);break;case _.LCH:reducePrecision(n[1],4)<=0&&(n[2]=NaN);break;case _.OKLCH:reducePrecision(n[1],6)<=0&&(n[2]=NaN)}return n}function convertPowerlessComponentsToZeroValuesForDisplay(e,a){const n=[...e];switch(a){case _.HSL:(reducePrecision(n[2])<=0||reducePrecision(n[2])>=100)&&(n[0]=NaN,n[1]=NaN),reducePrecision(n[1])<=0&&(n[0]=NaN);break;case _.HWB:Math.max(0,reducePrecision(n[1]))+Math.max(0,reducePrecision(n[2]))>=100&&(n[0]=NaN);break;case _.Lab:(reducePrecision(n[0])<=0||reducePrecision(n[0])>=100)&&(n[1]=NaN,n[2]=NaN);break;case _.LCH:reducePrecision(n[1])<=0&&(n[2]=NaN),(reducePrecision(n[0])<=0||reducePrecision(n[0])>=100)&&(n[1]=NaN,n[2]=NaN);break;case _.OKLab:(reducePrecision(n[0])<=0||reducePrecision(n[0])>=1)&&(n[1]=NaN,n[2]=NaN);break;case _.OKLCH:reducePrecision(n[1])<=0&&(n[2]=NaN),(reducePrecision(n[0])<=0||reducePrecision(n[0])>=1)&&(n[1]=NaN,n[2]=NaN)}return n}function carryForwardMissingComponents(e,a,n,r){const o=[...n];for(const n of a)Number.isNaN(e[a[n]])&&(o[r[n]]=NaN);return o}function normalizeRelativeColorDataChannels(e){const a=new Map;switch(e.colorNotation){case _.RGB:case _.HEX:a.set("r",dummyNumberToken(255*e.channels[0])),a.set("g",dummyNumberToken(255*e.channels[1])),a.set("b",dummyNumberToken(255*e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha));break;case _.HSL:a.set("h",dummyNumberToken(e.channels[0])),a.set("s",dummyNumberToken(e.channels[1])),a.set("l",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha));break;case _.HWB:a.set("h",dummyNumberToken(e.channels[0])),a.set("w",dummyNumberToken(e.channels[1])),a.set("b",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha));break;case _.Lab:case _.OKLab:a.set("l",dummyNumberToken(e.channels[0])),a.set("a",dummyNumberToken(e.channels[1])),a.set("b",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha));break;case _.LCH:case _.OKLCH:a.set("l",dummyNumberToken(e.channels[0])),a.set("c",dummyNumberToken(e.channels[1])),a.set("h",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha));break;case _.sRGB:case _.A98_RGB:case _.Display_P3:case _.Rec2020:case _.Linear_sRGB:case _.ProPhoto_RGB:a.set("r",dummyNumberToken(e.channels[0])),a.set("g",dummyNumberToken(e.channels[1])),a.set("b",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha));break;case _.XYZ_D50:case _.XYZ_D65:a.set("x",dummyNumberToken(e.channels[0])),a.set("y",dummyNumberToken(e.channels[1])),a.set("z",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha))}return a}function noneToZeroInRelativeColorDataChannels(e){const a=new Map(e);for(const[n,r]of e)Number.isNaN(r[4].value)&&a.set(n,dummyNumberToken(0));return a}function dummyNumberToken(n){return[e.Number,n.toString(),-1,-1,{value:n,type:a.Number}]}function reducePrecision(e,a=7){if(Number.isNaN(e))return 0;const n=Math.pow(10,a);return Math.round(e*n)/n}function colorDataFitsRGB_Gamut(e){const a={...e,channels:[...e.channels]};a.channels=convertPowerlessComponentsToZeroValuesForDisplay(a.channels,a.colorNotation);return!colorDataTo(a,_.RGB).channels.find((e=>e<-1e-5||e>1.00001))}function colorDataFitsDisplayP3_Gamut(e){const a={...e,channels:[...e.channels]};a.channels=convertPowerlessComponentsToZeroValuesForDisplay(a.channels,a.colorNotation);return!colorDataTo(a,_.Display_P3).channels.find((e=>e<-1e-5||e>1.00001))}function normalize(e,a,n,r){return Math.min(Math.max(e/a,n),r)}const v=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(v,(e=>String.fromCharCode(e.charCodeAt(0)+32)))}function normalize_Color_ChannelValues(n,r,o){if(n[0]===e.Ident&&"none"===toLowerCaseAZ(n[4].value))return o.syntaxFlags.add(g.HasNoneKeywords),[e.Number,"none",n[2],n[3],{value:NaN,type:a.Number}];if(n[0]===e.Percentage){3!==r&&o.syntaxFlags.add(g.HasPercentageValues);let t=normalize(n[4].value,100,-1/0,1/0);return 3===r&&(t=normalize(n[4].value,100,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}if(n[0]===e.Number){3!==r&&o.syntaxFlags.add(g.HasNumberValues);let t=normalize(n[4].value,1,-1/0,1/0);return 3===r&&(t=normalize(n[4].value,1,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}return!1}const d=new Set(["srgb","srgb-linear","display-p3","a98-rgb","prophoto-rgb","rec2020","xyz","xyz-d50","xyz-d65"]);function color$1(a,n){const r=[],o=[],t=[],l=[];let h,N,f=!1,v=!1;const y={colorNotation:_.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])};let C=r;for(let _=0;_<a.value.length;_++){let w=a.value[_];if(s(w)||u(w))for(;s(a.value[_+1])||u(a.value[_+1]);)_++;else if(C===r&&r.length&&(C=o),C===o&&o.length&&(C=t),i(w)&&w.value[0]===e.Delim&&"/"===w.value[4].value){if(C===l)return!1;C=l}else{if(c(w)){if(C===l&&"var"===toLowerCaseAZ(w.getName())){y.syntaxFlags.add(g.HasVariableAlpha),C.push(w);continue}if(!p.has(toLowerCaseAZ(w.getName())))return!1;const[[a]]=b([[w]],{toCanonicalUnits:!0,precision:100,globals:N});if(!a||!i(a)||(a.value[0]===e.Percentage||a.value[0]===e.Number||a.value[0]===e.Dimension)&&Number.isNaN(a.value[4].value))return!1;w=a}if(C===r&&0===r.length&&i(w)&&w.value[0]===e.Ident&&d.has(toLowerCaseAZ(w.value[4].value))){if(f)return!1;f=toLowerCaseAZ(w.value[4].value),y.colorNotation=colorSpaceNameToColorNotation(f),v&&(v.colorNotation!==y.colorNotation&&(v=colorDataTo(v,y.colorNotation)),h=normalizeRelativeColorDataChannels(v),N=noneToZeroInRelativeColorDataChannels(h))}else if(C===r&&0===r.length&&i(w)&&w.value[0]===e.Ident&&"from"===toLowerCaseAZ(w.value[4].value)){if(v)return!1;if(f)return!1;for(;s(a.value[_+1])||u(a.value[_+1]);)_++;if(_++,w=a.value[_],v=n(w),!1===v)return!1;y.syntaxFlags.add(g.RelativeColorSyntax)}else{if(!i(w))return!1;if(w.value[0]===e.Ident&&h&&h.has(toLowerCaseAZ(w.value[4].value))){C.push(new m(h.get(toLowerCaseAZ(w.value[4].value))));continue}C.push(w)}}}if(!f)return!1;if(1!==C.length)return!1;if(1!==r.length||1!==o.length||1!==t.length)return!1;if(!i(r[0])||!i(o[0])||!i(t[0]))return!1;if(h&&!h.has("alpha"))return!1;const w=normalize_Color_ChannelValues(r[0].value,0,y);if(!w||w[0]!==e.Number)return!1;const L=normalize_Color_ChannelValues(o[0].value,1,y);if(!L||L[0]!==e.Number)return!1;const H=normalize_Color_ChannelValues(t[0].value,2,y);if(!H||H[0]!==e.Number)return!1;const D=[w,L,H];if(1===l.length)if(y.syntaxFlags.add(g.HasAlpha),i(l[0])){const a=normalize_Color_ChannelValues(l[0].value,3,y);if(!a||a[0]!==e.Number)return!1;D.push(a)}else y.alpha=l[0];else if(h&&h.has("alpha")){const a=normalize_Color_ChannelValues(h.get("alpha"),3,y);if(!a||a[0]!==e.Number)return!1;D.push(a)}return y.channels=[D[0][4].value,D[1][4].value,D[2][4].value],4===D.length&&(y.alpha=D[3][4].value),y}function colorSpaceNameToColorNotation(e){switch(e){case"srgb":return _.sRGB;case"srgb-linear":return _.Linear_sRGB;case"display-p3":return _.Display_P3;case"a98-rgb":return _.A98_RGB;case"prophoto-rgb":return _.ProPhoto_RGB;case"rec2020":return _.Rec2020;case"xyz":case"xyz-d65":return _.XYZ_D65;case"xyz-d50":return _.XYZ_D50;default:throw new Error("Unknown color space name: "+e)}}const y=new Set(["srgb","srgb-linear","lab","oklab","xyz","xyz-d50","xyz-d65"]),C=new Set(["hsl","hwb","lch","oklch"]),w=new Set(["shorter","longer","increasing","decreasing"]);function colorMix(a,n){let r=null,o=null,t=null,l=!1;for(let c=0;c<a.value.length;c++){const m=a.value[c];if(!s(m)&&!u(m)){if(i(m)&&m.value[0]===e.Ident){if(!r&&"in"===toLowerCaseAZ(m.value[4].value)){r=m;continue}if(r&&!o){o=toLowerCaseAZ(m.value[4].value);continue}if(r&&o&&!t&&C.has(o)){t=toLowerCaseAZ(m.value[4].value);continue}if(r&&o&&t&&!l&&"hue"===toLowerCaseAZ(m.value[4].value)){l=!0;continue}return!1}return!(!i(m)||m.value[0]!==e.Comma)&&(!!o&&(t||l?!!(o&&t&&l&&C.has(o)&&w.has(t))&&colorMixPolar(o,t,colorMixComponents(a.value.slice(c+1),n)):y.has(o)?colorMixRectangular(o,colorMixComponents(a.value.slice(c+1),n)):!!C.has(o)&&colorMixPolar(o,"shorter",colorMixComponents(a.value.slice(c+1),n))))}}return!1}function colorMixComponents(a,n){const r=[];let o=1,t=!1,l=!1;for(let o=0;o<a.length;o++){let m=a[o];if(!s(m)&&!u(m)){if(!i(m)||m.value[0]!==e.Comma){if(!t){const e=n(m);if(e){t=e;continue}}if(!l){if(c(m)&&p.has(toLowerCaseAZ(m.getName()))&&([[m]]=b([[m]],{toCanonicalUnits:!0,precision:100}),!m||!i(m)||(m.value[0]===e.Percentage||m.value[0]===e.Number||m.value[0]===e.Dimension)&&Number.isNaN(m.value[4].value)))return!1;if(i(m)&&m.value[0]===e.Percentage&&m.value[4].value>=0){l=m.value[4].value;continue}}return!1}if(!t)return!1;r.push({color:t,percentage:l}),t=!1,l=!1}}if(t&&r.push({color:t,percentage:l}),2!==r.length)return!1;let m=r[0].percentage,h=r[1].percentage;return(!1===m||!(m<0||m>100))&&((!1===h||!(h<0||h>100))&&(!1===m&&!1===h?(m=50,h=50):!1!==m&&!1===h?h=100-m:!1===m&&!1!==h&&(m=100-h),(0!==m||0!==h)&&(!1!==m&&!1!==h&&(m+h>100&&(m=m/(m+h)*100,h=h/(m+h)*100),m+h<100&&(o=(m+h)/100,m=m/(m+h)*100,h=h/(m+h)*100),{a:{color:r[0].color,percentage:m},b:{color:r[1].color,percentage:h},alphaMultiplier:o}))))}function colorMixRectangular(e,a){if(!a)return!1;const n=a.a.color,r=a.b.color,o=a.a.percentage/100;let t=n.channels,l=r.channels,s=_.RGB,u=n.alpha;if("number"!=typeof u)return!1;let i=r.alpha;if("number"!=typeof i)return!1;switch(u=Number.isNaN(u)?i:u,i=Number.isNaN(i)?u:i,e){case"srgb":s=_.RGB;break;case"srgb-linear":s=_.Linear_sRGB;break;case"lab":s=_.Lab;break;case"oklab":s=_.OKLab;break;case"xyz-d50":s=_.XYZ_D50;break;case"xyz":case"xyz-d65":s=_.XYZ_D65}t=colorDataTo(n,s).channels,l=colorDataTo(r,s).channels,t[0]=fillInMissingComponent(t[0],l[0]),l[0]=fillInMissingComponent(l[0],t[0]),t[1]=fillInMissingComponent(t[1],l[1]),l[1]=fillInMissingComponent(l[1],t[1]),t[2]=fillInMissingComponent(t[2],l[2]),l[2]=fillInMissingComponent(l[2],t[2]),t[0]=premultiply(t[0],u),t[1]=premultiply(t[1],u),t[2]=premultiply(t[2],u),l[0]=premultiply(l[0],i),l[1]=premultiply(l[1],i),l[2]=premultiply(l[2],i);const c=interpolate(u,i,o);return{colorNotation:s,channels:[un_premultiply(interpolate(t[0],l[0],o),c),un_premultiply(interpolate(t[1],l[1],o),c),un_premultiply(interpolate(t[2],l[2],o),c)],alpha:c*a.alphaMultiplier,syntaxFlags:new Set([g.ColorMix])}}function colorMixPolar(e,a,n){if(!n)return!1;const r=n.a.color,o=n.b.color,t=n.a.percentage/100;let l=r.channels,s=o.channels,u=0,i=0,c=0,m=0,h=0,N=0,p=_.RGB,b=r.alpha;if("number"!=typeof b)return!1;let f=o.alpha;if("number"!=typeof f)return!1;switch(b=Number.isNaN(b)?f:b,f=Number.isNaN(f)?b:f,e){case"hsl":p=_.HSL;break;case"hwb":p=_.HWB;break;case"lch":p=_.LCH;break;case"oklch":p=_.OKLCH}switch(l=colorDataTo(r,p).channels,s=colorDataTo(o,p).channels,e){case"hsl":case"hwb":u=l[0],i=s[0],c=l[1],m=s[1],h=l[2],N=s[2];break;case"lch":case"oklch":c=l[0],m=s[0],h=l[1],N=s[1],u=l[2],i=s[2]}u=fillInMissingComponent(u,i),Number.isNaN(u)&&(u=0),i=fillInMissingComponent(i,u),Number.isNaN(i)&&(i=0),c=fillInMissingComponent(c,m),m=fillInMissingComponent(m,c),h=fillInMissingComponent(h,N),N=fillInMissingComponent(N,h);const v=i-u;switch(a){case"shorter":v>180?u+=360:v<-180&&(i+=360);break;case"longer":-180<v&&v<180&&(v>0?u+=360:i+=360);break;case"increasing":v<0&&(i+=360);break;case"decreasing":v>0&&(u+=360);break;default:throw new Error("Unknown hue interpolation method")}c=premultiply(c,b),h=premultiply(h,b),m=premultiply(m,f),N=premultiply(N,f);let d=[0,0,0];const y=interpolate(b,f,t);switch(e){case"hsl":case"hwb":d=[interpolate(u,i,t),un_premultiply(interpolate(c,m,t),y),un_premultiply(interpolate(h,N,t),y)];break;case"lch":case"oklch":d=[un_premultiply(interpolate(c,m,t),y),un_premultiply(interpolate(h,N,t),y),interpolate(u,i,t)]}return{colorNotation:p,channels:d,alpha:y*n.alphaMultiplier,syntaxFlags:new Set([g.ColorMix])}}function fillInMissingComponent(e,a){return Number.isNaN(e)?a:e}function interpolate(e,a,n){return e*n+a*(1-n)}function premultiply(e,a){return Number.isNaN(a)?e:Number.isNaN(e)?NaN:e*a}function un_premultiply(e,a){return 0===a||Number.isNaN(a)?e:Number.isNaN(e)?NaN:e/a}function hex(e){const a=toLowerCaseAZ(e[4].value);if(a.match(/[^a-f0-9]/))return!1;const n={colorNotation:_.HEX,channels:[0,0,0],alpha:1,syntaxFlags:new Set([g.Hex])},r=a.length;if(3===r){const e=a[0],r=a[1],o=a[2];return n.channels=[parseInt(e+e,16)/255,parseInt(r+r,16)/255,parseInt(o+o,16)/255],n}if(6===r){const e=a[0]+a[1],r=a[2]+a[3],o=a[4]+a[5];return n.channels=[parseInt(e,16)/255,parseInt(r,16)/255,parseInt(o,16)/255],n}if(4===r){const e=a[0],r=a[1],o=a[2],t=a[3];return n.channels=[parseInt(e+e,16)/255,parseInt(r+r,16)/255,parseInt(o+o,16)/255],n.alpha=parseInt(t+t,16)/255,n.syntaxFlags.add(g.HasAlpha),n}if(8===r){const e=a[0]+a[1],r=a[2]+a[3],o=a[4]+a[5],t=a[6]+a[7];return n.channels=[parseInt(e,16)/255,parseInt(r,16)/255,parseInt(o,16)/255],n.alpha=parseInt(t,16)/255,n.syntaxFlags.add(g.HasAlpha),n}return!1}function normalizeHue(n){if(n[0]===e.Number)return n[4].value=n[4].value%360,n[1]=n[4].value.toString(),n;if(n[0]===e.Dimension){let r=n[4].value;switch(toLowerCaseAZ(n[4].unit)){case"deg":break;case"rad":r=180*n[4].value/Math.PI;break;case"grad":r=.9*n[4].value;break;case"turn":r=360*n[4].value;break;default:return!1}return r%=360,[e.Number,r.toString(),n[2],n[3],{value:r,type:a.Number}]}return!1}function normalize_legacy_HSL_ChannelValues(n,r,o){if(0===r){const a=normalizeHue(n);return!1!==a&&(n[0]===e.Dimension&&o.syntaxFlags.add(g.HasDimensionValues),a)}if(n[0]===e.Percentage){3===r?o.syntaxFlags.add(g.HasPercentageAlpha):o.syntaxFlags.add(g.HasPercentageValues);let t=normalize(n[4].value,1,0,100);return 3===r&&(t=normalize(n[4].value,100,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}if(n[0]===e.Number){if(3!==r)return!1;let o=normalize(n[4].value,1,0,100);return 3===r&&(o=normalize(n[4].value,1,0,1)),[e.Number,o.toString(),n[2],n[3],{value:o,type:a.Number}]}return!1}function normalize_modern_HSL_ChannelValues(n,r,o){if(n[0]===e.Ident&&"none"===toLowerCaseAZ(n[4].value))return o.syntaxFlags.add(g.HasNoneKeywords),[e.Number,"none",n[2],n[3],{value:NaN,type:a.Number}];if(0===r){const a=normalizeHue(n);return!1!==a&&(n[0]===e.Dimension&&o.syntaxFlags.add(g.HasDimensionValues),a)}if(n[0]===e.Percentage){3===r?o.syntaxFlags.add(g.HasPercentageAlpha):o.syntaxFlags.add(g.HasPercentageValues);let t=n[4].value;return 3===r&&(t=normalize(n[4].value,100,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}if(n[0]===e.Number){3!==r&&o.syntaxFlags.add(g.HasNumberValues);let t=n[4].value;return 3===r&&(t=normalize(n[4].value,1,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}return!1}function threeChannelLegacySyntax(a,n,r,o){const t=[],l=[],m=[],h=[],N={colorNotation:r,channels:[0,0,0],alpha:1,syntaxFlags:new Set(o)};let _=t;for(let n=0;n<a.value.length;n++){let r=a.value[n];if(!s(r)&&!u(r)){if(i(r)&&r.value[0]===e.Comma){if(_===t){_=l;continue}if(_===l){_=m;continue}if(_===m){_=h;continue}if(_===h)return!1}if(c(r)){if(_===h&&"var"===toLowerCaseAZ(r.getName())){N.syntaxFlags.add(g.HasVariableAlpha),_.push(r);continue}if(!p.has(toLowerCaseAZ(r.getName())))return!1;const[[a]]=b([[r]],{toCanonicalUnits:!0,precision:100});if(!a||!i(a)||(a.value[0]===e.Percentage||a.value[0]===e.Number||a.value[0]===e.Dimension)&&Number.isNaN(a.value[4].value))return!1;r=a}if(!i(r))return!1;_.push(r)}}if(1!==_.length)return!1;if(1!==t.length||1!==l.length||1!==m.length)return!1;if(!i(t[0])||!i(l[0])||!i(m[0]))return!1;const f=n(t[0].value,0,N);if(!f||f[0]!==e.Number)return!1;const v=n(l[0].value,1,N);if(!v||v[0]!==e.Number)return!1;const d=n(m[0].value,2,N);if(!d||d[0]!==e.Number)return!1;const y=[f,v,d];if(1===h.length)if(N.syntaxFlags.add(g.HasAlpha),i(h[0])){const a=n(h[0].value,3,N);if(!a||a[0]!==e.Number)return!1;y.push(a)}else N.alpha=h[0];return N.channels=[y[0][4].value,y[1][4].value,y[2][4].value],4===y.length&&(N.alpha=y[3][4].value),N}function threeChannelSpaceSeparated(a,n,r,o,t){const l=toLowerCaseAZ(a.getName()),h=[],N=[],_=[],f=[];let v,d,y=!1;const C={colorNotation:r,channels:[0,0,0],alpha:1,syntaxFlags:new Set(o)};let w=h;for(let n=0;n<a.value.length;n++){let o=a.value[n];if(s(o)||u(o))for(;s(a.value[n+1])||u(a.value[n+1]);)n++;else if(w===h&&h.length&&(w=N),w===N&&N.length&&(w=_),i(o)&&o.value[0]===e.Delim&&"/"===o.value[4].value){if(w===f)return!1;w=f}else{if(c(o)){if(w===f&&"var"===toLowerCaseAZ(o.getName())){C.syntaxFlags.add(g.HasVariableAlpha),w.push(o);continue}if(!p.has(toLowerCaseAZ(o.getName())))return!1;const[[a]]=b([[o]],{toCanonicalUnits:!0,precision:100,globals:d});if(!a||!i(a)||(a.value[0]===e.Percentage||a.value[0]===e.Number||a.value[0]===e.Dimension)&&Number.isNaN(a.value[4].value))return!1;o=a}if(w===h&&0===h.length&&i(o)&&o.value[0]===e.Ident&&"from"===toLowerCaseAZ(o.value[4].value)&&"hsla"!==l&&"rgba"!==l){if(y)return!1;for(;s(a.value[n+1])||u(a.value[n+1]);)n++;if(n++,o=a.value[n],y=t(o),!1===y)return!1;C.syntaxFlags.add(g.RelativeColorSyntax),y.colorNotation!==r&&(y=colorDataTo(y,r)),v=normalizeRelativeColorDataChannels(y),d=noneToZeroInRelativeColorDataChannels(v)}else{if(!i(o))return!1;if(o.value[0]===e.Ident&&v&&v.has(toLowerCaseAZ(o.value[4].value))){w.push(new m(v.get(toLowerCaseAZ(o.value[4].value))));continue}w.push(o)}}}if(1!==w.length)return!1;if(1!==h.length||1!==N.length||1!==_.length)return!1;if(!i(h[0])||!i(N[0])||!i(_[0]))return!1;if(v&&!v.has("alpha"))return!1;const L=n(h[0].value,0,C);if(!L||L[0]!==e.Number)return!1;const H=n(N[0].value,1,C);if(!H||H[0]!==e.Number)return!1;const D=n(_[0].value,2,C);if(!D||D[0]!==e.Number)return!1;const Z=[L,H,D];if(1===f.length)if(C.syntaxFlags.add(g.HasAlpha),i(f[0])){const a=n(f[0].value,3,C);if(!a||a[0]!==e.Number)return!1;Z.push(a)}else C.alpha=f[0];else if(v&&v.has("alpha")){const a=n(v.get("alpha"),3,C);if(!a||a[0]!==e.Number)return!1;Z.push(a)}return C.channels=[Z[0][4].value,Z[1][4].value,Z[2][4].value],4===Z.length&&(C.alpha=Z[3][4].value),C}function hsl(a,n){if(a.value.some((a=>i(a)&&a.value[0]===e.Comma))){const e=hslCommaSeparated(a);if(!1!==e)return e}{const e=hslSpaceSeparated(a,n);if(!1!==e)return e}return!1}function hslCommaSeparated(e){return threeChannelLegacySyntax(e,normalize_legacy_HSL_ChannelValues,_.HSL,[g.LegacyHSL])}function hslSpaceSeparated(e,a){return threeChannelSpaceSeparated(e,normalize_modern_HSL_ChannelValues,_.HSL,[],a)}function normalize_HWB_ChannelValues(n,r,o){if(n[0]===e.Ident&&"none"===toLowerCaseAZ(n[4].value))return o.syntaxFlags.add(g.HasNoneKeywords),[e.Number,"none",n[2],n[3],{value:NaN,type:a.Number}];if(0===r){const a=normalizeHue(n);return!1!==a&&(n[0]===e.Dimension&&o.syntaxFlags.add(g.HasDimensionValues),a)}if(n[0]===e.Percentage){3===r?o.syntaxFlags.add(g.HasPercentageAlpha):o.syntaxFlags.add(g.HasPercentageValues);let t=n[4].value;return 3===r&&(t=normalize(n[4].value,100,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}if(n[0]===e.Number){3!==r&&o.syntaxFlags.add(g.HasNumberValues);let t=n[4].value;return 3===r&&(t=normalize(n[4].value,1,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}return!1}function normalize_Lab_ChannelValues(n,r,o){if(n[0]===e.Ident&&"none"===toLowerCaseAZ(n[4].value))return o.syntaxFlags.add(g.HasNoneKeywords),[e.Number,"none",n[2],n[3],{value:NaN,type:a.Number}];if(n[0]===e.Percentage){3!==r&&o.syntaxFlags.add(g.HasPercentageValues);let t=normalize(n[4].value,1,0,100);return 1===r||2===r?t=normalize(n[4].value,.8,-1/0,1/0):3===r&&(t=normalize(n[4].value,100,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}if(n[0]===e.Number){3!==r&&o.syntaxFlags.add(g.HasNumberValues);let t=normalize(n[4].value,1,0,100);return 1===r||2===r?t=normalize(n[4].value,1,-1/0,1/0):3===r&&(t=normalize(n[4].value,1,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}return!1}function lab(e,a){return threeChannelSpaceSeparated(e,normalize_Lab_ChannelValues,_.Lab,[],a)}function normalize_LCH_ChannelValues(n,r,o){if(n[0]===e.Ident&&"none"===toLowerCaseAZ(n[4].value))return o.syntaxFlags.add(g.HasNoneKeywords),[e.Number,"none",n[2],n[3],{value:NaN,type:a.Number}];if(2===r){const a=normalizeHue(n);return!1!==a&&(n[0]===e.Dimension&&o.syntaxFlags.add(g.HasDimensionValues),a)}if(n[0]===e.Percentage){3!==r&&o.syntaxFlags.add(g.HasPercentageValues);let t=normalize(n[4].value,1,0,100);return 1===r?t=normalize(n[4].value,100/150,0,1/0):3===r&&(t=normalize(n[4].value,100,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}if(n[0]===e.Number){3!==r&&o.syntaxFlags.add(g.HasNumberValues);let t=normalize(n[4].value,1,0,100);return 1===r?t=normalize(n[4].value,1,0,1/0):3===r&&(t=normalize(n[4].value,1,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}return!1}function lch(e,a){return threeChannelSpaceSeparated(e,normalize_LCH_ChannelValues,_.LCH,[],a)}const L=new Map;for(const[e,a]of Object.entries(r))L.set(e,a);function namedColor(e){const a=L.get(toLowerCaseAZ(e));return!!a&&{colorNotation:_.RGB,channels:[a[0]/255,a[1]/255,a[2]/255],alpha:1,syntaxFlags:new Set([g.ColorKeyword,g.NamedColor])}}function normalize_OKLab_ChannelValues(n,r,o){if(n[0]===e.Ident&&"none"===toLowerCaseAZ(n[4].value))return o.syntaxFlags.add(g.HasNoneKeywords),[e.Number,"none",n[2],n[3],{value:NaN,type:a.Number}];if(n[0]===e.Percentage){3!==r&&o.syntaxFlags.add(g.HasPercentageValues);let t=normalize(n[4].value,100,0,1);return 1===r||2===r?t=normalize(n[4].value,250,-1/0,1/0):3===r&&(t=normalize(n[4].value,100,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}if(n[0]===e.Number){3!==r&&o.syntaxFlags.add(g.HasNumberValues);let t=normalize(n[4].value,1,0,1);return 1===r||2===r?t=normalize(n[4].value,1,-1/0,1/0):3===r&&(t=normalize(n[4].value,1,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}return!1}function oklab(e,a){return threeChannelSpaceSeparated(e,normalize_OKLab_ChannelValues,_.OKLab,[],a)}function normalize_OKLCH_ChannelValues(n,r,o){if(n[0]===e.Ident&&"none"===toLowerCaseAZ(n[4].value))return o.syntaxFlags.add(g.HasNoneKeywords),[e.Number,"none",n[2],n[3],{value:NaN,type:a.Number}];if(2===r){const a=normalizeHue(n);return!1!==a&&(n[0]===e.Dimension&&o.syntaxFlags.add(g.HasDimensionValues),a)}if(n[0]===e.Percentage){3!==r&&o.syntaxFlags.add(g.HasPercentageValues);let t=normalize(n[4].value,100,0,1);return 1===r?t=normalize(n[4].value,250,0,1/0):3===r&&(t=normalize(n[4].value,100,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}if(n[0]===e.Number){3!==r&&o.syntaxFlags.add(g.HasNumberValues);let t=normalize(n[4].value,1,0,1);return 1===r?t=normalize(n[4].value,1,0,1/0):3===r&&(t=normalize(n[4].value,1,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}return!1}function oklch(e,a){return threeChannelSpaceSeparated(e,normalize_OKLCH_ChannelValues,_.OKLCH,[],a)}function normalize_legacy_sRGB_ChannelValues(n,r,o){if(n[0]===e.Percentage){3===r?o.syntaxFlags.add(g.HasPercentageAlpha):o.syntaxFlags.add(g.HasPercentageValues);const t=normalize(n[4].value,100,0,1);return[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}if(n[0]===e.Number){3!==r&&o.syntaxFlags.add(g.HasNumberValues);let t=normalize(n[4].value,255,0,1);return 3===r&&(t=normalize(n[4].value,1,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}return!1}function normalize_modern_sRGB_ChannelValues(n,r,o){if(n[0]===e.Ident&&"none"===toLowerCaseAZ(n[4].value))return o.syntaxFlags.add(g.HasNoneKeywords),[e.Number,"none",n[2],n[3],{value:NaN,type:a.Number}];if(n[0]===e.Percentage){3!==r&&o.syntaxFlags.add(g.HasPercentageValues);let t=normalize(n[4].value,100,-1/0,1/0);return 3===r&&(t=normalize(n[4].value,100,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}if(n[0]===e.Number){3!==r&&o.syntaxFlags.add(g.HasNumberValues);let t=normalize(n[4].value,255,-1/0,1/0);return 3===r&&(t=normalize(n[4].value,1,0,1)),[e.Number,t.toString(),n[2],n[3],{value:t,type:a.Number}]}return!1}function rgb(a,n){if(a.value.some((a=>i(a)&&a.value[0]===e.Comma))){const e=rgbCommaSeparated(a);if(!1!==e)return(!e.syntaxFlags.has(g.HasNumberValues)||!e.syntaxFlags.has(g.HasPercentageValues))&&e}else{const e=rgbSpaceSeparated(a,n);if(!1!==e)return e}return!1}function rgbCommaSeparated(e){return threeChannelLegacySyntax(e,normalize_legacy_sRGB_ChannelValues,_.RGB,[g.LegacyRGB])}function rgbSpaceSeparated(e,a){return threeChannelSpaceSeparated(e,normalize_modern_sRGB_ChannelValues,_.RGB,[],a)}function toPrecision(e,a=7){e=+e,a=+a;const n=(Math.floor(e)+"").length;if(a>n)return+e.toFixed(a-n);{const r=10**(n-a);return Math.round(e/r)*r}}function XYZ_D50_to_P3_Gamut(e){const a=n.XYZ_D50_to_P3(e);if(o.inGamut(a))return o.clip(a);let r=e.slice();return r=t.D50_to_D65(r),r=t.XYZ_to_OKLab(r),r=t.OKLab_to_OKLCH(r),r[0]<1e-6&&(r=[0,0,0]),r[0]>.999999&&(r=[1,0,0]),l.mapGamut(r,(e=>(e=t.OKLCH_to_OKLab(e),e=t.OKLab_to_XYZ(e),e=t.XYZ_to_lin_P3(e),t.gam_P3(e))),(e=>(e=t.lin_P3(e),e=t.lin_P3_to_XYZ(e),e=t.XYZ_to_OKLab(e),t.OKLab_to_OKLCH(e))))}function serializeWithAlpha(n,r,o,t){const l=[e.CloseParen,")",-1,-1,void 0];if("number"==typeof n.alpha){const s=Math.min(1,Math.max(0,toPrecision(Number.isNaN(n.alpha)?0:n.alpha)));return 1===toPrecision(s,4)?new h(r,l,t):new h(r,l,[...t,new N([o]),new m([e.Delim,"/",-1,-1,{value:"/"}]),new N([o]),new m([e.Number,toPrecision(s,4).toString(),-1,-1,{value:n.alpha,type:a.Integer}])])}return new h(r,l,[...t,new N([o]),new m([e.Delim,"/",-1,-1,{value:"/"}]),new N([o]),n.alpha])}function serializeP3(r,o=!0){r.channels=convertPowerlessComponentsToZeroValuesForDisplay(r.channels,r.colorNotation);let t=r.channels.map((e=>Number.isNaN(e)?0:e));r.colorNotation!==_.Display_P3&&(t=o?XYZ_D50_to_P3_Gamut(colorData_to_XYZ_D50(r).channels):n.XYZ_D50_to_P3(colorData_to_XYZ_D50(r).channels));const l=toPrecision(t[0],6),s=toPrecision(t[1],6),u=toPrecision(t[2],6),i=[e.Function,"color(",-1,-1,{value:"color"}],c=[e.Whitespace," ",-1,-1,void 0];return serializeWithAlpha(r,i,c,[new m([e.Ident,"display-p3",-1,-1,{value:"display-p3"}]),new N([c]),new m([e.Number,l.toString(),-1,-1,{value:t[0],type:a.Number}]),new N([c]),new m([e.Number,s.toString(),-1,-1,{value:t[1],type:a.Number}]),new N([c]),new m([e.Number,u.toString(),-1,-1,{value:t[2],type:a.Number}])])}function XYZ_D50_to_sRGB_Gamut(e){const a=n.XYZ_D50_to_sRGB(e);if(o.inGamut(a))return o.clip(a);let r=e.slice();return r=t.D50_to_D65(r),r=t.XYZ_to_OKLab(r),r=t.OKLab_to_OKLCH(r),r[0]<1e-6&&(r=[0,0,0]),r[0]>.999999&&(r=[1,0,0]),l.mapGamut(r,(e=>(e=t.OKLCH_to_OKLab(e),e=t.OKLab_to_XYZ(e),e=t.XYZ_to_lin_sRGB(e),t.gam_sRGB(e))),(e=>(e=t.lin_sRGB(e),e=t.lin_sRGB_to_XYZ(e),e=t.XYZ_to_OKLab(e),t.OKLab_to_OKLCH(e))))}function serializeRGB(r,o=!0){r.channels=convertPowerlessComponentsToZeroValuesForDisplay(r.channels,r.colorNotation);let t=r.channels.map((e=>Number.isNaN(e)?0:e));t=o?XYZ_D50_to_sRGB_Gamut(colorData_to_XYZ_D50(r).channels):n.XYZ_D50_to_sRGB(colorData_to_XYZ_D50(r).channels);const l=Math.min(255,Math.max(0,Math.round(255*toPrecision(t[0])))),s=Math.min(255,Math.max(0,Math.round(255*toPrecision(t[1])))),u=Math.min(255,Math.max(0,Math.round(255*toPrecision(t[2])))),i=[e.CloseParen,")",-1,-1,void 0],c=[e.Whitespace," ",-1,-1,void 0],p=[e.Comma,",",-1,-1,void 0],b=[new m([e.Number,l.toString(),-1,-1,{value:t[0],type:a.Integer}]),new m(p),new N([c]),new m([e.Number,s.toString(),-1,-1,{value:t[1],type:a.Integer}]),new m(p),new N([c]),new m([e.Number,u.toString(),-1,-1,{value:t[2],type:a.Integer}])];if("number"==typeof r.alpha){const n=Math.min(1,Math.max(0,toPrecision(Number.isNaN(r.alpha)?0:r.alpha)));return 1===toPrecision(n,4)?new h([e.Function,"rgb(",-1,-1,{value:"rgb"}],i,b):new h([e.Function,"rgba(",-1,-1,{value:"rgba"}],i,[...b,new m(p),new N([c]),new m([e.Number,toPrecision(n,4).toString(),-1,-1,{value:r.alpha,type:a.Number}])])}return new h([e.Function,"rgba(",-1,-1,{value:"rgba"}],i,[...b,new m(p),new N([c]),r.alpha])}function serializeOKLCH(r){r.channels=convertPowerlessComponentsToZeroValuesForDisplay(r.channels,r.colorNotation);let o=r.channels.map((e=>Number.isNaN(e)?0:e));r.colorNotation!==_.OKLCH&&(o=n.XYZ_D50_to_OKLCH(colorData_to_XYZ_D50(r).channels));const t=toPrecision(o[0],6),l=toPrecision(o[1],6),s=toPrecision(o[2],6),u=[e.Function,"oklch(",-1,-1,{value:"oklch"}],i=[e.Whitespace," ",-1,-1,void 0];return serializeWithAlpha(r,u,i,[new m([e.Number,t.toString(),-1,-1,{value:o[0],type:a.Number}]),new N([i]),new m([e.Number,l.toString(),-1,-1,{value:o[1],type:a.Number}]),new N([i]),new m([e.Number,s.toString(),-1,-1,{value:o[2],type:a.Number}])])}function color(a){if(c(a)){switch(toLowerCaseAZ(a.getName())){case"rgb":case"rgba":return rgb(a,color);case"hsl":case"hsla":return hsl(a,color);case"hwb":return n=color,threeChannelSpaceSeparated(a,normalize_HWB_ChannelValues,_.HWB,[],n);case"lab":return lab(a,color);case"lch":return lch(a,color);case"oklab":return oklab(a,color);case"oklch":return oklch(a,color);case"color":return color$1(a,color);case"color-mix":return colorMix(a,color)}}var n;if(i(a)){if(a.value[0]===e.Hash)return hex(a.value);if(a.value[0]===e.Ident){const e=namedColor(a.value[4].value);return!1!==e?e:"transparent"===toLowerCaseAZ(a.value[4].value)&&{colorNotation:_.RGB,channels:[0,0,0],alpha:0,syntaxFlags:new Set([g.ColorKeyword])}}}return!1}export{_ as ColorNotation,g as SyntaxFlag,color,colorDataFitsDisplayP3_Gamut,colorDataFitsRGB_Gamut,colorDataTo,serializeOKLCH,serializeP3,serializeRGB}; diff --git a/node_modules/@csstools/css-color-parser/dist/serialize/oklch.d.ts b/node_modules/@csstools/css-color-parser/dist/serialize/oklch.d.ts new file mode 100644 index 00000000..1963c49e --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/serialize/oklch.d.ts @@ -0,0 +1,3 @@ +import { ColorData } from '../color-data'; +import { FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function serializeOKLCH(color: ColorData): FunctionNode; diff --git a/node_modules/@csstools/css-color-parser/dist/serialize/p3.d.ts b/node_modules/@csstools/css-color-parser/dist/serialize/p3.d.ts new file mode 100644 index 00000000..503c5a25 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/serialize/p3.d.ts @@ -0,0 +1,3 @@ +import { ColorData } from '../color-data'; +import { FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function serializeP3(color: ColorData, gamutMapping?: boolean): FunctionNode; diff --git a/node_modules/@csstools/css-color-parser/dist/serialize/rgb.d.ts b/node_modules/@csstools/css-color-parser/dist/serialize/rgb.d.ts new file mode 100644 index 00000000..b4c38133 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/serialize/rgb.d.ts @@ -0,0 +1,3 @@ +import { ColorData } from '../color-data'; +import { FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function serializeRGB(color: ColorData, gamutMapping?: boolean): FunctionNode; diff --git a/node_modules/@csstools/css-color-parser/dist/serialize/to-precision.d.ts b/node_modules/@csstools/css-color-parser/dist/serialize/to-precision.d.ts new file mode 100644 index 00000000..1bcc6b27 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/serialize/to-precision.d.ts @@ -0,0 +1 @@ +export declare function toPrecision(n: number, precision?: number): number; diff --git a/node_modules/@csstools/css-color-parser/dist/serialize/with-alpha.d.ts b/node_modules/@csstools/css-color-parser/dist/serialize/with-alpha.d.ts new file mode 100644 index 00000000..c214a9cc --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/serialize/with-alpha.d.ts @@ -0,0 +1,4 @@ +import { ColorData } from '../color-data'; +import type { TokenFunction, TokenWhitespace } from '@csstools/css-tokenizer'; +import { FunctionNode, TokenNode, WhitespaceNode } from '@csstools/css-parser-algorithms'; +export declare function serializeWithAlpha(color: ColorData, fn: TokenFunction, space: TokenWhitespace, channels: Array<TokenNode | WhitespaceNode>): FunctionNode; diff --git a/node_modules/@csstools/css-color-parser/dist/util/to-lower-case-a-z.d.ts b/node_modules/@csstools/css-color-parser/dist/util/to-lower-case-a-z.d.ts new file mode 100644 index 00000000..396b252e --- /dev/null +++ b/node_modules/@csstools/css-color-parser/dist/util/to-lower-case-a-z.d.ts @@ -0,0 +1 @@ +export declare function toLowerCaseAZ(x: string): string; diff --git a/node_modules/@csstools/css-color-parser/package.json b/node_modules/@csstools/css-color-parser/package.json new file mode 100644 index 00000000..6ef632c9 --- /dev/null +++ b/node_modules/@csstools/css-color-parser/package.json @@ -0,0 +1,77 @@ +{ + "name": "@csstools/css-color-parser", + "description": "Parse CSS color values", + "version": "1.4.0", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/color-helpers": "^3.0.2", + "@csstools/css-calc": "^1.1.4" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1" + }, + "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", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "packages/css-color-parser" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "color", + "css", + "parser" + ], + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/css-parser-algorithms/CHANGELOG.md b/node_modules/@csstools/css-parser-algorithms/CHANGELOG.md new file mode 100644 index 00000000..8d6ae2ff --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/CHANGELOG.md @@ -0,0 +1,65 @@ +# Changes to CSS Parser Algorithms + +### 2.3.2 + +_September 24, 2023_ + +- 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) + +### 2.3.1 + +_July 24, 2023_ + +- 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) + +### 2.3.0 + +_July 3, 2023_ + +- Add `sourceIndices` helper function. + +This makes it easier to get the start and end indices of a node in the source string. +This function accepts any node that can be converted into an array of tokens. + +### 2.2.0 + +_June 1, 2023_ + +- Add `state` to `walk` methods. + +This makes it possible pass down information from a parent structure to children. +e.g. you can set `entry.state.isInCalcExpression = true` for `calc((10 + 5) / 2)` when walking the `FunctionNode` for `calc`. + +### 2.1.1 + +_April 10, 2023_ + +- Updated `@csstools/css-tokenizer` to `2.1.1` (patch) + +### 2.1.0 + +_March 25, 2023_ + +- Add `replaceComponentValues` utility function. +- Add `stringify` utility function. + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 19, 2023_ + +- Fix: Removes `UnclosedFunctionNode` and `UnclosedSimpleBlockNode`. (breaking) +- Change the `ParseError` interface, this is now a subclass of `Error` (breaking) +- Change `nameTokenValue` in `FunctionNode` to `getName` (breaking) +- Fix: Do not discard empty items in comma separated lists. + +### 1.0.0 + +_November 14, 2022_ + +- Initial version diff --git a/node_modules/@csstools/css-parser-algorithms/LICENSE.md b/node_modules/@csstools/css-parser-algorithms/LICENSE.md new file mode 100644 index 00000000..af5411fa --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/LICENSE.md @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright 2022 Romain Menke, Antonio Laguna <antonio@laguna.es> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/@csstools/css-parser-algorithms/README.md b/node_modules/@csstools/css-parser-algorithms/README.md new file mode 100644 index 00000000..b63c2ce3 --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/README.md @@ -0,0 +1,115 @@ +# CSS Parser Algorithms + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/css-parser-algorithms.svg" height="20">][npm-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +Implemented from : https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/ + +## Usage + +Add [CSS Parser Algorithms] to your project: + +```bash +npm install @csstools/css-parser-algorithms @csstools/css-tokenizer --save-dev +``` + +[CSS Parser Algorithms] only accepts tokenized CSS. +It must be used together with `@csstools/css-tokenizer`. + + +```js +import { tokenizer, TokenType } from '@csstools/css-tokenizer'; +import { parseComponentValue } from '@csstools/css-parser-algorithms'; + +const myCSS = `@media only screen and (min-width: 768rem) { + .foo { + content: 'Some content!' !important; + } +} +`; + +const t = tokenizer({ + css: myCSS, +}); + +const tokens = []; + +{ + while (!t.endOfFile()) { + tokens.push(t.nextToken()); + } + + tokens.push(t.nextToken()); // EOF-token +} + +const options = { + onParseError: ((err) => { + throw err; + }), +}; + +const result = parseComponentValue(tokens, options); + +console.log(result); +``` + +### Available functions + +- [`parseComponentValue`](https://www.w3.org/TR/css-syntax-3/#parse-component-value) +- [`parseListOfComponentValues`](https://www.w3.org/TR/css-syntax-3/#parse-list-of-component-values) +- [`parseCommaSeparatedListOfComponentValues`](https://www.w3.org/TR/css-syntax-3/#parse-comma-separated-list-of-component-values) + +### Utilities + +#### `gatherNodeAncestry` + +The AST does not expose the entire ancestry of each node. +The walker methods do provide access to the current parent, but also not the entire ancestry. + +To gather the entire ancestry for a a given sub tree of the AST you can use `gatherNodeAncestry`. +The result is a `Map` with the child nodes as keys and the parents as values. +This allows you to lookup any ancestor of any node. + +```css +import { parseComponentValue } from '@csstools/css-parser-algorithms'; + +const result = parseComponentValue(tokens, options); +const ancestry = gatherNodeAncestry(result); +``` + +### Options + +```ts +{ + onParseError?: (error: ParseError) => void +} +``` + +#### `onParseError` + +The parser algorithms are forgiving and won't stop when a parse error is encountered. +Parse errors also aren't tokens. + +To receive parsing error information you can set a callback. + +Parser errors will try to inform you about the point in the parsing logic the error happened. +This tells you the kind of error. + +## Goals and non-goals + +Things this package aims to be: +- specification compliant CSS parser +- a reliable low level package to be used in CSS sub-grammars + +What it is not: +- opinionated +- fast +- small +- a replacement for PostCSS (PostCSS is fast and also an ecosystem) + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/css-parser-algorithms + +[CSS Parser Algorithms]: https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms diff --git a/node_modules/@csstools/css-parser-algorithms/dist/consume/consume-component-block-function.d.ts b/node_modules/@csstools/css-parser-algorithms/dist/consume/consume-component-block-function.d.ts new file mode 100644 index 00000000..59cdf944 --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/consume/consume-component-block-function.d.ts @@ -0,0 +1,118 @@ +import { CSSToken, TokenFunction } from '@csstools/css-tokenizer'; +import { Context } from '../interfaces/context'; +import { ComponentValueType } from '../util/component-value-type'; +export type ContainerNode = FunctionNode | SimpleBlockNode; +export type ComponentValue = FunctionNode | SimpleBlockNode | WhitespaceNode | CommentNode | TokenNode; +export declare function consumeComponentValue(ctx: Context, tokens: Array<CSSToken>): { + advance: number; + node: ComponentValue; +}; +export declare class FunctionNode { + type: ComponentValueType; + name: TokenFunction; + endToken: CSSToken; + value: Array<ComponentValue>; + constructor(name: TokenFunction, endToken: CSSToken, value: Array<ComponentValue>); + getName(): string; + /** + * Normalize the current Function: + * - if the "endToken" is EOF, replace with a ")-token" + */ + normalize(): void; + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: ComponentValue): number | string; + at(index: number | string): ComponentValue | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: ComponentValue; + parent: ContainerNode; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): unknown; + isFunctionNode(): this is FunctionNode; + static isFunctionNode(x: unknown): x is FunctionNode; +} +export declare function consumeFunction(ctx: Context, tokens: Array<CSSToken>): { + advance: number; + node: FunctionNode; +}; +export declare class SimpleBlockNode { + type: ComponentValueType; + startToken: CSSToken; + endToken: CSSToken; + value: Array<ComponentValue>; + constructor(startToken: CSSToken, endToken: CSSToken, value: Array<ComponentValue>); + /** + * Normalize the current Simple Block: + * - if the "endToken" is EOF, replace with the mirror token of the "startToken" + */ + normalize(): void; + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: ComponentValue): number | string; + at(index: number | string): ComponentValue | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: ComponentValue; + parent: ContainerNode; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): unknown; + isSimpleBlockNode(): this is SimpleBlockNode; + static isSimpleBlockNode(x: unknown): x is SimpleBlockNode; +} +/** https://www.w3.org/TR/css-syntax-3/#consume-simple-block */ +export declare function consumeSimpleBlock(ctx: Context, tokens: Array<CSSToken>): { + advance: number; + node: SimpleBlockNode; +}; +export declare class WhitespaceNode { + type: ComponentValueType; + value: Array<CSSToken>; + constructor(value: Array<CSSToken>); + tokens(): Array<CSSToken>; + toString(): string; + toJSON(): { + type: ComponentValueType; + tokens: CSSToken[]; + }; + isWhitespaceNode(): this is WhitespaceNode; + static isWhitespaceNode(x: unknown): x is WhitespaceNode; +} +export declare function consumeWhitespace(ctx: Context, tokens: Array<CSSToken>): { + advance: number; + node: WhitespaceNode; +}; +export declare class CommentNode { + type: ComponentValueType; + value: CSSToken; + constructor(value: CSSToken); + tokens(): Array<CSSToken>; + toString(): string; + toJSON(): { + type: ComponentValueType; + tokens: CSSToken[]; + }; + isCommentNode(): this is CommentNode; + static isCommentNode(x: unknown): x is CommentNode; +} +export declare function consumeComment(ctx: Context, tokens: Array<CSSToken>): { + advance: number; + node: CommentNode; +}; +export declare function consumeAllCommentsAndWhitespace(ctx: Context, tokens: Array<CSSToken>): { + advance: number; + nodes: Array<WhitespaceNode | CommentNode>; +}; +export declare class TokenNode { + type: ComponentValueType; + value: CSSToken; + constructor(value: CSSToken); + tokens(): Array<CSSToken>; + toString(): string; + toJSON(): { + type: ComponentValueType; + tokens: CSSToken[]; + }; + isTokenNode(): this is TokenNode; + static isTokenNode(x: unknown): x is TokenNode; +} diff --git a/node_modules/@csstools/css-parser-algorithms/dist/index.cjs b/node_modules/@csstools/css-parser-algorithms/dist/index.cjs new file mode 100644 index 00000000..4405dce4 --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e,n=require("@csstools/css-tokenizer");function consumeComponentValue(e,o){const t=o[0];if(t[0]===n.TokenType.OpenParen||t[0]===n.TokenType.OpenCurly||t[0]===n.TokenType.OpenSquare){const n=consumeSimpleBlock(e,o);return{advance:n.advance,node:n.node}}if(t[0]===n.TokenType.Function){const n=consumeFunction(e,o);return{advance:n.advance,node:n.node}}if(t[0]===n.TokenType.Whitespace){const n=consumeWhitespace(e,o);return{advance:n.advance,node:n.node}}if(t[0]===n.TokenType.Comment){const n=consumeComment(e,o);return{advance:n.advance,node:n.node}}return{advance:1,node:new TokenNode(t)}}exports.ComponentValueType=void 0,(e=exports.ComponentValueType||(exports.ComponentValueType={})).Function="function",e.SimpleBlock="simple-block",e.Whitespace="whitespace",e.Comment="comment",e.Token="token";class FunctionNode{type=exports.ComponentValueType.Function;name;endToken;value;constructor(e,n,o){this.name=e,this.endToken=n,this.value=o}getName(){return this.name[4].value}normalize(){this.endToken[0]===n.TokenType.EOF&&(this.endToken=[n.TokenType.CloseParen,")",-1,-1,void 0])}tokens(){return this.endToken[0]===n.TokenType.EOF?[this.name,...this.value.flatMap((e=>e.tokens()))]:[this.name,...this.value.flatMap((e=>e.tokens())),this.endToken]}toString(){const e=this.value.map((e=>n.isToken(e)?n.stringify(e):e.toString())).join("");return n.stringify(this.name)+e+n.stringify(this.endToken)}indexOf(e){return this.value.indexOf(e)}at(e){if("number"==typeof e)return e<0&&(e=this.value.length+e),this.value[e]}walk(e,n){let o=!1;if(this.value.forEach(((t,s)=>{if(o)return;let i;n&&(i={...n}),!1!==e({node:t,parent:this,state:i},s)?"walk"in t&&!1===t.walk(e,i)&&(o=!0):o=!0})),o)return!1}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens(),value:this.value.map((e=>e.toJSON()))}}isFunctionNode(){return FunctionNode.isFunctionNode(this)}static isFunctionNode(e){return!!e&&(e instanceof FunctionNode&&e.type===exports.ComponentValueType.Function)}}function consumeFunction(e,o){const t=[];let s=1;for(;;){const i=o[s];if(!i||i[0]===n.TokenType.EOF)return e.onParseError(new n.ParseError("Unexpected EOF while consuming a function.",o[0][2],o[o.length-1][3],["5.4.9. Consume a function","Unexpected EOF"])),{advance:o.length,node:new FunctionNode(o[0],i,t)};if(i[0]===n.TokenType.CloseParen)return{advance:s+1,node:new FunctionNode(o[0],i,t)};if(i[0]===n.TokenType.Comment||i[0]===n.TokenType.Whitespace){const n=consumeAllCommentsAndWhitespace(e,o.slice(s));s+=n.advance,t.push(...n.nodes);continue}const r=consumeComponentValue(e,o.slice(s));s+=r.advance,t.push(r.node)}}class SimpleBlockNode{type=exports.ComponentValueType.SimpleBlock;startToken;endToken;value;constructor(e,n,o){this.startToken=e,this.endToken=n,this.value=o}normalize(){if(this.endToken[0]===n.TokenType.EOF){const e=n.mirrorVariant(this.startToken);e&&(this.endToken=e)}}tokens(){return this.endToken[0]===n.TokenType.EOF?[this.startToken,...this.value.flatMap((e=>e.tokens()))]:[this.startToken,...this.value.flatMap((e=>e.tokens())),this.endToken]}toString(){const e=this.value.map((e=>n.isToken(e)?n.stringify(e):e.toString())).join("");return n.stringify(this.startToken)+e+n.stringify(this.endToken)}indexOf(e){return this.value.indexOf(e)}at(e){if("number"==typeof e)return e<0&&(e=this.value.length+e),this.value[e]}walk(e,n){let o=!1;if(this.value.forEach(((t,s)=>{if(o)return;let i;n&&(i={...n}),!1!==e({node:t,parent:this,state:i},s)?"walk"in t&&!1===t.walk(e,i)&&(o=!0):o=!0})),o)return!1}toJSON(){return{type:this.type,startToken:this.startToken,tokens:this.tokens(),value:this.value.map((e=>e.toJSON()))}}isSimpleBlockNode(){return SimpleBlockNode.isSimpleBlockNode(this)}static isSimpleBlockNode(e){return!!e&&(e instanceof SimpleBlockNode&&e.type===exports.ComponentValueType.SimpleBlock)}}function consumeSimpleBlock(e,o){const t=n.mirrorVariantType(o[0][0]);if(!t)throw new Error("Failed to parse, a mirror variant must exist for all block open tokens.");const s=[];let i=1;for(;;){const r=o[i];if(!r||r[0]===n.TokenType.EOF)return e.onParseError(new n.ParseError("Unexpected EOF while consuming a simple block.",o[0][2],o[o.length-1][3],["5.4.8. Consume a simple block","Unexpected EOF"])),{advance:o.length,node:new SimpleBlockNode(o[0],r,s)};if(r[0]===t)return{advance:i+1,node:new SimpleBlockNode(o[0],r,s)};if(r[0]===n.TokenType.Comment||r[0]===n.TokenType.Whitespace){const n=consumeAllCommentsAndWhitespace(e,o.slice(i));i+=n.advance,s.push(...n.nodes);continue}const a=consumeComponentValue(e,o.slice(i));i+=a.advance,s.push(a.node)}}class WhitespaceNode{type=exports.ComponentValueType.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return n.stringify(...this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isWhitespaceNode(){return WhitespaceNode.isWhitespaceNode(this)}static isWhitespaceNode(e){return!!e&&(e instanceof WhitespaceNode&&e.type===exports.ComponentValueType.Whitespace)}}function consumeWhitespace(e,o){let t=0;for(;;){if(o[t][0]!==n.TokenType.Whitespace)return{advance:t,node:new WhitespaceNode(o.slice(0,t))};t++}}class CommentNode{type=exports.ComponentValueType.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return n.stringify(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isCommentNode(){return CommentNode.isCommentNode(this)}static isCommentNode(e){return!!e&&(e instanceof CommentNode&&e.type===exports.ComponentValueType.Comment)}}function consumeComment(e,n){return{advance:1,node:new CommentNode(n[0])}}function consumeAllCommentsAndWhitespace(e,o){const t=[];let s=0;for(;;)if(o[s][0]!==n.TokenType.Whitespace){if(o[s][0]!==n.TokenType.Comment)return{advance:s,nodes:t};t.push(new CommentNode(o[s])),s++}else{const e=consumeWhitespace(0,o.slice(s));s+=e.advance,t.push(e.node)}}class TokenNode{type=exports.ComponentValueType.Token;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return n.stringify(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isTokenNode(){return TokenNode.isTokenNode(this)}static isTokenNode(e){return!!e&&(e instanceof TokenNode&&e.type===exports.ComponentValueType.Token)}}function isSimpleBlockNode(e){return SimpleBlockNode.isSimpleBlockNode(e)}function isFunctionNode(e){return FunctionNode.isFunctionNode(e)}exports.CommentNode=CommentNode,exports.FunctionNode=FunctionNode,exports.SimpleBlockNode=SimpleBlockNode,exports.TokenNode=TokenNode,exports.WhitespaceNode=WhitespaceNode,exports.consumeAllCommentsAndWhitespace=consumeAllCommentsAndWhitespace,exports.consumeComment=consumeComment,exports.consumeComponentValue=consumeComponentValue,exports.consumeFunction=consumeFunction,exports.consumeSimpleBlock=consumeSimpleBlock,exports.consumeWhitespace=consumeWhitespace,exports.gatherNodeAncestry=function gatherNodeAncestry(e){const n=new Map;return e.walk((e=>{Array.isArray(e.node)?e.node.forEach((o=>{n.set(o,e.parent)})):n.set(e.node,e.parent)})),n},exports.isCommentNode=function isCommentNode(e){return CommentNode.isCommentNode(e)},exports.isFunctionNode=isFunctionNode,exports.isSimpleBlockNode=isSimpleBlockNode,exports.isTokenNode=function isTokenNode(e){return TokenNode.isTokenNode(e)},exports.isWhitespaceNode=function isWhitespaceNode(e){return WhitespaceNode.isWhitespaceNode(e)},exports.parseCommaSeparatedListOfComponentValues=function parseCommaSeparatedListOfComponentValues(e,o){const t={onParseError:(null==o?void 0:o.onParseError)??(()=>{})},s=[...e];if(0===e.length)return[];s[s.length-1][0]!==n.TokenType.EOF&&s.push([n.TokenType.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=[];let r=[],a=0;for(;;){if(!s[a]||s[a][0]===n.TokenType.EOF)return r.length&&i.push(r),i;if(s[a][0]===n.TokenType.Comma){i.push(r),r=[],a++;continue}const o=consumeComponentValue(t,e.slice(a));r.push(o.node),a+=o.advance}},exports.parseComponentValue=function parseComponentValue(e,o){const t={onParseError:(null==o?void 0:o.onParseError)??(()=>{})},s=[...e];s[s.length-1][0]!==n.TokenType.EOF&&s.push([n.TokenType.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=consumeComponentValue(t,s);if(s[Math.min(i.advance,s.length-1)][0]===n.TokenType.EOF)return i.node;t.onParseError(new n.ParseError("Expected EOF after parsing a component value.",e[0][2],e[e.length-1][3],["5.3.9. Parse a component value","Expected EOF"]))},exports.parseListOfComponentValues=function parseListOfComponentValues(e,o){const t={onParseError:(null==o?void 0:o.onParseError)??(()=>{})},s=[...e];s[s.length-1][0]!==n.TokenType.EOF&&s.push([n.TokenType.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=[];let r=0;for(;;){if(!s[r]||s[r][0]===n.TokenType.EOF)return i;const e=consumeComponentValue(t,s.slice(r));i.push(e.node),r+=e.advance}},exports.replaceComponentValues=function replaceComponentValues(e,n){for(let o=0;o<e.length;o++){const t=e[o];for(let e=0;e<t.length;e++){const o=t[e];{const s=n(o);if(s){t.splice(e,1,s);continue}}(isSimpleBlockNode(o)||isFunctionNode(o))&&o.walk(((e,o)=>{if("number"!=typeof o)return;const t=e.node,s=n(t);s&&e.parent.value.splice(o,1,s)}))}}return e},exports.sourceIndices=function sourceIndices(e){if(Array.isArray(e)){const n=e[0];if(!n)return[0,0];const o=e[e.length-1]||n;return[sourceIndices(n)[0],sourceIndices(o)[1]]}const n=e.tokens(),o=n[0],t=n[n.length-1];return o&&t?[o[2],t[3]]:[0,0]},exports.stringify=function stringify(e){return e.map((e=>e.map((e=>n.stringify(...e.tokens()))).join(""))).join(",")}; diff --git a/node_modules/@csstools/css-parser-algorithms/dist/index.d.ts b/node_modules/@csstools/css-parser-algorithms/dist/index.d.ts new file mode 100644 index 00000000..47c3cec9 --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/index.d.ts @@ -0,0 +1,10 @@ +export * from './consume/consume-component-block-function'; +export { parseComponentValue } from './parse/parse-component-value'; +export { parseListOfComponentValues } from './parse/parse-list-of-component-values'; +export { parseCommaSeparatedListOfComponentValues } from './parse/parse-comma-separated-list-of-component-values'; +export { gatherNodeAncestry } from './util/node-ancestry'; +export { replaceComponentValues } from './util/replace-component-values'; +export { stringify } from './util/stringify'; +export { ComponentValueType } from './util/component-value-type'; +export { isCommentNode, isFunctionNode, isSimpleBlockNode, isTokenNode, isWhitespaceNode, } from './util/type-predicates'; +export { sourceIndices } from './util/source-indices'; diff --git a/node_modules/@csstools/css-parser-algorithms/dist/index.mjs b/node_modules/@csstools/css-parser-algorithms/dist/index.mjs new file mode 100644 index 00000000..cc63349e --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/index.mjs @@ -0,0 +1 @@ +import{TokenType as e,isToken as n,stringify as t,ParseError as o,mirrorVariant as s,mirrorVariantType as i}from"@csstools/css-tokenizer";var r;function consumeComponentValue(n,t){const o=t[0];if(o[0]===e.OpenParen||o[0]===e.OpenCurly||o[0]===e.OpenSquare){const e=consumeSimpleBlock(n,t);return{advance:e.advance,node:e.node}}if(o[0]===e.Function){const e=consumeFunction(n,t);return{advance:e.advance,node:e.node}}if(o[0]===e.Whitespace){const e=consumeWhitespace(n,t);return{advance:e.advance,node:e.node}}if(o[0]===e.Comment){const e=consumeComment(n,t);return{advance:e.advance,node:e.node}}return{advance:1,node:new TokenNode(o)}}!function(e){e.Function="function",e.SimpleBlock="simple-block",e.Whitespace="whitespace",e.Comment="comment",e.Token="token"}(r||(r={}));class FunctionNode{type=r.Function;name;endToken;value;constructor(e,n,t){this.name=e,this.endToken=n,this.value=t}getName(){return this.name[4].value}normalize(){this.endToken[0]===e.EOF&&(this.endToken=[e.CloseParen,")",-1,-1,void 0])}tokens(){return this.endToken[0]===e.EOF?[this.name,...this.value.flatMap((e=>e.tokens()))]:[this.name,...this.value.flatMap((e=>e.tokens())),this.endToken]}toString(){const e=this.value.map((e=>n(e)?t(e):e.toString())).join("");return t(this.name)+e+t(this.endToken)}indexOf(e){return this.value.indexOf(e)}at(e){if("number"==typeof e)return e<0&&(e=this.value.length+e),this.value[e]}walk(e,n){let t=!1;if(this.value.forEach(((o,s)=>{if(t)return;let i;n&&(i={...n}),!1!==e({node:o,parent:this,state:i},s)?"walk"in o&&!1===o.walk(e,i)&&(t=!0):t=!0})),t)return!1}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens(),value:this.value.map((e=>e.toJSON()))}}isFunctionNode(){return FunctionNode.isFunctionNode(this)}static isFunctionNode(e){return!!e&&(e instanceof FunctionNode&&e.type===r.Function)}}function consumeFunction(n,t){const s=[];let i=1;for(;;){const r=t[i];if(!r||r[0]===e.EOF)return n.onParseError(new o("Unexpected EOF while consuming a function.",t[0][2],t[t.length-1][3],["5.4.9. Consume a function","Unexpected EOF"])),{advance:t.length,node:new FunctionNode(t[0],r,s)};if(r[0]===e.CloseParen)return{advance:i+1,node:new FunctionNode(t[0],r,s)};if(r[0]===e.Comment||r[0]===e.Whitespace){const e=consumeAllCommentsAndWhitespace(n,t.slice(i));i+=e.advance,s.push(...e.nodes);continue}const a=consumeComponentValue(n,t.slice(i));i+=a.advance,s.push(a.node)}}class SimpleBlockNode{type=r.SimpleBlock;startToken;endToken;value;constructor(e,n,t){this.startToken=e,this.endToken=n,this.value=t}normalize(){if(this.endToken[0]===e.EOF){const e=s(this.startToken);e&&(this.endToken=e)}}tokens(){return this.endToken[0]===e.EOF?[this.startToken,...this.value.flatMap((e=>e.tokens()))]:[this.startToken,...this.value.flatMap((e=>e.tokens())),this.endToken]}toString(){const e=this.value.map((e=>n(e)?t(e):e.toString())).join("");return t(this.startToken)+e+t(this.endToken)}indexOf(e){return this.value.indexOf(e)}at(e){if("number"==typeof e)return e<0&&(e=this.value.length+e),this.value[e]}walk(e,n){let t=!1;if(this.value.forEach(((o,s)=>{if(t)return;let i;n&&(i={...n}),!1!==e({node:o,parent:this,state:i},s)?"walk"in o&&!1===o.walk(e,i)&&(t=!0):t=!0})),t)return!1}toJSON(){return{type:this.type,startToken:this.startToken,tokens:this.tokens(),value:this.value.map((e=>e.toJSON()))}}isSimpleBlockNode(){return SimpleBlockNode.isSimpleBlockNode(this)}static isSimpleBlockNode(e){return!!e&&(e instanceof SimpleBlockNode&&e.type===r.SimpleBlock)}}function consumeSimpleBlock(n,t){const s=i(t[0][0]);if(!s)throw new Error("Failed to parse, a mirror variant must exist for all block open tokens.");const r=[];let a=1;for(;;){const i=t[a];if(!i||i[0]===e.EOF)return n.onParseError(new o("Unexpected EOF while consuming a simple block.",t[0][2],t[t.length-1][3],["5.4.8. Consume a simple block","Unexpected EOF"])),{advance:t.length,node:new SimpleBlockNode(t[0],i,r)};if(i[0]===s)return{advance:a+1,node:new SimpleBlockNode(t[0],i,r)};if(i[0]===e.Comment||i[0]===e.Whitespace){const e=consumeAllCommentsAndWhitespace(n,t.slice(a));a+=e.advance,r.push(...e.nodes);continue}const c=consumeComponentValue(n,t.slice(a));a+=c.advance,r.push(c.node)}}class WhitespaceNode{type=r.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return t(...this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isWhitespaceNode(){return WhitespaceNode.isWhitespaceNode(this)}static isWhitespaceNode(e){return!!e&&(e instanceof WhitespaceNode&&e.type===r.Whitespace)}}function consumeWhitespace(n,t){let o=0;for(;;){if(t[o][0]!==e.Whitespace)return{advance:o,node:new WhitespaceNode(t.slice(0,o))};o++}}class CommentNode{type=r.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return t(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isCommentNode(){return CommentNode.isCommentNode(this)}static isCommentNode(e){return!!e&&(e instanceof CommentNode&&e.type===r.Comment)}}function consumeComment(e,n){return{advance:1,node:new CommentNode(n[0])}}function consumeAllCommentsAndWhitespace(n,t){const o=[];let s=0;for(;;)if(t[s][0]!==e.Whitespace){if(t[s][0]!==e.Comment)return{advance:s,nodes:o};o.push(new CommentNode(t[s])),s++}else{const e=consumeWhitespace(0,t.slice(s));s+=e.advance,o.push(e.node)}}class TokenNode{type=r.Token;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return t(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isTokenNode(){return TokenNode.isTokenNode(this)}static isTokenNode(e){return!!e&&(e instanceof TokenNode&&e.type===r.Token)}}function parseComponentValue(n,t){const s={onParseError:(null==t?void 0:t.onParseError)??(()=>{})},i=[...n];i[i.length-1][0]!==e.EOF&&i.push([e.EOF,"",i[i.length-1][2],i[i.length-1][3],void 0]);const r=consumeComponentValue(s,i);if(i[Math.min(r.advance,i.length-1)][0]===e.EOF)return r.node;s.onParseError(new o("Expected EOF after parsing a component value.",n[0][2],n[n.length-1][3],["5.3.9. Parse a component value","Expected EOF"]))}function parseListOfComponentValues(n,t){const o={onParseError:(null==t?void 0:t.onParseError)??(()=>{})},s=[...n];s[s.length-1][0]!==e.EOF&&s.push([e.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=[];let r=0;for(;;){if(!s[r]||s[r][0]===e.EOF)return i;const n=consumeComponentValue(o,s.slice(r));i.push(n.node),r+=n.advance}}function parseCommaSeparatedListOfComponentValues(n,t){const o={onParseError:(null==t?void 0:t.onParseError)??(()=>{})},s=[...n];if(0===n.length)return[];s[s.length-1][0]!==e.EOF&&s.push([e.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=[];let r=[],a=0;for(;;){if(!s[a]||s[a][0]===e.EOF)return r.length&&i.push(r),i;if(s[a][0]===e.Comma){i.push(r),r=[],a++;continue}const t=consumeComponentValue(o,n.slice(a));r.push(t.node),a+=t.advance}}function gatherNodeAncestry(e){const n=new Map;return e.walk((e=>{Array.isArray(e.node)?e.node.forEach((t=>{n.set(t,e.parent)})):n.set(e.node,e.parent)})),n}function isSimpleBlockNode(e){return SimpleBlockNode.isSimpleBlockNode(e)}function isFunctionNode(e){return FunctionNode.isFunctionNode(e)}function isWhitespaceNode(e){return WhitespaceNode.isWhitespaceNode(e)}function isCommentNode(e){return CommentNode.isCommentNode(e)}function isTokenNode(e){return TokenNode.isTokenNode(e)}function replaceComponentValues(e,n){for(let t=0;t<e.length;t++){const o=e[t];for(let e=0;e<o.length;e++){const t=o[e];{const s=n(t);if(s){o.splice(e,1,s);continue}}(isSimpleBlockNode(t)||isFunctionNode(t))&&t.walk(((e,t)=>{if("number"!=typeof t)return;const o=e.node,s=n(o);s&&e.parent.value.splice(t,1,s)}))}}return e}function stringify(e){return e.map((e=>e.map((e=>t(...e.tokens()))).join(""))).join(",")}function sourceIndices(e){if(Array.isArray(e)){const n=e[0];if(!n)return[0,0];const t=e[e.length-1]||n;return[sourceIndices(n)[0],sourceIndices(t)[1]]}const n=e.tokens(),t=n[0],o=n[n.length-1];return t&&o?[t[2],o[3]]:[0,0]}export{CommentNode,r as ComponentValueType,FunctionNode,SimpleBlockNode,TokenNode,WhitespaceNode,consumeAllCommentsAndWhitespace,consumeComment,consumeComponentValue,consumeFunction,consumeSimpleBlock,consumeWhitespace,gatherNodeAncestry,isCommentNode,isFunctionNode,isSimpleBlockNode,isTokenNode,isWhitespaceNode,parseCommaSeparatedListOfComponentValues,parseComponentValue,parseListOfComponentValues,replaceComponentValues,sourceIndices,stringify}; diff --git a/node_modules/@csstools/css-parser-algorithms/dist/interfaces/context.d.ts b/node_modules/@csstools/css-parser-algorithms/dist/interfaces/context.d.ts new file mode 100644 index 00000000..dc246e00 --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/interfaces/context.d.ts @@ -0,0 +1,4 @@ +import { ParseError } from '@csstools/css-tokenizer'; +export type Context = { + onParseError: (error: ParseError) => void; +}; diff --git a/node_modules/@csstools/css-parser-algorithms/dist/parse/parse-comma-separated-list-of-component-values.d.ts b/node_modules/@csstools/css-parser-algorithms/dist/parse/parse-comma-separated-list-of-component-values.d.ts new file mode 100644 index 00000000..67dff1d0 --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/parse/parse-comma-separated-list-of-component-values.d.ts @@ -0,0 +1,5 @@ +import { CSSToken, ParseError } from '@csstools/css-tokenizer'; +import { ComponentValue } from '../consume/consume-component-block-function'; +export declare function parseCommaSeparatedListOfComponentValues(tokens: Array<CSSToken>, options?: { + onParseError?: (error: ParseError) => void; +}): ComponentValue[][]; diff --git a/node_modules/@csstools/css-parser-algorithms/dist/parse/parse-component-value.d.ts b/node_modules/@csstools/css-parser-algorithms/dist/parse/parse-component-value.d.ts new file mode 100644 index 00000000..2961290f --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/parse/parse-component-value.d.ts @@ -0,0 +1,4 @@ +import { CSSToken, ParseError } from '@csstools/css-tokenizer'; +export declare function parseComponentValue(tokens: Array<CSSToken>, options?: { + onParseError?: (error: ParseError) => void; +}): import("../consume/consume-component-block-function").ComponentValue | undefined; diff --git a/node_modules/@csstools/css-parser-algorithms/dist/parse/parse-list-of-component-values.d.ts b/node_modules/@csstools/css-parser-algorithms/dist/parse/parse-list-of-component-values.d.ts new file mode 100644 index 00000000..737f554d --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/parse/parse-list-of-component-values.d.ts @@ -0,0 +1,5 @@ +import { CSSToken, ParseError } from '@csstools/css-tokenizer'; +import { ComponentValue } from '../consume/consume-component-block-function'; +export declare function parseListOfComponentValues(tokens: Array<CSSToken>, options?: { + onParseError?: (error: ParseError) => void; +}): ComponentValue[]; diff --git a/node_modules/@csstools/css-parser-algorithms/dist/util/component-value-type.d.ts b/node_modules/@csstools/css-parser-algorithms/dist/util/component-value-type.d.ts new file mode 100644 index 00000000..eda7ee93 --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/util/component-value-type.d.ts @@ -0,0 +1,7 @@ +export declare enum ComponentValueType { + Function = "function", + SimpleBlock = "simple-block", + Whitespace = "whitespace", + Comment = "comment", + Token = "token" +} diff --git a/node_modules/@csstools/css-parser-algorithms/dist/util/node-ancestry.d.ts b/node_modules/@csstools/css-parser-algorithms/dist/util/node-ancestry.d.ts new file mode 100644 index 00000000..219ea619 --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/util/node-ancestry.d.ts @@ -0,0 +1,7 @@ +export interface walkable { + walk(cb: (entry: { + node: Array<unknown> | unknown; + parent: unknown; + }, index: number | string) => boolean | void): false | undefined; +} +export declare function gatherNodeAncestry(node: walkable): Map<unknown, unknown>; diff --git a/node_modules/@csstools/css-parser-algorithms/dist/util/replace-component-values.d.ts b/node_modules/@csstools/css-parser-algorithms/dist/util/replace-component-values.d.ts new file mode 100644 index 00000000..774051c6 --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/util/replace-component-values.d.ts @@ -0,0 +1,2 @@ +import type { ComponentValue } from '../consume/consume-component-block-function'; +export declare function replaceComponentValues(componentValuesList: Array<Array<ComponentValue>>, replaceWith: (componentValue: ComponentValue) => ComponentValue | void): ComponentValue[][]; diff --git a/node_modules/@csstools/css-parser-algorithms/dist/util/source-indices.d.ts b/node_modules/@csstools/css-parser-algorithms/dist/util/source-indices.d.ts new file mode 100644 index 00000000..92d124be --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/util/source-indices.d.ts @@ -0,0 +1,9 @@ +import { CSSToken } from '@csstools/css-tokenizer'; +interface TokenConvertible { + tokens(): Array<CSSToken>; +} +/** + * Returns the start and end index of a node in the CSS source string. + */ +export declare function sourceIndices(x: TokenConvertible | Array<TokenConvertible>): [number, number]; +export {}; diff --git a/node_modules/@csstools/css-parser-algorithms/dist/util/stringify.d.ts b/node_modules/@csstools/css-parser-algorithms/dist/util/stringify.d.ts new file mode 100644 index 00000000..6ab4140c --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/util/stringify.d.ts @@ -0,0 +1,2 @@ +import type { ComponentValue } from '../consume/consume-component-block-function'; +export declare function stringify(componentValueLists: Array<Array<ComponentValue>>): string; diff --git a/node_modules/@csstools/css-parser-algorithms/dist/util/type-predicates.d.ts b/node_modules/@csstools/css-parser-algorithms/dist/util/type-predicates.d.ts new file mode 100644 index 00000000..896d3036 --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/dist/util/type-predicates.d.ts @@ -0,0 +1,6 @@ +import { CommentNode, FunctionNode, SimpleBlockNode, TokenNode, WhitespaceNode } from '../consume/consume-component-block-function'; +export declare function isSimpleBlockNode(x: unknown): x is SimpleBlockNode; +export declare function isFunctionNode(x: unknown): x is FunctionNode; +export declare function isWhitespaceNode(x: unknown): x is WhitespaceNode; +export declare function isCommentNode(x: unknown): x is CommentNode; +export declare function isTokenNode(x: unknown): x is TokenNode; diff --git a/node_modules/@csstools/css-parser-algorithms/package.json b/node_modules/@csstools/css-parser-algorithms/package.json new file mode 100644 index 00000000..009c0560 --- /dev/null +++ b/node_modules/@csstools/css-parser-algorithms/package.json @@ -0,0 +1,72 @@ +{ + "name": "@csstools/css-parser-algorithms", + "description": "Algorithms to help you parse CSS from an array of tokens.", + "version": "2.3.2", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "peerDependencies": { + "@csstools/css-tokenizer": "^2.2.1" + }, + "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", + "test:rewrite-expects": "REWRITE_EXPECTS=true node ./test/test.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "packages/css-parser-algorithms" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "css", + "parser" + ], + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/css-tokenizer/CHANGELOG.md b/node_modules/@csstools/css-tokenizer/CHANGELOG.md new file mode 100644 index 00000000..ee539e2a --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/CHANGELOG.md @@ -0,0 +1,54 @@ +# Changes to CSS Tokenizer + +### 2.2.1 + +_September 24, 2023_ + +- Small performance improvements + +### 2.2.0 + +_July 24, 2023_ + +- Add support for `unicode-range-token` +- Add `signCharacter` to `DimensionToken`, `NumberToken` and `PercentageToken` +- Correctly tokenize negative zero `-0` + +### 2.1.1 + +_April 10, 2023_ + +- Document `tokenize` helper function + +### 2.1.0 + +_February 21, 2023_ + +- Add `tokenize` helper function + +### 2.0.2 + +_February 13, 2023_ + +- Relax `isToken` to match artificial tokens that correctly follow the interface. + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 19, 2023_ + +- Simplify `Reader` interface (breaking) +- Change the `ParseError` interface, this is now a subclass of `Error` (breaking) +- Remove the `commentsAreTokens` option as `true` was the only desirable value (breaking) +- Improve performance + +### 1.0.0 + +_November 14, 2022_ + +- Initial version diff --git a/node_modules/@csstools/css-tokenizer/LICENSE.md b/node_modules/@csstools/css-tokenizer/LICENSE.md new file mode 100644 index 00000000..af5411fa --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/LICENSE.md @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright 2022 Romain Menke, Antonio Laguna <antonio@laguna.es> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/@csstools/css-tokenizer/README.md b/node_modules/@csstools/css-tokenizer/README.md new file mode 100644 index 00000000..810e47c8 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/README.md @@ -0,0 +1,108 @@ +# CSS Tokenizer + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/css-tokenizer.svg" height="20">][npm-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +Implemented from : https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/ + +## Usage + +Add [CSS Tokenizer] to your project: + +```bash +npm install @csstools/css-tokenizer --save-dev +``` + +```js +import { tokenizer, TokenType } from '@csstools/css-tokenizer'; + +const myCSS = `@media only screen and (min-width: 768rem) { + .foo { + content: 'Some content!' !important; + } +} +`; + +const t = tokenizer({ + css: myCSS, +}); + +while (true) { + const token = t.nextToken(); + if (token[0] === TokenType.EOF) { + break; + } + + console.log(token); +} +``` + +Or use the `tokenize` helper function: + +```js +import { tokenize } from '@csstools/css-tokenizer'; + +const myCSS = `@media only screen and (min-width: 768rem) { + .foo { + content: 'Some content!' !important; + } +} +`; + +const tokens = tokenize({ + css: myCSS, +}); + +console.log(tokens); +``` + +### Options + +```ts +{ + onParseError?: (error: ParseError) => void +} +``` + +#### `onParseError` + +The tokenizer is forgiving and won't stop when a parse error is encountered. +Parse errors also aren't tokens. + +To receive parsing error information you can set a callback. + +```js +import { tokenizer, TokenType } from '@csstools/css-tokenizer'; + +const t = tokenizer({ + css: '\\', +}, { onParseError: (err) => console.warn(err) }); + +while (true) { + const token = t.nextToken(); + if (token[0] === TokenType.EOF) { + break; + } +} +``` + +Parser errors will try to inform you about the point in the tokenizer logic the error happened. +This tells you the kind of error. + +## Goals and non-goals + +Things this package aims to be: +- specification compliant CSS tokenizer +- a reliable low level package to be used in CSS parsers + +What it is not: +- opinionated +- fast +- small + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/css-tokenizer + +[CSS Tokenizer]: https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer diff --git a/node_modules/@csstools/css-tokenizer/dist/checks/four-code-points-would-start-cdo.d.ts b/node_modules/@csstools/css-tokenizer/dist/checks/four-code-points-would-start-cdo.d.ts new file mode 100644 index 00000000..a9243f63 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/checks/four-code-points-would-start-cdo.d.ts @@ -0,0 +1,2 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +export declare function checkIfFourCodePointsWouldStartCDO(reader: CodePointReader): boolean; diff --git a/node_modules/@csstools/css-tokenizer/dist/checks/matches-url-ident.d.ts b/node_modules/@csstools/css-tokenizer/dist/checks/matches-url-ident.d.ts new file mode 100644 index 00000000..6af31e4e --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/checks/matches-url-ident.d.ts @@ -0,0 +1 @@ +export declare function checkIfCodePointsMatchURLIdent(codePoints: Array<number>): boolean; diff --git a/node_modules/@csstools/css-tokenizer/dist/checks/three-code-points-would-start-cdc.d.ts b/node_modules/@csstools/css-tokenizer/dist/checks/three-code-points-would-start-cdc.d.ts new file mode 100644 index 00000000..09bd2323 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/checks/three-code-points-would-start-cdc.d.ts @@ -0,0 +1,2 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +export declare function checkIfThreeCodePointsWouldStartCDC(reader: CodePointReader): boolean; diff --git a/node_modules/@csstools/css-tokenizer/dist/checks/three-code-points-would-start-ident-sequence.d.ts b/node_modules/@csstools/css-tokenizer/dist/checks/three-code-points-would-start-ident-sequence.d.ts new file mode 100644 index 00000000..d48323bb --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/checks/three-code-points-would-start-ident-sequence.d.ts @@ -0,0 +1,3 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +import { Context } from '../interfaces/context'; +export declare function checkIfThreeCodePointsWouldStartAnIdentSequence(ctx: Context, reader: CodePointReader): boolean; diff --git a/node_modules/@csstools/css-tokenizer/dist/checks/three-code-points-would-start-number.d.ts b/node_modules/@csstools/css-tokenizer/dist/checks/three-code-points-would-start-number.d.ts new file mode 100644 index 00000000..9c428a45 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/checks/three-code-points-would-start-number.d.ts @@ -0,0 +1,2 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +export declare function checkIfThreeCodePointsWouldStartANumber(reader: CodePointReader): boolean; diff --git a/node_modules/@csstools/css-tokenizer/dist/checks/three-code-points-would-start-unicode-range.d.ts b/node_modules/@csstools/css-tokenizer/dist/checks/three-code-points-would-start-unicode-range.d.ts new file mode 100644 index 00000000..46c91076 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/checks/three-code-points-would-start-unicode-range.d.ts @@ -0,0 +1,2 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +export declare function checkIfThreeCodePointsWouldStartAUnicodeRange(reader: CodePointReader): boolean; diff --git a/node_modules/@csstools/css-tokenizer/dist/checks/two-code-points-are-valid-escape.d.ts b/node_modules/@csstools/css-tokenizer/dist/checks/two-code-points-are-valid-escape.d.ts new file mode 100644 index 00000000..99d954fd --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/checks/two-code-points-are-valid-escape.d.ts @@ -0,0 +1,2 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +export declare function checkIfTwoCodePointsAreAValidEscape(reader: CodePointReader): boolean; diff --git a/node_modules/@csstools/css-tokenizer/dist/checks/two-code-points-start-comment.d.ts b/node_modules/@csstools/css-tokenizer/dist/checks/two-code-points-start-comment.d.ts new file mode 100644 index 00000000..9d9fd495 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/checks/two-code-points-start-comment.d.ts @@ -0,0 +1,2 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +export declare function checkIfTwoCodePointsStartAComment(reader: CodePointReader): boolean; diff --git a/node_modules/@csstools/css-tokenizer/dist/code-points/code-points.d.ts b/node_modules/@csstools/css-tokenizer/dist/code-points/code-points.d.ts new file mode 100644 index 00000000..3dcc4778 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/code-points/code-points.d.ts @@ -0,0 +1,96 @@ +/** ' */ +export declare const APOSTROPHE = 39; +/** * */ +export declare const ASTERISK = 42; +/** \b */ +export declare const BACKSPACE = 8; +/** \r */ +export declare const CARRIAGE_RETURN = 13; +/** \t */ +export declare const CHARACTER_TABULATION = 9; +/** : */ +export declare const COLON = 58; +/** , */ +export declare const COMMA = 44; +/** @ */ +export declare const COMMERCIAL_AT = 64; +/** \x7F */ +export declare const DELETE = 127; +/** ! */ +export declare const EXCLAMATION_MARK = 33; +/** \f */ +export declare const FORM_FEED = 12; +/** . */ +export declare const FULL_STOP = 46; +/** > */ +export declare const GREATER_THAN_SIGN = 62; +/** - */ +export declare const HYPHEN_MINUS = 45; +/** \x1F */ +export declare const INFORMATION_SEPARATOR_ONE = 31; +/** E */ +export declare const LATIN_CAPITAL_LETTER_E = 69; +/** e */ +export declare const LATIN_SMALL_LETTER_E = 101; +/** { */ +export declare const LEFT_CURLY_BRACKET = 123; +/** ( */ +export declare const LEFT_PARENTHESIS = 40; +/** [ */ +export declare const LEFT_SQUARE_BRACKET = 91; +/** < */ +export declare const LESS_THAN_SIGN = 60; +/** \n */ +export declare const LINE_FEED = 10; +/** \v */ +export declare const LINE_TABULATION = 11; +/** _ */ +export declare const LOW_LINE = 95; +/** \x10FFFF */ +export declare const MAXIMUM_ALLOWED_CODEPOINT = 1114111; +/** \x00 */ +export declare const NULL = 0; +/** # */ +export declare const NUMBER_SIGN = 35; +/** % */ +export declare const PERCENTAGE_SIGN = 37; +/** + */ +export declare const PLUS_SIGN = 43; +/** " */ +export declare const QUOTATION_MARK = 34; +/** � */ +export declare const REPLACEMENT_CHARACTER = 65533; +/** \ */ +export declare const REVERSE_SOLIDUS = 92; +/** } */ +export declare const RIGHT_CURLY_BRACKET = 125; +/** ) */ +export declare const RIGHT_PARENTHESIS = 41; +/** ] */ +export declare const RIGHT_SQUARE_BRACKET = 93; +/** ; */ +export declare const SEMICOLON = 59; +/** \u0E */ +export declare const SHIFT_OUT = 14; +/** / */ +export declare const SOLIDUS = 47; +/** \u20 */ +export declare const SPACE = 32; +/** u */ +export declare const LATIN_SMALL_LETTER_U = 117; +/** U */ +export declare const LATIN_CAPITAL_LETTER_U = 85; +/** r */ +export declare const LATIN_SMALL_LETTER_R = 114; +/** R */ +export declare const LATIN_CAPITAL_LETTER_R = 82; +/** l */ +export declare const LATIN_SMALL_LETTER_L = 108; +/** L */ +export declare const LATIN_CAPITAL_LETTER_L = 76; +/** ? */ +export declare const QUESTION_MARK = 63; +/** 0 */ +export declare const DIGIT_ZERO = 48; +/** F */ +export declare const LATIN_CAPITAL_LETTER_F = 70; diff --git a/node_modules/@csstools/css-tokenizer/dist/code-points/ranges.d.ts b/node_modules/@csstools/css-tokenizer/dist/code-points/ranges.d.ts new file mode 100644 index 00000000..2fe67d8c --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/code-points/ranges.d.ts @@ -0,0 +1,13 @@ +export declare function isDigitCodePoint(search: number): boolean; +export declare function isUppercaseLetterCodePoint(search: number): boolean; +export declare function isLowercaseLetterCodePoint(search: number): boolean; +export declare function isHexDigitCodePoint(search: number): boolean; +export declare function isLetterCodePoint(search: number): boolean; +export declare function isNonASCIICodePoint(search: number): boolean; +export declare function isIdentStartCodePoint(search: number): boolean; +export declare function isIdentCodePoint(search: number): boolean; +export declare function isNonASCII_IdentCodePoint(search: number): boolean; +export declare function isNonPrintableCodePoint(search: number): boolean; +export declare function isNewLine(search: number): boolean; +export declare function isWhitespace(search: number): boolean; +export declare function isSurrogate(search: number): boolean; diff --git a/node_modules/@csstools/css-tokenizer/dist/consume/bad-url.d.ts b/node_modules/@csstools/css-tokenizer/dist/consume/bad-url.d.ts new file mode 100644 index 00000000..4b18d0e8 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/consume/bad-url.d.ts @@ -0,0 +1,3 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +import { Context } from '../interfaces/context'; +export declare function consumeBadURL(ctx: Context, reader: CodePointReader): void; diff --git a/node_modules/@csstools/css-tokenizer/dist/consume/comment.d.ts b/node_modules/@csstools/css-tokenizer/dist/consume/comment.d.ts new file mode 100644 index 00000000..d4ba2211 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/consume/comment.d.ts @@ -0,0 +1,4 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +import { Context } from '../interfaces/context'; +import { TokenComment } from '../interfaces/token'; +export declare function consumeComment(ctx: Context, reader: CodePointReader): TokenComment; diff --git a/node_modules/@csstools/css-tokenizer/dist/consume/escaped-code-point.d.ts b/node_modules/@csstools/css-tokenizer/dist/consume/escaped-code-point.d.ts new file mode 100644 index 00000000..a6f8dc2e --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/consume/escaped-code-point.d.ts @@ -0,0 +1,3 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +import { Context } from '../interfaces/context'; +export declare function consumeEscapedCodePoint(ctx: Context, reader: CodePointReader): number; diff --git a/node_modules/@csstools/css-tokenizer/dist/consume/hash-token.d.ts b/node_modules/@csstools/css-tokenizer/dist/consume/hash-token.d.ts new file mode 100644 index 00000000..ac061a84 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/consume/hash-token.d.ts @@ -0,0 +1,4 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +import { Context } from '../interfaces/context'; +import { TokenDelim, TokenHash } from '../interfaces/token'; +export declare function consumeHashToken(ctx: Context, reader: CodePointReader): TokenDelim | TokenHash; diff --git a/node_modules/@csstools/css-tokenizer/dist/consume/ident-like-token.d.ts b/node_modules/@csstools/css-tokenizer/dist/consume/ident-like-token.d.ts new file mode 100644 index 00000000..6be73762 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/consume/ident-like-token.d.ts @@ -0,0 +1,4 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +import { Context } from '../interfaces/context'; +import { TokenBadURL, TokenFunction, TokenIdent, TokenURL } from '../interfaces/token'; +export declare function consumeIdentLikeToken(ctx: Context, reader: CodePointReader): TokenIdent | TokenFunction | TokenURL | TokenBadURL; diff --git a/node_modules/@csstools/css-tokenizer/dist/consume/ident-sequence.d.ts b/node_modules/@csstools/css-tokenizer/dist/consume/ident-sequence.d.ts new file mode 100644 index 00000000..992520e2 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/consume/ident-sequence.d.ts @@ -0,0 +1,3 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +import { Context } from '../interfaces/context'; +export declare function consumeIdentSequence(ctx: Context, reader: CodePointReader): Array<number>; diff --git a/node_modules/@csstools/css-tokenizer/dist/consume/number.d.ts b/node_modules/@csstools/css-tokenizer/dist/consume/number.d.ts new file mode 100644 index 00000000..18f1704f --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/consume/number.d.ts @@ -0,0 +1,4 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +import { Context } from '../interfaces/context'; +import { NumberType } from '../interfaces/token'; +export declare function consumeNumber(ctx: Context, reader: CodePointReader): NumberType; diff --git a/node_modules/@csstools/css-tokenizer/dist/consume/numeric-token.d.ts b/node_modules/@csstools/css-tokenizer/dist/consume/numeric-token.d.ts new file mode 100644 index 00000000..1217bb0a --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/consume/numeric-token.d.ts @@ -0,0 +1,4 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +import { Context } from '../interfaces/context'; +import { TokenDimension, TokenNumber, TokenPercentage } from '../interfaces/token'; +export declare function consumeNumericToken(ctx: Context, reader: CodePointReader): TokenPercentage | TokenNumber | TokenDimension; diff --git a/node_modules/@csstools/css-tokenizer/dist/consume/string-token.d.ts b/node_modules/@csstools/css-tokenizer/dist/consume/string-token.d.ts new file mode 100644 index 00000000..31f6448f --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/consume/string-token.d.ts @@ -0,0 +1,4 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +import { Context } from '../interfaces/context'; +import { TokenBadString, TokenString } from '../interfaces/token'; +export declare function consumeStringToken(ctx: Context, reader: CodePointReader): TokenBadString | TokenString; diff --git a/node_modules/@csstools/css-tokenizer/dist/consume/unicode-range-token.d.ts b/node_modules/@csstools/css-tokenizer/dist/consume/unicode-range-token.d.ts new file mode 100644 index 00000000..526bcfe1 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/consume/unicode-range-token.d.ts @@ -0,0 +1,4 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +import { Context } from '../interfaces/context'; +import { TokenUnicodeRange } from '../interfaces/token'; +export declare function consumeUnicodeRangeToken(ctx: Context, reader: CodePointReader): TokenUnicodeRange; diff --git a/node_modules/@csstools/css-tokenizer/dist/consume/url-token.d.ts b/node_modules/@csstools/css-tokenizer/dist/consume/url-token.d.ts new file mode 100644 index 00000000..9140be70 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/consume/url-token.d.ts @@ -0,0 +1,4 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +import { Context } from '../interfaces/context'; +import { TokenBadURL, TokenURL } from '../interfaces/token'; +export declare function consumeUrlToken(ctx: Context, reader: CodePointReader): TokenURL | TokenBadURL; diff --git a/node_modules/@csstools/css-tokenizer/dist/consume/whitespace-token.d.ts b/node_modules/@csstools/css-tokenizer/dist/consume/whitespace-token.d.ts new file mode 100644 index 00000000..4584dc9a --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/consume/whitespace-token.d.ts @@ -0,0 +1,3 @@ +import { CodePointReader } from '../interfaces/code-point-reader'; +import { TokenWhitespace } from '../interfaces/token'; +export declare function consumeWhiteSpace(reader: CodePointReader): TokenWhitespace; diff --git a/node_modules/@csstools/css-tokenizer/dist/index.cjs b/node_modules/@csstools/css-tokenizer/dist/index.cjs new file mode 100644 index 00000000..915afc28 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/index.cjs @@ -0,0 +1 @@ +"use strict";class ParseError extends Error{sourceStart;sourceEnd;parserState;constructor(e,o,n,r){super(e),this.name="ParseError",this.sourceStart=o,this.sourceEnd=n,this.parserState=r}}class Reader{cursor=0;source="";codePointSource=[];representationIndices=[-1];length=0;representationStart=0;representationEnd=-1;constructor(e){this.source=e;{let o=-1,n="";for(n of e)o+=n.length,this.codePointSource.push(n.codePointAt(0)),this.representationIndices.push(o)}this.length=this.codePointSource.length}advanceCodePoint(e=1){this.cursor=this.cursor+e,this.representationEnd=this.representationIndices[this.cursor]}readCodePoint(e=1){const o=this.codePointSource[this.cursor];return void 0!==o&&(this.cursor=this.cursor+e,this.representationEnd=this.representationIndices[this.cursor],o)}unreadCodePoint(e=1){this.cursor=this.cursor-e,this.representationEnd=this.representationIndices[this.cursor]}resetRepresentation(){this.representationStart=this.representationIndices[this.cursor]+1,this.representationEnd=-1}}var e,o,n;exports.TokenType=void 0,(e=exports.TokenType||(exports.TokenType={})).Comment="comment",e.AtKeyword="at-keyword-token",e.BadString="bad-string-token",e.BadURL="bad-url-token",e.CDC="CDC-token",e.CDO="CDO-token",e.Colon="colon-token",e.Comma="comma-token",e.Delim="delim-token",e.Dimension="dimension-token",e.EOF="EOF-token",e.Function="function-token",e.Hash="hash-token",e.Ident="ident-token",e.Number="number-token",e.Percentage="percentage-token",e.Semicolon="semicolon-token",e.String="string-token",e.URL="url-token",e.Whitespace="whitespace-token",e.OpenParen="(-token",e.CloseParen=")-token",e.OpenSquare="[-token",e.CloseSquare="]-token",e.OpenCurly="{-token",e.CloseCurly="}-token",e.UnicodeRange="unicode-range-token",exports.NumberType=void 0,(o=exports.NumberType||(exports.NumberType={})).Integer="integer",o.Number="number",function(e){e.Unrestricted="unrestricted",e.ID="id"}(n||(n={}));const r=Object.values(exports.TokenType);const t=39,i=42,s=8,c=13,a=9,u=58,d=44,p=64,P=127,S=33,C=12,T=46,l=62,k=45,f=31,m=69,h=101,E=123,v=40,x=91,y=60,g=10,I=11,O=95,U=1114111,w=0,D=35,R=37,A=43,L=34,N=65533,b=92,q=125,W=41,F=93,H=59,V=14,B=47,z=32,K=117,M=85,$=114,J=82,_=108,j=76,Q=63,G=48,X=70;function checkIfFourCodePointsWouldStartCDO(e){return e.codePointSource[e.cursor]===y&&e.codePointSource[e.cursor+1]===S&&e.codePointSource[e.cursor+2]===k&&e.codePointSource[e.cursor+3]===k}function isDigitCodePoint(e){return e>=48&&e<=57}function isUppercaseLetterCodePoint(e){return e>=65&&e<=90}function isLowercaseLetterCodePoint(e){return e>=97&&e<=122}function isHexDigitCodePoint(e){return isDigitCodePoint(e)||e>=97&&e<=102||e>=65&&e<=70}function isLetterCodePoint(e){return isLowercaseLetterCodePoint(e)||isUppercaseLetterCodePoint(e)}function isIdentStartCodePoint(e){return isLetterCodePoint(e)||isNonASCII_IdentCodePoint(e)||e===O}function isIdentCodePoint(e){return isIdentStartCodePoint(e)||isDigitCodePoint(e)||e===k}function isNonASCII_IdentCodePoint(e){return 183===e||8204===e||8205===e||8255===e||8256===e||8204===e||(192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=893||895<=e&&e<=8191||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||63744<=e&&e<=64975||65008<=e&&e<=65533||e>=65536)}function isNewLine(e){return 10===e||13===e||12===e}function isWhitespace(e){return 32===e||10===e||9===e||13===e||12===e}function checkIfTwoCodePointsAreAValidEscape(e){return e.codePointSource[e.cursor]===b&&!isNewLine(e.codePointSource[e.cursor+1])}function checkIfThreeCodePointsWouldStartAnIdentSequence(e,o){return o.codePointSource[o.cursor]===k?o.codePointSource[o.cursor+1]===k||(!!isIdentStartCodePoint(o.codePointSource[o.cursor+1])||o.codePointSource[o.cursor+1]===b&&!isNewLine(o.codePointSource[o.cursor+2])):!!isIdentStartCodePoint(o.codePointSource[o.cursor])||checkIfTwoCodePointsAreAValidEscape(o)}function checkIfThreeCodePointsWouldStartANumber(e){return e.codePointSource[e.cursor]===A||e.codePointSource[e.cursor]===k?!!isDigitCodePoint(e.codePointSource[e.cursor+1])||e.codePointSource[e.cursor+1]===T&&isDigitCodePoint(e.codePointSource[e.cursor+2]):e.codePointSource[e.cursor]===T?isDigitCodePoint(e.codePointSource[e.cursor+1]):isDigitCodePoint(e.codePointSource[e.cursor])}function checkIfTwoCodePointsStartAComment(e){return e.codePointSource[e.cursor]===B&&e.codePointSource[e.cursor+1]===i}function checkIfThreeCodePointsWouldStartCDC(e){return e.codePointSource[e.cursor]===k&&e.codePointSource[e.cursor+1]===k&&e.codePointSource[e.cursor+2]===l}function consumeComment(e,o){for(o.advanceCodePoint(2);;){const n=o.readCodePoint();if(!1===n){e.onParseError(new ParseError("Unexpected EOF while consuming a comment.",o.representationStart,o.representationEnd,["4.3.2. Consume comments","Unexpected EOF"]));break}if(n===i&&(void 0!==o.codePointSource[o.cursor]&&o.codePointSource[o.cursor]===B)){o.advanceCodePoint();break}}return[exports.TokenType.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0]}function consumeEscapedCodePoint(e,o){const n=o.readCodePoint();if(!1===n)return e.onParseError(new ParseError("Unexpected EOF while consuming an escaped code point.",o.representationStart,o.representationEnd,["4.3.7. Consume an escaped code point","Unexpected EOF"])),N;if(isHexDigitCodePoint(n)){const e=[n];for(;void 0!==o.codePointSource[o.cursor]&&isHexDigitCodePoint(o.codePointSource[o.cursor])&&e.length<6;)e.push(o.codePointSource[o.cursor]),o.advanceCodePoint();isWhitespace(o.codePointSource[o.cursor])&&o.advanceCodePoint();const t=parseInt(String.fromCodePoint(...e),16);return 0===t?N:(r=t)>=55296&&r<=57343||t>U?N:t}var r;return n}function consumeIdentSequence(e,o){const n=[];for(;;)if(isIdentCodePoint(o.codePointSource[o.cursor]))n.push(o.codePointSource[o.cursor]),o.advanceCodePoint();else{if(!checkIfTwoCodePointsAreAValidEscape(o))return n;o.advanceCodePoint(),n.push(consumeEscapedCodePoint(e,o))}}function consumeHashToken(e,o){if(o.advanceCodePoint(),void 0!==o.codePointSource[o.cursor]&&(isIdentCodePoint(o.codePointSource[o.cursor])||checkIfTwoCodePointsAreAValidEscape(o))){let r=n.Unrestricted;checkIfThreeCodePointsWouldStartAnIdentSequence(0,o)&&(r=n.ID);const t=consumeIdentSequence(e,o);return[exports.TokenType.Hash,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:String.fromCodePoint(...t),type:r}]}return[exports.TokenType.Delim,"#",o.representationStart,o.representationEnd,{value:"#"}]}function consumeNumber(e,o){let n=exports.NumberType.Integer;for(o.codePointSource[o.cursor]!==A&&o.codePointSource[o.cursor]!==k||o.advanceCodePoint();isDigitCodePoint(o.codePointSource[o.cursor]);)o.advanceCodePoint();if(o.codePointSource[o.cursor]===T&&isDigitCodePoint(o.codePointSource[o.cursor+1]))for(o.advanceCodePoint(2),n=exports.NumberType.Number;isDigitCodePoint(o.codePointSource[o.cursor]);)o.advanceCodePoint();if(o.codePointSource[o.cursor]===h||o.codePointSource[o.cursor]===m){if(isDigitCodePoint(o.codePointSource[o.cursor+1]))o.advanceCodePoint(2);else{if(o.codePointSource[o.cursor+1]!==k&&o.codePointSource[o.cursor+1]!==A||!isDigitCodePoint(o.codePointSource[o.cursor+2]))return n;o.advanceCodePoint(3)}for(n=exports.NumberType.Number;isDigitCodePoint(o.codePointSource[o.cursor]);)o.advanceCodePoint()}return n}function consumeNumericToken(e,o){let n;{const e=o.codePointSource[o.cursor];e===k?n="-":e===A&&(n="+")}const r=consumeNumber(0,o),t=parseFloat(o.source.slice(o.representationStart,o.representationEnd+1))||0;if(checkIfThreeCodePointsWouldStartAnIdentSequence(0,o)){const i=consumeIdentSequence(e,o);return[exports.TokenType.Dimension,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t,signCharacter:n,type:r,unit:String.fromCodePoint(...i)}]}return o.codePointSource[o.cursor]===R?(o.advanceCodePoint(),[exports.TokenType.Percentage,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t,signCharacter:n}]):[exports.TokenType.Number,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t,signCharacter:n,type:r}]}function consumeWhiteSpace(e){for(;isWhitespace(e.codePointSource[e.cursor]);)e.advanceCodePoint();return[exports.TokenType.Whitespace,e.source.slice(e.representationStart,e.representationEnd+1),e.representationStart,e.representationEnd,void 0]}function consumeStringToken(e,o){let n="";const r=o.readCodePoint();for(;;){const t=o.readCodePoint();if(!1===t)return e.onParseError(new ParseError("Unexpected EOF while consuming a string token.",o.representationStart,o.representationEnd,["4.3.5. Consume a string token","Unexpected EOF"])),[exports.TokenType.String,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:n}];if(isNewLine(t))return e.onParseError(new ParseError("Unexpected newline while consuming a string token.",o.representationStart,o.representationEnd,["4.3.5. Consume a string token","Unexpected newline"])),o.unreadCodePoint(),[exports.TokenType.BadString,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];if(t===r)return[exports.TokenType.String,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:n}];if(t!==b)n+=String.fromCodePoint(t);else{if(void 0===o.codePointSource[o.cursor])continue;if(isNewLine(o.codePointSource[o.cursor])){o.advanceCodePoint();continue}n+=String.fromCodePoint(consumeEscapedCodePoint(e,o))}}}function checkIfCodePointsMatchURLIdent(e){return!(3!==e.length||e[0]!==K&&e[0]!==M||e[1]!==$&&e[1]!==J||e[2]!==_&&e[2]!==j)}function consumeBadURL(e,o){for(;;){if(void 0===o.codePointSource[o.cursor])return;if(o.codePointSource[o.cursor]===W)return void o.advanceCodePoint();checkIfTwoCodePointsAreAValidEscape(o)?(o.advanceCodePoint(),consumeEscapedCodePoint(e,o)):o.advanceCodePoint()}}function consumeUrlToken(e,o){for(;isWhitespace(o.codePointSource[o.cursor]);)o.advanceCodePoint();let n="";for(;;){if(void 0===o.codePointSource[o.cursor])return e.onParseError(new ParseError("Unexpected EOF while consuming a url token.",o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected EOF"])),[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:n}];if(o.codePointSource[o.cursor]===W)return o.advanceCodePoint(),[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:n}];if(isWhitespace(o.codePointSource[o.cursor])){for(o.advanceCodePoint();isWhitespace(o.codePointSource[o.cursor]);)o.advanceCodePoint();return void 0===o.codePointSource[o.cursor]?(e.onParseError(new ParseError("Unexpected EOF while consuming a url token.",o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Consume as much whitespace as possible","Unexpected EOF"])),[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:n}]):o.codePointSource[o.cursor]===W?(o.advanceCodePoint(),[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:n}]):(consumeBadURL(e,o),[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0])}if(o.codePointSource[o.cursor]===L||o.codePointSource[o.cursor]===t||o.codePointSource[o.cursor]===v||((r=o.codePointSource[o.cursor])===I||r===P||w<=r&&r<=s||V<=r&&r<=f))return consumeBadURL(e,o),e.onParseError(new ParseError("Unexpected character while consuming a url token.",o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected U+0022 QUOTATION MARK (\"), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point"])),[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];if(o.codePointSource[o.cursor]===b){if(checkIfTwoCodePointsAreAValidEscape(o)){o.advanceCodePoint(),n+=String.fromCodePoint(consumeEscapedCodePoint(e,o));continue}return consumeBadURL(e,o),e.onParseError(new ParseError("Invalid escape sequence while consuming a url token.",o.representationStart,o.representationEnd,["4.3.6. Consume a url token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"])),[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0]}n+=String.fromCodePoint(o.codePointSource[o.cursor]),o.advanceCodePoint()}var r}function consumeIdentLikeToken(e,o){const n=consumeIdentSequence(e,o);if(o.codePointSource[o.cursor]!==v)return[exports.TokenType.Ident,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:String.fromCodePoint(...n)}];if(checkIfCodePointsMatchURLIdent(n)){o.advanceCodePoint();let r=0;for(;;){const e=isWhitespace(o.codePointSource[o.cursor]),i=isWhitespace(o.codePointSource[o.cursor+1]);if(e&&i){r+=1,o.advanceCodePoint(1);continue}const s=e?o.codePointSource[o.cursor+1]:o.codePointSource[o.cursor];if(s===L||s===t)return r>0&&o.unreadCodePoint(r),[exports.TokenType.Function,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:String.fromCodePoint(...n)}];break}return consumeUrlToken(e,o)}return o.advanceCodePoint(),[exports.TokenType.Function,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:String.fromCodePoint(...n)}]}function checkIfThreeCodePointsWouldStartAUnicodeRange(e){return!(e.codePointSource[e.cursor]!==K&&e.codePointSource[e.cursor]!==M||e.codePointSource[e.cursor+1]!==A||e.codePointSource[e.cursor+2]!==Q&&!isHexDigitCodePoint(e.codePointSource[e.cursor+2]))}function consumeUnicodeRangeToken(e,o){o.advanceCodePoint(2);const n=[],r=[];for(;void 0!==o.codePointSource[o.cursor]&&n.length<6&&isHexDigitCodePoint(o.codePointSource[o.cursor]);)n.push(o.codePointSource[o.cursor]),o.advanceCodePoint();for(;void 0!==o.codePointSource[o.cursor]&&n.length<6&&o.codePointSource[o.cursor]===Q;)0===r.length&&r.push(...n),n.push(G),r.push(X),o.advanceCodePoint();if(!r.length&&o.codePointSource[o.cursor]===k&&isHexDigitCodePoint(o.codePointSource[o.cursor+1]))for(o.advanceCodePoint();void 0!==o.codePointSource[o.cursor]&&r.length<6&&isHexDigitCodePoint(o.codePointSource[o.cursor]);)r.push(o.codePointSource[o.cursor]),o.advanceCodePoint();if(!r.length){const e=parseInt(String.fromCodePoint(...n),16);return[exports.TokenType.UnicodeRange,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{startOfRange:e,endOfRange:e}]}const t=parseInt(String.fromCodePoint(...n),16),i=parseInt(String.fromCodePoint(...r),16);return[exports.TokenType.UnicodeRange,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{startOfRange:t,endOfRange:i}]}function tokenizer(e,o){const n=e.css.valueOf(),r=e.unicodeRangesAllowed??!1,i=new Reader(n),s={onParseError:(null==o?void 0:o.onParseError)??(()=>{})};return{nextToken:function nextToken(){i.resetRepresentation();const e=i.codePointSource[i.cursor];if(void 0===e)return[exports.TokenType.EOF,"",-1,-1,void 0];if(e===B&&checkIfTwoCodePointsStartAComment(i))return consumeComment(s,i);if(r&&(e===K||e===M)&&checkIfThreeCodePointsWouldStartAUnicodeRange(i))return consumeUnicodeRangeToken(0,i);if(isIdentStartCodePoint(e))return consumeIdentLikeToken(s,i);if(isDigitCodePoint(e))return consumeNumericToken(s,i);switch(e){case d:return i.advanceCodePoint(),[exports.TokenType.Comma,",",i.representationStart,i.representationEnd,void 0];case u:return i.advanceCodePoint(),[exports.TokenType.Colon,":",i.representationStart,i.representationEnd,void 0];case H:return i.advanceCodePoint(),[exports.TokenType.Semicolon,";",i.representationStart,i.representationEnd,void 0];case v:return i.advanceCodePoint(),[exports.TokenType.OpenParen,"(",i.representationStart,i.representationEnd,void 0];case W:return i.advanceCodePoint(),[exports.TokenType.CloseParen,")",i.representationStart,i.representationEnd,void 0];case x:return i.advanceCodePoint(),[exports.TokenType.OpenSquare,"[",i.representationStart,i.representationEnd,void 0];case F:return i.advanceCodePoint(),[exports.TokenType.CloseSquare,"]",i.representationStart,i.representationEnd,void 0];case E:return i.advanceCodePoint(),[exports.TokenType.OpenCurly,"{",i.representationStart,i.representationEnd,void 0];case q:return i.advanceCodePoint(),[exports.TokenType.CloseCurly,"}",i.representationStart,i.representationEnd,void 0];case t:case L:return consumeStringToken(s,i);case D:return consumeHashToken(s,i);case A:case T:return checkIfThreeCodePointsWouldStartANumber(i)?consumeNumericToken(s,i):(i.advanceCodePoint(),[exports.TokenType.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]);case g:case c:case C:case a:case z:return consumeWhiteSpace(i);case k:return checkIfThreeCodePointsWouldStartANumber(i)?consumeNumericToken(s,i):checkIfThreeCodePointsWouldStartCDC(i)?(i.advanceCodePoint(3),[exports.TokenType.CDC,"--\x3e",i.representationStart,i.representationEnd,void 0]):checkIfThreeCodePointsWouldStartAnIdentSequence(0,i)?consumeIdentLikeToken(s,i):(i.advanceCodePoint(),[exports.TokenType.Delim,"-",i.representationStart,i.representationEnd,{value:"-"}]);case y:return checkIfFourCodePointsWouldStartCDO(i)?(i.advanceCodePoint(4),[exports.TokenType.CDO,"\x3c!--",i.representationStart,i.representationEnd,void 0]):(i.advanceCodePoint(),[exports.TokenType.Delim,"<",i.representationStart,i.representationEnd,{value:"<"}]);case p:if(i.advanceCodePoint(),checkIfThreeCodePointsWouldStartAnIdentSequence(0,i)){const e=consumeIdentSequence(s,i);return[exports.TokenType.AtKeyword,i.source.slice(i.representationStart,i.representationEnd+1),i.representationStart,i.representationEnd,{value:String.fromCodePoint(...e)}]}return[exports.TokenType.Delim,"@",i.representationStart,i.representationEnd,{value:"@"}];case b:return checkIfTwoCodePointsAreAValidEscape(i)?consumeIdentLikeToken(s,i):(i.advanceCodePoint(),s.onParseError(new ParseError('Invalid escape sequence after "\\"',i.representationStart,i.representationEnd,["4.3.1. Consume a token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"])),[exports.TokenType.Delim,"\\",i.representationStart,i.representationEnd,{value:"\\"}])}return i.advanceCodePoint(),[exports.TokenType.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]},endOfFile:function endOfFile(){return void 0===i.codePointSource[i.cursor]}}}exports.ParseError=ParseError,exports.Reader=Reader,exports.cloneTokens=function cloneTokens(e){return"undefined"!=typeof globalThis&&"structuredClone"in globalThis?structuredClone(e):JSON.parse(JSON.stringify(e))},exports.isToken=function isToken(e){return!!Array.isArray(e)&&(!(e.length<4)&&(!!r.includes(e[0])&&("string"==typeof e[1]&&("number"==typeof e[2]&&"number"==typeof e[3]))))},exports.mirrorVariant=function mirrorVariant(e){switch(e[0]){case exports.TokenType.OpenParen:return[exports.TokenType.CloseParen,")",-1,-1,void 0];case exports.TokenType.CloseParen:return[exports.TokenType.OpenParen,"(",-1,-1,void 0];case exports.TokenType.OpenCurly:return[exports.TokenType.CloseCurly,"}",-1,-1,void 0];case exports.TokenType.CloseCurly:return[exports.TokenType.OpenCurly,"{",-1,-1,void 0];case exports.TokenType.OpenSquare:return[exports.TokenType.CloseSquare,"]",-1,-1,void 0];case exports.TokenType.CloseSquare:return[exports.TokenType.OpenSquare,"[",-1,-1,void 0];default:return null}},exports.mirrorVariantType=function mirrorVariantType(e){switch(e){case exports.TokenType.OpenParen:return exports.TokenType.CloseParen;case exports.TokenType.CloseParen:return exports.TokenType.OpenParen;case exports.TokenType.OpenCurly:return exports.TokenType.CloseCurly;case exports.TokenType.CloseCurly:return exports.TokenType.OpenCurly;case exports.TokenType.OpenSquare:return exports.TokenType.CloseSquare;case exports.TokenType.CloseSquare:return exports.TokenType.OpenSquare;default:return null}},exports.mutateIdent=function mutateIdent(e,o){let n="";const r=[];{let e="";for(e of o)r.push(e.codePointAt(0))}let t=0;r[0]===k&&r[1]===k?(n="--",t=2):r[0]===k&&r[1]?(n="-",t=2,isIdentStartCodePoint(r[1])?n+=o[1]:n+=`\\${r[1].toString(16)} `):isIdentStartCodePoint(r[0])?(n=o[0],t=1):(n=`\\${r[0].toString(16)} `,t=1);for(let e=t;e<r.length;e++)isIdentCodePoint(r[e])?n+=o[e]:n+=`\\${r[e].toString(16)} `;e[1]=n,e[4].value=o},exports.stringify=function stringify(...e){let o="";for(let n=0;n<e.length;n++)o+=e[n][1];return o},exports.tokenize=function tokenize(e,o){const n=tokenizer(e,o),r=[];{for(;!n.endOfFile();){const e=n.nextToken();e&&r.push(e)}const e=n.nextToken();e&&r.push(e)}return r},exports.tokenizer=tokenizer; diff --git a/node_modules/@csstools/css-tokenizer/dist/index.d.ts b/node_modules/@csstools/css-tokenizer/dist/index.d.ts new file mode 100644 index 00000000..ce252e77 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/index.d.ts @@ -0,0 +1,9 @@ +export type { CSSToken } from './interfaces/token'; +export { ParseError } from './interfaces/error'; +export { Reader } from './reader'; +export { TokenType, NumberType, mirrorVariantType, mirrorVariant, isToken } from './interfaces/token'; +export { stringify } from './stringify'; +export { tokenize, tokenizer } from './tokenizer'; +export { cloneTokens } from './util/clone-tokens'; +export type { TokenAtKeyword, TokenBadString, TokenBadURL, TokenCDC, TokenCDO, TokenColon, TokenComma, TokenComment, TokenDelim, TokenDimension, TokenEOF, TokenFunction, TokenHash, TokenIdent, TokenNumber, TokenPercentage, TokenSemicolon, TokenString, TokenURL, TokenWhitespace, TokenOpenParen, TokenCloseParen, TokenOpenSquare, TokenCloseSquare, TokenOpenCurly, TokenCloseCurly, } from './interfaces/token'; +export { mutateIdent, } from './util/mutations'; diff --git a/node_modules/@csstools/css-tokenizer/dist/index.mjs b/node_modules/@csstools/css-tokenizer/dist/index.mjs new file mode 100644 index 00000000..a073b6bc --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/index.mjs @@ -0,0 +1 @@ +class ParseError extends Error{sourceStart;sourceEnd;parserState;constructor(e,n,o,r){super(e),this.name="ParseError",this.sourceStart=n,this.sourceEnd=o,this.parserState=r}}class Reader{cursor=0;source="";codePointSource=[];representationIndices=[-1];length=0;representationStart=0;representationEnd=-1;constructor(e){this.source=e;{let n=-1,o="";for(o of e)n+=o.length,this.codePointSource.push(o.codePointAt(0)),this.representationIndices.push(n)}this.length=this.codePointSource.length}advanceCodePoint(e=1){this.cursor=this.cursor+e,this.representationEnd=this.representationIndices[this.cursor]}readCodePoint(e=1){const n=this.codePointSource[this.cursor];return void 0!==n&&(this.cursor=this.cursor+e,this.representationEnd=this.representationIndices[this.cursor],n)}unreadCodePoint(e=1){this.cursor=this.cursor-e,this.representationEnd=this.representationIndices[this.cursor]}resetRepresentation(){this.representationStart=this.representationIndices[this.cursor]+1,this.representationEnd=-1}}var e,n,o;function mirrorVariantType(n){switch(n){case e.OpenParen:return e.CloseParen;case e.CloseParen:return e.OpenParen;case e.OpenCurly:return e.CloseCurly;case e.CloseCurly:return e.OpenCurly;case e.OpenSquare:return e.CloseSquare;case e.CloseSquare:return e.OpenSquare;default:return null}}function mirrorVariant(n){switch(n[0]){case e.OpenParen:return[e.CloseParen,")",-1,-1,void 0];case e.CloseParen:return[e.OpenParen,"(",-1,-1,void 0];case e.OpenCurly:return[e.CloseCurly,"}",-1,-1,void 0];case e.CloseCurly:return[e.OpenCurly,"{",-1,-1,void 0];case e.OpenSquare:return[e.CloseSquare,"]",-1,-1,void 0];case e.CloseSquare:return[e.OpenSquare,"[",-1,-1,void 0];default:return null}}!function(e){e.Comment="comment",e.AtKeyword="at-keyword-token",e.BadString="bad-string-token",e.BadURL="bad-url-token",e.CDC="CDC-token",e.CDO="CDO-token",e.Colon="colon-token",e.Comma="comma-token",e.Delim="delim-token",e.Dimension="dimension-token",e.EOF="EOF-token",e.Function="function-token",e.Hash="hash-token",e.Ident="ident-token",e.Number="number-token",e.Percentage="percentage-token",e.Semicolon="semicolon-token",e.String="string-token",e.URL="url-token",e.Whitespace="whitespace-token",e.OpenParen="(-token",e.CloseParen=")-token",e.OpenSquare="[-token",e.CloseSquare="]-token",e.OpenCurly="{-token",e.CloseCurly="}-token",e.UnicodeRange="unicode-range-token"}(e||(e={})),function(e){e.Integer="integer",e.Number="number"}(n||(n={})),function(e){e.Unrestricted="unrestricted",e.ID="id"}(o||(o={}));const r=Object.values(e);function isToken(e){return!!Array.isArray(e)&&(!(e.length<4)&&(!!r.includes(e[0])&&("string"==typeof e[1]&&("number"==typeof e[2]&&"number"==typeof e[3]))))}function stringify(...e){let n="";for(let o=0;o<e.length;o++)n+=e[o][1];return n}const t=39,i=42,c=8,s=13,a=9,u=58,d=44,P=64,p=127,S=33,C=12,l=46,f=62,h=45,E=31,m=69,v=101,g=123,k=40,I=91,T=60,O=10,U=11,w=95,D=1114111,A=0,R=35,L=37,x=43,y=34,q=65533,W=92,N=125,b=41,F=93,H=59,V=14,B=47,z=32,K=117,M=85,$=114,J=82,_=108,j=76,Q=63,G=48,X=70;function checkIfFourCodePointsWouldStartCDO(e){return e.codePointSource[e.cursor]===T&&e.codePointSource[e.cursor+1]===S&&e.codePointSource[e.cursor+2]===h&&e.codePointSource[e.cursor+3]===h}function isDigitCodePoint(e){return e>=48&&e<=57}function isUppercaseLetterCodePoint(e){return e>=65&&e<=90}function isLowercaseLetterCodePoint(e){return e>=97&&e<=122}function isHexDigitCodePoint(e){return isDigitCodePoint(e)||e>=97&&e<=102||e>=65&&e<=70}function isLetterCodePoint(e){return isLowercaseLetterCodePoint(e)||isUppercaseLetterCodePoint(e)}function isIdentStartCodePoint(e){return isLetterCodePoint(e)||isNonASCII_IdentCodePoint(e)||e===w}function isIdentCodePoint(e){return isIdentStartCodePoint(e)||isDigitCodePoint(e)||e===h}function isNonASCII_IdentCodePoint(e){return 183===e||8204===e||8205===e||8255===e||8256===e||8204===e||(192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=893||895<=e&&e<=8191||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||63744<=e&&e<=64975||65008<=e&&e<=65533||e>=65536)}function isNewLine(e){return 10===e||13===e||12===e}function isWhitespace(e){return 32===e||10===e||9===e||13===e||12===e}function checkIfTwoCodePointsAreAValidEscape(e){return e.codePointSource[e.cursor]===W&&!isNewLine(e.codePointSource[e.cursor+1])}function checkIfThreeCodePointsWouldStartAnIdentSequence(e,n){return n.codePointSource[n.cursor]===h?n.codePointSource[n.cursor+1]===h||(!!isIdentStartCodePoint(n.codePointSource[n.cursor+1])||n.codePointSource[n.cursor+1]===W&&!isNewLine(n.codePointSource[n.cursor+2])):!!isIdentStartCodePoint(n.codePointSource[n.cursor])||checkIfTwoCodePointsAreAValidEscape(n)}function checkIfThreeCodePointsWouldStartANumber(e){return e.codePointSource[e.cursor]===x||e.codePointSource[e.cursor]===h?!!isDigitCodePoint(e.codePointSource[e.cursor+1])||e.codePointSource[e.cursor+1]===l&&isDigitCodePoint(e.codePointSource[e.cursor+2]):e.codePointSource[e.cursor]===l?isDigitCodePoint(e.codePointSource[e.cursor+1]):isDigitCodePoint(e.codePointSource[e.cursor])}function checkIfTwoCodePointsStartAComment(e){return e.codePointSource[e.cursor]===B&&e.codePointSource[e.cursor+1]===i}function checkIfThreeCodePointsWouldStartCDC(e){return e.codePointSource[e.cursor]===h&&e.codePointSource[e.cursor+1]===h&&e.codePointSource[e.cursor+2]===f}function consumeComment(n,o){for(o.advanceCodePoint(2);;){const e=o.readCodePoint();if(!1===e){n.onParseError(new ParseError("Unexpected EOF while consuming a comment.",o.representationStart,o.representationEnd,["4.3.2. Consume comments","Unexpected EOF"]));break}if(e===i&&(void 0!==o.codePointSource[o.cursor]&&o.codePointSource[o.cursor]===B)){o.advanceCodePoint();break}}return[e.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0]}function consumeEscapedCodePoint(e,n){const o=n.readCodePoint();if(!1===o)return e.onParseError(new ParseError("Unexpected EOF while consuming an escaped code point.",n.representationStart,n.representationEnd,["4.3.7. Consume an escaped code point","Unexpected EOF"])),q;if(isHexDigitCodePoint(o)){const e=[o];for(;void 0!==n.codePointSource[n.cursor]&&isHexDigitCodePoint(n.codePointSource[n.cursor])&&e.length<6;)e.push(n.codePointSource[n.cursor]),n.advanceCodePoint();isWhitespace(n.codePointSource[n.cursor])&&n.advanceCodePoint();const t=parseInt(String.fromCodePoint(...e),16);return 0===t?q:(r=t)>=55296&&r<=57343||t>D?q:t}var r;return o}function consumeIdentSequence(e,n){const o=[];for(;;)if(isIdentCodePoint(n.codePointSource[n.cursor]))o.push(n.codePointSource[n.cursor]),n.advanceCodePoint();else{if(!checkIfTwoCodePointsAreAValidEscape(n))return o;n.advanceCodePoint(),o.push(consumeEscapedCodePoint(e,n))}}function consumeHashToken(n,r){if(r.advanceCodePoint(),void 0!==r.codePointSource[r.cursor]&&(isIdentCodePoint(r.codePointSource[r.cursor])||checkIfTwoCodePointsAreAValidEscape(r))){let t=o.Unrestricted;checkIfThreeCodePointsWouldStartAnIdentSequence(0,r)&&(t=o.ID);const i=consumeIdentSequence(n,r);return[e.Hash,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,{value:String.fromCodePoint(...i),type:t}]}return[e.Delim,"#",r.representationStart,r.representationEnd,{value:"#"}]}function consumeNumber(e,o){let r=n.Integer;for(o.codePointSource[o.cursor]!==x&&o.codePointSource[o.cursor]!==h||o.advanceCodePoint();isDigitCodePoint(o.codePointSource[o.cursor]);)o.advanceCodePoint();if(o.codePointSource[o.cursor]===l&&isDigitCodePoint(o.codePointSource[o.cursor+1]))for(o.advanceCodePoint(2),r=n.Number;isDigitCodePoint(o.codePointSource[o.cursor]);)o.advanceCodePoint();if(o.codePointSource[o.cursor]===v||o.codePointSource[o.cursor]===m){if(isDigitCodePoint(o.codePointSource[o.cursor+1]))o.advanceCodePoint(2);else{if(o.codePointSource[o.cursor+1]!==h&&o.codePointSource[o.cursor+1]!==x||!isDigitCodePoint(o.codePointSource[o.cursor+2]))return r;o.advanceCodePoint(3)}for(r=n.Number;isDigitCodePoint(o.codePointSource[o.cursor]);)o.advanceCodePoint()}return r}function consumeNumericToken(n,o){let r;{const e=o.codePointSource[o.cursor];e===h?r="-":e===x&&(r="+")}const t=consumeNumber(0,o),i=parseFloat(o.source.slice(o.representationStart,o.representationEnd+1))||0;if(checkIfThreeCodePointsWouldStartAnIdentSequence(0,o)){const c=consumeIdentSequence(n,o);return[e.Dimension,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:i,signCharacter:r,type:t,unit:String.fromCodePoint(...c)}]}return o.codePointSource[o.cursor]===L?(o.advanceCodePoint(),[e.Percentage,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:i,signCharacter:r}]):[e.Number,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:i,signCharacter:r,type:t}]}function consumeWhiteSpace(n){for(;isWhitespace(n.codePointSource[n.cursor]);)n.advanceCodePoint();return[e.Whitespace,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,void 0]}function consumeStringToken(n,o){let r="";const t=o.readCodePoint();for(;;){const i=o.readCodePoint();if(!1===i)return n.onParseError(new ParseError("Unexpected EOF while consuming a string token.",o.representationStart,o.representationEnd,["4.3.5. Consume a string token","Unexpected EOF"])),[e.String,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:r}];if(isNewLine(i))return n.onParseError(new ParseError("Unexpected newline while consuming a string token.",o.representationStart,o.representationEnd,["4.3.5. Consume a string token","Unexpected newline"])),o.unreadCodePoint(),[e.BadString,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];if(i===t)return[e.String,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:r}];if(i!==W)r+=String.fromCodePoint(i);else{if(void 0===o.codePointSource[o.cursor])continue;if(isNewLine(o.codePointSource[o.cursor])){o.advanceCodePoint();continue}r+=String.fromCodePoint(consumeEscapedCodePoint(n,o))}}}function checkIfCodePointsMatchURLIdent(e){return!(3!==e.length||e[0]!==K&&e[0]!==M||e[1]!==$&&e[1]!==J||e[2]!==_&&e[2]!==j)}function consumeBadURL(e,n){for(;;){if(void 0===n.codePointSource[n.cursor])return;if(n.codePointSource[n.cursor]===b)return void n.advanceCodePoint();checkIfTwoCodePointsAreAValidEscape(n)?(n.advanceCodePoint(),consumeEscapedCodePoint(e,n)):n.advanceCodePoint()}}function consumeUrlToken(n,o){for(;isWhitespace(o.codePointSource[o.cursor]);)o.advanceCodePoint();let r="";for(;;){if(void 0===o.codePointSource[o.cursor])return n.onParseError(new ParseError("Unexpected EOF while consuming a url token.",o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected EOF"])),[e.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:r}];if(o.codePointSource[o.cursor]===b)return o.advanceCodePoint(),[e.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:r}];if(isWhitespace(o.codePointSource[o.cursor])){for(o.advanceCodePoint();isWhitespace(o.codePointSource[o.cursor]);)o.advanceCodePoint();return void 0===o.codePointSource[o.cursor]?(n.onParseError(new ParseError("Unexpected EOF while consuming a url token.",o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Consume as much whitespace as possible","Unexpected EOF"])),[e.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:r}]):o.codePointSource[o.cursor]===b?(o.advanceCodePoint(),[e.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:r}]):(consumeBadURL(n,o),[e.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0])}if(o.codePointSource[o.cursor]===y||o.codePointSource[o.cursor]===t||o.codePointSource[o.cursor]===k||((i=o.codePointSource[o.cursor])===U||i===p||A<=i&&i<=c||V<=i&&i<=E))return consumeBadURL(n,o),n.onParseError(new ParseError("Unexpected character while consuming a url token.",o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected U+0022 QUOTATION MARK (\"), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point"])),[e.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];if(o.codePointSource[o.cursor]===W){if(checkIfTwoCodePointsAreAValidEscape(o)){o.advanceCodePoint(),r+=String.fromCodePoint(consumeEscapedCodePoint(n,o));continue}return consumeBadURL(n,o),n.onParseError(new ParseError("Invalid escape sequence while consuming a url token.",o.representationStart,o.representationEnd,["4.3.6. Consume a url token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"])),[e.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0]}r+=String.fromCodePoint(o.codePointSource[o.cursor]),o.advanceCodePoint()}var i}function consumeIdentLikeToken(n,o){const r=consumeIdentSequence(n,o);if(o.codePointSource[o.cursor]!==k)return[e.Ident,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:String.fromCodePoint(...r)}];if(checkIfCodePointsMatchURLIdent(r)){o.advanceCodePoint();let i=0;for(;;){const n=isWhitespace(o.codePointSource[o.cursor]),c=isWhitespace(o.codePointSource[o.cursor+1]);if(n&&c){i+=1,o.advanceCodePoint(1);continue}const s=n?o.codePointSource[o.cursor+1]:o.codePointSource[o.cursor];if(s===y||s===t)return i>0&&o.unreadCodePoint(i),[e.Function,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:String.fromCodePoint(...r)}];break}return consumeUrlToken(n,o)}return o.advanceCodePoint(),[e.Function,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:String.fromCodePoint(...r)}]}function checkIfThreeCodePointsWouldStartAUnicodeRange(e){return!(e.codePointSource[e.cursor]!==K&&e.codePointSource[e.cursor]!==M||e.codePointSource[e.cursor+1]!==x||e.codePointSource[e.cursor+2]!==Q&&!isHexDigitCodePoint(e.codePointSource[e.cursor+2]))}function consumeUnicodeRangeToken(n,o){o.advanceCodePoint(2);const r=[],t=[];for(;void 0!==o.codePointSource[o.cursor]&&r.length<6&&isHexDigitCodePoint(o.codePointSource[o.cursor]);)r.push(o.codePointSource[o.cursor]),o.advanceCodePoint();for(;void 0!==o.codePointSource[o.cursor]&&r.length<6&&o.codePointSource[o.cursor]===Q;)0===t.length&&t.push(...r),r.push(G),t.push(X),o.advanceCodePoint();if(!t.length&&o.codePointSource[o.cursor]===h&&isHexDigitCodePoint(o.codePointSource[o.cursor+1]))for(o.advanceCodePoint();void 0!==o.codePointSource[o.cursor]&&t.length<6&&isHexDigitCodePoint(o.codePointSource[o.cursor]);)t.push(o.codePointSource[o.cursor]),o.advanceCodePoint();if(!t.length){const n=parseInt(String.fromCodePoint(...r),16);return[e.UnicodeRange,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{startOfRange:n,endOfRange:n}]}const i=parseInt(String.fromCodePoint(...r),16),c=parseInt(String.fromCodePoint(...t),16);return[e.UnicodeRange,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{startOfRange:i,endOfRange:c}]}function tokenize(e,n){const o=tokenizer(e,n),r=[];{for(;!o.endOfFile();){const e=o.nextToken();e&&r.push(e)}const e=o.nextToken();e&&r.push(e)}return r}function tokenizer(n,o){const r=n.css.valueOf(),i=n.unicodeRangesAllowed??!1,c=new Reader(r),p={onParseError:(null==o?void 0:o.onParseError)??(()=>{})};return{nextToken:function nextToken(){c.resetRepresentation();const n=c.codePointSource[c.cursor];if(void 0===n)return[e.EOF,"",-1,-1,void 0];if(n===B&&checkIfTwoCodePointsStartAComment(c))return consumeComment(p,c);if(i&&(n===K||n===M)&&checkIfThreeCodePointsWouldStartAUnicodeRange(c))return consumeUnicodeRangeToken(0,c);if(isIdentStartCodePoint(n))return consumeIdentLikeToken(p,c);if(isDigitCodePoint(n))return consumeNumericToken(p,c);switch(n){case d:return c.advanceCodePoint(),[e.Comma,",",c.representationStart,c.representationEnd,void 0];case u:return c.advanceCodePoint(),[e.Colon,":",c.representationStart,c.representationEnd,void 0];case H:return c.advanceCodePoint(),[e.Semicolon,";",c.representationStart,c.representationEnd,void 0];case k:return c.advanceCodePoint(),[e.OpenParen,"(",c.representationStart,c.representationEnd,void 0];case b:return c.advanceCodePoint(),[e.CloseParen,")",c.representationStart,c.representationEnd,void 0];case I:return c.advanceCodePoint(),[e.OpenSquare,"[",c.representationStart,c.representationEnd,void 0];case F:return c.advanceCodePoint(),[e.CloseSquare,"]",c.representationStart,c.representationEnd,void 0];case g:return c.advanceCodePoint(),[e.OpenCurly,"{",c.representationStart,c.representationEnd,void 0];case N:return c.advanceCodePoint(),[e.CloseCurly,"}",c.representationStart,c.representationEnd,void 0];case t:case y:return consumeStringToken(p,c);case R:return consumeHashToken(p,c);case x:case l:return checkIfThreeCodePointsWouldStartANumber(c)?consumeNumericToken(p,c):(c.advanceCodePoint(),[e.Delim,c.source[c.representationStart],c.representationStart,c.representationEnd,{value:c.source[c.representationStart]}]);case O:case s:case C:case a:case z:return consumeWhiteSpace(c);case h:return checkIfThreeCodePointsWouldStartANumber(c)?consumeNumericToken(p,c):checkIfThreeCodePointsWouldStartCDC(c)?(c.advanceCodePoint(3),[e.CDC,"--\x3e",c.representationStart,c.representationEnd,void 0]):checkIfThreeCodePointsWouldStartAnIdentSequence(0,c)?consumeIdentLikeToken(p,c):(c.advanceCodePoint(),[e.Delim,"-",c.representationStart,c.representationEnd,{value:"-"}]);case T:return checkIfFourCodePointsWouldStartCDO(c)?(c.advanceCodePoint(4),[e.CDO,"\x3c!--",c.representationStart,c.representationEnd,void 0]):(c.advanceCodePoint(),[e.Delim,"<",c.representationStart,c.representationEnd,{value:"<"}]);case P:if(c.advanceCodePoint(),checkIfThreeCodePointsWouldStartAnIdentSequence(0,c)){const n=consumeIdentSequence(p,c);return[e.AtKeyword,c.source.slice(c.representationStart,c.representationEnd+1),c.representationStart,c.representationEnd,{value:String.fromCodePoint(...n)}]}return[e.Delim,"@",c.representationStart,c.representationEnd,{value:"@"}];case W:return checkIfTwoCodePointsAreAValidEscape(c)?consumeIdentLikeToken(p,c):(c.advanceCodePoint(),p.onParseError(new ParseError('Invalid escape sequence after "\\"',c.representationStart,c.representationEnd,["4.3.1. Consume a token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"])),[e.Delim,"\\",c.representationStart,c.representationEnd,{value:"\\"}])}return c.advanceCodePoint(),[e.Delim,c.source[c.representationStart],c.representationStart,c.representationEnd,{value:c.source[c.representationStart]}]},endOfFile:function endOfFile(){return void 0===c.codePointSource[c.cursor]}}}function cloneTokens(e){return"undefined"!=typeof globalThis&&"structuredClone"in globalThis?structuredClone(e):JSON.parse(JSON.stringify(e))}function mutateIdent(e,n){let o="";const r=[];{let e="";for(e of n)r.push(e.codePointAt(0))}let t=0;r[0]===h&&r[1]===h?(o="--",t=2):r[0]===h&&r[1]?(o="-",t=2,isIdentStartCodePoint(r[1])?o+=n[1]:o+=`\\${r[1].toString(16)} `):isIdentStartCodePoint(r[0])?(o=n[0],t=1):(o=`\\${r[0].toString(16)} `,t=1);for(let e=t;e<r.length;e++)isIdentCodePoint(r[e])?o+=n[e]:o+=`\\${r[e].toString(16)} `;e[1]=o,e[4].value=n}export{n as NumberType,ParseError,Reader,e as TokenType,cloneTokens,isToken,mirrorVariant,mirrorVariantType,mutateIdent,stringify,tokenize,tokenizer}; diff --git a/node_modules/@csstools/css-tokenizer/dist/interfaces/code-point-reader.d.ts b/node_modules/@csstools/css-tokenizer/dist/interfaces/code-point-reader.d.ts new file mode 100644 index 00000000..a178ed8f --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/interfaces/code-point-reader.d.ts @@ -0,0 +1,12 @@ +export type CodePointReader = { + representationStart: number; + representationEnd: number; + cursor: number; + codePointSource: Array<number>; + representationIndices: Array<number>; + source: string; + advanceCodePoint(n?: number): void; + readCodePoint(n?: number): number | false; + unreadCodePoint(n?: number): void; + resetRepresentation(): void; +}; diff --git a/node_modules/@csstools/css-tokenizer/dist/interfaces/context.d.ts b/node_modules/@csstools/css-tokenizer/dist/interfaces/context.d.ts new file mode 100644 index 00000000..339bfe4e --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/interfaces/context.d.ts @@ -0,0 +1,4 @@ +import { ParseError } from './error'; +export type Context = { + onParseError: (error: ParseError) => void; +}; diff --git a/node_modules/@csstools/css-tokenizer/dist/interfaces/error.d.ts b/node_modules/@csstools/css-tokenizer/dist/interfaces/error.d.ts new file mode 100644 index 00000000..dc47e1d6 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/interfaces/error.d.ts @@ -0,0 +1,9 @@ +export declare class ParseError extends Error { + /** The index of the start character of the current token. */ + sourceStart: number; + /** The index of the end character of the current token. */ + sourceEnd: number; + /** The parser steps that preceded the error. */ + parserState: Array<string>; + constructor(message: string, sourceStart: number, sourceEnd: number, parserState: Array<string>); +} diff --git a/node_modules/@csstools/css-tokenizer/dist/interfaces/token.d.ts b/node_modules/@csstools/css-tokenizer/dist/interfaces/token.d.ts new file mode 100644 index 00000000..c4f2f4e3 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/interfaces/token.d.ts @@ -0,0 +1,137 @@ +export declare enum TokenType { + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#comment-diagram */ + Comment = "comment", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-at-keyword-token */ + AtKeyword = "at-keyword-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-bad-string-token */ + BadString = "bad-string-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-bad-url-token */ + BadURL = "bad-url-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-cdc-token */ + CDC = "CDC-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-cdo-token */ + CDO = "CDO-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-colon-token */ + Colon = "colon-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-comma-token */ + Comma = "comma-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-delim-token */ + Delim = "delim-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-dimension-token */ + Dimension = "dimension-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-eof-token */ + EOF = "EOF-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-function-token */ + Function = "function-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-hash-token */ + Hash = "hash-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-ident-token */ + Ident = "ident-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-percentage-token */ + Number = "number-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-percentage-token */ + Percentage = "percentage-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-semicolon-token */ + Semicolon = "semicolon-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-string-token */ + String = "string-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-url-token */ + URL = "url-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-whitespace-token */ + Whitespace = "whitespace-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#tokendef-open-paren */ + OpenParen = "(-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#tokendef-close-paren */ + CloseParen = ")-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#tokendef-open-square */ + OpenSquare = "[-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#tokendef-close-square */ + CloseSquare = "]-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#tokendef-open-curly */ + OpenCurly = "{-token", + /** https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#tokendef-close-curly */ + CloseCurly = "}-token", + /** https://drafts.csswg.org/css-syntax/#typedef-unicode-range-token */ + UnicodeRange = "unicode-range-token" +} +export declare enum NumberType { + Integer = "integer", + Number = "number" +} +export declare enum HashType { + Unrestricted = "unrestricted", + ID = "id" +} +export type TokenAtKeyword = Token<TokenType.AtKeyword, { + value: string; +}>; +export type TokenBadString = Token<TokenType.BadString, undefined>; +export type TokenBadURL = Token<TokenType.BadURL, undefined>; +export type TokenCDC = Token<TokenType.CDC, undefined>; +export type TokenCDO = Token<TokenType.CDO, undefined>; +export type TokenColon = Token<TokenType.Colon, undefined>; +export type TokenComma = Token<TokenType.Comma, undefined>; +export type TokenComment = Token<TokenType.Comment, undefined>; +export type TokenDelim = Token<TokenType.Delim, { + value: string; +}>; +export type TokenDimension = Token<TokenType.Dimension, { + value: number; + signCharacter?: '+' | '-'; + unit: string; + type: NumberType; +}>; +export type TokenEOF = Token<TokenType.EOF, undefined>; +export type TokenFunction = Token<TokenType.Function, { + value: string; +}>; +export type TokenHash = Token<TokenType.Hash, { + value: string; + type: HashType; +}>; +export type TokenIdent = Token<TokenType.Ident, { + value: string; +}>; +export type TokenNumber = Token<TokenType.Number, { + value: number; + signCharacter?: '+' | '-'; + type: NumberType; +}>; +export type TokenPercentage = Token<TokenType.Percentage, { + value: number; + signCharacter?: '+' | '-'; +}>; +export type TokenSemicolon = Token<TokenType.Semicolon, undefined>; +export type TokenString = Token<TokenType.String, { + value: string; +}>; +export type TokenURL = Token<TokenType.URL, { + value: string; +}>; +export type TokenWhitespace = Token<TokenType.Whitespace, undefined>; +export type TokenOpenParen = Token<TokenType.OpenParen, undefined>; +export type TokenCloseParen = Token<TokenType.CloseParen, undefined>; +export type TokenOpenSquare = Token<TokenType.OpenSquare, undefined>; +export type TokenCloseSquare = Token<TokenType.CloseSquare, undefined>; +export type TokenOpenCurly = Token<TokenType.OpenCurly, undefined>; +export type TokenCloseCurly = Token<TokenType.CloseCurly, undefined>; +export type TokenUnicodeRange = Token<TokenType.UnicodeRange, { + startOfRange: number; + endOfRange: number; +}>; +export type CSSToken = TokenAtKeyword | TokenBadString | TokenBadURL | TokenCDC | TokenCDO | TokenColon | TokenComma | TokenComment | TokenDelim | TokenDimension | TokenEOF | TokenFunction | TokenHash | TokenIdent | TokenNumber | TokenPercentage | TokenSemicolon | TokenString | TokenURL | TokenWhitespace | TokenOpenParen | TokenCloseParen | TokenOpenSquare | TokenCloseSquare | TokenOpenCurly | TokenCloseCurly | TokenUnicodeRange; +export type Token<T extends TokenType, U> = [ + /** The type of token */ + T, + /** The token representation */ + string, + /** Start position of representation */ + number, + /** End position of representation */ + number, + /** Extra data */ + U +]; +export declare function mirrorVariantType(type: TokenType): TokenType | null; +export declare function mirrorVariant(token: CSSToken): CSSToken | null; +export declare function isToken(x: any): x is CSSToken; diff --git a/node_modules/@csstools/css-tokenizer/dist/reader.d.ts b/node_modules/@csstools/css-tokenizer/dist/reader.d.ts new file mode 100644 index 00000000..fc798c58 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/reader.d.ts @@ -0,0 +1,15 @@ +import { CodePointReader } from './interfaces/code-point-reader'; +export declare class Reader implements CodePointReader { + cursor: number; + source: string; + codePointSource: Array<number>; + representationIndices: Array<number>; + length: number; + representationStart: number; + representationEnd: number; + constructor(source: string); + advanceCodePoint(n?: number): void; + readCodePoint(n?: number): number | false; + unreadCodePoint(n?: number): void; + resetRepresentation(): void; +} diff --git a/node_modules/@csstools/css-tokenizer/dist/stringify.d.ts b/node_modules/@csstools/css-tokenizer/dist/stringify.d.ts new file mode 100644 index 00000000..574d2043 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/stringify.d.ts @@ -0,0 +1,2 @@ +import type { CSSToken } from './interfaces/token'; +export declare function stringify(...tokens: Array<CSSToken>): string; diff --git a/node_modules/@csstools/css-tokenizer/dist/tokenizer.d.ts b/node_modules/@csstools/css-tokenizer/dist/tokenizer.d.ts new file mode 100644 index 00000000..318a16bb --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/tokenizer.d.ts @@ -0,0 +1,21 @@ +import { CSSToken } from './interfaces/token'; +import { ParseError } from './interfaces/error'; +interface Stringer { + valueOf(): string; +} +export declare function tokenize(input: { + css: Stringer; + unicodeRangesAllowed?: boolean; +}, options?: { + onParseError?: (error: ParseError) => void; +}): Array<CSSToken>; +export declare function tokenizer(input: { + css: Stringer; + unicodeRangesAllowed?: boolean; +}, options?: { + onParseError?: (error: ParseError) => void; +}): { + nextToken: () => CSSToken | undefined; + endOfFile: () => boolean; +}; +export {}; diff --git a/node_modules/@csstools/css-tokenizer/dist/util/clone-tokens.d.ts b/node_modules/@csstools/css-tokenizer/dist/util/clone-tokens.d.ts new file mode 100644 index 00000000..1db05d03 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/util/clone-tokens.d.ts @@ -0,0 +1,2 @@ +import { CSSToken } from '../interfaces/token'; +export declare function cloneTokens(tokens: Array<CSSToken>): Array<CSSToken>; diff --git a/node_modules/@csstools/css-tokenizer/dist/util/mutations.d.ts b/node_modules/@csstools/css-tokenizer/dist/util/mutations.d.ts new file mode 100644 index 00000000..37f23cd2 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/dist/util/mutations.d.ts @@ -0,0 +1,2 @@ +import { TokenIdent } from '../interfaces/token'; +export declare function mutateIdent(ident: TokenIdent, newValue: string): void; diff --git a/node_modules/@csstools/css-tokenizer/package.json b/node_modules/@csstools/css-tokenizer/package.json new file mode 100644 index 00000000..4fcbeb61 --- /dev/null +++ b/node_modules/@csstools/css-tokenizer/package.json @@ -0,0 +1,73 @@ +{ + "name": "@csstools/css-tokenizer", + "description": "Tokenize CSS", + "version": "2.2.1", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "devDependencies": { + "@rmenke/css-tokenizer-tests": "^1.1.1", + "postcss-parser-tests": "^8.8.0" + }, + "scripts": { + "benchmark": "node ./test/benchmark.mjs", + "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-tokenizer#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "packages/css-tokenizer" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "css", + "tokenizer" + ], + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/media-query-list-parser/CHANGELOG.md b/node_modules/@csstools/media-query-list-parser/CHANGELOG.md new file mode 100644 index 00000000..d8f8b70f --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/CHANGELOG.md @@ -0,0 +1,84 @@ +# Changes to Media Query List Parser + +### 2.1.5 + +_September 24, 2023_ + +- 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) + +### 2.1.4 + +_August 5, 2023_ + +- Do not allow keywords as media feature values in range context queries. + +### 2.1.3 + +_July 24, 2023_ + +- 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) + +### 2.1.2 + +_July 3, 2023_ + +- 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) + +### 2.1.1 + +_June 21, 2023_ + +- Fix parsing of `(width == 100px)`. This was erroneously parsed as a range query and will now instead be a general enclosed node. + +### 2.1.0 + +_June 1, 2023_ + +- Fix `walk` for `MediaFeatureValue` with complex component values. +- Add `state` to `walk` methods. + +This makes it possible pass down information from a parent structure to children. +e.g. you can set `entry.state.inInPrintQuery = true` for `print and (min-width: 30cm)`. + +### 2.0.4 + +_April 10, 2023_ + +- Updated `@csstools/css-tokenizer` to `2.1.1` (patch) +- Updated `@csstools/css-parser-algorithms` to `2.1.1` (patch) + +### 2.0.3 + +_April 10, 2023_ + +- Add support for `env()` functions as values in media queries. +- Improve the detection of math function as values in media queries. + +### 2.0.2 + +_March 25, 2023_ + +- Improve case insensitive string matching. + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 19, 2023_ + +- Refactor `MediaFeatureBoolean` so that it follows the same structure as `MediaFeaturePlain` (breaking) +- Change the `ParseError` interface, this is now a subclass of `Error` (breaking) +- Add `getName` and `getNameToken` to all nodes that have a feature name. +- Add `@custom-media` parsing. + +### 1.0.0 + +_November 14, 2022_ + +- Initial version diff --git a/node_modules/@csstools/media-query-list-parser/LICENSE.md b/node_modules/@csstools/media-query-list-parser/LICENSE.md new file mode 100644 index 00000000..af5411fa --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/LICENSE.md @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright 2022 Romain Menke, Antonio Laguna <antonio@laguna.es> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/@csstools/media-query-list-parser/README.md b/node_modules/@csstools/media-query-list-parser/README.md new file mode 100644 index 00000000..d72dc7dd --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/README.md @@ -0,0 +1,61 @@ +# Media Query List Parser + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/media-query-list-parser.svg" height="20">][npm-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +Implemented from : https://www.w3.org/TR/mediaqueries-5/ + +## Usage + +Add [Media Query List Parser] to your project: + +```bash +npm install @csstools/media-query-list-parser @csstools/css-parser-algorithms @csstools/css-tokenizer --save-dev +``` + +[Media Query List Parser] depends on our CSS tokenizer and parser algorithms. +It must be used together with `@csstools/css-tokenizer` and `@csstools/css-parser-algorithms`. + +```ts +import { parse } from '@csstools/media-query-list-parser'; + +export function parseCustomMedia() { + const mediaQueryList = parse('screen and (min-width: 300px), (50px < height < 30vw)'); + + mediaQueryList.forEach((mediaQuery) => { + mediaQuery.walk((entry, index) => { + // Index of the current Node in `parent`. + console.log(index); + // Type of `parent`. + console.log(entry.parent.type); + + // Type of `node` + { + // Sometimes nodes can be arrays. + if (Array.isArray(entry.node)) { + entry.node.forEach((item) => { + console.log(item.type); + }); + } + + if ('type' in entry.node) { + console.log(entry.node.type); + } + } + + // stringified version of the current node. + console.log(entry.node.toString()); + + // Return `false` to stop the walker. + return false; + }); + }); +} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/media-query-list-parser + +[Media Query List Parser]: https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser diff --git a/node_modules/@csstools/media-query-list-parser/dist/index.cjs b/node_modules/@csstools/media-query-list-parser/dist/index.cjs new file mode 100644 index 00000000..aabcfbcc --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e,t=require("@csstools/css-parser-algorithms"),i=require("@csstools/css-tokenizer");exports.NodeType=void 0,(e=exports.NodeType||(exports.NodeType={})).CustomMedia="custom-media",e.GeneralEnclosed="general-enclosed",e.MediaAnd="media-and",e.MediaCondition="media-condition",e.MediaConditionListWithAnd="media-condition-list-and",e.MediaConditionListWithOr="media-condition-list-or",e.MediaFeature="media-feature",e.MediaFeatureBoolean="mf-boolean",e.MediaFeatureName="mf-name",e.MediaFeaturePlain="mf-plain",e.MediaFeatureRangeNameValue="mf-range-name-value",e.MediaFeatureRangeValueName="mf-range-value-name",e.MediaFeatureRangeValueNameValue="mf-range-value-name-value",e.MediaFeatureValue="mf-value",e.MediaInParens="media-in-parens",e.MediaNot="media-not",e.MediaOr="media-or",e.MediaQueryWithType="media-query-with-type",e.MediaQueryWithoutType="media-query-without-type",e.MediaQueryInvalid="media-query-invalid";const a=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(a,(e=>String.fromCharCode(e.charCodeAt(0)+32)))}class MediaCondition{type=exports.NodeType.MediaCondition;media;constructor(e){this.media=e}tokens(){return this.media.tokens()}toString(){return this.media.toString()}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&this.media.walk(e,i)}toJSON(){return{type:this.type,media:this.media.toJSON()}}isMediaCondition(){return MediaCondition.isMediaCondition(this)}static isMediaCondition(e){return!!e&&(e instanceof MediaCondition&&e.type===exports.NodeType.MediaCondition)}}class MediaInParens{type=exports.NodeType.MediaInParens;media;before;after;constructor(e,t=[],i=[]){this.media=e,this.before=t,this.after=i}tokens(){return[...this.before,...this.media.tokens(),...this.after]}toString(){return i.stringify(...this.before)+this.media.toString()+i.stringify(...this.after)}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&("walk"in this.media?this.media.walk(e,i):void 0)}toJSON(){return{type:this.type,media:this.media.toJSON(),before:this.before,after:this.after}}isMediaInParens(){return MediaInParens.isMediaInParens(this)}static isMediaInParens(e){return!!e&&(e instanceof MediaInParens&&e.type===exports.NodeType.MediaInParens)}}class MediaQueryWithType{type=exports.NodeType.MediaQueryWithType;modifier;mediaType;and=void 0;media=void 0;constructor(e,t,i,a){this.modifier=e,this.mediaType=t,i&&a&&(this.and=i,this.media=a)}getModifier(){if(!this.modifier.length)return"";for(let e=0;e<this.modifier.length;e++){const t=this.modifier[e];if(t[0]===i.TokenType.Ident)return t[4].value}return""}negateQuery(){const e=new MediaQueryWithType([...this.modifier],[...this.mediaType],this.and,this.media);if(0===e.modifier.length)return e.modifier=[[i.TokenType.Ident,"not",-1,-1,{value:"not"}],[i.TokenType.Whitespace," ",-1,-1,void 0]],e;for(let t=0;t<e.modifier.length;t++){const a=e.modifier[t];if(a[0]===i.TokenType.Ident&&"not"===toLowerCaseAZ(a[4].value)){e.modifier.splice(t,1);break}if(a[0]===i.TokenType.Ident&&"only"===toLowerCaseAZ(a[4].value)){a[1]="not",a[4].value="not";break}}return e}getMediaType(){if(!this.mediaType.length)return"";for(let e=0;e<this.mediaType.length;e++){const t=this.mediaType[e];if(t[0]===i.TokenType.Ident)return t[4].value}return""}tokens(){return this.and&&this.media?[...this.modifier,...this.mediaType,...this.and,...this.media.tokens()]:[...this.modifier,...this.mediaType]}toString(){return this.and&&this.media?i.stringify(...this.modifier)+i.stringify(...this.mediaType)+i.stringify(...this.and)+this.media.toString():i.stringify(...this.modifier)+i.stringify(...this.mediaType)}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;if(t&&(i={...t}),this.media)return!1!==e({node:this.media,parent:this,state:i},"media")&&this.media.walk(e,i)}toJSON(){return{type:this.type,string:this.toString(),modifier:this.modifier,mediaType:this.mediaType,and:this.and,media:this.media}}isMediaQueryWithType(){return MediaQueryWithType.isMediaQueryWithType(this)}static isMediaQueryWithType(e){return!!e&&(e instanceof MediaQueryWithType&&e.type===exports.NodeType.MediaQueryWithType)}}class MediaQueryWithoutType{type=exports.NodeType.MediaQueryWithoutType;media;constructor(e){this.media=e}negateQuery(){let e=this.media;if(e.media.type===exports.NodeType.MediaNot)return new MediaQueryWithoutType(new MediaCondition(e.media.media));e.media.type===exports.NodeType.MediaConditionListWithOr&&(e=new MediaCondition(new MediaInParens(e,[[i.TokenType.Whitespace," ",0,0,void 0],[i.TokenType.OpenParen,"(",0,0,void 0]],[[i.TokenType.CloseParen,")",0,0,void 0]])));return new MediaQueryWithType([[i.TokenType.Ident,"not",0,0,{value:"not"}],[i.TokenType.Whitespace," ",0,0,void 0]],[[i.TokenType.Ident,"all",0,0,{value:"all"}],[i.TokenType.Whitespace," ",0,0,void 0]],[[i.TokenType.Ident,"and",0,0,{value:"and"}]],e)}tokens(){return this.media.tokens()}toString(){return this.media.toString()}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&this.media.walk(e,i)}toJSON(){return{type:this.type,string:this.toString(),media:this.media}}isMediaQueryWithoutType(){return MediaQueryWithoutType.isMediaQueryWithoutType(this)}static isMediaQueryWithoutType(e){return!!e&&(e instanceof MediaQueryWithoutType&&e.type===exports.NodeType.MediaQueryWithoutType)}}class MediaQueryInvalid{type=exports.NodeType.MediaQueryInvalid;media;constructor(e){this.media=e}negateQuery(){return new MediaQueryInvalid(this.media)}tokens(){return this.media.flatMap((e=>e.tokens()))}toString(){return this.media.map((e=>e.toString())).join("")}walk(e,t){let i=!1;if(this.media.forEach(((a,r)=>{if(i)return;let n;t&&(n={...t}),!1!==e({node:a,parent:this,state:n},r)?"walk"in a&&!1===a.walk(e,n)&&(i=!0):i=!0})),i)return!1}toJSON(){return{type:this.type,string:this.toString(),media:this.media}}isMediaQueryInvalid(){return MediaQueryInvalid.isMediaQueryInvalid(this)}static isMediaQueryInvalid(e){return!!e&&(e instanceof MediaQueryInvalid&&e.type===exports.NodeType.MediaQueryInvalid)}}class GeneralEnclosed{type=exports.NodeType.GeneralEnclosed;value;constructor(e){this.value=e}tokens(){return this.value.tokens()}toString(){return this.value.toString()}indexOf(e){return e===this.value?"value":-1}at(e){if("value"===e)return this.value}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.value,parent:this,state:i},"value")&&("walk"in this.value?this.value.walk(e,i):void 0)}toJSON(){return{type:this.type,tokens:this.tokens()}}isGeneralEnclosed(){return GeneralEnclosed.isGeneralEnclosed(this)}static isGeneralEnclosed(e){return!!e&&(e instanceof GeneralEnclosed&&e.type===exports.NodeType.GeneralEnclosed)}}class MediaAnd{type=exports.NodeType.MediaAnd;modifier;media;constructor(e,t){this.modifier=e,this.media=t}tokens(){return[...this.modifier,...this.media.tokens()]}toString(){return i.stringify(...this.modifier)+this.media.toString()}indexOf(e){return e===this.media?"media":-1}at(e){return"media"===e?this.media:null}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&this.media.walk(e,i)}toJSON(){return{type:this.type,modifier:this.modifier,media:this.media.toJSON()}}isMediaAnd(){return MediaAnd.isMediaAnd(this)}static isMediaAnd(e){return!!e&&(e instanceof MediaAnd&&e.type===exports.NodeType.MediaAnd)}}class MediaConditionListWithAnd{type=exports.NodeType.MediaConditionListWithAnd;leading;list;before;after;constructor(e,t,i=[],a=[]){this.leading=e,this.list=t,this.before=i,this.after=a}tokens(){return[...this.before,...this.leading.tokens(),...this.list.flatMap((e=>e.tokens())),...this.after]}toString(){return i.stringify(...this.before)+this.leading.toString()+this.list.map((e=>e.toString())).join("")+i.stringify(...this.after)}indexOf(e){return e===this.leading?"leading":"media-and"===e.type?this.list.indexOf(e):-1}at(e){return"leading"===e?this.leading:"number"==typeof e?(e<0&&(e=this.list.length+e),this.list[e]):void 0}walk(e,t){let i;if(t&&(i={...t}),!1===e({node:this.leading,parent:this,state:i},"leading"))return!1;if("walk"in this.leading&&!1===this.leading.walk(e,i))return!1;let a=!1;return this.list.forEach(((r,n)=>{a||(t&&(i={...t}),!1!==e({node:r,parent:this,state:i},n)?"walk"in r&&!1===r.walk(e,i)&&(a=!0):a=!0)})),!a&&void 0}toJSON(){return{type:this.type,leading:this.leading.toJSON(),list:this.list.map((e=>e.toJSON())),before:this.before,after:this.after}}isMediaConditionListWithAnd(){return MediaConditionListWithAnd.isMediaConditionListWithAnd(this)}static isMediaConditionListWithAnd(e){return!!e&&(e instanceof MediaConditionListWithAnd&&e.type===exports.NodeType.MediaConditionListWithAnd)}}class MediaConditionListWithOr{type=exports.NodeType.MediaConditionListWithOr;leading;list;before;after;constructor(e,t,i=[],a=[]){this.leading=e,this.list=t,this.before=i,this.after=a}tokens(){return[...this.before,...this.leading.tokens(),...this.list.flatMap((e=>e.tokens())),...this.after]}toString(){return i.stringify(...this.before)+this.leading.toString()+this.list.map((e=>e.toString())).join("")+i.stringify(...this.after)}indexOf(e){return e===this.leading?"leading":"media-or"===e.type?this.list.indexOf(e):-1}at(e){return"leading"===e?this.leading:"number"==typeof e?(e<0&&(e=this.list.length+e),this.list[e]):void 0}walk(e,t){let i;if(t&&(i={...t}),!1===e({node:this.leading,parent:this,state:i},"leading"))return!1;if("walk"in this.leading&&!1===this.leading.walk(e,i))return!1;let a=!1;return this.list.forEach(((r,n)=>{a||(t&&(i={...t}),!1!==e({node:r,parent:this,state:i},n)?"walk"in r&&!1===r.walk(e,i)&&(a=!0):a=!0)})),!a&&void 0}toJSON(){return{type:this.type,leading:this.leading.toJSON(),list:this.list.map((e=>e.toJSON())),before:this.before,after:this.after}}isMediaConditionListWithOr(){return MediaConditionListWithOr.isMediaConditionListWithOr(this)}static isMediaConditionListWithOr(e){return!!e&&(e instanceof MediaConditionListWithOr&&e.type===exports.NodeType.MediaConditionListWithOr)}}function isNumber(e){return!!(e.type===t.ComponentValueType.Token&&e.value[0]===i.TokenType.Number||e.type===t.ComponentValueType.Function&&r.has(toLowerCaseAZ(e.name[4].value)))}const r=new Set(["abs","acos","asin","atan","atan2","calc","clamp","cos","exp","hypot","log","max","min","mod","pow","rem","round","sign","sin","sqrt","tan"]);function isDimension(e){return e.type===t.ComponentValueType.Token&&e.value[0]===i.TokenType.Dimension}function isIdent(e){return e.type===t.ComponentValueType.Token&&e.value[0]===i.TokenType.Ident}function isEnvironmentVariable(e){return e.type===t.ComponentValueType.Function&&"env"===toLowerCaseAZ(e.name[4].value)}class MediaFeatureName{type=exports.NodeType.MediaFeatureName;name;before;after;constructor(e,t=[],i=[]){this.name=e,this.before=t,this.after=i}getName(){return this.name.value[4].value}getNameToken(){return this.name.value}tokens(){return[...this.before,...this.name.tokens(),...this.after]}toString(){return i.stringify(...this.before)+this.name.toString()+i.stringify(...this.after)}indexOf(e){return e===this.name?"name":-1}at(e){if("name"===e)return this.name}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens()}}isMediaFeatureName(){return MediaFeatureName.isMediaFeatureName(this)}static isMediaFeatureName(e){return!!e&&(e instanceof MediaFeatureName&&e.type===exports.NodeType.MediaFeatureName)}}function parseMediaFeatureName(e){let i=-1;for(let a=0;a<e.length;a++){const r=e[a];if(r.type!==t.ComponentValueType.Whitespace&&r.type!==t.ComponentValueType.Comment){if(!isIdent(r))return!1;if(-1!==i)return!1;i=a}}return-1!==i&&new MediaFeatureName(e[i],e.slice(0,i).flatMap((e=>e.tokens())),e.slice(i+1).flatMap((e=>e.tokens())))}class MediaFeatureBoolean{type=exports.NodeType.MediaFeatureBoolean;name;constructor(e){this.name=e}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return this.name.tokens()}toString(){return this.name.toString()}indexOf(e){return e===this.name?"name":-1}at(e){if("name"===e)return this.name}toJSON(){return{type:this.type,name:this.name.toJSON(),tokens:this.tokens()}}isMediaFeatureBoolean(){return MediaFeatureBoolean.isMediaFeatureBoolean(this)}static isMediaFeatureBoolean(e){return!!e&&(e instanceof MediaFeatureBoolean&&e.type===exports.NodeType.MediaFeatureBoolean)}}function parseMediaFeatureBoolean(e){const t=parseMediaFeatureName(e);return!1===t?t:new MediaFeatureBoolean(t)}class MediaFeatureValue{type=exports.NodeType.MediaFeatureValue;value;before;after;constructor(e,t=[],i=[]){Array.isArray(e)&&1===e.length?this.value=e[0]:this.value=e,this.before=t,this.after=i}tokens(){return Array.isArray(this.value)?[...this.before,...this.value.flatMap((e=>e.tokens())),...this.after]:[...this.before,...this.value.tokens(),...this.after]}toString(){return Array.isArray(this.value)?i.stringify(...this.before)+this.value.map((e=>e.toString())).join("")+i.stringify(...this.after):i.stringify(...this.before)+this.value.toString()+i.stringify(...this.after)}indexOf(e){return e===this.value?"value":-1}at(e){return"value"===e?this.value:Array.isArray(this.value)&&"number"==typeof e?(e<0&&(e=this.value.length+e),this.value[e]):void 0}walk(e,t){if(Array.isArray(this.value)){let i=!1;if(this.value.forEach(((a,r)=>{if(i)return;let n;t&&(n={...t}),!1!==e({node:a,parent:this,state:n},r)?"walk"in a&&!1===a.walk(e,n)&&(i=!0):i=!0})),i)return!1}else{let i;if(t&&(i={...t}),!1===e({node:this.value,parent:this,state:i},"value"))return!1;if("walk"in this.value)return this.value.walk(e,i)}}toJSON(){return Array.isArray(this.value)?{type:this.type,value:this.value.map((e=>e.toJSON())),tokens:this.tokens()}:{type:this.type,value:this.value.toJSON(),tokens:this.tokens()}}isMediaFeatureValue(){return MediaFeatureValue.isMediaFeatureValue(this)}static isMediaFeatureValue(e){return!!e&&(e instanceof MediaFeatureValue&&e.type===exports.NodeType.MediaFeatureValue)}}function parseMediaFeatureValue(e,i=!1){let a=-1,r=-1;for(let n=0;n<e.length;n++){const s=e[n];if(s.type!==t.ComponentValueType.Whitespace&&s.type!==t.ComponentValueType.Comment){if(-1!==a)return!1;if(isNumber(s)){const t=matchesRatioExactly(e.slice(n));if(-1!==t){a=t[0]+n,r=t[1]+n,n+=t[1]-t[0];continue}a=n,r=n}else if(isEnvironmentVariable(s))a=n,r=n;else if(isDimension(s))a=n,r=n;else{if(i||!isIdent(s))return!1;a=n,r=n}}}return-1!==a&&new MediaFeatureValue(e.slice(a,r+1),e.slice(0,a).flatMap((e=>e.tokens())),e.slice(r+1).flatMap((e=>e.tokens())))}function matchesRatioExactly(e){let t=-1,i=-1;const a=matchesRatio(e);if(-1===a)return-1;t=a[0],i=a[1];for(let t=i+1;t<e.length;t++){const i=e[t];if("whitespace"!==i.type&&"comment"!==i.type)return-1}return[t,i]}function matchesRatio(e){let t=-1,a=-1;for(let r=0;r<e.length;r++){const n=e[r];if("whitespace"!==n.type&&"comment"!==n.type){if("token"===n.type){const e=n.value;if(e[0]===i.TokenType.Delim&&"/"===e[4].value){if(-1===t)return-1;if(-1!==a)return-1;a=r;continue}}if(!isNumber(n))return-1;if(-1!==a)return[t,r];if(-1!==t)return-1;t=r}}return-1}class MediaFeaturePlain{type=exports.NodeType.MediaFeaturePlain;name;colon;value;constructor(e,t,i){this.name=e,this.colon=t,this.value=i}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return[...this.name.tokens(),this.colon,...this.value.tokens()]}toString(){return this.name.toString()+i.stringify(this.colon)+this.value.toString()}indexOf(e){return e===this.name?"name":e===this.value?"value":-1}at(e){return"name"===e?this.name:"value"===e?this.value:void 0}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.value,parent:this,state:i},"value")&&this.value.walk(e,i)}toJSON(){return{type:this.type,name:this.name.toJSON(),value:this.value.toJSON(),tokens:this.tokens()}}isMediaFeaturePlain(){return MediaFeaturePlain.isMediaFeaturePlain(this)}static isMediaFeaturePlain(e){return!!e&&(e instanceof MediaFeaturePlain&&e.type===exports.NodeType.MediaFeaturePlain)}}function parseMediaFeaturePlain(e){let a=[],r=[],n=null;for(let s=0;s<e.length;s++){const o=e[s];if(o.type===t.ComponentValueType.Token){const t=o.value;if(t[0]===i.TokenType.Colon){a=e.slice(0,s),r=e.slice(s+1),n=t;break}}}if(!a.length||!r.length||!n)return!1;const s=parseMediaFeatureName(a);if(!1===s)return!1;const o=parseMediaFeatureValue(r);return!1!==o&&new MediaFeaturePlain(s,n,o)}var n,s,o,u;function matchesComparison(e){let a=-1;for(let r=0;r<e.length;r++){const n=e[r];if(n.type===t.ComponentValueType.Token){const e=n.value;if(e[0]===i.TokenType.Delim){if(e[4].value===exports.MediaFeatureEQ.EQ)return-1!==a?[a,r]:[r,r];if(e[4].value===exports.MediaFeatureLT.LT){a=r;continue}if(e[4].value===exports.MediaFeatureGT.GT){a=r;continue}}}break}return-1!==a&&[a,a]}function comparisonFromTokens(e){if(0===e.length||e.length>2)return!1;if(e[0][0]!==i.TokenType.Delim)return!1;if(1===e.length)switch(e[0][4].value){case exports.MediaFeatureEQ.EQ:return exports.MediaFeatureEQ.EQ;case exports.MediaFeatureLT.LT:return exports.MediaFeatureLT.LT;case exports.MediaFeatureGT.GT:return exports.MediaFeatureGT.GT;default:return!1}if(e[1][0]!==i.TokenType.Delim)return!1;if(e[1][4].value!==exports.MediaFeatureEQ.EQ)return!1;switch(e[0][4].value){case exports.MediaFeatureLT.LT:return exports.MediaFeatureLT.LT_OR_EQ;case exports.MediaFeatureGT.GT:return exports.MediaFeatureGT.GT_OR_EQ;default:return!1}}exports.MediaFeatureLT=void 0,(n=exports.MediaFeatureLT||(exports.MediaFeatureLT={})).LT="<",n.LT_OR_EQ="<=",exports.MediaFeatureGT=void 0,(s=exports.MediaFeatureGT||(exports.MediaFeatureGT={})).GT=">",s.GT_OR_EQ=">=",exports.MediaFeatureEQ=void 0,(exports.MediaFeatureEQ||(exports.MediaFeatureEQ={})).EQ="=";class MediaFeatureRangeNameValue{type=exports.NodeType.MediaFeatureRangeNameValue;name;operator;value;constructor(e,t,i){this.name=e,this.operator=t,this.value=i}operatorKind(){return comparisonFromTokens(this.operator)}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return[...this.name.tokens(),...this.operator,...this.value.tokens()]}toString(){return this.name.toString()+i.stringify(...this.operator)+this.value.toString()}indexOf(e){return e===this.name?"name":e===this.value?"value":-1}at(e){return"name"===e?this.name:"value"===e?this.value:void 0}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.value,parent:this,state:i},"value")&&("walk"in this.value?this.value.walk(e,i):void 0)}toJSON(){return{type:this.type,name:this.name.toJSON(),value:this.value.toJSON(),tokens:this.tokens()}}isMediaFeatureRangeNameValue(){return MediaFeatureRangeNameValue.isMediaFeatureRangeNameValue(this)}static isMediaFeatureRangeNameValue(e){return!!e&&(e instanceof MediaFeatureRangeNameValue&&e.type===exports.NodeType.MediaFeatureRangeNameValue)}}class MediaFeatureRangeValueName{type=exports.NodeType.MediaFeatureRangeValueName;name;operator;value;constructor(e,t,i){this.name=e,this.operator=t,this.value=i}operatorKind(){return comparisonFromTokens(this.operator)}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return[...this.value.tokens(),...this.operator,...this.name.tokens()]}toString(){return this.value.toString()+i.stringify(...this.operator)+this.name.toString()}indexOf(e){return e===this.name?"name":e===this.value?"value":-1}at(e){return"name"===e?this.name:"value"===e?this.value:void 0}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.value,parent:this,state:i},"value")&&("walk"in this.value?this.value.walk(e,i):void 0)}toJSON(){return{type:this.type,name:this.name.toJSON(),value:this.value.toJSON(),tokens:this.tokens()}}isMediaFeatureRangeValueName(){return MediaFeatureRangeValueName.isMediaFeatureRangeValueName(this)}static isMediaFeatureRangeValueName(e){return!!e&&(e instanceof MediaFeatureRangeValueName&&e.type===exports.NodeType.MediaFeatureRangeValueName)}}class MediaFeatureRangeValueNameValue{type=exports.NodeType.MediaFeatureRangeValueNameValue;name;valueOne;valueOneOperator;valueTwo;valueTwoOperator;constructor(e,t,i,a,r){this.name=e,this.valueOne=t,this.valueOneOperator=i,this.valueTwo=a,this.valueTwoOperator=r}valueOneOperatorKind(){return comparisonFromTokens(this.valueOneOperator)}valueTwoOperatorKind(){return comparisonFromTokens(this.valueTwoOperator)}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return[...this.valueOne.tokens(),...this.valueOneOperator,...this.name.tokens(),...this.valueTwoOperator,...this.valueTwo.tokens()]}toString(){return this.valueOne.toString()+i.stringify(...this.valueOneOperator)+this.name.toString()+i.stringify(...this.valueTwoOperator)+this.valueTwo.toString()}indexOf(e){return e===this.name?"name":e===this.valueOne?"valueOne":e===this.valueTwo?"valueTwo":-1}at(e){return"name"===e?this.name:"valueOne"===e?this.valueOne:"valueTwo"===e?this.valueTwo:void 0}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.valueOne,parent:this,state:i},"valueOne")&&((!("walk"in this.valueOne)||!1!==this.valueOne.walk(e,i))&&(t&&(i={...t}),!1!==e({node:this.valueTwo,parent:this,state:i},"valueTwo")&&((!("walk"in this.valueTwo)||!1!==this.valueTwo.walk(e,i))&&void 0)))}toJSON(){return{type:this.type,name:this.name.toJSON(),valueOne:this.valueOne.toJSON(),valueTwo:this.valueTwo.toJSON(),tokens:this.tokens()}}isMediaFeatureRangeValueNameValue(){return MediaFeatureRangeValueNameValue.isMediaFeatureRangeValueNameValue(this)}static isMediaFeatureRangeValueNameValue(e){return!!e&&(e instanceof MediaFeatureRangeValueNameValue&&e.type===exports.NodeType.MediaFeatureRangeValueNameValue)}}function parseMediaFeatureRange(e){let a=!1,r=!1;for(let n=0;n<e.length;n++){const s=e[n];if(s.type===t.ComponentValueType.Token){if(s.value[0]===i.TokenType.Delim){const t=matchesComparison(e.slice(n));if(!1!==t){if(!1!==a){r=[t[0]+n,t[1]+n];break}a=[t[0]+n,t[1]+n],n+=t[1]}}}}if(!1===a)return!1;const n=[e[a[0]].value];if(a[0]!==a[1]&&n.push(e[a[1]].value),!1===r){const t=e.slice(0,a[0]),i=e.slice(a[1]+1),r=parseMediaFeatureName(t);if(r){const e=parseMediaFeatureValue(i,!0);return!!e&&new MediaFeatureRangeNameValue(r,n,e)}const s=parseMediaFeatureName(i);if(s){const e=parseMediaFeatureValue(t,!0);return!!e&&new MediaFeatureRangeValueName(s,n,e)}return!1}const s=[e[r[0]].value];r[0]!==r[1]&&s.push(e[r[1]].value);const o=e.slice(0,a[0]),u=e.slice(a[1]+1,r[0]),d=e.slice(r[1]+1),l=parseMediaFeatureValue(o,!0),p=parseMediaFeatureName(u),h=parseMediaFeatureValue(d,!0);if(!l||!p||!h)return!1;{const e=comparisonFromTokens(n);if(!1===e||e===exports.MediaFeatureEQ.EQ)return!1;const t=comparisonFromTokens(s);if(!1===t||t===exports.MediaFeatureEQ.EQ)return!1;if(!(e!==exports.MediaFeatureLT.LT&&e!==exports.MediaFeatureLT.LT_OR_EQ||t!==exports.MediaFeatureGT.GT&&t!==exports.MediaFeatureGT.GT_OR_EQ))return!1;if(!(e!==exports.MediaFeatureGT.GT&&e!==exports.MediaFeatureGT.GT_OR_EQ||t!==exports.MediaFeatureLT.LT&&t!==exports.MediaFeatureLT.LT_OR_EQ))return!1}return new MediaFeatureRangeValueNameValue(p,l,n,h,s)}class MediaFeature{type=exports.NodeType.MediaFeature;feature;before;after;constructor(e,t=[],i=[]){this.feature=e,this.before=t,this.after=i}getName(){return this.feature.getName()}getNameToken(){return this.feature.getNameToken()}tokens(){return[...this.before,...this.feature.tokens(),...this.after]}toString(){return i.stringify(...this.before)+this.feature.toString()+i.stringify(...this.after)}indexOf(e){return e===this.feature?"feature":-1}at(e){if("feature"===e)return this.feature}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.feature,parent:this,state:i},"feature")&&("walk"in this.feature?this.feature.walk(e,i):void 0)}toJSON(){return{type:this.type,feature:this.feature.toJSON(),before:this.before,after:this.after}}isMediaFeature(){return MediaFeature.isMediaFeature(this)}static isMediaFeature(e){return!!e&&(e instanceof MediaFeature&&e.type===exports.NodeType.MediaFeature)}}function parseMediaFeature(e,t=[],a=[]){if(e.startToken[0]!==i.TokenType.OpenParen)return!1;const r=parseMediaFeatureBoolean(e.value);if(!1!==r)return new MediaFeature(r,t,a);const n=parseMediaFeaturePlain(e.value);if(!1!==n)return new MediaFeature(n,t,a);const s=parseMediaFeatureRange(e.value);return!1!==s&&new MediaFeature(s,t,a)}class MediaNot{type=exports.NodeType.MediaNot;modifier;media;constructor(e,t){this.modifier=e,this.media=t}tokens(){return[...this.modifier,...this.media.tokens()]}toString(){return i.stringify(...this.modifier)+this.media.toString()}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&this.media.walk(e,i)}toJSON(){return{type:this.type,modifier:this.modifier,media:this.media.toJSON()}}isMediaNot(){return MediaNot.isMediaNot(this)}static isMediaNot(e){return!!e&&(e instanceof MediaNot&&e.type===exports.NodeType.MediaNot)}}class MediaOr{type=exports.NodeType.MediaOr;modifier;media;constructor(e,t){this.modifier=e,this.media=t}tokens(){return[...this.modifier,...this.media.tokens()]}toString(){return i.stringify(...this.modifier)+this.media.toString()}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&this.media.walk(e,i)}toJSON(){return{type:this.type,modifier:this.modifier,media:this.media.toJSON()}}isMediaOr(){return MediaOr.isMediaOr(this)}static isMediaOr(e){return!!e&&(e instanceof MediaOr&&e.type===exports.NodeType.MediaOr)}}function modifierFromToken(e){if(e[0]!==i.TokenType.Ident)return!1;switch(toLowerCaseAZ(e[4].value)){case exports.MediaQueryModifier.Not:return exports.MediaQueryModifier.Not;case exports.MediaQueryModifier.Only:return exports.MediaQueryModifier.Only;default:return!1}}function parseMediaQuery(e){{const t=parseMediaCondition(e);if(!1!==t)return new MediaQueryWithoutType(t)}{let a=-1,r=-1,n=-1;for(let s=0;s<e.length;s++){const o=e[s];if(!t.isWhitespaceNode(o)&&!t.isCommentNode(o)){if(t.isTokenNode(o)){const t=o.value;if(-1===a&&t[0]===i.TokenType.Ident&&modifierFromToken(t)){a=s;continue}if(-1===r&&t[0]===i.TokenType.Ident&&!modifierFromToken(t)){r=s;continue}if(-1===n&&t[0]===i.TokenType.Ident&&"and"===toLowerCaseAZ(t[4].value)){n=s;if(!1===parseMediaConditionWithoutOr(e.slice(s+1)))return!1;break}return!1}return!1}}let s=[],o=[];-1!==a?(s=e.slice(0,a+1).flatMap((e=>e.tokens())),-1!==r&&(o=e.slice(a+1,r+1).flatMap((e=>e.tokens())))):-1!==r&&(o=e.slice(0,r+1).flatMap((e=>e.tokens())));const u=parseMediaConditionWithoutOr(e.slice(Math.max(a,r,n)+1));return!1===u?new MediaQueryWithType(s,[...o,...e.slice(r+1).flatMap((e=>e.tokens()))]):new MediaQueryWithType(s,o,e.slice(r+1,n+1).flatMap((e=>e.tokens())),u)}}function parseMediaConditionListWithOr(e){let i=!1;const a=[];let r=-1,n=-1;for(let s=0;s<e.length;s++){if(i){const t=parseMediaOr(e.slice(s));if(!1!==t){s+=t.advance,a.push(t.node),n=s;continue}}const o=e[s];if(o.type!==t.ComponentValueType.Whitespace&&o.type!==t.ComponentValueType.Comment){if(i)return!1;if(!1!==i||!t.isSimpleBlockNode(o))return!1;if(o.normalize(),i=parseMediaInParensFromSimpleBlock(o),!1===i)return!1;r=s}}return!(!i||!a.length)&&new MediaConditionListWithOr(i,a,e.slice(0,r).flatMap((e=>e.tokens())),e.slice(n+1).flatMap((e=>e.tokens())))}function parseMediaConditionListWithAnd(e){let i=!1;const a=[];let r=-1,n=-1;for(let s=0;s<e.length;s++){if(i){const t=parseMediaAnd(e.slice(s));if(!1!==t){s+=t.advance,a.push(t.node),n=s;continue}}const o=e[s];if(o.type!==t.ComponentValueType.Whitespace&&o.type!==t.ComponentValueType.Comment){if(i)return!1;if(!1!==i||!t.isSimpleBlockNode(o))return!1;if(o.normalize(),i=parseMediaInParensFromSimpleBlock(o),!1===i)return!1;r=s}}return!(!i||!a.length)&&new MediaConditionListWithAnd(i,a,e.slice(0,r).flatMap((e=>e.tokens())),e.slice(n+1).flatMap((e=>e.tokens())))}function parseMediaCondition(e){const t=parseMediaNot(e);if(!1!==t)return new MediaCondition(t);const i=parseMediaConditionListWithAnd(e);if(!1!==i)return new MediaCondition(i);const a=parseMediaConditionListWithOr(e);if(!1!==a)return new MediaCondition(a);const r=parseMediaInParens(e);return!1!==r&&new MediaCondition(r)}function parseMediaConditionWithoutOr(e){const t=parseMediaNot(e);if(!1!==t)return new MediaCondition(t);const i=parseMediaConditionListWithAnd(e);if(!1!==i)return new MediaCondition(i);const a=parseMediaInParens(e);return!1!==a&&new MediaCondition(a)}function parseMediaInParens(e){let a=-1;for(let i=0;i<e.length;i++){const r=e[i];if(r.type!==t.ComponentValueType.Whitespace&&r.type!==t.ComponentValueType.Comment){if(!t.isSimpleBlockNode(r))return!1;if(-1!==a)return!1;a=i}}if(-1===a)return!1;const r=e[a];if(r.startToken[0]!==i.TokenType.OpenParen)return!1;r.normalize();const n=[...e.slice(0,a).flatMap((e=>e.tokens())),r.startToken],s=[r.endToken,...e.slice(a+1).flatMap((e=>e.tokens()))],o=parseMediaFeature(r,n,s);if(!1!==o)return new MediaInParens(o);const u=parseMediaCondition(r.value);return!1!==u?new MediaInParens(u,n,s):new MediaInParens(new GeneralEnclosed(r),e.slice(0,a).flatMap((e=>e.tokens())),e.slice(a+1).flatMap((e=>e.tokens())))}function parseMediaInParensFromSimpleBlock(e){if(e.startToken[0]!==i.TokenType.OpenParen)return!1;const t=parseMediaFeature(e,[e.startToken],[e.endToken]);if(!1!==t)return new MediaInParens(t);const a=parseMediaCondition(e.value);return!1!==a?new MediaInParens(a,[e.startToken],[e.endToken]):new MediaInParens(new GeneralEnclosed(e))}function parseMediaNot(e){let i=!1,a=null;for(let r=0;r<e.length;r++){const n=e[r];if(n.type!==t.ComponentValueType.Whitespace&&n.type!==t.ComponentValueType.Comment){if(isIdent(n)){if("not"===toLowerCaseAZ(n.value[4].value)){if(i)return!1;i=!0;continue}return!1}if(!i||!t.isSimpleBlockNode(n))return!1;{n.normalize();const t=parseMediaInParensFromSimpleBlock(n);if(!1===t)return!1;a=new MediaNot(e.slice(0,r).flatMap((e=>e.tokens())),t)}}}return a||!1}function parseMediaOr(e){let i=!1;for(let a=0;a<e.length;a++){const r=e[a];if(r.type!==t.ComponentValueType.Whitespace&&r.type!==t.ComponentValueType.Comment){if(isIdent(r)){if("or"===toLowerCaseAZ(r.value[4].value)){if(i)return!1;i=!0;continue}return!1}if(i&&t.isSimpleBlockNode(r)){r.normalize();const t=parseMediaInParensFromSimpleBlock(r);return!1!==t&&{advance:a,node:new MediaOr(e.slice(0,a).flatMap((e=>e.tokens())),t)}}return!1}}return!1}function parseMediaAnd(e){let i=!1;for(let a=0;a<e.length;a++){const r=e[a];if(r.type!==t.ComponentValueType.Whitespace&&r.type!==t.ComponentValueType.Comment){if(isIdent(r)){if("and"===toLowerCaseAZ(r.value[4].value)){if(i)return!1;i=!0;continue}return!1}if(i&&t.isSimpleBlockNode(r)){r.normalize();const t=parseMediaInParensFromSimpleBlock(r);return!1!==t&&{advance:a,node:new MediaAnd(e.slice(0,a).flatMap((e=>e.tokens())),t)}}return!1}}return!1}function parseFromTokens(e,i){const a=t.parseCommaSeparatedListOfComponentValues(e,{onParseError:null==i?void 0:i.onParseError});return a.map(((e,t)=>{const r=parseMediaQuery(e);return 0==r&&!0===(null==i?void 0:i.preserveInvalidMediaQueries)?new MediaQueryInvalid(a[t]):r})).filter((e=>!!e))}exports.MediaQueryModifier=void 0,(o=exports.MediaQueryModifier||(exports.MediaQueryModifier={})).Not="not",o.Only="only";class CustomMedia{type=exports.NodeType.CustomMedia;name;mediaQueryList=null;trueOrFalseKeyword=null;constructor(e,t,i){this.name=e,this.mediaQueryList=t,this.trueOrFalseKeyword=i??null}getName(){for(let e=0;e<this.name.length;e++){const t=this.name[e];if(t[0]===i.TokenType.Ident)return t[4].value}return""}getNameToken(){for(let e=0;e<this.name.length;e++){const t=this.name[e];if(t[0]===i.TokenType.Ident)return t}return null}hasMediaQueryList(){return!!this.mediaQueryList}hasTrueKeyword(){if(!this.trueOrFalseKeyword)return!1;for(let e=0;e<this.trueOrFalseKeyword.length;e++){const t=this.trueOrFalseKeyword[e];if(t[0]!==i.TokenType.Comment&&t[0]!==i.TokenType.Whitespace)return t[0]===i.TokenType.Ident&&"true"===toLowerCaseAZ(t[4].value)}return!1}hasFalseKeyword(){if(!this.trueOrFalseKeyword)return!1;for(let e=0;e<this.trueOrFalseKeyword.length;e++){const t=this.trueOrFalseKeyword[e];if(t[0]!==i.TokenType.Comment&&t[0]!==i.TokenType.Whitespace)return t[0]===i.TokenType.Ident&&"false"===toLowerCaseAZ(t[4].value)}return!1}tokens(){if(this.trueOrFalseKeyword)return[...this.name,...this.trueOrFalseKeyword];if(!this.mediaQueryList)return[...this.name];const e=[];for(let t=0;t<this.mediaQueryList.length;t++){const a=this.mediaQueryList[t];0!==t&&e.push([i.TokenType.Comma,",",-1,-1,void 0]),e.push(...a.tokens())}return[...this.name,...e]}toString(){return i.stringify(...this.tokens())}toJSON(){var e;return{type:this.type,string:this.toString(),nameValue:this.getName(),name:this.name,hasFalseKeyword:this.hasFalseKeyword(),hasTrueKeyword:this.hasTrueKeyword(),trueOrFalseKeyword:this.trueOrFalseKeyword,mediaQueryList:null==(e=this.mediaQueryList)?void 0:e.map((e=>e.toJSON()))}}isCustomMedia(){return CustomMedia.isCustomMedia(this)}static isCustomMedia(e){return!!e&&(e instanceof CustomMedia&&e.type===exports.NodeType.CustomMedia)}}function parseCustomMediaFromTokens(e,t){let a=[],r=e;for(let t=0;t<e.length;t++)if(e[t][0]!==i.TokenType.Comment&&e[t][0]!==i.TokenType.Whitespace){if(e[t][0]===i.TokenType.Ident){if(e[t][4].value.startsWith("--")){a=e.slice(0,t+1),r=e.slice(t+1);break}}return!1}let n=!0;for(let e=0;e<r.length;e++)if(r[e][0]!==i.TokenType.Comment&&r[e][0]!==i.TokenType.Whitespace){if(r[e][0]===i.TokenType.Ident){const t=toLowerCaseAZ(r[e][4].value);if("false"===t)continue;if("true"===t)continue}if(r[e][0]===i.TokenType.EOF)break;n=!1}return n?new CustomMedia(a,null,r):new CustomMedia(a,parseFromTokens(i.cloneTokens(r),t))}function isMediaConditionListWithAnd(e){return MediaConditionListWithAnd.isMediaConditionListWithAnd(e)}function isMediaConditionListWithOr(e){return MediaConditionListWithOr.isMediaConditionListWithOr(e)}function isMediaFeatureRangeNameValue(e){return MediaFeatureRangeNameValue.isMediaFeatureRangeNameValue(e)}function isMediaFeatureRangeValueName(e){return MediaFeatureRangeValueName.isMediaFeatureRangeValueName(e)}function isMediaFeatureRangeValueNameValue(e){return MediaFeatureRangeValueNameValue.isMediaFeatureRangeValueNameValue(e)}function isMediaQueryWithType(e){return MediaQueryWithType.isMediaQueryWithType(e)}function isMediaQueryWithoutType(e){return MediaQueryWithoutType.isMediaQueryWithoutType(e)}function isMediaQueryInvalid(e){return MediaQueryInvalid.isMediaQueryInvalid(e)}exports.MediaType=void 0,(u=exports.MediaType||(exports.MediaType={})).All="all",u.Print="print",u.Screen="screen",u.Tty="tty",u.Tv="tv",u.Projection="projection",u.Handheld="handheld",u.Braille="braille",u.Embossed="embossed",u.Aural="aural",u.Speech="speech",exports.CustomMedia=CustomMedia,exports.GeneralEnclosed=GeneralEnclosed,exports.MediaAnd=MediaAnd,exports.MediaCondition=MediaCondition,exports.MediaConditionListWithAnd=MediaConditionListWithAnd,exports.MediaConditionListWithOr=MediaConditionListWithOr,exports.MediaFeature=MediaFeature,exports.MediaFeatureBoolean=MediaFeatureBoolean,exports.MediaFeatureName=MediaFeatureName,exports.MediaFeaturePlain=MediaFeaturePlain,exports.MediaFeatureRangeNameValue=MediaFeatureRangeNameValue,exports.MediaFeatureRangeValueName=MediaFeatureRangeValueName,exports.MediaFeatureRangeValueNameValue=MediaFeatureRangeValueNameValue,exports.MediaFeatureValue=MediaFeatureValue,exports.MediaInParens=MediaInParens,exports.MediaNot=MediaNot,exports.MediaOr=MediaOr,exports.MediaQueryInvalid=MediaQueryInvalid,exports.MediaQueryWithType=MediaQueryWithType,exports.MediaQueryWithoutType=MediaQueryWithoutType,exports.cloneMediaQuery=function cloneMediaQuery(e){const t=i.cloneTokens(e.tokens()),a=parseFromTokens(t,{preserveInvalidMediaQueries:!0})[0];if(!a)throw new Error(`Failed to clone media query for : "${i.stringify(...t)}"`);if(isMediaQueryInvalid(e)&&isMediaQueryInvalid(a))return a;if(isMediaQueryWithType(e)&&isMediaQueryWithType(a))return a;if(isMediaQueryWithoutType(e)&&isMediaQueryWithoutType(a))return a;throw new Error(`Failed to clone media query for : "${i.stringify(...t)}"`)},exports.comparisonFromTokens=comparisonFromTokens,exports.invertComparison=function invertComparison(e){switch(e){case exports.MediaFeatureEQ.EQ:return exports.MediaFeatureEQ.EQ;case exports.MediaFeatureLT.LT:return exports.MediaFeatureGT.GT;case exports.MediaFeatureLT.LT_OR_EQ:return exports.MediaFeatureGT.GT_OR_EQ;case exports.MediaFeatureGT.GT:return exports.MediaFeatureLT.LT;case exports.MediaFeatureGT.GT_OR_EQ:return exports.MediaFeatureLT.LT_OR_EQ;default:return!1}},exports.isCustomMedia=function isCustomMedia(e){return CustomMedia.isCustomMedia(e)},exports.isGeneralEnclosed=function isGeneralEnclosed(e){return GeneralEnclosed.isGeneralEnclosed(e)},exports.isMediaAnd=function isMediaAnd(e){return MediaAnd.isMediaAnd(e)},exports.isMediaCondition=function isMediaCondition(e){return MediaCondition.isMediaCondition(e)},exports.isMediaConditionList=function isMediaConditionList(e){return isMediaConditionListWithAnd(e)||isMediaConditionListWithOr(e)},exports.isMediaConditionListWithAnd=isMediaConditionListWithAnd,exports.isMediaConditionListWithOr=isMediaConditionListWithOr,exports.isMediaFeature=function isMediaFeature(e){return MediaFeature.isMediaFeature(e)},exports.isMediaFeatureBoolean=function isMediaFeatureBoolean(e){return MediaFeatureBoolean.isMediaFeatureBoolean(e)},exports.isMediaFeatureName=function isMediaFeatureName(e){return MediaFeatureName.isMediaFeatureName(e)},exports.isMediaFeaturePlain=function isMediaFeaturePlain(e){return MediaFeaturePlain.isMediaFeaturePlain(e)},exports.isMediaFeatureRange=function isMediaFeatureRange(e){return isMediaFeatureRangeNameValue(e)||isMediaFeatureRangeValueName(e)||isMediaFeatureRangeValueNameValue(e)},exports.isMediaFeatureRangeNameValue=isMediaFeatureRangeNameValue,exports.isMediaFeatureRangeValueName=isMediaFeatureRangeValueName,exports.isMediaFeatureRangeValueNameValue=isMediaFeatureRangeValueNameValue,exports.isMediaFeatureValue=function isMediaFeatureValue(e){return MediaFeatureValue.isMediaFeatureValue(e)},exports.isMediaInParens=function isMediaInParens(e){return MediaInParens.isMediaInParens(e)},exports.isMediaNot=function isMediaNot(e){return MediaNot.isMediaNot(e)},exports.isMediaOr=function isMediaOr(e){return MediaOr.isMediaOr(e)},exports.isMediaQuery=function isMediaQuery(e){return isMediaQueryWithType(e)||isMediaQueryWithoutType(e)||isMediaQueryInvalid(e)},exports.isMediaQueryInvalid=isMediaQueryInvalid,exports.isMediaQueryWithType=isMediaQueryWithType,exports.isMediaQueryWithoutType=isMediaQueryWithoutType,exports.matchesComparison=matchesComparison,exports.matchesRatio=matchesRatio,exports.matchesRatioExactly=matchesRatioExactly,exports.modifierFromToken=modifierFromToken,exports.newMediaFeatureBoolean=function newMediaFeatureBoolean(e){const a=[i.TokenType.Ident,"",-1,-1,{value:""}];return i.mutateIdent(a,e),new MediaFeature(new MediaFeatureBoolean(new MediaFeatureName(new t.TokenNode(a))),[[i.TokenType.OpenParen,"(",-1,-1,void 0]],[[i.TokenType.CloseParen,")",-1,-1,void 0]])},exports.newMediaFeaturePlain=function newMediaFeaturePlain(e,...a){const r=[i.TokenType.Ident,"",-1,-1,{value:""}];i.mutateIdent(r,e);const n=t.parseListOfComponentValues(a);return new MediaFeature(new MediaFeaturePlain(new MediaFeatureName(new t.TokenNode(r)),[i.TokenType.Colon,":",-1,-1,void 0],new MediaFeatureValue(1===n.length?n[0]:n)),[[i.TokenType.OpenParen,"(",-1,-1,void 0]],[[i.TokenType.CloseParen,")",-1,-1,void 0]])},exports.parse=function parse(e,t){const a=i.tokenizer({css:e},{onParseError:null==t?void 0:t.onParseError}),r=[];for(;!a.endOfFile();)r.push(a.nextToken());return r.push(a.nextToken()),parseFromTokens(r,t)},exports.parseCustomMedia=function parseCustomMedia(e,t){const a=i.tokenizer({css:e},{onParseError:null==t?void 0:t.onParseError}),r=[];for(;!a.endOfFile();)r.push(a.nextToken());return r.push(a.nextToken()),parseCustomMediaFromTokens(r,t)},exports.parseCustomMediaFromTokens=parseCustomMediaFromTokens,exports.parseFromTokens=parseFromTokens,exports.typeFromToken=function typeFromToken(e){if(e[0]!==i.TokenType.Ident)return!1;switch(toLowerCaseAZ(e[4].value)){case exports.MediaType.All:return exports.MediaType.All;case exports.MediaType.Print:return exports.MediaType.Print;case exports.MediaType.Screen:return exports.MediaType.Screen;case exports.MediaType.Tty:return exports.MediaType.Tty;case exports.MediaType.Tv:return exports.MediaType.Tv;case exports.MediaType.Projection:return exports.MediaType.Projection;case exports.MediaType.Handheld:return exports.MediaType.Handheld;case exports.MediaType.Braille:return exports.MediaType.Braille;case exports.MediaType.Embossed:return exports.MediaType.Embossed;case exports.MediaType.Aural:return exports.MediaType.Aural;case exports.MediaType.Speech:return exports.MediaType.Speech;default:return!1}}; diff --git a/node_modules/@csstools/media-query-list-parser/dist/index.d.ts b/node_modules/@csstools/media-query-list-parser/dist/index.d.ts new file mode 100644 index 00000000..c78041d7 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/index.d.ts @@ -0,0 +1,23 @@ +export { parse, parseFromTokens } from './parser/parse'; +export { parseCustomMedia, parseCustomMediaFromTokens } from './parser/parse-custom-media'; +export { NodeType } from './util/node-type'; +export { isCustomMedia, isGeneralEnclosed, isMediaAnd, isMediaCondition, isMediaConditionList, isMediaConditionListWithAnd, isMediaConditionListWithOr, isMediaFeature, isMediaFeatureBoolean, isMediaFeatureName, isMediaFeaturePlain, isMediaFeatureRange, isMediaFeatureRangeNameValue, isMediaFeatureRangeValueName, isMediaFeatureRangeValueNameValue, isMediaFeatureValue, isMediaInParens, isMediaNot, isMediaOr, isMediaQuery, isMediaQueryInvalid, isMediaQueryWithType, isMediaQueryWithoutType, } from './util/type-predicates'; +export { CustomMedia } from './nodes/custom-media'; +export { GeneralEnclosed } from './nodes/general-enclosed'; +export { MediaAnd } from './nodes/media-and'; +export { MediaCondition } from './nodes/media-condition'; +export { MediaConditionList, MediaConditionListWithAnd, MediaConditionListWithOr } from './nodes/media-condition-list'; +export { MediaFeature, newMediaFeatureBoolean, newMediaFeaturePlain } from './nodes/media-feature'; +export { MediaFeatureBoolean } from './nodes/media-feature-boolean'; +export { MediaFeatureName } from './nodes/media-feature-name'; +export { MediaFeaturePlain } from './nodes/media-feature-plain'; +export { MediaFeatureRange, MediaFeatureRangeNameValue, MediaFeatureRangeValueName, MediaFeatureRangeValueNameValue } from './nodes/media-feature-range'; +export { MediaFeatureValue, matchesRatio, matchesRatioExactly } from './nodes/media-feature-value'; +export { MediaInParens } from './nodes/media-in-parens'; +export { MediaNot } from './nodes/media-not'; +export { MediaOr } from './nodes/media-or'; +export { MediaQuery, MediaQueryWithType, MediaQueryWithoutType, MediaQueryInvalid } from './nodes/media-query'; +export { MediaFeatureComparison, MediaFeatureEQ, MediaFeatureGT, MediaFeatureLT, invertComparison, matchesComparison, comparisonFromTokens } from './nodes/media-feature-comparison'; +export { MediaType, typeFromToken } from './nodes/media-type'; +export { MediaQueryModifier, modifierFromToken } from './nodes/media-query-modifier'; +export { cloneMediaQuery } from './util/clone-media-query'; diff --git a/node_modules/@csstools/media-query-list-parser/dist/index.mjs b/node_modules/@csstools/media-query-list-parser/dist/index.mjs new file mode 100644 index 00000000..66bfa3f4 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/index.mjs @@ -0,0 +1 @@ +import{ComponentValueType as e,TokenNode as t,parseListOfComponentValues as i,isWhitespaceNode as a,isCommentNode as n,isTokenNode as r,isSimpleBlockNode as s,parseCommaSeparatedListOfComponentValues as o}from"@csstools/css-parser-algorithms";import{stringify as u,TokenType as d,mutateIdent as l,tokenizer as h,cloneTokens as m}from"@csstools/css-tokenizer";var f;!function(e){e.CustomMedia="custom-media",e.GeneralEnclosed="general-enclosed",e.MediaAnd="media-and",e.MediaCondition="media-condition",e.MediaConditionListWithAnd="media-condition-list-and",e.MediaConditionListWithOr="media-condition-list-or",e.MediaFeature="media-feature",e.MediaFeatureBoolean="mf-boolean",e.MediaFeatureName="mf-name",e.MediaFeaturePlain="mf-plain",e.MediaFeatureRangeNameValue="mf-range-name-value",e.MediaFeatureRangeValueName="mf-range-value-name",e.MediaFeatureRangeValueNameValue="mf-range-value-name-value",e.MediaFeatureValue="mf-value",e.MediaInParens="media-in-parens",e.MediaNot="media-not",e.MediaOr="media-or",e.MediaQueryWithType="media-query-with-type",e.MediaQueryWithoutType="media-query-without-type",e.MediaQueryInvalid="media-query-invalid"}(f||(f={}));const c=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(c,(e=>String.fromCharCode(e.charCodeAt(0)+32)))}class MediaCondition{type=f.MediaCondition;media;constructor(e){this.media=e}tokens(){return this.media.tokens()}toString(){return this.media.toString()}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&this.media.walk(e,i)}toJSON(){return{type:this.type,media:this.media.toJSON()}}isMediaCondition(){return MediaCondition.isMediaCondition(this)}static isMediaCondition(e){return!!e&&(e instanceof MediaCondition&&e.type===f.MediaCondition)}}class MediaInParens{type=f.MediaInParens;media;before;after;constructor(e,t=[],i=[]){this.media=e,this.before=t,this.after=i}tokens(){return[...this.before,...this.media.tokens(),...this.after]}toString(){return u(...this.before)+this.media.toString()+u(...this.after)}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&("walk"in this.media?this.media.walk(e,i):void 0)}toJSON(){return{type:this.type,media:this.media.toJSON(),before:this.before,after:this.after}}isMediaInParens(){return MediaInParens.isMediaInParens(this)}static isMediaInParens(e){return!!e&&(e instanceof MediaInParens&&e.type===f.MediaInParens)}}class MediaQueryWithType{type=f.MediaQueryWithType;modifier;mediaType;and=void 0;media=void 0;constructor(e,t,i,a){this.modifier=e,this.mediaType=t,i&&a&&(this.and=i,this.media=a)}getModifier(){if(!this.modifier.length)return"";for(let e=0;e<this.modifier.length;e++){const t=this.modifier[e];if(t[0]===d.Ident)return t[4].value}return""}negateQuery(){const e=new MediaQueryWithType([...this.modifier],[...this.mediaType],this.and,this.media);if(0===e.modifier.length)return e.modifier=[[d.Ident,"not",-1,-1,{value:"not"}],[d.Whitespace," ",-1,-1,void 0]],e;for(let t=0;t<e.modifier.length;t++){const i=e.modifier[t];if(i[0]===d.Ident&&"not"===toLowerCaseAZ(i[4].value)){e.modifier.splice(t,1);break}if(i[0]===d.Ident&&"only"===toLowerCaseAZ(i[4].value)){i[1]="not",i[4].value="not";break}}return e}getMediaType(){if(!this.mediaType.length)return"";for(let e=0;e<this.mediaType.length;e++){const t=this.mediaType[e];if(t[0]===d.Ident)return t[4].value}return""}tokens(){return this.and&&this.media?[...this.modifier,...this.mediaType,...this.and,...this.media.tokens()]:[...this.modifier,...this.mediaType]}toString(){return this.and&&this.media?u(...this.modifier)+u(...this.mediaType)+u(...this.and)+this.media.toString():u(...this.modifier)+u(...this.mediaType)}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;if(t&&(i={...t}),this.media)return!1!==e({node:this.media,parent:this,state:i},"media")&&this.media.walk(e,i)}toJSON(){return{type:this.type,string:this.toString(),modifier:this.modifier,mediaType:this.mediaType,and:this.and,media:this.media}}isMediaQueryWithType(){return MediaQueryWithType.isMediaQueryWithType(this)}static isMediaQueryWithType(e){return!!e&&(e instanceof MediaQueryWithType&&e.type===f.MediaQueryWithType)}}class MediaQueryWithoutType{type=f.MediaQueryWithoutType;media;constructor(e){this.media=e}negateQuery(){let e=this.media;if(e.media.type===f.MediaNot)return new MediaQueryWithoutType(new MediaCondition(e.media.media));e.media.type===f.MediaConditionListWithOr&&(e=new MediaCondition(new MediaInParens(e,[[d.Whitespace," ",0,0,void 0],[d.OpenParen,"(",0,0,void 0]],[[d.CloseParen,")",0,0,void 0]])));return new MediaQueryWithType([[d.Ident,"not",0,0,{value:"not"}],[d.Whitespace," ",0,0,void 0]],[[d.Ident,"all",0,0,{value:"all"}],[d.Whitespace," ",0,0,void 0]],[[d.Ident,"and",0,0,{value:"and"}]],e)}tokens(){return this.media.tokens()}toString(){return this.media.toString()}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&this.media.walk(e,i)}toJSON(){return{type:this.type,string:this.toString(),media:this.media}}isMediaQueryWithoutType(){return MediaQueryWithoutType.isMediaQueryWithoutType(this)}static isMediaQueryWithoutType(e){return!!e&&(e instanceof MediaQueryWithoutType&&e.type===f.MediaQueryWithoutType)}}class MediaQueryInvalid{type=f.MediaQueryInvalid;media;constructor(e){this.media=e}negateQuery(){return new MediaQueryInvalid(this.media)}tokens(){return this.media.flatMap((e=>e.tokens()))}toString(){return this.media.map((e=>e.toString())).join("")}walk(e,t){let i=!1;if(this.media.forEach(((a,n)=>{if(i)return;let r;t&&(r={...t}),!1!==e({node:a,parent:this,state:r},n)?"walk"in a&&!1===a.walk(e,r)&&(i=!0):i=!0})),i)return!1}toJSON(){return{type:this.type,string:this.toString(),media:this.media}}isMediaQueryInvalid(){return MediaQueryInvalid.isMediaQueryInvalid(this)}static isMediaQueryInvalid(e){return!!e&&(e instanceof MediaQueryInvalid&&e.type===f.MediaQueryInvalid)}}class GeneralEnclosed{type=f.GeneralEnclosed;value;constructor(e){this.value=e}tokens(){return this.value.tokens()}toString(){return this.value.toString()}indexOf(e){return e===this.value?"value":-1}at(e){if("value"===e)return this.value}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.value,parent:this,state:i},"value")&&("walk"in this.value?this.value.walk(e,i):void 0)}toJSON(){return{type:this.type,tokens:this.tokens()}}isGeneralEnclosed(){return GeneralEnclosed.isGeneralEnclosed(this)}static isGeneralEnclosed(e){return!!e&&(e instanceof GeneralEnclosed&&e.type===f.GeneralEnclosed)}}class MediaAnd{type=f.MediaAnd;modifier;media;constructor(e,t){this.modifier=e,this.media=t}tokens(){return[...this.modifier,...this.media.tokens()]}toString(){return u(...this.modifier)+this.media.toString()}indexOf(e){return e===this.media?"media":-1}at(e){return"media"===e?this.media:null}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&this.media.walk(e,i)}toJSON(){return{type:this.type,modifier:this.modifier,media:this.media.toJSON()}}isMediaAnd(){return MediaAnd.isMediaAnd(this)}static isMediaAnd(e){return!!e&&(e instanceof MediaAnd&&e.type===f.MediaAnd)}}class MediaConditionListWithAnd{type=f.MediaConditionListWithAnd;leading;list;before;after;constructor(e,t,i=[],a=[]){this.leading=e,this.list=t,this.before=i,this.after=a}tokens(){return[...this.before,...this.leading.tokens(),...this.list.flatMap((e=>e.tokens())),...this.after]}toString(){return u(...this.before)+this.leading.toString()+this.list.map((e=>e.toString())).join("")+u(...this.after)}indexOf(e){return e===this.leading?"leading":"media-and"===e.type?this.list.indexOf(e):-1}at(e){return"leading"===e?this.leading:"number"==typeof e?(e<0&&(e=this.list.length+e),this.list[e]):void 0}walk(e,t){let i;if(t&&(i={...t}),!1===e({node:this.leading,parent:this,state:i},"leading"))return!1;if("walk"in this.leading&&!1===this.leading.walk(e,i))return!1;let a=!1;return this.list.forEach(((n,r)=>{a||(t&&(i={...t}),!1!==e({node:n,parent:this,state:i},r)?"walk"in n&&!1===n.walk(e,i)&&(a=!0):a=!0)})),!a&&void 0}toJSON(){return{type:this.type,leading:this.leading.toJSON(),list:this.list.map((e=>e.toJSON())),before:this.before,after:this.after}}isMediaConditionListWithAnd(){return MediaConditionListWithAnd.isMediaConditionListWithAnd(this)}static isMediaConditionListWithAnd(e){return!!e&&(e instanceof MediaConditionListWithAnd&&e.type===f.MediaConditionListWithAnd)}}class MediaConditionListWithOr{type=f.MediaConditionListWithOr;leading;list;before;after;constructor(e,t,i=[],a=[]){this.leading=e,this.list=t,this.before=i,this.after=a}tokens(){return[...this.before,...this.leading.tokens(),...this.list.flatMap((e=>e.tokens())),...this.after]}toString(){return u(...this.before)+this.leading.toString()+this.list.map((e=>e.toString())).join("")+u(...this.after)}indexOf(e){return e===this.leading?"leading":"media-or"===e.type?this.list.indexOf(e):-1}at(e){return"leading"===e?this.leading:"number"==typeof e?(e<0&&(e=this.list.length+e),this.list[e]):void 0}walk(e,t){let i;if(t&&(i={...t}),!1===e({node:this.leading,parent:this,state:i},"leading"))return!1;if("walk"in this.leading&&!1===this.leading.walk(e,i))return!1;let a=!1;return this.list.forEach(((n,r)=>{a||(t&&(i={...t}),!1!==e({node:n,parent:this,state:i},r)?"walk"in n&&!1===n.walk(e,i)&&(a=!0):a=!0)})),!a&&void 0}toJSON(){return{type:this.type,leading:this.leading.toJSON(),list:this.list.map((e=>e.toJSON())),before:this.before,after:this.after}}isMediaConditionListWithOr(){return MediaConditionListWithOr.isMediaConditionListWithOr(this)}static isMediaConditionListWithOr(e){return!!e&&(e instanceof MediaConditionListWithOr&&e.type===f.MediaConditionListWithOr)}}function isNumber(t){return!!(t.type===e.Token&&t.value[0]===d.Number||t.type===e.Function&&M.has(toLowerCaseAZ(t.name[4].value)))}const M=new Set(["abs","acos","asin","atan","atan2","calc","clamp","cos","exp","hypot","log","max","min","mod","pow","rem","round","sign","sin","sqrt","tan"]);function isDimension(t){return t.type===e.Token&&t.value[0]===d.Dimension}function isIdent(t){return t.type===e.Token&&t.value[0]===d.Ident}function isEnvironmentVariable(t){return t.type===e.Function&&"env"===toLowerCaseAZ(t.name[4].value)}class MediaFeatureName{type=f.MediaFeatureName;name;before;after;constructor(e,t=[],i=[]){this.name=e,this.before=t,this.after=i}getName(){return this.name.value[4].value}getNameToken(){return this.name.value}tokens(){return[...this.before,...this.name.tokens(),...this.after]}toString(){return u(...this.before)+this.name.toString()+u(...this.after)}indexOf(e){return e===this.name?"name":-1}at(e){if("name"===e)return this.name}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens()}}isMediaFeatureName(){return MediaFeatureName.isMediaFeatureName(this)}static isMediaFeatureName(e){return!!e&&(e instanceof MediaFeatureName&&e.type===f.MediaFeatureName)}}function parseMediaFeatureName(t){let i=-1;for(let a=0;a<t.length;a++){const n=t[a];if(n.type!==e.Whitespace&&n.type!==e.Comment){if(!isIdent(n))return!1;if(-1!==i)return!1;i=a}}return-1!==i&&new MediaFeatureName(t[i],t.slice(0,i).flatMap((e=>e.tokens())),t.slice(i+1).flatMap((e=>e.tokens())))}class MediaFeatureBoolean{type=f.MediaFeatureBoolean;name;constructor(e){this.name=e}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return this.name.tokens()}toString(){return this.name.toString()}indexOf(e){return e===this.name?"name":-1}at(e){if("name"===e)return this.name}toJSON(){return{type:this.type,name:this.name.toJSON(),tokens:this.tokens()}}isMediaFeatureBoolean(){return MediaFeatureBoolean.isMediaFeatureBoolean(this)}static isMediaFeatureBoolean(e){return!!e&&(e instanceof MediaFeatureBoolean&&e.type===f.MediaFeatureBoolean)}}function parseMediaFeatureBoolean(e){const t=parseMediaFeatureName(e);return!1===t?t:new MediaFeatureBoolean(t)}class MediaFeatureValue{type=f.MediaFeatureValue;value;before;after;constructor(e,t=[],i=[]){Array.isArray(e)&&1===e.length?this.value=e[0]:this.value=e,this.before=t,this.after=i}tokens(){return Array.isArray(this.value)?[...this.before,...this.value.flatMap((e=>e.tokens())),...this.after]:[...this.before,...this.value.tokens(),...this.after]}toString(){return Array.isArray(this.value)?u(...this.before)+this.value.map((e=>e.toString())).join("")+u(...this.after):u(...this.before)+this.value.toString()+u(...this.after)}indexOf(e){return e===this.value?"value":-1}at(e){return"value"===e?this.value:Array.isArray(this.value)&&"number"==typeof e?(e<0&&(e=this.value.length+e),this.value[e]):void 0}walk(e,t){if(Array.isArray(this.value)){let i=!1;if(this.value.forEach(((a,n)=>{if(i)return;let r;t&&(r={...t}),!1!==e({node:a,parent:this,state:r},n)?"walk"in a&&!1===a.walk(e,r)&&(i=!0):i=!0})),i)return!1}else{let i;if(t&&(i={...t}),!1===e({node:this.value,parent:this,state:i},"value"))return!1;if("walk"in this.value)return this.value.walk(e,i)}}toJSON(){return Array.isArray(this.value)?{type:this.type,value:this.value.map((e=>e.toJSON())),tokens:this.tokens()}:{type:this.type,value:this.value.toJSON(),tokens:this.tokens()}}isMediaFeatureValue(){return MediaFeatureValue.isMediaFeatureValue(this)}static isMediaFeatureValue(e){return!!e&&(e instanceof MediaFeatureValue&&e.type===f.MediaFeatureValue)}}function parseMediaFeatureValue(t,i=!1){let a=-1,n=-1;for(let r=0;r<t.length;r++){const s=t[r];if(s.type!==e.Whitespace&&s.type!==e.Comment){if(-1!==a)return!1;if(isNumber(s)){const e=matchesRatioExactly(t.slice(r));if(-1!==e){a=e[0]+r,n=e[1]+r,r+=e[1]-e[0];continue}a=r,n=r}else if(isEnvironmentVariable(s))a=r,n=r;else if(isDimension(s))a=r,n=r;else{if(i||!isIdent(s))return!1;a=r,n=r}}}return-1!==a&&new MediaFeatureValue(t.slice(a,n+1),t.slice(0,a).flatMap((e=>e.tokens())),t.slice(n+1).flatMap((e=>e.tokens())))}function matchesRatioExactly(e){let t=-1,i=-1;const a=matchesRatio(e);if(-1===a)return-1;t=a[0],i=a[1];for(let t=i+1;t<e.length;t++){const i=e[t];if("whitespace"!==i.type&&"comment"!==i.type)return-1}return[t,i]}function matchesRatio(e){let t=-1,i=-1;for(let a=0;a<e.length;a++){const n=e[a];if("whitespace"!==n.type&&"comment"!==n.type){if("token"===n.type){const e=n.value;if(e[0]===d.Delim&&"/"===e[4].value){if(-1===t)return-1;if(-1!==i)return-1;i=a;continue}}if(!isNumber(n))return-1;if(-1!==i)return[t,a];if(-1!==t)return-1;t=a}}return-1}class MediaFeaturePlain{type=f.MediaFeaturePlain;name;colon;value;constructor(e,t,i){this.name=e,this.colon=t,this.value=i}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return[...this.name.tokens(),this.colon,...this.value.tokens()]}toString(){return this.name.toString()+u(this.colon)+this.value.toString()}indexOf(e){return e===this.name?"name":e===this.value?"value":-1}at(e){return"name"===e?this.name:"value"===e?this.value:void 0}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.value,parent:this,state:i},"value")&&this.value.walk(e,i)}toJSON(){return{type:this.type,name:this.name.toJSON(),value:this.value.toJSON(),tokens:this.tokens()}}isMediaFeaturePlain(){return MediaFeaturePlain.isMediaFeaturePlain(this)}static isMediaFeaturePlain(e){return!!e&&(e instanceof MediaFeaturePlain&&e.type===f.MediaFeaturePlain)}}function parseMediaFeaturePlain(t){let i=[],a=[],n=null;for(let r=0;r<t.length;r++){const s=t[r];if(s.type===e.Token){const e=s.value;if(e[0]===d.Colon){i=t.slice(0,r),a=t.slice(r+1),n=e;break}}}if(!i.length||!a.length||!n)return!1;const r=parseMediaFeatureName(i);if(!1===r)return!1;const s=parseMediaFeatureValue(a);return!1!==s&&new MediaFeaturePlain(r,n,s)}var p,y,v,g,k;function matchesComparison(t){let i=-1;for(let a=0;a<t.length;a++){const n=t[a];if(n.type===e.Token){const e=n.value;if(e[0]===d.Delim){if(e[4].value===v.EQ)return-1!==i?[i,a]:[a,a];if(e[4].value===p.LT){i=a;continue}if(e[4].value===y.GT){i=a;continue}}}break}return-1!==i&&[i,i]}function comparisonFromTokens(e){if(0===e.length||e.length>2)return!1;if(e[0][0]!==d.Delim)return!1;if(1===e.length)switch(e[0][4].value){case v.EQ:return v.EQ;case p.LT:return p.LT;case y.GT:return y.GT;default:return!1}if(e[1][0]!==d.Delim)return!1;if(e[1][4].value!==v.EQ)return!1;switch(e[0][4].value){case p.LT:return p.LT_OR_EQ;case y.GT:return y.GT_OR_EQ;default:return!1}}function invertComparison(e){switch(e){case v.EQ:return v.EQ;case p.LT:return y.GT;case p.LT_OR_EQ:return y.GT_OR_EQ;case y.GT:return p.LT;case y.GT_OR_EQ:return p.LT_OR_EQ;default:return!1}}!function(e){e.LT="<",e.LT_OR_EQ="<="}(p||(p={})),function(e){e.GT=">",e.GT_OR_EQ=">="}(y||(y={})),function(e){e.EQ="="}(v||(v={}));class MediaFeatureRangeNameValue{type=f.MediaFeatureRangeNameValue;name;operator;value;constructor(e,t,i){this.name=e,this.operator=t,this.value=i}operatorKind(){return comparisonFromTokens(this.operator)}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return[...this.name.tokens(),...this.operator,...this.value.tokens()]}toString(){return this.name.toString()+u(...this.operator)+this.value.toString()}indexOf(e){return e===this.name?"name":e===this.value?"value":-1}at(e){return"name"===e?this.name:"value"===e?this.value:void 0}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.value,parent:this,state:i},"value")&&("walk"in this.value?this.value.walk(e,i):void 0)}toJSON(){return{type:this.type,name:this.name.toJSON(),value:this.value.toJSON(),tokens:this.tokens()}}isMediaFeatureRangeNameValue(){return MediaFeatureRangeNameValue.isMediaFeatureRangeNameValue(this)}static isMediaFeatureRangeNameValue(e){return!!e&&(e instanceof MediaFeatureRangeNameValue&&e.type===f.MediaFeatureRangeNameValue)}}class MediaFeatureRangeValueName{type=f.MediaFeatureRangeValueName;name;operator;value;constructor(e,t,i){this.name=e,this.operator=t,this.value=i}operatorKind(){return comparisonFromTokens(this.operator)}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return[...this.value.tokens(),...this.operator,...this.name.tokens()]}toString(){return this.value.toString()+u(...this.operator)+this.name.toString()}indexOf(e){return e===this.name?"name":e===this.value?"value":-1}at(e){return"name"===e?this.name:"value"===e?this.value:void 0}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.value,parent:this,state:i},"value")&&("walk"in this.value?this.value.walk(e,i):void 0)}toJSON(){return{type:this.type,name:this.name.toJSON(),value:this.value.toJSON(),tokens:this.tokens()}}isMediaFeatureRangeValueName(){return MediaFeatureRangeValueName.isMediaFeatureRangeValueName(this)}static isMediaFeatureRangeValueName(e){return!!e&&(e instanceof MediaFeatureRangeValueName&&e.type===f.MediaFeatureRangeValueName)}}class MediaFeatureRangeValueNameValue{type=f.MediaFeatureRangeValueNameValue;name;valueOne;valueOneOperator;valueTwo;valueTwoOperator;constructor(e,t,i,a,n){this.name=e,this.valueOne=t,this.valueOneOperator=i,this.valueTwo=a,this.valueTwoOperator=n}valueOneOperatorKind(){return comparisonFromTokens(this.valueOneOperator)}valueTwoOperatorKind(){return comparisonFromTokens(this.valueTwoOperator)}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return[...this.valueOne.tokens(),...this.valueOneOperator,...this.name.tokens(),...this.valueTwoOperator,...this.valueTwo.tokens()]}toString(){return this.valueOne.toString()+u(...this.valueOneOperator)+this.name.toString()+u(...this.valueTwoOperator)+this.valueTwo.toString()}indexOf(e){return e===this.name?"name":e===this.valueOne?"valueOne":e===this.valueTwo?"valueTwo":-1}at(e){return"name"===e?this.name:"valueOne"===e?this.valueOne:"valueTwo"===e?this.valueTwo:void 0}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.valueOne,parent:this,state:i},"valueOne")&&((!("walk"in this.valueOne)||!1!==this.valueOne.walk(e,i))&&(t&&(i={...t}),!1!==e({node:this.valueTwo,parent:this,state:i},"valueTwo")&&((!("walk"in this.valueTwo)||!1!==this.valueTwo.walk(e,i))&&void 0)))}toJSON(){return{type:this.type,name:this.name.toJSON(),valueOne:this.valueOne.toJSON(),valueTwo:this.valueTwo.toJSON(),tokens:this.tokens()}}isMediaFeatureRangeValueNameValue(){return MediaFeatureRangeValueNameValue.isMediaFeatureRangeValueNameValue(this)}static isMediaFeatureRangeValueNameValue(e){return!!e&&(e instanceof MediaFeatureRangeValueNameValue&&e.type===f.MediaFeatureRangeValueNameValue)}}function parseMediaFeatureRange(t){let i=!1,a=!1;for(let n=0;n<t.length;n++){const r=t[n];if(r.type===e.Token){if(r.value[0]===d.Delim){const e=matchesComparison(t.slice(n));if(!1!==e){if(!1!==i){a=[e[0]+n,e[1]+n];break}i=[e[0]+n,e[1]+n],n+=e[1]}}}}if(!1===i)return!1;const n=[t[i[0]].value];if(i[0]!==i[1]&&n.push(t[i[1]].value),!1===a){const e=t.slice(0,i[0]),a=t.slice(i[1]+1),r=parseMediaFeatureName(e);if(r){const e=parseMediaFeatureValue(a,!0);return!!e&&new MediaFeatureRangeNameValue(r,n,e)}const s=parseMediaFeatureName(a);if(s){const t=parseMediaFeatureValue(e,!0);return!!t&&new MediaFeatureRangeValueName(s,n,t)}return!1}const r=[t[a[0]].value];a[0]!==a[1]&&r.push(t[a[1]].value);const s=t.slice(0,i[0]),o=t.slice(i[1]+1,a[0]),u=t.slice(a[1]+1),l=parseMediaFeatureValue(s,!0),h=parseMediaFeatureName(o),m=parseMediaFeatureValue(u,!0);if(!l||!h||!m)return!1;{const e=comparisonFromTokens(n);if(!1===e||e===v.EQ)return!1;const t=comparisonFromTokens(r);if(!1===t||t===v.EQ)return!1;if(!(e!==p.LT&&e!==p.LT_OR_EQ||t!==y.GT&&t!==y.GT_OR_EQ))return!1;if(!(e!==y.GT&&e!==y.GT_OR_EQ||t!==p.LT&&t!==p.LT_OR_EQ))return!1}return new MediaFeatureRangeValueNameValue(h,l,n,m,r)}class MediaFeature{type=f.MediaFeature;feature;before;after;constructor(e,t=[],i=[]){this.feature=e,this.before=t,this.after=i}getName(){return this.feature.getName()}getNameToken(){return this.feature.getNameToken()}tokens(){return[...this.before,...this.feature.tokens(),...this.after]}toString(){return u(...this.before)+this.feature.toString()+u(...this.after)}indexOf(e){return e===this.feature?"feature":-1}at(e){if("feature"===e)return this.feature}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.feature,parent:this,state:i},"feature")&&("walk"in this.feature?this.feature.walk(e,i):void 0)}toJSON(){return{type:this.type,feature:this.feature.toJSON(),before:this.before,after:this.after}}isMediaFeature(){return MediaFeature.isMediaFeature(this)}static isMediaFeature(e){return!!e&&(e instanceof MediaFeature&&e.type===f.MediaFeature)}}function parseMediaFeature(e,t=[],i=[]){if(e.startToken[0]!==d.OpenParen)return!1;const a=parseMediaFeatureBoolean(e.value);if(!1!==a)return new MediaFeature(a,t,i);const n=parseMediaFeaturePlain(e.value);if(!1!==n)return new MediaFeature(n,t,i);const r=parseMediaFeatureRange(e.value);return!1!==r&&new MediaFeature(r,t,i)}function newMediaFeatureBoolean(e){const i=[d.Ident,"",-1,-1,{value:""}];return l(i,e),new MediaFeature(new MediaFeatureBoolean(new MediaFeatureName(new t(i))),[[d.OpenParen,"(",-1,-1,void 0]],[[d.CloseParen,")",-1,-1,void 0]])}function newMediaFeaturePlain(e,...a){const n=[d.Ident,"",-1,-1,{value:""}];l(n,e);const r=i(a);return new MediaFeature(new MediaFeaturePlain(new MediaFeatureName(new t(n)),[d.Colon,":",-1,-1,void 0],new MediaFeatureValue(1===r.length?r[0]:r)),[[d.OpenParen,"(",-1,-1,void 0]],[[d.CloseParen,")",-1,-1,void 0]])}class MediaNot{type=f.MediaNot;modifier;media;constructor(e,t){this.modifier=e,this.media=t}tokens(){return[...this.modifier,...this.media.tokens()]}toString(){return u(...this.modifier)+this.media.toString()}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&this.media.walk(e,i)}toJSON(){return{type:this.type,modifier:this.modifier,media:this.media.toJSON()}}isMediaNot(){return MediaNot.isMediaNot(this)}static isMediaNot(e){return!!e&&(e instanceof MediaNot&&e.type===f.MediaNot)}}class MediaOr{type=f.MediaOr;modifier;media;constructor(e,t){this.modifier=e,this.media=t}tokens(){return[...this.modifier,...this.media.tokens()]}toString(){return u(...this.modifier)+this.media.toString()}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&this.media.walk(e,i)}toJSON(){return{type:this.type,modifier:this.modifier,media:this.media.toJSON()}}isMediaOr(){return MediaOr.isMediaOr(this)}static isMediaOr(e){return!!e&&(e instanceof MediaOr&&e.type===f.MediaOr)}}function modifierFromToken(e){if(e[0]!==d.Ident)return!1;switch(toLowerCaseAZ(e[4].value)){case g.Not:return g.Not;case g.Only:return g.Only;default:return!1}}function parseMediaQuery(e){{const t=parseMediaCondition(e);if(!1!==t)return new MediaQueryWithoutType(t)}{let t=-1,i=-1,s=-1;for(let o=0;o<e.length;o++){const u=e[o];if(!a(u)&&!n(u)){if(r(u)){const a=u.value;if(-1===t&&a[0]===d.Ident&&modifierFromToken(a)){t=o;continue}if(-1===i&&a[0]===d.Ident&&!modifierFromToken(a)){i=o;continue}if(-1===s&&a[0]===d.Ident&&"and"===toLowerCaseAZ(a[4].value)){s=o;if(!1===parseMediaConditionWithoutOr(e.slice(o+1)))return!1;break}return!1}return!1}}let o=[],u=[];-1!==t?(o=e.slice(0,t+1).flatMap((e=>e.tokens())),-1!==i&&(u=e.slice(t+1,i+1).flatMap((e=>e.tokens())))):-1!==i&&(u=e.slice(0,i+1).flatMap((e=>e.tokens())));const l=parseMediaConditionWithoutOr(e.slice(Math.max(t,i,s)+1));return!1===l?new MediaQueryWithType(o,[...u,...e.slice(i+1).flatMap((e=>e.tokens()))]):new MediaQueryWithType(o,u,e.slice(i+1,s+1).flatMap((e=>e.tokens())),l)}}function parseMediaConditionListWithOr(t){let i=!1;const a=[];let n=-1,r=-1;for(let o=0;o<t.length;o++){if(i){const e=parseMediaOr(t.slice(o));if(!1!==e){o+=e.advance,a.push(e.node),r=o;continue}}const u=t[o];if(u.type!==e.Whitespace&&u.type!==e.Comment){if(i)return!1;if(!1!==i||!s(u))return!1;if(u.normalize(),i=parseMediaInParensFromSimpleBlock(u),!1===i)return!1;n=o}}return!(!i||!a.length)&&new MediaConditionListWithOr(i,a,t.slice(0,n).flatMap((e=>e.tokens())),t.slice(r+1).flatMap((e=>e.tokens())))}function parseMediaConditionListWithAnd(t){let i=!1;const a=[];let n=-1,r=-1;for(let o=0;o<t.length;o++){if(i){const e=parseMediaAnd(t.slice(o));if(!1!==e){o+=e.advance,a.push(e.node),r=o;continue}}const u=t[o];if(u.type!==e.Whitespace&&u.type!==e.Comment){if(i)return!1;if(!1!==i||!s(u))return!1;if(u.normalize(),i=parseMediaInParensFromSimpleBlock(u),!1===i)return!1;n=o}}return!(!i||!a.length)&&new MediaConditionListWithAnd(i,a,t.slice(0,n).flatMap((e=>e.tokens())),t.slice(r+1).flatMap((e=>e.tokens())))}function parseMediaCondition(e){const t=parseMediaNot(e);if(!1!==t)return new MediaCondition(t);const i=parseMediaConditionListWithAnd(e);if(!1!==i)return new MediaCondition(i);const a=parseMediaConditionListWithOr(e);if(!1!==a)return new MediaCondition(a);const n=parseMediaInParens(e);return!1!==n&&new MediaCondition(n)}function parseMediaConditionWithoutOr(e){const t=parseMediaNot(e);if(!1!==t)return new MediaCondition(t);const i=parseMediaConditionListWithAnd(e);if(!1!==i)return new MediaCondition(i);const a=parseMediaInParens(e);return!1!==a&&new MediaCondition(a)}function parseMediaInParens(t){let i=-1;for(let a=0;a<t.length;a++){const n=t[a];if(n.type!==e.Whitespace&&n.type!==e.Comment){if(!s(n))return!1;if(-1!==i)return!1;i=a}}if(-1===i)return!1;const a=t[i];if(a.startToken[0]!==d.OpenParen)return!1;a.normalize();const n=[...t.slice(0,i).flatMap((e=>e.tokens())),a.startToken],r=[a.endToken,...t.slice(i+1).flatMap((e=>e.tokens()))],o=parseMediaFeature(a,n,r);if(!1!==o)return new MediaInParens(o);const u=parseMediaCondition(a.value);return!1!==u?new MediaInParens(u,n,r):new MediaInParens(new GeneralEnclosed(a),t.slice(0,i).flatMap((e=>e.tokens())),t.slice(i+1).flatMap((e=>e.tokens())))}function parseMediaInParensFromSimpleBlock(e){if(e.startToken[0]!==d.OpenParen)return!1;const t=parseMediaFeature(e,[e.startToken],[e.endToken]);if(!1!==t)return new MediaInParens(t);const i=parseMediaCondition(e.value);return!1!==i?new MediaInParens(i,[e.startToken],[e.endToken]):new MediaInParens(new GeneralEnclosed(e))}function parseMediaNot(t){let i=!1,a=null;for(let n=0;n<t.length;n++){const r=t[n];if(r.type!==e.Whitespace&&r.type!==e.Comment){if(isIdent(r)){if("not"===toLowerCaseAZ(r.value[4].value)){if(i)return!1;i=!0;continue}return!1}if(!i||!s(r))return!1;{r.normalize();const e=parseMediaInParensFromSimpleBlock(r);if(!1===e)return!1;a=new MediaNot(t.slice(0,n).flatMap((e=>e.tokens())),e)}}}return a||!1}function parseMediaOr(t){let i=!1;for(let a=0;a<t.length;a++){const n=t[a];if(n.type!==e.Whitespace&&n.type!==e.Comment){if(isIdent(n)){if("or"===toLowerCaseAZ(n.value[4].value)){if(i)return!1;i=!0;continue}return!1}if(i&&s(n)){n.normalize();const e=parseMediaInParensFromSimpleBlock(n);return!1!==e&&{advance:a,node:new MediaOr(t.slice(0,a).flatMap((e=>e.tokens())),e)}}return!1}}return!1}function parseMediaAnd(t){let i=!1;for(let a=0;a<t.length;a++){const n=t[a];if(n.type!==e.Whitespace&&n.type!==e.Comment){if(isIdent(n)){if("and"===toLowerCaseAZ(n.value[4].value)){if(i)return!1;i=!0;continue}return!1}if(i&&s(n)){n.normalize();const e=parseMediaInParensFromSimpleBlock(n);return!1!==e&&{advance:a,node:new MediaAnd(t.slice(0,a).flatMap((e=>e.tokens())),e)}}return!1}}return!1}function parseFromTokens(e,t){const i=o(e,{onParseError:null==t?void 0:t.onParseError});return i.map(((e,a)=>{const n=parseMediaQuery(e);return 0==n&&!0===(null==t?void 0:t.preserveInvalidMediaQueries)?new MediaQueryInvalid(i[a]):n})).filter((e=>!!e))}function parse(e,t){const i=h({css:e},{onParseError:null==t?void 0:t.onParseError}),a=[];for(;!i.endOfFile();)a.push(i.nextToken());return a.push(i.nextToken()),parseFromTokens(a,t)}!function(e){e.Not="not",e.Only="only"}(g||(g={}));class CustomMedia{type=f.CustomMedia;name;mediaQueryList=null;trueOrFalseKeyword=null;constructor(e,t,i){this.name=e,this.mediaQueryList=t,this.trueOrFalseKeyword=i??null}getName(){for(let e=0;e<this.name.length;e++){const t=this.name[e];if(t[0]===d.Ident)return t[4].value}return""}getNameToken(){for(let e=0;e<this.name.length;e++){const t=this.name[e];if(t[0]===d.Ident)return t}return null}hasMediaQueryList(){return!!this.mediaQueryList}hasTrueKeyword(){if(!this.trueOrFalseKeyword)return!1;for(let e=0;e<this.trueOrFalseKeyword.length;e++){const t=this.trueOrFalseKeyword[e];if(t[0]!==d.Comment&&t[0]!==d.Whitespace)return t[0]===d.Ident&&"true"===toLowerCaseAZ(t[4].value)}return!1}hasFalseKeyword(){if(!this.trueOrFalseKeyword)return!1;for(let e=0;e<this.trueOrFalseKeyword.length;e++){const t=this.trueOrFalseKeyword[e];if(t[0]!==d.Comment&&t[0]!==d.Whitespace)return t[0]===d.Ident&&"false"===toLowerCaseAZ(t[4].value)}return!1}tokens(){if(this.trueOrFalseKeyword)return[...this.name,...this.trueOrFalseKeyword];if(!this.mediaQueryList)return[...this.name];const e=[];for(let t=0;t<this.mediaQueryList.length;t++){const i=this.mediaQueryList[t];0!==t&&e.push([d.Comma,",",-1,-1,void 0]),e.push(...i.tokens())}return[...this.name,...e]}toString(){return u(...this.tokens())}toJSON(){var e;return{type:this.type,string:this.toString(),nameValue:this.getName(),name:this.name,hasFalseKeyword:this.hasFalseKeyword(),hasTrueKeyword:this.hasTrueKeyword(),trueOrFalseKeyword:this.trueOrFalseKeyword,mediaQueryList:null==(e=this.mediaQueryList)?void 0:e.map((e=>e.toJSON()))}}isCustomMedia(){return CustomMedia.isCustomMedia(this)}static isCustomMedia(e){return!!e&&(e instanceof CustomMedia&&e.type===f.CustomMedia)}}function parseCustomMediaFromTokens(e,t){let i=[],a=e;for(let t=0;t<e.length;t++)if(e[t][0]!==d.Comment&&e[t][0]!==d.Whitespace){if(e[t][0]===d.Ident){if(e[t][4].value.startsWith("--")){i=e.slice(0,t+1),a=e.slice(t+1);break}}return!1}let n=!0;for(let e=0;e<a.length;e++)if(a[e][0]!==d.Comment&&a[e][0]!==d.Whitespace){if(a[e][0]===d.Ident){const t=toLowerCaseAZ(a[e][4].value);if("false"===t)continue;if("true"===t)continue}if(a[e][0]===d.EOF)break;n=!1}return n?new CustomMedia(i,null,a):new CustomMedia(i,parseFromTokens(m(a),t))}function parseCustomMedia(e,t){const i=h({css:e},{onParseError:null==t?void 0:t.onParseError}),a=[];for(;!i.endOfFile();)a.push(i.nextToken());return a.push(i.nextToken()),parseCustomMediaFromTokens(a,t)}function isCustomMedia(e){return CustomMedia.isCustomMedia(e)}function isGeneralEnclosed(e){return GeneralEnclosed.isGeneralEnclosed(e)}function isMediaAnd(e){return MediaAnd.isMediaAnd(e)}function isMediaConditionList(e){return isMediaConditionListWithAnd(e)||isMediaConditionListWithOr(e)}function isMediaConditionListWithAnd(e){return MediaConditionListWithAnd.isMediaConditionListWithAnd(e)}function isMediaConditionListWithOr(e){return MediaConditionListWithOr.isMediaConditionListWithOr(e)}function isMediaCondition(e){return MediaCondition.isMediaCondition(e)}function isMediaFeatureBoolean(e){return MediaFeatureBoolean.isMediaFeatureBoolean(e)}function isMediaFeatureName(e){return MediaFeatureName.isMediaFeatureName(e)}function isMediaFeatureValue(e){return MediaFeatureValue.isMediaFeatureValue(e)}function isMediaFeaturePlain(e){return MediaFeaturePlain.isMediaFeaturePlain(e)}function isMediaFeatureRange(e){return isMediaFeatureRangeNameValue(e)||isMediaFeatureRangeValueName(e)||isMediaFeatureRangeValueNameValue(e)}function isMediaFeatureRangeNameValue(e){return MediaFeatureRangeNameValue.isMediaFeatureRangeNameValue(e)}function isMediaFeatureRangeValueName(e){return MediaFeatureRangeValueName.isMediaFeatureRangeValueName(e)}function isMediaFeatureRangeValueNameValue(e){return MediaFeatureRangeValueNameValue.isMediaFeatureRangeValueNameValue(e)}function isMediaFeature(e){return MediaFeature.isMediaFeature(e)}function isMediaInParens(e){return MediaInParens.isMediaInParens(e)}function isMediaNot(e){return MediaNot.isMediaNot(e)}function isMediaOr(e){return MediaOr.isMediaOr(e)}function isMediaQuery(e){return isMediaQueryWithType(e)||isMediaQueryWithoutType(e)||isMediaQueryInvalid(e)}function isMediaQueryWithType(e){return MediaQueryWithType.isMediaQueryWithType(e)}function isMediaQueryWithoutType(e){return MediaQueryWithoutType.isMediaQueryWithoutType(e)}function isMediaQueryInvalid(e){return MediaQueryInvalid.isMediaQueryInvalid(e)}function typeFromToken(e){if(e[0]!==d.Ident)return!1;switch(toLowerCaseAZ(e[4].value)){case k.All:return k.All;case k.Print:return k.Print;case k.Screen:return k.Screen;case k.Tty:return k.Tty;case k.Tv:return k.Tv;case k.Projection:return k.Projection;case k.Handheld:return k.Handheld;case k.Braille:return k.Braille;case k.Embossed:return k.Embossed;case k.Aural:return k.Aural;case k.Speech:return k.Speech;default:return!1}}function cloneMediaQuery(e){const t=m(e.tokens()),i=parseFromTokens(t,{preserveInvalidMediaQueries:!0})[0];if(!i)throw new Error(`Failed to clone media query for : "${u(...t)}"`);if(isMediaQueryInvalid(e)&&isMediaQueryInvalid(i))return i;if(isMediaQueryWithType(e)&&isMediaQueryWithType(i))return i;if(isMediaQueryWithoutType(e)&&isMediaQueryWithoutType(i))return i;throw new Error(`Failed to clone media query for : "${u(...t)}"`)}!function(e){e.All="all",e.Print="print",e.Screen="screen",e.Tty="tty",e.Tv="tv",e.Projection="projection",e.Handheld="handheld",e.Braille="braille",e.Embossed="embossed",e.Aural="aural",e.Speech="speech"}(k||(k={}));export{CustomMedia,GeneralEnclosed,MediaAnd,MediaCondition,MediaConditionListWithAnd,MediaConditionListWithOr,MediaFeature,MediaFeatureBoolean,v as MediaFeatureEQ,y as MediaFeatureGT,p as MediaFeatureLT,MediaFeatureName,MediaFeaturePlain,MediaFeatureRangeNameValue,MediaFeatureRangeValueName,MediaFeatureRangeValueNameValue,MediaFeatureValue,MediaInParens,MediaNot,MediaOr,MediaQueryInvalid,g as MediaQueryModifier,MediaQueryWithType,MediaQueryWithoutType,k as MediaType,f as NodeType,cloneMediaQuery,comparisonFromTokens,invertComparison,isCustomMedia,isGeneralEnclosed,isMediaAnd,isMediaCondition,isMediaConditionList,isMediaConditionListWithAnd,isMediaConditionListWithOr,isMediaFeature,isMediaFeatureBoolean,isMediaFeatureName,isMediaFeaturePlain,isMediaFeatureRange,isMediaFeatureRangeNameValue,isMediaFeatureRangeValueName,isMediaFeatureRangeValueNameValue,isMediaFeatureValue,isMediaInParens,isMediaNot,isMediaOr,isMediaQuery,isMediaQueryInvalid,isMediaQueryWithType,isMediaQueryWithoutType,matchesComparison,matchesRatio,matchesRatioExactly,modifierFromToken,newMediaFeatureBoolean,newMediaFeaturePlain,parse,parseCustomMedia,parseCustomMediaFromTokens,parseFromTokens,typeFromToken}; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/custom-media.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/custom-media.d.ts new file mode 100644 index 00000000..6e2a33cb --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/custom-media.d.ts @@ -0,0 +1,44 @@ +import { CSSToken } from '@csstools/css-tokenizer'; +import { NodeType } from '../util/node-type'; +import { MediaQuery } from './media-query'; +export declare class CustomMedia { + type: NodeType; + name: Array<CSSToken>; + mediaQueryList: Array<MediaQuery> | null; + trueOrFalseKeyword: Array<CSSToken> | null; + constructor(name: Array<CSSToken>, mediaQueryList: Array<MediaQuery> | null, trueOrFalseKeyword?: Array<CSSToken>); + getName(): string; + getNameToken(): CSSToken | null; + hasMediaQueryList(): boolean; + hasTrueKeyword(): boolean; + hasFalseKeyword(): boolean; + tokens(): Array<CSSToken>; + toString(): string; + toJSON(): { + type: NodeType; + string: string; + nameValue: string; + name: CSSToken[]; + hasFalseKeyword: boolean; + hasTrueKeyword: boolean; + trueOrFalseKeyword: CSSToken[] | null; + mediaQueryList: ({ + type: NodeType; + string: string; + modifier: CSSToken[]; + mediaType: CSSToken[]; + and: CSSToken[] | undefined; + media: import("./media-condition").MediaCondition | undefined; + } | { + type: NodeType; + string: string; + media: import("./media-condition").MediaCondition; + } | { + type: NodeType; + string: string; + media: import("@csstools/css-parser-algorithms").ComponentValue[]; + })[] | undefined; + }; + isCustomMedia(): this is CustomMedia; + static isCustomMedia(x: unknown): x is CustomMedia; +} diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/general-enclosed.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/general-enclosed.d.ts new file mode 100644 index 00000000..5ab840f5 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/general-enclosed.d.ts @@ -0,0 +1,25 @@ +import { ComponentValue, ContainerNode } from '@csstools/css-parser-algorithms'; +import { CSSToken } from '@csstools/css-tokenizer'; +import { NodeType } from '../util/node-type'; +export declare class GeneralEnclosed { + type: NodeType; + value: ComponentValue; + constructor(value: ComponentValue); + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: ComponentValue): number | string; + at(index: number | string): ComponentValue | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: GeneralEnclosedWalkerEntry; + parent: GeneralEnclosedWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): { + type: NodeType; + tokens: CSSToken[]; + }; + isGeneralEnclosed(): this is GeneralEnclosed; + static isGeneralEnclosed(x: unknown): x is GeneralEnclosed; +} +export type GeneralEnclosedWalkerEntry = ComponentValue; +export type GeneralEnclosedWalkerParent = ContainerNode | GeneralEnclosed; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-and.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-and.d.ts new file mode 100644 index 00000000..ddd73d53 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-and.d.ts @@ -0,0 +1,23 @@ +import { CSSToken } from '@csstools/css-tokenizer'; +import { MediaInParens, MediaInParensWalkerEntry, MediaInParensWalkerParent } from './media-in-parens'; +import { NodeType } from '../util/node-type'; +export declare class MediaAnd { + type: NodeType; + modifier: Array<CSSToken>; + media: MediaInParens; + constructor(modifier: Array<CSSToken>, media: MediaInParens); + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaInParens): number | string; + at(index: number | string): MediaInParens | null; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaAndWalkerEntry; + parent: MediaAndWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): unknown; + isMediaAnd(): this is MediaAnd; + static isMediaAnd(x: unknown): x is MediaAnd; +} +export type MediaAndWalkerEntry = MediaInParensWalkerEntry | MediaInParens; +export type MediaAndWalkerParent = MediaInParensWalkerParent | MediaAnd; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-condition-list.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-condition-list.d.ts new file mode 100644 index 00000000..ddc51062 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-condition-list.d.ts @@ -0,0 +1,50 @@ +import { CSSToken } from '@csstools/css-tokenizer'; +import { MediaAnd, MediaAndWalkerEntry, MediaAndWalkerParent } from './media-and'; +import { MediaInParens } from './media-in-parens'; +import { MediaOr, MediaOrWalkerEntry, MediaOrWalkerParent } from './media-or'; +import { NodeType } from '../util/node-type'; +export type MediaConditionList = MediaConditionListWithAnd | MediaConditionListWithOr; +export declare class MediaConditionListWithAnd { + type: NodeType; + leading: MediaInParens; + list: Array<MediaAnd>; + before: Array<CSSToken>; + after: Array<CSSToken>; + constructor(leading: MediaInParens, list: Array<MediaAnd>, before?: Array<CSSToken>, after?: Array<CSSToken>); + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaInParens | MediaAnd): number | string; + at(index: number | string): MediaInParens | MediaAnd | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaConditionListWithAndWalkerEntry; + parent: MediaConditionListWithAndWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): unknown; + isMediaConditionListWithAnd(): this is MediaConditionListWithAnd; + static isMediaConditionListWithAnd(x: unknown): x is MediaConditionListWithAnd; +} +export type MediaConditionListWithAndWalkerEntry = MediaAndWalkerEntry | MediaAnd; +export type MediaConditionListWithAndWalkerParent = MediaAndWalkerParent | MediaConditionListWithAnd; +export declare class MediaConditionListWithOr { + type: NodeType; + leading: MediaInParens; + list: Array<MediaOr>; + before: Array<CSSToken>; + after: Array<CSSToken>; + constructor(leading: MediaInParens, list: Array<MediaOr>, before?: Array<CSSToken>, after?: Array<CSSToken>); + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaInParens | MediaOr): number | string; + at(index: number | string): MediaInParens | MediaOr | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaConditionListWithOrWalkerEntry; + parent: MediaConditionListWithOrWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): unknown; + isMediaConditionListWithOr(): this is MediaConditionListWithOr; + static isMediaConditionListWithOr(x: unknown): x is MediaConditionListWithOr; +} +export type MediaConditionListWithOrWalkerEntry = MediaOrWalkerEntry | MediaOr; +export type MediaConditionListWithOrWalkerParent = MediaOrWalkerParent | MediaConditionListWithOr; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-condition.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-condition.d.ts new file mode 100644 index 00000000..faf2b49d --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-condition.d.ts @@ -0,0 +1,24 @@ +import { CSSToken } from '@csstools/css-tokenizer'; +import { MediaConditionListWithAnd, MediaConditionListWithAndWalkerEntry, MediaConditionListWithAndWalkerParent, MediaConditionListWithOr, MediaConditionListWithOrWalkerEntry, MediaConditionListWithOrWalkerParent } from './media-condition-list'; +import { MediaInParens } from './media-in-parens'; +import { MediaNot, MediaNotWalkerEntry, MediaNotWalkerParent } from './media-not'; +import { NodeType } from '../util/node-type'; +export declare class MediaCondition { + type: NodeType; + media: MediaNot | MediaInParens | MediaConditionListWithAnd | MediaConditionListWithOr; + constructor(media: MediaNot | MediaInParens | MediaConditionListWithAnd | MediaConditionListWithOr); + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaNot | MediaInParens | MediaConditionListWithAnd | MediaConditionListWithOr): number | string; + at(index: number | string): MediaNot | MediaInParens | MediaConditionListWithAnd | MediaConditionListWithOr | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaConditionWalkerEntry; + parent: MediaConditionWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): unknown; + isMediaCondition(): this is MediaCondition; + static isMediaCondition(x: unknown): x is MediaCondition; +} +export type MediaConditionWalkerEntry = MediaNotWalkerEntry | MediaConditionListWithAndWalkerEntry | MediaConditionListWithOrWalkerEntry | MediaNot | MediaConditionListWithAnd | MediaConditionListWithOr; +export type MediaConditionWalkerParent = MediaNotWalkerParent | MediaConditionListWithAndWalkerParent | MediaConditionListWithOrWalkerParent | MediaCondition; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-boolean.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-boolean.d.ts new file mode 100644 index 00000000..a5c64ec1 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-boolean.d.ts @@ -0,0 +1,27 @@ +import { ComponentValue } from '@csstools/css-parser-algorithms'; +import { MediaFeatureName } from './media-feature-name'; +import { NodeType } from '../util/node-type'; +import { CSSToken } from '@csstools/css-tokenizer'; +export declare class MediaFeatureBoolean { + type: NodeType; + name: MediaFeatureName; + constructor(name: MediaFeatureName); + getName(): string; + getNameToken(): CSSToken; + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaFeatureName): number | string; + at(index: number | string): MediaFeatureName | undefined; + toJSON(): { + type: NodeType; + name: { + type: NodeType; + name: string; + tokens: CSSToken[]; + }; + tokens: CSSToken[]; + }; + isMediaFeatureBoolean(): this is MediaFeatureBoolean; + static isMediaFeatureBoolean(x: unknown): x is MediaFeatureBoolean; +} +export declare function parseMediaFeatureBoolean(componentValues: Array<ComponentValue>): false | MediaFeatureBoolean; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-comparison.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-comparison.d.ts new file mode 100644 index 00000000..37769657 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-comparison.d.ts @@ -0,0 +1,17 @@ +import { ComponentValue } from '@csstools/css-parser-algorithms'; +import { TokenDelim } from '@csstools/css-tokenizer'; +export declare enum MediaFeatureLT { + LT = "<", + LT_OR_EQ = "<=" +} +export declare enum MediaFeatureGT { + GT = ">", + GT_OR_EQ = ">=" +} +export declare enum MediaFeatureEQ { + EQ = "=" +} +export type MediaFeatureComparison = MediaFeatureLT | MediaFeatureGT | MediaFeatureEQ; +export declare function matchesComparison(componentValues: Array<ComponentValue>): false | [number, number]; +export declare function comparisonFromTokens(tokens: [TokenDelim, TokenDelim] | [TokenDelim]): MediaFeatureComparison | false; +export declare function invertComparison(operator: MediaFeatureComparison): MediaFeatureComparison | false; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-name.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-name.d.ts new file mode 100644 index 00000000..332b421a --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-name.d.ts @@ -0,0 +1,24 @@ +import { ComponentValue } from '@csstools/css-parser-algorithms'; +import { CSSToken } from '@csstools/css-tokenizer'; +import { NodeType } from '../util/node-type'; +export declare class MediaFeatureName { + type: NodeType; + name: ComponentValue; + before: Array<CSSToken>; + after: Array<CSSToken>; + constructor(name: ComponentValue, before?: Array<CSSToken>, after?: Array<CSSToken>); + getName(): string; + getNameToken(): CSSToken; + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: ComponentValue): number | string; + at(index: number | string): ComponentValue | undefined; + toJSON(): { + type: NodeType; + name: string; + tokens: CSSToken[]; + }; + isMediaFeatureName(): this is MediaFeatureName; + static isMediaFeatureName(x: unknown): x is MediaFeatureName; +} +export declare function parseMediaFeatureName(componentValues: Array<ComponentValue>): MediaFeatureName | false; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-plain.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-plain.d.ts new file mode 100644 index 00000000..32f22c40 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-plain.d.ts @@ -0,0 +1,42 @@ +import { ComponentValue } from '@csstools/css-parser-algorithms'; +import { CSSToken, TokenColon } from '@csstools/css-tokenizer'; +import { MediaFeatureName } from './media-feature-name'; +import { MediaFeatureValue, MediaFeatureValueWalkerEntry, MediaFeatureValueWalkerParent } from './media-feature-value'; +import { NodeType } from '../util/node-type'; +export declare class MediaFeaturePlain { + type: NodeType; + name: MediaFeatureName; + colon: TokenColon; + value: MediaFeatureValue; + constructor(name: MediaFeatureName, colon: TokenColon, value: MediaFeatureValue); + getName(): string; + getNameToken(): CSSToken; + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaFeatureName | MediaFeatureValue): number | string; + at(index: number | string): MediaFeatureName | MediaFeatureValue | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaFeaturePlainWalkerEntry; + parent: MediaFeaturePlainWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): { + type: NodeType; + name: { + type: NodeType; + name: string; + tokens: CSSToken[]; + }; + value: { + type: NodeType; + value: unknown; + tokens: CSSToken[]; + }; + tokens: CSSToken[]; + }; + isMediaFeaturePlain(): this is MediaFeaturePlain; + static isMediaFeaturePlain(x: unknown): x is MediaFeaturePlain; +} +export type MediaFeaturePlainWalkerEntry = MediaFeatureValueWalkerEntry | MediaFeatureValue; +export type MediaFeaturePlainWalkerParent = MediaFeatureValueWalkerParent | MediaFeaturePlain; +export declare function parseMediaFeaturePlain(componentValues: Array<ComponentValue>): MediaFeaturePlain | false; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-range.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-range.d.ts new file mode 100644 index 00000000..afe322ae --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-range.d.ts @@ -0,0 +1,123 @@ +import { ComponentValue } from '@csstools/css-parser-algorithms'; +import { CSSToken, TokenDelim } from '@csstools/css-tokenizer'; +import { MediaFeatureComparison } from './media-feature-comparison'; +import { MediaFeatureName } from './media-feature-name'; +import { MediaFeatureValue, MediaFeatureValueWalkerEntry, MediaFeatureValueWalkerParent } from './media-feature-value'; +import { NodeType } from '../util/node-type'; +export type MediaFeatureRange = MediaFeatureRangeNameValue | MediaFeatureRangeValueName | MediaFeatureRangeValueNameValue; +export declare class MediaFeatureRangeNameValue { + type: NodeType; + name: MediaFeatureName; + operator: [TokenDelim, TokenDelim] | [TokenDelim]; + value: MediaFeatureValue; + constructor(name: MediaFeatureName, operator: [TokenDelim, TokenDelim] | [TokenDelim], value: MediaFeatureValue); + operatorKind(): MediaFeatureComparison | false; + getName(): string; + getNameToken(): CSSToken; + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaFeatureName | MediaFeatureValue): number | string; + at(index: number | string): MediaFeatureName | MediaFeatureValue | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaFeatureRangeWalkerEntry; + parent: MediaFeatureRangeWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): { + type: NodeType; + name: { + type: NodeType; + name: string; + tokens: CSSToken[]; + }; + value: { + type: NodeType; + value: unknown; + tokens: CSSToken[]; + }; + tokens: CSSToken[]; + }; + isMediaFeatureRangeNameValue(): this is MediaFeatureRangeNameValue; + static isMediaFeatureRangeNameValue(x: unknown): x is MediaFeatureRangeNameValue; +} +export declare class MediaFeatureRangeValueName { + type: NodeType; + name: MediaFeatureName; + operator: [TokenDelim, TokenDelim] | [TokenDelim]; + value: MediaFeatureValue; + constructor(name: MediaFeatureName, operator: [TokenDelim, TokenDelim] | [TokenDelim], value: MediaFeatureValue); + operatorKind(): MediaFeatureComparison | false; + getName(): string; + getNameToken(): CSSToken; + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaFeatureName | MediaFeatureValue): number | string; + at(index: number | string): MediaFeatureName | MediaFeatureValue | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaFeatureRangeWalkerEntry; + parent: MediaFeatureRangeWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): { + type: NodeType; + name: { + type: NodeType; + name: string; + tokens: CSSToken[]; + }; + value: { + type: NodeType; + value: unknown; + tokens: CSSToken[]; + }; + tokens: CSSToken[]; + }; + isMediaFeatureRangeValueName(): this is MediaFeatureRangeValueName; + static isMediaFeatureRangeValueName(x: unknown): x is MediaFeatureRangeValueName; +} +export declare class MediaFeatureRangeValueNameValue { + type: NodeType; + name: MediaFeatureName; + valueOne: MediaFeatureValue; + valueOneOperator: [TokenDelim, TokenDelim] | [TokenDelim]; + valueTwo: MediaFeatureValue; + valueTwoOperator: [TokenDelim, TokenDelim] | [TokenDelim]; + constructor(name: MediaFeatureName, valueOne: MediaFeatureValue, valueOneOperator: [TokenDelim, TokenDelim] | [TokenDelim], valueTwo: MediaFeatureValue, valueTwoOperator: [TokenDelim, TokenDelim] | [TokenDelim]); + valueOneOperatorKind(): MediaFeatureComparison | false; + valueTwoOperatorKind(): MediaFeatureComparison | false; + getName(): string; + getNameToken(): CSSToken; + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaFeatureName | MediaFeatureValue): number | string; + at(index: number | string): MediaFeatureName | MediaFeatureValue | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaFeatureRangeWalkerEntry; + parent: MediaFeatureRangeWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): { + type: NodeType; + name: { + type: NodeType; + name: string; + tokens: CSSToken[]; + }; + valueOne: { + type: NodeType; + value: unknown; + tokens: CSSToken[]; + }; + valueTwo: { + type: NodeType; + value: unknown; + tokens: CSSToken[]; + }; + tokens: CSSToken[]; + }; + isMediaFeatureRangeValueNameValue(): this is MediaFeatureRangeValueNameValue; + static isMediaFeatureRangeValueNameValue(x: unknown): x is MediaFeatureRangeValueNameValue; +} +export type MediaFeatureRangeWalkerEntry = MediaFeatureValueWalkerEntry | MediaFeatureValue; +export type MediaFeatureRangeWalkerParent = MediaFeatureValueWalkerParent | MediaFeatureRange; +export declare function parseMediaFeatureRange(componentValues: Array<ComponentValue>): MediaFeatureRange | false; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-value.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-value.d.ts new file mode 100644 index 00000000..dda072bb --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature-value.d.ts @@ -0,0 +1,31 @@ +import { ComponentValue, ContainerNode } from '@csstools/css-parser-algorithms'; +import { CSSToken } from '@csstools/css-tokenizer'; +import { NodeType } from '../util/node-type'; +export declare class MediaFeatureValue { + type: NodeType; + value: ComponentValue | Array<ComponentValue>; + before: Array<CSSToken>; + after: Array<CSSToken>; + constructor(value: ComponentValue | Array<ComponentValue>, before?: Array<CSSToken>, after?: Array<CSSToken>); + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: ComponentValue): number | string; + at(index: number | string): ComponentValue | Array<ComponentValue> | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaFeatureValueWalkerEntry; + parent: MediaFeatureValueWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): { + type: NodeType; + value: unknown; + tokens: CSSToken[]; + }; + isMediaFeatureValue(): this is MediaFeatureValue; + static isMediaFeatureValue(x: unknown): x is MediaFeatureValue; +} +export type MediaFeatureValueWalkerEntry = ComponentValue; +export type MediaFeatureValueWalkerParent = ContainerNode | MediaFeatureValue; +export declare function parseMediaFeatureValue(componentValues: Array<ComponentValue>, inRangeContext?: boolean): MediaFeatureValue | false; +export declare function matchesRatioExactly(componentValues: Array<ComponentValue>): number[] | -1; +export declare function matchesRatio(componentValues: Array<ComponentValue>): number[] | -1; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature.d.ts new file mode 100644 index 00000000..bf9c0384 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-feature.d.ts @@ -0,0 +1,45 @@ +import { SimpleBlockNode } from '@csstools/css-parser-algorithms'; +import { CSSToken } from '@csstools/css-tokenizer'; +import { MediaFeatureBoolean } from './media-feature-boolean'; +import { MediaFeaturePlain, MediaFeaturePlainWalkerEntry, MediaFeaturePlainWalkerParent } from './media-feature-plain'; +import { MediaFeatureRange, MediaFeatureRangeWalkerEntry, MediaFeatureRangeWalkerParent } from './media-feature-range'; +import { NodeType } from '../util/node-type'; +export declare class MediaFeature { + type: NodeType; + feature: MediaFeaturePlain | MediaFeatureBoolean | MediaFeatureRange; + before: Array<CSSToken>; + after: Array<CSSToken>; + constructor(feature: MediaFeaturePlain | MediaFeatureBoolean | MediaFeatureRange, before?: Array<CSSToken>, after?: Array<CSSToken>); + getName(): string; + getNameToken(): CSSToken; + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaFeaturePlain | MediaFeatureBoolean | MediaFeatureRange): number | string; + at(index: number | string): MediaFeatureBoolean | MediaFeaturePlain | MediaFeatureRange | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaFeatureWalkerEntry; + parent: MediaFeatureWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): { + type: NodeType; + feature: { + type: NodeType; + name: { + type: NodeType; + name: string; + tokens: CSSToken[]; + }; + tokens: CSSToken[]; + }; + before: CSSToken[]; + after: CSSToken[]; + }; + isMediaFeature(): this is MediaFeature; + static isMediaFeature(x: unknown): x is MediaFeature; +} +export type MediaFeatureWalkerEntry = MediaFeaturePlainWalkerEntry | MediaFeatureRangeWalkerEntry | MediaFeaturePlain | MediaFeatureBoolean | MediaFeatureRange; +export type MediaFeatureWalkerParent = MediaFeaturePlainWalkerParent | MediaFeatureRangeWalkerParent | MediaFeature; +export declare function parseMediaFeature(simpleBlock: SimpleBlockNode, before?: Array<CSSToken>, after?: Array<CSSToken>): false | MediaFeature; +export declare function newMediaFeatureBoolean(name: string): MediaFeature; +export declare function newMediaFeaturePlain(name: string, ...value: Array<CSSToken>): MediaFeature; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-in-parens.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-in-parens.d.ts new file mode 100644 index 00000000..904a0725 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-in-parens.d.ts @@ -0,0 +1,41 @@ +import { ComponentValue, ContainerNode } from '@csstools/css-parser-algorithms'; +import { CSSToken } from '@csstools/css-tokenizer'; +import { GeneralEnclosed } from './general-enclosed'; +import { MediaAnd } from './media-and'; +import { MediaCondition } from './media-condition'; +import { MediaConditionList } from './media-condition-list'; +import { MediaFeature } from './media-feature'; +import { MediaFeatureBoolean } from './media-feature-boolean'; +import { MediaFeatureName } from './media-feature-name'; +import { MediaFeaturePlain } from './media-feature-plain'; +import { MediaFeatureRange } from './media-feature-range'; +import { MediaFeatureValue } from './media-feature-value'; +import { NodeType } from '../util/node-type'; +import { MediaNot } from './media-not'; +import { MediaOr } from './media-or'; +export declare class MediaInParens { + type: NodeType; + media: MediaCondition | MediaFeature | GeneralEnclosed; + before: Array<CSSToken>; + after: Array<CSSToken>; + constructor(media: MediaCondition | MediaFeature | GeneralEnclosed, before?: Array<CSSToken>, after?: Array<CSSToken>); + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaCondition | MediaFeature | GeneralEnclosed): number | string; + at(index: number | string): MediaCondition | MediaFeature | GeneralEnclosed | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaInParensWalkerEntry; + parent: MediaInParensWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): { + type: NodeType; + media: unknown; + before: CSSToken[]; + after: CSSToken[]; + }; + isMediaInParens(): this is MediaInParens; + static isMediaInParens(x: unknown): x is MediaInParens; +} +export type MediaInParensWalkerEntry = ComponentValue | GeneralEnclosed | MediaAnd | MediaNot | MediaOr | MediaConditionList | MediaCondition | MediaFeatureBoolean | MediaFeatureName | MediaFeaturePlain | MediaFeatureRange | MediaFeatureValue | MediaFeature | GeneralEnclosed | MediaInParens; +export type MediaInParensWalkerParent = ContainerNode | GeneralEnclosed | MediaAnd | MediaNot | MediaOr | MediaConditionList | MediaCondition | MediaFeatureBoolean | MediaFeatureName | MediaFeaturePlain | MediaFeatureRange | MediaFeatureValue | MediaFeature | GeneralEnclosed | MediaInParens; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-not.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-not.d.ts new file mode 100644 index 00000000..2bedcaa3 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-not.d.ts @@ -0,0 +1,32 @@ +import { CSSToken } from '@csstools/css-tokenizer'; +import { MediaInParens, MediaInParensWalkerEntry, MediaInParensWalkerParent } from './media-in-parens'; +import { NodeType } from '../util/node-type'; +export declare class MediaNot { + type: NodeType; + modifier: Array<CSSToken>; + media: MediaInParens; + constructor(modifier: Array<CSSToken>, media: MediaInParens); + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaInParens): number | string; + at(index: number | string): MediaInParens | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaNotWalkerEntry; + parent: MediaNotWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): { + type: NodeType; + modifier: CSSToken[]; + media: { + type: NodeType; + media: unknown; + before: CSSToken[]; + after: CSSToken[]; + }; + }; + isMediaNot(): this is MediaNot; + static isMediaNot(x: unknown): x is MediaNot; +} +export type MediaNotWalkerEntry = MediaInParensWalkerEntry | MediaInParens; +export type MediaNotWalkerParent = MediaInParensWalkerParent | MediaNot; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-or.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-or.d.ts new file mode 100644 index 00000000..4459412d --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-or.d.ts @@ -0,0 +1,32 @@ +import { CSSToken } from '@csstools/css-tokenizer'; +import { MediaInParens, MediaInParensWalkerEntry, MediaInParensWalkerParent } from './media-in-parens'; +import { NodeType } from '../util/node-type'; +export declare class MediaOr { + type: NodeType; + modifier: Array<CSSToken>; + media: MediaInParens; + constructor(modifier: Array<CSSToken>, media: MediaInParens); + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaInParens): number | string; + at(index: number | string): MediaInParens | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaOrWalkerEntry; + parent: MediaOrWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): { + type: NodeType; + modifier: CSSToken[]; + media: { + type: NodeType; + media: unknown; + before: CSSToken[]; + after: CSSToken[]; + }; + }; + isMediaOr(): this is MediaOr; + static isMediaOr(x: unknown): x is MediaOr; +} +export type MediaOrWalkerEntry = MediaInParensWalkerEntry | MediaInParens; +export type MediaOrWalkerParent = MediaInParensWalkerParent | MediaOr; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-query-modifier.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-query-modifier.d.ts new file mode 100644 index 00000000..df9733cb --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-query-modifier.d.ts @@ -0,0 +1,6 @@ +import { TokenIdent } from '@csstools/css-tokenizer'; +export declare enum MediaQueryModifier { + Not = "not", + Only = "only" +} +export declare function modifierFromToken(token: TokenIdent): MediaQueryModifier | false; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-query.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-query.d.ts new file mode 100644 index 00000000..aa77dee0 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-query.d.ts @@ -0,0 +1,83 @@ +import { ComponentValue } from '@csstools/css-parser-algorithms'; +import { CSSToken } from '@csstools/css-tokenizer'; +import { NodeType } from '../util/node-type'; +import { MediaCondition, MediaConditionWalkerEntry, MediaConditionWalkerParent } from './media-condition'; +export type MediaQuery = MediaQueryWithType | MediaQueryWithoutType | MediaQueryInvalid; +export declare class MediaQueryWithType { + type: NodeType; + modifier: Array<CSSToken>; + mediaType: Array<CSSToken>; + and: Array<CSSToken> | undefined; + media: MediaCondition | undefined; + constructor(modifier: Array<CSSToken>, mediaType: Array<CSSToken>, and?: Array<CSSToken> | undefined, media?: MediaCondition | undefined); + getModifier(): string; + negateQuery(): MediaQuery; + getMediaType(): string; + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaCondition): number | string; + at(index: number | string): MediaCondition | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaQueryWithTypeWalkerEntry; + parent: MediaQueryWithTypeWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): { + type: NodeType; + string: string; + modifier: CSSToken[]; + mediaType: CSSToken[]; + and: CSSToken[] | undefined; + media: MediaCondition | undefined; + }; + isMediaQueryWithType(): this is MediaQueryWithType; + static isMediaQueryWithType(x: unknown): x is MediaQueryWithType; +} +export type MediaQueryWithTypeWalkerEntry = MediaConditionWalkerEntry | MediaCondition; +export type MediaQueryWithTypeWalkerParent = MediaConditionWalkerParent | MediaQueryWithType; +export declare class MediaQueryWithoutType { + type: NodeType; + media: MediaCondition; + constructor(media: MediaCondition); + negateQuery(): MediaQuery; + tokens(): Array<CSSToken>; + toString(): string; + indexOf(item: MediaCondition): number | string; + at(index: number | string): MediaCondition | undefined; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaQueryWithoutTypeWalkerEntry; + parent: MediaQueryWithoutTypeWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): { + type: NodeType; + string: string; + media: MediaCondition; + }; + isMediaQueryWithoutType(): this is MediaQueryWithoutType; + static isMediaQueryWithoutType(x: unknown): x is MediaQueryWithoutType; +} +export type MediaQueryWithoutTypeWalkerEntry = MediaConditionWalkerEntry | MediaCondition; +export type MediaQueryWithoutTypeWalkerParent = MediaConditionWalkerParent | MediaQueryWithoutType; +export declare class MediaQueryInvalid { + type: NodeType; + media: Array<ComponentValue>; + constructor(media: Array<ComponentValue>); + negateQuery(): MediaQuery; + tokens(): Array<CSSToken>; + toString(): string; + walk<T extends Record<string, unknown>>(cb: (entry: { + node: MediaQueryInvalidWalkerEntry; + parent: MediaQueryInvalidWalkerParent; + state?: T; + }, index: number | string) => boolean | void, state?: T): false | undefined; + toJSON(): { + type: NodeType; + string: string; + media: ComponentValue[]; + }; + isMediaQueryInvalid(): this is MediaQueryInvalid; + static isMediaQueryInvalid(x: unknown): x is MediaQueryInvalid; +} +export type MediaQueryInvalidWalkerEntry = ComponentValue; +export type MediaQueryInvalidWalkerParent = ComponentValue | MediaQueryInvalid; diff --git a/node_modules/@csstools/media-query-list-parser/dist/nodes/media-type.d.ts b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-type.d.ts new file mode 100644 index 00000000..b7924b76 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/nodes/media-type.d.ts @@ -0,0 +1,24 @@ +import { TokenIdent } from '@csstools/css-tokenizer'; +export declare enum MediaType { + /** Always matches */ + All = "all", + Print = "print", + Screen = "screen", + /** Never matches */ + Tty = "tty", + /** Never matches */ + Tv = "tv", + /** Never matches */ + Projection = "projection", + /** Never matches */ + Handheld = "handheld", + /** Never matches */ + Braille = "braille", + /** Never matches */ + Embossed = "embossed", + /** Never matches */ + Aural = "aural", + /** Never matches */ + Speech = "speech" +} +export declare function typeFromToken(token: TokenIdent): MediaType | false; diff --git a/node_modules/@csstools/media-query-list-parser/dist/parser/parse-custom-media.d.ts b/node_modules/@csstools/media-query-list-parser/dist/parser/parse-custom-media.d.ts new file mode 100644 index 00000000..1be3d0f3 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/parser/parse-custom-media.d.ts @@ -0,0 +1,8 @@ +import { CSSToken, ParseError } from '@csstools/css-tokenizer'; +import { CustomMedia } from '../nodes/custom-media'; +export type Options = { + preserveInvalidMediaQueries?: boolean; + onParseError?: (error: ParseError) => void; +}; +export declare function parseCustomMediaFromTokens(tokens: Array<CSSToken>, options?: Options): CustomMedia | false; +export declare function parseCustomMedia(source: string, options?: Options): CustomMedia | false; diff --git a/node_modules/@csstools/media-query-list-parser/dist/parser/parse-media-query.d.ts b/node_modules/@csstools/media-query-list-parser/dist/parser/parse-media-query.d.ts new file mode 100644 index 00000000..3801d178 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/parser/parse-media-query.d.ts @@ -0,0 +1,24 @@ +import { ComponentValue, SimpleBlockNode } from '@csstools/css-parser-algorithms'; +import { MediaAnd } from '../nodes/media-and'; +import { MediaCondition } from '../nodes/media-condition'; +import { MediaConditionListWithAnd, MediaConditionListWithOr } from '../nodes/media-condition-list'; +import { MediaInParens } from '../nodes/media-in-parens'; +import { MediaNot } from '../nodes/media-not'; +import { MediaOr } from '../nodes/media-or'; +import { MediaQuery } from '../nodes/media-query'; +export declare function parseMediaQuery(componentValues: Array<ComponentValue>): MediaQuery | false; +export declare function parseMediaConditionListWithOr(componentValues: Array<ComponentValue>): MediaConditionListWithOr | false; +export declare function parseMediaConditionListWithAnd(componentValues: Array<ComponentValue>): MediaConditionListWithAnd | false; +export declare function parseMediaCondition(componentValues: Array<ComponentValue>): MediaCondition | false; +export declare function parseMediaConditionWithoutOr(componentValues: Array<ComponentValue>): MediaCondition | false; +export declare function parseMediaInParens(componentValues: Array<ComponentValue>): MediaInParens | false; +export declare function parseMediaInParensFromSimpleBlock(simpleBlock: SimpleBlockNode): MediaInParens | false; +export declare function parseMediaNot(componentValues: Array<ComponentValue>): MediaNot | false; +export declare function parseMediaOr(componentValues: Array<ComponentValue>): false | { + advance: number; + node: MediaOr; +}; +export declare function parseMediaAnd(componentValues: Array<ComponentValue>): false | { + advance: number; + node: MediaAnd; +}; diff --git a/node_modules/@csstools/media-query-list-parser/dist/parser/parse.d.ts b/node_modules/@csstools/media-query-list-parser/dist/parser/parse.d.ts new file mode 100644 index 00000000..a09339bd --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/parser/parse.d.ts @@ -0,0 +1,8 @@ +import { CSSToken, ParseError } from '@csstools/css-tokenizer'; +import { MediaQuery } from '../nodes/media-query'; +export type Options = { + preserveInvalidMediaQueries?: boolean; + onParseError?: (error: ParseError) => void; +}; +export declare function parseFromTokens(tokens: Array<CSSToken>, options?: Options): MediaQuery[]; +export declare function parse(source: string, options?: Options): MediaQuery[]; diff --git a/node_modules/@csstools/media-query-list-parser/dist/util/clone-media-query.d.ts b/node_modules/@csstools/media-query-list-parser/dist/util/clone-media-query.d.ts new file mode 100644 index 00000000..e0702c23 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/util/clone-media-query.d.ts @@ -0,0 +1,2 @@ +import { MediaQueryInvalid, MediaQueryWithoutType, MediaQueryWithType } from '../nodes/media-query'; +export declare function cloneMediaQuery<T extends MediaQueryWithType | MediaQueryWithoutType | MediaQueryInvalid>(x: T): T; diff --git a/node_modules/@csstools/media-query-list-parser/dist/util/component-value-is.d.ts b/node_modules/@csstools/media-query-list-parser/dist/util/component-value-is.d.ts new file mode 100644 index 00000000..f0763807 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/util/component-value-is.d.ts @@ -0,0 +1,5 @@ +import { ComponentValue } from '@csstools/css-parser-algorithms'; +export declare function isNumber(componentValue: ComponentValue): boolean; +export declare function isDimension(componentValue: ComponentValue): boolean; +export declare function isIdent(componentValue: ComponentValue): boolean; +export declare function isEnvironmentVariable(componentValue: ComponentValue): boolean; diff --git a/node_modules/@csstools/media-query-list-parser/dist/util/node-type.d.ts b/node_modules/@csstools/media-query-list-parser/dist/util/node-type.d.ts new file mode 100644 index 00000000..935e6eb5 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/util/node-type.d.ts @@ -0,0 +1,22 @@ +export declare enum NodeType { + CustomMedia = "custom-media", + GeneralEnclosed = "general-enclosed", + MediaAnd = "media-and", + MediaCondition = "media-condition", + MediaConditionListWithAnd = "media-condition-list-and", + MediaConditionListWithOr = "media-condition-list-or", + MediaFeature = "media-feature", + MediaFeatureBoolean = "mf-boolean", + MediaFeatureName = "mf-name", + MediaFeaturePlain = "mf-plain", + MediaFeatureRangeNameValue = "mf-range-name-value", + MediaFeatureRangeValueName = "mf-range-value-name", + MediaFeatureRangeValueNameValue = "mf-range-value-name-value", + MediaFeatureValue = "mf-value", + MediaInParens = "media-in-parens", + MediaNot = "media-not", + MediaOr = "media-or", + MediaQueryWithType = "media-query-with-type", + MediaQueryWithoutType = "media-query-without-type", + MediaQueryInvalid = "media-query-invalid" +} diff --git a/node_modules/@csstools/media-query-list-parser/dist/util/to-lower-case-a-z.d.ts b/node_modules/@csstools/media-query-list-parser/dist/util/to-lower-case-a-z.d.ts new file mode 100644 index 00000000..396b252e --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/util/to-lower-case-a-z.d.ts @@ -0,0 +1 @@ +export declare function toLowerCaseAZ(x: string): string; diff --git a/node_modules/@csstools/media-query-list-parser/dist/util/type-predicates.d.ts b/node_modules/@csstools/media-query-list-parser/dist/util/type-predicates.d.ts new file mode 100644 index 00000000..2313f29b --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/dist/util/type-predicates.d.ts @@ -0,0 +1,37 @@ +import { GeneralEnclosed } from '../nodes/general-enclosed'; +import { MediaAnd } from '../nodes/media-and'; +import { MediaCondition } from '../nodes/media-condition'; +import { MediaConditionList, MediaConditionListWithAnd, MediaConditionListWithOr } from '../nodes/media-condition-list'; +import { MediaFeature } from '../nodes/media-feature'; +import { MediaFeatureBoolean } from '../nodes/media-feature-boolean'; +import { MediaFeatureName } from '../nodes/media-feature-name'; +import { MediaFeaturePlain } from '../nodes/media-feature-plain'; +import { MediaFeatureRange, MediaFeatureRangeNameValue, MediaFeatureRangeValueName, MediaFeatureRangeValueNameValue } from '../nodes/media-feature-range'; +import { MediaFeatureValue } from '../nodes/media-feature-value'; +import { MediaInParens } from '../nodes/media-in-parens'; +import { MediaNot } from '../nodes/media-not'; +import { MediaOr } from '../nodes/media-or'; +import { MediaQuery, MediaQueryInvalid, MediaQueryWithoutType, MediaQueryWithType } from '../nodes/media-query'; +export declare function isCustomMedia(x: unknown): x is GeneralEnclosed; +export declare function isGeneralEnclosed(x: unknown): x is GeneralEnclosed; +export declare function isMediaAnd(x: unknown): x is MediaAnd; +export declare function isMediaConditionList(x: unknown): x is MediaConditionList; +export declare function isMediaConditionListWithAnd(x: unknown): x is MediaConditionListWithAnd; +export declare function isMediaConditionListWithOr(x: unknown): x is MediaConditionListWithOr; +export declare function isMediaCondition(x: unknown): x is MediaCondition; +export declare function isMediaFeatureBoolean(x: unknown): x is MediaFeatureBoolean; +export declare function isMediaFeatureName(x: unknown): x is MediaFeatureName; +export declare function isMediaFeatureValue(x: unknown): x is MediaFeatureValue; +export declare function isMediaFeaturePlain(x: unknown): x is MediaFeaturePlain; +export declare function isMediaFeatureRange(x: unknown): x is MediaFeatureRange; +export declare function isMediaFeatureRangeNameValue(x: unknown): x is MediaFeatureRangeNameValue; +export declare function isMediaFeatureRangeValueName(x: unknown): x is MediaFeatureRangeValueName; +export declare function isMediaFeatureRangeValueNameValue(x: unknown): x is MediaFeatureRangeValueNameValue; +export declare function isMediaFeature(x: unknown): x is MediaFeature; +export declare function isMediaInParens(x: unknown): x is MediaInParens; +export declare function isMediaNot(x: unknown): x is MediaNot; +export declare function isMediaOr(x: unknown): x is MediaOr; +export declare function isMediaQuery(x: unknown): x is MediaQuery; +export declare function isMediaQueryWithType(x: unknown): x is MediaQueryWithType; +export declare function isMediaQueryWithoutType(x: unknown): x is MediaQueryWithoutType; +export declare function isMediaQueryInvalid(x: unknown): x is MediaQueryInvalid; diff --git a/node_modules/@csstools/media-query-list-parser/package.json b/node_modules/@csstools/media-query-list-parser/package.json new file mode 100644 index 00000000..d9037c74 --- /dev/null +++ b/node_modules/@csstools/media-query-list-parser/package.json @@ -0,0 +1,74 @@ +{ + "name": "@csstools/media-query-list-parser", + "description": "Parse CSS media query lists.", + "version": "2.1.5", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "peerDependencies": { + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1" + }, + "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", + "test:rewrite-expects": "REWRITE_EXPECTS=true node ./test/test.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "packages/media-query-list-parser" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "css", + "media query", + "parser" + ], + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-cascade-layers/CHANGELOG.md b/node_modules/@csstools/postcss-cascade-layers/CHANGELOG.md new file mode 100644 index 00000000..ebe49f70 --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/CHANGELOG.md @@ -0,0 +1,87 @@ +# Changes to PostCSS Cascade Layers + +### 4.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) +- Updated [`@csstools/selector-specificity`](/packages/selector-specificity) to [`3.0.0`](/packages/selector-specificity/CHANGELOG.md#300) (major) + +### 3.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 3.0.0 + +_January 24, 2023_ + +- Run `postcss-cascade-layers` late compared to other PostCSS plugins (breaking) + +_This will be the last time we change this after several times back and forth. +We are sticking with this configuration now._ + +### 2.0.0 + +_November 14, 2022_ + +- Run `postcss-cascade-layers` early compared to other PostCSS plugins (breaking) +- Updated: Support for Node v14+ (major). +- Fix: Do not throw when a selector is invalid, show a warning instead. + +### 1.1.1 + +_September 17, 2022_ + +- Fix pre-defined layer order in nested `@layer` rules. + +### 1.1.0 + +_September 14, 2022_ + +- Add support for `@scope` and `@container` as parent rules for `@layer` + +### 1.0.6 + +_September 7, 2022_ + +- Fix broken `@keyframes` in `@layer`. + +### 1.0.5 + +_July 8, 2022_ + +- Fix case insensitive `@layer` matching (`@LaYeR`). +- Updated `@csstools/selector-specificity` to `2.0.2` (patch) + +### 1.0.4 + +_June 23, 2022_ + +- Fix selector order with any pseudo element. This plugin will no longer re-order selectors. + +### 1.0.3 + +_June 4, 2022_ + +- Update `@csstools/selector-specificity` (major) + +### 1.0.2 + +_May 20, 2022_ + +- Use only simple `:not(#\#)` selectors to adjust specificity. + +### 1.0.1 + +_May 17, 2022_ + +- Process CSS after most other plugins to ensure correct analysis and transformation of sugary CSS. +- Fix selector order with `:before` and other pseudo elements. + +### 1.0.0 + +_May 12, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-cascade-layers/LICENSE.md b/node_modules/@csstools/postcss-cascade-layers/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-cascade-layers/README.md b/node_modules/@csstools/postcss-cascade-layers/README.md new file mode 100644 index 00000000..0bbceb7c --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/README.md @@ -0,0 +1,202 @@ +# PostCSS Cascade Layers [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-cascade-layers.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/cascade-layers.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +[PostCSS Cascade Layers] lets you use `@layer` following the [Cascade Layers Specification]. For more information on layers, checkout [A Complete Guide to CSS Cascade Layers] by Miriam Suzanne. + +```pcss + +target { + color: purple; +} + +@layer { + target { + color: green; + } +} + + +/* becomes */ + + +target:not(#\#) { + color: purple; +} + +target { + color: green; + } + +``` + +## How it works + +[PostCSS Cascade Layers] creates "layers" of specificity. + +It applies extra specificity on all your styles based on : +- the most specific selector found +- the order in which layers are defined + +```css +@layer A, B; + +@layer B { + .a-less-specific-selector { + /* styles */ + } +} + +@layer A { + #something #very-specific { + /* styles */ + } +} + +@layer C { + .a-less-specific-selector { + /* styles */ + } +} +``` + +most specific selector : +- `#something #very-specific` +- `[2, 0, 0]` +- `2 + 1` -> `3` to ensure there is no overlap + +the order in which layers are defined : +- `A` +- `B` +- `C` + +| layer | previous adjustment | specificity adjustment | selector | +| ------ | ------ | ----------- | --- | +| `A` | `0` | `0 + 0 = 0` | N/A | +| `B` | `0` | `0 + 3 = 3` | `:not(#\#):not(#\#):not(#\#)` | +| `C` | `3` | `3 + 3 = 6` | `:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)` | + +This approach lets more important (later) layers always override less important (earlier) layers.<br> +And layers have enough room internally so that each selector works and overrides as expected. + +More layers with more specificity will cause longer `:not(...)` selectors to be generated. + +⚠️ For this to work the plugin needs to analyze your entire stylesheet at once.<br> +If you have different assets that are unaware of each other it will not work correctly as the analysis will be incorrect. + +## Usage + +Add [PostCSS Cascade Layers] to your project: + +```bash +npm install postcss @csstools/postcss-cascade-layers --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssCascadeLayers = require('@csstools/postcss-cascade-layers'); + +postcss([ + postcssCascadeLayers(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Cascade Layers] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### onRevertLayerKeyword + +The `onRevertLayerKeyword` option enables warnings if `revert-layer` is used. +Transforming `revert-layer` for older browsers is not possible in this plugin. + +Defaults to `warn` + +```js +postcssCascadeLayers({ onRevertLayerKeyword: 'warn' }) // 'warn' | false +``` + +```pcss +/* [postcss-cascade-layers]: handling "revert-layer" is unsupported by this plugin and will cause style differences between browser versions. */ +@layer { + .foo { + color: revert-layer; + } +} +``` + +### onConditionalRulesChangingLayerOrder + +The `onConditionalRulesChangingLayerOrder` option enables warnings if layers are declared in multiple different orders in conditional rules. +Transforming these layers correctly for older browsers is not possible in this plugin. + +Defaults to `warn` + +```js +postcssCascadeLayers({ onConditionalRulesChangingLayerOrder: 'warn' }) // 'warn' | false +``` + +```pcss +/* [postcss-cascade-layers]: handling different layer orders in conditional rules is unsupported by this plugin and will cause style differences between browser versions. */ +@media (min-width: 10px) { + @layer B { + .foo { + color: red; + } + } +} + +@layer A { + .foo { + color: pink; + } +} + +@layer B { + .foo { + color: red; + } +} +``` + +### onImportLayerRule + +The `@import` at-rule can also be used with cascade layers, specifically to create a new layer like so: +```css +@import 'theme.css' layer(utilities); +``` +If your CSS uses `@import` with layers, you will also need the [postcss-import] plugin. This plugin alone will not handle the `@import` at-rule. + +This plugin will warn you when it detects that [postcss-import] did not transform`@import` at-rules. + +```js +postcssCascadeLayers({ onImportLayerRule: 'warn' }) // 'warn' | false +``` + +### Contributors +The contributors to this plugin were [Olu Niyi-Awosusi] and [Sana Javed] from [Oddbird] and Romain Menke. + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#cascade-layers +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-cascade-layers + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Cascade Layers]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-cascade-layers +[Cascade Layers Specification]: https://www.w3.org/TR/css-cascade-5/#layering +[A Complete Guide to CSS Cascade Layers]: https://css-tricks.com/css-cascade-layers/ +[Olu Niyi-Awosusi]: https://github.com/oluoluoxenfree +[Sana Javed]: https://github.com/sanajaved7 +[Oddbird]: https://github.com/oddbird +[postcss-import]: https://github.com/postcss/postcss-import diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/adjust-selector-specificity.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/adjust-selector-specificity.d.ts new file mode 100644 index 00000000..af7b5e19 --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/adjust-selector-specificity.d.ts @@ -0,0 +1 @@ +export declare function adjustSelectorSpecificity(selector: string, amount: number): string; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/clean-blocks.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/clean-blocks.d.ts new file mode 100644 index 00000000..b9f2a564 --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/clean-blocks.d.ts @@ -0,0 +1,3 @@ +import type { Container } from 'postcss'; +export declare function removeEmptyDescendantBlocks(block: Container | undefined): void; +export declare function removeEmptyAncestorBlocks(block: Container | undefined): void; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/constants.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/constants.d.ts new file mode 100644 index 00000000..6a4c9c36 --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/constants.d.ts @@ -0,0 +1,8 @@ +/** @constant {string} INVALID_LAYER_NAME Used to replace "layer" temporarily when an invalid layer is detected. This allows us to ignore this rule in further processing. */ +export declare const INVALID_LAYER_NAME = "csstools-invalid-layer"; +/** @constant {string} WITH_SELECTORS_LAYER_NAME Used to replace "layer" temporarily for any layer at rules that contain selectors. This allows us to sort these differently from other layer at rules. */ +export declare const WITH_SELECTORS_LAYER_NAME = "csstools-layer-with-selector-rules"; +export declare const ANONYMOUS_LAYER_SUFFIX = "6efdb677-bb05-44e5-840f-29d2175862fd"; +export declare const IMPLICIT_LAYER_SUFFIX = "b147acf6-11a6-4338-a4d0-80aef4cd1a2f"; +export declare const CONDITIONAL_ATRULES: string[]; +export declare const ATRULES_WITH_NON_SELECTOR_BLOCK_LISTS: string[]; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/desugar-and-parse-layer-names.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/desugar-and-parse-layer-names.d.ts new file mode 100644 index 00000000..d44fd454 --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/desugar-and-parse-layer-names.d.ts @@ -0,0 +1,3 @@ +import type { Container } from 'postcss'; +import type { Model } from './model'; +export declare function desugarAndParseLayerNames(root: Container, model: Model): void; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/desugar-nested-layers.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/desugar-nested-layers.d.ts new file mode 100644 index 00000000..e15d3bfb --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/desugar-nested-layers.d.ts @@ -0,0 +1,3 @@ +import type { Container, ChildNode } from 'postcss'; +import type { Model } from './model'; +export declare function desugarNestedLayers(root: Container<ChildNode>, model: Model): void; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/get-conditional-atrule-ancestor.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/get-conditional-atrule-ancestor.d.ts new file mode 100644 index 00000000..25a6756a --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/get-conditional-atrule-ancestor.d.ts @@ -0,0 +1,2 @@ +import type { AtRule } from 'postcss'; +export declare function getConditionalAtRuleAncestor(layerRule: AtRule): AtRule | null; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/get-layer-atrule-ancestor.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/get-layer-atrule-ancestor.d.ts new file mode 100644 index 00000000..b59be340 --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/get-layer-atrule-ancestor.d.ts @@ -0,0 +1,2 @@ +import type { AtRule, Node } from 'postcss'; +export declare function getLayerAtRuleAncestor(node: Node): AtRule | null; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/index.cjs b/node_modules/@csstools/postcss-cascade-layers/dist/index.cjs new file mode 100644 index 00000000..6788e74a --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("postcss-selector-parser"),r=require("@csstools/selector-specificity");const t="csstools-invalid-layer",a="csstools-layer-with-selector-rules",s="6efdb677-bb05-44e5-840f-29d2175862fd",n="b147acf6-11a6-4338-a4d0-80aef4cd1a2f",o=["media","supports"],l=["keyframes"],i=new Set(["layer","supports","media","container","scope"]);function isProcessableLayerRule(e){if("atrule"!==e.type)return!1;if("layer"!==e.name.toLowerCase())return!1;let r=e.parent;for(;r;){if("rule"===r.type)return!1;if("atrule"===r.type&&!i.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}class Model{anonymousLayerCount=0;layerCount=0;layerOrder;layerParamsParsed;layerNameParts;constructor(){this.anonymousLayerCount=0,this.layerCount=0,this.layerOrder=new Map,this.layerParamsParsed=new Map,this.layerNameParts=new Map}createAnonymousLayerName(){const e=`anonymous-${this.anonymousLayerCount}-${s}`;return this.addLayerNameParts(e),this.layerParamsParsed.set(e,[e]),this.anonymousLayerCount++,e}createImplicitLayerName(e){const r=this.layerNameParts.get(e)??[],t=`implicit-${r[r.length-1]}-${n}`;return this.addLayerNameParts([...r,t]),this.layerParamsParsed.set(t,[t]),t}addLayerParams(e,r){r?"string"!=typeof r?this.layerParamsParsed.set(e,r):this.layerParamsParsed.set(e,[r]):this.layerParamsParsed.set(e,[e])}addLayerNameParts(e){"string"!=typeof e?this.layerNameParts.set(e.join("."),e):this.layerNameParts.set(e,[e])}getLayerParams(e){const r=[...this.layerParamsParsed.get(e.params)??[]];let t=e.parent;for(;t;)"atrule"===t.type?(isProcessableLayerRule(t)&&r.push(...this.layerParamsParsed.get(t.params)??[]),t=t.parent):t=t.parent;return r.reverse(),r.flatMap((e=>this.layerNameParts.get(e)??[]))}getLayerNameList(e){const r=this.layerNameParts.get(e)??[],t=[];for(let e=0;e<r.length;e++){const a=r.slice(0,e+1).join(".");this.layerParamsParsed.has(a)||this.layerParamsParsed.set(a,[a]),this.layerNameParts.has(a)||this.layerNameParts.set(a,r.slice(0,e+1)),t.push(r.slice(0,e+1).join("."))}return t}sortLayerNames(){for(const[e,r]of this.layerOrder){const t=this.layerNameParts.get(e)??[];for(let e=1;e<t.length;e++){const a=t.slice(0,e).join(".");this.layerOrder.has(a)||this.layerOrder.set(a,r)}}let e=Array.from(this.layerOrder.entries());e=e.sort(((e,r)=>{const t=this.layerNameParts.get(e[0])??[],a=this.layerNameParts.get(r[0])??[];if(t[0]!==a[0])return(this.layerOrder.get(t[0])??0)-(this.layerOrder.get(a[0])??0);const s=Math.max(t.length,a.length);for(let e=0;e<s;e++){const r=t[e],s=a[e];if(r!==s)return r?s?(this.layerOrder.get(t.slice(0,e).join("."))??0)-(this.layerOrder.get(a.slice(0,e).join("."))??0):-1:1}return 0})),this.layerOrder.clear(),e.forEach(((e,r)=>{this.layerOrder.set(e[0],r)}))}}function adjustSelectorSpecificity(r,t){const a=e().astSync(r),s=e().astSync(generateNot(t));let n=!1;for(let r=0;r<a.nodes[0].nodes.length;r++)if("combinator"===a.nodes[0].nodes[r].type||e.isPseudoElement(a.nodes[0].nodes[r])){a.nodes[0].insertBefore(a.nodes[0].nodes[r],s),n=!0;break}return n||a.nodes[0].insertAfter(a.nodes[0].nodes[a.nodes[0].nodes.length-1],s),a.toString()}function generateNot(e){if(0===e)return"";let r="";for(let t=0;t<e;t++)r+=":not(#\\#)";return r}function someInTree(e,r){let t=!1;return e.walk((e=>{if(r(e))return t=!0,!1})),t}function someAtRuleInTree(e,r){let t=!1;return e.walkAtRules((e=>{if(r(e))return t=!0,!1})),t}function getLayerAtRuleAncestor(e){let r=e.parent;for(;r;)if("atrule"===r.type){if(isProcessableLayerRule(r))return r;r=r.parent}else r=r.parent;return null}function removeEmptyDescendantBlocks(e){var r;e&&(e.walk((e=>{var r;("rule"===e.type||"atrule"===e.type&&["layer",...o].includes(e.name.toLowerCase()))&&(0===(null==(r=e.nodes)?void 0:r.length)&&e.remove())})),0===(null==(r=e.nodes)?void 0:r.length)&&e.remove())}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(void 0===r.nodes)return;if(r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function desugarAndParseLayerNames(r,a){r.walkAtRules((r=>{if(!isProcessableLayerRule(r))return;if(r.params){const s=[];let n=!1;if(e().astSync(r.params).each((e=>{const r=[];e.walk((e=>{switch(e.type){case"class":case"tag":r.push(e.value);break;default:n=!0}})),n||(s.push(r.join(".")),a.addLayerNameParts(r))})),a.addLayerParams(r.params,s),r.nodes&&s.length>1&&(n=!0),n)return void(r.name=t);if(!r.nodes||0===r.nodes.length){if(s.length<=1)return;return s.slice(0,-1).forEach((e=>{a.addLayerParams(e,e),r.cloneBefore({params:e})})),a.addLayerParams(s[s.length-1],s[s.length-1]),void(r.params=s[s.length-1])}}r.params||(r.raws.afterName=" ",r.params=a.createAnonymousLayerName());const s=someAtRuleInTree(r,(e=>isProcessableLayerRule(e))),n=someInTree(r,(e=>{if("rule"!==e.type)return!1;return getLayerAtRuleAncestor(e)===r}));if(s&&n){const e=a.createImplicitLayerName(r.params),t=r.clone({params:e});t.walkAtRules((e=>{isProcessableLayerRule(e)&&e.remove()})),r.walk((e=>{if("atrule"===e.type&&isProcessableLayerRule(e))return;if("atrule"===e.type&&o.includes(e.name.toLowerCase()))return;getLayerAtRuleAncestor(e)===r&&e.remove()})),r.append(t),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)}}))}function desugarNestedLayers(e,r){for(;someAtRuleInTree(e,(e=>e.nodes&&someAtRuleInTree(e,(e=>isProcessableLayerRule(e)))));){let t=!1;if(e.walkAtRules((a=>{var s,n;if(isProcessableLayerRule(a)&&a.parent!==e){if("atrule"===(null==(s=a.parent)?void 0:s.type)&&isProcessableLayerRule(a.parent)){const e=a.parent;{const t=r.layerNameParts.get(e.params),s=r.layerNameParts.get(a.params);if(!t||!s)return;r.layerNameParts.set(`${e.params}.${a.params}`,[...t,...s]),r.layerParamsParsed.set(`${e.params}.${a.params}`,[`${e.params}.${a.params}`])}return a.params=`${e.params}.${a.params}`,e.before(a),removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)}if("atrule"===(null==(n=a.parent)?void 0:n.type)){const e=a.parent,r=e.clone(),t=a.clone();return r.removeAll(),t.removeAll(),r.append(a.nodes),t.append(r),e.before(t),a.remove(),removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)}t=!0}})),t)break}}function sortRootNodes(e,r){e.walkAtRules((e=>{if(!isProcessableLayerRule(e))return;const r=e.clone(),t=e.clone();r.walkAtRules((e=>{if(l.includes(e.name.toLowerCase())){const r=e.parent;return e.remove(),removeEmptyDescendantBlocks(r),void removeEmptyAncestorBlocks(r)}if(someInTree(e,(e=>"rule"===e.type)))return;const r=e.parent;e.remove(),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)})),t.walkRules((e=>{if(e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase()))return;const r=e.parent;e.remove(),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)})),t.walkAtRules((e=>{if(o.includes(e.name.toLowerCase()))return removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)})),r.name=a,e.replaceWith(r,t),0===r.nodes.length&&r.remove(),0===t.nodes.length&&t.remove()})),e.nodes.sort(((e,t)=>{const a="atrule"===e.type&&"layer"===e.name.toLowerCase(),s="atrule"===t.type&&"layer"===t.name.toLowerCase();if(a&&s){return(r.layerOrder.get(e.params)??0)-(r.layerOrder.get(t.params)??0)}return a!==s?a?-1:1:0})),e.walkAtRules(a,(e=>{e.name="layer"}))}function getConditionalAtRuleAncestor(e){let r=e.parent;for(;r;)if("atrule"===r.type){if(o.includes(r.name.toLowerCase()))return r;r=r.parent}else r=r.parent;return null}function recordLayerOrder(e,r,{result:t,options:a}){e.walkAtRules((e=>{if(!isProcessableLayerRule(e))return;const o=r.getLayerParams(e),l=o.join(".");r.layerOrder.has(l)||(a.onConditionalRulesChangingLayerOrder&&getConditionalAtRuleAncestor(e)&&!e.params.endsWith(n)&&!e.params.endsWith(s)&&e.warn(t,"handling different layer orders in conditional rules is unsupported by this plugin and will cause style differences between browser versions."),r.layerParamsParsed.has(l)||r.layerParamsParsed.set(l,[l]),r.layerNameParts.has(l)||r.layerNameParts.set(l,[...o]),r.getLayerNameList(l).forEach((e=>{r.layerOrder.has(e)||(r.layerOrder.set(e,r.layerCount),r.layerCount+=1)}))),e.nodes&&0!==e.nodes.length||e.remove()}))}function splitImportantStyles(e){e.walkDecls((e=>{var r;if(!e.important)return;const t=e.parent;if(!t)return;if("atrule"===(null==t||null==(r=t.parent)?void 0:r.type)&&l.includes(t.parent.name.toLowerCase()))return;const a=t.clone();a.each((e=>{"decl"===e.type&&e.important||e.remove()})),t.each((e=>{"decl"===e.type&&e.important&&e.remove()})),t.before(a),removeEmptyDescendantBlocks(t)}))}const creator=a=>{const s=Object.assign({onRevertLayerKeyword:"warn",onConditionalRulesChangingLayerOrder:"warn",onImportLayerRule:"warn"},a);return{postcssPlugin:"postcss-cascade-layers",OnceExit(a,{result:n}){s.onRevertLayerKeyword&&a.walkDecls((e=>{"revert-layer"===e.value.toLowerCase()&&e.warn(n,'handling "revert-layer" is unsupported by this plugin and will cause style differences between browser versions.')})),s.onImportLayerRule&&a.walkAtRules((e=>{"import"===e.name.toLowerCase()&&e.params.toLowerCase().includes("layer")&&e.warn(n,"To use @import with layers, the postcss-import plugin is also required. This plugin alone will not support using the @import at-rule.")})),splitImportantStyles(a);const o=new Model;if(desugarAndParseLayerNames(a,o),recordLayerOrder(a,o,{result:n,options:s}),!o.layerCount)return void a.walkAtRules(t,(e=>{e.name="layer"}));let i=0;for(a.walkRules((t=>{t.selectors.forEach((a=>{try{const t=r.selectorSpecificity(e().astSync(a));i=Math.max(i,t.a+1)}catch(e){t.warn(n,`Failed to parse selector : "${a}" with message: "${e.message}"`)}}))})),a.walkRules((e=>{e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase())||getLayerAtRuleAncestor(e)||e.some((e=>"decl"===e.type&&e.important))||(e.selectors=e.selectors.map((r=>{try{return adjustSelectorSpecificity(r,o.layerCount*i)}catch(t){e.warn(n,`Failed to parse selector : "${r}" with message: "${t.message}"`)}return r})))})),o.sortLayerNames(),desugarNestedLayers(a,o),sortRootNodes(a,o),a.walkRules((e=>{if(e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase()))return;const r=getLayerAtRuleAncestor(e);if(!r)return;const t=o.getLayerParams(r).join(".");let a=(o.layerOrder.get(t)??0)*i;e.some((e=>"decl"===e.type&&e.important))&&(a=o.layerCount-a),e.selectors=e.selectors.map((e=>adjustSelectorSpecificity(e,a)))}));someAtRuleInTree(a,(e=>isProcessableLayerRule(e)));)a.walkAtRules((e=>{isProcessableLayerRule(e)&&e.replaceWith(e.nodes)}));a.walkAtRules(t,(e=>{e.name="layer"}))}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/index.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/index.d.ts new file mode 100644 index 00000000..9f366fbb --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/index.d.ts @@ -0,0 +1,5 @@ +import type { PluginCreator } from 'postcss'; +import type { pluginOptions } from './options'; +export type { pluginOptions } from './options'; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/index.mjs b/node_modules/@csstools/postcss-cascade-layers/dist/index.mjs new file mode 100644 index 00000000..5894e725 --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/index.mjs @@ -0,0 +1 @@ +import e from"postcss-selector-parser";import{selectorSpecificity as r}from"@csstools/selector-specificity";const t="csstools-invalid-layer",a="csstools-layer-with-selector-rules",s="6efdb677-bb05-44e5-840f-29d2175862fd",n="b147acf6-11a6-4338-a4d0-80aef4cd1a2f",o=["media","supports"],l=["keyframes"],i=new Set(["layer","supports","media","container","scope"]);function isProcessableLayerRule(e){if("atrule"!==e.type)return!1;if("layer"!==e.name.toLowerCase())return!1;let r=e.parent;for(;r;){if("rule"===r.type)return!1;if("atrule"===r.type&&!i.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}class Model{anonymousLayerCount=0;layerCount=0;layerOrder;layerParamsParsed;layerNameParts;constructor(){this.anonymousLayerCount=0,this.layerCount=0,this.layerOrder=new Map,this.layerParamsParsed=new Map,this.layerNameParts=new Map}createAnonymousLayerName(){const e=`anonymous-${this.anonymousLayerCount}-${s}`;return this.addLayerNameParts(e),this.layerParamsParsed.set(e,[e]),this.anonymousLayerCount++,e}createImplicitLayerName(e){const r=this.layerNameParts.get(e)??[],t=`implicit-${r[r.length-1]}-${n}`;return this.addLayerNameParts([...r,t]),this.layerParamsParsed.set(t,[t]),t}addLayerParams(e,r){r?"string"!=typeof r?this.layerParamsParsed.set(e,r):this.layerParamsParsed.set(e,[r]):this.layerParamsParsed.set(e,[e])}addLayerNameParts(e){"string"!=typeof e?this.layerNameParts.set(e.join("."),e):this.layerNameParts.set(e,[e])}getLayerParams(e){const r=[...this.layerParamsParsed.get(e.params)??[]];let t=e.parent;for(;t;)"atrule"===t.type?(isProcessableLayerRule(t)&&r.push(...this.layerParamsParsed.get(t.params)??[]),t=t.parent):t=t.parent;return r.reverse(),r.flatMap((e=>this.layerNameParts.get(e)??[]))}getLayerNameList(e){const r=this.layerNameParts.get(e)??[],t=[];for(let e=0;e<r.length;e++){const a=r.slice(0,e+1).join(".");this.layerParamsParsed.has(a)||this.layerParamsParsed.set(a,[a]),this.layerNameParts.has(a)||this.layerNameParts.set(a,r.slice(0,e+1)),t.push(r.slice(0,e+1).join("."))}return t}sortLayerNames(){for(const[e,r]of this.layerOrder){const t=this.layerNameParts.get(e)??[];for(let e=1;e<t.length;e++){const a=t.slice(0,e).join(".");this.layerOrder.has(a)||this.layerOrder.set(a,r)}}let e=Array.from(this.layerOrder.entries());e=e.sort(((e,r)=>{const t=this.layerNameParts.get(e[0])??[],a=this.layerNameParts.get(r[0])??[];if(t[0]!==a[0])return(this.layerOrder.get(t[0])??0)-(this.layerOrder.get(a[0])??0);const s=Math.max(t.length,a.length);for(let e=0;e<s;e++){const r=t[e],s=a[e];if(r!==s)return r?s?(this.layerOrder.get(t.slice(0,e).join("."))??0)-(this.layerOrder.get(a.slice(0,e).join("."))??0):-1:1}return 0})),this.layerOrder.clear(),e.forEach(((e,r)=>{this.layerOrder.set(e[0],r)}))}}function adjustSelectorSpecificity(r,t){const a=e().astSync(r),s=e().astSync(generateNot(t));let n=!1;for(let r=0;r<a.nodes[0].nodes.length;r++)if("combinator"===a.nodes[0].nodes[r].type||e.isPseudoElement(a.nodes[0].nodes[r])){a.nodes[0].insertBefore(a.nodes[0].nodes[r],s),n=!0;break}return n||a.nodes[0].insertAfter(a.nodes[0].nodes[a.nodes[0].nodes.length-1],s),a.toString()}function generateNot(e){if(0===e)return"";let r="";for(let t=0;t<e;t++)r+=":not(#\\#)";return r}function someInTree(e,r){let t=!1;return e.walk((e=>{if(r(e))return t=!0,!1})),t}function someAtRuleInTree(e,r){let t=!1;return e.walkAtRules((e=>{if(r(e))return t=!0,!1})),t}function getLayerAtRuleAncestor(e){let r=e.parent;for(;r;)if("atrule"===r.type){if(isProcessableLayerRule(r))return r;r=r.parent}else r=r.parent;return null}function removeEmptyDescendantBlocks(e){var r;e&&(e.walk((e=>{var r;("rule"===e.type||"atrule"===e.type&&["layer",...o].includes(e.name.toLowerCase()))&&(0===(null==(r=e.nodes)?void 0:r.length)&&e.remove())})),0===(null==(r=e.nodes)?void 0:r.length)&&e.remove())}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(void 0===r.nodes)return;if(r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function desugarAndParseLayerNames(r,a){r.walkAtRules((r=>{if(!isProcessableLayerRule(r))return;if(r.params){const s=[];let n=!1;if(e().astSync(r.params).each((e=>{const r=[];e.walk((e=>{switch(e.type){case"class":case"tag":r.push(e.value);break;default:n=!0}})),n||(s.push(r.join(".")),a.addLayerNameParts(r))})),a.addLayerParams(r.params,s),r.nodes&&s.length>1&&(n=!0),n)return void(r.name=t);if(!r.nodes||0===r.nodes.length){if(s.length<=1)return;return s.slice(0,-1).forEach((e=>{a.addLayerParams(e,e),r.cloneBefore({params:e})})),a.addLayerParams(s[s.length-1],s[s.length-1]),void(r.params=s[s.length-1])}}r.params||(r.raws.afterName=" ",r.params=a.createAnonymousLayerName());const s=someAtRuleInTree(r,(e=>isProcessableLayerRule(e))),n=someInTree(r,(e=>{if("rule"!==e.type)return!1;return getLayerAtRuleAncestor(e)===r}));if(s&&n){const e=a.createImplicitLayerName(r.params),t=r.clone({params:e});t.walkAtRules((e=>{isProcessableLayerRule(e)&&e.remove()})),r.walk((e=>{if("atrule"===e.type&&isProcessableLayerRule(e))return;if("atrule"===e.type&&o.includes(e.name.toLowerCase()))return;getLayerAtRuleAncestor(e)===r&&e.remove()})),r.append(t),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)}}))}function desugarNestedLayers(e,r){for(;someAtRuleInTree(e,(e=>e.nodes&&someAtRuleInTree(e,(e=>isProcessableLayerRule(e)))));){let t=!1;if(e.walkAtRules((a=>{var s,n;if(isProcessableLayerRule(a)&&a.parent!==e){if("atrule"===(null==(s=a.parent)?void 0:s.type)&&isProcessableLayerRule(a.parent)){const e=a.parent;{const t=r.layerNameParts.get(e.params),s=r.layerNameParts.get(a.params);if(!t||!s)return;r.layerNameParts.set(`${e.params}.${a.params}`,[...t,...s]),r.layerParamsParsed.set(`${e.params}.${a.params}`,[`${e.params}.${a.params}`])}return a.params=`${e.params}.${a.params}`,e.before(a),removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)}if("atrule"===(null==(n=a.parent)?void 0:n.type)){const e=a.parent,r=e.clone(),t=a.clone();return r.removeAll(),t.removeAll(),r.append(a.nodes),t.append(r),e.before(t),a.remove(),removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)}t=!0}})),t)break}}function sortRootNodes(e,r){e.walkAtRules((e=>{if(!isProcessableLayerRule(e))return;const r=e.clone(),t=e.clone();r.walkAtRules((e=>{if(l.includes(e.name.toLowerCase())){const r=e.parent;return e.remove(),removeEmptyDescendantBlocks(r),void removeEmptyAncestorBlocks(r)}if(someInTree(e,(e=>"rule"===e.type)))return;const r=e.parent;e.remove(),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)})),t.walkRules((e=>{if(e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase()))return;const r=e.parent;e.remove(),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)})),t.walkAtRules((e=>{if(o.includes(e.name.toLowerCase()))return removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)})),r.name=a,e.replaceWith(r,t),0===r.nodes.length&&r.remove(),0===t.nodes.length&&t.remove()})),e.nodes.sort(((e,t)=>{const a="atrule"===e.type&&"layer"===e.name.toLowerCase(),s="atrule"===t.type&&"layer"===t.name.toLowerCase();if(a&&s){return(r.layerOrder.get(e.params)??0)-(r.layerOrder.get(t.params)??0)}return a!==s?a?-1:1:0})),e.walkAtRules(a,(e=>{e.name="layer"}))}function getConditionalAtRuleAncestor(e){let r=e.parent;for(;r;)if("atrule"===r.type){if(o.includes(r.name.toLowerCase()))return r;r=r.parent}else r=r.parent;return null}function recordLayerOrder(e,r,{result:t,options:a}){e.walkAtRules((e=>{if(!isProcessableLayerRule(e))return;const o=r.getLayerParams(e),l=o.join(".");r.layerOrder.has(l)||(a.onConditionalRulesChangingLayerOrder&&getConditionalAtRuleAncestor(e)&&!e.params.endsWith(n)&&!e.params.endsWith(s)&&e.warn(t,"handling different layer orders in conditional rules is unsupported by this plugin and will cause style differences between browser versions."),r.layerParamsParsed.has(l)||r.layerParamsParsed.set(l,[l]),r.layerNameParts.has(l)||r.layerNameParts.set(l,[...o]),r.getLayerNameList(l).forEach((e=>{r.layerOrder.has(e)||(r.layerOrder.set(e,r.layerCount),r.layerCount+=1)}))),e.nodes&&0!==e.nodes.length||e.remove()}))}function splitImportantStyles(e){e.walkDecls((e=>{var r;if(!e.important)return;const t=e.parent;if(!t)return;if("atrule"===(null==t||null==(r=t.parent)?void 0:r.type)&&l.includes(t.parent.name.toLowerCase()))return;const a=t.clone();a.each((e=>{"decl"===e.type&&e.important||e.remove()})),t.each((e=>{"decl"===e.type&&e.important&&e.remove()})),t.before(a),removeEmptyDescendantBlocks(t)}))}const creator=a=>{const s=Object.assign({onRevertLayerKeyword:"warn",onConditionalRulesChangingLayerOrder:"warn",onImportLayerRule:"warn"},a);return{postcssPlugin:"postcss-cascade-layers",OnceExit(a,{result:n}){s.onRevertLayerKeyword&&a.walkDecls((e=>{"revert-layer"===e.value.toLowerCase()&&e.warn(n,'handling "revert-layer" is unsupported by this plugin and will cause style differences between browser versions.')})),s.onImportLayerRule&&a.walkAtRules((e=>{"import"===e.name.toLowerCase()&&e.params.toLowerCase().includes("layer")&&e.warn(n,"To use @import with layers, the postcss-import plugin is also required. This plugin alone will not support using the @import at-rule.")})),splitImportantStyles(a);const o=new Model;if(desugarAndParseLayerNames(a,o),recordLayerOrder(a,o,{result:n,options:s}),!o.layerCount)return void a.walkAtRules(t,(e=>{e.name="layer"}));let i=0;for(a.walkRules((t=>{t.selectors.forEach((a=>{try{const t=r(e().astSync(a));i=Math.max(i,t.a+1)}catch(e){t.warn(n,`Failed to parse selector : "${a}" with message: "${e.message}"`)}}))})),a.walkRules((e=>{e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase())||getLayerAtRuleAncestor(e)||e.some((e=>"decl"===e.type&&e.important))||(e.selectors=e.selectors.map((r=>{try{return adjustSelectorSpecificity(r,o.layerCount*i)}catch(t){e.warn(n,`Failed to parse selector : "${r}" with message: "${t.message}"`)}return r})))})),o.sortLayerNames(),desugarNestedLayers(a,o),sortRootNodes(a,o),a.walkRules((e=>{if(e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase()))return;const r=getLayerAtRuleAncestor(e);if(!r)return;const t=o.getLayerParams(r).join(".");let a=(o.layerOrder.get(t)??0)*i;e.some((e=>"decl"===e.type&&e.important))&&(a=o.layerCount-a),e.selectors=e.selectors.map((e=>adjustSelectorSpecificity(e,a)))}));someAtRuleInTree(a,(e=>isProcessableLayerRule(e)));)a.walkAtRules((e=>{isProcessableLayerRule(e)&&e.replaceWith(e.nodes)}));a.walkAtRules(t,(e=>{e.name="layer"}))}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/is-processable-layer-rule.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/is-processable-layer-rule.d.ts new file mode 100644 index 00000000..115b5dba --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/is-processable-layer-rule.d.ts @@ -0,0 +1,2 @@ +import type { AtRule } from 'postcss'; +export declare function isProcessableLayerRule(atRule: AtRule): boolean; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/model.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/model.d.ts new file mode 100644 index 00000000..38a268e4 --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/model.d.ts @@ -0,0 +1,18 @@ +import type { AtRule } from 'postcss'; +export declare class Model { + anonymousLayerCount: number; + layerCount: number; + layerOrder: Map<string, number>; + layerParamsParsed: Map<string, Array<string>>; + layerNameParts: Map<string, Array<string>>; + constructor(); + createAnonymousLayerName(): string; + createImplicitLayerName(layerName: string): string; + addLayerParams(key: string, parts?: string): void; + addLayerParams(key: string, parts: Array<string>): void; + addLayerNameParts(parts: string): void; + addLayerNameParts(parts: Array<string>): void; + getLayerParams(layer: AtRule): Array<string>; + getLayerNameList(layerName: string): Array<string>; + sortLayerNames(): void; +} diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/options.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/options.d.ts new file mode 100644 index 00000000..e3a1943d --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/options.d.ts @@ -0,0 +1,9 @@ +/** postcss-cascasde-layers plugin options */ +export type pluginOptions = { + /** Emit a warning when the "revert" keyword is found in your CSS. default: "warn" */ + onRevertLayerKeyword?: 'warn' | false; + /** Emit a warning when conditional rules could change the layer order. default: "warn" */ + onConditionalRulesChangingLayerOrder?: 'warn' | false; + /** Emit a warning when "layer" is used in "@import". default: "warn" */ + onImportLayerRule?: 'warn' | false; +}; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/record-layer-order.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/record-layer-order.d.ts new file mode 100644 index 00000000..05d6ac7d --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/record-layer-order.d.ts @@ -0,0 +1,7 @@ +import type { Container, Result } from 'postcss'; +import type { Model } from './model'; +import { pluginOptions } from './options'; +export declare function recordLayerOrder(root: Container, model: Model, { result, options }: { + result: Result; + options: pluginOptions; +}): void; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/some-in-tree.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/some-in-tree.d.ts new file mode 100644 index 00000000..8c416c59 --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/some-in-tree.d.ts @@ -0,0 +1,3 @@ +import type { Container, ChildNode, AtRule } from 'postcss'; +export declare function someInTree(container: Container, predicate: (node: ChildNode) => boolean): boolean; +export declare function someAtRuleInTree(container: Container, predicate: (node: AtRule) => boolean): boolean; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/sort-root-nodes.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/sort-root-nodes.d.ts new file mode 100644 index 00000000..8eb479ed --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/sort-root-nodes.d.ts @@ -0,0 +1,3 @@ +import type { Container } from 'postcss'; +import type { Model } from './model'; +export declare function sortRootNodes(root: Container, model: Model): void; diff --git a/node_modules/@csstools/postcss-cascade-layers/dist/split-important-styles.d.ts b/node_modules/@csstools/postcss-cascade-layers/dist/split-important-styles.d.ts new file mode 100644 index 00000000..270c69a9 --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/dist/split-important-styles.d.ts @@ -0,0 +1,2 @@ +import type { Container } from 'postcss'; +export declare function splitImportantStyles(root: Container): void; diff --git a/node_modules/@csstools/postcss-cascade-layers/package.json b/node_modules/@csstools/postcss-cascade-layers/package.json new file mode 100644 index 00000000..62751263 --- /dev/null +++ b/node_modules/@csstools/postcss-cascade-layers/package.json @@ -0,0 +1,102 @@ +{ + "name": "@csstools/postcss-cascade-layers", + "description": "Use cascade layers in CSS", + "version": "4.0.0", + "contributors": [ + { + "name": "Olu Niyi-Awosusi", + "email": "o.niyiawosusi@gmail.com" + }, + { + "name": "Sana Javed", + "email": "sanajaved7@gmail.com" + }, + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/selector-specificity": "^3.0.0", + "postcss-selector-parser": "^6.0.13" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*", + "postcss-import": "^15.1.0", + "puppeteer": "^20.7.4" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:browser": "node ./test/_browser.mjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-cascade-layers#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-cascade-layers" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "cascade", + "css", + "layers", + "postcss", + "postcss-plugin", + "selectors", + "specificity" + ], + "csstools": { + "assumesToProcessBundledCSS": true, + "cssdbId": "cascade-layers", + "exportName": "postcssCascadeLayers", + "humanReadableName": "PostCSS Cascade Layers", + "specUrl": "https://www.w3.org/TR/css-cascade-5/#layering" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-color-function/CHANGELOG.md b/node_modules/@csstools/postcss-color-function/CHANGELOG.md new file mode 100644 index 00000000..53ab6b0a --- /dev/null +++ b/node_modules/@csstools/postcss-color-function/CHANGELOG.md @@ -0,0 +1,156 @@ +# Changes to PostCSS Color Function + +### 3.0.7 + +_October 9, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.4.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#140) (minor) +- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.2`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#302) (patch) + +### 3.0.6 + +_October 2, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#133) (patch) + +### 3.0.5 + +_September 24, 2023_ + +- 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-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#132) (patch) + +### 3.0.4 + +_September 18, 2023_ + +- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.1`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#301) (patch) + +### 3.0.3 + +_September 2, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#131) (patch) + +### 3.0.2 + +_August 28, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#130) (minor) + +### 3.0.1 + +_July 24, 2023_ + +- 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) + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) +- 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/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#300) (major) +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.2.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#122) (patch) + +### 2.2.3 + +_June 1, 2023_ + +- Updated `@csstools/postcss-progressive-custom-properties` to `2.3.0` (minor) + +### 2.2.2 + +_May 19, 2023_ + +- Ignore relative color syntax +- Updated `@csstools/postcss-progressive-custom-properties` to `2.2.0` (minor) +- Updated `@csstools/css-color-parser` to `1.2.0` (minor) + +### 2.2.1 + +_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-color-parser` to `1.1.2` (patch) + +### 2.2.0 + +_March 25, 2023_ + +- Add `@csstools/css-color-parser` dependency for all color value transformations. +- Add support for `calc` expressions in color components. +- Remove support for missing channel values (`color(display-p3 1)`). This was never documented and was removed from the specification. + +### 2.1.0 + +_February 6, 2023_ + +- Add: `@csstools/color-helpers` dependency for all color value transformations. + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). + +### 1.1.1 + +_July 8, 2022_ + +- Fix case insensitive matching. + +### 1.1.0 + +_April 4, 2022_ + +- Allow percentage units in XYZ color spaces. + +```css +.percentages { + color-1: color(xyz-d50 64.331% 19.245% 16.771%); + color-2: color(xyz-d65 64.331% 19.245% 16.771%); + color-3: color(xyz 64.331% 19.245% 16.771%); + + /* becomes */ + + color-1: rgb(245,0,135); + color-2: rgb(253,0,127); + color-3: rgb(253,0,127); +} +``` + +### 1.0.3 + +_March 8, 2022_ + +- Fix gamut mapping giving overly unsaturated colors. +- Implement powerless color components in gamut mapping. + +### 1.0.2 + +_February 12, 2022_ + +- Updated `@csstools/postcss-progressive-custom-properties` to `1.1.0`. + +### 1.0.1 + +_February 11, 2022_ + +- Add tests for percentage values in non-xyz color spaces. +- Ignore percentage values in xyz color space as these are not supported. + +### 1.0.0 + +_February 7, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-color-function/LICENSE.md b/node_modules/@csstools/postcss-color-function/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-color-function/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-color-function/README.md b/node_modules/@csstools/postcss-color-function/README.md new file mode 100644 index 00000000..44168b62 --- /dev/null +++ b/node_modules/@csstools/postcss-color-function/README.md @@ -0,0 +1,162 @@ +# PostCSS Color Function [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-color-function.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/color-function.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +```bash +npm install @csstools/postcss-color-function --save-dev +``` + +[PostCSS Color Function] lets you use the `color` function in +CSS, following the [CSS Color] specification. + +```pcss +.color { + color: color(display-p3 0.64331 0.19245 0.16771); +} + +:root { + --a-color: color(srgb 0.64331 0.19245 0.16771); +} + +/* becomes */ + +.color { + color: rgb(179, 35, 35); +} + +:root { + --a-color: rgb(164, 49, 43); +} +``` + +## Usage + +Add [PostCSS Color Function] to your project: + +```bash +npm install postcss @csstools/postcss-color-function --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssColorFunction = require('@csstools/postcss-color-function'); + +postcss([ + postcssColorFunction(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Color Function] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is not preserved. + +```js +postcssColorFunction({ preserve: true }) +``` + +```pcss +.color { + color: color(display-p3 0.64331 0.19245 0.16771); +} + +:root { + --a-color: color(srgb 0.64331 0.19245 0.16771); +} + +/* becomes */ + +.color { + color: rgb(179, 35, 35); + color: color(display-p3 0.64331 0.19245 0.16771); +} + +:root { + --a-color: rgb(164, 49, 43); +} + +@supports (color: color(display-p3 0 0 0)) { +:root { + --a-color: color(srgb 0.64331 0.19245 0.16771); +} +} +``` + +### enableProgressiveCustomProperties + +The `enableProgressiveCustomProperties` option determines whether the original notation +is wrapped with `@supports` when used in Custom Properties. By default, it is enabled. + +⚠️ We only recommend disabling this when you set `preserve` to `false` or if you bring your own fix for Custom Properties. See what the plugin does in its [README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties#readme). + +```js +postcssColorFunction({ enableProgressiveCustomProperties: false }) +``` + +```pcss +.color { + color: color(display-p3 0.64331 0.19245 0.16771); +} + +:root { + --a-color: color(srgb 0.64331 0.19245 0.16771); +} + +/* becomes */ + +.color { + color: rgb(179, 35, 35); + color: color(display-p3 0.64331 0.19245 0.16771); +} + +:root { + --a-color: rgb(164, 49, 43); + --a-color: color(srgb 0.64331 0.19245 0.16771); +} +``` + +_Custom properties do not fallback to the previous declaration_ + +## Supported Color Spaces + +```css +.color-spaces { + color: color(a98-rgb 0.803 0.484 0.944); + color: color(display-p3 0.8434 0.509 0.934); + color: color(prophoto-rgb 0.759 0.493 0.898); + color: color(rec2020 0.772 0.491 0.920); + color: color(srgb 0.897 0.488 0.959); + color: color(srgb-linear 0.783 0.203 0.910); + color: color(xyz 0.560 0.377 0.904); + color: color(xyz-d50 0.550 0.375 0.680); + color: color(xyz-d65 0.560 0.377 0.904); +} +``` + +## Copyright : color conversions + +This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/tree/main/css-color-4. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#color-function +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-color-function + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Color Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-function +[CSS Color]: https://www.w3.org/TR/css-color-4/#funcdef-color diff --git a/node_modules/@csstools/postcss-color-function/dist/has-fallback-decl.d.ts b/node_modules/@csstools/postcss-color-function/dist/has-fallback-decl.d.ts new file mode 100644 index 00000000..d7ae8d89 --- /dev/null +++ b/node_modules/@csstools/postcss-color-function/dist/has-fallback-decl.d.ts @@ -0,0 +1,2 @@ +import type { Declaration } from 'postcss'; +export declare function hasFallback(node: Declaration): boolean; diff --git a/node_modules/@csstools/postcss-color-function/dist/has-supports-at-rule-ancestor.d.ts b/node_modules/@csstools/postcss-color-function/dist/has-supports-at-rule-ancestor.d.ts new file mode 100644 index 00000000..a46009ec --- /dev/null +++ b/node_modules/@csstools/postcss-color-function/dist/has-supports-at-rule-ancestor.d.ts @@ -0,0 +1,2 @@ +import type { Node } from 'postcss'; +export declare function hasSupportsAtRuleAncestor(node: Node): boolean; diff --git a/node_modules/@csstools/postcss-color-function/dist/index.cjs b/node_modules/@csstools/postcss-color-function/dist/index.cjs new file mode 100644 index 00000000..d6a9614a --- /dev/null +++ b/node_modules/@csstools/postcss-color-function/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),s=require("@csstools/css-tokenizer"),r=require("@csstools/css-color-parser"),t=require("@csstools/css-parser-algorithms");function hasFallback(e){const s=e.parent;if(!s)return!1;const r=e.prop.toLowerCase(),t=s.index(e);for(let e=0;e<t;e++){const t=s.nodes[e];if("decl"===t.type&&t.prop.toLowerCase()===r)return!0}return!1}function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name&&-1!==s.params.indexOf("color("))return!0;s=s.parent}else s=s.parent;return!1}const o=/(color)\(/i,n=/^(color)$/i,basePlugin=e=>({postcssPlugin:"postcss-color-function",Declaration:a=>{const c=a.value;if(!o.test(c))return;if(hasFallback(a))return;if(hasSupportsAtRuleAncestor(a))return;const i=s.tokenize({css:c}),l=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(i),(e=>{if(t.isFunctionNode(e)&&n.test(e.getName())){const s=r.color(e);if(!s)return;if(s.syntaxFlags.has(r.SyntaxFlag.HasNoneKeywords))return;if(s.syntaxFlags.has(r.SyntaxFlag.RelativeColorSyntax))return;return r.serializeRGB(s)}})),p=t.stringify(l);p!==c&&(a.cloneBefore({value:p}),null!=e&&e.preserve||a.remove())}});basePlugin.postcss=!0;const postcssPlugin=s=>{const r=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},s);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-color-function",plugins:[e(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/node_modules/@csstools/postcss-color-function/dist/index.d.ts b/node_modules/@csstools/postcss-color-function/dist/index.d.ts new file mode 100644 index 00000000..616abbd7 --- /dev/null +++ b/node_modules/@csstools/postcss-color-function/dist/index.d.ts @@ -0,0 +1,10 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-color-function plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; + /** Enable "@csstools/postcss-progressive-custom-properties". default: true */ + enableProgressiveCustomProperties?: boolean; +}; +declare const postcssPlugin: PluginCreator<pluginOptions>; +export default postcssPlugin; diff --git a/node_modules/@csstools/postcss-color-function/dist/index.mjs b/node_modules/@csstools/postcss-color-function/dist/index.mjs new file mode 100644 index 00000000..b1bc9224 --- /dev/null +++ b/node_modules/@csstools/postcss-color-function/dist/index.mjs @@ -0,0 +1 @@ +import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as r}from"@csstools/css-tokenizer";import{color as e,SyntaxFlag as o,serializeRGB as t}from"@csstools/css-color-parser";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as c,isFunctionNode as a,stringify as p}from"@csstools/css-parser-algorithms";function hasFallback(s){const r=s.parent;if(!r)return!1;const e=s.prop.toLowerCase(),o=r.index(s);for(let s=0;s<o;s++){const o=r.nodes[s];if("decl"===o.type&&o.prop.toLowerCase()===e)return!0}return!1}function hasSupportsAtRuleAncestor(s){let r=s.parent;for(;r;)if("atrule"===r.type){if("supports"===r.name&&-1!==r.params.indexOf("color("))return!0;r=r.parent}else r=r.parent;return!1}const l=/(color)\(/i,i=/^(color)$/i,basePlugin=s=>({postcssPlugin:"postcss-color-function",Declaration:u=>{const f=u.value;if(!l.test(f))return;if(hasFallback(u))return;if(hasSupportsAtRuleAncestor(u))return;const m=r({css:f}),g=n(c(m),(s=>{if(a(s)&&i.test(s.getName())){const r=e(s);if(!r)return;if(r.syntaxFlags.has(o.HasNoneKeywords))return;if(r.syntaxFlags.has(o.RelativeColorSyntax))return;return t(r)}})),v=p(g);v!==f&&(u.cloneBefore({value:v}),null!=s&&s.preserve||u.remove())}});basePlugin.postcss=!0;const postcssPlugin=r=>{const e=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},r);return e.enableProgressiveCustomProperties&&e.preserve?{postcssPlugin:"postcss-color-function",plugins:[s(),basePlugin(e)]}:basePlugin(e)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; diff --git a/node_modules/@csstools/postcss-color-function/package.json b/node_modules/@csstools/postcss-color-function/package.json new file mode 100644 index 00000000..a2b330a4 --- /dev/null +++ b/node_modules/@csstools/postcss-color-function/package.json @@ -0,0 +1,89 @@ +{ + "name": "@csstools/postcss-color-function", + "description": "Use the color() function in CSS", + "version": "3.0.7", + "author": "Jonathan Neal <jonathantneal@hotmail.com>", + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/css-color-parser": "^1.4.0", + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1", + "@csstools/postcss-progressive-custom-properties": "^3.0.2" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*", + "postcss-lab-function": "^6.0.0" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-function#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-color-function" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "color", + "css", + "design", + "display-p3", + "postcss", + "postcss-plugin", + "prophoto-rgb", + "rec2020", + "rgb", + "rgba", + "srgb-linear", + "syntax", + "xyz" + ], + "csstools": { + "cssdbId": "color-function", + "exportName": "postcssColorFunction", + "humanReadableName": "PostCSS Color Function", + "specUrl": "https://www.w3.org/TR/css-color-4/#funcdef-color" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-color-mix-function/CHANGELOG.md b/node_modules/@csstools/postcss-color-mix-function/CHANGELOG.md new file mode 100644 index 00000000..e56cec1c --- /dev/null +++ b/node_modules/@csstools/postcss-color-mix-function/CHANGELOG.md @@ -0,0 +1,85 @@ +# Changes to PostCSS Color Mix Function + +### 2.0.7 + +_October 9, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.4.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#140) (minor) +- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.2`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#302) (patch) + +### 2.0.6 + +_October 2, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#133) (patch) + +### 2.0.5 + +_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-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#132) (patch) + +### 2.0.4 + +_September 18, 2023_ + +- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.1`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#301) (patch) + +### 2.0.3 + +_September 2, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#131) (patch) + +### 2.0.2 + +_August 28, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#130) (minor) + +### 2.0.1 + +_July 24, 2023_ + +- 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) + +### 2.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) +- 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/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#300) (major) +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.2.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#122) (patch) + +### 1.0.3 + +_June 1, 2023_ + +- Updated `@csstools/postcss-progressive-custom-properties` to `2.3.0` (minor) + + +### 1.0.2 + +_May 19, 2023_ + +- Updated `@csstools/postcss-progressive-custom-properties` to `2.2.0` (minor) +- Updated `@csstools/css-color-parser` to `1.2.0` (minor) + +### 1.0.1 + +_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-color-parser` to `1.1.2` (patch) + +### 1.0.0 + +_March 25, 2023_ + +- Initial version diff --git a/node_modules/@csstools/postcss-color-mix-function/LICENSE.md b/node_modules/@csstools/postcss-color-mix-function/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-color-mix-function/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-color-mix-function/README.md b/node_modules/@csstools/postcss-color-mix-function/README.md new file mode 100644 index 00000000..e7c54e48 --- /dev/null +++ b/node_modules/@csstools/postcss-color-mix-function/README.md @@ -0,0 +1,84 @@ +# PostCSS Color Mix Function [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-color-mix-function.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/color-mix.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +```bash +npm install @csstools/postcss-color-mix-function --save-dev +``` + +[PostCSS Color Mix Function] lets you use the `color-mix()` function following the [CSS Color 5 Specification]. + +```pcss +.purple_plum { + color: color-mix(in lch, purple 50%, plum 50%); +} + +/* becomes */ + +.purple_plum { + color: rgb(175, 92, 174); +} +``` + +## Usage + +Add [PostCSS Color Mix Function] to your project: + +```bash +npm install postcss @csstools/postcss-color-mix-function --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssColorMixFunction = require('@csstools/postcss-color-mix-function'); + +postcss([ + postcssColorMixFunction(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Color Mix Function] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is not preserved. + +```js +postcssColorMixFunction({ preserve: true }) +``` + +```pcss +.purple_plum { + color: color-mix(in lch, purple 50%, plum 50%); +} + +/* becomes */ + +.purple_plum { + color: rgb(175, 92, 174); + color: color-mix(in lch, purple 50%, plum 50%); +} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#color-mix +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-color-mix-function + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Color Mix Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-mix-function +[CSS Color 5 Specification]: https://www.w3.org/TR/css-color-5/#color-mix diff --git a/node_modules/@csstools/postcss-color-mix-function/dist/has-fallback-decl.d.ts b/node_modules/@csstools/postcss-color-mix-function/dist/has-fallback-decl.d.ts new file mode 100644 index 00000000..d7ae8d89 --- /dev/null +++ b/node_modules/@csstools/postcss-color-mix-function/dist/has-fallback-decl.d.ts @@ -0,0 +1,2 @@ +import type { Declaration } from 'postcss'; +export declare function hasFallback(node: Declaration): boolean; diff --git a/node_modules/@csstools/postcss-color-mix-function/dist/has-supports-at-rule-ancestor.d.ts b/node_modules/@csstools/postcss-color-mix-function/dist/has-supports-at-rule-ancestor.d.ts new file mode 100644 index 00000000..a46009ec --- /dev/null +++ b/node_modules/@csstools/postcss-color-mix-function/dist/has-supports-at-rule-ancestor.d.ts @@ -0,0 +1,2 @@ +import type { Node } from 'postcss'; +export declare function hasSupportsAtRuleAncestor(node: Node): boolean; diff --git a/node_modules/@csstools/postcss-color-mix-function/dist/index.cjs b/node_modules/@csstools/postcss-color-mix-function/dist/index.cjs new file mode 100644 index 00000000..ef647904 --- /dev/null +++ b/node_modules/@csstools/postcss-color-mix-function/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),s=require("@csstools/css-tokenizer"),r=require("@csstools/css-color-parser"),t=require("@csstools/css-parser-algorithms");function hasFallback(e){const s=e.parent;if(!s)return!1;const r=e.prop.toLowerCase(),t=s.index(e);for(let e=0;e<t;e++){const t=s.nodes[e];if("decl"===t.type&&t.prop.toLowerCase()===r)return!0}return!1}function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name.toLowerCase()&&-1!==s.params.toLowerCase().indexOf("color-mix("))return!0;s=s.parent}else s=s.parent;return!1}const o=/(color-mix)\(/i,n=/^(color-mix)$/i,basePlugin=e=>({postcssPlugin:"postcss-color-mix-function",Declaration:i=>{const a=i.value;if(!o.test(a))return;if(hasFallback(i))return;if(hasSupportsAtRuleAncestor(i))return;const u=s.tokenize({css:a}),l=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(u),(e=>{if(t.isFunctionNode(e)&&n.test(e.getName())){const s=r.color(e);if(!s)return;return r.serializeRGB(s)}})),c=t.stringify(l);if(c===a)return;let p=c;null!=e&&e.subFeatures.displayP3&&(p=t.stringify(t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(u),(e=>{if(t.isFunctionNode(e)&&n.test(e.getName())){const s=r.color(e);if(!s)return;return r.colorDataFitsRGB_Gamut(s)?r.serializeRGB(s):r.serializeP3(s)}})))),i.cloneBefore({value:c}),null!=e&&e.subFeatures.displayP3&&p!==c&&i.cloneBefore({value:p}),null!=e&&e.preserve||i.remove()}});basePlugin.postcss=!0;const postcssPlugin=s=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},s);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-color-mix-function",plugins:[e(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/node_modules/@csstools/postcss-color-mix-function/dist/index.d.ts b/node_modules/@csstools/postcss-color-mix-function/dist/index.d.ts new file mode 100644 index 00000000..22a656f0 --- /dev/null +++ b/node_modules/@csstools/postcss-color-mix-function/dist/index.d.ts @@ -0,0 +1,15 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-color-mix-function plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; + /** Enable "@csstools/postcss-progressive-custom-properties". default: true */ + enableProgressiveCustomProperties?: boolean; + /** Toggle sub features. default: { displayP3: true } */ + subFeatures?: { + /** Enable displayP3 fallbacks. default: true */ + displayP3?: boolean; + }; +}; +declare const postcssPlugin: PluginCreator<pluginOptions>; +export default postcssPlugin; diff --git a/node_modules/@csstools/postcss-color-mix-function/dist/index.mjs b/node_modules/@csstools/postcss-color-mix-function/dist/index.mjs new file mode 100644 index 00000000..35b6a3c0 --- /dev/null +++ b/node_modules/@csstools/postcss-color-mix-function/dist/index.mjs @@ -0,0 +1 @@ +import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as e}from"@csstools/css-tokenizer";import{color as r,serializeRGB as t,colorDataFitsRGB_Gamut as o,serializeP3 as n}from"@csstools/css-color-parser";import{replaceComponentValues as u,parseCommaSeparatedListOfComponentValues as i,isFunctionNode as a,stringify as c}from"@csstools/css-parser-algorithms";function hasFallback(s){const e=s.parent;if(!e)return!1;const r=s.prop.toLowerCase(),t=e.index(s);for(let s=0;s<t;s++){const t=e.nodes[s];if("decl"===t.type&&t.prop.toLowerCase()===r)return!0}return!1}function hasSupportsAtRuleAncestor(s){let e=s.parent;for(;e;)if("atrule"===e.type){if("supports"===e.name.toLowerCase()&&-1!==e.params.toLowerCase().indexOf("color-mix("))return!0;e=e.parent}else e=e.parent;return!1}const l=/(color-mix)\(/i,p=/^(color-mix)$/i,basePlugin=s=>({postcssPlugin:"postcss-color-mix-function",Declaration:f=>{const m=f.value;if(!l.test(m))return;if(hasFallback(f))return;if(hasSupportsAtRuleAncestor(f))return;const b=e({css:m}),g=u(i(b),(s=>{if(a(s)&&p.test(s.getName())){const e=r(s);if(!e)return;return t(e)}})),P=c(g);if(P===m)return;let d=P;null!=s&&s.subFeatures.displayP3&&(d=c(u(i(b),(s=>{if(a(s)&&p.test(s.getName())){const e=r(s);if(!e)return;return o(e)?t(e):n(e)}})))),f.cloneBefore({value:P}),null!=s&&s.subFeatures.displayP3&&d!==P&&f.cloneBefore({value:d}),null!=s&&s.preserve||f.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-color-mix-function",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; diff --git a/node_modules/@csstools/postcss-color-mix-function/package.json b/node_modules/@csstools/postcss-color-mix-function/package.json new file mode 100644 index 00000000..1636ac7f --- /dev/null +++ b/node_modules/@csstools/postcss-color-mix-function/package.json @@ -0,0 +1,97 @@ +{ + "name": "@csstools/postcss-color-mix-function", + "description": "Use the color-mix function in CSS", + "version": "2.0.7", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/css-color-parser": "^1.4.0", + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1", + "@csstools/postcss-progressive-custom-properties": "^3.0.2" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-mix-function#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-color-mix-function" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "color-mix", + "css", + "display-p3", + "interpolation", + "postcss-plugin", + "prophoto-rgb", + "rec2020", + "rgb", + "rgba", + "srgb-linear", + "syntax", + "xyz" + ], + "csstools": { + "cssdbId": "color-mix", + "exportName": "postcssColorMixFunction", + "humanReadableName": "PostCSS Color Mix Function", + "specUrl": "https://www.w3.org/TR/css-color-5/#color-mix" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-exponential-functions/CHANGELOG.md b/node_modules/@csstools/postcss-exponential-functions/CHANGELOG.md new file mode 100644 index 00000000..cd08f07e --- /dev/null +++ b/node_modules/@csstools/postcss-exponential-functions/CHANGELOG.md @@ -0,0 +1,18 @@ +# Changes to PostCSS Exponential Functions + +### 1.0.1 + +_September 24, 2023_ + +- 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.0.0 + +_July 24, 2023_ + +- Initial version +- 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) diff --git a/node_modules/@csstools/postcss-exponential-functions/LICENSE.md b/node_modules/@csstools/postcss-exponential-functions/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-exponential-functions/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-exponential-functions/README.md b/node_modules/@csstools/postcss-exponential-functions/README.md new file mode 100644 index 00000000..f09493e6 --- /dev/null +++ b/node_modules/@csstools/postcss-exponential-functions/README.md @@ -0,0 +1,104 @@ +# PostCSS Exponential Functions [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-exponential-functions.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/exponential-functions.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +```bash +npm install @csstools/postcss-exponential-functions --save-dev +``` + +[PostCSS Exponential Functions] lets you use the `pow()`, `sqrt()`, `hypot()`, `log()`, `exp()` functions following the [CSS Values 4 Specification]. + +```pcss +.foo { + top: calc(1px * pow(2, 3)); + line-height: sqrt(1.2); + padding: hypot(3px, 4px); + order: log(10, 10); + min-height: calc(e - exp(1)); +} + +/* becomes */ + +.foo { + top: 8px; + line-height: 1.0954451150103; + padding: 5px; + order: 1; + min-height: 0; +} +``` + +## Usage + +Add [PostCSS Exponential Functions] to your project: + +```bash +npm install postcss @csstools/postcss-exponential-functions --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssExponentialFunctions = require('@csstools/postcss-exponential-functions'); + +postcss([ + postcssExponentialFunctions(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Exponential Functions] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is not preserved. + +```js +postcssExponentialFunctions({ preserve: true }) +``` + +```pcss +.foo { + top: calc(1px * pow(2, 3)); + line-height: sqrt(1.2); + padding: hypot(3px, 4px); + order: log(10, 10); + min-height: calc(e - exp(1)); +} + +/* becomes */ + +.foo { + top: 8px; + top: calc(1px * pow(2, 3)); + line-height: 1.0954451150103; + line-height: sqrt(1.2); + padding: 5px; + padding: hypot(3px, 4px); + order: 1; + order: log(10, 10); + min-height: 0; + min-height: calc(e - exp(1)); +} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#exponential-functions +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-exponential-functions + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Exponential Functions]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-exponential-functions +[CSS Values 4 Specification]: https://www.w3.org/TR/css-values-4/#exponent-funcs diff --git a/node_modules/@csstools/postcss-exponential-functions/dist/calc.d.ts b/node_modules/@csstools/postcss-exponential-functions/dist/calc.d.ts new file mode 100644 index 00000000..5a1ee11e --- /dev/null +++ b/node_modules/@csstools/postcss-exponential-functions/dist/calc.d.ts @@ -0,0 +1 @@ +export declare function calc(css: string): string; diff --git a/node_modules/@csstools/postcss-exponential-functions/dist/checks.d.ts b/node_modules/@csstools/postcss-exponential-functions/dist/checks.d.ts new file mode 100644 index 00000000..6623beb7 --- /dev/null +++ b/node_modules/@csstools/postcss-exponential-functions/dist/checks.d.ts @@ -0,0 +1,2 @@ +export declare const FUNCTION_NAME_REGEXP: RegExp; +export declare const FUNCTION_CALL_REGEXP: RegExp; diff --git a/node_modules/@csstools/postcss-exponential-functions/dist/index.cjs b/node_modules/@csstools/postcss-exponential-functions/dist/index.cjs new file mode 100644 index 00000000..defdaba9 --- /dev/null +++ b/node_modules/@csstools/postcss-exponential-functions/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/css-calc");const s=new RegExp(`(${["exp","hypot","log","pow","sqrt"].join("|")})\\(`,"i"),creator=o=>{const t=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-exponential-functions",Declaration(o){if(!s.test(o.value))return;const c=e.calc(o.value);c!==o.value&&(o.cloneBefore({value:c}),t.preserve||o.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-exponential-functions/dist/index.d.ts b/node_modules/@csstools/postcss-exponential-functions/dist/index.d.ts new file mode 100644 index 00000000..d216e578 --- /dev/null +++ b/node_modules/@csstools/postcss-exponential-functions/dist/index.d.ts @@ -0,0 +1,8 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-exponential-functions plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-exponential-functions/dist/index.mjs b/node_modules/@csstools/postcss-exponential-functions/dist/index.mjs new file mode 100644 index 00000000..748e9dbb --- /dev/null +++ b/node_modules/@csstools/postcss-exponential-functions/dist/index.mjs @@ -0,0 +1 @@ +import{calc as e}from"@csstools/css-calc";const s=new RegExp(`(${["exp","hypot","log","pow","sqrt"].join("|")})\\(`,"i"),creator=o=>{const t=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-exponential-functions",Declaration(o){if(!s.test(o.value))return;const n=e(o.value);n!==o.value&&(o.cloneBefore({value:n}),t.preserve||o.remove())}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-exponential-functions/package.json b/node_modules/@csstools/postcss-exponential-functions/package.json new file mode 100644 index 00000000..5b6fd683 --- /dev/null +++ b/node_modules/@csstools/postcss-exponential-functions/package.json @@ -0,0 +1,91 @@ +{ + "name": "@csstools/postcss-exponential-functions", + "description": "Use pow(), sqrt(), hypot(), log(), exp() exponential functions in CSS", + "version": "1.0.1", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/css-calc": "^1.1.4", + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-exponential-functions#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-exponential-functions" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "exp", + "exponential", + "hypot", + "log", + "postcss-plugin", + "pow", + "sqrt" + ], + "csstools": { + "cssdbId": "exponential-functions", + "exportName": "postcssExponentialFunctions", + "humanReadableName": "PostCSS Exponential Functions", + "specUrl": "https://www.w3.org/TR/css-values-4/#exponent-funcs" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-font-format-keywords/CHANGELOG.md b/node_modules/@csstools/postcss-font-format-keywords/CHANGELOG.md new file mode 100644 index 00000000..78f76768 --- /dev/null +++ b/node_modules/@csstools/postcss-font-format-keywords/CHANGELOG.md @@ -0,0 +1,37 @@ +# Changes to PostCSS Font Format + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) + +### 2.0.2 + +_February 8, 2023_ + +- Reduce the amount of duplicate fallback CSS. + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). + +### 1.0.1 + +_July 8, 2022_ + +- Fix case insensitive matching. + +### 1.0.0 + +_January 25, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-font-format-keywords/LICENSE.md b/node_modules/@csstools/postcss-font-format-keywords/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-font-format-keywords/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-font-format-keywords/README.md b/node_modules/@csstools/postcss-font-format-keywords/README.md new file mode 100644 index 00000000..bf4927ee --- /dev/null +++ b/node_modules/@csstools/postcss-font-format-keywords/README.md @@ -0,0 +1,86 @@ +# PostCSS Font Format [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-font-format-keywords.svg" height="20">][npm-url] +[<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/font-format-keywords.svg" height="20">][css-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +[PostCSS Font Format Keywords] lets you specify font formats as keywords, following the [CSS Fonts] specification. + +```pcss +@font-face { + src: url(file.woff2) format(woff2); +} + +/* becomes */ + +@font-face { + src: url(file.woff2) format("woff2"); +} +``` + +_See prior work by [valtlai](https://github.com/valtlai) here [postcss-font-format-keywords](https://github.com/valtlai/postcss-font-format-keywords) +To ensure long term maintenance and to provide the needed features this plugin was recreated based on valtlai's work._ + +## Usage + +Add [PostCSS Font Format Keywords] to your project: + +```bash +npm install postcss @csstools/postcss-font-format-keywords --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssFontFormatKeywords = require('@csstools/postcss-font-format-keywords'); + +postcss([ + postcssFontFormatKeywords(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Font Format Keywords] runs in all Node environments, with special +instructions for: + +| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) | +| --- | --- | --- | --- | --- | + +## Options + +### preserve + +The `preserve` option determines whether the original source +is preserved. By default, it is not preserved. + +```js +postcssFontFormatKeywords({ preserve: true }) +``` + +```pcss +@font-face { + src: url(file.woff2) format(woff2); +} + +/* becomes */ + +@font-face { + src: url(file.woff2) format("woff2"); + src: url(file.woff2) format(woff2); +} +``` + +[postcss]: https://github.com/postcss/postcss + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#font-format-keywords +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-font-format-keywords + +[CSS Fonts]: https://www.w3.org/TR/css-fonts-4/#font-format-values +[Gulp PostCSS]: https://github.com/postcss/gulp-postcss +[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Loader]: https://github.com/postcss/postcss-loader +[PostCSS Font Format Keywords]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-font-format-keywords diff --git a/node_modules/@csstools/postcss-font-format-keywords/dist/has-fallback-decl.d.ts b/node_modules/@csstools/postcss-font-format-keywords/dist/has-fallback-decl.d.ts new file mode 100644 index 00000000..d7ae8d89 --- /dev/null +++ b/node_modules/@csstools/postcss-font-format-keywords/dist/has-fallback-decl.d.ts @@ -0,0 +1,2 @@ +import type { Declaration } from 'postcss'; +export declare function hasFallback(node: Declaration): boolean; diff --git a/node_modules/@csstools/postcss-font-format-keywords/dist/index.cjs b/node_modules/@csstools/postcss-font-format-keywords/dist/index.cjs new file mode 100644 index 00000000..7ffbcdcb --- /dev/null +++ b/node_modules/@csstools/postcss-font-format-keywords/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("postcss-value-parser");function hasFallback(e){const t=e.parent;if(!t)return!1;const o=e.prop.toLowerCase(),r=t.index(e);for(let e=0;e<r;e++){const r=t.nodes[e];if("decl"===r.type&&r.prop.toLowerCase()===o)return!0}return!1}const t=["woff","truetype","opentype","woff2","embedded-opentype","collection","svg"],creator=o=>{const r="preserve"in Object(o)&&Boolean(null==o?void 0:o.preserve);return{postcssPlugin:"postcss-font-format-keywords",Declaration(o){if("src"!==o.prop.toLowerCase())return;if(!o.value.toLowerCase().includes("format("))return;if(hasFallback(o))return;const n=o.parent;if(!n||"atrule"!==n.type)return;if("font-face"!==n.name.toLowerCase())return;const s=e(o.value);s.walk((o=>{"function"===o.type&&"format"===o.value.toLowerCase()&&o.nodes.forEach((o=>{"word"===o.type&&t.includes(o.value.toLowerCase())&&(o.value=e.stringify({type:"string",value:o.value,quote:'"'}))}))})),s.toString()!==o.value&&(o.cloneBefore({value:s.toString()}),r||o.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-font-format-keywords/dist/index.d.ts b/node_modules/@csstools/postcss-font-format-keywords/dist/index.d.ts new file mode 100644 index 00000000..08f71203 --- /dev/null +++ b/node_modules/@csstools/postcss-font-format-keywords/dist/index.d.ts @@ -0,0 +1,8 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-font-format-keywords plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-font-format-keywords/dist/index.mjs b/node_modules/@csstools/postcss-font-format-keywords/dist/index.mjs new file mode 100644 index 00000000..896d2b41 --- /dev/null +++ b/node_modules/@csstools/postcss-font-format-keywords/dist/index.mjs @@ -0,0 +1 @@ +import e from"postcss-value-parser";function hasFallback(e){const o=e.parent;if(!o)return!1;const t=e.prop.toLowerCase(),r=o.index(e);for(let e=0;e<r;e++){const r=o.nodes[e];if("decl"===r.type&&r.prop.toLowerCase()===t)return!0}return!1}const o=["woff","truetype","opentype","woff2","embedded-opentype","collection","svg"],creator=t=>{const r="preserve"in Object(t)&&Boolean(null==t?void 0:t.preserve);return{postcssPlugin:"postcss-font-format-keywords",Declaration(t){if("src"!==t.prop.toLowerCase())return;if(!t.value.toLowerCase().includes("format("))return;if(hasFallback(t))return;const n=t.parent;if(!n||"atrule"!==n.type)return;if("font-face"!==n.name.toLowerCase())return;const s=e(t.value);s.walk((t=>{"function"===t.type&&"format"===t.value.toLowerCase()&&t.nodes.forEach((t=>{"word"===t.type&&o.includes(t.value.toLowerCase())&&(t.value=e.stringify({type:"string",value:t.value,quote:'"'}))}))})),s.toString()!==t.value&&(t.cloneBefore({value:s.toString()}),r||t.remove())}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-font-format-keywords/package.json b/node_modules/@csstools/postcss-font-format-keywords/package.json new file mode 100644 index 00000000..2f41adca --- /dev/null +++ b/node_modules/@csstools/postcss-font-format-keywords/package.json @@ -0,0 +1,79 @@ +{ + "name": "@csstools/postcss-font-format-keywords", + "description": "Use unquoted format on @font-face CSS definitions.", + "version": "3.0.0", + "author": "Jonathan Neal <jonathantneal@hotmail.com>", + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-font-format-keywords#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-font-format-keywords" + }, + "keywords": [ + "css", + "embedded-opentype", + "font", + "font-format-keywords", + "format", + "opentype", + "postcss-plugin", + "truetype", + "woff", + "woff2" + ], + "csstools": { + "exportName": "postcssFontFormatKeywords", + "humanReadableName": "PostCSS Font Format Keywords" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-gamut-mapping/CHANGELOG.md b/node_modules/@csstools/postcss-gamut-mapping/CHANGELOG.md new file mode 100644 index 00000000..646591c8 --- /dev/null +++ b/node_modules/@csstools/postcss-gamut-mapping/CHANGELOG.md @@ -0,0 +1,8 @@ +# Changes to PostCSS gamut-mapping + +### 1.0.0 + +_October 9, 2023_ + +- Initial version +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.4.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#140) (minor) diff --git a/node_modules/@csstools/postcss-gamut-mapping/LICENSE.md b/node_modules/@csstools/postcss-gamut-mapping/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-gamut-mapping/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-gamut-mapping/README.md b/node_modules/@csstools/postcss-gamut-mapping/README.md new file mode 100644 index 00000000..a5edb31c --- /dev/null +++ b/node_modules/@csstools/postcss-gamut-mapping/README.md @@ -0,0 +1,84 @@ +# PostCSS Gamut Mapping [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-gamut-mapping.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/gamut-mapping.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +```bash +npm install @csstools/postcss-gamut-mapping --save-dev +``` + +[PostCSS Gamut Mapping] lets you use wide gamut colors with gamut mapping for specific displays following the [CSS Color 4 Specification]. + +When out of gamut colors are naively clipped the result can be radically different. +A saturated and bright color will be much darker after clipping. + +To correctly adjust colors for a narrow gamut display, the colors must be mapped. +This is done by lowering the `chroma` in `oklch` until the color is in gamut. + +Using the `@media (color-gamut)` media feature makes it possible to only use the wide gamut colors on displays that support them. + +```pcss +p { + background-color: oklch(80% 0.05 0.39 / 0.5); + color: oklch(20% 0.234 0.39 / 0.5); + border-color: color(display-p3 0 1 0); +} + +/* becomes */ + +p { + background-color: oklch(80% 0.05 0.39 / 0.5); + color: rgba(50, 0, 20, 0.5); + border-color: rgb(0, 249, 66); +} + +@media (color-gamut: rec2020) { +p { + color: oklch(20% 0.234 0.39 / 0.5); +} +} + +@media (color-gamut: p3) { +p { + border-color: color(display-p3 0 1 0); +} +} +``` + +## Usage + +Add [PostCSS Gamut Mapping] to your project: + +```bash +npm install postcss @csstools/postcss-gamut-mapping --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssGamutMapping = require('@csstools/postcss-gamut-mapping'); + +postcss([ + postcssGamutMapping(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Gamut Mapping] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#gamut-mapping +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-gamut-mapping + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Gamut Mapping]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-gamut-mapping +[CSS Color 4 Specification]: https://www.w3.org/TR/css-color-4/#gamut-mapping diff --git a/node_modules/@csstools/postcss-gamut-mapping/dist/has-conditional-ancestor.d.ts b/node_modules/@csstools/postcss-gamut-mapping/dist/has-conditional-ancestor.d.ts new file mode 100644 index 00000000..7c086270 --- /dev/null +++ b/node_modules/@csstools/postcss-gamut-mapping/dist/has-conditional-ancestor.d.ts @@ -0,0 +1,2 @@ +import type { Node } from 'postcss'; +export declare function hasConditionalAncestor(node: Node): boolean; diff --git a/node_modules/@csstools/postcss-gamut-mapping/dist/has-override-decl.d.ts b/node_modules/@csstools/postcss-gamut-mapping/dist/has-override-decl.d.ts new file mode 100644 index 00000000..e98c4f8a --- /dev/null +++ b/node_modules/@csstools/postcss-gamut-mapping/dist/has-override-decl.d.ts @@ -0,0 +1,5 @@ +import type { Declaration } from 'postcss'; +export declare function hasOverrideOrFallback(node: Declaration): { + hasOverride: boolean; + hasFallback: boolean; +}; diff --git a/node_modules/@csstools/postcss-gamut-mapping/dist/index.cjs b/node_modules/@csstools/postcss-gamut-mapping/dist/index.cjs new file mode 100644 index 00000000..77030d6a --- /dev/null +++ b/node_modules/@csstools/postcss-gamut-mapping/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/css-tokenizer"),o=require("@csstools/css-parser-algorithms"),a=require("@csstools/css-color-parser");const t=/\bcolor-gamut\b/i;function hasConditionalAncestor(e){let o=e.parent;for(;o;)if("atrule"===o.type){if("media"===o.name.toLowerCase()&&t.test(o.params))return!0;o=o.parent}else o=o.parent;return!1}function hasOverrideOrFallback(e){var o;const a=e.prop.toLowerCase();let t=!1,s=!1;const r=(null==(o=e.parent)?void 0:o.nodes)??[],n=r.indexOf(e);for(let e=0;e<r.length;e++){if(e===n)continue;const o=r[e];if("decl"===o.type&&o.prop.toLowerCase()===a){if(!(e<n)){t=!0;break}s=!0,e=n}}return{hasOverride:t,hasFallback:s}}const s=/\b(?:color|lab|lch|oklab|oklch)\(/i,r=/^(?:color|lab|lch|oklab|oklch)$/i,creator=()=>({postcssPlugin:"postcss-gamut-mapping",prepare(){const t=new WeakMap;return{OnceExit:(n,{postcss:l})=>{n.walkDecls((n=>{const i=n.value;if(!s.test(i))return;if(!n.parent||hasConditionalAncestor(n))return;const{hasOverride:c,hasFallback:p}=hasOverrideOrFallback(n);if(c)return;const u=t.get(n.parent)||{conditionalRules:[],propNames:new Set,lastConditionParams:{media:void 0},lastConditionalRule:void 0};t.set(n.parent,u);let d=!1;const m=o.replaceComponentValues(o.parseCommaSeparatedListOfComponentValues(e.tokenize({css:i})),(e=>{if(!o.isFunctionNode(e)||!r.test(e.getName()))return;const t=a.color(e);return!t||t.syntaxFlags.has(a.SyntaxFlag.HasNoneKeywords)||a.colorDataFitsRGB_Gamut(t)?void 0:(d||a.colorDataFitsDisplayP3_Gamut(t)||(d=!0),a.serializeRGB(t,!0))})),f=o.stringify(m);if(f===i)return;const v=`(color-gamut: ${d?"rec2020":"p3"})`;if(u.lastConditionParams.media!==v&&(u.lastConditionalRule=void 0),u.lastConditionalRule)return p||n.cloneBefore({value:f}),u.lastConditionalRule.append(n.clone()),void n.remove();p||n.cloneBefore({value:f});const h=l.atRule({name:"media",params:v,source:n.parent.source,raws:{before:"\n\n",after:"\n"}}),C=n.parent.clone();C.removeAll(),C.raws.before="\n",C.append(n.clone()),n.remove(),u.lastConditionParams.media=h.params,u.lastConditionalRule=C,h.append(C),u.conditionalRules.push(h)})),n.walk((e=>{const o=t.get(e);o&&0!==o.conditionalRules.length&&o.conditionalRules.reverse().forEach((o=>{e.after(o)}))}))}}}});creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-gamut-mapping/dist/index.d.ts b/node_modules/@csstools/postcss-gamut-mapping/dist/index.d.ts new file mode 100644 index 00000000..cf42343c --- /dev/null +++ b/node_modules/@csstools/postcss-gamut-mapping/dist/index.d.ts @@ -0,0 +1,5 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-gamut-mapping plugin options */ +export type pluginOptions = never; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-gamut-mapping/dist/index.mjs b/node_modules/@csstools/postcss-gamut-mapping/dist/index.mjs new file mode 100644 index 00000000..1899c2c4 --- /dev/null +++ b/node_modules/@csstools/postcss-gamut-mapping/dist/index.mjs @@ -0,0 +1 @@ +import{tokenize as e}from"@csstools/css-tokenizer";import{replaceComponentValues as o,parseCommaSeparatedListOfComponentValues as t,isFunctionNode as a,stringify as r}from"@csstools/css-parser-algorithms";import{color as n,SyntaxFlag as s,colorDataFitsRGB_Gamut as l,colorDataFitsDisplayP3_Gamut as i,serializeRGB as c}from"@csstools/css-color-parser";const p=/\bcolor-gamut\b/i;function hasConditionalAncestor(e){let o=e.parent;for(;o;)if("atrule"===o.type){if("media"===o.name.toLowerCase()&&p.test(o.params))return!0;o=o.parent}else o=o.parent;return!1}function hasOverrideOrFallback(e){var o;const t=e.prop.toLowerCase();let a=!1,r=!1;const n=(null==(o=e.parent)?void 0:o.nodes)??[],s=n.indexOf(e);for(let e=0;e<n.length;e++){if(e===s)continue;const o=n[e];if("decl"===o.type&&o.prop.toLowerCase()===t){if(!(e<s)){a=!0;break}r=!0,e=s}}return{hasOverride:a,hasFallback:r}}const d=/\b(?:color|lab|lch|oklab|oklch)\(/i,u=/^(?:color|lab|lch|oklab|oklch)$/i,creator=()=>({postcssPlugin:"postcss-gamut-mapping",prepare(){const p=new WeakMap;return{OnceExit:(m,{postcss:f})=>{m.walkDecls((m=>{const h=m.value;if(!d.test(h))return;if(!m.parent||hasConditionalAncestor(m))return;const{hasOverride:v,hasFallback:b}=hasOverrideOrFallback(m);if(v)return;const k=p.get(m.parent)||{conditionalRules:[],propNames:new Set,lastConditionParams:{media:void 0},lastConditionalRule:void 0};p.set(m.parent,k);let C=!1;const g=o(t(e({css:h})),(e=>{if(!a(e)||!u.test(e.getName()))return;const o=n(e);return!o||o.syntaxFlags.has(s.HasNoneKeywords)||l(o)?void 0:(C||i(o)||(C=!0),c(o,!0))})),w=r(g);if(w===h)return;const R=`(color-gamut: ${C?"rec2020":"p3"})`;if(k.lastConditionParams.media!==R&&(k.lastConditionalRule=void 0),k.lastConditionalRule)return b||m.cloneBefore({value:w}),k.lastConditionalRule.append(m.clone()),void m.remove();b||m.cloneBefore({value:w});const O=f.atRule({name:"media",params:R,source:m.parent.source,raws:{before:"\n\n",after:"\n"}}),F=m.parent.clone();F.removeAll(),F.raws.before="\n",F.append(m.clone()),m.remove(),k.lastConditionParams.media=O.params,k.lastConditionalRule=F,O.append(F),k.conditionalRules.push(O)})),m.walk((e=>{const o=p.get(e);o&&0!==o.conditionalRules.length&&o.conditionalRules.reverse().forEach((o=>{e.after(o)}))}))}}}});creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-gamut-mapping/package.json b/node_modules/@csstools/postcss-gamut-mapping/package.json new file mode 100644 index 00000000..45255518 --- /dev/null +++ b/node_modules/@csstools/postcss-gamut-mapping/package.json @@ -0,0 +1,94 @@ +{ + "name": "@csstools/postcss-gamut-mapping", + "description": "Gamut map css colors to fit display specific gamuts", + "version": "1.0.0", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/css-color-parser": "^1.4.0", + "@csstools/css-parser-algorithms": "2.3.2", + "@csstools/css-tokenizer": "^2.2.1" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-gamut-mapping#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-gamut-mapping" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "color", + "css", + "display-p3", + "gamut mapping", + "p3", + "postcss", + "postcss-plugin", + "rec2020", + "srgb", + "wide gamut" + ], + "csstools": { + "cssdbId": "gamut-mapping", + "exportName": "postcssGamutMapping", + "humanReadableName": "PostCSS Gamut Mapping", + "specUrl": "https://www.w3.org/TR/css-color-4/#gamut-mapping" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-gradients-interpolation-method/CHANGELOG.md b/node_modules/@csstools/postcss-gradients-interpolation-method/CHANGELOG.md new file mode 100644 index 00000000..1c0818d0 --- /dev/null +++ b/node_modules/@csstools/postcss-gradients-interpolation-method/CHANGELOG.md @@ -0,0 +1,129 @@ +# Changes to PostCSS Gradients Interpolation Method + +### 4.0.7 + +_October 9, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.4.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#140) (minor) +- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.2`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#302) (patch) + +### 4.0.6 + +_October 2, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#133) (patch) + +### 4.0.5 + +_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-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#132) (patch) + +### 4.0.4 + +_September 18, 2023_ + +- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.1`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#301) (patch) + +### 4.0.3 + +_September 2, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#131) (patch) + +### 4.0.2 + +_August 28, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#130) (minor) + +### 4.0.1 + +_July 24, 2023_ + +- 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) + +### 4.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) +- 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/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#300) (major) +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.2.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#122) (patch) + +### 3.0.6 + +_June 1, 2023_ + +- Updated `@csstools/postcss-progressive-custom-properties` to `2.3.0` (minor) + + +### 3.0.5 + +_May 19, 2023_ + +- Updated `@csstools/postcss-progressive-custom-properties` to `2.2.0` (minor) +- Updated `@csstools/css-color-parser` to `1.2.0` (minor) + + + +### 3.0.4 + +_April 17, 2023_ + +- Fix infinite loop when parsing gradient functions. (see : https://github.com/csstools/postcss-plugins/issues/948) + +### 3.0.3 + +_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-color-parser` to `1.1.2` (patch) + +### 3.0.2 + +_April 10, 2023_ + +- Fix interpolation method `longer`, `increasing`,... for color stops with the same color. + +### 3.0.1 + +_March 28, 2023_ + +- Skip gamut mapping for interpolation color hints. + +### 3.0.0 + +_March 25, 2023_ + +- Handle `color-mix()` internally with `@csstools/css-color-parser` + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). + +### 1.0.1 + +_March 7, 2022_ + +- fix dependencies + +### 1.0.0 + +_March 4, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-gradients-interpolation-method/LICENSE.md b/node_modules/@csstools/postcss-gradients-interpolation-method/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-gradients-interpolation-method/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-gradients-interpolation-method/README.md b/node_modules/@csstools/postcss-gradients-interpolation-method/README.md new file mode 100644 index 00000000..8412d0aa --- /dev/null +++ b/node_modules/@csstools/postcss-gradients-interpolation-method/README.md @@ -0,0 +1,169 @@ +# PostCSS Gradients Interpolation Method [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-gradients-interpolation-method.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/gradients-interpolation-method.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +```bash +npm install @csstools/postcss-gradients-interpolation-method --save-dev +``` + +[PostCSS Gradients Interpolation Method] lets you use different interpolation methods in CSS gradient functions following [CSS Images Module 4]. + +```pcss +.example { + background-image: linear-gradient(in oklch, hsl(0deg 85% 75%) 0%, hsl(180deg 80% 65%) 100%); +} + +:root { + --background-image: linear-gradient(in oklab, hsl(96, 42%, 24%) 0%, hsl(302, 67%, 25%) 100%); +} + +/* becomes */ + +.example { + background-image: linear-gradient(rgb(245, 137, 137) 0%, rgb(248, 146, 114), rgb(244, 158, 94), rgb(235, 171, 82), rgb(220, 185, 81), rgb(201, 199, 95), rgb(177, 211, 118), rgb(151, 221, 146), rgb(125, 229, 177), rgb(103, 235, 208), rgb(94, 237, 237) 100%); + background-image: linear-gradient(in oklch, hsl(0deg 85% 75%) 0%, hsl(180deg 80% 65%) 100%); +} + +:root { + --background-image: linear-gradient(rgb(56, 87, 35) 0%, rgb(64, 83, 46), rgb(70, 79, 54), rgb(76, 74, 62), rgb(82, 69, 68), rgb(86, 64, 75), rgb(91, 58, 81), rgb(95, 51, 87), rgb(99, 44, 93), rgb(103, 34, 98), rgb(106, 21, 104) 100%); +} + +@supports (background: linear-gradient(in oklch, red 0%, red 0% 1%, red 2%)) { +:root { + --background-image: linear-gradient(in oklab, hsl(96, 42%, 24%) 0%, hsl(302, 67%, 25%) 100%); +} +} +``` + +## Shortcomings + +⚠️ Color stops with only a color or only an interpolation hint are not supported. + +For best results you should always provide at least the color and position for each color stop. +Double position color stops are supported. + +```pcss +.foo { + /* Only a color: can't transform */ + background-image: linear-gradient(in oklch, black 0%, green, blue 100%); + + /* Only an interpolation hint: can't transform */ + background-image: linear-gradient(in oklch, black 0%, 25%, blue 100%); +} +``` + +⚠️ Variable colors are also not supported. +We can not mix colors when the color is a variable. + +```pcss +.foo { + --red: red; + /* Color stop variable : can't transform */ + background-image: linear-gradient(in oklch, black 0%, var(--red), blue 100%); +} +``` + +## Usage + +Add [PostCSS Gradients Interpolation Method] to your project: + +```bash +npm install postcss @csstools/postcss-gradients-interpolation-method --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssGradientsInterpolationMethod = require('@csstools/postcss-gradients-interpolation-method'); + +postcss([ + postcssGradientsInterpolationMethod(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Gradients Interpolation Method] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is preserved. + +```js +postcssGradientsInterpolationMethod({ preserve: false }) +``` + +```pcss +.example { + background-image: linear-gradient(in oklch, hsl(0deg 85% 75%) 0%, hsl(180deg 80% 65%) 100%); +} + +:root { + --background-image: linear-gradient(in oklab, hsl(96, 42%, 24%) 0%, hsl(302, 67%, 25%) 100%); +} + +/* becomes */ + +.example { + background-image: linear-gradient(rgb(245, 137, 137) 0%, rgb(248, 146, 114), rgb(244, 158, 94), rgb(235, 171, 82), rgb(220, 185, 81), rgb(201, 199, 95), rgb(177, 211, 118), rgb(151, 221, 146), rgb(125, 229, 177), rgb(103, 235, 208), rgb(94, 237, 237) 100%); +} + +:root { + --background-image: linear-gradient(rgb(56, 87, 35) 0%, rgb(64, 83, 46), rgb(70, 79, 54), rgb(76, 74, 62), rgb(82, 69, 68), rgb(86, 64, 75), rgb(91, 58, 81), rgb(95, 51, 87), rgb(99, 44, 93), rgb(103, 34, 98), rgb(106, 21, 104) 100%); +} +``` + +### enableProgressiveCustomProperties + +The `enableProgressiveCustomProperties` option determines whether the original notation +is wrapped with `@supports` when used in Custom Properties. By default, it is enabled. + +⚠️ We only recommend disabling this when you set `preserve` to `false` or if you bring your own fix for Custom Properties. See what the plugin does in its [README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties#readme). + +```js +postcssGradientsInterpolationMethod({ enableProgressiveCustomProperties: false }) +``` + +```pcss +.example { + background-image: linear-gradient(in oklch, hsl(0deg 85% 75%) 0%, hsl(180deg 80% 65%) 100%); +} + +:root { + --background-image: linear-gradient(in oklab, hsl(96, 42%, 24%) 0%, hsl(302, 67%, 25%) 100%); +} + +/* becomes */ + +.example { + background-image: linear-gradient(rgb(245, 137, 137) 0%, rgb(248, 146, 114), rgb(244, 158, 94), rgb(235, 171, 82), rgb(220, 185, 81), rgb(201, 199, 95), rgb(177, 211, 118), rgb(151, 221, 146), rgb(125, 229, 177), rgb(103, 235, 208), rgb(94, 237, 237) 100%); + background-image: linear-gradient(in oklch, hsl(0deg 85% 75%) 0%, hsl(180deg 80% 65%) 100%); +} + +:root { + --background-image: linear-gradient(rgb(56, 87, 35) 0%, rgb(64, 83, 46), rgb(70, 79, 54), rgb(76, 74, 62), rgb(82, 69, 68), rgb(86, 64, 75), rgb(91, 58, 81), rgb(95, 51, 87), rgb(99, 44, 93), rgb(103, 34, 98), rgb(106, 21, 104) 100%); + --background-image: linear-gradient(in oklab, hsl(96, 42%, 24%) 0%, hsl(302, 67%, 25%) 100%); +} +``` + +_Custom properties do not fallback to the previous declaration_ + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#gradients-interpolation-method +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-gradients-interpolation-method + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Gradients Interpolation Method]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-gradients-interpolation-method +[CSS Images Module 4]: https://drafts.csswg.org/css-images-4/#linear-gradients diff --git a/node_modules/@csstools/postcss-gradients-interpolation-method/dist/color-stop-list.d.ts b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/color-stop-list.d.ts new file mode 100644 index 00000000..4159c39f --- /dev/null +++ b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/color-stop-list.d.ts @@ -0,0 +1,9 @@ +import type { ColorData } from '@csstools/css-color-parser'; +import type { ComponentValue } from '@csstools/css-parser-algorithms'; +import { TokenNode } from '@csstools/css-parser-algorithms'; +export type ColorStop = { + color: ComponentValue; + colorData: ColorData; + position: ComponentValue; +}; +export declare function interpolateColorsInColorStopsList(colorStops: Array<ColorStop>, colorSpace: TokenNode, hueInterpolationMethod: TokenNode | null, wideGamut?: boolean): Array<ComponentValue> | false; diff --git a/node_modules/@csstools/postcss-gradients-interpolation-method/dist/has-fallback-decl.d.ts b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/has-fallback-decl.d.ts new file mode 100644 index 00000000..d7ae8d89 --- /dev/null +++ b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/has-fallback-decl.d.ts @@ -0,0 +1,2 @@ +import type { Declaration } from 'postcss'; +export declare function hasFallback(node: Declaration): boolean; diff --git a/node_modules/@csstools/postcss-gradients-interpolation-method/dist/has-supports-at-rule-ancestor.d.ts b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/has-supports-at-rule-ancestor.d.ts new file mode 100644 index 00000000..a46009ec --- /dev/null +++ b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/has-supports-at-rule-ancestor.d.ts @@ -0,0 +1,2 @@ +import type { Node } from 'postcss'; +export declare function hasSupportsAtRuleAncestor(node: Node): boolean; diff --git a/node_modules/@csstools/postcss-gradients-interpolation-method/dist/index.cjs b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/index.cjs new file mode 100644 index 00000000..3ab3f55e --- /dev/null +++ b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),o=require("@csstools/css-parser-algorithms"),t=require("@csstools/css-tokenizer"),n=require("@csstools/css-color-parser");const i=/(repeating-)?(linear|radial|conic)-gradient\(.*?in/i,s=/^(repeating-)?(linear|radial|conic)-gradient$/i;function hasFallback(e){const o=e.parent;if(!o)return!1;const t=e.prop.toLowerCase(),n=o.index(e);for(let e=0;e<n;e++){const n=o.nodes[e];if("decl"===n.type&&n.prop.toLowerCase()===t)return!0}return!1}function hasSupportsAtRuleAncestor(e){let o=e.parent;for(;o;)if("atrule"===o.type){if("supports"===o.name&&i.test(o.params))return!0;o=o.parent}else o=o.parent;return!1}function interpolateColorsInColorStopsList(e,i,s,r=!1){const a=[],l=[];for(let r=0;r<e.length-1;r++){const a=e[r],c=e[r+1];if(l.push(a),s||n.serializeP3(a.colorData,!1).toString()!==n.serializeP3(c.colorData,!1).toString()&&a.position.toString()!==c.position.toString())for(let e=1;e<=9;e++){const r=10*e;let p=[];s&&(p=[new o.WhitespaceNode([[t.TokenType.Whitespace," ",-1,-1,void 0]]),s,new o.WhitespaceNode([[t.TokenType.Whitespace," ",-1,-1,void 0]]),new o.TokenNode([t.TokenType.Ident,"hue",-1,-1,{value:"hue"}])]);const u=new o.FunctionNode([t.TokenType.Function,"color-mix(",-1,-1,{value:"color-mix"}],[t.TokenType.CloseParen,")",-1,-1,void 0],[new o.TokenNode([t.TokenType.Ident,"in",-1,-1,{value:"in"}]),new o.WhitespaceNode([[t.TokenType.Whitespace," ",-1,-1,void 0]]),i,...p,new o.TokenNode([t.TokenType.Comma,",",-1,-1,void 0]),new o.WhitespaceNode([[t.TokenType.Whitespace," ",-1,-1,void 0]]),a.color,new o.WhitespaceNode([[t.TokenType.Whitespace," ",-1,-1,void 0]]),new o.TokenNode([t.TokenType.Percentage,100-r+"%",-1,-1,{value:100-r}]),new o.TokenNode([t.TokenType.Comma,",",-1,-1,void 0]),new o.WhitespaceNode([[t.TokenType.Whitespace," ",-1,-1,void 0]]),c.color,new o.WhitespaceNode([[t.TokenType.Whitespace," ",-1,-1,void 0]]),new o.TokenNode([t.TokenType.Percentage,`${r}%`,-1,-1,{value:r}])]),d=n.color(u);if(!d)return!1;l.push({colorData:d})}r===e.length-2&&l.push(c)}for(let e=0;e<l.length;e++)r&&!n.colorDataFitsRGB_Gamut(l[e].colorData)?l[e].color=n.serializeP3(l[e].colorData,!1):l[e].color=n.serializeRGB(l[e].colorData,!1);for(let e=0;e<l.length;e++){const n=l[e];n.position?a.push(n.color,new o.WhitespaceNode([[t.TokenType.Whitespace," ",-1,-1,void 0]]),n.position):a.push(n.color),e!==l.length-1&&a.push(new o.TokenNode([t.TokenType.Comma,",",-1,-1,void 0]),new o.WhitespaceNode([[t.TokenType.Whitespace," ",-1,-1,void 0]]))}return a}function parseColorStops(e){const i=[];let s={};for(let r=0;r<e.length;r++){const a=e[r];if(o.isCommentNode(a)||o.isWhitespaceNode(a))continue;if(o.isTokenNode(a)&&a.value[0]===t.TokenType.Comma){if(s.color&&s.colorData&&s.positionA){i.push({color:s.color,colorData:s.colorData,position:s.positionA}),s.positionB&&i.push({color:s.color,colorData:s.colorData,position:s.positionB}),s={};continue}return!1}const l=n.color(a);if(l){if(s.color)return!1;s.color=a,s.colorData=l}else{if(!s.color)return!1;if(s.positionA){if(!s.positionA||s.positionB)return!1;s.positionB=a}else s.positionA=a}}return!(!s.color||!s.positionA)&&(s.color&&s.colorData&&s.positionA&&(i.push({color:s.color,colorData:s.colorData,position:s.positionA}),s.positionB&&i.push({color:s.color,colorData:s.colorData,position:s.positionB})),!(i.length<2)&&i)}const r=/^(srgb|srgb-linear|lab|oklab|xyz|xyz-d50|xyz-d65|hsl|hwb|lch|oklch)$/i,a=/^(hsl|hwb|lch|oklch)$/i,l=/^(shorter|longer|increasing|decreasing)$/i,c=/^in$/i,p=/^hue$/i;function modifyGradientFunctionComponentValues(e,n=!1){const i=e.getName();if(!s.test(i))return!1;let u="srgb",d=null,T=null,f=null,h=null,v=null,m=[];{let n=0,i=e.value[n];for(;i&&(!o.isTokenNode(i)||i.value[0]!==t.TokenType.Ident||!c.test(i.value[4].value));){if(o.isTokenNode(i)&&i.value[0]===t.TokenType.Comma)return!1;n++,i=e.value[n]}for(d=i,n++,i=e.value[n];o.isCommentNode(i)||o.isWhitespaceNode(i);)n++,i=e.value[n];if(o.isTokenNode(i)&&i.value[0]===t.TokenType.Ident&&r.test(i.value[4].value)){if(T)return!1;T=i,u=i.value[4].value,n++,i=e.value[n]}for(;o.isCommentNode(i)||o.isWhitespaceNode(i);)n++,i=e.value[n];if(o.isTokenNode(i)&&i.value[0]===t.TokenType.Ident&&l.test(i.value[4].value)&&a.test(u)){if(f||!T)return!1;f=i,n++,i=e.value[n]}for(;o.isCommentNode(i)||o.isWhitespaceNode(i);)n++,i=e.value[n];if(o.isTokenNode(i)&&i.value[0]===t.TokenType.Ident&&p.test(i.value[4].value)){if(h||!T||!f)return!1;h=i,n++,i=e.value[n]}for(;i&&(!o.isTokenNode(i)||i.value[0]!==t.TokenType.Comma);)n++,i=e.value[n];if(v=i,!v)return!1;m=e.value.slice(n+1)}if(!T)return!1;if(f&&!h)return!1;if(h&&!f)return!1;const k=parseColorStops(m);if(!k)return!1;const g=interpolateColorsInColorStopsList(k,T,f,n);if(!g)return!1;const N=trim([...e.value.slice(0,e.value.indexOf(d)),...e.value.slice(e.value.indexOf(h||T)+1,e.value.indexOf(v))]);return N.length>0&&N.some((e=>!o.isCommentNode(e)))&&N.push(new o.TokenNode([t.TokenType.Comma,",",-1,-1,void 0]),new o.WhitespaceNode([[t.TokenType.Whitespace," ",-1,-1,void 0]])),trim([...N,...trim(g)])}function trim(e){let t=0,n=e.length-1;for(let n=0;n<e.length;n++)if(!o.isWhitespaceNode(e[n])){t=n;break}for(let t=e.length-1;t>=0;t--)if(!o.isWhitespaceNode(e[t])){n=t;break}return e.slice(t,n+1)}const basePlugin=e=>({postcssPlugin:"postcss-gradients-interpolation-method",Declaration(n){if(!i.test(n.value))return;if(hasFallback(n))return;if(hasSupportsAtRuleAncestor(n))return;const s=t.tokenize({css:n.value}),r=o.stringify(o.replaceComponentValues(o.parseCommaSeparatedListOfComponentValues(s),(e=>{if(!o.isFunctionNode(e))return;const t=modifyGradientFunctionComponentValues(e);t&&(e.value=t)})));if(r===n.value)return;const a=o.stringify(o.replaceComponentValues(o.parseCommaSeparatedListOfComponentValues(s),(e=>{if(!o.isFunctionNode(e))return;const t=modifyGradientFunctionComponentValues(e,!0);t&&(e.value=t)})));n.cloneBefore({value:r}),r!==a&&n.cloneBefore({value:a}),null!=e&&e.preserve||n.remove()}});basePlugin.postcss=!0;const postcssPlugin=o=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},o);return t.enableProgressiveCustomProperties?{postcssPlugin:"postcss-gradients-interpolation-method",plugins:[e(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/node_modules/@csstools/postcss-gradients-interpolation-method/dist/index.d.ts b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/index.d.ts new file mode 100644 index 00000000..0520e965 --- /dev/null +++ b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/index.d.ts @@ -0,0 +1,10 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-gradients-interpolation-method plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: true */ + preserve?: boolean; + /** Enable "@csstools/postcss-progressive-custom-properties". default: true */ + enableProgressiveCustomProperties?: boolean; +}; +declare const postcssPlugin: PluginCreator<pluginOptions>; +export default postcssPlugin; diff --git a/node_modules/@csstools/postcss-gradients-interpolation-method/dist/index.mjs b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/index.mjs new file mode 100644 index 00000000..392d72e1 --- /dev/null +++ b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/index.mjs @@ -0,0 +1 @@ +import o from"@csstools/postcss-progressive-custom-properties";import{WhitespaceNode as e,TokenNode as t,FunctionNode as r,isCommentNode as n,isWhitespaceNode as i,isTokenNode as s,stringify as l,replaceComponentValues as a,parseCommaSeparatedListOfComponentValues as c,isFunctionNode as u}from"@csstools/css-parser-algorithms";import{TokenType as p,tokenize as f}from"@csstools/css-tokenizer";import{serializeP3 as v,color as h,colorDataFitsRGB_Gamut as d,serializeRGB as m}from"@csstools/css-color-parser";const g=/(repeating-)?(linear|radial|conic)-gradient\(.*?in/i,w=/^(repeating-)?(linear|radial|conic)-gradient$/i;function hasFallback(o){const e=o.parent;if(!e)return!1;const t=o.prop.toLowerCase(),r=e.index(o);for(let o=0;o<r;o++){const r=e.nodes[o];if("decl"===r.type&&r.prop.toLowerCase()===t)return!0}return!1}function hasSupportsAtRuleAncestor(o){let e=o.parent;for(;e;)if("atrule"===e.type){if("supports"===e.name&&g.test(e.params))return!0;e=e.parent}else e=e.parent;return!1}function interpolateColorsInColorStopsList(o,n,i,s=!1){const l=[],a=[];for(let s=0;s<o.length-1;s++){const l=o[s],c=o[s+1];if(a.push(l),i||v(l.colorData,!1).toString()!==v(c.colorData,!1).toString()&&l.position.toString()!==c.position.toString())for(let o=1;o<=9;o++){const s=10*o;let u=[];i&&(u=[new e([[p.Whitespace," ",-1,-1,void 0]]),i,new e([[p.Whitespace," ",-1,-1,void 0]]),new t([p.Ident,"hue",-1,-1,{value:"hue"}])]);const f=new r([p.Function,"color-mix(",-1,-1,{value:"color-mix"}],[p.CloseParen,")",-1,-1,void 0],[new t([p.Ident,"in",-1,-1,{value:"in"}]),new e([[p.Whitespace," ",-1,-1,void 0]]),n,...u,new t([p.Comma,",",-1,-1,void 0]),new e([[p.Whitespace," ",-1,-1,void 0]]),l.color,new e([[p.Whitespace," ",-1,-1,void 0]]),new t([p.Percentage,100-s+"%",-1,-1,{value:100-s}]),new t([p.Comma,",",-1,-1,void 0]),new e([[p.Whitespace," ",-1,-1,void 0]]),c.color,new e([[p.Whitespace," ",-1,-1,void 0]]),new t([p.Percentage,`${s}%`,-1,-1,{value:s}])]),v=h(f);if(!v)return!1;a.push({colorData:v})}s===o.length-2&&a.push(c)}for(let o=0;o<a.length;o++)s&&!d(a[o].colorData)?a[o].color=v(a[o].colorData,!1):a[o].color=m(a[o].colorData,!1);for(let o=0;o<a.length;o++){const r=a[o];r.position?l.push(r.color,new e([[p.Whitespace," ",-1,-1,void 0]]),r.position):l.push(r.color),o!==a.length-1&&l.push(new t([p.Comma,",",-1,-1,void 0]),new e([[p.Whitespace," ",-1,-1,void 0]]))}return l}function parseColorStops(o){const e=[];let t={};for(let r=0;r<o.length;r++){const l=o[r];if(n(l)||i(l))continue;if(s(l)&&l.value[0]===p.Comma){if(t.color&&t.colorData&&t.positionA){e.push({color:t.color,colorData:t.colorData,position:t.positionA}),t.positionB&&e.push({color:t.color,colorData:t.colorData,position:t.positionB}),t={};continue}return!1}const a=h(l);if(a){if(t.color)return!1;t.color=l,t.colorData=a}else{if(!t.color)return!1;if(t.positionA){if(!t.positionA||t.positionB)return!1;t.positionB=l}else t.positionA=l}}return!(!t.color||!t.positionA)&&(t.color&&t.colorData&&t.positionA&&(e.push({color:t.color,colorData:t.colorData,position:t.positionA}),t.positionB&&e.push({color:t.color,colorData:t.colorData,position:t.positionB})),!(e.length<2)&&e)}const C=/^(srgb|srgb-linear|lab|oklab|xyz|xyz-d50|xyz-d65|hsl|hwb|lch|oklch)$/i,D=/^(hsl|hwb|lch|oklch)$/i,b=/^(shorter|longer|increasing|decreasing)$/i,A=/^in$/i,x=/^hue$/i;function modifyGradientFunctionComponentValues(o,r=!1){const l=o.getName();if(!w.test(l))return!1;let a="srgb",c=null,u=null,f=null,v=null,h=null,d=[];{let e=0,t=o.value[e];for(;t&&(!s(t)||t.value[0]!==p.Ident||!A.test(t.value[4].value));){if(s(t)&&t.value[0]===p.Comma)return!1;e++,t=o.value[e]}for(c=t,e++,t=o.value[e];n(t)||i(t);)e++,t=o.value[e];if(s(t)&&t.value[0]===p.Ident&&C.test(t.value[4].value)){if(u)return!1;u=t,a=t.value[4].value,e++,t=o.value[e]}for(;n(t)||i(t);)e++,t=o.value[e];if(s(t)&&t.value[0]===p.Ident&&b.test(t.value[4].value)&&D.test(a)){if(f||!u)return!1;f=t,e++,t=o.value[e]}for(;n(t)||i(t);)e++,t=o.value[e];if(s(t)&&t.value[0]===p.Ident&&x.test(t.value[4].value)){if(v||!u||!f)return!1;v=t,e++,t=o.value[e]}for(;t&&(!s(t)||t.value[0]!==p.Comma);)e++,t=o.value[e];if(h=t,!h)return!1;d=o.value.slice(e+1)}if(!u)return!1;if(f&&!v)return!1;if(v&&!f)return!1;const m=parseColorStops(d);if(!m)return!1;const g=interpolateColorsInColorStopsList(m,u,f,r);if(!g)return!1;const S=trim([...o.value.slice(0,o.value.indexOf(c)),...o.value.slice(o.value.indexOf(v||u)+1,o.value.indexOf(h))]);return S.length>0&&S.some((o=>!n(o)))&&S.push(new t([p.Comma,",",-1,-1,void 0]),new e([[p.Whitespace," ",-1,-1,void 0]])),trim([...S,...trim(g)])}function trim(o){let e=0,t=o.length-1;for(let t=0;t<o.length;t++)if(!i(o[t])){e=t;break}for(let e=o.length-1;e>=0;e--)if(!i(o[e])){t=e;break}return o.slice(e,t+1)}const basePlugin=o=>({postcssPlugin:"postcss-gradients-interpolation-method",Declaration(e){if(!g.test(e.value))return;if(hasFallback(e))return;if(hasSupportsAtRuleAncestor(e))return;const t=f({css:e.value}),r=l(a(c(t),(o=>{if(!u(o))return;const e=modifyGradientFunctionComponentValues(o);e&&(o.value=e)})));if(r===e.value)return;const n=l(a(c(t),(o=>{if(!u(o))return;const e=modifyGradientFunctionComponentValues(o,!0);e&&(o.value=e)})));e.cloneBefore({value:r}),r!==n&&e.cloneBefore({value:n}),null!=o&&o.preserve||e.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},e);return t.enableProgressiveCustomProperties?{postcssPlugin:"postcss-gradients-interpolation-method",plugins:[o(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; diff --git a/node_modules/@csstools/postcss-gradients-interpolation-method/dist/is-gradient.d.ts b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/is-gradient.d.ts new file mode 100644 index 00000000..2d83e89e --- /dev/null +++ b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/is-gradient.d.ts @@ -0,0 +1,2 @@ +export declare const gradientFunctionRegex: RegExp; +export declare const gradientNameRegex: RegExp; diff --git a/node_modules/@csstools/postcss-gradients-interpolation-method/dist/modify-gradient-component-values.d.ts b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/modify-gradient-component-values.d.ts new file mode 100644 index 00000000..6917beda --- /dev/null +++ b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/modify-gradient-component-values.d.ts @@ -0,0 +1,2 @@ +import type { ComponentValue, FunctionNode } from '@csstools/css-parser-algorithms'; +export declare function modifyGradientFunctionComponentValues(gradientFunction: FunctionNode, wideGamut?: boolean): Array<ComponentValue> | false; diff --git a/node_modules/@csstools/postcss-gradients-interpolation-method/dist/parse-color-stops.d.ts b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/parse-color-stops.d.ts new file mode 100644 index 00000000..0342da5c --- /dev/null +++ b/node_modules/@csstools/postcss-gradients-interpolation-method/dist/parse-color-stops.d.ts @@ -0,0 +1,3 @@ +import type { ColorStop } from './color-stop-list'; +import type { ComponentValue } from '@csstools/css-parser-algorithms'; +export declare function parseColorStops(componentValues: Array<ComponentValue>): Array<ColorStop> | false; diff --git a/node_modules/@csstools/postcss-gradients-interpolation-method/package.json b/node_modules/@csstools/postcss-gradients-interpolation-method/package.json new file mode 100644 index 00000000..b6fdb43e --- /dev/null +++ b/node_modules/@csstools/postcss-gradients-interpolation-method/package.json @@ -0,0 +1,88 @@ +{ + "name": "@csstools/postcss-gradients-interpolation-method", + "description": "Use interpolation methods in CSS gradient functions", + "version": "4.0.7", + "author": "Jonathan Neal <jonathantneal@hotmail.com>", + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/css-color-parser": "^1.4.0", + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1", + "@csstools/postcss-progressive-custom-properties": "^3.0.2" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-gradients-interpolation-method#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-gradients-interpolation-method" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "color", + "color space interpolation", + "conic", + "css", + "gradients", + "hue interpolation method", + "interpolation", + "linear", + "postcss", + "postcss-plugin", + "radial", + "repeating", + "syntax" + ], + "csstools": { + "cssdbId": "gradients-interpolation-method", + "exportName": "postcssGradientsInterpolationMethod", + "humanReadableName": "PostCSS Gradients Interpolation Method", + "specUrl": "https://drafts.csswg.org/css-images-4/#linear-gradients" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-hwb-function/CHANGELOG.md b/node_modules/@csstools/postcss-hwb-function/CHANGELOG.md new file mode 100644 index 00000000..d3d6844f --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/CHANGELOG.md @@ -0,0 +1,113 @@ +# Changes to PostCSS HWB Function + +### 3.0.6 + +_October 9, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.4.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#140) (minor) + +### 3.0.5 + +_October 2, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#133) (patch) + +### 3.0.4 + +_September 24, 2023_ + +- 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-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#132) (patch) + +### 3.0.3 + +_September 2, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#131) (patch) + +### 3.0.2 + +_August 28, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#130) (minor) + +### 3.0.1 + +_July 24, 2023_ + +- 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) + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) +- 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-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.2.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#122) (patch) + +### 2.2.2 + +_May 19, 2023_ + +- Ignore relative color syntax +- Updated `@csstools/css-color-parser` to `1.2.0` (minor) + + +### 2.2.1 + +_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-color-parser` to `1.1.2` (patch) + +### 2.2.0 + +_March 25, 2023_ + +- Add `@csstools/css-color-parser` dependency for all color value transformations. +- Add support for `calc` expressions in color components. + +### 2.1.1 + +_February 8, 2023_ + +- Reduce the amount of duplicate fallback CSS. + +### 2.1.0 + +_February 2, 2023_ + +- Add: `@csstools/color-helpers` dependency for all color value transformations. + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). + +### 1.0.2 + +_July 8, 2022_ + +- Fix case insensitive matching. + +### 1.0.1 + +_May 18, 2022_ + +- Fix grayscale conversions. + +### 1.0.0 + +_January 22, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-hwb-function/INSTALL.md b/node_modules/@csstools/postcss-hwb-function/INSTALL.md new file mode 100644 index 00000000..eaf1cf25 --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/INSTALL.md @@ -0,0 +1,235 @@ +# Installing PostCSS HWB Function + +[PostCSS HWB Function] runs in all Node environments, with special instructions for: + +- [Node](#node) +- [PostCSS CLI](#postcss-cli) +- [PostCSS Load Config](#postcss-load-config) +- [Webpack](#webpack) +- [Next.js](#nextjs) +- [Gulp](#gulp) +- [Grunt](#grunt) + + + +## Node + +Add [PostCSS HWB Function] to your project: + +```bash +npm install postcss @csstools/postcss-hwb-function --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +// commonjs +const postcss = require('postcss'); +const postcssHWBFunction = require('@csstools/postcss-hwb-function'); + +postcss([ + postcssHWBFunction(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +```js +// esm +import postcss from 'postcss'; +import postcssHWBFunction from '@csstools/postcss-hwb-function'; + +postcss([ + postcssHWBFunction(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +## PostCSS CLI + +Add [PostCSS CLI] to your project: + +```bash +npm install postcss-cli @csstools/postcss-hwb-function --save-dev +``` + +Use [PostCSS HWB Function] in your `postcss.config.js` configuration file: + +```js +const postcssHWBFunction = require('@csstools/postcss-hwb-function'); + +module.exports = { + plugins: [ + postcssHWBFunction(/* pluginOptions */) + ] +} +``` + +## PostCSS Load Config + +If your framework/CLI supports [`postcss-load-config`](https://github.com/postcss/postcss-load-config). + +```bash +npm install @csstools/postcss-hwb-function --save-dev +``` + +`package.json`: + +```json +{ + "postcss": { + "plugins": { + "@csstools/postcss-hwb-function": {} + } + } +} +``` + +`.postcssrc.json`: + +```json +{ + "plugins": { + "@csstools/postcss-hwb-function": {} + } +} +``` + +_See the [README of `postcss-load-config`](https://github.com/postcss/postcss-load-config#usage) for more usage options._ + +## Webpack + +_Webpack version 5_ + +Add [PostCSS Loader] to your project: + +```bash +npm install postcss-loader @csstools/postcss-hwb-function --save-dev +``` + +Use [PostCSS HWB Function] in your Webpack configuration: + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/i, + use: [ + "style-loader", + { + loader: "css-loader", + options: { importLoaders: 1 }, + }, + { + loader: "postcss-loader", + options: { + postcssOptions: { + plugins: [ + // Other plugins, + [ + "@csstools/postcss-hwb-function", + { + // Options + }, + ], + ], + }, + }, + }, + ], + }, + ], + }, +}; +``` + +## Next.js + +Read the instructions on how to [customize the PostCSS configuration in Next.js](https://nextjs.org/docs/advanced-features/customizing-postcss-config) + +```bash +npm install @csstools/postcss-hwb-function --save-dev +``` + +Use [PostCSS HWB Function] in your `postcss.config.json` file: + +```json +{ + "plugins": [ + "@csstools/postcss-hwb-function" + ] +} +``` + +```json5 +{ + "plugins": [ + [ + "@csstools/postcss-hwb-function", + { + // Optionally add plugin options + } + ] + ] +} +``` + +## Gulp + +Add [Gulp PostCSS] to your project: + +```bash +npm install gulp-postcss @csstools/postcss-hwb-function --save-dev +``` + +Use [PostCSS HWB Function] in your Gulpfile: + +```js +const postcss = require('gulp-postcss'); +const postcssHWBFunction = require('@csstools/postcss-hwb-function'); + +gulp.task('css', function () { + var plugins = [ + postcssHWBFunction(/* pluginOptions */) + ]; + + return gulp.src('./src/*.css') + .pipe(postcss(plugins)) + .pipe(gulp.dest('.')); +}); +``` + +## Grunt + +Add [Grunt PostCSS] to your project: + +```bash +npm install grunt-postcss @csstools/postcss-hwb-function --save-dev +``` + +Use [PostCSS HWB Function] in your Gruntfile: + +```js +const postcssHWBFunction = require('@csstools/postcss-hwb-function'); + +grunt.loadNpmTasks('grunt-postcss'); + +grunt.initConfig({ + postcss: { + options: { + processors: [ + postcssHWBFunction(/* pluginOptions */) + ] + }, + dist: { + src: '*.css' + } + } +}); +``` + +[Gulp PostCSS]: https://github.com/postcss/gulp-postcss +[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss +[PostCSS]: https://github.com/postcss/postcss +[PostCSS CLI]: https://github.com/postcss/postcss-cli +[PostCSS Loader]: https://github.com/postcss/postcss-loader +[PostCSS HWB Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-hwb-function +[Next.js]: https://nextjs.org diff --git a/node_modules/@csstools/postcss-hwb-function/LICENSE.md b/node_modules/@csstools/postcss-hwb-function/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-hwb-function/README.md b/node_modules/@csstools/postcss-hwb-function/README.md new file mode 100644 index 00000000..1d20d6da --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/README.md @@ -0,0 +1,88 @@ +# PostCSS HWB Function [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-hwb-function.svg" height="20">][npm-url] +[<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/hwb-function.svg" height="20">][css-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + + +[PostCSS HWB Function] lets you use `hwb` color functions in +CSS, following the [CSS Color] specification. + +```pcss +a { + color: hwb(194 0% 0%); + color: hwb(194 0% 0% / .5); +} + +/* becomes */ + +a { + color: rgb(0, 195, 255); + color: rgba(0, 195, 255, .5); +} +``` + +## Usage + +Add [PostCSS HWB Function] to your project: + +```bash +npm install postcss @csstools/postcss-hwb-function --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssHWBFunction = require('@csstools/postcss-hwb-function'); + +postcss([ + postcssHWBFunction(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS HWB Function] runs in all Node environments, with special +instructions for: + +| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) | +| --- | --- | --- | --- | --- | + +## Options + +### preserve + +The `preserve` option determines whether the original functional color notation +is preserved. By default, it is not preserved. + +```js +postcssHWBFunction({ preserve: true }) +``` + +```pcss +a { + color: hwb(194 0% 0%); + color: hwb(194 0% 0% / .5); +} + +/* becomes */ + +a { + color: rgb(0, 195, 255); + color: hwb(194 0% 0%); + color: rgba(0, 195, 255, .5); + color: hwb(194 0% 0% / .5); +} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#hwb-function +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-hwb-function + +[CSS Color]: https://drafts.csswg.org/css-color/#the-hwb-notation +[Gulp PostCSS]: https://github.com/postcss/gulp-postcss +[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Loader]: https://github.com/postcss/postcss-loader +[PostCSS HWB Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-hwb-function diff --git a/node_modules/@csstools/postcss-hwb-function/dist/has-fallback-decl.d.ts b/node_modules/@csstools/postcss-hwb-function/dist/has-fallback-decl.d.ts new file mode 100644 index 00000000..d7ae8d89 --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/dist/has-fallback-decl.d.ts @@ -0,0 +1,2 @@ +import type { Declaration } from 'postcss'; +export declare function hasFallback(node: Declaration): boolean; diff --git a/node_modules/@csstools/postcss-hwb-function/dist/has-supports-at-rule-ancestor.d.ts b/node_modules/@csstools/postcss-hwb-function/dist/has-supports-at-rule-ancestor.d.ts new file mode 100644 index 00000000..7fbe0b29 --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/dist/has-supports-at-rule-ancestor.d.ts @@ -0,0 +1,3 @@ +import type { Node } from 'postcss'; +export declare const atSupportsHwbParams = "(color: hwb(0 0% 0%))"; +export declare function hasSupportsAtRuleAncestor(node: Node): boolean; diff --git a/node_modules/@csstools/postcss-hwb-function/dist/index.cjs b/node_modules/@csstools/postcss-hwb-function/dist/index.cjs new file mode 100644 index 00000000..19fafe2e --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/css-color-parser"),t=require("@csstools/css-parser-algorithms"),r=require("@csstools/css-tokenizer");const s="(color: hwb(0 0% 0%))";function hasSupportsAtRuleAncestor(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name.toLowerCase()&&t.params.includes(s))return!0;t=t.parent}else t=t.parent;return!1}function hasFallback(e){const t=e.parent;if(!t)return!1;const r=e.prop.toLowerCase(),s=t.index(e);for(let e=0;e<s;e++){const s=t.nodes[e];if("decl"===s.type&&s.prop.toLowerCase()===r)return!0}return!1}const o=/hwb\(/i,n=/^hwb$/i,postcssPlugin=a=>{const l="preserve"in Object(a)&&Boolean(null==a?void 0:a.preserve);return{postcssPlugin:"postcss-hwb-function",Declaration:(a,{postcss:c})=>{const p=a.value;if(!o.test(p))return;if(l&&hasSupportsAtRuleAncestor(a))return;if(hasFallback(a))return;const u=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(r.tokenize({css:p})),(r=>{if(t.isFunctionNode(r)&&n.test(r.getName())){const t=e.color(r);if(!t)return;if(t.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords))return;if(t.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax))return;return e.serializeRGB(t)}})),i=t.stringify(u);if(i!==p)if(a.variable&&l&&a.parent){const e=a.parent,t=c.atRule({name:"supports",params:s,source:a.source}),r=e.clone();r.removeAll(),r.append(a.clone()),t.append(r),insertAtSupportsAfterCorrectRule(t,e,s),a.replaceWith(a.clone({value:i}))}else l?a.cloneBefore({value:i}):a.replaceWith(a.clone({value:i}))}}};function insertAtSupportsAfterCorrectRule(e,t,r){let s=t,o=t.next();for(;s&&o&&"atrule"===o.type&&"supports"===o.name.toLowerCase()&&o.params===r;)s=o,o=o.next();s.after(e)}postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/node_modules/@csstools/postcss-hwb-function/dist/index.d.ts b/node_modules/@csstools/postcss-hwb-function/dist/index.d.ts new file mode 100644 index 00000000..0304f878 --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/dist/index.d.ts @@ -0,0 +1,9 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-hwb-function plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; +}; +/** Transform hwb() functions in CSS. */ +declare const postcssPlugin: PluginCreator<pluginOptions>; +export default postcssPlugin; diff --git a/node_modules/@csstools/postcss-hwb-function/dist/index.mjs b/node_modules/@csstools/postcss-hwb-function/dist/index.mjs new file mode 100644 index 00000000..067e6891 --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/dist/index.mjs @@ -0,0 +1 @@ +import{color as e,SyntaxFlag as t,serializeRGB as r}from"@csstools/css-color-parser";import{replaceComponentValues as s,parseCommaSeparatedListOfComponentValues as o,isFunctionNode as n,stringify as a}from"@csstools/css-parser-algorithms";import{tokenize as l}from"@csstools/css-tokenizer";const p="(color: hwb(0 0% 0%))";function hasSupportsAtRuleAncestor(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name.toLowerCase()&&t.params.includes(p))return!0;t=t.parent}else t=t.parent;return!1}function hasFallback(e){const t=e.parent;if(!t)return!1;const r=e.prop.toLowerCase(),s=t.index(e);for(let e=0;e<s;e++){const s=t.nodes[e];if("decl"===s.type&&s.prop.toLowerCase()===r)return!0}return!1}const c=/hwb\(/i,u=/^hwb$/i,postcssPlugin=i=>{const f="preserve"in Object(i)&&Boolean(null==i?void 0:i.preserve);return{postcssPlugin:"postcss-hwb-function",Declaration:(i,{postcss:m})=>{const h=i.value;if(!c.test(h))return;if(f&&hasSupportsAtRuleAncestor(i))return;if(hasFallback(i))return;const v=s(o(l({css:h})),(s=>{if(n(s)&&u.test(s.getName())){const o=e(s);if(!o)return;if(o.syntaxFlags.has(t.HasNoneKeywords))return;if(o.syntaxFlags.has(t.RelativeColorSyntax))return;return r(o)}})),d=a(v);if(d!==h)if(i.variable&&f&&i.parent){const e=i.parent,t=m.atRule({name:"supports",params:p,source:i.source}),r=e.clone();r.removeAll(),r.append(i.clone()),t.append(r),insertAtSupportsAfterCorrectRule(t,e,p),i.replaceWith(i.clone({value:d}))}else f?i.cloneBefore({value:d}):i.replaceWith(i.clone({value:d}))}}};function insertAtSupportsAfterCorrectRule(e,t,r){let s=t,o=t.next();for(;s&&o&&"atrule"===o.type&&"supports"===o.name.toLowerCase()&&o.params===r;)s=o,o=o.next();s.after(e)}postcssPlugin.postcss=!0;export{postcssPlugin as default}; diff --git a/node_modules/@csstools/postcss-hwb-function/package.json b/node_modules/@csstools/postcss-hwb-function/package.json new file mode 100644 index 00000000..de60d8d8 --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/package.json @@ -0,0 +1,88 @@ +{ + "name": "@csstools/postcss-hwb-function", + "description": "Use hwb() color functions in CSS", + "version": "3.0.6", + "author": "Jonathan Neal <jonathantneal@hotmail.com>", + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "INSTALL.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/css-color-parser": "^1.4.0", + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-hwb-function#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-hwb-function" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "color", + "comma", + "css", + "design", + "functional", + "hsl", + "hsla", + "hwb", + "notation", + "postcss", + "postcss-plugin", + "rgb", + "rgba", + "space", + "syntax" + ], + "csstools": { + "exportName": "postcssHWBFunction", + "humanReadableName": "PostCSS HWB Function" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-ic-unit/CHANGELOG.md b/node_modules/@csstools/postcss-ic-unit/CHANGELOG.md new file mode 100644 index 00000000..33354058 --- /dev/null +++ b/node_modules/@csstools/postcss-ic-unit/CHANGELOG.md @@ -0,0 +1,65 @@ +# Changes to PostCSS IC Unit + +### 3.0.2 + +_October 9, 2023_ + +- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.2`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#302) (patch) + +### 3.0.1 + +_September 18, 2023_ + +- Improve performance +- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.1`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#301) (patch) + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) +- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#300) (major) + +### 2.0.4 + +_June 1, 2023_ + +- Updated `@csstools/postcss-progressive-custom-properties` to `2.3.0` (minor) + + +### 2.0.3 + +_May 19, 2023_ + +- Updated `@csstools/postcss-progressive-custom-properties` to `2.2.0` (minor) + + +### 2.0.2 + +_February 8, 2023_ + +- Reduce the amount of duplicate fallback CSS. + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). + +### 1.0.1 + +_July 8, 2022_ + +- Fix case insensitive matching. + +### 1.0.0 + +_February 15, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-ic-unit/LICENSE.md b/node_modules/@csstools/postcss-ic-unit/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-ic-unit/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-ic-unit/README.md b/node_modules/@csstools/postcss-ic-unit/README.md new file mode 100644 index 00000000..b7069c16 --- /dev/null +++ b/node_modules/@csstools/postcss-ic-unit/README.md @@ -0,0 +1,94 @@ +# PostCSS IC Unit [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss] + + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-ic-unit.svg" height="20">][npm-url] +[<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/ic-unit.svg" height="20">][css-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +[PostCSS IC Unit] lets you use the ic length unit, following the [CSS Values and Units Module] specification. + +```pcss +p { + text-indent: 2ic; +} + +.bubble { + width: calc(8ic + 20px); +} + +/* becomes */ +p { + text-indent: 2em; +} + +.bubble { + width: calc(8em + 20px); +} +``` + +_See prior work by [JLHwung](https://github.com/JLHwung) here [postcss-ic-unit](https://github.com/JLHwung/postcss-ic-unit) +To ensure long term maintenance and to provide the needed features this plugin was recreated based on JLHwung's work._ + +## Usage + +Add [PostCSS IC Unit] to your project: + +```bash +npm install postcss @csstools/postcss-ic-unit --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssIcUnit = require('@csstools/postcss-ic-unit'); + +postcss([ + postcssIcUnit(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS IC Unit] runs in all Node environments, with special +instructions for: + +| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) | +| --- | --- | --- | --- | --- | + +## Options + +### preserve + +The `preserve` option determines whether the original source +is preserved. By default, it is not preserved. + +```js +postcssIcUnit({ preserve: true }) +``` + +```pcss +p { + text-indent: 2ic; +} + +/* becomes */ + +p { + text-indent: 2em; + text-indent: 2ic; +} +``` + +[postcss]: https://github.com/postcss/postcss + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#ic-unit +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-ic-unit + +[Gulp PostCSS]: https://github.com/postcss/gulp-postcss +[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Loader]: https://github.com/postcss/postcss-loader +[CSS Values and Units Module]: https://www.w3.org/TR/css-values-4/#ic +[PostCSS IC Unit]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-ic-unit diff --git a/node_modules/@csstools/postcss-ic-unit/dist/has-fallback-decl.d.ts b/node_modules/@csstools/postcss-ic-unit/dist/has-fallback-decl.d.ts new file mode 100644 index 00000000..d7ae8d89 --- /dev/null +++ b/node_modules/@csstools/postcss-ic-unit/dist/has-fallback-decl.d.ts @@ -0,0 +1,2 @@ +import type { Declaration } from 'postcss'; +export declare function hasFallback(node: Declaration): boolean; diff --git a/node_modules/@csstools/postcss-ic-unit/dist/has-supports-at-rule-ancestor.d.ts b/node_modules/@csstools/postcss-ic-unit/dist/has-supports-at-rule-ancestor.d.ts new file mode 100644 index 00000000..a46009ec --- /dev/null +++ b/node_modules/@csstools/postcss-ic-unit/dist/has-supports-at-rule-ancestor.d.ts @@ -0,0 +1,2 @@ +import type { Node } from 'postcss'; +export declare function hasSupportsAtRuleAncestor(node: Node): boolean; diff --git a/node_modules/@csstools/postcss-ic-unit/dist/index.cjs b/node_modules/@csstools/postcss-ic-unit/dist/index.cjs new file mode 100644 index 00000000..d85ab48a --- /dev/null +++ b/node_modules/@csstools/postcss-ic-unit/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),s=require("postcss-value-parser");function hasFallback(e){const s=e.parent;if(!s)return!1;const t=e.prop.toLowerCase(),r=s.index(e);for(let e=0;e<r;e++){const r=s.nodes[e];if("decl"===r.type&&r.prop.toLowerCase()===t)return!0}return!1}function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name.toLowerCase()&&/\(font-size: \d+ic\)/i.test(s.params))return!0;s=s.parent}else s=s.parent;return!1}const t=/ic\b/i,basePlugin=e=>({postcssPlugin:"postcss-ic-unit",Declaration(r){if(!t.test(r.value))return;if(hasFallback(r))return;if(hasSupportsAtRuleAncestor(r))return;const o=s(r.value);o.walk((e=>{if(!e.type||"word"!==e.type)return;const t=s.unit(e.value);t&&"ic"===t.unit.toLowerCase()&&(e.value=`${t.number}em`)}));const n=String(o);n!==r.value&&(r.cloneBefore({value:n}),null!=e&&e.preserve||r.remove())}});basePlugin.postcss=!0;const postcssPlugin=s=>{const t=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},s);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-ic-unit",plugins:[e(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/node_modules/@csstools/postcss-ic-unit/dist/index.d.ts b/node_modules/@csstools/postcss-ic-unit/dist/index.d.ts new file mode 100644 index 00000000..6900fd7d --- /dev/null +++ b/node_modules/@csstools/postcss-ic-unit/dist/index.d.ts @@ -0,0 +1,10 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-ic-unit plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; + /** Enable "@csstools/postcss-progressive-custom-properties". default: true */ + enableProgressiveCustomProperties?: boolean; +}; +declare const postcssPlugin: PluginCreator<pluginOptions>; +export default postcssPlugin; diff --git a/node_modules/@csstools/postcss-ic-unit/dist/index.mjs b/node_modules/@csstools/postcss-ic-unit/dist/index.mjs new file mode 100644 index 00000000..ef0b7a83 --- /dev/null +++ b/node_modules/@csstools/postcss-ic-unit/dist/index.mjs @@ -0,0 +1 @@ +import e from"@csstools/postcss-progressive-custom-properties";import s from"postcss-value-parser";function hasFallback(e){const s=e.parent;if(!s)return!1;const t=e.prop.toLowerCase(),r=s.index(e);for(let e=0;e<r;e++){const r=s.nodes[e];if("decl"===r.type&&r.prop.toLowerCase()===t)return!0}return!1}function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name.toLowerCase()&&/\(font-size: \d+ic\)/i.test(s.params))return!0;s=s.parent}else s=s.parent;return!1}const t=/ic\b/i,basePlugin=e=>({postcssPlugin:"postcss-ic-unit",Declaration(r){if(!t.test(r.value))return;if(hasFallback(r))return;if(hasSupportsAtRuleAncestor(r))return;const o=s(r.value);o.walk((e=>{if(!e.type||"word"!==e.type)return;const t=s.unit(e.value);t&&"ic"===t.unit.toLowerCase()&&(e.value=`${t.number}em`)}));const n=String(o);n!==r.value&&(r.cloneBefore({value:n}),null!=e&&e.preserve||r.remove())}});basePlugin.postcss=!0;const postcssPlugin=s=>{const t=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},s);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-ic-unit",plugins:[e(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; diff --git a/node_modules/@csstools/postcss-ic-unit/package.json b/node_modules/@csstools/postcss-ic-unit/package.json new file mode 100644 index 00000000..e638c94a --- /dev/null +++ b/node_modules/@csstools/postcss-ic-unit/package.json @@ -0,0 +1,78 @@ +{ + "name": "@csstools/postcss-ic-unit", + "description": "Use the ic length unit", + "version": "3.0.2", + "author": "Jonathan Neal <jonathantneal@hotmail.com>", + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/postcss-progressive-custom-properties": "^3.0.2", + "postcss-value-parser": "^4.2.0" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-ic-unit#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-ic-unit" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "CJK water ideograph", + "css", + "glyph", + "ic", + "length", + "postcss-plugin", + "values" + ], + "csstools": { + "exportName": "postcssIcUnit", + "humanReadableName": "PostCSS IC Unit" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-initial/CHANGELOG.md b/node_modules/@csstools/postcss-initial/CHANGELOG.md new file mode 100644 index 00000000..296a43b5 --- /dev/null +++ b/node_modules/@csstools/postcss-initial/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changes to PostCSS Initial + +### 1.0.0 + +_September 18, 2023_ + +- Initial version diff --git a/node_modules/@csstools/postcss-initial/LICENSE.md b/node_modules/@csstools/postcss-initial/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-initial/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-initial/README.md b/node_modules/@csstools/postcss-initial/README.md new file mode 100644 index 00000000..26d6b14a --- /dev/null +++ b/node_modules/@csstools/postcss-initial/README.md @@ -0,0 +1,87 @@ +# PostCSS Initial [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-initial.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/all-property.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +```bash +npm install @csstools/postcss-initial --save-dev +``` + +[PostCSS Initial] fallback the `initial` keyword following the [CSS Cascade 4 Specification]. + +```pcss +.foo { + border: initial; +} + +/* becomes */ + +.foo { + border: medium none currentcolor; + border: initial; +} +``` + +_See prior work by [maximkoretskiy](https://github.com/maximkoretskiy) here [postcss-initial](https://github.com/maximkoretskiy/postcss-initial) +To ensure long term maintenance and to provide the needed features this plugin was recreated based on maximkoretskiy's work._ + +## Usage + +Add [PostCSS Initial] to your project: + +```bash +npm install postcss @csstools/postcss-initial --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssInitial = require('@csstools/postcss-initial'); + +postcss([ + postcssInitial(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Initial] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is preserved. + +```js +postcssInitial({ preserve: false }) +``` + +```pcss +.foo { + border: initial; +} + +/* becomes */ + +.foo { + border: medium none currentcolor; +} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#all-property +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-initial + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Initial]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-initial +[CSS Cascade 4 Specification]: https://www.w3.org/TR/css-cascade-4/#initial diff --git a/node_modules/@csstools/postcss-initial/dist/has-fallback-decl.d.ts b/node_modules/@csstools/postcss-initial/dist/has-fallback-decl.d.ts new file mode 100644 index 00000000..c044b787 --- /dev/null +++ b/node_modules/@csstools/postcss-initial/dist/has-fallback-decl.d.ts @@ -0,0 +1,2 @@ +import type { Declaration } from 'postcss'; +export declare function hasExactFallback(node: Declaration, newValue: string): boolean; diff --git a/node_modules/@csstools/postcss-initial/dist/index.cjs b/node_modules/@csstools/postcss-initial/dist/index.cjs new file mode 100644 index 00000000..a28e74ee --- /dev/null +++ b/node_modules/@csstools/postcss-initial/dist/index.cjs @@ -0,0 +1 @@ +"use strict";const o=new Map([["animation","none 0s ease 0s 1 normal none running"],["animation-delay","0s"],["animation-direction","normal"],["animation-duration","0s"],["animation-fill-mode","none"],["animation-iteration-count","1"],["animation-name","none"],["animation-play-state","running"],["animation-timing-function","ease"],["backface-visibility","visible"],["background","transparent none repeat 0 0 / auto auto padding-box border-box scroll"],["background-attachment","scroll"],["background-clip","border-box"],["background-color","transparent"],["background-image","none"],["background-origin","padding-box"],["background-position","0 0"],["background-position-x","0"],["background-position-y","0"],["background-repeat","repeat"],["background-size","auto auto"],["border","medium none currentcolor"],["border-style","none"],["border-width","medium"],["border-color","currentcolor"],["border-bottom","0"],["border-bottom-color","currentcolor"],["border-bottom-left-radius","0"],["border-bottom-right-radius","0"],["border-bottom-style","none"],["border-bottom-width","medium"],["border-collapse","separate"],["border-image","none"],["border-left","0"],["border-left-color","currentcolor"],["border-left-style","none"],["border-left-width","medium"],["border-radius","0"],["border-right","0"],["border-right-color","currentcolor"],["border-right-style","none"],["border-right-width","medium"],["border-spacing","0"],["border-top","0"],["border-top-color","currentcolor"],["border-top-left-radius","0"],["border-top-right-radius","0"],["border-top-style","none"],["border-top-width","medium"],["bottom","auto"],["box-shadow","none"],["box-sizing","content-box"],["caption-side","top"],["clear","none"],["clip","auto"],["color","#000"],["columns","auto"],["column-count","auto"],["column-fill","balance"],["column-gap","normal"],["column-rule","medium none currentcolor"],["column-rule-color","currentcolor"],["column-rule-style","none"],["column-rule-width","medium"],["column-span","1"],["column-width","auto"],["content","normal"],["counter-increment","none"],["counter-reset","none"],["cursor","auto"],["direction","ltr"],["display","inline"],["empty-cells","show"],["float","none"],["font-family","serif"],["font-size","medium"],["font-style","normal"],["font-variant","normal"],["font-weight","normal"],["font-stretch","normal"],["line-height","normal"],["height","auto"],["hyphens","none"],["left","auto"],["letter-spacing","normal"],["list-style","disc outside none"],["list-style-image","none"],["list-style-position","outside"],["list-style-type","disc"],["margin","0"],["margin-bottom","0"],["margin-left","0"],["margin-right","0"],["margin-top","0"],["max-height","none"],["max-width","none"],["min-height","0"],["min-width","0"],["opacity","1"],["orphans","2"],["outline","medium none currentcolor"],["outline-color","currentcolor"],["outline-style","none"],["outline-width","medium"],["overflow","visible"],["overflow-x","visible"],["overflow-y","visible"],["padding","0"],["padding-bottom","0"],["padding-left","0"],["padding-right","0"],["padding-top","0"],["page-break-after","auto"],["page-break-before","auto"],["page-break-inside","auto"],["perspective","none"],["perspective-origin","50% 50%"],["position","static"],["quotes",'"“" "”" "‘" "’"'],["right","auto"],["tab-size","8"],["table-layout","auto"],["text-align","left"],["text-align-last","auto"],["text-decoration","none"],["text-decoration-color","currentcolor"],["text-decoration-line","none"],["text-decoration-style","solid"],["text-indent","0"],["text-shadow","none"],["text-transform","none"],["top","auto"],["transform","none"],["transform-origin","50% 50% 0"],["transform-style","flat"],["transition","none 0s ease 0s"],["transition-delay","0s"],["transition-duration","0s"],["transition-property","none"],["transition-timing-function","ease"],["unicode-bidi","normal"],["vertical-align","baseline"],["visibility","visible"],["white-space","normal"],["widows","2"],["width","auto"],["word-spacing","normal"],["z-index","auto"]]),t=["animation","backface-visibility","background","border","border-collapse","border-image","border-radius","border-spacing","bottom","box-shadow","box-sizing","caption-side","clear","clip","color","columns","column-count","column-fill","column-gap","column-rule","column-span","column-width","content","counter-increment","counter-reset","cursor","display","empty-cells","float","font-family","font-size","font-style","font-variant","font-weight","font-stretch","line-height","font","height","hyphens","left","letter-spacing","list-style","margin","max-height","max-width","min-height","min-width","opacity","orphans","outline","overflow","overflow-x","overflow-y","padding","page-break-after","page-break-before","page-break-inside","perspective","perspective-origin","position","right","tab-size","table-layout","text-align","text-align-last","text-decoration","text-indent","text-shadow","text-transform","top","transform","transform-origin","transform-style","transition","vertical-align","visibility","white-space","widows","width","word-spacing","z-index"];function hasExactFallback(o,t){const e=o.parent;if(!e)return!1;const n=o.prop.toLowerCase();for(let r=e.index(o)-1;r>=0;r--){const o=e.nodes[r];if("decl"===o.type&&o.prop.toLowerCase()===n)return o.value===t}return!1}const e=/^\s?initial\s?$/i,n=/^font$/i,r=/^all$/i,i=["font-family","font-size","font-style","font-variant","font-weight","font-stretch","line-height"],creator=a=>{const l=Object.assign({preserve:!0},a);return{postcssPlugin:"postcss-initial",Declaration(a){if(a.variable)return;if(!e.test(a.value))return;let s;s=n.test(a.prop)?i:r.test(a.prop)?t:[a.prop.toLowerCase()],s.forEach((t=>{const e=o.get(t);e&&(hasExactFallback(a,e)||a.cloneBefore({prop:t,value:e}))})),l.preserve||a.remove()}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-initial/dist/index.d.ts b/node_modules/@csstools/postcss-initial/dist/index.d.ts new file mode 100644 index 00000000..55f858c1 --- /dev/null +++ b/node_modules/@csstools/postcss-initial/dist/index.d.ts @@ -0,0 +1,8 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-initial plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-initial/dist/index.mjs b/node_modules/@csstools/postcss-initial/dist/index.mjs new file mode 100644 index 00000000..be1f1b9d --- /dev/null +++ b/node_modules/@csstools/postcss-initial/dist/index.mjs @@ -0,0 +1 @@ +const o=new Map([["animation","none 0s ease 0s 1 normal none running"],["animation-delay","0s"],["animation-direction","normal"],["animation-duration","0s"],["animation-fill-mode","none"],["animation-iteration-count","1"],["animation-name","none"],["animation-play-state","running"],["animation-timing-function","ease"],["backface-visibility","visible"],["background","transparent none repeat 0 0 / auto auto padding-box border-box scroll"],["background-attachment","scroll"],["background-clip","border-box"],["background-color","transparent"],["background-image","none"],["background-origin","padding-box"],["background-position","0 0"],["background-position-x","0"],["background-position-y","0"],["background-repeat","repeat"],["background-size","auto auto"],["border","medium none currentcolor"],["border-style","none"],["border-width","medium"],["border-color","currentcolor"],["border-bottom","0"],["border-bottom-color","currentcolor"],["border-bottom-left-radius","0"],["border-bottom-right-radius","0"],["border-bottom-style","none"],["border-bottom-width","medium"],["border-collapse","separate"],["border-image","none"],["border-left","0"],["border-left-color","currentcolor"],["border-left-style","none"],["border-left-width","medium"],["border-radius","0"],["border-right","0"],["border-right-color","currentcolor"],["border-right-style","none"],["border-right-width","medium"],["border-spacing","0"],["border-top","0"],["border-top-color","currentcolor"],["border-top-left-radius","0"],["border-top-right-radius","0"],["border-top-style","none"],["border-top-width","medium"],["bottom","auto"],["box-shadow","none"],["box-sizing","content-box"],["caption-side","top"],["clear","none"],["clip","auto"],["color","#000"],["columns","auto"],["column-count","auto"],["column-fill","balance"],["column-gap","normal"],["column-rule","medium none currentcolor"],["column-rule-color","currentcolor"],["column-rule-style","none"],["column-rule-width","medium"],["column-span","1"],["column-width","auto"],["content","normal"],["counter-increment","none"],["counter-reset","none"],["cursor","auto"],["direction","ltr"],["display","inline"],["empty-cells","show"],["float","none"],["font-family","serif"],["font-size","medium"],["font-style","normal"],["font-variant","normal"],["font-weight","normal"],["font-stretch","normal"],["line-height","normal"],["height","auto"],["hyphens","none"],["left","auto"],["letter-spacing","normal"],["list-style","disc outside none"],["list-style-image","none"],["list-style-position","outside"],["list-style-type","disc"],["margin","0"],["margin-bottom","0"],["margin-left","0"],["margin-right","0"],["margin-top","0"],["max-height","none"],["max-width","none"],["min-height","0"],["min-width","0"],["opacity","1"],["orphans","2"],["outline","medium none currentcolor"],["outline-color","currentcolor"],["outline-style","none"],["outline-width","medium"],["overflow","visible"],["overflow-x","visible"],["overflow-y","visible"],["padding","0"],["padding-bottom","0"],["padding-left","0"],["padding-right","0"],["padding-top","0"],["page-break-after","auto"],["page-break-before","auto"],["page-break-inside","auto"],["perspective","none"],["perspective-origin","50% 50%"],["position","static"],["quotes",'"“" "”" "‘" "’"'],["right","auto"],["tab-size","8"],["table-layout","auto"],["text-align","left"],["text-align-last","auto"],["text-decoration","none"],["text-decoration-color","currentcolor"],["text-decoration-line","none"],["text-decoration-style","solid"],["text-indent","0"],["text-shadow","none"],["text-transform","none"],["top","auto"],["transform","none"],["transform-origin","50% 50% 0"],["transform-style","flat"],["transition","none 0s ease 0s"],["transition-delay","0s"],["transition-duration","0s"],["transition-property","none"],["transition-timing-function","ease"],["unicode-bidi","normal"],["vertical-align","baseline"],["visibility","visible"],["white-space","normal"],["widows","2"],["width","auto"],["word-spacing","normal"],["z-index","auto"]]),t=["animation","backface-visibility","background","border","border-collapse","border-image","border-radius","border-spacing","bottom","box-shadow","box-sizing","caption-side","clear","clip","color","columns","column-count","column-fill","column-gap","column-rule","column-span","column-width","content","counter-increment","counter-reset","cursor","display","empty-cells","float","font-family","font-size","font-style","font-variant","font-weight","font-stretch","line-height","font","height","hyphens","left","letter-spacing","list-style","margin","max-height","max-width","min-height","min-width","opacity","orphans","outline","overflow","overflow-x","overflow-y","padding","page-break-after","page-break-before","page-break-inside","perspective","perspective-origin","position","right","tab-size","table-layout","text-align","text-align-last","text-decoration","text-indent","text-shadow","text-transform","top","transform","transform-origin","transform-style","transition","vertical-align","visibility","white-space","widows","width","word-spacing","z-index"];function hasExactFallback(o,t){const e=o.parent;if(!e)return!1;const n=o.prop.toLowerCase();for(let r=e.index(o)-1;r>=0;r--){const o=e.nodes[r];if("decl"===o.type&&o.prop.toLowerCase()===n)return o.value===t}return!1}const e=/^\s?initial\s?$/i,n=/^font$/i,r=/^all$/i,i=["font-family","font-size","font-style","font-variant","font-weight","font-stretch","line-height"],creator=a=>{const l=Object.assign({preserve:!0},a);return{postcssPlugin:"postcss-initial",Declaration(a){if(a.variable)return;if(!e.test(a.value))return;let s;s=n.test(a.prop)?i:r.test(a.prop)?t:[a.prop.toLowerCase()],s.forEach((t=>{const e=o.get(t);e&&(hasExactFallback(a,e)||a.cloneBefore({prop:t,value:e}))})),l.preserve||a.remove()}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-initial/dist/properties.d.ts b/node_modules/@csstools/postcss-initial/dist/properties.d.ts new file mode 100644 index 00000000..5345546e --- /dev/null +++ b/node_modules/@csstools/postcss-initial/dist/properties.d.ts @@ -0,0 +1,2 @@ +export declare const properties: Map<string, string>; +export declare const allProperties: string[]; diff --git a/node_modules/@csstools/postcss-initial/package.json b/node_modules/@csstools/postcss-initial/package.json new file mode 100644 index 00000000..d5b6e09e --- /dev/null +++ b/node_modules/@csstools/postcss-initial/package.json @@ -0,0 +1,80 @@ +{ + "name": "@csstools/postcss-initial", + "description": "PostCSS plugin to fallback initial keyword.", + "version": "1.0.0", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-initial#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-initial" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "postcss-plugin" + ], + "csstools": { + "cssdbId": "all-property", + "exportName": "postcssInitial", + "humanReadableName": "PostCSS Initial", + "specUrl": "https://www.w3.org/TR/css-cascade-4/#initial" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-is-pseudo-class/CHANGELOG.md b/node_modules/@csstools/postcss-is-pseudo-class/CHANGELOG.md new file mode 100644 index 00000000..12453434 --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/CHANGELOG.md @@ -0,0 +1,148 @@ +# Changes to PostCSS Is Pseudo Class + +### 4.0.3 + +_October 2, 2023_ + +- Prevent incorrect transforms when `:is()` is wrapped in `:has()`. + +### 4.0.2 + +_September 18, 2023_ + +- Improve performance + +### 4.0.1 + +_September 2, 2023_ + +- Fix substitution when selectors have mixed types for compound selectors where one of two parts is a `:is()` pseudo class. + +```diff +header:is(.a .b) {} + +/* becomes : */ + +- header.a .b {} ++ .a header.b {} +``` + +### 4.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) +- Updated [`@csstools/selector-specificity`](https://github.com/csstools/postcss-plugins/tree/main/packages/selector-specificity) to [`3.0.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/selector-specificity/CHANGELOG.md#300) (major) + +### 3.2.1 + +_May 19, 2023_ + +- Fix compound selectors with `*`. + +```diff +:is(.a *):is(h1, h2, h3) {} + +/* becomes : */ + +- .a *h1, .a *h2, .a *h3 {} ++ .a h1, .a h2, .a h3 {} +``` + +### 3.2.0 + +_April 10, 2023_ + +- Add support for more complex selector patterns. In particular anything where `:is()` is in the left-most compound selector. + +### 3.1.1 + +_February 8, 2023_ + +- Reduce the amount of duplicate fallback CSS. + +### 3.1.0 + +_February 2, 2023_ + +- Fix is pseudo inside a not pseudo (`:not(:is(h1, h2, h3))`) +- Reduce the output size when all selectors are known to be valid + +### 3.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 3.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). + +### 2.0.7 + +_July 8, 2022_ + +- Fix case insensitive matching. + +### 2.0.6 + +_June 23, 2022_ + +- Fix selector order with any pseudo element. +- Fix transforming pseudo elements in `:is()`. Following the specification pseudo elements are invalid and we now transform to a known invalid pseudo element. +- Add `onPseudoElement` plugin option. Set `{ onPseudoElement: 'warning' }` to receive warnings when this plugin encounters an unprocessable pseudo element. + +### 2.0.5 + +_June 4, 2022_ + +- Update `@csstools/selector-specificity` (major) + +### 2.0.4 + +_May 17, 2022_ + +- Fix selector order with `:before` and other pseudo elements. + +### 2.0.3 + +_May 11, 2022_ + +- Use `@csstools/selector-specificity` for specificity calculations. + +### 2.0.2 + +_April 4, 2022_ + +- Improved : compound selector order with pseudo elements +- Improved : selector specificity calculation. + +### 2.0.1 + +_March 4, 2022_ + +- Preserve selector order as much as possible. Fixes issues where pseudo elements `::before` were moved. + +### 2.0.0 + +_January 31, 2022_ + +- Remove `skip` flag in `onComplexSelectors` option. + +If a complex selector is encountered that has no known equivalent, it will always be skipped and preserved now. + +The previous behavior was to remove `:is()` even if that broke the selector. + +### 1.0.1 + +_January 17, 2022_ + +- Fix selector order + +### 1.0.0 + +_January 13, 2022_ + +- initial release diff --git a/node_modules/@csstools/postcss-is-pseudo-class/LICENSE.md b/node_modules/@csstools/postcss-is-pseudo-class/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-is-pseudo-class/README.md b/node_modules/@csstools/postcss-is-pseudo-class/README.md new file mode 100644 index 00000000..407fab67 --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/README.md @@ -0,0 +1,251 @@ +# PostCSS Is Pseudo [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" width="90" height="90" align="right">][postcss] + +[![NPM Version][npm-img]][npm-url] +[![CSS Standard Status][css-img]][css-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +[PostCSS Is Pseudo Class] lets you use the `:is` pseudo class function, following the +[CSS Selector] specification. + +```pcss +:is(input, button):is(:hover, :focus) { + order: 1; +} +``` + +Becomes : + +```pcss +input:hover { + order: 1; +} +input:focus { + order: 1; +} +button:hover { + order: 1; +} +button:focus { + order: 1; +} +``` + +## Usage + +Add [PostCSS Is Pseudo Class] to your project: + +```bash +npm install @csstools/postcss-is-pseudo-class --save-dev +``` + +Use [PostCSS Is Pseudo Class] as a [PostCSS] plugin: + +```js +import postcss from 'postcss'; +import postcssIsPseudoClass from '@csstools/postcss-is-pseudo-class'; + +postcss([ + postcssIsPseudoClass(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Is Pseudo Class] runs in all Node environments, with special instructions for: + +| [Node](INSTALL.md#node) | [Webpack](INSTALL.md#webpack) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) | +| --- | --- | --- | --- | + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is not preserved. + +```js +postcss([ + postcssIsPseudoClass({ preserve: true }) +]).process(YOUR_CSS /*, processOptions */); +``` + +```pcss +:is(input, button):is(:hover, :focus) { + order: 1; +} +``` + +Becomes : + +```pcss +input:hover { + order: 1; +} +input:focus { + order: 1; +} +button:hover { + order: 1; +} +button:focus { + order: 1; +} +:is(input, button):is(:hover, :focus) { + order: 1; +} +``` + +### specificityMatchingName + +The `specificityMatchingName` option allows you to change the selector used to adjust specificity. +The default value is `does-not-exist`. +If this is an actual class, id or tag name in your code, you will need to set a different option here. + +See how `:not` is used to modify [specificity](#specificity). + +```js +postcss([ + postcssIsPseudoClass({ specificityMatchingName: 'something-random' }) +]).process(YOUR_CSS /*, processOptions */); +``` + +```pcss +:is(.button, button):hover { + order: 7; +} +``` + +Becomes : + +```pcss +.button:hover { + order: 7; +} + +button:not(.something-random):hover { + order: 7; +} +``` + +### onComplexSelector + +Warn on complex selectors in `:is` pseudo class functions. + +```js +postcss([ + postcssIsPseudoClass({ onComplexSelector: 'warning' }) +]).process(YOUR_CSS /*, processOptions */); +``` + +### onPseudoElement + +Warn when pseudo elements are used in `:is` pseudo class functions. + +⚠️ Pseudo elements are always invalid and will be transformed to `::-csstools-invalid-<pseudo-name>`. + +```js +postcss([ + postcssIsPseudoClass({ onPseudoElement: 'warning' }) +]).process(YOUR_CSS /*, processOptions */); +``` + +```css +:is(::after):hover { + order: 1.0; +} + +/* becomes */ + +::-csstools-invalid-after:hover { + order: 1.0; +} +``` + +## ⚠️ Known shortcomings + +### Specificity + +`:is` takes the specificity of the most specific list item. +We can increase specificity with `:not` selectors, but we can't decrease it. + +Converted selectors are ensured to have the same specificity as `:is` for the most important bit. +Less important bits can have higher specificity that `:is`. + +Before : + +[specificity: 0, 2, 0](https://polypane.app/css-specificity-calculator/#selector=%3Ais(%3Ahover%2C%20%3Afocus)%3Ais(.button%2C%20button)) + +```pcss +:is(:hover, :focus):is(.button, button) { + order: 7; +} +``` + +After : + +```pcss +/* specificity: [0, 2, 0] */ +.button:hover { + order: 7; +} + +/* specificity: [0, 2, 1] */ +/* last bit is higher than it should be, but middle bit matches */ +button:not(.does-not-exist):hover { + order: 7; +} + +/* specificity: [0, 2, 0] */ +.button:focus { + order: 7; +} + +/* specificity: [0, 2, 1] */ +/* last bit is higher than it should be, but middle bit matches */ +button:not(.does-not-exist):focus { + order: 7; +} +``` + +### Complex selectors + +Before : + + +```pcss +:is(.alpha > .beta) ~ :is(:focus > .beta) { + order: 2; +} +``` + +After : + +```pcss +.alpha > .beta ~ :focus > .beta { + order: 2; +} +``` + +_this is a different selector than expected as `.beta ~ :focus` matches `.beta` followed by `:focus`._<br> +_avoid these cases._<br> +_writing the selector without `:is()` is advised here_ + +```pcss +/* without is */ +.alpha:focus > .beta ~ .beta { + order: 2; +} +``` + +If you have a specific pattern you can open an issue to discuss it. +We can detect and transform some cases but can't generalize them into a single solution that tackles all of them. + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-img]: https://cssdb.org/images/badges/is-pseudo-class.svg +[css-url]: https://cssdb.org/#is-pseudo-class +[discord]: https://discord.gg/bUadyRwkJS +[npm-img]: https://img.shields.io/npm/v/@csstools/postcss-is-pseudo-class.svg +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-is-pseudo-class + +[CSS Selector]: https://www.w3.org/TR/selectors-4/#matches +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Is Pseudo Class]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-is-pseudo-class diff --git a/node_modules/@csstools/postcss-is-pseudo-class/dist/index.cjs b/node_modules/@csstools/postcss-is-pseudo-class/dist/index.cjs new file mode 100644 index 00000000..939299bd --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("postcss-selector-parser"),o=require("@csstools/selector-specificity");function alwaysValidSelector(o){const s=e().astSync(o);let t=!0;return s.walk((e=>{var o,s;if("class"!==e.type&&"comment"!==e.type&&"id"!==e.type&&"root"!==e.type&&"selector"!==e.type&&"string"!==e.type&&"tag"!==e.type&&"universal"!==e.type&&("attribute"!==e.type||e.insensitive)&&("combinator"!==e.type||"+"!==e.value&&">"!==e.value&&"~"!==e.value&&" "!==e.value)&&("pseudo"!==e.type||null!=(o=e.nodes)&&o.length||":hover"!==e.value.toLowerCase()&&":focus"!==e.value.toLowerCase())){if("pseudo"===e.type&&1===(null==(s=e.nodes)?void 0:s.length)&&":not"===e.value.toLowerCase()){let o=!0;if(e.nodes[0].walkCombinators((()=>{o=!1})),o)return}return t=!1,!1}})),t}function sortCompoundSelectorsInsideComplexSelector(o){if(!o||!o.nodes||1===o.nodes.length)return;const s=[];let t=[];for(let n=0;n<o.nodes.length;n++)"combinator"!==o.nodes[n].type?e.isPseudoElement(o.nodes[n])?(s.push(t),t=[o.nodes[n]]):t.push(o.nodes[n]):(s.push(t),s.push([o.nodes[n]]),t=[]);s.push(t);const n=[];for(let e=0;e<s.length;e++){const o=s[e];o.sort(((e,o)=>"selector"===e.type&&"selector"===o.type&&e.nodes.length&&o.nodes.length?selectorTypeOrder(e.nodes[0],e.nodes[0].type)-selectorTypeOrder(o.nodes[0],o.nodes[0].type):"selector"===e.type&&e.nodes.length?selectorTypeOrder(e.nodes[0],e.nodes[0].type)-selectorTypeOrder(o,o.type):"selector"===o.type&&o.nodes.length?selectorTypeOrder(e,e.type)-selectorTypeOrder(o.nodes[0],o.nodes[0].type):selectorTypeOrder(e,e.type)-selectorTypeOrder(o,o.type)));const t=new Set(o.map((e=>e.type))),r=t.has("universal")&&(t.has("tag")||t.has("attribute")||t.has("class")||t.has("id")||t.has("pseudo"));for(let e=0;e<o.length;e++)"universal"===o[e].type&&r?o[e].remove():n.push(o[e])}for(let s=n.length-1;s>=0;s--){const t=n[s-1];if(n[s].remove(),t&&"tag"===t.type&&"tag"===n[s].type){const t=e.pseudo({value:":is",nodes:[e.selector({value:"",nodes:[n[s]]})]});o.prepend(t)}else o.prepend(n[s])}}function selectorTypeOrder(o,t){return e.isPseudoElement(o)?s.pseudoElement:s[t]}const s={universal:0,tag:1,pseudoElement:2,id:3,class:4,attribute:5,pseudo:6,selector:7,string:8,root:9,comment:10};function childAdjacentChild(e){return!(!e||!e.nodes)&&("selector"===e.type&&(3===e.nodes.length&&(!(!e.nodes[0]||"pseudo"!==e.nodes[0].type||":-csstools-matches"!==e.nodes[0].value)&&(!(!e.nodes[1]||"combinator"!==e.nodes[1].type||"+"!==e.nodes[1].value&&"~"!==e.nodes[1].value)&&(!(!e.nodes[2]||"pseudo"!==e.nodes[2].type||":-csstools-matches"!==e.nodes[2].value)&&(!(!e.nodes[0].nodes||1!==e.nodes[0].nodes.length)&&("selector"===e.nodes[0].nodes[0].type&&(!(!e.nodes[0].nodes[0].nodes||3!==e.nodes[0].nodes[0].nodes.length)&&(!(!e.nodes[0].nodes[0].nodes||"combinator"!==e.nodes[0].nodes[0].nodes[1].type||">"!==e.nodes[0].nodes[0].nodes[1].value)&&(!(!e.nodes[2].nodes||1!==e.nodes[2].nodes.length)&&("selector"===e.nodes[2].nodes[0].type&&(!(!e.nodes[2].nodes[0].nodes||3!==e.nodes[2].nodes[0].nodes.length)&&(!(!e.nodes[2].nodes[0].nodes||"combinator"!==e.nodes[2].nodes[0].nodes[1].type||">"!==e.nodes[2].nodes[0].nodes[1].value)&&(e.nodes[0].nodes[0].insertAfter(e.nodes[0].nodes[0].nodes[0],e.nodes[2].nodes[0].nodes[0].clone()),e.nodes[2].nodes[0].nodes[1].remove(),e.nodes[2].nodes[0].nodes[0].remove(),e.nodes[0].replaceWith(e.nodes[0].nodes[0]),e.nodes[2].replaceWith(e.nodes[2].nodes[0]),!0))))))))))))))}function isInCompoundWithOneOtherElement(o){if(!o||!o.nodes)return!1;if("selector"!==o.type)return!1;if(2!==o.nodes.length)return!1;let s,t;return o.nodes[0]&&"pseudo"===o.nodes[0].type&&":-csstools-matches"===o.nodes[0].value?(s=0,t=1):o.nodes[1]&&"pseudo"===o.nodes[1].type&&":-csstools-matches"===o.nodes[1].value&&(s=1,t=0),!!s&&(!!o.nodes[t]&&(("selector"!==o.nodes[t].type||!o.nodes[t].some((o=>"combinator"===o.type||e.isPseudoElement(o))))&&("combinator"!==o.nodes[t].type&&(o.nodes[s].nodes[0].append(o.nodes[t].clone()),o.nodes[s].replaceWith(...o.nodes[s].nodes[0].nodes),o.nodes[t].remove(),!0))))}function isPseudoInFirstCompound(e){if(!e||!e.nodes)return!1;if("selector"!==e.type)return!1;let o=-1;for(let s=0;s<e.nodes.length;s++){const t=e.nodes[s];if("combinator"===t.type)return!1;if("pseudo"===t.type&&":-csstools-matches"===t.value){if(!t.nodes||1!==t.nodes.length)return!1;o=s;break}}if(-1===o)return!1;const s=e.nodes.slice(0,o),t=e.nodes[o],n=e.nodes.slice(o+1);return s.forEach((e=>{t.nodes[0].append(e.clone())})),n.forEach((e=>{t.nodes[0].append(e.clone())})),t.replaceWith(...t.nodes),s.forEach((e=>{e.remove()})),n.forEach((e=>{e.remove()})),!0}function complexSelectors(o,s,t,n){return o.flatMap((o=>{if(-1===o.indexOf(":-csstools-matches")&&-1===o.toLowerCase().indexOf(":is"))return o;const r=e().astSync(o);return r.walkPseudos((o=>{if(":is"===o.value.toLowerCase()&&o.nodes&&o.nodes.length&&"selector"===o.nodes[0].type&&0===o.nodes[0].nodes.length)return o.value=":not",void o.nodes[0].append(e.universal());if(":-csstools-matches"===o.value)if(!o.nodes||o.nodes.length){if(o.walkPseudos((o=>{if(e.isPseudoElement(o)){let e=o.value;if(e.startsWith("::-csstools-invalid-"))return;for(;e.startsWith(":");)e=e.slice(1);o.value=`::-csstools-invalid-${e}`,n()}})),1===o.nodes.length&&"selector"===o.nodes[0].type){if(1===o.nodes[0].nodes.length)return void o.replaceWith(o.nodes[0].nodes[0]);if(!o.nodes[0].some((e=>"combinator"===e.type)))return void o.replaceWith(...o.nodes[0].nodes)}1!==r.nodes.length||"selector"!==r.nodes[0].type||1!==r.nodes[0].nodes.length||r.nodes[0].nodes[0]!==o?childAdjacentChild(o.parent)||isInCompoundWithOneOtherElement(o.parent)||isPseudoInFirstCompound(o.parent)||("warning"===s.onComplexSelector&&t(),o.value=":is"):o.replaceWith(...o.nodes[0].nodes)}else o.remove()})),r.walk((e=>{"selector"===e.type&&"nodes"in e&&1===e.nodes.length&&"selector"===e.nodes[0].type&&e.replaceWith(e.nodes[0])})),r.walk((e=>{"nodes"in e&&sortCompoundSelectorsInsideComplexSelector(e)})),r.toString()})).filter((e=>!!e))}function splitSelectors(s,t,n=0){const r=":not(#"+t.specificityMatchingName+")",l=":not(."+t.specificityMatchingName+")",d=":not("+t.specificityMatchingName+")";return s.flatMap((s=>{if(-1===s.toLowerCase().indexOf(":is"))return s;let i=!1;const c=[];if(e().astSync(s).walkPseudos((e=>{var s,t,n,a;if(":is"!==e.value.toLowerCase()||!e.nodes||!e.nodes.length)return;if("selector"===e.nodes[0].type&&0===e.nodes[0].nodes.length)return;if("pseudo"===(null==(s=e.parent)||null==(s=s.parent)?void 0:s.type)&&":not"===(null==(t=e.parent)||null==(t=t.parent)||null==(t=t.value)?void 0:t.toLowerCase()))return void c.push([{start:e.parent.parent.sourceIndex,end:e.parent.parent.sourceIndex+e.parent.parent.toString().length,option:`:not(${e.nodes.toString()})`}]);if("pseudo"===(null==(n=e.parent)||null==(n=n.parent)?void 0:n.type)&&":has"===(null==(a=e.parent)||null==(a=a.parent)||null==(a=a.value)?void 0:a.toLowerCase()))return void(e.value=":-csstools-matches");let p=e.parent;for(;p;){if(p.value&&":is"===p.value.toLowerCase()&&"pseudo"===p.type)return void(i=!0);p=p.parent}const u=o.selectorSpecificity(e),h=e.sourceIndex,f=h+e.toString().length,y=[];e.nodes.forEach((e=>{const s={start:h,end:f,option:""},t=o.selectorSpecificity(e);let n=e.toString().trim();const i=Math.max(0,u.a-t.a),c=Math.max(0,u.b-t.b),a=Math.max(0,u.c-t.c);for(let e=0;e<i;e++)n+=r;for(let e=0;e<c;e++)n+=l;for(let e=0;e<a;e++)n+=d;s.option=n,y.push(s)})),c.push(y)})),!c.length)return[s];let a=[];return cartesianProduct(...c).forEach((e=>{let o="";for(let n=0;n<e.length;n++){var t;const r=e[n];o+=s.substring((null==(t=e[n-1])?void 0:t.end)||0,e[n].start),o+=":-csstools-matches("+r.option+")",n===e.length-1&&(o+=s.substring(e[n].end))}a.push(o)})),i&&n<10&&(a=splitSelectors(a,t,n+1)),a})).filter((e=>!!e))}function cartesianProduct(...e){const o=[],s=e.length-1;return function helper(t,n){for(let r=0,l=e[n].length;r<l;r++){const l=t.slice(0);l.push(e[n][r]),n===s?o.push(l):helper(l,n+1)}}([],0),o}const t=/:is\(/i,creator=e=>{const o={specificityMatchingName:"does-not-exist",...e||{}};return{postcssPlugin:"postcss-is-pseudo-class",prepare(){const e=new WeakSet;return{Rule(s,{result:n}){if(!s.selector)return;if(!t.test(s.selector))return;if(e.has(s))return;let r=!1;const warnOnComplexSelector=()=>{"warning"===o.onComplexSelector&&(r||(r=!0,s.warn(n,`Complex selectors in '${s.selector}' can not be transformed to an equivalent selector without ':is()'.`)))};let l=!1;const warnOnPseudoElements=()=>{"warning"===o.onPseudoElement&&(l||(l=!0,s.warn(n,`Pseudo elements are not allowed in ':is()', unable to transform '${s.selector}'`)))};try{let t=!1;const n=[],r=complexSelectors(splitSelectors(s.selectors,{specificityMatchingName:o.specificityMatchingName}),{onComplexSelector:o.onComplexSelector},warnOnComplexSelector,warnOnPseudoElements);if(Array.from(new Set(r)).forEach((o=>{if(s.selectors.indexOf(o)>-1)n.push(o);else{if(alwaysValidSelector(o))return n.push(o),void(t=!0);e.add(s),s.cloneBefore({selector:o}),t=!0}})),n.length&&t&&(e.add(s),s.cloneBefore({selectors:n})),!o.preserve){if(!t)return;s.remove()}}catch(e){if(e.message.indexOf("call stack size exceeded")>-1)throw e;s.warn(n,`Failed to parse selector "${s.selector}"`)}}}}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-is-pseudo-class/dist/index.d.ts b/node_modules/@csstools/postcss-is-pseudo-class/dist/index.d.ts new file mode 100644 index 00000000..5b65f016 --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/dist/index.d.ts @@ -0,0 +1,23 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-is-pseudo-class plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; + /** + * Warn on complex selectors in `:is` pseudo class functions. + * default: _not set_ + */ + onComplexSelector?: 'warning'; + /** + * Warn when pseudo elements are used in `:is` pseudo class functions. + * default: _not set_ + */ + onPseudoElement?: 'warning'; + /** + * Change the selector used to adjust specificity. + * default: `does-not-exist`. + */ + specificityMatchingName?: string; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs b/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs new file mode 100644 index 00000000..98bdd1ac --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs @@ -0,0 +1 @@ +import e from"postcss-selector-parser";import{selectorSpecificity as o}from"@csstools/selector-specificity";function alwaysValidSelector(o){const s=e().astSync(o);let t=!0;return s.walk((e=>{var o,s;if("class"!==e.type&&"comment"!==e.type&&"id"!==e.type&&"root"!==e.type&&"selector"!==e.type&&"string"!==e.type&&"tag"!==e.type&&"universal"!==e.type&&("attribute"!==e.type||e.insensitive)&&("combinator"!==e.type||"+"!==e.value&&">"!==e.value&&"~"!==e.value&&" "!==e.value)&&("pseudo"!==e.type||null!=(o=e.nodes)&&o.length||":hover"!==e.value.toLowerCase()&&":focus"!==e.value.toLowerCase())){if("pseudo"===e.type&&1===(null==(s=e.nodes)?void 0:s.length)&&":not"===e.value.toLowerCase()){let o=!0;if(e.nodes[0].walkCombinators((()=>{o=!1})),o)return}return t=!1,!1}})),t}function sortCompoundSelectorsInsideComplexSelector(o){if(!o||!o.nodes||1===o.nodes.length)return;const s=[];let t=[];for(let n=0;n<o.nodes.length;n++)"combinator"!==o.nodes[n].type?e.isPseudoElement(o.nodes[n])?(s.push(t),t=[o.nodes[n]]):t.push(o.nodes[n]):(s.push(t),s.push([o.nodes[n]]),t=[]);s.push(t);const n=[];for(let e=0;e<s.length;e++){const o=s[e];o.sort(((e,o)=>"selector"===e.type&&"selector"===o.type&&e.nodes.length&&o.nodes.length?selectorTypeOrder(e.nodes[0],e.nodes[0].type)-selectorTypeOrder(o.nodes[0],o.nodes[0].type):"selector"===e.type&&e.nodes.length?selectorTypeOrder(e.nodes[0],e.nodes[0].type)-selectorTypeOrder(o,o.type):"selector"===o.type&&o.nodes.length?selectorTypeOrder(e,e.type)-selectorTypeOrder(o.nodes[0],o.nodes[0].type):selectorTypeOrder(e,e.type)-selectorTypeOrder(o,o.type)));const t=new Set(o.map((e=>e.type))),r=t.has("universal")&&(t.has("tag")||t.has("attribute")||t.has("class")||t.has("id")||t.has("pseudo"));for(let e=0;e<o.length;e++)"universal"===o[e].type&&r?o[e].remove():n.push(o[e])}for(let s=n.length-1;s>=0;s--){const t=n[s-1];if(n[s].remove(),t&&"tag"===t.type&&"tag"===n[s].type){const t=e.pseudo({value:":is",nodes:[e.selector({value:"",nodes:[n[s]]})]});o.prepend(t)}else o.prepend(n[s])}}function selectorTypeOrder(o,t){return e.isPseudoElement(o)?s.pseudoElement:s[t]}const s={universal:0,tag:1,pseudoElement:2,id:3,class:4,attribute:5,pseudo:6,selector:7,string:8,root:9,comment:10};function childAdjacentChild(e){return!(!e||!e.nodes)&&("selector"===e.type&&(3===e.nodes.length&&(!(!e.nodes[0]||"pseudo"!==e.nodes[0].type||":-csstools-matches"!==e.nodes[0].value)&&(!(!e.nodes[1]||"combinator"!==e.nodes[1].type||"+"!==e.nodes[1].value&&"~"!==e.nodes[1].value)&&(!(!e.nodes[2]||"pseudo"!==e.nodes[2].type||":-csstools-matches"!==e.nodes[2].value)&&(!(!e.nodes[0].nodes||1!==e.nodes[0].nodes.length)&&("selector"===e.nodes[0].nodes[0].type&&(!(!e.nodes[0].nodes[0].nodes||3!==e.nodes[0].nodes[0].nodes.length)&&(!(!e.nodes[0].nodes[0].nodes||"combinator"!==e.nodes[0].nodes[0].nodes[1].type||">"!==e.nodes[0].nodes[0].nodes[1].value)&&(!(!e.nodes[2].nodes||1!==e.nodes[2].nodes.length)&&("selector"===e.nodes[2].nodes[0].type&&(!(!e.nodes[2].nodes[0].nodes||3!==e.nodes[2].nodes[0].nodes.length)&&(!(!e.nodes[2].nodes[0].nodes||"combinator"!==e.nodes[2].nodes[0].nodes[1].type||">"!==e.nodes[2].nodes[0].nodes[1].value)&&(e.nodes[0].nodes[0].insertAfter(e.nodes[0].nodes[0].nodes[0],e.nodes[2].nodes[0].nodes[0].clone()),e.nodes[2].nodes[0].nodes[1].remove(),e.nodes[2].nodes[0].nodes[0].remove(),e.nodes[0].replaceWith(e.nodes[0].nodes[0]),e.nodes[2].replaceWith(e.nodes[2].nodes[0]),!0))))))))))))))}function isInCompoundWithOneOtherElement(o){if(!o||!o.nodes)return!1;if("selector"!==o.type)return!1;if(2!==o.nodes.length)return!1;let s,t;return o.nodes[0]&&"pseudo"===o.nodes[0].type&&":-csstools-matches"===o.nodes[0].value?(s=0,t=1):o.nodes[1]&&"pseudo"===o.nodes[1].type&&":-csstools-matches"===o.nodes[1].value&&(s=1,t=0),!!s&&(!!o.nodes[t]&&(("selector"!==o.nodes[t].type||!o.nodes[t].some((o=>"combinator"===o.type||e.isPseudoElement(o))))&&("combinator"!==o.nodes[t].type&&(o.nodes[s].nodes[0].append(o.nodes[t].clone()),o.nodes[s].replaceWith(...o.nodes[s].nodes[0].nodes),o.nodes[t].remove(),!0))))}function isPseudoInFirstCompound(e){if(!e||!e.nodes)return!1;if("selector"!==e.type)return!1;let o=-1;for(let s=0;s<e.nodes.length;s++){const t=e.nodes[s];if("combinator"===t.type)return!1;if("pseudo"===t.type&&":-csstools-matches"===t.value){if(!t.nodes||1!==t.nodes.length)return!1;o=s;break}}if(-1===o)return!1;const s=e.nodes.slice(0,o),t=e.nodes[o],n=e.nodes.slice(o+1);return s.forEach((e=>{t.nodes[0].append(e.clone())})),n.forEach((e=>{t.nodes[0].append(e.clone())})),t.replaceWith(...t.nodes),s.forEach((e=>{e.remove()})),n.forEach((e=>{e.remove()})),!0}function complexSelectors(o,s,t,n){return o.flatMap((o=>{if(-1===o.indexOf(":-csstools-matches")&&-1===o.toLowerCase().indexOf(":is"))return o;const r=e().astSync(o);return r.walkPseudos((o=>{if(":is"===o.value.toLowerCase()&&o.nodes&&o.nodes.length&&"selector"===o.nodes[0].type&&0===o.nodes[0].nodes.length)return o.value=":not",void o.nodes[0].append(e.universal());if(":-csstools-matches"===o.value)if(!o.nodes||o.nodes.length){if(o.walkPseudos((o=>{if(e.isPseudoElement(o)){let e=o.value;if(e.startsWith("::-csstools-invalid-"))return;for(;e.startsWith(":");)e=e.slice(1);o.value=`::-csstools-invalid-${e}`,n()}})),1===o.nodes.length&&"selector"===o.nodes[0].type){if(1===o.nodes[0].nodes.length)return void o.replaceWith(o.nodes[0].nodes[0]);if(!o.nodes[0].some((e=>"combinator"===e.type)))return void o.replaceWith(...o.nodes[0].nodes)}1!==r.nodes.length||"selector"!==r.nodes[0].type||1!==r.nodes[0].nodes.length||r.nodes[0].nodes[0]!==o?childAdjacentChild(o.parent)||isInCompoundWithOneOtherElement(o.parent)||isPseudoInFirstCompound(o.parent)||("warning"===s.onComplexSelector&&t(),o.value=":is"):o.replaceWith(...o.nodes[0].nodes)}else o.remove()})),r.walk((e=>{"selector"===e.type&&"nodes"in e&&1===e.nodes.length&&"selector"===e.nodes[0].type&&e.replaceWith(e.nodes[0])})),r.walk((e=>{"nodes"in e&&sortCompoundSelectorsInsideComplexSelector(e)})),r.toString()})).filter((e=>!!e))}function splitSelectors(s,t,n=0){const r=":not(#"+t.specificityMatchingName+")",l=":not(."+t.specificityMatchingName+")",d=":not("+t.specificityMatchingName+")";return s.flatMap((s=>{if(-1===s.toLowerCase().indexOf(":is"))return s;let a=!1;const i=[];if(e().astSync(s).walkPseudos((e=>{var s,t,n,c;if(":is"!==e.value.toLowerCase()||!e.nodes||!e.nodes.length)return;if("selector"===e.nodes[0].type&&0===e.nodes[0].nodes.length)return;if("pseudo"===(null==(s=e.parent)||null==(s=s.parent)?void 0:s.type)&&":not"===(null==(t=e.parent)||null==(t=t.parent)||null==(t=t.value)?void 0:t.toLowerCase()))return void i.push([{start:e.parent.parent.sourceIndex,end:e.parent.parent.sourceIndex+e.parent.parent.toString().length,option:`:not(${e.nodes.toString()})`}]);if("pseudo"===(null==(n=e.parent)||null==(n=n.parent)?void 0:n.type)&&":has"===(null==(c=e.parent)||null==(c=c.parent)||null==(c=c.value)?void 0:c.toLowerCase()))return void(e.value=":-csstools-matches");let p=e.parent;for(;p;){if(p.value&&":is"===p.value.toLowerCase()&&"pseudo"===p.type)return void(a=!0);p=p.parent}const u=o(e),h=e.sourceIndex,f=h+e.toString().length,y=[];e.nodes.forEach((e=>{const s={start:h,end:f,option:""},t=o(e);let n=e.toString().trim();const a=Math.max(0,u.a-t.a),i=Math.max(0,u.b-t.b),c=Math.max(0,u.c-t.c);for(let e=0;e<a;e++)n+=r;for(let e=0;e<i;e++)n+=l;for(let e=0;e<c;e++)n+=d;s.option=n,y.push(s)})),i.push(y)})),!i.length)return[s];let c=[];return cartesianProduct(...i).forEach((e=>{let o="";for(let n=0;n<e.length;n++){var t;const r=e[n];o+=s.substring((null==(t=e[n-1])?void 0:t.end)||0,e[n].start),o+=":-csstools-matches("+r.option+")",n===e.length-1&&(o+=s.substring(e[n].end))}c.push(o)})),a&&n<10&&(c=splitSelectors(c,t,n+1)),c})).filter((e=>!!e))}function cartesianProduct(...e){const o=[],s=e.length-1;return function helper(t,n){for(let r=0,l=e[n].length;r<l;r++){const l=t.slice(0);l.push(e[n][r]),n===s?o.push(l):helper(l,n+1)}}([],0),o}const t=/:is\(/i,creator=e=>{const o={specificityMatchingName:"does-not-exist",...e||{}};return{postcssPlugin:"postcss-is-pseudo-class",prepare(){const e=new WeakSet;return{Rule(s,{result:n}){if(!s.selector)return;if(!t.test(s.selector))return;if(e.has(s))return;let r=!1;const warnOnComplexSelector=()=>{"warning"===o.onComplexSelector&&(r||(r=!0,s.warn(n,`Complex selectors in '${s.selector}' can not be transformed to an equivalent selector without ':is()'.`)))};let l=!1;const warnOnPseudoElements=()=>{"warning"===o.onPseudoElement&&(l||(l=!0,s.warn(n,`Pseudo elements are not allowed in ':is()', unable to transform '${s.selector}'`)))};try{let t=!1;const n=[],r=complexSelectors(splitSelectors(s.selectors,{specificityMatchingName:o.specificityMatchingName}),{onComplexSelector:o.onComplexSelector},warnOnComplexSelector,warnOnPseudoElements);if(Array.from(new Set(r)).forEach((o=>{if(s.selectors.indexOf(o)>-1)n.push(o);else{if(alwaysValidSelector(o))return n.push(o),void(t=!0);e.add(s),s.cloneBefore({selector:o}),t=!0}})),n.length&&t&&(e.add(s),s.cloneBefore({selectors:n})),!o.preserve){if(!t)return;s.remove()}}catch(e){if(e.message.indexOf("call stack size exceeded")>-1)throw e;s.warn(n,`Failed to parse selector "${s.selector}"`)}}}}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/always-valid.d.ts b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/always-valid.d.ts new file mode 100644 index 00000000..a3bb60b3 --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/always-valid.d.ts @@ -0,0 +1 @@ +export default function alwaysValidSelector(selector: string): boolean; diff --git a/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/complex.d.ts b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/complex.d.ts new file mode 100644 index 00000000..904515e7 --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/complex.d.ts @@ -0,0 +1,3 @@ +export default function complexSelectors(selectors: Array<string>, pluginOptions: { + onComplexSelector?: 'warning'; +}, warnOnComplexSelector: () => void, warnOnPseudoElements: () => void): string[]; diff --git a/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/complex/child-adjacent-child.d.ts b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/complex/child-adjacent-child.d.ts new file mode 100644 index 00000000..644eaaec --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/complex/child-adjacent-child.d.ts @@ -0,0 +1 @@ +export declare function childAdjacentChild(selector: any): boolean; diff --git a/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/complex/is-in-compound.d.ts b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/complex/is-in-compound.d.ts new file mode 100644 index 00000000..3a91eef6 --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/complex/is-in-compound.d.ts @@ -0,0 +1 @@ +export declare function isInCompoundWithOneOtherElement(selector: any): boolean; diff --git a/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/complex/is-pseudo-in-first-compound.d.ts b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/complex/is-pseudo-in-first-compound.d.ts new file mode 100644 index 00000000..06ba1481 --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/complex/is-pseudo-in-first-compound.d.ts @@ -0,0 +1 @@ +export declare function isPseudoInFirstCompound(selector: any): boolean; diff --git a/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/compound-selector-order.d.ts b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/compound-selector-order.d.ts new file mode 100644 index 00000000..3fb1e39f --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/compound-selector-order.d.ts @@ -0,0 +1 @@ +export declare function sortCompoundSelectorsInsideComplexSelector(node: any): void; diff --git a/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/split-selectors.d.ts b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/split-selectors.d.ts new file mode 100644 index 00000000..7bb70f21 --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/dist/split-selectors/split-selectors.d.ts @@ -0,0 +1,3 @@ +export default function splitSelectors(selectors: Array<string>, pluginOptions: { + specificityMatchingName: string; +}, recursionDepth?: number): Array<string>; diff --git a/node_modules/@csstools/postcss-is-pseudo-class/package.json b/node_modules/@csstools/postcss-is-pseudo-class/package.json new file mode 100644 index 00000000..05e2749c --- /dev/null +++ b/node_modules/@csstools/postcss-is-pseudo-class/package.json @@ -0,0 +1,81 @@ +{ + "name": "@csstools/postcss-is-pseudo-class", + "description": "A pseudo-class for matching elements in a selector list", + "version": "4.0.3", + "author": "Jonathan Neal <jonathantneal@hotmail.com>", + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/selector-specificity": "^3.0.0", + "postcss-selector-parser": "^6.0.13" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*", + "puppeteer": "^21.3.6" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:browser": "node ./test/_browser.mjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-is-pseudo-class#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-is-pseudo-class" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "css", + "is", + "matches", + "polyfill", + "postcss", + "postcss-plugin", + "pseudo", + "selector" + ], + "csstools": { + "exportName": "postcssIsPseudoClass", + "humanReadableName": "PostCSS Is Pseudo" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-logical-float-and-clear/CHANGELOG.md b/node_modules/@csstools/postcss-logical-float-and-clear/CHANGELOG.md new file mode 100644 index 00000000..b11158f8 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-float-and-clear/CHANGELOG.md @@ -0,0 +1,19 @@ +# Changes to PostCSS Logical Float And Clear + +### 2.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) + +### 1.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 1.0.0 + +_January 19, 2023_ + +- Initial version diff --git a/node_modules/@csstools/postcss-logical-float-and-clear/LICENSE.md b/node_modules/@csstools/postcss-logical-float-and-clear/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-float-and-clear/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-logical-float-and-clear/README.md b/node_modules/@csstools/postcss-logical-float-and-clear/README.md new file mode 100644 index 00000000..268c3085 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-float-and-clear/README.md @@ -0,0 +1,95 @@ +# PostCSS Logical Float And Clear [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-logical-float-and-clear.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/float-clear-logical-values.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +[PostCSS Logical Float And Clear] lets you use logical, rather than physical, direction and dimension mappings in CSS, following the [CSS Logical Properties and Values] specification. + +```pcss +.element { + clear: inline-start; + float: inline-end; +} + +/* becomes */ + +.element { + clear: left; + float: right; +} +``` + +## Usage + +Add [PostCSS Logical Float And Clear] to your project: + +```bash +npm install postcss @csstools/postcss-logical-float-and-clear --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssLogicalFloatAndClear = require('@csstools/postcss-logical-float-and-clear'); + +postcss([ + postcssLogicalFloatAndClear(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Logical Float And Clear] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### inlineDirection + +The `inlineDirection` option allows you to specify the direction of the inline axe. The default value is `left-to-right` respectively which would match any latin language. + +You might want to tweak these value if you are using a different writing system, such as Arabic, Hebrew or Chinese for example. + +```js +postcssLogicalFloatAndClear({ + inlineDirection: 'right-to-left' +}) +``` + +```pcss +.element { + clear: inline-start; + float: inline-end; +} + +/* becomes */ + +.element { + clear: right; + float: left; +} +``` + +Each direction must be one of the following: + +- `top-to-bottom` +- `bottom-to-top` +- `left-to-right` +- `right-to-left` + +Please do note that transformations won't run if `inlineDirection` becomes vertical. + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#float-clear-logical-values +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-logical-float-and-clear + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Logical Float And Clear]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-logical-float-and-clear +[CSS Logical Properties and Values]: https://www.w3.org/TR/css-logical-1/#float-clear diff --git a/node_modules/@csstools/postcss-logical-float-and-clear/dist/index.cjs b/node_modules/@csstools/postcss-logical-float-and-clear/dist/index.cjs new file mode 100644 index 00000000..c073727d --- /dev/null +++ b/node_modules/@csstools/postcss-logical-float-and-clear/dist/index.cjs @@ -0,0 +1 @@ +"use strict";const t="inline-start",o="inline-end";var e,i;function directionFlowToAxes(t){switch(t){case e.TopToBottom:return[i.Top,i.Bottom];case e.BottomToTop:return[i.Bottom,i.Top];case e.RightToLeft:return[i.Right,i.Left];case e.LeftToRight:return[i.Left,i.Right]}}function cloneDeclaration(t,o,e){t.parent&&t.parent.some((t=>"decl"==t.type&&t.prop===e&&t.value===o))||t.cloneBefore({value:o,prop:e})}!function(t){t.TopToBottom="top-to-bottom",t.BottomToTop="bottom-to-top",t.RightToLeft="right-to-left",t.LeftToRight="left-to-right"}(e||(e={})),function(t){t.Top="top",t.Right="right",t.Bottom="bottom",t.Left="left"}(i||(i={}));const creator=i=>{const n=Object.assign({inlineDirection:e.LeftToRight},i),c=Object.values(e);if(!c.includes(n.inlineDirection))throw new Error(`[postcss-logical-float-and-clear] "inlineDirection" must be one of ${c.join(", ")}`);if(![e.LeftToRight,e.RightToLeft].includes(n.inlineDirection))return{postcssPlugin:"postcss-logical-float-and-clear",Once(){}};const[r,l]=directionFlowToAxes(n.inlineDirection),makeTransform=e=>{const i=e.value.toLowerCase();if(![t,o].includes(i))return;cloneDeclaration(e,i===t?r:l,e.prop),e.remove()};return{postcssPlugin:"postcss-logical-float-and-clear",Declaration:{float:makeTransform,clear:makeTransform}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-logical-float-and-clear/dist/index.d.ts b/node_modules/@csstools/postcss-logical-float-and-clear/dist/index.d.ts new file mode 100644 index 00000000..8faa333f --- /dev/null +++ b/node_modules/@csstools/postcss-logical-float-and-clear/dist/index.d.ts @@ -0,0 +1,9 @@ +import type { PluginCreator } from 'postcss'; +import { DirectionFlow } from './lib/types'; +/** postcss-logical-float-and-clear plugin options */ +export type pluginOptions = { + /** Sets the direction for inline. default: left-to-right */ + inlineDirection?: DirectionFlow; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-logical-float-and-clear/dist/index.mjs b/node_modules/@csstools/postcss-logical-float-and-clear/dist/index.mjs new file mode 100644 index 00000000..f05b6578 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-float-and-clear/dist/index.mjs @@ -0,0 +1 @@ +const t="inline-start",o="inline-end";var e,n;function directionFlowToAxes(t){switch(t){case e.TopToBottom:return[n.Top,n.Bottom];case e.BottomToTop:return[n.Bottom,n.Top];case e.RightToLeft:return[n.Right,n.Left];case e.LeftToRight:return[n.Left,n.Right]}}function cloneDeclaration(t,o,e){t.parent&&t.parent.some((t=>"decl"==t.type&&t.prop===e&&t.value===o))||t.cloneBefore({value:o,prop:e})}!function(t){t.TopToBottom="top-to-bottom",t.BottomToTop="bottom-to-top",t.RightToLeft="right-to-left",t.LeftToRight="left-to-right"}(e||(e={})),function(t){t.Top="top",t.Right="right",t.Bottom="bottom",t.Left="left"}(n||(n={}));const creator=n=>{const i=Object.assign({inlineDirection:e.LeftToRight},n),c=Object.values(e);if(!c.includes(i.inlineDirection))throw new Error(`[postcss-logical-float-and-clear] "inlineDirection" must be one of ${c.join(", ")}`);if(![e.LeftToRight,e.RightToLeft].includes(i.inlineDirection))return{postcssPlugin:"postcss-logical-float-and-clear",Once(){}};const[r,l]=directionFlowToAxes(i.inlineDirection),makeTransform=e=>{const n=e.value.toLowerCase();if(![t,o].includes(n))return;cloneDeclaration(e,n===t?r:l,e.prop),e.remove()};return{postcssPlugin:"postcss-logical-float-and-clear",Declaration:{float:makeTransform,clear:makeTransform}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-logical-float-and-clear/dist/lib/clone-declaration.d.ts b/node_modules/@csstools/postcss-logical-float-and-clear/dist/lib/clone-declaration.d.ts new file mode 100644 index 00000000..1503bf6f --- /dev/null +++ b/node_modules/@csstools/postcss-logical-float-and-clear/dist/lib/clone-declaration.d.ts @@ -0,0 +1,2 @@ +import type { Declaration } from 'postcss'; +export declare function cloneDeclaration(declaration: Declaration, value: string, prop: string): void; diff --git a/node_modules/@csstools/postcss-logical-float-and-clear/dist/lib/types.d.ts b/node_modules/@csstools/postcss-logical-float-and-clear/dist/lib/types.d.ts new file mode 100644 index 00000000..2b3c47f9 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-float-and-clear/dist/lib/types.d.ts @@ -0,0 +1,18 @@ +export declare const DirectionValues: { + BlockStart: string; + BlockEnd: string; + InlineStart: string; + InlineEnd: string; +}; +export declare enum DirectionFlow { + TopToBottom = "top-to-bottom", + BottomToTop = "bottom-to-top", + RightToLeft = "right-to-left", + LeftToRight = "left-to-right" +} +export declare enum Axes { + Top = "top", + Right = "right", + Bottom = "bottom", + Left = "left" +} diff --git a/node_modules/@csstools/postcss-logical-float-and-clear/dist/utils/direction-flow-to-axes.d.ts b/node_modules/@csstools/postcss-logical-float-and-clear/dist/utils/direction-flow-to-axes.d.ts new file mode 100644 index 00000000..2652d71d --- /dev/null +++ b/node_modules/@csstools/postcss-logical-float-and-clear/dist/utils/direction-flow-to-axes.d.ts @@ -0,0 +1,2 @@ +import { DirectionFlow, Axes } from '../lib/types'; +export declare function directionFlowToAxes(directionFlow: DirectionFlow): [Axes, Axes]; diff --git a/node_modules/@csstools/postcss-logical-float-and-clear/package.json b/node_modules/@csstools/postcss-logical-float-and-clear/package.json new file mode 100644 index 00000000..5738faeb --- /dev/null +++ b/node_modules/@csstools/postcss-logical-float-and-clear/package.json @@ -0,0 +1,87 @@ +{ + "name": "@csstools/postcss-logical-float-and-clear", + "description": "Use flow-relative (inline-start and inline-end) values for float and clear", + "version": "2.0.0", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-logical-float-and-clear#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-logical-float-and-clear" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "block", + "clear", + "css", + "float", + "inline", + "logical", + "postcss", + "postcss-plugin" + ], + "csstools": { + "cssdbId": "float-clear-logical-values", + "exportName": "postcssLogicalFloatAndClear", + "humanReadableName": "PostCSS Logical Float And Clear", + "specUrl": "https://www.w3.org/TR/css-logical-1/#float-clear" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-logical-resize/CHANGELOG.md b/node_modules/@csstools/postcss-logical-resize/CHANGELOG.md new file mode 100644 index 00000000..5d9ea88f --- /dev/null +++ b/node_modules/@csstools/postcss-logical-resize/CHANGELOG.md @@ -0,0 +1,19 @@ +# Changes to PostCSS Logical Resize + +### 2.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) + +### 1.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 1.0.0 + +_January 21, 20223_ + +- Initial version diff --git a/node_modules/@csstools/postcss-logical-resize/LICENSE.md b/node_modules/@csstools/postcss-logical-resize/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-resize/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-logical-resize/README.md b/node_modules/@csstools/postcss-logical-resize/README.md new file mode 100644 index 00000000..3e0d3a24 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-resize/README.md @@ -0,0 +1,108 @@ +# PostCSS Logical Resize [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-logical-resize.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/logical-resize.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +[PostCSS Logical Resize] lets you use logical, rather than physical, values for `resize`, following the [CSS Logical Properties and Values] specification. + +```pcss +.resize-block { + resize: block; +} + +.resize-inline { + resize: inline; +} + +/* becomes */ + +.resize-block { + resize: vertical; +} + +.resize-inline { + resize: horizontal; +} +``` + +## Usage + +Add [PostCSS Logical Resize] to your project: + +```bash +npm install postcss @csstools/postcss-logical-resize --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssLogicalResize = require('@csstools/postcss-logical-resize'); + +postcss([ + postcssLogicalResize(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Logical Resize] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### blockDirection & inlineDirection + +The `blockDirection` and `inlineDirection` options allow you to specify the direction of the block and inline axes. The default values are `top-to-bottom` and `left-to-right` respectively which would match any latin language. + +You might want to tweak these values if you are using a different writing system, such as Arabic, Hebrew or Chinese for example. + +```js +postcssLogicalResize({ + blockDirection: 'right-to-left', + inlineDirection: 'top-to-bottom' +}) +``` + +```pcss +.resize-block { + resize: block; +} + +.resize-inline { + resize: inline; +} + +/* becomes */ + +.resize-block { + resize: horizontal; +} + +.resize-inline { + resize: vertical; +} +``` + +Each direction must be one of the following: + +- `top-to-bottom` +- `bottom-to-top` +- `left-to-right` +- `right-to-left` + +You can't mix two vertical directions or two horizontal directions so for example `top-to-bottom` and `right-to-left` are valid, but `top-to-bottom` and `bottom-to-top` are not. + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#logical-resize +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-logical-resize + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Logical Resize]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-logical-resize +[CSS Logical Properties and Values]: https://www.w3.org/TR/css-logical-1/ diff --git a/node_modules/@csstools/postcss-logical-resize/dist/index.cjs b/node_modules/@csstools/postcss-logical-resize/dist/index.cjs new file mode 100644 index 00000000..6c1aaad1 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-resize/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var o,t,e,i,n=require("postcss-value-parser");function cloneDeclaration(o,t,e){o.parent&&o.parent.some((o=>"decl"==o.type&&o.prop===e&&o.value===t))||o.cloneBefore({value:t,prop:e})}function transformResize(o){return t=>{const{prop:e,value:i}=t,r=n(i),c=o.inlineIsHorizontal?"horizontal":"vertical",s=o.inlineIsHorizontal?"vertical":"horizontal";r.nodes.forEach((o=>{if("word"===o.type){const t=o.value.toLowerCase();if("inline"===t)return void(o.value=c);"block"===t&&(o.value=s)}}));const l=r.toString();return l!==i&&(cloneDeclaration(t,l,e),!0)}}function directionFlowToAxes(o){switch(o){case e.TopToBottom:return[i.Top,i.Bottom];case e.BottomToTop:return[i.Bottom,i.Top];case e.RightToLeft:return[i.Right,i.Left];case e.LeftToRight:return[i.Left,i.Right]}}!function(o){o.Block="block",o.Inline="inline"}(o||(o={})),function(o){o.Start="start",o.End="end"}(t||(t={})),function(o){o.TopToBottom="top-to-bottom",o.BottomToTop="bottom-to-top",o.RightToLeft="right-to-left",o.LeftToRight="left-to-right"}(e||(e={})),function(o){o.Top="top",o.Right="right",o.Bottom="bottom",o.Left="left"}(i||(i={}));const creator=o=>{const t=Object.assign({blockDirection:e.TopToBottom,inlineDirection:e.LeftToRight},o),n=Object.values(e);if(!n.includes(t.blockDirection))throw new Error(`[postcss-logical-resize] "blockDirection" must be one of ${n.join(", ")}`);if(!n.includes(t.inlineDirection))throw new Error(`[postcss-logical-resize] "inlineDirection" must be one of ${n.join(", ")}`);const[r,c]=directionFlowToAxes(t.blockDirection),[s,l]=directionFlowToAxes(t.inlineDirection);if(!Object.values(i).every((o=>[r,c,s,l].includes(o))))throw new Error('[postcss-logical-resize] "blockDirection" and "inlineDirection" must be on separate axes');const a={block:[r,c],inline:[s,l],inlineIsHorizontal:[e.LeftToRight,e.RightToLeft].includes(t.inlineDirection)};return{postcssPlugin:"postcss-logical-resize",Declaration:{resize:(u=transformResize(a),(o,{result:t})=>{if(!u)return;let e=!1;try{e=u(o)}catch(e){return void o.warn(t,e.message)}e&&o.remove()})}};var u};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-logical-resize/dist/index.d.ts b/node_modules/@csstools/postcss-logical-resize/dist/index.d.ts new file mode 100644 index 00000000..0cac31d0 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-resize/dist/index.d.ts @@ -0,0 +1,11 @@ +import type { PluginCreator } from 'postcss'; +import { DirectionFlow } from './lib/types'; +/** postcss-logical-resize plugin options */ +export type pluginOptions = { + /** Sets the direction for block. default: top-to-bottom */ + blockDirection?: DirectionFlow; + /** Sets the direction for inline. default: left-to-right */ + inlineDirection?: DirectionFlow; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-logical-resize/dist/index.mjs b/node_modules/@csstools/postcss-logical-resize/dist/index.mjs new file mode 100644 index 00000000..5cffc5e7 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-resize/dist/index.mjs @@ -0,0 +1 @@ +import o from"postcss-value-parser";var t,e,i,n;function cloneDeclaration(o,t,e){o.parent&&o.parent.some((o=>"decl"==o.type&&o.prop===e&&o.value===t))||o.cloneBefore({value:t,prop:e})}function transformResize(t){return e=>{const{prop:i,value:n}=e,r=o(n),c=t.inlineIsHorizontal?"horizontal":"vertical",s=t.inlineIsHorizontal?"vertical":"horizontal";r.nodes.forEach((o=>{if("word"===o.type){const t=o.value.toLowerCase();if("inline"===t)return void(o.value=c);"block"===t&&(o.value=s)}}));const l=r.toString();return l!==n&&(cloneDeclaration(e,l,i),!0)}}function directionFlowToAxes(o){switch(o){case i.TopToBottom:return[n.Top,n.Bottom];case i.BottomToTop:return[n.Bottom,n.Top];case i.RightToLeft:return[n.Right,n.Left];case i.LeftToRight:return[n.Left,n.Right]}}!function(o){o.Block="block",o.Inline="inline"}(t||(t={})),function(o){o.Start="start",o.End="end"}(e||(e={})),function(o){o.TopToBottom="top-to-bottom",o.BottomToTop="bottom-to-top",o.RightToLeft="right-to-left",o.LeftToRight="left-to-right"}(i||(i={})),function(o){o.Top="top",o.Right="right",o.Bottom="bottom",o.Left="left"}(n||(n={}));const creator=o=>{const t=Object.assign({blockDirection:i.TopToBottom,inlineDirection:i.LeftToRight},o),e=Object.values(i);if(!e.includes(t.blockDirection))throw new Error(`[postcss-logical-resize] "blockDirection" must be one of ${e.join(", ")}`);if(!e.includes(t.inlineDirection))throw new Error(`[postcss-logical-resize] "inlineDirection" must be one of ${e.join(", ")}`);const[r,c]=directionFlowToAxes(t.blockDirection),[s,l]=directionFlowToAxes(t.inlineDirection);if(!Object.values(n).every((o=>[r,c,s,l].includes(o))))throw new Error('[postcss-logical-resize] "blockDirection" and "inlineDirection" must be on separate axes');const a={block:[r,c],inline:[s,l],inlineIsHorizontal:[i.LeftToRight,i.RightToLeft].includes(t.inlineDirection)};return{postcssPlugin:"postcss-logical-resize",Declaration:{resize:(u=transformResize(a),(o,{result:t})=>{if(!u)return;let e=!1;try{e=u(o)}catch(e){return void o.warn(t,e.message)}e&&o.remove()})}};var u};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-logical-resize/dist/lib/clone-declaration.d.ts b/node_modules/@csstools/postcss-logical-resize/dist/lib/clone-declaration.d.ts new file mode 100644 index 00000000..1503bf6f --- /dev/null +++ b/node_modules/@csstools/postcss-logical-resize/dist/lib/clone-declaration.d.ts @@ -0,0 +1,2 @@ +import type { Declaration } from 'postcss'; +export declare function cloneDeclaration(declaration: Declaration, value: string, prop: string): void; diff --git a/node_modules/@csstools/postcss-logical-resize/dist/lib/transform-resize.d.ts b/node_modules/@csstools/postcss-logical-resize/dist/lib/transform-resize.d.ts new file mode 100644 index 00000000..12100551 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-resize/dist/lib/transform-resize.d.ts @@ -0,0 +1,3 @@ +import type { Declaration } from 'postcss'; +import { DirectionConfig } from './types'; +export declare function transformResize(directionConfig: DirectionConfig): (declaration: Declaration) => boolean; diff --git a/node_modules/@csstools/postcss-logical-resize/dist/lib/types.d.ts b/node_modules/@csstools/postcss-logical-resize/dist/lib/types.d.ts new file mode 100644 index 00000000..7f27fd46 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-resize/dist/lib/types.d.ts @@ -0,0 +1,31 @@ +export declare enum Direction { + Block = "block", + Inline = "inline" +} +export declare enum DirectionValue { + Start = "start", + End = "end" +} +export declare const DirectionValues: { + BlockStart: string; + BlockEnd: string; + InlineStart: string; + InlineEnd: string; +}; +export declare enum DirectionFlow { + TopToBottom = "top-to-bottom", + BottomToTop = "bottom-to-top", + RightToLeft = "right-to-left", + LeftToRight = "left-to-right" +} +export declare enum Axes { + Top = "top", + Right = "right", + Bottom = "bottom", + Left = "left" +} +export type DirectionConfig = { + [Direction.Block]: [Axes, Axes]; + [Direction.Inline]: [Axes, Axes]; + inlineIsHorizontal: boolean; +}; diff --git a/node_modules/@csstools/postcss-logical-resize/dist/utils/direction-flow-to-axes.d.ts b/node_modules/@csstools/postcss-logical-resize/dist/utils/direction-flow-to-axes.d.ts new file mode 100644 index 00000000..2652d71d --- /dev/null +++ b/node_modules/@csstools/postcss-logical-resize/dist/utils/direction-flow-to-axes.d.ts @@ -0,0 +1,2 @@ +import { DirectionFlow, Axes } from '../lib/types'; +export declare function directionFlowToAxes(directionFlow: DirectionFlow): [Axes, Axes]; diff --git a/node_modules/@csstools/postcss-logical-resize/package.json b/node_modules/@csstools/postcss-logical-resize/package.json new file mode 100644 index 00000000..9fa60ff6 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-resize/package.json @@ -0,0 +1,89 @@ +{ + "name": "@csstools/postcss-logical-resize", + "description": "Use logical values in the resize property", + "version": "2.0.0", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-logical-resize#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-logical-resize" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "block", + "css", + "inline", + "logical", + "postcss", + "postcss-plugin", + "resize" + ], + "csstools": { + "cssdbId": "logical-resize", + "exportName": "postcssLogicalResize", + "humanReadableName": "PostCSS Logical Resize", + "specUrl": "https://www.w3.org/TR/css-logical-1/" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-logical-viewport-units/CHANGELOG.md b/node_modules/@csstools/postcss-logical-viewport-units/CHANGELOG.md new file mode 100644 index 00000000..a93e5c0c --- /dev/null +++ b/node_modules/@csstools/postcss-logical-viewport-units/CHANGELOG.md @@ -0,0 +1,49 @@ +# Changes to PostCSS Logical Viewport Units + +### 2.0.3 + +_September 24, 2023_ + +- 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) + +### 2.0.2 + +_September 18, 2023_ + +- Improve performance + +### 2.0.1 + +_July 24, 2023_ + +- 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) + +### 2.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) + +### 1.0.3 + +_April 10, 2023_ + +- Updated `@csstools/css-tokenizer` to `2.1.1` (patch) + +### 1.0.2 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 1.0.1 + +_January 24, 2023_ + +- Correctly list dependencies in `package.json` + +### 1.0.0 + +_January 19, 2023_ + +- Initial version diff --git a/node_modules/@csstools/postcss-logical-viewport-units/LICENSE.md b/node_modules/@csstools/postcss-logical-viewport-units/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-viewport-units/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-logical-viewport-units/README.md b/node_modules/@csstools/postcss-logical-viewport-units/README.md new file mode 100644 index 00000000..622864c0 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-viewport-units/README.md @@ -0,0 +1,118 @@ +# PostCSS Logical Viewport Units [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-logical-viewport-units.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/logical-viewport-units.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +```bash +npm install @csstools/postcss-logical-viewport-units --save-dev +``` + +[PostCSS Logical Viewport Units] lets you easily use `vb` and `vi` length units following the [CSS-Values-4 Specification]. + +```pcss +.foo { + margin: 10vi 20vb; +} + +/* becomes */ + +.foo { + margin: 10vw 20vh; + margin: 10vi 20vb; +} +``` + +## Usage + +Add [PostCSS Logical Viewport Units] to your project: + +```bash +npm install postcss @csstools/postcss-logical-viewport-units --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssLogicalViewportUnits = require('@csstools/postcss-logical-viewport-units'); + +postcss([ + postcssLogicalViewportUnits(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Logical Viewport Units] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### inlineDirection + +The `inlineDirection` option allows you to specify the direction of the inline axe. The default value is `left-to-right`, which would match any latin language. + +**You should tweak this value so that it is specific to your language and writing mode.** + +```js +postcssLogicalViewportUnits({ + inlineDirection: 'top-to-bottom' +}) +``` + +```pcss +.foo { + margin: 10vi 20vb; +} + +/* becomes */ + +.foo { + margin: 10vh 20vw; + margin: 10vi 20vb; +} +``` + +Each direction must be one of the following: + +- `top-to-bottom` +- `bottom-to-top` +- `left-to-right` +- `right-to-left` + +Please do note that transformations won't do anything particular for `right-to-left` or `bottom-to-top`. + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is preserved. + +```js +postcssLogicalViewportUnits({ preserve: false }) +``` + +```pcss +.foo { + margin: 10vi 20vb; +} + +/* becomes */ + +.foo { + margin: 10vw 20vh; +} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#logical-viewport-units +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-logical-viewport-units + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Logical Viewport Units]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-logical-viewport-units +[CSS-Values-4 Specification]: https://www.w3.org/TR/css-values-4/#viewport-relative-units diff --git a/node_modules/@csstools/postcss-logical-viewport-units/dist/has-feature.d.ts b/node_modules/@csstools/postcss-logical-viewport-units/dist/has-feature.d.ts new file mode 100644 index 00000000..a902b0da --- /dev/null +++ b/node_modules/@csstools/postcss-logical-viewport-units/dist/has-feature.d.ts @@ -0,0 +1 @@ +export declare function hasFeature(source: string): boolean; diff --git a/node_modules/@csstools/postcss-logical-viewport-units/dist/has-supports-at-rule-ancestor.d.ts b/node_modules/@csstools/postcss-logical-viewport-units/dist/has-supports-at-rule-ancestor.d.ts new file mode 100644 index 00000000..a46009ec --- /dev/null +++ b/node_modules/@csstools/postcss-logical-viewport-units/dist/has-supports-at-rule-ancestor.d.ts @@ -0,0 +1,2 @@ +import type { Node } from 'postcss'; +export declare function hasSupportsAtRuleAncestor(node: Node): boolean; diff --git a/node_modules/@csstools/postcss-logical-viewport-units/dist/index.cjs b/node_modules/@csstools/postcss-logical-viewport-units/dist/index.cjs new file mode 100644 index 00000000..4371e8d6 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-viewport-units/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var t,e,o=require("@csstools/css-tokenizer");function hasFeature(t){{const e=t.toLowerCase();if(!e.includes("vb")&&!e.includes("vi"))return!1}const e=o.tokenizer({css:t});for(;;){const t=e.nextToken();if(!t)break;if(t[0]===o.TokenType.EOF)break;if(t[0]!==o.TokenType.Dimension)continue;const n=t[4].unit.toLowerCase();if("vb"===n||"vi"===n)return!0}return!1}function hasSupportsAtRuleAncestor(t){let e=t.parent;for(;e;)if("atrule"===e.type){if("supports"===e.name.toLowerCase()&&hasFeature(e.params))return!0;e=e.parent}else e=e.parent;return!1}function transform(t,e){const n=o.tokenizer({css:t}),r=[];let i=!1;for(;;){const t=n.nextToken();if(!t)break;if(r.push(t),t[0]===o.TokenType.EOF)break;if(t[0]!==o.TokenType.Dimension)continue;const s=t[4].unit.toLowerCase();let u;"vi"===s?u=e.vi:"vb"===s&&(u=e.vb),u&&(t[1]=t[4].value.toString()+u,t[4].unit=u,i=!0)}return i?o.stringify(...r):t}!function(t){t.TopToBottom="top-to-bottom",t.BottomToTop="bottom-to-top",t.RightToLeft="right-to-left",t.LeftToRight="left-to-right"}(t||(t={})),function(t){t.Top="top",t.Right="right",t.Bottom="bottom",t.Left="left"}(e||(e={}));const n=/(?:vi|vb)\b/i,creator=e=>{const o=Object.assign({inlineDirection:t.LeftToRight,preserve:!0},e),r=Object.values(t);if(!r.includes(o.inlineDirection))throw new Error(`[postcss-logical-viewport-units] "inlineDirection" must be one of ${r.join(", ")}`);const i=[t.LeftToRight,t.RightToLeft].includes(o.inlineDirection),s={vb:"vh",vi:"vw"};return i||(s.vb="vw",s.vi="vh"),{postcssPlugin:"postcss-logical-viewport-units",Declaration(t,{atRule:e}){{if(!n.test(t.value))return;const e=t.prev();if(e&&"decl"===e.type&&e.prop===t.prop)return;if(hasSupportsAtRuleAncestor(t))return}const r=transform(t.value,s);if(r===t.value)return;if(t.cloneBefore({value:r}),!o.preserve)return void t.remove();if(!t.variable)return;const i=e({name:"supports",params:"(top: 1vi)",source:t.source}),u=t.parent;if(!u)return;const c=u.cloneAfter({nodes:[]});c.append(t),i.append(c),u.after(i)}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-logical-viewport-units/dist/index.d.ts b/node_modules/@csstools/postcss-logical-viewport-units/dist/index.d.ts new file mode 100644 index 00000000..bf4c6641 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-viewport-units/dist/index.d.ts @@ -0,0 +1,11 @@ +import type { PluginCreator } from 'postcss'; +import { DirectionFlow } from './lib/types'; +/** postcss-logical-viewport-units plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; + /** Sets the direction for inline. default: left-to-right */ + inlineDirection?: DirectionFlow; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-logical-viewport-units/dist/index.mjs b/node_modules/@csstools/postcss-logical-viewport-units/dist/index.mjs new file mode 100644 index 00000000..5cd02459 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-viewport-units/dist/index.mjs @@ -0,0 +1 @@ +import{tokenizer as t,TokenType as e,stringify as o}from"@csstools/css-tokenizer";function hasFeature(o){{const t=o.toLowerCase();if(!t.includes("vb")&&!t.includes("vi"))return!1}const n=t({css:o});for(;;){const t=n.nextToken();if(!t)break;if(t[0]===e.EOF)break;if(t[0]!==e.Dimension)continue;const o=t[4].unit.toLowerCase();if("vb"===o||"vi"===o)return!0}return!1}function hasSupportsAtRuleAncestor(t){let e=t.parent;for(;e;)if("atrule"===e.type){if("supports"===e.name.toLowerCase()&&hasFeature(e.params))return!0;e=e.parent}else e=e.parent;return!1}var n,r;function transform(n,r){const i=t({css:n}),s=[];let u=!1;for(;;){const t=i.nextToken();if(!t)break;if(s.push(t),t[0]===e.EOF)break;if(t[0]!==e.Dimension)continue;const o=t[4].unit.toLowerCase();let n;"vi"===o?n=r.vi:"vb"===o&&(n=r.vb),n&&(t[1]=t[4].value.toString()+n,t[4].unit=n,u=!0)}return u?o(...s):n}!function(t){t.TopToBottom="top-to-bottom",t.BottomToTop="bottom-to-top",t.RightToLeft="right-to-left",t.LeftToRight="left-to-right"}(n||(n={})),function(t){t.Top="top",t.Right="right",t.Bottom="bottom",t.Left="left"}(r||(r={}));const i=/(?:vi|vb)\b/i,creator=t=>{const e=Object.assign({inlineDirection:n.LeftToRight,preserve:!0},t),o=Object.values(n);if(!o.includes(e.inlineDirection))throw new Error(`[postcss-logical-viewport-units] "inlineDirection" must be one of ${o.join(", ")}`);const r=[n.LeftToRight,n.RightToLeft].includes(e.inlineDirection),s={vb:"vh",vi:"vw"};return r||(s.vb="vw",s.vi="vh"),{postcssPlugin:"postcss-logical-viewport-units",Declaration(t,{atRule:o}){{if(!i.test(t.value))return;const e=t.prev();if(e&&"decl"===e.type&&e.prop===t.prop)return;if(hasSupportsAtRuleAncestor(t))return}const n=transform(t.value,s);if(n===t.value)return;if(t.cloneBefore({value:n}),!e.preserve)return void t.remove();if(!t.variable)return;const r=o({name:"supports",params:"(top: 1vi)",source:t.source}),u=t.parent;if(!u)return;const c=u.cloneAfter({nodes:[]});c.append(t),r.append(c),u.after(r)}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-logical-viewport-units/dist/lib/types.d.ts b/node_modules/@csstools/postcss-logical-viewport-units/dist/lib/types.d.ts new file mode 100644 index 00000000..2b3c47f9 --- /dev/null +++ b/node_modules/@csstools/postcss-logical-viewport-units/dist/lib/types.d.ts @@ -0,0 +1,18 @@ +export declare const DirectionValues: { + BlockStart: string; + BlockEnd: string; + InlineStart: string; + InlineEnd: string; +}; +export declare enum DirectionFlow { + TopToBottom = "top-to-bottom", + BottomToTop = "bottom-to-top", + RightToLeft = "right-to-left", + LeftToRight = "left-to-right" +} +export declare enum Axes { + Top = "top", + Right = "right", + Bottom = "bottom", + Left = "left" +} diff --git a/node_modules/@csstools/postcss-logical-viewport-units/dist/transform.d.ts b/node_modules/@csstools/postcss-logical-viewport-units/dist/transform.d.ts new file mode 100644 index 00000000..0d007ffa --- /dev/null +++ b/node_modules/@csstools/postcss-logical-viewport-units/dist/transform.d.ts @@ -0,0 +1,4 @@ +export declare function transform(source: string, replacements: { + vi: 'vw' | 'vh'; + vb: 'vw' | 'vh'; +}): string; diff --git a/node_modules/@csstools/postcss-logical-viewport-units/package.json b/node_modules/@csstools/postcss-logical-viewport-units/package.json new file mode 100644 index 00000000..f20a819d --- /dev/null +++ b/node_modules/@csstools/postcss-logical-viewport-units/package.json @@ -0,0 +1,90 @@ +{ + "name": "@csstools/postcss-logical-viewport-units", + "description": "Use vb and vi length units in CSS", + "version": "2.0.3", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/css-tokenizer": "^2.2.1" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-logical-viewport-units#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-logical-viewport-units" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "block", + "css", + "inline", + "logical", + "padding", + "postcss", + "postcss-plugin", + "viewport units" + ], + "csstools": { + "cssdbId": "logical-viewport-units", + "exportName": "postcssLogicalViewportUnits", + "humanReadableName": "PostCSS Logical Viewport Units", + "specUrl": "https://www.w3.org/TR/css-values-4/#viewport-relative-units" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-media-minmax/CHANGELOG.md b/node_modules/@csstools/postcss-media-minmax/CHANGELOG.md new file mode 100644 index 00000000..2ed00d6d --- /dev/null +++ b/node_modules/@csstools/postcss-media-minmax/CHANGELOG.md @@ -0,0 +1,69 @@ +# Changes to PostCSS Media MinMax + +### 1.1.0 + +_September 24, 2023_ + +- Add support for `@custom-media` queries. +- 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) +- Updated [`@csstools/media-query-list-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser) to [`2.1.5`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser/CHANGELOG.md#215) (patch) + +### 1.0.7 + +_August 5, 2023_ + +- Updated [`@csstools/media-query-list-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser) to [`2.1.4`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser/CHANGELOG.md#214) (patch) + +### 1.0.6 + +_July 24, 2023_ + +- 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) +- Updated [`@csstools/media-query-list-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser) to [`2.1.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser/CHANGELOG.md#213) (patch) + +### 1.0.5 + +_July 3, 2023_ + +- 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) +- Updated [`@csstools/media-query-list-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser) to [`2.1.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser/CHANGELOG.md#212) (patch) + +### 1.0.4 + +_June 21, 2023_ + +- Updated `@csstools/media-query-list-parser` to `2.1.1` (patch) + + +### 1.0.3 + +_June 1, 2023_ + +- Updated `@csstools/media-query-list-parser` to `2.1.0` (minor) + + +### 1.0.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) +- Updated `@csstools/media-query-list-parser` to `2.0.4` (patch) + +### 1.0.1 + +_April 10, 2023_ + +- Improve the detection of math function in media queries. + +### 1.0.0 + +_March 30, 2023_ + +- Initial version diff --git a/node_modules/@csstools/postcss-media-minmax/LICENSE.md b/node_modules/@csstools/postcss-media-minmax/LICENSE.md new file mode 100644 index 00000000..324aa86d --- /dev/null +++ b/node_modules/@csstools/postcss-media-minmax/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2022 Romain Menke, Antonio Laguna <antonio@laguna.es>, PostCSS + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-media-minmax/README.md b/node_modules/@csstools/postcss-media-minmax/README.md new file mode 100644 index 00000000..6129f0ab --- /dev/null +++ b/node_modules/@csstools/postcss-media-minmax/README.md @@ -0,0 +1,67 @@ +# PostCSS Media MinMax [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-media-minmax.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/media-query-ranges.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +```bash +npm install @csstools/postcss-media-minmax --save-dev +``` + +[PostCSS Media MinMax] lets you use the range notation in media queries following the [Media Queries 4 Specification]. + +```pcss +@media screen and (width >=500px) and (width <=1200px) { + .bar { + display: block; + } +} + +/* becomes */ + +@media screen and (min-width:500px) and (max-width:1200px) { + .bar { + display: block; + } +} +``` + +## Usage + +Add [PostCSS Media MinMax] to your project: + +```bash +npm install postcss @csstools/postcss-media-minmax --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssMediaMinMax = require('@csstools/postcss-media-minmax'); + +postcss([ + postcssMediaMinMax(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Media MinMax] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +_See prior work by [yisibl](https://github.com/yisibl) here [postcss-media-minmax](https://github.com/postcss/postcss-media-minmax) +To ensure long term maintenance and to provide the needed features this plugin was recreated based on yisibl's work._ + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#media-query-ranges +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-media-minmax + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Media MinMax]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-media-minmax +[Media Queries 4 Specification]: https://www.w3.org/TR/mediaqueries-4/#mq-features diff --git a/node_modules/@csstools/postcss-media-minmax/dist/index.cjs b/node_modules/@csstools/postcss-media-minmax/dist/index.cjs new file mode 100644 index 00000000..1552173d --- /dev/null +++ b/node_modules/@csstools/postcss-media-minmax/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/css-parser-algorithms"),i=require("@csstools/css-tokenizer"),n=require("@csstools/media-query-list-parser"),a=require("@csstools/css-calc");const t=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(t,(e=>String.fromCharCode(e.charCodeAt(0)+32)))}const r={width:"px",height:"px","device-width":"px","device-height":"px","aspect-ratio":"","device-aspect-ratio":"",color:"","color-index":"",monochrome:"",resolution:"dpi"},o={width:!1,height:!1,"device-width":!1,"device-height":!1,"aspect-ratio":!1,"device-aspect-ratio":!1,color:!0,"color-index":!0,monochrome:!0,resolution:"dpi"};function featureNamePrefix(e){return e===n.MediaFeatureLT.LT||e===n.MediaFeatureLT.LT_OR_EQ?"max-":e===n.MediaFeatureGT.GT||e===n.MediaFeatureGT.GT_OR_EQ?"min-":""}const s={">":1,"<":-1},u=.001,d=.02;function transformSingleNameValuePair(t,l,c,p){let T=c.before,m=c.after;if(p||(T=c.after,m=c.before),!p){const e=n.invertComparison(l);if(!1===e)return;l=e}if(l===n.MediaFeatureEQ.EQ||l===n.MediaFeatureLT.LT_OR_EQ||l===n.MediaFeatureGT.GT_OR_EQ)return Array.isArray(c.value)?n.newMediaFeaturePlain(featureNamePrefix(l)+t,...T,...c.value.flatMap((e=>e.tokens())),...m):n.newMediaFeaturePlain(featureNamePrefix(l)+t,...T,...c.value.tokens(),...m);let f,v,y=!1;if(Array.isArray(c.value)){if(!n.matchesRatioExactly(c.value))return;if("aspect-ratio"!==t&&"device-aspect-ratio"!==t)return;const e=n.matchesRatio(c.value);if(-1===e)return;y=!0,f=c.value[e[0]],v=[...c.value.slice(e[0]+1).flatMap((e=>e.tokens()))]}else f=c.value,v=[];const h=r[t.toLowerCase()];if(e.isFunctionNode(f)){const r=toLowerCaseAZ(f.getName());if(a.mathFunctionNames.has(r)||"env"===r){const[[r]]=a.calcFromComponentValues([[f]],{precision:5,toCanonicalUnits:!0});if(!r||!e.isTokenNode(r)||r.value[0]!==i.TokenType.Number&&r.value[0]!==i.TokenType.Percentage&&r.value[0]!==i.TokenType.Dimension||!Number.isInteger(r.value[4].value)){let e;if(void 0!==h){const n=s[l]*("px"===h?d:u);e=[i.TokenType.Dimension,`${n.toString()}${h}`,-1,-1,{value:n,unit:h,type:i.NumberType.Integer}]}else if(!0===o[t]){const n=s[l];e=[i.TokenType.Number,n.toString(),-1,-1,{value:n,type:i.NumberType.Integer}]}else if(y){const n=s[l]*u;e=[i.TokenType.Number,n.toString(),-1,-1,{value:n,type:i.NumberType.Integer}]}else{const n=s[l];e=[i.TokenType.Number,n.toString(),-1,-1,{value:n,type:i.NumberType.Integer}]}return n.newMediaFeaturePlain(featureNamePrefix(l)+t,...T,[i.TokenType.Function,"calc(",-1,-1,{value:"calc("}],[i.TokenType.OpenParen,"(",-1,-1,void 0],...f.tokens().slice(1),[i.TokenType.Whitespace," ",-1,-1,void 0],[i.TokenType.Delim,"+",-1,-1,{value:"+"}],[i.TokenType.Whitespace," ",-1,-1,void 0],e,[i.TokenType.CloseParen,")",-1,-1,void 0],...v,...m)}f=r}}if(!e.isTokenNode(f))return;let g,k=f.value,M="";if(void 0!==h&&k[0]===i.TokenType.Number&&0===k[4].value)g=s[l],M=h;else if(k[0]===i.TokenType.Number&&0===k[4].value)g=s[l],M="";else if(k[0]===i.TokenType.Dimension&&0===k[4].value)g=s[l],M=k[4].unit;else if(k[0]===i.TokenType.Number&&!0===o[t])g=k[4].value+s[l];else if(k[0]===i.TokenType.Dimension&&"px"===k[4].unit&&k[4].type===i.NumberType.Integer)g=Number(Math.round(Number(k[4].value+d*s[l]+"e6"))+"e-6");else{if(k[0]!==i.TokenType.Dimension&&k[0]!==i.TokenType.Number)return;g=Number(Math.round(Number(k[4].value+u*s[l]+"e6"))+"e-6")}return M&&(k=[i.TokenType.Dimension,k[1],k[2],k[3],{value:k[4].value,unit:M,type:k[4].type}]),k[4].value=g,k[0]===i.TokenType.Dimension?k[1]=k[4].value.toString()+k[4].unit:k[1]=k[4].value.toString(),n.newMediaFeaturePlain(featureNamePrefix(l)+t,...T,k,...v,...m)}const l=new Set(["aspect-ratio","color","color-index","device-aspect-ratio","device-height","device-width","height","horizontal-viewport-segments","monochrome","resolution","vertical-viewport-segments","width"]);function transform(a){return a.map(((a,t)=>{const r=e.gatherNodeAncestry(a);a.walk((e=>{const t=e.node;if(!n.isMediaFeatureRange(t))return;const o=e.parent;if(!n.isMediaFeature(o))return;const s=toLowerCaseAZ(t.name.getName());if(!l.has(s))return;if(n.isMediaFeatureRangeNameValue(t)||n.isMediaFeatureRangeValueName(t)){const e=t.operatorKind();if(!1===e)return;const i=transformSingleNameValuePair(s,e,t.value,n.isMediaFeatureRangeNameValue(t));return void(i&&(o.feature=i.feature))}const u=r.get(o);if(!n.isMediaInParens(u))return;let d=null,c=null;{const e=t.valueOneOperatorKind();if(!1===e)return;const i=transformSingleNameValuePair(s,e,t.valueOne,!1);if(!i)return;e===n.MediaFeatureLT.LT||e===n.MediaFeatureLT.LT_OR_EQ?(d=i,d.before=o.before):(c=i,c.after=o.after)}{const e=t.valueTwoOperatorKind();if(!1===e)return;const i=transformSingleNameValuePair(s,e,t.valueTwo,!0);if(!i)return;e===n.MediaFeatureLT.LT||e===n.MediaFeatureLT.LT_OR_EQ?(c=i,c.before=o.before):(d=i,d.after=o.after)}if(!d||!c)return;const p=new n.MediaInParens(d),T=new n.MediaInParens(c),m=getMediaConditionListWithAndFromAncestry(u,r);if(m)return m.leading===u?(m.leading=p,void(m.list=[new n.MediaAnd([[i.TokenType.Whitespace," ",-1,-1,void 0],[i.TokenType.Ident,"and",-1,-1,{value:"and"}],[i.TokenType.Whitespace," ",-1,-1,void 0]],T),...m.list])):void m.list.splice(m.indexOf(r.get(u)),1,new n.MediaAnd([[i.TokenType.Whitespace," ",-1,-1,void 0],[i.TokenType.Ident,"and",-1,-1,{value:"and"}],[i.TokenType.Whitespace," ",-1,-1,void 0]],p),new n.MediaAnd([[i.TokenType.Whitespace," ",-1,-1,void 0],[i.TokenType.Ident,"and",-1,-1,{value:"and"}],[i.TokenType.Whitespace," ",-1,-1,void 0]],T));const f=new n.MediaConditionListWithAnd(p,[new n.MediaAnd([[i.TokenType.Whitespace," ",-1,-1,void 0],[i.TokenType.Ident,"and",-1,-1,{value:"and"}],[i.TokenType.Whitespace," ",-1,-1,void 0]],T)],[[i.TokenType.Whitespace," ",-1,-1,void 0]]),v=getMediaConditionInShallowMediaQueryFromAncestry(u,a,r);v?v.media=f:u.media=new n.MediaCondition(new n.MediaInParens(new n.MediaCondition(f),[[i.TokenType.Whitespace," ",-1,-1,void 0],[i.TokenType.OpenParen,"(",-1,-1,void 0]],[[i.TokenType.CloseParen,")",-1,-1,void 0]]))}));const o=a.tokens();return i.stringify(...o.filter(((e,n)=>(0!==n||0!==t||e[0]!==i.TokenType.Whitespace)&&(e[0]!==i.TokenType.Whitespace||!o[n+1]||o[n+1][0]!==i.TokenType.Whitespace))))})).join(",")}function getMediaConditionListWithAndFromAncestry(e,i){let a=e;if(a){if(a=i.get(a),n.isMediaConditionListWithAnd(a))return a;if(n.isMediaAnd(a))return a=i.get(a),n.isMediaConditionListWithAnd(a)?a:void 0}}function getMediaConditionInShallowMediaQueryFromAncestry(e,i,a){let t=e;if(!t)return;if(t=a.get(t),!n.isMediaCondition(t))return;const r=t;return t=a.get(t),n.isMediaQuery(t)&&t===i?r:void 0}const creator=()=>({postcssPlugin:"postcss-media-minmax",AtRule:{media:e=>{if(!(e.params.includes("<")||e.params.includes(">")||e.params.includes("=")))return;const i=transform(n.parse(e.params,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw e.error(`Unable to parse media query "${e.params}"`)}}));e.params!==i&&(e.params=i)},"custom-media":e=>{if(!(e.params.includes("<")||e.params.includes(">")||e.params.includes("=")))return;const a=n.parseCustomMedia(e.params,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw e.error(`Unable to parse media query "${e.params}"`)}});if(!a||!a.mediaQueryList)return;const t=a.mediaQueryList.map((e=>e.toString())).join(","),r=transform(a.mediaQueryList);t!==r&&(e.params=`${i.stringify(...a.name)} ${r}`)}}});creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-media-minmax/dist/index.d.ts b/node_modules/@csstools/postcss-media-minmax/dist/index.d.ts new file mode 100644 index 00000000..f22ef708 --- /dev/null +++ b/node_modules/@csstools/postcss-media-minmax/dist/index.d.ts @@ -0,0 +1,5 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-media-minmax plugin options */ +export type pluginOptions = never; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-media-minmax/dist/index.mjs b/node_modules/@csstools/postcss-media-minmax/dist/index.mjs new file mode 100644 index 00000000..1d4c7bf2 --- /dev/null +++ b/node_modules/@csstools/postcss-media-minmax/dist/index.mjs @@ -0,0 +1 @@ +import{isFunctionNode as e,isTokenNode as t,gatherNodeAncestry as r}from"@csstools/css-parser-algorithms";import{TokenType as i,NumberType as n,stringify as a}from"@csstools/css-tokenizer";import{invertComparison as o,MediaFeatureEQ as s,MediaFeatureLT as u,MediaFeatureGT as l,newMediaFeaturePlain as c,matchesRatioExactly as d,matchesRatio as m,isMediaFeatureRange as f,isMediaFeature as v,isMediaFeatureRangeNameValue as p,isMediaFeatureRangeValueName as h,isMediaInParens as g,MediaInParens as w,MediaAnd as N,MediaConditionListWithAnd as y,MediaCondition as b,isMediaConditionListWithAnd as x,isMediaAnd as P,isMediaCondition as W,isMediaQuery as A,parse as L,parseCustomMedia as S}from"@csstools/media-query-list-parser";import{mathFunctionNames as C,calcFromComponentValues as I}from"@csstools/css-calc";const Q=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(Q,(e=>String.fromCharCode(e.charCodeAt(0)+32)))}const O={width:"px",height:"px","device-width":"px","device-height":"px","aspect-ratio":"","device-aspect-ratio":"",color:"","color-index":"",monochrome:"",resolution:"dpi"},M={width:!1,height:!1,"device-width":!1,"device-height":!1,"aspect-ratio":!1,"device-aspect-ratio":!1,color:!0,"color-index":!0,monochrome:!0,resolution:"dpi"};function featureNamePrefix(e){return e===u.LT||e===u.LT_OR_EQ?"max-":e===l.GT||e===l.GT_OR_EQ?"min-":""}const T={">":1,"<":-1},_=.001,E=.02;function transformSingleNameValuePair(r,a,f,v){let p=f.before,h=f.after;if(v||(p=f.after,h=f.before),!v){const e=o(a);if(!1===e)return;a=e}if(a===s.EQ||a===u.LT_OR_EQ||a===l.GT_OR_EQ)return Array.isArray(f.value)?c(featureNamePrefix(a)+r,...p,...f.value.flatMap((e=>e.tokens())),...h):c(featureNamePrefix(a)+r,...p,...f.value.tokens(),...h);let g,w,N=!1;if(Array.isArray(f.value)){if(!d(f.value))return;if("aspect-ratio"!==r&&"device-aspect-ratio"!==r)return;const e=m(f.value);if(-1===e)return;N=!0,g=f.value[e[0]],w=[...f.value.slice(e[0]+1).flatMap((e=>e.tokens()))]}else g=f.value,w=[];const y=O[r.toLowerCase()];if(e(g)){const e=toLowerCaseAZ(g.getName());if(C.has(e)||"env"===e){const[[e]]=I([[g]],{precision:5,toCanonicalUnits:!0});if(!e||!t(e)||e.value[0]!==i.Number&&e.value[0]!==i.Percentage&&e.value[0]!==i.Dimension||!Number.isInteger(e.value[4].value)){let e;if(void 0!==y){const t=T[a]*("px"===y?E:_);e=[i.Dimension,`${t.toString()}${y}`,-1,-1,{value:t,unit:y,type:n.Integer}]}else if(!0===M[r]){const t=T[a];e=[i.Number,t.toString(),-1,-1,{value:t,type:n.Integer}]}else if(N){const t=T[a]*_;e=[i.Number,t.toString(),-1,-1,{value:t,type:n.Integer}]}else{const t=T[a];e=[i.Number,t.toString(),-1,-1,{value:t,type:n.Integer}]}return c(featureNamePrefix(a)+r,...p,[i.Function,"calc(",-1,-1,{value:"calc("}],[i.OpenParen,"(",-1,-1,void 0],...g.tokens().slice(1),[i.Whitespace," ",-1,-1,void 0],[i.Delim,"+",-1,-1,{value:"+"}],[i.Whitespace," ",-1,-1,void 0],e,[i.CloseParen,")",-1,-1,void 0],...w,...h)}g=e}}if(!t(g))return;let b,x=g.value,P="";if(void 0!==y&&x[0]===i.Number&&0===x[4].value)b=T[a],P=y;else if(x[0]===i.Number&&0===x[4].value)b=T[a],P="";else if(x[0]===i.Dimension&&0===x[4].value)b=T[a],P=x[4].unit;else if(x[0]===i.Number&&!0===M[r])b=x[4].value+T[a];else if(x[0]===i.Dimension&&"px"===x[4].unit&&x[4].type===n.Integer)b=Number(Math.round(Number(x[4].value+E*T[a]+"e6"))+"e-6");else{if(x[0]!==i.Dimension&&x[0]!==i.Number)return;b=Number(Math.round(Number(x[4].value+_*T[a]+"e6"))+"e-6")}return P&&(x=[i.Dimension,x[1],x[2],x[3],{value:x[4].value,unit:P,type:x[4].type}]),x[4].value=b,x[0]===i.Dimension?x[1]=x[4].value.toString()+x[4].unit:x[1]=x[4].value.toString(),c(featureNamePrefix(a)+r,...p,x,...w,...h)}const D=new Set(["aspect-ratio","color","color-index","device-aspect-ratio","device-height","device-width","height","horizontal-viewport-segments","monochrome","resolution","vertical-viewport-segments","width"]);function transform(e){return e.map(((e,t)=>{const n=r(e);e.walk((t=>{const r=t.node;if(!f(r))return;const a=t.parent;if(!v(a))return;const o=toLowerCaseAZ(r.name.getName());if(!D.has(o))return;if(p(r)||h(r)){const e=r.operatorKind();if(!1===e)return;const t=transformSingleNameValuePair(o,e,r.value,p(r));return void(t&&(a.feature=t.feature))}const s=n.get(a);if(!g(s))return;let l=null,c=null;{const e=r.valueOneOperatorKind();if(!1===e)return;const t=transformSingleNameValuePair(o,e,r.valueOne,!1);if(!t)return;e===u.LT||e===u.LT_OR_EQ?(l=t,l.before=a.before):(c=t,c.after=a.after)}{const e=r.valueTwoOperatorKind();if(!1===e)return;const t=transformSingleNameValuePair(o,e,r.valueTwo,!0);if(!t)return;e===u.LT||e===u.LT_OR_EQ?(c=t,c.before=a.before):(l=t,l.after=a.after)}if(!l||!c)return;const d=new w(l),m=new w(c),x=getMediaConditionListWithAndFromAncestry(s,n);if(x)return x.leading===s?(x.leading=d,void(x.list=[new N([[i.Whitespace," ",-1,-1,void 0],[i.Ident,"and",-1,-1,{value:"and"}],[i.Whitespace," ",-1,-1,void 0]],m),...x.list])):void x.list.splice(x.indexOf(n.get(s)),1,new N([[i.Whitespace," ",-1,-1,void 0],[i.Ident,"and",-1,-1,{value:"and"}],[i.Whitespace," ",-1,-1,void 0]],d),new N([[i.Whitespace," ",-1,-1,void 0],[i.Ident,"and",-1,-1,{value:"and"}],[i.Whitespace," ",-1,-1,void 0]],m));const P=new y(d,[new N([[i.Whitespace," ",-1,-1,void 0],[i.Ident,"and",-1,-1,{value:"and"}],[i.Whitespace," ",-1,-1,void 0]],m)],[[i.Whitespace," ",-1,-1,void 0]]),W=getMediaConditionInShallowMediaQueryFromAncestry(s,e,n);W?W.media=P:s.media=new b(new w(new b(P),[[i.Whitespace," ",-1,-1,void 0],[i.OpenParen,"(",-1,-1,void 0]],[[i.CloseParen,")",-1,-1,void 0]]))}));const o=e.tokens();return a(...o.filter(((e,r)=>(0!==r||0!==t||e[0]!==i.Whitespace)&&(e[0]!==i.Whitespace||!o[r+1]||o[r+1][0]!==i.Whitespace))))})).join(",")}function getMediaConditionListWithAndFromAncestry(e,t){let r=e;if(r){if(r=t.get(r),x(r))return r;if(P(r))return r=t.get(r),x(r)?r:void 0}}function getMediaConditionInShallowMediaQueryFromAncestry(e,t,r){let i=e;if(!i)return;if(i=r.get(i),!W(i))return;const n=i;return i=r.get(i),A(i)&&i===t?n:void 0}const creator=()=>({postcssPlugin:"postcss-media-minmax",AtRule:{media:e=>{if(!(e.params.includes("<")||e.params.includes(">")||e.params.includes("=")))return;const t=transform(L(e.params,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw e.error(`Unable to parse media query "${e.params}"`)}}));e.params!==t&&(e.params=t)},"custom-media":e=>{if(!(e.params.includes("<")||e.params.includes(">")||e.params.includes("=")))return;const t=S(e.params,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw e.error(`Unable to parse media query "${e.params}"`)}});if(!t||!t.mediaQueryList)return;const r=t.mediaQueryList.map((e=>e.toString())).join(","),i=transform(t.mediaQueryList);r!==i&&(e.params=`${a(...t.name)} ${i}`)}}});creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-media-minmax/dist/to-lower-case-a-z.d.ts b/node_modules/@csstools/postcss-media-minmax/dist/to-lower-case-a-z.d.ts new file mode 100644 index 00000000..396b252e --- /dev/null +++ b/node_modules/@csstools/postcss-media-minmax/dist/to-lower-case-a-z.d.ts @@ -0,0 +1 @@ +export declare function toLowerCaseAZ(x: string): string; diff --git a/node_modules/@csstools/postcss-media-minmax/dist/transform-single-pair.d.ts b/node_modules/@csstools/postcss-media-minmax/dist/transform-single-pair.d.ts new file mode 100644 index 00000000..2b3e5ce0 --- /dev/null +++ b/node_modules/@csstools/postcss-media-minmax/dist/transform-single-pair.d.ts @@ -0,0 +1,2 @@ +import { MediaFeature, MediaFeatureComparison, MediaFeatureValue } from '@csstools/media-query-list-parser'; +export declare function transformSingleNameValuePair(name: string, operator: MediaFeatureComparison, value: MediaFeatureValue, nameBeforeValue: boolean): MediaFeature | undefined; diff --git a/node_modules/@csstools/postcss-media-minmax/dist/transform.d.ts b/node_modules/@csstools/postcss-media-minmax/dist/transform.d.ts new file mode 100644 index 00000000..9bcd6223 --- /dev/null +++ b/node_modules/@csstools/postcss-media-minmax/dist/transform.d.ts @@ -0,0 +1,2 @@ +import { MediaQuery } from '@csstools/media-query-list-parser'; +export declare function transform(mediaQueries: Array<MediaQuery>): string; diff --git a/node_modules/@csstools/postcss-media-minmax/package.json b/node_modules/@csstools/postcss-media-minmax/package.json new file mode 100644 index 00000000..1da41c6a --- /dev/null +++ b/node_modules/@csstools/postcss-media-minmax/package.json @@ -0,0 +1,92 @@ +{ + "name": "@csstools/postcss-media-minmax", + "description": "Use the range notation in CSS media queries", + "version": "1.1.0", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + }, + { + "name": "yisi" + } + ], + "license": "MIT", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/css-calc": "^1.1.4", + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1", + "@csstools/media-query-list-parser": "^2.1.5" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:browser": "node ./test/_browser.mjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-media-minmax#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-media-minmax" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "media queries", + "postcss-plugin", + "range" + ], + "csstools": { + "cssdbId": "media-query-ranges", + "exportName": "postcssMediaMinMax", + "humanReadableName": "PostCSS Media MinMax", + "specUrl": "https://www.w3.org/TR/mediaqueries-4/#mq-features" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/CHANGELOG.md b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/CHANGELOG.md new file mode 100644 index 00000000..71c37160 --- /dev/null +++ b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/CHANGELOG.md @@ -0,0 +1,68 @@ +# Changes to PostCSS Media Queries Aspect-Ratio Number Values + +### 2.0.3 + +_September 24, 2023_ + +- 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/media-query-list-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser) to [`2.1.5`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser/CHANGELOG.md#215) (patch) + +### 2.0.2 + +_August 5, 2023_ + +- Updated [`@csstools/media-query-list-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser) to [`2.1.4`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser/CHANGELOG.md#214) (patch) + +### 2.0.1 + +_July 24, 2023_ + +- 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/media-query-list-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser) to [`2.1.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser/CHANGELOG.md#213) (patch) + +### 2.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) +- 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/media-query-list-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser) to [`2.1.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser/CHANGELOG.md#212) (patch) + +### 1.0.4 + +_June 21, 2023_ + +- Updated `@csstools/media-query-list-parser` to `2.1.1` (patch) + + +### 1.0.3 + +_June 1, 2023_ + +- Updated `@csstools/media-query-list-parser` to `2.1.0` (minor) + + +### 1.0.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/media-query-list-parser` to `2.0.4` (patch) + +### 1.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` +- Updated `@csstools/css-parser-algorithms` to `2.0.0` (major) +- Updated `@csstools/css-tokenizer` to `2.0.0` (major) +- Updated `@csstools/media-query-list-parser` to `2.0.0` (major) + +### 1.0.0 + +_November 14, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/LICENSE.md b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/README.md b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/README.md new file mode 100644 index 00000000..8ed8ca89 --- /dev/null +++ b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/README.md @@ -0,0 +1,75 @@ +# PostCSS Media Queries Aspect-Ratio Number Values [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-media-queries-aspect-ratio-number-values.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/media-queries-aspect-ratio-number-values.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +```bash +npm install @csstools/postcss-media-queries-aspect-ratio-number-values --save-dev +``` + +[PostCSS Media Queries Aspect-Ratio Number Values] lets you use non-integer numbers and `calc()` in `aspect-ratio` feature queries following the [Media Queries 4 Specification]. + +```pcss +@media (min-aspect-ratio: 1.77) {} + +/* becomes */ + +@media (min-aspect-ratio: 177/100) {} +``` + +## Usage + +Add [PostCSS Media Queries Aspect-Ratio Number Values] to your project: + +```bash +npm install postcss @csstools/postcss-media-queries-aspect-ratio-number-values --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssMediaQueriesAspectRatioNumberValues = require('@csstools/postcss-media-queries-aspect-ratio-number-values'); + +postcss([ + postcssMediaQueriesAspectRatioNumberValues(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Media Queries Aspect-Ratio Number Values] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is not preserved. + +```js +postcssMediaQueriesAspectRatioNumberValues({ preserve: true }) +``` + +```pcss +@media (min-aspect-ratio: 1.77) {} + +/* becomes */ + +@media (min-aspect-ratio: 1.77),(min-aspect-ratio: 177/100) {} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#media-queries-aspect-ratio-number-values +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-media-queries-aspect-ratio-number-values + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Media Queries Aspect-Ratio Number Values]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-media-queries-aspect-ratio-number-values +[Media Queries 4 Specification]: https://www.w3.org/TR/mediaqueries-4/#aspect-ratio diff --git a/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/index.cjs b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/index.cjs new file mode 100644 index 00000000..836078f8 --- /dev/null +++ b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/media-query-list-parser"),r=require("@csstools/css-parser-algorithms"),n=require("@csstools/css-tokenizer");const o=1e5,t=2147483647;function transformMediaFeatureValue(a){if(Array.isArray(a.value)&&e.matchesRatioExactly(a.value)){const e=[];for(let o=0;o<a.value.length;o++){const t=a.value[o];r.isTokenNode(t)&&t.value[0]===n.TokenType.Number?e.push(t):r.isFunctionNode(t)&&"calc"===t.getName().toLowerCase()&&e.push(t)}if(2!==e.length)return;const i=e[0],u=a.value.indexOf(i),s=e[1],l=a.value.indexOf(s);if(r.isTokenNode(s)&&s.value[0]===n.TokenType.Number&&0===s.value[4].value)return a.value.splice(u,1,new r.TokenNode([n.TokenType.Number,t.toString(),-1,-1,{value:t,type:n.NumberType.Integer}])),void a.value.splice(l,1,new r.TokenNode([n.TokenType.Number,"1",-1,-1,{value:1,type:n.NumberType.Integer}]));if(r.isTokenNode(i)&&i.value[0]===n.TokenType.Number&&i.value[4].type===n.NumberType.Integer&&r.isTokenNode(s)&&s.value[0]===n.TokenType.Number&&s.value[4].type===n.NumberType.Integer)return;let c=null,p=null;if(r.isFunctionNode(i)&&"calc"===i.getName().toLowerCase()){if(i.toString().includes(o.toString()))return;c=modifyCalc(i)}if(r.isFunctionNode(s)&&"calc"===s.getName().toLowerCase()){if(s.toString().includes(o.toString()))return;p=modifyCalc(s)}if(r.isTokenNode(i)&&i.value[0]===n.TokenType.Number&&r.isTokenNode(s)&&s.value[0]===n.TokenType.Number){const e=i.value,t=s.value,a=Math.round(e[4].value*o),u=Math.round(t[4].value*o),l=greatestCommonDivisor(a,u);c=new r.TokenNode([n.TokenType.Number,Math.round(a/l).toString(),-1,-1,{value:Math.round(a/l),type:n.NumberType.Integer}]),p=new r.TokenNode([n.TokenType.Number,Math.round(u/l).toString(),-1,-1,{value:Math.round(u/l),type:n.NumberType.Integer}])}else{if(r.isTokenNode(i)&&i.value[0]===n.TokenType.Number){const e=i.value;c=new r.TokenNode([n.TokenType.Number,Math.round(e[4].value*o).toString(),-1,-1,{value:Math.round(e[4].value*o),type:n.NumberType.Integer}])}if(r.isTokenNode(s)&&s.value[0]===n.TokenType.Number){const e=s.value;p=new r.TokenNode([n.TokenType.Number,Math.round(e[4].value*o).toString(),-1,-1,{value:Math.round(e[4].value*o),type:n.NumberType.Integer}])}}return c&&p?(a.value.splice(u,1,c),void a.value.splice(l,1,p)):void 0}const i=Array.isArray(a.value)?a.value:[a.value];for(let e=0;e<i.length;e++){const t=i[e];if(r.isTokenNode(t)){const u=t.value;if(u[0]!==n.TokenType.Number)return;if(u[4].type===n.NumberType.Integer)return i.splice(e+1,0,new r.TokenNode([n.TokenType.Delim,"/",-1,-1,{value:"/"}]),new r.TokenNode([n.TokenType.Number,"1",-1,-1,{value:1,type:n.NumberType.Integer}])),void(a.value=i);if(u[4].type===n.NumberType.Number){const t=Math.round(u[4].value*o),s=greatestCommonDivisor(t,o);return i.splice(e,1,new r.TokenNode([n.TokenType.Number,Math.round(t/s).toString(),-1,-1,{value:Math.round(t/s),type:n.NumberType.Integer}]),new r.TokenNode([n.TokenType.Delim,"/",-1,-1,{value:"/"}]),new r.TokenNode([n.TokenType.Number,Math.round(o/s).toString(),-1,-1,{value:Math.round(o/s),type:n.NumberType.Integer}])),void(a.value=i)}return}if(r.isFunctionNode(t)&&"calc"===t.getName().toLowerCase())return i.splice(e,1,modifyCalc(t),new r.TokenNode([n.TokenType.Delim,"/",-1,-1,{value:"/"}]),new r.TokenNode([n.TokenType.Number,o.toString(),-1,-1,{value:o,type:n.NumberType.Integer}])),void(a.value=i)}}function modifyCalc(e){return new r.FunctionNode([n.TokenType.Function,"calc(",-1,-1,{value:"calc("}],[n.TokenType.CloseParen,")",-1,-1,void 0],[new r.SimpleBlockNode([n.TokenType.OpenParen,"(",-1,-1,void 0],[n.TokenType.CloseParen,")",-1,-1,void 0],e.value),new r.WhitespaceNode([[n.TokenType.Whitespace," ",-1,-1,void 0]]),new r.TokenNode([n.TokenType.Delim,"*",-1,-1,{value:"*"}]),new r.WhitespaceNode([[n.TokenType.Whitespace," ",-1,-1,void 0]]),new r.TokenNode([n.TokenType.Number,o.toString(),-1,-1,{value:o,type:n.NumberType.Integer}])])}function greatestCommonDivisor(e,r){if(Number.isNaN(e)||Number.isNaN(r))throw new Error("Unexpected 'NaN' when calculating the greatest common divisor.");if(!Number.isFinite(e)||!Number.isFinite(r))throw new Error("Unexpected 'Infinite' value when calculating the greatest common divisor.");for(r>e&&([e,r]=[r,e]);;){if(0==r)return e;if(0==(e%=r))return r;r%=e}}const a=new Set(["aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio"]);function transformMediaQueryList(r,n){const o=e.parse(r,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${r}"`)}}),t=new Set(o.map((e=>e.toString())));return o.flatMap((r=>{if(e.isMediaQueryInvalid(r))return[r.toString()];const o=e.cloneMediaQuery(r);o.walk((r=>{const n=r.node;if(e.isMediaFeaturePlain(n)||e.isMediaFeatureRangeNameValue(n)||e.isMediaFeatureRangeValueName(n)){const e=n.name.getName().toLowerCase();if(!a.has(e))return;transformMediaFeatureValue(n.value)}else if(e.isMediaFeatureRangeValueNameValue(n)){const e=n.name.getName().toLowerCase();if(!a.has(e))return;transformMediaFeatureValue(n.valueOne);transformMediaFeatureValue(n.valueTwo)}else;}));const i=r.toString(),u=o.toString();return u===i||t.has(u)?[i]:n?[i,u]:[u]})).join(",")}const creator=e=>{const r=Object.assign({preserve:!1},e);return{postcssPlugin:"postcss-media-queries-aspect-ratio-number-values",AtRule(e,{result:n}){if("media"!==e.name.toLowerCase())return;const o=e.params.toLowerCase();if(!(o.includes("aspect-ratio")||o.includes("min-aspect-ratio")||o.includes("max-aspect-ratio")||o.includes("device-aspect-ratio")||o.includes("min-device-aspect-ratio")||o.includes("max-device-aspect-ratio")))return;let t;try{if(t=transformMediaQueryList(e.params,r.preserve),t===e.params)return}catch(r){return void e.warn(n,`Failed to transform @media params for "${e.params}" with message: "${r.message}"`)}e.cloneBefore({params:t}),e.remove()}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/index.d.ts b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/index.d.ts new file mode 100644 index 00000000..92223f79 --- /dev/null +++ b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/index.d.ts @@ -0,0 +1,8 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-media-queries-aspect-ratio-number-values plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/index.mjs b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/index.mjs new file mode 100644 index 00000000..ceb624c5 --- /dev/null +++ b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/index.mjs @@ -0,0 +1 @@ +import{matchesRatioExactly as e,parse as r,isMediaQueryInvalid as t,cloneMediaQuery as a,isMediaFeaturePlain as n,isMediaFeatureRangeNameValue as o,isMediaFeatureRangeValueName as i,isMediaFeatureRangeValueNameValue as u}from"@csstools/media-query-list-parser";import{isTokenNode as s,isFunctionNode as l,TokenNode as c,FunctionNode as m,SimpleBlockNode as v,WhitespaceNode as d}from"@csstools/css-parser-algorithms";import{TokenType as p,NumberType as f}from"@csstools/css-tokenizer";const g=1e5,w=2147483647;function transformMediaFeatureValue(r){if(Array.isArray(r.value)&&e(r.value)){const e=[];for(let t=0;t<r.value.length;t++){const a=r.value[t];s(a)&&a.value[0]===p.Number?e.push(a):l(a)&&"calc"===a.getName().toLowerCase()&&e.push(a)}if(2!==e.length)return;const t=e[0],a=r.value.indexOf(t),n=e[1],o=r.value.indexOf(n);if(s(n)&&n.value[0]===p.Number&&0===n.value[4].value)return r.value.splice(a,1,new c([p.Number,w.toString(),-1,-1,{value:w,type:f.Integer}])),void r.value.splice(o,1,new c([p.Number,"1",-1,-1,{value:1,type:f.Integer}]));if(s(t)&&t.value[0]===p.Number&&t.value[4].type===f.Integer&&s(n)&&n.value[0]===p.Number&&n.value[4].type===f.Integer)return;let i=null,u=null;if(l(t)&&"calc"===t.getName().toLowerCase()){if(t.toString().includes(g.toString()))return;i=modifyCalc(t)}if(l(n)&&"calc"===n.getName().toLowerCase()){if(n.toString().includes(g.toString()))return;u=modifyCalc(n)}if(s(t)&&t.value[0]===p.Number&&s(n)&&n.value[0]===p.Number){const e=t.value,r=n.value,a=Math.round(e[4].value*g),o=Math.round(r[4].value*g),s=greatestCommonDivisor(a,o);i=new c([p.Number,Math.round(a/s).toString(),-1,-1,{value:Math.round(a/s),type:f.Integer}]),u=new c([p.Number,Math.round(o/s).toString(),-1,-1,{value:Math.round(o/s),type:f.Integer}])}else{if(s(t)&&t.value[0]===p.Number){const e=t.value;i=new c([p.Number,Math.round(e[4].value*g).toString(),-1,-1,{value:Math.round(e[4].value*g),type:f.Integer}])}if(s(n)&&n.value[0]===p.Number){const e=n.value;u=new c([p.Number,Math.round(e[4].value*g).toString(),-1,-1,{value:Math.round(e[4].value*g),type:f.Integer}])}}return i&&u?(r.value.splice(a,1,i),void r.value.splice(o,1,u)):void 0}const t=Array.isArray(r.value)?r.value:[r.value];for(let e=0;e<t.length;e++){const a=t[e];if(s(a)){const n=a.value;if(n[0]!==p.Number)return;if(n[4].type===f.Integer)return t.splice(e+1,0,new c([p.Delim,"/",-1,-1,{value:"/"}]),new c([p.Number,"1",-1,-1,{value:1,type:f.Integer}])),void(r.value=t);if(n[4].type===f.Number){const a=Math.round(n[4].value*g),o=greatestCommonDivisor(a,g);return t.splice(e,1,new c([p.Number,Math.round(a/o).toString(),-1,-1,{value:Math.round(a/o),type:f.Integer}]),new c([p.Delim,"/",-1,-1,{value:"/"}]),new c([p.Number,Math.round(g/o).toString(),-1,-1,{value:Math.round(g/o),type:f.Integer}])),void(r.value=t)}return}if(l(a)&&"calc"===a.getName().toLowerCase())return t.splice(e,1,modifyCalc(a),new c([p.Delim,"/",-1,-1,{value:"/"}]),new c([p.Number,g.toString(),-1,-1,{value:g,type:f.Integer}])),void(r.value=t)}}function modifyCalc(e){return new m([p.Function,"calc(",-1,-1,{value:"calc("}],[p.CloseParen,")",-1,-1,void 0],[new v([p.OpenParen,"(",-1,-1,void 0],[p.CloseParen,")",-1,-1,void 0],e.value),new d([[p.Whitespace," ",-1,-1,void 0]]),new c([p.Delim,"*",-1,-1,{value:"*"}]),new d([[p.Whitespace," ",-1,-1,void 0]]),new c([p.Number,g.toString(),-1,-1,{value:g,type:f.Integer}])])}function greatestCommonDivisor(e,r){if(Number.isNaN(e)||Number.isNaN(r))throw new Error("Unexpected 'NaN' when calculating the greatest common divisor.");if(!Number.isFinite(e)||!Number.isFinite(r))throw new Error("Unexpected 'Infinite' value when calculating the greatest common divisor.");for(r>e&&([e,r]=[r,e]);;){if(0==r)return e;if(0==(e%=r))return r;r%=e}}const N=new Set(["aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio"]);function transformMediaQueryList(e,s){const l=r(e,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${e}"`)}}),c=new Set(l.map((e=>e.toString())));return l.flatMap((e=>{if(t(e))return[e.toString()];const r=a(e);r.walk((e=>{const r=e.node;if(n(r)||o(r)||i(r)){const e=r.name.getName().toLowerCase();if(!N.has(e))return;transformMediaFeatureValue(r.value)}else if(u(r)){const e=r.name.getName().toLowerCase();if(!N.has(e))return;transformMediaFeatureValue(r.valueOne);transformMediaFeatureValue(r.valueTwo)}else;}));const l=e.toString(),m=r.toString();return m===l||c.has(m)?[l]:s?[l,m]:[m]})).join(",")}const creator=e=>{const r=Object.assign({preserve:!1},e);return{postcssPlugin:"postcss-media-queries-aspect-ratio-number-values",AtRule(e,{result:t}){if("media"!==e.name.toLowerCase())return;const a=e.params.toLowerCase();if(!(a.includes("aspect-ratio")||a.includes("min-aspect-ratio")||a.includes("max-aspect-ratio")||a.includes("device-aspect-ratio")||a.includes("min-device-aspect-ratio")||a.includes("max-device-aspect-ratio")))return;let n;try{if(n=transformMediaQueryList(e.params,r.preserve),n===e.params)return}catch(r){return void e.warn(t,`Failed to transform @media params for "${e.params}" with message: "${r.message}"`)}e.cloneBefore({params:n}),e.remove()}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/transform-media-feature-value.d.ts b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/transform-media-feature-value.d.ts new file mode 100644 index 00000000..1808b946 --- /dev/null +++ b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/transform-media-feature-value.d.ts @@ -0,0 +1,2 @@ +import { MediaFeatureValue } from '@csstools/media-query-list-parser'; +export declare function transformMediaFeatureValue(value: MediaFeatureValue): void; diff --git a/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/transform-media-query-list.d.ts b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/transform-media-query-list.d.ts new file mode 100644 index 00000000..a2fcb6a9 --- /dev/null +++ b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/dist/transform-media-query-list.d.ts @@ -0,0 +1 @@ +export declare function transformMediaQueryList(params: string, preserve: boolean): string; diff --git a/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/package.json b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/package.json new file mode 100644 index 00000000..b7c3b033 --- /dev/null +++ b/node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values/package.json @@ -0,0 +1,87 @@ +{ + "name": "@csstools/postcss-media-queries-aspect-ratio-number-values", + "description": "Use number values in aspect-ratio media queries.", + "version": "2.0.3", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1", + "@csstools/media-query-list-parser": "^2.1.5" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-media-queries-aspect-ratio-number-values#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-media-queries-aspect-ratio-number-values" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "aspect-ratio", + "media queries", + "postcss-plugin" + ], + "csstools": { + "cssdbId": "media-queries-aspect-ratio-number-values", + "exportName": "postcssMediaQueriesAspectRatioNumberValues", + "humanReadableName": "PostCSS Media Queries Aspect-Ratio Number Values", + "specUrl": "https://www.w3.org/TR/mediaqueries-4/#aspect-ratio" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-nested-calc/CHANGELOG.md b/node_modules/@csstools/postcss-nested-calc/CHANGELOG.md new file mode 100644 index 00000000..fc9be8f1 --- /dev/null +++ b/node_modules/@csstools/postcss-nested-calc/CHANGELOG.md @@ -0,0 +1,31 @@ +# Changes to PostCSS Nested Calc + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) + +### 2.0.2 + +_February 9, 2023_ + +- Reduce the amount of duplicate fallback CSS. + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). + +### 1.0.0 + +_August 15, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-nested-calc/LICENSE.md b/node_modules/@csstools/postcss-nested-calc/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-nested-calc/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-nested-calc/README.md b/node_modules/@csstools/postcss-nested-calc/README.md new file mode 100644 index 00000000..fb7beee0 --- /dev/null +++ b/node_modules/@csstools/postcss-nested-calc/README.md @@ -0,0 +1,80 @@ +# PostCSS Nested Calc [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-nested-calc.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/nested-calc.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +[PostCSS Nested Calc] lets you use nested `calc()` expressions following the [CSS Values and Units 4 specification]. + +```pcss +.example { + order: calc(1 + calc(2 * 2)); +} + +/* becomes */ + +.example { + order: calc(1 + (2 * 2)); + order: calc(1 + calc(2 * 2)); +} +``` + +## Usage + +Add [PostCSS Nested Calc] to your project: + +```bash +npm install postcss @csstools/postcss-nested-calc --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssNestedCalc = require('@csstools/postcss-nested-calc'); + +postcss([ + postcssNestedCalc(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Nested Calc] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default the original values are preserved. + +```js +postcssNestedCalc({ preserve: false }) +``` + +```pcss +.example { + order: calc(1 + calc(2 * 2)); +} + +/* becomes */ + +.example { + order: calc(1 + (2 * 2)); +} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#nested-calc +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-nested-calc + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Nested Calc]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nested-calc +[CSS Values and Units 4 specification]: https://www.w3.org/TR/css-values/#calc-func diff --git a/node_modules/@csstools/postcss-nested-calc/dist/has-fallback-decl.d.ts b/node_modules/@csstools/postcss-nested-calc/dist/has-fallback-decl.d.ts new file mode 100644 index 00000000..d7ae8d89 --- /dev/null +++ b/node_modules/@csstools/postcss-nested-calc/dist/has-fallback-decl.d.ts @@ -0,0 +1,2 @@ +import type { Declaration } from 'postcss'; +export declare function hasFallback(node: Declaration): boolean; diff --git a/node_modules/@csstools/postcss-nested-calc/dist/index.cjs b/node_modules/@csstools/postcss-nested-calc/dist/index.cjs new file mode 100644 index 00000000..a52f3cd7 --- /dev/null +++ b/node_modules/@csstools/postcss-nested-calc/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("postcss-value-parser");const t=/calc\(/gim;function hasFallback(e){const t=e.parent;if(!t)return!1;const r=t.index(e);for(let a=0;a<r;a++){const r=t.nodes[a];if("decl"===r.type&&r.prop.toLowerCase()===e.prop.toLowerCase())return!0}return!1}const creator=r=>{const a=Object.assign({preserve:!0},r);return{postcssPlugin:"postcss-nested-calc",Declaration(r,{result:n}){if((r.value.match(t)||[]).length<2)return;if(r.variable)return;if(hasFallback(r))return;const o=r.value;let s;try{s=e(o)}catch(e){return void r.warn(n,`Failed to parse value '${o}'. Leaving the original value intact.`)}if(void 0===s)return;e.walk(s.nodes,(t=>{t.type&&"function"===t.type&&"calc"===t.value.toLowerCase()&&e.walk(t.nodes,(e=>{if(e.type&&"function"===e.type)return"calc"===e.value.toLowerCase()&&void(e.value="")}))}),!0);const c=String(s);c!==o&&(r.cloneBefore({value:c}),a.preserve||r.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-nested-calc/dist/index.d.ts b/node_modules/@csstools/postcss-nested-calc/dist/index.d.ts new file mode 100644 index 00000000..139448be --- /dev/null +++ b/node_modules/@csstools/postcss-nested-calc/dist/index.d.ts @@ -0,0 +1,8 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-nested-calc plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: true */ + preserve?: boolean; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-nested-calc/dist/index.mjs b/node_modules/@csstools/postcss-nested-calc/dist/index.mjs new file mode 100644 index 00000000..41363381 --- /dev/null +++ b/node_modules/@csstools/postcss-nested-calc/dist/index.mjs @@ -0,0 +1 @@ +import e from"postcss-value-parser";const t=/calc\(/gim;function hasFallback(e){const t=e.parent;if(!t)return!1;const r=t.index(e);for(let a=0;a<r;a++){const r=t.nodes[a];if("decl"===r.type&&r.prop.toLowerCase()===e.prop.toLowerCase())return!0}return!1}const creator=r=>{const a=Object.assign({preserve:!0},r);return{postcssPlugin:"postcss-nested-calc",Declaration(r,{result:o}){if((r.value.match(t)||[]).length<2)return;if(r.variable)return;if(hasFallback(r))return;const n=r.value;let s;try{s=e(n)}catch(e){return void r.warn(o,`Failed to parse value '${n}'. Leaving the original value intact.`)}if(void 0===s)return;e.walk(s.nodes,(t=>{t.type&&"function"===t.type&&"calc"===t.value.toLowerCase()&&e.walk(t.nodes,(e=>{if(e.type&&"function"===e.type)return"calc"===e.value.toLowerCase()&&void(e.value="")}))}),!0);const c=String(s);c!==n&&(r.cloneBefore({value:c}),a.preserve||r.remove())}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-nested-calc/dist/occurrences.d.ts b/node_modules/@csstools/postcss-nested-calc/dist/occurrences.d.ts new file mode 100644 index 00000000..61f8b784 --- /dev/null +++ b/node_modules/@csstools/postcss-nested-calc/dist/occurrences.d.ts @@ -0,0 +1 @@ +export declare function numberOfCalcOccurrences(value: string): number; diff --git a/node_modules/@csstools/postcss-nested-calc/package.json b/node_modules/@csstools/postcss-nested-calc/package.json new file mode 100644 index 00000000..3f36e0b1 --- /dev/null +++ b/node_modules/@csstools/postcss-nested-calc/package.json @@ -0,0 +1,87 @@ +{ + "name": "@csstools/postcss-nested-calc", + "description": "Use nested calc() expressions in CSS", + "version": "3.0.0", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nested-calc#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-nested-calc" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "calc", + "css", + "math", + "nested", + "postcss-plugin" + ], + "csstools": { + "cssdbId": "nested-calc", + "exportName": "postcssNestedCalc", + "humanReadableName": "PostCSS Nested Calc", + "specUrl": "https://www.w3.org/TR/css-values/#calc-func" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-normalize-display-values/CHANGELOG.md b/node_modules/@csstools/postcss-normalize-display-values/CHANGELOG.md new file mode 100644 index 00000000..a1c02e84 --- /dev/null +++ b/node_modules/@csstools/postcss-normalize-display-values/CHANGELOG.md @@ -0,0 +1,37 @@ +# Changes to PostCSS Normalize Display Values + +### 3.0.1 + +_September 18, 2023_ + +- Improve performance + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). + +### 1.0.1 + +_July 8, 2022_ + +- Fix case insensitive matching. + +### 1.0.0 + +_January 25, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-normalize-display-values/LICENSE.md b/node_modules/@csstools/postcss-normalize-display-values/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-normalize-display-values/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-normalize-display-values/README.md b/node_modules/@csstools/postcss-normalize-display-values/README.md new file mode 100644 index 00000000..5af8725b --- /dev/null +++ b/node_modules/@csstools/postcss-normalize-display-values/README.md @@ -0,0 +1,86 @@ +# PostCSS Normalize Display Values [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-normalize-display-values.svg" height="20">][npm-url] +[<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/display-two-values.svg" height="20">][css-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +[PostCSS Normalize Display Values] lets you specify definition of outer and inner displays types for an element. + +```pcss +.element { + display: inline flow-root; +} + +/* becomes */ + +.element { + display: inline-block; + display: inline flow-root; +} +``` + +_See prior work by [cssnano](https://github.com/cssnano) here [postcss-normalize-display-values](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-display-values) +To ensure long term maintenance and to provide the needed features this plugin was recreated based on cssnano's work._ + +## Usage + +Add [PostCSS Normalize Display Values] to your project: + +```bash +npm install postcss @csstools/postcss-normalize-display-values --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssNormalizeDisplayValues = require('@csstools/postcss-normalize-display-values'); + +postcss([ + postcssNormalizeDisplayValues(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Normalize Display Values] runs in all Node environments, with special +instructions for: + +| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) | +| --- | --- | --- | --- | --- | + +## Options + +### preserve + +The `preserve` option determines whether the original source +is preserved. By default, it is preserved. + +```js +postcssNormalizeDisplayValues({ preserve: false }) +``` + +```pcss +.element { + display: inline flow-root; +} + +/* becomes */ + +.element { + display: inline-block; +} +``` + +[postcss]: https://github.com/postcss/postcss + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#display-two-values +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-normalize-display-values + +[CSS Fonts]: https://www.w3.org/TR/css-display-3/#the-display-properties +[Gulp PostCSS]: https://github.com/postcss/gulp-postcss +[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Loader]: https://github.com/postcss/postcss-loader +[PostCSS Normalize Display Values]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-normalize-display-values diff --git a/node_modules/@csstools/postcss-normalize-display-values/dist/index.cjs b/node_modules/@csstools/postcss-normalize-display-values/dist/index.cjs new file mode 100644 index 00000000..cdd54eb4 --- /dev/null +++ b/node_modules/@csstools/postcss-normalize-display-values/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("postcss-value-parser"),l=new Map([["block,flow","block"],["block,flow-root","flow-root"],["inline,flow","inline"],["inline,flow-root","inline-block"],["run-in,flow","run-in"],["list-item,block,flow","list-item"],["inline,flow,list-item","inline list-item"],["block,flex","flex"],["inline,flex","inline-flex"],["block,grid","grid"],["inline,grid","inline-grid"],["inline,ruby","ruby"],["block,table","table"],["inline,table","inline-table"],["table-cell,flow","table-cell"],["table-caption,flow","table-caption"],["ruby-base,flow","ruby-base"],["ruby-text,flow","ruby-text"]]);function transform(n){const{nodes:t}=e(n);if(1===t.length)return n;const o=t.filter((e=>"word"===e.type)).map((e=>e.value.toLowerCase()));if(o.length<=1)return n;const i=l.get(o.join(","));return i||n}const n=/^display$/i,creator=e=>{const l=!("preserve"in Object(e))||Boolean(null==e?void 0:e.preserve);return{postcssPlugin:"postcss-normalize-display-values",prepare(){const e=new Map;return{Declaration(t){if(!n.test(t.prop))return;const o=t.value;if(!o)return;if(e.has(o))return void(t.value!==e.get(o)&&(t.cloneBefore({value:e.get(o)}),l||t.remove()));const i=transform(o);e.set(o,i),t.value!==i&&(t.cloneBefore({value:i}),l||t.remove())}}}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-normalize-display-values/dist/index.d.ts b/node_modules/@csstools/postcss-normalize-display-values/dist/index.d.ts new file mode 100644 index 00000000..b0606a31 --- /dev/null +++ b/node_modules/@csstools/postcss-normalize-display-values/dist/index.d.ts @@ -0,0 +1,8 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-normalize-display-values plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: true */ + preserve?: boolean; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-normalize-display-values/dist/index.mjs b/node_modules/@csstools/postcss-normalize-display-values/dist/index.mjs new file mode 100644 index 00000000..bda81c6d --- /dev/null +++ b/node_modules/@csstools/postcss-normalize-display-values/dist/index.mjs @@ -0,0 +1 @@ +import e from"postcss-value-parser";var l=new Map([["block,flow","block"],["block,flow-root","flow-root"],["inline,flow","inline"],["inline,flow-root","inline-block"],["run-in,flow","run-in"],["list-item,block,flow","list-item"],["inline,flow,list-item","inline list-item"],["block,flex","flex"],["inline,flex","inline-flex"],["block,grid","grid"],["inline,grid","inline-grid"],["inline,ruby","ruby"],["block,table","table"],["inline,table","inline-table"],["table-cell,flow","table-cell"],["table-caption,flow","table-caption"],["ruby-base,flow","ruby-base"],["ruby-text,flow","ruby-text"]]);function transform(n){const{nodes:o}=e(n);if(1===o.length)return n;const t=o.filter((e=>"word"===e.type)).map((e=>e.value.toLowerCase()));if(t.length<=1)return n;const i=l.get(t.join(","));return i||n}const n=/^display$/i,creator=e=>{const l=!("preserve"in Object(e))||Boolean(null==e?void 0:e.preserve);return{postcssPlugin:"postcss-normalize-display-values",prepare(){const e=new Map;return{Declaration(o){if(!n.test(o.prop))return;const t=o.value;if(!t)return;if(e.has(t))return void(o.value!==e.get(t)&&(o.cloneBefore({value:e.get(t)}),l||o.remove()));const i=transform(t);e.set(t,i),o.value!==i&&(o.cloneBefore({value:i}),l||o.remove())}}}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-normalize-display-values/dist/mappings.d.ts b/node_modules/@csstools/postcss-normalize-display-values/dist/mappings.d.ts new file mode 100644 index 00000000..7ca13f69 --- /dev/null +++ b/node_modules/@csstools/postcss-normalize-display-values/dist/mappings.d.ts @@ -0,0 +1,5 @@ +/** + * Specification: https://www.w3.org/TR/css-display-3/#the-display-properties + */ +declare const _default: Map<string, string>; +export default _default; diff --git a/node_modules/@csstools/postcss-normalize-display-values/package.json b/node_modules/@csstools/postcss-normalize-display-values/package.json new file mode 100644 index 00000000..d2fa0fad --- /dev/null +++ b/node_modules/@csstools/postcss-normalize-display-values/package.json @@ -0,0 +1,89 @@ +{ + "name": "@csstools/postcss-normalize-display-values", + "description": "Use two values display syntax for inner and outer display types.", + "version": "3.0.1", + "author": "Jonathan Neal <jonathantneal@hotmail.com>", + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-normalize-display-values" + }, + "keywords": [ + "block", + "css", + "display", + "flex", + "flow", + "flow-root", + "grid", + "inline", + "inline-block", + "inline-flex", + "inline-grid", + "inline-table", + "list-item", + "postcss-plugin", + "ruby", + "ruby-base", + "ruby-text", + "run-in", + "table", + "table-caption", + "table-cell" + ], + "csstools": { + "exportName": "postcssNormalizeDisplayValues", + "humanReadableName": "PostCSS Normalize Display Values" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-oklab-function/CHANGELOG.md b/node_modules/@csstools/postcss-oklab-function/CHANGELOG.md new file mode 100644 index 00000000..ba174ce8 --- /dev/null +++ b/node_modules/@csstools/postcss-oklab-function/CHANGELOG.md @@ -0,0 +1,165 @@ +# Changes to PostCSS OKLab Function + +### 3.0.7 + +_October 9, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.4.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#140) (minor) +- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.2`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#302) (patch) + +### 3.0.6 + +_October 2, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#133) (patch) + +### 3.0.5 + +_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-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#132) (patch) + +### 3.0.4 + +_September 18, 2023_ + +- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.1`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#301) (patch) + +### 3.0.3 + +_September 2, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#131) (patch) + +### 3.0.2 + +_August 28, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#130) (minor) + +### 3.0.1 + +_July 24, 2023_ + +- 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) + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) +- 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/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#300) (major) +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.2.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#122) (patch) + +### 2.2.3 + +_June 1, 2023_ + +- Updated `@csstools/postcss-progressive-custom-properties` to `2.3.0` (minor) + + +### 2.2.2 + +_May 19, 2023_ + +- Ignore relative color syntax +- Updated `@csstools/postcss-progressive-custom-properties` to `2.2.0` (minor) +- Updated `@csstools/css-color-parser` to `1.2.0` (minor) + + + +### 2.2.1 + +_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-color-parser` to `1.1.2` (patch) + +### 2.2.0 + +_March 25, 2023_ + +- Add `@csstools/css-color-parser` dependency for all color value transformations. +- Add support for `calc` expressions in color components. +- Skip `color(display-p3 0 0 0)` fallbacks when the color is already in the `srgb` gamut. + +### 2.1.0 + +_February 6, 2023_ + +- Add: `@csstools/color-helpers` dependency for all color value transformations. + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). + +### 1.1.1 + +_July 8, 2022_ + +- Fix case insensitive matching. + +### 1.1.0 + +_April 4, 2022_ + +- Allow percentage and number units in more color components. + +```css +.percentages { + color-1: oklab(40% 0.309% 0.975%); + color-2: oklch(40% 31.718385875% 34.568626); + + /* becomes */ + + color-1: rgb(73, 71, 69); + color-1: color(display-p3 0.28515 0.27983 0.27246); + color-2: rgb(126, 37, 15); + color-2: color(display-p3 0.45368 0.16978 0.09411); +} + +.numbers { + color-1: oklab(0.40 0.001236 0.0039); + color-2: oklch(0.40 0.1268735435 34.568626); + + /* becomes */ + + color-1: rgb(73, 71, 69); + color-1: color(display-p3 0.28515 0.27983 0.27246); + color-2: rgb(126, 37, 15); + color-2: color(display-p3 0.45368 0.16978 0.09411); +} +``` + +### 1.0.2 + +_March 8, 2022_ + +- Fix gamut mapping giving overly unsaturated colors. +- Implement powerless color components in gamut mapping. + +### 1.0.1 + +_February 12, 2022_ + +- Updated `@csstools/postcss-progressive-custom-properties` to `1.1.0`. + +### 1.0.0 + +_February 11, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-oklab-function/LICENSE.md b/node_modules/@csstools/postcss-oklab-function/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-oklab-function/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-oklab-function/README.md b/node_modules/@csstools/postcss-oklab-function/README.md new file mode 100644 index 00000000..6543b063 --- /dev/null +++ b/node_modules/@csstools/postcss-oklab-function/README.md @@ -0,0 +1,169 @@ +# PostCSS OKLab Function [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-oklab-function.svg" height="20">][npm-url] +[<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/oklab-function.svg" height="20">][css-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +[PostCSS OKLab Function] lets you use `oklab` and `oklch` color functions in +CSS, following the [CSS Color] specification. + +```pcss +.test-oklab { + color: oklab(40% 0.001236 0.0039); +} + +.test-oklch { + color: oklch(40% 0.268735435 34.568626); +} + +/* becomes */ + +.test-oklab { + color: rgb(73, 71, 69); + color: color(display-p3 0.28515 0.27983 0.27246); +} + +.test-oklch { + color: rgb(131, 28, 0); + color: color(display-p3 0.49163 0.11178 0.00000); +} +``` + +## Usage + +Add [PostCSS OKLab Function] to your project: + +```bash +npm install postcss @csstools/postcss-oklab-function --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssOKLabFunction = require('@csstools/postcss-oklab-function'); + +postcss([ + postcssOKLabFunction(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS OKLab Function] runs in all Node environments, with special +instructions for: + +| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) | +| --- | --- | --- | --- | --- | + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is not preserved. + +```js +postcssOKLabFunction({ preserve: true }) +``` + +```pcss +.test-oklab { + color: oklab(40% 0.001236 0.0039); +} + +.test-oklch { + color: oklch(40% 0.268735435 34.568626); +} + +/* becomes */ + +.test-oklab { + color: rgb(73, 71, 69); + color: color(display-p3 0.28515 0.27983 0.27246); + color: oklab(40% 0.001236 0.0039); +} + +.test-oklch { + color: rgb(131, 28, 0); + color: color(display-p3 0.49163 0.11178 0.00000); + color: oklch(40% 0.268735435 34.568626); +} +``` + +### enableProgressiveCustomProperties + +The `enableProgressiveCustomProperties` option determines whether the original notation +is wrapped with `@supports` when used in Custom Properties. By default, it is enabled. + +⚠️ We only recommend disabling this when you set `preserve` to `false` or if you bring your own fix for Custom Properties. See what the plugin does in its [README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties#readme). + +```js +postcssOKLabFunction({ enableProgressiveCustomProperties: false }) +``` + +```pcss +:root { + --firebrick: oklab(40% 0.234 0.39); +} + +/* becomes */ + +:root { + --firebrick: rgb(133, 0, 67); /* will never be used, not even in older browser */ + --firebrick: color(display-p3 0.49890 0.00000 0.25954); /* will never be used, not even in older browser */ + --firebrick: oklab(40% 0.234 0.39); +} +``` + +### subFeatures + +#### displayP3 + +The `subFeatures.displayP3` option determines if `color(display-p3 ...)` is used as a fallback.<br> +By default, it is enabled. + +`display-p3` can display wider gamut colors than `rgb` on some devices. + +```js +postcssOKLabFunction({ + subFeatures: { + displayP3: false + } +}) +``` + +```pcss +.test-oklab { + color: oklab(40% 0.001236 0.0039); +} + +.test-oklch { + color: oklch(40% 0.268735435 34.568626); +} + +/* becomes */ + +.test-oklab { + color: rgb(73, 71, 69); +} + +.test-oklch { + color: rgb(131, 28, 0); +} +``` + +## Copyright : color conversions + +This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/tree/main/css-color-4. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#oklab-function +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-oklab-function + +[CSS Color]: https://www.w3.org/TR/css-color-4/#specifying-oklab-oklch +[Gulp PostCSS]: https://github.com/postcss/gulp-postcss +[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Loader]: https://github.com/postcss/postcss-loader +[PostCSS OKLab Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-oklab-function diff --git a/node_modules/@csstools/postcss-oklab-function/dist/has-fallback-decl.d.ts b/node_modules/@csstools/postcss-oklab-function/dist/has-fallback-decl.d.ts new file mode 100644 index 00000000..d7ae8d89 --- /dev/null +++ b/node_modules/@csstools/postcss-oklab-function/dist/has-fallback-decl.d.ts @@ -0,0 +1,2 @@ +import type { Declaration } from 'postcss'; +export declare function hasFallback(node: Declaration): boolean; diff --git a/node_modules/@csstools/postcss-oklab-function/dist/has-supports-at-rule-ancestor.d.ts b/node_modules/@csstools/postcss-oklab-function/dist/has-supports-at-rule-ancestor.d.ts new file mode 100644 index 00000000..a46009ec --- /dev/null +++ b/node_modules/@csstools/postcss-oklab-function/dist/has-supports-at-rule-ancestor.d.ts @@ -0,0 +1,2 @@ +import type { Node } from 'postcss'; +export declare function hasSupportsAtRuleAncestor(node: Node): boolean; diff --git a/node_modules/@csstools/postcss-oklab-function/dist/index.cjs b/node_modules/@csstools/postcss-oklab-function/dist/index.cjs new file mode 100644 index 00000000..161dff7e --- /dev/null +++ b/node_modules/@csstools/postcss-oklab-function/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),s=require("@csstools/css-tokenizer"),r=require("@csstools/css-color-parser"),t=require("@csstools/css-parser-algorithms");function hasFallback(e){const s=e.parent;if(!s)return!1;const r=e.prop.toLowerCase(),t=s.index(e);for(let e=0;e<t;e++){const t=s.nodes[e];if("decl"===t.type&&t.prop.toLowerCase()===r)return!0}return!1}function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name.toLowerCase()){if(-1!==s.params.toLowerCase().indexOf("oklab("))return!0;if(-1!==s.params.toLowerCase().indexOf("oklch("))return!0}s=s.parent}else s=s.parent;return!1}const o=/(oklab|oklch)\(/i,a=/^(oklab|oklch)$/i,basePlugin=e=>({postcssPlugin:"postcss-oklab-function",Declaration:n=>{const l=n.value;if(!o.test(l))return;if(hasFallback(n))return;if(hasSupportsAtRuleAncestor(n))return;const i=s.tokenize({css:l}),u=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(i),(e=>{if(t.isFunctionNode(e)&&a.test(e.getName())){const s=r.color(e);if(!s)return;if(s.syntaxFlags.has(r.SyntaxFlag.HasNoneKeywords))return;if(s.syntaxFlags.has(r.SyntaxFlag.RelativeColorSyntax))return;return r.serializeRGB(s)}})),c=t.stringify(u);if(c===l)return;let p=c;null!=e&&e.subFeatures.displayP3&&(p=t.stringify(t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(i),(e=>{if(t.isFunctionNode(e)&&a.test(e.getName())){const s=r.color(e);if(!s)return;if(s.syntaxFlags.has(r.SyntaxFlag.HasNoneKeywords))return;if(s.syntaxFlags.has(r.SyntaxFlag.RelativeColorSyntax))return;return r.colorDataFitsRGB_Gamut(s)?r.serializeRGB(s):r.serializeP3(s)}})))),n.cloneBefore({value:c}),null!=e&&e.subFeatures.displayP3&&p!==c&&n.cloneBefore({value:p}),null!=e&&e.preserve||n.remove()}});basePlugin.postcss=!0;const postcssPlugin=s=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},s);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-oklab-function",plugins:[e(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/node_modules/@csstools/postcss-oklab-function/dist/index.d.ts b/node_modules/@csstools/postcss-oklab-function/dist/index.d.ts new file mode 100644 index 00000000..aee8de5f --- /dev/null +++ b/node_modules/@csstools/postcss-oklab-function/dist/index.d.ts @@ -0,0 +1,15 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-oklab-function plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; + /** Enable "@csstools/postcss-progressive-custom-properties". default: true */ + enableProgressiveCustomProperties?: boolean; + /** Toggle sub features. default: { displayP3: true } */ + subFeatures?: { + /** Enable displayP3 fallbacks. default: true */ + displayP3?: boolean; + }; +}; +declare const postcssPlugin: PluginCreator<pluginOptions>; +export default postcssPlugin; diff --git a/node_modules/@csstools/postcss-oklab-function/dist/index.mjs b/node_modules/@csstools/postcss-oklab-function/dist/index.mjs new file mode 100644 index 00000000..8544a15e --- /dev/null +++ b/node_modules/@csstools/postcss-oklab-function/dist/index.mjs @@ -0,0 +1 @@ +import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as e}from"@csstools/css-tokenizer";import{color as r,SyntaxFlag as t,serializeRGB as o,colorDataFitsRGB_Gamut as a,serializeP3 as n}from"@csstools/css-color-parser";import{replaceComponentValues as l,parseCommaSeparatedListOfComponentValues as u,isFunctionNode as i,stringify as p}from"@csstools/css-parser-algorithms";function hasFallback(s){const e=s.parent;if(!e)return!1;const r=s.prop.toLowerCase(),t=e.index(s);for(let s=0;s<t;s++){const t=e.nodes[s];if("decl"===t.type&&t.prop.toLowerCase()===r)return!0}return!1}function hasSupportsAtRuleAncestor(s){let e=s.parent;for(;e;)if("atrule"===e.type){if("supports"===e.name.toLowerCase()){if(-1!==e.params.toLowerCase().indexOf("oklab("))return!0;if(-1!==e.params.toLowerCase().indexOf("oklch("))return!0}e=e.parent}else e=e.parent;return!1}const c=/(oklab|oklch)\(/i,f=/^(oklab|oklch)$/i,basePlugin=s=>({postcssPlugin:"postcss-oklab-function",Declaration:m=>{const b=m.value;if(!c.test(b))return;if(hasFallback(m))return;if(hasSupportsAtRuleAncestor(m))return;const g=e({css:b}),y=l(u(g),(s=>{if(i(s)&&f.test(s.getName())){const e=r(s);if(!e)return;if(e.syntaxFlags.has(t.HasNoneKeywords))return;if(e.syntaxFlags.has(t.RelativeColorSyntax))return;return o(e)}})),d=p(y);if(d===b)return;let h=d;null!=s&&s.subFeatures.displayP3&&(h=p(l(u(g),(s=>{if(i(s)&&f.test(s.getName())){const e=r(s);if(!e)return;if(e.syntaxFlags.has(t.HasNoneKeywords))return;if(e.syntaxFlags.has(t.RelativeColorSyntax))return;return a(e)?o(e):n(e)}})))),m.cloneBefore({value:d}),null!=s&&s.subFeatures.displayP3&&h!==d&&m.cloneBefore({value:h}),null!=s&&s.preserve||m.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-oklab-function",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; diff --git a/node_modules/@csstools/postcss-oklab-function/package.json b/node_modules/@csstools/postcss-oklab-function/package.json new file mode 100644 index 00000000..34b11c0e --- /dev/null +++ b/node_modules/@csstools/postcss-oklab-function/package.json @@ -0,0 +1,82 @@ +{ + "name": "@csstools/postcss-oklab-function", + "description": "Use oklab() and oklch() color functions in CSS", + "version": "3.0.7", + "author": "Jonathan Neal <jonathantneal@hotmail.com>", + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/css-color-parser": "^1.4.0", + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1", + "@csstools/postcss-progressive-custom-properties": "^3.0.2" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-oklab-function#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-oklab-function" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "color", + "css", + "design", + "display-p3", + "oklab", + "oklch", + "postcss", + "postcss-plugin", + "syntax" + ], + "csstools": { + "exportName": "postcssOKLabFunction", + "humanReadableName": "PostCSS OKLab Function" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-progressive-custom-properties/CHANGELOG.md b/node_modules/@csstools/postcss-progressive-custom-properties/CHANGELOG.md new file mode 100644 index 00000000..ad87d81d --- /dev/null +++ b/node_modules/@csstools/postcss-progressive-custom-properties/CHANGELOG.md @@ -0,0 +1,95 @@ +# Changes to PostCSS Progressive Custom Properties + +### 3.0.2 + +_October 9, 2023_ + +- Add support for css nesting +- Improve grouping of `@supports` rules +- Reduce the size of the generated `@supports` rules for values that contain `var()` + +### 3.0.1 + +_September 18, 2023_ + +- Improve performance + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) + +### 2.3.0 + +_June 1, 2023_ + +- Add support for regular properties whose values contain `var()` + +```css +.property-with-var--1 { + color: rgba(87, 107, 149, var(--opacity)); + color: rgb(87 107 149 / var(--opacity)); +} + +/* becomes */ +.property-with-var--1 { + color: rgba(87, 107, 149, var(--opacity)); +} + +@supports (color: rgb(0 0 0 / 0)) and (top: var(--f)) { + .property-with-var--1 { + color: rgb(87 107 149 / var(--opacity)); + } +} +``` + +### 2.2.0 + +_May 19, 2023_ + +- Add relative color syntax support. +- Fix false positive matches for `rgb` and `hsl` modern function notations. + +### 2.1.1 + +_March 25, 2023_ + +- Smaller `@supports` check for `color-mix`. + +### 2.1.0 + +_February 2, 2023_ + +- Group support rules with the same params to reduce the output size. + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). + +## 1.3.0 (March 7, 2022) + +- Add matching rules for `color-mix` +- Fix matching rules for gradient functions +- Reduce matchers size + +## 1.2.0 (February 15, 2022) + +- More matching rules for [double position gradients](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-double-position-gradients#readme). + +## 1.1.0 (February 12, 2022) + +- No longer uses custom properties in `@supports` rules. +- Implement AST matching for values and units and generate minimal `@supports` for select features. + +## 1.0.0 (February 6, 2022) + +Initial release diff --git a/node_modules/@csstools/postcss-progressive-custom-properties/LICENSE.md b/node_modules/@csstools/postcss-progressive-custom-properties/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-progressive-custom-properties/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-progressive-custom-properties/README.md b/node_modules/@csstools/postcss-progressive-custom-properties/README.md new file mode 100644 index 00000000..1e59a3e4 --- /dev/null +++ b/node_modules/@csstools/postcss-progressive-custom-properties/README.md @@ -0,0 +1,121 @@ +# PostCSS Progressive Custom Properties [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" width="90" height="90" align="right">][postcss] + +[![NPM Version][npm-img]][npm-url] +[![Build Status][cli-img]][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +[PostCSS Progressive Custom Properties] is a utility plugin to correctly declare Custom Property fallbacks and enhancements. + +⚠️ It is not intended to be used directly by stylesheet authors. +Meant to be included in other PostCSS plugins that provide CSS value transforms as fallbacks. + +[Custom Properties are not discarded like regular declarations when invalid.](https://www.w3.org/TR/css-variables-1/#invalid-variables) +This makes it tricky to provide fallback values for older browsers. + +The solution is to wrap Custom Property declarations in an `@supports` rule. + +```pcss +:root { + /* fallback */ + --a-color: red; + /* progressive enhancement */ + --a-color: oklch(40% 0.234 0.39 / var(--opacity-50)); +} + +/* becomes */ + +:root { + --a-color: red; +} + +@supports (color: oklch(0% 0 0)) { + :root { + --a-color: oklch(40% 0.234 0.39 / var(--opacity-50)); + } +} +``` + +## Ignored values + +`initial` and `<white space>` are ignored. + +```pcss +.initial { + --prop-1: red; + --prop-1: initial; +} + +.white-space { + --prop-1: red; + --prop-1:; + + --prop-2: red; + --prop-2: ; + + --prop-3: red; + --prop-3: ; +} + +/* remains */ + +.initial { + --prop-1: red; + --prop-1: initial; +} + +.white-space { + --prop-1: red; + --prop-1:; + + --prop-2: red; + --prop-2: ; + + --prop-3: red; + --prop-3: ; +} +``` + +## Usage + +Add [PostCSS Progressive Custom Properties] to your project: + +```bash +npm install @csstools/postcss-progressive-custom-properties --save-dev +``` + +Use [PostCSS Progressive Custom Properties] as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssCustomProperties = require('@csstools/postcss-progressive-custom-properties'); + +postcss([ + postcssProgressiveCustomProperties() +]).process(YOUR_CSS /*, processOptions */); +``` + +## @supports + +This plugin wraps Custom Property override declarations in an `@supports` rule. +With PostCSS 8 this trigger declaration visitors to run again. + +Make sure your plugin detects and ignores values inside relevant `@supports` rules. + +## Reading list + +- https://moderncss.dev/how-custom-property-values-are-computed/ + +[PostCSS Progressive Custom Properties] runs in all Node environments, with special instructions for: + +| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) | +| --- | --- | --- | --- | --- | + + +[cli-img]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[discord]: https://discord.gg/bUadyRwkJS +[npm-img]: https://img.shields.io/npm/v/@csstools/postcss-progressive-custom-properties.svg +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-progressive-custom-properties + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Progressive Custom Properties]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties diff --git a/node_modules/@csstools/postcss-progressive-custom-properties/dist/conditions-from-values.d.ts b/node_modules/@csstools/postcss-progressive-custom-properties/dist/conditions-from-values.d.ts new file mode 100644 index 00000000..250b5e91 --- /dev/null +++ b/node_modules/@csstools/postcss-progressive-custom-properties/dist/conditions-from-values.d.ts @@ -0,0 +1,3 @@ +export declare function conditionsFromValue(value: string, mustContainVar?: boolean): { + support: Array<string>; +}; diff --git a/node_modules/@csstools/postcss-progressive-custom-properties/dist/custom/double-position-gradients.d.ts b/node_modules/@csstools/postcss-progressive-custom-properties/dist/custom/double-position-gradients.d.ts new file mode 100644 index 00000000..6ca404c9 --- /dev/null +++ b/node_modules/@csstools/postcss-progressive-custom-properties/dist/custom/double-position-gradients.d.ts @@ -0,0 +1,2 @@ +import type { Node } from 'postcss-value-parser'; +export declare function doublePositionGradients(node: Node): Array<string>; diff --git a/node_modules/@csstools/postcss-progressive-custom-properties/dist/index.cjs b/node_modules/@csstools/postcss-progressive-custom-properties/dist/index.cjs new file mode 100644 index 00000000..35a10519 --- /dev/null +++ b/node_modules/@csstools/postcss-progressive-custom-properties/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("postcss-value-parser");const a=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"];function doublePositionGradients(e){const r=[],p=e.value.toLowerCase();if("function"===e.type&&("conic-gradient"===p||"linear-gradient"===p||"radial-gradient"===p||"repeating-conic-gradient"===p||"repeating-linear-gradient"===p||"repeating-radial-gradient"===p)){let p=0,t=!1,i=!1;e:for(let o=0;o<e.nodes.length;o++){const s=e.nodes[o];if("word"===s.type&&a.includes(s.value.toLowerCase())&&(t=!0),"div"!==s.type||","!==s.value.trim())if("word"!==s.type||"in"!==s.value.toLowerCase()){if("word"!==s.type&&"function"!==s.type||p++,i)switch(e.value.toLowerCase()){case"conic-gradient":r.push("(background: conic-gradient(in oklch, red 0deg, red 0deg 1deg, red 2deg))");break e;case"linear-gradient":r.push("(background: linear-gradient(in oklch, red 0%, red 0% 1%, red 2%))");break e;case"radial-gradient":r.push("(background: radial-gradient(in oklch, red, red 1px 2px, red 3px))");break e;case"repeating-conic-gradient":r.push("(background: repeating-conic-gradient(in oklch from 0deg, red 0deg, red 0deg 1deg, red 2deg))");break e;case"repeating-linear-gradient":r.push("(background: repeating-linear-gradient(in oklch, red 0%, red 0% 1%, red 2%))");break e;case"repeating-radial-gradient":r.push("(background: repeating-radial-gradient(in oklch, red, red 1px 2px, red 3px))");break e}if(!t&&3===p)switch(e.value.toLowerCase()){case"conic-gradient":r.push("(background: conic-gradient(red 0deg, red 0deg 1deg, red 2deg))");break e;case"linear-gradient":r.push("(background: linear-gradient(red 0%, red 0% 1%, red 2%))");break e;case"radial-gradient":r.push("(background: radial-gradient(red, red 1px 2px, red 3px))");break e;case"repeating-conic-gradient":r.push("(background: repeating-conic-gradient(from 0deg, red 0deg, red 0deg 1deg, red 2deg))");break e;case"repeating-linear-gradient":r.push("(background: repeating-linear-gradient(red 0%, red 0% 1%, red 2%))");break e;case"repeating-radial-gradient":r.push("(background: repeating-radial-gradient(red, red 1px 2px, red 3px))");break e}}else i=!0;else p=0,t=!1}}return r}const r=[{supports:"color-mix(in lch, red, blue)",property:"color",sniff:"color-mix",matchers:[{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]}]},{supports:"rgb(from red r g b)",property:"color",sniff:"from ",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"rgb",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"hwb",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"hwb",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"lch",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"lch",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"oklch",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"oklch",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"lab",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"lab",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"oklab",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"oklab",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(display-p3 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"srgb"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"srgb"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(display-p3 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"display-p3"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"display-p3"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"srgb-linear"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"srgb-linear"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"a98-rgb"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"a98-rgb"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"prophoto-rgb"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"prophoto-rgb"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"rec2020"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"rec2020"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d50"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d50"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d65"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d65"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hsl(0, 0%, 0%)",property:"color",sniff:"hsl",matchers:[{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]}]},{supports:"hsl(0 0% 0% / 0)",property:"color",sniff:"hsl",matchers:[{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hsla(0 0% 0% / 0)",property:"color",sniff:"hsla",matchers:[{type:"function",value:"hsla",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hwb(0 0% 0%)",property:"color",sniff:"hwb",matchers:[{type:"function",value:"hwb",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"hwb",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"lab(0% 0 0)",property:"color",sniff:"lab",matchers:[{type:"function",value:"lab",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"lab",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"lab(0% 0 0)",property:"color",sniff:"lch",matchers:[{type:"function",value:"lch",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"lch",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"oklab(0% 0 0)",property:"color",sniff:"oklab",matchers:[{type:"function",value:"oklab",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"oklab",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"oklab(0% 0 0)",property:"color",sniff:"oklch",matchers:[{type:"function",value:"oklch",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"oklch",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"rgb(0, 0, 0, 0)",property:"color",sniff:"rgb",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]}]},{supports:"rgb(0 0 0 / 0)",property:"color",sniff:"rgb",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"rgba(0 0 0 / 0)",property:"color",sniff:"rgba",matchers:[{type:"function",value:"rgba",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"1ic",property:"font-size",sniff:"ic",matchers:[{type:"word",value:"1ic",dimension:{unit:"ic"}}]}];function matches(e,a){if(e.isVariable&&a&&("word"===a.type||"string"===a.type||"function"===a.type))return!0;if(e.type!==a.type)return!1;if(doesNotMatchValue(e,a))return!1;if(e.nodes&&a.nodes){for(let r=0;r<Math.max(e.nodes.length,a.nodes.length);r++){let p=r,t=r;for(;e.nodes[p]&&"space"===e.nodes[p].type;)p++;for(;a.nodes[t]&&"space"===a.nodes[t].type;)t++;if(!!e.nodes[p]!=!!a.nodes[t])return!1;if(!matches(e.nodes[p],a.nodes[t]))return!1}return!0}return!0}function doesNotMatchValue(e,a){var r,p,t,i;return("space"!==e.type||"space"!==a.type||(null==(r=e.value)?void 0:r.trim())!==(null==(p=a.value)?void 0:p.trim()))&&(e.dimension&&a.dimension?e.dimension.unit!==a.dimension.unit:"string"===e.type?e.value!==a.value:(null==(t=e.value)?void 0:t.toLowerCase())!==(null==(i=a.value)?void 0:i.toLowerCase()))}const p=/^var$/i;function conditionsFromValue(a,t=!1){const i=[],o=r.filter((e=>a.includes(e.sniff)));let s=!1;try{e(a).walk((a=>{"function"===a.type&&p.test(a.value)&&(s=!0);try{const r=e.unit(a.value);!1!==r&&(a.dimension=r)}catch{}for(let e=0;e<o.length;e++){const r=o[e];for(let e=0;e<r.matchers.length;e++){if(matches(r.matchers[e],a))return void i.push(`(${r.property}: ${r.supports})`)}}i.push(...doublePositionGradients(a))}))}catch(e){}return t&&!s?{support:[]}:{support:Array.from(new Set(i)).sort()}}const t=/var\(/i,i=/^initial$/i,o=/^\s*$/,creator=()=>({postcssPlugin:"postcss-progressive-custom-properties",prepare(){const e=new WeakMap;return{OnceExit:(a,{postcss:r})=>{a.walkDecls((a=>{if(!a.parent)return;const p=e.get(a.parent)||{conditionalRules:[],propNames:new Set,lastConditionParams:{support:void 0},lastConditionalRule:void 0};if(e.set(a.parent,p),a.variable){if(!p.propNames.has(a.prop))return void p.propNames.add(a.prop)}else{const e=a.prop.toLowerCase();if(!p.propNames.has(e))return void p.propNames.add(e)}if(!a.variable&&!t.test(a.value))return;if(i.test(a.value))return;if(o.test(a.value))return;const s=!a.variable,l=conditionsFromValue(a.value,s).support.join(" and ");if(!l)return;if(p.lastConditionParams.support!==l&&(p.lastConditionalRule=void 0),p.lastConditionalRule)return p.lastConditionalRule.append(a.clone()),void a.remove();const y=[];if(l&&y.push(r.atRule({name:"supports",params:l,source:a.parent.source,raws:{before:"\n\n",after:"\n"}})),!y.length)return;for(let e=0;e<y.length-1;e++){const a=y[e],r=y[e+1];a.append(r)}const d=y[0],c=y[y.length-1],n=a.parent.clone();n.removeAll(),n.raws.before="\n",n.append(a.clone()),a.remove(),p.lastConditionParams.support=l,p.lastConditionalRule=n,c.append(n),p.conditionalRules.push(d)})),a.walk((a=>{const r=e.get(a);r&&0!==r.conditionalRules.length&&r.conditionalRules.reverse().forEach((e=>{a.after(e)}))}))}}}});creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-progressive-custom-properties/dist/index.d.ts b/node_modules/@csstools/postcss-progressive-custom-properties/dist/index.d.ts new file mode 100644 index 00000000..5b5a74dd --- /dev/null +++ b/node_modules/@csstools/postcss-progressive-custom-properties/dist/index.d.ts @@ -0,0 +1,3 @@ +import { type PluginCreator } from 'postcss'; +declare const creator: PluginCreator<null>; +export default creator; diff --git a/node_modules/@csstools/postcss-progressive-custom-properties/dist/index.mjs b/node_modules/@csstools/postcss-progressive-custom-properties/dist/index.mjs new file mode 100644 index 00000000..19ceb72e --- /dev/null +++ b/node_modules/@csstools/postcss-progressive-custom-properties/dist/index.mjs @@ -0,0 +1 @@ +import e from"postcss-value-parser";const a=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"];function doublePositionGradients(e){const r=[],p=e.value.toLowerCase();if("function"===e.type&&("conic-gradient"===p||"linear-gradient"===p||"radial-gradient"===p||"repeating-conic-gradient"===p||"repeating-linear-gradient"===p||"repeating-radial-gradient"===p)){let p=0,t=!1,i=!1;e:for(let o=0;o<e.nodes.length;o++){const s=e.nodes[o];if("word"===s.type&&a.includes(s.value.toLowerCase())&&(t=!0),"div"!==s.type||","!==s.value.trim())if("word"!==s.type||"in"!==s.value.toLowerCase()){if("word"!==s.type&&"function"!==s.type||p++,i)switch(e.value.toLowerCase()){case"conic-gradient":r.push("(background: conic-gradient(in oklch, red 0deg, red 0deg 1deg, red 2deg))");break e;case"linear-gradient":r.push("(background: linear-gradient(in oklch, red 0%, red 0% 1%, red 2%))");break e;case"radial-gradient":r.push("(background: radial-gradient(in oklch, red, red 1px 2px, red 3px))");break e;case"repeating-conic-gradient":r.push("(background: repeating-conic-gradient(in oklch from 0deg, red 0deg, red 0deg 1deg, red 2deg))");break e;case"repeating-linear-gradient":r.push("(background: repeating-linear-gradient(in oklch, red 0%, red 0% 1%, red 2%))");break e;case"repeating-radial-gradient":r.push("(background: repeating-radial-gradient(in oklch, red, red 1px 2px, red 3px))");break e}if(!t&&3===p)switch(e.value.toLowerCase()){case"conic-gradient":r.push("(background: conic-gradient(red 0deg, red 0deg 1deg, red 2deg))");break e;case"linear-gradient":r.push("(background: linear-gradient(red 0%, red 0% 1%, red 2%))");break e;case"radial-gradient":r.push("(background: radial-gradient(red, red 1px 2px, red 3px))");break e;case"repeating-conic-gradient":r.push("(background: repeating-conic-gradient(from 0deg, red 0deg, red 0deg 1deg, red 2deg))");break e;case"repeating-linear-gradient":r.push("(background: repeating-linear-gradient(red 0%, red 0% 1%, red 2%))");break e;case"repeating-radial-gradient":r.push("(background: repeating-radial-gradient(red, red 1px 2px, red 3px))");break e}}else i=!0;else p=0,t=!1}}return r}const r=[{supports:"color-mix(in lch, red, blue)",property:"color",sniff:"color-mix",matchers:[{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color-mix",nodes:[{type:"word",value:"in"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]}]},{supports:"rgb(from red r g b)",property:"color",sniff:"from ",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"rgb",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"hwb",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"hwb",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"lch",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"lch",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"oklch",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"oklch",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"lab",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"lab",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"oklab",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"oklab",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"from"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(display-p3 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"srgb"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"srgb"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(display-p3 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"display-p3"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"display-p3"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"srgb-linear"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"srgb-linear"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"a98-rgb"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"a98-rgb"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"prophoto-rgb"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"prophoto-rgb"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"rec2020"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"rec2020"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d50"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d50"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d65"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d65"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz"},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hsl(0, 0%, 0%)",property:"color",sniff:"hsl",matchers:[{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]}]},{supports:"hsl(0 0% 0% / 0)",property:"color",sniff:"hsl",matchers:[{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hsla(0 0% 0% / 0)",property:"color",sniff:"hsla",matchers:[{type:"function",value:"hsla",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hwb(0 0% 0%)",property:"color",sniff:"hwb",matchers:[{type:"function",value:"hwb",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"hwb",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"lab(0% 0 0)",property:"color",sniff:"lab",matchers:[{type:"function",value:"lab",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"lab",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"lab(0% 0 0)",property:"color",sniff:"lch",matchers:[{type:"function",value:"lch",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"lch",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"oklab(0% 0 0)",property:"color",sniff:"oklab",matchers:[{type:"function",value:"oklab",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"oklab",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"oklab(0% 0 0)",property:"color",sniff:"oklch",matchers:[{type:"function",value:"oklch",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"oklch",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"rgb(0, 0, 0, 0)",property:"color",sniff:"rgb",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]}]},{supports:"rgb(0 0 0 / 0)",property:"color",sniff:"rgb",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0}]},{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"rgba(0 0 0 / 0)",property:"color",sniff:"rgba",matchers:[{type:"function",value:"rgba",nodes:[{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"space"},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"1ic",property:"font-size",sniff:"ic",matchers:[{type:"word",value:"1ic",dimension:{unit:"ic"}}]}];function matches(e,a){if(e.isVariable&&a&&("word"===a.type||"string"===a.type||"function"===a.type))return!0;if(e.type!==a.type)return!1;if(doesNotMatchValue(e,a))return!1;if(e.nodes&&a.nodes){for(let r=0;r<Math.max(e.nodes.length,a.nodes.length);r++){let p=r,t=r;for(;e.nodes[p]&&"space"===e.nodes[p].type;)p++;for(;a.nodes[t]&&"space"===a.nodes[t].type;)t++;if(!!e.nodes[p]!=!!a.nodes[t])return!1;if(!matches(e.nodes[p],a.nodes[t]))return!1}return!0}return!0}function doesNotMatchValue(e,a){var r,p,t,i;return("space"!==e.type||"space"!==a.type||(null==(r=e.value)?void 0:r.trim())!==(null==(p=a.value)?void 0:p.trim()))&&(e.dimension&&a.dimension?e.dimension.unit!==a.dimension.unit:"string"===e.type?e.value!==a.value:(null==(t=e.value)?void 0:t.toLowerCase())!==(null==(i=a.value)?void 0:i.toLowerCase()))}const p=/^var$/i;function conditionsFromValue(a,t=!1){const i=[],o=r.filter((e=>a.includes(e.sniff)));let s=!1;try{e(a).walk((a=>{"function"===a.type&&p.test(a.value)&&(s=!0);try{const r=e.unit(a.value);!1!==r&&(a.dimension=r)}catch{}for(let e=0;e<o.length;e++){const r=o[e];for(let e=0;e<r.matchers.length;e++){if(matches(r.matchers[e],a))return void i.push(`(${r.property}: ${r.supports})`)}}i.push(...doublePositionGradients(a))}))}catch(e){}return t&&!s?{support:[]}:{support:Array.from(new Set(i)).sort()}}const t=/var\(/i,i=/^initial$/i,o=/^\s*$/,creator=()=>({postcssPlugin:"postcss-progressive-custom-properties",prepare(){const e=new WeakMap;return{OnceExit:(a,{postcss:r})=>{a.walkDecls((a=>{if(!a.parent)return;const p=e.get(a.parent)||{conditionalRules:[],propNames:new Set,lastConditionParams:{support:void 0},lastConditionalRule:void 0};if(e.set(a.parent,p),a.variable){if(!p.propNames.has(a.prop))return void p.propNames.add(a.prop)}else{const e=a.prop.toLowerCase();if(!p.propNames.has(e))return void p.propNames.add(e)}if(!a.variable&&!t.test(a.value))return;if(i.test(a.value))return;if(o.test(a.value))return;const s=!a.variable,l=conditionsFromValue(a.value,s).support.join(" and ");if(!l)return;if(p.lastConditionParams.support!==l&&(p.lastConditionalRule=void 0),p.lastConditionalRule)return p.lastConditionalRule.append(a.clone()),void a.remove();const y=[];if(l&&y.push(r.atRule({name:"supports",params:l,source:a.parent.source,raws:{before:"\n\n",after:"\n"}})),!y.length)return;for(let e=0;e<y.length-1;e++){const a=y[e],r=y[e+1];a.append(r)}const d=y[0],c=y[y.length-1],n=a.parent.clone();n.removeAll(),n.raws.before="\n",n.append(a.clone()),a.remove(),p.lastConditionParams.support=l,p.lastConditionalRule=n,c.append(n),p.conditionalRules.push(d)})),a.walk((a=>{const r=e.get(a);r&&0!==r.conditionalRules.length&&r.conditionalRules.reverse().forEach((e=>{a.after(e)}))}))}}}});creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-progressive-custom-properties/dist/match.d.ts b/node_modules/@csstools/postcss-progressive-custom-properties/dist/match.d.ts new file mode 100644 index 00000000..95a56e03 --- /dev/null +++ b/node_modules/@csstools/postcss-progressive-custom-properties/dist/match.d.ts @@ -0,0 +1,11 @@ +type MatcherNode = { + type: string; + value?: string; + nodes?: Array<MatcherNode>; + dimension?: { + unit?: string; + }; + isVariable?: boolean; +}; +export declare function matches(a: MatcherNode, b: MatcherNode): boolean; +export {}; diff --git a/node_modules/@csstools/postcss-progressive-custom-properties/dist/matchers.d.ts b/node_modules/@csstools/postcss-progressive-custom-properties/dist/matchers.d.ts new file mode 100644 index 00000000..746c0edb --- /dev/null +++ b/node_modules/@csstools/postcss-progressive-custom-properties/dist/matchers.d.ts @@ -0,0 +1,33 @@ +export declare const matchers: ({ + supports: string; + property: string; + sniff: string; + matchers: { + type: string; + value: string; + nodes: ({ + type: string; + value: string; + isVariable?: undefined; + } | { + type: string; + value?: undefined; + isVariable?: undefined; + } | { + type: string; + isVariable: boolean; + value?: undefined; + })[]; + }[]; +} | { + supports: string; + property: string; + sniff: string; + matchers: { + type: string; + value: string; + dimension: { + unit: string; + }; + }[]; +})[]; diff --git a/node_modules/@csstools/postcss-progressive-custom-properties/package.json b/node_modules/@csstools/postcss-progressive-custom-properties/package.json new file mode 100644 index 00000000..6a30f654 --- /dev/null +++ b/node_modules/@csstools/postcss-progressive-custom-properties/package.json @@ -0,0 +1,78 @@ +{ + "name": "@csstools/postcss-progressive-custom-properties", + "description": "Correctly declare progressive enhancements for CSS Custom Properties.", + "version": "3.0.2", + "author": "Jonathan Neal <jonathantneal@hotmail.com>", + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "node ./generate/matchers.mjs && eslint --fix ./src/matchers.ts && rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-progressive-custom-properties" + }, + "keywords": [ + "css", + "custom", + "declarations", + "postcss", + "postcss-plugin", + "progressive", + "properties", + "utility", + "variables", + "vars" + ], + "csstools": { + "exportName": "postcssProgressiveCustomProperties", + "humanReadableName": "PostCSS Progressive Custom Properties" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-relative-color-syntax/CHANGELOG.md b/node_modules/@csstools/postcss-relative-color-syntax/CHANGELOG.md new file mode 100644 index 00000000..70ab0992 --- /dev/null +++ b/node_modules/@csstools/postcss-relative-color-syntax/CHANGELOG.md @@ -0,0 +1,79 @@ +# Changes to PostCSS Relative Color Syntax + +### 2.0.7 + +_October 9, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.4.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#140) (minor) +- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.2`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#302) (patch) + +### 2.0.6 + +_October 2, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#133) (patch) + +### 2.0.5 + +_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-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#132) (patch) + +### 2.0.4 + +_September 18, 2023_ + +- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.1`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#301) (patch) + +### 2.0.3 + +_September 2, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#131) (patch) + +### 2.0.2 + +_August 28, 2023_ + +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#130) (minor) + +### 2.0.1 + +_July 24, 2023_ + +- 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) + +### 2.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) +- 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/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#300) (major) +- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.2.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#122) (patch) + +### 1.0.2 + +_June 14, 2023_ + +- Fix value calculation for `hue` components in relative color syntax. + +### 1.0.1 + +_June 1, 2023_ + +- Updated `@csstools/postcss-progressive-custom-properties` to `2.3.0` (minor) + +### 1.0.0 + +_May 19, 2023_ + +- Initial version +- Updated `@csstools/postcss-progressive-custom-properties` to `2.2.0` (minor) +- Updated `@csstools/css-color-parser` to `1.2.0` (minor) + + diff --git a/node_modules/@csstools/postcss-relative-color-syntax/LICENSE.md b/node_modules/@csstools/postcss-relative-color-syntax/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-relative-color-syntax/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-relative-color-syntax/README.md b/node_modules/@csstools/postcss-relative-color-syntax/README.md new file mode 100644 index 00000000..f61aaa14 --- /dev/null +++ b/node_modules/@csstools/postcss-relative-color-syntax/README.md @@ -0,0 +1,84 @@ +# PostCSS Relative Color Syntax [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-relative-color-syntax.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/relative-color-syntax.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +```bash +npm install @csstools/postcss-relative-color-syntax --save-dev +``` + +[PostCSS Relative Color Syntax] lets you use the relative color syntax in CSS color functions following [CSS Color Module 5]. + +```pcss +.example { + background: oklab(from oklab(54.3% -22.5% -5%) calc(1.0 - l) calc(a * 0.8) b); +} + +/* becomes */ + +.example { + background: rgb(12, 100, 100); +} +``` + +## Usage + +Add [PostCSS Relative Color Syntax] to your project: + +```bash +npm install postcss @csstools/postcss-relative-color-syntax --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssRelativeColorSyntax = require('@csstools/postcss-relative-color-syntax'); + +postcss([ + postcssRelativeColorSyntax(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Relative Color Syntax] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is not preserved. + +```js +postcssRelativeColorSyntax({ preserve: true }) +``` + +```pcss +.example { + background: oklab(from oklab(54.3% -22.5% -5%) calc(1.0 - l) calc(a * 0.8) b); +} + +/* becomes */ + +.example { + background: rgb(12, 100, 100); + background: oklab(from oklab(54.3% -22.5% -5%) calc(1.0 - l) calc(a * 0.8) b); +} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#relative-color-syntax +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-relative-color-syntax + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Relative Color Syntax]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-relative-color-syntax +[CSS Color Module 5]: https://www.w3.org/TR/css-color-5/#relative-colors diff --git a/node_modules/@csstools/postcss-relative-color-syntax/dist/has-fallback-decl.d.ts b/node_modules/@csstools/postcss-relative-color-syntax/dist/has-fallback-decl.d.ts new file mode 100644 index 00000000..d7ae8d89 --- /dev/null +++ b/node_modules/@csstools/postcss-relative-color-syntax/dist/has-fallback-decl.d.ts @@ -0,0 +1,2 @@ +import type { Declaration } from 'postcss'; +export declare function hasFallback(node: Declaration): boolean; diff --git a/node_modules/@csstools/postcss-relative-color-syntax/dist/has-supports-at-rule-ancestor.d.ts b/node_modules/@csstools/postcss-relative-color-syntax/dist/has-supports-at-rule-ancestor.d.ts new file mode 100644 index 00000000..a46009ec --- /dev/null +++ b/node_modules/@csstools/postcss-relative-color-syntax/dist/has-supports-at-rule-ancestor.d.ts @@ -0,0 +1,2 @@ +import type { Node } from 'postcss'; +export declare function hasSupportsAtRuleAncestor(node: Node): boolean; diff --git a/node_modules/@csstools/postcss-relative-color-syntax/dist/index.cjs b/node_modules/@csstools/postcss-relative-color-syntax/dist/index.cjs new file mode 100644 index 00000000..6d266ad5 --- /dev/null +++ b/node_modules/@csstools/postcss-relative-color-syntax/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),s=require("@csstools/css-tokenizer"),r=require("@csstools/css-color-parser"),t=require("@csstools/css-parser-algorithms");function hasFallback(e){const s=e.parent;if(!s)return!1;const r=e.prop.toLowerCase(),t=s.index(e);for(let e=0;e<t;e++){const t=s.nodes[e];if("decl"===t.type&&t.prop.toLowerCase()===r)return!0}return!1}const o=/(rgb|hsl|hwb|lab|lch|oklch|oklab|color)\(\s*?from/i;function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name.toLowerCase()&&o.test(s.params))return!0;s=s.parent}else s=s.parent;return!1}const a=/(rgb|hsl|hwb|lab|lch|oklch|oklab|color)\(/i,l=/^(rgb|hsl|hwb|lab|lch|oklch|oklab|color)$/i,n=/from/i,basePlugin=e=>({postcssPlugin:"postcss-relative-color-syntax",Declaration:o=>{const i=o.value;if(!a.test(i))return;if(!n.test(i))return;if(hasFallback(o))return;if(hasSupportsAtRuleAncestor(o))return;const u=s.tokenize({css:i}),c=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(u),(e=>{if(t.isFunctionNode(e)&&l.test(e.getName())){const s=r.color(e);if(!s)return;if(s.syntaxFlags.has(r.SyntaxFlag.HasNoneKeywords))return;if(!s.syntaxFlags.has(r.SyntaxFlag.RelativeColorSyntax))return;return r.serializeRGB(s)}})),p=t.stringify(c);if(p===i)return;let f=p;null!=e&&e.subFeatures.displayP3&&(f=t.stringify(t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(u),(e=>{if(t.isFunctionNode(e)&&l.test(e.getName())){const s=r.color(e);if(!s)return;if(s.syntaxFlags.has(r.SyntaxFlag.HasNoneKeywords))return;if(!s.syntaxFlags.has(r.SyntaxFlag.RelativeColorSyntax))return;return r.colorDataFitsRGB_Gamut(s)?r.serializeRGB(s):r.serializeP3(s)}})))),o.cloneBefore({value:p}),null!=e&&e.subFeatures.displayP3&&f!==p&&o.cloneBefore({value:f}),null!=e&&e.preserve||o.remove()}});basePlugin.postcss=!0;const postcssPlugin=s=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},s);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-relative-color-syntax",plugins:[e(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/node_modules/@csstools/postcss-relative-color-syntax/dist/index.d.ts b/node_modules/@csstools/postcss-relative-color-syntax/dist/index.d.ts new file mode 100644 index 00000000..15f89fd4 --- /dev/null +++ b/node_modules/@csstools/postcss-relative-color-syntax/dist/index.d.ts @@ -0,0 +1,15 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-relative-color-syntax plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; + /** Enable "@csstools/postcss-progressive-custom-properties". default: true */ + enableProgressiveCustomProperties?: boolean; + /** Toggle sub features. default: { displayP3: true } */ + subFeatures?: { + /** Enable displayP3 fallbacks. default: true */ + displayP3?: boolean; + }; +}; +declare const postcssPlugin: PluginCreator<pluginOptions>; +export default postcssPlugin; diff --git a/node_modules/@csstools/postcss-relative-color-syntax/dist/index.mjs b/node_modules/@csstools/postcss-relative-color-syntax/dist/index.mjs new file mode 100644 index 00000000..0c2dd8bd --- /dev/null +++ b/node_modules/@csstools/postcss-relative-color-syntax/dist/index.mjs @@ -0,0 +1 @@ +import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as e}from"@csstools/css-tokenizer";import{color as r,SyntaxFlag as t,serializeRGB as o,colorDataFitsRGB_Gamut as a,serializeP3 as l}from"@csstools/css-color-parser";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as u,isFunctionNode as c,stringify as i}from"@csstools/css-parser-algorithms";function hasFallback(s){const e=s.parent;if(!e)return!1;const r=s.prop.toLowerCase(),t=e.index(s);for(let s=0;s<t;s++){const t=e.nodes[s];if("decl"===t.type&&t.prop.toLowerCase()===r)return!0}return!1}const p=/(rgb|hsl|hwb|lab|lch|oklch|oklab|color)\(\s*?from/i;function hasSupportsAtRuleAncestor(s){let e=s.parent;for(;e;)if("atrule"===e.type){if("supports"===e.name.toLowerCase()&&p.test(e.params))return!0;e=e.parent}else e=e.parent;return!1}const f=/(rgb|hsl|hwb|lab|lch|oklch|oklab|color)\(/i,b=/^(rgb|hsl|hwb|lab|lch|oklch|oklab|color)$/i,h=/from/i,basePlugin=s=>({postcssPlugin:"postcss-relative-color-syntax",Declaration:p=>{const m=p.value;if(!f.test(m))return;if(!h.test(m))return;if(hasFallback(p))return;if(hasSupportsAtRuleAncestor(p))return;const g=e({css:m}),y=n(u(g),(s=>{if(c(s)&&b.test(s.getName())){const e=r(s);if(!e)return;if(e.syntaxFlags.has(t.HasNoneKeywords))return;if(!e.syntaxFlags.has(t.RelativeColorSyntax))return;return o(e)}})),v=i(y);if(v===m)return;let F=v;null!=s&&s.subFeatures.displayP3&&(F=i(n(u(g),(s=>{if(c(s)&&b.test(s.getName())){const e=r(s);if(!e)return;if(e.syntaxFlags.has(t.HasNoneKeywords))return;if(!e.syntaxFlags.has(t.RelativeColorSyntax))return;return a(e)?o(e):l(e)}})))),p.cloneBefore({value:v}),null!=s&&s.subFeatures.displayP3&&F!==v&&p.cloneBefore({value:F}),null!=s&&s.preserve||p.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-relative-color-syntax",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; diff --git a/node_modules/@csstools/postcss-relative-color-syntax/package.json b/node_modules/@csstools/postcss-relative-color-syntax/package.json new file mode 100644 index 00000000..5667037c --- /dev/null +++ b/node_modules/@csstools/postcss-relative-color-syntax/package.json @@ -0,0 +1,88 @@ +{ + "name": "@csstools/postcss-relative-color-syntax", + "description": "Use the relative color syntax in CSS", + "version": "2.0.7", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/css-color-parser": "^1.4.0", + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1", + "@csstools/postcss-progressive-custom-properties": "^3.0.2" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-relative-color-syntax#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-relative-color-syntax" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "color", + "postcss-plugin", + "relative color syntax" + ], + "csstools": { + "cssdbId": "relative-color-syntax", + "exportName": "postcssRelativeColorSyntax", + "humanReadableName": "PostCSS Relative Color Syntax", + "specUrl": "https://www.w3.org/TR/css-color-5/#relative-colors" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-scope-pseudo-class/CHANGELOG.md b/node_modules/@csstools/postcss-scope-pseudo-class/CHANGELOG.md new file mode 100644 index 00000000..18bfb712 --- /dev/null +++ b/node_modules/@csstools/postcss-scope-pseudo-class/CHANGELOG.md @@ -0,0 +1,32 @@ +# Changes to PostCSS Scope Pseudo Class + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) + +### 2.0.2 + +_February 9, 2023_ + +- Reduce the amount of duplicate fallback CSS. + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). +- Fix: Do not throw when a selector is invalid, show a warning instead. + +### 1.0.0 + +_November 4, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-scope-pseudo-class/LICENSE.md b/node_modules/@csstools/postcss-scope-pseudo-class/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-scope-pseudo-class/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-scope-pseudo-class/README.md b/node_modules/@csstools/postcss-scope-pseudo-class/README.md new file mode 100644 index 00000000..eb1ff5ba --- /dev/null +++ b/node_modules/@csstools/postcss-scope-pseudo-class/README.md @@ -0,0 +1,82 @@ +# PostCSS Scope Pseudo Class [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-scope-pseudo-class.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/scope-pseudo-class.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +[PostCSS Scope Pseudo Class] lets you use the `:scope` Pseudo-class following the [Selectors 4 specification]. + +```pcss +:scope { + color: green; +} + +/* becomes */ + +:root { + color: green; +} +``` + +## Usage + +Add [PostCSS Scope Pseudo Class] to your project: + +```bash +npm install postcss @csstools/postcss-scope-pseudo-class --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssScopePseudoClass = require('@csstools/postcss-scope-pseudo-class'); + +postcss([ + postcssScopePseudoClass(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Scope Pseudo Class] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is not preserved. + +```js +postcssScopePseudoClass({ preserve: true }) +``` + +```pcss +:scope { + color: green; +} + +/* becomes */ + +:root { + color: green; +} +:scope { + color: green; +} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#scope-pseudo-class +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-scope-pseudo-class + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Scope Pseudo Class]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-scope-pseudo-class +[Selectors 4 specification]: https://www.w3.org/TR/selectors-4/#the-scope-pseudo diff --git a/node_modules/@csstools/postcss-scope-pseudo-class/dist/index.cjs b/node_modules/@csstools/postcss-scope-pseudo-class/dist/index.cjs new file mode 100644 index 00000000..e4bc3bd9 --- /dev/null +++ b/node_modules/@csstools/postcss-scope-pseudo-class/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("postcss-selector-parser");const creator=s=>{const r=Object.assign({preserve:!1},s);return{postcssPlugin:"postcss-scope-pseudo-class",prepare(){const s=new WeakSet;return{Rule(t,{result:o}){if(!t.selector.toLowerCase().includes(":scope"))return;if(s.has(t))return;{let e=t.parent;for(;e;){if("atrule"===e.type&&"scope"===e.name.toLowerCase())return;e=e.parent}}let a=t.selector;try{const s=e().astSync(a);if(!s)return;s.walkPseudos((e=>{if(":has"===e.value.toLowerCase())return!1;":scope"===e.value.toLowerCase()&&(e.value=":root")})),a=s.toString()}catch(e){t.warn(o,`Failed to parse selector : "${t.selector}" with message: "${e.message}"`)}a!==t.selector&&(s.add(t),t.cloneBefore({selector:a}),r.preserve||t.remove())}}}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-scope-pseudo-class/dist/index.d.ts b/node_modules/@csstools/postcss-scope-pseudo-class/dist/index.d.ts new file mode 100644 index 00000000..77dc51e7 --- /dev/null +++ b/node_modules/@csstools/postcss-scope-pseudo-class/dist/index.d.ts @@ -0,0 +1,8 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-scope-pseudo-class plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-scope-pseudo-class/dist/index.mjs b/node_modules/@csstools/postcss-scope-pseudo-class/dist/index.mjs new file mode 100644 index 00000000..76a5d07b --- /dev/null +++ b/node_modules/@csstools/postcss-scope-pseudo-class/dist/index.mjs @@ -0,0 +1 @@ +import e from"postcss-selector-parser";const creator=s=>{const r=Object.assign({preserve:!1},s);return{postcssPlugin:"postcss-scope-pseudo-class",prepare(){const s=new WeakSet;return{Rule(t,{result:o}){if(!t.selector.toLowerCase().includes(":scope"))return;if(s.has(t))return;{let e=t.parent;for(;e;){if("atrule"===e.type&&"scope"===e.name.toLowerCase())return;e=e.parent}}let a=t.selector;try{const s=e().astSync(a);if(!s)return;s.walkPseudos((e=>{if(":has"===e.value.toLowerCase())return!1;":scope"===e.value.toLowerCase()&&(e.value=":root")})),a=s.toString()}catch(e){t.warn(o,`Failed to parse selector : "${t.selector}" with message: "${e.message}"`)}a!==t.selector&&(s.add(t),t.cloneBefore({selector:a}),r.preserve||t.remove())}}}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-scope-pseudo-class/package.json b/node_modules/@csstools/postcss-scope-pseudo-class/package.json new file mode 100644 index 00000000..2e67a480 --- /dev/null +++ b/node_modules/@csstools/postcss-scope-pseudo-class/package.json @@ -0,0 +1,86 @@ +{ + "name": "@csstools/postcss-scope-pseudo-class", + "description": "The Reference Element Pseudo-class: :scope", + "version": "3.0.0", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "postcss-selector-parser": "^6.0.13" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-scope-pseudo-class#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-scope-pseudo-class" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "postcss-plugin", + "pseudo", + "scope", + "selector" + ], + "csstools": { + "cssdbId": "scope-pseudo-class", + "exportName": "postcssScopePseudoClass", + "humanReadableName": "PostCSS Scope Pseudo Class", + "specUrl": "https://www.w3.org/TR/selectors-4/#the-scope-pseudo" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-stepped-value-functions/CHANGELOG.md b/node_modules/@csstools/postcss-stepped-value-functions/CHANGELOG.md new file mode 100644 index 00000000..5f310e1a --- /dev/null +++ b/node_modules/@csstools/postcss-stepped-value-functions/CHANGELOG.md @@ -0,0 +1,66 @@ +# Changes to PostCSS Stepped Value Functions + +### 3.0.2 + +_September 24, 2023_ + +- 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) + +### 3.0.1 + +_July 24, 2023_ + +- Use the latest utilities from `@csstools/css-tokenizer` to reduce the bundle size. +- 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) + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) +- 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) + +### 2.1.1 + +_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) + +### 2.1.0 + +_February 21, 2023_ + +- Removed: warnings on `var()` or otherwise unconvertible values (doesn't affect the output, non-breaking) +- Added: `@csstools/css-calc` +- Added: unit conversions (`mod(735ms, 0.1s)`) + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). + +### 1.0.1 + +_July 8, 2022_ + +- Fix case insensitive matching. + +### 1.0.0 + +_May 2, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-stepped-value-functions/LICENSE.md b/node_modules/@csstools/postcss-stepped-value-functions/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-stepped-value-functions/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-stepped-value-functions/README.md b/node_modules/@csstools/postcss-stepped-value-functions/README.md new file mode 100644 index 00000000..54a2a1c5 --- /dev/null +++ b/node_modules/@csstools/postcss-stepped-value-functions/README.md @@ -0,0 +1,120 @@ +# PostCSS Stepped Value Functions [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-stepped-value-functions.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/stepped-value-functions.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +```bash +npm install @csstools/postcss-stepped-value-functions --save-dev +``` + +[PostCSS Stepped Value Functions] lets you use `round`, `rem` and `mod` stepped value functions, following the [CSS Values 4]. + +```pcss +.test-functions { + padding: 8px mod(18px, 5px) 1px calc(rem(15px, 6px) + 50%); + transform: rotate(mod(-140deg, -90deg)); + top: round(15px, 4px); + right: round(nearest, 15px, 4px); + bottom: round(up, 15px, 7px); + left: round(down, 15px, 4px); + width: round(to-zero, 15px, 4px); +} + +/* becomes */ + +.test-functions { + padding: 8px 3px 1px calc(3px + 50%); + transform: rotate(-50deg); + top: 16px; + right: 16px; + bottom: 21px; + left: 12px; + width: 12px; +} +``` + +## Usage + +Add [PostCSS Stepped Value Functions] to your project: + +```bash +npm install postcss @csstools/postcss-stepped-value-functions --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssSteppedValueFunctions = require('@csstools/postcss-stepped-value-functions'); + +postcss([ + postcssSteppedValueFunctions(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Stepped Value Functions] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## ⚠️ About custom properties + +Given the dynamic nature of custom properties it's impossible to know what the variable value is, which means the plugin can't compute a final value for the stylesheet. + +Because of that, any usage that contains a `var` is skipped. + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is not preserved. + +```js +postcssSteppedValueFunctions({ preserve: true }) +``` + +```pcss +.test-functions { + padding: 8px mod(18px, 5px) 1px calc(rem(15px, 6px) + 50%); + transform: rotate(mod(-140deg, -90deg)); + top: round(15px, 4px); + right: round(nearest, 15px, 4px); + bottom: round(up, 15px, 7px); + left: round(down, 15px, 4px); + width: round(to-zero, 15px, 4px); +} + +/* becomes */ + +.test-functions { + padding: 8px 3px 1px calc(3px + 50%); + padding: 8px mod(18px, 5px) 1px calc(rem(15px, 6px) + 50%); + transform: rotate(-50deg); + transform: rotate(mod(-140deg, -90deg)); + top: 16px; + top: round(15px, 4px); + right: 16px; + right: round(nearest, 15px, 4px); + bottom: 21px; + bottom: round(up, 15px, 7px); + left: 12px; + left: round(down, 15px, 4px); + width: 12px; + width: round(to-zero, 15px, 4px); +} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#stepped-value-functions +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-stepped-value-functions + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Stepped Value Functions]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-stepped-value-functions +[CSS Values 4]: https://www.w3.org/TR/css-values-4/#round-func diff --git a/node_modules/@csstools/postcss-stepped-value-functions/dist/calc.d.ts b/node_modules/@csstools/postcss-stepped-value-functions/dist/calc.d.ts new file mode 100644 index 00000000..5a1ee11e --- /dev/null +++ b/node_modules/@csstools/postcss-stepped-value-functions/dist/calc.d.ts @@ -0,0 +1 @@ +export declare function calc(css: string): string; diff --git a/node_modules/@csstools/postcss-stepped-value-functions/dist/checks.d.ts b/node_modules/@csstools/postcss-stepped-value-functions/dist/checks.d.ts new file mode 100644 index 00000000..6623beb7 --- /dev/null +++ b/node_modules/@csstools/postcss-stepped-value-functions/dist/checks.d.ts @@ -0,0 +1,2 @@ +export declare const FUNCTION_NAME_REGEXP: RegExp; +export declare const FUNCTION_CALL_REGEXP: RegExp; diff --git a/node_modules/@csstools/postcss-stepped-value-functions/dist/index.cjs b/node_modules/@csstools/postcss-stepped-value-functions/dist/index.cjs new file mode 100644 index 00000000..0ccad206 --- /dev/null +++ b/node_modules/@csstools/postcss-stepped-value-functions/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/css-calc"),s=require("@csstools/css-parser-algorithms"),o=require("@csstools/css-tokenizer");const n=["mod","rem","round"],t=new RegExp(`^(${n.join("|")})$`,"i"),r=new RegExp(`(${n.join("|")})\\(`,"i");function calc(n){const r=o.tokenize({css:n});return r.some((e=>e[0]===o.TokenType.Function&&t.test(e[4].value)))?s.stringify(e.calcFromComponentValues(s.parseCommaSeparatedListOfComponentValues(r),{precision:5,toCanonicalUnits:!0})):n}const creator=e=>{const s=Object.assign({preserve:!1,onInvalid:""},e);return{postcssPlugin:"postcss-stepped-value-functions",Declaration(e){if(!r.test(e.value))return;const o=calc(e.value);o!==e.value&&(e.cloneBefore({value:o}),s.preserve||e.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-stepped-value-functions/dist/index.d.ts b/node_modules/@csstools/postcss-stepped-value-functions/dist/index.d.ts new file mode 100644 index 00000000..c7772f76 --- /dev/null +++ b/node_modules/@csstools/postcss-stepped-value-functions/dist/index.d.ts @@ -0,0 +1,8 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-stepped-value-functions plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-stepped-value-functions/dist/index.mjs b/node_modules/@csstools/postcss-stepped-value-functions/dist/index.mjs new file mode 100644 index 00000000..2e8dbdf0 --- /dev/null +++ b/node_modules/@csstools/postcss-stepped-value-functions/dist/index.mjs @@ -0,0 +1 @@ +import{calcFromComponentValues as s}from"@csstools/css-calc";import{stringify as o,parseCommaSeparatedListOfComponentValues as e}from"@csstools/css-parser-algorithms";import{tokenize as t,TokenType as n}from"@csstools/css-tokenizer";const c=["mod","rem","round"],r=new RegExp(`^(${c.join("|")})$`,"i"),i=new RegExp(`(${c.join("|")})\\(`,"i");function calc(c){const i=t({css:c});return i.some((s=>s[0]===n.Function&&r.test(s[4].value)))?o(s(e(i),{precision:5,toCanonicalUnits:!0})):c}const creator=s=>{const o=Object.assign({preserve:!1,onInvalid:""},s);return{postcssPlugin:"postcss-stepped-value-functions",Declaration(s){if(!i.test(s.value))return;const e=calc(s.value);e!==s.value&&(s.cloneBefore({value:e}),o.preserve||s.remove())}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-stepped-value-functions/package.json b/node_modules/@csstools/postcss-stepped-value-functions/package.json new file mode 100644 index 00000000..eab24b20 --- /dev/null +++ b/node_modules/@csstools/postcss-stepped-value-functions/package.json @@ -0,0 +1,90 @@ +{ + "name": "@csstools/postcss-stepped-value-functions", + "description": "Use round, rem and mod functions in CSS", + "version": "3.0.2", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/css-calc": "^1.1.4", + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-stepped-value-functions#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-stepped-value-functions" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "css", + "modulus", + "postcss-plugin", + "remainder", + "round", + "stepped" + ], + "csstools": { + "cssdbId": "stepped-value-functions", + "exportName": "postcssSteppedValueFunctions", + "humanReadableName": "PostCSS Stepped Value Functions", + "specUrl": "https://www.w3.org/TR/css-values-4/#round-func" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-text-decoration-shorthand/CHANGELOG.md b/node_modules/@csstools/postcss-text-decoration-shorthand/CHANGELOG.md new file mode 100644 index 00000000..00ec3a12 --- /dev/null +++ b/node_modules/@csstools/postcss-text-decoration-shorthand/CHANGELOG.md @@ -0,0 +1,82 @@ +# Changes to PostCSS Text Decoration Shorthand + +### 3.0.3 + +_September 18, 2023_ + +- Improve performance + +### 3.0.2 + +_September 2, 2023_ + +- 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) + +### 3.0.1 + +_August 28, 2023_ + +- 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) + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) +- 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) + +### 2.2.4 + +_May 19, 2023_ + +- Updated `@csstools/color-helpers` to `2.1.0` (minor) + + +### 2.2.3 + +_April 10, 2023_ + +- Updated: `@csstools/color-helpers` to `v2.0.0` + +### 2.2.2 + +_March 25, 2023_ + +- Add `color-mix` as a known color function. + +### 2.2.1 + +_February 13, 2023_ + +- Updated: `preserve` option defaults to `true` + +### 2.2.0 + +_February 2, 2023_ + +- Add: `@csstools/color-helpers` dependency for the named colors list. + +### 2.1.0 + +_January 28, 2023_ + +- Add: support for multiple line values (`text-decoration: overline underline;`) + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). +- Add: `-webkit-text-decoration` shorthand for single value `text-decoration: underline;`. [autoprefixer 1473](https://github.com/postcss/autoprefixer/issues/1473#issuecomment-1243370592) + +### 1.0.0 + +_August 15, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-text-decoration-shorthand/LICENSE.md b/node_modules/@csstools/postcss-text-decoration-shorthand/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-text-decoration-shorthand/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-text-decoration-shorthand/README.md b/node_modules/@csstools/postcss-text-decoration-shorthand/README.md new file mode 100644 index 00000000..4e16d512 --- /dev/null +++ b/node_modules/@csstools/postcss-text-decoration-shorthand/README.md @@ -0,0 +1,88 @@ +# PostCSS Text Decoration Shorthand [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-text-decoration-shorthand.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/text-decoration-shorthand.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +```bash +npm install @csstools/postcss-text-decoration-shorthand --save-dev +``` + +[PostCSS Text Decoration Shorthand] lets you use `text-decoration` as a shorthand following the [Text Decoration Specification]. + +```pcss +.example { + text-decoration: wavy underline purple 25%; +} + +/* becomes */ + +.example { + text-decoration: underline; + text-decoration: underline wavy purple; + text-decoration-thickness: calc(0.01em * 25); + text-decoration: wavy underline purple 25%; +} +``` + +## Usage + +Add [PostCSS Text Decoration Shorthand] to your project: + +```bash +npm install postcss @csstools/postcss-text-decoration-shorthand --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssTextDecorationShorthand = require('@csstools/postcss-text-decoration-shorthand'); + +postcss([ + postcssTextDecorationShorthand(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Text Decoration Shorthand] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is preserved. + +```js +postcssTextDecorationShorthand({ preserve: false }) +``` + +```pcss +.example { + text-decoration: wavy underline purple 25%; +} + +/* becomes */ + +.example { + text-decoration: underline; + text-decoration: underline wavy purple; + text-decoration-thickness: calc(0.01em * 25); +} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#text-decoration-shorthand +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-text-decoration-shorthand + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Text Decoration Shorthand]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-text-decoration-shorthand +[Text Decoration Specification]: https://drafts.csswg.org/css-text-decor-4/#text-decoration-property diff --git a/node_modules/@csstools/postcss-text-decoration-shorthand/dist/index.cjs b/node_modules/@csstools/postcss-text-decoration-shorthand/dist/index.cjs new file mode 100644 index 00000000..44f618a9 --- /dev/null +++ b/node_modules/@csstools/postcss-text-decoration-shorthand/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/color-helpers"),o=require("postcss-value-parser");const r=/^text-decoration$/i,creator=e=>{const c=Object.assign({preserve:!0},e);return{postcssPlugin:"postcss-text-decoration-shorthand",prepare(){const e=new Map;return{OnceExit:()=>{e.clear()},Declaration:u=>{if(!r.test(u.prop))return;const a=u.parent;if(!a)return;const i=a.index(u);if(a.nodes.some((o=>"decl"===o.type&&r.test(o.prop)&&e.get(u.value)===o.value&&a.index(o)!==i)))return;const d=o(u.value),p=d.nodes.filter((e=>"space"!==e.type&&"comment"!==e.type));if(p.find((e=>"var"===e.value.toLowerCase()&&"function"===e.type)))return;if(p.find((e=>"word"===e.type&&t.includes(e.value))))return;const f={line:[],style:null,color:null,thickness:null};for(let e=0;e<p.length;e++){const r=p[e];if(f.line.length||"word"!==r.type||!n.includes(r.value.toLowerCase()))if(f.line.length||"word"!==r.type||"none"!==r.value.toLowerCase())if(f.style||"word"!==r.type||!s.includes(r.value.toLowerCase()))if(f.thickness||"word"!==r.type||!l.includes(r.value.toLowerCase()))if(f.thickness||"function"!==r.type||"calc"!==r.value.toLowerCase())if(f.color||!nodeIsAColor(r)){if("word"!==r.type)return;{let e;try{e=o.unit(r.value)}catch(e){return}if(!e||!e.unit)return;f.thickness=r,"%"===e.unit&&(f.thickness={before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"function",value:"calc",nodes:[{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"0.01em"},{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"space",value:" "},{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"*"},{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"space",value:" "},{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:e.number}]})}}else f.color=r;else f.thickness=r;else f.thickness=r;else f.style=r;else f.line.push(r);else{const o=r;let t=r;for(;;){const o=p[e+1];if(!o||"word"!==o.type||!n.includes(o.value.toLowerCase()))break;t=o,e++}f.line=d.nodes.slice(d.nodes.indexOf(o),d.nodes.indexOf(t)+1)}}f.line.length||f.line.push({before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"none"}),f.style||(f.style={before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"solid"}),f.color||(f.color={before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"currentColor"});const v=o.stringify(f.line);if(u.value.toLowerCase()===v.toLowerCase()){const e=u.next();return void(e&&"decl"===e.type&&"text-decoration"===e.prop.toLowerCase()||u.cloneBefore({prop:"-webkit-text-decoration",value:v}))}u.cloneBefore({prop:"text-decoration",value:v});const y=o.stringify([...f.line,{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"space",value:" "},f.style,{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"space",value:" "},f.color]);f.thickness&&u.cloneBefore({prop:"text-decoration",value:y}),f.thickness&&u.cloneBefore({prop:"text-decoration-thickness",value:o.stringify([f.thickness])}),e.set(u.value,v),e.set(y,v),c.preserve||u.remove()}}}}};function nodeIsAColor(e){return!("word"!==e.type||!e.value.startsWith("#"))||(!("word"!==e.type||!u.includes(e.value.toLowerCase()))||!("function"!==e.type||!c.includes(e.value.toLowerCase())))}creator.postcss=!0;const t=["unset","inherit","initial","revert","revert-layer"],n=["underline","overline","line-through","blink","spelling-error","grammar-error"],s=["solid","double","dotted","dashed","wavy"],l=["auto","from-font"],c=["color","color-mix","hsl","hsla","hwb","lab","lch","oklab","oklch","rgb","rgba"],u=["currentcolor","transparent",...Object.keys(e.namedColors)];module.exports=creator; diff --git a/node_modules/@csstools/postcss-text-decoration-shorthand/dist/index.d.ts b/node_modules/@csstools/postcss-text-decoration-shorthand/dist/index.d.ts new file mode 100644 index 00000000..c9808969 --- /dev/null +++ b/node_modules/@csstools/postcss-text-decoration-shorthand/dist/index.d.ts @@ -0,0 +1,8 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-text-decoration-shorthand plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: true */ + preserve?: boolean; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-text-decoration-shorthand/dist/index.mjs b/node_modules/@csstools/postcss-text-decoration-shorthand/dist/index.mjs new file mode 100644 index 00000000..09cd53e2 --- /dev/null +++ b/node_modules/@csstools/postcss-text-decoration-shorthand/dist/index.mjs @@ -0,0 +1 @@ +import{namedColors as e}from"@csstools/color-helpers";import o from"postcss-value-parser";const r=/^text-decoration$/i,creator=e=>{const c=Object.assign({preserve:!0},e);return{postcssPlugin:"postcss-text-decoration-shorthand",prepare(){const e=new Map;return{OnceExit:()=>{e.clear()},Declaration:a=>{if(!r.test(a.prop))return;const u=a.parent;if(!u)return;const i=u.index(a);if(u.nodes.some((o=>"decl"===o.type&&r.test(o.prop)&&e.get(a.value)===o.value&&u.index(o)!==i)))return;const d=o(a.value),p=d.nodes.filter((e=>"space"!==e.type&&"comment"!==e.type));if(p.find((e=>"var"===e.value.toLowerCase()&&"function"===e.type)))return;if(p.find((e=>"word"===e.type&&t.includes(e.value))))return;const f={line:[],style:null,color:null,thickness:null};for(let e=0;e<p.length;e++){const r=p[e];if(f.line.length||"word"!==r.type||!n.includes(r.value.toLowerCase()))if(f.line.length||"word"!==r.type||"none"!==r.value.toLowerCase())if(f.style||"word"!==r.type||!s.includes(r.value.toLowerCase()))if(f.thickness||"word"!==r.type||!l.includes(r.value.toLowerCase()))if(f.thickness||"function"!==r.type||"calc"!==r.value.toLowerCase())if(f.color||!nodeIsAColor(r)){if("word"!==r.type)return;{let e;try{e=o.unit(r.value)}catch(e){return}if(!e||!e.unit)return;f.thickness=r,"%"===e.unit&&(f.thickness={before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"function",value:"calc",nodes:[{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"0.01em"},{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"space",value:" "},{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"*"},{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"space",value:" "},{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:e.number}]})}}else f.color=r;else f.thickness=r;else f.thickness=r;else f.style=r;else f.line.push(r);else{const o=r;let t=r;for(;;){const o=p[e+1];if(!o||"word"!==o.type||!n.includes(o.value.toLowerCase()))break;t=o,e++}f.line=d.nodes.slice(d.nodes.indexOf(o),d.nodes.indexOf(t)+1)}}f.line.length||f.line.push({before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"none"}),f.style||(f.style={before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"solid"}),f.color||(f.color={before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"currentColor"});const v=o.stringify(f.line);if(a.value.toLowerCase()===v.toLowerCase()){const e=a.next();return void(e&&"decl"===e.type&&"text-decoration"===e.prop.toLowerCase()||a.cloneBefore({prop:"-webkit-text-decoration",value:v}))}a.cloneBefore({prop:"text-decoration",value:v});const y=o.stringify([...f.line,{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"space",value:" "},f.style,{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"space",value:" "},f.color]);f.thickness&&a.cloneBefore({prop:"text-decoration",value:y}),f.thickness&&a.cloneBefore({prop:"text-decoration-thickness",value:o.stringify([f.thickness])}),e.set(a.value,v),e.set(y,v),c.preserve||a.remove()}}}}};function nodeIsAColor(e){return!("word"!==e.type||!e.value.startsWith("#"))||(!("word"!==e.type||!a.includes(e.value.toLowerCase()))||!("function"!==e.type||!c.includes(e.value.toLowerCase())))}creator.postcss=!0;const t=["unset","inherit","initial","revert","revert-layer"],n=["underline","overline","line-through","blink","spelling-error","grammar-error"],s=["solid","double","dotted","dashed","wavy"],l=["auto","from-font"],c=["color","color-mix","hsl","hsla","hwb","lab","lch","oklab","oklch","rgb","rgba"],a=["currentcolor","transparent",...Object.keys(e)];export{creator as default}; diff --git a/node_modules/@csstools/postcss-text-decoration-shorthand/package.json b/node_modules/@csstools/postcss-text-decoration-shorthand/package.json new file mode 100644 index 00000000..6d1d6006 --- /dev/null +++ b/node_modules/@csstools/postcss-text-decoration-shorthand/package.json @@ -0,0 +1,89 @@ +{ + "name": "@csstools/postcss-text-decoration-shorthand", + "description": "Use text-decoration in it's shorthand form in CSS", + "version": "3.0.3", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/color-helpers": "^3.0.2", + "postcss-value-parser": "^4.2.0" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*", + "autoprefixer": "^10.4.15" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-text-decoration-shorthand#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-text-decoration-shorthand" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "css", + "postcss-plugin", + "shorthand", + "text-decoration", + "text-decoration-thickness" + ], + "csstools": { + "cssdbId": "text-decoration-shorthand", + "exportName": "postcssTextDecorationShorthand", + "humanReadableName": "PostCSS Text Decoration Shorthand", + "specUrl": "https://drafts.csswg.org/css-text-decor-4/#text-decoration-property" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-trigonometric-functions/CHANGELOG.md b/node_modules/@csstools/postcss-trigonometric-functions/CHANGELOG.md new file mode 100644 index 00000000..9ec73779 --- /dev/null +++ b/node_modules/@csstools/postcss-trigonometric-functions/CHANGELOG.md @@ -0,0 +1,71 @@ +# Changes to PostCSS Trigonometric Functions + +### 3.0.2 + +_September 24, 2023_ + +- 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) + +### 3.0.1 + +_July 24, 2023_ + +- Use the latest utilities from `@csstools/css-tokenizer` to reduce the bundle size. +- 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) + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) +- 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) + +### 2.1.1 + +_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) + +### 2.1.0 + +_March 21, 2023_ + +- Added: `@csstools/css-calc` +- Added: unit conversions (`sin(30deg + (.125turn / 3))`) + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). + +### 1.0.2 + +_July 8, 2022_ + +- Fix case insensitive matching. + +### 1.0.1 + +_May 31, 2022_ + +- Ensure that the plugin works in node 14 + +### 1.0.0 + +_May 20, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-trigonometric-functions/LICENSE.md b/node_modules/@csstools/postcss-trigonometric-functions/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-trigonometric-functions/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-trigonometric-functions/README.md b/node_modules/@csstools/postcss-trigonometric-functions/README.md new file mode 100644 index 00000000..2c1f3cc7 --- /dev/null +++ b/node_modules/@csstools/postcss-trigonometric-functions/README.md @@ -0,0 +1,162 @@ +# PostCSS Trigonometric Functions [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-trigonometric-functions.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/trigonometric-functions.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +```bash +npm install @csstools/postcss-trigonometric-functions --save-dev +``` + +[PostCSS Trigonometric Functions] lets you use `sin`, `cos`, `tan`, `asin`, `acos`, `atan` and `atan2` to be able to compute trigonometric relationships following the [CSS Values 4] specification. + +```pcss +.trigonometry { + line-height: sin(pi / 4); + line-height: cos(.125turn); + line-height: tan(50grad); + transform: rotate(asin(-1)); + transform: rotate(asin(sin(30deg + 1.0471967rad))); + transform: rotate(acos(-1)); + transform: rotate(acos(cos(0 / 2 + 1 - 1))); + transform: rotate(atan(infinity)); + transform: rotate(atan(e - 2.7182818284590452354)); + transform: rotate(atan2(-infinity,-infinity)); + transform: rotate(atan2(-infinity,infinity)); + transform: rotate(atan2(-infinity,infinity)); + transform: rotate(atan2(90, 15)); +} + +/* becomes */ + +.trigonometry { + line-height: 0.70711; + line-height: 0.70711; + line-height: 1; + transform: rotate(-90deg); + transform: rotate(89.99995deg); + transform: rotate(180deg); + transform: rotate(0deg); + transform: rotate(90deg); + transform: rotate(0deg); + transform: rotate(-135deg); + transform: rotate(-45deg); + transform: rotate(-45deg); + transform: rotate(80.53768deg); +} +``` + +## Usage + +Add [PostCSS Trigonometric Functions] to your project: + +```bash +npm install postcss @csstools/postcss-trigonometric-functions --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssTrigonometricFunctions = require('@csstools/postcss-trigonometric-functions'); + +postcss([ + postcssTrigonometricFunctions(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Trigonometric Functions] runs in all Node environments, with special +instructions for: + +- [Node](INSTALL.md#node) +- [PostCSS CLI](INSTALL.md#postcss-cli) +- [PostCSS Load Config](INSTALL.md#postcss-load-config) +- [Webpack](INSTALL.md#webpack) +- [Next.js](INSTALL.md#nextjs) +- [Gulp](INSTALL.md#gulp) +- [Grunt](INSTALL.md#grunt) + +## ⚠️ About custom properties + +Given the dynamic nature of custom properties it's impossible to know what the variable value is, which means the plugin can't compute a final value for the stylesheet. + +Because of that, any usage that contains a `var` is skipped. + +## Units + +[PostCSS Trigonometric Functions] lets you use different special units that are within the spec and computed at run time to be able to calculate the result of the trigonometric function. + +The following units are supported: + +* `pi`: Computes to `Math.PI` which is `3.141592653589793` +* `e`: Computes to `Math.E` which is `2.718281828459045` +* `infinity`, `-infinity`: Compute to `Infinity` and `-Infinity` respectively. Note that the usage is case insensitive so `InFiNiTy` is a valid value. + +Some calculations (such as `sin(-infinity)`) might return `NaN` as per the spec. Given that `NaN` can't be replaced with a value that's useful to CSS it is left as is, as the result will be effectively ignored by the browser. + +## Options + +### preserve + +The `preserve` option determines whether the original notation +is preserved. By default, it is not preserved. + +```js +postcssTrigonometricFunctions({ preserve: true }) +``` + +```pcss +.trigonometry { + line-height: sin(pi / 4); + line-height: cos(.125turn); + line-height: tan(50grad); + transform: rotate(asin(-1)); + transform: rotate(asin(sin(30deg + 1.0471967rad))); + transform: rotate(acos(-1)); + transform: rotate(acos(cos(0 / 2 + 1 - 1))); + transform: rotate(atan(infinity)); + transform: rotate(atan(e - 2.7182818284590452354)); + transform: rotate(atan2(-infinity,-infinity)); + transform: rotate(atan2(-infinity,infinity)); + transform: rotate(atan2(-infinity,infinity)); + transform: rotate(atan2(90, 15)); +} + +/* becomes */ + +.trigonometry { + line-height: 0.70711; + line-height: sin(pi / 4); + line-height: 0.70711; + line-height: cos(.125turn); + line-height: 1; + line-height: tan(50grad); + transform: rotate(-90deg); + transform: rotate(asin(-1)); + transform: rotate(89.99995deg); + transform: rotate(asin(sin(30deg + 1.0471967rad))); + transform: rotate(180deg); + transform: rotate(acos(-1)); + transform: rotate(0deg); + transform: rotate(acos(cos(0 / 2 + 1 - 1))); + transform: rotate(90deg); + transform: rotate(atan(infinity)); + transform: rotate(0deg); + transform: rotate(atan(e - 2.7182818284590452354)); + transform: rotate(-135deg); + transform: rotate(atan2(-infinity,-infinity)); + transform: rotate(-45deg); + transform: rotate(atan2(-infinity,infinity)); + transform: rotate(-45deg); + transform: rotate(atan2(-infinity,infinity)); + transform: rotate(80.53768deg); + transform: rotate(atan2(90, 15)); +} +``` + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#trigonometric-functions +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-trigonometric-functions + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Trigonometric Functions]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-trigonometric-functions +[CSS Values 4]: https://www.w3.org/TR/css-values-4/#trig-funcs diff --git a/node_modules/@csstools/postcss-trigonometric-functions/dist/calc.d.ts b/node_modules/@csstools/postcss-trigonometric-functions/dist/calc.d.ts new file mode 100644 index 00000000..5a1ee11e --- /dev/null +++ b/node_modules/@csstools/postcss-trigonometric-functions/dist/calc.d.ts @@ -0,0 +1 @@ +export declare function calc(css: string): string; diff --git a/node_modules/@csstools/postcss-trigonometric-functions/dist/checks.d.ts b/node_modules/@csstools/postcss-trigonometric-functions/dist/checks.d.ts new file mode 100644 index 00000000..6623beb7 --- /dev/null +++ b/node_modules/@csstools/postcss-trigonometric-functions/dist/checks.d.ts @@ -0,0 +1,2 @@ +export declare const FUNCTION_NAME_REGEXP: RegExp; +export declare const FUNCTION_CALL_REGEXP: RegExp; diff --git a/node_modules/@csstools/postcss-trigonometric-functions/dist/index.cjs b/node_modules/@csstools/postcss-trigonometric-functions/dist/index.cjs new file mode 100644 index 00000000..6fe36838 --- /dev/null +++ b/node_modules/@csstools/postcss-trigonometric-functions/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var s=require("@csstools/css-calc"),e=require("@csstools/css-parser-algorithms"),o=require("@csstools/css-tokenizer");const t=["asin","acos","atan","atan2","sin","cos","tan"],n=new RegExp(`^(${t.join("|")})$`,"i"),c=new RegExp(`(${t.join("|")})\\(`,"i");function calc(t){const c=o.tokenize({css:t});return c.some((s=>s[0]===o.TokenType.Function&&n.test(s[4].value)))?e.stringify(s.calcFromComponentValues(e.parseCommaSeparatedListOfComponentValues(c),{precision:5,toCanonicalUnits:!0})):t}const creator=s=>{const e=Object.assign({preserve:!1},s);return{postcssPlugin:"postcss-trigonometric-functions",Declaration(s){if(!c.test(s.value))return;const o=calc(s.value);o!==s.value&&(s.cloneBefore({value:o}),e.preserve||s.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-trigonometric-functions/dist/index.d.ts b/node_modules/@csstools/postcss-trigonometric-functions/dist/index.d.ts new file mode 100644 index 00000000..40ac49ea --- /dev/null +++ b/node_modules/@csstools/postcss-trigonometric-functions/dist/index.d.ts @@ -0,0 +1,8 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-trigonometric-functions plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-trigonometric-functions/dist/index.mjs b/node_modules/@csstools/postcss-trigonometric-functions/dist/index.mjs new file mode 100644 index 00000000..8fed33de --- /dev/null +++ b/node_modules/@csstools/postcss-trigonometric-functions/dist/index.mjs @@ -0,0 +1 @@ +import{calcFromComponentValues as s}from"@csstools/css-calc";import{stringify as o,parseCommaSeparatedListOfComponentValues as t}from"@csstools/css-parser-algorithms";import{tokenize as e,TokenType as n}from"@csstools/css-tokenizer";const c=["asin","acos","atan","atan2","sin","cos","tan"],r=new RegExp(`^(${c.join("|")})$`,"i"),a=new RegExp(`(${c.join("|")})\\(`,"i");function calc(c){const a=e({css:c});return a.some((s=>s[0]===n.Function&&r.test(s[4].value)))?o(s(t(a),{precision:5,toCanonicalUnits:!0})):c}const creator=s=>{const o=Object.assign({preserve:!1},s);return{postcssPlugin:"postcss-trigonometric-functions",Declaration(s){if(!a.test(s.value))return;const t=calc(s.value);t!==s.value&&(s.cloneBefore({value:t}),o.preserve||s.remove())}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-trigonometric-functions/package.json b/node_modules/@csstools/postcss-trigonometric-functions/package.json new file mode 100644 index 00000000..95a0b08f --- /dev/null +++ b/node_modules/@csstools/postcss-trigonometric-functions/package.json @@ -0,0 +1,94 @@ +{ + "name": "@csstools/postcss-trigonometric-functions", + "description": "Use sin(), cos(), tan(), acos(), atan(), and atan2() to compute trigonometric relationships", + "version": "3.0.2", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "dependencies": { + "@csstools/css-calc": "^1.1.4", + "@csstools/css-parser-algorithms": "^2.3.2", + "@csstools/css-tokenizer": "^2.2.1" + }, + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-trigonometric-functions#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-trigonometric-functions" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "acos", + "acos2", + "asin", + "atan", + "cos", + "css", + "postcss-plugin", + "sin", + "tan", + "trigonometric" + ], + "csstools": { + "cssdbId": "trigonometric-functions", + "exportName": "postcssTrigonometricFunctions", + "humanReadableName": "PostCSS Trigonometric Functions", + "specUrl": "https://www.w3.org/TR/css-values-4/#trig-funcs" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/postcss-unset-value/CHANGELOG.md b/node_modules/@csstools/postcss-unset-value/CHANGELOG.md new file mode 100644 index 00000000..438f5c2d --- /dev/null +++ b/node_modules/@csstools/postcss-unset-value/CHANGELOG.md @@ -0,0 +1,37 @@ +# Changes to PostCSS Unset Value + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) + +### 2.0.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.0.0 + +_January 24, 2023_ + +- Updated: Support for Node v14+ (major). + +### 1.0.2 + +_July 8, 2022_ + +- Fixed: Case insensitive property and keyword matching. + +### 1.0.1 + +_May 11, 2022_ + +- No longer converts `all: unset;` to `all: initial;`. `all: unset` is now ignored. + +### 1.0.0 + +_February 21, 2022_ + +- Initial version diff --git a/node_modules/@csstools/postcss-unset-value/LICENSE.md b/node_modules/@csstools/postcss-unset-value/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/postcss-unset-value/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/postcss-unset-value/README.md b/node_modules/@csstools/postcss-unset-value/README.md new file mode 100644 index 00000000..915c8144 --- /dev/null +++ b/node_modules/@csstools/postcss-unset-value/README.md @@ -0,0 +1,118 @@ +# PostCSS Unset Value [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss] + + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-unset-value.svg" height="20">][npm-url] +[<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/unset-value.svg" height="20">][css-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +[PostCSS Unset Value] lets you use the unset keyword, following the [CSS Cascading and Inheritance] specification. + +```pcss +.color { + color: unset; +} + +.border-color { + border-color: unset; +} + +.margin { + margin: unset; +} + + +/* becomes */ +.color { + color: inherit; +} + +.border-color { + border-color: initial; +} + +.margin { + margin: initial; +} +``` + +## Usage + +Add [PostCSS Unset Value] to your project: + +```bash +npm install postcss @csstools/postcss-unset-value --save-dev +``` + +Use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssUnsetValue = require('@csstools/postcss-unset-value'); + +postcss([ + postcssUnsetValue(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +[PostCSS Unset Value] runs in all Node environments, with special +instructions for: + +| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) | +| --- | --- | --- | --- | --- | + +## Options + +### preserve + +The `preserve` option determines whether the original source +is preserved. By default, it is not preserved. + +```js +postcssUnsetValue({ preserve: true }) +``` + +```pcss +.color { + color: unset; +} + +.border-color { + border-color: unset; +} + +.margin { + margin: unset; +} + +/* becomes */ + +.color { + color: inherit; + color: unset; +} + +.border-color { + border-color: initial; + border-color: unset; +} + +.margin { + margin: initial; + margin: unset; +} +``` + +[postcss]: https://github.com/postcss/postcss + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[css-url]: https://cssdb.org/#unset-value +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/postcss-unset-value + +[Gulp PostCSS]: https://github.com/postcss/gulp-postcss +[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss +[PostCSS]: https://github.com/postcss/postcss +[PostCSS Loader]: https://github.com/postcss/postcss-loader +[CSS Cascading and Inheritance]: https://www.w3.org/TR/css-cascade-4/#inherit-initial +[PostCSS Unset Value]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-unset-value diff --git a/node_modules/@csstools/postcss-unset-value/dist/index.cjs b/node_modules/@csstools/postcss-unset-value/dist/index.cjs new file mode 100644 index 00000000..8464cec8 --- /dev/null +++ b/node_modules/@csstools/postcss-unset-value/dist/index.cjs @@ -0,0 +1 @@ +"use strict";const e=new Set(["block-ellipsis","border-boundary","border-collapse","border-spacing","box-snap","caption-side","caret","caret-shape","clip-rule","color","color-interpolation","color-interpolation-filters","cursor","direction","dominant-baseline","empty-cells","fill","fill-color","fill-image","fill-opacity","fill-position","fill-repeat","fill-rule","fill-size","font","font-family","font-feature-settings","font-kerning","font-language-override","font-palette","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-emoji","font-variant-ligatures","font-weight","forced-color-adjust","hyphenate-character","hyphenate-limit-chars","hyphenate-limit-last","hyphenate-limit-lines","hyphenate-limit-zone","hyphens","image-orientation","image-rendering","image-resolution","initial-letter-wrap","letter-spacing","line-break","line-height","line-padding","line-snap","list-style","list-style-image","list-style-position","list-style-type","marker","marker-end","marker-mid","marker-side","marker-start","orphans","overflow-wrap","paint-order","pointer-events","print-color-adjust","quotes","ruby-merge","ruby-overhang","ruby-position","shape-rendering","speak","speak-as","stroke","stroke-align","stroke-alignment","stroke-color","stroke-dash-corner","stroke-dash-justify","stroke-dashadjust","stroke-dasharray","stroke-dashcorner","stroke-dashoffset","stroke-image","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-position","stroke-repeat","stroke-size","stroke-width","tab-size","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration-skip","text-decoration-skip-box","text-decoration-skip-inset","text-decoration-skip-self","text-decoration-skip-spaces","text-edge","text-emphasis-color","text-emphasis-position","text-emphasis-skip","text-emphasis-style","text-indent","text-justify","text-orientation","text-rendering","text-shadow","text-size-adjust","text-space-collapse","text-spacing","text-transform","text-underline-position","text-wrap","visibility","voice-balance","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","widows","word-boundary-detection","word-boundary-expansion","word-break","word-spacing","word-wrap","writing-mode"]),t=new Set(["align-content","align-items","align-self","alignment-baseline","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timeline","animation-timing-function","appearance","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-block","background-position-inline","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","baseline-source","block-step","block-step-align","block-step-insert","block-step-round","block-step-size","bookmark-label","bookmark-level","bookmark-state","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-clip","border-clip-bottom","border-clip-left","border-clip-right","border-clip-top","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-limit","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","clear","clip","clip-path","color-adjust","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-width","container","container-name","container-type","content","continue","copy-into","corner-shape","corners","counter-increment","counter-reset","cue","cue-after","cue-before","cx","cy","d","display","fill-break","fill-origin","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-defer","float-offset","float-reference","flood-color","flood-opacity","flow-from","flow-into","footnote-display","footnote-policy","gap","glyph-orientation-vertical","grid-auto-columns","grid-auto-rows","grid-column-gap","grid-gap","grid-row-gap","grid-template-columns","grid-template-rows","height","initial-letter","inline-sizing","input-security","isolation","justify-content","justify-items","justify-self","leading-trim","left","lighting-color","line-clamp","line-grid","margin","margin-bottom","margin-break","margin-left","margin-right","margin-top","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-image","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-height","max-lines","max-width","min-height","min-intrinsic-sizing","min-width","mix-blend-mode","nav-down","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","perspective","perspective-origin","place-content","position","r","region-fragment","resize","rest","rest-after","rest-before","right","row-gap","rx","ry","scroll-snap-type","shape-image-threshold","shape-inside","shape-margin","shape-outside","shape-padding","shape-subtract","spatial-navigation-action","spatial-navigation-contain","spatial-navigation-function","stop-color","stop-opacity","string-set","stroke-break","stroke-origin","table-layout","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-emphasis","text-group-align","text-overflow","text-space-trim","top","touch-action","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","user-select","vector-effect","vertical-align","voice-duration","width","will-change","wrap-after","wrap-before","wrap-flow","wrap-inside","wrap-through","x","y","z-index"]),creator=o=>{const i=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-unset-value",Declaration(o){if("unset"!==o.value.toLowerCase())return;let r=!1;e.has(o.prop.toLowerCase())?r="inherit":t.has(o.prop.toLowerCase())&&(r="initial"),r&&(o.cloneBefore({prop:o.prop,value:r}),i.preserve||o.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/@csstools/postcss-unset-value/dist/index.d.ts b/node_modules/@csstools/postcss-unset-value/dist/index.d.ts new file mode 100644 index 00000000..9bf13c0d --- /dev/null +++ b/node_modules/@csstools/postcss-unset-value/dist/index.d.ts @@ -0,0 +1,8 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-unset-value plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; +}; +declare const creator: PluginCreator<pluginOptions>; +export default creator; diff --git a/node_modules/@csstools/postcss-unset-value/dist/index.mjs b/node_modules/@csstools/postcss-unset-value/dist/index.mjs new file mode 100644 index 00000000..96b55390 --- /dev/null +++ b/node_modules/@csstools/postcss-unset-value/dist/index.mjs @@ -0,0 +1 @@ +const e=new Set(["block-ellipsis","border-boundary","border-collapse","border-spacing","box-snap","caption-side","caret","caret-shape","clip-rule","color","color-interpolation","color-interpolation-filters","cursor","direction","dominant-baseline","empty-cells","fill","fill-color","fill-image","fill-opacity","fill-position","fill-repeat","fill-rule","fill-size","font","font-family","font-feature-settings","font-kerning","font-language-override","font-palette","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-emoji","font-variant-ligatures","font-weight","forced-color-adjust","hyphenate-character","hyphenate-limit-chars","hyphenate-limit-last","hyphenate-limit-lines","hyphenate-limit-zone","hyphens","image-orientation","image-rendering","image-resolution","initial-letter-wrap","letter-spacing","line-break","line-height","line-padding","line-snap","list-style","list-style-image","list-style-position","list-style-type","marker","marker-end","marker-mid","marker-side","marker-start","orphans","overflow-wrap","paint-order","pointer-events","print-color-adjust","quotes","ruby-merge","ruby-overhang","ruby-position","shape-rendering","speak","speak-as","stroke","stroke-align","stroke-alignment","stroke-color","stroke-dash-corner","stroke-dash-justify","stroke-dashadjust","stroke-dasharray","stroke-dashcorner","stroke-dashoffset","stroke-image","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-position","stroke-repeat","stroke-size","stroke-width","tab-size","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration-skip","text-decoration-skip-box","text-decoration-skip-inset","text-decoration-skip-self","text-decoration-skip-spaces","text-edge","text-emphasis-color","text-emphasis-position","text-emphasis-skip","text-emphasis-style","text-indent","text-justify","text-orientation","text-rendering","text-shadow","text-size-adjust","text-space-collapse","text-spacing","text-transform","text-underline-position","text-wrap","visibility","voice-balance","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","widows","word-boundary-detection","word-boundary-expansion","word-break","word-spacing","word-wrap","writing-mode"]),t=new Set(["align-content","align-items","align-self","alignment-baseline","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timeline","animation-timing-function","appearance","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-block","background-position-inline","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","baseline-source","block-step","block-step-align","block-step-insert","block-step-round","block-step-size","bookmark-label","bookmark-level","bookmark-state","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-clip","border-clip-bottom","border-clip-left","border-clip-right","border-clip-top","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-limit","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","clear","clip","clip-path","color-adjust","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-width","container","container-name","container-type","content","continue","copy-into","corner-shape","corners","counter-increment","counter-reset","cue","cue-after","cue-before","cx","cy","d","display","fill-break","fill-origin","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-defer","float-offset","float-reference","flood-color","flood-opacity","flow-from","flow-into","footnote-display","footnote-policy","gap","glyph-orientation-vertical","grid-auto-columns","grid-auto-rows","grid-column-gap","grid-gap","grid-row-gap","grid-template-columns","grid-template-rows","height","initial-letter","inline-sizing","input-security","isolation","justify-content","justify-items","justify-self","leading-trim","left","lighting-color","line-clamp","line-grid","margin","margin-bottom","margin-break","margin-left","margin-right","margin-top","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-image","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-height","max-lines","max-width","min-height","min-intrinsic-sizing","min-width","mix-blend-mode","nav-down","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","perspective","perspective-origin","place-content","position","r","region-fragment","resize","rest","rest-after","rest-before","right","row-gap","rx","ry","scroll-snap-type","shape-image-threshold","shape-inside","shape-margin","shape-outside","shape-padding","shape-subtract","spatial-navigation-action","spatial-navigation-contain","spatial-navigation-function","stop-color","stop-opacity","string-set","stroke-break","stroke-origin","table-layout","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-emphasis","text-group-align","text-overflow","text-space-trim","top","touch-action","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","user-select","vector-effect","vertical-align","voice-duration","width","will-change","wrap-after","wrap-before","wrap-flow","wrap-inside","wrap-through","x","y","z-index"]),creator=o=>{const i=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-unset-value",Declaration(o){if("unset"!==o.value.toLowerCase())return;let r=!1;e.has(o.prop.toLowerCase())?r="inherit":t.has(o.prop.toLowerCase())&&(r="initial"),r&&(o.cloneBefore({prop:o.prop,value:r}),i.preserve||o.remove())}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/@csstools/postcss-unset-value/dist/property-def.d.ts b/node_modules/@csstools/postcss-unset-value/dist/property-def.d.ts new file mode 100644 index 00000000..46c84073 --- /dev/null +++ b/node_modules/@csstools/postcss-unset-value/dist/property-def.d.ts @@ -0,0 +1,2 @@ +export declare const inherited: Set<string>; +export declare const nonInherited: Set<string>; diff --git a/node_modules/@csstools/postcss-unset-value/package.json b/node_modules/@csstools/postcss-unset-value/package.json new file mode 100644 index 00000000..6ecdd94e --- /dev/null +++ b/node_modules/@csstools/postcss-unset-value/package.json @@ -0,0 +1,81 @@ +{ + "name": "@csstools/postcss-unset-value", + "description": "Use the unset keyword in CSS.", + "version": "3.0.0", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "peerDependencies": { + "postcss": "^8.4" + }, + "devDependencies": { + "@csstools/postcss-tape": "*" + }, + "scripts": { + "build": "rollup -c ../../rollup/default.mjs", + "docs": "node ../../.github/bin/generate-docs/install.mjs", + "lint": "node ../../.github/bin/format-package-json.mjs", + "prepublishOnly": "npm run build && npm run test", + "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", + "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-unset-value#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-unset-value" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "inherit", + "initial", + "postcss-plugin", + "unset" + ], + "csstools": { + "exportName": "postcssUnsetValue", + "humanReadableName": "PostCSS Unset Value" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/node_modules/@csstools/selector-specificity/CHANGELOG.md b/node_modules/@csstools/selector-specificity/CHANGELOG.md new file mode 100644 index 00000000..770a6b9f --- /dev/null +++ b/node_modules/@csstools/selector-specificity/CHANGELOG.md @@ -0,0 +1,63 @@ +# Changes to Selector Specificity + +### 3.0.0 + +_July 3, 2023_ + +- Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/)) + +### 2.2.0 + +_March 21, 2023_ + +- Improve case insensitive string matching. +- Add support for: + - `::view-transition` + - `::view-transition-group(*)` and `::view-transition-group(name)` + - `::view-transition-image-par(*)` and `::view-transition-image-par(name)` + - `::view-transition-old(*)` and `::view-transition-old(name)` + - `::view-transition-new(*)` and `::view-transition-new(name)` + +### 2.1.1 + +_January 28, 2023_ + +- Improve `types` declaration in `package.json` + +### 2.1.0 + +_January 19, 2023_ + +- Add support for `::slotted` +- Add support for `:host` +- Add support for `:host-context` + +### 2.0.2 + +_July 8, 2022_ + +- Fix case insensitive matching. + +### 2.0.1 + +_June 10, 2022_ + +- Fixed: Exception on `:nth-child` without arguments. [#439](https://github.com/csstools/postcss-plugins/issues/439) + +### 2.0.0 + +_June 4, 2022_ + +- Breaking: use only named exports instead of `default` +- Added: `compare(a, b)` function to compare selectors by specificity + +```diff +- `import selectorSpecificity from '@csstools/selector-specificity';` ++ `import { selectorSpecificity } from '@csstools/selector-specificity';` +``` + +### 1.0.0 + +_April 26, 2022_ + +- Initial version diff --git a/node_modules/@csstools/selector-specificity/LICENSE.md b/node_modules/@csstools/selector-specificity/LICENSE.md new file mode 100644 index 00000000..e8ae93b9 --- /dev/null +++ b/node_modules/@csstools/selector-specificity/LICENSE.md @@ -0,0 +1,18 @@ +MIT No Attribution (MIT-0) + +Copyright © CSSTools Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@csstools/selector-specificity/README.md b/node_modules/@csstools/selector-specificity/README.md new file mode 100644 index 00000000..3868d7d0 --- /dev/null +++ b/node_modules/@csstools/selector-specificity/README.md @@ -0,0 +1,57 @@ +# Selector Specificity + +[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/selector-specificity.svg" height="20">][npm-url] +[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] +[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] + +## Usage + +Add [Selector Specificity] to your project: + +```bash +npm install @csstools/selector-specificity --save-dev +``` + +```js +import parser from 'postcss-selector-parser'; +import { selectorSpecificity } from '@csstools/selector-specificity'; + +const selectorAST = parser().astSync('#foo:has(> .foo)'); +const specificity = selectorSpecificity(selectorAST); + +console.log(specificity.a); // 1 +console.log(specificity.b); // 1 +console.log(specificity.c); // 0 +``` + +_`selectorSpecificity` takes a single selector, not a list of selectors (not : `a, b, c`). +To compare or otherwise manipulate lists of selectors you need to call `selectorSpecificity` on each part._ + +### Comparing + +The package exports a utility function to compare two specificities. + +```js +import { selectorSpecificity, compare } from '@csstools/selector-specificity'; + +const s1 = selectorSpecificity(ast1); +const s2 = selectorSpecificity(ast2); +compare(s1, s2); // -1 | 0 | 1 +``` + +- if `s1 < s2` then `compare(s1, s2)` returns a negative number (`< 0`) +- if `s1 > s2` then `compare(s1, s2)` returns a positive number (`> 0`) +- if `s1 === s2` then `compare(s1, s2)` returns zero (`=== 0`) + +## Prior Art + +- [keeganstreet/specificity](https://github.com/keeganstreet/specificity) +- [bramus/specificity](https://github.com/bramus/specificity) + +For CSSTools we always use `postcss-selector-parser` and want to calculate specificity from this AST. + +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test +[discord]: https://discord.gg/bUadyRwkJS +[npm-url]: https://www.npmjs.com/package/@csstools/selector-specificity + +[Selector Specificity]: https://github.com/csstools/postcss-plugins/tree/main/packages/selector-specificity diff --git a/node_modules/@csstools/selector-specificity/dist/index.cjs b/node_modules/@csstools/selector-specificity/dist/index.cjs new file mode 100644 index 00000000..4633d0fc --- /dev/null +++ b/node_modules/@csstools/selector-specificity/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("postcss-selector-parser");const s=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(s,(e=>String.fromCharCode(e.charCodeAt(0)+32)))}function selectorSpecificity(s){if(!s)return{a:0,b:0,c:0};let t=0,c=0,i=0;if("universal"==s.type)return{a:0,b:0,c:0};if("id"===s.type)t+=1;else if("tag"===s.type)i+=1;else if("class"===s.type)c+=1;else if("attribute"===s.type)c+=1;else if(isPseudoElement(s))switch(toLowerCaseAZ(s.value)){case"::slotted":if(i+=1,s.nodes&&s.nodes.length>0){const e=specificityOfMostSpecificListItem(s.nodes);t+=e.a,c+=e.b,i+=e.c}break;case"::view-transition-group":case"::view-transition-image-pair":case"::view-transition-old":case"::view-transition-new":if(s.nodes&&1===s.nodes.length&&"selector"===s.nodes[0].type&&selectorNodeContainsOnlyUniversal(s.nodes[0]))return{a:0,b:0,c:0};i+=1;break;default:i+=1}else if(e.isPseudoClass(s))switch(toLowerCaseAZ(s.value)){case":-moz-any":case":-webkit-any":case":any":case":has":case":is":case":matches":case":not":if(s.nodes&&s.nodes.length>0){const e=specificityOfMostSpecificListItem(s.nodes);t+=e.a,c+=e.b,i+=e.c}break;case":where":break;case":nth-child":case":nth-last-child":if(c+=1,s.nodes&&s.nodes.length>0){const n=s.nodes[0].nodes.findIndex((e=>"tag"===e.type&&"of"===toLowerCaseAZ(e.value)));if(n>-1){const o=[e.selector({nodes:s.nodes[0].nodes.slice(n+1),value:""})];s.nodes.length>1&&o.push(...s.nodes.slice(1));const a=specificityOfMostSpecificListItem(o);t+=a.a,c+=a.b,i+=a.c}}break;case":local":case":global":s.nodes&&s.nodes.length>0&&s.nodes.forEach((e=>{const s=selectorSpecificity(e);t+=s.a,c+=s.b,i+=s.c}));break;case":host":case":host-context":if(c+=1,s.nodes&&s.nodes.length>0){const e=specificityOfMostSpecificListItem(s.nodes);t+=e.a,c+=e.b,i+=e.c}break;default:c+=1}else e.isContainer(s)&&s.nodes.length>0&&s.nodes.forEach((e=>{const s=selectorSpecificity(e);t+=s.a,c+=s.b,i+=s.c}));return{a:t,b:c,c:i}}function specificityOfMostSpecificListItem(e){let s={a:0,b:0,c:0};return e.forEach((e=>{const t=selectorSpecificity(e);t.a>s.a?s=t:t.a<s.a||(t.b>s.b?s=t:t.b<s.b||t.c>s.c&&(s=t))})),s}function isPseudoElement(s){return e.isPseudoElement(s)}function selectorNodeContainsOnlyUniversal(e){if(!e)return!1;if(!e.nodes)return!1;const s=e.nodes.filter((e=>"comment"!==e.type));return 1===s.length&&"universal"===s[0].type}exports.compare=function compare(e,s){return e.a===s.a?e.b===s.b?e.c-s.c:e.b-s.b:e.a-s.a},exports.selectorSpecificity=selectorSpecificity; diff --git a/node_modules/@csstools/selector-specificity/dist/index.d.ts b/node_modules/@csstools/selector-specificity/dist/index.d.ts new file mode 100644 index 00000000..f92ce6d8 --- /dev/null +++ b/node_modules/@csstools/selector-specificity/dist/index.d.ts @@ -0,0 +1,8 @@ +import type { Node } from 'postcss-selector-parser'; +export type Specificity = { + a: number; + b: number; + c: number; +}; +export declare function compare(s1: Specificity, s2: Specificity): number; +export declare function selectorSpecificity(node: Node): Specificity; diff --git a/node_modules/@csstools/selector-specificity/dist/index.mjs b/node_modules/@csstools/selector-specificity/dist/index.mjs new file mode 100644 index 00000000..8ac79c74 --- /dev/null +++ b/node_modules/@csstools/selector-specificity/dist/index.mjs @@ -0,0 +1 @@ +import e from"postcss-selector-parser";const s=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(s,(e=>String.fromCharCode(e.charCodeAt(0)+32)))}function compare(e,s){return e.a===s.a?e.b===s.b?e.c-s.c:e.b-s.b:e.a-s.a}function selectorSpecificity(s){if(!s)return{a:0,b:0,c:0};let t=0,c=0,i=0;if("universal"==s.type)return{a:0,b:0,c:0};if("id"===s.type)t+=1;else if("tag"===s.type)i+=1;else if("class"===s.type)c+=1;else if("attribute"===s.type)c+=1;else if(isPseudoElement(s))switch(toLowerCaseAZ(s.value)){case"::slotted":if(i+=1,s.nodes&&s.nodes.length>0){const e=specificityOfMostSpecificListItem(s.nodes);t+=e.a,c+=e.b,i+=e.c}break;case"::view-transition-group":case"::view-transition-image-pair":case"::view-transition-old":case"::view-transition-new":if(s.nodes&&1===s.nodes.length&&"selector"===s.nodes[0].type&&selectorNodeContainsOnlyUniversal(s.nodes[0]))return{a:0,b:0,c:0};i+=1;break;default:i+=1}else if(e.isPseudoClass(s))switch(toLowerCaseAZ(s.value)){case":-moz-any":case":-webkit-any":case":any":case":has":case":is":case":matches":case":not":if(s.nodes&&s.nodes.length>0){const e=specificityOfMostSpecificListItem(s.nodes);t+=e.a,c+=e.b,i+=e.c}break;case":where":break;case":nth-child":case":nth-last-child":if(c+=1,s.nodes&&s.nodes.length>0){const n=s.nodes[0].nodes.findIndex((e=>"tag"===e.type&&"of"===toLowerCaseAZ(e.value)));if(n>-1){const o=[e.selector({nodes:s.nodes[0].nodes.slice(n+1),value:""})];s.nodes.length>1&&o.push(...s.nodes.slice(1));const a=specificityOfMostSpecificListItem(o);t+=a.a,c+=a.b,i+=a.c}}break;case":local":case":global":s.nodes&&s.nodes.length>0&&s.nodes.forEach((e=>{const s=selectorSpecificity(e);t+=s.a,c+=s.b,i+=s.c}));break;case":host":case":host-context":if(c+=1,s.nodes&&s.nodes.length>0){const e=specificityOfMostSpecificListItem(s.nodes);t+=e.a,c+=e.b,i+=e.c}break;default:c+=1}else e.isContainer(s)&&s.nodes.length>0&&s.nodes.forEach((e=>{const s=selectorSpecificity(e);t+=s.a,c+=s.b,i+=s.c}));return{a:t,b:c,c:i}}function specificityOfMostSpecificListItem(e){let s={a:0,b:0,c:0};return e.forEach((e=>{const t=selectorSpecificity(e);t.a>s.a?s=t:t.a<s.a||(t.b>s.b?s=t:t.b<s.b||t.c>s.c&&(s=t))})),s}function isPseudoElement(s){return e.isPseudoElement(s)}function selectorNodeContainsOnlyUniversal(e){if(!e)return!1;if(!e.nodes)return!1;const s=e.nodes.filter((e=>"comment"!==e.type));return 1===s.length&&"universal"===s[0].type}export{compare,selectorSpecificity}; diff --git a/node_modules/@csstools/selector-specificity/dist/to-lower-case-a-z.d.ts b/node_modules/@csstools/selector-specificity/dist/to-lower-case-a-z.d.ts new file mode 100644 index 00000000..396b252e --- /dev/null +++ b/node_modules/@csstools/selector-specificity/dist/to-lower-case-a-z.d.ts @@ -0,0 +1 @@ +export declare function toLowerCaseAZ(x: string): string; diff --git a/node_modules/@csstools/selector-specificity/package.json b/node_modules/@csstools/selector-specificity/package.json new file mode 100644 index 00000000..36e08389 --- /dev/null +++ b/node_modules/@csstools/selector-specificity/package.json @@ -0,0 +1,75 @@ +{ + "name": "@csstools/selector-specificity", + "description": "Determine selector specificity with postcss-selector-parser", + "version": "3.0.0", + "contributors": [ + { + "name": "Antonio Laguna", + "email": "antonio@laguna.es", + "url": "https://antonio.laguna.es" + }, + { + "name": "Romain Menke", + "email": "romainmenke@gmail.com" + } + ], + "license": "MIT-0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "engines": { + "node": "^14 || ^16 || >=18" + }, + "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" + } + }, + "files": [ + "CHANGELOG.md", + "LICENSE.md", + "README.md", + "dist" + ], + "peerDependencies": { + "postcss-selector-parser": "^6.0.13" + }, + "devDependencies": { + "postcss-selector-parser": "^6.0.13" + }, + "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/index.mjs && node ./test/_import.mjs && node ./test/_require.cjs" + }, + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/selector-specificity#readme", + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "packages/selector-specificity" + }, + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "keywords": [ + "css", + "postcss-selector-parser", + "specificity" + ], + "volta": { + "extends": "../../package.json" + } +} |
