postcss-preset-env 7.2.2 → 7.3.2

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 CHANGED
@@ -1,5 +1,58 @@
1
1
  # Changes to PostCSS Preset Env
2
2
 
3
+ ### 7.3.2 (February 12, 2022)
4
+
5
+ - Updated `postcss-lab-function` to `4.1.0` (minor)
6
+
7
+ `postcss-lab-function` now supports [wide gamut colors](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-lab-function#displayp3) and [out of gamut color mapping](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-lab-function#displayp3).
8
+
9
+ - Updated `css-blank-pseudo` to `3.0.3` (patch)
10
+ - Updated `css-has-pseudo` to `3.0.4` (patch)
11
+ - Updated `cssdb` to `6.2.1` (patch)
12
+ - Updated `postcss-color-functional-notation` to `4.2.2` (patch)
13
+ - Updated `postcss-color-hex-alpha` to `8.0.3` (patch)
14
+ - Updated `postcss-dir-pseudo-class` to `6.0.4` (patch)
15
+ - Updated `postcss-double-position-gradients` to `3.0.5` (patch)
16
+ - Updated `postcss-env-function` to `4.0.5` (patch)
17
+ - Updated `postcss-focus-visible` to `6.0.4` (patch)
18
+ - Updated `postcss-focus-within` to `5.0.4` (patch)
19
+ - Updated `postcss-gap-properties` to `3.0.3` (patch)
20
+ - Updated `postcss-image-set-function` to `4.0.6` (patch)
21
+ - Updated `postcss-logical` to `5.0.4` (patch)
22
+ - Updated `postcss-overflow-shorthand` to `3.0.3` (patch)
23
+ - Updated `postcss-place` to `7.0.4` (patch)
24
+ - Updated `postcss-pseudo-class-any-link` to `7.1.1` (patch)
25
+ - Updated `@csstools/postcss-progressive-custom-properties` to `1.1.0`.
26
+
27
+ ### 7.3.1 (February 3, 2022)
28
+
29
+ - Ensured that `debug` option uses a single instance per run, this allows for `debug` to work on parallel runs within CI environments.
30
+ - Normalized exports to support both Common JS and ESM within our modules. This allows for the package to be processable via Webpack [#221](https://github.com/csstools/postcss-plugins/issues/221)
31
+ - Updated `postcss-opacity-percentage` to `1.1.2` (patch).
32
+
33
+ ### 7.3.0 (January 31, 2022)
34
+
35
+ - Added `@csstools/postcss-is-pseudo-class` <br/> [Check the plugin README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-is-pseudo-class#readme) for usage details.
36
+ - Added `@csstools/postcss-hwb-function` <br/> [Check the plugin README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-hwb-function#readme) for usage details.
37
+ - Added `postcss-opacity-percentage` <br/> [Check the plugin README](https://github.com/mrcgrtz/postcss-opacity-percentage#readme) for usage details.
38
+ - Added `postcss-clamp` <br/> [Check the plugin README](https://github.com/polemius/postcss-clamp#readme) for usage details.
39
+ - Added `@csstools/postcss-normalize-display-values` <br/> [Check the plugin README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-normalize-display-values#readme) for usage details.
40
+ - Added `@csstools/postcss-font-format-keywords` <br/> [Check the plugin README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-font-format-keywords#readme) for usage details.
41
+ - Added `debug` [option](https://github.com/csstools/postcss-plugins/tree/main/plugin-packs/postcss-preset-env#debug) that enables extra debugging information while processing the CSS.
42
+ - Added `enableClientSidePolyfills` [option](https://github.com/csstools/postcss-plugins/tree/main/plugin-packs/postcss-preset-env#enableclientsidepolyfills) that allows you to control every single plugin that requires a browser library to fully work. Defaults to `true` so they're enabled by default.
43
+ - Added `minimumVendorImplementations` [option](https://github.com/csstools/postcss-plugins/tree/main/plugin-packs/postcss-preset-env#minimumvendorimplementations) that allows you to enable/disable plugins based on their implementation status in browsers.
44
+ - Fix sourcemaps for `image-set()` function.
45
+ - Removed `caniuse-lite` dependency. This results not only in lower package size but also in better feature detection lead by changes on CSSDB.
46
+ - Updated `cssdb` to `6.1.0` (major).
47
+ - Updated `css-prefers-color-scheme` to `6.0.3` (patch)
48
+ - Updated `postcss-custom-properties` to `12.1.4` (patch)
49
+ - Updated `postcss-image-set-function` to `4.0.5` (patch)
50
+ - Updated `postcss-pseudo-class-any-link` to `7.1.0` (minor)
51
+
52
+ ### 7.2.3 (January 12, 2022)
53
+
54
+ - Enhanced `importFrom` / `exportTo` so it's harder to cause unexpected issues by different shapes of data.
55
+
3
56
  ### 7.2.2 (January 12, 2022)
4
57
 
5
58
  - Updated `postcss-logical` to `5.0.3` (patch)
package/README.md CHANGED
@@ -2,15 +2,33 @@
2
2
 
3
3
  [<img alt="npm version" src="https://img.shields.io/npm/v/postcss-preset-env.svg" height="20">][npm-url]
4
4
  [<img alt="build status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url]
5
- [<img alt="support chat" src="https://img.shields.io/badge/support-chat-blue.svg" height="20">][git-url]
5
+ [![install size][package-phobia-badge]][package-phobia]
6
+ [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
6
7
 
7
8
  [PostCSS Preset Env] lets you convert modern CSS into something most browsers
8
9
  can understand, determining the polyfills you need based on your targeted
9
10
  browsers or runtime environments.
10
11
 
11
- ```bash
12
- npm install postcss-preset-env
13
- ```
12
+ ## How does it work?
13
+
14
+ [PostCSS Preset Env] is a Plugin Pack for [PostCSS]. It leverages the list of the features we keep an eye from [CSSDB][cssdb] and applies plugins, so you can use those new features without having to worry about browser support.
15
+
16
+ CSSDB exposes the browser support that each feature has which can come from [Can I Use](https://caniuse.com/css-all) or from [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/all) (through [mdn/browser-compat-data](https://github.com/mdn/browser-compat-data)).
17
+
18
+ By providing a list of browser targets for your project, plugins that aren't needed will be skipped. Over time your targets might change and by updating the settings your CSS bundle will only ever contain the needed fallbacks.
19
+
20
+ What [PostCSS Preset Env] does is to take the support data that comes from MDN and Can I Use and determine from a [browserlist](https://github.com/browserslist/browserslist) whether those transformations are needed. It also packs [Autoprefixer](https://github.com/postcss/autoprefixer) within and shares the list with it, so prefixes are only applied when you're going to need them given your browser support list.
21
+
22
+ Glossary:
23
+
24
+ * **Browser list option**: [Browserlist](https://github.com/browserslist/browserslist) is a package that gives you a list of browsers for a given query. For example, `chrome < 42` will give you a list of every Chrome version that has been released up to, but not including, 42.
25
+ * **Browser support stats**: Features get introduced on browsers at certain versions. They're often visible on [MDN](https://developer.mozilla.org/en-US/) and [Can I Use](https://caniuse.com/). Comparing these stats with the needed _support_ for your project tells you if it's safe to use a feature or not.
26
+ * **CSS Feature**: A CSS feature is often part of some spec that enables a specific feature. For example, `hwb` functional notation lets you express a given color according to its hue, whiteness, and blackness. This is part of the CSS Color 4 Spec.
27
+ * **CSS Spec**: A Spec is a document that collects new features, what problems are they trying to solve and how it's intended to be solved (generally). This is usually an evolving document that goes over lengthy discussions between several people from different companies.
28
+ * **Plugin**: A plugin is package that's intended (usually) to enable a new CSS Feature by leveraging PostCSS. This doesn't need to be part of any spec. An example of the latter is [PostCSS Mixins](https://github.com/postcss/postcss-mixins), a concept that existed on Less or Sass, but it's not part of any spec. This plugin plack **only** packs plugins that enable features acknowledged by the World Wide Web Consortium (W3C) which will then be implemented by browsers later.
29
+ * **Polyfill**: A polyfill is a piece of code (usually JavaScript on the Web) used to provide modern functionality on older browsers that do not natively support it. A polyfill _should_ be indistinguishable from the native behaviour.
30
+
31
+ Here's a quick example of the syntax you can leverage by using [PostCSS Preset Env].
14
32
 
15
33
  ```pcss
16
34
  @custom-media --viewport-medium (width <= 50rem);
@@ -87,6 +105,12 @@ features and supports **all** browsers.
87
105
  [![Transform with Preset Env][readme-transform-with-preset-env-img]][readme-transform-with-preset-env-url]
88
106
  [![Style with Preset Env][readme-style-with-preset-env-img]][readme-style-with-preset-env-url]
89
107
 
108
+ ⚠️ Please note that some features need a companion library that makes
109
+ the feature work. While we try to avoid this requirement, there are instances
110
+ in which this isn't possible to polyfill a new behaviour with _just_ CSS.
111
+
112
+ [See the list below](#plugins-that-need-client-library).
113
+
90
114
  ## Usage
91
115
 
92
116
  Add [PostCSS Preset Env] to your project:
@@ -126,8 +150,30 @@ The `stage` can be `0` (experimental) through `4` (stable), or `false`. Setting
126
150
  `stage` to `false` will disable every polyfill. Doing this would only be useful
127
151
  if you intended to exclusively use the [`features`](#features) option.
128
152
 
129
- Without any configuration options, [PostCSS Preset Env] enables **Stage 2**
130
- features.
153
+ Default: `2`
154
+
155
+ ### minimumVendorImplementations
156
+
157
+ The `minimumVendorImplementations` option determines which CSS features to polyfill, based their implementation status.
158
+ This can be used to enable plugins that are available in browsers regardless of the [spec status](#stage).
159
+
160
+ ```js
161
+ postcssPresetEnv({ minimumVendorImplementations: 2 })
162
+ ```
163
+
164
+ `minimumVendorImplementations` can be `0` (no vendor has implemented it) through `3` (all major vendors).<br>
165
+
166
+ Default: `0`
167
+
168
+ **Note:**
169
+
170
+ When a feature has not yet been implemented by any vendor it can be considered experimental.<br>
171
+ Even with a single implementation it might still change in the future.<br>
172
+ Sometimes issues with a feature/specification are only discovered after it becomes available.
173
+
174
+ A value of `2` is recommended when you want to use only those features that should be [stable](#stability-and-portability).
175
+
176
+ Having 2 independent implementations is [a critical step in proposals becoming standards](https://www.w3.org/2021/Process-20211102/#implementation-experience) and a good indicator of a feature's stability.
131
177
 
132
178
  ### features
133
179
 
@@ -176,7 +222,7 @@ configuration is not available.
176
222
  postcssPresetEnv({ browsers: 'last 2 versions' })
177
223
  ```
178
224
 
179
- If not valid browserslist configuration is specified, the
225
+ If no valid browserslist configuration is specified, the
180
226
  [default browserslist query](https://github.com/browserslist/browserslist#queries)
181
227
  will be used.
182
228
 
@@ -214,6 +260,40 @@ postcssPresetEnv({
214
260
 
215
261
  Passing `autoprefixer: false` disables autoprefixer.
216
262
 
263
+ ⚠️ [autoprefixer] has [complex logic to fix CSS Grid in IE en older Edge](https://github.com/postcss/autoprefixer#grid-autoplacement-support-in-ie).
264
+
265
+ This can have unexpected results with certain features and when [`preserve: true`](#preserve) is used. (defaults to `true`)
266
+
267
+ ```pcss
268
+ :root {
269
+ --grid-gap: 15px;
270
+ }
271
+
272
+ .test-grid {
273
+ grid-gap: var(--grid-gap);
274
+ grid-template-columns: repeat(2, 1fr);
275
+ }
276
+ ```
277
+
278
+ Becomes :
279
+
280
+ ```
281
+ .test-grid {
282
+ grid-gap: 15px;
283
+ grid-gap: var(--grid-gap);
284
+ -ms-grid-columns: 1fr var(--grid-gap) 1fr;
285
+ grid-template-columns: repeat(2, 1fr);
286
+ }
287
+ ```
288
+
289
+ The prefixed `-ms-grid-columns` still has a custom property: `1fr var(--grid-gap) 1fr;` which won't work.<br />
290
+ This example shows issues with custom properties but other transforms might have similar issues.
291
+
292
+ If you target IE or older Edge it is best to avoid using other modern features in grid property values.<br />
293
+ As a last resort you can set [`preserve: false`](#preserve), we do not advice this as doing so purely to fix issues with CSS grid.
294
+
295
+ _older Edge is any version before chromium (<79)_
296
+
217
297
  ### preserve
218
298
 
219
299
  The `preserve` option determines whether all plugins should receive a
@@ -354,12 +434,61 @@ postcssPresetEnv({
354
434
  });
355
435
  ```
356
436
 
437
+ ### debug
438
+
439
+ The `debug` option enables debugging messages to stdout which should be useful to help you debug which features have been enabled/disabled and why.
440
+
441
+ ### enableClientSidePolyfills
442
+
443
+ The `enableClientSidePolyfills` enables any feature that would need an extra browser library to be loaded into the page for it to work. Defaults to `true`.
444
+
445
+ Note that manually enabling/disabling features via the "feature" option overrides this flag.
446
+
447
+ ## Stability and Portability
448
+
449
+ [PostCSS Preset Env] will often include very modern CSS features that are not fully ready yet.
450
+ This gives users the chance to play around with these features and provide feedback.
451
+
452
+ If the specification changes or is abandoned a new major version of the plugin will be released.
453
+ This will require you to update your source code so that everything works as expected.
454
+
455
+ To have more stability between updates of [PostCSS Preset Env] you may set `stage: 3` and/or `minimumVendorImplementations: 2`.
456
+
457
+ A side effect of staying close to the standard is that you can more easily migrate your project to other tooling all together.
458
+
459
+ ## Plugins list
460
+
461
+ ### Plugins that need client library
462
+
463
+ This is the current list of features that need a client library with a link
464
+ to the polyfill's library.
465
+
466
+ * `blank-pseudo-class`: [Plugin](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-blank-pseudo) / [Polyfill](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-blank-pseudo/README-BROWSER.md)
467
+ * `focus-visible-pseudo-class`: [Plugin](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-focus-visible) / [Polyfill](https://github.com/WICG/focus-visible)
468
+ * `focus-within-pseudo-class`: [Plugin](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-focus-within) / [Library](https://github.com/jsxtools/focus-within) / [Polyfill](https://github.com/jsxtools/focus-within/blob/master/README-BROWSER.md)
469
+ * `has-pseudo-class`: [Plugin](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-has-pseudo) / [Polyfill](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-has-pseudo/README-BROWSER.md)
470
+ * `prefers-color-scheme-query`: [Plugin](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-prefers-color-scheme) / [Polyfill](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-prefers-color-scheme/README-BROWSER.md)
471
+
472
+ If you want to disable these types of features, please check the [`enableClientSidePolyfills` option](#enableclientsidepolyfills).
473
+
474
+ ### Plugins not affected by Browser Support
475
+
476
+ Given they have no support they will always be enabled if they match by Stage:
477
+
478
+ * `blank-pseudo-class`: [Plugin](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-blank-pseudo) / [Polyfill](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-blank-pseudo/README-BROWSER.md)
479
+ * `custom-media-queries`: [Plugin](https://github.com/postcss/postcss-custom-media)
480
+ * `has-pseudo-class`: [Plugin](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-has-pseudo) / [Polyfill](https://github.com/csstools/postcss-plugins/blob/main/plugins/css-has-pseudo/README-BROWSER.md)
481
+ * `image-set-function`: [Plugin](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-image-set-function)
482
+ * `media-query-ranges`: [Plugin](https://github.com/postcss/postcss-media-minmax)
483
+ * `nesting-rules`: [Plugin](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting)
484
+
357
485
  [cli-img]: https://github.com/csstools/postcss-plugins/workflows/test/badge.svg
358
486
  [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
359
- [git-img]: https://img.shields.io/badge/support-chat-blue.svg
360
- [git-url]: https://gitter.im/postcss/postcss
487
+ [discord]: https://discord.gg/bUadyRwkJS
361
488
  [npm-img]: https://img.shields.io/npm/v/postcss-preset-env.svg
362
489
  [npm-url]: https://www.npmjs.com/package/postcss-preset-env
490
+ [package-phobia-badge]: https://packagephobia.com/badge?p=postcss-preset-env
491
+ [package-phobia]: https://packagephobia.com/result?p=postcss-preset-env
363
492
 
364
493
  [autoprefixer]: https://github.com/postcss/autoprefixer
365
494
  [browserslist]: https://github.com/browserslist/browserslist#readme
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("autoprefixer"),s=require("browserslist"),t=require("cssdb"),o=require("postcss-attribute-case-insensitive"),r=require("css-blank-pseudo"),n=require("postcss-color-functional-notation"),i=require("postcss-color-hex-alpha"),c=require("postcss-color-rebeccapurple"),u=require("postcss-custom-media"),a=require("postcss-custom-properties"),p=require("postcss-custom-selectors"),l=require("postcss-dir-pseudo-class"),f=require("postcss-double-position-gradients"),d=require("postcss-env-function"),m=require("postcss-focus-visible"),b=require("postcss-focus-within"),g=require("postcss-font-variant"),y=require("postcss-gap-properties"),O=require("css-has-pseudo"),j=require("postcss-image-set-function"),h=require("postcss-initial"),v=require("postcss-lab-function"),w=require("postcss-logical"),k=require("postcss-media-minmax"),$=require("postcss-nesting"),q=require("postcss-overflow-shorthand"),x=require("postcss-page-break"),S=require("postcss-place"),P=require("css-prefers-color-scheme"),M=require("postcss-pseudo-class-any-link"),F=require("postcss-replace-overflow-wrap"),T=require("postcss-selector-not"),B=require("caniuse-lite"),U=require("fs"),V=require("path");function A(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function E(e){if(e&&e.__esModule)return e;var s=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),s.default=e,Object.freeze(s)}var I=A(e),N=A(s),C=A(t),D=A(o),J=A(r),R=A(n),_=A(i),z=A(c),L=A(u),G=A(a),H=A(p),K=A(l),Q=A(f),W=A(d),X=A(m),Y=A(b),Z=A(g),ee=A(y),se=A(O),te=A(j),oe=A(h),re=A(v),ne=A(w),ie=A(k),ce=A($),ue=A(q),ae=A(x),pe=A(S),le=A(P),fe=A(M),de=A(F),me=A(T),be=E(B),ge=A(U),ye=A(V);function Oe(){return{postcssPlugin:"postcss-system-ui-font",Declaration(e){je.test(e.prop)&&(e.value.includes(ve.join(", "))||(e.value=e.value.replace(we,ke)))}}}Oe.postcss=!0;const je=/(?:^(?:-|\\002d){2})|(?:^font(?:-family)?$)/i,he="[\\f\\n\\r\\x09\\x20]",ve=["system-ui","-apple-system","Segoe UI","Roboto","Ubuntu","Cantarell","Noto Sans","sans-serif"],we=new RegExp(`(^|,|${he}+)(?:system-ui${he}*)(?:,${he}*(?:${ve.join("|")})${he}*)?(,|$)`,"i"),ke=`$1${ve.join(", ")}$2`,$e={"css-blank-pseudo":"blank-pseudo-class","css-has-pseudo":"has-pseudo-class","css-prefers-color-scheme":"prefers-color-scheme-query","postcss-attribute-case-insensitive":"case-insensitive-attributes","postcss-color-functional-notation":"color-functional-notation","postcss-color-hex-alpha":"hexadecimal-alpha-notation","postcss-color-rebeccapurple":"rebeccapurple-color","postcss-custom-media":"custom-media-queries","postcss-custom-properties":"custom-properties","postcss-custom-selectors":"custom-selectors","postcss-dir-pseudo-class":"dir-pseudo-class","postcss-double-position-gradients":"double-position-gradients","postcss-env-function":"environment-variables","postcss-focus-visible":"focus-visible-pseudo-class","postcss-focus-within":"focus-within-pseudo-class","postcss-font-variant":"font-variant-property","postcss-gap-properties":"gap-properties","postcss-image-set-function":"image-set-function","postcss-initial":"all-property","postcss-lab-function":"lab-function","postcss-logical":"logical-properties-and-values","postcss-media-minmax":"media-query-ranges","postcss-nesting":"nesting-rules","postcss-overflow-shorthand":"overflow-property","postcss-page-break":"break-properties","postcss-place":"place-properties","postcss-pseudo-class-any-link":"any-link-pseudo-class","postcss-replace-overflow-wrap":"overflow-wrap-property","postcss-selector-not":"not-pseudo-class","postcss-system-ui-font-family":"system-ui-font-family"},qe=(()=>{const e={};for(const[s,t]of Object.entries($e))e[t]=s;return e})(),xe={"all-property":oe.default,"any-link-pseudo-class":fe.default,"blank-pseudo-class":J.default,"break-properties":ae.default,"case-insensitive-attributes":D.default,"color-functional-notation":R.default,"custom-media-queries":L.default,"custom-properties":G.default,"custom-selectors":H.default,"dir-pseudo-class":K.default,"double-position-gradients":Q.default,"environment-variables":W.default,"focus-visible-pseudo-class":X.default,"focus-within-pseudo-class":Y.default,"font-variant-property":Z.default,"gap-properties":ee.default,"has-pseudo-class":se.default,"hexadecimal-alpha-notation":_.default,"image-set-function":te.default,"lab-function":re.default,"logical-properties-and-values":ne.default,"media-query-ranges":ie.default,"nesting-rules":ce.default,"not-pseudo-class":me.default,"overflow-property":ue.default,"overflow-wrap-property":de.default,"place-properties":pe.default,"prefers-color-scheme-query":le.default,"rebeccapurple-color":z.default,"system-ui-font-family":Oe};function Se(e,s){return Object.keys(e).map((t=>[].concat(e[t]).map((e=>({[s]:!0,plugin:e,id:t}))))).reduce(((e,s)=>e.concat(s)),[])}function Pe(e){const s=be.features[e];if(s){const e=be.feature(s).stats;return Object.keys(e).reduce(((s,t)=>s.concat(Object.keys(e[t]).filter((s=>0!==e[t][s].indexOf("y"))).map((e=>`${t} ${e}`)))),[])}return["> 0%"]}var Me=["custom-media-queries","custom-properties","environment-variables","image-set-function","media-query-ranges","prefers-color-scheme-query","nesting-rules","custom-selectors","any-link-pseudo-class","case-insensitive-attributes","focus-visible-pseudo-class","focus-within-pseudo-class","matches-pseudo-class","not-pseudo-class","logical-properties-and-values","dir-pseudo-class","all-property","color-functional-notation","double-position-gradients","hexadecimal-alpha-notation","lab-function","rebeccapurple-color","color-mod-function","blank-pseudo-class","break-properties","font-variant-property","has-pseudo-class","gap-properties","overflow-property","overflow-wrap-property","place-properties","system-ui-font-family"];async function Fe(e,s,t,o){const r=function(e){return`:root {\n${Object.keys(e).reduce(((s,t)=>(s.push(`\t${t}: ${e[t]};`),s)),[]).join("\n")}\n}\n`}(t),n=function(e){return`${Object.keys(e).reduce(((s,t)=>(s.push(`@custom-media ${t} ${e[t]};`),s)),[]).join("\n")}\n`}(s),i=function(e){return`${Object.keys(e).reduce(((s,t)=>(s.push(`@custom-selector ${t} ${e[t]};`),s)),[]).join("\n")}\n`}(o),c=`${n}\n${i}\n${r}`;await Ae(e,c)}function Te(e,s){return`\n\t${e}: {\n${Object.keys(s).reduce(((e,t)=>(e.push(`\t\t'${Ee(t)}': '${Ee(s[t])}'`),e)),[]).join(",\n")}\n\t}`}function Be(e,s){return`export const ${e} = {\n${Object.keys(s).reduce(((e,t)=>(e.push(`\t'${Ee(t)}': '${Ee(s[t])}'`),e)),[]).join(",\n")}\n};\n`}function Ue(e,s){return Promise.all([].concat(s).map((async s=>{if(s instanceof Function)await s({customMedia:Ve(e.customMedia),customProperties:Ve(e.customProperties),customSelectors:Ve(e.customSelectors)});else{const t=s===Object(s)?s:{to:String(s)},o=t.toJSON||Ve;if("customMedia"in t||"customProperties"in t||"customSelectors"in t)t.customMedia=o(e.customMedia),t.customProperties=o(e.customProperties),t.customSelectors=o(e.customSelectors);else if("custom-media"in t||"custom-properties"in t||"custom-selectors"in t)t["custom-media"]=o(e.customMedia),t["custom-properties"]=o(e.customProperties),t["custom-selectors"]=o(e.customSelectors);else{const s=String(t.to||""),r=(t.type||ye.default.extname(t.to).slice(1)).toLowerCase(),n=o(e.customMedia),i=o(e.customProperties),c=o(e.customSelectors);"css"===r&&await Fe(s,n,i,c),"js"===r&&await async function(e,s,t,o){const r=`module.exports = {${Te("customMedia",s)},${Te("customProperties",t)},${Te("customSelectors",o)}\n};\n`;await Ae(e,r)}(s,n,i,c),"json"===r&&await async function(e,s,t,o){const r=`${JSON.stringify({"custom-media":s,"custom-properties":t,"custom-selectors":o},null," ")}\n`;await Ae(e,r)}(s,n,i,c),"mjs"===r&&await async function(e,s,t,o){const r=`${Be("customMedia",s)}\n${Be("customProperties",t)}\n${Be("customSelectors",o)}`;await Ae(e,r)}(s,n,i,c)}}})))}function Ve(e){return Object.keys(e).reduce(((s,t)=>(s[t]=String(e[t]),s)),{})}function Ae(e,s){return new Promise(((t,o)=>{ge.default.writeFile(e,s,(e=>{e?o(e):t()}))}))}function Ee(e){return e.replace(/\\([\s\S])|(')/g,"\\$1$2").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}function Ie(e,s){const t=N.default(e,{ignoreUnknownVersions:!0});return"nesting-rules"===s.id&&function(e,s){const t=Pe(e);if(s.some((e=>N.default(t,{ignoreUnknownVersions:!0}).some((s=>s===e)))))return!0;return!1}("css-matches-pseudo",t)?{noIsPseudoSelector:!0}:{}}function Ne(e,s){let t="unknown",o=1/0;for(let r=0;r<s.length;r++){const n=Ce(e,s[r]);n<o&&(o=n,t=s[r])}return{mostSimilar:t,distance:o}}function Ce(e,s){if(!e.length)return s.length;if(!s.length)return e.length;const t=[];for(let o=0;o<=s.length;o++){t[o]=[o];for(let r=1;r<=e.length;r++)t[o][r]=0===o?r:Math.min(t[o-1][r]+1,t[o][r-1]+1,t[o-1][r-1]+(e[r-1]===s[o-1]?0:1))}return t[s.length][e.length]}const De=e=>{const s=Object(Object(e).features),t=Object.keys(s),o=Object(Object(e).insertBefore),r=Object(Object(e).insertAfter),n=Object(e).browsers,i="stage"in Object(e)?!1===e.stage?5:parseInt(e.stage)||0:2,c=Object(e).autoprefixer,u=Je(Object(e)),a=!1===c?()=>{}:I.default(Object.assign({overrideBrowserslist:n},c)),p=C.default.concat(Se(o,"insertBefore"),Se(r,"insertAfter")).filter((e=>e.insertBefore||e.id in xe)).sort(((e,s)=>Me.indexOf(e.id)-Me.indexOf(s.id)||(e.insertBefore?-1:s.insertBefore?1:0)||(e.insertAfter?1:s.insertAfter?-1:0))).map((e=>{const s=Pe(e.caniuse);return e.insertBefore||e.insertAfter?{browsers:s,plugin:e.plugin,id:`${e.insertBefore?"before":"after"}-${e.id}`,stage:6}:{browsers:s,plugin:xe[e.id],id:e.id,stage:e.stage}})).filter((e=>e.id in s?s[e.id]:e.stage>=i)).map((e=>{let t,o;return t=Ie(n,e),t=!0===s[e.id]?u?Object.assign({},t,u):void 0:u?Object.assign({},t,u,s[e.id]):Object.assign({},t,s[e.id]),o=e.plugin.postcss?e.plugin(t):e.plugin,{browsers:e.browsers,plugin:o,pluginOptions:t,id:e.id}})),l=N.default(n,{ignoreUnknownVersions:!0}),f=p.filter((e=>e.id in s?s[e.id]:!!function(e){if("importFrom"in e.pluginOptions)switch(e.id){case"custom-media-queries":if(Object.keys(Object(e.pluginOptions.importFrom.customMedia)).length)return!0;break;case"custom-properties":if(Object.keys(Object(e.pluginOptions.importFrom.customProperties)).length)return!0;break;case"environment-variables":if(Object.keys(Object(e.pluginOptions.importFrom.environmentVariables)).length)return!0;break;case"custom-selectors":if(Object.keys(Object(e.pluginOptions.importFrom.customSelectors)).length)return!0}if("exportTo"in e.pluginOptions)switch(e.id){case"custom-media-queries":if(Object.keys(Object(e.pluginOptions.exportTo.customMedia)).length)return!0;break;case"custom-properties":if(Object.keys(Object(e.pluginOptions.exportTo.customProperties)).length)return!0;break;case"environment-variables":if(Object.keys(Object(e.pluginOptions.exportTo.environmentVariables)).length)return!0;break;case"custom-selectors":if(Object.keys(Object(e.pluginOptions.exportTo.customSelectors)).length)return!0}return!1}(e)||l.some((s=>N.default(e.browsers,{ignoreUnknownVersions:!0}).some((e=>e===s)))))).map((e=>e.plugin));f.push(a);const d=()=>({postcssPlugin:"postcss-preset-env",OnceExit:function(s,{result:o}){!function(e,s,t){const o=Object.keys(qe),r=Object.keys($e);e.forEach((e=>{if(o.includes(e))return;const n=Ne(e,o),i=Ne(e,r);n.distance<i.distance?s.warn(t,`Unknown feature: "${e}" did you mean: "${n.mostSimilar}"`):s.warn(t,`Unknown feature: "${e}" did you mean: "${$e[i.mostSimilar]}"`)}))}(t,s,o),Object(e).exportTo&&Ue(u.exportTo,e.exportTo)}});return d.postcss=!0,{postcssPlugin:"postcss-preset-env",plugins:[...f,d()]}},Je=e=>{if("importFrom"in e||"exportTo"in e||"preserve"in e){const s={};return"importFrom"in e&&(s.importFrom=e.importFrom),"exportTo"in e&&(s.exportTo={customMedia:{},customProperties:{},customSelectors:{}}),"preserve"in e&&(s.preserve=e.preserve),s}return!1};De.postcss=!0,module.exports=De;
1
+ "use strict";var e=require("autoprefixer"),s=require("cssdb"),t=require("@csstools/postcss-progressive-custom-properties"),o=require("fs"),r=require("path"),i=require("browserslist"),n=require("postcss-attribute-case-insensitive"),c=require("css-blank-pseudo"),u=require("postcss-color-functional-notation"),a=require("postcss-color-hex-alpha"),l=require("postcss-color-rebeccapurple"),p=require("postcss-custom-media"),f=require("postcss-custom-properties"),d=require("postcss-custom-selectors"),m=require("postcss-dir-pseudo-class"),g=require("postcss-double-position-gradients"),b=require("postcss-env-function"),h=require("postcss-focus-visible"),y=require("postcss-focus-within"),w=require("postcss-font-variant"),v=require("postcss-gap-properties"),$=require("css-has-pseudo"),q=require("postcss-image-set-function"),k=require("postcss-initial"),O=require("postcss-lab-function"),S=require("postcss-logical"),j=require("postcss-media-minmax"),x=require("postcss-nesting"),P=require("postcss-overflow-shorthand"),E=require("postcss-page-break"),M=require("postcss-place"),_=require("css-prefers-color-scheme"),R=require("postcss-pseudo-class-any-link"),A=require("postcss-replace-overflow-wrap"),F=require("postcss-selector-not"),N=require("@csstools/postcss-is-pseudo-class"),T=require("@csstools/postcss-hwb-function"),B=require("postcss-opacity-percentage"),U=require("postcss-clamp"),W=require("@csstools/postcss-font-format-keywords"),C=require("@csstools/postcss-normalize-display-values");function I(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var V=I(e),D=I(s),L=I(t),J=I(o),z=I(r),G=I(i),H=I(n),K=I(c),Q=I(u),X=I(a),Y=I(l),Z=I(p),ee=I(f),se=I(d),te=I(m),oe=I(g),re=I(b),ie=I(h),ne=I(y),ce=I(w),ue=I(v),ae=I($),le=I(q),pe=I(k),fe=I(O),de=I(S),me=I(j),ge=I(x),be=I(P),he=I(E),ye=I(M),we=I(_),ve=I(R),$e=I(A),qe=I(F),ke=I(N),Oe=I(T),Se=I(B),je=I(U),xe=I(W),Pe=I(C);const Ee={"blank-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-blank-pseudo/README-BROWSER.md","focus-visible-pseudo-class":"https://github.com/WICG/focus-visible","focus-within-pseudo-class":"https://github.com/jsxtools/focus-within/blob/master/README-BROWSER.md","has-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-has-pseudo/README-BROWSER.md","prefers-color-scheme-query":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-prefers-color-scheme/README-BROWSER.md"},Me=["blank-pseudo-class","focus-visible-pseudo-class","focus-within-pseudo-class","has-pseudo-class","prefers-color-scheme-query"];async function _e(e,s,t,o){const r=function(e){return`:root {\n${Object.keys(e).reduce(((s,t)=>(s.push(`\t${t}: ${e[t]};`),s)),[]).join("\n")}\n}\n`}(t),i=function(e){return`${Object.keys(e).reduce(((s,t)=>(s.push(`@custom-media ${t} ${e[t]};`),s)),[]).join("\n")}\n`}(s),n=function(e){return`${Object.keys(e).reduce(((s,t)=>(s.push(`@custom-selector ${t} ${e[t]};`),s)),[]).join("\n")}\n`}(o),c=`${i}\n${n}\n${r}`;await Te(e,c)}function Re(e,s){return`\n\t${e}: {\n${Object.keys(s).reduce(((e,t)=>(e.push(`\t\t'${Be(t)}': '${Be(s[t])}'`),e)),[]).join(",\n")}\n\t}`}function Ae(e,s){return`export const ${e} = {\n${Object.keys(s).reduce(((e,t)=>(e.push(`\t'${Be(t)}': '${Be(s[t])}'`),e)),[]).join(",\n")}\n};\n`}function Fe(e,s){return Promise.all([].concat(s).map((async s=>{if(s instanceof Function)await s({customMedia:Ne(e.customMedia),customProperties:Ne(e.customProperties),customSelectors:Ne(e.customSelectors)});else{const t=s===Object(s)?s:{to:String(s)},o=t.toJSON||Ne;if("customMedia"in t||"customProperties"in t||"customSelectors"in t)t.customMedia=o(e.customMedia),t.customProperties=o(e.customProperties),t.customSelectors=o(e.customSelectors);else if("custom-media"in t||"custom-properties"in t||"custom-selectors"in t)t["custom-media"]=o(e.customMedia),t["custom-properties"]=o(e.customProperties),t["custom-selectors"]=o(e.customSelectors);else{const s=String(t.to||""),r=(t.type||z.default.extname(t.to).slice(1)).toLowerCase(),i=o(e.customMedia),n=o(e.customProperties),c=o(e.customSelectors);"css"===r&&await _e(s,i,n,c),"js"===r&&await async function(e,s,t,o){const r=`module.exports = {${Re("customMedia",s)},${Re("customProperties",t)},${Re("customSelectors",o)}\n};\n`;await Te(e,r)}(s,i,n,c),"json"===r&&await async function(e,s,t,o){const r=`${JSON.stringify({"custom-media":s,"custom-properties":t,"custom-selectors":o},null," ")}\n`;await Te(e,r)}(s,i,n,c),"mjs"===r&&await async function(e,s,t,o){const r=`${Ae("customMedia",s)}\n${Ae("customProperties",t)}\n${Ae("customSelectors",o)}`;await Te(e,r)}(s,i,n,c)}}})))}function Ne(e){return Object.keys(e).reduce(((s,t)=>(s[t]=String(e[t]),s)),{})}function Te(e,s){return new Promise(((t,o)=>{J.default.writeFile(e,s,(e=>{e?o(e):t()}))}))}function Be(e){return e.replace(/\\([\s\S])|(')/g,"\\$1$2").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}function Ue(e,s){if(!e)return!1;if("string"==typeof e)return!0;if(Array.isArray(e)){for(let t=0;t<e.length;t++){if("string"==typeof e[t])return!0;if(e[t]&&s in Object(e[t]))return!0}return!1}return s in Object(e)}function We(e,s,t){return Math.max(e,Math.min(s,t))}const Ce=Symbol("insertBefore"),Ie=Symbol("insertAfter"),Ve=Symbol("insertOrder"),De=Symbol("plugin");function Le(e,s,t){if("insertBefore"!==t&&"insertAfter"!==t)return[];const o="insertBefore"===t?Ce:Ie,r=[];for(const t in s){if(!Object.hasOwnProperty.call(s,t))continue;if(!e.find((e=>e.id===t)))continue;let i=s[t];Array.isArray(i)||(i=[i]);for(let e=0;e<i.length;e++)r.push({id:t,[De]:i[e],[Ve]:e,[o]:!0})}return r}var Je=["custom-media-queries","custom-properties","environment-variables","image-set-function","media-query-ranges","prefers-color-scheme-query","nesting-rules","custom-selectors","any-link-pseudo-class","case-insensitive-attributes","focus-visible-pseudo-class","focus-within-pseudo-class","not-pseudo-class","logical-properties-and-values","dir-pseudo-class","all-property","color-functional-notation","double-position-gradients","hexadecimal-alpha-notation","hwb-function","lab-function","rebeccapurple-color","blank-pseudo-class","break-properties","font-variant-property","is-pseudo-class","has-pseudo-class","gap-properties","overflow-property","overflow-wrap-property","place-properties","system-ui-font-family"];function ze(){return{postcssPlugin:"postcss-system-ui-font",Declaration(e){Ge.test(e.prop)&&(e.value.includes(Ke.join(", "))||(e.value=e.value.replace(Qe,Xe)))}}}ze.postcss=!0;const Ge=/(?:^(?:-|\\002d){2})|(?:^font(?:-family)?$)/i,He="[\\f\\n\\r\\x09\\x20]",Ke=["system-ui","-apple-system","Segoe UI","Roboto","Ubuntu","Cantarell","Noto Sans","sans-serif"],Qe=new RegExp(`(^|,|${He}+)(?:system-ui${He}*)(?:,${He}*(?:${Ke.join("|")})${He}*)?(,|$)`,"i"),Xe=`$1${Ke.join(", ")}$2`,Ye={"css-blank-pseudo":"blank-pseudo-class","css-has-pseudo":"has-pseudo-class","css-prefers-color-scheme":"prefers-color-scheme-query","postcss-attribute-case-insensitive":"case-insensitive-attributes","postcss-clamp":"clamp","postcss-color-functional-notation":"color-functional-notation","postcss-color-hex-alpha":"hexadecimal-alpha-notation","postcss-color-rebeccapurple":"rebeccapurple-color","postcss-custom-media":"custom-media-queries","postcss-custom-properties":"custom-properties","postcss-custom-selectors":"custom-selectors","postcss-dir-pseudo-class":"dir-pseudo-class","postcss-double-position-gradients":"double-position-gradients","postcss-env-function":"environment-variables","postcss-focus-visible":"focus-visible-pseudo-class","postcss-focus-within":"focus-within-pseudo-class","postcss-font-format-keywords":"font-format-keywords","postcss-font-variant":"font-variant-property","postcss-gap-properties":"gap-properties","postcss-hwb-function":"hwb-function","postcss-image-set-function":"image-set-function","postcss-initial":"all-property","postcss-is-pseudo-class":"is-pseudo-class","postcss-lab-function":"lab-function","postcss-logical":"logical-properties-and-values","postcss-media-minmax":"media-query-ranges","postcss-nesting":"nesting-rules","postcss-normalize-display-values":"display-two-values","postcss-opacity-percentage":"opacity-percentage","postcss-overflow-shorthand":"overflow-property","postcss-page-break":"break-properties","postcss-place":"place-properties","postcss-pseudo-class-any-link":"any-link-pseudo-class","postcss-replace-overflow-wrap":"overflow-wrap-property","postcss-selector-not":"not-pseudo-class","postcss-system-ui-font-family":"system-ui-font-family"},Ze=(()=>{const e={};for(const[s,t]of Object.entries(Ye))e[t]=s;return e})(),es=new Map([["all-property",pe.default],["any-link-pseudo-class",ve.default],["blank-pseudo-class",K.default],["break-properties",he.default],["case-insensitive-attributes",H.default],["clamp",je.default],["color-functional-notation",Q.default],["custom-media-queries",Z.default],["custom-properties",ee.default],["custom-selectors",se.default],["dir-pseudo-class",te.default],["display-two-values",Pe.default],["double-position-gradients",oe.default],["environment-variables",re.default],["focus-visible-pseudo-class",ie.default],["focus-within-pseudo-class",ne.default],["font-format-keywords",xe.default],["font-variant-property",ce.default],["gap-properties",ue.default],["hwb-function",Oe.default],["has-pseudo-class",ae.default],["hexadecimal-alpha-notation",X.default],["image-set-function",le.default],["is-pseudo-class",ke.default],["lab-function",fe.default],["logical-properties-and-values",de.default],["media-query-ranges",me.default],["nesting-rules",ge.default],["not-pseudo-class",qe.default],["opacity-percentage",Se.default],["overflow-property",be.default],["overflow-wrap-property",$e.default],["place-properties",ye.default],["prefers-color-scheme-query",we.default],["rebeccapurple-color",Y.default],["system-ui-font-family",ze]]);function ss(e,s,t){return e.concat(Le(e,s,"insertBefore"),Le(e,t,"insertAfter")).filter((e=>function(e){return!!e[Ce]||!!e[Ie]||!!es.has(e.id)}(e))).sort(((e,s)=>function(e,s){return e.id===s.id?e[Ce]&&s[Ce]||e[Ie]&&s[Ie]?We(-1,e[Ve]-s[Ve],1):e[Ce]||s[Ie]?-1:e[Ie]||s[Ce]?1:0:We(-1,Je.indexOf(e.id)-Je.indexOf(s.id),1)}(e,s)))}const ts=["ie","edge","firefox","chrome","safari","opera","ios_saf","android","op_mob","and_chr","and_ff","and_uc","samsung","and_qq","baidu","kaios"];function os(e){if(!e)return[];if(!("browser_support"in e))return["> 0%"];const s=[];return ts.forEach((t=>{const o=e.browser_support[t];"string"==typeof o&&/^[0-9|.]+$/.test(o)?s.push(`${t} < ${e.browser_support[t]}`):s.push(`${t} >= 1`)})),s}function rs(e,s,t,o){const r=G.default(e,{ignoreUnknownVersions:!0});switch(s.id){case"is-pseudo-class":return{onComplexSelector:"warning"};case"nesting-rules":if(function(e,s){const t=os(e);if(s.some((e=>G.default(t,{ignoreUnknownVersions:!0}).some((s=>s===e)))))return!0;return!1}(t.find((e=>"is-pseudo-class"===e.id)),r))return o.log('Disabling :is on "nesting-rules" due to lack of browser support.'),{noIsPseudoSelector:!0};return{};case"any-link-pseudo-class":if(r.find((e=>e.startsWith("ie ")||e.startsWith("edge "))))return o.log('Adding area[href] fallbacks for ":any-link" support in Edge and IE.'),{subFeatures:{areaHrefNeedsFixing:!0}};return{};default:return{}}}function is(e,s,t,o){const r=Object(s.features),i=!("enableClientSidePolyfills"in s)||s.enableClientSidePolyfills,n=Object(s.insertBefore),c=Object(s.insertAfter),u=s.browsers,a=We(0,function(e){const s=parseInt(e,10);return Number.isNaN(s)?0:s}(s.minimumVendorImplementations),3);a>0&&o.log(`Using features with ${a} or more vendor implementations`);const l=function(e,s){let t=2;if(void 0===e.stage)return s.log(`Using features from Stage ${t} (default)`),t;if(!1===e.stage)t=5;else{let s=parseInt(e.stage,10);Number.isNaN(s)&&(s=0),t=We(0,s,5)}return 5===t?s.log('Stage has been disabled, features will be handled via the "features" option.'):s.log(`Using features from Stage ${t}`),t}(s,o);2===l&&t&&!1===t.preserve&&(e=JSON.parse(JSON.stringify(e))).forEach((e=>{("blank-pseudo-class"===e.id||"prefers-color-scheme-query"===e.id)&&(e.stage=1)}));const p=ss(e,n,c).map((e=>function(e){const s=os(e);if(e[Ce]||e[Ie]){let t=e.id;return t=e.insertBefore?`before-${t}`:`after-${t}`,{browsers:s,vendors_implementations:e.vendors_implementations,plugin:e[De],id:t,stage:6}}return{browsers:s,vendors_implementations:e.vendors_implementations,plugin:es.get(e.id),id:e.id,stage:e.stage}}(e))).filter((e=>0===a||(!(!e[Ce]&&!e[Ie])||(a<=e.vendors_implementations||(o.log(` ${e.id} with ${e.vendors_implementations} vendor implementations has been disabled`),!1))))).filter((e=>{const s=e.stage>=l,t=i||!Me.includes(e.id),n=!1===r[e.id],c=r[e.id]?r[e.id]:s&&t;return n?o.log(` ${e.id} has been disabled by options`):s?t||o.log(` ${e.id} has been disabled by "enableClientSidePolyfills: false".`):c?o.log(` ${e.id} has been enabled by options`):o.log(` ${e.id} with stage ${e.stage} has been disabled`),c})).map((s=>function(e,s,t,o,r,i){let n,c;return n=rs(s,o,e,i),!0===t[o.id]?r&&(n=Object.assign({},n,r)):n=r?Object.assign({},n,r,t[o.id]):Object.assign({},n,t[o.id]),n.enableProgressiveCustomProperties=!1,c=o.plugin.postcss&&"function"==typeof o.plugin?o.plugin(n):o.plugin&&o.plugin.default&&"function"==typeof o.plugin.default&&o.plugin.default.postcss?o.plugin.default(n):o.plugin,{browsers:o.browsers,vendors_implementations:o.vendors_implementations,plugin:c,pluginOptions:n,id:o.id}}(e,u,r,s,t,o))),f=G.default(u,{ignoreUnknownVersions:!0});return p.filter((e=>{if(e.id in r)return r[e.id];if(function(e){if("importFrom"in Object(e.pluginOptions))switch(e.id){case"custom-media-queries":if(Ue(e.pluginOptions.importFrom,"customMedia"))return!0;break;case"custom-properties":if(Ue(e.pluginOptions.importFrom,"customProperties"))return!0;break;case"environment-variables":if(Ue(e.pluginOptions.importFrom,"environmentVariables"))return!0;break;case"custom-selectors":if(Ue(e.pluginOptions.importFrom,"customSelectors"))return!0}if("exportTo"in Object(e.pluginOptions))switch(e.id){case"custom-media-queries":if(Ue(e.pluginOptions.exportTo,"customMedia"))return!0;break;case"custom-properties":if(Ue(e.pluginOptions.exportTo,"customProperties"))return!0;break;case"environment-variables":if(Ue(e.pluginOptions.exportTo,"environmentVariables"))return!0;break;case"custom-selectors":if(Ue(e.pluginOptions.exportTo,"customSelectors"))return!0}return!1}(e))return!0;const s=G.default(e.browsers,{ignoreUnknownVersions:!0}),t=f.some((e=>s.some((s=>s===e))));return t||o.log(`${e.id} disabled due to browser support`),t}))}class ns{constructor(){this.logs=[]}log(e){this.logs.push(e)}resetLogger(){this.logs.length=0}dumpLogs(e){e&&this.logs.forEach((s=>e.warn(s))),this.resetLogger()}}function cs(e,s){let t="unknown",o=1/0;for(let r=0;r<s.length;r++){const i=us(e,s[r]);i<o&&(o=i,t=s[r])}return{mostSimilar:t,distance:o}}function us(e,s){if(!e.length)return s.length;if(!s.length)return e.length;const t=[];for(let o=0;o<=s.length;o++){t[o]=[o];for(let r=1;r<=e.length;r++)t[o][r]=0===o?r:Math.min(t[o-1][r]+1,t[o][r-1]+1,t[o-1][r-1]+(e[r-1]===s[o-1]?0:1))}return t[s.length][e.length]}const as=e=>{const s=new ns,t=Object(e),o=Object.keys(Object(t.features)),r=t.browsers,i=function(e){if("importFrom"in e||"exportTo"in e||"preserve"in e){const s={};return"importFrom"in e&&(s.importFrom=e.importFrom),"exportTo"in e&&(s.exportTo={customMedia:{},customProperties:{},customSelectors:{}}),"preserve"in e&&(s.preserve=e.preserve),s}return!1}(t),n=is(D.default,t,i,s),c=n.map((e=>e.plugin));!1!==t.autoprefixer&&c.push(V.default(Object.assign({overrideBrowserslist:r},t.autoprefixer))),c.push(L.default()),function(e,s,t){if(s.debug){t.log("Enabling the following feature(s):");const s=[];e.forEach((e=>{e.id.startsWith("before")||e.id.startsWith("after")?t.log(` ${e.id} (injected via options)`):t.log(` ${e.id}`),void 0!==Ee[e.id]&&s.push(e.id)})),s.length&&(t.log("These feature(s) need a browser library to work:"),s.forEach((e=>t.log(` ${e}: ${Ee[e]}`))))}}(n,t,s);const u=()=>({postcssPlugin:"postcss-preset-env",OnceExit:function(r,{result:n}){!function(e,s,t){const o=Object.keys(Ze),r=Object.keys(Ye);e.forEach((e=>{if(o.includes(e))return;const i=cs(e,o),n=cs(e,r);i.distance<n.distance?s.warn(t,`Unknown feature: "${e}" did you mean: "${i.mostSimilar}"`):s.warn(t,`Unknown feature: "${e}" did you mean: "${Ye[n.mostSimilar]}"`)}))}(o,r,n),t.debug&&s.dumpLogs(n),s.resetLogger(),t.exportTo&&Fe(i.exportTo,e.exportTo)}});return u.postcss=!0,{postcssPlugin:"postcss-preset-env",plugins:[...c,u()]}};as.postcss=!0,module.exports=as;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import s from"autoprefixer";import e from"browserslist";import t from"cssdb";import o from"postcss-attribute-case-insensitive";import r from"css-blank-pseudo";import i from"postcss-color-functional-notation";import n from"postcss-color-hex-alpha";import c from"postcss-color-rebeccapurple";import p from"postcss-custom-media";import a from"postcss-custom-properties";import u from"postcss-custom-selectors";import l from"postcss-dir-pseudo-class";import m from"postcss-double-position-gradients";import f from"postcss-env-function";import d from"postcss-focus-visible";import b from"postcss-focus-within";import g from"postcss-font-variant";import y from"postcss-gap-properties";import O from"css-has-pseudo";import h from"postcss-image-set-function";import j from"postcss-initial";import v from"postcss-lab-function";import w from"postcss-logical";import k from"postcss-media-minmax";import $ from"postcss-nesting";import x from"postcss-overflow-shorthand";import S from"postcss-page-break";import P from"postcss-place";import M from"css-prefers-color-scheme";import q from"postcss-pseudo-class-any-link";import F from"postcss-replace-overflow-wrap";import T from"postcss-selector-not";import*as B from"caniuse-lite";import U from"fs";import V from"path";function A(){return{postcssPlugin:"postcss-system-ui-font",Declaration(s){E.test(s.prop)&&(s.value.includes(N.join(", "))||(s.value=s.value.replace(C,J)))}}}A.postcss=!0;const E=/(?:^(?:-|\\002d){2})|(?:^font(?:-family)?$)/i,I="[\\f\\n\\r\\x09\\x20]",N=["system-ui","-apple-system","Segoe UI","Roboto","Ubuntu","Cantarell","Noto Sans","sans-serif"],C=new RegExp(`(^|,|${I}+)(?:system-ui${I}*)(?:,${I}*(?:${N.join("|")})${I}*)?(,|$)`,"i"),J=`$1${N.join(", ")}$2`,R={"css-blank-pseudo":"blank-pseudo-class","css-has-pseudo":"has-pseudo-class","css-prefers-color-scheme":"prefers-color-scheme-query","postcss-attribute-case-insensitive":"case-insensitive-attributes","postcss-color-functional-notation":"color-functional-notation","postcss-color-hex-alpha":"hexadecimal-alpha-notation","postcss-color-rebeccapurple":"rebeccapurple-color","postcss-custom-media":"custom-media-queries","postcss-custom-properties":"custom-properties","postcss-custom-selectors":"custom-selectors","postcss-dir-pseudo-class":"dir-pseudo-class","postcss-double-position-gradients":"double-position-gradients","postcss-env-function":"environment-variables","postcss-focus-visible":"focus-visible-pseudo-class","postcss-focus-within":"focus-within-pseudo-class","postcss-font-variant":"font-variant-property","postcss-gap-properties":"gap-properties","postcss-image-set-function":"image-set-function","postcss-initial":"all-property","postcss-lab-function":"lab-function","postcss-logical":"logical-properties-and-values","postcss-media-minmax":"media-query-ranges","postcss-nesting":"nesting-rules","postcss-overflow-shorthand":"overflow-property","postcss-page-break":"break-properties","postcss-place":"place-properties","postcss-pseudo-class-any-link":"any-link-pseudo-class","postcss-replace-overflow-wrap":"overflow-wrap-property","postcss-selector-not":"not-pseudo-class","postcss-system-ui-font-family":"system-ui-font-family"},D=(()=>{const s={};for(const[e,t]of Object.entries(R))s[t]=e;return s})(),L={"all-property":j,"any-link-pseudo-class":q,"blank-pseudo-class":r,"break-properties":S,"case-insensitive-attributes":o,"color-functional-notation":i,"custom-media-queries":p,"custom-properties":a,"custom-selectors":u,"dir-pseudo-class":l,"double-position-gradients":m,"environment-variables":f,"focus-visible-pseudo-class":d,"focus-within-pseudo-class":b,"font-variant-property":g,"gap-properties":y,"has-pseudo-class":O,"hexadecimal-alpha-notation":n,"image-set-function":h,"lab-function":v,"logical-properties-and-values":w,"media-query-ranges":k,"nesting-rules":$,"not-pseudo-class":T,"overflow-property":x,"overflow-wrap-property":F,"place-properties":P,"prefers-color-scheme-query":M,"rebeccapurple-color":c,"system-ui-font-family":A};function z(s,e){return Object.keys(s).map((t=>[].concat(s[t]).map((s=>({[e]:!0,plugin:s,id:t}))))).reduce(((s,e)=>s.concat(e)),[])}function G(s){const e=B.features[s];if(e){const s=B.feature(e).stats;return Object.keys(s).reduce(((e,t)=>e.concat(Object.keys(s[t]).filter((e=>0!==s[t][e].indexOf("y"))).map((s=>`${t} ${s}`)))),[])}return["> 0%"]}var H=["custom-media-queries","custom-properties","environment-variables","image-set-function","media-query-ranges","prefers-color-scheme-query","nesting-rules","custom-selectors","any-link-pseudo-class","case-insensitive-attributes","focus-visible-pseudo-class","focus-within-pseudo-class","matches-pseudo-class","not-pseudo-class","logical-properties-and-values","dir-pseudo-class","all-property","color-functional-notation","double-position-gradients","hexadecimal-alpha-notation","lab-function","rebeccapurple-color","color-mod-function","blank-pseudo-class","break-properties","font-variant-property","has-pseudo-class","gap-properties","overflow-property","overflow-wrap-property","place-properties","system-ui-font-family"];async function K(s,e,t,o){const r=function(s){return`:root {\n${Object.keys(s).reduce(((e,t)=>(e.push(`\t${t}: ${s[t]};`),e)),[]).join("\n")}\n}\n`}(t),i=function(s){return`${Object.keys(s).reduce(((e,t)=>(e.push(`@custom-media ${t} ${s[t]};`),e)),[]).join("\n")}\n`}(e),n=function(s){return`${Object.keys(s).reduce(((e,t)=>(e.push(`@custom-selector ${t} ${s[t]};`),e)),[]).join("\n")}\n`}(o),c=`${i}\n${n}\n${r}`;await Z(s,c)}function Q(s,e){return`\n\t${s}: {\n${Object.keys(e).reduce(((s,t)=>(s.push(`\t\t'${_(t)}': '${_(e[t])}'`),s)),[]).join(",\n")}\n\t}`}function W(s,e){return`export const ${s} = {\n${Object.keys(e).reduce(((s,t)=>(s.push(`\t'${_(t)}': '${_(e[t])}'`),s)),[]).join(",\n")}\n};\n`}function X(s,e){return Promise.all([].concat(e).map((async e=>{if(e instanceof Function)await e({customMedia:Y(s.customMedia),customProperties:Y(s.customProperties),customSelectors:Y(s.customSelectors)});else{const t=e===Object(e)?e:{to:String(e)},o=t.toJSON||Y;if("customMedia"in t||"customProperties"in t||"customSelectors"in t)t.customMedia=o(s.customMedia),t.customProperties=o(s.customProperties),t.customSelectors=o(s.customSelectors);else if("custom-media"in t||"custom-properties"in t||"custom-selectors"in t)t["custom-media"]=o(s.customMedia),t["custom-properties"]=o(s.customProperties),t["custom-selectors"]=o(s.customSelectors);else{const e=String(t.to||""),r=(t.type||V.extname(t.to).slice(1)).toLowerCase(),i=o(s.customMedia),n=o(s.customProperties),c=o(s.customSelectors);"css"===r&&await K(e,i,n,c),"js"===r&&await async function(s,e,t,o){const r=`module.exports = {${Q("customMedia",e)},${Q("customProperties",t)},${Q("customSelectors",o)}\n};\n`;await Z(s,r)}(e,i,n,c),"json"===r&&await async function(s,e,t,o){const r=`${JSON.stringify({"custom-media":e,"custom-properties":t,"custom-selectors":o},null," ")}\n`;await Z(s,r)}(e,i,n,c),"mjs"===r&&await async function(s,e,t,o){const r=`${W("customMedia",e)}\n${W("customProperties",t)}\n${W("customSelectors",o)}`;await Z(s,r)}(e,i,n,c)}}})))}function Y(s){return Object.keys(s).reduce(((e,t)=>(e[t]=String(s[t]),e)),{})}function Z(s,e){return new Promise(((t,o)=>{U.writeFile(s,e,(s=>{s?o(s):t()}))}))}function _(s){return s.replace(/\\([\s\S])|(')/g,"\\$1$2").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}function ss(s,t){const o=e(s,{ignoreUnknownVersions:!0});return"nesting-rules"===t.id&&function(s,t){const o=G(s);if(t.some((s=>e(o,{ignoreUnknownVersions:!0}).some((e=>e===s)))))return!0;return!1}("css-matches-pseudo",o)?{noIsPseudoSelector:!0}:{}}function es(s,e){let t="unknown",o=1/0;for(let r=0;r<e.length;r++){const i=ts(s,e[r]);i<o&&(o=i,t=e[r])}return{mostSimilar:t,distance:o}}function ts(s,e){if(!s.length)return e.length;if(!e.length)return s.length;const t=[];for(let o=0;o<=e.length;o++){t[o]=[o];for(let r=1;r<=s.length;r++)t[o][r]=0===o?r:Math.min(t[o-1][r]+1,t[o][r-1]+1,t[o-1][r-1]+(s[r-1]===e[o-1]?0:1))}return t[e.length][s.length]}const os=o=>{const r=Object(Object(o).features),i=Object.keys(r),n=Object(Object(o).insertBefore),c=Object(Object(o).insertAfter),p=Object(o).browsers,a="stage"in Object(o)?!1===o.stage?5:parseInt(o.stage)||0:2,u=Object(o).autoprefixer,l=rs(Object(o)),m=!1===u?()=>{}:s(Object.assign({overrideBrowserslist:p},u)),f=t.concat(z(n,"insertBefore"),z(c,"insertAfter")).filter((s=>s.insertBefore||s.id in L)).sort(((s,e)=>H.indexOf(s.id)-H.indexOf(e.id)||(s.insertBefore?-1:e.insertBefore?1:0)||(s.insertAfter?1:e.insertAfter?-1:0))).map((s=>{const e=G(s.caniuse);return s.insertBefore||s.insertAfter?{browsers:e,plugin:s.plugin,id:`${s.insertBefore?"before":"after"}-${s.id}`,stage:6}:{browsers:e,plugin:L[s.id],id:s.id,stage:s.stage}})).filter((s=>s.id in r?r[s.id]:s.stage>=a)).map((s=>{let e,t;return e=ss(p,s),e=!0===r[s.id]?l?Object.assign({},e,l):void 0:l?Object.assign({},e,l,r[s.id]):Object.assign({},e,r[s.id]),t=s.plugin.postcss?s.plugin(e):s.plugin,{browsers:s.browsers,plugin:t,pluginOptions:e,id:s.id}})),d=e(p,{ignoreUnknownVersions:!0}),b=f.filter((s=>s.id in r?r[s.id]:!!function(s){if("importFrom"in s.pluginOptions)switch(s.id){case"custom-media-queries":if(Object.keys(Object(s.pluginOptions.importFrom.customMedia)).length)return!0;break;case"custom-properties":if(Object.keys(Object(s.pluginOptions.importFrom.customProperties)).length)return!0;break;case"environment-variables":if(Object.keys(Object(s.pluginOptions.importFrom.environmentVariables)).length)return!0;break;case"custom-selectors":if(Object.keys(Object(s.pluginOptions.importFrom.customSelectors)).length)return!0}if("exportTo"in s.pluginOptions)switch(s.id){case"custom-media-queries":if(Object.keys(Object(s.pluginOptions.exportTo.customMedia)).length)return!0;break;case"custom-properties":if(Object.keys(Object(s.pluginOptions.exportTo.customProperties)).length)return!0;break;case"environment-variables":if(Object.keys(Object(s.pluginOptions.exportTo.environmentVariables)).length)return!0;break;case"custom-selectors":if(Object.keys(Object(s.pluginOptions.exportTo.customSelectors)).length)return!0}return!1}(s)||d.some((t=>e(s.browsers,{ignoreUnknownVersions:!0}).some((s=>s===t)))))).map((s=>s.plugin));b.push(m);const g=()=>({postcssPlugin:"postcss-preset-env",OnceExit:function(s,{result:e}){!function(s,e,t){const o=Object.keys(D),r=Object.keys(R);s.forEach((s=>{if(o.includes(s))return;const i=es(s,o),n=es(s,r);i.distance<n.distance?e.warn(t,`Unknown feature: "${s}" did you mean: "${i.mostSimilar}"`):e.warn(t,`Unknown feature: "${s}" did you mean: "${R[n.mostSimilar]}"`)}))}(i,s,e),Object(o).exportTo&&X(l.exportTo,o.exportTo)}});return g.postcss=!0,{postcssPlugin:"postcss-preset-env",plugins:[...b,g()]}},rs=s=>{if("importFrom"in s||"exportTo"in s||"preserve"in s){const e={};return"importFrom"in s&&(e.importFrom=s.importFrom),"exportTo"in s&&(e.exportTo={customMedia:{},customProperties:{},customSelectors:{}}),"preserve"in s&&(e.preserve=s.preserve),e}return!1};os.postcss=!0;export{os as default};
1
+ import s from"autoprefixer";import e from"cssdb";import o from"@csstools/postcss-progressive-custom-properties";import t from"fs";import r from"path";import i from"browserslist";import n from"postcss-attribute-case-insensitive";import c from"css-blank-pseudo";import p from"postcss-color-functional-notation";import a from"postcss-color-hex-alpha";import u from"postcss-color-rebeccapurple";import l from"postcss-custom-media";import m from"postcss-custom-properties";import f from"postcss-custom-selectors";import d from"postcss-dir-pseudo-class";import g from"postcss-double-position-gradients";import b from"postcss-env-function";import h from"postcss-focus-visible";import y from"postcss-focus-within";import w from"postcss-font-variant";import v from"postcss-gap-properties";import $ from"css-has-pseudo";import k from"postcss-image-set-function";import O from"postcss-initial";import S from"postcss-lab-function";import j from"postcss-logical";import x from"postcss-media-minmax";import P from"postcss-nesting";import E from"postcss-overflow-shorthand";import M from"postcss-page-break";import _ from"postcss-place";import q from"css-prefers-color-scheme";import R from"postcss-pseudo-class-any-link";import A from"postcss-replace-overflow-wrap";import F from"postcss-selector-not";import N from"@csstools/postcss-is-pseudo-class";import T from"@csstools/postcss-hwb-function";import B from"postcss-opacity-percentage";import U from"postcss-clamp";import W from"@csstools/postcss-font-format-keywords";import C from"@csstools/postcss-normalize-display-values";const I={"blank-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-blank-pseudo/README-BROWSER.md","focus-visible-pseudo-class":"https://github.com/WICG/focus-visible","focus-within-pseudo-class":"https://github.com/jsxtools/focus-within/blob/master/README-BROWSER.md","has-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-has-pseudo/README-BROWSER.md","prefers-color-scheme-query":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-prefers-color-scheme/README-BROWSER.md"},V=["blank-pseudo-class","focus-visible-pseudo-class","focus-within-pseudo-class","has-pseudo-class","prefers-color-scheme-query"];async function D(s,e,o,t){const r=function(s){return`:root {\n${Object.keys(s).reduce(((e,o)=>(e.push(`\t${o}: ${s[o]};`),e)),[]).join("\n")}\n}\n`}(o),i=function(s){return`${Object.keys(s).reduce(((e,o)=>(e.push(`@custom-media ${o} ${s[o]};`),e)),[]).join("\n")}\n`}(e),n=function(s){return`${Object.keys(s).reduce(((e,o)=>(e.push(`@custom-selector ${o} ${s[o]};`),e)),[]).join("\n")}\n`}(t),c=`${i}\n${n}\n${r}`;await H(s,c)}function L(s,e){return`\n\t${s}: {\n${Object.keys(e).reduce(((s,o)=>(s.push(`\t\t'${K(o)}': '${K(e[o])}'`),s)),[]).join(",\n")}\n\t}`}function J(s,e){return`export const ${s} = {\n${Object.keys(e).reduce(((s,o)=>(s.push(`\t'${K(o)}': '${K(e[o])}'`),s)),[]).join(",\n")}\n};\n`}function z(s,e){return Promise.all([].concat(e).map((async e=>{if(e instanceof Function)await e({customMedia:G(s.customMedia),customProperties:G(s.customProperties),customSelectors:G(s.customSelectors)});else{const o=e===Object(e)?e:{to:String(e)},t=o.toJSON||G;if("customMedia"in o||"customProperties"in o||"customSelectors"in o)o.customMedia=t(s.customMedia),o.customProperties=t(s.customProperties),o.customSelectors=t(s.customSelectors);else if("custom-media"in o||"custom-properties"in o||"custom-selectors"in o)o["custom-media"]=t(s.customMedia),o["custom-properties"]=t(s.customProperties),o["custom-selectors"]=t(s.customSelectors);else{const e=String(o.to||""),i=(o.type||r.extname(o.to).slice(1)).toLowerCase(),n=t(s.customMedia),c=t(s.customProperties),p=t(s.customSelectors);"css"===i&&await D(e,n,c,p),"js"===i&&await async function(s,e,o,t){const r=`module.exports = {${L("customMedia",e)},${L("customProperties",o)},${L("customSelectors",t)}\n};\n`;await H(s,r)}(e,n,c,p),"json"===i&&await async function(s,e,o,t){const r=`${JSON.stringify({"custom-media":e,"custom-properties":o,"custom-selectors":t},null," ")}\n`;await H(s,r)}(e,n,c,p),"mjs"===i&&await async function(s,e,o,t){const r=`${J("customMedia",e)}\n${J("customProperties",o)}\n${J("customSelectors",t)}`;await H(s,r)}(e,n,c,p)}}})))}function G(s){return Object.keys(s).reduce(((e,o)=>(e[o]=String(s[o]),e)),{})}function H(s,e){return new Promise(((o,r)=>{t.writeFile(s,e,(s=>{s?r(s):o()}))}))}function K(s){return s.replace(/\\([\s\S])|(')/g,"\\$1$2").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}function Q(s,e){if(!s)return!1;if("string"==typeof s)return!0;if(Array.isArray(s)){for(let o=0;o<s.length;o++){if("string"==typeof s[o])return!0;if(s[o]&&e in Object(s[o]))return!0}return!1}return e in Object(s)}function X(s,e,o){return Math.max(s,Math.min(e,o))}const Y=Symbol("insertBefore"),Z=Symbol("insertAfter"),ss=Symbol("insertOrder"),es=Symbol("plugin");function os(s,e,o){if("insertBefore"!==o&&"insertAfter"!==o)return[];const t="insertBefore"===o?Y:Z,r=[];for(const o in e){if(!Object.hasOwnProperty.call(e,o))continue;if(!s.find((s=>s.id===o)))continue;let i=e[o];Array.isArray(i)||(i=[i]);for(let s=0;s<i.length;s++)r.push({id:o,[es]:i[s],[ss]:s,[t]:!0})}return r}var ts=["custom-media-queries","custom-properties","environment-variables","image-set-function","media-query-ranges","prefers-color-scheme-query","nesting-rules","custom-selectors","any-link-pseudo-class","case-insensitive-attributes","focus-visible-pseudo-class","focus-within-pseudo-class","not-pseudo-class","logical-properties-and-values","dir-pseudo-class","all-property","color-functional-notation","double-position-gradients","hexadecimal-alpha-notation","hwb-function","lab-function","rebeccapurple-color","blank-pseudo-class","break-properties","font-variant-property","is-pseudo-class","has-pseudo-class","gap-properties","overflow-property","overflow-wrap-property","place-properties","system-ui-font-family"];function rs(){return{postcssPlugin:"postcss-system-ui-font",Declaration(s){is.test(s.prop)&&(s.value.includes(cs.join(", "))||(s.value=s.value.replace(ps,as)))}}}rs.postcss=!0;const is=/(?:^(?:-|\\002d){2})|(?:^font(?:-family)?$)/i,ns="[\\f\\n\\r\\x09\\x20]",cs=["system-ui","-apple-system","Segoe UI","Roboto","Ubuntu","Cantarell","Noto Sans","sans-serif"],ps=new RegExp(`(^|,|${ns}+)(?:system-ui${ns}*)(?:,${ns}*(?:${cs.join("|")})${ns}*)?(,|$)`,"i"),as=`$1${cs.join(", ")}$2`,us={"css-blank-pseudo":"blank-pseudo-class","css-has-pseudo":"has-pseudo-class","css-prefers-color-scheme":"prefers-color-scheme-query","postcss-attribute-case-insensitive":"case-insensitive-attributes","postcss-clamp":"clamp","postcss-color-functional-notation":"color-functional-notation","postcss-color-hex-alpha":"hexadecimal-alpha-notation","postcss-color-rebeccapurple":"rebeccapurple-color","postcss-custom-media":"custom-media-queries","postcss-custom-properties":"custom-properties","postcss-custom-selectors":"custom-selectors","postcss-dir-pseudo-class":"dir-pseudo-class","postcss-double-position-gradients":"double-position-gradients","postcss-env-function":"environment-variables","postcss-focus-visible":"focus-visible-pseudo-class","postcss-focus-within":"focus-within-pseudo-class","postcss-font-format-keywords":"font-format-keywords","postcss-font-variant":"font-variant-property","postcss-gap-properties":"gap-properties","postcss-hwb-function":"hwb-function","postcss-image-set-function":"image-set-function","postcss-initial":"all-property","postcss-is-pseudo-class":"is-pseudo-class","postcss-lab-function":"lab-function","postcss-logical":"logical-properties-and-values","postcss-media-minmax":"media-query-ranges","postcss-nesting":"nesting-rules","postcss-normalize-display-values":"display-two-values","postcss-opacity-percentage":"opacity-percentage","postcss-overflow-shorthand":"overflow-property","postcss-page-break":"break-properties","postcss-place":"place-properties","postcss-pseudo-class-any-link":"any-link-pseudo-class","postcss-replace-overflow-wrap":"overflow-wrap-property","postcss-selector-not":"not-pseudo-class","postcss-system-ui-font-family":"system-ui-font-family"},ls=(()=>{const s={};for(const[e,o]of Object.entries(us))s[o]=e;return s})(),ms=new Map([["all-property",O],["any-link-pseudo-class",R],["blank-pseudo-class",c],["break-properties",M],["case-insensitive-attributes",n],["clamp",U],["color-functional-notation",p],["custom-media-queries",l],["custom-properties",m],["custom-selectors",f],["dir-pseudo-class",d],["display-two-values",C],["double-position-gradients",g],["environment-variables",b],["focus-visible-pseudo-class",h],["focus-within-pseudo-class",y],["font-format-keywords",W],["font-variant-property",w],["gap-properties",v],["hwb-function",T],["has-pseudo-class",$],["hexadecimal-alpha-notation",a],["image-set-function",k],["is-pseudo-class",N],["lab-function",S],["logical-properties-and-values",j],["media-query-ranges",x],["nesting-rules",P],["not-pseudo-class",F],["opacity-percentage",B],["overflow-property",E],["overflow-wrap-property",A],["place-properties",_],["prefers-color-scheme-query",q],["rebeccapurple-color",u],["system-ui-font-family",rs]]);function fs(s,e,o){return s.concat(os(s,e,"insertBefore"),os(s,o,"insertAfter")).filter((s=>function(s){return!!s[Y]||!!s[Z]||!!ms.has(s.id)}(s))).sort(((s,e)=>function(s,e){return s.id===e.id?s[Y]&&e[Y]||s[Z]&&e[Z]?X(-1,s[ss]-e[ss],1):s[Y]||e[Z]?-1:s[Z]||e[Y]?1:0:X(-1,ts.indexOf(s.id)-ts.indexOf(e.id),1)}(s,e)))}const ds=["ie","edge","firefox","chrome","safari","opera","ios_saf","android","op_mob","and_chr","and_ff","and_uc","samsung","and_qq","baidu","kaios"];function gs(s){if(!s)return[];if(!("browser_support"in s))return["> 0%"];const e=[];return ds.forEach((o=>{const t=s.browser_support[o];"string"==typeof t&&/^[0-9|.]+$/.test(t)?e.push(`${o} < ${s.browser_support[o]}`):e.push(`${o} >= 1`)})),e}function bs(s,e,o,t){const r=i(s,{ignoreUnknownVersions:!0});switch(e.id){case"is-pseudo-class":return{onComplexSelector:"warning"};case"nesting-rules":if(function(s,e){const o=gs(s);if(e.some((s=>i(o,{ignoreUnknownVersions:!0}).some((e=>e===s)))))return!0;return!1}(o.find((s=>"is-pseudo-class"===s.id)),r))return t.log('Disabling :is on "nesting-rules" due to lack of browser support.'),{noIsPseudoSelector:!0};return{};case"any-link-pseudo-class":if(r.find((s=>s.startsWith("ie ")||s.startsWith("edge "))))return t.log('Adding area[href] fallbacks for ":any-link" support in Edge and IE.'),{subFeatures:{areaHrefNeedsFixing:!0}};return{};default:return{}}}function hs(s,e,o,t){const r=Object(e.features),n=!("enableClientSidePolyfills"in e)||e.enableClientSidePolyfills,c=Object(e.insertBefore),p=Object(e.insertAfter),a=e.browsers,u=X(0,function(s){const e=parseInt(s,10);return Number.isNaN(e)?0:e}(e.minimumVendorImplementations),3);u>0&&t.log(`Using features with ${u} or more vendor implementations`);const l=function(s,e){let o=2;if(void 0===s.stage)return e.log(`Using features from Stage ${o} (default)`),o;if(!1===s.stage)o=5;else{let e=parseInt(s.stage,10);Number.isNaN(e)&&(e=0),o=X(0,e,5)}return 5===o?e.log('Stage has been disabled, features will be handled via the "features" option.'):e.log(`Using features from Stage ${o}`),o}(e,t);2===l&&o&&!1===o.preserve&&(s=JSON.parse(JSON.stringify(s))).forEach((s=>{("blank-pseudo-class"===s.id||"prefers-color-scheme-query"===s.id)&&(s.stage=1)}));const m=fs(s,c,p).map((s=>function(s){const e=gs(s);if(s[Y]||s[Z]){let o=s.id;return o=s.insertBefore?`before-${o}`:`after-${o}`,{browsers:e,vendors_implementations:s.vendors_implementations,plugin:s[es],id:o,stage:6}}return{browsers:e,vendors_implementations:s.vendors_implementations,plugin:ms.get(s.id),id:s.id,stage:s.stage}}(s))).filter((s=>0===u||(!(!s[Y]&&!s[Z])||(u<=s.vendors_implementations||(t.log(` ${s.id} with ${s.vendors_implementations} vendor implementations has been disabled`),!1))))).filter((s=>{const e=s.stage>=l,o=n||!V.includes(s.id),i=!1===r[s.id],c=r[s.id]?r[s.id]:e&&o;return i?t.log(` ${s.id} has been disabled by options`):e?o||t.log(` ${s.id} has been disabled by "enableClientSidePolyfills: false".`):c?t.log(` ${s.id} has been enabled by options`):t.log(` ${s.id} with stage ${s.stage} has been disabled`),c})).map((e=>function(s,e,o,t,r,i){let n,c;return n=bs(e,t,s,i),!0===o[t.id]?r&&(n=Object.assign({},n,r)):n=r?Object.assign({},n,r,o[t.id]):Object.assign({},n,o[t.id]),n.enableProgressiveCustomProperties=!1,c=t.plugin.postcss&&"function"==typeof t.plugin?t.plugin(n):t.plugin&&t.plugin.default&&"function"==typeof t.plugin.default&&t.plugin.default.postcss?t.plugin.default(n):t.plugin,{browsers:t.browsers,vendors_implementations:t.vendors_implementations,plugin:c,pluginOptions:n,id:t.id}}(s,a,r,e,o,t))),f=i(a,{ignoreUnknownVersions:!0});return m.filter((s=>{if(s.id in r)return r[s.id];if(function(s){if("importFrom"in Object(s.pluginOptions))switch(s.id){case"custom-media-queries":if(Q(s.pluginOptions.importFrom,"customMedia"))return!0;break;case"custom-properties":if(Q(s.pluginOptions.importFrom,"customProperties"))return!0;break;case"environment-variables":if(Q(s.pluginOptions.importFrom,"environmentVariables"))return!0;break;case"custom-selectors":if(Q(s.pluginOptions.importFrom,"customSelectors"))return!0}if("exportTo"in Object(s.pluginOptions))switch(s.id){case"custom-media-queries":if(Q(s.pluginOptions.exportTo,"customMedia"))return!0;break;case"custom-properties":if(Q(s.pluginOptions.exportTo,"customProperties"))return!0;break;case"environment-variables":if(Q(s.pluginOptions.exportTo,"environmentVariables"))return!0;break;case"custom-selectors":if(Q(s.pluginOptions.exportTo,"customSelectors"))return!0}return!1}(s))return!0;const e=i(s.browsers,{ignoreUnknownVersions:!0}),o=f.some((s=>e.some((e=>e===s))));return o||t.log(`${s.id} disabled due to browser support`),o}))}class ys{constructor(){this.logs=[]}log(s){this.logs.push(s)}resetLogger(){this.logs.length=0}dumpLogs(s){s&&this.logs.forEach((e=>s.warn(e))),this.resetLogger()}}function ws(s,e){let o="unknown",t=1/0;for(let r=0;r<e.length;r++){const i=vs(s,e[r]);i<t&&(t=i,o=e[r])}return{mostSimilar:o,distance:t}}function vs(s,e){if(!s.length)return e.length;if(!e.length)return s.length;const o=[];for(let t=0;t<=e.length;t++){o[t]=[t];for(let r=1;r<=s.length;r++)o[t][r]=0===t?r:Math.min(o[t-1][r]+1,o[t][r-1]+1,o[t-1][r-1]+(s[r-1]===e[t-1]?0:1))}return o[e.length][s.length]}const $s=t=>{const r=new ys,i=Object(t),n=Object.keys(Object(i.features)),c=i.browsers,p=function(s){if("importFrom"in s||"exportTo"in s||"preserve"in s){const e={};return"importFrom"in s&&(e.importFrom=s.importFrom),"exportTo"in s&&(e.exportTo={customMedia:{},customProperties:{},customSelectors:{}}),"preserve"in s&&(e.preserve=s.preserve),e}return!1}(i),a=hs(e,i,p,r),u=a.map((s=>s.plugin));!1!==i.autoprefixer&&u.push(s(Object.assign({overrideBrowserslist:c},i.autoprefixer))),u.push(o()),function(s,e,o){if(e.debug){o.log("Enabling the following feature(s):");const e=[];s.forEach((s=>{s.id.startsWith("before")||s.id.startsWith("after")?o.log(` ${s.id} (injected via options)`):o.log(` ${s.id}`),void 0!==I[s.id]&&e.push(s.id)})),e.length&&(o.log("These feature(s) need a browser library to work:"),e.forEach((s=>o.log(` ${s}: ${I[s]}`))))}}(a,i,r);const l=()=>({postcssPlugin:"postcss-preset-env",OnceExit:function(s,{result:e}){!function(s,e,o){const t=Object.keys(ls),r=Object.keys(us);s.forEach((s=>{if(t.includes(s))return;const i=ws(s,t),n=ws(s,r);i.distance<n.distance?e.warn(o,`Unknown feature: "${s}" did you mean: "${i.mostSimilar}"`):e.warn(o,`Unknown feature: "${s}" did you mean: "${us[n.mostSimilar]}"`)}))}(n,s,e),i.debug&&r.dumpLogs(e),r.resetLogger(),i.exportTo&&z(p.exportTo,t.exportTo)}});return l.postcss=!0,{postcssPlugin:"postcss-preset-env",plugins:[...u,l()]}};$s.postcss=!0;export{$s as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-preset-env",
3
- "version": "7.2.2",
3
+ "version": "7.3.2",
4
4
  "description": "Convert modern CSS into something browsers understand",
5
5
  "author": "Jonathan Neal <jonathantneal@hotmail.com>",
6
6
  "license": "CC0-1.0",
@@ -8,6 +8,13 @@
8
8
  "bugs": "https://github.com/csstools/postcss-plugins/issues",
9
9
  "main": "dist/index.cjs",
10
10
  "module": "dist/index.mjs",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.mjs",
14
+ "require": "./dist/index.cjs",
15
+ "default": "./dist/index.mjs"
16
+ }
17
+ },
11
18
  "files": [
12
19
  "CHANGELOG.md",
13
20
  "LICENSE.md",
@@ -20,51 +27,56 @@
20
27
  "lint": "eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern",
21
28
  "prepublishOnly": "npm run clean && npm run build && npm run test",
22
29
  "stryker": "stryker run --logLevel error",
23
- "test": "postcss-tape --ci && npm run test:exports",
30
+ "test": "node .tape.mjs && node ./src/test/test.mjs && npm run test:exports",
31
+ "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs",
24
32
  "test:exports": "node ./test/_import.mjs && node ./test/_require.cjs"
25
33
  },
26
34
  "engines": {
27
35
  "node": "^12 || ^14 || >=16"
28
36
  },
29
37
  "dependencies": {
38
+ "@csstools/postcss-font-format-keywords": "^1.0.0",
39
+ "@csstools/postcss-hwb-function": "^1.0.0",
40
+ "@csstools/postcss-is-pseudo-class": "^2.0.0",
41
+ "@csstools/postcss-normalize-display-values": "^1.0.0",
42
+ "@csstools/postcss-progressive-custom-properties": "^1.1.0",
30
43
  "autoprefixer": "^10.4.2",
31
44
  "browserslist": "^4.19.1",
32
- "caniuse-lite": "^1.0.30001299",
33
- "css-blank-pseudo": "^3.0.2",
34
- "css-has-pseudo": "^3.0.3",
35
- "css-prefers-color-scheme": "^6.0.2",
36
- "cssdb": "^5.0.0",
45
+ "css-blank-pseudo": "^3.0.3",
46
+ "css-has-pseudo": "^3.0.4",
47
+ "css-prefers-color-scheme": "^6.0.3",
48
+ "cssdb": "^6.2.1",
37
49
  "postcss-attribute-case-insensitive": "^5.0.0",
38
- "postcss-color-functional-notation": "^4.2.1",
39
- "postcss-color-hex-alpha": "^8.0.2",
50
+ "postcss-clamp": "^3.0.0",
51
+ "postcss-color-functional-notation": "^4.2.2",
52
+ "postcss-color-hex-alpha": "^8.0.3",
40
53
  "postcss-color-rebeccapurple": "^7.0.2",
41
54
  "postcss-custom-media": "^8.0.0",
42
- "postcss-custom-properties": "^12.1.2",
55
+ "postcss-custom-properties": "^12.1.4",
43
56
  "postcss-custom-selectors": "^6.0.0",
44
- "postcss-dir-pseudo-class": "^6.0.3",
45
- "postcss-double-position-gradients": "^3.0.4",
46
- "postcss-env-function": "^4.0.4",
47
- "postcss-focus-visible": "^6.0.3",
48
- "postcss-focus-within": "^5.0.3",
57
+ "postcss-dir-pseudo-class": "^6.0.4",
58
+ "postcss-double-position-gradients": "^3.0.5",
59
+ "postcss-env-function": "^4.0.5",
60
+ "postcss-focus-visible": "^6.0.4",
61
+ "postcss-focus-within": "^5.0.4",
49
62
  "postcss-font-variant": "^5.0.0",
50
- "postcss-gap-properties": "^3.0.2",
51
- "postcss-image-set-function": "^4.0.4",
63
+ "postcss-gap-properties": "^3.0.3",
64
+ "postcss-image-set-function": "^4.0.6",
52
65
  "postcss-initial": "^4.0.1",
53
- "postcss-lab-function": "^4.0.3",
54
- "postcss-logical": "^5.0.3",
66
+ "postcss-lab-function": "^4.1.0",
67
+ "postcss-logical": "^5.0.4",
55
68
  "postcss-media-minmax": "^5.0.0",
56
69
  "postcss-nesting": "^10.1.2",
57
- "postcss-overflow-shorthand": "^3.0.2",
70
+ "postcss-opacity-percentage": "^1.1.2",
71
+ "postcss-overflow-shorthand": "^3.0.3",
58
72
  "postcss-page-break": "^3.0.4",
59
- "postcss-place": "^7.0.3",
60
- "postcss-pseudo-class-any-link": "^7.0.2",
73
+ "postcss-place": "^7.0.4",
74
+ "postcss-pseudo-class-any-link": "^7.1.1",
61
75
  "postcss-replace-overflow-wrap": "^4.0.0",
62
76
  "postcss-selector-not": "^5.0.0"
63
77
  },
64
78
  "devDependencies": {
65
- "postcss": "^8.4.5",
66
- "postcss-simple-vars": "^6.0.3",
67
- "postcss-tape": "^6.0.1"
79
+ "postcss-simple-vars": "^6.0.3"
68
80
  },
69
81
  "peerDependencies": {
70
82
  "postcss": "^8.4"