mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
19
web/node_modules/postcss-env-function/CHANGELOG.md
generated
vendored
Normal file
19
web/node_modules/postcss-env-function/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Changes to PostCSS Environment Variables
|
||||
|
||||
### 2.0.2 (September 20, 2018)
|
||||
|
||||
- Updated: Do not break on an empty importFrom object
|
||||
|
||||
### 2.0.1 (September 18, 2018)
|
||||
|
||||
- Updated: Support for PostCSS Values Parser 2
|
||||
|
||||
### 2.0.0 (September 17, 2018)
|
||||
|
||||
- Updated: Support for PostCSS 7+
|
||||
- Updated: Support for Node 6+
|
||||
- Updated: Changed `variables` option to `importFrom` option
|
||||
|
||||
### 1.0.0 (April 28, 2018)
|
||||
|
||||
- Initial version
|
108
web/node_modules/postcss-env-function/LICENSE.md
generated
vendored
Normal file
108
web/node_modules/postcss-env-function/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
# CC0 1.0 Universal
|
||||
|
||||
## Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator and
|
||||
subsequent owner(s) (each and all, an “owner”) of an original work of
|
||||
authorship and/or a database (each, a “Work”).
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for the
|
||||
purpose of contributing to a commons of creative, cultural and scientific works
|
||||
(“Commons”) that the public can reliably and without fear of later claims of
|
||||
infringement build upon, modify, incorporate in other works, reuse and
|
||||
redistribute as freely as possible in any form whatsoever and for any purposes,
|
||||
including without limitation commercial purposes. These owners may contribute
|
||||
to the Commons to promote the ideal of a free culture and the further
|
||||
production of creative, cultural and scientific works, or to gain reputation or
|
||||
greater distribution for their Work in part through the use and efforts of
|
||||
others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any expectation of
|
||||
additional consideration or compensation, the person associating CC0 with a
|
||||
Work (the “Affirmer”), to the extent that he or she is an owner of Copyright
|
||||
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and
|
||||
publicly distribute the Work under its terms, with knowledge of his or her
|
||||
Copyright and Related Rights in the Work and the meaning and intended legal
|
||||
effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights (“Copyright and
|
||||
Related Rights”). Copyright and Related Rights include, but are not limited
|
||||
to, the following:
|
||||
1. the right to reproduce, adapt, distribute, perform, display, communicate,
|
||||
and translate a Work;
|
||||
2. moral rights retained by the original author(s) and/or performer(s);
|
||||
3. publicity and privacy rights pertaining to a person’s image or likeness
|
||||
depicted in a Work;
|
||||
4. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(i), below;
|
||||
5. rights protecting the extraction, dissemination, use and reuse of data in
|
||||
a Work;
|
||||
6. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation thereof,
|
||||
including any amended or successor version of such directive); and
|
||||
7. other similar, equivalent or corresponding rights throughout the world
|
||||
based on applicable law or treaty, and any national implementations
|
||||
thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention of,
|
||||
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
|
||||
unconditionally waives, abandons, and surrenders all of Affirmer’s Copyright
|
||||
and Related Rights and associated claims and causes of action, whether now
|
||||
known or unknown (including existing as well as future claims and causes of
|
||||
action), in the Work (i) in all territories worldwide, (ii) for the maximum
|
||||
duration provided by applicable law or treaty (including future time
|
||||
extensions), (iii) in any current or future medium and for any number of
|
||||
copies, and (iv) for any purpose whatsoever, including without limitation
|
||||
commercial, advertising or promotional purposes (the “Waiver”). Affirmer
|
||||
makes the Waiver for the benefit of each member of the public at large and
|
||||
to the detriment of Affirmer’s heirs and successors, fully intending that
|
||||
such Waiver shall not be subject to revocation, rescission, cancellation,
|
||||
termination, or any other legal or equitable action to disrupt the quiet
|
||||
enjoyment of the Work by the public as contemplated by Affirmer’s express
|
||||
Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason be
|
||||
judged legally invalid or ineffective under applicable law, then the Waiver
|
||||
shall be preserved to the maximum extent permitted taking into account
|
||||
Affirmer’s express Statement of Purpose. In addition, to the extent the
|
||||
Waiver is so judged Affirmer hereby grants to each affected person a
|
||||
royalty-free, non transferable, non sublicensable, non exclusive,
|
||||
irrevocable and unconditional license to exercise Affirmer’s Copyright and
|
||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||
maximum duration provided by applicable law or treaty (including future time
|
||||
extensions), (iii) in any current or future medium and for any number of
|
||||
copies, and (iv) for any purpose whatsoever, including without limitation
|
||||
commercial, advertising or promotional purposes (the “License”). The License
|
||||
shall be deemed effective as of the date CC0 was applied by Affirmer to the
|
||||
Work. Should any part of the License for any reason be judged legally
|
||||
invalid or ineffective under applicable law, such partial invalidity or
|
||||
ineffectiveness shall not invalidate the remainder of the License, and in
|
||||
such case Affirmer hereby affirms that he or she will not (i) exercise any
|
||||
of his or her remaining Copyright and Related Rights in the Work or (ii)
|
||||
assert any associated claims and causes of action with respect to the Work,
|
||||
in either case contrary to Affirmer’s express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
1. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
2. Affirmer offers the Work as-is and makes no representations or warranties
|
||||
of any kind concerning the Work, express, implied, statutory or
|
||||
otherwise, including without limitation warranties of title,
|
||||
merchantability, fitness for a particular purpose, non infringement, or
|
||||
the absence of latent or other defects, accuracy, or the present or
|
||||
absence of errors, whether or not discoverable, all to the greatest
|
||||
extent permissible under applicable law.
|
||||
3. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without
|
||||
limitation any person’s Copyright and Related Rights in the Work.
|
||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||
consents, permissions or other rights required for any use of the Work.
|
||||
4. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to this
|
||||
CC0 or use of the Work.
|
||||
|
||||
For more information, please see
|
||||
http://creativecommons.org/publicdomain/zero/1.0/.
|
137
web/node_modules/postcss-env-function/README.md
generated
vendored
Normal file
137
web/node_modules/postcss-env-function/README.md
generated
vendored
Normal file
|
@ -0,0 +1,137 @@
|
|||
# PostCSS Environment Variables [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" 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 Environment Variables] lets you use `env()` variables in CSS,
|
||||
following the [CSS Environment Variables] specification.
|
||||
|
||||
```pcss
|
||||
@media (max-width: env(--branding-small)) {
|
||||
body {
|
||||
padding: env(--branding-padding);
|
||||
}
|
||||
}
|
||||
|
||||
/* becomes */
|
||||
|
||||
@media (min-width: 600px) {
|
||||
body {
|
||||
padding: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
/* when the `importFrom` option is: {
|
||||
"environmentVariables": {
|
||||
"--branding-small": "600px",
|
||||
"--branding-padding": "20px"
|
||||
}
|
||||
} */
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Add [PostCSS Environment Variables] to your project:
|
||||
|
||||
```bash
|
||||
npm install postcss-env-function --save-dev
|
||||
```
|
||||
|
||||
Use [PostCSS Environment Variables] to process your CSS:
|
||||
|
||||
```js
|
||||
const postcssEnvFunction = require('postcss-env-function');
|
||||
|
||||
postcssEnvFunction.process(YOUR_CSS /*, processOptions, pluginOptions */);
|
||||
```
|
||||
|
||||
Or use it as a [PostCSS] plugin:
|
||||
|
||||
```js
|
||||
const postcss = require('postcss');
|
||||
const postcssEnvFunction = require('postcss-env-function');
|
||||
|
||||
postcss([
|
||||
postcssEnvFunction(/* pluginOptions */)
|
||||
]).process(YOUR_CSS /*, processOptions */);
|
||||
```
|
||||
|
||||
[PostCSS Environment Variables] 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
|
||||
|
||||
### importFrom
|
||||
|
||||
The `importFrom` option specifies sources where Environment Variables can be
|
||||
imported from, which might be JS and JSON files, functions, and directly passed
|
||||
objects.
|
||||
|
||||
```js
|
||||
postcssCustomProperties({
|
||||
importFrom: 'path/to/file.js' /* module.exports = {
|
||||
environmentVariables: {
|
||||
'--branding-padding': '20px',
|
||||
'--branding-small': '600px'
|
||||
}
|
||||
} */
|
||||
});
|
||||
```
|
||||
|
||||
```pcss
|
||||
@media (max-width: env(--branding-small)) {
|
||||
body {
|
||||
padding: env(--branding-padding);
|
||||
}
|
||||
}
|
||||
|
||||
/* becomes */
|
||||
|
||||
@media (min-width: 600px) {
|
||||
body {
|
||||
padding: 20px;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
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 Properties using the `environmentVariables` or
|
||||
`variables-variables` key.
|
||||
|
||||
```js
|
||||
postcssCustomProperties({
|
||||
importFrom: [
|
||||
'path/to/file.js', // module.exports = { environmentVariables: { '--branding-padding': '20px' } }
|
||||
'and/then/this.json', // { "environment-variables": { "--branding-padding": "20px" } }
|
||||
{
|
||||
environmentVariables: { '--branding-padding': '20px' }
|
||||
},
|
||||
() => {
|
||||
const environmentVariables = { '--branding-padding': '20px' };
|
||||
|
||||
return { environmentVariables };
|
||||
}
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
See example imports written in [JS](test/import-variables.js) and
|
||||
[JSON](test/import-variables.json).
|
||||
|
||||
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-env-function.svg
|
||||
[cli-url]: https://travis-ci.org/jonathantneal/postcss-env-function
|
||||
[css-img]: https://cssdb.org/badge/environment-variables.svg
|
||||
[css-url]: https://cssdb.org/#environment-variables
|
||||
[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-env-function.svg
|
||||
[npm-url]: https://www.npmjs.com/package/postcss-env-function
|
||||
|
||||
[CSS Environment Variables]: https://drafts.csswg.org/css-env-1/
|
||||
[PostCSS]: https://github.com/postcss/postcss
|
||||
[PostCSS Environment Variables]: https://github.com/jonathantneal/postcss-env-function
|
288
web/node_modules/postcss-env-function/index.cjs.js
generated
vendored
Normal file
288
web/node_modules/postcss-env-function/index.cjs.js
generated
vendored
Normal file
|
@ -0,0 +1,288 @@
|
|||
'use strict';
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var parser = _interopDefault(require('postcss-values-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);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const dashedMatch = /^--/; // returns the value of a css function as a string
|
||||
|
||||
var getFnValue = (node => {
|
||||
const value = String(node.nodes.slice(1, -1));
|
||||
return dashedMatch.test(value) ? value : undefined;
|
||||
});
|
||||
|
||||
var updateEnvValue = ((node, variables) => {
|
||||
// get the value of a css function as a string
|
||||
const value = getFnValue(node);
|
||||
|
||||
if (typeof value === 'string' && value in variables) {
|
||||
node.replaceWith(...asClonedArrayWithBeforeSpacing(variables[value], node.raws.before));
|
||||
}
|
||||
}); // return an array with its nodes cloned, preserving the raw
|
||||
|
||||
const asClonedArrayWithBeforeSpacing = (array, beforeSpacing) => {
|
||||
const clonedArray = asClonedArray(array, null);
|
||||
|
||||
if (clonedArray[0]) {
|
||||
clonedArray[0].raws.before = beforeSpacing;
|
||||
}
|
||||
|
||||
return clonedArray;
|
||||
}; // return an array with its nodes cloned
|
||||
|
||||
|
||||
const asClonedArray = (array, parent) => array.map(node => asClonedNode(node, parent)); // return a cloned node
|
||||
|
||||
|
||||
const asClonedNode = (node, parent) => {
|
||||
const cloneNode = new node.constructor(node);
|
||||
|
||||
for (const key in node) {
|
||||
if (key === 'parent') {
|
||||
cloneNode.parent = parent;
|
||||
} else if (Object(node[key]).constructor === Array) {
|
||||
cloneNode[key] = asClonedArray(node.nodes, cloneNode);
|
||||
} else if (Object(node[key]).constructor === Object) {
|
||||
cloneNode[key] = Object.assign({}, node[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return cloneNode;
|
||||
};
|
||||
|
||||
// returns whether a node is a css env() function
|
||||
var isEnvFunc = (node => node && node.type === 'func' && node.value === 'env');
|
||||
|
||||
function walk(node, fn) {
|
||||
node.nodes.slice(0).forEach(childNode => {
|
||||
if (childNode.nodes) {
|
||||
walk(childNode, fn);
|
||||
}
|
||||
|
||||
if (isEnvFunc(childNode)) {
|
||||
fn(childNode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var getReplacedValue = ((originalValue, variables) => {
|
||||
// get the ast of the original value
|
||||
const ast = parser(originalValue).parse(); // walk all of the css env() functions
|
||||
|
||||
walk(ast, node => {
|
||||
// update the environment value for the css env() function
|
||||
updateEnvValue(node, variables);
|
||||
}); // return the stringified ast
|
||||
|
||||
return String(ast);
|
||||
});
|
||||
|
||||
// returns whether a node is an at-rule
|
||||
var isAtrule = (node => node && node.type === 'atrule');
|
||||
|
||||
// returns whether a node is a declaration
|
||||
var isDecl = (node => node && node.type === 'decl');
|
||||
|
||||
var getSupportedValue = (node => isAtrule(node) && node.params || isDecl(node) && node.value);
|
||||
|
||||
function setSupportedValue (node, value) {
|
||||
if (isAtrule(node)) {
|
||||
node.params = value;
|
||||
}
|
||||
|
||||
if (isDecl(node)) {
|
||||
node.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
/* Import Custom Properties from Object
|
||||
/* ========================================================================== */
|
||||
|
||||
function importEnvironmentVariablesFromObject(object) {
|
||||
const environmentVariables = Object.assign({}, Object(object).environmentVariables || Object(object)['environment-variables']);
|
||||
|
||||
for (const key in environmentVariables) {
|
||||
environmentVariables[key] = parser(environmentVariables[key]).parse().nodes;
|
||||
}
|
||||
|
||||
return environmentVariables;
|
||||
}
|
||||
/* Import Custom Properties from JSON file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function importEnvironmentVariablesFromJSONFile(_x) {
|
||||
return _importEnvironmentVariablesFromJSONFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Properties from JS file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _importEnvironmentVariablesFromJSONFile() {
|
||||
_importEnvironmentVariablesFromJSONFile = _asyncToGenerator(function* (from) {
|
||||
const object = yield readJSON(path.resolve(from));
|
||||
return importEnvironmentVariablesFromObject(object);
|
||||
});
|
||||
return _importEnvironmentVariablesFromJSONFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function importEnvironmentVariablesFromJSFile(_x2) {
|
||||
return _importEnvironmentVariablesFromJSFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Properties from Sources
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _importEnvironmentVariablesFromJSFile() {
|
||||
_importEnvironmentVariablesFromJSFile = _asyncToGenerator(function* (from) {
|
||||
const object = yield Promise.resolve(require(path.resolve(from)));
|
||||
return importEnvironmentVariablesFromObject(object);
|
||||
});
|
||||
return _importEnvironmentVariablesFromJSFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function importEnvironmentVariablesFromSources(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 Properties
|
||||
|
||||
if (opts.environmentVariables || opts['environment-variables']) {
|
||||
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* (environmentVariables, source) {
|
||||
const _ref2 = yield source,
|
||||
type = _ref2.type,
|
||||
from = _ref2.from;
|
||||
|
||||
if (type === 'js') {
|
||||
return Object.assign(environmentVariables, (yield importEnvironmentVariablesFromJSFile(from)));
|
||||
}
|
||||
|
||||
if (type === 'json') {
|
||||
return Object.assign(environmentVariables, (yield importEnvironmentVariablesFromJSONFile(from)));
|
||||
}
|
||||
|
||||
return Object.assign(environmentVariables, importEnvironmentVariablesFromObject((yield source)));
|
||||
});
|
||||
|
||||
return function (_x3, _x4) {
|
||||
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(_x5) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
|
||||
var index = postcss.plugin('postcss-env-fn', opts => {
|
||||
// sources to import environment variables from
|
||||
const importFrom = [].concat(Object(opts).importFrom || []); // promise any environment variables are imported
|
||||
|
||||
const environmentVariablesPromise = importEnvironmentVariablesFromSources(importFrom);
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
var _ref = _asyncToGenerator(function* (root) {
|
||||
const environmentVariables = yield environmentVariablesPromise;
|
||||
root.walk(node => {
|
||||
const supportedValue = getSupportedValue(node);
|
||||
|
||||
if (supportedValue) {
|
||||
const replacedValue = getReplacedValue(supportedValue, environmentVariables);
|
||||
|
||||
if (replacedValue !== supportedValue) {
|
||||
setSupportedValue(node, replacedValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}()
|
||||
);
|
||||
});
|
||||
|
||||
module.exports = index;
|
||||
//# sourceMappingURL=index.cjs.js.map
|
1
web/node_modules/postcss-env-function/index.cjs.js.map
generated
vendored
Normal file
1
web/node_modules/postcss-env-function/index.cjs.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
284
web/node_modules/postcss-env-function/index.es.mjs
generated
vendored
Normal file
284
web/node_modules/postcss-env-function/index.es.mjs
generated
vendored
Normal file
|
@ -0,0 +1,284 @@
|
|||
import parser from 'postcss-values-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);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const dashedMatch = /^--/; // returns the value of a css function as a string
|
||||
|
||||
var getFnValue = (node => {
|
||||
const value = String(node.nodes.slice(1, -1));
|
||||
return dashedMatch.test(value) ? value : undefined;
|
||||
});
|
||||
|
||||
var updateEnvValue = ((node, variables) => {
|
||||
// get the value of a css function as a string
|
||||
const value = getFnValue(node);
|
||||
|
||||
if (typeof value === 'string' && value in variables) {
|
||||
node.replaceWith(...asClonedArrayWithBeforeSpacing(variables[value], node.raws.before));
|
||||
}
|
||||
}); // return an array with its nodes cloned, preserving the raw
|
||||
|
||||
const asClonedArrayWithBeforeSpacing = (array, beforeSpacing) => {
|
||||
const clonedArray = asClonedArray(array, null);
|
||||
|
||||
if (clonedArray[0]) {
|
||||
clonedArray[0].raws.before = beforeSpacing;
|
||||
}
|
||||
|
||||
return clonedArray;
|
||||
}; // return an array with its nodes cloned
|
||||
|
||||
|
||||
const asClonedArray = (array, parent) => array.map(node => asClonedNode(node, parent)); // return a cloned node
|
||||
|
||||
|
||||
const asClonedNode = (node, parent) => {
|
||||
const cloneNode = new node.constructor(node);
|
||||
|
||||
for (const key in node) {
|
||||
if (key === 'parent') {
|
||||
cloneNode.parent = parent;
|
||||
} else if (Object(node[key]).constructor === Array) {
|
||||
cloneNode[key] = asClonedArray(node.nodes, cloneNode);
|
||||
} else if (Object(node[key]).constructor === Object) {
|
||||
cloneNode[key] = Object.assign({}, node[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return cloneNode;
|
||||
};
|
||||
|
||||
// returns whether a node is a css env() function
|
||||
var isEnvFunc = (node => node && node.type === 'func' && node.value === 'env');
|
||||
|
||||
function walk(node, fn) {
|
||||
node.nodes.slice(0).forEach(childNode => {
|
||||
if (childNode.nodes) {
|
||||
walk(childNode, fn);
|
||||
}
|
||||
|
||||
if (isEnvFunc(childNode)) {
|
||||
fn(childNode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var getReplacedValue = ((originalValue, variables) => {
|
||||
// get the ast of the original value
|
||||
const ast = parser(originalValue).parse(); // walk all of the css env() functions
|
||||
|
||||
walk(ast, node => {
|
||||
// update the environment value for the css env() function
|
||||
updateEnvValue(node, variables);
|
||||
}); // return the stringified ast
|
||||
|
||||
return String(ast);
|
||||
});
|
||||
|
||||
// returns whether a node is an at-rule
|
||||
var isAtrule = (node => node && node.type === 'atrule');
|
||||
|
||||
// returns whether a node is a declaration
|
||||
var isDecl = (node => node && node.type === 'decl');
|
||||
|
||||
var getSupportedValue = (node => isAtrule(node) && node.params || isDecl(node) && node.value);
|
||||
|
||||
function setSupportedValue (node, value) {
|
||||
if (isAtrule(node)) {
|
||||
node.params = value;
|
||||
}
|
||||
|
||||
if (isDecl(node)) {
|
||||
node.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
/* Import Custom Properties from Object
|
||||
/* ========================================================================== */
|
||||
|
||||
function importEnvironmentVariablesFromObject(object) {
|
||||
const environmentVariables = Object.assign({}, Object(object).environmentVariables || Object(object)['environment-variables']);
|
||||
|
||||
for (const key in environmentVariables) {
|
||||
environmentVariables[key] = parser(environmentVariables[key]).parse().nodes;
|
||||
}
|
||||
|
||||
return environmentVariables;
|
||||
}
|
||||
/* Import Custom Properties from JSON file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function importEnvironmentVariablesFromJSONFile(_x) {
|
||||
return _importEnvironmentVariablesFromJSONFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Properties from JS file
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _importEnvironmentVariablesFromJSONFile() {
|
||||
_importEnvironmentVariablesFromJSONFile = _asyncToGenerator(function* (from) {
|
||||
const object = yield readJSON(path.resolve(from));
|
||||
return importEnvironmentVariablesFromObject(object);
|
||||
});
|
||||
return _importEnvironmentVariablesFromJSONFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function importEnvironmentVariablesFromJSFile(_x2) {
|
||||
return _importEnvironmentVariablesFromJSFile.apply(this, arguments);
|
||||
}
|
||||
/* Import Custom Properties from Sources
|
||||
/* ========================================================================== */
|
||||
|
||||
|
||||
function _importEnvironmentVariablesFromJSFile() {
|
||||
_importEnvironmentVariablesFromJSFile = _asyncToGenerator(function* (from) {
|
||||
const object = yield import(path.resolve(from));
|
||||
return importEnvironmentVariablesFromObject(object);
|
||||
});
|
||||
return _importEnvironmentVariablesFromJSFile.apply(this, arguments);
|
||||
}
|
||||
|
||||
function importEnvironmentVariablesFromSources(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 Properties
|
||||
|
||||
if (opts.environmentVariables || opts['environment-variables']) {
|
||||
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* (environmentVariables, source) {
|
||||
const _ref2 = yield source,
|
||||
type = _ref2.type,
|
||||
from = _ref2.from;
|
||||
|
||||
if (type === 'js') {
|
||||
return Object.assign(environmentVariables, (yield importEnvironmentVariablesFromJSFile(from)));
|
||||
}
|
||||
|
||||
if (type === 'json') {
|
||||
return Object.assign(environmentVariables, (yield importEnvironmentVariablesFromJSONFile(from)));
|
||||
}
|
||||
|
||||
return Object.assign(environmentVariables, importEnvironmentVariablesFromObject((yield source)));
|
||||
});
|
||||
|
||||
return function (_x3, _x4) {
|
||||
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(_x5) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
|
||||
var index = postcss.plugin('postcss-env-fn', opts => {
|
||||
// sources to import environment variables from
|
||||
const importFrom = [].concat(Object(opts).importFrom || []); // promise any environment variables are imported
|
||||
|
||||
const environmentVariablesPromise = importEnvironmentVariablesFromSources(importFrom);
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
var _ref = _asyncToGenerator(function* (root) {
|
||||
const environmentVariables = yield environmentVariablesPromise;
|
||||
root.walk(node => {
|
||||
const supportedValue = getSupportedValue(node);
|
||||
|
||||
if (supportedValue) {
|
||||
const replacedValue = getReplacedValue(supportedValue, environmentVariables);
|
||||
|
||||
if (replacedValue !== supportedValue) {
|
||||
setSupportedValue(node, replacedValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}()
|
||||
);
|
||||
});
|
||||
|
||||
export default index;
|
||||
//# sourceMappingURL=index.es.mjs.map
|
1
web/node_modules/postcss-env-function/index.es.mjs.map
generated
vendored
Normal file
1
web/node_modules/postcss-env-function/index.es.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
59
web/node_modules/postcss-env-function/package.json
generated
vendored
Normal file
59
web/node_modules/postcss-env-function/package.json
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
"name": "postcss-env-function",
|
||||
"version": "2.0.2",
|
||||
"description": "Use env() variables in CSS",
|
||||
"author": "Jonathan Neal <jonathantneal@hotmail.com>",
|
||||
"license": "CC0-1.0",
|
||||
"repository": "jonathantneal/postcss-env-function",
|
||||
"homepage": "https://github.com/jonathantneal/postcss-env-function#readme",
|
||||
"bugs": "https://github.com/jonathantneal/postcss-env-function/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:ec": "echint --ignore index.*.js test",
|
||||
"test:js": "eslint *.js --cache --ignore-path .gitignore --quiet",
|
||||
"test:tape": "postcss-tape"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"postcss": "^7.0.2",
|
||||
"postcss-values-parser": "^2.0.0"
|
||||
},
|
||||
"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",
|
||||
"environments",
|
||||
"variables",
|
||||
"envs",
|
||||
"constants",
|
||||
"functions"
|
||||
]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue