@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/.gitattributes +2 -0
- package/README.md +2 -6
- package/dist/index-umd-web.js +649 -161
- package/dist/index.cjs +647 -159
- package/dist/index.d.ts +24 -6
- package/dist/index.js +1 -1
- package/dist/lib/parser/deduplicate.js +530 -35
- package/dist/lib/parser/parse.js +100 -98
- package/dist/lib/parser/utils/syntax.js +7 -2
- package/dist/lib/renderer/render.js +11 -23
- package/dist/lib/walker/walk.js +1 -1
- package/dist/node/index.js +2 -4
- package/dist/web/index.js +5 -7
- package/package.json +5 -4
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:
|
|
306
|
-
declare function deduplicateRule(ast:
|
|
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';
|