vite 6.0.0-beta.9 → 6.0.1

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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

@@ -1,589 +0,0 @@
1
- import { createRequire as __cjs_createRequire } from 'node:module';
2
-
3
- const require = __cjs_createRequire(import.meta.url);
4
- const __require = require;
5
- var parse;
6
- var hasRequiredParse;
7
-
8
- function requireParse () {
9
- if (hasRequiredParse) return parse;
10
- hasRequiredParse = 1;
11
- var openParentheses = "(".charCodeAt(0);
12
- var closeParentheses = ")".charCodeAt(0);
13
- var singleQuote = "'".charCodeAt(0);
14
- var doubleQuote = '"'.charCodeAt(0);
15
- var backslash = "\\".charCodeAt(0);
16
- var slash = "/".charCodeAt(0);
17
- var comma = ",".charCodeAt(0);
18
- var colon = ":".charCodeAt(0);
19
- var star = "*".charCodeAt(0);
20
- var uLower = "u".charCodeAt(0);
21
- var uUpper = "U".charCodeAt(0);
22
- var plus = "+".charCodeAt(0);
23
- var isUnicodeRange = /^[a-f0-9?-]+$/i;
24
-
25
- parse = function(input) {
26
- var tokens = [];
27
- var value = input;
28
-
29
- var next,
30
- quote,
31
- prev,
32
- token,
33
- escape,
34
- escapePos,
35
- whitespacePos,
36
- parenthesesOpenPos;
37
- var pos = 0;
38
- var code = value.charCodeAt(pos);
39
- var max = value.length;
40
- var stack = [{ nodes: tokens }];
41
- var balanced = 0;
42
- var parent;
43
-
44
- var name = "";
45
- var before = "";
46
- var after = "";
47
-
48
- while (pos < max) {
49
- // Whitespaces
50
- if (code <= 32) {
51
- next = pos;
52
- do {
53
- next += 1;
54
- code = value.charCodeAt(next);
55
- } while (code <= 32);
56
- token = value.slice(pos, next);
57
-
58
- prev = tokens[tokens.length - 1];
59
- if (code === closeParentheses && balanced) {
60
- after = token;
61
- } else if (prev && prev.type === "div") {
62
- prev.after = token;
63
- prev.sourceEndIndex += token.length;
64
- } else if (
65
- code === comma ||
66
- code === colon ||
67
- (code === slash &&
68
- value.charCodeAt(next + 1) !== star &&
69
- (!parent ||
70
- (parent && parent.type === "function" && parent.value !== "calc")))
71
- ) {
72
- before = token;
73
- } else {
74
- tokens.push({
75
- type: "space",
76
- sourceIndex: pos,
77
- sourceEndIndex: next,
78
- value: token
79
- });
80
- }
81
-
82
- pos = next;
83
-
84
- // Quotes
85
- } else if (code === singleQuote || code === doubleQuote) {
86
- next = pos;
87
- quote = code === singleQuote ? "'" : '"';
88
- token = {
89
- type: "string",
90
- sourceIndex: pos,
91
- quote: quote
92
- };
93
- do {
94
- escape = false;
95
- next = value.indexOf(quote, next + 1);
96
- if (~next) {
97
- escapePos = next;
98
- while (value.charCodeAt(escapePos - 1) === backslash) {
99
- escapePos -= 1;
100
- escape = !escape;
101
- }
102
- } else {
103
- value += quote;
104
- next = value.length - 1;
105
- token.unclosed = true;
106
- }
107
- } while (escape);
108
- token.value = value.slice(pos + 1, next);
109
- token.sourceEndIndex = token.unclosed ? next : next + 1;
110
- tokens.push(token);
111
- pos = next + 1;
112
- code = value.charCodeAt(pos);
113
-
114
- // Comments
115
- } else if (code === slash && value.charCodeAt(pos + 1) === star) {
116
- next = value.indexOf("*/", pos);
117
-
118
- token = {
119
- type: "comment",
120
- sourceIndex: pos,
121
- sourceEndIndex: next + 2
122
- };
123
-
124
- if (next === -1) {
125
- token.unclosed = true;
126
- next = value.length;
127
- token.sourceEndIndex = next;
128
- }
129
-
130
- token.value = value.slice(pos + 2, next);
131
- tokens.push(token);
132
-
133
- pos = next + 2;
134
- code = value.charCodeAt(pos);
135
-
136
- // Operation within calc
137
- } else if (
138
- (code === slash || code === star) &&
139
- parent &&
140
- parent.type === "function" &&
141
- parent.value === "calc"
142
- ) {
143
- token = value[pos];
144
- tokens.push({
145
- type: "word",
146
- sourceIndex: pos - before.length,
147
- sourceEndIndex: pos + token.length,
148
- value: token
149
- });
150
- pos += 1;
151
- code = value.charCodeAt(pos);
152
-
153
- // Dividers
154
- } else if (code === slash || code === comma || code === colon) {
155
- token = value[pos];
156
-
157
- tokens.push({
158
- type: "div",
159
- sourceIndex: pos - before.length,
160
- sourceEndIndex: pos + token.length,
161
- value: token,
162
- before: before,
163
- after: ""
164
- });
165
- before = "";
166
-
167
- pos += 1;
168
- code = value.charCodeAt(pos);
169
-
170
- // Open parentheses
171
- } else if (openParentheses === code) {
172
- // Whitespaces after open parentheses
173
- next = pos;
174
- do {
175
- next += 1;
176
- code = value.charCodeAt(next);
177
- } while (code <= 32);
178
- parenthesesOpenPos = pos;
179
- token = {
180
- type: "function",
181
- sourceIndex: pos - name.length,
182
- value: name,
183
- before: value.slice(parenthesesOpenPos + 1, next)
184
- };
185
- pos = next;
186
-
187
- if (name === "url" && code !== singleQuote && code !== doubleQuote) {
188
- next -= 1;
189
- do {
190
- escape = false;
191
- next = value.indexOf(")", next + 1);
192
- if (~next) {
193
- escapePos = next;
194
- while (value.charCodeAt(escapePos - 1) === backslash) {
195
- escapePos -= 1;
196
- escape = !escape;
197
- }
198
- } else {
199
- value += ")";
200
- next = value.length - 1;
201
- token.unclosed = true;
202
- }
203
- } while (escape);
204
- // Whitespaces before closed
205
- whitespacePos = next;
206
- do {
207
- whitespacePos -= 1;
208
- code = value.charCodeAt(whitespacePos);
209
- } while (code <= 32);
210
- if (parenthesesOpenPos < whitespacePos) {
211
- if (pos !== whitespacePos + 1) {
212
- token.nodes = [
213
- {
214
- type: "word",
215
- sourceIndex: pos,
216
- sourceEndIndex: whitespacePos + 1,
217
- value: value.slice(pos, whitespacePos + 1)
218
- }
219
- ];
220
- } else {
221
- token.nodes = [];
222
- }
223
- if (token.unclosed && whitespacePos + 1 !== next) {
224
- token.after = "";
225
- token.nodes.push({
226
- type: "space",
227
- sourceIndex: whitespacePos + 1,
228
- sourceEndIndex: next,
229
- value: value.slice(whitespacePos + 1, next)
230
- });
231
- } else {
232
- token.after = value.slice(whitespacePos + 1, next);
233
- token.sourceEndIndex = next;
234
- }
235
- } else {
236
- token.after = "";
237
- token.nodes = [];
238
- }
239
- pos = next + 1;
240
- token.sourceEndIndex = token.unclosed ? next : pos;
241
- code = value.charCodeAt(pos);
242
- tokens.push(token);
243
- } else {
244
- balanced += 1;
245
- token.after = "";
246
- token.sourceEndIndex = pos + 1;
247
- tokens.push(token);
248
- stack.push(token);
249
- tokens = token.nodes = [];
250
- parent = token;
251
- }
252
- name = "";
253
-
254
- // Close parentheses
255
- } else if (closeParentheses === code && balanced) {
256
- pos += 1;
257
- code = value.charCodeAt(pos);
258
-
259
- parent.after = after;
260
- parent.sourceEndIndex += after.length;
261
- after = "";
262
- balanced -= 1;
263
- stack[stack.length - 1].sourceEndIndex = pos;
264
- stack.pop();
265
- parent = stack[balanced];
266
- tokens = parent.nodes;
267
-
268
- // Words
269
- } else {
270
- next = pos;
271
- do {
272
- if (code === backslash) {
273
- next += 1;
274
- }
275
- next += 1;
276
- code = value.charCodeAt(next);
277
- } while (
278
- next < max &&
279
- !(
280
- code <= 32 ||
281
- code === singleQuote ||
282
- code === doubleQuote ||
283
- code === comma ||
284
- code === colon ||
285
- code === slash ||
286
- code === openParentheses ||
287
- (code === star &&
288
- parent &&
289
- parent.type === "function" &&
290
- parent.value === "calc") ||
291
- (code === slash &&
292
- parent.type === "function" &&
293
- parent.value === "calc") ||
294
- (code === closeParentheses && balanced)
295
- )
296
- );
297
- token = value.slice(pos, next);
298
-
299
- if (openParentheses === code) {
300
- name = token;
301
- } else if (
302
- (uLower === token.charCodeAt(0) || uUpper === token.charCodeAt(0)) &&
303
- plus === token.charCodeAt(1) &&
304
- isUnicodeRange.test(token.slice(2))
305
- ) {
306
- tokens.push({
307
- type: "unicode-range",
308
- sourceIndex: pos,
309
- sourceEndIndex: next,
310
- value: token
311
- });
312
- } else {
313
- tokens.push({
314
- type: "word",
315
- sourceIndex: pos,
316
- sourceEndIndex: next,
317
- value: token
318
- });
319
- }
320
-
321
- pos = next;
322
- }
323
- }
324
-
325
- for (pos = stack.length - 1; pos; pos -= 1) {
326
- stack[pos].unclosed = true;
327
- stack[pos].sourceEndIndex = value.length;
328
- }
329
-
330
- return stack[0].nodes;
331
- };
332
- return parse;
333
- }
334
-
335
- var walk;
336
- var hasRequiredWalk;
337
-
338
- function requireWalk () {
339
- if (hasRequiredWalk) return walk;
340
- hasRequiredWalk = 1;
341
- walk = function walk(nodes, cb, bubble) {
342
- var i, max, node, result;
343
-
344
- for (i = 0, max = nodes.length; i < max; i += 1) {
345
- node = nodes[i];
346
- if (!bubble) {
347
- result = cb(node, i, nodes);
348
- }
349
-
350
- if (
351
- result !== false &&
352
- node.type === "function" &&
353
- Array.isArray(node.nodes)
354
- ) {
355
- walk(node.nodes, cb, bubble);
356
- }
357
-
358
- if (bubble) {
359
- cb(node, i, nodes);
360
- }
361
- }
362
- };
363
- return walk;
364
- }
365
-
366
- var stringify_1;
367
- var hasRequiredStringify;
368
-
369
- function requireStringify () {
370
- if (hasRequiredStringify) return stringify_1;
371
- hasRequiredStringify = 1;
372
- function stringifyNode(node, custom) {
373
- var type = node.type;
374
- var value = node.value;
375
- var buf;
376
- var customResult;
377
-
378
- if (custom && (customResult = custom(node)) !== undefined) {
379
- return customResult;
380
- } else if (type === "word" || type === "space") {
381
- return value;
382
- } else if (type === "string") {
383
- buf = node.quote || "";
384
- return buf + value + (node.unclosed ? "" : buf);
385
- } else if (type === "comment") {
386
- return "/*" + value + (node.unclosed ? "" : "*/");
387
- } else if (type === "div") {
388
- return (node.before || "") + value + (node.after || "");
389
- } else if (Array.isArray(node.nodes)) {
390
- buf = stringify(node.nodes, custom);
391
- if (type !== "function") {
392
- return buf;
393
- }
394
- return (
395
- value +
396
- "(" +
397
- (node.before || "") +
398
- buf +
399
- (node.after || "") +
400
- (node.unclosed ? "" : ")")
401
- );
402
- }
403
- return value;
404
- }
405
-
406
- function stringify(nodes, custom) {
407
- var result, i;
408
-
409
- if (Array.isArray(nodes)) {
410
- result = "";
411
- for (i = nodes.length - 1; ~i; i -= 1) {
412
- result = stringifyNode(nodes[i], custom) + result;
413
- }
414
- return result;
415
- }
416
- return stringifyNode(nodes, custom);
417
- }
418
-
419
- stringify_1 = stringify;
420
- return stringify_1;
421
- }
422
-
423
- var unit;
424
- var hasRequiredUnit;
425
-
426
- function requireUnit () {
427
- if (hasRequiredUnit) return unit;
428
- hasRequiredUnit = 1;
429
- var minus = "-".charCodeAt(0);
430
- var plus = "+".charCodeAt(0);
431
- var dot = ".".charCodeAt(0);
432
- var exp = "e".charCodeAt(0);
433
- var EXP = "E".charCodeAt(0);
434
-
435
- // Check if three code points would start a number
436
- // https://www.w3.org/TR/css-syntax-3/#starts-with-a-number
437
- function likeNumber(value) {
438
- var code = value.charCodeAt(0);
439
- var nextCode;
440
-
441
- if (code === plus || code === minus) {
442
- nextCode = value.charCodeAt(1);
443
-
444
- if (nextCode >= 48 && nextCode <= 57) {
445
- return true;
446
- }
447
-
448
- var nextNextCode = value.charCodeAt(2);
449
-
450
- if (nextCode === dot && nextNextCode >= 48 && nextNextCode <= 57) {
451
- return true;
452
- }
453
-
454
- return false;
455
- }
456
-
457
- if (code === dot) {
458
- nextCode = value.charCodeAt(1);
459
-
460
- if (nextCode >= 48 && nextCode <= 57) {
461
- return true;
462
- }
463
-
464
- return false;
465
- }
466
-
467
- if (code >= 48 && code <= 57) {
468
- return true;
469
- }
470
-
471
- return false;
472
- }
473
-
474
- // Consume a number
475
- // https://www.w3.org/TR/css-syntax-3/#consume-number
476
- unit = function(value) {
477
- var pos = 0;
478
- var length = value.length;
479
- var code;
480
- var nextCode;
481
- var nextNextCode;
482
-
483
- if (length === 0 || !likeNumber(value)) {
484
- return false;
485
- }
486
-
487
- code = value.charCodeAt(pos);
488
-
489
- if (code === plus || code === minus) {
490
- pos++;
491
- }
492
-
493
- while (pos < length) {
494
- code = value.charCodeAt(pos);
495
-
496
- if (code < 48 || code > 57) {
497
- break;
498
- }
499
-
500
- pos += 1;
501
- }
502
-
503
- code = value.charCodeAt(pos);
504
- nextCode = value.charCodeAt(pos + 1);
505
-
506
- if (code === dot && nextCode >= 48 && nextCode <= 57) {
507
- pos += 2;
508
-
509
- while (pos < length) {
510
- code = value.charCodeAt(pos);
511
-
512
- if (code < 48 || code > 57) {
513
- break;
514
- }
515
-
516
- pos += 1;
517
- }
518
- }
519
-
520
- code = value.charCodeAt(pos);
521
- nextCode = value.charCodeAt(pos + 1);
522
- nextNextCode = value.charCodeAt(pos + 2);
523
-
524
- if (
525
- (code === exp || code === EXP) &&
526
- ((nextCode >= 48 && nextCode <= 57) ||
527
- ((nextCode === plus || nextCode === minus) &&
528
- nextNextCode >= 48 &&
529
- nextNextCode <= 57))
530
- ) {
531
- pos += nextCode === plus || nextCode === minus ? 3 : 2;
532
-
533
- while (pos < length) {
534
- code = value.charCodeAt(pos);
535
-
536
- if (code < 48 || code > 57) {
537
- break;
538
- }
539
-
540
- pos += 1;
541
- }
542
- }
543
-
544
- return {
545
- number: value.slice(0, pos),
546
- unit: value.slice(pos)
547
- };
548
- };
549
- return unit;
550
- }
551
-
552
- var lib;
553
- var hasRequiredLib;
554
-
555
- function requireLib () {
556
- if (hasRequiredLib) return lib;
557
- hasRequiredLib = 1;
558
- var parse = requireParse();
559
- var walk = requireWalk();
560
- var stringify = requireStringify();
561
-
562
- function ValueParser(value) {
563
- if (this instanceof ValueParser) {
564
- this.nodes = parse(value);
565
- return this;
566
- }
567
- return new ValueParser(value);
568
- }
569
-
570
- ValueParser.prototype.toString = function() {
571
- return Array.isArray(this.nodes) ? stringify(this.nodes) : "";
572
- };
573
-
574
- ValueParser.prototype.walk = function(cb, bubble) {
575
- walk(this.nodes, cb, bubble);
576
- return this;
577
- };
578
-
579
- ValueParser.unit = requireUnit();
580
-
581
- ValueParser.walk = walk;
582
-
583
- ValueParser.stringify = stringify;
584
-
585
- lib = ValueParser;
586
- return lib;
587
- }
588
-
589
- export { requireLib as r };