first
This commit is contained in:
22
node_modules/postcss-normalize-url/LICENSE-MIT
generated
vendored
Normal file
22
node_modules/postcss-normalize-url/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.
|
55
node_modules/postcss-normalize-url/README.md
generated
vendored
Normal file
55
node_modules/postcss-normalize-url/README.md
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
# [postcss][postcss]-normalize-url
|
||||
|
||||
> [Normalize URLs](https://github.com/sindresorhus/normalize-url) with PostCSS.
|
||||
|
||||
## Install
|
||||
|
||||
With [npm](https://npmjs.org/package/postcss-normalize-url) do:
|
||||
|
||||
```
|
||||
npm install postcss-normalize-url --save
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
### Input
|
||||
|
||||
```css
|
||||
h1 {
|
||||
background: url("http://site.com:80/image.jpg")
|
||||
}
|
||||
```
|
||||
|
||||
### Output
|
||||
|
||||
```css
|
||||
h1 {
|
||||
background: url(http://site.com/image.jpg)
|
||||
}
|
||||
```
|
||||
|
||||
Note that this module will also try to normalize relative URLs, and is capable
|
||||
of stripping unnecessary quotes. For more examples, see the [tests](test.js).
|
||||
|
||||
## Usage
|
||||
|
||||
See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
|
||||
examples for your environment.
|
||||
|
||||
## API
|
||||
|
||||
### normalize([options])
|
||||
|
||||
Please see the [normalize-url documentation][docs]. By default,
|
||||
`normalizeProtocol`, `stripHash` & `stripWWW` are set to `false`.
|
||||
|
||||
## Contributors
|
||||
|
||||
See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Ben Briggs](http://beneb.info)
|
||||
|
||||
[docs]: https://github.com/sindresorhus/normalize-url#options
|
||||
[postcss]: https://github.com/postcss/postcss
|
73
node_modules/postcss-normalize-url/package.json
generated
vendored
Normal file
73
node_modules/postcss-normalize-url/package.json
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
"_from": "postcss-normalize-url@^5.1.0",
|
||||
"_id": "postcss-normalize-url@5.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-5upGeDO+PVthOxSmds43ZeMeZfKH+/DKgGRD7TElkkyS46JXAUhMzIKiCa7BabPeIy3AQcTkXwVVN7DbqsiCew==",
|
||||
"_location": "/postcss-normalize-url",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "postcss-normalize-url@^5.1.0",
|
||||
"name": "postcss-normalize-url",
|
||||
"escapedName": "postcss-normalize-url",
|
||||
"rawSpec": "^5.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^5.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cssnano-preset-default"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/postcss-normalize-url/-/postcss-normalize-url-5.1.0.tgz",
|
||||
"_shasum": "ed9d88ca82e21abef99f743457d3729a042adcdc",
|
||||
"_spec": "postcss-normalize-url@^5.1.0",
|
||||
"_where": "C:\\Users\\zhouxueli\\Desktop\\scheduling-app\\node_modules\\cssnano-preset-default",
|
||||
"author": {
|
||||
"name": "Ben Briggs",
|
||||
"email": "beneb.info@gmail.com",
|
||||
"url": "http://beneb.info"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/cssnano/cssnano/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"normalize-url": "^6.0.1",
|
||||
"postcss-value-parser": "^4.2.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Normalize URLs with PostCSS",
|
||||
"devDependencies": {
|
||||
"postcss": "^8.2.15"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || >=14.0"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"LICENSE-MIT",
|
||||
"types"
|
||||
],
|
||||
"homepage": "https://github.com/cssnano/cssnano",
|
||||
"keywords": [
|
||||
"css",
|
||||
"normalize",
|
||||
"optimise",
|
||||
"optimisation",
|
||||
"postcss",
|
||||
"postcss-plugin",
|
||||
"url"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "src/index.js",
|
||||
"name": "postcss-normalize-url",
|
||||
"peerDependencies": {
|
||||
"postcss": "^8.2.15"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/cssnano/cssnano.git"
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"version": "5.1.0"
|
||||
}
|
167
node_modules/postcss-normalize-url/src/index.js
generated
vendored
Normal file
167
node_modules/postcss-normalize-url/src/index.js
generated
vendored
Normal file
@ -0,0 +1,167 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const valueParser = require('postcss-value-parser');
|
||||
const normalize = require('normalize-url');
|
||||
|
||||
const multiline = /\\[\r\n]/;
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
const escapeChars = /([\s\(\)"'])/g;
|
||||
|
||||
// Scheme: https://tools.ietf.org/html/rfc3986#section-3.1
|
||||
// Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
|
||||
const ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/;
|
||||
// Windows paths like `c:\`
|
||||
const WINDOWS_PATH_REGEX = /^[a-zA-Z]:\\/;
|
||||
|
||||
/**
|
||||
* Originally in sindresorhus/is-absolute-url
|
||||
*
|
||||
* @param {string} url
|
||||
*/
|
||||
function isAbsolute(url) {
|
||||
if (WINDOWS_PATH_REGEX.test(url)) {
|
||||
return false;
|
||||
}
|
||||
return ABSOLUTE_URL_REGEX.test(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} url
|
||||
* @param {normalize.Options} options
|
||||
* @return {string}
|
||||
*/
|
||||
function convert(url, options) {
|
||||
if (isAbsolute(url) || url.startsWith('//')) {
|
||||
let normalizedURL;
|
||||
|
||||
try {
|
||||
normalizedURL = normalize(url, options);
|
||||
} catch (e) {
|
||||
normalizedURL = url;
|
||||
}
|
||||
|
||||
return normalizedURL;
|
||||
}
|
||||
|
||||
// `path.normalize` always returns backslashes on Windows, need replace in `/`
|
||||
return path.normalize(url).replace(new RegExp('\\' + path.sep, 'g'), '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('postcss').AtRule} rule
|
||||
* @return {void}
|
||||
*/
|
||||
function transformNamespace(rule) {
|
||||
rule.params = valueParser(rule.params)
|
||||
.walk((node) => {
|
||||
if (
|
||||
node.type === 'function' &&
|
||||
node.value.toLowerCase() === 'url' &&
|
||||
node.nodes.length
|
||||
) {
|
||||
/** @type {valueParser.Node} */ (node).type = 'string';
|
||||
/** @type {any} */ (node).quote =
|
||||
node.nodes[0].type === 'string' ? node.nodes[0].quote : '"';
|
||||
node.value = node.nodes[0].value;
|
||||
}
|
||||
if (node.type === 'string') {
|
||||
node.value = node.value.trim();
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('postcss').Declaration} decl
|
||||
* @param {normalize.Options} opts
|
||||
* @return {void}
|
||||
*/
|
||||
function transformDecl(decl, opts) {
|
||||
decl.value = valueParser(decl.value)
|
||||
.walk((node) => {
|
||||
if (node.type !== 'function' || node.value.toLowerCase() !== 'url') {
|
||||
return false;
|
||||
}
|
||||
|
||||
node.before = node.after = '';
|
||||
|
||||
if (!node.nodes.length) {
|
||||
return false;
|
||||
}
|
||||
let url = node.nodes[0];
|
||||
let escaped;
|
||||
|
||||
url.value = url.value.trim().replace(multiline, '');
|
||||
|
||||
// Skip empty URLs
|
||||
// Empty URL function equals request to current stylesheet where it is declared
|
||||
if (url.value.length === 0) {
|
||||
/** @type {any} */ (url).quote = '';
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (/^data:(.*)?,/i.test(url.value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!/^.+-extension:\//i.test(url.value)) {
|
||||
url.value = convert(url.value, opts);
|
||||
}
|
||||
|
||||
if (escapeChars.test(url.value) && url.type === 'string') {
|
||||
escaped = url.value.replace(escapeChars, '\\$1');
|
||||
|
||||
if (escaped.length < url.value.length + 2) {
|
||||
url.value = escaped;
|
||||
/** @type {valueParser.Node} */ (url).type = 'word';
|
||||
}
|
||||
} else {
|
||||
url.type = 'word';
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
.toString();
|
||||
}
|
||||
|
||||
/** @typedef {normalize.Options} Options */
|
||||
/**
|
||||
* @type {import('postcss').PluginCreator<Options>}
|
||||
* @param {Options} opts
|
||||
* @return {import('postcss').Plugin}
|
||||
*/
|
||||
function pluginCreator(opts) {
|
||||
opts = Object.assign(
|
||||
{},
|
||||
{
|
||||
normalizeProtocol: false,
|
||||
sortQueryParameters: false,
|
||||
stripHash: false,
|
||||
stripWWW: false,
|
||||
stripTextFragment: false,
|
||||
},
|
||||
opts
|
||||
);
|
||||
|
||||
return {
|
||||
postcssPlugin: 'postcss-normalize-url',
|
||||
|
||||
OnceExit(css) {
|
||||
css.walk((node) => {
|
||||
if (node.type === 'decl') {
|
||||
return transformDecl(node, opts);
|
||||
} else if (
|
||||
node.type === 'atrule' &&
|
||||
node.name.toLowerCase() === 'namespace'
|
||||
) {
|
||||
return transformNamespace(node);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
pluginCreator.postcss = true;
|
||||
module.exports = pluginCreator;
|
14
node_modules/postcss-normalize-url/types/index.d.ts
generated
vendored
Normal file
14
node_modules/postcss-normalize-url/types/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
export = pluginCreator;
|
||||
/** @typedef {normalize.Options} Options */
|
||||
/**
|
||||
* @type {import('postcss').PluginCreator<Options>}
|
||||
* @param {Options} opts
|
||||
* @return {import('postcss').Plugin}
|
||||
*/
|
||||
declare function pluginCreator(opts: Options): import('postcss').Plugin;
|
||||
declare namespace pluginCreator {
|
||||
export { postcss, Options };
|
||||
}
|
||||
type Options = normalize.Options;
|
||||
declare var postcss: true;
|
||||
import normalize = require("normalize-url");
|
Reference in New Issue
Block a user