css-prefers-color-scheme 9.0.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -170
- package/README.md +14 -8
- package/dist/index.d.ts +7 -3
- package/package.json +10 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changes to Prefers Color Scheme
|
|
2
2
|
|
|
3
|
+
### 9.0.1
|
|
4
|
+
|
|
5
|
+
_December 15, 2023_
|
|
6
|
+
|
|
7
|
+
- Fix type definitions
|
|
8
|
+
|
|
3
9
|
### 9.0.0
|
|
4
10
|
|
|
5
11
|
_July 3, 2023_
|
|
@@ -12,173 +18,4 @@ _February 6, 2023_
|
|
|
12
18
|
|
|
13
19
|
- Reduce the amount of duplicate fallback CSS.
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
_January 28, 2023_
|
|
18
|
-
|
|
19
|
-
- Improve `types` declaration in `package.json`
|
|
20
|
-
|
|
21
|
-
### 8.0.0
|
|
22
|
-
|
|
23
|
-
_January 24, 2023_
|
|
24
|
-
|
|
25
|
-
- Updated: Support for Node v14+ (major).
|
|
26
|
-
|
|
27
|
-
### 7.0.1
|
|
28
|
-
|
|
29
|
-
_August 23, 2022_
|
|
30
|
-
|
|
31
|
-
- Fix: assign global browser polyfill to `window`, `self` or a blank object.
|
|
32
|
-
|
|
33
|
-
### 7.0.0
|
|
34
|
-
|
|
35
|
-
_July 8, 2022_
|
|
36
|
-
|
|
37
|
-
[Read the full changelog](https://github.com/csstools/postcss-plugins/wiki/PostCSS-Preset-Env-8)
|
|
38
|
-
|
|
39
|
-
- Breaking: removed old CDN urls
|
|
40
|
-
- Breaking: remove `color-depth` queries fallback
|
|
41
|
-
- Breaking: remove 'no-preference' support as this was dropped from the spec
|
|
42
|
-
- Breaking: remove old global object
|
|
43
|
-
- Fix: case insensitive matching.
|
|
44
|
-
|
|
45
|
-
#### How to migrate :
|
|
46
|
-
|
|
47
|
-
##### Re-build your CSS with the new version of the library.
|
|
48
|
-
|
|
49
|
-
##### If you use a CDN url, please update it.
|
|
50
|
-
|
|
51
|
-
```diff
|
|
52
|
-
- <script src="https://unpkg.com/css-prefers-color-scheme/browser"></script>
|
|
53
|
-
+ <script src="https://unpkg.com/css-prefers-color-scheme/dist/browser-global.js"></script>
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
```diff
|
|
57
|
-
- <script src="https://unpkg.com/css-prefers-color-scheme/browser.min"></script>
|
|
58
|
-
+ <script src="https://unpkg.com/css-prefers-color-scheme/dist/browser-global.js"></script>
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
##### Use `prefersColorSchemeInit` to initialize the polyfill in the browser.
|
|
62
|
-
|
|
63
|
-
```diff
|
|
64
|
-
- initPrefersColorScheme()
|
|
65
|
-
+ prefersColorSchemeInit()
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
##### Remove `@media (prefer-color-scheme: no-preference)` from your CSS.
|
|
69
|
-
|
|
70
|
-
`@media (prefers-color-scheme: no-preference)` was removed from the specification and should be equivalent to not having any media query.
|
|
71
|
-
|
|
72
|
-
```diff
|
|
73
|
-
- @media (prefers-color-scheme: no-preference) {
|
|
74
|
-
- .some-selector {
|
|
75
|
-
- /* your styles ... */
|
|
76
|
-
- }
|
|
77
|
-
- }
|
|
78
|
-
+ .some-selector {
|
|
79
|
-
+ /* your styles ... */
|
|
80
|
-
+ }
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### 6.0.3
|
|
84
|
-
|
|
85
|
-
_January 31, 2022_
|
|
86
|
-
|
|
87
|
-
- Fix `preserve: false` option.
|
|
88
|
-
|
|
89
|
-
### 6.0.2
|
|
90
|
-
|
|
91
|
-
_January 2, 2022_
|
|
92
|
-
|
|
93
|
-
- Removed Sourcemaps from package tarball.
|
|
94
|
-
- Moved CLI to CLI Package. See [announcement](https://github.com/csstools/postcss-plugins/discussions/121).
|
|
95
|
-
|
|
96
|
-
### 6.0.1
|
|
97
|
-
|
|
98
|
-
_December 27, 2021_
|
|
99
|
-
|
|
100
|
-
- Fixed: require/import paths for browser script
|
|
101
|
-
|
|
102
|
-
### 6.0.0
|
|
103
|
-
|
|
104
|
-
_December 13, 2021_
|
|
105
|
-
|
|
106
|
-
- Breaking: require/import paths have changed
|
|
107
|
-
- Changed: new polyfill CDN urls.
|
|
108
|
-
- Updated: documentation
|
|
109
|
-
- Fixed: `CSSRuleList` edits skipping rules as this is a live list.
|
|
110
|
-
- Fixed: complex `@media` queries not working.
|
|
111
|
-
|
|
112
|
-
**Migrating to 6.0.0**
|
|
113
|
-
|
|
114
|
-
PostCSS plugin :
|
|
115
|
-
|
|
116
|
-
```diff
|
|
117
|
-
- const postcssPrefersColorScheme = require('css-prefers-color-scheme/postcss');
|
|
118
|
-
+ const postcssPrefersColorScheme = require('css-prefers-color-scheme');
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Browser Polyfill :
|
|
122
|
-
|
|
123
|
-
```diff
|
|
124
|
-
- const prefersColorScheme = require('css-prefers-color-scheme')();
|
|
125
|
-
+ const prefersColorScheme = require('css-prefers-color-scheme/browser')();
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
_The old CND url is now deprecated and will be removed in a next major release._
|
|
129
|
-
_It will continue to work for now._
|
|
130
|
-
|
|
131
|
-
```diff
|
|
132
|
-
- <script src="https://unpkg.com/css-prefers-color-scheme/browser.min"></script>
|
|
133
|
-
+ <script src="https://unpkg.com/css-prefers-color-scheme/dist/browser-global.js"></script>
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### 5.0.0
|
|
137
|
-
|
|
138
|
-
_September 17, 2021_
|
|
139
|
-
|
|
140
|
-
- Updated: Support for PostCS 8+ (major).
|
|
141
|
-
- Updated: Support for Node 12+ (major).
|
|
142
|
-
|
|
143
|
-
### 4.0.0
|
|
144
|
-
|
|
145
|
-
_May 24, 2019_
|
|
146
|
-
|
|
147
|
-
- Updated: `postcss` to 7.0.16 (patch)
|
|
148
|
-
- Updated: Node 8+ compatibility (major)
|
|
149
|
-
|
|
150
|
-
### 3.1.1
|
|
151
|
-
|
|
152
|
-
_November 10, 2018_
|
|
153
|
-
|
|
154
|
-
- Updated: Project organization. No functional changes.
|
|
155
|
-
|
|
156
|
-
### 3.1.0
|
|
157
|
-
|
|
158
|
-
_November 10, 2018_
|
|
159
|
-
|
|
160
|
-
- Include CLI tool for transforming CSS without any installation
|
|
161
|
-
- Update documentation
|
|
162
|
-
|
|
163
|
-
### 3.0.0
|
|
164
|
-
|
|
165
|
-
_November 4, 2018_
|
|
166
|
-
|
|
167
|
-
- Preserve `prefers-color-scheme` queries by default for non-JS environments
|
|
168
|
-
- Remove `prefers-color-scheme` queries on the frontend for JS environments
|
|
169
|
-
|
|
170
|
-
### 2.0.0
|
|
171
|
-
|
|
172
|
-
_November 3, 2018_
|
|
173
|
-
|
|
174
|
-
- The client library now returns an object with various features, including:
|
|
175
|
-
- `scheme` to get or set the preferred color scheme
|
|
176
|
-
- `hasNativeSupport` to report whether `prefers-color-scheme` is supported
|
|
177
|
-
- `onChange` to listen for when the preferred color scheme changes
|
|
178
|
-
- `removeListener` to destroy the native `prefers-color-scheme` listener
|
|
179
|
-
|
|
180
|
-
### 1.0.0
|
|
181
|
-
|
|
182
|
-
_September 24, 2018_
|
|
183
|
-
|
|
184
|
-
- Initial version
|
|
21
|
+
[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/css-prefers-color-scheme/CHANGELOG.md)
|
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
[<img alt="npm version" src="https://img.shields.io/npm/v/css-prefers-color-scheme.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/prefers-color-scheme-query.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]
|
|
4
4
|
|
|
5
|
+
```bash
|
|
6
|
+
npm install css-prefers-color-scheme --save-dev
|
|
7
|
+
```
|
|
8
|
+
|
|
5
9
|
[Prefers Color Scheme] lets you use light and dark color schemes in all browsers, following the [Media Queries] specification.
|
|
6
10
|
|
|
7
11
|
To use this feature you need to do two things :
|
|
@@ -142,12 +146,13 @@ or
|
|
|
142
146
|
|
|
143
147
|
```html
|
|
144
148
|
<!-- When using a CDN url you will have to manually update the version number -->
|
|
145
|
-
<script src="https://unpkg.com/css-prefers-color-scheme@9.0.
|
|
149
|
+
<script src="https://unpkg.com/css-prefers-color-scheme@9.0.1/dist/browser-global.js"></script>
|
|
146
150
|
<script>prefersColorSchemeInit()</script>
|
|
147
151
|
```
|
|
148
152
|
|
|
149
|
-
|
|
150
|
-
|
|
153
|
+
> [!TIP]
|
|
154
|
+
> Please use a versioned url, like this : `https://unpkg.com/css-prefers-color-scheme@9.0.1/dist/browser-global.js`
|
|
155
|
+
> Without the version, you might unexpectedly get a new major version of the library with breaking changes.
|
|
151
156
|
|
|
152
157
|
[Prefers Color Scheme] works in all major browsers, including Safari 6+ and
|
|
153
158
|
Internet Explorer 9+ without any additional polyfills.
|
|
@@ -220,7 +225,7 @@ const prefersColorScheme = prefersColorSchemeInit('light', { debug: true });
|
|
|
220
225
|
```
|
|
221
226
|
|
|
222
227
|
```html
|
|
223
|
-
<script src="https://unpkg.com/css-prefers-color-scheme@9.0.
|
|
228
|
+
<script src="https://unpkg.com/css-prefers-color-scheme@9.0.1/dist/browser-global.js"></script>
|
|
224
229
|
<script>prefersColorSchemeInit('light', { debug: true })</script>
|
|
225
230
|
```
|
|
226
231
|
|
|
@@ -242,10 +247,11 @@ ECMA Script:
|
|
|
242
247
|
|
|
243
248
|
## CORS
|
|
244
249
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
250
|
+
> [!IMPORTANT]
|
|
251
|
+
> Applies to you if you load CSS from a different domain than the page.
|
|
252
|
+
>
|
|
253
|
+
> In this case the CSS is treated as untrusted and will not be made available to the JavaScript polyfill.
|
|
254
|
+
> The polyfill will not work without applying the correct configuration for CORS.
|
|
249
255
|
|
|
250
256
|
Example :
|
|
251
257
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { PluginCreator } from 'postcss';
|
|
2
|
+
|
|
3
|
+
declare const creator: PluginCreator<pluginOptions>;
|
|
4
|
+
export default creator;
|
|
5
|
+
|
|
2
6
|
/** postcss-prefers-color-scheme plugin options */
|
|
3
|
-
export type pluginOptions = {
|
|
7
|
+
export declare type pluginOptions = {
|
|
4
8
|
/** Preserve the original notation. default: true */
|
|
5
9
|
preserve?: boolean;
|
|
6
10
|
};
|
|
7
|
-
|
|
8
|
-
export
|
|
11
|
+
|
|
12
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "css-prefers-color-scheme",
|
|
3
3
|
"description": "Use light and dark color schemes in all browsers",
|
|
4
|
-
"version": "9.0.
|
|
4
|
+
"version": "9.0.1",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
7
7
|
"name": "Antonio Laguna",
|
|
@@ -31,15 +31,18 @@
|
|
|
31
31
|
"engines": {
|
|
32
32
|
"node": "^14 || ^16 || >=18"
|
|
33
33
|
},
|
|
34
|
+
"type": "module",
|
|
34
35
|
"main": "dist/index.cjs",
|
|
35
36
|
"module": "dist/index.mjs",
|
|
36
|
-
"types": "dist/index.d.ts",
|
|
37
37
|
"exports": {
|
|
38
38
|
".": {
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
"import": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"default": "./dist/index.mjs"
|
|
42
|
+
},
|
|
43
|
+
"require": {
|
|
44
|
+
"default": "./dist/index.cjs"
|
|
45
|
+
}
|
|
43
46
|
},
|
|
44
47
|
"./browser": {
|
|
45
48
|
"import": "./dist/browser.mjs",
|
|
@@ -59,19 +62,6 @@
|
|
|
59
62
|
"peerDependencies": {
|
|
60
63
|
"postcss": "^8.4"
|
|
61
64
|
},
|
|
62
|
-
"devDependencies": {
|
|
63
|
-
"@csstools/postcss-tape": "*",
|
|
64
|
-
"puppeteer": "^20.7.4"
|
|
65
|
-
},
|
|
66
|
-
"scripts": {
|
|
67
|
-
"build": "rollup -c ../../rollup/default.mjs",
|
|
68
|
-
"docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs",
|
|
69
|
-
"lint": "node ../../.github/bin/format-package-json.mjs",
|
|
70
|
-
"prepublishOnly": "npm run build && npm run test",
|
|
71
|
-
"test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs",
|
|
72
|
-
"test:browser": "node ./test/_browser.mjs",
|
|
73
|
-
"test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
|
|
74
|
-
},
|
|
75
65
|
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/css-prefers-color-scheme#readme",
|
|
76
66
|
"repository": {
|
|
77
67
|
"type": "git",
|
|
@@ -94,14 +84,5 @@
|
|
|
94
84
|
"queries",
|
|
95
85
|
"query",
|
|
96
86
|
"scheme"
|
|
97
|
-
]
|
|
98
|
-
"csstools": {
|
|
99
|
-
"cssdbId": "prefers-color-scheme-query",
|
|
100
|
-
"exportName": "prefersColorScheme",
|
|
101
|
-
"humanReadableName": "Prefers Color Scheme",
|
|
102
|
-
"specUrl": "https://www.w3.org/TR/mediaqueries-5/#prefers-color-scheme"
|
|
103
|
-
},
|
|
104
|
-
"volta": {
|
|
105
|
-
"extends": "../../package.json"
|
|
106
|
-
}
|
|
87
|
+
]
|
|
107
88
|
}
|