@projectwallace/css-parser 0.13.8 → 0.13.10

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.
@@ -1,223 +1,5 @@
1
+ import "./arena-CDAx4eAB.js";
1
2
  import { a as is_whitespace, c as str_starts_with, i as is_vendor_prefixed, t as parse_dimension } from "./parse-dimension-CCn_XRDe.js";
2
- //#region src/arena.ts
3
- let BYTES_PER_NODE = 36;
4
- const STYLESHEET = 1;
5
- const STYLE_RULE = 2;
6
- const AT_RULE = 3;
7
- const DECLARATION = 4;
8
- const SELECTOR = 5;
9
- const COMMENT = 6;
10
- const BLOCK = 7;
11
- const RAW = 8;
12
- const IDENTIFIER = 10;
13
- const NUMBER = 11;
14
- const DIMENSION = 12;
15
- const STRING = 13;
16
- const HASH = 14;
17
- const FUNCTION = 15;
18
- const OPERATOR = 16;
19
- const PARENTHESIS = 17;
20
- const URL = 18;
21
- const SELECTOR_LIST = 20;
22
- const TYPE_SELECTOR = 21;
23
- const CLASS_SELECTOR = 22;
24
- const ID_SELECTOR = 23;
25
- const ATTRIBUTE_SELECTOR = 24;
26
- const PSEUDO_CLASS_SELECTOR = 25;
27
- const PSEUDO_ELEMENT_SELECTOR = 26;
28
- const COMBINATOR = 27;
29
- const UNIVERSAL_SELECTOR = 28;
30
- const NESTING_SELECTOR = 29;
31
- const NTH_SELECTOR = 30;
32
- const NTH_OF_SELECTOR = 31;
33
- const LANG_SELECTOR = 56;
34
- const MEDIA_QUERY = 32;
35
- const MEDIA_FEATURE = 33;
36
- const MEDIA_TYPE = 34;
37
- const CONTAINER_QUERY = 35;
38
- const SUPPORTS_QUERY = 36;
39
- const LAYER_NAME = 37;
40
- const PRELUDE_OPERATOR = 38;
41
- const FEATURE_RANGE = 39;
42
- const AT_RULE_PRELUDE = 40;
43
- const VALUE = 50;
44
- const FLAG_IMPORTANT = 1;
45
- const ATTR_OPERATOR_NONE = 0;
46
- const ATTR_OPERATOR_EQUAL = 1;
47
- const ATTR_OPERATOR_TILDE_EQUAL = 2;
48
- const ATTR_OPERATOR_PIPE_EQUAL = 3;
49
- const ATTR_OPERATOR_CARET_EQUAL = 4;
50
- const ATTR_OPERATOR_DOLLAR_EQUAL = 5;
51
- const ATTR_OPERATOR_STAR_EQUAL = 6;
52
- const ATTR_FLAG_NONE = 0;
53
- const ATTR_FLAG_CASE_INSENSITIVE = 1;
54
- const ATTR_FLAG_CASE_SENSITIVE = 2;
55
- /** @internal */
56
- var CSSDataArena = class CSSDataArena {
57
- buffer;
58
- view;
59
- capacity;
60
- count;
61
- growth_count;
62
- overflow_lengths;
63
- static GROWTH_FACTOR = 1.3;
64
- static NODES_PER_KB = 325;
65
- static CAPACITY_BUFFER = 1.2;
66
- constructor(initial_capacity = 1024) {
67
- this.capacity = initial_capacity;
68
- this.count = 1;
69
- this.growth_count = 0;
70
- this.buffer = new ArrayBuffer(initial_capacity * BYTES_PER_NODE);
71
- this.view = new DataView(this.buffer);
72
- this.overflow_lengths = /* @__PURE__ */ new Map();
73
- }
74
- static capacity_for_source(source_length) {
75
- let size_in_kb = source_length / 1024;
76
- let estimated_nodes = Math.ceil(size_in_kb * CSSDataArena.NODES_PER_KB);
77
- let capacity = Math.ceil(estimated_nodes * CSSDataArena.CAPACITY_BUFFER);
78
- return Math.max(16, capacity);
79
- }
80
- get_count() {
81
- return this.count;
82
- }
83
- get_capacity() {
84
- return this.capacity;
85
- }
86
- get_growth_count() {
87
- return this.growth_count;
88
- }
89
- node_offset(node_index) {
90
- return node_index * BYTES_PER_NODE;
91
- }
92
- get_type(node_index) {
93
- return this.view.getUint8(this.node_offset(node_index));
94
- }
95
- get_flags(node_index) {
96
- return this.view.getUint8(this.node_offset(node_index) + 1);
97
- }
98
- get_start_offset(node_index) {
99
- return this.view.getUint32(this.node_offset(node_index) + 12, true);
100
- }
101
- get_length(node_index) {
102
- if (this.has_flag(node_index, 4)) {
103
- const overflow_length = this.overflow_lengths.get(node_index);
104
- if (overflow_length !== void 0) return overflow_length;
105
- }
106
- return this.view.getUint16(this.node_offset(node_index) + 2, true);
107
- }
108
- get_content_start(node_index) {
109
- return this.get_start_offset(node_index) + this.view.getUint16(this.node_offset(node_index) + 16, true);
110
- }
111
- get_content_length(node_index) {
112
- return this.view.getUint16(this.node_offset(node_index) + 20, true);
113
- }
114
- get_attr_operator(node_index) {
115
- return this.view.getUint8(this.node_offset(node_index) + 32);
116
- }
117
- get_attr_flags(node_index) {
118
- return this.view.getUint8(this.node_offset(node_index) + 33);
119
- }
120
- get_first_child(node_index) {
121
- return this.view.getUint32(this.node_offset(node_index) + 4, true);
122
- }
123
- get_next_sibling(node_index) {
124
- return this.view.getUint32(this.node_offset(node_index) + 8, true);
125
- }
126
- get_start_line(node_index) {
127
- return this.view.getUint32(this.node_offset(node_index) + 24, true);
128
- }
129
- get_start_column(node_index) {
130
- return this.view.getUint32(this.node_offset(node_index) + 28, true);
131
- }
132
- get_value_start(node_index) {
133
- return this.get_start_offset(node_index) + this.view.getUint16(this.node_offset(node_index) + 18, true);
134
- }
135
- get_value_length(node_index) {
136
- return this.view.getUint16(this.node_offset(node_index) + 22, true);
137
- }
138
- set_type(node_index, type) {
139
- this.view.setUint8(this.node_offset(node_index), type);
140
- }
141
- set_flags(node_index, flags) {
142
- this.view.setUint8(this.node_offset(node_index) + 1, flags);
143
- }
144
- set_length(node_index, length) {
145
- if (length > 65535) {
146
- this.view.setUint16(this.node_offset(node_index) + 2, 65535, true);
147
- this.set_flag(node_index, 4);
148
- this.overflow_lengths.set(node_index, length);
149
- } else this.view.setUint16(this.node_offset(node_index) + 2, length, true);
150
- }
151
- set_content_start_delta(node_index, delta) {
152
- this.view.setUint16(this.node_offset(node_index) + 16, delta, true);
153
- }
154
- set_content_length(node_index, length) {
155
- this.view.setUint16(this.node_offset(node_index) + 20, length, true);
156
- }
157
- set_attr_operator(node_index, operator) {
158
- this.view.setUint8(this.node_offset(node_index) + 32, operator);
159
- }
160
- set_attr_flags(node_index, flags) {
161
- this.view.setUint8(this.node_offset(node_index) + 33, flags);
162
- }
163
- set_first_child(node_index, childIndex) {
164
- this.view.setUint32(this.node_offset(node_index) + 4, childIndex, true);
165
- }
166
- set_next_sibling(node_index, siblingIndex) {
167
- this.view.setUint32(this.node_offset(node_index) + 8, siblingIndex, true);
168
- }
169
- set_value_start_delta(node_index, delta) {
170
- this.view.setUint16(this.node_offset(node_index) + 18, delta, true);
171
- }
172
- set_value_length(node_index, length) {
173
- this.view.setUint16(this.node_offset(node_index) + 22, length, true);
174
- }
175
- grow() {
176
- this.growth_count++;
177
- let new_capacity = Math.ceil(this.capacity * CSSDataArena.GROWTH_FACTOR);
178
- let new_buffer = new ArrayBuffer(new_capacity * BYTES_PER_NODE);
179
- new Uint8Array(new_buffer).set(new Uint8Array(this.buffer));
180
- this.buffer = new_buffer;
181
- this.view = new DataView(new_buffer);
182
- this.capacity = new_capacity;
183
- }
184
- create_node(type, start_offset, length, start_line, start_column) {
185
- if (this.count >= this.capacity) this.grow();
186
- const node_index = this.count;
187
- this.count++;
188
- const offset = node_index * BYTES_PER_NODE;
189
- this.view.setUint8(offset, type);
190
- this.view.setUint32(offset + 12, start_offset, true);
191
- this.view.setUint32(offset + 24, start_line, true);
192
- this.view.setUint32(offset + 28, start_column, true);
193
- this.set_length(node_index, length);
194
- return node_index;
195
- }
196
- append_children(parent_index, children) {
197
- if (children.length === 0) return;
198
- const offset = this.node_offset(parent_index);
199
- this.view.setUint32(offset + 4, children[0], true);
200
- for (let i = 0; i < children.length - 1; i++) this.set_next_sibling(children[i], children[i + 1]);
201
- }
202
- has_children(node_index) {
203
- return this.get_first_child(node_index) !== 0;
204
- }
205
- has_next_sibling(node_index) {
206
- return this.get_next_sibling(node_index) !== 0;
207
- }
208
- set_flag(node_index, flag) {
209
- let current_flags = this.get_flags(node_index);
210
- this.set_flags(node_index, current_flags | flag);
211
- }
212
- clear_flag(node_index, flag) {
213
- let current_flags = this.get_flags(node_index);
214
- this.set_flags(node_index, current_flags & ~flag);
215
- }
216
- has_flag(node_index, flag) {
217
- return (this.get_flags(node_index) & flag) !== 0;
218
- }
219
- };
220
- //#endregion
221
3
  //#region src/css-node.ts
