| import type { Root } from 'postcss'; | ||
| export type SelectorPattern = string | RegExp; | ||
| export interface CssDedupOptions { | ||
| from?: string; | ||
| ignoreSelectors?: SelectorPattern[]; | ||
| ignoreSelectorsDefaults?: boolean; | ||
| aggressive?: boolean; | ||
| savingsOnly?: boolean; | ||
| } | ||
| export interface Occurrence { | ||
| selector: string; | ||
| selectors: string[]; | ||
| prop?: string; | ||
| value?: string; | ||
| line?: number; | ||
| } | ||
| export interface Finding { | ||
| scope: string; | ||
| key: string; | ||
| redundant?: true; | ||
| repeated?: true; | ||
| occurrences: Occurrence[]; | ||
| } | ||
| export interface AnalyzeResult { | ||
| findings: Finding[]; | ||
| } | ||
| export interface AppliedChange { | ||
| scope: string; | ||
| key: string; | ||
| selectors?: string[]; | ||
| value?: string; | ||
| redundant?: true; | ||
| folded?: true; | ||
| } | ||
| export interface SkippedChange { | ||
| scope: string; | ||
| key: string; | ||
| reason: string; | ||
| } | ||
| export interface ByteCounts { | ||
| before: number; | ||
| after: number; | ||
| saved: number; | ||
| } | ||
| export interface WithheldResult { | ||
| count: number; | ||
| bytes: ByteCounts; | ||
| } | ||
| export interface DedupRootResult { | ||
| applied: AppliedChange[]; | ||
| skipped: SkippedChange[]; | ||
| bytes: ByteCounts; | ||
| withheld?: WithheldResult; | ||
| } | ||
| export interface DedupResult extends DedupRootResult { | ||
| css: string; | ||
| } | ||
| export declare function analyzeRoot(root: Root, options?: CssDedupOptions): AnalyzeResult; | ||
| export declare function analyze(css: string, options?: CssDedupOptions): AnalyzeResult; | ||
| export declare function dedupRoot(root: Root, options?: CssDedupOptions): DedupRootResult; | ||
| export declare function dedup(css: string, options?: CssDedupOptions): DedupResult; |
| import type { PluginCreator } from 'postcss'; | ||
| import type { CssDedupOptions } from './index.js'; | ||
| export interface CssDedupPluginOptions extends CssDedupOptions { | ||
| fix?: boolean; | ||
| } | ||
| declare const cssdedup: PluginCreator<CssDedupPluginOptions>; | ||
| export default cssdedup; |
+16
-6
@@ -13,3 +13,4 @@ { | ||
| "eslint": "^10.6.0", | ||
| "globals": "^17.6.0" | ||
| "globals": "^17.6.0", | ||
| "typescript": "^6.0.3" | ||
| }, | ||
@@ -20,4 +21,10 @@ "engines": { | ||
| "exports": { | ||
| ".": "./src/index.js", | ||
| "./plugin": "./src/plugin.js" | ||
| ".": { | ||
| "types": "./src/index.d.ts", | ||
| "default": "./src/index.js" | ||
| }, | ||
| "./plugin": { | ||
| "types": "./src/plugin.d.ts", | ||
| "default": "./src/plugin.js" | ||
| } | ||
| }, | ||
@@ -27,3 +34,4 @@ "files": [ | ||
| "src/", | ||
| "!src/plugin.test.js" | ||
| "!src/plugin.test.js", | ||
| "!src/index.test.ts" | ||
| ], | ||
@@ -53,6 +61,8 @@ "funding": "https://github.com/j9t/css-dedup?sponsor=1", | ||
| "start": "node ./bin/css-dedup.js", | ||
| "test": "node --test bin/css-dedup.test.js src/plugin.test.js" | ||
| "test": "npm run test:types && node --test bin/css-dedup.test.js src/plugin.test.js", | ||
| "test:types": "tsc" | ||
| }, | ||
| "type": "module", | ||
| "version": "1.1.0" | ||
| "types": "src/index.d.ts", | ||
| "version": "1.2.0" | ||
| } |
143117
1.47%12
20%2311
2.94%4
33.33%