Initial Commit
This commit is contained in:
20
dependencies/scssphp/scssphp/scss.inc.php
vendored
Normal file
20
dependencies/scssphp/scssphp/scss.inc.php
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies;
|
||||
|
||||
if (\version_compare(\PHP_VERSION, '5.6') < 0) {
|
||||
throw new \Exception('scssphp requires PHP 5.6 or above');
|
||||
}
|
||||
if (!\class_exists('WP_Ultimo\\Dependencies\\ScssPhp\\ScssPhp\\Version')) {
|
||||
\spl_autoload_register(function ($class) {
|
||||
if (0 !== \strpos($class, 'ScssPhp\\ScssPhp\\')) {
|
||||
// Not a ScssPhp class
|
||||
return;
|
||||
}
|
||||
$subClass = \substr($class, \strlen('ScssPhp\\ScssPhp\\'));
|
||||
$path = __DIR__ . '/src/' . \str_replace('\\', '/', $subClass) . '.php';
|
||||
if (\file_exists($path)) {
|
||||
require $path;
|
||||
}
|
||||
});
|
||||
}
|
53
dependencies/scssphp/scssphp/src/Base/Range.php
vendored
Normal file
53
dependencies/scssphp/scssphp/src/Base/Range.php
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2015-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Base;
|
||||
|
||||
/**
|
||||
* Range
|
||||
*
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Range
|
||||
{
|
||||
/**
|
||||
* @var float|int
|
||||
*/
|
||||
public $first;
|
||||
/**
|
||||
* @var float|int
|
||||
*/
|
||||
public $last;
|
||||
/**
|
||||
* Initialize range
|
||||
*
|
||||
* @param int|float $first
|
||||
* @param int|float $last
|
||||
*/
|
||||
public function __construct($first, $last)
|
||||
{
|
||||
$this->first = $first;
|
||||
$this->last = $last;
|
||||
}
|
||||
/**
|
||||
* Test for inclusion in range
|
||||
*
|
||||
* @param int|float $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function includes($value)
|
||||
{
|
||||
return $value >= $this->first && $value <= $this->last;
|
||||
}
|
||||
}
|
63
dependencies/scssphp/scssphp/src/Block.php
vendored
Normal file
63
dependencies/scssphp/scssphp/src/Block.php
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp;
|
||||
|
||||
/**
|
||||
* Block
|
||||
*
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Block
|
||||
{
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
public $type;
|
||||
/**
|
||||
* @var Block|null
|
||||
*/
|
||||
public $parent;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $sourceName;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $sourceIndex;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $sourceLine;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $sourceColumn;
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
public $selectors;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $comments;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $children;
|
||||
/**
|
||||
* @var Block|null
|
||||
*/
|
||||
public $selfParent;
|
||||
}
|
33
dependencies/scssphp/scssphp/src/Block/AtRootBlock.php
vendored
Normal file
33
dependencies/scssphp/scssphp/src/Block/AtRootBlock.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Type;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class AtRootBlock extends Block
|
||||
{
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
public $selector;
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
public $with;
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = Type::T_AT_ROOT;
|
||||
}
|
||||
}
|
40
dependencies/scssphp/scssphp/src/Block/CallableBlock.php
vendored
Normal file
40
dependencies/scssphp/scssphp/src/Block/CallableBlock.php
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Compiler\Environment;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class CallableBlock extends Block
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
public $args;
|
||||
/**
|
||||
* @var Environment|null
|
||||
*/
|
||||
public $parentEnv;
|
||||
/**
|
||||
* @param string $type
|
||||
*/
|
||||
public function __construct($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
}
|
34
dependencies/scssphp/scssphp/src/Block/ContentBlock.php
vendored
Normal file
34
dependencies/scssphp/scssphp/src/Block/ContentBlock.php
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Compiler\Environment;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Type;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class ContentBlock extends Block
|
||||
{
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
public $child;
|
||||
/**
|
||||
* @var Environment|null
|
||||
*/
|
||||
public $scope;
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = Type::T_INCLUDE;
|
||||
}
|
||||
}
|
33
dependencies/scssphp/scssphp/src/Block/DirectiveBlock.php
vendored
Normal file
33
dependencies/scssphp/scssphp/src/Block/DirectiveBlock.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Type;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class DirectiveBlock extends Block
|
||||
{
|
||||
/**
|
||||
* @var string|array
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* @var string|array|null
|
||||
*/
|
||||
public $value;
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = Type::T_DIRECTIVE;
|
||||
}
|
||||
}
|
33
dependencies/scssphp/scssphp/src/Block/EachBlock.php
vendored
Normal file
33
dependencies/scssphp/scssphp/src/Block/EachBlock.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Type;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class EachBlock extends Block
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $vars = [];
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $list;
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = Type::T_EACH;
|
||||
}
|
||||
}
|
25
dependencies/scssphp/scssphp/src/Block/ElseBlock.php
vendored
Normal file
25
dependencies/scssphp/scssphp/src/Block/ElseBlock.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Type;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class ElseBlock extends Block
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = Type::T_ELSE;
|
||||
}
|
||||
}
|
29
dependencies/scssphp/scssphp/src/Block/ElseifBlock.php
vendored
Normal file
29
dependencies/scssphp/scssphp/src/Block/ElseifBlock.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Type;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class ElseifBlock extends Block
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $cond;
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = Type::T_ELSEIF;
|
||||
}
|
||||
}
|
41
dependencies/scssphp/scssphp/src/Block/ForBlock.php
vendored
Normal file
41
dependencies/scssphp/scssphp/src/Block/ForBlock.php
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Type;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class ForBlock extends Block
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $var;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $start;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $end;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $until;
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = Type::T_FOR;
|
||||
}
|
||||
}
|
33
dependencies/scssphp/scssphp/src/Block/IfBlock.php
vendored
Normal file
33
dependencies/scssphp/scssphp/src/Block/IfBlock.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Type;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class IfBlock extends Block
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $cond;
|
||||
/**
|
||||
* @var array<ElseifBlock|ElseBlock>
|
||||
*/
|
||||
public $cases = [];
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = Type::T_IF;
|
||||
}
|
||||
}
|
33
dependencies/scssphp/scssphp/src/Block/MediaBlock.php
vendored
Normal file
33
dependencies/scssphp/scssphp/src/Block/MediaBlock.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Type;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class MediaBlock extends Block
|
||||
{
|
||||
/**
|
||||
* @var string|array|null
|
||||
*/
|
||||
public $value;
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
public $queryList;
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = Type::T_MEDIA;
|
||||
}
|
||||
}
|
33
dependencies/scssphp/scssphp/src/Block/NestedPropertyBlock.php
vendored
Normal file
33
dependencies/scssphp/scssphp/src/Block/NestedPropertyBlock.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Type;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class NestedPropertyBlock extends Block
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $hasValue;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $prefix;
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = Type::T_NESTED_PROPERTY;
|
||||
}
|
||||
}
|
29
dependencies/scssphp/scssphp/src/Block/WhileBlock.php
vendored
Normal file
29
dependencies/scssphp/scssphp/src/Block/WhileBlock.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Block;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Type;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class WhileBlock extends Block
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $cond;
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = Type::T_WHILE;
|
||||
}
|
||||
}
|
215
dependencies/scssphp/scssphp/src/Cache.php
vendored
Normal file
215
dependencies/scssphp/scssphp/src/Cache.php
vendored
Normal file
@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp;
|
||||
|
||||
use Exception;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Version;
|
||||
/**
|
||||
* The scss cache manager.
|
||||
*
|
||||
* In short:
|
||||
*
|
||||
* allow to put in cache/get from cache a generic result from a known operation on a generic dataset,
|
||||
* taking in account options that affects the result
|
||||
*
|
||||
* The cache manager is agnostic about data format and only the operation is expected to be described by string
|
||||
*/
|
||||
/**
|
||||
* SCSS cache
|
||||
*
|
||||
* @author Cedric Morin <cedric@yterium.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Cache
|
||||
{
|
||||
const CACHE_VERSION = 1;
|
||||
/**
|
||||
* directory used for storing data
|
||||
*
|
||||
* @var string|false
|
||||
*/
|
||||
public static $cacheDir = \false;
|
||||
/**
|
||||
* prefix for the storing data
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $prefix = 'scssphp_';
|
||||
/**
|
||||
* force a refresh : 'once' for refreshing the first hit on a cache only, true to never use the cache in this hit
|
||||
*
|
||||
* @var bool|string
|
||||
*/
|
||||
public static $forceRefresh = \false;
|
||||
/**
|
||||
* specifies the number of seconds after which data cached will be seen as 'garbage' and potentially cleaned up
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public static $gcLifetime = 604800;
|
||||
/**
|
||||
* array of already refreshed cache if $forceRefresh==='once'
|
||||
*
|
||||
* @var array<string, bool>
|
||||
*/
|
||||
protected static $refreshed = [];
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @phpstan-param array{cacheDir?: string, prefix?: string, forceRefresh?: string} $options
|
||||
*/
|
||||
public function __construct($options)
|
||||
{
|
||||
// check $cacheDir
|
||||
if (isset($options['cacheDir'])) {
|
||||
self::$cacheDir = $options['cacheDir'];
|
||||
}
|
||||
if (empty(self::$cacheDir)) {
|
||||
throw new Exception('cacheDir not set');
|
||||
}
|
||||
if (isset($options['prefix'])) {
|
||||
self::$prefix = $options['prefix'];
|
||||
}
|
||||
if (empty(self::$prefix)) {
|
||||
throw new Exception('prefix not set');
|
||||
}
|
||||
if (isset($options['forceRefresh'])) {
|
||||
self::$forceRefresh = $options['forceRefresh'];
|
||||
}
|
||||
self::checkCacheDir();
|
||||
}
|
||||
/**
|
||||
* Get the cached result of $operation on $what,
|
||||
* which is known as dependant from the content of $options
|
||||
*
|
||||
* @param string $operation parse, compile...
|
||||
* @param mixed $what content key (e.g., filename to be treated)
|
||||
* @param array $options any option that affect the operation result on the content
|
||||
* @param int|null $lastModified last modified timestamp
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getCache($operation, $what, $options = [], $lastModified = null)
|
||||
{
|
||||
$fileCache = self::$cacheDir . self::cacheName($operation, $what, $options);
|
||||
if ((self::$forceRefresh === \false || self::$forceRefresh === 'once' && isset(self::$refreshed[$fileCache])) && \file_exists($fileCache)) {
|
||||
$cacheTime = \filemtime($fileCache);
|
||||
if ((\is_null($lastModified) || $cacheTime > $lastModified) && $cacheTime + self::$gcLifetime > \time()) {
|
||||
$c = \file_get_contents($fileCache);
|
||||
$c = \unserialize($c);
|
||||
if (\is_array($c) && isset($c['value'])) {
|
||||
return $c['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Put in cache the result of $operation on $what,
|
||||
* which is known as dependant from the content of $options
|
||||
*
|
||||
* @param string $operation
|
||||
* @param mixed $what
|
||||
* @param mixed $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCache($operation, $what, $value, $options = [])
|
||||
{
|
||||
$fileCache = self::$cacheDir . self::cacheName($operation, $what, $options);
|
||||
$c = ['value' => $value];
|
||||
$c = \serialize($c);
|
||||
\file_put_contents($fileCache, $c);
|
||||
if (self::$forceRefresh === 'once') {
|
||||
self::$refreshed[$fileCache] = \true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the cache name for the caching of $operation on $what,
|
||||
* which is known as dependant from the content of $options
|
||||
*
|
||||
* @param string $operation
|
||||
* @param mixed $what
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function cacheName($operation, $what, $options = [])
|
||||
{
|
||||
$t = ['version' => self::CACHE_VERSION, 'scssphpVersion' => Version::VERSION, 'operation' => $operation, 'what' => $what, 'options' => $options];
|
||||
$t = self::$prefix . \sha1(\json_encode($t)) . ".{$operation}" . ".scsscache";
|
||||
return $t;
|
||||
}
|
||||
/**
|
||||
* Check that the cache dir exists and is writeable
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function checkCacheDir()
|
||||
{
|
||||
self::$cacheDir = \str_replace('\\', '/', self::$cacheDir);
|
||||
self::$cacheDir = \rtrim(self::$cacheDir, '/') . '/';
|
||||
if (!\is_dir(self::$cacheDir)) {
|
||||
throw new Exception('Cache directory doesn\'t exist: ' . self::$cacheDir);
|
||||
}
|
||||
if (!\is_writable(self::$cacheDir)) {
|
||||
throw new Exception('Cache directory isn\'t writable: ' . self::$cacheDir);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Delete unused cached files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function cleanCache()
|
||||
{
|
||||
static $clean = \false;
|
||||
if ($clean || empty(self::$cacheDir)) {
|
||||
return;
|
||||
}
|
||||
$clean = \true;
|
||||
// only remove files with extensions created by SCSSPHP Cache
|
||||
// css files removed based on the list files
|
||||
$removeTypes = ['scsscache' => 1];
|
||||
$files = \scandir(self::$cacheDir);
|
||||
if (!$files) {
|
||||
return;
|
||||
}
|
||||
$checkTime = \time() - self::$gcLifetime;
|
||||
foreach ($files as $file) {
|
||||
// don't delete if the file wasn't created with SCSSPHP Cache
|
||||
if (\strpos($file, self::$prefix) !== 0) {
|
||||
continue;
|
||||
}
|
||||
$parts = \explode('.', $file);
|
||||
$type = \array_pop($parts);
|
||||
if (!isset($removeTypes[$type])) {
|
||||
continue;
|
||||
}
|
||||
$fullPath = self::$cacheDir . $file;
|
||||
$mtime = \filemtime($fullPath);
|
||||
// don't delete if it's a relatively new file
|
||||
if ($mtime > $checkTime) {
|
||||
continue;
|
||||
}
|
||||
\unlink($fullPath);
|
||||
}
|
||||
}
|
||||
}
|
81
dependencies/scssphp/scssphp/src/Colors.php
vendored
Normal file
81
dependencies/scssphp/scssphp/src/Colors.php
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp;
|
||||
|
||||
/**
|
||||
* CSS Colors
|
||||
*
|
||||
* @author Leaf Corcoran <leafot@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Colors
|
||||
{
|
||||
/**
|
||||
* CSS Colors
|
||||
*
|
||||
* @see http://www.w3.org/TR/css3-color
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected static $cssColors = ['aliceblue' => '240,248,255', 'antiquewhite' => '250,235,215', 'aqua' => '0,255,255', 'cyan' => '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', 'darkblue' => '0,0,139', 'darkcyan' => '0,139,139', 'darkgoldenrod' => '184,134,11', 'darkgray' => '169,169,169', 'darkgrey' => '169,169,169', 'darkgreen' => '0,100,0', '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', 'magenta' => '255,0,255', 'gainsboro' => '220,220,220', 'ghostwhite' => '248,248,255', 'gold' => '255,215,0', 'goldenrod' => '218,165,32', 'gray' => '128,128,128', 'grey' => '128,128,128', 'green' => '0,128,0', 'greenyellow' => '173,255,47', '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', 'lightgrey' => '211,211,211', 'lightgreen' => '144,238,144', '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', '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', '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', 'rebeccapurple' => '102,51,153', 'transparent' => '0,0,0,0'];
|
||||
/**
|
||||
* Convert named color in a [r,g,b[,a]] array
|
||||
*
|
||||
* @param string $colorName
|
||||
*
|
||||
* @return int[]|null
|
||||
*/
|
||||
public static function colorNameToRGBa($colorName)
|
||||
{
|
||||
if (\is_string($colorName) && isset(static::$cssColors[$colorName])) {
|
||||
$rgba = \explode(',', static::$cssColors[$colorName]);
|
||||
// only case with opacity is transparent, with opacity=0, so we can intval on opacity also
|
||||
$rgba = \array_map('intval', $rgba);
|
||||
return $rgba;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Reverse conversion : from RGBA to a color name if possible
|
||||
*
|
||||
* @param int $r
|
||||
* @param int $g
|
||||
* @param int $b
|
||||
* @param int|float $a
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function RGBaToColorName($r, $g, $b, $a = 1)
|
||||
{
|
||||
static $reverseColorTable = null;
|
||||
if (!\is_numeric($r) || !\is_numeric($g) || !\is_numeric($b) || !\is_numeric($a)) {
|
||||
return null;
|
||||
}
|
||||
if ($a < 1) {
|
||||
return null;
|
||||
}
|
||||
if (\is_null($reverseColorTable)) {
|
||||
$reverseColorTable = [];
|
||||
foreach (static::$cssColors as $name => $rgb_str) {
|
||||
$rgb_str = \explode(',', $rgb_str);
|
||||
if (\count($rgb_str) == 3 && !isset($reverseColorTable[\intval($rgb_str[0])][\intval($rgb_str[1])][\intval($rgb_str[2])])) {
|
||||
$reverseColorTable[\intval($rgb_str[0])][\intval($rgb_str[1])][\intval($rgb_str[2])] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($reverseColorTable[\intval($r)][\intval($g)][\intval($b)])) {
|
||||
return $reverseColorTable[\intval($r)][\intval($g)][\intval($b)];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
62
dependencies/scssphp/scssphp/src/CompilationResult.php
vendored
Normal file
62
dependencies/scssphp/scssphp/src/CompilationResult.php
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp;
|
||||
|
||||
class CompilationResult
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $css;
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $sourceMap;
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $includedFiles;
|
||||
/**
|
||||
* @param string $css
|
||||
* @param string|null $sourceMap
|
||||
* @param string[] $includedFiles
|
||||
*/
|
||||
public function __construct($css, $sourceMap, array $includedFiles)
|
||||
{
|
||||
$this->css = $css;
|
||||
$this->sourceMap = $sourceMap;
|
||||
$this->includedFiles = $includedFiles;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCss()
|
||||
{
|
||||
return $this->css;
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getIncludedFiles()
|
||||
{
|
||||
return $this->includedFiles;
|
||||
}
|
||||
/**
|
||||
* The sourceMap content, if it was generated
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getSourceMap()
|
||||
{
|
||||
return $this->sourceMap;
|
||||
}
|
||||
}
|
8372
dependencies/scssphp/scssphp/src/Compiler.php
vendored
Normal file
8372
dependencies/scssphp/scssphp/src/Compiler.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
69
dependencies/scssphp/scssphp/src/Compiler/CachedResult.php
vendored
Normal file
69
dependencies/scssphp/scssphp/src/Compiler/CachedResult.php
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Compiler;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\CompilationResult;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class CachedResult
|
||||
{
|
||||
/**
|
||||
* @var CompilationResult
|
||||
*/
|
||||
private $result;
|
||||
/**
|
||||
* @var array<string, int>
|
||||
*/
|
||||
private $parsedFiles;
|
||||
/**
|
||||
* @var array
|
||||
* @phpstan-var list<array{currentDir: string|null, path: string, filePath: string}>
|
||||
*/
|
||||
private $resolvedImports;
|
||||
/**
|
||||
* @param CompilationResult $result
|
||||
* @param array<string, int> $parsedFiles
|
||||
* @param array $resolvedImports
|
||||
*
|
||||
* @phpstan-param list<array{currentDir: string|null, path: string, filePath: string}> $resolvedImports
|
||||
*/
|
||||
public function __construct(CompilationResult $result, array $parsedFiles, array $resolvedImports)
|
||||
{
|
||||
$this->result = $result;
|
||||
$this->parsedFiles = $parsedFiles;
|
||||
$this->resolvedImports = $resolvedImports;
|
||||
}
|
||||
/**
|
||||
* @return CompilationResult
|
||||
*/
|
||||
public function getResult()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
/**
|
||||
* @return array<string, int>
|
||||
*/
|
||||
public function getParsedFiles()
|
||||
{
|
||||
return $this->parsedFiles;
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @phpstan-return list<array{currentDir: string|null, path: string, filePath: string}>
|
||||
*/
|
||||
public function getResolvedImports()
|
||||
{
|
||||
return $this->resolvedImports;
|
||||
}
|
||||
}
|
59
dependencies/scssphp/scssphp/src/Compiler/Environment.php
vendored
Normal file
59
dependencies/scssphp/scssphp/src/Compiler/Environment.php
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Compiler;
|
||||
|
||||
/**
|
||||
* Compiler environment
|
||||
*
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Environment
|
||||
{
|
||||
/**
|
||||
* @var \ScssPhp\ScssPhp\Block|null
|
||||
*/
|
||||
public $block;
|
||||
/**
|
||||
* @var \ScssPhp\ScssPhp\Compiler\Environment|null
|
||||
*/
|
||||
public $parent;
|
||||
/**
|
||||
* @var Environment|null
|
||||
*/
|
||||
public $declarationScopeParent;
|
||||
/**
|
||||
* @var Environment|null
|
||||
*/
|
||||
public $parentStore;
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
public $selectors;
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
public $marker;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $store;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $storeUnreduced;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $depth;
|
||||
}
|
23
dependencies/scssphp/scssphp/src/Exception/CompilerException.php
vendored
Normal file
23
dependencies/scssphp/scssphp/src/Exception/CompilerException.php
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Exception;
|
||||
|
||||
/**
|
||||
* Compiler exception
|
||||
*
|
||||
* @author Oleksandr Savchenko <traveltino@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class CompilerException extends \Exception implements SassException
|
||||
{
|
||||
}
|
55
dependencies/scssphp/scssphp/src/Exception/ParserException.php
vendored
Normal file
55
dependencies/scssphp/scssphp/src/Exception/ParserException.php
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Exception;
|
||||
|
||||
/**
|
||||
* Parser Exception
|
||||
*
|
||||
* @author Oleksandr Savchenko <traveltino@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ParserException extends \Exception implements SassException
|
||||
{
|
||||
/**
|
||||
* @var array|null
|
||||
* @phpstan-var array{string, int, int}|null
|
||||
*/
|
||||
private $sourcePosition;
|
||||
/**
|
||||
* Get source position
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @return array|null
|
||||
* @phpstan-return array{string, int, int}|null
|
||||
*/
|
||||
public function getSourcePosition()
|
||||
{
|
||||
return $this->sourcePosition;
|
||||
}
|
||||
/**
|
||||
* Set source position
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @param array $sourcePosition
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @phpstan-param array{string, int, int} $sourcePosition
|
||||
*/
|
||||
public function setSourcePosition($sourcePosition)
|
||||
{
|
||||
$this->sourcePosition = $sourcePosition;
|
||||
}
|
||||
}
|
23
dependencies/scssphp/scssphp/src/Exception/RangeException.php
vendored
Normal file
23
dependencies/scssphp/scssphp/src/Exception/RangeException.php
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Exception;
|
||||
|
||||
/**
|
||||
* Range exception
|
||||
*
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class RangeException extends \Exception implements SassException
|
||||
{
|
||||
}
|
7
dependencies/scssphp/scssphp/src/Exception/SassException.php
vendored
Normal file
7
dependencies/scssphp/scssphp/src/Exception/SassException.php
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Exception;
|
||||
|
||||
interface SassException
|
||||
{
|
||||
}
|
31
dependencies/scssphp/scssphp/src/Exception/SassScriptException.php
vendored
Normal file
31
dependencies/scssphp/scssphp/src/Exception/SassScriptException.php
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Exception;
|
||||
|
||||
/**
|
||||
* An exception thrown by SassScript.
|
||||
*
|
||||
* This class does not implement SassException on purpose, as it should
|
||||
* never be returned to the outside code. The compilation will catch it
|
||||
* and replace it with a SassException reporting the location of the
|
||||
* error.
|
||||
*/
|
||||
class SassScriptException extends \Exception
|
||||
{
|
||||
/**
|
||||
* Creates a SassScriptException with support for an argument name.
|
||||
*
|
||||
* This helper ensures a consistent handling of argument names in the
|
||||
* error message, without duplicating it.
|
||||
*
|
||||
* @param string $message
|
||||
* @param string|null $name The argument name, without $
|
||||
*
|
||||
* @return SassScriptException
|
||||
*/
|
||||
public static function forArgument($message, $name = null)
|
||||
{
|
||||
$varDisplay = !\is_null($name) ? "\${$name}: " : '';
|
||||
return new self($varDisplay . $message);
|
||||
}
|
||||
}
|
24
dependencies/scssphp/scssphp/src/Exception/ServerException.php
vendored
Normal file
24
dependencies/scssphp/scssphp/src/Exception/ServerException.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Exception;
|
||||
|
||||
@\trigger_error(\sprintf('The "%s" class is deprecated.', ServerException::class), \E_USER_DEPRECATED);
|
||||
/**
|
||||
* Server Exception
|
||||
*
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*
|
||||
* @deprecated The Scssphp server should define its own exception instead.
|
||||
*/
|
||||
class ServerException extends \Exception implements SassException
|
||||
{
|
||||
}
|
313
dependencies/scssphp/scssphp/src/Formatter.php
vendored
Normal file
313
dependencies/scssphp/scssphp/src/Formatter.php
vendored
Normal file
@ -0,0 +1,313 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter\OutputBlock;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\SourceMap\SourceMapGenerator;
|
||||
/**
|
||||
* Base formatter
|
||||
*
|
||||
* @author Leaf Corcoran <leafot@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract class Formatter
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $indentLevel;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $indentChar;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $break;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $open;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $close;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tagSeparator;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $assignSeparator;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $keepSemicolons;
|
||||
/**
|
||||
* @var \ScssPhp\ScssPhp\Formatter\OutputBlock
|
||||
*/
|
||||
protected $currentBlock;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $currentLine;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $currentColumn;
|
||||
/**
|
||||
* @var \ScssPhp\ScssPhp\SourceMap\SourceMapGenerator|null
|
||||
*/
|
||||
protected $sourceMapGenerator;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $strippedSemicolon;
|
||||
/**
|
||||
* Initialize formatter
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public abstract function __construct();
|
||||
/**
|
||||
* Return indentation (whitespace)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function indentStr()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
/**
|
||||
* Return property assignment
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function property($name, $value)
|
||||
{
|
||||
return \rtrim($name) . $this->assignSeparator . $value . ';';
|
||||
}
|
||||
/**
|
||||
* Return custom property assignment
|
||||
* differs in that you have to keep spaces in the value as is
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function customProperty($name, $value)
|
||||
{
|
||||
return \rtrim($name) . \trim($this->assignSeparator) . $value . ';';
|
||||
}
|
||||
/**
|
||||
* Output lines inside a block
|
||||
*
|
||||
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function blockLines(OutputBlock $block)
|
||||
{
|
||||
$inner = $this->indentStr();
|
||||
$glue = $this->break . $inner;
|
||||
$this->write($inner . \implode($glue, $block->lines));
|
||||
if (!empty($block->children)) {
|
||||
$this->write($this->break);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Output block selectors
|
||||
*
|
||||
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function blockSelectors(OutputBlock $block)
|
||||
{
|
||||
\assert(!empty($block->selectors));
|
||||
$inner = $this->indentStr();
|
||||
$this->write($inner . \implode($this->tagSeparator, $block->selectors) . $this->open . $this->break);
|
||||
}
|
||||
/**
|
||||
* Output block children
|
||||
*
|
||||
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function blockChildren(OutputBlock $block)
|
||||
{
|
||||
foreach ($block->children as $child) {
|
||||
$this->block($child);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Output non-empty block
|
||||
*
|
||||
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function block(OutputBlock $block)
|
||||
{
|
||||
if (empty($block->lines) && empty($block->children)) {
|
||||
return;
|
||||
}
|
||||
$this->currentBlock = $block;
|
||||
$pre = $this->indentStr();
|
||||
if (!empty($block->selectors)) {
|
||||
$this->blockSelectors($block);
|
||||
$this->indentLevel++;
|
||||
}
|
||||
if (!empty($block->lines)) {
|
||||
$this->blockLines($block);
|
||||
}
|
||||
if (!empty($block->children)) {
|
||||
$this->blockChildren($block);
|
||||
}
|
||||
if (!empty($block->selectors)) {
|
||||
$this->indentLevel--;
|
||||
if (!$this->keepSemicolons) {
|
||||
$this->strippedSemicolon = '';
|
||||
}
|
||||
if (empty($block->children)) {
|
||||
$this->write($this->break);
|
||||
}
|
||||
$this->write($pre . $this->close . $this->break);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Test and clean safely empty children
|
||||
*
|
||||
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function testEmptyChildren($block)
|
||||
{
|
||||
$isEmpty = empty($block->lines);
|
||||
if ($block->children) {
|
||||
foreach ($block->children as $k => &$child) {
|
||||
if (!$this->testEmptyChildren($child)) {
|
||||
$isEmpty = \false;
|
||||
continue;
|
||||
}
|
||||
if ($child->type === Type::T_MEDIA || $child->type === Type::T_DIRECTIVE) {
|
||||
$child->children = [];
|
||||
$child->selectors = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $isEmpty;
|
||||
}
|
||||
/**
|
||||
* Entry point to formatting a block
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block An abstract syntax tree
|
||||
* @param \ScssPhp\ScssPhp\SourceMap\SourceMapGenerator|null $sourceMapGenerator Optional source map generator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function format(OutputBlock $block, SourceMapGenerator $sourceMapGenerator = null)
|
||||
{
|
||||
$this->sourceMapGenerator = null;
|
||||
if ($sourceMapGenerator) {
|
||||
$this->currentLine = 1;
|
||||
$this->currentColumn = 0;
|
||||
$this->sourceMapGenerator = $sourceMapGenerator;
|
||||
}
|
||||
$this->testEmptyChildren($block);
|
||||
\ob_start();
|
||||
try {
|
||||
$this->block($block);
|
||||
} catch (\Exception $e) {
|
||||
\ob_end_clean();
|
||||
throw $e;
|
||||
} catch (\Throwable $e) {
|
||||
\ob_end_clean();
|
||||
throw $e;
|
||||
}
|
||||
$out = \ob_get_clean();
|
||||
\assert($out !== \false);
|
||||
return $out;
|
||||
}
|
||||
/**
|
||||
* Output content
|
||||
*
|
||||
* @param string $str
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function write($str)
|
||||
{
|
||||
if (!empty($this->strippedSemicolon)) {
|
||||
echo $this->strippedSemicolon;
|
||||
$this->strippedSemicolon = '';
|
||||
}
|
||||
/*
|
||||
* Maybe Strip semi-colon appended by property(); it's a separator, not a terminator
|
||||
* will be striped for real before a closing, otherwise displayed unchanged starting the next write
|
||||
*/
|
||||
if (!$this->keepSemicolons && $str && \strpos($str, ';') !== \false && \substr($str, -1) === ';') {
|
||||
$str = \substr($str, 0, -1);
|
||||
$this->strippedSemicolon = ';';
|
||||
}
|
||||
if ($this->sourceMapGenerator) {
|
||||
$lines = \explode("\n", $str);
|
||||
$lastLine = \array_pop($lines);
|
||||
foreach ($lines as $line) {
|
||||
// If the written line starts is empty, adding a mapping would add it for
|
||||
// a non-existent column as we are at the end of the line
|
||||
if ($line !== '') {
|
||||
\assert($this->currentBlock->sourceLine !== null);
|
||||
\assert($this->currentBlock->sourceName !== null);
|
||||
$this->sourceMapGenerator->addMapping(
|
||||
$this->currentLine,
|
||||
$this->currentColumn,
|
||||
$this->currentBlock->sourceLine,
|
||||
//columns from parser are off by one
|
||||
$this->currentBlock->sourceColumn > 0 ? $this->currentBlock->sourceColumn - 1 : 0,
|
||||
$this->currentBlock->sourceName
|
||||
);
|
||||
}
|
||||
$this->currentLine++;
|
||||
$this->currentColumn = 0;
|
||||
}
|
||||
if ($lastLine !== '') {
|
||||
\assert($this->currentBlock->sourceLine !== null);
|
||||
\assert($this->currentBlock->sourceName !== null);
|
||||
$this->sourceMapGenerator->addMapping(
|
||||
$this->currentLine,
|
||||
$this->currentColumn,
|
||||
$this->currentBlock->sourceLine,
|
||||
//columns from parser are off by one
|
||||
$this->currentBlock->sourceColumn > 0 ? $this->currentBlock->sourceColumn - 1 : 0,
|
||||
$this->currentBlock->sourceName
|
||||
);
|
||||
}
|
||||
$this->currentColumn += \strlen($lastLine);
|
||||
}
|
||||
echo $str;
|
||||
}
|
||||
}
|
48
dependencies/scssphp/scssphp/src/Formatter/Compact.php
vendored
Normal file
48
dependencies/scssphp/scssphp/src/Formatter/Compact.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter;
|
||||
/**
|
||||
* Compact formatter
|
||||
*
|
||||
* @author Leaf Corcoran <leafot@gmail.com>
|
||||
*
|
||||
* @deprecated since 1.4.0. Use the Compressed formatter instead.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Compact extends Formatter
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@\trigger_error('The Compact formatter is deprecated since 1.4.0. Use the Compressed formatter instead.', \E_USER_DEPRECATED);
|
||||
$this->indentLevel = 0;
|
||||
$this->indentChar = '';
|
||||
$this->break = '';
|
||||
$this->open = ' {';
|
||||
$this->close = "}\n\n";
|
||||
$this->tagSeparator = ',';
|
||||
$this->assignSeparator = ':';
|
||||
$this->keepSemicolons = \true;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function indentStr()
|
||||
{
|
||||
return ' ';
|
||||
}
|
||||
}
|
66
dependencies/scssphp/scssphp/src/Formatter/Compressed.php
vendored
Normal file
66
dependencies/scssphp/scssphp/src/Formatter/Compressed.php
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter;
|
||||
/**
|
||||
* Compressed formatter
|
||||
*
|
||||
* @author Leaf Corcoran <leafot@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Compressed extends Formatter
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->indentLevel = 0;
|
||||
$this->indentChar = ' ';
|
||||
$this->break = '';
|
||||
$this->open = '{';
|
||||
$this->close = '}';
|
||||
$this->tagSeparator = ',';
|
||||
$this->assignSeparator = ':';
|
||||
$this->keepSemicolons = \false;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function blockLines(OutputBlock $block)
|
||||
{
|
||||
$inner = $this->indentStr();
|
||||
$glue = $this->break . $inner;
|
||||
foreach ($block->lines as $index => $line) {
|
||||
if (\substr($line, 0, 2) === '/*' && \substr($line, 2, 1) !== '!') {
|
||||
unset($block->lines[$index]);
|
||||
}
|
||||
}
|
||||
$this->write($inner . \implode($glue, $block->lines));
|
||||
if (!empty($block->children)) {
|
||||
$this->write($this->break);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Output block selectors
|
||||
*
|
||||
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
|
||||
*/
|
||||
protected function blockSelectors(OutputBlock $block)
|
||||
{
|
||||
\assert(!empty($block->selectors));
|
||||
$inner = $this->indentStr();
|
||||
$this->write($inner . \implode($this->tagSeparator, \str_replace([' > ', ' + ', ' ~ '], ['>', '+', '~'], $block->selectors)) . $this->open . $this->break);
|
||||
}
|
||||
}
|
69
dependencies/scssphp/scssphp/src/Formatter/Crunched.php
vendored
Normal file
69
dependencies/scssphp/scssphp/src/Formatter/Crunched.php
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter;
|
||||
/**
|
||||
* Crunched formatter
|
||||
*
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*
|
||||
* @deprecated since 1.4.0. Use the Compressed formatter instead.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Crunched extends Formatter
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@\trigger_error('The Crunched formatter is deprecated since 1.4.0. Use the Compressed formatter instead.', \E_USER_DEPRECATED);
|
||||
$this->indentLevel = 0;
|
||||
$this->indentChar = ' ';
|
||||
$this->break = '';
|
||||
$this->open = '{';
|
||||
$this->close = '}';
|
||||
$this->tagSeparator = ',';
|
||||
$this->assignSeparator = ':';
|
||||
$this->keepSemicolons = \false;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function blockLines(OutputBlock $block)
|
||||
{
|
||||
$inner = $this->indentStr();
|
||||
$glue = $this->break . $inner;
|
||||
foreach ($block->lines as $index => $line) {
|
||||
if (\substr($line, 0, 2) === '/*') {
|
||||
unset($block->lines[$index]);
|
||||
}
|
||||
}
|
||||
$this->write($inner . \implode($glue, $block->lines));
|
||||
if (!empty($block->children)) {
|
||||
$this->write($this->break);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Output block selectors
|
||||
*
|
||||
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
|
||||
*/
|
||||
protected function blockSelectors(OutputBlock $block)
|
||||
{
|
||||
\assert(!empty($block->selectors));
|
||||
$inner = $this->indentStr();
|
||||
$this->write($inner . \implode($this->tagSeparator, \str_replace([' > ', ' + ', ' ~ '], ['>', '+', '~'], $block->selectors)) . $this->open . $this->break);
|
||||
}
|
||||
}
|
104
dependencies/scssphp/scssphp/src/Formatter/Debug.php
vendored
Normal file
104
dependencies/scssphp/scssphp/src/Formatter/Debug.php
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter;
|
||||
/**
|
||||
* Debug formatter
|
||||
*
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*
|
||||
* @deprecated since 1.4.0.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Debug extends Formatter
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@\trigger_error('The Debug formatter is deprecated since 1.4.0.', \E_USER_DEPRECATED);
|
||||
$this->indentLevel = 0;
|
||||
$this->indentChar = '';
|
||||
$this->break = "\n";
|
||||
$this->open = ' {';
|
||||
$this->close = ' }';
|
||||
$this->tagSeparator = ', ';
|
||||
$this->assignSeparator = ': ';
|
||||
$this->keepSemicolons = \true;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function indentStr()
|
||||
{
|
||||
return \str_repeat(' ', $this->indentLevel);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function blockLines(OutputBlock $block)
|
||||
{
|
||||
$indent = $this->indentStr();
|
||||
if (empty($block->lines)) {
|
||||
$this->write("{$indent}block->lines: []\n");
|
||||
return;
|
||||
}
|
||||
foreach ($block->lines as $index => $line) {
|
||||
$this->write("{$indent}block->lines[{$index}]: {$line}\n");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function blockSelectors(OutputBlock $block)
|
||||
{
|
||||
$indent = $this->indentStr();
|
||||
if (empty($block->selectors)) {
|
||||
$this->write("{$indent}block->selectors: []\n");
|
||||
return;
|
||||
}
|
||||
foreach ($block->selectors as $index => $selector) {
|
||||
$this->write("{$indent}block->selectors[{$index}]: {$selector}\n");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function blockChildren(OutputBlock $block)
|
||||
{
|
||||
$indent = $this->indentStr();
|
||||
if (empty($block->children)) {
|
||||
$this->write("{$indent}block->children: []\n");
|
||||
return;
|
||||
}
|
||||
$this->indentLevel++;
|
||||
foreach ($block->children as $i => $child) {
|
||||
$this->block($child);
|
||||
}
|
||||
$this->indentLevel--;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function block(OutputBlock $block)
|
||||
{
|
||||
$indent = $this->indentStr();
|
||||
$this->write("{$indent}block->type: {$block->type}\n" . "{$indent}block->depth: {$block->depth}\n");
|
||||
$this->currentBlock = $block;
|
||||
$this->blockSelectors($block);
|
||||
$this->blockLines($block);
|
||||
$this->blockChildren($block);
|
||||
}
|
||||
}
|
64
dependencies/scssphp/scssphp/src/Formatter/Expanded.php
vendored
Normal file
64
dependencies/scssphp/scssphp/src/Formatter/Expanded.php
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter;
|
||||
/**
|
||||
* Expanded formatter
|
||||
*
|
||||
* @author Leaf Corcoran <leafot@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Expanded extends Formatter
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->indentLevel = 0;
|
||||
$this->indentChar = ' ';
|
||||
$this->break = "\n";
|
||||
$this->open = ' {';
|
||||
$this->close = '}';
|
||||
$this->tagSeparator = ', ';
|
||||
$this->assignSeparator = ': ';
|
||||
$this->keepSemicolons = \true;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function indentStr()
|
||||
{
|
||||
return \str_repeat($this->indentChar, $this->indentLevel);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function blockLines(OutputBlock $block)
|
||||
{
|
||||
$inner = $this->indentStr();
|
||||
$glue = $this->break . $inner;
|
||||
foreach ($block->lines as $index => $line) {
|
||||
if (\substr($line, 0, 2) === '/*') {
|
||||
$replacedLine = \preg_replace('/\\r\\n?|\\n|\\f/', $this->break, $line);
|
||||
\assert($replacedLine !== null);
|
||||
$block->lines[$index] = $replacedLine;
|
||||
}
|
||||
}
|
||||
$this->write($inner . \implode($glue, $block->lines));
|
||||
if (empty($block->selectors) || !empty($block->children)) {
|
||||
$this->write($this->break);
|
||||
}
|
||||
}
|
||||
}
|
192
dependencies/scssphp/scssphp/src/Formatter/Nested.php
vendored
Normal file
192
dependencies/scssphp/scssphp/src/Formatter/Nested.php
vendored
Normal file
@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Type;
|
||||
/**
|
||||
* Nested formatter
|
||||
*
|
||||
* @author Leaf Corcoran <leafot@gmail.com>
|
||||
*
|
||||
* @deprecated since 1.4.0. Use the Expanded formatter instead.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Nested extends Formatter
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $depth;
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@\trigger_error('The Nested formatter is deprecated since 1.4.0. Use the Expanded formatter instead.', \E_USER_DEPRECATED);
|
||||
$this->indentLevel = 0;
|
||||
$this->indentChar = ' ';
|
||||
$this->break = "\n";
|
||||
$this->open = ' {';
|
||||
$this->close = ' }';
|
||||
$this->tagSeparator = ', ';
|
||||
$this->assignSeparator = ': ';
|
||||
$this->keepSemicolons = \true;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function indentStr()
|
||||
{
|
||||
$n = $this->depth - 1;
|
||||
return \str_repeat($this->indentChar, \max($this->indentLevel + $n, 0));
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function blockLines(OutputBlock $block)
|
||||
{
|
||||
$inner = $this->indentStr();
|
||||
$glue = $this->break . $inner;
|
||||
foreach ($block->lines as $index => $line) {
|
||||
if (\substr($line, 0, 2) === '/*') {
|
||||
$replacedLine = \preg_replace('/\\r\\n?|\\n|\\f/', $this->break, $line);
|
||||
\assert($replacedLine !== null);
|
||||
$block->lines[$index] = $replacedLine;
|
||||
}
|
||||
}
|
||||
$this->write($inner . \implode($glue, $block->lines));
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function block(OutputBlock $block)
|
||||
{
|
||||
static $depths;
|
||||
static $downLevel;
|
||||
static $closeBlock;
|
||||
static $previousEmpty;
|
||||
static $previousHasSelector;
|
||||
if ($block->type === 'root') {
|
||||
$depths = [0];
|
||||
$downLevel = '';
|
||||
$closeBlock = '';
|
||||
$this->depth = 0;
|
||||
$previousEmpty = \false;
|
||||
$previousHasSelector = \false;
|
||||
}
|
||||
$isMediaOrDirective = \in_array($block->type, [Type::T_DIRECTIVE, Type::T_MEDIA]);
|
||||
$isSupport = $block->type === Type::T_DIRECTIVE && $block->selectors && \strpos(\implode('', $block->selectors), '@supports') !== \false;
|
||||
while ($block->depth < \end($depths) || $block->depth == 1 && \end($depths) == 1) {
|
||||
\array_pop($depths);
|
||||
$this->depth--;
|
||||
if (!$this->depth && ($block->depth <= 1 || !$this->indentLevel && $block->type === Type::T_COMMENT) && ($block->selectors && !$isMediaOrDirective || $previousHasSelector)) {
|
||||
$downLevel = $this->break;
|
||||
}
|
||||
if (empty($block->lines) && empty($block->children)) {
|
||||
$previousEmpty = \true;
|
||||
}
|
||||
}
|
||||
if (empty($block->lines) && empty($block->children)) {
|
||||
return;
|
||||
}
|
||||
$this->currentBlock = $block;
|
||||
if (!empty($block->lines) || !empty($block->children) && ($this->depth < 1 || $isSupport)) {
|
||||
if ($block->depth > \end($depths)) {
|
||||
if (!$previousEmpty || $this->depth < 1) {
|
||||
$this->depth++;
|
||||
$depths[] = $block->depth;
|
||||
} else {
|
||||
// keep the current depth unchanged but take the block depth as a new reference for following blocks
|
||||
\array_pop($depths);
|
||||
$depths[] = $block->depth;
|
||||
}
|
||||
}
|
||||
}
|
||||
$previousEmpty = $block->type === Type::T_COMMENT;
|
||||
$previousHasSelector = \false;
|
||||
if (!empty($block->selectors)) {
|
||||
if ($closeBlock) {
|
||||
$this->write($closeBlock);
|
||||
$closeBlock = '';
|
||||
}
|
||||
if ($downLevel) {
|
||||
$this->write($downLevel);
|
||||
$downLevel = '';
|
||||
}
|
||||
$this->blockSelectors($block);
|
||||
$this->indentLevel++;
|
||||
}
|
||||
if (!empty($block->lines)) {
|
||||
if ($closeBlock) {
|
||||
$this->write($closeBlock);
|
||||
$closeBlock = '';
|
||||
}
|
||||
if ($downLevel) {
|
||||
$this->write($downLevel);
|
||||
$downLevel = '';
|
||||
}
|
||||
$this->blockLines($block);
|
||||
$closeBlock = $this->break;
|
||||
}
|
||||
if (!empty($block->children)) {
|
||||
if ($this->depth > 0 && ($isMediaOrDirective || !$this->hasFlatChild($block))) {
|
||||
\array_pop($depths);
|
||||
$this->depth--;
|
||||
$this->blockChildren($block);
|
||||
$this->depth++;
|
||||
$depths[] = $block->depth;
|
||||
} else {
|
||||
$this->blockChildren($block);
|
||||
}
|
||||
}
|
||||
// reclear to not be spoiled by children if T_DIRECTIVE
|
||||
if ($block->type === Type::T_DIRECTIVE) {
|
||||
$previousHasSelector = \false;
|
||||
}
|
||||
if (!empty($block->selectors)) {
|
||||
$this->indentLevel--;
|
||||
if (!$this->keepSemicolons) {
|
||||
$this->strippedSemicolon = '';
|
||||
}
|
||||
$this->write($this->close);
|
||||
$closeBlock = $this->break;
|
||||
if ($this->depth > 1 && !empty($block->children)) {
|
||||
\array_pop($depths);
|
||||
$this->depth--;
|
||||
}
|
||||
if (!$isMediaOrDirective) {
|
||||
$previousHasSelector = \true;
|
||||
}
|
||||
}
|
||||
if ($block->type === 'root') {
|
||||
$this->write($this->break);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Block has flat child
|
||||
*
|
||||
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function hasFlatChild($block)
|
||||
{
|
||||
foreach ($block->children as $child) {
|
||||
if (empty($child->selectors)) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
}
|
59
dependencies/scssphp/scssphp/src/Formatter/OutputBlock.php
vendored
Normal file
59
dependencies/scssphp/scssphp/src/Formatter/OutputBlock.php
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Formatter;
|
||||
|
||||
/**
|
||||
* Output block
|
||||
*
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class OutputBlock
|
||||
{
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
public $type;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $depth;
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
public $selectors;
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $lines;
|
||||
/**
|
||||
* @var OutputBlock[]
|
||||
*/
|
||||
public $children;
|
||||
/**
|
||||
* @var OutputBlock|null
|
||||
*/
|
||||
public $parent;
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
public $sourceName;
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
public $sourceLine;
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
public $sourceColumn;
|
||||
}
|
46
dependencies/scssphp/scssphp/src/Logger/LoggerInterface.php
vendored
Normal file
46
dependencies/scssphp/scssphp/src/Logger/LoggerInterface.php
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Logger;
|
||||
|
||||
/**
|
||||
* Interface implemented by loggers for warnings and debug messages.
|
||||
*
|
||||
* The official Sass implementation recommends that loggers report the
|
||||
* messages immediately rather than waiting for the end of the
|
||||
* compilation, to provide a better debugging experience when the
|
||||
* compilation does not end (error or infinite loop after the warning
|
||||
* for instance).
|
||||
*/
|
||||
interface LoggerInterface
|
||||
{
|
||||
/**
|
||||
* Emits a warning with the given message.
|
||||
*
|
||||
* If $deprecation is true, it indicates that this is a deprecation
|
||||
* warning. Implementations should surface all this information to
|
||||
* the end user.
|
||||
*
|
||||
* @param string $message
|
||||
* @param bool $deprecation
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function warn($message, $deprecation = \false);
|
||||
/**
|
||||
* Emits a debugging message.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function debug($message);
|
||||
}
|
27
dependencies/scssphp/scssphp/src/Logger/QuietLogger.php
vendored
Normal file
27
dependencies/scssphp/scssphp/src/Logger/QuietLogger.php
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Logger;
|
||||
|
||||
/**
|
||||
* A logger that silently ignores all messages.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class QuietLogger implements LoggerInterface
|
||||
{
|
||||
public function warn($message, $deprecation = \false)
|
||||
{
|
||||
}
|
||||
public function debug($message)
|
||||
{
|
||||
}
|
||||
}
|
56
dependencies/scssphp/scssphp/src/Logger/StreamLogger.php
vendored
Normal file
56
dependencies/scssphp/scssphp/src/Logger/StreamLogger.php
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Logger;
|
||||
|
||||
/**
|
||||
* A logger that prints to a PHP stream (for instance stderr)
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class StreamLogger implements LoggerInterface
|
||||
{
|
||||
private $stream;
|
||||
private $closeOnDestruct;
|
||||
/**
|
||||
* @param resource $stream A stream resource
|
||||
* @param bool $closeOnDestruct If true, takes ownership of the stream and close it on destruct to avoid leaks.
|
||||
*/
|
||||
public function __construct($stream, $closeOnDestruct = \false)
|
||||
{
|
||||
$this->stream = $stream;
|
||||
$this->closeOnDestruct = $closeOnDestruct;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if ($this->closeOnDestruct) {
|
||||
\fclose($this->stream);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function warn($message, $deprecation = \false)
|
||||
{
|
||||
$prefix = ($deprecation ? 'DEPRECATION ' : '') . 'WARNING: ';
|
||||
\fwrite($this->stream, $prefix . $message . "\n\n");
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function debug($message)
|
||||
{
|
||||
\fwrite($this->stream, $message . "\n");
|
||||
}
|
||||
}
|
39
dependencies/scssphp/scssphp/src/Node.php
vendored
Normal file
39
dependencies/scssphp/scssphp/src/Node.php
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp;
|
||||
|
||||
/**
|
||||
* Base node
|
||||
*
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract class Node
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $sourceIndex;
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
public $sourceLine;
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
public $sourceColumn;
|
||||
}
|
682
dependencies/scssphp/scssphp/src/Node/Number.php
vendored
Normal file
682
dependencies/scssphp/scssphp/src/Node/Number.php
vendored
Normal file
@ -0,0 +1,682 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Node;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Base\Range;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Compiler;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Exception\RangeException;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Exception\SassScriptException;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Node;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Type;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Util;
|
||||
/**
|
||||
* Dimension + optional units
|
||||
*
|
||||
* {@internal
|
||||
* This is a work-in-progress.
|
||||
*
|
||||
* The \ArrayAccess interface is temporary until the migration is complete.
|
||||
* }}
|
||||
*
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*
|
||||
* @template-implements \ArrayAccess<int, mixed>
|
||||
*/
|
||||
class Number extends Node implements \ArrayAccess
|
||||
{
|
||||
const PRECISION = 10;
|
||||
/**
|
||||
* @var int
|
||||
* @deprecated use {Number::PRECISION} instead to read the precision. Configuring it is not supported anymore.
|
||||
*/
|
||||
public static $precision = self::PRECISION;
|
||||
/**
|
||||
* @see http://www.w3.org/TR/2012/WD-css3-values-20120308/
|
||||
*
|
||||
* @var array
|
||||
* @phpstan-var array<string, array<string, float|int>>
|
||||
*/
|
||||
protected static $unitTable = ['in' => ['in' => 1, 'pc' => 6, 'pt' => 72, 'px' => 96, 'cm' => 2.54, 'mm' => 25.4, 'q' => 101.6], 'turn' => [
|
||||
'deg' => 360,
|
||||
'grad' => 400,
|
||||
'rad' => 6.283185307179586,
|
||||
// 2 * M_PI
|
||||
'turn' => 1,
|
||||
], 's' => ['s' => 1, 'ms' => 1000], 'Hz' => ['Hz' => 1, 'kHz' => 0.001], 'dpi' => ['dpi' => 1, 'dpcm' => 1 / 2.54, 'dppx' => 1 / 96]];
|
||||
/**
|
||||
* @var int|float
|
||||
*/
|
||||
private $dimension;
|
||||
/**
|
||||
* @var string[]
|
||||
* @phpstan-var list<string>
|
||||
*/
|
||||
private $numeratorUnits;
|
||||
/**
|
||||
* @var string[]
|
||||
* @phpstan-var list<string>
|
||||
*/
|
||||
private $denominatorUnits;
|
||||
/**
|
||||
* Initialize number
|
||||
*
|
||||
* @param int|float $dimension
|
||||
* @param string[]|string $numeratorUnits
|
||||
* @param string[] $denominatorUnits
|
||||
*
|
||||
* @phpstan-param list<string>|string $numeratorUnits
|
||||
* @phpstan-param list<string> $denominatorUnits
|
||||
*/
|
||||
public function __construct($dimension, $numeratorUnits, array $denominatorUnits = [])
|
||||
{
|
||||
if (\is_string($numeratorUnits)) {
|
||||
$numeratorUnits = $numeratorUnits ? [$numeratorUnits] : [];
|
||||
} elseif (isset($numeratorUnits['numerator_units'], $numeratorUnits['denominator_units'])) {
|
||||
// TODO get rid of this once `$number[2]` is not used anymore
|
||||
$denominatorUnits = $numeratorUnits['denominator_units'];
|
||||
$numeratorUnits = $numeratorUnits['numerator_units'];
|
||||
}
|
||||
$this->dimension = $dimension;
|
||||
$this->numeratorUnits = $numeratorUnits;
|
||||
$this->denominatorUnits = $denominatorUnits;
|
||||
}
|
||||
/**
|
||||
* @return float|int
|
||||
*/
|
||||
public function getDimension()
|
||||
{
|
||||
return $this->dimension;
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getNumeratorUnits()
|
||||
{
|
||||
return $this->numeratorUnits;
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDenominatorUnits()
|
||||
{
|
||||
return $this->denominatorUnits;
|
||||
}
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
if ($offset === -3) {
|
||||
return !\is_null($this->sourceColumn);
|
||||
}
|
||||
if ($offset === -2) {
|
||||
return !\is_null($this->sourceLine);
|
||||
}
|
||||
if ($offset === -1 || $offset === 0 || $offset === 1 || $offset === 2) {
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
switch ($offset) {
|
||||
case -3:
|
||||
return $this->sourceColumn;
|
||||
case -2:
|
||||
return $this->sourceLine;
|
||||
case -1:
|
||||
return $this->sourceIndex;
|
||||
case 0:
|
||||
return Type::T_NUMBER;
|
||||
case 1:
|
||||
return $this->dimension;
|
||||
case 2:
|
||||
return array('numerator_units' => $this->numeratorUnits, 'denominator_units' => $this->denominatorUnits);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
throw new \BadMethodCallException('Number is immutable');
|
||||
}
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
throw new \BadMethodCallException('Number is immutable');
|
||||
}
|
||||
/**
|
||||
* Returns true if the number is unitless
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function unitless()
|
||||
{
|
||||
return \count($this->numeratorUnits) === 0 && \count($this->denominatorUnits) === 0;
|
||||
}
|
||||
/**
|
||||
* Returns true if the number has any units
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasUnits()
|
||||
{
|
||||
return !$this->unitless();
|
||||
}
|
||||
/**
|
||||
* Checks whether the number has exactly this unit
|
||||
*
|
||||
* @param string $unit
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasUnit($unit)
|
||||
{
|
||||
return \count($this->numeratorUnits) === 1 && \count($this->denominatorUnits) === 0 && $this->numeratorUnits[0] === $unit;
|
||||
}
|
||||
/**
|
||||
* Returns unit(s) as the product of numerator units divided by the product of denominator units
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function unitStr()
|
||||
{
|
||||
if ($this->unitless()) {
|
||||
return '';
|
||||
}
|
||||
return self::getUnitString($this->numeratorUnits, $this->denominatorUnits);
|
||||
}
|
||||
/**
|
||||
* @param float|int $min
|
||||
* @param float|int $max
|
||||
* @param string|null $name
|
||||
*
|
||||
* @return float|int
|
||||
* @throws SassScriptException
|
||||
*/
|
||||
public function valueInRange($min, $max, $name = null)
|
||||
{
|
||||
try {
|
||||
return Util::checkRange('', new Range($min, $max), $this);
|
||||
} catch (RangeException $e) {
|
||||
throw SassScriptException::forArgument(\sprintf('Expected %s to be within %s%s and %s%3$s.', $this, $min, $this->unitStr(), $max), $name);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param float|int $min
|
||||
* @param float|int $max
|
||||
* @param string $name
|
||||
* @param string $unit
|
||||
*
|
||||
* @return float|int
|
||||
* @throws SassScriptException
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function valueInRangeWithUnit($min, $max, $name, $unit)
|
||||
{
|
||||
try {
|
||||
return Util::checkRange('', new Range($min, $max), $this);
|
||||
} catch (RangeException $e) {
|
||||
throw SassScriptException::forArgument(\sprintf('Expected %s to be within %s%s and %s%3$s.', $this, $min, $unit, $max), $name);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param string|null $varName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function assertNoUnits($varName = null)
|
||||
{
|
||||
if ($this->unitless()) {
|
||||
return;
|
||||
}
|
||||
throw SassScriptException::forArgument(\sprintf('Expected %s to have no units.', $this), $varName);
|
||||
}
|
||||
/**
|
||||
* @param string $unit
|
||||
* @param string|null $varName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function assertUnit($unit, $varName = null)
|
||||
{
|
||||
if ($this->hasUnit($unit)) {
|
||||
return;
|
||||
}
|
||||
throw SassScriptException::forArgument(\sprintf('Expected %s to have unit "%s".', $this, $unit), $varName);
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function assertSameUnitOrUnitless(Number $other)
|
||||
{
|
||||
if ($other->unitless()) {
|
||||
return;
|
||||
}
|
||||
if ($this->numeratorUnits === $other->numeratorUnits && $this->denominatorUnits === $other->denominatorUnits) {
|
||||
return;
|
||||
}
|
||||
throw new SassScriptException(\sprintf('Incompatible units %s and %s.', self::getUnitString($this->numeratorUnits, $this->denominatorUnits), self::getUnitString($other->numeratorUnits, $other->denominatorUnits)));
|
||||
}
|
||||
/**
|
||||
* Returns a copy of this number, converted to the units represented by $newNumeratorUnits and $newDenominatorUnits.
|
||||
*
|
||||
* This does not throw an error if this number is unitless and
|
||||
* $newNumeratorUnits/$newDenominatorUnits are not empty, or vice versa. Instead,
|
||||
* it treats all unitless numbers as convertible to and from all units without
|
||||
* changing the value.
|
||||
*
|
||||
* @param string[] $newNumeratorUnits
|
||||
* @param string[] $newDenominatorUnits
|
||||
*
|
||||
* @return Number
|
||||
*
|
||||
* @phpstan-param list<string> $newNumeratorUnits
|
||||
* @phpstan-param list<string> $newDenominatorUnits
|
||||
*
|
||||
* @throws SassScriptException if this number's units are not compatible with $newNumeratorUnits and $newDenominatorUnits
|
||||
*/
|
||||
public function coerce(array $newNumeratorUnits, array $newDenominatorUnits)
|
||||
{
|
||||
return new Number($this->valueInUnits($newNumeratorUnits, $newDenominatorUnits), $newNumeratorUnits, $newDenominatorUnits);
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isComparableTo(Number $other)
|
||||
{
|
||||
if ($this->unitless() || $other->unitless()) {
|
||||
return \true;
|
||||
}
|
||||
try {
|
||||
$this->greaterThan($other);
|
||||
return \true;
|
||||
} catch (SassScriptException $e) {
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function lessThan(Number $other)
|
||||
{
|
||||
return $this->coerceUnits($other, function ($num1, $num2) {
|
||||
return $num1 < $num2;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function lessThanOrEqual(Number $other)
|
||||
{
|
||||
return $this->coerceUnits($other, function ($num1, $num2) {
|
||||
return $num1 <= $num2;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function greaterThan(Number $other)
|
||||
{
|
||||
return $this->coerceUnits($other, function ($num1, $num2) {
|
||||
return $num1 > $num2;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function greaterThanOrEqual(Number $other)
|
||||
{
|
||||
return $this->coerceUnits($other, function ($num1, $num2) {
|
||||
return $num1 >= $num2;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
*
|
||||
* @return Number
|
||||
*/
|
||||
public function plus(Number $other)
|
||||
{
|
||||
return $this->coerceNumber($other, function ($num1, $num2) {
|
||||
return $num1 + $num2;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
*
|
||||
* @return Number
|
||||
*/
|
||||
public function minus(Number $other)
|
||||
{
|
||||
return $this->coerceNumber($other, function ($num1, $num2) {
|
||||
return $num1 - $num2;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @return Number
|
||||
*/
|
||||
public function unaryMinus()
|
||||
{
|
||||
return new Number(-$this->dimension, $this->numeratorUnits, $this->denominatorUnits);
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
*
|
||||
* @return Number
|
||||
*/
|
||||
public function modulo(Number $other)
|
||||
{
|
||||
return $this->coerceNumber($other, function ($num1, $num2) {
|
||||
if ($num2 == 0) {
|
||||
return \NAN;
|
||||
}
|
||||
$result = \fmod($num1, $num2);
|
||||
if ($result == 0) {
|
||||
return 0;
|
||||
}
|
||||
if ($num2 < 0 xor $num1 < 0) {
|
||||
$result += $num2;
|
||||
}
|
||||
return $result;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
*
|
||||
* @return Number
|
||||
*/
|
||||
public function times(Number $other)
|
||||
{
|
||||
return $this->multiplyUnits($this->dimension * $other->dimension, $this->numeratorUnits, $this->denominatorUnits, $other->numeratorUnits, $other->denominatorUnits);
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
*
|
||||
* @return Number
|
||||
*/
|
||||
public function dividedBy(Number $other)
|
||||
{
|
||||
if ($other->dimension == 0) {
|
||||
if ($this->dimension == 0) {
|
||||
$value = \NAN;
|
||||
} elseif ($this->dimension > 0) {
|
||||
$value = \INF;
|
||||
} else {
|
||||
$value = -\INF;
|
||||
}
|
||||
} else {
|
||||
$value = $this->dimension / $other->dimension;
|
||||
}
|
||||
return $this->multiplyUnits($value, $this->numeratorUnits, $this->denominatorUnits, $other->denominatorUnits, $other->numeratorUnits);
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function equals(Number $other)
|
||||
{
|
||||
// Unitless numbers are convertable to unit numbers, but not equal, so we special-case unitless here.
|
||||
if ($this->unitless() !== $other->unitless()) {
|
||||
return \false;
|
||||
}
|
||||
// In Sass, neither NaN nor Infinity are equal to themselves, while PHP defines INF==INF
|
||||
if (\is_nan($this->dimension) || \is_nan($other->dimension) || !\is_finite($this->dimension) || !\is_finite($other->dimension)) {
|
||||
return \false;
|
||||
}
|
||||
if ($this->unitless()) {
|
||||
return \round($this->dimension, self::PRECISION) == \round($other->dimension, self::PRECISION);
|
||||
}
|
||||
try {
|
||||
return $this->coerceUnits($other, function ($num1, $num2) {
|
||||
return \round($num1, self::PRECISION) == \round($num2, self::PRECISION);
|
||||
});
|
||||
} catch (SassScriptException $e) {
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Output number
|
||||
*
|
||||
* @param \ScssPhp\ScssPhp\Compiler $compiler
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function output(Compiler $compiler = null)
|
||||
{
|
||||
$dimension = \round($this->dimension, self::PRECISION);
|
||||
if (\is_nan($dimension)) {
|
||||
return 'NaN';
|
||||
}
|
||||
if ($dimension === \INF) {
|
||||
return 'Infinity';
|
||||
}
|
||||
if ($dimension === -\INF) {
|
||||
return '-Infinity';
|
||||
}
|
||||
if ($compiler) {
|
||||
$unit = $this->unitStr();
|
||||
} elseif (isset($this->numeratorUnits[0])) {
|
||||
$unit = $this->numeratorUnits[0];
|
||||
} else {
|
||||
$unit = '';
|
||||
}
|
||||
$dimension = \number_format($dimension, self::PRECISION, '.', '');
|
||||
return \rtrim(\rtrim($dimension, '0'), '.') . $unit;
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->output();
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
* @param callable $operation
|
||||
*
|
||||
* @return Number
|
||||
*
|
||||
* @phpstan-param callable(int|float, int|float): (int|float) $operation
|
||||
*/
|
||||
private function coerceNumber(Number $other, $operation)
|
||||
{
|
||||
$result = $this->coerceUnits($other, $operation);
|
||||
if (!$this->unitless()) {
|
||||
return new Number($result, $this->numeratorUnits, $this->denominatorUnits);
|
||||
}
|
||||
return new Number($result, $other->numeratorUnits, $other->denominatorUnits);
|
||||
}
|
||||
/**
|
||||
* @param Number $other
|
||||
* @param callable $operation
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @phpstan-template T
|
||||
* @phpstan-param callable(int|float, int|float): T $operation
|
||||
* @phpstan-return T
|
||||
*/
|
||||
private function coerceUnits(Number $other, $operation)
|
||||
{
|
||||
if (!$this->unitless()) {
|
||||
$num1 = $this->dimension;
|
||||
$num2 = $other->valueInUnits($this->numeratorUnits, $this->denominatorUnits);
|
||||
} else {
|
||||
$num1 = $this->valueInUnits($other->numeratorUnits, $other->denominatorUnits);
|
||||
$num2 = $other->dimension;
|
||||
}
|
||||
return \call_user_func($operation, $num1, $num2);
|
||||
}
|
||||
/**
|
||||
* @param string[] $numeratorUnits
|
||||
* @param string[] $denominatorUnits
|
||||
*
|
||||
* @return int|float
|
||||
*
|
||||
* @phpstan-param list<string> $numeratorUnits
|
||||
* @phpstan-param list<string> $denominatorUnits
|
||||
*
|
||||
* @throws SassScriptException if this number's units are not compatible with $numeratorUnits and $denominatorUnits
|
||||
*/
|
||||
private function valueInUnits(array $numeratorUnits, array $denominatorUnits)
|
||||
{
|
||||
if ($this->unitless() || \count($numeratorUnits) === 0 && \count($denominatorUnits) === 0 || $this->numeratorUnits === $numeratorUnits && $this->denominatorUnits === $denominatorUnits) {
|
||||
return $this->dimension;
|
||||
}
|
||||
$value = $this->dimension;
|
||||
$oldNumerators = $this->numeratorUnits;
|
||||
foreach ($numeratorUnits as $newNumerator) {
|
||||
foreach ($oldNumerators as $key => $oldNumerator) {
|
||||
$conversionFactor = self::getConversionFactor($newNumerator, $oldNumerator);
|
||||
if (\is_null($conversionFactor)) {
|
||||
continue;
|
||||
}
|
||||
$value *= $conversionFactor;
|
||||
unset($oldNumerators[$key]);
|
||||
continue 2;
|
||||
}
|
||||
throw new SassScriptException(\sprintf('Incompatible units %s and %s.', self::getUnitString($this->numeratorUnits, $this->denominatorUnits), self::getUnitString($numeratorUnits, $denominatorUnits)));
|
||||
}
|
||||
$oldDenominators = $this->denominatorUnits;
|
||||
foreach ($denominatorUnits as $newDenominator) {
|
||||
foreach ($oldDenominators as $key => $oldDenominator) {
|
||||
$conversionFactor = self::getConversionFactor($newDenominator, $oldDenominator);
|
||||
if (\is_null($conversionFactor)) {
|
||||
continue;
|
||||
}
|
||||
$value /= $conversionFactor;
|
||||
unset($oldDenominators[$key]);
|
||||
continue 2;
|
||||
}
|
||||
throw new SassScriptException(\sprintf('Incompatible units %s and %s.', self::getUnitString($this->numeratorUnits, $this->denominatorUnits), self::getUnitString($numeratorUnits, $denominatorUnits)));
|
||||
}
|
||||
if (\count($oldNumerators) || \count($oldDenominators)) {
|
||||
throw new SassScriptException(\sprintf('Incompatible units %s and %s.', self::getUnitString($this->numeratorUnits, $this->denominatorUnits), self::getUnitString($numeratorUnits, $denominatorUnits)));
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
/**
|
||||
* @param int|float $value
|
||||
* @param string[] $numerators1
|
||||
* @param string[] $denominators1
|
||||
* @param string[] $numerators2
|
||||
* @param string[] $denominators2
|
||||
*
|
||||
* @return Number
|
||||
*
|
||||
* @phpstan-param list<string> $numerators1
|
||||
* @phpstan-param list<string> $denominators1
|
||||
* @phpstan-param list<string> $numerators2
|
||||
* @phpstan-param list<string> $denominators2
|
||||
*/
|
||||
private function multiplyUnits($value, array $numerators1, array $denominators1, array $numerators2, array $denominators2)
|
||||
{
|
||||
$newNumerators = array();
|
||||
foreach ($numerators1 as $numerator) {
|
||||
foreach ($denominators2 as $key => $denominator) {
|
||||
$conversionFactor = self::getConversionFactor($numerator, $denominator);
|
||||
if (\is_null($conversionFactor)) {
|
||||
continue;
|
||||
}
|
||||
$value /= $conversionFactor;
|
||||
unset($denominators2[$key]);
|
||||
continue 2;
|
||||
}
|
||||
$newNumerators[] = $numerator;
|
||||
}
|
||||
foreach ($numerators2 as $numerator) {
|
||||
foreach ($denominators1 as $key => $denominator) {
|
||||
$conversionFactor = self::getConversionFactor($numerator, $denominator);
|
||||
if (\is_null($conversionFactor)) {
|
||||
continue;
|
||||
}
|
||||
$value /= $conversionFactor;
|
||||
unset($denominators1[$key]);
|
||||
continue 2;
|
||||
}
|
||||
$newNumerators[] = $numerator;
|
||||
}
|
||||
$newDenominators = \array_values(\array_merge($denominators1, $denominators2));
|
||||
return new Number($value, $newNumerators, $newDenominators);
|
||||
}
|
||||
/**
|
||||
* Returns the number of [unit1]s per [unit2].
|
||||
*
|
||||
* Equivalently, `1unit1 * conversionFactor(unit1, unit2) = 1unit2`.
|
||||
*
|
||||
* @param string $unit1
|
||||
* @param string $unit2
|
||||
*
|
||||
* @return float|int|null
|
||||
*/
|
||||
private static function getConversionFactor($unit1, $unit2)
|
||||
{
|
||||
if ($unit1 === $unit2) {
|
||||
return 1;
|
||||
}
|
||||
foreach (static::$unitTable as $unitVariants) {
|
||||
if (isset($unitVariants[$unit1]) && isset($unitVariants[$unit2])) {
|
||||
return $unitVariants[$unit1] / $unitVariants[$unit2];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns unit(s) as the product of numerator units divided by the product of denominator units
|
||||
*
|
||||
* @param string[] $numerators
|
||||
* @param string[] $denominators
|
||||
*
|
||||
* @phpstan-param list<string> $numerators
|
||||
* @phpstan-param list<string> $denominators
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function getUnitString(array $numerators, array $denominators)
|
||||
{
|
||||
if (!\count($numerators)) {
|
||||
if (\count($denominators) === 0) {
|
||||
return 'no units';
|
||||
}
|
||||
if (\count($denominators) === 1) {
|
||||
return $denominators[0] . '^-1';
|
||||
}
|
||||
return '(' . \implode('*', $denominators) . ')^-1';
|
||||
}
|
||||
return \implode('*', $numerators) . (\count($denominators) ? '/' . \implode('*', $denominators) : '');
|
||||
}
|
||||
}
|
9
dependencies/scssphp/scssphp/src/OutputStyle.php
vendored
Normal file
9
dependencies/scssphp/scssphp/src/OutputStyle.php
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp;
|
||||
|
||||
final class OutputStyle
|
||||
{
|
||||
const EXPANDED = 'expanded';
|
||||
const COMPRESSED = 'compressed';
|
||||
}
|
3075
dependencies/scssphp/scssphp/src/Parser.php
vendored
Normal file
3075
dependencies/scssphp/scssphp/src/Parser.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
53
dependencies/scssphp/scssphp/src/SourceMap/Base64.php
vendored
Normal file
53
dependencies/scssphp/scssphp/src/SourceMap/Base64.php
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\SourceMap;
|
||||
|
||||
/**
|
||||
* Base 64 Encode/Decode
|
||||
*
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Base64
|
||||
{
|
||||
/**
|
||||
* @var array<int, string>
|
||||
*/
|
||||
private static $encodingMap = [0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D', 4 => 'E', 5 => 'F', 6 => 'G', 7 => 'H', 8 => 'I', 9 => 'J', 10 => 'K', 11 => 'L', 12 => 'M', 13 => 'N', 14 => 'O', 15 => 'P', 16 => 'Q', 17 => 'R', 18 => 'S', 19 => 'T', 20 => 'U', 21 => 'V', 22 => 'W', 23 => 'X', 24 => 'Y', 25 => 'Z', 26 => 'a', 27 => 'b', 28 => 'c', 29 => 'd', 30 => 'e', 31 => 'f', 32 => 'g', 33 => 'h', 34 => 'i', 35 => 'j', 36 => 'k', 37 => 'l', 38 => 'm', 39 => 'n', 40 => 'o', 41 => 'p', 42 => 'q', 43 => 'r', 44 => 's', 45 => 't', 46 => 'u', 47 => 'v', 48 => 'w', 49 => 'x', 50 => 'y', 51 => 'z', 52 => '0', 53 => '1', 54 => '2', 55 => '3', 56 => '4', 57 => '5', 58 => '6', 59 => '7', 60 => '8', 61 => '9', 62 => '+', 63 => '/'];
|
||||
/**
|
||||
* @var array<string|int, int>
|
||||
*/
|
||||
private static $decodingMap = ['A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6, 'H' => 7, 'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, 'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19, 'U' => 20, 'V' => 21, 'W' => 22, 'X' => 23, 'Y' => 24, 'Z' => 25, 'a' => 26, 'b' => 27, 'c' => 28, 'd' => 29, 'e' => 30, 'f' => 31, 'g' => 32, 'h' => 33, 'i' => 34, 'j' => 35, 'k' => 36, 'l' => 37, 'm' => 38, 'n' => 39, 'o' => 40, 'p' => 41, 'q' => 42, 'r' => 43, 's' => 44, 't' => 45, 'u' => 46, 'v' => 47, 'w' => 48, 'x' => 49, 'y' => 50, 'z' => 51, 0 => 52, 1 => 53, 2 => 54, 3 => 55, 4 => 56, 5 => 57, 6 => 58, 7 => 59, 8 => 60, 9 => 61, '+' => 62, '/' => 63];
|
||||
/**
|
||||
* Convert to base64
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function encode($value)
|
||||
{
|
||||
return self::$encodingMap[$value];
|
||||
}
|
||||
/**
|
||||
* Convert from base64
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function decode($value)
|
||||
{
|
||||
return self::$decodingMap[$value];
|
||||
}
|
||||
}
|
133
dependencies/scssphp/scssphp/src/SourceMap/Base64VLQ.php
vendored
Normal file
133
dependencies/scssphp/scssphp/src/SourceMap/Base64VLQ.php
vendored
Normal file
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\SourceMap;
|
||||
|
||||
/**
|
||||
* Base 64 VLQ
|
||||
*
|
||||
* Based on the Base 64 VLQ implementation in Closure Compiler:
|
||||
* https://github.com/google/closure-compiler/blob/master/src/com/google/debugging/sourcemap/Base64VLQ.java
|
||||
*
|
||||
* Copyright 2011 The Closure Compiler Authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @author John Lenz <johnlenz@google.com>
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Base64VLQ
|
||||
{
|
||||
// A Base64 VLQ digit can represent 5 bits, so it is base-32.
|
||||
const VLQ_BASE_SHIFT = 5;
|
||||
// A mask of bits for a VLQ digit (11111), 31 decimal.
|
||||
const VLQ_BASE_MASK = 31;
|
||||
// The continuation bit is the 6th bit.
|
||||
const VLQ_CONTINUATION_BIT = 32;
|
||||
/**
|
||||
* Returns the VLQ encoded value.
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function encode($value)
|
||||
{
|
||||
$encoded = '';
|
||||
$vlq = self::toVLQSigned($value);
|
||||
do {
|
||||
$digit = $vlq & self::VLQ_BASE_MASK;
|
||||
//$vlq >>>= self::VLQ_BASE_SHIFT; // unsigned right shift
|
||||
$vlq = ($vlq >> 1 & \PHP_INT_MAX) >> self::VLQ_BASE_SHIFT - 1;
|
||||
if ($vlq > 0) {
|
||||
$digit |= self::VLQ_CONTINUATION_BIT;
|
||||
}
|
||||
$encoded .= Base64::encode($digit);
|
||||
} while ($vlq > 0);
|
||||
return $encoded;
|
||||
}
|
||||
/**
|
||||
* Decodes VLQValue.
|
||||
*
|
||||
* @param string $str
|
||||
* @param int $index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function decode($str, &$index)
|
||||
{
|
||||
$result = 0;
|
||||
$shift = 0;
|
||||
do {
|
||||
$c = $str[$index++];
|
||||
$digit = Base64::decode($c);
|
||||
$continuation = ($digit & self::VLQ_CONTINUATION_BIT) != 0;
|
||||
$digit &= self::VLQ_BASE_MASK;
|
||||
$result = $result + ($digit << $shift);
|
||||
$shift = $shift + self::VLQ_BASE_SHIFT;
|
||||
} while ($continuation);
|
||||
return self::fromVLQSigned($result);
|
||||
}
|
||||
/**
|
||||
* Converts from a two-complement value to a value where the sign bit is
|
||||
* is placed in the least significant bit. For example, as decimals:
|
||||
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
|
||||
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private static function toVLQSigned($value)
|
||||
{
|
||||
if ($value < 0) {
|
||||
return (-$value << 1) + 1;
|
||||
}
|
||||
return ($value << 1) + 0;
|
||||
}
|
||||
/**
|
||||
* Converts to a two-complement value from a value where the sign bit is
|
||||
* is placed in the least significant bit. For example, as decimals:
|
||||
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
|
||||
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private static function fromVLQSigned($value)
|
||||
{
|
||||
$negate = ($value & 1) === 1;
|
||||
//$value >>>= 1; // unsigned right shift
|
||||
$value = $value >> 1 & \PHP_INT_MAX;
|
||||
if (!$negate) {
|
||||
return $value;
|
||||
}
|
||||
// We need to OR 0x80000000 here to ensure the 32nd bit (the sign bit) is
|
||||
// always set for negative numbers. If `value` were 1, (meaning `negate` is
|
||||
// true and all other bits were zeros), `value` would now be 0. -0 is just
|
||||
// 0, and doesn't flip the 32nd bit as intended. All positive numbers will
|
||||
// successfully flip the 32nd bit without issue, so it's a noop for them.
|
||||
return -$value | 0x80000000;
|
||||
}
|
||||
}
|
315
dependencies/scssphp/scssphp/src/SourceMap/SourceMapGenerator.php
vendored
Normal file
315
dependencies/scssphp/scssphp/src/SourceMap/SourceMapGenerator.php
vendored
Normal file
@ -0,0 +1,315 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\SourceMap;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Exception\CompilerException;
|
||||
/**
|
||||
* Source Map Generator
|
||||
*
|
||||
* {@internal Derivative of oyejorge/less.php's lib/SourceMap/Generator.php, relicensed with permission. }}
|
||||
*
|
||||
* @author Josh Schmidt <oyejorge@gmail.com>
|
||||
* @author Nicolas FRANÇOIS <nicolas.francois@frog-labs.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class SourceMapGenerator
|
||||
{
|
||||
/**
|
||||
* What version of source map does the generator generate?
|
||||
*/
|
||||
const VERSION = 3;
|
||||
/**
|
||||
* Array of default options
|
||||
*
|
||||
* @var array
|
||||
* @phpstan-var array{sourceRoot: string, sourceMapFilename: string|null, sourceMapURL: string|null, sourceMapWriteTo: string|null, outputSourceFiles: bool, sourceMapRootpath: string, sourceMapBasepath: string}
|
||||
*/
|
||||
protected $defaultOptions = [
|
||||
// an optional source root, useful for relocating source files
|
||||
// on a server or removing repeated values in the 'sources' entry.
|
||||
// This value is prepended to the individual entries in the 'source' field.
|
||||
'sourceRoot' => '',
|
||||
// an optional name of the generated code that this source map is associated with.
|
||||
'sourceMapFilename' => null,
|
||||
// url of the map
|
||||
'sourceMapURL' => null,
|
||||
// absolute path to a file to write the map to
|
||||
'sourceMapWriteTo' => null,
|
||||
// output source contents?
|
||||
'outputSourceFiles' => \false,
|
||||
// base path for filename normalization
|
||||
'sourceMapRootpath' => '',
|
||||
// base path for filename normalization
|
||||
'sourceMapBasepath' => '',
|
||||
];
|
||||
/**
|
||||
* The base64 VLQ encoder
|
||||
*
|
||||
* @var \ScssPhp\ScssPhp\SourceMap\Base64VLQ
|
||||
*/
|
||||
protected $encoder;
|
||||
/**
|
||||
* Array of mappings
|
||||
*
|
||||
* @var array
|
||||
* @phpstan-var list<array{generated_line: int, generated_column: int, original_line: int, original_column: int, source_file: string}>
|
||||
*/
|
||||
protected $mappings = [];
|
||||
/**
|
||||
* Array of contents map
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $contentsMap = [];
|
||||
/**
|
||||
* File to content map
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $sources = [];
|
||||
/**
|
||||
* @var array<string, int>
|
||||
*/
|
||||
protected $sourceKeys = [];
|
||||
/**
|
||||
* @var array
|
||||
* @phpstan-var array{sourceRoot: string, sourceMapFilename: string|null, sourceMapURL: string|null, sourceMapWriteTo: string|null, outputSourceFiles: bool, sourceMapRootpath: string, sourceMapBasepath: string}
|
||||
*/
|
||||
private $options;
|
||||
/**
|
||||
* @phpstan-param array{sourceRoot?: string, sourceMapFilename?: string|null, sourceMapURL?: string|null, sourceMapWriteTo?: string|null, outputSourceFiles?: bool, sourceMapRootpath?: string, sourceMapBasepath?: string} $options
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->options = \array_replace($this->defaultOptions, $options);
|
||||
$this->encoder = new Base64VLQ();
|
||||
}
|
||||
/**
|
||||
* Adds a mapping
|
||||
*
|
||||
* @param int $generatedLine The line number in generated file
|
||||
* @param int $generatedColumn The column number in generated file
|
||||
* @param int $originalLine The line number in original file
|
||||
* @param int $originalColumn The column number in original file
|
||||
* @param string $sourceFile The original source file
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $sourceFile)
|
||||
{
|
||||
$this->mappings[] = ['generated_line' => $generatedLine, 'generated_column' => $generatedColumn, 'original_line' => $originalLine, 'original_column' => $originalColumn, 'source_file' => $sourceFile];
|
||||
$this->sources[$sourceFile] = $sourceFile;
|
||||
}
|
||||
/**
|
||||
* Saves the source map to a file
|
||||
*
|
||||
* @param string $content The content to write
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @throws \ScssPhp\ScssPhp\Exception\CompilerException If the file could not be saved
|
||||
* @deprecated
|
||||
*/
|
||||
public function saveMap($content)
|
||||
{
|
||||
$file = $this->options['sourceMapWriteTo'];
|
||||
\assert($file !== null);
|
||||
$dir = \dirname($file);
|
||||
// directory does not exist
|
||||
if (!\is_dir($dir)) {
|
||||
// FIXME: create the dir automatically?
|
||||
throw new CompilerException(\sprintf('The directory "%s" does not exist. Cannot save the source map.', $dir));
|
||||
}
|
||||
// FIXME: proper saving, with dir write check!
|
||||
if (\file_put_contents($file, $content) === \false) {
|
||||
throw new CompilerException(\sprintf('Cannot save the source map to "%s"', $file));
|
||||
}
|
||||
return $this->options['sourceMapURL'];
|
||||
}
|
||||
/**
|
||||
* Generates the JSON source map
|
||||
*
|
||||
* @param string $prefix A prefix added in the output file, which needs to shift mappings
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @see https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#
|
||||
*/
|
||||
public function generateJson($prefix = '')
|
||||
{
|
||||
$sourceMap = [];
|
||||
$mappings = $this->generateMappings($prefix);
|
||||
// File version (always the first entry in the object) and must be a positive integer.
|
||||
$sourceMap['version'] = self::VERSION;
|
||||
// An optional name of the generated code that this source map is associated with.
|
||||
$file = $this->options['sourceMapFilename'];
|
||||
if ($file) {
|
||||
$sourceMap['file'] = $file;
|
||||
}
|
||||
// An optional source root, useful for relocating source files on a server or removing repeated values in the
|
||||
// 'sources' entry. This value is prepended to the individual entries in the 'source' field.
|
||||
$root = $this->options['sourceRoot'];
|
||||
if ($root) {
|
||||
$sourceMap['sourceRoot'] = $root;
|
||||
}
|
||||
// A list of original sources used by the 'mappings' entry.
|
||||
$sourceMap['sources'] = [];
|
||||
foreach ($this->sources as $sourceFilename) {
|
||||
$sourceMap['sources'][] = $this->normalizeFilename($sourceFilename);
|
||||
}
|
||||
// A list of symbol names used by the 'mappings' entry.
|
||||
$sourceMap['names'] = [];
|
||||
// A string with the encoded mapping data.
|
||||
$sourceMap['mappings'] = $mappings;
|
||||
if ($this->options['outputSourceFiles']) {
|
||||
// An optional list of source content, useful when the 'source' can't be hosted.
|
||||
// The contents are listed in the same order as the sources above.
|
||||
// 'null' may be used if some original sources should be retrieved by name.
|
||||
$sourceMap['sourcesContent'] = $this->getSourcesContent();
|
||||
}
|
||||
// less.js compat fixes
|
||||
if (\count($sourceMap['sources']) && empty($sourceMap['sourceRoot'])) {
|
||||
unset($sourceMap['sourceRoot']);
|
||||
}
|
||||
$jsonSourceMap = \json_encode($sourceMap, \JSON_UNESCAPED_SLASHES);
|
||||
if (\json_last_error() !== \JSON_ERROR_NONE) {
|
||||
throw new \RuntimeException(\json_last_error_msg());
|
||||
}
|
||||
\assert($jsonSourceMap !== \false);
|
||||
return $jsonSourceMap;
|
||||
}
|
||||
/**
|
||||
* Returns the sources contents
|
||||
*
|
||||
* @return string[]|null
|
||||
*/
|
||||
protected function getSourcesContent()
|
||||
{
|
||||
if (empty($this->sources)) {
|
||||
return null;
|
||||
}
|
||||
$content = [];
|
||||
foreach ($this->sources as $sourceFile) {
|
||||
$content[] = \file_get_contents($sourceFile);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
/**
|
||||
* Generates the mappings string
|
||||
*
|
||||
* @param string $prefix A prefix added in the output file, which needs to shift mappings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateMappings($prefix = '')
|
||||
{
|
||||
if (!\count($this->mappings)) {
|
||||
return '';
|
||||
}
|
||||
$prefixLines = \substr_count($prefix, "\n");
|
||||
$lastPrefixNewLine = \strrpos($prefix, "\n");
|
||||
$lastPrefixLineStart = \false === $lastPrefixNewLine ? 0 : $lastPrefixNewLine + 1;
|
||||
$prefixColumn = \strlen($prefix) - $lastPrefixLineStart;
|
||||
$this->sourceKeys = \array_flip(\array_keys($this->sources));
|
||||
// group mappings by generated line number.
|
||||
$groupedMap = $groupedMapEncoded = [];
|
||||
foreach ($this->mappings as $m) {
|
||||
$groupedMap[$m['generated_line']][] = $m;
|
||||
}
|
||||
\ksort($groupedMap);
|
||||
$lastGeneratedLine = $lastOriginalIndex = $lastOriginalLine = $lastOriginalColumn = 0;
|
||||
foreach ($groupedMap as $lineNumber => $lineMap) {
|
||||
if ($lineNumber > 1) {
|
||||
// The prefix only impacts the column for the first line of the original output
|
||||
$prefixColumn = 0;
|
||||
}
|
||||
$lineNumber += $prefixLines;
|
||||
while (++$lastGeneratedLine < $lineNumber) {
|
||||
$groupedMapEncoded[] = ';';
|
||||
}
|
||||
$lineMapEncoded = [];
|
||||
$lastGeneratedColumn = 0;
|
||||
foreach ($lineMap as $m) {
|
||||
$generatedColumn = $m['generated_column'] + $prefixColumn;
|
||||
$mapEncoded = $this->encoder->encode($generatedColumn - $lastGeneratedColumn);
|
||||
$lastGeneratedColumn = $generatedColumn;
|
||||
// find the index
|
||||
if ($m['source_file']) {
|
||||
$index = $this->findFileIndex($m['source_file']);
|
||||
if ($index !== \false) {
|
||||
$mapEncoded .= $this->encoder->encode($index - $lastOriginalIndex);
|
||||
$lastOriginalIndex = $index;
|
||||
// lines are stored 0-based in SourceMap spec version 3
|
||||
$mapEncoded .= $this->encoder->encode($m['original_line'] - 1 - $lastOriginalLine);
|
||||
$lastOriginalLine = $m['original_line'] - 1;
|
||||
$mapEncoded .= $this->encoder->encode($m['original_column'] - $lastOriginalColumn);
|
||||
$lastOriginalColumn = $m['original_column'];
|
||||
}
|
||||
}
|
||||
$lineMapEncoded[] = $mapEncoded;
|
||||
}
|
||||
$groupedMapEncoded[] = \implode(',', $lineMapEncoded) . ';';
|
||||
}
|
||||
return \rtrim(\implode($groupedMapEncoded), ';');
|
||||
}
|
||||
/**
|
||||
* Finds the index for the filename
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return int|false
|
||||
*/
|
||||
protected function findFileIndex($filename)
|
||||
{
|
||||
return $this->sourceKeys[$filename];
|
||||
}
|
||||
/**
|
||||
* Normalize filename
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function normalizeFilename($filename)
|
||||
{
|
||||
$filename = $this->fixWindowsPath($filename);
|
||||
$rootpath = $this->options['sourceMapRootpath'];
|
||||
$basePath = $this->options['sourceMapBasepath'];
|
||||
// "Trim" the 'sourceMapBasepath' from the output filename.
|
||||
if (\strlen($basePath) && \strpos($filename, $basePath) === 0) {
|
||||
$filename = \substr($filename, \strlen($basePath));
|
||||
}
|
||||
// Remove extra leading path separators.
|
||||
if (\strpos($filename, '\\') === 0 || \strpos($filename, '/') === 0) {
|
||||
$filename = \substr($filename, 1);
|
||||
}
|
||||
return $rootpath . $filename;
|
||||
}
|
||||
/**
|
||||
* Fix windows paths
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $addEndSlash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fixWindowsPath($path, $addEndSlash = \false)
|
||||
{
|
||||
$slash = $addEndSlash ? '/' : '';
|
||||
if (!empty($path)) {
|
||||
$path = \str_replace('\\', '/', $path);
|
||||
$path = \rtrim($path, '/') . $slash;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
}
|
207
dependencies/scssphp/scssphp/src/Type.php
vendored
Normal file
207
dependencies/scssphp/scssphp/src/Type.php
vendored
Normal file
@ -0,0 +1,207 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp;
|
||||
|
||||
/**
|
||||
* Block/node types
|
||||
*
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*/
|
||||
class Type
|
||||
{
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_ASSIGN = 'assign';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_AT_ROOT = 'at-root';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_BLOCK = 'block';
|
||||
/**
|
||||
* @deprecated
|
||||
* @internal
|
||||
*/
|
||||
const T_BREAK = 'break';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_CHARSET = 'charset';
|
||||
const T_COLOR = 'color';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_COMMENT = 'comment';
|
||||
/**
|
||||
* @deprecated
|
||||
* @internal
|
||||
*/
|
||||
const T_CONTINUE = 'continue';
|
||||
/**
|
||||
* @deprecated
|
||||
* @internal
|
||||
*/
|
||||
const T_CONTROL = 'control';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_CUSTOM_PROPERTY = 'custom';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_DEBUG = 'debug';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_DIRECTIVE = 'directive';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_EACH = 'each';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_ELSE = 'else';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_ELSEIF = 'elseif';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_ERROR = 'error';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_EXPRESSION = 'exp';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_EXTEND = 'extend';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_FOR = 'for';
|
||||
const T_FUNCTION = 'function';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_FUNCTION_REFERENCE = 'function-reference';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_FUNCTION_CALL = 'fncall';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_HSL = 'hsl';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_HWB = 'hwb';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_IF = 'if';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_IMPORT = 'import';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_INCLUDE = 'include';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_INTERPOLATE = 'interpolate';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_INTERPOLATED = 'interpolated';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_KEYWORD = 'keyword';
|
||||
const T_LIST = 'list';
|
||||
const T_MAP = 'map';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_MEDIA = 'media';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_MEDIA_EXPRESSION = 'mediaExp';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_MEDIA_TYPE = 'mediaType';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_MEDIA_VALUE = 'mediaValue';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_MIXIN = 'mixin';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_MIXIN_CONTENT = 'mixin_content';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_NESTED_PROPERTY = 'nestedprop';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_NOT = 'not';
|
||||
const T_NULL = 'null';
|
||||
const T_NUMBER = 'number';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_RETURN = 'return';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_ROOT = 'root';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_SCSSPHP_IMPORT_ONCE = 'scssphp-import-once';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_SELF = 'self';
|
||||
const T_STRING = 'string';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_UNARY = 'unary';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_VARIABLE = 'var';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_WARN = 'warn';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const T_WHILE = 'while';
|
||||
}
|
160
dependencies/scssphp/scssphp/src/Util.php
vendored
Normal file
160
dependencies/scssphp/scssphp/src/Util.php
vendored
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Base\Range;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Exception\RangeException;
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Node\Number;
|
||||
/**
|
||||
* Utility functions
|
||||
*
|
||||
* @author Anthon Pang <anthon.pang@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Util
|
||||
{
|
||||
/**
|
||||
* Asserts that `value` falls within `range` (inclusive), leaving
|
||||
* room for slight floating-point errors.
|
||||
*
|
||||
* @param string $name The name of the value. Used in the error message.
|
||||
* @param Range $range Range of values.
|
||||
* @param array|Number $value The value to check.
|
||||
* @param string $unit The unit of the value. Used in error reporting.
|
||||
*
|
||||
* @return mixed `value` adjusted to fall within range, if it was outside by a floating-point margin.
|
||||
*
|
||||
* @throws \ScssPhp\ScssPhp\Exception\RangeException
|
||||
*/
|
||||
public static function checkRange($name, Range $range, $value, $unit = '')
|
||||
{
|
||||
$val = $value[1];
|
||||
$grace = new Range(-1.0E-5, 1.0E-5);
|
||||
if (!\is_numeric($val)) {
|
||||
throw new RangeException("{$name} {$val} is not a number.");
|
||||
}
|
||||
if ($range->includes($val)) {
|
||||
return $val;
|
||||
}
|
||||
if ($grace->includes($val - $range->first)) {
|
||||
return $range->first;
|
||||
}
|
||||
if ($grace->includes($val - $range->last)) {
|
||||
return $range->last;
|
||||
}
|
||||
throw new RangeException("{$name} {$val} must be between {$range->first} and {$range->last}{$unit}");
|
||||
}
|
||||
/**
|
||||
* Encode URI component
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function encodeURIComponent($string)
|
||||
{
|
||||
$revert = ['%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')'];
|
||||
return \strtr(\rawurlencode($string), $revert);
|
||||
}
|
||||
/**
|
||||
* mb_chr() wrapper
|
||||
*
|
||||
* @param int $code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function mbChr($code)
|
||||
{
|
||||
// Use the native implementation if available, but not on PHP 7.2 as mb_chr(0) is buggy there
|
||||
if (\PHP_VERSION_ID > 70300 && \function_exists('mb_chr')) {
|
||||
return \mb_chr($code, 'UTF-8');
|
||||
}
|
||||
if (0x80 > ($code %= 0x200000)) {
|
||||
$s = \chr($code);
|
||||
} elseif (0x800 > $code) {
|
||||
$s = \chr(0xc0 | $code >> 6) . \chr(0x80 | $code & 0x3f);
|
||||
} elseif (0x10000 > $code) {
|
||||
$s = \chr(0xe0 | $code >> 12) . \chr(0x80 | $code >> 6 & 0x3f) . \chr(0x80 | $code & 0x3f);
|
||||
} else {
|
||||
$s = \chr(0xf0 | $code >> 18) . \chr(0x80 | $code >> 12 & 0x3f) . \chr(0x80 | $code >> 6 & 0x3f) . \chr(0x80 | $code & 0x3f);
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
/**
|
||||
* mb_strlen() wrapper
|
||||
*
|
||||
* @param string $string
|
||||
* @return int
|
||||
*/
|
||||
public static function mbStrlen($string)
|
||||
{
|
||||
// Use the native implementation if available.
|
||||
if (\function_exists('mb_strlen')) {
|
||||
return \mb_strlen($string, 'UTF-8');
|
||||
}
|
||||
if (\function_exists('iconv_strlen')) {
|
||||
return (int) @\iconv_strlen($string, 'UTF-8');
|
||||
}
|
||||
throw new \LogicException('Either mbstring (recommended) or iconv is necessary to use Scssphp.');
|
||||
}
|
||||
/**
|
||||
* mb_substr() wrapper
|
||||
* @param string $string
|
||||
* @param int $start
|
||||
* @param null|int $length
|
||||
* @return string
|
||||
*/
|
||||
public static function mbSubstr($string, $start, $length = null)
|
||||
{
|
||||
// Use the native implementation if available.
|
||||
if (\function_exists('mb_substr')) {
|
||||
return \mb_substr($string, $start, $length, 'UTF-8');
|
||||
}
|
||||
if (\function_exists('iconv_substr')) {
|
||||
if ($start < 0) {
|
||||
$start = static::mbStrlen($string) + $start;
|
||||
if ($start < 0) {
|
||||
$start = 0;
|
||||
}
|
||||
}
|
||||
if (null === $length) {
|
||||
$length = 2147483647;
|
||||
} elseif ($length < 0) {
|
||||
$length = static::mbStrlen($string) + $length - $start;
|
||||
if ($length < 0) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
return (string) \iconv_substr($string, $start, $length, 'UTF-8');
|
||||
}
|
||||
throw new \LogicException('Either mbstring (recommended) or iconv is necessary to use Scssphp.');
|
||||
}
|
||||
/**
|
||||
* mb_strpos wrapper
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
* @param int $offset
|
||||
*
|
||||
* @return int|false
|
||||
*/
|
||||
public static function mbStrpos($haystack, $needle, $offset = 0)
|
||||
{
|
||||
if (\function_exists('mb_strpos')) {
|
||||
return \mb_strpos($haystack, $needle, $offset, 'UTF-8');
|
||||
}
|
||||
if (\function_exists('iconv_strpos')) {
|
||||
return \iconv_strpos($haystack, $needle, $offset, 'UTF-8');
|
||||
}
|
||||
throw new \LogicException('Either mbstring (recommended) or iconv is necessary to use Scssphp.');
|
||||
}
|
||||
}
|
64
dependencies/scssphp/scssphp/src/Util/Path.php
vendored
Normal file
64
dependencies/scssphp/scssphp/src/Util/Path.php
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Util;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class Path
|
||||
{
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isAbsolute($path)
|
||||
{
|
||||
if ($path === '') {
|
||||
return \false;
|
||||
}
|
||||
if ($path[0] === '/') {
|
||||
return \true;
|
||||
}
|
||||
if (\DIRECTORY_SEPARATOR !== '\\') {
|
||||
return \false;
|
||||
}
|
||||
if ($path[0] === '\\') {
|
||||
return \true;
|
||||
}
|
||||
if (\strlen($path) < 3) {
|
||||
return \false;
|
||||
}
|
||||
if ($path[1] !== ':') {
|
||||
return \false;
|
||||
}
|
||||
if ($path[2] !== '/' && $path[2] !== '\\') {
|
||||
return \false;
|
||||
}
|
||||
if (!\preg_match('/^[A-Za-z]$/', $path[0])) {
|
||||
return \false;
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
/**
|
||||
* @param string $part1
|
||||
* @param string $part2
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function join($part1, $part2)
|
||||
{
|
||||
if ($part1 === '' || self::isAbsolute($part2)) {
|
||||
return $part2;
|
||||
}
|
||||
if ($part2 === '') {
|
||||
return $part1;
|
||||
}
|
||||
$last = $part1[\strlen($part1) - 1];
|
||||
$separator = \DIRECTORY_SEPARATOR;
|
||||
if ($last === '/' || $last === \DIRECTORY_SEPARATOR) {
|
||||
$separator = '';
|
||||
}
|
||||
return $part1 . $separator . $part2;
|
||||
}
|
||||
}
|
81
dependencies/scssphp/scssphp/src/ValueConverter.php
vendored
Normal file
81
dependencies/scssphp/scssphp/src/ValueConverter.php
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp;
|
||||
|
||||
use WP_Ultimo\Dependencies\ScssPhp\ScssPhp\Node\Number;
|
||||
final class ValueConverter
|
||||
{
|
||||
// Prevent instantiating it
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Parses a value from a Scss source string.
|
||||
*
|
||||
* The returned value is guaranteed to be supported by the
|
||||
* Compiler methods for registering custom variables. No other
|
||||
* guarantee about it is provided. It should be considered
|
||||
* opaque values by the caller.
|
||||
*
|
||||
* @param string $source
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function parseValue($source)
|
||||
{
|
||||
$parser = new Parser(__CLASS__);
|
||||
if (!$parser->parseValue($source, $value)) {
|
||||
throw new \InvalidArgumentException(\sprintf('Invalid value source "%s".', $source));
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
/**
|
||||
* Converts a PHP value to a Sass value
|
||||
*
|
||||
* The returned value is guaranteed to be supported by the
|
||||
* Compiler methods for registering custom variables. No other
|
||||
* guarantee about it is provided. It should be considered
|
||||
* opaque values by the caller.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function fromPhp($value)
|
||||
{
|
||||
if ($value instanceof Number) {
|
||||
return $value;
|
||||
}
|
||||
if (\is_array($value) && isset($value[0]) && \in_array($value[0], [Type::T_NULL, Type::T_COLOR, Type::T_KEYWORD, Type::T_LIST, Type::T_MAP, Type::T_STRING])) {
|
||||
return $value;
|
||||
}
|
||||
if ($value === null) {
|
||||
return Compiler::$null;
|
||||
}
|
||||
if ($value === \true) {
|
||||
return Compiler::$true;
|
||||
}
|
||||
if ($value === \false) {
|
||||
return Compiler::$false;
|
||||
}
|
||||
if ($value === '') {
|
||||
return Compiler::$emptyString;
|
||||
}
|
||||
if (\is_int($value) || \is_float($value)) {
|
||||
return new Number($value, '');
|
||||
}
|
||||
if (\is_string($value)) {
|
||||
return [Type::T_STRING, '"', [$value]];
|
||||
}
|
||||
throw new \InvalidArgumentException(\sprintf('Cannot convert the value of type "%s" to a Sass value.', \gettype($value)));
|
||||
}
|
||||
}
|
22
dependencies/scssphp/scssphp/src/Version.php
vendored
Normal file
22
dependencies/scssphp/scssphp/src/Version.php
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp;
|
||||
|
||||
/**
|
||||
* SCSSPHP version
|
||||
*
|
||||
* @author Leaf Corcoran <leafot@gmail.com>
|
||||
*/
|
||||
class Version
|
||||
{
|
||||
const VERSION = '1.11.1';
|
||||
}
|
77
dependencies/scssphp/scssphp/src/Warn.php
vendored
Normal file
77
dependencies/scssphp/scssphp/src/Warn.php
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
namespace WP_Ultimo\Dependencies\ScssPhp\ScssPhp;
|
||||
|
||||
final class Warn
|
||||
{
|
||||
/**
|
||||
* @var callable|null
|
||||
* @phpstan-var (callable(string, bool): void)|null
|
||||
*/
|
||||
private static $callback;
|
||||
/**
|
||||
* Prints a warning message associated with the current `@import` or function call.
|
||||
*
|
||||
* This may only be called within a custom function or importer callback.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function warning($message)
|
||||
{
|
||||
self::reportWarning($message, \false);
|
||||
}
|
||||
/**
|
||||
* Prints a deprecation warning message associated with the current `@import` or function call.
|
||||
*
|
||||
* This may only be called within a custom function or importer callback.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function deprecation($message)
|
||||
{
|
||||
self::reportWarning($message, \true);
|
||||
}
|
||||
/**
|
||||
* @param callable|null $callback
|
||||
*
|
||||
* @return callable|null The previous warn callback
|
||||
*
|
||||
* @phpstan-param (callable(string, bool): void)|null $callback
|
||||
*
|
||||
* @phpstan-return (callable(string, bool): void)|null
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function setCallback(callable $callback = null)
|
||||
{
|
||||
$previousCallback = self::$callback;
|
||||
self::$callback = $callback;
|
||||
return $previousCallback;
|
||||
}
|
||||
/**
|
||||
* @param string $message
|
||||
* @param bool $deprecation
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function reportWarning($message, $deprecation)
|
||||
{
|
||||
if (self::$callback === null) {
|
||||
throw new \BadMethodCallException('The warning Reporter may only be called within a custom function or importer callback.');
|
||||
}
|
||||
\call_user_func(self::$callback, $message, $deprecation);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user