@projectwallace/css-parser 0.8.8 → 0.8.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.
@@ -81,8 +81,6 @@ export declare class CSSNode {
81
81
  private source;
82
82
  private index;
83
83
  constructor(arena: CSSDataArena, source: string, index: number);
84
- /** Get the arena (for internal/advanced use only) */
85
- __get_arena(): CSSDataArena;
86
84
  /** Get node type as number (for performance) */
87
85
  get type(): CSSNodeType;
88
86
  /** Get node type as human-readable string */
package/dist/css-node.js CHANGED
@@ -49,7 +49,10 @@ class CSSNode {
49
49
  this.source = source;
50
50
  this.index = index;
51
51
  }
52
- /** Get the arena (for internal/advanced use only) */
52
+ /**
53
+ * @internal
54
+ * Get the arena (for internal/advanced use only)
55
+ */
53
56
  __get_arena() {
54
57
  return this.arena;
55
58
  }
@@ -1,6 +1,6 @@
1
1
  import { Lexer } from './tokenize.js';
2
- import { CSSDataArena, PRELUDE_OPERATOR, MEDIA_TYPE, MEDIA_QUERY, MEDIA_FEATURE, IDENTIFIER, CONTAINER_QUERY, SUPPORTS_QUERY, LAYER_NAME, URL } from './arena.js';
3
- import { TOKEN_COMMA, TOKEN_IDENT, TOKEN_LEFT_PAREN, TOKEN_RIGHT_PAREN, TOKEN_WHITESPACE, TOKEN_URL, TOKEN_FUNCTION, TOKEN_STRING, TOKEN_EOF } from './token-types.js';
2
+ import { CSSDataArena, PRELUDE_OPERATOR, MEDIA_TYPE, MEDIA_QUERY, MEDIA_FEATURE, FUNCTION, IDENTIFIER, CONTAINER_QUERY, SUPPORTS_QUERY, LAYER_NAME, URL } from './arena.js';
3
+ import { TOKEN_COMMA, TOKEN_IDENT, TOKEN_LEFT_PAREN, TOKEN_RIGHT_PAREN, TOKEN_FUNCTION, TOKEN_EOF, TOKEN_WHITESPACE, TOKEN_URL, TOKEN_STRING } from './token-types.js';
4
4
  import { str_equals } from './string-utils.js';
5
5
  import { trim_boundaries, skip_whitespace_forward } from './parse-utils.js';
6
6
  import { CSSNode } from './css-node.js';
@@ -153,6 +153,34 @@ class AtRulePreludeParser {
153
153
  if (feature !== null) {
154
154
  components.push(feature);
155
155
  }
156
+ } else if (token_type === TOKEN_FUNCTION) {
157
+ let func_name = this.source.substring(this.lexer.token_start, this.lexer.token_end - 1);
158
+ let func_start = this.lexer.token_start;
159
+ let content_start = this.lexer.token_end;
160
+ let paren_depth = 1;
161
+ let func_end = this.lexer.token_end;
162
+ let content_end = content_start;
163
+ while (this.lexer.pos < this.prelude_end && paren_depth > 0) {
164
+ this.next_token();
165
+ let inner_token = this.lexer.token_type;
166
+ if (inner_token === TOKEN_LEFT_PAREN || inner_token === TOKEN_FUNCTION) {
167
+ paren_depth++;
168
+ } else if (inner_token === TOKEN_RIGHT_PAREN) {
169
+ paren_depth--;
170
+ if (paren_depth === 0) {
171
+ content_end = this.lexer.token_start;
172
+ func_end = this.lexer.token_end;
173
+ }
174
+ } else if (inner_token === TOKEN_EOF) {
175
+ break;
176
+ }
177
+ }
178
+ let func_node = this.create_node(FUNCTION, func_start, func_end);
179
+ this.arena.set_content_start_delta(func_node, 0);
180
+ this.arena.set_content_length(func_node, func_name.length);
181
+ this.arena.set_value_start_delta(func_node, content_start - func_start);
182
+ this.arena.set_value_length(func_node, content_end - content_start);
183
+ components.push(func_node);
156
184
  } else if (token_type === TOKEN_IDENT) {
157
185
  let text = this.source.substring(this.lexer.token_start, this.lexer.token_end);
158
186
  if (this.is_and_or_not(text)) {
@@ -222,6 +250,8 @@ class AtRulePreludeParser {
222
250
  let token_type = this.lexer.token_type;
223
251
  if (token_type === TOKEN_IDENT) {
224
252
  let layer = this.create_node(LAYER_NAME, this.lexer.token_start, this.lexer.token_end);
253
+ this.arena.set_value_start_delta(layer, 0);
254
+ this.arena.set_value_length(layer, this.lexer.token_end - this.lexer.token_start);
225
255
  nodes.push(layer);
226
256
  } else if (token_type === TOKEN_COMMA) {
227
257
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectwallace/css-parser",
3
- "version": "0.8.8",
3
+ "version": "0.8.10",
4
4
  "description": "High-performance CSS lexer and parser, optimized for CSS inspection and analysis",
5
5
  "author": "Bart Veneman <bart@projectwallace.com>",
6
6
  "license": "MIT",