@eslint/css-tree 4.1.3 → 4.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -201,7 +201,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
201
201
  to get your logo on our READMEs and [website](https://eslint.org/sponsors).
202
202
 
203
203
  <h3>Gold Sponsors</h3>
204
- <p><a href="#"><img src="https://images.opencollective.com/vite-ecosystem-fund/logo.png" alt="Vite Ecosystem Fund" height="96"></a> <a href="https://forceindexer.com"><img src="https://images.opencollective.com/forceindexer/588566e/logo.png" alt="ForceIndexer" height="96"></a> <a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a> <a href="https://www.coderabbit.ai/?utm_source=cr_org&utm_medium=github"><img src="https://avatars.githubusercontent.com/u/132028505" alt="CodeRabbit" height="96"></a> <a href="https://automattic.com"><img src="https://avatars.githubusercontent.com/u/887802" alt="Automattic" height="96"></a></p><h3>Silver Sponsors</h3>
204
+ <p><a href="#"><img src="https://images.opencollective.com/vite-ecosystem-fund/logo.png" alt="Vite Ecosystem Fund" height="96"></a> <a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a> <a href="https://www.coderabbit.ai/?utm_source=cr_org&utm_medium=github"><img src="https://avatars.githubusercontent.com/u/132028505" alt="CodeRabbit" height="96"></a> <a href="https://automattic.com"><img src="https://avatars.githubusercontent.com/u/887802" alt="Automattic" height="96"></a></p><h3>Silver Sponsors</h3>
205
205
  <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/d472863/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/2d6c3b6/logo.png" alt="Liftoff" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
206
206
  <p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://opensource.sap.com"><img src="https://avatars.githubusercontent.com/u/2531208" alt="SAP" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://citadel-ai.com"><img src="https://avatars.githubusercontent.com/u/75781367" alt="Citadel AI" height="32"></a> <a href="https://www.testmuai.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="TestMu AI Open Source Office (Formerly LambdaTest)" height="32"></a></p>
207
207
  <h3>Technology Sponsors</h3>
@@ -68,9 +68,13 @@ function parse() {
68
68
  }
69
69
  }
70
70
 
71
+ const loc = this.getLocation(start, this.tokenStart);
72
+
73
+ this.skipSC();
74
+
71
75
  return {
72
76
  type: 'MediaQuery',
73
- loc: this.getLocation(start, this.tokenStart),
77
+ loc,
74
78
  modifier,
75
79
  mediaType,
76
80
  condition
@@ -5,8 +5,8 @@ const utils = require('./utils.cjs');
5
5
  const names = require('./names.cjs');
6
6
  const types = require('./types.cjs');
7
7
 
8
- const OFFSET_MASK = 0x00FFFFFF;
9
- const TYPE_SHIFT = 24;
8
+ const OFFSET_MASK = 0x07FFFFFF;
9
+ const TYPE_SHIFT = 27;
10
10
  const BLOCK_OPEN_TOKEN = 1;
11
11
  const BLOCK_CLOSE_TOKEN = 2;
12
12
  const balancePair = new Uint8Array(32); // 32b of memory ought to be enough for anyone (any number of tokens)
@@ -43,6 +43,10 @@ class TokenStream {
43
43
  source = String(source || '');
44
44
 
45
45
  const sourceLength = source.length;
46
+ if (sourceLength > OFFSET_MASK) {
47
+ throw new RangeError('Source exceeds the maximum length of ' + OFFSET_MASK + ' UTF-16 code units');
48
+ }
49
+
46
50
  const offsetAndType = adoptBuffer.adoptBuffer(this.offsetAndType, source.length + 1); // +1 because of eof-token
47
51
  const balance = adoptBuffer.adoptBuffer(this.balance, source.length + 1);
48
52
  let tokenCount = 0;
@@ -53,7 +57,7 @@ class TokenStream {
53
57
  // capture buffers
54
58
  this.offsetAndType = null;
55
59
  this.balance = null;
56
- balance.fill(0);
60
+ balance.fill(0, 0, sourceLength + 1);
57
61
 
58
62
  tokenize(source, (type, start, end) => {
59
63
  const index = tokenCount++;
@@ -76,7 +80,7 @@ class TokenStream {
76
80
 
77
81
  // pop state
78
82
  balanceStart = prevBalanceStart;
79
- balanceCloseType = balancePair[offsetAndType[prevBalanceStart] >> TYPE_SHIFT];
83
+ balanceCloseType = balancePair[offsetAndType[prevBalanceStart] >>> TYPE_SHIFT];
80
84
  } else if (this.isBlockOpenerTokenType(type)) { // check for FunctionToken, <(-token>, <[-token> and <{-token>
81
85
  // push state
82
86
  balanceStart = index;
@@ -128,14 +132,14 @@ class TokenStream {
128
132
  offset += this.tokenIndex;
129
133
 
130
134
  if (offset < this.tokenCount) {
131
- return this.offsetAndType[offset] >> TYPE_SHIFT;
135
+ return this.offsetAndType[offset] >>> TYPE_SHIFT;
132
136
  }
133
137
 
134
138
  return types.EOF;
135
139
  }
136
140
  lookupTypeNonSC(idx) {
137
141
  for (let offset = this.tokenIndex; offset < this.tokenCount; offset++) {
138
- const tokenType = this.offsetAndType[offset] >> TYPE_SHIFT;
142
+ const tokenType = this.offsetAndType[offset] >>> TYPE_SHIFT;
139
143
 
140
144
  if (tokenType !== types.WhiteSpace && tokenType !== types.Comment) {
141
145
  if (idx-- === 0) {
@@ -157,7 +161,7 @@ class TokenStream {
157
161
  }
158
162
  lookupOffsetNonSC(idx) {
159
163
  for (let offset = this.tokenIndex; offset < this.tokenCount; offset++) {
160
- const tokenType = this.offsetAndType[offset] >> TYPE_SHIFT;
164
+ const tokenType = this.offsetAndType[offset] >>> TYPE_SHIFT;
161
165
 
162
166
  if (tokenType !== types.WhiteSpace && tokenType !== types.Comment) {
163
167
  if (idx-- === 0) {
@@ -207,7 +211,7 @@ class TokenStream {
207
211
  return this.tokenType;
208
212
  }
209
213
 
210
- return this.offsetAndType[boundIndex(tokenIndex, 0, this.tokenCount)] >> TYPE_SHIFT;
214
+ return this.offsetAndType[boundIndex(tokenIndex, 0, this.tokenCount)] >>> TYPE_SHIFT;
211
215
  }
212
216
  substrToCursor(start) {
213
217
  return this.source.substring(start, this.tokenStart);
@@ -263,7 +267,7 @@ class TokenStream {
263
267
  this.tokenIndex = next;
264
268
  this.tokenStart = this.offsetAndType[next - 1] & OFFSET_MASK;
265
269
  next = this.offsetAndType[next];
266
- this.tokenType = next >> TYPE_SHIFT;
270
+ this.tokenType = next >>> TYPE_SHIFT;
267
271
  this.tokenEnd = next & OFFSET_MASK;
268
272
  } else {
269
273
  this.tokenIndex = this.tokenCount;
@@ -277,7 +281,7 @@ class TokenStream {
277
281
  this.tokenIndex = next;
278
282
  this.tokenStart = this.tokenEnd;
279
283
  next = this.offsetAndType[next];
280
- this.tokenType = next >> TYPE_SHIFT;
284
+ this.tokenType = next >>> TYPE_SHIFT;
281
285
  this.tokenEnd = next & OFFSET_MASK;
282
286
  } else {
283
287
  this.eof = true;
@@ -318,7 +322,7 @@ class TokenStream {
318
322
 
319
323
  default:
320
324
  // fast forward to the end of balanced block for an open block tokens
321
- if (this.isBlockOpenerTokenType(this.offsetAndType[cursor] >> TYPE_SHIFT)) {
325
+ if (this.isBlockOpenerTokenType(this.offsetAndType[cursor] >>> TYPE_SHIFT)) {
322
326
  cursor = balanceEnd;
323
327
  }
324
328
  }
@@ -332,7 +336,7 @@ class TokenStream {
332
336
  const start = offset;
333
337
  const item = this.offsetAndType[i];
334
338
  const end = item & OFFSET_MASK;
335
- const type = item >> TYPE_SHIFT;
339
+ const type = item >>> TYPE_SHIFT;
336
340
 
337
341
  offset = end;
338
342
 
@@ -217,7 +217,7 @@ function consumeBadUrlRemnants(source, offset) {
217
217
  // Note: This allows an escaped right parenthesis ("\)") to be encountered
218
218
  // without ending the <bad-url-token>. This is otherwise identical to
219
219
  // the "anything else" clause.
220
- offset = consumeEscaped(source, offset);
220
+ offset = consumeEscaped(source, offset) - 1;
221
221
  }
222
222
  }
223
223
 
package/cjs/utils/url.cjs CHANGED
@@ -24,10 +24,14 @@ function decode(str) {
24
24
  end--;
25
25
  }
26
26
 
27
+ let runStart = start;
28
+
27
29
  for (let i = start; i <= end; i++) {
28
30
  let code = str.charCodeAt(i);
29
31
 
30
32
  if (code === REVERSE_SOLIDUS) {
33
+ decoded += str.slice(runStart, i);
34
+
31
35
  // special case at the ending
32
36
  if (i === end) {
33
37
  // if the next input code point is EOF, do nothing
@@ -35,7 +39,7 @@ function decode(str) {
35
39
  if (i !== len - 1) {
36
40
  decoded = str.substr(i + 1);
37
41
  }
38
- break;
42
+ return decoded;
39
43
  }
40
44
 
41
45
  code = str.charCodeAt(++i);
@@ -47,22 +51,24 @@ function decode(str) {
47
51
 
48
52
  i = escapeEnd - 1;
49
53
  decoded += utils.decodeEscaped(str.substring(escapeStart + 1, escapeEnd));
54
+ runStart = escapeEnd;
50
55
  } else {
51
56
  // \r\n
52
57
  if (code === 0x000d && str.charCodeAt(i + 1) === 0x000a) {
53
58
  i++;
54
59
  }
60
+
61
+ runStart = i + 1;
55
62
  }
56
- } else {
57
- decoded += str[i];
58
63
  }
59
64
  }
60
65
 
61
- return decoded;
66
+ return decoded + str.slice(runStart, end + 1);
62
67
  }
63
68
 
64
69
  function encode(str) {
65
70
  let encoded = '';
71
+ let runStart = 0;
66
72
  let wsBeforeHexIsNeeded = false;
67
73
 
68
74
  for (let i = 0; i < str.length; i++) {
@@ -70,7 +76,8 @@ function encode(str) {
70
76
 
71
77
  // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER (U+FFFD).
72
78
  if (code === 0x0000) {
73
- encoded += '\uFFFD';
79
+ encoded += str.slice(runStart, i) + '\uFFFD';
80
+ runStart = i + 1;
74
81
  continue;
75
82
  }
76
83
 
@@ -78,7 +85,8 @@ function encode(str) {
78
85
  // the character escaped as code point.
79
86
  // Note: Do not compare with 0x0001 since 0x0000 is precessed before
80
87
  if (code <= 0x001f || code === 0x007F) {
81
- encoded += '\\' + code.toString(16);
88
+ encoded += str.slice(runStart, i) + '\\' + code.toString(16);
89
+ runStart = i + 1;
82
90
  wsBeforeHexIsNeeded = true;
83
91
  continue;
84
92
  }
@@ -89,19 +97,20 @@ function encode(str) {
89
97
  code === APOSTROPHE ||
90
98
  code === LEFTPARENTHESIS ||
91
99
  code === RIGHTPARENTHESIS) {
92
- encoded += '\\' + str.charAt(i);
100
+ encoded += str.slice(runStart, i) + '\\' + str.charAt(i);
101
+ runStart = i + 1;
93
102
  wsBeforeHexIsNeeded = false;
94
103
  } else {
95
104
  if (wsBeforeHexIsNeeded && charCodeDefinitions.isHexDigit(code)) {
96
- encoded += ' ';
105
+ encoded += str.slice(runStart, i) + ' ';
106
+ runStart = i;
97
107
  }
98
108
 
99
- encoded += str.charAt(i);
100
109
  wsBeforeHexIsNeeded = false;
101
110
  }
102
111
  }
103
112
 
104
- return 'url(' + encoded + ')';
113
+ return 'url(' + encoded + str.slice(runStart) + ')';
105
114
  }
106
115
 
107
116
  exports.decode = decode;