@tbela99/css-parser 1.6.9 → 1.8.1
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/CHANGELOG.md +42 -1
- package/README.md +1 -0
- package/dist/index-umd-web.js +1139 -529
- package/dist/index.cjs +1138 -528
- package/dist/index.d.ts +259 -8
- package/dist/package.json.js +2 -2
- package/dist/src/data/properties.json.js +1 -1
- package/dist/src/data/validation.json.js +11 -2
- package/dist/src/lib/ast/clone.js +1 -1
- package/dist/src/lib/ast/expand.js +1 -1
- package/dist/src/lib/ast/features/calc.js +1 -1
- package/dist/src/lib/ast/features/if.js +1 -1
- package/dist/src/lib/ast/features/index.js +1 -1
- package/dist/src/lib/ast/features/inlinecssvariables.js +6 -5
- package/dist/src/lib/ast/features/prefix.js +1 -1
- package/dist/src/lib/ast/features/shorthand.js +39 -22
- package/dist/src/lib/ast/features/transform.js +1 -1
- package/dist/src/lib/ast/features/type.js +1 -1
- package/dist/src/lib/ast/find.js +26 -21
- package/dist/src/lib/ast/math/expression.js +4 -1
- package/dist/src/lib/ast/math/math.js +1 -1
- package/dist/src/lib/ast/minify.js +31 -3
- package/dist/src/lib/ast/node.js +1 -1
- package/dist/src/lib/ast/transform/compute.js +1 -1
- package/dist/src/lib/ast/transform/matrix.js +1 -1
- package/dist/src/lib/ast/transform/minify.js +1 -1
- package/dist/src/lib/ast/transform/perspective.js +1 -1
- package/dist/src/lib/ast/transform/rotate.js +1 -1
- package/dist/src/lib/ast/transform/scale.js +1 -1
- package/dist/src/lib/ast/transform/skew.js +1 -1
- package/dist/src/lib/ast/transform/translate.js +1 -1
- package/dist/src/lib/ast/transform/utils.js +1 -1
- package/dist/src/lib/ast/types.js +5 -1
- package/dist/src/lib/ast/walk.js +319 -94
- package/dist/src/lib/fs/resolve.js +1 -1
- package/dist/src/lib/parser/declaration/list.js +35 -1
- package/dist/src/lib/parser/declaration/map.js +2 -2
- package/dist/src/lib/parser/declaration/set.js +1 -1
- package/dist/src/lib/parser/linesmap.js +1 -1
- package/dist/src/lib/parser/parse.js +504 -177
- package/dist/src/lib/parser/source.js +1 -1
- package/dist/src/lib/parser/tokenize.js +23 -3
- package/dist/src/lib/parser/utils/angle.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-container.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-font-feature-values.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-generic.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-import.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-media.js +2 -2
- package/dist/src/lib/parser/utils/at-rule-support.js +2 -2
- package/dist/src/lib/parser/utils/at-rule-when-else.js +1 -1
- package/dist/src/lib/parser/utils/at-rule.js +1 -1
- package/dist/src/lib/parser/utils/base64.js +1 -1
- package/dist/src/lib/parser/utils/cache.js +1 -1
- package/dist/src/lib/parser/utils/config.js +1 -1
- package/dist/src/lib/parser/utils/declaration.js +1 -1
- package/dist/src/lib/parser/utils/eq.js +1 -1
- package/dist/src/lib/parser/utils/hash.js +1 -1
- package/dist/src/lib/parser/utils/selector.js +1 -1
- package/dist/src/lib/parser/utils/text.js +1 -1
- package/dist/src/lib/parser/utils/token.js +12 -4
- package/dist/src/lib/parser/utils/type.js +1 -1
- package/dist/src/lib/printer/render.js +6 -3
- package/dist/src/lib/printer/sourcemap/lib/codec.js +1 -1
- package/dist/src/lib/printer/sourcemap/sourcemap.js +1 -1
- package/dist/src/lib/syntax/color/a98rgb.js +1 -1
- package/dist/src/lib/syntax/color/alpha.js +1 -1
- package/dist/src/lib/syntax/color/cmyk.js +1 -1
- package/dist/src/lib/syntax/color/color-mix.js +1 -1
- package/dist/src/lib/syntax/color/color.js +1 -1
- package/dist/src/lib/syntax/color/hex.js +1 -1
- package/dist/src/lib/syntax/color/hsl.js +1 -1
- package/dist/src/lib/syntax/color/hwb.js +1 -1
- package/dist/src/lib/syntax/color/lab.js +1 -1
- package/dist/src/lib/syntax/color/lch.js +1 -1
- package/dist/src/lib/syntax/color/oklab.js +1 -1
- package/dist/src/lib/syntax/color/oklch.js +1 -1
- package/dist/src/lib/syntax/color/p3.js +1 -1
- package/dist/src/lib/syntax/color/prophotorgb.js +1 -1
- package/dist/src/lib/syntax/color/rec2020.js +1 -1
- package/dist/src/lib/syntax/color/relative-color.js +1 -1
- package/dist/src/lib/syntax/color/rgb.js +1 -1
- package/dist/src/lib/syntax/color/srgb.js +1 -1
- package/dist/src/lib/syntax/color/utils/color-type.js +1 -1
- package/dist/src/lib/syntax/color/utils/colorspace.js +1 -1
- package/dist/src/lib/syntax/color/utils/components.js +1 -1
- package/dist/src/lib/syntax/color/utils/distance.js +1 -1
- package/dist/src/lib/syntax/color/utils/make-color.js +1 -1
- package/dist/src/lib/syntax/color/utils/matrix.js +1 -1
- package/dist/src/lib/syntax/color/xyz.js +1 -1
- package/dist/src/lib/syntax/color/xyzd50.js +1 -1
- package/dist/src/lib/syntax/constants.js +1 -1
- package/dist/src/lib/syntax/syntax.js +1 -1
- package/dist/src/lib/validation/config.js +20 -3
- package/dist/src/lib/validation/match.js +105 -200
- package/dist/src/lib/validation/parser/parse.js +8 -3
- package/dist/src/lib/validation/parser/typedef.js +1 -1
- package/dist/src/lib/validation/utils/list.js +1 -1
- package/dist/src/node.js +2 -1
- package/dist/src/types.js +1 -1
- package/dist/src/utils/sync.js +1 -1
- package/dist/src/web.js +2 -1
- package/package.json +8 -7
- package/CONTRIBUTING.md +0 -119
package/dist/index.d.ts
CHANGED
|
@@ -677,6 +677,10 @@ declare enum EnumToken {
|
|
|
677
677
|
* CSS type token
|
|
678
678
|
*/
|
|
679
679
|
CssTypeTokenType = 144,
|
|
680
|
+
/**
|
|
681
|
+
* user defined dimension token type
|
|
682
|
+
*/
|
|
683
|
+
UserDefinedDimensionTokenType = 145,
|
|
680
684
|
/**
|
|
681
685
|
* alias for time token type
|
|
682
686
|
*/
|
|
@@ -2468,6 +2472,7 @@ export declare interface ComposesSelectorToken extends BaseToken {
|
|
|
2468
2472
|
* @inheritdoc
|
|
2469
2473
|
*/
|
|
2470
2474
|
typ: EnumToken.ComposesSelectorTokenType;
|
|
2475
|
+
|
|
2471
2476
|
/**
|
|
2472
2477
|
* Left handle
|
|
2473
2478
|
*/
|
|
@@ -3392,7 +3397,7 @@ declare function walk(node: AstNode$1, filter?: WalkerOptions | null): Generator
|
|
|
3392
3397
|
* // [ "Iden", "from" ]
|
|
3393
3398
|
* ```
|
|
3394
3399
|
*/
|
|
3395
|
-
declare function walkValues(
|
|
3400
|
+
declare function walkValues(tokens: Token$1[], root?: AstNode$1 | Token$1 | null, filter?: WalkerValueFilter | null | {
|
|
3396
3401
|
event?: WalkerEvent;
|
|
3397
3402
|
fn?: WalkerValueFilter;
|
|
3398
3403
|
type?: EnumToken | EnumToken[] | ((token: Token$1) => boolean);
|
|
@@ -3939,8 +3944,14 @@ export declare interface VisitorNodeMap {
|
|
|
3939
3944
|
*/
|
|
3940
3945
|
Rule?: GenericVisitorAstNodeHandlerMap<AstRule>;
|
|
3941
3946
|
|
|
3947
|
+
/**
|
|
3948
|
+
* keyframes rule visitor
|
|
3949
|
+
*/
|
|
3942
3950
|
KeyframesRule?: GenericVisitorAstNodeHandlerMap<AstKeyframesRule>;
|
|
3943
3951
|
|
|
3952
|
+
/**
|
|
3953
|
+
* keyframes at-rule visitor
|
|
3954
|
+
*/
|
|
3944
3955
|
KeyframesAtRule?: GenericVisitorAstNodeHandlerMap<AstKeyframesAtRule>;
|
|
3945
3956
|
|
|
3946
3957
|
/**
|
|
@@ -4266,8 +4277,17 @@ declare class SourceFile {
|
|
|
4266
4277
|
getInputSourceMap(): SourceMap | null;
|
|
4267
4278
|
}
|
|
4268
4279
|
|
|
4280
|
+
/**
|
|
4281
|
+
* property list options
|
|
4282
|
+
*/
|
|
4269
4283
|
export declare interface PropertyListOptions {
|
|
4284
|
+
/**
|
|
4285
|
+
* remove duplicate declarations
|
|
4286
|
+
*/
|
|
4270
4287
|
removeDuplicateDeclarations?: boolean | string | string[];
|
|
4288
|
+
/**
|
|
4289
|
+
* compute shorthand
|
|
4290
|
+
*/
|
|
4271
4291
|
computeShorthand?: boolean;
|
|
4272
4292
|
}
|
|
4273
4293
|
|
|
@@ -4544,104 +4564,328 @@ declare enum ResponseType {
|
|
|
4544
4564
|
JSON = 3
|
|
4545
4565
|
}
|
|
4546
4566
|
|
|
4567
|
+
/**
|
|
4568
|
+
* shorthand property type
|
|
4569
|
+
*/
|
|
4547
4570
|
interface PropertyType {
|
|
4571
|
+
/**
|
|
4572
|
+
* shorthand name
|
|
4573
|
+
*/
|
|
4548
4574
|
shorthand: string;
|
|
4549
4575
|
}
|
|
4550
4576
|
|
|
4577
|
+
/**
|
|
4578
|
+
* single property
|
|
4579
|
+
*/
|
|
4551
4580
|
interface SinglePropertyType {
|
|
4581
|
+
/**
|
|
4582
|
+
* keyof shorthand property type
|
|
4583
|
+
*/
|
|
4552
4584
|
typ: keyof EnumToken;
|
|
4585
|
+
/**
|
|
4586
|
+
* value
|
|
4587
|
+
*/
|
|
4553
4588
|
val: string | number;
|
|
4554
4589
|
}
|
|
4555
4590
|
|
|
4591
|
+
/**
|
|
4592
|
+
* shorthand property map
|
|
4593
|
+
*/
|
|
4556
4594
|
interface SinglePropertyTypeMapping {
|
|
4595
|
+
/**
|
|
4596
|
+
* shorthand pattern
|
|
4597
|
+
*/
|
|
4557
4598
|
pattern?: string[][];
|
|
4599
|
+
/**
|
|
4600
|
+
* shorthand mappings
|
|
4601
|
+
*/
|
|
4558
4602
|
mapping: Record<string, SinglePropertyType>;
|
|
4559
4603
|
}
|
|
4560
|
-
|
|
4604
|
+
/**
|
|
4605
|
+
* shorthand configuration
|
|
4606
|
+
*/
|
|
4561
4607
|
interface ShorthandPropertyType {
|
|
4608
|
+
/**
|
|
4609
|
+
* shorthand name
|
|
4610
|
+
*/
|
|
4562
4611
|
shorthand: string;
|
|
4612
|
+
/**
|
|
4613
|
+
* mapped shorthand property
|
|
4614
|
+
*/
|
|
4563
4615
|
map?: string;
|
|
4616
|
+
/**
|
|
4617
|
+
* property names
|
|
4618
|
+
*/
|
|
4564
4619
|
properties: string[];
|
|
4620
|
+
/**
|
|
4621
|
+
* property types
|
|
4622
|
+
*/
|
|
4565
4623
|
types: string[];
|
|
4624
|
+
/**
|
|
4625
|
+
* allow multiple values
|
|
4626
|
+
*/
|
|
4566
4627
|
multiple: boolean;
|
|
4628
|
+
/**
|
|
4629
|
+
* values separator
|
|
4630
|
+
*/
|
|
4567
4631
|
separator: {
|
|
4632
|
+
/**
|
|
4633
|
+
* token type
|
|
4634
|
+
*/
|
|
4568
4635
|
typ: keyof EnumToken;
|
|
4636
|
+
/**
|
|
4637
|
+
* token value
|
|
4638
|
+
*/
|
|
4569
4639
|
val: string;
|
|
4570
4640
|
};
|
|
4641
|
+
/**
|
|
4642
|
+
* value separator
|
|
4643
|
+
*/
|
|
4571
4644
|
valueSeparator?: {
|
|
4645
|
+
/**
|
|
4646
|
+
* token type
|
|
4647
|
+
*/
|
|
4572
4648
|
typ: keyof EnumToken;
|
|
4649
|
+
/**
|
|
4650
|
+
* token value
|
|
4651
|
+
*/
|
|
4573
4652
|
val: string;
|
|
4574
4653
|
};
|
|
4654
|
+
/**
|
|
4655
|
+
* keywords
|
|
4656
|
+
*/
|
|
4575
4657
|
keywords: string[];
|
|
4576
4658
|
}
|
|
4577
4659
|
|
|
4660
|
+
/**
|
|
4661
|
+
* shorthand property set. a set of identical properties such as `margin`
|
|
4662
|
+
*/
|
|
4578
4663
|
interface PropertySetType {
|
|
4664
|
+
/**
|
|
4665
|
+
* shorthand property definition
|
|
4666
|
+
*/
|
|
4579
4667
|
[key: string]: PropertyType | ShorthandPropertyType;
|
|
4580
4668
|
}
|
|
4581
4669
|
|
|
4670
|
+
/**
|
|
4671
|
+
* mapped shorthand property. a set of different properties such as `font`
|
|
4672
|
+
*/
|
|
4582
4673
|
interface PropertyMapType {
|
|
4674
|
+
/**
|
|
4675
|
+
* default values
|
|
4676
|
+
*/
|
|
4583
4677
|
default: string[];
|
|
4678
|
+
/**
|
|
4679
|
+
* property types
|
|
4680
|
+
*/
|
|
4584
4681
|
types: string[];
|
|
4682
|
+
/**
|
|
4683
|
+
* keywords
|
|
4684
|
+
*/
|
|
4585
4685
|
keywords: string[];
|
|
4686
|
+
/**
|
|
4687
|
+
* required
|
|
4688
|
+
*/
|
|
4586
4689
|
required?: boolean;
|
|
4690
|
+
/**
|
|
4691
|
+
* allow multiple values
|
|
4692
|
+
*/
|
|
4587
4693
|
multiple?: boolean;
|
|
4694
|
+
/**
|
|
4695
|
+
* property has a prefix
|
|
4696
|
+
*/
|
|
4588
4697
|
prefix?: {
|
|
4698
|
+
/**
|
|
4699
|
+
* token type
|
|
4700
|
+
*/
|
|
4589
4701
|
typ: keyof EnumToken;
|
|
4702
|
+
/**
|
|
4703
|
+
* token value
|
|
4704
|
+
*/
|
|
4590
4705
|
val: string;
|
|
4591
4706
|
};
|
|
4707
|
+
/**
|
|
4708
|
+
* previous property
|
|
4709
|
+
*/
|
|
4592
4710
|
previous?: string;
|
|
4711
|
+
/**
|
|
4712
|
+
* separator
|
|
4713
|
+
*/
|
|
4593
4714
|
separator?: {
|
|
4715
|
+
/**
|
|
4716
|
+
* token type
|
|
4717
|
+
*/
|
|
4594
4718
|
typ: keyof EnumToken;
|
|
4595
4719
|
};
|
|
4720
|
+
/**
|
|
4721
|
+
* property constraints
|
|
4722
|
+
*/
|
|
4596
4723
|
constraints?: {
|
|
4724
|
+
/**
|
|
4725
|
+
* property constraints
|
|
4726
|
+
*/
|
|
4597
4727
|
[key: string]: {
|
|
4728
|
+
/**
|
|
4729
|
+
* property constraints
|
|
4730
|
+
*/
|
|
4598
4731
|
[key: string]: any;
|
|
4599
4732
|
};
|
|
4600
4733
|
};
|
|
4734
|
+
/**
|
|
4735
|
+
* values mapping
|
|
4736
|
+
*/
|
|
4601
4737
|
mapping?: Record<string, string>;
|
|
4602
4738
|
}
|
|
4603
4739
|
|
|
4740
|
+
/**
|
|
4741
|
+
* mapped shorthand definition
|
|
4742
|
+
*/
|
|
4604
4743
|
interface ShorthandMapType {
|
|
4744
|
+
/**
|
|
4745
|
+
* shorthand name
|
|
4746
|
+
*/
|
|
4605
4747
|
shorthand: string;
|
|
4748
|
+
/**
|
|
4749
|
+
* shorthand pattern
|
|
4750
|
+
*/
|
|
4606
4751
|
pattern: string;
|
|
4752
|
+
/**
|
|
4753
|
+
* shorthand keywords
|
|
4754
|
+
*/
|
|
4607
4755
|
keywords: string[];
|
|
4756
|
+
/**
|
|
4757
|
+
* default values
|
|
4758
|
+
*/
|
|
4608
4759
|
default: string[];
|
|
4760
|
+
/**
|
|
4761
|
+
* values mapping
|
|
4762
|
+
*/
|
|
4609
4763
|
mapping?: Record<string, string>;
|
|
4764
|
+
/**
|
|
4765
|
+
* allow multiple values
|
|
4766
|
+
*/
|
|
4610
4767
|
multiple?: boolean;
|
|
4611
|
-
|
|
4768
|
+
/**
|
|
4769
|
+
* shorthand values separator
|
|
4770
|
+
*/
|
|
4771
|
+
separator?: {
|
|
4772
|
+
/**
|
|
4773
|
+
* token type
|
|
4774
|
+
*/
|
|
4775
|
+
typ: keyof EnumToken;
|
|
4776
|
+
/**
|
|
4777
|
+
* token value
|
|
4778
|
+
*/
|
|
4779
|
+
val?: string;
|
|
4780
|
+
};
|
|
4781
|
+
/**
|
|
4782
|
+
* shorthand property sets
|
|
4783
|
+
*/
|
|
4612
4784
|
set?: Record<string, string[]>;
|
|
4785
|
+
/**
|
|
4786
|
+
* shorthand properties
|
|
4787
|
+
*/
|
|
4613
4788
|
properties: {
|
|
4789
|
+
/**
|
|
4790
|
+
* shorthand properties
|
|
4791
|
+
*/
|
|
4614
4792
|
[property: string]: PropertyMapType;
|
|
4615
4793
|
};
|
|
4616
4794
|
}
|
|
4617
4795
|
|
|
4796
|
+
/**
|
|
4797
|
+
* shorthand properties
|
|
4798
|
+
*/
|
|
4618
4799
|
interface ShorthandProperties {
|
|
4800
|
+
/**
|
|
4801
|
+
* property types
|
|
4802
|
+
*/
|
|
4619
4803
|
types: EnumToken[];
|
|
4804
|
+
/**
|
|
4805
|
+
* default values
|
|
4806
|
+
*/
|
|
4620
4807
|
default: string[];
|
|
4808
|
+
/**
|
|
4809
|
+
* keywords
|
|
4810
|
+
*/
|
|
4621
4811
|
keywords: string[];
|
|
4812
|
+
/**
|
|
4813
|
+
* required
|
|
4814
|
+
*/
|
|
4622
4815
|
required?: boolean;
|
|
4816
|
+
/**
|
|
4817
|
+
* allow multiple values
|
|
4818
|
+
*/
|
|
4623
4819
|
multiple?: boolean;
|
|
4820
|
+
/**
|
|
4821
|
+
* propery constraints
|
|
4822
|
+
*/
|
|
4624
4823
|
constraints?: Array<any>;
|
|
4824
|
+
/**
|
|
4825
|
+
* values mapping
|
|
4826
|
+
*/
|
|
4625
4827
|
mapping?: {
|
|
4828
|
+
/**
|
|
4829
|
+
* values mapping
|
|
4830
|
+
*/
|
|
4626
4831
|
[key: string]: any;
|
|
4627
4832
|
};
|
|
4833
|
+
/**
|
|
4834
|
+
* property validation
|
|
4835
|
+
*/
|
|
4628
4836
|
validation?: {
|
|
4837
|
+
/**
|
|
4838
|
+
* property validation
|
|
4839
|
+
*/
|
|
4629
4840
|
[key: string]: any;
|
|
4630
4841
|
};
|
|
4842
|
+
/**
|
|
4843
|
+
* property has a prefix
|
|
4844
|
+
*/
|
|
4631
4845
|
prefix?: string;
|
|
4632
4846
|
}
|
|
4633
4847
|
|
|
4848
|
+
/**
|
|
4849
|
+
* shorthand definition
|
|
4850
|
+
*/
|
|
4634
4851
|
interface ShorthandDef {
|
|
4852
|
+
/**
|
|
4853
|
+
* shorthand name
|
|
4854
|
+
*/
|
|
4635
4855
|
shorthand: string;
|
|
4856
|
+
/**
|
|
4857
|
+
* shorthand pattern
|
|
4858
|
+
*/
|
|
4636
4859
|
pattern: string;
|
|
4860
|
+
/**
|
|
4861
|
+
* shorthand keywords
|
|
4862
|
+
*/
|
|
4637
4863
|
keywords: string;
|
|
4864
|
+
/**
|
|
4865
|
+
* default values
|
|
4866
|
+
*/
|
|
4638
4867
|
defaults: string[];
|
|
4868
|
+
/**
|
|
4869
|
+
* allow multiple values
|
|
4870
|
+
*/
|
|
4639
4871
|
multiple?: boolean;
|
|
4872
|
+
/**
|
|
4873
|
+
* values separator
|
|
4874
|
+
*/
|
|
4640
4875
|
separator?: string;
|
|
4641
4876
|
}
|
|
4642
4877
|
|
|
4878
|
+
/**
|
|
4879
|
+
* shorthand type
|
|
4880
|
+
*/
|
|
4643
4881
|
interface ShorthandType {
|
|
4882
|
+
/**
|
|
4883
|
+
* shorthand name
|
|
4884
|
+
*/
|
|
4644
4885
|
shorthand: string;
|
|
4886
|
+
/**
|
|
4887
|
+
* shorthand properties
|
|
4888
|
+
*/
|
|
4645
4889
|
properties: ShorthandProperties;
|
|
4646
4890
|
}
|
|
4647
4891
|
|
|
@@ -5118,7 +5362,7 @@ export declare interface WalkResult {
|
|
|
5118
5362
|
/**
|
|
5119
5363
|
* current node
|
|
5120
5364
|
*/
|
|
5121
|
-
node: AstNode$1;
|
|
5365
|
+
node: AstNode$1 | Token$1;
|
|
5122
5366
|
/**
|
|
5123
5367
|
* parent node
|
|
5124
5368
|
*/
|
|
@@ -5130,7 +5374,7 @@ export declare interface WalkResult {
|
|
|
5130
5374
|
/**
|
|
5131
5375
|
* parent nodes
|
|
5132
5376
|
*/
|
|
5133
|
-
parents: Generator<AstNode$1>;
|
|
5377
|
+
parents: Generator<AstNode$1 | Token$1>;
|
|
5134
5378
|
}
|
|
5135
5379
|
|
|
5136
5380
|
/**
|
|
@@ -6560,7 +6804,7 @@ button-small {
|
|
|
6560
6804
|
* @param matcher
|
|
6561
6805
|
* @returns
|
|
6562
6806
|
*/
|
|
6563
|
-
declare function findAll(ast: AstNode$1, matcher: (node: AstNode$1, parent?: AstNode$1 | null) => boolean): AstNode$1
|
|
6807
|
+
declare function findAll(ast: AstNode$1, matcher: (node: AstNode$1 | Token$1, parent?: AstNode$1 | Token$1 | null) => boolean): Array<AstNode$1 | Token$1>;
|
|
6564
6808
|
/**
|
|
6565
6809
|
* Search the ast sub-tree and return the last match.
|
|
6566
6810
|
*
|
|
@@ -6591,7 +6835,7 @@ button {
|
|
|
6591
6835
|
* @param matcher
|
|
6592
6836
|
* @returns
|
|
6593
6837
|
*/
|
|
6594
|
-
declare function findLast(ast: AstNode$1, matcher: (node: AstNode$1, parent?: AstNode$1 | null) => boolean): AstNode$1 | null;
|
|
6838
|
+
declare function findLast(ast: AstNode$1 | Token$1, matcher: (node: AstNode$1 | Token$1, parent?: AstNode$1 | Token$1 | null) => boolean): AstNode$1 | Token$1 | null;
|
|
6595
6839
|
|
|
6596
6840
|
/**
|
|
6597
6841
|
*
|
|
@@ -6687,6 +6931,13 @@ declare function setNodeProperty(node: AstNode$1, key: 'errors', value: ErrorDes
|
|
|
6687
6931
|
*/
|
|
6688
6932
|
declare function setNodeProperty(node: AstNode$1, key: 'tokens', value: Token$1[] | null): void;
|
|
6689
6933
|
|
|
6934
|
+
/**
|
|
6935
|
+
* parse mdn data syntax
|
|
6936
|
+
* @param syntax
|
|
6937
|
+
* @returns
|
|
6938
|
+
*/
|
|
6939
|
+
declare function parseSyntax(syntax: string): ValidationToken$1[];
|
|
6940
|
+
|
|
6690
6941
|
declare let version: string;
|
|
6691
6942
|
|
|
6692
6943
|
/**
|
|
@@ -7076,5 +7327,5 @@ declare function transform(options: ParseInputStreamOptions & TransformOptions):
|
|
|
7076
7327
|
*/
|
|
7077
7328
|
declare function transform(options: ParseInputFileOptions & TransformOptions): Promise<TransformResult>;
|
|
7078
7329
|
|
|
7079
|
-
export { ColorType$1 as ColorType, EnumAstNodeStatus$1 as EnumAstNodeStatus, EnumToken, FeatureWalkMode, ModuleCaseTransformEnum, ModuleScopeEnumOptions, ResponseType, SourceMap, ValidationLevel, WalkerEvent, WalkerOptionEnum, cloneNode, convertColor, dirname, expand, find, findAll, findByValue, findLast, getNodeProperty, isOkLabClose, load, minify, okLabDistance, parse, parseDeclarations, parseFile, parseString, parseSync, render, renderValue as renderToken, replaceNodeOrValue, resolve, setNodeProperty, transform, transformFile, transformSync, version, walk, walkValues };
|
|
7330
|
+
export { ColorType$1 as ColorType, EnumAstNodeStatus$1 as EnumAstNodeStatus, EnumToken, FeatureWalkMode, ModuleCaseTransformEnum, ModuleScopeEnumOptions, ResponseType, SourceMap, ValidationLevel, WalkerEvent, WalkerOptionEnum, cloneNode, convertColor, dirname, expand, find, findAll, findByValue, findLast, getNodeProperty, isOkLabClose, load, minify, okLabDistance, parse, parseDeclarations, parseFile, parseString, parseSync, parseSyntax, render, renderValue as renderToken, replaceNodeOrValue, resolve, setNodeProperty, transform, transformFile, transformSync, version, walk, walkValues };
|
|
7080
7331
|
export type { AddToken, AndToken, AngleToken, AstAtRule, AstComment, AstDeclaration, AstInvalidAtRule, AstInvalidDeclaration, AstInvalidRule, AstKeyframesAtRule, AstKeyframesRule, AstNode$1 as AstNode, AstNodeStatus, AstRule, AstRuleList, AstStyleSheet, AstValueMatcher, AtRuleToken, AtRuleVisitorHandler, AttrEndToken, AttrStartToken, AttrToken, Background, BackgroundAttachmentMapping, BackgroundPosition, BackgroundPositionClass, BackgroundPositionConstraints, BackgroundPositionMapping, BackgroundProperties, BackgroundRepeat, BackgroundRepeatMapping, BackgroundSize, BackgroundSizeMapping, BadCDOCommentToken, BadCommentToken, BadStringToken, BadUrlToken, BaseToken, BinaryExpressionNode, BinaryExpressionToken, BlockEndToken, BlockStartToken, Border, BorderColor, BorderColorClass, BorderProperties, BorderRadius, CDOCommentToken, ChildCombinatorToken, ClassSelectorToken, ColonToken, ColorToken, ColumnCombinatorToken, CommaToken, CommentToken, ComposesSelectorToken, ConstraintsMapping, ContainMatchToken, ContainerStyleRangeToken, CssTypeTokenType, CssVariableImportTokenType, CssVariableMapTokenType, CssVariableToken, DashMatchToken, DashedIdentToken, DeclarationVisitorHandler, DelimToken, DescendantCombinatorToken, DimensionToken, DivToken, DoubleColonToken, EOFToken, EndMatchToken, EqualMatchToken, ErrorDescription$1 as ErrorDescription, FlexToken, Font, FontFamily, FontProperties, FontWeight, FontWeightConstraints, FontWeightMapping, FractionToken, FrequencyToken, FunctionDefToken, FunctionImageToken, FunctionToken, FunctionURLToken, GenericVisitorAstNodeHandlerMap, GenericVisitorAstNodeSyncHandlerMap, GenericVisitorAsyncResult, GenericVisitorHandler, GenericVisitorResult, GenericVisitorSyncHandler, GenericVisitorSyncResult, GreaterThanOrEqualToken, GreaterThanToken, GridTemplateFuncToken, HashToken, IdentListToken, IdentToken, IfConditionToken, IfElseConditionToken, ImportantToken, IncludeMatchToken, InfinityToken, InvalidAttrToken, InvalidClassSelectorToken, InvalidMediaQueryToken, LengthToken, LessThanOrEqualToken, LessThanToken, LineHeight, ListToken, LiteralToken, LoadResult, Map$1 as Map, MatchExpressionToken, MatchedSelector, MediaFeatureOnlyToken, MediaFeatureToken, MediaQueryConditionToken, MediaQueryUnaryFeatureToken, MediaRangeQueryToken, MinifyFeature, MinifyFeatureOptions, MinifyOptions, ModuleAsyncOptions, ModuleSyncOptions, MulToken, NaNToken, NameSpaceAttributeToken, NegativeInfinityToken, NestingSelectorToken, NextSiblingCombinatorToken, NotToken, NumberToken, OptimizedSelector, OptimizedSelectorToken, OrToken, Outline, OutlineProperties, ParensEndToken, ParensStartToken, ParensToken, ParseInfo$1 as ParseInfo, ParseInputFileOptions, ParseInputOptions, ParseInputStreamOptions, ParseResult, ParseResultStats, ParseSourceOptions, ParseTokenOptions, ParsedVisitorHandlers, ParserOptions, ParserSourceMapOptions, ParserSyncOptions, PercentageToken, Prefix, PropertiesConfig, PropertiesConfigProperties, PropertyListOptions, PropertyMapType, PropertySetType, PropertyType, PseudoClassFunctionToken, PseudoClassToken, PseudoElementToken, PseudoPageToken, PurpleBackgroundAttachment, RawNodeToken, RawSelectorTokens, RenderOptions, RenderResult, ResolutionToken, ResolvedPath, RuleVisitorHandler, SemiColonToken, Separator, ShorthandDef, ShorthandMapType, ShorthandProperties, ShorthandPropertyType, ShorthandType, SinglePropertyType, SinglePropertyTypeMapping, SourceLocation, SourceMapObject, StartMatchToken, StringToken, SubToken, SubsequentCombinatorToken, SupportsQueryConditionToken, SupportsQueryUnaryConditionToken, TimeToken, TimelineFunctionToken, TimingFunctionToken, Token$1 as Token, TokenSearchResult, TokenizeResult, TransformOptions, TransformResult, TransformSyncOptions, UnaryExpression, UnaryExpressionNode, UnclosedStringToken, UniversalSelectorToken, UrlToken, ValidationConfiguration, ValidationMediaFeature, ValidationOptions, ValidationResult, ValidationSelectorOptions, ValidationSyntaxNode, ValidationSyntaxResult, ValidationToken$1 as ValidationToken, Value, ValueVisitorHandler, ValueVisitorSyncHandler, VariableScopeInfo, VisitorNodeMap, VisitorSyncNodeMap, WalkAttributesResult, WalkResult, WalkerFilter, WalkerOption, WalkerOptions, WalkerValueFilter, WhenElseQueryConditionToken, WhenElseUnaryConditionToken, WhitespaceToken, WrappedValuesToken };
|
package/dist/package.json.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 1.
|
|
5
|
+
Version: 1.8.1
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
var declarations = {
|
|
@@ -4712,7 +4712,16 @@ var atRules = {
|
|
|
4712
4712
|
syntax: " @bottom-right-corner { <declaration-list> }"
|
|
4713
4713
|
},
|
|
4714
4714
|
"@function": {
|
|
4715
|
-
syntax: " @function <dashed-
|
|
4715
|
+
syntax: " @function <dashed-function> <function-parameter>#?) [returns <css-type>]? { <declaration-rule-list> }"
|
|
4716
|
+
},
|
|
4717
|
+
"@mixin": {
|
|
4718
|
+
syntax: " @mixin [<dashed-function> <function-parameter>#? ) | <ident-token> ]{<block-contents>}"
|
|
4719
|
+
},
|
|
4720
|
+
"@apply": {
|
|
4721
|
+
syntax: " @apply [ <dashed-ident> | <dashed-function> ] [ { <declaration-list> } ]?;"
|
|
4722
|
+
},
|
|
4723
|
+
"@contents": {
|
|
4724
|
+
syntax: " @contents [ { <declaration-list> } ]?;"
|
|
4716
4725
|
},
|
|
4717
4726
|
"@left-top": {
|
|
4718
4727
|
syntax: " @left-top { <declaration-list> }"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 1.
|
|
5
|
+
Version: 1.8.1
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { EnumToken } from '../types.js';
|
|
@@ -38,7 +38,7 @@ function replace(node, variableScope) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
for (const { value, parent: parentValue } of walkValues(node.val)) {
|
|
41
|
-
if (value.typ == EnumToken.
|
|
41
|
+
if (value.typ == EnumToken.MathFunctionTokenType ||
|
|
42
42
|
(value.typ == EnumToken.WildCardFunctionTokenType && value.val == "var")) {
|
|
43
43
|
if (value.chi.length == 1 &&
|
|
44
44
|
value.chi[0].typ == EnumToken.DashedIdenTokenType) {
|
|
@@ -46,9 +46,10 @@ function replace(node, variableScope) {
|
|
|
46
46
|
if (info?.replaceable) {
|
|
47
47
|
if (parentValue != null) {
|
|
48
48
|
let i = 0;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const source = parentValue.typ == EnumToken.DeclarationNodeType ? parentValue.val : parentValue.chi;
|
|
50
|
+
for (; i < source.length; i++) {
|
|
51
|
+
if (source[i] == value) {
|
|
52
|
+
source.splice(i, 1, ...info.node.val);
|
|
52
53
|
break;
|
|
53
54
|
}
|
|
54
55
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 1.
|
|
5
|
+
Version: 1.8.1
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { PropertyList } from '../../parser/declaration/list.js';
|
|
@@ -37,32 +37,49 @@ class ComputeShorthandFeature {
|
|
|
37
37
|
let l;
|
|
38
38
|
const rules = [];
|
|
39
39
|
const declarations = [];
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
let doNotSort = false;
|
|
41
|
+
if (ast.typ == EnumToken.AtRuleNodeType) {
|
|
42
|
+
switch (ast.nam) {
|
|
43
|
+
case "function":
|
|
44
|
+
case "mixin":
|
|
45
|
+
doNotSort = true;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// https://drafts.csswg.org/css-mixins/#:~:text=The%20value%20of%20the%20result%20descriptor%20is%20always%2016px%20in%20the%20above%20example
|
|
50
|
+
if (doNotSort) {
|
|
51
|
+
for (const node of ast.chi) {
|
|
52
|
+
declarations.push(node);
|
|
52
53
|
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
53
56
|
// @ts-ignore
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
for (; k < j; k++) {
|
|
58
|
+
l = k;
|
|
59
|
+
// capture comments with the next token
|
|
60
|
+
while (l + 1 < j) {
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
const node = ast.chi[l];
|
|
63
|
+
if (node.typ == EnumToken.CommentNodeType) {
|
|
64
|
+
l++;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
58
68
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
const node = ast.chi[l];
|
|
71
|
+
if (node.typ == EnumToken.DeclarationNodeType) {
|
|
72
|
+
for (let m = k; m <= l; m++) {
|
|
73
|
+
declarations.push(ast.chi[m]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
for (let m = k; m <= l; m++) {
|
|
78
|
+
rules.push(ast.chi[m]);
|
|
79
|
+
}
|
|
63
80
|
}
|
|
81
|
+
k = l;
|
|
64
82
|
}
|
|
65
|
-
k = l;
|
|
66
83
|
}
|
|
67
84
|
if (declarations.length > 0) {
|
|
68
85
|
ast.chi.length = 0;
|