@projectwallace/css-parser 0.18.1 → 0.18.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/dist/{arena-CFwM4uQs.js → arena-C-ZXJe7F.js} +2 -1
- package/dist/{arena-Bx5vp6Sl.d.ts → arena-C-uRgG5-.d.ts} +2 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +4 -3
- package/dist/{css-node-Cf8K9nWd.js → css-node-Briho45Z.js} +21 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -4
- package/dist/{node-types-D41wr72y.d.ts → node-types-Dh1wEDRK.d.ts} +15 -6
- package/dist/parse-anplusb.d.ts +2 -2
- package/dist/parse-anplusb.js +3 -3
- package/dist/parse-atrule-prelude.d.ts +4 -2
- package/dist/parse-atrule-prelude.js +59 -84
- package/dist/parse-declaration.d.ts +3 -3
- package/dist/parse-declaration.js +56 -22
- package/dist/parse-selector.d.ts +2 -3
- package/dist/parse-selector.js +15 -34
- package/dist/parse-value.d.ts +2 -2
- package/dist/parse-value.js +5 -4
- package/dist/parse.d.ts +4 -3
- package/dist/parse.js +34 -60
- package/dist/{tokenize-DeZYFa9R.d.ts → tokenize-CDEnYcVG.d.ts} +22 -0
- package/dist/{tokenize-BiRLfVbm.js → tokenize-DK24ACbY.js} +236 -103
- package/dist/tokenize.d.ts +1 -1
- package/dist/tokenize.js +1 -1
- package/dist/{value-node-parser-CZ47v3hp.js → value-node-parser-B0WfJCvC.js} +3 -6
- package/dist/walk.d.ts +1 -1
- package/dist/walk.js +5 -31
- package/package.json +3 -3
|
@@ -41,6 +41,7 @@ const PRELUDE_OPERATOR = 38;
|
|
|
41
41
|
const FEATURE_RANGE = 39;
|
|
42
42
|
const AT_RULE_PRELUDE = 40;
|
|
43
43
|
const SUPPORTS_DECLARATION = 57;
|
|
44
|
+
const RATIO = 58;
|
|
44
45
|
const VALUE = 50;
|
|
45
46
|
const FLAG_IMPORTANT = 1;
|
|
46
47
|
/** @internal */
|
|
@@ -216,4 +217,4 @@ var CSSDataArena = class CSSDataArena {
|
|
|
216
217
|
}
|
|
217
218
|
};
|
|
218
219
|
//#endregion
|
|
219
|
-
export { PSEUDO_CLASS_SELECTOR as A,
|
|
220
|
+
export { PSEUDO_CLASS_SELECTOR as A, SUPPORTS_QUERY as B, NESTING_SELECTOR as C, OPERATOR as D, NUMBER as E, SELECTOR_LIST as F, VALUE as G, UNICODE_RANGE as H, STRING as I, STYLESHEET as L, RATIO as M, RAW as N, PARENTHESIS as O, SELECTOR as P, STYLE_RULE as R, MEDIA_TYPE as S, NTH_SELECTOR as T, UNIVERSAL_SELECTOR as U, TYPE_SELECTOR as V, URL as W, ID_SELECTOR as _, CLASS_SELECTOR as a, MEDIA_FEATURE as b, CONTAINER_QUERY as c, DIMENSION as d, FEATURE_RANGE as f, IDENTIFIER as g, HASH as h, BLOCK as i, PSEUDO_ELEMENT_SELECTOR as j, PRELUDE_OPERATOR as k, CSSDataArena as l, FUNCTION as m, AT_RULE as n, COMBINATOR as o, FLAG_IMPORTANT as p, AT_RULE_PRELUDE as r, COMMENT as s, ATTRIBUTE_SELECTOR as t, DECLARATION as u, LANG_SELECTOR as v, NTH_OF_SELECTOR as w, MEDIA_QUERY as x, LAYER_NAME as y, SUPPORTS_DECLARATION as z };
|
|
@@ -41,6 +41,7 @@ declare const FEATURE_RANGE = 39;
|
|
|
41
41
|
declare const AT_RULE_PRELUDE = 40;
|
|
42
42
|
declare const PRELUDE_SELECTORLIST = 41;
|
|
43
43
|
declare const SUPPORTS_DECLARATION = 57;
|
|
44
|
+
declare const RATIO = 58;
|
|
44
45
|
declare const VALUE = 50;
|
|
45
46
|
declare const FLAG_IMPORTANT: number;
|
|
46
47
|
/** @internal */
|
|
@@ -94,4 +95,4 @@ declare class CSSDataArena {
|
|
|
94
95
|
has_flag(node_index: number, flag: number): boolean;
|
|
95
96
|
}
|
|
96
97
|
//#endregion
|
|
97
|
-
export { PRELUDE_SELECTORLIST as A,
|
|
98
|
+
export { PRELUDE_SELECTORLIST as A, SUPPORTS_DECLARATION as B, NESTING_SELECTOR as C, OPERATOR as D, NUMBER as E, SELECTOR as F, URL as G, TYPE_SELECTOR as H, SELECTOR_LIST as I, VALUE as K, STRING as L, PSEUDO_ELEMENT_SELECTOR as M, RATIO as N, PARENTHESIS as O, RAW as P, STYLESHEET as R, MEDIA_TYPE as S, NTH_SELECTOR as T, UNICODE_RANGE as U, SUPPORTS_QUERY as V, UNIVERSAL_SELECTOR as W, ID_SELECTOR as _, CLASS_SELECTOR as a, MEDIA_FEATURE as b, CONTAINER_QUERY as c, DIMENSION as d, FEATURE_RANGE as f, IDENTIFIER as g, HASH as h, BLOCK as i, PSEUDO_CLASS_SELECTOR as j, PRELUDE_OPERATOR as k, CSSDataArena as l, FUNCTION as m, AT_RULE as n, COMBINATOR as o, FLAG_IMPORTANT as p, AT_RULE_PRELUDE as r, COMMENT as s, ATTRIBUTE_SELECTOR as t, DECLARATION as u, LANG_SELECTOR as v, NTH_OF_SELECTOR as w, MEDIA_QUERY as x, LAYER_NAME as y, STYLE_RULE as z };
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as
|
|
1
|
+
import { B as SUPPORTS_DECLARATION, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as SELECTOR, G as URL, H as TYPE_SELECTOR, I as SELECTOR_LIST, K as VALUE, L as STRING, M as PSEUDO_ELEMENT_SELECTOR, N as RATIO, O as PARENTHESIS, P as RAW, R as STYLESHEET, S as MEDIA_TYPE, T as NTH_SELECTOR, U as UNICODE_RANGE, V as SUPPORTS_QUERY, W as UNIVERSAL_SELECTOR, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_CLASS_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as STYLE_RULE } from "./arena-C-uRgG5-.js";
|
|
2
2
|
//#region src/constants.d.ts
|
|
3
3
|
declare const NODE_TYPES: {
|
|
4
4
|
readonly STYLESHEET: 1;
|
|
@@ -43,6 +43,7 @@ declare const NODE_TYPES: {
|
|
|
43
43
|
readonly PRELUDE_OPERATOR: 38;
|
|
44
44
|
readonly FEATURE_RANGE: 39;
|
|
45
45
|
readonly AT_RULE_PRELUDE: 40;
|
|
46
|
+
readonly RATIO: 58;
|
|
46
47
|
};
|
|
47
48
|
//#endregion
|
|
48
|
-
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE };
|
|
49
|
+
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RATIO, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE };
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as PSEUDO_CLASS_SELECTOR, B as
|
|
1
|
+
import { A as PSEUDO_CLASS_SELECTOR, B as SUPPORTS_QUERY, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as SELECTOR_LIST, G as VALUE, H as UNICODE_RANGE, I as STRING, L as STYLESHEET, M as RATIO, N as RAW, O as PARENTHESIS, P as SELECTOR, R as STYLE_RULE, S as MEDIA_TYPE, T as NTH_SELECTOR, U as UNIVERSAL_SELECTOR, V as TYPE_SELECTOR, W as URL, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_ELEMENT_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_DECLARATION } from "./arena-C-ZXJe7F.js";
|
|
2
2
|
//#region src/constants.ts
|
|
3
3
|
const NODE_TYPES = {
|
|
4
4
|
STYLESHEET: 1,
|
|
@@ -42,7 +42,8 @@ const NODE_TYPES = {
|
|
|
42
42
|
LAYER_NAME: 37,
|
|
43
43
|
PRELUDE_OPERATOR: 38,
|
|
44
44
|
FEATURE_RANGE: 39,
|
|
45
|
-
AT_RULE_PRELUDE: 40
|
|
45
|
+
AT_RULE_PRELUDE: 40,
|
|
46
|
+
RATIO: 58
|
|
46
47
|
};
|
|
47
48
|
//#endregion
|
|
48
|
-
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE };
|
|
49
|
+
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RATIO, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./arena-
|
|
1
|
+
import "./arena-C-ZXJe7F.js";
|
|
2
2
|
import { a as is_whitespace, c as str_starts_with, i as is_vendor_prefixed, t as parse_dimension } from "./parse-dimension-ouWXNHdx.js";
|
|
3
3
|
//#region src/css-node.ts
|
|
4
4
|
const TYPE_NAMES = {
|
|
@@ -44,7 +44,8 @@ const TYPE_NAMES = {
|
|
|
44
44
|
[38]: "Operator",
|
|
45
45
|
[39]: "MediaFeatureRange",
|
|
46
46
|
[40]: "AtrulePrelude",
|
|
47
|
-
[41]: "PreludeSelectorList"
|
|
47
|
+
[41]: "PreludeSelectorList",
|
|
48
|
+
[58]: "Ratio"
|
|
48
49
|
};
|
|
49
50
|
const nodes_with_name = /* @__PURE__ */ new Set([
|
|
50
51
|
3,
|
|
@@ -94,7 +95,9 @@ const enumerable_properties = [
|
|
|
94
95
|
"is_browserhack",
|
|
95
96
|
"is_vendor_prefixed",
|
|
96
97
|
"has_error",
|
|
97
|
-
"is_important"
|
|
98
|
+
"is_important",
|
|
99
|
+
"left",
|
|
100
|
+
"right"
|
|
98
101
|
];
|
|
99
102
|
var CSSNode = class CSSNode {
|
|
100
103
|
arena;
|
|
@@ -238,6 +241,16 @@ var CSSNode = class CSSNode {
|
|
|
238
241
|
if (this.type !== 12) return void 0;
|
|
239
242
|
return parse_dimension(this.text).unit;
|
|
240
243
|
}
|
|
244
|
+
/** Numerator for ratio values, e.g. the Number "16" in `aspect-ratio: 16/9` */
|
|
245
|
+
get left() {
|
|
246
|
+
if (this.type !== 58) return void 0;
|
|
247
|
+
return this.first_child ?? void 0;
|
|
248
|
+
}
|
|
249
|
+
/** Denominator for ratio values, e.g. the Number "9" in `aspect-ratio: 16/9` */
|
|
250
|
+
get right() {
|
|
251
|
+
if (this.type !== 58) return void 0;
|
|
252
|
+
return this.first_child?.next_sibling ?? void 0;
|
|
253
|
+
}
|
|
241
254
|
/** Check if this declaration has !important */
|
|
242
255
|
get is_important() {
|
|
243
256
|
if (this.type !== 4) return void 0;
|
|
@@ -441,7 +454,11 @@ var CSSNode = class CSSNode {
|
|
|
441
454
|
};
|
|
442
455
|
for (let key of enumerable_properties) {
|
|
443
456
|
let val = this[key];
|
|
444
|
-
if (val
|
|
457
|
+
if (val instanceof CSSNode) plain[key] = val.clone({
|
|
458
|
+
deep,
|
|
459
|
+
locations
|
|
460
|
+
});
|
|
461
|
+
else if (val !== void 0 && val !== false) plain[key] = val;
|
|
445
462
|
}
|
|
446
463
|
if (locations) {
|
|
447
464
|
plain.line = this.line;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { B as
|
|
1
|
+
import { B as SUPPORTS_DECLARATION, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as SELECTOR, G as URL, H as TYPE_SELECTOR, I as SELECTOR_LIST, K as VALUE, L as STRING, M as PSEUDO_ELEMENT_SELECTOR, N as RATIO, O as PARENTHESIS, P as RAW, R as STYLESHEET, S as MEDIA_TYPE, T as NTH_SELECTOR, U as UNICODE_RANGE, V as SUPPORTS_QUERY, W as UNIVERSAL_SELECTOR, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_CLASS_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as STYLE_RULE } from "./arena-C-uRgG5-.js";
|
|
2
2
|
import { NODE_TYPES } from "./constants.js";
|
|
3
|
-
import { A as TOKEN_URL, C as TOKEN_PERCENTAGE, D as TOKEN_SEMICOLON, E as TOKEN_RIGHT_PAREN, M as Token, N as TokenType, O as TOKEN_STRING, S as TOKEN_NUMBER, T as TOKEN_RIGHT_BRACKET, _ as TOKEN_HASH, a as TOKEN_AT_KEYWORD, b as TOKEN_LEFT_BRACKET, c as TOKEN_CDC, d as TOKEN_COMMA, f as TOKEN_COMMENT, g as TOKEN_FUNCTION, h as TOKEN_EOF, i as tokenize, j as TOKEN_WHITESPACE, k as TOKEN_UNICODE_RANGE, l as TOKEN_CDO, m as TOKEN_DIMENSION, o as TOKEN_BAD_STRING, p as TOKEN_DELIM, r as LexerPosition, s as TOKEN_BAD_URL, t as CommentInfo, u as TOKEN_COLON, v as TOKEN_IDENT, w as TOKEN_RIGHT_BRACE, x as TOKEN_LEFT_PAREN, y as TOKEN_LEFT_BRACE } from "./tokenize-
|
|
4
|
-
import { $ as
|
|
3
|
+
import { A as TOKEN_URL, C as TOKEN_PERCENTAGE, D as TOKEN_SEMICOLON, E as TOKEN_RIGHT_PAREN, M as Token, N as TokenType, O as TOKEN_STRING, S as TOKEN_NUMBER, T as TOKEN_RIGHT_BRACKET, _ as TOKEN_HASH, a as TOKEN_AT_KEYWORD, b as TOKEN_LEFT_BRACKET, c as TOKEN_CDC, d as TOKEN_COMMA, f as TOKEN_COMMENT, g as TOKEN_FUNCTION, h as TOKEN_EOF, i as tokenize, j as TOKEN_WHITESPACE, k as TOKEN_UNICODE_RANGE, l as TOKEN_CDO, m as TOKEN_DIMENSION, o as TOKEN_BAD_STRING, p as TOKEN_DELIM, r as LexerPosition, s as TOKEN_BAD_URL, t as CommentInfo, u as TOKEN_COLON, v as TOKEN_IDENT, w as TOKEN_RIGHT_BRACE, x as TOKEN_LEFT_PAREN, y as TOKEN_LEFT_BRACE } from "./tokenize-CDEnYcVG.js";
|
|
4
|
+
import { $ as is_block, A as PreludeSelectorList, At as is_selector_list, B as StyleSheet, Bt as CloneOptions, C as NestingSelector, Ct as is_prelude_selectorlist, D as Operator, Dt as is_raw, E as Number, Et as is_ratio, F as Rule, Ft as is_type_selector, G as UnicodeRange, H as SupportsQuery, Ht as TYPE_NAMES, I as Selector, It as is_unicode_range, J as Value, K as UniversalSelector, L as SelectorList, Lt as is_universal_selector, M as PseudoElementSelector, Mt as is_stylesheet, N as Ratio, Nt as is_supports_declaration, O as Parenthesis, Ot as is_rule, P as Raw, Pt as is_supports_query, Q as is_attribute_selector, R as SelectorNode, Rt as is_url, S as MediaType, St as is_prelude_operator, T as NthSelector, Tt as is_pseudo_element_selector, U as ToPlain, V as SupportsDeclaration, Vt as PlainCSSNode, W as TypeSelector, X as is_atrule, Y as WithChildren, Z as is_atrule_prelude, _ as Identifier, _t as is_nth_of_selector, a as Block, at as is_dimension, b as MediaFeature, bt as is_operator, c as Combinator, ct as is_hash, d as Declaration, dt as is_lang_selector, et as is_class_selector, f as Dimension, ft as is_layer_name, g as IdSelector, gt as is_nesting_selector, h as Hash, ht as is_media_type, i as AttributeSelector, it as is_declaration, j as PseudoClassSelector, jt as is_string, k as PreludeOperator, kt as is_selector, l as Comment, lt as is_id_selector, m as Function, mt as is_media_query, n as Atrule, nt as is_comment, o as CSSNode, ot as is_feature_range, p as FeatureRange, pt as is_media_feature, q as Url, r as AtrulePrelude, rt as is_container_query, s as ClassSelector, st as is_function, t as AnyNode, tt as is_combinator, u as ContainerQuery, ut as is_identifier, v as LangSelector, vt as is_nth_selector, w as NthOfSelector, wt as is_pseudo_class_selector, x as MediaQuery, xt as is_parenthesis, y as LayerName, yt as is_number, z as String, zt as is_value } from "./node-types-Dh1wEDRK.js";
|
|
5
5
|
import { ParserOptions, parse } from "./parse.js";
|
|
6
6
|
import { parse_selector, parse_selector_list } from "./parse-selector.js";
|
|
7
7
|
import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
|
|
@@ -25,4 +25,4 @@ declare function is_vendor_prefixed(source: string, start: number, end: number):
|
|
|
25
25
|
/** True if the string is a CSS custom property (starts with `--`). */
|
|
26
26
|
declare function is_custom(str: string): boolean;
|
|
27
27
|
//#endregion
|
|
28
|
-
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, type AnyNode, type Atrule, type AtrulePrelude, type AttributeSelector, BLOCK, BREAK, type Block, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, type CSSNode, type ClassSelector, type CloneOptions, type Combinator, type Comment, type CommentInfo, type ContainerQuery, DECLARATION, DIMENSION, type Declaration, type Dimension, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, type FeatureRange, type Function, HASH, type Hash, IDENTIFIER, ID_SELECTOR, type IdSelector, type Identifier, LANG_SELECTOR, LAYER_NAME, type LangSelector, type LayerName, type LexerPosition, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, type MediaFeature, type MediaQuery, type MediaType, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, type NestingSelector, type NthOfSelector, type NthSelector, type Number, OPERATOR, type Operator, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, type Parenthesis, type ParserOptions, type PlainCSSNode, type PreludeOperator, type PreludeSelectorList, type PseudoClassSelector, type PseudoElementSelector, RAW, type Raw, type Rule, SELECTOR, SELECTOR_LIST, SKIP, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, type Selector, type SelectorList, type SelectorNode, type String, type StyleSheet, type SupportsDeclaration, type SupportsQuery, TOKEN_AT_KEYWORD, TOKEN_BAD_STRING, TOKEN_BAD_URL, TOKEN_CDC, TOKEN_CDO, TOKEN_COLON, TOKEN_COMMA, TOKEN_COMMENT, TOKEN_DELIM, TOKEN_DIMENSION, TOKEN_EOF, TOKEN_FUNCTION, TOKEN_HASH, TOKEN_IDENT, TOKEN_LEFT_BRACE, TOKEN_LEFT_BRACKET, TOKEN_LEFT_PAREN, TOKEN_NUMBER, TOKEN_PERCENTAGE, TOKEN_RIGHT_BRACE, TOKEN_RIGHT_BRACKET, TOKEN_RIGHT_PAREN, TOKEN_SEMICOLON, TOKEN_STRING, TOKEN_UNICODE_RANGE, TOKEN_URL, TOKEN_WHITESPACE, TYPE_NAMES, TYPE_SELECTOR, type ToPlain, Token, TokenType, type TypeSelector, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, type UnicodeRange, type UniversalSelector, type Url, VALUE, type Value, type WithChildren, is_atrule, is_atrule_prelude, is_attribute_selector, is_block, is_class_selector, is_combinator, is_comment, is_container_query, is_custom, is_declaration, is_dimension, is_feature_range, is_function, is_hash, is_id_selector, is_identifier, 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_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, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_selector_list, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
|
28
|
+
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, type AnyNode, type Atrule, type AtrulePrelude, type AttributeSelector, BLOCK, BREAK, type Block, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, type CSSNode, type ClassSelector, type CloneOptions, type Combinator, type Comment, type CommentInfo, type ContainerQuery, DECLARATION, DIMENSION, type Declaration, type Dimension, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, type FeatureRange, type Function, HASH, type Hash, IDENTIFIER, ID_SELECTOR, type IdSelector, type Identifier, LANG_SELECTOR, LAYER_NAME, type LangSelector, type LayerName, type LexerPosition, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, type MediaFeature, type MediaQuery, type MediaType, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, type NestingSelector, type NthOfSelector, type NthSelector, type Number, OPERATOR, type Operator, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, type Parenthesis, type ParserOptions, type PlainCSSNode, type PreludeOperator, type PreludeSelectorList, type PseudoClassSelector, type PseudoElementSelector, RATIO, RAW, type Ratio, type Raw, type Rule, SELECTOR, SELECTOR_LIST, SKIP, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, type Selector, type SelectorList, type SelectorNode, type String, type StyleSheet, type SupportsDeclaration, type SupportsQuery, TOKEN_AT_KEYWORD, TOKEN_BAD_STRING, TOKEN_BAD_URL, TOKEN_CDC, TOKEN_CDO, TOKEN_COLON, TOKEN_COMMA, TOKEN_COMMENT, TOKEN_DELIM, TOKEN_DIMENSION, TOKEN_EOF, TOKEN_FUNCTION, TOKEN_HASH, TOKEN_IDENT, TOKEN_LEFT_BRACE, TOKEN_LEFT_BRACKET, TOKEN_LEFT_PAREN, TOKEN_NUMBER, TOKEN_PERCENTAGE, TOKEN_RIGHT_BRACE, TOKEN_RIGHT_BRACKET, TOKEN_RIGHT_PAREN, TOKEN_SEMICOLON, TOKEN_STRING, TOKEN_UNICODE_RANGE, TOKEN_URL, TOKEN_WHITESPACE, TYPE_NAMES, TYPE_SELECTOR, type ToPlain, Token, TokenType, type TypeSelector, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, type UnicodeRange, type UniversalSelector, type Url, VALUE, type Value, type WithChildren, is_atrule, is_atrule_prelude, is_attribute_selector, is_block, is_class_selector, is_combinator, is_comment, is_container_query, is_custom, is_declaration, is_dimension, is_feature_range, is_function, is_hash, is_id_selector, is_identifier, 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, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_selector_list, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as TOKEN_RIGHT_BRACKET, D as TOKEN_UNICODE_RANGE, E as TOKEN_STRING, O as TOKEN_URL, S as TOKEN_RIGHT_BRACE, T as TOKEN_SEMICOLON, _ as TOKEN_LEFT_BRACE, a as TOKEN_BAD_URL, b as TOKEN_NUMBER, c as TOKEN_COLON, d as TOKEN_DELIM, f as TOKEN_DIMENSION, g as TOKEN_IDENT, h as TOKEN_HASH, i as TOKEN_BAD_STRING, k as TOKEN_WHITESPACE, l as TOKEN_COMMA, m as TOKEN_FUNCTION, n as tokenize, o as TOKEN_CDC, p as TOKEN_EOF, r as TOKEN_AT_KEYWORD, s as TOKEN_CDO, u as TOKEN_COMMENT, v as TOKEN_LEFT_BRACKET, w as TOKEN_RIGHT_PAREN, x as TOKEN_PERCENTAGE, y as TOKEN_LEFT_PAREN } from "./tokenize-
|
|
2
|
-
import { A as PSEUDO_CLASS_SELECTOR, B as
|
|
1
|
+
import { C as TOKEN_RIGHT_BRACKET, D as TOKEN_UNICODE_RANGE, E as TOKEN_STRING, O as TOKEN_URL, S as TOKEN_RIGHT_BRACE, T as TOKEN_SEMICOLON, _ as TOKEN_LEFT_BRACE, a as TOKEN_BAD_URL, b as TOKEN_NUMBER, c as TOKEN_COLON, d as TOKEN_DELIM, f as TOKEN_DIMENSION, g as TOKEN_IDENT, h as TOKEN_HASH, i as TOKEN_BAD_STRING, k as TOKEN_WHITESPACE, l as TOKEN_COMMA, m as TOKEN_FUNCTION, n as tokenize, o as TOKEN_CDC, p as TOKEN_EOF, r as TOKEN_AT_KEYWORD, s as TOKEN_CDO, u as TOKEN_COMMENT, v as TOKEN_LEFT_BRACKET, w as TOKEN_RIGHT_PAREN, x as TOKEN_PERCENTAGE, y as TOKEN_LEFT_PAREN } from "./tokenize-DK24ACbY.js";
|
|
2
|
+
import { A as PSEUDO_CLASS_SELECTOR, B as SUPPORTS_QUERY, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as SELECTOR_LIST, G as VALUE, H as UNICODE_RANGE, I as STRING, L as STYLESHEET, M as RATIO, N as RAW, O as PARENTHESIS, P as SELECTOR, R as STYLE_RULE, S as MEDIA_TYPE, T as NTH_SELECTOR, U as UNIVERSAL_SELECTOR, V as TYPE_SELECTOR, W as URL, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_ELEMENT_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_DECLARATION } from "./arena-C-ZXJe7F.js";
|
|
3
3
|
import { c as str_starts_with, i as is_vendor_prefixed, o as str_equals, r as is_custom, s as str_index_of, t as parse_dimension } from "./parse-dimension-ouWXNHdx.js";
|
|
4
|
-
import { n as TYPE_NAMES } from "./css-node-
|
|
4
|
+
import { n as TYPE_NAMES } from "./css-node-Briho45Z.js";
|
|
5
5
|
import { parse_selector, parse_selector_list } from "./parse-selector.js";
|
|
6
6
|
import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
|
|
7
7
|
import { parse_value } from "./parse-value.js";
|
|
@@ -136,8 +136,11 @@ function is_prelude_operator(node) {
|
|
|
136
136
|
function is_feature_range(node) {
|
|
137
137
|
return node.type === 39;
|
|
138
138
|
}
|
|
139
|
+
function is_ratio(node) {
|
|
140
|
+
return node.type === 58;
|
|
141
|
+
}
|
|
139
142
|
function is_prelude_selectorlist(node) {
|
|
140
143
|
return node.type === 41;
|
|
141
144
|
}
|
|
142
145
|
//#endregion
|
|
143
|
-
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, BREAK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RAW, SELECTOR, SELECTOR_LIST, SKIP, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TOKEN_AT_KEYWORD, TOKEN_BAD_STRING, TOKEN_BAD_URL, TOKEN_CDC, TOKEN_CDO, TOKEN_COLON, TOKEN_COMMA, TOKEN_COMMENT, TOKEN_DELIM, TOKEN_DIMENSION, TOKEN_EOF, TOKEN_FUNCTION, TOKEN_HASH, TOKEN_IDENT, TOKEN_LEFT_BRACE, TOKEN_LEFT_BRACKET, TOKEN_LEFT_PAREN, TOKEN_NUMBER, TOKEN_PERCENTAGE, TOKEN_RIGHT_BRACE, TOKEN_RIGHT_BRACKET, TOKEN_RIGHT_PAREN, TOKEN_SEMICOLON, TOKEN_STRING, TOKEN_UNICODE_RANGE, TOKEN_URL, TOKEN_WHITESPACE, TYPE_NAMES, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE, is_atrule, is_atrule_prelude, is_attribute_selector, is_block, is_class_selector, is_combinator, is_comment, is_container_query, is_custom, is_declaration, is_dimension, is_feature_range, is_function, is_hash, is_id_selector, is_identifier, 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_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, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_selector_list, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
|
146
|
+
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, BREAK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RATIO, RAW, SELECTOR, SELECTOR_LIST, SKIP, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TOKEN_AT_KEYWORD, TOKEN_BAD_STRING, TOKEN_BAD_URL, TOKEN_CDC, TOKEN_CDO, TOKEN_COLON, TOKEN_COMMA, TOKEN_COMMENT, TOKEN_DELIM, TOKEN_DIMENSION, TOKEN_EOF, TOKEN_FUNCTION, TOKEN_HASH, TOKEN_IDENT, TOKEN_LEFT_BRACE, TOKEN_LEFT_BRACKET, TOKEN_LEFT_PAREN, TOKEN_NUMBER, TOKEN_PERCENTAGE, TOKEN_RIGHT_BRACE, TOKEN_RIGHT_BRACKET, TOKEN_RIGHT_PAREN, TOKEN_SEMICOLON, TOKEN_STRING, TOKEN_UNICODE_RANGE, TOKEN_URL, TOKEN_WHITESPACE, TYPE_NAMES, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE, is_atrule, is_atrule_prelude, is_attribute_selector, is_block, is_class_selector, is_combinator, is_comment, is_container_query, is_custom, is_declaration, is_dimension, is_feature_range, is_function, is_hash, is_id_selector, is_identifier, 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, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_selector_list, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as PRELUDE_SELECTORLIST, B as
|
|
1
|
+
import { A as PRELUDE_SELECTORLIST, B as SUPPORTS_DECLARATION, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as SELECTOR, G as URL, H as TYPE_SELECTOR, I as SELECTOR_LIST, K as VALUE, L as STRING, M as PSEUDO_ELEMENT_SELECTOR, N as RATIO, O as PARENTHESIS, P as RAW, R as STYLESHEET, S as MEDIA_TYPE, T as NTH_SELECTOR, U as UNICODE_RANGE, V as SUPPORTS_QUERY, W as UNIVERSAL_SELECTOR, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_CLASS_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as STYLE_RULE } from "./arena-C-uRgG5-.js";
|
|
2
2
|
//#region src/css-node.d.ts
|
|
3
3
|
declare const TYPE_NAMES: {
|
|
4
4
|
readonly 1: 'StyleSheet';
|
|
@@ -44,9 +44,10 @@ declare const TYPE_NAMES: {
|
|
|
44
44
|
readonly 39: 'MediaFeatureRange';
|
|
45
45
|
readonly 40: 'AtrulePrelude';
|
|
46
46
|
readonly 41: 'PreludeSelectorList';
|
|
47
|
+
readonly 58: 'Ratio';
|
|
47
48
|
};
|
|
48
49
|
type TypeName = (typeof TYPE_NAMES)[keyof typeof TYPE_NAMES] | 'unknown';
|
|
49
|
-
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;
|
|
50
|
+
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;
|
|
50
51
|
interface CloneOptions {
|
|
51
52
|
/**
|
|
52
53
|
* Recursively clone all children
|
|
@@ -71,6 +72,8 @@ type PlainCSSNode = {
|
|
|
71
72
|
value?: PlainCSSNode | string | number | null;
|
|
72
73
|
unit?: string;
|
|
73
74
|
prelude?: PlainCSSNode | null;
|
|
75
|
+
left?: PlainCSSNode;
|
|
76
|
+
right?: PlainCSSNode;
|
|
74
77
|
is_important?: boolean;
|
|
75
78
|
is_vendor_prefixed?: boolean;
|
|
76
79
|
is_browserhack?: boolean;
|
|
@@ -192,13 +195,18 @@ type Block = WithClone<CSSNode & WithChildren<Raw | Declaration | Atrule | Rule>
|
|
|
192
195
|
}>;
|
|
193
196
|
type Comment = Leaf<typeof COMMENT, 'Comment'>;
|
|
194
197
|
type Raw = Leaf<typeof RAW, 'Raw'>;
|
|
195
|
-
type ValueLike = Function | Identifier | Operator | Parenthesis | Url | UnicodeRange | String | Hash | Dimension | Number | SelectorList | SupportsDeclaration;
|
|
198
|
+
type ValueLike = Function | Identifier | Operator | Parenthesis | Url | UnicodeRange | String | Hash | Dimension | Number | Ratio | SelectorList | SupportsDeclaration;
|
|
196
199
|
type Identifier = Leaf<typeof IDENTIFIER, 'Identifier', {
|
|
197
200
|
readonly name: string;
|
|
198
201
|
}>;
|
|
199
202
|
type Number = Leaf<typeof NUMBER, 'Number', {
|
|
200
203
|
readonly value: number;
|
|
201
204
|
}>;
|
|
205
|
+
/** Ratio value, e.g. "16/9" in `aspect-ratio: 16/9`. A bare number like `aspect-ratio: 1` parses as a plain Number instead. */
|
|
206
|
+
type Ratio = Leaf<typeof RATIO, 'Ratio', {
|
|
207
|
+
readonly left: Number;
|
|
208
|
+
readonly right: Number;
|
|
209
|
+
}>;
|
|
202
210
|
type Dimension = Leaf<typeof DIMENSION, 'Dimension', {
|
|
203
211
|
readonly value: number;
|
|
204
212
|
/** Unit string, e.g. "px", "%" */
|
|
@@ -305,7 +313,7 @@ type MediaQuery = WithClone<CSSNode & WithChildren<MediaFeature | PreludeOperato
|
|
|
305
313
|
type MediaFeature = Leaf<typeof MEDIA_FEATURE, 'Feature', {
|
|
306
314
|
/** Feature name, e.g. "min-width" */
|
|
307
315
|
readonly property: string;
|
|
308
|
-
/** Feature value node, or null for boolean features like (hover) */
|
|
316
|
+
/** Feature value node (e.g. Dimension, Number, Identifier, Ratio), or null for boolean features like (hover) */
|
|
309
317
|
readonly value: CSSNode | null;
|
|
310
318
|
}>;
|
|
311
319
|
type MediaType = Leaf<typeof MEDIA_TYPE, 'MediaType', {
|
|
@@ -351,7 +359,7 @@ type FeatureRange = WithClone<CSSNode & WithChildren<Dimension | PreludeOperator
|
|
|
351
359
|
/** The feature name in a range comparison, e.g. "width" from "(width >= 400px)" */
|
|
352
360
|
readonly name: string;
|
|
353
361
|
}>;
|
|
354
|
-
type AnyNode = StyleSheet | Rule | Atrule | Declaration | Selector | SelectorList | Block | Comment | Raw | Identifier | Number | Dimension | String | Hash | Function | Operator | Parenthesis | Url | UnicodeRange | Value | TypeSelector | ClassSelector | IdSelector | AttributeSelector | PseudoClassSelector | PseudoElementSelector | Combinator | UniversalSelector | NestingSelector | NthSelector | NthOfSelector | LangSelector | AtrulePrelude | MediaQuery | MediaFeature | MediaType | ContainerQuery | SupportsQuery | SupportsDeclaration | LayerName | PreludeOperator | FeatureRange | PreludeSelectorList;
|
|
362
|
+
type AnyNode = StyleSheet | Rule | Atrule | Declaration | Selector | SelectorList | Block | Comment | Raw | Identifier | Number | Dimension | Ratio | String | Hash | Function | Operator | Parenthesis | Url | UnicodeRange | Value | TypeSelector | ClassSelector | IdSelector | AttributeSelector | PseudoClassSelector | PseudoElementSelector | Combinator | UniversalSelector | NestingSelector | NthSelector | NthOfSelector | LangSelector | AtrulePrelude | MediaQuery | MediaFeature | MediaType | ContainerQuery | SupportsQuery | SupportsDeclaration | LayerName | PreludeOperator | FeatureRange | PreludeSelectorList;
|
|
355
363
|
declare function is_stylesheet(node: CSSNode): node is StyleSheet;
|
|
356
364
|
declare function is_rule(node: CSSNode): node is Rule;
|
|
357
365
|
declare function is_atrule(node: CSSNode): node is Atrule;
|
|
@@ -394,6 +402,7 @@ declare function is_supports_declaration(node: CSSNode): node is SupportsDeclara
|
|
|
394
402
|
declare function is_layer_name(node: CSSNode): node is LayerName;
|
|
395
403
|
declare function is_prelude_operator(node: CSSNode): node is PreludeOperator;
|
|
396
404
|
declare function is_feature_range(node: CSSNode): node is FeatureRange;
|
|
405
|
+
declare function is_ratio(node: CSSNode): node is Ratio;
|
|
397
406
|
declare function is_prelude_selectorlist(node: CSSNode): node is PreludeSelectorList;
|
|
398
407
|
//#endregion
|
|
399
|
-
export {
|
|
408
|
+
export { is_block as $, PreludeSelectorList as A, is_selector_list as At, StyleSheet as B, CloneOptions as Bt, NestingSelector as C, is_prelude_selectorlist as Ct, Operator as D, is_raw as Dt, Number as E, is_ratio as Et, Rule as F, is_type_selector as Ft, UnicodeRange as G, SupportsQuery as H, TYPE_NAMES as Ht, Selector as I, is_unicode_range as It, Value as J, UniversalSelector as K, SelectorList as L, is_universal_selector as Lt, PseudoElementSelector as M, is_stylesheet as Mt, Ratio as N, is_supports_declaration as Nt, Parenthesis as O, is_rule as Ot, Raw as P, is_supports_query as Pt, is_attribute_selector as Q, SelectorNode as R, is_url as Rt, MediaType as S, is_prelude_operator as St, NthSelector as T, is_pseudo_element_selector as Tt, ToPlain as U, SupportsDeclaration as V, PlainCSSNode as Vt, TypeSelector as W, is_atrule as X, WithChildren as Y, is_atrule_prelude as Z, Identifier as _, is_nth_of_selector as _t, Block as a, is_dimension as at, MediaFeature as b, is_operator as bt, Combinator as c, is_hash as ct, Declaration as d, is_lang_selector as dt, is_class_selector as et, Dimension as f, is_layer_name as ft, IdSelector as g, is_nesting_selector as gt, Hash as h, is_media_type as ht, AttributeSelector as i, is_declaration as it, PseudoClassSelector as j, is_string as jt, PreludeOperator as k, is_selector as kt, Comment as l, is_id_selector as lt, Function as m, is_media_query as mt, Atrule as n, is_comment as nt, CSSNode as o, is_feature_range as ot, FeatureRange as p, is_media_feature as pt, Url as q, AtrulePrelude as r, is_container_query as rt, ClassSelector as s, is_function as st, AnyNode as t, is_combinator as tt, ContainerQuery as u, is_identifier as ut, LangSelector as v, is_nth_selector as vt, NthOfSelector as w, is_pseudo_class_selector as wt, MediaQuery as x, is_parenthesis as xt, LayerName as y, is_number as yt, String as z, is_value as zt };
|
package/dist/parse-anplusb.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { T as NthSelector } from "./node-types-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-C-uRgG5-.js";
|
|
2
|
+
import { T as NthSelector } from "./node-types-Dh1wEDRK.js";
|
|
3
3
|
//#region src/parse-anplusb.d.ts
|
|
4
4
|
/** @internal */
|
|
5
5
|
declare class ANplusBParser {
|
package/dist/parse-anplusb.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as Lexer } from "./tokenize-
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
1
|
+
import { t as Lexer } from "./tokenize-DK24ACbY.js";
|
|
2
|
+
import { l as CSSDataArena } from "./arena-C-ZXJe7F.js";
|
|
3
3
|
import { o as str_equals, s as str_index_of } from "./parse-dimension-ouWXNHdx.js";
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
4
|
+
import { t as CSSNode } from "./css-node-Briho45Z.js";
|
|
5
5
|
//#region src/parse-anplusb.ts
|
|
6
6
|
/** @internal */
|
|
7
7
|
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-C-uRgG5-.js";
|
|
2
|
+
import { t as AnyNode } from "./node-types-Dh1wEDRK.js";
|
|
3
3
|
//#region src/parse-atrule-prelude.d.ts
|
|
4
4
|
/** @internal */
|
|
5
5
|
declare class AtRulePreludeParser {
|
|
@@ -15,6 +15,7 @@ declare class AtRulePreludeParser {
|
|
|
15
15
|
private parse_media_query_list;
|
|
16
16
|
private create_node;
|
|
17
17
|
private is_and_or_not;
|
|
18
|
+
private scan_matching_paren;
|
|
18
19
|
private parse_function_condition;
|
|
19
20
|
private parse_single_media_query;
|
|
20
21
|
private parse_media_feature;
|
|
@@ -34,6 +35,7 @@ declare class AtRulePreludeParser {
|
|
|
34
35
|
private peek_token_type;
|
|
35
36
|
private next_token;
|
|
36
37
|
private parse_feature_value;
|
|
38
|
+
private wrap_ratio_value;
|
|
37
39
|
private parse_namespace_prelude;
|
|
38
40
|
private parse_scope_prelude;
|
|
39
41
|
private parse_custom_media_prelude;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as Lexer } from "./tokenize-
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
1
|
+
import { t as Lexer } from "./tokenize-DK24ACbY.js";
|
|
2
|
+
import { l as CSSDataArena } from "./arena-C-ZXJe7F.js";
|
|
3
3
|
import { l as strip_vendor_prefix, o as str_equals } from "./parse-dimension-ouWXNHdx.js";
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
4
|
+
import { t as CSSNode } from "./css-node-Briho45Z.js";
|
|
5
5
|
import { i as trim_boundaries, n as skip_whitespace_and_comments_forward } from "./parse-utils-D7srNG13.js";
|
|
6
6
|
import { SelectorParser } from "./parse-selector.js";
|
|
7
|
-
import { t as ValueNodeParser } from "./value-node-parser-
|
|
7
|
+
import { t as ValueNodeParser } from "./value-node-parser-B0WfJCvC.js";
|
|
8
8
|
//#region src/parse-atrule-prelude.ts
|
|
9
9
|
/** @internal */
|
|
10
10
|
var AtRulePreludeParser = class {
|
|
@@ -70,25 +70,32 @@ var AtRulePreludeParser = class {
|
|
|
70
70
|
is_and_or_not(str) {
|
|
71
71
|
return str_equals("and", str) || str_equals("or", str) || str_equals("not", str);
|
|
72
72
|
}
|
|
73
|
+
scan_matching_paren() {
|
|
74
|
+
let depth = 1;
|
|
75
|
+
let content_end = this.lexer.pos;
|
|
76
|
+
let close_end = this.lexer.token_end;
|
|
77
|
+
while (this.lexer.pos < this.prelude_end && depth > 0) {
|
|
78
|
+
let token_type = this.next_token();
|
|
79
|
+
if (token_type === 21 || token_type === 2) depth++;
|
|
80
|
+
else if (token_type === 22) {
|
|
81
|
+
depth--;
|
|
82
|
+
if (depth === 0) {
|
|
83
|
+
content_end = this.lexer.token_start;
|
|
84
|
+
close_end = this.lexer.token_end;
|
|
85
|
+
}
|
|
86
|
+
} else if (token_type === 26) break;
|
|
87
|
+
}
|
|
88
|
+
return [
|
|
89
|
+
content_end,
|
|
90
|
+
close_end,
|
|
91
|
+
depth === 0
|
|
92
|
+
];
|
|
93
|
+
}
|
|
73
94
|
parse_function_condition() {
|
|
74
95
|
let func_name = this.source.substring(this.lexer.token_start, this.lexer.token_end - 1);
|
|
75
96
|
let func_start = this.lexer.token_start;
|
|
76
97
|
let content_start = this.lexer.token_end;
|
|
77
|
-
let
|
|
78
|
-
let func_end = this.lexer.token_end;
|
|
79
|
-
let content_end = content_start;
|
|
80
|
-
while (this.lexer.pos < this.prelude_end && paren_depth > 0) {
|
|
81
|
-
this.next_token();
|
|
82
|
-
let inner_token = this.lexer.token_type;
|
|
83
|
-
if (inner_token === 21 || inner_token === 2) paren_depth++;
|
|
84
|
-
else if (inner_token === 22) {
|
|
85
|
-
paren_depth--;
|
|
86
|
-
if (paren_depth === 0) {
|
|
87
|
-
content_end = this.lexer.token_start;
|
|
88
|
-
func_end = this.lexer.token_end;
|
|
89
|
-
}
|
|
90
|
-
} else if (inner_token === 26) break;
|
|
91
|
-
}
|
|
98
|
+
let [content_end, func_end] = this.scan_matching_paren();
|
|
92
99
|
let func_node = this.create_node(15, func_start, func_end);
|
|
93
100
|
this.arena.set_content_start_delta(func_node, 0);
|
|
94
101
|
this.arena.set_content_length(func_node, func_name.length);
|
|
@@ -148,17 +155,9 @@ var AtRulePreludeParser = class {
|
|
|
148
155
|
}
|
|
149
156
|
parse_media_feature() {
|
|
150
157
|
let feature_start = this.lexer.token_start;
|
|
151
|
-
let depth = 1;
|
|
152
158
|
let content_start = this.lexer.pos;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
let token_type = this.lexer.token_type;
|
|
156
|
-
if (token_type === 21 || token_type === 2) depth++;
|
|
157
|
-
else if (token_type === 22) depth--;
|
|
158
|
-
}
|
|
159
|
-
if (depth !== 0) return null;
|
|
160
|
-
let content_end = this.lexer.token_start;
|
|
161
|
-
let feature_end = this.lexer.token_end;
|
|
159
|
+
let [content_end, feature_end, matched] = this.scan_matching_paren();
|
|
160
|
+
if (!matched) return null;
|
|
162
161
|
let has_comparison = false;
|
|
163
162
|
let i = content_start;
|
|
164
163
|
while (i < content_end) {
|
|
@@ -199,7 +198,7 @@ var AtRulePreludeParser = class {
|
|
|
199
198
|
let value_trimmed = trim_boundaries(this.source, colon_pos + 1, content_end);
|
|
200
199
|
if (value_trimmed) {
|
|
201
200
|
let value_first = this.parse_feature_value(value_trimmed[0], value_trimmed[1]);
|
|
202
|
-
if (value_first !== 0) this.arena.set_first_child(feature, value_first);
|
|
201
|
+
if (value_first !== 0) this.arena.set_first_child(feature, this.wrap_ratio_value(value_first));
|
|
203
202
|
}
|
|
204
203
|
}
|
|
205
204
|
return feature;
|
|
@@ -241,17 +240,9 @@ var AtRulePreludeParser = class {
|
|
|
241
240
|
let token_type = this.lexer.token_type;
|
|
242
241
|
if (token_type === 21) {
|
|
243
242
|
let feature_start = this.lexer.token_start;
|
|
244
|
-
let depth = 1;
|
|
245
243
|
let content_start = this.lexer.pos;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
let inner_token_type = this.lexer.token_type;
|
|
249
|
-
if (inner_token_type === 21 || inner_token_type === 2) depth++;
|
|
250
|
-
else if (inner_token_type === 22) depth--;
|
|
251
|
-
}
|
|
252
|
-
if (depth === 0) {
|
|
253
|
-
let content_end = this.lexer.token_start;
|
|
254
|
-
let feature_end = this.lexer.token_end;
|
|
244
|
+
let [content_end, feature_end, matched] = this.scan_matching_paren();
|
|
245
|
+
if (matched) {
|
|
255
246
|
let query = this.create_node(36, feature_start, feature_end);
|
|
256
247
|
let trimmed = trim_boundaries(this.source, content_start, content_end);
|
|
257
248
|
if (trimmed) {
|
|
@@ -392,15 +383,8 @@ var AtRulePreludeParser = class {
|
|
|
392
383
|
let url_start = this.lexer.token_start;
|
|
393
384
|
let url_end = this.lexer.token_end;
|
|
394
385
|
if (this.lexer.token_type === 2) {
|
|
395
|
-
let
|
|
396
|
-
|
|
397
|
-
let tokenType = this.next_token();
|
|
398
|
-
if (tokenType === 21 || tokenType === 2) paren_depth++;
|
|
399
|
-
else if (tokenType === 22) {
|
|
400
|
-
paren_depth--;
|
|
401
|
-
if (paren_depth === 0) url_end = this.lexer.token_end;
|
|
402
|
-
} else if (tokenType === 26) break;
|
|
403
|
-
}
|
|
386
|
+
let [, close_end] = this.scan_matching_paren();
|
|
387
|
+
url_end = close_end;
|
|
404
388
|
}
|
|
405
389
|
return this.create_node(18, url_start, url_end);
|
|
406
390
|
}
|
|
@@ -417,17 +401,10 @@ var AtRulePreludeParser = class {
|
|
|
417
401
|
let content_length = 0;
|
|
418
402
|
if (this.lexer.token_type === 2) {
|
|
419
403
|
content_start = this.lexer.pos;
|
|
420
|
-
let
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
else if (tokenType === 22) {
|
|
425
|
-
paren_depth--;
|
|
426
|
-
if (paren_depth === 0) {
|
|
427
|
-
content_length = this.lexer.token_start - content_start;
|
|
428
|
-
layer_end = this.lexer.token_end;
|
|
429
|
-
}
|
|
430
|
-
} else if (tokenType === 26) break;
|
|
404
|
+
let [content_end, close_end, matched] = this.scan_matching_paren();
|
|
405
|
+
if (matched) {
|
|
406
|
+
content_length = content_end - content_start;
|
|
407
|
+
layer_end = close_end;
|
|
431
408
|
}
|
|
432
409
|
}
|
|
433
410
|
let layer_node = this.create_node(37, layer_start, layer_end);
|
|
@@ -448,23 +425,11 @@ var AtRulePreludeParser = class {
|
|
|
448
425
|
const saved = this.lexer.save_position();
|
|
449
426
|
this.next_token();
|
|
450
427
|
if (this.lexer.token_type === 2) {
|
|
451
|
-
|
|
428
|
+
let text = this.source.substring(this.lexer.token_start, this.lexer.token_end - 1);
|
|
429
|
+
if (str_equals("supports", text)) {
|
|
452
430
|
let supports_start = this.lexer.token_start;
|
|
453
431
|
let content_start = this.lexer.token_end;
|
|
454
|
-
let
|
|
455
|
-
let supports_end = this.lexer.token_end;
|
|
456
|
-
let content_end = content_start;
|
|
457
|
-
while (this.lexer.pos < this.prelude_end && paren_depth > 0) {
|
|
458
|
-
let tokenType = this.next_token();
|
|
459
|
-
if (tokenType === 21 || tokenType === 2) paren_depth++;
|
|
460
|
-
else if (tokenType === 22) {
|
|
461
|
-
paren_depth--;
|
|
462
|
-
if (paren_depth === 0) {
|
|
463
|
-
content_end = this.lexer.token_start;
|
|
464
|
-
supports_end = this.lexer.token_end;
|
|
465
|
-
}
|
|
466
|
-
} else if (tokenType === 26) break;
|
|
467
|
-
}
|
|
432
|
+
let [content_end, supports_end] = this.scan_matching_paren();
|
|
468
433
|
let supports_node = this.create_node(36, supports_start, supports_end);
|
|
469
434
|
let trimmed = trim_boundaries(this.source, content_start, content_end);
|
|
470
435
|
if (trimmed) {
|
|
@@ -502,6 +467,22 @@ var AtRulePreludeParser = class {
|
|
|
502
467
|
parse_feature_value(start, end) {
|
|
503
468
|
return this.value_node_parser.parse_chain(start, end, this.lexer.line, this.lexer.column);
|
|
504
469
|
}
|
|
470
|
+
wrap_ratio_value(first_node) {
|
|
471
|
+
if (this.arena.get_type(first_node) !== 11) return first_node;
|
|
472
|
+
let op_node = this.arena.get_next_sibling(first_node);
|
|
473
|
+
if (op_node === 0 || this.arena.get_type(op_node) !== 16) return first_node;
|
|
474
|
+
if (this.arena.get_length(op_node) !== 1) return first_node;
|
|
475
|
+
if (this.source.charCodeAt(this.arena.get_start_offset(op_node)) !== 47) return first_node;
|
|
476
|
+
let second_node = this.arena.get_next_sibling(op_node);
|
|
477
|
+
if (second_node === 0 || this.arena.get_type(second_node) !== 11) return first_node;
|
|
478
|
+
if (this.arena.get_next_sibling(second_node) !== 0) return first_node;
|
|
479
|
+
let start = this.arena.get_start_offset(first_node);
|
|
480
|
+
let end = this.arena.get_start_offset(second_node) + this.arena.get_length(second_node);
|
|
481
|
+
let ratio_node = this.arena.create_node(58, start, end - start, this.arena.get_start_line(first_node), this.arena.get_start_column(first_node));
|
|
482
|
+
this.arena.set_first_child(ratio_node, first_node);
|
|
483
|
+
this.arena.set_next_sibling(first_node, second_node);
|
|
484
|
+
return ratio_node;
|
|
485
|
+
}
|
|
505
486
|
parse_namespace_prelude() {
|
|
506
487
|
let nodes = [];
|
|
507
488
|
this.skip_whitespace();
|
|
@@ -526,14 +507,7 @@ var AtRulePreludeParser = class {
|
|
|
526
507
|
this.next_token();
|
|
527
508
|
let paren_start = this.lexer.token_start;
|
|
528
509
|
let content_start = this.lexer.pos;
|
|
529
|
-
let
|
|
530
|
-
while (this.lexer.pos < this.prelude_end && depth > 0) {
|
|
531
|
-
this.next_token();
|
|
532
|
-
if (this.lexer.token_type === 21 || this.lexer.token_type === 2) depth++;
|
|
533
|
-
else if (this.lexer.token_type === 22) depth--;
|
|
534
|
-
}
|
|
535
|
-
let content_end = this.lexer.token_start;
|
|
536
|
-
let paren_end = this.lexer.token_end;
|
|
510
|
+
let [content_end, paren_end] = this.scan_matching_paren();
|
|
537
511
|
let scope_node = this.create_node(41, paren_start, paren_end);
|
|
538
512
|
let trimmed = trim_boundaries(this.source, content_start, content_end);
|
|
539
513
|
if (trimmed) {
|
|
@@ -543,7 +517,8 @@ var AtRulePreludeParser = class {
|
|
|
543
517
|
nodes.push(scope_node);
|
|
544
518
|
} else if (token_type === 1) {
|
|
545
519
|
this.next_token();
|
|
546
|
-
|
|
520
|
+
let text = this.source.substring(this.lexer.token_start, this.lexer.token_end);
|
|
521
|
+
if (str_equals("to", text)) nodes.push(this.create_node(38, this.lexer.token_start, this.lexer.token_end));
|
|
547
522
|
} else this.next_token();
|
|
548
523
|
}
|
|
549
524
|
return nodes;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { n as Lexer } from "./tokenize-
|
|
3
|
-
import { d as Declaration } from "./node-types-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-C-uRgG5-.js";
|
|
2
|
+
import { n as Lexer } from "./tokenize-CDEnYcVG.js";
|
|
3
|
+
import { d as Declaration } from "./node-types-Dh1wEDRK.js";
|
|
4
4
|
//#region src/parse-declaration.d.ts
|
|
5
5
|
/** @internal */
|
|
6
6
|
declare class DeclarationParser {
|