Skip to content

Commit 86431a0

Browse files
committed
feat: add TypeScript definitions and update package.json
1 parent 5efe243 commit 86431a0

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

index.d.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { Plugin } from 'postcss';
2+
3+
declare namespace PostcssUnitProcessor {
4+
interface Options {
5+
/**
6+
* A function to process the value and unit.
7+
* @param value The numeric value to process.
8+
* @param unit The unit of the value (e.g., 'px', 'rem').
9+
* @param node The PostCSS node being processed.
10+
* @param root The root PostCSS node.
11+
* @returns The processed value as a number, string, or an object with value and unit.
12+
*/
13+
processor?: (value: number, unit: string, node: any, root: any) => number | string | { value: number | string; unit?: string };
14+
15+
/**
16+
* The precision for rounding unit values.
17+
* @default 5
18+
*/
19+
unitPrecision?: number;
20+
21+
/**
22+
* List of selectors to exclude from processing.
23+
* @default []
24+
*/
25+
selectorBlackList?: Array<string | RegExp>;
26+
27+
/**
28+
* List of properties to process. Supports wildcards and negation.
29+
* @default ['*']
30+
*/
31+
propList?: string[];
32+
33+
/**
34+
* Whether to replace the original declaration or add a new one.
35+
* @default true
36+
*/
37+
replace?: boolean;
38+
39+
/**
40+
* Whether to process units in media queries.
41+
* @default false
42+
*/
43+
mediaQuery?: boolean;
44+
45+
/**
46+
* Pattern or function to exclude files from processing.
47+
* @default /node_modules/i
48+
*/
49+
exclude?: RegExp | string | ((filePath: string) => boolean);
50+
51+
/**
52+
* Custom units to support in addition to default units.
53+
* @default []
54+
*/
55+
customUnitList?: string[];
56+
}
57+
}
58+
59+
/**
60+
* A PostCSS plugin to process units in CSS declarations and media queries.
61+
* @param options Configuration options for the plugin.
62+
* @returns A PostCSS plugin instance.
63+
*/
64+
declare function PostcssUnitProcessor(options?: PostcssUnitProcessor.Options): Plugin;
65+
66+
export = PostcssUnitProcessor;

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
"version": "1.1.1",
44
"description": "PostCSS plugin to process css unit.",
55
"main": "index.js",
6+
"types": "index.d.ts",
7+
"files": [
8+
"index.js",
9+
"index.d.ts",
10+
"LICENSE",
11+
"README.md"
12+
],
613
"scripts": {
714
"test": "jest",
815
"test:coverage": "jest --coverage"

0 commit comments

Comments
 (0)