222
4
  const TYPE_NAMES = {
223
5
  [1]: "StyleSheet",
@@ -644,4 +426,4 @@ var CSSNode = class CSSNode {
644
426
  }
645
427
  };
646
428
  //#endregion
647
- export { TYPE_SELECTOR as $, IDENTIFIER as A, NUMBER as B, CSSDataArena as C, FLAG_IMPORTANT as D, FEATURE_RANGE as E, MEDIA_QUERY as F, PSEUDO_ELEMENT_SELECTOR as G, PARENTHESIS as H, MEDIA_TYPE as I, SELECTOR_LIST as J, RAW as K, NESTING_SELECTOR as L, LANG_SELECTOR as M, LAYER_NAME as N, FUNCTION as O, MEDIA_FEATURE as P, SUPPORTS_QUERY as Q, NTH_OF_SELECTOR as R, CONTAINER_QUERY as S, DIMENSION as T, PRELUDE_OPERATOR as U, OPERATOR as V, PSEUDO_CLASS_SELECTOR as W, STYLESHEET as X, STRING as Y, STYLE_RULE as Z, AT_RULE_PRELUDE as _, ATTRIBUTE_SELECTOR as a, COMBINATOR as b, ATTR_FLAG_NONE as c, ATTR_OPERATOR_EQUAL as d, UNIVERSAL_SELECTOR as et, ATTR_OPERATOR_NONE as f, AT_RULE as g, ATTR_OPERATOR_TILDE_EQUAL as h, TYPE_NAMES as i, ID_SELECTOR as j, HASH as k, ATTR_OPERATOR_CARET_EQUAL as l, ATTR_OPERATOR_STAR_EQUAL as m, ATTR_OPERATOR_NAMES as n, VALUE as nt, ATTR_FLAG_CASE_INSENSITIVE as o, ATTR_OPERATOR_PIPE_EQUAL as p, SELECTOR as q, CSSNode as r, ATTR_FLAG_CASE_SENSITIVE as s, ATTR_FLAG_NAMES as t, URL as tt, ATTR_OPERATOR_DOLLAR_EQUAL as u, BLOCK as v, DECLARATION as w, COMMENT as x, CLASS_SELECTOR as y, NTH_SELECTOR as z };
429
+ export { TYPE_NAMES as i, ATTR_OPERATOR_NAMES as n, CSSNode as r, ATTR_FLAG_NAMES as t };
package/dist/index.d.ts CHANGED
@@ -1,43 +1,15 @@
1
- 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-odLrcjj2.js";
2
- import { $ as STYLESHEET, A as FLAG_IMPORTANT, B as NESTING_SELECTOR, C as COMBINATOR, D as DECLARATION, F as LANG_SELECTOR, G as PARENTHESIS, H as NTH_SELECTOR, I as LAYER_NAME, J as PSEUDO_ELEMENT_SELECTOR, K as PRELUDE_OPERATOR, L as MEDIA_FEATURE, M as HASH, N as IDENTIFIER, O as DIMENSION, P as ID_SELECTOR, Q as STRING, R as MEDIA_QUERY, S as CLASS_SELECTOR, T as CONTAINER_QUERY, U as NUMBER, V as NTH_OF_SELECTOR, W as OPERATOR, X as SELECTOR, Y as RAW, Z as SELECTOR_LIST, _ as ATTR_OPERATOR_STAR_EQUAL, a as CloneOptions, at as VALUE, b as AT_RULE_PRELUDE, c as ATTRIBUTE_SELECTOR, d as ATTR_FLAG_NONE, et as STYLE_RULE, f as ATTR_OPERATOR_CARET_EQUAL, g as ATTR_OPERATOR_PIPE_EQUAL, h as ATTR_OPERATOR_NONE, i as CSSNodeType, it as URL, j as FUNCTION, k as FEATURE_RANGE, l as ATTR_FLAG_CASE_INSENSITIVE, m as ATTR_OPERATOR_EQUAL, n as ATTR_OPERATOR_NAMES, nt as TYPE_SELECTOR, o as PlainCSSNode, p as ATTR_OPERATOR_DOLLAR_EQUAL, q as PSEUDO_CLASS_SELECTOR, r as CSSNode, rt as UNIVERSAL_SELECTOR, s as TYPE_NAMES, t as ATTR_FLAG_NAMES, tt as SUPPORTS_QUERY, u as ATTR_FLAG_CASE_SENSITIVE, v as ATTR_OPERATOR_TILDE_EQUAL, w as COMMENT, x as BLOCK, y as AT_RULE, z as MEDIA_TYPE } from "./css-node-DqyvMXBN.js";
1
+ import { A as MEDIA_FEATURE, B as PSEUDO_CLASS_SELECTOR, C as FLAG_IMPORTANT, D as ID_SELECTOR, E as IDENTIFIER, F as NTH_SELECTOR, G as STRING, H as RAW, I as NUMBER, J as SUPPORTS_QUERY, K as STYLESHEET, L as OPERATOR, M as MEDIA_TYPE, N as NESTING_SELECTOR, O as LANG_SELECTOR, P as NTH_OF_SELECTOR, Q as VALUE, R as PARENTHESIS, S as FEATURE_RANGE, T as HASH, U as SELECTOR, V as PSEUDO_ELEMENT_SELECTOR, W as SELECTOR_LIST, X as UNIVERSAL_SELECTOR, Y as TYPE_SELECTOR, Z as URL, _ as COMMENT, a as ATTR_OPERATOR_CARET_EQUAL, b as DECLARATION, c as ATTR_OPERATOR_NONE, d as ATTR_OPERATOR_TILDE_EQUAL, f as AT_RULE, g as COMBINATOR, h as CLASS_SELECTOR, i as ATTR_FLAG_NONE, j as MEDIA_QUERY, k as LAYER_NAME, l as ATTR_OPERATOR_PIPE_EQUAL, m as BLOCK, n as ATTR_FLAG_CASE_INSENSITIVE, o as ATTR_OPERATOR_DOLLAR_EQUAL, p as AT_RULE_PRELUDE, q as STYLE_RULE, r as ATTR_FLAG_CASE_SENSITIVE, s as ATTR_OPERATOR_EQUAL, t as ATTRIBUTE_SELECTOR, u as ATTR_OPERATOR_STAR_EQUAL, v as CONTAINER_QUERY, w as FUNCTION, x as DIMENSION, z as PRELUDE_OPERATOR } from "./arena-BtlVZlkG.js";
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-CyiJelQC.js";
4
+ import { a as CloneOptions, i as CSSNodeType, n as ATTR_OPERATOR_NAMES, o as PlainCSSNode, r as CSSNode, s as TYPE_NAMES, t as ATTR_FLAG_NAMES } from "./css-node-B9tSb6YD.js";
3
5
  import { ParserOptions, parse } from "./parse.js";
