postcss-discard-comments 8.0.1 → 8.0.2

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/LICENSE-MIT CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) Ben Briggs <beneb.info@gmail.com> (http://beneb.info)
1
+ Copyright (c) Ben Briggs <beneb.info@gmail.com> (https://beneb.info)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
package/README.md CHANGED
@@ -108,7 +108,7 @@ See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTOR
108
108
 
109
109
  ## License
110
110
 
111
- MIT © [Ben Briggs](http://beneb.info)
111
+ MIT © [Ben Briggs](https://beneb.info)
112
112
 
113
113
 
114
114
  [postcss]: https://github.com/postcss/postcss
package/package.json CHANGED
@@ -1,9 +1,19 @@
1
1
  {
2
2
  "name": "postcss-discard-comments",
3
- "version": "8.0.1",
3
+ "version": "8.0.2",
4
4
  "description": "Discard comments in your CSS files with PostCSS.",
5
- "main": "src/index.js",
6
- "types": "types/index.d.ts",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./types/index.d.ts",
8
+ "default": "./src/index.js"
9
+ },
10
+ "./src": "./src/index.js",
11
+ "./src/index": "./src/index.js",
12
+ "./src/index.js": "./src/index.js",
13
+ "./src/lib/*": "./src/lib/*.js",
14
+ "./src/lib/*.js": "./src/lib/*.js",
15
+ "./package.json": "./package.json"
16
+ },
7
17
  "files": [
8
18
  "src",
9
19
  "LICENSE-MIT",
@@ -20,11 +30,14 @@
20
30
  "author": {
21
31
  "name": "Ben Briggs",
22
32
  "email": "beneb.info@gmail.com",
23
- "url": "http://beneb.info"
33
+ "url": "https://beneb.info"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "cssnano/cssnano"
24
38
  },
25
- "repository": "cssnano/cssnano",
26
39
  "dependencies": {
27
- "postcss-selector-parser": "^7.1.2"
40
+ "postcss-selector-parser": "^7.1.4"
28
41
  },
29
42
  "bugs": {
30
43
  "url": "https://github.com/cssnano/cssnano/issues"
@@ -33,11 +46,11 @@
33
46
  "node": "^22.11.0 || ^24.11.0 || >=26.0"
34
47
  },
35
48
  "devDependencies": {
36
- "postcss": "^8.5.15",
49
+ "postcss": "^8.5.25",
37
50
  "postcss-scss": "^4.0.9",
38
51
  "postcss-simple-vars": "^7.0.1"
39
52
  },
40
53
  "peerDependencies": {
41
- "postcss": "^8.5.15"
54
+ "postcss": "^8.5.25"
42
55
  }
43
56
  }
package/src/index.js CHANGED
@@ -9,7 +9,6 @@ const selectorParser = require('postcss-selector-parser');
9
9
  * @property {(s: string) => boolean=} remove
10
10
  */
11
11
  /**
12
- * @type {import('postcss').PluginCreator<Options>}
13
12
  * @param {Options} opts
14
13
  * @return {import('postcss').Plugin}
15
14
  */
@@ -65,7 +64,7 @@ function pluginCreator(opts = {}) {
65
64
  return replacerCache.get(key);
66
65
  }
67
66
 
68
- if (source.indexOf('/*') === -1) {
67
+ if (!source.includes('/*')) {
69
68
  const normalized = space(source).join(' ');
70
69
 
71
70
  replacerCache.set(key, normalized);
@@ -112,7 +111,7 @@ function pluginCreator(opts = {}) {
112
111
  if (replacerCache.has(key)) {
113
112
  return replacerCache.get(key);
114
113
  }
115
- if (source.indexOf('/*') === -1) {
114
+ if (!source.includes('/*')) {
116
115
  const normalized = space(source).join(' ');
117
116
 
118
117
  replacerCache.set(key, normalized);
@@ -149,7 +148,10 @@ function pluginCreator(opts = {}) {
149
148
 
150
149
  return {
151
150
  postcssPlugin: 'postcss-discard-comments',
152
-
151
+ /**
152
+ * @param {import('postcss').Root} css
153
+ * @param {import('postcss').Helpers} helpers
154
+ */
153
155
  OnceExit(css, { list }) {
154
156
  css.walk((node) => {
155
157
  if (node.type === 'comment' && remover.canRemove(node.text)) {
@@ -236,4 +238,6 @@ function pluginCreator(opts = {}) {
236
238
  }
237
239
 
238
240
  pluginCreator.postcss = true;
239
- module.exports = pluginCreator;
241
+ module.exports = /** @type {import('postcss').PluginCreator<Options>}*/ (
242
+ pluginCreator
243
+ );
@@ -1,32 +1,34 @@
1
1
  'use strict';
2
2
 
3
- /** @param {import('../index.js').Options} options */
4
- function CommentRemover(options) {
5
- this.options = options;
6
- }
7
- /**
8
- * @param {string} comment
9
- * @return {boolean | undefined}
10
- */
11
- CommentRemover.prototype.canRemove = function (comment) {
12
- const remove = this.options.remove;
3
+ class CommentRemover {
4
+ /** @param {import('../index.js').Options} options */
5
+ constructor(options) {
6
+ this.options = options;
7
+ }
8
+ /**
9
+ * @param {string} comment
10
+ * @return {boolean | undefined}
11
+ */
12
+ canRemove(comment) {
13
+ const remove = this.options.remove;
13
14
 
14
- if (remove) {
15
- return remove(comment);
16
- } else {
17
- const isImportant = comment.indexOf('!') === 0;
15
+ if (remove) {
16
+ return remove(comment);
17
+ } else {
18
+ const isImportant = comment.indexOf('!') === 0;
18
19
 
19
- if (!isImportant) {
20
- return true;
21
- }
20
+ if (!isImportant) {
21
+ return true;
22
+ }
22
23
 
23
- if (this.options.removeAll || this._hasFirst) {
24
- return true;
25
- } else if (this.options.removeAllButFirst && !this._hasFirst) {
26
- this._hasFirst = true;
27
- return false;
24
+ if (this.options.removeAll || this._hasFirst) {
25
+ return true;
26
+ } else if (this.options.removeAllButFirst && !this._hasFirst) {
27
+ this._hasFirst = true;
28
+ return false;
29
+ }
28
30
  }
29
31
  }
30
- };
32
+ }
31
33
 
32
34
  module.exports = CommentRemover;
package/types/index.d.ts CHANGED
@@ -1,20 +1,6 @@
1
- export = pluginCreator;
2
- /** @typedef {object} Options
3
- * @property {boolean=} removeAll
4
- * @property {boolean=} removeAllButFirst
5
- * @property {(s: string) => boolean=} remove
6
- */
7
- /**
8
- * @type {import('postcss').PluginCreator<Options>}
9
- * @param {Options} opts
10
- * @return {import('postcss').Plugin}
11
- */
12
- declare function pluginCreator(opts?: Options): import("postcss").Plugin;
13
- declare namespace pluginCreator {
14
- export { postcss, Options };
15
- }
16
- declare var postcss: true;
17
- type Options = {
1
+ declare const _exports: import("postcss").PluginCreator<Options>;
2
+ export = _exports;
3
+ export type Options = {
18
4
  removeAll?: boolean | undefined;
19
5
  removeAllButFirst?: boolean | undefined;
20
6
  remove?: ((s: string) => boolean) | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AAKA;;;;GAIG;AACH;;;;GAIG;AACH,sCAHW,OAAO,GACN,OAAO,SAAS,EAAE,MAAM,CA8NnC;;;;;;gBArOc,OAAO,YAAC;wBACR,OAAO,YAAC;aACR,CAAA,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,aAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;AAKI,YAAkB,OAAO,GACzB;IAAqB,SAAS,AAA9B,CACA,EADW,OAAO,YAAC,CACnB;IAAqB,iBAAiB,AAAtC,CACA,EADW,OAAO,YAAC,CACnB;IAAoC,MAAM,AAA1C,CACH,EADc,CAAA,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,aAAC,CACrC;CAAA,CAAA"}
@@ -1,3 +1,10 @@
1
- declare function _exports(input: string): [number, number, number][];
2
- export = _exports;
1
+ export = commentParser;
2
+ /**
3
+ * CSS Comment Parser with context awareness
4
+ * Properly handles comments inside strings, URLs, and escaped characters
5
+ *
6
+ * @param {string} input
7
+ * @return {[number, number, number][]}
8
+ */
9
+ declare function commentParser(input: string): [number, number, number][];
3
10
  //# sourceMappingURL=commentParser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commentParser.d.ts","sourceRoot":"","sources":["../../src/lib/commentParser.js"],"names":[],"mappings":"AAiBiB,iCAHN,MAAM,GACL,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CA+ErC"}
1
+ {"version":3,"file":"commentParser.d.ts","sourceRoot":"","sources":["../../src/lib/commentParser.js"],"names":[],"mappings":";AAUA;;;;;;GAMG;+BACqC,KAAK,EAHlC,MAGkC,GAFjC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE"}
@@ -1,15 +1,13 @@
1
1
  export = CommentRemover;
2
- /** @param {import('../index.js').Options} options */
3
- declare function CommentRemover(options: import("../index.js").Options): void;
4
2
  declare class CommentRemover {
5
- /** @param {import('../index.js').Options} options */
6
- constructor(options: import("../index.js").Options);
7
3
  options: import("../index.js").Options;
4
+ _hasFirst: boolean | undefined;
5
+ /** @param {import('../index.js').Options} options */
6
+ constructor(options: import('../index.js').Options);
8
7
  /**
9
8
  * @param {string} comment
10
9
  * @return {boolean | undefined}
11
10
  */
12
11
  canRemove(comment: string): boolean | undefined;
13
- _hasFirst: boolean | undefined;
14
12
  }
15
13
  //# sourceMappingURL=commentRemover.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commentRemover.d.ts","sourceRoot":"","sources":["../../src/lib/commentRemover.js"],"names":[],"mappings":";AAEA,qDAAqD;AACrD,yCADY,OAAO,aAAa,EAAE,OAAO,QAGxC;;IAHD,qDAAqD;IACrD,qBADY,OAAO,aAAa,EAAE,OAAO,EAGxC;IADC,uCAAsB;IAExB;;;OAGG;IACH,mBAHW,MAAM,GACL,OAAO,GAAG,SAAS,CAqB9B;IAJK,+BAAqB"}
1
+ {"version":3,"file":"commentRemover.d.ts","sourceRoot":"","sources":["../../src/lib/commentRemover.js"],"names":[],"mappings":"SAiCiB,cAAc;AA/B/B,cAAM,cAAc;IAGX,OAAO;IAqBH,SAAS;IAvBpB,qDAAqD;IACrD,YAAY,OAAO,EADP,OAAO,aAAa,EAAE,OACf,EAElB;IACD;;;OAGG;IACH,SAAS,CAAC,OAAO,EAHN,MAGM,GAFL,OAAO,GAAG,SAAS,CAqB9B;CACF"}