postcss-normalize-string 8.0.1 → 8.0.3
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 +1 -1
- package/README.md +1 -1
- package/package.json +21 -7
- package/src/index.js +15 -10
- package/types/index.d.ts +13 -19
- package/types/index.d.ts.map +1 -1
package/LICENSE-MIT
CHANGED
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-normalize-string",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.3",
|
|
4
4
|
"description": "Normalize wrapping quotes for CSS string literals.",
|
|
5
|
-
"
|
|
6
|
-
|
|
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
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
7
15
|
"files": [
|
|
8
16
|
"src",
|
|
9
17
|
"LICENSE-MIT",
|
|
@@ -19,9 +27,12 @@
|
|
|
19
27
|
"author": {
|
|
20
28
|
"name": "Ben Briggs",
|
|
21
29
|
"email": "beneb.info@gmail.com",
|
|
22
|
-
"url": "
|
|
30
|
+
"url": "https://beneb.info"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "cssnano/cssnano"
|
|
23
35
|
},
|
|
24
|
-
"repository": "cssnano/cssnano",
|
|
25
36
|
"dependencies": {
|
|
26
37
|
"postcss-value-parser": "^4.2.0"
|
|
27
38
|
},
|
|
@@ -32,9 +43,12 @@
|
|
|
32
43
|
"node": "^22.11.0 || ^24.11.0 || >=26.0"
|
|
33
44
|
},
|
|
34
45
|
"devDependencies": {
|
|
35
|
-
"postcss": "^8.5.
|
|
46
|
+
"postcss": "^8.5.26"
|
|
36
47
|
},
|
|
37
48
|
"peerDependencies": {
|
|
38
|
-
"postcss": "^8.5.
|
|
49
|
+
"postcss": "^8.5.26"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"test": "node --test"
|
|
39
53
|
}
|
|
40
54
|
}
|
package/src/index.js
CHANGED
|
@@ -46,7 +46,7 @@ const T_SINGLE_QUOTE = { type: C_SINGLE_QUOTE, value: L_SINGLE_QUOTE };
|
|
|
46
46
|
const T_DOUBLE_QUOTE = { type: C_DOUBLE_QUOTE, value: L_DOUBLE_QUOTE };
|
|
47
47
|
const T_NEWLINE = { type: C_NEWLINE, value: L_NEWLINE };
|
|
48
48
|
|
|
49
|
-
/** @typedef {T_ESCAPED_SINGLE_QUOTE | T_ESCAPED_DOUBLE_QUOTE | T_SINGLE_QUOTE | T_NEWLINE} StringAstNode */
|
|
49
|
+
/** @typedef {typeof T_ESCAPED_SINGLE_QUOTE | typeof T_ESCAPED_DOUBLE_QUOTE | typeof T_SINGLE_QUOTE | typeof T_NEWLINE} StringAstNode */
|
|
50
50
|
/**
|
|
51
51
|
* @typedef {{nodes: StringAstNode[],
|
|
52
52
|
* types: {escapedSingleQuote: number, escapedDoubleQuote: number, singleQuote: number, doubleQuote: number},
|
|
@@ -58,14 +58,14 @@ const T_NEWLINE = { type: C_NEWLINE, value: L_NEWLINE };
|
|
|
58
58
|
* @return {string}
|
|
59
59
|
*/
|
|
60
60
|
function stringify(ast) {
|
|
61
|
-
|
|
61
|
+
let str = '';
|
|
62
|
+
for (const { value } of ast.nodes) {
|
|
62
63
|
// Collapse multiple line strings automatically
|
|
63
|
-
if (value
|
|
64
|
-
|
|
64
|
+
if (value !== L_NEWLINE) {
|
|
65
|
+
str += value;
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}, '');
|
|
67
|
+
}
|
|
68
|
+
return str;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
@@ -75,7 +75,7 @@ function stringify(ast) {
|
|
|
75
75
|
function parse(str) {
|
|
76
76
|
let code, next, value;
|
|
77
77
|
let pos = 0;
|
|
78
|
-
|
|
78
|
+
const len = str.length;
|
|
79
79
|
|
|
80
80
|
/** @type StringAst */
|
|
81
81
|
const ast = {
|
|
@@ -150,6 +150,7 @@ function parse(str) {
|
|
|
150
150
|
* We need to fall through here to handle the token as
|
|
151
151
|
* a whole word. The missing 'break' is intentional.
|
|
152
152
|
*/
|
|
153
|
+
// oxlint-disable-next-line no-fallthrough
|
|
153
154
|
default:
|
|
154
155
|
WORD_END.lastIndex = pos + 1;
|
|
155
156
|
WORD_END.test(str);
|
|
@@ -279,7 +280,6 @@ function minify(original, cache, preferredQuote) {
|
|
|
279
280
|
|
|
280
281
|
/** @typedef {{preferredQuote?: 'double' | 'single'}} Options */
|
|
281
282
|
/**
|
|
282
|
-
* @type {import('postcss').PluginCreator<Options>}
|
|
283
283
|
* @param {Options} opts
|
|
284
284
|
* @return {import('postcss').Plugin}
|
|
285
285
|
*/
|
|
@@ -295,6 +295,9 @@ function pluginCreator(opts) {
|
|
|
295
295
|
return {
|
|
296
296
|
postcssPlugin: 'postcss-normalize-string',
|
|
297
297
|
|
|
298
|
+
/**
|
|
299
|
+
* @param {import('postcss').Root} css
|
|
300
|
+
*/
|
|
298
301
|
OnceExit(css) {
|
|
299
302
|
const cache = new Map();
|
|
300
303
|
|
|
@@ -316,4 +319,6 @@ function pluginCreator(opts) {
|
|
|
316
319
|
}
|
|
317
320
|
|
|
318
321
|
pluginCreator.postcss = true;
|
|
319
|
-
module.exports =
|
|
322
|
+
module.exports = /** @type {import('postcss').PluginCreator<Options>}*/ (
|
|
323
|
+
pluginCreator
|
|
324
|
+
);
|
package/types/index.d.ts
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @type {import('postcss').PluginCreator<Options>}
|
|
5
|
-
* @param {Options} opts
|
|
6
|
-
* @return {import('postcss').Plugin}
|
|
7
|
-
*/
|
|
8
|
-
declare function pluginCreator(opts: Options): import("postcss").Plugin;
|
|
9
|
-
declare namespace pluginCreator {
|
|
10
|
-
export { postcss, StringAstNode, StringAst, Options };
|
|
11
|
-
}
|
|
12
|
-
declare var postcss: true;
|
|
13
|
-
type StringAstNode = {
|
|
1
|
+
declare const _exports: import("postcss").PluginCreator<Options>;
|
|
2
|
+
export = _exports;
|
|
3
|
+
declare const T_ESCAPED_SINGLE_QUOTE: {
|
|
14
4
|
type: string;
|
|
15
5
|
value: string;
|
|
16
|
-
}
|
|
6
|
+
};
|
|
7
|
+
declare const T_ESCAPED_DOUBLE_QUOTE: {
|
|
17
8
|
type: string;
|
|
18
9
|
value: string;
|
|
19
|
-
}
|
|
10
|
+
};
|
|
11
|
+
declare const T_SINGLE_QUOTE: {
|
|
20
12
|
type: string;
|
|
21
13
|
value: string;
|
|
22
|
-
}
|
|
14
|
+
};
|
|
15
|
+
declare const T_NEWLINE: {
|
|
23
16
|
type: string;
|
|
24
17
|
value: string;
|
|
25
18
|
};
|
|
26
|
-
type
|
|
19
|
+
export type StringAstNode = typeof T_ESCAPED_SINGLE_QUOTE | typeof T_ESCAPED_DOUBLE_QUOTE | typeof T_SINGLE_QUOTE | typeof T_NEWLINE;
|
|
20
|
+
export type StringAst = {
|
|
27
21
|
nodes: StringAstNode[];
|
|
28
22
|
types: {
|
|
29
23
|
escapedSingleQuote: number;
|
|
@@ -33,7 +27,7 @@ type StringAst = {
|
|
|
33
27
|
};
|
|
34
28
|
quotes: boolean;
|
|
35
29
|
};
|
|
36
|
-
type Options = {
|
|
37
|
-
preferredQuote?:
|
|
30
|
+
export type Options = {
|
|
31
|
+
preferredQuote?: 'double' | 'single';
|
|
38
32
|
};
|
|
39
33
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;AA0CA,QAAA,MAAM,sBAAsB;;;CAAiD,CAAC;AAC9E,QAAA,MAAM,sBAAsB;;;CAAiD,CAAC;AAC9E,QAAA,MAAM,cAAc;;;CAAkD,CAAC;AAEvE,QAAA,MAAM,SAAS;;;CAAwC,CAAC;AAEpD,YAAoH,aAAa,GAAvH,OAAO,sBAAsB,GAAG,OAAO,sBAAsB,GAAG,OAAO,cAAc,GAAG,OAAO,SAAS,CAAe;AAElI,YAE6B,SAAS,GAF5B;IAAC,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,KAAK,EAAE;QAAC,kBAAkB,EAAE,MAAM,CAAC;QAAC,kBAAkB,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAC,CAAC;IAC1G,MAAM,EAAE,OAAO,CAAA;CAAC,CAAW;AAoOrC,YAAkD,OAAO,GAA/C;IAAC,cAAc,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;CAAC,CAAS"}
|