4
6
  import { parse_selector } from "./parse-selector.js";
5
7
  import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
6
8
  import { parse_declaration } from "./parse-declaration.js";
7
9
  import { parse_value } from "./parse-value.js";
8
10
  import { parse_dimension } from "./parse-dimension.js";
11
+ import { BREAK, SKIP, traverse, walk } from "./walk.js";
9
12
 
10
- //#region src/walk.d.ts
11
- declare const SKIP: unique symbol;
12
- declare const BREAK: unique symbol;
13
- type WalkCallback = (node: CSSNode, depth: number) => void | typeof SKIP | typeof BREAK;
14
- /**
15
- * Walk the AST in depth-first order, calling the callback for each node.
16
- * Return SKIP to skip children, BREAK to stop traversal. See API.md for examples.
17
- *
18
- * @param node - The root node to start walking from
19
- * @param callback - Function called for each node. Receives the node and its nesting depth.
20
- * Depth increments only for STYLE_RULE and AT_RULE nodes (tracks rule nesting, not tree depth).
21
- * @param depth - Starting depth (default: 0)
22
- */
23
- declare function walk(node: CSSNode, callback: WalkCallback, depth?: number): boolean;
24
- type WalkEnterLeaveCallback = (node: CSSNode) => void | typeof SKIP | typeof BREAK;
25
- interface WalkEnterLeaveOptions {
26
- enter?: WalkEnterLeaveCallback;
27
- leave?: WalkEnterLeaveCallback;
28
- }
29
- /**
30
- * Walk the AST in depth-first order, calling enter before visiting children and leave after.
31
- * Return SKIP in enter to skip children (leave still called), BREAK to stop (leave NOT called). See API.md for examples.
32
- *
33
- * @param node - The root node to start walking from
34
- * @param options - Object with optional enter and leave callback functions
35
- */
36
- declare function traverse(node: CSSNode, {
37
- enter,
38
- leave
39
- }?: WalkEnterLeaveOptions): boolean;
40
- //#endregion
41
13
  //#region src/string-utils.d.ts
