| Server IP : 82.148.16.210 / Your IP : 216.73.216.32 Web Server : nginx/1.29.5 System : Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /srv/projects/env4/src/dev/frontend5/node_modules/postcss-reduce-initial/src/ |
Upload File : |
'use strict';
const { dirname } = require('path');
const browserslist = require('browserslist');
const { isSupported } = require('caniuse-api');
const fromInitial = require('./data/fromInitial.json');
const toInitial = require('./data/toInitial.json');
const ignoreProps = require('./lib/ignoreProps.js');
const initial = 'initial';
// In most of the browser including chrome the initial for `writing-mode` is not `horizontal-tb`. Ref https://github.com/cssnano/cssnano/pull/905
const defaultIgnoreProps = ignoreProps;
/**
* @typedef {{ overrideBrowserslist?: string | string[] }} AutoprefixerOptions
* @typedef {Pick<browserslist.Options, 'stats' | 'path' | 'env'>} BrowserslistOptions
* @typedef {{ignore?: string[]} & AutoprefixerOptions & BrowserslistOptions} Options
*/
/**
* @type {import('postcss').PluginCreator<Options>}
* @param {Options} options
* @return {import('postcss').Plugin}
*/
function pluginCreator(options = {}) {
return {
postcssPlugin: 'postcss-reduce-initial',
/**
* @param {import('postcss').Result & {opts: BrowserslistOptions & {file?: string}}} result
*/
prepare(result) {
const { stats, env, from, file } = result.opts || {};
const browsers = browserslist(options.overrideBrowserslist, {
stats: options.stats || stats,
path: options.path || dirname(from || file || __filename),
env: options.env || env,
});
const initialSupport = isSupported('css-initial-value', browsers);
return {
OnceExit(css) {
css.walkDecls((decl) => {
const lowerCasedProp = decl.prop.toLowerCase();
const ignoreProp = new Set(
defaultIgnoreProps.concat(options.ignore || [])
);
if (ignoreProp.has(lowerCasedProp)) {
return;
}
if (
initialSupport &&
Object.prototype.hasOwnProperty.call(toInitial, lowerCasedProp) &&
decl.value.toLowerCase() ===
toInitial[/** @type {keyof toInitial} */ (lowerCasedProp)]
) {
decl.value = initial;
return;
}
if (
decl.value.toLowerCase() !== initial ||
!fromInitial[/** @type {keyof fromInitial} */ (lowerCasedProp)]
) {
return;
}
decl.value =
fromInitial[/** @type {keyof fromInitial} */ (lowerCasedProp)];
});
},
};
},
};
}
pluginCreator.postcss = true;
module.exports = pluginCreator;