Updated SCSS compiler to v1.7

This commit is contained in:
Matias Griese
2021-09-16 18:23:30 +03:00
parent 8798191233
commit 15d3cd6cfe
13 changed files with 122 additions and 85 deletions

View File

@@ -1,6 +1,12 @@
# v1.10.21
## 09/14/2021
1. [](#new)
* Updated SCSS compiler to v1.7
# v1.10.21
## 09/14/2021
1. [](#new)
* Require **Grav 1.7.21**
2. [](#improved)

View File

@@ -23,7 +23,7 @@
"php": "^7.3.6 || ^8.0",
"ext-json": "*",
"p3k/picofeed": "@stable",
"scssphp/scssphp": "^1.5"
"scssphp/scssphp": "^1.7"
},
"require-dev": {
"codeception/codeception": "^2.4",

15
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "e00ccb05e2b5cfc4c32a0ee55a9bb686",
"content-hash": "9841a8a750e293f602d3064be4fd61b4",
"packages": [
{
"name": "laminas/laminas-xml",
@@ -188,16 +188,16 @@
},
{
"name": "scssphp/scssphp",
"version": "v1.6.0",
"version": "v1.7.0",
"source": {
"type": "git",
"url": "https://github.com/scssphp/scssphp.git",
"reference": "b83594e2323c5d6e80785df3f91b9d1d32aad530"
"reference": "797f76527c72bc4fe4ee32a94c4732e8d94517ae"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/scssphp/scssphp/zipball/b83594e2323c5d6e80785df3f91b9d1d32aad530",
"reference": "b83594e2323c5d6e80785df3f91b9d1d32aad530",
"url": "https://api.github.com/repos/scssphp/scssphp/zipball/797f76527c72bc4fe4ee32a94c4732e8d94517ae",
"reference": "797f76527c72bc4fe4ee32a94c4732e8d94517ae",
"shasum": ""
},
"require": {
@@ -255,9 +255,9 @@
],
"support": {
"issues": "https://github.com/scssphp/scssphp/issues",
"source": "https://github.com/scssphp/scssphp/tree/v1.6.0"
"source": "https://github.com/scssphp/scssphp/tree/v1.7.0"
},
"time": "2021-07-02T16:28:10+00:00"
"time": "2021-09-15T21:57:30+00:00"
}
],
"packages-dev": [
@@ -2425,7 +2425,6 @@
"type": "github"
}
],
"abandoned": true,
"time": "2020-11-30T07:30:19+00:00"
},
{

2
vendor/autoload.php vendored
View File

@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit14b786715d80b97050af9c30f5c07b7c::getLoader();
return ComposerAutoloaderInitd6a520eb662703b9aa0b94d2e30cc77f::getLoader();

View File

@@ -29,7 +29,7 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => 'ea31417d33e4e26168a4130260ce0c727f0f8fbc',
'reference' => '879819123303cf642c0552339cc2e1b46e94aab1',
'name' => 'getgrav/grav-plugin-admin',
),
'versions' =>
@@ -41,7 +41,7 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => 'ea31417d33e4e26168a4130260ce0c727f0f8fbc',
'reference' => '879819123303cf642c0552339cc2e1b46e94aab1',
),
'laminas/laminas-xml' =>
array (
@@ -79,12 +79,12 @@ private static $installed = array (
),
'scssphp/scssphp' =>
array (
'pretty_version' => 'v1.6.0',
'version' => '1.6.0.0',
'pretty_version' => 'v1.7.0',
'version' => '1.7.0.0',
'aliases' =>
array (
),
'reference' => 'b83594e2323c5d6e80785df3f91b9d1d32aad530',
'reference' => '797f76527c72bc4fe4ee32a94c4732e8d94517ae',
),
'symfony/polyfill-php72' =>
array (

View File

@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit14b786715d80b97050af9c30f5c07b7c
class ComposerAutoloaderInitd6a520eb662703b9aa0b94d2e30cc77f
{
private static $loader;
@@ -24,15 +24,15 @@ class ComposerAutoloaderInit14b786715d80b97050af9c30f5c07b7c
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInit14b786715d80b97050af9c30f5c07b7c', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitd6a520eb662703b9aa0b94d2e30cc77f', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit14b786715d80b97050af9c30f5c07b7c', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitd6a520eb662703b9aa0b94d2e30cc77f', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit14b786715d80b97050af9c30f5c07b7c::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitd6a520eb662703b9aa0b94d2e30cc77f::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@@ -53,19 +53,19 @@ class ComposerAutoloaderInit14b786715d80b97050af9c30f5c07b7c
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit14b786715d80b97050af9c30f5c07b7c::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitd6a520eb662703b9aa0b94d2e30cc77f::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire14b786715d80b97050af9c30f5c07b7c($fileIdentifier, $file);
composerRequired6a520eb662703b9aa0b94d2e30cc77f($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire14b786715d80b97050af9c30f5c07b7c($fileIdentifier, $file)
function composerRequired6a520eb662703b9aa0b94d2e30cc77f($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit14b786715d80b97050af9c30f5c07b7c
class ComposerStaticInitd6a520eb662703b9aa0b94d2e30cc77f
{
public static $files = array (
'7e9bd612cc444b3eed788ebbe46263a0' => __DIR__ . '/..' . '/laminas/laminas-zendframework-bridge/src/autoload.php',
@@ -63,10 +63,10 @@ class ComposerStaticInit14b786715d80b97050af9c30f5c07b7c
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit14b786715d80b97050af9c30f5c07b7c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit14b786715d80b97050af9c30f5c07b7c::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInit14b786715d80b97050af9c30f5c07b7c::$prefixesPsr0;
$loader->classMap = ComposerStaticInit14b786715d80b97050af9c30f5c07b7c::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitd6a520eb662703b9aa0b94d2e30cc77f::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd6a520eb662703b9aa0b94d2e30cc77f::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInitd6a520eb662703b9aa0b94d2e30cc77f::$prefixesPsr0;
$loader->classMap = ComposerStaticInitd6a520eb662703b9aa0b94d2e30cc77f::$classMap;
}, null, ClassLoader::class);
}

View File

@@ -191,17 +191,17 @@
},
{
"name": "scssphp/scssphp",
"version": "v1.6.0",
"version_normalized": "1.6.0.0",
"version": "v1.7.0",
"version_normalized": "1.7.0.0",
"source": {
"type": "git",
"url": "https://github.com/scssphp/scssphp.git",
"reference": "b83594e2323c5d6e80785df3f91b9d1d32aad530"
"reference": "797f76527c72bc4fe4ee32a94c4732e8d94517ae"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/scssphp/scssphp/zipball/b83594e2323c5d6e80785df3f91b9d1d32aad530",
"reference": "b83594e2323c5d6e80785df3f91b9d1d32aad530",
"url": "https://api.github.com/repos/scssphp/scssphp/zipball/797f76527c72bc4fe4ee32a94c4732e8d94517ae",
"reference": "797f76527c72bc4fe4ee32a94c4732e8d94517ae",
"shasum": ""
},
"require": {
@@ -223,7 +223,7 @@
"ext-iconv": "Can be used as fallback when ext-mbstring is not available",
"ext-mbstring": "For best performance, mbstring should be installed as it is faster than ext-iconv"
},
"time": "2021-07-02T16:28:10+00:00",
"time": "2021-09-15T21:57:30+00:00",
"bin": [
"bin/pscss"
],
@@ -261,7 +261,7 @@
],
"support": {
"issues": "https://github.com/scssphp/scssphp/issues",
"source": "https://github.com/scssphp/scssphp/tree/v1.6.0"
"source": "https://github.com/scssphp/scssphp/tree/v1.7.0"
},
"install-path": "../scssphp/scssphp"
}

View File

@@ -6,7 +6,7 @@
'aliases' =>
array (
),
'reference' => 'ea31417d33e4e26168a4130260ce0c727f0f8fbc',
'reference' => '879819123303cf642c0552339cc2e1b46e94aab1',
'name' => 'getgrav/grav-plugin-admin',
),
'versions' =>
@@ -18,7 +18,7 @@
'aliases' =>
array (
),
'reference' => 'ea31417d33e4e26168a4130260ce0c727f0f8fbc',
'reference' => '879819123303cf642c0552339cc2e1b46e94aab1',
),
'laminas/laminas-xml' =>
array (
@@ -56,12 +56,12 @@
),
'scssphp/scssphp' =>
array (
'pretty_version' => 'v1.6.0',
'version' => '1.6.0.0',
'pretty_version' => 'v1.7.0',
'version' => '1.7.0.0',
'aliases' =>
array (
),
'reference' => 'b83594e2323c5d6e80785df3f91b9d1d32aad530',
'reference' => '797f76527c72bc4fe4ee32a94c4732e8d94517ae',
),
'symfony/polyfill-php72' =>
array (

View File

@@ -49,16 +49,16 @@
"type": "package",
"package": {
"name": "sass/sass-spec",
"version": "2021.06.30",
"version": "2021.09.15",
"source": {
"type": "git",
"url": "https://github.com/sass/sass-spec.git",
"reference": "e348959657f1e274cef658283436a311a925a673"
"reference": "eb2d7a0865c1faf0b55a39ff962b24aca9b4c955"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sass/sass-spec/zipball/e348959657f1e274cef658283436a311a925a673",
"reference": "e348959657f1e274cef658283436a311a925a673",
"url": "https://api.github.com/repos/sass/sass-spec/zipball/eb2d7a0865c1faf0b55a39ff962b24aca9b4c955",
"reference": "eb2d7a0865c1faf0b55a39ff962b24aca9b4c955",
"shasum": ""
}
}

View File

@@ -193,6 +193,11 @@ class Compiler
*/
protected $sourceMapOptions = [];
/**
* @var bool
*/
private $charset = true;
/**
* @var string|\ScssPhp\ScssPhp\Formatter
*/
@@ -221,6 +226,8 @@ class Compiler
protected $storeEnv;
/**
* @var bool|null
*
* @deprecated
*/
protected $charsetSeen;
/**
@@ -463,7 +470,6 @@ class Compiler
$this->env = null;
$this->scope = null;
$this->storeEnv = null;
$this->charsetSeen = null;
$this->shouldEvaluate = null;
$this->ignoreCallStackMessage = false;
$this->parsedFiles = [];
@@ -516,11 +522,9 @@ class Compiler
$prefix = '';
if (!$this->charsetSeen) {
if (strlen($out) !== Util::mbStrlen($out)) {
$prefix = '@charset "UTF-8";' . "\n";
$out = $prefix . $out;
}
if ($this->charset && strlen($out) !== Util::mbStrlen($out)) {
$prefix = '@charset "UTF-8";' . "\n";
$out = $prefix . $out;
}
$sourceMap = null;
@@ -2877,10 +2881,6 @@ class Compiler
break;
case Type::T_CHARSET:
if (! $this->charsetSeen) {
$this->charsetSeen = true;
$this->appendRootDirective('@charset ' . $this->compileValue($child[1]) . ';', $out);
}
break;
case Type::T_CUSTOM_PROPERTY:
@@ -5498,6 +5498,25 @@ EOL;
. 'Use source maps instead.', E_USER_DEPRECATED);
}
/**
* Configures the handling of non-ASCII outputs.
*
* If $charset is `true`, this will include a `@charset` declaration or a
* UTF-8 [byte-order mark][] if the stylesheet contains any non-ASCII
* characters. Otherwise, it will never include a `@charset` declaration or a
* byte-order mark.
*
* [byte-order mark]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8
*
* @param bool $charset
*
* @return void
*/
public function setCharset($charset)
{
$this->charset = $charset;
}
/**
* Enable/disable source maps
*
@@ -5872,7 +5891,7 @@ EOL;
}
if (0 === strpos($normalizedPath, $normalizedRootDirectory)) {
return substr($normalizedPath, \strlen($normalizedRootDirectory));
return substr($path, \strlen($normalizedRootDirectory));
}
return $path;
@@ -7209,9 +7228,13 @@ EOL;
* @param array|Number $value
*
* @return integer|float
*
* @deprecated
*/
protected function coercePercent($value)
{
@trigger_error(sprintf('"%s" is deprecated since 1.7.0.', __METHOD__), E_USER_DEPRECATED);
if ($value instanceof Number) {
if ($value->hasUnit('%')) {
return $value->getDimension() / 100;
@@ -7719,7 +7742,7 @@ EOL;
[$funcName . '(', $color[1], ', ', $color[2], ', ', $color[3], ', ', $alpha, ')']];
}
} else {
$color = [Type::T_STRING, '', [$funcName . '(', $args[0], ')']];
$color = [Type::T_STRING, '', [$funcName . '(', $args[0], ', ', $args[1], ')']];
}
break;
@@ -8020,8 +8043,8 @@ EOL;
// mix two colors
protected static $libMix = [
['color1', 'color2', 'weight:0.5'],
['color-1', 'color-2', 'weight:0.5']
['color1', 'color2', 'weight:50%'],
['color-1', 'color-2', 'weight:50%']
];
protected function libMix($args)
{
@@ -8029,25 +8052,26 @@ EOL;
$first = $this->assertColor($first, 'color1');
$second = $this->assertColor($second, 'color2');
$weight = $this->coercePercent($this->assertNumber($weight, 'weight'));
$weightScale = $this->assertNumber($weight, 'weight')->valueInRange(0, 100, 'weight') / 100;
$firstAlpha = isset($first[4]) ? $first[4] : 1;
$secondAlpha = isset($second[4]) ? $second[4] : 1;
$w = $weight * 2 - 1;
$a = $firstAlpha - $secondAlpha;
$normalizedWeight = $weightScale * 2 - 1;
$alphaDistance = $firstAlpha - $secondAlpha;
$w1 = (($w * $a === -1 ? $w : ($w + $a) / (1 + $w * $a)) + 1) / 2.0;
$w2 = 1.0 - $w1;
$combinedWeight = $normalizedWeight * $alphaDistance == -1 ? $normalizedWeight : ($normalizedWeight + $alphaDistance) / (1 + $normalizedWeight * $alphaDistance);
$weight1 = ($combinedWeight + 1) / 2.0;
$weight2 = 1.0 - $weight1;
$new = [Type::T_COLOR,
$w1 * $first[1] + $w2 * $second[1],
$w1 * $first[2] + $w2 * $second[2],
$w1 * $first[3] + $w2 * $second[3],
$weight1 * $first[1] + $weight2 * $second[1],
$weight1 * $first[2] + $weight2 * $second[2],
$weight1 * $first[3] + $weight2 * $second[3],
];
if ($firstAlpha != 1.0 || $secondAlpha != 1.0) {
$new[] = $firstAlpha * $weight + $secondAlpha * (1 - $weight);
$new[] = $firstAlpha * $weightScale + $secondAlpha * (1 - $weightScale);
}
return $this->fixColor($new);
@@ -8306,6 +8330,12 @@ EOL;
{
$hsl = $this->toHSL($color[1], $color[2], $color[3]);
$hsl[$idx] += $amount;
if ($idx !== 1) {
// Clamp the saturation and lightness
$hsl[$idx] = min(max(0, $hsl[$idx]), 100);
}
$out = $this->toRGB($hsl[1], $hsl[2], $hsl[3]);
if (isset($color[4])) {
@@ -8353,19 +8383,19 @@ EOL;
return null;
}
$color = $this->assertColor($value, 'color');
$amount = 100 * $this->coercePercent($this->assertNumber($args[1], 'amount'));
$color = $this->assertColor($args[0], 'color');
$amount = $this->assertNumber($args[1], 'amount');
return $this->adjustHsl($color, 2, $amount);
return $this->adjustHsl($color, 2, $amount->valueInRange(0, 100, 'amount'));
}
protected static $libDesaturate = ['color', 'amount'];
protected function libDesaturate($args)
{
$color = $this->assertColor($args[0], 'color');
$amount = 100 * $this->coercePercent($this->assertNumber($args[1], 'amount'));
$amount = $this->assertNumber($args[1], 'amount');
return $this->adjustHsl($color, 2, -$amount);
return $this->adjustHsl($color, 2, -$amount->valueInRange(0, 100, 'amount'));
}
protected static $libGrayscale = ['color'];
@@ -8386,28 +8416,28 @@ EOL;
return $this->adjustHsl($this->assertColor($args[0], 'color'), 1, 180);
}
protected static $libInvert = ['color', 'weight:1'];
protected static $libInvert = ['color', 'weight:100%'];
protected function libInvert($args)
{
$value = $args[0];
$weight = $this->assertNumber($args[1], 'weight');
if ($value instanceof Number) {
if ($weight->getDimension() != 100 || !$weight->hasUnit('%')) {
throw new SassScriptException('Only one argument may be passed to the plain-CSS invert() function.');
}
return null;
}
$weight = $this->coercePercent($this->assertNumber($args[1], 'weight'));
$color = $this->assertColor($value, 'color');
$inverted = $color;
$inverted[1] = 255 - $inverted[1];
$inverted[2] = 255 - $inverted[2];
$inverted[3] = 255 - $inverted[3];
if ($weight < 1) {
return $this->libMix([$inverted, $color, new Number($weight, '')]);
}
return $inverted;
return $this->libMix([$inverted, $color, $weight]);
}
// increases opacity by amount
@@ -8415,9 +8445,9 @@ EOL;
protected function libOpacify($args)
{
$color = $this->assertColor($args[0], 'color');
$amount = $this->coercePercent($this->assertNumber($args[1], 'amount'));
$amount = $this->assertNumber($args[1], 'amount');
$color[4] = (isset($color[4]) ? $color[4] : 1) + $amount;
$color[4] = (isset($color[4]) ? $color[4] : 1) + $amount->valueInRange(0, 1, 'amount');
$color[4] = min(1, max(0, $color[4]));
return $color;
@@ -8434,9 +8464,9 @@ EOL;
protected function libTransparentize($args)
{
$color = $this->assertColor($args[0], 'color');
$amount = $this->coercePercent($this->assertNumber($args[1], 'amount'));
$amount = $this->assertNumber($args[1], 'amount');
$color[4] = (isset($color[4]) ? $color[4] : 1) - $amount;
$color[4] = (isset($color[4]) ? $color[4] : 1) - $amount->valueInRange(0, 1, 'amount');
$color[4] = min(1, max(0, $color[4]));
return $color;

View File

@@ -1580,7 +1580,9 @@ class Parser
} else {
list($line, $column) = $this->getSourcePosition($this->count);
$file = $this->sourceName;
$this->logger->warn("Unterminated interpolations in multiline comments are deprecated and will be removed in ScssPhp 2.0, in \"$file\", line $line, column $column.", true);
if (!$this->discardComments) {
$this->logger->warn("Unterminated interpolations in multiline comments are deprecated and will be removed in ScssPhp 2.0, in \"$file\", line $line, column $column.", true);
}
$comment[] = substr($this->buffer, $this->count, 2);
$this->count += 2;

View File

@@ -19,5 +19,5 @@ namespace ScssPhp\ScssPhp;
*/
class Version
{
const VERSION = '1.6.0';
const VERSION = '1.7.0';
}