@projectwallace/css-parser 0.18.8 → 0.18.11
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/README.md +186 -18
- package/dist/{arena-e9O_g2AN.js → arena-Bsf96CQK.js} +27 -19
- package/dist/{arena-BGvFdbj5.d.ts → arena-DvT75bvK.d.ts} +2 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/{css-node-CH5HqF0J.js → css-node-yoUdFtNg.js} +101 -106
- package/dist/index.d.ts +6 -20
- package/dist/index.js +9 -146
- package/dist/{node-types-YnOKcNfU.d.ts → node-types-DG8OKqPu.d.ts} +8 -54
- package/dist/node-types.d.ts +2 -0
- package/dist/node-types.js +142 -0
- package/dist/parse-anplusb.d.ts +2 -2
- package/dist/parse-anplusb.js +5 -4
- package/dist/parse-atrule-prelude.d.ts +4 -3
- package/dist/parse-atrule-prelude.js +82 -77
- package/dist/parse-declaration.d.ts +4 -3
- package/dist/parse-declaration.js +28 -26
- package/dist/parse-dimension.js +46 -1
- package/dist/{parse-selector-PhqFezCi.js → parse-selector-CqIpnBrQ.js} +74 -89
- package/dist/parse-selector.d.ts +2 -2
- package/dist/parse-selector.js +1 -2
- package/dist/parse-value.d.ts +2 -2
- package/dist/parse-value.js +8 -8
- package/dist/parse.d.ts +3 -3
- package/dist/parse.js +49 -47
- package/dist/string-helpers-BMWJduts.d.ts +18 -0
- package/dist/string-helpers.d.ts +2 -0
- package/dist/string-helpers.js +1 -0
- package/dist/{parse-dimension-CQELWb5z.js → string-utils-DiRRd28d.js} +9 -59
- package/dist/token-types-Bqsf5FX-.d.ts +38 -0
- package/dist/token-types.d.ts +2 -0
- package/dist/token-types.js +30 -0
- package/dist/{tokenize-BYl6GvyV.js → tokenize-Ccg58Z_k.js} +79 -96
- package/dist/tokenize.d.ts +97 -2
- package/dist/tokenize.js +1 -2
- package/dist/{value-node-parser-tjY982sG.js → value-node-parser-D0qnA_bD.js} +153 -219
- package/dist/walk.d.ts +3 -2
- package/dist/walk.js +2 -2
- package/package.json +29 -18
- package/dist/tokenize-CDEnYcVG.d.ts +0 -133
|
@@ -1,54 +1,6 @@
|
|
|
1
|
-
import { A as PARENTHESIS, B as STYLESHEET, C as MEDIA_QUERY, D as NTH_SELECTOR, E as NTH_OF_SELECTOR, F as RATIO, G as UNICODE_RANGE, H as SUPPORTS_DECLARATION, I as RAW, J as VALUE, K as UNIVERSAL_SELECTOR, L as SELECTOR, M as PRELUDE_SELECTORLIST, N as PSEUDO_CLASS_SELECTOR, O as NUMBER, P as PSEUDO_ELEMENT_SELECTOR, R as SELECTOR_LIST, S as MEDIA_FEATURE, T as NESTING_SELECTOR, U as SUPPORTS_QUERY, V as STYLE_RULE, W as TYPE_SELECTOR, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LANG_SELECTOR, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PRELUDE_OPERATOR, k as OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, q as URL, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as IF_BRANCH, w as MEDIA_TYPE, x as LAYER_NAME, y as IF_CONDITION, z as STRING } from "./arena-
|
|
1
|
+
import { A as PARENTHESIS, B as STYLESHEET, C as MEDIA_QUERY, D as NTH_SELECTOR, E as NTH_OF_SELECTOR, F as RATIO, G as UNICODE_RANGE, H as SUPPORTS_DECLARATION, I as RAW, J as VALUE, K as UNIVERSAL_SELECTOR, L as SELECTOR, M as PRELUDE_SELECTORLIST, N as PSEUDO_CLASS_SELECTOR, O as NUMBER, P as PSEUDO_ELEMENT_SELECTOR, R as SELECTOR_LIST, S as MEDIA_FEATURE, T as NESTING_SELECTOR, U as SUPPORTS_QUERY, V as STYLE_RULE, W as TYPE_SELECTOR, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LANG_SELECTOR, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PRELUDE_OPERATOR, k as OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, q as URL, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as IF_BRANCH, w as MEDIA_TYPE, x as LAYER_NAME, y as IF_CONDITION, z as STRING } from "./arena-DvT75bvK.js";
|
|
2
2
|
//#region src/css-node.d.ts
|
|
3
|
-
|
|
4
|
-
readonly 1: 'StyleSheet';
|
|
5
|
-
readonly 2: 'Rule';
|
|
6
|
-
readonly 3: 'Atrule';
|
|
7
|
-
readonly 4: 'Declaration';
|
|
8
|
-
readonly 5: 'Selector';
|
|
9
|
-
readonly 6: 'Comment';
|
|
10
|
-
readonly 7: 'Block';
|
|
11
|
-
readonly 8: 'Raw';
|
|
12
|
-
readonly 10: 'Identifier';
|
|
13
|
-
readonly 11: 'Number';
|
|
14
|
-
readonly 12: 'Dimension';
|
|
15
|
-
readonly 13: 'String';
|
|
16
|
-
readonly 14: 'Hash';
|
|
17
|
-
readonly 15: 'Function';
|
|
18
|
-
readonly 16: 'Operator';
|
|
19
|
-
readonly 17: 'Parentheses';
|
|
20
|
-
readonly 18: 'Url';
|
|
21
|
-
readonly 19: 'UnicodeRange';
|
|
22
|
-
readonly 50: 'Value';
|
|
23
|
-
readonly 20: 'SelectorList';
|
|
24
|
-
readonly 21: 'TypeSelector';
|
|
25
|
-
readonly 22: 'ClassSelector';
|
|
26
|
-
readonly 23: 'IdSelector';
|
|
27
|
-
readonly 24: 'AttributeSelector';
|
|
28
|
-
readonly 25: 'PseudoClassSelector';
|
|
29
|
-
readonly 26: 'PseudoElementSelector';
|
|
30
|
-
readonly 27: 'Combinator';
|
|
31
|
-
readonly 28: 'UniversalSelector';
|
|
32
|
-
readonly 29: 'NestingSelector';
|
|
33
|
-
readonly 30: 'Nth';
|
|
34
|
-
readonly 31: 'NthOf';
|
|
35
|
-
readonly 56: 'Lang';
|
|
36
|
-
readonly 32: 'MediaQuery';
|
|
37
|
-
readonly 33: 'Feature';
|
|
38
|
-
readonly 34: 'MediaType';
|
|
39
|
-
readonly 35: 'ContainerQuery';
|
|
40
|
-
readonly 36: 'SupportsQuery';
|
|
41
|
-
readonly 57: 'SupportsDeclaration';
|
|
42
|
-
readonly 37: 'Layer';
|
|
43
|
-
readonly 38: 'Operator';
|
|
44
|
-
readonly 39: 'MediaFeatureRange';
|
|
45
|
-
readonly 40: 'AtrulePrelude';
|
|
46
|
-
readonly 41: 'PreludeSelectorList';
|
|
47
|
-
readonly 58: 'Ratio';
|
|
48
|
-
readonly 59: 'IfBranch';
|
|
49
|
-
readonly 60: 'IfCondition';
|
|
50
|
-
};
|
|
51
|
-
type TypeName = (typeof TYPE_NAMES)[keyof typeof TYPE_NAMES] | 'unknown';
|
|
3
|
+
type TypeName = 'StyleSheet' | 'Rule' | 'Atrule' | 'Declaration' | 'Selector' | 'Comment' | 'Block' | 'Raw' | 'Identifier' | 'Number' | 'Dimension' | 'String' | 'Hash' | 'Function' | 'Operator' | 'Parentheses' | 'Url' | 'UnicodeRange' | 'Value' | 'SelectorList' | 'TypeSelector' | 'ClassSelector' | 'IdSelector' | 'AttributeSelector' | 'PseudoClassSelector' | 'PseudoElementSelector' | 'Combinator' | 'UniversalSelector' | 'NestingSelector' | 'Nth' | 'NthOf' | 'Lang' | 'MediaQuery' | 'Feature' | 'MediaType' | 'ContainerQuery' | 'SupportsQuery' | 'SupportsDeclaration' | 'Layer' | 'MediaFeatureRange' | 'AtrulePrelude' | 'PreludeSelectorList' | 'Ratio' | 'IfBranch' | 'IfCondition' | 'unknown';
|
|
52
4
|
type CSSNodeType = typeof STYLESHEET | typeof STYLE_RULE | typeof AT_RULE | typeof DECLARATION | typeof SELECTOR | typeof COMMENT | typeof BLOCK | typeof RAW | typeof IDENTIFIER | typeof NUMBER | typeof DIMENSION | typeof STRING | typeof HASH | typeof FUNCTION | typeof OPERATOR | typeof PARENTHESIS | typeof URL | typeof UNICODE_RANGE | typeof VALUE | typeof SELECTOR_LIST | typeof TYPE_SELECTOR | typeof CLASS_SELECTOR | typeof ID_SELECTOR | typeof ATTRIBUTE_SELECTOR | typeof PSEUDO_CLASS_SELECTOR | typeof PSEUDO_ELEMENT_SELECTOR | typeof COMBINATOR | typeof UNIVERSAL_SELECTOR | typeof NESTING_SELECTOR | typeof NTH_SELECTOR | typeof NTH_OF_SELECTOR | typeof LANG_SELECTOR | typeof MEDIA_QUERY | typeof MEDIA_FEATURE | typeof MEDIA_TYPE | typeof CONTAINER_QUERY | typeof SUPPORTS_QUERY | typeof LAYER_NAME | typeof PRELUDE_OPERATOR | typeof FEATURE_RANGE | typeof AT_RULE_PRELUDE | typeof PRELUDE_SELECTORLIST | typeof SUPPORTS_DECLARATION | typeof RATIO | typeof IF_BRANCH | typeof IF_CONDITION;
|
|
53
5
|
interface CloneOptions {
|
|
54
6
|
/**
|
|
@@ -351,11 +303,13 @@ type MediaQuery = WithClone<CSSNode & WithChildren<MediaFeature | PreludeOperato
|
|
|
351
303
|
readonly type: typeof MEDIA_QUERY;
|
|
352
304
|
readonly type_name: 'MediaQuery';
|
|
353
305
|
}>;
|
|
354
|
-
type MediaFeature =
|
|
306
|
+
type MediaFeature = WithClone<CSSNode & WithChildren<Identifier | Number | Dimension | Ratio> & {
|
|
307
|
+
readonly type: typeof MEDIA_FEATURE;
|
|
308
|
+
readonly type_name: 'Feature';
|
|
355
309
|
/** Feature name, e.g. "min-width" */
|
|
356
310
|
readonly property: string;
|
|
357
|
-
/** Feature value node (
|
|
358
|
-
readonly value:
|
|
311
|
+
/** Feature value node (Dimension, Number, Identifier or Ratio), or null for boolean features like (hover). Hacks like `0\0` add further children after it. */
|
|
312
|
+
readonly value: Identifier | Number | Dimension | Ratio | null;
|
|
359
313
|
}>;
|
|
360
314
|
type MediaType = Leaf<typeof MEDIA_TYPE, 'MediaType', {
|
|
361
315
|
/** Media type text, e.g. "screen", "print" */
|
|
@@ -448,4 +402,4 @@ declare function is_feature_range(node: CSSNode): node is FeatureRange;
|
|
|
448
402
|
declare function is_ratio(node: CSSNode): node is Ratio;
|
|
449
403
|
declare function is_prelude_selectorlist(node: CSSNode): node is PreludeSelectorList;
|
|
450
404
|
//#endregion
|
|
451
|
-
export {
|
|
405
|
+
export { is_atrule as $, Operator as A, is_pseudo_element_selector as At, SelectorList as B, is_type_selector as Bt, MediaFeature as C, is_nth_selector as Ct, NthOfSelector as D, is_prelude_operator as Dt, NestingSelector as E, is_parenthesis as Et, PseudoElementSelector as F, is_selector_list as Ft, SupportsQuery as G, CloneOptions as Gt, String as H, is_universal_selector as Ht, Ratio as I, is_string as It, UnicodeRange as J, ToPlain as K, PlainCSSNode as Kt, Raw as L, is_stylesheet as Lt, PreludeOperator as M, is_raw as Mt, PreludeSelectorList as N, is_rule as Nt, NthSelector as O, is_prelude_selectorlist as Ot, PseudoClassSelector as P, is_selector as Pt, WithChildren as Q, Rule as R, is_supports_declaration as Rt, LayerName as S, is_nth_of_selector as St, MediaType as T, is_operator as Tt, StyleSheet as U, is_url as Ut, SelectorNode as V, is_unicode_range as Vt, SupportsDeclaration as W, is_value as Wt, Url as X, UniversalSelector as Y, Value as Z, IdSelector as _, is_layer_name as _t, Block as a, is_comment as at, IfCondition as b, is_media_type as bt, ClassSelector as c, is_dimension as ct, ContainerQuery as d, is_hash as dt, is_atrule_prelude as et, Declaration as f, is_id_selector as ft, Hash as g, is_lang_selector as gt, Function as h, is_if_condition as ht, AttributeSelector as i, is_combinator as it, Parenthesis as j, is_ratio as jt, Number as k, is_pseudo_class_selector as kt, Combinator as l, is_feature_range as lt, FeatureRange as m, is_if_branch as mt, Atrule as n, is_block as nt, BlockChild as o, is_container_query as ot, Dimension as p, is_identifier as pt, TypeSelector as q, AtrulePrelude as r, is_class_selector as rt, CSSNode as s, is_declaration as st, AnyNode as t, is_attribute_selector as tt, Comment as u, is_function as ut, Identifier as v, is_media_feature as vt, MediaQuery as w, is_number as wt, LangSelector as x, is_nesting_selector as xt, IfBranch as y, is_media_query as yt, Selector as z, is_supports_query as zt };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $ as is_atrule, A as Operator, At as is_pseudo_element_selector, B as SelectorList, Bt as is_type_selector, C as MediaFeature, Ct as is_nth_selector, D as NthOfSelector, Dt as is_prelude_operator, E as NestingSelector, Et as is_parenthesis, F as PseudoElementSelector, Ft as is_selector_list, G as SupportsQuery, Gt as CloneOptions, H as String, Ht as is_universal_selector, I as Ratio, It as is_string, J as UnicodeRange, K as ToPlain, Kt as PlainCSSNode, L as Raw, Lt as is_stylesheet, M as PreludeOperator, Mt as is_raw, N as PreludeSelectorList, Nt as is_rule, O as NthSelector, Ot as is_prelude_selectorlist, P as PseudoClassSelector, Pt as is_selector, Q as WithChildren, R as Rule, Rt as is_supports_declaration, S as LayerName, St as is_nth_of_selector, T as MediaType, Tt as is_operator, U as StyleSheet, Ut as is_url, V as SelectorNode, Vt as is_unicode_range, W as SupportsDeclaration, Wt as is_value, X as Url, Y as UniversalSelector, Z as Value, _ as IdSelector, _t as is_layer_name, a as Block, at as is_comment, b as IfCondition, bt as is_media_type, c as ClassSelector, ct as is_dimension, d as ContainerQuery, dt as is_hash, et as is_atrule_prelude, f as Declaration, ft as is_id_selector, g as Hash, gt as is_lang_selector, h as Function, ht as is_if_condition, i as AttributeSelector, it as is_combinator, j as Parenthesis, jt as is_ratio, k as Number, kt as is_pseudo_class_selector, l as Combinator, lt as is_feature_range, m as FeatureRange, mt as is_if_branch, n as Atrule, nt as is_block, o as BlockChild, ot as is_container_query, p as Dimension, pt as is_identifier, q as TypeSelector, r as AtrulePrelude, rt as is_class_selector, s as CSSNode, st as is_declaration, t as AnyNode, tt as is_attribute_selector, u as Comment, ut as is_function, v as Identifier, vt as is_media_feature, w as MediaQuery, wt as is_number, x as LangSelector, xt as is_nesting_selector, y as IfBranch, yt as is_media_query, z as Selector, zt as is_supports_query } from "./node-types-DG8OKqPu.js";
|
|
2
|
+
export { AnyNode, Atrule, AtrulePrelude, AttributeSelector, Block, BlockChild, CSSNode, ClassSelector, type CloneOptions, Combinator, Comment, ContainerQuery, Declaration, Dimension, FeatureRange, Function, Hash, IdSelector, Identifier, IfBranch, IfCondition, LangSelector, LayerName, MediaFeature, MediaQuery, MediaType, NestingSelector, NthOfSelector, NthSelector, Number, Operator, Parenthesis, type PlainCSSNode, PreludeOperator, PreludeSelectorList, PseudoClassSelector, PseudoElementSelector, Ratio, Raw, Rule, Selector, SelectorList, SelectorNode, String, StyleSheet, SupportsDeclaration, SupportsQuery, ToPlain, TypeSelector, UnicodeRange, UniversalSelector, Url, Value, WithChildren, is_atrule, is_atrule_prelude, is_attribute_selector, is_block, is_class_selector, is_combinator, is_comment, is_container_query, is_declaration, is_dimension, is_feature_range, is_function, is_hash, is_id_selector, is_identifier, is_if_branch, is_if_condition, is_lang_selector, is_layer_name, is_media_feature, is_media_query, is_media_type, is_nesting_selector, is_nth_of_selector, is_nth_selector, is_number, is_operator, is_parenthesis, is_prelude_operator, is_prelude_selectorlist, is_pseudo_class_selector, is_pseudo_element_selector, is_ratio, is_raw, is_rule, is_selector, is_selector_list, is_string, is_stylesheet, is_supports_declaration, is_supports_query, is_type_selector, is_unicode_range, is_universal_selector, is_url, is_value };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import "./arena-Bsf96CQK.js";
|
|
2
|
+
//#region src/node-types.ts
|
|
3
|
+
function is_stylesheet(node) {
|
|
4
|
+
return node.type === 1;
|
|
5
|
+
}
|
|
6
|
+
function is_rule(node) {
|
|
7
|
+
return node.type === 2;
|
|
8
|
+
}
|
|
9
|
+
function is_atrule(node) {
|
|
10
|
+
return node.type === 3;
|
|
11
|
+
}
|
|
12
|
+
function is_declaration(node) {
|
|
13
|
+
return node.type === 4;
|
|
14
|
+
}
|
|
15
|
+
function is_selector(node) {
|
|
16
|
+
return node.type === 5;
|
|
17
|
+
}
|
|
18
|
+
function is_selector_list(node) {
|
|
19
|
+
return node.type === 20;
|
|
20
|
+
}
|
|
21
|
+
function is_block(node) {
|
|
22
|
+
return node.type === 7;
|
|
23
|
+
}
|
|
24
|
+
function is_comment(node) {
|
|
25
|
+
return node.type === 6;
|
|
26
|
+
}
|
|
27
|
+
function is_raw(node) {
|
|
28
|
+
return node.type === 8;
|
|
29
|
+
}
|
|
30
|
+
function is_identifier(node) {
|
|
31
|
+
return node.type === 10;
|
|
32
|
+
}
|
|
33
|
+
function is_number(node) {
|
|
34
|
+
return node.type === 11;
|
|
35
|
+
}
|
|
36
|
+
function is_dimension(node) {
|
|
37
|
+
return node.type === 12;
|
|
38
|
+
}
|
|
39
|
+
function is_string(node) {
|
|
40
|
+
return node.type === 13;
|
|
41
|
+
}
|
|
42
|
+
function is_hash(node) {
|
|
43
|
+
return node.type === 14;
|
|
44
|
+
}
|
|
45
|
+
function is_function(node) {
|
|
46
|
+
return node.type === 15;
|
|
47
|
+
}
|
|
48
|
+
function is_operator(node) {
|
|
49
|
+
return node.type === 16;
|
|
50
|
+
}
|
|
51
|
+
function is_parenthesis(node) {
|
|
52
|
+
return node.type === 17;
|
|
53
|
+
}
|
|
54
|
+
function is_url(node) {
|
|
55
|
+
return node.type === 18;
|
|
56
|
+
}
|
|
57
|
+
function is_unicode_range(node) {
|
|
58
|
+
return node.type === 19;
|
|
59
|
+
}
|
|
60
|
+
function is_if_branch(node) {
|
|
61
|
+
return node.type === 59;
|
|
62
|
+
}
|
|
63
|
+
function is_if_condition(node) {
|
|
64
|
+
return node.type === 60;
|
|
65
|
+
}
|
|
66
|
+
function is_value(node) {
|
|
67
|
+
return node.type === 50;
|
|
68
|
+
}
|
|
69
|
+
function is_type_selector(node) {
|
|
70
|
+
return node.type === 21;
|
|
71
|
+
}
|
|
72
|
+
function is_class_selector(node) {
|
|
73
|
+
return node.type === 22;
|
|
74
|
+
}
|
|
75
|
+
function is_id_selector(node) {
|
|
76
|
+
return node.type === 23;
|
|
77
|
+
}
|
|
78
|
+
function is_attribute_selector(node) {
|
|
79
|
+
return node.type === 24;
|
|
80
|
+
}
|
|
81
|
+
function is_pseudo_class_selector(node) {
|
|
82
|
+
return node.type === 25;
|
|
83
|
+
}
|
|
84
|
+
function is_pseudo_element_selector(node) {
|
|
85
|
+
return node.type === 26;
|
|
86
|
+
}
|
|
87
|
+
function is_combinator(node) {
|
|
88
|
+
return node.type === 27;
|
|
89
|
+
}
|
|
90
|
+
function is_universal_selector(node) {
|
|
91
|
+
return node.type === 28;
|
|
92
|
+
}
|
|
93
|
+
function is_nesting_selector(node) {
|
|
94
|
+
return node.type === 29;
|
|
95
|
+
}
|
|
96
|
+
function is_nth_selector(node) {
|
|
97
|
+
return node.type === 30;
|
|
98
|
+
}
|
|
99
|
+
function is_nth_of_selector(node) {
|
|
100
|
+
return node.type === 31;
|
|
101
|
+
}
|
|
102
|
+
function is_lang_selector(node) {
|
|
103
|
+
return node.type === 56;
|
|
104
|
+
}
|
|
105
|
+
function is_atrule_prelude(node) {
|
|
106
|
+
return node.type === 40;
|
|
107
|
+
}
|
|
108
|
+
function is_media_query(node) {
|
|
109
|
+
return node.type === 32;
|
|
110
|
+
}
|
|
111
|
+
function is_media_feature(node) {
|
|
112
|
+
return node.type === 33;
|
|
113
|
+
}
|
|
114
|
+
function is_media_type(node) {
|
|
115
|
+
return node.type === 34;
|
|
116
|
+
}
|
|
117
|
+
function is_container_query(node) {
|
|
118
|
+
return node.type === 35;
|
|
119
|
+
}
|
|
120
|
+
function is_supports_query(node) {
|
|
121
|
+
return node.type === 36;
|
|
122
|
+
}
|
|
123
|
+
function is_supports_declaration(node) {
|
|
124
|
+
return node.type === 57;
|
|
125
|
+
}
|
|
126
|
+
function is_layer_name(node) {
|
|
127
|
+
return node.type === 37;
|
|
128
|
+
}
|
|
129
|
+
function is_prelude_operator(node) {
|
|
130
|
+
return node.type === 38;
|
|
131
|
+
}
|
|
132
|
+
function is_feature_range(node) {
|
|
133
|
+
return node.type === 39;
|
|
134
|
+
}
|
|
135
|
+
function is_ratio(node) {
|
|
136
|
+
return node.type === 58;
|
|
137
|
+
}
|
|
138
|
+
function is_prelude_selectorlist(node) {
|
|
139
|
+
return node.type === 41;
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
export { is_atrule, is_atrule_prelude, is_attribute_selector, is_block, is_class_selector, is_combinator, is_comment, is_container_query, is_declaration, is_dimension, is_feature_range, is_function, is_hash, is_id_selector, is_identifier, is_if_branch, is_if_condition, is_lang_selector, is_layer_name, is_media_feature, is_media_query, is_media_type, is_nesting_selector, is_nth_of_selector, is_nth_selector, is_number, is_operator, is_parenthesis, is_prelude_operator, is_prelude_selectorlist, is_pseudo_class_selector, is_pseudo_element_selector, is_ratio, is_raw, is_rule, is_selector, is_selector_list, is_string, is_stylesheet, is_supports_declaration, is_supports_query, is_type_selector, is_unicode_range, is_universal_selector, is_url, is_value };
|
package/dist/parse-anplusb.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import {
|
|
1
|
+
import { l as CSSDataArena } from "./arena-DvT75bvK.js";
|
|
2
|
+
import { O as NthSelector } from "./node-types-DG8OKqPu.js";
|
|
3
3
|
//#region src/parse-anplusb.d.ts
|
|
4
4
|
/** @internal */
|
|
5
5
|
export declare class ANplusBParser {
|
package/dist/parse-anplusb.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { t as Lexer } from "./tokenize-
|
|
2
|
-
import
|
|
3
|
-
import { l as
|
|
4
|
-
import {
|
|
1
|
+
import { t as Lexer } from "./tokenize-Ccg58Z_k.js";
|
|
2
|
+
import "./token-types.js";
|
|
3
|
+
import { l as CSSDataArena } from "./arena-Bsf96CQK.js";
|
|
4
|
+
import { l as str_index_of, s as str_equals } from "./string-utils-DiRRd28d.js";
|
|
5
|
+
import { t as CSSNode } from "./css-node-yoUdFtNg.js";
|
|
5
6
|
//#region src/parse-anplusb.ts
|
|
6
7
|
/** @internal */
|
|
7
8
|
var ANplusBParser = class {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { t as AnyNode } from "./node-types-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-DvT75bvK.js";
|
|
2
|
+
import { t as AnyNode } from "./node-types-DG8OKqPu.js";
|
|
3
3
|
//#region src/parse-atrule-prelude.d.ts
|
|
4
4
|
/** @internal */
|
|
5
5
|
export declare class AtRulePreludeParser {
|
|
@@ -14,7 +14,8 @@ export declare class AtRulePreludeParser {
|
|
|
14
14
|
private parse_prelude_dispatch;
|
|
15
15
|
private parse_media_query_list;
|
|
16
16
|
private create_node;
|
|
17
|
-
private
|
|
17
|
+
private paren_content_end;
|
|
18
|
+
private paren_close_end;
|
|
18
19
|
private scan_matching_paren;
|
|
19
20
|
private parse_single_media_query;
|
|
20
21
|
private parse_container_query;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { t as Lexer } from "./tokenize-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { t as Lexer } from "./tokenize-Ccg58Z_k.js";
|
|
2
|
+
import "./token-types.js";
|
|
3
|
+
import { l as CSSDataArena } from "./arena-Bsf96CQK.js";
|
|
4
|
+
import { c as str_equals_range, d as strip_vendor_prefix, t as is_and_or_not_range } from "./string-utils-DiRRd28d.js";
|
|
5
|
+
import { t as CSSNode } from "./css-node-yoUdFtNg.js";
|
|
6
|
+
import { s as trim_boundaries } from "./parse-selector-CqIpnBrQ.js";
|
|
7
|
+
import { n as ConditionParser, t as ValueNodeParser } from "./value-node-parser-D0qnA_bD.js";
|
|
7
8
|
//#region src/parse-atrule-prelude.ts
|
|
8
9
|
/** @internal */
|
|
9
10
|
var AtRulePreludeParser = class {
|
|
@@ -50,11 +51,11 @@ var AtRulePreludeParser = class {
|
|
|
50
51
|
return [];
|
|
51
52
|
}
|
|
52
53
|
parse_media_query_list() {
|
|
53
|
-
|
|
54
|
+
const nodes = [];
|
|
54
55
|
while (this.lexer.pos < this.prelude_end) {
|
|
55
56
|
this.skip_whitespace();
|
|
56
57
|
if (this.lexer.pos >= this.prelude_end) break;
|
|
57
|
-
|
|
58
|
+
const query = this.parse_single_media_query();
|
|
58
59
|
if (query !== null) nodes.push(query);
|
|
59
60
|
this.skip_whitespace();
|
|
60
61
|
const saved = this.lexer.save_position();
|
|
@@ -66,15 +67,14 @@ var AtRulePreludeParser = class {
|
|
|
66
67
|
create_node(type, start, end) {
|
|
67
68
|
return this.arena.create_node(type, start, end - start, this.lexer.token_line, this.lexer.token_column);
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
70
|
+
paren_content_end = 0;
|
|
71
|
+
paren_close_end = 0;
|
|
72
72
|
scan_matching_paren() {
|
|
73
73
|
let depth = 1;
|
|
74
74
|
let content_end = this.lexer.pos;
|
|
75
75
|
let close_end = this.lexer.token_end;
|
|
76
76
|
while (this.lexer.pos < this.prelude_end && depth > 0) {
|
|
77
|
-
|
|
77
|
+
const token_type = this.next_token();
|
|
78
78
|
if (token_type === 21 || token_type === 2) depth++;
|
|
79
79
|
else if (token_type === 22) {
|
|
80
80
|
depth--;
|
|
@@ -84,14 +84,12 @@ var AtRulePreludeParser = class {
|
|
|
84
84
|
}
|
|
85
85
|
} else if (token_type === 26) break;
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
depth === 0
|
|
91
|
-
];
|
|
87
|
+
this.paren_content_end = content_end;
|
|
88
|
+
this.paren_close_end = close_end;
|
|
89
|
+
return depth === 0;
|
|
92
90
|
}
|
|
93
91
|
parse_single_media_query() {
|
|
94
|
-
|
|
92
|
+
const query_start = this.lexer.pos;
|
|
95
93
|
this.skip_whitespace();
|
|
96
94
|
if (this.lexer.pos >= this.prelude_end) return null;
|
|
97
95
|
let first_component = 0;
|
|
@@ -99,9 +97,11 @@ var AtRulePreludeParser = class {
|
|
|
99
97
|
const saved_token_start = this.lexer.save_position();
|
|
100
98
|
this.next_token();
|
|
101
99
|
if (this.lexer.token_type === 1) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
const source = this.source;
|
|
101
|
+
const token_start = this.lexer.token_start;
|
|
102
|
+
const token_end = this.lexer.token_end;
|
|
103
|
+
if (str_equals_range(source, token_start, token_end, "only") || str_equals_range(source, token_start, token_end, "not")) {
|
|
104
|
+
const modifier = this.create_node(38, token_start, token_end);
|
|
105
105
|
first_component = modifier;
|
|
106
106
|
last_component = modifier;
|
|
107
107
|
} else this.lexer.restore_position(saved_token_start);
|
|
@@ -111,15 +111,16 @@ var AtRulePreludeParser = class {
|
|
|
111
111
|
if (this.lexer.pos >= this.prelude_end) break;
|
|
112
112
|
if (this.peek_token_type() === 18) break;
|
|
113
113
|
this.next_token();
|
|
114
|
-
|
|
114
|
+
const token_type = this.lexer.token_type;
|
|
115
115
|
let component = null;
|
|
116
116
|
if (token_type === 21) {
|
|
117
117
|
component = this.condition_parser.parse_media_feature(this.lexer.token_start, this.prelude_end, this.lexer.token_line, this.lexer.token_column);
|
|
118
|
-
if (component !== null) this.
|
|
118
|
+
if (component !== null) this.condition_parser.seek_to_end(this.lexer);
|
|
119
119
|
} else if (token_type === 1) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
const token_start = this.lexer.token_start;
|
|
121
|
+
const token_end = this.lexer.token_end;
|
|
122
|
+
if (is_and_or_not_range(this.source, token_start, token_end)) component = this.create_node(38, token_start, token_end);
|
|
123
|
+
else component = this.create_node(34, token_start, token_end);
|
|
123
124
|
} else break;
|
|
124
125
|
if (component !== null) {
|
|
125
126
|
if (first_component === 0) first_component = component;
|
|
@@ -128,30 +129,31 @@ var AtRulePreludeParser = class {
|
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
if (first_component === 0) return null;
|
|
131
|
-
|
|
132
|
+
const query_node = this.create_node(32, query_start, this.lexer.pos);
|
|
132
133
|
this.arena.set_first_child(query_node, first_component);
|
|
133
134
|
return query_node;
|
|
134
135
|
}
|
|
135
136
|
parse_container_query() {
|
|
136
|
-
|
|
137
|
+
const query_start = this.lexer.pos;
|
|
137
138
|
let first_component = 0;
|
|
138
139
|
let last_component = 0;
|
|
139
140
|
while (this.lexer.pos < this.prelude_end) {
|
|
140
141
|
this.skip_whitespace();
|
|
141
142
|
if (this.lexer.pos >= this.prelude_end) break;
|
|
142
143
|
this.next_token();
|
|
143
|
-
|
|
144
|
+
const token_type = this.lexer.token_type;
|
|
144
145
|
let component = null;
|
|
145
146
|
if (token_type === 21) {
|
|
146
147
|
component = this.condition_parser.parse_media_feature(this.lexer.token_start, this.prelude_end, this.lexer.token_line, this.lexer.token_column);
|
|
147
|
-
if (component !== null) this.
|
|
148
|
+
if (component !== null) this.condition_parser.seek_to_end(this.lexer);
|
|
148
149
|
} else if (token_type === 2) {
|
|
149
150
|
component = this.condition_parser.parse_function_condition(this.lexer.token_start, this.prelude_end, this.lexer.token_line, this.lexer.token_column);
|
|
150
|
-
this.
|
|
151
|
+
this.condition_parser.seek_to_end(this.lexer);
|
|
151
152
|
} else if (token_type === 1) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
const token_start = this.lexer.token_start;
|
|
154
|
+
const token_end = this.lexer.token_end;
|
|
155
|
+
if (is_and_or_not_range(this.source, token_start, token_end)) component = this.create_node(38, token_start, token_end);
|
|
156
|
+
else component = this.create_node(10, token_start, token_end);
|
|
155
157
|
}
|
|
156
158
|
if (component !== null) {
|
|
157
159
|
if (first_component === 0) first_component = component;
|
|
@@ -160,7 +162,7 @@ var AtRulePreludeParser = class {
|
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
164
|
if (first_component === 0) return [];
|
|
163
|
-
|
|
165
|
+
const query_node = this.create_node(35, query_start, this.lexer.pos);
|
|
164
166
|
this.arena.set_first_child(query_node, first_component);
|
|
165
167
|
return [query_node];
|
|
166
168
|
}
|
|
@@ -168,29 +170,29 @@ var AtRulePreludeParser = class {
|
|
|
168
170
|
return this.condition_parser.parse_supports_condition(this.lexer.pos, this.prelude_end, this.lexer.line, this.lexer.column);
|
|
169
171
|
}
|
|
170
172
|
parse_layer_names() {
|
|
171
|
-
|
|
173
|
+
const nodes = [];
|
|
172
174
|
while (this.lexer.pos < this.prelude_end) {
|
|
173
175
|
this.skip_whitespace();
|
|
174
176
|
if (this.lexer.pos >= this.prelude_end) break;
|
|
175
177
|
this.next_token();
|
|
176
|
-
|
|
178
|
+
const token_type = this.lexer.token_type;
|
|
177
179
|
if (token_type === 1) {
|
|
178
|
-
|
|
180
|
+
const name_start = this.lexer.token_start;
|
|
179
181
|
let name_end = this.lexer.token_end;
|
|
180
182
|
while (this.lexer.pos < this.prelude_end) {
|
|
181
|
-
|
|
183
|
+
const saved = this.lexer.save_position();
|
|
182
184
|
if (this.next_token() !== 9 || this.source.charCodeAt(this.lexer.token_start) !== 46 || this.lexer.token_start !== name_end) {
|
|
183
185
|
this.lexer.restore_position(saved);
|
|
184
186
|
break;
|
|
185
187
|
}
|
|
186
|
-
|
|
188
|
+
const dot_end = this.lexer.token_end;
|
|
187
189
|
if (this.next_token() !== 1 || this.lexer.token_start !== dot_end) {
|
|
188
190
|
this.lexer.restore_position(saved);
|
|
189
191
|
break;
|
|
190
192
|
}
|
|
191
193
|
name_end = this.lexer.token_end;
|
|
192
194
|
}
|
|
193
|
-
|
|
195
|
+
const layer = this.create_node(37, name_start, name_end);
|
|
194
196
|
this.arena.set_content_start_delta(layer, 0);
|
|
195
197
|
this.arena.set_content_length(layer, name_end - name_start);
|
|
196
198
|
nodes.push(layer);
|
|
@@ -204,8 +206,8 @@ var AtRulePreludeParser = class {
|
|
|
204
206
|
if (this.lexer.pos >= this.prelude_end) return [];
|
|
205
207
|
this.next_token();
|
|
206
208
|
if (this.lexer.token_type !== 2) return [];
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
const name_start = this.lexer.token_start;
|
|
210
|
+
const name_end = this.lexer.token_end - 1;
|
|
209
211
|
return [this.create_node(10, name_start, name_end)];
|
|
210
212
|
}
|
|
211
213
|
parse_identifier() {
|
|
@@ -223,34 +225,34 @@ var AtRulePreludeParser = class {
|
|
|
223
225
|
return [this.create_node(13, this.lexer.token_start, this.lexer.token_end)];
|
|
224
226
|
}
|
|
225
227
|
parse_import_prelude() {
|
|
226
|
-
|
|
228
|
+
const nodes = [];
|
|
227
229
|
this.skip_whitespace();
|
|
228
230
|
if (this.lexer.pos >= this.prelude_end) return [];
|
|
229
|
-
|
|
231
|
+
const url_node = this.parse_import_url();
|
|
230
232
|
if (url_node === null) return [];
|
|
231
233
|
nodes.push(url_node);
|
|
232
234
|
this.skip_whitespace();
|
|
233
235
|
if (this.lexer.pos >= this.prelude_end) return nodes;
|
|
234
|
-
|
|
236
|
+
const layer_node = this.parse_import_layer();
|
|
235
237
|
if (layer_node !== null) nodes.push(layer_node);
|
|
236
238
|
this.skip_whitespace();
|
|
237
239
|
if (this.lexer.pos >= this.prelude_end) return nodes;
|
|
238
|
-
|
|
240
|
+
const supports_node = this.parse_import_supports();
|
|
239
241
|
if (supports_node !== null) nodes.push(supports_node);
|
|
240
242
|
this.skip_whitespace();
|
|
241
243
|
if (this.lexer.pos >= this.prelude_end) return nodes;
|
|
242
|
-
|
|
244
|
+
const media_nodes = this.parse_media_query_list();
|
|
243
245
|
nodes.push(...media_nodes);
|
|
244
246
|
return nodes;
|
|
245
247
|
}
|
|
246
248
|
parse_import_url() {
|
|
247
249
|
this.next_token();
|
|
248
250
|
if (this.lexer.token_type !== 7 && this.lexer.token_type !== 2 && this.lexer.token_type !== 5) return null;
|
|
249
|
-
|
|
251
|
+
const url_start = this.lexer.token_start;
|
|
250
252
|
let url_end = this.lexer.token_end;
|
|
251
253
|
if (this.lexer.token_type === 2) {
|
|
252
|
-
|
|
253
|
-
url_end =
|
|
254
|
+
this.scan_matching_paren();
|
|
255
|
+
url_end = this.paren_close_end;
|
|
254
256
|
}
|
|
255
257
|
return this.create_node(18, url_start, url_end);
|
|
256
258
|
}
|
|
@@ -258,24 +260,25 @@ var AtRulePreludeParser = class {
|
|
|
258
260
|
const saved = this.lexer.save_position();
|
|
259
261
|
this.next_token();
|
|
260
262
|
if (this.lexer.token_type === 1 || this.lexer.token_type === 2) {
|
|
261
|
-
|
|
262
|
-
if (this.lexer.
|
|
263
|
-
|
|
264
|
-
let layer_start = this.lexer.token_start;
|
|
263
|
+
const name_end = this.lexer.token_type === 2 ? this.lexer.token_end - 1 : this.lexer.token_end;
|
|
264
|
+
if (str_equals_range(this.source, this.lexer.token_start, name_end, "layer")) {
|
|
265
|
+
const layer_start = this.lexer.token_start;
|
|
265
266
|
let layer_end = this.lexer.token_end;
|
|
266
267
|
let content_start = 0;
|
|
267
268
|
let content_length = 0;
|
|
268
269
|
if (this.lexer.token_type === 2) {
|
|
269
270
|
content_start = this.lexer.pos;
|
|
270
|
-
|
|
271
|
+
const matched = this.scan_matching_paren();
|
|
272
|
+
const content_end = this.paren_content_end;
|
|
273
|
+
const close_end = this.paren_close_end;
|
|
271
274
|
if (matched) {
|
|
272
275
|
content_length = content_end - content_start;
|
|
273
276
|
layer_end = close_end;
|
|
274
277
|
}
|
|
275
278
|
}
|
|
276
|
-
|
|
279
|
+
const layer_node = this.create_node(37, layer_start, layer_end);
|
|
277
280
|
if (content_length > 0) {
|
|
278
|
-
|
|
281
|
+
const trimmed = trim_boundaries(this.source, content_start, content_start + content_length);
|
|
279
282
|
if (trimmed) {
|
|
280
283
|
this.arena.set_content_start_delta(layer_node, trimmed[0] - layer_start);
|
|
281
284
|
this.arena.set_content_length(layer_node, trimmed[1] - trimmed[0]);
|
|
@@ -291,17 +294,18 @@ var AtRulePreludeParser = class {
|
|
|
291
294
|
const saved = this.lexer.save_position();
|
|
292
295
|
this.next_token();
|
|
293
296
|
if (this.lexer.token_type === 2) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
297
|
+
if (str_equals_range(this.source, this.lexer.token_start, this.lexer.token_end - 1, "supports")) {
|
|
298
|
+
const supports_start = this.lexer.token_start;
|
|
299
|
+
const content_start = this.lexer.token_end;
|
|
300
|
+
this.scan_matching_paren();
|
|
301
|
+
const content_end = this.paren_content_end;
|
|
302
|
+
const supports_end = this.paren_close_end;
|
|
303
|
+
const supports_node = this.create_node(36, supports_start, supports_end);
|
|
304
|
+
const trimmed = trim_boundaries(this.source, content_start, content_end);
|
|
301
305
|
if (trimmed) {
|
|
302
306
|
this.arena.set_value_start_delta(supports_node, trimmed[0] - supports_start);
|
|
303
307
|
this.arena.set_value_length(supports_node, trimmed[1] - trimmed[0]);
|
|
304
|
-
|
|
308
|
+
const decl_child = this.condition_parser.parse_supports_declaration_content(trimmed[0], trimmed[1]);
|
|
305
309
|
if (decl_child !== null) this.arena.set_first_child(supports_node, decl_child);
|
|
306
310
|
}
|
|
307
311
|
return supports_node;
|
|
@@ -316,7 +320,7 @@ var AtRulePreludeParser = class {
|
|
|
316
320
|
peek_token_type() {
|
|
317
321
|
const saved = this.lexer.save_position();
|
|
318
322
|
this.next_token();
|
|
319
|
-
|
|
323
|
+
const type = this.lexer.token_type;
|
|
320
324
|
this.lexer.restore_position(saved);
|
|
321
325
|
return type;
|
|
322
326
|
}
|
|
@@ -328,7 +332,7 @@ var AtRulePreludeParser = class {
|
|
|
328
332
|
return this.lexer.next_token_fast(false);
|
|
329
333
|
}
|
|
330
334
|
parse_namespace_prelude() {
|
|
331
|
-
|
|
335
|
+
const nodes = [];
|
|
332
336
|
this.skip_whitespace();
|
|
333
337
|
if (this.lexer.pos >= this.prelude_end) return [];
|
|
334
338
|
const saved = this.lexer.save_position();
|
|
@@ -342,18 +346,20 @@ var AtRulePreludeParser = class {
|
|
|
342
346
|
return nodes;
|
|
343
347
|
}
|
|
344
348
|
parse_scope_prelude() {
|
|
345
|
-
|
|
349
|
+
const nodes = [];
|
|
346
350
|
while (this.lexer.pos < this.prelude_end) {
|
|
347
351
|
this.skip_whitespace();
|
|
348
352
|
if (this.lexer.pos >= this.prelude_end) break;
|
|
349
353
|
const token_type = this.peek_token_type();
|
|
350
354
|
if (token_type === 21) {
|
|
351
355
|
this.next_token();
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
356
|
+
const paren_start = this.lexer.token_start;
|
|
357
|
+
const content_start = this.lexer.pos;
|
|
358
|
+
this.scan_matching_paren();
|
|
359
|
+
const content_end = this.paren_content_end;
|
|
360
|
+
const paren_end = this.paren_close_end;
|
|
361
|
+
const scope_node = this.create_node(41, paren_start, paren_end);
|
|
362
|
+
const trimmed = trim_boundaries(this.source, content_start, content_end);
|
|
357
363
|
if (trimmed) {
|
|
358
364
|
this.arena.set_value_start_delta(scope_node, trimmed[0] - paren_start);
|
|
359
365
|
this.arena.set_value_length(scope_node, trimmed[1] - trimmed[0]);
|
|
@@ -361,14 +367,13 @@ var AtRulePreludeParser = class {
|
|
|
361
367
|
nodes.push(scope_node);
|
|
362
368
|
} else if (token_type === 1) {
|
|
363
369
|
this.next_token();
|
|
364
|
-
|
|
365
|
-
if (str_equals("to", text)) nodes.push(this.create_node(38, this.lexer.token_start, this.lexer.token_end));
|
|
370
|
+
if (str_equals_range(this.source, this.lexer.token_start, this.lexer.token_end, "to")) nodes.push(this.create_node(38, this.lexer.token_start, this.lexer.token_end));
|
|
366
371
|
} else this.next_token();
|
|
367
372
|
}
|
|
368
373
|
return nodes;
|
|
369
374
|
}
|
|
370
375
|
parse_custom_media_prelude() {
|
|
371
|
-
|
|
376
|
+
const nodes = [];
|
|
372
377
|
this.skip_whitespace();
|
|
373
378
|
if (this.lexer.pos >= this.prelude_end) return [];
|
|
374
379
|
this.next_token();
|