postcss-normalize-charset 5.0.1 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-normalize-charset",
3
- "version": "5.0.1",
3
+ "version": "5.1.0",
4
4
  "description": "Add necessary or remove extra charset with PostCSS",
5
5
  "keywords": [
6
6
  "postcss",
@@ -10,7 +10,9 @@
10
10
  ],
11
11
  "author": "Bogdan Chadkin <trysound@yandex.ru>",
12
12
  "files": [
13
- "dist"
13
+ "src",
14
+ "LICENSE",
15
+ "types"
14
16
  ],
15
17
  "license": "MIT",
16
18
  "repository": "cssnano/cssnano",
@@ -18,12 +20,8 @@
18
20
  "url": "https://github.com/cssnano/cssnano/issues"
19
21
  },
20
22
  "homepage": "https://github.com/cssnano/cssnano",
21
- "main": "dist/index.js",
22
- "scripts": {
23
- "prebuild": "del-cli dist",
24
- "build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
25
- "prepublish": "yarn build"
26
- },
23
+ "main": "src/index.js",
24
+ "types": "types/index.d.ts",
27
25
  "engines": {
28
26
  "node": "^10 || ^12 || >=14.0"
29
27
  },
@@ -33,5 +31,5 @@
33
31
  "peerDependencies": {
34
32
  "postcss": "^8.2.15"
35
33
  },
36
- "gitHead": "28c247175032fa03f04911cde56ad82d74d211cc"
37
- }
34
+ "readme": "# postcss-normalize-charset\n\nAdd necessary or remove extra charset with PostCSS\n\n```css\na{\n content: \"©\";\n}\n```\n\n```css\n@charset \"utf-8\";\na{\n content: \"©\";\n}\n```\n\n## API\n\n### normalizeCharset([options])\n\n#### options\n\n##### add\n\nType: `boolean` \nDefault: `true`\n\nPass `false` to stop the module from adding a `@charset` declaration if it was\nmissing from the file (and the file contained non-ascii characters).\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n## License\n\nMIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)\n"
35
+ }
@@ -1,30 +1,37 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- const charset = 'charset'; // eslint-disable-next-line no-control-regex
8
-
1
+ 'use strict';
2
+ const charset = 'charset';
3
+ // eslint-disable-next-line no-control-regex
9
4
  const nonAscii = /[^\x00-\x7F]/;
10
5
 
