From 80158fe8d953ed2297875a64e09d2df6346cffe2 Mon Sep 17 00:00:00 2001 From: Romain Menke Date: Tue, 13 Jan 2026 22:18:39 +0100 Subject: [PATCH 1/5] esm only --- .github/bin/format-package-json.mjs | 19 +- .github/workflows/codeql.yml | 13 +- .github/workflows/test.yml | 2 +- cli/csstools-cli/CHANGELOG.md | 5 + cli/csstools-cli/package.json | 3 +- eslint.config.mjs | 4 +- experimental/css-has-pseudo/CHANGELOG.md | 5 + experimental/css-has-pseudo/dist/index.cjs | 1 - experimental/css-has-pseudo/dist/index.d.ts | 1 + experimental/css-has-pseudo/dist/index.mjs | 2 +- experimental/css-has-pseudo/package.json | 12 +- experimental/css-has-pseudo/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + experimental/postcss-nesting/CHANGELOG.md | 5 + experimental/postcss-nesting/dist/index.cjs | 1 - experimental/postcss-nesting/dist/index.d.ts | 1 + experimental/postcss-nesting/dist/index.mjs | 2 +- experimental/postcss-nesting/package.json | 12 +- experimental/postcss-nesting/src/index.ts | 1 + package-lock.json | 25 +- package.json | 4 - packages/base-cli/dist/index.cjs | 1 - packages/base-cli/package.json | 12 +- .../cascade-layer-name-parser/CHANGELOG.md | 5 + .../cascade-layer-name-parser/dist/index.cjs | 1 - .../cascade-layer-name-parser/package.json | 12 +- packages/color-helpers/CHANGELOG.md | 5 + packages/color-helpers/dist/index.cjs | 263 ------------------ packages/color-helpers/package.json | 12 +- packages/css-calc/CHANGELOG.md | 5 + packages/css-calc/dist/index.cjs | 1 - packages/css-calc/package.json | 12 +- packages/css-color-parser/CHANGELOG.md | 5 + packages/css-color-parser/dist/index.cjs | 1 - packages/css-color-parser/package.json | 12 +- packages/css-parser-algorithms/CHANGELOG.md | 5 + packages/css-parser-algorithms/dist/index.cjs | 1 - packages/css-parser-algorithms/package.json | 12 +- .../CHANGELOG.md | 5 + .../package.json | 4 +- .../tests/import.test.mjs | 4 + .../tests/require.test.cjs | 4 + packages/css-tokenizer/CHANGELOG.md | 5 + packages/css-tokenizer/dist/index.cjs | 1 - packages/css-tokenizer/package.json | 12 +- packages/generate-test-cases/package.json | 3 +- packages/media-query-list-parser/CHANGELOG.md | 5 + .../media-query-list-parser/dist/index.cjs | 1 - packages/media-query-list-parser/package.json | 12 +- packages/pack-test/CHANGELOG.md | 5 + packages/pack-test/dist/index.cjs | 1 - packages/pack-test/package.json | 12 +- packages/postcss-tape/CHANGELOG.md | 5 + packages/postcss-tape/dist/index.cjs | 3 - packages/postcss-tape/package.json | 12 +- packages/selector-resolve-nested/CHANGELOG.md | 5 + .../selector-resolve-nested/dist/index.cjs | 1 - packages/selector-resolve-nested/package.json | 12 +- packages/selector-specificity/CHANGELOG.md | 5 + packages/selector-specificity/dist/index.cjs | 1 - packages/selector-specificity/package.json | 12 +- packages/utilities/CHANGELOG.md | 5 + packages/utilities/dist/index.cjs | 1 - packages/utilities/package.json | 12 +- plugin-packs/postcss-bundler/CHANGELOG.md | 5 + plugin-packs/postcss-bundler/dist/index.cjs | 1 - plugin-packs/postcss-bundler/dist/index.d.ts | 1 + plugin-packs/postcss-bundler/dist/index.mjs | 2 +- plugin-packs/postcss-bundler/package.json | 12 +- plugin-packs/postcss-bundler/src/index.ts | 1 + .../src/postcss-import/lib/noop-plugin.ts | 1 + plugin-packs/postcss-preset-env/CHANGELOG.md | 5 + .../postcss-preset-env/dist/index.cjs | 1 - .../postcss-preset-env/dist/index.d.ts | 1 + .../postcss-preset-env/dist/index.mjs | 2 +- plugin-packs/postcss-preset-env/package.json | 12 +- plugin-packs/postcss-preset-env/src/index.ts | 1 + plugins-stylelint/at-risk/package.json | 3 +- .../formatter-github/package.json | 3 +- .../no-at-nest-rule/package.json | 3 +- .../package.json | 3 +- plugins/css-blank-pseudo/CHANGELOG.md | 5 + plugins/css-blank-pseudo/dist/index.cjs | 1 - plugins/css-blank-pseudo/dist/index.d.ts | 1 + plugins/css-blank-pseudo/dist/index.mjs | 2 +- plugins/css-blank-pseudo/index.d.ts | 13 + plugins/css-blank-pseudo/package.json | 18 +- plugins/css-blank-pseudo/src/index.ts | 1 + plugins/css-has-pseudo/CHANGELOG.md | 5 + plugins/css-has-pseudo/dist/index.cjs | 1 - plugins/css-has-pseudo/dist/index.d.ts | 1 + plugins/css-has-pseudo/dist/index.mjs | 2 +- plugins/css-has-pseudo/package.json | 12 +- plugins/css-has-pseudo/src/index.ts | 1 + plugins/css-prefers-color-scheme/CHANGELOG.md | 5 + .../css-prefers-color-scheme/dist/index.cjs | 1 - .../css-prefers-color-scheme/dist/index.d.ts | 1 + .../css-prefers-color-scheme/dist/index.mjs | 2 +- plugins/css-prefers-color-scheme/package.json | 12 +- plugins/css-prefers-color-scheme/src/index.ts | 1 + plugins/postcss-alpha-function/CHANGELOG.md | 5 + plugins/postcss-alpha-function/dist/index.cjs | 1 - .../postcss-alpha-function/dist/index.d.ts | 1 + plugins/postcss-alpha-function/dist/index.mjs | 2 +- plugins/postcss-alpha-function/package.json | 12 +- plugins/postcss-alpha-function/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-base-plugin/dist/index.cjs | 1 - plugins/postcss-base-plugin/dist/index.d.ts | 1 + plugins/postcss-base-plugin/dist/index.mjs | 2 +- plugins/postcss-base-plugin/package.json | 12 +- plugins/postcss-base-plugin/src/index.ts | 1 + plugins/postcss-browser-comments/CHANGELOG.md | 5 + .../postcss-browser-comments/dist/index.cjs | 1 - .../postcss-browser-comments/dist/index.d.ts | 1 + .../postcss-browser-comments/dist/index.mjs | 2 +- plugins/postcss-browser-comments/package.json | 12 +- plugins/postcss-browser-comments/src/index.ts | 1 + plugins/postcss-cascade-layers/CHANGELOG.md | 5 + plugins/postcss-cascade-layers/dist/index.cjs | 1 - .../postcss-cascade-layers/dist/index.d.ts | 1 + plugins/postcss-cascade-layers/dist/index.mjs | 2 +- plugins/postcss-cascade-layers/package.json | 12 +- plugins/postcss-cascade-layers/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-color-function/CHANGELOG.md | 5 + plugins/postcss-color-function/dist/index.cjs | 1 - .../postcss-color-function/dist/index.d.ts | 1 + plugins/postcss-color-function/dist/index.mjs | 2 +- plugins/postcss-color-function/package.json | 12 +- plugins/postcss-color-function/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-color-hex-alpha/CHANGELOG.md | 5 + .../postcss-color-hex-alpha/dist/index.cjs | 1 - .../postcss-color-hex-alpha/dist/index.d.ts | 1 + .../postcss-color-hex-alpha/dist/index.mjs | 2 +- plugins/postcss-color-hex-alpha/package.json | 12 +- plugins/postcss-color-hex-alpha/src/index.ts | 1 + .../postcss-color-mix-function/CHANGELOG.md | 5 + .../postcss-color-mix-function/dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../postcss-color-mix-function/dist/index.mjs | 2 +- .../postcss-color-mix-function/package.json | 12 +- .../postcss-color-mix-function/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + .../postcss-color-rebeccapurple/CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../postcss-color-rebeccapurple/package.json | 12 +- .../postcss-color-rebeccapurple/src/index.ts | 1 + .../postcss-conditional-values/CHANGELOG.md | 5 + .../postcss-conditional-values/dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../postcss-conditional-values/dist/index.mjs | 2 +- .../postcss-conditional-values/package.json | 12 +- .../postcss-conditional-values/src/index.ts | 1 + plugins/postcss-content-alt-text/CHANGELOG.md | 5 + .../postcss-content-alt-text/dist/index.cjs | 1 - .../postcss-content-alt-text/dist/index.d.ts | 1 + .../postcss-content-alt-text/dist/index.mjs | 2 +- plugins/postcss-content-alt-text/package.json | 12 +- plugins/postcss-content-alt-text/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-custom-media/CHANGELOG.md | 5 + plugins/postcss-custom-media/dist/index.cjs | 1 - plugins/postcss-custom-media/dist/index.d.ts | 1 + plugins/postcss-custom-media/dist/index.mjs | 2 +- plugins/postcss-custom-media/package.json | 12 +- plugins/postcss-custom-media/src/index.ts | 1 + .../postcss-custom-properties/CHANGELOG.md | 5 + .../postcss-custom-properties/dist/index.cjs | 1 - .../postcss-custom-properties/dist/index.d.ts | 1 + .../postcss-custom-properties/dist/index.mjs | 2 +- .../postcss-custom-properties/package.json | 12 +- .../postcss-custom-properties/src/index.ts | 1 + plugins/postcss-custom-selectors/CHANGELOG.md | 5 + .../postcss-custom-selectors/dist/index.cjs | 1 - .../postcss-custom-selectors/dist/index.d.ts | 1 + .../postcss-custom-selectors/dist/index.mjs | 2 +- plugins/postcss-custom-selectors/package.json | 12 +- plugins/postcss-custom-selectors/src/index.ts | 1 + plugins/postcss-debug-logger/CHANGELOG.md | 5 + plugins/postcss-debug-logger/dist/index.cjs | 1 - plugins/postcss-debug-logger/dist/index.d.ts | 1 + plugins/postcss-debug-logger/dist/index.mjs | 2 +- plugins/postcss-debug-logger/package.json | 12 +- plugins/postcss-debug-logger/src/index.ts | 1 + plugins/postcss-design-tokens/CHANGELOG.md | 5 + plugins/postcss-design-tokens/dist/index.cjs | 1 - plugins/postcss-design-tokens/dist/index.d.ts | 1 + plugins/postcss-design-tokens/dist/index.mjs | 2 +- plugins/postcss-design-tokens/package.json | 12 +- plugins/postcss-design-tokens/src/index.ts | 1 + plugins/postcss-dir-pseudo-class/CHANGELOG.md | 5 + .../postcss-dir-pseudo-class/dist/index.cjs | 1 - .../postcss-dir-pseudo-class/dist/index.d.ts | 1 + .../postcss-dir-pseudo-class/dist/index.mjs | 2 +- plugins/postcss-dir-pseudo-class/package.json | 12 +- plugins/postcss-dir-pseudo-class/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-env-function/CHANGELOG.md | 5 + plugins/postcss-env-function/dist/index.cjs | 1 - plugins/postcss-env-function/dist/index.mjs | 2 +- plugins/postcss-env-function/package.json | 5 +- plugins/postcss-env-function/src/index.js | 7 +- .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-extract/CHANGELOG.md | 5 + plugins/postcss-extract/dist/index.cjs | 1 - plugins/postcss-extract/dist/index.d.ts | 1 + plugins/postcss-extract/dist/index.mjs | 2 +- plugins/postcss-extract/package.json | 12 +- plugins/postcss-extract/src/index.ts | 1 + plugins/postcss-focus-visible/CHANGELOG.md | 5 + plugins/postcss-focus-visible/dist/index.cjs | 1 - plugins/postcss-focus-visible/dist/index.d.ts | 1 + plugins/postcss-focus-visible/dist/index.mjs | 2 +- plugins/postcss-focus-visible/package.json | 12 +- plugins/postcss-focus-visible/src/index.ts | 1 + plugins/postcss-focus-within/CHANGELOG.md | 5 + plugins/postcss-focus-within/dist/index.cjs | 1 - plugins/postcss-focus-within/dist/index.d.ts | 1 + plugins/postcss-focus-within/dist/index.mjs | 2 +- plugins/postcss-focus-within/package.json | 12 +- plugins/postcss-focus-within/src/index.ts | 1 + .../postcss-font-format-keywords/CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../postcss-font-format-keywords/package.json | 12 +- .../postcss-font-format-keywords/src/index.ts | 1 + plugins/postcss-gamut-mapping/CHANGELOG.md | 5 + plugins/postcss-gamut-mapping/dist/index.cjs | 1 - plugins/postcss-gamut-mapping/dist/index.d.ts | 1 + plugins/postcss-gamut-mapping/dist/index.mjs | 2 +- plugins/postcss-gamut-mapping/package.json | 12 +- plugins/postcss-gamut-mapping/src/index.ts | 1 + plugins/postcss-gap-properties/CHANGELOG.md | 5 + plugins/postcss-gap-properties/dist/index.cjs | 1 - .../postcss-gap-properties/dist/index.d.ts | 1 + plugins/postcss-gap-properties/dist/index.mjs | 2 +- plugins/postcss-gap-properties/package.json | 12 +- plugins/postcss-gap-properties/src/index.ts | 1 + plugins/postcss-global-data/CHANGELOG.md | 5 + plugins/postcss-global-data/dist/index.cjs | 1 - plugins/postcss-global-data/dist/index.d.ts | 1 + plugins/postcss-global-data/dist/index.mjs | 2 +- plugins/postcss-global-data/package.json | 12 +- plugins/postcss-global-data/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-hwb-function/CHANGELOG.md | 5 + plugins/postcss-hwb-function/dist/index.cjs | 1 - plugins/postcss-hwb-function/dist/index.d.ts | 1 + plugins/postcss-hwb-function/dist/index.mjs | 2 +- plugins/postcss-hwb-function/package.json | 12 +- plugins/postcss-hwb-function/src/index.ts | 1 + plugins/postcss-ic-unit/CHANGELOG.md | 5 + plugins/postcss-ic-unit/dist/index.cjs | 1 - plugins/postcss-ic-unit/dist/index.d.ts | 1 + plugins/postcss-ic-unit/dist/index.mjs | 2 +- plugins/postcss-ic-unit/package.json | 12 +- plugins/postcss-ic-unit/src/index.ts | 1 + .../postcss-image-set-function/CHANGELOG.md | 5 + .../postcss-image-set-function/dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../postcss-image-set-function/dist/index.mjs | 2 +- .../postcss-image-set-function/package.json | 12 +- .../postcss-image-set-function/src/index.ts | 1 + plugins/postcss-initial/CHANGELOG.md | 5 + plugins/postcss-initial/dist/index.cjs | 1 - plugins/postcss-initial/dist/index.d.ts | 1 + plugins/postcss-initial/dist/index.mjs | 2 +- plugins/postcss-initial/package.json | 12 +- plugins/postcss-initial/src/index.ts | 1 + plugins/postcss-is-pseudo-class/CHANGELOG.md | 5 + .../postcss-is-pseudo-class/dist/index.cjs | 1 - .../postcss-is-pseudo-class/dist/index.d.ts | 1 + .../postcss-is-pseudo-class/dist/index.mjs | 2 +- plugins/postcss-is-pseudo-class/package.json | 12 +- plugins/postcss-is-pseudo-class/src/index.ts | 1 + plugins/postcss-lab-function/CHANGELOG.md | 5 + plugins/postcss-lab-function/dist/index.cjs | 1 - plugins/postcss-lab-function/dist/index.d.ts | 1 + plugins/postcss-lab-function/dist/index.mjs | 2 +- plugins/postcss-lab-function/package.json | 12 +- plugins/postcss-lab-function/src/index.ts | 1 + .../postcss-light-dark-function/CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../postcss-light-dark-function/package.json | 12 +- .../postcss-light-dark-function/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-logical-overflow/CHANGELOG.md | 5 + .../postcss-logical-overflow/dist/index.cjs | 1 - .../postcss-logical-overflow/dist/index.d.ts | 1 + .../postcss-logical-overflow/dist/index.mjs | 2 +- plugins/postcss-logical-overflow/package.json | 12 +- plugins/postcss-logical-overflow/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-logical-resize/CHANGELOG.md | 5 + plugins/postcss-logical-resize/dist/index.cjs | 1 - .../postcss-logical-resize/dist/index.d.ts | 1 + plugins/postcss-logical-resize/dist/index.mjs | 2 +- plugins/postcss-logical-resize/package.json | 12 +- plugins/postcss-logical-resize/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-logical/CHANGELOG.md | 5 + plugins/postcss-logical/dist/index.cjs | 1 - plugins/postcss-logical/dist/index.d.ts | 1 + plugins/postcss-logical/dist/index.mjs | 2 +- plugins/postcss-logical/package.json | 12 +- plugins/postcss-logical/src/index.ts | 1 + plugins/postcss-media-minmax/CHANGELOG.md | 5 + plugins/postcss-media-minmax/dist/index.cjs | 1 - plugins/postcss-media-minmax/dist/index.d.ts | 1 + plugins/postcss-media-minmax/dist/index.mjs | 2 +- plugins/postcss-media-minmax/package.json | 12 +- plugins/postcss-media-minmax/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-minify/CHANGELOG.md | 5 + plugins/postcss-minify/dist/index.cjs | 1 - plugins/postcss-minify/dist/index.d.ts | 1 + plugins/postcss-minify/dist/index.mjs | 2 +- plugins/postcss-minify/package.json | 12 +- plugins/postcss-minify/src/index.ts | 1 + plugins/postcss-nested-calc/CHANGELOG.md | 5 + plugins/postcss-nested-calc/dist/index.cjs | 1 - plugins/postcss-nested-calc/dist/index.d.ts | 1 + plugins/postcss-nested-calc/dist/index.mjs | 2 +- plugins/postcss-nested-calc/package.json | 12 +- plugins/postcss-nested-calc/src/index.ts | 1 + plugins/postcss-nesting/CHANGELOG.md | 5 + plugins/postcss-nesting/dist/index.cjs | 1 - plugins/postcss-nesting/dist/index.d.ts | 1 + plugins/postcss-nesting/dist/index.mjs | 2 +- plugins/postcss-nesting/package.json | 12 +- plugins/postcss-nesting/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-oklab-function/CHANGELOG.md | 5 + plugins/postcss-oklab-function/dist/index.cjs | 1 - .../postcss-oklab-function/dist/index.d.ts | 1 + plugins/postcss-oklab-function/dist/index.mjs | 2 +- plugins/postcss-oklab-function/package.json | 12 +- plugins/postcss-oklab-function/src/index.ts | 1 + .../postcss-overflow-shorthand/CHANGELOG.md | 5 + .../postcss-overflow-shorthand/dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../postcss-overflow-shorthand/dist/index.mjs | 2 +- .../postcss-overflow-shorthand/package.json | 12 +- .../postcss-overflow-shorthand/src/index.ts | 1 + plugins/postcss-place/CHANGELOG.md | 5 + plugins/postcss-place/dist/index.cjs | 1 - plugins/postcss-place/dist/index.d.ts | 1 + plugins/postcss-place/dist/index.mjs | 2 +- plugins/postcss-place/package.json | 12 +- plugins/postcss-place/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-random-function/CHANGELOG.md | 5 + .../postcss-random-function/dist/index.cjs | 1 - .../postcss-random-function/dist/index.d.ts | 1 + .../postcss-random-function/dist/index.mjs | 2 +- plugins/postcss-random-function/package.json | 12 +- plugins/postcss-random-function/src/index.ts | 1 + plugins/postcss-rebase-url/CHANGELOG.md | 5 + plugins/postcss-rebase-url/dist/index.cjs | 1 - plugins/postcss-rebase-url/dist/index.d.ts | 1 + plugins/postcss-rebase-url/dist/index.mjs | 2 +- plugins/postcss-rebase-url/package.json | 12 +- plugins/postcss-rebase-url/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-rewrite-url/CHANGELOG.md | 5 + plugins/postcss-rewrite-url/dist/index.cjs | 1 - plugins/postcss-rewrite-url/dist/index.d.ts | 1 + plugins/postcss-rewrite-url/dist/index.mjs | 2 +- plugins/postcss-rewrite-url/package.json | 12 +- plugins/postcss-rewrite-url/src/index.ts | 1 + .../postcss-scope-pseudo-class/CHANGELOG.md | 5 + .../postcss-scope-pseudo-class/dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../postcss-scope-pseudo-class/dist/index.mjs | 2 +- .../postcss-scope-pseudo-class/package.json | 12 +- .../postcss-scope-pseudo-class/src/index.ts | 1 + plugins/postcss-selector-not/CHANGELOG.md | 5 + plugins/postcss-selector-not/dist/index.cjs | 1 - plugins/postcss-selector-not/dist/index.d.ts | 1 + plugins/postcss-selector-not/dist/index.mjs | 2 +- plugins/postcss-selector-not/package.json | 12 +- plugins/postcss-selector-not/src/index.ts | 1 + plugins/postcss-sign-functions/CHANGELOG.md | 5 + plugins/postcss-sign-functions/dist/index.cjs | 1 - .../postcss-sign-functions/dist/index.d.ts | 1 + plugins/postcss-sign-functions/dist/index.mjs | 2 +- plugins/postcss-sign-functions/package.json | 12 +- plugins/postcss-sign-functions/src/index.ts | 1 + plugins/postcss-slow-plugins/CHANGELOG.md | 5 + plugins/postcss-slow-plugins/dist/index.cjs | 1 - plugins/postcss-slow-plugins/dist/index.d.ts | 1 + plugins/postcss-slow-plugins/dist/index.mjs | 2 +- plugins/postcss-slow-plugins/package.json | 12 +- plugins/postcss-slow-plugins/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-todo-or-die/CHANGELOG.md | 5 + plugins/postcss-todo-or-die/dist/index.cjs | 1 - plugins/postcss-todo-or-die/dist/index.d.ts | 1 + plugins/postcss-todo-or-die/dist/index.mjs | 2 +- plugins/postcss-todo-or-die/package.json | 12 +- plugins/postcss-todo-or-die/src/index.ts | 1 + .../CHANGELOG.md | 5 + .../dist/index.cjs | 1 - .../dist/index.d.ts | 1 + .../dist/index.mjs | 2 +- .../package.json | 12 +- .../src/index.ts | 1 + plugins/postcss-unset-value/CHANGELOG.md | 5 + plugins/postcss-unset-value/dist/index.cjs | 1 - plugins/postcss-unset-value/dist/index.d.ts | 1 + plugins/postcss-unset-value/dist/index.mjs | 2 +- plugins/postcss-unset-value/package.json | 12 +- plugins/postcss-unset-value/src/index.ts | 1 + rollup/default.mjs | 12 +- rollup/presets/package-javascript.mjs | 1 - rollup/presets/package-typescript.mjs | 27 +- rollup/transforms/api-extractor.mjs | 4 + tsconfig.json | 4 +- 546 files changed, 1075 insertions(+), 1368 deletions(-) delete mode 100644 experimental/css-has-pseudo/dist/index.cjs delete mode 100644 experimental/postcss-gradient-stop-increments/dist/index.cjs delete mode 100644 experimental/postcss-nesting/dist/index.cjs delete mode 100644 packages/base-cli/dist/index.cjs delete mode 100644 packages/cascade-layer-name-parser/dist/index.cjs delete mode 100644 packages/color-helpers/dist/index.cjs delete mode 100644 packages/css-calc/dist/index.cjs delete mode 100644 packages/css-color-parser/dist/index.cjs delete mode 100644 packages/css-parser-algorithms/dist/index.cjs create mode 100644 packages/css-syntax-patches-for-csstree/tests/import.test.mjs create mode 100644 packages/css-syntax-patches-for-csstree/tests/require.test.cjs delete mode 100644 packages/css-tokenizer/dist/index.cjs delete mode 100644 packages/media-query-list-parser/dist/index.cjs delete mode 100644 packages/pack-test/dist/index.cjs delete mode 100644 packages/postcss-tape/dist/index.cjs delete mode 100644 packages/selector-resolve-nested/dist/index.cjs delete mode 100644 packages/selector-specificity/dist/index.cjs delete mode 100644 packages/utilities/dist/index.cjs delete mode 100644 plugin-packs/postcss-bundler/dist/index.cjs delete mode 100644 plugin-packs/postcss-preset-env/dist/index.cjs delete mode 100644 plugins/css-blank-pseudo/dist/index.cjs create mode 100644 plugins/css-blank-pseudo/index.d.ts delete mode 100644 plugins/css-has-pseudo/dist/index.cjs delete mode 100644 plugins/css-prefers-color-scheme/dist/index.cjs delete mode 100644 plugins/postcss-alpha-function/dist/index.cjs delete mode 100644 plugins/postcss-attribute-case-insensitive/dist/index.cjs delete mode 100644 plugins/postcss-base-plugin/dist/index.cjs delete mode 100644 plugins/postcss-browser-comments/dist/index.cjs delete mode 100644 plugins/postcss-cascade-layers/dist/index.cjs delete mode 100644 plugins/postcss-color-function-display-p3-linear/dist/index.cjs delete mode 100644 plugins/postcss-color-function/dist/index.cjs delete mode 100644 plugins/postcss-color-functional-notation/dist/index.cjs delete mode 100644 plugins/postcss-color-hex-alpha/dist/index.cjs delete mode 100644 plugins/postcss-color-mix-function/dist/index.cjs delete mode 100644 plugins/postcss-color-mix-variadic-function-arguments/dist/index.cjs delete mode 100644 plugins/postcss-color-rebeccapurple/dist/index.cjs delete mode 100644 plugins/postcss-conditional-values/dist/index.cjs delete mode 100644 plugins/postcss-content-alt-text/dist/index.cjs delete mode 100644 plugins/postcss-contrast-color-function/dist/index.cjs delete mode 100644 plugins/postcss-custom-media/dist/index.cjs delete mode 100644 plugins/postcss-custom-properties/dist/index.cjs delete mode 100644 plugins/postcss-custom-selectors/dist/index.cjs delete mode 100644 plugins/postcss-debug-logger/dist/index.cjs delete mode 100644 plugins/postcss-design-tokens/dist/index.cjs delete mode 100644 plugins/postcss-dir-pseudo-class/dist/index.cjs delete mode 100644 plugins/postcss-double-position-gradients/dist/index.cjs delete mode 100644 plugins/postcss-env-function/dist/index.cjs delete mode 100644 plugins/postcss-exponential-functions/dist/index.cjs delete mode 100644 plugins/postcss-extract/dist/index.cjs delete mode 100644 plugins/postcss-focus-visible/dist/index.cjs delete mode 100644 plugins/postcss-focus-within/dist/index.cjs delete mode 100644 plugins/postcss-font-format-keywords/dist/index.cjs delete mode 100644 plugins/postcss-gamut-mapping/dist/index.cjs delete mode 100644 plugins/postcss-gap-properties/dist/index.cjs delete mode 100644 plugins/postcss-global-data/dist/index.cjs delete mode 100644 plugins/postcss-gradients-interpolation-method/dist/index.cjs delete mode 100644 plugins/postcss-hwb-function/dist/index.cjs delete mode 100644 plugins/postcss-ic-unit/dist/index.cjs delete mode 100644 plugins/postcss-image-set-function/dist/index.cjs delete mode 100644 plugins/postcss-initial/dist/index.cjs delete mode 100644 plugins/postcss-is-pseudo-class/dist/index.cjs delete mode 100644 plugins/postcss-lab-function/dist/index.cjs delete mode 100644 plugins/postcss-light-dark-function/dist/index.cjs delete mode 100644 plugins/postcss-logical-float-and-clear/dist/index.cjs delete mode 100644 plugins/postcss-logical-overflow/dist/index.cjs delete mode 100644 plugins/postcss-logical-overscroll-behavior/dist/index.cjs delete mode 100644 plugins/postcss-logical-resize/dist/index.cjs delete mode 100644 plugins/postcss-logical-viewport-units/dist/index.cjs delete mode 100644 plugins/postcss-logical/dist/index.cjs delete mode 100644 plugins/postcss-media-minmax/dist/index.cjs delete mode 100644 plugins/postcss-media-queries-aspect-ratio-number-values/dist/index.cjs delete mode 100644 plugins/postcss-minify/dist/index.cjs delete mode 100644 plugins/postcss-nested-calc/dist/index.cjs delete mode 100644 plugins/postcss-nesting/dist/index.cjs delete mode 100644 plugins/postcss-normalize-display-values/dist/index.cjs delete mode 100644 plugins/postcss-oklab-function/dist/index.cjs delete mode 100644 plugins/postcss-overflow-shorthand/dist/index.cjs delete mode 100644 plugins/postcss-place/dist/index.cjs delete mode 100644 plugins/postcss-position-area-property/dist/index.cjs delete mode 100644 plugins/postcss-progressive-custom-properties/dist/index.cjs delete mode 100644 plugins/postcss-property-rule-prelude-list/dist/index.cjs delete mode 100644 plugins/postcss-pseudo-class-any-link/dist/index.cjs delete mode 100644 plugins/postcss-random-function/dist/index.cjs delete mode 100644 plugins/postcss-rebase-url/dist/index.cjs delete mode 100644 plugins/postcss-relative-color-syntax/dist/index.cjs delete mode 100644 plugins/postcss-rewrite-url/dist/index.cjs delete mode 100644 plugins/postcss-scope-pseudo-class/dist/index.cjs delete mode 100644 plugins/postcss-selector-not/dist/index.cjs delete mode 100644 plugins/postcss-sign-functions/dist/index.cjs delete mode 100644 plugins/postcss-slow-plugins/dist/index.cjs delete mode 100644 plugins/postcss-stepped-value-functions/dist/index.cjs delete mode 100644 plugins/postcss-syntax-descriptor-syntax-production/dist/index.cjs delete mode 100644 plugins/postcss-system-ui-font-family/dist/index.cjs delete mode 100644 plugins/postcss-text-decoration-shorthand/dist/index.cjs delete mode 100644 plugins/postcss-todo-or-die/dist/index.cjs delete mode 100644 plugins/postcss-trigonometric-functions/dist/index.cjs delete mode 100644 plugins/postcss-unset-value/dist/index.cjs diff --git a/.github/bin/format-package-json.mjs b/.github/bin/format-package-json.mjs index baa7b583f..47c912d36 100644 --- a/.github/bin/format-package-json.mjs +++ b/.github/bin/format-package-json.mjs @@ -75,10 +75,15 @@ const formatted = {}; delete packageJSONInfo.private; formatted.engines = { - node: '>=18', + node: '>=20.19.0', }; delete packageJSONInfo.engines; + // json only package + if (formatted.name === '@csstools/css-syntax-patches-for-csstree') { + delete formatted.engines; + } + formatted.type = packageJSONInfo.type; delete packageJSONInfo.type; } @@ -103,16 +108,8 @@ const formatted = {}; formatted.unpkg = packageJSONInfo.unpkg; delete packageJSONInfo.unpkg; - if (packageJSONInfo.exports) { - formatted.exports = packageJSONInfo.exports; - if (packageJSONInfo.exports['.'] && packageJSONInfo.exports['.'].types) { - formatted.exports['.'] = { - types: packageJSONInfo.exports['.'].types, - ...formatted.exports['.'], - }; - } - delete packageJSONInfo.exports; - } + formatted.exports = packageJSONInfo.exports; + delete packageJSONInfo.exports; formatted.files = packageJSONInfo.files; delete packageJSONInfo.files; diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 15ed1e34e..590ea838c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -4,6 +4,10 @@ on: schedule: - cron: '0 4 * * 1' workflow_dispatch: + push: + branches: + - 'main' + pull_request: defaults: run: @@ -33,14 +37,5 @@ jobs: languages: ${{ matrix.language }} queries: security-extended - - name: setup node - uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f - with: - node-version: 24 - cache: 'npm' - - - run: npm ci --ignore-scripts - - run: npm run build --workspaces --if-present - - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3ca7cc9de..f01d5a62b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: # Enable annotations only for node 24 + ubuntu matrix: os: [ubuntu-latest] - node: [18, 20, 22, 24, 25] + node: [20, 22, 24, 25] include: - os: macos-latest node: 24 diff --git a/cli/csstools-cli/CHANGELOG.md b/cli/csstools-cli/CHANGELOG.md index 1c635f9c7..1952944df 100644 --- a/cli/csstools-cli/CHANGELOG.md +++ b/cli/csstools-cli/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to CSSTools CLI +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.25 _January 10, 2026_ diff --git a/cli/csstools-cli/package.json b/cli/csstools-cli/package.json index a087d5478..1f3bf8647 100644 --- a/cli/csstools-cli/package.json +++ b/cli/csstools-cli/package.json @@ -25,12 +25,11 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "bin": { "csstools-cli": "dist/cli.cjs" }, - "types": "dist/cli.d.ts", "files": [ "CHANGELOG.md", "LICENSE.md", diff --git a/eslint.config.mjs b/eslint.config.mjs index 16ea66b5a..83cd9758a 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -34,7 +34,7 @@ export default [ globals: { ...globals.node, }, - ecmaVersion: 2022, + ecmaVersion: 2025, sourceType: 'module', }, @@ -71,7 +71,7 @@ export default [ globals: { ...globals.browser, }, - ecmaVersion: 2022, + ecmaVersion: 2025, sourceType: 'module', }, diff --git a/experimental/css-has-pseudo/CHANGELOG.md b/experimental/css-has-pseudo/CHANGELOG.md index 56fa3dbbb..eee9fbeda 100644 --- a/experimental/css-has-pseudo/CHANGELOG.md +++ b/experimental/css-has-pseudo/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to CSS Has Pseudo +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 1.0.0 _August 3, 2024_ diff --git a/experimental/css-has-pseudo/dist/index.cjs b/experimental/css-has-pseudo/dist/index.cjs deleted file mode 100644 index d8343b867..000000000 --- a/experimental/css-has-pseudo/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";const creator=()=>({postcssPlugin:"css-has-pseudo-experimental",Once(s,{result:e}){s.warn(e,'"@csstools/css-has-pseudo-experimental" is no longer supported. Please use "css-has-pseudo" instead.')}});creator.postcss=!0,module.exports=creator; diff --git a/experimental/css-has-pseudo/dist/index.d.ts b/experimental/css-has-pseudo/dist/index.d.ts index 4b66a8014..104650cef 100644 --- a/experimental/css-has-pseudo/dist/index.d.ts +++ b/experimental/css-has-pseudo/dist/index.d.ts @@ -2,5 +2,6 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export { } diff --git a/experimental/css-has-pseudo/dist/index.mjs b/experimental/css-has-pseudo/dist/index.mjs index 911a0c742..a4882b5f6 100644 --- a/experimental/css-has-pseudo/dist/index.mjs +++ b/experimental/css-has-pseudo/dist/index.mjs @@ -1 +1 @@ -const creator=()=>({postcssPlugin:"css-has-pseudo-experimental",Once(s,{result:e}){s.warn(e,'"@csstools/css-has-pseudo-experimental" is no longer supported. Please use "css-has-pseudo" instead.')}});creator.postcss=!0;export{creator as default}; +const creator=()=>({postcssPlugin:"css-has-pseudo-experimental",Once(s,{result:e}){s.warn(e,'"@csstools/css-has-pseudo-experimental" is no longer supported. Please use "css-has-pseudo" instead.')}});creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/experimental/css-has-pseudo/package.json b/experimental/css-has-pseudo/package.json index 7c3d26ebd..13e1cc60a 100644 --- a/experimental/css-has-pseudo/package.json +++ b/experimental/css-has-pseudo/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" }, "./browser": { "import": "./dist/browser.mjs", diff --git a/experimental/css-has-pseudo/src/index.ts b/experimental/css-has-pseudo/src/index.ts index 7ee667397..cedfe2860 100644 --- a/experimental/css-has-pseudo/src/index.ts +++ b/experimental/css-has-pseudo/src/index.ts @@ -12,3 +12,4 @@ const creator: PluginCreator = () => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/experimental/postcss-gradient-stop-increments/CHANGELOG.md b/experimental/postcss-gradient-stop-increments/CHANGELOG.md index 2be9bd1b2..359372fba 100644 --- a/experimental/postcss-gradient-stop-increments/CHANGELOG.md +++ b/experimental/postcss-gradient-stop-increments/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Gradient Stop Increments +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.9 _May 27, 2025_ diff --git a/experimental/postcss-gradient-stop-increments/dist/index.cjs b/experimental/postcss-gradient-stop-increments/dist/index.cjs deleted file mode 100644 index cf2e0504d..000000000 --- a/experimental/postcss-gradient-stop-increments/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-parser-algorithms"),n=require("@csstools/css-calc"),o=require("@csstools/css-tokenizer");const t=/(?:repeating-)?(?:linear|radial|conic)-gradient\(/i,a=/^(?:repeating-)?(?:linear|radial|conic)-gradient$/i,i=/^(?:abs|acos|asin|atan|atan2|calc|clamp|cos|exp|hypot|log|max|min|mod|pow|rem|round|sign|sin|sqrt|tan)$/i,creator=n=>{const s=Object.assign({preserve:!1},n);return{postcssPlugin:"postcss-gradient-stop-increments",Declaration(n){if(!t.test(n.value))return;const r=o.tokenize({css:n.value});if(!r.find(e=>o.isTokenDelim(e)&&"+"===e[4].value))return;const c=e.stringify(e.replaceComponentValues(e.parseCommaSeparatedListOfComponentValues(r),n=>{if(!e.isFunctionNode(n))return;const t=n.getName();if(!a.test(t))return;let s=null;for(let t=0;t0)}function isZeroOrNegative(n){return!!(e.isTokenNode(n)&&o.isTokenNumeric(n.value)&&n.value[4].value<=0)}function incrementLengthNode(t,a,i){if(!t)return i;const s=new e.FunctionNode([o.TokenType.Function,"calc(",-1,-1,{value:"calc"}],[o.TokenType.CloseParen,")",-1,-1,void 0],[t,new e.WhitespaceNode([[o.TokenType.Whitespace," ",-1,-1,void 0]]),a,new e.WhitespaceNode([[o.TokenType.Whitespace," ",-1,-1,void 0]]),i]),[[r]]=n.calcFromComponentValues([[s]]);return r}function maxOfLastAndCurrentLengthNode(t,a){if(!t)return a;const i=new e.FunctionNode([o.TokenType.Function,"max(",-1,-1,{value:"max"}],[o.TokenType.CloseParen,")",-1,-1,void 0],[t,new e.TokenNode([o.TokenType.Comma,",",-1,-1,void 0]),new e.WhitespaceNode([[o.TokenType.Whitespace," ",-1,-1,void 0]]),a]),[[s]]=n.calcFromComponentValues([[i]]);return s}creator.postcss=!0,module.exports=creator; diff --git a/experimental/postcss-gradient-stop-increments/dist/index.d.ts b/experimental/postcss-gradient-stop-increments/dist/index.d.ts index 9a55a7819..a8ae6ff9d 100644 --- a/experimental/postcss-gradient-stop-increments/dist/index.d.ts +++ b/experimental/postcss-gradient-stop-increments/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-gradient-stop-increments plugin options */ export declare type pluginOptions = { diff --git a/experimental/postcss-gradient-stop-increments/dist/index.mjs b/experimental/postcss-gradient-stop-increments/dist/index.mjs index 16cc588cd..4451e5b2f 100644 --- a/experimental/postcss-gradient-stop-increments/dist/index.mjs +++ b/experimental/postcss-gradient-stop-increments/dist/index.mjs @@ -1 +1 @@ -import{stringify as e,replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as t,isFunctionNode as a,isTokenNode as r,isCommentNode as o,TokenNode as s,FunctionNode as i,WhitespaceNode as c}from"@csstools/css-parser-algorithms";import{calcFromComponentValues as u}from"@csstools/css-calc";import{tokenize as l,isTokenDelim as v,TokenType as m,NumberType as d,isTokenNumeric as f}from"@csstools/css-tokenizer";const g=/(?:repeating-)?(?:linear|radial|conic)-gradient\(/i,p=/^(?:repeating-)?(?:linear|radial|conic)-gradient$/i,h=/^(?:abs|acos|asin|atan|atan2|calc|clamp|cos|exp|hypot|log|max|min|mod|pow|rem|round|sign|sin|sqrt|tan)$/i,creator=i=>{const c=Object.assign({preserve:!1},i);return{postcssPlugin:"postcss-gradient-stop-increments",Declaration(i){if(!g.test(i.value))return;const u=l({css:i.value});if(!u.find(e=>v(e)&&"+"===e[4].value))return;const f=e(n(t(u),e=>{if(!a(e))return;const n=e.getName();if(!p.test(n))return;let t=null;for(let n=0;n0)}function isZeroOrNegative(e){return!!(r(e)&&f(e.value)&&e.value[4].value<=0)}function incrementLengthNode(e,n,t){if(!e)return t;const a=new i([m.Function,"calc(",-1,-1,{value:"calc"}],[m.CloseParen,")",-1,-1,void 0],[e,new c([[m.Whitespace," ",-1,-1,void 0]]),n,new c([[m.Whitespace," ",-1,-1,void 0]]),t]),[[r]]=u([[a]]);return r}function maxOfLastAndCurrentLengthNode(e,n){if(!e)return n;const t=new i([m.Function,"max(",-1,-1,{value:"max"}],[m.CloseParen,")",-1,-1,void 0],[e,new s([m.Comma,",",-1,-1,void 0]),new c([[m.Whitespace," ",-1,-1,void 0]]),n]),[[a]]=u([[t]]);return a}creator.postcss=!0;export{creator as default}; +import{stringify as e,replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as t,isFunctionNode as a,isTokenNode as r,isCommentNode as o,TokenNode as s,FunctionNode as i,WhitespaceNode as c}from"@csstools/css-parser-algorithms";import{calcFromComponentValues as u}from"@csstools/css-calc";import{tokenize as l,isTokenDelim as v,TokenType as m,NumberType as d,isTokenNumeric as f}from"@csstools/css-tokenizer";const p=/(?:repeating-)?(?:linear|radial|conic)-gradient\(/i,g=/^(?:repeating-)?(?:linear|radial|conic)-gradient$/i,h=/^(?:abs|acos|asin|atan|atan2|calc|clamp|cos|exp|hypot|log|max|min|mod|pow|rem|round|sign|sin|sqrt|tan)$/i,creator=i=>{const c=Object.assign({preserve:!1},i);return{postcssPlugin:"postcss-gradient-stop-increments",Declaration(i){if(!p.test(i.value))return;const u=l({css:i.value});if(!u.find(e=>v(e)&&"+"===e[4].value))return;const f=e(n(t(u),e=>{if(!a(e))return;const n=e.getName();if(!g.test(n))return;let t=null;for(let n=0;n0)}function isZeroOrNegative(e){return!!(r(e)&&f(e.value)&&e.value[4].value<=0)}function incrementLengthNode(e,n,t){if(!e)return t;const a=new i([m.Function,"calc(",-1,-1,{value:"calc"}],[m.CloseParen,")",-1,-1,void 0],[e,new c([[m.Whitespace," ",-1,-1,void 0]]),n,new c([[m.Whitespace," ",-1,-1,void 0]]),t]),[[r]]=u([[a]]);return r}function maxOfLastAndCurrentLengthNode(e,n){if(!e)return n;const t=new i([m.Function,"max(",-1,-1,{value:"max"}],[m.CloseParen,")",-1,-1,void 0],[e,new s([m.Comma,",",-1,-1,void 0]),new c([[m.Whitespace," ",-1,-1,void 0]]),n]),[[a]]=u([[t]]);return a}creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/experimental/postcss-gradient-stop-increments/package.json b/experimental/postcss-gradient-stop-increments/package.json index 5173bedf6..18634fcdc 100644 --- a/experimental/postcss-gradient-stop-increments/package.json +++ b/experimental/postcss-gradient-stop-increments/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/experimental/postcss-gradient-stop-increments/src/index.ts b/experimental/postcss-gradient-stop-increments/src/index.ts index af432a345..3435d0ff5 100644 --- a/experimental/postcss-gradient-stop-increments/src/index.ts +++ b/experimental/postcss-gradient-stop-increments/src/index.ts @@ -114,6 +114,7 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; function isNumericLargerThanZero(node: ComponentValue): boolean { if ( diff --git a/experimental/postcss-nesting/CHANGELOG.md b/experimental/postcss-nesting/CHANGELOG.md index ab9f29b93..0fa1c44b9 100644 --- a/experimental/postcss-nesting/CHANGELOG.md +++ b/experimental/postcss-nesting/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Nesting Experimental +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.0.1 _October 23, 2024_ diff --git a/experimental/postcss-nesting/dist/index.cjs b/experimental/postcss-nesting/dist/index.cjs deleted file mode 100644 index f1c1fb418..000000000 --- a/experimental/postcss-nesting/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser");function ampersandToScope(t,n){let r,o=t.parent;for(;o;){if("rule"===o.type)return;o=o.parent}try{r=e().astSync(t.selector)}catch(e){if(!(e instanceof Error))throw e;return void t.warn(n,`Failed to parse selector : "${t.selector}" with message: "${e.message}"`)}r&&(r.walkNesting(t=>{"root"===t.parent?.parent?.type?t.replaceWith(e.pseudo({value:":scope"})):t.replaceWith(e.pseudo({value:":is",nodes:[e.pseudo({value:":root"}),e.pseudo({value:":host"})]}))}),t.selector=r.toString())}function cleanupParent(e){if(!e.nodes.length)return void e.remove();const t=e.nodes.filter(e=>"comment"===e.type);t.length===e.nodes.length&&e.replaceWith(...t)}function shiftNodesBeforeParent(e,t){const n=t.index(e);if(n){const e=t.cloneBefore().removeAll().append(t.nodes.slice(0,n));e.raws.semicolon=!0,cleanupParent(e)}t.before(e),t.raws.semicolon=!0}function mergeSelectors(t,n,r,o){const s=[];if(0===o.length)return;const i=e().astSync(`:is(${r.join(",")})`);for(let r=0;r{"nesting"===e.type&&(a=!0)}),!a){const s=l.nodes[0];let i=!1;if(s.each(e=>"combinator"===e.type&&(i=!0,!1)),0===r){let e=!1;s.each(t=>"tag"===t.type&&(e=!0,!1)),e&&t.warn(n,`Invalid nested rule : "${o[r]}"`)}i||s.insertBefore(s.at(0),e.combinator({value:" "})),s.insertBefore(s.at(0),e.nesting())}l.walk(e=>{"nesting"===e.type&&e.replaceWith(i.clone({}))}),s.push(l.toString())}return s}function groupDeclarations(e){let t=-1;e.each((n,r)=>{if("decl"===n.type){if(-1===t)return void(t=r);if(t===r-1)return void(t=r);n.remove(),e.insertAfter(t,n),t=e.index(n)}})}function transformRuleWithinRule(e,t,n){let r=[];try{r=mergeSelectors(e,n,t.selectors,e.selectors)}catch(r){if(!(r instanceof Error))throw r;return void e.warn(n,`Failed to transform selectors : "${t.selector}" / "${e.selector}" with message: "${r.message}"`)}groupDeclarations(t),shiftNodesBeforeParent(e,t),e.selectors=r;"rule"===e.type&&"rule"===t.type&&e.selector===t.selector&&e.append(...t.nodes),cleanupParent(t)}var t=["container","document","media","supports","layer"];function atruleWithinRule(e,t,n,r){if(groupDeclarations(t),shiftNodesBeforeParent(e,t),e.nodes){const o=t.clone().removeAll().append(e.nodes);e.append(o),cleanupParent(t),r(o,n)}}function isAtruleWithinRule(e){return t.includes(e.name)}function comma(e){const t=[];let n="",r=!1,o=0,s=!1,i=!1;for(const l of e)i?i=!1:"\\"===l?i=!0:s?l===s&&(s=!1):'"'===l||"'"===l?s=l:"("===l?o+=1:")"===l?o>0&&(o-=1):0===o&&","===l&&(r=!0),r?(""!==n&&t.push(n.trim()),n="",r=!1):n+=l;return t.push(n.trim()),t}function transformAtruleWithinAtrule(e,t){var n,r;groupDeclarations(t),shiftNodesBeforeParent(e,t),e.params=(n=t.params,r=e.params,comma(n).map(e=>comma(r).map(t=>`${e} and ${t}`).join(", ")).join(", ")),cleanupParent(t)}function isAtruleWithinAtrule(e,n){return t.includes(e.name)&&e.name===n.name}function isAtRule(e){return e&&"atrule"===e.type}function isRule(e){return e&&"rule"===e.type}function walk(e,t){e.each(e=>{const n=e.parent;isRule(e)&&e.selector.trim()&&isRule(n)&&n.selector.trim()?transformRuleWithinRule(e,n,t):isAtRule(e)&&isRule(n)&&n.selector.trim()&&isAtruleWithinRule(e)?atruleWithinRule(e,n,t,walk):isAtRule(e)&&isAtRule(n)&&isAtruleWithinAtrule(e,n)&&transformAtruleWithinAtrule(e,n),"nodes"in e&&e.nodes.length&&walk(e,t)})}const creator=()=>({postcssPlugin:"postcss-nesting",Rule(e,{result:t}){walk(e,t),e.selector.trim().includes("&")&&ersandToScope(e,t)}});creator.postcss=!0,module.exports=creator; diff --git a/experimental/postcss-nesting/dist/index.d.ts b/experimental/postcss-nesting/dist/index.d.ts index 73f8cdb79..172fc5169 100644 --- a/experimental/postcss-nesting/dist/index.d.ts +++ b/experimental/postcss-nesting/dist/index.d.ts @@ -2,5 +2,6 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export { } diff --git a/experimental/postcss-nesting/dist/index.mjs b/experimental/postcss-nesting/dist/index.mjs index 6cfce8988..92a5cce82 100644 --- a/experimental/postcss-nesting/dist/index.mjs +++ b/experimental/postcss-nesting/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";function ampersandToScope(t,n){let r,o=t.parent;for(;o;){if("rule"===o.type)return;o=o.parent}try{r=e().astSync(t.selector)}catch(e){if(!(e instanceof Error))throw e;return void t.warn(n,`Failed to parse selector : "${t.selector}" with message: "${e.message}"`)}r&&(r.walkNesting(t=>{"root"===t.parent?.parent?.type?t.replaceWith(e.pseudo({value:":scope"})):t.replaceWith(e.pseudo({value:":is",nodes:[e.pseudo({value:":root"}),e.pseudo({value:":host"})]}))}),t.selector=r.toString())}function cleanupParent(e){if(!e.nodes.length)return void e.remove();const t=e.nodes.filter(e=>"comment"===e.type);t.length===e.nodes.length&&e.replaceWith(...t)}function shiftNodesBeforeParent(e,t){const n=t.index(e);if(n){const e=t.cloneBefore().removeAll().append(t.nodes.slice(0,n));e.raws.semicolon=!0,cleanupParent(e)}t.before(e),t.raws.semicolon=!0}function mergeSelectors(t,n,r,o){const s=[];if(0===o.length)return;const i=e().astSync(`:is(${r.join(",")})`);for(let r=0;r{"nesting"===e.type&&(a=!0)}),!a){const s=l.nodes[0];let i=!1;if(s.each(e=>"combinator"===e.type&&(i=!0,!1)),0===r){let e=!1;s.each(t=>"tag"===t.type&&(e=!0,!1)),e&&t.warn(n,`Invalid nested rule : "${o[r]}"`)}i||s.insertBefore(s.at(0),e.combinator({value:" "})),s.insertBefore(s.at(0),e.nesting())}l.walk(e=>{"nesting"===e.type&&e.replaceWith(i.clone({}))}),s.push(l.toString())}return s}function groupDeclarations(e){let t=-1;e.each((n,r)=>{if("decl"===n.type){if(-1===t)return void(t=r);if(t===r-1)return void(t=r);n.remove(),e.insertAfter(t,n),t=e.index(n)}})}function transformRuleWithinRule(e,t,n){let r=[];try{r=mergeSelectors(e,n,t.selectors,e.selectors)}catch(r){if(!(r instanceof Error))throw r;return void e.warn(n,`Failed to transform selectors : "${t.selector}" / "${e.selector}" with message: "${r.message}"`)}groupDeclarations(t),shiftNodesBeforeParent(e,t),e.selectors=r;"rule"===e.type&&"rule"===t.type&&e.selector===t.selector&&e.append(...t.nodes),cleanupParent(t)}var t=["container","document","media","supports","layer"];function atruleWithinRule(e,t,n,r){if(groupDeclarations(t),shiftNodesBeforeParent(e,t),e.nodes){const o=t.clone().removeAll().append(e.nodes);e.append(o),cleanupParent(t),r(o,n)}}function isAtruleWithinRule(e){return t.includes(e.name)}function comma(e){const t=[];let n="",r=!1,o=0,s=!1,i=!1;for(const l of e)i?i=!1:"\\"===l?i=!0:s?l===s&&(s=!1):'"'===l||"'"===l?s=l:"("===l?o+=1:")"===l?o>0&&(o-=1):0===o&&","===l&&(r=!0),r?(""!==n&&t.push(n.trim()),n="",r=!1):n+=l;return t.push(n.trim()),t}function transformAtruleWithinAtrule(e,t){var n,r;groupDeclarations(t),shiftNodesBeforeParent(e,t),e.params=(n=t.params,r=e.params,comma(n).map(e=>comma(r).map(t=>`${e} and ${t}`).join(", ")).join(", ")),cleanupParent(t)}function isAtruleWithinAtrule(e,n){return t.includes(e.name)&&e.name===n.name}function isAtRule(e){return e&&"atrule"===e.type}function isRule(e){return e&&"rule"===e.type}function walk(e,t){e.each(e=>{const n=e.parent;isRule(e)&&e.selector.trim()&&isRule(n)&&n.selector.trim()?transformRuleWithinRule(e,n,t):isAtRule(e)&&isRule(n)&&n.selector.trim()&&isAtruleWithinRule(e)?atruleWithinRule(e,n,t,walk):isAtRule(e)&&isAtRule(n)&&isAtruleWithinAtrule(e,n)&&transformAtruleWithinAtrule(e,n),"nodes"in e&&e.nodes.length&&walk(e,t)})}const creator=()=>({postcssPlugin:"postcss-nesting",Rule(e,{result:t}){walk(e,t),e.selector.trim().includes("&")&&ersandToScope(e,t)}});creator.postcss=!0;export{creator as default}; +import e from"postcss-selector-parser";function ampersandToScope(t,n){let r,o=t.parent;for(;o;){if("rule"===o.type)return;o=o.parent}try{r=e().astSync(t.selector)}catch(e){if(!(e instanceof Error))throw e;return void t.warn(n,`Failed to parse selector : "${t.selector}" with message: "${e.message}"`)}r&&(r.walkNesting(t=>{"root"===t.parent?.parent?.type?t.replaceWith(e.pseudo({value:":scope"})):t.replaceWith(e.pseudo({value:":is",nodes:[e.pseudo({value:":root"}),e.pseudo({value:":host"})]}))}),t.selector=r.toString())}function cleanupParent(e){if(!e.nodes.length)return void e.remove();const t=e.nodes.filter(e=>"comment"===e.type);t.length===e.nodes.length&&e.replaceWith(...t)}function shiftNodesBeforeParent(e,t){const n=t.index(e);if(n){const e=t.cloneBefore().removeAll().append(t.nodes.slice(0,n));e.raws.semicolon=!0,cleanupParent(e)}t.before(e),t.raws.semicolon=!0}function mergeSelectors(t,n,r,o){const s=[];if(0===o.length)return;const i=e().astSync(`:is(${r.join(",")})`);for(let r=0;r{"nesting"===e.type&&(a=!0)}),!a){const s=l.nodes[0];let i=!1;if(s.each(e=>"combinator"===e.type&&(i=!0,!1)),0===r){let e=!1;s.each(t=>"tag"===t.type&&(e=!0,!1)),e&&t.warn(n,`Invalid nested rule : "${o[r]}"`)}i||s.insertBefore(s.at(0),e.combinator({value:" "})),s.insertBefore(s.at(0),e.nesting())}l.walk(e=>{"nesting"===e.type&&e.replaceWith(i.clone({}))}),s.push(l.toString())}return s}function groupDeclarations(e){let t=-1;e.each((n,r)=>{if("decl"===n.type){if(-1===t)return void(t=r);if(t===r-1)return void(t=r);n.remove(),e.insertAfter(t,n),t=e.index(n)}})}function transformRuleWithinRule(e,t,n){let r=[];try{r=mergeSelectors(e,n,t.selectors,e.selectors)}catch(r){if(!(r instanceof Error))throw r;return void e.warn(n,`Failed to transform selectors : "${t.selector}" / "${e.selector}" with message: "${r.message}"`)}groupDeclarations(t),shiftNodesBeforeParent(e,t),e.selectors=r;"rule"===e.type&&"rule"===t.type&&e.selector===t.selector&&e.append(...t.nodes),cleanupParent(t)}var t=["container","document","media","supports","layer"];function atruleWithinRule(e,t,n,r){if(groupDeclarations(t),shiftNodesBeforeParent(e,t),e.nodes){const o=t.clone().removeAll().append(e.nodes);e.append(o),cleanupParent(t),r(o,n)}}function isAtruleWithinRule(e){return t.includes(e.name)}function comma(e){const t=[];let n="",r=!1,o=0,s=!1,i=!1;for(const l of e)i?i=!1:"\\"===l?i=!0:s?l===s&&(s=!1):'"'===l||"'"===l?s=l:"("===l?o+=1:")"===l?o>0&&(o-=1):0===o&&","===l&&(r=!0),r?(""!==n&&t.push(n.trim()),n="",r=!1):n+=l;return t.push(n.trim()),t}function transformAtruleWithinAtrule(e,t){var n,r;groupDeclarations(t),shiftNodesBeforeParent(e,t),e.params=(n=t.params,r=e.params,comma(n).map(e=>comma(r).map(t=>`${e} and ${t}`).join(", ")).join(", ")),cleanupParent(t)}function isAtruleWithinAtrule(e,n){return t.includes(e.name)&&e.name===n.name}function isAtRule(e){return e&&"atrule"===e.type}function isRule(e){return e&&"rule"===e.type}function walk(e,t){e.each(e=>{const n=e.parent;isRule(e)&&e.selector.trim()&&isRule(n)&&n.selector.trim()?transformRuleWithinRule(e,n,t):isAtRule(e)&&isRule(n)&&n.selector.trim()&&isAtruleWithinRule(e)?atruleWithinRule(e,n,t,walk):isAtRule(e)&&isAtRule(n)&&isAtruleWithinAtrule(e,n)&&transformAtruleWithinAtrule(e,n),"nodes"in e&&e.nodes.length&&walk(e,t)})}const creator=()=>({postcssPlugin:"postcss-nesting",Rule(e,{result:t}){walk(e,t),e.selector.trim().includes("&")&&ersandToScope(e,t)}});creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/experimental/postcss-nesting/package.json b/experimental/postcss-nesting/package.json index 239dbae6c..76aa287e3 100644 --- a/experimental/postcss-nesting/package.json +++ b/experimental/postcss-nesting/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/experimental/postcss-nesting/src/index.ts b/experimental/postcss-nesting/src/index.ts index 3deeec3c5..e015be661 100644 --- a/experimental/postcss-nesting/src/index.ts +++ b/experimental/postcss-nesting/src/index.ts @@ -18,3 +18,4 @@ const creator: PluginCreator = () => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/package-lock.json b/package-lock.json index d4af3870f..82e414354 100644 --- a/package-lock.json +++ b/package-lock.json @@ -236,6 +236,7 @@ "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -1861,6 +1862,7 @@ "integrity": "sha512-eohl3hKTiVyD1ilYdw9T0OiB4hnjef89e3dMYKz+mVKDzj+5IteTseASUsOB+EU9Tf6VNTCjDePcP6wkDGmLKQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@keyv/serialize": "^1.1.1" } @@ -4298,6 +4300,7 @@ "integrity": "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "undici-types": "~7.10.0" } @@ -4365,6 +4368,7 @@ "integrity": "sha512-3xP4XzzDNQOIqBMWogftkwxhg5oMKApqY0BAflmLZiFYHqyhSOxv/cd/zPQLTcCXr4AkaKb25joocY0BD1WC6A==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.51.0", "@typescript-eslint/types": "8.51.0", @@ -4605,6 +4609,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -5020,6 +5025,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -5355,6 +5361,7 @@ "integrity": "sha512-0eW44TGN5SQXU1mWSkKwFstI/22X2bG1nYzZTYMAWjylYURhse752YgbE4Cx46AC+bAvI+/dYTPRk1LqSUnu6w==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "mdn-data": "2.12.2", "source-map-js": "^1.0.1" @@ -5474,7 +5481,8 @@ "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1534754.tgz", "integrity": "sha512-26T91cV5dbOYnXdJi5qQHoTtUoNEqwkHcAyu/IKtjIAxiEqPMrDiRkDOPWVsGfNZGmlQVHQbZRSjD8sxagWVsQ==", "dev": true, - "license": "BSD-3-Clause" + "license": "BSD-3-Clause", + "peer": true }, "node_modules/diff": { "version": "8.0.2", @@ -5647,6 +5655,7 @@ "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -7647,6 +7656,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", @@ -8276,6 +8286,7 @@ "integrity": "sha512-3nk8Y3a9Ea8szgKhinMlGMhGMw89mqule3KWczxhIzqudyHdCIOHw8WJlj/r329fACjKLEh13ZSk7oE22kyeIw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@types/estree": "1.0.8" }, @@ -9124,8 +9135,8 @@ "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", - "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -9697,9 +9708,6 @@ "@webref/css": "8.1.3", "css-tree": "^3.1.0", "postcss": "^8.4" - }, - "engines": { - "node": ">=18" } }, "packages/css-tokenizer": { @@ -10005,7 +10013,7 @@ "@webref/css": "8.1.3" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10134,7 +10142,8 @@ ], "license": "MIT-0", "dependencies": { - "postcss-selector-parser": "^7.1.1" + "postcss-selector-parser": "^7.1.1", + "typescript": "^5.9.3" }, "devDependencies": { "@csstools/postcss-tape": "*", @@ -11377,7 +11386,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" diff --git a/package.json b/package.json index 08d46c666..354d6299c 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,7 @@ "private": true, "version": "1.0.0", "description": "", - "author": "Jonathan Neal ", "license": "MIT-0", - "engines": { - "node": "^14 || ^16 || >=18" - }, "workspaces": [ "packages/color-helpers", "packages/css-tokenizer", diff --git a/packages/base-cli/dist/index.cjs b/packages/base-cli/dist/index.cjs deleted file mode 100644 index 37897f837..000000000 --- a/packages/base-cli/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var t,e=require("postcss"),n=require("node:path"),s=require("node:fs/promises");function parseArguments(e,n,s){const o=e.map(t=>t.trim()).filter(t=>!!t),r={stdin:!1,stdout:!1,output:void 0,outputDir:void 0,inputs:[],inlineMap:!0,externalMap:!1,replace:!1,pluginOptions:{},debug:!1};let i,a=!1;for(let e=0;e1&&r.output)return console.warn('[error] omit "--output" when processing multiple inputs\n'),s(),t.InvalidArguments;0===r.inputs.length&&(r.stdin=!0),r.output||r.outputDir||r.replace||(r.stdout=!0),r.stdout&&(r.externalMap=!1);let p={};if(i)try{p=JSON.parse(i)}catch{return console.warn("[error] plugin options must be valid JSON\n"),s(),t.InvalidArguments}for(const e in p){const o=p[e];if(!n.includes(e))return console.warn(`[error] unknown plugin option: ${e}\n`),s(),t.InvalidArguments;r.pluginOptions[e]=o}return r}async function getStdin(){return new Promise(t=>{let e="",n=!1;if(setTimeout(()=>{n=!0,t("")},1e4),process.stdin.isTTY){if(n)return;t(e)}else process.stdin.setEncoding("utf8"),process.stdin.on("readable",()=>{let t="";for(;t=process.stdin.read();)e+=t??""}),process.stdin.on("end",()=>{n||t(e)})})}async function stdinToStdout(t,n,s){let o="";try{const r=await getStdin();r||(s(),process.exit(1));const i=await e([t]).process(r,{from:"stdin",to:"stdout",map:!!n.inlineMap&&{inline:!0}});i.warnings().forEach(t=>{console.warn(t.toString())}),o=i.css}catch(t){t instanceof Error?console.error(n.debug?t:t.message):console.error(t),process.exit(1)}process.stdout.write(o+(n.inlineMap?"\n":"")),process.exit(0)}async function stdinToFs(t,o,r){let i=o.output;!i&&o.outputDir&&(i=n.join(o.outputDir,"output.css")),i||process.exit(0);try{const n=await getStdin();n||(r(),process.exit(1));const a=await e([t]).process(n,{from:"stdin",to:i,map:!(!o.inlineMap&&!o.externalMap)&&{inline:o.inlineMap}});a.warnings().forEach(t=>{console.warn(t.toString())}),o.externalMap&&a.map?await Promise.all([s.writeFile(i,a.css+(o.inlineMap?"\n":"")),s.writeFile(`${i}.map`,a.map.toString())]):await s.writeFile(i,a.css+(o.inlineMap?"\n":""))}catch(t){t instanceof Error?console.error(o.debug?t:t.message):console.error(t),process.exit(1)}console.log(`CSS was written to "${n.normalize(i)}"`),process.exit(0)}async function fsToStdout(t,n){let o=[];try{o=await Promise.all(n.inputs.map(async n=>{const o=await s.readFile(n),r=await e([t]).process(o,{from:n,to:"stdout",map:!1});return r.warnings().forEach(t=>{console.warn(t.toString())}),r.css}))}catch(t){t instanceof Error?console.error(n.debug?t:t.message):console.error(t),process.exit(1)}for(const t of o)process.stdout.write(t);process.exit(0)}async function fsToFs(t,o){try{await Promise.all(o.inputs.map(async r=>{let i=o.output;o.outputDir&&(i=n.join(o.outputDir,n.basename(r))),o.replace&&(i=r),i||process.exit(0);const a=await s.readFile(r),p=await e([t]).process(a,{from:r,to:i,map:!(!o.inlineMap&&!o.externalMap)&&{inline:o.inlineMap}});p.warnings().forEach(t=>{console.warn(t.toString())}),o.externalMap&&p.map?await Promise.all([s.writeFile(i,p.css+(o.inlineMap?"\n":"")),s.writeFile(`${i}.map`,p.map.toString())]):await s.writeFile(i,p.css+(o.inlineMap?"\n":"")),console.log(`CSS was written to "${n.normalize(i)}"`)}))}catch(t){t instanceof Error?console.error(o.debug?t:t.message):console.error(t),process.exit(1)}process.exit(0)}!function(t){t.InvalidArguments="INVALID_ARGUMENTS"}(t||(t={})),exports.cli=async function cli(e,n,s,o=!0){const r=parseArguments(process.argv.slice(o?2:3),n,s);r===t.InvalidArguments&&process.exit(1);const i=e(r.pluginOptions);r.stdin&&r.stdout?await stdinToStdout(i,r,s):r.stdin?await stdinToFs(i,r,s):r.stdout?await fsToStdout(i,r):await fsToFs(i,r)},exports.helpTextLogger=function helpTextLogger(t,e,n,s=null){let o=[];if(s){const t=Math.max(...Object.keys(s).map(t=>t.length)),e=new Array(t).fill(" ").join("");e.length&&(o=["\nPlugin Options:",...Object.keys(s).map(t=>` ${(t+e).slice(0,e.length)} ${typeof s[t]}`)],o.push(`\n ${JSON.stringify(s,null,2).split("\n").join("\n ")}`))}const r=[`${e}\n`,` ${n}\n`,"Usage:",` ${t} [input.css] [OPTIONS] [-o|--output output.css]`,` ${t} ... [OPTIONS] --dir `,` ${t} ... [OPTIONS] --replace`,"\nOptions:"," -o, --output Output file"," -d, --dir Output directory"," -r, --replace Replace (overwrite) the input file"," -m, --map Create an external sourcemap"," --no-map Disable the default inline sourcemaps"," -p, --plugin-options Stringified JSON object with plugin options"];return o.length>0&&r.push(...o),()=>{console.warn(r.join("\n"))}},exports.parseArguments=parseArguments; diff --git a/packages/base-cli/package.json b/packages/base-cli/package.json index 9e5ff894c..b4559089c 100644 --- a/packages/base-cli/package.json +++ b/packages/base-cli/package.json @@ -16,20 +16,14 @@ ], "private": true, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "peerDependencies": { diff --git a/packages/cascade-layer-name-parser/CHANGELOG.md b/packages/cascade-layer-name-parser/CHANGELOG.md index 45684c4b2..2d5628e97 100644 --- a/packages/cascade-layer-name-parser/CHANGELOG.md +++ b/packages/cascade-layer-name-parser/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to Cascade Layer Name Parser +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.5 _May 27, 2025_ diff --git a/packages/cascade-layer-name-parser/dist/index.cjs b/packages/cascade-layer-name-parser/dist/index.cjs deleted file mode 100644 index 9cf3150c3..000000000 --- a/packages/cascade-layer-name-parser/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-tokenizer"),r=require("@csstools/css-parser-algorithms");class LayerName{parts;constructor(e){this.parts=e}tokens(){return[...this.parts]}slice(r,n){const t=[];for(let r=0;re.isTokenIdent(r)||e.isTokenDelim(r)),n,...r.parts.filter(r=>e.isTokenIdent(r)||e.isTokenDelim(r))])}segments(){return this.parts.filter(r=>e.isTokenIdent(r)).map(e=>e[4].value)}name(){return this.parts.filter(r=>e.isTokenIdent(r)||e.isTokenDelim(r)).map(e=>e[1]).join("")}equal(e){const r=this.segments(),n=e.segments();if(r.length!==n.length)return!1;for(let e=0;e{}),o=["6.4.2. Layer Naming and Nesting","Layer name syntax"," = [ '.' ]*"],i=n[0][2],l=n[n.length-1][3],m=[];for(let n=0;ne.tokens());let d=!1,p=!1,u=null;for(let r=0;r{const n=r.segments();e:for(let t=0;t=o&&(a=r,o=t)}-1===a?e.push(n):e.splice(a+1,0,n)}})},exports.parse=function parse(r,n){return parseFromTokens(e.tokenize({css:r},{onParseError:n?.onParseError}),n)},exports.parseFromTokens=parseFromTokens; diff --git a/packages/cascade-layer-name-parser/package.json b/packages/cascade-layer-name-parser/package.json index 8642cb6a3..c0c111a23 100644 --- a/packages/cascade-layer-name-parser/package.json +++ b/packages/cascade-layer-name-parser/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/packages/color-helpers/CHANGELOG.md b/packages/color-helpers/CHANGELOG.md index 55933c496..84ad30787 100644 --- a/packages/color-helpers/CHANGELOG.md +++ b/packages/color-helpers/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to Color Helpers +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 5.1.0 _August 22, 2025_ diff --git a/packages/color-helpers/dist/index.cjs b/packages/color-helpers/dist/index.cjs deleted file mode 100644 index 47012b729..000000000 --- a/packages/color-helpers/dist/index.cjs +++ /dev/null @@ -1,263 +0,0 @@ -"use strict";function multiplyMatrices(t,_){return[t[0]*_[0]+t[1]*_[1]+t[2]*_[2],t[3]*_[0]+t[4]*_[1]+t[5]*_[2],t[6]*_[0]+t[7]*_[1]+t[8]*_[2]]}const t=[.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124]; -/** - * Bradford chromatic adaptation from D50 to D65 - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */function D50_to_D65(_){return multiplyMatrices(t,_)}const _=[1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371]; -/** - * Bradford chromatic adaptation from D65 to D50 - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html - */function D65_to_D50(t){return multiplyMatrices(_,t)} -/** - * @param {number} hue - Hue as degrees 0..360 - * @param {number} sat - Saturation as percentage 0..100 - * @param {number} light - Lightness as percentage 0..100 - * @return {number[]} Array of sRGB components; in-gamut colors in range [0..1] - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js - */function HSL_to_sRGB(t){let _=t[0]%360;const n=t[1]/100,o=t[2]/100;return _<0&&(_+=360),[HSL_to_sRGB_channel(0,_,n,o),HSL_to_sRGB_channel(8,_,n,o),HSL_to_sRGB_channel(4,_,n,o)]}function HSL_to_sRGB_channel(t,_,n,o){const e=(t+_/30)%12;return o-n*Math.min(o,1-o)*Math.max(-1,Math.min(e-3,9-e,1))} -/** - * @param {number} hue - Hue as degrees 0..360 - * @param {number} white - Whiteness as percentage 0..100 - * @param {number} black - Blackness as percentage 0..100 - * @return {number[]} Array of RGB components 0..1 - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js - */function HWB_to_sRGB(t){const _=t[0],n=t[1]/100,o=t[2]/100;if(n+o>=1){const t=n/(n+o);return[t,t,t]}const e=HSL_to_sRGB([_,100,50]),r=1-n-o;return[e[0]*r+n,e[1]*r+n,e[2]*r+n]} -/** - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */function LCH_to_Lab(t){const _=t[2]*Math.PI/180;return[t[0],t[1]*Math.cos(_),t[1]*Math.sin(_)]} -/** - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */function Lab_to_LCH(t){const _=180*Math.atan2(t[2],t[1])/Math.PI;return[t[0],Math.sqrt(Math.pow(t[1],2)+Math.pow(t[2],2)),_>=0?_:_+360]}const n=[.3457/.3585,1,.2958/.3585]; -/** - * Convert Lab to D50-adapted XYZ - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html - */function Lab_to_XYZ(t){const _=24389/27,o=216/24389,e=(t[0]+16)/116,r=t[1]/500+e,a=e-t[2]/200;return[(Math.pow(r,3)>o?Math.pow(r,3):(116*r-16)/_)*n[0],(t[0]>8?Math.pow((t[0]+16)/116,3):t[0]/_)*n[1],(Math.pow(a,3)>o?Math.pow(a,3):(116*a-16)/_)*n[2]]} -/** - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js - */function OKLCH_to_OKLab(t){const _=t[2]*Math.PI/180;return[t[0],t[1]*Math.cos(_),t[1]*Math.sin(_)]} -/** - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js - */function OKLab_to_OKLCH(t){const _=180*Math.atan2(t[2],t[1])/Math.PI;return[t[0],Math.sqrt(t[1]**2+t[2]**2),_>=0?_:_+360]}const o=[1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],e=[1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092]; -/** - * Given OKLab, convert to XYZ relative to D65 - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js - */ -function OKLab_to_XYZ(t){const _=multiplyMatrices(e,t);return multiplyMatrices(o,[_[0]**3,_[1]**3,_[2]**3])} -/** - * Assuming XYZ is relative to D50, convert to CIE Lab - * from CIE standard, which now defines these as a rational fraction - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */function XYZ_to_Lab(t){const _=compute_f(t[0]/n[0]),o=compute_f(t[1]/n[1]);return[116*o-16,500*(_-o),200*(o-compute_f(t[2]/n[2]))]}const r=216/24389,a=24389/27;function compute_f(t){return t>r?Math.cbrt(t):(a*t+16)/116}const i=[.819022437996703,.3619062600528904,-.1288737815209879,.0329836539323885,.9292868615863434,.0361446663506424,.0481771893596242,.2642395317527308,.6335478284694309],l=[.210454268309314,.7936177747023054,-.0040720430116193,1.9779985324311684,-2.42859224204858,.450593709617411,.0259040424655478,.7827717124575296,-.8086757549230774]; -/** - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * - * XYZ <-> LMS matrices recalculated for consistent reference white - * @see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484 - */ -function XYZ_to_OKLab(t){const _=multiplyMatrices(i,t);return multiplyMatrices(l,[Math.cbrt(_[0]),Math.cbrt(_[1]),Math.cbrt(_[2])])}const s=[30757411/17917100,-6372589/17917100,-4539589/17917100,-.666684351832489,1.616481236634939,467509/29648200,792561/44930125,-1921689/44930125,.942103121235474]; -/** - * Convert XYZ to linear-light rec2020 - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */const c=[446124/178915,-333277/357830,-72051/178915,-14852/17905,63121/35810,423/17905,11844/330415,-50337/660830,316169/330415]; -/** - * Convert XYZ to linear-light P3 - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */function XYZ_to_lin_P3(t){return multiplyMatrices(c,t)}const u=[1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452]; -/** - * Convert D50 XYZ to linear-light prophoto-rgb - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html - */const h=[1829569/896150,-506331/896150,-308931/896150,-851781/878810,1648619/878810,36519/878810,16779/1248040,-147721/1248040,1266979/1248040]; -/** - * Convert XYZ to linear-light a98-rgb - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */const m=[12831/3959,-329/214,-1974/3959,-851781/878810,1648619/878810,36519/878810,705/12673,-2585/12673,705/667]; -/** - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */function XYZ_to_lin_sRGB(t){return multiplyMatrices(m,t)} -/** - * Convert an array of linear-light rec2020 RGB in the range 0.0-1.0 - * to gamma corrected form ITU-R BT.2020-2 p.4 - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */const p=1.09929682680944,D=.018053968510807;function gam_2020_channel(t){const _=t<0?-1:1,n=Math.abs(t);return n>D?_*(p*Math.pow(n,.45)-(p-1)):4.5*t} -/** - * Convert an array of linear-light sRGB values in the range 0.0-1.0 to gamma corrected form - * Extended transfer function: - * For negative values, linear portion extends on reflection - * of axis, then uses reflected pow below that - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see https://en.wikipedia.org/wiki/SRGB - */function gam_sRGB(t){return[gam_sRGB_channel(t[0]),gam_sRGB_channel(t[1]),gam_sRGB_channel(t[2])]}function gam_sRGB_channel(t){const _=t<0?-1:1,n=Math.abs(t);return n>.0031308?_*(1.055*Math.pow(n,1/2.4)-.055):12.92*t} -/** - * Convert an array of linear-light display-p3 RGB in the range 0.0-1.0 - * to gamma corrected form - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */function gam_P3(t){return gam_sRGB(t)} -/** - * Convert an array of linear-light prophoto-rgb in the range 0.0-1.0 - * to gamma corrected form. - * Transfer curve is gamma 1.8 with a small linear portion. - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */const X=1/512;function gam_ProPhoto_channel(t){const _=t<0?-1:1,n=Math.abs(t);return n>=X?_*Math.pow(n,1/1.8):16*t} -/** - * Convert an array of linear-light a98-rgb in the range 0.0-1.0 - * to gamma corrected form. Negative values are also now accepted - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */function gam_a98rgb_channel(t){const _=t<0?-1:1,n=Math.abs(t);return _*Math.pow(n,256/563)} -/** - * Convert an array of rec2020 RGB values in the range 0.0 - 1.0 - * to linear light (un-companded) form. - * ITU-R BT.2020-2 p.4 - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */const Y=1.09929682680944,Z=.018053968510807;function lin_2020_channel(t){const _=t<0?-1:1,n=Math.abs(t);return n<4.5*Z?t/4.5:_*Math.pow((n+Y-1)/Y,1/.45)}const b=[63426534/99577255,20160776/139408157,47086771/278816314,26158966/99577255,.677998071518871,8267143/139408157,0,19567812/697040785,1.0609850577107909]; -/** - * Convert an array of linear-light rec2020 values to CIE XYZ - * using D65 (no chromatic adaptation) - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html - */ -/** - * Convert an array of of sRGB values where in-gamut values are in the range - * [0 - 1] to linear light (un-companded) form. - * Extended transfer function: - * For negative values, linear portion is extended on reflection of axis, - * then reflected power function is used. - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see https://en.wikipedia.org/wiki/SRGB - */ -function lin_sRGB(t){return[lin_sRGB_channel(t[0]),lin_sRGB_channel(t[1]),lin_sRGB_channel(t[2])]}function lin_sRGB_channel(t){const _=t<0?-1:1,n=Math.abs(t);return n<=.04045?t/12.92:_*Math.pow((n+.055)/1.055,2.4)} -/** - * Convert an array of display-p3 RGB values in the range 0.0 - 1.0 - * to linear light (un-companded) form. - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */function lin_P3(t){return lin_sRGB(t)}const g=[608311/1250200,189793/714400,198249/1000160,35783/156275,247089/357200,198249/2500400,0,32229/714400,5220557/5000800]; -/** - * Convert an array of linear-light display-p3 values to CIE XYZ - * using D65 (no chromatic adaptation) - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html - */function lin_P3_to_XYZ(t){return multiplyMatrices(g,t)} -/** - * Convert an array of prophoto-rgb values where in-gamut Colors are in the - * range [0.0 - 1.0] to linear light (un-companded) form. Transfer curve is - * gamma 1.8 with a small linear portion. Extended transfer function - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */const f=16/512;function lin_ProPhoto_channel(t){const _=t<0?-1:1,n=Math.abs(t);return n<=f?t/16:_*Math.pow(n,1.8)}const L=[.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602]; -/** - * Convert an array of linear-light prophoto-rgb values to CIE D50 XYZ. - * Matrix cannot be expressed in rational form, but is calculated to 64 bit accuracy. - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see see https://github.com/w3c/csswg-drafts/issues/7675 - */function lin_a98rgb_channel(t){const _=t<0?-1:1,n=Math.abs(t);return _*Math.pow(n,563/256)}const M=[573536/994567,263643/1420810,187206/994567,591459/1989134,6239551/9945670,374412/4972835,53769/1989134,351524/4972835,4929758/4972835]; -/** - * Convert an array of linear-light a98-rgb values to CIE XYZ - * http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html - * has greater numerical precision than section 4.3.5.3 of - * https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf - * but the values below were calculated from first principles - * from the chromaticity coordinates of R G B W - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html - * @see https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf - * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/matrixmaker.html - */const d=[506752/1228815,87881/245763,12673/70218,87098/409605,175762/245763,12673/175545,7918/409605,87881/737289,1001167/1053270]; -/** - * Convert an array of linear-light sRGB values to CIE XYZ - * using sRGB's own white, D65 (no chromatic adaptation) - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */function lin_sRGB_to_XYZ(t){return multiplyMatrices(d,t)} -/** - * Convert an array of gamma-corrected sRGB values in the 0.0 to 1.0 range to HSL. - * - * @param {Color} RGB [r, g, b] - * - Red component 0..1 - * - Green component 0..1 - * - Blue component 0..1 - * @return {number[]} Array of HSL values: Hue as degrees 0..360, Saturation and Lightness as percentages 0..100 - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * - * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/better-rgbToHsl.js - */function sRGB_to_HSL(t){const _=t[0],n=t[1],o=t[2],e=Math.max(_,n,o),r=Math.min(_,n,o),a=(r+e)/2,i=e-r;let l=Number.NaN,s=0;if(0!==Math.round(1e5*i)){const t=Math.round(1e5*a);switch(s=0===t||1e5===t?0:(e-a)/Math.min(a,1-a),e){case _:l=(n-o)/i+(n=360&&(l-=360),[l,100*s,100*a]}function sRGB_to_Hue(t){const _=t[0],n=t[1],o=t[2],e=Math.max(_,n,o),r=Math.min(_,n,o);let a=Number.NaN;const i=e-r;if(0!==i){switch(e){case _:a=(n-o)/i+(n=360&&(a-=360),a}function inGamut(t){return t[0]>=-1e-4&&t[0]<=1.0001&&t[1]>=-1e-4&&t[1]<=1.0001&&t[2]>=-1e-4&&t[2]<=1.0001}function clip(t){return[t[0]<0?0:t[0]>1?1:t[0],t[1]<0?0:t[1]>1?1:t[1],t[2]<0?0:t[2]>1?1:t[2]]} -/** - * @description Calculate deltaE OK which is the simple root sum of squares - * @param {number[]} reference - Array of OKLab values: L as 0..1, a and b as -1..1 - * @param {number[]} sample - Array of OKLab values: L as 0..1, a and b as -1..1 - * @return {number} How different a color sample is from reference - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/deltaEOK.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/deltaEOK.js - */function deltaEOK(t,_){const[n,o,e]=t,[r,a,i]=_,l=n-r,s=o-a,c=e-i;return Math.sqrt(l**2+s**2+c**2)}const B=.02,G=1e-4;function rayTraceBox(t,_){let n=1/0,o=-1/0;const e=[0,0,0];for(let r=0;r<3;r++){const a=t[r],i=_[r]-a;e[r]=i;const l=0,s=1;if(i){const t=1/i,_=(l-a)*t,e=(s-a)*t;o=Math.max(Math.min(_,e),o),n=Math.min(Math.max(_,e),n)}else if(as)return!1}return!(o>n||n<0)&&(o<0&&(o=n),!!isFinite(o)&&[t[0]+e[0]*o,t[1]+e[1]*o,t[2]+e[2]*o])}function luminance(t){const[_,n,o]=t.map(t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4));return.2126*_+.7152*n+.0722*o}exports.HSL_to_XYZ_D50=function HSL_to_XYZ_D50(t){let _=t;return _=HSL_to_sRGB(_),_=lin_sRGB(_),_=lin_sRGB_to_XYZ(_),_=D65_to_D50(_),_},exports.HWB_to_XYZ_D50=function HWB_to_XYZ_D50(t){let _=t;return _=HWB_to_sRGB(_),_=lin_sRGB(_),_=lin_sRGB_to_XYZ(_),_=D65_to_D50(_),_},exports.LCH_to_XYZ_D50=function LCH_to_XYZ_D50(t){let _=t;return _=LCH_to_Lab(_),_=Lab_to_XYZ(_),_},exports.Lab_to_XYZ_D50=function Lab_to_XYZ_D50(t){let _=t;return _=Lab_to_XYZ(_),_},exports.OKLCH_to_OKLab=OKLCH_to_OKLab,exports.OKLCH_to_XYZ_D50=function OKLCH_to_XYZ_D50(t){let _=t;return _=OKLCH_to_OKLab(_),_=OKLab_to_XYZ(_),_=D65_to_D50(_),_},exports.OKLab_to_OKLCH=OKLab_to_OKLCH,exports.OKLab_to_XYZ=OKLab_to_XYZ,exports.OKLab_to_XYZ_D50=function OKLab_to_XYZ_D50(t){let _=t;return _=OKLab_to_XYZ(_),_=D65_to_D50(_),_},exports.P3_to_XYZ_D50=function P3_to_XYZ_D50(t){let _=t;return _=lin_P3(_),_=lin_P3_to_XYZ(_),_=D65_to_D50(_),_},exports.ProPhoto_RGB_to_XYZ_D50=function ProPhoto_RGB_to_XYZ_D50(t){let _=t;var n;return _=[lin_ProPhoto_channel((n=_)[0]),lin_ProPhoto_channel(n[1]),lin_ProPhoto_channel(n[2])],_=multiplyMatrices(L,_),_},exports.XYZ_D50_to_HSL=function XYZ_D50_to_HSL(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_sRGB(_),_=gam_sRGB(_),_=sRGB_to_HSL(_),_},exports.XYZ_D50_to_HWB=function XYZ_D50_to_HWB(t){let _=t;_=D50_to_D65(_),_=XYZ_to_lin_sRGB(_);const n=gam_sRGB(_),o=Math.min(n[0],n[1],n[2]),e=1-Math.max(n[0],n[1],n[2]);return[sRGB_to_Hue(n),100*o,100*e]},exports.XYZ_D50_to_LCH=function XYZ_D50_to_LCH(t){let _=t;return _=XYZ_to_Lab(_),_=Lab_to_LCH(_),_},exports.XYZ_D50_to_Lab=function XYZ_D50_to_Lab(t){let _=t;return _=XYZ_to_Lab(_),_},exports.XYZ_D50_to_OKLCH=function XYZ_D50_to_OKLCH(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_OKLab(_),_=OKLab_to_OKLCH(_),_},exports.XYZ_D50_to_OKLab=function XYZ_D50_to_OKLab(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_OKLab(_),_},exports.XYZ_D50_to_P3=function XYZ_D50_to_P3(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_P3(_),_=gam_P3(_),_},exports.XYZ_D50_to_ProPhoto=function XYZ_D50_to_ProPhoto(t){let _=t;var n;return _=multiplyMatrices(u,_),_=[gam_ProPhoto_channel((n=_)[0]),gam_ProPhoto_channel(n[1]),gam_ProPhoto_channel(n[2])],_},exports.XYZ_D50_to_XYZ_D50=function XYZ_D50_to_XYZ_D50(t){return t},exports.XYZ_D50_to_XYZ_D65=function XYZ_D50_to_XYZ_D65(t){let _=t;return _=D50_to_D65(_),_},exports.XYZ_D50_to_a98_RGB=function XYZ_D50_to_a98_RGB(t){let _=t;var n;return _=D50_to_D65(_),_=multiplyMatrices(h,_),_=[gam_a98rgb_channel((n=_)[0]),gam_a98rgb_channel(n[1]),gam_a98rgb_channel(n[2])],_},exports.XYZ_D50_to_lin_P3=function XYZ_D50_to_lin_P3(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_P3(_),_},exports.XYZ_D50_to_lin_sRGB=function XYZ_D50_to_lin_sRGB(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_sRGB(_),_},exports.XYZ_D50_to_rec_2020=function XYZ_D50_to_rec_2020(t){let _=t;var n;return _=D50_to_D65(_),_=multiplyMatrices(s,_),_=[gam_2020_channel((n=_)[0]),gam_2020_channel(n[1]),gam_2020_channel(n[2])],_},exports.XYZ_D50_to_sRGB=function XYZ_D50_to_sRGB(t){let _=t;return _=D50_to_D65(_),_=XYZ_to_lin_sRGB(_),_=gam_sRGB(_),_},exports.XYZ_D65_to_XYZ_D50=function XYZ_D65_to_XYZ_D50(t){let _=t;return _=D65_to_D50(_),_},exports.XYZ_to_OKLab=XYZ_to_OKLab,exports.XYZ_to_lin_P3=XYZ_to_lin_P3,exports.XYZ_to_lin_sRGB=XYZ_to_lin_sRGB,exports.a98_RGB_to_XYZ_D50=function a98_RGB_to_XYZ_D50(t){let _=t; -/** - * Convert an array of a98-rgb values in the range 0.0 - 1.0 - * to linear light (un-companded) form. Negative values are also now accepted - * - * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document - * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang). - */ -var n;return _=[lin_a98rgb_channel((n=_)[0]),lin_a98rgb_channel(n[1]),lin_a98rgb_channel(n[2])],_=multiplyMatrices(M,_),_=D65_to_D50(_),_},exports.clip=clip,exports.contrast_ratio_wcag_2_1=function contrast_ratio_wcag_2_1(t,_){const n=luminance(t),o=luminance(_);return(Math.max(n,o)+.05)/(Math.min(n,o)+.05)},exports.gam_P3=gam_P3,exports.gam_sRGB=gam_sRGB,exports.inGamut=inGamut,exports.lin_P3=lin_P3,exports.lin_P3_to_XYZ=lin_P3_to_XYZ,exports.lin_P3_to_XYZ_D50=function lin_P3_to_XYZ_D50(t){let _=t;return _=lin_P3_to_XYZ(_),_=D65_to_D50(_),_},exports.lin_sRGB=lin_sRGB,exports.lin_sRGB_to_XYZ=lin_sRGB_to_XYZ,exports.lin_sRGB_to_XYZ_D50=function lin_sRGB_to_XYZ_D50(t){let _=t;return _=lin_sRGB_to_XYZ(_),_=D65_to_D50(_),_},exports.mapGamut=function mapGamut(t,_,n){const o=t;let e=clip(_(o)),r=deltaEOK(OKLCH_to_OKLab(n(e)),OKLCH_to_OKLab(o));if(rG;){const t=(a+i)/2;if(o[1]=t,l&&inGamut(_(o)))a=t;else if(e=clip(_(o)),r=deltaEOK(OKLCH_to_OKLab(n(e)),OKLCH_to_OKLab(o)),r0){const t=n(r);t[0]=o,t[2]=e,r=_(t)}const i=rayTraceBox(a,r);if(!i)break;r=i}return clip(r)},exports.namedColors={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},exports.rec_2020_to_XYZ_D50=function rec_2020_to_XYZ_D50(t){let _=t;var n;return _=[lin_2020_channel((n=_)[0]),lin_2020_channel(n[1]),lin_2020_channel(n[2])],_=multiplyMatrices(b,_),_=D65_to_D50(_),_},exports.sRGB_to_XYZ_D50=function sRGB_to_XYZ_D50(t){let _=t;return _=lin_sRGB(_),_=lin_sRGB_to_XYZ(_),_=D65_to_D50(_),_}; diff --git a/packages/color-helpers/package.json b/packages/color-helpers/package.json index fcee4fda5..7c6e689c6 100644 --- a/packages/color-helpers/package.json +++ b/packages/color-helpers/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/packages/css-calc/CHANGELOG.md b/packages/css-calc/CHANGELOG.md index 634677f7b..7c97d2edf 100644 --- a/packages/css-calc/CHANGELOG.md +++ b/packages/css-calc/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to CSS Calc +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.1.4 _May 27, 2025_ diff --git a/packages/css-calc/dist/index.cjs b/packages/css-calc/dist/index.cjs deleted file mode 100644 index 032b35934..000000000 --- a/packages/css-calc/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-parser-algorithms"),n=require("@csstools/css-tokenizer");const t=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(t,e=>String.fromCharCode(e.charCodeAt(0)+32))}const o={cm:"px",in:"px",mm:"px",pc:"px",pt:"px",px:"px",q:"px",deg:"deg",grad:"deg",rad:"deg",turn:"deg",ms:"s",s:"s",hz:"hz",khz:"hz"},r=new Map([["cm",e=>e],["mm",e=>10*e],["q",e=>40*e],["in",e=>e/2.54],["pc",e=>e/2.54*6],["pt",e=>e/2.54*72],["px",e=>e/2.54*96]]),i=new Map([["deg",e=>e],["grad",e=>e/.9],["rad",e=>e/180*Math.PI],["turn",e=>e/360]]),u=new Map([["deg",e=>.9*e],["grad",e=>e],["rad",e=>.9*e/180*Math.PI],["turn",e=>.9*e/360]]),a=new Map([["hz",e=>e],["khz",e=>e/1e3]]),s=new Map([["cm",e=>2.54*e],["mm",e=>25.4*e],["q",e=>25.4*e*4],["in",e=>e],["pc",e=>6*e],["pt",e=>72*e],["px",e=>96*e]]),l=new Map([["hz",e=>1e3*e],["khz",e=>e]]),c=new Map([["cm",e=>e/10],["mm",e=>e],["q",e=>4*e],["in",e=>e/25.4],["pc",e=>e/25.4*6],["pt",e=>e/25.4*72],["px",e=>e/25.4*96]]),m=new Map([["ms",e=>e],["s",e=>e/1e3]]),v=new Map([["cm",e=>e/6*2.54],["mm",e=>e/6*25.4],["q",e=>e/6*25.4*4],["in",e=>e/6],["pc",e=>e],["pt",e=>e/6*72],["px",e=>e/6*96]]),T=new Map([["cm",e=>e/72*2.54],["mm",e=>e/72*25.4],["q",e=>e/72*25.4*4],["in",e=>e/72],["pc",e=>e/72*6],["pt",e=>e],["px",e=>e/72*96]]),p=new Map([["cm",e=>e/96*2.54],["mm",e=>e/96*25.4],["q",e=>e/96*25.4*4],["in",e=>e/96],["pc",e=>e/96*6],["pt",e=>e/96*72],["px",e=>e]]),N=new Map([["cm",e=>e/4/10],["mm",e=>e/4],["q",e=>e],["in",e=>e/4/25.4],["pc",e=>e/4/25.4*6],["pt",e=>e/4/25.4*72],["px",e=>e/4/25.4*96]]),f=new Map([["deg",e=>180*e/Math.PI],["grad",e=>180*e/Math.PI/.9],["rad",e=>e],["turn",e=>180*e/Math.PI/360]]),d=new Map([["ms",e=>1e3*e],["s",e=>e]]),k=new Map([["deg",e=>360*e],["grad",e=>360*e/.9],["rad",e=>360*e/180*Math.PI],["turn",e=>e]]),C=new Map([["cm",r],["mm",c],["q",N],["in",s],["pc",v],["pt",T],["px",p],["ms",m],["s",d],["deg",i],["grad",u],["rad",f],["turn",k],["hz",a],["khz",l]]);function convertUnit(e,t){if(!n.isTokenDimension(e))return t;if(!n.isTokenDimension(t))return t;const o=toLowerCaseAZ(e[4].unit),r=toLowerCaseAZ(t[4].unit);if(o===r)return t;const i=C.get(r);if(!i)return t;const u=i.get(o);if(!u)return t;const a=u(t[4].value),s=[n.TokenType.Dimension,"",t[2],t[3],{...t[4],signCharacter:a<0?"-":void 0,type:Number.isInteger(a)?n.NumberType.Integer:n.NumberType.Number,value:a}];return n.mutateUnit(s,e[4].unit),s}function toCanonicalUnit(e){if(!n.isTokenDimension(e))return e;const t=toLowerCaseAZ(e[4].unit),r=o[t];if(t===r)return e;const i=C.get(t);if(!i)return e;const u=i.get(r);if(!u)return e;const a=u(e[4].value),s=[n.TokenType.Dimension,"",e[2],e[3],{...e[4],signCharacter:a<0?"-":void 0,type:Number.isInteger(a)?n.NumberType.Integer:n.NumberType.Number,value:a}];return n.mutateUnit(s,r),s}function addition(t){if(2!==t.length)return-1;const o=t[0].value;let r=t[1].value;if(n.isTokenNumber(o)&&n.isTokenNumber(r)){const t=o[4].value+r[4].value;return new e.TokenNode([n.TokenType.Number,t.toString(),o[2],r[3],{value:t,type:o[4].type===n.NumberType.Integer&&r[4].type===n.NumberType.Integer?n.NumberType.Integer:n.NumberType.Number}])}if(n.isTokenPercentage(o)&&n.isTokenPercentage(r)){const t=o[4].value+r[4].value;return new e.TokenNode([n.TokenType.Percentage,t.toString()+"%",o[2],r[3],{value:t}])}if(n.isTokenDimension(o)&&n.isTokenDimension(r)&&(r=convertUnit(o,r),toLowerCaseAZ(o[4].unit)===toLowerCaseAZ(r[4].unit))){const t=o[4].value+r[4].value;return new e.TokenNode([n.TokenType.Dimension,t.toString()+o[4].unit,o[2],r[3],{value:t,type:o[4].type===n.NumberType.Integer&&r[4].type===n.NumberType.Integer?n.NumberType.Integer:n.NumberType.Number,unit:o[4].unit}])}return-1}function division(t){if(2!==t.length)return-1;const o=t[0].value,r=t[1].value;if(n.isTokenNumber(o)&&n.isTokenNumber(r)){const t=o[4].value/r[4].value;return new e.TokenNode([n.TokenType.Number,t.toString(),o[2],r[3],{value:t,type:Number.isInteger(t)?n.NumberType.Integer:n.NumberType.Number}])}if(n.isTokenPercentage(o)&&n.isTokenNumber(r)){const t=o[4].value/r[4].value;return new e.TokenNode([n.TokenType.Percentage,t.toString()+"%",o[2],r[3],{value:t}])}if(n.isTokenDimension(o)&&n.isTokenNumber(r)){const t=o[4].value/r[4].value;return new e.TokenNode([n.TokenType.Dimension,t.toString()+o[4].unit,o[2],r[3],{value:t,type:Number.isInteger(t)?n.NumberType.Integer:n.NumberType.Number,unit:o[4].unit}])}return-1}function isCalculation(e){return!!e&&"object"==typeof e&&"inputs"in e&&Array.isArray(e.inputs)&&"operation"in e}function solve(n){if(-1===n)return-1;const t=[];for(let o=0;oconvertUnit(i,e.value));if(!arrayOfSameNumeric(u))return-1;const a=u.map(e=>e[4].value),s=Math.hypot(...a);return resultToCalculation(t,i,s)}function solveMax(t,o,r){if(!o.every(e.isTokenNode))return-1;const i=o[0].value;if(!n.isTokenNumeric(i))return-1;if(!r.rawPercentages&&n.isTokenPercentage(i))return-1;const u=o.map(e=>convertUnit(i,e.value));if(!arrayOfSameNumeric(u))return-1;const a=u.map(e=>e[4].value),s=Math.max(...a);return resultToCalculation(t,i,s)}function solveMin(t,o,r){if(!o.every(e.isTokenNode))return-1;const i=o[0].value;if(!n.isTokenNumeric(i))return-1;if(!r.rawPercentages&&n.isTokenPercentage(i))return-1;const u=o.map(e=>convertUnit(i,e.value));if(!arrayOfSameNumeric(u))return-1;const a=u.map(e=>e[4].value),s=Math.min(...a);return resultToCalculation(t,i,s)}function solveMod(e,t,o){const r=t.value;if(!n.isTokenNumeric(r))return-1;const i=convertUnit(r,o.value);if(!twoOfSameNumeric(r,i))return-1;let u;return u=0===i[4].value?Number.NaN:Number.isFinite(r[4].value)&&(Number.isFinite(i[4].value)||(i[4].value!==Number.POSITIVE_INFINITY||r[4].value!==Number.NEGATIVE_INFINITY&&!Object.is(0*r[4].value,-0))&&(i[4].value!==Number.NEGATIVE_INFINITY||r[4].value!==Number.POSITIVE_INFINITY&&!Object.is(0*r[4].value,0)))?Number.isFinite(i[4].value)?(r[4].value%i[4].value+i[4].value)%i[4].value:r[4].value:Number.NaN,resultToCalculation(e,r,u)}function solvePow(e,t,o){const r=t.value,i=o.value;if(!n.isTokenNumber(r))return-1;if(!twoOfSameNumeric(r,i))return-1;return numberToCalculation(e,Math.pow(r[4].value,i[4].value))}function solveRem(e,t,o){const r=t.value;if(!n.isTokenNumeric(r))return-1;const i=convertUnit(r,o.value);if(!twoOfSameNumeric(r,i))return-1;let u;return u=0===i[4].value?Number.NaN:Number.isFinite(r[4].value)?Number.isFinite(i[4].value)?r[4].value%i[4].value:r[4].value:Number.NaN,resultToCalculation(e,r,u)}function solveRound(e,t,o,r,i){const u=o.value;if(!n.isTokenNumeric(u))return-1;if(!i.rawPercentages&&n.isTokenPercentage(u))return-1;const a=convertUnit(u,r.value);if(!twoOfSameNumeric(u,a))return-1;let s;if(0===a[4].value)s=Number.NaN;else if(Number.isFinite(u[4].value)||Number.isFinite(a[4].value))if(!Number.isFinite(u[4].value)&&Number.isFinite(a[4].value))s=u[4].value;else if(Number.isFinite(u[4].value)&&!Number.isFinite(a[4].value))switch(t){case"down":s=u[4].value<0?-1/0:Object.is(-0,0*u[4].value)?-0:0;break;case"up":s=u[4].value>0?1/0:Object.is(0,0*u[4].value)?0:-0;break;default:s=Object.is(0,0*u[4].value)?0:-0}else if(Number.isFinite(a[4].value))switch(t){case"down":s=Math.floor(u[4].value/a[4].value)*a[4].value;break;case"up":s=Math.ceil(u[4].value/a[4].value)*a[4].value;break;case"to-zero":s=Math.trunc(u[4].value/a[4].value)*a[4].value;break;default:{let e=Math.floor(u[4].value/a[4].value)*a[4].value,n=Math.ceil(u[4].value/a[4].value)*a[4].value;if(e>n){const t=e;e=n,n=t}const t=Math.abs(u[4].value-e),o=Math.abs(u[4].value-n);s=t===o?n:t0?1/0:-1/0:Math.tan(s),numberToCalculation(e,s)}function subtraction(t){if(2!==t.length)return-1;const o=t[0].value;let r=t[1].value;if(n.isTokenNumber(o)&&n.isTokenNumber(r)){const t=o[4].value-r[4].value;return new e.TokenNode([n.TokenType.Number,t.toString(),o[2],r[3],{value:t,type:o[4].type===n.NumberType.Integer&&r[4].type===n.NumberType.Integer?n.NumberType.Integer:n.NumberType.Number}])}if(n.isTokenPercentage(o)&&n.isTokenPercentage(r)){const t=o[4].value-r[4].value;return new e.TokenNode([n.TokenType.Percentage,t.toString()+"%",o[2],r[3],{value:t}])}if(n.isTokenDimension(o)&&n.isTokenDimension(r)&&(r=convertUnit(o,r),toLowerCaseAZ(o[4].unit)===toLowerCaseAZ(r[4].unit))){const t=o[4].value-r[4].value;return new e.TokenNode([n.TokenType.Dimension,t.toString()+o[4].unit,o[2],r[3],{value:t,type:o[4].type===n.NumberType.Integer&&r[4].type===n.NumberType.Integer?n.NumberType.Integer:n.NumberType.Number,unit:o[4].unit}])}return-1}function solveLog(t,o){if(1===o.length){const r=o[0];if(!r||!e.isTokenNode(r))return-1;const i=r.value;if(!n.isTokenNumber(i))return-1;return numberToCalculation(t,Math.log(i[4].value))}if(2===o.length){const r=o[0];if(!r||!e.isTokenNode(r))return-1;const i=r.value;if(!n.isTokenNumber(i))return-1;const u=o[1];if(!u||!e.isTokenNode(u))return-1;const a=u.value;if(!n.isTokenNumber(a))return-1;return numberToCalculation(t,Math.log(i[4].value)/Math.log(a[4].value))}return-1}const g=/^none$/i;function isNone(t){if(Array.isArray(t)){const n=t.filter(n=>!(e.isWhitespaceNode(n)&&e.isCommentNode(n)));return 1===n.length&&isNone(n[0])}if(!e.isTokenNode(t))return!1;const o=t.value;return!!n.isTokenIdent(o)&&g.test(o[4].value)}const D=String.fromCodePoint(0);function solveRandom(e,t,o,r,i,u){if(-1===t.fixed&&!u.randomCaching)return-1;u.randomCaching||(u.randomCaching={propertyName:"",propertyN:0,elementID:"",documentID:""}),u.randomCaching&&!u.randomCaching.propertyN&&(u.randomCaching.propertyN=0);const a=o.value;if(!n.isTokenNumeric(a))return-1;const s=convertUnit(a,r.value);if(!twoOfSameNumeric(a,s))return-1;let l=null;if(i&&(l=convertUnit(a,i.value),!twoOfSameNumeric(a,l)))return-1;if(!Number.isFinite(a[4].value))return resultToCalculation(e,a,Number.NaN);if(!Number.isFinite(s[4].value))return resultToCalculation(e,a,Number.NaN);if(!Number.isFinite(s[4].value-a[4].value))return resultToCalculation(e,a,Number.NaN);if(l&&!Number.isFinite(l[4].value))return resultToCalculation(e,a,a[4].value);const c=-1===t.fixed?sfc32(crc32([t.dashedIdent?t.dashedIdent:`${u.randomCaching?.propertyName} ${u.randomCaching.propertyN++}`,t.elementShared?"":u.randomCaching.elementID,u.randomCaching.documentID].join(D))):()=>t.fixed;let m=a[4].value,v=s[4].value;if(m>v&&([m,v]=[v,m]),l&&(l[4].value<=0||Math.abs(m-v)/l[4].value>1e10)&&(l=null),l){const n=Math.max(l[4].value/1e3,1e-9),t=[m];let o=0;for(;;){o+=l[4].value;const e=m+o;if(!(e+nv)break}const r=c();return resultToCalculation(e,a,Number(t[Math.floor(t.length*r)].toFixed(5)))}const T=c();return resultToCalculation(e,a,Number((T*(v-m)+m).toFixed(5)))}function sfc32(e=.34944106645296036,n=.19228640875738723,t=.8784393832007205,o=.04850964319275053){return()=>{const r=((e|=0)+(n|=0)|0)+(o|=0)|0;return o=o+1|0,e=n^n>>>9,n=(t|=0)+(t<<3)|0,t=(t=t<<21|t>>>11)+r|0,(r>>>0)/4294967296}}function crc32(e){let n=0,t=0,o=0;n^=-1;for(let r=0,i=e.length;r>>8^t;return(-1^n)>>>0}const b=new Map([["abs",function abs(e,n,t){return singleNodeSolver(e,n,t,solveAbs)}],["acos",function acos(e,n,t){return singleNodeSolver(e,n,t,solveACos)}],["asin",function asin(e,n,t){return singleNodeSolver(e,n,t,solveASin)}],["atan",function atan(e,n,t){return singleNodeSolver(e,n,t,solveATan)}],["atan2",function atan2(e,n,t){return twoCommaSeparatedNodesSolver(e,n,t,solveATan2)}],["calc",calc$1],["clamp",function clamp(t,o,r){const i=resolveGlobalsAndConstants([...t.value.filter(n=>!e.isWhiteSpaceOrCommentNode(n))],o),u=[],a=[],s=[];{let t=u;for(let o=0;o!e.isWhiteSpaceOrCommentNode(n)),t,o);if(-1===r)return-1;const[i,u]=r,a=variadicArguments(u,t,o);if(-1===a)return-1;const[s,l,c]=a;if(!s||!l)return-1;return solveRandom(n,i,s,l,c,o)}],["rem",function rem(e,n,t){return twoCommaSeparatedNodesSolver(e,n,t,solveRem)}],["round",function round(t,o,r){const i=resolveGlobalsAndConstants([...t.value.filter(n=>!e.isWhiteSpaceOrCommentNode(n))],o);let u="",a=!1;const s=[],l=[];{let t=s;for(let o=0;o!e.isWhiteSpaceOrCommentNode(n))],o);if(1===i.length&&e.isTokenNode(i[0]))return{inputs:[i[0]],operation:unary};let u=0;for(;u!e.isWhiteSpaceOrCommentNode(n))],t)),t,o));return-1===r?-1:r}function twoCommaSeparatedNodesSolver(e,n,t,o){const r=twoCommaSeparatedArguments(e.value,n,t);if(-1===r)return-1;const[i,u]=r;return o(e,i,u,t)}function twoCommaSeparatedArguments(t,o,r){const i=resolveGlobalsAndConstants([...t.filter(n=>!e.isWhiteSpaceOrCommentNode(n))],o),u=[],a=[];{let t=u;for(let o=0;o!e.isWhiteSpaceOrCommentNode(n))],o),u=[];{const t=[];let a=[];for(let o=0;o1)return-1;i.fixed=Math.max(0,Math.min(a.value[4].value,1-1e-9));continue}if("auto"!==s)if(s.startsWith("--")){if(-1!==i.fixed||i.isAuto)return-1;i.dashedIdent=s}else;else{if(-1!==i.fixed||i.dashedIdent)return-1;i.isAuto=!0}}else{if(-1!==i.fixed)return-1;i.elementShared=!0}}return-1}function calcWrapper(t){return new e.FunctionNode([n.TokenType.Function,"calc(",-1,-1,{value:"calc"}],[n.TokenType.CloseParen,")",-1,-1,void 0],t)}function maxWrapper(t,o){return new e.FunctionNode([n.TokenType.Function,"max(",-1,-1,{value:"max"}],[n.TokenType.CloseParen,")",-1,-1,void 0],[t,new e.TokenNode([n.TokenType.Comma,",",-1,-1,void 0]),o])}function patchNaN(t){if(-1===t)return-1;if(e.isFunctionNode(t))return t;const o=t.value;return n.isTokenNumeric(o)&&Number.isNaN(o[4].value)?n.isTokenNumber(o)?new e.FunctionNode([n.TokenType.Function,"calc(",o[2],o[3],{value:"calc"}],[n.TokenType.CloseParen,")",o[2],o[3],void 0],[new e.TokenNode([n.TokenType.Ident,"NaN",o[2],o[3],{value:"NaN"}])]):n.isTokenDimension(o)?new e.FunctionNode([n.TokenType.Function,"calc(",o[2],o[3],{value:"calc"}],[n.TokenType.CloseParen,")",o[2],o[3],void 0],[new e.TokenNode([n.TokenType.Ident,"NaN",o[2],o[3],{value:"NaN"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",o[2],o[3],void 0]]),new e.TokenNode([n.TokenType.Delim,"*",o[2],o[3],{value:"*"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",o[2],o[3],void 0]]),new e.TokenNode([n.TokenType.Dimension,"1"+o[4].unit,o[2],o[3],{value:1,type:n.NumberType.Integer,unit:o[4].unit}])]):n.isTokenPercentage(o)?new e.FunctionNode([n.TokenType.Function,"calc(",o[2],o[3],{value:"calc"}],[n.TokenType.CloseParen,")",o[2],o[3],void 0],[new e.TokenNode([n.TokenType.Ident,"NaN",o[2],o[3],{value:"NaN"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",o[2],o[3],void 0]]),new e.TokenNode([n.TokenType.Delim,"*",o[2],o[3],{value:"*"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",o[2],o[3],void 0]]),new e.TokenNode([n.TokenType.Percentage,"1%",o[2],o[3],{value:1}])]):-1:t}function patchInfinity(t){if(-1===t)return-1;if(e.isFunctionNode(t))return t;const o=t.value;if(!n.isTokenNumeric(o))return t;if(Number.isFinite(o[4].value)||Number.isNaN(o[4].value))return t;let r="";return Number.NEGATIVE_INFINITY===o[4].value&&(r="-"),n.isTokenNumber(o)?new e.FunctionNode([n.TokenType.Function,"calc(",o[2],o[3],{value:"calc"}],[n.TokenType.CloseParen,")",o[2],o[3],void 0],[new e.TokenNode([n.TokenType.Ident,r+"infinity",o[2],o[3],{value:r+"infinity"}])]):n.isTokenDimension(o)?new e.FunctionNode([n.TokenType.Function,"calc(",o[2],o[3],{value:"calc"}],[n.TokenType.CloseParen,")",o[2],o[3],void 0],[new e.TokenNode([n.TokenType.Ident,r+"infinity",o[2],o[3],{value:r+"infinity"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",o[2],o[3],void 0]]),new e.TokenNode([n.TokenType.Delim,"*",o[2],o[3],{value:"*"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",o[2],o[3],void 0]]),new e.TokenNode([n.TokenType.Dimension,"1"+o[4].unit,o[2],o[3],{value:1,type:n.NumberType.Integer,unit:o[4].unit}])]):new e.FunctionNode([n.TokenType.Function,"calc(",o[2],o[3],{value:"calc"}],[n.TokenType.CloseParen,")",o[2],o[3],void 0],[new e.TokenNode([n.TokenType.Ident,r+"infinity",o[2],o[3],{value:r+"infinity"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",o[2],o[3],void 0]]),new e.TokenNode([n.TokenType.Delim,"*",o[2],o[3],{value:"*"}]),new e.WhitespaceNode([[n.TokenType.Whitespace," ",o[2],o[3],void 0]]),new e.TokenNode([n.TokenType.Percentage,"1%",o[2],o[3],{value:1}])])}function patchMinusZero(t){if(-1===t)return-1;if(e.isFunctionNode(t))return t;const o=t.value;return n.isTokenNumeric(o)&&Object.is(-0,o[4].value)?("-0"===o[1]||(n.isTokenPercentage(o)?o[1]="-0%":n.isTokenDimension(o)?o[1]="-0"+o[4].unit:o[1]="-0"),t):t}function patchPrecision(t,o=13){if(-1===t)return-1;if(o<=0)return t;if(e.isFunctionNode(t))return t;const r=t.value;if(!n.isTokenNumeric(r))return t;if(Number.isInteger(r[4].value))return t;const i=Number(r[4].value.toFixed(o)).toString();return n.isTokenNumber(r)?r[1]=i:n.isTokenPercentage(r)?r[1]=i+"%":n.isTokenDimension(r)&&(r[1]=i+r[4].unit),t}function patchCanonicalUnit(t){return-1===t?-1:e.isFunctionNode(t)?t:n.isTokenDimension(t.value)?(t.value=toCanonicalUnit(t.value),t):t}function patchCalcResult(e,n){let t=e;return n?.toCanonicalUnits&&(t=patchCanonicalUnit(t)),t=patchPrecision(t,n?.precision),t=patchMinusZero(t),n?.censorIntoStandardRepresentableValues||(t=patchNaN(t),t=patchInfinity(t)),t}function tokenizeGlobals(e){const t=new Map;if(!e)return t;for(const[o,r]of e)if(n.isToken(r))t.set(o,r);else if("string"==typeof r){const e=n.tokenizer({css:r}),i=e.nextToken();if(e.nextToken(),!e.endOfFile())continue;if(!n.isTokenNumeric(i))continue;t.set(o,i);continue}return t}function calcFromComponentValues(n,t){const o=tokenizeGlobals(t?.globals);return e.replaceComponentValues(n,n=>{if(!e.isFunctionNode(n))return;const r=b.get(n.getName().toLowerCase());if(!r)return;const i=patchCalcResult(solve(r(n,o,t??{})),t);return-1!==i?i:void 0})}const h=new Set(b.keys());exports.calc=function calc(t,o){return calcFromComponentValues(e.parseCommaSeparatedListOfComponentValues(n.tokenize({css:t}),{}),o).map(e=>e.map(e=>n.stringify(...e.tokens())).join("")).join(",")},exports.calcFromComponentValues=calcFromComponentValues,exports.mathFunctionNames=h; diff --git a/packages/css-calc/package.json b/packages/css-calc/package.json index 761621e2a..106355a20 100644 --- a/packages/css-calc/package.json +++ b/packages/css-calc/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/packages/css-color-parser/CHANGELOG.md b/packages/css-color-parser/CHANGELOG.md index 144d4d9e8..3814e8ccc 100644 --- a/packages/css-color-parser/CHANGELOG.md +++ b/packages/css-color-parser/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to CSS Color Parser +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.1.0 _August 22, 2025_ diff --git a/packages/css-color-parser/dist/index.cjs b/packages/css-color-parser/dist/index.cjs deleted file mode 100644 index cc198f632..000000000 --- a/packages/css-color-parser/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e,o,a=require("@csstools/css-tokenizer"),n=require("@csstools/color-helpers"),t=require("@csstools/css-parser-algorithms"),r=require("@csstools/css-calc");function convertNaNToZero(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function colorData_to_XYZ_D50(e){switch(e.colorNotation){case exports.ColorNotation.HEX:case exports.ColorNotation.RGB:case exports.ColorNotation.sRGB:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.sRGB_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.Linear_sRGB:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.lin_sRGB_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.Display_P3:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.P3_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.Linear_Display_P3:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.lin_P3_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.Rec2020:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.rec_2020_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.A98_RGB:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.a98_RGB_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.ProPhoto_RGB:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.ProPhoto_RGB_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.HSL:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.HSL_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.HWB:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.HWB_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.Lab:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.Lab_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.OKLab:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.OKLab_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.LCH:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.LCH_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.OKLCH:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.OKLCH_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.XYZ_D50:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.XYZ_D50_to_XYZ_D50(convertNaNToZero(e.channels))};case exports.ColorNotation.XYZ_D65:return{...e,colorNotation:exports.ColorNotation.XYZ_D50,channels:n.XYZ_D65_to_XYZ_D50(convertNaNToZero(e.channels))};default:throw new Error("Unsupported color notation")}}exports.ColorNotation=void 0,(e=exports.ColorNotation||(exports.ColorNotation={})).A98_RGB="a98-rgb",e.Display_P3="display-p3",e.Linear_Display_P3="display-p3-linear",e.HEX="hex",e.HSL="hsl",e.HWB="hwb",e.LCH="lch",e.Lab="lab",e.Linear_sRGB="srgb-linear",e.OKLCH="oklch",e.OKLab="oklab",e.ProPhoto_RGB="prophoto-rgb",e.RGB="rgb",e.sRGB="srgb",e.Rec2020="rec2020",e.XYZ_D50="xyz-d50",e.XYZ_D65="xyz-d65",exports.SyntaxFlag=void 0,(o=exports.SyntaxFlag||(exports.SyntaxFlag={})).ColorKeyword="color-keyword",o.HasAlpha="has-alpha",o.HasDimensionValues="has-dimension-values",o.HasNoneKeywords="has-none-keywords",o.HasNumberValues="has-number-values",o.HasPercentageAlpha="has-percentage-alpha",o.HasPercentageValues="has-percentage-values",o.HasVariableAlpha="has-variable-alpha",o.Hex="hex",o.LegacyHSL="legacy-hsl",o.LegacyRGB="legacy-rgb",o.NamedColor="named-color",o.RelativeColorSyntax="relative-color-syntax",o.ColorMix="color-mix",o.ColorMixVariadic="color-mix-variadic",o.ContrastColor="contrast-color",o.RelativeAlphaSyntax="relative-alpha-syntax",o.Experimental="experimental";const l=new Set([exports.ColorNotation.A98_RGB,exports.ColorNotation.Display_P3,exports.ColorNotation.Linear_Display_P3,exports.ColorNotation.HEX,exports.ColorNotation.Linear_sRGB,exports.ColorNotation.ProPhoto_RGB,exports.ColorNotation.RGB,exports.ColorNotation.sRGB,exports.ColorNotation.Rec2020,exports.ColorNotation.XYZ_D50,exports.ColorNotation.XYZ_D65]);function colorDataTo(e,o){const a={...e};if(e.colorNotation!==o){const e=colorData_to_XYZ_D50(a);switch(o){case exports.ColorNotation.HEX:case exports.ColorNotation.RGB:a.colorNotation=exports.ColorNotation.RGB,a.channels=n.XYZ_D50_to_sRGB(e.channels);break;case exports.ColorNotation.sRGB:a.colorNotation=exports.ColorNotation.sRGB,a.channels=n.XYZ_D50_to_sRGB(e.channels);break;case exports.ColorNotation.Linear_sRGB:a.colorNotation=exports.ColorNotation.Linear_sRGB,a.channels=n.XYZ_D50_to_lin_sRGB(e.channels);break;case exports.ColorNotation.Display_P3:a.colorNotation=exports.ColorNotation.Display_P3,a.channels=n.XYZ_D50_to_P3(e.channels);break;case exports.ColorNotation.Linear_Display_P3:a.colorNotation=exports.ColorNotation.Linear_Display_P3,a.channels=n.XYZ_D50_to_lin_P3(e.channels);break;case exports.ColorNotation.Rec2020:a.colorNotation=exports.ColorNotation.Rec2020,a.channels=n.XYZ_D50_to_rec_2020(e.channels);break;case exports.ColorNotation.ProPhoto_RGB:a.colorNotation=exports.ColorNotation.ProPhoto_RGB,a.channels=n.XYZ_D50_to_ProPhoto(e.channels);break;case exports.ColorNotation.A98_RGB:a.colorNotation=exports.ColorNotation.A98_RGB,a.channels=n.XYZ_D50_to_a98_RGB(e.channels);break;case exports.ColorNotation.HSL:a.colorNotation=exports.ColorNotation.HSL,a.channels=n.XYZ_D50_to_HSL(e.channels);break;case exports.ColorNotation.HWB:a.colorNotation=exports.ColorNotation.HWB,a.channels=n.XYZ_D50_to_HWB(e.channels);break;case exports.ColorNotation.Lab:a.colorNotation=exports.ColorNotation.Lab,a.channels=n.XYZ_D50_to_Lab(e.channels);break;case exports.ColorNotation.LCH:a.colorNotation=exports.ColorNotation.LCH,a.channels=n.XYZ_D50_to_LCH(e.channels);break;case exports.ColorNotation.OKLCH:a.colorNotation=exports.ColorNotation.OKLCH,a.channels=n.XYZ_D50_to_OKLCH(e.channels);break;case exports.ColorNotation.OKLab:a.colorNotation=exports.ColorNotation.OKLab,a.channels=n.XYZ_D50_to_OKLab(e.channels);break;case exports.ColorNotation.XYZ_D50:a.colorNotation=exports.ColorNotation.XYZ_D50,a.channels=n.XYZ_D50_to_XYZ_D50(e.channels);break;case exports.ColorNotation.XYZ_D65:a.colorNotation=exports.ColorNotation.XYZ_D65,a.channels=n.XYZ_D50_to_XYZ_D65(e.channels);break;default:throw new Error("Unsupported color notation")}}else a.channels=convertNaNToZero(e.channels);if(o===e.colorNotation)a.channels=carryForwardMissingComponents(e.channels,[0,1,2],a.channels,[0,1,2]);else if(l.has(o)&&l.has(e.colorNotation))a.channels=carryForwardMissingComponents(e.channels,[0,1,2],a.channels,[0,1,2]);else switch(o){case exports.ColorNotation.HSL:switch(e.colorNotation){case exports.ColorNotation.HWB:a.channels=carryForwardMissingComponents(e.channels,[0],a.channels,[0]);break;case exports.ColorNotation.Lab:case exports.ColorNotation.OKLab:a.channels=carryForwardMissingComponents(e.channels,[2],a.channels,[0]);break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:a.channels=carryForwardMissingComponents(e.channels,[0,1,2],a.channels,[2,1,0])}break;case exports.ColorNotation.HWB:switch(e.colorNotation){case exports.ColorNotation.HSL:a.channels=carryForwardMissingComponents(e.channels,[0],a.channels,[0]);break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:a.channels=carryForwardMissingComponents(e.channels,[0],a.channels,[2])}break;case exports.ColorNotation.Lab:case exports.ColorNotation.OKLab:switch(e.colorNotation){case exports.ColorNotation.HSL:a.channels=carryForwardMissingComponents(e.channels,[0],a.channels,[2]);break;case exports.ColorNotation.Lab:case exports.ColorNotation.OKLab:a.channels=carryForwardMissingComponents(e.channels,[0,1,2],a.channels,[0,1,2]);break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:a.channels=carryForwardMissingComponents(e.channels,[0],a.channels,[0])}break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:switch(e.colorNotation){case exports.ColorNotation.HSL:a.channels=carryForwardMissingComponents(e.channels,[0,1,2],a.channels,[2,1,0]);break;case exports.ColorNotation.HWB:a.channels=carryForwardMissingComponents(e.channels,[0],a.channels,[2]);break;case exports.ColorNotation.Lab:case exports.ColorNotation.OKLab:a.channels=carryForwardMissingComponents(e.channels,[0],a.channels,[0]);break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:a.channels=carryForwardMissingComponents(e.channels,[0,1,2],a.channels,[0,1,2])}}return a.channels=convertPowerlessComponentsToMissingComponents(a.channels,o),a}function convertPowerlessComponentsToMissingComponents(e,o){const a=[...e];switch(o){case exports.ColorNotation.HSL:!Number.isNaN(a[1])&&reducePrecision(a[1],4)<=0&&(a[0]=Number.NaN);break;case exports.ColorNotation.HWB:Math.max(0,reducePrecision(a[1],4))+Math.max(0,reducePrecision(a[2],4))>=100&&(a[0]=Number.NaN);break;case exports.ColorNotation.LCH:!Number.isNaN(a[1])&&reducePrecision(a[1],4)<=0&&(a[2]=Number.NaN);break;case exports.ColorNotation.OKLCH:!Number.isNaN(a[1])&&reducePrecision(a[1],6)<=0&&(a[2]=Number.NaN)}return a}function convertPowerlessComponentsToZeroValuesForDisplay(e,o){const a=[...e];switch(o){case exports.ColorNotation.HSL:(reducePrecision(a[2])<=0||reducePrecision(a[2])>=100)&&(a[0]=Number.NaN,a[1]=Number.NaN),reducePrecision(a[1])<=0&&(a[0]=Number.NaN);break;case exports.ColorNotation.HWB:Math.max(0,reducePrecision(a[1]))+Math.max(0,reducePrecision(a[2]))>=100&&(a[0]=Number.NaN);break;case exports.ColorNotation.Lab:(reducePrecision(a[0])<=0||reducePrecision(a[0])>=100)&&(a[1]=Number.NaN,a[2]=Number.NaN);break;case exports.ColorNotation.LCH:reducePrecision(a[1])<=0&&(a[2]=Number.NaN),(reducePrecision(a[0])<=0||reducePrecision(a[0])>=100)&&(a[1]=Number.NaN,a[2]=Number.NaN);break;case exports.ColorNotation.OKLab:(reducePrecision(a[0])<=0||reducePrecision(a[0])>=1)&&(a[1]=Number.NaN,a[2]=Number.NaN);break;case exports.ColorNotation.OKLCH:reducePrecision(a[1])<=0&&(a[2]=Number.NaN),(reducePrecision(a[0])<=0||reducePrecision(a[0])>=1)&&(a[1]=Number.NaN,a[2]=Number.NaN)}return a}function carryForwardMissingComponents(e,o,a,n){const t=[...a];for(const a of o)Number.isNaN(e[o[a]])&&(t[n[a]]=Number.NaN);return t}function normalizeRelativeColorDataChannels(e){const o=new Map;switch(e.colorNotation){case exports.ColorNotation.RGB:case exports.ColorNotation.HEX:o.set("r",dummyNumberToken(255*e.channels[0])),o.set("g",dummyNumberToken(255*e.channels[1])),o.set("b",dummyNumberToken(255*e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha));break;case exports.ColorNotation.HSL:o.set("h",dummyNumberToken(e.channels[0])),o.set("s",dummyNumberToken(e.channels[1])),o.set("l",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha));break;case exports.ColorNotation.HWB:o.set("h",dummyNumberToken(e.channels[0])),o.set("w",dummyNumberToken(e.channels[1])),o.set("b",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha));break;case exports.ColorNotation.Lab:case exports.ColorNotation.OKLab:o.set("l",dummyNumberToken(e.channels[0])),o.set("a",dummyNumberToken(e.channels[1])),o.set("b",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha));break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:o.set("l",dummyNumberToken(e.channels[0])),o.set("c",dummyNumberToken(e.channels[1])),o.set("h",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha));break;case exports.ColorNotation.sRGB:case exports.ColorNotation.A98_RGB:case exports.ColorNotation.Display_P3:case exports.ColorNotation.Linear_Display_P3:case exports.ColorNotation.Rec2020:case exports.ColorNotation.Linear_sRGB:case exports.ColorNotation.ProPhoto_RGB:o.set("r",dummyNumberToken(e.channels[0])),o.set("g",dummyNumberToken(e.channels[1])),o.set("b",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha));break;case exports.ColorNotation.XYZ_D50:case exports.ColorNotation.XYZ_D65:o.set("x",dummyNumberToken(e.channels[0])),o.set("y",dummyNumberToken(e.channels[1])),o.set("z",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&o.set("alpha",dummyNumberToken(e.alpha))}return o}function noneToZeroInRelativeColorDataChannels(e){const o=new Map(e);for(const[a,n]of e)Number.isNaN(n[4].value)&&o.set(a,dummyNumberToken(0));return o}function dummyNumberToken(e){return Number.isNaN(e)?[a.TokenType.Number,"none",-1,-1,{value:Number.NaN,type:a.NumberType.Number}]:[a.TokenType.Number,e.toString(),-1,-1,{value:e,type:a.NumberType.Number}]}function reducePrecision(e,o=7){if(Number.isNaN(e))return 0;const a=Math.pow(10,o);return Math.round(e*a)/a}function normalize(e,o,a,n){return Math.min(Math.max(e/o,a),n)}const s=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(s,e=>String.fromCharCode(e.charCodeAt(0)+32))}function normalize_Color_ChannelValues(e,o,n){if(a.isTokenIdent(e)&&"none"===toLowerCaseAZ(e[4].value))return n.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[a.TokenType.Number,"none",e[2],e[3],{value:Number.NaN,type:a.NumberType.Number}];if(a.isTokenPercentage(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,100,-2147483647,2147483647);return 3===o&&(t=normalize(e[4].value,100,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}if(a.isTokenNumber(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,1,-2147483647,2147483647);return 3===o&&(t=normalize(e[4].value,1,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}return!1}const i=new Set(["srgb","srgb-linear","display-p3","display-p3-linear","a98-rgb","prophoto-rgb","rec2020","xyz","xyz-d50","xyz-d65"]);function color$1(e,o){const n=[],l=[],s=[],u=[];let c,p,N=!1,m=!1;const h={colorNotation:exports.ColorNotation.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])};let x=n;for(let y=0;y=0){i=u.value[4].value;continue}}return!1}if(!s)return!1;n.push({color:s,percentage:i}),s=!1,i=!1}}if(!s)return!1;n.push({color:s,percentage:i});let u=0,c=0;for(let e=0;e100)return!1;u+=o}else c++}const p=Math.max(0,100-u);u=0;for(let e=0;e100)for(let e=0;e=2;){const e=a.pop(),o=a.pop();if(!e||!o)return!1;const t=colorMixRectangularPair(n,e.color,e.percentage,o.color,o.percentage);if(!t)return!1;a.push({color:t,percentage:e.percentage+o.percentage})}const t=a[0]?.color;return!!t&&(o.colors.some(e=>e.color.syntaxFlags.has(exports.SyntaxFlag.Experimental))&&t.syntaxFlags.add(exports.SyntaxFlag.Experimental),"number"==typeof t.alpha&&(t.alpha=t.alpha*o.alphaMultiplier,2!==o.colors.length&&t.syntaxFlags.add(exports.SyntaxFlag.ColorMixVariadic),t))}function colorMixRectangularPair(e,o,a,n,t){const r=a/(a+t);let l=o.alpha;if("number"!=typeof l)return!1;let s=n.alpha;if("number"!=typeof s)return!1;l=Number.isNaN(l)?s:l,s=Number.isNaN(s)?l:s;const i=colorDataTo(o,e).channels,u=colorDataTo(n,e).channels;i[0]=fillInMissingComponent(i[0],u[0]),u[0]=fillInMissingComponent(u[0],i[0]),i[1]=fillInMissingComponent(i[1],u[1]),u[1]=fillInMissingComponent(u[1],i[1]),i[2]=fillInMissingComponent(i[2],u[2]),u[2]=fillInMissingComponent(u[2],i[2]),i[0]=premultiply(i[0],l),i[1]=premultiply(i[1],l),i[2]=premultiply(i[2],l),u[0]=premultiply(u[0],s),u[1]=premultiply(u[1],s),u[2]=premultiply(u[2],s);const c=interpolate(l,s,r);return{colorNotation:e,channels:[un_premultiply(interpolate(i[0],u[0],r),c),un_premultiply(interpolate(i[1],u[1],r),c),un_premultiply(interpolate(i[2],u[2],r),c)],alpha:c,syntaxFlags:new Set([exports.SyntaxFlag.ColorMix])}}function colorMixPolar(e,o,a){if(!a||!a.colors.length)return!1;const n=a.colors.slice();n.reverse();let t=exports.ColorNotation.HSL;switch(e){case"hsl":t=exports.ColorNotation.HSL;break;case"hwb":t=exports.ColorNotation.HWB;break;case"lch":t=exports.ColorNotation.LCH;break;case"oklch":t=exports.ColorNotation.OKLCH;break;default:return!1}if(1===n.length){const e=colorDataTo(n[0].color,t);return e.colorNotation=t,e.syntaxFlags.add(exports.SyntaxFlag.ColorMixVariadic),"number"!=typeof e.alpha?!1:(e.alpha=e.alpha*a.alphaMultiplier,e)}for(;n.length>=2;){const e=n.pop(),a=n.pop();if(!e||!a)return!1;const r=colorMixPolarPair(t,o,e.color,e.percentage,a.color,a.percentage);if(!r)return!1;n.push({color:r,percentage:e.percentage+a.percentage})}const r=n[0]?.color;return!!r&&(a.colors.some(e=>e.color.syntaxFlags.has(exports.SyntaxFlag.Experimental))&&r.syntaxFlags.add(exports.SyntaxFlag.Experimental),"number"==typeof r.alpha&&(r.alpha=r.alpha*a.alphaMultiplier,2!==a.colors.length&&r.syntaxFlags.add(exports.SyntaxFlag.ColorMixVariadic),r))}function colorMixPolarPair(e,o,a,n,t,r){const l=n/(n+r);let s=0,i=0,u=0,c=0,p=0,N=0,m=a.alpha;if("number"!=typeof m)return!1;let h=t.alpha;if("number"!=typeof h)return!1;m=Number.isNaN(m)?h:m,h=Number.isNaN(h)?m:h;const x=colorDataTo(a,e).channels,y=colorDataTo(t,e).channels;switch(e){case exports.ColorNotation.HSL:case exports.ColorNotation.HWB:s=x[0],i=y[0],u=x[1],c=y[1],p=x[2],N=y[2];break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:u=x[0],c=y[0],p=x[1],N=y[1],s=x[2],i=y[2]}s=fillInMissingComponent(s,i),Number.isNaN(s)&&(s=0),i=fillInMissingComponent(i,s),Number.isNaN(i)&&(i=0),u=fillInMissingComponent(u,c),c=fillInMissingComponent(c,u),p=fillInMissingComponent(p,N),N=fillInMissingComponent(N,p);const b=i-s;switch(o){case"shorter":b>180?s+=360:b<-180&&(i+=360);break;case"longer":-1800?s+=360:i+=360);break;case"increasing":b<0&&(i+=360);break;case"decreasing":b>0&&(s+=360);break;default:throw new Error("Unknown hue interpolation method")}u=premultiply(u,m),p=premultiply(p,m),c=premultiply(c,h),N=premultiply(N,h);let C=[0,0,0];const d=interpolate(m,h,l);switch(e){case exports.ColorNotation.HSL:case exports.ColorNotation.HWB:C=[interpolate(s,i,l),un_premultiply(interpolate(u,c,l),d),un_premultiply(interpolate(p,N,l),d)];break;case exports.ColorNotation.LCH:case exports.ColorNotation.OKLCH:C=[un_premultiply(interpolate(u,c,l),d),un_premultiply(interpolate(p,N,l),d),interpolate(s,i,l)]}return{colorNotation:e,channels:C,alpha:d,syntaxFlags:new Set([exports.SyntaxFlag.ColorMix])}}function fillInMissingComponent(e,o){return Number.isNaN(e)?o:e}function interpolate(e,o,a){return e*a+o*(1-a)}function premultiply(e,o){return Number.isNaN(o)?e:Number.isNaN(e)?Number.NaN:e*o}function un_premultiply(e,o){return 0===o||Number.isNaN(o)?e:Number.isNaN(e)?Number.NaN:e/o}function hex(e){const o=toLowerCaseAZ(e[4].value);if(o.match(/[^a-f0-9]/))return!1;const a={colorNotation:exports.ColorNotation.HEX,channels:[0,0,0],alpha:1,syntaxFlags:new Set([exports.SyntaxFlag.Hex])},n=o.length;if(3===n){const e=o[0],n=o[1],t=o[2];return a.channels=[parseInt(e+e,16)/255,parseInt(n+n,16)/255,parseInt(t+t,16)/255],a}if(6===n){const e=o[0]+o[1],n=o[2]+o[3],t=o[4]+o[5];return a.channels=[parseInt(e,16)/255,parseInt(n,16)/255,parseInt(t,16)/255],a}if(4===n){const e=o[0],n=o[1],t=o[2],r=o[3];return a.channels=[parseInt(e+e,16)/255,parseInt(n+n,16)/255,parseInt(t+t,16)/255],a.alpha=parseInt(r+r,16)/255,a.syntaxFlags.add(exports.SyntaxFlag.HasAlpha),a}if(8===n){const e=o[0]+o[1],n=o[2]+o[3],t=o[4]+o[5],r=o[6]+o[7];return a.channels=[parseInt(e,16)/255,parseInt(n,16)/255,parseInt(t,16)/255],a.alpha=parseInt(r,16)/255,a.syntaxFlags.add(exports.SyntaxFlag.HasAlpha),a}return!1}function normalizeHue(e){if(a.isTokenNumber(e))return e[4].value=e[4].value%360,e[1]=e[4].value.toString(),e;if(a.isTokenDimension(e)){let o=e[4].value;switch(toLowerCaseAZ(e[4].unit)){case"deg":break;case"rad":o=180*e[4].value/Math.PI;break;case"grad":o=.9*e[4].value;break;case"turn":o=360*e[4].value;break;default:return!1}return o%=360,[a.TokenType.Number,o.toString(),e[2],e[3],{value:o,type:a.NumberType.Number}]}return!1}function normalize_legacy_HSL_ChannelValues(e,o,n){if(0===o){const o=normalizeHue(e);return!1!==o&&(a.isTokenDimension(e)&&n.syntaxFlags.add(exports.SyntaxFlag.HasDimensionValues),o)}if(a.isTokenPercentage(e)){3===o?n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageAlpha):n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,1,0,100);return 3===o&&(t=normalize(e[4].value,100,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}if(a.isTokenNumber(e)){if(3!==o)return!1;let n=normalize(e[4].value,1,0,100);return 3===o&&(n=normalize(e[4].value,1,0,1)),[a.TokenType.Number,n.toString(),e[2],e[3],{value:n,type:a.NumberType.Number}]}return!1}function normalize_modern_HSL_ChannelValues(e,o,n){if(a.isTokenIdent(e)&&"none"===toLowerCaseAZ(e[4].value))return n.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[a.TokenType.Number,"none",e[2],e[3],{value:Number.NaN,type:a.NumberType.Number}];if(0===o){const o=normalizeHue(e);return!1!==o&&(a.isTokenDimension(e)&&n.syntaxFlags.add(exports.SyntaxFlag.HasDimensionValues),o)}if(a.isTokenPercentage(e)){3===o?n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageAlpha):n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=e[4].value;return 3===o?t=normalize(e[4].value,100,0,1):1===o&&(t=normalize(e[4].value,1,0,2147483647)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}if(a.isTokenNumber(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=e[4].value;return 3===o?t=normalize(e[4].value,1,0,1):1===o&&(t=normalize(e[4].value,1,0,2147483647)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}return!1}function threeChannelLegacySyntax(e,o,n,l){const s=[],i=[],u=[],c=[],p={colorNotation:n,channels:[0,0,0],alpha:1,syntaxFlags:new Set(l)};let N=s;for(let o=0;ot.isTokenNode(e)&&a.isTokenComma(e.value))){const o=hslCommaSeparated(e);if(!1!==o)return o}{const a=hslSpaceSeparated(e,o);if(!1!==a)return a}return!1}function hslCommaSeparated(e){return threeChannelLegacySyntax(e,normalize_legacy_HSL_ChannelValues,exports.ColorNotation.HSL,[exports.SyntaxFlag.LegacyHSL])}function hslSpaceSeparated(e,o){return threeChannelSpaceSeparated(e,normalize_modern_HSL_ChannelValues,exports.ColorNotation.HSL,[],o)}function normalize_HWB_ChannelValues(e,o,n){if(a.isTokenIdent(e)&&"none"===toLowerCaseAZ(e[4].value))return n.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[a.TokenType.Number,"none",e[2],e[3],{value:Number.NaN,type:a.NumberType.Number}];if(0===o){const o=normalizeHue(e);return!1!==o&&(a.isTokenDimension(e)&&n.syntaxFlags.add(exports.SyntaxFlag.HasDimensionValues),o)}if(a.isTokenPercentage(e)){3===o?n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageAlpha):n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=e[4].value;return 3===o&&(t=normalize(e[4].value,100,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}if(a.isTokenNumber(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=e[4].value;return 3===o&&(t=normalize(e[4].value,1,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}return!1}function normalize_Lab_ChannelValues(e,o,n){if(a.isTokenIdent(e)&&"none"===toLowerCaseAZ(e[4].value))return n.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[a.TokenType.Number,"none",e[2],e[3],{value:Number.NaN,type:a.NumberType.Number}];if(a.isTokenPercentage(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,1,0,100);return 1===o||2===o?t=normalize(e[4].value,.8,-2147483647,2147483647):3===o&&(t=normalize(e[4].value,100,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}if(a.isTokenNumber(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,1,0,100);return 1===o||2===o?t=normalize(e[4].value,1,-2147483647,2147483647):3===o&&(t=normalize(e[4].value,1,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}return!1}function lab(e,o){return threeChannelSpaceSeparated(e,normalize_Lab_ChannelValues,exports.ColorNotation.Lab,[],o)}function normalize_LCH_ChannelValues(e,o,n){if(a.isTokenIdent(e)&&"none"===toLowerCaseAZ(e[4].value))return n.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[a.TokenType.Number,"none",e[2],e[3],{value:Number.NaN,type:a.NumberType.Number}];if(2===o){const o=normalizeHue(e);return!1!==o&&(a.isTokenDimension(e)&&n.syntaxFlags.add(exports.SyntaxFlag.HasDimensionValues),o)}if(a.isTokenPercentage(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,1,0,100);return 1===o?t=normalize(e[4].value,100/150,0,2147483647):3===o&&(t=normalize(e[4].value,100,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}if(a.isTokenNumber(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,1,0,100);return 1===o?t=normalize(e[4].value,1,0,2147483647):3===o&&(t=normalize(e[4].value,1,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}return!1}function lch(e,o){return threeChannelSpaceSeparated(e,normalize_LCH_ChannelValues,exports.ColorNotation.LCH,[],o)}const N=new Map;for(const[e,o]of Object.entries(n.namedColors))N.set(e,o);function namedColor(e){const o=N.get(toLowerCaseAZ(e));return!!o&&{colorNotation:exports.ColorNotation.RGB,channels:[o[0]/255,o[1]/255,o[2]/255],alpha:1,syntaxFlags:new Set([exports.SyntaxFlag.ColorKeyword,exports.SyntaxFlag.NamedColor])}}function normalize_OKLab_ChannelValues(e,o,n){if(a.isTokenIdent(e)&&"none"===toLowerCaseAZ(e[4].value))return n.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[a.TokenType.Number,"none",e[2],e[3],{value:Number.NaN,type:a.NumberType.Number}];if(a.isTokenPercentage(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,100,0,1);return 1===o||2===o?t=normalize(e[4].value,250,-2147483647,2147483647):3===o&&(t=normalize(e[4].value,100,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}if(a.isTokenNumber(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,1,0,1);return 1===o||2===o?t=normalize(e[4].value,1,-2147483647,2147483647):3===o&&(t=normalize(e[4].value,1,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}return!1}function oklab(e,o){return threeChannelSpaceSeparated(e,normalize_OKLab_ChannelValues,exports.ColorNotation.OKLab,[],o)}function normalize_OKLCH_ChannelValues(e,o,n){if(a.isTokenIdent(e)&&"none"===toLowerCaseAZ(e[4].value))return n.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[a.TokenType.Number,"none",e[2],e[3],{value:Number.NaN,type:a.NumberType.Number}];if(2===o){const o=normalizeHue(e);return!1!==o&&(a.isTokenDimension(e)&&n.syntaxFlags.add(exports.SyntaxFlag.HasDimensionValues),o)}if(a.isTokenPercentage(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,100,0,1);return 1===o?t=normalize(e[4].value,250,0,2147483647):3===o&&(t=normalize(e[4].value,100,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}if(a.isTokenNumber(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,1,0,1);return 1===o?t=normalize(e[4].value,1,0,2147483647):3===o&&(t=normalize(e[4].value,1,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}return!1}function oklch(e,o){return threeChannelSpaceSeparated(e,normalize_OKLCH_ChannelValues,exports.ColorNotation.OKLCH,[],o)}function normalize_legacy_sRGB_ChannelValues(e,o,n){if(a.isTokenPercentage(e)){3===o?n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageAlpha):n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);const t=normalize(e[4].value,100,0,1);return[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}if(a.isTokenNumber(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,255,0,1);return 3===o&&(t=normalize(e[4].value,1,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}return!1}function normalize_modern_sRGB_ChannelValues(e,o,n){if(a.isTokenIdent(e)&&"none"===e[4].value.toLowerCase())return n.syntaxFlags.add(exports.SyntaxFlag.HasNoneKeywords),[a.TokenType.Number,"none",e[2],e[3],{value:Number.NaN,type:a.NumberType.Number}];if(a.isTokenPercentage(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasPercentageValues);let t=normalize(e[4].value,100,-2147483647,2147483647);return 3===o&&(t=normalize(e[4].value,100,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}if(a.isTokenNumber(e)){3!==o&&n.syntaxFlags.add(exports.SyntaxFlag.HasNumberValues);let t=normalize(e[4].value,255,-2147483647,2147483647);return 3===o&&(t=normalize(e[4].value,1,0,1)),[a.TokenType.Number,t.toString(),e[2],e[3],{value:t,type:a.NumberType.Number}]}return!1}function rgb(e,o){if(e.value.some(e=>t.isTokenNode(e)&&a.isTokenComma(e.value))){const o=rgbCommaSeparated(e);if(!1!==o)return(!o.syntaxFlags.has(exports.SyntaxFlag.HasNumberValues)||!o.syntaxFlags.has(exports.SyntaxFlag.HasPercentageValues))&&o}else{const a=rgbSpaceSeparated(e,o);if(!1!==a)return a}return!1}function rgbCommaSeparated(e){return threeChannelLegacySyntax(e,normalize_legacy_sRGB_ChannelValues,exports.ColorNotation.RGB,[exports.SyntaxFlag.LegacyRGB])}function rgbSpaceSeparated(e,o){return threeChannelSpaceSeparated(e,normalize_modern_sRGB_ChannelValues,exports.ColorNotation.RGB,[],o)}function XYZ_D50_to_sRGB_Gamut(e){const o=n.XYZ_D50_to_sRGB(e);if(n.inGamut(o))return n.clip(o);let a=e;return a=n.XYZ_D50_to_OKLCH(a),a[0]<1e-6&&(a=[0,0,0]),a[0]>.999999&&(a=[1,0,0]),n.gam_sRGB(n.mapGamutRayTrace(a,oklch_to_lin_srgb,lin_srgb_to_oklch))}function oklch_to_lin_srgb(e){return e=n.OKLCH_to_OKLab(e),e=n.OKLab_to_XYZ(e),n.XYZ_to_lin_sRGB(e)}function lin_srgb_to_oklch(e){return e=n.lin_sRGB_to_XYZ(e),e=n.XYZ_to_OKLab(e),n.OKLab_to_OKLCH(e)}function contrastColor(e,o){let a=!1;for(let n=0;ns?[1,1,1]:[0,0,0],r}function alpha(e,o){let n,l,s=!1,i=!1,u=!1;const c={colorNotation:exports.ColorNotation.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])};for(let p=0;p{if(t.isTokenNode(e)&&a.isTokenIdent(e.value)&&"alpha"===toLowerCaseAZ(e.value[4].value)&&n&&n.has("alpha"))return new t.TokenNode(n.get("alpha"))});c.alpha=e[0][0],i=!0;continue}return!1}if(u)return!1;for(;t.isWhitespaceNode(e.value[p+1])||t.isCommentNode(e.value[p+1]);)p++;if(p++,N=e.value[p],u=o(N),!1===u)return!1;n=normalizeRelativeColorDataChannels(u),l=noneToZeroInRelativeColorDataChannels(n),c.syntaxFlags=new Set(u.syntaxFlags),c.syntaxFlags.add(exports.SyntaxFlag.RelativeAlphaSyntax),c.channels=[...u.channels],c.colorNotation=u.colorNotation,c.alpha=u.alpha}}return!!n&&c}function XYZ_D50_to_P3_Gamut(e){const o=n.XYZ_D50_to_P3(e);if(n.inGamut(o))return n.clip(o);let a=e;return a=n.XYZ_D50_to_OKLCH(a),a[0]<1e-6&&(a=[0,0,0]),a[0]>.999999&&(a=[1,0,0]),n.gam_P3(n.mapGamutRayTrace(a,oklch_to_lin_p3,lin_p3_to_oklch))}function oklch_to_lin_p3(e){return e=n.OKLCH_to_OKLab(e),e=n.OKLab_to_XYZ(e),n.XYZ_to_lin_P3(e)}function lin_p3_to_oklch(e){return e=n.lin_P3_to_XYZ(e),e=n.XYZ_to_OKLab(e),n.OKLab_to_OKLCH(e)}function toPrecision(e,o=7){e=+e,o=+o;const a=(Math.floor(Math.abs(e))+"").length;if(o>a)return+e.toFixed(o-a);{const n=10**(a-o);return Math.round(e/n)*n}}function serializeWithAlpha(e,o,n,r){const l=[a.TokenType.CloseParen,")",-1,-1,void 0];if("number"==typeof e.alpha){const s=Math.min(1,Math.max(0,toPrecision(Number.isNaN(e.alpha)?0:e.alpha)));return 1===toPrecision(s,4)?new t.FunctionNode(o,l,r):new t.FunctionNode(o,l,[...r,new t.WhitespaceNode([n]),new t.TokenNode([a.TokenType.Delim,"/",-1,-1,{value:"/"}]),new t.WhitespaceNode([n]),new t.TokenNode([a.TokenType.Number,toPrecision(s,4).toString(),-1,-1,{value:e.alpha,type:a.NumberType.Integer}])])}return new t.FunctionNode(o,l,[...r,new t.WhitespaceNode([n]),new t.TokenNode([a.TokenType.Delim,"/",-1,-1,{value:"/"}]),new t.WhitespaceNode([n]),e.alpha])}exports.color=function color(e){if(t.isFunctionNode(e)){switch(toLowerCaseAZ(e.getName())){case"rgb":case"rgba":return rgb(e,color);case"hsl":case"hsla":return hsl(e,color);case"hwb":return o=color,threeChannelSpaceSeparated(e,normalize_HWB_ChannelValues,exports.ColorNotation.HWB,[],o);case"lab":return lab(e,color);case"lch":return lch(e,color);case"oklab":return oklab(e,color);case"oklch":return oklch(e,color);case"color":return color$1(e,color);case"color-mix":return colorMix(e,color);case"contrast-color":return contrastColor(e,color);case"alpha":return alpha(e,color)}}var o;if(t.isTokenNode(e)){if(a.isTokenHash(e.value))return hex(e.value);if(a.isTokenIdent(e.value)){const o=namedColor(e.value[4].value);return!1!==o?o:"transparent"===toLowerCaseAZ(e.value[4].value)&&{colorNotation:exports.ColorNotation.RGB,channels:[0,0,0],alpha:0,syntaxFlags:new Set([exports.SyntaxFlag.ColorKeyword])}}}return!1},exports.colorDataFitsDisplayP3_Gamut=function colorDataFitsDisplayP3_Gamut(e){const o={...e,channels:[...e.channels]};return o.channels=convertPowerlessComponentsToZeroValuesForDisplay(o.channels,o.colorNotation),!colorDataTo(o,exports.ColorNotation.Display_P3).channels.find(e=>e<-1e-5||e>1.00001)},exports.colorDataFitsRGB_Gamut=function colorDataFitsRGB_Gamut(e){const o={...e,channels:[...e.channels]};return o.channels=convertPowerlessComponentsToZeroValuesForDisplay(o.channels,o.colorNotation),!colorDataTo(o,exports.ColorNotation.RGB).channels.find(e=>e<-1e-5||e>1.00001)},exports.serializeHSL=function serializeHSL(e,o=!0){e.channels=convertPowerlessComponentsToZeroValuesForDisplay(e.channels,e.colorNotation);let r=e.channels.map(e=>Number.isNaN(e)?0:e);r=o?n.XYZ_D50_to_HSL(n.sRGB_to_XYZ_D50(XYZ_D50_to_sRGB_Gamut(colorData_to_XYZ_D50(e).channels))):n.XYZ_D50_to_HSL(colorData_to_XYZ_D50(e).channels),r=r.map(e=>Number.isNaN(e)?0:e);const l=Math.min(360,Math.max(0,Math.round(toPrecision(r[0])))),s=Math.min(100,Math.max(0,Math.round(toPrecision(r[1])))),i=Math.min(100,Math.max(0,Math.round(toPrecision(r[2])))),u=[a.TokenType.CloseParen,")",-1,-1,void 0],c=[a.TokenType.Whitespace," ",-1,-1,void 0],p=[a.TokenType.Comma,",",-1,-1,void 0],N=[new t.TokenNode([a.TokenType.Number,l.toString(),-1,-1,{value:r[0],type:a.NumberType.Integer}]),new t.TokenNode(p),new t.WhitespaceNode([c]),new t.TokenNode([a.TokenType.Percentage,s.toString()+"%",-1,-1,{value:r[1]}]),new t.TokenNode(p),new t.WhitespaceNode([c]),new t.TokenNode([a.TokenType.Percentage,i.toString()+"%",-1,-1,{value:r[2]}])];if("number"==typeof e.alpha){const o=Math.min(1,Math.max(0,toPrecision(Number.isNaN(e.alpha)?0:e.alpha)));return 1===toPrecision(o,4)?new t.FunctionNode([a.TokenType.Function,"hsl(",-1,-1,{value:"hsl"}],u,N):new t.FunctionNode([a.TokenType.Function,"hsla(",-1,-1,{value:"hsla"}],u,[...N,new t.TokenNode(p),new t.WhitespaceNode([c]),new t.TokenNode([a.TokenType.Number,toPrecision(o,4).toString(),-1,-1,{value:e.alpha,type:a.NumberType.Number}])])}return new t.FunctionNode([a.TokenType.Function,"hsla(",-1,-1,{value:"hsla"}],u,[...N,new t.TokenNode(p),new t.WhitespaceNode([c]),e.alpha])},exports.serializeOKLCH=function serializeOKLCH(e){e.channels=convertPowerlessComponentsToZeroValuesForDisplay(e.channels,e.colorNotation);let o=e.channels.map(e=>Number.isNaN(e)?0:e);e.colorNotation!==exports.ColorNotation.OKLCH&&(o=n.XYZ_D50_to_OKLCH(colorData_to_XYZ_D50(e).channels));const r=toPrecision(o[0],6),l=toPrecision(o[1],6),s=toPrecision(o[2],6),i=[a.TokenType.Function,"oklch(",-1,-1,{value:"oklch"}],u=[a.TokenType.Whitespace," ",-1,-1,void 0];return serializeWithAlpha(e,i,u,[new t.TokenNode([a.TokenType.Number,r.toString(),-1,-1,{value:o[0],type:a.NumberType.Number}]),new t.WhitespaceNode([u]),new t.TokenNode([a.TokenType.Number,l.toString(),-1,-1,{value:o[1],type:a.NumberType.Number}]),new t.WhitespaceNode([u]),new t.TokenNode([a.TokenType.Number,s.toString(),-1,-1,{value:o[2],type:a.NumberType.Number}])])},exports.serializeP3=function serializeP3(e,o=!0){e.channels=convertPowerlessComponentsToZeroValuesForDisplay(e.channels,e.colorNotation);let r=e.channels.map(e=>Number.isNaN(e)?0:e);o?r=XYZ_D50_to_P3_Gamut(colorData_to_XYZ_D50(e).channels):e.colorNotation!==exports.ColorNotation.Display_P3&&(r=n.XYZ_D50_to_P3(colorData_to_XYZ_D50(e).channels));const l=o?Math.min(1,Math.max(0,toPrecision(r[0],6))):toPrecision(r[0],6),s=o?Math.min(1,Math.max(0,toPrecision(r[1],6))):toPrecision(r[1],6),i=o?Math.min(1,Math.max(0,toPrecision(r[2],6))):toPrecision(r[2],6),u=[a.TokenType.Function,"color(",-1,-1,{value:"color"}],c=[a.TokenType.Whitespace," ",-1,-1,void 0];return serializeWithAlpha(e,u,c,[new t.TokenNode([a.TokenType.Ident,"display-p3",-1,-1,{value:"display-p3"}]),new t.WhitespaceNode([c]),new t.TokenNode([a.TokenType.Number,l.toString(),-1,-1,{value:r[0],type:a.NumberType.Number}]),new t.WhitespaceNode([c]),new t.TokenNode([a.TokenType.Number,s.toString(),-1,-1,{value:r[1],type:a.NumberType.Number}]),new t.WhitespaceNode([c]),new t.TokenNode([a.TokenType.Number,i.toString(),-1,-1,{value:r[2],type:a.NumberType.Number}])])},exports.serializeRGB=function serializeRGB(e,o=!0){e.channels=convertPowerlessComponentsToZeroValuesForDisplay(e.channels,e.colorNotation);let r=e.channels.map(e=>Number.isNaN(e)?0:e);r=o?XYZ_D50_to_sRGB_Gamut(colorData_to_XYZ_D50(e).channels):n.XYZ_D50_to_sRGB(colorData_to_XYZ_D50(e).channels);const l=Math.min(255,Math.max(0,Math.round(255*toPrecision(r[0])))),s=Math.min(255,Math.max(0,Math.round(255*toPrecision(r[1])))),i=Math.min(255,Math.max(0,Math.round(255*toPrecision(r[2])))),u=[a.TokenType.CloseParen,")",-1,-1,void 0],c=[a.TokenType.Whitespace," ",-1,-1,void 0],p=[a.TokenType.Comma,",",-1,-1,void 0],N=[new t.TokenNode([a.TokenType.Number,l.toString(),-1,-1,{value:Math.min(255,255*Math.max(0,r[0])),type:a.NumberType.Integer}]),new t.TokenNode(p),new t.WhitespaceNode([c]),new t.TokenNode([a.TokenType.Number,s.toString(),-1,-1,{value:Math.min(255,255*Math.max(0,r[1])),type:a.NumberType.Integer}]),new t.TokenNode(p),new t.WhitespaceNode([c]),new t.TokenNode([a.TokenType.Number,i.toString(),-1,-1,{value:Math.min(255,255*Math.max(0,r[2])),type:a.NumberType.Integer}])];if("number"==typeof e.alpha){const o=Math.min(1,Math.max(0,toPrecision(Number.isNaN(e.alpha)?0:e.alpha)));return 1===toPrecision(o,4)?new t.FunctionNode([a.TokenType.Function,"rgb(",-1,-1,{value:"rgb"}],u,N):new t.FunctionNode([a.TokenType.Function,"rgba(",-1,-1,{value:"rgba"}],u,[...N,new t.TokenNode(p),new t.WhitespaceNode([c]),new t.TokenNode([a.TokenType.Number,toPrecision(o,4).toString(),-1,-1,{value:e.alpha,type:a.NumberType.Number}])])}return new t.FunctionNode([a.TokenType.Function,"rgba(",-1,-1,{value:"rgba"}],u,[...N,new t.TokenNode(p),new t.WhitespaceNode([c]),e.alpha])}; diff --git a/packages/css-color-parser/package.json b/packages/css-color-parser/package.json index 2bb7fb20c..9880743ca 100644 --- a/packages/css-color-parser/package.json +++ b/packages/css-color-parser/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/packages/css-parser-algorithms/CHANGELOG.md b/packages/css-parser-algorithms/CHANGELOG.md index cdd0b7e27..bee939d70 100644 --- a/packages/css-parser-algorithms/CHANGELOG.md +++ b/packages/css-parser-algorithms/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to CSS Parser Algorithms +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.0.5 _May 27, 2025_ diff --git a/packages/css-parser-algorithms/dist/index.cjs b/packages/css-parser-algorithms/dist/index.cjs deleted file mode 100644 index 2ad335a50..000000000 --- a/packages/css-parser-algorithms/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e,n=require("@csstools/css-tokenizer");function walkerIndexGenerator(e){let n=e.slice();return(e,o,t)=>{let s=-1;for(let i=n.indexOf(o);i=e.length)?-1:(n=e.slice(),s)}}function consumeComponentValue(e,o){const t=o[0];if(n.isTokenOpenParen(t)||n.isTokenOpenCurly(t)||n.isTokenOpenSquare(t)){const n=consumeSimpleBlock(e,o);return{advance:n.advance,node:n.node}}if(n.isTokenFunction(t)){const n=consumeFunction(e,o);return{advance:n.advance,node:n.node}}if(n.isTokenWhitespace(t)){const n=consumeWhitespace(e,o);return{advance:n.advance,node:n.node}}if(n.isTokenComment(t)){const n=consumeComment(e,o);return{advance:n.advance,node:n.node}}return{advance:1,node:new TokenNode(t)}}exports.ComponentValueType=void 0,(e=exports.ComponentValueType||(exports.ComponentValueType={})).Function="function",e.SimpleBlock="simple-block",e.Whitespace="whitespace",e.Comment="comment",e.Token="token";class ContainerNodeBaseClass{value=[];indexOf(e){return this.value.indexOf(e)}at(e){if("number"==typeof e)return e<0&&(e=this.value.length+e),this.value[e]}forEach(e,n){if(0===this.value.length)return;const o=walkerIndexGenerator(this.value);let t=0;for(;t!1!==e(n,o)&&((!("walk"in n.node)||!this.value.includes(n.node)||!1!==n.node.walk(e,n.state))&&void 0),n)}}class FunctionNode extends ContainerNodeBaseClass{type=exports.ComponentValueType.Function;name;endToken;constructor(e,n,o){super(),this.name=e,this.endToken=n,this.value=o}getName(){return this.name[4].value}normalize(){n.isTokenEOF(this.endToken)&&(this.endToken=[n.TokenType.CloseParen,")",-1,-1,void 0])}tokens(){return n.isTokenEOF(this.endToken)?[this.name,...this.value.flatMap(e=>e.tokens())]:[this.name,...this.value.flatMap(e=>e.tokens()),this.endToken]}toString(){const e=this.value.map(e=>n.isToken(e)?n.stringify(e):e.toString()).join("");return n.stringify(this.name)+e+n.stringify(this.endToken)}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens(),value:this.value.map(e=>e.toJSON())}}isFunctionNode(){return FunctionNode.isFunctionNode(this)}static isFunctionNode(e){return!!e&&(e instanceof FunctionNode&&e.type===exports.ComponentValueType.Function)}}function consumeFunction(e,o){const t=[];let s=1;for(;;){const i=o[s];if(!i||n.isTokenEOF(i))return e.onParseError(new n.ParseError("Unexpected EOF while consuming a function.",o[0][2],o[o.length-1][3],["5.4.9. Consume a function","Unexpected EOF"])),{advance:o.length,node:new FunctionNode(o[0],i,t)};if(n.isTokenCloseParen(i))return{advance:s+1,node:new FunctionNode(o[0],i,t)};if(n.isTokenWhiteSpaceOrComment(i)){const n=consumeAllCommentsAndWhitespace(e,o.slice(s));s+=n.advance,t.push(...n.nodes);continue}const r=consumeComponentValue(e,o.slice(s));s+=r.advance,t.push(r.node)}}class SimpleBlockNode extends ContainerNodeBaseClass{type=exports.ComponentValueType.SimpleBlock;startToken;endToken;constructor(e,n,o){super(),this.startToken=e,this.endToken=n,this.value=o}normalize(){if(n.isTokenEOF(this.endToken)){const e=n.mirrorVariant(this.startToken);e&&(this.endToken=e)}}tokens(){return n.isTokenEOF(this.endToken)?[this.startToken,...this.value.flatMap(e=>e.tokens())]:[this.startToken,...this.value.flatMap(e=>e.tokens()),this.endToken]}toString(){const e=this.value.map(e=>n.isToken(e)?n.stringify(e):e.toString()).join("");return n.stringify(this.startToken)+e+n.stringify(this.endToken)}toJSON(){return{type:this.type,startToken:this.startToken,tokens:this.tokens(),value:this.value.map(e=>e.toJSON())}}isSimpleBlockNode(){return SimpleBlockNode.isSimpleBlockNode(this)}static isSimpleBlockNode(e){return!!e&&(e instanceof SimpleBlockNode&&e.type===exports.ComponentValueType.SimpleBlock)}}function consumeSimpleBlock(e,o){const t=n.mirrorVariantType(o[0][0]);if(!t)throw new Error("Failed to parse, a mirror variant must exist for all block open tokens.");const s=[];let i=1;for(;;){const r=o[i];if(!r||n.isTokenEOF(r))return e.onParseError(new n.ParseError("Unexpected EOF while consuming a simple block.",o[0][2],o[o.length-1][3],["5.4.8. Consume a simple block","Unexpected EOF"])),{advance:o.length,node:new SimpleBlockNode(o[0],r,s)};if(r[0]===t)return{advance:i+1,node:new SimpleBlockNode(o[0],r,s)};if(n.isTokenWhiteSpaceOrComment(r)){const n=consumeAllCommentsAndWhitespace(e,o.slice(i));i+=n.advance,s.push(...n.nodes);continue}const a=consumeComponentValue(e,o.slice(i));i+=a.advance,s.push(a.node)}}class WhitespaceNode{type=exports.ComponentValueType.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return n.stringify(...this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isWhitespaceNode(){return WhitespaceNode.isWhitespaceNode(this)}static isWhitespaceNode(e){return!!e&&(e instanceof WhitespaceNode&&e.type===exports.ComponentValueType.Whitespace)}}function consumeWhitespace(e,o){let t=0;for(;;){const e=o[t];if(!n.isTokenWhitespace(e))return{advance:t,node:new WhitespaceNode(o.slice(0,t))};t++}}class CommentNode{type=exports.ComponentValueType.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return n.stringify(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isCommentNode(){return CommentNode.isCommentNode(this)}static isCommentNode(e){return!!e&&(e instanceof CommentNode&&e.type===exports.ComponentValueType.Comment)}}function consumeComment(e,n){return{advance:1,node:new CommentNode(n[0])}}function consumeAllCommentsAndWhitespace(e,o){const t=[];let s=0;for(;;){if(n.isTokenWhitespace(o[s])){const e=consumeWhitespace(0,o.slice(s));s+=e.advance,t.push(e.node);continue}if(!n.isTokenComment(o[s]))return{advance:s,nodes:t};t.push(new CommentNode(o[s])),s++}}class TokenNode{type=exports.ComponentValueType.Token;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return this.value[1]}toJSON(){return{type:this.type,tokens:this.tokens()}}isTokenNode(){return TokenNode.isTokenNode(this)}static isTokenNode(e){return!!e&&(e instanceof TokenNode&&e.type===exports.ComponentValueType.Token)}}function forEach(e,n,o){if(0===e.length)return;const t=walkerIndexGenerator(e);let s=0;for(;s!1!==n(o,t)&&((!("walk"in o.node)||!e.includes(o.node)||!1!==o.node.walk(n,o.state))&&void 0),o)}function isWhitespaceNode(e){return WhitespaceNode.isWhitespaceNode(e)}function isCommentNode(e){return CommentNode.isCommentNode(e)}exports.CommentNode=CommentNode,exports.ContainerNodeBaseClass=ContainerNodeBaseClass,exports.FunctionNode=FunctionNode,exports.SimpleBlockNode=SimpleBlockNode,exports.TokenNode=TokenNode,exports.WhitespaceNode=WhitespaceNode,exports.forEach=forEach,exports.gatherNodeAncestry=function gatherNodeAncestry(e){const n=new Map;return e.walk(e=>{Array.isArray(e.node)?e.node.forEach(o=>{n.set(o,e.parent)}):n.set(e.node,e.parent)}),n},exports.isCommentNode=isCommentNode,exports.isFunctionNode=function isFunctionNode(e){return FunctionNode.isFunctionNode(e)},exports.isSimpleBlockNode=function isSimpleBlockNode(e){return SimpleBlockNode.isSimpleBlockNode(e)},exports.isTokenNode=function isTokenNode(e){return TokenNode.isTokenNode(e)},exports.isWhiteSpaceOrCommentNode=function isWhiteSpaceOrCommentNode(e){return isWhitespaceNode(e)||isCommentNode(e)},exports.isWhitespaceNode=isWhitespaceNode,exports.parseCommaSeparatedListOfComponentValues=function parseCommaSeparatedListOfComponentValues(e,o){const t={onParseError:o?.onParseError??(()=>{})},s=[...e];if(0===e.length)return[];n.isTokenEOF(s[s.length-1])&&s.push([n.TokenType.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=[];let r=[],a=0;for(;;){if(!s[a]||n.isTokenEOF(s[a]))return r.length&&i.push(r),i;if(n.isTokenComma(s[a])){i.push(r),r=[],a++;continue}const o=consumeComponentValue(t,e.slice(a));r.push(o.node),a+=o.advance}},exports.parseComponentValue=function parseComponentValue(e,o){const t={onParseError:o?.onParseError??(()=>{})},s=[...e];n.isTokenEOF(s[s.length-1])||s.push([n.TokenType.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=consumeComponentValue(t,s);if(n.isTokenEOF(s[Math.min(i.advance,s.length-1)]))return i.node;t.onParseError(new n.ParseError("Expected EOF after parsing a component value.",e[0][2],e[e.length-1][3],["5.3.9. Parse a component value","Expected EOF"]))},exports.parseListOfComponentValues=function parseListOfComponentValues(e,o){const t={onParseError:o?.onParseError??(()=>{})},s=[...e];n.isTokenEOF(s[s.length-1])&&s.push([n.TokenType.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=[];let r=0;for(;;){if(!s[r]||n.isTokenEOF(s[r]))return i;const e=consumeComponentValue(t,s.slice(r));i.push(e.node),r+=e.advance}},exports.replaceComponentValues=function replaceComponentValues(e,n){for(let o=0;o{if("number"!=typeof o)return;const t=n(e.node);t&&(Array.isArray(t)?e.parent.value.splice(o,1,...t):e.parent.value.splice(o,1,t))})}return e},exports.sourceIndices=function sourceIndices(e){if(Array.isArray(e)){const n=e[0];if(!n)return[0,0];const o=e[e.length-1]||n;return[sourceIndices(n)[0],sourceIndices(o)[1]]}const n=e.tokens(),o=n[0],t=n[n.length-1];return o&&t?[o[2],t[3]]:[0,0]},exports.stringify=function stringify(e){return e.map(e=>e.map(e=>n.stringify(...e.tokens())).join("")).join(",")},exports.walk=walk,exports.walkerIndexGenerator=walkerIndexGenerator; diff --git a/packages/css-parser-algorithms/package.json b/packages/css-parser-algorithms/package.json index 47a0f76de..928f19ed5 100644 --- a/packages/css-parser-algorithms/package.json +++ b/packages/css-parser-algorithms/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/packages/css-syntax-patches-for-csstree/CHANGELOG.md b/packages/css-syntax-patches-for-csstree/CHANGELOG.md index 2617d2916..a0a3afe36 100644 --- a/packages/css-syntax-patches-for-csstree/CHANGELOG.md +++ b/packages/css-syntax-patches-for-csstree/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to CSS Syntax Patches For CSSTree +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 1.0.25 _January 11, 2026_ diff --git a/packages/css-syntax-patches-for-csstree/package.json b/packages/css-syntax-patches-for-csstree/package.json index bb12ee5ec..5c7321c91 100644 --- a/packages/css-syntax-patches-for-csstree/package.json +++ b/packages/css-syntax-patches-for-csstree/package.json @@ -24,11 +24,9 @@ "url": "https://opencollective.com/csstools" } ], - "engines": { - "node": ">=18" - }, "main": "dist/index.json", "types": "dist/index.d.ts", + "exports": "./dist/index.json", "files": [ "CHANGELOG.md", "LICENSE.md", diff --git a/packages/css-syntax-patches-for-csstree/tests/import.test.mjs b/packages/css-syntax-patches-for-csstree/tests/import.test.mjs new file mode 100644 index 000000000..fda830449 --- /dev/null +++ b/packages/css-syntax-patches-for-csstree/tests/import.test.mjs @@ -0,0 +1,4 @@ +import assert from 'node:assert'; +import syntax_patches from '@csstools/css-syntax-patches-for-csstree' with { type: 'json' }; + +assert.ok(syntax_patches.next); diff --git a/packages/css-syntax-patches-for-csstree/tests/require.test.cjs b/packages/css-syntax-patches-for-csstree/tests/require.test.cjs new file mode 100644 index 000000000..ea253d960 --- /dev/null +++ b/packages/css-syntax-patches-for-csstree/tests/require.test.cjs @@ -0,0 +1,4 @@ +const assert = require('node:assert'); +const syntax_patches = require('@csstools/css-syntax-patches-for-csstree'); + +assert.ok(syntax_patches.next); diff --git a/packages/css-tokenizer/CHANGELOG.md b/packages/css-tokenizer/CHANGELOG.md index 7d1df0487..d6245d5b3 100644 --- a/packages/css-tokenizer/CHANGELOG.md +++ b/packages/css-tokenizer/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to CSS Tokenizer +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.0.4 _May 27, 2025_ diff --git a/packages/css-tokenizer/dist/index.cjs b/packages/css-tokenizer/dist/index.cjs deleted file mode 100644 index 4c84b1d5b..000000000 --- a/packages/css-tokenizer/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";class ParseError extends Error{sourceStart;sourceEnd;parserState;constructor(e,n,o,t){super(e),this.name="ParseError",this.sourceStart=n,this.sourceEnd=o,this.parserState=t}}class ParseErrorWithToken extends ParseError{token;constructor(e,n,o,t,r){super(e,n,o,t),this.token=r}}const e={UnexpectedNewLineInString:"Unexpected newline while consuming a string token.",UnexpectedEOFInString:"Unexpected EOF while consuming a string token.",UnexpectedEOFInComment:"Unexpected EOF while consuming a comment.",UnexpectedEOFInURL:"Unexpected EOF while consuming a url token.",UnexpectedEOFInEscapedCodePoint:"Unexpected EOF while consuming an escaped code point.",UnexpectedCharacterInURL:"Unexpected character while consuming a url token.",InvalidEscapeSequenceInURL:"Invalid escape sequence while consuming a url token.",InvalidEscapeSequenceAfterBackslash:'Invalid escape sequence after "\\"'},n="undefined"!=typeof globalThis&&"structuredClone"in globalThis;const o=13,t=45,r=10,s=43,i=65533;function checkIfFourCodePointsWouldStartCDO(e){return 60===e.source.codePointAt(e.cursor)&&33===e.source.codePointAt(e.cursor+1)&&e.source.codePointAt(e.cursor+2)===t&&e.source.codePointAt(e.cursor+3)===t}function isDigitCodePoint(e){return e>=48&&e<=57}function isUppercaseLetterCodePoint(e){return e>=65&&e<=90}function isLowercaseLetterCodePoint(e){return e>=97&&e<=122}function isHexDigitCodePoint(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function isLetterCodePoint(e){return isLowercaseLetterCodePoint(e)||isUppercaseLetterCodePoint(e)}function isIdentStartCodePoint(e){return isLetterCodePoint(e)||isNonASCII_IdentCodePoint(e)||95===e}function isIdentCodePoint(e){return isIdentStartCodePoint(e)||isDigitCodePoint(e)||e===t}function isNonASCII_IdentCodePoint(e){return 183===e||8204===e||8205===e||8255===e||8256===e||8204===e||(192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=893||895<=e&&e<=8191||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||63744<=e&&e<=64975||65008<=e&&e<=65533||(0===e||(!!isSurrogate(e)||e>=65536)))}function isNonPrintableCodePoint(e){return 11===e||127===e||0<=e&&e<=8||14<=e&&e<=31}function isNewLine(e){return e===r||e===o||12===e}function isWhitespace(e){return 32===e||e===r||9===e||e===o||12===e}function isSurrogate(e){return e>=55296&&e<=57343}function checkIfTwoCodePointsAreAValidEscape(e){return 92===e.source.codePointAt(e.cursor)&&!isNewLine(e.source.codePointAt(e.cursor+1)??-1)}function checkIfThreeCodePointsWouldStartAnIdentSequence(e,n){return n.source.codePointAt(n.cursor)===t?n.source.codePointAt(n.cursor+1)===t||(!!isIdentStartCodePoint(n.source.codePointAt(n.cursor+1)??-1)||92===n.source.codePointAt(n.cursor+1)&&!isNewLine(n.source.codePointAt(n.cursor+2)??-1)):!!isIdentStartCodePoint(n.source.codePointAt(n.cursor)??-1)||checkIfTwoCodePointsAreAValidEscape(n)}function checkIfThreeCodePointsWouldStartANumber(e){return e.source.codePointAt(e.cursor)===s||e.source.codePointAt(e.cursor)===t?!!isDigitCodePoint(e.source.codePointAt(e.cursor+1)??-1)||46===e.source.codePointAt(e.cursor+1)&&isDigitCodePoint(e.source.codePointAt(e.cursor+2)??-1):46===e.source.codePointAt(e.cursor)?isDigitCodePoint(e.source.codePointAt(e.cursor+1)??-1):isDigitCodePoint(e.source.codePointAt(e.cursor)??-1)}function checkIfTwoCodePointsStartAComment(e){return 47===e.source.codePointAt(e.cursor)&&42===e.source.codePointAt(e.cursor+1)}function checkIfThreeCodePointsWouldStartCDC(e){return e.source.codePointAt(e.cursor)===t&&e.source.codePointAt(e.cursor+1)===t&&62===e.source.codePointAt(e.cursor+2)}var c,a,u;function consumeComment(n,o){for(o.advanceCodePoint(2);;){const t=o.readCodePoint();if(void 0===t){const t=[exports.TokenType.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInComment,o.representationStart,o.representationEnd,["4.3.2. Consume comments","Unexpected EOF"],t)),t}if(42===t&&(void 0!==o.source.codePointAt(o.cursor)&&47===o.source.codePointAt(o.cursor))){o.advanceCodePoint();break}}return[exports.TokenType.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0]}function consumeEscapedCodePoint(n,t){const s=t.readCodePoint();if(void 0===s)return n.onParseError(new ParseError(e.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,["4.3.7. Consume an escaped code point","Unexpected EOF"])),i;if(isHexDigitCodePoint(s)){const e=[s];let n;for(;void 0!==(n=t.source.codePointAt(t.cursor))&&isHexDigitCodePoint(n)&&e.length<6;)e.push(n),t.advanceCodePoint();isWhitespace(t.source.codePointAt(t.cursor)??-1)&&(t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r&&t.advanceCodePoint(),t.advanceCodePoint());const c=parseInt(String.fromCodePoint(...e),16);return 0===c||isSurrogate(c)||c>1114111?i:c}return 0===s||isSurrogate(s)?i:s}function consumeIdentSequence(e,n){const o=[];for(;;){const t=n.source.codePointAt(n.cursor)??-1;if(0===t||isSurrogate(t))o.push(i),n.advanceCodePoint(+(t>65535)+1);else if(isIdentCodePoint(t))o.push(t),n.advanceCodePoint(+(t>65535)+1);else{if(!checkIfTwoCodePointsAreAValidEscape(n))return o;n.advanceCodePoint(),o.push(consumeEscapedCodePoint(e,n))}}}function consumeHashToken(e,n){n.advanceCodePoint();const o=n.source.codePointAt(n.cursor);if(void 0!==o&&(isIdentCodePoint(o)||checkIfTwoCodePointsAreAValidEscape(n))){let o=exports.HashType.Unrestricted;checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)&&(o=exports.HashType.ID);const t=consumeIdentSequence(e,n);return[exports.TokenType.Hash,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...t),type:o}]}return[exports.TokenType.Delim,"#",n.representationStart,n.representationEnd,{value:"#"}]}function consumeNumber(e,n){let o=exports.NumberType.Integer;for(n.source.codePointAt(n.cursor)!==s&&n.source.codePointAt(n.cursor)!==t||n.advanceCodePoint();isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();if(46===n.source.codePointAt(n.cursor)&&isDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))for(n.advanceCodePoint(2),o=exports.NumberType.Number;isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();if(101===n.source.codePointAt(n.cursor)||69===n.source.codePointAt(n.cursor)){if(isDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))n.advanceCodePoint(2);else{if(n.source.codePointAt(n.cursor+1)!==t&&n.source.codePointAt(n.cursor+1)!==s||!isDigitCodePoint(n.source.codePointAt(n.cursor+2)??-1))return o;n.advanceCodePoint(3)}for(o=exports.NumberType.Number;isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint()}return o}function consumeNumericToken(e,n){let o;{const e=n.source.codePointAt(n.cursor);e===t?o="-":e===s&&(o="+")}const r=consumeNumber(0,n),i=parseFloat(n.source.slice(n.representationStart,n.representationEnd+1));if(checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)){const t=consumeIdentSequence(e,n);return[exports.TokenType.Dimension,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o,type:r,unit:String.fromCodePoint(...t)}]}return 37===n.source.codePointAt(n.cursor)?(n.advanceCodePoint(),[exports.TokenType.Percentage,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o}]):[exports.TokenType.Number,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o,type:r}]}function consumeWhiteSpace(e){for(;isWhitespace(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return[exports.TokenType.Whitespace,e.source.slice(e.representationStart,e.representationEnd+1),e.representationStart,e.representationEnd,void 0]}exports.TokenType=void 0,(c=exports.TokenType||(exports.TokenType={})).Comment="comment",c.AtKeyword="at-keyword-token",c.BadString="bad-string-token",c.BadURL="bad-url-token",c.CDC="CDC-token",c.CDO="CDO-token",c.Colon="colon-token",c.Comma="comma-token",c.Delim="delim-token",c.Dimension="dimension-token",c.EOF="EOF-token",c.Function="function-token",c.Hash="hash-token",c.Ident="ident-token",c.Number="number-token",c.Percentage="percentage-token",c.Semicolon="semicolon-token",c.String="string-token",c.URL="url-token",c.Whitespace="whitespace-token",c.OpenParen="(-token",c.CloseParen=")-token",c.OpenSquare="[-token",c.CloseSquare="]-token",c.OpenCurly="{-token",c.CloseCurly="}-token",c.UnicodeRange="unicode-range-token",exports.NumberType=void 0,(a=exports.NumberType||(exports.NumberType={})).Integer="integer",a.Number="number",exports.HashType=void 0,(u=exports.HashType||(exports.HashType={})).Unrestricted="unrestricted",u.ID="id";class Reader{cursor=0;source="";representationStart=0;representationEnd=-1;constructor(e){this.source=e}advanceCodePoint(e=1){this.cursor=this.cursor+e,this.representationEnd=this.cursor-1}readCodePoint(){const e=this.source.codePointAt(this.cursor);if(void 0!==e)return this.cursor=this.cursor+1,this.representationEnd=this.cursor-1,e}unreadCodePoint(e=1){this.cursor=this.cursor-e,this.representationEnd=this.cursor-1}resetRepresentation(){this.representationStart=this.cursor,this.representationEnd=-1}}function consumeStringToken(n,t){let s="";const c=t.readCodePoint();for(;;){const a=t.readCodePoint();if(void 0===a){const o=[exports.TokenType.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:s}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInString,t.representationStart,t.representationEnd,["4.3.5. Consume a string token","Unexpected EOF"],o)),o}if(isNewLine(a)){t.unreadCodePoint();const s=[exports.TokenType.BadString,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedNewLineInString,t.representationStart,t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r?t.representationEnd+2:t.representationEnd+1,["4.3.5. Consume a string token","Unexpected newline"],s)),s}if(a===c)return[exports.TokenType.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:s}];if(92!==a)0===a||isSurrogate(a)?s+=String.fromCodePoint(i):s+=String.fromCodePoint(a);else{if(void 0===t.source.codePointAt(t.cursor))continue;if(isNewLine(t.source.codePointAt(t.cursor)??-1)){t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r&&t.advanceCodePoint(),t.advanceCodePoint();continue}s+=String.fromCodePoint(consumeEscapedCodePoint(n,t))}}}function checkIfCodePointsMatchURLIdent(e){return!(3!==e.length||117!==e[0]&&85!==e[0]||114!==e[1]&&82!==e[1]||108!==e[2]&&76!==e[2])}function consumeBadURL(e,n){for(;;){const o=n.source.codePointAt(n.cursor);if(void 0===o)return;if(41===o)return void n.advanceCodePoint();checkIfTwoCodePointsAreAValidEscape(n)?(n.advanceCodePoint(),consumeEscapedCodePoint(e,n)):n.advanceCodePoint()}}function consumeUrlToken(n,o){for(;isWhitespace(o.source.codePointAt(o.cursor)??-1);)o.advanceCodePoint();let t="";for(;;){if(void 0===o.source.codePointAt(o.cursor)){const r=[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected EOF"],r)),r}if(41===o.source.codePointAt(o.cursor))return o.advanceCodePoint(),[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];if(isWhitespace(o.source.codePointAt(o.cursor)??-1)){for(o.advanceCodePoint();isWhitespace(o.source.codePointAt(o.cursor)??-1);)o.advanceCodePoint();if(void 0===o.source.codePointAt(o.cursor)){const r=[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Consume as much whitespace as possible","Unexpected EOF"],r)),r}return 41===o.source.codePointAt(o.cursor)?(o.advanceCodePoint(),[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}]):(consumeBadURL(n,o),[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0])}const r=o.source.codePointAt(o.cursor);if(34===r||39===r||40===r||isNonPrintableCodePoint(r??-1)){consumeBadURL(n,o);const t=[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedCharacterInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected U+0022 QUOTATION MARK (\"), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point"],t)),t}if(92===r){if(checkIfTwoCodePointsAreAValidEscape(o)){o.advanceCodePoint(),t+=String.fromCodePoint(consumeEscapedCodePoint(n,o));continue}consumeBadURL(n,o);const r=[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"],r)),r}0===o.source.codePointAt(o.cursor)||isSurrogate(o.source.codePointAt(o.cursor)??-1)?(t+=String.fromCodePoint(i),o.advanceCodePoint()):(t+=o.source[o.cursor],o.advanceCodePoint())}}function consumeIdentLikeToken(e,n){const o=consumeIdentSequence(e,n);if(40!==n.source.codePointAt(n.cursor))return[exports.TokenType.Ident,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}];if(checkIfCodePointsMatchURLIdent(o)){n.advanceCodePoint();let t=0;for(;;){const e=isWhitespace(n.source.codePointAt(n.cursor)??-1),r=isWhitespace(n.source.codePointAt(n.cursor+1)??-1);if(e&&r){t+=1,n.advanceCodePoint(1);continue}const s=e?n.source.codePointAt(n.cursor+1):n.source.codePointAt(n.cursor);if(34===s||39===s)return t>0&&n.unreadCodePoint(t),[exports.TokenType.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}];break}return consumeUrlToken(e,n)}return n.advanceCodePoint(),[exports.TokenType.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}]}function checkIfThreeCodePointsWouldStartAUnicodeRange(e){return!(117!==e.source.codePointAt(e.cursor)&&85!==e.source.codePointAt(e.cursor)||e.source.codePointAt(e.cursor+1)!==s||63!==e.source.codePointAt(e.cursor+2)&&!isHexDigitCodePoint(e.source.codePointAt(e.cursor+2)??-1))}function consumeUnicodeRangeToken(e,n){n.advanceCodePoint(2);const o=[],r=[];let s;for(;void 0!==(s=n.source.codePointAt(n.cursor))&&o.length<6&&isHexDigitCodePoint(s);)o.push(s),n.advanceCodePoint();for(;void 0!==(s=n.source.codePointAt(n.cursor))&&o.length<6&&63===s;)0===r.length&&r.push(...o),o.push(48),r.push(70),n.advanceCodePoint();if(!r.length&&n.source.codePointAt(n.cursor)===t&&isHexDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))for(n.advanceCodePoint();void 0!==(s=n.source.codePointAt(n.cursor))&&r.length<6&&isHexDigitCodePoint(s);)r.push(s),n.advanceCodePoint();if(!r.length){const e=parseInt(String.fromCodePoint(...o),16);return[exports.TokenType.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:e,endOfRange:e}]}const i=parseInt(String.fromCodePoint(...o),16),c=parseInt(String.fromCodePoint(...r),16);return[exports.TokenType.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:i,endOfRange:c}]}function tokenizer(n,i){const c=n.css.valueOf(),a=n.unicodeRangesAllowed??!1,u=new Reader(c),d={onParseError:i?.onParseError??noop};return{nextToken:function nextToken(){u.resetRepresentation();const n=u.source.codePointAt(u.cursor);if(void 0===n)return[exports.TokenType.EOF,"",-1,-1,void 0];if(47===n&&checkIfTwoCodePointsStartAComment(u))return consumeComment(d,u);if(a&&(117===n||85===n)&&checkIfThreeCodePointsWouldStartAUnicodeRange(u))return consumeUnicodeRangeToken(0,u);if(isIdentStartCodePoint(n))return consumeIdentLikeToken(d,u);if(isDigitCodePoint(n))return consumeNumericToken(d,u);switch(n){case 44:return u.advanceCodePoint(),[exports.TokenType.Comma,",",u.representationStart,u.representationEnd,void 0];case 58:return u.advanceCodePoint(),[exports.TokenType.Colon,":",u.representationStart,u.representationEnd,void 0];case 59:return u.advanceCodePoint(),[exports.TokenType.Semicolon,";",u.representationStart,u.representationEnd,void 0];case 40:return u.advanceCodePoint(),[exports.TokenType.OpenParen,"(",u.representationStart,u.representationEnd,void 0];case 41:return u.advanceCodePoint(),[exports.TokenType.CloseParen,")",u.representationStart,u.representationEnd,void 0];case 91:return u.advanceCodePoint(),[exports.TokenType.OpenSquare,"[",u.representationStart,u.representationEnd,void 0];case 93:return u.advanceCodePoint(),[exports.TokenType.CloseSquare,"]",u.representationStart,u.representationEnd,void 0];case 123:return u.advanceCodePoint(),[exports.TokenType.OpenCurly,"{",u.representationStart,u.representationEnd,void 0];case 125:return u.advanceCodePoint(),[exports.TokenType.CloseCurly,"}",u.representationStart,u.representationEnd,void 0];case 39:case 34:return consumeStringToken(d,u);case 35:return consumeHashToken(d,u);case s:case 46:return checkIfThreeCodePointsWouldStartANumber(u)?consumeNumericToken(d,u):(u.advanceCodePoint(),[exports.TokenType.Delim,u.source[u.representationStart],u.representationStart,u.representationEnd,{value:u.source[u.representationStart]}]);case r:case o:case 12:case 9:case 32:return consumeWhiteSpace(u);case t:return checkIfThreeCodePointsWouldStartANumber(u)?consumeNumericToken(d,u):checkIfThreeCodePointsWouldStartCDC(u)?(u.advanceCodePoint(3),[exports.TokenType.CDC,"--\x3e",u.representationStart,u.representationEnd,void 0]):checkIfThreeCodePointsWouldStartAnIdentSequence(0,u)?consumeIdentLikeToken(d,u):(u.advanceCodePoint(),[exports.TokenType.Delim,"-",u.representationStart,u.representationEnd,{value:"-"}]);case 60:return checkIfFourCodePointsWouldStartCDO(u)?(u.advanceCodePoint(4),[exports.TokenType.CDO,"\x3c!--",u.representationStart,u.representationEnd,void 0]):(u.advanceCodePoint(),[exports.TokenType.Delim,"<",u.representationStart,u.representationEnd,{value:"<"}]);case 64:if(u.advanceCodePoint(),checkIfThreeCodePointsWouldStartAnIdentSequence(0,u)){const e=consumeIdentSequence(d,u);return[exports.TokenType.AtKeyword,u.source.slice(u.representationStart,u.representationEnd+1),u.representationStart,u.representationEnd,{value:String.fromCodePoint(...e)}]}return[exports.TokenType.Delim,"@",u.representationStart,u.representationEnd,{value:"@"}];case 92:{if(checkIfTwoCodePointsAreAValidEscape(u))return consumeIdentLikeToken(d,u);u.advanceCodePoint();const n=[exports.TokenType.Delim,"\\",u.representationStart,u.representationEnd,{value:"\\"}];return d.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceAfterBackslash,u.representationStart,u.representationEnd,["4.3.1. Consume a token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"],n)),n}}return u.advanceCodePoint(),[exports.TokenType.Delim,u.source[u.representationStart],u.representationStart,u.representationEnd,{value:u.source[u.representationStart]}]},endOfFile:function endOfFile(){return void 0===u.source.codePointAt(u.cursor)}}}function noop(){}function serializeIdent(e){let n=0;if(0===e[0])e.splice(0,1,i),n=1;else if(e[0]===t&&e[1]===t)n=2;else if(e[0]===t&&e[1])n=2,isIdentStartCodePoint(e[1])||(n+=insertEscapedCodePoint(e,1,e[1]));else{if(e[0]===t&&!e[1])return[92,e[0]];isIdentStartCodePoint(e[0])?n=1:(n=1,n+=insertEscapedCodePoint(e,0,e[0]))}for(let o=n;o=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/packages/generate-test-cases/package.json b/packages/generate-test-cases/package.json index f5ed7e21c..f0d53421a 100644 --- a/packages/generate-test-cases/package.json +++ b/packages/generate-test-cases/package.json @@ -16,10 +16,9 @@ ], "private": true, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "src/index.mjs", "devDependencies": { "mdn-data": "^2.25.0" }, diff --git a/packages/media-query-list-parser/CHANGELOG.md b/packages/media-query-list-parser/CHANGELOG.md index d4f9c622e..ad52c091f 100644 --- a/packages/media-query-list-parser/CHANGELOG.md +++ b/packages/media-query-list-parser/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to Media Query List Parser +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.3 _May 27, 2025_ diff --git a/packages/media-query-list-parser/dist/index.cjs b/packages/media-query-list-parser/dist/index.cjs deleted file mode 100644 index 27caad794..000000000 --- a/packages/media-query-list-parser/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e,t=require("@csstools/css-parser-algorithms"),i=require("@csstools/css-tokenizer");exports.NodeType=void 0,(e=exports.NodeType||(exports.NodeType={})).CustomMedia="custom-media",e.GeneralEnclosed="general-enclosed",e.MediaAnd="media-and",e.MediaCondition="media-condition",e.MediaConditionListWithAnd="media-condition-list-and",e.MediaConditionListWithOr="media-condition-list-or",e.MediaFeature="media-feature",e.MediaFeatureBoolean="mf-boolean",e.MediaFeatureName="mf-name",e.MediaFeaturePlain="mf-plain",e.MediaFeatureRangeNameValue="mf-range-name-value",e.MediaFeatureRangeValueName="mf-range-value-name",e.MediaFeatureRangeValueNameValue="mf-range-value-name-value",e.MediaFeatureValue="mf-value",e.MediaInParens="media-in-parens",e.MediaNot="media-not",e.MediaOr="media-or",e.MediaQueryWithType="media-query-with-type",e.MediaQueryWithoutType="media-query-without-type",e.MediaQueryInvalid="media-query-invalid";class MediaCondition{type=exports.NodeType.MediaCondition;media;constructor(e){this.media=e}tokens(){return this.media.tokens()}toString(){return this.media.toString()}hasLeadingSpace(){return this.media.hasLeadingSpace()}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&this.media.walk(e,i)}toJSON(){return{type:this.type,media:this.media.toJSON()}}isMediaCondition(){return MediaCondition.isMediaCondition(this)}static isMediaCondition(e){return!!e&&(e instanceof MediaCondition&&e.type===exports.NodeType.MediaCondition)}}class MediaInParens{type=exports.NodeType.MediaInParens;media;before;after;constructor(e,t=[],i=[]){this.media=e,this.before=t,this.after=i}tokens(){return[...this.before,...this.media.tokens(),...this.after]}toString(){return i.stringify(...this.before)+this.media.toString()+i.stringify(...this.after)}hasLeadingSpace(){return this.before.length?i.isTokenWhiteSpaceOrComment(this.before[0]):this.media.hasLeadingSpace()}indexOf(e){return e===this.media?"media":-1}at(e){if("media"===e)return this.media}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.media,parent:this,state:i},"media")&&("walk"in this.media?this.media.walk(e,i):void 0)}toJSON(){return{type:this.type,media:this.media.toJSON(),before:this.before,after:this.after}}isMediaInParens(){return MediaInParens.isMediaInParens(this)}static isMediaInParens(e){return!!e&&(e instanceof MediaInParens&&e.type===exports.NodeType.MediaInParens)}}class MediaQueryWithType{type=exports.NodeType.MediaQueryWithType;modifier;mediaType;and=void 0;media=void 0;constructor(e,t,i,a){this.modifier=e,this.mediaType=t,i&&a&&(this.and=i,this.media=a)}getModifier(){if(!this.modifier.length)return"";for(let e=0;ee.tokens())}toString(){return this.media.map(e=>e.toString()).join("")}walk(e,i){if(0===this.media.length)return;const a=t.walkerIndexGenerator(this.media);let r=0;for(;re.tokens()),...this.after]}toString(){return i.stringify(...this.before)+this.leading.toString()+this.list.map(e=>e.toString()).join("")+i.stringify(...this.after)}hasLeadingSpace(){return this.before.length?i.isTokenWhiteSpaceOrComment(this.before[0]):this.leading.hasLeadingSpace()}indexOf(e){return e===this.leading?"leading":e.type===exports.NodeType.MediaAnd?this.list.indexOf(e):-1}at(e){return"leading"===e?this.leading:"number"==typeof e?(e<0&&(e=this.list.length+e),this.list[e]):void 0}walk(e,i){let a;if(i&&(a={...i}),!1===e({node:this.leading,parent:this,state:a},"leading"))return!1;if("walk"in this.leading&&!1===this.leading.walk(e,a))return!1;if(0===this.list.length)return;const r=t.walkerIndexGenerator(this.list);let n=0;for(;ne.toJSON()),before:this.before,after:this.after}}isMediaConditionListWithAnd(){return MediaConditionListWithAnd.isMediaConditionListWithAnd(this)}static isMediaConditionListWithAnd(e){return!!e&&(e instanceof MediaConditionListWithAnd&&e.type===exports.NodeType.MediaConditionListWithAnd)}}class MediaConditionListWithOr{type=exports.NodeType.MediaConditionListWithOr;leading;list;before;after;constructor(e,t,i=[],a=[]){this.leading=e,this.list=t,this.before=i,this.after=a}tokens(){return[...this.before,...this.leading.tokens(),...this.list.flatMap(e=>e.tokens()),...this.after]}toString(){return i.stringify(...this.before)+this.leading.toString()+this.list.map(e=>e.toString()).join("")+i.stringify(...this.after)}hasLeadingSpace(){return this.before.length?i.isTokenWhiteSpaceOrComment(this.before[0]):this.leading.hasLeadingSpace()}indexOf(e){return e===this.leading?"leading":e.type===exports.NodeType.MediaOr?this.list.indexOf(e):-1}at(e){return"leading"===e?this.leading:"number"==typeof e?(e<0&&(e=this.list.length+e),this.list[e]):void 0}walk(e,i){let a;if(i&&(a={...i}),!1===e({node:this.leading,parent:this,state:a},"leading"))return!1;if("walk"in this.leading&&!1===this.leading.walk(e,a))return!1;if(0===this.list.length)return;const r=t.walkerIndexGenerator(this.list);let n=0;for(;ne.toJSON()),before:this.before,after:this.after}}isMediaConditionListWithOr(){return MediaConditionListWithOr.isMediaConditionListWithOr(this)}static isMediaConditionListWithOr(e){return!!e&&(e instanceof MediaConditionListWithOr&&e.type===exports.NodeType.MediaConditionListWithOr)}}function isNumber(e){return!!(t.isTokenNode(e)&&i.isTokenNumber(e.value)||t.isFunctionNode(e)&&a.has(e.getName().toLowerCase()))}const a=new Set(["abs","acos","asin","atan","atan2","calc","clamp","cos","exp","hypot","log","max","min","mod","pow","rem","round","sign","sin","sqrt","tan"]);function isDimension(e){return t.isTokenNode(e)&&i.isTokenDimension(e.value)}function isIdent(e){return t.isTokenNode(e)&&i.isTokenIdent(e.value)}function isEnvironmentVariable(e){return t.isFunctionNode(e)&&"env"===e.getName().toLowerCase()}class MediaFeatureName{type=exports.NodeType.MediaFeatureName;name;before;after;constructor(e,t=[],i=[]){this.name=e,this.before=t,this.after=i}getName(){return this.name.value[4].value}getNameToken(){return this.name.value}tokens(){return[...this.before,...this.name.tokens(),...this.after]}toString(){return i.stringify(...this.before)+this.name.toString()+i.stringify(...this.after)}indexOf(e){return e===this.name?"name":-1}at(e){if("name"===e)return this.name}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens()}}isMediaFeatureName(){return MediaFeatureName.isMediaFeatureName(this)}static isMediaFeatureName(e){return!!e&&(e instanceof MediaFeatureName&&e.type===exports.NodeType.MediaFeatureName)}}function parseMediaFeatureName(e){let i=-1;for(let a=0;ae.tokens()),e.slice(i+1).flatMap(e=>e.tokens()))}class MediaFeatureBoolean{type=exports.NodeType.MediaFeatureBoolean;name;constructor(e){this.name=e}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return this.name.tokens()}toString(){return this.name.toString()}indexOf(e){return e===this.name?"name":-1}at(e){if("name"===e)return this.name}toJSON(){return{type:this.type,name:this.name.toJSON(),tokens:this.tokens()}}isMediaFeatureBoolean(){return MediaFeatureBoolean.isMediaFeatureBoolean(this)}static isMediaFeatureBoolean(e){return!!e&&(e instanceof MediaFeatureBoolean&&e.type===exports.NodeType.MediaFeatureBoolean)}}function parseMediaFeatureBoolean(e){const t=parseMediaFeatureName(e);return!1===t?t:new MediaFeatureBoolean(t)}class MediaFeatureValue{type=exports.NodeType.MediaFeatureValue;value;before;after;constructor(e,t=[],i=[]){Array.isArray(e)&&1===e.length?this.value=e[0]:this.value=e,this.before=t,this.after=i}tokens(){return Array.isArray(this.value)?[...this.before,...this.value.flatMap(e=>e.tokens()),...this.after]:[...this.before,...this.value.tokens(),...this.after]}toString(){return Array.isArray(this.value)?i.stringify(...this.before)+this.value.map(e=>e.toString()).join("")+i.stringify(...this.after):i.stringify(...this.before)+this.value.toString()+i.stringify(...this.after)}indexOf(e){return e===this.value?"value":-1}at(e){return"value"===e?this.value:Array.isArray(this.value)&&"number"==typeof e?(e<0&&(e=this.value.length+e),this.value[e]):void 0}walk(e,i){if(Array.isArray(this.value)){if(0===this.value.length)return;const a=t.walkerIndexGenerator(this.value);let r=0;for(;re.toJSON()),tokens:this.tokens()}:{type:this.type,value:this.value.toJSON(),tokens:this.tokens()}}isMediaFeatureValue(){return MediaFeatureValue.isMediaFeatureValue(this)}static isMediaFeatureValue(e){return!!e&&(e instanceof MediaFeatureValue&&e.type===exports.NodeType.MediaFeatureValue)}}function parseMediaFeatureValue(e,i=!1){let a=-1,r=-1;for(let n=0;ne.tokens()),e.slice(r+1).flatMap(e=>e.tokens()))}function matchesRatioExactly(e){let i=-1,a=-1;const r=matchesRatio(e);if(-1===r)return-1;i=r[0],a=r[1];for(let i=a+1;i",n.GT_OR_EQ=">=",exports.MediaFeatureEQ=void 0,(exports.MediaFeatureEQ||(exports.MediaFeatureEQ={})).EQ="=";class MediaFeatureRangeNameValue{type=exports.NodeType.MediaFeatureRangeNameValue;name;operator;value;constructor(e,t,i){this.name=e,this.operator=t,this.value=i}operatorKind(){return comparisonFromTokens(this.operator)}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return[...this.name.tokens(),...this.operator,...this.value.tokens()]}toString(){return this.name.toString()+i.stringify(...this.operator)+this.value.toString()}indexOf(e){return e===this.name?"name":e===this.value?"value":-1}at(e){return"name"===e?this.name:"value"===e?this.value:void 0}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.value,parent:this,state:i},"value")&&("walk"in this.value?this.value.walk(e,i):void 0)}toJSON(){return{type:this.type,name:this.name.toJSON(),value:this.value.toJSON(),tokens:this.tokens()}}isMediaFeatureRangeNameValue(){return MediaFeatureRangeNameValue.isMediaFeatureRangeNameValue(this)}static isMediaFeatureRangeNameValue(e){return!!e&&(e instanceof MediaFeatureRangeNameValue&&e.type===exports.NodeType.MediaFeatureRangeNameValue)}}class MediaFeatureRangeValueName{type=exports.NodeType.MediaFeatureRangeValueName;name;operator;value;constructor(e,t,i){this.name=e,this.operator=t,this.value=i}operatorKind(){return comparisonFromTokens(this.operator)}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return[...this.value.tokens(),...this.operator,...this.name.tokens()]}toString(){return this.value.toString()+i.stringify(...this.operator)+this.name.toString()}indexOf(e){return e===this.name?"name":e===this.value?"value":-1}at(e){return"name"===e?this.name:"value"===e?this.value:void 0}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.value,parent:this,state:i},"value")&&("walk"in this.value?this.value.walk(e,i):void 0)}toJSON(){return{type:this.type,name:this.name.toJSON(),value:this.value.toJSON(),tokens:this.tokens()}}isMediaFeatureRangeValueName(){return MediaFeatureRangeValueName.isMediaFeatureRangeValueName(this)}static isMediaFeatureRangeValueName(e){return!!e&&(e instanceof MediaFeatureRangeValueName&&e.type===exports.NodeType.MediaFeatureRangeValueName)}}class MediaFeatureRangeValueNameValue{type=exports.NodeType.MediaFeatureRangeValueNameValue;name;valueOne;valueOneOperator;valueTwo;valueTwoOperator;constructor(e,t,i,a,r){this.name=e,this.valueOne=t,this.valueOneOperator=i,this.valueTwo=a,this.valueTwoOperator=r}valueOneOperatorKind(){return comparisonFromTokens(this.valueOneOperator)}valueTwoOperatorKind(){return comparisonFromTokens(this.valueTwoOperator)}getName(){return this.name.getName()}getNameToken(){return this.name.getNameToken()}tokens(){return[...this.valueOne.tokens(),...this.valueOneOperator,...this.name.tokens(),...this.valueTwoOperator,...this.valueTwo.tokens()]}toString(){return this.valueOne.toString()+i.stringify(...this.valueOneOperator)+this.name.toString()+i.stringify(...this.valueTwoOperator)+this.valueTwo.toString()}indexOf(e){return e===this.name?"name":e===this.valueOne?"valueOne":e===this.valueTwo?"valueTwo":-1}at(e){return"name"===e?this.name:"valueOne"===e?this.valueOne:"valueTwo"===e?this.valueTwo:void 0}walk(e,t){let i;return t&&(i={...t}),!1!==e({node:this.valueOne,parent:this,state:i},"valueOne")&&((!("walk"in this.valueOne)||!1!==this.valueOne.walk(e,i))&&(t&&(i={...t}),!1!==e({node:this.valueTwo,parent:this,state:i},"valueTwo")&&((!("walk"in this.valueTwo)||!1!==this.valueTwo.walk(e,i))&&void 0)))}toJSON(){return{type:this.type,name:this.name.toJSON(),valueOne:this.valueOne.toJSON(),valueTwo:this.valueTwo.toJSON(),tokens:this.tokens()}}isMediaFeatureRangeValueNameValue(){return MediaFeatureRangeValueNameValue.isMediaFeatureRangeValueNameValue(this)}static isMediaFeatureRangeValueNameValue(e){return!!e&&(e instanceof MediaFeatureRangeValueNameValue&&e.type===exports.NodeType.MediaFeatureRangeValueNameValue)}}function parseMediaFeatureRange(e){let a=!1,r=!1;for(let n=0;ne.tokens()),-1!==r&&(o=e.slice(a+1,r+1).flatMap(e=>e.tokens()))):-1!==r&&(o=e.slice(0,r+1).flatMap(e=>e.tokens()));const u=parseMediaConditionWithoutOr(e.slice(Math.max(a,r,n)+1));return!1===u?new MediaQueryWithType(s,[...o,...e.slice(r+1).flatMap(e=>e.tokens())]):new MediaQueryWithType(s,o,e.slice(r+1,n+1).flatMap(e=>e.tokens()),u)}}function parseMediaConditionListWithOr(e){let i=!1;const a=[];let r=-1,n=-1;for(let s=0;se.tokens()),e.slice(n+1).flatMap(e=>e.tokens()))}function parseMediaConditionListWithAnd(e){let i=!1;const a=[];let r=-1,n=-1;for(let s=0;se.tokens()),e.slice(n+1).flatMap(e=>e.tokens()))}function parseMediaCondition(e){const t=parseMediaNot(e);if(!1!==t)return new MediaCondition(t);const i=parseMediaConditionListWithAnd(e);if(!1!==i)return new MediaCondition(i);const a=parseMediaConditionListWithOr(e);if(!1!==a)return new MediaCondition(a);const r=parseMediaInParens(e);return!1!==r&&new MediaCondition(r)}function parseMediaConditionWithoutOr(e){const t=parseMediaNot(e);if(!1!==t)return new MediaCondition(t);const i=parseMediaConditionListWithAnd(e);if(!1!==i)return new MediaCondition(i);const a=parseMediaInParens(e);return!1!==a&&new MediaCondition(a)}function parseMediaInParens(e){let a=-1;for(let i=0;ie.tokens()),r.startToken],s=[r.endToken,...e.slice(a+1).flatMap(e=>e.tokens())],o=parseMediaFeature(r,n,s);if(!1!==o)return new MediaInParens(o);const u=parseMediaCondition(r.value);return!1!==u?new MediaInParens(u,n,s):new MediaInParens(new GeneralEnclosed(r),e.slice(0,a).flatMap(e=>e.tokens()),e.slice(a+1).flatMap(e=>e.tokens()))}function parseMediaInParensFromSimpleBlock(e){if(!i.isTokenOpenParen(e.startToken))return!1;const t=parseMediaFeature(e,[e.startToken],[e.endToken]);if(!1!==t)return new MediaInParens(t);const a=parseMediaCondition(e.value);return!1!==a?new MediaInParens(a,[e.startToken],[e.endToken]):new MediaInParens(new GeneralEnclosed(e))}exports.MediaQueryModifier=void 0,(s=exports.MediaQueryModifier||(exports.MediaQueryModifier={})).Not="not",s.Only="only";const o=/^not$/i;function parseMediaNot(e){let i=!1,a=null;for(let r=0;re.tokens()),t);continue}return!1}}return a||!1}const u=/^or$/i;function parseMediaOr(e){let i=!1;for(let a=0;ae.tokens()),t)}}return!1}}return!1}const d=/^and$/i;function parseMediaAnd(e){let i=!1;for(let a=0;ae.tokens()),t)}}return!1}}return!1}function parseFromTokens(e,i){const a=t.parseCommaSeparatedListOfComponentValues(e,{onParseError:i?.onParseError});return a.map((e,t)=>{const r=parseMediaQuery(e);return!1===r&&!0===i?.preserveInvalidMediaQueries?new MediaQueryInvalid(a[t]):r}).filter(e=>!!e)}class CustomMedia{type=exports.NodeType.CustomMedia;name;mediaQueryList=null;trueOrFalseKeyword=null;constructor(e,t,i){this.name=e,this.mediaQueryList=t,this.trueOrFalseKeyword=i??null}getName(){for(let e=0;ee.toJSON())}}isCustomMedia(){return CustomMedia.isCustomMedia(this)}static isCustomMedia(e){return!!e&&(e instanceof CustomMedia&&e.type===exports.NodeType.CustomMedia)}}function parseCustomMediaFromTokens(e,t){let a=[],r=e;for(let t=0;t=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/packages/pack-test/CHANGELOG.md b/packages/pack-test/CHANGELOG.md index a4e8862df..ec9eeab69 100644 --- a/packages/pack-test/CHANGELOG.md +++ b/packages/pack-test/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to Pack Test +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 1.0.2 _September 21, 2025_ diff --git a/packages/pack-test/dist/index.cjs b/packages/pack-test/dist/index.cjs deleted file mode 100644 index 4abadd7e4..000000000 --- a/packages/pack-test/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("node:url"),n=require("node:fs/promises"),t=require("node:path"),i=require("node:os"),o=require("node:process"),a=require("node:child_process"),r="undefined"!=typeof document?document.currentScript:null;const s="package";async function findPackageJsonFromDir(e,i=10){const o=t.join(e,"package.json");try{return await n.access(o),o}catch{if("/"===e||i<=0)throw new Error("Could not find package.json")}return findPackageJsonFromDir(t.dirname(e),i-1)}async function pack(e,i){const r=await n.mkdir(t.join(i,"pack"),{recursive:!0}),s=a.spawn("npm",["pack","--pack-destination",r],{cwd:e,shell:"win32"===o.platform}),c=await new Promise((e,n)=>{let t="",i="";s.stdout.on("data",e=>{t+=e.toString()}),s.stderr.on("data",e=>{i+=e.toString()}),s.on("close",o=>{0===o?e(t.trim()):(console.error(i),n(new Error(`npm pack exited with code ${o}`)))})});return t.join(r,c)}async function unpack(e,i){const o=t.join(i,s);await n.mkdir(o,{recursive:!0});const r=a.spawn("tar",["-xf",e,"-C",s,"--strip-components","1"],{cwd:i});return await new Promise((e,n)=>{r.on("close",t=>{0===t?e():n(new Error(`tar exited with code ${t}`))})}),o}async function eraseDevDependenciesInfo(e){const t=JSON.parse(await n.readFile(e,"utf8"));delete t.devDependencies,await n.writeFile(e,JSON.stringify(t,null,"\t"))}async function getPackageInfo(e){return JSON.parse(await n.readFile(e,"utf8"))}async function createRootPackage(e,i){await n.writeFile(t.join(e,"package.json"),JSON.stringify({name:"@csstools/pack-test--root",private:!0,type:"module",version:"1.0.0",description:"",workspaces:[s],dependencies:i.peerDependencies??{},scripts:{test:"node --test"}},null,"\t")),await n.writeFile(t.join(e,"index.mjs"),`import '${i.name}';`)}async function runNPMInstall(e){const n=a.spawn("npm",["install","--ignore-scripts","--omit","dev","--engine-strict","false"],{cwd:e,stdio:"inherit",shell:"win32"===o.platform});await new Promise((e,t)=>{n.on("close",n=>{0===n?e():t(new Error(`npm install exited with code ${n}`))})})}async function runTest(e){const n=a.spawn("node",["index.mjs"],{cwd:e,stdio:"inherit",shell:"win32"===o.platform});await new Promise((e,t)=>{n.on("close",n=>{0===n?e():t(new Error(`npm install exited with code ${n}`))})})}exports.testPack=async function testPack(a){if(o.platform.startsWith("win"))return void console.log("Skipping test on Windows");if(!("resolve"in{url:"undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index.cjs",document.baseURI).href}))return void console.log("Skipping test on platform without `import.meta.resolve` support");const s=await n.mkdtemp(t.join(i.tmpdir(),"csstools-pack-test-"));try{const n=new URL((void 0)(a));console.log(`Testing module: ${a}`);const i=e.fileURLToPath(n),o=await findPackageJsonFromDir(t.dirname(i)),r=t.dirname(o),c=await pack(r,s),d=await unpack(c,s),p=await getPackageInfo(t.join(d,"package.json"));await eraseDevDependenciesInfo(t.join(d,"package.json")),await createRootPackage(s,p),await runNPMInstall(s),await runTest(s)}finally{await n.rm(s,{recursive:!0})}}; diff --git a/packages/pack-test/package.json b/packages/pack-test/package.json index 50a0cbf80..497a84cc3 100644 --- a/packages/pack-test/package.json +++ b/packages/pack-test/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/packages/postcss-tape/CHANGELOG.md b/packages/postcss-tape/CHANGELOG.md index cb25b5818..8c6ac0378 100644 --- a/packages/postcss-tape/CHANGELOG.md +++ b/packages/postcss-tape/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Tape +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 6.0.1 _August 22, 2025_ diff --git a/packages/postcss-tape/dist/index.cjs b/packages/postcss-tape/dist/index.cjs deleted file mode 100644 index c8626fc6d..000000000 --- a/packages/postcss-tape/dist/index.cjs +++ /dev/null @@ -1,3 +0,0 @@ -/* node:coverage disable */ -"use strict";var e=require("node:assert/strict"),s=require("node:fs/promises"),t=require("node:fs"),n=require("node:path"),o=require("postcss"),r=require("postcss-8.4"),i=require("node:test"),a=require("node:url");const noopPlugin=()=>({postcssPlugin:"noop-plugin",Once(){}});async function fileContentsOrEmptyString(e){try{return await s.readFile(e,"utf8")}catch{return""}}function reduceInformationInCssSyntaxError(e){process.env.DEBUG||(delete e.source,e.input&&delete e.input.source,delete e.postcssNode)}noopPlugin.postcss=!0;const c={postcssPlugin:"declaration-cloner",Declaration(e){"to-clone"===e.prop&&e.cloneBefore({prop:"cloned"})}},p={postcssPlugin:"rule-cloner",prepare(){const e=new WeakSet;return{postcssPlugin:"rule-cloner",RuleExit(s){e.has(s)||"to-clone"===s.selector&&(e.add(s),s.cloneBefore({selector:"cloned"}))}}}},l={postcssPlugin:"at-rule-cloner",prepare(){const e=new WeakSet;return{postcssPlugin:"at-rule-cloner",AtRuleExit(s){if(!e.has(s))return"to-clone"===s.params?(e.add(s),void s.cloneBefore({params:"cloned"})):"to-clone"===s.name?(e.add(s),void s.cloneBefore({name:"cloned"})):void 0}}}};class PackageDescriptionError extends Error{constructor(e,s){super(e),this.name="PackageDescriptionError",this.stack=`${this.name}: ${this.message}\n at "${s}" (${a.pathToFileURL(n.resolve("package.json")).href}:1:1)`}}class OutcomeError extends Error{constructor(e,s){super(e),this.name="OutcomeError",this.stack=`${this.name}: ${this.message}\n at ${a.pathToFileURL(n.resolve(s)).href}:1:1`}}exports.atRuleClonerPlugin=l,exports.declarationClonerPlugin=c,exports.postcssTape=function postcssTape(a,c){return async p=>{c=c??{},await i("`postcss` flag is set on exported plugin creator",()=>{e.equal(a.postcss,!0)}),await i("exported plugin creator is a function",()=>{e.equal(typeof a,"function")}),await i("`postcssPlugin` is set on a plugin instance",()=>{const s=a();e.ok(s.postcssPlugin),e.equal(typeof s.postcssPlugin,"string")}),await i("package.json",async t=>{const n=await s.readFile("./package.json","utf-8"),o=JSON.parse(n);await t.test('includes "postcss-plugin" keyword',()=>{e.ok(Array.isArray(o.keywords)&&o.keywords?.includes("postcss-plugin"),new PackageDescriptionError('Missing "postcss-plugin" keyword in package.json',"keywords"))}),await t.test('name starts with "postcss-"',{skip:c?.skipPackageNameCheck},()=>{let s="string"==typeof o.name?o.name:"";if(s.startsWith("@")){const e=s.split("/");s=e.slice(1).join("/")}e.ok(s.startsWith("postcss-"),new PackageDescriptionError(`package name "${s}" does not start with "postcss-"`,"name"))}),await t.test("`postcss` is a peer dependency and not a direct dependency",{skip:"postcssTapeSelfTest"in a},()=>{e.ok(Object.keys(Object(o.peerDependencies)).includes("postcss"),new PackageDescriptionError('"postcss" must be listed in "peerDependencies"',"peerDependencies")),e.ok(!Object.keys(Object(o.dependencies)).includes("postcss"),new PackageDescriptionError('"postcss" must not be listed in "dependencies"',"dependencies"))})});const l=a().postcssPlugin;await i(l,async i=>{for(const c in p)await i.test(c,async i=>{const l=p[c];l.before&&await l.before();const u=n.join(".","test",...c.split(":")[0].split(n.posix.sep)),d=n.join(".","test",...c.replace(/:/g,".").split(n.posix.sep)),g="css";let w=`${u}.${g}`,m=`${d}.expect.${g}`,f=`${d}.result.${g}`;l.source&&(w=n.join(".","test",l.source)),l.expect&&(m=n.join(".","test",l.expect)),l.result&&(f=n.join(".","test",l.result));const k=l.plugins??[a(l.options)],h=await fileContentsOrEmptyString(w),y=await fileContentsOrEmptyString(m);let E,x=null;const P=o([noopPlugin()]).version===r([noopPlugin()]).version;try{E=await o(k).process(h,{from:w,to:f,map:{inline:!1,annotation:!1}});try{x=P?null:await r(k).process(h,{from:w,to:f,map:{inline:!1,annotation:!1}})}catch{}}catch(e){if(!(e instanceof Error))throw e;if(reduceInformationInCssSyntaxError(e),l.exception&&l.exception.test(e.message))return;throw e}e.ok(!l.exception,new OutcomeError(`expected an exception matching "${l.exception}"`,w));const S=E.css.toString();{const e=[s.writeFile(f,S,"utf8")];process.env.REWRITE_EXPECTS&&e.push(s.writeFile(m,S,"utf8")),await Promise.all(e)}y||e.ok(t.existsSync(m),new OutcomeError(`Missing expect file: "${m}"`,w)),l.after&&await l.after();const $=await fileContentsOrEmptyString(f);let q=null;try{q=await o([noopPlugin()]).process($,{from:f,to:f,map:{inline:!1,annotation:!1}})}catch{}await i.test("has expected output",()=>{e.deepEqual(S,y),e.deepEqual(E.warnings().length,l.warnings??0,`Unexpected number warnings:\n${E.warnings().toString()}`)}),await i.test("sourcemaps",()=>{e.ok(!E.map.toJSON().sources.includes(""),'Sourcemap is broken. This is most likely a newly created PostCSS AST Node without a value for "source". See: https://github.com/postcss/postcss/blob/main/docs/guidelines/plugin.md#24-set-nodesource-for-new-nodes')}),await i.test("output is parsable with PostCSS",()=>{e.deepEqual(q?.warnings(),[],"Unexpected warnings on second pass")}),await i.test("The oldest and current PostCSS version produce the same result",{skip:P},()=>{e.deepEqual(x?.css?.toString(),S)})})})}},exports.ruleClonerPlugin=p; -/* node:coverage enable */ diff --git a/packages/postcss-tape/package.json b/packages/postcss-tape/package.json index b0e216db9..b89414728 100644 --- a/packages/postcss-tape/package.json +++ b/packages/postcss-tape/package.json @@ -29,20 +29,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/packages/selector-resolve-nested/CHANGELOG.md b/packages/selector-resolve-nested/CHANGELOG.md index 971ac41d1..fb879a2ac 100644 --- a/packages/selector-resolve-nested/CHANGELOG.md +++ b/packages/selector-resolve-nested/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to Selector Resolve Nested +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.1.0 _June 6, 2025_ diff --git a/packages/selector-resolve-nested/dist/index.cjs b/packages/selector-resolve-nested/dist/index.cjs deleted file mode 100644 index 71fb21304..000000000 --- a/packages/selector-resolve-nested/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser");function sourceFrom(e){return{sourceIndex:e.sourceIndex??0,source:e.source}}function sortCompoundSelectorsInsideComplexSelector(o){const t=[];let r=[];o.each(o=>{if("combinator"===o.type)return t.push(r,[o]),void(r=[]);if(e.isPseudoElement(o))return t.push(r),void(r=[o]);if("universal"===o.type&&r.find(e=>"universal"===e.type))o.remove();else{if("tag"===o.type&&r.find(e=>"tag"===e.type)){o.remove();const t=e.selector({value:"",...sourceFrom(o)});t.append(o);const n=e.pseudo({value:":is",...sourceFrom(o)});return n.append(t),void r.push(n)}r.push(o)}}),t.push(r);const n=[];for(let e=0;eselectorTypeOrder(e)-selectorTypeOrder(o)),n.push(...o)}o.removeAll();for(let e=n.length-1;e>=0;e--)n[e].remove(),n[e].parent=o,o.nodes.unshift(n[e])}function selectorTypeOrder(t){return e.isPseudoElement(t)?o.pseudoElement:o[t.type]}const o={universal:0,tag:1,pseudoElement:2,nesting:3,id:4,class:5,attribute:6,pseudo:7,comment:8};function prepareParentSelectors(o,t=!1){if(t||!isCompoundSelector(o.nodes)){const t=e.pseudo({value:":is",...sourceFrom(o)});return o.nodes.forEach(e=>{t.append(e.clone())}),[t]}return o.nodes[0].nodes.map(e=>e.clone())}function isCompoundSelector(o){return 1===o.length&&!o[0].nodes.some(o=>"combinator"===o.type||e.isPseudoElement(o))}function combinationsWithSizeN(e,o){if(o<2)throw new Error("n must be greater than 1");if(e.length<2)throw new Error("s must be greater than 1");if(Math.pow(e.length,o)>1e4)throw new Error("Too many combinations when trying to resolve a nested selector with lists, reduce the complexity of your selectors");const t=[];for(let e=0;e=0;s--){let o=t[s];if(o>=e.length){if(o=0,t[s]=0,0===s)return r;t[s-1]+=1}n[s]=e[o].clone()}r.push(n),t[t.length-1]++}}exports.flattenNestedSelector=function flattenNestedSelector(o,t){const r=[];for(let n=0;n{o=!0,l++}),o?"combinator"===s.nodes[0]?.type&&(s.prepend(e.nesting({...sourceFrom(s)})),l++):(s.prepend(e.combinator({value:" ",...sourceFrom(s)})),s.prepend(e.nesting({...sourceFrom(s)})),l++)}let p=[];if(l>1&&t.nodes.length>1)p=combinationsWithSizeN(t.nodes,l),c=p.length;else{c=t.nodes.length;for(let e=0;e{const r=p[e][o];o++,t.replaceWith(...r.nodes)}),r.push(t)}}const n=e.root({value:"",...sourceFrom(o)});return r.forEach(e=>{n.append(e)}),n},exports.resolveNestedSelector=function resolveNestedSelector(o,t,r){const n=[];for(let s=0;s(o=!0,!1)),o?"combinator"===c.nodes[0]?.type&&c.prepend(e.nesting({...sourceFrom(c)})):(c.prepend(e.combinator({value:" ",...sourceFrom(c)})),c.prepend(e.nesting({...sourceFrom(c)})))}{const e=new Set;c.walkNesting(o=>{const r=o.parent;r&&(e.add(r),"pseudo"===r.parent?.type&&":has"===r.parent.value?.toLowerCase()?o.replaceWith(...prepareParentSelectors(t,!0)):o.replaceWith(...prepareParentSelectors(t)))});for(const o of e)sortCompoundSelectorsInsideComplexSelector(o)}c.walk(e=>{"combinator"===e.type&&""!==e.value.trim()?(e.rawSpaceAfter=" ",e.rawSpaceBefore=" "):(e.rawSpaceAfter="",e.rawSpaceBefore="")}),n.push(c)}const s=e.root({value:"",...sourceFrom(o)});return n.forEach(e=>{s.append(e)}),s}; diff --git a/packages/selector-resolve-nested/package.json b/packages/selector-resolve-nested/package.json index c2ef6536b..5361b12c2 100644 --- a/packages/selector-resolve-nested/package.json +++ b/packages/selector-resolve-nested/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/packages/selector-specificity/CHANGELOG.md b/packages/selector-specificity/CHANGELOG.md index 2c88d32ba..4fad1d7f5 100644 --- a/packages/selector-specificity/CHANGELOG.md +++ b/packages/selector-specificity/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to Selector Specificity +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 5.0.0 _October 23, 2024_ diff --git a/packages/selector-specificity/dist/index.cjs b/packages/selector-specificity/dist/index.cjs deleted file mode 100644 index d57c96f5d..000000000 --- a/packages/selector-specificity/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser");function compare(e,t){return e.a===t.a?e.b===t.b?e.c-t.c:e.b-t.b:e.a-t.a}function selectorSpecificity(t,s){const i=s?.customSpecificity?.(t);if(i)return i;if(!t)return{a:0,b:0,c:0};let c=0,n=0,o=0;if("universal"==t.type)return{a:0,b:0,c:0};if("id"===t.type)c+=1;else if("tag"===t.type)o+=1;else if("class"===t.type)n+=1;else if("attribute"===t.type)n+=1;else if(isPseudoElement(t))switch(t.value.toLowerCase()){case"::slotted":if(o+=1,t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case"::view-transition-group":case"::view-transition-image-pair":case"::view-transition-old":case"::view-transition-new":return t.nodes&&1===t.nodes.length&&"selector"===t.nodes[0].type&&selectorNodeContainsNothingOrOnlyUniversal(t.nodes[0])?{a:0,b:0,c:0}:{a:0,b:0,c:1};default:o+=1}else if(e.isPseudoClass(t))switch(t.value.toLowerCase()){case":-webkit-any":case":any":default:n+=1;break;case":-moz-any":case":has":case":is":case":matches":case":not":if(t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case":where":break;case":nth-child":case":nth-last-child":if(n+=1,t.nodes&&t.nodes.length>0){const i=t.nodes[0].nodes.findIndex(e=>"tag"===e.type&&"of"===e.value.toLowerCase());if(i>-1){const a=e.selector({nodes:[],value:""});t.nodes[0].nodes.slice(i+1).forEach(e=>{a.append(e.clone())});const r=[a];t.nodes.length>1&&r.push(...t.nodes.slice(1));const l=specificityOfMostSpecificListItem(r,s);c+=l.a,n+=l.b,o+=l.c}}break;case":local":case":global":t.nodes&&t.nodes.length>0&&t.nodes.forEach(e=>{const t=selectorSpecificity(e,s);c+=t.a,n+=t.b,o+=t.c});break;case":host":case":host-context":if(n+=1,t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case":active-view-transition":case":active-view-transition-type":return{a:0,b:1,c:0}}else e.isContainer(t)&&t.nodes?.length>0&&t.nodes.forEach(e=>{const t=selectorSpecificity(e,s);c+=t.a,n+=t.b,o+=t.c});return{a:c,b:n,c:o}}function specificityOfMostSpecificListItem(e,t){let s={a:0,b:0,c:0};return e.forEach(e=>{const i=selectorSpecificity(e,t);compare(i,s)<0||(s=i)}),s}function isPseudoElement(t){return e.isPseudoElement(t)}function selectorNodeContainsNothingOrOnlyUniversal(e){if(!e)return!1;if(!e.nodes)return!1;const t=e.nodes.filter(e=>"comment"!==e.type);return 0===t.length||1===t.length&&"universal"===t[0].type}exports.compare=compare,exports.selectorSpecificity=selectorSpecificity,exports.specificityOfMostSpecificListItem=specificityOfMostSpecificListItem; diff --git a/packages/selector-specificity/package.json b/packages/selector-specificity/package.json index 204405b48..78e76e1ce 100644 --- a/packages/selector-specificity/package.json +++ b/packages/selector-specificity/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/packages/utilities/CHANGELOG.md b/packages/utilities/CHANGELOG.md index 1dbd3cc6e..407352593 100644 --- a/packages/utilities/CHANGELOG.md +++ b/packages/utilities/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to Utilities +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.0 _August 3, 2024_ diff --git a/packages/utilities/dist/index.cjs b/packages/utilities/dist/index.cjs deleted file mode 100644 index 5b60709f6..000000000 --- a/packages/utilities/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";exports.hasFallback=function hasFallback(t){const e=t.parent;if(!e)return!1;const r=t.prop.toLowerCase(),s=e.index(t);for(let t=0;t=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugin-packs/postcss-bundler/CHANGELOG.md b/plugin-packs/postcss-bundler/CHANGELOG.md index ece79da53..4ce664ad2 100644 --- a/plugin-packs/postcss-bundler/CHANGELOG.md +++ b/plugin-packs/postcss-bundler/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Bundler +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.8 _June 2, 2025_ diff --git a/plugin-packs/postcss-bundler/dist/index.cjs b/plugin-packs/postcss-bundler/dist/index.cjs deleted file mode 100644 index f3f84e670..000000000 --- a/plugin-packs/postcss-bundler/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-parser-algorithms"),t=require("@csstools/css-tokenizer"),s=require("node:path"),o=require("node:module"),n=require("node:fs/promises"),r=require("@csstools/postcss-rebase-url");function isWarning(e){return"warning"===e.type}function isNodesStatement(e){return"nodes"===e.type}function isImportStatement(e){return"import"===e.type}function isPreImportStatement(e){return"pre-import"===e.type}const i=/^data:text\/css(?:;(?:base64|plain))?,/i,a=/^data:text\/css;base64,/i,c=/^data:text\/css;plain,/i;function isValidDataURL(e){return!!e&&i.test(e)}const p=/^charset$/i,u=/^import$/i,m=/^url$/i,l=/^layer$/i,d=/^supports$/i,f=/^scope$/i;function parseAtImport(s){const o=t.tokenize({css:s});if(2===o.length&&(t.isTokenString(o[0])||t.isTokenURL(o[0]))){let e=o[0][4].value;return e=stripHash(e),!!e&&{uri:e,fullUri:o[0][1]}}const n=e.parseListOfComponentValues(o);let r,i,a,c,p="",u="";for(let s=0;s!e.isWhiteSpaceOrCommentNode(t)))return!1;r=e.stringify([o.value])}else if(e.isFunctionNode(o)&&d.test(o.getName())){if(void 0!==a)return!1;a=e.stringify([o.value])}else{if(!e.isFunctionNode(o)||!f.test(o.getName())){i=e.stringify([n.slice(s)]);break}if(void 0!==c)return!1;c=e.stringify([wrapInParenthesisIfNeeded(o.value)])}}}return p=stripHash(p),!!p&&{uri:p,fullUri:u,layer:r,media:i,supports:a,scope:c}}function wrapInParenthesisIfNeeded(s){for(let o=0;o{const i=parseStylesheet(e,t,s,o,n);if(r.charset&&i.charset&&r.charset.params.toLowerCase()!==i.charset.params.toLowerCase())throw i.charset.error(`Incompatible @charset statements:\n ${i.charset.params} specified in ${i.charset.source?.input.file}\n ${r.charset.params} specified in ${r.charset.source?.input.file}`);!r.charset&&i.charset&&(r.charset=i.charset),r.statements.push(...i.statements)}),r;let i,a,c=[],m=[];for(let r=0;r({postcssPlugin:"noop-plugin",Once(){}});async function parseStyles(e,t,s,o,n,r){const i=parseStylesheet(e,t,s,o,n);{let t,s,o;const n=[];for(const a of i.statements)isImportStatement(a)&&isProcessableURL(a.uri)&&(t&&s&&o||([t,s,o]=createRequire(a.node,e),t&&s&&o))&&n.push(resolveImportId(e,a,r,t,s,o));n.length&&await Promise.all(n)}for(let e=0;e{if(isWarning(s)||isPreImportStatement(s)||!s.conditions?.length)return;if(isImportStatement(s))return void(s.node.params=base64EncodedConditionalImport(s.fullUri,s.conditions));const n=s.nodes;if(!n.length)return;const r=n[0].parent;if(!r)return;const i=[];for(const e of s.conditions){if(void 0!==e.media){const o=t({name:"media",params:e.media,source:s.importingNode?.source??r.source});i.push(o)}if(void 0!==e.scope){const o=t({name:"scope",params:e.scope,source:s.importingNode?.source??r.source});i.push(o)}if(void 0!==e.supports){const o=t({name:"supports",params:"("+e.supports+")",source:s.importingNode?.source??r.source});i.push(o)}if(void 0!==e.layer){const o=t({name:"layer",params:e.layer,source:s.importingNode?.source??r.source});i.push(o)}}const a=i[0];if(!a)return;for(let e=0;e{e.parent=void 0}),c.append(n),e.statements[o]={type:"nodes",nodes:[a],conditions:s.conditions,from:s.from,importingNode:s.importingNode}})}function applyStyles(e,t){t.nodes=[],e.charset&&(e.charset.parent=void 0,t.append(e.charset)),e.statements.forEach(e=>{isImportStatement(e)?(e.node.parent=void 0,t.append(e.node)):isNodesStatement(e)&&e.nodes.forEach(e=>{e.parent=void 0,t.append(e)})})}function postProcess(e,t,s){let o=-1,n=-1;for(let t=0;t"atrule"===e.type&&!e.nodes))&&!(r"comment"===e.type))&&r{e.parent=void 0,o.append(e)});const n="data:text/css;base64,"+Buffer.from(o.toString()).toString("base64"),a={type:"import",uri:n,fullUri:'"'+n+'"',node:t({name:"import",params:'"'+n+'"',source:i.importingNode?.source??i.nodes[0]?.source}),conditions:i.conditions,from:i.from,importingNode:i.importingNode};e.statements.splice(r,1,a)}}}const creator$1=()=>({postcssPlugin:"postcss-bundler",async Once(e,{result:t,atRule:s,root:o,postcss:n}){const r=await parseStyles(t,e,null,[],[],n);postProcess(r,s,o),applyConditions(r,s),applyStyles(r,e)}});creator$1.postcss=!0;const creator=()=>({postcssPlugin:"postcss-bundler",plugins:[creator$1(),r()]});creator.postcss=!0,module.exports=creator; diff --git a/plugin-packs/postcss-bundler/dist/index.d.ts b/plugin-packs/postcss-bundler/dist/index.d.ts index 38635f8f5..dd275869c 100644 --- a/plugin-packs/postcss-bundler/dist/index.d.ts +++ b/plugin-packs/postcss-bundler/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-bundler plugin options */ export declare type pluginOptions = never; diff --git a/plugin-packs/postcss-bundler/dist/index.mjs b/plugin-packs/postcss-bundler/dist/index.mjs index b85be5fa6..b409d0c68 100644 --- a/plugin-packs/postcss-bundler/dist/index.mjs +++ b/plugin-packs/postcss-bundler/dist/index.mjs @@ -1 +1 @@ -import{parseListOfComponentValues as e,isWhiteSpaceOrCommentNode as t,isTokenNode as s,isFunctionNode as o,stringify as n,isSimpleBlockNode as r,SimpleBlockNode as i}from"@csstools/css-parser-algorithms";import{tokenize as a,isTokenString as c,isTokenURL as p,isTokenIdent as u,isTokenOpenParen as m,TokenType as l}from"@csstools/css-tokenizer";import d from"node:path";import f from"node:module";import h from"node:fs/promises";import y from"@csstools/postcss-rebase-url";function isWarning(e){return"warning"===e.type}function isNodesStatement(e){return"nodes"===e.type}function isImportStatement(e){return"import"===e.type}function isPreImportStatement(e){return"pre-import"===e.type}const g=/^data:text\/css(?:;(?:base64|plain))?,/i,v=/^data:text\/css;base64,/i,I=/^data:text\/css;plain,/i;function isValidDataURL(e){return!!e&&g.test(e)}const S=/^charset$/i,N=/^import$/i,b=/^url$/i,$=/^layer$/i,w=/^supports$/i,C=/^scope$/i;function parseAtImport(r){const i=a({css:r});if(2===i.length&&(c(i[0])||p(i[0]))){let e=i[0][4].value;return e=stripHash(e),!!e&&{uri:e,fullUri:i[0][1]}}const m=e(i);let l,d,f,h,y="",g="";for(let e=0;e!t(e)))return!1;l=n([r.value])}else if(o(r)&&w.test(r.getName())){if(void 0!==f)return!1;f=n([r.value])}else{if(!o(r)||!C.test(r.getName())){d=n([m.slice(e)]);break}if(void 0!==h)return!1;h=n([wrapInParenthesisIfNeeded(r.value)])}}}return y=stripHash(y),!!y&&{uri:y,fullUri:g,layer:l,media:d,supports:f,scope:h}}function wrapInParenthesisIfNeeded(e){for(let s=0;s{const i=parseStylesheet(e,t,s,o,n);if(r.charset&&i.charset&&r.charset.params.toLowerCase()!==i.charset.params.toLowerCase())throw i.charset.error(`Incompatible @charset statements:\n ${i.charset.params} specified in ${i.charset.source?.input.file}\n ${r.charset.params} specified in ${r.charset.source?.input.file}`);!r.charset&&i.charset&&(r.charset=i.charset),r.statements.push(...i.statements)}),r;let i,a,c=[],p=[];for(let r=0;r({postcssPlugin:"noop-plugin",Once(){}});async function parseStyles(e,t,s,o,n,r){const i=parseStylesheet(e,t,s,o,n);{let t,s,o;const n=[];for(const a of i.statements)isImportStatement(a)&&isProcessableURL(a.uri)&&(t&&s&&o||([t,s,o]=createRequire(a.node,e),t&&s&&o))&&n.push(resolveImportId(e,a,r,t,s,o));n.length&&await Promise.all(n)}for(let e=0;e{if(isWarning(s)||isPreImportStatement(s)||!s.conditions?.length)return;if(isImportStatement(s))return void(s.node.params=base64EncodedConditionalImport(s.fullUri,s.conditions));const n=s.nodes;if(!n.length)return;const r=n[0].parent;if(!r)return;const i=[];for(const e of s.conditions){if(void 0!==e.media){const o=t({name:"media",params:e.media,source:s.importingNode?.source??r.source});i.push(o)}if(void 0!==e.scope){const o=t({name:"scope",params:e.scope,source:s.importingNode?.source??r.source});i.push(o)}if(void 0!==e.supports){const o=t({name:"supports",params:"("+e.supports+")",source:s.importingNode?.source??r.source});i.push(o)}if(void 0!==e.layer){const o=t({name:"layer",params:e.layer,source:s.importingNode?.source??r.source});i.push(o)}}const a=i[0];if(!a)return;for(let e=0;e{e.parent=void 0}),c.append(n),e.statements[o]={type:"nodes",nodes:[a],conditions:s.conditions,from:s.from,importingNode:s.importingNode}})}function applyStyles(e,t){t.nodes=[],e.charset&&(e.charset.parent=void 0,t.append(e.charset)),e.statements.forEach(e=>{isImportStatement(e)?(e.node.parent=void 0,t.append(e.node)):isNodesStatement(e)&&e.nodes.forEach(e=>{e.parent=void 0,t.append(e)})})}function postProcess(e,t,s){let o=-1,n=-1;for(let t=0;t"atrule"===e.type&&!e.nodes))&&!(r"comment"===e.type))&&r{e.parent=void 0,o.append(e)});const n="data:text/css;base64,"+Buffer.from(o.toString()).toString("base64"),a={type:"import",uri:n,fullUri:'"'+n+'"',node:t({name:"import",params:'"'+n+'"',source:i.importingNode?.source??i.nodes[0]?.source}),conditions:i.conditions,from:i.from,importingNode:i.importingNode};e.statements.splice(r,1,a)}}}const creator$1=()=>({postcssPlugin:"postcss-bundler",async Once(e,{result:t,atRule:s,root:o,postcss:n}){const r=await parseStyles(t,e,null,[],[],n);postProcess(r,s,o),applyConditions(r,s),applyStyles(r,e)}});creator$1.postcss=!0;const creator=()=>({postcssPlugin:"postcss-bundler",plugins:[creator$1(),y()]});creator.postcss=!0;export{creator as default}; +import{parseListOfComponentValues as e,isWhiteSpaceOrCommentNode as t,isTokenNode as s,isFunctionNode as o,stringify as n,isSimpleBlockNode as r,SimpleBlockNode as i}from"@csstools/css-parser-algorithms";import{tokenize as a,isTokenString as c,isTokenURL as p,isTokenIdent as u,isTokenOpenParen as m,TokenType as l}from"@csstools/css-tokenizer";import d from"node:path";import f from"node:module";import h from"node:fs/promises";import y from"@csstools/postcss-rebase-url";function isWarning(e){return"warning"===e.type}function isNodesStatement(e){return"nodes"===e.type}function isImportStatement(e){return"import"===e.type}function isPreImportStatement(e){return"pre-import"===e.type}const g=/^data:text\/css(?:;(?:base64|plain))?,/i,v=/^data:text\/css;base64,/i,I=/^data:text\/css;plain,/i;function isValidDataURL(e){return!!e&&g.test(e)}const S=/^charset$/i,N=/^import$/i,b=/^url$/i,$=/^layer$/i,w=/^supports$/i,C=/^scope$/i;function parseAtImport(r){const i=a({css:r});if(2===i.length&&(c(i[0])||p(i[0]))){let e=i[0][4].value;return e=stripHash(e),!!e&&{uri:e,fullUri:i[0][1]}}const m=e(i);let l,d,f,h,y="",g="";for(let e=0;e!t(e)))return!1;l=n([r.value])}else if(o(r)&&w.test(r.getName())){if(void 0!==f)return!1;f=n([r.value])}else{if(!o(r)||!C.test(r.getName())){d=n([m.slice(e)]);break}if(void 0!==h)return!1;h=n([wrapInParenthesisIfNeeded(r.value)])}}}return y=stripHash(y),!!y&&{uri:y,fullUri:g,layer:l,media:d,supports:f,scope:h}}function wrapInParenthesisIfNeeded(e){for(let s=0;s{const i=parseStylesheet(e,t,s,o,n);if(r.charset&&i.charset&&r.charset.params.toLowerCase()!==i.charset.params.toLowerCase())throw i.charset.error(`Incompatible @charset statements:\n ${i.charset.params} specified in ${i.charset.source?.input.file}\n ${r.charset.params} specified in ${r.charset.source?.input.file}`);!r.charset&&i.charset&&(r.charset=i.charset),r.statements.push(...i.statements)}),r;let i,a,c=[],p=[];for(let r=0;r({postcssPlugin:"noop-plugin",Once(){}});async function parseStyles(e,t,s,o,n,r){const i=parseStylesheet(e,t,s,o,n);{let t,s,o;const n=[];for(const a of i.statements)isImportStatement(a)&&isProcessableURL(a.uri)&&(t&&s&&o||([t,s,o]=createRequire(a.node,e),t&&s&&o))&&n.push(resolveImportId(e,a,r,t,s,o));n.length&&await Promise.all(n)}for(let e=0;e{if(isWarning(s)||isPreImportStatement(s)||!s.conditions?.length)return;if(isImportStatement(s))return void(s.node.params=base64EncodedConditionalImport(s.fullUri,s.conditions));const n=s.nodes;if(!n.length)return;const r=n[0].parent;if(!r)return;const i=[];for(const e of s.conditions){if(void 0!==e.media){const o=t({name:"media",params:e.media,source:s.importingNode?.source??r.source});i.push(o)}if(void 0!==e.scope){const o=t({name:"scope",params:e.scope,source:s.importingNode?.source??r.source});i.push(o)}if(void 0!==e.supports){const o=t({name:"supports",params:"("+e.supports+")",source:s.importingNode?.source??r.source});i.push(o)}if(void 0!==e.layer){const o=t({name:"layer",params:e.layer,source:s.importingNode?.source??r.source});i.push(o)}}const a=i[0];if(!a)return;for(let e=0;e{e.parent=void 0}),c.append(n),e.statements[o]={type:"nodes",nodes:[a],conditions:s.conditions,from:s.from,importingNode:s.importingNode}})}function applyStyles(e,t){t.nodes=[],e.charset&&(e.charset.parent=void 0,t.append(e.charset)),e.statements.forEach(e=>{isImportStatement(e)?(e.node.parent=void 0,t.append(e.node)):isNodesStatement(e)&&e.nodes.forEach(e=>{e.parent=void 0,t.append(e)})})}function postProcess(e,t,s){let o=-1,n=-1;for(let t=0;t"atrule"===e.type&&!e.nodes))&&!(r"comment"===e.type))&&r{e.parent=void 0,o.append(e)});const n="data:text/css;base64,"+Buffer.from(o.toString()).toString("base64"),a={type:"import",uri:n,fullUri:'"'+n+'"',node:t({name:"import",params:'"'+n+'"',source:i.importingNode?.source??i.nodes[0]?.source}),conditions:i.conditions,from:i.from,importingNode:i.importingNode};e.statements.splice(r,1,a)}}}const creator$1=()=>({postcssPlugin:"postcss-bundler",async Once(e,{result:t,atRule:s,root:o,postcss:n}){const r=await parseStyles(t,e,null,[],[],n);postProcess(r,s,o),applyConditions(r,s),applyStyles(r,e)}});creator$1.postcss=!0;const creator=()=>({postcssPlugin:"postcss-bundler",plugins:[creator$1(),y()]});creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugin-packs/postcss-bundler/package.json b/plugin-packs/postcss-bundler/package.json index b6bccf141..c27a5f610 100644 --- a/plugin-packs/postcss-bundler/package.json +++ b/plugin-packs/postcss-bundler/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugin-packs/postcss-bundler/src/index.ts b/plugin-packs/postcss-bundler/src/index.ts index 74fb0c688..b6783feaf 100644 --- a/plugin-packs/postcss-bundler/src/index.ts +++ b/plugin-packs/postcss-bundler/src/index.ts @@ -18,3 +18,4 @@ const creator: PluginCreator = () => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugin-packs/postcss-bundler/src/postcss-import/lib/noop-plugin.ts b/plugin-packs/postcss-bundler/src/postcss-import/lib/noop-plugin.ts index a9b7aef0e..b09d6fec7 100644 --- a/plugin-packs/postcss-bundler/src/postcss-import/lib/noop-plugin.ts +++ b/plugin-packs/postcss-bundler/src/postcss-import/lib/noop-plugin.ts @@ -13,3 +13,4 @@ const noopPlugin: PluginCreator = () => { noopPlugin.postcss = true; export default noopPlugin; + diff --git a/plugin-packs/postcss-preset-env/CHANGELOG.md b/plugin-packs/postcss-preset-env/CHANGELOG.md index 46ad75b82..e6997bcf0 100644 --- a/plugin-packs/postcss-preset-env/CHANGELOG.md +++ b/plugin-packs/postcss-preset-env/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Preset Env +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 10.6.1 _January 10, 2026_ diff --git a/plugin-packs/postcss-preset-env/dist/index.cjs b/plugin-packs/postcss-preset-env/dist/index.cjs deleted file mode 100644 index ccba240ab..000000000 --- a/plugin-packs/postcss-preset-env/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("autoprefixer"),e=require("cssdb"),o=require("browserslist"),t=require("@csstools/postcss-initial"),r=require("@csstools/postcss-alpha-function"),i=require("postcss-pseudo-class-any-link"),a=require("css-blank-pseudo"),c=require("postcss-page-break"),n=require("@csstools/postcss-cascade-layers"),p=require("postcss-attribute-case-insensitive"),l=require("postcss-clamp"),u=require("@csstools/postcss-color-function"),m=require("@csstools/postcss-color-function-display-p3-linear"),d=require("postcss-color-functional-notation"),g=require("@csstools/postcss-color-mix-function"),f=require("@csstools/postcss-color-mix-variadic-function-arguments"),h=require("@csstools/postcss-content-alt-text"),b=require("@csstools/postcss-contrast-color-function"),N=require("postcss-custom-media"),v=require("postcss-custom-properties"),y=require("postcss-custom-selectors"),k=require("postcss-dir-pseudo-class"),w=require("@csstools/postcss-normalize-display-values"),q=require("postcss-double-position-gradients"),x=require("@csstools/postcss-exponential-functions"),F=require("@csstools/postcss-logical-float-and-clear"),O=require("postcss-focus-visible"),P=require("postcss-focus-within"),C=require("@csstools/postcss-font-format-keywords"),$=require("postcss-font-variant"),S=require("@csstools/postcss-gamut-mapping"),A=require("postcss-gap-properties"),_=require("@csstools/postcss-gradients-interpolation-method"),L=require("css-has-pseudo"),E=require("postcss-color-hex-alpha"),I=require("@csstools/postcss-hwb-function"),B=require("@csstools/postcss-ic-unit"),M=require("postcss-image-set-function"),D=require("@csstools/postcss-is-pseudo-class"),j=require("postcss-lab-function"),z=require("@csstools/postcss-light-dark-function"),U=require("@csstools/postcss-logical-overflow"),R=require("@csstools/postcss-logical-overscroll-behavior"),T=require("postcss-logical"),V=require("@csstools/postcss-logical-resize"),H=require("@csstools/postcss-logical-viewport-units"),W=require("@csstools/postcss-media-queries-aspect-ratio-number-values"),G=require("@csstools/postcss-media-minmax"),K=require("@csstools/postcss-nested-calc"),Z=require("postcss-nesting"),Q=require("postcss-selector-not"),J=require("@csstools/postcss-oklab-function"),X=require("postcss-opacity-percentage"),Y=require("postcss-overflow-shorthand"),ss=require("postcss-replace-overflow-wrap"),es=require("postcss-place"),os=require("@csstools/postcss-position-area-property"),ts=require("css-prefers-color-scheme"),rs=require("@csstools/postcss-progressive-custom-properties"),is=require("@csstools/postcss-property-rule-prelude-list"),as=require("@csstools/postcss-random-function"),cs=require("postcss-color-rebeccapurple"),ns=require("@csstools/postcss-relative-color-syntax"),ps=require("@csstools/postcss-scope-pseudo-class"),ls=require("@csstools/postcss-sign-functions"),us=require("@csstools/postcss-stepped-value-functions"),ms=require("@csstools/postcss-syntax-descriptor-syntax-production"),ds=require("@csstools/postcss-system-ui-font-family"),gs=require("@csstools/postcss-text-decoration-shorthand"),fs=require("@csstools/postcss-trigonometric-functions"),hs=require("@csstools/postcss-unset-value");const bs={"blank-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-blank-pseudo/README.md#browser","focus-visible-pseudo-class":"https://github.com/WICG/focus-visible","focus-within-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/postcss-focus-within/README.md#browser","has-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-has-pseudo/README.md#browser","prefers-color-scheme-query":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-prefers-color-scheme/README.md#browser"},Ns=["blank-pseudo-class","focus-visible-pseudo-class","focus-within-pseudo-class","has-pseudo-class","prefers-color-scheme-query"];function logFeaturesList(s,e,o){if(e.debug){o.log("Enabling the following feature(s):");const t=[],r=[];!1!==e.autoprefixer&&r.push(" autoprefixer"),s.forEach(s=>{s.id.startsWith("before")||s.id.startsWith("after")?r.push(` ${s.id} (injected via options)`):r.push(` ${s.id}`),void 0!==bs[s.id]&&t.push(s.id)}),r.sort((s,e)=>s.localeCompare(e)),t.sort((s,e)=>s.localeCompare(e)),r.forEach(s=>o.log(s)),t.length&&(o.log("These feature(s) need a browser library to work:"),t.forEach(s=>o.log(` ${s}: ${bs[s]}`)))}}function initializeSharedOptions(s){if("preserve"in s){const e={};return e.preserve=s.preserve,e}return!1}function clamp(s,e,o){return Math.max(s,Math.min(e,o))}function stageFromOptions(s,e){let o=2;if(void 0===s.stage)return e.log("Using features from Stage 2 (default)."),o;if(!1===s.stage)o=5;else{let e=parseInt(s.stage,10);Number.isNaN(e)&&(e=0),o=clamp(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}const vs=Symbol("insertBefore"),ys=Symbol("insertAfter"),ks=Symbol("insertOrder"),ws=Symbol("plugin");function getTransformedInsertions(s,e,o){if("insertBefore"!==o&&"insertAfter"!==o)return[];const t="insertBefore"===o?vs:ys,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;sfeatureIsInsertedOrHasAPlugin(s)).sort((s,e)=>featureIsLess(s,e))}function getOptionsForBrowsersByFeature(s,e,o,t){switch(e.id){case"is-pseudo-class":return{onComplexSelector:"warning"};case"any-link-pseudo-class":if(s.find(s=>s.startsWith("ie ")||"edge 12"===s||"edge 13"===s||"edge 14"===s||"edge 15"===s||"edge 16"===s||"edge 17"===s||"edge 18"===s))return t.log("- 'any-link-pseudo-class' setting 'subFeatures: { areaHrefNeedsFixing: true }' due to lack of browser support for area[href] in Edge and IE."),{subFeatures:{areaHrefNeedsFixing:!0}};return{};case"logical-properties-and-values":case"float-clear-logical-values":case"logical-resize":case"logical-viewport-units":case"logical-overflow":case"logical-overscroll-behavior":return"logical"in o?o.logical:{};default:return{}}}const Fs=["and_chr","and_ff","android","chrome","edge","firefox","ie","ios_saf","op_mini","op_mob","opera","safari","samsung"];function getUnsupportedBrowsersByFeature(s){if(!s)return[];if("position-area-property"===s.id)return["chrome 125","chrome 126","chrome 127","chrome 128","edge 125","edge 126","edge 127","edge 128","and_chr 125","and_chr 126","and_chr 127","and_chr 128","android 125","android 126","android 127","android 128","samsung 27","opera 111","opera 112","opera 113","opera 114","op_mob 83","op_mob 84","op_mob 85"];if(!("browser_support"in s))return["> 0%"];const e=[];return Fs.forEach(o=>{if("op_mini"===o&&void 0===s.browser_support[o])return void e.push("op_mini all");const t=s.browser_support[o];"string"==typeof t&&Os.test(t)?e.push(`${o} < ${s.browser_support[o]}`):e.push(`${o} >= 1`)}),e}const Os=/^[0-9|.]+$/;function formatPolyfillableFeature(s){const e=getUnsupportedBrowsersByFeature(s);if(s[vs]||s[ys]){let o=s.id;return o=s.insertBefore?`before-${o}`:`after-${o}`,{browsers:e,vendors_implementations:s.vendors_implementations,plugin:s[ws],id:o,stage:6}}return{browsers:e,vendors_implementations:s.vendors_implementations,plugin:xs.get(s.id),id:s.id,stage:s.stage}}function formatStagedFeature(s,e,o,t,r,i){let a,c;return a=getOptionsForBrowsersByFeature(s,o,r,i),a=t?Object.assign({},a,t,featureOptions(e,o.id)):Object.assign({},a,featureOptions(e,o.id)),"progressive-custom-properties"!==o.id&&(a.enableProgressiveCustomProperties=!1),"overflow-wrap-property"===o.id&&"preserve"in a&&(a.method=a.preserve?"copy":"replace"),c=o.plugin.postcss&&"function"==typeof o.plugin?o.plugin(a):o.plugin&&o.plugin.default&&"function"==typeof o.plugin.default&&o.plugin.default.postcss?o.plugin.default(a):o.plugin,{browsers:o.browsers,vendors_implementations:o.vendors_implementations,plugin:c,pluginOptions:a,id:o.id}}function featureOptions(s,e){if(!(e in s))return;const o=s[e];return Array.isArray(o)?o[1]:o}function intOrZero(s){const e=parseInt(s,10);return Number.isNaN(e)?0:e}const Ps=new Set(["progressive-custom-properties"]);function listFeatures(s,e,t,r){const i=Object(e.features),a="enableClientSidePolyfills"in e&&e.enableClientSidePolyfills,c=Object(e.insertBefore),n=Object(e.insertAfter),p=e.browsers?void 0:e.env,l=e.browsers,u=clamp(0,intOrZero(e.minimumVendorImplementations),3);u>0&&r.log(`Using features with ${u} or more vendor implementations.`);const m=stageFromOptions(e,r),d=prepareFeaturesList([...s,{id:"progressive-custom-properties"}],c,n).map(s=>formatPolyfillableFeature(s)).filter(s=>!!Ps.has(s.id)||(0===u||(!(!s[vs]&&!s[ys])||(u<=s.vendors_implementations||(!0===featureEnabledByOptions(i,s.id)?(r.log(`- '${s.id}' enabled manually even when it lacks the required interop (${s.vendors_implementations} out of ${u}).`),!0):(r.log(`- '${s.id}' disabled because it lacks the required interop (${s.vendors_implementations} out of ${u}).`),!1)))))),g=o(l,{env:p,ignoreUnknownVersions:!0}).filter(s=>Fs.includes(s.split(" ")[0]));return d.filter(s=>{if(Ps.has(s.id))return!0;const e=s.stage>=m,o=a||!Ns.includes(s.id),t=featureEnabledByOptions(i,s.id),c=!1===t,n=!0===t||e&&o;return c?r.log(`- '${s.id}' disabled manually`):e?o||r.log(`- '${s.id}' disabled because 'enableClientSidePolyfills' is 'false'.`):n?r.log(`- '${s.id}' enabled manually even when it lacks the required stage (${s.stage} out of ${m}).`):r.log(`- '${s.id}' disabled because it lacks the required stage (${s.stage} out of ${m}).`),!c&&n}).map(s=>formatStagedFeature(g,i,s,t,e,r)).filter(s=>{if(Ps.has(s.id))return!0;const e=featureEnabledByOptions(i,s.id);if(!0===e||!1===e)return e;const t=o(s.browsers,{ignoreUnknownVersions:!0}),a=g.filter(s=>t.some(e=>e===s));return a.length>0?r.log(`- '${s.id}' enabled for:\n ${a.join("\n ")}`):r.log(`- '${s.id}' disabled because all targeted browsers support it.`),a.length>0})}function featureEnabledByOptions(s,e){if(!(e in s))return"auto";const o=s[e];return Array.isArray(o)?!0===o[0]||!1!==o[0]&&"auto":Boolean(o)}class Logger{constructor(){this.logs=[]}log(s){this.logs.push(s)}resetLogger(){this.logs.length=0}emitLogs(s){s&&s.warn(this.logs.join("\n")),this.resetLogger()}}var Cs=[{packageName:"css-blank-pseudo",id:"blank-pseudo-class",importName:"postcssBlankPseudo"},{packageName:"css-has-pseudo",id:"has-pseudo-class",importName:"postcssHasPseudo"},{packageName:"css-prefers-color-scheme",id:"prefers-color-scheme-query",importName:"postcssPrefersColorScheme"},{packageName:"postcss-attribute-case-insensitive",id:"case-insensitive-attributes",importName:"postcssAttributeCaseInsensitive"},{packageName:"postcss-clamp",id:"clamp",importName:"postcssClamp"},{packageName:"@csstools/postcss-alpha-function",id:"alpha-function",importName:"postcssAlphaFunction"},{packageName:"@csstools/postcss-color-mix-variadic-function-arguments",id:"color-mix-variadic-function-arguments",importName:"postcssColorMixVariadicFunctionArguments"},{packageName:"@csstools/postcss-color-mix-function",id:"color-mix",importName:"postcssColorMixFunction"},{packageName:"@csstools/postcss-color-function",id:"color-function",importName:"postcssColorFunction"},{packageName:"@csstools/postcss-color-function-display-p3-linear",id:"color-function-display-p3-linear",importName:"postcssColorFunctionDisplayP3Linear"},{packageName:"postcss-color-functional-notation",id:"color-functional-notation",importName:"postcssColorFunctionalNotation"},{packageName:"postcss-color-hex-alpha",id:"hexadecimal-alpha-notation",importName:"postcssColorHexAlpha"},{packageName:"@csstools/postcss-content-alt-text",id:"content-alt-text",importName:"postcssContentAltText"},{packageName:"postcss-color-rebeccapurple",id:"rebeccapurple-color",importName:"postcssColorRebeccapurple"},{packageName:"@csstools/postcss-contrast-color-function",id:"contrast-color-function",importName:"postcssContrastColorFunction"},{packageName:"postcss-custom-media",id:"custom-media-queries",importName:"postcssCustomMedia"},{packageName:"postcss-custom-properties",id:"custom-properties",importName:"postcssCustomProperties"},{packageName:"postcss-custom-selectors",id:"custom-selectors",importName:"postcssCustomSelectors"},{packageName:"postcss-dir-pseudo-class",id:"dir-pseudo-class",importName:"postcssDirPseudoClass"},{packageName:"postcss-double-position-gradients",id:"double-position-gradients",importName:"postcssDoublePositionGradients"},{packageName:"@csstools/postcss-exponential-functions",id:"exponential-functions",importName:"postcssExponentialFunctions"},{packageName:"postcss-focus-visible",id:"focus-visible-pseudo-class",importName:"postcssFocusVisible"},{packageName:"postcss-focus-within",id:"focus-within-pseudo-class",importName:"postcssFocusWithin"},{packageName:"@csstools/postcss-font-format-keywords",id:"font-format-keywords",importName:"postcssFontFormatKeywords"},{packageName:"postcss-font-variant",id:"font-variant-property",importName:"postcssFontVariant"},{packageName:"@csstools/postcss-gamut-mapping",id:"gamut-mapping",importName:"postcssGamutMapping"},{packageName:"postcss-gap-properties",id:"gap-properties",importName:"postcssGapProperties"},{packageName:"@csstools/postcss-gradients-interpolation-method",id:"gradients-interpolation-method",importName:"postcssGradientsInterpolationMethod"},{packageName:"@csstools/postcss-hwb-function",id:"hwb-function",importName:"postcssHWBFunction"},{packageName:"@csstools/postcss-ic-unit",id:"ic-unit",importName:"postcssICUnit"},{packageName:"postcss-image-set-function",id:"image-set-function",importName:"postcssImageSetFunction"},{packageName:"@csstools/postcss-initial",id:"all-property",importName:"postcssInitial"},{packageName:"@csstools/postcss-is-pseudo-class",id:"is-pseudo-class",importName:"postcssIsPseudoClass"},{packageName:"@csstools/postcss-scope-pseudo-class",id:"scope-pseudo-class",importName:"postcssScopePseudoClass"},{packageName:"postcss-lab-function",id:"lab-function",importName:"postcssLabFunction"},{packageName:"@csstools/postcss-light-dark-function",id:"light-dark-function",importName:"postcssLightDarkFunction"},{packageName:"postcss-logical",id:"logical-properties-and-values",importName:"postcssLogical"},{packageName:"@csstools/postcss-logical-float-and-clear",id:"float-clear-logical-values",importName:"postcssLogicalFloatAndClear"},{packageName:"@csstools/postcss-logical-overflow",id:"logical-overflow",importName:"postcssLogicalOverflow"},{packageName:"@csstools/postcss-logical-overscroll-behavior",id:"logical-overscroll-behavior",importName:"postcssLogicalOverscrollBehavor"},{packageName:"@csstools/postcss-logical-resize",id:"logical-resize",importName:"postcssLogicalResize"},{packageName:"@csstools/postcss-logical-viewport-units",id:"logical-viewport-units",importName:"postcssLogicalViewportUnits"},{packageName:"@csstools/postcss-media-minmax",id:"media-query-ranges",importName:"postcssMediaMinmax"},{packageName:"@csstools/postcss-media-queries-aspect-ratio-number-values",id:"media-queries-aspect-ratio-number-values",importName:"postcssMediaQueriesAspectRatioNumberValues"},{packageName:"postcss-nesting",id:"nesting-rules",importName:"postcssNesting"},{packageName:"@csstools/postcss-normalize-display-values",id:"display-two-values",importName:"postcssNormalizeDisplayValues"},{packageName:"@csstools/postcss-oklab-function",id:"oklab-function",importName:"postcssOKLabFunction"},{packageName:"@csstools/postcss-relative-color-syntax",id:"relative-color-syntax",importName:"postcssRelativeColorSyntax"},{packageName:"postcss-opacity-percentage",id:"opacity-percentage",importName:"postcssOpacityPercentage"},{packageName:"postcss-overflow-shorthand",id:"overflow-property",importName:"postcssOverflowShorthand"},{packageName:"postcss-page-break",id:"break-properties",importName:"postcssPageBreak"},{packageName:"@csstools/postcss-position-area-property",id:"position-area-property",importName:"postcssPositionAreaProperty"},{packageName:"postcss-place",id:"place-properties",importName:"postcssPlace"},{packageName:"postcss-pseudo-class-any-link",id:"any-link-pseudo-class",importName:"postcssPseudoClassAnyLink"},{packageName:"postcss-replace-overflow-wrap",id:"overflow-wrap-property",importName:"postcssReplaceOverflowWrap"},{packageName:"postcss-selector-not",id:"not-pseudo-class",importName:"postcssSelectorNot"},{packageName:"@csstools/postcss-stepped-value-functions",id:"stepped-value-functions",importName:"postcssSteppedValueFunctions"},{packageName:"@csstools/postcss-system-ui-font-family",id:"system-ui-font-family",importName:"postcssSystemUIFontFamily"},{packageName:"@csstools/postcss-unset-value",id:"unset-value",importName:"postcssUnsetValue"},{packageName:"@csstools/postcss-cascade-layers",id:"cascade-layers",importName:"postcssCascadeLayers"},{packageName:"@csstools/postcss-trigonometric-functions",id:"trigonometric-functions",importName:"postcssTrigonometricFunctions"},{packageName:"@csstools/postcss-nested-calc",id:"nested-calc",importName:"postcssNestedCalc"},{packageName:"@csstools/postcss-text-decoration-shorthand",id:"text-decoration-shorthand",importName:"postcssTextDecorationShorthand"},{packageName:"@csstools/postcss-sign-functions",id:"sign-functions",importName:"postcssSignFunctions"},{packageName:"@csstools/postcss-random-function",id:"random-function",importName:"postcssRandomFunction"},{packageName:"@csstools/postcss-property-rule-prelude-list",id:"property-rule-prelude-list",importName:"postcssPropertyRulePreludeList"},{packageName:"@csstools/postcss-syntax-descriptor-syntax-production",id:"syntax-descriptor-syntax-production",importName:"postcssSyntaxDescriptorSyntaxProduction"},{packageName:"@csstools/postcss-progressive-custom-properties",id:"progressive-custom-properties",importName:"postcssProgressiveCustomProperties",omitTypedOptions:!0,omitDocs:!0}];function getPackageNamesToIds(){const s={};return Cs.forEach(e=>{s[e.packageName]=e.id}),s}function pluginIdHelp(s,e,o){const t=Cs.map(s=>s.id),r=Cs.map(s=>s.packageName),i=getPackageNamesToIds();s.forEach(s=>{if(t.includes(s))return;const a=[...t.map(e=>[e,levenshteinDistance(s,e)]),...r.map(e=>[i[e],levenshteinDistance(s,e)])].sort((s,e)=>s[1]-e[1]).filter(s=>s[1]<10),c=new Set;for(let s=0;s=3));s++);if(!c.size)return void e.warn(o,`Unknown feature: "${s}", see the list of features https://github.com/csstools/postcss-plugins/blob/main/plugin-packs/postcss-preset-env/FEATURES.md`);let n='"';n+=Array.from(c).join('", "'),n+='"',e.warn(o,`Unknown feature: "${s}", did you mean one of: ${n}`)})}function levenshteinDistance(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 creator=o=>{const t=new Logger,r=Object(o),i=Object.keys(Object(r.features)),a=r.browsers?void 0:r.env,c=r.browsers,n=initializeSharedOptions(r),p=listFeatures(e,r,n,t),l=p.map(s=>s.plugin);!1!==r.autoprefixer&&l.push(s(Object.assign({env:a,overrideBrowserslist:c},r.autoprefixer))),logFeaturesList(p,r,t);const internalPlugin=()=>({postcssPlugin:"postcss-preset-env",OnceExit(s,{result:e}){pluginIdHelp(i,s,e),r.debug&&t.emitLogs(e),t.resetLogger()}});return internalPlugin.postcss=!0,{postcssPlugin:"postcss-preset-env",plugins:[...l,internalPlugin()]}};creator.postcss=!0,module.exports=creator; diff --git a/plugin-packs/postcss-preset-env/dist/index.d.ts b/plugin-packs/postcss-preset-env/dist/index.d.ts index 3b74b0d73..31e0ddf26 100644 --- a/plugin-packs/postcss-preset-env/dist/index.d.ts +++ b/plugin-packs/postcss-preset-env/dist/index.d.ts @@ -65,6 +65,7 @@ import type { pluginOptions as pluginOptions_9 } from '@csstools/postcss-color-f declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export declare enum DirectionFlow { TopToBottom = "top-to-bottom", diff --git a/plugin-packs/postcss-preset-env/dist/index.mjs b/plugin-packs/postcss-preset-env/dist/index.mjs index d0857fd9a..c7370eec3 100644 --- a/plugin-packs/postcss-preset-env/dist/index.mjs +++ b/plugin-packs/postcss-preset-env/dist/index.mjs @@ -1 +1 @@ -import s from"autoprefixer";import o from"cssdb";import e from"browserslist";import t from"@csstools/postcss-initial";import r from"@csstools/postcss-alpha-function";import i from"postcss-pseudo-class-any-link";import a from"css-blank-pseudo";import c from"postcss-page-break";import p from"@csstools/postcss-cascade-layers";import n from"postcss-attribute-case-insensitive";import l from"postcss-clamp";import m from"@csstools/postcss-color-function";import u from"@csstools/postcss-color-function-display-p3-linear";import d from"postcss-color-functional-notation";import f from"@csstools/postcss-color-mix-function";import g from"@csstools/postcss-color-mix-variadic-function-arguments";import h from"@csstools/postcss-content-alt-text";import b from"@csstools/postcss-contrast-color-function";import N from"postcss-custom-media";import v from"postcss-custom-properties";import y from"postcss-custom-selectors";import k from"postcss-dir-pseudo-class";import w from"@csstools/postcss-normalize-display-values";import x from"postcss-double-position-gradients";import F from"@csstools/postcss-exponential-functions";import O from"@csstools/postcss-logical-float-and-clear";import P from"postcss-focus-visible";import C from"postcss-focus-within";import $ from"@csstools/postcss-font-format-keywords";import S from"postcss-font-variant";import A from"@csstools/postcss-gamut-mapping";import _ from"postcss-gap-properties";import L from"@csstools/postcss-gradients-interpolation-method";import E from"css-has-pseudo";import I from"postcss-color-hex-alpha";import B from"@csstools/postcss-hwb-function";import q from"@csstools/postcss-ic-unit";import M from"postcss-image-set-function";import D from"@csstools/postcss-is-pseudo-class";import j from"postcss-lab-function";import z from"@csstools/postcss-light-dark-function";import U from"@csstools/postcss-logical-overflow";import R from"@csstools/postcss-logical-overscroll-behavior";import T from"postcss-logical";import V from"@csstools/postcss-logical-resize";import H from"@csstools/postcss-logical-viewport-units";import W from"@csstools/postcss-media-queries-aspect-ratio-number-values";import G from"@csstools/postcss-media-minmax";import K from"@csstools/postcss-nested-calc";import Z from"postcss-nesting";import Q from"postcss-selector-not";import J from"@csstools/postcss-oklab-function";import X from"postcss-opacity-percentage";import Y from"postcss-overflow-shorthand";import ss from"postcss-replace-overflow-wrap";import os from"postcss-place";import es from"@csstools/postcss-position-area-property";import ts from"css-prefers-color-scheme";import rs from"@csstools/postcss-progressive-custom-properties";import is from"@csstools/postcss-property-rule-prelude-list";import as from"@csstools/postcss-random-function";import cs from"postcss-color-rebeccapurple";import ps from"@csstools/postcss-relative-color-syntax";import ns from"@csstools/postcss-scope-pseudo-class";import ls from"@csstools/postcss-sign-functions";import ms from"@csstools/postcss-stepped-value-functions";import us from"@csstools/postcss-syntax-descriptor-syntax-production";import ds from"@csstools/postcss-system-ui-font-family";import fs from"@csstools/postcss-text-decoration-shorthand";import gs from"@csstools/postcss-trigonometric-functions";import hs from"@csstools/postcss-unset-value";const bs={"blank-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-blank-pseudo/README.md#browser","focus-visible-pseudo-class":"https://github.com/WICG/focus-visible","focus-within-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/postcss-focus-within/README.md#browser","has-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-has-pseudo/README.md#browser","prefers-color-scheme-query":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-prefers-color-scheme/README.md#browser"},Ns=["blank-pseudo-class","focus-visible-pseudo-class","focus-within-pseudo-class","has-pseudo-class","prefers-color-scheme-query"];function logFeaturesList(s,o,e){if(o.debug){e.log("Enabling the following feature(s):");const t=[],r=[];!1!==o.autoprefixer&&r.push(" autoprefixer"),s.forEach(s=>{s.id.startsWith("before")||s.id.startsWith("after")?r.push(` ${s.id} (injected via options)`):r.push(` ${s.id}`),void 0!==bs[s.id]&&t.push(s.id)}),r.sort((s,o)=>s.localeCompare(o)),t.sort((s,o)=>s.localeCompare(o)),r.forEach(s=>e.log(s)),t.length&&(e.log("These feature(s) need a browser library to work:"),t.forEach(s=>e.log(` ${s}: ${bs[s]}`)))}}function initializeSharedOptions(s){if("preserve"in s){const o={};return o.preserve=s.preserve,o}return!1}function clamp(s,o,e){return Math.max(s,Math.min(o,e))}function stageFromOptions(s,o){let e=2;if(void 0===s.stage)return o.log("Using features from Stage 2 (default)."),e;if(!1===s.stage)e=5;else{let o=parseInt(s.stage,10);Number.isNaN(o)&&(o=0),e=clamp(0,o,5)}return 5===e?o.log('Stage has been disabled, features will be handled via the "features" option.'):o.log(`Using features from Stage ${e}.`),e}const vs=Symbol("insertBefore"),ys=Symbol("insertAfter"),ks=Symbol("insertOrder"),ws=Symbol("plugin");function getTransformedInsertions(s,o,e){if("insertBefore"!==e&&"insertAfter"!==e)return[];const t="insertBefore"===e?vs:ys,r=[];for(const e in o){if(!Object.hasOwnProperty.call(o,e))continue;if(!s.find(s=>s.id===e))continue;let i=o[e];Array.isArray(i)||(i=[i]);for(let s=0;sfeatureIsInsertedOrHasAPlugin(s)).sort((s,o)=>featureIsLess(s,o))}function getOptionsForBrowsersByFeature(s,o,e,t){switch(o.id){case"is-pseudo-class":return{onComplexSelector:"warning"};case"any-link-pseudo-class":if(s.find(s=>s.startsWith("ie ")||"edge 12"===s||"edge 13"===s||"edge 14"===s||"edge 15"===s||"edge 16"===s||"edge 17"===s||"edge 18"===s))return t.log("- 'any-link-pseudo-class' setting 'subFeatures: { areaHrefNeedsFixing: true }' due to lack of browser support for area[href] in Edge and IE."),{subFeatures:{areaHrefNeedsFixing:!0}};return{};case"logical-properties-and-values":case"float-clear-logical-values":case"logical-resize":case"logical-viewport-units":case"logical-overflow":case"logical-overscroll-behavior":return"logical"in e?e.logical:{};default:return{}}}const Os=["and_chr","and_ff","android","chrome","edge","firefox","ie","ios_saf","op_mini","op_mob","opera","safari","samsung"];function getUnsupportedBrowsersByFeature(s){if(!s)return[];if("position-area-property"===s.id)return["chrome 125","chrome 126","chrome 127","chrome 128","edge 125","edge 126","edge 127","edge 128","and_chr 125","and_chr 126","and_chr 127","and_chr 128","android 125","android 126","android 127","android 128","samsung 27","opera 111","opera 112","opera 113","opera 114","op_mob 83","op_mob 84","op_mob 85"];if(!("browser_support"in s))return["> 0%"];const o=[];return Os.forEach(e=>{if("op_mini"===e&&void 0===s.browser_support[e])return void o.push("op_mini all");const t=s.browser_support[e];"string"==typeof t&&Ps.test(t)?o.push(`${e} < ${s.browser_support[e]}`):o.push(`${e} >= 1`)}),o}const Ps=/^[0-9|.]+$/;function formatPolyfillableFeature(s){const o=getUnsupportedBrowsersByFeature(s);if(s[vs]||s[ys]){let e=s.id;return e=s.insertBefore?`before-${e}`:`after-${e}`,{browsers:o,vendors_implementations:s.vendors_implementations,plugin:s[ws],id:e,stage:6}}return{browsers:o,vendors_implementations:s.vendors_implementations,plugin:Fs.get(s.id),id:s.id,stage:s.stage}}function formatStagedFeature(s,o,e,t,r,i){let a,c;return a=getOptionsForBrowsersByFeature(s,e,r,i),a=t?Object.assign({},a,t,featureOptions(o,e.id)):Object.assign({},a,featureOptions(o,e.id)),"progressive-custom-properties"!==e.id&&(a.enableProgressiveCustomProperties=!1),"overflow-wrap-property"===e.id&&"preserve"in a&&(a.method=a.preserve?"copy":"replace"),c=e.plugin.postcss&&"function"==typeof e.plugin?e.plugin(a):e.plugin&&e.plugin.default&&"function"==typeof e.plugin.default&&e.plugin.default.postcss?e.plugin.default(a):e.plugin,{browsers:e.browsers,vendors_implementations:e.vendors_implementations,plugin:c,pluginOptions:a,id:e.id}}function featureOptions(s,o){if(!(o in s))return;const e=s[o];return Array.isArray(e)?e[1]:e}function intOrZero(s){const o=parseInt(s,10);return Number.isNaN(o)?0:o}const Cs=new Set(["progressive-custom-properties"]);function listFeatures(s,o,t,r){const i=Object(o.features),a="enableClientSidePolyfills"in o&&o.enableClientSidePolyfills,c=Object(o.insertBefore),p=Object(o.insertAfter),n=o.browsers?void 0:o.env,l=o.browsers,m=clamp(0,intOrZero(o.minimumVendorImplementations),3);m>0&&r.log(`Using features with ${m} or more vendor implementations.`);const u=stageFromOptions(o,r),d=prepareFeaturesList([...s,{id:"progressive-custom-properties"}],c,p).map(s=>formatPolyfillableFeature(s)).filter(s=>!!Cs.has(s.id)||(0===m||(!(!s[vs]&&!s[ys])||(m<=s.vendors_implementations||(!0===featureEnabledByOptions(i,s.id)?(r.log(`- '${s.id}' enabled manually even when it lacks the required interop (${s.vendors_implementations} out of ${m}).`),!0):(r.log(`- '${s.id}' disabled because it lacks the required interop (${s.vendors_implementations} out of ${m}).`),!1)))))),f=e(l,{env:n,ignoreUnknownVersions:!0}).filter(s=>Os.includes(s.split(" ")[0]));return d.filter(s=>{if(Cs.has(s.id))return!0;const o=s.stage>=u,e=a||!Ns.includes(s.id),t=featureEnabledByOptions(i,s.id),c=!1===t,p=!0===t||o&&e;return c?r.log(`- '${s.id}' disabled manually`):o?e||r.log(`- '${s.id}' disabled because 'enableClientSidePolyfills' is 'false'.`):p?r.log(`- '${s.id}' enabled manually even when it lacks the required stage (${s.stage} out of ${u}).`):r.log(`- '${s.id}' disabled because it lacks the required stage (${s.stage} out of ${u}).`),!c&&p}).map(s=>formatStagedFeature(f,i,s,t,o,r)).filter(s=>{if(Cs.has(s.id))return!0;const o=featureEnabledByOptions(i,s.id);if(!0===o||!1===o)return o;const t=e(s.browsers,{ignoreUnknownVersions:!0}),a=f.filter(s=>t.some(o=>o===s));return a.length>0?r.log(`- '${s.id}' enabled for:\n ${a.join("\n ")}`):r.log(`- '${s.id}' disabled because all targeted browsers support it.`),a.length>0})}function featureEnabledByOptions(s,o){if(!(o in s))return"auto";const e=s[o];return Array.isArray(e)?!0===e[0]||!1!==e[0]&&"auto":Boolean(e)}class Logger{constructor(){this.logs=[]}log(s){this.logs.push(s)}resetLogger(){this.logs.length=0}emitLogs(s){s&&s.warn(this.logs.join("\n")),this.resetLogger()}}var $s=[{packageName:"css-blank-pseudo",id:"blank-pseudo-class",importName:"postcssBlankPseudo"},{packageName:"css-has-pseudo",id:"has-pseudo-class",importName:"postcssHasPseudo"},{packageName:"css-prefers-color-scheme",id:"prefers-color-scheme-query",importName:"postcssPrefersColorScheme"},{packageName:"postcss-attribute-case-insensitive",id:"case-insensitive-attributes",importName:"postcssAttributeCaseInsensitive"},{packageName:"postcss-clamp",id:"clamp",importName:"postcssClamp"},{packageName:"@csstools/postcss-alpha-function",id:"alpha-function",importName:"postcssAlphaFunction"},{packageName:"@csstools/postcss-color-mix-variadic-function-arguments",id:"color-mix-variadic-function-arguments",importName:"postcssColorMixVariadicFunctionArguments"},{packageName:"@csstools/postcss-color-mix-function",id:"color-mix",importName:"postcssColorMixFunction"},{packageName:"@csstools/postcss-color-function",id:"color-function",importName:"postcssColorFunction"},{packageName:"@csstools/postcss-color-function-display-p3-linear",id:"color-function-display-p3-linear",importName:"postcssColorFunctionDisplayP3Linear"},{packageName:"postcss-color-functional-notation",id:"color-functional-notation",importName:"postcssColorFunctionalNotation"},{packageName:"postcss-color-hex-alpha",id:"hexadecimal-alpha-notation",importName:"postcssColorHexAlpha"},{packageName:"@csstools/postcss-content-alt-text",id:"content-alt-text",importName:"postcssContentAltText"},{packageName:"postcss-color-rebeccapurple",id:"rebeccapurple-color",importName:"postcssColorRebeccapurple"},{packageName:"@csstools/postcss-contrast-color-function",id:"contrast-color-function",importName:"postcssContrastColorFunction"},{packageName:"postcss-custom-media",id:"custom-media-queries",importName:"postcssCustomMedia"},{packageName:"postcss-custom-properties",id:"custom-properties",importName:"postcssCustomProperties"},{packageName:"postcss-custom-selectors",id:"custom-selectors",importName:"postcssCustomSelectors"},{packageName:"postcss-dir-pseudo-class",id:"dir-pseudo-class",importName:"postcssDirPseudoClass"},{packageName:"postcss-double-position-gradients",id:"double-position-gradients",importName:"postcssDoublePositionGradients"},{packageName:"@csstools/postcss-exponential-functions",id:"exponential-functions",importName:"postcssExponentialFunctions"},{packageName:"postcss-focus-visible",id:"focus-visible-pseudo-class",importName:"postcssFocusVisible"},{packageName:"postcss-focus-within",id:"focus-within-pseudo-class",importName:"postcssFocusWithin"},{packageName:"@csstools/postcss-font-format-keywords",id:"font-format-keywords",importName:"postcssFontFormatKeywords"},{packageName:"postcss-font-variant",id:"font-variant-property",importName:"postcssFontVariant"},{packageName:"@csstools/postcss-gamut-mapping",id:"gamut-mapping",importName:"postcssGamutMapping"},{packageName:"postcss-gap-properties",id:"gap-properties",importName:"postcssGapProperties"},{packageName:"@csstools/postcss-gradients-interpolation-method",id:"gradients-interpolation-method",importName:"postcssGradientsInterpolationMethod"},{packageName:"@csstools/postcss-hwb-function",id:"hwb-function",importName:"postcssHWBFunction"},{packageName:"@csstools/postcss-ic-unit",id:"ic-unit",importName:"postcssICUnit"},{packageName:"postcss-image-set-function",id:"image-set-function",importName:"postcssImageSetFunction"},{packageName:"@csstools/postcss-initial",id:"all-property",importName:"postcssInitial"},{packageName:"@csstools/postcss-is-pseudo-class",id:"is-pseudo-class",importName:"postcssIsPseudoClass"},{packageName:"@csstools/postcss-scope-pseudo-class",id:"scope-pseudo-class",importName:"postcssScopePseudoClass"},{packageName:"postcss-lab-function",id:"lab-function",importName:"postcssLabFunction"},{packageName:"@csstools/postcss-light-dark-function",id:"light-dark-function",importName:"postcssLightDarkFunction"},{packageName:"postcss-logical",id:"logical-properties-and-values",importName:"postcssLogical"},{packageName:"@csstools/postcss-logical-float-and-clear",id:"float-clear-logical-values",importName:"postcssLogicalFloatAndClear"},{packageName:"@csstools/postcss-logical-overflow",id:"logical-overflow",importName:"postcssLogicalOverflow"},{packageName:"@csstools/postcss-logical-overscroll-behavior",id:"logical-overscroll-behavior",importName:"postcssLogicalOverscrollBehavor"},{packageName:"@csstools/postcss-logical-resize",id:"logical-resize",importName:"postcssLogicalResize"},{packageName:"@csstools/postcss-logical-viewport-units",id:"logical-viewport-units",importName:"postcssLogicalViewportUnits"},{packageName:"@csstools/postcss-media-minmax",id:"media-query-ranges",importName:"postcssMediaMinmax"},{packageName:"@csstools/postcss-media-queries-aspect-ratio-number-values",id:"media-queries-aspect-ratio-number-values",importName:"postcssMediaQueriesAspectRatioNumberValues"},{packageName:"postcss-nesting",id:"nesting-rules",importName:"postcssNesting"},{packageName:"@csstools/postcss-normalize-display-values",id:"display-two-values",importName:"postcssNormalizeDisplayValues"},{packageName:"@csstools/postcss-oklab-function",id:"oklab-function",importName:"postcssOKLabFunction"},{packageName:"@csstools/postcss-relative-color-syntax",id:"relative-color-syntax",importName:"postcssRelativeColorSyntax"},{packageName:"postcss-opacity-percentage",id:"opacity-percentage",importName:"postcssOpacityPercentage"},{packageName:"postcss-overflow-shorthand",id:"overflow-property",importName:"postcssOverflowShorthand"},{packageName:"postcss-page-break",id:"break-properties",importName:"postcssPageBreak"},{packageName:"@csstools/postcss-position-area-property",id:"position-area-property",importName:"postcssPositionAreaProperty"},{packageName:"postcss-place",id:"place-properties",importName:"postcssPlace"},{packageName:"postcss-pseudo-class-any-link",id:"any-link-pseudo-class",importName:"postcssPseudoClassAnyLink"},{packageName:"postcss-replace-overflow-wrap",id:"overflow-wrap-property",importName:"postcssReplaceOverflowWrap"},{packageName:"postcss-selector-not",id:"not-pseudo-class",importName:"postcssSelectorNot"},{packageName:"@csstools/postcss-stepped-value-functions",id:"stepped-value-functions",importName:"postcssSteppedValueFunctions"},{packageName:"@csstools/postcss-system-ui-font-family",id:"system-ui-font-family",importName:"postcssSystemUIFontFamily"},{packageName:"@csstools/postcss-unset-value",id:"unset-value",importName:"postcssUnsetValue"},{packageName:"@csstools/postcss-cascade-layers",id:"cascade-layers",importName:"postcssCascadeLayers"},{packageName:"@csstools/postcss-trigonometric-functions",id:"trigonometric-functions",importName:"postcssTrigonometricFunctions"},{packageName:"@csstools/postcss-nested-calc",id:"nested-calc",importName:"postcssNestedCalc"},{packageName:"@csstools/postcss-text-decoration-shorthand",id:"text-decoration-shorthand",importName:"postcssTextDecorationShorthand"},{packageName:"@csstools/postcss-sign-functions",id:"sign-functions",importName:"postcssSignFunctions"},{packageName:"@csstools/postcss-random-function",id:"random-function",importName:"postcssRandomFunction"},{packageName:"@csstools/postcss-property-rule-prelude-list",id:"property-rule-prelude-list",importName:"postcssPropertyRulePreludeList"},{packageName:"@csstools/postcss-syntax-descriptor-syntax-production",id:"syntax-descriptor-syntax-production",importName:"postcssSyntaxDescriptorSyntaxProduction"},{packageName:"@csstools/postcss-progressive-custom-properties",id:"progressive-custom-properties",importName:"postcssProgressiveCustomProperties",omitTypedOptions:!0,omitDocs:!0}];function getPackageNamesToIds(){const s={};return $s.forEach(o=>{s[o.packageName]=o.id}),s}function pluginIdHelp(s,o,e){const t=$s.map(s=>s.id),r=$s.map(s=>s.packageName),i=getPackageNamesToIds();s.forEach(s=>{if(t.includes(s))return;const a=[...t.map(o=>[o,levenshteinDistance(s,o)]),...r.map(o=>[i[o],levenshteinDistance(s,o)])].sort((s,o)=>s[1]-o[1]).filter(s=>s[1]<10),c=new Set;for(let s=0;s=3));s++);if(!c.size)return void o.warn(e,`Unknown feature: "${s}", see the list of features https://github.com/csstools/postcss-plugins/blob/main/plugin-packs/postcss-preset-env/FEATURES.md`);let p='"';p+=Array.from(c).join('", "'),p+='"',o.warn(e,`Unknown feature: "${s}", did you mean one of: ${p}`)})}function levenshteinDistance(s,o){if(!s.length)return o.length;if(!o.length)return s.length;const e=[];for(let t=0;t<=o.length;t++){e[t]=[t];for(let r=1;r<=s.length;r++)e[t][r]=0===t?r:Math.min(e[t-1][r]+1,e[t][r-1]+1,e[t-1][r-1]+(s[r-1]===o[t-1]?0:1))}return e[o.length][s.length]}const creator=e=>{const t=new Logger,r=Object(e),i=Object.keys(Object(r.features)),a=r.browsers?void 0:r.env,c=r.browsers,p=initializeSharedOptions(r),n=listFeatures(o,r,p,t),l=n.map(s=>s.plugin);!1!==r.autoprefixer&&l.push(s(Object.assign({env:a,overrideBrowserslist:c},r.autoprefixer))),logFeaturesList(n,r,t);const internalPlugin=()=>({postcssPlugin:"postcss-preset-env",OnceExit(s,{result:o}){pluginIdHelp(i,s,o),r.debug&&t.emitLogs(o),t.resetLogger()}});return internalPlugin.postcss=!0,{postcssPlugin:"postcss-preset-env",plugins:[...l,internalPlugin()]}};creator.postcss=!0;export{creator as default}; +import s from"autoprefixer";import o from"cssdb";import e from"browserslist";import t from"@csstools/postcss-initial";import r from"@csstools/postcss-alpha-function";import i from"postcss-pseudo-class-any-link";import a from"css-blank-pseudo";import c from"postcss-page-break";import p from"@csstools/postcss-cascade-layers";import n from"postcss-attribute-case-insensitive";import l from"postcss-clamp";import m from"@csstools/postcss-color-function";import u from"@csstools/postcss-color-function-display-p3-linear";import d from"postcss-color-functional-notation";import f from"@csstools/postcss-color-mix-function";import g from"@csstools/postcss-color-mix-variadic-function-arguments";import h from"@csstools/postcss-content-alt-text";import b from"@csstools/postcss-contrast-color-function";import N from"postcss-custom-media";import v from"postcss-custom-properties";import y from"postcss-custom-selectors";import k from"postcss-dir-pseudo-class";import w from"@csstools/postcss-normalize-display-values";import x from"postcss-double-position-gradients";import F from"@csstools/postcss-exponential-functions";import O from"@csstools/postcss-logical-float-and-clear";import P from"postcss-focus-visible";import C from"postcss-focus-within";import $ from"@csstools/postcss-font-format-keywords";import S from"postcss-font-variant";import A from"@csstools/postcss-gamut-mapping";import _ from"postcss-gap-properties";import L from"@csstools/postcss-gradients-interpolation-method";import E from"css-has-pseudo";import I from"postcss-color-hex-alpha";import B from"@csstools/postcss-hwb-function";import q from"@csstools/postcss-ic-unit";import M from"postcss-image-set-function";import D from"@csstools/postcss-is-pseudo-class";import j from"postcss-lab-function";import z from"@csstools/postcss-light-dark-function";import U from"@csstools/postcss-logical-overflow";import R from"@csstools/postcss-logical-overscroll-behavior";import T from"postcss-logical";import V from"@csstools/postcss-logical-resize";import H from"@csstools/postcss-logical-viewport-units";import W from"@csstools/postcss-media-queries-aspect-ratio-number-values";import G from"@csstools/postcss-media-minmax";import K from"@csstools/postcss-nested-calc";import Z from"postcss-nesting";import Q from"postcss-selector-not";import J from"@csstools/postcss-oklab-function";import X from"postcss-opacity-percentage";import Y from"postcss-overflow-shorthand";import ss from"postcss-replace-overflow-wrap";import os from"postcss-place";import es from"@csstools/postcss-position-area-property";import ts from"css-prefers-color-scheme";import rs from"@csstools/postcss-progressive-custom-properties";import is from"@csstools/postcss-property-rule-prelude-list";import as from"@csstools/postcss-random-function";import cs from"postcss-color-rebeccapurple";import ps from"@csstools/postcss-relative-color-syntax";import ns from"@csstools/postcss-scope-pseudo-class";import ls from"@csstools/postcss-sign-functions";import ms from"@csstools/postcss-stepped-value-functions";import us from"@csstools/postcss-syntax-descriptor-syntax-production";import ds from"@csstools/postcss-system-ui-font-family";import fs from"@csstools/postcss-text-decoration-shorthand";import gs from"@csstools/postcss-trigonometric-functions";import hs from"@csstools/postcss-unset-value";const bs={"blank-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-blank-pseudo/README.md#browser","focus-visible-pseudo-class":"https://github.com/WICG/focus-visible","focus-within-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/postcss-focus-within/README.md#browser","has-pseudo-class":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-has-pseudo/README.md#browser","prefers-color-scheme-query":"https://github.com/csstools/postcss-plugins/blob/main/plugins/css-prefers-color-scheme/README.md#browser"},Ns=["blank-pseudo-class","focus-visible-pseudo-class","focus-within-pseudo-class","has-pseudo-class","prefers-color-scheme-query"];function logFeaturesList(s,o,e){if(o.debug){e.log("Enabling the following feature(s):");const t=[],r=[];!1!==o.autoprefixer&&r.push(" autoprefixer"),s.forEach(s=>{s.id.startsWith("before")||s.id.startsWith("after")?r.push(` ${s.id} (injected via options)`):r.push(` ${s.id}`),void 0!==bs[s.id]&&t.push(s.id)}),r.sort((s,o)=>s.localeCompare(o)),t.sort((s,o)=>s.localeCompare(o)),r.forEach(s=>e.log(s)),t.length&&(e.log("These feature(s) need a browser library to work:"),t.forEach(s=>e.log(` ${s}: ${bs[s]}`)))}}function initializeSharedOptions(s){if("preserve"in s){const o={};return o.preserve=s.preserve,o}return!1}function clamp(s,o,e){return Math.max(s,Math.min(o,e))}function stageFromOptions(s,o){let e=2;if(void 0===s.stage)return o.log("Using features from Stage 2 (default)."),e;if(!1===s.stage)e=5;else{let o=parseInt(s.stage,10);Number.isNaN(o)&&(o=0),e=clamp(0,o,5)}return 5===e?o.log('Stage has been disabled, features will be handled via the "features" option.'):o.log(`Using features from Stage ${e}.`),e}const vs=Symbol("insertBefore"),ys=Symbol("insertAfter"),ks=Symbol("insertOrder"),ws=Symbol("plugin");function getTransformedInsertions(s,o,e){if("insertBefore"!==e&&"insertAfter"!==e)return[];const t="insertBefore"===e?vs:ys,r=[];for(const e in o){if(!Object.hasOwnProperty.call(o,e))continue;if(!s.find(s=>s.id===e))continue;let i=o[e];Array.isArray(i)||(i=[i]);for(let s=0;sfeatureIsInsertedOrHasAPlugin(s)).sort((s,o)=>featureIsLess(s,o))}function getOptionsForBrowsersByFeature(s,o,e,t){switch(o.id){case"is-pseudo-class":return{onComplexSelector:"warning"};case"any-link-pseudo-class":if(s.find(s=>s.startsWith("ie ")||"edge 12"===s||"edge 13"===s||"edge 14"===s||"edge 15"===s||"edge 16"===s||"edge 17"===s||"edge 18"===s))return t.log("- 'any-link-pseudo-class' setting 'subFeatures: { areaHrefNeedsFixing: true }' due to lack of browser support for area[href] in Edge and IE."),{subFeatures:{areaHrefNeedsFixing:!0}};return{};case"logical-properties-and-values":case"float-clear-logical-values":case"logical-resize":case"logical-viewport-units":case"logical-overflow":case"logical-overscroll-behavior":return"logical"in e?e.logical:{};default:return{}}}const Os=["and_chr","and_ff","android","chrome","edge","firefox","ie","ios_saf","op_mini","op_mob","opera","safari","samsung"];function getUnsupportedBrowsersByFeature(s){if(!s)return[];if("position-area-property"===s.id)return["chrome 125","chrome 126","chrome 127","chrome 128","edge 125","edge 126","edge 127","edge 128","and_chr 125","and_chr 126","and_chr 127","and_chr 128","android 125","android 126","android 127","android 128","samsung 27","opera 111","opera 112","opera 113","opera 114","op_mob 83","op_mob 84","op_mob 85"];if(!("browser_support"in s))return["> 0%"];const o=[];return Os.forEach(e=>{if("op_mini"===e&&void 0===s.browser_support[e])return void o.push("op_mini all");const t=s.browser_support[e];"string"==typeof t&&Ps.test(t)?o.push(`${e} < ${s.browser_support[e]}`):o.push(`${e} >= 1`)}),o}const Ps=/^[0-9|.]+$/;function formatPolyfillableFeature(s){const o=getUnsupportedBrowsersByFeature(s);if(s[vs]||s[ys]){let e=s.id;return e=s.insertBefore?`before-${e}`:`after-${e}`,{browsers:o,vendors_implementations:s.vendors_implementations,plugin:s[ws],id:e,stage:6}}return{browsers:o,vendors_implementations:s.vendors_implementations,plugin:Fs.get(s.id),id:s.id,stage:s.stage}}function formatStagedFeature(s,o,e,t,r,i){let a,c;return a=getOptionsForBrowsersByFeature(s,e,r,i),a=t?Object.assign({},a,t,featureOptions(o,e.id)):Object.assign({},a,featureOptions(o,e.id)),"progressive-custom-properties"!==e.id&&(a.enableProgressiveCustomProperties=!1),"overflow-wrap-property"===e.id&&"preserve"in a&&(a.method=a.preserve?"copy":"replace"),c=e.plugin.postcss&&"function"==typeof e.plugin?e.plugin(a):e.plugin&&e.plugin.default&&"function"==typeof e.plugin.default&&e.plugin.default.postcss?e.plugin.default(a):e.plugin,{browsers:e.browsers,vendors_implementations:e.vendors_implementations,plugin:c,pluginOptions:a,id:e.id}}function featureOptions(s,o){if(!(o in s))return;const e=s[o];return Array.isArray(e)?e[1]:e}function intOrZero(s){const o=parseInt(s,10);return Number.isNaN(o)?0:o}const Cs=new Set(["progressive-custom-properties"]);function listFeatures(s,o,t,r){const i=Object(o.features),a="enableClientSidePolyfills"in o&&o.enableClientSidePolyfills,c=Object(o.insertBefore),p=Object(o.insertAfter),n=o.browsers?void 0:o.env,l=o.browsers,m=clamp(0,intOrZero(o.minimumVendorImplementations),3);m>0&&r.log(`Using features with ${m} or more vendor implementations.`);const u=stageFromOptions(o,r),d=prepareFeaturesList([...s,{id:"progressive-custom-properties"}],c,p).map(s=>formatPolyfillableFeature(s)).filter(s=>!!Cs.has(s.id)||(0===m||(!(!s[vs]&&!s[ys])||(m<=s.vendors_implementations||(!0===featureEnabledByOptions(i,s.id)?(r.log(`- '${s.id}' enabled manually even when it lacks the required interop (${s.vendors_implementations} out of ${m}).`),!0):(r.log(`- '${s.id}' disabled because it lacks the required interop (${s.vendors_implementations} out of ${m}).`),!1)))))),f=e(l,{env:n,ignoreUnknownVersions:!0}).filter(s=>Os.includes(s.split(" ")[0]));return d.filter(s=>{if(Cs.has(s.id))return!0;const o=s.stage>=u,e=a||!Ns.includes(s.id),t=featureEnabledByOptions(i,s.id),c=!1===t,p=!0===t||o&&e;return c?r.log(`- '${s.id}' disabled manually`):o?e||r.log(`- '${s.id}' disabled because 'enableClientSidePolyfills' is 'false'.`):p?r.log(`- '${s.id}' enabled manually even when it lacks the required stage (${s.stage} out of ${u}).`):r.log(`- '${s.id}' disabled because it lacks the required stage (${s.stage} out of ${u}).`),!c&&p}).map(s=>formatStagedFeature(f,i,s,t,o,r)).filter(s=>{if(Cs.has(s.id))return!0;const o=featureEnabledByOptions(i,s.id);if(!0===o||!1===o)return o;const t=e(s.browsers,{ignoreUnknownVersions:!0}),a=f.filter(s=>t.some(o=>o===s));return a.length>0?r.log(`- '${s.id}' enabled for:\n ${a.join("\n ")}`):r.log(`- '${s.id}' disabled because all targeted browsers support it.`),a.length>0})}function featureEnabledByOptions(s,o){if(!(o in s))return"auto";const e=s[o];return Array.isArray(e)?!0===e[0]||!1!==e[0]&&"auto":Boolean(e)}class Logger{constructor(){this.logs=[]}log(s){this.logs.push(s)}resetLogger(){this.logs.length=0}emitLogs(s){s&&s.warn(this.logs.join("\n")),this.resetLogger()}}var $s=[{packageName:"css-blank-pseudo",id:"blank-pseudo-class",importName:"postcssBlankPseudo"},{packageName:"css-has-pseudo",id:"has-pseudo-class",importName:"postcssHasPseudo"},{packageName:"css-prefers-color-scheme",id:"prefers-color-scheme-query",importName:"postcssPrefersColorScheme"},{packageName:"postcss-attribute-case-insensitive",id:"case-insensitive-attributes",importName:"postcssAttributeCaseInsensitive"},{packageName:"postcss-clamp",id:"clamp",importName:"postcssClamp"},{packageName:"@csstools/postcss-alpha-function",id:"alpha-function",importName:"postcssAlphaFunction"},{packageName:"@csstools/postcss-color-mix-variadic-function-arguments",id:"color-mix-variadic-function-arguments",importName:"postcssColorMixVariadicFunctionArguments"},{packageName:"@csstools/postcss-color-mix-function",id:"color-mix",importName:"postcssColorMixFunction"},{packageName:"@csstools/postcss-color-function",id:"color-function",importName:"postcssColorFunction"},{packageName:"@csstools/postcss-color-function-display-p3-linear",id:"color-function-display-p3-linear",importName:"postcssColorFunctionDisplayP3Linear"},{packageName:"postcss-color-functional-notation",id:"color-functional-notation",importName:"postcssColorFunctionalNotation"},{packageName:"postcss-color-hex-alpha",id:"hexadecimal-alpha-notation",importName:"postcssColorHexAlpha"},{packageName:"@csstools/postcss-content-alt-text",id:"content-alt-text",importName:"postcssContentAltText"},{packageName:"postcss-color-rebeccapurple",id:"rebeccapurple-color",importName:"postcssColorRebeccapurple"},{packageName:"@csstools/postcss-contrast-color-function",id:"contrast-color-function",importName:"postcssContrastColorFunction"},{packageName:"postcss-custom-media",id:"custom-media-queries",importName:"postcssCustomMedia"},{packageName:"postcss-custom-properties",id:"custom-properties",importName:"postcssCustomProperties"},{packageName:"postcss-custom-selectors",id:"custom-selectors",importName:"postcssCustomSelectors"},{packageName:"postcss-dir-pseudo-class",id:"dir-pseudo-class",importName:"postcssDirPseudoClass"},{packageName:"postcss-double-position-gradients",id:"double-position-gradients",importName:"postcssDoublePositionGradients"},{packageName:"@csstools/postcss-exponential-functions",id:"exponential-functions",importName:"postcssExponentialFunctions"},{packageName:"postcss-focus-visible",id:"focus-visible-pseudo-class",importName:"postcssFocusVisible"},{packageName:"postcss-focus-within",id:"focus-within-pseudo-class",importName:"postcssFocusWithin"},{packageName:"@csstools/postcss-font-format-keywords",id:"font-format-keywords",importName:"postcssFontFormatKeywords"},{packageName:"postcss-font-variant",id:"font-variant-property",importName:"postcssFontVariant"},{packageName:"@csstools/postcss-gamut-mapping",id:"gamut-mapping",importName:"postcssGamutMapping"},{packageName:"postcss-gap-properties",id:"gap-properties",importName:"postcssGapProperties"},{packageName:"@csstools/postcss-gradients-interpolation-method",id:"gradients-interpolation-method",importName:"postcssGradientsInterpolationMethod"},{packageName:"@csstools/postcss-hwb-function",id:"hwb-function",importName:"postcssHWBFunction"},{packageName:"@csstools/postcss-ic-unit",id:"ic-unit",importName:"postcssICUnit"},{packageName:"postcss-image-set-function",id:"image-set-function",importName:"postcssImageSetFunction"},{packageName:"@csstools/postcss-initial",id:"all-property",importName:"postcssInitial"},{packageName:"@csstools/postcss-is-pseudo-class",id:"is-pseudo-class",importName:"postcssIsPseudoClass"},{packageName:"@csstools/postcss-scope-pseudo-class",id:"scope-pseudo-class",importName:"postcssScopePseudoClass"},{packageName:"postcss-lab-function",id:"lab-function",importName:"postcssLabFunction"},{packageName:"@csstools/postcss-light-dark-function",id:"light-dark-function",importName:"postcssLightDarkFunction"},{packageName:"postcss-logical",id:"logical-properties-and-values",importName:"postcssLogical"},{packageName:"@csstools/postcss-logical-float-and-clear",id:"float-clear-logical-values",importName:"postcssLogicalFloatAndClear"},{packageName:"@csstools/postcss-logical-overflow",id:"logical-overflow",importName:"postcssLogicalOverflow"},{packageName:"@csstools/postcss-logical-overscroll-behavior",id:"logical-overscroll-behavior",importName:"postcssLogicalOverscrollBehavor"},{packageName:"@csstools/postcss-logical-resize",id:"logical-resize",importName:"postcssLogicalResize"},{packageName:"@csstools/postcss-logical-viewport-units",id:"logical-viewport-units",importName:"postcssLogicalViewportUnits"},{packageName:"@csstools/postcss-media-minmax",id:"media-query-ranges",importName:"postcssMediaMinmax"},{packageName:"@csstools/postcss-media-queries-aspect-ratio-number-values",id:"media-queries-aspect-ratio-number-values",importName:"postcssMediaQueriesAspectRatioNumberValues"},{packageName:"postcss-nesting",id:"nesting-rules",importName:"postcssNesting"},{packageName:"@csstools/postcss-normalize-display-values",id:"display-two-values",importName:"postcssNormalizeDisplayValues"},{packageName:"@csstools/postcss-oklab-function",id:"oklab-function",importName:"postcssOKLabFunction"},{packageName:"@csstools/postcss-relative-color-syntax",id:"relative-color-syntax",importName:"postcssRelativeColorSyntax"},{packageName:"postcss-opacity-percentage",id:"opacity-percentage",importName:"postcssOpacityPercentage"},{packageName:"postcss-overflow-shorthand",id:"overflow-property",importName:"postcssOverflowShorthand"},{packageName:"postcss-page-break",id:"break-properties",importName:"postcssPageBreak"},{packageName:"@csstools/postcss-position-area-property",id:"position-area-property",importName:"postcssPositionAreaProperty"},{packageName:"postcss-place",id:"place-properties",importName:"postcssPlace"},{packageName:"postcss-pseudo-class-any-link",id:"any-link-pseudo-class",importName:"postcssPseudoClassAnyLink"},{packageName:"postcss-replace-overflow-wrap",id:"overflow-wrap-property",importName:"postcssReplaceOverflowWrap"},{packageName:"postcss-selector-not",id:"not-pseudo-class",importName:"postcssSelectorNot"},{packageName:"@csstools/postcss-stepped-value-functions",id:"stepped-value-functions",importName:"postcssSteppedValueFunctions"},{packageName:"@csstools/postcss-system-ui-font-family",id:"system-ui-font-family",importName:"postcssSystemUIFontFamily"},{packageName:"@csstools/postcss-unset-value",id:"unset-value",importName:"postcssUnsetValue"},{packageName:"@csstools/postcss-cascade-layers",id:"cascade-layers",importName:"postcssCascadeLayers"},{packageName:"@csstools/postcss-trigonometric-functions",id:"trigonometric-functions",importName:"postcssTrigonometricFunctions"},{packageName:"@csstools/postcss-nested-calc",id:"nested-calc",importName:"postcssNestedCalc"},{packageName:"@csstools/postcss-text-decoration-shorthand",id:"text-decoration-shorthand",importName:"postcssTextDecorationShorthand"},{packageName:"@csstools/postcss-sign-functions",id:"sign-functions",importName:"postcssSignFunctions"},{packageName:"@csstools/postcss-random-function",id:"random-function",importName:"postcssRandomFunction"},{packageName:"@csstools/postcss-property-rule-prelude-list",id:"property-rule-prelude-list",importName:"postcssPropertyRulePreludeList"},{packageName:"@csstools/postcss-syntax-descriptor-syntax-production",id:"syntax-descriptor-syntax-production",importName:"postcssSyntaxDescriptorSyntaxProduction"},{packageName:"@csstools/postcss-progressive-custom-properties",id:"progressive-custom-properties",importName:"postcssProgressiveCustomProperties",omitTypedOptions:!0,omitDocs:!0}];function getPackageNamesToIds(){const s={};return $s.forEach(o=>{s[o.packageName]=o.id}),s}function pluginIdHelp(s,o,e){const t=$s.map(s=>s.id),r=$s.map(s=>s.packageName),i=getPackageNamesToIds();s.forEach(s=>{if(t.includes(s))return;const a=[...t.map(o=>[o,levenshteinDistance(s,o)]),...r.map(o=>[i[o],levenshteinDistance(s,o)])].sort((s,o)=>s[1]-o[1]).filter(s=>s[1]<10),c=new Set;for(let s=0;s=3));s++);if(!c.size)return void o.warn(e,`Unknown feature: "${s}", see the list of features https://github.com/csstools/postcss-plugins/blob/main/plugin-packs/postcss-preset-env/FEATURES.md`);let p='"';p+=Array.from(c).join('", "'),p+='"',o.warn(e,`Unknown feature: "${s}", did you mean one of: ${p}`)})}function levenshteinDistance(s,o){if(!s.length)return o.length;if(!o.length)return s.length;const e=[];for(let t=0;t<=o.length;t++){e[t]=[t];for(let r=1;r<=s.length;r++)e[t][r]=0===t?r:Math.min(e[t-1][r]+1,e[t][r-1]+1,e[t-1][r-1]+(s[r-1]===o[t-1]?0:1))}return e[o.length][s.length]}const creator=e=>{const t=new Logger,r=Object(e),i=Object.keys(Object(r.features)),a=r.browsers?void 0:r.env,c=r.browsers,p=initializeSharedOptions(r),n=listFeatures(o,r,p,t),l=n.map(s=>s.plugin);!1!==r.autoprefixer&&l.push(s(Object.assign({env:a,overrideBrowserslist:c},r.autoprefixer))),logFeaturesList(n,r,t);const internalPlugin=()=>({postcssPlugin:"postcss-preset-env",OnceExit(s,{result:o}){pluginIdHelp(i,s,o),r.debug&&t.emitLogs(o),t.resetLogger()}});return internalPlugin.postcss=!0,{postcssPlugin:"postcss-preset-env",plugins:[...l,internalPlugin()]}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugin-packs/postcss-preset-env/package.json b/plugin-packs/postcss-preset-env/package.json index f5b4e17ce..4c447073e 100644 --- a/plugin-packs/postcss-preset-env/package.json +++ b/plugin-packs/postcss-preset-env/package.json @@ -29,20 +29,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugin-packs/postcss-preset-env/src/index.ts b/plugin-packs/postcss-preset-env/src/index.ts index 931ef2a28..a53d91df2 100644 --- a/plugin-packs/postcss-preset-env/src/index.ts +++ b/plugin-packs/postcss-preset-env/src/index.ts @@ -70,3 +70,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins-stylelint/at-risk/package.json b/plugins-stylelint/at-risk/package.json index ed4c7e0a4..f52aac1e4 100644 --- a/plugins-stylelint/at-risk/package.json +++ b/plugins-stylelint/at-risk/package.json @@ -25,10 +25,9 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "index.mjs", "files": [ "LICENSE.md", "README.md", diff --git a/plugins-stylelint/formatter-github/package.json b/plugins-stylelint/formatter-github/package.json index ddd6d80f7..6b8b0ab49 100644 --- a/plugins-stylelint/formatter-github/package.json +++ b/plugins-stylelint/formatter-github/package.json @@ -25,10 +25,9 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "index.mjs", "files": [ "LICENSE.md", "README.md", diff --git a/plugins-stylelint/no-at-nest-rule/package.json b/plugins-stylelint/no-at-nest-rule/package.json index 0317e20a7..7af89d842 100644 --- a/plugins-stylelint/no-at-nest-rule/package.json +++ b/plugins-stylelint/no-at-nest-rule/package.json @@ -25,10 +25,9 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "index.mjs", "files": [ "LICENSE.md", "README.md", diff --git a/plugins-stylelint/no-invalid-at-import-rules-when-bundling/package.json b/plugins-stylelint/no-invalid-at-import-rules-when-bundling/package.json index abe863175..7ec59ab9d 100644 --- a/plugins-stylelint/no-invalid-at-import-rules-when-bundling/package.json +++ b/plugins-stylelint/no-invalid-at-import-rules-when-bundling/package.json @@ -25,10 +25,9 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "index.mjs", "files": [ "LICENSE.md", "README.md", diff --git a/plugins/css-blank-pseudo/CHANGELOG.md b/plugins/css-blank-pseudo/CHANGELOG.md index 77b6ad780..01f8c7dac 100644 --- a/plugins/css-blank-pseudo/CHANGELOG.md +++ b/plugins/css-blank-pseudo/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to CSS Blank Pseudo +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 7.0.1 _October 23, 2024_ diff --git a/plugins/css-blank-pseudo/dist/index.cjs b/plugins/css-blank-pseudo/dist/index.cjs deleted file mode 100644 index ce0b8c47f..000000000 --- a/plugins/css-blank-pseudo/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser");const s=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(e){let n=!0;for(let t=0,o=s.length;t-1&&(n=!1);return n}const n="js-blank-pseudo",t=":blank",creator=s=>{const o=Object.assign({preserve:!0,replaceWith:"[blank]",disablePolyfillReadyClass:!1},s),r=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"css-blank-pseudo",prepare(){const s=new WeakSet;return{postcssPlugin:"css-blank-pseudo",Rule(l,{result:a}){if(s.has(l))return;if(!l.selector.toLowerCase().includes(t))return;const i=l.selectors.flatMap(s=>{if(!s.toLowerCase().includes(t))return[s];let i;try{i=e().astSync(s)}catch(e){return l.warn(a,`Failed to parse selector : "${s}" with message: "${e instanceof Error?e.message:e}"`),[s]}if(void 0===i)return[s];let c=!1;if(i.walkPseudos(e=>{e.value.toLowerCase()===t&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(r.clone({}))))}),!c)return[s];const d=i.clone();if(!o.disablePolyfillReadyClass){if(i.nodes?.[0]?.nodes?.length)for(let s=0;s; export default creator; +export { creator as 'module.exports' } /** css-blank-pseudo plugin options */ export declare type pluginOptions = { diff --git a/plugins/css-blank-pseudo/dist/index.mjs b/plugins/css-blank-pseudo/dist/index.mjs index 840c00d2c..e74d93afb 100644 --- a/plugins/css-blank-pseudo/dist/index.mjs +++ b/plugins/css-blank-pseudo/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";const s=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(e){let n=!0;for(let t=0,o=s.length;t-1&&(n=!1);return n}const n="js-blank-pseudo",t=":blank",creator=s=>{const o=Object.assign({preserve:!0,replaceWith:"[blank]",disablePolyfillReadyClass:!1},s),r=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"css-blank-pseudo",prepare(){const s=new WeakSet;return{postcssPlugin:"css-blank-pseudo",Rule(l,{result:a}){if(s.has(l))return;if(!l.selector.toLowerCase().includes(t))return;const i=l.selectors.flatMap(s=>{if(!s.toLowerCase().includes(t))return[s];let i;try{i=e().astSync(s)}catch(e){return l.warn(a,`Failed to parse selector : "${s}" with message: "${e instanceof Error?e.message:e}"`),[s]}if(void 0===i)return[s];let c=!1;if(i.walkPseudos(e=>{e.value.toLowerCase()===t&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(r.clone({}))))}),!c)return[s];const d=i.clone();if(!o.disablePolyfillReadyClass){if(i.nodes?.[0]?.nodes?.length)for(let s=0;s","~",":","+","@","#","(",")"];function isValidReplacement(e){let n=!0;for(let t=0,o=s.length;t-1&&(n=!1);return n}const n="js-blank-pseudo",t=":blank",creator=s=>{const o=Object.assign({preserve:!0,replaceWith:"[blank]",disablePolyfillReadyClass:!1},s),r=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"css-blank-pseudo",prepare(){const s=new WeakSet;return{postcssPlugin:"css-blank-pseudo",Rule(l,{result:a}){if(s.has(l))return;if(!l.selector.toLowerCase().includes(t))return;const i=l.selectors.flatMap(s=>{if(!s.toLowerCase().includes(t))return[s];let i;try{i=e().astSync(s)}catch(e){return l.warn(a,`Failed to parse selector : "${s}" with message: "${e instanceof Error?e.message:e}"`),[s]}if(void 0===i)return[s];let c=!1;if(i.walkPseudos(e=>{e.value.toLowerCase()===t&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(r.clone({}))))}),!c)return[s];const d=i.clone();if(!o.disablePolyfillReadyClass){if(i.nodes?.[0]?.nodes?.length)for(let s=0;s; +export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/css-blank-pseudo/package.json b/plugins/css-blank-pseudo/package.json index 2573cd1ef..923a8e0e2 100644 --- a/plugins/css-blank-pseudo/package.json +++ b/plugins/css-blank-pseudo/package.json @@ -29,20 +29,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" }, "./browser": { "import": "./dist/browser.mjs", @@ -60,7 +54,8 @@ "dist" ], "dependencies": { - "postcss-selector-parser": "^7.1.1" + "postcss-selector-parser": "^7.1.1", + "typescript": "^5.9.3" }, "peerDependencies": { "postcss": "^8.4" @@ -75,7 +70,8 @@ "lint": "node ../../.github/bin/format-package-json.mjs", "prepublishOnly": "npm run build && npm run test", "test": "node --test", - "test:rewrite-expects": "REWRITE_EXPECTS=true node --test" + "test:rewrite-expects": "REWRITE_EXPECTS=true node --test", + "tsc": "tsc" }, "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/css-blank-pseudo#readme", "repository": { diff --git a/plugins/css-blank-pseudo/src/index.ts b/plugins/css-blank-pseudo/src/index.ts index 6971c8451..24ed4ff0e 100644 --- a/plugins/css-blank-pseudo/src/index.ts +++ b/plugins/css-blank-pseudo/src/index.ts @@ -147,3 +147,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/css-has-pseudo/CHANGELOG.md b/plugins/css-has-pseudo/CHANGELOG.md index 2a97aa709..b410b51b5 100644 --- a/plugins/css-has-pseudo/CHANGELOG.md +++ b/plugins/css-has-pseudo/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to CSS Has Pseudo +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 7.0.3 _August 27, 2025_ diff --git a/plugins/css-has-pseudo/dist/index.cjs b/plugins/css-has-pseudo/dist/index.cjs deleted file mode 100644 index d739b9264..000000000 --- a/plugins/css-has-pseudo/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser"),t=require("postcss-value-parser"),s=require("@csstools/selector-specificity");function encodeCSS(e){if(""===e)return"";let t,s="";for(let r=0;r{if("function"===e.type&&"selector"===e.value.toLowerCase())return r.add(t.stringify(e.nodes)),!1}),r.forEach(e=>{selectorContainsHasPseudo(e)&&(s=!0)})}catch{}return s}function selectorContainsHasPseudo(t){if(!t.toLowerCase().includes(":has("))return!1;let s=!1;try{e().astSync(t).walk(e=>{if("pseudo"===e.type&&":has"===e.value.toLowerCase()&&e.nodes&&e.nodes.length>0)return s=!0,!1})}catch{}return s}const creator=t=>{const r={preserve:!0,specificityMatchingName:"does-not-exist",...t||{}},o=":not(#"+r.specificityMatchingName+")",n=":not(."+r.specificityMatchingName+")",a=":not("+r.specificityMatchingName+")";return{postcssPlugin:"css-has-pseudo",prepare(){const t=new WeakSet;return{postcssPlugin:"css-has-pseudo",RuleExit(c,{result:i}){if(t.has(c))return;if(!c.selector.toLowerCase().includes(":has(")||isWithinSupportCheck(c))return;const l=c.selectors.map(t=>{if(!t.toLowerCase().includes(":has("))return t;let l;try{l=e().astSync(t)}catch(e){return c.warn(i,`Failed to parse selector : "${t}" with message: "${e instanceof Error?e.message:e}"`),t}if(void 0===l)return t;l.walkPseudos(t=>{let s=t.parent,o=!1;for(;s;)e.isPseudoClass(s)&&":has"===s.value.toLowerCase()&&(o=!0),s=s.parent;o&&(":visited"===t.value.toLowerCase()&&t.replaceWith(e.className({value:r.specificityMatchingName})),":any-link"===t.value.toLowerCase()&&(t.value=":link"))}),l.walkPseudos(t=>{if(":has"!==t.value.toLowerCase()||!t.nodes)return;const r=t.parent;if(!r)return;const c=e.selector({value:"",nodes:[]});{let t=r.nodes.length;e:for(let s=0;s=0;e--)if("combinator"!==r.nodes[s].type&&"comment"!==r.nodes[s].type){t=e+1;break e}}r.nodes.slice(0,t).forEach(e=>{e.remove(),"selector"===e.type?e.nodes.forEach(e=>{delete e.parent,c.append(e)}):(delete e.parent,c.append(e))})}const i="["+encodeCSS(c.toString())+"]",l=s.selectorSpecificity(c);let u=i;for(let e=0;e=0;e--)r.prepend(d[e])});const u=l.toString();return u!==t?".js-has-pseudo "+u:t});l.join(",")!==c.selectors.join(",")&&(t.add(c),c.cloneBefore({selectors:l}),r.preserve||c.remove())}}}}};function isWithinSupportCheck(e){let t=e.parent;for(;t;){if("atrule"===t.type&&isGuardedByAtSupportsFromAtRuleParams(t.params))return!0;t=t.parent}return!1}creator.postcss=!0,module.exports=creator; diff --git a/plugins/css-has-pseudo/dist/index.d.ts b/plugins/css-has-pseudo/dist/index.d.ts index fa7b73629..78fb6c6cc 100644 --- a/plugins/css-has-pseudo/dist/index.d.ts +++ b/plugins/css-has-pseudo/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** css-has-pseudo plugin options */ export declare type pluginOptions = { diff --git a/plugins/css-has-pseudo/dist/index.mjs b/plugins/css-has-pseudo/dist/index.mjs index 149469311..da12a7d5b 100644 --- a/plugins/css-has-pseudo/dist/index.mjs +++ b/plugins/css-has-pseudo/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";import t from"postcss-value-parser";import{selectorSpecificity as s}from"@csstools/selector-specificity";function encodeCSS(e){if(""===e)return"";let t,s="";for(let o=0;o{if("function"===e.type&&"selector"===e.value.toLowerCase())return o.add(t.stringify(e.nodes)),!1}),o.forEach(e=>{selectorContainsHasPseudo(e)&&(s=!0)})}catch{}return s}function selectorContainsHasPseudo(t){if(!t.toLowerCase().includes(":has("))return!1;let s=!1;try{e().astSync(t).walk(e=>{if("pseudo"===e.type&&":has"===e.value.toLowerCase()&&e.nodes&&e.nodes.length>0)return s=!0,!1})}catch{}return s}const creator=t=>{const o={preserve:!0,specificityMatchingName:"does-not-exist",...t||{}},r=":not(#"+o.specificityMatchingName+")",n=":not(."+o.specificityMatchingName+")",a=":not("+o.specificityMatchingName+")";return{postcssPlugin:"css-has-pseudo",prepare(){const t=new WeakSet;return{postcssPlugin:"css-has-pseudo",RuleExit(c,{result:i}){if(t.has(c))return;if(!c.selector.toLowerCase().includes(":has(")||isWithinSupportCheck(c))return;const l=c.selectors.map(t=>{if(!t.toLowerCase().includes(":has("))return t;let l;try{l=e().astSync(t)}catch(e){return c.warn(i,`Failed to parse selector : "${t}" with message: "${e instanceof Error?e.message:e}"`),t}if(void 0===l)return t;l.walkPseudos(t=>{let s=t.parent,r=!1;for(;s;)e.isPseudoClass(s)&&":has"===s.value.toLowerCase()&&(r=!0),s=s.parent;r&&(":visited"===t.value.toLowerCase()&&t.replaceWith(e.className({value:o.specificityMatchingName})),":any-link"===t.value.toLowerCase()&&(t.value=":link"))}),l.walkPseudos(t=>{if(":has"!==t.value.toLowerCase()||!t.nodes)return;const o=t.parent;if(!o)return;const c=e.selector({value:"",nodes:[]});{let t=o.nodes.length;e:for(let s=0;s=0;e--)if("combinator"!==o.nodes[s].type&&"comment"!==o.nodes[s].type){t=e+1;break e}}o.nodes.slice(0,t).forEach(e=>{e.remove(),"selector"===e.type?e.nodes.forEach(e=>{delete e.parent,c.append(e)}):(delete e.parent,c.append(e))})}const i="["+encodeCSS(c.toString())+"]",l=s(c);let u=i;for(let e=0;e=0;e--)o.prepend(d[e])});const u=l.toString();return u!==t?".js-has-pseudo "+u:t});l.join(",")!==c.selectors.join(",")&&(t.add(c),c.cloneBefore({selectors:l}),o.preserve||c.remove())}}}}};function isWithinSupportCheck(e){let t=e.parent;for(;t;){if("atrule"===t.type&&isGuardedByAtSupportsFromAtRuleParams(t.params))return!0;t=t.parent}return!1}creator.postcss=!0;export{creator as default}; +import e from"postcss-selector-parser";import t from"postcss-value-parser";import{selectorSpecificity as s}from"@csstools/selector-specificity";function encodeCSS(e){if(""===e)return"";let t,s="";for(let o=0;o{if("function"===e.type&&"selector"===e.value.toLowerCase())return o.add(t.stringify(e.nodes)),!1}),o.forEach(e=>{selectorContainsHasPseudo(e)&&(s=!0)})}catch{}return s}function selectorContainsHasPseudo(t){if(!t.toLowerCase().includes(":has("))return!1;let s=!1;try{e().astSync(t).walk(e=>{if("pseudo"===e.type&&":has"===e.value.toLowerCase()&&e.nodes&&e.nodes.length>0)return s=!0,!1})}catch{}return s}const creator=t=>{const o={preserve:!0,specificityMatchingName:"does-not-exist",...t||{}},r=":not(#"+o.specificityMatchingName+")",n=":not(."+o.specificityMatchingName+")",a=":not("+o.specificityMatchingName+")";return{postcssPlugin:"css-has-pseudo",prepare(){const t=new WeakSet;return{postcssPlugin:"css-has-pseudo",RuleExit(c,{result:i}){if(t.has(c))return;if(!c.selector.toLowerCase().includes(":has(")||isWithinSupportCheck(c))return;const l=c.selectors.map(t=>{if(!t.toLowerCase().includes(":has("))return t;let l;try{l=e().astSync(t)}catch(e){return c.warn(i,`Failed to parse selector : "${t}" with message: "${e instanceof Error?e.message:e}"`),t}if(void 0===l)return t;l.walkPseudos(t=>{let s=t.parent,r=!1;for(;s;)e.isPseudoClass(s)&&":has"===s.value.toLowerCase()&&(r=!0),s=s.parent;r&&(":visited"===t.value.toLowerCase()&&t.replaceWith(e.className({value:o.specificityMatchingName})),":any-link"===t.value.toLowerCase()&&(t.value=":link"))}),l.walkPseudos(t=>{if(":has"!==t.value.toLowerCase()||!t.nodes)return;const o=t.parent;if(!o)return;const c=e.selector({value:"",nodes:[]});{let t=o.nodes.length;e:for(let s=0;s=0;e--)if("combinator"!==o.nodes[s].type&&"comment"!==o.nodes[s].type){t=e+1;break e}}o.nodes.slice(0,t).forEach(e=>{e.remove(),"selector"===e.type?e.nodes.forEach(e=>{delete e.parent,c.append(e)}):(delete e.parent,c.append(e))})}const i="["+encodeCSS(c.toString())+"]",l=s(c);let u=i;for(let e=0;e=0;e--)o.prepend(d[e])});const u=l.toString();return u!==t?".js-has-pseudo "+u:t});l.join(",")!==c.selectors.join(",")&&(t.add(c),c.cloneBefore({selectors:l}),o.preserve||c.remove())}}}}};function isWithinSupportCheck(e){let t=e.parent;for(;t;){if("atrule"===t.type&&isGuardedByAtSupportsFromAtRuleParams(t.params))return!0;t=t.parent}return!1}creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/css-has-pseudo/package.json b/plugins/css-has-pseudo/package.json index f8f4864b7..d5472e3db 100644 --- a/plugins/css-has-pseudo/package.json +++ b/plugins/css-has-pseudo/package.json @@ -29,20 +29,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" }, "./browser": { "import": "./dist/browser.mjs", diff --git a/plugins/css-has-pseudo/src/index.ts b/plugins/css-has-pseudo/src/index.ts index 6ca568cb5..8a2d4f8c2 100644 --- a/plugins/css-has-pseudo/src/index.ts +++ b/plugins/css-has-pseudo/src/index.ts @@ -197,6 +197,7 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; function isWithinSupportCheck(rule: Rule): boolean { let ruleParent: Container | Document | undefined = rule.parent; diff --git a/plugins/css-prefers-color-scheme/CHANGELOG.md b/plugins/css-prefers-color-scheme/CHANGELOG.md index 65fcc363c..8ab1ce26e 100644 --- a/plugins/css-prefers-color-scheme/CHANGELOG.md +++ b/plugins/css-prefers-color-scheme/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to Prefers Color Scheme +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 10.0.0 _August 3, 2024_ diff --git a/plugins/css-prefers-color-scheme/dist/index.cjs b/plugins/css-prefers-color-scheme/dist/index.cjs deleted file mode 100644 index 052124ac3..000000000 --- a/plugins/css-prefers-color-scheme/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";const e=/\(\s*prefers-color-scheme\s*:\s*(dark|light)\s*\)/gi,s="(color: 48842621)",r="(color: 70318723)",creator=o=>{const t=Object.assign({preserve:!0},o);return{postcssPlugin:"postcss-prefers-color-scheme",prepare(){const o=new WeakSet;return{postcssPlugin:"postcss-prefers-color-scheme",AtRule(c){if(o.has(c))return;if("media"!==c.name.toLowerCase())return;const{params:a}=c,p=a.replace(e,(e,o)=>"dark"===o.toLowerCase()?s:"light"===o.toLowerCase()?r:e);a!==p&&(o.add(c),c.cloneBefore({params:p}),t.preserve||c.remove())}}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/css-prefers-color-scheme/dist/index.d.ts b/plugins/css-prefers-color-scheme/dist/index.d.ts index c401d2a20..be6e2f6f4 100644 --- a/plugins/css-prefers-color-scheme/dist/index.d.ts +++ b/plugins/css-prefers-color-scheme/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-prefers-color-scheme plugin options */ export declare type pluginOptions = { diff --git a/plugins/css-prefers-color-scheme/dist/index.mjs b/plugins/css-prefers-color-scheme/dist/index.mjs index fdbf13bf7..a2721139d 100644 --- a/plugins/css-prefers-color-scheme/dist/index.mjs +++ b/plugins/css-prefers-color-scheme/dist/index.mjs @@ -1 +1 @@ -const e=/\(\s*prefers-color-scheme\s*:\s*(dark|light)\s*\)/gi,s="(color: 48842621)",r="(color: 70318723)",creator=o=>{const t=Object.assign({preserve:!0},o);return{postcssPlugin:"postcss-prefers-color-scheme",prepare(){const o=new WeakSet;return{postcssPlugin:"postcss-prefers-color-scheme",AtRule(c){if(o.has(c))return;if("media"!==c.name.toLowerCase())return;const{params:a}=c,p=a.replace(e,(e,o)=>"dark"===o.toLowerCase()?s:"light"===o.toLowerCase()?r:e);a!==p&&(o.add(c),c.cloneBefore({params:p}),t.preserve||c.remove())}}}}};creator.postcss=!0;export{creator as default}; +const e=/\(\s*prefers-color-scheme\s*:\s*(dark|light)\s*\)/gi,s="(color: 48842621)",r="(color: 70318723)",creator=o=>{const t=Object.assign({preserve:!0},o);return{postcssPlugin:"postcss-prefers-color-scheme",prepare(){const o=new WeakSet;return{postcssPlugin:"postcss-prefers-color-scheme",AtRule(a){if(o.has(a))return;if("media"!==a.name.toLowerCase())return;const{params:c}=a,p=c.replace(e,(e,o)=>"dark"===o.toLowerCase()?s:"light"===o.toLowerCase()?r:e);c!==p&&(o.add(a),a.cloneBefore({params:p}),t.preserve||a.remove())}}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/css-prefers-color-scheme/package.json b/plugins/css-prefers-color-scheme/package.json index 27d76e538..6f7dadd39 100644 --- a/plugins/css-prefers-color-scheme/package.json +++ b/plugins/css-prefers-color-scheme/package.json @@ -29,20 +29,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" }, "./browser": { "import": "./dist/browser.mjs", diff --git a/plugins/css-prefers-color-scheme/src/index.ts b/plugins/css-prefers-color-scheme/src/index.ts index bc6c254d1..39d1c274e 100644 --- a/plugins/css-prefers-color-scheme/src/index.ts +++ b/plugins/css-prefers-color-scheme/src/index.ts @@ -67,4 +67,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-alpha-function/CHANGELOG.md b/plugins/postcss-alpha-function/CHANGELOG.md index eed3f1765..21d1ad631 100644 --- a/plugins/postcss-alpha-function/CHANGELOG.md +++ b/plugins/postcss-alpha-function/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Alpha Function +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 1.0.1 _September 21, 2025_ diff --git a/plugins/postcss-alpha-function/dist/index.cjs b/plugins/postcss-alpha-function/dist/index.cjs deleted file mode 100644 index c519bcb99..000000000 --- a/plugins/postcss-alpha-function/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),o=require("@csstools/css-tokenizer"),s=require("@csstools/css-color-parser"),t=require("@csstools/utilities"),r=require("@csstools/css-parser-algorithms");const n=/\balpha\(/i,a=/^alpha$/i,l=new Set(["srgb","srgb-linear","display-p3","display-p3-linear","a98-rgb","prophoto-rgb","rec2020","xyz","xyz-d50","xyz-d65"]),basePlugin=e=>({postcssPlugin:"postcss-color-function",Declaration(i){const c=i.value;if(!n.test(c))return;if(t.hasFallback(i))return;if(t.hasSupportsAtRuleAncestor(i,n))return;const v=o.tokenize({css:c}),u=r.replaceComponentValues(r.parseCommaSeparatedListOfComponentValues(v),e=>{if(r.isFunctionNode(e)&&a.test(e.getName()))for(let t=0;t{const s=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},o);return s.enableProgressiveCustomProperties&&s.preserve?{postcssPlugin:"postcss-color-function",plugins:[e(),basePlugin(s)]}:basePlugin(s)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-alpha-function/dist/index.d.ts b/plugins/postcss-alpha-function/dist/index.d.ts index 830368cd4..9d076aff3 100644 --- a/plugins/postcss-alpha-function/dist/index.d.ts +++ b/plugins/postcss-alpha-function/dist/index.d.ts @@ -11,5 +11,6 @@ export declare type pluginOptions = { /** Transform the color() function in CSS. */ declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-alpha-function/dist/index.mjs b/plugins/postcss-alpha-function/dist/index.mjs index 97dca6a5a..ef71ea642 100644 --- a/plugins/postcss-alpha-function/dist/index.mjs +++ b/plugins/postcss-alpha-function/dist/index.mjs @@ -1 +1 @@ -import e from"@csstools/postcss-progressive-custom-properties";import{tokenize as o,isTokenIdent as r,TokenType as s,isTokenHash as t}from"@csstools/css-tokenizer";import{color as l,SyntaxFlag as a}from"@csstools/css-color-parser";import{hasFallback as n,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as c,parseCommaSeparatedListOfComponentValues as v,isFunctionNode as u,isWhiteSpaceOrCommentNode as p,isTokenNode as d,WhitespaceNode as h,TokenNode as f,stringify as g}from"@csstools/css-parser-algorithms";const b=/\balpha\(/i,w=/^alpha$/i,m=new Set(["srgb","srgb-linear","display-p3","display-p3-linear","a98-rgb","prophoto-rgb","rec2020","xyz","xyz-d50","xyz-d65"]),basePlugin=e=>({postcssPlugin:"postcss-color-function",Declaration(C){const y=C.value;if(!b.test(y))return;if(n(C))return;if(i(C,b))return;const x=o({css:y}),R=c(v(x),e=>{if(u(e)&&w.test(e.getName()))for(let o=0;o{const r=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},o);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-color-function",plugins:[e(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import e from"@csstools/postcss-progressive-custom-properties";import{tokenize as o,isTokenIdent as r,TokenType as s,isTokenHash as t}from"@csstools/css-tokenizer";import{color as l,SyntaxFlag as a}from"@csstools/css-color-parser";import{hasFallback as n,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as c,parseCommaSeparatedListOfComponentValues as v,isFunctionNode as u,isWhiteSpaceOrCommentNode as p,isTokenNode as d,WhitespaceNode as h,TokenNode as f,stringify as g}from"@csstools/css-parser-algorithms";const b=/\balpha\(/i,m=/^alpha$/i,w=new Set(["srgb","srgb-linear","display-p3","display-p3-linear","a98-rgb","prophoto-rgb","rec2020","xyz","xyz-d50","xyz-d65"]),basePlugin=e=>({postcssPlugin:"postcss-color-function",Declaration(C){const x=C.value;if(!b.test(x))return;if(n(C))return;if(i(C,b))return;const y=o({css:x}),R=c(v(y),e=>{if(u(e)&&m.test(e.getName()))for(let o=0;o{const r=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},o);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-color-function",plugins:[e(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-alpha-function/package.json b/plugins/postcss-alpha-function/package.json index 948d87091..b907ab700 100644 --- a/plugins/postcss-alpha-function/package.json +++ b/plugins/postcss-alpha-function/package.json @@ -20,20 +20,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-alpha-function/src/index.ts b/plugins/postcss-alpha-function/src/index.ts index e8a76911d..554ed1cf5 100644 --- a/plugins/postcss-alpha-function/src/index.ts +++ b/plugins/postcss-alpha-function/src/index.ts @@ -219,3 +219,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-attribute-case-insensitive/CHANGELOG.md b/plugins/postcss-attribute-case-insensitive/CHANGELOG.md index 2a4175855..9df110d95 100644 --- a/plugins/postcss-attribute-case-insensitive/CHANGELOG.md +++ b/plugins/postcss-attribute-case-insensitive/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Attribute Case Insensitive +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 7.0.1 _October 23, 2024_ diff --git a/plugins/postcss-attribute-case-insensitive/dist/index.cjs b/plugins/postcss-attribute-case-insensitive/dist/index.cjs deleted file mode 100644 index 7df6875eb..000000000 --- a/plugins/postcss-attribute-case-insensitive/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser");function nodeIsInsensitiveAttribute(e){return"attribute"===e.type&&(e.insensitive??!1)}function selectorHasInsensitiveAttribute(e){return e.some(nodeIsInsensitiveAttribute)}function transformString(e,t,s){const r=s.charAt(t);if(""===r)return e;let n=e.map(e=>e+r);const o=r.toLocaleUpperCase();return o!==r&&(n=n.concat(e.map(e=>e+o))),transformString(n,t+1,s)}function createNewSelectors(t){let s=[e.selector({value:"",nodes:[]})];return t.each(e=>{if(!nodeIsInsensitiveAttribute(e))return void s.forEach(t=>{t.append(e.clone())});const t=transformString([""],0,(r=e).value??"").map(e=>{const t=r.clone({spaces:{after:r.spaces.after,before:r.spaces.before},insensitive:!1});return t.setValue(e),t});var r;const n=[];t.forEach(e=>{s.forEach(t=>{const s=t.clone({});s.append(e),n.push(s)})}),s=n}),s}const creator=t=>{const s=Object.assign({preserve:!1},t);return{postcssPlugin:"postcss-attribute-case-insensitive",prepare(){const t=new WeakSet;return{postcssPlugin:"postcss-attribute-case-insensitive",Rule(r,{result:n}){if(t.has(r))return;if(!/i\s*\]/i.test(r.selector))return;let o;try{o=e(e=>{let t=[];e.each(e=>{selectorHasInsensitiveAttribute(e)&&(t=t.concat(createNewSelectors(e)),e.remove())}),t.length&&t.forEach(t=>e.append(t))}).processSync(r.selector)}catch(e){return void r.warn(n,`Failed to parse selector : "${r.selector}" with message: "${e instanceof Error?e.message:e}"`)}o!==r.selector&&(t.add(r),r.cloneBefore({selector:o}),s.preserve||r.remove())}}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-attribute-case-insensitive/dist/index.d.ts b/plugins/postcss-attribute-case-insensitive/dist/index.d.ts index ba9565d22..d47b21116 100644 --- a/plugins/postcss-attribute-case-insensitive/dist/index.d.ts +++ b/plugins/postcss-attribute-case-insensitive/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-prefers-color-scheme plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-attribute-case-insensitive/dist/index.mjs b/plugins/postcss-attribute-case-insensitive/dist/index.mjs index df739d6b0..15372287a 100644 --- a/plugins/postcss-attribute-case-insensitive/dist/index.mjs +++ b/plugins/postcss-attribute-case-insensitive/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";function nodeIsInsensitiveAttribute(e){return"attribute"===e.type&&(e.insensitive??!1)}function selectorHasInsensitiveAttribute(e){return e.some(nodeIsInsensitiveAttribute)}function transformString(e,t,s){const r=s.charAt(t);if(""===r)return e;let n=e.map(e=>e+r);const o=r.toLocaleUpperCase();return o!==r&&(n=n.concat(e.map(e=>e+o))),transformString(n,t+1,s)}function createNewSelectors(t){let s=[e.selector({value:"",nodes:[]})];return t.each(e=>{if(!nodeIsInsensitiveAttribute(e))return void s.forEach(t=>{t.append(e.clone())});const t=transformString([""],0,(r=e).value??"").map(e=>{const t=r.clone({spaces:{after:r.spaces.after,before:r.spaces.before},insensitive:!1});return t.setValue(e),t});var r;const n=[];t.forEach(e=>{s.forEach(t=>{const s=t.clone({});s.append(e),n.push(s)})}),s=n}),s}const creator=t=>{const s=Object.assign({preserve:!1},t);return{postcssPlugin:"postcss-attribute-case-insensitive",prepare(){const t=new WeakSet;return{postcssPlugin:"postcss-attribute-case-insensitive",Rule(r,{result:n}){if(t.has(r))return;if(!/i\s*\]/i.test(r.selector))return;let o;try{o=e(e=>{let t=[];e.each(e=>{selectorHasInsensitiveAttribute(e)&&(t=t.concat(createNewSelectors(e)),e.remove())}),t.length&&t.forEach(t=>e.append(t))}).processSync(r.selector)}catch(e){return void r.warn(n,`Failed to parse selector : "${r.selector}" with message: "${e instanceof Error?e.message:e}"`)}o!==r.selector&&(t.add(r),r.cloneBefore({selector:o}),s.preserve||r.remove())}}}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-selector-parser";function nodeIsInsensitiveAttribute(e){return"attribute"===e.type&&(e.insensitive??!1)}function selectorHasInsensitiveAttribute(e){return e.some(nodeIsInsensitiveAttribute)}function transformString(e,t,s){const r=s.charAt(t);if(""===r)return e;let n=e.map(e=>e+r);const o=r.toLocaleUpperCase();return o!==r&&(n=n.concat(e.map(e=>e+o))),transformString(n,t+1,s)}function createNewSelectors(t){let s=[e.selector({value:"",nodes:[]})];return t.each(e=>{if(!nodeIsInsensitiveAttribute(e))return void s.forEach(t=>{t.append(e.clone())});const t=transformString([""],0,(r=e).value??"").map(e=>{const t=r.clone({spaces:{after:r.spaces.after,before:r.spaces.before},insensitive:!1});return t.setValue(e),t});var r;const n=[];t.forEach(e=>{s.forEach(t=>{const s=t.clone({});s.append(e),n.push(s)})}),s=n}),s}const creator=t=>{const s=Object.assign({preserve:!1},t);return{postcssPlugin:"postcss-attribute-case-insensitive",prepare(){const t=new WeakSet;return{postcssPlugin:"postcss-attribute-case-insensitive",Rule(r,{result:n}){if(t.has(r))return;if(!/i\s*\]/i.test(r.selector))return;let o;try{o=e(e=>{let t=[];e.each(e=>{selectorHasInsensitiveAttribute(e)&&(t=t.concat(createNewSelectors(e)),e.remove())}),t.length&&t.forEach(t=>e.append(t))}).processSync(r.selector)}catch(e){return void r.warn(n,`Failed to parse selector : "${r.selector}" with message: "${e instanceof Error?e.message:e}"`)}o!==r.selector&&(t.add(r),r.cloneBefore({selector:o}),s.preserve||r.remove())}}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-attribute-case-insensitive/package.json b/plugins/postcss-attribute-case-insensitive/package.json index 2dae883eb..e46dea67b 100644 --- a/plugins/postcss-attribute-case-insensitive/package.json +++ b/plugins/postcss-attribute-case-insensitive/package.json @@ -28,20 +28,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-attribute-case-insensitive/src/index.ts b/plugins/postcss-attribute-case-insensitive/src/index.ts index 7db3f5622..965101882 100644 --- a/plugins/postcss-attribute-case-insensitive/src/index.ts +++ b/plugins/postcss-attribute-case-insensitive/src/index.ts @@ -143,4 +143,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-base-plugin/dist/index.cjs b/plugins/postcss-base-plugin/dist/index.cjs deleted file mode 100644 index affdc47ef..000000000 --- a/plugins/postcss-base-plugin/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";const creator=e=>{const r=Object.assign({color:null,preserve:!1},e);return{postcssPlugin:"postcss-base-plugin",Declaration(e){if("red"===e.value){let o="blue";if(r.color&&(o=r.color),o===e.value)return;if(e.cloneBefore({prop:"color",value:o}),r.preserve)return;e.remove()}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-base-plugin/dist/index.d.ts b/plugins/postcss-base-plugin/dist/index.d.ts index be70ff742..37261f69b 100644 --- a/plugins/postcss-base-plugin/dist/index.d.ts +++ b/plugins/postcss-base-plugin/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-base-plugin plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-base-plugin/dist/index.mjs b/plugins/postcss-base-plugin/dist/index.mjs index 8850dfc53..194a6cee7 100644 --- a/plugins/postcss-base-plugin/dist/index.mjs +++ b/plugins/postcss-base-plugin/dist/index.mjs @@ -1 +1 @@ -const creator=e=>{const r=Object.assign({color:null,preserve:!1},e);return{postcssPlugin:"postcss-base-plugin",Declaration(e){if("red"===e.value){let o="blue";if(r.color&&(o=r.color),o===e.value)return;if(e.cloneBefore({prop:"color",value:o}),r.preserve)return;e.remove()}}}};creator.postcss=!0;export{creator as default}; +const creator=e=>{const o=Object.assign({color:null,preserve:!1},e);return{postcssPlugin:"postcss-base-plugin",Declaration(e){if("red"===e.value){let r="blue";if(o.color&&(r=o.color),r===e.value)return;if(e.cloneBefore({prop:"color",value:r}),o.preserve)return;e.remove()}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-base-plugin/package.json b/plugins/postcss-base-plugin/package.json index c54922d99..d18a6d8a0 100644 --- a/plugins/postcss-base-plugin/package.json +++ b/plugins/postcss-base-plugin/package.json @@ -26,20 +26,14 @@ ], "private": true, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-base-plugin/src/index.ts b/plugins/postcss-base-plugin/src/index.ts index d9de7c4e8..f6383dddd 100644 --- a/plugins/postcss-base-plugin/src/index.ts +++ b/plugins/postcss-base-plugin/src/index.ts @@ -55,3 +55,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-browser-comments/CHANGELOG.md b/plugins/postcss-browser-comments/CHANGELOG.md index de16e57b3..5381df148 100644 --- a/plugins/postcss-browser-comments/CHANGELOG.md +++ b/plugins/postcss-browser-comments/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Browser Comments +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 6.0.2 _November 26, 2025_ diff --git a/plugins/postcss-browser-comments/dist/index.cjs b/plugins/postcss-browser-comments/dist/index.cjs deleted file mode 100644 index ac75902d9..000000000 --- a/plugins/postcss-browser-comments/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("browserslist");const creator=s=>({postcssPlugin:"postcss-browser-comments",Once(t){const r=new Set(e(s?.browsers??null,{path:t?.source?.input.file})),o=t.nodes.slice(0);for(const s of o){if(!isBrowserCommentNode(s))continue;const t=s.next();if(!t||"rule"!==t.type)continue;const o=getBrowserData(s.text);o.isNumbered?(t.nodes.filter(isBrowserReferenceCommentNode).map(s=>{const t=parseFloat(s.text)-1,n=e(o.browserslist[t]);browserslistsOverlap(r,n)||(s.prev()?.remove(),s.remove())}),t.nodes.length||(t.remove(),s.remove())):browserslistsOverlap(r,e(o.browserslist))||(t.remove(),s.remove())}}});function isBrowserCommentNode(e){return"comment"===e.type&&(!!s.test(e.text)&&"rule"===e.next()?.type)}creator.postcss=!0;const s=/^\*\n +/;function isBrowserReferenceCommentNode(e){return"comment"===e.type&&t.test(e.text)}const t=/^\d+$/;function getBrowserData(e){const s=e.match(r);return s?{browserslist:s.map(e=>getBrowsersList(e.replace(n,"$1"))),isNumbered:!0}:{browserslist:getBrowsersList(e.replace(o,"")),isNumbered:!1}}const r=/(\n \* \d+\. (?:[^\n]|\n \* {4,})+)/g,o=/^\*\n \* ?|\n \*/g,n=/\n \* (?:( )\s*)?/g;function getBrowsersList(e){return e.split(i).slice(1).map(e=>e.split(c).filter(e=>e)).reduce((e,s)=>e.concat(s),[]).map(e=>e.replace(l,(e,s,t)=>"all"===s?">= 0%":`${s}${t?/^((?:\d*\.)?\d+)-$/.test(t)?` <= ${t.slice(0,-1)}`:` ${t}`:" > 0"}`).toLowerCase())}const i=/\s+in\s+/,c=/ and|, and|,/,l=/^\s*(\w+)(?: ((?:(?:\d*\.)?\d+-)?(?:\d*\.)?\d+[+-]?))?.*$/;function browserslistsOverlap(e,s){return s.some(s=>e.has(s))}module.exports=creator; diff --git a/plugins/postcss-browser-comments/dist/index.d.ts b/plugins/postcss-browser-comments/dist/index.d.ts index 4a8418d95..47babc85a 100644 --- a/plugins/postcss-browser-comments/dist/index.d.ts +++ b/plugins/postcss-browser-comments/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-browser-comments plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-browser-comments/dist/index.mjs b/plugins/postcss-browser-comments/dist/index.mjs index e5950cecd..340e60585 100644 --- a/plugins/postcss-browser-comments/dist/index.mjs +++ b/plugins/postcss-browser-comments/dist/index.mjs @@ -1 +1 @@ -import e from"browserslist";const creator=s=>({postcssPlugin:"postcss-browser-comments",Once(t){const r=new Set(e(s?.browsers??null,{path:t?.source?.input.file})),o=t.nodes.slice(0);for(const s of o){if(!isBrowserCommentNode(s))continue;const t=s.next();if(!t||"rule"!==t.type)continue;const o=getBrowserData(s.text);o.isNumbered?(t.nodes.filter(isBrowserReferenceCommentNode).map(s=>{const t=parseFloat(s.text)-1,n=e(o.browserslist[t]);browserslistsOverlap(r,n)||(s.prev()?.remove(),s.remove())}),t.nodes.length||(t.remove(),s.remove())):browserslistsOverlap(r,e(o.browserslist))||(t.remove(),s.remove())}}});function isBrowserCommentNode(e){return"comment"===e.type&&(!!s.test(e.text)&&"rule"===e.next()?.type)}creator.postcss=!0;const s=/^\*\n +/;function isBrowserReferenceCommentNode(e){return"comment"===e.type&&t.test(e.text)}const t=/^\d+$/;function getBrowserData(e){const s=e.match(r);return s?{browserslist:s.map(e=>getBrowsersList(e.replace(n,"$1"))),isNumbered:!0}:{browserslist:getBrowsersList(e.replace(o,"")),isNumbered:!1}}const r=/(\n \* \d+\. (?:[^\n]|\n \* {4,})+)/g,o=/^\*\n \* ?|\n \*/g,n=/\n \* (?:( )\s*)?/g;function getBrowsersList(e){return e.split(i).slice(1).map(e=>e.split(c).filter(e=>e)).reduce((e,s)=>e.concat(s),[]).map(e=>e.replace(l,(e,s,t)=>"all"===s?">= 0%":`${s}${t?/^((?:\d*\.)?\d+)-$/.test(t)?` <= ${t.slice(0,-1)}`:` ${t}`:" > 0"}`).toLowerCase())}const i=/\s+in\s+/,c=/ and|, and|,/,l=/^\s*(\w+)(?: ((?:(?:\d*\.)?\d+-)?(?:\d*\.)?\d+[+-]?))?.*$/;function browserslistsOverlap(e,s){return s.some(s=>e.has(s))}export{creator as default}; +import e from"browserslist";const creator=s=>({postcssPlugin:"postcss-browser-comments",Once(t){const r=new Set(e(s?.browsers??null,{path:t?.source?.input.file})),o=t.nodes.slice(0);for(const s of o){if(!isBrowserCommentNode(s))continue;const t=s.next();if(!t||"rule"!==t.type)continue;const o=getBrowserData(s.text);o.isNumbered?(t.nodes.filter(isBrowserReferenceCommentNode).map(s=>{const t=parseFloat(s.text)-1,n=e(o.browserslist[t]);browserslistsOverlap(r,n)||(s.prev()?.remove(),s.remove())}),t.nodes.length||(t.remove(),s.remove())):browserslistsOverlap(r,e(o.browserslist))||(t.remove(),s.remove())}}});function isBrowserCommentNode(e){return"comment"===e.type&&(!!s.test(e.text)&&"rule"===e.next()?.type)}creator.postcss=!0;const s=/^\*\n +/;function isBrowserReferenceCommentNode(e){return"comment"===e.type&&t.test(e.text)}const t=/^\d+$/;function getBrowserData(e){const s=e.match(r);return s?{browserslist:s.map(e=>getBrowsersList(e.replace(n,"$1"))),isNumbered:!0}:{browserslist:getBrowsersList(e.replace(o,"")),isNumbered:!1}}const r=/(\n \* \d+\. (?:[^\n]|\n \* {4,})+)/g,o=/^\*\n \* ?|\n \*/g,n=/\n \* (?:( )\s*)?/g;function getBrowsersList(e){return e.split(i).slice(1).map(e=>e.split(c).filter(e=>e)).reduce((e,s)=>e.concat(s),[]).map(e=>e.replace(l,(e,s,t)=>"all"===s?">= 0%":`${s}${t?/^((?:\d*\.)?\d+)-$/.test(t)?` <= ${t.slice(0,-1)}`:` ${t}`:" > 0"}`).toLowerCase())}const i=/\s+in\s+/,c=/ and|, and|,/,l=/^\s*(\w+)(?: ((?:(?:\d*\.)?\d+-)?(?:\d*\.)?\d+[+-]?))?.*$/;function browserslistsOverlap(e,s){return s.some(s=>e.has(s))}export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-browser-comments/package.json b/plugins/postcss-browser-comments/package.json index c44fd58f2..13ee6b1dc 100644 --- a/plugins/postcss-browser-comments/package.json +++ b/plugins/postcss-browser-comments/package.json @@ -29,20 +29,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-browser-comments/src/index.ts b/plugins/postcss-browser-comments/src/index.ts index 95c058575..87ef09f5c 100644 --- a/plugins/postcss-browser-comments/src/index.ts +++ b/plugins/postcss-browser-comments/src/index.ts @@ -70,6 +70,7 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; // returns whether a node is a browser comment function isBrowserCommentNode(node: Node): node is Comment { diff --git a/plugins/postcss-cascade-layers/CHANGELOG.md b/plugins/postcss-cascade-layers/CHANGELOG.md index 4725caaf8..da2e919ba 100644 --- a/plugins/postcss-cascade-layers/CHANGELOG.md +++ b/plugins/postcss-cascade-layers/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Cascade Layers +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 5.0.2 _June 26, 2025_ diff --git a/plugins/postcss-cascade-layers/dist/index.cjs b/plugins/postcss-cascade-layers/dist/index.cjs deleted file mode 100644 index 38593f94f..000000000 --- a/plugins/postcss-cascade-layers/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser"),r=require("@csstools/selector-specificity");const t="csstools-invalid-layer",a="csstools-layer-with-selector-rules",s="6efdb677-bb05-44e5-840f-29d2175862fd",n="b147acf6-11a6-4338-a4d0-80aef4cd1a2f",o=["media","supports"],l=["keyframes"],i=/^revert-layer$/i,c=/^import$/i,u=/^layer$/i,m=/layer/i,y=new Set(["layer","supports","media","container","scope"]);function isProcessableLayerRule(e){if("atrule"!==e.type)return!1;if(!u.test(e.name))return!1;let r=e.parent;for(;r;){if("rule"===r.type)return!1;if("atrule"===r.type&&!y.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}class Model{anonymousLayerCount=0;layerCount=0;layerOrder;layerParamsParsed;layerNameParts;constructor(){this.anonymousLayerCount=0,this.layerCount=0,this.layerOrder=new Map,this.layerParamsParsed=new Map,this.layerNameParts=new Map}createAnonymousLayerName(){const e=`anonymous-${this.anonymousLayerCount}-${s}`;return this.addLayerNameParts(e),this.layerParamsParsed.set(e,[e]),this.anonymousLayerCount++,e}createImplicitLayerName(e){const r=this.layerNameParts.get(e)??[],t=`implicit-${r[r.length-1]}-${n}`;return this.addLayerNameParts([...r,t]),this.layerParamsParsed.set(t,[t]),t}addLayerParams(e,r){r?"string"!=typeof r?this.layerParamsParsed.set(e,r):this.layerParamsParsed.set(e,[r]):this.layerParamsParsed.set(e,[e])}addLayerNameParts(e){"string"!=typeof e?this.layerNameParts.set(e.join("."),e):this.layerNameParts.set(e,[e])}getLayerParams(e){const r=[...this.layerParamsParsed.get(e.params)??[]];let t=e.parent;for(;t;)"atrule"===t.type?(isProcessableLayerRule(t)&&r.push(...this.layerParamsParsed.get(t.params)??[]),t=t.parent):t=t.parent;return r.reverse(),r.flatMap(e=>this.layerNameParts.get(e)??[])}getLayerNameList(e){const r=this.layerNameParts.get(e)??[],t=[];for(let e=0;e{const t=this.layerNameParts.get(e[0])??[],a=this.layerNameParts.get(r[0])??[];if(t[0]!==a[0])return(this.layerOrder.get(t[0])??0)-(this.layerOrder.get(a[0])??0);const s=Math.max(t.length,a.length);for(let e=0;e{this.layerOrder.set(e[0],r)})}}function adjustSelectorSpecificity(r,t){const a=e().astSync(r),s=e().astSync(generateNot(t));let n=!1;for(let r=0;r{if(r(e))return t=!0,!1}),t}function someAtRuleInTree(e,r){let t=!1;return e.walkAtRules(e=>{if(r(e))return t=!0,!1}),t}function getLayerAtRuleAncestor(e){let r=e.parent;for(;r;)if("atrule"===r.type){if(isProcessableLayerRule(r))return r;r=r.parent}else r=r.parent;return null}function removeEmptyDescendantBlocks(e){e&&(e.walk(e=>{("rule"===e.type||"atrule"===e.type&&["layer",...o].includes(e.name.toLowerCase()))&&0===e.nodes?.length&&e.remove()}),0===e.nodes?.length&&e.remove())}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(void 0===r.nodes)return;if(r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function desugarAndParseLayerNames(r,a){r.walkAtRules(r=>{if(!isProcessableLayerRule(r))return;if(r.params){const s=[];let n=!1;if(e().astSync(r.params).each(e=>{const r=[];e.walk(e=>{switch(e.type){case"class":case"tag":r.push(e.value);break;default:n=!0}}),n||(s.push(r.join(".")),a.addLayerNameParts(r))}),a.addLayerParams(r.params,s),r.nodes&&s.length>1&&(n=!0),n)return void(r.name=t);if(!r.nodes||0===r.nodes.length){if(s.length<=1)return;return s.slice(0,-1).forEach(e=>{a.addLayerParams(e,e),r.cloneBefore({params:e})}),a.addLayerParams(s[s.length-1],s[s.length-1]),void(r.params=s[s.length-1])}}r.params||(r.raws.afterName=" ",r.params=a.createAnonymousLayerName());const s=someAtRuleInTree(r,e=>isProcessableLayerRule(e)),n=someInTree(r,e=>{if("rule"!==e.type)return!1;return getLayerAtRuleAncestor(e)===r});if(s&&n){const e=a.createImplicitLayerName(r.params),t=r.clone({params:e});t.walkAtRules(e=>{isProcessableLayerRule(e)&&e.remove()}),r.walk(e=>{if("atrule"===e.type&&isProcessableLayerRule(e))return;if("atrule"===e.type&&o.includes(e.name.toLowerCase()))return;getLayerAtRuleAncestor(e)===r&&e.remove()}),r.append(t),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)}})}function desugarNestedLayers(e,r){for(;someAtRuleInTree(e,e=>!!e.nodes&&someAtRuleInTree(e,e=>isProcessableLayerRule(e)));){let t=!1;if(e.walkAtRules(a=>{if(isProcessableLayerRule(a)&&a.parent!==e){if("atrule"===a.parent?.type&&isProcessableLayerRule(a.parent)){const e=a.parent;{const t=r.layerNameParts.get(e.params),s=r.layerNameParts.get(a.params);if(!t||!s)return;r.layerNameParts.set(`${e.params}.${a.params}`,[...t,...s]),r.layerParamsParsed.set(`${e.params}.${a.params}`,[`${e.params}.${a.params}`])}return a.params=`${e.params}.${a.params}`,e.before(a),removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)}if("atrule"===a.parent?.type){const e=a.parent,r=e.clone(),t=a.clone();return r.removeAll(),t.removeAll(),r.append(a.nodes),t.append(r),e.before(t),a.remove(),removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)}t=!0}}),t)break}}function sortRootNodes(e,r){e.nodes&&(e.walkAtRules(e=>{if(!isProcessableLayerRule(e))return;const r=e.clone(),t=e.clone();r.walkAtRules(e=>{if(l.includes(e.name.toLowerCase())){const r=e.parent;return e.remove(),removeEmptyDescendantBlocks(r),void removeEmptyAncestorBlocks(r)}if(someInTree(e,e=>"rule"===e.type))return;const r=e.parent;e.remove(),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)}),t.walkRules(e=>{if(e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase()))return;const r=e.parent;e.remove(),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)}),t.walkAtRules(e=>{if(o.includes(e.name.toLowerCase()))return removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)}),r.name=a,e.replaceWith(r,t),r.nodes?.length||r.remove(),t.nodes?.length||t.remove()}),e.nodes.sort((e,t)=>{const a="atrule"===e.type&&u.test(e.name),s="atrule"===t.type&&u.test(t.name);if(a&&s){return(r.layerOrder.get(e.params)??0)-(r.layerOrder.get(t.params)??0)}return a!==s?a?-1:1:0}),e.walkAtRules(a,e=>{e.name="layer"}))}function getConditionalAtRuleAncestor(e){let r=e.parent;for(;r;)if("atrule"===r.type){if(o.includes(r.name.toLowerCase()))return r;r=r.parent}else r=r.parent;return null}function recordLayerOrder(e,r,{result:t,options:a}){e.walkAtRules(e=>{if(!isProcessableLayerRule(e))return;const o=r.getLayerParams(e),l=o.join(".");r.layerOrder.has(l)||(a.onConditionalRulesChangingLayerOrder&&getConditionalAtRuleAncestor(e)&&!e.params.endsWith(n)&&!e.params.endsWith(s)&&e.warn(t,"handling different layer orders in conditional rules is unsupported by this plugin and will cause style differences between browser versions."),r.layerParamsParsed.has(l)||r.layerParamsParsed.set(l,[l]),r.layerNameParts.has(l)||r.layerNameParts.set(l,[...o]),r.getLayerNameList(l).forEach(e=>{r.layerOrder.has(e)||(r.layerOrder.set(e,r.layerCount),r.layerCount+=1)})),e.nodes&&0!==e.nodes.length||e.remove()})}function splitImportantStyles(e){e.walkDecls(e=>{if(!e.important)return;const r=e.parent;if(!r)return;if("atrule"===r?.parent?.type&&l.includes(r.parent.name.toLowerCase()))return;const t=r.clone();t.each(e=>{"decl"===e.type&&e.important||e.remove()}),r.each(e=>{"decl"===e.type&&e.important&&e.remove()}),r.before(t),removeEmptyDescendantBlocks(r)})}const creator=a=>{const s=Object.assign({onRevertLayerKeyword:"warn",onConditionalRulesChangingLayerOrder:"warn",onImportLayerRule:"warn"},a);return{postcssPlugin:"postcss-cascade-layers",OnceExit(a,{result:n}){let o=!1;if(a.walk(e=>"decl"===e.type?s.onRevertLayerKeyword&&i.test(e.value)?void e.warn(n,'handling "revert-layer" is unsupported by this plugin and will cause style differences between browser versions.'):void 0:"atrule"===e.type?s.onImportLayerRule&&c.test(e.name)&&m.test(e.params)?void e.warn(n,"To use @import with layers, the postcss-import plugin is also required. This plugin alone will not support using the @import at-rule."):u.test(e.name)?void(o=!0):void 0:void 0),!o)return;splitImportantStyles(a);const y=new Model;if(desugarAndParseLayerNames(a,y),recordLayerOrder(a,y,{result:n,options:s}),!y.layerCount)return void a.walkAtRules(t,e=>{e.name="layer"});let d=0;for(a.walkRules(t=>{t.selectors.forEach(a=>{try{const t=r.selectorSpecificity(e().astSync(a));d=Math.max(d,t.a+1)}catch(e){t.warn(n,`Failed to parse selector : "${a}" with message: "${e instanceof Error?e.message:e}"`)}})}),a.walkRules(e=>{e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase())||getLayerAtRuleAncestor(e)||e.some(e=>"decl"===e.type&&e.important)||(e.selectors=e.selectors.map(r=>{try{return adjustSelectorSpecificity(r,y.layerCount*d)}catch(t){e.warn(n,`Failed to parse selector : "${r}" with message: "${t instanceof Error?t.message:t}"`)}return r}))}),y.sortLayerNames(),desugarNestedLayers(a,y),sortRootNodes(a,y),a.walkRules(e=>{if(e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase()))return;const r=getLayerAtRuleAncestor(e);if(!r)return;const t=y.getLayerParams(r).join(".");let a=(y.layerOrder.get(t)??0)*d;e.some(e=>"decl"===e.type&&e.important)&&(a=y.layerCount-a),e.selectors=e.selectors.map(e=>adjustSelectorSpecificity(e,a))});someAtRuleInTree(a,e=>isProcessableLayerRule(e));)a.walkAtRules(e=>{isProcessableLayerRule(e)&&(e.nodes?e.replaceWith(e.nodes):e.remove())});a.walkAtRules(t,e=>{e.name="layer"})}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-cascade-layers/dist/index.d.ts b/plugins/postcss-cascade-layers/dist/index.d.ts index da46b302d..8a2cffa55 100644 --- a/plugins/postcss-cascade-layers/dist/index.d.ts +++ b/plugins/postcss-cascade-layers/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-cascasde-layers plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-cascade-layers/dist/index.mjs b/plugins/postcss-cascade-layers/dist/index.mjs index 690b30f69..754e51d13 100644 --- a/plugins/postcss-cascade-layers/dist/index.mjs +++ b/plugins/postcss-cascade-layers/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";import{selectorSpecificity as r}from"@csstools/selector-specificity";const t="csstools-invalid-layer",a="csstools-layer-with-selector-rules",s="6efdb677-bb05-44e5-840f-29d2175862fd",n="b147acf6-11a6-4338-a4d0-80aef4cd1a2f",o=["media","supports"],l=["keyframes"],i=/^revert-layer$/i,c=/^import$/i,u=/^layer$/i,m=/layer/i,y=new Set(["layer","supports","media","container","scope"]);function isProcessableLayerRule(e){if("atrule"!==e.type)return!1;if(!u.test(e.name))return!1;let r=e.parent;for(;r;){if("rule"===r.type)return!1;if("atrule"===r.type&&!y.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}class Model{anonymousLayerCount=0;layerCount=0;layerOrder;layerParamsParsed;layerNameParts;constructor(){this.anonymousLayerCount=0,this.layerCount=0,this.layerOrder=new Map,this.layerParamsParsed=new Map,this.layerNameParts=new Map}createAnonymousLayerName(){const e=`anonymous-${this.anonymousLayerCount}-${s}`;return this.addLayerNameParts(e),this.layerParamsParsed.set(e,[e]),this.anonymousLayerCount++,e}createImplicitLayerName(e){const r=this.layerNameParts.get(e)??[],t=`implicit-${r[r.length-1]}-${n}`;return this.addLayerNameParts([...r,t]),this.layerParamsParsed.set(t,[t]),t}addLayerParams(e,r){r?"string"!=typeof r?this.layerParamsParsed.set(e,r):this.layerParamsParsed.set(e,[r]):this.layerParamsParsed.set(e,[e])}addLayerNameParts(e){"string"!=typeof e?this.layerNameParts.set(e.join("."),e):this.layerNameParts.set(e,[e])}getLayerParams(e){const r=[...this.layerParamsParsed.get(e.params)??[]];let t=e.parent;for(;t;)"atrule"===t.type?(isProcessableLayerRule(t)&&r.push(...this.layerParamsParsed.get(t.params)??[]),t=t.parent):t=t.parent;return r.reverse(),r.flatMap(e=>this.layerNameParts.get(e)??[])}getLayerNameList(e){const r=this.layerNameParts.get(e)??[],t=[];for(let e=0;e{const t=this.layerNameParts.get(e[0])??[],a=this.layerNameParts.get(r[0])??[];if(t[0]!==a[0])return(this.layerOrder.get(t[0])??0)-(this.layerOrder.get(a[0])??0);const s=Math.max(t.length,a.length);for(let e=0;e{this.layerOrder.set(e[0],r)})}}function adjustSelectorSpecificity(r,t){const a=e().astSync(r),s=e().astSync(generateNot(t));let n=!1;for(let r=0;r{if(r(e))return t=!0,!1}),t}function someAtRuleInTree(e,r){let t=!1;return e.walkAtRules(e=>{if(r(e))return t=!0,!1}),t}function getLayerAtRuleAncestor(e){let r=e.parent;for(;r;)if("atrule"===r.type){if(isProcessableLayerRule(r))return r;r=r.parent}else r=r.parent;return null}function removeEmptyDescendantBlocks(e){e&&(e.walk(e=>{("rule"===e.type||"atrule"===e.type&&["layer",...o].includes(e.name.toLowerCase()))&&0===e.nodes?.length&&e.remove()}),0===e.nodes?.length&&e.remove())}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(void 0===r.nodes)return;if(r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function desugarAndParseLayerNames(r,a){r.walkAtRules(r=>{if(!isProcessableLayerRule(r))return;if(r.params){const s=[];let n=!1;if(e().astSync(r.params).each(e=>{const r=[];e.walk(e=>{switch(e.type){case"class":case"tag":r.push(e.value);break;default:n=!0}}),n||(s.push(r.join(".")),a.addLayerNameParts(r))}),a.addLayerParams(r.params,s),r.nodes&&s.length>1&&(n=!0),n)return void(r.name=t);if(!r.nodes||0===r.nodes.length){if(s.length<=1)return;return s.slice(0,-1).forEach(e=>{a.addLayerParams(e,e),r.cloneBefore({params:e})}),a.addLayerParams(s[s.length-1],s[s.length-1]),void(r.params=s[s.length-1])}}r.params||(r.raws.afterName=" ",r.params=a.createAnonymousLayerName());const s=someAtRuleInTree(r,e=>isProcessableLayerRule(e)),n=someInTree(r,e=>{if("rule"!==e.type)return!1;return getLayerAtRuleAncestor(e)===r});if(s&&n){const e=a.createImplicitLayerName(r.params),t=r.clone({params:e});t.walkAtRules(e=>{isProcessableLayerRule(e)&&e.remove()}),r.walk(e=>{if("atrule"===e.type&&isProcessableLayerRule(e))return;if("atrule"===e.type&&o.includes(e.name.toLowerCase()))return;getLayerAtRuleAncestor(e)===r&&e.remove()}),r.append(t),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)}})}function desugarNestedLayers(e,r){for(;someAtRuleInTree(e,e=>!!e.nodes&&someAtRuleInTree(e,e=>isProcessableLayerRule(e)));){let t=!1;if(e.walkAtRules(a=>{if(isProcessableLayerRule(a)&&a.parent!==e){if("atrule"===a.parent?.type&&isProcessableLayerRule(a.parent)){const e=a.parent;{const t=r.layerNameParts.get(e.params),s=r.layerNameParts.get(a.params);if(!t||!s)return;r.layerNameParts.set(`${e.params}.${a.params}`,[...t,...s]),r.layerParamsParsed.set(`${e.params}.${a.params}`,[`${e.params}.${a.params}`])}return a.params=`${e.params}.${a.params}`,e.before(a),removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)}if("atrule"===a.parent?.type){const e=a.parent,r=e.clone(),t=a.clone();return r.removeAll(),t.removeAll(),r.append(a.nodes),t.append(r),e.before(t),a.remove(),removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)}t=!0}}),t)break}}function sortRootNodes(e,r){e.nodes&&(e.walkAtRules(e=>{if(!isProcessableLayerRule(e))return;const r=e.clone(),t=e.clone();r.walkAtRules(e=>{if(l.includes(e.name.toLowerCase())){const r=e.parent;return e.remove(),removeEmptyDescendantBlocks(r),void removeEmptyAncestorBlocks(r)}if(someInTree(e,e=>"rule"===e.type))return;const r=e.parent;e.remove(),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)}),t.walkRules(e=>{if(e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase()))return;const r=e.parent;e.remove(),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)}),t.walkAtRules(e=>{if(o.includes(e.name.toLowerCase()))return removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)}),r.name=a,e.replaceWith(r,t),r.nodes?.length||r.remove(),t.nodes?.length||t.remove()}),e.nodes.sort((e,t)=>{const a="atrule"===e.type&&u.test(e.name),s="atrule"===t.type&&u.test(t.name);if(a&&s){return(r.layerOrder.get(e.params)??0)-(r.layerOrder.get(t.params)??0)}return a!==s?a?-1:1:0}),e.walkAtRules(a,e=>{e.name="layer"}))}function getConditionalAtRuleAncestor(e){let r=e.parent;for(;r;)if("atrule"===r.type){if(o.includes(r.name.toLowerCase()))return r;r=r.parent}else r=r.parent;return null}function recordLayerOrder(e,r,{result:t,options:a}){e.walkAtRules(e=>{if(!isProcessableLayerRule(e))return;const o=r.getLayerParams(e),l=o.join(".");r.layerOrder.has(l)||(a.onConditionalRulesChangingLayerOrder&&getConditionalAtRuleAncestor(e)&&!e.params.endsWith(n)&&!e.params.endsWith(s)&&e.warn(t,"handling different layer orders in conditional rules is unsupported by this plugin and will cause style differences between browser versions."),r.layerParamsParsed.has(l)||r.layerParamsParsed.set(l,[l]),r.layerNameParts.has(l)||r.layerNameParts.set(l,[...o]),r.getLayerNameList(l).forEach(e=>{r.layerOrder.has(e)||(r.layerOrder.set(e,r.layerCount),r.layerCount+=1)})),e.nodes&&0!==e.nodes.length||e.remove()})}function splitImportantStyles(e){e.walkDecls(e=>{if(!e.important)return;const r=e.parent;if(!r)return;if("atrule"===r?.parent?.type&&l.includes(r.parent.name.toLowerCase()))return;const t=r.clone();t.each(e=>{"decl"===e.type&&e.important||e.remove()}),r.each(e=>{"decl"===e.type&&e.important&&e.remove()}),r.before(t),removeEmptyDescendantBlocks(r)})}const creator=a=>{const s=Object.assign({onRevertLayerKeyword:"warn",onConditionalRulesChangingLayerOrder:"warn",onImportLayerRule:"warn"},a);return{postcssPlugin:"postcss-cascade-layers",OnceExit(a,{result:n}){let o=!1;if(a.walk(e=>"decl"===e.type?s.onRevertLayerKeyword&&i.test(e.value)?void e.warn(n,'handling "revert-layer" is unsupported by this plugin and will cause style differences between browser versions.'):void 0:"atrule"===e.type?s.onImportLayerRule&&c.test(e.name)&&m.test(e.params)?void e.warn(n,"To use @import with layers, the postcss-import plugin is also required. This plugin alone will not support using the @import at-rule."):u.test(e.name)?void(o=!0):void 0:void 0),!o)return;splitImportantStyles(a);const y=new Model;if(desugarAndParseLayerNames(a,y),recordLayerOrder(a,y,{result:n,options:s}),!y.layerCount)return void a.walkAtRules(t,e=>{e.name="layer"});let p=0;for(a.walkRules(t=>{t.selectors.forEach(a=>{try{const t=r(e().astSync(a));p=Math.max(p,t.a+1)}catch(e){t.warn(n,`Failed to parse selector : "${a}" with message: "${e instanceof Error?e.message:e}"`)}})}),a.walkRules(e=>{e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase())||getLayerAtRuleAncestor(e)||e.some(e=>"decl"===e.type&&e.important)||(e.selectors=e.selectors.map(r=>{try{return adjustSelectorSpecificity(r,y.layerCount*p)}catch(t){e.warn(n,`Failed to parse selector : "${r}" with message: "${t instanceof Error?t.message:t}"`)}return r}))}),y.sortLayerNames(),desugarNestedLayers(a,y),sortRootNodes(a,y),a.walkRules(e=>{if(e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase()))return;const r=getLayerAtRuleAncestor(e);if(!r)return;const t=y.getLayerParams(r).join(".");let a=(y.layerOrder.get(t)??0)*p;e.some(e=>"decl"===e.type&&e.important)&&(a=y.layerCount-a),e.selectors=e.selectors.map(e=>adjustSelectorSpecificity(e,a))});someAtRuleInTree(a,e=>isProcessableLayerRule(e));)a.walkAtRules(e=>{isProcessableLayerRule(e)&&(e.nodes?e.replaceWith(e.nodes):e.remove())});a.walkAtRules(t,e=>{e.name="layer"})}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-selector-parser";import{selectorSpecificity as r}from"@csstools/selector-specificity";const t="csstools-invalid-layer",a="csstools-layer-with-selector-rules",s="6efdb677-bb05-44e5-840f-29d2175862fd",n="b147acf6-11a6-4338-a4d0-80aef4cd1a2f",o=["media","supports"],l=["keyframes"],i=/^revert-layer$/i,c=/^import$/i,u=/^layer$/i,m=/layer/i,y=new Set(["layer","supports","media","container","scope"]);function isProcessableLayerRule(e){if("atrule"!==e.type)return!1;if(!u.test(e.name))return!1;let r=e.parent;for(;r;){if("rule"===r.type)return!1;if("atrule"===r.type&&!y.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}class Model{anonymousLayerCount=0;layerCount=0;layerOrder;layerParamsParsed;layerNameParts;constructor(){this.anonymousLayerCount=0,this.layerCount=0,this.layerOrder=new Map,this.layerParamsParsed=new Map,this.layerNameParts=new Map}createAnonymousLayerName(){const e=`anonymous-${this.anonymousLayerCount}-${s}`;return this.addLayerNameParts(e),this.layerParamsParsed.set(e,[e]),this.anonymousLayerCount++,e}createImplicitLayerName(e){const r=this.layerNameParts.get(e)??[],t=`implicit-${r[r.length-1]}-${n}`;return this.addLayerNameParts([...r,t]),this.layerParamsParsed.set(t,[t]),t}addLayerParams(e,r){r?"string"!=typeof r?this.layerParamsParsed.set(e,r):this.layerParamsParsed.set(e,[r]):this.layerParamsParsed.set(e,[e])}addLayerNameParts(e){"string"!=typeof e?this.layerNameParts.set(e.join("."),e):this.layerNameParts.set(e,[e])}getLayerParams(e){const r=[...this.layerParamsParsed.get(e.params)??[]];let t=e.parent;for(;t;)"atrule"===t.type?(isProcessableLayerRule(t)&&r.push(...this.layerParamsParsed.get(t.params)??[]),t=t.parent):t=t.parent;return r.reverse(),r.flatMap(e=>this.layerNameParts.get(e)??[])}getLayerNameList(e){const r=this.layerNameParts.get(e)??[],t=[];for(let e=0;e{const t=this.layerNameParts.get(e[0])??[],a=this.layerNameParts.get(r[0])??[];if(t[0]!==a[0])return(this.layerOrder.get(t[0])??0)-(this.layerOrder.get(a[0])??0);const s=Math.max(t.length,a.length);for(let e=0;e{this.layerOrder.set(e[0],r)})}}function adjustSelectorSpecificity(r,t){const a=e().astSync(r),s=e().astSync(generateNot(t));let n=!1;for(let r=0;r{if(r(e))return t=!0,!1}),t}function someAtRuleInTree(e,r){let t=!1;return e.walkAtRules(e=>{if(r(e))return t=!0,!1}),t}function getLayerAtRuleAncestor(e){let r=e.parent;for(;r;)if("atrule"===r.type){if(isProcessableLayerRule(r))return r;r=r.parent}else r=r.parent;return null}function removeEmptyDescendantBlocks(e){e&&(e.walk(e=>{("rule"===e.type||"atrule"===e.type&&["layer",...o].includes(e.name.toLowerCase()))&&0===e.nodes?.length&&e.remove()}),0===e.nodes?.length&&e.remove())}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(void 0===r.nodes)return;if(r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function desugarAndParseLayerNames(r,a){r.walkAtRules(r=>{if(!isProcessableLayerRule(r))return;if(r.params){const s=[];let n=!1;if(e().astSync(r.params).each(e=>{const r=[];e.walk(e=>{switch(e.type){case"class":case"tag":r.push(e.value);break;default:n=!0}}),n||(s.push(r.join(".")),a.addLayerNameParts(r))}),a.addLayerParams(r.params,s),r.nodes&&s.length>1&&(n=!0),n)return void(r.name=t);if(!r.nodes||0===r.nodes.length){if(s.length<=1)return;return s.slice(0,-1).forEach(e=>{a.addLayerParams(e,e),r.cloneBefore({params:e})}),a.addLayerParams(s[s.length-1],s[s.length-1]),void(r.params=s[s.length-1])}}r.params||(r.raws.afterName=" ",r.params=a.createAnonymousLayerName());const s=someAtRuleInTree(r,e=>isProcessableLayerRule(e)),n=someInTree(r,e=>{if("rule"!==e.type)return!1;return getLayerAtRuleAncestor(e)===r});if(s&&n){const e=a.createImplicitLayerName(r.params),t=r.clone({params:e});t.walkAtRules(e=>{isProcessableLayerRule(e)&&e.remove()}),r.walk(e=>{if("atrule"===e.type&&isProcessableLayerRule(e))return;if("atrule"===e.type&&o.includes(e.name.toLowerCase()))return;getLayerAtRuleAncestor(e)===r&&e.remove()}),r.append(t),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)}})}function desugarNestedLayers(e,r){for(;someAtRuleInTree(e,e=>!!e.nodes&&someAtRuleInTree(e,e=>isProcessableLayerRule(e)));){let t=!1;if(e.walkAtRules(a=>{if(isProcessableLayerRule(a)&&a.parent!==e){if("atrule"===a.parent?.type&&isProcessableLayerRule(a.parent)){const e=a.parent;{const t=r.layerNameParts.get(e.params),s=r.layerNameParts.get(a.params);if(!t||!s)return;r.layerNameParts.set(`${e.params}.${a.params}`,[...t,...s]),r.layerParamsParsed.set(`${e.params}.${a.params}`,[`${e.params}.${a.params}`])}return a.params=`${e.params}.${a.params}`,e.before(a),removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)}if("atrule"===a.parent?.type){const e=a.parent,r=e.clone(),t=a.clone();return r.removeAll(),t.removeAll(),r.append(a.nodes),t.append(r),e.before(t),a.remove(),removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)}t=!0}}),t)break}}function sortRootNodes(e,r){e.nodes&&(e.walkAtRules(e=>{if(!isProcessableLayerRule(e))return;const r=e.clone(),t=e.clone();r.walkAtRules(e=>{if(l.includes(e.name.toLowerCase())){const r=e.parent;return e.remove(),removeEmptyDescendantBlocks(r),void removeEmptyAncestorBlocks(r)}if(someInTree(e,e=>"rule"===e.type))return;const r=e.parent;e.remove(),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)}),t.walkRules(e=>{if(e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase()))return;const r=e.parent;e.remove(),removeEmptyDescendantBlocks(r),removeEmptyAncestorBlocks(r)}),t.walkAtRules(e=>{if(o.includes(e.name.toLowerCase()))return removeEmptyDescendantBlocks(e),void removeEmptyAncestorBlocks(e)}),r.name=a,e.replaceWith(r,t),r.nodes?.length||r.remove(),t.nodes?.length||t.remove()}),e.nodes.sort((e,t)=>{const a="atrule"===e.type&&u.test(e.name),s="atrule"===t.type&&u.test(t.name);if(a&&s){return(r.layerOrder.get(e.params)??0)-(r.layerOrder.get(t.params)??0)}return a!==s?a?-1:1:0}),e.walkAtRules(a,e=>{e.name="layer"}))}function getConditionalAtRuleAncestor(e){let r=e.parent;for(;r;)if("atrule"===r.type){if(o.includes(r.name.toLowerCase()))return r;r=r.parent}else r=r.parent;return null}function recordLayerOrder(e,r,{result:t,options:a}){e.walkAtRules(e=>{if(!isProcessableLayerRule(e))return;const o=r.getLayerParams(e),l=o.join(".");r.layerOrder.has(l)||(a.onConditionalRulesChangingLayerOrder&&getConditionalAtRuleAncestor(e)&&!e.params.endsWith(n)&&!e.params.endsWith(s)&&e.warn(t,"handling different layer orders in conditional rules is unsupported by this plugin and will cause style differences between browser versions."),r.layerParamsParsed.has(l)||r.layerParamsParsed.set(l,[l]),r.layerNameParts.has(l)||r.layerNameParts.set(l,[...o]),r.getLayerNameList(l).forEach(e=>{r.layerOrder.has(e)||(r.layerOrder.set(e,r.layerCount),r.layerCount+=1)})),e.nodes&&0!==e.nodes.length||e.remove()})}function splitImportantStyles(e){e.walkDecls(e=>{if(!e.important)return;const r=e.parent;if(!r)return;if("atrule"===r?.parent?.type&&l.includes(r.parent.name.toLowerCase()))return;const t=r.clone();t.each(e=>{"decl"===e.type&&e.important||e.remove()}),r.each(e=>{"decl"===e.type&&e.important&&e.remove()}),r.before(t),removeEmptyDescendantBlocks(r)})}const creator=a=>{const s=Object.assign({onRevertLayerKeyword:"warn",onConditionalRulesChangingLayerOrder:"warn",onImportLayerRule:"warn"},a);return{postcssPlugin:"postcss-cascade-layers",OnceExit(a,{result:n}){let o=!1;if(a.walk(e=>"decl"===e.type?s.onRevertLayerKeyword&&i.test(e.value)?void e.warn(n,'handling "revert-layer" is unsupported by this plugin and will cause style differences between browser versions.'):void 0:"atrule"===e.type?s.onImportLayerRule&&c.test(e.name)&&m.test(e.params)?void e.warn(n,"To use @import with layers, the postcss-import plugin is also required. This plugin alone will not support using the @import at-rule."):u.test(e.name)?void(o=!0):void 0:void 0),!o)return;splitImportantStyles(a);const y=new Model;if(desugarAndParseLayerNames(a,y),recordLayerOrder(a,y,{result:n,options:s}),!y.layerCount)return void a.walkAtRules(t,e=>{e.name="layer"});let p=0;for(a.walkRules(t=>{t.selectors.forEach(a=>{try{const t=r(e().astSync(a));p=Math.max(p,t.a+1)}catch(e){t.warn(n,`Failed to parse selector : "${a}" with message: "${e instanceof Error?e.message:e}"`)}})}),a.walkRules(e=>{e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase())||getLayerAtRuleAncestor(e)||e.some(e=>"decl"===e.type&&e.important)||(e.selectors=e.selectors.map(r=>{try{return adjustSelectorSpecificity(r,y.layerCount*p)}catch(t){e.warn(n,`Failed to parse selector : "${r}" with message: "${t instanceof Error?t.message:t}"`)}return r}))}),y.sortLayerNames(),desugarNestedLayers(a,y),sortRootNodes(a,y),a.walkRules(e=>{if(e.parent&&"atrule"===e.parent.type&&l.includes(e.parent.name.toLowerCase()))return;const r=getLayerAtRuleAncestor(e);if(!r)return;const t=y.getLayerParams(r).join(".");let a=(y.layerOrder.get(t)??0)*p;e.some(e=>"decl"===e.type&&e.important)&&(a=y.layerCount-a),e.selectors=e.selectors.map(e=>adjustSelectorSpecificity(e,a))});someAtRuleInTree(a,e=>isProcessableLayerRule(e));)a.walkAtRules(e=>{isProcessableLayerRule(e)&&(e.nodes?e.replaceWith(e.nodes):e.remove())});a.walkAtRules(t,e=>{e.name="layer"})}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-cascade-layers/package.json b/plugins/postcss-cascade-layers/package.json index addba79f5..1d4c16491 100644 --- a/plugins/postcss-cascade-layers/package.json +++ b/plugins/postcss-cascade-layers/package.json @@ -33,20 +33,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-cascade-layers/src/index.ts b/plugins/postcss-cascade-layers/src/index.ts index 4e31d474d..935a6e856 100644 --- a/plugins/postcss-cascade-layers/src/index.ts +++ b/plugins/postcss-cascade-layers/src/index.ts @@ -183,3 +183,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-color-function-display-p3-linear/CHANGELOG.md b/plugins/postcss-color-function-display-p3-linear/CHANGELOG.md index 3c259e45b..6e69cfe9a 100644 --- a/plugins/postcss-color-function-display-p3-linear/CHANGELOG.md +++ b/plugins/postcss-color-function-display-p3-linear/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Color Function Display P3 Linear +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 1.0.1 _September 21, 2025_ diff --git a/plugins/postcss-color-function-display-p3-linear/dist/index.cjs b/plugins/postcss-color-function-display-p3-linear/dist/index.cjs deleted file mode 100644 index bafe27493..000000000 --- a/plugins/postcss-color-function-display-p3-linear/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/css-tokenizer"),o=require("@csstools/css-color-parser"),r=require("@csstools/utilities"),t=require("@csstools/css-parser-algorithms");const i=/\bdisplay-p3-linear\b/i,a=/^color$/i,basePlugin=s=>({postcssPlugin:"postcss-color-function-display-p3-linear",Declaration(n){const l=n.value;if(!i.test(l))return;if(r.hasFallback(n))return;if(r.hasSupportsAtRuleAncestor(n,i))return;const c=e.tokenize({css:l}),p=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(c),s=>{if(!t.isFunctionNode(s)||!a.test(s.getName()))return;const e=o.color(s);return!e||e.colorNotation!==o.ColorNotation.Linear_Display_P3||e.syntaxFlags.has(o.SyntaxFlag.Experimental)||e.syntaxFlags.has(o.SyntaxFlag.HasNoneKeywords)?void 0:o.serializeP3(e)}),u=t.stringify(p);u!==l&&(n.cloneBefore({value:u}),s?.preserve||n.remove())}});basePlugin.postcss=!0;const postcssPlugin=e=>{const o=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},e);return o.enableProgressiveCustomProperties&&o.preserve?{postcssPlugin:"postcss-color-function-display-p3-linear",plugins:[s(),basePlugin(o)]}:basePlugin(o)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-color-function-display-p3-linear/dist/index.d.ts b/plugins/postcss-color-function-display-p3-linear/dist/index.d.ts index fdd37b369..78046ef94 100644 --- a/plugins/postcss-color-function-display-p3-linear/dist/index.d.ts +++ b/plugins/postcss-color-function-display-p3-linear/dist/index.d.ts @@ -11,5 +11,6 @@ export declare type pluginOptions = { /** Transform the display-p3-linear color space in the color() function in CSS. */ declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-color-function-display-p3-linear/dist/index.mjs b/plugins/postcss-color-function-display-p3-linear/dist/index.mjs index 203f41d14..89bc8e232 100644 --- a/plugins/postcss-color-function-display-p3-linear/dist/index.mjs +++ b/plugins/postcss-color-function-display-p3-linear/dist/index.mjs @@ -1 +1 @@ -import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as o}from"@csstools/css-tokenizer";import{color as r,ColorNotation as e,SyntaxFlag as t,serializeP3 as i}from"@csstools/css-color-parser";import{hasFallback as n,hasSupportsAtRuleAncestor as c}from"@csstools/utilities";import{replaceComponentValues as l,parseCommaSeparatedListOfComponentValues as p,isFunctionNode as a,stringify as u}from"@csstools/css-parser-algorithms";const m=/\bdisplay-p3-linear\b/i,f=/^color$/i,basePlugin=s=>({postcssPlugin:"postcss-color-function-display-p3-linear",Declaration(g){const v=g.value;if(!m.test(v))return;if(n(g))return;if(c(g,m))return;const y=o({css:v}),P=l(p(y),s=>{if(!a(s)||!f.test(s.getName()))return;const o=r(s);return!o||o.colorNotation!==e.Linear_Display_P3||o.syntaxFlags.has(t.Experimental)||o.syntaxFlags.has(t.HasNoneKeywords)?void 0:i(o)}),d=u(P);d!==v&&(g.cloneBefore({value:d}),s?.preserve||g.remove())}});basePlugin.postcss=!0;const postcssPlugin=o=>{const r=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},o);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-color-function-display-p3-linear",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as o}from"@csstools/css-tokenizer";import{color as r,ColorNotation as e,SyntaxFlag as t,serializeP3 as i}from"@csstools/css-color-parser";import{hasFallback as n,hasSupportsAtRuleAncestor as c}from"@csstools/utilities";import{replaceComponentValues as l,parseCommaSeparatedListOfComponentValues as p,isFunctionNode as a,stringify as u}from"@csstools/css-parser-algorithms";const m=/\bdisplay-p3-linear\b/i,f=/^color$/i,basePlugin=s=>({postcssPlugin:"postcss-color-function-display-p3-linear",Declaration(g){const v=g.value;if(!m.test(v))return;if(n(g))return;if(c(g,m))return;const d=o({css:v}),y=l(p(d),s=>{if(!a(s)||!f.test(s.getName()))return;const o=r(s);return!o||o.colorNotation!==e.Linear_Display_P3||o.syntaxFlags.has(t.Experimental)||o.syntaxFlags.has(t.HasNoneKeywords)?void 0:i(o)}),P=u(y);P!==v&&(g.cloneBefore({value:P}),s?.preserve||g.remove())}});basePlugin.postcss=!0;const postcssPlugin=o=>{const r=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},o);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-color-function-display-p3-linear",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-color-function-display-p3-linear/package.json b/plugins/postcss-color-function-display-p3-linear/package.json index f5c062c57..67590135c 100644 --- a/plugins/postcss-color-function-display-p3-linear/package.json +++ b/plugins/postcss-color-function-display-p3-linear/package.json @@ -20,20 +20,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-color-function-display-p3-linear/src/index.ts b/plugins/postcss-color-function-display-p3-linear/src/index.ts index bca84bbb5..0f71e8f80 100644 --- a/plugins/postcss-color-function-display-p3-linear/src/index.ts +++ b/plugins/postcss-color-function-display-p3-linear/src/index.ts @@ -105,3 +105,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-color-function/CHANGELOG.md b/plugins/postcss-color-function/CHANGELOG.md index a859fcf88..f9ff6fbe7 100644 --- a/plugins/postcss-color-function/CHANGELOG.md +++ b/plugins/postcss-color-function/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Color Function +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.12 _September 21, 2025_ diff --git a/plugins/postcss-color-function/dist/index.cjs b/plugins/postcss-color-function/dist/index.cjs deleted file mode 100644 index fd064b20a..000000000 --- a/plugins/postcss-color-function/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/css-tokenizer"),o=require("@csstools/css-color-parser"),r=require("@csstools/utilities"),t=require("@csstools/css-parser-algorithms");const a=/\bcolor\(/i,n=/^color$/i,basePlugin=s=>({postcssPlugin:"postcss-color-function",Declaration(i){const c=i.value;if(!a.test(c))return;if(r.hasFallback(i))return;if(r.hasSupportsAtRuleAncestor(i,a))return;const l=e.tokenize({css:c}),u=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(l),s=>{if(!t.isFunctionNode(s)||!n.test(s.getName()))return;const e=o.color(s);return e&&!(e.syntaxFlags.has(o.SyntaxFlag.Experimental)||e.syntaxFlags.has(o.SyntaxFlag.HasNoneKeywords)||e.syntaxFlags.has(o.SyntaxFlag.RelativeColorSyntax))?o.serializeRGB(e):void 0}),p=t.stringify(u);p!==c&&(i.cloneBefore({value:p}),s?.preserve||i.remove())}});basePlugin.postcss=!0;const postcssPlugin=e=>{const o=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},e);return o.enableProgressiveCustomProperties&&o.preserve?{postcssPlugin:"postcss-color-function",plugins:[s(),basePlugin(o)]}:basePlugin(o)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-color-function/dist/index.d.ts b/plugins/postcss-color-function/dist/index.d.ts index 830368cd4..9d076aff3 100644 --- a/plugins/postcss-color-function/dist/index.d.ts +++ b/plugins/postcss-color-function/dist/index.d.ts @@ -11,5 +11,6 @@ export declare type pluginOptions = { /** Transform the color() function in CSS. */ declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-color-function/dist/index.mjs b/plugins/postcss-color-function/dist/index.mjs index 00fa71296..c575bf9bd 100644 --- a/plugins/postcss-color-function/dist/index.mjs +++ b/plugins/postcss-color-function/dist/index.mjs @@ -1 +1 @@ -import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as o}from"@csstools/css-tokenizer";import{color as r,SyntaxFlag as e,serializeRGB as t}from"@csstools/css-color-parser";import{hasFallback as c,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as l,isFunctionNode as a,stringify as p}from"@csstools/css-parser-algorithms";const u=/\bcolor\(/i,m=/^color$/i,basePlugin=s=>({postcssPlugin:"postcss-color-function",Declaration(f){const g=f.value;if(!u.test(g))return;if(c(f))return;if(i(f,u))return;const v=o({css:g}),x=n(l(v),s=>{if(!a(s)||!m.test(s.getName()))return;const o=r(s);return o&&!(o.syntaxFlags.has(e.Experimental)||o.syntaxFlags.has(e.HasNoneKeywords)||o.syntaxFlags.has(e.RelativeColorSyntax))?t(o):void 0}),P=p(x);P!==g&&(f.cloneBefore({value:P}),s?.preserve||f.remove())}});basePlugin.postcss=!0;const postcssPlugin=o=>{const r=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},o);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-color-function",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as o}from"@csstools/css-tokenizer";import{color as e,SyntaxFlag as r,serializeRGB as t}from"@csstools/css-color-parser";import{hasFallback as c,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as l,isFunctionNode as a,stringify as p}from"@csstools/css-parser-algorithms";const u=/\bcolor\(/i,m=/^color$/i,basePlugin=s=>({postcssPlugin:"postcss-color-function",Declaration(f){const g=f.value;if(!u.test(g))return;if(c(f))return;if(i(f,u))return;const v=o({css:g}),x=n(l(v),s=>{if(!a(s)||!m.test(s.getName()))return;const o=e(s);return o&&!(o.syntaxFlags.has(r.Experimental)||o.syntaxFlags.has(r.HasNoneKeywords)||o.syntaxFlags.has(r.RelativeColorSyntax))?t(o):void 0}),P=p(x);P!==g&&(f.cloneBefore({value:P}),s?.preserve||f.remove())}});basePlugin.postcss=!0;const postcssPlugin=o=>{const e=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},o);return e.enableProgressiveCustomProperties&&e.preserve?{postcssPlugin:"postcss-color-function",plugins:[s(),basePlugin(e)]}:basePlugin(e)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-color-function/package.json b/plugins/postcss-color-function/package.json index ff8461151..a019e0c50 100644 --- a/plugins/postcss-color-function/package.json +++ b/plugins/postcss-color-function/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-color-function/src/index.ts b/plugins/postcss-color-function/src/index.ts index 78d3498ed..6665092d0 100644 --- a/plugins/postcss-color-function/src/index.ts +++ b/plugins/postcss-color-function/src/index.ts @@ -102,3 +102,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-color-functional-notation/CHANGELOG.md b/plugins/postcss-color-functional-notation/CHANGELOG.md index 17ed6eb54..a764b49fb 100644 --- a/plugins/postcss-color-functional-notation/CHANGELOG.md +++ b/plugins/postcss-color-functional-notation/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Color Functional Notation +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 7.0.12 _September 21, 2025_ diff --git a/plugins/postcss-color-functional-notation/dist/index.cjs b/plugins/postcss-color-functional-notation/dist/index.cjs deleted file mode 100644 index 09d5f8c6c..000000000 --- a/plugins/postcss-color-functional-notation/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/css-color-parser"),t=require("@csstools/utilities"),o=require("@csstools/css-parser-algorithms"),a=require("@csstools/css-tokenizer");const r=/^(?:rgb|hsl)a?$/i,n=/\b(?:rgb|hsl)a?\(/i,basePlugin=s=>({postcssPlugin:"postcss-color-functional-notation",Declaration(l){const i=l.value;if(!n.test(i))return;if(t.hasFallback(l))return;if(t.hasSupportsAtRuleAncestor(l,n))return;const c=o.replaceComponentValues(o.parseCommaSeparatedListOfComponentValues(a.tokenize({css:i})),s=>{if(!o.isFunctionNode(s)||!r.test(s.getName()))return;const t=e.color(s);return!t||t.syntaxFlags.has(e.SyntaxFlag.Experimental)||t.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords)||t.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax)||(t.syntaxFlags.has(e.SyntaxFlag.LegacyRGB)||t.syntaxFlags.has(e.SyntaxFlag.LegacyHSL))&&!t.syntaxFlags.has(e.SyntaxFlag.HasPercentageAlpha)?void 0:t.colorNotation===e.ColorNotation.HSL?e.serializeHSL(t):e.serializeRGB(t)}),u=o.stringify(c);u!==i&&(l.cloneBefore({value:u}),s?.preserve||l.remove())}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},e);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-color-functional-notation",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-color-functional-notation/dist/index.d.ts b/plugins/postcss-color-functional-notation/dist/index.d.ts index 7992d58a1..ef5256afc 100644 --- a/plugins/postcss-color-functional-notation/dist/index.d.ts +++ b/plugins/postcss-color-functional-notation/dist/index.d.ts @@ -11,5 +11,6 @@ export declare type pluginOptions = { /** Transform the color functional notation in CSS. */ declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-color-functional-notation/dist/index.mjs b/plugins/postcss-color-functional-notation/dist/index.mjs index 966a61117..55e739cd4 100644 --- a/plugins/postcss-color-functional-notation/dist/index.mjs +++ b/plugins/postcss-color-functional-notation/dist/index.mjs @@ -1 +1 @@ -import s from"@csstools/postcss-progressive-custom-properties";import{color as o,SyntaxFlag as t,ColorNotation as e,serializeHSL as r,serializeRGB as a}from"@csstools/css-color-parser";import{hasFallback as n,hasSupportsAtRuleAncestor as c}from"@csstools/utilities";import{replaceComponentValues as i,parseCommaSeparatedListOfComponentValues as l,isFunctionNode as p,stringify as g}from"@csstools/css-parser-algorithms";import{tokenize as u}from"@csstools/css-tokenizer";const m=/^(?:rgb|hsl)a?$/i,f=/\b(?:rgb|hsl)a?\(/i,basePlugin=s=>({postcssPlugin:"postcss-color-functional-notation",Declaration(v){const h=v.value;if(!f.test(h))return;if(n(v))return;if(c(v,f))return;const y=i(l(u({css:h})),s=>{if(!p(s)||!m.test(s.getName()))return;const n=o(s);return!n||n.syntaxFlags.has(t.Experimental)||n.syntaxFlags.has(t.HasNoneKeywords)||n.syntaxFlags.has(t.RelativeColorSyntax)||(n.syntaxFlags.has(t.LegacyRGB)||n.syntaxFlags.has(t.LegacyHSL))&&!n.syntaxFlags.has(t.HasPercentageAlpha)?void 0:n.colorNotation===e.HSL?r(n):a(n)}),x=g(y);x!==h&&(v.cloneBefore({value:x}),s?.preserve||v.remove())}});basePlugin.postcss=!0;const postcssPlugin=o=>{const t=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},o);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-color-functional-notation",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import s from"@csstools/postcss-progressive-custom-properties";import{color as o,SyntaxFlag as t,ColorNotation as e,serializeHSL as r,serializeRGB as a}from"@csstools/css-color-parser";import{hasFallback as n,hasSupportsAtRuleAncestor as l}from"@csstools/utilities";import{replaceComponentValues as c,parseCommaSeparatedListOfComponentValues as i,isFunctionNode as p,stringify as g}from"@csstools/css-parser-algorithms";import{tokenize as u}from"@csstools/css-tokenizer";const m=/^(?:rgb|hsl)a?$/i,f=/\b(?:rgb|hsl)a?\(/i,basePlugin=s=>({postcssPlugin:"postcss-color-functional-notation",Declaration(v){const h=v.value;if(!f.test(h))return;if(n(v))return;if(l(v,f))return;const x=c(i(u({css:h})),s=>{if(!p(s)||!m.test(s.getName()))return;const n=o(s);return!n||n.syntaxFlags.has(t.Experimental)||n.syntaxFlags.has(t.HasNoneKeywords)||n.syntaxFlags.has(t.RelativeColorSyntax)||(n.syntaxFlags.has(t.LegacyRGB)||n.syntaxFlags.has(t.LegacyHSL))&&!n.syntaxFlags.has(t.HasPercentageAlpha)?void 0:n.colorNotation===e.HSL?r(n):a(n)}),y=g(x);y!==h&&(v.cloneBefore({value:y}),s?.preserve||v.remove())}});basePlugin.postcss=!0;const postcssPlugin=o=>{const t=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},o);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-color-functional-notation",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-color-functional-notation/package.json b/plugins/postcss-color-functional-notation/package.json index 80b1389fc..702b536b8 100644 --- a/plugins/postcss-color-functional-notation/package.json +++ b/plugins/postcss-color-functional-notation/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-color-functional-notation/src/index.ts b/plugins/postcss-color-functional-notation/src/index.ts index feb5954ac..0b3038877 100644 --- a/plugins/postcss-color-functional-notation/src/index.ts +++ b/plugins/postcss-color-functional-notation/src/index.ts @@ -117,3 +117,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-color-hex-alpha/CHANGELOG.md b/plugins/postcss-color-hex-alpha/CHANGELOG.md index 1c28e6570..e3ae79e60 100644 --- a/plugins/postcss-color-hex-alpha/CHANGELOG.md +++ b/plugins/postcss-color-hex-alpha/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Color Hex Alpha +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 10.0.0 _August 3, 2024_ diff --git a/plugins/postcss-color-hex-alpha/dist/index.cjs b/plugins/postcss-color-hex-alpha/dist/index.cjs deleted file mode 100644 index 2cd155445..000000000 --- a/plugins/postcss-color-hex-alpha/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser"),s=require("@csstools/utilities");const creator=a=>{const l=Object.assign({preserve:!1},a);return{postcssPlugin:"postcss-color-hex-alpha",Declaration(a){if(!t.test(a.value))return;if(s.hasFallback(a))return;const{value:c}=a,n=e(c);n.walk(e=>{if("function"===e.type&&"url"===e.value)return!1;"word"===e.type&&r.test(e.value)&&hexa2rgba(e)});const o=n.toString();o!==c&&(a.cloneBefore({value:o}),l.preserve||a.remove())}}};creator.postcss=!0;const t=/#[0-9a-f]{4}(?:[0-9a-f]{4})?\b/i,r=/^#[0-9a-f]{4}(?:[0-9a-f]{4})?$/i,a=1e5,l=/[0-9a-f]/gi;function hexa2rgba(e){const s=e.value,t=`0x${5===s.length?s.slice(1).replace(l,"$&$&"):s.slice(1)}`,[r,c,n,o]=[parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),parseInt(t.slice(6,8),16),Math.round(parseInt(t.slice(8,10),16)/255*a)/a];e.value=`rgba(${r},${c},${n},${o})`}module.exports=creator; diff --git a/plugins/postcss-color-hex-alpha/dist/index.d.ts b/plugins/postcss-color-hex-alpha/dist/index.d.ts index ce39d2bcd..0ef819b7d 100644 --- a/plugins/postcss-color-hex-alpha/dist/index.d.ts +++ b/plugins/postcss-color-hex-alpha/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-color-hex-alpha plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-color-hex-alpha/dist/index.mjs b/plugins/postcss-color-hex-alpha/dist/index.mjs index bdbbd53c0..db7a7f6e0 100644 --- a/plugins/postcss-color-hex-alpha/dist/index.mjs +++ b/plugins/postcss-color-hex-alpha/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";import{hasFallback as s}from"@csstools/utilities";const creator=a=>{const o=Object.assign({preserve:!1},a);return{postcssPlugin:"postcss-color-hex-alpha",Declaration(a){if(!t.test(a.value))return;if(s(a))return;const{value:l}=a,n=e(l);n.walk(e=>{if("function"===e.type&&"url"===e.value)return!1;"word"===e.type&&r.test(e.value)&&hexa2rgba(e)});const c=n.toString();c!==l&&(a.cloneBefore({value:c}),o.preserve||a.remove())}}};creator.postcss=!0;const t=/#[0-9a-f]{4}(?:[0-9a-f]{4})?\b/i,r=/^#[0-9a-f]{4}(?:[0-9a-f]{4})?$/i,a=1e5,o=/[0-9a-f]/gi;function hexa2rgba(e){const s=e.value,t=`0x${5===s.length?s.slice(1).replace(o,"$&$&"):s.slice(1)}`,[r,l,n,c]=[parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),parseInt(t.slice(6,8),16),Math.round(parseInt(t.slice(8,10),16)/255*a)/a];e.value=`rgba(${r},${l},${n},${c})`}export{creator as default}; +import e from"postcss-value-parser";import{hasFallback as s}from"@csstools/utilities";const creator=a=>{const o=Object.assign({preserve:!1},a);return{postcssPlugin:"postcss-color-hex-alpha",Declaration(a){if(!t.test(a.value))return;if(s(a))return;const{value:l}=a,n=e(l);n.walk(e=>{if("function"===e.type&&"url"===e.value)return!1;"word"===e.type&&r.test(e.value)&&hexa2rgba(e)});const c=n.toString();c!==l&&(a.cloneBefore({value:c}),o.preserve||a.remove())}}};creator.postcss=!0;const t=/#[0-9a-f]{4}(?:[0-9a-f]{4})?\b/i,r=/^#[0-9a-f]{4}(?:[0-9a-f]{4})?$/i,a=1e5,o=/[0-9a-f]/gi;function hexa2rgba(e){const s=e.value,t=`0x${5===s.length?s.slice(1).replace(o,"$&$&"):s.slice(1)}`,[r,l,n,c]=[parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),parseInt(t.slice(6,8),16),Math.round(parseInt(t.slice(8,10),16)/255*a)/a];e.value=`rgba(${r},${l},${n},${c})`}export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-color-hex-alpha/package.json b/plugins/postcss-color-hex-alpha/package.json index 3910313bb..c4ee67822 100644 --- a/plugins/postcss-color-hex-alpha/package.json +++ b/plugins/postcss-color-hex-alpha/package.json @@ -32,20 +32,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-color-hex-alpha/src/index.ts b/plugins/postcss-color-hex-alpha/src/index.ts index 1c11ed383..72f5c1203 100644 --- a/plugins/postcss-color-hex-alpha/src/index.ts +++ b/plugins/postcss-color-hex-alpha/src/index.ts @@ -63,6 +63,7 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; const HAS_HEX_ALPHA_REGEX = /#[0-9a-f]{4}(?:[0-9a-f]{4})?\b/i; diff --git a/plugins/postcss-color-mix-function/CHANGELOG.md b/plugins/postcss-color-mix-function/CHANGELOG.md index 14a41dbac..33e4354cd 100644 --- a/plugins/postcss-color-mix-function/CHANGELOG.md +++ b/plugins/postcss-color-mix-function/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Color Mix Function +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.0.12 _September 21, 2025_ diff --git a/plugins/postcss-color-mix-function/dist/index.cjs b/plugins/postcss-color-mix-function/dist/index.cjs deleted file mode 100644 index 5594b34d0..000000000 --- a/plugins/postcss-color-mix-function/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/css-color-parser"),r=require("@csstools/utilities"),t=require("@csstools/css-parser-algorithms"),o=require("@csstools/css-tokenizer");const a=/\bcolor-mix\(/i,i=/^color-mix$/i,basePlugin=s=>({postcssPlugin:"postcss-color-mix-function",Declaration(n){const l=n.value;if(!a.test(l))return;if(r.hasFallback(n))return;if(r.hasSupportsAtRuleAncestor(n,a))return;const u=o.tokenize({css:l}),c=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(u),s=>{if(!t.isFunctionNode(s)||!i.test(s.getName()))return;const r=e.color(s);return!r||r.syntaxFlags.has(e.SyntaxFlag.Experimental)||r.syntaxFlags.has(e.SyntaxFlag.ColorMixVariadic)?void 0:e.serializeRGB(r)}),p=t.stringify(c);if(p===l)return;let m=p;s?.subFeatures.displayP3&&(m=t.stringify(t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(u),s=>{if(!t.isFunctionNode(s)||!i.test(s.getName()))return;const r=e.color(s);return r&&!r.syntaxFlags.has(e.SyntaxFlag.Experimental)?e.colorDataFitsRGB_Gamut(r)?e.serializeRGB(r):e.serializeP3(r):void 0}))),n.cloneBefore({value:p}),s?.subFeatures.displayP3&&m!==p&&n.cloneBefore({value:m}),s?.preserve||n.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-color-mix-function",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-color-mix-function/dist/index.d.ts b/plugins/postcss-color-mix-function/dist/index.d.ts index 28d26eb4c..5fb865e90 100644 --- a/plugins/postcss-color-mix-function/dist/index.d.ts +++ b/plugins/postcss-color-mix-function/dist/index.d.ts @@ -16,5 +16,6 @@ export declare type pluginOptions = { /** Transform color-mix() functions in CSS. */ declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-color-mix-function/dist/index.mjs b/plugins/postcss-color-mix-function/dist/index.mjs index 2ec88b526..f00bc1171 100644 --- a/plugins/postcss-color-mix-function/dist/index.mjs +++ b/plugins/postcss-color-mix-function/dist/index.mjs @@ -1 +1 @@ -import s from"@csstools/postcss-progressive-custom-properties";import{color as e,SyntaxFlag as r,serializeRGB as t,colorDataFitsRGB_Gamut as o,serializeP3 as i}from"@csstools/css-color-parser";import{hasFallback as a,hasSupportsAtRuleAncestor as c}from"@csstools/utilities";import{replaceComponentValues as l,parseCommaSeparatedListOfComponentValues as n,isFunctionNode as u,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as m}from"@csstools/css-tokenizer";const f=/\bcolor-mix\(/i,g=/^color-mix$/i,basePlugin=s=>({postcssPlugin:"postcss-color-mix-function",Declaration(v){const b=v.value;if(!f.test(b))return;if(a(v))return;if(c(v,f))return;const x=m({css:b}),P=l(n(x),s=>{if(!u(s)||!g.test(s.getName()))return;const o=e(s);return!o||o.syntaxFlags.has(r.Experimental)||o.syntaxFlags.has(r.ColorMixVariadic)?void 0:t(o)}),d=p(P);if(d===b)return;let F=d;s?.subFeatures.displayP3&&(F=p(l(n(x),s=>{if(!u(s)||!g.test(s.getName()))return;const a=e(s);return a&&!a.syntaxFlags.has(r.Experimental)?o(a)?t(a):i(a):void 0}))),v.cloneBefore({value:d}),s?.subFeatures.displayP3&&F!==d&&v.cloneBefore({value:F}),s?.preserve||v.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-color-mix-function",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import s from"@csstools/postcss-progressive-custom-properties";import{color as e,SyntaxFlag as r,serializeRGB as t,colorDataFitsRGB_Gamut as o,serializeP3 as i}from"@csstools/css-color-parser";import{hasFallback as a,hasSupportsAtRuleAncestor as c}from"@csstools/utilities";import{replaceComponentValues as l,parseCommaSeparatedListOfComponentValues as n,isFunctionNode as u,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as m}from"@csstools/css-tokenizer";const f=/\bcolor-mix\(/i,g=/^color-mix$/i,basePlugin=s=>({postcssPlugin:"postcss-color-mix-function",Declaration(v){const x=v.value;if(!f.test(x))return;if(a(v))return;if(c(v,f))return;const b=m({css:x}),P=l(n(b),s=>{if(!u(s)||!g.test(s.getName()))return;const o=e(s);return!o||o.syntaxFlags.has(r.Experimental)||o.syntaxFlags.has(r.ColorMixVariadic)?void 0:t(o)}),d=p(P);if(d===x)return;let F=d;s?.subFeatures.displayP3&&(F=p(l(n(b),s=>{if(!u(s)||!g.test(s.getName()))return;const a=e(s);return a&&!a.syntaxFlags.has(r.Experimental)?o(a)?t(a):i(a):void 0}))),v.cloneBefore({value:d}),s?.subFeatures.displayP3&&F!==d&&v.cloneBefore({value:F}),s?.preserve||v.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-color-mix-function",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-color-mix-function/package.json b/plugins/postcss-color-mix-function/package.json index d3492bc7a..7b76abf23 100644 --- a/plugins/postcss-color-mix-function/package.json +++ b/plugins/postcss-color-mix-function/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-color-mix-function/src/index.ts b/plugins/postcss-color-mix-function/src/index.ts index cea3449c2..613a62123 100644 --- a/plugins/postcss-color-mix-function/src/index.ts +++ b/plugins/postcss-color-mix-function/src/index.ts @@ -149,3 +149,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-color-mix-variadic-function-arguments/CHANGELOG.md b/plugins/postcss-color-mix-variadic-function-arguments/CHANGELOG.md index eaee6674c..b0dd3f18b 100644 --- a/plugins/postcss-color-mix-variadic-function-arguments/CHANGELOG.md +++ b/plugins/postcss-color-mix-variadic-function-arguments/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Color Mix Variadic Function Arguments +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 1.0.2 _September 21, 2025_ diff --git a/plugins/postcss-color-mix-variadic-function-arguments/dist/index.cjs b/plugins/postcss-color-mix-variadic-function-arguments/dist/index.cjs deleted file mode 100644 index 16a85479f..000000000 --- a/plugins/postcss-color-mix-variadic-function-arguments/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/css-color-parser"),r=require("@csstools/utilities"),t=require("@csstools/css-parser-algorithms"),o=require("@csstools/css-tokenizer");const a=/\bcolor-mix\(/i,i=/^color-mix$/i,basePlugin=s=>({postcssPlugin:"color-mix-variadic-function-arguments",Declaration(n){const l=n.value;if(!a.test(l))return;if(r.hasFallback(n))return;if(r.hasSupportsAtRuleAncestor(n,a))return;const u=o.tokenize({css:l}),c=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(u),s=>{if(!t.isFunctionNode(s)||!i.test(s.getName()))return;const r=e.color(s);return r&&!r.syntaxFlags.has(e.SyntaxFlag.Experimental)&&r.syntaxFlags.has(e.SyntaxFlag.ColorMixVariadic)?e.serializeRGB(r):void 0}),p=t.stringify(c);if(p===l)return;let m=p;s?.subFeatures.displayP3&&(m=t.stringify(t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(u),s=>{if(!t.isFunctionNode(s)||!i.test(s.getName()))return;const r=e.color(s);return r&&!r.syntaxFlags.has(e.SyntaxFlag.Experimental)?e.colorDataFitsRGB_Gamut(r)?e.serializeRGB(r):e.serializeP3(r):void 0}))),n.cloneBefore({value:p}),s?.subFeatures.displayP3&&m!==p&&n.cloneBefore({value:m}),s?.preserve||n.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"color-mix-variadic-function-arguments",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-color-mix-variadic-function-arguments/dist/index.d.ts b/plugins/postcss-color-mix-variadic-function-arguments/dist/index.d.ts index bdd9355f5..b8d722031 100644 --- a/plugins/postcss-color-mix-variadic-function-arguments/dist/index.d.ts +++ b/plugins/postcss-color-mix-variadic-function-arguments/dist/index.d.ts @@ -16,5 +16,6 @@ export declare type pluginOptions = { /** Transform color-mix() functions in CSS. */ declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-color-mix-variadic-function-arguments/dist/index.mjs b/plugins/postcss-color-mix-variadic-function-arguments/dist/index.mjs index b2597f99b..3f566ad67 100644 --- a/plugins/postcss-color-mix-variadic-function-arguments/dist/index.mjs +++ b/plugins/postcss-color-mix-variadic-function-arguments/dist/index.mjs @@ -1 +1 @@ -import s from"@csstools/postcss-progressive-custom-properties";import{color as e,SyntaxFlag as r,serializeRGB as t,colorDataFitsRGB_Gamut as o,serializeP3 as i}from"@csstools/css-color-parser";import{hasFallback as a,hasSupportsAtRuleAncestor as n}from"@csstools/utilities";import{replaceComponentValues as c,parseCommaSeparatedListOfComponentValues as l,isFunctionNode as u,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as m}from"@csstools/css-tokenizer";const f=/\bcolor-mix\(/i,g=/^color-mix$/i,basePlugin=s=>({postcssPlugin:"color-mix-variadic-function-arguments",Declaration(v){const b=v.value;if(!f.test(b))return;if(a(v))return;if(n(v,f))return;const d=m({css:b}),x=c(l(d),s=>{if(!u(s)||!g.test(s.getName()))return;const o=e(s);return o&&!o.syntaxFlags.has(r.Experimental)&&o.syntaxFlags.has(r.ColorMixVariadic)?t(o):void 0}),P=p(x);if(P===b)return;let F=P;s?.subFeatures.displayP3&&(F=p(c(l(d),s=>{if(!u(s)||!g.test(s.getName()))return;const a=e(s);return a&&!a.syntaxFlags.has(r.Experimental)?o(a)?t(a):i(a):void 0}))),v.cloneBefore({value:P}),s?.subFeatures.displayP3&&F!==P&&v.cloneBefore({value:F}),s?.preserve||v.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"color-mix-variadic-function-arguments",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import s from"@csstools/postcss-progressive-custom-properties";import{color as e,SyntaxFlag as r,serializeRGB as t,colorDataFitsRGB_Gamut as o,serializeP3 as i}from"@csstools/css-color-parser";import{hasFallback as a,hasSupportsAtRuleAncestor as n}from"@csstools/utilities";import{replaceComponentValues as c,parseCommaSeparatedListOfComponentValues as l,isFunctionNode as u,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as m}from"@csstools/css-tokenizer";const f=/\bcolor-mix\(/i,g=/^color-mix$/i,basePlugin=s=>({postcssPlugin:"color-mix-variadic-function-arguments",Declaration(v){const d=v.value;if(!f.test(d))return;if(a(v))return;if(n(v,f))return;const x=m({css:d}),b=c(l(x),s=>{if(!u(s)||!g.test(s.getName()))return;const o=e(s);return o&&!o.syntaxFlags.has(r.Experimental)&&o.syntaxFlags.has(r.ColorMixVariadic)?t(o):void 0}),P=p(b);if(P===d)return;let F=P;s?.subFeatures.displayP3&&(F=p(c(l(x),s=>{if(!u(s)||!g.test(s.getName()))return;const a=e(s);return a&&!a.syntaxFlags.has(r.Experimental)?o(a)?t(a):i(a):void 0}))),v.cloneBefore({value:P}),s?.subFeatures.displayP3&&F!==P&&v.cloneBefore({value:F}),s?.preserve||v.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"color-mix-variadic-function-arguments",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-color-mix-variadic-function-arguments/package.json b/plugins/postcss-color-mix-variadic-function-arguments/package.json index d157e4614..d5c34cc0a 100644 --- a/plugins/postcss-color-mix-variadic-function-arguments/package.json +++ b/plugins/postcss-color-mix-variadic-function-arguments/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-color-mix-variadic-function-arguments/src/index.ts b/plugins/postcss-color-mix-variadic-function-arguments/src/index.ts index cbe115c69..eab3dd641 100644 --- a/plugins/postcss-color-mix-variadic-function-arguments/src/index.ts +++ b/plugins/postcss-color-mix-variadic-function-arguments/src/index.ts @@ -149,3 +149,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-color-rebeccapurple/CHANGELOG.md b/plugins/postcss-color-rebeccapurple/CHANGELOG.md index cd3c36306..93c0b431f 100644 --- a/plugins/postcss-color-rebeccapurple/CHANGELOG.md +++ b/plugins/postcss-color-rebeccapurple/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS RebeccaPurple +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 10.0.0 _August 3, 2024_ diff --git a/plugins/postcss-color-rebeccapurple/dist/index.cjs b/plugins/postcss-color-rebeccapurple/dist/index.cjs deleted file mode 100644 index 26d77b73a..000000000 --- a/plugins/postcss-color-rebeccapurple/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser"),r=require("@csstools/utilities");const s=/rebeccapurple/i,t=/^rebeccapurple$/i,creator=c=>{const l=Object.assign({preserve:!1},c);return{postcssPlugin:"postcss-color-rebeccapurple",Declaration(c){if(!s.test(c.value))return;if(r.hasFallback(c))return;const a=e(c.value);a.walk(e=>{"word"===e.type&&t.test(e.value)&&(e.value="#639")});const o=String(a);o!==c.value&&(c.cloneBefore({value:o}),l.preserve||c.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-color-rebeccapurple/dist/index.d.ts b/plugins/postcss-color-rebeccapurple/dist/index.d.ts index fd19298ad..782b78912 100644 --- a/plugins/postcss-color-rebeccapurple/dist/index.d.ts +++ b/plugins/postcss-color-rebeccapurple/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-color-rebeccapurple plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-color-rebeccapurple/dist/index.mjs b/plugins/postcss-color-rebeccapurple/dist/index.mjs index 3106c1210..42a775026 100644 --- a/plugins/postcss-color-rebeccapurple/dist/index.mjs +++ b/plugins/postcss-color-rebeccapurple/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";import{hasFallback as r}from"@csstools/utilities";const s=/rebeccapurple/i,t=/^rebeccapurple$/i,creator=o=>{const c=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-color-rebeccapurple",Declaration(o){if(!s.test(o.value))return;if(r(o))return;const l=e(o.value);l.walk(e=>{"word"===e.type&&t.test(e.value)&&(e.value="#639")});const a=String(l);a!==o.value&&(o.cloneBefore({value:a}),c.preserve||o.remove())}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-value-parser";import{hasFallback as r}from"@csstools/utilities";const s=/rebeccapurple/i,t=/^rebeccapurple$/i,creator=o=>{const c=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-color-rebeccapurple",Declaration(o){if(!s.test(o.value))return;if(r(o))return;const l=e(o.value);l.walk(e=>{"word"===e.type&&t.test(e.value)&&(e.value="#639")});const a=String(l);a!==o.value&&(o.cloneBefore({value:a}),c.preserve||o.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-color-rebeccapurple/package.json b/plugins/postcss-color-rebeccapurple/package.json index 0f245dfc2..f585a6d4a 100644 --- a/plugins/postcss-color-rebeccapurple/package.json +++ b/plugins/postcss-color-rebeccapurple/package.json @@ -32,20 +32,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-color-rebeccapurple/src/index.ts b/plugins/postcss-color-rebeccapurple/src/index.ts index 5a80f58e0..03a8eec97 100644 --- a/plugins/postcss-color-rebeccapurple/src/index.ts +++ b/plugins/postcss-color-rebeccapurple/src/index.ts @@ -63,4 +63,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-conditional-values/CHANGELOG.md b/plugins/postcss-conditional-values/CHANGELOG.md index bc9e1579e..ada9d981f 100644 --- a/plugins/postcss-conditional-values/CHANGELOG.md +++ b/plugins/postcss-conditional-values/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Conditional Values +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.0 _August 3, 2024_ diff --git a/plugins/postcss-conditional-values/dist/index.cjs b/plugins/postcss-conditional-values/dist/index.cjs deleted file mode 100644 index 1b3ccca5d..000000000 --- a/plugins/postcss-conditional-values/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser");const creator=t=>{const o=Object.assign({functionName:"csstools-if"},t);return{postcssPlugin:"postcss-conditional-values",prepare(){const t=new Map,r=new Set,s=new Set;return{postcssPlugin:"postcss-conditional-values",Declaration(n,{postcss:a}){if(!n.value.toLowerCase().includes(o.functionName))return;const u=e(n.value);let i="";const l=[];let c=!1;const p=[];if(u.walk(t=>{if("function"===t.type&&t.nodes&&t.value.toLowerCase()===o.functionName)return t.nodes.forEach(t=>{i||"word"!==t.type||"--"!==t.value.slice(0,2)?i&&("word"!==t.type||"else"!==t.value?c?p.push(t):l.push(t):c=!0):i=e.stringify(t).trim()}),!1}),!i)return;if(l.some(e=>"div"===e.type&&","===e.value))return;if(p.some(e=>"div"===e.type&&","===e.value))return;const d=e.stringify(l).trim(),f=e.stringify(p).trim();if(d&&f){{const r=t.get(i)||0;t.set(i,r+1);const s=`${i}--${r}`;n.cloneBefore({prop:s,value:`var(${i}) ${f}`}),u.walk(t=>{if("function"===t.type&&t.nodes&&t.value.toLowerCase()===o.functionName)return t.value="var",t.nodes=[...e(s).nodes,{sourceIndex:0,sourceEndIndex:1,value:",",type:"div",before:"",after:""},...e(d).nodes],!1}),n.cloneBefore({value:u.toString()})}if(!r.has(i)&&(n.root().walkDecls(i,e=>{e.prop===i&&(""!==e.value.trim()?"true"===e.value.trim().toLowerCase()?e.value="initial":"false"===e.value.trim().toLowerCase()&&(e.value=" ",s.add(i)):s.add(i))}),r.add(i),!s.has(i))){let e;s.add(i),n.root().each(t=>{if("rule"===t.type&&":root"===t.selector)return e=t,!1}),e||(e=a.rule({selector:":root",source:n.source,raws:{before:"",after:"\n",between:" "}}),n.root().prepend(e));const t=a.decl({value:" ",prop:i,raws:{before:"\n\t"}});t.source=n.source,e.append(t)}n.remove()}}}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-conditional-values/dist/index.d.ts b/plugins/postcss-conditional-values/dist/index.d.ts index 3cac06f72..0dbe7306f 100644 --- a/plugins/postcss-conditional-values/dist/index.d.ts +++ b/plugins/postcss-conditional-values/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export declare type pluginOptions = { functionName: string; diff --git a/plugins/postcss-conditional-values/dist/index.mjs b/plugins/postcss-conditional-values/dist/index.mjs index 09c7a984c..eb704c52c 100644 --- a/plugins/postcss-conditional-values/dist/index.mjs +++ b/plugins/postcss-conditional-values/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";const creator=o=>{const t=Object.assign({functionName:"csstools-if"},o);return{postcssPlugin:"postcss-conditional-values",prepare(){const o=new Map,r=new Set,s=new Set;return{postcssPlugin:"postcss-conditional-values",Declaration(n,{postcss:a}){if(!n.value.toLowerCase().includes(t.functionName))return;const u=e(n.value);let l="";const i=[];let c=!1;const p=[];if(u.walk(o=>{if("function"===o.type&&o.nodes&&o.value.toLowerCase()===t.functionName)return o.nodes.forEach(o=>{l||"word"!==o.type||"--"!==o.value.slice(0,2)?l&&("word"!==o.type||"else"!==o.value?c?p.push(o):i.push(o):c=!0):l=e.stringify(o).trim()}),!1}),!l)return;if(i.some(e=>"div"===e.type&&","===e.value))return;if(p.some(e=>"div"===e.type&&","===e.value))return;const f=e.stringify(i).trim(),d=e.stringify(p).trim();if(f&&d){{const r=o.get(l)||0;o.set(l,r+1);const s=`${l}--${r}`;n.cloneBefore({prop:s,value:`var(${l}) ${d}`}),u.walk(o=>{if("function"===o.type&&o.nodes&&o.value.toLowerCase()===t.functionName)return o.value="var",o.nodes=[...e(s).nodes,{sourceIndex:0,sourceEndIndex:1,value:",",type:"div",before:"",after:""},...e(f).nodes],!1}),n.cloneBefore({value:u.toString()})}if(!r.has(l)&&(n.root().walkDecls(l,e=>{e.prop===l&&(""!==e.value.trim()?"true"===e.value.trim().toLowerCase()?e.value="initial":"false"===e.value.trim().toLowerCase()&&(e.value=" ",s.add(l)):s.add(l))}),r.add(l),!s.has(l))){let e;s.add(l),n.root().each(o=>{if("rule"===o.type&&":root"===o.selector)return e=o,!1}),e||(e=a.rule({selector:":root",source:n.source,raws:{before:"",after:"\n",between:" "}}),n.root().prepend(e));const o=a.decl({value:" ",prop:l,raws:{before:"\n\t"}});o.source=n.source,e.append(o)}n.remove()}}}}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-value-parser";const creator=o=>{const t=Object.assign({functionName:"csstools-if"},o);return{postcssPlugin:"postcss-conditional-values",prepare(){const o=new Map,s=new Set,r=new Set;return{postcssPlugin:"postcss-conditional-values",Declaration(n,{postcss:a}){if(!n.value.toLowerCase().includes(t.functionName))return;const u=e(n.value);let l="";const i=[];let c=!1;const p=[];if(u.walk(o=>{if("function"===o.type&&o.nodes&&o.value.toLowerCase()===t.functionName)return o.nodes.forEach(o=>{l||"word"!==o.type||"--"!==o.value.slice(0,2)?l&&("word"!==o.type||"else"!==o.value?c?p.push(o):i.push(o):c=!0):l=e.stringify(o).trim()}),!1}),!l)return;if(i.some(e=>"div"===e.type&&","===e.value))return;if(p.some(e=>"div"===e.type&&","===e.value))return;const d=e.stringify(i).trim(),f=e.stringify(p).trim();if(d&&f){{const s=o.get(l)||0;o.set(l,s+1);const r=`${l}--${s}`;n.cloneBefore({prop:r,value:`var(${l}) ${f}`}),u.walk(o=>{if("function"===o.type&&o.nodes&&o.value.toLowerCase()===t.functionName)return o.value="var",o.nodes=[...e(r).nodes,{sourceIndex:0,sourceEndIndex:1,value:",",type:"div",before:"",after:""},...e(d).nodes],!1}),n.cloneBefore({value:u.toString()})}if(!s.has(l)&&(n.root().walkDecls(l,e=>{e.prop===l&&(""!==e.value.trim()?"true"===e.value.trim().toLowerCase()?e.value="initial":"false"===e.value.trim().toLowerCase()&&(e.value=" ",r.add(l)):r.add(l))}),s.add(l),!r.has(l))){let e;r.add(l),n.root().each(o=>{if("rule"===o.type&&":root"===o.selector)return e=o,!1}),e||(e=a.rule({selector:":root",source:n.source,raws:{before:"",after:"\n",between:" "}}),n.root().prepend(e));const o=a.decl({value:" ",prop:l,raws:{before:"\n\t"}});o.source=n.source,e.append(o)}n.remove()}}}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-conditional-values/package.json b/plugins/postcss-conditional-values/package.json index 94c2444c0..c5e0a2a45 100644 --- a/plugins/postcss-conditional-values/package.json +++ b/plugins/postcss-conditional-values/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-conditional-values/src/index.ts b/plugins/postcss-conditional-values/src/index.ts index 7fb3213a8..2cc55fc37 100644 --- a/plugins/postcss-conditional-values/src/index.ts +++ b/plugins/postcss-conditional-values/src/index.ts @@ -201,3 +201,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-content-alt-text/CHANGELOG.md b/plugins/postcss-content-alt-text/CHANGELOG.md index afaeb4b59..d299eae3b 100644 --- a/plugins/postcss-content-alt-text/CHANGELOG.md +++ b/plugins/postcss-content-alt-text/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Content Alt Text +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.8 _September 21, 2025_ diff --git a/plugins/postcss-content-alt-text/dist/index.cjs b/plugins/postcss-content-alt-text/dist/index.cjs deleted file mode 100644 index 0434eb158..000000000 --- a/plugins/postcss-content-alt-text/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),s=require("@csstools/utilities"),t=require("@csstools/css-parser-algorithms"),r=require("@csstools/css-tokenizer");function transform(e,s){const o=e[0];if(!o.length)return"";if(s)return t.stringify([o]);const n=e[1].filter(e=>!t.isWhiteSpaceOrCommentNode(e));return 1===n.length&&t.isTokenNode(n[0])&&r.isTokenString(n[0].value)&&""===n[0].value[4].value?t.stringify([o]):t.stringify([[...o,...e[1]]])}function parse(e){const s=t.parseListOfComponentValues(r.tokenize({css:e})),o=[];let n=0;for(let e=s.length-1;e>=0;e--){const i=s[e];if(!t.isTokenNode(i))continue;const l=i.value;r.isTokenDelim(l)&&("/"===l[4].value&&(o.push(s.slice(n,e)),n=e+1))}return 0!==n&&o.push(s.slice(n,s.length)),o}const o={test:e=>e.includes("content:")&&e.includes("/")},basePlugin=e=>({postcssPlugin:"postcss-content-alt-text",Declaration(t){if("content"!==t.prop||!t.value.includes("/"))return;if(s.hasFallback(t))return;if(s.hasSupportsAtRuleAncestor(t,o))return;const r=parse(t.value);if(2!==r.length)return;const n=transform(r,e?.stripAltText);n!==t.value&&(t.cloneBefore({value:n}),!1===e?.preserve&&t.remove())}});basePlugin.postcss=!0;const creator=s=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0,stripAltText:!1},s);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-content-alt-text",plugins:[e(),basePlugin(t)]}:basePlugin(t)};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-content-alt-text/dist/index.d.ts b/plugins/postcss-content-alt-text/dist/index.d.ts index 2ebb7a3be..5dddeaecd 100644 --- a/plugins/postcss-content-alt-text/dist/index.d.ts +++ b/plugins/postcss-content-alt-text/dist/index.d.ts @@ -10,6 +10,7 @@ export declare type basePluginOptions = { declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-content-alt-text plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-content-alt-text/dist/index.mjs b/plugins/postcss-content-alt-text/dist/index.mjs index 54c5207dc..0cc173f81 100644 --- a/plugins/postcss-content-alt-text/dist/index.mjs +++ b/plugins/postcss-content-alt-text/dist/index.mjs @@ -1 +1 @@ -import s from"@csstools/postcss-progressive-custom-properties";import{hasFallback as t,hasSupportsAtRuleAncestor as e}from"@csstools/utilities";import{stringify as r,isWhiteSpaceOrCommentNode as o,isTokenNode as n,parseListOfComponentValues as c}from"@csstools/css-parser-algorithms";import{isTokenString as l,tokenize as i,isTokenDelim as u}from"@csstools/css-tokenizer";function transform(s,t){const e=s[0];if(!e.length)return"";if(t)return r([e]);const c=s[1].filter(s=>!o(s));return 1===c.length&&n(c[0])&&l(c[0].value)&&""===c[0].value[4].value?r([e]):r([[...e,...s[1]]])}function parse(s){const t=c(i({css:s})),e=[];let r=0;for(let s=t.length-1;s>=0;s--){const o=t[s];if(!n(o))continue;const c=o.value;u(c)&&("/"===c[4].value&&(e.push(t.slice(r,s)),r=s+1))}return 0!==r&&e.push(t.slice(r,t.length)),e}const p={test:s=>s.includes("content:")&&s.includes("/")},basePlugin=s=>({postcssPlugin:"postcss-content-alt-text",Declaration(r){if("content"!==r.prop||!r.value.includes("/"))return;if(t(r))return;if(e(r,p))return;const o=parse(r.value);if(2!==o.length)return;const n=transform(o,s?.stripAltText);n!==r.value&&(r.cloneBefore({value:n}),!1===s?.preserve&&r.remove())}});basePlugin.postcss=!0;const creator=t=>{const e=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0,stripAltText:!1},t);return e.enableProgressiveCustomProperties&&e.preserve?{postcssPlugin:"postcss-content-alt-text",plugins:[s(),basePlugin(e)]}:basePlugin(e)};creator.postcss=!0;export{creator as default}; +import s from"@csstools/postcss-progressive-custom-properties";import{hasFallback as t,hasSupportsAtRuleAncestor as e}from"@csstools/utilities";import{stringify as r,isWhiteSpaceOrCommentNode as o,isTokenNode as n,parseListOfComponentValues as l}from"@csstools/css-parser-algorithms";import{isTokenString as c,tokenize as i,isTokenDelim as u}from"@csstools/css-tokenizer";function transform(s,t){const e=s[0];if(!e.length)return"";if(t)return r([e]);const l=s[1].filter(s=>!o(s));return 1===l.length&&n(l[0])&&c(l[0].value)&&""===l[0].value[4].value?r([e]):r([[...e,...s[1]]])}function parse(s){const t=l(i({css:s})),e=[];let r=0;for(let s=t.length-1;s>=0;s--){const o=t[s];if(!n(o))continue;const l=o.value;u(l)&&("/"===l[4].value&&(e.push(t.slice(r,s)),r=s+1))}return 0!==r&&e.push(t.slice(r,t.length)),e}const p={test:s=>s.includes("content:")&&s.includes("/")},basePlugin=s=>({postcssPlugin:"postcss-content-alt-text",Declaration(r){if("content"!==r.prop||!r.value.includes("/"))return;if(t(r))return;if(e(r,p))return;const o=parse(r.value);if(2!==o.length)return;const n=transform(o,s?.stripAltText);n!==r.value&&(r.cloneBefore({value:n}),!1===s?.preserve&&r.remove())}});basePlugin.postcss=!0;const creator=t=>{const e=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0,stripAltText:!1},t);return e.enableProgressiveCustomProperties&&e.preserve?{postcssPlugin:"postcss-content-alt-text",plugins:[s(),basePlugin(e)]}:basePlugin(e)};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-content-alt-text/package.json b/plugins/postcss-content-alt-text/package.json index 5dcaaf698..b39e33fa3 100644 --- a/plugins/postcss-content-alt-text/package.json +++ b/plugins/postcss-content-alt-text/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-content-alt-text/src/index.ts b/plugins/postcss-content-alt-text/src/index.ts index 9d9ac1d6c..cb95c5a11 100644 --- a/plugins/postcss-content-alt-text/src/index.ts +++ b/plugins/postcss-content-alt-text/src/index.ts @@ -90,3 +90,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-contrast-color-function/CHANGELOG.md b/plugins/postcss-contrast-color-function/CHANGELOG.md index ed07213f9..19846a546 100644 --- a/plugins/postcss-contrast-color-function/CHANGELOG.md +++ b/plugins/postcss-contrast-color-function/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Contrast Color Function +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.12 _September 21, 2025_ diff --git a/plugins/postcss-contrast-color-function/dist/index.cjs b/plugins/postcss-contrast-color-function/dist/index.cjs deleted file mode 100644 index f47e562e0..000000000 --- a/plugins/postcss-contrast-color-function/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/utilities"),o=require("@csstools/css-tokenizer"),r=require("@csstools/css-parser-algorithms"),t=require("@csstools/css-color-parser");const c=/\bcontrast-color\(/i,n=/^contrast-color$/i,basePlugin=s=>({postcssPlugin:"postcss-contrast-color-function",prepare:()=>({postcssPlugin:"postcss-contrast-color-function",Declaration(i){const a=i.value;if(!c.test(a))return;if(e.hasFallback(i))return;if(e.hasSupportsAtRuleAncestor(i,c))return;const l=o.tokenize({css:a}),u=r.replaceComponentValues(r.parseCommaSeparatedListOfComponentValues(l),s=>{if(!r.isFunctionNode(s)||!n.test(s.getName()))return;const e=t.color(s);return e&&!e.syntaxFlags.has(t.SyntaxFlag.HasNoneKeywords)?t.serializeRGB(e):void 0}),p=r.stringify(u);p!==a&&(i.cloneBefore({value:p}),s?.preserve||i.remove())}})});basePlugin.postcss=!0;const postcssPlugin=e=>{const o=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},e);return o.enableProgressiveCustomProperties&&o.preserve?{postcssPlugin:"postcss-contrast-color-function",plugins:[s(),basePlugin(o)]}:basePlugin(o)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-contrast-color-function/dist/index.d.ts b/plugins/postcss-contrast-color-function/dist/index.d.ts index f54903ca7..07699f3e3 100644 --- a/plugins/postcss-contrast-color-function/dist/index.d.ts +++ b/plugins/postcss-contrast-color-function/dist/index.d.ts @@ -11,5 +11,6 @@ export declare type pluginOptions = { /** Transform the contrast-color() function in CSS. */ declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-contrast-color-function/dist/index.mjs b/plugins/postcss-contrast-color-function/dist/index.mjs index 88c63f891..5b7dab18a 100644 --- a/plugins/postcss-contrast-color-function/dist/index.mjs +++ b/plugins/postcss-contrast-color-function/dist/index.mjs @@ -1 +1 @@ -import s from"@csstools/postcss-progressive-custom-properties";import{hasFallback as o,hasSupportsAtRuleAncestor as r}from"@csstools/utilities";import{tokenize as t}from"@csstools/css-tokenizer";import{replaceComponentValues as e,parseCommaSeparatedListOfComponentValues as c,isFunctionNode as n,stringify as i}from"@csstools/css-parser-algorithms";import{color as p,SyntaxFlag as l,serializeRGB as a}from"@csstools/css-color-parser";const u=/\bcontrast-color\(/i,m=/^contrast-color$/i,basePlugin=s=>({postcssPlugin:"postcss-contrast-color-function",prepare:()=>({postcssPlugin:"postcss-contrast-color-function",Declaration(f){const g=f.value;if(!u.test(g))return;if(o(f))return;if(r(f,u))return;const v=t({css:g}),P=e(c(v),s=>{if(!n(s)||!m.test(s.getName()))return;const o=p(s);return o&&!o.syntaxFlags.has(l.HasNoneKeywords)?a(o):void 0}),b=i(P);b!==g&&(f.cloneBefore({value:b}),s?.preserve||f.remove())}})});basePlugin.postcss=!0;const postcssPlugin=o=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},o);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-contrast-color-function",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import s from"@csstools/postcss-progressive-custom-properties";import{hasFallback as o,hasSupportsAtRuleAncestor as r}from"@csstools/utilities";import{tokenize as t}from"@csstools/css-tokenizer";import{replaceComponentValues as e,parseCommaSeparatedListOfComponentValues as c,isFunctionNode as n,stringify as i}from"@csstools/css-parser-algorithms";import{color as p,SyntaxFlag as l,serializeRGB as a}from"@csstools/css-color-parser";const u=/\bcontrast-color\(/i,m=/^contrast-color$/i,basePlugin=s=>({postcssPlugin:"postcss-contrast-color-function",prepare:()=>({postcssPlugin:"postcss-contrast-color-function",Declaration(f){const g=f.value;if(!u.test(g))return;if(o(f))return;if(r(f,u))return;const v=t({css:g}),P=e(c(v),s=>{if(!n(s)||!m.test(s.getName()))return;const o=p(s);return o&&!o.syntaxFlags.has(l.HasNoneKeywords)?a(o):void 0}),b=i(P);b!==g&&(f.cloneBefore({value:b}),s?.preserve||f.remove())}})});basePlugin.postcss=!0;const postcssPlugin=o=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},o);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-contrast-color-function",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-contrast-color-function/package.json b/plugins/postcss-contrast-color-function/package.json index 64e1788b9..171e8ea53 100644 --- a/plugins/postcss-contrast-color-function/package.json +++ b/plugins/postcss-contrast-color-function/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-contrast-color-function/src/index.ts b/plugins/postcss-contrast-color-function/src/index.ts index bc9d485b0..46bc94982 100644 --- a/plugins/postcss-contrast-color-function/src/index.ts +++ b/plugins/postcss-contrast-color-function/src/index.ts @@ -98,3 +98,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-custom-media/CHANGELOG.md b/plugins/postcss-custom-media/CHANGELOG.md index 45e44b23a..fbebe13e9 100644 --- a/plugins/postcss-custom-media/CHANGELOG.md +++ b/plugins/postcss-custom-media/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Custom Media +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 11.0.6 _May 27, 2025_ diff --git a/plugins/postcss-custom-media/dist/index.cjs b/plugins/postcss-custom-media/dist/index.cjs deleted file mode 100644 index 7543fb6e1..000000000 --- a/plugins/postcss-custom-media/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/cascade-layer-name-parser"),r=require("@csstools/css-tokenizer"),t=require("@csstools/media-query-list-parser");const n=e.parse("csstools-implicit-layer")[0];function collectCascadeLayerOrder(r){const t=new Map,a=new Map,o=[];r.walkAtRules(r=>{if("layer"!==r.name.toLowerCase())return;{let e=r.parent;for(;e;){if("atrule"!==e.type||"layer"!==e.name.toLowerCase()){if(e===r.root())break;return}e=e.parent}}let s;if(r.nodes)s=normalizeLayerName(r.params,1);else{if(!r.params.trim())return;s=r.params}let i=e.parse(s);if(i?.length){{let e=r.parent;for(;e&&"atrule"===e.type&&"layer"===e.name.toLowerCase();){const r=a.get(e);r?(i=i.map(e=>r.concat(e)),e=e.parent):e=e.parent}}if(e.addLayerToModel(o,i),r.nodes){const e=i[0].concat(n);t.set(r,e),a.set(r,i[0])}}});for(const r of t.values())e.addLayerToModel(o,[r]);const s=new WeakMap;for(const[e,r]of t)s.set(e,o.findIndex(e=>r.equal(e)));return s}function normalizeLayerName(e,r){return e.trim()?e:"csstools-anon-layer--"+r++}const a=new Set(["scope","container","layer"]);function isProcessableCustomMediaRule(e){if("custom-media"!==e.name.toLowerCase())return!1;if(!e.params||!e.params.includes("--"))return!1;if(e.nodes&&e.nodes.length>0)return!1;let r=e.parent;for(;r;){if("atrule"===r.type&&!a.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}function removeCyclicReferences(e,r){const t=new Set;for(;e.size>0;){const n=findCyclicNode(Array.from(e.keys()),r);if(!n)return t;e.delete(n),t.add(n),r=r.filter(e=>-1===e.indexOf(n))}return t}function findCyclicNode(e,r){let t=e.length;const n=new Array(t),a={};let o=t;const s=makeOutgoingEdges(r),i=makeNodesHash(e);for(;o--;)if(!a[o]){const r=visit(e[o],o,new Set);if(!r)continue;return r}function visit(e,r,o){if(o.has(e))return e;if(!i.has(e))return;if(a[r])return;a[r]=!0;const l=Array.from(s.get(e)||new Set);if(r=l.length){o.add(e);do{const e=l[--r],t=visit(e,i.get(e),o);if(t)return t}while(r);o.delete(e)}n[--t]=e}}function makeOutgoingEdges(e){const r=new Map;for(let t=0,n=e.length;t{throw new Error(`Unable to parse media query "${e}"`)}}),n=[];for(;!t.endOfFile();)n.push(t.nextToken());return n}const o=[[r.TokenType.Ident,"max-color",0,0,{value:"max-color"}],[r.TokenType.Colon,":",0,0,void 0],[r.TokenType.Number,"2147477350",0,0,{value:2147477350,type:r.NumberType.Integer}]],s=[[r.TokenType.Ident,"color",0,0,{value:"color"}],[r.TokenType.Colon,":",0,0,void 0],[r.TokenType.Number,"2147477350",0,0,{value:2147477350,type:r.NumberType.Integer}]];function replaceTrueAndFalseTokens(e){let t,n=[];for(let a=0;a{throw new Error(`Unable to parse media query "${r.stringify(...s)}"`)}}),l=t.parseFromTokens(r.cloneTokens(s),{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${r.stringify(...s)}"`)}}).map(e=>e.negateQuery());return{name:o,truthy:i,falsy:l,dependencies:Array.from(a).map(e=>[o,e])}}function getCustomMedia(e,r,t){const n=new Map,a=new Map,o=[],s=collectCascadeLayerOrder(e);e.walkAtRules(e=>{if(!isProcessableCustomMediaRule(e))return;const r=parseCustomMedia(e.params);if(!r)return;if(0===r.truthy.length)return;const i=(u=s,(l=e).parent&&"atrule"===l.parent.type&&"layer"===l.parent.name.toLowerCase()?u.has(l.parent)?u.get(l.parent)+1:0:1e7);var l,u;const c=a.get(r.name)??-1;if(i&&i>=c&&(a.set(r.name,i),n.set(r.name,{truthy:r.truthy,falsy:r.falsy}),o.push(...r.dependencies)),!t.preserve){const r=e.parent;e.remove(),removeEmptyAncestorBlocks(r)}});const i=removeCyclicReferences(n,o);for(const t of i.values())e.warn(r,`@custom-media rules have cyclic dependencies for "${t}"`);return n}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(r.nodes&&r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function transformAtMediaListTokens(e,r){const n=t.parse(e,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${e}"`)}}),a=n.map(e=>e.toString());for(let e=0;et===e?n:{replaceWith:r})}const s=transformComplexMediaQuery(t,r);if(s&&0!==s.length&&s[0].replaceWith!==o)return a.flatMap((r,t)=>t===e?s:[{replaceWith:r}])}return[]}function transformSimpleMediaQuery(e,r){if(!mediaQueryIsSimple(e))return null;let n=null;return e.walk(e=>{const a=e.node;if(!t.isMediaFeatureBoolean(a))return;const o=a.getName();if(!o.startsWith("--"))return;const s=r.get(o);return s?(n={replaceWith:s.truthy.map(e=>e.toString().trim()).join(",")},!1):void 0}),n}function transformComplexMediaQuery(e,r){let n=[];return e.walk(a=>{const i=a.node;if(!t.isMediaFeatureBoolean(i))return;const l=a.parent;if(!t.isMediaFeature(l))return;const u=i.getName();if(!u.startsWith("--"))return;const c=r.get(u);if(c){if(1===c.truthy.length&&mediaQueryIsSimple(c.truthy[0])){let r=null;if(c.truthy[0].walk(e=>{if(t.isMediaFeature(e.node))return r=e.node,!1}),r&&r.feature)return l.feature=r.feature,n=[{replaceWith:e.toString()}],!1}const r=t.newMediaFeaturePlain(o[0][4].value,o[2]);l.feature=r.feature;const a=e.toString(),i=t.newMediaFeaturePlain(s[0][4].value,s[2]);l.feature=i.feature;const u=e.toString();return n=[{replaceWith:a,encapsulateWith:[c.truthy.map(e=>e.toString().trim()).join(",")]},{replaceWith:u,encapsulateWith:c.falsy.map(e=>e.map(e=>e.toString().trim()).join(",").toString().trim())}],!1}}),n}function mediaQueryIsSimple(e){if(t.isMediaQueryInvalid(e))return!1;if(t.isMediaQueryWithType(e))return!1;let r=!0;return e.walk(e=>{if(t.isMediaAnd(e.node)||t.isMediaOr(e.node)||t.isMediaNot(e.node)||t.isMediaConditionList(e.node)||t.isGeneralEnclosed(e.node))return r=!1,!1}),r}const creator=e=>{const r=e?.preserve??!1;if("importFrom"in Object(e))throw new Error('[postcss-custom-media] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-media] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-media",prepare(){const e=new WeakSet;let t=new Map;return{postcssPlugin:"postcss-custom-media",Once(e,{result:n}){t=getCustomMedia(e,n,{preserve:r})},AtRule(n,{result:a}){if(e.has(n))return;if("media"!==n.name.toLowerCase())return;if(!n.params)return;if(!n.params.includes("--"))return;let o=[];try{o=transformAtMediaListTokens(n.params,t)}catch(e){return void n.warn(a,`Failed to parse @custom-media params with error message: "${e instanceof Error?e.message:e}"`)}if(!o||0===o.length)return;if(1===o.length){if(n.params.trim()===o[0].replaceWith.trim())return;return e.add(n),n.cloneBefore({params:o[0].replaceWith.trim()}),r?void 0:void n.remove()}if(!!!o.find(e=>!!e.encapsulateWith?.length))return e.add(n),n.cloneBefore({params:o.map(e=>e.replaceWith).join(",").trim()}),void(r||n.remove());o.forEach(r=>{if(!r.encapsulateWith?.length)return void n.cloneBefore({params:r.replaceWith.trim()});const t=n.clone({params:r.replaceWith});t.parent=void 0;let a=n.clone({params:r.encapsulateWith[0],nodes:[]});a.parent=void 0,a.append(t),r.encapsulateWith.slice(1).forEach(e=>{const r=n.clone({params:e,nodes:[]});r.parent=void 0,r.append(a),a=r}),e.add(n),n.before(a)}),r||n.remove()}}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-custom-media/dist/index.d.ts b/plugins/postcss-custom-media/dist/index.d.ts index ff7d04217..21e09a594 100644 --- a/plugins/postcss-custom-media/dist/index.d.ts +++ b/plugins/postcss-custom-media/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-custom-media plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-custom-media/dist/index.mjs b/plugins/postcss-custom-media/dist/index.mjs index 56c14fea5..7da4ccdc3 100644 --- a/plugins/postcss-custom-media/dist/index.mjs +++ b/plugins/postcss-custom-media/dist/index.mjs @@ -1 +1 @@ -import{parse as e,addLayerToModel as r}from"@csstools/cascade-layer-name-parser";import{tokenizer as t,TokenType as n,NumberType as a,isTokenWhiteSpaceOrComment as o,isTokenIdent as s,cloneTokens as i,stringify as l}from"@csstools/css-tokenizer";import{parseFromTokens as u,parse as c,isMediaFeatureBoolean as f,isMediaFeature as p,newMediaFeaturePlain as m,isMediaQueryInvalid as d,isMediaQueryWithType as h,isMediaAnd as y,isMediaOr as g,isMediaNot as v,isMediaConditionList as w,isGeneralEnclosed as k}from"@csstools/media-query-list-parser";const C=e("csstools-implicit-layer")[0];function collectCascadeLayerOrder(t){const n=new Map,a=new Map,o=[];t.walkAtRules(t=>{if("layer"!==t.name.toLowerCase())return;{let e=t.parent;for(;e;){if("atrule"!==e.type||"layer"!==e.name.toLowerCase()){if(e===t.root())break;return}e=e.parent}}let s;if(t.nodes)s=normalizeLayerName(t.params,1);else{if(!t.params.trim())return;s=t.params}let i=e(s);if(i?.length){{let e=t.parent;for(;e&&"atrule"===e.type&&"layer"===e.name.toLowerCase();){const r=a.get(e);r?(i=i.map(e=>r.concat(e)),e=e.parent):e=e.parent}}if(r(o,i),t.nodes){const e=i[0].concat(C);n.set(t,e),a.set(t,i[0])}}});for(const e of n.values())r(o,[e]);const s=new WeakMap;for(const[e,r]of n)s.set(e,o.findIndex(e=>r.equal(e)));return s}function normalizeLayerName(e,r){return e.trim()?e:"csstools-anon-layer--"+r++}const W=new Set(["scope","container","layer"]);function isProcessableCustomMediaRule(e){if("custom-media"!==e.name.toLowerCase())return!1;if(!e.params||!e.params.includes("--"))return!1;if(e.nodes&&e.nodes.length>0)return!1;let r=e.parent;for(;r;){if("atrule"===r.type&&!W.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}function removeCyclicReferences(e,r){const t=new Set;for(;e.size>0;){const n=findCyclicNode(Array.from(e.keys()),r);if(!n)return t;e.delete(n),t.add(n),r=r.filter(e=>-1===e.indexOf(n))}return t}function findCyclicNode(e,r){let t=e.length;const n=new Array(t),a={};let o=t;const s=makeOutgoingEdges(r),i=makeNodesHash(e);for(;o--;)if(!a[o]){const r=visit(e[o],o,new Set);if(!r)continue;return r}function visit(e,r,o){if(o.has(e))return e;if(!i.has(e))return;if(a[r])return;a[r]=!0;const l=Array.from(s.get(e)||new Set);if(r=l.length){o.add(e);do{const e=l[--r],t=visit(e,i.get(e),o);if(t)return t}while(r);o.delete(e)}n[--t]=e}}function makeOutgoingEdges(e){const r=new Map;for(let t=0,n=e.length;t{throw new Error(`Unable to parse media query "${e}"`)}}),n=[];for(;!r.endOfFile();)n.push(r.nextToken());return n}const M=[[n.Ident,"max-color",0,0,{value:"max-color"}],[n.Colon,":",0,0,void 0],[n.Number,"2147477350",0,0,{value:2147477350,type:a.Integer}]],S=[[n.Ident,"color",0,0,{value:"color"}],[n.Colon,":",0,0,void 0],[n.Number,"2147477350",0,0,{value:2147477350,type:a.Integer}]];function replaceTrueAndFalseTokens(e){let r,t=[];for(let n=0;n{throw new Error(`Unable to parse media query "${l(...a)}"`)}}),f=u(i(a),{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${l(...a)}"`)}}).map(e=>e.negateQuery());return{name:n,truthy:c,falsy:f,dependencies:Array.from(t).map(e=>[n,e])}}function getCustomMedia(e,r,t){const n=new Map,a=new Map,o=[],s=collectCascadeLayerOrder(e);e.walkAtRules(e=>{if(!isProcessableCustomMediaRule(e))return;const r=parseCustomMedia(e.params);if(!r)return;if(0===r.truthy.length)return;const i=(u=s,(l=e).parent&&"atrule"===l.parent.type&&"layer"===l.parent.name.toLowerCase()?u.has(l.parent)?u.get(l.parent)+1:0:1e7);var l,u;const c=a.get(r.name)??-1;if(i&&i>=c&&(a.set(r.name,i),n.set(r.name,{truthy:r.truthy,falsy:r.falsy}),o.push(...r.dependencies)),!t.preserve){const r=e.parent;e.remove(),removeEmptyAncestorBlocks(r)}});const i=removeCyclicReferences(n,o);for(const t of i.values())e.warn(r,`@custom-media rules have cyclic dependencies for "${t}"`);return n}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(r.nodes&&r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function transformAtMediaListTokens(e,r){const t=c(e,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${e}"`)}}),n=t.map(e=>e.toString());for(let e=0;en===e?t:{replaceWith:r})}const s=transformComplexMediaQuery(a,r);if(s&&0!==s.length&&s[0].replaceWith!==o)return n.flatMap((r,t)=>t===e?s:[{replaceWith:r}])}return[]}function transformSimpleMediaQuery(e,r){if(!mediaQueryIsSimple(e))return null;let t=null;return e.walk(e=>{const n=e.node;if(!f(n))return;const a=n.getName();if(!a.startsWith("--"))return;const o=r.get(a);return o?(t={replaceWith:o.truthy.map(e=>e.toString().trim()).join(",")},!1):void 0}),t}function transformComplexMediaQuery(e,r){let t=[];return e.walk(n=>{const a=n.node;if(!f(a))return;const o=n.parent;if(!p(o))return;const s=a.getName();if(!s.startsWith("--"))return;const i=r.get(s);if(i){if(1===i.truthy.length&&mediaQueryIsSimple(i.truthy[0])){let r=null;if(i.truthy[0].walk(e=>{if(p(e.node))return r=e.node,!1}),r&&r.feature)return o.feature=r.feature,t=[{replaceWith:e.toString()}],!1}const r=m(M[0][4].value,M[2]);o.feature=r.feature;const n=e.toString(),a=m(S[0][4].value,S[2]);o.feature=a.feature;const s=e.toString();return t=[{replaceWith:n,encapsulateWith:[i.truthy.map(e=>e.toString().trim()).join(",")]},{replaceWith:s,encapsulateWith:i.falsy.map(e=>e.map(e=>e.toString().trim()).join(",").toString().trim())}],!1}}),t}function mediaQueryIsSimple(e){if(d(e))return!1;if(h(e))return!1;let r=!0;return e.walk(e=>{if(y(e.node)||g(e.node)||v(e.node)||w(e.node)||k(e.node))return r=!1,!1}),r}const creator=e=>{const r=e?.preserve??!1;if("importFrom"in Object(e))throw new Error('[postcss-custom-media] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-media] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-media",prepare(){const e=new WeakSet;let t=new Map;return{postcssPlugin:"postcss-custom-media",Once(e,{result:n}){t=getCustomMedia(e,n,{preserve:r})},AtRule(n,{result:a}){if(e.has(n))return;if("media"!==n.name.toLowerCase())return;if(!n.params)return;if(!n.params.includes("--"))return;let o=[];try{o=transformAtMediaListTokens(n.params,t)}catch(e){return void n.warn(a,`Failed to parse @custom-media params with error message: "${e instanceof Error?e.message:e}"`)}if(!o||0===o.length)return;if(1===o.length){if(n.params.trim()===o[0].replaceWith.trim())return;return e.add(n),n.cloneBefore({params:o[0].replaceWith.trim()}),r?void 0:void n.remove()}if(!!!o.find(e=>!!e.encapsulateWith?.length))return e.add(n),n.cloneBefore({params:o.map(e=>e.replaceWith).join(",").trim()}),void(r||n.remove());o.forEach(r=>{if(!r.encapsulateWith?.length)return void n.cloneBefore({params:r.replaceWith.trim()});const t=n.clone({params:r.replaceWith});t.parent=void 0;let a=n.clone({params:r.encapsulateWith[0],nodes:[]});a.parent=void 0,a.append(t),r.encapsulateWith.slice(1).forEach(e=>{const r=n.clone({params:e,nodes:[]});r.parent=void 0,r.append(a),a=r}),e.add(n),n.before(a)}),r||n.remove()}}}}};creator.postcss=!0;export{creator as default}; +import{parse as e,addLayerToModel as r}from"@csstools/cascade-layer-name-parser";import{tokenizer as t,TokenType as n,NumberType as a,isTokenWhiteSpaceOrComment as o,isTokenIdent as s,cloneTokens as i,stringify as l}from"@csstools/css-tokenizer";import{parseFromTokens as u,parse as c,isMediaFeatureBoolean as p,isMediaFeature as f,newMediaFeaturePlain as m,isMediaQueryInvalid as d,isMediaQueryWithType as h,isMediaAnd as y,isMediaOr as g,isMediaNot as v,isMediaConditionList as w,isGeneralEnclosed as k}from"@csstools/media-query-list-parser";const C=e("csstools-implicit-layer")[0];function collectCascadeLayerOrder(t){const n=new Map,a=new Map,o=[];t.walkAtRules(t=>{if("layer"!==t.name.toLowerCase())return;{let e=t.parent;for(;e;){if("atrule"!==e.type||"layer"!==e.name.toLowerCase()){if(e===t.root())break;return}e=e.parent}}let s;if(t.nodes)s=normalizeLayerName(t.params,1);else{if(!t.params.trim())return;s=t.params}let i=e(s);if(i?.length){{let e=t.parent;for(;e&&"atrule"===e.type&&"layer"===e.name.toLowerCase();){const r=a.get(e);r?(i=i.map(e=>r.concat(e)),e=e.parent):e=e.parent}}if(r(o,i),t.nodes){const e=i[0].concat(C);n.set(t,e),a.set(t,i[0])}}});for(const e of n.values())r(o,[e]);const s=new WeakMap;for(const[e,r]of n)s.set(e,o.findIndex(e=>r.equal(e)));return s}function normalizeLayerName(e,r){return e.trim()?e:"csstools-anon-layer--"+r++}const W=new Set(["scope","container","layer"]);function isProcessableCustomMediaRule(e){if("custom-media"!==e.name.toLowerCase())return!1;if(!e.params||!e.params.includes("--"))return!1;if(e.nodes&&e.nodes.length>0)return!1;let r=e.parent;for(;r;){if("atrule"===r.type&&!W.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}function removeCyclicReferences(e,r){const t=new Set;for(;e.size>0;){const n=findCyclicNode(Array.from(e.keys()),r);if(!n)return t;e.delete(n),t.add(n),r=r.filter(e=>-1===e.indexOf(n))}return t}function findCyclicNode(e,r){let t=e.length;const n=new Array(t),a={};let o=t;const s=makeOutgoingEdges(r),i=makeNodesHash(e);for(;o--;)if(!a[o]){const r=visit(e[o],o,new Set);if(!r)continue;return r}function visit(e,r,o){if(o.has(e))return e;if(!i.has(e))return;if(a[r])return;a[r]=!0;const l=Array.from(s.get(e)||new Set);if(r=l.length){o.add(e);do{const e=l[--r],t=visit(e,i.get(e),o);if(t)return t}while(r);o.delete(e)}n[--t]=e}}function makeOutgoingEdges(e){const r=new Map;for(let t=0,n=e.length;t{throw new Error(`Unable to parse media query "${e}"`)}}),n=[];for(;!r.endOfFile();)n.push(r.nextToken());return n}const M=[[n.Ident,"max-color",0,0,{value:"max-color"}],[n.Colon,":",0,0,void 0],[n.Number,"2147477350",0,0,{value:2147477350,type:a.Integer}]],S=[[n.Ident,"color",0,0,{value:"color"}],[n.Colon,":",0,0,void 0],[n.Number,"2147477350",0,0,{value:2147477350,type:a.Integer}]];function replaceTrueAndFalseTokens(e){let r,t=[];for(let n=0;n{throw new Error(`Unable to parse media query "${l(...a)}"`)}}),p=u(i(a),{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${l(...a)}"`)}}).map(e=>e.negateQuery());return{name:n,truthy:c,falsy:p,dependencies:Array.from(t).map(e=>[n,e])}}function getCustomMedia(e,r,t){const n=new Map,a=new Map,o=[],s=collectCascadeLayerOrder(e);e.walkAtRules(e=>{if(!isProcessableCustomMediaRule(e))return;const r=parseCustomMedia(e.params);if(!r)return;if(0===r.truthy.length)return;const i=(u=s,(l=e).parent&&"atrule"===l.parent.type&&"layer"===l.parent.name.toLowerCase()?u.has(l.parent)?u.get(l.parent)+1:0:1e7);var l,u;const c=a.get(r.name)??-1;if(i&&i>=c&&(a.set(r.name,i),n.set(r.name,{truthy:r.truthy,falsy:r.falsy}),o.push(...r.dependencies)),!t.preserve){const r=e.parent;e.remove(),removeEmptyAncestorBlocks(r)}});const i=removeCyclicReferences(n,o);for(const t of i.values())e.warn(r,`@custom-media rules have cyclic dependencies for "${t}"`);return n}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(r.nodes&&r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function transformAtMediaListTokens(e,r){const t=c(e,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${e}"`)}}),n=t.map(e=>e.toString());for(let e=0;en===e?t:{replaceWith:r})}const s=transformComplexMediaQuery(a,r);if(s&&0!==s.length&&s[0].replaceWith!==o)return n.flatMap((r,t)=>t===e?s:[{replaceWith:r}])}return[]}function transformSimpleMediaQuery(e,r){if(!mediaQueryIsSimple(e))return null;let t=null;return e.walk(e=>{const n=e.node;if(!p(n))return;const a=n.getName();if(!a.startsWith("--"))return;const o=r.get(a);return o?(t={replaceWith:o.truthy.map(e=>e.toString().trim()).join(",")},!1):void 0}),t}function transformComplexMediaQuery(e,r){let t=[];return e.walk(n=>{const a=n.node;if(!p(a))return;const o=n.parent;if(!f(o))return;const s=a.getName();if(!s.startsWith("--"))return;const i=r.get(s);if(i){if(1===i.truthy.length&&mediaQueryIsSimple(i.truthy[0])){let r=null;if(i.truthy[0].walk(e=>{if(f(e.node))return r=e.node,!1}),r&&r.feature)return o.feature=r.feature,t=[{replaceWith:e.toString()}],!1}const r=m(M[0][4].value,M[2]);o.feature=r.feature;const n=e.toString(),a=m(S[0][4].value,S[2]);o.feature=a.feature;const s=e.toString();return t=[{replaceWith:n,encapsulateWith:[i.truthy.map(e=>e.toString().trim()).join(",")]},{replaceWith:s,encapsulateWith:i.falsy.map(e=>e.map(e=>e.toString().trim()).join(",").toString().trim())}],!1}}),t}function mediaQueryIsSimple(e){if(d(e))return!1;if(h(e))return!1;let r=!0;return e.walk(e=>{if(y(e.node)||g(e.node)||v(e.node)||w(e.node)||k(e.node))return r=!1,!1}),r}const creator=e=>{const r=e?.preserve??!1;if("importFrom"in Object(e))throw new Error('[postcss-custom-media] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-media] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-media",prepare(){const e=new WeakSet;let t=new Map;return{postcssPlugin:"postcss-custom-media",Once(e,{result:n}){t=getCustomMedia(e,n,{preserve:r})},AtRule(n,{result:a}){if(e.has(n))return;if("media"!==n.name.toLowerCase())return;if(!n.params)return;if(!n.params.includes("--"))return;let o=[];try{o=transformAtMediaListTokens(n.params,t)}catch(e){return void n.warn(a,`Failed to parse @custom-media params with error message: "${e instanceof Error?e.message:e}"`)}if(!o||0===o.length)return;if(1===o.length){if(n.params.trim()===o[0].replaceWith.trim())return;return e.add(n),n.cloneBefore({params:o[0].replaceWith.trim()}),r?void 0:void n.remove()}if(!!!o.find(e=>!!e.encapsulateWith?.length))return e.add(n),n.cloneBefore({params:o.map(e=>e.replaceWith).join(",").trim()}),void(r||n.remove());o.forEach(r=>{if(!r.encapsulateWith?.length)return void n.cloneBefore({params:r.replaceWith.trim()});const t=n.clone({params:r.replaceWith});t.parent=void 0;let a=n.clone({params:r.encapsulateWith[0],nodes:[]});a.parent=void 0,a.append(t),r.encapsulateWith.slice(1).forEach(e=>{const r=n.clone({params:e,nodes:[]});r.parent=void 0,r.append(a),a=r}),e.add(n),n.before(a)}),r||n.remove()}}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-custom-media/package.json b/plugins/postcss-custom-media/package.json index 3968051b3..4e6a5ec4e 100644 --- a/plugins/postcss-custom-media/package.json +++ b/plugins/postcss-custom-media/package.json @@ -32,20 +32,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-custom-media/src/index.ts b/plugins/postcss-custom-media/src/index.ts index 083b27259..42df235cf 100644 --- a/plugins/postcss-custom-media/src/index.ts +++ b/plugins/postcss-custom-media/src/index.ts @@ -132,3 +132,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-custom-properties/CHANGELOG.md b/plugins/postcss-custom-properties/CHANGELOG.md index c73e9b119..93ab0c3ff 100644 --- a/plugins/postcss-custom-properties/CHANGELOG.md +++ b/plugins/postcss-custom-properties/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Custom Properties +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 14.0.6 _June 5, 2025_ diff --git a/plugins/postcss-custom-properties/dist/index.cjs b/plugins/postcss-custom-properties/dist/index.cjs deleted file mode 100644 index c0a41e805..000000000 --- a/plugins/postcss-custom-properties/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/cascade-layer-name-parser"),t=require("postcss-value-parser"),r=require("@csstools/utilities");const n=e.parse("csstools-implicit-layer")[0];function collectCascadeLayerOrder(t){const r=new Map,o=new Map,s=[];t.walkAtRules(t=>{if("layer"!==t.name.toLowerCase())return;{let e=t.parent;for(;e;){if("atrule"!==e.type||"layer"!==e.name.toLowerCase()){if(e===t.root())break;return}e=e.parent}}let a;if(t.nodes)a=normalizeLayerName(t.params,1);else{if(!t.params.trim())return;a=t.params}let i=e.parse(a);if(i?.length){{let e=t.parent;for(;e&&"atrule"===e.type&&"layer"===e.name.toLowerCase();){const t=o.get(e);t?(i=i.map(e=>t.concat(e)),e=e.parent):e=e.parent}}if(e.addLayerToModel(s,i),t.nodes){const e=i[0].concat(n);r.set(t,e),o.set(t,i[0])}}});for(const t of r.values())e.addLayerToModel(s,[t]);const a=new WeakMap;for(const[e,t]of r)a.set(e,s.findIndex(e=>t.equal(e)));return a}function normalizeLayerName(e,t){return e.trim()?e:"csstools-anon-layer--"+t++}const o=/(?:!\s*)?postcss-custom-properties:\s*off\b/i,s=new WeakMap;function isBlockIgnored(e){if(!e||!e.nodes)return!1;if(s.has(e))return s.get(e);const t=e.some(e=>isIgnoreComment(e,o));return s.set(e,t),t}const a=/(?:!\s*)?postcss-custom-properties:\s*ignore\s+next\b/i;function isDeclarationIgnored(e){return!!e&&(!!isBlockIgnored(e.parent)||isIgnoreComment(e.prev(),a))}function isIgnoreComment(e,t){return!!e&&"comment"===e.type&&t.test(e.text)}const i=new Set(["layer"]);function isProcessableRule(e){let t=e.parent;for(;t;){if("atrule"===t.type&&!i.has(t.name.toLowerCase()))return!1;t=t.parent}return!0}const c=/^html$/i,l=/^:where\(html\)$/i,u=/^:root$/i,p=/^:where\(:root\)$/i,f=/(html|:root)/i,d=/^var$/i;function isVarFunction(e){return"function"===e.type&&d.test(e.value)&&e.nodes?.length>0}const m=/\bvar\(/i;function parseOrCached(e,r){let n=r.get(e);return n||(n=t(e),r.set(e,n),n)}function toposort(e,t){let r=e.length;const n=new Array(r),o={};let s=r;const a=makeOutgoingEdges(t),i=makeNodesHash(e);for(;s--;)o[s]||visit(e[s],s,new Set);return n;function visit(e,t,s){if(s.has(e)){let t;try{t=", node was:"+JSON.stringify(e)}catch{t=""}throw new Error("Cyclic dependency"+t)}if(!i.has(e))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(e));if(o[t])return;o[t]=!0;const c=Array.from(a.get(e)||new Set);if(t=c.length){s.add(e);do{const e=c[--t];visit(e,i.get(e),s)}while(t);s.delete(e)}n[--r]=e}}function removeCyclicReferences(e,t){const r=new Set;for(;e.size>0;){const n=findCyclicNode(Array.from(e.keys()),t);if(!n)return r;e.delete(n),r.add(n),t=t.filter(e=>-1===e.indexOf(n))}return r}function findCyclicNode(e,t){let r=e.length;const n=new Array(r),o={};let s=r;const a=makeOutgoingEdges(t),i=makeNodesHash(e);for(;s--;)if(!o[s]){const t=visit(e[s],s,new Set);if(!t)continue;return t}function visit(e,t,s){if(s.has(e))return e;if(!i.has(e))return;if(o[t])return;o[t]=!0;const c=Array.from(a.get(e)||new Set);if(t=c.length){s.add(e);do{const e=c[--t],r=visit(e,i.get(e),s);if(r)return r}while(t);s.delete(e)}n[--r]=e}}function makeOutgoingEdges(e){const t=new Map;for(let r=0,n=e.length;r{if(!isVarFunction(e))return;const s=parseVarFunction(e);if(!s)return;let a=!1;s.fallback&&t.walk(s.fallback,e=>{if(!isVarFunction(e))return;const t=parseVarFunction(e);return t?t.fallback||r.has(t.name.value)?void 0:(a=!0,!1):void 0});let i=r.get(s.name.value)?.nodes;i||!s.fallback||a||(i=s.fallback),void 0!==i&&(i.length?o.splice(n,1,...i):o.splice(n,1,{type:"div",value:" ",before:"",after:"",sourceIndex:e.sourceIndex,sourceEndIndex:e.sourceEndIndex}))}),t.stringify(e.nodes)):""}function walk(e,t){let r,n,o;for(r=0,n=e.length;r"comment"!==e.type&&"space"!==e.type);return 1===t.length&&("word"===t[0].type&&w.test(t[0].value))}function buildCustomPropertiesMap(e,r,n){if(!e.size)return r;const o=new Map(r);{const s=[];for(const[a,i]of e.entries()){const c=parseOrCached(i,n);let l=!1;t.walk(c.nodes,t=>{if(!isVarFunction(t))return;const n=parseVarFunction(t);n&&(n.fallback||e.has(n.name.value)||r.has(n.name.value)?s.push([n.name.value,a]):l=!0)}),l||o.set(a,c)}removeCyclicReferences(o,s)}{const e=[];for(const[r,n]of o.entries())t.walk(n.nodes,t=>{if(!isVarFunction(t))return;const n=parseVarFunction(t);n&&(n.fallback||o.has(n.name.value)?e.push([n.name.value,r]):o.delete(r))});for(let t=0;t{f.test(e.selector)&&e.nodes?.length&&isProcessableRule(e)&&(isBlockIgnored(e)||e.selectors.forEach(t=>{let s=-1;if(l.test(t)||p.test(t))s=0;else if(c.test(t))s=1;else{if(!u.test(t))return;s=2}const a=(f=o,((i=e).parent&&"atrule"===i.parent.type&&"layer"===i.parent.name.toLowerCase()?f.has(i.parent)?f.get(i.parent)+1:0:1e7)+10+s);var i,f;e.each(e=>{if("decl"!==e.type)return;if(!e.variable||isDeclarationIgnored(e))return;if("initial"===e.value.toLowerCase().trim())return;const t=n.get(e.prop)??-1;a>=t&&(n.set(e.prop,a),r.set(e.prop,e.value))})}))}),buildCustomPropertiesMap(r,new Map,t)}function getCustomPropertiesFromSiblings(e,t,r){if(!e.parent)return t;const n=new Map;return e.parent.each(t=>{"decl"===t.type&&t.variable&&e!==t&&(isDeclarationIgnored(t)||n.set(t.prop,t.value))}),n.size?buildCustomPropertiesMap(n,t,r):t}function transformProperties(e,r,n){if(isTransformableDecl(e)&&!isDeclarationIgnored(e)){const o=e.raws?.value?.raw??e.value,s=transformValueAST(t(o),r);if(s===o)return;if(parentHasExactFallback(e,s))return void(n.preserve||e.remove());const a=e.cloneBefore({value:s});a.raws?.value?.raw&&(a.raws.value.raw=""),n?.preserve||e.remove()}}const isTransformableDecl=e=>!e.variable&&e.value.includes("--")&&e.value.toLowerCase().includes("var(");function parentHasExactFallback(e,t){if(!e||!e.parent)return!1;let r=!1;const n=e.parent.index(e);return e.parent.each((o,s)=>o!==e&&(!(s>=n)&&void("decl"===o.type&&o.prop.toLowerCase()===e.prop.toLowerCase()&&o.value===t&&(r=!0)))),r}const v=/\bvar\(|\(top: var\(--f\)/i,creator=e=>{const t=!("preserve"in Object(e))||Boolean(e?.preserve);if("importFrom"in Object(e))throw new Error('[postcss-custom-properties] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-properties] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-properties",prepare(){let e=new Map;const n=new WeakMap,o=new Map;return{postcssPlugin:"postcss-custom-properties",Once(t){e=getCustomPropertiesFromRoot(t,o)},Declaration(s){if(!m.test(s.value))return;if(r.hasSupportsAtRuleAncestor(s,v))return;let a=e;t&&s.parent&&(a=n.get(s.parent)??getCustomPropertiesFromSiblings(s,e,o),n.set(s.parent,a)),transformProperties(s,a,{preserve:t})}}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-custom-properties/dist/index.d.ts b/plugins/postcss-custom-properties/dist/index.d.ts index 7e2b993e2..0fa32737b 100644 --- a/plugins/postcss-custom-properties/dist/index.d.ts +++ b/plugins/postcss-custom-properties/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-custom-properties plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-custom-properties/dist/index.mjs b/plugins/postcss-custom-properties/dist/index.mjs index be9926f7a..e9b6ffb7d 100644 --- a/plugins/postcss-custom-properties/dist/index.mjs +++ b/plugins/postcss-custom-properties/dist/index.mjs @@ -1 +1 @@ -import{parse as e,addLayerToModel as t}from"@csstools/cascade-layer-name-parser";import r from"postcss-value-parser";import{hasSupportsAtRuleAncestor as n}from"@csstools/utilities";const o=e("csstools-implicit-layer")[0];function collectCascadeLayerOrder(r){const n=new Map,s=new Map,a=[];r.walkAtRules(r=>{if("layer"!==r.name.toLowerCase())return;{let e=r.parent;for(;e;){if("atrule"!==e.type||"layer"!==e.name.toLowerCase()){if(e===r.root())break;return}e=e.parent}}let i;if(r.nodes)i=normalizeLayerName(r.params,1);else{if(!r.params.trim())return;i=r.params}let c=e(i);if(c?.length){{let e=r.parent;for(;e&&"atrule"===e.type&&"layer"===e.name.toLowerCase();){const t=s.get(e);t?(c=c.map(e=>t.concat(e)),e=e.parent):e=e.parent}}if(t(a,c),r.nodes){const e=c[0].concat(o);n.set(r,e),s.set(r,c[0])}}});for(const e of n.values())t(a,[e]);const i=new WeakMap;for(const[e,t]of n)i.set(e,a.findIndex(e=>t.equal(e)));return i}function normalizeLayerName(e,t){return e.trim()?e:"csstools-anon-layer--"+t++}const s=/(?:!\s*)?postcss-custom-properties:\s*off\b/i,a=new WeakMap;function isBlockIgnored(e){if(!e||!e.nodes)return!1;if(a.has(e))return a.get(e);const t=e.some(e=>isIgnoreComment(e,s));return a.set(e,t),t}const i=/(?:!\s*)?postcss-custom-properties:\s*ignore\s+next\b/i;function isDeclarationIgnored(e){return!!e&&(!!isBlockIgnored(e.parent)||isIgnoreComment(e.prev(),i))}function isIgnoreComment(e,t){return!!e&&"comment"===e.type&&t.test(e.text)}const c=new Set(["layer"]);function isProcessableRule(e){let t=e.parent;for(;t;){if("atrule"===t.type&&!c.has(t.name.toLowerCase()))return!1;t=t.parent}return!0}const l=/^html$/i,u=/^:where\(html\)$/i,p=/^:root$/i,f=/^:where\(:root\)$/i,d=/(html|:root)/i,m=/^var$/i;function isVarFunction(e){return"function"===e.type&&m.test(e.value)&&e.nodes?.length>0}const w=/\bvar\(/i;function parseOrCached(e,t){let n=t.get(e);return n||(n=r(e),t.set(e,n),n)}function toposort(e,t){let r=e.length;const n=new Array(r),o={};let s=r;const a=makeOutgoingEdges(t),i=makeNodesHash(e);for(;s--;)o[s]||visit(e[s],s,new Set);return n;function visit(e,t,s){if(s.has(e)){let t;try{t=", node was:"+JSON.stringify(e)}catch{t=""}throw new Error("Cyclic dependency"+t)}if(!i.has(e))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(e));if(o[t])return;o[t]=!0;const c=Array.from(a.get(e)||new Set);if(t=c.length){s.add(e);do{const e=c[--t];visit(e,i.get(e),s)}while(t);s.delete(e)}n[--r]=e}}function removeCyclicReferences(e,t){const r=new Set;for(;e.size>0;){const n=findCyclicNode(Array.from(e.keys()),t);if(!n)return r;e.delete(n),r.add(n),t=t.filter(e=>-1===e.indexOf(n))}return r}function findCyclicNode(e,t){let r=e.length;const n=new Array(r),o={};let s=r;const a=makeOutgoingEdges(t),i=makeNodesHash(e);for(;s--;)if(!o[s]){const t=visit(e[s],s,new Set);if(!t)continue;return t}function visit(e,t,s){if(s.has(e))return e;if(!i.has(e))return;if(o[t])return;o[t]=!0;const c=Array.from(a.get(e)||new Set);if(t=c.length){s.add(e);do{const e=c[--t],r=visit(e,i.get(e),s);if(r)return r}while(t);s.delete(e)}n[--r]=e}}function makeOutgoingEdges(e){const t=new Map;for(let r=0,n=e.length;r{if(!isVarFunction(e))return;const s=parseVarFunction(e);if(!s)return;let a=!1;s.fallback&&r.walk(s.fallback,e=>{if(!isVarFunction(e))return;const r=parseVarFunction(e);return r?r.fallback||t.has(r.name.value)?void 0:(a=!0,!1):void 0});let i=t.get(s.name.value)?.nodes;i||!s.fallback||a||(i=s.fallback),void 0!==i&&(i.length?o.splice(n,1,...i):o.splice(n,1,{type:"div",value:" ",before:"",after:"",sourceIndex:e.sourceIndex,sourceEndIndex:e.sourceEndIndex}))}),r.stringify(e.nodes)):""}function walk(e,t){let r,n,o;for(r=0,n=e.length;r"comment"!==e.type&&"space"!==e.type);return 1===t.length&&("word"===t[0].type&&v.test(t[0].value))}function buildCustomPropertiesMap(e,t,n){if(!e.size)return t;const o=new Map(t);{const s=[];for(const[a,i]of e.entries()){const c=parseOrCached(i,n);let l=!1;r.walk(c.nodes,r=>{if(!isVarFunction(r))return;const n=parseVarFunction(r);n&&(n.fallback||e.has(n.name.value)||t.has(n.name.value)?s.push([n.name.value,a]):l=!0)}),l||o.set(a,c)}removeCyclicReferences(o,s)}{const e=[];for(const[t,n]of o.entries())r.walk(n.nodes,r=>{if(!isVarFunction(r))return;const n=parseVarFunction(r);n&&(n.fallback||o.has(n.name.value)?e.push([n.name.value,t]):o.delete(t))});for(let t=0;t{d.test(e.selector)&&e.nodes?.length&&isProcessableRule(e)&&(isBlockIgnored(e)||e.selectors.forEach(t=>{let s=-1;if(u.test(t)||f.test(t))s=0;else if(l.test(t))s=1;else{if(!p.test(t))return;s=2}const a=(c=o,((i=e).parent&&"atrule"===i.parent.type&&"layer"===i.parent.name.toLowerCase()?c.has(i.parent)?c.get(i.parent)+1:0:1e7)+10+s);var i,c;e.each(e=>{if("decl"!==e.type)return;if(!e.variable||isDeclarationIgnored(e))return;if("initial"===e.value.toLowerCase().trim())return;const t=n.get(e.prop)??-1;a>=t&&(n.set(e.prop,a),r.set(e.prop,e.value))})}))}),buildCustomPropertiesMap(r,new Map,t)}function getCustomPropertiesFromSiblings(e,t,r){if(!e.parent)return t;const n=new Map;return e.parent.each(t=>{"decl"===t.type&&t.variable&&e!==t&&(isDeclarationIgnored(t)||n.set(t.prop,t.value))}),n.size?buildCustomPropertiesMap(n,t,r):t}function transformProperties(e,t,n){if(isTransformableDecl(e)&&!isDeclarationIgnored(e)){const o=e.raws?.value?.raw??e.value,s=transformValueAST(r(o),t);if(s===o)return;if(parentHasExactFallback(e,s))return void(n.preserve||e.remove());const a=e.cloneBefore({value:s});a.raws?.value?.raw&&(a.raws.value.raw=""),n?.preserve||e.remove()}}const isTransformableDecl=e=>!e.variable&&e.value.includes("--")&&e.value.toLowerCase().includes("var(");function parentHasExactFallback(e,t){if(!e||!e.parent)return!1;let r=!1;const n=e.parent.index(e);return e.parent.each((o,s)=>o!==e&&(!(s>=n)&&void("decl"===o.type&&o.prop.toLowerCase()===e.prop.toLowerCase()&&o.value===t&&(r=!0)))),r}const g=/\bvar\(|\(top: var\(--f\)/i,creator=e=>{const t=!("preserve"in Object(e))||Boolean(e?.preserve);if("importFrom"in Object(e))throw new Error('[postcss-custom-properties] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-properties] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-properties",prepare(){let e=new Map;const r=new WeakMap,o=new Map;return{postcssPlugin:"postcss-custom-properties",Once(t){e=getCustomPropertiesFromRoot(t,o)},Declaration(s){if(!w.test(s.value))return;if(n(s,g))return;let a=e;t&&s.parent&&(a=r.get(s.parent)??getCustomPropertiesFromSiblings(s,e,o),r.set(s.parent,a)),transformProperties(s,a,{preserve:t})}}}}};creator.postcss=!0;export{creator as default}; +import{parse as e,addLayerToModel as t}from"@csstools/cascade-layer-name-parser";import r from"postcss-value-parser";import{hasSupportsAtRuleAncestor as n}from"@csstools/utilities";const o=e("csstools-implicit-layer")[0];function collectCascadeLayerOrder(r){const n=new Map,s=new Map,a=[];r.walkAtRules(r=>{if("layer"!==r.name.toLowerCase())return;{let e=r.parent;for(;e;){if("atrule"!==e.type||"layer"!==e.name.toLowerCase()){if(e===r.root())break;return}e=e.parent}}let i;if(r.nodes)i=normalizeLayerName(r.params,1);else{if(!r.params.trim())return;i=r.params}let c=e(i);if(c?.length){{let e=r.parent;for(;e&&"atrule"===e.type&&"layer"===e.name.toLowerCase();){const t=s.get(e);t?(c=c.map(e=>t.concat(e)),e=e.parent):e=e.parent}}if(t(a,c),r.nodes){const e=c[0].concat(o);n.set(r,e),s.set(r,c[0])}}});for(const e of n.values())t(a,[e]);const i=new WeakMap;for(const[e,t]of n)i.set(e,a.findIndex(e=>t.equal(e)));return i}function normalizeLayerName(e,t){return e.trim()?e:"csstools-anon-layer--"+t++}const s=/(?:!\s*)?postcss-custom-properties:\s*off\b/i,a=new WeakMap;function isBlockIgnored(e){if(!e||!e.nodes)return!1;if(a.has(e))return a.get(e);const t=e.some(e=>isIgnoreComment(e,s));return a.set(e,t),t}const i=/(?:!\s*)?postcss-custom-properties:\s*ignore\s+next\b/i;function isDeclarationIgnored(e){return!!e&&(!!isBlockIgnored(e.parent)||isIgnoreComment(e.prev(),i))}function isIgnoreComment(e,t){return!!e&&"comment"===e.type&&t.test(e.text)}const c=new Set(["layer"]);function isProcessableRule(e){let t=e.parent;for(;t;){if("atrule"===t.type&&!c.has(t.name.toLowerCase()))return!1;t=t.parent}return!0}const l=/^html$/i,u=/^:where\(html\)$/i,p=/^:root$/i,f=/^:where\(:root\)$/i,d=/(html|:root)/i,m=/^var$/i;function isVarFunction(e){return"function"===e.type&&m.test(e.value)&&e.nodes?.length>0}const w=/\bvar\(/i;function parseOrCached(e,t){let n=t.get(e);return n||(n=r(e),t.set(e,n),n)}function toposort(e,t){let r=e.length;const n=new Array(r),o={};let s=r;const a=makeOutgoingEdges(t),i=makeNodesHash(e);for(;s--;)o[s]||visit(e[s],s,new Set);return n;function visit(e,t,s){if(s.has(e)){let t;try{t=", node was:"+JSON.stringify(e)}catch{t=""}throw new Error("Cyclic dependency"+t)}if(!i.has(e))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(e));if(o[t])return;o[t]=!0;const c=Array.from(a.get(e)||new Set);if(t=c.length){s.add(e);do{const e=c[--t];visit(e,i.get(e),s)}while(t);s.delete(e)}n[--r]=e}}function removeCyclicReferences(e,t){const r=new Set;for(;e.size>0;){const n=findCyclicNode(Array.from(e.keys()),t);if(!n)return r;e.delete(n),r.add(n),t=t.filter(e=>-1===e.indexOf(n))}return r}function findCyclicNode(e,t){let r=e.length;const n=new Array(r),o={};let s=r;const a=makeOutgoingEdges(t),i=makeNodesHash(e);for(;s--;)if(!o[s]){const t=visit(e[s],s,new Set);if(!t)continue;return t}function visit(e,t,s){if(s.has(e))return e;if(!i.has(e))return;if(o[t])return;o[t]=!0;const c=Array.from(a.get(e)||new Set);if(t=c.length){s.add(e);do{const e=c[--t],r=visit(e,i.get(e),s);if(r)return r}while(t);s.delete(e)}n[--r]=e}}function makeOutgoingEdges(e){const t=new Map;for(let r=0,n=e.length;r{if(!isVarFunction(e))return;const s=parseVarFunction(e);if(!s)return;let a=!1;s.fallback&&r.walk(s.fallback,e=>{if(!isVarFunction(e))return;const r=parseVarFunction(e);return r?r.fallback||t.has(r.name.value)?void 0:(a=!0,!1):void 0});let i=t.get(s.name.value)?.nodes;i||!s.fallback||a||(i=s.fallback),void 0!==i&&(i.length?o.splice(n,1,...i):o.splice(n,1,{type:"div",value:" ",before:"",after:"",sourceIndex:e.sourceIndex,sourceEndIndex:e.sourceEndIndex}))}),r.stringify(e.nodes)):""}function walk(e,t){let r,n,o;for(r=0,n=e.length;r"comment"!==e.type&&"space"!==e.type);return 1===t.length&&("word"===t[0].type&&v.test(t[0].value))}function buildCustomPropertiesMap(e,t,n){if(!e.size)return t;const o=new Map(t);{const s=[];for(const[a,i]of e.entries()){const c=parseOrCached(i,n);let l=!1;r.walk(c.nodes,r=>{if(!isVarFunction(r))return;const n=parseVarFunction(r);n&&(n.fallback||e.has(n.name.value)||t.has(n.name.value)?s.push([n.name.value,a]):l=!0)}),l||o.set(a,c)}removeCyclicReferences(o,s)}{const e=[];for(const[t,n]of o.entries())r.walk(n.nodes,r=>{if(!isVarFunction(r))return;const n=parseVarFunction(r);n&&(n.fallback||o.has(n.name.value)?e.push([n.name.value,t]):o.delete(t))});for(let t=0;t{d.test(e.selector)&&e.nodes?.length&&isProcessableRule(e)&&(isBlockIgnored(e)||e.selectors.forEach(t=>{let s=-1;if(u.test(t)||f.test(t))s=0;else if(l.test(t))s=1;else{if(!p.test(t))return;s=2}const a=(c=o,((i=e).parent&&"atrule"===i.parent.type&&"layer"===i.parent.name.toLowerCase()?c.has(i.parent)?c.get(i.parent)+1:0:1e7)+10+s);var i,c;e.each(e=>{if("decl"!==e.type)return;if(!e.variable||isDeclarationIgnored(e))return;if("initial"===e.value.toLowerCase().trim())return;const t=n.get(e.prop)??-1;a>=t&&(n.set(e.prop,a),r.set(e.prop,e.value))})}))}),buildCustomPropertiesMap(r,new Map,t)}function getCustomPropertiesFromSiblings(e,t,r){if(!e.parent)return t;const n=new Map;return e.parent.each(t=>{"decl"===t.type&&t.variable&&e!==t&&(isDeclarationIgnored(t)||n.set(t.prop,t.value))}),n.size?buildCustomPropertiesMap(n,t,r):t}function transformProperties(e,t,n){if(isTransformableDecl(e)&&!isDeclarationIgnored(e)){const o=e.raws?.value?.raw??e.value,s=transformValueAST(r(o),t);if(s===o)return;if(parentHasExactFallback(e,s))return void(n.preserve||e.remove());const a=e.cloneBefore({value:s});a.raws?.value?.raw&&(a.raws.value.raw=""),n?.preserve||e.remove()}}const isTransformableDecl=e=>!e.variable&&e.value.includes("--")&&e.value.toLowerCase().includes("var(");function parentHasExactFallback(e,t){if(!e||!e.parent)return!1;let r=!1;const n=e.parent.index(e);return e.parent.each((o,s)=>o!==e&&(!(s>=n)&&void("decl"===o.type&&o.prop.toLowerCase()===e.prop.toLowerCase()&&o.value===t&&(r=!0)))),r}const g=/\bvar\(|\(top: var\(--f\)/i,creator=e=>{const t=!("preserve"in Object(e))||Boolean(e?.preserve);if("importFrom"in Object(e))throw new Error('[postcss-custom-properties] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-properties] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-properties",prepare(){let e=new Map;const r=new WeakMap,o=new Map;return{postcssPlugin:"postcss-custom-properties",Once(t){e=getCustomPropertiesFromRoot(t,o)},Declaration(s){if(!w.test(s.value))return;if(n(s,g))return;let a=e;t&&s.parent&&(a=r.get(s.parent)??getCustomPropertiesFromSiblings(s,e,o),r.set(s.parent,a)),transformProperties(s,a,{preserve:t})}}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-custom-properties/package.json b/plugins/postcss-custom-properties/package.json index c67451f36..7eac0a4fc 100644 --- a/plugins/postcss-custom-properties/package.json +++ b/plugins/postcss-custom-properties/package.json @@ -18,20 +18,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-custom-properties/src/index.ts b/plugins/postcss-custom-properties/src/index.ts index ff5296885..9f2533498 100644 --- a/plugins/postcss-custom-properties/src/index.ts +++ b/plugins/postcss-custom-properties/src/index.ts @@ -64,3 +64,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-custom-selectors/CHANGELOG.md b/plugins/postcss-custom-selectors/CHANGELOG.md index 6d6b157ee..6752a660c 100644 --- a/plugins/postcss-custom-selectors/CHANGELOG.md +++ b/plugins/postcss-custom-selectors/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Custom Selectors +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 8.0.5 _May 27, 2025_ diff --git a/plugins/postcss-custom-selectors/dist/index.cjs b/plugins/postcss-custom-selectors/dist/index.cjs deleted file mode 100644 index 729a92211..000000000 --- a/plugins/postcss-custom-selectors/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser"),r=require("@csstools/cascade-layer-name-parser");const t=r.parse("csstools-implicit-layer")[0];function collectCascadeLayerOrder(e){const s=new Map,o=new Map,n=[];e.walkAtRules(e=>{if("layer"!==e.name.toLowerCase())return;{let r=e.parent;for(;r;){if("atrule"!==r.type||"layer"!==r.name.toLowerCase()){if(r===e.root())break;return}r=r.parent}}let a;if(e.nodes)a=normalizeLayerName(e.params,1);else{if(!e.params.trim())return;a=e.params}let c=r.parse(a);if(c?.length){{let r=e.parent;for(;r&&"atrule"===r.type&&"layer"===r.name.toLowerCase();){const e=o.get(r);e?(c=c.map(r=>e.concat(r)),r=r.parent):r=r.parent}}if(r.addLayerToModel(n,c),e.nodes){const r=c[0].concat(t);s.set(e,r),o.set(e,c[0])}}});for(const e of s.values())r.addLayerToModel(n,[e]);const a=new WeakMap;for(const[e,r]of s)a.set(e,n.findIndex(e=>r.equal(e)));return a}function normalizeLayerName(e,r){return e.trim()?e:"csstools-anon-layer--"+r++}const s=new Set(["scope","container","layer"]);function isProcessableCustomSelectorRule(e){if("atrule"!==e.type)return!1;if("custom-selector"!==e.name.toLowerCase())return!1;if(!e.params||!e.params.includes(":--"))return!1;if(e.nodes&&e.nodes.length>0)return!1;let r=e.parent;for(;r;){if("rule"===r.type)return!1;if("atrule"===r.type&&!s.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}function getCustomSelectors(r,t,s){const o=new Map,n=new Map,a=collectCascadeLayerOrder(r);return r.walkAtRules(r=>{var c,l;if(isProcessableCustomSelectorRule(r))try{const t=r.params.trim(),p=e().astSync(t),u=p?.nodes?.[0]?.nodes?.[0];if(!u||"pseudo"!==u.type||!u.value.startsWith(":--"))return;const i=u.toString(),m=(l=a,(c=r).parent&&"atrule"===c.parent.type&&"layer"===c.parent.name.toLowerCase()?l.has(c.parent)?l.get(c.parent)+1:0:1e7),f=n.get(i)??-1;if(m&&m>=f&&(n.set(i,m),o.set(i,e().astSync(t.slice(i.length).trim()))),!s.preserve){const e=r.parent;r.remove(),removeEmptyAncestorBlocks(e)}}catch(e){r.warn(t,`Failed to parse selector : "${r.params}" with message: "${e instanceof Error?e.message:e}"`)}}),o}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(r.nodes&&r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function transformRule(r,t,s){let o=r.selector;try{o=e(r=>{r.walkPseudos(r=>{if(!s.has(r.value))return;const t=e.pseudo({value:":is",nodes:[]}),o=s.get(r.value);o&&(o.each(e=>{t.append(e.clone())}),r.replaceWith(t))})}).processSync(r.selector)}catch(e){return r.warn(t,`Failed to parse selector : "${o}" with message: "${e instanceof Error?e.message:e}"`),r.selector}return o}const creator=e=>{const r=e?.preserve??!1;if("importFrom"in Object(e))throw new Error('[postcss-custom-selectors] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-selectors] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-selectors",prepare(){const e=new WeakSet;let t=new Map;return{postcssPlugin:"postcss-custom-selectors",Once(e,{result:s}){t=getCustomSelectors(e,s,{preserve:r})},Rule(s,{result:o}){if(e.has(s))return;if(!s.selector?.includes(":--"))return;const n=transformRule(s,o,t);n!==s.selector&&(e.add(s),s.cloneBefore({selector:n}),r||s.remove())}}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-custom-selectors/dist/index.d.ts b/plugins/postcss-custom-selectors/dist/index.d.ts index d745e5f7a..4320abc6b 100644 --- a/plugins/postcss-custom-selectors/dist/index.d.ts +++ b/plugins/postcss-custom-selectors/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-custom-selectors plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-custom-selectors/dist/index.mjs b/plugins/postcss-custom-selectors/dist/index.mjs index d20c27dc4..69171cdfe 100644 --- a/plugins/postcss-custom-selectors/dist/index.mjs +++ b/plugins/postcss-custom-selectors/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";import{parse as r,addLayerToModel as t}from"@csstools/cascade-layer-name-parser";const s=r("csstools-implicit-layer")[0];function collectCascadeLayerOrder(e){const o=new Map,n=new Map,a=[];e.walkAtRules(e=>{if("layer"!==e.name.toLowerCase())return;{let r=e.parent;for(;r;){if("atrule"!==r.type||"layer"!==r.name.toLowerCase()){if(r===e.root())break;return}r=r.parent}}let c;if(e.nodes)c=normalizeLayerName(e.params,1);else{if(!e.params.trim())return;c=e.params}let l=r(c);if(l?.length){{let r=e.parent;for(;r&&"atrule"===r.type&&"layer"===r.name.toLowerCase();){const e=n.get(r);e?(l=l.map(r=>e.concat(r)),r=r.parent):r=r.parent}}if(t(a,l),e.nodes){const r=l[0].concat(s);o.set(e,r),n.set(e,l[0])}}});for(const e of o.values())t(a,[e]);const c=new WeakMap;for(const[e,r]of o)c.set(e,a.findIndex(e=>r.equal(e)));return c}function normalizeLayerName(e,r){return e.trim()?e:"csstools-anon-layer--"+r++}const o=new Set(["scope","container","layer"]);function isProcessableCustomSelectorRule(e){if("atrule"!==e.type)return!1;if("custom-selector"!==e.name.toLowerCase())return!1;if(!e.params||!e.params.includes(":--"))return!1;if(e.nodes&&e.nodes.length>0)return!1;let r=e.parent;for(;r;){if("rule"===r.type)return!1;if("atrule"===r.type&&!o.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}function getCustomSelectors(r,t,s){const o=new Map,n=new Map,a=collectCascadeLayerOrder(r);return r.walkAtRules(r=>{var c,l;if(isProcessableCustomSelectorRule(r))try{const t=r.params.trim(),p=e().astSync(t),u=p?.nodes?.[0]?.nodes?.[0];if(!u||"pseudo"!==u.type||!u.value.startsWith(":--"))return;const i=u.toString(),m=(l=a,(c=r).parent&&"atrule"===c.parent.type&&"layer"===c.parent.name.toLowerCase()?l.has(c.parent)?l.get(c.parent)+1:0:1e7),f=n.get(i)??-1;if(m&&m>=f&&(n.set(i,m),o.set(i,e().astSync(t.slice(i.length).trim()))),!s.preserve){const e=r.parent;r.remove(),removeEmptyAncestorBlocks(e)}}catch(e){r.warn(t,`Failed to parse selector : "${r.params}" with message: "${e instanceof Error?e.message:e}"`)}}),o}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(r.nodes&&r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function transformRule(r,t,s){let o=r.selector;try{o=e(r=>{r.walkPseudos(r=>{if(!s.has(r.value))return;const t=e.pseudo({value:":is",nodes:[]}),o=s.get(r.value);o&&(o.each(e=>{t.append(e.clone())}),r.replaceWith(t))})}).processSync(r.selector)}catch(e){return r.warn(t,`Failed to parse selector : "${o}" with message: "${e instanceof Error?e.message:e}"`),r.selector}return o}const creator=e=>{const r=e?.preserve??!1;if("importFrom"in Object(e))throw new Error('[postcss-custom-selectors] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-selectors] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-selectors",prepare(){const e=new WeakSet;let t=new Map;return{postcssPlugin:"postcss-custom-selectors",Once(e,{result:s}){t=getCustomSelectors(e,s,{preserve:r})},Rule(s,{result:o}){if(e.has(s))return;if(!s.selector?.includes(":--"))return;const n=transformRule(s,o,t);n!==s.selector&&(e.add(s),s.cloneBefore({selector:n}),r||s.remove())}}}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-selector-parser";import{parse as r,addLayerToModel as t}from"@csstools/cascade-layer-name-parser";const s=r("csstools-implicit-layer")[0];function collectCascadeLayerOrder(e){const o=new Map,n=new Map,a=[];e.walkAtRules(e=>{if("layer"!==e.name.toLowerCase())return;{let r=e.parent;for(;r;){if("atrule"!==r.type||"layer"!==r.name.toLowerCase()){if(r===e.root())break;return}r=r.parent}}let c;if(e.nodes)c=normalizeLayerName(e.params,1);else{if(!e.params.trim())return;c=e.params}let l=r(c);if(l?.length){{let r=e.parent;for(;r&&"atrule"===r.type&&"layer"===r.name.toLowerCase();){const e=n.get(r);e?(l=l.map(r=>e.concat(r)),r=r.parent):r=r.parent}}if(t(a,l),e.nodes){const r=l[0].concat(s);o.set(e,r),n.set(e,l[0])}}});for(const e of o.values())t(a,[e]);const c=new WeakMap;for(const[e,r]of o)c.set(e,a.findIndex(e=>r.equal(e)));return c}function normalizeLayerName(e,r){return e.trim()?e:"csstools-anon-layer--"+r++}const o=new Set(["scope","container","layer"]);function isProcessableCustomSelectorRule(e){if("atrule"!==e.type)return!1;if("custom-selector"!==e.name.toLowerCase())return!1;if(!e.params||!e.params.includes(":--"))return!1;if(e.nodes&&e.nodes.length>0)return!1;let r=e.parent;for(;r;){if("rule"===r.type)return!1;if("atrule"===r.type&&!o.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}function getCustomSelectors(r,t,s){const o=new Map,n=new Map,a=collectCascadeLayerOrder(r);return r.walkAtRules(r=>{var c,l;if(isProcessableCustomSelectorRule(r))try{const t=r.params.trim(),p=e().astSync(t),u=p?.nodes?.[0]?.nodes?.[0];if(!u||"pseudo"!==u.type||!u.value.startsWith(":--"))return;const i=u.toString(),m=(l=a,(c=r).parent&&"atrule"===c.parent.type&&"layer"===c.parent.name.toLowerCase()?l.has(c.parent)?l.get(c.parent)+1:0:1e7),f=n.get(i)??-1;if(m&&m>=f&&(n.set(i,m),o.set(i,e().astSync(t.slice(i.length).trim()))),!s.preserve){const e=r.parent;r.remove(),removeEmptyAncestorBlocks(e)}}catch(e){r.warn(t,`Failed to parse selector : "${r.params}" with message: "${e instanceof Error?e.message:e}"`)}}),o}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(r.nodes&&r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function transformRule(r,t,s){let o=r.selector;try{o=e(r=>{r.walkPseudos(r=>{if(!s.has(r.value))return;const t=e.pseudo({value:":is",nodes:[]}),o=s.get(r.value);o&&(o.each(e=>{t.append(e.clone())}),r.replaceWith(t))})}).processSync(r.selector)}catch(e){return r.warn(t,`Failed to parse selector : "${o}" with message: "${e instanceof Error?e.message:e}"`),r.selector}return o}const creator=e=>{const r=e?.preserve??!1;if("importFrom"in Object(e))throw new Error('[postcss-custom-selectors] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-selectors] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-selectors",prepare(){const e=new WeakSet;let t=new Map;return{postcssPlugin:"postcss-custom-selectors",Once(e,{result:s}){t=getCustomSelectors(e,s,{preserve:r})},Rule(s,{result:o}){if(e.has(s))return;if(!s.selector?.includes(":--"))return;const n=transformRule(s,o,t);n!==s.selector&&(e.add(s),s.cloneBefore({selector:n}),r||s.remove())}}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-custom-selectors/package.json b/plugins/postcss-custom-selectors/package.json index 736490cb7..e77a57394 100644 --- a/plugins/postcss-custom-selectors/package.json +++ b/plugins/postcss-custom-selectors/package.json @@ -35,20 +35,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-custom-selectors/src/index.ts b/plugins/postcss-custom-selectors/src/index.ts index b328bd11b..723eb4827 100644 --- a/plugins/postcss-custom-selectors/src/index.ts +++ b/plugins/postcss-custom-selectors/src/index.ts @@ -61,3 +61,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-debug-logger/CHANGELOG.md b/plugins/postcss-debug-logger/CHANGELOG.md index 6b1710d9f..50bdec3f0 100644 --- a/plugins/postcss-debug-logger/CHANGELOG.md +++ b/plugins/postcss-debug-logger/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Debug Logger +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.0.0 _August 3, 2024_ diff --git a/plugins/postcss-debug-logger/dist/index.cjs b/plugins/postcss-debug-logger/dist/index.cjs deleted file mode 100644 index 02ebd7126..000000000 --- a/plugins/postcss-debug-logger/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("node:path");const creator=()=>{const onceHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n nodes : ${t.nodes?.length}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},documentHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n nodes : ${t.nodes?.length}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},atRuleHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n name : ${t.name}`,r+=`\n params : ${t.params}`,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n nodes : ${t.nodes?.length}`,r+=`\n raw : ${JSON.stringify(t.raws)}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},ruleHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n selector : ${t.selector}`,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n nodes : ${t.nodes?.length}`,r+=`\n raw : ${JSON.stringify(t.raws)}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},commentHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n text : ${t.text}`,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n raw : ${JSON.stringify(t.raws)}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},declHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n prop : ${t.prop}`,r+=`\n value : ${t.value}`,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n raw : ${JSON.stringify(t.raws)}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")};return{postcssPlugin:"postcss-debug-logger",AtRule:atRuleHandler("AtRule"),AtRuleExit:atRuleHandler("AtRuleExit"),Comment:commentHandler("Comment"),CommentExit:commentHandler("CommentExit"),Declaration:declHandler("Declaration"),DeclarationExit:declHandler("DeclarationExit"),Document:documentHandler("Document"),DocumentExit:documentHandler("DocumentExit"),Once:onceHandler("Once"),OnceExit:onceHandler("OnceExit"),Root:onceHandler("Root"),RootExit:onceHandler("RootExit"),Rule:ruleHandler("Rule"),RuleExit:ruleHandler("RuleExit")}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-debug-logger/dist/index.d.ts b/plugins/postcss-debug-logger/dist/index.d.ts index 73f8cdb79..172fc5169 100644 --- a/plugins/postcss-debug-logger/dist/index.d.ts +++ b/plugins/postcss-debug-logger/dist/index.d.ts @@ -2,5 +2,6 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export { } diff --git a/plugins/postcss-debug-logger/dist/index.mjs b/plugins/postcss-debug-logger/dist/index.mjs index 9f92ecf6f..bacb628c8 100644 --- a/plugins/postcss-debug-logger/dist/index.mjs +++ b/plugins/postcss-debug-logger/dist/index.mjs @@ -1 +1 @@ -import e from"node:path";const creator=()=>{const onceHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n nodes : ${t.nodes?.length}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},documentHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n nodes : ${t.nodes?.length}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},atRuleHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n name : ${t.name}`,r+=`\n params : ${t.params}`,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n nodes : ${t.nodes?.length}`,r+=`\n raw : ${JSON.stringify(t.raws)}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},ruleHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n selector : ${t.selector}`,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n nodes : ${t.nodes?.length}`,r+=`\n raw : ${JSON.stringify(t.raws)}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},commentHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n text : ${t.text}`,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n raw : ${JSON.stringify(t.raws)}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},declHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n prop : ${t.prop}`,r+=`\n value : ${t.value}`,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n raw : ${JSON.stringify(t.raws)}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")};return{postcssPlugin:"postcss-debug-logger",AtRule:atRuleHandler("AtRule"),AtRuleExit:atRuleHandler("AtRuleExit"),Comment:commentHandler("Comment"),CommentExit:commentHandler("CommentExit"),Declaration:declHandler("Declaration"),DeclarationExit:declHandler("DeclarationExit"),Document:documentHandler("Document"),DocumentExit:documentHandler("DocumentExit"),Once:onceHandler("Once"),OnceExit:onceHandler("OnceExit"),Root:onceHandler("Root"),RootExit:onceHandler("RootExit"),Rule:ruleHandler("Rule"),RuleExit:ruleHandler("RuleExit")}};creator.postcss=!0;export{creator as default}; +import e from"node:path";const creator=()=>{const onceHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n nodes : ${t.nodes?.length}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},documentHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n nodes : ${t.nodes?.length}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},atRuleHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n name : ${t.name}`,r+=`\n params : ${t.params}`,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n nodes : ${t.nodes?.length}`,r+=`\n raw : ${JSON.stringify(t.raws)}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},ruleHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n selector : ${t.selector}`,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n nodes : ${t.nodes?.length}`,r+=`\n raw : ${JSON.stringify(t.raws)}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},commentHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n text : ${t.text}`,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n raw : ${JSON.stringify(t.raws)}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")},declHandler=n=>t=>{let o=t.source?.input?.from;o&&(o=e.relative(process.cwd(),o));let r="";r+=n,r+=`\n prop : ${t.prop}`,r+=`\n value : ${t.value}`,r+=`\n index : ${t.parent?.index(t)??"N/A"}`,r+=`\n raw : ${JSON.stringify(t.raws)}`,r+=`\n input.from : ${o??"N/A"}`,console.log(r+"\n")};return{postcssPlugin:"postcss-debug-logger",AtRule:atRuleHandler("AtRule"),AtRuleExit:atRuleHandler("AtRuleExit"),Comment:commentHandler("Comment"),CommentExit:commentHandler("CommentExit"),Declaration:declHandler("Declaration"),DeclarationExit:declHandler("DeclarationExit"),Document:documentHandler("Document"),DocumentExit:documentHandler("DocumentExit"),Once:onceHandler("Once"),OnceExit:onceHandler("OnceExit"),Root:onceHandler("Root"),RootExit:onceHandler("RootExit"),Rule:ruleHandler("Rule"),RuleExit:ruleHandler("RuleExit")}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-debug-logger/package.json b/plugins/postcss-debug-logger/package.json index 64aef46e7..aa4b881dc 100644 --- a/plugins/postcss-debug-logger/package.json +++ b/plugins/postcss-debug-logger/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-debug-logger/src/index.ts b/plugins/postcss-debug-logger/src/index.ts index 29e5afdbe..dda590403 100644 --- a/plugins/postcss-debug-logger/src/index.ts +++ b/plugins/postcss-debug-logger/src/index.ts @@ -146,3 +146,4 @@ const creator: PluginCreator = () => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-design-tokens/CHANGELOG.md b/plugins/postcss-design-tokens/CHANGELOG.md index ce8c416b1..3e0a49df0 100644 --- a/plugins/postcss-design-tokens/CHANGELOG.md +++ b/plugins/postcss-design-tokens/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Design Tokens +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.5 _May 27, 2025_ diff --git a/plugins/postcss-design-tokens/dist/index.cjs b/plugins/postcss-design-tokens/dist/index.cjs deleted file mode 100644 index c78f11654..000000000 --- a/plugins/postcss-design-tokens/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser"),t=require("node:path"),n=require("node:fs/promises"),r=require("node:module"),o=require("@csstools/css-parser-algorithms"),s=require("@csstools/css-tokenizer");function toposort(e,t){let n=e.length;const r=new Array(n),o={};let s=n;const a=makeOutgoingEdges(t),i=makeNodesHash(e);for(t.forEach(function(e){if(!i.has(e[0])||!i.has(e[1]))throw new Error("Unknown token. Make sure to provide all tokens used in aliases.")});s--;)o[s]||visit(e[s],s,new Set);return r;function visit(e,t,s){if(s.has(e)){let t;try{t=", token was: "+JSON.stringify(e)}catch{t=""}throw new Error("Cyclic dependency"+t)}if(!i.has(e))throw new Error("Found unknown token. Make sure to provided all involved tokens. Unknown token: "+JSON.stringify(e));if(o[t])return;o[t]=!0;const u=Array.from(a.get(e)||new Set);if(t=u.length){s.add(e);do{const e=u[--t];visit(e,i.get(e),s)}while(t);s.delete(e)}r[--n]=e}}function makeOutgoingEdges(e){const t=new Map;for(let n=0,r=e.length;napplyTransformsToValue(o,e),name:String(e.name??"")||t,comment:String(e.comment??"")||void 0,metadata:{name:String(e.name??"")?t:void 0,path:[...n,t],filePath:r,isSource:!0}}}const a=new Map;function applyTransformsToValue(t,n){if(!t)return"";if(!n)return t;if(!n.toUnit)return t;const r=e.unit(t);if(!r||r.unit===n.toUnit)return t;if(!r.unit){if(a.has(n.toUnit)){if(a.get(n.toUnit))return`${t}${n.toUnit}`;throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}try{const r=e.unit(`${t}${n.toUnit}`);if(r&&r.unit===n.toUnit)return a.set(n.toUnit,!0),`${t}${n.toUnit}`;a.set(n.toUnit,!1)}catch{a.set(n.toUnit,!1)}throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}return"rem"===r.unit&&"px"===n.toUnit?remToPx(parseFloat(r.number),n.pluginOptions?.rootFontSize??16):"px"===r.unit&&"rem"===n.toUnit?pxToRem(parseFloat(r.number),n.pluginOptions?.rootFontSize??16):t}function remToPx(e,t){return`${formatFloat(e*t)}px`}function pxToRem(e,t){return`${formatFloat(e/t)}rem`}function formatFloat(e){if(Number.isInteger(e))return e.toString();let t=e.toFixed(5);for(let e=t.length-1;e>=0&&"."!==t[e]&&"0"===t[e];e--)t=t.slice(0,e);return t}function dereferenceTokenValues(e){const t=new Set,n=new Map;for(const[r,o]of e.entries()){const e=parseReferences(o.value);e.length&&(t.add(r),n.set(r,e))}for(const[r,o]of n.entries()){for(let n=0;n"value-reference"===e.type))continue;const s=o.map(e=>e.value).join(""),a=e.get(r);a.value=s,a.cssValue=e=>applyTransformsToValue(s,e),e.set(r,a),t.delete(r),n.delete(r)}if(0===t.size)return e;{const r=Array.from(e.keys()),o=[];for(const[e,t]of n.entries())for(let n=0;n"value-reference"===e.type))throw new Error('Token "'+r+'" can not be fully resolved');const s=o.map(e=>e.value).join(""),a=e.get(r);a.value=s,a.cssValue=e=>applyTransformsToValue(s,e),e.set(r,a),t.delete(r),n.delete(r)}if(0===t.size)return e}return e}function parseReferences(e){if("string"!=typeof e)return[];if(-1===e.indexOf("{"))return[];const t=[];let n=!1,r=!1,o="";for(let s=0;s0&&(t.push({type:"value-non-reference",value:o}),o=""),r=!0;break;case"}":if(!r)throw new Error('Unexpected "}" in "'+e+'" at '+s);if(0===o.length)throw new Error('Empty alias "{}" in "'+e+'" at '+s);{let e=o.trim();".value"===e.slice(-6)&&(e=e.slice(0,-6)),t.push({type:"value-reference",raw:e}),o=""}n=!0,r=!1;break;default:o+=a}}if(r)throw new Error('Unexpected end of alias in "'+e+'"');return o.length>0&&t.push({type:"value-non-reference",value:o}),n?t:[]}function isTokenGroup(e){return"object"==typeof e&&null!==e&&void 0===e.value}function extractTokens(e,t,n){const r=new Map;for(const o in e)if(Object.hasOwnProperty.call(e,o)){if(null===e[o]||"object"!=typeof e[o]||Array.isArray(e[o]))throw new Error(`Parsing error at "${[...t,o].join(".")}"`);const s=e[o];if(!s)throw new Error(`Parsing error at "${[...t,o].join(".")}"`);if(!isTokenGroup(s)){const e=extractStyleDictionaryV3Token(s,o,t,n);r.set(e.metadata.path.join("."),e);continue}for(const[e,a]of extractTokens(s,[...t,o],n).entries())r.set(e,a)}return r}function extractStyleDictionaryV3Tokens(e,t){return dereferenceTokenValues(extractTokens(e,[],t))}function extractStyleDictionaryTokens(e,t,n){return extractStyleDictionaryV3Tokens(t,n)}const i="6b4e71e7-4787-42f7-a092-8684961895db";function parseImport(t){const n=e(t),r={filePath:"",format:"standard",conditions:[i]};return n.walk(e=>{"function"===e.type&&"url"===e.value&&(r.filePath=e.nodes[0].value),"function"===e.type&&"format"===e.value&&(r.format=e.nodes[0].value),"function"===e.type&&"when"===e.value&&(r.conditions=e.nodes.filter(e=>"string"===e.type).map(e=>e.value))}),r.conditions.length||(r.conditions=[i]),r}async function tokensFromImport(e,o,s,a,i,u){const{filePath:l,format:c,conditions:f}=parseImport(i);if(!f.every(e=>s.includes(e)))return!1;let p="";try{if(l.startsWith("node_modules://")){p=r.createRequire(t.dirname(a)).resolve(l.slice(15))}else if(l.startsWith("node_modules:")){p=r.createRequire(t.dirname(a)).resolve(l.slice(13))}else p=t.resolve(t.dirname(a),l)}catch(e){throw new Error(`Failed to read ${l} with error ${e instanceof Error?e.message:e}`)}if(u.has(p))return!1;o.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:p,parent:e.source?.input?.file}),u.add(p);const d=await n.readFile(p,"utf8"),m=JSON.parse(d);if("style-dictionary3"===c)return{filePath:t.resolve(l),tokens:extractStyleDictionaryTokens(0,m,p)};throw new Error("Unsupported format: "+c)}function mergeTokens(e,t){const n=new Map(e);for(const[e,r]of t)n.set(e,r);return n}function parsePluginOptions(e){const t={importAtRuleName:"design-tokens",is:[i],unitsAndValues:{rootFontSize:16},valueFunctionName:"design-token"};return e?("object"!=typeof e||(Array.isArray(e.is)&&(t.is=e.is.filter(e=>"string"==typeof e)),0===t.is.length&&(t.is=[i]),"object"==typeof e.unitsAndValues&&"number"==typeof e.unitsAndValues.rootFontSize&&((n=e.unitsAndValues.rootFontSize)>0&&n!==1/0)&&(t.unitsAndValues.rootFontSize=e.unitsAndValues.rootFontSize),"string"==typeof e.valueFunctionName&&(t.valueFunctionName=e.valueFunctionName),"string"==typeof e.importAtRuleName&&(t.importAtRuleName=e.importAtRuleName)),t):t;var n}function parseComponentValues(e){return t=s.tokenize({css:e},{onParseError:e=>{throw e}}),o.parseListOfComponentValues(t,{onParseError:e=>{throw e}});var t}function transform(e,t,n,r,o){const s=parseComponentValues(r);let a=!1;return s.forEach((r,i)=>{if("walk"in r){{const u=transformComponentValue(r,e,t,n,o);if(u)return s.splice(i,1,...u),a=!0,!1}r.walk((r,s)=>{if("string"==typeof s)return;const i=transformComponentValue(r.node,e,t,n,o);return i?(r.parent.value.splice(s,1,...i),a=!0,!1):void 0})}}),a?s.map(e=>e.toString()).join(""):r}function transformComponentValue(e,t,n,r,a){if(!o.isFunctionNode(e))return;if(e.getName().toLowerCase()!==a.valueFunctionName)return;let i="",u="",l="";for(let t=0;t{const t=parsePluginOptions(e);return{postcssPlugin:"postcss-design-tokens",prepare(){let e=new Map,n=new Set;return{postcssPlugin:"postcss-design-tokens",OnceExit(){e=new Map,n=new Set},async Once(r,o){const s=[];r.walkAtRules(e=>{if(e.name.toLowerCase()!==t.importAtRuleName)return;if(!e?.source?.input?.file)return;const n=e.source.input.file,r=e.params;e.remove(),s.push({filePath:n,params:r,node:e})});for(const a of s.values()){let s;try{if(s=await tokensFromImport(r,o,t.is,a.filePath,a.params,n),!s)continue}catch(e){a.node.warn(o.result,`Failed to import design tokens from "${a.params}" with error:\n\t`+(e instanceof Error?e.message:e));continue}o.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:s.filePath,parent:a.filePath}),e=mergeTokens(e,s.tokens)}},Declaration(n,{result:r}){if(n.value.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.value,t);if(o===n.value)return;n.value=o}catch{n.warn(r,`Failed to parse and transform "${n.value}"`)}},AtRule(n,{result:r}){if(n.params.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.params,t);if(o===n.params)return;n.params=o}catch{n.warn(r,`Failed to parse and transform "${n.params}"`)}}}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-design-tokens/dist/index.d.ts b/plugins/postcss-design-tokens/dist/index.d.ts index 4042d30de..bb9f18061 100644 --- a/plugins/postcss-design-tokens/dist/index.d.ts +++ b/plugins/postcss-design-tokens/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export declare type pluginOptions = { importAtRuleName: string; diff --git a/plugins/postcss-design-tokens/dist/index.mjs b/plugins/postcss-design-tokens/dist/index.mjs index ae56260dc..9b9994fc5 100644 --- a/plugins/postcss-design-tokens/dist/index.mjs +++ b/plugins/postcss-design-tokens/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";import t from"node:path";import n from"node:fs/promises";import r from"node:module";import{parseListOfComponentValues as o,isFunctionNode as s,isWhitespaceNode as a,isCommentNode as i,isTokenNode as u}from"@csstools/css-parser-algorithms";import{tokenize as l,isTokenString as c,isTokenIdent as f}from"@csstools/css-tokenizer";function toposort(e,t){let n=e.length;const r=new Array(n),o={};let s=n;const a=makeOutgoingEdges(t),i=makeNodesHash(e);for(t.forEach(function(e){if(!i.has(e[0])||!i.has(e[1]))throw new Error("Unknown token. Make sure to provide all tokens used in aliases.")});s--;)o[s]||visit(e[s],s,new Set);return r;function visit(e,t,s){if(s.has(e)){let t;try{t=", token was: "+JSON.stringify(e)}catch{t=""}throw new Error("Cyclic dependency"+t)}if(!i.has(e))throw new Error("Found unknown token. Make sure to provided all involved tokens. Unknown token: "+JSON.stringify(e));if(o[t])return;o[t]=!0;const u=Array.from(a.get(e)||new Set);if(t=u.length){s.add(e);do{const e=u[--t];visit(e,i.get(e),s)}while(t);s.delete(e)}r[--n]=e}}function makeOutgoingEdges(e){const t=new Map;for(let n=0,r=e.length;napplyTransformsToValue(o,e),name:String(e.name??"")||t,comment:String(e.comment??"")||void 0,metadata:{name:String(e.name??"")?t:void 0,path:[...n,t],filePath:r,isSource:!0}}}const p=new Map;function applyTransformsToValue(t,n){if(!t)return"";if(!n)return t;if(!n.toUnit)return t;const r=e.unit(t);if(!r||r.unit===n.toUnit)return t;if(!r.unit){if(p.has(n.toUnit)){if(p.get(n.toUnit))return`${t}${n.toUnit}`;throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}try{const r=e.unit(`${t}${n.toUnit}`);if(r&&r.unit===n.toUnit)return p.set(n.toUnit,!0),`${t}${n.toUnit}`;p.set(n.toUnit,!1)}catch{p.set(n.toUnit,!1)}throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}return"rem"===r.unit&&"px"===n.toUnit?remToPx(parseFloat(r.number),n.pluginOptions?.rootFontSize??16):"px"===r.unit&&"rem"===n.toUnit?pxToRem(parseFloat(r.number),n.pluginOptions?.rootFontSize??16):t}function remToPx(e,t){return`${formatFloat(e*t)}px`}function pxToRem(e,t){return`${formatFloat(e/t)}rem`}function formatFloat(e){if(Number.isInteger(e))return e.toString();let t=e.toFixed(5);for(let e=t.length-1;e>=0&&"."!==t[e]&&"0"===t[e];e--)t=t.slice(0,e);return t}function dereferenceTokenValues(e){const t=new Set,n=new Map;for(const[r,o]of e.entries()){const e=parseReferences(o.value);e.length&&(t.add(r),n.set(r,e))}for(const[r,o]of n.entries()){for(let n=0;n"value-reference"===e.type))continue;const s=o.map(e=>e.value).join(""),a=e.get(r);a.value=s,a.cssValue=e=>applyTransformsToValue(s,e),e.set(r,a),t.delete(r),n.delete(r)}if(0===t.size)return e;{const r=Array.from(e.keys()),o=[];for(const[e,t]of n.entries())for(let n=0;n"value-reference"===e.type))throw new Error('Token "'+r+'" can not be fully resolved');const s=o.map(e=>e.value).join(""),a=e.get(r);a.value=s,a.cssValue=e=>applyTransformsToValue(s,e),e.set(r,a),t.delete(r),n.delete(r)}if(0===t.size)return e}return e}function parseReferences(e){if("string"!=typeof e)return[];if(-1===e.indexOf("{"))return[];const t=[];let n=!1,r=!1,o="";for(let s=0;s0&&(t.push({type:"value-non-reference",value:o}),o=""),r=!0;break;case"}":if(!r)throw new Error('Unexpected "}" in "'+e+'" at '+s);if(0===o.length)throw new Error('Empty alias "{}" in "'+e+'" at '+s);{let e=o.trim();".value"===e.slice(-6)&&(e=e.slice(0,-6)),t.push({type:"value-reference",raw:e}),o=""}n=!0,r=!1;break;default:o+=a}}if(r)throw new Error('Unexpected end of alias in "'+e+'"');return o.length>0&&t.push({type:"value-non-reference",value:o}),n?t:[]}function isTokenGroup(e){return"object"==typeof e&&null!==e&&void 0===e.value}function extractTokens(e,t,n){const r=new Map;for(const o in e)if(Object.hasOwnProperty.call(e,o)){if(null===e[o]||"object"!=typeof e[o]||Array.isArray(e[o]))throw new Error(`Parsing error at "${[...t,o].join(".")}"`);const s=e[o];if(!s)throw new Error(`Parsing error at "${[...t,o].join(".")}"`);if(!isTokenGroup(s)){const e=extractStyleDictionaryV3Token(s,o,t,n);r.set(e.metadata.path.join("."),e);continue}for(const[e,a]of extractTokens(s,[...t,o],n).entries())r.set(e,a)}return r}function extractStyleDictionaryV3Tokens(e,t){return dereferenceTokenValues(extractTokens(e,[],t))}function extractStyleDictionaryTokens(e,t,n){return extractStyleDictionaryV3Tokens(t,n)}const m="6b4e71e7-4787-42f7-a092-8684961895db";function parseImport(t){const n=e(t),r={filePath:"",format:"standard",conditions:[m]};return n.walk(e=>{"function"===e.type&&"url"===e.value&&(r.filePath=e.nodes[0].value),"function"===e.type&&"format"===e.value&&(r.format=e.nodes[0].value),"function"===e.type&&"when"===e.value&&(r.conditions=e.nodes.filter(e=>"string"===e.type).map(e=>e.value))}),r.conditions.length||(r.conditions=[m]),r}async function tokensFromImport(e,o,s,a,i,u){const{filePath:l,format:c,conditions:f}=parseImport(i);if(!f.every(e=>s.includes(e)))return!1;let p="";try{if(l.startsWith("node_modules://")){p=r.createRequire(t.dirname(a)).resolve(l.slice(15))}else if(l.startsWith("node_modules:")){p=r.createRequire(t.dirname(a)).resolve(l.slice(13))}else p=t.resolve(t.dirname(a),l)}catch(e){throw new Error(`Failed to read ${l} with error ${e instanceof Error?e.message:e}`)}if(u.has(p))return!1;o.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:p,parent:e.source?.input?.file}),u.add(p);const m=await n.readFile(p,"utf8"),d=JSON.parse(m);if("style-dictionary3"===c)return{filePath:t.resolve(l),tokens:extractStyleDictionaryTokens(0,d,p)};throw new Error("Unsupported format: "+c)}function mergeTokens(e,t){const n=new Map(e);for(const[e,r]of t)n.set(e,r);return n}function parsePluginOptions(e){const t={importAtRuleName:"design-tokens",is:[m],unitsAndValues:{rootFontSize:16},valueFunctionName:"design-token"};return e?("object"!=typeof e||(Array.isArray(e.is)&&(t.is=e.is.filter(e=>"string"==typeof e)),0===t.is.length&&(t.is=[m]),"object"==typeof e.unitsAndValues&&"number"==typeof e.unitsAndValues.rootFontSize&&((n=e.unitsAndValues.rootFontSize)>0&&n!==1/0)&&(t.unitsAndValues.rootFontSize=e.unitsAndValues.rootFontSize),"string"==typeof e.valueFunctionName&&(t.valueFunctionName=e.valueFunctionName),"string"==typeof e.importAtRuleName&&(t.importAtRuleName=e.importAtRuleName)),t):t;var n}function parseComponentValues(e){return t=l({css:e},{onParseError:e=>{throw e}}),o(t,{onParseError:e=>{throw e}});var t}function transform(e,t,n,r,o){const s=parseComponentValues(r);let a=!1;return s.forEach((r,i)=>{if("walk"in r){{const u=transformComponentValue(r,e,t,n,o);if(u)return s.splice(i,1,...u),a=!0,!1}r.walk((r,s)=>{if("string"==typeof s)return;const i=transformComponentValue(r.node,e,t,n,o);return i?(r.parent.value.splice(s,1,...i),a=!0,!1):void 0})}}),a?s.map(e=>e.toString()).join(""):r}function transformComponentValue(e,t,n,r,o){if(!s(e))return;if(e.getName().toLowerCase()!==o.valueFunctionName)return;let l="",p="",m="";for(let t=0;t{const t=parsePluginOptions(e);return{postcssPlugin:"postcss-design-tokens",prepare(){let e=new Map,n=new Set;return{postcssPlugin:"postcss-design-tokens",OnceExit(){e=new Map,n=new Set},async Once(r,o){const s=[];r.walkAtRules(e=>{if(e.name.toLowerCase()!==t.importAtRuleName)return;if(!e?.source?.input?.file)return;const n=e.source.input.file,r=e.params;e.remove(),s.push({filePath:n,params:r,node:e})});for(const a of s.values()){let s;try{if(s=await tokensFromImport(r,o,t.is,a.filePath,a.params,n),!s)continue}catch(e){a.node.warn(o.result,`Failed to import design tokens from "${a.params}" with error:\n\t`+(e instanceof Error?e.message:e));continue}o.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:s.filePath,parent:a.filePath}),e=mergeTokens(e,s.tokens)}},Declaration(n,{result:r}){if(n.value.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.value,t);if(o===n.value)return;n.value=o}catch{n.warn(r,`Failed to parse and transform "${n.value}"`)}},AtRule(n,{result:r}){if(n.params.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.params,t);if(o===n.params)return;n.params=o}catch{n.warn(r,`Failed to parse and transform "${n.params}"`)}}}}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-value-parser";import t from"node:path";import n from"node:fs/promises";import r from"node:module";import{parseListOfComponentValues as o,isFunctionNode as s,isWhitespaceNode as a,isCommentNode as i,isTokenNode as u}from"@csstools/css-parser-algorithms";import{tokenize as l,isTokenString as c,isTokenIdent as f}from"@csstools/css-tokenizer";function toposort(e,t){let n=e.length;const r=new Array(n),o={};let s=n;const a=makeOutgoingEdges(t),i=makeNodesHash(e);for(t.forEach(function(e){if(!i.has(e[0])||!i.has(e[1]))throw new Error("Unknown token. Make sure to provide all tokens used in aliases.")});s--;)o[s]||visit(e[s],s,new Set);return r;function visit(e,t,s){if(s.has(e)){let t;try{t=", token was: "+JSON.stringify(e)}catch{t=""}throw new Error("Cyclic dependency"+t)}if(!i.has(e))throw new Error("Found unknown token. Make sure to provided all involved tokens. Unknown token: "+JSON.stringify(e));if(o[t])return;o[t]=!0;const u=Array.from(a.get(e)||new Set);if(t=u.length){s.add(e);do{const e=u[--t];visit(e,i.get(e),s)}while(t);s.delete(e)}r[--n]=e}}function makeOutgoingEdges(e){const t=new Map;for(let n=0,r=e.length;napplyTransformsToValue(o,e),name:String(e.name??"")||t,comment:String(e.comment??"")||void 0,metadata:{name:String(e.name??"")?t:void 0,path:[...n,t],filePath:r,isSource:!0}}}const p=new Map;function applyTransformsToValue(t,n){if(!t)return"";if(!n)return t;if(!n.toUnit)return t;const r=e.unit(t);if(!r||r.unit===n.toUnit)return t;if(!r.unit){if(p.has(n.toUnit)){if(p.get(n.toUnit))return`${t}${n.toUnit}`;throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}try{const r=e.unit(`${t}${n.toUnit}`);if(r&&r.unit===n.toUnit)return p.set(n.toUnit,!0),`${t}${n.toUnit}`;p.set(n.toUnit,!1)}catch{p.set(n.toUnit,!1)}throw new Error(`Invalid unit "${n.toUnit}" for "${t}"`)}return"rem"===r.unit&&"px"===n.toUnit?remToPx(parseFloat(r.number),n.pluginOptions?.rootFontSize??16):"px"===r.unit&&"rem"===n.toUnit?pxToRem(parseFloat(r.number),n.pluginOptions?.rootFontSize??16):t}function remToPx(e,t){return`${formatFloat(e*t)}px`}function pxToRem(e,t){return`${formatFloat(e/t)}rem`}function formatFloat(e){if(Number.isInteger(e))return e.toString();let t=e.toFixed(5);for(let e=t.length-1;e>=0&&"."!==t[e]&&"0"===t[e];e--)t=t.slice(0,e);return t}function dereferenceTokenValues(e){const t=new Set,n=new Map;for(const[r,o]of e.entries()){const e=parseReferences(o.value);e.length&&(t.add(r),n.set(r,e))}for(const[r,o]of n.entries()){for(let n=0;n"value-reference"===e.type))continue;const s=o.map(e=>e.value).join(""),a=e.get(r);a.value=s,a.cssValue=e=>applyTransformsToValue(s,e),e.set(r,a),t.delete(r),n.delete(r)}if(0===t.size)return e;{const r=Array.from(e.keys()),o=[];for(const[e,t]of n.entries())for(let n=0;n"value-reference"===e.type))throw new Error('Token "'+r+'" can not be fully resolved');const s=o.map(e=>e.value).join(""),a=e.get(r);a.value=s,a.cssValue=e=>applyTransformsToValue(s,e),e.set(r,a),t.delete(r),n.delete(r)}if(0===t.size)return e}return e}function parseReferences(e){if("string"!=typeof e)return[];if(-1===e.indexOf("{"))return[];const t=[];let n=!1,r=!1,o="";for(let s=0;s0&&(t.push({type:"value-non-reference",value:o}),o=""),r=!0;break;case"}":if(!r)throw new Error('Unexpected "}" in "'+e+'" at '+s);if(0===o.length)throw new Error('Empty alias "{}" in "'+e+'" at '+s);{let e=o.trim();".value"===e.slice(-6)&&(e=e.slice(0,-6)),t.push({type:"value-reference",raw:e}),o=""}n=!0,r=!1;break;default:o+=a}}if(r)throw new Error('Unexpected end of alias in "'+e+'"');return o.length>0&&t.push({type:"value-non-reference",value:o}),n?t:[]}function isTokenGroup(e){return"object"==typeof e&&null!==e&&void 0===e.value}function extractTokens(e,t,n){const r=new Map;for(const o in e)if(Object.hasOwnProperty.call(e,o)){if(null===e[o]||"object"!=typeof e[o]||Array.isArray(e[o]))throw new Error(`Parsing error at "${[...t,o].join(".")}"`);const s=e[o];if(!s)throw new Error(`Parsing error at "${[...t,o].join(".")}"`);if(!isTokenGroup(s)){const e=extractStyleDictionaryV3Token(s,o,t,n);r.set(e.metadata.path.join("."),e);continue}for(const[e,a]of extractTokens(s,[...t,o],n).entries())r.set(e,a)}return r}function extractStyleDictionaryV3Tokens(e,t){return dereferenceTokenValues(extractTokens(e,[],t))}function extractStyleDictionaryTokens(e,t,n){return extractStyleDictionaryV3Tokens(t,n)}const m="6b4e71e7-4787-42f7-a092-8684961895db";function parseImport(t){const n=e(t),r={filePath:"",format:"standard",conditions:[m]};return n.walk(e=>{"function"===e.type&&"url"===e.value&&(r.filePath=e.nodes[0].value),"function"===e.type&&"format"===e.value&&(r.format=e.nodes[0].value),"function"===e.type&&"when"===e.value&&(r.conditions=e.nodes.filter(e=>"string"===e.type).map(e=>e.value))}),r.conditions.length||(r.conditions=[m]),r}async function tokensFromImport(e,o,s,a,i,u){const{filePath:l,format:c,conditions:f}=parseImport(i);if(!f.every(e=>s.includes(e)))return!1;let p="";try{if(l.startsWith("node_modules://")){p=r.createRequire(t.dirname(a)).resolve(l.slice(15))}else if(l.startsWith("node_modules:")){p=r.createRequire(t.dirname(a)).resolve(l.slice(13))}else p=t.resolve(t.dirname(a),l)}catch(e){throw new Error(`Failed to read ${l} with error ${e instanceof Error?e.message:e}`)}if(u.has(p))return!1;o.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:p,parent:e.source?.input?.file}),u.add(p);const m=await n.readFile(p,"utf8"),d=JSON.parse(m);if("style-dictionary3"===c)return{filePath:t.resolve(l),tokens:extractStyleDictionaryTokens(0,d,p)};throw new Error("Unsupported format: "+c)}function mergeTokens(e,t){const n=new Map(e);for(const[e,r]of t)n.set(e,r);return n}function parsePluginOptions(e){const t={importAtRuleName:"design-tokens",is:[m],unitsAndValues:{rootFontSize:16},valueFunctionName:"design-token"};return e?("object"!=typeof e||(Array.isArray(e.is)&&(t.is=e.is.filter(e=>"string"==typeof e)),0===t.is.length&&(t.is=[m]),"object"==typeof e.unitsAndValues&&"number"==typeof e.unitsAndValues.rootFontSize&&((n=e.unitsAndValues.rootFontSize)>0&&n!==1/0)&&(t.unitsAndValues.rootFontSize=e.unitsAndValues.rootFontSize),"string"==typeof e.valueFunctionName&&(t.valueFunctionName=e.valueFunctionName),"string"==typeof e.importAtRuleName&&(t.importAtRuleName=e.importAtRuleName)),t):t;var n}function parseComponentValues(e){return t=l({css:e},{onParseError:e=>{throw e}}),o(t,{onParseError:e=>{throw e}});var t}function transform(e,t,n,r,o){const s=parseComponentValues(r);let a=!1;return s.forEach((r,i)=>{if("walk"in r){{const u=transformComponentValue(r,e,t,n,o);if(u)return s.splice(i,1,...u),a=!0,!1}r.walk((r,s)=>{if("string"==typeof s)return;const i=transformComponentValue(r.node,e,t,n,o);return i?(r.parent.value.splice(s,1,...i),a=!0,!1):void 0})}}),a?s.map(e=>e.toString()).join(""):r}function transformComponentValue(e,t,n,r,o){if(!s(e))return;if(e.getName().toLowerCase()!==o.valueFunctionName)return;let l="",p="",m="";for(let t=0;t{const t=parsePluginOptions(e);return{postcssPlugin:"postcss-design-tokens",prepare(){let e=new Map,n=new Set;return{postcssPlugin:"postcss-design-tokens",OnceExit(){e=new Map,n=new Set},async Once(r,o){const s=[];r.walkAtRules(e=>{if(e.name.toLowerCase()!==t.importAtRuleName)return;if(!e?.source?.input?.file)return;const n=e.source.input.file,r=e.params;e.remove(),s.push({filePath:n,params:r,node:e})});for(const a of s.values()){let s;try{if(s=await tokensFromImport(r,o,t.is,a.filePath,a.params,n),!s)continue}catch(e){a.node.warn(o.result,`Failed to import design tokens from "${a.params}" with error:\n\t`+(e instanceof Error?e.message:e));continue}o.result.messages.push({type:"dependency",plugin:"postcss-design-tokens",file:s.filePath,parent:a.filePath}),e=mergeTokens(e,s.tokens)}},Declaration(n,{result:r}){if(n.value.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.value,t);if(o===n.value)return;n.value=o}catch{n.warn(r,`Failed to parse and transform "${n.value}"`)}},AtRule(n,{result:r}){if(n.params.toLowerCase().includes(t.valueFunctionName))try{const o=transform(e,r,n,n.params,t);if(o===n.params)return;n.params=o}catch{n.warn(r,`Failed to parse and transform "${n.params}"`)}}}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-design-tokens/package.json b/plugins/postcss-design-tokens/package.json index c86d03fab..81f84ec57 100644 --- a/plugins/postcss-design-tokens/package.json +++ b/plugins/postcss-design-tokens/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-design-tokens/src/index.ts b/plugins/postcss-design-tokens/src/index.ts index b2feed89c..e1217e1d4 100644 --- a/plugins/postcss-design-tokens/src/index.ts +++ b/plugins/postcss-design-tokens/src/index.ts @@ -106,4 +106,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-dir-pseudo-class/CHANGELOG.md b/plugins/postcss-dir-pseudo-class/CHANGELOG.md index 4dab12110..44abe9a6e 100644 --- a/plugins/postcss-dir-pseudo-class/CHANGELOG.md +++ b/plugins/postcss-dir-pseudo-class/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Dir Pseudo Class +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 9.0.1 _October 23, 2024_ diff --git a/plugins/postcss-dir-pseudo-class/dist/index.cjs b/plugins/postcss-dir-pseudo-class/dist/index.cjs deleted file mode 100644 index 13c288a2f..000000000 --- a/plugins/postcss-dir-pseudo-class/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser");const creator=t=>{const r=Object.assign({dir:null,preserve:!1,shadow:!1},t);return{postcssPlugin:"postcss-dir-pseudo-class",prepare(){const t=new WeakSet;return{postcssPlugin:"postcss-dir-pseudo-class",Rule(o,{result:s}){if(t.has(o))return;let a,n=!1;if(o.selector.toLowerCase().includes(":dir(")){try{a=e(t=>{t.nodes.forEach(t=>{t.walk(t=>{if("pseudo"!==t.type)return;if(":dir"!==t.value.toLowerCase())return;if(!t.nodes||!t.nodes.length)return;const a=t.nodes.toString().toLowerCase();if("rtl"!==a&&"ltr"!==a)return;const l=t.parent;if(!l)return;l.nodes.filter(e=>"pseudo"===e.type&&":dir"===e.value.toLowerCase()).length>1&&!n&&(n=!0,o.warn(s,`Hierarchical :dir pseudo class usage can't be transformed correctly to [dir] attributes. This will lead to incorrect selectors for "${o.selector}"`));const c=t.prev(),p=t.next(),i=c&&c.type&&"combinator"!==c.type,u=p&&p.type&&"combinator"!==p.type,d=p&&p.type&&("combinator"!==p.type||"combinator"===p.type&&" "===p.value);i||u||0===l.nodes.indexOf(t)&&d||1===l.nodes.length?t.remove():t.replaceWith(e.universal());const v=l.nodes[0],f=v&&"combinator"===v.type&&" "===v.value,w=v&&"tag"===v.type&&"html"===v.value.toLowerCase(),y=v&&"pseudo"===v.type&&":root"===v.value.toLowerCase();!v||w||y||f||l.prepend(e.combinator({value:" "}));const h=r.dir===a,b=e.attribute({attribute:"dir",operator:"=",quoteMark:'"',value:`"${a}"`,raws:{}}),m=e.pseudo({value:":host-context"});m.append(e.selector({value:"",nodes:[b]}));const g=e.pseudo({value:(w||y?"":"html")+":not"});g.append(e.selector({value:"",nodes:[e.attribute({attribute:"dir",operator:"=",quoteMark:'"',value:`"${"ltr"===a?"rtl":"ltr"}"`,raws:{}})]})),h?w?l.insertAfter(v,g):l.prepend(g):w?l.insertAfter(v,b):r.shadow&&!y?l.prepend(m):l.prepend(b)})})}).processSync(o.selector)}catch{return void o.warn(s,`Failed to parse selector : ${o.selector}`)}void 0!==a&&a!==o.selector&&(t.add(o),o.cloneBefore({selector:a}),r.preserve||o.remove())}}}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-dir-pseudo-class/dist/index.d.ts b/plugins/postcss-dir-pseudo-class/dist/index.d.ts index bcfe2c60d..3bdd347f2 100644 --- a/plugins/postcss-dir-pseudo-class/dist/index.d.ts +++ b/plugins/postcss-dir-pseudo-class/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-dir-pseudo-class plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-dir-pseudo-class/dist/index.mjs b/plugins/postcss-dir-pseudo-class/dist/index.mjs index a65381bbc..de54616f1 100644 --- a/plugins/postcss-dir-pseudo-class/dist/index.mjs +++ b/plugins/postcss-dir-pseudo-class/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";const creator=t=>{const r=Object.assign({dir:null,preserve:!1,shadow:!1},t);return{postcssPlugin:"postcss-dir-pseudo-class",prepare(){const t=new WeakSet;return{postcssPlugin:"postcss-dir-pseudo-class",Rule(o,{result:s}){if(t.has(o))return;let a,n=!1;if(o.selector.toLowerCase().includes(":dir(")){try{a=e(t=>{t.nodes.forEach(t=>{t.walk(t=>{if("pseudo"!==t.type)return;if(":dir"!==t.value.toLowerCase())return;if(!t.nodes||!t.nodes.length)return;const a=t.nodes.toString().toLowerCase();if("rtl"!==a&&"ltr"!==a)return;const l=t.parent;if(!l)return;l.nodes.filter(e=>"pseudo"===e.type&&":dir"===e.value.toLowerCase()).length>1&&!n&&(n=!0,o.warn(s,`Hierarchical :dir pseudo class usage can't be transformed correctly to [dir] attributes. This will lead to incorrect selectors for "${o.selector}"`));const c=t.prev(),p=t.next(),i=c&&c.type&&"combinator"!==c.type,d=p&&p.type&&"combinator"!==p.type,u=p&&p.type&&("combinator"!==p.type||"combinator"===p.type&&" "===p.value);i||d||0===l.nodes.indexOf(t)&&u||1===l.nodes.length?t.remove():t.replaceWith(e.universal());const v=l.nodes[0],f=v&&"combinator"===v.type&&" "===v.value,w=v&&"tag"===v.type&&"html"===v.value.toLowerCase(),y=v&&"pseudo"===v.type&&":root"===v.value.toLowerCase();!v||w||y||f||l.prepend(e.combinator({value:" "}));const h=r.dir===a,b=e.attribute({attribute:"dir",operator:"=",quoteMark:'"',value:`"${a}"`,raws:{}}),m=e.pseudo({value:":host-context"});m.append(e.selector({value:"",nodes:[b]}));const g=e.pseudo({value:(w||y?"":"html")+":not"});g.append(e.selector({value:"",nodes:[e.attribute({attribute:"dir",operator:"=",quoteMark:'"',value:`"${"ltr"===a?"rtl":"ltr"}"`,raws:{}})]})),h?w?l.insertAfter(v,g):l.prepend(g):w?l.insertAfter(v,b):r.shadow&&!y?l.prepend(m):l.prepend(b)})})}).processSync(o.selector)}catch{return void o.warn(s,`Failed to parse selector : ${o.selector}`)}void 0!==a&&a!==o.selector&&(t.add(o),o.cloneBefore({selector:a}),r.preserve||o.remove())}}}}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-selector-parser";const creator=t=>{const r=Object.assign({dir:null,preserve:!1,shadow:!1},t);return{postcssPlugin:"postcss-dir-pseudo-class",prepare(){const t=new WeakSet;return{postcssPlugin:"postcss-dir-pseudo-class",Rule(o,{result:s}){if(t.has(o))return;let a,n=!1;if(o.selector.toLowerCase().includes(":dir(")){try{a=e(t=>{t.nodes.forEach(t=>{t.walk(t=>{if("pseudo"!==t.type)return;if(":dir"!==t.value.toLowerCase())return;if(!t.nodes||!t.nodes.length)return;const a=t.nodes.toString().toLowerCase();if("rtl"!==a&&"ltr"!==a)return;const l=t.parent;if(!l)return;l.nodes.filter(e=>"pseudo"===e.type&&":dir"===e.value.toLowerCase()).length>1&&!n&&(n=!0,o.warn(s,`Hierarchical :dir pseudo class usage can't be transformed correctly to [dir] attributes. This will lead to incorrect selectors for "${o.selector}"`));const p=t.prev(),c=t.next(),i=p&&p.type&&"combinator"!==p.type,d=c&&c.type&&"combinator"!==c.type,u=c&&c.type&&("combinator"!==c.type||"combinator"===c.type&&" "===c.value);i||d||0===l.nodes.indexOf(t)&&u||1===l.nodes.length?t.remove():t.replaceWith(e.universal());const v=l.nodes[0],f=v&&"combinator"===v.type&&" "===v.value,w=v&&"tag"===v.type&&"html"===v.value.toLowerCase(),y=v&&"pseudo"===v.type&&":root"===v.value.toLowerCase();!v||w||y||f||l.prepend(e.combinator({value:" "}));const h=r.dir===a,m=e.attribute({attribute:"dir",operator:"=",quoteMark:'"',value:`"${a}"`,raws:{}}),b=e.pseudo({value:":host-context"});b.append(e.selector({value:"",nodes:[m]}));const g=e.pseudo({value:(w||y?"":"html")+":not"});g.append(e.selector({value:"",nodes:[e.attribute({attribute:"dir",operator:"=",quoteMark:'"',value:`"${"ltr"===a?"rtl":"ltr"}"`,raws:{}})]})),h?w?l.insertAfter(v,g):l.prepend(g):w?l.insertAfter(v,m):r.shadow&&!y?l.prepend(b):l.prepend(m)})})}).processSync(o.selector)}catch{return void o.warn(s,`Failed to parse selector : ${o.selector}`)}void 0!==a&&a!==o.selector&&(t.add(o),o.cloneBefore({selector:a}),r.preserve||o.remove())}}}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-dir-pseudo-class/package.json b/plugins/postcss-dir-pseudo-class/package.json index 26c7f53a6..5aae18f87 100644 --- a/plugins/postcss-dir-pseudo-class/package.json +++ b/plugins/postcss-dir-pseudo-class/package.json @@ -29,20 +29,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-dir-pseudo-class/src/index.ts b/plugins/postcss-dir-pseudo-class/src/index.ts index 812cb0631..963bf0c35 100644 --- a/plugins/postcss-dir-pseudo-class/src/index.ts +++ b/plugins/postcss-dir-pseudo-class/src/index.ts @@ -214,3 +214,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-double-position-gradients/CHANGELOG.md b/plugins/postcss-double-position-gradients/CHANGELOG.md index 3f555082a..af629e22f 100644 --- a/plugins/postcss-double-position-gradients/CHANGELOG.md +++ b/plugins/postcss-double-position-gradients/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Double Position Gradients +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 6.0.4 _September 21, 2025_ diff --git a/plugins/postcss-double-position-gradients/dist/index.cjs b/plugins/postcss-double-position-gradients/dist/index.cjs deleted file mode 100644 index a4d676c01..000000000 --- a/plugins/postcss-double-position-gradients/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),t=require("postcss-value-parser"),s=require("@csstools/utilities");const r=/(?:repeating-)?(?:conic|linear|radial)-gradient\(/i,o=/^(?:repeating-)?(?:conic|linear|radial)-gradient$/i,i=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"];function isPunctuationCommaNode(e){return!!e&&"div"===e.type&&","===e.value}function isNumericNode(e){if(!e)return!1;try{return!1!==t.unit(e.value)}catch{return!1}}const basePlugin=e=>({postcssPlugin:"postcss-double-position-gradients",Declaration(n,{result:a}){if(!r.test(n.value))return;if(s.hasFallback(n))return;if(s.hasSupportsAtRuleAncestor(n,r))return;let u;try{u=t(n.value)}catch{n.warn(a,`Failed to parse value '${n.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===u)return;u.walk(e=>{if("function"!==e.type||!o.test(e.value))return;const t=e.nodes.filter(e=>"comment"!==e.type&&"space"!==e.type);let s=!1;t.forEach((t,r,o)=>{if("word"===t.type&&i.includes(t.value.toLowerCase())&&(s=!0),"div"===t.type&&","===t.value&&(s=!1),s)return;const n=o[r-1],a=o[r-2],u=o[r+1];if(a&&a.type&&isNumericNode(n)&&isNumericNode(t)){const s=a,r={type:"div",value:",",before:isPunctuationCommaNode(u)?u.before:"",after:isPunctuationCommaNode(u)?"":" ",sourceIndex:0,sourceEndIndex:0};e.nodes.splice(e.nodes.indexOf(t)-1,0,r,s)}})});const c=u.toString();c!==n.value&&(n.cloneBefore({value:c}),e?.preserve||n.remove())}});basePlugin.postcss=!0;const postcssPlugin=t=>{const s=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},t);return s.enableProgressiveCustomProperties&&s.preserve?{postcssPlugin:"postcss-double-position-gradients",plugins:[e(),basePlugin(s)]}:basePlugin(s)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-double-position-gradients/dist/index.d.ts b/plugins/postcss-double-position-gradients/dist/index.d.ts index b002dc64f..98d8da14d 100644 --- a/plugins/postcss-double-position-gradients/dist/index.d.ts +++ b/plugins/postcss-double-position-gradients/dist/index.d.ts @@ -10,5 +10,6 @@ export declare type pluginOptions = { declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-double-position-gradients/dist/index.mjs b/plugins/postcss-double-position-gradients/dist/index.mjs index 80efca684..52821259b 100644 --- a/plugins/postcss-double-position-gradients/dist/index.mjs +++ b/plugins/postcss-double-position-gradients/dist/index.mjs @@ -1 +1 @@ -import e from"@csstools/postcss-progressive-custom-properties";import t from"postcss-value-parser";import{hasFallback as r,hasSupportsAtRuleAncestor as s}from"@csstools/utilities";const o=/(?:repeating-)?(?:conic|linear|radial)-gradient\(/i,i=/^(?:repeating-)?(?:conic|linear|radial)-gradient$/i,n=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"];function isPunctuationCommaNode(e){return!!e&&"div"===e.type&&","===e.value}function isNumericNode(e){if(!e)return!1;try{return!1!==t.unit(e.value)}catch{return!1}}const basePlugin=e=>({postcssPlugin:"postcss-double-position-gradients",Declaration(a,{result:c}){if(!o.test(a.value))return;if(r(a))return;if(s(a,o))return;let u;try{u=t(a.value)}catch{a.warn(c,`Failed to parse value '${a.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===u)return;u.walk(e=>{if("function"!==e.type||!i.test(e.value))return;const t=e.nodes.filter(e=>"comment"!==e.type&&"space"!==e.type);let r=!1;t.forEach((t,s,o)=>{if("word"===t.type&&n.includes(t.value.toLowerCase())&&(r=!0),"div"===t.type&&","===t.value&&(r=!1),r)return;const i=o[s-1],a=o[s-2],c=o[s+1];if(a&&a.type&&isNumericNode(i)&&isNumericNode(t)){const r=a,s={type:"div",value:",",before:isPunctuationCommaNode(c)?c.before:"",after:isPunctuationCommaNode(c)?"":" ",sourceIndex:0,sourceEndIndex:0};e.nodes.splice(e.nodes.indexOf(t)-1,0,s,r)}})});const l=u.toString();l!==a.value&&(a.cloneBefore({value:l}),e?.preserve||a.remove())}});basePlugin.postcss=!0;const postcssPlugin=t=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},t);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-double-position-gradients",plugins:[e(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import e from"@csstools/postcss-progressive-custom-properties";import t from"postcss-value-parser";import{hasFallback as s,hasSupportsAtRuleAncestor as r}from"@csstools/utilities";const o=/(?:repeating-)?(?:conic|linear|radial)-gradient\(/i,i=/^(?:repeating-)?(?:conic|linear|radial)-gradient$/i,n=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"];function isPunctuationCommaNode(e){return!!e&&"div"===e.type&&","===e.value}function isNumericNode(e){if(!e)return!1;try{return!1!==t.unit(e.value)}catch{return!1}}const basePlugin=e=>({postcssPlugin:"postcss-double-position-gradients",Declaration(a,{result:c}){if(!o.test(a.value))return;if(s(a))return;if(r(a,o))return;let u;try{u=t(a.value)}catch{a.warn(c,`Failed to parse value '${a.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===u)return;u.walk(e=>{if("function"!==e.type||!i.test(e.value))return;const t=e.nodes.filter(e=>"comment"!==e.type&&"space"!==e.type);let s=!1;t.forEach((t,r,o)=>{if("word"===t.type&&n.includes(t.value.toLowerCase())&&(s=!0),"div"===t.type&&","===t.value&&(s=!1),s)return;const i=o[r-1],a=o[r-2],c=o[r+1];if(a&&a.type&&isNumericNode(i)&&isNumericNode(t)){const s=a,r={type:"div",value:",",before:isPunctuationCommaNode(c)?c.before:"",after:isPunctuationCommaNode(c)?"":" ",sourceIndex:0,sourceEndIndex:0};e.nodes.splice(e.nodes.indexOf(t)-1,0,r,s)}})});const l=u.toString();l!==a.value&&(a.cloneBefore({value:l}),e?.preserve||a.remove())}});basePlugin.postcss=!0;const postcssPlugin=t=>{const s=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},t);return s.enableProgressiveCustomProperties&&s.preserve?{postcssPlugin:"postcss-double-position-gradients",plugins:[e(),basePlugin(s)]}:basePlugin(s)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-double-position-gradients/package.json b/plugins/postcss-double-position-gradients/package.json index e036a99a9..044b0cc0e 100644 --- a/plugins/postcss-double-position-gradients/package.json +++ b/plugins/postcss-double-position-gradients/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-double-position-gradients/src/index.ts b/plugins/postcss-double-position-gradients/src/index.ts index df4e48fd1..492d5dda6 100644 --- a/plugins/postcss-double-position-gradients/src/index.ts +++ b/plugins/postcss-double-position-gradients/src/index.ts @@ -181,3 +181,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-env-function/CHANGELOG.md b/plugins/postcss-env-function/CHANGELOG.md index d811e18ef..a4a68ee43 100644 --- a/plugins/postcss-env-function/CHANGELOG.md +++ b/plugins/postcss-env-function/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Environment Variables +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 7.0.0 _August 3, 2024_ diff --git a/plugins/postcss-env-function/dist/index.cjs b/plugins/postcss-env-function/dist/index.cjs deleted file mode 100644 index 299e742dd..000000000 --- a/plugins/postcss-env-function/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser"),t=require("node:fs"),n=require("node:path"),r=require("node:url"),isEnvFunc=e=>e&&"function"===e.type&&"env"===e.value,getReplacedValue=(t,n)=>{const r=e(t);return r.walk(e=>{if(isEnvFunc(e)){const[t]=e.nodes;"word"===t.type&&void 0!==n[t.value]&&(e.nodes=[],e.type="word",e.value=n[t.value])}}),r.toString()};function importEnvironmentVariablesFromObject(e){return Object.assign({},Object(e).environmentVariables||Object(e)["environment-variables"])}async function importEnvironmentVariablesFromJSONFile(e){return importEnvironmentVariablesFromObject(await readJSON(n.resolve(e)))}async function importEnvironmentVariablesFromJSFile(e){const t=await import(r.pathToFileURL(n.resolve(e)));return importEnvironmentVariablesFromObject("default"in t?t.default:t)}const readFile=e=>new Promise((n,r)=>{t.readFile(e,"utf8",(e,t)=>{e?r(e):n(t)})}),readJSON=async e=>JSON.parse(await readFile(e));function creator(e){const t=[].concat(Object(e).importFrom||[]),r=t.map(e=>{if(e instanceof Promise)return e;if(e instanceof Function)return e();const t=e===Object(e)?e:{from:String(e)};if(t.environmentVariables||t["environment-variables"])return t;const r=String(t.from||"");return{type:(t.type||n.extname(r).slice(1)).toLowerCase(),from:r}}).reduce(async(e,t)=>{const{type:n,from:r}=await t;return"js"===n||"cjs"===n?Object.assign(e,await importEnvironmentVariablesFromJSFile(r)):"json"===n?Object.assign(e,await importEnvironmentVariablesFromJSONFile(r)):Object.assign(e,importEnvironmentVariablesFromObject(await t))},{});const a="disableDeprecationNotice"in Object(e)&&Boolean(e.disableDeprecationNotice);let i=!1;return{postcssPlugin:"postcss-env-fn",async AtRule(e,{result:t}){let n;try{n=getReplacedValue(e.params,await r)}catch{e.warn(t,`Failed to parse params '${e.params}' as an environment value. Leaving the original value intact.`)}void 0!==n&&n!==e.params&&(e.params=n,a||i||(i=!0,e.warn(t,"postcss-env-function is deprecated and will be removed.\nCheck the discussion on github for more details. https://github.com/csstools/postcss-plugins/discussions/192")))},async Declaration(e,{result:t}){let n;try{n=getReplacedValue(e.value,await r)}catch{e.warn(t,`Failed to parse value '${e.value}' as an environment value. Leaving the original value intact.`)}void 0!==n&&n!==e.value&&(e.value=n,a||i||(i=!0,e.warn(t,"postcss-env-function is deprecated and will be removed.\nWe are looking for insights and anecdotes on how these features are used so that we can design the best alternative.\nPlease let us know if our proposal will work for you.\nVisit the discussion on github for more details. https://github.com/csstools/postcss-plugins/discussions/192")))}}}creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-env-function/dist/index.mjs b/plugins/postcss-env-function/dist/index.mjs index 6395f54bc..25cc30e8a 100644 --- a/plugins/postcss-env-function/dist/index.mjs +++ b/plugins/postcss-env-function/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";import t from"node:fs";import n from"node:path";import a from"node:url";var isEnvFunc=e=>e&&"function"===e.type&&"env"===e.value,getReplacedValue=(t,n)=>{const a=e(t);return a.walk(e=>{if(isEnvFunc(e)){const[t]=e.nodes;"word"===t.type&&void 0!==n[t.value]&&(e.nodes=[],e.type="word",e.value=n[t.value])}}),a.toString()};function importEnvironmentVariablesFromObject(e){return Object.assign({},Object(e).environmentVariables||Object(e)["environment-variables"])}async function importEnvironmentVariablesFromJSONFile(e){return importEnvironmentVariablesFromObject(await readJSON(n.resolve(e)))}async function importEnvironmentVariablesFromJSFile(e){const t=await import(a.pathToFileURL(n.resolve(e)));return importEnvironmentVariablesFromObject("default"in t?t.default:t)}const readFile=e=>new Promise((n,a)=>{t.readFile(e,"utf8",(e,t)=>{e?a(e):n(t)})}),readJSON=async e=>JSON.parse(await readFile(e));function creator(e){const t=[].concat(Object(e).importFrom||[]),a=t.map(e=>{if(e instanceof Promise)return e;if(e instanceof Function)return e();const t=e===Object(e)?e:{from:String(e)};if(t.environmentVariables||t["environment-variables"])return t;const a=String(t.from||"");return{type:(t.type||n.extname(a).slice(1)).toLowerCase(),from:a}}).reduce(async(e,t)=>{const{type:n,from:a}=await t;return"js"===n||"cjs"===n?Object.assign(e,await importEnvironmentVariablesFromJSFile(a)):"json"===n?Object.assign(e,await importEnvironmentVariablesFromJSONFile(a)):Object.assign(e,importEnvironmentVariablesFromObject(await t))},{});const o="disableDeprecationNotice"in Object(e)&&Boolean(e.disableDeprecationNotice);let r=!1;return{postcssPlugin:"postcss-env-fn",async AtRule(e,{result:t}){let n;try{n=getReplacedValue(e.params,await a)}catch{e.warn(t,`Failed to parse params '${e.params}' as an environment value. Leaving the original value intact.`)}void 0!==n&&n!==e.params&&(e.params=n,o||r||(r=!0,e.warn(t,"postcss-env-function is deprecated and will be removed.\nCheck the discussion on github for more details. https://github.com/csstools/postcss-plugins/discussions/192")))},async Declaration(e,{result:t}){let n;try{n=getReplacedValue(e.value,await a)}catch{e.warn(t,`Failed to parse value '${e.value}' as an environment value. Leaving the original value intact.`)}void 0!==n&&n!==e.value&&(e.value=n,o||r||(r=!0,e.warn(t,"postcss-env-function is deprecated and will be removed.\nWe are looking for insights and anecdotes on how these features are used so that we can design the best alternative.\nPlease let us know if our proposal will work for you.\nVisit the discussion on github for more details. https://github.com/csstools/postcss-plugins/discussions/192")))}}}creator.postcss=!0;export{creator as default}; +import e from"postcss-value-parser";import t from"node:fs";import n from"node:path";import a from"node:url";var isEnvFunc=e=>e&&"function"===e.type&&"env"===e.value,getReplacedValue=(t,n)=>{const a=e(t);return a.walk(e=>{if(isEnvFunc(e)){const[t]=e.nodes;"word"===t.type&&void 0!==n[t.value]&&(e.nodes=[],e.type="word",e.value=n[t.value])}}),a.toString()};function importEnvironmentVariablesFromObject(e){return Object.assign({},Object(e).environmentVariables||Object(e)["environment-variables"])}async function importEnvironmentVariablesFromJSONFile(e){return importEnvironmentVariablesFromObject(await readJSON(n.resolve(e)))}async function importEnvironmentVariablesFromJSFile(e){const t=await import(a.pathToFileURL(n.resolve(e)));return importEnvironmentVariablesFromObject("default"in t?t.default:t)}const readFile=e=>new Promise((n,a)=>{t.readFile(e,"utf8",(e,t)=>{e?a(e):n(t)})}),readJSON=async e=>JSON.parse(await readFile(e)),creator=e=>{const t=[].concat(Object(e).importFrom||[]),a=t.map(e=>{if(e instanceof Promise)return e;if(e instanceof Function)return e();const t=e===Object(e)?e:{from:String(e)};if(t.environmentVariables||t["environment-variables"])return t;const a=String(t.from||"");return{type:(t.type||n.extname(a).slice(1)).toLowerCase(),from:a}}).reduce(async(e,t)=>{const{type:n,from:a}=await t;return"js"===n||"cjs"===n?Object.assign(e,await importEnvironmentVariablesFromJSFile(a)):"json"===n?Object.assign(e,await importEnvironmentVariablesFromJSONFile(a)):Object.assign(e,importEnvironmentVariablesFromObject(await t))},{});const o="disableDeprecationNotice"in Object(e)&&Boolean(e.disableDeprecationNotice);let r=!1;return{postcssPlugin:"postcss-env-fn",async AtRule(e,{result:t}){let n;try{n=getReplacedValue(e.params,await a)}catch{e.warn(t,`Failed to parse params '${e.params}' as an environment value. Leaving the original value intact.`)}void 0!==n&&n!==e.params&&(e.params=n,o||r||(r=!0,e.warn(t,"postcss-env-function is deprecated and will be removed.\nCheck the discussion on github for more details. https://github.com/csstools/postcss-plugins/discussions/192")))},async Declaration(e,{result:t}){let n;try{n=getReplacedValue(e.value,await a)}catch{e.warn(t,`Failed to parse value '${e.value}' as an environment value. Leaving the original value intact.`)}void 0!==n&&n!==e.value&&(e.value=n,o||r||(r=!0,e.warn(t,"postcss-env-function is deprecated and will be removed.\nWe are looking for insights and anecdotes on how these features are used so that we can design the best alternative.\nPlease let us know if our proposal will work for you.\nVisit the discussion on github for more details. https://github.com/csstools/postcss-plugins/discussions/192")))}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-env-function/package.json b/plugins/postcss-env-function/package.json index dae552e00..7933022ab 100644 --- a/plugins/postcss-env-function/package.json +++ b/plugins/postcss-env-function/package.json @@ -15,14 +15,11 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.cjs", "default": "./dist/index.mjs" } }, diff --git a/plugins/postcss-env-function/src/index.js b/plugins/postcss-env-function/src/index.js index e3b6c6a83..a8be480a5 100644 --- a/plugins/postcss-env-function/src/index.js +++ b/plugins/postcss-env-function/src/index.js @@ -5,7 +5,7 @@ import importEnvironmentVariablesFromSources from './lib/import-from'; * @param {{importFrom?: string[]}} opts * @returns {import('postcss').Plugin} */ -export default function creator(opts) { +const creator = (opts) => { // sources to import environment variables from const importFrom = [].concat(Object(opts).importFrom || []); @@ -67,6 +67,9 @@ export default function creator(opts) { } }, }; -} +}; creator.postcss = true; + +export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-exponential-functions/CHANGELOG.md b/plugins/postcss-exponential-functions/CHANGELOG.md index f874f33cc..9fc77990c 100644 --- a/plugins/postcss-exponential-functions/CHANGELOG.md +++ b/plugins/postcss-exponential-functions/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Exponential Functions +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.9 _May 27, 2025_ diff --git a/plugins/postcss-exponential-functions/dist/index.cjs b/plugins/postcss-exponential-functions/dist/index.cjs deleted file mode 100644 index 111e78996..000000000 --- a/plugins/postcss-exponential-functions/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-calc");const s=/(?{const o=Object.assign({preserve:!1},t);return{postcssPlugin:"postcss-exponential-functions",Declaration(t){if(!s.test(t.value))return;const c=e.calc(t.value);c!==t.value&&(t.cloneBefore({value:c}),o.preserve||t.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-exponential-functions/dist/index.d.ts b/plugins/postcss-exponential-functions/dist/index.d.ts index 44407b783..0f3641050 100644 --- a/plugins/postcss-exponential-functions/dist/index.d.ts +++ b/plugins/postcss-exponential-functions/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-exponential-functions plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-exponential-functions/dist/index.mjs b/plugins/postcss-exponential-functions/dist/index.mjs index e27788f6a..10b296798 100644 --- a/plugins/postcss-exponential-functions/dist/index.mjs +++ b/plugins/postcss-exponential-functions/dist/index.mjs @@ -1 +1 @@ -import{calc as e}from"@csstools/css-calc";const s=/(?{const t=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-exponential-functions",Declaration(o){if(!s.test(o.value))return;const r=e(o.value);r!==o.value&&(o.cloneBefore({value:r}),t.preserve||o.remove())}}};creator.postcss=!0;export{creator as default}; +import{calc as e}from"@csstools/css-calc";const s=/(?{const t=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-exponential-functions",Declaration(o){if(!s.test(o.value))return;const r=e(o.value);r!==o.value&&(o.cloneBefore({value:r}),t.preserve||o.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-exponential-functions/package.json b/plugins/postcss-exponential-functions/package.json index e89492a3c..fbab82789 100644 --- a/plugins/postcss-exponential-functions/package.json +++ b/plugins/postcss-exponential-functions/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-exponential-functions/src/index.ts b/plugins/postcss-exponential-functions/src/index.ts index fd53d0940..4e592ea27 100644 --- a/plugins/postcss-exponential-functions/src/index.ts +++ b/plugins/postcss-exponential-functions/src/index.ts @@ -43,3 +43,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-extract/CHANGELOG.md b/plugins/postcss-extract/CHANGELOG.md index 387ba5342..91588212a 100644 --- a/plugins/postcss-extract/CHANGELOG.md +++ b/plugins/postcss-extract/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Extract +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.1 _October 23, 2024_ diff --git a/plugins/postcss-extract/dist/index.cjs b/plugins/postcss-extract/dist/index.cjs deleted file mode 100644 index 17753e2ff..000000000 --- a/plugins/postcss-extract/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e,t=require("postcss-selector-parser");function notPseudo(e,t){return e.filter(e=>!t.includes(e))}function adjacentSiblingCombinator(e){return e.map(e=>e.prev()).filter(e=>!!e)}function childCombinator(e){return e.map(e=>e.parent).filter(e=>!!e)}function descendantCombinator(e){return e.flatMap(t=>{const n=[];let r=t.parent;for(;r;)n.push(r),r=r.parent;return e.length?n:[]}).filter(e=>!!e)}function generalSiblingCombinator(e){return e.flatMap(t=>{const n=[];let r=t.prev();for(;r;)n.push(r),r=r.prev();return e.length?n:[]}).filter(e=>!!e)}function matchAttribute(t,n,r,a,s=!1){if(n.startsWith("__proto__")||r?.startsWith("__proto__"))return[];let i=!1;r||""===r||(i=!0);let o="";i||(o=r.toString()),s&&(o=o.toLowerCase());return t.filter(t=>{let r="";if(r="variable"===n.toLowerCase()&&"decl"===t.type&&"variable"in t?"variable":Object.keys(t).find(e=>e.toLowerCase()===n.toLowerCase()&&Object.prototype.hasOwnProperty.call(t,e)),!r)return!1;if("boolean"==typeof t[r])return t[r];if(i)return!0;let u=[t[r].toString()];switch("rule"!==t.type||"selector"!==r&&"selectors"!==r||(u=t.selectors),s&&(u=u.map(e=>e.toLowerCase())),a){case e.StartsWith:return!!u.find(e=>e.startsWith(o));case e.EndsWith:return!!u.find(e=>e.endsWith(o));case e.Contains:return!!u.find(e=>e.includes(o));case e.Exact:default:return!!u.find(e=>e===o)}})}function matchTagName(e,t){return e.filter(e=>e.type.toLowerCase()===t.toLowerCase())}function simplifyASTNode(e){switch(e.type){case"decl":{const t=e;return cleanUndefinedValues({type:t.type,important:t.important,prop:t.prop,value:t.value,variable:t.variable})}case"rule":{const t=e;return cleanUndefinedValues({type:t.type,selectors:t.selectors})}case"atrule":{const t=e;return cleanUndefinedValues({type:t.type,name:t.name,params:t.params})}case"comment":{const t=e;return cleanUndefinedValues({type:t.type,text:t.text})}default:return{}}}function cleanUndefinedValues(e){return Object.keys(e).forEach(t=>{void 0===e[t]&&delete e[t]}),e}function extract(e,t){const n={};for(const[r,a]of t){let t=new Set;a.each(n=>{t=selectNodesForSingleQuery(e,n,t)}),n[r]=[];for(const e of t)n[r].push(simplifyASTNode(e))}return n}function selectNodesForSingleQuery(e,t,n){const r=buildQuery(t);if(!r)return new Set;const a=new Set(n);return e.walk(e=>{if(a.has(e))return;executeConditions(r,[e]).length>0&&a.add(e)}),a}function buildQuery(t){if(!t||!t.nodes)return;let n;return t.each(t=>{switch(t.type){case"universal":n={next:n,run:e=>e};break;case"combinator":switch(t.value){case" ":n={next:n,run:e=>descendantCombinator(e)};break;case">":n={next:n,run:e=>childCombinator(e)};break;case"+":n={next:n,run:e=>adjacentSiblingCombinator(e)};break;case"~":n={next:n,run:e=>generalSiblingCombinator(e)};break;default:n={next:n,run:()=>[]}}break;case"tag":n={next:n,run:e=>matchTagName(e,t.value)};break;case"pseudo":if(":not"===t.value)n={next:n,run:e=>{const n=t.nodes.map(e=>buildQuery(e)),r=e.filter(e=>n.flatMap(t=>t?executeConditions(t,[e]):[]).length>0);return notPseudo(e,r)}};else n={next:n,run:()=>[]};break;case"attribute":switch(t.operator){case"^=":n={next:n,run:n=>matchAttribute(n,t.attribute,t.value,e.StartsWith,t.insensitive)};break;case"$=":n={next:n,run:n=>matchAttribute(n,t.attribute,t.value,e.EndsWith,t.insensitive)};break;case"*=":n={next:n,run:n=>matchAttribute(n,t.attribute,t.value,e.Contains,t.insensitive)};break;default:n={next:n,run:n=>matchAttribute(n,t.attribute,t.value,e.Exact,t.insensitive)}}break;default:n={next:n,run:()=>[]}}}),n}function executeConditions(e,t){let n=e,r=t;for(;n&&r.length>0;)r=n.run(r),n=n.next;return r}!function(e){e.Exact="",e.StartsWith="^",e.EndsWith="$",e.Contains="*"}(e||(e={}));const creator=e=>{const n=Object(e),r=new Map;return Object.keys(n.queries??{}).forEach(e=>{r.set(e,t().astSync(n.queries[e]))}),n.results||(n.results=e=>{console.log(e)}),{postcssPlugin:"postcss-extract",prepare:()=>n.extractLate?{postcssPlugin:"postcss-extract",OnceExit(e){n.results(extract(e,r))}}:{postcssPlugin:"postcss-extract",Once(e){n.results(extract(e,r))}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-extract/dist/index.d.ts b/plugins/postcss-extract/dist/index.d.ts index 0cf1e8524..d8cbe862d 100644 --- a/plugins/postcss-extract/dist/index.d.ts +++ b/plugins/postcss-extract/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export declare type pluginOptions = { /** Mapping of queries */ diff --git a/plugins/postcss-extract/dist/index.mjs b/plugins/postcss-extract/dist/index.mjs index 61d698073..43b916d48 100644 --- a/plugins/postcss-extract/dist/index.mjs +++ b/plugins/postcss-extract/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";function notPseudo(e,t){return e.filter(e=>!t.includes(e))}function adjacentSiblingCombinator(e){return e.map(e=>e.prev()).filter(e=>!!e)}function childCombinator(e){return e.map(e=>e.parent).filter(e=>!!e)}function descendantCombinator(e){return e.flatMap(t=>{const n=[];let r=t.parent;for(;r;)n.push(r),r=r.parent;return e.length?n:[]}).filter(e=>!!e)}function generalSiblingCombinator(e){return e.flatMap(t=>{const n=[];let r=t.prev();for(;r;)n.push(r),r=r.prev();return e.length?n:[]}).filter(e=>!!e)}var t;function matchAttribute(e,n,r,a,s=!1){if(n.startsWith("__proto__")||r?.startsWith("__proto__"))return[];let i=!1;r||""===r||(i=!0);let o="";i||(o=r.toString()),s&&(o=o.toLowerCase());return e.filter(e=>{let r="";if(r="variable"===n.toLowerCase()&&"decl"===e.type&&"variable"in e?"variable":Object.keys(e).find(t=>t.toLowerCase()===n.toLowerCase()&&Object.prototype.hasOwnProperty.call(e,t)),!r)return!1;if("boolean"==typeof e[r])return e[r];if(i)return!0;let u=[e[r].toString()];switch("rule"!==e.type||"selector"!==r&&"selectors"!==r||(u=e.selectors),s&&(u=u.map(e=>e.toLowerCase())),a){case t.StartsWith:return!!u.find(e=>e.startsWith(o));case t.EndsWith:return!!u.find(e=>e.endsWith(o));case t.Contains:return!!u.find(e=>e.includes(o));case t.Exact:default:return!!u.find(e=>e===o)}})}function matchTagName(e,t){return e.filter(e=>e.type.toLowerCase()===t.toLowerCase())}function simplifyASTNode(e){switch(e.type){case"decl":{const t=e;return cleanUndefinedValues({type:t.type,important:t.important,prop:t.prop,value:t.value,variable:t.variable})}case"rule":{const t=e;return cleanUndefinedValues({type:t.type,selectors:t.selectors})}case"atrule":{const t=e;return cleanUndefinedValues({type:t.type,name:t.name,params:t.params})}case"comment":{const t=e;return cleanUndefinedValues({type:t.type,text:t.text})}default:return{}}}function cleanUndefinedValues(e){return Object.keys(e).forEach(t=>{void 0===e[t]&&delete e[t]}),e}function extract(e,t){const n={};for(const[r,a]of t){let t=new Set;a.each(n=>{t=selectNodesForSingleQuery(e,n,t)}),n[r]=[];for(const e of t)n[r].push(simplifyASTNode(e))}return n}function selectNodesForSingleQuery(e,t,n){const r=buildQuery(t);if(!r)return new Set;const a=new Set(n);return e.walk(e=>{if(a.has(e))return;executeConditions(r,[e]).length>0&&a.add(e)}),a}function buildQuery(e){if(!e||!e.nodes)return;let n;return e.each(e=>{switch(e.type){case"universal":n={next:n,run:e=>e};break;case"combinator":switch(e.value){case" ":n={next:n,run:e=>descendantCombinator(e)};break;case">":n={next:n,run:e=>childCombinator(e)};break;case"+":n={next:n,run:e=>adjacentSiblingCombinator(e)};break;case"~":n={next:n,run:e=>generalSiblingCombinator(e)};break;default:n={next:n,run:()=>[]}}break;case"tag":n={next:n,run:t=>matchTagName(t,e.value)};break;case"pseudo":if(":not"===e.value)n={next:n,run:t=>{const n=e.nodes.map(e=>buildQuery(e)),r=t.filter(e=>n.flatMap(t=>t?executeConditions(t,[e]):[]).length>0);return notPseudo(t,r)}};else n={next:n,run:()=>[]};break;case"attribute":switch(e.operator){case"^=":n={next:n,run:n=>matchAttribute(n,e.attribute,e.value,t.StartsWith,e.insensitive)};break;case"$=":n={next:n,run:n=>matchAttribute(n,e.attribute,e.value,t.EndsWith,e.insensitive)};break;case"*=":n={next:n,run:n=>matchAttribute(n,e.attribute,e.value,t.Contains,e.insensitive)};break;default:n={next:n,run:n=>matchAttribute(n,e.attribute,e.value,t.Exact,e.insensitive)}}break;default:n={next:n,run:()=>[]}}}),n}function executeConditions(e,t){let n=e,r=t;for(;n&&r.length>0;)r=n.run(r),n=n.next;return r}!function(e){e.Exact="",e.StartsWith="^",e.EndsWith="$",e.Contains="*"}(t||(t={}));const creator=t=>{const n=Object(t),r=new Map;return Object.keys(n.queries??{}).forEach(t=>{r.set(t,e().astSync(n.queries[t]))}),n.results||(n.results=e=>{console.log(e)}),{postcssPlugin:"postcss-extract",prepare:()=>n.extractLate?{postcssPlugin:"postcss-extract",OnceExit(e){n.results(extract(e,r))}}:{postcssPlugin:"postcss-extract",Once(e){n.results(extract(e,r))}}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-selector-parser";function notPseudo(e,t){return e.filter(e=>!t.includes(e))}function adjacentSiblingCombinator(e){return e.map(e=>e.prev()).filter(e=>!!e)}function childCombinator(e){return e.map(e=>e.parent).filter(e=>!!e)}function descendantCombinator(e){return e.flatMap(t=>{const n=[];let r=t.parent;for(;r;)n.push(r),r=r.parent;return e.length?n:[]}).filter(e=>!!e)}function generalSiblingCombinator(e){return e.flatMap(t=>{const n=[];let r=t.prev();for(;r;)n.push(r),r=r.prev();return e.length?n:[]}).filter(e=>!!e)}var t;function matchAttribute(e,n,r,a,s=!1){if(n.startsWith("__proto__")||r?.startsWith("__proto__"))return[];let i=!1;r||""===r||(i=!0);let o="";i||(o=r.toString()),s&&(o=o.toLowerCase());return e.filter(e=>{let r="";if(r="variable"===n.toLowerCase()&&"decl"===e.type&&"variable"in e?"variable":Object.keys(e).find(t=>t.toLowerCase()===n.toLowerCase()&&Object.prototype.hasOwnProperty.call(e,t)),!r)return!1;if("boolean"==typeof e[r])return e[r];if(i)return!0;let u=[e[r].toString()];switch("rule"!==e.type||"selector"!==r&&"selectors"!==r||(u=e.selectors),s&&(u=u.map(e=>e.toLowerCase())),a){case t.StartsWith:return!!u.find(e=>e.startsWith(o));case t.EndsWith:return!!u.find(e=>e.endsWith(o));case t.Contains:return!!u.find(e=>e.includes(o));case t.Exact:default:return!!u.find(e=>e===o)}})}function matchTagName(e,t){return e.filter(e=>e.type.toLowerCase()===t.toLowerCase())}function simplifyASTNode(e){switch(e.type){case"decl":{const t=e;return cleanUndefinedValues({type:t.type,important:t.important,prop:t.prop,value:t.value,variable:t.variable})}case"rule":{const t=e;return cleanUndefinedValues({type:t.type,selectors:t.selectors})}case"atrule":{const t=e;return cleanUndefinedValues({type:t.type,name:t.name,params:t.params})}case"comment":{const t=e;return cleanUndefinedValues({type:t.type,text:t.text})}default:return{}}}function cleanUndefinedValues(e){return Object.keys(e).forEach(t=>{void 0===e[t]&&delete e[t]}),e}function extract(e,t){const n={};for(const[r,a]of t){let t=new Set;a.each(n=>{t=selectNodesForSingleQuery(e,n,t)}),n[r]=[];for(const e of t)n[r].push(simplifyASTNode(e))}return n}function selectNodesForSingleQuery(e,t,n){const r=buildQuery(t);if(!r)return new Set;const a=new Set(n);return e.walk(e=>{if(a.has(e))return;executeConditions(r,[e]).length>0&&a.add(e)}),a}function buildQuery(e){if(!e||!e.nodes)return;let n;return e.each(e=>{switch(e.type){case"universal":n={next:n,run:e=>e};break;case"combinator":switch(e.value){case" ":n={next:n,run:e=>descendantCombinator(e)};break;case">":n={next:n,run:e=>childCombinator(e)};break;case"+":n={next:n,run:e=>adjacentSiblingCombinator(e)};break;case"~":n={next:n,run:e=>generalSiblingCombinator(e)};break;default:n={next:n,run:()=>[]}}break;case"tag":n={next:n,run:t=>matchTagName(t,e.value)};break;case"pseudo":if(":not"===e.value)n={next:n,run:t=>{const n=e.nodes.map(e=>buildQuery(e)),r=t.filter(e=>n.flatMap(t=>t?executeConditions(t,[e]):[]).length>0);return notPseudo(t,r)}};else n={next:n,run:()=>[]};break;case"attribute":switch(e.operator){case"^=":n={next:n,run:n=>matchAttribute(n,e.attribute,e.value,t.StartsWith,e.insensitive)};break;case"$=":n={next:n,run:n=>matchAttribute(n,e.attribute,e.value,t.EndsWith,e.insensitive)};break;case"*=":n={next:n,run:n=>matchAttribute(n,e.attribute,e.value,t.Contains,e.insensitive)};break;default:n={next:n,run:n=>matchAttribute(n,e.attribute,e.value,t.Exact,e.insensitive)}}break;default:n={next:n,run:()=>[]}}}),n}function executeConditions(e,t){let n=e,r=t;for(;n&&r.length>0;)r=n.run(r),n=n.next;return r}!function(e){e.Exact="",e.StartsWith="^",e.EndsWith="$",e.Contains="*"}(t||(t={}));const creator=t=>{const n=Object(t),r=new Map;return Object.keys(n.queries??{}).forEach(t=>{r.set(t,e().astSync(n.queries[t]))}),n.results||(n.results=e=>{console.log(e)}),{postcssPlugin:"postcss-extract",prepare:()=>n.extractLate?{postcssPlugin:"postcss-extract",OnceExit(e){n.results(extract(e,r))}}:{postcssPlugin:"postcss-extract",Once(e){n.results(extract(e,r))}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-extract/package.json b/plugins/postcss-extract/package.json index 8de758dd2..0d374d879 100644 --- a/plugins/postcss-extract/package.json +++ b/plugins/postcss-extract/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-extract/src/index.ts b/plugins/postcss-extract/src/index.ts index e5b0b653d..810e3fec1 100644 --- a/plugins/postcss-extract/src/index.ts +++ b/plugins/postcss-extract/src/index.ts @@ -51,4 +51,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-focus-visible/CHANGELOG.md b/plugins/postcss-focus-visible/CHANGELOG.md index cb8cf0d9e..3ba3e6673 100644 --- a/plugins/postcss-focus-visible/CHANGELOG.md +++ b/plugins/postcss-focus-visible/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Focus Visible +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 10.0.1 _October 23, 2024_ diff --git a/plugins/postcss-focus-visible/dist/index.cjs b/plugins/postcss-focus-visible/dist/index.cjs deleted file mode 100644 index 7e75ff8a8..000000000 --- a/plugins/postcss-focus-visible/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser");const s="js-focus-visible",o=":focus-visible",creator=r=>{const t=Object.assign({preserve:!0,replaceWith:".focus-visible",disablePolyfillReadyClass:!1},r),n=e().astSync(t.replaceWith);return{postcssPlugin:"postcss-focus-visible",prepare(){const r=new WeakSet;return{postcssPlugin:"postcss-focus-visible",Rule(l,{result:a}){if(r.has(l))return;if(!l.selector.toLowerCase().includes(o))return;const i=l.selectors.flatMap(r=>{if(!r.toLowerCase().includes(o))return[r];let i;try{i=e().astSync(r)}catch(e){return l.warn(a,`Failed to parse selector : "${r}" with message: "${e instanceof Error?e.message:e}"`),r}if(void 0===i)return[r];let c=!1;if(i.walkPseudos(e=>{e.value.toLowerCase()===o&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(n.clone({}))))}),!c)return[r];const d=i.clone();if(!t.disablePolyfillReadyClass){if(i.nodes?.[0]?.nodes?.length)for(let o=0;o; export default creator; +export { creator as 'module.exports' } /** postcss-focus-visible plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-focus-visible/dist/index.mjs b/plugins/postcss-focus-visible/dist/index.mjs index bdbeb4314..a8c22f1f6 100644 --- a/plugins/postcss-focus-visible/dist/index.mjs +++ b/plugins/postcss-focus-visible/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";const s="js-focus-visible",o=":focus-visible",creator=t=>{const r=Object.assign({preserve:!0,replaceWith:".focus-visible",disablePolyfillReadyClass:!1},t),n=e().astSync(r.replaceWith);return{postcssPlugin:"postcss-focus-visible",prepare(){const t=new WeakSet;return{postcssPlugin:"postcss-focus-visible",Rule(l,{result:a}){if(t.has(l))return;if(!l.selector.toLowerCase().includes(o))return;const i=l.selectors.flatMap(t=>{if(!t.toLowerCase().includes(o))return[t];let i;try{i=e().astSync(t)}catch(e){return l.warn(a,`Failed to parse selector : "${t}" with message: "${e instanceof Error?e.message:e}"`),t}if(void 0===i)return[t];let c=!1;if(i.walkPseudos(e=>{e.value.toLowerCase()===o&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(n.clone({}))))}),!c)return[t];const d=i.clone();if(!r.disablePolyfillReadyClass){if(i.nodes?.[0]?.nodes?.length)for(let o=0;o{const r=Object.assign({preserve:!0,replaceWith:".focus-visible",disablePolyfillReadyClass:!1},t),n=e().astSync(r.replaceWith);return{postcssPlugin:"postcss-focus-visible",prepare(){const t=new WeakSet;return{postcssPlugin:"postcss-focus-visible",Rule(l,{result:a}){if(t.has(l))return;if(!l.selector.toLowerCase().includes(o))return;const i=l.selectors.flatMap(t=>{if(!t.toLowerCase().includes(o))return[t];let i;try{i=e().astSync(t)}catch(e){return l.warn(a,`Failed to parse selector : "${t}" with message: "${e instanceof Error?e.message:e}"`),t}if(void 0===i)return[t];let c=!1;if(i.walkPseudos(e=>{e.value.toLowerCase()===o&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(n.clone({}))))}),!c)return[t];const d=i.clone();if(!r.disablePolyfillReadyClass){if(i.nodes?.[0]?.nodes?.length)for(let o=0;o=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-focus-visible/src/index.ts b/plugins/postcss-focus-visible/src/index.ts index b99073438..1bfb055ac 100644 --- a/plugins/postcss-focus-visible/src/index.ts +++ b/plugins/postcss-focus-visible/src/index.ts @@ -135,4 +135,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-focus-within/CHANGELOG.md b/plugins/postcss-focus-within/CHANGELOG.md index cd1edc473..a02fc9873 100644 --- a/plugins/postcss-focus-within/CHANGELOG.md +++ b/plugins/postcss-focus-within/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Focus Within +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 9.0.1 _October 23, 2024_ diff --git a/plugins/postcss-focus-within/dist/index.cjs b/plugins/postcss-focus-within/dist/index.cjs deleted file mode 100644 index ff9ae8a11..000000000 --- a/plugins/postcss-focus-within/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser");const s=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(e){let t=!0;for(let n=0,o=s.length;n-1&&(t=!1);return t}const t="js-focus-within",n=":focus-within",creator=s=>{const o=Object.assign({preserve:!0,replaceWith:"[focus-within]",disablePolyfillReadyClass:!1},s),r=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"postcss-focus-within",prepare(){const s=new WeakSet;return{postcssPlugin:"postcss-focus-within",Rule(l,{result:i}){if(s.has(l))return;if(!l.selector.toLowerCase().includes(n))return;const a=l.selectors.flatMap(s=>{if(!s.toLowerCase().includes(n))return[s];let a;try{a=e().astSync(s)}catch(e){return l.warn(i,`Failed to parse selector : "${s}" with message: "${e instanceof Error?e.message:e}"`),s}if(void 0===a)return[s];let c=!1;if(a.walkPseudos(e=>{e.value.toLowerCase()===n&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(r.clone({}))))}),!c)return[s];const d=a.clone();if(!o.disablePolyfillReadyClass){if(a.nodes?.[0]?.nodes?.length)for(let s=0;s; export default creator; +export { creator as 'module.exports' } /** postcss-focus-within plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-focus-within/dist/index.mjs b/plugins/postcss-focus-within/dist/index.mjs index 6bd746bf5..f07b3e9a9 100644 --- a/plugins/postcss-focus-within/dist/index.mjs +++ b/plugins/postcss-focus-within/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";const s=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(e){let t=!0;for(let n=0,o=s.length;n-1&&(t=!1);return t}const t="js-focus-within",n=":focus-within",creator=s=>{const o=Object.assign({preserve:!0,replaceWith:"[focus-within]",disablePolyfillReadyClass:!1},s),r=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"postcss-focus-within",prepare(){const s=new WeakSet;return{postcssPlugin:"postcss-focus-within",Rule(l,{result:i}){if(s.has(l))return;if(!l.selector.toLowerCase().includes(n))return;const a=l.selectors.flatMap(s=>{if(!s.toLowerCase().includes(n))return[s];let a;try{a=e().astSync(s)}catch(e){return l.warn(i,`Failed to parse selector : "${s}" with message: "${e instanceof Error?e.message:e}"`),s}if(void 0===a)return[s];let c=!1;if(a.walkPseudos(e=>{e.value.toLowerCase()===n&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(r.clone({}))))}),!c)return[s];const d=a.clone();if(!o.disablePolyfillReadyClass){if(a.nodes?.[0]?.nodes?.length)for(let s=0;s","~",":","+","@","#","(",")"];function isValidReplacement(e){let t=!0;for(let n=0,o=s.length;n-1&&(t=!1);return t}const t="js-focus-within",n=":focus-within",creator=s=>{const o=Object.assign({preserve:!0,replaceWith:"[focus-within]",disablePolyfillReadyClass:!1},s),r=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"postcss-focus-within",prepare(){const s=new WeakSet;return{postcssPlugin:"postcss-focus-within",Rule(l,{result:i}){if(s.has(l))return;if(!l.selector.toLowerCase().includes(n))return;const a=l.selectors.flatMap(s=>{if(!s.toLowerCase().includes(n))return[s];let a;try{a=e().astSync(s)}catch(e){return l.warn(i,`Failed to parse selector : "${s}" with message: "${e instanceof Error?e.message:e}"`),s}if(void 0===a)return[s];let c=!1;if(a.walkPseudos(e=>{e.value.toLowerCase()===n&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(r.clone({}))))}),!c)return[s];const d=a.clone();if(!o.disablePolyfillReadyClass){if(a.nodes?.[0]?.nodes?.length)for(let s=0;s=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" }, "./browser": { "import": "./dist/browser.mjs", diff --git a/plugins/postcss-focus-within/src/index.ts b/plugins/postcss-focus-within/src/index.ts index 19cd8794c..f1bfef17c 100644 --- a/plugins/postcss-focus-within/src/index.ts +++ b/plugins/postcss-focus-within/src/index.ts @@ -147,4 +147,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-font-format-keywords/CHANGELOG.md b/plugins/postcss-font-format-keywords/CHANGELOG.md index 5d3c292b3..30837adad 100644 --- a/plugins/postcss-font-format-keywords/CHANGELOG.md +++ b/plugins/postcss-font-format-keywords/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Font Format +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.0 _August 3, 2024_ diff --git a/plugins/postcss-font-format-keywords/dist/index.cjs b/plugins/postcss-font-format-keywords/dist/index.cjs deleted file mode 100644 index 7acbecabf..000000000 --- a/plugins/postcss-font-format-keywords/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser"),t=require("@csstools/utilities");const o=["woff","truetype","opentype","woff2","embedded-opentype","collection","svg"],creator=r=>{const s="preserve"in Object(r)&&Boolean(r?.preserve);return{postcssPlugin:"postcss-font-format-keywords",Declaration(r){if("src"!==r.prop.toLowerCase())return;if(!r.value.toLowerCase().includes("format("))return;if(t.hasFallback(r))return;const a=r.parent;if(!a||"atrule"!==a.type)return;if("font-face"!==a.name.toLowerCase())return;const n=e(r.value);n.walk(t=>{"function"===t.type&&"format"===t.value.toLowerCase()&&t.nodes.forEach(t=>{"word"===t.type&&o.includes(t.value.toLowerCase())&&(t.value=e.stringify({type:"string",value:t.value,quote:'"'}))})}),n.toString()!==r.value&&(r.cloneBefore({value:n.toString()}),s||r.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-font-format-keywords/dist/index.d.ts b/plugins/postcss-font-format-keywords/dist/index.d.ts index 4bc6e82c7..7d347d7f3 100644 --- a/plugins/postcss-font-format-keywords/dist/index.d.ts +++ b/plugins/postcss-font-format-keywords/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-font-format-keywords plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-font-format-keywords/dist/index.mjs b/plugins/postcss-font-format-keywords/dist/index.mjs index 115c39540..7cbbb974a 100644 --- a/plugins/postcss-font-format-keywords/dist/index.mjs +++ b/plugins/postcss-font-format-keywords/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";import{hasFallback as t}from"@csstools/utilities";const o=["woff","truetype","opentype","woff2","embedded-opentype","collection","svg"],creator=r=>{const s="preserve"in Object(r)&&Boolean(r?.preserve);return{postcssPlugin:"postcss-font-format-keywords",Declaration(r){if("src"!==r.prop.toLowerCase())return;if(!r.value.toLowerCase().includes("format("))return;if(t(r))return;const n=r.parent;if(!n||"atrule"!==n.type)return;if("font-face"!==n.name.toLowerCase())return;const a=e(r.value);a.walk(t=>{"function"===t.type&&"format"===t.value.toLowerCase()&&t.nodes.forEach(t=>{"word"===t.type&&o.includes(t.value.toLowerCase())&&(t.value=e.stringify({type:"string",value:t.value,quote:'"'}))})}),a.toString()!==r.value&&(r.cloneBefore({value:a.toString()}),s||r.remove())}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-value-parser";import{hasFallback as o}from"@csstools/utilities";const t=["woff","truetype","opentype","woff2","embedded-opentype","collection","svg"],creator=r=>{const s="preserve"in Object(r)&&Boolean(r?.preserve);return{postcssPlugin:"postcss-font-format-keywords",Declaration(r){if("src"!==r.prop.toLowerCase())return;if(!r.value.toLowerCase().includes("format("))return;if(o(r))return;const a=r.parent;if(!a||"atrule"!==a.type)return;if("font-face"!==a.name.toLowerCase())return;const n=e(r.value);n.walk(o=>{"function"===o.type&&"format"===o.value.toLowerCase()&&o.nodes.forEach(o=>{"word"===o.type&&t.includes(o.value.toLowerCase())&&(o.value=e.stringify({type:"string",value:o.value,quote:'"'}))})}),n.toString()!==r.value&&(r.cloneBefore({value:n.toString()}),s||r.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-font-format-keywords/package.json b/plugins/postcss-font-format-keywords/package.json index 4954a7a10..e6eab72fd 100644 --- a/plugins/postcss-font-format-keywords/package.json +++ b/plugins/postcss-font-format-keywords/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-font-format-keywords/src/index.ts b/plugins/postcss-font-format-keywords/src/index.ts index 994e392e3..583ff3372 100644 --- a/plugins/postcss-font-format-keywords/src/index.ts +++ b/plugins/postcss-font-format-keywords/src/index.ts @@ -84,4 +84,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-gamut-mapping/CHANGELOG.md b/plugins/postcss-gamut-mapping/CHANGELOG.md index 0077f8478..8cc8eb4e0 100644 --- a/plugins/postcss-gamut-mapping/CHANGELOG.md +++ b/plugins/postcss-gamut-mapping/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS gamut-mapping +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.11 _August 22, 2025_ diff --git a/plugins/postcss-gamut-mapping/dist/index.cjs b/plugins/postcss-gamut-mapping/dist/index.cjs deleted file mode 100644 index e1b99370f..000000000 --- a/plugins/postcss-gamut-mapping/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-tokenizer"),o=require("@csstools/css-parser-algorithms"),a=require("@csstools/css-color-parser");const t=/\bcolor-gamut\b/i;function hasConditionalAncestor(e){let o=e.parent;for(;o;)if("atrule"===o.type){if("media"===o.name.toLowerCase()&&t.test(o.params))return!0;o=o.parent}else o=o.parent;return!1}function sameProperty(e){const o=e.prop.toLowerCase(),a=[],t=e.parent?.nodes??[];for(let e=0;e({postcssPlugin:"postcss-gamut-mapping",prepare(){const t=new WeakMap,r=new WeakSet;return{postcssPlugin:"postcss-gamut-mapping",OnceExit(i,{postcss:l}){i.walkDecls(i=>{if(r.has(i))return;if(!s.test(i.value))return;if(!i.parent||hasConditionalAncestor(i))return;const c=sameProperty(i).map((t,s)=>{r.add(t);let i=!1;const l=t.value,c=o.replaceComponentValues(o.parseCommaSeparatedListOfComponentValues(e.tokenize({css:l})),e=>{if(!o.isFunctionNode(e)||!n.test(e.getName()))return;const t=a.color(e);return!t||t.syntaxFlags.has(a.SyntaxFlag.HasNoneKeywords)||a.colorDataFitsRGB_Gamut(t)?void 0:(i||a.colorDataFitsDisplayP3_Gamut(t)||(i=!0),a.serializeRGB(t,!0))}),p=o.stringify(c);return{isRec2020:i,matchesOriginal:p===l,modifiedValue:p,hasFallback:s>0,item:t}}),p=[];c.reverse();for(const e of c){if(e.matchesOriginal)break;p.push(e)}p.reverse(),p.forEach(({isRec2020:e,modifiedValue:o,hasFallback:a,item:s})=>{const n=s.parent;if(!n)return;const i=t.get(n)||{conditionalRules:[],propNames:new Set,lastConditionParams:{media:void 0},lastConditionalRule:void 0};t.set(n,i);const c=`(color-gamut: ${e?"rec2020":"p3"})`;if(i.lastConditionParams.media!==c&&(i.lastConditionalRule=void 0),!a){const e=s.cloneBefore({value:o});r.add(e)}if(i.lastConditionalRule){const e=s.clone();return i.lastConditionalRule.append(e),r.add(e),void s.remove()}const p=l.atRule({name:"media",params:c,source:n.source,raws:{before:"\n\n",after:"\n"}}),u=n.clone();u.removeAll(),u.raws.before="\n";const d=s.clone();u.append(d),s.remove(),r.add(d),i.lastConditionParams.media=p.params,i.lastConditionalRule=u,p.append(u),i.conditionalRules.push(p)})}),i.walk(e=>{const o=t.get(e);o&&0!==o.conditionalRules.length&&o.conditionalRules.reverse().forEach(o=>{e.after(o)})})}}}});creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-gamut-mapping/dist/index.d.ts b/plugins/postcss-gamut-mapping/dist/index.d.ts index c8f9aec3a..334bc977a 100644 --- a/plugins/postcss-gamut-mapping/dist/index.d.ts +++ b/plugins/postcss-gamut-mapping/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-gamut-mapping plugin options */ export declare type pluginOptions = never; diff --git a/plugins/postcss-gamut-mapping/dist/index.mjs b/plugins/postcss-gamut-mapping/dist/index.mjs index 0f4065e9d..6299b9da4 100644 --- a/plugins/postcss-gamut-mapping/dist/index.mjs +++ b/plugins/postcss-gamut-mapping/dist/index.mjs @@ -1 +1 @@ -import{tokenize as e}from"@csstools/css-tokenizer";import{replaceComponentValues as o,parseCommaSeparatedListOfComponentValues as t,isFunctionNode as s,stringify as a}from"@csstools/css-parser-algorithms";import{color as n,SyntaxFlag as r,colorDataFitsRGB_Gamut as l,colorDataFitsDisplayP3_Gamut as i,serializeRGB as c}from"@csstools/css-color-parser";const p=/\bcolor-gamut\b/i;function hasConditionalAncestor(e){let o=e.parent;for(;o;)if("atrule"===o.type){if("media"===o.name.toLowerCase()&&p.test(o.params))return!0;o=o.parent}else o=o.parent;return!1}function sameProperty(e){const o=e.prop.toLowerCase(),t=[],s=e.parent?.nodes??[];for(let e=0;e({postcssPlugin:"postcss-gamut-mapping",prepare(){const p=new WeakMap,m=new WeakSet;return{postcssPlugin:"postcss-gamut-mapping",OnceExit(f,{postcss:h}){f.walkDecls(f=>{if(m.has(f))return;if(!d.test(f.value))return;if(!f.parent||hasConditionalAncestor(f))return;const g=sameProperty(f).map((p,d)=>{m.add(p);let f=!1;const h=p.value,g=o(t(e({css:h})),e=>{if(!s(e)||!u.test(e.getName()))return;const o=n(e);return!o||o.syntaxFlags.has(r.HasNoneKeywords)||l(o)?void 0:(f||i(o)||(f=!0),c(o,!0))}),v=a(g);return{isRec2020:f,matchesOriginal:v===h,modifiedValue:v,hasFallback:d>0,item:p}}),v=[];g.reverse();for(const e of g){if(e.matchesOriginal)break;v.push(e)}v.reverse(),v.forEach(({isRec2020:e,modifiedValue:o,hasFallback:t,item:s})=>{const a=s.parent;if(!a)return;const n=p.get(a)||{conditionalRules:[],propNames:new Set,lastConditionParams:{media:void 0},lastConditionalRule:void 0};p.set(a,n);const r=`(color-gamut: ${e?"rec2020":"p3"})`;if(n.lastConditionParams.media!==r&&(n.lastConditionalRule=void 0),!t){const e=s.cloneBefore({value:o});m.add(e)}if(n.lastConditionalRule){const e=s.clone();return n.lastConditionalRule.append(e),m.add(e),void s.remove()}const l=h.atRule({name:"media",params:r,source:a.source,raws:{before:"\n\n",after:"\n"}}),i=a.clone();i.removeAll(),i.raws.before="\n";const c=s.clone();i.append(c),s.remove(),m.add(c),n.lastConditionParams.media=l.params,n.lastConditionalRule=i,l.append(i),n.conditionalRules.push(l)})}),f.walk(e=>{const o=p.get(e);o&&0!==o.conditionalRules.length&&o.conditionalRules.reverse().forEach(o=>{e.after(o)})})}}}});creator.postcss=!0;export{creator as default}; +import{tokenize as e}from"@csstools/css-tokenizer";import{replaceComponentValues as o,parseCommaSeparatedListOfComponentValues as t,isFunctionNode as s,stringify as a}from"@csstools/css-parser-algorithms";import{color as n,SyntaxFlag as r,colorDataFitsRGB_Gamut as l,colorDataFitsDisplayP3_Gamut as i,serializeRGB as c}from"@csstools/css-color-parser";const p=/\bcolor-gamut\b/i;function hasConditionalAncestor(e){let o=e.parent;for(;o;)if("atrule"===o.type){if("media"===o.name.toLowerCase()&&p.test(o.params))return!0;o=o.parent}else o=o.parent;return!1}function sameProperty(e){const o=e.prop.toLowerCase(),t=[],s=e.parent?.nodes??[];for(let e=0;e({postcssPlugin:"postcss-gamut-mapping",prepare(){const p=new WeakMap,m=new WeakSet;return{postcssPlugin:"postcss-gamut-mapping",OnceExit(f,{postcss:h}){f.walkDecls(f=>{if(m.has(f))return;if(!d.test(f.value))return;if(!f.parent||hasConditionalAncestor(f))return;const g=sameProperty(f).map((p,d)=>{m.add(p);let f=!1;const h=p.value,g=o(t(e({css:h})),e=>{if(!s(e)||!u.test(e.getName()))return;const o=n(e);return!o||o.syntaxFlags.has(r.HasNoneKeywords)||l(o)?void 0:(f||i(o)||(f=!0),c(o,!0))}),v=a(g);return{isRec2020:f,matchesOriginal:v===h,modifiedValue:v,hasFallback:d>0,item:p}}),v=[];g.reverse();for(const e of g){if(e.matchesOriginal)break;v.push(e)}v.reverse(),v.forEach(({isRec2020:e,modifiedValue:o,hasFallback:t,item:s})=>{const a=s.parent;if(!a)return;const n=p.get(a)||{conditionalRules:[],propNames:new Set,lastConditionParams:{media:void 0},lastConditionalRule:void 0};p.set(a,n);const r=`(color-gamut: ${e?"rec2020":"p3"})`;if(n.lastConditionParams.media!==r&&(n.lastConditionalRule=void 0),!t){const e=s.cloneBefore({value:o});m.add(e)}if(n.lastConditionalRule){const e=s.clone();return n.lastConditionalRule.append(e),m.add(e),void s.remove()}const l=h.atRule({name:"media",params:r,source:a.source,raws:{before:"\n\n",after:"\n"}}),i=a.clone();i.removeAll(),i.raws.before="\n";const c=s.clone();i.append(c),s.remove(),m.add(c),n.lastConditionParams.media=l.params,n.lastConditionalRule=i,l.append(i),n.conditionalRules.push(l)})}),f.walk(e=>{const o=p.get(e);o&&0!==o.conditionalRules.length&&o.conditionalRules.reverse().forEach(o=>{e.after(o)})})}}}});creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-gamut-mapping/package.json b/plugins/postcss-gamut-mapping/package.json index 4548f5dcf..64262a7f3 100644 --- a/plugins/postcss-gamut-mapping/package.json +++ b/plugins/postcss-gamut-mapping/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-gamut-mapping/src/index.ts b/plugins/postcss-gamut-mapping/src/index.ts index 60b296f89..5c0cd7286 100644 --- a/plugins/postcss-gamut-mapping/src/index.ts +++ b/plugins/postcss-gamut-mapping/src/index.ts @@ -211,3 +211,4 @@ const creator: PluginCreator = () => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-gap-properties/CHANGELOG.md b/plugins/postcss-gap-properties/CHANGELOG.md index efe3479e6..83ada6921 100644 --- a/plugins/postcss-gap-properties/CHANGELOG.md +++ b/plugins/postcss-gap-properties/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Gap Properties +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 6.0.0 _August 3, 2024_ diff --git a/plugins/postcss-gap-properties/dist/index.cjs b/plugins/postcss-gap-properties/dist/index.cjs deleted file mode 100644 index bf47020f1..000000000 --- a/plugins/postcss-gap-properties/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";const e=["column-gap","gap","row-gap"],creator=o=>{const r=Object.assign({preserve:!0},o);return{postcssPlugin:"postcss-gap-properties",Declaration(o){if(!e.includes(o.prop.toLowerCase()))return;if(!o.parent?.some(e=>"decl"===e.type&&("display"===e.prop.toLowerCase()&&"grid"===e.value.toLowerCase())))return;const s=`grid-${o.prop.toLowerCase()}`,p=o.parent?.some(e=>"decl"===e.type&&e.prop.toLowerCase()===s);p||(o.cloneBefore({prop:s}),r.preserve||o.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-gap-properties/dist/index.d.ts b/plugins/postcss-gap-properties/dist/index.d.ts index 2cc7af8f7..032fd357e 100644 --- a/plugins/postcss-gap-properties/dist/index.d.ts +++ b/plugins/postcss-gap-properties/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-gap-properties plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-gap-properties/dist/index.mjs b/plugins/postcss-gap-properties/dist/index.mjs index 911b041bf..934ba61c5 100644 --- a/plugins/postcss-gap-properties/dist/index.mjs +++ b/plugins/postcss-gap-properties/dist/index.mjs @@ -1 +1 @@ -const e=["column-gap","gap","row-gap"],creator=o=>{const r=Object.assign({preserve:!0},o);return{postcssPlugin:"postcss-gap-properties",Declaration(o){if(!e.includes(o.prop.toLowerCase()))return;if(!o.parent?.some(e=>"decl"===e.type&&("display"===e.prop.toLowerCase()&&"grid"===e.value.toLowerCase())))return;const p=`grid-${o.prop.toLowerCase()}`,s=o.parent?.some(e=>"decl"===e.type&&e.prop.toLowerCase()===p);s||(o.cloneBefore({prop:p}),r.preserve||o.remove())}}};creator.postcss=!0;export{creator as default}; +const e=["column-gap","gap","row-gap"],creator=o=>{const r=Object.assign({preserve:!0},o);return{postcssPlugin:"postcss-gap-properties",Declaration(o){if(!e.includes(o.prop.toLowerCase()))return;if(!o.parent?.some(e=>"decl"===e.type&&("display"===e.prop.toLowerCase()&&"grid"===e.value.toLowerCase())))return;const s=`grid-${o.prop.toLowerCase()}`,p=o.parent?.some(e=>"decl"===e.type&&e.prop.toLowerCase()===s);p||(o.cloneBefore({prop:s}),r.preserve||o.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-gap-properties/package.json b/plugins/postcss-gap-properties/package.json index 41ae2984f..397d4eade 100644 --- a/plugins/postcss-gap-properties/package.json +++ b/plugins/postcss-gap-properties/package.json @@ -29,20 +29,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-gap-properties/src/index.ts b/plugins/postcss-gap-properties/src/index.ts index ccf30adb3..2460c9cd4 100644 --- a/plugins/postcss-gap-properties/src/index.ts +++ b/plugins/postcss-gap-properties/src/index.ts @@ -69,3 +69,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-global-data/CHANGELOG.md b/plugins/postcss-global-data/CHANGELOG.md index c45b401d0..742581218 100644 --- a/plugins/postcss-global-data/CHANGELOG.md +++ b/plugins/postcss-global-data/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS global-data +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.1.0 _August 22, 2025_ diff --git a/plugins/postcss-global-data/dist/index.cjs b/plugins/postcss-global-data/dist/index.cjs deleted file mode 100644 index ec5bb5e06..000000000 --- a/plugins/postcss-global-data/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("node:path"),r=require("node:fs"),s=require("node:module");function parseImport(t,o,n,c){let a="";try{if(n.startsWith("node_modules://")){a=s.createRequire(process.cwd()).resolve(n.slice(15))}else if(n.startsWith("node_modules:")){a=s.createRequire(process.cwd()).resolve(n.slice(13))}else a=e.resolve(n)}catch(e){throw new Error(`Failed to read ${n} with error ${e instanceof Error?e.message:e}`)}if(c.has(a))return!1;c.add(a),o.result.messages.push({type:"dependency",plugin:"postcss-global-data",file:a,parent:t.source?.input?.file});const i=r.readFileSync(a,"utf8");return o.postcss.parse(i,{from:a})}const t="postcss-global-data",creator=e=>{const r=Object.assign({files:[],lateRemover:!1,prepend:!1},e);function insert(e,s,t){if(!r.prepend)return void s.each(r=>{e.append(r),t.add(r)});const o=Array.from(s.nodes);o.reverse(),o.forEach(r=>{e.prepend(r),t.add(r)})}if(!r.lateRemover)return{postcssPlugin:t,prepare(){const e=new Set,s=new Set;return{postcssPlugin:t,Once(t,o){r.files.forEach(r=>{const n=parseImport(t,o,r,s);n&&insert(t,n,e)})},OnceExit(){e.forEach(e=>{e.remove()}),s.clear(),e.clear()}}}};const s=new WeakSet;return{postcssPlugin:t,plugins:[{postcssPlugin:t,prepare(){const e=new Set;return{postcssPlugin:t,Once(t,o){r.files.forEach(r=>{const n=parseImport(t,o,r,e);n&&insert(t,n,s)})},OnceExit(){e.clear()}}}},{postcssPlugin:t+"/late-remover",OnceExit(e){e.each(e=>{s.has(e)&&e.remove()})}}]}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-global-data/dist/index.d.ts b/plugins/postcss-global-data/dist/index.d.ts index 92d4432d1..8d0a015e2 100644 --- a/plugins/postcss-global-data/dist/index.d.ts +++ b/plugins/postcss-global-data/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-global-data plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-global-data/dist/index.mjs b/plugins/postcss-global-data/dist/index.mjs index a5a5e2ed7..849d39e1e 100644 --- a/plugins/postcss-global-data/dist/index.mjs +++ b/plugins/postcss-global-data/dist/index.mjs @@ -1 +1 @@ -import e from"node:path";import r from"node:fs";import s from"node:module";function parseImport(t,o,n,c){let a="";try{if(n.startsWith("node_modules://")){a=s.createRequire(process.cwd()).resolve(n.slice(15))}else if(n.startsWith("node_modules:")){a=s.createRequire(process.cwd()).resolve(n.slice(13))}else a=e.resolve(n)}catch(e){throw new Error(`Failed to read ${n} with error ${e instanceof Error?e.message:e}`)}if(c.has(a))return!1;c.add(a),o.result.messages.push({type:"dependency",plugin:"postcss-global-data",file:a,parent:t.source?.input?.file});const p=r.readFileSync(a,"utf8");return o.postcss.parse(p,{from:a})}const t="postcss-global-data",creator=e=>{const r=Object.assign({files:[],lateRemover:!1,prepend:!1},e);function insert(e,s,t){if(!r.prepend)return void s.each(r=>{e.append(r),t.add(r)});const o=Array.from(s.nodes);o.reverse(),o.forEach(r=>{e.prepend(r),t.add(r)})}if(!r.lateRemover)return{postcssPlugin:t,prepare(){const e=new Set,s=new Set;return{postcssPlugin:t,Once(t,o){r.files.forEach(r=>{const n=parseImport(t,o,r,s);n&&insert(t,n,e)})},OnceExit(){e.forEach(e=>{e.remove()}),s.clear(),e.clear()}}}};const s=new WeakSet;return{postcssPlugin:t,plugins:[{postcssPlugin:t,prepare(){const e=new Set;return{postcssPlugin:t,Once(t,o){r.files.forEach(r=>{const n=parseImport(t,o,r,e);n&&insert(t,n,s)})},OnceExit(){e.clear()}}}},{postcssPlugin:t+"/late-remover",OnceExit(e){e.each(e=>{s.has(e)&&e.remove()})}}]}};creator.postcss=!0;export{creator as default}; +import e from"node:path";import s from"node:fs";import r from"node:module";function parseImport(t,o,n,c){let a="";try{if(n.startsWith("node_modules://")){a=r.createRequire(process.cwd()).resolve(n.slice(15))}else if(n.startsWith("node_modules:")){a=r.createRequire(process.cwd()).resolve(n.slice(13))}else a=e.resolve(n)}catch(e){throw new Error(`Failed to read ${n} with error ${e instanceof Error?e.message:e}`)}if(c.has(a))return!1;c.add(a),o.result.messages.push({type:"dependency",plugin:"postcss-global-data",file:a,parent:t.source?.input?.file});const p=s.readFileSync(a,"utf8");return o.postcss.parse(p,{from:a})}const t="postcss-global-data",creator=e=>{const s=Object.assign({files:[],lateRemover:!1,prepend:!1},e);function insert(e,r,t){if(!s.prepend)return void r.each(s=>{e.append(s),t.add(s)});const o=Array.from(r.nodes);o.reverse(),o.forEach(s=>{e.prepend(s),t.add(s)})}if(!s.lateRemover)return{postcssPlugin:t,prepare(){const e=new Set,r=new Set;return{postcssPlugin:t,Once(t,o){s.files.forEach(s=>{const n=parseImport(t,o,s,r);n&&insert(t,n,e)})},OnceExit(){e.forEach(e=>{e.remove()}),r.clear(),e.clear()}}}};const r=new WeakSet;return{postcssPlugin:t,plugins:[{postcssPlugin:t,prepare(){const e=new Set;return{postcssPlugin:t,Once(t,o){s.files.forEach(s=>{const n=parseImport(t,o,s,e);n&&insert(t,n,r)})},OnceExit(){e.clear()}}}},{postcssPlugin:t+"/late-remover",OnceExit(e){e.each(e=>{r.has(e)&&e.remove()})}}]}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-global-data/package.json b/plugins/postcss-global-data/package.json index 6c65b2135..8b3c5c18c 100644 --- a/plugins/postcss-global-data/package.json +++ b/plugins/postcss-global-data/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-global-data/src/index.ts b/plugins/postcss-global-data/src/index.ts index e84d39d97..7015fc343 100644 --- a/plugins/postcss-global-data/src/index.ts +++ b/plugins/postcss-global-data/src/index.ts @@ -121,3 +121,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-gradients-interpolation-method/CHANGELOG.md b/plugins/postcss-gradients-interpolation-method/CHANGELOG.md index 592c9f9c6..40087ee7b 100644 --- a/plugins/postcss-gradients-interpolation-method/CHANGELOG.md +++ b/plugins/postcss-gradients-interpolation-method/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Gradients Interpolation Method +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 5.0.12 _September 21, 2025_ diff --git a/plugins/postcss-gradients-interpolation-method/dist/index.cjs b/plugins/postcss-gradients-interpolation-method/dist/index.cjs deleted file mode 100644 index 67f088592..000000000 --- a/plugins/postcss-gradients-interpolation-method/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),o=require("@csstools/utilities"),t=require("@csstools/css-parser-algorithms"),i=require("@csstools/css-tokenizer"),n=require("@csstools/css-color-parser");const s=/(?:repeating-)?(?:linear|radial|conic)-gradient\(/i,r=/\bin\b/i,a={test:e=>s.test(e)&&r.test(e)},l=/^(repeating-)?(linear|radial|conic)-gradient$/i;function interpolateColorsInColorStopsList(e,o,s,r=!1){const a=[],l=[];for(let r=0;r0&&N.some(e=>!t.isCommentNode(e))&&N.push(new t.TokenNode([i.TokenType.Comma,",",-1,-1,void 0]),new t.WhitespaceNode([[i.TokenType.Whitespace," ",-1,-1,void 0]])),trim([...N,...trim(g)])}function trim(e){let o=0,i=e.length-1;for(let i=0;i=0;o--)if(!t.isWhitespaceNode(e[o])){i=o;break}return e.slice(o,i+1)}const basePlugin=e=>({postcssPlugin:"postcss-gradients-interpolation-method",Declaration(n){if(!a.test(n.value))return;if(o.hasFallback(n))return;if(o.hasSupportsAtRuleAncestor(n,a))return;const s=i.tokenize({css:n.value}),r=t.stringify(t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(s),e=>{if(!t.isFunctionNode(e))return;const o=modifyGradientFunctionComponentValues(e);o&&(e.value=o)}));if(r===n.value)return;const l=t.stringify(t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(s),e=>{if(!t.isFunctionNode(e))return;const o=modifyGradientFunctionComponentValues(e,!0);o&&(e.value=o)}));n.cloneBefore({value:r}),r!==l&&n.cloneBefore({value:l}),e?.preserve||n.remove()}});basePlugin.postcss=!0;const postcssPlugin=o=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},o);return t.enableProgressiveCustomProperties?{postcssPlugin:"postcss-gradients-interpolation-method",plugins:[e(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-gradients-interpolation-method/dist/index.d.ts b/plugins/postcss-gradients-interpolation-method/dist/index.d.ts index 6565bf2a9..1356813eb 100644 --- a/plugins/postcss-gradients-interpolation-method/dist/index.d.ts +++ b/plugins/postcss-gradients-interpolation-method/dist/index.d.ts @@ -11,5 +11,6 @@ export declare type pluginOptions = { /** Transform gradients with interpolation methods in CSS. */ declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-gradients-interpolation-method/dist/index.mjs b/plugins/postcss-gradients-interpolation-method/dist/index.mjs index 03f968959..b58817fd6 100644 --- a/plugins/postcss-gradients-interpolation-method/dist/index.mjs +++ b/plugins/postcss-gradients-interpolation-method/dist/index.mjs @@ -1 +1 @@ -import o from"@csstools/postcss-progressive-custom-properties";import{hasFallback as e,hasSupportsAtRuleAncestor as t}from"@csstools/utilities";import{WhitespaceNode as i,TokenNode as r,FunctionNode as n,isCommentNode as s,isWhitespaceNode as l,isTokenNode as a,stringify as c,replaceComponentValues as u,parseCommaSeparatedListOfComponentValues as p,isFunctionNode as v}from"@csstools/css-parser-algorithms";import{TokenType as f,isTokenComma as h,isTokenIdent as m,tokenize as g}from"@csstools/css-tokenizer";import{serializeP3 as d,color as w,colorDataFitsRGB_Gamut as D,serializeRGB as C,SyntaxFlag as b}from"@csstools/css-color-parser";const x=/(?:repeating-)?(?:linear|radial|conic)-gradient\(/i,W=/\bin\b/i,P={test:o=>x.test(o)&&W.test(o)},A=/^(repeating-)?(linear|radial|conic)-gradient$/i;function interpolateColorsInColorStopsList(o,e,t,s=!1){const l=[],a=[];for(let s=0;s0&&C.some(o=>!s(o))&&C.push(new r([f.Comma,",",-1,-1,void 0]),new i([[f.Whitespace," ",-1,-1,void 0]])),trim([...C,...trim(D)])}function trim(o){let e=0,t=o.length-1;for(let t=0;t=0;e--)if(!l(o[e])){t=e;break}return o.slice(e,t+1)}const basePlugin=o=>({postcssPlugin:"postcss-gradients-interpolation-method",Declaration(i){if(!P.test(i.value))return;if(e(i))return;if(t(i,P))return;const r=g({css:i.value}),n=c(u(p(r),o=>{if(!v(o))return;const e=modifyGradientFunctionComponentValues(o);e&&(o.value=e)}));if(n===i.value)return;const s=c(u(p(r),o=>{if(!v(o))return;const e=modifyGradientFunctionComponentValues(o,!0);e&&(o.value=e)}));i.cloneBefore({value:n}),n!==s&&i.cloneBefore({value:s}),o?.preserve||i.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},e);return t.enableProgressiveCustomProperties?{postcssPlugin:"postcss-gradients-interpolation-method",plugins:[o(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import o from"@csstools/postcss-progressive-custom-properties";import{hasFallback as e,hasSupportsAtRuleAncestor as t}from"@csstools/utilities";import{WhitespaceNode as r,TokenNode as i,FunctionNode as n,isCommentNode as s,isWhitespaceNode as l,isTokenNode as a,stringify as c,replaceComponentValues as u,parseCommaSeparatedListOfComponentValues as p,isFunctionNode as v}from"@csstools/css-parser-algorithms";import{TokenType as f,isTokenComma as h,isTokenIdent as m,tokenize as d}from"@csstools/css-tokenizer";import{serializeP3 as g,color as w,colorDataFitsRGB_Gamut as D,serializeRGB as C,SyntaxFlag as b}from"@csstools/css-color-parser";const x=/(?:repeating-)?(?:linear|radial|conic)-gradient\(/i,W=/\bin\b/i,P={test:o=>x.test(o)&&W.test(o)},A=/^(repeating-)?(linear|radial|conic)-gradient$/i;function interpolateColorsInColorStopsList(o,e,t,s=!1){const l=[],a=[];for(let s=0;s0&&C.some(o=>!s(o))&&C.push(new i([f.Comma,",",-1,-1,void 0]),new r([[f.Whitespace," ",-1,-1,void 0]])),trim([...C,...trim(D)])}function trim(o){let e=0,t=o.length-1;for(let t=0;t=0;e--)if(!l(o[e])){t=e;break}return o.slice(e,t+1)}const basePlugin=o=>({postcssPlugin:"postcss-gradients-interpolation-method",Declaration(r){if(!P.test(r.value))return;if(e(r))return;if(t(r,P))return;const i=d({css:r.value}),n=c(u(p(i),o=>{if(!v(o))return;const e=modifyGradientFunctionComponentValues(o);e&&(o.value=e)}));if(n===r.value)return;const s=c(u(p(i),o=>{if(!v(o))return;const e=modifyGradientFunctionComponentValues(o,!0);e&&(o.value=e)}));r.cloneBefore({value:n}),n!==s&&r.cloneBefore({value:s}),o?.preserve||r.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},e);return t.enableProgressiveCustomProperties?{postcssPlugin:"postcss-gradients-interpolation-method",plugins:[o(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-gradients-interpolation-method/package.json b/plugins/postcss-gradients-interpolation-method/package.json index b5f2aec1c..7f0269a2e 100644 --- a/plugins/postcss-gradients-interpolation-method/package.json +++ b/plugins/postcss-gradients-interpolation-method/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-gradients-interpolation-method/src/index.ts b/plugins/postcss-gradients-interpolation-method/src/index.ts index cb733055b..9be56e61b 100644 --- a/plugins/postcss-gradients-interpolation-method/src/index.ts +++ b/plugins/postcss-gradients-interpolation-method/src/index.ts @@ -106,3 +106,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-hwb-function/CHANGELOG.md b/plugins/postcss-hwb-function/CHANGELOG.md index c40f32cbc..ab26b251b 100644 --- a/plugins/postcss-hwb-function/CHANGELOG.md +++ b/plugins/postcss-hwb-function/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS HWB Function +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.12 _September 21, 2025_ diff --git a/plugins/postcss-hwb-function/dist/index.cjs b/plugins/postcss-hwb-function/dist/index.cjs deleted file mode 100644 index fa953d213..000000000 --- a/plugins/postcss-hwb-function/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/css-color-parser"),t=require("@csstools/utilities"),r=require("@csstools/css-parser-algorithms"),o=require("@csstools/css-tokenizer");const a=/\bhwb\(/i,n=/^hwb$/i,basePlugin=s=>({postcssPlugin:"postcss-hwb-function",Declaration(i){const c=i.value;if(!a.test(c))return;if(t.hasFallback(i))return;if(t.hasSupportsAtRuleAncestor(i,a))return;const l=r.replaceComponentValues(r.parseCommaSeparatedListOfComponentValues(o.tokenize({css:c})),s=>{if(!r.isFunctionNode(s)||!n.test(s.getName()))return;const t=e.color(s);return t&&!(t.syntaxFlags.has(e.SyntaxFlag.Experimental)||t.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords)||t.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax))?e.serializeRGB(t):void 0}),u=r.stringify(l);u!==c&&(i.cloneBefore({value:u}),s?.preserve||i.remove())}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},e);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-hwb-function",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-hwb-function/dist/index.d.ts b/plugins/postcss-hwb-function/dist/index.d.ts index f502980c3..701546e30 100644 --- a/plugins/postcss-hwb-function/dist/index.d.ts +++ b/plugins/postcss-hwb-function/dist/index.d.ts @@ -17,5 +17,6 @@ export declare type pluginOptions = { /** Transform hwb() functions in CSS. */ declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-hwb-function/dist/index.mjs b/plugins/postcss-hwb-function/dist/index.mjs index 022fa28b8..602c1282d 100644 --- a/plugins/postcss-hwb-function/dist/index.mjs +++ b/plugins/postcss-hwb-function/dist/index.mjs @@ -1 +1 @@ -import s from"@csstools/postcss-progressive-custom-properties";import{color as o,SyntaxFlag as e,serializeRGB as t}from"@csstools/css-color-parser";import{hasFallback as r,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as c,isFunctionNode as a,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as l}from"@csstools/css-tokenizer";const u=/\bhwb\(/i,m=/^hwb$/i,basePlugin=s=>({postcssPlugin:"postcss-hwb-function",Declaration(f){const g=f.value;if(!u.test(g))return;if(r(f))return;if(i(f,u))return;const v=n(c(l({css:g})),s=>{if(!a(s)||!m.test(s.getName()))return;const r=o(s);return r&&!(r.syntaxFlags.has(e.Experimental)||r.syntaxFlags.has(e.HasNoneKeywords)||r.syntaxFlags.has(e.RelativeColorSyntax))?t(r):void 0}),b=p(v);b!==g&&(f.cloneBefore({value:b}),s?.preserve||f.remove())}});basePlugin.postcss=!0;const postcssPlugin=o=>{const e=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},o);return e.enableProgressiveCustomProperties&&e.preserve?{postcssPlugin:"postcss-hwb-function",plugins:[s(),basePlugin(e)]}:basePlugin(e)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import s from"@csstools/postcss-progressive-custom-properties";import{color as o,SyntaxFlag as e,serializeRGB as t}from"@csstools/css-color-parser";import{hasFallback as r,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as c,isFunctionNode as a,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as l}from"@csstools/css-tokenizer";const u=/\bhwb\(/i,m=/^hwb$/i,basePlugin=s=>({postcssPlugin:"postcss-hwb-function",Declaration(f){const g=f.value;if(!u.test(g))return;if(r(f))return;if(i(f,u))return;const v=n(c(l({css:g})),s=>{if(!a(s)||!m.test(s.getName()))return;const r=o(s);return r&&!(r.syntaxFlags.has(e.Experimental)||r.syntaxFlags.has(e.HasNoneKeywords)||r.syntaxFlags.has(e.RelativeColorSyntax))?t(r):void 0}),b=p(v);b!==g&&(f.cloneBefore({value:b}),s?.preserve||f.remove())}});basePlugin.postcss=!0;const postcssPlugin=o=>{const e=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},o);return e.enableProgressiveCustomProperties&&e.preserve?{postcssPlugin:"postcss-hwb-function",plugins:[s(),basePlugin(e)]}:basePlugin(e)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-hwb-function/package.json b/plugins/postcss-hwb-function/package.json index 8f1604527..611e1fb16 100644 --- a/plugins/postcss-hwb-function/package.json +++ b/plugins/postcss-hwb-function/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-hwb-function/src/index.ts b/plugins/postcss-hwb-function/src/index.ts index f1a38254d..dada66621 100644 --- a/plugins/postcss-hwb-function/src/index.ts +++ b/plugins/postcss-hwb-function/src/index.ts @@ -103,3 +103,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-ic-unit/CHANGELOG.md b/plugins/postcss-ic-unit/CHANGELOG.md index 23573f894..ac4aa3be0 100644 --- a/plugins/postcss-ic-unit/CHANGELOG.md +++ b/plugins/postcss-ic-unit/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS IC Unit +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.4 _September 21, 2025_ diff --git a/plugins/postcss-ic-unit/dist/index.cjs b/plugins/postcss-ic-unit/dist/index.cjs deleted file mode 100644 index 9c7a186e7..000000000 --- a/plugins/postcss-ic-unit/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("postcss-value-parser"),r=require("@csstools/utilities");const t=/ic\b/i,o=/\(font-size: \d+ic\)/i,basePlugin=s=>({postcssPlugin:"postcss-ic-unit",Declaration(i){if(!t.test(i.value))return;if(r.hasFallback(i))return;if(r.hasSupportsAtRuleAncestor(i,o))return;const u=e(i.value);u.walk(s=>{if(!s.type||"word"!==s.type)return;const r=e.unit(s.value);r&&"ic"===r.unit.toLowerCase()&&(s.value=`${r.number}em`)});const c=String(u);c!==i.value&&(i.cloneBefore({value:c}),s?.preserve||i.remove())}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},e);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-ic-unit",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-ic-unit/dist/index.d.ts b/plugins/postcss-ic-unit/dist/index.d.ts index d894fc822..94de93526 100644 --- a/plugins/postcss-ic-unit/dist/index.d.ts +++ b/plugins/postcss-ic-unit/dist/index.d.ts @@ -10,5 +10,6 @@ export declare type pluginOptions = { declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-ic-unit/dist/index.mjs b/plugins/postcss-ic-unit/dist/index.mjs index 4906e9ff2..7d8c2f1ff 100644 --- a/plugins/postcss-ic-unit/dist/index.mjs +++ b/plugins/postcss-ic-unit/dist/index.mjs @@ -1 +1 @@ -import s from"@csstools/postcss-progressive-custom-properties";import e from"postcss-value-parser";import{hasFallback as t,hasSupportsAtRuleAncestor as r}from"@csstools/utilities";const o=/ic\b/i,i=/\(font-size: \d+ic\)/i,basePlugin=s=>({postcssPlugin:"postcss-ic-unit",Declaration(n){if(!o.test(n.value))return;if(t(n))return;if(r(n,i))return;const c=e(n.value);c.walk(s=>{if(!s.type||"word"!==s.type)return;const t=e.unit(s.value);t&&"ic"===t.unit.toLowerCase()&&(s.value=`${t.number}em`)});const u=String(c);u!==n.value&&(n.cloneBefore({value:u}),s?.preserve||n.remove())}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},e);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-ic-unit",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import s from"@csstools/postcss-progressive-custom-properties";import e from"postcss-value-parser";import{hasFallback as t,hasSupportsAtRuleAncestor as r}from"@csstools/utilities";const o=/ic\b/i,i=/\(font-size: \d+ic\)/i,basePlugin=s=>({postcssPlugin:"postcss-ic-unit",Declaration(n){if(!o.test(n.value))return;if(t(n))return;if(r(n,i))return;const u=e(n.value);u.walk(s=>{if(!s.type||"word"!==s.type)return;const t=e.unit(s.value);t&&"ic"===t.unit.toLowerCase()&&(s.value=`${t.number}em`)});const c=String(u);c!==n.value&&(n.cloneBefore({value:c}),s?.preserve||n.remove())}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},e);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-ic-unit",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-ic-unit/package.json b/plugins/postcss-ic-unit/package.json index 3634a6df7..f4cdec320 100644 --- a/plugins/postcss-ic-unit/package.json +++ b/plugins/postcss-ic-unit/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-ic-unit/src/index.ts b/plugins/postcss-ic-unit/src/index.ts index 437289f68..c7a8ebefc 100644 --- a/plugins/postcss-ic-unit/src/index.ts +++ b/plugins/postcss-ic-unit/src/index.ts @@ -87,3 +87,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-image-set-function/CHANGELOG.md b/plugins/postcss-image-set-function/CHANGELOG.md index 6087f2b09..9ee525824 100644 --- a/plugins/postcss-image-set-function/CHANGELOG.md +++ b/plugins/postcss-image-set-function/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS image-set() Function +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 7.0.0 _August 3, 2024_ diff --git a/plugins/postcss-image-set-function/dist/index.cjs b/plugins/postcss-image-set-function/dist/index.cjs deleted file mode 100644 index 2134c3eae..000000000 --- a/plugins/postcss-image-set-function/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser"),t=require("@csstools/utilities");function isComma(e){return!!e&&"div"===e.type&&","===e.value}const n=/^(?:cross-fade|image|(?:repeating-)?(?:conic|linear|radial)-gradient|url|var)$/i;function getImage(t){return!(!t||!t.type)&&("string"===t.type?"url("+e.stringify(t)+")":!("function"!==t.type||!n.test(t.value))&&e.stringify(t))}const i=new Map([["dpcm",2.54],["dpi",1],["dppx",96],["x",96]]);function getMedia(e,t,n){if("boolean"==typeof e)return!1;const i=Math.floor(e/96*100)/100;return t.atRule({name:"media",params:`(-webkit-min-device-pixel-ratio: ${i}), (min-resolution: ${e}dpi)`,source:n.source})}function getMediaDPI(t){if(!t)return!1;if("word"!==t.type)return!1;if(!isNumericNode(t))return!1;const n=e.unit(t.value);if(!n)return!1;const r=i.get(n.unit.toLowerCase());return!!r&&Number(n.number)*r}function isNumericNode(t){if(!t||!t.value)return!1;try{return!1!==e.unit(t.value)}catch{return!1}}const handleInvalidation=(e,t,n)=>{if("warn"===e.oninvalid)e.decl.warn(e.result,t,{word:String(n)});else if("throw"===e.oninvalid)throw e.decl.error(t,{word:String(n)})},processImageSet=(t,n,i)=>{const r=n.parent;if(!r)return;const o=new Map,s=n.value;for(let r=0;re-t),u=a.map(e=>o.get(e)?.atRule).filter(e=>!!e);if(!u.length)return;const l=o.get(a[0])?.value;if(!l)return;const c=u.slice(1);c.length&&r.after(c),n.cloneBefore({value:l.trim()}),i.preserve||(n.remove(),r.nodes?.length||r.remove())},r=/(?:^|[^\w-])(?:-webkit-)?image-set\(/i,o=/^(?:-webkit-)?image-set$/i,creator=n=>{const i=!("preserve"in Object(n))||Boolean(n?.preserve),s="onInvalid"in Object(n)?n?.onInvalid:"ignore";if("oninvalid"in Object(n))throw new Error('"oninvalid" was changed to "onInvalid" to match other plugins with similar options');return{postcssPlugin:"postcss-image-set-function",Declaration(n,{result:a,postcss:u}){const l=n.value;if(!r.test(l))return;if(t.hasFallback(n))return;let c;try{c=e(l)}catch{n.warn(a,`Failed to parse value '${l}' as an image-set function. Leaving the original value intact.`)}if(void 0===c)return;const f=[];c.walk(t=>{if("function"!==t.type)return;if(!o.test(t.value))return;let i=!1;if(e.walk(t.nodes,e=>{"function"===e.type&&o.test(e.value)&&(i=!0)}),i)return handleInvalidation({decl:n,oninvalid:s,result:a},"nested image-set functions are not allowed",e.stringify(t)),!1;const r=t.nodes.filter(e=>"comment"!==e.type&&"space"!==e.type);f.push({imageSetFunction:t,imageSetOptionNodes:r})}),processImageSet(f,n,{decl:n,oninvalid:s,preserve:i,result:a,postcss:u})}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-image-set-function/dist/index.d.ts b/plugins/postcss-image-set-function/dist/index.d.ts index 5eb630f7c..6bc6b651b 100644 --- a/plugins/postcss-image-set-function/dist/index.d.ts +++ b/plugins/postcss-image-set-function/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-image-set-function plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-image-set-function/dist/index.mjs b/plugins/postcss-image-set-function/dist/index.mjs index cda2f9609..2037754c4 100644 --- a/plugins/postcss-image-set-function/dist/index.mjs +++ b/plugins/postcss-image-set-function/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";import{hasFallback as t}from"@csstools/utilities";function isComma(e){return!!e&&"div"===e.type&&","===e.value}const n=/^(?:cross-fade|image|(?:repeating-)?(?:conic|linear|radial)-gradient|url|var)$/i;function getImage(t){return!(!t||!t.type)&&("string"===t.type?"url("+e.stringify(t)+")":!("function"!==t.type||!n.test(t.value))&&e.stringify(t))}const i=new Map([["dpcm",2.54],["dpi",1],["dppx",96],["x",96]]);function getMedia(e,t,n){if("boolean"==typeof e)return!1;const i=Math.floor(e/96*100)/100;return t.atRule({name:"media",params:`(-webkit-min-device-pixel-ratio: ${i}), (min-resolution: ${e}dpi)`,source:n.source})}function getMediaDPI(t){if(!t)return!1;if("word"!==t.type)return!1;if(!isNumericNode(t))return!1;const n=e.unit(t.value);if(!n)return!1;const r=i.get(n.unit.toLowerCase());return!!r&&Number(n.number)*r}function isNumericNode(t){if(!t||!t.value)return!1;try{return!1!==e.unit(t.value)}catch{return!1}}const handleInvalidation=(e,t,n)=>{if("warn"===e.oninvalid)e.decl.warn(e.result,t,{word:String(n)});else if("throw"===e.oninvalid)throw e.decl.error(t,{word:String(n)})},processImageSet=(t,n,i)=>{const r=n.parent;if(!r)return;const o=new Map,s=n.value;for(let r=0;re-t),u=a.map(e=>o.get(e)?.atRule).filter(e=>!!e);if(!u.length)return;const l=o.get(a[0])?.value;if(!l)return;const c=u.slice(1);c.length&&r.after(c),n.cloneBefore({value:l.trim()}),i.preserve||(n.remove(),r.nodes?.length||r.remove())},r=/(?:^|[^\w-])(?:-webkit-)?image-set\(/i,o=/^(?:-webkit-)?image-set$/i,creator=n=>{const i=!("preserve"in Object(n))||Boolean(n?.preserve),s="onInvalid"in Object(n)?n?.onInvalid:"ignore";if("oninvalid"in Object(n))throw new Error('"oninvalid" was changed to "onInvalid" to match other plugins with similar options');return{postcssPlugin:"postcss-image-set-function",Declaration(n,{result:a,postcss:u}){const l=n.value;if(!r.test(l))return;if(t(n))return;let c;try{c=e(l)}catch{n.warn(a,`Failed to parse value '${l}' as an image-set function. Leaving the original value intact.`)}if(void 0===c)return;const f=[];c.walk(t=>{if("function"!==t.type)return;if(!o.test(t.value))return;let i=!1;if(e.walk(t.nodes,e=>{"function"===e.type&&o.test(e.value)&&(i=!0)}),i)return handleInvalidation({decl:n,oninvalid:s,result:a},"nested image-set functions are not allowed",e.stringify(t)),!1;const r=t.nodes.filter(e=>"comment"!==e.type&&"space"!==e.type);f.push({imageSetFunction:t,imageSetOptionNodes:r})}),processImageSet(f,n,{decl:n,oninvalid:s,preserve:i,result:a,postcss:u})}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-value-parser";import{hasFallback as t}from"@csstools/utilities";function isComma(e){return!!e&&"div"===e.type&&","===e.value}const n=/^(?:cross-fade|image|(?:repeating-)?(?:conic|linear|radial)-gradient|url|var)$/i;function getImage(t){return!(!t||!t.type)&&("string"===t.type?"url("+e.stringify(t)+")":!("function"!==t.type||!n.test(t.value))&&e.stringify(t))}const i=new Map([["dpcm",2.54],["dpi",1],["dppx",96],["x",96]]);function getMedia(e,t,n){if("boolean"==typeof e)return!1;const i=Math.floor(e/96*100)/100;return t.atRule({name:"media",params:`(-webkit-min-device-pixel-ratio: ${i}), (min-resolution: ${e}dpi)`,source:n.source})}function getMediaDPI(t){if(!t)return!1;if("word"!==t.type)return!1;if(!isNumericNode(t))return!1;const n=e.unit(t.value);if(!n)return!1;const r=i.get(n.unit.toLowerCase());return!!r&&Number(n.number)*r}function isNumericNode(t){if(!t||!t.value)return!1;try{return!1!==e.unit(t.value)}catch{return!1}}const handleInvalidation=(e,t,n)=>{if("warn"===e.oninvalid)e.decl.warn(e.result,t,{word:String(n)});else if("throw"===e.oninvalid)throw e.decl.error(t,{word:String(n)})},processImageSet=(t,n,i)=>{const r=n.parent;if(!r)return;const o=new Map,s=n.value;for(let r=0;re-t),u=a.map(e=>o.get(e)?.atRule).filter(e=>!!e);if(!u.length)return;const l=o.get(a[0])?.value;if(!l)return;const c=u.slice(1);c.length&&r.after(c),n.cloneBefore({value:l.trim()}),i.preserve||(n.remove(),r.nodes?.length||r.remove())},r=/(?:^|[^\w-])(?:-webkit-)?image-set\(/i,o=/^(?:-webkit-)?image-set$/i,creator=n=>{const i=!("preserve"in Object(n))||Boolean(n?.preserve),s="onInvalid"in Object(n)?n?.onInvalid:"ignore";if("oninvalid"in Object(n))throw new Error('"oninvalid" was changed to "onInvalid" to match other plugins with similar options');return{postcssPlugin:"postcss-image-set-function",Declaration(n,{result:a,postcss:u}){const l=n.value;if(!r.test(l))return;if(t(n))return;let c;try{c=e(l)}catch{n.warn(a,`Failed to parse value '${l}' as an image-set function. Leaving the original value intact.`)}if(void 0===c)return;const f=[];c.walk(t=>{if("function"!==t.type)return;if(!o.test(t.value))return;let i=!1;if(e.walk(t.nodes,e=>{"function"===e.type&&o.test(e.value)&&(i=!0)}),i)return handleInvalidation({decl:n,oninvalid:s,result:a},"nested image-set functions are not allowed",e.stringify(t)),!1;const r=t.nodes.filter(e=>"comment"!==e.type&&"space"!==e.type);f.push({imageSetFunction:t,imageSetOptionNodes:r})}),processImageSet(f,n,{decl:n,oninvalid:s,preserve:i,result:a,postcss:u})}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-image-set-function/package.json b/plugins/postcss-image-set-function/package.json index 9d07185bb..49aa64d24 100644 --- a/plugins/postcss-image-set-function/package.json +++ b/plugins/postcss-image-set-function/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-image-set-function/src/index.ts b/plugins/postcss-image-set-function/src/index.ts index 4f582323f..691478216 100644 --- a/plugins/postcss-image-set-function/src/index.ts +++ b/plugins/postcss-image-set-function/src/index.ts @@ -115,4 +115,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-initial/CHANGELOG.md b/plugins/postcss-initial/CHANGELOG.md index 85f4e7a51..a4b229148 100644 --- a/plugins/postcss-initial/CHANGELOG.md +++ b/plugins/postcss-initial/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Initial +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.1 _February 12, 2025_ diff --git a/plugins/postcss-initial/dist/index.cjs b/plugins/postcss-initial/dist/index.cjs deleted file mode 100644 index eb19cec6a..000000000 --- a/plugins/postcss-initial/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";const o=new Map([["animation","none 0s ease 0s 1 normal none running"],["animation-delay","0s"],["animation-direction","normal"],["animation-duration","0s"],["animation-fill-mode","none"],["animation-iteration-count","1"],["animation-name","none"],["animation-play-state","running"],["animation-timing-function","ease"],["backface-visibility","visible"],["background","transparent none repeat 0 0 / auto auto padding-box border-box scroll"],["background-attachment","scroll"],["background-clip","border-box"],["background-color","transparent"],["background-image","none"],["background-origin","padding-box"],["background-position","0 0"],["background-position-x","0"],["background-position-y","0"],["background-repeat","repeat"],["background-size","auto auto"],["border","medium none currentcolor"],["border-style","none"],["border-width","medium"],["border-color","currentcolor"],["border-bottom","0"],["border-bottom-color","currentcolor"],["border-bottom-left-radius","0"],["border-bottom-right-radius","0"],["border-bottom-style","none"],["border-bottom-width","medium"],["border-collapse","separate"],["border-image","none"],["border-left","0"],["border-left-color","currentcolor"],["border-left-style","none"],["border-left-width","medium"],["border-radius","0"],["border-right","0"],["border-right-color","currentcolor"],["border-right-style","none"],["border-right-width","medium"],["border-spacing","0"],["border-top","0"],["border-top-color","currentcolor"],["border-top-left-radius","0"],["border-top-right-radius","0"],["border-top-style","none"],["border-top-width","medium"],["bottom","auto"],["box-shadow","none"],["box-sizing","content-box"],["caption-side","top"],["clear","none"],["clip","auto"],["color","#000"],["columns","auto"],["column-count","auto"],["column-fill","balance"],["column-gap","normal"],["column-rule","medium none currentcolor"],["column-rule-color","currentcolor"],["column-rule-style","none"],["column-rule-width","medium"],["column-span","1"],["column-width","auto"],["content","normal"],["counter-increment","none"],["counter-reset","none"],["cursor","auto"],["direction","ltr"],["display","inline"],["empty-cells","show"],["float","none"],["font-family","serif"],["font-size","medium"],["font-style","normal"],["font-variant","normal"],["font-weight","normal"],["font-stretch","normal"],["line-height","normal"],["height","auto"],["hyphens","none"],["left","auto"],["letter-spacing","normal"],["list-style","disc outside none"],["list-style-image","none"],["list-style-position","outside"],["list-style-type","disc"],["margin","0"],["margin-bottom","0"],["margin-left","0"],["margin-right","0"],["margin-top","0"],["max-height","none"],["max-width","none"],["min-height","0"],["min-width","0"],["opacity","1"],["orphans","2"],["outline","medium none currentcolor"],["outline-color","currentcolor"],["outline-style","none"],["outline-width","medium"],["overflow","visible"],["overflow-x","visible"],["overflow-y","visible"],["padding","0"],["padding-bottom","0"],["padding-left","0"],["padding-right","0"],["padding-top","0"],["page-break-after","auto"],["page-break-before","auto"],["page-break-inside","auto"],["perspective","none"],["perspective-origin","50% 50%"],["position","static"],["quotes",'"“" "”" "‘" "’"'],["right","auto"],["tab-size","8"],["table-layout","auto"],["text-align","left"],["text-align-last","auto"],["text-decoration","none"],["text-decoration-color","currentcolor"],["text-decoration-line","none"],["text-decoration-style","solid"],["text-indent","0"],["text-shadow","none"],["text-transform","none"],["top","auto"],["transform","none"],["transform-origin","50% 50% 0"],["transform-style","flat"],["transition","none 0s ease 0s"],["transition-delay","0s"],["transition-duration","0s"],["transition-property","none"],["transition-timing-function","ease"],["unicode-bidi","normal"],["vertical-align","baseline"],["visibility","visible"],["white-space","normal"],["widows","2"],["width","auto"],["word-spacing","normal"],["z-index","auto"]]),t=["animation","backface-visibility","background","border","border-collapse","border-image","border-radius","border-spacing","bottom","box-shadow","box-sizing","caption-side","clear","clip","color","columns","column-count","column-fill","column-gap","column-rule","column-span","column-width","content","counter-increment","counter-reset","cursor","display","empty-cells","float","font-family","font-size","font-style","font-variant","font-weight","font-stretch","line-height","font","height","hyphens","left","letter-spacing","list-style","margin","max-height","max-width","min-height","min-width","opacity","orphans","outline","overflow","overflow-x","overflow-y","padding","page-break-after","page-break-before","page-break-inside","perspective","perspective-origin","position","right","tab-size","table-layout","text-align","text-align-last","text-decoration","text-indent","text-shadow","text-transform","top","transform","transform-origin","transform-style","transition","vertical-align","visibility","white-space","widows","width","word-spacing","z-index"];function hasExactFallback(o,t){const e=o.parent;if(!e)return!1;const n=o.prop.toLowerCase();for(let r=e.index(o)-1;r>=0;r--){const o=e.nodes[r];if("decl"===o.type&&o.prop.toLowerCase()===n)return o.value===t}return!1}const e=/^\s?initial\s?$/i,n=/^font$/i,r=/^all$/i,i=["font-family","font-size","font-style","font-variant","font-weight","font-stretch","line-height"],creator=a=>{const l=Object.assign({preserve:!0},a);return{postcssPlugin:"postcss-initial",Declaration(a){if(a.variable)return;if(!e.test(a.value))return;let s;s=n.test(a.prop)?i:r.test(a.prop)?t:[a.prop.toLowerCase()];let c=!1;s.forEach(t=>{const e=o.get(t);e&&(hasExactFallback(a,e)||(c=!0,a.cloneBefore({prop:t,value:e})))}),!l.preserve&&c&&a.remove()}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-initial/dist/index.d.ts b/plugins/postcss-initial/dist/index.d.ts index 20f8fc5de..4e706e5ba 100644 --- a/plugins/postcss-initial/dist/index.d.ts +++ b/plugins/postcss-initial/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-initial plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-initial/dist/index.mjs b/plugins/postcss-initial/dist/index.mjs index a298b7f2f..f2cda65bd 100644 --- a/plugins/postcss-initial/dist/index.mjs +++ b/plugins/postcss-initial/dist/index.mjs @@ -1 +1 @@ -const o=new Map([["animation","none 0s ease 0s 1 normal none running"],["animation-delay","0s"],["animation-direction","normal"],["animation-duration","0s"],["animation-fill-mode","none"],["animation-iteration-count","1"],["animation-name","none"],["animation-play-state","running"],["animation-timing-function","ease"],["backface-visibility","visible"],["background","transparent none repeat 0 0 / auto auto padding-box border-box scroll"],["background-attachment","scroll"],["background-clip","border-box"],["background-color","transparent"],["background-image","none"],["background-origin","padding-box"],["background-position","0 0"],["background-position-x","0"],["background-position-y","0"],["background-repeat","repeat"],["background-size","auto auto"],["border","medium none currentcolor"],["border-style","none"],["border-width","medium"],["border-color","currentcolor"],["border-bottom","0"],["border-bottom-color","currentcolor"],["border-bottom-left-radius","0"],["border-bottom-right-radius","0"],["border-bottom-style","none"],["border-bottom-width","medium"],["border-collapse","separate"],["border-image","none"],["border-left","0"],["border-left-color","currentcolor"],["border-left-style","none"],["border-left-width","medium"],["border-radius","0"],["border-right","0"],["border-right-color","currentcolor"],["border-right-style","none"],["border-right-width","medium"],["border-spacing","0"],["border-top","0"],["border-top-color","currentcolor"],["border-top-left-radius","0"],["border-top-right-radius","0"],["border-top-style","none"],["border-top-width","medium"],["bottom","auto"],["box-shadow","none"],["box-sizing","content-box"],["caption-side","top"],["clear","none"],["clip","auto"],["color","#000"],["columns","auto"],["column-count","auto"],["column-fill","balance"],["column-gap","normal"],["column-rule","medium none currentcolor"],["column-rule-color","currentcolor"],["column-rule-style","none"],["column-rule-width","medium"],["column-span","1"],["column-width","auto"],["content","normal"],["counter-increment","none"],["counter-reset","none"],["cursor","auto"],["direction","ltr"],["display","inline"],["empty-cells","show"],["float","none"],["font-family","serif"],["font-size","medium"],["font-style","normal"],["font-variant","normal"],["font-weight","normal"],["font-stretch","normal"],["line-height","normal"],["height","auto"],["hyphens","none"],["left","auto"],["letter-spacing","normal"],["list-style","disc outside none"],["list-style-image","none"],["list-style-position","outside"],["list-style-type","disc"],["margin","0"],["margin-bottom","0"],["margin-left","0"],["margin-right","0"],["margin-top","0"],["max-height","none"],["max-width","none"],["min-height","0"],["min-width","0"],["opacity","1"],["orphans","2"],["outline","medium none currentcolor"],["outline-color","currentcolor"],["outline-style","none"],["outline-width","medium"],["overflow","visible"],["overflow-x","visible"],["overflow-y","visible"],["padding","0"],["padding-bottom","0"],["padding-left","0"],["padding-right","0"],["padding-top","0"],["page-break-after","auto"],["page-break-before","auto"],["page-break-inside","auto"],["perspective","none"],["perspective-origin","50% 50%"],["position","static"],["quotes",'"“" "”" "‘" "’"'],["right","auto"],["tab-size","8"],["table-layout","auto"],["text-align","left"],["text-align-last","auto"],["text-decoration","none"],["text-decoration-color","currentcolor"],["text-decoration-line","none"],["text-decoration-style","solid"],["text-indent","0"],["text-shadow","none"],["text-transform","none"],["top","auto"],["transform","none"],["transform-origin","50% 50% 0"],["transform-style","flat"],["transition","none 0s ease 0s"],["transition-delay","0s"],["transition-duration","0s"],["transition-property","none"],["transition-timing-function","ease"],["unicode-bidi","normal"],["vertical-align","baseline"],["visibility","visible"],["white-space","normal"],["widows","2"],["width","auto"],["word-spacing","normal"],["z-index","auto"]]),t=["animation","backface-visibility","background","border","border-collapse","border-image","border-radius","border-spacing","bottom","box-shadow","box-sizing","caption-side","clear","clip","color","columns","column-count","column-fill","column-gap","column-rule","column-span","column-width","content","counter-increment","counter-reset","cursor","display","empty-cells","float","font-family","font-size","font-style","font-variant","font-weight","font-stretch","line-height","font","height","hyphens","left","letter-spacing","list-style","margin","max-height","max-width","min-height","min-width","opacity","orphans","outline","overflow","overflow-x","overflow-y","padding","page-break-after","page-break-before","page-break-inside","perspective","perspective-origin","position","right","tab-size","table-layout","text-align","text-align-last","text-decoration","text-indent","text-shadow","text-transform","top","transform","transform-origin","transform-style","transition","vertical-align","visibility","white-space","widows","width","word-spacing","z-index"];function hasExactFallback(o,t){const e=o.parent;if(!e)return!1;const n=o.prop.toLowerCase();for(let r=e.index(o)-1;r>=0;r--){const o=e.nodes[r];if("decl"===o.type&&o.prop.toLowerCase()===n)return o.value===t}return!1}const e=/^\s?initial\s?$/i,n=/^font$/i,r=/^all$/i,i=["font-family","font-size","font-style","font-variant","font-weight","font-stretch","line-height"],creator=a=>{const l=Object.assign({preserve:!0},a);return{postcssPlugin:"postcss-initial",Declaration(a){if(a.variable)return;if(!e.test(a.value))return;let s;s=n.test(a.prop)?i:r.test(a.prop)?t:[a.prop.toLowerCase()];let c=!1;s.forEach(t=>{const e=o.get(t);e&&(hasExactFallback(a,e)||(c=!0,a.cloneBefore({prop:t,value:e})))}),!l.preserve&&c&&a.remove()}}};creator.postcss=!0;export{creator as default}; +const o=new Map([["animation","none 0s ease 0s 1 normal none running"],["animation-delay","0s"],["animation-direction","normal"],["animation-duration","0s"],["animation-fill-mode","none"],["animation-iteration-count","1"],["animation-name","none"],["animation-play-state","running"],["animation-timing-function","ease"],["backface-visibility","visible"],["background","transparent none repeat 0 0 / auto auto padding-box border-box scroll"],["background-attachment","scroll"],["background-clip","border-box"],["background-color","transparent"],["background-image","none"],["background-origin","padding-box"],["background-position","0 0"],["background-position-x","0"],["background-position-y","0"],["background-repeat","repeat"],["background-size","auto auto"],["border","medium none currentcolor"],["border-style","none"],["border-width","medium"],["border-color","currentcolor"],["border-bottom","0"],["border-bottom-color","currentcolor"],["border-bottom-left-radius","0"],["border-bottom-right-radius","0"],["border-bottom-style","none"],["border-bottom-width","medium"],["border-collapse","separate"],["border-image","none"],["border-left","0"],["border-left-color","currentcolor"],["border-left-style","none"],["border-left-width","medium"],["border-radius","0"],["border-right","0"],["border-right-color","currentcolor"],["border-right-style","none"],["border-right-width","medium"],["border-spacing","0"],["border-top","0"],["border-top-color","currentcolor"],["border-top-left-radius","0"],["border-top-right-radius","0"],["border-top-style","none"],["border-top-width","medium"],["bottom","auto"],["box-shadow","none"],["box-sizing","content-box"],["caption-side","top"],["clear","none"],["clip","auto"],["color","#000"],["columns","auto"],["column-count","auto"],["column-fill","balance"],["column-gap","normal"],["column-rule","medium none currentcolor"],["column-rule-color","currentcolor"],["column-rule-style","none"],["column-rule-width","medium"],["column-span","1"],["column-width","auto"],["content","normal"],["counter-increment","none"],["counter-reset","none"],["cursor","auto"],["direction","ltr"],["display","inline"],["empty-cells","show"],["float","none"],["font-family","serif"],["font-size","medium"],["font-style","normal"],["font-variant","normal"],["font-weight","normal"],["font-stretch","normal"],["line-height","normal"],["height","auto"],["hyphens","none"],["left","auto"],["letter-spacing","normal"],["list-style","disc outside none"],["list-style-image","none"],["list-style-position","outside"],["list-style-type","disc"],["margin","0"],["margin-bottom","0"],["margin-left","0"],["margin-right","0"],["margin-top","0"],["max-height","none"],["max-width","none"],["min-height","0"],["min-width","0"],["opacity","1"],["orphans","2"],["outline","medium none currentcolor"],["outline-color","currentcolor"],["outline-style","none"],["outline-width","medium"],["overflow","visible"],["overflow-x","visible"],["overflow-y","visible"],["padding","0"],["padding-bottom","0"],["padding-left","0"],["padding-right","0"],["padding-top","0"],["page-break-after","auto"],["page-break-before","auto"],["page-break-inside","auto"],["perspective","none"],["perspective-origin","50% 50%"],["position","static"],["quotes",'"“" "”" "‘" "’"'],["right","auto"],["tab-size","8"],["table-layout","auto"],["text-align","left"],["text-align-last","auto"],["text-decoration","none"],["text-decoration-color","currentcolor"],["text-decoration-line","none"],["text-decoration-style","solid"],["text-indent","0"],["text-shadow","none"],["text-transform","none"],["top","auto"],["transform","none"],["transform-origin","50% 50% 0"],["transform-style","flat"],["transition","none 0s ease 0s"],["transition-delay","0s"],["transition-duration","0s"],["transition-property","none"],["transition-timing-function","ease"],["unicode-bidi","normal"],["vertical-align","baseline"],["visibility","visible"],["white-space","normal"],["widows","2"],["width","auto"],["word-spacing","normal"],["z-index","auto"]]),t=["animation","backface-visibility","background","border","border-collapse","border-image","border-radius","border-spacing","bottom","box-shadow","box-sizing","caption-side","clear","clip","color","columns","column-count","column-fill","column-gap","column-rule","column-span","column-width","content","counter-increment","counter-reset","cursor","display","empty-cells","float","font-family","font-size","font-style","font-variant","font-weight","font-stretch","line-height","font","height","hyphens","left","letter-spacing","list-style","margin","max-height","max-width","min-height","min-width","opacity","orphans","outline","overflow","overflow-x","overflow-y","padding","page-break-after","page-break-before","page-break-inside","perspective","perspective-origin","position","right","tab-size","table-layout","text-align","text-align-last","text-decoration","text-indent","text-shadow","text-transform","top","transform","transform-origin","transform-style","transition","vertical-align","visibility","white-space","widows","width","word-spacing","z-index"];function hasExactFallback(o,t){const e=o.parent;if(!e)return!1;const n=o.prop.toLowerCase();for(let r=e.index(o)-1;r>=0;r--){const o=e.nodes[r];if("decl"===o.type&&o.prop.toLowerCase()===n)return o.value===t}return!1}const e=/^\s?initial\s?$/i,n=/^font$/i,r=/^all$/i,i=["font-family","font-size","font-style","font-variant","font-weight","font-stretch","line-height"],creator=a=>{const l=Object.assign({preserve:!0},a);return{postcssPlugin:"postcss-initial",Declaration(a){if(a.variable)return;if(!e.test(a.value))return;let s;s=n.test(a.prop)?i:r.test(a.prop)?t:[a.prop.toLowerCase()];let c=!1;s.forEach(t=>{const e=o.get(t);e&&(hasExactFallback(a,e)||(c=!0,a.cloneBefore({prop:t,value:e})))}),!l.preserve&&c&&a.remove()}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-initial/package.json b/plugins/postcss-initial/package.json index 5278fe7c1..7e5bc1355 100644 --- a/plugins/postcss-initial/package.json +++ b/plugins/postcss-initial/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-initial/src/index.ts b/plugins/postcss-initial/src/index.ts index ad23d6e1b..7bc5add96 100644 --- a/plugins/postcss-initial/src/index.ts +++ b/plugins/postcss-initial/src/index.ts @@ -82,3 +82,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-is-pseudo-class/CHANGELOG.md b/plugins/postcss-is-pseudo-class/CHANGELOG.md index 7181b7a03..d0ad13d09 100644 --- a/plugins/postcss-is-pseudo-class/CHANGELOG.md +++ b/plugins/postcss-is-pseudo-class/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Is Pseudo Class +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 5.0.3 _June 11, 2025_ diff --git a/plugins/postcss-is-pseudo-class/dist/index.cjs b/plugins/postcss-is-pseudo-class/dist/index.cjs deleted file mode 100644 index b6e1526fa..000000000 --- a/plugins/postcss-is-pseudo-class/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser"),s=require("@csstools/selector-specificity");function alwaysValidSelector(s){const o=e().astSync(s);let n=!0;return o.walk(e=>{if("class"!==e.type&&"comment"!==e.type&&"id"!==e.type&&"root"!==e.type&&"selector"!==e.type&&"string"!==e.type&&"tag"!==e.type&&"universal"!==e.type&&("attribute"!==e.type||e.insensitive)&&("combinator"!==e.type||"+"!==e.value&&">"!==e.value&&"~"!==e.value&&" "!==e.value)&&("pseudo"!==e.type||e.nodes?.length||":hover"!==e.value.toLowerCase()&&":focus"!==e.value.toLowerCase())){if("pseudo"===e.type&&1===e.nodes?.length&&":not"===e.value.toLowerCase()){let s=!0;if(e.nodes[0].walkCombinators(()=>{s=!1}),s)return}return n=!1,!1}}),n}function sortCompoundSelectorsInsideComplexSelector(s){if(!s||!s.nodes||1===s.nodes.length)return;const o=[];let n=[];for(let t=0;t"selector"===e.type&&"selector"===s.type&&e.nodes.length&&s.nodes.length?selectorTypeOrder(e.nodes[0],e.nodes[0].type)-selectorTypeOrder(s.nodes[0],s.nodes[0].type):"selector"===e.type&&e.nodes.length?selectorTypeOrder(e.nodes[0],e.nodes[0].type)-selectorTypeOrder(s,s.type):"selector"===s.type&&s.nodes.length?selectorTypeOrder(e,e.type)-selectorTypeOrder(s.nodes[0],s.nodes[0].type):selectorTypeOrder(e,e.type)-selectorTypeOrder(s,s.type));const n=new Set(s.map(e=>e.type)),r=n.has("universal")&&(n.has("tag")||n.has("attribute")||n.has("class")||n.has("id")||n.has("pseudo"));for(let e=0;e=0;o--){const n=t[o-1];if(t[o].remove(),n&&"tag"===n.type&&"tag"===t[o].type){const n=e.pseudo({value:":is",nodes:[e.selector({value:"",nodes:[t[o]]})]});n.parent=s,s.nodes.unshift(n)}else t[o].parent=s,s.nodes.unshift(t[o])}}function selectorTypeOrder(s,n){return e.isPseudoElement(s)?o.pseudoElement:o[n]}const o={universal:0,tag:1,pseudoElement:2,id:3,class:4,attribute:5,pseudo:6,selector:7,string:8,root:9,comment:10};function childAdjacentChild(e){return!(!e||!e.nodes)&&("selector"===e.type&&(3===e.nodes.length&&(!(!e.nodes[0]||"pseudo"!==e.nodes[0].type||":-csstools-matches"!==e.nodes[0].value)&&(!(!e.nodes[1]||"combinator"!==e.nodes[1].type||"+"!==e.nodes[1].value&&"~"!==e.nodes[1].value)&&(!(!e.nodes[2]||"pseudo"!==e.nodes[2].type||":-csstools-matches"!==e.nodes[2].value)&&(!(!e.nodes[0].nodes||1!==e.nodes[0].nodes.length)&&("selector"===e.nodes[0].nodes[0].type&&(!(!e.nodes[0].nodes[0].nodes||3!==e.nodes[0].nodes[0].nodes.length)&&(!(!e.nodes[0].nodes[0].nodes||"combinator"!==e.nodes[0].nodes[0].nodes[1].type||">"!==e.nodes[0].nodes[0].nodes[1].value)&&(!(!e.nodes[2].nodes||1!==e.nodes[2].nodes.length)&&("selector"===e.nodes[2].nodes[0].type&&(!(!e.nodes[2].nodes[0].nodes||3!==e.nodes[2].nodes[0].nodes.length)&&(!(!e.nodes[2].nodes[0].nodes||"combinator"!==e.nodes[2].nodes[0].nodes[1].type||">"!==e.nodes[2].nodes[0].nodes[1].value)&&(e.nodes[0].nodes[0].insertAfter(e.nodes[0].nodes[0].nodes[0],e.nodes[2].nodes[0].nodes[0].clone()),e.nodes[2].nodes[0].nodes[1].remove(),e.nodes[2].nodes[0].nodes[0].remove(),e.nodes[0].replaceWith(e.nodes[0].nodes[0]),e.nodes[2].replaceWith(e.nodes[2].nodes[0]),!0))))))))))))))}function isInCompoundWithOneOtherElement(s){if(!s||!s.nodes)return!1;if(!e.isSelector(s))return!1;if(2!==s.nodes.length)return!1;let o=-1,n=-1;s.nodes[0]&&e.isPseudoClass(s.nodes[0])&&":-csstools-matches"===s.nodes[0].value?(o=0,n=1):s.nodes[1]&&e.isPseudoClass(s.nodes[1])&&":-csstools-matches"===s.nodes[1].value&&(o=1,n=0);const t=s.nodes[o];if(!t||!e.isPseudoClass(t)||1!==t.nodes.length)return!1;const r=s.nodes[n];return!!r&&(!e.isCombinator(r)&&(!e.isPseudoElement(r)&&(t.nodes[0].append(r.clone()),t.replaceWith(...t.nodes[0].nodes),r.remove(),!0)))}function isPseudoInFirstCompound(s){if(!s||!s.nodes)return!1;if(!e.isSelector(s))return!1;let o=-1;for(let n=0;n{n.nodes[0].append(e.clone())}),r.forEach(e=>{n.nodes[0].append(e.clone())}),n.replaceWith(...n.nodes),t.forEach(e=>{e.remove()}),r.forEach(e=>{e.remove()}),!0}function samePrecedingElement(s){if(!s||!s.nodes)return!1;if("selector"!==s.type)return!1;let o=-1;for(let n=0;n"!==s.nodes[o].value&&"+"!==s.nodes[o].value)return!1;const t=s.nodes[o].value;if(!s.nodes[n]||"pseudo"!==s.nodes[n].type||":-csstools-matches"!==s.nodes[n].value)return!1;if(!s.nodes[n].nodes||1!==s.nodes[n].nodes.length)return!1;if("selector"!==s.nodes[n].nodes[0].type)return!1;if(!s.nodes[n].nodes[0].nodes||3!==s.nodes[n].nodes[0].nodes.length)return!1;if(!s.nodes[n].nodes[0].nodes||"combinator"!==s.nodes[n].nodes[0].nodes[1].type||s.nodes[n].nodes[0].nodes[1].value!==t)return!1;const r=s.nodes[n];if(!r||!e.isPseudoClass(r))return!1;const d=s.nodes.slice(0,o),l=s.nodes.slice(n+1);return s.each(e=>{e.remove()}),d.forEach(e=>{s.append(e)}),r.nodes[0].nodes.forEach(e=>{s.append(e)}),l.forEach(e=>{s.append(e)}),!0}function complexSelectors(s,o,n,t){return s.flatMap(s=>{if(-1===s.indexOf(":-csstools-matches")&&-1===s.toLowerCase().indexOf(":is"))return s;const r=e().astSync(s);return r.walkPseudos(s=>{if(":is"===s.value.toLowerCase()&&s.nodes&&s.nodes.length&&"selector"===s.nodes[0].type&&0===s.nodes[0].nodes.length)return s.value=":not",void s.nodes[0].append(e.universal());if(":-csstools-matches"===s.value)if(!s.nodes||s.nodes.length){if(s.walkPseudos(s=>{if(e.isPseudoElement(s)){let e=s.value;if(e.startsWith("::-csstools-invalid-"))return;for(;e.startsWith(":");)e=e.slice(1);s.value=`::-csstools-invalid-${e}`,t()}}),1===s.nodes.length&&"selector"===s.nodes[0].type){if(1===s.nodes[0].nodes.length)return void s.replaceWith(s.nodes[0].nodes[0]);if(!s.nodes[0].some(e=>"combinator"===e.type))return void s.replaceWith(...s.nodes[0].nodes)}1!==r.nodes.length||"selector"!==r.nodes[0].type||1!==r.nodes[0].nodes.length||r.nodes[0].nodes[0]!==s?childAdjacentChild(s.parent)||isInCompoundWithOneOtherElement(s.parent)||isPseudoInFirstCompound(s.parent)||samePrecedingElement(s.parent)||("warning"===o.onComplexSelector&&n(),s.value=":is"):s.replaceWith(...s.nodes[0].nodes)}else s.remove()}),r.walk(e=>{"selector"===e.type&&"nodes"in e&&1===e.nodes.length&&"selector"===e.nodes[0].type&&e.replaceWith(e.nodes[0])}),r.walk(e=>{"nodes"in e&&sortCompoundSelectorsInsideComplexSelector(e)}),r.toString()}).filter(e=>!!e)}function splitSelectors(o,n,t=0){const r=":not(#"+n.specificityMatchingName+")",d=":not(."+n.specificityMatchingName+")",l=":not("+n.specificityMatchingName+")";return o.flatMap(o=>{if(-1===o.toLowerCase().indexOf(":is"))return o;let i=!1;const a=[];if(e().astSync(o).walkPseudos(e=>{if(":is"!==e.value.toLowerCase()||!e.nodes||!e.nodes.length)return;if("selector"===e.nodes[0].type&&0===e.nodes[0].nodes.length)return;if("pseudo"===e.parent?.parent?.type&&":not"===e.parent?.parent?.value?.toLowerCase())return void a.push([{start:e.parent.parent.sourceIndex,end:e.parent.parent.sourceIndex+e.parent.parent.toString().length,option:`:not(${e.nodes.toString()})`}]);if("pseudo"===e.parent?.parent?.type&&":has"===e.parent?.parent?.value?.toLowerCase())return void(e.value=":-csstools-matches");let o=e.parent;for(;o;){if(o.value&&":is"===o.value.toLowerCase()&&"pseudo"===o.type)return void(i=!0);o=o.parent}const n=s.selectorSpecificity(e),t=e.sourceIndex,c=t+e.toString().length,u=[];e.nodes.forEach(e=>{const o={start:t,end:c,option:""},i=s.selectorSpecificity(e);let a=e.toString().trim();const p=Math.max(0,n.a-i.a),h=Math.max(0,n.b-i.b),f=Math.max(0,n.c-i.c);for(let e=0;e{let s="";for(let n=0;n!!e)}function cartesianProduct(...e){const s=[],o=e.length-1;return function helper(n,t){for(let r=0,d=e[t].length;r{const s={specificityMatchingName:"does-not-exist",...e||{}};return{postcssPlugin:"postcss-is-pseudo-class",prepare(){const e=new WeakSet;return{postcssPlugin:"postcss-is-pseudo-class",Rule(o,{result:t}){if(!o.selector)return;if(!n.test(o.selector))return;if(e.has(o))return;let r=!1;const warnOnComplexSelector=()=>{"warning"===s.onComplexSelector&&(r||(r=!0,o.warn(t,`Complex selectors in '${o.selector}' can not be transformed to an equivalent selector without ':is()'.`)))};let d=!1;const warnOnPseudoElements=()=>{"warning"===s.onPseudoElement&&(d||(d=!0,o.warn(t,`Pseudo elements are not allowed in ':is()', unable to transform '${o.selector}'`)))};try{let n=!1;const t=[],r=complexSelectors(splitSelectors(o.selectors,{specificityMatchingName:s.specificityMatchingName}),{onComplexSelector:s.onComplexSelector},warnOnComplexSelector,warnOnPseudoElements);if(Array.from(new Set(r)).forEach(s=>{if(o.selectors.indexOf(s)>-1)t.push(s);else{if(alwaysValidSelector(s))return t.push(s),void(n=!0);e.add(o),o.cloneBefore({selector:s}),n=!0}}),t.length&&n&&(e.add(o),o.cloneBefore({selectors:t})),!s.preserve){if(!n)return;o.remove()}}catch(e){if(!(e instanceof Error))throw e;if(e.message.indexOf("call stack size exceeded")>-1)throw e;o.warn(t,`Failed to parse selector "${o.selector}" with error: ${e.message}`)}}}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-is-pseudo-class/dist/index.d.ts b/plugins/postcss-is-pseudo-class/dist/index.d.ts index 6f69c11ec..cb6233d5b 100644 --- a/plugins/postcss-is-pseudo-class/dist/index.d.ts +++ b/plugins/postcss-is-pseudo-class/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-is-pseudo-class plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-is-pseudo-class/dist/index.mjs b/plugins/postcss-is-pseudo-class/dist/index.mjs index 1d4e88f8f..757d3900b 100644 --- a/plugins/postcss-is-pseudo-class/dist/index.mjs +++ b/plugins/postcss-is-pseudo-class/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";import{selectorSpecificity as s}from"@csstools/selector-specificity";function alwaysValidSelector(s){const o=e().astSync(s);let n=!0;return o.walk(e=>{if("class"!==e.type&&"comment"!==e.type&&"id"!==e.type&&"root"!==e.type&&"selector"!==e.type&&"string"!==e.type&&"tag"!==e.type&&"universal"!==e.type&&("attribute"!==e.type||e.insensitive)&&("combinator"!==e.type||"+"!==e.value&&">"!==e.value&&"~"!==e.value&&" "!==e.value)&&("pseudo"!==e.type||e.nodes?.length||":hover"!==e.value.toLowerCase()&&":focus"!==e.value.toLowerCase())){if("pseudo"===e.type&&1===e.nodes?.length&&":not"===e.value.toLowerCase()){let s=!0;if(e.nodes[0].walkCombinators(()=>{s=!1}),s)return}return n=!1,!1}}),n}function sortCompoundSelectorsInsideComplexSelector(s){if(!s||!s.nodes||1===s.nodes.length)return;const o=[];let n=[];for(let t=0;t"selector"===e.type&&"selector"===s.type&&e.nodes.length&&s.nodes.length?selectorTypeOrder(e.nodes[0],e.nodes[0].type)-selectorTypeOrder(s.nodes[0],s.nodes[0].type):"selector"===e.type&&e.nodes.length?selectorTypeOrder(e.nodes[0],e.nodes[0].type)-selectorTypeOrder(s,s.type):"selector"===s.type&&s.nodes.length?selectorTypeOrder(e,e.type)-selectorTypeOrder(s.nodes[0],s.nodes[0].type):selectorTypeOrder(e,e.type)-selectorTypeOrder(s,s.type));const n=new Set(s.map(e=>e.type)),r=n.has("universal")&&(n.has("tag")||n.has("attribute")||n.has("class")||n.has("id")||n.has("pseudo"));for(let e=0;e=0;o--){const n=t[o-1];if(t[o].remove(),n&&"tag"===n.type&&"tag"===t[o].type){const n=e.pseudo({value:":is",nodes:[e.selector({value:"",nodes:[t[o]]})]});n.parent=s,s.nodes.unshift(n)}else t[o].parent=s,s.nodes.unshift(t[o])}}function selectorTypeOrder(s,n){return e.isPseudoElement(s)?o.pseudoElement:o[n]}const o={universal:0,tag:1,pseudoElement:2,id:3,class:4,attribute:5,pseudo:6,selector:7,string:8,root:9,comment:10};function childAdjacentChild(e){return!(!e||!e.nodes)&&("selector"===e.type&&(3===e.nodes.length&&(!(!e.nodes[0]||"pseudo"!==e.nodes[0].type||":-csstools-matches"!==e.nodes[0].value)&&(!(!e.nodes[1]||"combinator"!==e.nodes[1].type||"+"!==e.nodes[1].value&&"~"!==e.nodes[1].value)&&(!(!e.nodes[2]||"pseudo"!==e.nodes[2].type||":-csstools-matches"!==e.nodes[2].value)&&(!(!e.nodes[0].nodes||1!==e.nodes[0].nodes.length)&&("selector"===e.nodes[0].nodes[0].type&&(!(!e.nodes[0].nodes[0].nodes||3!==e.nodes[0].nodes[0].nodes.length)&&(!(!e.nodes[0].nodes[0].nodes||"combinator"!==e.nodes[0].nodes[0].nodes[1].type||">"!==e.nodes[0].nodes[0].nodes[1].value)&&(!(!e.nodes[2].nodes||1!==e.nodes[2].nodes.length)&&("selector"===e.nodes[2].nodes[0].type&&(!(!e.nodes[2].nodes[0].nodes||3!==e.nodes[2].nodes[0].nodes.length)&&(!(!e.nodes[2].nodes[0].nodes||"combinator"!==e.nodes[2].nodes[0].nodes[1].type||">"!==e.nodes[2].nodes[0].nodes[1].value)&&(e.nodes[0].nodes[0].insertAfter(e.nodes[0].nodes[0].nodes[0],e.nodes[2].nodes[0].nodes[0].clone()),e.nodes[2].nodes[0].nodes[1].remove(),e.nodes[2].nodes[0].nodes[0].remove(),e.nodes[0].replaceWith(e.nodes[0].nodes[0]),e.nodes[2].replaceWith(e.nodes[2].nodes[0]),!0))))))))))))))}function isInCompoundWithOneOtherElement(s){if(!s||!s.nodes)return!1;if(!e.isSelector(s))return!1;if(2!==s.nodes.length)return!1;let o=-1,n=-1;s.nodes[0]&&e.isPseudoClass(s.nodes[0])&&":-csstools-matches"===s.nodes[0].value?(o=0,n=1):s.nodes[1]&&e.isPseudoClass(s.nodes[1])&&":-csstools-matches"===s.nodes[1].value&&(o=1,n=0);const t=s.nodes[o];if(!t||!e.isPseudoClass(t)||1!==t.nodes.length)return!1;const r=s.nodes[n];return!!r&&(!e.isCombinator(r)&&(!e.isPseudoElement(r)&&(t.nodes[0].append(r.clone()),t.replaceWith(...t.nodes[0].nodes),r.remove(),!0)))}function isPseudoInFirstCompound(s){if(!s||!s.nodes)return!1;if(!e.isSelector(s))return!1;let o=-1;for(let n=0;n{n.nodes[0].append(e.clone())}),r.forEach(e=>{n.nodes[0].append(e.clone())}),n.replaceWith(...n.nodes),t.forEach(e=>{e.remove()}),r.forEach(e=>{e.remove()}),!0}function samePrecedingElement(s){if(!s||!s.nodes)return!1;if("selector"!==s.type)return!1;let o=-1;for(let n=0;n"!==s.nodes[o].value&&"+"!==s.nodes[o].value)return!1;const t=s.nodes[o].value;if(!s.nodes[n]||"pseudo"!==s.nodes[n].type||":-csstools-matches"!==s.nodes[n].value)return!1;if(!s.nodes[n].nodes||1!==s.nodes[n].nodes.length)return!1;if("selector"!==s.nodes[n].nodes[0].type)return!1;if(!s.nodes[n].nodes[0].nodes||3!==s.nodes[n].nodes[0].nodes.length)return!1;if(!s.nodes[n].nodes[0].nodes||"combinator"!==s.nodes[n].nodes[0].nodes[1].type||s.nodes[n].nodes[0].nodes[1].value!==t)return!1;const r=s.nodes[n];if(!r||!e.isPseudoClass(r))return!1;const d=s.nodes.slice(0,o),l=s.nodes.slice(n+1);return s.each(e=>{e.remove()}),d.forEach(e=>{s.append(e)}),r.nodes[0].nodes.forEach(e=>{s.append(e)}),l.forEach(e=>{s.append(e)}),!0}function complexSelectors(s,o,n,t){return s.flatMap(s=>{if(-1===s.indexOf(":-csstools-matches")&&-1===s.toLowerCase().indexOf(":is"))return s;const r=e().astSync(s);return r.walkPseudos(s=>{if(":is"===s.value.toLowerCase()&&s.nodes&&s.nodes.length&&"selector"===s.nodes[0].type&&0===s.nodes[0].nodes.length)return s.value=":not",void s.nodes[0].append(e.universal());if(":-csstools-matches"===s.value)if(!s.nodes||s.nodes.length){if(s.walkPseudos(s=>{if(e.isPseudoElement(s)){let e=s.value;if(e.startsWith("::-csstools-invalid-"))return;for(;e.startsWith(":");)e=e.slice(1);s.value=`::-csstools-invalid-${e}`,t()}}),1===s.nodes.length&&"selector"===s.nodes[0].type){if(1===s.nodes[0].nodes.length)return void s.replaceWith(s.nodes[0].nodes[0]);if(!s.nodes[0].some(e=>"combinator"===e.type))return void s.replaceWith(...s.nodes[0].nodes)}1!==r.nodes.length||"selector"!==r.nodes[0].type||1!==r.nodes[0].nodes.length||r.nodes[0].nodes[0]!==s?childAdjacentChild(s.parent)||isInCompoundWithOneOtherElement(s.parent)||isPseudoInFirstCompound(s.parent)||samePrecedingElement(s.parent)||("warning"===o.onComplexSelector&&n(),s.value=":is"):s.replaceWith(...s.nodes[0].nodes)}else s.remove()}),r.walk(e=>{"selector"===e.type&&"nodes"in e&&1===e.nodes.length&&"selector"===e.nodes[0].type&&e.replaceWith(e.nodes[0])}),r.walk(e=>{"nodes"in e&&sortCompoundSelectorsInsideComplexSelector(e)}),r.toString()}).filter(e=>!!e)}function splitSelectors(o,n,t=0){const r=":not(#"+n.specificityMatchingName+")",d=":not(."+n.specificityMatchingName+")",l=":not("+n.specificityMatchingName+")";return o.flatMap(o=>{if(-1===o.toLowerCase().indexOf(":is"))return o;let i=!1;const a=[];if(e().astSync(o).walkPseudos(e=>{if(":is"!==e.value.toLowerCase()||!e.nodes||!e.nodes.length)return;if("selector"===e.nodes[0].type&&0===e.nodes[0].nodes.length)return;if("pseudo"===e.parent?.parent?.type&&":not"===e.parent?.parent?.value?.toLowerCase())return void a.push([{start:e.parent.parent.sourceIndex,end:e.parent.parent.sourceIndex+e.parent.parent.toString().length,option:`:not(${e.nodes.toString()})`}]);if("pseudo"===e.parent?.parent?.type&&":has"===e.parent?.parent?.value?.toLowerCase())return void(e.value=":-csstools-matches");let o=e.parent;for(;o;){if(o.value&&":is"===o.value.toLowerCase()&&"pseudo"===o.type)return void(i=!0);o=o.parent}const n=s(e),t=e.sourceIndex,c=t+e.toString().length,p=[];e.nodes.forEach(e=>{const o={start:t,end:c,option:""},i=s(e);let a=e.toString().trim();const u=Math.max(0,n.a-i.a),h=Math.max(0,n.b-i.b),f=Math.max(0,n.c-i.c);for(let e=0;e{let s="";for(let n=0;n!!e)}function cartesianProduct(...e){const s=[],o=e.length-1;return function helper(n,t){for(let r=0,d=e[t].length;r{const s={specificityMatchingName:"does-not-exist",...e||{}};return{postcssPlugin:"postcss-is-pseudo-class",prepare(){const e=new WeakSet;return{postcssPlugin:"postcss-is-pseudo-class",Rule(o,{result:t}){if(!o.selector)return;if(!n.test(o.selector))return;if(e.has(o))return;let r=!1;const warnOnComplexSelector=()=>{"warning"===s.onComplexSelector&&(r||(r=!0,o.warn(t,`Complex selectors in '${o.selector}' can not be transformed to an equivalent selector without ':is()'.`)))};let d=!1;const warnOnPseudoElements=()=>{"warning"===s.onPseudoElement&&(d||(d=!0,o.warn(t,`Pseudo elements are not allowed in ':is()', unable to transform '${o.selector}'`)))};try{let n=!1;const t=[],r=complexSelectors(splitSelectors(o.selectors,{specificityMatchingName:s.specificityMatchingName}),{onComplexSelector:s.onComplexSelector},warnOnComplexSelector,warnOnPseudoElements);if(Array.from(new Set(r)).forEach(s=>{if(o.selectors.indexOf(s)>-1)t.push(s);else{if(alwaysValidSelector(s))return t.push(s),void(n=!0);e.add(o),o.cloneBefore({selector:s}),n=!0}}),t.length&&n&&(e.add(o),o.cloneBefore({selectors:t})),!s.preserve){if(!n)return;o.remove()}}catch(e){if(!(e instanceof Error))throw e;if(e.message.indexOf("call stack size exceeded")>-1)throw e;o.warn(t,`Failed to parse selector "${o.selector}" with error: ${e.message}`)}}}}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-selector-parser";import{selectorSpecificity as s}from"@csstools/selector-specificity";function alwaysValidSelector(s){const o=e().astSync(s);let n=!0;return o.walk(e=>{if("class"!==e.type&&"comment"!==e.type&&"id"!==e.type&&"root"!==e.type&&"selector"!==e.type&&"string"!==e.type&&"tag"!==e.type&&"universal"!==e.type&&("attribute"!==e.type||e.insensitive)&&("combinator"!==e.type||"+"!==e.value&&">"!==e.value&&"~"!==e.value&&" "!==e.value)&&("pseudo"!==e.type||e.nodes?.length||":hover"!==e.value.toLowerCase()&&":focus"!==e.value.toLowerCase())){if("pseudo"===e.type&&1===e.nodes?.length&&":not"===e.value.toLowerCase()){let s=!0;if(e.nodes[0].walkCombinators(()=>{s=!1}),s)return}return n=!1,!1}}),n}function sortCompoundSelectorsInsideComplexSelector(s){if(!s||!s.nodes||1===s.nodes.length)return;const o=[];let n=[];for(let t=0;t"selector"===e.type&&"selector"===s.type&&e.nodes.length&&s.nodes.length?selectorTypeOrder(e.nodes[0],e.nodes[0].type)-selectorTypeOrder(s.nodes[0],s.nodes[0].type):"selector"===e.type&&e.nodes.length?selectorTypeOrder(e.nodes[0],e.nodes[0].type)-selectorTypeOrder(s,s.type):"selector"===s.type&&s.nodes.length?selectorTypeOrder(e,e.type)-selectorTypeOrder(s.nodes[0],s.nodes[0].type):selectorTypeOrder(e,e.type)-selectorTypeOrder(s,s.type));const n=new Set(s.map(e=>e.type)),r=n.has("universal")&&(n.has("tag")||n.has("attribute")||n.has("class")||n.has("id")||n.has("pseudo"));for(let e=0;e=0;o--){const n=t[o-1];if(t[o].remove(),n&&"tag"===n.type&&"tag"===t[o].type){const n=e.pseudo({value:":is",nodes:[e.selector({value:"",nodes:[t[o]]})]});n.parent=s,s.nodes.unshift(n)}else t[o].parent=s,s.nodes.unshift(t[o])}}function selectorTypeOrder(s,n){return e.isPseudoElement(s)?o.pseudoElement:o[n]}const o={universal:0,tag:1,pseudoElement:2,id:3,class:4,attribute:5,pseudo:6,selector:7,string:8,root:9,comment:10};function childAdjacentChild(e){return!(!e||!e.nodes)&&("selector"===e.type&&(3===e.nodes.length&&(!(!e.nodes[0]||"pseudo"!==e.nodes[0].type||":-csstools-matches"!==e.nodes[0].value)&&(!(!e.nodes[1]||"combinator"!==e.nodes[1].type||"+"!==e.nodes[1].value&&"~"!==e.nodes[1].value)&&(!(!e.nodes[2]||"pseudo"!==e.nodes[2].type||":-csstools-matches"!==e.nodes[2].value)&&(!(!e.nodes[0].nodes||1!==e.nodes[0].nodes.length)&&("selector"===e.nodes[0].nodes[0].type&&(!(!e.nodes[0].nodes[0].nodes||3!==e.nodes[0].nodes[0].nodes.length)&&(!(!e.nodes[0].nodes[0].nodes||"combinator"!==e.nodes[0].nodes[0].nodes[1].type||">"!==e.nodes[0].nodes[0].nodes[1].value)&&(!(!e.nodes[2].nodes||1!==e.nodes[2].nodes.length)&&("selector"===e.nodes[2].nodes[0].type&&(!(!e.nodes[2].nodes[0].nodes||3!==e.nodes[2].nodes[0].nodes.length)&&(!(!e.nodes[2].nodes[0].nodes||"combinator"!==e.nodes[2].nodes[0].nodes[1].type||">"!==e.nodes[2].nodes[0].nodes[1].value)&&(e.nodes[0].nodes[0].insertAfter(e.nodes[0].nodes[0].nodes[0],e.nodes[2].nodes[0].nodes[0].clone()),e.nodes[2].nodes[0].nodes[1].remove(),e.nodes[2].nodes[0].nodes[0].remove(),e.nodes[0].replaceWith(e.nodes[0].nodes[0]),e.nodes[2].replaceWith(e.nodes[2].nodes[0]),!0))))))))))))))}function isInCompoundWithOneOtherElement(s){if(!s||!s.nodes)return!1;if(!e.isSelector(s))return!1;if(2!==s.nodes.length)return!1;let o=-1,n=-1;s.nodes[0]&&e.isPseudoClass(s.nodes[0])&&":-csstools-matches"===s.nodes[0].value?(o=0,n=1):s.nodes[1]&&e.isPseudoClass(s.nodes[1])&&":-csstools-matches"===s.nodes[1].value&&(o=1,n=0);const t=s.nodes[o];if(!t||!e.isPseudoClass(t)||1!==t.nodes.length)return!1;const r=s.nodes[n];return!!r&&(!e.isCombinator(r)&&(!e.isPseudoElement(r)&&(t.nodes[0].append(r.clone()),t.replaceWith(...t.nodes[0].nodes),r.remove(),!0)))}function isPseudoInFirstCompound(s){if(!s||!s.nodes)return!1;if(!e.isSelector(s))return!1;let o=-1;for(let n=0;n{n.nodes[0].append(e.clone())}),r.forEach(e=>{n.nodes[0].append(e.clone())}),n.replaceWith(...n.nodes),t.forEach(e=>{e.remove()}),r.forEach(e=>{e.remove()}),!0}function samePrecedingElement(s){if(!s||!s.nodes)return!1;if("selector"!==s.type)return!1;let o=-1;for(let n=0;n"!==s.nodes[o].value&&"+"!==s.nodes[o].value)return!1;const t=s.nodes[o].value;if(!s.nodes[n]||"pseudo"!==s.nodes[n].type||":-csstools-matches"!==s.nodes[n].value)return!1;if(!s.nodes[n].nodes||1!==s.nodes[n].nodes.length)return!1;if("selector"!==s.nodes[n].nodes[0].type)return!1;if(!s.nodes[n].nodes[0].nodes||3!==s.nodes[n].nodes[0].nodes.length)return!1;if(!s.nodes[n].nodes[0].nodes||"combinator"!==s.nodes[n].nodes[0].nodes[1].type||s.nodes[n].nodes[0].nodes[1].value!==t)return!1;const r=s.nodes[n];if(!r||!e.isPseudoClass(r))return!1;const d=s.nodes.slice(0,o),l=s.nodes.slice(n+1);return s.each(e=>{e.remove()}),d.forEach(e=>{s.append(e)}),r.nodes[0].nodes.forEach(e=>{s.append(e)}),l.forEach(e=>{s.append(e)}),!0}function complexSelectors(s,o,n,t){return s.flatMap(s=>{if(-1===s.indexOf(":-csstools-matches")&&-1===s.toLowerCase().indexOf(":is"))return s;const r=e().astSync(s);return r.walkPseudos(s=>{if(":is"===s.value.toLowerCase()&&s.nodes&&s.nodes.length&&"selector"===s.nodes[0].type&&0===s.nodes[0].nodes.length)return s.value=":not",void s.nodes[0].append(e.universal());if(":-csstools-matches"===s.value)if(!s.nodes||s.nodes.length){if(s.walkPseudos(s=>{if(e.isPseudoElement(s)){let e=s.value;if(e.startsWith("::-csstools-invalid-"))return;for(;e.startsWith(":");)e=e.slice(1);s.value=`::-csstools-invalid-${e}`,t()}}),1===s.nodes.length&&"selector"===s.nodes[0].type){if(1===s.nodes[0].nodes.length)return void s.replaceWith(s.nodes[0].nodes[0]);if(!s.nodes[0].some(e=>"combinator"===e.type))return void s.replaceWith(...s.nodes[0].nodes)}1!==r.nodes.length||"selector"!==r.nodes[0].type||1!==r.nodes[0].nodes.length||r.nodes[0].nodes[0]!==s?childAdjacentChild(s.parent)||isInCompoundWithOneOtherElement(s.parent)||isPseudoInFirstCompound(s.parent)||samePrecedingElement(s.parent)||("warning"===o.onComplexSelector&&n(),s.value=":is"):s.replaceWith(...s.nodes[0].nodes)}else s.remove()}),r.walk(e=>{"selector"===e.type&&"nodes"in e&&1===e.nodes.length&&"selector"===e.nodes[0].type&&e.replaceWith(e.nodes[0])}),r.walk(e=>{"nodes"in e&&sortCompoundSelectorsInsideComplexSelector(e)}),r.toString()}).filter(e=>!!e)}function splitSelectors(o,n,t=0){const r=":not(#"+n.specificityMatchingName+")",d=":not(."+n.specificityMatchingName+")",l=":not("+n.specificityMatchingName+")";return o.flatMap(o=>{if(-1===o.toLowerCase().indexOf(":is"))return o;let i=!1;const a=[];if(e().astSync(o).walkPseudos(e=>{if(":is"!==e.value.toLowerCase()||!e.nodes||!e.nodes.length)return;if("selector"===e.nodes[0].type&&0===e.nodes[0].nodes.length)return;if("pseudo"===e.parent?.parent?.type&&":not"===e.parent?.parent?.value?.toLowerCase())return void a.push([{start:e.parent.parent.sourceIndex,end:e.parent.parent.sourceIndex+e.parent.parent.toString().length,option:`:not(${e.nodes.toString()})`}]);if("pseudo"===e.parent?.parent?.type&&":has"===e.parent?.parent?.value?.toLowerCase())return void(e.value=":-csstools-matches");let o=e.parent;for(;o;){if(o.value&&":is"===o.value.toLowerCase()&&"pseudo"===o.type)return void(i=!0);o=o.parent}const n=s(e),t=e.sourceIndex,c=t+e.toString().length,p=[];e.nodes.forEach(e=>{const o={start:t,end:c,option:""},i=s(e);let a=e.toString().trim();const u=Math.max(0,n.a-i.a),h=Math.max(0,n.b-i.b),f=Math.max(0,n.c-i.c);for(let e=0;e{let s="";for(let n=0;n!!e)}function cartesianProduct(...e){const s=[],o=e.length-1;return function helper(n,t){for(let r=0,d=e[t].length;r{const s={specificityMatchingName:"does-not-exist",...e||{}};return{postcssPlugin:"postcss-is-pseudo-class",prepare(){const e=new WeakSet;return{postcssPlugin:"postcss-is-pseudo-class",Rule(o,{result:t}){if(!o.selector)return;if(!n.test(o.selector))return;if(e.has(o))return;let r=!1;const warnOnComplexSelector=()=>{"warning"===s.onComplexSelector&&(r||(r=!0,o.warn(t,`Complex selectors in '${o.selector}' can not be transformed to an equivalent selector without ':is()'.`)))};let d=!1;const warnOnPseudoElements=()=>{"warning"===s.onPseudoElement&&(d||(d=!0,o.warn(t,`Pseudo elements are not allowed in ':is()', unable to transform '${o.selector}'`)))};try{let n=!1;const t=[],r=complexSelectors(splitSelectors(o.selectors,{specificityMatchingName:s.specificityMatchingName}),{onComplexSelector:s.onComplexSelector},warnOnComplexSelector,warnOnPseudoElements);if(Array.from(new Set(r)).forEach(s=>{if(o.selectors.indexOf(s)>-1)t.push(s);else{if(alwaysValidSelector(s))return t.push(s),void(n=!0);e.add(o),o.cloneBefore({selector:s}),n=!0}}),t.length&&n&&(e.add(o),o.cloneBefore({selectors:t})),!s.preserve){if(!n)return;o.remove()}}catch(e){if(!(e instanceof Error))throw e;if(e.message.indexOf("call stack size exceeded")>-1)throw e;o.warn(t,`Failed to parse selector "${o.selector}" with error: ${e.message}`)}}}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-is-pseudo-class/package.json b/plugins/postcss-is-pseudo-class/package.json index d72da6e38..54ac98f75 100644 --- a/plugins/postcss-is-pseudo-class/package.json +++ b/plugins/postcss-is-pseudo-class/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-is-pseudo-class/src/index.ts b/plugins/postcss-is-pseudo-class/src/index.ts index de282b709..76461d3a8 100644 --- a/plugins/postcss-is-pseudo-class/src/index.ts +++ b/plugins/postcss-is-pseudo-class/src/index.ts @@ -160,4 +160,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-lab-function/CHANGELOG.md b/plugins/postcss-lab-function/CHANGELOG.md index 821124744..301a17248 100644 --- a/plugins/postcss-lab-function/CHANGELOG.md +++ b/plugins/postcss-lab-function/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Lab Function +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 7.0.12 _September 21, 2025_ diff --git a/plugins/postcss-lab-function/dist/index.cjs b/plugins/postcss-lab-function/dist/index.cjs deleted file mode 100644 index 5be18d0c2..000000000 --- a/plugins/postcss-lab-function/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/css-color-parser"),t=require("@csstools/utilities"),a=require("@csstools/css-parser-algorithms"),r=require("@csstools/css-tokenizer");const o=/\b(?:lab|lch)\(/i,l=/^(?:lab|lch)$/i,basePlugin=s=>({postcssPlugin:"postcss-lab-function",Declaration(n){const i=n.value;if(!o.test(i))return;if(t.hasFallback(n))return;if(t.hasSupportsAtRuleAncestor(n,o))return;const u=r.tokenize({css:i}),c=a.replaceComponentValues(a.parseCommaSeparatedListOfComponentValues(u),s=>{if(!a.isFunctionNode(s)||!l.test(s.getName()))return;const t=e.color(s);return t&&!(t.syntaxFlags.has(e.SyntaxFlag.Experimental)||t.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords)||t.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax))?e.serializeRGB(t):void 0}),p=a.stringify(c);if(p===i)return;let g=p;s?.subFeatures.displayP3&&(g=a.stringify(a.replaceComponentValues(a.parseCommaSeparatedListOfComponentValues(u),s=>{if(!a.isFunctionNode(s)||!l.test(s.getName()))return;const t=e.color(s);return t&&!(t.syntaxFlags.has(e.SyntaxFlag.Experimental)||t.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords)||t.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax))?e.colorDataFitsRGB_Gamut(t)?e.serializeRGB(t):e.serializeP3(t):void 0}))),n.cloneBefore({value:p}),s?.subFeatures.displayP3&&g!==p&&n.cloneBefore({value:g}),s?.preserve||n.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return t.subFeatures=Object.assign({displayP3:!0},t.subFeatures),t.enableProgressiveCustomProperties&&(t.preserve||t.subFeatures.displayP3)?{postcssPlugin:"postcss-lab-function",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-lab-function/dist/index.d.ts b/plugins/postcss-lab-function/dist/index.d.ts index 4ec3cf9c6..c71590b77 100644 --- a/plugins/postcss-lab-function/dist/index.d.ts +++ b/plugins/postcss-lab-function/dist/index.d.ts @@ -16,5 +16,6 @@ export declare type pluginOptions = { /** Transform lab() and lch() functions in CSS. */ declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-lab-function/dist/index.mjs b/plugins/postcss-lab-function/dist/index.mjs index 2cd091ebe..39a29acf3 100644 --- a/plugins/postcss-lab-function/dist/index.mjs +++ b/plugins/postcss-lab-function/dist/index.mjs @@ -1 +1 @@ -import s from"@csstools/postcss-progressive-custom-properties";import{color as e,SyntaxFlag as t,serializeRGB as r,colorDataFitsRGB_Gamut as o,serializeP3 as a}from"@csstools/css-color-parser";import{hasFallback as l,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as c,isFunctionNode as u,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as m}from"@csstools/css-tokenizer";const g=/\b(?:lab|lch)\(/i,f=/^(?:lab|lch)$/i,basePlugin=s=>({postcssPlugin:"postcss-lab-function",Declaration(b){const y=b.value;if(!g.test(y))return;if(l(b))return;if(i(b,g))return;const v=m({css:y}),F=n(c(v),s=>{if(!u(s)||!f.test(s.getName()))return;const o=e(s);return o&&!(o.syntaxFlags.has(t.Experimental)||o.syntaxFlags.has(t.HasNoneKeywords)||o.syntaxFlags.has(t.RelativeColorSyntax))?r(o):void 0}),x=p(F);if(x===y)return;let P=x;s?.subFeatures.displayP3&&(P=p(n(c(v),s=>{if(!u(s)||!f.test(s.getName()))return;const l=e(s);return l&&!(l.syntaxFlags.has(t.Experimental)||l.syntaxFlags.has(t.HasNoneKeywords)||l.syntaxFlags.has(t.RelativeColorSyntax))?o(l)?r(l):a(l):void 0}))),b.cloneBefore({value:x}),s?.subFeatures.displayP3&&P!==x&&b.cloneBefore({value:P}),s?.preserve||b.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return t.subFeatures=Object.assign({displayP3:!0},t.subFeatures),t.enableProgressiveCustomProperties&&(t.preserve||t.subFeatures.displayP3)?{postcssPlugin:"postcss-lab-function",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import s from"@csstools/postcss-progressive-custom-properties";import{color as e,SyntaxFlag as t,serializeRGB as r,colorDataFitsRGB_Gamut as o,serializeP3 as a}from"@csstools/css-color-parser";import{hasFallback as l,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as u,isFunctionNode as c,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as m}from"@csstools/css-tokenizer";const g=/\b(?:lab|lch)\(/i,f=/^(?:lab|lch)$/i,basePlugin=s=>({postcssPlugin:"postcss-lab-function",Declaration(b){const y=b.value;if(!g.test(y))return;if(l(b))return;if(i(b,g))return;const v=m({css:y}),x=n(u(v),s=>{if(!c(s)||!f.test(s.getName()))return;const o=e(s);return o&&!(o.syntaxFlags.has(t.Experimental)||o.syntaxFlags.has(t.HasNoneKeywords)||o.syntaxFlags.has(t.RelativeColorSyntax))?r(o):void 0}),F=p(x);if(F===y)return;let d=F;s?.subFeatures.displayP3&&(d=p(n(u(v),s=>{if(!c(s)||!f.test(s.getName()))return;const l=e(s);return l&&!(l.syntaxFlags.has(t.Experimental)||l.syntaxFlags.has(t.HasNoneKeywords)||l.syntaxFlags.has(t.RelativeColorSyntax))?o(l)?r(l):a(l):void 0}))),b.cloneBefore({value:F}),s?.subFeatures.displayP3&&d!==F&&b.cloneBefore({value:d}),s?.preserve||b.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return t.subFeatures=Object.assign({displayP3:!0},t.subFeatures),t.enableProgressiveCustomProperties&&(t.preserve||t.subFeatures.displayP3)?{postcssPlugin:"postcss-lab-function",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-lab-function/package.json b/plugins/postcss-lab-function/package.json index 7ae39bd30..e2684272d 100644 --- a/plugins/postcss-lab-function/package.json +++ b/plugins/postcss-lab-function/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-lab-function/src/index.ts b/plugins/postcss-lab-function/src/index.ts index c7223010f..995faf08d 100644 --- a/plugins/postcss-lab-function/src/index.ts +++ b/plugins/postcss-lab-function/src/index.ts @@ -153,3 +153,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-light-dark-function/CHANGELOG.md b/plugins/postcss-light-dark-function/CHANGELOG.md index de60703ce..37476f741 100644 --- a/plugins/postcss-light-dark-function/CHANGELOG.md +++ b/plugins/postcss-light-dark-function/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Light Dark Function +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.11 _September 21, 2025_ diff --git a/plugins/postcss-light-dark-function/dist/index.cjs b/plugins/postcss-light-dark-function/dist/index.cjs deleted file mode 100644 index 42e664392..000000000 --- a/plugins/postcss-light-dark-function/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),o=require("@csstools/css-tokenizer"),t=require("@csstools/utilities"),r=require("@csstools/css-parser-algorithms");const s="--csstools-color-scheme--light",n="initial";function toggleNameGenerator(e){return`--csstools-light-dark-toggle--${e}`}const i=/dark/i,a=/light/i;function colorSchemes(e){const t=o.tokenize({css:e});let r=!1,s=!1;return t.forEach(e=>{o.isTokenIdent(e)&&(a.test(e[4].value)?r=!0:i.test(e[4].value)&&(s=!0))}),[r,s]}const c=/^light-dark$/i;function isComma(e){return r.isTokenNode(e)&&o.isTokenComma(e.value)}function parseLightDark(e){if(!r.isFunctionNode(e)||!c.test(e.getName()))return!1;const o=e.value.filter(e=>!r.isWhitespaceNode(e)&&!r.isCommentNode(e));if(3!==o.length)return!1;let t=o[0];const s=o[1];let n=o[2];if(!t||!s||!n)return!1;if(!isComma(s))return!1;if(isComma(t)||isComma(n))return!1;if(r.isFunctionNode(t)){const e=[t];r.walk(e,({node:e,parent:o},t)=>{recurseLightDark(e,o,t,!0)}),[t]=e}if(r.isFunctionNode(n)){const e=[n];r.walk(e,({node:e,parent:o},t)=>{recurseLightDark(e,o,t,!1)}),[n]=e}return[t,n]}function recurseLightDark(e,o,t,s){if("number"!=typeof t)return;const n=parseLightDark(e);if(!n)return;let i=n[s?0:1];if(r.isFunctionNode(i)){const e=[i];r.walk(e,({node:e,parent:o},t)=>{recurseLightDark(e,o,t,s)}),[i]=e}o.value[t]=i}function transformLightDark(e,t){const n=new Map,i=r.replaceComponentValues(r.parseCommaSeparatedListOfComponentValues(o.tokenize({css:e})),e=>{const i=parseLightDark(e);if(!i)return;const[a,c]=i,u=t();return n.set(u,`var(${s}) ${c.toString()}`),new r.FunctionNode([o.TokenType.Function,"var(",-1,-1,{value:"var"}],[o.TokenType.CloseParen,")",-1,-1,void 0],[new r.TokenNode([o.TokenType.Ident,u,-1,-1,{value:u}]),new r.TokenNode([o.TokenType.Comma,",",-1,-1,void 0]),new r.WhitespaceNode([[o.TokenType.Whitespace," ",-1,-1,void 0]]),a])});return{value:r.stringify(i),toggles:n}}function newNestedRuleWithSupportsNot(e,o,t,r){const s=o({selector:"& *",source:e.source});if(!r)return{inner:s,outer:s};const n=t({name:"supports",params:"not (color: light-dark(tan, tan))",source:e.source});return n.append(s),{inner:s,outer:n}}const u=/^color-scheme$/i,l=/\blight-dark\(/i,basePlugin=e=>({postcssPlugin:"postcss-light-dark-function",prepare(){let o=0;const currentToggleNameGenerator=()=>toggleNameGenerator(o++),r=new Map;return{postcssPlugin:"postcss-light-dark-function",Declaration(o,{atRule:i,rule:a}){const c=o.parent;if(c){if(u.test(o.prop)){if(c.some(e=>"decl"===e.type&&e.prop===s))return;const[e,t]=colorSchemes(o.value);if(e&&t){o.cloneBefore({prop:s,value:n});const e=c.clone();e.removeAll(),e.append(o.clone({prop:s,value:" "}));const t=i({name:"media",params:"(prefers-color-scheme: dark)",source:c.source});return t.append(e),void c.after(t)}return t?void o.cloneBefore({prop:s,value:" "}):e?void o.cloneBefore({prop:s,value:n}):void 0}if(l.test(o.value)){if(t.hasFallback(o))return;if(t.hasSupportsAtRuleAncestor(o,l))return;const s=transformLightDark(o.value,currentToggleNameGenerator);if(s.value===o.value)return;for(const[e,t]of s.toggles)o.cloneBefore({prop:e,value:t});if(o.cloneBefore({value:s.value}),o.variable&&o.parent){const t=r.get(o.parent)??newNestedRuleWithSupportsNot(o,a,i,e?.preserve);for(const[e,r]of s.toggles)t.inner.append(o.clone({prop:e,value:r}));t.inner.append(o.clone({value:s.value})),r.has(o.parent)||(o.parent.append(t.outer),r.set(o.parent,t))}e?.preserve||o.remove()}}}}}});basePlugin.postcss=!0;const postcssPlugin=o=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},o);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-light-dark-function",plugins:[e(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-light-dark-function/dist/index.d.ts b/plugins/postcss-light-dark-function/dist/index.d.ts index 2cecf28b6..9f5444d88 100644 --- a/plugins/postcss-light-dark-function/dist/index.d.ts +++ b/plugins/postcss-light-dark-function/dist/index.d.ts @@ -11,5 +11,6 @@ export declare type pluginOptions = { /** Transform the light-dark() function in CSS. */ declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-light-dark-function/dist/index.mjs b/plugins/postcss-light-dark-function/dist/index.mjs index a8c89771a..1445dfd07 100644 --- a/plugins/postcss-light-dark-function/dist/index.mjs +++ b/plugins/postcss-light-dark-function/dist/index.mjs @@ -1 +1 @@ -import e from"@csstools/postcss-progressive-custom-properties";import{tokenize as r,isTokenIdent as t,isTokenComma as o,TokenType as s}from"@csstools/css-tokenizer";import{hasFallback as n,hasSupportsAtRuleAncestor as a}from"@csstools/utilities";import{isFunctionNode as i,isWhitespaceNode as c,isCommentNode as u,walk as l,isTokenNode as p,replaceComponentValues as f,parseCommaSeparatedListOfComponentValues as g,FunctionNode as v,TokenNode as m,WhitespaceNode as d,stringify as h}from"@csstools/css-parser-algorithms";const k="--csstools-color-scheme--light",D="initial";function toggleNameGenerator(e){return`--csstools-light-dark-toggle--${e}`}const L=/dark/i,w=/light/i;function colorSchemes(e){const o=r({css:e});let s=!1,n=!1;return o.forEach(e=>{t(e)&&(w.test(e[4].value)?s=!0:L.test(e[4].value)&&(n=!0))}),[s,n]}const C=/^light-dark$/i;function isComma(e){return p(e)&&o(e.value)}function parseLightDark(e){if(!i(e)||!C.test(e.getName()))return!1;const r=e.value.filter(e=>!c(e)&&!u(e));if(3!==r.length)return!1;let t=r[0];const o=r[1];let s=r[2];if(!t||!o||!s)return!1;if(!isComma(o))return!1;if(isComma(t)||isComma(s))return!1;if(i(t)){const e=[t];l(e,({node:e,parent:r},t)=>{recurseLightDark(e,r,t,!0)}),[t]=e}if(i(s)){const e=[s];l(e,({node:e,parent:r},t)=>{recurseLightDark(e,r,t,!1)}),[s]=e}return[t,s]}function recurseLightDark(e,r,t,o){if("number"!=typeof t)return;const s=parseLightDark(e);if(!s)return;let n=s[o?0:1];if(i(n)){const e=[n];l(e,({node:e,parent:r},t)=>{recurseLightDark(e,r,t,o)}),[n]=e}r.value[t]=n}function transformLightDark(e,t){const o=new Map,n=f(g(r({css:e})),e=>{const r=parseLightDark(e);if(!r)return;const[n,a]=r,i=t();return o.set(i,`var(${k}) ${a.toString()}`),new v([s.Function,"var(",-1,-1,{value:"var"}],[s.CloseParen,")",-1,-1,void 0],[new m([s.Ident,i,-1,-1,{value:i}]),new m([s.Comma,",",-1,-1,void 0]),new d([[s.Whitespace," ",-1,-1,void 0]]),n])});return{value:h(n),toggles:o}}function newNestedRuleWithSupportsNot(e,r,t,o){const s=r({selector:"& *",source:e.source});if(!o)return{inner:s,outer:s};const n=t({name:"supports",params:"not (color: light-dark(tan, tan))",source:e.source});return n.append(s),{inner:s,outer:n}}const P=/^color-scheme$/i,N=/\blight-dark\(/i,basePlugin=e=>({postcssPlugin:"postcss-light-dark-function",prepare(){let r=0;const currentToggleNameGenerator=()=>toggleNameGenerator(r++),t=new Map;return{postcssPlugin:"postcss-light-dark-function",Declaration(r,{atRule:o,rule:s}){const i=r.parent;if(i){if(P.test(r.prop)){if(i.some(e=>"decl"===e.type&&e.prop===k))return;const[e,t]=colorSchemes(r.value);if(e&&t){r.cloneBefore({prop:k,value:D});const e=i.clone();e.removeAll(),e.append(r.clone({prop:k,value:" "}));const t=o({name:"media",params:"(prefers-color-scheme: dark)",source:i.source});return t.append(e),void i.after(t)}return t?void r.cloneBefore({prop:k,value:" "}):e?void r.cloneBefore({prop:k,value:D}):void 0}if(N.test(r.value)){if(n(r))return;if(a(r,N))return;const i=transformLightDark(r.value,currentToggleNameGenerator);if(i.value===r.value)return;for(const[e,t]of i.toggles)r.cloneBefore({prop:e,value:t});if(r.cloneBefore({value:i.value}),r.variable&&r.parent){const n=t.get(r.parent)??newNestedRuleWithSupportsNot(r,s,o,e?.preserve);for(const[e,t]of i.toggles)n.inner.append(r.clone({prop:e,value:t}));n.inner.append(r.clone({value:i.value})),t.has(r.parent)||(r.parent.append(n.outer),t.set(r.parent,n))}e?.preserve||r.remove()}}}}}});basePlugin.postcss=!0;const postcssPlugin=r=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},r);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-light-dark-function",plugins:[e(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import e from"@csstools/postcss-progressive-custom-properties";import{tokenize as r,isTokenIdent as t,isTokenComma as o,TokenType as s}from"@csstools/css-tokenizer";import{hasFallback as n,hasSupportsAtRuleAncestor as a}from"@csstools/utilities";import{isFunctionNode as i,isWhitespaceNode as c,isCommentNode as u,walk as l,isTokenNode as p,replaceComponentValues as f,parseCommaSeparatedListOfComponentValues as g,FunctionNode as v,TokenNode as m,WhitespaceNode as d,stringify as h}from"@csstools/css-parser-algorithms";const k="--csstools-color-scheme--light",D="initial";function toggleNameGenerator(e){return`--csstools-light-dark-toggle--${e}`}const L=/dark/i,w=/light/i;function colorSchemes(e){const o=r({css:e});let s=!1,n=!1;return o.forEach(e=>{t(e)&&(w.test(e[4].value)?s=!0:L.test(e[4].value)&&(n=!0))}),[s,n]}const C=/^light-dark$/i;function isComma(e){return p(e)&&o(e.value)}function parseLightDark(e){if(!i(e)||!C.test(e.getName()))return!1;const r=e.value.filter(e=>!c(e)&&!u(e));if(3!==r.length)return!1;let t=r[0];const o=r[1];let s=r[2];if(!t||!o||!s)return!1;if(!isComma(o))return!1;if(isComma(t)||isComma(s))return!1;if(i(t)){const e=[t];l(e,({node:e,parent:r},t)=>{recurseLightDark(e,r,t,!0)}),[t]=e}if(i(s)){const e=[s];l(e,({node:e,parent:r},t)=>{recurseLightDark(e,r,t,!1)}),[s]=e}return[t,s]}function recurseLightDark(e,r,t,o){if("number"!=typeof t)return;const s=parseLightDark(e);if(!s)return;let n=s[o?0:1];if(i(n)){const e=[n];l(e,({node:e,parent:r},t)=>{recurseLightDark(e,r,t,o)}),[n]=e}r.value[t]=n}function transformLightDark(e,t){const o=new Map,n=f(g(r({css:e})),e=>{const r=parseLightDark(e);if(!r)return;const[n,a]=r,i=t();return o.set(i,`var(${k}) ${a.toString()}`),new v([s.Function,"var(",-1,-1,{value:"var"}],[s.CloseParen,")",-1,-1,void 0],[new m([s.Ident,i,-1,-1,{value:i}]),new m([s.Comma,",",-1,-1,void 0]),new d([[s.Whitespace," ",-1,-1,void 0]]),n])});return{value:h(n),toggles:o}}function newNestedRuleWithSupportsNot(e,r,t,o){const s=r({selector:"& *",source:e.source});if(!o)return{inner:s,outer:s};const n=t({name:"supports",params:"not (color: light-dark(tan, tan))",source:e.source});return n.append(s),{inner:s,outer:n}}const P=/^color-scheme$/i,N=/\blight-dark\(/i,basePlugin=e=>({postcssPlugin:"postcss-light-dark-function",prepare(){let r=0;const currentToggleNameGenerator=()=>toggleNameGenerator(r++),t=new Map;return{postcssPlugin:"postcss-light-dark-function",Declaration(r,{atRule:o,rule:s}){const i=r.parent;if(i){if(P.test(r.prop)){if(i.some(e=>"decl"===e.type&&e.prop===k))return;const[e,t]=colorSchemes(r.value);if(e&&t){r.cloneBefore({prop:k,value:D});const e=i.clone();e.removeAll(),e.append(r.clone({prop:k,value:" "}));const t=o({name:"media",params:"(prefers-color-scheme: dark)",source:i.source});return t.append(e),void i.after(t)}return t?void r.cloneBefore({prop:k,value:" "}):e?void r.cloneBefore({prop:k,value:D}):void 0}if(N.test(r.value)){if(n(r))return;if(a(r,N))return;const i=transformLightDark(r.value,currentToggleNameGenerator);if(i.value===r.value)return;for(const[e,t]of i.toggles)r.cloneBefore({prop:e,value:t});if(r.cloneBefore({value:i.value}),r.variable&&r.parent){const n=t.get(r.parent)??newNestedRuleWithSupportsNot(r,s,o,e?.preserve);for(const[e,t]of i.toggles)n.inner.append(r.clone({prop:e,value:t}));n.inner.append(r.clone({value:i.value})),t.has(r.parent)||(r.parent.append(n.outer),t.set(r.parent,n))}e?.preserve||r.remove()}}}}}});basePlugin.postcss=!0;const postcssPlugin=r=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},r);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-light-dark-function",plugins:[e(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-light-dark-function/package.json b/plugins/postcss-light-dark-function/package.json index b96ac9552..2418c7300 100644 --- a/plugins/postcss-light-dark-function/package.json +++ b/plugins/postcss-light-dark-function/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-light-dark-function/src/index.ts b/plugins/postcss-light-dark-function/src/index.ts index 20330d0ed..cb0f32b99 100644 --- a/plugins/postcss-light-dark-function/src/index.ts +++ b/plugins/postcss-light-dark-function/src/index.ts @@ -149,3 +149,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-logical-float-and-clear/CHANGELOG.md b/plugins/postcss-logical-float-and-clear/CHANGELOG.md index 5f358acfb..50e90857c 100644 --- a/plugins/postcss-logical-float-and-clear/CHANGELOG.md +++ b/plugins/postcss-logical-float-and-clear/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Logical Float And Clear +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.0.0 _August 3, 2024_ diff --git a/plugins/postcss-logical-float-and-clear/dist/index.cjs b/plugins/postcss-logical-float-and-clear/dist/index.cjs deleted file mode 100644 index a036cd906..000000000 --- a/plugins/postcss-logical-float-and-clear/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";const t="inline-start",o="inline-end";var e,i;function directionFlowToAxes(t){switch(t){case e.TopToBottom:return[i.Top,i.Bottom];case e.BottomToTop:return[i.Bottom,i.Top];case e.RightToLeft:return[i.Right,i.Left];case e.LeftToRight:return[i.Left,i.Right]}}function cloneDeclaration(t,o,e){t.parent&&t.parent.some(t=>"decl"==t.type&&t.prop===e&&t.value===o)||t.cloneBefore({value:o,prop:e})}!function(t){t.TopToBottom="top-to-bottom",t.BottomToTop="bottom-to-top",t.RightToLeft="right-to-left",t.LeftToRight="left-to-right"}(e||(e={})),function(t){t.Top="top",t.Right="right",t.Bottom="bottom",t.Left="left"}(i||(i={}));const creator=i=>{const n=Object.assign({inlineDirection:e.LeftToRight},i),c=Object.values(e);if(!c.includes(n.inlineDirection))throw new Error(`[postcss-logical-float-and-clear] "inlineDirection" must be one of ${c.join(", ")}`);if(![e.LeftToRight,e.RightToLeft].includes(n.inlineDirection))return{postcssPlugin:"postcss-logical-float-and-clear",Once(){}};const[r,l]=directionFlowToAxes(n.inlineDirection),makeTransform=e=>{const i=e.value.toLowerCase();if(![t,o].includes(i))return;cloneDeclaration(e,i===t?r:l,e.prop),e.remove()};return{postcssPlugin:"postcss-logical-float-and-clear",Declaration:{float:makeTransform,clear:makeTransform}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-logical-float-and-clear/dist/index.d.ts b/plugins/postcss-logical-float-and-clear/dist/index.d.ts index 44d0817a8..bfdb19f11 100644 --- a/plugins/postcss-logical-float-and-clear/dist/index.d.ts +++ b/plugins/postcss-logical-float-and-clear/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export declare enum DirectionFlow { TopToBottom = "top-to-bottom", diff --git a/plugins/postcss-logical-float-and-clear/dist/index.mjs b/plugins/postcss-logical-float-and-clear/dist/index.mjs index bdb177676..dd6fa2597 100644 --- a/plugins/postcss-logical-float-and-clear/dist/index.mjs +++ b/plugins/postcss-logical-float-and-clear/dist/index.mjs @@ -1 +1 @@ -const t="inline-start",o="inline-end";var e,n;function directionFlowToAxes(t){switch(t){case e.TopToBottom:return[n.Top,n.Bottom];case e.BottomToTop:return[n.Bottom,n.Top];case e.RightToLeft:return[n.Right,n.Left];case e.LeftToRight:return[n.Left,n.Right]}}function cloneDeclaration(t,o,e){t.parent&&t.parent.some(t=>"decl"==t.type&&t.prop===e&&t.value===o)||t.cloneBefore({value:o,prop:e})}!function(t){t.TopToBottom="top-to-bottom",t.BottomToTop="bottom-to-top",t.RightToLeft="right-to-left",t.LeftToRight="left-to-right"}(e||(e={})),function(t){t.Top="top",t.Right="right",t.Bottom="bottom",t.Left="left"}(n||(n={}));const creator=n=>{const i=Object.assign({inlineDirection:e.LeftToRight},n),c=Object.values(e);if(!c.includes(i.inlineDirection))throw new Error(`[postcss-logical-float-and-clear] "inlineDirection" must be one of ${c.join(", ")}`);if(![e.LeftToRight,e.RightToLeft].includes(i.inlineDirection))return{postcssPlugin:"postcss-logical-float-and-clear",Once(){}};const[r,l]=directionFlowToAxes(i.inlineDirection),makeTransform=e=>{const n=e.value.toLowerCase();if(![t,o].includes(n))return;cloneDeclaration(e,n===t?r:l,e.prop),e.remove()};return{postcssPlugin:"postcss-logical-float-and-clear",Declaration:{float:makeTransform,clear:makeTransform}}};creator.postcss=!0;export{creator as default}; +const t="inline-start",o="inline-end";var e,n;function directionFlowToAxes(t){switch(t){case e.TopToBottom:return[n.Top,n.Bottom];case e.BottomToTop:return[n.Bottom,n.Top];case e.RightToLeft:return[n.Right,n.Left];case e.LeftToRight:return[n.Left,n.Right]}}function cloneDeclaration(t,o,e){t.parent&&t.parent.some(t=>"decl"==t.type&&t.prop===e&&t.value===o)||t.cloneBefore({value:o,prop:e})}!function(t){t.TopToBottom="top-to-bottom",t.BottomToTop="bottom-to-top",t.RightToLeft="right-to-left",t.LeftToRight="left-to-right"}(e||(e={})),function(t){t.Top="top",t.Right="right",t.Bottom="bottom",t.Left="left"}(n||(n={}));const creator=n=>{const i=Object.assign({inlineDirection:e.LeftToRight},n),c=Object.values(e);if(!c.includes(i.inlineDirection))throw new Error(`[postcss-logical-float-and-clear] "inlineDirection" must be one of ${c.join(", ")}`);if(![e.LeftToRight,e.RightToLeft].includes(i.inlineDirection))return{postcssPlugin:"postcss-logical-float-and-clear",Once(){}};const[r,l]=directionFlowToAxes(i.inlineDirection),makeTransform=e=>{const n=e.value.toLowerCase();if(![t,o].includes(n))return;cloneDeclaration(e,n===t?r:l,e.prop),e.remove()};return{postcssPlugin:"postcss-logical-float-and-clear",Declaration:{float:makeTransform,clear:makeTransform}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-logical-float-and-clear/package.json b/plugins/postcss-logical-float-and-clear/package.json index a1dad42b3..b94068860 100644 --- a/plugins/postcss-logical-float-and-clear/package.json +++ b/plugins/postcss-logical-float-and-clear/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-logical-float-and-clear/src/index.ts b/plugins/postcss-logical-float-and-clear/src/index.ts index 380a28211..f60b53963 100644 --- a/plugins/postcss-logical-float-and-clear/src/index.ts +++ b/plugins/postcss-logical-float-and-clear/src/index.ts @@ -63,3 +63,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-logical-overflow/CHANGELOG.md b/plugins/postcss-logical-overflow/CHANGELOG.md index 1b6f1d60c..0da2d4dab 100644 --- a/plugins/postcss-logical-overflow/CHANGELOG.md +++ b/plugins/postcss-logical-overflow/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Logical Overflow +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.0 _August 3, 2024_ diff --git a/plugins/postcss-logical-overflow/dist/index.cjs b/plugins/postcss-logical-overflow/dist/index.cjs deleted file mode 100644 index 272b0cd0b..000000000 --- a/plugins/postcss-logical-overflow/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var o;function transformAxes(o,t){const e=t?"-x":"-y",i=t?"-y":"-x",n=o.prop.toLowerCase().replace("-inline",e).replace("-block",i),s=o.value;o.parent?.some(o=>"decl"==o.type&&o.prop===n&&o.value===s)||(o.cloneBefore({prop:n,value:s}),o.remove())}!function(o){o.TopToBottom="top-to-bottom",o.BottomToTop="bottom-to-top",o.RightToLeft="right-to-left",o.LeftToRight="left-to-right"}(o||(o={}));const creator=t=>{const e=Object.assign({inlineDirection:o.LeftToRight},t);switch(e.inlineDirection){case o.LeftToRight:case o.RightToLeft:case o.TopToBottom:case o.BottomToTop:break;default:throw new Error(`[postcss-logical-viewport-units] "inlineDirection" must be one of ${Object.values(o).join(", ")}`)}const i=[o.LeftToRight,o.RightToLeft].includes(e.inlineDirection);return{postcssPlugin:"postcss-logical-overflow",Declaration:{"overflow-block":o=>transformAxes(o,i),"overflow-inline":o=>transformAxes(o,i)}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-logical-overflow/dist/index.d.ts b/plugins/postcss-logical-overflow/dist/index.d.ts index d9afe9d40..8077f4585 100644 --- a/plugins/postcss-logical-overflow/dist/index.d.ts +++ b/plugins/postcss-logical-overflow/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export declare enum DirectionFlow { TopToBottom = "top-to-bottom", diff --git a/plugins/postcss-logical-overflow/dist/index.mjs b/plugins/postcss-logical-overflow/dist/index.mjs index 754ffbd49..49515b0f0 100644 --- a/plugins/postcss-logical-overflow/dist/index.mjs +++ b/plugins/postcss-logical-overflow/dist/index.mjs @@ -1 +1 @@ -var o;function transformAxes(o,t){const e=t?"-x":"-y",i=t?"-y":"-x",n=o.prop.toLowerCase().replace("-inline",e).replace("-block",i),s=o.value;o.parent?.some(o=>"decl"==o.type&&o.prop===n&&o.value===s)||(o.cloneBefore({prop:n,value:s}),o.remove())}!function(o){o.TopToBottom="top-to-bottom",o.BottomToTop="bottom-to-top",o.RightToLeft="right-to-left",o.LeftToRight="left-to-right"}(o||(o={}));const creator=t=>{const e=Object.assign({inlineDirection:o.LeftToRight},t);switch(e.inlineDirection){case o.LeftToRight:case o.RightToLeft:case o.TopToBottom:case o.BottomToTop:break;default:throw new Error(`[postcss-logical-viewport-units] "inlineDirection" must be one of ${Object.values(o).join(", ")}`)}const i=[o.LeftToRight,o.RightToLeft].includes(e.inlineDirection);return{postcssPlugin:"postcss-logical-overflow",Declaration:{"overflow-block":o=>transformAxes(o,i),"overflow-inline":o=>transformAxes(o,i)}}};creator.postcss=!0;export{creator as default}; +var o;function transformAxes(o,t){const e=t?"-x":"-y",i=t?"-y":"-x",n=o.prop.toLowerCase().replace("-inline",e).replace("-block",i),s=o.value;o.parent?.some(o=>"decl"==o.type&&o.prop===n&&o.value===s)||(o.cloneBefore({prop:n,value:s}),o.remove())}!function(o){o.TopToBottom="top-to-bottom",o.BottomToTop="bottom-to-top",o.RightToLeft="right-to-left",o.LeftToRight="left-to-right"}(o||(o={}));const creator=t=>{const e=Object.assign({inlineDirection:o.LeftToRight},t);switch(e.inlineDirection){case o.LeftToRight:case o.RightToLeft:case o.TopToBottom:case o.BottomToTop:break;default:throw new Error(`[postcss-logical-viewport-units] "inlineDirection" must be one of ${Object.values(o).join(", ")}`)}const i=[o.LeftToRight,o.RightToLeft].includes(e.inlineDirection);return{postcssPlugin:"postcss-logical-overflow",Declaration:{"overflow-block":o=>transformAxes(o,i),"overflow-inline":o=>transformAxes(o,i)}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-logical-overflow/package.json b/plugins/postcss-logical-overflow/package.json index 62fbae80e..aabfa7cf7 100644 --- a/plugins/postcss-logical-overflow/package.json +++ b/plugins/postcss-logical-overflow/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-logical-overflow/src/index.ts b/plugins/postcss-logical-overflow/src/index.ts index d9af1563a..4c2a941a4 100644 --- a/plugins/postcss-logical-overflow/src/index.ts +++ b/plugins/postcss-logical-overflow/src/index.ts @@ -44,3 +44,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-logical-overscroll-behavior/CHANGELOG.md b/plugins/postcss-logical-overscroll-behavior/CHANGELOG.md index 579f9bc24..c9dd53f8e 100644 --- a/plugins/postcss-logical-overscroll-behavior/CHANGELOG.md +++ b/plugins/postcss-logical-overscroll-behavior/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Logical Overscroll Behavior +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.0 _August 3, 2024_ diff --git a/plugins/postcss-logical-overscroll-behavior/dist/index.cjs b/plugins/postcss-logical-overscroll-behavior/dist/index.cjs deleted file mode 100644 index 92dde4a3d..000000000 --- a/plugins/postcss-logical-overscroll-behavior/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var o;function transformAxes(o,t){const e=t?"-x":"-y",i=t?"-y":"-x",r=o.prop.toLowerCase().replace("-inline",e).replace("-block",i),s=o.value;o.parent?.some(o=>"decl"==o.type&&o.prop===r&&o.value===s)||(o.cloneBefore({prop:r,value:s}),o.remove())}!function(o){o.TopToBottom="top-to-bottom",o.BottomToTop="bottom-to-top",o.RightToLeft="right-to-left",o.LeftToRight="left-to-right"}(o||(o={}));const creator=t=>{const e=Object.assign({inlineDirection:o.LeftToRight},t);switch(e.inlineDirection){case o.LeftToRight:case o.RightToLeft:case o.TopToBottom:case o.BottomToTop:break;default:throw new Error(`[postcss-logical-viewport-units] "inlineDirection" must be one of ${Object.values(o).join(", ")}`)}const i=[o.LeftToRight,o.RightToLeft].includes(e.inlineDirection);return{postcssPlugin:"postcss-logical-overscroll-behavior",Declaration:{"overscroll-behavior-block":o=>transformAxes(o,i),"overscroll-behavior-inline":o=>transformAxes(o,i)}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-logical-overscroll-behavior/dist/index.d.ts b/plugins/postcss-logical-overscroll-behavior/dist/index.d.ts index 69581fa58..64abb334b 100644 --- a/plugins/postcss-logical-overscroll-behavior/dist/index.d.ts +++ b/plugins/postcss-logical-overscroll-behavior/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export declare enum DirectionFlow { TopToBottom = "top-to-bottom", diff --git a/plugins/postcss-logical-overscroll-behavior/dist/index.mjs b/plugins/postcss-logical-overscroll-behavior/dist/index.mjs index e34571f44..42c5210fc 100644 --- a/plugins/postcss-logical-overscroll-behavior/dist/index.mjs +++ b/plugins/postcss-logical-overscroll-behavior/dist/index.mjs @@ -1 +1 @@ -var o;function transformAxes(o,t){const e=t?"-x":"-y",i=t?"-y":"-x",r=o.prop.toLowerCase().replace("-inline",e).replace("-block",i),s=o.value;o.parent?.some(o=>"decl"==o.type&&o.prop===r&&o.value===s)||(o.cloneBefore({prop:r,value:s}),o.remove())}!function(o){o.TopToBottom="top-to-bottom",o.BottomToTop="bottom-to-top",o.RightToLeft="right-to-left",o.LeftToRight="left-to-right"}(o||(o={}));const creator=t=>{const e=Object.assign({inlineDirection:o.LeftToRight},t);switch(e.inlineDirection){case o.LeftToRight:case o.RightToLeft:case o.TopToBottom:case o.BottomToTop:break;default:throw new Error(`[postcss-logical-viewport-units] "inlineDirection" must be one of ${Object.values(o).join(", ")}`)}const i=[o.LeftToRight,o.RightToLeft].includes(e.inlineDirection);return{postcssPlugin:"postcss-logical-overscroll-behavior",Declaration:{"overscroll-behavior-block":o=>transformAxes(o,i),"overscroll-behavior-inline":o=>transformAxes(o,i)}}};creator.postcss=!0;export{creator as default}; +var o;function transformAxes(o,t){const e=t?"-x":"-y",i=t?"-y":"-x",r=o.prop.toLowerCase().replace("-inline",e).replace("-block",i),s=o.value;o.parent?.some(o=>"decl"==o.type&&o.prop===r&&o.value===s)||(o.cloneBefore({prop:r,value:s}),o.remove())}!function(o){o.TopToBottom="top-to-bottom",o.BottomToTop="bottom-to-top",o.RightToLeft="right-to-left",o.LeftToRight="left-to-right"}(o||(o={}));const creator=t=>{const e=Object.assign({inlineDirection:o.LeftToRight},t);switch(e.inlineDirection){case o.LeftToRight:case o.RightToLeft:case o.TopToBottom:case o.BottomToTop:break;default:throw new Error(`[postcss-logical-viewport-units] "inlineDirection" must be one of ${Object.values(o).join(", ")}`)}const i=[o.LeftToRight,o.RightToLeft].includes(e.inlineDirection);return{postcssPlugin:"postcss-logical-overscroll-behavior",Declaration:{"overscroll-behavior-block":o=>transformAxes(o,i),"overscroll-behavior-inline":o=>transformAxes(o,i)}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-logical-overscroll-behavior/package.json b/plugins/postcss-logical-overscroll-behavior/package.json index 5625682a7..58f7e7e68 100644 --- a/plugins/postcss-logical-overscroll-behavior/package.json +++ b/plugins/postcss-logical-overscroll-behavior/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-logical-overscroll-behavior/src/index.ts b/plugins/postcss-logical-overscroll-behavior/src/index.ts index 17887529d..2885abf9d 100644 --- a/plugins/postcss-logical-overscroll-behavior/src/index.ts +++ b/plugins/postcss-logical-overscroll-behavior/src/index.ts @@ -44,3 +44,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-logical-resize/CHANGELOG.md b/plugins/postcss-logical-resize/CHANGELOG.md index e1c787f43..136549c84 100644 --- a/plugins/postcss-logical-resize/CHANGELOG.md +++ b/plugins/postcss-logical-resize/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Logical Resize +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.0.0 _August 3, 2024_ diff --git a/plugins/postcss-logical-resize/dist/index.cjs b/plugins/postcss-logical-resize/dist/index.cjs deleted file mode 100644 index 4b47d55d8..000000000 --- a/plugins/postcss-logical-resize/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var o,t,e,i=require("postcss-value-parser");function cloneDeclaration(o,t,e){o.parent&&o.parent.some(o=>"decl"==o.type&&o.prop===e&&o.value===t)||o.cloneBefore({value:t,prop:e})}function transformResize(o){return t=>{const{prop:e,value:n}=t,r=i(n),c=o.inlineIsHorizontal?"horizontal":"vertical",s=o.inlineIsHorizontal?"vertical":"horizontal";r.nodes.forEach(o=>{if("word"===o.type){const t=o.value.toLowerCase();if("inline"===t)return void(o.value=c);"block"===t&&(o.value=s)}});const l=r.toString();return l!==n&&(cloneDeclaration(t,l,e),!0)}}function directionFlowToAxes(o){switch(o){case t.TopToBottom:return[e.Top,e.Bottom];case t.BottomToTop:return[e.Bottom,e.Top];case t.RightToLeft:return[e.Right,e.Left];case t.LeftToRight:return[e.Left,e.Right]}}!function(o){o.Block="block",o.Inline="inline"}(o||(o={})),function(o){o.TopToBottom="top-to-bottom",o.BottomToTop="bottom-to-top",o.RightToLeft="right-to-left",o.LeftToRight="left-to-right"}(t||(t={})),function(o){o.Top="top",o.Right="right",o.Bottom="bottom",o.Left="left"}(e||(e={}));const creator=o=>{const i=Object.assign({blockDirection:t.TopToBottom,inlineDirection:t.LeftToRight},o),n=Object.values(t);if(!n.includes(i.blockDirection))throw new Error(`[postcss-logical-resize] "blockDirection" must be one of ${n.join(", ")}`);if(!n.includes(i.inlineDirection))throw new Error(`[postcss-logical-resize] "inlineDirection" must be one of ${n.join(", ")}`);const[r,c]=directionFlowToAxes(i.blockDirection),[s,l]=directionFlowToAxes(i.inlineDirection);if(!Object.values(e).every(o=>[r,c,s,l].includes(o)))throw new Error('[postcss-logical-resize] "blockDirection" and "inlineDirection" must be on separate axes');const a={block:[r,c],inline:[s,l],inlineIsHorizontal:[t.LeftToRight,t.RightToLeft].includes(i.inlineDirection)};return{postcssPlugin:"postcss-logical-resize",Declaration:{resize:(u=transformResize(a),(o,{result:t})=>{if(!u)return;let e=!1;try{e=u(o)}catch(e){return void o.warn(t,e instanceof Error?e.message:String(e))}e&&o.remove()})}};var u};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-logical-resize/dist/index.d.ts b/plugins/postcss-logical-resize/dist/index.d.ts index 1a57d9f9e..2c1122de7 100644 --- a/plugins/postcss-logical-resize/dist/index.d.ts +++ b/plugins/postcss-logical-resize/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export declare enum DirectionFlow { TopToBottom = "top-to-bottom", diff --git a/plugins/postcss-logical-resize/dist/index.mjs b/plugins/postcss-logical-resize/dist/index.mjs index 457fe9d6f..dc4505e66 100644 --- a/plugins/postcss-logical-resize/dist/index.mjs +++ b/plugins/postcss-logical-resize/dist/index.mjs @@ -1 +1 @@ -import o from"postcss-value-parser";var t,e,i;function cloneDeclaration(o,t,e){o.parent&&o.parent.some(o=>"decl"==o.type&&o.prop===e&&o.value===t)||o.cloneBefore({value:t,prop:e})}function transformResize(t){return e=>{const{prop:i,value:n}=e,r=o(n),c=t.inlineIsHorizontal?"horizontal":"vertical",s=t.inlineIsHorizontal?"vertical":"horizontal";r.nodes.forEach(o=>{if("word"===o.type){const t=o.value.toLowerCase();if("inline"===t)return void(o.value=c);"block"===t&&(o.value=s)}});const l=r.toString();return l!==n&&(cloneDeclaration(e,l,i),!0)}}function directionFlowToAxes(o){switch(o){case e.TopToBottom:return[i.Top,i.Bottom];case e.BottomToTop:return[i.Bottom,i.Top];case e.RightToLeft:return[i.Right,i.Left];case e.LeftToRight:return[i.Left,i.Right]}}!function(o){o.Block="block",o.Inline="inline"}(t||(t={})),function(o){o.TopToBottom="top-to-bottom",o.BottomToTop="bottom-to-top",o.RightToLeft="right-to-left",o.LeftToRight="left-to-right"}(e||(e={})),function(o){o.Top="top",o.Right="right",o.Bottom="bottom",o.Left="left"}(i||(i={}));const creator=o=>{const t=Object.assign({blockDirection:e.TopToBottom,inlineDirection:e.LeftToRight},o),n=Object.values(e);if(!n.includes(t.blockDirection))throw new Error(`[postcss-logical-resize] "blockDirection" must be one of ${n.join(", ")}`);if(!n.includes(t.inlineDirection))throw new Error(`[postcss-logical-resize] "inlineDirection" must be one of ${n.join(", ")}`);const[r,c]=directionFlowToAxes(t.blockDirection),[s,l]=directionFlowToAxes(t.inlineDirection);if(!Object.values(i).every(o=>[r,c,s,l].includes(o)))throw new Error('[postcss-logical-resize] "blockDirection" and "inlineDirection" must be on separate axes');const a={block:[r,c],inline:[s,l],inlineIsHorizontal:[e.LeftToRight,e.RightToLeft].includes(t.inlineDirection)};return{postcssPlugin:"postcss-logical-resize",Declaration:{resize:(u=transformResize(a),(o,{result:t})=>{if(!u)return;let e=!1;try{e=u(o)}catch(e){return void o.warn(t,e instanceof Error?e.message:String(e))}e&&o.remove()})}};var u};creator.postcss=!0;export{creator as default}; +import o from"postcss-value-parser";var t,e,i;function cloneDeclaration(o,t,e){o.parent&&o.parent.some(o=>"decl"==o.type&&o.prop===e&&o.value===t)||o.cloneBefore({value:t,prop:e})}function transformResize(t){return e=>{const{prop:i,value:n}=e,r=o(n),c=t.inlineIsHorizontal?"horizontal":"vertical",s=t.inlineIsHorizontal?"vertical":"horizontal";r.nodes.forEach(o=>{if("word"===o.type){const t=o.value.toLowerCase();if("inline"===t)return void(o.value=c);"block"===t&&(o.value=s)}});const l=r.toString();return l!==n&&(cloneDeclaration(e,l,i),!0)}}function directionFlowToAxes(o){switch(o){case e.TopToBottom:return[i.Top,i.Bottom];case e.BottomToTop:return[i.Bottom,i.Top];case e.RightToLeft:return[i.Right,i.Left];case e.LeftToRight:return[i.Left,i.Right]}}!function(o){o.Block="block",o.Inline="inline"}(t||(t={})),function(o){o.TopToBottom="top-to-bottom",o.BottomToTop="bottom-to-top",o.RightToLeft="right-to-left",o.LeftToRight="left-to-right"}(e||(e={})),function(o){o.Top="top",o.Right="right",o.Bottom="bottom",o.Left="left"}(i||(i={}));const creator=o=>{const t=Object.assign({blockDirection:e.TopToBottom,inlineDirection:e.LeftToRight},o),n=Object.values(e);if(!n.includes(t.blockDirection))throw new Error(`[postcss-logical-resize] "blockDirection" must be one of ${n.join(", ")}`);if(!n.includes(t.inlineDirection))throw new Error(`[postcss-logical-resize] "inlineDirection" must be one of ${n.join(", ")}`);const[r,c]=directionFlowToAxes(t.blockDirection),[s,l]=directionFlowToAxes(t.inlineDirection);if(!Object.values(i).every(o=>[r,c,s,l].includes(o)))throw new Error('[postcss-logical-resize] "blockDirection" and "inlineDirection" must be on separate axes');const a={block:[r,c],inline:[s,l],inlineIsHorizontal:[e.LeftToRight,e.RightToLeft].includes(t.inlineDirection)};return{postcssPlugin:"postcss-logical-resize",Declaration:{resize:(u=transformResize(a),(o,{result:t})=>{if(!u)return;let e=!1;try{e=u(o)}catch(e){return void o.warn(t,e instanceof Error?e.message:String(e))}e&&o.remove()})}};var u};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-logical-resize/package.json b/plugins/postcss-logical-resize/package.json index 54a552f4d..761e37405 100644 --- a/plugins/postcss-logical-resize/package.json +++ b/plugins/postcss-logical-resize/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-logical-resize/src/index.ts b/plugins/postcss-logical-resize/src/index.ts index a815a4036..01e165234 100644 --- a/plugins/postcss-logical-resize/src/index.ts +++ b/plugins/postcss-logical-resize/src/index.ts @@ -87,3 +87,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-logical-viewport-units/CHANGELOG.md b/plugins/postcss-logical-viewport-units/CHANGELOG.md index b20060854..712f3be68 100644 --- a/plugins/postcss-logical-viewport-units/CHANGELOG.md +++ b/plugins/postcss-logical-viewport-units/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Logical Viewport Units +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.0.4 _May 27, 2025_ diff --git a/plugins/postcss-logical-viewport-units/dist/index.cjs b/plugins/postcss-logical-viewport-units/dist/index.cjs deleted file mode 100644 index 099f2144c..000000000 --- a/plugins/postcss-logical-viewport-units/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var t,e=require("@csstools/utilities"),o=require("@csstools/css-tokenizer");function transform(t,e){const i=o.tokenizer({css:t}),n=[];let s=!1;for(;;){const t=i.nextToken();if(!t)break;if(n.push(t),o.isTokenEOF(t))break;if(!o.isTokenDimension(t))continue;const r=t[4].unit.toLowerCase();let c;"vi"===r?c=e.vi:"vb"===r&&(c=e.vb),c&&(t[1]=t[4].value.toString()+c,t[4].unit=c,s=!0)}return s?o.stringify(...n):t}!function(t){t.TopToBottom="top-to-bottom",t.BottomToTop="bottom-to-top",t.RightToLeft="right-to-left",t.LeftToRight="left-to-right"}(t||(t={}));const i=/vb|vi/i,n={test(t){if(!i.test(t))return!1;const e=o.tokenizer({css:t});for(;;){const t=e.nextToken();if(o.isTokenEOF(t))break;if(!o.isTokenDimension(t))continue;const i=t[4].unit.toLowerCase();if("vb"===i||"vi"===i)return!0}return!1}},s=/(?:vi|vb)\b/i,creator=o=>{const i=Object.assign({inlineDirection:t.LeftToRight,preserve:!0},o);switch(i.inlineDirection){case t.LeftToRight:case t.RightToLeft:case t.TopToBottom:case t.BottomToTop:break;default:throw new Error(`[postcss-logical-viewport-units] "inlineDirection" must be one of ${Object.values(t).join(", ")}`)}const r=[t.LeftToRight,t.RightToLeft].includes(i.inlineDirection),c={vb:"vh",vi:"vw"};return r||(c.vb="vw",c.vi="vh"),{postcssPlugin:"postcss-logical-viewport-units",Declaration(t,{atRule:o}){if(!s.test(t.value))return;if(e.hasFallback(t))return;if(e.hasSupportsAtRuleAncestor(t,n))return;const r=transform(t.value,c);if(r===t.value)return;if(t.cloneBefore({value:r}),!i.preserve)return void t.remove();if(!t.variable)return;const u=o({name:"supports",params:"(top: 1vi)",source:t.source}),a=t.parent;if(!a)return;const f=a.cloneAfter({nodes:[]});f.append(t),u.append(f),a.after(u)}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-logical-viewport-units/dist/index.d.ts b/plugins/postcss-logical-viewport-units/dist/index.d.ts index 7933d724d..a9bc2e832 100644 --- a/plugins/postcss-logical-viewport-units/dist/index.d.ts +++ b/plugins/postcss-logical-viewport-units/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export declare enum DirectionFlow { TopToBottom = "top-to-bottom", diff --git a/plugins/postcss-logical-viewport-units/dist/index.mjs b/plugins/postcss-logical-viewport-units/dist/index.mjs index 36955fbda..c20ba2402 100644 --- a/plugins/postcss-logical-viewport-units/dist/index.mjs +++ b/plugins/postcss-logical-viewport-units/dist/index.mjs @@ -1 +1 @@ -import{hasFallback as t,hasSupportsAtRuleAncestor as o}from"@csstools/utilities";import{tokenizer as e,isTokenEOF as i,isTokenDimension as n,stringify as r}from"@csstools/css-tokenizer";var s;function transform(t,o){const s=e({css:t}),c=[];let u=!1;for(;;){const t=s.nextToken();if(!t)break;if(c.push(t),i(t))break;if(!n(t))continue;const e=t[4].unit.toLowerCase();let r;"vi"===e?r=o.vi:"vb"===e&&(r=o.vb),r&&(t[1]=t[4].value.toString()+r,t[4].unit=r,u=!0)}return u?r(...c):t}!function(t){t.TopToBottom="top-to-bottom",t.BottomToTop="bottom-to-top",t.RightToLeft="right-to-left",t.LeftToRight="left-to-right"}(s||(s={}));const c=/vb|vi/i,u={test(t){if(!c.test(t))return!1;const o=e({css:t});for(;;){const t=o.nextToken();if(i(t))break;if(!n(t))continue;const e=t[4].unit.toLowerCase();if("vb"===e||"vi"===e)return!0}return!1}},a=/(?:vi|vb)\b/i,creator=e=>{const i=Object.assign({inlineDirection:s.LeftToRight,preserve:!0},e);switch(i.inlineDirection){case s.LeftToRight:case s.RightToLeft:case s.TopToBottom:case s.BottomToTop:break;default:throw new Error(`[postcss-logical-viewport-units] "inlineDirection" must be one of ${Object.values(s).join(", ")}`)}const n=[s.LeftToRight,s.RightToLeft].includes(i.inlineDirection),r={vb:"vh",vi:"vw"};return n||(r.vb="vw",r.vi="vh"),{postcssPlugin:"postcss-logical-viewport-units",Declaration(e,{atRule:n}){if(!a.test(e.value))return;if(t(e))return;if(o(e,u))return;const s=transform(e.value,r);if(s===e.value)return;if(e.cloneBefore({value:s}),!i.preserve)return void e.remove();if(!e.variable)return;const c=n({name:"supports",params:"(top: 1vi)",source:e.source}),f=e.parent;if(!f)return;const v=f.cloneAfter({nodes:[]});v.append(e),c.append(v),f.after(c)}}};creator.postcss=!0;export{creator as default}; +import{hasFallback as t,hasSupportsAtRuleAncestor as o}from"@csstools/utilities";import{tokenizer as e,isTokenEOF as i,isTokenDimension as r,stringify as n}from"@csstools/css-tokenizer";var s;function transform(t,o){const s=e({css:t}),c=[];let u=!1;for(;;){const t=s.nextToken();if(!t)break;if(c.push(t),i(t))break;if(!r(t))continue;const e=t[4].unit.toLowerCase();let n;"vi"===e?n=o.vi:"vb"===e&&(n=o.vb),n&&(t[1]=t[4].value.toString()+n,t[4].unit=n,u=!0)}return u?n(...c):t}!function(t){t.TopToBottom="top-to-bottom",t.BottomToTop="bottom-to-top",t.RightToLeft="right-to-left",t.LeftToRight="left-to-right"}(s||(s={}));const c=/vb|vi/i,u={test(t){if(!c.test(t))return!1;const o=e({css:t});for(;;){const t=o.nextToken();if(i(t))break;if(!r(t))continue;const e=t[4].unit.toLowerCase();if("vb"===e||"vi"===e)return!0}return!1}},a=/(?:vi|vb)\b/i,creator=e=>{const i=Object.assign({inlineDirection:s.LeftToRight,preserve:!0},e);switch(i.inlineDirection){case s.LeftToRight:case s.RightToLeft:case s.TopToBottom:case s.BottomToTop:break;default:throw new Error(`[postcss-logical-viewport-units] "inlineDirection" must be one of ${Object.values(s).join(", ")}`)}const r=[s.LeftToRight,s.RightToLeft].includes(i.inlineDirection),n={vb:"vh",vi:"vw"};return r||(n.vb="vw",n.vi="vh"),{postcssPlugin:"postcss-logical-viewport-units",Declaration(e,{atRule:r}){if(!a.test(e.value))return;if(t(e))return;if(o(e,u))return;const s=transform(e.value,n);if(s===e.value)return;if(e.cloneBefore({value:s}),!i.preserve)return void e.remove();if(!e.variable)return;const c=r({name:"supports",params:"(top: 1vi)",source:e.source}),f=e.parent;if(!f)return;const v=f.cloneAfter({nodes:[]});v.append(e),c.append(v),f.after(c)}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-logical-viewport-units/package.json b/plugins/postcss-logical-viewport-units/package.json index 2a66d7594..5ace6984b 100644 --- a/plugins/postcss-logical-viewport-units/package.json +++ b/plugins/postcss-logical-viewport-units/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-logical-viewport-units/src/index.ts b/plugins/postcss-logical-viewport-units/src/index.ts index 66dfc5649..b89e21124 100644 --- a/plugins/postcss-logical-viewport-units/src/index.ts +++ b/plugins/postcss-logical-viewport-units/src/index.ts @@ -109,3 +109,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-logical/CHANGELOG.md b/plugins/postcss-logical/CHANGELOG.md index 977f16cbd..307f1b337 100644 --- a/plugins/postcss-logical/CHANGELOG.md +++ b/plugins/postcss-logical/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Logical Properties +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 8.1.0 _February 23, 2025_ diff --git a/plugins/postcss-logical/dist/index.cjs b/plugins/postcss-logical/dist/index.cjs deleted file mode 100644 index 36ab9bc27..000000000 --- a/plugins/postcss-logical/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var r,e,n=require("postcss-value-parser");!function(r){r.Block="block",r.Inline="inline"}(r||(r={})),function(r){r.Start="start",r.End="end"}(e||(e={}));const o={BlockStart:"block-start",BlockEnd:"block-end",InlineStart:"inline-start",InlineEnd:"inline-end"};var t,i;function directionFlowToAxes(r){switch(r){case t.TopToBottom:return[i.Top,i.Bottom];case t.BottomToTop:return[i.Bottom,i.Top];case t.RightToLeft:return[i.Right,i.Left];case t.LeftToRight:return[i.Left,i.Right]}}function cloneDeclaration(r,e,n){return r.parent&&r.parent.some(r=>"decl"==r.type&&r.prop===n&&r.value===e)?[]:[r.clone({value:e,prop:n})]}function transformTransition(r,e,o){const{prop:t,value:i}=r,l=n(i),a=[];let s=[];l.nodes.forEach(r=>{if("div"===r.type&&","===r.value)return a.push(s),void(s=[]);s.push(r)}),a.push(s);for(let r=0;r=0;e--){const o=JSON.parse(JSON.stringify(n));o[t].value=d[e].prop,a.splice(r+1,0,o)}a.splice(r,1),r++}}}const d=[];for(let r=0;r"space"!==r.type);if(e.length>2||0===e.length){const n=`[postcss-logical] Invalid number of values for ${r.prop}. Found ${e.length} values, expected 1 or 2.`;throw r.error(n)}let o,t;return 1===e.length?(o=n.stringify(e[0]),t=o):(o=n.stringify(e[0]),t=n.stringify(e[1])),[o,t]}function transformBorder(r,e){return n=>cloneDeclaration(n,n.value,`border-${e}-${r}`)}function transformBorderProperty(r,e){return n=>{const[o,t]=e,[i,l]=parseValueCouple(n);return[...cloneDeclaration(n,i,`border-${o}-${r}`),...cloneDeclaration(n,l,`border-${t}-${r}`)]}}function transformBorderShorthand(r){return e=>r.flatMap(r=>cloneDeclaration(e,e.value,`border-${r}`))}function transformBorderRadius(r){return e=>{let n;switch(e.prop.toLowerCase()){case"border-start-start-radius":n=`border-${r.inlineIsHorizontal?`${r.block[0]}-${r.inline[0]}`:`${r.inline[0]}-${r.block[0]}`}-radius`;break;case"border-start-end-radius":n=`border-${r.inlineIsHorizontal?`${r.block[0]}-${r.inline[1]}`:`${r.inline[1]}-${r.block[0]}`}-radius`;break;case"border-end-start-radius":n=`border-${r.inlineIsHorizontal?`${r.block[1]}-${r.inline[0]}`:`${r.inline[0]}-${r.block[1]}`}-radius`;break;case"border-end-end-radius":n=`border-${r.inlineIsHorizontal?`${r.block[1]}-${r.inline[1]}`:`${r.inline[1]}-${r.block[1]}`}-radius`;break}return n?cloneDeclaration(e,e.value,n):[]}}function transformLogicalSize(r){return e=>{const{value:n}=e,o=r.inlineIsHorizontal?"width":"height",t=r.inlineIsHorizontal?"height":"width",i=e.prop.toLowerCase().replace("inline-size",o).replace("block-size",t);return cloneDeclaration(e,n,i)}}function transformOffset(r){return e=>cloneDeclaration(e,e.value,r)}function transformOffsetShorthand(r){return e=>{const[n,o]=r,[t,i]=parseValueCouple(e);return[...cloneDeclaration(e,t,n),...cloneDeclaration(e,i,o)]}}function transformSide(r,e){return n=>cloneDeclaration(n,n.value,`${r}-${e}`)}function transformSideShorthand(r,e){return n=>{const[o,t]=e,[i,l]=parseValueCouple(n);return[...cloneDeclaration(n,i,`${r}-${o}`),...cloneDeclaration(n,l,`${r}-${t}`)]}}function logicalToPhysical(r,e){const[n,t]=e.block,[i,l]=e.inline;switch(r){case o.BlockStart:return n;case o.BlockEnd:return t;case o.InlineStart:return i;case o.InlineEnd:return l;default:throw new Error("Unsupported logical direction")}}function doTransform(r,e,o){const{prop:t,value:i}=r,l=n(i);l.nodes.forEach(r=>{if("word"===r.type){const n=r.value.toLowerCase();e.includes(n)&&(r.value=logicalToPhysical(n,o))}});const a=l.toString();return a!==i?cloneDeclaration(r,a,t):[]}function prepareTransforms(r,t,i,l,a){return{"caption-side":(d=r,r=>doTransform(r,Object.values(o),d)),"text-align":r.inlineIsHorizontal?(s=r.inline,r=>{const{prop:o,value:t}=r,i=n(t),[l,a]=s;i.nodes.forEach(r=>{if("word"===r.type){const n=r.value.toLowerCase();if(n===e.End)return void(r.value=a);if(n===e.Start)return void(r.value=l)}});const d=i.toString();return d!==t?cloneDeclaration(r,d,o):[]}):null,"block-size":transformLogicalSize(r),"inline-size":transformLogicalSize(r),"min-block-size":transformLogicalSize(r),"max-block-size":transformLogicalSize(r),"min-inline-size":transformLogicalSize(r),"max-inline-size":transformLogicalSize(r),"margin-block-start":transformSide("margin",t),"margin-block-end":transformSide("margin",i),"margin-inline-start":transformSide("margin",l),"margin-inline-end":transformSide("margin",a),"margin-block":transformSideShorthand("margin",r.block),"margin-inline":transformSideShorthand("margin",r.inline),"inset-block":transformOffsetShorthand(r.block),"inset-block-start":transformOffset(t),"inset-block-end":transformOffset(i),"inset-inline":transformOffsetShorthand(r.inline),"inset-inline-start":transformOffset(l),"inset-inline-end":transformOffset(a),inset:r=>{const e=n(r.value).nodes.filter(r=>"space"!==r.type&&"comment"!==r.type);if(e.length>4){const n=`[postcss-logical] Invalid number of values for ${r.prop}. Found ${e.length} values, expected up to 4 values.`;throw r.error(n)}let o,t,i,l;if(1===e.length)o=n.stringify(e[0]),t=o,i=o,l=o;else if(2===e.length)o=n.stringify(e[0]),t=n.stringify(e[1]),i=o,l=t;else if(3===e.length)o=n.stringify(e[0]),t=n.stringify(e[1]),l=t,i=n.stringify(e[2]);else{if(4!==e.length)return[];o=n.stringify(e[0]),t=n.stringify(e[1]),i=n.stringify(e[2]),l=n.stringify(e[3])}return[...cloneDeclaration(r,o,"top"),...cloneDeclaration(r,t,"right"),...cloneDeclaration(r,i,"bottom"),...cloneDeclaration(r,l,"left")]},"padding-block-start":transformSide("padding",t),"padding-block-end":transformSide("padding",i),"padding-inline-start":transformSide("padding",l),"padding-inline-end":transformSide("padding",a),"padding-block":transformSideShorthand("padding",r.block),"padding-inline":transformSideShorthand("padding",r.inline),"border-block-start-width":transformBorder("width",t),"border-block-end-width":transformBorder("width",i),"border-inline-start-width":transformBorder("width",l),"border-inline-end-width":transformBorder("width",a),"border-block-width":transformBorderProperty("width",r.block),"border-inline-width":transformBorderProperty("width",r.inline),"border-block-start-style":transformBorder("style",t),"border-block-end-style":transformBorder("style",i),"border-inline-start-style":transformBorder("style",l),"border-inline-end-style":transformBorder("style",a),"border-block-style":transformBorderProperty("style",r.block),"border-inline-style":transformBorderProperty("style",r.inline),"border-block-start-color":transformBorder("color",t),"border-block-end-color":transformBorder("color",i),"border-inline-start-color":transformBorder("color",l),"border-inline-end-color":transformBorder("color",a),"border-block-color":transformBorderProperty("color",r.block),"border-inline-color":transformBorderProperty("color",r.inline),"border-block":transformBorderShorthand(r.block),"border-block-start":transformBorderShorthand([t]),"border-block-end":transformBorderShorthand([i]),"border-inline":transformBorderShorthand(r.inline),"border-inline-start":transformBorderShorthand([l]),"border-inline-end":transformBorderShorthand([a]),"border-start-start-radius":transformBorderRadius(r),"border-start-end-radius":transformBorderRadius(r),"border-end-start-radius":transformBorderRadius(r),"border-end-end-radius":transformBorderRadius(r)};var s,d}!function(r){r.TopToBottom="top-to-bottom",r.BottomToTop="bottom-to-top",r.RightToLeft="right-to-left",r.LeftToRight="left-to-right"}(t||(t={})),function(r){r.Top="top",r.Right="right",r.Bottom="bottom",r.Left="left"}(i||(i={}));const l=/var\(/i,creator=r=>{const e=Object.assign({blockDirection:t.TopToBottom,inlineDirection:t.LeftToRight},r),n=Object.values(t);if(!n.includes(e.blockDirection))throw new Error(`[postcss-logical] "blockDirection" must be one of ${n.join(", ")}`);if(!n.includes(e.inlineDirection))throw new Error(`[postcss-logical] "inlineDirection" must be one of ${n.join(", ")}`);const[o,a]=directionFlowToAxes(e.blockDirection),[s,d]=directionFlowToAxes(e.inlineDirection);if(!Object.values(i).every(r=>[o,a,s,d].includes(r)))throw new Error('[postcss-logical] "blockDirection" and "inlineDirection" must be on separate axes');const makeTransform=r=>(n,{result:o})=>{if(!r)return;if(e.ignoreCustomProperties&&l.test(n.value))return;let t=[];try{t=r(n)}catch(r){return void n.warn(o,r instanceof Error?r.message:String(r))}t?.length&&(t.forEach(r=>{n.cloneBefore(r)}),n.remove())},c=prepareTransforms({block:[o,a],inline:[s,d],inlineIsHorizontal:[t.LeftToRight,t.RightToLeft].includes(e.inlineDirection)},o,a,s,d);return{postcssPlugin:"postcss-logical",Declaration:{"caption-side":makeTransform(c["caption-side"]),"text-align":makeTransform(c["text-align"]),"block-size":makeTransform(c["block-size"]),"inline-size":makeTransform(c["inline-size"]),"min-block-size":makeTransform(c["min-block-size"]),"max-block-size":makeTransform(c["max-block-size"]),"min-inline-size":makeTransform(c["min-inline-size"]),"max-inline-size":makeTransform(c["max-inline-size"]),"margin-block-start":makeTransform(c["margin-block-start"]),"margin-block-end":makeTransform(c["margin-block-end"]),"margin-inline-start":makeTransform(c["margin-inline-start"]),"margin-inline-end":makeTransform(c["margin-inline-end"]),"margin-block":makeTransform(c["margin-block"]),"margin-inline":makeTransform(c["margin-inline"]),"inset-block":makeTransform(c["inset-block"]),"inset-block-start":makeTransform(c["inset-block-start"]),"inset-block-end":makeTransform(c["inset-block-end"]),"inset-inline":makeTransform(c["inset-inline"]),"inset-inline-start":makeTransform(c["inset-inline-start"]),"inset-inline-end":makeTransform(c["inset-inline-end"]),inset:makeTransform(c.inset),"padding-block-start":makeTransform(c["padding-block-start"]),"padding-block-end":makeTransform(c["padding-block-end"]),"padding-inline-start":makeTransform(c["padding-inline-start"]),"padding-inline-end":makeTransform(c["padding-inline-end"]),"padding-block":makeTransform(c["padding-block"]),"padding-inline":makeTransform(c["padding-inline"]),"border-block-start-width":makeTransform(c["border-block-start-width"]),"border-block-end-width":makeTransform(c["border-block-end-width"]),"border-inline-start-width":makeTransform(c["border-inline-start-width"]),"border-inline-end-width":makeTransform(c["border-inline-end-width"]),"border-block-width":makeTransform(c["border-block-width"]),"border-inline-width":makeTransform(c["border-inline-width"]),"border-block-start-style":makeTransform(c["border-block-start-style"]),"border-block-end-style":makeTransform(c["border-block-end-style"]),"border-inline-start-style":makeTransform(c["border-inline-start-style"]),"border-inline-end-style":makeTransform(c["border-inline-end-style"]),"border-block-style":makeTransform(c["border-block-style"]),"border-inline-style":makeTransform(c["border-inline-style"]),"border-block-start-color":makeTransform(c["border-block-start-color"]),"border-block-end-color":makeTransform(c["border-block-end-color"]),"border-inline-start-color":makeTransform(c["border-inline-start-color"]),"border-inline-end-color":makeTransform(c["border-inline-end-color"]),"border-block-color":makeTransform(c["border-block-color"]),"border-inline-color":makeTransform(c["border-inline-color"]),"border-block":makeTransform(c["border-block"]),"border-block-start":makeTransform(c["border-block-start"]),"border-block-end":makeTransform(c["border-block-end"]),"border-inline":makeTransform(c["border-inline"]),"border-inline-start":makeTransform(c["border-inline-start"]),"border-inline-end":makeTransform(c["border-inline-end"]),"border-start-start-radius":makeTransform(c["border-start-start-radius"]),"border-start-end-radius":makeTransform(c["border-start-end-radius"]),"border-end-start-radius":makeTransform(c["border-end-start-radius"]),"border-end-end-radius":makeTransform(c["border-end-end-radius"]),transition:(r,{result:n,postcss:o})=>{if(e.ignoreCustomProperties&&l.test(r.value))return;let t=[];try{t=transformTransition(r,o,c)}catch(e){return void r.warn(n,e instanceof Error?e.message:String(e))}t?.length&&(t.forEach(e=>{r.cloneBefore(e)}),r.remove())}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-logical/dist/index.d.ts b/plugins/postcss-logical/dist/index.d.ts index 185bfe33d..77da222db 100644 --- a/plugins/postcss-logical/dist/index.d.ts +++ b/plugins/postcss-logical/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export declare enum DirectionFlow { TopToBottom = "top-to-bottom", diff --git a/plugins/postcss-logical/dist/index.mjs b/plugins/postcss-logical/dist/index.mjs index d66d226f4..d3c9de752 100644 --- a/plugins/postcss-logical/dist/index.mjs +++ b/plugins/postcss-logical/dist/index.mjs @@ -1 +1 @@ -import r from"postcss-value-parser";var e,n;!function(r){r.Block="block",r.Inline="inline"}(e||(e={})),function(r){r.Start="start",r.End="end"}(n||(n={}));const o={BlockStart:"block-start",BlockEnd:"block-end",InlineStart:"inline-start",InlineEnd:"inline-end"};var t,i;function directionFlowToAxes(r){switch(r){case t.TopToBottom:return[i.Top,i.Bottom];case t.BottomToTop:return[i.Bottom,i.Top];case t.RightToLeft:return[i.Right,i.Left];case t.LeftToRight:return[i.Left,i.Right]}}function cloneDeclaration(r,e,n){return r.parent&&r.parent.some(r=>"decl"==r.type&&r.prop===n&&r.value===e)?[]:[r.clone({value:e,prop:n})]}function transformTransition(e,n,o){const{prop:t,value:i}=e,l=r(i),a=[];let s=[];l.nodes.forEach(r=>{if("div"===r.type&&","===r.value)return a.push(s),void(s=[]);s.push(r)}),a.push(s);for(let r=0;r=0;n--){const o=JSON.parse(JSON.stringify(e));o[t].value=d[n].prop,a.splice(r+1,0,o)}a.splice(r,1),r++}}}const d=[];for(let r=0;r"space"!==r.type);if(n.length>2||0===n.length){const r=`[postcss-logical] Invalid number of values for ${e.prop}. Found ${n.length} values, expected 1 or 2.`;throw e.error(r)}let o,t;return 1===n.length?(o=r.stringify(n[0]),t=o):(o=r.stringify(n[0]),t=r.stringify(n[1])),[o,t]}function transformBorder(r,e){return n=>cloneDeclaration(n,n.value,`border-${e}-${r}`)}function transformBorderProperty(r,e){return n=>{const[o,t]=e,[i,l]=parseValueCouple(n);return[...cloneDeclaration(n,i,`border-${o}-${r}`),...cloneDeclaration(n,l,`border-${t}-${r}`)]}}function transformBorderShorthand(r){return e=>r.flatMap(r=>cloneDeclaration(e,e.value,`border-${r}`))}function transformBorderRadius(r){return e=>{let n;switch(e.prop.toLowerCase()){case"border-start-start-radius":n=`border-${r.inlineIsHorizontal?`${r.block[0]}-${r.inline[0]}`:`${r.inline[0]}-${r.block[0]}`}-radius`;break;case"border-start-end-radius":n=`border-${r.inlineIsHorizontal?`${r.block[0]}-${r.inline[1]}`:`${r.inline[1]}-${r.block[0]}`}-radius`;break;case"border-end-start-radius":n=`border-${r.inlineIsHorizontal?`${r.block[1]}-${r.inline[0]}`:`${r.inline[0]}-${r.block[1]}`}-radius`;break;case"border-end-end-radius":n=`border-${r.inlineIsHorizontal?`${r.block[1]}-${r.inline[1]}`:`${r.inline[1]}-${r.block[1]}`}-radius`;break}return n?cloneDeclaration(e,e.value,n):[]}}function transformLogicalSize(r){return e=>{const{value:n}=e,o=r.inlineIsHorizontal?"width":"height",t=r.inlineIsHorizontal?"height":"width",i=e.prop.toLowerCase().replace("inline-size",o).replace("block-size",t);return cloneDeclaration(e,n,i)}}function transformOffset(r){return e=>cloneDeclaration(e,e.value,r)}function transformOffsetShorthand(r){return e=>{const[n,o]=r,[t,i]=parseValueCouple(e);return[...cloneDeclaration(e,t,n),...cloneDeclaration(e,i,o)]}}function transformSide(r,e){return n=>cloneDeclaration(n,n.value,`${r}-${e}`)}function transformSideShorthand(r,e){return n=>{const[o,t]=e,[i,l]=parseValueCouple(n);return[...cloneDeclaration(n,i,`${r}-${o}`),...cloneDeclaration(n,l,`${r}-${t}`)]}}function logicalToPhysical(r,e){const[n,t]=e.block,[i,l]=e.inline;switch(r){case o.BlockStart:return n;case o.BlockEnd:return t;case o.InlineStart:return i;case o.InlineEnd:return l;default:throw new Error("Unsupported logical direction")}}function doTransform(e,n,o){const{prop:t,value:i}=e,l=r(i);l.nodes.forEach(r=>{if("word"===r.type){const e=r.value.toLowerCase();n.includes(e)&&(r.value=logicalToPhysical(e,o))}});const a=l.toString();return a!==i?cloneDeclaration(e,a,t):[]}function prepareTransforms(e,t,i,l,a){return{"caption-side":(d=e,r=>doTransform(r,Object.values(o),d)),"text-align":e.inlineIsHorizontal?(s=e.inline,e=>{const{prop:o,value:t}=e,i=r(t),[l,a]=s;i.nodes.forEach(r=>{if("word"===r.type){const e=r.value.toLowerCase();if(e===n.End)return void(r.value=a);if(e===n.Start)return void(r.value=l)}});const d=i.toString();return d!==t?cloneDeclaration(e,d,o):[]}):null,"block-size":transformLogicalSize(e),"inline-size":transformLogicalSize(e),"min-block-size":transformLogicalSize(e),"max-block-size":transformLogicalSize(e),"min-inline-size":transformLogicalSize(e),"max-inline-size":transformLogicalSize(e),"margin-block-start":transformSide("margin",t),"margin-block-end":transformSide("margin",i),"margin-inline-start":transformSide("margin",l),"margin-inline-end":transformSide("margin",a),"margin-block":transformSideShorthand("margin",e.block),"margin-inline":transformSideShorthand("margin",e.inline),"inset-block":transformOffsetShorthand(e.block),"inset-block-start":transformOffset(t),"inset-block-end":transformOffset(i),"inset-inline":transformOffsetShorthand(e.inline),"inset-inline-start":transformOffset(l),"inset-inline-end":transformOffset(a),inset:e=>{const n=r(e.value).nodes.filter(r=>"space"!==r.type&&"comment"!==r.type);if(n.length>4){const r=`[postcss-logical] Invalid number of values for ${e.prop}. Found ${n.length} values, expected up to 4 values.`;throw e.error(r)}let o,t,i,l;if(1===n.length)o=r.stringify(n[0]),t=o,i=o,l=o;else if(2===n.length)o=r.stringify(n[0]),t=r.stringify(n[1]),i=o,l=t;else if(3===n.length)o=r.stringify(n[0]),t=r.stringify(n[1]),l=t,i=r.stringify(n[2]);else{if(4!==n.length)return[];o=r.stringify(n[0]),t=r.stringify(n[1]),i=r.stringify(n[2]),l=r.stringify(n[3])}return[...cloneDeclaration(e,o,"top"),...cloneDeclaration(e,t,"right"),...cloneDeclaration(e,i,"bottom"),...cloneDeclaration(e,l,"left")]},"padding-block-start":transformSide("padding",t),"padding-block-end":transformSide("padding",i),"padding-inline-start":transformSide("padding",l),"padding-inline-end":transformSide("padding",a),"padding-block":transformSideShorthand("padding",e.block),"padding-inline":transformSideShorthand("padding",e.inline),"border-block-start-width":transformBorder("width",t),"border-block-end-width":transformBorder("width",i),"border-inline-start-width":transformBorder("width",l),"border-inline-end-width":transformBorder("width",a),"border-block-width":transformBorderProperty("width",e.block),"border-inline-width":transformBorderProperty("width",e.inline),"border-block-start-style":transformBorder("style",t),"border-block-end-style":transformBorder("style",i),"border-inline-start-style":transformBorder("style",l),"border-inline-end-style":transformBorder("style",a),"border-block-style":transformBorderProperty("style",e.block),"border-inline-style":transformBorderProperty("style",e.inline),"border-block-start-color":transformBorder("color",t),"border-block-end-color":transformBorder("color",i),"border-inline-start-color":transformBorder("color",l),"border-inline-end-color":transformBorder("color",a),"border-block-color":transformBorderProperty("color",e.block),"border-inline-color":transformBorderProperty("color",e.inline),"border-block":transformBorderShorthand(e.block),"border-block-start":transformBorderShorthand([t]),"border-block-end":transformBorderShorthand([i]),"border-inline":transformBorderShorthand(e.inline),"border-inline-start":transformBorderShorthand([l]),"border-inline-end":transformBorderShorthand([a]),"border-start-start-radius":transformBorderRadius(e),"border-start-end-radius":transformBorderRadius(e),"border-end-start-radius":transformBorderRadius(e),"border-end-end-radius":transformBorderRadius(e)};var s,d}!function(r){r.TopToBottom="top-to-bottom",r.BottomToTop="bottom-to-top",r.RightToLeft="right-to-left",r.LeftToRight="left-to-right"}(t||(t={})),function(r){r.Top="top",r.Right="right",r.Bottom="bottom",r.Left="left"}(i||(i={}));const l=/var\(/i,creator=r=>{const e=Object.assign({blockDirection:t.TopToBottom,inlineDirection:t.LeftToRight},r),n=Object.values(t);if(!n.includes(e.blockDirection))throw new Error(`[postcss-logical] "blockDirection" must be one of ${n.join(", ")}`);if(!n.includes(e.inlineDirection))throw new Error(`[postcss-logical] "inlineDirection" must be one of ${n.join(", ")}`);const[o,a]=directionFlowToAxes(e.blockDirection),[s,d]=directionFlowToAxes(e.inlineDirection);if(!Object.values(i).every(r=>[o,a,s,d].includes(r)))throw new Error('[postcss-logical] "blockDirection" and "inlineDirection" must be on separate axes');const makeTransform=r=>(n,{result:o})=>{if(!r)return;if(e.ignoreCustomProperties&&l.test(n.value))return;let t=[];try{t=r(n)}catch(r){return void n.warn(o,r instanceof Error?r.message:String(r))}t?.length&&(t.forEach(r=>{n.cloneBefore(r)}),n.remove())},c=prepareTransforms({block:[o,a],inline:[s,d],inlineIsHorizontal:[t.LeftToRight,t.RightToLeft].includes(e.inlineDirection)},o,a,s,d);return{postcssPlugin:"postcss-logical",Declaration:{"caption-side":makeTransform(c["caption-side"]),"text-align":makeTransform(c["text-align"]),"block-size":makeTransform(c["block-size"]),"inline-size":makeTransform(c["inline-size"]),"min-block-size":makeTransform(c["min-block-size"]),"max-block-size":makeTransform(c["max-block-size"]),"min-inline-size":makeTransform(c["min-inline-size"]),"max-inline-size":makeTransform(c["max-inline-size"]),"margin-block-start":makeTransform(c["margin-block-start"]),"margin-block-end":makeTransform(c["margin-block-end"]),"margin-inline-start":makeTransform(c["margin-inline-start"]),"margin-inline-end":makeTransform(c["margin-inline-end"]),"margin-block":makeTransform(c["margin-block"]),"margin-inline":makeTransform(c["margin-inline"]),"inset-block":makeTransform(c["inset-block"]),"inset-block-start":makeTransform(c["inset-block-start"]),"inset-block-end":makeTransform(c["inset-block-end"]),"inset-inline":makeTransform(c["inset-inline"]),"inset-inline-start":makeTransform(c["inset-inline-start"]),"inset-inline-end":makeTransform(c["inset-inline-end"]),inset:makeTransform(c.inset),"padding-block-start":makeTransform(c["padding-block-start"]),"padding-block-end":makeTransform(c["padding-block-end"]),"padding-inline-start":makeTransform(c["padding-inline-start"]),"padding-inline-end":makeTransform(c["padding-inline-end"]),"padding-block":makeTransform(c["padding-block"]),"padding-inline":makeTransform(c["padding-inline"]),"border-block-start-width":makeTransform(c["border-block-start-width"]),"border-block-end-width":makeTransform(c["border-block-end-width"]),"border-inline-start-width":makeTransform(c["border-inline-start-width"]),"border-inline-end-width":makeTransform(c["border-inline-end-width"]),"border-block-width":makeTransform(c["border-block-width"]),"border-inline-width":makeTransform(c["border-inline-width"]),"border-block-start-style":makeTransform(c["border-block-start-style"]),"border-block-end-style":makeTransform(c["border-block-end-style"]),"border-inline-start-style":makeTransform(c["border-inline-start-style"]),"border-inline-end-style":makeTransform(c["border-inline-end-style"]),"border-block-style":makeTransform(c["border-block-style"]),"border-inline-style":makeTransform(c["border-inline-style"]),"border-block-start-color":makeTransform(c["border-block-start-color"]),"border-block-end-color":makeTransform(c["border-block-end-color"]),"border-inline-start-color":makeTransform(c["border-inline-start-color"]),"border-inline-end-color":makeTransform(c["border-inline-end-color"]),"border-block-color":makeTransform(c["border-block-color"]),"border-inline-color":makeTransform(c["border-inline-color"]),"border-block":makeTransform(c["border-block"]),"border-block-start":makeTransform(c["border-block-start"]),"border-block-end":makeTransform(c["border-block-end"]),"border-inline":makeTransform(c["border-inline"]),"border-inline-start":makeTransform(c["border-inline-start"]),"border-inline-end":makeTransform(c["border-inline-end"]),"border-start-start-radius":makeTransform(c["border-start-start-radius"]),"border-start-end-radius":makeTransform(c["border-start-end-radius"]),"border-end-start-radius":makeTransform(c["border-end-start-radius"]),"border-end-end-radius":makeTransform(c["border-end-end-radius"]),transition:(r,{result:n,postcss:o})=>{if(e.ignoreCustomProperties&&l.test(r.value))return;let t=[];try{t=transformTransition(r,o,c)}catch(e){return void r.warn(n,e instanceof Error?e.message:String(e))}t?.length&&(t.forEach(e=>{r.cloneBefore(e)}),r.remove())}}}};creator.postcss=!0;export{creator as default}; +import r from"postcss-value-parser";var e,n;!function(r){r.Block="block",r.Inline="inline"}(e||(e={})),function(r){r.Start="start",r.End="end"}(n||(n={}));const o={BlockStart:"block-start",BlockEnd:"block-end",InlineStart:"inline-start",InlineEnd:"inline-end"};var t,i;function directionFlowToAxes(r){switch(r){case t.TopToBottom:return[i.Top,i.Bottom];case t.BottomToTop:return[i.Bottom,i.Top];case t.RightToLeft:return[i.Right,i.Left];case t.LeftToRight:return[i.Left,i.Right]}}function cloneDeclaration(r,e,n){return r.parent&&r.parent.some(r=>"decl"==r.type&&r.prop===n&&r.value===e)?[]:[r.clone({value:e,prop:n})]}function transformTransition(e,n,o){const{prop:t,value:i}=e,l=r(i),a=[];let s=[];l.nodes.forEach(r=>{if("div"===r.type&&","===r.value)return a.push(s),void(s=[]);s.push(r)}),a.push(s);for(let r=0;r=0;n--){const o=JSON.parse(JSON.stringify(e));o[t].value=d[n].prop,a.splice(r+1,0,o)}a.splice(r,1),r++}}}const d=[];for(let r=0;r"space"!==r.type);if(n.length>2||0===n.length){const r=`[postcss-logical] Invalid number of values for ${e.prop}. Found ${n.length} values, expected 1 or 2.`;throw e.error(r)}let o,t;return 1===n.length?(o=r.stringify(n[0]),t=o):(o=r.stringify(n[0]),t=r.stringify(n[1])),[o,t]}function transformBorder(r,e){return n=>cloneDeclaration(n,n.value,`border-${e}-${r}`)}function transformBorderProperty(r,e){return n=>{const[o,t]=e,[i,l]=parseValueCouple(n);return[...cloneDeclaration(n,i,`border-${o}-${r}`),...cloneDeclaration(n,l,`border-${t}-${r}`)]}}function transformBorderShorthand(r){return e=>r.flatMap(r=>cloneDeclaration(e,e.value,`border-${r}`))}function transformBorderRadius(r){return e=>{let n;switch(e.prop.toLowerCase()){case"border-start-start-radius":n=`border-${r.inlineIsHorizontal?`${r.block[0]}-${r.inline[0]}`:`${r.inline[0]}-${r.block[0]}`}-radius`;break;case"border-start-end-radius":n=`border-${r.inlineIsHorizontal?`${r.block[0]}-${r.inline[1]}`:`${r.inline[1]}-${r.block[0]}`}-radius`;break;case"border-end-start-radius":n=`border-${r.inlineIsHorizontal?`${r.block[1]}-${r.inline[0]}`:`${r.inline[0]}-${r.block[1]}`}-radius`;break;case"border-end-end-radius":n=`border-${r.inlineIsHorizontal?`${r.block[1]}-${r.inline[1]}`:`${r.inline[1]}-${r.block[1]}`}-radius`;break}return n?cloneDeclaration(e,e.value,n):[]}}function transformLogicalSize(r){return e=>{const{value:n}=e,o=r.inlineIsHorizontal?"width":"height",t=r.inlineIsHorizontal?"height":"width",i=e.prop.toLowerCase().replace("inline-size",o).replace("block-size",t);return cloneDeclaration(e,n,i)}}function transformOffset(r){return e=>cloneDeclaration(e,e.value,r)}function transformOffsetShorthand(r){return e=>{const[n,o]=r,[t,i]=parseValueCouple(e);return[...cloneDeclaration(e,t,n),...cloneDeclaration(e,i,o)]}}function transformSide(r,e){return n=>cloneDeclaration(n,n.value,`${r}-${e}`)}function transformSideShorthand(r,e){return n=>{const[o,t]=e,[i,l]=parseValueCouple(n);return[...cloneDeclaration(n,i,`${r}-${o}`),...cloneDeclaration(n,l,`${r}-${t}`)]}}function logicalToPhysical(r,e){const[n,t]=e.block,[i,l]=e.inline;switch(r){case o.BlockStart:return n;case o.BlockEnd:return t;case o.InlineStart:return i;case o.InlineEnd:return l;default:throw new Error("Unsupported logical direction")}}function doTransform(e,n,o){const{prop:t,value:i}=e,l=r(i);l.nodes.forEach(r=>{if("word"===r.type){const e=r.value.toLowerCase();n.includes(e)&&(r.value=logicalToPhysical(e,o))}});const a=l.toString();return a!==i?cloneDeclaration(e,a,t):[]}function prepareTransforms(e,t,i,l,a){return{"caption-side":(d=e,r=>doTransform(r,Object.values(o),d)),"text-align":e.inlineIsHorizontal?(s=e.inline,e=>{const{prop:o,value:t}=e,i=r(t),[l,a]=s;i.nodes.forEach(r=>{if("word"===r.type){const e=r.value.toLowerCase();if(e===n.End)return void(r.value=a);if(e===n.Start)return void(r.value=l)}});const d=i.toString();return d!==t?cloneDeclaration(e,d,o):[]}):null,"block-size":transformLogicalSize(e),"inline-size":transformLogicalSize(e),"min-block-size":transformLogicalSize(e),"max-block-size":transformLogicalSize(e),"min-inline-size":transformLogicalSize(e),"max-inline-size":transformLogicalSize(e),"margin-block-start":transformSide("margin",t),"margin-block-end":transformSide("margin",i),"margin-inline-start":transformSide("margin",l),"margin-inline-end":transformSide("margin",a),"margin-block":transformSideShorthand("margin",e.block),"margin-inline":transformSideShorthand("margin",e.inline),"inset-block":transformOffsetShorthand(e.block),"inset-block-start":transformOffset(t),"inset-block-end":transformOffset(i),"inset-inline":transformOffsetShorthand(e.inline),"inset-inline-start":transformOffset(l),"inset-inline-end":transformOffset(a),inset:e=>{const n=r(e.value).nodes.filter(r=>"space"!==r.type&&"comment"!==r.type);if(n.length>4){const r=`[postcss-logical] Invalid number of values for ${e.prop}. Found ${n.length} values, expected up to 4 values.`;throw e.error(r)}let o,t,i,l;if(1===n.length)o=r.stringify(n[0]),t=o,i=o,l=o;else if(2===n.length)o=r.stringify(n[0]),t=r.stringify(n[1]),i=o,l=t;else if(3===n.length)o=r.stringify(n[0]),t=r.stringify(n[1]),l=t,i=r.stringify(n[2]);else{if(4!==n.length)return[];o=r.stringify(n[0]),t=r.stringify(n[1]),i=r.stringify(n[2]),l=r.stringify(n[3])}return[...cloneDeclaration(e,o,"top"),...cloneDeclaration(e,t,"right"),...cloneDeclaration(e,i,"bottom"),...cloneDeclaration(e,l,"left")]},"padding-block-start":transformSide("padding",t),"padding-block-end":transformSide("padding",i),"padding-inline-start":transformSide("padding",l),"padding-inline-end":transformSide("padding",a),"padding-block":transformSideShorthand("padding",e.block),"padding-inline":transformSideShorthand("padding",e.inline),"border-block-start-width":transformBorder("width",t),"border-block-end-width":transformBorder("width",i),"border-inline-start-width":transformBorder("width",l),"border-inline-end-width":transformBorder("width",a),"border-block-width":transformBorderProperty("width",e.block),"border-inline-width":transformBorderProperty("width",e.inline),"border-block-start-style":transformBorder("style",t),"border-block-end-style":transformBorder("style",i),"border-inline-start-style":transformBorder("style",l),"border-inline-end-style":transformBorder("style",a),"border-block-style":transformBorderProperty("style",e.block),"border-inline-style":transformBorderProperty("style",e.inline),"border-block-start-color":transformBorder("color",t),"border-block-end-color":transformBorder("color",i),"border-inline-start-color":transformBorder("color",l),"border-inline-end-color":transformBorder("color",a),"border-block-color":transformBorderProperty("color",e.block),"border-inline-color":transformBorderProperty("color",e.inline),"border-block":transformBorderShorthand(e.block),"border-block-start":transformBorderShorthand([t]),"border-block-end":transformBorderShorthand([i]),"border-inline":transformBorderShorthand(e.inline),"border-inline-start":transformBorderShorthand([l]),"border-inline-end":transformBorderShorthand([a]),"border-start-start-radius":transformBorderRadius(e),"border-start-end-radius":transformBorderRadius(e),"border-end-start-radius":transformBorderRadius(e),"border-end-end-radius":transformBorderRadius(e)};var s,d}!function(r){r.TopToBottom="top-to-bottom",r.BottomToTop="bottom-to-top",r.RightToLeft="right-to-left",r.LeftToRight="left-to-right"}(t||(t={})),function(r){r.Top="top",r.Right="right",r.Bottom="bottom",r.Left="left"}(i||(i={}));const l=/var\(/i,creator=r=>{const e=Object.assign({blockDirection:t.TopToBottom,inlineDirection:t.LeftToRight},r),n=Object.values(t);if(!n.includes(e.blockDirection))throw new Error(`[postcss-logical] "blockDirection" must be one of ${n.join(", ")}`);if(!n.includes(e.inlineDirection))throw new Error(`[postcss-logical] "inlineDirection" must be one of ${n.join(", ")}`);const[o,a]=directionFlowToAxes(e.blockDirection),[s,d]=directionFlowToAxes(e.inlineDirection);if(!Object.values(i).every(r=>[o,a,s,d].includes(r)))throw new Error('[postcss-logical] "blockDirection" and "inlineDirection" must be on separate axes');const makeTransform=r=>(n,{result:o})=>{if(!r)return;if(e.ignoreCustomProperties&&l.test(n.value))return;let t=[];try{t=r(n)}catch(r){return void n.warn(o,r instanceof Error?r.message:String(r))}t?.length&&(t.forEach(r=>{n.cloneBefore(r)}),n.remove())},c=prepareTransforms({block:[o,a],inline:[s,d],inlineIsHorizontal:[t.LeftToRight,t.RightToLeft].includes(e.inlineDirection)},o,a,s,d);return{postcssPlugin:"postcss-logical",Declaration:{"caption-side":makeTransform(c["caption-side"]),"text-align":makeTransform(c["text-align"]),"block-size":makeTransform(c["block-size"]),"inline-size":makeTransform(c["inline-size"]),"min-block-size":makeTransform(c["min-block-size"]),"max-block-size":makeTransform(c["max-block-size"]),"min-inline-size":makeTransform(c["min-inline-size"]),"max-inline-size":makeTransform(c["max-inline-size"]),"margin-block-start":makeTransform(c["margin-block-start"]),"margin-block-end":makeTransform(c["margin-block-end"]),"margin-inline-start":makeTransform(c["margin-inline-start"]),"margin-inline-end":makeTransform(c["margin-inline-end"]),"margin-block":makeTransform(c["margin-block"]),"margin-inline":makeTransform(c["margin-inline"]),"inset-block":makeTransform(c["inset-block"]),"inset-block-start":makeTransform(c["inset-block-start"]),"inset-block-end":makeTransform(c["inset-block-end"]),"inset-inline":makeTransform(c["inset-inline"]),"inset-inline-start":makeTransform(c["inset-inline-start"]),"inset-inline-end":makeTransform(c["inset-inline-end"]),inset:makeTransform(c.inset),"padding-block-start":makeTransform(c["padding-block-start"]),"padding-block-end":makeTransform(c["padding-block-end"]),"padding-inline-start":makeTransform(c["padding-inline-start"]),"padding-inline-end":makeTransform(c["padding-inline-end"]),"padding-block":makeTransform(c["padding-block"]),"padding-inline":makeTransform(c["padding-inline"]),"border-block-start-width":makeTransform(c["border-block-start-width"]),"border-block-end-width":makeTransform(c["border-block-end-width"]),"border-inline-start-width":makeTransform(c["border-inline-start-width"]),"border-inline-end-width":makeTransform(c["border-inline-end-width"]),"border-block-width":makeTransform(c["border-block-width"]),"border-inline-width":makeTransform(c["border-inline-width"]),"border-block-start-style":makeTransform(c["border-block-start-style"]),"border-block-end-style":makeTransform(c["border-block-end-style"]),"border-inline-start-style":makeTransform(c["border-inline-start-style"]),"border-inline-end-style":makeTransform(c["border-inline-end-style"]),"border-block-style":makeTransform(c["border-block-style"]),"border-inline-style":makeTransform(c["border-inline-style"]),"border-block-start-color":makeTransform(c["border-block-start-color"]),"border-block-end-color":makeTransform(c["border-block-end-color"]),"border-inline-start-color":makeTransform(c["border-inline-start-color"]),"border-inline-end-color":makeTransform(c["border-inline-end-color"]),"border-block-color":makeTransform(c["border-block-color"]),"border-inline-color":makeTransform(c["border-inline-color"]),"border-block":makeTransform(c["border-block"]),"border-block-start":makeTransform(c["border-block-start"]),"border-block-end":makeTransform(c["border-block-end"]),"border-inline":makeTransform(c["border-inline"]),"border-inline-start":makeTransform(c["border-inline-start"]),"border-inline-end":makeTransform(c["border-inline-end"]),"border-start-start-radius":makeTransform(c["border-start-start-radius"]),"border-start-end-radius":makeTransform(c["border-start-end-radius"]),"border-end-start-radius":makeTransform(c["border-end-start-radius"]),"border-end-end-radius":makeTransform(c["border-end-end-radius"]),transition:(r,{result:n,postcss:o})=>{if(e.ignoreCustomProperties&&l.test(r.value))return;let t=[];try{t=transformTransition(r,o,c)}catch(e){return void r.warn(n,e instanceof Error?e.message:String(e))}t?.length&&(t.forEach(e=>{r.cloneBefore(e)}),r.remove())}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-logical/package.json b/plugins/postcss-logical/package.json index 725c019b9..4b99f013d 100644 --- a/plugins/postcss-logical/package.json +++ b/plugins/postcss-logical/package.json @@ -29,20 +29,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-logical/src/index.ts b/plugins/postcss-logical/src/index.ts index 70bbb59c1..742cf06df 100644 --- a/plugins/postcss-logical/src/index.ts +++ b/plugins/postcss-logical/src/index.ts @@ -190,3 +190,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-media-minmax/CHANGELOG.md b/plugins/postcss-media-minmax/CHANGELOG.md index 4dc1e022e..9a6b4986c 100644 --- a/plugins/postcss-media-minmax/CHANGELOG.md +++ b/plugins/postcss-media-minmax/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Media MinMax +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.9 _May 27, 2025_ diff --git a/plugins/postcss-media-minmax/dist/index.cjs b/plugins/postcss-media-minmax/dist/index.cjs deleted file mode 100644 index f636047c3..000000000 --- a/plugins/postcss-media-minmax/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-parser-algorithms"),i=require("@csstools/css-tokenizer"),n=require("@csstools/media-query-list-parser"),a=require("@csstools/css-calc");const t={width:"px",height:"px","device-width":"px","device-height":"px","aspect-ratio":"","device-aspect-ratio":"",color:"","color-index":"",monochrome:"",resolution:"dpi"},r={width:!1,height:!1,"device-width":!1,"device-height":!1,"aspect-ratio":!1,"device-aspect-ratio":!1,color:!0,"color-index":!0,monochrome:!0,resolution:"dpi"};function featureNamePrefix(e){return e===n.MediaFeatureLT.LT||e===n.MediaFeatureLT.LT_OR_EQ?"max-":e===n.MediaFeatureGT.GT||e===n.MediaFeatureGT.GT_OR_EQ?"min-":""}const o={">":1,"<":-1},s=.001;function transformSingleNameValuePair(u,d,l,c){let p=l.before,m=l.after;if(c||(p=l.after,m=l.before),!c){const e=n.invertComparison(d);if(!1===e)return;d=e}if(d===n.MediaFeatureEQ.EQ||d===n.MediaFeatureLT.LT_OR_EQ||d===n.MediaFeatureGT.GT_OR_EQ)return Array.isArray(l.value)?n.newMediaFeaturePlain(featureNamePrefix(d)+u,...p,...l.value.flatMap(e=>e.tokens()),...m):n.newMediaFeaturePlain(featureNamePrefix(d)+u,...p,...l.value.tokens(),...m);let T,f,v=!1;if(Array.isArray(l.value)){if(!n.matchesRatioExactly(l.value))return;if("aspect-ratio"!==u&&"device-aspect-ratio"!==u)return;const e=n.matchesRatio(l.value);if(-1===e)return;v=!0,T=l.value[e[0]],f=[...l.value.slice(e[0]+1).flatMap(e=>e.tokens())]}else T=l.value,f=[];const y=t[u.toLowerCase()];if(e.isFunctionNode(T)){const t=T.getName().toLowerCase();if(a.mathFunctionNames.has(t)||"env"===t){const[[t]]=a.calcFromComponentValues([[T]],{precision:5,toCanonicalUnits:!0});if(!(t&&e.isTokenNode(t)&&i.isTokenNumeric(t.value)&&Number.isInteger(t.value[4].value))){let e;if(void 0!==y){const n=o[d]*("px"===y?.02:s);e=[i.TokenType.Dimension,`${n.toString()}${y}`,-1,-1,{value:n,unit:y,type:i.NumberType.Integer}]}else if(!0===r[u]){const n=o[d];e=[i.TokenType.Number,n.toString(),-1,-1,{value:n,type:i.NumberType.Integer}]}else if(v){const n=o[d]*s;e=[i.TokenType.Number,n.toString(),-1,-1,{value:n,type:i.NumberType.Integer}]}else{const n=o[d];e=[i.TokenType.Number,n.toString(),-1,-1,{value:n,type:i.NumberType.Integer}]}return n.newMediaFeaturePlain(featureNamePrefix(d)+u,...p,[i.TokenType.Function,"calc(",-1,-1,{value:"calc("}],[i.TokenType.OpenParen,"(",-1,-1,void 0],...T.tokens().slice(1),[i.TokenType.Whitespace," ",-1,-1,void 0],[i.TokenType.Delim,"+",-1,-1,{value:"+"}],[i.TokenType.Whitespace," ",-1,-1,void 0],e,[i.TokenType.CloseParen,")",-1,-1,void 0],...f,...m)}T=t}}if(!e.isTokenNode(T))return;let h,M=T.value,g="";if(void 0!==y&&i.isTokenNumber(M)&&0===M[4].value)h=o[d],g=y;else if(i.isTokenNumber(M)&&0===M[4].value)h=o[d],g="";else if(i.isTokenDimension(M)&&0===M[4].value)h=o[d],g=M[4].unit;else if(i.isTokenNumber(M)&&!0===r[u])h=M[4].value+o[d];else if(i.isTokenDimension(M)&&"px"===M[4].unit&&M[4].type===i.NumberType.Integer)h=Number(Math.round(Number(M[4].value+.02*o[d]+"e6"))+"e-6");else{if(!i.isTokenDimension(M)&&!i.isTokenNumber(M))return;h=Number(Math.round(Number(M[4].value+s*o[d]+"e6"))+"e-6")}return g&&(M=[i.TokenType.Dimension,M[1],M[2],M[3],{value:M[4].value,unit:g,type:M[4].type}]),M[4].value=h,i.isTokenDimension(M)?M[1]=M[4].value.toString()+M[4].unit:M[1]=M[4].value.toString(),n.newMediaFeaturePlain(featureNamePrefix(d)+u,...p,M,...f,...m)}const u=new Set(["aspect-ratio","color","color-index","device-aspect-ratio","device-height","device-width","height","horizontal-viewport-segments","monochrome","resolution","vertical-viewport-segments","width"]);function transform(a){return a.map((a,t)=>{const r=e.gatherNodeAncestry(a);a.walk(e=>{const t=e.node;if(!n.isMediaFeatureRange(t))return;const o=e.parent;if(!n.isMediaFeature(o))return;const s=t.name.getName().toLowerCase();if(!u.has(s))return;if(n.isMediaFeatureRangeNameValue(t)||n.isMediaFeatureRangeValueName(t)){const e=t.operatorKind();if(!1===e)return;const i=transformSingleNameValuePair(s,e,t.value,n.isMediaFeatureRangeNameValue(t));return void(i&&(o.feature=i.feature))}const d=r.get(o);if(!n.isMediaInParens(d))return;let l=null,c=null;{const e=t.valueOneOperatorKind();if(!1===e)return;const i=transformSingleNameValuePair(s,e,t.valueOne,!1);if(!i)return;e===n.MediaFeatureLT.LT||e===n.MediaFeatureLT.LT_OR_EQ?(l=i,l.before=o.before):(c=i,c.after=o.after)}{const e=t.valueTwoOperatorKind();if(!1===e)return;const i=transformSingleNameValuePair(s,e,t.valueTwo,!0);if(!i)return;e===n.MediaFeatureLT.LT||e===n.MediaFeatureLT.LT_OR_EQ?(c=i,c.before=o.before):(l=i,l.after=o.after)}if(!l||!c)return;const p=new n.MediaInParens(l),m=new n.MediaInParens(c),T=getMediaConditionListWithAndFromAncestry(d,r);if(T)return T.leading===d?(T.leading=p,void(T.list=[new n.MediaAnd([[i.TokenType.Whitespace," ",-1,-1,void 0],[i.TokenType.Ident,"and",-1,-1,{value:"and"}],[i.TokenType.Whitespace," ",-1,-1,void 0]],m),...T.list])):void T.list.splice(T.indexOf(r.get(d)),1,new n.MediaAnd([[i.TokenType.Whitespace," ",-1,-1,void 0],[i.TokenType.Ident,"and",-1,-1,{value:"and"}],[i.TokenType.Whitespace," ",-1,-1,void 0]],p),new n.MediaAnd([[i.TokenType.Whitespace," ",-1,-1,void 0],[i.TokenType.Ident,"and",-1,-1,{value:"and"}],[i.TokenType.Whitespace," ",-1,-1,void 0]],m));const f=new n.MediaConditionListWithAnd(p,[new n.MediaAnd([[i.TokenType.Whitespace," ",-1,-1,void 0],[i.TokenType.Ident,"and",-1,-1,{value:"and"}],[i.TokenType.Whitespace," ",-1,-1,void 0]],m)],[[i.TokenType.Whitespace," ",-1,-1,void 0]]),v=getMediaConditionInShallowMediaQueryFromAncestry(d,a,r);v?v.media=f:d.media=new n.MediaCondition(new n.MediaInParens(new n.MediaCondition(f),[[i.TokenType.Whitespace," ",-1,-1,void 0],[i.TokenType.OpenParen,"(",-1,-1,void 0]],[[i.TokenType.CloseParen,")",-1,-1,void 0]]))});const o=a.tokens();return i.stringify(...o.filter((e,n)=>(0!==n||0!==t||!i.isTokenWhitespace(e))&&!(i.isTokenWhitespace(e)&&o[n+1]&&i.isTokenWhitespace(o[n+1]))))}).join(",")}function getMediaConditionListWithAndFromAncestry(e,i){let a=e;if(a){if(a=i.get(a),n.isMediaConditionListWithAnd(a))return a;if(n.isMediaAnd(a))return a=i.get(a),n.isMediaConditionListWithAnd(a)?a:void 0}}function getMediaConditionInShallowMediaQueryFromAncestry(e,i,a){let t=e;if(!t)return;if(t=a.get(t),!n.isMediaCondition(t))return;const r=t;return t=a.get(t),n.isMediaQuery(t)&&t===i?r:void 0}const creator=()=>({postcssPlugin:"postcss-media-minmax",AtRule:{media(e){if(!(e.params.includes("<")||e.params.includes(">")||e.params.includes("=")))return;const i=transform(n.parse(e.params,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw e.error(`Unable to parse media query "${e.params}"`)}}));e.params!==i&&(e.params=i)},"custom-media"(e){if(!(e.params.includes("<")||e.params.includes(">")||e.params.includes("=")))return;const a=n.parseCustomMedia(e.params,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw e.error(`Unable to parse media query "${e.params}"`)}});if(!a||!a.mediaQueryList)return;const t=a.mediaQueryList.map(e=>e.toString()).join(","),r=transform(a.mediaQueryList);t!==r&&(e.params=`${i.stringify(...a.name)} ${r}`)}}});creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-media-minmax/dist/index.d.ts b/plugins/postcss-media-minmax/dist/index.d.ts index e60e05c07..f7766d4f4 100644 --- a/plugins/postcss-media-minmax/dist/index.d.ts +++ b/plugins/postcss-media-minmax/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-media-minmax plugin options */ export declare type pluginOptions = never; diff --git a/plugins/postcss-media-minmax/dist/index.mjs b/plugins/postcss-media-minmax/dist/index.mjs index 69f2c850a..cd3170f5a 100644 --- a/plugins/postcss-media-minmax/dist/index.mjs +++ b/plugins/postcss-media-minmax/dist/index.mjs @@ -1 +1 @@ -import{isFunctionNode as e,isTokenNode as t,gatherNodeAncestry as r}from"@csstools/css-parser-algorithms";import{isTokenNumeric as i,TokenType as a,NumberType as n,isTokenNumber as o,isTokenDimension as s,stringify as u,isTokenWhitespace as l}from"@csstools/css-tokenizer";import{invertComparison as c,MediaFeatureEQ as d,MediaFeatureLT as f,MediaFeatureGT as m,newMediaFeaturePlain as v,matchesRatioExactly as p,matchesRatio as h,isMediaFeatureRange as g,isMediaFeature as w,isMediaFeatureRangeNameValue as y,isMediaFeatureRangeValueName as N,isMediaInParens as x,MediaInParens as b,MediaAnd as P,MediaConditionListWithAnd as L,MediaCondition as I,isMediaConditionListWithAnd as Q,isMediaAnd as S,isMediaCondition as W,isMediaQuery as O,parseCustomMedia as M,parse as T}from"@csstools/media-query-list-parser";import{mathFunctionNames as _,calcFromComponentValues as A}from"@csstools/css-calc";const C={width:"px",height:"px","device-width":"px","device-height":"px","aspect-ratio":"","device-aspect-ratio":"",color:"","color-index":"",monochrome:"",resolution:"dpi"},E={width:!1,height:!1,"device-width":!1,"device-height":!1,"aspect-ratio":!1,"device-aspect-ratio":!1,color:!0,"color-index":!0,monochrome:!0,resolution:"dpi"};function featureNamePrefix(e){return e===f.LT||e===f.LT_OR_EQ?"max-":e===m.GT||e===m.GT_OR_EQ?"min-":""}const k={">":1,"<":-1},R=.001;function transformSingleNameValuePair(r,u,l,g){let w=l.before,y=l.after;if(g||(w=l.after,y=l.before),!g){const e=c(u);if(!1===e)return;u=e}if(u===d.EQ||u===f.LT_OR_EQ||u===m.GT_OR_EQ)return Array.isArray(l.value)?v(featureNamePrefix(u)+r,...w,...l.value.flatMap(e=>e.tokens()),...y):v(featureNamePrefix(u)+r,...w,...l.value.tokens(),...y);let N,x,b=!1;if(Array.isArray(l.value)){if(!p(l.value))return;if("aspect-ratio"!==r&&"device-aspect-ratio"!==r)return;const e=h(l.value);if(-1===e)return;b=!0,N=l.value[e[0]],x=[...l.value.slice(e[0]+1).flatMap(e=>e.tokens())]}else N=l.value,x=[];const P=C[r.toLowerCase()];if(e(N)){const e=N.getName().toLowerCase();if(_.has(e)||"env"===e){const[[e]]=A([[N]],{precision:5,toCanonicalUnits:!0});if(!(e&&t(e)&&i(e.value)&&Number.isInteger(e.value[4].value))){let e;if(void 0!==P){const t=k[u]*("px"===P?.02:R);e=[a.Dimension,`${t.toString()}${P}`,-1,-1,{value:t,unit:P,type:n.Integer}]}else if(!0===E[r]){const t=k[u];e=[a.Number,t.toString(),-1,-1,{value:t,type:n.Integer}]}else if(b){const t=k[u]*R;e=[a.Number,t.toString(),-1,-1,{value:t,type:n.Integer}]}else{const t=k[u];e=[a.Number,t.toString(),-1,-1,{value:t,type:n.Integer}]}return v(featureNamePrefix(u)+r,...w,[a.Function,"calc(",-1,-1,{value:"calc("}],[a.OpenParen,"(",-1,-1,void 0],...N.tokens().slice(1),[a.Whitespace," ",-1,-1,void 0],[a.Delim,"+",-1,-1,{value:"+"}],[a.Whitespace," ",-1,-1,void 0],e,[a.CloseParen,")",-1,-1,void 0],...x,...y)}N=e}}if(!t(N))return;let L,I=N.value,Q="";if(void 0!==P&&o(I)&&0===I[4].value)L=k[u],Q=P;else if(o(I)&&0===I[4].value)L=k[u],Q="";else if(s(I)&&0===I[4].value)L=k[u],Q=I[4].unit;else if(o(I)&&!0===E[r])L=I[4].value+k[u];else if(s(I)&&"px"===I[4].unit&&I[4].type===n.Integer)L=Number(Math.round(Number(I[4].value+.02*k[u]+"e6"))+"e-6");else{if(!s(I)&&!o(I))return;L=Number(Math.round(Number(I[4].value+R*k[u]+"e6"))+"e-6")}return Q&&(I=[a.Dimension,I[1],I[2],I[3],{value:I[4].value,unit:Q,type:I[4].type}]),I[4].value=L,s(I)?I[1]=I[4].value.toString()+I[4].unit:I[1]=I[4].value.toString(),v(featureNamePrefix(u)+r,...w,I,...x,...y)}const $=new Set(["aspect-ratio","color","color-index","device-aspect-ratio","device-height","device-width","height","horizontal-viewport-segments","monochrome","resolution","vertical-viewport-segments","width"]);function transform(e){return e.map((e,t)=>{const i=r(e);e.walk(t=>{const r=t.node;if(!g(r))return;const n=t.parent;if(!w(n))return;const o=r.name.getName().toLowerCase();if(!$.has(o))return;if(y(r)||N(r)){const e=r.operatorKind();if(!1===e)return;const t=transformSingleNameValuePair(o,e,r.value,y(r));return void(t&&(n.feature=t.feature))}const s=i.get(n);if(!x(s))return;let u=null,l=null;{const e=r.valueOneOperatorKind();if(!1===e)return;const t=transformSingleNameValuePair(o,e,r.valueOne,!1);if(!t)return;e===f.LT||e===f.LT_OR_EQ?(u=t,u.before=n.before):(l=t,l.after=n.after)}{const e=r.valueTwoOperatorKind();if(!1===e)return;const t=transformSingleNameValuePair(o,e,r.valueTwo,!0);if(!t)return;e===f.LT||e===f.LT_OR_EQ?(l=t,l.before=n.before):(u=t,u.after=n.after)}if(!u||!l)return;const c=new b(u),d=new b(l),m=getMediaConditionListWithAndFromAncestry(s,i);if(m)return m.leading===s?(m.leading=c,void(m.list=[new P([[a.Whitespace," ",-1,-1,void 0],[a.Ident,"and",-1,-1,{value:"and"}],[a.Whitespace," ",-1,-1,void 0]],d),...m.list])):void m.list.splice(m.indexOf(i.get(s)),1,new P([[a.Whitespace," ",-1,-1,void 0],[a.Ident,"and",-1,-1,{value:"and"}],[a.Whitespace," ",-1,-1,void 0]],c),new P([[a.Whitespace," ",-1,-1,void 0],[a.Ident,"and",-1,-1,{value:"and"}],[a.Whitespace," ",-1,-1,void 0]],d));const v=new L(c,[new P([[a.Whitespace," ",-1,-1,void 0],[a.Ident,"and",-1,-1,{value:"and"}],[a.Whitespace," ",-1,-1,void 0]],d)],[[a.Whitespace," ",-1,-1,void 0]]),p=getMediaConditionInShallowMediaQueryFromAncestry(s,e,i);p?p.media=v:s.media=new I(new b(new I(v),[[a.Whitespace," ",-1,-1,void 0],[a.OpenParen,"(",-1,-1,void 0]],[[a.CloseParen,")",-1,-1,void 0]]))});const n=e.tokens();return u(...n.filter((e,r)=>(0!==r||0!==t||!l(e))&&!(l(e)&&n[r+1]&&l(n[r+1]))))}).join(",")}function getMediaConditionListWithAndFromAncestry(e,t){let r=e;if(r){if(r=t.get(r),Q(r))return r;if(S(r))return r=t.get(r),Q(r)?r:void 0}}function getMediaConditionInShallowMediaQueryFromAncestry(e,t,r){let i=e;if(!i)return;if(i=r.get(i),!W(i))return;const a=i;return i=r.get(i),O(i)&&i===t?a:void 0}const creator=()=>({postcssPlugin:"postcss-media-minmax",AtRule:{media(e){if(!(e.params.includes("<")||e.params.includes(">")||e.params.includes("=")))return;const t=transform(T(e.params,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw e.error(`Unable to parse media query "${e.params}"`)}}));e.params!==t&&(e.params=t)},"custom-media"(e){if(!(e.params.includes("<")||e.params.includes(">")||e.params.includes("=")))return;const t=M(e.params,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw e.error(`Unable to parse media query "${e.params}"`)}});if(!t||!t.mediaQueryList)return;const r=t.mediaQueryList.map(e=>e.toString()).join(","),i=transform(t.mediaQueryList);r!==i&&(e.params=`${u(...t.name)} ${i}`)}}});creator.postcss=!0;export{creator as default}; +import{isFunctionNode as e,isTokenNode as t,gatherNodeAncestry as r}from"@csstools/css-parser-algorithms";import{isTokenNumeric as i,TokenType as a,NumberType as n,isTokenNumber as o,isTokenDimension as s,stringify as u,isTokenWhitespace as l}from"@csstools/css-tokenizer";import{invertComparison as c,MediaFeatureEQ as d,MediaFeatureLT as f,MediaFeatureGT as m,newMediaFeaturePlain as v,matchesRatioExactly as p,matchesRatio as h,isMediaFeatureRange as g,isMediaFeature as w,isMediaFeatureRangeNameValue as y,isMediaFeatureRangeValueName as x,isMediaInParens as N,MediaInParens as b,MediaAnd as P,MediaConditionListWithAnd as L,MediaCondition as I,isMediaConditionListWithAnd as Q,isMediaAnd as S,isMediaCondition as W,isMediaQuery as O,parseCustomMedia as M,parse as T}from"@csstools/media-query-list-parser";import{mathFunctionNames as _,calcFromComponentValues as A}from"@csstools/css-calc";const C={width:"px",height:"px","device-width":"px","device-height":"px","aspect-ratio":"","device-aspect-ratio":"",color:"","color-index":"",monochrome:"",resolution:"dpi"},E={width:!1,height:!1,"device-width":!1,"device-height":!1,"aspect-ratio":!1,"device-aspect-ratio":!1,color:!0,"color-index":!0,monochrome:!0,resolution:"dpi"};function featureNamePrefix(e){return e===f.LT||e===f.LT_OR_EQ?"max-":e===m.GT||e===m.GT_OR_EQ?"min-":""}const k={">":1,"<":-1},R=.001;function transformSingleNameValuePair(r,u,l,g){let w=l.before,y=l.after;if(g||(w=l.after,y=l.before),!g){const e=c(u);if(!1===e)return;u=e}if(u===d.EQ||u===f.LT_OR_EQ||u===m.GT_OR_EQ)return Array.isArray(l.value)?v(featureNamePrefix(u)+r,...w,...l.value.flatMap(e=>e.tokens()),...y):v(featureNamePrefix(u)+r,...w,...l.value.tokens(),...y);let x,N,b=!1;if(Array.isArray(l.value)){if(!p(l.value))return;if("aspect-ratio"!==r&&"device-aspect-ratio"!==r)return;const e=h(l.value);if(-1===e)return;b=!0,x=l.value[e[0]],N=[...l.value.slice(e[0]+1).flatMap(e=>e.tokens())]}else x=l.value,N=[];const P=C[r.toLowerCase()];if(e(x)){const e=x.getName().toLowerCase();if(_.has(e)||"env"===e){const[[e]]=A([[x]],{precision:5,toCanonicalUnits:!0});if(!(e&&t(e)&&i(e.value)&&Number.isInteger(e.value[4].value))){let e;if(void 0!==P){const t=k[u]*("px"===P?.02:R);e=[a.Dimension,`${t.toString()}${P}`,-1,-1,{value:t,unit:P,type:n.Integer}]}else if(!0===E[r]){const t=k[u];e=[a.Number,t.toString(),-1,-1,{value:t,type:n.Integer}]}else if(b){const t=k[u]*R;e=[a.Number,t.toString(),-1,-1,{value:t,type:n.Integer}]}else{const t=k[u];e=[a.Number,t.toString(),-1,-1,{value:t,type:n.Integer}]}return v(featureNamePrefix(u)+r,...w,[a.Function,"calc(",-1,-1,{value:"calc("}],[a.OpenParen,"(",-1,-1,void 0],...x.tokens().slice(1),[a.Whitespace," ",-1,-1,void 0],[a.Delim,"+",-1,-1,{value:"+"}],[a.Whitespace," ",-1,-1,void 0],e,[a.CloseParen,")",-1,-1,void 0],...N,...y)}x=e}}if(!t(x))return;let L,I=x.value,Q="";if(void 0!==P&&o(I)&&0===I[4].value)L=k[u],Q=P;else if(o(I)&&0===I[4].value)L=k[u],Q="";else if(s(I)&&0===I[4].value)L=k[u],Q=I[4].unit;else if(o(I)&&!0===E[r])L=I[4].value+k[u];else if(s(I)&&"px"===I[4].unit&&I[4].type===n.Integer)L=Number(Math.round(Number(I[4].value+.02*k[u]+"e6"))+"e-6");else{if(!s(I)&&!o(I))return;L=Number(Math.round(Number(I[4].value+R*k[u]+"e6"))+"e-6")}return Q&&(I=[a.Dimension,I[1],I[2],I[3],{value:I[4].value,unit:Q,type:I[4].type}]),I[4].value=L,s(I)?I[1]=I[4].value.toString()+I[4].unit:I[1]=I[4].value.toString(),v(featureNamePrefix(u)+r,...w,I,...N,...y)}const $=new Set(["aspect-ratio","color","color-index","device-aspect-ratio","device-height","device-width","height","horizontal-viewport-segments","monochrome","resolution","vertical-viewport-segments","width"]);function transform(e){return e.map((e,t)=>{const i=r(e);e.walk(t=>{const r=t.node;if(!g(r))return;const n=t.parent;if(!w(n))return;const o=r.name.getName().toLowerCase();if(!$.has(o))return;if(y(r)||x(r)){const e=r.operatorKind();if(!1===e)return;const t=transformSingleNameValuePair(o,e,r.value,y(r));return void(t&&(n.feature=t.feature))}const s=i.get(n);if(!N(s))return;let u=null,l=null;{const e=r.valueOneOperatorKind();if(!1===e)return;const t=transformSingleNameValuePair(o,e,r.valueOne,!1);if(!t)return;e===f.LT||e===f.LT_OR_EQ?(u=t,u.before=n.before):(l=t,l.after=n.after)}{const e=r.valueTwoOperatorKind();if(!1===e)return;const t=transformSingleNameValuePair(o,e,r.valueTwo,!0);if(!t)return;e===f.LT||e===f.LT_OR_EQ?(l=t,l.before=n.before):(u=t,u.after=n.after)}if(!u||!l)return;const c=new b(u),d=new b(l),m=getMediaConditionListWithAndFromAncestry(s,i);if(m)return m.leading===s?(m.leading=c,void(m.list=[new P([[a.Whitespace," ",-1,-1,void 0],[a.Ident,"and",-1,-1,{value:"and"}],[a.Whitespace," ",-1,-1,void 0]],d),...m.list])):void m.list.splice(m.indexOf(i.get(s)),1,new P([[a.Whitespace," ",-1,-1,void 0],[a.Ident,"and",-1,-1,{value:"and"}],[a.Whitespace," ",-1,-1,void 0]],c),new P([[a.Whitespace," ",-1,-1,void 0],[a.Ident,"and",-1,-1,{value:"and"}],[a.Whitespace," ",-1,-1,void 0]],d));const v=new L(c,[new P([[a.Whitespace," ",-1,-1,void 0],[a.Ident,"and",-1,-1,{value:"and"}],[a.Whitespace," ",-1,-1,void 0]],d)],[[a.Whitespace," ",-1,-1,void 0]]),p=getMediaConditionInShallowMediaQueryFromAncestry(s,e,i);p?p.media=v:s.media=new I(new b(new I(v),[[a.Whitespace," ",-1,-1,void 0],[a.OpenParen,"(",-1,-1,void 0]],[[a.CloseParen,")",-1,-1,void 0]]))});const n=e.tokens();return u(...n.filter((e,r)=>(0!==r||0!==t||!l(e))&&!(l(e)&&n[r+1]&&l(n[r+1]))))}).join(",")}function getMediaConditionListWithAndFromAncestry(e,t){let r=e;if(r){if(r=t.get(r),Q(r))return r;if(S(r))return r=t.get(r),Q(r)?r:void 0}}function getMediaConditionInShallowMediaQueryFromAncestry(e,t,r){let i=e;if(!i)return;if(i=r.get(i),!W(i))return;const a=i;return i=r.get(i),O(i)&&i===t?a:void 0}const creator=()=>({postcssPlugin:"postcss-media-minmax",AtRule:{media(e){if(!(e.params.includes("<")||e.params.includes(">")||e.params.includes("=")))return;const t=transform(T(e.params,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw e.error(`Unable to parse media query "${e.params}"`)}}));e.params!==t&&(e.params=t)},"custom-media"(e){if(!(e.params.includes("<")||e.params.includes(">")||e.params.includes("=")))return;const t=M(e.params,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw e.error(`Unable to parse media query "${e.params}"`)}});if(!t||!t.mediaQueryList)return;const r=t.mediaQueryList.map(e=>e.toString()).join(","),i=transform(t.mediaQueryList);r!==i&&(e.params=`${u(...t.name)} ${i}`)}}});creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-media-minmax/package.json b/plugins/postcss-media-minmax/package.json index a0c5c0edb..7fa5ba09a 100644 --- a/plugins/postcss-media-minmax/package.json +++ b/plugins/postcss-media-minmax/package.json @@ -28,20 +28,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-media-minmax/src/index.ts b/plugins/postcss-media-minmax/src/index.ts index 4aa533fee..7bdda21bb 100644 --- a/plugins/postcss-media-minmax/src/index.ts +++ b/plugins/postcss-media-minmax/src/index.ts @@ -60,3 +60,4 @@ const creator: PluginCreator = () => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-media-queries-aspect-ratio-number-values/CHANGELOG.md b/plugins/postcss-media-queries-aspect-ratio-number-values/CHANGELOG.md index c038aa00c..deb128191 100644 --- a/plugins/postcss-media-queries-aspect-ratio-number-values/CHANGELOG.md +++ b/plugins/postcss-media-queries-aspect-ratio-number-values/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Media Queries Aspect-Ratio Number Values +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.0.5 _May 27, 2025_ diff --git a/plugins/postcss-media-queries-aspect-ratio-number-values/dist/index.cjs b/plugins/postcss-media-queries-aspect-ratio-number-values/dist/index.cjs deleted file mode 100644 index a12ffb7c5..000000000 --- a/plugins/postcss-media-queries-aspect-ratio-number-values/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/media-query-list-parser"),r=require("@csstools/css-parser-algorithms"),n=require("@csstools/css-tokenizer");const o=1e5,t=2147483647;function transformMediaFeatureValue(a){if(Array.isArray(a.value)&&e.matchesRatioExactly(a.value)){const e=[];for(let o=0;oe&&([e,r]=[r,e]);;){if(0==r)return e;if(0==(e%=r))return r;r%=e}}const a=new Set(["aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio"]);function transformMediaQueryList(r,n){const o=e.parse(r,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${r}"`)}}),t=new Set(o.map(e=>e.toString()));return o.flatMap(r=>{if(e.isMediaQueryInvalid(r))return[r.toString()];const o=e.cloneMediaQuery(r);o.walk(r=>{const n=r.node;if(e.isMediaFeaturePlain(n)||e.isMediaFeatureRangeNameValue(n)||e.isMediaFeatureRangeValueName(n)){const e=n.name.getName().toLowerCase();if(!a.has(e))return;return void transformMediaFeatureValue(n.value)}if(e.isMediaFeatureRangeValueNameValue(n)){const e=n.name.getName().toLowerCase();if(!a.has(e))return;transformMediaFeatureValue(n.valueOne);transformMediaFeatureValue(n.valueTwo);return}});const i=r.toString(),u=o.toString();return u===i||t.has(u)?[i]:n?[i,u]:[u]}).join(",")}const creator=e=>{const r=Object.assign({preserve:!1},e);return{postcssPlugin:"postcss-media-queries-aspect-ratio-number-values",AtRule(e,{result:n}){if("media"!==e.name.toLowerCase())return;const o=e.params.toLowerCase();if(!(o.includes("aspect-ratio")||o.includes("min-aspect-ratio")||o.includes("max-aspect-ratio")||o.includes("device-aspect-ratio")||o.includes("min-device-aspect-ratio")||o.includes("max-device-aspect-ratio")))return;let t;try{if(t=transformMediaQueryList(e.params,r.preserve),t===e.params)return}catch(r){return void e.warn(n,`Failed to transform @media params for "${e.params}" with message: "${r instanceof Error?r.message:r}"`)}e.cloneBefore({params:t}),e.remove()}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-media-queries-aspect-ratio-number-values/dist/index.d.ts b/plugins/postcss-media-queries-aspect-ratio-number-values/dist/index.d.ts index 5c1498f8c..91608d9ba 100644 --- a/plugins/postcss-media-queries-aspect-ratio-number-values/dist/index.d.ts +++ b/plugins/postcss-media-queries-aspect-ratio-number-values/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-media-queries-aspect-ratio-number-values plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-media-queries-aspect-ratio-number-values/dist/index.mjs b/plugins/postcss-media-queries-aspect-ratio-number-values/dist/index.mjs index c35d355a1..db0e8358c 100644 --- a/plugins/postcss-media-queries-aspect-ratio-number-values/dist/index.mjs +++ b/plugins/postcss-media-queries-aspect-ratio-number-values/dist/index.mjs @@ -1 +1 @@ -import{matchesRatioExactly as e,parse as t,isMediaQueryInvalid as r,cloneMediaQuery as a,isMediaFeaturePlain as n,isMediaFeatureRangeNameValue as o,isMediaFeatureRangeValueName as i,isMediaFeatureRangeValueNameValue as u}from"@csstools/media-query-list-parser";import{isTokenNode as s,isFunctionNode as l,TokenNode as c,FunctionNode as v,SimpleBlockNode as m,WhitespaceNode as d}from"@csstools/css-parser-algorithms";import{isTokenNumber as p,TokenType as f,NumberType as g}from"@csstools/css-tokenizer";const w=1e5,h=2147483647;function transformMediaFeatureValue(t){if(Array.isArray(t.value)&&e(t.value)){const e=[];for(let r=0;re&&([e,t]=[t,e]);;){if(0==t)return e;if(0==(e%=t))return t;t%=e}}const y=new Set(["aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio"]);function transformMediaQueryList(e,s){const l=t(e,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${e}"`)}}),c=new Set(l.map(e=>e.toString()));return l.flatMap(e=>{if(r(e))return[e.toString()];const t=a(e);t.walk(e=>{const t=e.node;if(n(t)||o(t)||i(t)){const e=t.name.getName().toLowerCase();if(!y.has(e))return;return void transformMediaFeatureValue(t.value)}if(u(t)){const e=t.name.getName().toLowerCase();if(!y.has(e))return;transformMediaFeatureValue(t.valueOne);transformMediaFeatureValue(t.valueTwo);return}});const l=e.toString(),v=t.toString();return v===l||c.has(v)?[l]:s?[l,v]:[v]}).join(",")}const creator=e=>{const t=Object.assign({preserve:!1},e);return{postcssPlugin:"postcss-media-queries-aspect-ratio-number-values",AtRule(e,{result:r}){if("media"!==e.name.toLowerCase())return;const a=e.params.toLowerCase();if(!(a.includes("aspect-ratio")||a.includes("min-aspect-ratio")||a.includes("max-aspect-ratio")||a.includes("device-aspect-ratio")||a.includes("min-device-aspect-ratio")||a.includes("max-device-aspect-ratio")))return;let n;try{if(n=transformMediaQueryList(e.params,t.preserve),n===e.params)return}catch(t){return void e.warn(r,`Failed to transform @media params for "${e.params}" with message: "${t instanceof Error?t.message:t}"`)}e.cloneBefore({params:n}),e.remove()}}};creator.postcss=!0;export{creator as default}; +import{matchesRatioExactly as e,parse as t,isMediaQueryInvalid as r,cloneMediaQuery as a,isMediaFeaturePlain as n,isMediaFeatureRangeNameValue as o,isMediaFeatureRangeValueName as i,isMediaFeatureRangeValueNameValue as u}from"@csstools/media-query-list-parser";import{isTokenNode as s,isFunctionNode as l,TokenNode as c,FunctionNode as v,SimpleBlockNode as m,WhitespaceNode as d}from"@csstools/css-parser-algorithms";import{isTokenNumber as p,TokenType as f,NumberType as g}from"@csstools/css-tokenizer";const w=1e5,h=2147483647;function transformMediaFeatureValue(t){if(Array.isArray(t.value)&&e(t.value)){const e=[];for(let r=0;re&&([e,t]=[t,e]);;){if(0==t)return e;if(0==(e%=t))return t;t%=e}}const y=new Set(["aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio"]);function transformMediaQueryList(e,s){const l=t(e,{preserveInvalidMediaQueries:!0,onParseError:()=>{throw new Error(`Unable to parse media query "${e}"`)}}),c=new Set(l.map(e=>e.toString()));return l.flatMap(e=>{if(r(e))return[e.toString()];const t=a(e);t.walk(e=>{const t=e.node;if(n(t)||o(t)||i(t)){const e=t.name.getName().toLowerCase();if(!y.has(e))return;return void transformMediaFeatureValue(t.value)}if(u(t)){const e=t.name.getName().toLowerCase();if(!y.has(e))return;transformMediaFeatureValue(t.valueOne);transformMediaFeatureValue(t.valueTwo);return}});const l=e.toString(),v=t.toString();return v===l||c.has(v)?[l]:s?[l,v]:[v]}).join(",")}const creator=e=>{const t=Object.assign({preserve:!1},e);return{postcssPlugin:"postcss-media-queries-aspect-ratio-number-values",AtRule(e,{result:r}){if("media"!==e.name.toLowerCase())return;const a=e.params.toLowerCase();if(!(a.includes("aspect-ratio")||a.includes("min-aspect-ratio")||a.includes("max-aspect-ratio")||a.includes("device-aspect-ratio")||a.includes("min-device-aspect-ratio")||a.includes("max-device-aspect-ratio")))return;let n;try{if(n=transformMediaQueryList(e.params,t.preserve),n===e.params)return}catch(t){return void e.warn(r,`Failed to transform @media params for "${e.params}" with message: "${t instanceof Error?t.message:t}"`)}e.cloneBefore({params:n}),e.remove()}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-media-queries-aspect-ratio-number-values/package.json b/plugins/postcss-media-queries-aspect-ratio-number-values/package.json index 260012e27..2ba6ce21e 100644 --- a/plugins/postcss-media-queries-aspect-ratio-number-values/package.json +++ b/plugins/postcss-media-queries-aspect-ratio-number-values/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-media-queries-aspect-ratio-number-values/src/index.ts b/plugins/postcss-media-queries-aspect-ratio-number-values/src/index.ts index aaf00d528..7f33f5ad7 100644 --- a/plugins/postcss-media-queries-aspect-ratio-number-values/src/index.ts +++ b/plugins/postcss-media-queries-aspect-ratio-number-values/src/index.ts @@ -56,4 +56,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-minify/CHANGELOG.md b/plugins/postcss-minify/CHANGELOG.md index 4b35a0401..dfe27db36 100644 --- a/plugins/postcss-minify/CHANGELOG.md +++ b/plugins/postcss-minify/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Minify +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.5 _December 22, 2025_ diff --git a/plugins/postcss-minify/dist/index.cjs b/plugins/postcss-minify/dist/index.cjs deleted file mode 100644 index df83f6fa0..000000000 --- a/plugins/postcss-minify/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-tokenizer");const r=/license|copyright|sourcemappingurl/i,t=/\s|\/\*/,s=/^layer$/i;function minify(r,s){if(!s)return s;if(r.has(s))return r.get(s);const o=s.trim();if(""===o)return r.set(s,""),"";if(!t.test(o))return r.set(s,o),o;let n=!1,i=!1,a="";const c=e.tokenizer({css:o});for(;!c.endOfFile();){const r=c.nextToken();e.isTokenWhitespace(r)?(n||(a+=" "),n=!0,i=!1):e.isTokenComment(r)?(i||(a+="/**/"),n=!1,i=!0):(n=!1,i=!1,a+=r[1])}return r.set(s,a),a}function removeEmptyNodes(e){if("rule"===e.type){if(0===e.nodes?.length){const r=e.parent;return!!r&&(e.remove(),removeEmptyNodes(r),!0)}}else if("atrule"===e.type&&0===e.nodes?.length&&!s.test(e.name)){const r=e.parent;return!!r&&(e.remove(),removeEmptyNodes(r),!0)}return!1}function setSemicolon(e){if(!e.raws.semicolon)return;const r=e.last;"decl"===r?.type&&r.variable||(e.raws.semicolon=!1)}const creator=()=>{const e=new Map;return{postcssPlugin:"postcss-minify",OnceExit(t){t.raws.before="",t.raws.after="\n",t.walk(t=>{switch(t.type){case"atrule":if(removeEmptyNodes(t))return;return t.raws.after="",t.raws.afterName=" ",t.raws.before="",t.raws.between="",t.raws.params=void 0,setSemicolon(t),void(t.params=minify(e,t.params));case"rule":if(removeEmptyNodes(t))return;return t.raws.after="",t.raws.before="",t.raws.between="",t.raws.selector=void 0,setSemicolon(t),void(t.selector=minify(e,t.selector));case"decl":return t.prop.startsWith("--")?void(t.raws.before=""):(t.raws.before="",t.raws.between=":",t.raws.important=t.important?"!important":"",t.raws.value=void 0,void(t.value=minify(e,t.value)));case"comment":return t.text.startsWith("!")||r.test(t.text)?void(t.raws.before=""):void t.remove()}})}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-minify/dist/index.d.ts b/plugins/postcss-minify/dist/index.d.ts index 332621cd8..d055d8f92 100644 --- a/plugins/postcss-minify/dist/index.d.ts +++ b/plugins/postcss-minify/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-minify plugin options */ export declare type pluginOptions = never; diff --git a/plugins/postcss-minify/dist/index.mjs b/plugins/postcss-minify/dist/index.mjs index 3abf68a94..edae1066b 100644 --- a/plugins/postcss-minify/dist/index.mjs +++ b/plugins/postcss-minify/dist/index.mjs @@ -1 +1 @@ -import{tokenizer as e,isTokenWhitespace as r,isTokenComment as t}from"@csstools/css-tokenizer";const s=/license|copyright|sourcemappingurl/i,o=/\s|\/\*/,n=/^layer$/i;function minify(s,n){if(!n)return n;if(s.has(n))return s.get(n);const a=n.trim();if(""===a)return s.set(n,""),"";if(!o.test(a))return s.set(n,a),a;let i=!1,c=!1,m="";const f=e({css:a});for(;!f.endOfFile();){const e=f.nextToken();r(e)?(i||(m+=" "),i=!0,c=!1):t(e)?(c||(m+="/**/"),i=!1,c=!0):(i=!1,c=!1,m+=e[1])}return s.set(n,m),m}function removeEmptyNodes(e){if("rule"===e.type){if(0===e.nodes?.length){const r=e.parent;return!!r&&(e.remove(),removeEmptyNodes(r),!0)}}else if("atrule"===e.type&&0===e.nodes?.length&&!n.test(e.name)){const r=e.parent;return!!r&&(e.remove(),removeEmptyNodes(r),!0)}return!1}function setSemicolon(e){if(!e.raws.semicolon)return;const r=e.last;"decl"===r?.type&&r.variable||(e.raws.semicolon=!1)}const creator=()=>{const e=new Map;return{postcssPlugin:"postcss-minify",OnceExit(r){r.raws.before="",r.raws.after="\n",r.walk(r=>{switch(r.type){case"atrule":if(removeEmptyNodes(r))return;return r.raws.after="",r.raws.afterName=" ",r.raws.before="",r.raws.between="",r.raws.params=void 0,setSemicolon(r),void(r.params=minify(e,r.params));case"rule":if(removeEmptyNodes(r))return;return r.raws.after="",r.raws.before="",r.raws.between="",r.raws.selector=void 0,setSemicolon(r),void(r.selector=minify(e,r.selector));case"decl":return r.prop.startsWith("--")?void(r.raws.before=""):(r.raws.before="",r.raws.between=":",r.raws.important=r.important?"!important":"",r.raws.value=void 0,void(r.value=minify(e,r.value)));case"comment":return r.text.startsWith("!")||s.test(r.text)?void(r.raws.before=""):void r.remove()}})}}};creator.postcss=!0;export{creator as default}; +import{tokenizer as e,isTokenWhitespace as r,isTokenComment as t}from"@csstools/css-tokenizer";const s=/license|copyright|sourcemappingurl/i,o=/\s|\/\*/,n=/^layer$/i;function minify(s,n){if(!n)return n;if(s.has(n))return s.get(n);const a=n.trim();if(""===a)return s.set(n,""),"";if(!o.test(a))return s.set(n,a),a;let i=!1,c=!1,m="";const f=e({css:a});for(;!f.endOfFile();){const e=f.nextToken();r(e)?(i||(m+=" "),i=!0,c=!1):t(e)?(c||(m+="/**/"),i=!1,c=!0):(i=!1,c=!1,m+=e[1])}return s.set(n,m),m}function removeEmptyNodes(e){if("rule"===e.type){if(0===e.nodes?.length){const r=e.parent;return!!r&&(e.remove(),removeEmptyNodes(r),!0)}}else if("atrule"===e.type&&0===e.nodes?.length&&!n.test(e.name)){const r=e.parent;return!!r&&(e.remove(),removeEmptyNodes(r),!0)}return!1}function setSemicolon(e){if(!e.raws.semicolon)return;const r=e.last;"decl"===r?.type&&r.variable||(e.raws.semicolon=!1)}const creator=()=>{const e=new Map;return{postcssPlugin:"postcss-minify",OnceExit(r){r.raws.before="",r.raws.after="\n",r.walk(r=>{switch(r.type){case"atrule":if(removeEmptyNodes(r))return;return r.raws.after="",r.raws.afterName=" ",r.raws.before="",r.raws.between="",r.raws.params=void 0,setSemicolon(r),void(r.params=minify(e,r.params));case"rule":if(removeEmptyNodes(r))return;return r.raws.after="",r.raws.before="",r.raws.between="",r.raws.selector=void 0,setSemicolon(r),void(r.selector=minify(e,r.selector));case"decl":return r.prop.startsWith("--")?void(r.raws.before=""):(r.raws.before="",r.raws.between=":",r.raws.important=r.important?"!important":"",r.raws.value=void 0,void(r.value=minify(e,r.value)));case"comment":return r.text.startsWith("!")||s.test(r.text)?void(r.raws.before=""):void r.remove()}})}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-minify/package.json b/plugins/postcss-minify/package.json index 596e348e7..96934cd84 100644 --- a/plugins/postcss-minify/package.json +++ b/plugins/postcss-minify/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-minify/src/index.ts b/plugins/postcss-minify/src/index.ts index 260b6550e..85990b883 100644 --- a/plugins/postcss-minify/src/index.ts +++ b/plugins/postcss-minify/src/index.ts @@ -200,3 +200,4 @@ const creator: PluginCreator = () => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-nested-calc/CHANGELOG.md b/plugins/postcss-nested-calc/CHANGELOG.md index 65bb6f556..211ff99e5 100644 --- a/plugins/postcss-nested-calc/CHANGELOG.md +++ b/plugins/postcss-nested-calc/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Nested Calc +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.0 _August 3, 2024_ diff --git a/plugins/postcss-nested-calc/dist/index.cjs b/plugins/postcss-nested-calc/dist/index.cjs deleted file mode 100644 index 55744edca..000000000 --- a/plugins/postcss-nested-calc/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser"),t=require("@csstools/utilities");const r=/calc\(/gi;const creator=s=>{const a=Object.assign({preserve:!0},s);return{postcssPlugin:"postcss-nested-calc",Declaration(s,{result:o}){if((s.value.match(r)||[]).length<2)return;if(s.variable)return;if(t.hasFallback(s))return;const c=s.value;let l;try{l=e(c)}catch{return void s.warn(o,`Failed to parse value '${c}'. Leaving the original value intact.`)}if(void 0===l)return;e.walk(l.nodes,t=>{t.type&&"function"===t.type&&"calc"===t.value.toLowerCase()&&e.walk(t.nodes,e=>{if(e.type&&"function"===e.type)return"calc"===e.value.toLowerCase()&&void(e.value="")})},!0);const n=String(l);n!==c&&(s.cloneBefore({value:n}),a.preserve||s.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-nested-calc/dist/index.d.ts b/plugins/postcss-nested-calc/dist/index.d.ts index d6f1df1ef..500e37f2a 100644 --- a/plugins/postcss-nested-calc/dist/index.d.ts +++ b/plugins/postcss-nested-calc/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-nested-calc plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-nested-calc/dist/index.mjs b/plugins/postcss-nested-calc/dist/index.mjs index 41d27deca..eb9702f53 100644 --- a/plugins/postcss-nested-calc/dist/index.mjs +++ b/plugins/postcss-nested-calc/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";import{hasFallback as t}from"@csstools/utilities";const r=/calc\(/gi;const creator=s=>{const a=Object.assign({preserve:!0},s);return{postcssPlugin:"postcss-nested-calc",Declaration(s,{result:o}){if((s.value.match(r)||[]).length<2)return;if(s.variable)return;if(t(s))return;const n=s.value;let c;try{c=e(n)}catch{return void s.warn(o,`Failed to parse value '${n}'. Leaving the original value intact.`)}if(void 0===c)return;e.walk(c.nodes,t=>{t.type&&"function"===t.type&&"calc"===t.value.toLowerCase()&&e.walk(t.nodes,e=>{if(e.type&&"function"===e.type)return"calc"===e.value.toLowerCase()&&void(e.value="")})},!0);const l=String(c);l!==n&&(s.cloneBefore({value:l}),a.preserve||s.remove())}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-value-parser";import{hasFallback as t}from"@csstools/utilities";const r=/calc\(/gi;const creator=s=>{const o=Object.assign({preserve:!0},s);return{postcssPlugin:"postcss-nested-calc",Declaration(s,{result:a}){if((s.value.match(r)||[]).length<2)return;if(s.variable)return;if(t(s))return;const n=s.value;let l;try{l=e(n)}catch{return void s.warn(a,`Failed to parse value '${n}'. Leaving the original value intact.`)}if(void 0===l)return;e.walk(l.nodes,t=>{t.type&&"function"===t.type&&"calc"===t.value.toLowerCase()&&e.walk(t.nodes,e=>{if(e.type&&"function"===e.type)return"calc"===e.value.toLowerCase()&&void(e.value="")})},!0);const c=String(l);c!==n&&(s.cloneBefore({value:c}),o.preserve||s.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-nested-calc/package.json b/plugins/postcss-nested-calc/package.json index 5f57fda26..f81f0533c 100644 --- a/plugins/postcss-nested-calc/package.json +++ b/plugins/postcss-nested-calc/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-nested-calc/src/index.ts b/plugins/postcss-nested-calc/src/index.ts index fe0f690ea..48df04427 100644 --- a/plugins/postcss-nested-calc/src/index.ts +++ b/plugins/postcss-nested-calc/src/index.ts @@ -93,4 +93,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-nesting/CHANGELOG.md b/plugins/postcss-nesting/CHANGELOG.md index 6c0e8cc50..d1c74174b 100644 --- a/plugins/postcss-nesting/CHANGELOG.md +++ b/plugins/postcss-nesting/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Nesting +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 13.0.2 _June 10, 2025_ diff --git a/plugins/postcss-nesting/dist/index.cjs b/plugins/postcss-nesting/dist/index.cjs deleted file mode 100644 index 6556e3979..000000000 --- a/plugins/postcss-nesting/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser"),t=require("@csstools/selector-specificity"),n=require("@csstools/selector-resolve-nested");const r=e.pseudo({value:":is"});function sortCompoundSelectorsInsideComplexSelector(t){if(!t||!t.nodes)return;const n=[];let o=[];for(let s=0;s"tag"===e.type)){const n=r.clone({}),o=t.nodes[s];o.replaceWith(n),n.append(e.selector({nodes:[o],value:void 0}))}o.push(t.nodes[s])}else n.push(o),n.push([t.nodes[s]]),o=[];n.push(o);const s=[];for(let e=0;e"selector"===e.type&&"selector"===t.type&&e.nodes.length&&t.nodes.length?selectorTypeOrder(e.nodes[0])-selectorTypeOrder(t.nodes[0]):"selector"===e.type&&e.nodes.length?selectorTypeOrder(e.nodes[0])-selectorTypeOrder(t):"selector"===t.type&&t.nodes.length?selectorTypeOrder(e)-selectorTypeOrder(t.nodes[0]):selectorTypeOrder(e)-selectorTypeOrder(t));for(let e=0;e=0;e--)s[e].remove(),s[e].parent=t,t.nodes.unshift(s[e])}function selectorTypeOrder(t){return e.isPseudoElement(t)?o.pseudoElement:o[t.type]}const o={universal:0,tag:1,pseudoElement:2,id:3,class:4,attribute:5,pseudo:6,selector:7,string:8,root:9,comment:10};function isAtRule(e){return e&&"atrule"===e.type}function isNestRule(e){return e&&isAtRule(e)&&"nest"===e.name}function isRule(e){return e&&"rule"===e.type}function ampersandToScope$1(t,n){let r,o=t.parent;for(;o;){if("rule"===o.type)return;if(isAtRule(o)&&"scope"===o.name)return;o=o.parent}try{r=e().astSync(t.selector)}catch(e){return void t.warn(n,`Failed to parse selector : "${t.selector}" with message: "${e instanceof Error?e.message:e}"`)}r&&(r.walkNesting(t=>{const n=t.parent;t.replaceWith(e.pseudo({value:":scope"})),n&&sortCompoundSelectorsInsideComplexSelector(n)}),t.selector=r.toString())}function cleanupParent(e){if(!e.nodes.length)return void e.remove();const t=e.nodes.filter(e=>"comment"===e.type);t.length===e.nodes.length&&e.replaceWith(...t)}function groupDeclarations(e){const t=[],n=[];e.each(e=>{if(isDeclarationLike(e,n.length>0))t.push(e);else{if("comment"===e.type){let r=e.next();for(;r&&"comment"===r.type;)r=r.next();if(isDeclarationLike(r,n.length>0))return void t.push(e)}n.push(e)}}),e.removeAll(),t.forEach(t=>{e.append(t)}),n.forEach(t=>{e.append(t)})}function isDeclarationLike(e,t){return!!e&&("decl"===e.type||"atrule"===e.type&&"mixin"===e.name.toLowerCase()&&!t)}function comma(e){const t=[];let n="",r=!1,o=0,s=!1,i=!1;for(const l of e)i?i=!1:"\\"===l?i=!0:s?l===s&&(s=!1):'"'===l||"'"===l?s=l:"("===l?o+=1:")"===l?o>0&&(o-=1):0===o&&","===l&&(r=!0),r?(""!==n&&t.push(n.trim()),n="",r=!1):n+=l;return t.push(n.trim()),t}function shiftNodesBeforeParent(e,t){const n=t.index(e);if(n){const e=t.cloneBefore().removeAll().append(t.nodes.slice(0,n));e.raws.semicolon=!0,cleanupParent(e)}t.before(e),t.raws.semicolon=!0}var s=["container","document","media","supports","layer","starting-style"];function transformAtruleWithinAtrule(e,t){var n,r;groupDeclarations(t),shiftNodesBeforeParent(e,t),e.params=(n=t.params,r=e.params,comma(n).map(e=>comma(r).map(t=>`${e} and ${t}`).join(", ")).join(", ")),cleanupParent(t)}function isAtruleWithinAtrule(e,t){return s.includes(e.name)&&e.name===t.name}function atruleWithinRule$1(e,t,n,r,o){if(groupDeclarations(t),shiftNodesBeforeParent(e,t),e.nodes){const s=t.clone().removeAll().append(e.nodes);e.append(s),cleanupParent(t),r(s,n,o)}else cleanupParent(t)}function isAtruleWithinRule$1(e){return s.includes(e.name)}function combinationsWithSizeN(e,t){if(t<2)throw new Error("n must be greater than 1");if(e.length<2)throw new Error("s must be greater than 1");if(Math.pow(e.length,t)>1e4)throw new Error("Too many combinations when trying to resolve a nested selector with lists, reduce the complexity of your selectors");const n=[];for(let e=0;e=0;s--){let t=n[s];if(t>=e.length){if(t=0,n[s]=0,0===s)return r;n[s-1]+=1}o[s]=e[t].clone()}r.push(o),n[n.length-1]++}}function nodesAreEquallySpecific(n){const r=n.map(t=>e().astSync(t)).map(e=>t.selectorSpecificity(e)),o=r[0];for(let e=1;ee().astSync(t)):[e().astSync(`:is(${t.join(",")})`)];const s=[];for(let t=0;t{"nesting"===e.type&&(n=!0)});const r=t.nodes[0];let o=!1;r.each(e=>"combinator"===e.type&&(o=!0,!1)),n?o&&r.insertBefore(r.at(0),e.nesting()):(r.insertBefore(r.at(0),e.combinator({value:" "})),r.insertBefore(r.at(0),e.nesting())),l=t.toString()}let c=[],a=0;if(e().astSync(l).walkNesting(()=>{a++}),a>1&&o.length>1)c=combinationsWithSizeN(o,a),i=c.length;else{i=o.length;for(let e=0;e{if("nesting"!==o.type)return;let s=c[t][n];n++,"root"===s.type&&1===s.nodes.length&&(s=s.nodes[0]);const i=e().astSync(`:is(${s.toString()})`),l=isSimpleSelector(s.nodes[0]),a=isCompoundSelector(s.nodes[0]),u=isSimpleSelector(o),p=isCompoundSelector(o);if(l&&u)return void o.replaceWith(s.clone());if((l||a)&&(u||p)){const e=o.parent;return l&&"selector"===s.type?o.replaceWith(s.clone().nodes[0]):o.replaceWith(...s.clone().nodes),void(e&&e.nodes.length>1&&sortCompoundSelectorsInsideComplexSelector(e))}if(l){const e=o.parent;return o.replaceWith(s.clone().nodes[0]),void(e&&sortCompoundSelectorsInsideComplexSelector(e))}if(a){const e=o.parent;return o.replaceWith(...s.clone().nodes),void(e&&sortCompoundSelectorsInsideComplexSelector(e))}if(nestingIsFirstAndOnlyInSelectorWithEitherSpaceOrChildCombinator(o)){const e=o.parent;return o.replaceWith(...s.clone().nodes),void(e&&sortCompoundSelectorsInsideComplexSelector(e))}if(nestingIsNotInsideCompoundSelector(o)){const e=o.parent;return o.replaceWith(...s.clone().nodes),void(e&&sortCompoundSelectorsInsideComplexSelector(e))}const d=o.parent;r.noIsPseudoSelector?o.replaceWith(...s.clone().nodes):o.replaceWith(...i.clone({}).nodes),d&&sortCompoundSelectorsInsideComplexSelector(d)}),s.push(o.toString())}}return s}function isSimpleSelector(e){return"combinator"!==e.type&&!(e.parent&&e.parent.nodes.length>1)}function isCompoundSelector(e,t=null){if(isSimpleSelector(e))return!1;if(!e.parent)return!1;if(!!e.parent.nodes.find(e=>"combinator"===e.type))return!1;return!(!!e.parent.nodes.find(e=>"nesting"===e.type)&&t&&!isCompoundSelector(t))}function nestingIsFirstAndOnlyInSelectorWithEitherSpaceOrChildCombinator(e){if(!e.parent)return!1;if(0!==e.parent.nodes.indexOf(e))return!1;for(let t=1;t"!==e.parent.nodes[t].value)return!1;return!0}function nestingIsNotInsideCompoundSelector(e){if(isSimpleSelector(e))return!0;if(!e.parent)return!1;for(let t=0;te.split("&").length>=2&&-1===e.indexOf("|"))}function transformRuleWithinRule$1(e,t,n,r){let o=[];try{o=mergeSelectors$1(t.selectors,e.selectors,r)}catch(r){return void e.warn(n,`Failed to parse selectors : "${t.selector}" / "${e.selector}" with message: "${r instanceof Error?r.message:r}"`)}if(!o.length)return;groupDeclarations(t),shiftNodesBeforeParent(e,t),e.selectors=o;"rule"===e.type&&"rule"===t.type&&e.selector===t.selector&&e.append(...t.nodes),cleanupParent(t)}function isValidRuleWithinRule$1(e){return e.selectors.every(e=>-1===e.indexOf("|"))}function walk$1(e,t,n){e.each(r=>{const o=r.parent;isNestRule(r)&&!n.silenceAtNestWarning&&e.warn(t,`\`@nest\` was removed from the CSS Nesting specification and will be removed from PostCSS Nesting in the next major version.\nChange \`@nest ${r.params} {}\` to \`${r.params} {}\` to migrate to the latest standard.`),isRule(r)&&isRule(o)&&isValidRuleWithinRule$1(r)?transformRuleWithinRule$1(r,o,t,n):isNestRule(r)&&isRule(o)&&isValidNestRuleWithinRule(r)?transformNestRuleWithinRule(r,o,t,walk$1,n):isAtRule(r)&&isRule(o)&&isAtruleWithinRule$1(r)?atruleWithinRule$1(r,o,t,walk$1,n):isAtRule(r)&&isAtRule(o)&&isAtruleWithinAtrule(r,o)&&transformAtruleWithinAtrule(r,o),"nodes"in r&&r.nodes.length&&walk$1(r,t,n)})}const creator$2=e=>{const t=Object.assign({noIsPseudoSelector:!1,silenceAtNestWarning:!1},e);return{postcssPlugin:"postcss-nesting",Rule(e,{result:n}){walk$1(e,n,t),e.selector.includes("&")&&ersandToScope$1(e,n)}}};creator$2.postcss=!0;const i=e();function mergeSelectors(e,t,r,o){let s;try{s=n.resolveNestedSelector(i.astSync(t),i.astSync(r))}catch(n){return e.warn(o,`Failed to parse selectors : "${r}" / "${t}" with message: "${n instanceof Error?n.message:n}"`),!1}return!!s&&s.toString()}function ampersandToScope(t,n){{let r=t.parent;for(;r;){if("rule"===r.type)return;if(isAtRule(r)&&"scope"===r.name)return;r=r.parent}try{let n=!1;if(e().astSync(t.selector).walkNesting(()=>(n=!0,!1)),!n)return}catch(e){return void t.warn(n,`Failed to parse selector : "${t.selector}" with message: "${e instanceof Error?e.message:e}"`)}}const r=mergeSelectors(t,t.selector,":scope",n);r&&(t.selector=r)}function atruleWithinRule(e,t,n,r){if(shiftNodesBeforeParent(e,t),e.nodes){const o=t.clone().removeAll().append(e.nodes);e.append(o),cleanupParent(t),r(o,n)}else cleanupParent(t)}function isAtruleWithinRule(e){return s.includes(e.name)}function transformRuleWithinRule(e,t,n){const r=mergeSelectors(e,e.selector,t.selector,n);if(!r)return;shiftNodesBeforeParent(e,t),e.selector=r;"rule"===e.type&&"rule"===t.type&&e.selector===t.selector&&e.append(...t.nodes),cleanupParent(t)}function isValidRuleWithinRule(e){return e.selectors.every(e=>-1===e.indexOf("|"))}function walk(e,t){e.each(e=>{const n=e.parent;isRule(e)&&isRule(n)&&isValidRuleWithinRule(e)?transformRuleWithinRule(e,n,t):isAtRule(e)&&isRule(n)&&isAtruleWithinRule(e)&&atruleWithinRule(e,n,t,walk),"nodes"in e&&e.nodes.length&&walk(e,t)})}const creator$1=()=>({postcssPlugin:"postcss-nesting",Rule(e,{result:t}){walk(e,t),e.selector.includes("&")&&ersandToScope(e,t)},AtRule:{nest(e){throw e.error(`\`@nest\` was removed from the CSS Nesting specification and will be removed from PostCSS Nesting in the next major version.\nChange \`@nest ${e.params} {}\` to \`${e.params} {}\` to migrate to the latest standard.`)}}});creator$1.postcss=!0;const creator=e=>{const t=Object.assign({edition:"2024-02"},e);switch(t.edition){case"2021":return creator$2(e);case"2024-02":return creator$1();default:throw new Error(`Invalid edition: ${t.edition}`)}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-nesting/dist/index.d.ts b/plugins/postcss-nesting/dist/index.d.ts index 356c13de6..2733b20d5 100644 --- a/plugins/postcss-nesting/dist/index.d.ts +++ b/plugins/postcss-nesting/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-nesting plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-nesting/dist/index.mjs b/plugins/postcss-nesting/dist/index.mjs index cf16ad250..bdc2961cc 100644 --- a/plugins/postcss-nesting/dist/index.mjs +++ b/plugins/postcss-nesting/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";import{selectorSpecificity as t}from"@csstools/selector-specificity";import{resolveNestedSelector as n}from"@csstools/selector-resolve-nested";const r=e.pseudo({value:":is"});function sortCompoundSelectorsInsideComplexSelector(t){if(!t||!t.nodes)return;const n=[];let o=[];for(let s=0;s"tag"===e.type)){const n=r.clone({}),o=t.nodes[s];o.replaceWith(n),n.append(e.selector({nodes:[o],value:void 0}))}o.push(t.nodes[s])}else n.push(o),n.push([t.nodes[s]]),o=[];n.push(o);const s=[];for(let e=0;e"selector"===e.type&&"selector"===t.type&&e.nodes.length&&t.nodes.length?selectorTypeOrder(e.nodes[0])-selectorTypeOrder(t.nodes[0]):"selector"===e.type&&e.nodes.length?selectorTypeOrder(e.nodes[0])-selectorTypeOrder(t):"selector"===t.type&&t.nodes.length?selectorTypeOrder(e)-selectorTypeOrder(t.nodes[0]):selectorTypeOrder(e)-selectorTypeOrder(t));for(let e=0;e=0;e--)s[e].remove(),s[e].parent=t,t.nodes.unshift(s[e])}function selectorTypeOrder(t){return e.isPseudoElement(t)?o.pseudoElement:o[t.type]}const o={universal:0,tag:1,pseudoElement:2,id:3,class:4,attribute:5,pseudo:6,selector:7,string:8,root:9,comment:10};function isAtRule(e){return e&&"atrule"===e.type}function isNestRule(e){return e&&isAtRule(e)&&"nest"===e.name}function isRule(e){return e&&"rule"===e.type}function ampersandToScope$1(t,n){let r,o=t.parent;for(;o;){if("rule"===o.type)return;if(isAtRule(o)&&"scope"===o.name)return;o=o.parent}try{r=e().astSync(t.selector)}catch(e){return void t.warn(n,`Failed to parse selector : "${t.selector}" with message: "${e instanceof Error?e.message:e}"`)}r&&(r.walkNesting(t=>{const n=t.parent;t.replaceWith(e.pseudo({value:":scope"})),n&&sortCompoundSelectorsInsideComplexSelector(n)}),t.selector=r.toString())}function cleanupParent(e){if(!e.nodes.length)return void e.remove();const t=e.nodes.filter(e=>"comment"===e.type);t.length===e.nodes.length&&e.replaceWith(...t)}function groupDeclarations(e){const t=[],n=[];e.each(e=>{if(isDeclarationLike(e,n.length>0))t.push(e);else{if("comment"===e.type){let r=e.next();for(;r&&"comment"===r.type;)r=r.next();if(isDeclarationLike(r,n.length>0))return void t.push(e)}n.push(e)}}),e.removeAll(),t.forEach(t=>{e.append(t)}),n.forEach(t=>{e.append(t)})}function isDeclarationLike(e,t){return!!e&&("decl"===e.type||"atrule"===e.type&&"mixin"===e.name.toLowerCase()&&!t)}function comma(e){const t=[];let n="",r=!1,o=0,s=!1,i=!1;for(const l of e)i?i=!1:"\\"===l?i=!0:s?l===s&&(s=!1):'"'===l||"'"===l?s=l:"("===l?o+=1:")"===l?o>0&&(o-=1):0===o&&","===l&&(r=!0),r?(""!==n&&t.push(n.trim()),n="",r=!1):n+=l;return t.push(n.trim()),t}function shiftNodesBeforeParent(e,t){const n=t.index(e);if(n){const e=t.cloneBefore().removeAll().append(t.nodes.slice(0,n));e.raws.semicolon=!0,cleanupParent(e)}t.before(e),t.raws.semicolon=!0}var s=["container","document","media","supports","layer","starting-style"];function transformAtruleWithinAtrule(e,t){var n,r;groupDeclarations(t),shiftNodesBeforeParent(e,t),e.params=(n=t.params,r=e.params,comma(n).map(e=>comma(r).map(t=>`${e} and ${t}`).join(", ")).join(", ")),cleanupParent(t)}function isAtruleWithinAtrule(e,t){return s.includes(e.name)&&e.name===t.name}function atruleWithinRule$1(e,t,n,r,o){if(groupDeclarations(t),shiftNodesBeforeParent(e,t),e.nodes){const s=t.clone().removeAll().append(e.nodes);e.append(s),cleanupParent(t),r(s,n,o)}else cleanupParent(t)}function isAtruleWithinRule$1(e){return s.includes(e.name)}function combinationsWithSizeN(e,t){if(t<2)throw new Error("n must be greater than 1");if(e.length<2)throw new Error("s must be greater than 1");if(Math.pow(e.length,t)>1e4)throw new Error("Too many combinations when trying to resolve a nested selector with lists, reduce the complexity of your selectors");const n=[];for(let e=0;e=0;s--){let t=n[s];if(t>=e.length){if(t=0,n[s]=0,0===s)return r;n[s-1]+=1}o[s]=e[t].clone()}r.push(o),n[n.length-1]++}}function nodesAreEquallySpecific(n){const r=n.map(t=>e().astSync(t)).map(e=>t(e)),o=r[0];for(let e=1;ee().astSync(t)):[e().astSync(`:is(${t.join(",")})`)];const s=[];for(let t=0;t{"nesting"===e.type&&(n=!0)});const r=t.nodes[0];let o=!1;r.each(e=>"combinator"===e.type&&(o=!0,!1)),n?o&&r.insertBefore(r.at(0),e.nesting()):(r.insertBefore(r.at(0),e.combinator({value:" "})),r.insertBefore(r.at(0),e.nesting())),l=t.toString()}let c=[],a=0;if(e().astSync(l).walkNesting(()=>{a++}),a>1&&o.length>1)c=combinationsWithSizeN(o,a),i=c.length;else{i=o.length;for(let e=0;e{if("nesting"!==o.type)return;let s=c[t][n];n++,"root"===s.type&&1===s.nodes.length&&(s=s.nodes[0]);const i=e().astSync(`:is(${s.toString()})`),l=isSimpleSelector(s.nodes[0]),a=isCompoundSelector(s.nodes[0]),u=isSimpleSelector(o),p=isCompoundSelector(o);if(l&&u)return void o.replaceWith(s.clone());if((l||a)&&(u||p)){const e=o.parent;return l&&"selector"===s.type?o.replaceWith(s.clone().nodes[0]):o.replaceWith(...s.clone().nodes),void(e&&e.nodes.length>1&&sortCompoundSelectorsInsideComplexSelector(e))}if(l){const e=o.parent;return o.replaceWith(s.clone().nodes[0]),void(e&&sortCompoundSelectorsInsideComplexSelector(e))}if(a){const e=o.parent;return o.replaceWith(...s.clone().nodes),void(e&&sortCompoundSelectorsInsideComplexSelector(e))}if(nestingIsFirstAndOnlyInSelectorWithEitherSpaceOrChildCombinator(o)){const e=o.parent;return o.replaceWith(...s.clone().nodes),void(e&&sortCompoundSelectorsInsideComplexSelector(e))}if(nestingIsNotInsideCompoundSelector(o)){const e=o.parent;return o.replaceWith(...s.clone().nodes),void(e&&sortCompoundSelectorsInsideComplexSelector(e))}const d=o.parent;r.noIsPseudoSelector?o.replaceWith(...s.clone().nodes):o.replaceWith(...i.clone({}).nodes),d&&sortCompoundSelectorsInsideComplexSelector(d)}),s.push(o.toString())}}return s}function isSimpleSelector(e){return"combinator"!==e.type&&!(e.parent&&e.parent.nodes.length>1)}function isCompoundSelector(e,t=null){if(isSimpleSelector(e))return!1;if(!e.parent)return!1;if(!!e.parent.nodes.find(e=>"combinator"===e.type))return!1;return!(!!e.parent.nodes.find(e=>"nesting"===e.type)&&t&&!isCompoundSelector(t))}function nestingIsFirstAndOnlyInSelectorWithEitherSpaceOrChildCombinator(e){if(!e.parent)return!1;if(0!==e.parent.nodes.indexOf(e))return!1;for(let t=1;t"!==e.parent.nodes[t].value)return!1;return!0}function nestingIsNotInsideCompoundSelector(e){if(isSimpleSelector(e))return!0;if(!e.parent)return!1;for(let t=0;te.split("&").length>=2&&-1===e.indexOf("|"))}function transformRuleWithinRule$1(e,t,n,r){let o=[];try{o=mergeSelectors$1(t.selectors,e.selectors,r)}catch(r){return void e.warn(n,`Failed to parse selectors : "${t.selector}" / "${e.selector}" with message: "${r instanceof Error?r.message:r}"`)}if(!o.length)return;groupDeclarations(t),shiftNodesBeforeParent(e,t),e.selectors=o;"rule"===e.type&&"rule"===t.type&&e.selector===t.selector&&e.append(...t.nodes),cleanupParent(t)}function isValidRuleWithinRule$1(e){return e.selectors.every(e=>-1===e.indexOf("|"))}function walk$1(e,t,n){e.each(r=>{const o=r.parent;isNestRule(r)&&!n.silenceAtNestWarning&&e.warn(t,`\`@nest\` was removed from the CSS Nesting specification and will be removed from PostCSS Nesting in the next major version.\nChange \`@nest ${r.params} {}\` to \`${r.params} {}\` to migrate to the latest standard.`),isRule(r)&&isRule(o)&&isValidRuleWithinRule$1(r)?transformRuleWithinRule$1(r,o,t,n):isNestRule(r)&&isRule(o)&&isValidNestRuleWithinRule(r)?transformNestRuleWithinRule(r,o,t,walk$1,n):isAtRule(r)&&isRule(o)&&isAtruleWithinRule$1(r)?atruleWithinRule$1(r,o,t,walk$1,n):isAtRule(r)&&isAtRule(o)&&isAtruleWithinAtrule(r,o)&&transformAtruleWithinAtrule(r,o),"nodes"in r&&r.nodes.length&&walk$1(r,t,n)})}const creator$2=e=>{const t=Object.assign({noIsPseudoSelector:!1,silenceAtNestWarning:!1},e);return{postcssPlugin:"postcss-nesting",Rule(e,{result:n}){walk$1(e,n,t),e.selector.includes("&")&&ersandToScope$1(e,n)}}};creator$2.postcss=!0;const i=e();function mergeSelectors(e,t,r,o){let s;try{s=n(i.astSync(t),i.astSync(r))}catch(n){return e.warn(o,`Failed to parse selectors : "${r}" / "${t}" with message: "${n instanceof Error?n.message:n}"`),!1}return!!s&&s.toString()}function ampersandToScope(t,n){{let r=t.parent;for(;r;){if("rule"===r.type)return;if(isAtRule(r)&&"scope"===r.name)return;r=r.parent}try{let n=!1;if(e().astSync(t.selector).walkNesting(()=>(n=!0,!1)),!n)return}catch(e){return void t.warn(n,`Failed to parse selector : "${t.selector}" with message: "${e instanceof Error?e.message:e}"`)}}const r=mergeSelectors(t,t.selector,":scope",n);r&&(t.selector=r)}function atruleWithinRule(e,t,n,r){if(shiftNodesBeforeParent(e,t),e.nodes){const o=t.clone().removeAll().append(e.nodes);e.append(o),cleanupParent(t),r(o,n)}else cleanupParent(t)}function isAtruleWithinRule(e){return s.includes(e.name)}function transformRuleWithinRule(e,t,n){const r=mergeSelectors(e,e.selector,t.selector,n);if(!r)return;shiftNodesBeforeParent(e,t),e.selector=r;"rule"===e.type&&"rule"===t.type&&e.selector===t.selector&&e.append(...t.nodes),cleanupParent(t)}function isValidRuleWithinRule(e){return e.selectors.every(e=>-1===e.indexOf("|"))}function walk(e,t){e.each(e=>{const n=e.parent;isRule(e)&&isRule(n)&&isValidRuleWithinRule(e)?transformRuleWithinRule(e,n,t):isAtRule(e)&&isRule(n)&&isAtruleWithinRule(e)&&atruleWithinRule(e,n,t,walk),"nodes"in e&&e.nodes.length&&walk(e,t)})}const creator$1=()=>({postcssPlugin:"postcss-nesting",Rule(e,{result:t}){walk(e,t),e.selector.includes("&")&&ersandToScope(e,t)},AtRule:{nest(e){throw e.error(`\`@nest\` was removed from the CSS Nesting specification and will be removed from PostCSS Nesting in the next major version.\nChange \`@nest ${e.params} {}\` to \`${e.params} {}\` to migrate to the latest standard.`)}}});creator$1.postcss=!0;const creator=e=>{const t=Object.assign({edition:"2024-02"},e);switch(t.edition){case"2021":return creator$2(e);case"2024-02":return creator$1();default:throw new Error(`Invalid edition: ${t.edition}`)}};creator.postcss=!0;export{creator as default}; +import e from"postcss-selector-parser";import{selectorSpecificity as t}from"@csstools/selector-specificity";import{resolveNestedSelector as n}from"@csstools/selector-resolve-nested";const r=e.pseudo({value:":is"});function sortCompoundSelectorsInsideComplexSelector(t){if(!t||!t.nodes)return;const n=[];let o=[];for(let s=0;s"tag"===e.type)){const n=r.clone({}),o=t.nodes[s];o.replaceWith(n),n.append(e.selector({nodes:[o],value:void 0}))}o.push(t.nodes[s])}else n.push(o),n.push([t.nodes[s]]),o=[];n.push(o);const s=[];for(let e=0;e"selector"===e.type&&"selector"===t.type&&e.nodes.length&&t.nodes.length?selectorTypeOrder(e.nodes[0])-selectorTypeOrder(t.nodes[0]):"selector"===e.type&&e.nodes.length?selectorTypeOrder(e.nodes[0])-selectorTypeOrder(t):"selector"===t.type&&t.nodes.length?selectorTypeOrder(e)-selectorTypeOrder(t.nodes[0]):selectorTypeOrder(e)-selectorTypeOrder(t));for(let e=0;e=0;e--)s[e].remove(),s[e].parent=t,t.nodes.unshift(s[e])}function selectorTypeOrder(t){return e.isPseudoElement(t)?o.pseudoElement:o[t.type]}const o={universal:0,tag:1,pseudoElement:2,id:3,class:4,attribute:5,pseudo:6,selector:7,string:8,root:9,comment:10};function isAtRule(e){return e&&"atrule"===e.type}function isNestRule(e){return e&&isAtRule(e)&&"nest"===e.name}function isRule(e){return e&&"rule"===e.type}function ampersandToScope$1(t,n){let r,o=t.parent;for(;o;){if("rule"===o.type)return;if(isAtRule(o)&&"scope"===o.name)return;o=o.parent}try{r=e().astSync(t.selector)}catch(e){return void t.warn(n,`Failed to parse selector : "${t.selector}" with message: "${e instanceof Error?e.message:e}"`)}r&&(r.walkNesting(t=>{const n=t.parent;t.replaceWith(e.pseudo({value:":scope"})),n&&sortCompoundSelectorsInsideComplexSelector(n)}),t.selector=r.toString())}function cleanupParent(e){if(!e.nodes.length)return void e.remove();const t=e.nodes.filter(e=>"comment"===e.type);t.length===e.nodes.length&&e.replaceWith(...t)}function groupDeclarations(e){const t=[],n=[];e.each(e=>{if(isDeclarationLike(e,n.length>0))t.push(e);else{if("comment"===e.type){let r=e.next();for(;r&&"comment"===r.type;)r=r.next();if(isDeclarationLike(r,n.length>0))return void t.push(e)}n.push(e)}}),e.removeAll(),t.forEach(t=>{e.append(t)}),n.forEach(t=>{e.append(t)})}function isDeclarationLike(e,t){return!!e&&("decl"===e.type||"atrule"===e.type&&"mixin"===e.name.toLowerCase()&&!t)}function comma(e){const t=[];let n="",r=!1,o=0,s=!1,l=!1;for(const i of e)l?l=!1:"\\"===i?l=!0:s?i===s&&(s=!1):'"'===i||"'"===i?s=i:"("===i?o+=1:")"===i?o>0&&(o-=1):0===o&&","===i&&(r=!0),r?(""!==n&&t.push(n.trim()),n="",r=!1):n+=i;return t.push(n.trim()),t}function shiftNodesBeforeParent(e,t){const n=t.index(e);if(n){const e=t.cloneBefore().removeAll().append(t.nodes.slice(0,n));e.raws.semicolon=!0,cleanupParent(e)}t.before(e),t.raws.semicolon=!0}var s=["container","document","media","supports","layer","starting-style"];function transformAtruleWithinAtrule(e,t){var n,r;groupDeclarations(t),shiftNodesBeforeParent(e,t),e.params=(n=t.params,r=e.params,comma(n).map(e=>comma(r).map(t=>`${e} and ${t}`).join(", ")).join(", ")),cleanupParent(t)}function isAtruleWithinAtrule(e,t){return s.includes(e.name)&&e.name===t.name}function atruleWithinRule$1(e,t,n,r,o){if(groupDeclarations(t),shiftNodesBeforeParent(e,t),e.nodes){const s=t.clone().removeAll().append(e.nodes);e.append(s),cleanupParent(t),r(s,n,o)}else cleanupParent(t)}function isAtruleWithinRule$1(e){return s.includes(e.name)}function combinationsWithSizeN(e,t){if(t<2)throw new Error("n must be greater than 1");if(e.length<2)throw new Error("s must be greater than 1");if(Math.pow(e.length,t)>1e4)throw new Error("Too many combinations when trying to resolve a nested selector with lists, reduce the complexity of your selectors");const n=[];for(let e=0;e=0;s--){let t=n[s];if(t>=e.length){if(t=0,n[s]=0,0===s)return r;n[s-1]+=1}o[s]=e[t].clone()}r.push(o),n[n.length-1]++}}function nodesAreEquallySpecific(n){const r=n.map(t=>e().astSync(t)).map(e=>t(e)),o=r[0];for(let e=1;ee().astSync(t)):[e().astSync(`:is(${t.join(",")})`)];const s=[];for(let t=0;t{"nesting"===e.type&&(n=!0)});const r=t.nodes[0];let o=!1;r.each(e=>"combinator"===e.type&&(o=!0,!1)),n?o&&r.insertBefore(r.at(0),e.nesting()):(r.insertBefore(r.at(0),e.combinator({value:" "})),r.insertBefore(r.at(0),e.nesting())),i=t.toString()}let c=[],a=0;if(e().astSync(i).walkNesting(()=>{a++}),a>1&&o.length>1)c=combinationsWithSizeN(o,a),l=c.length;else{l=o.length;for(let e=0;e{if("nesting"!==o.type)return;let s=c[t][n];n++,"root"===s.type&&1===s.nodes.length&&(s=s.nodes[0]);const l=e().astSync(`:is(${s.toString()})`),i=isSimpleSelector(s.nodes[0]),a=isCompoundSelector(s.nodes[0]),u=isSimpleSelector(o),p=isCompoundSelector(o);if(i&&u)return void o.replaceWith(s.clone());if((i||a)&&(u||p)){const e=o.parent;return i&&"selector"===s.type?o.replaceWith(s.clone().nodes[0]):o.replaceWith(...s.clone().nodes),void(e&&e.nodes.length>1&&sortCompoundSelectorsInsideComplexSelector(e))}if(i){const e=o.parent;return o.replaceWith(s.clone().nodes[0]),void(e&&sortCompoundSelectorsInsideComplexSelector(e))}if(a){const e=o.parent;return o.replaceWith(...s.clone().nodes),void(e&&sortCompoundSelectorsInsideComplexSelector(e))}if(nestingIsFirstAndOnlyInSelectorWithEitherSpaceOrChildCombinator(o)){const e=o.parent;return o.replaceWith(...s.clone().nodes),void(e&&sortCompoundSelectorsInsideComplexSelector(e))}if(nestingIsNotInsideCompoundSelector(o)){const e=o.parent;return o.replaceWith(...s.clone().nodes),void(e&&sortCompoundSelectorsInsideComplexSelector(e))}const d=o.parent;r.noIsPseudoSelector?o.replaceWith(...s.clone().nodes):o.replaceWith(...l.clone({}).nodes),d&&sortCompoundSelectorsInsideComplexSelector(d)}),s.push(o.toString())}}return s}function isSimpleSelector(e){return"combinator"!==e.type&&!(e.parent&&e.parent.nodes.length>1)}function isCompoundSelector(e,t=null){if(isSimpleSelector(e))return!1;if(!e.parent)return!1;if(!!e.parent.nodes.find(e=>"combinator"===e.type))return!1;return!(!!e.parent.nodes.find(e=>"nesting"===e.type)&&t&&!isCompoundSelector(t))}function nestingIsFirstAndOnlyInSelectorWithEitherSpaceOrChildCombinator(e){if(!e.parent)return!1;if(0!==e.parent.nodes.indexOf(e))return!1;for(let t=1;t"!==e.parent.nodes[t].value)return!1;return!0}function nestingIsNotInsideCompoundSelector(e){if(isSimpleSelector(e))return!0;if(!e.parent)return!1;for(let t=0;te.split("&").length>=2&&-1===e.indexOf("|"))}function transformRuleWithinRule$1(e,t,n,r){let o=[];try{o=mergeSelectors$1(t.selectors,e.selectors,r)}catch(r){return void e.warn(n,`Failed to parse selectors : "${t.selector}" / "${e.selector}" with message: "${r instanceof Error?r.message:r}"`)}if(!o.length)return;groupDeclarations(t),shiftNodesBeforeParent(e,t),e.selectors=o;"rule"===e.type&&"rule"===t.type&&e.selector===t.selector&&e.append(...t.nodes),cleanupParent(t)}function isValidRuleWithinRule$1(e){return e.selectors.every(e=>-1===e.indexOf("|"))}function walk$1(e,t,n){e.each(r=>{const o=r.parent;isNestRule(r)&&!n.silenceAtNestWarning&&e.warn(t,`\`@nest\` was removed from the CSS Nesting specification and will be removed from PostCSS Nesting in the next major version.\nChange \`@nest ${r.params} {}\` to \`${r.params} {}\` to migrate to the latest standard.`),isRule(r)&&isRule(o)&&isValidRuleWithinRule$1(r)?transformRuleWithinRule$1(r,o,t,n):isNestRule(r)&&isRule(o)&&isValidNestRuleWithinRule(r)?transformNestRuleWithinRule(r,o,t,walk$1,n):isAtRule(r)&&isRule(o)&&isAtruleWithinRule$1(r)?atruleWithinRule$1(r,o,t,walk$1,n):isAtRule(r)&&isAtRule(o)&&isAtruleWithinAtrule(r,o)&&transformAtruleWithinAtrule(r,o),"nodes"in r&&r.nodes.length&&walk$1(r,t,n)})}const creator$2=e=>{const t=Object.assign({noIsPseudoSelector:!1,silenceAtNestWarning:!1},e);return{postcssPlugin:"postcss-nesting",Rule(e,{result:n}){walk$1(e,n,t),e.selector.includes("&")&&ersandToScope$1(e,n)}}};creator$2.postcss=!0;const l=e();function mergeSelectors(e,t,r,o){let s;try{s=n(l.astSync(t),l.astSync(r))}catch(n){return e.warn(o,`Failed to parse selectors : "${r}" / "${t}" with message: "${n instanceof Error?n.message:n}"`),!1}return!!s&&s.toString()}function ampersandToScope(t,n){{let r=t.parent;for(;r;){if("rule"===r.type)return;if(isAtRule(r)&&"scope"===r.name)return;r=r.parent}try{let n=!1;if(e().astSync(t.selector).walkNesting(()=>(n=!0,!1)),!n)return}catch(e){return void t.warn(n,`Failed to parse selector : "${t.selector}" with message: "${e instanceof Error?e.message:e}"`)}}const r=mergeSelectors(t,t.selector,":scope",n);r&&(t.selector=r)}function atruleWithinRule(e,t,n,r){if(shiftNodesBeforeParent(e,t),e.nodes){const o=t.clone().removeAll().append(e.nodes);e.append(o),cleanupParent(t),r(o,n)}else cleanupParent(t)}function isAtruleWithinRule(e){return s.includes(e.name)}function transformRuleWithinRule(e,t,n){const r=mergeSelectors(e,e.selector,t.selector,n);if(!r)return;shiftNodesBeforeParent(e,t),e.selector=r;"rule"===e.type&&"rule"===t.type&&e.selector===t.selector&&e.append(...t.nodes),cleanupParent(t)}function isValidRuleWithinRule(e){return e.selectors.every(e=>-1===e.indexOf("|"))}function walk(e,t){e.each(e=>{const n=e.parent;isRule(e)&&isRule(n)&&isValidRuleWithinRule(e)?transformRuleWithinRule(e,n,t):isAtRule(e)&&isRule(n)&&isAtruleWithinRule(e)&&atruleWithinRule(e,n,t,walk),"nodes"in e&&e.nodes.length&&walk(e,t)})}const creator$1=()=>({postcssPlugin:"postcss-nesting",Rule(e,{result:t}){walk(e,t),e.selector.includes("&")&&ersandToScope(e,t)},AtRule:{nest(e){throw e.error(`\`@nest\` was removed from the CSS Nesting specification and will be removed from PostCSS Nesting in the next major version.\nChange \`@nest ${e.params} {}\` to \`${e.params} {}\` to migrate to the latest standard.`)}}});creator$1.postcss=!0;const creator=e=>{const t=Object.assign({edition:"2024-02"},e);switch(t.edition){case"2021":return creator$2(e);case"2024-02":return creator$1();default:throw new Error(`Invalid edition: ${t.edition}`)}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-nesting/package.json b/plugins/postcss-nesting/package.json index 1e987ca8d..b4f96bc5e 100644 --- a/plugins/postcss-nesting/package.json +++ b/plugins/postcss-nesting/package.json @@ -29,22 +29,16 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "jsdelivr": "dist/index.mjs", "unpkg": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-nesting/src/index.ts b/plugins/postcss-nesting/src/index.ts index 814e12571..f7a277079 100644 --- a/plugins/postcss-nesting/src/index.ts +++ b/plugins/postcss-nesting/src/index.ts @@ -38,3 +38,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-normalize-display-values/CHANGELOG.md b/plugins/postcss-normalize-display-values/CHANGELOG.md index 5b525670e..74e509131 100644 --- a/plugins/postcss-normalize-display-values/CHANGELOG.md +++ b/plugins/postcss-normalize-display-values/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Normalize Display Values +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.1 _January 10, 2026_ diff --git a/plugins/postcss-normalize-display-values/dist/index.cjs b/plugins/postcss-normalize-display-values/dist/index.cjs deleted file mode 100644 index 25adcd0a8..000000000 --- a/plugins/postcss-normalize-display-values/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser"),l=new Map([["block,flex","flex"],["block,flow","block"],["block,flow-root","flow-root"],["block,grid","grid"],["block,table","table"],["inline,block","inline-block"],["inline,flex","inline-flex"],["inline,flow","inline"],["inline,flow,list-item","inline list-item"],["inline,flow-root","inline-block"],["inline,grid","inline-grid"],["inline,ruby","ruby"],["inline,table","inline-table"],["list-item,block,flow","list-item"],["ruby-base,flow","ruby-base"],["ruby-text,flow","ruby-text"],["run-in,flow","run-in"],["table-caption,flow","table-caption"],["table-cell,flow","table-cell"]]);function transform(n){if(!n.trim())return n;const{nodes:i}=e(n);if(i.length<=1)return n;const t=i.filter(e=>"word"===e.type).map(e=>e.value.toLowerCase());if(t.length<=1)return n;const o=l.get(t.join(","));return o||n}const n=/^display$/i,i=/\b\s\b/,creator=e=>{const l=!("preserve"in Object(e))||Boolean(e?.preserve);return{postcssPlugin:"postcss-normalize-display-values",Declaration(e){if(!n.test(e.prop))return;const t=e.value;if(!t)return;if(!i.test(t))return;const o=transform(t);e.value!==o&&(e.cloneBefore({value:o}),l||e.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-normalize-display-values/dist/index.d.ts b/plugins/postcss-normalize-display-values/dist/index.d.ts index 54036ec0b..a64418776 100644 --- a/plugins/postcss-normalize-display-values/dist/index.d.ts +++ b/plugins/postcss-normalize-display-values/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-normalize-display-values plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-normalize-display-values/dist/index.mjs b/plugins/postcss-normalize-display-values/dist/index.mjs index 50185423c..06ae293f2 100644 --- a/plugins/postcss-normalize-display-values/dist/index.mjs +++ b/plugins/postcss-normalize-display-values/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";var l=new Map([["block,flex","flex"],["block,flow","block"],["block,flow-root","flow-root"],["block,grid","grid"],["block,table","table"],["inline,block","inline-block"],["inline,flex","inline-flex"],["inline,flow","inline"],["inline,flow,list-item","inline list-item"],["inline,flow-root","inline-block"],["inline,grid","inline-grid"],["inline,ruby","ruby"],["inline,table","inline-table"],["list-item,block,flow","list-item"],["ruby-base,flow","ruby-base"],["ruby-text,flow","ruby-text"],["run-in,flow","run-in"],["table-caption,flow","table-caption"],["table-cell,flow","table-cell"]]);function transform(n){if(!n.trim())return n;const{nodes:i}=e(n);if(i.length<=1)return n;const t=i.filter(e=>"word"===e.type).map(e=>e.value.toLowerCase());if(t.length<=1)return n;const o=l.get(t.join(","));return o||n}const n=/^display$/i,i=/\b\s\b/,creator=e=>{const l=!("preserve"in Object(e))||Boolean(e?.preserve);return{postcssPlugin:"postcss-normalize-display-values",Declaration(e){if(!n.test(e.prop))return;const t=e.value;if(!t)return;if(!i.test(t))return;const o=transform(t);e.value!==o&&(e.cloneBefore({value:o}),l||e.remove())}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-value-parser";var l=new Map([["block,flex","flex"],["block,flow","block"],["block,flow-root","flow-root"],["block,grid","grid"],["block,table","table"],["inline,block","inline-block"],["inline,flex","inline-flex"],["inline,flow","inline"],["inline,flow,list-item","inline list-item"],["inline,flow-root","inline-block"],["inline,grid","inline-grid"],["inline,ruby","ruby"],["inline,table","inline-table"],["list-item,block,flow","list-item"],["ruby-base,flow","ruby-base"],["ruby-text,flow","ruby-text"],["run-in,flow","run-in"],["table-caption,flow","table-caption"],["table-cell,flow","table-cell"]]);function transform(n){if(!n.trim())return n;const{nodes:i}=e(n);if(i.length<=1)return n;const t=i.filter(e=>"word"===e.type).map(e=>e.value.toLowerCase());if(t.length<=1)return n;const o=l.get(t.join(","));return o||n}const n=/^display$/i,i=/\b\s\b/,creator=e=>{const l=!("preserve"in Object(e))||Boolean(e?.preserve);return{postcssPlugin:"postcss-normalize-display-values",Declaration(e){if(!n.test(e.prop))return;const t=e.value;if(!t)return;if(!i.test(t))return;const o=transform(t);e.value!==o&&(e.cloneBefore({value:o}),l||e.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-normalize-display-values/package.json b/plugins/postcss-normalize-display-values/package.json index 274d33c7a..2b590d862 100644 --- a/plugins/postcss-normalize-display-values/package.json +++ b/plugins/postcss-normalize-display-values/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-normalize-display-values/src/index.ts b/plugins/postcss-normalize-display-values/src/index.ts index 38bd0c4bf..67d067132 100644 --- a/plugins/postcss-normalize-display-values/src/index.ts +++ b/plugins/postcss-normalize-display-values/src/index.ts @@ -76,4 +76,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-oklab-function/CHANGELOG.md b/plugins/postcss-oklab-function/CHANGELOG.md index cc2113f90..4597f2a28 100644 --- a/plugins/postcss-oklab-function/CHANGELOG.md +++ b/plugins/postcss-oklab-function/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS OKLab Function +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.12 _September 21, 2025_ diff --git a/plugins/postcss-oklab-function/dist/index.cjs b/plugins/postcss-oklab-function/dist/index.cjs deleted file mode 100644 index 8fefe517f..000000000 --- a/plugins/postcss-oklab-function/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/css-color-parser"),t=require("@csstools/utilities"),a=require("@csstools/css-parser-algorithms"),r=require("@csstools/css-tokenizer");const o=/\b(?:oklab|oklch)\(/i,l=/^(?:oklab|oklch)$/i,basePlugin=s=>({postcssPlugin:"postcss-oklab-function",Declaration(n){const i=n.value;if(!o.test(i))return;if(t.hasFallback(n))return;if(t.hasSupportsAtRuleAncestor(n,o))return;const u=r.tokenize({css:i}),c=a.replaceComponentValues(a.parseCommaSeparatedListOfComponentValues(u),s=>{if(!a.isFunctionNode(s)||!l.test(s.getName()))return;const t=e.color(s);return t&&!(t.syntaxFlags.has(e.SyntaxFlag.Experimental)||t.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords)||t.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax))?e.serializeRGB(t):void 0}),p=a.stringify(c);if(p===i)return;let g=p;s?.subFeatures.displayP3&&(g=a.stringify(a.replaceComponentValues(a.parseCommaSeparatedListOfComponentValues(u),s=>{if(!a.isFunctionNode(s)||!l.test(s.getName()))return;const t=e.color(s);return t&&!(t.syntaxFlags.has(e.SyntaxFlag.Experimental)||t.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords)||t.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax))?e.colorDataFitsRGB_Gamut(t)?e.serializeRGB(t):e.serializeP3(t):void 0}))),n.cloneBefore({value:p}),s?.subFeatures.displayP3&&g!==p&&n.cloneBefore({value:g}),s?.preserve||n.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return t.subFeatures=Object.assign({displayP3:!0},t.subFeatures),t.enableProgressiveCustomProperties&&(t.preserve||t.subFeatures.displayP3)?{postcssPlugin:"postcss-oklab-function",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-oklab-function/dist/index.d.ts b/plugins/postcss-oklab-function/dist/index.d.ts index d77c17a08..39e393ea2 100644 --- a/plugins/postcss-oklab-function/dist/index.d.ts +++ b/plugins/postcss-oklab-function/dist/index.d.ts @@ -16,5 +16,6 @@ export declare type pluginOptions = { /** Transform oklab() and oklch() functions in CSS. */ declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-oklab-function/dist/index.mjs b/plugins/postcss-oklab-function/dist/index.mjs index 961004ffb..12e6b3ca8 100644 --- a/plugins/postcss-oklab-function/dist/index.mjs +++ b/plugins/postcss-oklab-function/dist/index.mjs @@ -1 +1 @@ -import s from"@csstools/postcss-progressive-custom-properties";import{color as e,SyntaxFlag as t,serializeRGB as o,colorDataFitsRGB_Gamut as r,serializeP3 as a}from"@csstools/css-color-parser";import{hasFallback as l,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as c,isFunctionNode as u,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as m}from"@csstools/css-tokenizer";const g=/\b(?:oklab|oklch)\(/i,f=/^(?:oklab|oklch)$/i,basePlugin=s=>({postcssPlugin:"postcss-oklab-function",Declaration(b){const y=b.value;if(!g.test(y))return;if(l(b))return;if(i(b,g))return;const v=m({css:y}),F=n(c(v),s=>{if(!u(s)||!f.test(s.getName()))return;const r=e(s);return r&&!(r.syntaxFlags.has(t.Experimental)||r.syntaxFlags.has(t.HasNoneKeywords)||r.syntaxFlags.has(t.RelativeColorSyntax))?o(r):void 0}),x=p(F);if(x===y)return;let P=x;s?.subFeatures.displayP3&&(P=p(n(c(v),s=>{if(!u(s)||!f.test(s.getName()))return;const l=e(s);return l&&!(l.syntaxFlags.has(t.Experimental)||l.syntaxFlags.has(t.HasNoneKeywords)||l.syntaxFlags.has(t.RelativeColorSyntax))?r(l)?o(l):a(l):void 0}))),b.cloneBefore({value:x}),s?.subFeatures.displayP3&&P!==x&&b.cloneBefore({value:P}),s?.preserve||b.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return t.subFeatures=Object.assign({displayP3:!0},t.subFeatures),t.enableProgressiveCustomProperties&&(t.preserve||t.subFeatures.displayP3)?{postcssPlugin:"postcss-oklab-function",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import s from"@csstools/postcss-progressive-custom-properties";import{color as e,SyntaxFlag as t,serializeRGB as o,colorDataFitsRGB_Gamut as r,serializeP3 as a}from"@csstools/css-color-parser";import{hasFallback as l,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as u,isFunctionNode as c,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as m}from"@csstools/css-tokenizer";const g=/\b(?:oklab|oklch)\(/i,f=/^(?:oklab|oklch)$/i,basePlugin=s=>({postcssPlugin:"postcss-oklab-function",Declaration(b){const y=b.value;if(!g.test(y))return;if(l(b))return;if(i(b,g))return;const v=m({css:y}),x=n(u(v),s=>{if(!c(s)||!f.test(s.getName()))return;const r=e(s);return r&&!(r.syntaxFlags.has(t.Experimental)||r.syntaxFlags.has(t.HasNoneKeywords)||r.syntaxFlags.has(t.RelativeColorSyntax))?o(r):void 0}),F=p(x);if(F===y)return;let d=F;s?.subFeatures.displayP3&&(d=p(n(u(v),s=>{if(!c(s)||!f.test(s.getName()))return;const l=e(s);return l&&!(l.syntaxFlags.has(t.Experimental)||l.syntaxFlags.has(t.HasNoneKeywords)||l.syntaxFlags.has(t.RelativeColorSyntax))?r(l)?o(l):a(l):void 0}))),b.cloneBefore({value:F}),s?.subFeatures.displayP3&&d!==F&&b.cloneBefore({value:d}),s?.preserve||b.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return t.subFeatures=Object.assign({displayP3:!0},t.subFeatures),t.enableProgressiveCustomProperties&&(t.preserve||t.subFeatures.displayP3)?{postcssPlugin:"postcss-oklab-function",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-oklab-function/package.json b/plugins/postcss-oklab-function/package.json index 3022641b5..057b27587 100644 --- a/plugins/postcss-oklab-function/package.json +++ b/plugins/postcss-oklab-function/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-oklab-function/src/index.ts b/plugins/postcss-oklab-function/src/index.ts index fc1ff2253..e46441fef 100644 --- a/plugins/postcss-oklab-function/src/index.ts +++ b/plugins/postcss-oklab-function/src/index.ts @@ -153,3 +153,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-overflow-shorthand/CHANGELOG.md b/plugins/postcss-overflow-shorthand/CHANGELOG.md index 46dad2eca..df3439214 100644 --- a/plugins/postcss-overflow-shorthand/CHANGELOG.md +++ b/plugins/postcss-overflow-shorthand/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Overflow Shorthand +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 6.0.0 _August 3, 2024_ diff --git a/plugins/postcss-overflow-shorthand/dist/index.cjs b/plugins/postcss-overflow-shorthand/dist/index.cjs deleted file mode 100644 index 80d003c6d..000000000 --- a/plugins/postcss-overflow-shorthand/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser");const creator=r=>{const o=Object.assign({preserve:!0},r);return{postcssPlugin:"postcss-overflow-shorthand",Declaration(r,{result:s}){if("overflow"!==r.prop.toLowerCase())return;let t="",a="";const l=r.value;try{const r=e(l).nodes.slice().filter(e=>"comment"!==e.type&&"space"!==e.type);if(r.length<2)return;t=e.stringify(r[0]),a=e.stringify(r[1])}catch{return void r.warn(s,`Failed to parse value '${l}' as a shorthand for "overflow". Leaving the original value intact.`)}t&&a&&(t.toLowerCase()===a.toLowerCase()?r.cloneBefore({value:t}):(r.cloneBefore({prop:"overflow-x",value:t}),r.cloneBefore({prop:"overflow-y",value:a})),o.preserve||r.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-overflow-shorthand/dist/index.d.ts b/plugins/postcss-overflow-shorthand/dist/index.d.ts index 51611ae6f..367a7e786 100644 --- a/plugins/postcss-overflow-shorthand/dist/index.d.ts +++ b/plugins/postcss-overflow-shorthand/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-overflow-shorthand plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-overflow-shorthand/dist/index.mjs b/plugins/postcss-overflow-shorthand/dist/index.mjs index 58d54a875..d0afdef3e 100644 --- a/plugins/postcss-overflow-shorthand/dist/index.mjs +++ b/plugins/postcss-overflow-shorthand/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";const creator=o=>{const r=Object.assign({preserve:!0},o);return{postcssPlugin:"postcss-overflow-shorthand",Declaration(o,{result:t}){if("overflow"!==o.prop.toLowerCase())return;let s="",a="";const l=o.value;try{const o=e(l).nodes.slice().filter(e=>"comment"!==e.type&&"space"!==e.type);if(o.length<2)return;s=e.stringify(o[0]),a=e.stringify(o[1])}catch{return void o.warn(t,`Failed to parse value '${l}' as a shorthand for "overflow". Leaving the original value intact.`)}s&&a&&(s.toLowerCase()===a.toLowerCase()?o.cloneBefore({value:s}):(o.cloneBefore({prop:"overflow-x",value:s}),o.cloneBefore({prop:"overflow-y",value:a})),r.preserve||o.remove())}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-value-parser";const creator=o=>{const r=Object.assign({preserve:!0},o);return{postcssPlugin:"postcss-overflow-shorthand",Declaration(o,{result:t}){if("overflow"!==o.prop.toLowerCase())return;let s="",a="";const l=o.value;try{const o=e(l).nodes.slice().filter(e=>"comment"!==e.type&&"space"!==e.type);if(o.length<2)return;s=e.stringify(o[0]),a=e.stringify(o[1])}catch{return void o.warn(t,`Failed to parse value '${l}' as a shorthand for "overflow". Leaving the original value intact.`)}s&&a&&(s.toLowerCase()===a.toLowerCase()?o.cloneBefore({value:s}):(o.cloneBefore({prop:"overflow-x",value:s}),o.cloneBefore({prop:"overflow-y",value:a})),r.preserve||o.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-overflow-shorthand/package.json b/plugins/postcss-overflow-shorthand/package.json index e29d60738..7e8fbefb5 100644 --- a/plugins/postcss-overflow-shorthand/package.json +++ b/plugins/postcss-overflow-shorthand/package.json @@ -29,20 +29,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-overflow-shorthand/src/index.ts b/plugins/postcss-overflow-shorthand/src/index.ts index 21f917399..e7d14318c 100644 --- a/plugins/postcss-overflow-shorthand/src/index.ts +++ b/plugins/postcss-overflow-shorthand/src/index.ts @@ -79,3 +79,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-place/CHANGELOG.md b/plugins/postcss-place/CHANGELOG.md index b37b95910..ced824a24 100644 --- a/plugins/postcss-place/CHANGELOG.md +++ b/plugins/postcss-place/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Place Properties +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 10.0.0 _August 3, 2024_ diff --git a/plugins/postcss-place/dist/index.cjs b/plugins/postcss-place/dist/index.cjs deleted file mode 100644 index 4d925e54c..000000000 --- a/plugins/postcss-place/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser");function onCSSDeclaration(r,o,s){const n=r.prop.match(t)?.[1].toLowerCase();if(!n)return;let a;try{a=e(r.value)}catch{r.warn(o,`Failed to parse value '${r.value}'. Leaving the original value intact.`)}if(void 0===a)return;let i=[];i=a.nodes.length?a.nodes.filter(e=>"word"===e.type||"function"===e.type).map(t=>e.stringify(t)):[e.stringify(a.nodes)],r.cloneBefore({prop:`align-${n}`,value:i[0]}),r.cloneBefore({prop:`justify-${n}`,value:i[1]||i[0]}),s.preserve||r.remove()}const t=/^place-(content|items|self)/i,creator=e=>{const r=Object.assign({preserve:!0},e);return{postcssPlugin:"postcss-place",Declaration(e,{result:o}){t.test(e.prop)&&onCSSDeclaration(e,o,r)}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-place/dist/index.d.ts b/plugins/postcss-place/dist/index.d.ts index 381ddc139..7b16032bc 100644 --- a/plugins/postcss-place/dist/index.d.ts +++ b/plugins/postcss-place/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-place plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-place/dist/index.mjs b/plugins/postcss-place/dist/index.mjs index 0108bf04b..1dc7b8dd8 100644 --- a/plugins/postcss-place/dist/index.mjs +++ b/plugins/postcss-place/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";function onCSSDeclaration(o,r,s){const n=o.prop.match(t)?.[1].toLowerCase();if(!n)return;let a;try{a=e(o.value)}catch{o.warn(r,`Failed to parse value '${o.value}'. Leaving the original value intact.`)}if(void 0===a)return;let i=[];i=a.nodes.length?a.nodes.filter(e=>"word"===e.type||"function"===e.type).map(t=>e.stringify(t)):[e.stringify(a.nodes)],o.cloneBefore({prop:`align-${n}`,value:i[0]}),o.cloneBefore({prop:`justify-${n}`,value:i[1]||i[0]}),s.preserve||o.remove()}const t=/^place-(content|items|self)/i,creator=e=>{const o=Object.assign({preserve:!0},e);return{postcssPlugin:"postcss-place",Declaration(e,{result:r}){t.test(e.prop)&&onCSSDeclaration(e,r,o)}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-value-parser";function onCSSDeclaration(o,r,s){const n=o.prop.match(t)?.[1].toLowerCase();if(!n)return;let a;try{a=e(o.value)}catch{o.warn(r,`Failed to parse value '${o.value}'. Leaving the original value intact.`)}if(void 0===a)return;let l=[];l=a.nodes.length?a.nodes.filter(e=>"word"===e.type||"function"===e.type).map(t=>e.stringify(t)):[e.stringify(a.nodes)],o.cloneBefore({prop:`align-${n}`,value:l[0]}),o.cloneBefore({prop:`justify-${n}`,value:l[1]||l[0]}),s.preserve||o.remove()}const t=/^place-(content|items|self)/i,creator=e=>{const o=Object.assign({preserve:!0},e);return{postcssPlugin:"postcss-place",Declaration(e,{result:r}){t.test(e.prop)&&onCSSDeclaration(e,r,o)}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-place/package.json b/plugins/postcss-place/package.json index 272515e97..871977e25 100644 --- a/plugins/postcss-place/package.json +++ b/plugins/postcss-place/package.json @@ -29,20 +29,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-place/src/index.ts b/plugins/postcss-place/src/index.ts index e6a97dfc5..1f6a454af 100644 --- a/plugins/postcss-place/src/index.ts +++ b/plugins/postcss-place/src/index.ts @@ -32,3 +32,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-position-area-property/CHANGELOG.md b/plugins/postcss-position-area-property/CHANGELOG.md index eae61a895..5358a1020 100644 --- a/plugins/postcss-position-area-property/CHANGELOG.md +++ b/plugins/postcss-position-area-property/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Position Area Property +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 1.0.0 _December 3, 2025_ diff --git a/plugins/postcss-position-area-property/dist/index.cjs b/plugins/postcss-position-area-property/dist/index.cjs deleted file mode 100644 index 5dfd00b8b..000000000 --- a/plugins/postcss-position-area-property/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";const s=/^position-area$/i,creator=()=>({postcssPlugin:"postcss-position-area-property",Declaration(o){s.test(o.prop)&&o.cloneBefore({prop:"inset-area",value:o.value})}});creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-position-area-property/dist/index.d.ts b/plugins/postcss-position-area-property/dist/index.d.ts index 8a5d53e0a..ee5070e74 100644 --- a/plugins/postcss-position-area-property/dist/index.d.ts +++ b/plugins/postcss-position-area-property/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-position-area-property plugin options */ export declare type pluginOptions = never; diff --git a/plugins/postcss-position-area-property/dist/index.mjs b/plugins/postcss-position-area-property/dist/index.mjs index 9dc05288f..5cfe3c322 100644 --- a/plugins/postcss-position-area-property/dist/index.mjs +++ b/plugins/postcss-position-area-property/dist/index.mjs @@ -1 +1 @@ -const o=/^position-area$/i,creator=()=>({postcssPlugin:"postcss-position-area-property",Declaration(s){o.test(s.prop)&&s.cloneBefore({prop:"inset-area",value:s.value})}});creator.postcss=!0;export{creator as default}; +const o=/^position-area$/i,creator=()=>({postcssPlugin:"postcss-position-area-property",Declaration(s){o.test(s.prop)&&s.cloneBefore({prop:"inset-area",value:s.value})}});creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-position-area-property/package.json b/plugins/postcss-position-area-property/package.json index 2574c0081..17b33ff2f 100644 --- a/plugins/postcss-position-area-property/package.json +++ b/plugins/postcss-position-area-property/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-position-area-property/src/index.ts b/plugins/postcss-position-area-property/src/index.ts index 3728f47e6..21f5a506a 100644 --- a/plugins/postcss-position-area-property/src/index.ts +++ b/plugins/postcss-position-area-property/src/index.ts @@ -24,3 +24,4 @@ const creator: PluginCreator = () => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-progressive-custom-properties/CHANGELOG.md b/plugins/postcss-progressive-custom-properties/CHANGELOG.md index 3bf1d7e84..bf0692a3f 100644 --- a/plugins/postcss-progressive-custom-properties/CHANGELOG.md +++ b/plugins/postcss-progressive-custom-properties/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Progressive Custom Properties +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.2.1 _September 21, 2025_ diff --git a/plugins/postcss-progressive-custom-properties/dist/index.cjs b/plugins/postcss-progressive-custom-properties/dist/index.cjs deleted file mode 100644 index e984f754a..000000000 --- a/plugins/postcss-progressive-custom-properties/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser");const a=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"];function doublePositionGradients(e){const p=[],r=e.value.toLowerCase();if("function"===e.type&&("conic-gradient"===r||"linear-gradient"===r||"radial-gradient"===r||"repeating-conic-gradient"===r||"repeating-linear-gradient"===r||"repeating-radial-gradient"===r)){let r=0,t=!1,i=!1;e:for(let o=0;oi.includes(e.sniff)&&(e.only_on_property??a.prop)===a.prop);let y=!1;try{e(i).walk(a=>{"function"===a.type&&r.test(a.value)&&(y=!0);try{const p=e.unit(a.value);!1!==p&&(a.dimension=p)}catch{}for(let e=0;e({postcssPlugin:"postcss-progressive-custom-properties",prepare(){const e=new WeakMap;return{postcssPlugin:"postcss-progressive-custom-properties",OnceExit(a,{postcss:p}){a.walkDecls(a=>{if(!a.parent)return;const r=e.get(a.parent)||{conditionalRules:[],propNames:new Set,lastConditionParams:{support:void 0},lastConditionalRule:void 0};if(e.set(a.parent,r),a.variable){if(!r.propNames.has(a.prop))return void r.propNames.add(a.prop)}else{const e=a.prop.toLowerCase();if(!r.propNames.has(e))return void r.propNames.add(e)}if(!a.variable&&!t.test(a.value))return;if(i.test(a.value))return;if(o.test(a.value))return;const s=conditionsFromValue(a,!a.variable).support.join(" and ");if(!s)return;if(r.lastConditionParams.support!==s&&(r.lastConditionalRule=void 0),r.lastConditionalRule)return r.lastConditionalRule.append(a.clone()),void a.remove();const y=[];if(s&&y.push(p.atRule({name:"supports",params:s,source:a.parent.source,raws:{before:"\n\n",after:"\n"}})),!y.length)return;for(let e=0;e{const p=e.get(a);p&&0!==p.conditionalRules.length&&p.conditionalRules.reverse().forEach(e=>{a.after(e)})})}}}});creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-progressive-custom-properties/dist/index.d.ts b/plugins/postcss-progressive-custom-properties/dist/index.d.ts index 240fc585b..ce6429263 100644 --- a/plugins/postcss-progressive-custom-properties/dist/index.d.ts +++ b/plugins/postcss-progressive-custom-properties/dist/index.d.ts @@ -2,5 +2,6 @@ import { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export { } diff --git a/plugins/postcss-progressive-custom-properties/dist/index.mjs b/plugins/postcss-progressive-custom-properties/dist/index.mjs index 18937f7c3..4e0c1118c 100644 --- a/plugins/postcss-progressive-custom-properties/dist/index.mjs +++ b/plugins/postcss-progressive-custom-properties/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";const a=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"];function doublePositionGradients(e){const p=[],r=e.value.toLowerCase();if("function"===e.type&&("conic-gradient"===r||"linear-gradient"===r||"radial-gradient"===r||"repeating-conic-gradient"===r||"repeating-linear-gradient"===r||"repeating-radial-gradient"===r)){let r=0,t=!1,i=!1;e:for(let o=0;oi.includes(e.sniff)&&(e.only_on_property??a.prop)===a.prop);let y=!1;try{e(i).walk(a=>{"function"===a.type&&r.test(a.value)&&(y=!0);try{const p=e.unit(a.value);!1!==p&&(a.dimension=p)}catch{}for(let e=0;e({postcssPlugin:"postcss-progressive-custom-properties",prepare(){const e=new WeakMap;return{postcssPlugin:"postcss-progressive-custom-properties",OnceExit(a,{postcss:p}){a.walkDecls(a=>{if(!a.parent)return;const r=e.get(a.parent)||{conditionalRules:[],propNames:new Set,lastConditionParams:{support:void 0},lastConditionalRule:void 0};if(e.set(a.parent,r),a.variable){if(!r.propNames.has(a.prop))return void r.propNames.add(a.prop)}else{const e=a.prop.toLowerCase();if(!r.propNames.has(e))return void r.propNames.add(e)}if(!a.variable&&!t.test(a.value))return;if(i.test(a.value))return;if(o.test(a.value))return;const s=conditionsFromValue(a,!a.variable).support.join(" and ");if(!s)return;if(r.lastConditionParams.support!==s&&(r.lastConditionalRule=void 0),r.lastConditionalRule)return r.lastConditionalRule.append(a.clone()),void a.remove();const y=[];if(s&&y.push(p.atRule({name:"supports",params:s,source:a.parent.source,raws:{before:"\n\n",after:"\n"}})),!y.length)return;for(let e=0;e{const p=e.get(a);p&&0!==p.conditionalRules.length&&p.conditionalRules.reverse().forEach(e=>{a.after(e)})})}}}});creator.postcss=!0;export{creator as default}; +import e from"postcss-value-parser";const a=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"];function doublePositionGradients(e){const p=[],r=e.value.toLowerCase();if("function"===e.type&&("conic-gradient"===r||"linear-gradient"===r||"radial-gradient"===r||"repeating-conic-gradient"===r||"repeating-linear-gradient"===r||"repeating-radial-gradient"===r)){let r=0,t=!1,i=!1;e:for(let o=0;oi.includes(e.sniff)&&(e.only_on_property??a.prop)===a.prop);let y=!1;try{e(i).walk(a=>{"function"===a.type&&r.test(a.value)&&(y=!0);try{const p=e.unit(a.value);!1!==p&&(a.dimension=p)}catch{}for(let e=0;e({postcssPlugin:"postcss-progressive-custom-properties",prepare(){const e=new WeakMap;return{postcssPlugin:"postcss-progressive-custom-properties",OnceExit(a,{postcss:p}){a.walkDecls(a=>{if(!a.parent)return;const r=e.get(a.parent)||{conditionalRules:[],propNames:new Set,lastConditionParams:{support:void 0},lastConditionalRule:void 0};if(e.set(a.parent,r),a.variable){if(!r.propNames.has(a.prop))return void r.propNames.add(a.prop)}else{const e=a.prop.toLowerCase();if(!r.propNames.has(e))return void r.propNames.add(e)}if(!a.variable&&!t.test(a.value))return;if(i.test(a.value))return;if(o.test(a.value))return;const s=conditionsFromValue(a,!a.variable).support.join(" and ");if(!s)return;if(r.lastConditionParams.support!==s&&(r.lastConditionalRule=void 0),r.lastConditionalRule)return r.lastConditionalRule.append(a.clone()),void a.remove();const y=[];if(s&&y.push(p.atRule({name:"supports",params:s,source:a.parent.source,raws:{before:"\n\n",after:"\n"}})),!y.length)return;for(let e=0;e{const p=e.get(a);p&&0!==p.conditionalRules.length&&p.conditionalRules.reverse().forEach(e=>{a.after(e)})})}}}});creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-progressive-custom-properties/package.json b/plugins/postcss-progressive-custom-properties/package.json index 3099b69a8..f4fbbd0fd 100644 --- a/plugins/postcss-progressive-custom-properties/package.json +++ b/plugins/postcss-progressive-custom-properties/package.json @@ -15,20 +15,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-progressive-custom-properties/src/index.ts b/plugins/postcss-progressive-custom-properties/src/index.ts index 876483ebf..31dbbab29 100644 --- a/plugins/postcss-progressive-custom-properties/src/index.ts +++ b/plugins/postcss-progressive-custom-properties/src/index.ts @@ -157,3 +157,4 @@ const creator: PluginCreator = () => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-property-rule-prelude-list/CHANGELOG.md b/plugins/postcss-property-rule-prelude-list/CHANGELOG.md index 8bcd6758b..ad2703a44 100644 --- a/plugins/postcss-property-rule-prelude-list/CHANGELOG.md +++ b/plugins/postcss-property-rule-prelude-list/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Property Rule Prelude List +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 1.0.0 _December 27, 2025_ diff --git a/plugins/postcss-property-rule-prelude-list/dist/index.cjs b/plugins/postcss-property-rule-prelude-list/dist/index.cjs deleted file mode 100644 index 64a2db2d7..000000000 --- a/plugins/postcss-property-rule-prelude-list/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("@csstools/css-parser-algorithms"),e=require("@csstools/css-tokenizer");const r=/^property$/i,creator=()=>({postcssPlugin:"postcss-property-rule-prelude-list",AtRule(t){if(!r.test(t.name))return;if(!t.params.includes(","))return;const o=s.parseCommaSeparatedListOfComponentValues(e.tokenize({css:t.params}));o.length<2||(o.forEach(e=>{t.cloneBefore({params:s.stringify([e]).trim()})}),t.remove())}});creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-property-rule-prelude-list/dist/index.d.ts b/plugins/postcss-property-rule-prelude-list/dist/index.d.ts index 27d0f244b..62b929e50 100644 --- a/plugins/postcss-property-rule-prelude-list/dist/index.d.ts +++ b/plugins/postcss-property-rule-prelude-list/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-property-rule-prelude-list plugin options */ export declare type pluginOptions = never; diff --git a/plugins/postcss-property-rule-prelude-list/dist/index.mjs b/plugins/postcss-property-rule-prelude-list/dist/index.mjs index 26a8de6c1..7435cceca 100644 --- a/plugins/postcss-property-rule-prelude-list/dist/index.mjs +++ b/plugins/postcss-property-rule-prelude-list/dist/index.mjs @@ -1 +1 @@ -import{parseCommaSeparatedListOfComponentValues as s,stringify as r}from"@csstools/css-parser-algorithms";import{tokenize as t}from"@csstools/css-tokenizer";const e=/^property$/i,creator=()=>({postcssPlugin:"postcss-property-rule-prelude-list",AtRule(o){if(!e.test(o.name))return;if(!o.params.includes(","))return;const p=s(t({css:o.params}));p.length<2||(p.forEach(s=>{o.cloneBefore({params:r([s]).trim()})}),o.remove())}});creator.postcss=!0;export{creator as default}; +import{parseCommaSeparatedListOfComponentValues as s,stringify as r}from"@csstools/css-parser-algorithms";import{tokenize as e}from"@csstools/css-tokenizer";const o=/^property$/i,creator=()=>({postcssPlugin:"postcss-property-rule-prelude-list",AtRule(t){if(!o.test(t.name))return;if(!t.params.includes(","))return;const p=s(e({css:t.params}));p.length<2||(p.forEach(s=>{t.cloneBefore({params:r([s]).trim()})}),t.remove())}});creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-property-rule-prelude-list/package.json b/plugins/postcss-property-rule-prelude-list/package.json index 34fa9c2f0..44ab63b3c 100644 --- a/plugins/postcss-property-rule-prelude-list/package.json +++ b/plugins/postcss-property-rule-prelude-list/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-property-rule-prelude-list/src/index.ts b/plugins/postcss-property-rule-prelude-list/src/index.ts index 4ce1a3b87..2c542e134 100644 --- a/plugins/postcss-property-rule-prelude-list/src/index.ts +++ b/plugins/postcss-property-rule-prelude-list/src/index.ts @@ -39,3 +39,4 @@ const creator: PluginCreator = () => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-pseudo-class-any-link/CHANGELOG.md b/plugins/postcss-pseudo-class-any-link/CHANGELOG.md index c5590e66d..1f144c783 100644 --- a/plugins/postcss-pseudo-class-any-link/CHANGELOG.md +++ b/plugins/postcss-pseudo-class-any-link/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Pseudo Class Any Link +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 10.0.1 _October 23, 2024_ diff --git a/plugins/postcss-pseudo-class-any-link/dist/index.cjs b/plugins/postcss-pseudo-class-any-link/dist/index.cjs deleted file mode 100644 index dba5f95dd..000000000 --- a/plugins/postcss-pseudo-class-any-link/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser");const t=e().astSync(":link").nodes[0],s=e().astSync(":visited").nodes[0],n=e().astSync("area[href]").nodes[0],o=e().astSync("[href]").nodes[0];function replaceAnyLink(e,t,s,n){const o=[],r=[];try{for(let t=0;t{const r=[];if(e.walkPseudos(e=>{if(":not"===e.value.toLowerCase())return!1;if(":any-link"!==e.value.toLowerCase()||e.nodes&&e.nodes.length)return;if(!l)return void r.push([t.clone(),s.clone()]);const c=getTagElementsNextToPseudo(e);c.includes("area")?r.push([t.clone(),s.clone(),o.clone()]):c.length?r.push([t.clone(),s.clone()]):r.push([t.clone(),s.clone(),n.clone()])}),!r.length)return;cartesianProduct(...r).forEach(t=>{const s=e.clone();s.walkPseudos(e=>{":any-link"!==e.value.toLowerCase()||e.nodes&&e.nodes.length||(insertNode(e.parent,e,t.shift()),e.remove())}),c.push(s.toString())})}).processSync(r),c}function cartesianProduct(...e){const t=[],s=e.length-1;return function helper(n,o){for(let r=0,l=e[o].length;r=0&&("combinator"!==t.nodes[s].type&&!e.isPseudoElement(t.nodes[s].type));s--)r=s;if("tag"!==o){for(let s=c;s{const t={preserve:e?.preserve??!0,subFeatures:{areaHrefNeedsFixing:e?.subFeatures?.areaHrefNeedsFixing??!1}};return{postcssPlugin:"postcss-pseudo-class-any-link",prepare(){const e=new WeakSet;return{postcssPlugin:"postcss-pseudo-class-any-link",Rule(s,{result:n}){if(!s.selector.toLowerCase().includes(":any-link"))return;if(e.has(s))return;if((s.raws.selector&&s.raws.selector.raw||s.selector).endsWith(":"))return;replaceAnyLink(s,n,t.preserve,t.subFeatures.areaHrefNeedsFixing)&&e.add(s)}}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-pseudo-class-any-link/dist/index.d.ts b/plugins/postcss-pseudo-class-any-link/dist/index.d.ts index e59a9a2ce..9227b5511 100644 --- a/plugins/postcss-pseudo-class-any-link/dist/index.d.ts +++ b/plugins/postcss-pseudo-class-any-link/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-pseudo-class-any-link plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-pseudo-class-any-link/dist/index.mjs b/plugins/postcss-pseudo-class-any-link/dist/index.mjs index be194f62e..b4e8b6829 100644 --- a/plugins/postcss-pseudo-class-any-link/dist/index.mjs +++ b/plugins/postcss-pseudo-class-any-link/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";const t=e().astSync(":link").nodes[0],s=e().astSync(":visited").nodes[0],n=e().astSync("area[href]").nodes[0],o=e().astSync("[href]").nodes[0];function replaceAnyLink(e,t,s,n){const o=[],r=[];try{for(let t=0;t{const r=[];if(e.walkPseudos(e=>{if(":not"===e.value.toLowerCase())return!1;if(":any-link"!==e.value.toLowerCase()||e.nodes&&e.nodes.length)return;if(!l)return void r.push([t.clone(),s.clone()]);const c=getTagElementsNextToPseudo(e);c.includes("area")?r.push([t.clone(),s.clone(),o.clone()]):c.length?r.push([t.clone(),s.clone()]):r.push([t.clone(),s.clone(),n.clone()])}),!r.length)return;cartesianProduct(...r).forEach(t=>{const s=e.clone();s.walkPseudos(e=>{":any-link"!==e.value.toLowerCase()||e.nodes&&e.nodes.length||(insertNode(e.parent,e,t.shift()),e.remove())}),c.push(s.toString())})}).processSync(r),c}function cartesianProduct(...e){const t=[],s=e.length-1;return function helper(n,o){for(let r=0,l=e[o].length;r=0&&("combinator"!==t.nodes[s].type&&!e.isPseudoElement(t.nodes[s].type));s--)r=s;if("tag"!==o){for(let s=c;s{const t={preserve:e?.preserve??!0,subFeatures:{areaHrefNeedsFixing:e?.subFeatures?.areaHrefNeedsFixing??!1}};return{postcssPlugin:"postcss-pseudo-class-any-link",prepare(){const e=new WeakSet;return{postcssPlugin:"postcss-pseudo-class-any-link",Rule(s,{result:n}){if(!s.selector.toLowerCase().includes(":any-link"))return;if(e.has(s))return;if((s.raws.selector&&s.raws.selector.raw||s.selector).endsWith(":"))return;replaceAnyLink(s,n,t.preserve,t.subFeatures.areaHrefNeedsFixing)&&e.add(s)}}}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-selector-parser";const t=e().astSync(":link").nodes[0],s=e().astSync(":visited").nodes[0],n=e().astSync("area[href]").nodes[0],o=e().astSync("[href]").nodes[0];function replaceAnyLink(e,t,s,n){const o=[],r=[];try{for(let t=0;t{const r=[];if(e.walkPseudos(e=>{if(":not"===e.value.toLowerCase())return!1;if(":any-link"!==e.value.toLowerCase()||e.nodes&&e.nodes.length)return;if(!l)return void r.push([t.clone(),s.clone()]);const c=getTagElementsNextToPseudo(e);c.includes("area")?r.push([t.clone(),s.clone(),o.clone()]):c.length?r.push([t.clone(),s.clone()]):r.push([t.clone(),s.clone(),n.clone()])}),!r.length)return;cartesianProduct(...r).forEach(t=>{const s=e.clone();s.walkPseudos(e=>{":any-link"!==e.value.toLowerCase()||e.nodes&&e.nodes.length||(insertNode(e.parent,e,t.shift()),e.remove())}),c.push(s.toString())})}).processSync(r),c}function cartesianProduct(...e){const t=[],s=e.length-1;return function helper(n,o){for(let r=0,l=e[o].length;r=0&&("combinator"!==t.nodes[s].type&&!e.isPseudoElement(t.nodes[s].type));s--)r=s;if("tag"!==o){for(let s=c;s{const t={preserve:e?.preserve??!0,subFeatures:{areaHrefNeedsFixing:e?.subFeatures?.areaHrefNeedsFixing??!1}};return{postcssPlugin:"postcss-pseudo-class-any-link",prepare(){const e=new WeakSet;return{postcssPlugin:"postcss-pseudo-class-any-link",Rule(s,{result:n}){if(!s.selector.toLowerCase().includes(":any-link"))return;if(e.has(s))return;if((s.raws.selector&&s.raws.selector.raw||s.selector).endsWith(":"))return;replaceAnyLink(s,n,t.preserve,t.subFeatures.areaHrefNeedsFixing)&&e.add(s)}}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-pseudo-class-any-link/package.json b/plugins/postcss-pseudo-class-any-link/package.json index 843678520..cc025e60e 100644 --- a/plugins/postcss-pseudo-class-any-link/package.json +++ b/plugins/postcss-pseudo-class-any-link/package.json @@ -29,20 +29,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-pseudo-class-any-link/src/index.ts b/plugins/postcss-pseudo-class-any-link/src/index.ts index 92009582d..51f90ce71 100644 --- a/plugins/postcss-pseudo-class-any-link/src/index.ts +++ b/plugins/postcss-pseudo-class-any-link/src/index.ts @@ -55,3 +55,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-random-function/CHANGELOG.md b/plugins/postcss-random-function/CHANGELOG.md index 28a38f13e..80013efce 100644 --- a/plugins/postcss-random-function/CHANGELOG.md +++ b/plugins/postcss-random-function/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Random Function +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.1 _May 27, 2025_ diff --git a/plugins/postcss-random-function/dist/index.cjs b/plugins/postcss-random-function/dist/index.cjs deleted file mode 100644 index a0d2f50ed..000000000 --- a/plugins/postcss-random-function/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-calc");const r=String.fromCodePoint(0);function randomCacheKeyFromPostcssDeclaration(e){let o="",s=e.parent;for(;s;){switch(s.type){case"rule":o+=r+"selector"+r+s.selector+r;break;case"atrule":"scope"===s.name&&(o+=r+"prelude"+r+s.params+r)}s=s.parent}return{propertyName:e.prop,propertyN:0,elementID:o,documentID:e.source?.input.css??e.root().toString()}}const o=/(?{const s=Object.assign({preserve:!1},r);return{postcssPlugin:"postcss-random-function",Declaration(r){if(!o.test(r.value))return;const t=e.calc(r.value,{precision:5,toCanonicalUnits:!0,randomCaching:randomCacheKeyFromPostcssDeclaration(r)});t!==r.value&&(r.cloneBefore({value:t}),s.preserve||r.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-random-function/dist/index.d.ts b/plugins/postcss-random-function/dist/index.d.ts index 956e42f1e..ec95f97ff 100644 --- a/plugins/postcss-random-function/dist/index.d.ts +++ b/plugins/postcss-random-function/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-random-function plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-random-function/dist/index.mjs b/plugins/postcss-random-function/dist/index.mjs index b99ecce64..783390fa0 100644 --- a/plugins/postcss-random-function/dist/index.mjs +++ b/plugins/postcss-random-function/dist/index.mjs @@ -1 +1 @@ -import{calc as e}from"@csstools/css-calc";const o=String.fromCodePoint(0);function randomCacheKeyFromPostcssDeclaration(e){let r="",t=e.parent;for(;t;){switch(t.type){case"rule":r+=o+"selector"+o+t.selector+o;break;case"atrule":"scope"===t.name&&(r+=o+"prelude"+o+t.params+o)}t=t.parent}return{propertyName:e.prop,propertyN:0,elementID:r,documentID:e.source?.input.css??e.root().toString()}}const r=/(?{const t=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-random-function",Declaration(o){if(!r.test(o.value))return;const s=e(o.value,{precision:5,toCanonicalUnits:!0,randomCaching:randomCacheKeyFromPostcssDeclaration(o)});s!==o.value&&(o.cloneBefore({value:s}),t.preserve||o.remove())}}};creator.postcss=!0;export{creator as default}; +import{calc as e}from"@csstools/css-calc";const o=String.fromCodePoint(0);function randomCacheKeyFromPostcssDeclaration(e){let r="",t=e.parent;for(;t;){switch(t.type){case"rule":r+=o+"selector"+o+t.selector+o;break;case"atrule":"scope"===t.name&&(r+=o+"prelude"+o+t.params+o)}t=t.parent}return{propertyName:e.prop,propertyN:0,elementID:r,documentID:e.source?.input.css??e.root().toString()}}const r=/(?{const t=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-random-function",Declaration(o){if(!r.test(o.value))return;const s=e(o.value,{precision:5,toCanonicalUnits:!0,randomCaching:randomCacheKeyFromPostcssDeclaration(o)});s!==o.value&&(o.cloneBefore({value:s}),t.preserve||o.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-random-function/package.json b/plugins/postcss-random-function/package.json index 06a610983..d14799af2 100644 --- a/plugins/postcss-random-function/package.json +++ b/plugins/postcss-random-function/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-random-function/src/index.ts b/plugins/postcss-random-function/src/index.ts index 48f04b69c..c0acf210a 100644 --- a/plugins/postcss-random-function/src/index.ts +++ b/plugins/postcss-random-function/src/index.ts @@ -48,3 +48,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-rebase-url/CHANGELOG.md b/plugins/postcss-rebase-url/CHANGELOG.md index 775f7937b..19e5ef494 100644 --- a/plugins/postcss-rebase-url/CHANGELOG.md +++ b/plugins/postcss-rebase-url/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Rebase URL +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.5 _May 27, 2025_ diff --git a/plugins/postcss-rebase-url/dist/index.cjs b/plugins/postcss-rebase-url/dist/index.cjs deleted file mode 100644 index cf72c0ae3..000000000 --- a/plugins/postcss-rebase-url/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-tokenizer"),r=require("@csstools/css-parser-algorithms"),t=require("node:path");const s=/^([-_a-z0-9]+:)?\/\//i;function rebase(e,r,i){if(e.startsWith("data:"))return!1;if(s.test(e))return!1;if(e.startsWith("/"))return e;if(e.startsWith("#"))return e;try{const r=new URL(e);if(r.port||r.protocol)return!1}catch{}const o=t.posix.resolve(t.posix.join(r,e));return t.posix.relative(i,o)}function serializeString(e){let r="";for(const t of e){const e=t.codePointAt(0);if(void 0!==e)switch(e){case 0:r+=String.fromCodePoint(65533);break;case 127:r+=`\\${e.toString(16)}`;break;case 34:case 39:case 92:r+=`\\${t}`;break;default:if(1<=e&&e<=31){r+=`\\${e.toString(16)} `;break}r+=t}else r+=String.fromCodePoint(65533)}return r}function normalizedDir(e){return t.parse(t.resolve(e.trim())).dir.split(t.sep).join(t.posix.sep)}const i=/^initial-value$/i,o=/^property$/i,n=/^syntax$/i,a=/url\(/i,u=/^url$/i,l=//i,creator=()=>({postcssPlugin:"postcss-rebase-url",prepare(){const t=new WeakSet,s=new Set;return{postcssPlugin:"postcss-rebase-url",Once(e){e.walkAtRules(o,e=>{if(!e.nodes)return;const r=e.nodes.find(e=>{if("decl"===e.type&&n.test(e.prop))return!0});r&&l.test(r.value)&&s.add(e.params.trim())})},Declaration(n,{result:l}){if(t.has(n))return;if(n.variable&&!s.has(n.prop))return;if(i.test(n.prop)&&"atrule"===n.parent?.type&&o.test(n.parent.name))return;const{from:c}=l.opts;if(!c)return;if(!n.source?.input.from)return;if(!a.test(n.value))return;const p=normalizedDir(c),f=n.source.input.from.trim();if(!f)return;const d=normalizedDir(f),v=r.parseCommaSeparatedListOfComponentValues(e.tokenize({css:n.value})),m=r.replaceComponentValues(v,t=>{if(r.isTokenNode(t)&&e.isTokenURL(t.value)){const e=rebase(t.value[4].value.trim(),d,p);if(e)return t.value[4].value=e,t.value[1]=`url(${serializeString(e)})`,t}if(r.isFunctionNode(t)&&u.test(t.getName()))for(const s of t.value)if(!r.isWhitespaceNode(s)&&!r.isCommentNode(s)&&r.isTokenNode(s)&&e.isTokenString(s.value)){const e=rebase(s.value[4].value.trim(),d,p);if(e)return s.value[4].value=e,s.value[1]=`"${serializeString(e)}"`,t;break}}),g=r.stringify(m);g!==n.value&&(n.value=g,t.add(n))}}}});creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-rebase-url/dist/index.d.ts b/plugins/postcss-rebase-url/dist/index.d.ts index c63d024d3..08dd3f5f4 100644 --- a/plugins/postcss-rebase-url/dist/index.d.ts +++ b/plugins/postcss-rebase-url/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-rebase-url plugin options */ export declare type pluginOptions = never; diff --git a/plugins/postcss-rebase-url/dist/index.mjs b/plugins/postcss-rebase-url/dist/index.mjs index 437ef48d3..7b618689d 100644 --- a/plugins/postcss-rebase-url/dist/index.mjs +++ b/plugins/postcss-rebase-url/dist/index.mjs @@ -1 +1 @@ -import{tokenize as e,isTokenURL as r,isTokenString as t}from"@csstools/css-tokenizer";import{parseCommaSeparatedListOfComponentValues as s,replaceComponentValues as i,isTokenNode as o,isFunctionNode as a,isWhitespaceNode as n,isCommentNode as u,stringify as l}from"@csstools/css-parser-algorithms";import c from"node:path";const f=/^([-_a-z0-9]+:)?\/\//i;function rebase(e,r,t){if(e.startsWith("data:"))return!1;if(f.test(e))return!1;if(e.startsWith("/"))return e;if(e.startsWith("#"))return e;try{const r=new URL(e);if(r.port||r.protocol)return!1}catch{}const s=c.posix.resolve(c.posix.join(r,e));return c.posix.relative(t,s)}function serializeString(e){let r="";for(const t of e){const e=t.codePointAt(0);if(void 0!==e)switch(e){case 0:r+=String.fromCodePoint(65533);break;case 127:r+=`\\${e.toString(16)}`;break;case 34:case 39:case 92:r+=`\\${t}`;break;default:if(1<=e&&e<=31){r+=`\\${e.toString(16)} `;break}r+=t}else r+=String.fromCodePoint(65533)}return r}function normalizedDir(e){return c.parse(c.resolve(e.trim())).dir.split(c.sep).join(c.posix.sep)}const p=/^initial-value$/i,v=/^property$/i,m=/^syntax$/i,d=/url\(/i,b=/^url$/i,g=//i,creator=()=>({postcssPlugin:"postcss-rebase-url",prepare(){const c=new WeakSet,f=new Set;return{postcssPlugin:"postcss-rebase-url",Once(e){e.walkAtRules(v,e=>{if(!e.nodes)return;const r=e.nodes.find(e=>{if("decl"===e.type&&m.test(e.prop))return!0});r&&g.test(r.value)&&f.add(e.params.trim())})},Declaration(m,{result:g}){if(c.has(m))return;if(m.variable&&!f.has(m.prop))return;if(p.test(m.prop)&&"atrule"===m.parent?.type&&v.test(m.parent.name))return;const{from:h}=g.opts;if(!h)return;if(!m.source?.input.from)return;if(!d.test(m.value))return;const S=normalizedDir(h),$=m.source.input.from.trim();if(!$)return;const k=normalizedDir($),z=s(e({css:m.value})),x=i(z,e=>{if(o(e)&&r(e.value)){const r=rebase(e.value[4].value.trim(),k,S);if(r)return e.value[4].value=r,e.value[1]=`url(${serializeString(r)})`,e}if(a(e)&&b.test(e.getName()))for(const r of e.value)if(!n(r)&&!u(r)&&o(r)&&t(r.value)){const t=rebase(r.value[4].value.trim(),k,S);if(t)return r.value[4].value=t,r.value[1]=`"${serializeString(t)}"`,e;break}}),w=l(x);w!==m.value&&(m.value=w,c.add(m))}}}});creator.postcss=!0;export{creator as default}; +import{tokenize as e,isTokenURL as r,isTokenString as t}from"@csstools/css-tokenizer";import{parseCommaSeparatedListOfComponentValues as s,replaceComponentValues as i,isTokenNode as o,isFunctionNode as a,isWhitespaceNode as n,isCommentNode as u,stringify as l}from"@csstools/css-parser-algorithms";import c from"node:path";const p=/^([-_a-z0-9]+:)?\/\//i;function rebase(e,r,t){if(e.startsWith("data:"))return!1;if(p.test(e))return!1;if(e.startsWith("/"))return e;if(e.startsWith("#"))return e;try{const r=new URL(e);if(r.port||r.protocol)return!1}catch{}const s=c.posix.resolve(c.posix.join(r,e));return c.posix.relative(t,s)}function serializeString(e){let r="";for(const t of e){const e=t.codePointAt(0);if(void 0!==e)switch(e){case 0:r+=String.fromCodePoint(65533);break;case 127:r+=`\\${e.toString(16)}`;break;case 34:case 39:case 92:r+=`\\${t}`;break;default:if(1<=e&&e<=31){r+=`\\${e.toString(16)} `;break}r+=t}else r+=String.fromCodePoint(65533)}return r}function normalizedDir(e){return c.parse(c.resolve(e.trim())).dir.split(c.sep).join(c.posix.sep)}const f=/^initial-value$/i,m=/^property$/i,v=/^syntax$/i,d=/url\(/i,b=/^url$/i,g=//i,creator=()=>({postcssPlugin:"postcss-rebase-url",prepare(){const c=new WeakSet,p=new Set;return{postcssPlugin:"postcss-rebase-url",Once(e){e.walkAtRules(m,e=>{if(!e.nodes)return;const r=e.nodes.find(e=>{if("decl"===e.type&&v.test(e.prop))return!0});r&&g.test(r.value)&&p.add(e.params.trim())})},Declaration(v,{result:g}){if(c.has(v))return;if(v.variable&&!p.has(v.prop))return;if(f.test(v.prop)&&"atrule"===v.parent?.type&&m.test(v.parent.name))return;const{from:h}=g.opts;if(!h)return;if(!v.source?.input.from)return;if(!d.test(v.value))return;const S=normalizedDir(h),$=v.source.input.from.trim();if(!$)return;const k=normalizedDir($),z=s(e({css:v.value})),x=i(z,e=>{if(o(e)&&r(e.value)){const r=rebase(e.value[4].value.trim(),k,S);if(r)return e.value[4].value=r,e.value[1]=`url(${serializeString(r)})`,e}if(a(e)&&b.test(e.getName()))for(const r of e.value)if(!n(r)&&!u(r)&&o(r)&&t(r.value)){const t=rebase(r.value[4].value.trim(),k,S);if(t)return r.value[4].value=t,r.value[1]=`"${serializeString(t)}"`,e;break}}),w=l(x);w!==v.value&&(v.value=w,c.add(v))}}}});creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-rebase-url/package.json b/plugins/postcss-rebase-url/package.json index fb977be78..fe157d2e1 100644 --- a/plugins/postcss-rebase-url/package.json +++ b/plugins/postcss-rebase-url/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-rebase-url/src/index.ts b/plugins/postcss-rebase-url/src/index.ts index 6c4342c4e..27dc05960 100644 --- a/plugins/postcss-rebase-url/src/index.ts +++ b/plugins/postcss-rebase-url/src/index.ts @@ -142,3 +142,4 @@ const creator: PluginCreator = () => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-relative-color-syntax/CHANGELOG.md b/plugins/postcss-relative-color-syntax/CHANGELOG.md index 962a9e85e..043ef14cb 100644 --- a/plugins/postcss-relative-color-syntax/CHANGELOG.md +++ b/plugins/postcss-relative-color-syntax/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Relative Color Syntax +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.0.12 _September 21, 2025_ diff --git a/plugins/postcss-relative-color-syntax/dist/index.cjs b/plugins/postcss-relative-color-syntax/dist/index.cjs deleted file mode 100644 index f977601dc..000000000 --- a/plugins/postcss-relative-color-syntax/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/css-color-parser"),a=require("@csstools/utilities"),r=require("@csstools/css-parser-algorithms"),t=require("@csstools/css-tokenizer");const o=/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklch|oklab|color)\(/i,l=/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklch|oklab|color)\(\s*from/i,i=/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklch|oklab|color)$/i,n=/from/i,basePlugin=s=>({postcssPlugin:"postcss-relative-color-syntax",Declaration(c){const u=c.value;if(!o.test(u)||!n.test(u))return;if(a.hasFallback(c))return;if(a.hasSupportsAtRuleAncestor(c,l))return;const p=t.tokenize({css:u}),g=r.replaceComponentValues(r.parseCommaSeparatedListOfComponentValues(p),s=>{if(!r.isFunctionNode(s)||!i.test(s.getName()))return;const a=e.color(s);return a&&!a.syntaxFlags.has(e.SyntaxFlag.Experimental)&&!a.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords)&&a.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax)?e.serializeRGB(a):void 0}),b=r.stringify(g);if(b===u)return;let y=b;s?.subFeatures.displayP3&&(y=r.stringify(r.replaceComponentValues(r.parseCommaSeparatedListOfComponentValues(p),s=>{if(!r.isFunctionNode(s)||!i.test(s.getName()))return;const a=e.color(s);return a&&!a.syntaxFlags.has(e.SyntaxFlag.Experimental)&&!a.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords)&&a.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax)?e.colorDataFitsRGB_Gamut(a)?e.serializeRGB(a):e.serializeP3(a):void 0}))),c.cloneBefore({value:b}),s?.subFeatures.displayP3&&y!==b&&c.cloneBefore({value:y}),s?.preserve||c.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const a=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return a.subFeatures=Object.assign({displayP3:!0},a.subFeatures),a.enableProgressiveCustomProperties&&(a.preserve||a.subFeatures.displayP3)?{postcssPlugin:"postcss-relative-color-syntax",plugins:[s(),basePlugin(a)]}:basePlugin(a)};postcssPlugin.postcss=!0,module.exports=postcssPlugin; diff --git a/plugins/postcss-relative-color-syntax/dist/index.d.ts b/plugins/postcss-relative-color-syntax/dist/index.d.ts index 2e42806a2..82a9da44a 100644 --- a/plugins/postcss-relative-color-syntax/dist/index.d.ts +++ b/plugins/postcss-relative-color-syntax/dist/index.d.ts @@ -16,5 +16,6 @@ export declare type pluginOptions = { /** Transform relative color syntax in CSS. */ declare const postcssPlugin: PluginCreator; export default postcssPlugin; +export { postcssPlugin as 'module.exports' } export { } diff --git a/plugins/postcss-relative-color-syntax/dist/index.mjs b/plugins/postcss-relative-color-syntax/dist/index.mjs index 5215fc021..27683ddbe 100644 --- a/plugins/postcss-relative-color-syntax/dist/index.mjs +++ b/plugins/postcss-relative-color-syntax/dist/index.mjs @@ -1 +1 @@ -import s from"@csstools/postcss-progressive-custom-properties";import{color as e,SyntaxFlag as r,serializeRGB as o,colorDataFitsRGB_Gamut as t,serializeP3 as a}from"@csstools/css-color-parser";import{hasFallback as l,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as c,parseCommaSeparatedListOfComponentValues as n,isFunctionNode as u,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as b}from"@csstools/css-tokenizer";const g=/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklch|oklab|color)\(/i,h=/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklch|oklab|color)\(\s*from/i,m=/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklch|oklab|color)$/i,y=/from/i,basePlugin=s=>({postcssPlugin:"postcss-relative-color-syntax",Declaration(f){const v=f.value;if(!g.test(v)||!y.test(v))return;if(l(f))return;if(i(f,h))return;const x=b({css:v}),F=c(n(x),s=>{if(!u(s)||!m.test(s.getName()))return;const t=e(s);return t&&!t.syntaxFlags.has(r.Experimental)&&!t.syntaxFlags.has(r.HasNoneKeywords)&&t.syntaxFlags.has(r.RelativeColorSyntax)?o(t):void 0}),P=p(F);if(P===v)return;let d=P;s?.subFeatures.displayP3&&(d=p(c(n(x),s=>{if(!u(s)||!m.test(s.getName()))return;const l=e(s);return l&&!l.syntaxFlags.has(r.Experimental)&&!l.syntaxFlags.has(r.HasNoneKeywords)&&l.syntaxFlags.has(r.RelativeColorSyntax)?t(l)?o(l):a(l):void 0}))),f.cloneBefore({value:P}),s?.subFeatures.displayP3&&d!==P&&f.cloneBefore({value:d}),s?.preserve||f.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-relative-color-syntax",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default}; +import s from"@csstools/postcss-progressive-custom-properties";import{color as e,SyntaxFlag as r,serializeRGB as o,colorDataFitsRGB_Gamut as t,serializeP3 as a}from"@csstools/css-color-parser";import{hasFallback as l,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as c,parseCommaSeparatedListOfComponentValues as n,isFunctionNode as u,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as b}from"@csstools/css-tokenizer";const g=/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklch|oklab|color)\(/i,h=/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklch|oklab|color)\(\s*from/i,m=/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklch|oklab|color)$/i,y=/from/i,basePlugin=s=>({postcssPlugin:"postcss-relative-color-syntax",Declaration(f){const v=f.value;if(!g.test(v)||!y.test(v))return;if(l(f))return;if(i(f,h))return;const x=b({css:v}),F=c(n(x),s=>{if(!u(s)||!m.test(s.getName()))return;const t=e(s);return t&&!t.syntaxFlags.has(r.Experimental)&&!t.syntaxFlags.has(r.HasNoneKeywords)&&t.syntaxFlags.has(r.RelativeColorSyntax)?o(t):void 0}),d=p(F);if(d===v)return;let P=d;s?.subFeatures.displayP3&&(P=p(c(n(x),s=>{if(!u(s)||!m.test(s.getName()))return;const l=e(s);return l&&!l.syntaxFlags.has(r.Experimental)&&!l.syntaxFlags.has(r.HasNoneKeywords)&&l.syntaxFlags.has(r.RelativeColorSyntax)?t(l)?o(l):a(l):void 0}))),f.cloneBefore({value:d}),s?.subFeatures.displayP3&&P!==d&&f.cloneBefore({value:P}),s?.preserve||f.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-relative-color-syntax",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"}; diff --git a/plugins/postcss-relative-color-syntax/package.json b/plugins/postcss-relative-color-syntax/package.json index f7ecb9f96..41d693671 100644 --- a/plugins/postcss-relative-color-syntax/package.json +++ b/plugins/postcss-relative-color-syntax/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-relative-color-syntax/src/index.ts b/plugins/postcss-relative-color-syntax/src/index.ts index 88ec9843f..e0a4d2ff4 100644 --- a/plugins/postcss-relative-color-syntax/src/index.ts +++ b/plugins/postcss-relative-color-syntax/src/index.ts @@ -155,3 +155,4 @@ const postcssPlugin: PluginCreator = (opts?: pluginOptions) => { postcssPlugin.postcss = true; export default postcssPlugin; +export { postcssPlugin as 'module.exports' }; diff --git a/plugins/postcss-rewrite-url/CHANGELOG.md b/plugins/postcss-rewrite-url/CHANGELOG.md index 54bcfb87f..4e1af41f2 100644 --- a/plugins/postcss-rewrite-url/CHANGELOG.md +++ b/plugins/postcss-rewrite-url/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Rewrite URL +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.1.1 _May 27, 2025_ diff --git a/plugins/postcss-rewrite-url/dist/index.cjs b/plugins/postcss-rewrite-url/dist/index.cjs deleted file mode 100644 index 97ec2db4b..000000000 --- a/plugins/postcss-rewrite-url/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-tokenizer"),r=require("@csstools/css-parser-algorithms");function serializeString(e){let r="";for(const t of e){const e=t.codePointAt(0);if(void 0!==e)switch(e){case 0:r+=String.fromCodePoint(65533);break;case 127:r+=`\\${e.toString(16)}`;break;case 34:case 39:case 92:r+=`\\${t}`;break;default:if(1<=e&&e<=31){r+=`\\${e.toString(16)} `;break}r+=t}else r+=String.fromCodePoint(65533)}return r}const t=/rewrite-url\(/i,o=/^rewrite-url$/i,creator=e=>{const r=e?.rewriter??(e=>e);return{postcssPlugin:"postcss-rewrite-url",Once(e,{result:t}){e.walkDecls(e=>{rewriteDeclaration(e,t,r)}),e.walkAtRules(e=>{rewriteAtRule(e,t,r)})},Declaration(e,{result:t}){rewriteDeclaration(e,t,r)},AtRule(e,{result:t}){rewriteAtRule(e,t,r)}}};function rewriteDeclaration(e,r,o){if(!t.test(e.value))return;const s={type:"declaration-value",rootFrom:r.opts.from,from:e.source?.input.from,property:e.prop},i=rewrite(o,e.value,s);i!==e.value&&(e.value=i)}function rewriteAtRule(e,r,o){if(!t.test(e.params))return;const s={type:"at-rule-prelude",rootFrom:r.opts.from,from:e.source?.input.from,atRuleName:e.name},i=rewrite(o,e.params,s);i!==e.params&&(e.params=i)}function rewrite(t,s,i){const n=r.parseCommaSeparatedListOfComponentValues(e.tokenize({css:s})),a=r.replaceComponentValues(n,s=>{if(!r.isFunctionNode(s)||!o.test(s.getName()))return;const n=s.value.filter(e=>!r.isWhiteSpaceOrCommentNode(e));for(let o=0;oe.toString())},i);if(!1===c)return;const m=r.parseListOfComponentValues(e.tokenize({css:[`"${serializeString(c.url)}"`,...c.urlModifiers??l].join(" ")}));return s.value=m,s.name[1]="url(",s.name[4].value="url",s}return}});return r.stringify(a)}creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-rewrite-url/dist/index.d.ts b/plugins/postcss-rewrite-url/dist/index.d.ts index 0335102c3..aa94b46d3 100644 --- a/plugins/postcss-rewrite-url/dist/index.d.ts +++ b/plugins/postcss-rewrite-url/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-rewrite-url plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-rewrite-url/dist/index.mjs b/plugins/postcss-rewrite-url/dist/index.mjs index 511ebf89a..4c716de36 100644 --- a/plugins/postcss-rewrite-url/dist/index.mjs +++ b/plugins/postcss-rewrite-url/dist/index.mjs @@ -1 +1 @@ -import{tokenize as r,isTokenString as e}from"@csstools/css-tokenizer";import{parseCommaSeparatedListOfComponentValues as t,replaceComponentValues as o,isFunctionNode as s,isWhiteSpaceOrCommentNode as i,isTokenNode as a,parseListOfComponentValues as l,stringify as n}from"@csstools/css-parser-algorithms";function serializeString(r){let e="";for(const t of r){const r=t.codePointAt(0);if(void 0!==r)switch(r){case 0:e+=String.fromCodePoint(65533);break;case 127:e+=`\\${r.toString(16)}`;break;case 34:case 39:case 92:e+=`\\${t}`;break;default:if(1<=r&&r<=31){e+=`\\${r.toString(16)} `;break}e+=t}else e+=String.fromCodePoint(65533)}return e}const u=/rewrite-url\(/i,c=/^rewrite-url$/i,creator=r=>{const e=r?.rewriter??(r=>r);return{postcssPlugin:"postcss-rewrite-url",Once(r,{result:t}){r.walkDecls(r=>{rewriteDeclaration(r,t,e)}),r.walkAtRules(r=>{rewriteAtRule(r,t,e)})},Declaration(r,{result:t}){rewriteDeclaration(r,t,e)},AtRule(r,{result:t}){rewriteAtRule(r,t,e)}}};function rewriteDeclaration(r,e,t){if(!u.test(r.value))return;const o={type:"declaration-value",rootFrom:e.opts.from,from:r.source?.input.from,property:r.prop},s=rewrite(t,r.value,o);s!==r.value&&(r.value=s)}function rewriteAtRule(r,e,t){if(!u.test(r.params))return;const o={type:"at-rule-prelude",rootFrom:e.opts.from,from:r.source?.input.from,atRuleName:r.name},s=rewrite(t,r.params,o);s!==r.params&&(r.params=s)}function rewrite(u,f,m){const p=t(r({css:f})),w=o(p,t=>{if(!s(t)||!c.test(t.getName()))return;const o=t.value.filter(r=>!i(r));for(let s=0;sr.toString())},m);if(!1===n)return;const c=l(r({css:[`"${serializeString(n.url)}"`,...n.urlModifiers??a].join(" ")}));return t.value=c,t.name[1]="url(",t.name[4].value="url",t}return}});return n(w)}creator.postcss=!0;export{creator as default}; +import{tokenize as r,isTokenString as e}from"@csstools/css-tokenizer";import{parseCommaSeparatedListOfComponentValues as t,replaceComponentValues as o,isFunctionNode as s,isWhiteSpaceOrCommentNode as i,isTokenNode as a,parseListOfComponentValues as l,stringify as n}from"@csstools/css-parser-algorithms";function serializeString(r){let e="";for(const t of r){const r=t.codePointAt(0);if(void 0!==r)switch(r){case 0:e+=String.fromCodePoint(65533);break;case 127:e+=`\\${r.toString(16)}`;break;case 34:case 39:case 92:e+=`\\${t}`;break;default:if(1<=r&&r<=31){e+=`\\${r.toString(16)} `;break}e+=t}else e+=String.fromCodePoint(65533)}return e}const u=/rewrite-url\(/i,c=/^rewrite-url$/i,creator=r=>{const e=r?.rewriter??(r=>r);return{postcssPlugin:"postcss-rewrite-url",Once(r,{result:t}){r.walkDecls(r=>{rewriteDeclaration(r,t,e)}),r.walkAtRules(r=>{rewriteAtRule(r,t,e)})},Declaration(r,{result:t}){rewriteDeclaration(r,t,e)},AtRule(r,{result:t}){rewriteAtRule(r,t,e)}}};function rewriteDeclaration(r,e,t){if(!u.test(r.value))return;const o={type:"declaration-value",rootFrom:e.opts.from,from:r.source?.input.from,property:r.prop},s=rewrite(t,r.value,o);s!==r.value&&(r.value=s)}function rewriteAtRule(r,e,t){if(!u.test(r.params))return;const o={type:"at-rule-prelude",rootFrom:e.opts.from,from:r.source?.input.from,atRuleName:r.name},s=rewrite(t,r.params,o);s!==r.params&&(r.params=s)}function rewrite(u,f,m){const p=t(r({css:f})),w=o(p,t=>{if(!s(t)||!c.test(t.getName()))return;const o=t.value.filter(r=>!i(r));for(let s=0;sr.toString())},m);if(!1===n)return;const c=l(r({css:[`"${serializeString(n.url)}"`,...n.urlModifiers??a].join(" ")}));return t.value=c,t.name[1]="url(",t.name[4].value="url",t}return}});return n(w)}creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-rewrite-url/package.json b/plugins/postcss-rewrite-url/package.json index e0e565c79..6313cc2b7 100644 --- a/plugins/postcss-rewrite-url/package.json +++ b/plugins/postcss-rewrite-url/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-rewrite-url/src/index.ts b/plugins/postcss-rewrite-url/src/index.ts index 521eb2b34..11ceed683 100644 --- a/plugins/postcss-rewrite-url/src/index.ts +++ b/plugins/postcss-rewrite-url/src/index.ts @@ -54,6 +54,7 @@ const creator: PluginCreator = (options?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; function rewriteDeclaration(decl: Declaration, result: Result, rewriter: Rewriter): void { if(!URL_FUNCTION_CALL_REGEX.test(decl.value)) { diff --git a/plugins/postcss-scope-pseudo-class/CHANGELOG.md b/plugins/postcss-scope-pseudo-class/CHANGELOG.md index 0a87336dc..ed7cca6b2 100644 --- a/plugins/postcss-scope-pseudo-class/CHANGELOG.md +++ b/plugins/postcss-scope-pseudo-class/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Scope Pseudo Class +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.1 _October 23, 2024_ diff --git a/plugins/postcss-scope-pseudo-class/dist/index.cjs b/plugins/postcss-scope-pseudo-class/dist/index.cjs deleted file mode 100644 index 6058728d8..000000000 --- a/plugins/postcss-scope-pseudo-class/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser");const creator=s=>{const r=Object.assign({preserve:!1},s);return{postcssPlugin:"postcss-scope-pseudo-class",prepare(){const s=new WeakSet;return{postcssPlugin:"postcss-scope-pseudo-class",Rule(t,{result:o}){if(!t.selector.toLowerCase().includes(":scope"))return;if(s.has(t))return;{let e=t.parent;for(;e;){if("atrule"===e.type&&"scope"===e.name.toLowerCase())return;e=e.parent}}let c=t.selector;try{const s=e().astSync(c);if(!s)return;s.walkPseudos(e=>{if(":has"===e.value.toLowerCase())return!1;":scope"===e.value.toLowerCase()&&(e.value=":root")}),c=s.toString()}catch(e){t.warn(o,`Failed to parse selector : "${t.selector}" with message: "${e instanceof Error?e.message:e}"`)}c!==t.selector&&(s.add(t),t.cloneBefore({selector:c}),r.preserve||t.remove())}}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-scope-pseudo-class/dist/index.d.ts b/plugins/postcss-scope-pseudo-class/dist/index.d.ts index 69020b0f4..37c3190e5 100644 --- a/plugins/postcss-scope-pseudo-class/dist/index.d.ts +++ b/plugins/postcss-scope-pseudo-class/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-scope-pseudo-class plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-scope-pseudo-class/dist/index.mjs b/plugins/postcss-scope-pseudo-class/dist/index.mjs index b1a4d2e4c..e4708b8f6 100644 --- a/plugins/postcss-scope-pseudo-class/dist/index.mjs +++ b/plugins/postcss-scope-pseudo-class/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";const creator=s=>{const r=Object.assign({preserve:!1},s);return{postcssPlugin:"postcss-scope-pseudo-class",prepare(){const s=new WeakSet;return{postcssPlugin:"postcss-scope-pseudo-class",Rule(t,{result:o}){if(!t.selector.toLowerCase().includes(":scope"))return;if(s.has(t))return;{let e=t.parent;for(;e;){if("atrule"===e.type&&"scope"===e.name.toLowerCase())return;e=e.parent}}let a=t.selector;try{const s=e().astSync(a);if(!s)return;s.walkPseudos(e=>{if(":has"===e.value.toLowerCase())return!1;":scope"===e.value.toLowerCase()&&(e.value=":root")}),a=s.toString()}catch(e){t.warn(o,`Failed to parse selector : "${t.selector}" with message: "${e instanceof Error?e.message:e}"`)}a!==t.selector&&(s.add(t),t.cloneBefore({selector:a}),r.preserve||t.remove())}}}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-selector-parser";const creator=s=>{const r=Object.assign({preserve:!1},s);return{postcssPlugin:"postcss-scope-pseudo-class",prepare(){const s=new WeakSet;return{postcssPlugin:"postcss-scope-pseudo-class",Rule(t,{result:o}){if(!t.selector.toLowerCase().includes(":scope"))return;if(s.has(t))return;{let e=t.parent;for(;e;){if("atrule"===e.type&&"scope"===e.name.toLowerCase())return;e=e.parent}}let a=t.selector;try{const s=e().astSync(a);if(!s)return;s.walkPseudos(e=>{if(":has"===e.value.toLowerCase())return!1;":scope"===e.value.toLowerCase()&&(e.value=":root")}),a=s.toString()}catch(e){t.warn(o,`Failed to parse selector : "${t.selector}" with message: "${e instanceof Error?e.message:e}"`)}a!==t.selector&&(s.add(t),t.cloneBefore({selector:a}),r.preserve||t.remove())}}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-scope-pseudo-class/package.json b/plugins/postcss-scope-pseudo-class/package.json index 85d0038da..ca30783fb 100644 --- a/plugins/postcss-scope-pseudo-class/package.json +++ b/plugins/postcss-scope-pseudo-class/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-scope-pseudo-class/src/index.ts b/plugins/postcss-scope-pseudo-class/src/index.ts index 73a23d95e..81c521965 100644 --- a/plugins/postcss-scope-pseudo-class/src/index.ts +++ b/plugins/postcss-scope-pseudo-class/src/index.ts @@ -88,4 +88,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-selector-not/CHANGELOG.md b/plugins/postcss-selector-not/CHANGELOG.md index 84a92b788..d049ee57c 100644 --- a/plugins/postcss-selector-not/CHANGELOG.md +++ b/plugins/postcss-selector-not/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Selector Not +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 8.0.1 _October 23, 2024_ diff --git a/plugins/postcss-selector-not/dist/index.cjs b/plugins/postcss-selector-not/dist/index.cjs deleted file mode 100644 index 3ec047cd5..000000000 --- a/plugins/postcss-selector-not/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-selector-parser");function cleanupWhitespace(e){e.spaces&&(e.spaces.after="",e.spaces.before=""),e.nodes&&e.nodes.length>0&&(e.nodes[0]&&e.nodes[0].spaces&&(e.nodes[0].spaces.before=""),e.nodes[e.nodes.length-1]&&e.nodes[e.nodes.length-1].spaces&&(e.nodes[e.nodes.length-1].spaces.after=""))}const creator=()=>({postcssPlugin:"postcss-selector-not",Rule(s,{result:o}){if(s.selector&&s.selector.toLowerCase().includes(":not("))try{const o=e().astSync(s.selector);o.walkPseudos(s=>{if(":not"!==s.value.toLowerCase())return;if(!s.nodes||s.nodes.length<2)return;const o=[];s.nodes.forEach(s=>{cleanupWhitespace(s);const t=e.pseudo({value:":not",nodes:[s]});o.push(t)}),s.replaceWith(...o)});const t=o.toString();t!==s.selector&&s.replaceWith(s.clone({selector:t}))}catch(e){s.warn(o,`Failed to parse selector : "${s.selector}" with message: "${e instanceof Error?e.message:e}"`)}}});creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-selector-not/dist/index.d.ts b/plugins/postcss-selector-not/dist/index.d.ts index 9ecd70532..3adffae1a 100644 --- a/plugins/postcss-selector-not/dist/index.d.ts +++ b/plugins/postcss-selector-not/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-selector-not plugin options */ export declare type pluginOptions = Record; diff --git a/plugins/postcss-selector-not/dist/index.mjs b/plugins/postcss-selector-not/dist/index.mjs index a9ec7db2c..9e595383e 100644 --- a/plugins/postcss-selector-not/dist/index.mjs +++ b/plugins/postcss-selector-not/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";function cleanupWhitespace(e){e.spaces&&(e.spaces.after="",e.spaces.before=""),e.nodes&&e.nodes.length>0&&(e.nodes[0]&&e.nodes[0].spaces&&(e.nodes[0].spaces.before=""),e.nodes[e.nodes.length-1]&&e.nodes[e.nodes.length-1].spaces&&(e.nodes[e.nodes.length-1].spaces.after=""))}const creator=()=>({postcssPlugin:"postcss-selector-not",Rule(s,{result:o}){if(s.selector&&s.selector.toLowerCase().includes(":not("))try{const o=e().astSync(s.selector);o.walkPseudos(s=>{if(":not"!==s.value.toLowerCase())return;if(!s.nodes||s.nodes.length<2)return;const o=[];s.nodes.forEach(s=>{cleanupWhitespace(s);const t=e.pseudo({value:":not",nodes:[s]});o.push(t)}),s.replaceWith(...o)});const t=o.toString();t!==s.selector&&s.replaceWith(s.clone({selector:t}))}catch(e){s.warn(o,`Failed to parse selector : "${s.selector}" with message: "${e instanceof Error?e.message:e}"`)}}});creator.postcss=!0;export{creator as default}; +import e from"postcss-selector-parser";function cleanupWhitespace(e){e.spaces&&(e.spaces.after="",e.spaces.before=""),e.nodes&&e.nodes.length>0&&(e.nodes[0]&&e.nodes[0].spaces&&(e.nodes[0].spaces.before=""),e.nodes[e.nodes.length-1]&&e.nodes[e.nodes.length-1].spaces&&(e.nodes[e.nodes.length-1].spaces.after=""))}const creator=()=>({postcssPlugin:"postcss-selector-not",Rule(s,{result:o}){if(s.selector&&s.selector.toLowerCase().includes(":not("))try{const o=e().astSync(s.selector);o.walkPseudos(s=>{if(":not"!==s.value.toLowerCase())return;if(!s.nodes||s.nodes.length<2)return;const o=[];s.nodes.forEach(s=>{cleanupWhitespace(s);const t=e.pseudo({value:":not",nodes:[s]});o.push(t)}),s.replaceWith(...o)});const t=o.toString();t!==s.selector&&s.replaceWith(s.clone({selector:t}))}catch(e){s.warn(o,`Failed to parse selector : "${s.selector}" with message: "${e instanceof Error?e.message:e}"`)}}});creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-selector-not/package.json b/plugins/postcss-selector-not/package.json index 408be0604..636de2b45 100644 --- a/plugins/postcss-selector-not/package.json +++ b/plugins/postcss-selector-not/package.json @@ -28,20 +28,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-selector-not/src/index.ts b/plugins/postcss-selector-not/src/index.ts index a0983a762..13a4550d5 100644 --- a/plugins/postcss-selector-not/src/index.ts +++ b/plugins/postcss-selector-not/src/index.ts @@ -74,4 +74,5 @@ const creator: PluginCreator = () => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-sign-functions/CHANGELOG.md b/plugins/postcss-sign-functions/CHANGELOG.md index dfc76bb18..439a45db0 100644 --- a/plugins/postcss-sign-functions/CHANGELOG.md +++ b/plugins/postcss-sign-functions/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Sign Functions +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 1.1.4 _May 27, 2025_ diff --git a/plugins/postcss-sign-functions/dist/index.cjs b/plugins/postcss-sign-functions/dist/index.cjs deleted file mode 100644 index 8d2c29b11..000000000 --- a/plugins/postcss-sign-functions/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-calc"),o=require("@csstools/css-tokenizer"),n=require("@csstools/css-parser-algorithms");const s=/(?{const r=Object.assign({preserve:!1},t);return{postcssPlugin:"postcss-sign-functions",Declaration(t){if(!s.test(t.value))return;let i;i=a.test(t.value)?n.replaceComponentValues(n.parseCommaSeparatedListOfComponentValues(o.tokenize({css:t.value})),replacer):n.parseCommaSeparatedListOfComponentValues(o.tokenize({css:t.value}));const p=n.stringify(e.calcFromComponentValues(i,{precision:5,toCanonicalUnits:!0}));p!==t.value&&(t.cloneBefore({value:p}),r.preserve||t.remove())}}};function replacer(e){if(!n.isFunctionNode(e))return;if("abs"!==e.getName().toLowerCase())return;const[s]=n.replaceComponentValues([e.value],replacer);return[new n.FunctionNode([o.TokenType.Function,"max(",-1,-1,{value:"max"}],[o.TokenType.CloseParen,")",-1,-1,void 0],[new n.SimpleBlockNode([o.TokenType.OpenParen,"(",-1,-1,void 0],[o.TokenType.CloseParen,")",-1,-1,void 0],n.parseListOfComponentValues(s.flatMap(e=>e.tokens()))),new n.TokenNode([o.TokenType.Comma,",",-1,-1,void 0]),new n.WhitespaceNode([[o.TokenType.Whitespace," ",-1,-1,void 0]]),new n.TokenNode([o.TokenType.Number,"-1",-1,-1,{value:-1,type:o.NumberType.Integer,signCharacter:"-"}]),new n.WhitespaceNode([[o.TokenType.Whitespace," ",-1,-1,void 0]]),new n.TokenNode([o.TokenType.Delim,"*",-1,-1,{value:"*"}]),new n.WhitespaceNode([[o.TokenType.Whitespace," ",-1,-1,void 0]]),new n.SimpleBlockNode([o.TokenType.OpenParen,"(",-1,-1,void 0],[o.TokenType.CloseParen,")",-1,-1,void 0],n.parseListOfComponentValues(s.flatMap(e=>e.tokens())))])]}creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-sign-functions/dist/index.d.ts b/plugins/postcss-sign-functions/dist/index.d.ts index 220781fa2..f9eebbaf4 100644 --- a/plugins/postcss-sign-functions/dist/index.d.ts +++ b/plugins/postcss-sign-functions/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-sign-functions plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-sign-functions/dist/index.mjs b/plugins/postcss-sign-functions/dist/index.mjs index 91a16e1f0..293543537 100644 --- a/plugins/postcss-sign-functions/dist/index.mjs +++ b/plugins/postcss-sign-functions/dist/index.mjs @@ -1 +1 @@ -import{calcFromComponentValues as e}from"@csstools/css-calc";import{tokenize as s,TokenType as o,NumberType as n}from"@csstools/css-tokenizer";import{replaceComponentValues as t,parseCommaSeparatedListOfComponentValues as a,stringify as r,isFunctionNode as i,FunctionNode as c,SimpleBlockNode as l,TokenNode as p,WhitespaceNode as v,parseListOfComponentValues as u}from"@csstools/css-parser-algorithms";const m=/(?{const n=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-sign-functions",Declaration(o){if(!m.test(o.value))return;let i;i=f.test(o.value)?t(a(s({css:o.value})),replacer):a(s({css:o.value}));const c=r(e(i,{precision:5,toCanonicalUnits:!0}));c!==o.value&&(o.cloneBefore({value:c}),n.preserve||o.remove())}}};function replacer(e){if(!i(e))return;if("abs"!==e.getName().toLowerCase())return;const[s]=t([e.value],replacer);return[new c([o.Function,"max(",-1,-1,{value:"max"}],[o.CloseParen,")",-1,-1,void 0],[new l([o.OpenParen,"(",-1,-1,void 0],[o.CloseParen,")",-1,-1,void 0],u(s.flatMap(e=>e.tokens()))),new p([o.Comma,",",-1,-1,void 0]),new v([[o.Whitespace," ",-1,-1,void 0]]),new p([o.Number,"-1",-1,-1,{value:-1,type:n.Integer,signCharacter:"-"}]),new v([[o.Whitespace," ",-1,-1,void 0]]),new p([o.Delim,"*",-1,-1,{value:"*"}]),new v([[o.Whitespace," ",-1,-1,void 0]]),new l([o.OpenParen,"(",-1,-1,void 0],[o.CloseParen,")",-1,-1,void 0],u(s.flatMap(e=>e.tokens())))])]}creator.postcss=!0;export{creator as default}; +import{calcFromComponentValues as e}from"@csstools/css-calc";import{tokenize as s,TokenType as o,NumberType as n}from"@csstools/css-tokenizer";import{replaceComponentValues as t,parseCommaSeparatedListOfComponentValues as a,stringify as r,isFunctionNode as i,FunctionNode as c,SimpleBlockNode as l,TokenNode as p,WhitespaceNode as u,parseListOfComponentValues as v}from"@csstools/css-parser-algorithms";const m=/(?{const n=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-sign-functions",Declaration(o){if(!m.test(o.value))return;let i;i=f.test(o.value)?t(a(s({css:o.value})),replacer):a(s({css:o.value}));const c=r(e(i,{precision:5,toCanonicalUnits:!0}));c!==o.value&&(o.cloneBefore({value:c}),n.preserve||o.remove())}}};function replacer(e){if(!i(e))return;if("abs"!==e.getName().toLowerCase())return;const[s]=t([e.value],replacer);return[new c([o.Function,"max(",-1,-1,{value:"max"}],[o.CloseParen,")",-1,-1,void 0],[new l([o.OpenParen,"(",-1,-1,void 0],[o.CloseParen,")",-1,-1,void 0],v(s.flatMap(e=>e.tokens()))),new p([o.Comma,",",-1,-1,void 0]),new u([[o.Whitespace," ",-1,-1,void 0]]),new p([o.Number,"-1",-1,-1,{value:-1,type:n.Integer,signCharacter:"-"}]),new u([[o.Whitespace," ",-1,-1,void 0]]),new p([o.Delim,"*",-1,-1,{value:"*"}]),new u([[o.Whitespace," ",-1,-1,void 0]]),new l([o.OpenParen,"(",-1,-1,void 0],[o.CloseParen,")",-1,-1,void 0],v(s.flatMap(e=>e.tokens())))])]}creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-sign-functions/package.json b/plugins/postcss-sign-functions/package.json index 3fb087ba3..8507116a4 100644 --- a/plugins/postcss-sign-functions/package.json +++ b/plugins/postcss-sign-functions/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-sign-functions/src/index.ts b/plugins/postcss-sign-functions/src/index.ts index 8ab47607e..ae3bcd9bd 100644 --- a/plugins/postcss-sign-functions/src/index.ts +++ b/plugins/postcss-sign-functions/src/index.ts @@ -110,3 +110,4 @@ function replacer(componentValue: ComponentValue): Array | void creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-slow-plugins/CHANGELOG.md b/plugins/postcss-slow-plugins/CHANGELOG.md index 74527ca1d..174b1f909 100644 --- a/plugins/postcss-slow-plugins/CHANGELOG.md +++ b/plugins/postcss-slow-plugins/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Slow Plugins +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 2.0.0 _August 3, 2024_ diff --git a/plugins/postcss-slow-plugins/dist/index.cjs b/plugins/postcss-slow-plugins/dist/index.cjs deleted file mode 100644 index cd6a1858c..000000000 --- a/plugins/postcss-slow-plugins/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";const creator=s=>{const o=s?.ignore??[];return{postcssPlugin:"postcss-slow-plugins",async Once(s,{result:n,postcss:t}){console.log("Analyzing with file:\n "+s.source?.input.from+"\n");const e=s.source?.input.css??"",i=[...n.processor.plugins.filter(s=>"postcssPlugin"in s&&"postcss-slow-plugins"!==s.postcssPlugin)],r=(await t(i).process(e??"",n.opts)).css.length/1024,medianDuration=async s=>{const o=[];for(let n=0;n<21;n++){const n=performance.now();await s(),o.push(performance.now()-n)}return o.sort((s,o)=>s-o),o[10]},p=await medianDuration(async()=>{await t(i).process(e??"",n.opts)});{const s=[];for(let c=0;cs!==i[c]),a=await medianDuration(async()=>{await t(u).process(e??"",n.opts)}),d=p-a;s.push({duration:`${a.toFixed(2)}ms`,"kb's per ms":`${(r/a).toFixed(2)}kb/ms`,drop:d,name:l,"index in plugins list":c})}s.sort((s,o)=>Number(o.drop)-Number(s.drop)),s.splice(0,0,{duration:`${p.toFixed(2)}ms`,"kb's per ms":`${(r/p).toFixed(2)}kb/ms`,drop:"--",name:"-- all plugins --","index in plugins list":"--"}),s.map(s=>("string"==typeof s.drop||(s.drop=`${s.drop.toFixed(2)}ms`),s)),console.log("Most impactful to improve, ordered by drop in duration when excluded:"),console.table(s.slice(0,11))}{const s=[];for(let c=0;cs===i[c]||"postcssPlugin"in s&&o.includes(s.postcssPlugin))],a=await medianDuration(async()=>{await t(u).process(e??"",n.opts)}),d=p-a;s.push({duration:`${a.toFixed(2)}ms`,"kb's per ms":`${(r/a).toFixed(2)}kb/ms`,drop:d,name:l,"index in plugins list":c})}s.sort((s,o)=>Number(s.drop)-Number(o.drop)),s.map(s=>(delete s.drop,s)),console.log("Most impactful to improve, ordered by increase in duration when running alone:"),console.table(s.slice(0,11))}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-slow-plugins/dist/index.d.ts b/plugins/postcss-slow-plugins/dist/index.d.ts index 2c043bca2..3d1926e94 100644 --- a/plugins/postcss-slow-plugins/dist/index.d.ts +++ b/plugins/postcss-slow-plugins/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-slow-plugins plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-slow-plugins/dist/index.mjs b/plugins/postcss-slow-plugins/dist/index.mjs index 9723583d4..0dfff110c 100644 --- a/plugins/postcss-slow-plugins/dist/index.mjs +++ b/plugins/postcss-slow-plugins/dist/index.mjs @@ -1 +1 @@ -const creator=s=>{const o=s?.ignore??[];return{postcssPlugin:"postcss-slow-plugins",async Once(s,{result:n,postcss:t}){console.log("Analyzing with file:\n "+s.source?.input.from+"\n");const e=s.source?.input.css??"",i=[...n.processor.plugins.filter(s=>"postcssPlugin"in s&&"postcss-slow-plugins"!==s.postcssPlugin)],p=(await t(i).process(e??"",n.opts)).css.length/1024,medianDuration=async s=>{const o=[];for(let n=0;n<21;n++){const n=performance.now();await s(),o.push(performance.now()-n)}return o.sort((s,o)=>s-o),o[10]},r=await medianDuration(async()=>{await t(i).process(e??"",n.opts)});{const s=[];for(let l=0;ls!==i[l]),a=await medianDuration(async()=>{await t(u).process(e??"",n.opts)}),d=r-a;s.push({duration:`${a.toFixed(2)}ms`,"kb's per ms":`${(p/a).toFixed(2)}kb/ms`,drop:d,name:c,"index in plugins list":l})}s.sort((s,o)=>Number(o.drop)-Number(s.drop)),s.splice(0,0,{duration:`${r.toFixed(2)}ms`,"kb's per ms":`${(p/r).toFixed(2)}kb/ms`,drop:"--",name:"-- all plugins --","index in plugins list":"--"}),s.map(s=>("string"==typeof s.drop||(s.drop=`${s.drop.toFixed(2)}ms`),s)),console.log("Most impactful to improve, ordered by drop in duration when excluded:"),console.table(s.slice(0,11))}{const s=[];for(let l=0;ls===i[l]||"postcssPlugin"in s&&o.includes(s.postcssPlugin))],a=await medianDuration(async()=>{await t(u).process(e??"",n.opts)}),d=r-a;s.push({duration:`${a.toFixed(2)}ms`,"kb's per ms":`${(p/a).toFixed(2)}kb/ms`,drop:d,name:c,"index in plugins list":l})}s.sort((s,o)=>Number(s.drop)-Number(o.drop)),s.map(s=>(delete s.drop,s)),console.log("Most impactful to improve, ordered by increase in duration when running alone:"),console.table(s.slice(0,11))}}}};creator.postcss=!0;export{creator as default}; +const creator=s=>{const o=s?.ignore??[];return{postcssPlugin:"postcss-slow-plugins",async Once(s,{result:n,postcss:t}){console.log("Analyzing with file:\n "+s.source?.input.from+"\n");const e=s.source?.input.css??"",i=[...n.processor.plugins.filter(s=>"postcssPlugin"in s&&"postcss-slow-plugins"!==s.postcssPlugin)],p=(await t(i).process(e??"",n.opts)).css.length/1024,medianDuration=async s=>{const o=[];for(let n=0;n<21;n++){const n=performance.now();await s(),o.push(performance.now()-n)}return o.sort((s,o)=>s-o),o[10]},r=await medianDuration(async()=>{await t(i).process(e??"",n.opts)});{const s=[];for(let l=0;ls!==i[l]),a=await medianDuration(async()=>{await t(u).process(e??"",n.opts)}),d=r-a;s.push({duration:`${a.toFixed(2)}ms`,"kb's per ms":`${(p/a).toFixed(2)}kb/ms`,drop:d,name:c,"index in plugins list":l})}s.sort((s,o)=>Number(o.drop)-Number(s.drop)),s.splice(0,0,{duration:`${r.toFixed(2)}ms`,"kb's per ms":`${(p/r).toFixed(2)}kb/ms`,drop:"--",name:"-- all plugins --","index in plugins list":"--"}),s.map(s=>("string"==typeof s.drop||(s.drop=`${s.drop.toFixed(2)}ms`),s)),console.log("Most impactful to improve, ordered by drop in duration when excluded:"),console.table(s.slice(0,11))}{const s=[];for(let l=0;ls===i[l]||"postcssPlugin"in s&&o.includes(s.postcssPlugin))],a=await medianDuration(async()=>{await t(u).process(e??"",n.opts)}),d=r-a;s.push({duration:`${a.toFixed(2)}ms`,"kb's per ms":`${(p/a).toFixed(2)}kb/ms`,drop:d,name:c,"index in plugins list":l})}s.sort((s,o)=>Number(s.drop)-Number(o.drop)),s.map(s=>(delete s.drop,s)),console.log("Most impactful to improve, ordered by increase in duration when running alone:"),console.table(s.slice(0,11))}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-slow-plugins/package.json b/plugins/postcss-slow-plugins/package.json index d6fdb83cb..4f8c7bb67 100644 --- a/plugins/postcss-slow-plugins/package.json +++ b/plugins/postcss-slow-plugins/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-slow-plugins/src/index.ts b/plugins/postcss-slow-plugins/src/index.ts index 177200fdc..0a7f85b5d 100644 --- a/plugins/postcss-slow-plugins/src/index.ts +++ b/plugins/postcss-slow-plugins/src/index.ts @@ -154,3 +154,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-stepped-value-functions/CHANGELOG.md b/plugins/postcss-stepped-value-functions/CHANGELOG.md index 0cbec7699..f4ec68ac0 100644 --- a/plugins/postcss-stepped-value-functions/CHANGELOG.md +++ b/plugins/postcss-stepped-value-functions/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Stepped Value Functions +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.9 _May 27, 2025_ diff --git a/plugins/postcss-stepped-value-functions/dist/index.cjs b/plugins/postcss-stepped-value-functions/dist/index.cjs deleted file mode 100644 index 396dbe2c0..000000000 --- a/plugins/postcss-stepped-value-functions/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-calc");const s=/(?{const t=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-stepped-value-functions",Declaration(o){if(!s.test(o.value))return;const c=e.calc(o.value,{precision:5,toCanonicalUnits:!0});c!==o.value&&(o.cloneBefore({value:c}),t.preserve||o.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-stepped-value-functions/dist/index.d.ts b/plugins/postcss-stepped-value-functions/dist/index.d.ts index f5f73bbff..04e74a69c 100644 --- a/plugins/postcss-stepped-value-functions/dist/index.d.ts +++ b/plugins/postcss-stepped-value-functions/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-stepped-value-functions plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-stepped-value-functions/dist/index.mjs b/plugins/postcss-stepped-value-functions/dist/index.mjs index ac5168e54..39d996dc8 100644 --- a/plugins/postcss-stepped-value-functions/dist/index.mjs +++ b/plugins/postcss-stepped-value-functions/dist/index.mjs @@ -1 +1 @@ -import{calc as e}from"@csstools/css-calc";const s=/(?{const t=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-stepped-value-functions",Declaration(o){if(!s.test(o.value))return;const r=e(o.value,{precision:5,toCanonicalUnits:!0});r!==o.value&&(o.cloneBefore({value:r}),t.preserve||o.remove())}}};creator.postcss=!0;export{creator as default}; +import{calc as e}from"@csstools/css-calc";const s=/(?{const t=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-stepped-value-functions",Declaration(o){if(!s.test(o.value))return;const r=e(o.value,{precision:5,toCanonicalUnits:!0});r!==o.value&&(o.cloneBefore({value:r}),t.preserve||o.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-stepped-value-functions/package.json b/plugins/postcss-stepped-value-functions/package.json index 72309cd26..18493e9d4 100644 --- a/plugins/postcss-stepped-value-functions/package.json +++ b/plugins/postcss-stepped-value-functions/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-stepped-value-functions/src/index.ts b/plugins/postcss-stepped-value-functions/src/index.ts index fcb308578..4be02310f 100644 --- a/plugins/postcss-stepped-value-functions/src/index.ts +++ b/plugins/postcss-stepped-value-functions/src/index.ts @@ -46,3 +46,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-syntax-descriptor-syntax-production/CHANGELOG.md b/plugins/postcss-syntax-descriptor-syntax-production/CHANGELOG.md index 6403e04e2..ad1d2567e 100644 --- a/plugins/postcss-syntax-descriptor-syntax-production/CHANGELOG.md +++ b/plugins/postcss-syntax-descriptor-syntax-production/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Syntax Descriptor Syntax Production +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 1.0.1 _December 27, 2025_ diff --git a/plugins/postcss-syntax-descriptor-syntax-production/dist/index.cjs b/plugins/postcss-syntax-descriptor-syntax-production/dist/index.cjs deleted file mode 100644 index 604a00aad..000000000 --- a/plugins/postcss-syntax-descriptor-syntax-production/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-tokenizer");const s=/^property$/i,t=/^syntax$/i,creator=c=>{const a=Object.assign({preserve:!1},c);return{postcssPlugin:"postcss-syntax-descriptor-syntax-production",Declaration(c){if(!t.test(c.prop))return;if(!c.parent||"atrule"!==c.parent.type)return;if(!s.test(c.parent.name))return;const r=c.prev();if(r&&"decl"===r.type&&t.test(r.prop))return;const o=c.value,n=e.tokenize({css:c.value}),i=n.filter(s=>!(e.isTokenWhiteSpaceOrComment(s)||e.isTokenEOF(s)));if(1===i.length&&e.isTokenString(i[0]))return;let p="";n.forEach(s=>{e.isTokenComment(s)||(e.isTokenWhitespace(s)?p+=" ":p+=s[1])});let u='"';for(const e of p){const s=e.codePointAt(0);if(void 0!==s)switch(s){case 0:u+=String.fromCodePoint(65533);break;case 34:case 92:u+="\\"+String.fromCodePoint(s);break;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 127:u+="\\"+s.toString(16)+" ";break;default:u+=String.fromCodePoint(s)}}u+='"',o!==u&&(c.cloneBefore({value:u}),a.preserve||c.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-syntax-descriptor-syntax-production/dist/index.d.ts b/plugins/postcss-syntax-descriptor-syntax-production/dist/index.d.ts index 9e6a37297..f640387fe 100644 --- a/plugins/postcss-syntax-descriptor-syntax-production/dist/index.d.ts +++ b/plugins/postcss-syntax-descriptor-syntax-production/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-syntax-descriptor-syntax-production plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-syntax-descriptor-syntax-production/dist/index.mjs b/plugins/postcss-syntax-descriptor-syntax-production/dist/index.mjs index 2a78a57b4..38414931c 100644 --- a/plugins/postcss-syntax-descriptor-syntax-production/dist/index.mjs +++ b/plugins/postcss-syntax-descriptor-syntax-production/dist/index.mjs @@ -1 +1 @@ -import{tokenize as e,isTokenWhiteSpaceOrComment as s,isTokenEOF as a,isTokenString as c,isTokenComment as t,isTokenWhitespace as r}from"@csstools/css-tokenizer";const o=/^property$/i,n=/^syntax$/i,creator=i=>{const p=Object.assign({preserve:!1},i);return{postcssPlugin:"postcss-syntax-descriptor-syntax-production",Declaration(i){if(!n.test(i.prop))return;if(!i.parent||"atrule"!==i.parent.type)return;if(!o.test(i.parent.name))return;const f=i.prev();if(f&&"decl"===f.type&&n.test(f.prop))return;const l=i.value,u=e({css:i.value}),d=u.filter(e=>!(s(e)||a(e)));if(1===d.length&&c(d[0]))return;let v="";u.forEach(e=>{t(e)||(r(e)?v+=" ":v+=e[1])});let g='"';for(const e of v){const s=e.codePointAt(0);if(void 0!==s)switch(s){case 0:g+=String.fromCodePoint(65533);break;case 34:case 92:g+="\\"+String.fromCodePoint(s);break;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 127:g+="\\"+s.toString(16)+" ";break;default:g+=String.fromCodePoint(s)}}g+='"',l!==g&&(i.cloneBefore({value:g}),p.preserve||i.remove())}}};creator.postcss=!0;export{creator as default}; +import{tokenize as e,isTokenWhiteSpaceOrComment as s,isTokenEOF as a,isTokenString as t,isTokenComment as c,isTokenWhitespace as r}from"@csstools/css-tokenizer";const o=/^property$/i,n=/^syntax$/i,creator=i=>{const p=Object.assign({preserve:!1},i);return{postcssPlugin:"postcss-syntax-descriptor-syntax-production",Declaration(i){if(!n.test(i.prop))return;if(!i.parent||"atrule"!==i.parent.type)return;if(!o.test(i.parent.name))return;const f=i.prev();if(f&&"decl"===f.type&&n.test(f.prop))return;const l=i.value,u=e({css:i.value}),d=u.filter(e=>!(s(e)||a(e)));if(1===d.length&&t(d[0]))return;let m="";u.forEach(e=>{c(e)||(r(e)?m+=" ":m+=e[1])});let v='"';for(const e of m){const s=e.codePointAt(0);if(void 0!==s)switch(s){case 0:v+=String.fromCodePoint(65533);break;case 34:case 92:v+="\\"+String.fromCodePoint(s);break;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 127:v+="\\"+s.toString(16)+" ";break;default:v+=String.fromCodePoint(s)}}v+='"',l!==v&&(i.cloneBefore({value:v}),p.preserve||i.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-syntax-descriptor-syntax-production/package.json b/plugins/postcss-syntax-descriptor-syntax-production/package.json index 29a032dc5..0637cc6e3 100644 --- a/plugins/postcss-syntax-descriptor-syntax-production/package.json +++ b/plugins/postcss-syntax-descriptor-syntax-production/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-syntax-descriptor-syntax-production/src/index.ts b/plugins/postcss-syntax-descriptor-syntax-production/src/index.ts index 3b7347a6a..b48463622 100644 --- a/plugins/postcss-syntax-descriptor-syntax-production/src/index.ts +++ b/plugins/postcss-syntax-descriptor-syntax-production/src/index.ts @@ -142,3 +142,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-system-ui-font-family/CHANGELOG.md b/plugins/postcss-system-ui-font-family/CHANGELOG.md index fa498c726..16a7e63e6 100644 --- a/plugins/postcss-system-ui-font-family/CHANGELOG.md +++ b/plugins/postcss-system-ui-font-family/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS System UI Font Family +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 1.0.0 _December 4, 2025_ diff --git a/plugins/postcss-system-ui-font-family/dist/index.cjs b/plugins/postcss-system-ui-font-family/dist/index.cjs deleted file mode 100644 index 090961a2a..000000000 --- a/plugins/postcss-system-ui-font-family/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("@csstools/css-parser-algorithms"),s=require("@csstools/css-tokenizer");const t=/^font(?:-family)?$/i,o=["system-ui","-apple-system","Segoe UI","Roboto","Ubuntu","Cantarell","Noto Sans","sans-serif"];const n=o.join(","),creator=r=>{const i=Object.assign({preserve:!0},r);return{postcssPlugin:"postcss-system-ui-font-family",Declaration(r){if(!r.variable&&!t.test(r.prop))return;if(r.value.includes(n))return;const a=r.value,l=s.tokenize({css:a}),u=e.parseCommaSeparatedListOfComponentValues(l),c=new Map;let p=-1;e:for(let t=0;t!("system-ui"!==e||!v)||!m.has(e)).map(t=>[new e.TokenNode([s.TokenType.Ident,t,-1,-1,{value:t}])]));var m,v;if(0===f.length)return;u.splice(p,1,...f);const d=e.stringify(u);d!==a&&(r.cloneBefore({prop:r.prop,value:d}),r.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-system-ui-font-family/dist/index.d.ts b/plugins/postcss-system-ui-font-family/dist/index.d.ts index 03cfbc7b1..fbfbf80d8 100644 --- a/plugins/postcss-system-ui-font-family/dist/index.d.ts +++ b/plugins/postcss-system-ui-font-family/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-system-ui-font-family plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-system-ui-font-family/dist/index.mjs b/plugins/postcss-system-ui-font-family/dist/index.mjs index aaab436a7..7800b2c94 100644 --- a/plugins/postcss-system-ui-font-family/dist/index.mjs +++ b/plugins/postcss-system-ui-font-family/dist/index.mjs @@ -1 +1 @@ -import{parseCommaSeparatedListOfComponentValues as e,isWhiteSpaceOrCommentNode as s,isTokenNode as t,stringify as o,TokenNode as n}from"@csstools/css-parser-algorithms";import{tokenize as r,isTokenIdent as i,TokenType as l}from"@csstools/css-tokenizer";const a=/^font(?:-family)?$/i,c=["system-ui","-apple-system","Segoe UI","Roboto","Ubuntu","Cantarell","Noto Sans","sans-serif"];const u=c.join(","),creator=p=>{const f=Object.assign({preserve:!0},p);return{postcssPlugin:"postcss-system-ui-font-family",Declaration(p){if(!p.variable&&!a.test(p.prop))return;if(p.value.includes(u))return;const m=p.value,v=r({css:m}),g=e(v),y=new Map;let h=-1;e:for(let e=0;e!("system-ui"!==e||!j)||!d.has(e)).map(e=>[new n([l.Ident,e,-1,-1,{value:e}])]));var d,j;if(0===b.length)return;g.splice(h,1,...b);const w=o(g);w!==m&&(p.cloneBefore({prop:p.prop,value:w}),p.remove())}}};creator.postcss=!0;export{creator as default}; +import{parseCommaSeparatedListOfComponentValues as e,isWhiteSpaceOrCommentNode as s,isTokenNode as t,stringify as o,TokenNode as n}from"@csstools/css-parser-algorithms";import{tokenize as r,isTokenIdent as i,TokenType as l}from"@csstools/css-tokenizer";const a=/^font(?:-family)?$/i,c=["system-ui","-apple-system","Segoe UI","Roboto","Ubuntu","Cantarell","Noto Sans","sans-serif"];const u=c.join(","),creator=p=>{const f=Object.assign({preserve:!0},p);return{postcssPlugin:"postcss-system-ui-font-family",Declaration(p){if(!p.variable&&!a.test(p.prop))return;if(p.value.includes(u))return;const m=p.value,v=r({css:m}),g=e(v),y=new Map;let h=-1;e:for(let e=0;e!("system-ui"!==e||!j)||!b.has(e)).map(e=>[new n([l.Ident,e,-1,-1,{value:e}])]));var b,j;if(0===d.length)return;g.splice(h,1,...d);const w=o(g);w!==m&&(p.cloneBefore({prop:p.prop,value:w}),p.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-system-ui-font-family/package.json b/plugins/postcss-system-ui-font-family/package.json index 67250716d..a3fb1277f 100644 --- a/plugins/postcss-system-ui-font-family/package.json +++ b/plugins/postcss-system-ui-font-family/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-system-ui-font-family/src/index.ts b/plugins/postcss-system-ui-font-family/src/index.ts index 976bcbe63..920d06d04 100644 --- a/plugins/postcss-system-ui-font-family/src/index.ts +++ b/plugins/postcss-system-ui-font-family/src/index.ts @@ -128,3 +128,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-text-decoration-shorthand/CHANGELOG.md b/plugins/postcss-text-decoration-shorthand/CHANGELOG.md index 88829f9ff..92d8c56d2 100644 --- a/plugins/postcss-text-decoration-shorthand/CHANGELOG.md +++ b/plugins/postcss-text-decoration-shorthand/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Text Decoration Shorthand +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.3 _August 22, 2025_ diff --git a/plugins/postcss-text-decoration-shorthand/dist/index.cjs b/plugins/postcss-text-decoration-shorthand/dist/index.cjs deleted file mode 100644 index b4aa6b2d7..000000000 --- a/plugins/postcss-text-decoration-shorthand/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("postcss-value-parser"),t=require("@csstools/color-helpers");const o=/^text-decoration$/i,creator=t=>{const c=Object.assign({preserve:!0},t);return{postcssPlugin:"postcss-text-decoration-shorthand",prepare(){const t=new Map;return{postcssPlugin:"postcss-text-decoration-shorthand",OnceExit(){t.clear()},Declaration(i){if(!o.test(i.prop))return;const a=i.parent;if(!a)return;const u=a.index(i);if(a.nodes.some(e=>"decl"===e.type&&o.test(e.prop)&&t.get(i.value)===e.value&&a.index(e)!==u))return;const d=e(i.value),p=d.nodes.filter(e=>"space"!==e.type&&"comment"!==e.type);if(p.find(e=>"var"===e.value.toLowerCase()&&"function"===e.type))return;if(p.find(e=>"word"===e.type&&r.includes(e.value)))return;const f={line:[],style:null,color:null,thickness:null};for(let t=0;t; export default creator; +export { creator as 'module.exports' } /** postcss-text-decoration-shorthand plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-text-decoration-shorthand/dist/index.mjs b/plugins/postcss-text-decoration-shorthand/dist/index.mjs index 1408ec8f1..46296ce26 100644 --- a/plugins/postcss-text-decoration-shorthand/dist/index.mjs +++ b/plugins/postcss-text-decoration-shorthand/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-value-parser";import{namedColors as t}from"@csstools/color-helpers";const o=/^text-decoration$/i,creator=t=>{const c=Object.assign({preserve:!0},t);return{postcssPlugin:"postcss-text-decoration-shorthand",prepare(){const t=new Map;return{postcssPlugin:"postcss-text-decoration-shorthand",OnceExit(){t.clear()},Declaration(i){if(!o.test(i.prop))return;const a=i.parent;if(!a)return;const u=a.index(i);if(a.nodes.some(e=>"decl"===e.type&&o.test(e.prop)&&t.get(i.value)===e.value&&a.index(e)!==u))return;const d=e(i.value),p=d.nodes.filter(e=>"space"!==e.type&&"comment"!==e.type);if(p.find(e=>"var"===e.value.toLowerCase()&&"function"===e.type))return;if(p.find(e=>"word"===e.type&&r.includes(e.value)))return;const f={line:[],style:null,color:null,thickness:null};for(let t=0;t{const c=Object.assign({preserve:!0},o);return{postcssPlugin:"postcss-text-decoration-shorthand",prepare(){const o=new Map;return{postcssPlugin:"postcss-text-decoration-shorthand",OnceExit(){o.clear()},Declaration(i){if(!t.test(i.prop))return;const a=i.parent;if(!a)return;const u=a.index(i);if(a.nodes.some(e=>"decl"===e.type&&t.test(e.prop)&&o.get(i.value)===e.value&&a.index(e)!==u))return;const d=e(i.value),p=d.nodes.filter(e=>"space"!==e.type&&"comment"!==e.type);if(p.find(e=>"var"===e.value.toLowerCase()&&"function"===e.type))return;if(p.find(e=>"word"===e.type&&r.includes(e.value)))return;const f={line:[],style:null,color:null,thickness:null};for(let o=0;o=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-text-decoration-shorthand/src/index.ts b/plugins/postcss-text-decoration-shorthand/src/index.ts index 616485bb2..1246f170b 100644 --- a/plugins/postcss-text-decoration-shorthand/src/index.ts +++ b/plugins/postcss-text-decoration-shorthand/src/index.ts @@ -258,6 +258,7 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; function nodeIsAColor(node: valueParser.Node): boolean { if ('word' === node.type && node.value.startsWith('#')) { diff --git a/plugins/postcss-todo-or-die/CHANGELOG.md b/plugins/postcss-todo-or-die/CHANGELOG.md index b1d01024f..1f0364025 100644 --- a/plugins/postcss-todo-or-die/CHANGELOG.md +++ b/plugins/postcss-todo-or-die/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Todo or Die +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 3.0.5 _May 27, 2025_ diff --git a/plugins/postcss-todo-or-die/dist/index.cjs b/plugins/postcss-todo-or-die/dist/index.cjs deleted file mode 100644 index dfc6770e0..000000000 --- a/plugins/postcss-todo-or-die/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var e=require("browserslist"),o=require("@csstools/css-tokenizer"),t=require("@csstools/css-parser-algorithms");function died(e){return"string"==typeof e}function matchBeforeDateCondition(e,o,t){const n=new Date;n.setUTCFullYear(e),n.setUTCMonth(o),n.setUTCDate(t);return(new Date).getTime()=n[4].value)return`Died because A (${t[1]}) is no longer less than B (${n[1]})`;break;case">":if(t[4].value<=n[4].value)return`Died because A (${t[1]}) is no longer greater than B (${n[1]})`;break;case"=":if(t[4].value!==n[4].value)return`Died because A (${t[1]}) is no longer equal to B (${n[1]})`}return!0}}function matchNotCondition(e){const t=e.a,n=e.b;if(!(t[0]!==n[0]||o.isTokenDimension(t)&&o.isTokenDimension(n)&&t[4].unit.toLowerCase()!==n[4].unit.toLowerCase())){switch(e.operator){case"<":if(t[4].value":if(t[4].value>n[4].value)return`Died because A (${t[1]}) is greater than B (${n[1]})`;break;case"=":if(t[4].value===n[4].value)return`Died because A (${t[1]}) equals B (${n[1]})`}return!0}}function parseBeforeDateCondition(e){const n=e.value.filter(e=>!t.isWhitespaceNode(e)&&!t.isCommentNode(e));if(n.length>3)return!1;const r=n[0],i=n[1],s=n[2];if(!r||!i||!s)return!1;if(!t.isTokenNode(r)||!t.isTokenNode(i)||!t.isTokenNode(s))return!1;const a=r.value,u=i.value,c=s.value;return!(!o.isTokenNumber(a)||a[4].type!==o.NumberType.Integer)&&(!(!o.isTokenNumber(u)||u[4].type!==o.NumberType.Integer)&&(!(!o.isTokenNumber(c)||c[4].type!==o.NumberType.Integer)&&{year:a[4].value,month:u[4].value,day:c[4].value}))}function parseBrowserslistCondition(e){const n=e.value.filter(e=>!t.isWhitespaceNode(e)&&!t.isCommentNode(e));if(n.length>1)return!1;const r=n[0];if(!r)return!1;if(!t.isTokenNode(r))return!1;const i=r.value;return!!o.isTokenString(i)&&i[4].value}const n=[o.TokenType.Ident,o.TokenType.Number,o.TokenType.Percentage,o.TokenType.Dimension],r=["<",">","="];function parseIfCondition(e){const i=e.value.filter(e=>!t.isWhitespaceNode(e)&&!t.isCommentNode(e));if(i.length>3)return!1;const s=i[0],a=i[1],u=i[2];if(!s||!a||!u)return!1;if(!t.isTokenNode(s)||!t.isTokenNode(a)||!t.isTokenNode(u))return!1;const c=s.value,d=a.value,l=u.value;return!!o.isTokenDelim(d)&&(!!r.includes(d[4].value)&&(!!n.includes(c[0])&&(!!n.includes(l[0])&&{a:c,b:l,operator:d[4].value})))}function parseNotCondition(e){const o=parseIfCondition(e);return!!o&&{a:o.a,b:o.b,operator:o.operator}}const creator=()=>{const n=new Set(e());return{postcssPlugin:"postcss-todo-or-die",Once(e,{result:r}){const i=[];e.walkAtRules(e=>{if("todo-or-die"===e.name.toLowerCase()){if(!e.params.trim())throw e.error("Rule must have valid params");i.push(e)}});for(const e of i){const errorHandler=o=>{throw e.error(o.message)},i=o.tokenize({css:e.params},{onParseError:errorHandler}),s=t.parseCommaSeparatedListOfComponentValues(i,{onParseError:errorHandler});if(!s.length)return void e.warn(r,"Rule must have some valid params.");for(let o=0;o!t.isWhitespaceNode(e)&&!t.isCommentNode(e));if(1!==i.length)return void e.warn(r,"Conditions must be split by commas when adding multiple in a list.");if(!t.isFunctionNode(i[0]))return void e.warn(r,"Conditions must be one of the supported functions.");switch(i[0].name[4].value.toLowerCase()){case"if":{const o=parseIfCondition(i[0]);if(!o)return void e.warn(r,"Incorrect arguments in `if()` function.");const t=matchIfCondition(o);if(died(t))throw e.error(t);break}case"not":{const o=parseNotCondition(i[0]);if(!o)return void e.warn(r,"Incorrect arguments in `not()` function.");const t=matchNotCondition(o);if(died(t))throw e.error(t);break}case"browserslist":{const o=parseBrowserslistCondition(i[0]);if(!o)return void e.warn(r,"Incorrect arguments in `browserslist()` function.");const t=matchBrowserslistCondition(o,n);if(died(t))throw e.error(t);break}case"before-date":{const o=parseBeforeDateCondition(i[0]);if(!o)return void e.warn(r,"Incorrect arguments in `before-date()` function.");const t=matchBeforeDateCondition(o.year,o.month,o.day);if(died(t))throw e.error(t);break}}}e.nodes?e.replaceWith(e.nodes):e.remove()}}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-todo-or-die/dist/index.d.ts b/plugins/postcss-todo-or-die/dist/index.d.ts index 73f8cdb79..172fc5169 100644 --- a/plugins/postcss-todo-or-die/dist/index.d.ts +++ b/plugins/postcss-todo-or-die/dist/index.d.ts @@ -2,5 +2,6 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } export { } diff --git a/plugins/postcss-todo-or-die/dist/index.mjs b/plugins/postcss-todo-or-die/dist/index.mjs index 0ff8de5fe..5782bb742 100644 --- a/plugins/postcss-todo-or-die/dist/index.mjs +++ b/plugins/postcss-todo-or-die/dist/index.mjs @@ -1 +1 @@ -import e from"browserslist";import{isTokenDimension as t,isTokenNumber as r,NumberType as n,isTokenString as o,TokenType as s,isTokenDelim as i,tokenize as a}from"@csstools/css-tokenizer";import{isWhitespaceNode as u,isCommentNode as c,isTokenNode as l,parseCommaSeparatedListOfComponentValues as f,isFunctionNode as d}from"@csstools/css-parser-algorithms";function died(e){return"string"==typeof e}function matchBeforeDateCondition(e,t,r){const n=new Date;n.setUTCFullYear(e),n.setUTCMonth(t),n.setUTCDate(r);return(new Date).getTime()=n[4].value)return`Died because A (${r[1]}) is no longer less than B (${n[1]})`;break;case">":if(r[4].value<=n[4].value)return`Died because A (${r[1]}) is no longer greater than B (${n[1]})`;break;case"=":if(r[4].value!==n[4].value)return`Died because A (${r[1]}) is no longer equal to B (${n[1]})`}return!0}}function matchNotCondition(e){const r=e.a,n=e.b;if(!(r[0]!==n[0]||t(r)&&t(n)&&r[4].unit.toLowerCase()!==n[4].unit.toLowerCase())){switch(e.operator){case"<":if(r[4].value":if(r[4].value>n[4].value)return`Died because A (${r[1]}) is greater than B (${n[1]})`;break;case"=":if(r[4].value===n[4].value)return`Died because A (${r[1]}) equals B (${n[1]})`}return!0}}function parseBeforeDateCondition(e){const t=e.value.filter(e=>!u(e)&&!c(e));if(t.length>3)return!1;const o=t[0],s=t[1],i=t[2];if(!o||!s||!i)return!1;if(!l(o)||!l(s)||!l(i))return!1;const a=o.value,f=s.value,d=i.value;return!(!r(a)||a[4].type!==n.Integer)&&(!(!r(f)||f[4].type!==n.Integer)&&(!(!r(d)||d[4].type!==n.Integer)&&{year:a[4].value,month:f[4].value,day:d[4].value}))}function parseBrowserslistCondition(e){const t=e.value.filter(e=>!u(e)&&!c(e));if(t.length>1)return!1;const r=t[0];if(!r)return!1;if(!l(r))return!1;const n=r.value;return!!o(n)&&n[4].value}const h=[s.Ident,s.Number,s.Percentage,s.Dimension],m=["<",">","="];function parseIfCondition(e){const t=e.value.filter(e=>!u(e)&&!c(e));if(t.length>3)return!1;const r=t[0],n=t[1],o=t[2];if(!r||!n||!o)return!1;if(!l(r)||!l(n)||!l(o))return!1;const s=r.value,a=n.value,f=o.value;return!!i(a)&&(!!m.includes(a[4].value)&&(!!h.includes(s[0])&&(!!h.includes(f[0])&&{a:s,b:f,operator:a[4].value})))}function parseNotCondition(e){const t=parseIfCondition(e);return!!t&&{a:t.a,b:t.b,operator:t.operator}}const creator=()=>{const t=new Set(e());return{postcssPlugin:"postcss-todo-or-die",Once(e,{result:r}){const n=[];e.walkAtRules(e=>{if("todo-or-die"===e.name.toLowerCase()){if(!e.params.trim())throw e.error("Rule must have valid params");n.push(e)}});for(const e of n){const errorHandler=t=>{throw e.error(t.message)},n=a({css:e.params},{onParseError:errorHandler}),o=f(n,{onParseError:errorHandler});if(!o.length)return void e.warn(r,"Rule must have some valid params.");for(let n=0;n!u(e)&&!c(e));if(1!==s.length)return void e.warn(r,"Conditions must be split by commas when adding multiple in a list.");if(!d(s[0]))return void e.warn(r,"Conditions must be one of the supported functions.");switch(s[0].name[4].value.toLowerCase()){case"if":{const t=parseIfCondition(s[0]);if(!t)return void e.warn(r,"Incorrect arguments in `if()` function.");const n=matchIfCondition(t);if(died(n))throw e.error(n);break}case"not":{const t=parseNotCondition(s[0]);if(!t)return void e.warn(r,"Incorrect arguments in `not()` function.");const n=matchNotCondition(t);if(died(n))throw e.error(n);break}case"browserslist":{const n=parseBrowserslistCondition(s[0]);if(!n)return void e.warn(r,"Incorrect arguments in `browserslist()` function.");const o=matchBrowserslistCondition(n,t);if(died(o))throw e.error(o);break}case"before-date":{const t=parseBeforeDateCondition(s[0]);if(!t)return void e.warn(r,"Incorrect arguments in `before-date()` function.");const n=matchBeforeDateCondition(t.year,t.month,t.day);if(died(n))throw e.error(n);break}}}e.nodes?e.replaceWith(e.nodes):e.remove()}}}};creator.postcss=!0;export{creator as default}; +import e from"browserslist";import{isTokenDimension as t,isTokenNumber as r,NumberType as n,isTokenString as o,TokenType as s,isTokenDelim as i,tokenize as a}from"@csstools/css-tokenizer";import{isWhitespaceNode as u,isCommentNode as c,isTokenNode as l,parseCommaSeparatedListOfComponentValues as f,isFunctionNode as d}from"@csstools/css-parser-algorithms";function died(e){return"string"==typeof e}function matchBeforeDateCondition(e,t,r){const n=new Date;n.setUTCFullYear(e),n.setUTCMonth(t),n.setUTCDate(r);return(new Date).getTime()=n[4].value)return`Died because A (${r[1]}) is no longer less than B (${n[1]})`;break;case">":if(r[4].value<=n[4].value)return`Died because A (${r[1]}) is no longer greater than B (${n[1]})`;break;case"=":if(r[4].value!==n[4].value)return`Died because A (${r[1]}) is no longer equal to B (${n[1]})`}return!0}}function matchNotCondition(e){const r=e.a,n=e.b;if(!(r[0]!==n[0]||t(r)&&t(n)&&r[4].unit.toLowerCase()!==n[4].unit.toLowerCase())){switch(e.operator){case"<":if(r[4].value":if(r[4].value>n[4].value)return`Died because A (${r[1]}) is greater than B (${n[1]})`;break;case"=":if(r[4].value===n[4].value)return`Died because A (${r[1]}) equals B (${n[1]})`}return!0}}function parseBeforeDateCondition(e){const t=e.value.filter(e=>!u(e)&&!c(e));if(t.length>3)return!1;const o=t[0],s=t[1],i=t[2];if(!o||!s||!i)return!1;if(!l(o)||!l(s)||!l(i))return!1;const a=o.value,f=s.value,d=i.value;return!(!r(a)||a[4].type!==n.Integer)&&(!(!r(f)||f[4].type!==n.Integer)&&(!(!r(d)||d[4].type!==n.Integer)&&{year:a[4].value,month:f[4].value,day:d[4].value}))}function parseBrowserslistCondition(e){const t=e.value.filter(e=>!u(e)&&!c(e));if(t.length>1)return!1;const r=t[0];if(!r)return!1;if(!l(r))return!1;const n=r.value;return!!o(n)&&n[4].value}const h=[s.Ident,s.Number,s.Percentage,s.Dimension],m=["<",">","="];function parseIfCondition(e){const t=e.value.filter(e=>!u(e)&&!c(e));if(t.length>3)return!1;const r=t[0],n=t[1],o=t[2];if(!r||!n||!o)return!1;if(!l(r)||!l(n)||!l(o))return!1;const s=r.value,a=n.value,f=o.value;return!!i(a)&&(!!m.includes(a[4].value)&&(!!h.includes(s[0])&&(!!h.includes(f[0])&&{a:s,b:f,operator:a[4].value})))}function parseNotCondition(e){const t=parseIfCondition(e);return!!t&&{a:t.a,b:t.b,operator:t.operator}}const creator=()=>{const t=new Set(e());return{postcssPlugin:"postcss-todo-or-die",Once(e,{result:r}){const n=[];e.walkAtRules(e=>{if("todo-or-die"===e.name.toLowerCase()){if(!e.params.trim())throw e.error("Rule must have valid params");n.push(e)}});for(const e of n){const errorHandler=t=>{throw e.error(t.message)},n=a({css:e.params},{onParseError:errorHandler}),o=f(n,{onParseError:errorHandler});if(!o.length)return void e.warn(r,"Rule must have some valid params.");for(let n=0;n!u(e)&&!c(e));if(1!==s.length)return void e.warn(r,"Conditions must be split by commas when adding multiple in a list.");if(!d(s[0]))return void e.warn(r,"Conditions must be one of the supported functions.");switch(s[0].name[4].value.toLowerCase()){case"if":{const t=parseIfCondition(s[0]);if(!t)return void e.warn(r,"Incorrect arguments in `if()` function.");const n=matchIfCondition(t);if(died(n))throw e.error(n);break}case"not":{const t=parseNotCondition(s[0]);if(!t)return void e.warn(r,"Incorrect arguments in `not()` function.");const n=matchNotCondition(t);if(died(n))throw e.error(n);break}case"browserslist":{const n=parseBrowserslistCondition(s[0]);if(!n)return void e.warn(r,"Incorrect arguments in `browserslist()` function.");const o=matchBrowserslistCondition(n,t);if(died(o))throw e.error(o);break}case"before-date":{const t=parseBeforeDateCondition(s[0]);if(!t)return void e.warn(r,"Incorrect arguments in `before-date()` function.");const n=matchBeforeDateCondition(t.year,t.month,t.day);if(died(n))throw e.error(n);break}}}e.nodes?e.replaceWith(e.nodes):e.remove()}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-todo-or-die/package.json b/plugins/postcss-todo-or-die/package.json index e8d60aa7a..eaf3cad22 100644 --- a/plugins/postcss-todo-or-die/package.json +++ b/plugins/postcss-todo-or-die/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-todo-or-die/src/index.ts b/plugins/postcss-todo-or-die/src/index.ts index 70d64c3dd..219c0bfbe 100644 --- a/plugins/postcss-todo-or-die/src/index.ts +++ b/plugins/postcss-todo-or-die/src/index.ts @@ -143,3 +143,4 @@ const creator: PluginCreator = () => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-trigonometric-functions/CHANGELOG.md b/plugins/postcss-trigonometric-functions/CHANGELOG.md index e455ee9df..d8dd16343 100644 --- a/plugins/postcss-trigonometric-functions/CHANGELOG.md +++ b/plugins/postcss-trigonometric-functions/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Trigonometric Functions +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.9 _May 27, 2025_ diff --git a/plugins/postcss-trigonometric-functions/dist/index.cjs b/plugins/postcss-trigonometric-functions/dist/index.cjs deleted file mode 100644 index 1ba42783d..000000000 --- a/plugins/postcss-trigonometric-functions/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var s=require("@csstools/css-calc");const e=/(?{const c=Object.assign({preserve:!1},t);return{postcssPlugin:"postcss-trigonometric-functions",Declaration(t){if(!e.test(t.value))return;const o=s.calc(t.value,{precision:5,toCanonicalUnits:!0});o!==t.value&&(t.cloneBefore({value:o}),c.preserve||t.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-trigonometric-functions/dist/index.d.ts b/plugins/postcss-trigonometric-functions/dist/index.d.ts index 21e161538..1ee49deb6 100644 --- a/plugins/postcss-trigonometric-functions/dist/index.d.ts +++ b/plugins/postcss-trigonometric-functions/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-trigonometric-functions plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-trigonometric-functions/dist/index.mjs b/plugins/postcss-trigonometric-functions/dist/index.mjs index 686ebd566..98e7a7e8e 100644 --- a/plugins/postcss-trigonometric-functions/dist/index.mjs +++ b/plugins/postcss-trigonometric-functions/dist/index.mjs @@ -1 +1 @@ -import{calc as s}from"@csstools/css-calc";const e=/(?{const o=Object.assign({preserve:!1},t);return{postcssPlugin:"postcss-trigonometric-functions",Declaration(t){if(!e.test(t.value))return;const n=s(t.value,{precision:5,toCanonicalUnits:!0});n!==t.value&&(t.cloneBefore({value:n}),o.preserve||t.remove())}}};creator.postcss=!0;export{creator as default}; +import{calc as s}from"@csstools/css-calc";const e=/(?{const t=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-trigonometric-functions",Declaration(o){if(!e.test(o.value))return;const n=s(o.value,{precision:5,toCanonicalUnits:!0});n!==o.value&&(o.cloneBefore({value:n}),t.preserve||o.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-trigonometric-functions/package.json b/plugins/postcss-trigonometric-functions/package.json index 0ebeee30a..42ba58417 100644 --- a/plugins/postcss-trigonometric-functions/package.json +++ b/plugins/postcss-trigonometric-functions/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-trigonometric-functions/src/index.ts b/plugins/postcss-trigonometric-functions/src/index.ts index a65edf74d..a1a5edd05 100644 --- a/plugins/postcss-trigonometric-functions/src/index.ts +++ b/plugins/postcss-trigonometric-functions/src/index.ts @@ -46,3 +46,4 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/plugins/postcss-unset-value/CHANGELOG.md b/plugins/postcss-unset-value/CHANGELOG.md index e8526757b..6787dc915 100644 --- a/plugins/postcss-unset-value/CHANGELOG.md +++ b/plugins/postcss-unset-value/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes to PostCSS Unset Value +### Unreleased (major) + +- Updated: Support for Node `20.19.0` or later (major). +- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes. + ### 4.0.0 _August 3, 2024_ diff --git a/plugins/postcss-unset-value/dist/index.cjs b/plugins/postcss-unset-value/dist/index.cjs deleted file mode 100644 index 8464cec8d..000000000 --- a/plugins/postcss-unset-value/dist/index.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";const e=new Set(["block-ellipsis","border-boundary","border-collapse","border-spacing","box-snap","caption-side","caret","caret-shape","clip-rule","color","color-interpolation","color-interpolation-filters","cursor","direction","dominant-baseline","empty-cells","fill","fill-color","fill-image","fill-opacity","fill-position","fill-repeat","fill-rule","fill-size","font","font-family","font-feature-settings","font-kerning","font-language-override","font-palette","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-emoji","font-variant-ligatures","font-weight","forced-color-adjust","hyphenate-character","hyphenate-limit-chars","hyphenate-limit-last","hyphenate-limit-lines","hyphenate-limit-zone","hyphens","image-orientation","image-rendering","image-resolution","initial-letter-wrap","letter-spacing","line-break","line-height","line-padding","line-snap","list-style","list-style-image","list-style-position","list-style-type","marker","marker-end","marker-mid","marker-side","marker-start","orphans","overflow-wrap","paint-order","pointer-events","print-color-adjust","quotes","ruby-merge","ruby-overhang","ruby-position","shape-rendering","speak","speak-as","stroke","stroke-align","stroke-alignment","stroke-color","stroke-dash-corner","stroke-dash-justify","stroke-dashadjust","stroke-dasharray","stroke-dashcorner","stroke-dashoffset","stroke-image","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-position","stroke-repeat","stroke-size","stroke-width","tab-size","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration-skip","text-decoration-skip-box","text-decoration-skip-inset","text-decoration-skip-self","text-decoration-skip-spaces","text-edge","text-emphasis-color","text-emphasis-position","text-emphasis-skip","text-emphasis-style","text-indent","text-justify","text-orientation","text-rendering","text-shadow","text-size-adjust","text-space-collapse","text-spacing","text-transform","text-underline-position","text-wrap","visibility","voice-balance","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","widows","word-boundary-detection","word-boundary-expansion","word-break","word-spacing","word-wrap","writing-mode"]),t=new Set(["align-content","align-items","align-self","alignment-baseline","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timeline","animation-timing-function","appearance","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-block","background-position-inline","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","baseline-source","block-step","block-step-align","block-step-insert","block-step-round","block-step-size","bookmark-label","bookmark-level","bookmark-state","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-clip","border-clip-bottom","border-clip-left","border-clip-right","border-clip-top","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-limit","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","clear","clip","clip-path","color-adjust","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-width","container","container-name","container-type","content","continue","copy-into","corner-shape","corners","counter-increment","counter-reset","cue","cue-after","cue-before","cx","cy","d","display","fill-break","fill-origin","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-defer","float-offset","float-reference","flood-color","flood-opacity","flow-from","flow-into","footnote-display","footnote-policy","gap","glyph-orientation-vertical","grid-auto-columns","grid-auto-rows","grid-column-gap","grid-gap","grid-row-gap","grid-template-columns","grid-template-rows","height","initial-letter","inline-sizing","input-security","isolation","justify-content","justify-items","justify-self","leading-trim","left","lighting-color","line-clamp","line-grid","margin","margin-bottom","margin-break","margin-left","margin-right","margin-top","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-image","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-height","max-lines","max-width","min-height","min-intrinsic-sizing","min-width","mix-blend-mode","nav-down","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","perspective","perspective-origin","place-content","position","r","region-fragment","resize","rest","rest-after","rest-before","right","row-gap","rx","ry","scroll-snap-type","shape-image-threshold","shape-inside","shape-margin","shape-outside","shape-padding","shape-subtract","spatial-navigation-action","spatial-navigation-contain","spatial-navigation-function","stop-color","stop-opacity","string-set","stroke-break","stroke-origin","table-layout","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-emphasis","text-group-align","text-overflow","text-space-trim","top","touch-action","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","user-select","vector-effect","vertical-align","voice-duration","width","will-change","wrap-after","wrap-before","wrap-flow","wrap-inside","wrap-through","x","y","z-index"]),creator=o=>{const i=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-unset-value",Declaration(o){if("unset"!==o.value.toLowerCase())return;let r=!1;e.has(o.prop.toLowerCase())?r="inherit":t.has(o.prop.toLowerCase())&&(r="initial"),r&&(o.cloneBefore({prop:o.prop,value:r}),i.preserve||o.remove())}}};creator.postcss=!0,module.exports=creator; diff --git a/plugins/postcss-unset-value/dist/index.d.ts b/plugins/postcss-unset-value/dist/index.d.ts index c211bb827..6d1a24cae 100644 --- a/plugins/postcss-unset-value/dist/index.d.ts +++ b/plugins/postcss-unset-value/dist/index.d.ts @@ -2,6 +2,7 @@ import type { PluginCreator } from 'postcss'; declare const creator: PluginCreator; export default creator; +export { creator as 'module.exports' } /** postcss-unset-value plugin options */ export declare type pluginOptions = { diff --git a/plugins/postcss-unset-value/dist/index.mjs b/plugins/postcss-unset-value/dist/index.mjs index 96b553904..ec81eb6f1 100644 --- a/plugins/postcss-unset-value/dist/index.mjs +++ b/plugins/postcss-unset-value/dist/index.mjs @@ -1 +1 @@ -const e=new Set(["block-ellipsis","border-boundary","border-collapse","border-spacing","box-snap","caption-side","caret","caret-shape","clip-rule","color","color-interpolation","color-interpolation-filters","cursor","direction","dominant-baseline","empty-cells","fill","fill-color","fill-image","fill-opacity","fill-position","fill-repeat","fill-rule","fill-size","font","font-family","font-feature-settings","font-kerning","font-language-override","font-palette","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-emoji","font-variant-ligatures","font-weight","forced-color-adjust","hyphenate-character","hyphenate-limit-chars","hyphenate-limit-last","hyphenate-limit-lines","hyphenate-limit-zone","hyphens","image-orientation","image-rendering","image-resolution","initial-letter-wrap","letter-spacing","line-break","line-height","line-padding","line-snap","list-style","list-style-image","list-style-position","list-style-type","marker","marker-end","marker-mid","marker-side","marker-start","orphans","overflow-wrap","paint-order","pointer-events","print-color-adjust","quotes","ruby-merge","ruby-overhang","ruby-position","shape-rendering","speak","speak-as","stroke","stroke-align","stroke-alignment","stroke-color","stroke-dash-corner","stroke-dash-justify","stroke-dashadjust","stroke-dasharray","stroke-dashcorner","stroke-dashoffset","stroke-image","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-position","stroke-repeat","stroke-size","stroke-width","tab-size","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration-skip","text-decoration-skip-box","text-decoration-skip-inset","text-decoration-skip-self","text-decoration-skip-spaces","text-edge","text-emphasis-color","text-emphasis-position","text-emphasis-skip","text-emphasis-style","text-indent","text-justify","text-orientation","text-rendering","text-shadow","text-size-adjust","text-space-collapse","text-spacing","text-transform","text-underline-position","text-wrap","visibility","voice-balance","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","widows","word-boundary-detection","word-boundary-expansion","word-break","word-spacing","word-wrap","writing-mode"]),t=new Set(["align-content","align-items","align-self","alignment-baseline","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timeline","animation-timing-function","appearance","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-block","background-position-inline","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","baseline-source","block-step","block-step-align","block-step-insert","block-step-round","block-step-size","bookmark-label","bookmark-level","bookmark-state","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-clip","border-clip-bottom","border-clip-left","border-clip-right","border-clip-top","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-limit","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","clear","clip","clip-path","color-adjust","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-width","container","container-name","container-type","content","continue","copy-into","corner-shape","corners","counter-increment","counter-reset","cue","cue-after","cue-before","cx","cy","d","display","fill-break","fill-origin","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-defer","float-offset","float-reference","flood-color","flood-opacity","flow-from","flow-into","footnote-display","footnote-policy","gap","glyph-orientation-vertical","grid-auto-columns","grid-auto-rows","grid-column-gap","grid-gap","grid-row-gap","grid-template-columns","grid-template-rows","height","initial-letter","inline-sizing","input-security","isolation","justify-content","justify-items","justify-self","leading-trim","left","lighting-color","line-clamp","line-grid","margin","margin-bottom","margin-break","margin-left","margin-right","margin-top","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-image","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-height","max-lines","max-width","min-height","min-intrinsic-sizing","min-width","mix-blend-mode","nav-down","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","perspective","perspective-origin","place-content","position","r","region-fragment","resize","rest","rest-after","rest-before","right","row-gap","rx","ry","scroll-snap-type","shape-image-threshold","shape-inside","shape-margin","shape-outside","shape-padding","shape-subtract","spatial-navigation-action","spatial-navigation-contain","spatial-navigation-function","stop-color","stop-opacity","string-set","stroke-break","stroke-origin","table-layout","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-emphasis","text-group-align","text-overflow","text-space-trim","top","touch-action","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","user-select","vector-effect","vertical-align","voice-duration","width","will-change","wrap-after","wrap-before","wrap-flow","wrap-inside","wrap-through","x","y","z-index"]),creator=o=>{const i=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-unset-value",Declaration(o){if("unset"!==o.value.toLowerCase())return;let r=!1;e.has(o.prop.toLowerCase())?r="inherit":t.has(o.prop.toLowerCase())&&(r="initial"),r&&(o.cloneBefore({prop:o.prop,value:r}),i.preserve||o.remove())}}};creator.postcss=!0;export{creator as default}; +const e=new Set(["block-ellipsis","border-boundary","border-collapse","border-spacing","box-snap","caption-side","caret","caret-shape","clip-rule","color","color-interpolation","color-interpolation-filters","cursor","direction","dominant-baseline","empty-cells","fill","fill-color","fill-image","fill-opacity","fill-position","fill-repeat","fill-rule","fill-size","font","font-family","font-feature-settings","font-kerning","font-language-override","font-palette","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-emoji","font-variant-ligatures","font-weight","forced-color-adjust","hyphenate-character","hyphenate-limit-chars","hyphenate-limit-last","hyphenate-limit-lines","hyphenate-limit-zone","hyphens","image-orientation","image-rendering","image-resolution","initial-letter-wrap","letter-spacing","line-break","line-height","line-padding","line-snap","list-style","list-style-image","list-style-position","list-style-type","marker","marker-end","marker-mid","marker-side","marker-start","orphans","overflow-wrap","paint-order","pointer-events","print-color-adjust","quotes","ruby-merge","ruby-overhang","ruby-position","shape-rendering","speak","speak-as","stroke","stroke-align","stroke-alignment","stroke-color","stroke-dash-corner","stroke-dash-justify","stroke-dashadjust","stroke-dasharray","stroke-dashcorner","stroke-dashoffset","stroke-image","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-position","stroke-repeat","stroke-size","stroke-width","tab-size","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration-skip","text-decoration-skip-box","text-decoration-skip-inset","text-decoration-skip-self","text-decoration-skip-spaces","text-edge","text-emphasis-color","text-emphasis-position","text-emphasis-skip","text-emphasis-style","text-indent","text-justify","text-orientation","text-rendering","text-shadow","text-size-adjust","text-space-collapse","text-spacing","text-transform","text-underline-position","text-wrap","visibility","voice-balance","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","widows","word-boundary-detection","word-boundary-expansion","word-break","word-spacing","word-wrap","writing-mode"]),t=new Set(["align-content","align-items","align-self","alignment-baseline","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timeline","animation-timing-function","appearance","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-block","background-position-inline","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","baseline-source","block-step","block-step-align","block-step-insert","block-step-round","block-step-size","bookmark-label","bookmark-level","bookmark-state","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-clip","border-clip-bottom","border-clip-left","border-clip-right","border-clip-top","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-limit","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","clear","clip","clip-path","color-adjust","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-width","container","container-name","container-type","content","continue","copy-into","corner-shape","corners","counter-increment","counter-reset","cue","cue-after","cue-before","cx","cy","d","display","fill-break","fill-origin","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-defer","float-offset","float-reference","flood-color","flood-opacity","flow-from","flow-into","footnote-display","footnote-policy","gap","glyph-orientation-vertical","grid-auto-columns","grid-auto-rows","grid-column-gap","grid-gap","grid-row-gap","grid-template-columns","grid-template-rows","height","initial-letter","inline-sizing","input-security","isolation","justify-content","justify-items","justify-self","leading-trim","left","lighting-color","line-clamp","line-grid","margin","margin-bottom","margin-break","margin-left","margin-right","margin-top","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-image","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-height","max-lines","max-width","min-height","min-intrinsic-sizing","min-width","mix-blend-mode","nav-down","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","perspective","perspective-origin","place-content","position","r","region-fragment","resize","rest","rest-after","rest-before","right","row-gap","rx","ry","scroll-snap-type","shape-image-threshold","shape-inside","shape-margin","shape-outside","shape-padding","shape-subtract","spatial-navigation-action","spatial-navigation-contain","spatial-navigation-function","stop-color","stop-opacity","string-set","stroke-break","stroke-origin","table-layout","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-emphasis","text-group-align","text-overflow","text-space-trim","top","touch-action","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","user-select","vector-effect","vertical-align","voice-duration","width","will-change","wrap-after","wrap-before","wrap-flow","wrap-inside","wrap-through","x","y","z-index"]),creator=o=>{const i=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-unset-value",Declaration(o){if("unset"!==o.value.toLowerCase())return;let r=!1;e.has(o.prop.toLowerCase())?r="inherit":t.has(o.prop.toLowerCase())&&(r="initial"),r&&(o.cloneBefore({prop:o.prop,value:r}),i.preserve||o.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"}; diff --git a/plugins/postcss-unset-value/package.json b/plugins/postcss-unset-value/package.json index e0e542eba..4dbca159a 100644 --- a/plugins/postcss-unset-value/package.json +++ b/plugins/postcss-unset-value/package.json @@ -25,20 +25,14 @@ } ], "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "type": "module", - "main": "dist/index.cjs", "module": "dist/index.mjs", "exports": { ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" - }, - "require": { - "default": "./dist/index.cjs" - } + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" } }, "files": [ diff --git a/plugins/postcss-unset-value/src/index.ts b/plugins/postcss-unset-value/src/index.ts index 089513340..d3e556919 100644 --- a/plugins/postcss-unset-value/src/index.ts +++ b/plugins/postcss-unset-value/src/index.ts @@ -41,4 +41,5 @@ const creator: PluginCreator = (opts?: pluginOptions) => { creator.postcss = true; export default creator; +export { creator as 'module.exports' }; diff --git a/rollup/default.mjs b/rollup/default.mjs index 5eab1e147..9ef84c3ae 100644 --- a/rollup/default.mjs +++ b/rollup/default.mjs @@ -25,20 +25,22 @@ if (packageInfo.name === '@csstools/postcss-tape') { const presets = []; if (isTypescript) { - if (packageInfo.main || packageInfo.module) { - presets.push(...packageTypescript({nodeCoverageDisable: nodeCoverageDisable})); + if (packageInfo.exports) { + presets.push(...packageTypescript({ + nodeCoverageDisable: nodeCoverageDisable, + })); } - if (packageInfo.exports && ('./browser' in packageInfo.exports)) { + if (packageInfo.exports && ('./browser' in Object(packageInfo.exports))) { // Browser script remain javascript as it's simpler to go old school JS in regular JS. presets.push(...browserJavascript()); } } else { - if (packageInfo.main || packageInfo.module) { + if (packageInfo.exports) { presets.push(...packageJavascript()); } - if (packageInfo.exports && ('./browser' in packageInfo.exports)) { + if (packageInfo.exports && ('./browser' in Object(packageInfo.exports))) { presets.push(...browserJavascript()); } } diff --git a/rollup/presets/package-javascript.mjs b/rollup/presets/package-javascript.mjs index a78ef6e37..3de32d3c3 100644 --- a/rollup/presets/package-javascript.mjs +++ b/rollup/presets/package-javascript.mjs @@ -6,7 +6,6 @@ export function packageJavascript() { { input: 'src/index.js', output: [ - { file: 'dist/index.cjs', format: 'cjs', sourcemap: false, exports: 'auto' }, { file: 'dist/index.mjs', format: 'esm', sourcemap: false, exports: 'auto' }, ], external: externalsForPlugin, diff --git a/rollup/presets/package-typescript.mjs b/rollup/presets/package-typescript.mjs index e1884af4b..e76047dff 100644 --- a/rollup/presets/package-typescript.mjs +++ b/rollup/presets/package-typescript.mjs @@ -6,33 +6,8 @@ import { apiExtractor } from '../transforms/api-extractor.mjs'; import { nodeCoverageDisable } from '../transforms/node-coverage-disable.mjs'; import { move } from '../transforms/move.mjs'; -export function packageTypescript(options) { - options = options || {}; +export function packageTypescript(options = {}) { return [ - { - input: path.join('src', 'index.ts'), - output: [ - { file: path.join('dist', 'index.cjs'), format: 'cjs', sourcemap: false, exports: 'auto' }, - ], - external: externalsForPlugin, - plugins: [ - typescript({ - tsconfig: './tsconfig.json', - declaration: false, - declarationDir: undefined, - noEmit: false, - noEmitOnError: true, - }), - terser({ - compress: { - reduce_funcs: false, // https://github.com/terser/terser/issues/1305 - }, - keep_classnames: true, - keep_fnames: true, - }), - options.nodeCoverageDisable ? nodeCoverageDisable() : undefined, - ], - }, { input: path.join('src', 'index.ts'), output: [ diff --git a/rollup/transforms/api-extractor.mjs b/rollup/transforms/api-extractor.mjs index 44793aa0f..486daaa8d 100644 --- a/rollup/transforms/api-extractor.mjs +++ b/rollup/transforms/api-extractor.mjs @@ -24,6 +24,10 @@ export function apiExtractor() { await fs.writeFile(extractorConfig.apiJsonFilePath, JSON.stringify(api, null, 2)); } + let types = await fs.readFile(extractorConfig.untrimmedFilePath, 'utf-8'); + types = types.replaceAll('as module.exports', 'as \'module.exports\''); + await fs.writeFile(extractorConfig.untrimmedFilePath, types, 'utf-8'); + await fs.rm(path.join('dist', '_types'), { recursive: true, force: true }); }, }; diff --git a/tsconfig.json b/tsconfig.json index 1fdb5d013..3cf9c6313 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,8 +2,8 @@ "compilerOptions": { "moduleResolution": "bundler", "allowJs": false, - "target": "ES2022", - "lib": ["ES2022"], + "target": "ES2024", + "lib": ["ES2024"], "module": "ESNext", "declaration": true, "isolatedModules": true, From 9803cd538d4138c24c2c417f106a823238d4c80f Mon Sep 17 00:00:00 2001 From: Romain Menke Date: Tue, 13 Jan 2026 22:32:33 +0100 Subject: [PATCH 2/5] fix --- package-lock.json | 199 +++++++++--------- .../package.json | 1 - plugins-stylelint/at-risk/package.json | 1 + .../formatter-github/package.json | 1 + .../no-at-nest-rule/package.json | 1 + .../package.json | 1 + 6 files changed, 102 insertions(+), 102 deletions(-) diff --git a/package-lock.json b/package-lock.json index 82e414354..49992b3f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,9 +44,6 @@ "tslib": "^2.8.0", "typescript": "^5.9.3", "typescript-eslint": "^8.51.0" - }, - "engines": { - "node": "^14 || ^16 || >=18" } }, "cli/csstools-cli": { @@ -122,7 +119,7 @@ "@csstools/base-cli": "0.1.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" } }, "experimental/css-has-pseudo": { @@ -143,7 +140,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -172,7 +169,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -199,7 +196,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -9575,7 +9572,7 @@ ], "license": "MIT-0", "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -9596,7 +9593,7 @@ ], "license": "MIT", "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "@csstools/css-parser-algorithms": "^3.0.5", @@ -9618,7 +9615,7 @@ ], "license": "MIT-0", "engines": { - "node": ">=18" + "node": ">=20.19.0" } }, "packages/css-calc": { @@ -9636,7 +9633,7 @@ ], "license": "MIT", "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "@csstools/css-parser-algorithms": "^3.0.5", @@ -9662,7 +9659,7 @@ "@csstools/css-calc": "^2.1.4" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "@csstools/css-parser-algorithms": "^3.0.5", @@ -9684,7 +9681,7 @@ ], "license": "MIT", "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "@csstools/css-tokenizer": "^3.0.4" @@ -9730,7 +9727,7 @@ "postcss-parser-tests": "^8.8.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" } }, "packages/generate-test-cases": { @@ -9751,7 +9748,7 @@ "mdn-data": "^2.25.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" } }, "packages/media-query-list-parser": { @@ -9769,7 +9766,7 @@ ], "license": "MIT", "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "@csstools/css-parser-algorithms": "^3.0.5", @@ -9791,7 +9788,7 @@ ], "license": "MIT-0", "engines": { - "node": ">=18" + "node": ">=20.19.0" } }, "packages/postcss-tape": { @@ -9813,7 +9810,7 @@ "postcss-8.4": "npm:postcss@~8.4" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" } }, "packages/selector-resolve-nested": { @@ -9834,7 +9831,7 @@ "postcss-selector-parser": "^7.1.1" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss-selector-parser": "^7.1.1" @@ -9858,7 +9855,7 @@ "postcss-selector-parser": "^7.1.1" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss-selector-parser": "^7.1.1" @@ -9882,7 +9879,7 @@ "postcss": "^8.5.6" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -9914,7 +9911,7 @@ "open-props": "^1.7.17" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10039,7 +10036,7 @@ "stylelint-test-rule-node": "^0.4.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "stylelint": "^16.26.1" @@ -10064,7 +10061,7 @@ "stylelint": "^16.26.1" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "stylelint": "^16.26.1" @@ -10091,7 +10088,7 @@ "stylelint-test-rule-node": "^0.4.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4", @@ -10122,7 +10119,7 @@ "stylelint-test-rule-node": "^0.4.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "stylelint": "^16.26.1" @@ -10150,7 +10147,7 @@ "puppeteer": "^24.34.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10183,7 +10180,7 @@ "puppeteer": "^24.34.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10207,7 +10204,7 @@ "puppeteer": "^24.34.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10238,7 +10235,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10264,7 +10261,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10288,7 +10285,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10312,7 +10309,7 @@ "browserslist": "^4.28.1" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "browserslist": "^4.28.1", @@ -10343,7 +10340,7 @@ "puppeteer": "^24.34.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10375,7 +10372,7 @@ "postcss-lab-function": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10406,7 +10403,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10436,7 +10433,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10463,7 +10460,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10494,7 +10491,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10525,7 +10522,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10552,7 +10549,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10577,7 +10574,7 @@ "postcss-value-parser": "^4.2.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10607,7 +10604,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10638,7 +10635,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10667,7 +10664,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10698,7 +10695,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10727,7 +10724,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10751,7 +10748,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10782,7 +10779,7 @@ "style-dictionary-design-tokens-example": "^1.1.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10808,7 +10805,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10836,7 +10833,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10862,7 +10859,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10891,7 +10888,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10918,7 +10915,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10945,7 +10942,7 @@ "puppeteer": "^24.34.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -10972,7 +10969,7 @@ "puppeteer": "^24.34.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11000,7 +10997,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11029,7 +11026,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11052,7 +11049,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11079,7 +11076,7 @@ "postcss-custom-properties": "^14.0.6" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11110,7 +11107,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11141,7 +11138,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11170,7 +11167,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11197,7 +11194,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11221,7 +11218,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11250,7 +11247,7 @@ "puppeteer": "^24.34.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11280,7 +11277,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11312,7 +11309,7 @@ "puppeteer": "^24.34.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11338,7 +11335,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11362,7 +11359,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11410,7 +11407,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11437,7 +11434,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11465,7 +11462,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11496,7 +11493,7 @@ "puppeteer": "^24.34.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11525,7 +11522,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11552,7 +11549,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11580,7 +11577,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11609,7 +11606,7 @@ "puppeteer": "^24.34.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11636,7 +11633,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11667,7 +11664,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11693,7 +11690,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11719,7 +11716,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11743,7 +11740,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11770,7 +11767,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11798,7 +11795,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11824,7 +11821,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11853,7 +11850,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11882,7 +11879,7 @@ "postcss-import": "^16.1.1" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11913,7 +11910,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11941,7 +11938,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11968,7 +11965,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -11994,7 +11991,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -12023,7 +12020,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -12047,7 +12044,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -12076,7 +12073,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -12103,7 +12100,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -12131,7 +12128,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -12160,7 +12157,7 @@ "autoprefixer": "^10.4.23" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -12189,7 +12186,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -12218,7 +12215,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -12242,7 +12239,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" diff --git a/packages/css-syntax-patches-for-csstree/package.json b/packages/css-syntax-patches-for-csstree/package.json index 5c7321c91..95ab8737a 100644 --- a/packages/css-syntax-patches-for-csstree/package.json +++ b/packages/css-syntax-patches-for-csstree/package.json @@ -26,7 +26,6 @@ ], "main": "dist/index.json", "types": "dist/index.d.ts", - "exports": "./dist/index.json", "files": [ "CHANGELOG.md", "LICENSE.md", diff --git a/plugins-stylelint/at-risk/package.json b/plugins-stylelint/at-risk/package.json index f52aac1e4..70e0286d5 100644 --- a/plugins-stylelint/at-risk/package.json +++ b/plugins-stylelint/at-risk/package.json @@ -28,6 +28,7 @@ "node": ">=20.19.0" }, "type": "module", + "main": "index.mjs", "files": [ "LICENSE.md", "README.md", diff --git a/plugins-stylelint/formatter-github/package.json b/plugins-stylelint/formatter-github/package.json index 6b8b0ab49..d017dc58b 100644 --- a/plugins-stylelint/formatter-github/package.json +++ b/plugins-stylelint/formatter-github/package.json @@ -28,6 +28,7 @@ "node": ">=20.19.0" }, "type": "module", + "main": "index.mjs", "files": [ "LICENSE.md", "README.md", diff --git a/plugins-stylelint/no-at-nest-rule/package.json b/plugins-stylelint/no-at-nest-rule/package.json index 7af89d842..55bba770b 100644 --- a/plugins-stylelint/no-at-nest-rule/package.json +++ b/plugins-stylelint/no-at-nest-rule/package.json @@ -28,6 +28,7 @@ "node": ">=20.19.0" }, "type": "module", + "main": "index.mjs", "files": [ "LICENSE.md", "README.md", diff --git a/plugins-stylelint/no-invalid-at-import-rules-when-bundling/package.json b/plugins-stylelint/no-invalid-at-import-rules-when-bundling/package.json index 7ec59ab9d..8c84335a5 100644 --- a/plugins-stylelint/no-invalid-at-import-rules-when-bundling/package.json +++ b/plugins-stylelint/no-invalid-at-import-rules-when-bundling/package.json @@ -28,6 +28,7 @@ "node": ">=20.19.0" }, "type": "module", + "main": "index.mjs", "files": [ "LICENSE.md", "README.md", From 977d6647df327e02153117836d51a2fd923e74e3 Mon Sep 17 00:00:00 2001 From: Romain Menke Date: Tue, 13 Jan 2026 22:41:19 +0100 Subject: [PATCH 3/5] tweak --- e2e/package-lock.json | 16 ++++++++-------- e2e/typescript/esm--node-next/dist/index.js | 12 +++++++++++- e2e/webpack/bundle-through/index.cjs | 2 +- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/e2e/package-lock.json b/e2e/package-lock.json index 6710d3e6d..a37214f76 100644 --- a/e2e/package-lock.json +++ b/e2e/package-lock.json @@ -16,7 +16,7 @@ ] }, "../plugin-packs/postcss-preset-env": { - "version": "10.6.0", + "version": "10.6.1", "funding": [ { "type": "github", @@ -54,7 +54,7 @@ "@csstools/postcss-media-minmax": "^2.0.9", "@csstools/postcss-media-queries-aspect-ratio-number-values": "^3.0.5", "@csstools/postcss-nested-calc": "^4.0.0", - "@csstools/postcss-normalize-display-values": "^4.0.0", + "@csstools/postcss-normalize-display-values": "^4.0.1", "@csstools/postcss-oklab-function": "^4.0.12", "@csstools/postcss-position-area-property": "^1.0.0", "@csstools/postcss-progressive-custom-properties": "^4.2.1", @@ -105,10 +105,10 @@ "@csstools/pack-test": "*", "@csstools/postcss-bundler": "*", "@csstools/postcss-tape": "*", - "@webref/css": "8.1.2" + "@webref/css": "8.1.3" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -138,7 +138,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -170,7 +170,7 @@ "style-dictionary-design-tokens-example": "^1.1.0" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -198,7 +198,7 @@ "postcss-custom-properties": "^14.0.6" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" @@ -228,7 +228,7 @@ "@csstools/postcss-tape": "*" }, "engines": { - "node": ">=18" + "node": ">=20.19.0" }, "peerDependencies": { "postcss": "^8.4" diff --git a/e2e/typescript/esm--node-next/dist/index.js b/e2e/typescript/esm--node-next/dist/index.js index 534ee6670..5be92bbce 100644 --- a/e2e/typescript/esm--node-next/dist/index.js +++ b/e2e/typescript/esm--node-next/dist/index.js @@ -1,5 +1,15 @@ import assert from 'node:assert'; import plugin from 'postcss-preset-env'; -plugin({ preserve: true }); +plugin({ + preserve: true, + features: { + 'all-property': [true, { preserve: true }], + 'any-link-pseudo-class': [false, { preserve: true }], + 'cascade-layers': ['auto', { onImportLayerRule: 'warn' }], + 'color-function': { preserve: true, enableProgressiveCustomProperties: false }, + 'color-mix': false, + 'light-dark-function': true, + }, +}); assert.ok(plugin.postcss, 'should have "postcss flag"'); assert.equal(typeof plugin, 'function', 'should return a function'); diff --git a/e2e/webpack/bundle-through/index.cjs b/e2e/webpack/bundle-through/index.cjs index fca48a79e..c5dd8bdd3 100644 --- a/e2e/webpack/bundle-through/index.cjs +++ b/e2e/webpack/bundle-through/index.cjs @@ -1,5 +1,5 @@ const postcss = require('postcss'); -const postcssPresetEnv = require('postcss-preset-env'); +const postcssPresetEnv = require('postcss-preset-env').default; try { postcss([postcssPresetEnv({ From dec8fc596d5a291f0e84781775b76983868a5408 Mon Sep 17 00:00:00 2001 From: Romain Menke Date: Wed, 14 Jan 2026 07:48:43 +0100 Subject: [PATCH 4/5] fix --- .../css-syntax-patches-for-csstree/package.json | 16 ++++++++++++++-- .../tests/require.test.cjs | 8 ++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/css-syntax-patches-for-csstree/package.json b/packages/css-syntax-patches-for-csstree/package.json index 95ab8737a..59039e440 100644 --- a/packages/css-syntax-patches-for-csstree/package.json +++ b/packages/css-syntax-patches-for-csstree/package.json @@ -24,8 +24,20 @@ "url": "https://opencollective.com/csstools" } ], - "main": "dist/index.json", - "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "module": "./dist/index.json", + "require": "./dist/index.json", + "default": "./dist/index.json" + }, + "./dist/index.json": { + "types": "./dist/index.d.ts", + "module": "./dist/index.json", + "require": "./dist/index.json", + "default": "./dist/index.json" + } + }, "files": [ "CHANGELOG.md", "LICENSE.md", diff --git a/packages/css-syntax-patches-for-csstree/tests/require.test.cjs b/packages/css-syntax-patches-for-csstree/tests/require.test.cjs index ea253d960..44246d04d 100644 --- a/packages/css-syntax-patches-for-csstree/tests/require.test.cjs +++ b/packages/css-syntax-patches-for-csstree/tests/require.test.cjs @@ -1,4 +1,8 @@ const assert = require('node:assert'); -const syntax_patches = require('@csstools/css-syntax-patches-for-csstree'); +const syntax_patches_a = require('@csstools/css-syntax-patches-for-csstree'); -assert.ok(syntax_patches.next); +assert.ok(syntax_patches_a.next); + +const syntax_patches_b = require('@csstools/css-syntax-patches-for-csstree/dist/index.json'); + +assert.ok(syntax_patches_b.next); From cb6c5df91e306da79e890a2a1e178f3bf4e35844 Mon Sep 17 00:00:00 2001 From: Romain Menke Date: Wed, 14 Jan 2026 07:59:04 +0100 Subject: [PATCH 5/5] cleanup --- .github/bin/format-package-json.mjs | 3 --- experimental/css-has-pseudo/package.json | 1 - experimental/postcss-gradient-stop-increments/package.json | 1 - experimental/postcss-nesting/package.json | 1 - packages/base-cli/package.json | 1 - packages/cascade-layer-name-parser/package.json | 1 - packages/color-helpers/package.json | 1 - packages/css-calc/package.json | 1 - packages/css-color-parser/package.json | 1 - packages/css-parser-algorithms/package.json | 1 - packages/css-tokenizer/package.json | 1 - packages/media-query-list-parser/package.json | 1 - packages/pack-test/package.json | 1 - packages/postcss-tape/package.json | 1 - packages/selector-resolve-nested/package.json | 1 - packages/selector-specificity/package.json | 1 - packages/utilities/package.json | 1 - plugin-packs/postcss-bundler/package.json | 1 - plugin-packs/postcss-preset-env/package.json | 1 - plugins-stylelint/at-risk/package.json | 6 +++++- plugins-stylelint/formatter-github/package.json | 6 +++++- plugins-stylelint/no-at-nest-rule/package.json | 6 +++++- .../no-invalid-at-import-rules-when-bundling/package.json | 6 +++++- plugins/css-blank-pseudo/package.json | 1 - plugins/css-has-pseudo/package.json | 1 - plugins/css-prefers-color-scheme/package.json | 1 - plugins/postcss-alpha-function/package.json | 1 - plugins/postcss-attribute-case-insensitive/package.json | 1 - plugins/postcss-base-plugin/package.json | 1 - plugins/postcss-browser-comments/package.json | 1 - plugins/postcss-cascade-layers/package.json | 1 - .../postcss-color-function-display-p3-linear/package.json | 1 - plugins/postcss-color-function/package.json | 1 - plugins/postcss-color-functional-notation/package.json | 1 - plugins/postcss-color-hex-alpha/package.json | 1 - plugins/postcss-color-mix-function/package.json | 1 - .../package.json | 1 - plugins/postcss-color-rebeccapurple/package.json | 1 - plugins/postcss-conditional-values/package.json | 1 - plugins/postcss-content-alt-text/package.json | 1 - plugins/postcss-contrast-color-function/package.json | 1 - plugins/postcss-custom-media/package.json | 1 - plugins/postcss-custom-properties/package.json | 1 - plugins/postcss-custom-selectors/package.json | 1 - plugins/postcss-debug-logger/package.json | 1 - plugins/postcss-design-tokens/package.json | 1 - plugins/postcss-dir-pseudo-class/package.json | 1 - plugins/postcss-double-position-gradients/package.json | 1 - plugins/postcss-env-function/package.json | 1 - plugins/postcss-exponential-functions/package.json | 1 - plugins/postcss-extract/package.json | 1 - plugins/postcss-focus-visible/package.json | 1 - plugins/postcss-focus-within/package.json | 1 - plugins/postcss-font-format-keywords/package.json | 1 - plugins/postcss-gamut-mapping/package.json | 1 - plugins/postcss-gap-properties/package.json | 1 - plugins/postcss-global-data/package.json | 1 - plugins/postcss-gradients-interpolation-method/package.json | 1 - plugins/postcss-hwb-function/package.json | 1 - plugins/postcss-ic-unit/package.json | 1 - plugins/postcss-image-set-function/package.json | 1 - plugins/postcss-initial/package.json | 1 - plugins/postcss-is-pseudo-class/package.json | 1 - plugins/postcss-lab-function/package.json | 1 - plugins/postcss-light-dark-function/package.json | 1 - plugins/postcss-logical-float-and-clear/package.json | 1 - plugins/postcss-logical-overflow/package.json | 1 - plugins/postcss-logical-overscroll-behavior/package.json | 1 - plugins/postcss-logical-resize/package.json | 1 - plugins/postcss-logical-viewport-units/package.json | 1 - plugins/postcss-logical/package.json | 1 - plugins/postcss-media-minmax/package.json | 1 - .../package.json | 1 - plugins/postcss-minify/package.json | 1 - plugins/postcss-nested-calc/package.json | 1 - plugins/postcss-nesting/package.json | 1 - plugins/postcss-normalize-display-values/package.json | 1 - plugins/postcss-oklab-function/package.json | 1 - plugins/postcss-overflow-shorthand/package.json | 1 - plugins/postcss-place/package.json | 1 - plugins/postcss-position-area-property/package.json | 1 - plugins/postcss-progressive-custom-properties/package.json | 1 - plugins/postcss-property-rule-prelude-list/package.json | 1 - plugins/postcss-pseudo-class-any-link/package.json | 1 - plugins/postcss-random-function/package.json | 1 - plugins/postcss-rebase-url/package.json | 1 - plugins/postcss-relative-color-syntax/package.json | 1 - plugins/postcss-rewrite-url/package.json | 1 - plugins/postcss-scope-pseudo-class/package.json | 1 - plugins/postcss-selector-not/package.json | 1 - plugins/postcss-sign-functions/package.json | 1 - plugins/postcss-slow-plugins/package.json | 1 - plugins/postcss-stepped-value-functions/package.json | 1 - .../package.json | 1 - plugins/postcss-system-ui-font-family/package.json | 1 - plugins/postcss-text-decoration-shorthand/package.json | 1 - plugins/postcss-todo-or-die/package.json | 1 - plugins/postcss-trigonometric-functions/package.json | 1 - plugins/postcss-unset-value/package.json | 1 - 99 files changed, 20 insertions(+), 101 deletions(-) diff --git a/.github/bin/format-package-json.mjs b/.github/bin/format-package-json.mjs index 47c912d36..d630d3904 100644 --- a/.github/bin/format-package-json.mjs +++ b/.github/bin/format-package-json.mjs @@ -90,10 +90,7 @@ const formatted = {}; // Exports and packaged { - formatted.main = packageJSONInfo.main; delete packageJSONInfo.main; - - formatted.module = packageJSONInfo.module; delete packageJSONInfo.module; formatted.bin = packageJSONInfo.bin; diff --git a/experimental/css-has-pseudo/package.json b/experimental/css-has-pseudo/package.json index 13e1cc60a..f322e2960 100644 --- a/experimental/css-has-pseudo/package.json +++ b/experimental/css-has-pseudo/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/experimental/postcss-gradient-stop-increments/package.json b/experimental/postcss-gradient-stop-increments/package.json index 18634fcdc..0dd75154f 100644 --- a/experimental/postcss-gradient-stop-increments/package.json +++ b/experimental/postcss-gradient-stop-increments/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/experimental/postcss-nesting/package.json b/experimental/postcss-nesting/package.json index 76aa287e3..0b314530f 100644 --- a/experimental/postcss-nesting/package.json +++ b/experimental/postcss-nesting/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/base-cli/package.json b/packages/base-cli/package.json index b4559089c..41a75b0a9 100644 --- a/packages/base-cli/package.json +++ b/packages/base-cli/package.json @@ -19,7 +19,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/cascade-layer-name-parser/package.json b/packages/cascade-layer-name-parser/package.json index c0c111a23..45bad66ac 100644 --- a/packages/cascade-layer-name-parser/package.json +++ b/packages/cascade-layer-name-parser/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/color-helpers/package.json b/packages/color-helpers/package.json index 7c6e689c6..f9c8061b2 100644 --- a/packages/color-helpers/package.json +++ b/packages/color-helpers/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/css-calc/package.json b/packages/css-calc/package.json index 106355a20..992c08175 100644 --- a/packages/css-calc/package.json +++ b/packages/css-calc/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/css-color-parser/package.json b/packages/css-color-parser/package.json index 9880743ca..da5a7c801 100644 --- a/packages/css-color-parser/package.json +++ b/packages/css-color-parser/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/css-parser-algorithms/package.json b/packages/css-parser-algorithms/package.json index 928f19ed5..598aacdc6 100644 --- a/packages/css-parser-algorithms/package.json +++ b/packages/css-parser-algorithms/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/css-tokenizer/package.json b/packages/css-tokenizer/package.json index 3bf2288c2..1fa19b3fe 100644 --- a/packages/css-tokenizer/package.json +++ b/packages/css-tokenizer/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/media-query-list-parser/package.json b/packages/media-query-list-parser/package.json index d53b54d9a..bcd85f462 100644 --- a/packages/media-query-list-parser/package.json +++ b/packages/media-query-list-parser/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/pack-test/package.json b/packages/pack-test/package.json index 497a84cc3..8ef4d4d04 100644 --- a/packages/pack-test/package.json +++ b/packages/pack-test/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/postcss-tape/package.json b/packages/postcss-tape/package.json index b89414728..eaebe9f0a 100644 --- a/packages/postcss-tape/package.json +++ b/packages/postcss-tape/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/selector-resolve-nested/package.json b/packages/selector-resolve-nested/package.json index 5361b12c2..c46312dc2 100644 --- a/packages/selector-resolve-nested/package.json +++ b/packages/selector-resolve-nested/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/selector-specificity/package.json b/packages/selector-specificity/package.json index 78e76e1ce..e3bfdf1fe 100644 --- a/packages/selector-specificity/package.json +++ b/packages/selector-specificity/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/utilities/package.json b/packages/utilities/package.json index d16731dc7..0cf425b26 100644 --- a/packages/utilities/package.json +++ b/packages/utilities/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugin-packs/postcss-bundler/package.json b/plugin-packs/postcss-bundler/package.json index c27a5f610..27901aa2b 100644 --- a/plugin-packs/postcss-bundler/package.json +++ b/plugin-packs/postcss-bundler/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugin-packs/postcss-preset-env/package.json b/plugin-packs/postcss-preset-env/package.json index 4c447073e..775ad8dbd 100644 --- a/plugin-packs/postcss-preset-env/package.json +++ b/plugin-packs/postcss-preset-env/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins-stylelint/at-risk/package.json b/plugins-stylelint/at-risk/package.json index 70e0286d5..b6a17aa4c 100644 --- a/plugins-stylelint/at-risk/package.json +++ b/plugins-stylelint/at-risk/package.json @@ -28,7 +28,11 @@ "node": ">=20.19.0" }, "type": "module", - "main": "index.mjs", + "exports": { + ".": { + "default": "./index.mjs" + } + }, "files": [ "LICENSE.md", "README.md", diff --git a/plugins-stylelint/formatter-github/package.json b/plugins-stylelint/formatter-github/package.json index d017dc58b..3a775b08b 100644 --- a/plugins-stylelint/formatter-github/package.json +++ b/plugins-stylelint/formatter-github/package.json @@ -28,7 +28,11 @@ "node": ">=20.19.0" }, "type": "module", - "main": "index.mjs", + "exports": { + ".": { + "default": "./index.mjs" + } + }, "files": [ "LICENSE.md", "README.md", diff --git a/plugins-stylelint/no-at-nest-rule/package.json b/plugins-stylelint/no-at-nest-rule/package.json index 55bba770b..0d6f4caac 100644 --- a/plugins-stylelint/no-at-nest-rule/package.json +++ b/plugins-stylelint/no-at-nest-rule/package.json @@ -28,7 +28,11 @@ "node": ">=20.19.0" }, "type": "module", - "main": "index.mjs", + "exports": { + ".": { + "default": "./index.mjs" + } + }, "files": [ "LICENSE.md", "README.md", diff --git a/plugins-stylelint/no-invalid-at-import-rules-when-bundling/package.json b/plugins-stylelint/no-invalid-at-import-rules-when-bundling/package.json index 8c84335a5..7ea4fa43a 100644 --- a/plugins-stylelint/no-invalid-at-import-rules-when-bundling/package.json +++ b/plugins-stylelint/no-invalid-at-import-rules-when-bundling/package.json @@ -28,7 +28,11 @@ "node": ">=20.19.0" }, "type": "module", - "main": "index.mjs", + "exports": { + ".": { + "default": "./index.mjs" + } + }, "files": [ "LICENSE.md", "README.md", diff --git a/plugins/css-blank-pseudo/package.json b/plugins/css-blank-pseudo/package.json index 923a8e0e2..5429d10db 100644 --- a/plugins/css-blank-pseudo/package.json +++ b/plugins/css-blank-pseudo/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/css-has-pseudo/package.json b/plugins/css-has-pseudo/package.json index d5472e3db..426c7a5a2 100644 --- a/plugins/css-has-pseudo/package.json +++ b/plugins/css-has-pseudo/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/css-prefers-color-scheme/package.json b/plugins/css-prefers-color-scheme/package.json index 6f7dadd39..05cdb49c4 100644 --- a/plugins/css-prefers-color-scheme/package.json +++ b/plugins/css-prefers-color-scheme/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-alpha-function/package.json b/plugins/postcss-alpha-function/package.json index b907ab700..31d628186 100644 --- a/plugins/postcss-alpha-function/package.json +++ b/plugins/postcss-alpha-function/package.json @@ -23,7 +23,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-attribute-case-insensitive/package.json b/plugins/postcss-attribute-case-insensitive/package.json index e46dea67b..90b4ca896 100644 --- a/plugins/postcss-attribute-case-insensitive/package.json +++ b/plugins/postcss-attribute-case-insensitive/package.json @@ -31,7 +31,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-base-plugin/package.json b/plugins/postcss-base-plugin/package.json index d18a6d8a0..471d9529f 100644 --- a/plugins/postcss-base-plugin/package.json +++ b/plugins/postcss-base-plugin/package.json @@ -29,7 +29,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-browser-comments/package.json b/plugins/postcss-browser-comments/package.json index 13ee6b1dc..fbeeae131 100644 --- a/plugins/postcss-browser-comments/package.json +++ b/plugins/postcss-browser-comments/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-cascade-layers/package.json b/plugins/postcss-cascade-layers/package.json index 1d4c16491..5efc05059 100644 --- a/plugins/postcss-cascade-layers/package.json +++ b/plugins/postcss-cascade-layers/package.json @@ -36,7 +36,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-color-function-display-p3-linear/package.json b/plugins/postcss-color-function-display-p3-linear/package.json index 67590135c..f521f3b5f 100644 --- a/plugins/postcss-color-function-display-p3-linear/package.json +++ b/plugins/postcss-color-function-display-p3-linear/package.json @@ -23,7 +23,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-color-function/package.json b/plugins/postcss-color-function/package.json index a019e0c50..1aed52cbd 100644 --- a/plugins/postcss-color-function/package.json +++ b/plugins/postcss-color-function/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-color-functional-notation/package.json b/plugins/postcss-color-functional-notation/package.json index 702b536b8..0463b8ca5 100644 --- a/plugins/postcss-color-functional-notation/package.json +++ b/plugins/postcss-color-functional-notation/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-color-hex-alpha/package.json b/plugins/postcss-color-hex-alpha/package.json index c4ee67822..665075349 100644 --- a/plugins/postcss-color-hex-alpha/package.json +++ b/plugins/postcss-color-hex-alpha/package.json @@ -35,7 +35,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-color-mix-function/package.json b/plugins/postcss-color-mix-function/package.json index 7b76abf23..e3b398a66 100644 --- a/plugins/postcss-color-mix-function/package.json +++ b/plugins/postcss-color-mix-function/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-color-mix-variadic-function-arguments/package.json b/plugins/postcss-color-mix-variadic-function-arguments/package.json index d5c34cc0a..bcddcf790 100644 --- a/plugins/postcss-color-mix-variadic-function-arguments/package.json +++ b/plugins/postcss-color-mix-variadic-function-arguments/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-color-rebeccapurple/package.json b/plugins/postcss-color-rebeccapurple/package.json index f585a6d4a..1da321f00 100644 --- a/plugins/postcss-color-rebeccapurple/package.json +++ b/plugins/postcss-color-rebeccapurple/package.json @@ -35,7 +35,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-conditional-values/package.json b/plugins/postcss-conditional-values/package.json index c5e0a2a45..ec9f6627b 100644 --- a/plugins/postcss-conditional-values/package.json +++ b/plugins/postcss-conditional-values/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-content-alt-text/package.json b/plugins/postcss-content-alt-text/package.json index b39e33fa3..003a98089 100644 --- a/plugins/postcss-content-alt-text/package.json +++ b/plugins/postcss-content-alt-text/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-contrast-color-function/package.json b/plugins/postcss-contrast-color-function/package.json index 171e8ea53..251a042b9 100644 --- a/plugins/postcss-contrast-color-function/package.json +++ b/plugins/postcss-contrast-color-function/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-custom-media/package.json b/plugins/postcss-custom-media/package.json index 4e6a5ec4e..0d92351d6 100644 --- a/plugins/postcss-custom-media/package.json +++ b/plugins/postcss-custom-media/package.json @@ -35,7 +35,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-custom-properties/package.json b/plugins/postcss-custom-properties/package.json index 7eac0a4fc..f0f08cb42 100644 --- a/plugins/postcss-custom-properties/package.json +++ b/plugins/postcss-custom-properties/package.json @@ -21,7 +21,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-custom-selectors/package.json b/plugins/postcss-custom-selectors/package.json index e77a57394..8b7209fea 100644 --- a/plugins/postcss-custom-selectors/package.json +++ b/plugins/postcss-custom-selectors/package.json @@ -38,7 +38,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-debug-logger/package.json b/plugins/postcss-debug-logger/package.json index aa4b881dc..8f174f99c 100644 --- a/plugins/postcss-debug-logger/package.json +++ b/plugins/postcss-debug-logger/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-design-tokens/package.json b/plugins/postcss-design-tokens/package.json index 81f84ec57..b98c10024 100644 --- a/plugins/postcss-design-tokens/package.json +++ b/plugins/postcss-design-tokens/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-dir-pseudo-class/package.json b/plugins/postcss-dir-pseudo-class/package.json index 5aae18f87..44b1a2b0a 100644 --- a/plugins/postcss-dir-pseudo-class/package.json +++ b/plugins/postcss-dir-pseudo-class/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-double-position-gradients/package.json b/plugins/postcss-double-position-gradients/package.json index 044b0cc0e..11d180656 100644 --- a/plugins/postcss-double-position-gradients/package.json +++ b/plugins/postcss-double-position-gradients/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-env-function/package.json b/plugins/postcss-env-function/package.json index 7933022ab..0784a31d1 100644 --- a/plugins/postcss-env-function/package.json +++ b/plugins/postcss-env-function/package.json @@ -17,7 +17,6 @@ "engines": { "node": ">=20.19.0" }, - "module": "dist/index.mjs", "exports": { ".": { "default": "./dist/index.mjs" diff --git a/plugins/postcss-exponential-functions/package.json b/plugins/postcss-exponential-functions/package.json index fbab82789..373a91b24 100644 --- a/plugins/postcss-exponential-functions/package.json +++ b/plugins/postcss-exponential-functions/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-extract/package.json b/plugins/postcss-extract/package.json index 0d374d879..d14083662 100644 --- a/plugins/postcss-extract/package.json +++ b/plugins/postcss-extract/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-focus-visible/package.json b/plugins/postcss-focus-visible/package.json index a2df7560a..e991ddad4 100644 --- a/plugins/postcss-focus-visible/package.json +++ b/plugins/postcss-focus-visible/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-focus-within/package.json b/plugins/postcss-focus-within/package.json index 2f0e30b2a..20b7132e0 100644 --- a/plugins/postcss-focus-within/package.json +++ b/plugins/postcss-focus-within/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-font-format-keywords/package.json b/plugins/postcss-font-format-keywords/package.json index e6eab72fd..675fb5765 100644 --- a/plugins/postcss-font-format-keywords/package.json +++ b/plugins/postcss-font-format-keywords/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-gamut-mapping/package.json b/plugins/postcss-gamut-mapping/package.json index 64262a7f3..82f511c47 100644 --- a/plugins/postcss-gamut-mapping/package.json +++ b/plugins/postcss-gamut-mapping/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-gap-properties/package.json b/plugins/postcss-gap-properties/package.json index 397d4eade..b5221aad5 100644 --- a/plugins/postcss-gap-properties/package.json +++ b/plugins/postcss-gap-properties/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-global-data/package.json b/plugins/postcss-global-data/package.json index 8b3c5c18c..02d4c391c 100644 --- a/plugins/postcss-global-data/package.json +++ b/plugins/postcss-global-data/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-gradients-interpolation-method/package.json b/plugins/postcss-gradients-interpolation-method/package.json index 7f0269a2e..02940eeff 100644 --- a/plugins/postcss-gradients-interpolation-method/package.json +++ b/plugins/postcss-gradients-interpolation-method/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-hwb-function/package.json b/plugins/postcss-hwb-function/package.json index 611e1fb16..69e9002c6 100644 --- a/plugins/postcss-hwb-function/package.json +++ b/plugins/postcss-hwb-function/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-ic-unit/package.json b/plugins/postcss-ic-unit/package.json index f4cdec320..1a5c09c10 100644 --- a/plugins/postcss-ic-unit/package.json +++ b/plugins/postcss-ic-unit/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-image-set-function/package.json b/plugins/postcss-image-set-function/package.json index 49aa64d24..c2ce11442 100644 --- a/plugins/postcss-image-set-function/package.json +++ b/plugins/postcss-image-set-function/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-initial/package.json b/plugins/postcss-initial/package.json index 7e5bc1355..f34a3277d 100644 --- a/plugins/postcss-initial/package.json +++ b/plugins/postcss-initial/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-is-pseudo-class/package.json b/plugins/postcss-is-pseudo-class/package.json index 54ac98f75..d9d4afabc 100644 --- a/plugins/postcss-is-pseudo-class/package.json +++ b/plugins/postcss-is-pseudo-class/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-lab-function/package.json b/plugins/postcss-lab-function/package.json index e2684272d..658b84c59 100644 --- a/plugins/postcss-lab-function/package.json +++ b/plugins/postcss-lab-function/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-light-dark-function/package.json b/plugins/postcss-light-dark-function/package.json index 2418c7300..4542dccdb 100644 --- a/plugins/postcss-light-dark-function/package.json +++ b/plugins/postcss-light-dark-function/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-logical-float-and-clear/package.json b/plugins/postcss-logical-float-and-clear/package.json index b94068860..107453a52 100644 --- a/plugins/postcss-logical-float-and-clear/package.json +++ b/plugins/postcss-logical-float-and-clear/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-logical-overflow/package.json b/plugins/postcss-logical-overflow/package.json index aabfa7cf7..79a99e8f6 100644 --- a/plugins/postcss-logical-overflow/package.json +++ b/plugins/postcss-logical-overflow/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-logical-overscroll-behavior/package.json b/plugins/postcss-logical-overscroll-behavior/package.json index 58f7e7e68..09c6c3dd6 100644 --- a/plugins/postcss-logical-overscroll-behavior/package.json +++ b/plugins/postcss-logical-overscroll-behavior/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-logical-resize/package.json b/plugins/postcss-logical-resize/package.json index 761e37405..0ddafd007 100644 --- a/plugins/postcss-logical-resize/package.json +++ b/plugins/postcss-logical-resize/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-logical-viewport-units/package.json b/plugins/postcss-logical-viewport-units/package.json index 5ace6984b..ef44a6254 100644 --- a/plugins/postcss-logical-viewport-units/package.json +++ b/plugins/postcss-logical-viewport-units/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-logical/package.json b/plugins/postcss-logical/package.json index 4b99f013d..2880f2020 100644 --- a/plugins/postcss-logical/package.json +++ b/plugins/postcss-logical/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-media-minmax/package.json b/plugins/postcss-media-minmax/package.json index 7fa5ba09a..e7d1ed777 100644 --- a/plugins/postcss-media-minmax/package.json +++ b/plugins/postcss-media-minmax/package.json @@ -31,7 +31,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-media-queries-aspect-ratio-number-values/package.json b/plugins/postcss-media-queries-aspect-ratio-number-values/package.json index 2ba6ce21e..d687975ea 100644 --- a/plugins/postcss-media-queries-aspect-ratio-number-values/package.json +++ b/plugins/postcss-media-queries-aspect-ratio-number-values/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-minify/package.json b/plugins/postcss-minify/package.json index 96934cd84..eac9af386 100644 --- a/plugins/postcss-minify/package.json +++ b/plugins/postcss-minify/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-nested-calc/package.json b/plugins/postcss-nested-calc/package.json index f81f0533c..3020e726c 100644 --- a/plugins/postcss-nested-calc/package.json +++ b/plugins/postcss-nested-calc/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-nesting/package.json b/plugins/postcss-nesting/package.json index b4f96bc5e..60fb94d95 100644 --- a/plugins/postcss-nesting/package.json +++ b/plugins/postcss-nesting/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "jsdelivr": "dist/index.mjs", "unpkg": "dist/index.mjs", "exports": { diff --git a/plugins/postcss-normalize-display-values/package.json b/plugins/postcss-normalize-display-values/package.json index 2b590d862..618388a72 100644 --- a/plugins/postcss-normalize-display-values/package.json +++ b/plugins/postcss-normalize-display-values/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-oklab-function/package.json b/plugins/postcss-oklab-function/package.json index 057b27587..ae859ad2e 100644 --- a/plugins/postcss-oklab-function/package.json +++ b/plugins/postcss-oklab-function/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-overflow-shorthand/package.json b/plugins/postcss-overflow-shorthand/package.json index 7e8fbefb5..b04193601 100644 --- a/plugins/postcss-overflow-shorthand/package.json +++ b/plugins/postcss-overflow-shorthand/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-place/package.json b/plugins/postcss-place/package.json index 871977e25..2077014d5 100644 --- a/plugins/postcss-place/package.json +++ b/plugins/postcss-place/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-position-area-property/package.json b/plugins/postcss-position-area-property/package.json index 17b33ff2f..42478496a 100644 --- a/plugins/postcss-position-area-property/package.json +++ b/plugins/postcss-position-area-property/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-progressive-custom-properties/package.json b/plugins/postcss-progressive-custom-properties/package.json index f4fbbd0fd..de69d2b7b 100644 --- a/plugins/postcss-progressive-custom-properties/package.json +++ b/plugins/postcss-progressive-custom-properties/package.json @@ -18,7 +18,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-property-rule-prelude-list/package.json b/plugins/postcss-property-rule-prelude-list/package.json index 44ab63b3c..90aa37a81 100644 --- a/plugins/postcss-property-rule-prelude-list/package.json +++ b/plugins/postcss-property-rule-prelude-list/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-pseudo-class-any-link/package.json b/plugins/postcss-pseudo-class-any-link/package.json index cc025e60e..95b2bed05 100644 --- a/plugins/postcss-pseudo-class-any-link/package.json +++ b/plugins/postcss-pseudo-class-any-link/package.json @@ -32,7 +32,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-random-function/package.json b/plugins/postcss-random-function/package.json index d14799af2..f9a40ea04 100644 --- a/plugins/postcss-random-function/package.json +++ b/plugins/postcss-random-function/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-rebase-url/package.json b/plugins/postcss-rebase-url/package.json index fe157d2e1..2dc4992bd 100644 --- a/plugins/postcss-rebase-url/package.json +++ b/plugins/postcss-rebase-url/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-relative-color-syntax/package.json b/plugins/postcss-relative-color-syntax/package.json index 41d693671..ceb5357d0 100644 --- a/plugins/postcss-relative-color-syntax/package.json +++ b/plugins/postcss-relative-color-syntax/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-rewrite-url/package.json b/plugins/postcss-rewrite-url/package.json index 6313cc2b7..60ead3be1 100644 --- a/plugins/postcss-rewrite-url/package.json +++ b/plugins/postcss-rewrite-url/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-scope-pseudo-class/package.json b/plugins/postcss-scope-pseudo-class/package.json index ca30783fb..f1f7e0343 100644 --- a/plugins/postcss-scope-pseudo-class/package.json +++ b/plugins/postcss-scope-pseudo-class/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-selector-not/package.json b/plugins/postcss-selector-not/package.json index 636de2b45..ce0e17415 100644 --- a/plugins/postcss-selector-not/package.json +++ b/plugins/postcss-selector-not/package.json @@ -31,7 +31,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-sign-functions/package.json b/plugins/postcss-sign-functions/package.json index 8507116a4..1938f6b62 100644 --- a/plugins/postcss-sign-functions/package.json +++ b/plugins/postcss-sign-functions/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-slow-plugins/package.json b/plugins/postcss-slow-plugins/package.json index 4f8c7bb67..d3cb95314 100644 --- a/plugins/postcss-slow-plugins/package.json +++ b/plugins/postcss-slow-plugins/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-stepped-value-functions/package.json b/plugins/postcss-stepped-value-functions/package.json index 18493e9d4..02418590a 100644 --- a/plugins/postcss-stepped-value-functions/package.json +++ b/plugins/postcss-stepped-value-functions/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-syntax-descriptor-syntax-production/package.json b/plugins/postcss-syntax-descriptor-syntax-production/package.json index 0637cc6e3..612f25db0 100644 --- a/plugins/postcss-syntax-descriptor-syntax-production/package.json +++ b/plugins/postcss-syntax-descriptor-syntax-production/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-system-ui-font-family/package.json b/plugins/postcss-system-ui-font-family/package.json index a3fb1277f..928096a2d 100644 --- a/plugins/postcss-system-ui-font-family/package.json +++ b/plugins/postcss-system-ui-font-family/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-text-decoration-shorthand/package.json b/plugins/postcss-text-decoration-shorthand/package.json index 27b67886c..2456ae6b9 100644 --- a/plugins/postcss-text-decoration-shorthand/package.json +++ b/plugins/postcss-text-decoration-shorthand/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-todo-or-die/package.json b/plugins/postcss-todo-or-die/package.json index eaf3cad22..dd61ffe51 100644 --- a/plugins/postcss-todo-or-die/package.json +++ b/plugins/postcss-todo-or-die/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-trigonometric-functions/package.json b/plugins/postcss-trigonometric-functions/package.json index 42ba58417..a8fd1a3bf 100644 --- a/plugins/postcss-trigonometric-functions/package.json +++ b/plugins/postcss-trigonometric-functions/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/plugins/postcss-unset-value/package.json b/plugins/postcss-unset-value/package.json index 4dbca159a..d3d5be2dd 100644 --- a/plugins/postcss-unset-value/package.json +++ b/plugins/postcss-unset-value/package.json @@ -28,7 +28,6 @@ "node": ">=20.19.0" }, "type": "module", - "module": "dist/index.mjs", "exports": { ".": { "types": "./dist/index.d.ts",