Version Description
- Updated scssphp to version 0.7.2 @hellerbenjamin
- Removed depricated screen_icon()
Download this release
Release Info
Developer | connectthink |
Plugin | WP-SCSS |
Version | 1.2.3 |
Comparing to | |
See all releases |
Code changes from version 1.2.2 to 1.2.3
- options.php +0 -1
- readme.txt +6 -2
- scssphp/bin/pscss +3 -3
- scssphp/scss.inc.php +5 -2
- scssphp/src/Base/Range.php +1 -1
- scssphp/src/Block.php +6 -1
- scssphp/src/Colors.php +1 -1
- scssphp/src/Compiler.php +70 -20
- scssphp/src/Compiler/Environment.php +1 -1
- scssphp/src/Exception/CompilerException.php +1 -1
- scssphp/src/Exception/ParserException.php +1 -1
- scssphp/src/Exception/RangeException.php +21 -0
- scssphp/src/Exception/ServerException.php +1 -1
- scssphp/src/Formatter.php +70 -9
- scssphp/src/Formatter/Compact.php +1 -1
- scssphp/src/Formatter/Compressed.php +3 -3
- scssphp/src/Formatter/Crunched.php +3 -3
- scssphp/src/Formatter/Debug.php +10 -8
- scssphp/src/Formatter/Expanded.php +3 -3
- scssphp/src/Formatter/Nested.php +12 -10
- scssphp/src/Formatter/OutputBlock.php +16 -1
- scssphp/src/Node.php +1 -1
- scssphp/src/Node/Number.php +5 -4
- scssphp/src/Parser.php +9 -2
- scssphp/src/SourceMap/Base64VLQEncoder.php +174 -0
- scssphp/src/SourceMap/SourceMapGenerator.php +265 -0
- scssphp/src/Type.php +1 -1
- scssphp/src/Util.php +4 -3
- scssphp/src/Version.php +2 -2
- wp-scss.php +2 -2
options.php
CHANGED
@@ -39,7 +39,6 @@ class Wp_Scss_Settings
|
|
39 |
$this->options = get_option( 'wpscss_options' );
|
40 |
?>
|
41 |
<div class="wrap">
|
42 |
-
<?php screen_icon(); ?>
|
43 |
<h2>WP-SCSS Settings</h2>
|
44 |
<p>
|
45 |
<span class="version">Version <em><?php echo get_option('wpscss_version'); ?></em>
|
39 |
$this->options = get_option( 'wpscss_options' );
|
40 |
?>
|
41 |
<div class="wrap">
|
|
|
42 |
<h2>WP-SCSS Settings</h2>
|
43 |
<p>
|
44 |
<span class="version">Version <em><?php echo get_option('wpscss_version'); ?></em>
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: connectthink
|
|
3 |
Tags: sass, scss, css
|
4 |
Plugin URI: https://github.com/ConnectThink/WP-SCSS
|
5 |
Requires at least: 3.0.1
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.2.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/copyleft/gpl.html
|
10 |
|
@@ -62,6 +62,10 @@ Make sure your directories are properly defined in the settings. Paths are defin
|
|
62 |
If you are having issues with the plugin, create an issue on [github](https://github.com/ConnectThink/WP-SCSS), and we'll do our best to help.
|
63 |
|
64 |
== Changelog ==
|
|
|
|
|
|
|
|
|
65 |
= 1.2.2 =
|
66 |
* Updated scssphp to version 0.6.6
|
67 |
|
3 |
Tags: sass, scss, css
|
4 |
Plugin URI: https://github.com/ConnectThink/WP-SCSS
|
5 |
Requires at least: 3.0.1
|
6 |
+
Tested up to: 4.9.2
|
7 |
+
Stable tag: 1.2.3
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/copyleft/gpl.html
|
10 |
|
62 |
If you are having issues with the plugin, create an issue on [github](https://github.com/ConnectThink/WP-SCSS), and we'll do our best to help.
|
63 |
|
64 |
== Changelog ==
|
65 |
+
= 1.2.3 =
|
66 |
+
* Updated scssphp to version 0.7.2 [@hellerbenjamin](https://github.com/ConnectThink/WP-SCSS/pull/86)
|
67 |
+
* Removed depricated screen_icon()
|
68 |
+
|
69 |
= 1.2.2 =
|
70 |
* Updated scssphp to version 0.6.6
|
71 |
|
scssphp/bin/pscss
CHANGED
@@ -76,7 +76,7 @@ Options include:
|
|
76 |
-i=path Set import path
|
77 |
--iso8859-1 Use iso8859-1 encoding instead of utf-8 (default utf-8)
|
78 |
--line-numbers Annotate selectors with comments referring to the source file and line number
|
79 |
-
-p=precision Set decimal number precision (default
|
80 |
-T Dump formatted parse tree
|
81 |
-v, --version Print the version
|
82 |
|
@@ -169,11 +169,11 @@ if ($dumpTree) {
|
|
169 |
|
170 |
$scss = new Compiler();
|
171 |
|
172 |
-
if ($debugInfo
|
173 |
$scss->setLineNumberStyle(Compiler::DEBUG_INFO);
|
174 |
}
|
175 |
|
176 |
-
if ($lineNumbers
|
177 |
$scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
|
178 |
}
|
179 |
|
76 |
-i=path Set import path
|
77 |
--iso8859-1 Use iso8859-1 encoding instead of utf-8 (default utf-8)
|
78 |
--line-numbers Annotate selectors with comments referring to the source file and line number
|
79 |
+
-p=precision Set decimal number precision (default 10)
|
80 |
-T Dump formatted parse tree
|
81 |
-v, --version Print the version
|
82 |
|
169 |
|
170 |
$scss = new Compiler();
|
171 |
|
172 |
+
if ($debugInfo) {
|
173 |
$scss->setLineNumberStyle(Compiler::DEBUG_INFO);
|
174 |
}
|
175 |
|
176 |
+
if ($lineNumbers) {
|
177 |
$scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
|
178 |
}
|
179 |
|
scssphp/scss.inc.php
CHANGED
@@ -3,7 +3,7 @@ if (version_compare(PHP_VERSION, '5.4') < 0) {
|
|
3 |
throw new \Exception('scssphp requires PHP 5.4 or above');
|
4 |
}
|
5 |
|
6 |
-
if (! class_exists('
|
7 |
include_once __DIR__ . '/src/Base/Range.php';
|
8 |
include_once __DIR__ . '/src/Block.php';
|
9 |
include_once __DIR__ . '/src/Colors.php';
|
@@ -11,6 +11,7 @@ if (! class_exists('scssc', false)) {
|
|
11 |
include_once __DIR__ . '/src/Compiler/Environment.php';
|
12 |
include_once __DIR__ . '/src/Exception/CompilerException.php';
|
13 |
include_once __DIR__ . '/src/Exception/ParserException.php';
|
|
|
14 |
include_once __DIR__ . '/src/Exception/ServerException.php';
|
15 |
include_once __DIR__ . '/src/Formatter.php';
|
16 |
include_once __DIR__ . '/src/Formatter/Compact.php';
|
@@ -23,8 +24,10 @@ if (! class_exists('scssc', false)) {
|
|
23 |
include_once __DIR__ . '/src/Node.php';
|
24 |
include_once __DIR__ . '/src/Node/Number.php';
|
25 |
include_once __DIR__ . '/src/Parser.php';
|
|
|
|
|
|
|
26 |
include_once __DIR__ . '/src/Type.php';
|
27 |
include_once __DIR__ . '/src/Util.php';
|
28 |
include_once __DIR__ . '/src/Version.php';
|
29 |
-
include_once __DIR__ . '/src/Server.php';
|
30 |
}
|
3 |
throw new \Exception('scssphp requires PHP 5.4 or above');
|
4 |
}
|
5 |
|
6 |
+
if (! class_exists('Leafo\ScssPhp\Version', false)) {
|
7 |
include_once __DIR__ . '/src/Base/Range.php';
|
8 |
include_once __DIR__ . '/src/Block.php';
|
9 |
include_once __DIR__ . '/src/Colors.php';
|
11 |
include_once __DIR__ . '/src/Compiler/Environment.php';
|
12 |
include_once __DIR__ . '/src/Exception/CompilerException.php';
|
13 |
include_once __DIR__ . '/src/Exception/ParserException.php';
|
14 |
+
include_once __DIR__ . '/src/Exception/RangeException.php'; //exp
|
15 |
include_once __DIR__ . '/src/Exception/ServerException.php';
|
16 |
include_once __DIR__ . '/src/Formatter.php';
|
17 |
include_once __DIR__ . '/src/Formatter/Compact.php';
|
24 |
include_once __DIR__ . '/src/Node.php';
|
25 |
include_once __DIR__ . '/src/Node/Number.php';
|
26 |
include_once __DIR__ . '/src/Parser.php';
|
27 |
+
// include_once __DIR__ . '/src/example/Server.php';
|
28 |
+
include_once __DIR__ . '/src/SourceMap/Base64VLQEncoder.php';
|
29 |
+
include_once __DIR__ . '/src/SourceMap/SourceMapGenerator.php';
|
30 |
include_once __DIR__ . '/src/Type.php';
|
31 |
include_once __DIR__ . '/src/Util.php';
|
32 |
include_once __DIR__ . '/src/Version.php';
|
|
|
33 |
}
|
scssphp/src/Base/Range.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
scssphp/src/Block.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
@@ -28,6 +28,11 @@ class Block
|
|
28 |
*/
|
29 |
public $parent;
|
30 |
|
|
|
|
|
|
|
|
|
|
|
31 |
/**
|
32 |
* @var integer
|
33 |
*/
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
28 |
*/
|
29 |
public $parent;
|
30 |
|
31 |
+
/**
|
32 |
+
* @var string;
|
33 |
+
*/
|
34 |
+
public $sourceName;
|
35 |
+
|
36 |
/**
|
37 |
* @var integer
|
38 |
*/
|
scssphp/src/Colors.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
scssphp/src/Compiler.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
@@ -18,6 +18,7 @@ use Leafo\ScssPhp\Compiler\Environment;
|
|
18 |
use Leafo\ScssPhp\Exception\CompilerException;
|
19 |
use Leafo\ScssPhp\Formatter\OutputBlock;
|
20 |
use Leafo\ScssPhp\Node;
|
|
|
21 |
use Leafo\ScssPhp\Type;
|
22 |
use Leafo\ScssPhp\Parser;
|
23 |
use Leafo\ScssPhp\Util;
|
@@ -64,6 +65,10 @@ class Compiler
|
|
64 |
const WITH_SUPPORTS = 4;
|
65 |
const WITH_ALL = 7;
|
66 |
|
|
|
|
|
|
|
|
|
67 |
/**
|
68 |
* @var array
|
69 |
*/
|
@@ -120,11 +125,16 @@ class Compiler
|
|
120 |
protected $encoding = null;
|
121 |
protected $lineNumberStyle = null;
|
122 |
|
|
|
|
|
|
|
|
|
123 |
protected $formatter = 'Leafo\ScssPhp\Formatter\Nested';
|
124 |
|
125 |
protected $rootEnv;
|
126 |
protected $rootBlock;
|
127 |
|
|
|
128 |
protected $env;
|
129 |
protected $scope;
|
130 |
protected $storeEnv;
|
@@ -165,9 +175,6 @@ class Compiler
|
|
165 |
*/
|
166 |
public function compile($code, $path = null)
|
167 |
{
|
168 |
-
$locale = setlocale(LC_NUMERIC, 0);
|
169 |
-
setlocale(LC_NUMERIC, 'C');
|
170 |
-
|
171 |
$this->indentLevel = -1;
|
172 |
$this->commentsSeen = [];
|
173 |
$this->extends = [];
|
@@ -194,10 +201,23 @@ class Compiler
|
|
194 |
$this->compileRoot($tree);
|
195 |
$this->popEnv();
|
196 |
|
197 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
200 |
|
|
|
|
|
201 |
return $out;
|
202 |
}
|
203 |
|
@@ -279,6 +299,9 @@ class Compiler
|
|
279 |
$out->parent = $this->scope;
|
280 |
$out->selectors = $selectors;
|
281 |
$out->depth = $this->env->depth;
|
|
|
|
|
|
|
282 |
|
283 |
return $out;
|
284 |
}
|
@@ -661,6 +684,7 @@ class Compiler
|
|
661 |
|
662 |
if ($needsWrap) {
|
663 |
$wrapped = new Block;
|
|
|
664 |
$wrapped->sourceIndex = $media->sourceIndex;
|
665 |
$wrapped->sourceLine = $media->sourceLine;
|
666 |
$wrapped->sourceColumn = $media->sourceColumn;
|
@@ -734,6 +758,7 @@ class Compiler
|
|
734 |
// wrap inline selector
|
735 |
if ($block->selector) {
|
736 |
$wrapped = new Block;
|
|
|
737 |
$wrapped->sourceIndex = $block->sourceIndex;
|
738 |
$wrapped->sourceLine = $block->sourceLine;
|
739 |
$wrapped->sourceColumn = $block->sourceColumn;
|
@@ -790,6 +815,7 @@ class Compiler
|
|
790 |
}
|
791 |
|
792 |
$b = new Block;
|
|
|
793 |
$b->sourceIndex = $e->block->sourceIndex;
|
794 |
$b->sourceLine = $e->block->sourceLine;
|
795 |
$b->sourceColumn = $e->block->sourceColumn;
|
@@ -1081,6 +1107,13 @@ class Compiler
|
|
1081 |
return $selectors;
|
1082 |
}
|
1083 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1084 |
/**
|
1085 |
* Evaluate selector
|
1086 |
*
|
@@ -1181,7 +1214,7 @@ class Compiler
|
|
1181 |
/**
|
1182 |
* Compile selector to string; self(&) should have been replaced by now
|
1183 |
*
|
1184 |
-
* @param array $selector
|
1185 |
*
|
1186 |
* @return string
|
1187 |
*/
|
@@ -1203,7 +1236,7 @@ class Compiler
|
|
1203 |
/**
|
1204 |
* Compile selector part
|
1205 |
*
|
1206 |
-
* @param
|
1207 |
*
|
1208 |
* @return string
|
1209 |
*/
|
@@ -1963,7 +1996,7 @@ class Compiler
|
|
1963 |
* @param array $value
|
1964 |
* @param boolean $inExp
|
1965 |
*
|
1966 |
-
* @return array
|
1967 |
*/
|
1968 |
protected function reduce($value, $inExp = false)
|
1969 |
{
|
@@ -2238,7 +2271,7 @@ class Compiler
|
|
2238 |
* @param array $left
|
2239 |
* @param array $right
|
2240 |
*
|
2241 |
-
* @return
|
2242 |
*/
|
2243 |
protected function opAddNumberNumber($left, $right)
|
2244 |
{
|
@@ -2251,7 +2284,7 @@ class Compiler
|
|
2251 |
* @param array $left
|
2252 |
* @param array $right
|
2253 |
*
|
2254 |
-
* @return
|
2255 |
*/
|
2256 |
protected function opMulNumberNumber($left, $right)
|
2257 |
{
|
@@ -2264,7 +2297,7 @@ class Compiler
|
|
2264 |
* @param array $left
|
2265 |
* @param array $right
|
2266 |
*
|
2267 |
-
* @return
|
2268 |
*/
|
2269 |
protected function opSubNumberNumber($left, $right)
|
2270 |
{
|
@@ -2277,7 +2310,7 @@ class Compiler
|
|
2277 |
* @param array $left
|
2278 |
* @param array $right
|
2279 |
*
|
2280 |
-
* @return array
|
2281 |
*/
|
2282 |
protected function opDivNumberNumber($left, $right)
|
2283 |
{
|
@@ -2294,7 +2327,7 @@ class Compiler
|
|
2294 |
* @param array $left
|
2295 |
* @param array $right
|
2296 |
*
|
2297 |
-
* @return
|
2298 |
*/
|
2299 |
protected function opModNumberNumber($left, $right)
|
2300 |
{
|
@@ -2580,7 +2613,7 @@ class Compiler
|
|
2580 |
* @param array $left
|
2581 |
* @param array $right
|
2582 |
*
|
2583 |
-
* @return
|
2584 |
*/
|
2585 |
protected function opCmpNumberNumber($left, $right)
|
2586 |
{
|
@@ -3304,6 +3337,13 @@ class Compiler
|
|
3304 |
$this->lineNumberStyle = $lineNumberStyle;
|
3305 |
}
|
3306 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3307 |
/**
|
3308 |
* Register function
|
3309 |
*
|
@@ -3390,6 +3430,8 @@ class Compiler
|
|
3390 |
$urls = [$url, preg_replace('/[^\/]+$/', '_\0', $url)];
|
3391 |
}
|
3392 |
|
|
|
|
|
3393 |
foreach ($this->importPaths as $dir) {
|
3394 |
if (is_string($dir)) {
|
3395 |
// check urls for normal import paths
|
@@ -3399,7 +3441,7 @@ class Compiler
|
|
3399 |
. $full;
|
3400 |
|
3401 |
if ($this->fileExists($file = $full . '.scss') ||
|
3402 |
-
$this->fileExists($file = $full)
|
3403 |
) {
|
3404 |
return $file;
|
3405 |
}
|
@@ -3496,14 +3538,14 @@ class Compiler
|
|
3496 |
*/
|
3497 |
protected function fileExists($name)
|
3498 |
{
|
3499 |
-
return is_file($name);
|
3500 |
}
|
3501 |
|
3502 |
/**
|
3503 |
* Call SCSS @function
|
3504 |
*
|
3505 |
* @param string $name
|
3506 |
-
* @param array $
|
3507 |
* @param array $returnValue
|
3508 |
*
|
3509 |
* @return boolean Returns true if returnValue is set; otherwise, false
|
@@ -3775,7 +3817,7 @@ class Compiler
|
|
3775 |
*
|
3776 |
* @param mixed $value
|
3777 |
*
|
3778 |
-
* @return array
|
3779 |
*/
|
3780 |
private function coerceValue($value)
|
3781 |
{
|
@@ -3848,7 +3890,8 @@ class Compiler
|
|
3848 |
/**
|
3849 |
* Coerce something to list
|
3850 |
*
|
3851 |
-
* @param array
|
|
|
3852 |
*
|
3853 |
* @return array
|
3854 |
*/
|
@@ -5208,6 +5251,8 @@ class Compiler
|
|
5208 |
* Workaround IE7's content counter bug.
|
5209 |
*
|
5210 |
* @param array $args
|
|
|
|
|
5211 |
*/
|
5212 |
protected function libCounter($args)
|
5213 |
{
|
@@ -5256,4 +5301,9 @@ class Compiler
|
|
5256 |
|
5257 |
return $args[0];
|
5258 |
}
|
|
|
|
|
|
|
|
|
|
|
5259 |
}
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
18 |
use Leafo\ScssPhp\Exception\CompilerException;
|
19 |
use Leafo\ScssPhp\Formatter\OutputBlock;
|
20 |
use Leafo\ScssPhp\Node;
|
21 |
+
use Leafo\ScssPhp\SourceMap\SourceMapGenerator;
|
22 |
use Leafo\ScssPhp\Type;
|
23 |
use Leafo\ScssPhp\Parser;
|
24 |
use Leafo\ScssPhp\Util;
|
65 |
const WITH_SUPPORTS = 4;
|
66 |
const WITH_ALL = 7;
|
67 |
|
68 |
+
const SOURCE_MAP_NONE = 0;
|
69 |
+
const SOURCE_MAP_INLINE = 1;
|
70 |
+
const SOURCE_MAP_FILE = 2;
|
71 |
+
|
72 |
/**
|
73 |
* @var array
|
74 |
*/
|
125 |
protected $encoding = null;
|
126 |
protected $lineNumberStyle = null;
|
127 |
|
128 |
+
protected $sourceMap = self::SOURCE_MAP_NONE;
|
129 |
+
protected $sourceMapOptions = [];
|
130 |
+
|
131 |
+
/** @var string|Formatter */
|
132 |
protected $formatter = 'Leafo\ScssPhp\Formatter\Nested';
|
133 |
|
134 |
protected $rootEnv;
|
135 |
protected $rootBlock;
|
136 |
|
137 |
+
/** @var Environment */
|
138 |
protected $env;
|
139 |
protected $scope;
|
140 |
protected $storeEnv;
|
175 |
*/
|
176 |
public function compile($code, $path = null)
|
177 |
{
|
|
|
|
|
|
|
178 |
$this->indentLevel = -1;
|
179 |
$this->commentsSeen = [];
|
180 |
$this->extends = [];
|
201 |
$this->compileRoot($tree);
|
202 |
$this->popEnv();
|
203 |
|
204 |
+
$sourceMapGenerator = null;
|
205 |
+
if($this->sourceMap && $this->sourceMap !== self::SOURCE_MAP_NONE) {
|
206 |
+
$sourceMapGenerator = new SourceMapGenerator($this->sourceMapOptions);
|
207 |
+
}
|
208 |
+
$out = $this->formatter->format($this->scope, $sourceMapGenerator);
|
209 |
+
if(!empty($out) && $this->sourceMap && $this->sourceMap !== self::SOURCE_MAP_NONE) {
|
210 |
+
$sourceMap = $sourceMapGenerator->generateJson();
|
211 |
|
212 |
+
$sourceMapUrl = null;
|
213 |
+
if($this->sourceMap == self::SOURCE_MAP_INLINE) {
|
214 |
+
$sourceMapUrl = sprintf('data:application/json,%s', self::encodeURIComponent($sourceMap));
|
215 |
+
} elseif ($this->sourceMap == self::SOURCE_MAP_FILE) {
|
216 |
+
$sourceMapUrl = $sourceMapGenerator->saveMap($sourceMap);
|
217 |
+
}
|
218 |
|
219 |
+
$out .= sprintf('/*# sourceMappingURL=%s */', $sourceMapUrl);
|
220 |
+
}
|
221 |
return $out;
|
222 |
}
|
223 |
|
299 |
$out->parent = $this->scope;
|
300 |
$out->selectors = $selectors;
|
301 |
$out->depth = $this->env->depth;
|
302 |
+
$out->sourceName = $this->env->block->sourceName;
|
303 |
+
$out->sourceLine = $this->env->block->sourceLine;
|
304 |
+
$out->sourceColumn = $this->env->block->sourceColumn;
|
305 |
|
306 |
return $out;
|
307 |
}
|
684 |
|
685 |
if ($needsWrap) {
|
686 |
$wrapped = new Block;
|
687 |
+
$wrapped->sourceName = $media->sourceName;
|
688 |
$wrapped->sourceIndex = $media->sourceIndex;
|
689 |
$wrapped->sourceLine = $media->sourceLine;
|
690 |
$wrapped->sourceColumn = $media->sourceColumn;
|
758 |
// wrap inline selector
|
759 |
if ($block->selector) {
|
760 |
$wrapped = new Block;
|
761 |
+
$wrapped->sourceName = $block->sourceName;
|
762 |
$wrapped->sourceIndex = $block->sourceIndex;
|
763 |
$wrapped->sourceLine = $block->sourceLine;
|
764 |
$wrapped->sourceColumn = $block->sourceColumn;
|
815 |
}
|
816 |
|
817 |
$b = new Block;
|
818 |
+
$b->sourceName = $e->block->sourceName;
|
819 |
$b->sourceIndex = $e->block->sourceIndex;
|
820 |
$b->sourceLine = $e->block->sourceLine;
|
821 |
$b->sourceColumn = $e->block->sourceColumn;
|
1107 |
return $selectors;
|
1108 |
}
|
1109 |
|
1110 |
+
/**
|
1111 |
+
* @param array $sourceMapOptions
|
1112 |
+
*/
|
1113 |
+
public function setSourceMapOptions($sourceMapOptions) {
|
1114 |
+
$this->sourceMapOptions = $sourceMapOptions;
|
1115 |
+
}
|
1116 |
+
|
1117 |
/**
|
1118 |
* Evaluate selector
|
1119 |
*
|
1214 |
/**
|
1215 |
* Compile selector to string; self(&) should have been replaced by now
|
1216 |
*
|
1217 |
+
* @param string|array $selector
|
1218 |
*
|
1219 |
* @return string
|
1220 |
*/
|
1236 |
/**
|
1237 |
* Compile selector part
|
1238 |
*
|
1239 |
+
* @param array $piece
|
1240 |
*
|
1241 |
* @return string
|
1242 |
*/
|
1996 |
* @param array $value
|
1997 |
* @param boolean $inExp
|
1998 |
*
|
1999 |
+
* @return array|\Leafo\ScssPhp\Node\Number
|
2000 |
*/
|
2001 |
protected function reduce($value, $inExp = false)
|
2002 |
{
|
2271 |
* @param array $left
|
2272 |
* @param array $right
|
2273 |
*
|
2274 |
+
* @return \Leafo\ScssPhp\Node\Number
|
2275 |
*/
|
2276 |
protected function opAddNumberNumber($left, $right)
|
2277 |
{
|
2284 |
* @param array $left
|
2285 |
* @param array $right
|
2286 |
*
|
2287 |
+
* @return \Leafo\ScssPhp\Node\Number
|
2288 |
*/
|
2289 |
protected function opMulNumberNumber($left, $right)
|
2290 |
{
|
2297 |
* @param array $left
|
2298 |
* @param array $right
|
2299 |
*
|
2300 |
+
* @return \Leafo\ScssPhp\Node\Number
|
2301 |
*/
|
2302 |
protected function opSubNumberNumber($left, $right)
|
2303 |
{
|
2310 |
* @param array $left
|
2311 |
* @param array $right
|
2312 |
*
|
2313 |
+
* @return array|\Leafo\ScssPhp\Node\Number
|
2314 |
*/
|
2315 |
protected function opDivNumberNumber($left, $right)
|
2316 |
{
|
2327 |
* @param array $left
|
2328 |
* @param array $right
|
2329 |
*
|
2330 |
+
* @return \Leafo\ScssPhp\Node\Number
|
2331 |
*/
|
2332 |
protected function opModNumberNumber($left, $right)
|
2333 |
{
|
2613 |
* @param array $left
|
2614 |
* @param array $right
|
2615 |
*
|
2616 |
+
* @return \Leafo\ScssPhp\Node\Number
|
2617 |
*/
|
2618 |
protected function opCmpNumberNumber($left, $right)
|
2619 |
{
|
3337 |
$this->lineNumberStyle = $lineNumberStyle;
|
3338 |
}
|
3339 |
|
3340 |
+
/**
|
3341 |
+
* @param int $sourceMap
|
3342 |
+
*/
|
3343 |
+
public function setSourceMap($sourceMap) {
|
3344 |
+
$this->sourceMap = $sourceMap;
|
3345 |
+
}
|
3346 |
+
|
3347 |
/**
|
3348 |
* Register function
|
3349 |
*
|
3430 |
$urls = [$url, preg_replace('/[^\/]+$/', '_\0', $url)];
|
3431 |
}
|
3432 |
|
3433 |
+
$hasExtension = preg_match('/[.]s?css$/', $url);
|
3434 |
+
|
3435 |
foreach ($this->importPaths as $dir) {
|
3436 |
if (is_string($dir)) {
|
3437 |
// check urls for normal import paths
|
3441 |
. $full;
|
3442 |
|
3443 |
if ($this->fileExists($file = $full . '.scss') ||
|
3444 |
+
($hasExtension && $this->fileExists($file = $full))
|
3445 |
) {
|
3446 |
return $file;
|
3447 |
}
|
3538 |
*/
|
3539 |
protected function fileExists($name)
|
3540 |
{
|
3541 |
+
return file_exists($name) && is_file($name);
|
3542 |
}
|
3543 |
|
3544 |
/**
|
3545 |
* Call SCSS @function
|
3546 |
*
|
3547 |
* @param string $name
|
3548 |
+
* @param array $argValues
|
3549 |
* @param array $returnValue
|
3550 |
*
|
3551 |
* @return boolean Returns true if returnValue is set; otherwise, false
|
3817 |
*
|
3818 |
* @param mixed $value
|
3819 |
*
|
3820 |
+
* @return array|\Leafo\ScssPhp\Node\Number
|
3821 |
*/
|
3822 |
private function coerceValue($value)
|
3823 |
{
|
3890 |
/**
|
3891 |
* Coerce something to list
|
3892 |
*
|
3893 |
+
* @param array $item
|
3894 |
+
* @param string $delim
|
3895 |
*
|
3896 |
* @return array
|
3897 |
*/
|
5251 |
* Workaround IE7's content counter bug.
|
5252 |
*
|
5253 |
* @param array $args
|
5254 |
+
*
|
5255 |
+
* @return array
|
5256 |
*/
|
5257 |
protected function libCounter($args)
|
5258 |
{
|
5301 |
|
5302 |
return $args[0];
|
5303 |
}
|
5304 |
+
|
5305 |
+
public static function encodeURIComponent($string){
|
5306 |
+
$revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')');
|
5307 |
+
return strtr(rawurlencode($string), $revert);
|
5308 |
+
}
|
5309 |
}
|
scssphp/src/Compiler/Environment.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
scssphp/src/Exception/CompilerException.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
scssphp/src/Exception/ParserException.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
scssphp/src/Exception/RangeException.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SCSSPHP
|
4 |
+
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
+
*
|
7 |
+
* @license http://opensource.org/licenses/MIT MIT
|
8 |
+
*
|
9 |
+
* @link http://leafo.github.io/scssphp
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace Leafo\ScssPhp\Exception;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Range exception
|
16 |
+
*
|
17 |
+
* @author Anthon Pang <anthon.pang@gmail.com>
|
18 |
+
*/
|
19 |
+
class RangeException extends \Exception
|
20 |
+
{
|
21 |
+
}
|
scssphp/src/Exception/ServerException.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
scssphp/src/Formatter.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
@@ -12,6 +12,7 @@
|
|
12 |
namespace Leafo\ScssPhp;
|
13 |
|
14 |
use Leafo\ScssPhp\Formatter\OutputBlock;
|
|
|
15 |
|
16 |
/**
|
17 |
* Base formatter
|
@@ -56,10 +57,31 @@ abstract class Formatter
|
|
56 |
public $assignSeparator;
|
57 |
|
58 |
/**
|
59 |
-
* @var
|
60 |
*/
|
61 |
public $keepSemicolons;
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
/**
|
64 |
* Initialize formatter
|
65 |
*
|
@@ -123,10 +145,10 @@ abstract class Formatter
|
|
123 |
|
124 |
$glue = $this->break . $inner;
|
125 |
|
126 |
-
|
127 |
|
128 |
if (! empty($block->children)) {
|
129 |
-
|
130 |
}
|
131 |
}
|
132 |
|
@@ -139,9 +161,9 @@ abstract class Formatter
|
|
139 |
{
|
140 |
$inner = $this->indentStr();
|
141 |
|
142 |
-
|
143 |
. implode($this->tagSeparator, $block->selectors)
|
144 |
-
. $this->open . $this->break;
|
145 |
}
|
146 |
|
147 |
/**
|
@@ -167,6 +189,8 @@ abstract class Formatter
|
|
167 |
return;
|
168 |
}
|
169 |
|
|
|
|
|
170 |
$pre = $this->indentStr();
|
171 |
|
172 |
if (! empty($block->selectors)) {
|
@@ -187,10 +211,10 @@ abstract class Formatter
|
|
187 |
$this->indentLevel--;
|
188 |
|
189 |
if (empty($block->children)) {
|
190 |
-
|
191 |
}
|
192 |
|
193 |
-
|
194 |
}
|
195 |
}
|
196 |
|
@@ -201,10 +225,19 @@ abstract class Formatter
|
|
201 |
*
|
202 |
* @param \Leafo\ScssPhp\Formatter\OutputBlock $block An abstract syntax tree
|
203 |
*
|
|
|
204 |
* @return string
|
|
|
205 |
*/
|
206 |
-
public function format(OutputBlock $block)
|
207 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
ob_start();
|
209 |
|
210 |
$this->block($block);
|
@@ -213,4 +246,32 @@ abstract class Formatter
|
|
213 |
|
214 |
return $out;
|
215 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
}
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
12 |
namespace Leafo\ScssPhp;
|
13 |
|
14 |
use Leafo\ScssPhp\Formatter\OutputBlock;
|
15 |
+
use Leafo\ScssPhp\SourceMap\SourceMapGenerator;
|
16 |
|
17 |
/**
|
18 |
* Base formatter
|
57 |
public $assignSeparator;
|
58 |
|
59 |
/**
|
60 |
+
* @var boolean
|
61 |
*/
|
62 |
public $keepSemicolons;
|
63 |
|
64 |
+
/**
|
65 |
+
* @var OutputBlock;
|
66 |
+
*/
|
67 |
+
protected $currentBlock;
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* @var int
|
72 |
+
*/
|
73 |
+
protected $currentLine;
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @var int;
|
77 |
+
*/
|
78 |
+
protected $currentColumn;
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @var SourceMapGenerator
|
82 |
+
*/
|
83 |
+
protected $sourceMapGenerator;
|
84 |
+
|
85 |
/**
|
86 |
* Initialize formatter
|
87 |
*
|
145 |
|
146 |
$glue = $this->break . $inner;
|
147 |
|
148 |
+
$this->write($inner . implode($glue, $block->lines));
|
149 |
|
150 |
if (! empty($block->children)) {
|
151 |
+
$this->write($this->break);
|
152 |
}
|
153 |
}
|
154 |
|
161 |
{
|
162 |
$inner = $this->indentStr();
|
163 |
|
164 |
+
$this->write($inner
|
165 |
. implode($this->tagSeparator, $block->selectors)
|
166 |
+
. $this->open . $this->break);
|
167 |
}
|
168 |
|
169 |
/**
|
189 |
return;
|
190 |
}
|
191 |
|
192 |
+
$this->currentBlock = $block;
|
193 |
+
|
194 |
$pre = $this->indentStr();
|
195 |
|
196 |
if (! empty($block->selectors)) {
|
211 |
$this->indentLevel--;
|
212 |
|
213 |
if (empty($block->children)) {
|
214 |
+
$this->write($this->break);
|
215 |
}
|
216 |
|
217 |
+
$this->write($pre . $this->close . $this->break);
|
218 |
}
|
219 |
}
|
220 |
|
225 |
*
|
226 |
* @param \Leafo\ScssPhp\Formatter\OutputBlock $block An abstract syntax tree
|
227 |
*
|
228 |
+
* @param SourceMapGenerator|null $sourceMapGenerator
|
229 |
* @return string
|
230 |
+
* @internal param bool $collectSourceMap
|
231 |
*/
|
232 |
+
public function format(OutputBlock $block, SourceMapGenerator $sourceMapGenerator = null)
|
233 |
{
|
234 |
+
if($sourceMapGenerator) {
|
235 |
+
$this->currentLine = 1;
|
236 |
+
$this->currentColumn = 0;
|
237 |
+
$this->sourceMapGenerator = $sourceMapGenerator;
|
238 |
+
} else {
|
239 |
+
$this->sourceMapGenerator = null;
|
240 |
+
}
|
241 |
ob_start();
|
242 |
|
243 |
$this->block($block);
|
246 |
|
247 |
return $out;
|
248 |
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* @param $str
|
252 |
+
*/
|
253 |
+
protected function write($str) {
|
254 |
+
if($this->sourceMapGenerator) {
|
255 |
+
$this->sourceMapGenerator->addMapping(
|
256 |
+
$this->currentLine,
|
257 |
+
$this->currentColumn,
|
258 |
+
$this->currentBlock->sourceLine,
|
259 |
+
$this->currentBlock->sourceColumn - 1, //columns from parser are off by one
|
260 |
+
$this->currentBlock->sourceName
|
261 |
+
);
|
262 |
+
|
263 |
+
$lines = explode("\n", $str);
|
264 |
+
$lineCount = count($lines);
|
265 |
+
$this->currentLine += $lineCount-1;
|
266 |
+
|
267 |
+
$lastLine = array_pop($lines);
|
268 |
+
if($lineCount == 1) {
|
269 |
+
$this->currentColumn += mb_strlen($lastLine);
|
270 |
+
} else {
|
271 |
+
$this->currentColumn = mb_strlen($lastLine);
|
272 |
+
}
|
273 |
+
}
|
274 |
+
|
275 |
+
echo $str;
|
276 |
+
}
|
277 |
}
|
scssphp/src/Formatter/Compact.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
scssphp/src/Formatter/Compressed.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
@@ -53,10 +53,10 @@ class Compressed extends Formatter
|
|
53 |
}
|
54 |
}
|
55 |
|
56 |
-
|
57 |
|
58 |
if (! empty($block->children)) {
|
59 |
-
|
60 |
}
|
61 |
}
|
62 |
}
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
53 |
}
|
54 |
}
|
55 |
|
56 |
+
$this->write( $inner . implode($glue, $block->lines));
|
57 |
|
58 |
if (! empty($block->children)) {
|
59 |
+
$this->write( $this->break);
|
60 |
}
|
61 |
}
|
62 |
}
|
scssphp/src/Formatter/Crunched.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
@@ -51,10 +51,10 @@ class Crunched extends Formatter
|
|
51 |
}
|
52 |
}
|
53 |
|
54 |
-
|
55 |
|
56 |
if (! empty($block->children)) {
|
57 |
-
|
58 |
}
|
59 |
}
|
60 |
}
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
51 |
}
|
52 |
}
|
53 |
|
54 |
+
$this->write($inner . implode($glue, $block->lines));
|
55 |
|
56 |
if (! empty($block->children)) {
|
57 |
+
$this->write($this->break);
|
58 |
}
|
59 |
}
|
60 |
}
|
scssphp/src/Formatter/Debug.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
@@ -52,13 +52,13 @@ class Debug extends Formatter
|
|
52 |
$indent = $this->indentStr();
|
53 |
|
54 |
if (empty($block->lines)) {
|
55 |
-
|
56 |
|
57 |
return;
|
58 |
}
|
59 |
|
60 |
foreach ($block->lines as $index => $line) {
|
61 |
-
|
62 |
}
|
63 |
}
|
64 |
|
@@ -70,13 +70,13 @@ class Debug extends Formatter
|
|
70 |
$indent = $this->indentStr();
|
71 |
|
72 |
if (empty($block->selectors)) {
|
73 |
-
|
74 |
|
75 |
return;
|
76 |
}
|
77 |
|
78 |
foreach ($block->selectors as $index => $selector) {
|
79 |
-
|
80 |
}
|
81 |
}
|
82 |
|
@@ -88,7 +88,7 @@ class Debug extends Formatter
|
|
88 |
$indent = $this->indentStr();
|
89 |
|
90 |
if (empty($block->children)) {
|
91 |
-
|
92 |
|
93 |
return;
|
94 |
}
|
@@ -109,8 +109,10 @@ class Debug extends Formatter
|
|
109 |
{
|
110 |
$indent = $this->indentStr();
|
111 |
|
112 |
-
|
113 |
-
"{$indent}block->depth: {$block->depth}\n";
|
|
|
|
|
114 |
|
115 |
$this->blockSelectors($block);
|
116 |
$this->blockLines($block);
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
52 |
$indent = $this->indentStr();
|
53 |
|
54 |
if (empty($block->lines)) {
|
55 |
+
$this->write("{$indent}block->lines: []\n");
|
56 |
|
57 |
return;
|
58 |
}
|
59 |
|
60 |
foreach ($block->lines as $index => $line) {
|
61 |
+
$this->write( "{$indent}block->lines[{$index}]: $line\n");
|
62 |
}
|
63 |
}
|
64 |
|
70 |
$indent = $this->indentStr();
|
71 |
|
72 |
if (empty($block->selectors)) {
|
73 |
+
$this->write( "{$indent}block->selectors: []\n");
|
74 |
|
75 |
return;
|
76 |
}
|
77 |
|
78 |
foreach ($block->selectors as $index => $selector) {
|
79 |
+
$this->write( "{$indent}block->selectors[{$index}]: $selector\n");
|
80 |
}
|
81 |
}
|
82 |
|
88 |
$indent = $this->indentStr();
|
89 |
|
90 |
if (empty($block->children)) {
|
91 |
+
$this->write( "{$indent}block->children: []\n");
|
92 |
|
93 |
return;
|
94 |
}
|
109 |
{
|
110 |
$indent = $this->indentStr();
|
111 |
|
112 |
+
$this->write( "{$indent}block->type: {$block->type}\n" .
|
113 |
+
"{$indent}block->depth: {$block->depth}\n");
|
114 |
+
|
115 |
+
$this->currentBlock = $block;
|
116 |
|
117 |
$this->blockSelectors($block);
|
118 |
$this->blockLines($block);
|
scssphp/src/Formatter/Expanded.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
@@ -59,10 +59,10 @@ class Expanded extends Formatter
|
|
59 |
}
|
60 |
}
|
61 |
|
62 |
-
|
63 |
|
64 |
if (empty($block->selectors) || ! empty($block->children)) {
|
65 |
-
|
66 |
}
|
67 |
}
|
68 |
}
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
59 |
}
|
60 |
}
|
61 |
|
62 |
+
$this->write($inner . implode($glue, $block->lines));
|
63 |
|
64 |
if (empty($block->selectors) || ! empty($block->children)) {
|
65 |
+
$this->write($this->break);
|
66 |
}
|
67 |
}
|
68 |
}
|
scssphp/src/Formatter/Nested.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
@@ -12,7 +12,6 @@
|
|
12 |
namespace Leafo\ScssPhp\Formatter;
|
13 |
|
14 |
use Leafo\ScssPhp\Formatter;
|
15 |
-
use Leafo\ScssPhp\Formatter\OutputBlock;
|
16 |
|
17 |
/**
|
18 |
* Nested formatter
|
@@ -66,10 +65,10 @@ class Nested extends Formatter
|
|
66 |
}
|
67 |
}
|
68 |
|
69 |
-
|
70 |
|
71 |
if (! empty($block->children)) {
|
72 |
-
|
73 |
}
|
74 |
}
|
75 |
|
@@ -80,9 +79,9 @@ class Nested extends Formatter
|
|
80 |
{
|
81 |
$inner = $this->indentStr();
|
82 |
|
83 |
-
|
84 |
. implode($this->tagSeparator, $block->selectors)
|
85 |
-
. $this->open . $this->break;
|
86 |
}
|
87 |
|
88 |
/**
|
@@ -94,13 +93,13 @@ class Nested extends Formatter
|
|
94 |
$this->block($child);
|
95 |
|
96 |
if ($i < count($block->children) - 1) {
|
97 |
-
|
98 |
|
99 |
if (isset($block->children[$i + 1])) {
|
100 |
$next = $block->children[$i + 1];
|
101 |
|
102 |
if ($next->depth === max($block->depth, 1) && $child->depth >= $next->depth) {
|
103 |
-
|
104 |
}
|
105 |
}
|
106 |
}
|
@@ -120,6 +119,9 @@ class Nested extends Formatter
|
|
120 |
return;
|
121 |
}
|
122 |
|
|
|
|
|
|
|
123 |
$this->depth = $block->depth;
|
124 |
|
125 |
if (! empty($block->selectors)) {
|
@@ -139,11 +141,11 @@ class Nested extends Formatter
|
|
139 |
if (! empty($block->selectors)) {
|
140 |
$this->indentLevel--;
|
141 |
|
142 |
-
|
143 |
}
|
144 |
|
145 |
if ($block->type === 'root') {
|
146 |
-
|
147 |
}
|
148 |
}
|
149 |
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
12 |
namespace Leafo\ScssPhp\Formatter;
|
13 |
|
14 |
use Leafo\ScssPhp\Formatter;
|
|
|
15 |
|
16 |
/**
|
17 |
* Nested formatter
|
65 |
}
|
66 |
}
|
67 |
|
68 |
+
$this->write( $inner . implode($glue, $block->lines));
|
69 |
|
70 |
if (! empty($block->children)) {
|
71 |
+
$this->write( $this->break);
|
72 |
}
|
73 |
}
|
74 |
|
79 |
{
|
80 |
$inner = $this->indentStr();
|
81 |
|
82 |
+
$this->write( $inner
|
83 |
. implode($this->tagSeparator, $block->selectors)
|
84 |
+
. $this->open . $this->break);
|
85 |
}
|
86 |
|
87 |
/**
|
93 |
$this->block($child);
|
94 |
|
95 |
if ($i < count($block->children) - 1) {
|
96 |
+
$this->write( $this->break);
|
97 |
|
98 |
if (isset($block->children[$i + 1])) {
|
99 |
$next = $block->children[$i + 1];
|
100 |
|
101 |
if ($next->depth === max($block->depth, 1) && $child->depth >= $next->depth) {
|
102 |
+
$this->write( $this->break);
|
103 |
}
|
104 |
}
|
105 |
}
|
119 |
return;
|
120 |
}
|
121 |
|
122 |
+
$this->currentBlock = $block;
|
123 |
+
|
124 |
+
|
125 |
$this->depth = $block->depth;
|
126 |
|
127 |
if (! empty($block->selectors)) {
|
141 |
if (! empty($block->selectors)) {
|
142 |
$this->indentLevel--;
|
143 |
|
144 |
+
$this->write( $this->close);
|
145 |
}
|
146 |
|
147 |
if ($block->type === 'root') {
|
148 |
+
$this->write( $this->break);
|
149 |
}
|
150 |
}
|
151 |
|
scssphp/src/Formatter/OutputBlock.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
@@ -47,4 +47,19 @@ class OutputBlock
|
|
47 |
* @var \Leafo\ScssPhp\Formatter\OutputBlock
|
48 |
*/
|
49 |
public $parent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
}
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
47 |
* @var \Leafo\ScssPhp\Formatter\OutputBlock
|
48 |
*/
|
49 |
public $parent;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @var string
|
53 |
+
*/
|
54 |
+
public $sourceName;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @var int
|
58 |
+
*/
|
59 |
+
public $sourceLine;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @var int
|
63 |
+
*/
|
64 |
+
public $sourceColumn;
|
65 |
}
|
scssphp/src/Node.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
scssphp/src/Node/Number.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
@@ -31,7 +31,7 @@ class Number extends Node implements \ArrayAccess
|
|
31 |
/**
|
32 |
* @var integer
|
33 |
*/
|
34 |
-
static public $precision =
|
35 |
|
36 |
/**
|
37 |
* @see http://www.w3.org/TR/2012/WD-css3-values-20120308/
|
@@ -290,9 +290,10 @@ class Number extends Node implements \ArrayAccess
|
|
290 |
}
|
291 |
|
292 |
reset($units);
|
293 |
-
|
|
|
294 |
|
295 |
-
return (
|
296 |
}
|
297 |
|
298 |
/**
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
31 |
/**
|
32 |
* @var integer
|
33 |
*/
|
34 |
+
static public $precision = 10;
|
35 |
|
36 |
/**
|
37 |
* @see http://www.w3.org/TR/2012/WD-css3-values-20120308/
|
290 |
}
|
291 |
|
292 |
reset($units);
|
293 |
+
$unit = key($units);
|
294 |
+
$dimension = number_format($dimension, static::$precision, '.', '');
|
295 |
|
296 |
+
return (static::$precision ? rtrim(rtrim($dimension, '0'), '.') : $dimension) . $unit;
|
297 |
}
|
298 |
|
299 |
/**
|
scssphp/src/Parser.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
@@ -708,6 +708,7 @@ class Parser
|
|
708 |
list($line, $column) = $this->getSourcePosition($pos);
|
709 |
|
710 |
$b = new Block;
|
|
|
711 |
$b->sourceLine = $line;
|
712 |
$b->sourceColumn = $column;
|
713 |
$b->sourceIndex = $this->sourceIndex;
|
@@ -2468,7 +2469,13 @@ class Parser
|
|
2468 |
*/
|
2469 |
private function saveEncoding()
|
2470 |
{
|
2471 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
2472 |
$this->encoding = mb_internal_encoding();
|
2473 |
|
2474 |
mb_internal_encoding('iso-8859-1');
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
708 |
list($line, $column) = $this->getSourcePosition($pos);
|
709 |
|
710 |
$b = new Block;
|
711 |
+
$b->sourceName = $this->sourceName;
|
712 |
$b->sourceLine = $line;
|
713 |
$b->sourceColumn = $column;
|
714 |
$b->sourceIndex = $this->sourceIndex;
|
2469 |
*/
|
2470 |
private function saveEncoding()
|
2471 |
{
|
2472 |
+
if (version_compare(PHP_VERSION, '7.2.0') >= 0) {
|
2473 |
+
return;
|
2474 |
+
}
|
2475 |
+
|
2476 |
+
$iniDirective = 'mbstring' . '.func_overload'; // deprecated in PHP 7.2
|
2477 |
+
|
2478 |
+
if (ini_get($iniDirective) & 2) {
|
2479 |
$this->encoding = mb_internal_encoding();
|
2480 |
|
2481 |
mb_internal_encoding('iso-8859-1');
|
scssphp/src/SourceMap/Base64VLQEncoder.php
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: nico
|
5 |
+
* Date: 08/11/17
|
6 |
+
* Time: 19:14
|
7 |
+
*/
|
8 |
+
|
9 |
+
namespace Leafo\ScssPhp\SourceMap;
|
10 |
+
|
11 |
+
|
12 |
+
class Base64VLQEncoder {
|
13 |
+
/**
|
14 |
+
* Shift
|
15 |
+
*
|
16 |
+
* @var integer
|
17 |
+
*/
|
18 |
+
private $shift = 5;
|
19 |
+
/**
|
20 |
+
* Mask
|
21 |
+
*
|
22 |
+
* @var integer
|
23 |
+
*/
|
24 |
+
private $mask = 0x1F; // == (1 << shift) == 0b00011111
|
25 |
+
/**
|
26 |
+
* Continuation bit
|
27 |
+
*
|
28 |
+
* @var integer
|
29 |
+
*/
|
30 |
+
private $continuationBit = 0x20; // == (mask - 1 ) == 0b00100000
|
31 |
+
/**
|
32 |
+
* Char to integer map
|
33 |
+
*
|
34 |
+
* @var array
|
35 |
+
*/
|
36 |
+
private $charToIntMap = array(
|
37 |
+
'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6,
|
38 |
+
'H' => 7,'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13,
|
39 |
+
'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19, 'U' => 20,
|
40 |
+
'V' => 21, 'W' => 22, 'X' => 23, 'Y' => 24, 'Z' => 25, 'a' => 26, 'b' => 27,
|
41 |
+
'c' => 28, 'd' => 29, 'e' => 30, 'f' => 31, 'g' => 32, 'h' => 33, 'i' => 34,
|
42 |
+
'j' => 35, 'k' => 36, 'l' => 37, 'm' => 38, 'n' => 39, 'o' => 40, 'p' => 41,
|
43 |
+
'q' => 42, 'r' => 43, 's' => 44, 't' => 45, 'u' => 46, 'v' => 47, 'w' => 48,
|
44 |
+
'x' => 49, 'y' => 50, 'z' => 51, 0 => 52, 1 => 53, 2 => 54, 3 => 55, 4 => 56,
|
45 |
+
5 => 57, 6 => 58, 7 => 59, 8 => 60, 9 => 61, '+' => 62, '/' => 63,
|
46 |
+
);
|
47 |
+
/**
|
48 |
+
* Integer to char map
|
49 |
+
*
|
50 |
+
* @var array
|
51 |
+
*/
|
52 |
+
private $intToCharMap = array(
|
53 |
+
0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D', 4 => 'E', 5 => 'F', 6 => 'G',
|
54 |
+
7 => 'H', 8 => 'I', 9 => 'J', 10 => 'K', 11 => 'L', 12 => 'M', 13 => 'N',
|
55 |
+
14 => 'O', 15 => 'P', 16 => 'Q', 17 => 'R', 18 => 'S', 19 => 'T', 20 => 'U',
|
56 |
+
21 => 'V', 22 => 'W', 23 => 'X', 24 => 'Y', 25 => 'Z', 26 => 'a', 27 => 'b',
|
57 |
+
28 => 'c', 29 => 'd', 30 => 'e', 31 => 'f', 32 => 'g', 33 => 'h', 34 => 'i',
|
58 |
+
35 => 'j', 36 => 'k', 37 => 'l', 38 => 'm', 39 => 'n', 40 => 'o', 41 => 'p',
|
59 |
+
42 => 'q', 43 => 'r', 44 => 's', 45 => 't', 46 => 'u', 47 => 'v', 48 => 'w',
|
60 |
+
49 => 'x', 50 => 'y', 51 => 'z', 52 => '0', 53 => '1', 54 => '2', 55 => '3',
|
61 |
+
56 => '4', 57 => '5', 58 => '6', 59 => '7', 60 => '8', 61 => '9', 62 => '+',
|
62 |
+
63 => '/',
|
63 |
+
);
|
64 |
+
/**
|
65 |
+
* Constructor
|
66 |
+
*/
|
67 |
+
public function __construct(){
|
68 |
+
// I leave it here for future reference
|
69 |
+
// foreach(str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/') as $i => $char)
|
70 |
+
// {
|
71 |
+
// $this->charToIntMap[$char] = $i;
|
72 |
+
// $this->intToCharMap[$i] = $char;
|
73 |
+
// }
|
74 |
+
}
|
75 |
+
/**
|
76 |
+
* Convert from a two-complement value to a value where the sign bit is
|
77 |
+
* is placed in the least significant bit. For example, as decimals:
|
78 |
+
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
|
79 |
+
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
80 |
+
* We generate the value for 32 bit machines, hence -2147483648 becomes 1, not 4294967297,
|
81 |
+
* even on a 64 bit machine.
|
82 |
+
* @param string $aValue
|
83 |
+
*/
|
84 |
+
public function toVLQSigned($aValue){
|
85 |
+
return 0xffffffff & ($aValue < 0 ? ((-$aValue) << 1) + 1 : ($aValue << 1) + 0);
|
86 |
+
}
|
87 |
+
/**
|
88 |
+
* Convert to a two-complement value from a value where the sign bit is
|
89 |
+
* is placed in the least significant bit. For example, as decimals:
|
90 |
+
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
|
91 |
+
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
|
92 |
+
* We assume that the value was generated with a 32 bit machine in mind.
|
93 |
+
* Hence
|
94 |
+
* 1 becomes -2147483648
|
95 |
+
* even on a 64 bit machine.
|
96 |
+
* @param integer $aValue
|
97 |
+
*/
|
98 |
+
public function fromVLQSigned($aValue){
|
99 |
+
return $aValue & 1 ? $this->zeroFill(~$aValue + 2, 1) | (-1 - 0x7fffffff) : $this->zeroFill($aValue, 1);
|
100 |
+
}
|
101 |
+
/**
|
102 |
+
* Return the base 64 VLQ encoded value.
|
103 |
+
*
|
104 |
+
* @param string $aValue The value to encode
|
105 |
+
* @return string The encoded value
|
106 |
+
*/
|
107 |
+
public function encode($aValue){
|
108 |
+
$encoded = '';
|
109 |
+
$vlq = $this->toVLQSigned($aValue);
|
110 |
+
do
|
111 |
+
{
|
112 |
+
$digit = $vlq & $this->mask;
|
113 |
+
$vlq = $this->zeroFill($vlq, $this->shift);
|
114 |
+
if($vlq > 0){
|
115 |
+
$digit |= $this->continuationBit;
|
116 |
+
}
|
117 |
+
$encoded .= $this->base64Encode($digit);
|
118 |
+
} while($vlq > 0);
|
119 |
+
return $encoded;
|
120 |
+
}
|
121 |
+
/**
|
122 |
+
* Return the value decoded from base 64 VLQ.
|
123 |
+
*
|
124 |
+
* @param string $encoded The encoded value to decode
|
125 |
+
* @return integer The decoded value
|
126 |
+
*/
|
127 |
+
public function decode($encoded){
|
128 |
+
$vlq = 0;
|
129 |
+
$i = 0;
|
130 |
+
do
|
131 |
+
{
|
132 |
+
$digit = $this->base64Decode($encoded[$i]);
|
133 |
+
$vlq |= ($digit & $this->mask) << ($i * $this->shift);
|
134 |
+
$i++;
|
135 |
+
} while($digit & $this->continuationBit);
|
136 |
+
return $this->fromVLQSigned($vlq);
|
137 |
+
}
|
138 |
+
/**
|
139 |
+
* Right shift with zero fill.
|
140 |
+
*
|
141 |
+
* @param integer $a number to shift
|
142 |
+
* @param integer $b number of bits to shift
|
143 |
+
* @return integer
|
144 |
+
*/
|
145 |
+
public function zeroFill($a, $b){
|
146 |
+
return ($a >= 0) ? ($a >> $b) : ($a >> $b) & (PHP_INT_MAX >> ($b - 1));
|
147 |
+
}
|
148 |
+
/**
|
149 |
+
* Encode single 6-bit digit as base64.
|
150 |
+
*
|
151 |
+
* @param integer $number
|
152 |
+
* @return string
|
153 |
+
* @throws Exception If the number is invalid
|
154 |
+
*/
|
155 |
+
public function base64Encode($number){
|
156 |
+
if($number < 0 || $number > 63){
|
157 |
+
throw new Exception(sprintf('Invalid number "%s" given. Must be between 0 and 63.', $number));
|
158 |
+
}
|
159 |
+
return $this->intToCharMap[$number];
|
160 |
+
}
|
161 |
+
/**
|
162 |
+
* Decode single 6-bit digit from base64
|
163 |
+
*
|
164 |
+
* @param string $char
|
165 |
+
* @return number
|
166 |
+
* @throws Exception If the number is invalid
|
167 |
+
*/
|
168 |
+
public function base64Decode($char){
|
169 |
+
if(!array_key_exists($char, $this->charToIntMap)){
|
170 |
+
throw new Exception(sprintf('Invalid base 64 digit "%s" given.', $char));
|
171 |
+
}
|
172 |
+
return $this->charToIntMap[$char];
|
173 |
+
}
|
174 |
+
}
|
scssphp/src/SourceMap/SourceMapGenerator.php
ADDED
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: nico
|
5 |
+
* Date: 08/11/17
|
6 |
+
* Time: 19:16
|
7 |
+
*/
|
8 |
+
|
9 |
+
namespace Leafo\ScssPhp\SourceMap;
|
10 |
+
|
11 |
+
use Leafo\ScssPhp\Exception\CompilerException;
|
12 |
+
|
13 |
+
class SourceMapGenerator {
|
14 |
+
/**
|
15 |
+
* What version of source map does the generator generate?
|
16 |
+
*/
|
17 |
+
const VERSION = 3;
|
18 |
+
/**
|
19 |
+
* Array of default options
|
20 |
+
*
|
21 |
+
* @var array
|
22 |
+
*/
|
23 |
+
protected $defaultOptions = array(
|
24 |
+
// an optional source root, useful for relocating source files
|
25 |
+
// on a server or removing repeated values in the 'sources' entry.
|
26 |
+
// This value is prepended to the individual entries in the 'source' field.
|
27 |
+
'sourceRoot' => '',
|
28 |
+
// an optional name of the generated code that this source map is associated with.
|
29 |
+
'sourceMapFilename' => null,
|
30 |
+
// url of the map
|
31 |
+
'sourceMapURL' => null,
|
32 |
+
// absolute path to a file to write the map to
|
33 |
+
'sourceMapWriteTo' => null,
|
34 |
+
// output source contents?
|
35 |
+
'outputSourceFiles' => false,
|
36 |
+
// base path for filename normalization
|
37 |
+
'sourceMapRootpath' => '',
|
38 |
+
// base path for filename normalization
|
39 |
+
'sourceMapBasepath' => ''
|
40 |
+
);
|
41 |
+
|
42 |
+
/**
|
43 |
+
* The base64 VLQ encoder
|
44 |
+
*
|
45 |
+
* @var Base64VLQEncoder
|
46 |
+
*/
|
47 |
+
protected $encoder;
|
48 |
+
/**
|
49 |
+
* Array of mappings
|
50 |
+
*
|
51 |
+
* @var array
|
52 |
+
*/
|
53 |
+
protected $mappings = array();
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Array of contents map
|
57 |
+
*
|
58 |
+
* @var array
|
59 |
+
*/
|
60 |
+
protected $contentsMap = array();
|
61 |
+
/**
|
62 |
+
* File to content map
|
63 |
+
*
|
64 |
+
* @var array
|
65 |
+
*/
|
66 |
+
protected $sources = array();
|
67 |
+
protected $source_keys = array();
|
68 |
+
/**
|
69 |
+
* @var array
|
70 |
+
*/
|
71 |
+
private $options;
|
72 |
+
|
73 |
+
public function __construct(array $options = []) {
|
74 |
+
$this->options = array_merge($this->defaultOptions, $options);
|
75 |
+
$this->encoder = new Base64VLQEncoder();
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Adds a mapping
|
80 |
+
*
|
81 |
+
* @param integer $generatedLine The line number in generated file
|
82 |
+
* @param integer $generatedColumn The column number in generated file
|
83 |
+
* @param integer $originalLine The line number in original file
|
84 |
+
* @param integer $originalColumn The column number in original file
|
85 |
+
* @param string $sourceFile The original source file
|
86 |
+
*/
|
87 |
+
public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $sourceFile) {
|
88 |
+
$this->mappings[] = array(
|
89 |
+
'generated_line' => $generatedLine,
|
90 |
+
'generated_column' => $generatedColumn,
|
91 |
+
'original_line' => $originalLine,
|
92 |
+
'original_column' => $originalColumn,
|
93 |
+
'source_file' => $sourceFile
|
94 |
+
);
|
95 |
+
|
96 |
+
$this->sources[$sourceFile] = $sourceFile;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Saves the source map to a file
|
101 |
+
*
|
102 |
+
* @param string $file The absolute path to a file
|
103 |
+
* @param string $content The content to write
|
104 |
+
* @throws Exception If the file could not be saved
|
105 |
+
*/
|
106 |
+
public function saveMap($content){
|
107 |
+
$file = $this->options['sourceMapWriteTo'];
|
108 |
+
$dir = dirname($file);
|
109 |
+
// directory does not exist
|
110 |
+
if( !is_dir($dir) ){
|
111 |
+
// FIXME: create the dir automatically?
|
112 |
+
throw new CompilerException(sprintf('The directory "%s" does not exist. Cannot save the source map.', $dir));
|
113 |
+
}
|
114 |
+
// FIXME: proper saving, with dir write check!
|
115 |
+
if(file_put_contents($file, $content) === false){
|
116 |
+
throw new CompilerException(sprintf('Cannot save the source map to "%s"', $file));
|
117 |
+
}
|
118 |
+
return $this->options['sourceMapURL'];
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Generates the JSON source map
|
123 |
+
*
|
124 |
+
* @return string
|
125 |
+
* @see https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#
|
126 |
+
*/
|
127 |
+
public function generateJson() {
|
128 |
+
$sourceMap = array();
|
129 |
+
$mappings = $this->generateMappings();
|
130 |
+
// File version (always the first entry in the object) and must be a positive integer.
|
131 |
+
$sourceMap['version'] = self::VERSION;
|
132 |
+
// An optional name of the generated code that this source map is associated with.
|
133 |
+
$file = $this->options['sourceMapFilename'];
|
134 |
+
if($file) {
|
135 |
+
$sourceMap['file'] = $file;
|
136 |
+
}
|
137 |
+
// 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.
|
138 |
+
$root = $this->options['sourceRoot'];
|
139 |
+
if($root) {
|
140 |
+
$sourceMap['sourceRoot'] = $root;
|
141 |
+
}
|
142 |
+
// A list of original sources used by the 'mappings' entry.
|
143 |
+
$sourceMap['sources'] = array();
|
144 |
+
foreach($this->sources as $source_uri => $source_filename) {
|
145 |
+
$sourceMap['sources'][] = $this->normalizeFilename($source_filename);
|
146 |
+
}
|
147 |
+
// A list of symbol names used by the 'mappings' entry.
|
148 |
+
$sourceMap['names'] = array();
|
149 |
+
// A string with the encoded mapping data.
|
150 |
+
$sourceMap['mappings'] = $mappings;
|
151 |
+
if($this->options['outputSourceFiles']) {
|
152 |
+
// An optional list of source content, useful when the 'source' can't be hosted.
|
153 |
+
// The contents are listed in the same order as the sources above.
|
154 |
+
// 'null' may be used if some original sources should be retrieved by name.
|
155 |
+
$sourceMap['sourcesContent'] = $this->getSourcesContent();
|
156 |
+
}
|
157 |
+
// less.js compat fixes
|
158 |
+
if(count($sourceMap['sources']) && empty($sourceMap['sourceRoot'])) {
|
159 |
+
unset($sourceMap['sourceRoot']);
|
160 |
+
}
|
161 |
+
return json_encode($sourceMap);
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Returns the sources contents
|
166 |
+
*
|
167 |
+
* @return array|null
|
168 |
+
*/
|
169 |
+
protected function getSourcesContent() {
|
170 |
+
if(empty($this->sources)) {
|
171 |
+
return null;
|
172 |
+
}
|
173 |
+
$content = array();
|
174 |
+
foreach($this->sources as $sourceFile) {
|
175 |
+
$content[] = file_get_contents($sourceFile);
|
176 |
+
}
|
177 |
+
return $content;
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Generates the mappings string
|
182 |
+
*
|
183 |
+
* @return string
|
184 |
+
*/
|
185 |
+
public function generateMappings() {
|
186 |
+
if(!count($this->mappings)) {
|
187 |
+
return '';
|
188 |
+
}
|
189 |
+
$this->source_keys = array_flip(array_keys($this->sources));
|
190 |
+
// group mappings by generated line number.
|
191 |
+
$groupedMap = $groupedMapEncoded = array();
|
192 |
+
foreach($this->mappings as $m) {
|
193 |
+
$groupedMap[$m['generated_line']][] = $m;
|
194 |
+
}
|
195 |
+
ksort($groupedMap);
|
196 |
+
$lastGeneratedLine = $lastOriginalIndex = $lastOriginalLine = $lastOriginalColumn = 0;
|
197 |
+
foreach($groupedMap as $lineNumber => $line_map) {
|
198 |
+
while(++$lastGeneratedLine < $lineNumber) {
|
199 |
+
$groupedMapEncoded[] = ';';
|
200 |
+
}
|
201 |
+
$lineMapEncoded = array();
|
202 |
+
$lastGeneratedColumn = 0;
|
203 |
+
foreach($line_map as $m) {
|
204 |
+
$mapEncoded = $this->encoder->encode($m['generated_column'] - $lastGeneratedColumn);
|
205 |
+
$lastGeneratedColumn = $m['generated_column'];
|
206 |
+
// find the index
|
207 |
+
if($m['source_file']) {
|
208 |
+
$index = $this->findFileIndex($m['source_file']);
|
209 |
+
if($index !== false) {
|
210 |
+
$mapEncoded .= $this->encoder->encode($index - $lastOriginalIndex);
|
211 |
+
$lastOriginalIndex = $index;
|
212 |
+
// lines are stored 0-based in SourceMap spec version 3
|
213 |
+
$mapEncoded .= $this->encoder->encode($m['original_line'] - 1 - $lastOriginalLine);
|
214 |
+
$lastOriginalLine = $m['original_line'] - 1;
|
215 |
+
$mapEncoded .= $this->encoder->encode($m['original_column'] - $lastOriginalColumn);
|
216 |
+
$lastOriginalColumn = $m['original_column'];
|
217 |
+
}
|
218 |
+
}
|
219 |
+
$lineMapEncoded[] = $mapEncoded;
|
220 |
+
}
|
221 |
+
$groupedMapEncoded[] = implode(',', $lineMapEncoded) . ';';
|
222 |
+
}
|
223 |
+
return rtrim(implode($groupedMapEncoded), ';');
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Finds the index for the filename
|
228 |
+
*
|
229 |
+
* @param string $filename
|
230 |
+
* @return integer|false
|
231 |
+
*/
|
232 |
+
protected function findFileIndex($filename) {
|
233 |
+
return $this->source_keys[$filename];
|
234 |
+
}
|
235 |
+
|
236 |
+
protected function normalizeFilename($filename) {
|
237 |
+
$filename = $this->fixWindowsPath($filename);
|
238 |
+
$rootpath = $this->options['sourceMapRootpath'];
|
239 |
+
$basePath = $this->options['sourceMapBasepath'];
|
240 |
+
// "Trim" the 'sourceMapBasepath' from the output filename.
|
241 |
+
if(strpos($filename, $basePath) === 0) {
|
242 |
+
$filename = substr($filename, strlen($basePath));
|
243 |
+
}
|
244 |
+
// Remove extra leading path separators.
|
245 |
+
if(strpos($filename, '\\') === 0 || strpos($filename, '/') === 0) {
|
246 |
+
$filename = substr($filename, 1);
|
247 |
+
}
|
248 |
+
return $rootpath . $filename;
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* fix windows paths
|
253 |
+
* @param string $path
|
254 |
+
* @param bool $addEndSlash
|
255 |
+
* @return string
|
256 |
+
*/
|
257 |
+
public function fixWindowsPath($path, $addEndSlash = false) {
|
258 |
+
$slash = ($addEndSlash) ? '/' : '';
|
259 |
+
if(!empty($path)) {
|
260 |
+
$path = str_replace('\\', '/', $path);
|
261 |
+
$path = rtrim($path, '/') . $slash;
|
262 |
+
}
|
263 |
+
return $path;
|
264 |
+
}
|
265 |
+
}
|
scssphp/src/Type.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
scssphp/src/Util.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
@@ -12,6 +12,7 @@
|
|
12 |
namespace Leafo\ScssPhp;
|
13 |
|
14 |
use Leafo\ScssPhp\Base\Range;
|
|
|
15 |
|
16 |
/**
|
17 |
* Utilties
|
@@ -31,7 +32,7 @@ class Util
|
|
31 |
*
|
32 |
* @return mixed `value` adjusted to fall within range, if it was outside by a floating-point margin.
|
33 |
*
|
34 |
-
* @throws \Exception
|
35 |
*/
|
36 |
public static function checkRange($name, Range $range, $value, $unit = '')
|
37 |
{
|
@@ -50,6 +51,6 @@ class Util
|
|
50 |
return $range->last;
|
51 |
}
|
52 |
|
53 |
-
throw new
|
54 |
}
|
55 |
}
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
12 |
namespace Leafo\ScssPhp;
|
13 |
|
14 |
use Leafo\ScssPhp\Base\Range;
|
15 |
+
use Leafo\ScssPhp\Exception\RangeException;
|
16 |
|
17 |
/**
|
18 |
* Utilties
|
32 |
*
|
33 |
* @return mixed `value` adjusted to fall within range, if it was outside by a floating-point margin.
|
34 |
*
|
35 |
+
* @throws \Leafo\ScssPhp\Exception\RangeException
|
36 |
*/
|
37 |
public static function checkRange($name, Range $range, $value, $unit = '')
|
38 |
{
|
51 |
return $range->last;
|
52 |
}
|
53 |
|
54 |
+
throw new RangeException("$name {$val} must be between {$range->first} and {$range->last}$unit");
|
55 |
}
|
56 |
}
|
scssphp/src/Version.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
-
* @copyright 2012-
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
@@ -18,5 +18,5 @@ namespace Leafo\ScssPhp;
|
|
18 |
*/
|
19 |
class Version
|
20 |
{
|
21 |
-
const VERSION = 'v0.
|
22 |
}
|
2 |
/**
|
3 |
* SCSSPHP
|
4 |
*
|
5 |
+
* @copyright 2012-2017 Leaf Corcoran
|
6 |
*
|
7 |
* @license http://opensource.org/licenses/MIT MIT
|
8 |
*
|
18 |
*/
|
19 |
class Version
|
20 |
{
|
21 |
+
const VERSION = 'v0.7.2';
|
22 |
}
|
wp-scss.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: WP-SCSS
|
4 |
* Plugin URI: https://github.com/ConnectThink/WP-SCSS
|
5 |
* Description: Compiles scss files live on WordPress.
|
6 |
-
* Version: 1.2.
|
7 |
* Author: Connect Think
|
8 |
* Author URI: http://connectthink.com
|
9 |
* License: GPLv3
|
@@ -46,7 +46,7 @@ if (!defined('WPSCSS_VERSION_KEY'))
|
|
46 |
define('WPSCSS_VERSION_KEY', 'wpscss_version');
|
47 |
|
48 |
if (!defined('WPSCSS_VERSION_NUM'))
|
49 |
-
define('WPSCSS_VERSION_NUM', '1.2.
|
50 |
|
51 |
// Add version to options table
|
52 |
if ( get_option( WPSCSS_VERSION_KEY ) !== false ) {
|
3 |
* Plugin Name: WP-SCSS
|
4 |
* Plugin URI: https://github.com/ConnectThink/WP-SCSS
|
5 |
* Description: Compiles scss files live on WordPress.
|
6 |
+
* Version: 1.2.3
|
7 |
* Author: Connect Think
|
8 |
* Author URI: http://connectthink.com
|
9 |
* License: GPLv3
|
46 |
define('WPSCSS_VERSION_KEY', 'wpscss_version');
|
47 |
|
48 |
if (!defined('WPSCSS_VERSION_NUM'))
|
49 |
+
define('WPSCSS_VERSION_NUM', '1.2.3');
|
50 |
|
51 |
// Add version to options table
|
52 |
if ( get_option( WPSCSS_VERSION_KEY ) !== false ) {
|