flow like the river

This commit is contained in:
root 2025-11-07 00:06:12 +01:00
commit 013fe673f3
42435 changed files with 5764238 additions and 0 deletions

122
BACK_BACK/node_modules/postcss-calc/CHANGELOG.md generated vendored Executable file
View file

@ -0,0 +1,122 @@
# 7.0.5
- Fixed: reduction
# 7.0.4
- Fixed: strips away important factors from multiplications in calc() ([#107](https://github.com/postcss/postcss-calc/issues/107))
# 7.0.3
- Fixed: substracted css-variable from zero ([#111](https://github.com/postcss/postcss-calc/issues/111))
# 7.0.2
- Fixed: incorrect reduction of subtraction from zero ([#88](https://github.com/postcss/postcss-calc/issues/88))
- Fixed: doesn't remove calc for single function
- Fixed: relax parser on unknown units ([#76](https://github.com/postcss/postcss-calc/issues/76))
- Fixed: handle numbers with exponen composed ([#83](https://github.com/postcss/postcss-calc/pull/83))
- Fixed: handle plus sign before value ([#79](https://github.com/postcss/postcss-calc/pull/79))
- Fixed: better handle precision for nested calc ([#75](https://github.com/postcss/postcss-calc/pull/75))
- Fixed: properly handle nested add and sub expression inside sub expression ([#64](https://github.com/postcss/postcss-calc/issues/64))
- Fixed: handle uppercase units and functions ([#71](https://github.com/postcss/postcss-calc/pull/71))
- Fixed: do not break `calc` with single var ([cssnano/cssnano#725](https://github.com/cssnano/cssnano/issues/725))
- Updated: `postcss` to 7.0.27 (patch)
- Updated: `postcss-selector-parser` to 6.0.2
- Updated: `postcss-value-parser` to 4.0.2
# 7.0.1
- Updated: `postcss` to 7.0.2 (patch)
- Updated: `postcss-selector-parser` to 5.0.0-rc.4 (patch)
- Updated: `postcss-value-parser` to 3.3.1 (patch)
# 7.0.0
- Changed: Updated postcss-selector-parser to version 5.0.0-rc.3
- Changed: Dropped reduce-css-calc as a dependency
- Fixed: Support constant() and env() ([#42](https://github.com/postcss/postcss-calc/issues/42), [#48](https://github.com/postcss/postcss-calc/issues/48))
- Fixed: Support custom properties with "calc" in its name ([#50](https://github.com/postcss/postcss-calc/issues/50))
- Fixed: Remove unnecessary whitespace around `*` and `/` ([cssnano#625](https://github.com/cssnano/cssnano/issues/625))
- Fixed: Arithmetic bugs around subtraction ([#49](https://github.com/postcss/postcss-calc/issues/49))
- Fixed: Handling of nested calc statements ([reduce-css-calc#49](https://github.com/MoOx/reduce-css-calc/issues/49))
- Fixed: Bugs regarding complex calculations ([reduce-cs-calc#45](https://github.com/MoOx/reduce-css-calc/issues/45))
- Fixed: `100%` incorrectly being transformed to `1` ([reduce-css-calc#44](https://github.com/MoOx/reduce-css-calc/issues/44))
- Added: support for case-insensitive calc statements
# 6.0.2 - 2018-09-25
- Fixed: use PostCSS 7 (thanks to @douglasduteil)
# 6.0.1 - 2017-10-10
- Fixed: throwing error for attribute selectors without a value
# 6.0.0 - 2017-05-08
- Breaking: Updated PostCSS from v5.x to v6.x, and reduce-css-calc from v1.x
to v2.x (thanks to @andyjansson).
# 5.3.1 - 2016-08-22
- Fixed: avoid security issue related to ``reduce-css-calc@< 1.2.4``.
# 5.3.0 - 2016-07-11
- Added: support for selector transformation via `selectors` option.
([#29](https://github.com/postcss/postcss-calc/pull/29) - @uniquegestaltung)
# 5.2.1 - 2016-04-10
- Fixed: support for multiline value
([#27](https://github.com/postcss/postcss-calc/pull/27))
# 5.2.0 - 2016-01-08
- Added: "mediaQueries" option for `@media` support
([#22](https://github.com/postcss/postcss-calc/pull/22))
# 5.1.0 - 2016-01-07
- Added: "warnWhenCannotResolve" option to warn when calc() are not reduced to a single value
([#20](https://github.com/postcss/postcss-calc/pull/20))
# 5.0.0 - 2015-08-25
- Removed: compatibility with postcss v4.x
- Added: compatibility with postcss v5.x
# 4.1.0 - 2015-04-09
- Added: compatibility with postcss v4.1.x ([#12](https://github.com/postcss/postcss-calc/pull/12))
# 4.0.1 - 2015-04-09
- Fixed: `preserve` option does not create duplicated values ([#7](https://github.com/postcss/postcss-calc/issues/7))
# 4.0.0 - 2015-01-26
- Added: compatibility with postcss v4.x
- Changed: partial compatiblity with postcss v3.x (stack traces have lost filename)
# 3.0.0 - 2014-11-24
- Added: GNU like exceptions ([#4](https://github.com/postcss/postcss-calc/issues/4))
- Added: `precision` option ([#5](https://github.com/postcss/postcss-calc/issues/5))
- Added: `preserve` option ([#6](https://github.com/postcss/postcss-calc/issues/6))
# 2.1.0 - 2014-10-15
- Added: source of the error (gnu like message) (fix [#3](https://github.com/postcss/postcss-calc/issues/3))
# 2.0.1 - 2014-08-10
- Fixed: correctly ignore unrecognized values (fix [#2](https://github.com/postcss/postcss-calc/issues/2))
# 2.0.0 - 2014-08-06
- Changed: Plugin now return a function to have a consistent api. ([ref 1](https://github.com/ianstormtaylor/rework-color-function/issues/6), [ref 2](https://twitter.com/jongleberry/status/496552790416576513))
# 1.0.0 - 2014-08-04
✨ First release based on [rework-calc](https://github.com/reworkcss/rework-calc) v1.1.0 (code mainly exported to [`reduce-css-calc`](https://github.com/MoOx/reduce-css-calc))

20
BACK_BACK/node_modules/postcss-calc/LICENSE generated vendored Executable file
View file

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2014 Maxime Thirouin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

189
BACK_BACK/node_modules/postcss-calc/README.md generated vendored Executable file
View file

@ -0,0 +1,189 @@
# PostCSS Calc [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" width="90" height="90" align="right">][PostCSS]
[![NPM Version][npm-img]][npm-url]
[![Build Status][cli-img]][cli-url]
[![Support Chat][git-img]][git-url]
[PostCSS Calc] lets you reduce `calc()` references whenever it's possible. This
can be particularly useful with the [PostCSS Custom Properties] plugin.
When multiple units are mixed together in the same expression, the `calc()`
statement is left as is, to fallback to the [W3C calc() implementation].
## Installation
```bash
npm install postcss-calc
```
## Usage
```js
// dependencies
var fs = require("fs")
var postcss = require("postcss")
var calc = require("postcss-calc")
// css to be processed
var css = fs.readFileSync("input.css", "utf8")
// process css
var output = postcss()
.use(calc())
.process(css)
.css
```
**Example** (with [PostCSS Custom Properties] enabled as well):
```js
// dependencies
var fs = require("fs")
var postcss = require("postcss")
var customProperties = require("postcss-custom-properties")
var calc = require("postcss-calc")
// css to be processed
var css = fs.readFileSync("input.css", "utf8")
// process css
var output = postcss()
.use(customProperties())
.use(calc())
.process(css)
.css
```
Using this `input.css`:
```css
:root {
--main-font-size: 16px;
}
body {
font-size: var(--main-font-size);
}
h1 {
font-size: calc(var(--main-font-size) * 2);
height: calc(100px - 2em);
margin-bottom: calc(
var(--main-font-size)
* 1.5
)
}
```
you will get:
```css
body {
font-size: 16px
}
h1 {
font-size: 32px;
height: calc(100px - 2em);
margin-bottom: 24px
}
```
Checkout [tests] for more examples.
### Options
#### `precision` (default: `5`)
Allow you to define the precision for decimal numbers.
```js
var out = postcss()
.use(calc({precision: 10}))
.process(css)
.css
```
#### `preserve` (default: `false`)
Allow you to preserve calc() usage in output so browsers will handle decimal
precision themselves.
```js
var out = postcss()
.use(calc({preserve: true}))
.process(css)
.css
```
#### `warnWhenCannotResolve` (default: `false`)
Adds warnings when calc() are not reduced to a single value.
```js
var out = postcss()
.use(calc({warnWhenCannotResolve: true}))
.process(css)
.css
```
#### `mediaQueries` (default: `false`)
Allows calc() usage as part of media query declarations.
```js
var out = postcss()
.use(calc({mediaQueries: true}))
.process(css)
.css
```
#### `selectors` (default: `false`)
Allows calc() usage as part of selectors.
```js
var out = postcss()
.use(calc({selectors: true}))
.process(css)
.css
```
Example:
```css
div[data-size="calc(3*3)"] {
width: 100px;
}
```
---
## Contributing
Work on a branch, install dev-dependencies, respect coding style & run tests
before submitting a bug fix or a feature.
```bash
git clone git@github.com:postcss/postcss-calc.git
git checkout -b patch-1
npm install
npm test
```
## [Changelog](CHANGELOG.md)
## [License](LICENSE)
[cli-img]: https://img.shields.io/travis/postcss/postcss-calc/master.svg
[cli-url]: https://travis-ci.org/postcss/postcss-calc
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
[git-url]: https://gitter.im/postcss/postcss
[npm-img]: https://img.shields.io/npm/v/postcss-calc.svg
[npm-url]: https://www.npmjs.com/package/postcss-calc
[PostCSS]: https://github.com/postcss
[PostCSS Calc]: https://github.com/postcss/postcss-calc
[PostCSS Custom Properties]: https://github.com/postcss/postcss-custom-properties
[tests]: src/__tests__/index.js
[W3C calc() implementation]: https://www.w3.org/TR/css3-values/#calc-notation

42
BACK_BACK/node_modules/postcss-calc/dist/index.js generated vendored Executable file
View file

@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcss = require("postcss");
var _transform = _interopRequireDefault(require("./lib/transform"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = (0, _postcss.plugin)('postcss-calc', function (opts) {
var options = Object.assign({
precision: 5,
preserve: false,
warnWhenCannotResolve: false,
mediaQueries: false,
selectors: false
}, opts);
return function (css, result) {
css.walk(function (node) {
var type = node.type;
if (type === 'decl') {
(0, _transform.default)(node, "value", options, result);
}
if (type === 'atrule' && options.mediaQueries) {
(0, _transform.default)(node, "params", options, result);
}
if (type === 'rule' && options.selectors) {
(0, _transform.default)(node, "selector", options, result);
}
});
};
});
exports.default = _default;
module.exports = exports.default;

157
BACK_BACK/node_modules/postcss-calc/dist/lib/convertUnit.js generated vendored Executable file
View file

@ -0,0 +1,157 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var conversions = {
// Absolute length units
'px': {
'px': 1,
'cm': 96 / 2.54,
'mm': 96 / 25.4,
'q': 96 / 101.6,
'in': 96,
'pt': 96 / 72,
'pc': 16
},
'cm': {
'px': 2.54 / 96,
'cm': 1,
'mm': 0.1,
'q': 0.025,
'in': 2.54,
'pt': 2.54 / 72,
'pc': 2.54 / 6
},
'mm': {
'px': 25.4 / 96,
'cm': 10,
'mm': 1,
'q': 0.25,
'in': 25.4,
'pt': 25.4 / 72,
'pc': 25.4 / 6
},
'q': {
'px': 101.6 / 96,
'cm': 40,
'mm': 4,
'q': 1,
'in': 101.6,
'pt': 101.6 / 72,
'pc': 101.6 / 6
},
'in': {
'px': 1 / 96,
'cm': 1 / 2.54,
'mm': 1 / 25.4,
'q': 1 / 101.6,
'in': 1,
'pt': 1 / 72,
'pc': 1 / 6
},
'pt': {
'px': 0.75,
'cm': 72 / 2.54,
'mm': 72 / 25.4,
'q': 72 / 101.6,
'in': 72,
'pt': 1,
'pc': 12
},
'pc': {
'px': 0.0625,
'cm': 6 / 2.54,
'mm': 6 / 25.4,
'q': 6 / 101.6,
'in': 6,
'pt': 6 / 72,
'pc': 1
},
// Angle units
'deg': {
'deg': 1,
'grad': 0.9,
'rad': 180 / Math.PI,
'turn': 360
},
'grad': {
'deg': 400 / 360,
'grad': 1,
'rad': 200 / Math.PI,
'turn': 400
},
'rad': {
'deg': Math.PI / 180,
'grad': Math.PI / 200,
'rad': 1,
'turn': Math.PI * 2
},
'turn': {
'deg': 1 / 360,
'grad': 0.0025,
'rad': 0.5 / Math.PI,
'turn': 1
},
// Duration units
's': {
's': 1,
'ms': 0.001
},
'ms': {
's': 1000,
'ms': 1
},
// Frequency units
'hz': {
'hz': 1,
'khz': 1000
},
'khz': {
'hz': 0.001,
'khz': 1
},
// Resolution units
'dpi': {
'dpi': 1,
'dpcm': 1 / 2.54,
'dppx': 1 / 96
},
'dpcm': {
'dpi': 2.54,
'dpcm': 1,
'dppx': 2.54 / 96
},
'dppx': {
'dpi': 96,
'dpcm': 96 / 2.54,
'dppx': 1
}
};
function convertUnit(value, sourceUnit, targetUnit, precision) {
var sourceUnitNormalized = sourceUnit.toLowerCase();
var targetUnitNormalized = targetUnit.toLowerCase();
if (!conversions[targetUnitNormalized]) {
throw new Error("Cannot convert to " + targetUnit);
}
if (!conversions[targetUnitNormalized][sourceUnitNormalized]) {
throw new Error("Cannot convert from " + sourceUnit + " to " + targetUnit);
}
var converted = conversions[targetUnitNormalized][sourceUnitNormalized] * value;
if (precision !== false) {
precision = Math.pow(10, parseInt(precision) || 5);
return Math.round(converted * precision) / precision;
}
return converted;
}
var _default = convertUnit;
exports.default = _default;
module.exports = exports.default;

320
BACK_BACK/node_modules/postcss-calc/dist/lib/reducer.js generated vendored Executable file
View file

@ -0,0 +1,320 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _convertUnit = _interopRequireDefault(require("./convertUnit"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function isValueType(type) {
switch (type) {
case 'LengthValue':
case 'AngleValue':
case 'TimeValue':
case 'FrequencyValue':
case 'ResolutionValue':
case 'EmValue':
case 'ExValue':
case 'ChValue':
case 'RemValue':
case 'VhValue':
case 'VwValue':
case 'VminValue':
case 'VmaxValue':
case 'PercentageValue':
case 'Number':
return true;
}
return false;
}
function flip(operator) {
return operator === '+' ? '-' : '+';
}
function isAddSubOperator(operator) {
return operator === '+' || operator === '-';
}
function collectAddSubItems(preOperator, node, collected, precision) {
if (!isAddSubOperator(preOperator)) {
throw new Error(`invalid operator ${preOperator}`);
}
var type = node.type;
if (isValueType(type)) {
var itemIndex = collected.findIndex(function (x) {
return x.node.type === type;
});
if (itemIndex >= 0) {
if (node.value === 0) {
return;
}
var _covertNodesUnits = covertNodesUnits(collected[itemIndex].node, node, precision),
reducedNode = _covertNodesUnits.left,
current = _covertNodesUnits.right;
if (collected[itemIndex].preOperator === '-') {
collected[itemIndex].preOperator = '+';
reducedNode.value *= -1;
}
if (preOperator === "+") {
reducedNode.value += current.value;
} else {
reducedNode.value -= current.value;
} // make sure reducedNode.value >= 0
if (reducedNode.value >= 0) {
collected[itemIndex] = {
node: reducedNode,
preOperator: '+'
};
} else {
reducedNode.value *= -1;
collected[itemIndex] = {
node: reducedNode,
preOperator: '-'
};
}
} else {
// make sure node.value >= 0
if (node.value >= 0) {
collected.push({
node,
preOperator
});
} else {
node.value *= -1;
collected.push({
node,
preOperator: flip(preOperator)
});
}
}
} else if (type === "MathExpression") {
if (isAddSubOperator(node.operator)) {
collectAddSubItems(preOperator, node.left, collected, precision);
var collectRightOperator = preOperator === '-' ? flip(node.operator) : node.operator;
collectAddSubItems(collectRightOperator, node.right, collected, precision);
} else {
// * or /
var _reducedNode = reduce(node, precision); // prevent infinite recursive call
if (_reducedNode.type !== "MathExpression" || isAddSubOperator(_reducedNode.operator)) {
collectAddSubItems(preOperator, _reducedNode, collected, precision);
} else {
collected.push({
node: _reducedNode,
preOperator
});
}
}
} else {
collected.push({
node,
preOperator
});
}
}
function reduceAddSubExpression(node, precision) {
var collected = [];
collectAddSubItems('+', node, collected, precision);
var withoutZeroItem = collected.filter(function (item) {
return !(isValueType(item.node.type) && item.node.value === 0);
});
var firstNonZeroItem = withoutZeroItem[0]; // could be undefined
// prevent producing "calc(-var(--a))" or "calc()"
// which is invalid css
if (!firstNonZeroItem || firstNonZeroItem.preOperator === '-' && !isValueType(firstNonZeroItem.node.type)) {
var firstZeroItem = collected.find(function (item) {
return isValueType(item.node.type) && item.node.value === 0;
});
withoutZeroItem.unshift(firstZeroItem);
} // make sure the preOperator of the first item is +
if (withoutZeroItem[0].preOperator === '-' && isValueType(withoutZeroItem[0].node.type)) {
withoutZeroItem[0].node.value *= -1;
withoutZeroItem[0].preOperator = '+';
}
var root = withoutZeroItem[0].node;
for (var i = 1; i < withoutZeroItem.length; i++) {
root = {
type: 'MathExpression',
operator: withoutZeroItem[i].preOperator,
left: root,
right: withoutZeroItem[i].node
};
}
return root;
}
function reduceDivisionExpression(node) {
if (!isValueType(node.right.type)) {
return node;
}
if (node.right.type !== 'Number') {
throw new Error(`Cannot divide by "${node.right.unit}", number expected`);
}
return applyNumberDivision(node.left, node.right.value);
} // apply (expr) / number
function applyNumberDivision(node, divisor) {
if (divisor === 0) {
throw new Error('Cannot divide by zero');
}
if (isValueType(node.type)) {
node.value /= divisor;
return node;
}
if (node.type === "MathExpression" && isAddSubOperator(node.operator)) {
// turn (a + b) / num into a/num + b/num
// is good for further reduction
// checkout the test case
// "should reduce division before reducing additions"
return {
type: "MathExpression",
operator: node.operator,
left: applyNumberDivision(node.left, divisor),
right: applyNumberDivision(node.right, divisor)
};
} // it is impossible to reduce it into a single value
// .e.g the node contains css variable
// so we just preserve the division and let browser do it
return {
type: "MathExpression",
operator: '/',
left: node,
right: {
type: "Number",
value: divisor
}
};
}
function reduceMultiplicationExpression(node) {
// (expr) * number
if (node.right.type === 'Number') {
return applyNumberMultiplication(node.left, node.right.value);
} // number * (expr)
if (node.left.type === 'Number') {
return applyNumberMultiplication(node.right, node.left.value);
}
return node;
} // apply (expr) / number
function applyNumberMultiplication(node, multiplier) {
if (isValueType(node.type)) {
node.value *= multiplier;
return node;
}
if (node.type === "MathExpression" && isAddSubOperator(node.operator)) {
// turn (a + b) * num into a*num + b*num
// is good for further reduction
// checkout the test case
// "should reduce multiplication before reducing additions"
return {
type: "MathExpression",
operator: node.operator,
left: applyNumberMultiplication(node.left, multiplier),
right: applyNumberMultiplication(node.right, multiplier)
};
} // it is impossible to reduce it into a single value
// .e.g the node contains css variable
// so we just preserve the division and let browser do it
return {
type: "MathExpression",
operator: '*',
left: node,
right: {
type: "Number",
value: multiplier
}
};
}
function covertNodesUnits(left, right, precision) {
switch (left.type) {
case 'LengthValue':
case 'AngleValue':
case 'TimeValue':
case 'FrequencyValue':
case 'ResolutionValue':
if (right.type === left.type && right.unit && left.unit) {
var converted = (0, _convertUnit.default)(right.value, right.unit, left.unit, precision);
right = {
type: left.type,
value: converted,
unit: left.unit
};
}
return {
left,
right
};
default:
return {
left,
right
};
}
}
function reduce(node, precision) {
if (node.type === "MathExpression") {
if (isAddSubOperator(node.operator)) {
// reduceAddSubExpression will call reduce recursively
return reduceAddSubExpression(node, precision);
}
node.left = reduce(node.left, precision);
node.right = reduce(node.right, precision);
switch (node.operator) {
case "/":
return reduceDivisionExpression(node, precision);
case "*":
return reduceMultiplicationExpression(node, precision);
}
return node;
}
return node;
}
var _default = reduce;
exports.default = _default;
module.exports = exports.default;

81
BACK_BACK/node_modules/postcss-calc/dist/lib/stringifier.js generated vendored Executable file
View file

@ -0,0 +1,81 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var order = {
"*": 0,
"/": 0,
"+": 1,
"-": 1
};
function round(value, prec) {
if (prec !== false) {
var precision = Math.pow(10, prec);
return Math.round(value * precision) / precision;
}
return value;
}
function stringify(node, prec) {
switch (node.type) {
case "MathExpression":
{
var left = node.left,
right = node.right,
op = node.operator;
var str = "";
if (left.type === 'MathExpression' && order[op] < order[left.operator]) {
str += `(${stringify(left, prec)})`;
} else {
str += stringify(left, prec);
}
str += order[op] ? ` ${node.operator} ` : node.operator;
if (right.type === 'MathExpression' && order[op] < order[right.operator]) {
str += `(${stringify(right, prec)})`;
} else {
str += stringify(right, prec);
}
return str;
}
case 'Number':
return round(node.value, prec);
case 'Function':
return node.value;
default:
return round(node.value, prec) + node.unit;
}
}
function _default(calc, node, originalValue, options, result, item) {
var str = stringify(node, options.precision);
var shouldPrintCalc = node.type === "MathExpression" || node.type === "Function";
if (shouldPrintCalc) {
// if calc expression couldn't be resolved to a single value, re-wrap it as
// a calc()
str = `${calc}(${str})`; // if the warnWhenCannotResolve option is on, inform the user that the calc
// expression could not be resolved to a single value
if (options.warnWhenCannotResolve) {
result.warn("Could not reduce expression: " + originalValue, {
plugin: 'postcss-calc',
node: item
});
}
}
return str;
}
module.exports = exports.default;

81
BACK_BACK/node_modules/postcss-calc/dist/lib/transform.js generated vendored Executable file
View file

@ -0,0 +1,81 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
var _parser = require("../parser");
var _reducer = _interopRequireDefault(require("./reducer"));
var _stringifier = _interopRequireDefault(require("./stringifier"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// eslint-disable-next-line import/no-unresolved
var MATCH_CALC = /((?:-(moz|webkit)-)?calc)/i;
function transformValue(value, options, result, item) {
return (0, _postcssValueParser.default)(value).walk(function (node) {
// skip anything which isn't a calc() function
if (node.type !== 'function' || !MATCH_CALC.test(node.value)) {
return node;
} // stringify calc expression and produce an AST
var contents = _postcssValueParser.default.stringify(node.nodes);
var ast = _parser.parser.parse(contents); // reduce AST to its simplest form, that is, either to a single value
// or a simplified calc expression
var reducedAst = (0, _reducer.default)(ast, options.precision); // stringify AST and write it back
node.type = 'word';
node.value = (0, _stringifier.default)(node.value, reducedAst, value, options, result, item);
return false;
}).toString();
}
function transformSelector(value, options, result, item) {
return (0, _postcssSelectorParser.default)(function (selectors) {
selectors.walk(function (node) {
// attribute value
// e.g. the "calc(3*3)" part of "div[data-size="calc(3*3)"]"
if (node.type === 'attribute' && node.value) {
node.setValue(transformValue(node.value, options, result, item));
} // tag value
// e.g. the "calc(3*3)" part of "div:nth-child(2n + calc(3*3))"
if (node.type === 'tag') {
node.value = transformValue(node.value, options, result, item);
}
return;
});
}).processSync(value);
}
var _default = function _default(node, property, options, result) {
var value = property === "selector" ? transformSelector(node[property], options, result, node) : transformValue(node[property], options, result, node); // if the preserve option is enabled and the value has changed, write the
// transformed value into a cloned node which is inserted before the current
// node, preserving the original value. Otherwise, overwrite the original
// value.
if (options.preserve && node[property] !== value) {
var clone = node.clone();
clone[property] = value;
node.parent.insertBefore(node, clone);
} else {
node[property] = value;
}
};
exports.default = _default;
module.exports = exports.default;

3804
BACK_BACK/node_modules/postcss-calc/dist/parser.js generated vendored Executable file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,22 @@
Copyright (c) Bogdan Chadkin <trysound@yandex.ru>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,263 @@
# postcss-value-parser
[![Travis CI](https://travis-ci.org/TrySound/postcss-value-parser.svg)](https://travis-ci.org/TrySound/postcss-value-parser)
Transforms CSS declaration values and at-rule parameters into a tree of nodes, and provides a simple traversal API.
## Usage
```js
var valueParser = require('postcss-value-parser');
var cssBackgroundValue = 'url(foo.png) no-repeat 40px 73%';
var parsedValue = valueParser(cssBackgroundValue);
// parsedValue exposes an API described below,
// e.g. parsedValue.walk(..), parsedValue.toString(), etc.
```
For example, parsing the value `rgba(233, 45, 66, .5)` will return the following:
```js
{
nodes: [
{
type: 'function',
value: 'rgba',
before: '',
after: '',
nodes: [
{ type: 'word', value: '233' },
{ type: 'div', value: ',', before: '', after: ' ' },
{ type: 'word', value: '45' },
{ type: 'div', value: ',', before: '', after: ' ' },
{ type: 'word', value: '66' },
{ type: 'div', value: ',', before: ' ', after: '' },
{ type: 'word', value: '.5' }
]
}
]
}
```
If you wanted to convert each `rgba()` value in `sourceCSS` to a hex value, you could do so like this:
```js
var valueParser = require('postcss-value-parser');
var parsed = valueParser(sourceCSS);
// walk() will visit all the of the nodes in the tree,
// invoking the callback for each.
parsed.walk(function (node) {
// Since we only want to transform rgba() values,
// we can ignore anything else.
if (node.type !== 'function' && node.value !== 'rgba') return;
// We can make an array of the rgba() arguments to feed to a
// convertToHex() function
var color = node.nodes.filter(function (node) {
return node.type === 'word';
}).map(function (node) {
return Number(node.value);
}); // [233, 45, 66, .5]
// Now we will transform the existing rgba() function node
// into a word node with the hex value
node.type = 'word';
node.value = convertToHex(color);
})
parsed.toString(); // #E92D42
```
## Nodes
Each node is an object with these common properties:
- **type**: The type of node (`word`, `string`, `div`, `space`, `comment`, or `function`).
Each type is documented below.
- **value**: Each node has a `value` property; but what exactly `value` means
is specific to the node type. Details are documented for each type below.
- **sourceIndex**: The starting index of the node within the original source
string. For example, given the source string `10px 20px`, the `word` node
whose value is `20px` will have a `sourceIndex` of `5`.
### word
The catch-all node type that includes keywords (e.g. `no-repeat`),
quantities (e.g. `20px`, `75%`, `1.5`), and hex colors (e.g. `#e6e6e6`).
Node-specific properties:
- **value**: The "word" itself.
### string
A quoted string value, e.g. `"something"` in `content: "something";`.
Node-specific properties:
- **value**: The text content of the string.
- **quote**: The quotation mark surrounding the string, either `"` or `'`.
- **unclosed**: `true` if the string was not closed properly. e.g. `"unclosed string `.
### div
A divider, for example
- `,` in `animation-duration: 1s, 2s, 3s`
- `/` in `border-radius: 10px / 23px`
- `:` in `(min-width: 700px)`
Node-specific properties:
- **value**: The divider character. Either `,`, `/`, or `:` (see examples above).
- **before**: Whitespace before the divider.
- **after**: Whitespace after the divider.
### space
Whitespace used as a separator, e.g. ` ` occurring twice in `border: 1px solid black;`.
Node-specific properties:
- **value**: The whitespace itself.
### comment
A CSS comment starts with `/*` and ends with `*/`
Node-specific properties:
- **value**: The comment value without `/*` and `*/`
- **unclosed**: `true` if the comment was not closed properly. e.g. `/* comment without an end `.
### function
A CSS function, e.g. `rgb(0,0,0)` or `url(foo.bar)`.
Function nodes have nodes nested within them: the function arguments.
Additional properties:
- **value**: The name of the function, e.g. `rgb` in `rgb(0,0,0)`.
- **before**: Whitespace after the opening parenthesis and before the first argument,
e.g. ` ` in `rgb( 0,0,0)`.
- **after**: Whitespace before the closing parenthesis and after the last argument,
e.g. ` ` in `rgb(0,0,0 )`.
- **nodes**: More nodes representing the arguments to the function.
- **unclosed**: `true` if the parentheses was not closed properly. e.g. `( unclosed-function `.
Media features surrounded by parentheses are considered functions with an
empty value. For example, `(min-width: 700px)` parses to these nodes:
```js
[
{
type: 'function', value: '', before: '', after: '',
nodes: [
{ type: 'word', value: 'min-width' },
{ type: 'div', value: ':', before: '', after: ' ' },
{ type: 'word', value: '700px' }
]
}
]
```
`url()` functions can be parsed a little bit differently depending on
whether the first character in the argument is a quotation mark.
`url( /gfx/img/bg.jpg )` parses to:
```js
{ type: 'function', sourceIndex: 0, value: 'url', before: ' ', after: ' ', nodes: [
{ type: 'word', sourceIndex: 5, value: '/gfx/img/bg.jpg' }
] }
```
`url( "/gfx/img/bg.jpg" )`, on the other hand, parses to:
```js
{ type: 'function', sourceIndex: 0, value: 'url', before: ' ', after: ' ', nodes: [
type: 'string', sourceIndex: 5, quote: '"', value: '/gfx/img/bg.jpg' },
] }
```
### unicode-range
The unicode-range CSS descriptor sets the specific range of characters to be
used from a font defined by @font-face and made available
for use on the current page (`unicode-range: U+0025-00FF`).
Node-specific properties:
- **value**: The "unicode-range" itself.
## API
```
var valueParser = require('postcss-value-parser');
```
### valueParser.unit(quantity)
Parses `quantity`, distinguishing the number from the unit. Returns an object like the following:
```js
// Given 2rem
{
number: '2',
unit: 'rem'
}
```
If the `quantity` argument cannot be parsed as a number, returns `false`.
*This function does not parse complete values*: you cannot pass it `1px solid black` and expect `px` as
the unit. Instead, you should pass it single quantities only. Parse `1px solid black`, then pass it
the stringified `1px` node (a `word` node) to parse the number and unit.
### valueParser.stringify(nodes[, custom])
Stringifies a node or array of nodes.
The `custom` function is called for each `node`; return a string to override the default behaviour.
### valueParser.walk(nodes, callback[, bubble])
Walks each provided node, recursively walking all descendent nodes within functions.
Returning `false` in the `callback` will prevent traversal of descendent nodes (within functions).
You can use this feature to for shallow iteration, walking over only the *immediate* children.
*Note: This only applies if `bubble` is `false` (which is the default).*
By default, the tree is walked from the outermost node inwards.
To reverse the direction, pass `true` for the `bubble` argument.
The `callback` is invoked with three arguments: `callback(node, index, nodes)`.
- `node`: The current node.
- `index`: The index of the current node.
- `nodes`: The complete nodes array passed to `walk()`.
Returns the `valueParser` instance.
### var parsed = valueParser(value)
Returns the parsed node tree.
### parsed.nodes
The array of nodes.
### parsed.toString()
Stringifies the node tree.
### parsed.walk(callback[, bubble])
Walks each node inside `parsed.nodes`. See the documentation for `valueParser.walk()` above.
# License
MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)

View file

@ -0,0 +1,177 @@
declare namespace postcssValueParser {
interface BaseNode {
/**
* The offset, inclusive, inside the CSS value at which the node starts.
*/
sourceIndex: number;
/**
* The offset, exclusive, inside the CSS value at which the node ends.
*/
sourceEndIndex: number;
/**
* The node's characteristic value
*/
value: string;
}
interface ClosableNode {
/**
* Whether the parsed CSS value ended before the node was properly closed
*/
unclosed?: true;
}
interface AdjacentAwareNode {
/**
* The token at the start of the node
*/
before: string;
/**
* The token at the end of the node
*/
after: string;
}
interface CommentNode extends BaseNode, ClosableNode {
type: "comment";
}
interface DivNode extends BaseNode, AdjacentAwareNode {
type: "div";
}
interface FunctionNode extends BaseNode, ClosableNode, AdjacentAwareNode {
type: "function";
/**
* Nodes inside the function
*/
nodes: Node[];
}
interface SpaceNode extends BaseNode {
type: "space";
}
interface StringNode extends BaseNode, ClosableNode {
type: "string";
/**
* The quote type delimiting the string
*/
quote: '"' | "'";
}
interface UnicodeRangeNode extends BaseNode {
type: "unicode-range";
}
interface WordNode extends BaseNode {
type: "word";
}
/**
* Any node parsed from a CSS value
*/
type Node =
| CommentNode
| DivNode
| FunctionNode
| SpaceNode
| StringNode
| UnicodeRangeNode
| WordNode;
interface CustomStringifierCallback {
/**
* @param node The node to stringify
* @returns The serialized CSS representation of the node
*/
(nodes: Node): string | undefined;
}
interface WalkCallback {
/**
* @param node The currently visited node
* @param index The index of the node in the series of parsed nodes
* @param nodes The series of parsed nodes
* @returns Returning `false` will prevent traversal of descendant nodes (only applies if `bubble` was set to `true` in the `walk()` call)
*/
(node: Node, index: number, nodes: Node[]): void | boolean;
}
/**
* A CSS dimension, decomposed into its numeric and unit parts
*/
interface Dimension {
number: string;
unit: string;
}
/**
* A wrapper around a parsed CSS value that allows for inspecting and walking nodes
*/
interface ParsedValue {
/**
* The series of parsed nodes
*/
nodes: Node[];
/**
* Walk all parsed nodes, applying a callback
*
* @param callback A visitor callback that will be executed for each node
* @param bubble When set to `true`, walking will be done inside-out instead of outside-in
*/
walk(callback: WalkCallback, bubble?: boolean): this;
}
interface ValueParser {
/**
* Decompose a CSS dimension into its numeric and unit part
*
* @param value The dimension to decompose
* @returns An object representing `number` and `unit` part of the dimension or `false` if the decomposing fails
*/
unit(value: string): Dimension | false;
/**
* Serialize a series of nodes into a CSS value
*
* @param nodes The nodes to stringify
* @param custom A custom stringifier callback
* @returns The generated CSS value
*/
stringify(nodes: Node | Node[], custom?: CustomStringifierCallback): string;
/**
* Walk a series of nodes, applying a callback
*
* @param nodes The nodes to walk
* @param callback A visitor callback that will be executed for each node
* @param bubble When set to `true`, walking will be done inside-out instead of outside-in
*/
walk(nodes: Node[], callback: WalkCallback, bubble?: boolean): void;
/**
* Parse a CSS value into a series of nodes to operate on
*
* @param value The value to parse
*/
new (value: string): ParsedValue;
/**
* Parse a CSS value into a series of nodes to operate on
*
* @param value The value to parse
*/
(value: string): ParsedValue;
}
}
declare const postcssValueParser: postcssValueParser.ValueParser;
export = postcssValueParser;

View file

@ -0,0 +1,28 @@
var parse = require("./parse");
var walk = require("./walk");
var stringify = require("./stringify");
function ValueParser(value) {
if (this instanceof ValueParser) {
this.nodes = parse(value);
return this;
}
return new ValueParser(value);
}
ValueParser.prototype.toString = function() {
return Array.isArray(this.nodes) ? stringify(this.nodes) : "";
};
ValueParser.prototype.walk = function(cb, bubble) {
walk(this.nodes, cb, bubble);
return this;
};
ValueParser.unit = require("./unit");
ValueParser.walk = walk;
ValueParser.stringify = stringify;
module.exports = ValueParser;

View file

@ -0,0 +1,321 @@
var openParentheses = "(".charCodeAt(0);
var closeParentheses = ")".charCodeAt(0);
var singleQuote = "'".charCodeAt(0);
var doubleQuote = '"'.charCodeAt(0);
var backslash = "\\".charCodeAt(0);
var slash = "/".charCodeAt(0);
var comma = ",".charCodeAt(0);
var colon = ":".charCodeAt(0);
var star = "*".charCodeAt(0);
var uLower = "u".charCodeAt(0);
var uUpper = "U".charCodeAt(0);
var plus = "+".charCodeAt(0);
var isUnicodeRange = /^[a-f0-9?-]+$/i;
module.exports = function(input) {
var tokens = [];
var value = input;
var next,
quote,
prev,
token,
escape,
escapePos,
whitespacePos,
parenthesesOpenPos;
var pos = 0;
var code = value.charCodeAt(pos);
var max = value.length;
var stack = [{ nodes: tokens }];
var balanced = 0;
var parent;
var name = "";
var before = "";
var after = "";
while (pos < max) {
// Whitespaces
if (code <= 32) {
next = pos;
do {
next += 1;
code = value.charCodeAt(next);
} while (code <= 32);
token = value.slice(pos, next);
prev = tokens[tokens.length - 1];
if (code === closeParentheses && balanced) {
after = token;
} else if (prev && prev.type === "div") {
prev.after = token;
prev.sourceEndIndex += token.length;
} else if (
code === comma ||
code === colon ||
(code === slash &&
value.charCodeAt(next + 1) !== star &&
(!parent ||
(parent && parent.type === "function" && parent.value !== "calc")))
) {
before = token;
} else {
tokens.push({
type: "space",
sourceIndex: pos,
sourceEndIndex: next,
value: token
});
}
pos = next;
// Quotes
} else if (code === singleQuote || code === doubleQuote) {
next = pos;
quote = code === singleQuote ? "'" : '"';
token = {
type: "string",
sourceIndex: pos,
quote: quote
};
do {
escape = false;
next = value.indexOf(quote, next + 1);
if (~next) {
escapePos = next;
while (value.charCodeAt(escapePos - 1) === backslash) {
escapePos -= 1;
escape = !escape;
}
} else {
value += quote;
next = value.length - 1;
token.unclosed = true;
}
} while (escape);
token.value = value.slice(pos + 1, next);
token.sourceEndIndex = token.unclosed ? next : next + 1;
tokens.push(token);
pos = next + 1;
code = value.charCodeAt(pos);
// Comments
} else if (code === slash && value.charCodeAt(pos + 1) === star) {
next = value.indexOf("*/", pos);
token = {
type: "comment",
sourceIndex: pos,
sourceEndIndex: next + 2
};
if (next === -1) {
token.unclosed = true;
next = value.length;
token.sourceEndIndex = next;
}
token.value = value.slice(pos + 2, next);
tokens.push(token);
pos = next + 2;
code = value.charCodeAt(pos);
// Operation within calc
} else if (
(code === slash || code === star) &&
parent &&
parent.type === "function" &&
parent.value === "calc"
) {
token = value[pos];
tokens.push({
type: "word",
sourceIndex: pos - before.length,
sourceEndIndex: pos + token.length,
value: token
});
pos += 1;
code = value.charCodeAt(pos);
// Dividers
} else if (code === slash || code === comma || code === colon) {
token = value[pos];
tokens.push({
type: "div",
sourceIndex: pos - before.length,
sourceEndIndex: pos + token.length,
value: token,
before: before,
after: ""
});
before = "";
pos += 1;
code = value.charCodeAt(pos);
// Open parentheses
} else if (openParentheses === code) {
// Whitespaces after open parentheses
next = pos;
do {
next += 1;
code = value.charCodeAt(next);
} while (code <= 32);
parenthesesOpenPos = pos;
token = {
type: "function",
sourceIndex: pos - name.length,
value: name,
before: value.slice(parenthesesOpenPos + 1, next)
};
pos = next;
if (name === "url" && code !== singleQuote && code !== doubleQuote) {
next -= 1;
do {
escape = false;
next = value.indexOf(")", next + 1);
if (~next) {
escapePos = next;
while (value.charCodeAt(escapePos - 1) === backslash) {
escapePos -= 1;
escape = !escape;
}
} else {
value += ")";
next = value.length - 1;
token.unclosed = true;
}
} while (escape);
// Whitespaces before closed
whitespacePos = next;
do {
whitespacePos -= 1;
code = value.charCodeAt(whitespacePos);
} while (code <= 32);
if (parenthesesOpenPos < whitespacePos) {
if (pos !== whitespacePos + 1) {
token.nodes = [
{
type: "word",
sourceIndex: pos,
sourceEndIndex: whitespacePos + 1,
value: value.slice(pos, whitespacePos + 1)
}
];
} else {
token.nodes = [];
}
if (token.unclosed && whitespacePos + 1 !== next) {
token.after = "";
token.nodes.push({
type: "space",
sourceIndex: whitespacePos + 1,
sourceEndIndex: next,
value: value.slice(whitespacePos + 1, next)
});
} else {
token.after = value.slice(whitespacePos + 1, next);
token.sourceEndIndex = next;
}
} else {
token.after = "";
token.nodes = [];
}
pos = next + 1;
token.sourceEndIndex = token.unclosed ? next : pos;
code = value.charCodeAt(pos);
tokens.push(token);
} else {
balanced += 1;
token.after = "";
token.sourceEndIndex = pos + 1;
tokens.push(token);
stack.push(token);
tokens = token.nodes = [];
parent = token;
}
name = "";
// Close parentheses
} else if (closeParentheses === code && balanced) {
pos += 1;
code = value.charCodeAt(pos);
parent.after = after;
parent.sourceEndIndex += after.length;
after = "";
balanced -= 1;
stack[stack.length - 1].sourceEndIndex = pos;
stack.pop();
parent = stack[balanced];
tokens = parent.nodes;
// Words
} else {
next = pos;
do {
if (code === backslash) {
next += 1;
}
next += 1;
code = value.charCodeAt(next);
} while (
next < max &&
!(
code <= 32 ||
code === singleQuote ||
code === doubleQuote ||
code === comma ||
code === colon ||
code === slash ||
code === openParentheses ||
(code === star &&
parent &&
parent.type === "function" &&
parent.value === "calc") ||
(code === slash &&
parent.type === "function" &&
parent.value === "calc") ||
(code === closeParentheses && balanced)
)
);
token = value.slice(pos, next);
if (openParentheses === code) {
name = token;
} else if (
(uLower === token.charCodeAt(0) || uUpper === token.charCodeAt(0)) &&
plus === token.charCodeAt(1) &&
isUnicodeRange.test(token.slice(2))
) {
tokens.push({
type: "unicode-range",
sourceIndex: pos,
sourceEndIndex: next,
value: token
});
} else {
tokens.push({
type: "word",
sourceIndex: pos,
sourceEndIndex: next,
value: token
});
}
pos = next;
}
}
for (pos = stack.length - 1; pos; pos -= 1) {
stack[pos].unclosed = true;
stack[pos].sourceEndIndex = value.length;
}
return stack[0].nodes;
};

View file

@ -0,0 +1,48 @@
function stringifyNode(node, custom) {
var type = node.type;
var value = node.value;
var buf;
var customResult;
if (custom && (customResult = custom(node)) !== undefined) {
return customResult;
} else if (type === "word" || type === "space") {
return value;
} else if (type === "string") {
buf = node.quote || "";
return buf + value + (node.unclosed ? "" : buf);
} else if (type === "comment") {
return "/*" + value + (node.unclosed ? "" : "*/");
} else if (type === "div") {
return (node.before || "") + value + (node.after || "");
} else if (Array.isArray(node.nodes)) {
buf = stringify(node.nodes, custom);
if (type !== "function") {
return buf;
}
return (
value +
"(" +
(node.before || "") +
buf +
(node.after || "") +
(node.unclosed ? "" : ")")
);
}
return value;
}
function stringify(nodes, custom) {
var result, i;
if (Array.isArray(nodes)) {
result = "";
for (i = nodes.length - 1; ~i; i -= 1) {
result = stringifyNode(nodes[i], custom) + result;
}
return result;
}
return stringifyNode(nodes, custom);
}
module.exports = stringify;

View file

@ -0,0 +1,120 @@
var minus = "-".charCodeAt(0);
var plus = "+".charCodeAt(0);
var dot = ".".charCodeAt(0);
var exp = "e".charCodeAt(0);
var EXP = "E".charCodeAt(0);
// Check if three code points would start a number
// https://www.w3.org/TR/css-syntax-3/#starts-with-a-number
function likeNumber(value) {
var code = value.charCodeAt(0);
var nextCode;
if (code === plus || code === minus) {
nextCode = value.charCodeAt(1);
if (nextCode >= 48 && nextCode <= 57) {
return true;
}
var nextNextCode = value.charCodeAt(2);
if (nextCode === dot && nextNextCode >= 48 && nextNextCode <= 57) {
return true;
}
return false;
}
if (code === dot) {
nextCode = value.charCodeAt(1);
if (nextCode >= 48 && nextCode <= 57) {
return true;
}
return false;
}
if (code >= 48 && code <= 57) {
return true;
}
return false;
}
// Consume a number
// https://www.w3.org/TR/css-syntax-3/#consume-number
module.exports = function(value) {
var pos = 0;
var length = value.length;
var code;
var nextCode;
var nextNextCode;
if (length === 0 || !likeNumber(value)) {
return false;
}
code = value.charCodeAt(pos);
if (code === plus || code === minus) {
pos++;
}
while (pos < length) {
code = value.charCodeAt(pos);
if (code < 48 || code > 57) {
break;
}
pos += 1;
}
code = value.charCodeAt(pos);
nextCode = value.charCodeAt(pos + 1);
if (code === dot && nextCode >= 48 && nextCode <= 57) {
pos += 2;
while (pos < length) {
code = value.charCodeAt(pos);
if (code < 48 || code > 57) {
break;
}
pos += 1;
}
}
code = value.charCodeAt(pos);
nextCode = value.charCodeAt(pos + 1);
nextNextCode = value.charCodeAt(pos + 2);
if (
(code === exp || code === EXP) &&
((nextCode >= 48 && nextCode <= 57) ||
((nextCode === plus || nextCode === minus) &&
nextNextCode >= 48 &&
nextNextCode <= 57))
) {
pos += nextCode === plus || nextCode === minus ? 3 : 2;
while (pos < length) {
code = value.charCodeAt(pos);
if (code < 48 || code > 57) {
break;
}
pos += 1;
}
}
return {
number: value.slice(0, pos),
unit: value.slice(pos)
};
};

View file

@ -0,0 +1,22 @@
module.exports = function walk(nodes, cb, bubble) {
var i, max, node, result;
for (i = 0, max = nodes.length; i < max; i += 1) {
node = nodes[i];
if (!bubble) {
result = cb(node, i, nodes);
}
if (
result !== false &&
node.type === "function" &&
Array.isArray(node.nodes)
) {
walk(node.nodes, cb, bubble);
}
if (bubble) {
cb(node, i, nodes);
}
}
};

View file

@ -0,0 +1,58 @@
{
"name": "postcss-value-parser",
"version": "4.2.0",
"description": "Transforms css values and at-rule params into the tree",
"main": "lib/index.js",
"files": [
"lib"
],
"devDependencies": {
"eslint": "^5.16.0",
"husky": "^2.3.0",
"lint-staged": "^8.1.7",
"prettier": "^1.17.1",
"tap-spec": "^5.0.0",
"tape": "^4.10.2"
},
"scripts": {
"lint:prettier": "prettier \"**/*.js\" \"**/*.ts\" --list-different",
"lint:js": "eslint . --cache",
"lint": "yarn lint:js && yarn lint:prettier",
"pretest": "yarn lint",
"test": "tape test/*.js | tap-spec"
},
"eslintConfig": {
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended"
},
"lint-staged": {
"*.js": [
"eslint",
"prettier --write",
"git add"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"author": "Bogdan Chadkin <trysound@yandex.ru>",
"license": "MIT",
"homepage": "https://github.com/TrySound/postcss-value-parser",
"repository": {
"type": "git",
"url": "https://github.com/TrySound/postcss-value-parser.git"
},
"keywords": [
"postcss",
"value",
"parser"
],
"bugs": {
"url": "https://github.com/TrySound/postcss-value-parser/issues"
}
}

61
BACK_BACK/node_modules/postcss-calc/package.json generated vendored Executable file
View file

@ -0,0 +1,61 @@
{
"name": "postcss-calc",
"version": "7.0.5",
"description": "PostCSS plugin to reduce calc()",
"keywords": [
"css",
"postcss",
"postcss-plugin",
"calculation",
"calc"
],
"main": "dist/index.js",
"files": [
"dist",
"LICENSE"
],
"scripts": {
"prepublish": "npm run build",
"build": "del-cli dist && cross-env BABEL_ENV=publish babel src --out-dir dist --ignore src/__tests__/**/*.js && jison src/parser.jison -o dist/parser.js",
"pretest": "npm run build && eslint src",
"test": "ava"
},
"author": "Andy Jansson",
"license": "MIT",
"repository": "https://github.com/postcss/postcss-calc.git",
"eslintConfig": {
"parser": "babel-eslint",
"extends": "eslint-config-i-am-meticulous",
"rules": {
"curly": "error"
}
},
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/register": "^7.0.0",
"ava": "^1.4.1",
"babel-eslint": "^10.0.1",
"babel-plugin-add-module-exports": "^1.0.0",
"cross-env": "^5.2.0",
"del-cli": "^1.1.0",
"eslint": "^5.7.0",
"eslint-config-i-am-meticulous": "^11.0.0",
"eslint-plugin-babel": "^5.2.1",
"eslint-plugin-import": "^2.14.0",
"jison-gho": "^0.6.1-215"
},
"dependencies": {
"postcss": "^7.0.27",
"postcss-selector-parser": "^6.0.2",
"postcss-value-parser": "^4.0.2"
},
"ava": {
"require": [
"@babel/register",
"@babel/polyfill"
]
}
}