This commit is contained in:
Iliyan Angelov
2025-09-14 23:24:25 +03:00
commit c67067a2a4
71311 changed files with 6800714 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
# Changes to Prefers Color Scheme
### 6.0.3 (January 31, 2022)
- Fix `preserve: false` option.
### 6.0.2 (January 2, 2022)
- Removed Sourcemaps from package tarball.
- Moved CLI to CLI Package. See [announcement](https://github.com/csstools/postcss-plugins/discussions/121).
### 6.0.1 (December 27, 2021)
- Fixed: require/import paths for browser script
### 6.0.0 (December 13, 2021)
- Breaking: require/import paths have changed
- Changed: new polyfill CDN urls.
- Updated: documentation
- Fixed: `CSSRuleList` edits skipping rules as this is a live list.
- Fixed: complex `@media` queries not working.
**Migrating to 6.0.0**
PostCSS plugin :
```diff
- const postcssPrefersColorScheme = require('css-prefers-color-scheme/postcss');
+ const postcssPrefersColorScheme = require('css-prefers-color-scheme');
```
Browser Polyfill :
```diff
- const prefersColorScheme = require('css-prefers-color-scheme')();
+ const prefersColorScheme = require('css-prefers-color-scheme/browser')();
```
_The old CND url is now deprecated and will be removed in a next major release._
_It will continue to work for now._
```diff
- <script src="https://unpkg.com/css-prefers-color-scheme/browser.min"></script>
+ <script src="https://unpkg.com/css-prefers-color-scheme/dist/browser-global.js"></script>
```
### 5.0.0 (September 17, 2021)
- Updated: Support for PostCS 8+ (major).
- Updated: Support for Node 12+ (major).
### 4.0.0 (May 24, 2019)
- Updated: `postcss` to 7.0.16 (patch)
- Updated: Node 8+ compatibility (major)
### 3.1.1 (November 10, 2018)
- Updated: Project organization. No functional changes.
### 3.1.0 (November 10, 2018)
- Include CLI tool for transforming CSS without any installation
- Update documentation
### 3.0.0 (November 4, 2018)
- Preserve `prefers-color-scheme` queries by default for non-JS environments
- Remove `prefers-color-scheme` queries on the frontend for JS environments
### 2.0.0 (November 3, 2018)
- The client library now returns an object with various features, including:
- `scheme` to get or set the preferred color scheme
- `hasNativeSupport` to report whether `prefers-color-scheme` is supported
- `onChange` to listen for when the preferred color scheme changes
- `removeListener` to destroy the native `prefers-color-scheme` listener
### 1.0.0 (September 24, 2018)
- Initial version

View File

@@ -0,0 +1,108 @@
# CC0 1.0 Universal
## Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator and
subsequent owner(s) (each and all, an “owner”) of an original work of
authorship and/or a database (each, a “Work”).
Certain owners wish to permanently relinquish those rights to a Work for the
purpose of contributing to a commons of creative, cultural and scientific works
(“Commons”) that the public can reliably and without fear of later claims of
infringement build upon, modify, incorporate in other works, reuse and
redistribute as freely as possible in any form whatsoever and for any purposes,
including without limitation commercial purposes. These owners may contribute
to the Commons to promote the ideal of a free culture and the further
production of creative, cultural and scientific works, or to gain reputation or
greater distribution for their Work in part through the use and efforts of
others.
For these and/or other purposes and motivations, and without any expectation of
additional consideration or compensation, the person associating CC0 with a
Work (the “Affirmer”), to the extent that he or she is an owner of Copyright
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and
publicly distribute the Work under its terms, with knowledge of his or her
Copyright and Related Rights in the Work and the meaning and intended legal
effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights (“Copyright and
Related Rights”). Copyright and Related Rights include, but are not limited
to, the following:
1. the right to reproduce, adapt, distribute, perform, display, communicate,
and translate a Work;
2. moral rights retained by the original author(s) and/or performer(s);
3. publicity and privacy rights pertaining to a persons image or likeness
depicted in a Work;
4. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(i), below;
5. rights protecting the extraction, dissemination, use and reuse of data in
a Work;
6. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation thereof,
including any amended or successor version of such directive); and
7. other similar, equivalent or corresponding rights throughout the world
based on applicable law or treaty, and any national implementations
thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention of,
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
unconditionally waives, abandons, and surrenders all of Affirmers Copyright
and Related Rights and associated claims and causes of action, whether now
known or unknown (including existing as well as future claims and causes of
action), in the Work (i) in all territories worldwide, (ii) for the maximum
duration provided by applicable law or treaty (including future time
extensions), (iii) in any current or future medium and for any number of
copies, and (iv) for any purpose whatsoever, including without limitation
commercial, advertising or promotional purposes (the “Waiver”). Affirmer
makes the Waiver for the benefit of each member of the public at large and
to the detriment of Affirmers heirs and successors, fully intending that
such Waiver shall not be subject to revocation, rescission, cancellation,
termination, or any other legal or equitable action to disrupt the quiet
enjoyment of the Work by the public as contemplated by Affirmers express
Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason be
judged legally invalid or ineffective under applicable law, then the Waiver
shall be preserved to the maximum extent permitted taking into account
Affirmers express Statement of Purpose. In addition, to the extent the
Waiver is so judged Affirmer hereby grants to each affected person a
royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmers Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future time
extensions), (iii) in any current or future medium and for any number of
copies, and (iv) for any purpose whatsoever, including without limitation
commercial, advertising or promotional purposes (the “License”). The License
shall be deemed effective as of the date CC0 was applied by Affirmer to the
Work. Should any part of the License for any reason be judged legally
invalid or ineffective under applicable law, such partial invalidity or
ineffectiveness shall not invalidate the remainder of the License, and in
such case Affirmer hereby affirms that he or she will not (i) exercise any
of his or her remaining Copyright and Related Rights in the Work or (ii)
assert any associated claims and causes of action with respect to the Work,
in either case contrary to Affirmers express Statement of Purpose.
4. Limitations and Disclaimers.
1. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
2. Affirmer offers the Work as-is and makes no representations or warranties
of any kind concerning the Work, express, implied, statutory or
otherwise, including without limitation warranties of title,
merchantability, fitness for a particular purpose, non infringement, or
the absence of latent or other defects, accuracy, or the present or
absence of errors, whether or not discoverable, all to the greatest
extent permissible under applicable law.
3. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any persons Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the Work.
4. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to this
CC0 or use of the Work.
For more information, please see
http://creativecommons.org/publicdomain/zero/1.0/.

