Jesus sucks
This commit is contained in:
85
backend/frontend/node_modules/postcss-custom-selectors/CHANGELOG.md
generated
vendored
Normal file
85
backend/frontend/node_modules/postcss-custom-selectors/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
# Changes to PostCSS Custom Selectors
|
||||
|
||||
### 5.1.2 (September 20, 2018)
|
||||
|
||||
- Fixed: Do not break on an empty `importFrom` object
|
||||
|
||||
### 5.1.1 (September 18, 2018)
|
||||
|
||||
- Fixed: Selectors like `.foo:--h1` become `h1.foo` instead of `.fooh1`
|
||||
|
||||
### 5.1.0 (September 12, 2018)
|
||||
|
||||
- Added: New `exportTo` function to specify where to export custom selectors
|
||||
- Updated: `importFrom` option to support passing it a function
|
||||
|
||||
### 5.0.0 (September 7, 2018)
|
||||
|
||||
- Added: New `preserve` option to preserve custom selectors and rules using them
|
||||
- Added: New `importFrom` option to specify where to import custom selectors
|
||||
- Added: Support for PostCSS v7
|
||||
- Added: Support for Node v6+
|
||||
|
||||
### 4.0.1 (May 15, 2017)
|
||||
|
||||
- Fixed: incorrect export
|
||||
|
||||
### 4.0.0 (May 12, 2017)
|
||||
|
||||
- Added: compatibility with postcss v6.x
|
||||
|
||||
### 3.0.0 (August 25, 2015)
|
||||
|
||||
- Removed: compatibility with postcss v4.x
|
||||
- Added: compatibility with postcss v5.x
|
||||
|
||||
### 2.3.0 (July 14, 2015)
|
||||
|
||||
* Fixed: Nested/mixed selectors now works correctly
|
||||
([#19](https://github.com/postcss/postcss-custom-selectors/issues/19))
|
||||
* Added: `transformMatches` option to limit transformation to :matches()
|
||||
replacements.
|
||||
|
||||
### 2.2.0 (June 30, 2015)
|
||||
|
||||
* Fixed: No more useless warnings for undefined non custom selectors
|
||||
([#22](https://github.com/postcss/postcss-custom-selectors/issues/22))
|
||||
* Changed: warnings now use PostCSS message API
|
||||
|
||||
### 2.1.1 (June 30, 2015)
|
||||
|
||||
* Fixed: the lineBreak option keeping the selectors indent
|
||||
([#18](https://github.com/postcss/postcss-custom-selectors/issues/18))
|
||||
* Fixed: the tip of an undefined selector
|
||||
([#20](https://github.com/postcss/postcss-custom-selectors/issues/20))
|
||||
|
||||
### 2.1.0 (June 4, 2015)
|
||||
|
||||
* Changed: use PostCSS 4.1 plugin API
|
||||
([#13](https://github.com/postcss/postcss-custom-selectors/issues/13))
|
||||
|
||||
### 2.0.1 (June 3, 2015)
|
||||
|
||||
* Fixed: `(foo, bar)` conversion error exists in the selector
|
||||
(See also [:matches() test](test/fixtures/matches/input.css))
|
||||
|
||||
### 2.0.0 (May 29, 2015)
|
||||
|
||||
* Removed: no longer support `::` or `--` to defined a custom selectors,
|
||||
you must use the syntax `:--` to define it.
|
||||
([#6](https://github.com/postcss/postcss-custom-selectors/issues/6))
|
||||
* Fixed: two or more consecutive hyphens in selector don't output `undefined`
|
||||
([#14](https://github.com/postcss/postcss-custom-selectors/issues/14))
|
||||
|
||||
|
||||
### 1.1.1 (April 6, 2015)
|
||||
|
||||
* Fixed: add support for multilines definition
|
||||
|
||||
### 1.1.0 (December 6, 2014)
|
||||
|
||||
* Added: "lineBreak" option
|
||||
|
||||
### 1.0.0 (December 6, 2014)
|
||||
|
||||
* First release
|
||||
21
backend/frontend/node_modules/postcss-custom-selectors/LICENSE.md
generated
vendored
Normal file
21
backend/frontend/node_modules/postcss-custom-selectors/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# The MIT License (MIT)
|
||||
|
||||
Copyright © PostCSS
|
||||
|
||||
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.
|
||||
166
backend/frontend/node_modules/postcss-custom-selectors/README.md
generated
vendored
Normal file
166
backend/frontend/node_modules/postcss-custom-selectors/README.md
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
# PostCSS Custom Selectors [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" width="90" height="90" align="right">][postcss]
|
||||
|
||||
[![NPM Version][npm-img]][npm-url]
|
||||
[![CSS Standard Status][css-img]][css-url]
|
||||
[![Build Status][cli-img]][cli-url]
|
||||
[![Support Chat][git-img]][git-url]
|
||||
|
||||
[PostCSS Custom Selectors] lets you use Custom Selectors in CSS, following the
|
||||
[CSS Extensions] specification.
|
||||
|
||||
```pcss
|
||||
@custom-selector :--heading h1, h2, h3;
|
||||
|
||||
article :--heading + p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* becomes */
|
||||
|
||||
article h1 + p, article h2 + p, article h3 + p {}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Add [PostCSS Custom Selectors] to your project:
|
||||
|
||||
```bash
|
||||
npm install postcss-custom-selectors --save-dev
|
||||
```
|
||||
|
||||
Use [PostCSS Custom Selectors] to process your CSS:
|
||||
|
||||
```js
|
||||
const postcssCustomSelectors = require('postcss-custom-selectors');
|
||||
|
||||
postcssCustomSelectors.process(YOUR_CSS /*, processOptions, pluginOptions */);
|
||||
```
|
||||
|
||||
Or use it as a [PostCSS] plugin:
|
||||
|
||||
```js
|
||||
const postcss = require('postcss');
|
||||
const postcssCustomSelectors = require('postcss-custom-selectors');
|
||||
|
||||
postcss([
|
||||
postcssCustomSelectors(/* pluginOptions */)
|
||||
]).process(YOUR_CSS /*, processOptions */);
|
||||
```
|
||||
|
||||
[PostCSS Custom Selectors] runs in all Node environments, with special instructions for:
|
||||
|
||||
| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
|
||||
## Options
|
||||
|
||||
### preserve
|
||||
|
||||
The `preserve` option determines whether custom selectors and rules using
|
||||
custom selectors should be preserved in their original form.
|
||||
|
||||
```pcss
|
||||
@custom-selector :--heading h1, h2, h3;
|
||||
|
||||
article :--heading + p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* becomes */
|
||||
|
||||
article h1 + p, article h2 + p, article h3 + p {}
|
||||
|
||||
article :--heading + p {}
|
||||
```
|
||||
|
||||
### importFrom
|
||||
|
||||
The `importFrom` option specifies sources where custom selectors can be
|
||||
imported from, which might be CSS, JS, and JSON files, functions, and directly
|
||||
passed objects.
|
||||
|
||||
```js
|
||||
postcssCustomSelectors({
|
||||
importFrom: 'path/to/file.css' // => @custom-selector :--heading h1, h2, h3;
|
||||
});
|
||||
```
|
||||
|
||||
```pcss
|
||||
article :--heading + p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* becomes */
|
||||
|
||||
article h1 + p, article h2 + p, article h3 + p {}
|
||||
```
|
||||
|
||||
Multiple sources can be passed into this option, and they will be parsed in the
|
||||
order they are received. JavaScript files, JSON files, functions, and objects
|
||||
will need to namespace custom selectors using the `customProperties` or
|
||||
`custom-properties` key.
|
||||
|
||||
```js
|
||||
postcssCustomSelectors({
|
||||
importFrom: [
|
||||
'path/to/file.css',
|
||||
'and/then/this.js',
|
||||
'and/then/that.json',
|
||||
{
|
||||
customSelectors: { ':--heading': 'h1, h2, h3' }
|
||||
},
|
||||
() => {
|
||||
const customProperties = { ':--heading': 'h1, h2, h3' };
|
||||
|
||||
return { customProperties };
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
### exportTo
|
||||
|
||||
The `exportTo` option specifies destinations where custom selectors can be
|
||||
exported to, which might be CSS, JS, and JSON files, functions, and directly
|
||||
passed objects.
|
||||
|
||||
```js
|
||||
postcssCustomSelectors({
|
||||
exportTo: 'path/to/file.css' // @custom-selector :--heading h1, h2, h3;
|
||||
});
|
||||
```
|
||||
|
||||
Multiple destinations can be passed into this option, and they will be parsed
|
||||
in the order they are received. JavaScript files, JSON files, and objects will
|
||||
need to namespace custom selectors using the `customProperties` or
|
||||
`custom-properties` key.
|
||||
|
||||
```js
|
||||
const cachedObject = { customSelectors: {} };
|
||||
|
||||
postcssCustomSelectors({
|
||||
exportTo: [
|
||||
'path/to/file.css', // @custom-selector :--heading h1, h2, h3;
|
||||
'and/then/this.js', // module.exports = { customSelectors: { ':--heading': 'h1, h2, h3' } }
|
||||
'and/then/this.mjs', // export const customSelectors = { ':--heading': 'h1, h2, h3' } }
|
||||
'and/then/that.json', // { "custom-selectors": { ":--heading": "h1, h2, h3" } }
|
||||
cachedObject,
|
||||
customProperties => {
|
||||
customProperties // { ':--heading': 'h1, h2, h3' }
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
[cli-img]: https://img.shields.io/travis/postcss/postcss-custom-selectors.svg
|
||||
[cli-url]: https://travis-ci.org/postcss/postcss-custom-selectors
|
||||
[css-img]: https://cssdb.org/badge/custom-selectors.svg
|
||||
[css-url]: https://cssdb.org/#custom-selectors
|
||||
[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-custom-selectors.svg
|
||||
[npm-url]: https://www.npmjs.com/package/postcss-custom-selectors
|
||||
|
||||
[CSS Extensions]: https://drafts.csswg.org/css-extensions/#custom-selectors
|
||||
[PostCSS]: https://github.com/postcss/postcss
|
||||
[PostCSS Custom Selectors]: https://github.com/postcss/postcss-custom-selectors
|
||||
614
backend/frontend/node_modules/postcss-custom-selectors/index.cjs.js
generated
vendored
Normal file
614
backend/frontend/node_modules/postcss-custom-selectors/index.cjs.js
generated
vendored
Normal file
@@ -0,0 +1,614 @@
|
||||
'use strict';
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var parser = _interopDefault(require('postcss-selector-parser'));
|
||||
var fs = _interopDefault(require('fs'));
|
||||
var path = _interopDefault(require('path'));
|
||||
var postcss = _interopDefault(require('postcss'));
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
||||
try {
|
||||
var info = gen[key](arg);
|
||||
var value = info.value;
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (info.done) {
|
||||
resolve(value);
|
||||
} else {
|
||||
Promise.resolve(value).then(_next, _throw);
|
||||
}
|
||||
}
|
||||
|
||||
function _asyncToGenerator(fn) {
|
||||
return function () {
|
||||
var self = this,
|
||||
args = arguments;
|
||||
return new Promise(function (resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
||||
}
|
||||
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
||||
}
|
||||
|
||||
_next(undefined);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
var ownKeys = Object.keys(source);
|
||||
|
||||
if (typeof Object.getOwnPropertySymbols === 'function') {
|
||||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
|
||||
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
||||
}));
|
||||
}
|
||||
|
||||
ownKeys.forEach(function (key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
function _slicedToArray(arr, i) {
|
||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
|
||||
try {
|
||||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
||||
_arr.push(_s.value);
|
||||
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i["return"] != null) _i["return"]();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}
|
||||
|
||||
/* Return a Selectors AST from a Selectors String
|
||||
/* ========================================================================== */
|
||||
|
||||
var getSelectorsAstFromSelectorsString = (selectorString => {
|
||||
let selectorAST;
|
||||
parser(selectors => {
|
||||
selectorAST = selectors;
|
||||
}).processSync(selectorString);
|
||||
return selectorAST;
|
||||
});
|
||||
|
||||
var getCustomSelectors = ((root, opts) => {
|
||||
// initialize custom selectors
|
||||
const customSelectors = {}; // for each custom selector atrule that is a child of the css root
|
||||
|
||||
root.nodes.slice().forEach(node => {
|
||||
if (isCustomSelector(node)) {
|
||||
// extract the name and selectors from the params of the custom selector
|
||||
const _node$params$match = node.params.match(customSelectorParamsRegExp),
|
||||
_node$params$match2 = _slicedToArray(_node$params$match, 3),
|
||||
name = _node$params$match2[1],
|
||||
selectors = _node$params$match2[2]; // write the parsed selectors to the custom selector
|
||||
|
||||
|
||||
customSelectors[name] = getSelectorsAstFromSelectorsString(selectors); // conditionally remove the custom selector atrule
|
||||
|
||||
if (!Object(opts).preserve) {
|
||||
node.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
return customSelectors;
|
||||
}); // match the custom selector name
|
||||
|
||||
const customSelectorNameRegExp = /^custom-selector$/i; // match the custom selector params
|
||||
|
||||
const customSelectorParamsRegExp = /^(:--[A-z][\w-]*)\s+([\W\w]+)\s*$/; // whether the atrule is a custom selector
|
||||
|
||||
const isCustomSelector = node => node.type === 'atrule' && customSelectorNameRegExp.test(node.name) && customSelectorParamsRegExp.test(node.params);
|
||||
|
||||
// return transformed selectors, replacing custom pseudo selectors with custom selectors
|
||||
function transformSelectorList(selectorList, customSelectors) {
|
||||
let index = selectorList.nodes.length - 1;
|
||||
|
||||
while (index >= 0) {
|
||||
const transformedSelectors = transformSelector(selectorList.nodes[index], customSelectors);
|
||||
|
||||
if (transformedSelectors.length) {
|
||||
selectorList.nodes.splice(index, 1, ...transformedSelectors);
|
||||
}
|
||||
|
||||
--index;
|
||||
}
|
||||
|
||||
return selectorList;
|
||||
} // return custom pseudo selectors replaced with custom selectors
|
||||
|
||||
function transformSelector(selector, customSelectors) {
|
||||
const transpiledSelectors = [];
|
||||
|
||||
for (const index in selector.nodes) {
|
||||
const _selector$nodes$index = selector.nodes[index],
|
||||
value = _selector$nodes$index.value,
|
||||
nodes = _selector$nodes$index.nodes;
|
||||
|
||||
if (value in customSelectors) {
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = customSelectors[value].nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
const replacementSelector = _step.value;
|
||||
const selectorClone = selector.clone();
|
||||
selectorClone.nodes.splice(index, 1, ...replacementSelector.clone().nodes.map(node => {
|
||||
// use spacing from the current usage
|
||||
node.spaces = _objectSpread({}, selector.nodes[index].spaces);
|
||||
return node;
|
||||
}));
|
||||
const retranspiledSelectors = transformSelector(selectorClone, customSelectors);
|
||||
adjustNodesBySelectorEnds(selectorClone.nodes, Number(index));
|
||||
|
||||
if (retranspiledSelectors.length) {
|
||||
transpiledSelectors.push(...retranspiledSelectors);
|
||||
} else {
|
||||
transpiledSelectors.push(selectorClone);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return transpiledSelectors;
|
||||
} else if (nodes && nodes.length) {
|
||||
transformSelectorList(selector.nodes[index], customSelectors);
|
||||
}
|
||||
}
|
||||
|
||||
return transpiledSelectors;
|
||||
} // match selectors by difficult-to-separate ends
|
||||
|
||||
|
||||
const withoutSelectorStartMatch = /^(tag|universal)$/;
|
||||
const withoutSelectorEndMatch = /^(class|id|pseudo|tag|universal)$/;
|
||||
|
||||
const isWithoutSelectorStart = node => withoutSelectorStartMatch.test(Object(node).type);
|
||||
|
||||
const isWithoutSelectorEnd = node => withoutSelectorEndMatch.test(Object(node).type); // adjust nodes by selector ends (so that .class:--h1 becomes h1.class rather than .classh1)
|
||||
|
||||
|
||||
const adjustNodesBySelectorEnds = (nodes, index) => {
|
||||
if (index && isWithoutSelectorStart(nodes[index]) && isWithoutSelectorEnd(nodes[index - 1])) {
|
||||
let safeIndex = index - 1;
|
||||
|
||||
while (safeIndex && isWithoutSelectorEnd(nodes[safeIndex])) {
|
||||
--safeIndex;
|
||||
}
|
||||
|
||||
if (safeIndex < index) {
|
||||
const node = nodes.splice(index, 1)[0];
|
||||
nodes.splice(safeIndex, 0, node);
|
||||
nodes[safeIndex].spaces.before = nodes[safeIndex + 1].spaces.before;
|
||||
nodes[safeIndex + 1].spaces.before = '';
|
||||
|
||||
if (nodes[index]) {
|
||||
nodes[index].spaces.after = nodes[safeIndex].spaces.after;
|
||||
nodes[safeIndex].spaces.after = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var transformRules = ((root, customSelectors, opts) => {
|
||||
root.walkRules(customPseudoRegExp, rule => {
|
||||
const selector = parser(selectors => {
|
||||
transformSelectorList(selectors, customSelectors, opts);
|
||||
}).processSync(rule.selector);
|
||||
|
||||
if (opts.preserve) {
|
||||
rule.cloneBefore({
|
||||
selector
|
||||
});
|
||||
} else {
|
||||
rule.selector = selector;
|
||||
}
|
||||
});
|
||||
});
|
||||
const customPseudoRegExp = /:--[A-z][\w-]*/;
|
||||
|
||||
/* Import Custom Selectors from CSS AST
|
||||
/* ========================================================================== */
|
||||
|
||||
function importCustomSelectorsFromCSSAST(root) {
|
||||
return getCustomSelectors(root);
|
||||
}
|
||||
/* Import Custom Selectors from CSS File
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function importCustomSelectorsFromCSSFile(_x) {
|
||||
return _importCustomSelectorsFromCSSFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Selectors from Object
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _importCustomSelectorsFromCSSFile() {
|
||||
_importCustomSelectorsFromCSSFile = _asyncToGenerator(function* (from) {
|
||||
const css = yield readFile(path.resolve(from));
|
||||
const root = postcss.parse(css, {
|
||||
from: path.resolve(from)
|
||||
});
|
||||
return importCustomSelectorsFromCSSAST(root);
|
||||
});
|
||||
return _importCustomSelectorsFromCSSFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function importCustomSelectorsFromObject(object) {
|
||||
const customSelectors = Object.assign({}, Object(object).customSelectors || Object(object)['custom-selectors']);
|
||||
|
||||
for (const key in customSelectors) {
|
||||
customSelectors[key] = getSelectorsAstFromSelectorsString(customSelectors[key]);
|
||||
}
|
||||
|
||||
return customSelectors;
|
||||
}
|
||||
/* Import Custom Selectors from JSON file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function importCustomSelectorsFromJSONFile(_x2) {
|
||||
return _importCustomSelectorsFromJSONFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Selectors from JS file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _importCustomSelectorsFromJSONFile() {
|
||||
_importCustomSelectorsFromJSONFile = _asyncToGenerator(function* (from) {
|
||||
const object = yield readJSON(path.resolve(from));
|
||||
return importCustomSelectorsFromObject(object);
|
||||
});
|
||||
return _importCustomSelectorsFromJSONFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function importCustomSelectorsFromJSFile(_x3) {
|
||||
return _importCustomSelectorsFromJSFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Selectors from Sources
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _importCustomSelectorsFromJSFile() {
|
||||
_importCustomSelectorsFromJSFile = _asyncToGenerator(function* (from) {
|
||||
const object = yield Promise.resolve(require(path.resolve(from)));
|
||||
return importCustomSelectorsFromObject(object);
|
||||
});
|
||||
return _importCustomSelectorsFromJSFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function importCustomSelectorsFromSources(sources) {
|
||||
return sources.map(source => {
|
||||
if (source instanceof Promise) {
|
||||
return source;
|
||||
} else if (source instanceof Function) {
|
||||
return source();
|
||||
} // read the source as an object
|
||||
|
||||
|
||||
const opts = source === Object(source) ? source : {
|
||||
from: String(source)
|
||||
}; // skip objects with custom selectors
|
||||
|
||||
if (Object(opts).customSelectors || Object(opts)['custom-selectors']) {
|
||||
return opts;
|
||||
} // source pathname
|
||||
|
||||
|
||||
const from = String(opts.from || ''); // type of file being read from
|
||||
|
||||
const type = (opts.type || path.extname(from).slice(1)).toLowerCase();
|
||||
return {
|
||||
type,
|
||||
from
|
||||
};
|
||||
}).reduce(
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
var _ref = _asyncToGenerator(function* (customSelectors, source) {
|
||||
const _ref2 = yield source,
|
||||
type = _ref2.type,
|
||||
from = _ref2.from;
|
||||
|
||||
if (type === 'ast') {
|
||||
return Object.assign(customSelectors, importCustomSelectorsFromCSSAST(from));
|
||||
}
|
||||
|
||||
if (type === 'css') {
|
||||
return Object.assign(customSelectors, (yield importCustomSelectorsFromCSSFile(from)));
|
||||
}
|
||||
|
||||
if (type === 'js') {
|
||||
return Object.assign(customSelectors, (yield importCustomSelectorsFromJSFile(from)));
|
||||
}
|
||||
|
||||
if (type === 'json') {
|
||||
return Object.assign(customSelectors, (yield importCustomSelectorsFromJSONFile(from)));
|
||||
}
|
||||
|
||||
return Object.assign(customSelectors, importCustomSelectorsFromObject((yield source)));
|
||||
});
|
||||
|
||||
return function (_x4, _x5) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}(), {});
|
||||
}
|
||||
/* Helper utilities
|
||||
/* ========================================================================== */
|
||||
|
||||
const readFile = from => new Promise((resolve, reject) => {
|
||||
fs.readFile(from, 'utf8', (error, result) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const readJSON =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
var _ref3 = _asyncToGenerator(function* (from) {
|
||||
return JSON.parse((yield readFile(from)));
|
||||
});
|
||||
|
||||
return function readJSON(_x6) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
|
||||
/* Import Custom Selectors from CSS File
|
||||
/* ========================================================================== */
|
||||
|
||||
function exportCustomSelectorsToCssFile(_x, _x2) {
|
||||
return _exportCustomSelectorsToCssFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Selectors from JSON file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _exportCustomSelectorsToCssFile() {
|
||||
_exportCustomSelectorsToCssFile = _asyncToGenerator(function* (to, customSelectors) {
|
||||
const cssContent = Object.keys(customSelectors).reduce((cssLines, name) => {
|
||||
cssLines.push(`@custom-selector ${name} ${customSelectors[name]};`);
|
||||
return cssLines;
|
||||
}, []).join('\n');
|
||||
const css = `${cssContent}\n`;
|
||||
yield writeFile(to, css);
|
||||
});
|
||||
return _exportCustomSelectorsToCssFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function exportCustomSelectorsToJsonFile(_x3, _x4) {
|
||||
return _exportCustomSelectorsToJsonFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Selectors from Common JS file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _exportCustomSelectorsToJsonFile() {
|
||||
_exportCustomSelectorsToJsonFile = _asyncToGenerator(function* (to, customSelectors) {
|
||||
const jsonContent = JSON.stringify({
|
||||
'custom-selectors': customSelectors
|
||||
}, null, ' ');
|
||||
const json = `${jsonContent}\n`;
|
||||
yield writeFile(to, json);
|
||||
});
|
||||
return _exportCustomSelectorsToJsonFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function exportCustomSelectorsToCjsFile(_x5, _x6) {
|
||||
return _exportCustomSelectorsToCjsFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Selectors from Module JS file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _exportCustomSelectorsToCjsFile() {
|
||||
_exportCustomSelectorsToCjsFile = _asyncToGenerator(function* (to, customSelectors) {
|
||||
const jsContents = Object.keys(customSelectors).reduce((jsLines, name) => {
|
||||
jsLines.push(`\t\t'${escapeForJS(name)}': '${escapeForJS(customSelectors[name])}'`);
|
||||
return jsLines;
|
||||
}, []).join(',\n');
|
||||
const js = `module.exports = {\n\tcustomSelectors: {\n${jsContents}\n\t}\n};\n`;
|
||||
yield writeFile(to, js);
|
||||
});
|
||||
return _exportCustomSelectorsToCjsFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function exportCustomSelectorsToMjsFile(_x7, _x8) {
|
||||
return _exportCustomSelectorsToMjsFile.apply(this, arguments);
|
||||
}
|
||||
/* Export Custom Selectors to Destinations
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _exportCustomSelectorsToMjsFile() {
|
||||
_exportCustomSelectorsToMjsFile = _asyncToGenerator(function* (to, customSelectors) {
|
||||
const mjsContents = Object.keys(customSelectors).reduce((mjsLines, name) => {
|
||||
mjsLines.push(`\t'${escapeForJS(name)}': '${escapeForJS(customSelectors[name])}'`);
|
||||
return mjsLines;
|
||||
}, []).join(',\n');
|
||||
const mjs = `export const customSelectors = {\n${mjsContents}\n};\n`;
|
||||
yield writeFile(to, mjs);
|
||||
});
|
||||
return _exportCustomSelectorsToMjsFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function exportCustomSelectorsToDestinations(customSelectors, destinations) {
|
||||
return Promise.all(destinations.map(
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
var _ref = _asyncToGenerator(function* (destination) {
|
||||
if (destination instanceof Function) {
|
||||
yield destination(defaultCustomSelectorsToJSON(customSelectors));
|
||||
} else {
|
||||
// read the destination as an object
|
||||
const opts = destination === Object(destination) ? destination : {
|
||||
to: String(destination)
|
||||
}; // transformer for custom selectors into a JSON-compatible object
|
||||
|
||||
const toJSON = opts.toJSON || defaultCustomSelectorsToJSON;
|
||||
|
||||
if ('customSelectors' in opts) {
|
||||
// write directly to an object as customSelectors
|
||||
opts.customSelectors = toJSON(customSelectors);
|
||||
} else if ('custom-selectors' in opts) {
|
||||
// write directly to an object as custom-selectors
|
||||
opts['custom-selectors'] = toJSON(customSelectors);
|
||||
} else {
|
||||
// destination pathname
|
||||
const to = String(opts.to || ''); // type of file being written to
|
||||
|
||||
const type = (opts.type || path.extname(opts.to).slice(1)).toLowerCase(); // transformed custom selectors
|
||||
|
||||
const customSelectorsJSON = toJSON(customSelectors);
|
||||
|
||||
if (type === 'css') {
|
||||
yield exportCustomSelectorsToCssFile(to, customSelectorsJSON);
|
||||
}
|
||||
|
||||
if (type === 'js') {
|
||||
yield exportCustomSelectorsToCjsFile(to, customSelectorsJSON);
|
||||
}
|
||||
|
||||
if (type === 'json') {
|
||||
yield exportCustomSelectorsToJsonFile(to, customSelectorsJSON);
|
||||
}
|
||||
|
||||
if (type === 'mjs') {
|
||||
yield exportCustomSelectorsToMjsFile(to, customSelectorsJSON);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return function (_x9) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}()));
|
||||
}
|
||||
/* Helper utilities
|
||||
/* ========================================================================== */
|
||||
|
||||
const defaultCustomSelectorsToJSON = customSelectors => {
|
||||
return Object.keys(customSelectors).reduce((customSelectorsJSON, key) => {
|
||||
customSelectorsJSON[key] = String(customSelectors[key]);
|
||||
return customSelectorsJSON;
|
||||
}, {});
|
||||
};
|
||||
|
||||
const writeFile = (to, text) => new Promise((resolve, reject) => {
|
||||
fs.writeFile(to, text, error => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const escapeForJS = string => string.replace(/\\([\s\S])|(')/g, '\\$1$2').replace(/\n/g, '\\n').replace(/\r/g, '\\r');
|
||||
|
||||
var index = postcss.plugin('postcss-custom-selectors', opts => {
|
||||
// whether to preserve custom selectors and rules using them
|
||||
const preserve = Boolean(Object(opts).preserve); // sources to import custom selectors from
|
||||
|
||||
const importFrom = [].concat(Object(opts).importFrom || []); // destinations to export custom selectors to
|
||||
|
||||
const exportTo = [].concat(Object(opts).exportTo || []); // promise any custom selectors are imported
|
||||
|
||||
const customSelectorsPromise = importCustomSelectorsFromSources(importFrom);
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
var _ref = _asyncToGenerator(function* (root) {
|
||||
const customProperties = Object.assign((yield customSelectorsPromise), getCustomSelectors(root, {
|
||||
preserve
|
||||
}));
|
||||
yield exportCustomSelectorsToDestinations(customProperties, exportTo);
|
||||
transformRules(root, customProperties, {
|
||||
preserve
|
||||
});
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}()
|
||||
);
|
||||
});
|
||||
|
||||
module.exports = index;
|
||||
//# sourceMappingURL=index.cjs.js.map
|
||||
1
backend/frontend/node_modules/postcss-custom-selectors/index.cjs.js.map
generated
vendored
Normal file
1
backend/frontend/node_modules/postcss-custom-selectors/index.cjs.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
610
backend/frontend/node_modules/postcss-custom-selectors/index.es.mjs
generated
vendored
Normal file
610
backend/frontend/node_modules/postcss-custom-selectors/index.es.mjs
generated
vendored
Normal file
@@ -0,0 +1,610 @@
|
||||
import parser from 'postcss-selector-parser';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import postcss from 'postcss';
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
||||
try {
|
||||
var info = gen[key](arg);
|
||||
var value = info.value;
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (info.done) {
|
||||
resolve(value);
|
||||
} else {
|
||||
Promise.resolve(value).then(_next, _throw);
|
||||
}
|
||||
}
|
||||
|
||||
function _asyncToGenerator(fn) {
|
||||
return function () {
|
||||
var self = this,
|
||||
args = arguments;
|
||||
return new Promise(function (resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
||||
}
|
||||
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
||||
}
|
||||
|
||||
_next(undefined);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
var ownKeys = Object.keys(source);
|
||||
|
||||
if (typeof Object.getOwnPropertySymbols === 'function') {
|
||||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
|
||||
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
||||
}));
|
||||
}
|
||||
|
||||
ownKeys.forEach(function (key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
function _slicedToArray(arr, i) {
|
||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
|
||||
try {
|
||||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
||||
_arr.push(_s.value);
|
||||
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i["return"] != null) _i["return"]();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}
|
||||
|
||||
/* Return a Selectors AST from a Selectors String
|
||||
/* ========================================================================== */
|
||||
|
||||
var getSelectorsAstFromSelectorsString = (selectorString => {
|
||||
let selectorAST;
|
||||
parser(selectors => {
|
||||
selectorAST = selectors;
|
||||
}).processSync(selectorString);
|
||||
return selectorAST;
|
||||
});
|
||||
|
||||
var getCustomSelectors = ((root, opts) => {
|
||||
// initialize custom selectors
|
||||
const customSelectors = {}; // for each custom selector atrule that is a child of the css root
|
||||
|
||||
root.nodes.slice().forEach(node => {
|
||||
if (isCustomSelector(node)) {
|
||||
// extract the name and selectors from the params of the custom selector
|
||||
const _node$params$match = node.params.match(customSelectorParamsRegExp),
|
||||
_node$params$match2 = _slicedToArray(_node$params$match, 3),
|
||||
name = _node$params$match2[1],
|
||||
selectors = _node$params$match2[2]; // write the parsed selectors to the custom selector
|
||||
|
||||
|
||||
customSelectors[name] = getSelectorsAstFromSelectorsString(selectors); // conditionally remove the custom selector atrule
|
||||
|
||||
if (!Object(opts).preserve) {
|
||||
node.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
return customSelectors;
|
||||
}); // match the custom selector name
|
||||
|
||||
const customSelectorNameRegExp = /^custom-selector$/i; // match the custom selector params
|
||||
|
||||
const customSelectorParamsRegExp = /^(:--[A-z][\w-]*)\s+([\W\w]+)\s*$/; // whether the atrule is a custom selector
|
||||
|
||||
const isCustomSelector = node => node.type === 'atrule' && customSelectorNameRegExp.test(node.name) && customSelectorParamsRegExp.test(node.params);
|
||||
|
||||
// return transformed selectors, replacing custom pseudo selectors with custom selectors
|
||||
function transformSelectorList(selectorList, customSelectors) {
|
||||
let index = selectorList.nodes.length - 1;
|
||||
|
||||
while (index >= 0) {
|
||||
const transformedSelectors = transformSelector(selectorList.nodes[index], customSelectors);
|
||||
|
||||
if (transformedSelectors.length) {
|
||||
selectorList.nodes.splice(index, 1, ...transformedSelectors);
|
||||
}
|
||||
|
||||
--index;
|
||||
}
|
||||
|
||||
return selectorList;
|
||||
} // return custom pseudo selectors replaced with custom selectors
|
||||
|
||||
function transformSelector(selector, customSelectors) {
|
||||
const transpiledSelectors = [];
|
||||
|
||||
for (const index in selector.nodes) {
|
||||
const _selector$nodes$index = selector.nodes[index],
|
||||
value = _selector$nodes$index.value,
|
||||
nodes = _selector$nodes$index.nodes;
|
||||
|
||||
if (value in customSelectors) {
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = customSelectors[value].nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
const replacementSelector = _step.value;
|
||||
const selectorClone = selector.clone();
|
||||
selectorClone.nodes.splice(index, 1, ...replacementSelector.clone().nodes.map(node => {
|
||||
// use spacing from the current usage
|
||||
node.spaces = _objectSpread({}, selector.nodes[index].spaces);
|
||||
return node;
|
||||
}));
|
||||
const retranspiledSelectors = transformSelector(selectorClone, customSelectors);
|
||||
adjustNodesBySelectorEnds(selectorClone.nodes, Number(index));
|
||||
|
||||
if (retranspiledSelectors.length) {
|
||||
transpiledSelectors.push(...retranspiledSelectors);
|
||||
} else {
|
||||
transpiledSelectors.push(selectorClone);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return transpiledSelectors;
|
||||
} else if (nodes && nodes.length) {
|
||||
transformSelectorList(selector.nodes[index], customSelectors);
|
||||
}
|
||||
}
|
||||
|
||||
return transpiledSelectors;
|
||||
} // match selectors by difficult-to-separate ends
|
||||
|
||||
|
||||
const withoutSelectorStartMatch = /^(tag|universal)$/;
|
||||
const withoutSelectorEndMatch = /^(class|id|pseudo|tag|universal)$/;
|
||||
|
||||
const isWithoutSelectorStart = node => withoutSelectorStartMatch.test(Object(node).type);
|
||||
|
||||
const isWithoutSelectorEnd = node => withoutSelectorEndMatch.test(Object(node).type); // adjust nodes by selector ends (so that .class:--h1 becomes h1.class rather than .classh1)
|
||||
|
||||
|
||||
const adjustNodesBySelectorEnds = (nodes, index) => {
|
||||
if (index && isWithoutSelectorStart(nodes[index]) && isWithoutSelectorEnd(nodes[index - 1])) {
|
||||
let safeIndex = index - 1;
|
||||
|
||||
while (safeIndex && isWithoutSelectorEnd(nodes[safeIndex])) {
|
||||
--safeIndex;
|
||||
}
|
||||
|
||||
if (safeIndex < index) {
|
||||
const node = nodes.splice(index, 1)[0];
|
||||
nodes.splice(safeIndex, 0, node);
|
||||
nodes[safeIndex].spaces.before = nodes[safeIndex + 1].spaces.before;
|
||||
nodes[safeIndex + 1].spaces.before = '';
|
||||
|
||||
if (nodes[index]) {
|
||||
nodes[index].spaces.after = nodes[safeIndex].spaces.after;
|
||||
nodes[safeIndex].spaces.after = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var transformRules = ((root, customSelectors, opts) => {
|
||||
root.walkRules(customPseudoRegExp, rule => {
|
||||
const selector = parser(selectors => {
|
||||
transformSelectorList(selectors, customSelectors, opts);
|
||||
}).processSync(rule.selector);
|
||||
|
||||
if (opts.preserve) {
|
||||
rule.cloneBefore({
|
||||
selector
|
||||
});
|
||||
} else {
|
||||
rule.selector = selector;
|
||||
}
|
||||
});
|
||||
});
|
||||
const customPseudoRegExp = /:--[A-z][\w-]*/;
|
||||
|
||||
/* Import Custom Selectors from CSS AST
|
||||
/* ========================================================================== */
|
||||
|
||||
function importCustomSelectorsFromCSSAST(root) {
|
||||
return getCustomSelectors(root);
|
||||
}
|
||||
/* Import Custom Selectors from CSS File
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function importCustomSelectorsFromCSSFile(_x) {
|
||||
return _importCustomSelectorsFromCSSFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Selectors from Object
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _importCustomSelectorsFromCSSFile() {
|
||||
_importCustomSelectorsFromCSSFile = _asyncToGenerator(function* (from) {
|
||||
const css = yield readFile(path.resolve(from));
|
||||
const root = postcss.parse(css, {
|
||||
from: path.resolve(from)
|
||||
});
|
||||
return importCustomSelectorsFromCSSAST(root);
|
||||
});
|
||||
return _importCustomSelectorsFromCSSFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function importCustomSelectorsFromObject(object) {
|
||||
const customSelectors = Object.assign({}, Object(object).customSelectors || Object(object)['custom-selectors']);
|
||||
|
||||
for (const key in customSelectors) {
|
||||
customSelectors[key] = getSelectorsAstFromSelectorsString(customSelectors[key]);
|
||||
}
|
||||
|
||||
return customSelectors;
|
||||
}
|
||||
/* Import Custom Selectors from JSON file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function importCustomSelectorsFromJSONFile(_x2) {
|
||||
return _importCustomSelectorsFromJSONFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Selectors from JS file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _importCustomSelectorsFromJSONFile() {
|
||||
_importCustomSelectorsFromJSONFile = _asyncToGenerator(function* (from) {
|
||||
const object = yield readJSON(path.resolve(from));
|
||||
return importCustomSelectorsFromObject(object);
|
||||
});
|
||||
return _importCustomSelectorsFromJSONFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function importCustomSelectorsFromJSFile(_x3) {
|
||||
return _importCustomSelectorsFromJSFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Selectors from Sources
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _importCustomSelectorsFromJSFile() {
|
||||
_importCustomSelectorsFromJSFile = _asyncToGenerator(function* (from) {
|
||||
const object = yield import(path.resolve(from));
|
||||
return importCustomSelectorsFromObject(object);
|
||||
});
|
||||
return _importCustomSelectorsFromJSFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function importCustomSelectorsFromSources(sources) {
|
||||
return sources.map(source => {
|
||||
if (source instanceof Promise) {
|
||||
return source;
|
||||
} else if (source instanceof Function) {
|
||||
return source();
|
||||
} // read the source as an object
|
||||
|
||||
|
||||
const opts = source === Object(source) ? source : {
|
||||
from: String(source)
|
||||
}; // skip objects with custom selectors
|
||||
|
||||
if (Object(opts).customSelectors || Object(opts)['custom-selectors']) {
|
||||
return opts;
|
||||
} // source pathname
|
||||
|
||||
|
||||
const from = String(opts.from || ''); // type of file being read from
|
||||
|
||||
const type = (opts.type || path.extname(from).slice(1)).toLowerCase();
|
||||
return {
|
||||
type,
|
||||
from
|
||||
};
|
||||
}).reduce(
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
var _ref = _asyncToGenerator(function* (customSelectors, source) {
|
||||
const _ref2 = yield source,
|
||||
type = _ref2.type,
|
||||
from = _ref2.from;
|
||||
|
||||
if (type === 'ast') {
|
||||
return Object.assign(customSelectors, importCustomSelectorsFromCSSAST(from));
|
||||
}
|
||||
|
||||
if (type === 'css') {
|
||||
return Object.assign(customSelectors, (yield importCustomSelectorsFromCSSFile(from)));
|
||||
}
|
||||
|
||||
if (type === 'js') {
|
||||
return Object.assign(customSelectors, (yield importCustomSelectorsFromJSFile(from)));
|
||||
}
|
||||
|
||||
if (type === 'json') {
|
||||
return Object.assign(customSelectors, (yield importCustomSelectorsFromJSONFile(from)));
|
||||
}
|
||||
|
||||
return Object.assign(customSelectors, importCustomSelectorsFromObject((yield source)));
|
||||
});
|
||||
|
||||
return function (_x4, _x5) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}(), {});
|
||||
}
|
||||
/* Helper utilities
|
||||
/* ========================================================================== */
|
||||
|
||||
const readFile = from => new Promise((resolve, reject) => {
|
||||
fs.readFile(from, 'utf8', (error, result) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const readJSON =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
var _ref3 = _asyncToGenerator(function* (from) {
|
||||
return JSON.parse((yield readFile(from)));
|
||||
});
|
||||
|
||||
return function readJSON(_x6) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
|
||||
/* Import Custom Selectors from CSS File
|
||||
/* ========================================================================== */
|
||||
|
||||
function exportCustomSelectorsToCssFile(_x, _x2) {
|
||||
return _exportCustomSelectorsToCssFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Selectors from JSON file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _exportCustomSelectorsToCssFile() {
|
||||
_exportCustomSelectorsToCssFile = _asyncToGenerator(function* (to, customSelectors) {
|
||||
const cssContent = Object.keys(customSelectors).reduce((cssLines, name) => {
|
||||
cssLines.push(`@custom-selector ${name} ${customSelectors[name]};`);
|
||||
return cssLines;
|
||||
}, []).join('\n');
|
||||
const css = `${cssContent}\n`;
|
||||
yield writeFile(to, css);
|
||||
});
|
||||
return _exportCustomSelectorsToCssFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function exportCustomSelectorsToJsonFile(_x3, _x4) {
|
||||
return _exportCustomSelectorsToJsonFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Selectors from Common JS file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _exportCustomSelectorsToJsonFile() {
|
||||
_exportCustomSelectorsToJsonFile = _asyncToGenerator(function* (to, customSelectors) {
|
||||
const jsonContent = JSON.stringify({
|
||||
'custom-selectors': customSelectors
|
||||
}, null, ' ');
|
||||
const json = `${jsonContent}\n`;
|
||||
yield writeFile(to, json);
|
||||
});
|
||||
return _exportCustomSelectorsToJsonFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function exportCustomSelectorsToCjsFile(_x5, _x6) {
|
||||
return _exportCustomSelectorsToCjsFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Selectors from Module JS file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _exportCustomSelectorsToCjsFile() {
|
||||
_exportCustomSelectorsToCjsFile = _asyncToGenerator(function* (to, customSelectors) {
|
||||
const jsContents = Object.keys(customSelectors).reduce((jsLines, name) => {
|
||||
jsLines.push(`\t\t'${escapeForJS(name)}': '${escapeForJS(customSelectors[name])}'`);
|
||||
return jsLines;
|
||||
}, []).join(',\n');
|
||||
const js = `module.exports = {\n\tcustomSelectors: {\n${jsContents}\n\t}\n};\n`;
|
||||
yield writeFile(to, js);
|
||||
});
|
||||
return _exportCustomSelectorsToCjsFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function exportCustomSelectorsToMjsFile(_x7, _x8) {
|
||||
return _exportCustomSelectorsToMjsFile.apply(this, arguments);
|
||||
}
|
||||
/* Export Custom Selectors to Destinations
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _exportCustomSelectorsToMjsFile() {
|
||||
_exportCustomSelectorsToMjsFile = _asyncToGenerator(function* (to, customSelectors) {
|
||||
const mjsContents = Object.keys(customSelectors).reduce((mjsLines, name) => {
|
||||
mjsLines.push(`\t'${escapeForJS(name)}': '${escapeForJS(customSelectors[name])}'`);
|
||||
return mjsLines;
|
||||
}, []).join(',\n');
|
||||
const mjs = `export const customSelectors = {\n${mjsContents}\n};\n`;
|
||||
yield writeFile(to, mjs);
|
||||
});
|
||||
return _exportCustomSelectorsToMjsFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function exportCustomSelectorsToDestinations(customSelectors, destinations) {
|
||||
return Promise.all(destinations.map(
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
var _ref = _asyncToGenerator(function* (destination) {
|
||||
if (destination instanceof Function) {
|
||||
yield destination(defaultCustomSelectorsToJSON(customSelectors));
|
||||
} else {
|
||||
// read the destination as an object
|
||||
const opts = destination === Object(destination) ? destination : {
|
||||
to: String(destination)
|
||||
}; // transformer for custom selectors into a JSON-compatible object
|
||||
|
||||
const toJSON = opts.toJSON || defaultCustomSelectorsToJSON;
|
||||
|
||||
if ('customSelectors' in opts) {
|
||||
// write directly to an object as customSelectors
|
||||
opts.customSelectors = toJSON(customSelectors);
|
||||
} else if ('custom-selectors' in opts) {
|
||||
// write directly to an object as custom-selectors
|
||||
opts['custom-selectors'] = toJSON(customSelectors);
|
||||
} else {
|
||||
// destination pathname
|
||||
const to = String(opts.to || ''); // type of file being written to
|
||||
|
||||
const type = (opts.type || path.extname(opts.to).slice(1)).toLowerCase(); // transformed custom selectors
|
||||
|
||||
const customSelectorsJSON = toJSON(customSelectors);
|
||||
|
||||
if (type === 'css') {
|
||||
yield exportCustomSelectorsToCssFile(to, customSelectorsJSON);
|
||||
}
|
||||
|
||||
if (type === 'js') {
|
||||
yield exportCustomSelectorsToCjsFile(to, customSelectorsJSON);
|
||||
}
|
||||
|
||||
if (type === 'json') {
|
||||
yield exportCustomSelectorsToJsonFile(to, customSelectorsJSON);
|
||||
}
|
||||
|
||||
if (type === 'mjs') {
|
||||
yield exportCustomSelectorsToMjsFile(to, customSelectorsJSON);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return function (_x9) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}()));
|
||||
}
|
||||
/* Helper utilities
|
||||
/* ========================================================================== */
|
||||
|
||||
const defaultCustomSelectorsToJSON = customSelectors => {
|
||||
return Object.keys(customSelectors).reduce((customSelectorsJSON, key) => {
|
||||
customSelectorsJSON[key] = String(customSelectors[key]);
|
||||
return customSelectorsJSON;
|
||||
}, {});
|
||||
};
|
||||
|
||||
const writeFile = (to, text) => new Promise((resolve, reject) => {
|
||||
fs.writeFile(to, text, error => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const escapeForJS = string => string.replace(/\\([\s\S])|(')/g, '\\$1$2').replace(/\n/g, '\\n').replace(/\r/g, '\\r');
|
||||
|
||||
var index = postcss.plugin('postcss-custom-selectors', opts => {
|
||||
// whether to preserve custom selectors and rules using them
|
||||
const preserve = Boolean(Object(opts).preserve); // sources to import custom selectors from
|
||||
|
||||
const importFrom = [].concat(Object(opts).importFrom || []); // destinations to export custom selectors to
|
||||
|
||||
const exportTo = [].concat(Object(opts).exportTo || []); // promise any custom selectors are imported
|
||||
|
||||
const customSelectorsPromise = importCustomSelectorsFromSources(importFrom);
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
var _ref = _asyncToGenerator(function* (root) {
|
||||
const customProperties = Object.assign((yield customSelectorsPromise), getCustomSelectors(root, {
|
||||
preserve
|
||||
}));
|
||||
yield exportCustomSelectorsToDestinations(customProperties, exportTo);
|
||||
transformRules(root, customProperties, {
|
||||
preserve
|
||||
});
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}()
|
||||
);
|
||||
});
|
||||
|
||||
export default index;
|
||||
//# sourceMappingURL=index.es.mjs.map
|
||||
1
backend/frontend/node_modules/postcss-custom-selectors/index.es.mjs.map
generated
vendored
Normal file
1
backend/frontend/node_modules/postcss-custom-selectors/index.es.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
backend/frontend/node_modules/postcss-custom-selectors/node_modules/.bin/cssesc
generated
vendored
Symbolic link
1
backend/frontend/node_modules/postcss-custom-selectors/node_modules/.bin/cssesc
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../cssesc/bin/cssesc
|
||||
20
backend/frontend/node_modules/postcss-custom-selectors/node_modules/cssesc/LICENSE-MIT.txt
generated
vendored
Normal file
20
backend/frontend/node_modules/postcss-custom-selectors/node_modules/cssesc/LICENSE-MIT.txt
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright Mathias Bynens <https://mathiasbynens.be/>
|
||||
|
||||
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.
|
||||
201
backend/frontend/node_modules/postcss-custom-selectors/node_modules/cssesc/README.md
generated
vendored
Normal file
201
backend/frontend/node_modules/postcss-custom-selectors/node_modules/cssesc/README.md
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
# cssesc [](https://travis-ci.org/mathiasbynens/cssesc) [](https://codecov.io/gh/mathiasbynens/cssesc)
|
||||
|
||||
A JavaScript library for escaping CSS strings and identifiers while generating the shortest possible ASCII-only output.
|
||||
|
||||
This is a JavaScript library for [escaping text for use in CSS strings or identifiers](https://mathiasbynens.be/notes/css-escapes) while generating the shortest possible valid ASCII-only output. [Here’s an online demo.](https://mothereff.in/css-escapes)
|
||||
|
||||
[A polyfill for the CSSOM `CSS.escape()` method is available in a separate repository.](https://mths.be/cssescape) (In comparison, _cssesc_ is much more powerful.)
|
||||
|
||||
Feel free to fork if you see possible improvements!
|
||||
|
||||
## Installation
|
||||
|
||||
Via [npm](https://www.npmjs.com/):
|
||||
|
||||
```bash
|
||||
npm install cssesc
|
||||
```
|
||||
|
||||
In a browser:
|
||||
|
||||
```html
|
||||
<script src="cssesc.js"></script>
|
||||
```
|
||||
|
||||
In [Node.js](https://nodejs.org/):
|
||||
|
||||
```js
|
||||
const cssesc = require('cssesc');
|
||||
```
|
||||
|
||||
In Ruby using [the `ruby-cssesc` wrapper gem](https://github.com/borodean/ruby-cssesc):
|
||||
|
||||
```bash
|
||||
gem install ruby-cssesc
|
||||
```
|
||||
|
||||
```ruby
|
||||
require 'ruby-cssesc'
|
||||
CSSEsc.escape('I ♥ Ruby', is_identifier: true)
|
||||
```
|
||||
|
||||
In Sass using [`sassy-escape`](https://github.com/borodean/sassy-escape):
|
||||
|
||||
```bash
|
||||
gem install sassy-escape
|
||||
```
|
||||
|
||||
```scss
|
||||
body {
|
||||
content: escape('I ♥ Sass', $is-identifier: true);
|
||||
}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `cssesc(value, options)`
|
||||
|
||||
This function takes a value and returns an escaped version of the value where any characters that are not printable ASCII symbols are escaped using the shortest possible (but valid) [escape sequences for use in CSS strings or identifiers](https://mathiasbynens.be/notes/css-escapes).
|
||||
|
||||
```js
|
||||
cssesc('Ich ♥ Bücher');
|
||||
// → 'Ich \\2665 B\\FC cher'
|
||||
|
||||
cssesc('foo 𝌆 bar');
|
||||
// → 'foo \\1D306 bar'
|
||||
```
|
||||
|
||||
By default, `cssesc` returns a string that can be used as part of a CSS string. If the target is a CSS identifier rather than a CSS string, use the `isIdentifier: true` setting (see below).
|
||||
|
||||
The optional `options` argument accepts an object with the following options:
|
||||
|
||||
#### `isIdentifier`
|
||||
|
||||
The default value for the `isIdentifier` option is `false`. This means that the input text will be escaped for use in a CSS string literal. If you want to use the result as a CSS identifier instead (in a selector, for example), set this option to `true`.
|
||||
|
||||
```js
|
||||
cssesc('123a2b');
|
||||
// → '123a2b'
|
||||
|
||||
cssesc('123a2b', {
|
||||
'isIdentifier': true
|
||||
});
|
||||
// → '\\31 23a2b'
|
||||
```
|
||||
|
||||
#### `quotes`
|
||||
|
||||
The default value for the `quotes` option is `'single'`. This means that any occurences of `'` in the input text will be escaped as `\'`, so that the output can be used in a CSS string literal wrapped in single quotes.
|
||||
|
||||
```js
|
||||
cssesc('Lorem ipsum "dolor" sit \'amet\' etc.');
|
||||
// → 'Lorem ipsum "dolor" sit \\\'amet\\\' etc.'
|
||||
// → "Lorem ipsum \"dolor\" sit \\'amet\\' etc."
|
||||
|
||||
cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
|
||||
'quotes': 'single'
|
||||
});
|
||||
// → 'Lorem ipsum "dolor" sit \\\'amet\\\' etc.'
|
||||
// → "Lorem ipsum \"dolor\" sit \\'amet\\' etc."
|
||||
```
|
||||
|
||||
If you want to use the output as part of a CSS string literal wrapped in double quotes, set the `quotes` option to `'double'`.
|
||||
|
||||
```js
|
||||
cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
|
||||
'quotes': 'double'
|
||||
});
|
||||
// → 'Lorem ipsum \\"dolor\\" sit \'amet\' etc.'
|
||||
// → "Lorem ipsum \\\"dolor\\\" sit 'amet' etc."
|
||||
```
|
||||
|
||||
#### `wrap`
|
||||
|
||||
The `wrap` option takes a boolean value (`true` or `false`), and defaults to `false` (disabled). When enabled, the output will be a valid CSS string literal wrapped in quotes. The type of quotes can be specified through the `quotes` setting.
|
||||
|
||||
```js
|
||||
cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
|
||||
'quotes': 'single',
|
||||
'wrap': true
|
||||
});
|
||||
// → '\'Lorem ipsum "dolor" sit \\\'amet\\\' etc.\''
|
||||
// → "\'Lorem ipsum \"dolor\" sit \\\'amet\\\' etc.\'"
|
||||
|
||||
cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
|
||||
'quotes': 'double',
|
||||
'wrap': true
|
||||
});
|
||||
// → '"Lorem ipsum \\"dolor\\" sit \'amet\' etc."'
|
||||
// → "\"Lorem ipsum \\\"dolor\\\" sit \'amet\' etc.\""
|
||||
```
|
||||
|
||||
#### `escapeEverything`
|
||||
|
||||
The `escapeEverything` option takes a boolean value (`true` or `false`), and defaults to `false` (disabled). When enabled, all the symbols in the output will be escaped, even printable ASCII symbols.
|
||||
|
||||
```js
|
||||
cssesc('lolwat"foo\'bar', {
|
||||
'escapeEverything': true
|
||||
});
|
||||
// → '\\6C\\6F\\6C\\77\\61\\74\\"\\66\\6F\\6F\\\'\\62\\61\\72'
|
||||
// → "\\6C\\6F\\6C\\77\\61\\74\\\"\\66\\6F\\6F\\'\\62\\61\\72"
|
||||
```
|
||||
|
||||
#### Overriding the default options globally
|
||||
|
||||
The global default settings can be overridden by modifying the `css.options` object. This saves you from passing in an `options` object for every call to `encode` if you want to use the non-default setting.
|
||||
|
||||
```js
|
||||
// Read the global default setting for `escapeEverything`:
|
||||
cssesc.options.escapeEverything;
|
||||
// → `false` by default
|
||||
|
||||
// Override the global default setting for `escapeEverything`:
|
||||
cssesc.options.escapeEverything = true;
|
||||
|
||||
// Using the global default setting for `escapeEverything`, which is now `true`:
|
||||
cssesc('foo © bar ≠ baz 𝌆 qux');
|
||||
// → '\\66\\6F\\6F\\ \\A9\\ \\62\\61\\72\\ \\2260\\ \\62\\61\\7A\\ \\1D306\\ \\71\\75\\78'
|
||||
```
|
||||
|
||||
### `cssesc.version`
|
||||
|
||||
A string representing the semantic version number.
|
||||
|
||||
### Using the `cssesc` binary
|
||||
|
||||
To use the `cssesc` binary in your shell, simply install cssesc globally using npm:
|
||||
|
||||
```bash
|
||||
npm install -g cssesc
|
||||
```
|
||||
|
||||
After that you will be able to escape text for use in CSS strings or identifiers from the command line:
|
||||
|
||||
```bash
|
||||
$ cssesc 'föo ♥ bår 𝌆 baz'
|
||||
f\F6o \2665 b\E5r \1D306 baz
|
||||
```
|
||||
|
||||
If the output needs to be a CSS identifier rather than part of a string literal, use the `-i`/`--identifier` option:
|
||||
|
||||
```bash
|
||||
$ cssesc --identifier 'föo ♥ bår 𝌆 baz'
|
||||
f\F6o\ \2665\ b\E5r\ \1D306\ baz
|
||||
```
|
||||
|
||||
See `cssesc --help` for the full list of options.
|
||||
|
||||
## Support
|
||||
|
||||
This library supports the Node.js and browser versions mentioned in [`.babelrc`](https://github.com/mathiasbynens/cssesc/blob/master/.babelrc). For a version that supports a wider variety of legacy browsers and environments out-of-the-box, [see v0.1.0](https://github.com/mathiasbynens/cssesc/releases/tag/v0.1.0).
|
||||
|
||||
## Author
|
||||
|
||||
| [](https://twitter.com/mathias "Follow @mathias on Twitter") |
|
||||
|---|
|
||||
| [Mathias Bynens](https://mathiasbynens.be/) |
|
||||
|
||||
## License
|
||||
|
||||
This library is available under the [MIT](https://mths.be/mit) license.
|
||||
119
backend/frontend/node_modules/postcss-custom-selectors/node_modules/cssesc/cssesc.js
generated
vendored
Normal file
119
backend/frontend/node_modules/postcss-custom-selectors/node_modules/cssesc/cssesc.js
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
/*! https://mths.be/cssesc v1.0.1 by @mathias */
|
||||
'use strict';
|
||||
|
||||
var object = {};
|
||||
var hasOwnProperty = object.hasOwnProperty;
|
||||
var merge = function merge(options, defaults) {
|
||||
if (!options) {
|
||||
return defaults;
|
||||
}
|
||||
var result = {};
|
||||
for (var key in defaults) {
|
||||
// `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
|
||||
// only recognized option names are used.
|
||||
result[key] = hasOwnProperty.call(options, key) ? options[key] : defaults[key];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
var regexAnySingleEscape = /[ -,\.\/;-@\[-\^`\{-~]/;
|
||||
var regexSingleEscape = /[ -,\.\/;-@\[\]\^`\{-~]/;
|
||||
var regexAlwaysEscape = /['"\\]/;
|
||||
var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
|
||||
|
||||
// https://mathiasbynens.be/notes/css-escapes#css
|
||||
var cssesc = function cssesc(string, options) {
|
||||
options = merge(options, cssesc.options);
|
||||
if (options.quotes != 'single' && options.quotes != 'double') {
|
||||
options.quotes = 'single';
|
||||
}
|
||||
var quote = options.quotes == 'double' ? '"' : '\'';
|
||||
var isIdentifier = options.isIdentifier;
|
||||
|
||||
var firstChar = string.charAt(0);
|
||||
var output = '';
|
||||
var counter = 0;
|
||||
var length = string.length;
|
||||
while (counter < length) {
|
||||
var character = string.charAt(counter++);
|
||||
var codePoint = character.charCodeAt();
|
||||
var value = void 0;
|
||||
// If it’s not a printable ASCII character…
|
||||
if (codePoint < 0x20 || codePoint > 0x7E) {
|
||||
if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
|
||||
// It’s a high surrogate, and there is a next character.
|
||||
var extra = string.charCodeAt(counter++);
|
||||
if ((extra & 0xFC00) == 0xDC00) {
|
||||
// next character is low surrogate
|
||||
codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
|
||||
} else {
|
||||
// It’s an unmatched surrogate; only append this code unit, in case
|
||||
// the next code unit is the high surrogate of a surrogate pair.
|
||||
counter--;
|
||||
}
|
||||
}
|
||||
value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
|
||||
} else {
|
||||
if (options.escapeEverything) {
|
||||
if (regexAnySingleEscape.test(character)) {
|
||||
value = '\\' + character;
|
||||
} else {
|
||||
value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
|
||||
}
|
||||
// Note: `:` could be escaped as `\:`, but that fails in IE < 8.
|
||||
} else if (/[\t\n\f\r\x0B:]/.test(character)) {
|
||||
if (!isIdentifier && character == ':') {
|
||||
value = character;
|
||||
} else {
|
||||
value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
|
||||
}
|
||||
} else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
|
||||
value = '\\' + character;
|
||||
} else {
|
||||
value = character;
|
||||
}
|
||||
}
|
||||
output += value;
|
||||
}
|
||||
|
||||
if (isIdentifier) {
|
||||
if (/^_/.test(output)) {
|
||||
// Prevent IE6 from ignoring the rule altogether (in case this is for an
|
||||
// identifier used as a selector)
|
||||
output = '\\_' + output.slice(1);
|
||||
} else if (/^-[-\d]/.test(output)) {
|
||||
output = '\\-' + output.slice(1);
|
||||
} else if (/\d/.test(firstChar)) {
|
||||
output = '\\3' + firstChar + ' ' + output.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove spaces after `\HEX` escapes that are not followed by a hex digit,
|
||||
// since they’re redundant. Note that this is only possible if the escape
|
||||
// sequence isn’t preceded by an odd number of backslashes.
|
||||
output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
|
||||
if ($1 && $1.length % 2) {
|
||||
// It’s not safe to remove the space, so don’t.
|
||||
return $0;
|
||||
}
|
||||
// Strip the space.
|
||||
return ($1 || '') + $2;
|
||||
});
|
||||
|
||||
if (!isIdentifier && options.wrap) {
|
||||
return quote + output + quote;
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
// Expose default options (so they can be overridden globally).
|
||||
cssesc.options = {
|
||||
'escapeEverything': false,
|
||||
'isIdentifier': false,
|
||||
'quotes': 'single',
|
||||
'wrap': false
|
||||
};
|
||||
|
||||
cssesc.version = '1.0.1';
|
||||
|
||||
module.exports = cssesc;
|
||||
70
backend/frontend/node_modules/postcss-custom-selectors/node_modules/cssesc/man/cssesc.1
generated
vendored
Normal file
70
backend/frontend/node_modules/postcss-custom-selectors/node_modules/cssesc/man/cssesc.1
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
.Dd August 9, 2013
|
||||
.Dt cssesc 1
|
||||
.Sh NAME
|
||||
.Nm cssesc
|
||||
.Nd escape text for use in CSS string literals or identifiers
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl i | -identifier Ar string
|
||||
.br
|
||||
.Op Fl s | -single-quotes Ar string
|
||||
.br
|
||||
.Op Fl d | -double-quotes Ar string
|
||||
.br
|
||||
.Op Fl w | -wrap Ar string
|
||||
.br
|
||||
.Op Fl e | -escape-everything Ar string
|
||||
.br
|
||||
.Op Fl v | -version
|
||||
.br
|
||||
.Op Fl h | -help
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
escapes strings for use in CSS string literals or identifiers while generating the shortest possible valid ASCII-only output.
|
||||
.Sh OPTIONS
|
||||
.Bl -ohang -offset
|
||||
.It Sy "-s, --single-quotes"
|
||||
Escape any occurences of ' in the input string as \\', so that the output can be used in a CSS string literal wrapped in single quotes.
|
||||
.It Sy "-d, --double-quotes"
|
||||
Escape any occurences of " in the input string as \\", so that the output can be used in a CSS string literal wrapped in double quotes.
|
||||
.It Sy "-w, --wrap"
|
||||
Make sure the output is a valid CSS string literal wrapped in quotes. The type of quotes can be specified using the
|
||||
.Ar -s | --single-quotes
|
||||
or
|
||||
.Ar -d | --double-quotes
|
||||
settings.
|
||||
.It Sy "-e, --escape-everything"
|
||||
Escape all the symbols in the output, even printable ASCII symbols.
|
||||
.It Sy "-v, --version"
|
||||
Print cssesc's version.
|
||||
.It Sy "-h, --help"
|
||||
Show the help screen.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
The
|
||||
.Nm cssesc
|
||||
utility exits with one of the following values:
|
||||
.Pp
|
||||
.Bl -tag -width flag -compact
|
||||
.It Li 0
|
||||
.Nm
|
||||
successfully escaped the given text and printed the result.
|
||||
.It Li 1
|
||||
.Nm
|
||||
wasn't instructed to escape anything (for example, the
|
||||
.Ar --help
|
||||
flag was set); or, an error occurred.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
.Bl -ohang -offset
|
||||
.It Sy "cssesc 'foo bar baz'"
|
||||
Print an escaped version of the given text.
|
||||
.It Sy echo\ 'foo bar baz'\ |\ cssesc
|
||||
Print an escaped version of the text that gets piped in.
|
||||
.El
|
||||
.Sh BUGS
|
||||
cssesc's bug tracker is located at <https://github.com/mathiasbynens/cssesc/issues>.
|
||||
.Sh AUTHOR
|
||||
Mathias Bynens <https://mathiasbynens.be/>
|
||||
.Sh WWW
|
||||
<https://mths.be/cssesc>
|
||||
51
backend/frontend/node_modules/postcss-custom-selectors/node_modules/cssesc/package.json
generated
vendored
Normal file
51
backend/frontend/node_modules/postcss-custom-selectors/node_modules/cssesc/package.json
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "cssesc",
|
||||
"version": "2.0.0",
|
||||
"description": "A JavaScript library for escaping CSS strings and identifiers while generating the shortest possible ASCII-only output.",
|
||||
"homepage": "https://mths.be/cssesc",
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"main": "cssesc.js",
|
||||
"bin": "bin/cssesc",
|
||||
"man": "man/cssesc.1",
|
||||
"keywords": [
|
||||
"css",
|
||||
"escape",
|
||||
"identifier",
|
||||
"string",
|
||||
"tool"
|
||||
],
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Mathias Bynens",
|
||||
"url": "https://mathiasbynens.be/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mathiasbynens/cssesc.git"
|
||||
},
|
||||
"bugs": "https://github.com/mathiasbynens/cssesc/issues",
|
||||
"files": [
|
||||
"LICENSE-MIT.txt",
|
||||
"cssesc.js",
|
||||
"bin/",
|
||||
"man/"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "grunt template && babel cssesc.js -o cssesc.js",
|
||||
"test": "mocha tests",
|
||||
"cover": "istanbul cover --report html node_modules/.bin/_mocha tests -- -u exports -R spec"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"codecov": "^1.0.1",
|
||||
"grunt": "^1.0.1",
|
||||
"grunt-template": "^1.0.0",
|
||||
"istanbul": "^0.4.4",
|
||||
"mocha": "^2.5.3",
|
||||
"regenerate": "^1.2.1",
|
||||
"requirejs": "^2.1.16"
|
||||
}
|
||||
}
|
||||
15
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/LICENSE
generated
vendored
Normal file
15
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
ISC License
|
||||
|
||||
Copyright (c) 2021 Alexey Raspopov, Kostiantyn Denysov, Anton Verinov
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
23
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/README.md
generated
vendored
Normal file
23
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/README.md
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# picocolors
|
||||
|
||||
npm install picocolors
|
||||
|
||||
A tinier and faster alternative to [nanocolors](https://github.com/ai/nanocolors). Andrey, are you even trying?
|
||||
|
||||
```javascript
|
||||
import pc from "picocolors";
|
||||
|
||||
console.log(pc.green(`How are ${pc.italic(`you`)} doing?`));
|
||||
```
|
||||
|
||||
- Up to [2x faster and 2x smaller](#benchmarks) than alternatives
|
||||
- 3x faster and 10x smaller than `chalk`
|
||||
- [TypeScript](https://www.typescriptlang.org/) support
|
||||
- [`NO_COLOR`](https://no-color.org/) friendly
|
||||
- Node.js v6+ & browsers support
|
||||
- The same API, but faster, much faster
|
||||
- No `String.prototype` modifications (anyone still doing it?)
|
||||
- No dependencies and the smallest `node_modules` footprint
|
||||
|
||||
## Docs
|
||||
Read **[full docs](https://github.com/alexeyraspopov/picocolors#readme)** on GitHub.
|
||||
25
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/package.json
generated
vendored
Normal file
25
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "picocolors",
|
||||
"version": "0.2.1",
|
||||
"main": "./picocolors.js",
|
||||
"types": "./picocolors.d.ts",
|
||||
"browser": {
|
||||
"./picocolors.js": "./picocolors.browser.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"description": "The tiniest and the fastest coloring library ever",
|
||||
"files": [
|
||||
"picocolors.*",
|
||||
"types.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"terminal",
|
||||
"colors",
|
||||
"formatting",
|
||||
"cli",
|
||||
"console"
|
||||
],
|
||||
"author": "Alexey Raspopov",
|
||||
"repository": "alexeyraspopov/picocolors",
|
||||
"license": "ISC"
|
||||
}
|
||||
4
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/picocolors.browser.js
generated
vendored
Normal file
4
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/picocolors.browser.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
var x=String;
|
||||
var create=function() {return {isColorSupported:false,reset:x,bold:x,dim:x,italic:x,underline:x,inverse:x,hidden:x,strikethrough:x,black:x,red:x,green:x,yellow:x,blue:x,magenta:x,cyan:x,white:x,gray:x,bgBlack:x,bgRed:x,bgGreen:x,bgYellow:x,bgBlue:x,bgMagenta:x,bgCyan:x,bgWhite:x}};
|
||||
module.exports=create();
|
||||
module.exports.createColors = create;
|
||||
5
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/picocolors.d.ts
generated
vendored
Normal file
5
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/picocolors.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { Colors } from "./types"
|
||||
|
||||
declare const picocolors: Colors & { createColors: (enabled: boolean) => Colors }
|
||||
|
||||
export = picocolors
|
||||
60
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/picocolors.js
generated
vendored
Normal file
60
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/picocolors.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
let tty = require("tty")
|
||||
|
||||
let isColorSupported =
|
||||
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
|
||||
("FORCE_COLOR" in process.env ||
|
||||
process.argv.includes("--color") ||
|
||||
process.platform === "win32" ||
|
||||
(tty.isatty(1) && process.env.TERM !== "dumb") ||
|
||||
"CI" in process.env)
|
||||
|
||||
function formatter(open, close, replace = open) {
|
||||
return (input) => {
|
||||
let string = "" + input
|
||||
let index = string.indexOf(close, open.length)
|
||||
return !~index
|
||||
? open + string + close
|
||||
: open + replaceClose(string, close, replace, index) + close
|
||||
}
|
||||
}
|
||||
|
||||
function replaceClose(string, close, replace, index) {
|
||||
let start = string.substring(0, index) + replace
|
||||
let end = string.substring(index + close.length)
|
||||
let nextIndex = end.indexOf(close)
|
||||
return !~nextIndex ? start + end : start + replaceClose(end, close, replace, nextIndex)
|
||||
}
|
||||
|
||||
function createColors(enabled = isColorSupported) {
|
||||
return {
|
||||
isColorSupported: enabled,
|
||||
reset: enabled ? (s) => `\x1b[0m${s}\x1b[0m` : String,
|
||||
bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
|
||||
dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
|
||||
italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
|
||||
underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
|
||||
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
|
||||
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
|
||||
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
|
||||
black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
|
||||
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
|
||||
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
|
||||
yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
|
||||
blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
|
||||
magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
|
||||
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
|
||||
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
|
||||
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
|
||||
bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
|
||||
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
|
||||
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
|
||||
bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
|
||||
bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
|
||||
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
|
||||
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
|
||||
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = createColors()
|
||||
module.exports.createColors = createColors
|
||||
30
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/types.ts
generated
vendored
Normal file
30
backend/frontend/node_modules/postcss-custom-selectors/node_modules/picocolors/types.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
export type Formatter = (input: string | number | null | undefined) => string
|
||||
|
||||
export interface Colors {
|
||||
isColorSupported: boolean
|
||||
reset: Formatter
|
||||
bold: Formatter
|
||||
dim: Formatter
|
||||
italic: Formatter
|
||||
underline: Formatter
|
||||
inverse: Formatter
|
||||
hidden: Formatter
|
||||
strikethrough: Formatter
|
||||
black: Formatter
|
||||
red: Formatter
|
||||
green: Formatter
|
||||
yellow: Formatter
|
||||
blue: Formatter
|
||||
magenta: Formatter
|
||||
cyan: Formatter
|
||||
white: Formatter
|
||||
gray: Formatter
|
||||
bgBlack: Formatter
|
||||
bgRed: Formatter
|
||||
bgGreen: Formatter
|
||||
bgYellow: Formatter
|
||||
bgBlue: Formatter
|
||||
bgMagenta: Formatter
|
||||
bgCyan: Formatter
|
||||
bgWhite: Formatter
|
||||
}
|
||||
873
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser/API.md
generated
vendored
Normal file
873
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser/API.md
generated
vendored
Normal file
@@ -0,0 +1,873 @@
|
||||
# API Documentation
|
||||
|
||||
*Please use only this documented API when working with the parser. Methods
|
||||
not documented here are subject to change at any point.*
|
||||
|
||||
## `parser` function
|
||||
|
||||
This is the module's main entry point.
|
||||
|
||||
```js
|
||||
const parser = require('postcss-selector-parser');
|
||||
```
|
||||
|
||||
### `parser([transform], [options])`
|
||||
|
||||
Creates a new `processor` instance
|
||||
|
||||
```js
|
||||
const processor = parser();
|
||||
```
|
||||
|
||||
Or, with optional transform function
|
||||
|
||||
```js
|
||||
const transform = selectors => {
|
||||
selectors.walkUniversals(selector => {
|
||||
selector.remove();
|
||||
});
|
||||
};
|
||||
|
||||
const processor = parser(transform)
|
||||
|
||||
// Example
|
||||
const result = processor.processSync('*.class');
|
||||
// => .class
|
||||
```
|
||||
|
||||
[See processor documentation](#processor)
|
||||
|
||||
Arguments:
|
||||
|
||||
* `transform (function)`: Provide a function to work with the parsed AST.
|
||||
* `options (object)`: Provide default options for all calls on the returned `Processor`.
|
||||
|
||||
### `parser.attribute([props])`
|
||||
|
||||
Creates a new attribute selector.
|
||||
|
||||
```js
|
||||
parser.attribute({attribute: 'href'});
|
||||
// => [href]
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `props (object)`: The new node's properties.
|
||||
|
||||
### `parser.className([props])`
|
||||
|
||||
Creates a new class selector.
|
||||
|
||||
```js
|
||||
parser.className({value: 'button'});
|
||||
// => .button
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `props (object)`: The new node's properties.
|
||||
|
||||
### `parser.combinator([props])`
|
||||
|
||||
Creates a new selector combinator.
|
||||
|
||||
```js
|
||||
parser.combinator({value: '+'});
|
||||
// => +
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `props (object)`: The new node's properties.
|
||||
|
||||
Notes:
|
||||
* **Descendant Combinators** The value of descendant combinators created by the
|
||||
parser always just a single space (`" "`). For descendant selectors with no
|
||||
comments, additional space is now stored in `node.spaces.before`. Depending
|
||||
on the location of comments, additional spaces may be stored in
|
||||
`node.raws.spaces.before`, `node.raws.spaces.after`, or `node.raws.value`.
|
||||
* **Named Combinators** Although, nonstandard and unlikely to ever become a standard,
|
||||
named combinators like `/deep/` and `/for/` are parsed as combinators. The
|
||||
`node.value` is name after being unescaped and normalized as lowercase. The
|
||||
original value for the combinator name is stored in `node.raws.value`.
|
||||
|
||||
|
||||
### `parser.comment([props])`
|
||||
|
||||
Creates a new comment.
|
||||
|
||||
```js
|
||||
parser.comment({value: '/* Affirmative, Dave. I read you. */'});
|
||||
// => /* Affirmative, Dave. I read you. */
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `props (object)`: The new node's properties.
|
||||
|
||||
### `parser.id([props])`
|
||||
|
||||
Creates a new id selector.
|
||||
|
||||
```js
|
||||
parser.id({value: 'search'});
|
||||
// => #search
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `props (object)`: The new node's properties.
|
||||
|
||||
### `parser.nesting([props])`
|
||||
|
||||
Creates a new nesting selector.
|
||||
|
||||
```js
|
||||
parser.nesting();
|
||||
// => &
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `props (object)`: The new node's properties.
|
||||
|
||||
### `parser.pseudo([props])`
|
||||
|
||||
Creates a new pseudo selector.
|
||||
|
||||
```js
|
||||
parser.pseudo({value: '::before'});
|
||||
// => ::before
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `props (object)`: The new node's properties.
|
||||
|
||||
### `parser.root([props])`
|
||||
|
||||
Creates a new root node.
|
||||
|
||||
```js
|
||||
parser.root();
|
||||
// => (empty)
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `props (object)`: The new node's properties.
|
||||
|
||||
### `parser.selector([props])`
|
||||
|
||||
Creates a new selector node.
|
||||
|
||||
```js
|
||||
parser.selector();
|
||||
// => (empty)
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `props (object)`: The new node's properties.
|
||||
|
||||
### `parser.string([props])`
|
||||
|
||||
Creates a new string node.
|
||||
|
||||
```js
|
||||
parser.string();
|
||||
// => (empty)
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `props (object)`: The new node's properties.
|
||||
|
||||
### `parser.tag([props])`
|
||||
|
||||
Creates a new tag selector.
|
||||
|
||||
```js
|
||||
parser.tag({value: 'button'});
|
||||
// => button
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `props (object)`: The new node's properties.
|
||||
|
||||
### `parser.universal([props])`
|
||||
|
||||
Creates a new universal selector.
|
||||
|
||||
```js
|
||||
parser.universal();
|
||||
// => *
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `props (object)`: The new node's properties.
|
||||
|
||||
## Node types
|
||||
|
||||
### `node.type`
|
||||
|
||||
A string representation of the selector type. It can be one of the following;
|
||||
`attribute`, `class`, `combinator`, `comment`, `id`, `nesting`, `pseudo`,
|
||||
`root`, `selector`, `string`, `tag`, or `universal`. Note that for convenience,
|
||||
these constants are exposed on the main `parser` as uppercased keys. So for
|
||||
example you can get `id` by querying `parser.ID`.
|
||||
|
||||
```js
|
||||
parser.attribute({attribute: 'href'}).type;
|
||||
// => 'attribute'
|
||||
```
|
||||
|
||||
### `node.parent`
|
||||
|
||||
Returns the parent node.
|
||||
|
||||
```js
|
||||
root.nodes[0].parent === root;
|
||||
```
|
||||
|
||||
### `node.toString()`, `String(node)`, or `'' + node`
|
||||
|
||||
Returns a string representation of the node.
|
||||
|
||||
```js
|
||||
const id = parser.id({value: 'search'});
|
||||
console.log(String(id));
|
||||
// => #search
|
||||
```
|
||||
|
||||
### `node.next()` & `node.prev()`
|
||||
|
||||
Returns the next/previous child of the parent node.
|
||||
|
||||
```js
|
||||
const next = id.next();
|
||||
if (next && next.type !== 'combinator') {
|
||||
throw new Error('Qualified IDs are not allowed!');
|
||||
}
|
||||
```
|
||||
|
||||
### `node.replaceWith(node)`
|
||||
|
||||
Replace a node with another.
|
||||
|
||||
```js
|
||||
const attr = selectors.first.first;
|
||||
const className = parser.className({value: 'test'});
|
||||
attr.replaceWith(className);
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `node`: The node to substitute the original with.
|
||||
|
||||
### `node.remove()`
|
||||
|
||||
Removes the node from its parent node.
|
||||
|
||||
```js
|
||||
if (node.type === 'id') {
|
||||
node.remove();
|
||||
}
|
||||
```
|
||||
|
||||
### `node.clone()`
|
||||
|
||||
Returns a copy of a node, detached from any parent containers that the
|
||||
original might have had.
|
||||
|
||||
```js
|
||||
const cloned = parser.id({value: 'search'});
|
||||
String(cloned);
|
||||
|
||||
// => #search
|
||||
```
|
||||
|
||||
### `node.isAtPosition(line, column)`
|
||||
|
||||
Return a `boolean` indicating whether this node includes the character at the
|
||||
position of the given line and column. Returns `undefined` if the nodes lack
|
||||
sufficient source metadata to determine the position.
|
||||
|
||||
Arguments:
|
||||
|
||||
* `line`: 1-index based line number relative to the start of the selector.
|
||||
* `column`: 1-index based column number relative to the start of the selector.
|
||||
|
||||
### `node.spaces`
|
||||
|
||||
Extra whitespaces around the node will be moved into `node.spaces.before` and
|
||||
`node.spaces.after`. So for example, these spaces will be moved as they have
|
||||
no semantic meaning:
|
||||
|
||||
```css
|
||||
h1 , h2 {}
|
||||
```
|
||||
|
||||
For descendent selectors, the value is always a single space.
|
||||
|
||||
```css
|
||||
h1 h2 {}
|
||||
```
|
||||
|
||||
Additional whitespace is found in either the `node.spaces.before` and `node.spaces.after` depending on the presence of comments or other whitespace characters. If the actual whitespace does not start or end with a single space, the node's raw value is set to the actual space(s) found in the source.
|
||||
|
||||
### `node.source`
|
||||
|
||||
An object describing the node's start/end, line/column source position.
|
||||
|
||||
Within the following CSS, the `.bar` class node ...
|
||||
|
||||
```css
|
||||
.foo,
|
||||
.bar {}
|
||||
```
|
||||
|
||||
... will contain the following `source` object.
|
||||
|
||||
```js
|
||||
source: {
|
||||
start: {
|
||||
line: 2,
|
||||
column: 3
|
||||
},
|
||||
end: {
|
||||
line: 2,
|
||||
column: 6
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `node.sourceIndex`
|
||||
|
||||
The zero-based index of the node within the original source string.
|
||||
|
||||
Within the following CSS, the `.baz` class node will have a `sourceIndex` of `12`.
|
||||
|
||||
```css
|
||||
.foo, .bar, .baz {}
|
||||
```
|
||||
|
||||
## Container types
|
||||
|
||||
The `root`, `selector`, and `pseudo` nodes have some helper methods for working
|
||||
with their children.
|
||||
|
||||
### `container.nodes`
|
||||
|
||||
An array of the container's children.
|
||||
|
||||
```js
|
||||
// Input: h1 h2
|
||||
selectors.at(0).nodes.length // => 3
|
||||
selectors.at(0).nodes[0].value // => 'h1'
|
||||
selectors.at(0).nodes[1].value // => ' '
|
||||
```
|
||||
|
||||
### `container.first` & `container.last`
|
||||
|
||||
The first/last child of the container.
|
||||
|
||||
```js
|
||||
selector.first === selector.nodes[0];
|
||||
selector.last === selector.nodes[selector.nodes.length - 1];
|
||||
```
|
||||
|
||||
### `container.at(index)`
|
||||
|
||||
Returns the node at position `index`.
|
||||
|
||||
```js
|
||||
selector.at(0) === selector.first;
|
||||
selector.at(0) === selector.nodes[0];
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `index`: The index of the node to return.
|
||||
|
||||
### `container.atPosition(line, column)`
|
||||
|
||||
Returns the node at the source position `index`.
|
||||
|
||||
```js
|
||||
selector.at(0) === selector.first;
|
||||
selector.at(0) === selector.nodes[0];
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `index`: The index of the node to return.
|
||||
|
||||
### `container.index(node)`
|
||||
|
||||
Return the index of the node within its container.
|
||||
|
||||
```js
|
||||
selector.index(selector.nodes[2]) // => 2
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `node`: A node within the current container.
|
||||
|
||||
### `container.length`
|
||||
|
||||
Proxy to the length of the container's nodes.
|
||||
|
||||
```js
|
||||
container.length === container.nodes.length
|
||||
```
|
||||
|
||||
### `container` Array iterators
|
||||
|
||||
The container class provides proxies to certain Array methods; these are:
|
||||
|
||||
* `container.map === container.nodes.map`
|
||||
* `container.reduce === container.nodes.reduce`
|
||||
* `container.every === container.nodes.every`
|
||||
* `container.some === container.nodes.some`
|
||||
* `container.filter === container.nodes.filter`
|
||||
* `container.sort === container.nodes.sort`
|
||||
|
||||
Note that these methods only work on a container's immediate children; recursive
|
||||
iteration is provided by `container.walk`.
|
||||
|
||||
### `container.each(callback)`
|
||||
|
||||
Iterate the container's immediate children, calling `callback` for each child.
|
||||
You may return `false` within the callback to break the iteration.
|
||||
|
||||
```js
|
||||
let className;
|
||||
selectors.each((selector, index) => {
|
||||
if (selector.type === 'class') {
|
||||
className = selector.value;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Note that unlike `Array#forEach()`, this iterator is safe to use whilst adding
|
||||
or removing nodes from the container.
|
||||
|
||||
Arguments:
|
||||
|
||||
* `callback (function)`: A function to call for each node, which receives `node`
|
||||
and `index` arguments.
|
||||
|
||||
### `container.walk(callback)`
|
||||
|
||||
Like `container#each`, but will also iterate child nodes as long as they are
|
||||
`container` types.
|
||||
|
||||
```js
|
||||
selectors.walk((selector, index) => {
|
||||
// all nodes
|
||||
});
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `callback (function)`: A function to call for each node, which receives `node`
|
||||
and `index` arguments.
|
||||
|
||||
This iterator is safe to use whilst mutating `container.nodes`,
|
||||
like `container#each`.
|
||||
|
||||
### `container.walk` proxies
|
||||
|
||||
The container class provides proxy methods for iterating over types of nodes,
|
||||
so that it is easier to write modules that target specific selectors. Those
|
||||
methods are:
|
||||
|
||||
* `container.walkAttributes`
|
||||
* `container.walkClasses`
|
||||
* `container.walkCombinators`
|
||||
* `container.walkComments`
|
||||
* `container.walkIds`
|
||||
* `container.walkNesting`
|
||||
* `container.walkPseudos`
|
||||
* `container.walkTags`
|
||||
* `container.walkUniversals`
|
||||
|
||||
### `container.split(callback)`
|
||||
|
||||
This method allows you to split a group of nodes by returning `true` from
|
||||
a callback. It returns an array of arrays, where each inner array corresponds
|
||||
to the groups that you created via the callback.
|
||||
|
||||
```js
|
||||
// (input) => h1 h2>>h3
|
||||
const list = selectors.first.split(selector => {
|
||||
return selector.type === 'combinator';
|
||||
});
|
||||
|
||||
// (node values) => [['h1', ' '], ['h2', '>>'], ['h3']]
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `callback (function)`: A function to call for each node, which receives `node`
|
||||
as an argument.
|
||||
|
||||
### `container.prepend(node)` & `container.append(node)`
|
||||
|
||||
Add a node to the start/end of the container. Note that doing so will set
|
||||
the parent property of the node to this container.
|
||||
|
||||
```js
|
||||
const id = parser.id({value: 'search'});
|
||||
selector.append(id);
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `node`: The node to add.
|
||||
|
||||
### `container.insertBefore(old, new)` & `container.insertAfter(old, new)`
|
||||
|
||||
Add a node before or after an existing node in a container:
|
||||
|
||||
```js
|
||||
selectors.walk(selector => {
|
||||
if (selector.type !== 'class') {
|
||||
const className = parser.className({value: 'theme-name'});
|
||||
selector.parent.insertAfter(selector, className);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `old`: The existing node in the container.
|
||||
* `new`: The new node to add before/after the existing node.
|
||||
|
||||
### `container.removeChild(node)`
|
||||
|
||||
Remove the node from the container. Note that you can also use
|
||||
`node.remove()` if you would like to remove just a single node.
|
||||
|
||||
```js
|
||||
selector.length // => 2
|
||||
selector.remove(id)
|
||||
selector.length // => 1;
|
||||
id.parent // undefined
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `node`: The node to remove.
|
||||
|
||||
### `container.removeAll()` or `container.empty()`
|
||||
|
||||
Remove all children from the container.
|
||||
|
||||
```js
|
||||
selector.removeAll();
|
||||
selector.length // => 0
|
||||
```
|
||||
|
||||
## Root nodes
|
||||
|
||||
A root node represents a comma separated list of selectors. Indeed, all
|
||||
a root's `toString()` method does is join its selector children with a ','.
|
||||
Other than this, it has no special functionality and acts like a container.
|
||||
|
||||
### `root.trailingComma`
|
||||
|
||||
This will be set to `true` if the input has a trailing comma, in order to
|
||||
support parsing of legacy CSS hacks.
|
||||
|
||||
## Selector nodes
|
||||
|
||||
A selector node represents a single complex selector. For example, this
|
||||
selector string `h1 h2 h3, [href] > p`, is represented as two selector nodes.
|
||||
It has no special functionality of its own.
|
||||
|
||||
## Pseudo nodes
|
||||
|
||||
A pseudo selector extends a container node; if it has any parameters of its
|
||||
own (such as `h1:not(h2, h3)`), they will be its children. Note that the pseudo
|
||||
`value` will always contain the colons preceding the pseudo identifier. This
|
||||
is so that both `:before` and `::before` are properly represented in the AST.
|
||||
|
||||
## Attribute nodes
|
||||
|
||||
### `attribute.quoted`
|
||||
|
||||
Returns `true` if the attribute's value is wrapped in quotation marks, false if it is not.
|
||||
Remains `undefined` if there is no attribute value.
|
||||
|
||||
```css
|
||||
[href=foo] /* false */
|
||||
[href='foo'] /* true */
|
||||
[href="foo"] /* true */
|
||||
[href] /* undefined */
|
||||
```
|
||||
|
||||
### `attribute.qualifiedAttribute`
|
||||
|
||||
Returns the attribute name qualified with the namespace if one is given.
|
||||
|
||||
### `attribute.offsetOf(part)`
|
||||
|
||||
Returns the offset of the attribute part specified relative to the
|
||||
start of the node of the output string. This is useful in raising
|
||||
error messages about a specific part of the attribute, especially
|
||||
in combination with `attribute.sourceIndex`.
|
||||
|
||||
Returns `-1` if the name is invalid or the value doesn't exist in this
|
||||
attribute.
|
||||
|
||||
The legal values for `part` are:
|
||||
|
||||
* `"ns"` - alias for "namespace"
|
||||
* `"namespace"` - the namespace if it exists.
|
||||
* `"attribute"` - the attribute name
|
||||
* `"attributeNS"` - the start of the attribute or its namespace
|
||||
* `"operator"` - the match operator of the attribute
|
||||
* `"value"` - The value (string or identifier)
|
||||
* `"insensitive"` - the case insensitivity flag
|
||||
|
||||
### `attribute.raws.unquoted`
|
||||
|
||||
Returns the unquoted content of the attribute's value.
|
||||
Remains `undefined` if there is no attribute value.
|
||||
|
||||
```css
|
||||
[href=foo] /* foo */
|
||||
[href='foo'] /* foo */
|
||||
[href="foo"] /* foo */
|
||||
[href] /* undefined */
|
||||
```
|
||||
|
||||
### `attribute.spaces`
|
||||
|
||||
Like `node.spaces` with the `before` and `after` values containing the spaces
|
||||
around the element, the parts of the attribute can also have spaces before
|
||||
and after them. The for each of `attribute`, `operator`, `value` and
|
||||
`insensitive` there is corresponding property of the same nam in
|
||||
`node.spaces` that has an optional `before` or `after` string containing only
|
||||
whitespace.
|
||||
|
||||
Note that corresponding values in `attributes.raws.spaces` contain values
|
||||
including any comments. If set, these values will override the
|
||||
`attribute.spaces` value. Take care to remove them if changing
|
||||
`attribute.spaces`.
|
||||
|
||||
### `attribute.raws`
|
||||
|
||||
The raws object stores comments and other information necessary to re-render
|
||||
the node exactly as it was in the source.
|
||||
|
||||
If a comment is embedded within the identifiers for the `namespace`, `attribute`
|
||||
or `value` then a property is placed in the raws for that value containing the full source of the propery including comments.
|
||||
|
||||
If a comment is embedded within the space between parts of the attribute
|
||||
then the raw for that space is set accordingly.
|
||||
|
||||
Setting an attribute's property `raws` value to be deleted.
|
||||
|
||||
For now, changing the spaces required also updating or removing any of the
|
||||
raws values that override them.
|
||||
|
||||
Example: `[ /*before*/ href /* after-attr */ = /* after-operator */ te/*inside-value*/st/* wow */ /*omg*/i/*bbq*/ /*whodoesthis*/]` would parse as:
|
||||
|
||||
```js
|
||||
{
|
||||
attribute: "href",
|
||||
operatator: "=",
|
||||
value: "test",
|
||||
spaces: {
|
||||
before: '',
|
||||
after: '',
|
||||
attribute: { before: ' ', after: ' ' },
|
||||
operator: { after: ' ' },
|
||||
value: { after: ' ' },
|
||||
insensitive: { after: ' ' }
|
||||
},
|
||||
raws: {
|
||||
spaces: {
|
||||
attribute: { before: ' /*before*/ ', after: ' /* after-attr */ ' },
|
||||
operator: { after: ' /* after-operator */ ' },
|
||||
value: { after: '/* wow */ /*omg*/' },
|
||||
insensitive: { after: '/*bbq*/ /*whodoesthis*/' }
|
||||
},
|
||||
unquoted: 'test',
|
||||
value: 'te/*inside-value*/st'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## `Processor`
|
||||
|
||||
### `ProcessorOptions`
|
||||
|
||||
* `lossless` - When `true`, whitespace is preserved. Defaults to `true`.
|
||||
* `updateSelector` - When `true`, if any processor methods are passed a postcss
|
||||
`Rule` node instead of a string, then that Rule's selector is updated
|
||||
with the results of the processing. Defaults to `true`.
|
||||
|
||||
### `process|processSync(selectors, [options])`
|
||||
|
||||
Processes the `selectors`, returning a string from the result of processing.
|
||||
|
||||
Note: when the `updateSelector` option is set, the rule's selector
|
||||
will be updated with the resulting string.
|
||||
|
||||
**Example:**
|
||||
|
||||
```js
|
||||
const parser = require("postcss-selector-parser");
|
||||
const processor = parser();
|
||||
|
||||
let result = processor.processSync(' .class');
|
||||
console.log(result);
|
||||
// => .class
|
||||
|
||||
// Asynchronous operation
|
||||
let promise = processor.process(' .class').then(result => {
|
||||
console.log(result)
|
||||
// => .class
|
||||
});
|
||||
|
||||
// To have the parser normalize whitespace values, utilize the options
|
||||
result = processor.processSync(' .class ', {lossless: false});
|
||||
console.log(result);
|
||||
// => .class
|
||||
|
||||
// For better syntax errors, pass a PostCSS Rule node.
|
||||
const postcss = require('postcss');
|
||||
rule = postcss.rule({selector: ' #foo > a, .class '});
|
||||
processor.process(rule, {lossless: false, updateSelector: true}).then(result => {
|
||||
console.log(result);
|
||||
// => #foo>a,.class
|
||||
console.log("rule:", rule.selector);
|
||||
// => rule: #foo>a,.class
|
||||
})
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `selectors (string|postcss.Rule)`: Either a selector string or a PostCSS Rule
|
||||
node.
|
||||
* `[options] (object)`: Process options
|
||||
|
||||
|
||||
### `ast|astSync(selectors, [options])`
|
||||
|
||||
Like `process()` and `processSync()` but after
|
||||
processing the `selectors` these methods return the `Root` node of the result
|
||||
instead of a string.
|
||||
|
||||
Note: when the `updateSelector` option is set, the rule's selector
|
||||
will be updated with the resulting string.
|
||||
|
||||
### `transform|transformSync(selectors, [options])`
|
||||
|
||||
Like `process()` and `processSync()` but after
|
||||
processing the `selectors` these methods return the value returned by the
|
||||
processor callback.
|
||||
|
||||
Note: when the `updateSelector` option is set, the rule's selector
|
||||
will be updated with the resulting string.
|
||||
|
||||
### Error Handling Within Selector Processors
|
||||
|
||||
The root node passed to the selector processor callback
|
||||
has a method `error(message, options)` that returns an
|
||||
error object. This method should always be used to raise
|
||||
errors relating to the syntax of selectors. The options
|
||||
to this method are passed to postcss's error constructor
|
||||
([documentation](http://api.postcss.org/Container.html#error)).
|
||||
|
||||
#### Async Error Example
|
||||
|
||||
```js
|
||||
let processor = (root) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
root.walkClasses((classNode) => {
|
||||
if (/^(.*)[-_]/.test(classNode.value)) {
|
||||
let msg = "classes may not have underscores or dashes in them";
|
||||
reject(root.error(msg, {
|
||||
index: classNode.sourceIndex + RegExp.$1.length + 1,
|
||||
word: classNode.value
|
||||
}));
|
||||
}
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
const postcss = require("postcss");
|
||||
const parser = require("postcss-selector-parser");
|
||||
const selectorProcessor = parser(processor);
|
||||
const plugin = postcss.plugin('classValidator', (options) => {
|
||||
return (root) => {
|
||||
let promises = [];
|
||||
root.walkRules(rule => {
|
||||
promises.push(selectorProcessor.process(rule));
|
||||
});
|
||||
return Promise.all(promises);
|
||||
};
|
||||
});
|
||||
postcss(plugin()).process(`
|
||||
.foo-bar {
|
||||
color: red;
|
||||
}
|
||||
`.trim(), {from: 'test.css'}).catch((e) => console.error(e.toString()));
|
||||
|
||||
// CssSyntaxError: classValidator: ./test.css:1:5: classes may not have underscores or dashes in them
|
||||
//
|
||||
// > 1 | .foo-bar {
|
||||
// | ^
|
||||
// 2 | color: red;
|
||||
// 3 | }
|
||||
```
|
||||
|
||||
#### Synchronous Error Example
|
||||
|
||||
```js
|
||||
let processor = (root) => {
|
||||
root.walkClasses((classNode) => {
|
||||
if (/.*[-_]/.test(classNode.value)) {
|
||||
let msg = "classes may not have underscores or dashes in them";
|
||||
throw root.error(msg, {
|
||||
index: classNode.sourceIndex,
|
||||
word: classNode.value
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const postcss = require("postcss");
|
||||
const parser = require("postcss-selector-parser");
|
||||
const selectorProcessor = parser(processor);
|
||||
const plugin = postcss.plugin('classValidator', (options) => {
|
||||
return (root) => {
|
||||
root.walkRules(rule => {
|
||||
selectorProcessor.processSync(rule);
|
||||
});
|
||||
};
|
||||
});
|
||||
postcss(plugin()).process(`
|
||||
.foo-bar {
|
||||
color: red;
|
||||
}
|
||||
`.trim(), {from: 'test.css'}).catch((e) => console.error(e.toString()));
|
||||
|
||||
// CssSyntaxError: classValidator: ./test.css:1:5: classes may not have underscores or dashes in them
|
||||
//
|
||||
// > 1 | .foo-bar {
|
||||
// | ^
|
||||
// 2 | color: red;
|
||||
// 3 | }
|
||||
```
|
||||
466
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser/CHANGELOG.md
generated
vendored
Normal file
466
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,466 @@
|
||||
# 5.0.0
|
||||
|
||||
- Allow escaped dot within class name.
|
||||
- Update PostCSS to 7.0.7 (patch)
|
||||
|
||||
# 5.0.0-rc.4
|
||||
|
||||
- Fixed and issue where comments immediately after an insensitive
|
||||
(in attribute) were not parsed correctly.
|
||||
- Updated `cssesc` to 2.0.0 (major).
|
||||
- Removed outdated integration tests.
|
||||
- Added tests for custom selectors, tags with attributes, the universal
|
||||
selector with pseudos, and tokens after combinators.
|
||||
|
||||
# 5.0.0-rc.1
|
||||
|
||||
To ease adoption of the v5.0 release, we have relaxed the node version
|
||||
check performed by npm at installation time to allow for node 4, which
|
||||
remains officially unsupported, but likely to continue working for the
|
||||
time being.
|
||||
|
||||
# 5.0.0-rc.0
|
||||
|
||||
This release has **BREAKING CHANGES** that were required to fix regressions
|
||||
in 4.0.0 and to make the Combinator Node API consistent for all combinator
|
||||
types. Please read carefully.
|
||||
|
||||
## Summary of Changes
|
||||
|
||||
* The way a descendent combinator that isn't a single space character (E.g. `.a .b`) is stored in the AST has changed.
|
||||
* Named Combinators (E.g. `.a /for/ .b`) are now properly parsed as a combinator.
|
||||
* It is now possible to look up a node based on the source location of a character in that node and to query nodes if they contain some character.
|
||||
* Several bug fixes that caused the parser to hang and run out of memory when a `/` was encountered have been fixed.
|
||||
* The minimum supported version of Node is now `v6.0.0`.
|
||||
|
||||
### Changes to the Descendent Combinator
|
||||
|
||||
In prior releases, the value of a descendant combinator with multiple spaces included all the spaces.
|
||||
|
||||
* `.a .b`: Extra spaces are now stored as space before.
|
||||
- Old & Busted:
|
||||
- `combinator.value === " "`
|
||||
- New hotness:
|
||||
- `combinator.value === " " && combinator.spaces.before === " "`
|
||||
* `.a /*comment*/.b`: A comment at the end of the combinator causes extra space to become after space.
|
||||
- Old & Busted:
|
||||
- `combinator.value === " "`
|
||||
- `combinator.raws.value === " /*comment/"`
|
||||
- New hotness:
|
||||
- `combinator.value === " "`
|
||||
- `combinator.spaces.after === " "`
|
||||
- `combinator.raws.spaces.after === " /*comment*/"`
|
||||
* `.a<newline>.b`: whitespace that doesn't start or end with a single space character is stored as a raw value.
|
||||
- Old & Busted:
|
||||
- `combinator.value === "\n"`
|
||||
- `combinator.raws.value === undefined`
|
||||
- New hotness:
|
||||
- `combinator.value === " "`
|
||||
- `combinator.raws.value === "\n"`
|
||||
|
||||
### Support for "Named Combinators"
|
||||
|
||||
Although, nonstandard and unlikely to ever become a standard, combinators like `/deep/` and `/for/` are now properly supported.
|
||||
|
||||
Because they've been taken off the standardization track, there is no spec-official name for combinators of the form `/<ident>/`. However, I talked to [Tab Atkins](https://twitter.com/tabatkins) and we agreed to call them "named combinators" so now they are called that.
|
||||
|
||||
Before this release such named combinators were parsed without intention and generated three nodes of type `"tag"` where the first and last nodes had a value of `"/"`.
|
||||
|
||||
* `.a /for/ .b` is parsed as a combinator.
|
||||
- Old & Busted:
|
||||
- `root.nodes[0].nodes[1].type === "tag"`
|
||||
- `root.nodes[0].nodes[1].value === "/"`
|
||||
- New hotness:
|
||||
- `root.nodes[0].nodes[1].type === "combinator"`
|
||||
- `root.nodes[0].nodes[1].value === "/for/"`
|
||||
* `.a /F\6fR/ .b` escapes are handled and uppercase is normalized.
|
||||
- Old & Busted:
|
||||
- `root.nodes[0].nodes[2].type === "tag"`
|
||||
- `root.nodes[0].nodes[2].value === "F\\6fR"`
|
||||
- New hotness:
|
||||
- `root.nodes[0].nodes[1].type === "combinator"`
|
||||
- `root.nodes[0].nodes[1].value === "/for/"`
|
||||
- `root.nodes[0].nodes[1].raws.value === "/F\\6fR/"`
|
||||
|
||||
### Source position checks and lookups
|
||||
|
||||
A new API was added to look up a node based on the source location.
|
||||
|
||||
```js
|
||||
const selectorParser = require("postcss-selector-parser");
|
||||
// You can find the most specific node for any given character
|
||||
let combinator = selectorParser.astSync(".a > .b").atPosition(1,4);
|
||||
combinator.toString() === " > ";
|
||||
// You can check if a node includes a specific character
|
||||
// Whitespace surrounding the node that is owned by that node
|
||||
// is included in the check.
|
||||
[2,3,4,5,6].map(column => combinator.isAtPosition(1, column));
|
||||
// => [false, true, true, true, false]
|
||||
```
|
||||
|
||||
# 4.0.0
|
||||
|
||||
This release has **BREAKING CHANGES** that were required to fix bugs regarding values with escape sequences. Please read carefully.
|
||||
|
||||
* **Identifiers with escapes** - CSS escape sequences are now hidden from the public API by default.
|
||||
The normal value of a node like a class name or ID, or an aspect of a node such as attribute
|
||||
selector's value, is unescaped. Escapes representing Non-ascii characters are unescaped into
|
||||
unicode characters. For example: `bu\tton, .\31 00, #i\2764\FE0Fu, [attr="value is \"quoted\""]`
|
||||
will parse respectively to the values `button`, `100`, `i❤️u`, `value is "quoted"`.
|
||||
The original escape sequences for these values can be found in the corresponding property name
|
||||
in `node.raws`. Where possible, deprecation warnings were added, but the nature
|
||||
of escape handling makes it impossible to detect what is escaped or not. Our expectation is
|
||||
that most users are neither expecting nor handling escape sequences in their use of this library,
|
||||
and so for them, this is a bug fix. Users who are taking care to handle escapes correctly can
|
||||
now update their code to remove the escape handling and let us do it for them.
|
||||
|
||||
* **Mutating values with escapes** - When you make an update to a node property that has escape handling
|
||||
The value is assumed to be unescaped, and any special characters are escaped automatically and
|
||||
the corresponding `raws` value is immediately updated. This can result in changes to the original
|
||||
escape format. Where the exact value of the escape sequence is important there are methods that
|
||||
allow both values to be set in conjunction. There are a number of new convenience methods for
|
||||
manipulating values that involve escapes, especially for attributes values where the quote mark
|
||||
is involved. See https://github.com/postcss/postcss-selector-parser/pull/133 for an extensive
|
||||
write-up on these changes.
|
||||
|
||||
|
||||
**Upgrade/API Example**
|
||||
|
||||
In `3.x` there was no unescape handling and internal consistency of several properties was the caller's job to maintain. It was very easy for the developer
|
||||
to create a CSS file that did not parse correctly when some types of values
|
||||
were in use.
|
||||
|
||||
```js
|
||||
const selectorParser = require("postcss-selector-parser");
|
||||
let attr = selectorParser.attribute({attribute: "id", operator: "=", value: "a-value"});
|
||||
attr.value; // => "a-value"
|
||||
attr.toString(); // => [id=a-value]
|
||||
// Add quotes to an attribute's value.
|
||||
// All these values have to be set by the caller to be consistent:
|
||||
// no internal consistency is maintained.
|
||||
attr.raws.unquoted = attr.value
|
||||
attr.value = "'" + attr.value + "'";
|
||||
attr.value; // => "'a-value'"
|
||||
attr.quoted = true;
|
||||
attr.toString(); // => "[id='a-value']"
|
||||
```
|
||||
|
||||
In `4.0` there is a convenient API for setting and mutating values
|
||||
that may need escaping. Especially for attributes.
|
||||
|
||||
```js
|
||||
const selectorParser = require("postcss-selector-parser");
|
||||
|
||||
// The constructor requires you specify the exact escape sequence
|
||||
let className = selectorParser.className({value: "illegal class name", raws: {value: "illegal\\ class\\ name"}});
|
||||
className.toString(); // => '.illegal\\ class\\ name'
|
||||
|
||||
// So it's better to set the value as a property
|
||||
className = selectorParser.className();
|
||||
// Most properties that deal with identifiers work like this
|
||||
className.value = "escape for me";
|
||||
className.value; // => 'escape for me'
|
||||
className.toString(); // => '.escape\\ for\\ me'
|
||||
|
||||
// emoji and all non-ascii are escaped to ensure it works in every css file.
|
||||
className.value = "😱🦄😍";
|
||||
className.value; // => '😱🦄😍'
|
||||
className.toString(); // => '.\\1F631\\1F984\\1F60D'
|
||||
|
||||
// you can control the escape sequence if you want, or do bad bad things
|
||||
className.setPropertyAndEscape('value', 'xxxx', 'yyyy');
|
||||
className.value; // => "xxxx"
|
||||
className.toString(); // => ".yyyy"
|
||||
|
||||
// Pass a value directly through to the css output without escaping it.
|
||||
className.setPropertyWithoutEscape('value', '$REPLACE_ME$');
|
||||
className.value; // => "$REPLACE_ME$"
|
||||
className.toString(); // => ".$REPLACE_ME$"
|
||||
|
||||
// The biggest changes are to the Attribute class
|
||||
// passing quoteMark explicitly is required to avoid a deprecation warning.
|
||||
let attr = selectorParser.attribute({attribute: "id", operator: "=", value: "a-value", quoteMark: null});
|
||||
attr.toString(); // => "[id=a-value]"
|
||||
// Get the value with quotes on it and any necessary escapes.
|
||||
// This is the same as reading attr.value in 3.x.
|
||||
attr.getQuotedValue(); // => "a-value";
|
||||
attr.quoteMark; // => null
|
||||
|
||||
// Add quotes to an attribute's value.
|
||||
attr.quoteMark = "'"; // This is all that's required.
|
||||
attr.toString(); // => "[id='a-value']"
|
||||
attr.quoted; // => true
|
||||
// The value is still the same, only the quotes have changed.
|
||||
attr.value; // => a-value
|
||||
attr.getQuotedValue(); // => "'a-value'";
|
||||
|
||||
// deprecated assignment, no warning because there's no escapes
|
||||
attr.value = "new-value";
|
||||
// no quote mark is needed so it is removed
|
||||
attr.getQuotedValue(); // => "new-value";
|
||||
|
||||
// deprecated assignment,
|
||||
attr.value = "\"a 'single quoted' value\"";
|
||||
// > (node:27859) DeprecationWarning: Assigning an attribute a value containing characters that might need to be escaped is deprecated. Call attribute.setValue() instead.
|
||||
attr.getQuotedValue(); // => '"a \'single quoted\' value"';
|
||||
// quote mark inferred from first and last characters.
|
||||
attr.quoteMark; // => '"'
|
||||
|
||||
// setValue takes options to make manipulating the value simple.
|
||||
attr.setValue('foo', {smart: true});
|
||||
// foo doesn't require any escapes or quotes.
|
||||
attr.toString(); // => '[id=foo]'
|
||||
attr.quoteMark; // => null
|
||||
|
||||
// An explicit quote mark can be specified
|
||||
attr.setValue('foo', {quoteMark: '"'});
|
||||
attr.toString(); // => '[id="foo"]'
|
||||
|
||||
// preserves quote mark by default
|
||||
attr.setValue('bar');
|
||||
attr.toString(); // => '[id="bar"]'
|
||||
attr.quoteMark = null;
|
||||
attr.toString(); // => '[id=bar]'
|
||||
|
||||
// with no arguments, it preserves quote mark even when it's not a great idea
|
||||
attr.setValue('a value \n that should be quoted');
|
||||
attr.toString(); // => '[id=a\\ value\\ \\A\\ that\\ should\\ be\\ quoted]'
|
||||
|
||||
// smart preservation with a specified default
|
||||
attr.setValue('a value \n that should be quoted', {smart: true, preferCurrentQuoteMark: true, quoteMark: "'"});
|
||||
// => "[id='a value \\A that should be quoted']"
|
||||
attr.quoteMark = '"';
|
||||
// => '[id="a value \\A that should be quoted"]'
|
||||
|
||||
// this keeps double quotes because it wants to quote the value and the existing value has double quotes.
|
||||
attr.setValue('this should be quoted', {smart: true, preferCurrentQuoteMark: true, quoteMark: "'"});
|
||||
// => '[id="this should be quoted"]'
|
||||
|
||||
// picks single quotes because the value has double quotes
|
||||
attr.setValue('a "double quoted" value', {smart: true, preferCurrentQuoteMark: true, quoteMark: "'"});
|
||||
// => "[id='a "double quoted" value']"
|
||||
|
||||
// setPropertyAndEscape lets you do anything you want. Even things that are a bad idea and illegal.
|
||||
attr.setPropertyAndEscape('value', 'xxxx', 'the password is 42');
|
||||
attr.value; // => "xxxx"
|
||||
attr.toString(); // => "[id=the password is 42]"
|
||||
|
||||
// Pass a value directly through to the css output without escaping it.
|
||||
attr.setPropertyWithoutEscape('value', '$REPLACEMENT$');
|
||||
attr.value; // => "$REPLACEMENT$"
|
||||
attr.toString(); // => "[id=$REPLACEMENT$]"
|
||||
```
|
||||
|
||||
# 3.1.2
|
||||
|
||||
* Fix: Removed dot-prop dependency since it's no longer written in es5.
|
||||
|
||||
# 3.1.1
|
||||
|
||||
* Fix: typescript definitions weren't in the published package.
|
||||
|
||||
# 3.1.0
|
||||
|
||||
* Fixed numerous bugs in attribute nodes relating to the handling of comments
|
||||
and whitespace. There's significant changes to `attrNode.spaces` and `attrNode.raws` since the `3.0.0` release.
|
||||
* Added `Attribute#offsetOf(part)` to get the offset location of
|
||||
attribute parts like `"operator"` and `"value"`. This is most
|
||||
often added to `Attribute#sourceIndex` for error reporting.
|
||||
|
||||
# 3.0.0
|
||||
|
||||
## Breaking changes
|
||||
|
||||
* Some tweaks to the tokenizer/attribute selector parsing mean that whitespace
|
||||
locations might be slightly different to the 2.x code.
|
||||
* Better attribute selector parsing with more validation; postcss-selector-parser
|
||||
no longer uses regular expressions to parse attribute selectors.
|
||||
* Added an async API (thanks to @jacobp100); the default `process` API is now
|
||||
async, and the sync API is now accessed through `processSync` instead.
|
||||
* `process()` and `processSync()` now return a string instead of the Processor
|
||||
instance.
|
||||
* Tweaks handling of Less interpolation (thanks to @jwilsson).
|
||||
* Removes support for Node 0.12.
|
||||
|
||||
## Other changes
|
||||
|
||||
* `ast()` and `astSync()` methods have been added to the `Processor`. These
|
||||
return the `Root` node of the selectors after processing them.
|
||||
* `transform()` and `transformSync()` methods have been added to the
|
||||
`Processor`. These return the value returned by the processor callback
|
||||
after processing the selectors.
|
||||
* Set the parent when inserting a node (thanks to @chriseppstein).
|
||||
* Correctly adjust indices when using insertBefore/insertAfter (thanks to @tivac).
|
||||
* Fixes handling of namespaces with qualified tag selectors.
|
||||
* `process`, `ast` and `transform` (and their sync variants) now accept a
|
||||
`postcss` rule node. When provided, better errors are generated and selector
|
||||
processing is automatically set back to the rule selector (unless the `updateSelector` option is set to `false`.)
|
||||
* Now more memory efficient when tokenizing selectors.
|
||||
|
||||
### Upgrade hints
|
||||
|
||||
The pattern of:
|
||||
|
||||
`rule.selector = processor.process(rule.selector).result.toString();`
|
||||
|
||||
is now:
|
||||
|
||||
`processor.processSync(rule)`
|
||||
|
||||
# 2.2.3
|
||||
|
||||
* Resolves an issue where the parser would not reduce multiple spaces between an
|
||||
ampersand and another simple selector in lossy mode (thanks to @adam-26).
|
||||
|
||||
# 2.2.2
|
||||
|
||||
* No longer hangs on an unescaped semicolon; instead the parser will throw
|
||||
an exception for these cases.
|
||||
|
||||
# 2.2.1
|
||||
|
||||
* Allows a consumer to specify whitespace tokens when creating a new Node
|
||||
(thanks to @Semigradsky).
|
||||
|
||||
# 2.2.0
|
||||
|
||||
* Added a new option to normalize whitespace when parsing the selector string
|
||||
(thanks to @adam-26).
|
||||
|
||||
# 2.1.1
|
||||
|
||||
* Better unquoted value handling within attribute selectors
|
||||
(thanks to @evilebottnawi).
|
||||
|
||||
# 2.1.0
|
||||
|
||||
* Added: Use string constants for all node types & expose them on the main
|
||||
parser instance (thanks to @Aweary).
|
||||
|
||||
# 2.0.0
|
||||
|
||||
This release contains the following breaking changes:
|
||||
|
||||
* Renamed all `eachInside` iterators to `walk`. For example, `eachTag` is now
|
||||
`walkTags`, and `eachInside` is now `walk`.
|
||||
* Renamed `Node#removeSelf()` to `Node#remove()`.
|
||||
* Renamed `Container#remove()` to `Container#removeChild()`.
|
||||
* Renamed `Node#raw` to `Node#raws` (thanks to @davidtheclark).
|
||||
* Now parses `&` as the *nesting* selector, rather than a *tag* selector.
|
||||
* Fixes misinterpretation of Sass interpolation (e.g. `#{foo}`) as an
|
||||
id selector (thanks to @davidtheclark).
|
||||
|
||||
and;
|
||||
|
||||
* Fixes parsing of attribute selectors with equals signs in them
|
||||
(e.g. `[data-attr="foo=bar"]`) (thanks to @montmanu).
|
||||
* Adds `quoted` and `raw.unquoted` properties to attribute nodes
|
||||
(thanks to @davidtheclark).
|
||||
|
||||
# 1.3.3
|
||||
|
||||
* Fixes an infinite loop on `)` and `]` tokens when they had no opening pairs.
|
||||
Now postcss-selector-parser will throw when it encounters these lone tokens.
|
||||
|
||||
# 1.3.2
|
||||
|
||||
* Now uses plain integers rather than `str.charCodeAt(0)` for compiled builds.
|
||||
|
||||
# 1.3.1
|
||||
|
||||
* Update flatten to v1.x (thanks to @shinnn).
|
||||
|
||||
# 1.3.0
|
||||
|
||||
* Adds a new node type, `String`, to fix a crash on selectors such as
|
||||
`foo:bar("test")`.
|
||||
|
||||
# 1.2.1
|
||||
|
||||
* Fixes a crash when the parser encountered a trailing combinator.
|
||||
|
||||
# 1.2.0
|
||||
|
||||
* A more descriptive error is thrown when the parser expects to find a
|
||||
pseudo-class/pseudo-element (thanks to @ashelley).
|
||||
* Adds support for line/column locations for selector nodes, as well as a
|
||||
`Node#sourceIndex` method (thanks to @davidtheclark).
|
||||
|
||||
# 1.1.4
|
||||
|
||||
* Fixes a crash when a selector started with a `>` combinator. The module will
|
||||
now no longer throw if a selector has a leading/trailing combinator node.
|
||||
|
||||
# 1.1.3
|
||||
|
||||
* Fixes a crash on `@` tokens.
|
||||
|
||||
# 1.1.2
|
||||
|
||||
* Fixes an infinite loop caused by using parentheses in a non-pseudo element
|
||||
context.
|
||||
|
||||
# 1.1.1
|
||||
|
||||
* Fixes a crash when a backslash ended a selector string.
|
||||
|
||||
# 1.1.0
|
||||
|
||||
* Adds support for replacing multiple nodes at once with `replaceWith`
|
||||
(thanks to @jonathantneal).
|
||||
* Parser no longer throws on sequential IDs and trailing commas, to support
|
||||
parsing of selector hacks.
|
||||
|
||||
# 1.0.1
|
||||
|
||||
* Fixes using `insertAfter` and `insertBefore` during iteration.
|
||||
|
||||
# 1.0.0
|
||||
|
||||
* Adds `clone` and `replaceWith` methods to nodes.
|
||||
* Adds `insertBefore` and `insertAfter` to containers.
|
||||
* Stabilises API.
|
||||
|
||||
# 0.0.5
|
||||
|
||||
* Fixes crash on extra whitespace inside a pseudo selector's parentheses.
|
||||
* Adds sort function to the container class.
|
||||
* Enables the parser to pass its input through without transforming.
|
||||
* Iteration-safe `each` and `eachInside`.
|
||||
|
||||
# 0.0.4
|
||||
|
||||
* Tidy up redundant duplication.
|
||||
* Fixes a bug where the parser would loop infinitely on universal selectors
|
||||
inside pseudo selectors.
|
||||
* Adds `length` getter and `eachInside`, `map`, `reduce` to the container class.
|
||||
* When a selector has been removed from the tree, the root node will no longer
|
||||
cast it to a string.
|
||||
* Adds node type iterators to the container class (e.g. `eachComment`).
|
||||
* Adds filter function to the container class.
|
||||
* Adds split function to the container class.
|
||||
* Create new node types by doing `parser.id(opts)` etc.
|
||||
* Adds support for pseudo classes anywhere in the selector.
|
||||
|
||||
# 0.0.3
|
||||
|
||||
* Adds `next` and `prev` to the node class.
|
||||
* Adds `first` and `last` getters to the container class.
|
||||
* Adds `every` and `some` iterators to the container class.
|
||||
* Add `empty` alias for `removeAll`.
|
||||
* Combinators are now types of node.
|
||||
* Fixes the at method so that it is not an alias for `index`.
|
||||
* Tidy up creation of new nodes in the parser.
|
||||
* Refactors how namespaces are handled for consistency & less redundant code.
|
||||
* Refactors AST to use `nodes` exclusively, and eliminates excessive nesting.
|
||||
* Fixes nested pseudo parsing.
|
||||
* Fixes whitespace parsing.
|
||||
|
||||
# 0.0.2
|
||||
|
||||
* Adds support for namespace selectors.
|
||||
* Adds support for selectors joined by escaped spaces - such as `.\31\ 0`.
|
||||
|
||||
# 0.0.1
|
||||
|
||||
* Initial release.
|
||||
22
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser/LICENSE-MIT
generated
vendored
Normal file
22
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser/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.
|
||||
49
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser/README.md
generated
vendored
Normal file
49
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser/README.md
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
# postcss-selector-parser [](https://travis-ci.org/postcss/postcss-selector-parser)
|
||||
|
||||
> Selector parser with built in methods for working with selector strings.
|
||||
|
||||
## Install
|
||||
|
||||
With [npm](https://npmjs.com/package/postcss-selector-parser) do:
|
||||
|
||||
```
|
||||
npm install postcss-selector-parser
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
```js
|
||||
const parser = require('postcss-selector-parser');
|
||||
const transform = selectors => {
|
||||
selectors.walk(selector => {
|
||||
// do something with the selector
|
||||
console.log(String(selector))
|
||||
});
|
||||
};
|
||||
|
||||
const transformed = parser(transform).processSync('h1, h2, h3');
|
||||
```
|
||||
|
||||
To normalize selector whitespace:
|
||||
|
||||
```js
|
||||
const parser = require('postcss-selector-parser');
|
||||
const normalized = parser().processSync('h1, h2, h3', {lossless: false});
|
||||
// -> h1,h2,h3
|
||||
```
|
||||
|
||||
Async support is provided through `parser.process` and will resolve a Promise
|
||||
with the resulting selector string.
|
||||
|
||||
## API
|
||||
|
||||
Please see [API.md](API.md).
|
||||
|
||||
## Credits
|
||||
|
||||
* Huge thanks to Andrey Sitnik (@ai) for work on PostCSS which helped
|
||||
accelerate this module's development.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
76
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser/package.json
generated
vendored
Normal file
76
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser/package.json
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"name": "postcss-selector-parser",
|
||||
"version": "5.0.0",
|
||||
"devDependencies": {
|
||||
"ava": "^0.25.0",
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-eslint": "^8.2.3",
|
||||
"babel-plugin-add-module-exports": "^0.2.0",
|
||||
"babel-plugin-precompile-charcodes": "^1.1.0",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"babel-preset-es2015-loose": "^7.0.0",
|
||||
"babel-preset-stage-0": "^6.24.1",
|
||||
"babel-register": "^6.26.0",
|
||||
"coveralls": "^3.0.2",
|
||||
"del-cli": "^1.1.0",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-plugin-babel": "^3.3.0",
|
||||
"eslint-plugin-import": "^2.14.0",
|
||||
"glob": "^7.1.3",
|
||||
"minimist": "^1.2.0",
|
||||
"nyc": "^11.7.3",
|
||||
"postcss": "^7.0.7",
|
||||
"semver": "^5.6.0"
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"types": "postcss-selector-parser.d.ts",
|
||||
"files": [
|
||||
"API.md",
|
||||
"CHANGELOG.md",
|
||||
"LICENSE-MIT",
|
||||
"dist",
|
||||
"postcss-selector-parser.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"pretest": "eslint src",
|
||||
"prepare": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/",
|
||||
"lintfix": "eslint --fix src",
|
||||
"report": "nyc report --reporter=html",
|
||||
"test": "nyc ava src/__tests__/*.js",
|
||||
"testone": "ava"
|
||||
},
|
||||
"dependencies": {
|
||||
"cssesc": "^2.0.0",
|
||||
"indexes-of": "^1.0.1",
|
||||
"uniq": "^1.0.1"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"homepage": "https://github.com/postcss/postcss-selector-parser",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Ben Briggs",
|
||||
"email": "beneb.info@gmail.com",
|
||||
"url": "http://beneb.info"
|
||||
},
|
||||
{
|
||||
"name": "Chris Eppstein",
|
||||
"email": "chris@eppsteins.net",
|
||||
"url": "http://twitter.com/chriseppstein"
|
||||
}
|
||||
],
|
||||
"repository": "postcss/postcss-selector-parser",
|
||||
"ava": {
|
||||
"require": "babel-register",
|
||||
"concurrency": 5
|
||||
},
|
||||
"nyc": {
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"**/__tests__"
|
||||
]
|
||||
}
|
||||
}
|
||||
499
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser/postcss-selector-parser.d.ts
generated
vendored
Normal file
499
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser/postcss-selector-parser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,499 @@
|
||||
// Type definitions for postcss-selector-parser 2.2.3
|
||||
// Definitions by: Chris Eppstein <chris@eppsteins.net>
|
||||
|
||||
/*~ Note that ES6 modules cannot directly export callable functions.
|
||||
*~ This file should be imported using the CommonJS-style:
|
||||
*~ import x = require('someLibrary');
|
||||
*~
|
||||
*~ Refer to the documentation to understand common
|
||||
*~ workarounds for this limitation of ES6 modules.
|
||||
*/
|
||||
|
||||
/*~ This declaration specifies that the function
|
||||
*~ is the exported object from the file
|
||||
*/
|
||||
export = parser;
|
||||
|
||||
// TODO: Conditional types in TS 1.8 will really clean this up.
|
||||
declare function parser(): parser.Processor<never>;
|
||||
declare function parser<Transform>(processor: parser.AsyncProcessor<Transform>): parser.Processor<Transform, never>;
|
||||
declare function parser(processor: parser.AsyncProcessor<void>): parser.Processor<never, never>;
|
||||
declare function parser<Transform>(processor: parser.SyncProcessor<Transform>): parser.Processor<Transform>;
|
||||
declare function parser(processor: parser.SyncProcessor<void>): parser.Processor<never>;
|
||||
declare function parser<Transform>(processor?: parser.SyncProcessor<Transform> | parser.AsyncProcessor<Transform>): parser.Processor<Transform>;
|
||||
|
||||
/*~ If you want to expose types from your module as well, you can
|
||||
*~ place them in this block. Often you will want to describe the
|
||||
*~ shape of the return type of the function; that type should
|
||||
*~ be declared in here, as this example shows.
|
||||
*/
|
||||
declare namespace parser {
|
||||
/* copied from postcss -- so we don't need to add a dependency */
|
||||
type ErrorOptions = {
|
||||
plugin?: string;
|
||||
word?: string;
|
||||
index?: number
|
||||
};
|
||||
/* the bits we use of postcss.Rule, copied from postcss -- so we don't need to add a dependency */
|
||||
type PostCSSRuleNode = {
|
||||
selector: string
|
||||
/**
|
||||
* @returns postcss.CssSyntaxError but it's a complex object, caller
|
||||
* should cast to it if they have a dependency on postcss.
|
||||
*/
|
||||
error(message: string, options?: ErrorOptions): Error;
|
||||
};
|
||||
/** Accepts a string */
|
||||
type Selectors = string | PostCSSRuleNode
|
||||
type ProcessorFn<ReturnType = void> = (root: parser.Root) => ReturnType;
|
||||
type SyncProcessor<Transform = void> = ProcessorFn<Transform>;
|
||||
type AsyncProcessor<Transform = void> = ProcessorFn<PromiseLike<Transform>>;
|
||||
|
||||
const TAG: "tag";
|
||||
const STRING: "string";
|
||||
const SELECTOR: "selector";
|
||||
const ROOT: "root";
|
||||
const PSEUDO: "pseudo";
|
||||
const NESTING: "nesting";
|
||||
const ID: "id";
|
||||
const COMMENT: "comment";
|
||||
const COMBINATOR: "combinator";
|
||||
const CLASS: "class";
|
||||
const ATTRIBUTE: "attribute";
|
||||
const UNIVERSAL: "universal";
|
||||
|
||||
interface NodeTypes {
|
||||
tag: Tag,
|
||||
string: String,
|
||||
selector: Selector,
|
||||
root: Root,
|
||||
pseudo: Pseudo,
|
||||
nesting: Nesting,
|
||||
id: Identifier,
|
||||
comment: Comment,
|
||||
combinator: Combinator,
|
||||
class: ClassName,
|
||||
attribute: Attribute,
|
||||
universal: Universal
|
||||
}
|
||||
|
||||
type Node = NodeTypes[keyof NodeTypes];
|
||||
|
||||
function isNode(node: any): node is Node;
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* Preserve whitespace when true. Default: false;
|
||||
*/
|
||||
lossless: boolean;
|
||||
/**
|
||||
* When true and a postcss.Rule is passed, set the result of
|
||||
* processing back onto the rule when done. Default: false.
|
||||
*/
|
||||
updateSelector: boolean;
|
||||
}
|
||||
class Processor<
|
||||
TransformType = never,
|
||||
SyncSelectorsType extends Selectors | never = Selectors
|
||||
> {
|
||||
res: Root;
|
||||
readonly result: String;
|
||||
ast(selectors: Selectors, options?: Partial<Options>): Promise<Root>;
|
||||
astSync(selectors: SyncSelectorsType, options?: Partial<Options>): Root;
|
||||
transform(selectors: Selectors, options?: Partial<Options>): Promise<TransformType>;
|
||||
transformSync(selectors: SyncSelectorsType, options?: Partial<Options>): TransformType;
|
||||
process(selectors: Selectors, options?: Partial<Options>): Promise<string>;
|
||||
processSync(selectors: SyncSelectorsType, options?: Partial<Options>): string;
|
||||
}
|
||||
interface ParserOptions {
|
||||
css: string;
|
||||
error: (message: string, options: ErrorOptions) => Error;
|
||||
options: Options;
|
||||
}
|
||||
class Parser {
|
||||
input: ParserOptions;
|
||||
lossy: boolean;
|
||||
position: number;
|
||||
root: Root;
|
||||
selectors: string;
|
||||
current: Selector;
|
||||
constructor(input: ParserOptions);
|
||||
/**
|
||||
* Raises an error, if the processor is invoked on
|
||||
* a postcss Rule node, a better error message is raised.
|
||||
*/
|
||||
error(message: string, options?: ErrorOptions): void;
|
||||
}
|
||||
interface NodeSource {
|
||||
start?: {
|
||||
line: number,
|
||||
column: number
|
||||
},
|
||||
end?: {
|
||||
line: number,
|
||||
column: number
|
||||
}
|
||||
}
|
||||
interface SpaceAround {
|
||||
before: string;
|
||||
after: string;
|
||||
}
|
||||
interface Spaces extends SpaceAround {
|
||||
[spaceType: string]: string | Partial<SpaceAround> | undefined;
|
||||
}
|
||||
interface NodeOptions<Value = string> {
|
||||
value: Value;
|
||||
spaces?: Partial<Spaces>;
|
||||
source?: NodeSource;
|
||||
sourceIndex?: number;
|
||||
}
|
||||
interface Base<
|
||||
Value extends string | undefined = string,
|
||||
ParentType extends Container | undefined = Container | undefined
|
||||
> {
|
||||
type: keyof NodeTypes;
|
||||
parent: ParentType;
|
||||
value: Value;
|
||||
spaces: Spaces;
|
||||
source?: NodeSource;
|
||||
sourceIndex: number;
|
||||
rawSpaceBefore: string;
|
||||
rawSpaceAfter: string;
|
||||
remove(): Node;
|
||||
replaceWith(...nodes: Node[]): Node;
|
||||
next(): Node;
|
||||
prev(): Node;
|
||||
clone(opts: {[override: string]:any}): Node;
|
||||
/**
|
||||
* Return whether this node includes the character at the position of the given line and column.
|
||||
* Returns undefined if the nodes lack sufficient source metadata to determine the position.
|
||||
* @param line 1-index based line number relative to the start of the selector.
|
||||
* @param column 1-index based column number relative to the start of the selector.
|
||||
*/
|
||||
isAtPosition(line: number, column: number): boolean | undefined;
|
||||
/**
|
||||
* Some non-standard syntax doesn't follow normal escaping rules for css,
|
||||
* this allows the escaped value to be specified directly, allowing illegal characters to be
|
||||
* directly inserted into css output.
|
||||
* @param name the property to set
|
||||
* @param value the unescaped value of the property
|
||||
* @param valueEscaped optional. the escaped value of the property.
|
||||
*/
|
||||
setPropertyAndEscape(name: string, value: any, valueEscaped: string): void;
|
||||
/**
|
||||
* When you want a value to passed through to CSS directly. This method
|
||||
* deletes the corresponding raw value causing the stringifier to fallback
|
||||
* to the unescaped value.
|
||||
* @param name the property to set.
|
||||
* @param value The value that is both escaped and unescaped.
|
||||
*/
|
||||
setPropertyWithoutEscape(name: string, value: any): void;
|
||||
/**
|
||||
* Some non-standard syntax doesn't follow normal escaping rules for css.
|
||||
* This allows non standard syntax to be appended to an existing property
|
||||
* by specifying the escaped value. By specifying the escaped value,
|
||||
* illegal characters are allowed to be directly inserted into css output.
|
||||
* @param {string} name the property to set
|
||||
* @param {any} value the unescaped value of the property
|
||||
* @param {string} valueEscaped optional. the escaped value of the property.
|
||||
*/
|
||||
appendToPropertyAndEscape(name: string, value: any, valueEscaped: string): void;
|
||||
toString(): string;
|
||||
}
|
||||
interface ContainerOptions extends NodeOptions {
|
||||
nodes?: Array<Node>;
|
||||
}
|
||||
interface Container<Value extends string | undefined = string> extends Base<Value> {
|
||||
nodes: Array<Node>;
|
||||
append(selector: Selector): Container;
|
||||
prepend(selector: Selector): Container;
|
||||
at(index: number): Node;
|
||||
/**
|
||||
* Return the most specific node at the line and column number given.
|
||||
* The source location is based on the original parsed location, locations aren't
|
||||
* updated as selector nodes are mutated.
|
||||
*
|
||||
* Note that this location is relative to the location of the first character
|
||||
* of the selector, and not the location of the selector in the overall document
|
||||
* when used in conjunction with postcss.
|
||||
*
|
||||
* If not found, returns undefined.
|
||||
* @param line The line number of the node to find. (1-based index)
|
||||
* @param col The column number of the node to find. (1-based index)
|
||||
*/
|
||||
atPosition(line: number, column: number): Node;
|
||||
index(child: Node): number;
|
||||
readonly first: Node;
|
||||
readonly last: Node;
|
||||
readonly length: number;
|
||||
removeChild(child: Node): Container;
|
||||
removeAll(): Container;
|
||||
empty(): Container;
|
||||
insertAfter(oldNode: Node, newNode: Node): Container;
|
||||
insertBefore(oldNode: Node, newNode: Node): Container;
|
||||
each(callback: (node: Node) => boolean | void): boolean | undefined;
|
||||
walk(callback: (node: Node) => boolean | void): boolean | undefined;
|
||||
walkAttributes(callback: (node: Node) => boolean | void): boolean | undefined;
|
||||
walkClasses(callback: (node: Node) => boolean | void): boolean | undefined;
|
||||
walkCombinators(callback: (node: Node) => boolean | void): boolean | undefined;
|
||||
walkComments(callback: (node: Node) => boolean | void): boolean | undefined;
|
||||
walkIds(callback: (node: Node) => boolean | void): boolean | undefined;
|
||||
walkNesting(callback: (node: Node) => boolean | void): boolean | undefined;
|
||||
walkPseudos(callback: (node: Node) => boolean | void): boolean | undefined;
|
||||
walkTags(callback: (node: Node) => boolean | void): boolean | undefined;
|
||||
split(callback: (node: Node) => boolean): [Node[], Node[]];
|
||||
map(callback: (node: Node) => Node): Node[];
|
||||
reduce<T>(callback: (node: Node) => Node, memo: T): T;
|
||||
every(callback: (node: Node) => boolean): boolean;
|
||||
some(callback: (node: Node) => boolean): boolean;
|
||||
filter(callback: (node: Node) => boolean): Node[];
|
||||
sort(callback: (nodeA: Node, nodeB: Node) => number): Node[];
|
||||
toString(): string;
|
||||
}
|
||||
function isContainer(node: any): node is Root | Selector | Pseudo;
|
||||
|
||||
interface NamespaceOptions<Value extends string | undefined = string> extends NodeOptions<Value> {
|
||||
namespace?: string | true;
|
||||
}
|
||||
interface Namespace<Value extends string | undefined = string> extends Base<Value> {
|
||||
/** alias for namespace */
|
||||
ns: string | true;
|
||||
/**
|
||||
* namespace prefix.
|
||||
*/
|
||||
namespace: string | true;
|
||||
/**
|
||||
* If a namespace exists, prefix the value provided with it, separated by |.
|
||||
*/
|
||||
qualifiedName(value: string): string;
|
||||
/**
|
||||
* A string representing the namespace suitable for output.
|
||||
*/
|
||||
readonly namespaceString: string;
|
||||
}
|
||||
function isNamespace(node: any): node is Attribute | Tag;
|
||||
|
||||
interface Root extends Container<undefined> {
|
||||
type: "root";
|
||||
/**
|
||||
* Raises an error, if the processor is invoked on
|
||||
* a postcss Rule node, a better error message is raised.
|
||||
*/
|
||||
error(message: string, options?: ErrorOptions): Error;
|
||||
nodeAt(line: number, column: number): Node
|
||||
}
|
||||
function root(opts: ContainerOptions): Root;
|
||||
function isRoot(node: any): node is Root;
|
||||
|
||||
interface Selector extends Container {
|
||||
type: "selector";
|
||||
}
|
||||
function selector(opts: ContainerOptions): Selector;
|
||||
function isSelector(node: any): node is Selector;
|
||||
|
||||
interface Combinator extends Base {
|
||||
type: "combinator"
|
||||
}
|
||||
function combinator(opts: NodeOptions): Combinator;
|
||||
function isCombinator(node: any): node is Combinator;
|
||||
|
||||
interface ClassName extends Base {
|
||||
type: "class";
|
||||
}
|
||||
function className(opts: NamespaceOptions): ClassName;
|
||||
function isClassName(node: any): node is ClassName;
|
||||
|
||||
type AttributeOperator = "=" | "~=" | "|=" | "^=" | "$=" | "*=";
|
||||
type QuoteMark = '"' | "'" | null;
|
||||
interface PreferredQuoteMarkOptions {
|
||||
quoteMark?: QuoteMark;
|
||||
preferCurrentQuoteMark?: boolean;
|
||||
}
|
||||
interface SmartQuoteMarkOptions extends PreferredQuoteMarkOptions {
|
||||
smart?: boolean;
|
||||
}
|
||||
interface AttributeOptions extends NamespaceOptions<string | undefined> {
|
||||
attribute: string;
|
||||
operator?: AttributeOperator;
|
||||
insensitive?: boolean;
|
||||
quoteMark?: QuoteMark;
|
||||
/** @deprecated Use quoteMark instead. */
|
||||
quoted?: boolean;
|
||||
spaces?: {
|
||||
before?: string;
|
||||
after?: string;
|
||||
attribute?: Partial<SpaceAround>;
|
||||
operator?: Partial<SpaceAround>;
|
||||
value?: Partial<SpaceAround>;
|
||||
insensitive?: Partial<SpaceAround>;
|
||||
}
|
||||
raws: {
|
||||
unquoted?: string;
|
||||
attribute?: string;
|
||||
operator?: string;
|
||||
value?: string;
|
||||
insensitive?: string;
|
||||
spaces?: {
|
||||
attribute?: Partial<Spaces>;
|
||||
operator?: Partial<Spaces>;
|
||||
value?: Partial<Spaces>;
|
||||
insensitive?: Partial<Spaces>;
|
||||
}
|
||||
};
|
||||
}
|
||||
interface Attribute extends Namespace<string | undefined> {
|
||||
type: "attribute";
|
||||
attribute: string;
|
||||
operator?: AttributeOperator;
|
||||
insensitive?: boolean;
|
||||
quoteMark: QuoteMark;
|
||||
quoted?: boolean;
|
||||
spaces: {
|
||||
before: string;
|
||||
after: string;
|
||||
attribute?: Partial<Spaces>;
|
||||
operator?: Partial<Spaces>;
|
||||
value?: Partial<Spaces>;
|
||||
insensitive?: Partial<Spaces>;
|
||||
}
|
||||
raws: {
|
||||
/** @deprecated The attribute value is unquoted, use that instead.. */
|
||||
unquoted?: string;
|
||||
attribute?: string;
|
||||
operator?: string;
|
||||
/** The value of the attribute with quotes and escapes. */
|
||||
value?: string;
|
||||
insensitive?: string;
|
||||
spaces?: {
|
||||
attribute?: Partial<Spaces>;
|
||||
operator?: Partial<Spaces>;
|
||||
value?: Partial<Spaces>;
|
||||
insensitive?: Partial<Spaces>;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* The attribute name after having been qualified with a namespace.
|
||||
*/
|
||||
readonly qualifiedAttribute: string;
|
||||
|
||||
/**
|
||||
* The case insensitivity flag or an empty string depending on whether this
|
||||
* attribute is case insensitive.
|
||||
*/
|
||||
readonly insensitiveFlag : 'i' | '';
|
||||
|
||||
/**
|
||||
* Returns the attribute's value quoted such that it would be legal to use
|
||||
* in the value of a css file. The original value's quotation setting
|
||||
* used for stringification is left unchanged. See `setValue(value, options)`
|
||||
* if you want to control the quote settings of a new value for the attribute or
|
||||
* `set quoteMark(mark)` if you want to change the quote settings of the current
|
||||
* value.
|
||||
*
|
||||
* You can also change the quotation used for the current value by setting quoteMark.
|
||||
**/
|
||||
getQuotedValue(options?: SmartQuoteMarkOptions): string;
|
||||
|
||||
/**
|
||||
* Set the unescaped value with the specified quotation options. The value
|
||||
* provided must not include any wrapping quote marks -- those quotes will
|
||||
* be interpreted as part of the value and escaped accordingly.
|
||||
* @param value
|
||||
*/
|
||||
setValue(value: string, options?: SmartQuoteMarkOptions): void;
|
||||
|
||||
/**
|
||||
* Intelligently select a quoteMark value based on the value's contents. If
|
||||
* the value is a legal CSS ident, it will not be quoted. Otherwise a quote
|
||||
* mark will be picked that minimizes the number of escapes.
|
||||
*
|
||||
* If there's no clear winner, the quote mark from these options is used,
|
||||
* then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
|
||||
* true). If the quoteMark is unspecified, a double quote is used.
|
||||
**/
|
||||
smartQuoteMark(options: PreferredQuoteMarkOptions): QuoteMark;
|
||||
|
||||
/**
|
||||
* Selects the preferred quote mark based on the options and the current quote mark value.
|
||||
* If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
|
||||
* instead.
|
||||
*/
|
||||
preferredQuoteMark(options: PreferredQuoteMarkOptions): QuoteMark
|
||||
|
||||
/**
|
||||
* returns the offset of the attribute part specified relative to the
|
||||
* start of the node of the output string.
|
||||
*
|
||||
* * "ns" - alias for "namespace"
|
||||
* * "namespace" - the namespace if it exists.
|
||||
* * "attribute" - the attribute name
|
||||
* * "attributeNS" - the start of the attribute or its namespace
|
||||
* * "operator" - the match operator of the attribute
|
||||
* * "value" - The value (string or identifier)
|
||||
* * "insensitive" - the case insensitivity flag;
|
||||
* @param part One of the possible values inside an attribute.
|
||||
* @returns -1 if the name is invalid or the value doesn't exist in this attribute.
|
||||
*/
|
||||
offsetOf(part: "ns" | "namespace" | "attribute" | "attributeNS" | "operator" | "value" | "insensitive"): number;
|
||||
}
|
||||
function attribute(opts: AttributeOptions): Attribute;
|
||||
function isAttribute(node: any): node is Attribute;
|
||||
|
||||
interface Pseudo extends Container {
|
||||
type: "pseudo";
|
||||
}
|
||||
function pseudo(opts: ContainerOptions): Pseudo;
|
||||
/**
|
||||
* Checks wether the node is the Psuedo subtype of node.
|
||||
*/
|
||||
function isPseudo(node: any): node is Pseudo;
|
||||
|
||||
/**
|
||||
* Checks wether the node is, specifically, a pseudo element instead of
|
||||
* pseudo class.
|
||||
*/
|
||||
function isPseudoElement(node: any): node is Pseudo;
|
||||
|
||||
/**
|
||||
* Checks wether the node is, specifically, a pseudo class instead of
|
||||
* pseudo element.
|
||||
*/
|
||||
function isPseudoClass(node: any): node is Pseudo;
|
||||
|
||||
|
||||
interface Tag extends Namespace {
|
||||
type: "tag";
|
||||
}
|
||||
function tag(opts: NamespaceOptions): Tag;
|
||||
function isTag(node: any): node is Tag;
|
||||
|
||||
interface Comment extends Base {
|
||||
type: "comment";
|
||||
}
|
||||
function comment(opts: NodeOptions): Comment;
|
||||
function isComment(node: any): node is Comment;
|
||||
|
||||
interface Identifier extends Base {
|
||||
type: "id";
|
||||
}
|
||||
function id(opts: any): any;
|
||||
function isIdentifier(node: any): node is Identifier;
|
||||
|
||||
interface Nesting extends Base {
|
||||
type: "nesting";
|
||||
}
|
||||
function nesting(opts: any): any;
|
||||
function isNesting(node: any): node is Nesting;
|
||||
|
||||
interface String extends Base {
|
||||
type: "string";
|
||||
}
|
||||
function string(opts: NodeOptions): String;
|
||||
function isString(node: any): node is String;
|
||||
|
||||
interface Universal extends Base {
|
||||
type: "universal";
|
||||
}
|
||||
function universal(opts?: NamespaceOptions): any;
|
||||
function isUniversal(node: any): node is Universal;
|
||||
}
|
||||
20
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss/LICENSE
generated
vendored
Normal file
20
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2013 Andrey Sitnik <andrey@sitnik.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.
|
||||
43
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss/README.md
generated
vendored
Normal file
43
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss/README.md
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# PostCSS [![Gitter][chat-img]][chat]
|
||||
|
||||
<img align="right" width="95" height="95"
|
||||
alt="Philosopher’s stone, logo of PostCSS"
|
||||
src="http://postcss.github.io/postcss/logo.svg">
|
||||
|
||||
[chat-img]: https://img.shields.io/badge/Gitter-Join_the_PostCSS_chat-brightgreen.svg
|
||||
[chat]: https://gitter.im/postcss/postcss
|
||||
|
||||
PostCSS is a tool for transforming styles with JS plugins.
|
||||
These plugins can lint your CSS, support variables and mixins,
|
||||
transpile future CSS syntax, inline images, and more.
|
||||
|
||||
PostCSS is used by industry leaders including Wikipedia, Twitter, Alibaba,
|
||||
and JetBrains. The [Autoprefixer] PostCSS plugin is one of the most popular
|
||||
CSS processors.
|
||||
|
||||
PostCSS takes a CSS file and provides an API to analyze and modify its rules
|
||||
(by transforming them into an [Abstract Syntax Tree]).
|
||||
This API can then be used by [plugins] to do a lot of useful things,
|
||||
e.g. to find errors automatically insert vendor prefixes.
|
||||
|
||||
**Support / Discussion:** [Gitter](https://gitter.im/postcss/postcss)<br>
|
||||
**Twitter account:** [@postcss](https://twitter.com/postcss)<br>
|
||||
**VK.com page:** [postcss](https://vk.com/postcss)<br>
|
||||
**中文翻译**: [`README-cn.md`](./README-cn.md)
|
||||
|
||||
For PostCSS commercial support (consulting, improving the front-end culture
|
||||
of your company, PostCSS plugins), contact [Evil Martians]
|
||||
at <surrender@evilmartians.com>.
|
||||
|
||||
[Abstract Syntax Tree]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
|
||||
[Evil Martians]: https://evilmartians.com/?utm_source=postcss
|
||||
[Autoprefixer]: https://github.com/postcss/autoprefixer
|
||||
[plugins]: https://github.com/postcss/postcss#plugins
|
||||
|
||||
<a href="https://evilmartians.com/?utm_source=postcss">
|
||||
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
|
||||
alt="Sponsored by Evil Martians" width="236" height="54">
|
||||
</a>
|
||||
|
||||
## Docs
|
||||
Read **[full docs](https://github.com/postcss/postcss#readme)** on GitHub.
|
||||
37
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss/package.json
generated
vendored
Normal file
37
backend/frontend/node_modules/postcss-custom-selectors/node_modules/postcss/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "postcss",
|
||||
"version": "7.0.39",
|
||||
"description": "Tool for transforming styles with JS plugins",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"css",
|
||||
"postcss",
|
||||
"rework",
|
||||
"preprocessor",
|
||||
"parser",
|
||||
"source map",
|
||||
"transform",
|
||||
"manipulation",
|
||||
"transpiler"
|
||||
],
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/postcss/"
|
||||
},
|
||||
"author": "Andrey Sitnik <andrey@sitnik.ru>",
|
||||
"license": "MIT",
|
||||
"homepage": "https://postcss.org/",
|
||||
"repository": "postcss/postcss",
|
||||
"dependencies": {
|
||||
"picocolors": "^0.2.1",
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
"main": "lib/postcss",
|
||||
"types": "lib/postcss.d.ts",
|
||||
"browser": {
|
||||
"./lib/terminal-highlight": false,
|
||||
"fs": false
|
||||
}
|
||||
}
|
||||
301
backend/frontend/node_modules/postcss-custom-selectors/node_modules/source-map/CHANGELOG.md
generated
vendored
Normal file
301
backend/frontend/node_modules/postcss-custom-selectors/node_modules/source-map/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,301 @@
|
||||
# Change Log
|
||||
|
||||
## 0.5.6
|
||||
|
||||
* Fix for regression when people were using numbers as names in source maps. See
|
||||
#236.
|
||||
|
||||
## 0.5.5
|
||||
|
||||
* Fix "regression" of unsupported, implementation behavior that half the world
|
||||
happens to have come to depend on. See #235.
|
||||
|
||||
* Fix regression involving function hoisting in SpiderMonkey. See #233.
|
||||
|
||||
## 0.5.4
|
||||
|
||||
* Large performance improvements to source-map serialization. See #228 and #229.
|
||||
|
||||
## 0.5.3
|
||||
|
||||
* Do not include unnecessary distribution files. See
|
||||
commit ef7006f8d1647e0a83fdc60f04f5a7ca54886f86.
|
||||
|
||||
## 0.5.2
|
||||
|
||||
* Include browser distributions of the library in package.json's `files`. See
|
||||
issue #212.
|
||||
|
||||
## 0.5.1
|
||||
|
||||
* Fix latent bugs in IndexedSourceMapConsumer.prototype._parseMappings. See
|
||||
ff05274becc9e6e1295ed60f3ea090d31d843379.
|
||||
|
||||
## 0.5.0
|
||||
|
||||
* Node 0.8 is no longer supported.
|
||||
|
||||
* Use webpack instead of dryice for bundling.
|
||||
|
||||
* Big speedups serializing source maps. See pull request #203.
|
||||
|
||||
* Fix a bug with `SourceMapConsumer.prototype.sourceContentFor` and sources that
|
||||
explicitly start with the source root. See issue #199.
|
||||
|
||||
## 0.4.4
|
||||
|
||||
* Fix an issue where using a `SourceMapGenerator` after having created a
|
||||
`SourceMapConsumer` from it via `SourceMapConsumer.fromSourceMap` failed. See
|
||||
issue #191.
|
||||
|
||||
* Fix an issue with where `SourceMapGenerator` would mistakenly consider
|
||||
different mappings as duplicates of each other and avoid generating them. See
|
||||
issue #192.
|
||||
|
||||
## 0.4.3
|
||||
|
||||
* A very large number of performance improvements, particularly when parsing
|
||||
source maps. Collectively about 75% of time shaved off of the source map
|
||||
parsing benchmark!
|
||||
|
||||
* Fix a bug in `SourceMapConsumer.prototype.allGeneratedPositionsFor` and fuzzy
|
||||
searching in the presence of a column option. See issue #177.
|
||||
|
||||
* Fix a bug with joining a source and its source root when the source is above
|
||||
the root. See issue #182.
|
||||
|
||||
* Add the `SourceMapConsumer.prototype.hasContentsOfAllSources` method to
|
||||
determine when all sources' contents are inlined into the source map. See
|
||||
issue #190.
|
||||
|
||||
## 0.4.2
|
||||
|
||||
* Add an `.npmignore` file so that the benchmarks aren't pulled down by
|
||||
dependent projects. Issue #169.
|
||||
|
||||
* Add an optional `column` argument to
|
||||
`SourceMapConsumer.prototype.allGeneratedPositionsFor` and better handle lines
|
||||
with no mappings. Issues #172 and #173.
|
||||
|
||||
## 0.4.1
|
||||
|
||||
* Fix accidentally defining a global variable. #170.
|
||||
|
||||
## 0.4.0
|
||||
|
||||
* The default direction for fuzzy searching was changed back to its original
|
||||
direction. See #164.
|
||||
|
||||
* There is now a `bias` option you can supply to `SourceMapConsumer` to control
|
||||
the fuzzy searching direction. See #167.
|
||||
|
||||
* About an 8% speed up in parsing source maps. See #159.
|
||||
|
||||
* Added a benchmark for parsing and generating source maps.
|
||||
|
||||
## 0.3.0
|
||||
|
||||
* Change the default direction that searching for positions fuzzes when there is
|
||||
not an exact match. See #154.
|
||||
|
||||
* Support for environments using json2.js for JSON serialization. See #156.
|
||||
|
||||
## 0.2.0
|
||||
|
||||
* Support for consuming "indexed" source maps which do not have any remote
|
||||
sections. See pull request #127. This introduces a minor backwards
|
||||
incompatibility if you are monkey patching `SourceMapConsumer.prototype`
|
||||
methods.
|
||||
|
||||
## 0.1.43
|
||||
|
||||
* Performance improvements for `SourceMapGenerator` and `SourceNode`. See issue
|
||||
#148 for some discussion and issues #150, #151, and #152 for implementations.
|
||||
|
||||
## 0.1.42
|
||||
|
||||
* Fix an issue where `SourceNode`s from different versions of the source-map
|
||||
library couldn't be used in conjunction with each other. See issue #142.
|
||||
|
||||
## 0.1.41
|
||||
|
||||
* Fix a bug with getting the source content of relative sources with a "./"
|
||||
prefix. See issue #145 and [Bug 1090768](bugzil.la/1090768).
|
||||
|
||||
* Add the `SourceMapConsumer.prototype.computeColumnSpans` method to compute the
|
||||
column span of each mapping.
|
||||
|
||||
* Add the `SourceMapConsumer.prototype.allGeneratedPositionsFor` method to find
|
||||
all generated positions associated with a given original source and line.
|
||||
|
||||
## 0.1.40
|
||||
|
||||
* Performance improvements for parsing source maps in SourceMapConsumer.
|
||||
|
||||
## 0.1.39
|
||||
|
||||
* Fix a bug where setting a source's contents to null before any source content
|
||||
had been set before threw a TypeError. See issue #131.
|
||||
|
||||
## 0.1.38
|
||||
|
||||
* Fix a bug where finding relative paths from an empty path were creating
|
||||
absolute paths. See issue #129.
|
||||
|
||||
## 0.1.37
|
||||
|
||||
* Fix a bug where if the source root was an empty string, relative source paths
|
||||
would turn into absolute source paths. Issue #124.
|
||||
|
||||
## 0.1.36
|
||||
|
||||
* Allow the `names` mapping property to be an empty string. Issue #121.
|
||||
|
||||
## 0.1.35
|
||||
|
||||
* A third optional parameter was added to `SourceNode.fromStringWithSourceMap`
|
||||
to specify a path that relative sources in the second parameter should be
|
||||
relative to. Issue #105.
|
||||
|
||||
* If no file property is given to a `SourceMapGenerator`, then the resulting
|
||||
source map will no longer have a `null` file property. The property will
|
||||
simply not exist. Issue #104.
|
||||
|
||||
* Fixed a bug where consecutive newlines were ignored in `SourceNode`s.
|
||||
Issue #116.
|
||||
|
||||
## 0.1.34
|
||||
|
||||
* Make `SourceNode` work with windows style ("\r\n") newlines. Issue #103.
|
||||
|
||||
* Fix bug involving source contents and the
|
||||
`SourceMapGenerator.prototype.applySourceMap`. Issue #100.
|
||||
|
||||
## 0.1.33
|
||||
|
||||
* Fix some edge cases surrounding path joining and URL resolution.
|
||||
|
||||
* Add a third parameter for relative path to
|
||||
`SourceMapGenerator.prototype.applySourceMap`.
|
||||
|
||||
* Fix issues with mappings and EOLs.
|
||||
|
||||
## 0.1.32
|
||||
|
||||
* Fixed a bug where SourceMapConsumer couldn't handle negative relative columns
|
||||
(issue 92).
|
||||
|
||||
* Fixed test runner to actually report number of failed tests as its process
|
||||
exit code.
|
||||
|
||||
* Fixed a typo when reporting bad mappings (issue 87).
|
||||
|
||||
## 0.1.31
|
||||
|
||||
* Delay parsing the mappings in SourceMapConsumer until queried for a source
|
||||
location.
|
||||
|
||||
* Support Sass source maps (which at the time of writing deviate from the spec
|
||||
in small ways) in SourceMapConsumer.
|
||||
|
||||
## 0.1.30
|
||||
|
||||
* Do not join source root with a source, when the source is a data URI.
|
||||
|
||||
* Extend the test runner to allow running single specific test files at a time.
|
||||
|
||||
* Performance improvements in `SourceNode.prototype.walk` and
|
||||
`SourceMapConsumer.prototype.eachMapping`.
|
||||
|
||||
* Source map browser builds will now work inside Workers.
|
||||
|
||||
* Better error messages when attempting to add an invalid mapping to a
|
||||
`SourceMapGenerator`.
|
||||
|
||||
## 0.1.29
|
||||
|
||||
* Allow duplicate entries in the `names` and `sources` arrays of source maps
|
||||
(usually from TypeScript) we are parsing. Fixes github issue 72.
|
||||
|
||||
## 0.1.28
|
||||
|
||||
* Skip duplicate mappings when creating source maps from SourceNode; github
|
||||
issue 75.
|
||||
|
||||
## 0.1.27
|
||||
|
||||
* Don't throw an error when the `file` property is missing in SourceMapConsumer,
|
||||
we don't use it anyway.
|
||||
|
||||
## 0.1.26
|
||||
|
||||
* Fix SourceNode.fromStringWithSourceMap for empty maps. Fixes github issue 70.
|
||||
|
||||
## 0.1.25
|
||||
|
||||
* Make compatible with browserify
|
||||
|
||||
## 0.1.24
|
||||
|
||||
* Fix issue with absolute paths and `file://` URIs. See
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=885597
|
||||
|
||||
## 0.1.23
|
||||
|
||||
* Fix issue with absolute paths and sourcesContent, github issue 64.
|
||||
|
||||
## 0.1.22
|
||||
|
||||
* Ignore duplicate mappings in SourceMapGenerator. Fixes github issue 21.
|
||||
|
||||
## 0.1.21
|
||||
|
||||
* Fixed handling of sources that start with a slash so that they are relative to
|
||||
the source root's host.
|
||||
|
||||
## 0.1.20
|
||||
|
||||
* Fixed github issue #43: absolute URLs aren't joined with the source root
|
||||
anymore.
|
||||
|
||||
## 0.1.19
|
||||
|
||||
* Using Travis CI to run tests.
|
||||
|
||||
## 0.1.18
|
||||
|
||||
* Fixed a bug in the handling of sourceRoot.
|
||||
|
||||
## 0.1.17
|
||||
|
||||
* Added SourceNode.fromStringWithSourceMap.
|
||||
|
||||
## 0.1.16
|
||||
|
||||
* Added missing documentation.
|
||||
|
||||
* Fixed the generating of empty mappings in SourceNode.
|
||||
|
||||
## 0.1.15
|
||||
|
||||
* Added SourceMapGenerator.applySourceMap.
|
||||
|
||||
## 0.1.14
|
||||
|
||||
* The sourceRoot is now handled consistently.
|
||||
|
||||
## 0.1.13
|
||||
|
||||
* Added SourceMapGenerator.fromSourceMap.
|
||||
|
||||
## 0.1.12
|
||||
|
||||
* SourceNode now generates empty mappings too.
|
||||
|
||||
## 0.1.11
|
||||
|
||||
* Added name support to SourceNode.
|
||||
|
||||
## 0.1.10
|
||||
|
||||
* Added sourcesContent support to the customer and generator.
|
||||
28
backend/frontend/node_modules/postcss-custom-selectors/node_modules/source-map/LICENSE
generated
vendored
Normal file
28
backend/frontend/node_modules/postcss-custom-selectors/node_modules/source-map/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
Copyright (c) 2009-2011, Mozilla Foundation and contributors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the Mozilla Foundation nor the names of project
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
742
backend/frontend/node_modules/postcss-custom-selectors/node_modules/source-map/README.md
generated
vendored
Normal file
742
backend/frontend/node_modules/postcss-custom-selectors/node_modules/source-map/README.md
generated
vendored
Normal file
@@ -0,0 +1,742 @@
|
||||
# Source Map
|
||||
|
||||
[](https://travis-ci.org/mozilla/source-map)
|
||||
|
||||
[](https://www.npmjs.com/package/source-map)
|
||||
|
||||
This is a library to generate and consume the source map format
|
||||
[described here][format].
|
||||
|
||||
[format]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
|
||||
|
||||
## Use with Node
|
||||
|
||||
$ npm install source-map
|
||||
|
||||
## Use on the Web
|
||||
|
||||
<script src="https://raw.githubusercontent.com/mozilla/source-map/master/dist/source-map.min.js" defer></script>
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
<!-- `npm run toc` to regenerate the Table of Contents -->
|
||||
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
## Table of Contents
|
||||
|
||||
- [Examples](#examples)
|
||||
- [Consuming a source map](#consuming-a-source-map)
|
||||
- [Generating a source map](#generating-a-source-map)
|
||||
- [With SourceNode (high level API)](#with-sourcenode-high-level-api)
|
||||
- [With SourceMapGenerator (low level API)](#with-sourcemapgenerator-low-level-api)
|
||||
- [API](#api)
|
||||
- [SourceMapConsumer](#sourcemapconsumer)
|
||||
- [new SourceMapConsumer(rawSourceMap)](#new-sourcemapconsumerrawsourcemap)
|
||||
- [SourceMapConsumer.prototype.computeColumnSpans()](#sourcemapconsumerprototypecomputecolumnspans)
|
||||
- [SourceMapConsumer.prototype.originalPositionFor(generatedPosition)](#sourcemapconsumerprototypeoriginalpositionforgeneratedposition)
|
||||
- [SourceMapConsumer.prototype.generatedPositionFor(originalPosition)](#sourcemapconsumerprototypegeneratedpositionfororiginalposition)
|
||||
- [SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition)](#sourcemapconsumerprototypeallgeneratedpositionsfororiginalposition)
|
||||
- [SourceMapConsumer.prototype.hasContentsOfAllSources()](#sourcemapconsumerprototypehascontentsofallsources)
|
||||
- [SourceMapConsumer.prototype.sourceContentFor(source[, returnNullOnMissing])](#sourcemapconsumerprototypesourcecontentforsource-returnnullonmissing)
|
||||
- [SourceMapConsumer.prototype.eachMapping(callback, context, order)](#sourcemapconsumerprototypeeachmappingcallback-context-order)
|
||||
- [SourceMapGenerator](#sourcemapgenerator)
|
||||
- [new SourceMapGenerator([startOfSourceMap])](#new-sourcemapgeneratorstartofsourcemap)
|
||||
- [SourceMapGenerator.fromSourceMap(sourceMapConsumer)](#sourcemapgeneratorfromsourcemapsourcemapconsumer)
|
||||
- [SourceMapGenerator.prototype.addMapping(mapping)](#sourcemapgeneratorprototypeaddmappingmapping)
|
||||
- [SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)](#sourcemapgeneratorprototypesetsourcecontentsourcefile-sourcecontent)
|
||||
- [SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])](#sourcemapgeneratorprototypeapplysourcemapsourcemapconsumer-sourcefile-sourcemappath)
|
||||
- [SourceMapGenerator.prototype.toString()](#sourcemapgeneratorprototypetostring)
|
||||
- [SourceNode](#sourcenode)
|
||||
- [new SourceNode([line, column, source[, chunk[, name]]])](#new-sourcenodeline-column-source-chunk-name)
|
||||
- [SourceNode.fromStringWithSourceMap(code, sourceMapConsumer[, relativePath])](#sourcenodefromstringwithsourcemapcode-sourcemapconsumer-relativepath)
|
||||
- [SourceNode.prototype.add(chunk)](#sourcenodeprototypeaddchunk)
|
||||
- [SourceNode.prototype.prepend(chunk)](#sourcenodeprototypeprependchunk)
|
||||
- [SourceNode.prototype.setSourceContent(sourceFile, sourceContent)](#sourcenodeprototypesetsourcecontentsourcefile-sourcecontent)
|
||||
- [SourceNode.prototype.walk(fn)](#sourcenodeprototypewalkfn)
|
||||
- [SourceNode.prototype.walkSourceContents(fn)](#sourcenodeprototypewalksourcecontentsfn)
|
||||
- [SourceNode.prototype.join(sep)](#sourcenodeprototypejoinsep)
|
||||
- [SourceNode.prototype.replaceRight(pattern, replacement)](#sourcenodeprototypereplacerightpattern-replacement)
|
||||
- [SourceNode.prototype.toString()](#sourcenodeprototypetostring)
|
||||
- [SourceNode.prototype.toStringWithSourceMap([startOfSourceMap])](#sourcenodeprototypetostringwithsourcemapstartofsourcemap)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
|
||||
## Examples
|
||||
|
||||
### Consuming a source map
|
||||
|
||||
```js
|
||||
var rawSourceMap = {
|
||||
version: 3,
|
||||
file: 'min.js',
|
||||
names: ['bar', 'baz', 'n'],
|
||||
sources: ['one.js', 'two.js'],
|
||||
sourceRoot: 'http://example.com/www/js/',
|
||||
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'
|
||||
};
|
||||
|
||||
var smc = new SourceMapConsumer(rawSourceMap);
|
||||
|
||||
console.log(smc.sources);
|
||||
// [ 'http://example.com/www/js/one.js',
|
||||
// 'http://example.com/www/js/two.js' ]
|
||||
|
||||
console.log(smc.originalPositionFor({
|
||||
line: 2,
|
||||
column: 28
|
||||
}));
|
||||
// { source: 'http://example.com/www/js/two.js',
|
||||
// line: 2,
|
||||
// column: 10,
|
||||
// name: 'n' }
|
||||
|
||||
console.log(smc.generatedPositionFor({
|
||||
source: 'http://example.com/www/js/two.js',
|
||||
line: 2,
|
||||
column: 10
|
||||
}));
|
||||
// { line: 2, column: 28 }
|
||||
|
||||
smc.eachMapping(function (m) {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
### Generating a source map
|
||||
|
||||
In depth guide:
|
||||
[**Compiling to JavaScript, and Debugging with Source Maps**](https://hacks.mozilla.org/2013/05/compiling-to-javascript-and-debugging-with-source-maps/)
|
||||
|
||||
#### With SourceNode (high level API)
|
||||
|
||||
```js
|
||||
function compile(ast) {
|
||||
switch (ast.type) {
|
||||
case 'BinaryExpression':
|
||||
return new SourceNode(
|
||||
ast.location.line,
|
||||
ast.location.column,
|
||||
ast.location.source,
|
||||
[compile(ast.left), " + ", compile(ast.right)]
|
||||
);
|
||||
case 'Literal':
|
||||
return new SourceNode(
|
||||
ast.location.line,
|
||||
ast.location.column,
|
||||
ast.location.source,
|
||||
String(ast.value)
|
||||
);
|
||||
// ...
|
||||
default:
|
||||
throw new Error("Bad AST");
|
||||
}
|
||||
}
|
||||
|
||||
var ast = parse("40 + 2", "add.js");
|
||||
console.log(compile(ast).toStringWithSourceMap({
|
||||
file: 'add.js'
|
||||
}));
|
||||
// { code: '40 + 2',
|
||||
// map: [object SourceMapGenerator] }
|
||||
```
|
||||
|
||||
#### With SourceMapGenerator (low level API)
|
||||
|
||||
```js
|
||||
var map = new SourceMapGenerator({
|
||||
file: "source-mapped.js"
|
||||
});
|
||||
|
||||
map.addMapping({
|
||||
generated: {
|
||||
line: 10,
|
||||
column: 35
|
||||
},
|
||||
source: "foo.js",
|
||||
original: {
|
||||
line: 33,
|
||||
column: 2
|
||||
},
|
||||
name: "christopher"
|
||||
});
|
||||
|
||||
console.log(map.toString());
|
||||
// '{"version":3,"file":"source-mapped.js","sources":["foo.js"],"names":["christopher"],"mappings":";;;;;;;;;mCAgCEA"}'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
Get a reference to the module:
|
||||
|
||||
```js
|
||||
// Node.js
|
||||
var sourceMap = require('source-map');
|
||||
|
||||
// Browser builds
|
||||
var sourceMap = window.sourceMap;
|
||||
|
||||
// Inside Firefox
|
||||
const sourceMap = require("devtools/toolkit/sourcemap/source-map.js");
|
||||
```
|
||||
|
||||
### SourceMapConsumer
|
||||
|
||||
A SourceMapConsumer instance represents a parsed source map which we can query
|
||||
for information about the original file positions by giving it a file position
|
||||
in the generated source.
|
||||
|
||||
#### new SourceMapConsumer(rawSourceMap)
|
||||
|
||||
The only parameter is the raw source map (either as a string which can be
|
||||
`JSON.parse`'d, or an object). According to the spec, source maps have the
|
||||
following attributes:
|
||||
|
||||
* `version`: Which version of the source map spec this map is following.
|
||||
|
||||
* `sources`: An array of URLs to the original source files.
|
||||
|
||||
* `names`: An array of identifiers which can be referenced by individual
|
||||
mappings.
|
||||
|
||||
* `sourceRoot`: Optional. The URL root from which all sources are relative.
|
||||
|
||||
* `sourcesContent`: Optional. An array of contents of the original source files.
|
||||
|
||||
* `mappings`: A string of base64 VLQs which contain the actual mappings.
|
||||
|
||||
* `file`: Optional. The generated filename this source map is associated with.
|
||||
|
||||
```js
|
||||
var consumer = new sourceMap.SourceMapConsumer(rawSourceMapJsonData);
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.computeColumnSpans()
|
||||
|
||||
Compute the last column for each generated mapping. The last column is
|
||||
inclusive.
|
||||
|
||||
```js
|
||||
// Before:
|
||||
consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" })
|
||||
// [ { line: 2,
|
||||
// column: 1 },
|
||||
// { line: 2,
|
||||
// column: 10 },
|
||||
// { line: 2,
|
||||
// column: 20 } ]
|
||||
|
||||
consumer.computeColumnSpans();
|
||||
|
||||
// After:
|
||||
consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" })
|
||||
// [ { line: 2,
|
||||
// column: 1,
|
||||
// lastColumn: 9 },
|
||||
// { line: 2,
|
||||
// column: 10,
|
||||
// lastColumn: 19 },
|
||||
// { line: 2,
|
||||
// column: 20,
|
||||
// lastColumn: Infinity } ]
|
||||
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.originalPositionFor(generatedPosition)
|
||||
|
||||
Returns the original source, line, and column information for the generated
|
||||
source's line and column positions provided. The only argument is an object with
|
||||
the following properties:
|
||||
|
||||
* `line`: The line number in the generated source. Line numbers in
|
||||
this library are 1-based (note that the underlying source map
|
||||
specification uses 0-based line numbers -- this library handles the
|
||||
translation).
|
||||
|
||||
* `column`: The column number in the generated source. Column numbers
|
||||
in this library are 0-based.
|
||||
|
||||
* `bias`: Either `SourceMapConsumer.GREATEST_LOWER_BOUND` or
|
||||
`SourceMapConsumer.LEAST_UPPER_BOUND`. Specifies whether to return the closest
|
||||
element that is smaller than or greater than the one we are searching for,
|
||||
respectively, if the exact element cannot be found. Defaults to
|
||||
`SourceMapConsumer.GREATEST_LOWER_BOUND`.
|
||||
|
||||
and an object is returned with the following properties:
|
||||
|
||||
* `source`: The original source file, or null if this information is not
|
||||
available.
|
||||
|
||||
* `line`: The line number in the original source, or null if this information is
|
||||
not available. The line number is 1-based.
|
||||
|
||||
* `column`: The column number in the original source, or null if this
|
||||
information is not available. The column number is 0-based.
|
||||
|
||||
* `name`: The original identifier, or null if this information is not available.
|
||||
|
||||
```js
|
||||
consumer.originalPositionFor({ line: 2, column: 10 })
|
||||
// { source: 'foo.coffee',
|
||||
// line: 2,
|
||||
// column: 2,
|
||||
// name: null }
|
||||
|
||||
consumer.originalPositionFor({ line: 99999999999999999, column: 999999999999999 })
|
||||
// { source: null,
|
||||
// line: null,
|
||||
// column: null,
|
||||
// name: null }
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.generatedPositionFor(originalPosition)
|
||||
|
||||
Returns the generated line and column information for the original source,
|
||||
line, and column positions provided. The only argument is an object with
|
||||
the following properties:
|
||||
|
||||
* `source`: The filename of the original source.
|
||||
|
||||
* `line`: The line number in the original source. The line number is
|
||||
1-based.
|
||||
|
||||
* `column`: The column number in the original source. The column
|
||||
number is 0-based.
|
||||
|
||||
and an object is returned with the following properties:
|
||||
|
||||
* `line`: The line number in the generated source, or null. The line
|
||||
number is 1-based.
|
||||
|
||||
* `column`: The column number in the generated source, or null. The
|
||||
column number is 0-based.
|
||||
|
||||
```js
|
||||
consumer.generatedPositionFor({ source: "example.js", line: 2, column: 10 })
|
||||
// { line: 1,
|
||||
// column: 56 }
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition)
|
||||
|
||||
Returns all generated line and column information for the original source, line,
|
||||
and column provided. If no column is provided, returns all mappings
|
||||
corresponding to a either the line we are searching for or the next closest line
|
||||
that has any mappings. Otherwise, returns all mappings corresponding to the
|
||||
given line and either the column we are searching for or the next closest column
|
||||
that has any offsets.
|
||||
|
||||
The only argument is an object with the following properties:
|
||||
|
||||
* `source`: The filename of the original source.
|
||||
|
||||
* `line`: The line number in the original source. The line number is
|
||||
1-based.
|
||||
|
||||
* `column`: Optional. The column number in the original source. The
|
||||
column number is 0-based.
|
||||
|
||||
and an array of objects is returned, each with the following properties:
|
||||
|
||||
* `line`: The line number in the generated source, or null. The line
|
||||
number is 1-based.
|
||||
|
||||
* `column`: The column number in the generated source, or null. The
|
||||
column number is 0-based.
|
||||
|
||||
```js
|
||||
consumer.allGeneratedpositionsfor({ line: 2, source: "foo.coffee" })
|
||||
// [ { line: 2,
|
||||
// column: 1 },
|
||||
// { line: 2,
|
||||
// column: 10 },
|
||||
// { line: 2,
|
||||
// column: 20 } ]
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.hasContentsOfAllSources()
|
||||
|
||||
Return true if we have the embedded source content for every source listed in
|
||||
the source map, false otherwise.
|
||||
|
||||
In other words, if this method returns `true`, then
|
||||
`consumer.sourceContentFor(s)` will succeed for every source `s` in
|
||||
`consumer.sources`.
|
||||
|
||||
```js
|
||||
// ...
|
||||
if (consumer.hasContentsOfAllSources()) {
|
||||
consumerReadyCallback(consumer);
|
||||
} else {
|
||||
fetchSources(consumer, consumerReadyCallback);
|
||||
}
|
||||
// ...
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.sourceContentFor(source[, returnNullOnMissing])
|
||||
|
||||
Returns the original source content for the source provided. The only
|
||||
argument is the URL of the original source file.
|
||||
|
||||
If the source content for the given source is not found, then an error is
|
||||
thrown. Optionally, pass `true` as the second param to have `null` returned
|
||||
instead.
|
||||
|
||||
```js
|
||||
consumer.sources
|
||||
// [ "my-cool-lib.clj" ]
|
||||
|
||||
consumer.sourceContentFor("my-cool-lib.clj")
|
||||
// "..."
|
||||
|
||||
consumer.sourceContentFor("this is not in the source map");
|
||||
// Error: "this is not in the source map" is not in the source map
|
||||
|
||||
consumer.sourceContentFor("this is not in the source map", true);
|
||||
// null
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.eachMapping(callback, context, order)
|
||||
|
||||
Iterate over each mapping between an original source/line/column and a
|
||||
generated line/column in this source map.
|
||||
|
||||
* `callback`: The function that is called with each mapping. Mappings have the
|
||||
form `{ source, generatedLine, generatedColumn, originalLine, originalColumn,
|
||||
name }`
|
||||
|
||||
* `context`: Optional. If specified, this object will be the value of `this`
|
||||
every time that `callback` is called.
|
||||
|
||||
* `order`: Either `SourceMapConsumer.GENERATED_ORDER` or
|
||||
`SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to iterate over
|
||||
the mappings sorted by the generated file's line/column order or the
|
||||
original's source/line/column order, respectively. Defaults to
|
||||
`SourceMapConsumer.GENERATED_ORDER`.
|
||||
|
||||
```js
|
||||
consumer.eachMapping(function (m) { console.log(m); })
|
||||
// ...
|
||||
// { source: 'illmatic.js',
|
||||
// generatedLine: 1,
|
||||
// generatedColumn: 0,
|
||||
// originalLine: 1,
|
||||
// originalColumn: 0,
|
||||
// name: null }
|
||||
// { source: 'illmatic.js',
|
||||
// generatedLine: 2,
|
||||
// generatedColumn: 0,
|
||||
// originalLine: 2,
|
||||
// originalColumn: 0,
|
||||
// name: null }
|
||||
// ...
|
||||
```
|
||||
### SourceMapGenerator
|
||||
|
||||
An instance of the SourceMapGenerator represents a source map which is being
|
||||
built incrementally.
|
||||
|
||||
#### new SourceMapGenerator([startOfSourceMap])
|
||||
|
||||
You may pass an object with the following properties:
|
||||
|
||||
* `file`: The filename of the generated source that this source map is
|
||||
associated with.
|
||||
|
||||
* `sourceRoot`: A root for all relative URLs in this source map.
|
||||
|
||||
* `skipValidation`: Optional. When `true`, disables validation of mappings as
|
||||
they are added. This can improve performance but should be used with
|
||||
discretion, as a last resort. Even then, one should avoid using this flag when
|
||||
running tests, if possible.
|
||||
|
||||
```js
|
||||
var generator = new sourceMap.SourceMapGenerator({
|
||||
file: "my-generated-javascript-file.js",
|
||||
sourceRoot: "http://example.com/app/js/"
|
||||
});
|
||||
```
|
||||
|
||||
#### SourceMapGenerator.fromSourceMap(sourceMapConsumer)
|
||||
|
||||
Creates a new `SourceMapGenerator` from an existing `SourceMapConsumer` instance.
|
||||
|
||||
* `sourceMapConsumer` The SourceMap.
|
||||
|
||||
```js
|
||||
var generator = sourceMap.SourceMapGenerator.fromSourceMap(consumer);
|
||||
```
|
||||
|
||||
#### SourceMapGenerator.prototype.addMapping(mapping)
|
||||
|
||||
Add a single mapping from original source line and column to the generated
|
||||
source's line and column for this source map being created. The mapping object
|
||||
should have the following properties:
|
||||
|
||||
* `generated`: An object with the generated line and column positions.
|
||||
|
||||
* `original`: An object with the original line and column positions.
|
||||
|
||||
* `source`: The original source file (relative to the sourceRoot).
|
||||
|
||||
* `name`: An optional original token name for this mapping.
|
||||
|
||||
```js
|
||||
generator.addMapping({
|
||||
source: "module-one.scm",
|
||||
original: { line: 128, column: 0 },
|
||||
generated: { line: 3, column: 456 }
|
||||
})
|
||||
```
|
||||
|
||||
#### SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)
|
||||
|
||||
Set the source content for an original source file.
|
||||
|
||||
* `sourceFile` the URL of the original source file.
|
||||
|
||||
* `sourceContent` the content of the source file.
|
||||
|
||||
```js
|
||||
generator.setSourceContent("module-one.scm",
|
||||
fs.readFileSync("path/to/module-one.scm"))
|
||||
```
|
||||
|
||||
#### SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])
|
||||
|
||||
Applies a SourceMap for a source file to the SourceMap.
|
||||
Each mapping to the supplied source file is rewritten using the
|
||||
supplied SourceMap. Note: The resolution for the resulting mappings
|
||||
is the minimum of this map and the supplied map.
|
||||
|
||||
* `sourceMapConsumer`: The SourceMap to be applied.
|
||||
|
||||
* `sourceFile`: Optional. The filename of the source file.
|
||||
If omitted, sourceMapConsumer.file will be used, if it exists.
|
||||
Otherwise an error will be thrown.
|
||||
|
||||
* `sourceMapPath`: Optional. The dirname of the path to the SourceMap
|
||||
to be applied. If relative, it is relative to the SourceMap.
|
||||
|
||||
This parameter is needed when the two SourceMaps aren't in the same
|
||||
directory, and the SourceMap to be applied contains relative source
|
||||
paths. If so, those relative source paths need to be rewritten
|
||||
relative to the SourceMap.
|
||||
|
||||
If omitted, it is assumed that both SourceMaps are in the same directory,
|
||||
thus not needing any rewriting. (Supplying `'.'` has the same effect.)
|
||||
|
||||
#### SourceMapGenerator.prototype.toString()
|
||||
|
||||
Renders the source map being generated to a string.
|
||||
|
||||
```js
|
||||
generator.toString()
|
||||
// '{"version":3,"sources":["module-one.scm"],"names":[],"mappings":"...snip...","file":"my-generated-javascript-file.js","sourceRoot":"http://example.com/app/js/"}'
|
||||
```
|
||||
|
||||
### SourceNode
|
||||
|
||||
SourceNodes provide a way to abstract over interpolating and/or concatenating
|
||||
snippets of generated JavaScript source code, while maintaining the line and
|
||||
column information associated between those snippets and the original source
|
||||
code. This is useful as the final intermediate representation a compiler might
|
||||
use before outputting the generated JS and source map.
|
||||
|
||||
#### new SourceNode([line, column, source[, chunk[, name]]])
|
||||
|
||||
* `line`: The original line number associated with this source node, or null if
|
||||
it isn't associated with an original line. The line number is 1-based.
|
||||
|
||||
* `column`: The original column number associated with this source node, or null
|
||||
if it isn't associated with an original column. The column number
|
||||
is 0-based.
|
||||
|
||||
* `source`: The original source's filename; null if no filename is provided.
|
||||
|
||||
* `chunk`: Optional. Is immediately passed to `SourceNode.prototype.add`, see
|
||||
below.
|
||||
|
||||
* `name`: Optional. The original identifier.
|
||||
|
||||
```js
|
||||
var node = new SourceNode(1, 2, "a.cpp", [
|
||||
new SourceNode(3, 4, "b.cpp", "extern int status;\n"),
|
||||
new SourceNode(5, 6, "c.cpp", "std::string* make_string(size_t n);\n"),
|
||||
new SourceNode(7, 8, "d.cpp", "int main(int argc, char** argv) {}\n"),
|
||||
]);
|
||||
```
|
||||
|
||||
#### SourceNode.fromStringWithSourceMap(code, sourceMapConsumer[, relativePath])
|
||||
|
||||
Creates a SourceNode from generated code and a SourceMapConsumer.
|
||||
|
||||
* `code`: The generated code
|
||||
|
||||
* `sourceMapConsumer` The SourceMap for the generated code
|
||||
|
||||
* `relativePath` The optional path that relative sources in `sourceMapConsumer`
|
||||
should be relative to.
|
||||
|
||||
```js
|
||||
var consumer = new SourceMapConsumer(fs.readFileSync("path/to/my-file.js.map", "utf8"));
|
||||
var node = SourceNode.fromStringWithSourceMap(fs.readFileSync("path/to/my-file.js"),
|
||||
consumer);
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.add(chunk)
|
||||
|
||||
Add a chunk of generated JS to this source node.
|
||||
|
||||
* `chunk`: A string snippet of generated JS code, another instance of
|
||||
`SourceNode`, or an array where each member is one of those things.
|
||||
|
||||
```js
|
||||
node.add(" + ");
|
||||
node.add(otherNode);
|
||||
node.add([leftHandOperandNode, " + ", rightHandOperandNode]);
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.prepend(chunk)
|
||||
|
||||
Prepend a chunk of generated JS to this source node.
|
||||
|
||||
* `chunk`: A string snippet of generated JS code, another instance of
|
||||
`SourceNode`, or an array where each member is one of those things.
|
||||
|
||||
```js
|
||||
node.prepend("/** Build Id: f783haef86324gf **/\n\n");
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.setSourceContent(sourceFile, sourceContent)
|
||||
|
||||
Set the source content for a source file. This will be added to the
|
||||
`SourceMap` in the `sourcesContent` field.
|
||||
|
||||
* `sourceFile`: The filename of the source file
|
||||
|
||||
* `sourceContent`: The content of the source file
|
||||
|
||||
```js
|
||||
node.setSourceContent("module-one.scm",
|
||||
fs.readFileSync("path/to/module-one.scm"))
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.walk(fn)
|
||||
|
||||
Walk over the tree of JS snippets in this node and its children. The walking
|
||||
function is called once for each snippet of JS and is passed that snippet and
|
||||
the its original associated source's line/column location.
|
||||
|
||||
* `fn`: The traversal function.
|
||||
|
||||
```js
|
||||
var node = new SourceNode(1, 2, "a.js", [
|
||||
new SourceNode(3, 4, "b.js", "uno"),
|
||||
"dos",
|
||||
[
|
||||
"tres",
|
||||
new SourceNode(5, 6, "c.js", "quatro")
|
||||
]
|
||||
]);
|
||||
|
||||
node.walk(function (code, loc) { console.log("WALK:", code, loc); })
|
||||
// WALK: uno { source: 'b.js', line: 3, column: 4, name: null }
|
||||
// WALK: dos { source: 'a.js', line: 1, column: 2, name: null }
|
||||
// WALK: tres { source: 'a.js', line: 1, column: 2, name: null }
|
||||
// WALK: quatro { source: 'c.js', line: 5, column: 6, name: null }
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.walkSourceContents(fn)
|
||||
|
||||
Walk over the tree of SourceNodes. The walking function is called for each
|
||||
source file content and is passed the filename and source content.
|
||||
|
||||
* `fn`: The traversal function.
|
||||
|
||||
```js
|
||||
var a = new SourceNode(1, 2, "a.js", "generated from a");
|
||||
a.setSourceContent("a.js", "original a");
|
||||
var b = new SourceNode(1, 2, "b.js", "generated from b");
|
||||
b.setSourceContent("b.js", "original b");
|
||||
var c = new SourceNode(1, 2, "c.js", "generated from c");
|
||||
c.setSourceContent("c.js", "original c");
|
||||
|
||||
var node = new SourceNode(null, null, null, [a, b, c]);
|
||||
node.walkSourceContents(function (source, contents) { console.log("WALK:", source, ":", contents); })
|
||||
// WALK: a.js : original a
|
||||
// WALK: b.js : original b
|
||||
// WALK: c.js : original c
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.join(sep)
|
||||
|
||||
Like `Array.prototype.join` except for SourceNodes. Inserts the separator
|
||||
between each of this source node's children.
|
||||
|
||||
* `sep`: The separator.
|
||||
|
||||
```js
|
||||
var lhs = new SourceNode(1, 2, "a.rs", "my_copy");
|
||||
var operand = new SourceNode(3, 4, "a.rs", "=");
|
||||
var rhs = new SourceNode(5, 6, "a.rs", "orig.clone()");
|
||||
|
||||
var node = new SourceNode(null, null, null, [ lhs, operand, rhs ]);
|
||||
var joinedNode = node.join(" ");
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.replaceRight(pattern, replacement)
|
||||
|
||||
Call `String.prototype.replace` on the very right-most source snippet. Useful
|
||||
for trimming white space from the end of a source node, etc.
|
||||
|
||||
* `pattern`: The pattern to replace.
|
||||
|
||||
* `replacement`: The thing to replace the pattern with.
|
||||
|
||||
```js
|
||||
// Trim trailing white space.
|
||||
node.replaceRight(/\s*$/, "");
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.toString()
|
||||
|
||||
Return the string representation of this source node. Walks over the tree and
|
||||
concatenates all the various snippets together to one string.
|
||||
|
||||
```js
|
||||
var node = new SourceNode(1, 2, "a.js", [
|
||||
new SourceNode(3, 4, "b.js", "uno"),
|
||||
"dos",
|
||||
[
|
||||
"tres",
|
||||
new SourceNode(5, 6, "c.js", "quatro")
|
||||
]
|
||||
]);
|
||||
|
||||
node.toString()
|
||||
// 'unodostresquatro'
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.toStringWithSourceMap([startOfSourceMap])
|
||||
|
||||
Returns the string representation of this tree of source nodes, plus a
|
||||
SourceMapGenerator which contains all the mappings between the generated and
|
||||
original sources.
|
||||
|
||||
The arguments are the same as those to `new SourceMapGenerator`.
|
||||
|
||||
```js
|
||||
var node = new SourceNode(1, 2, "a.js", [
|
||||
new SourceNode(3, 4, "b.js", "uno"),
|
||||
"dos",
|
||||
[
|
||||
"tres",
|
||||
new SourceNode(5, 6, "c.js", "quatro")
|
||||
]
|
||||
]);
|
||||
|
||||
node.toStringWithSourceMap({ file: "my-output-file.js" })
|
||||
// { code: 'unodostresquatro',
|
||||
// map: [object SourceMapGenerator] }
|
||||
```
|
||||
73
backend/frontend/node_modules/postcss-custom-selectors/node_modules/source-map/package.json
generated
vendored
Normal file
73
backend/frontend/node_modules/postcss-custom-selectors/node_modules/source-map/package.json
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"name": "source-map",
|
||||
"description": "Generates and consumes source maps",
|
||||
"version": "0.6.1",
|
||||
"homepage": "https://github.com/mozilla/source-map",
|
||||
"author": "Nick Fitzgerald <nfitzgerald@mozilla.com>",
|
||||
"contributors": [
|
||||
"Tobias Koppers <tobias.koppers@googlemail.com>",
|
||||
"Duncan Beevers <duncan@dweebd.com>",
|
||||
"Stephen Crane <scrane@mozilla.com>",
|
||||
"Ryan Seddon <seddon.ryan@gmail.com>",
|
||||
"Miles Elam <miles.elam@deem.com>",
|
||||
"Mihai Bazon <mihai.bazon@gmail.com>",
|
||||
"Michael Ficarra <github.public.email@michael.ficarra.me>",
|
||||
"Todd Wolfson <todd@twolfson.com>",
|
||||
"Alexander Solovyov <alexander@solovyov.net>",
|
||||
"Felix Gnass <fgnass@gmail.com>",
|
||||
"Conrad Irwin <conrad.irwin@gmail.com>",
|
||||
"usrbincc <usrbincc@yahoo.com>",
|
||||
"David Glasser <glasser@davidglasser.net>",
|
||||
"Chase Douglas <chase@newrelic.com>",
|
||||
"Evan Wallace <evan.exe@gmail.com>",
|
||||
"Heather Arthur <fayearthur@gmail.com>",
|
||||
"Hugh Kennedy <hughskennedy@gmail.com>",
|
||||
"David Glasser <glasser@davidglasser.net>",
|
||||
"Simon Lydell <simon.lydell@gmail.com>",
|
||||
"Jmeas Smith <jellyes2@gmail.com>",
|
||||
"Michael Z Goddard <mzgoddard@gmail.com>",
|
||||
"azu <azu@users.noreply.github.com>",
|
||||
"John Gozde <john@gozde.ca>",
|
||||
"Adam Kirkton <akirkton@truefitinnovation.com>",
|
||||
"Chris Montgomery <christopher.montgomery@dowjones.com>",
|
||||
"J. Ryan Stinnett <jryans@gmail.com>",
|
||||
"Jack Herrington <jherrington@walmartlabs.com>",
|
||||
"Chris Truter <jeffpalentine@gmail.com>",
|
||||
"Daniel Espeset <daniel@danielespeset.com>",
|
||||
"Jamie Wong <jamie.lf.wong@gmail.com>",
|
||||
"Eddy Bruël <ejpbruel@mozilla.com>",
|
||||
"Hawken Rives <hawkrives@gmail.com>",
|
||||
"Gilad Peleg <giladp007@gmail.com>",
|
||||
"djchie <djchie.dev@gmail.com>",
|
||||
"Gary Ye <garysye@gmail.com>",
|
||||
"Nicolas Lalevée <nicolas.lalevee@hibnet.org>"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/mozilla/source-map.git"
|
||||
},
|
||||
"main": "./source-map.js",
|
||||
"files": [
|
||||
"source-map.js",
|
||||
"source-map.d.ts",
|
||||
"lib/",
|
||||
"dist/source-map.debug.js",
|
||||
"dist/source-map.js",
|
||||
"dist/source-map.min.js",
|
||||
"dist/source-map.min.js.map"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"license": "BSD-3-Clause",
|
||||
"scripts": {
|
||||
"test": "npm run build && node test/run-tests.js",
|
||||
"build": "webpack --color",
|
||||
"toc": "doctoc --title '## Table of Contents' README.md && doctoc --title '## Table of Contents' CONTRIBUTING.md"
|
||||
},
|
||||
"devDependencies": {
|
||||
"doctoc": "^0.15.0",
|
||||
"webpack": "^1.12.0"
|
||||
},
|
||||
"typings": "source-map"
|
||||
}
|
||||
98
backend/frontend/node_modules/postcss-custom-selectors/node_modules/source-map/source-map.d.ts
generated
vendored
Normal file
98
backend/frontend/node_modules/postcss-custom-selectors/node_modules/source-map/source-map.d.ts
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
export interface StartOfSourceMap {
|
||||
file?: string;
|
||||
sourceRoot?: string;
|
||||
}
|
||||
|
||||
export interface RawSourceMap extends StartOfSourceMap {
|
||||
version: string;
|
||||
sources: string[];
|
||||
names: string[];
|
||||
sourcesContent?: string[];
|
||||
mappings: string;
|
||||
}
|
||||
|
||||
export interface Position {
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
|
||||
export interface LineRange extends Position {
|
||||
lastColumn: number;
|
||||
}
|
||||
|
||||
export interface FindPosition extends Position {
|
||||
// SourceMapConsumer.GREATEST_LOWER_BOUND or SourceMapConsumer.LEAST_UPPER_BOUND
|
||||
bias?: number;
|
||||
}
|
||||
|
||||
export interface SourceFindPosition extends FindPosition {
|
||||
source: string;
|
||||
}
|
||||
|
||||
export interface MappedPosition extends Position {
|
||||
source: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface MappingItem {
|
||||
source: string;
|
||||
generatedLine: number;
|
||||
generatedColumn: number;
|
||||
originalLine: number;
|
||||
originalColumn: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export class SourceMapConsumer {
|
||||
static GENERATED_ORDER: number;
|
||||
static ORIGINAL_ORDER: number;
|
||||
|
||||
static GREATEST_LOWER_BOUND: number;
|
||||
static LEAST_UPPER_BOUND: number;
|
||||
|
||||
constructor(rawSourceMap: RawSourceMap);
|
||||
computeColumnSpans(): void;
|
||||
originalPositionFor(generatedPosition: FindPosition): MappedPosition;
|
||||
generatedPositionFor(originalPosition: SourceFindPosition): LineRange;
|
||||
allGeneratedPositionsFor(originalPosition: MappedPosition): Position[];
|
||||
hasContentsOfAllSources(): boolean;
|
||||
sourceContentFor(source: string, returnNullOnMissing?: boolean): string;
|
||||
eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void;
|
||||
}
|
||||
|
||||
export interface Mapping {
|
||||
generated: Position;
|
||||
original: Position;
|
||||
source: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export class SourceMapGenerator {
|
||||
constructor(startOfSourceMap?: StartOfSourceMap);
|
||||
static fromSourceMap(sourceMapConsumer: SourceMapConsumer): SourceMapGenerator;
|
||||
addMapping(mapping: Mapping): void;
|
||||
setSourceContent(sourceFile: string, sourceContent: string): void;
|
||||
applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
export interface CodeWithSourceMap {
|
||||
code: string;
|
||||
map: SourceMapGenerator;
|
||||
}
|
||||
|
||||
export class SourceNode {
|
||||
constructor();
|
||||
constructor(line: number, column: number, source: string);
|
||||
constructor(line: number, column: number, source: string, chunk?: string, name?: string);
|
||||
static fromStringWithSourceMap(code: string, sourceMapConsumer: SourceMapConsumer, relativePath?: string): SourceNode;
|
||||
add(chunk: string): void;
|
||||
prepend(chunk: string): void;
|
||||
setSourceContent(sourceFile: string, sourceContent: string): void;
|
||||
walk(fn: (chunk: string, mapping: MappedPosition) => void): void;
|
||||
walkSourceContents(fn: (file: string, content: string) => void): void;
|
||||
join(sep: string): SourceNode;
|
||||
replaceRight(pattern: string, replacement: string): SourceNode;
|
||||
toString(): string;
|
||||
toStringWithSourceMap(startOfSourceMap?: StartOfSourceMap): CodeWithSourceMap;
|
||||
}
|
||||
8
backend/frontend/node_modules/postcss-custom-selectors/node_modules/source-map/source-map.js
generated
vendored
Normal file
8
backend/frontend/node_modules/postcss-custom-selectors/node_modules/source-map/source-map.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* Copyright 2009-2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE.txt or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
exports.SourceMapGenerator = require('./lib/source-map-generator').SourceMapGenerator;
|
||||
exports.SourceMapConsumer = require('./lib/source-map-consumer').SourceMapConsumer;
|
||||
exports.SourceNode = require('./lib/source-node').SourceNode;
|
||||
67
backend/frontend/node_modules/postcss-custom-selectors/package.json
generated
vendored
Normal file
67
backend/frontend/node_modules/postcss-custom-selectors/package.json
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"name": "postcss-custom-selectors",
|
||||
"version": "5.1.2",
|
||||
"description": "Use Custom Selectors in CSS",
|
||||
"author": "Jonathan Neal <jonathantneal@hotmail.com>",
|
||||
"contributors": [
|
||||
"yisi",
|
||||
"Maxime Thirouin"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "postcss/postcss-custom-selectors",
|
||||
"homepage": "https://github.com/postcss/postcss-custom-selectors#readme",
|
||||
"bugs": "https://github.com/postcss/postcss-custom-selectors/issues",
|
||||
"main": "index.cjs.js",
|
||||
"module": "index.es.mjs",
|
||||
"files": [
|
||||
"index.cjs.js",
|
||||
"index.cjs.js.map",
|
||||
"index.es.mjs",
|
||||
"index.es.mjs.map"
|
||||
],
|
||||
"scripts": {
|
||||
"prepublishOnly": "npm test",
|
||||
"pretest": "rollup -c .rollup.js --silent",
|
||||
"test": "echo 'Running tests...'; npm run test:js && npm run test:tape",
|
||||
"test:js": "eslint *.js lib/*.js --cache --ignore-path .gitignore --quiet",
|
||||
"test:tape": "postcss-tape"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"postcss": "^7.0.2",
|
||||
"postcss-selector-parser": "^5.0.0-rc.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.1.0",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
|
||||
"@babel/preset-env": "^7.1.0",
|
||||
"babel-eslint": "^9.0.0",
|
||||
"eslint": "^5.6.0",
|
||||
"eslint-config-dev": "^2.0.0",
|
||||
"postcss-tape": "^2.2.0",
|
||||
"pre-commit": "^1.2.2",
|
||||
"rollup": "^0.66.1",
|
||||
"rollup-plugin-babel": "^4.0.3"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "dev",
|
||||
"parser": "babel-eslint"
|
||||
},
|
||||
"keywords": [
|
||||
"postcss",
|
||||
"css",
|
||||
"postcss-plugin",
|
||||
"custom",
|
||||
"selectors",
|
||||
"w3c",
|
||||
"csswg",
|
||||
"extensions",
|
||||
"declarative",
|
||||
"rule",
|
||||
"atrule",
|
||||
"at-rule",
|
||||
"specification"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user