mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-22 12:49:55 +09:00
Add CoolSMS PHP SDK, and update Composer dependencies
This commit is contained in:
parent
40c43e8fa0
commit
c719fc0500
242 changed files with 3487 additions and 28983 deletions
222
vendor/leafo/scssphp/src/Compiler.php
vendored
222
vendor/leafo/scssphp/src/Compiler.php
vendored
|
|
@ -125,20 +125,21 @@ class Compiler
|
|||
protected $rootEnv;
|
||||
protected $rootBlock;
|
||||
|
||||
protected $env;
|
||||
protected $scope;
|
||||
protected $storeEnv;
|
||||
protected $charsetSeen;
|
||||
protected $sourceNames;
|
||||
|
||||
private $indentLevel;
|
||||
private $commentsSeen;
|
||||
private $extends;
|
||||
private $extendsMap;
|
||||
private $parsedFiles;
|
||||
private $env;
|
||||
private $scope;
|
||||
private $parser;
|
||||
private $sourceNames;
|
||||
private $sourceIndex;
|
||||
private $sourceLine;
|
||||
private $sourceColumn;
|
||||
private $storeEnv;
|
||||
private $charsetSeen;
|
||||
private $stderr;
|
||||
private $shouldEvaluate;
|
||||
private $ignoreErrors;
|
||||
|
|
@ -207,7 +208,7 @@ class Compiler
|
|||
*
|
||||
* @return \Leafo\ScssPhp\Parser
|
||||
*/
|
||||
private function parserFactory($path)
|
||||
protected function parserFactory($path)
|
||||
{
|
||||
$parser = new Parser($path, count($this->sourceNames), $this->encoding);
|
||||
|
||||
|
|
@ -396,23 +397,42 @@ class Compiler
|
|||
}
|
||||
|
||||
if ($this->matchExtendsSingle($part, $origin)) {
|
||||
$before = array_slice($selector, 0, $i);
|
||||
$after = array_slice($selector, $i + 1);
|
||||
$s = count($before);
|
||||
$before = array_slice($selector, 0, $i);
|
||||
|
||||
list($before, $nonBreakableBefore) = $this->extractRelationshipFromFragment($before);
|
||||
|
||||
foreach ($origin as $new) {
|
||||
$k = 0;
|
||||
|
||||
// remove shared parts
|
||||
if ($initial) {
|
||||
while ($k < $s && isset($new[$k]) && $before[$k] === $new[$k]) {
|
||||
while ($k < $i && isset($new[$k]) && $selector[$k] === $new[$k]) {
|
||||
$k++;
|
||||
}
|
||||
}
|
||||
|
||||
$replacement = [];
|
||||
$tempReplacement = $k > 0 ? array_slice($new, $k) : $new;
|
||||
|
||||
for ($l = count($tempReplacement) - 1; $l >= 0; $l--) {
|
||||
$slice = $tempReplacement[$l];
|
||||
array_unshift($replacement, $slice);
|
||||
|
||||
if (! $this->isImmediateRelationshipCombinator(end($slice))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$afterBefore = $l != 0 ? array_slice($tempReplacement, 0, $l) : [];
|
||||
|
||||
// Merge shared direct relationships.
|
||||
$mergedBefore = $this->mergeDirectRelationships($afterBefore, $nonBreakableBefore);
|
||||
|
||||
$result = array_merge(
|
||||
$before,
|
||||
$k > 0 ? array_slice($new, $k) : $new,
|
||||
$mergedBefore,
|
||||
$replacement,
|
||||
$after
|
||||
);
|
||||
|
||||
|
|
@ -423,14 +443,22 @@ class Compiler
|
|||
$out[] = $result;
|
||||
|
||||
// recursively check for more matches
|
||||
$this->matchExtends($result, $out, $i, false);
|
||||
$this->matchExtends($result, $out, count($before) + count($mergedBefore), false);
|
||||
|
||||
// selector sequence merging
|
||||
if (! empty($before) && count($new) > 1) {
|
||||
$sharedParts = $k > 0 ? array_slice($before, 0, $k) : [];
|
||||
$postSharedParts = $k > 0 ? array_slice($before, $k) : $before;
|
||||
|
||||
list($injectBetweenSharedParts, $nonBreakable2) = $this->extractRelationshipFromFragment($afterBefore);
|
||||
|
||||
$result2 = array_merge(
|
||||
array_slice($new, 0, -1),
|
||||
$k > 0 ? array_slice($before, $k) : $before,
|
||||
array_slice($new, -1),
|
||||
$sharedParts,
|
||||
$injectBetweenSharedParts,
|
||||
$postSharedParts,
|
||||
$nonBreakable2,
|
||||
$nonBreakableBefore,
|
||||
$replacement,
|
||||
$after
|
||||
);
|
||||
|
||||
|
|
@ -467,6 +495,13 @@ class Compiler
|
|||
}
|
||||
}
|
||||
|
||||
$extendingDecoratedTag = false;
|
||||
|
||||
if (count($single) > 1) {
|
||||
$matches = null;
|
||||
$extendingDecoratedTag = preg_match('/^[a-z0-9]+$/i', $single[0], $matches) ? $matches[0] : false;
|
||||
}
|
||||
|
||||
foreach ($single as $part) {
|
||||
if (isset($this->extendsMap[$part])) {
|
||||
foreach ($this->extendsMap[$part] as $idx) {
|
||||
|
|
@ -496,7 +531,17 @@ class Compiler
|
|||
return false;
|
||||
}
|
||||
|
||||
$combined = $this->combineSelectorSingle(end($new), $rem);
|
||||
$replacement = end($new);
|
||||
|
||||
// Extending a decorated tag with another tag is not possible.
|
||||
if ($extendingDecoratedTag && $replacement[0] != $extendingDecoratedTag &&
|
||||
preg_match('/^[a-z0-9]+$/i', $replacement[0])
|
||||
) {
|
||||
unset($origin[$j]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$combined = $this->combineSelectorSingle($replacement, $rem);
|
||||
|
||||
if (count(array_diff($combined, $origin[$j][count($origin[$j]) - 1]))) {
|
||||
$origin[$j][count($origin[$j]) - 1] = $combined;
|
||||
|
|
@ -511,6 +556,39 @@ class Compiler
|
|||
return $found;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a relationship from the fragment.
|
||||
*
|
||||
* When extracting the last portion of a selector we will be left with a
|
||||
* fragment which may end with a direction relationship combinator. This
|
||||
* method will extract the relationship fragment and return it along side
|
||||
* the rest.
|
||||
*
|
||||
* @param array $fragment The selector fragment maybe ending with a direction relationship combinator.
|
||||
* @return array The selector without the relationship fragment if any, the relationship fragment.
|
||||
*/
|
||||
protected function extractRelationshipFromFragment(array $fragment)
|
||||
{
|
||||
$parents = [];
|
||||
$children = [];
|
||||
$j = $i = count($fragment);
|
||||
|
||||
for (;;) {
|
||||
$children = $j != $i ? array_slice($fragment, $j, $i - $j) : [];
|
||||
$parents = array_slice($fragment, 0, $j);
|
||||
$slice = end($parents);
|
||||
|
||||
if (empty($slice) || ! $this->isImmediateRelationshipCombinator($slice[0])) {
|
||||
break;
|
||||
}
|
||||
|
||||
$j -= 2;
|
||||
}
|
||||
|
||||
return [$parents, $children];
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine selector single
|
||||
*
|
||||
|
|
@ -1283,6 +1361,37 @@ class Compiler
|
|||
return $out;
|
||||
}
|
||||
|
||||
protected function mergeDirectRelationships($selectors1, $selectors2)
|
||||
{
|
||||
if (empty($selectors1) || empty($selectors2)) {
|
||||
return array_merge($selectors1, $selectors2);
|
||||
}
|
||||
|
||||
$part1 = end($selectors1);
|
||||
$part2 = end($selectors2);
|
||||
|
||||
if (! $this->isImmediateRelationshipCombinator($part1[0]) || $part1 !== $part2) {
|
||||
return array_merge($selectors1, $selectors2);
|
||||
}
|
||||
|
||||
$merged = [];
|
||||
|
||||
do {
|
||||
$part1 = array_pop($selectors1);
|
||||
$part2 = array_pop($selectors2);
|
||||
|
||||
if ($this->isImmediateRelationshipCombinator($part1[0]) && $part1 !== $part2) {
|
||||
$merged = array_merge($selectors1, [$part1], $selectors2, [$part2], $merged);
|
||||
break;
|
||||
}
|
||||
|
||||
array_unshift($merged, $part1);
|
||||
array_unshift($merged, [array_pop($selectors1)[0] . array_pop($selectors2)[0]]);
|
||||
} while (! empty($selectors1) && ! empty($selectors2));
|
||||
|
||||
return $merged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge media types
|
||||
*
|
||||
|
|
@ -1460,9 +1569,9 @@ class Compiler
|
|||
list(, $name, $value) = $child;
|
||||
|
||||
if ($name[0] === Type::T_VARIABLE) {
|
||||
$flag = isset($child[3]) ? $child[3] : null;
|
||||
$isDefault = $flag === '!default';
|
||||
$isGlobal = $flag === '!global';
|
||||
$flags = isset($child[3]) ? $child[3] : [];
|
||||
$isDefault = in_array('!default', $flags);
|
||||
$isGlobal = in_array('!global', $flags);
|
||||
|
||||
if ($isGlobal) {
|
||||
$this->set($name[1], $this->reduce($value), false, $this->rootEnv);
|
||||
|
|
@ -1622,7 +1731,7 @@ class Compiler
|
|||
$end = $end[1];
|
||||
$d = $start < $end ? 1 : -1;
|
||||
|
||||
while (true) {
|
||||
for (;;) {
|
||||
if ((! $for->until && $start - $d == $end) ||
|
||||
($for->until && $start == $end)
|
||||
) {
|
||||
|
|
@ -1695,6 +1804,9 @@ class Compiler
|
|||
$this->pushEnv();
|
||||
$this->env->depth--;
|
||||
|
||||
$storeEnv = $this->storeEnv;
|
||||
$this->storeEnv = $this->env;
|
||||
|
||||
if (isset($content)) {
|
||||
$content->scope = $callingScope;
|
||||
|
||||
|
|
@ -1709,6 +1821,8 @@ class Compiler
|
|||
|
||||
$this->compileChildrenNoReturn($mixin->children, $out);
|
||||
|
||||
$this->storeEnv = $storeEnv;
|
||||
|
||||
$this->popEnv();
|
||||
break;
|
||||
|
||||
|
|
@ -1717,7 +1831,9 @@ class Compiler
|
|||
?: $this->get(self::$namespaces['special'] . 'content', false, $this->env);
|
||||
|
||||
if (! $content) {
|
||||
$this->throwError('Expected @content inside of mixin');
|
||||
$content = new \stdClass();
|
||||
$content->scope = new \stdClass();
|
||||
$content->children = $this->storeEnv->parent->block->children;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1742,7 +1858,7 @@ class Compiler
|
|||
|
||||
$line = $this->sourceLine;
|
||||
$value = $this->compileValue($this->reduce($value, true));
|
||||
echo "Line $line WARN: $value\n";
|
||||
fwrite($this->stderr, "Line $line WARN: $value\n");
|
||||
break;
|
||||
|
||||
case Type::T_ERROR:
|
||||
|
|
@ -1802,6 +1918,18 @@ class Compiler
|
|||
return $value !== self::$false && $value !== self::$null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the value a direct relationship combinator?
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isImmediateRelationshipCombinator($value)
|
||||
{
|
||||
return $value === '>' || $value === '+' || $value === '~';
|
||||
}
|
||||
|
||||
/**
|
||||
* Should $value cause its operand to eval
|
||||
*
|
||||
|
|
@ -2216,7 +2344,7 @@ class Compiler
|
|||
return;
|
||||
}
|
||||
|
||||
if ($left !== self::$false) {
|
||||
if ($left !== self::$false and $left !== self::$null) {
|
||||
return $this->reduce($right, true);
|
||||
}
|
||||
|
||||
|
|
@ -2238,7 +2366,7 @@ class Compiler
|
|||
return;
|
||||
}
|
||||
|
||||
if ($left !== self::$false) {
|
||||
if ($left !== self::$false and $left !== self::$null) {
|
||||
return $left;
|
||||
}
|
||||
|
||||
|
|
@ -2937,20 +3065,28 @@ class Compiler
|
|||
*/
|
||||
public function get($name, $shouldThrow = true, Environment $env = null)
|
||||
{
|
||||
$name = $this->normalizeName($name);
|
||||
$normalizedName = $this->normalizeName($name);
|
||||
$specialContentKey = self::$namespaces['special'] . 'content';
|
||||
|
||||
if (! isset($env)) {
|
||||
$env = $this->getStoreEnv();
|
||||
}
|
||||
|
||||
$hasNamespace = $name[0] === '^' || $name[0] === '@' || $name[0] === '%';
|
||||
$nextIsRoot = false;
|
||||
$hasNamespace = $normalizedName[0] === '^' || $normalizedName[0] === '@' || $normalizedName[0] === '%';
|
||||
|
||||
for (;;) {
|
||||
if (array_key_exists($name, $env->store)) {
|
||||
return $env->store[$name];
|
||||
if (array_key_exists($normalizedName, $env->store)) {
|
||||
return $env->store[$normalizedName];
|
||||
}
|
||||
|
||||
if (! $hasNamespace && isset($env->marker)) {
|
||||
if (! $nextIsRoot && ! empty($env->store[$specialContentKey])) {
|
||||
$env = $env->store[$specialContentKey]->scope;
|
||||
$nextIsRoot = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
$env = $this->rootEnv;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -3303,7 +3439,7 @@ class Compiler
|
|||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function handleImportLoop($name)
|
||||
protected function handleImportLoop($name)
|
||||
{
|
||||
for ($env = $this->env; $env; $env = $env->parent) {
|
||||
$file = $this->sourceNames[$env->block->sourceIndex];
|
||||
|
|
@ -3346,6 +3482,9 @@ class Compiler
|
|||
|
||||
$this->pushEnv();
|
||||
|
||||
$storeEnv = $this->storeEnv;
|
||||
$this->storeEnv = $this->env;
|
||||
|
||||
// set the args
|
||||
if (isset($func->args)) {
|
||||
$this->applyArguments($func->args, $argValues);
|
||||
|
|
@ -3360,6 +3499,8 @@ class Compiler
|
|||
|
||||
$ret = $this->compileChildren($func->children, $tmp);
|
||||
|
||||
$this->storeEnv = $storeEnv;
|
||||
|
||||
$this->popEnv();
|
||||
|
||||
$returnValue = ! isset($ret) ? self::$defaultValue : $ret;
|
||||
|
|
@ -3611,7 +3752,7 @@ class Compiler
|
|||
}
|
||||
|
||||
if ($value === null) {
|
||||
$value = self::$null;
|
||||
return self::$null;
|
||||
}
|
||||
|
||||
if (is_numeric($value)) {
|
||||
|
|
@ -3622,6 +3763,29 @@ class Compiler
|
|||
return self::$emptyString;
|
||||
}
|
||||
|
||||
if (preg_match('/^(#([0-9a-f]{6})|#([0-9a-f]{3}))$/i', $value, $m)) {
|
||||
$color = [Type::T_COLOR];
|
||||
|
||||
if (isset($m[3])) {
|
||||
$num = hexdec($m[3]);
|
||||
|
||||
foreach ([3, 2, 1] as $i) {
|
||||
$t = $num & 0xf;
|
||||
$color[$i] = $t << 4 | $t;
|
||||
$num >>= 4;
|
||||
}
|
||||
} else {
|
||||
$num = hexdec($m[2]);
|
||||
|
||||
foreach ([3, 2, 1] as $i) {
|
||||
$color[$i] = $num & 0xff;
|
||||
$num >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
return $color;
|
||||
}
|
||||
|
||||
return [Type::T_KEYWORD, $value];
|
||||
}
|
||||
|
||||
|
|
|
|||
29
vendor/leafo/scssphp/src/Parser.php
vendored
29
vendor/leafo/scssphp/src/Parser.php
vendored
|
|
@ -142,11 +142,16 @@ class Parser
|
|||
*/
|
||||
public function parse($buffer)
|
||||
{
|
||||
// strip BOM (byte order marker)
|
||||
if (substr($buffer, 0, 3) === "\xef\xbb\xbf") {
|
||||
$buffer = substr($buffer, 3);
|
||||
}
|
||||
|
||||
$this->buffer = rtrim($buffer, "\x00..\x1f");
|
||||
$this->count = 0;
|
||||
$this->env = null;
|
||||
$this->inParens = false;
|
||||
$this->eatWhiteDefault = true;
|
||||
$this->buffer = rtrim($buffer, "\x00..\x1f");
|
||||
|
||||
$this->saveEncoding();
|
||||
$this->extractLineNumbers($buffer);
|
||||
|
|
@ -617,8 +622,8 @@ class Parser
|
|||
$this->end()
|
||||
) {
|
||||
// check for '!flag'
|
||||
$assignmentFlag = $this->stripAssignmentFlag($value);
|
||||
$this->append([Type::T_ASSIGN, $name, $value, $assignmentFlag], $s);
|
||||
$assignmentFlags = $this->stripAssignmentFlags($value);
|
||||
$this->append([Type::T_ASSIGN, $name, $value, $assignmentFlags], $s);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -895,7 +900,7 @@ class Parser
|
|||
|
||||
$len = strlen($what);
|
||||
|
||||
if (substr($this->buffer, $this->count, $len) === $what) {
|
||||
if (strcasecmp(substr($this->buffer, $this->count, $len), $what) === 0) {
|
||||
$this->count += $len;
|
||||
|
||||
if ($eatWhitespace) {
|
||||
|
|
@ -2287,25 +2292,29 @@ class Parser
|
|||
*
|
||||
* @param array $value
|
||||
*
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
protected function stripAssignmentFlag(&$value)
|
||||
protected function stripAssignmentFlags(&$value)
|
||||
{
|
||||
$token = &$value;
|
||||
$flags = [];
|
||||
|
||||
for ($token = &$value; $token[0] === Type::T_LIST && ($s = count($token[2])); $token = &$lastNode) {
|
||||
$lastNode = &$token[2][$s - 1];
|
||||
|
||||
if ($lastNode[0] === Type::T_KEYWORD && in_array($lastNode[1], ['!default', '!global'])) {
|
||||
while ($lastNode[0] === Type::T_KEYWORD && in_array($lastNode[1], ['!default', '!global'])) {
|
||||
array_pop($token[2]);
|
||||
|
||||
$node = end($token[2]);
|
||||
|
||||
$token = $this->flattenList($token);
|
||||
|
||||
return $lastNode[1];
|
||||
$flags[] = $lastNode[1];
|
||||
|
||||
$lastNode = $node;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return $flags;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
2
vendor/leafo/scssphp/src/Version.php
vendored
2
vendor/leafo/scssphp/src/Version.php
vendored
|
|
@ -18,5 +18,5 @@ namespace Leafo\ScssPhp;
|
|||
*/
|
||||
class Version
|
||||
{
|
||||
const VERSION = 'v0.6.3';
|
||||
const VERSION = 'v0.6.6';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue