@projectwallace/css-parser 0.3.0 → 0.4.0
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.d.ts +1 -0
- package/dist/{at-rule-prelude-parser-pzWB6S0z.js → at-rule-prelude-parser-Cj8ecgQp.js} +1 -1
- package/dist/css-node.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/parse-atrule-prelude.js +2 -2
- package/dist/parse-selector.js +2 -2
- package/dist/parse.js +5 -9
- package/dist/parser.d.ts +1 -1
- package/dist/{selector-parser-CwNLN7Us.js → selector-parser-Wo-1tJbU.js} +1 -1
- package/dist/{string-utils-5j619JDp.js → string-utils-tMt2O9RW.js} +6 -1
- package/package.json +1 -1
package/dist/arena.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export declare const FLAG_HAS_ERROR: number;
|
|
|
37
37
|
export declare const FLAG_LENGTH_OVERFLOW: number;
|
|
38
38
|
export declare const FLAG_HAS_BLOCK: number;
|
|
39
39
|
export declare const FLAG_VENDOR_PREFIXED: number;
|
|
40
|
+
export declare const FLAG_HAS_DECLARATIONS: number;
|
|
40
41
|
export declare class CSSDataArena {
|
|
41
42
|
private buffer;
|
|
42
43
|
private view;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { L as Lexer, q as TOKEN_COMMA, T as TOKEN_IDENT, t as TOKEN_LEFT_PAREN, u as TOKEN_RIGHT_PAREN, l as TOKEN_WHITESPACE, f as TOKEN_URL, a as TOKEN_FUNCTION, d as TOKEN_STRING, y as TOKEN_EOF } from './lexer-DXablYMZ.js';
|
|
2
|
-
import {
|
|
2
|
+
import { R as str_equals, E as NODE_PRELUDE_OPERATOR, y as NODE_PRELUDE_MEDIA_TYPE, w as NODE_PRELUDE_MEDIA_QUERY, x as NODE_PRELUDE_MEDIA_FEATURE, Q as trim_boundaries, D as NODE_PRELUDE_IDENTIFIER, z as NODE_PRELUDE_CONTAINER_QUERY, A as NODE_PRELUDE_SUPPORTS_QUERY, B as NODE_PRELUDE_LAYER_NAME, F as NODE_PRELUDE_IMPORT_URL, G as NODE_PRELUDE_IMPORT_LAYER, H as NODE_PRELUDE_IMPORT_SUPPORTS, S as CHAR_SPACE, T as CHAR_TAB, U as CHAR_NEWLINE, V as CHAR_CARRIAGE_RETURN, W as CHAR_FORM_FEED } from './string-utils-tMt2O9RW.js';
|
|
3
3
|
|
|
4
4
|
class AtRulePreludeParser {
|
|
5
5
|
lexer;
|
package/dist/css-node.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { parse } from './parse.js';
|
|
|
2
2
|
export { parse_selector } from './parse-selector.js';
|
|
3
3
|
export { parse_atrule_prelude } from './parse-atrule-prelude.js';
|
|
4
4
|
export { tokenize } from './tokenize.js';
|
|
5
|
-
export { C as CSSNode, I as FLAG_IMPORTANT, a as NODE_AT_RULE, b as NODE_COMMENT, c as NODE_DECLARATION, z as NODE_PRELUDE_CONTAINER_QUERY, D as NODE_PRELUDE_IDENTIFIER, G as NODE_PRELUDE_IMPORT_LAYER, H as NODE_PRELUDE_IMPORT_SUPPORTS, F as NODE_PRELUDE_IMPORT_URL, B as NODE_PRELUDE_LAYER_NAME, x as NODE_PRELUDE_MEDIA_FEATURE, w as NODE_PRELUDE_MEDIA_QUERY, y as NODE_PRELUDE_MEDIA_TYPE, E as NODE_PRELUDE_OPERATOR, A as NODE_PRELUDE_SUPPORTS_QUERY, d as NODE_SELECTOR, q as NODE_SELECTOR_ATTRIBUTE, o as NODE_SELECTOR_CLASS, t as NODE_SELECTOR_COMBINATOR, p as NODE_SELECTOR_ID, m as NODE_SELECTOR_LIST, v as NODE_SELECTOR_NESTING, r as NODE_SELECTOR_PSEUDO_CLASS, s as NODE_SELECTOR_PSEUDO_ELEMENT, n as NODE_SELECTOR_TYPE, u as NODE_SELECTOR_UNIVERSAL, e as NODE_STYLESHEET, N as NODE_STYLE_RULE, j as NODE_VALUE_COLOR, h as NODE_VALUE_DIMENSION, k as NODE_VALUE_FUNCTION, f as NODE_VALUE_KEYWORD, g as NODE_VALUE_NUMBER, l as NODE_VALUE_OPERATOR, i as NODE_VALUE_STRING } from './string-utils-
|
|
5
|
+
export { C as CSSNode, I as FLAG_IMPORTANT, a as NODE_AT_RULE, b as NODE_COMMENT, c as NODE_DECLARATION, z as NODE_PRELUDE_CONTAINER_QUERY, D as NODE_PRELUDE_IDENTIFIER, G as NODE_PRELUDE_IMPORT_LAYER, H as NODE_PRELUDE_IMPORT_SUPPORTS, F as NODE_PRELUDE_IMPORT_URL, B as NODE_PRELUDE_LAYER_NAME, x as NODE_PRELUDE_MEDIA_FEATURE, w as NODE_PRELUDE_MEDIA_QUERY, y as NODE_PRELUDE_MEDIA_TYPE, E as NODE_PRELUDE_OPERATOR, A as NODE_PRELUDE_SUPPORTS_QUERY, d as NODE_SELECTOR, q as NODE_SELECTOR_ATTRIBUTE, o as NODE_SELECTOR_CLASS, t as NODE_SELECTOR_COMBINATOR, p as NODE_SELECTOR_ID, m as NODE_SELECTOR_LIST, v as NODE_SELECTOR_NESTING, r as NODE_SELECTOR_PSEUDO_CLASS, s as NODE_SELECTOR_PSEUDO_ELEMENT, n as NODE_SELECTOR_TYPE, u as NODE_SELECTOR_UNIVERSAL, e as NODE_STYLESHEET, N as NODE_STYLE_RULE, j as NODE_VALUE_COLOR, h as NODE_VALUE_DIMENSION, k as NODE_VALUE_FUNCTION, f as NODE_VALUE_KEYWORD, g as NODE_VALUE_NUMBER, l as NODE_VALUE_OPERATOR, i as NODE_VALUE_STRING } from './string-utils-tMt2O9RW.js';
|
|
6
6
|
export { b as TOKEN_AT_KEYWORD, e as TOKEN_BAD_STRING, g as TOKEN_BAD_URL, n as TOKEN_CDC, m as TOKEN_CDO, o as TOKEN_COLON, q as TOKEN_COMMA, x as TOKEN_COMMENT, h as TOKEN_DELIM, k as TOKEN_DIMENSION, y as TOKEN_EOF, a as TOKEN_FUNCTION, c as TOKEN_HASH, T as TOKEN_IDENT, v as TOKEN_LEFT_BRACE, r as TOKEN_LEFT_BRACKET, t as TOKEN_LEFT_PAREN, i as TOKEN_NUMBER, j as TOKEN_PERCENTAGE, w as TOKEN_RIGHT_BRACE, s as TOKEN_RIGHT_BRACKET, u as TOKEN_RIGHT_PAREN, p as TOKEN_SEMICOLON, d as TOKEN_STRING, f as TOKEN_URL, l as TOKEN_WHITESPACE } from './lexer-DXablYMZ.js';
|
|
7
7
|
|
|
8
8
|
function walk(node, callback, depth = 0) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as CSSDataArena, C as CSSNode } from './string-utils-
|
|
2
|
-
import { A as AtRulePreludeParser } from './at-rule-prelude-parser-
|
|
1
|
+
import { K as CSSDataArena, C as CSSNode } from './string-utils-tMt2O9RW.js';
|
|
2
|
+
import { A as AtRulePreludeParser } from './at-rule-prelude-parser-Cj8ecgQp.js';
|
|
3
3
|
|
|
4
4
|
function parse_atrule_prelude(at_rule_name, prelude) {
|
|
5
5
|
const arena = new CSSDataArena(CSSDataArena.capacity_for_source(prelude.length));
|
package/dist/parse-selector.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as CSSDataArena, d as NODE_SELECTOR, C as CSSNode } from './string-utils-
|
|
2
|
-
import { S as SelectorParser } from './selector-parser-
|
|
1
|
+
import { K as CSSDataArena, d as NODE_SELECTOR, C as CSSNode } from './string-utils-tMt2O9RW.js';
|
|
2
|
+
import { S as SelectorParser } from './selector-parser-Wo-1tJbU.js';
|
|
3
3
|
|
|
4
4
|
function parse_selector(source) {
|
|
5
5
|
const arena = new CSSDataArena(CSSDataArena.capacity_for_source(source.length));
|
package/dist/parse.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { L as Lexer, y as TOKEN_EOF, q as TOKEN_COMMA, h as TOKEN_DELIM, a as TOKEN_FUNCTION, c as TOKEN_HASH, d as TOKEN_STRING, k as TOKEN_DIMENSION, j as TOKEN_PERCENTAGE, i as TOKEN_NUMBER, T as TOKEN_IDENT, t as TOKEN_LEFT_PAREN, u as TOKEN_RIGHT_PAREN, b as TOKEN_AT_KEYWORD, v as TOKEN_LEFT_BRACE, w as TOKEN_RIGHT_BRACE, o as TOKEN_COLON, p as TOKEN_SEMICOLON } from './lexer-DXablYMZ.js';
|
|
2
|
-
import { J as is_whitespace, f as NODE_VALUE_KEYWORD, g as NODE_VALUE_NUMBER, h as NODE_VALUE_DIMENSION, i as NODE_VALUE_STRING, j as NODE_VALUE_COLOR, l as NODE_VALUE_OPERATOR, k as NODE_VALUE_FUNCTION, K as CSSDataArena, e as NODE_STYLESHEET, C as CSSNode, N as NODE_STYLE_RULE, L as FLAG_HAS_BLOCK, d as NODE_SELECTOR, c as NODE_DECLARATION,
|
|
3
|
-
import { S as SelectorParser } from './selector-parser-
|
|
4
|
-
import { A as AtRulePreludeParser } from './at-rule-prelude-parser-
|
|
2
|
+
import { J as is_whitespace, f as NODE_VALUE_KEYWORD, g as NODE_VALUE_NUMBER, h as NODE_VALUE_DIMENSION, i as NODE_VALUE_STRING, j as NODE_VALUE_COLOR, l as NODE_VALUE_OPERATOR, k as NODE_VALUE_FUNCTION, K as CSSDataArena, e as NODE_STYLESHEET, C as CSSNode, N as NODE_STYLE_RULE, L as FLAG_HAS_BLOCK, M as FLAG_HAS_DECLARATIONS, d as NODE_SELECTOR, c as NODE_DECLARATION, O as is_vendor_prefixed, P as FLAG_VENDOR_PREFIXED, Q as trim_boundaries, I as FLAG_IMPORTANT, a as NODE_AT_RULE } from './string-utils-tMt2O9RW.js';
|
|
3
|
+
import { S as SelectorParser } from './selector-parser-Wo-1tJbU.js';
|
|
4
|
+
import { A as AtRulePreludeParser } from './at-rule-prelude-parser-Cj8ecgQp.js';
|
|
5
5
|
|
|
6
6
|
const CH_PLUS = 43;
|
|
7
7
|
const CH_MINUS = 45;
|
|
@@ -195,12 +195,7 @@ class Parser {
|
|
|
195
195
|
parse_atrule_preludes_enabled;
|
|
196
196
|
constructor(source, options) {
|
|
197
197
|
this.source = source;
|
|
198
|
-
let opts;
|
|
199
|
-
if (typeof options === "boolean") {
|
|
200
|
-
opts = { skip_comments: options };
|
|
201
|
-
} else {
|
|
202
|
-
opts = options || {};
|
|
203
|
-
}
|
|
198
|
+
let opts = options || {};
|
|
204
199
|
let skip_comments = opts.skip_comments ?? true;
|
|
205
200
|
this.parse_values_enabled = opts.parse_values ?? true;
|
|
206
201
|
this.parse_selectors_enabled = opts.parse_selectors ?? true;
|
|
@@ -294,6 +289,7 @@ class Parser {
|
|
|
294
289
|
}
|
|
295
290
|
let declaration = this.parse_declaration();
|
|
296
291
|
if (declaration !== null) {
|
|
292
|
+
this.arena.set_flag(style_rule, FLAG_HAS_DECLARATIONS);
|
|
297
293
|
this.arena.append_child(style_rule, declaration);
|
|
298
294
|
continue;
|
|
299
295
|
}
|
package/dist/parser.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare class Parser {
|
|
|
16
16
|
private parse_values_enabled;
|
|
17
17
|
private parse_selectors_enabled;
|
|
18
18
|
private parse_atrule_preludes_enabled;
|
|
19
|
-
constructor(source: string, options?: ParserOptions
|
|
19
|
+
constructor(source: string, options?: ParserOptions);
|
|
20
20
|
get_arena(): CSSDataArena;
|
|
21
21
|
get_source(): string;
|
|
22
22
|
private next_token;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { L as Lexer, q as TOKEN_COMMA, y as TOKEN_EOF, l as TOKEN_WHITESPACE, a as TOKEN_FUNCTION, o as TOKEN_COLON, r as TOKEN_LEFT_BRACKET, h as TOKEN_DELIM, c as TOKEN_HASH, T as TOKEN_IDENT, s as TOKEN_RIGHT_BRACKET, t as TOKEN_LEFT_PAREN, u as TOKEN_RIGHT_PAREN } from './lexer-DXablYMZ.js';
|
|
2
|
-
import { d as NODE_SELECTOR, m as NODE_SELECTOR_LIST, J as is_whitespace, o as NODE_SELECTOR_CLASS, q as NODE_SELECTOR_ATTRIBUTE,
|
|
2
|
+
import { d as NODE_SELECTOR, m as NODE_SELECTOR_LIST, J as is_whitespace, o as NODE_SELECTOR_CLASS, q as NODE_SELECTOR_ATTRIBUTE, Q as trim_boundaries, s as NODE_SELECTOR_PSEUDO_ELEMENT, r as NODE_SELECTOR_PSEUDO_CLASS, O as is_vendor_prefixed, P as FLAG_VENDOR_PREFIXED, n as NODE_SELECTOR_TYPE, p as NODE_SELECTOR_ID, u as NODE_SELECTOR_UNIVERSAL, v as NODE_SELECTOR_NESTING, t as NODE_SELECTOR_COMBINATOR } from './string-utils-tMt2O9RW.js';
|
|
3
3
|
|
|
4
4
|
class SelectorParser {
|
|
5
5
|
lexer;
|
|
@@ -37,6 +37,7 @@ const FLAG_IMPORTANT = 1 << 0;
|
|
|
37
37
|
const FLAG_HAS_ERROR = 1 << 1;
|
|
38
38
|
const FLAG_HAS_BLOCK = 1 << 3;
|
|
39
39
|
const FLAG_VENDOR_PREFIXED = 1 << 4;
|
|
40
|
+
const FLAG_HAS_DECLARATIONS = 1 << 5;
|
|
40
41
|
class CSSDataArena {
|
|
41
42
|
buffer;
|
|
42
43
|
view;
|
|
@@ -307,6 +308,10 @@ class CSSNode {
|
|
|
307
308
|
get has_block() {
|
|
308
309
|
return this.arena.has_flag(this.index, FLAG_HAS_BLOCK);
|
|
309
310
|
}
|
|
311
|
+
// Check if this style rule has declarations
|
|
312
|
+
get has_declarations() {
|
|
313
|
+
return this.arena.has_flag(this.index, FLAG_HAS_DECLARATIONS);
|
|
314
|
+
}
|
|
310
315
|
// --- Value Node Access (for declarations) ---
|
|
311
316
|
// Get array of parsed value nodes (for declarations only)
|
|
312
317
|
get values() {
|
|
@@ -463,4 +468,4 @@ function is_vendor_prefixed(source, start, end) {
|
|
|
463
468
|
return secondHyphenPos !== -1 && secondHyphenPos < end;
|
|
464
469
|
}
|
|
465
470
|
|
|
466
|
-
export { NODE_PRELUDE_SUPPORTS_QUERY as A, NODE_PRELUDE_LAYER_NAME as B, CSSNode as C, NODE_PRELUDE_IDENTIFIER as D, NODE_PRELUDE_OPERATOR as E, NODE_PRELUDE_IMPORT_URL as F, NODE_PRELUDE_IMPORT_LAYER as G, NODE_PRELUDE_IMPORT_SUPPORTS as H, FLAG_IMPORTANT as I, is_whitespace as J, CSSDataArena as K, FLAG_HAS_BLOCK as L,
|
|
471
|
+
export { NODE_PRELUDE_SUPPORTS_QUERY as A, NODE_PRELUDE_LAYER_NAME as B, CSSNode as C, NODE_PRELUDE_IDENTIFIER as D, NODE_PRELUDE_OPERATOR as E, NODE_PRELUDE_IMPORT_URL as F, NODE_PRELUDE_IMPORT_LAYER as G, NODE_PRELUDE_IMPORT_SUPPORTS as H, FLAG_IMPORTANT as I, is_whitespace as J, CSSDataArena as K, FLAG_HAS_BLOCK as L, FLAG_HAS_DECLARATIONS as M, NODE_STYLE_RULE as N, is_vendor_prefixed as O, FLAG_VENDOR_PREFIXED as P, trim_boundaries as Q, str_equals as R, CHAR_SPACE as S, CHAR_TAB as T, CHAR_NEWLINE as U, CHAR_CARRIAGE_RETURN as V, CHAR_FORM_FEED as W, NODE_AT_RULE as a, NODE_COMMENT as b, NODE_DECLARATION as c, NODE_SELECTOR as d, NODE_STYLESHEET as e, NODE_VALUE_KEYWORD as f, NODE_VALUE_NUMBER as g, NODE_VALUE_DIMENSION as h, NODE_VALUE_STRING as i, NODE_VALUE_COLOR as j, NODE_VALUE_FUNCTION as k, NODE_VALUE_OPERATOR as l, NODE_SELECTOR_LIST as m, NODE_SELECTOR_TYPE as n, NODE_SELECTOR_CLASS as o, NODE_SELECTOR_ID as p, NODE_SELECTOR_ATTRIBUTE as q, NODE_SELECTOR_PSEUDO_CLASS as r, NODE_SELECTOR_PSEUDO_ELEMENT as s, NODE_SELECTOR_COMBINATOR as t, NODE_SELECTOR_UNIVERSAL as u, NODE_SELECTOR_NESTING as v, NODE_PRELUDE_MEDIA_QUERY as w, NODE_PRELUDE_MEDIA_FEATURE as x, NODE_PRELUDE_MEDIA_TYPE as y, NODE_PRELUDE_CONTAINER_QUERY as z };
|
package/package.json
CHANGED