first commit
This commit is contained in:
22
app_vue/node_modules/postcss-normalize-positions/LICENSE-MIT
generated
vendored
Normal file
22
app_vue/node_modules/postcss-normalize-positions/LICENSE-MIT
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
Copyright (c) Ben Briggs <beneb.info@gmail.com> (http://beneb.info)
|
||||
|
||||
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.
|
44
app_vue/node_modules/postcss-normalize-positions/README.md
generated
vendored
Normal file
44
app_vue/node_modules/postcss-normalize-positions/README.md
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
# [postcss][postcss]-normalize-positions
|
||||
|
||||
> Normalize positions with PostCSS.
|
||||
|
||||
## Install
|
||||
|
||||
With [npm](https://npmjs.org/package/postcss-normalize-positions) do:
|
||||
|
||||
```
|
||||
npm install postcss-normalize-positions --save
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
### Input
|
||||
|
||||
```css
|
||||
div {
|
||||
background-position: bottom left;
|
||||
}
|
||||
```
|
||||
|
||||
### Output
|
||||
|
||||
```css
|
||||
div {
|
||||
background-position:0 100%;
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
|
||||
examples for your environment.
|
||||
|
||||
## Contributors
|
||||
|
||||
See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Ben Briggs](http://beneb.info)
|
||||
|
||||
[postcss]: https://github.com/postcss/postcss
|
40
app_vue/node_modules/postcss-normalize-positions/package.json
generated
vendored
Normal file
40
app_vue/node_modules/postcss-normalize-positions/package.json
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "postcss-normalize-positions",
|
||||
"version": "5.1.1",
|
||||
"description": "Normalize keyword values for position into length values.",
|
||||
"main": "src/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"files": [
|
||||
"src",
|
||||
"LICENSE-MIT",
|
||||
"types"
|
||||
],
|
||||
"keywords": [
|
||||
"css",
|
||||
"postcss",
|
||||
"postcss-plugin"
|
||||
],
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/cssnano/cssnano",
|
||||
"author": {
|
||||
"name": "Ben Briggs",
|
||||
"email": "beneb.info@gmail.com",
|
||||
"url": "http://beneb.info"
|
||||
},
|
||||
"repository": "cssnano/cssnano",
|
||||
"dependencies": {
|
||||
"postcss-value-parser": "^4.2.0"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/cssnano/cssnano/issues"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || >=14.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"postcss": "^8.2.15"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"postcss": "^8.2.15"
|
||||
}
|
||||
}
|
248
app_vue/node_modules/postcss-normalize-positions/src/index.js
generated
vendored
Normal file
248
app_vue/node_modules/postcss-normalize-positions/src/index.js
generated
vendored
Normal file
@ -0,0 +1,248 @@
|
||||
'use strict';
|
||||
const valueParser = require('postcss-value-parser');
|
||||
|
||||
const directionKeywords = new Set(['top', 'right', 'bottom', 'left', 'center']);
|
||||
|
||||
const center = '50%';
|
||||
const horizontal = new Map([
|
||||
['right', '100%'],
|
||||
['left', '0'],
|
||||
]);
|
||||
const verticalValue = new Map([
|
||||
['bottom', '100%'],
|
||||
['top', '0'],
|
||||
]);
|
||||
const mathFunctions = new Set(['calc', 'min', 'max', 'clamp']);
|
||||
const variableFunctions = new Set(['var', 'env', 'constant']);
|
||||
/**
|
||||
* @param {valueParser.Node} node
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isCommaNode(node) {
|
||||
return node.type === 'div' && node.value === ',';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {valueParser.Node} node
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isVariableFunctionNode(node) {
|
||||
if (node.type !== 'function') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return variableFunctions.has(node.value.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {valueParser.Node} node
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isMathFunctionNode(node) {
|
||||
if (node.type !== 'function') {
|
||||
return false;
|
||||
}
|
||||
return mathFunctions.has(node.value.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {valueParser.Node} node
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isNumberNode(node) {
|
||||
if (node.type !== 'word') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const value = parseFloat(node.value);
|
||||
|
||||
return !isNaN(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {valueParser.Node} node
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isDimensionNode(node) {
|
||||
if (node.type !== 'word') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const parsed = valueParser.unit(node.value);
|
||||
|
||||
if (!parsed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return parsed.unit !== '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {string}
|
||||
*/
|
||||
function transform(value) {
|
||||
const parsed = valueParser(value);
|
||||
/** @type {({start: number, end: number} | {start: null, end: null})[]} */
|
||||
const ranges = [];
|
||||
let rangeIndex = 0;
|
||||
let shouldContinue = true;
|
||||
|
||||
parsed.nodes.forEach((node, index) => {
|
||||
// After comma (`,`) follows next background
|
||||
if (isCommaNode(node)) {
|
||||
rangeIndex += 1;
|
||||
shouldContinue = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!shouldContinue) {
|
||||
return;
|
||||
}
|
||||
|
||||
// After separator (`/`) follows `background-size` values
|
||||
// Avoid them
|
||||
if (node.type === 'div' && node.value === '/') {
|
||||
shouldContinue = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ranges[rangeIndex]) {
|
||||
ranges[rangeIndex] = {
|
||||
start: null,
|
||||
end: null,
|
||||
};
|
||||
}
|
||||
|
||||
// Do not try to be processed `var and `env` function inside background
|
||||
if (isVariableFunctionNode(node)) {
|
||||
shouldContinue = false;
|
||||
ranges[rangeIndex].start = null;
|
||||
ranges[rangeIndex].end = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const isPositionKeyword =
|
||||
(node.type === 'word' &&
|
||||
directionKeywords.has(node.value.toLowerCase())) ||
|
||||
isDimensionNode(node) ||
|
||||
isNumberNode(node) ||
|
||||
isMathFunctionNode(node);
|
||||
|
||||
if (ranges[rangeIndex].start === null && isPositionKeyword) {
|
||||
ranges[rangeIndex].start = index;
|
||||
ranges[rangeIndex].end = index;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ranges[rangeIndex].start !== null) {
|
||||
if (node.type === 'space') {
|
||||
return;
|
||||
} else if (isPositionKeyword) {
|
||||
ranges[rangeIndex].end = index;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
ranges.forEach((range) => {
|
||||
if (range.start === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nodes = parsed.nodes.slice(range.start, range.end + 1);
|
||||
|
||||
if (nodes.length > 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
const firstNode = nodes[0].value.toLowerCase();
|
||||
const secondNode =
|
||||
nodes[2] && nodes[2].value ? nodes[2].value.toLowerCase() : null;
|
||||
|
||||
if (nodes.length === 1 || secondNode === 'center') {
|
||||
if (secondNode) {
|
||||
nodes[2].value = nodes[1].value = '';
|
||||
}
|
||||
|
||||
const map = new Map([...horizontal, ['center', center]]);
|
||||
|
||||
if (map.has(firstNode)) {
|
||||
nodes[0].value = /** @type {string}*/ (map.get(firstNode));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (secondNode !== null) {
|
||||
if (firstNode === 'center' && directionKeywords.has(secondNode)) {
|
||||
nodes[0].value = nodes[1].value = '';
|
||||
|
||||
if (horizontal.has(secondNode)) {
|
||||
nodes[2].value = /** @type {string} */ (horizontal.get(secondNode));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (horizontal.has(firstNode) && verticalValue.has(secondNode)) {
|
||||
nodes[0].value = /** @type {string} */ (horizontal.get(firstNode));
|
||||
nodes[2].value = /** @type {string} */ (verticalValue.get(secondNode));
|
||||
|
||||
return;
|
||||
} else if (verticalValue.has(firstNode) && horizontal.has(secondNode)) {
|
||||
nodes[0].value = /** @type {string} */ (horizontal.get(secondNode));
|
||||
nodes[2].value = /** @type {string} */ (verticalValue.get(firstNode));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return parsed.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {import('postcss').PluginCreator<void>}
|
||||
* @return {import('postcss').Plugin}
|
||||
*/
|
||||
function pluginCreator() {
|
||||
return {
|
||||
postcssPlugin: 'postcss-normalize-positions',
|
||||
|
||||
OnceExit(css) {
|
||||
const cache = new Map();
|
||||
|
||||
css.walkDecls(
|
||||
/^(background(-position)?|(-\w+-)?perspective-origin)$/i,
|
||||
(decl) => {
|
||||
const value = decl.value;
|
||||
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cache.has(value)) {
|
||||
decl.value = cache.get(value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const result = transform(value);
|
||||
|
||||
decl.value = result;
|
||||
cache.set(value, result);
|
||||
}
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
pluginCreator.postcss = true;
|
||||
module.exports = pluginCreator;
|
9
app_vue/node_modules/postcss-normalize-positions/types/index.d.ts
generated
vendored
Normal file
9
app_vue/node_modules/postcss-normalize-positions/types/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
export = pluginCreator;
|
||||
/**
|
||||
* @type {import('postcss').PluginCreator<void>}
|
||||
* @return {import('postcss').Plugin}
|
||||
*/
|
||||
declare function pluginCreator(): import('postcss').Plugin;
|
||||
declare namespace pluginCreator {
|
||||
const postcss: true;
|
||||
}
|
Reference in New Issue
Block a user