View File

@@ -0,0 +1,95 @@
# Prefers Color Scheme [<img src="https://jonathantneal.github.io/js-logo.svg" alt="" width="90" height="90" align="right">][Prefers Color Scheme]
[![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]
[Prefers Color Scheme] lets you use light and dark color schemes in all
browsers, following the [Media Queries] specification.
[!['Can I use' table](https://caniuse.bitsofco.de/image/prefers-color-scheme.png)](https://caniuse.com/#feat=prefers-color-scheme)
## Usage
From the command line, transform CSS files that use `prefers-color-scheme`
media queries:
```bash
npx css-prefers-color-scheme SOURCE.css TRANSFORMED.css
```
Next, use that transformed CSS with this script:
```html
<link rel="stylesheet" href="TRANSFORMED.css">
<script src="https://unpkg.com/css-prefers-color-scheme/dist/browser-global.js"></script>
<script>
colorScheme = initPrefersColorScheme('dark') // apply "dark" queries (you can change it afterward, too)
</script>
```
⚠️ Please use a versioned url, like this : `https://unpkg.com/css-prefers-color-scheme@6.0.0/dist/browser-global.js`
Without the version, you might unexpectedly get a new major version of the library with breaking changes.
⚠️ If you were using an older version via a CDN, please update the entire url.
The old URL will no longer work in a future release.
## Usage
- First, transform `prefers-color-scheme` queries using this
[PostCSS plugin](README-POSTCSS.md).
- Next, apply light and dark color schemes everywhere using this
[browser script](README-BROWSER.md).
---
## How does it work?
_This plugin used to work with `color-index` as detailed here : [color-index](https://github.com/csstools/css-prefers-color-scheme#how-does-it-work)._
_This is deprecated but will continue to work for now._
_`color` has better browser support and enables complex media queries._
[Prefers Color Scheme] uses a [PostCSS plugin](README-POSTCSS.md) to transform
`prefers-color-scheme` queries into `color` queries. This changes
`prefers-color-scheme: dark` into `(color: 48842621)`,
`prefers-color-scheme: light` into `(color: 70318723)`, and
`prefers-color-scheme: no-preference` into `(color: 22511989)`.
The frontend receives these `color` queries, which are understood in all
major browsers going back to Internet Explorer 9.
However, since browsers can only have a reasonably small number of bits per color,
our color scheme values are ignored.
[Prefers Color Scheme] uses a [browser script](README-BROWSER.md) to change
`(color: 48842621)` queries into `(max-color: 48842621)` in order to
activate “dark mode” specific CSS, and it changes `(color: 70318723)` queries
into `(max-color: 48842621)` to activate “light mode” specific CSS.
```css
@media (color: 70318723) { /* prefers-color-scheme: light */
body {
background-color: white;
color: black;
}
}
```
Since these media queries are accessible to `document.styleSheet`, no CSS
parsing is required.
## Why does the fallback work this way?
The value of `48` is chosen for dark mode because it is the keycode for `0`,
the hexidecimal value of black. Likewise, `70` is chosen for light mode because
it is the keycode for `f`, the hexidecimal value of white.
These are suffixed with a random large number.
[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
[discord]: https://discord.gg/bUadyRwkJS
[npm-img]: https://img.shields.io/npm/v/css-prefers-color-scheme.svg
[npm-url]: https://www.npmjs.com/package/css-prefers-color-scheme
[PostCSS]: https://github.com/postcss/postcss
[Prefers Color Scheme]: https://github.com/csstools/postcss-plugins/tree/main/plugins/css-prefers-color-scheme
[Media Queries]: https://drafts.csswg.org/mediaqueries-5/#descdef-media-prefers-color-scheme

View File

@@ -0,0 +1,2 @@
!function(){var e=/((?:not )?all and )?(\(color-index: *(22|48|70)\))/i,t=/prefers-color-scheme:/i,a=function(a){var i="(prefers-color-scheme: dark)",r=window.matchMedia&&matchMedia(i),c=r&&r.media===i,o=function(){n(r.matches?"dark":"light")},n=function(a){a!==l&&(l=a,"function"==typeof d.onChange&&d.onChange()),[].forEach.call(document.styleSheets||[],(function(i){var r=[];[].forEach.call(i.cssRules||[],(function(e){r.push(e)})),r.forEach((function(i){if(t.test(Object(i.media).mediaText)){var r=[].indexOf.call(i.parentStyleSheet.cssRules,i);i.parentStyleSheet.deleteRule(r)}else{var c=(Object(i.media).mediaText||"").match(e);if(c)i.media.mediaText=((/^dark$/i.test(a)?"48"===c[3]:/^light$/i.test(a)?"70"===c[3]:"22"===c[3])?"not all and ":"")+i.media.mediaText.replace(e,"$2");else{var o=(Object(i.media).mediaText||"").match(/\( *(?:color|max-color): *(48842621|70318723|22511989) *\)/i);o&&o.length>1&&(!/^dark$/i.test(a)||"48842621"!==o[1]&&"22511989"!==o[1]?!/^light$/i.test(a)||"70318723"!==o[1]&&"22511989"!==o[1]?i.media.mediaText=i.media.mediaText.replace(/\( *max-color: *(?:48842621|70318723|22511989) *\)/i,"(color: "+o[1]+")"):i.media.mediaText=i.media.mediaText.replace(/\( *color: *(?:48842621|22511989) *\)/i,"(max-color: "+o[1]+")"):i.media.mediaText=i.media.mediaText.replace(/\( *color: *(?:48842621|70318723) *\)/i,"(max-color: "+o[1]+")"))}}}))}))},d=Object.defineProperty({hasNativeSupport:c,removeListener:function(){r&&r.removeListener(o)}},"scheme",{get:function(){return l},set:n}),l=a||(r&&r.matches?"dark":"light");return n(l),r&&("addEventListener"in r?r.addEventListener("change",o):r.addListener(o)),d};self.prefersColorSchemeInit=a,self.initPrefersColorScheme=a}();
//# sourceMappingURL=browser-global.js.map

View File

@@ -0,0 +1,2 @@
!function(){var e=/((?:not )?all and )?(\(color-index: *(22|48|70)\))/i,t=/prefers-color-scheme:/i,a=function(a){var i="(prefers-color-scheme: dark)",r=window.matchMedia&&matchMedia(i),c=r&&r.media===i,o=function(){n(r.matches?"dark":"light")},n=function(a){a!==l&&(l=a,"function"==typeof d.onChange&&d.onChange()),[].forEach.call(document.styleSheets||[],(function(i){var r=[];[].forEach.call(i.cssRules||[],(function(e){r.push(e)})),r.forEach((function(i){if(t.test(Object(i.media).mediaText)){var r=[].indexOf.call(i.parentStyleSheet.cssRules,i);i.parentStyleSheet.deleteRule(r)}else{var c=(Object(i.media).mediaText||"").match(e);if(c)i.media.mediaText=((/^dark$/i.test(a)?"48"===c[3]:/^light$/i.test(a)?"70"===c[3]:"22"===c[3])?"not all and ":"")+i.media.mediaText.replace(e,"$2");else{var o=(Object(i.media).mediaText||"").match(/\( *(?:color|max-color): *(48842621|70318723|22511989) *\)/i);o&&o.length>1&&(!/^dark$/i.test(a)||"48842621"!==o[1]&&"22511989"!==o[1]?!/^light$/i.test(a)||"70318723"!==o[1]&&"22511989"!==o[1]?i.media.mediaText=i.media.mediaText.replace(/\( *max-color: *(?:48842621|70318723|22511989) *\)/i,"(color: "+o[1]+")"):i.media.mediaText=i.media.mediaText.replace(/\( *color: *(?:48842621|22511989) *\)/i,"(max-color: "+o[1]+")"):i.media.mediaText=i.media.mediaText.replace(/\( *color: *(?:48842621|70318723) *\)/i,"(max-color: "+o[1]+")"))}}}))}))},d=Object.defineProperty({hasNativeSupport:c,removeListener:function(){r&&r.removeListener(o)}},"scheme",{get:function(){return l},set:n}),l=a||(r&&r.matches?"dark":"light");return n(l),r&&("addEventListener"in r?r.addEventListener("change",o):r.addListener(o)),d};self.prefersColorSchemeInit=a,self.initPrefersColorScheme=a}();
//# sourceMappingURL=browser-global.js.map

View File

@@ -0,0 +1,2 @@
!function(){var e=/((?:not )?all and )?(\(color-index: *(22|48|70)\))/i,t=/prefers-color-scheme:/i,a=function(a){var i="(prefers-color-scheme: dark)",r=window.matchMedia&&matchMedia(i),c=r&&r.media===i,o=function(){n(r.matches?"dark":"light")},n=function(a){a!==l&&(l=a,"function"==typeof d.onChange&&d.onChange()),[].forEach.call(document.styleSheets||[],(function(i){var r=[];[].forEach.call(i.cssRules||[],(function(e){r.push(e)})),r.forEach((function(i){if(t.test(Object(i.media).mediaText)){var r=[].indexOf.call(i.parentStyleSheet.cssRules,i);i.parentStyleSheet.deleteRule(r)}else{var c=(Object(i.media).mediaText||"").match(e);if(c)i.media.mediaText=((/^dark$/i.test(a)?"48"===c[3]:/^light$/i.test(a)?"70"===c[3]:"22"===c[3])?"not all and ":"")+i.media.mediaText.replace(e,"$2");else{var o=(Object(i.media).mediaText||"").match(/\( *(?:color|max-color): *(48842621|70318723|22511989) *\)/i);o&&o.length>1&&(!/^dark$/i.test(a)||"48842621"!==o[1]&&"22511989"!==o[1]?!/^light$/i.test(a)||"70318723"!==o[1]&&"22511989"!==o[1]?i.media.mediaText=i.media.mediaText.replace(/\( *max-color: *(?:48842621|70318723|22511989) *\)/i,"(color: "+o[1]+")"):i.media.mediaText=i.media.mediaText.replace(/\( *color: *(?:48842621|22511989) *\)/i,"(max-color: "+o[1]+")"):i.media.mediaText=i.media.mediaText.replace(/\( *color: *(?:48842621|70318723) *\)/i,"(max-color: "+o[1]+")"))}}}))}))},d=Object.defineProperty({hasNativeSupport:c,removeListener:function(){r&&r.removeListener(o)}},"scheme",{get:function(){return l},set:n}),l=a||(r&&r.matches?"dark":"light");return n(l),r&&("addEventListener"in r?r.addEventListener("change",o):r.addListener(o)),d};self.prefersColorSchemeInit=a,self.initPrefersColorScheme=a}();
//# sourceMappingURL=browser-global.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
var e=/((?:not )?all and )?(\(color-index: *(22|48|70)\))/i,t=/prefers-color-scheme:/i;module.exports=function(a){var i="(prefers-color-scheme: dark)",r=window.matchMedia&&matchMedia(i),c=r&&r.media===i,o=function(){d(r.matches?"dark":"light")},d=function(a){a!==l&&(l=a,"function"==typeof n.onChange&&n.onChange()),[].forEach.call(document.styleSheets||[],(function(i){var r=[];[].forEach.call(i.cssRules||[],(function(e){r.push(e)})),r.forEach((function(i){if(t.test(Object(i.media).mediaText)){var r=[].indexOf.call(i.parentStyleSheet.cssRules,i);i.parentStyleSheet.deleteRule(r)}else{var c=(Object(i.media).mediaText||"").match(e);if(c)i.media.mediaText=((/^dark$/i.test(a)?"48"===c[3]:/^light$/i.test(a)?"70"===c[3]:"22"===c[3])?"not all and ":"")+i.media.mediaText.replace(e,"$2");else{var o=(Object(i.media).mediaText||"").match(/\( *(?:color|max-color): *(48842621|70318723|22511989) *\)/i);o&&o.length>1&&(!/^dark$/i.test(a)||"48842621"!==o[1]&&"22511989"!==o[1]?!/^light$/i.test(a)||"70318723"!==o[1]&&"22511989"!==o[1]?i.media.mediaText=i.media.mediaText.replace(/\( *max-color: *(?:48842621|70318723|22511989) *\)/i,"(color: "+o[1]+")"):i.media.mediaText=i.media.mediaText.replace(/\( *color: *(?:48842621|22511989) *\)/i,"(max-color: "+o[1]+")"):i.media.mediaText=i.media.mediaText.replace(/\( *color: *(?:48842621|70318723) *\)/i,"(max-color: "+o[1]+")"))}}}))}))},n=Object.defineProperty({hasNativeSupport:c,removeListener:function(){r&&r.removeListener(o)}},"scheme",{get:function(){return l},set:d}),l=a||(r&&r.matches?"dark":"light");return d(l),r&&("addEventListener"in r?r.addEventListener("change",o):r.addListener(o)),n};
//# sourceMappingURL=browser.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
var e=/((?:not )?all and )?(\(color-index: *(22|48|70)\))/i,t=/prefers-color-scheme:/i,a=function(a){var i="(prefers-color-scheme: dark)",r=window.matchMedia&&matchMedia(i),c=r&&r.media===i,o=function(){d(r.matches?"dark":"light")},d=function(a){a!==l&&(l=a,"function"==typeof n.onChange&&n.onChange()),[].forEach.call(document.styleSheets||[],(function(i){var r=[];[].forEach.call(i.cssRules||[],(function(e){r.push(e)})),r.forEach((function(i){if(t.test(Object(i.media).mediaText)){var r=[].indexOf.call(i.parentStyleSheet.cssRules,i);i.parentStyleSheet.deleteRule(r)}else{var c=(Object(i.media).mediaText||"").match(e);if(c)i.media.mediaText=((/^dark$/i.test(a)?"48"===c[3]:/^light$/i.test(a)?"70"===c[3]:"22"===c[3])?"not all and ":"")+i.media.mediaText.replace(e,"$2");else{var o=(Object(i.media).mediaText||"").match(/\( *(?:color|max-color): *(48842621|70318723|22511989) *\)/i);o&&o.length>1&&(!/^dark$/i.test(a)||"48842621"!==o[1]&&"22511989"!==o[1]?!/^light$/i.test(a)||"70318723"!==o[1]&&"22511989"!==o[1]?i.media.mediaText=i.media.mediaText.replace(/\( *max-color: *(?:48842621|70318723|22511989) *\)/i,"(color: "+o[1]+")"):i.media.mediaText=i.media.mediaText.replace(/\( *color: *(?:48842621|22511989) *\)/i,"(max-color: "+o[1]+")"):i.media.mediaText=i.media.mediaText.replace(/\( *color: *(?:48842621|70318723) *\)/i,"(max-color: "+o[1]+")"))}}}))}))},n=Object.defineProperty({hasNativeSupport:c,removeListener:function(){r&&r.removeListener(o)}},"scheme",{get:function(){return l},set:d}),l=a||(r&&r.matches?"dark":"light");return d(l),r&&("addEventListener"in r?r.addEventListener("change",o):r.addListener(o)),n};export{a as default};
//# sourceMappingURL=browser.mjs.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
"use strict";const e=/^media$/i,r=/\(\s*prefers-color-scheme\s*:\s*(dark|light|no-preference)\s*\)/i,o={dark:48,light:70,"no-preference":22},s=(e,r)=>`(color-index: ${o[r.toLowerCase()]})`,c={dark:48842621,light:70318723,"no-preference":22511989},t=(e,r)=>`(color: ${c[r.toLowerCase()]})`,l=o=>{const c=!("preserve"in Object(o))||o.preserve,l={};return!("mediaQuery"in Object(o))||"color-index"!==o.mediaQuery&&"color"!==o.mediaQuery?(l["color-index"]=!0,l.color=!0):l[o.mediaQuery]=!0,{postcssPlugin:"postcss-prefers-color-scheme",AtRule:o=>{if(!e.test(o.name))return;const{params:n}=o,a=n.replace(r,s),i=n.replace(r,t);let p=!1;n!==a&&l["color-index"]&&(o.cloneBefore({params:a}),p=!0),n!==i&&l.color&&(o.cloneBefore({params:i}),p=!0),!c&&p&&o.remove()}}};l.postcss=!0,module.exports=l;

View File

@@ -0,0 +1 @@
const e=/^media$/i,r=/\(\s*prefers-color-scheme\s*:\s*(dark|light|no-preference)\s*\)/i,o={dark:48,light:70,"no-preference":22},s=(e,r)=>`(color-index: ${o[r.toLowerCase()]})`,c={dark:48842621,light:70318723,"no-preference":22511989},a=(e,r)=>`(color: ${c[r.toLowerCase()]})`,l=o=>{const c=!("preserve"in Object(o))||o.preserve,l={};return!("mediaQuery"in Object(o))||"color-index"!==o.mediaQuery&&"color"!==o.mediaQuery?(l["color-index"]=!0,l.color=!0):l[o.mediaQuery]=!0,{postcssPlugin:"postcss-prefers-color-scheme",AtRule:o=>{if(!e.test(o.name))return;const{params:n}=o,t=n.replace(r,s),i=n.replace(r,a);let p=!1;n!==t&&l["color-index"]&&(o.cloneBefore({params:t}),p=!0),n!==i&&l.color&&(o.cloneBefore({params:i}),p=!0),!c&&p&&o.remove()}}};l.postcss=!0;export{l as default};

View File

@@ -0,0 +1,81 @@
{
"name": "css-prefers-color-scheme",
"version": "6.0.3",
"description": "Use light and dark color schemes in all browsers",
"author": "Jonathan Neal <jonathantneal@hotmail.com>",
"license": "CC0-1.0",
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/css-prefers-color-scheme#readme",
"bugs": "https://github.com/csstools/postcss-plugins/issues",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"default": "./dist/index.mjs"
},
"./browser": {
"import": "./dist/browser.mjs",
"require": "./dist/browser.cjs",
"default": "./dist/browser.mjs"
},
"./browser-global": {
"default": "./dist/browser-global.js"
}
},
"files": [
"CHANGELOG.md",
"LICENSE.md",
"README.md",
"dist",
"browser.js",
"browser.min.js"
],
"bin": {
"css-prefers-color-scheme": "dist/cli.cjs"
},
"scripts": {
"build": "rollup -c ../../rollup/default.js && npm run copy-browser-scripts-to-old-location",
"clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"",
"copy-browser-scripts-to-old-location": "node -e \"fs.copyFileSync('./dist/browser-global.js', './browser.js'); fs.copyFileSync('./dist/browser-global.js', './browser.min.js')\"",
"lint": "eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern",
"prepublishOnly": "npm run clean && npm run build && npm run test",
"stryker": "stryker run --logLevel error",
"test": "postcss-tape --ci && npm run test:exports",
"test:exports": "node ./test/_import.mjs && node ./test/_require.cjs"
},
"engines": {
"node": "^12 || ^14 || >=16"
},
"devDependencies": {
"postcss": "^8.3.6",
"postcss-tape": "^6.0.1"
},
"peerDependencies": {
"postcss": "^8.4"
},
"keywords": [
"postcss",
"css",
"postcss-plugin",
"media",
"query",
"prefers",
"color",
"scheme",
"dark",
"light",
"no-preference",
"mode",
"queries",
"interface"
],
"repository": {
"type": "git",
"url": "https://github.com/csstools/postcss-plugins.git",
"directory": "plugins/css-prefers-color-scheme"
},
"volta": {
"extends": "../../package.json"
}
}