postcss-convert-values 9.0.8 → 9.0.9

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-convert-values",
3
- "version": "9.0.8",
3
+ "version": "9.0.9",
4
4
  "description": "Convert values with PostCSS (e.g. ms -> s)",
5
5
  "exports": {
6
6
  ".": {
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "browserslist": "^4.29.3",
44
- "cssnano-utils": "^8.2.1"
44
+ "cssnano-utils": "^9.0.0"
45
45
  },
46
46
  "bugs": {
47
47
  "url": "https://github.com/cssnano/cssnano/issues"
@@ -6,6 +6,7 @@ import convert, {
6
6
  angleConv,
7
7
  freqConv,
8
8
  } from './convert.js';
9
+ import { numericSource } from './numericSource.js';
9
10
 
10
11
  const {
11
12
  TokenType,
@@ -14,7 +15,6 @@ const {
14
15
  decoded,
15
16
  lengthUnits,
16
17
  mathFunctions,
17
- numericSource,
18
18
  tokens,
19
19
  } = cssnanoUtils;
20
20
 
@@ -24,7 +24,7 @@ const {
24
24
  * unitless zero represents, while linear-gradient stops take a
25
25
  * <length-percentage>, which it does. */
26
26
  const functionsPreservingZeroUnits = new Set([
27
- ...mathFunctions,
27
+ ...mathFunctions.keys(),
28
28
  ...calcSumFunctions,
29
29
  'anchor',
30
30
  'anchor-size',
@@ -0,0 +1,53 @@
1
+ import cssnanoUtils from 'cssnano-utils';
2
+
3
+ const { TokenType, numeric, tokenEnd, tokenStart } = cssnanoUtils;
4
+
5
+ /** @typedef {ReturnType<typeof import('cssnano-utils').default.tokens>[number]} CSSToken */
6
+ /** @typedef {{index: number, start: number, end: number, raw: string, number: number, unit: string, hasDecimal: boolean}} NumericSource */
7
+
8
+ /**
9
+ * Capture one numeric source spelling, including PostCSS's historic `1.em`
10
+ * token shape. Its `end` is a character offset exclusive of the source.
11
+ *
12
+ * @param {CSSToken[]} input
13
+ * @param {number} index
14
+ * @return {NumericSource | false}
15
+ */
16
+ export function numericSource(input, index) {
17
+ const token = input[index];
18
+ const value = token && numeric(token);
19
+ if (!token || !value) return false;
20
+ let endIndex = index;
21
+ let end = tokenEnd(token);
22
+ let raw = token[1];
23
+ let unit = value.unit;
24
+ let hasDecimal = raw.includes('.');
25
+ const dot = input[endIndex + 1];
26
+ if (
27
+ token[0] === TokenType.Number &&
28
+ dot?.[0] === TokenType.Delim &&
29
+ dot[1] === '.' &&
30
+ tokenStart(dot) === end
31
+ ) {
32
+ raw += dot[1];
33
+ endIndex++;
34
+ end = tokenEnd(dot);
35
+ hasDecimal = true;
36
+ const ident = input[endIndex + 1];
37
+ if (ident?.[0] === TokenType.Ident && tokenStart(ident) === end) {
38
+ unit = ident[1];
39
+ raw += ident[1];
40
+ endIndex++;
41
+ end = tokenEnd(ident);
42
+ }
43
+ }
44
+ return {
45
+ index: endIndex,
46
+ start: tokenStart(token),
47
+ end,
48
+ raw,
49
+ ...value,
50
+ unit,
51
+ hasDecimal,
52
+ };
53
+ }
@@ -0,0 +1,22 @@
1
+ export type CSSToken = ReturnType<typeof import('cssnano-utils').default.tokens>[number];
2
+ export type NumericSource = {
3
+ index: number;
4
+ start: number;
5
+ end: number;
6
+ raw: string;
7
+ number: number;
8
+ unit: string;
9
+ hasDecimal: boolean;
10
+ };
11
+ /** @typedef {ReturnType<typeof import('cssnano-utils').default.tokens>[number]} CSSToken */
12
+ /** @typedef {{index: number, start: number, end: number, raw: string, number: number, unit: string, hasDecimal: boolean}} NumericSource */
13
+ /**
14
+ * Capture one numeric source spelling, including PostCSS's historic `1.em`
15
+ * token shape. Its `end` is a character offset exclusive of the source.
16
+ *
17
+ * @param {CSSToken[]} input
18
+ * @param {number} index
19
+ * @return {NumericSource | false}
20
+ */
21
+ export declare function numericSource(input: CSSToken[], index: number): NumericSource | false;
22
+ //# sourceMappingURL=numericSource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numericSource.d.ts","sourceRoot":"","sources":["../../src/lib/numericSource.js"],"names":[],"mappings":"AAII,YAA6E,QAAQ,GAA3E,UAAU,CAAC,cAAc,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAU;AACrF,YAAuH,aAAa,GAA1H;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAC,CAAe;AADxI,4FAA4F;AAC5F,2IAA2I;AAE3I;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAJxB,QAAQ,EAIgB,EAAE,KAAK,EAH/B,MAG+B,GAF9B,aAAa,GAAG,KAAK,CAuChC"}