summaryrefslogtreecommitdiff
path: root/node_modules/postcss-normalize-charset
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/postcss-normalize-charset')
-rw-r--r--node_modules/postcss-normalize-charset/LICENSE20
-rw-r--r--node_modules/postcss-normalize-charset/README.md43
-rw-r--r--node_modules/postcss-normalize-charset/package.json34
-rw-r--r--node_modules/postcss-normalize-charset/src/index.js56
-rw-r--r--node_modules/postcss-normalize-charset/types/index.d.ts17
5 files changed, 170 insertions, 0 deletions
diff --git a/node_modules/postcss-normalize-charset/LICENSE b/node_modules/postcss-normalize-charset/LICENSE
new file mode 100644
index 00000000..066ee676
--- /dev/null
+++ b/node_modules/postcss-normalize-charset/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright 2015 Bogdan Chadkin <trysound@yandex.ru>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/postcss-normalize-charset/README.md b/node_modules/postcss-normalize-charset/README.md
new file mode 100644
index 00000000..51f30601
--- /dev/null
+++ b/node_modules/postcss-normalize-charset/README.md
@@ -0,0 +1,43 @@
+# postcss-normalize-charset
+
+Add necessary or remove extra charset with PostCSS
+
+```css
+a{
+ content: "©";
+}
+```
+
+```css
+@charset "utf-8";
+a{
+ content: "©";
+}
+```
+
+## API
+
+### normalizeCharset([options])
+
+#### options
+
+##### add
+
+Type: `boolean`
+Default: `true`
+
+Pass `false` to stop the module from adding a `@charset` declaration if it was
+missing from the file (and the file contained non-ascii characters).
+
+## Usage
+
+See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
+examples for your environment.
+
+## Contributors
+
+See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
+
+## License
+
+MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)
diff --git a/node_modules/postcss-normalize-charset/package.json b/node_modules/postcss-normalize-charset/package.json
new file mode 100644
index 00000000..bbf43323
--- /dev/null
+++ b/node_modules/postcss-normalize-charset/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "postcss-normalize-charset",
+ "version": "6.0.0",
+ "description": "Add necessary or remove extra charset with PostCSS",
+ "keywords": [
+ "postcss",
+ "css",
+ "postcss-plugin",
+ "charset"
+ ],
+ "author": "Bogdan Chadkin <trysound@yandex.ru>",
+ "files": [
+ "src",
+ "LICENSE",
+ "types"
+ ],
+ "license": "MIT",
+ "repository": "cssnano/cssnano",
+ "bugs": {
+ "url": "https://github.com/cssnano/cssnano/issues"
+ },
+ "homepage": "https://github.com/cssnano/cssnano",
+ "main": "src/index.js",
+ "types": "types/index.d.ts",
+ "engines": {
+ "node": "^14 || ^16 || >=18.0"
+ },
+ "devDependencies": {
+ "postcss": "^8.2.15"
+ },
+ "peerDependencies": {
+ "postcss": "^8.2.15"
+ }
+} \ No newline at end of file
diff --git a/node_modules/postcss-normalize-charset/src/index.js b/node_modules/postcss-normalize-charset/src/index.js
new file mode 100644
index 00000000..eb8cde80
--- /dev/null
+++ b/node_modules/postcss-normalize-charset/src/index.js
@@ -0,0 +1,56 @@
+'use strict';
+const charset = 'charset';
+// eslint-disable-next-line no-control-regex
+const nonAscii = /[^\x00-\x7F]/;
+
+/**
+ * @typedef {{add?: boolean}} Options
+ */
+/**
+ * @type {import('postcss').PluginCreator<Options>}
+ * @param {Options} opts
+ * @return {import('postcss').Plugin}
+ */
+function pluginCreator(opts = {}) {
+ return {
+ postcssPlugin: 'postcss-normalize-' + charset,
+
+ OnceExit(css, { AtRule }) {
+ /** @type {import('postcss').AtRule | undefined} */
+ let charsetRule;
+ /** @type {import('postcss').Node | undefined} */
+ let nonAsciiNode;
+
+ css.walk((node) => {
+ if (node.type === 'atrule' && node.name === charset) {
+ if (!charsetRule) {
+ charsetRule = node;
+ }
+ node.remove();
+ } else if (
+ !nonAsciiNode &&
+ node.parent === css &&
+ nonAscii.test(node.toString())
+ ) {
+ nonAsciiNode = node;
+ }
+ });
+
+ if (nonAsciiNode) {
+ if (!charsetRule && opts.add !== false) {
+ charsetRule = new AtRule({
+ name: charset,
+ params: '"utf-8"',
+ });
+ }
+ if (charsetRule) {
+ charsetRule.source = nonAsciiNode.source;
+ css.prepend(charsetRule);
+ }
+ }
+ },
+ };
+}
+
+pluginCreator.postcss = true;
+module.exports = pluginCreator;
diff --git a/node_modules/postcss-normalize-charset/types/index.d.ts b/node_modules/postcss-normalize-charset/types/index.d.ts
new file mode 100644
index 00000000..df7ad766
--- /dev/null
+++ b/node_modules/postcss-normalize-charset/types/index.d.ts
@@ -0,0 +1,17 @@
+export = pluginCreator;
+/**
+ * @typedef {{add?: boolean}} 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 = {
+ add?: boolean;
+};
+declare var postcss: true;