42
14
  /**
43
15
  * @param a Base string, MUST be lowercase!
@@ -103,48 +75,4 @@ declare function is_vendor_prefixed(source: string, start: number, end: number):
103
75
  */
104
76
  declare function is_custom(str: string): boolean;
105
77
  //#endregion
106
- //#region src/constants.d.ts
107
- declare const NODE_TYPES: {
108
- readonly STYLESHEET: 1;
109
- readonly STYLE_RULE: 2;
110
- readonly AT_RULE: 3;
111
- readonly DECLARATION: 4;
112
- readonly SELECTOR: 5;
113
- readonly COMMENT: 6;
114
- readonly BLOCK: 7;
115
- readonly RAW: 8;
116
- readonly IDENTIFIER: 10;
117
- readonly NUMBER: 11;
118
- readonly DIMENSION: 12;
119
- readonly STRING: 13;
120
- readonly HASH: 14;
121
- readonly FUNCTION: 15;
122
- readonly OPERATOR: 16;
123
- readonly PARENTHESIS: 17;
124
- readonly URL: 18;
125
- readonly VALUE: 50;
126
- readonly SELECTOR_LIST: 20;
127
- readonly TYPE_SELECTOR: 21;
128
- readonly CLASS_SELECTOR: 22;
129
- readonly ID_SELECTOR: 23;
130
- readonly ATTRIBUTE_SELECTOR: 24;
131
- readonly PSEUDO_CLASS_SELECTOR: 25;
132
- readonly PSEUDO_ELEMENT_SELECTOR: 26;
133
- readonly COMBINATOR: 27;
134
- readonly UNIVERSAL_SELECTOR: 28;
135
- readonly NESTING_SELECTOR: 29;
136
- readonly NTH_SELECTOR: 30;
137
- readonly NTH_OF_SELECTOR: 31;
138
- readonly LANG_SELECTOR: 56;
139
- readonly MEDIA_QUERY: 32;
140
- readonly MEDIA_FEATURE: 33;
141
- readonly MEDIA_TYPE: 34;
142
- readonly CONTAINER_QUERY: 35;
143
- readonly SUPPORTS_QUERY: 36;
144
- readonly LAYER_NAME: 37;
145
- readonly PRELUDE_OPERATOR: 38;
146
- readonly FEATURE_RANGE: 39;
147
- readonly AT_RULE_PRELUDE: 40;
148
- };
149
- //#endregion
150
78
  export { ATTRIBUTE_SELECTOR, ATTR_FLAG_CASE_INSENSITIVE, ATTR_FLAG_CASE_SENSITIVE, ATTR_FLAG_NAMES, ATTR_FLAG_NONE, ATTR_OPERATOR_CARET_EQUAL, ATTR_OPERATOR_DOLLAR_EQUAL, ATTR_OPERATOR_EQUAL, ATTR_OPERATOR_NAMES, ATTR_OPERATOR_NONE, ATTR_OPERATOR_PIPE_EQUAL, ATTR_OPERATOR_STAR_EQUAL, ATTR_OPERATOR_TILDE_EQUAL, AT_RULE, AT_RULE_PRELUDE, BLOCK, BREAK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, CSSNode, type CSSNodeType, type CloneOptions, type CommentInfo, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, type LexerPosition, 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, type ParserOptions, type PlainCSSNode, RAW, SELECTOR, SELECTOR_LIST, SKIP, STRING, STYLESHEET, STYLE_RULE, 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, Token, TokenType, UNIVERSAL_SELECTOR, URL, VALUE, is_custom, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
package/dist/index.js CHANGED
@@ -1,103 +1,12 @@
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-BQFB1jXg.js";
2
- import { $ as TYPE_SELECTOR, A as IDENTIFIER, B as NUMBER, D as FLAG_IMPORTANT, E as FEATURE_RANGE, F as MEDIA_QUERY, G as PSEUDO_ELEMENT_SELECTOR, H as PARENTHESIS, I as MEDIA_TYPE, J as SELECTOR_LIST, K as RAW, L as NESTING_SELECTOR, M as LANG_SELECTOR, N as LAYER_NAME, O as FUNCTION, P as MEDIA_FEATURE, Q as SUPPORTS_QUERY, R as NTH_OF_SELECTOR, S as CONTAINER_QUERY, T as DIMENSION, U as PRELUDE_OPERATOR, V as OPERATOR, W as PSEUDO_CLASS_SELECTOR, X as STYLESHEET, Y as STRING, Z as STYLE_RULE, _ as AT_RULE_PRELUDE, a as ATTRIBUTE_SELECTOR, b as COMBINATOR, c as ATTR_FLAG_NONE, d as ATTR_OPERATOR_EQUAL, et as UNIVERSAL_SELECTOR, f as ATTR_OPERATOR_NONE, g as AT_RULE, h as ATTR_OPERATOR_TILDE_EQUAL, i as TYPE_NAMES, j as ID_SELECTOR, k as HASH, l as ATTR_OPERATOR_CARET_EQUAL, m as ATTR_OPERATOR_STAR_EQUAL, n as ATTR_OPERATOR_NAMES, nt as VALUE, o as ATTR_FLAG_CASE_INSENSITIVE, p as ATTR_OPERATOR_PIPE_EQUAL, q as SELECTOR, r as CSSNode, s as ATTR_FLAG_CASE_SENSITIVE, t as ATTR_FLAG_NAMES, tt as URL, u as ATTR_OPERATOR_DOLLAR_EQUAL, v as BLOCK, w as DECLARATION, x as COMMENT, y as CLASS_SELECTOR, z as NTH_SELECTOR } from "./css-node-Uj4oBgaw.js";
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-BSycRGm0.js";
2
+ import { A as MEDIA_FEATURE, B as PSEUDO_CLASS_SELECTOR, C as FLAG_IMPORTANT, D as ID_SELECTOR, E as IDENTIFIER, F as NTH_SELECTOR, G as STRING, H as RAW, I as NUMBER, J as SUPPORTS_QUERY, K as STYLESHEET, L as OPERATOR, M as MEDIA_TYPE, N as NESTING_SELECTOR, O as LANG_SELECTOR, P as NTH_OF_SELECTOR, Q as VALUE, R as PARENTHESIS, S as FEATURE_RANGE, T as HASH, U as SELECTOR, V as PSEUDO_ELEMENT_SELECTOR, W as SELECTOR_LIST, X as UNIVERSAL_SELECTOR, Y as TYPE_SELECTOR, Z as URL, _ as COMMENT, a as ATTR_OPERATOR_CARET_EQUAL, b as DECLARATION, c as ATTR_OPERATOR_NONE, d as ATTR_OPERATOR_TILDE_EQUAL, f as AT_RULE, g as COMBINATOR, h as CLASS_SELECTOR, i as ATTR_FLAG_NONE, j as MEDIA_QUERY, k as LAYER_NAME, l as ATTR_OPERATOR_PIPE_EQUAL, m as BLOCK, n as ATTR_FLAG_CASE_INSENSITIVE, o as ATTR_OPERATOR_DOLLAR_EQUAL, p as AT_RULE_PRELUDE, q as STYLE_RULE, r as ATTR_FLAG_CASE_SENSITIVE, s as ATTR_OPERATOR_EQUAL, t as ATTRIBUTE_SELECTOR, u as ATTR_OPERATOR_STAR_EQUAL, v as CONTAINER_QUERY, w as FUNCTION, x as DIMENSION, z as PRELUDE_OPERATOR } from "./arena-CDAx4eAB.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-CCn_XRDe.js";
4
+ import { i as TYPE_NAMES, n as ATTR_OPERATOR_NAMES, r as CSSNode, t as ATTR_FLAG_NAMES } from "./css-node-CZf-PvCf.js";
4
5
  import { parse_selector } from "./parse-selector.js";
5
6
  import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
6
7
  import { parse_value } from "./parse-value.js";
7
8
  import { parse_declaration } from "./parse-declaration.js";
8
9
  import { parse } from "./parse.js";
9
- //#region src/constants.ts
10
- const NODE_TYPES = {
11
- STYLESHEET: 1,
12
- STYLE_RULE: 2,
13
- AT_RULE: 3,
14
- DECLARATION: 4,
15
- SELECTOR: 5,
16
- COMMENT: 6,
17
- BLOCK: 7,
18
- RAW: 8,
19
- IDENTIFIER: 10,
20
- NUMBER: 11,
21
- DIMENSION: 12,
22
- STRING: 13,
23
- HASH: 14,
24
- FUNCTION: 15,
25
- OPERATOR: 16,
26
- PARENTHESIS: 17,
27
- URL: 18,
28
- VALUE: 50,
29
- SELECTOR_LIST: 20,
30
- TYPE_SELECTOR: 21,
31
- CLASS_SELECTOR: 22,
32
- ID_SELECTOR: 23,
33
- ATTRIBUTE_SELECTOR: 24,
34
- PSEUDO_CLASS_SELECTOR: 25,
35
- PSEUDO_ELEMENT_SELECTOR: 26,
36
- COMBINATOR: 27,
37
- UNIVERSAL_SELECTOR: 28,
38
- NESTING_SELECTOR: 29,
39
- NTH_SELECTOR: 30,
40
- NTH_OF_SELECTOR: 31,
41
- LANG_SELECTOR: 56,
42
- MEDIA_QUERY: 32,
43
- MEDIA_FEATURE: 33,
44
- MEDIA_TYPE: 34,
45
- CONTAINER_QUERY: 35,
46
- SUPPORTS_QUERY: 36,
47
- LAYER_NAME: 37,
48
- PRELUDE_OPERATOR: 38,
49
- FEATURE_RANGE: 39,
50
- AT_RULE_PRELUDE: 40
51
- };
52
- //#endregion
53
- //#region src/walk.ts
54
- const SKIP = Symbol("SKIP");
55
- const BREAK = Symbol("BREAK");
56
- /**
57
- * Walk the AST in depth-first order, calling the callback for each node.
58
- * Return SKIP to skip children, BREAK to stop traversal. See API.md for examples.
59
- *
60
- * @param node - The root node to start walking from
61
- * @param callback - Function called for each node. Receives the node and its nesting depth.
62
- * Depth increments only for STYLE_RULE and AT_RULE nodes (tracks rule nesting, not tree depth).
63
- * @param depth - Starting depth (default: 0)
64
- */
65
- function walk(node, callback, depth = 0) {
66
- const result = callback(node, depth);
67
- if (result === BREAK) return false;
68
- if (result === SKIP) return true;
69
- let child_depth = depth;
70
- if (node.type === 2 || node.type === 3) child_depth = depth + 1;
71
- let child = node.first_child;
72
- while (child) {
73
- if (!walk(child, callback, child_depth)) return false;
74
- child = child.next_sibling;
75
- }
76
- return true;
77
- }
78
- const NOOP = function() {};
79
- /**
80
- * Walk the AST in depth-first order, calling enter before visiting children and leave after.
81
- * Return SKIP in enter to skip children (leave still called), BREAK to stop (leave NOT called). See API.md for examples.
82
- *
83
- * @param node - The root node to start walking from
84
- * @param options - Object with optional enter and leave callback functions
85
- */
86
- function traverse(node, { enter = NOOP, leave = NOOP } = {}) {
87
- const enter_result = enter(node);
88
- if (enter_result === BREAK) return false;
89
- if (enter_result !== SKIP) {
90
- let child = node.first_child;
91
- while (child) {
92
- if (!traverse(child, {
93
- enter,
94
- leave
95
- })) return false;
96
- child = child.next_sibling;
97
- }
98
- }
99
- if (leave(node) === BREAK) return false;
100
- return true;
101
- }
102
- //#endregion
10
+ import { NODE_TYPES } from "./constants.js";
11
+ import { BREAK, SKIP, traverse, walk } from "./walk.js";
103
12
  export { ATTRIBUTE_SELECTOR, ATTR_FLAG_CASE_INSENSITIVE, ATTR_FLAG_CASE_SENSITIVE, ATTR_FLAG_NAMES, ATTR_FLAG_NONE, ATTR_OPERATOR_CARET_EQUAL, ATTR_OPERATOR_DOLLAR_EQUAL, ATTR_OPERATOR_EQUAL, ATTR_OPERATOR_NAMES, ATTR_OPERATOR_NONE, ATTR_OPERATOR_PIPE_EQUAL, ATTR_OPERATOR_STAR_EQUAL, ATTR_OPERATOR_TILDE_EQUAL, AT_RULE, AT_RULE_PRELUDE, BLOCK, BREAK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, CSSNode, 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_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, UNIVERSAL_SELECTOR, URL, VALUE, is_custom, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
@@ -1,4 +1,5 @@
1
- import { E as CSSDataArena, r as CSSNode } from "./css-node-DqyvMXBN.js";
1
+ import { y as CSSDataArena } from "./arena-BtlVZlkG.js";
2
+ import { r as CSSNode } from "./css-node-B9tSb6YD.js";
2
3
 
3
4
  //#region src/parse-anplusb.d.ts
4
5
  /** @internal */
@@ -1,6 +1,7 @@
1
- import { t as Lexer } from "./tokenize-BQFB1jXg.js";
2
- import { C as CSSDataArena, r as CSSNode } from "./css-node-Uj4oBgaw.js";
1
+ import { t as Lexer } from "./tokenize-BSycRGm0.js";
2
+ import { y as CSSDataArena } from "./arena-CDAx4eAB.js";
3
3
  import { o as str_equals, s as str_index_of } from "./parse-dimension-CCn_XRDe.js";
4
+ import { r as CSSNode } from "./css-node-CZf-PvCf.js";
4
5
  //#region src/parse-anplusb.ts
5
6
  /** @internal */
6
7
  var ANplusBParser = class {
@@ -1,4 +1,5 @@
1
- import { E as CSSDataArena, r as CSSNode } from "./css-node-DqyvMXBN.js";
1
+ import { y as CSSDataArena } from "./arena-BtlVZlkG.js";
2
+ import { r as CSSNode } from "./css-node-B9tSb6YD.js";
2
3
 
3
4
  //#region src/parse-atrule-prelude.d.ts
4
5
  /** @internal */
@@ -1,7 +1,8 @@
1
- import { t as Lexer } from "./tokenize-BQFB1jXg.js";
2
- import { C as CSSDataArena, r as CSSNode } from "./css-node-Uj4oBgaw.js";
1
+ import { t as Lexer } from "./tokenize-BSycRGm0.js";
2
+ import { y as CSSDataArena } from "./arena-CDAx4eAB.js";
3
3
  import { a as is_whitespace, l as strip_vendor_prefix, o as str_equals } from "./parse-dimension-CCn_XRDe.js";
4
- import { i as trim_boundaries, n as skip_whitespace_and_comments_forward } from "./parse-utils-DnsZRpfd.js";
4
+ import { r as CSSNode } from "./css-node-CZf-PvCf.js";
5
+ import { i as trim_boundaries, n as skip_whitespace_and_comments_forward } from "./parse-utils-BxrmqJxI.js";
5
6
  //#region src/parse-atrule-prelude.ts
6
7
  /** @internal */
7
8
  var AtRulePreludeParser = class {
@@ -1,5 +1,6 @@
1
- import { n as Lexer } from "./tokenize-odLrcjj2.js";
2
- import { E as CSSDataArena, r as CSSNode } from "./css-node-DqyvMXBN.js";
1
+ import { y as CSSDataArena } from "./arena-BtlVZlkG.js";
2
+ import { n as Lexer } from "./tokenize-CyiJelQC.js";
3
+ import { r as CSSNode } from "./css-node-B9tSb6YD.js";
3
4
 
4
5
  //#region src/parse-declaration.d.ts
5
6
  /** @internal */
@@ -1,7 +1,8 @@
1
- import { t as Lexer } from "./tokenize-BQFB1jXg.js";
2
- import { C as CSSDataArena, r as CSSNode } from "./css-node-Uj4oBgaw.js";
1
+ import { t as Lexer } from "./tokenize-BSycRGm0.js";
2
+ import { y as CSSDataArena } from "./arena-CDAx4eAB.js";
3
3
  import { i as is_vendor_prefixed } from "./parse-dimension-CCn_XRDe.js";
4
- import { i as trim_boundaries } from "./parse-utils-DnsZRpfd.js";
4
+ import { r as CSSNode } from "./css-node-CZf-PvCf.js";
5
+ import { i as trim_boundaries } from "./parse-utils-BxrmqJxI.js";
5
6
  import { ValueParser } from "./parse-value.js";
6
7
  //#region src/parse-declaration.ts
7
8
  /** @internal */
@@ -21,7 +22,9 @@ var DeclarationParser = class {
21
22
  return this.parse_declaration_with_lexer(lexer, end);
22
23
  }
23
24
  parse_declaration_with_lexer(lexer, end) {
25
+ const initial_saved = lexer.save_position();
24
26
  let has_browser_hack = false;
27
+ let has_delimiter_prefix = false;
25
28
  let browser_hack_start = 0;
26
29
  let browser_hack_line = 1;
27
30
  let browser_hack_column = 1;
@@ -51,8 +54,10 @@ var DeclarationParser = class {
51
54
  browser_hack_line = lexer.token_line;
52
55
  browser_hack_column = lexer.token_column;
53
56
  lexer.next_token_fast(true);
54
- if (lexer.token_type === 1) has_browser_hack = true;
55
- else lexer.restore_position(delim_saved);
57
+ if (lexer.token_type === 1) {
58
+ has_browser_hack = true;
59
+ has_delimiter_prefix = true;
60
+ } else lexer.restore_position(delim_saved);
56
61
  }
57
62
  if (lexer.token_type !== 1 && lexer.token_type !== 3 && lexer.token_type !== 4) return null;
58
63
  let prop_start = has_browser_hack ? browser_hack_start : lexer.token_start;
@@ -62,7 +67,7 @@ var DeclarationParser = class {
62
67
  const saved = lexer.save_position();
63
68
  lexer.next_token_fast(true);
64
69
  if (lexer.token_type !== 16) {
65
- lexer.restore_position(saved);
70
+ lexer.restore_position(has_delimiter_prefix ? initial_saved : saved);
66
71
  return null;
67
72
  }
68
73
  lexer.next_token_fast(true);
@@ -1,4 +1,5 @@
1
- import { E as CSSDataArena, r as CSSNode } from "./css-node-DqyvMXBN.js";
1
+ import { y as CSSDataArena } from "./arena-BtlVZlkG.js";
2
+ import { r as CSSNode } from "./css-node-B9tSb6YD.js";
2
3
 
3
4
  //#region src/parse-selector.d.ts
4
5
  /** @internal */
@@ -1,7 +1,8 @@
1
- import { t as Lexer } from "./tokenize-BQFB1jXg.js";
2
- import { C as CSSDataArena, r as CSSNode } from "./css-node-Uj4oBgaw.js";
1
+ import { t as Lexer } from "./tokenize-BSycRGm0.js";
2
+ import { y as CSSDataArena } from "./arena-CDAx4eAB.js";
3
3
  import { a as is_whitespace, n as is_combinator, o as str_equals } from "./parse-dimension-CCn_XRDe.js";
4
- import { n as skip_whitespace_and_comments_forward, r as skip_whitespace_forward, t as skip_whitespace_and_comments_backward } from "./parse-utils-DnsZRpfd.js";
4
+ import { r as CSSNode } from "./css-node-CZf-PvCf.js";
5
+ import { n as skip_whitespace_and_comments_forward, r as skip_whitespace_forward, t as skip_whitespace_and_comments_backward } from "./parse-utils-BxrmqJxI.js";
5
6
  import { ANplusBParser } from "./parse-anplusb.js";
6
7
  //#region src/parse-selector.ts
7
8
  /** @internal */
@@ -163,6 +164,7 @@ var SelectorParser = class {
163
164
  return node;
164
165
  }
165
166
  parse_type_or_namespace_selector(start, end) {
167
+ if (this.source.charCodeAt(start) === 45 && this.source.charCodeAt(start + 1) === 45) return null;
166
168
  const saved = this.lexer.save_position();
167
169
  this.skip_whitespace();
168
170
  if (this.lexer.pos < this.selector_end && this.source.charCodeAt(this.lexer.pos) === 124) {
@@ -1,4 +1,5 @@
1
- import { E as CSSDataArena, r as CSSNode } from "./css-node-DqyvMXBN.js";
1
+ import { y as CSSDataArena } from "./arena-BtlVZlkG.js";
2
+ import { r as CSSNode } from "./css-node-B9tSb6YD.js";
2
3
 
3
4
  //#region src/parse-value.d.ts
4
5
  /** @internal */
@@ -1,6 +1,7 @@
1
- import { t as Lexer } from "./tokenize-BQFB1jXg.js";
2
- import { C as CSSDataArena, r as CSSNode } from "./css-node-Uj4oBgaw.js";
1
+ import { t as Lexer } from "./tokenize-BSycRGm0.js";
2
+ import { y as CSSDataArena } from "./arena-CDAx4eAB.js";
3
3
  import { a as is_whitespace, o as str_equals } from "./parse-dimension-CCn_XRDe.js";
4
+ import { r as CSSNode } from "./css-node-CZf-PvCf.js";
4
5
  //#region src/parse-value.ts
5
6
  /** @internal */
6
7
  var ValueParser = class {
package/dist/parse.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { t as CommentInfo } from "./tokenize-odLrcjj2.js";
2
- import { E as CSSDataArena, r as CSSNode } from "./css-node-DqyvMXBN.js";
1
+ import { y as CSSDataArena } from "./arena-BtlVZlkG.js";
2
+ import { t as CommentInfo } from "./tokenize-CyiJelQC.js";
3
+ import { r as CSSNode } from "./css-node-B9tSb6YD.js";
3
4
 
4
5
  //#region src/parse.d.ts
5
6
  interface ParserOptions {
package/dist/parse.js CHANGED
@@ -1,6 +1,7 @@
1
- import { t as Lexer } from "./tokenize-BQFB1jXg.js";
2
- import { C as CSSDataArena, r as CSSNode } from "./css-node-Uj4oBgaw.js";
3
- import { i as trim_boundaries } from "./parse-utils-DnsZRpfd.js";
1
+ import { t as Lexer } from "./tokenize-BSycRGm0.js";
2
+ import { y as CSSDataArena } from "./arena-CDAx4eAB.js";
3
+ import { r as CSSNode } from "./css-node-CZf-PvCf.js";
4
+ import { i as trim_boundaries } from "./parse-utils-BxrmqJxI.js";
4
5
  import { SelectorParser } from "./parse-selector.js";
5
6
  import { AtRulePreludeParser } from "./parse-atrule-prelude.js";
6
7
  import { DeclarationParser } from "./parse-declaration.js";
@@ -1,23 +1,26 @@
1
+ //#region src/char-types.ts
2
+ let CHAR_ALPHA = 1;
3
+ let CHAR_HEX = 4;
1
4
  let char_types = new Uint8Array(128);
2
5
  for (let i = 48; i <= 57; i++) char_types[i] = 2;
3
- for (let i = 48; i <= 57; i++) char_types[i] |= 4;
4
- for (let i = 65; i <= 70; i++) char_types[i] = 4;
5
- for (let i = 97; i <= 102; i++) char_types[i] = 4;
6
- for (let i = 65; i <= 90; i++) char_types[i] |= 1;
7
- for (let i = 97; i <= 122; i++) char_types[i] |= 1;
6
+ for (let i = 48; i <= 57; i++) char_types[i] |= CHAR_HEX;
7
+ for (let i = 65; i <= 70; i++) char_types[i] = CHAR_HEX;
8
+ for (let i = 97; i <= 102; i++) char_types[i] = CHAR_HEX;
9
+ for (let i = 65; i <= 90; i++) char_types[i] |= CHAR_ALPHA;
10
+ for (let i = 97; i <= 122; i++) char_types[i] |= CHAR_ALPHA;
8
11
  char_types[32] = 8;
9
12
  char_types[9] = 8;
10
13
  char_types[10] = 16;
11
14
  char_types[13] = 16;
12
15
  char_types[12] = 16;
13
- for (let i = 0; i < 128; i++) if (char_types[i] & 3) char_types[i] |= 32;
16
+ for (let i = 0; i < 128; i++) if (char_types[i] & (CHAR_ALPHA | 2)) char_types[i] |= 32;
14
17
  char_types[45] |= 32;
15
18
  char_types[95] |= 32;
16
19
  function is_hex_digit(ch) {
17
- return ch < 128 && (char_types[ch] & 4) !== 0;
20
+ return ch < 128 && (char_types[ch] & CHAR_HEX) !== 0;
18
21
  }
19
22
  function is_alpha(ch) {
20
- return ch < 128 && (char_types[ch] & 1) !== 0;
23
+ return ch < 128 && (char_types[ch] & CHAR_ALPHA) !== 0;
21
24
  }
22
25
  function is_whitespace(ch) {
23
26
  return ch < 128 && (char_types[ch] & 8) !== 0;
@@ -1,2 +1,2 @@
1
- import { i as tokenize, n as Lexer, r as LexerPosition, t as CommentInfo } from "./tokenize-odLrcjj2.js";
1
+ import { i as tokenize, n as Lexer, r as LexerPosition, t as CommentInfo } from "./tokenize-CyiJelQC.js";
2
2
  export { CommentInfo, Lexer, LexerPosition, tokenize };