diff options
Diffstat (limited to 'node_modules/postcss-custom-media')
| -rw-r--r-- | node_modules/postcss-custom-media/CHANGELOG.md | 30 | ||||
| -rw-r--r-- | node_modules/postcss-custom-media/LICENSE.md | 21 | ||||
| -rw-r--r-- | node_modules/postcss-custom-media/README.md | 196 | ||||
| -rw-r--r-- | node_modules/postcss-custom-media/dist/index.cjs | 1 | ||||
| -rw-r--r-- | node_modules/postcss-custom-media/dist/index.d.ts | 12 | ||||
| -rw-r--r-- | node_modules/postcss-custom-media/dist/index.mjs | 1 | ||||
| -rw-r--r-- | node_modules/postcss-custom-media/package.json | 88 |
7 files changed, 0 insertions, 349 deletions
diff --git a/node_modules/postcss-custom-media/CHANGELOG.md b/node_modules/postcss-custom-media/CHANGELOG.md deleted file mode 100644 index 17435849..00000000 --- a/node_modules/postcss-custom-media/CHANGELOG.md +++ /dev/null @@ -1,30 +0,0 @@ -# Changes to PostCSS Custom Media - -### 10.0.8 - -_July 6, 2024_ - -- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.4.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#241) (patch) -- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.7.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#271) (patch) -- Updated [`@csstools/cascade-layer-name-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser) to [`1.0.13`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser/CHANGELOG.md#1013) (patch) -- Updated [`@csstools/media-query-list-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser) to [`2.1.13`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser/CHANGELOG.md#2113) (patch) - -### 10.0.7 - -_June 29, 2024_ - -- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.3.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#232) (patch) -- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.7.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#270) (minor) -- Updated [`@csstools/cascade-layer-name-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser) to [`1.0.12`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser/CHANGELOG.md#1012) (patch) -- Updated [`@csstools/media-query-list-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser) to [`2.1.12`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser/CHANGELOG.md#2112) (patch) - -### 10.0.6 - -_May 4, 2024_ - -- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#231) (patch) -- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.6.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#263) (patch) -- Updated [`@csstools/cascade-layer-name-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser) to [`1.0.11`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser/CHANGELOG.md#1011) (patch) -- Updated [`@csstools/media-query-list-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser) to [`2.1.11`](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser/CHANGELOG.md#2111) (patch) - -[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-custom-media/CHANGELOG.md) diff --git a/node_modules/postcss-custom-media/LICENSE.md b/node_modules/postcss-custom-media/LICENSE.md deleted file mode 100644 index 6d704708..00000000 --- a/node_modules/postcss-custom-media/LICENSE.md +++ /dev/null @@ -1,21 +0,0 @@ -# The MIT License (MIT) - -Copyright © 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/postcss-custom-media/README.md b/node_modules/postcss-custom-media/README.md deleted file mode 100644 index 0e6c1e87..00000000 --- a/node_modules/postcss-custom-media/README.md +++ /dev/null @@ -1,196 +0,0 @@ -# PostCSS Custom Media [<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/postcss-custom-media.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]<br><br>[<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/custom-media-queries.svg" height="20">][css-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/custom-media-queries.svg" height="20">][css-url] - -```bash -npm install postcss-custom-media --save-dev -``` - -[PostCSS Custom Media] lets you define `@custom-media` in CSS following the [Custom Media Specification]. - -```pcss -@custom-media --small-viewport (max-width: 30em); - -@media (--small-viewport) { - /* styles for small viewport */ -} - -/* becomes */ - -@media (max-width: 30em) { - /* styles for small viewport */ -} -``` - -## `true` and `false` - -With `@custom-media` you can use the constants `true` and `false`. -These are especially handy when debugging. - -If you are unsure how your page is affected when a certain media query matches or not you can use these, to quickly toggle the results. -This plugin downgrades these queries to something that works in all browsers. - -Quickly check the result as if the query matches: - -```pcss -@custom-media --small-viewport true; - -@media (--small-viewport) { - /* styles for small viewport */ -} - -/* becomes */ - -@media (max-color:2147477350) { - /* styles for small viewport */ -} -``` - -Quickly check the result as if the query does not match: - -```pcss -@custom-media --small-viewport false; - -@media (--small-viewport) { - /* styles for small viewport */ -} - -/* becomes */ - -@media (color:2147477350) { - /* styles for small viewport */ -} -``` - -## logical evaluation of complex media queries - -It is impossible to accurately and correctly resolve complex `@custom-media` queries -as these depend on the browser the queries will eventually run in. - -_Some of these queries will have only one possible outcome but we have to account for all possible queries in this plugin._ - -> [!NOTE] -> When handling complex media queries you will see that your CSS is doubled for each level of complexity.<br> -> GZIP works great to de-dupe this but having a lot of complex media queries will have a performance impact. - -An example of a very complex (and artificial) use-case : - -```pcss - -@custom-media --a-complex-query tty and (min-width: 300px); - -@media not screen and ((not (--a-complex-query)) or (color)) { - /* Your CSS */ -} - -/* becomes */ - - -@media tty and (min-width: 300px) { -@media not screen and ((not (max-color:2147477350)) or (color)) { - /* Your CSS */ -} -} -@media not tty and (min-width: 300px) { -@media not screen and ((not (color:2147477350)) or (color)) { - /* Your CSS */ -} -} -``` - -## Usage - -Add [PostCSS Custom Media] to your project: - -```bash -npm install postcss postcss-custom-media --save-dev -``` - -Use it as a [PostCSS] plugin: - -```js -const postcss = require('postcss'); -const postcssCustomMedia = require('postcss-custom-media'); - -postcss([ - postcssCustomMedia(/* pluginOptions */) -]).process(YOUR_CSS /*, processOptions */); -``` - -[PostCSS Custom Media] 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 -postcssCustomMedia({ preserve: true }) -``` - -```pcss -@custom-media --small-viewport (max-width: 30em); - -@media (--small-viewport) { - /* styles for small viewport */ -} - -/* becomes */ - -@custom-media --small-viewport (max-width: 30em); - -@media (max-width: 30em) { - /* styles for small viewport */ -} - -@media (--small-viewport) { - /* styles for small viewport */ -} -``` - -## Modular CSS Processing - -If you're using Modular CSS such as, CSS Modules, `postcss-loader` or `vanilla-extract` to name a few, you'll probably -notice that custom media queries are not being resolved. This happens because each file is processed separately so -unless you import the custom media query definitions in each file, they won't be resolved. - -To overcome this, we recommend using the [PostCSS Global Data](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-global-data#readme) -plugin which allows you to pass a list of files that will be globally available. The plugin won't inject any extra code -in the output but will provide the context needed to resolve custom media queries. - -For it to run it needs to be placed before the [PostCSS Custom Media] plugin. - -```js -const postcss = require('postcss'); -const postcssCustomMedia = require('postcss-custom-media'); -const postcssGlobalData = require('@csstools/postcss-global-data'); - -postcss([ - postcssGlobalData({ - files: [ - 'path/to/your/custom-media-queries.css' - ] - }), - postcssCustomMedia(/* pluginOptions */) -]).process(YOUR_CSS /*, processOptions */); -``` - -[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test -[css-url]: https://cssdb.org/#custom-media-queries -[discord]: https://discord.gg/bUadyRwkJS -[npm-url]: https://www.npmjs.com/package/postcss-custom-media - -[PostCSS]: https://github.com/postcss/postcss -[PostCSS Custom Media]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-custom-media -[Custom Media Specification]: https://www.w3.org/TR/mediaqueries-5/#at-ruledef-custom-media diff --git a/node_modules/postcss-custom-media/dist/index.cjs b/node_modules/postcss-custom-media/dist/index.cjs deleted file mode 100644 index 49927c98..00000000 --- a/node_modules/postcss-custom-media/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/cascade-layer-name-parser"),r=require("@csstools/css-tokenizer"),t=require("@csstools/media-query-list-parser");const n=e.parse("csstools-implicit-layer")[0];function collectCascadeLayerOrder(r){const t=new Map,o=new Map,a=[];r.walkAtRules((r=>{if("layer"!==r.name.toLowerCase())return;{let e=r.parent;for(;e;){if("atrule"!==e.type||"layer"!==e.name.toLowerCase()){if(e===r.root())break;return}e=e.parent}}let s;if(r.nodes)s=normalizeLayerName(r.params,1);else{if(!r.params.trim())return;s=r.params}let i=e.parse(s);if(i?.length){{let e=r.parent;for(;e&&"atrule"===e.type&&"layer"===e.name.toLowerCase();){const r=o.get(e);r?(i=i.map((e=>r.concat(e))),e=e.parent):e=e.parent}}if(e.addLayerToModel(a,i),r.nodes){const e=i[0].concat(n);t.set(r,e),o.set(r,i[0])}}}));for(const r of t.values())e.addLayerToModel(a,[r]);const s=new WeakMap;for(const[e,r]of t)s.set(e,a.findIndex((e=>r.equal(e))));return s}function normalizeLayerName(e,r){return e.trim()?e:"csstools-anon-layer--"+r++}const o=new Set(["scope","container","layer"]);function isProcessableCustomMediaRule(e){if("custom-media"!==e.name.toLowerCase())return!1;if(!e.params||!e.params.includes("--"))return!1;if(e.nodes&&e.nodes.length>0)return!1;let r=e.parent;for(;r;){if("atrule"===r.type&&!o.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}function removeCyclicReferences(e,r){const t=new Set;for(;e.size>0;){const n=findCyclicNode(Array.from(e.keys()),r);if(!n)return t;e.delete(n),t.add(n),r=r.filter((e=>-1===e.indexOf(n)))}return t}function findCyclicNode(e,r){let t=e.length;const n=new Array(t),o={};let a=t;const s=makeOutgoingEdges(r),i=makeNodesHash(e);for(;a--;)if(!o[a]){const r=visit(e[a],a,new Set);if(!r)continue;return r}function visit(e,r,a){if(a.has(e))return e;if(!i.has(e))return;if(o[r])return;o[r]=!0;const l=Array.from(s.get(e)||new Set);if(r=l.length){a.add(e);do{const e=l[--r],t=visit(e,i.get(e),a);if(t)return t}while(r);a.delete(e)}n[--t]=e}}function makeOutgoingEdges(e){const r=new Map;for(let t=0,n=e.length;t<n;t++){const n=e[t];r.has(n[0])||r.set(n[0],new Set),r.has(n[1])||r.set(n[1],new Set),r.get(n[0]).add(n[1])}return r}function makeNodesHash(e){const r=new Map;for(let t=0,n=e.length;t<n;t++)r.set(e[t],t);return r}function atMediaParamsTokens(e){const t=r.tokenizer({css:e},{onParseError:()=>{throw new Error(`Unable to parse media query "${e}"`)}}),n=[];for(;!t.endOfFile();)n.push(t.nextToken());return n}const a=[[r.TokenType.Ident,"max-color",0,0,{value:"max-color"}],[r.TokenType.Colon,":",0,0,void 0],[r.TokenType.Number,"2147477350",0,0,{value:2147477350,type:r.NumberType.Integer}]],s=[[r.TokenType.Ident,"color",0,0,{value:"color"}],[r.TokenType.Colon,":",0,0,void 0],[r.TokenType.Number,"2147477350",0,0,{value:2147477350,type:r.NumberType.Integer}]];function replaceTrueAndFalseTokens(e){let t,n=[];for(let o=0;o<e.length;o++)if(!r.isTokenWhiteSpaceOrComment(e[o])){if(r.isTokenIdent(e[o])){const r=e[o];if("true"===r[4].value.toLowerCase()){t="true",n=e.slice(o+1);break}if("false"===r[4].value.toLowerCase()){t="false",n=e.slice(o+1);break}}return e}if(!t)return e;for(let t=0;t<n.length;t++)if(!r.isTokenWhiteSpaceOrComment(n[t]))return e;return"true"===t?[[r.TokenType.Whitespace," ",0,0,void 0],[r.TokenType.OpenParen,"(",0,0,void 0],...a,[r.TokenType.CloseParen,")",0,0,void 0]]:[[r.TokenType.Whitespace," ",0,0,void 0],[r.TokenType.OpenParen,"(",0,0,void 0],...s,[r.TokenType.CloseParen,")",0,0,void 0]]}function parseCustomMedia(e){const n=atMediaParamsTokens(e),o=new Set;let a="",s=n;for(let e=0;e<n.length;e++)if(!r.isTokenWhiteSpaceOrComment(n[e])){if(r.isTokenIdent(n[e])){const r=n[e];if(r[4].value.startsWith("--")){a=r[4].value,s=n.slice(e+1);break}}return!1}for(let e=0;e<s.length;e++)if(r.isTokenIdent(s[e])){const r=s[e];r[4].value.startsWith("--")&&o.add(r[4].value)}s=replaceTrueAndFalseTokens(s);const i=t.parseFromTokens(r.cloneTokens(s),{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${r.stringify(...s)}"`)}}),l=t.parseFromTokens(r.cloneTokens(s),{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${r.stringify(...s)}"`)}});for(let e=0;e<l.length;e++)l[e]=l[e].negateQuery();return{name:a,truthy:i,falsy:l,dependencies:Array.from(o).map((e=>[a,e]))}}function getCustomMedia(e,r,t){const n=new Map,o=new Map,a=[],s=collectCascadeLayerOrder(e);e.walkAtRules((e=>{if(!isProcessableCustomMediaRule(e))return;const r=parseCustomMedia(e.params);if(!r)return;if(0===r.truthy.length)return;const i=(u=s,(l=e).parent&&"atrule"===l.parent.type&&"layer"===l.parent.name.toLowerCase()?u.has(l.parent)?u.get(l.parent)+1:0:1e7);var l,u;const c=o.get(r.name)??-1;if(i&&i>=c&&(o.set(r.name,i),n.set(r.name,{truthy:r.truthy,falsy:r.falsy}),a.push(...r.dependencies)),!t.preserve){const r=e.parent;e.remove(),removeEmptyAncestorBlocks(r)}}));const i=removeCyclicReferences(n,a);for(const t of i.values())e.warn(r,`@custom-media rules have cyclic dependencies for "${t}"`);return n}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(r.nodes&&r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function transformAtMediaListTokens(e,r){const n=t.parse(e,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${e}"`)}}),o=n.map((e=>e.toString()));for(let e=0;e<n.length;e++){const t=n[e],a=o[e];{const n=transformSimpleMediaQuery(t,r);if(n&&n.replaceWith!==a)return o.map(((r,t)=>t===e?n:{replaceWith:r}))}const s=transformComplexMediaQuery(t,r);if(s&&0!==s.length&&s[0].replaceWith!==a)return o.flatMap(((r,t)=>t===e?s:[{replaceWith:r}]))}return[]}function transformSimpleMediaQuery(e,r){if(!mediaQueryIsSimple(e))return null;let n=null;return e.walk((e=>{const o=e.node;if(!t.isMediaFeatureBoolean(o))return;const a=o.getName();if(!a.startsWith("--"))return!1;const s=r.get(a);return s?(n={replaceWith:s.truthy.map((e=>e.toString().trim())).join(",")},!1):void 0})),n}function transformComplexMediaQuery(e,r){let n=[];return e.walk((o=>{const i=o.node;if(!t.isMediaFeatureBoolean(i))return;const l=o.parent;if(!t.isMediaFeature(l))return;const u=i.getName();if(!u.startsWith("--"))return!1;const c=r.get(u);if(c){if(1===c.truthy.length&&mediaQueryIsSimple(c.truthy[0])){let r=null;if(c.truthy[0].walk((e=>{if(t.isMediaFeature(e.node))return r=e.node,!1})),r&&r.feature)return l.feature=r.feature,n=[{replaceWith:e.toString()}],!1}const r=t.newMediaFeaturePlain(a[0][4].value,a[2]);l.feature=r.feature;const o=e.toString(),i=t.newMediaFeaturePlain(s[0][4].value,s[2]);l.feature=i.feature;const u=e.toString();return n=[{replaceWith:o,encapsulateWith:c.truthy.map((e=>e.toString().trim())).join(",")},{replaceWith:u,encapsulateWith:c.falsy.map((e=>e.toString().trim())).join(",")}],!1}})),n}function mediaQueryIsSimple(e){if(t.isMediaQueryInvalid(e))return!1;if(t.isMediaQueryWithType(e))return!1;let r=!0;return e.walk((e=>{if(t.isMediaAnd(e.node)||t.isMediaOr(e.node)||t.isMediaNot(e.node)||t.isMediaConditionList(e.node)||t.isGeneralEnclosed(e.node))return r=!1,!1})),r}const creator=e=>{const r=e?.preserve??!1;if("importFrom"in Object(e))throw new Error('[postcss-custom-media] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-media] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-media",prepare(){const e=new WeakSet;let t=new Map;return{postcssPlugin:"postcss-custom-media",Once(e,{result:n}){t=getCustomMedia(e,n,{preserve:r})},AtRule(n,{result:o}){if(e.has(n))return;if("media"!==n.name.toLowerCase())return;if(!n.params)return;if(!n.params.includes("--"))return;let a=[];try{a=transformAtMediaListTokens(n.params,t)}catch(e){return void n.warn(o,`Failed to parse @custom-media params with error message: "${e instanceof Error?e.message:e}"`)}if(!a||0===a.length)return;if(1===a.length){if(n.params.trim()===a[0].replaceWith.trim())return;return e.add(n),n.cloneBefore({params:a[0].replaceWith.trim()}),r?void 0:void n.remove()}if(!!!a.find((e=>!!e.encapsulateWith)))return e.add(n),n.cloneBefore({params:a.map((e=>e.replaceWith)).join(",").trim()}),void(r||n.remove());a.forEach((r=>{if(!r.encapsulateWith)return void n.cloneBefore({params:r.replaceWith.trim()});const t=n.clone({params:r.replaceWith}),o=n.clone({params:r.encapsulateWith.trim(),nodes:[]});t.parent=void 0,o.parent=void 0,e.add(n),o.append(t),n.before(o)})),r||n.remove()}}}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/postcss-custom-media/dist/index.d.ts b/node_modules/postcss-custom-media/dist/index.d.ts deleted file mode 100644 index ff7d0421..00000000 --- a/node_modules/postcss-custom-media/dist/index.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { PluginCreator } from 'postcss'; - -declare const creator: PluginCreator<pluginOptions>; -export default creator; - -/** postcss-custom-media plugin options */ -export declare type pluginOptions = { - /** Preserve the original notation. default: false */ - preserve?: boolean; -}; - -export { } diff --git a/node_modules/postcss-custom-media/dist/index.mjs b/node_modules/postcss-custom-media/dist/index.mjs deleted file mode 100644 index 46fe6ca7..00000000 --- a/node_modules/postcss-custom-media/dist/index.mjs +++ /dev/null @@ -1 +0,0 @@ -import{parse as e,addLayerToModel as r}from"@csstools/cascade-layer-name-parser";import{tokenizer as t,TokenType as n,NumberType as a,isTokenWhiteSpaceOrComment as o,isTokenIdent as s,cloneTokens as i,stringify as l}from"@csstools/css-tokenizer";import{parseFromTokens as u,parse as c,isMediaFeatureBoolean as f,isMediaFeature as p,newMediaFeaturePlain as m,isMediaQueryInvalid as d,isMediaQueryWithType as h,isMediaAnd as y,isMediaOr as v,isMediaNot as g,isMediaConditionList as w,isGeneralEnclosed as k}from"@csstools/media-query-list-parser";const C=e("csstools-implicit-layer")[0];function collectCascadeLayerOrder(t){const n=new Map,a=new Map,o=[];t.walkAtRules((t=>{if("layer"!==t.name.toLowerCase())return;{let e=t.parent;for(;e;){if("atrule"!==e.type||"layer"!==e.name.toLowerCase()){if(e===t.root())break;return}e=e.parent}}let s;if(t.nodes)s=normalizeLayerName(t.params,1);else{if(!t.params.trim())return;s=t.params}let i=e(s);if(i?.length){{let e=t.parent;for(;e&&"atrule"===e.type&&"layer"===e.name.toLowerCase();){const r=a.get(e);r?(i=i.map((e=>r.concat(e))),e=e.parent):e=e.parent}}if(r(o,i),t.nodes){const e=i[0].concat(C);n.set(t,e),a.set(t,i[0])}}}));for(const e of n.values())r(o,[e]);const s=new WeakMap;for(const[e,r]of n)s.set(e,o.findIndex((e=>r.equal(e))));return s}function normalizeLayerName(e,r){return e.trim()?e:"csstools-anon-layer--"+r++}const M=new Set(["scope","container","layer"]);function isProcessableCustomMediaRule(e){if("custom-media"!==e.name.toLowerCase())return!1;if(!e.params||!e.params.includes("--"))return!1;if(e.nodes&&e.nodes.length>0)return!1;let r=e.parent;for(;r;){if("atrule"===r.type&&!M.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}function removeCyclicReferences(e,r){const t=new Set;for(;e.size>0;){const n=findCyclicNode(Array.from(e.keys()),r);if(!n)return t;e.delete(n),t.add(n),r=r.filter((e=>-1===e.indexOf(n)))}return t}function findCyclicNode(e,r){let t=e.length;const n=new Array(t),a={};let o=t;const s=makeOutgoingEdges(r),i=makeNodesHash(e);for(;o--;)if(!a[o]){const r=visit(e[o],o,new Set);if(!r)continue;return r}function visit(e,r,o){if(o.has(e))return e;if(!i.has(e))return;if(a[r])return;a[r]=!0;const l=Array.from(s.get(e)||new Set);if(r=l.length){o.add(e);do{const e=l[--r],t=visit(e,i.get(e),o);if(t)return t}while(r);o.delete(e)}n[--t]=e}}function makeOutgoingEdges(e){const r=new Map;for(let t=0,n=e.length;t<n;t++){const n=e[t];r.has(n[0])||r.set(n[0],new Set),r.has(n[1])||r.set(n[1],new Set),r.get(n[0]).add(n[1])}return r}function makeNodesHash(e){const r=new Map;for(let t=0,n=e.length;t<n;t++)r.set(e[t],t);return r}function atMediaParamsTokens(e){const r=t({css:e},{onParseError:()=>{throw new Error(`Unable to parse media query "${e}"`)}}),n=[];for(;!r.endOfFile();)n.push(r.nextToken());return n}const W=[[n.Ident,"max-color",0,0,{value:"max-color"}],[n.Colon,":",0,0,void 0],[n.Number,"2147477350",0,0,{value:2147477350,type:a.Integer}]],S=[[n.Ident,"color",0,0,{value:"color"}],[n.Colon,":",0,0,void 0],[n.Number,"2147477350",0,0,{value:2147477350,type:a.Integer}]];function replaceTrueAndFalseTokens(e){let r,t=[];for(let n=0;n<e.length;n++)if(!o(e[n])){if(s(e[n])){const a=e[n];if("true"===a[4].value.toLowerCase()){r="true",t=e.slice(n+1);break}if("false"===a[4].value.toLowerCase()){r="false",t=e.slice(n+1);break}}return e}if(!r)return e;for(let r=0;r<t.length;r++)if(!o(t[r]))return e;return"true"===r?[[n.Whitespace," ",0,0,void 0],[n.OpenParen,"(",0,0,void 0],...W,[n.CloseParen,")",0,0,void 0]]:[[n.Whitespace," ",0,0,void 0],[n.OpenParen,"(",0,0,void 0],...S,[n.CloseParen,")",0,0,void 0]]}function parseCustomMedia(e){const r=atMediaParamsTokens(e),t=new Set;let n="",a=r;for(let e=0;e<r.length;e++)if(!o(r[e])){if(s(r[e])){const t=r[e];if(t[4].value.startsWith("--")){n=t[4].value,a=r.slice(e+1);break}}return!1}for(let e=0;e<a.length;e++)if(s(a[e])){const r=a[e];r[4].value.startsWith("--")&&t.add(r[4].value)}a=replaceTrueAndFalseTokens(a);const c=u(i(a),{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${l(...a)}"`)}}),f=u(i(a),{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${l(...a)}"`)}});for(let e=0;e<f.length;e++)f[e]=f[e].negateQuery();return{name:n,truthy:c,falsy:f,dependencies:Array.from(t).map((e=>[n,e]))}}function getCustomMedia(e,r,t){const n=new Map,a=new Map,o=[],s=collectCascadeLayerOrder(e);e.walkAtRules((e=>{if(!isProcessableCustomMediaRule(e))return;const r=parseCustomMedia(e.params);if(!r)return;if(0===r.truthy.length)return;const i=(u=s,(l=e).parent&&"atrule"===l.parent.type&&"layer"===l.parent.name.toLowerCase()?u.has(l.parent)?u.get(l.parent)+1:0:1e7);var l,u;const c=a.get(r.name)??-1;if(i&&i>=c&&(a.set(r.name,i),n.set(r.name,{truthy:r.truthy,falsy:r.falsy}),o.push(...r.dependencies)),!t.preserve){const r=e.parent;e.remove(),removeEmptyAncestorBlocks(r)}}));const i=removeCyclicReferences(n,o);for(const t of i.values())e.warn(r,`@custom-media rules have cyclic dependencies for "${t}"`);return n}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(r.nodes&&r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function transformAtMediaListTokens(e,r){const t=c(e,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${e}"`)}}),n=t.map((e=>e.toString()));for(let e=0;e<t.length;e++){const a=t[e],o=n[e];{const t=transformSimpleMediaQuery(a,r);if(t&&t.replaceWith!==o)return n.map(((r,n)=>n===e?t:{replaceWith:r}))}const s=transformComplexMediaQuery(a,r);if(s&&0!==s.length&&s[0].replaceWith!==o)return n.flatMap(((r,t)=>t===e?s:[{replaceWith:r}]))}return[]}function transformSimpleMediaQuery(e,r){if(!mediaQueryIsSimple(e))return null;let t=null;return e.walk((e=>{const n=e.node;if(!f(n))return;const a=n.getName();if(!a.startsWith("--"))return!1;const o=r.get(a);return o?(t={replaceWith:o.truthy.map((e=>e.toString().trim())).join(",")},!1):void 0})),t}function transformComplexMediaQuery(e,r){let t=[];return e.walk((n=>{const a=n.node;if(!f(a))return;const o=n.parent;if(!p(o))return;const s=a.getName();if(!s.startsWith("--"))return!1;const i=r.get(s);if(i){if(1===i.truthy.length&&mediaQueryIsSimple(i.truthy[0])){let r=null;if(i.truthy[0].walk((e=>{if(p(e.node))return r=e.node,!1})),r&&r.feature)return o.feature=r.feature,t=[{replaceWith:e.toString()}],!1}const r=m(W[0][4].value,W[2]);o.feature=r.feature;const n=e.toString(),a=m(S[0][4].value,S[2]);o.feature=a.feature;const s=e.toString();return t=[{replaceWith:n,encapsulateWith:i.truthy.map((e=>e.toString().trim())).join(",")},{replaceWith:s,encapsulateWith:i.falsy.map((e=>e.toString().trim())).join(",")}],!1}})),t}function mediaQueryIsSimple(e){if(d(e))return!1;if(h(e))return!1;let r=!0;return e.walk((e=>{if(y(e.node)||v(e.node)||g(e.node)||w(e.node)||k(e.node))return r=!1,!1})),r}const creator=e=>{const r=e?.preserve??!1;if("importFrom"in Object(e))throw new Error('[postcss-custom-media] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-media] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-media",prepare(){const e=new WeakSet;let t=new Map;return{postcssPlugin:"postcss-custom-media",Once(e,{result:n}){t=getCustomMedia(e,n,{preserve:r})},AtRule(n,{result:a}){if(e.has(n))return;if("media"!==n.name.toLowerCase())return;if(!n.params)return;if(!n.params.includes("--"))return;let o=[];try{o=transformAtMediaListTokens(n.params,t)}catch(e){return void n.warn(a,`Failed to parse @custom-media params with error message: "${e instanceof Error?e.message:e}"`)}if(!o||0===o.length)return;if(1===o.length){if(n.params.trim()===o[0].replaceWith.trim())return;return e.add(n),n.cloneBefore({params:o[0].replaceWith.trim()}),r?void 0:void n.remove()}if(!!!o.find((e=>!!e.encapsulateWith)))return e.add(n),n.cloneBefore({params:o.map((e=>e.replaceWith)).join(",").trim()}),void(r||n.remove());o.forEach((r=>{if(!r.encapsulateWith)return void n.cloneBefore({params:r.replaceWith.trim()});const t=n.clone({params:r.replaceWith}),a=n.clone({params:r.encapsulateWith.trim(),nodes:[]});t.parent=void 0,a.parent=void 0,e.add(n),a.append(t),n.before(a)})),r||n.remove()}}}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/postcss-custom-media/package.json b/node_modules/postcss-custom-media/package.json deleted file mode 100644 index c7c0821d..00000000 --- a/node_modules/postcss-custom-media/package.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "name": "postcss-custom-media", - "description": "Use Custom Media Queries in CSS", - "version": "10.0.8", - "contributors": [ - { - "name": "Antonio Laguna", - "email": "antonio@laguna.es", - "url": "https://antonio.laguna.es" - }, - { - "name": "Romain Menke", - "email": "romainmenke@gmail.com" - }, - { - "name": "Jonathan Neal", - "email": "jonathantneal@hotmail.com" - }, - { - "name": "Maxime Thirouin" - } - ], - "license": "MIT", - "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/cascade-layer-name-parser": "^1.0.13", - "@csstools/css-parser-algorithms": "^2.7.1", - "@csstools/css-tokenizer": "^2.4.1", - "@csstools/media-query-list-parser": "^2.1.13" - }, - "peerDependencies": { - "postcss": "^8.4" - }, - "scripts": {}, - "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-custom-media#readme", - "repository": { - "type": "git", - "url": "git+https://github.com/csstools/postcss-plugins.git", - "directory": "plugins/postcss-custom-media" - }, - "bugs": "https://github.com/csstools/postcss-plugins/issues", - "keywords": [ - "at-rule", - "atrule", - "css", - "csswg", - "custom", - "media", - "postcss", - "postcss-plugin", - "queries", - "query", - "specification", - "w3c" - ] -} |
