@projectwallace/css-parser 0.19.2 → 0.19.4
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 +15 -2
- package/dist/{arena-CsJhQRUX.js → arena-CaLnNKbP.js} +7 -4
- package/dist/{arena-7RLvyGPB.d.ts → arena-D689Bo6V.d.ts} +4 -3
- package/dist/constants.d.ts +46 -48
- package/dist/constants.js +2 -3
- package/dist/{css-node-BKcf0ZeS.js → css-node-CDTLvxo3.js} +3 -4
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/{node-types-CD7A-d_c.d.ts → node-types-BF6bhAjo.d.ts} +56 -64
- package/dist/node-types.d.ts +1 -1
- package/dist/node-types.js +2 -3
- package/dist/parse-anplusb.d.ts +3 -5
- package/dist/parse-anplusb.js +5 -6
- package/dist/{value-node-parser-B568SwUx.js → parse-atrule-prelude-BMkgCZjw.js} +465 -15
- package/dist/parse-atrule-prelude.d.ts +13 -6
- package/dist/parse-atrule-prelude.js +1 -431
- package/dist/parse-declaration.d.ts +4 -6
- package/dist/parse-declaration.js +8 -9
- package/dist/parse-dimension.d.ts +1 -3
- package/dist/parse-dimension.js +2 -3
- package/dist/{parse-selector-DORsuJvq.js → parse-selector-CMKZgPmu.js} +6 -8
- package/dist/parse-selector.d.ts +3 -5
- package/dist/parse-selector.js +1 -1
- package/dist/parse-value.d.ts +4 -6
- package/dist/parse-value.js +6 -7
- package/dist/parse.d.ts +10 -5
- package/dist/parse.js +9 -10
- package/dist/{string-helpers-t7UofIfp.d.ts → string-helpers-CwNEcEhd.d.ts} +0 -2
- package/dist/string-helpers.d.ts +1 -1
- package/dist/string-helpers.js +1 -1
- package/dist/{string-utils-aEEsA2CS.js → string-utils-BYH1Oe8a.js} +0 -1
- package/dist/{token-types-Bqsf5FX-.d.ts → token-types-BhoXrORA.d.ts} +0 -2
- package/dist/token-types.d.ts +1 -1
- package/dist/token-types.js +1 -2
- package/dist/{tokenize-B2QSzdrM.js → tokenize-DC2Vb0J_.js} +20 -6
- package/dist/tokenize.d.ts +17 -5
- package/dist/tokenize.js +1 -1
- package/dist/walk.d.ts +1 -3
- package/dist/walk.js +3 -4
- package/package.json +3 -3
|
@@ -1,6 +1,5 @@
|
|
|
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-
|
|
2
|
-
|
|
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';
|
|
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-D689Bo6V.js";
|
|
2
|
+
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";
|
|
4
3
|
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;
|
|
5
4
|
interface CloneOptions {
|
|
6
5
|
/**
|
|
@@ -44,8 +43,6 @@ type PlainCSSNode = {
|
|
|
44
43
|
length?: number;
|
|
45
44
|
end?: number;
|
|
46
45
|
};
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/node-types.d.ts
|
|
49
46
|
type CSSNode = {
|
|
50
47
|
readonly type: CSSNodeType;
|
|
51
48
|
readonly type_name: TypeName;
|
|
@@ -95,29 +92,25 @@ interface WithChildren<T = AnyNode> {
|
|
|
95
92
|
* since clone() never serialises them.
|
|
96
93
|
*/
|
|
97
94
|
type ToPlain<T extends CSSNode> = PlainCSSNode & {
|
|
98
|
-
type: T[
|
|
99
|
-
} & { [K in Exclude<keyof T, keyof CSSNode | symbol |
|
|
95
|
+
type: T["type"];
|
|
96
|
+
} & { [K in Exclude<keyof T, keyof CSSNode | symbol | "attr_operator" | "attr_flags" | "has_children" | "child_count" | "children"> as T[K] extends ((...args: any[]) => any) ? never : K]: T[K] extends CSSNode | null | undefined ? PlainCSSNode | Exclude<T[K], CSSNode> : T[K] extends CSSNode[] ? PlainCSSNode[] : T[K]; };
|
|
100
97
|
type StyleSheet = WithClone<CSSNode & WithChildren & {
|
|
101
98
|
readonly type: typeof STYLESHEET;
|
|
102
|
-
readonly type_name:
|
|
99
|
+
readonly type_name: "StyleSheet";
|
|
103
100
|
}>;
|
|
104
|
-
type Rule = WithClone<CSSNode &
|
|
105
|
-
/** SELECTOR_LIST (parse_selectors=true) or RAW (parse_selectors=false) */
|
|
106
|
-
Toggle<'has_prelude', 'prelude', SelectorList | Raw> & Toggle<'has_block', 'block', Block> & {
|
|
101
|
+
type Rule = WithClone<CSSNode & Toggle<"has_prelude", "prelude", SelectorList | Raw> & Toggle<"has_block", "block", Block> & {
|
|
107
102
|
readonly type: typeof STYLE_RULE;
|
|
108
|
-
readonly type_name:
|
|
103
|
+
readonly type_name: "Rule";
|
|
109
104
|
readonly has_declarations: boolean;
|
|
110
105
|
}>;
|
|
111
|
-
type Atrule = WithClone<CSSNode &
|
|
112
|
-
/** AT_RULE_PRELUDE (parse_atrule_preludes=true) or RAW (parse_atrule_preludes=false) */
|
|
113
|
-
Toggle<'has_prelude', 'prelude', AtrulePrelude | Raw> & Toggle<'has_block', 'block', Block> & {
|
|
106
|
+
type Atrule = WithClone<CSSNode & Toggle<"has_prelude", "prelude", AtrulePrelude | Raw> & Toggle<"has_block", "block", Block> & {
|
|
114
107
|
readonly type: typeof AT_RULE;
|
|
115
|
-
readonly type_name:
|
|
108
|
+
readonly type_name: "Atrule";
|
|
116
109
|
/** At-rule keyword, e.g. "media", "keyframes" */
|
|
117
110
|
readonly name: string;
|
|
118
111
|
readonly has_declarations: boolean;
|
|
119
112
|
}>;
|
|
120
|
-
type Declaration = Leaf<typeof DECLARATION,
|
|
113
|
+
type Declaration = Leaf<typeof DECLARATION, "Declaration", {
|
|
121
114
|
/** Property name, e.g. "color" */
|
|
122
115
|
readonly property: string;
|
|
123
116
|
/** VALUE node (parse_values=true), RAW node (parse_values=false), or null */
|
|
@@ -128,82 +121,82 @@ type Declaration = Leaf<typeof DECLARATION, 'Declaration', {
|
|
|
128
121
|
type SelectorNode = TypeSelector | IdSelector | ClassSelector | NthSelector | NthOfSelector | LangSelector | NestingSelector | AttributeSelector | UniversalSelector | PseudoClassSelector | PseudoElementSelector;
|
|
129
122
|
type Selector = WithClone<CSSNode & WithChildren<SelectorNode> & {
|
|
130
123
|
readonly type: typeof SELECTOR;
|
|
131
|
-
readonly type_name:
|
|
124
|
+
readonly type_name: "Selector";
|
|
132
125
|
}>;
|
|
133
126
|
type SelectorList = WithClone<CSSNode & WithChildren<Selector> & {
|
|
134
127
|
readonly type: typeof SELECTOR_LIST;
|
|
135
|
-
readonly type_name:
|
|
128
|
+
readonly type_name: "SelectorList";
|
|
136
129
|
}>;
|
|
137
130
|
/**
|
|
138
131
|
* A direct child of a Block: `Raw | Declaration | Atrule | Rule` with
|
|
139
132
|
* `next_sibling` narrowed to the same union instead of generic `CSSNode`.
|
|
140
133
|
* Safe since none of the four use WithChildren, avoiding TS2589.
|
|
141
134
|
*/
|
|
142
|
-
type BlockChild = (Raw | Declaration | Atrule | Rule) & Toggle<
|
|
135
|
+
type BlockChild = (Raw | Declaration | Atrule | Rule) & Toggle<"has_next", "next_sibling", Raw | Declaration | Atrule | Rule>;
|
|
143
136
|
type Block = WithClone<CSSNode & WithChildren<Raw | Declaration | Atrule | Rule> & {
|
|
144
137
|
readonly type: typeof BLOCK;
|
|
145
|
-
readonly type_name:
|
|
138
|
+
readonly type_name: "Block";
|
|
146
139
|
readonly is_empty: boolean;
|
|
147
140
|
/** Block children with next_sibling narrowed to the Block child union. */
|
|
148
141
|
readonly first_child: BlockChild;
|
|
149
142
|
readonly children: BlockChild[];
|
|
150
143
|
[Symbol.iterator](): Iterator<BlockChild>;
|
|
151
144
|
}>;
|
|
152
|
-
type Comment = Leaf<typeof COMMENT,
|
|
153
|
-
type Raw = Leaf<typeof RAW,
|
|
145
|
+
type Comment = Leaf<typeof COMMENT, "Comment">;
|
|
146
|
+
type Raw = Leaf<typeof RAW, "Raw">;
|
|
154
147
|
type ValueLike = Function | IfBranch | Identifier | Operator | Parenthesis | Url | UnicodeRange | String | Hash | Dimension | Number | Ratio | SelectorList | SupportsDeclaration;
|
|
155
|
-
type Identifier = Leaf<typeof IDENTIFIER,
|
|
148
|
+
type Identifier = Leaf<typeof IDENTIFIER, "Identifier", {
|
|
156
149
|
readonly name: string;
|
|
157
150
|
}>;
|
|
158
|
-
type Number = Leaf<typeof NUMBER,
|
|
151
|
+
type Number = Leaf<typeof NUMBER, "Number", {
|
|
159
152
|
readonly value: number;
|
|
160
153
|
}>;
|
|
161
154
|
/** Ratio value, e.g. "16/9" in `aspect-ratio: 16/9`. A bare number like `aspect-ratio: 1` parses as a plain Number instead. */
|
|
162
|
-
type Ratio = Leaf<typeof RATIO,
|
|
155
|
+
type Ratio = Leaf<typeof RATIO, "Ratio", {
|
|
163
156
|
readonly left: Number;
|
|
164
157
|
readonly right: Number;
|
|
165
158
|
}>;
|
|
166
|
-
type Dimension = Leaf<typeof DIMENSION,
|
|
159
|
+
type Dimension = Leaf<typeof DIMENSION, "Dimension", {
|
|
167
160
|
readonly value: number;
|
|
168
161
|
/** Unit string, e.g. "px", "%" */
|
|
169
162
|
readonly unit: string;
|
|
170
163
|
}>;
|
|
171
|
-
type String = Leaf<typeof STRING,
|
|
172
|
-
type Hash = Leaf<typeof HASH,
|
|
173
|
-
type Function = WithClone<CSSNode & WithChildren<ValueLike | MediaFeature | SupportsDeclaration | SupportsQuery | LayerName | FeatureRange | PreludeOperator> & {
|
|
164
|
+
type String = Leaf<typeof STRING, "String">;
|
|
165
|
+
type Hash = Leaf<typeof HASH, "Hash">;
|
|
166
|
+
type Function = WithClone<CSSNode & WithChildren<ValueLike | MediaFeature | MediaQuery | SupportsDeclaration | SupportsQuery | LayerName | FeatureRange | PreludeOperator> & {
|
|
174
167
|
readonly type: typeof FUNCTION;
|
|
175
|
-
readonly type_name:
|
|
168
|
+
readonly type_name: "Function";
|
|
176
169
|
/** Function name, e.g. "rgb", "calc" */
|
|
177
170
|
readonly name: string;
|
|
178
171
|
/** Function arguments as raw text, e.g. "255, 0, 0" for rgb(255, 0, 0) */
|
|
179
172
|
readonly value: string | null;
|
|
180
173
|
}>;
|
|
181
|
-
type Operator = Leaf<typeof OPERATOR,
|
|
174
|
+
type Operator = Leaf<typeof OPERATOR, "Operator", {
|
|
182
175
|
/** The operator character(s), e.g. ",", "+", "-" */
|
|
183
176
|
readonly value: string;
|
|
184
177
|
}>;
|
|
185
178
|
type Parenthesis = WithClone<CSSNode & WithChildren & {
|
|
186
179
|
readonly type: typeof PARENTHESIS;
|
|
187
|
-
readonly type_name:
|
|
180
|
+
readonly type_name: "Parentheses";
|
|
188
181
|
}>;
|
|
189
|
-
type Url = Leaf<typeof URL,
|
|
182
|
+
type Url = Leaf<typeof URL, "Url", {
|
|
190
183
|
/** URL content, e.g. '"image.png"' (with quotes) or 'mycursor.cur' (unquoted) */
|
|
191
184
|
readonly value: string | null;
|
|
192
185
|
}>;
|
|
193
|
-
type UnicodeRange = Leaf<typeof UNICODE_RANGE,
|
|
186
|
+
type UnicodeRange = Leaf<typeof UNICODE_RANGE, "UnicodeRange">;
|
|
194
187
|
type Value = WithClone<CSSNode & WithChildren<ValueLike> & {
|
|
195
188
|
readonly type: typeof VALUE;
|
|
196
|
-
readonly type_name:
|
|
189
|
+
readonly type_name: "Value";
|
|
197
190
|
}>;
|
|
198
191
|
/** Compound `if()` condition: a flat sequence of `not`/`and`/`or` operators and `style()`/`media()`/`supports()` functions, e.g. `not style(--a: 1)`. */
|
|
199
192
|
type IfCondition = WithClone<CSSNode & WithChildren<Function | PreludeOperator> & {
|
|
200
193
|
readonly type: typeof IF_CONDITION;
|
|
201
|
-
readonly type_name:
|
|
194
|
+
readonly type_name: "IfCondition";
|
|
202
195
|
}>;
|
|
203
196
|
/** A `<condition>: <value>` branch of an `if()` function. `children` is the condition followed by the parsed value nodes. */
|
|
204
197
|
type IfBranch = CSSNode & WithChildren<Function | Identifier | IfCondition | Value> & {
|
|
205
198
|
readonly type: typeof IF_BRANCH;
|
|
206
|
-
readonly type_name:
|
|
199
|
+
readonly type_name: "IfBranch";
|
|
207
200
|
/** Function (`style(--x: 1)`), Identifier (`else`) or IfCondition */
|
|
208
201
|
readonly condition: Function | Identifier | IfCondition;
|
|
209
202
|
/** Branch value, or null when empty */
|
|
@@ -211,21 +204,21 @@ type IfBranch = CSSNode & WithChildren<Function | Identifier | IfCondition | Val
|
|
|
211
204
|
readonly is_else: boolean;
|
|
212
205
|
clone(options?: CloneOptions): ToPlain<IfBranch>;
|
|
213
206
|
};
|
|
214
|
-
type TypeSelector = Leaf<typeof TYPE_SELECTOR,
|
|
207
|
+
type TypeSelector = Leaf<typeof TYPE_SELECTOR, "TypeSelector", {
|
|
215
208
|
/** Local element name, e.g. "div" in both "div" and "ns|div" */
|
|
216
209
|
readonly name: string;
|
|
217
210
|
/** Namespace prefix: null if no qualifier, '' for |div, 'ns' for ns|div, '*' for *|div */
|
|
218
211
|
readonly namespace: string | null;
|
|
219
212
|
}>;
|
|
220
|
-
type ClassSelector = Leaf<typeof CLASS_SELECTOR,
|
|
213
|
+
type ClassSelector = Leaf<typeof CLASS_SELECTOR, "ClassSelector", {
|
|
221
214
|
/** Class name without dot, e.g. "foo" from ".foo" */
|
|
222
215
|
readonly name: string;
|
|
223
216
|
}>;
|
|
224
|
-
type IdSelector = Leaf<typeof ID_SELECTOR,
|
|
217
|
+
type IdSelector = Leaf<typeof ID_SELECTOR, "IdSelector", {
|
|
225
218
|
/** Id without hash, e.g. "bar" from "#bar" */
|
|
226
219
|
readonly name: string;
|
|
227
220
|
}>;
|
|
228
|
-
type AttributeSelector = Leaf<typeof ATTRIBUTE_SELECTOR,
|
|
221
|
+
type AttributeSelector = Leaf<typeof ATTRIBUTE_SELECTOR, "AttributeSelector", {
|
|
229
222
|
/** Attribute name, e.g. "href" from "[href]" */
|
|
230
223
|
readonly name: string;
|
|
231
224
|
/** Operator string, e.g. "=", "~=", "|="; null if no operator ([attr] form) */
|
|
@@ -237,82 +230,82 @@ type AttributeSelector = Leaf<typeof ATTRIBUTE_SELECTOR, 'AttributeSelector', {
|
|
|
237
230
|
}>;
|
|
238
231
|
type PseudoClassSelector = WithClone<CSSNode & WithChildren<Selector | NthOfSelector> & {
|
|
239
232
|
readonly type: typeof PSEUDO_CLASS_SELECTOR;
|
|
240
|
-
readonly type_name:
|
|
233
|
+
readonly type_name: "PseudoClassSelector";
|
|
241
234
|
/** Pseudo-class name without colon, e.g. "hover" */
|
|
242
235
|
readonly name: string;
|
|
243
236
|
}>;
|
|
244
237
|
type PseudoElementSelector = WithClone<CSSNode & WithChildren<SelectorList> & {
|
|
245
238
|
readonly type: typeof PSEUDO_ELEMENT_SELECTOR;
|
|
246
|
-
readonly type_name:
|
|
239
|
+
readonly type_name: "PseudoElementSelector";
|
|
247
240
|
/** Pseudo-element name without colons, e.g. "before" */
|
|
248
241
|
readonly name: string;
|
|
249
242
|
}>;
|
|
250
|
-
type Combinator = Leaf<typeof COMBINATOR,
|
|
243
|
+
type Combinator = Leaf<typeof COMBINATOR, "Combinator", {
|
|
251
244
|
/** Combinator character(s), e.g. " ", ">", "~", "+", "||", "/deep/" */
|
|
252
245
|
readonly name: string;
|
|
253
246
|
}>;
|
|
254
|
-
type UniversalSelector = Leaf<typeof UNIVERSAL_SELECTOR,
|
|
247
|
+
type UniversalSelector = Leaf<typeof UNIVERSAL_SELECTOR, "UniversalSelector", {
|
|
255
248
|
/** Always null — universal selector has no element name */
|
|
256
249
|
readonly name: null;
|
|
257
250
|
/** Namespace prefix: null if no qualifier, '' for |*, 'ns' for ns|*, '*' for *|* */
|
|
258
251
|
readonly namespace: string | null;
|
|
259
252
|
}>;
|
|
260
|
-
type NestingSelector = Leaf<typeof NESTING_SELECTOR,
|
|
261
|
-
type NthSelector = Leaf<typeof NTH_SELECTOR,
|
|
253
|
+
type NestingSelector = Leaf<typeof NESTING_SELECTOR, "NestingSelector">;
|
|
254
|
+
type NthSelector = Leaf<typeof NTH_SELECTOR, "Nth", {
|
|
262
255
|
/** The `An` part of the An+B formula, including keywords `odd`/`even`. Null when only a B value is present (e.g. `:nth-child(3)`). */
|
|
263
256
|
readonly nth_a: string | null;
|
|
264
257
|
/** The `+B` part of the An+B formula. Null when only an A value is present (e.g. `:nth-child(2n)` or `:nth-child(odd)`). */
|
|
265
258
|
readonly nth_b: string | null;
|
|
266
259
|
}>;
|
|
267
|
-
type NthOfSelector = Leaf<typeof NTH_OF_SELECTOR,
|
|
260
|
+
type NthOfSelector = Leaf<typeof NTH_OF_SELECTOR, "NthOf", {
|
|
268
261
|
/** The An+B formula node */
|
|
269
262
|
readonly nth: NthSelector | null;
|
|
270
263
|
/** The selector list from :nth-child(An+B of <selector>) */
|
|
271
264
|
readonly selector: SelectorList | null;
|
|
272
265
|
}>;
|
|
273
|
-
type LangSelector = Leaf<typeof LANG_SELECTOR,
|
|
266
|
+
type LangSelector = Leaf<typeof LANG_SELECTOR, "Lang", {
|
|
274
267
|
/** `"nl"`, `en-US` */
|
|
275
268
|
readonly name: string | null;
|
|
276
269
|
}>;
|
|
277
270
|
type AtrulePrelude = WithClone<CSSNode & WithChildren<Raw | MediaQuery | MediaType | ContainerQuery | SupportsQuery | LayerName | PreludeOperator | PreludeSelectorList | Parenthesis | Url | Function | Identifier | String> & {
|
|
278
271
|
readonly type: typeof AT_RULE_PRELUDE;
|
|
279
|
-
readonly type_name:
|
|
272
|
+
readonly type_name: "AtrulePrelude";
|
|
280
273
|
}>;
|
|
281
274
|
type MediaQuery = WithClone<CSSNode & WithChildren<MediaFeature | PreludeOperator | MediaType | FeatureRange> & {
|
|
282
275
|
readonly type: typeof MEDIA_QUERY;
|
|
283
|
-
readonly type_name:
|
|
276
|
+
readonly type_name: "MediaQuery";
|
|
284
277
|
}>;
|
|
285
278
|
type MediaFeature = WithClone<CSSNode & WithChildren<Identifier | Number | Dimension | Ratio> & {
|
|
286
279
|
readonly type: typeof MEDIA_FEATURE;
|
|
287
|
-
readonly type_name:
|
|
280
|
+
readonly type_name: "Feature";
|
|
288
281
|
/** Feature name, e.g. "min-width" */
|
|
289
282
|
readonly property: string;
|
|
290
283
|
/** Feature value node (Dimension, Number, Identifier or Ratio), or null for boolean features like (hover). Hacks like `0\0` add further children after it. */
|
|
291
284
|
readonly value: Identifier | Number | Dimension | Ratio | null;
|
|
292
285
|
}>;
|
|
293
|
-
type MediaType = Leaf<typeof MEDIA_TYPE,
|
|
286
|
+
type MediaType = Leaf<typeof MEDIA_TYPE, "MediaType", {
|
|
294
287
|
/** Media type text, e.g. "screen", "print" */
|
|
295
288
|
readonly value: string;
|
|
296
289
|
}>;
|
|
297
290
|
type ContainerQuery = WithClone<CSSNode & WithChildren<Identifier | MediaFeature | Function | PreludeOperator> & {
|
|
298
291
|
readonly type: typeof CONTAINER_QUERY;
|
|
299
|
-
readonly type_name:
|
|
292
|
+
readonly type_name: "ContainerQuery";
|
|
300
293
|
}>;
|
|
301
294
|
type SupportsQuery = WithClone<CSSNode & WithChildren<SupportsDeclaration | SupportsQuery | PreludeOperator | Function> & {
|
|
302
295
|
readonly type: typeof SUPPORTS_QUERY;
|
|
303
|
-
readonly type_name:
|
|
296
|
+
readonly type_name: "SupportsQuery";
|
|
304
297
|
/** The supports condition text, e.g. "display: flex" from "supports(display: flex)" */
|
|
305
298
|
readonly value: string;
|
|
306
299
|
}>;
|
|
307
300
|
type SupportsDeclaration = WithClone<CSSNode & WithChildren<Declaration> & {
|
|
308
301
|
readonly type: typeof SUPPORTS_DECLARATION;
|
|
309
|
-
readonly type_name:
|
|
302
|
+
readonly type_name: "SupportsDeclaration";
|
|
310
303
|
/** Property name, e.g. "display" from "(display: flex)" */
|
|
311
304
|
readonly property: string;
|
|
312
305
|
/** VALUE node for the declaration's value, e.g. "flex" from "(display: flex)" */
|
|
313
306
|
readonly value: Value | null;
|
|
314
307
|
}>;
|
|
315
|
-
type LayerName = Leaf<typeof LAYER_NAME,
|
|
308
|
+
type LayerName = Leaf<typeof LAYER_NAME, "Layer", {
|
|
316
309
|
readonly name: string;
|
|
317
310
|
/** Alias for name — the layer name string, e.g. "base" from "layer(base)" */
|
|
318
311
|
readonly value: string;
|
|
@@ -327,17 +320,17 @@ type LayerName = Leaf<typeof LAYER_NAME, 'Layer', {
|
|
|
327
320
|
*/
|
|
328
321
|
type PreludeSelectorList = WithClone<CSSNode & WithChildren<SelectorList> & {
|
|
329
322
|
readonly type: typeof PRELUDE_SELECTORLIST;
|
|
330
|
-
readonly type_name:
|
|
323
|
+
readonly type_name: "PreludeSelectorList";
|
|
331
324
|
readonly value: string;
|
|
332
325
|
}>;
|
|
333
|
-
type PreludeOperator = Leaf<typeof PRELUDE_OPERATOR,
|
|
326
|
+
type PreludeOperator = Leaf<typeof PRELUDE_OPERATOR, "Operator", {
|
|
334
327
|
/** The operator keyword or range comparator, e.g. "and", "or", "not", "only", "to", "<", "<=", ">", ">=", "=" */
|
|
335
328
|
readonly value: string;
|
|
336
329
|
}>;
|
|
337
|
-
type FeatureRange = WithClone<CSSNode & WithChildren<Dimension | Function | PreludeOperator> & {
|
|
330
|
+
type FeatureRange = WithClone<CSSNode & WithChildren<Dimension | Function | Identifier | PreludeOperator> & {
|
|
338
331
|
readonly type: typeof FEATURE_RANGE;
|
|
339
|
-
readonly type_name:
|
|
340
|
-
/** The feature name in a range comparison, e.g. "width" from "(width >= 400px)" */
|
|
332
|
+
readonly type_name: "MediaFeatureRange";
|
|
333
|
+
/** The feature name in a range comparison, e.g. "width" from "(width >= 400px)". Also present as an Identifier child, in source order. */
|
|
341
334
|
readonly name: string;
|
|
342
335
|
}>;
|
|
343
336
|
type AnyNode = StyleSheet | Rule | Atrule | Declaration | Selector | SelectorList | Block | Comment | Raw | Identifier | Number | Dimension | Ratio | String | Hash | Function | Operator | Parenthesis | Url | UnicodeRange | IfBranch | IfCondition | Value | TypeSelector | ClassSelector | IdSelector | AttributeSelector | PseudoClassSelector | PseudoElementSelector | Combinator | UniversalSelector | NestingSelector | NthSelector | NthOfSelector | LangSelector | AtrulePrelude | MediaQuery | MediaFeature | MediaType | ContainerQuery | SupportsQuery | SupportsDeclaration | LayerName | PreludeOperator | FeatureRange | PreludeSelectorList;
|
|
@@ -387,5 +380,4 @@ declare function is_prelude_operator(node: CSSNode): node is PreludeOperator;
|
|
|
387
380
|
declare function is_feature_range(node: CSSNode): node is FeatureRange;
|
|
388
381
|
declare function is_ratio(node: CSSNode): node is Ratio;
|
|
389
382
|
declare function is_prelude_selectorlist(node: CSSNode): node is PreludeSelectorList;
|
|
390
|
-
//#endregion
|
|
391
383
|
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 };
|
package/dist/node-types.d.ts
CHANGED
|
@@ -1,2 +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-
|
|
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-BF6bhAjo.js";
|
|
2
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 };
|
package/dist/node-types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./arena-
|
|
2
|
-
|
|
1
|
+
import "./arena-CaLnNKbP.js";
|
|
2
|
+
// src/node-types.ts
|
|
3
3
|
function is_stylesheet(node) {
|
|
4
4
|
return node.type === 1;
|
|
5
5
|
}
|
|
@@ -138,5 +138,4 @@ function is_ratio(node) {
|
|
|
138
138
|
function is_prelude_selectorlist(node) {
|
|
139
139
|
return node.type === 41;
|
|
140
140
|
}
|
|
141
|
-
//#endregion
|
|
142
141
|
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,6 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { O as NthSelector } from "./node-types-
|
|
3
|
-
//#region src/parse-anplusb.d.ts
|
|
1
|
+
import { l as CSSDataArena } from "./arena-D689Bo6V.js";
|
|
2
|
+
import { O as NthSelector } from "./node-types-BF6bhAjo.js";
|
|
4
3
|
/** @internal */
|
|
5
4
|
export declare class ANplusBParser {
|
|
6
5
|
private lexer;
|
|
@@ -13,5 +12,4 @@ export declare class ANplusBParser {
|
|
|
13
12
|
private skip_whitespace;
|
|
14
13
|
private create_anplusb_node;
|
|
15
14
|
}
|
|
16
|
-
export declare function parse_anplusb(expr: string): NthSelector | null;
|
|
17
|
-
//#endregion
|
|
15
|
+
export declare function parse_anplusb(expr: string): NthSelector | null;
|
package/dist/parse-anplusb.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as Lexer } from "./tokenize-
|
|
1
|
+
import { t as Lexer } from "./tokenize-DC2Vb0J_.js";
|
|
2
2
|
import "./token-types.js";
|
|
3
|
-
import { l as CSSDataArena } from "./arena-
|
|
4
|
-
import { l as str_index_of, s as str_equals } from "./string-utils-
|
|
5
|
-
import { t as CSSNode } from "./css-node-
|
|
6
|
-
|
|
3
|
+
import { l as CSSDataArena } from "./arena-CaLnNKbP.js";
|
|
4
|
+
import { l as str_index_of, s as str_equals } from "./string-utils-BYH1Oe8a.js";
|
|
5
|
+
import { t as CSSNode } from "./css-node-CDTLvxo3.js";
|
|
6
|
+
// src/parse-anplusb.ts
|
|
7
7
|
/** @internal */
|
|
8
8
|
var ANplusBParser = class {
|
|
9
9
|
lexer;
|
|
@@ -184,5 +184,4 @@ function parse_anplusb(expr) {
|
|
|
184
184
|
if (nodeIndex === null) return null;
|
|
185
185
|
return new CSSNode(arena, expr, nodeIndex);
|
|
186
186
|
}
|
|
187
|
-
//#endregion
|
|
188
187
|
export { ANplusBParser, parse_anplusb };
|