diff options
Diffstat (limited to 'node_modules/postcss-image-set-function')
7 files changed, 0 insertions, 290 deletions
diff --git a/node_modules/postcss-image-set-function/CHANGELOG.md b/node_modules/postcss-image-set-function/CHANGELOG.md deleted file mode 100644 index 4baca9a9..00000000 --- a/node_modules/postcss-image-set-function/CHANGELOG.md +++ /dev/null @@ -1,21 +0,0 @@ -# Changes to PostCSS image-set() Function - -### 6.0.3 - -_February 19, 2024_ - -- Reuse code with `@csstools/utilities` - -### 6.0.2 - -_December 15, 2023_ - -- Fix type definitions - -### 6.0.1 - -_September 18, 2023_ - -- Improve performance - -[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-image-set-function/CHANGELOG.md) diff --git a/node_modules/postcss-image-set-function/LICENSE.md b/node_modules/postcss-image-set-function/LICENSE.md deleted file mode 100644 index e8ae93b9..00000000 --- a/node_modules/postcss-image-set-function/LICENSE.md +++ /dev/null @@ -1,18 +0,0 @@ -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/postcss-image-set-function/README.md b/node_modules/postcss-image-set-function/README.md deleted file mode 100644 index 56aee6cc..00000000 --- a/node_modules/postcss-image-set-function/README.md +++ /dev/null @@ -1,164 +0,0 @@ -# PostCSS image-set() Function [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" 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] -<br><br> -[<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/image-set-function.svg" height="20">][css-url] -[![CSS Standard Status][css-img]][css-url] - -[PostCSS image-set() Function] lets you display resolution-dependent images -using the `image-set()` function in CSS, following the [CSS Images] -specification. - -[](https://caniuse.com/#feat=css-image-set) - -```pcss -.example { - background-image: image-set( - url(img.png) 1x, - url(img@2x.png) 2x, - url(img@print.png) 600dpi - ); -} - -/* becomes */ - -.example { - background-image: url(img.png); -} - -@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { - .example { - background-image: url(img@2x.png); - } -} - - -@media (-webkit-min-device-pixel-ratio: 6.25), (min-resolution: 600dpi) { - .example { - background-image: url(my@print.png); - } -} - -.example { - background-image: image-set( - url(img.png) 1x, - url(img@2x.png) 2x, - url(img@print.png) 600dpi - ); -} -``` - -## Usage - -Add [PostCSS image-set() Function] to your project: - -```bash -npm install postcss-image-set-function --save-dev -``` - -Use [PostCSS image-set() Function] as a [PostCSS] plugin: - -```js -const postcss = require('postcss'); -const postcssImageSetFunction = require('postcss-image-set-function'); - -postcss([ - postcssImageSetFunction(/* pluginOptions */) -]).process(YOUR_CSS /*, processOptions */); -``` - -[PostCSS image-set() 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 declaration using -`image-set()` is preserved. By default, it is preserved. - -```js -postcssImageSetFunction({ preserve: false }) -``` - -```pcss -.example { - background-image: image-set( - url(img.png) 1x, - url(img@2x.png) 2x, - url(img@print.png) 600dpi - ); -} - -/* becomes */ - -@media (-webkit-min-device-pixel-ratio: 1), (min-resolution: 96dpi) { - .example { - background-image: url(img.png); - } -} - -@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { - .example { - background-image: url(img@2x.png); - } -} - - -@media (-webkit-min-device-pixel-ratio: 6.25), (min-resolution: 600dpi) { - .example { - background-image: url(my@print.png); - } -} -``` - -### onInvalid - -The `onInvalid` option determines how invalid usage of `image-set()` should be -handled. By default, invalid usages of `image-set()` are ignored. -They can be configured to emit a warning with `warn` or throw an exception with `throw`. - -```js -postcssImageSetFunction({ onInvalid: 'warn' }) // warn on invalid usages -``` - -```js -postcssImageSetFunction({ onInvalid: 'throw' }) // throw on invalid usages -``` - -## Image Resolution - -The `image-set()` function allows an author to provide multiple resolutions of -an image and let the browser decide which is most appropriate in a given -situation. The `image-set()` also never fails to choose an image; the -`<resolution>` just helps determine which of the images is chosen. - -Since this plugin is not a browser, the image options are sorted by device -pixel ratio and the lowest ratio is used as the default, while the remaining -images are pushed behind media queries. - -Therefore, this plugin can only approximate native browser behavior. While -images should typically match the resolution as the device they’re being viewed -in, other factors can affect the chosen image. For example, if the user is on a -slow mobile connection, the browser may prefer to select a lower-res image -rather than wait for a larger, resolution-matching image to load. - -[cli-img]: https://github.com/csstools/postcss-plugins/workflows/test/badge.svg -[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test -[css-img]: https://cssdb.org/images/badges/image-set-function.svg -[css-url]: https://cssdb.org/#image-set-function -[discord]: https://discord.gg/bUadyRwkJS -[npm-img]: https://img.shields.io/npm/v/postcss-image-set-function.svg -[npm-url]: https://www.npmjs.com/package/postcss-image-set-function - -[CSS Images]: https://drafts.csswg.org/css-images-4/#image-set-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 image-set() Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-image-set-function diff --git a/node_modules/postcss-image-set-function/dist/index.cjs b/node_modules/postcss-image-set-function/dist/index.cjs deleted file mode 100644 index a2ab6d1f..00000000 --- a/node_modules/postcss-image-set-function/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser"),t=require("@csstools/utilities");const n=/^(cross-fade|image|(repeating-)?(conic|linear|radial)-gradient|url|var)$/i;function getImage(t){return!(!t||!t.type)&&("string"===t.type?"url("+e.stringify(t)+")":!("function"!==t.type||!n.test(t.value))&&e.stringify(t))}const i=new Map([["dpcm",2.54],["dpi",1],["dppx",96],["x",96]]);function getMedia(e,t,n){if("boolean"==typeof e)return!1;const i=Math.floor(e/96*100)/100;return t.atRule({name:"media",params:`(-webkit-min-device-pixel-ratio: ${i}), (min-resolution: ${e}dpi)`,source:n.source})}function getMediaDPI(t){if(!t)return!1;if("word"!==t.type)return!1;if(!isNumericNode(t))return!1;const n=e.unit(t.value);if(!n)return!1;const r=i.get(n.unit.toLowerCase());return!!r&&Number(n.number)*r}function isNumericNode(t){if(!t||!t.value)return!1;try{return!1!==e.unit(t.value)}catch(e){return!1}}const handleInvalidation=(e,t,n)=>{if("warn"===e.oninvalid)e.decl.warn(e.result,t,{word:String(n)});else if("throw"===e.oninvalid)throw e.decl.error(t,{word:String(n)})},processImageSet=(t,n,i)=>{const r=n.parent;if(!r)return;const o=new Map,s=n.value;for(let r=0;r<t.length;r++){const{imageSetFunction:l,imageSetOptionNodes:u}=t[r],c=new Map,f=u.length;let p=-1;for(;p<f;){const t=p<0||(a=u[p],"div"===Object(a).type&&","===Object(a).value),r=getImage(u[p+1]),f=getMediaDPI(u[p+2]),d=getMedia(f,i.postcss,n);if(!t)return void handleInvalidation(i,"expected a comma",e.stringify(u));if(!r)return void handleInvalidation(i,"unexpected image",e.stringify(u));if(!d||!f||c.has(f))return void handleInvalidation(i,"unexpected resolution",e.stringify(u));if(c.set(f,d),o.has(f)){const t=o.get(f);t.value=t.value.replace(e.stringify(l),r.trim()),o.set(f,t)}else o.set(f,{atRule:d,value:s.replace(e.stringify(l),r.trim())});p+=3}}var a;for(const{atRule:e,value:t}of o.values()){const i=r.clone().removeAll(),o=n.clone({value:t});i.append(o),e.append(i)}const l=Array.from(o.keys()).sort(((e,t)=>e-t)),u=l.map((e=>o.get(e)?.atRule)).filter((e=>!!e));if(!u.length)return;const c=o.get(l[0])?.value;if(!c)return;const f=u.slice(1);f.length&&r.after(f),n.cloneBefore({value:c.trim()}),i.preserve||(n.remove(),r.nodes?.length||r.remove())},r=/(^|[^\w-])(-webkit-)?image-set\(/i,o=/^(-webkit-)?image-set$/i,creator=n=>{const i=!("preserve"in Object(n))||Boolean(n?.preserve),s="onInvalid"in Object(n)?n?.onInvalid:"ignore";if("oninvalid"in Object(n))throw new Error('"oninvalid" was changed to "onInvalid" to match other plugins with similar options');return{postcssPlugin:"postcss-image-set-function",Declaration(n,{result:a,postcss:l}){const u=n.value;if(!r.test(u))return;if(t.hasFallback(n))return;let c;try{c=e(u)}catch(e){n.warn(a,`Failed to parse value '${u}' as an image-set function. Leaving the original value intact.`)}if(void 0===c)return;const f=[];c.walk((t=>{if("function"!==t.type)return;if(!o.test(t.value))return;let i=!1;if(e.walk(t.nodes,(e=>{"function"===e.type&&o.test(e.value)&&(i=!0)})),i)return handleInvalidation({decl:n,oninvalid:s,result:a},"nested image-set functions are not allowed",e.stringify(t)),!1;const r=t.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));f.push({imageSetFunction:t,imageSetOptionNodes:r})})),processImageSet(f,n,{decl:n,oninvalid:s,preserve:i,result:a,postcss:l})}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/postcss-image-set-function/dist/index.d.ts b/node_modules/postcss-image-set-function/dist/index.d.ts deleted file mode 100644 index 5eb630f7..00000000 --- a/node_modules/postcss-image-set-function/dist/index.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { PluginCreator } from 'postcss'; - -declare const creator: PluginCreator<pluginOptions>; -export default creator; - -/** postcss-image-set-function plugin options */ -export declare type pluginOptions = { - /** Preserve the original notation. default: true */ - preserve?: boolean; - /** - * Determine how invalid usage of `image-set()` should be handled. - * By default, invalid usages of `image-set()` are ignored. - * They can be configured to emit a warning with `warn` or throw an exception with `throw`. - * default: 'ignore' - */ - onInvalid?: 'warn' | 'throw' | 'ignore' | false; -}; - -export { } diff --git a/node_modules/postcss-image-set-function/dist/index.mjs b/node_modules/postcss-image-set-function/dist/index.mjs deleted file mode 100644 index c091d01a..00000000 --- a/node_modules/postcss-image-set-function/dist/index.mjs +++ /dev/null @@ -1 +0,0 @@ -import e from"postcss-value-parser";import{hasFallback as t}from"@csstools/utilities";const n=/^(cross-fade|image|(repeating-)?(conic|linear|radial)-gradient|url|var)$/i;function getImage(t){return!(!t||!t.type)&&("string"===t.type?"url("+e.stringify(t)+")":!("function"!==t.type||!n.test(t.value))&&e.stringify(t))}const i=new Map([["dpcm",2.54],["dpi",1],["dppx",96],["x",96]]);function getMedia(e,t,n){if("boolean"==typeof e)return!1;const i=Math.floor(e/96*100)/100;return t.atRule({name:"media",params:`(-webkit-min-device-pixel-ratio: ${i}), (min-resolution: ${e}dpi)`,source:n.source})}function getMediaDPI(t){if(!t)return!1;if("word"!==t.type)return!1;if(!isNumericNode(t))return!1;const n=e.unit(t.value);if(!n)return!1;const r=i.get(n.unit.toLowerCase());return!!r&&Number(n.number)*r}function isNumericNode(t){if(!t||!t.value)return!1;try{return!1!==e.unit(t.value)}catch(e){return!1}}const handleInvalidation=(e,t,n)=>{if("warn"===e.oninvalid)e.decl.warn(e.result,t,{word:String(n)});else if("throw"===e.oninvalid)throw e.decl.error(t,{word:String(n)})},processImageSet=(t,n,i)=>{const r=n.parent;if(!r)return;const o=new Map,s=n.value;for(let r=0;r<t.length;r++){const{imageSetFunction:l,imageSetOptionNodes:u}=t[r],c=new Map,f=u.length;let p=-1;for(;p<f;){const t=p<0||(a=u[p],"div"===Object(a).type&&","===Object(a).value),r=getImage(u[p+1]),f=getMediaDPI(u[p+2]),d=getMedia(f,i.postcss,n);if(!t)return void handleInvalidation(i,"expected a comma",e.stringify(u));if(!r)return void handleInvalidation(i,"unexpected image",e.stringify(u));if(!d||!f||c.has(f))return void handleInvalidation(i,"unexpected resolution",e.stringify(u));if(c.set(f,d),o.has(f)){const t=o.get(f);t.value=t.value.replace(e.stringify(l),r.trim()),o.set(f,t)}else o.set(f,{atRule:d,value:s.replace(e.stringify(l),r.trim())});p+=3}}var a;for(const{atRule:e,value:t}of o.values()){const i=r.clone().removeAll(),o=n.clone({value:t});i.append(o),e.append(i)}const l=Array.from(o.keys()).sort(((e,t)=>e-t)),u=l.map((e=>o.get(e)?.atRule)).filter((e=>!!e));if(!u.length)return;const c=o.get(l[0])?.value;if(!c)return;const f=u.slice(1);f.length&&r.after(f),n.cloneBefore({value:c.trim()}),i.preserve||(n.remove(),r.nodes?.length||r.remove())},r=/(^|[^\w-])(-webkit-)?image-set\(/i,o=/^(-webkit-)?image-set$/i,creator=n=>{const i=!("preserve"in Object(n))||Boolean(n?.preserve),s="onInvalid"in Object(n)?n?.onInvalid:"ignore";if("oninvalid"in Object(n))throw new Error('"oninvalid" was changed to "onInvalid" to match other plugins with similar options');return{postcssPlugin:"postcss-image-set-function",Declaration(n,{result:a,postcss:l}){const u=n.value;if(!r.test(u))return;if(t(n))return;let c;try{c=e(u)}catch(e){n.warn(a,`Failed to parse value '${u}' as an image-set function. Leaving the original value intact.`)}if(void 0===c)return;const f=[];c.walk((t=>{if("function"!==t.type)return;if(!o.test(t.value))return;let i=!1;if(e.walk(t.nodes,(e=>{"function"===e.type&&o.test(e.value)&&(i=!0)})),i)return handleInvalidation({decl:n,oninvalid:s,result:a},"nested image-set functions are not allowed",e.stringify(t)),!1;const r=t.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));f.push({imageSetFunction:t,imageSetOptionNodes:r})})),processImageSet(f,n,{decl:n,oninvalid:s,preserve:i,result:a,postcss:l})}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/postcss-image-set-function/package.json b/node_modules/postcss-image-set-function/package.json deleted file mode 100644 index 7e080f58..00000000 --- a/node_modules/postcss-image-set-function/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "postcss-image-set-function", - "description": "Display resolution-dependent images using the image-set() function in CSS", - "version": "6.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" - }, - "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.mjs", - "exports": { - ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } - } - }, - "files": [ - "CHANGELOG.md", - "LICENSE.md", - "README.md", - "dist" - ], - "dependencies": { - "@csstools/utilities": "^1.0.0", - "postcss-value-parser": "^4.2.0" - }, - "peerDependencies": { - "postcss": "^8.4" - }, - "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-image-set-function#readme", - "repository": { - "type": "git", - "url": "https://github.com/csstools/postcss-plugins.git", - "directory": "plugins/postcss-image-set-function" - }, - "bugs": "https://github.com/csstools/postcss-plugins/issues", - "keywords": [ - "background", - "css", - "image", - "image-set", - "negotiation", - "optimization", - "postcss", - "postcss-plugin", - "resolution", - "responsive" - ] -} |