6
+ /**
7
+ * @typedef {{add?: boolean}} Options
8
+ */
9
+ /**
10
+ * @type {import('postcss').PluginCreator<Options>}
11
+ * @param {Options} opts
12
+ * @return {import('postcss').Plugin}
13
+ */
11
14
  function pluginCreator(opts = {}) {
12
15
  return {
13
16
  postcssPlugin: 'postcss-normalize-' + charset,
14
17
 
15
- OnceExit(css, {
16
- AtRule
17
- }) {
18
+ OnceExit(css, { AtRule }) {
19
+ /** @type {import('postcss').AtRule | undefined} */
18
20
  let charsetRule;
21
+ /** @type {import('postcss').Node | undefined} */
19
22
  let nonAsciiNode;
20
- css.walk(node => {
23
+
24
+ css.walk((node) => {
21
25
  if (node.type === 'atrule' && node.name === charset) {
22
26
  if (!charsetRule) {
23
27
  charsetRule = node;
24
28
  }
25
-
26
29
  node.remove();
27
- } else if (!nonAsciiNode && node.parent === css && nonAscii.test(node.toString())) {
30
+ } else if (
31
+ !nonAsciiNode &&
32
+ node.parent === css &&
33
+ nonAscii.test(node.toString())
34
+ ) {
28
35
  nonAsciiNode = node;
29
36
  }
30
37
  });
@@ -33,21 +40,17 @@ function pluginCreator(opts = {}) {
33
40
  if (!charsetRule && opts.add !== false) {
34
41
  charsetRule = new AtRule({
35
42
  name: charset,
36
- params: '"utf-8"'
43
+ params: '"utf-8"',
37
44
  });
38
45
  }
39
-
40
46
  if (charsetRule) {
41
47
  charsetRule.source = nonAsciiNode.source;
42
48
  css.prepend(charsetRule);
43
49
  }
44
50
  }
45
- }
46
-
51
+ },
47
52
  };
48
53
  }
49
54
 
50
55
  pluginCreator.postcss = true;
51
- var _default = pluginCreator;
52
- exports.default = _default;
53
- module.exports = exports.default;
56
+ module.exports = pluginCreator;
@@ -0,0 +1,17 @@
1
+ export = pluginCreator;
2
+ /**
3
+ * @typedef {{add?: boolean}} Options
4
+ */
5
+ /**
6
+ * @type {import('postcss').PluginCreator<Options>}
7
+ * @param {Options} opts
8
+ * @return {import('postcss').Plugin}
9
+ */
10
+ declare function pluginCreator(opts?: Options): import('postcss').Plugin;
11
+ declare namespace pluginCreator {
12
+ export { postcss, Options };
13
+ }
14
+ type Options = {
15
+ add?: boolean;
16
+ };
17
+ declare var postcss: true;
package/CHANGELOG.md DELETED
@@ -1,63 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [5.0.1](https://github.com/cssnano/cssnano/compare/postcss-normalize-charset@5.0.0...postcss-normalize-charset@5.0.1) (2021-05-19)
7
-
8
- **Note:** Version bump only for package postcss-normalize-charset
9
-
10
-
11
-
12
-
13
-
14
- # [5.0.0](https://github.com/cssnano/cssnano/compare/postcss-normalize-charset@5.0.0-rc.2...postcss-normalize-charset@5.0.0) (2021-04-06)
15
-
16
- **Note:** Version bump only for package postcss-normalize-charset
17
-
18
-
19
-
20
-
21
-
22
- # [5.0.0-rc.2](https://github.com/cssnano/cssnano/compare/postcss-normalize-charset@5.0.0-rc.1...postcss-normalize-charset@5.0.0-rc.2) (2021-03-15)
23
-
24
- **Note:** Version bump only for package postcss-normalize-charset
25
-
26
-
27
-
28
-
29
-
30
- # [5.0.0-rc.1](https://github.com/cssnano/cssnano/compare/postcss-normalize-charset@5.0.0-rc.0...postcss-normalize-charset@5.0.0-rc.1) (2021-03-04)
31
-
32
- **Note:** Version bump only for package postcss-normalize-charset
33
-
34
-
35
-
36
-
37
-
38
- # 5.0.0-rc.0 (2021-02-19)
39
-
40
-
41
- ### chore
42
-
43
- * minimum require version of node is 10.13 ([#871](https://github.com/cssnano/cssnano/issues/871)) ([28bda24](https://github.com/cssnano/cssnano/commit/28bda243e32ce3ba89b3c358a5f78727b3732f11))
44
-
45
-
46
- ### Features
47
-
48
- * migarete to PostCSS 8 ([#975](https://github.com/cssnano/cssnano/issues/975)) ([40b82dc](https://github.com/cssnano/cssnano/commit/40b82dca7f53ac02cd4fe62846dec79b898ccb49))
49
-
50
-
51
- ### BREAKING CHANGES
52
-
53
- * minimum supported `postcss` version is `8.2.1`
54
- * minimum require version of node is 10.13
55
-
56
-
57
-
58
- ## 4.1.2 (2018-09-25)
59
-
60
-
61
- ### Bug Fixes
62
-
63
- * **postcss-merge-longhand:** not mangle border output ([#555](https://github.com/cssnano/cssnano/issues/555)) ([9a70605](https://github.com/cssnano/cssnano/commit/9a706050b621e7795a9bf74eb7110b5c81804ffe)), closes [#553](https://github.com/cssnano/cssnano/issues/553) [#554](https://github.com/cssnano/cssnano/issues/554)