@tbela99/css-parser 0.0.1-alpha3 → 0.0.1-alpha5

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/dist/index.d.ts CHANGED
@@ -191,6 +191,7 @@ interface ParserOptions {
191
191
  src?: string;
192
192
  sourcemap?: boolean;
193
193
  compress?: boolean;
194
+ nestingRules?: boolean;
194
195
  removeEmpty?: boolean;
195
196
  resolveUrls?: boolean;
196
197
  resolveImport?: boolean;
@@ -271,9 +272,20 @@ interface AstDeclaration extends Node {
271
272
 
272
273
  interface AstRule extends Node {
273
274
 
274
- typ: 'Rule',
275
- sel: string,
276
- chi: Array<AstDeclaration | AstComment | AstRuleList>
275
+ typ: 'Rule';
276
+ sel: string;
277
+ chi: Array<AstDeclaration | AstComment | AstRuleList>;
278
+ optimized?: OptimizedSelector;
279
+ raw?: RawSelectorTokens;
280
+ }
281
+
282
+ declare type RawSelectorTokens = string[][];
283
+
284
+ interface OptimizedSelector {
285
+ match: boolean;
286
+ optimized: string[];
287
+ selector: string[][],
288
+ reducible: boolean;
277
289
  }
278
290
 
279
291
  interface AstAtRule extends Node {
@@ -302,8 +314,14 @@ type AstNode =
302
314
  | AstDeclaration;
303
315
 
304
316
  declare function deduplicate(ast: AstNode, options?: ParserOptions, recursive?: boolean): AstNode;
305
- declare function hasDeclaration(node: AstAtRule | AstRule | AstRuleList): boolean;
306
- declare function deduplicateRule(ast: AstNode, options?: ParserOptions): AstNode;
317
+ declare function hasDeclaration(node: AstRule): boolean;
318
+ declare function deduplicateRule(ast: AstRule | AstAtRule): AstRule | AstAtRule;
319
+ declare function reduceSelector(selector: string[][]): {
320
+ match: boolean;
321
+ optimized: string[];
322
+ selector: string[][];
323
+ reducible: boolean;
324
+ } | null;
307
325
 
308
326
  declare function render(data: AstNode, opt?: RenderOptions): RenderResult;
309
327
  declare function renderToken(token: Token, options?: RenderOptions): string;
@@ -326,4 +344,4 @@ declare function resolve(url: string, currentDirectory: string, cwd?: string): {
326
344
  declare function parse(iterator: string, opt?: ParserOptions): Promise<ParseResult>;
327
345
  declare function transform(css: string, options?: TransformOptions): Promise<TransformResult>;
328
346
 
329
- export { deduplicate, deduplicateRule, dirname, hasDeclaration, load, matchUrl, parse, render, renderToken, resolve, transform, walk };
347
+ export { deduplicate, deduplicateRule, dirname, hasDeclaration, load, matchUrl, parse, reduceSelector, render, renderToken, resolve, transform, walk };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { parse, transform } from './node/index.js';
2
- export { deduplicate, deduplicateRule, hasDeclaration } from './lib/parser/deduplicate.js';
2
+ export { deduplicate, deduplicateRule, hasDeclaration, reduceSelector } from './lib/parser/deduplicate.js';
3
3
  export { render, renderToken } from './lib/renderer/render.js';
4
4
  export { walk } from './lib/walker/walk.js';
5
5
  export { load } from './node/load.js';