html2canvas-pro 2.2.4 → 2.3.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/html2canvas-pro.cjs +11218 -0
- package/dist/html2canvas-pro.cjs.map +1 -0
- package/dist/html2canvas-pro.esm.js +2601 -2379
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +2601 -2379
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +4 -5
- package/dist/lib/core/abort-helper.js +20 -0
- package/dist/lib/core/background-parser.js +41 -0
- package/dist/lib/core/cache-storage.js +63 -7
- package/dist/lib/core/config-assembler.js +88 -0
- package/dist/lib/core/lru-map.js +66 -0
- package/dist/lib/core/render-element.js +24 -103
- package/dist/lib/css/property-descriptors/background-position.js +1 -11
- package/dist/lib/css/property-descriptors/background-size.js +3 -1
- package/dist/lib/css/syntax/token-constants.js +214 -0
- package/dist/lib/css/syntax/token-singletons.js +36 -0
- package/dist/lib/css/syntax/token-types.js +10 -0
- package/dist/lib/css/syntax/tokenizer.js +175 -307
- package/dist/lib/css/types/length-percentage.js +63 -3
- package/dist/lib/dom/document-cloner.js +23 -22
- package/dist/lib/dom/node-parser.js +1 -21
- package/dist/lib/dom/slot-cloner.js +8 -8
- package/dist/lib/render/background.js +4 -1
- package/dist/lib/render/canvas/background-renderer.js +27 -39
- package/dist/lib/render/canvas/canvas-renderer.js +2 -2
- package/dist/lib/render/canvas/effects-renderer.js +94 -32
- package/dist/lib/render/canvas/text-renderer.js +68 -12
- package/dist/lib/render/stacking-context.js +12 -6
- package/dist/types/core/abort-helper.d.ts +12 -0
- package/dist/types/core/background-parser.d.ts +16 -0
- package/dist/types/core/cache-storage.d.ts +25 -0
- package/dist/types/core/config-assembler.d.ts +28 -0
- package/dist/types/core/lru-map.d.ts +37 -0
- package/dist/types/css/syntax/token-constants.d.ts +74 -0
- package/dist/types/css/syntax/token-singletons.d.ts +22 -0
- package/dist/types/css/syntax/token-types.d.ts +72 -0
- package/dist/types/css/syntax/tokenizer.d.ts +6 -73
- package/dist/types/css/types/length-percentage.d.ts +42 -1
- package/dist/types/dom/document-cloner.d.ts +5 -0
- package/dist/types/dom/node-parser.d.ts +0 -2
- package/dist/types/render/canvas/background-renderer.d.ts +0 -10
- package/dist/types/render/canvas/effects-renderer.d.ts +42 -17
- package/dist/types/render/canvas/text-renderer.d.ts +12 -0
- package/dist/types/render/stacking-context.d.ts +26 -1
- package/package.json +5 -7
|
@@ -1,184 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// https://www.w3.org/TR/css-syntax-3
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Tokenizer = exports.EOF_TOKEN = exports.FLAG_NUMBER = exports.FLAG_INTEGER = exports.FLAG_ID = exports.FLAG_UNRESTRICTED = void 0;
|
|
4
|
+
exports.Tokenizer = exports.COLUMN_TOKEN = exports.INCLUDE_MATCH_TOKEN = exports.DASH_MATCH_TOKEN = exports.SUBSTRING_MATCH_TOKEN = exports.SUFFIX_MATCH_TOKEN = exports.PREFIX_MATCH_TOKEN = exports.CDO_TOKEN = exports.CDC_TOKEN = exports.BAD_STRING_TOKEN = exports.BAD_URL_TOKEN = exports.EOF_TOKEN = exports.WHITESPACE_TOKEN = exports.RIGHT_SQUARE_BRACKET_TOKEN = exports.LEFT_SQUARE_BRACKET_TOKEN = exports.RIGHT_CURLY_BRACKET_TOKEN = exports.LEFT_CURLY_BRACKET_TOKEN = exports.RIGHT_PARENTHESIS_TOKEN = exports.LEFT_PARENTHESIS_TOKEN = exports.SEMICOLON_TOKEN = exports.COLON_TOKEN = exports.COMMA_TOKEN = exports.isNumberStart = exports.isNameStartCodePoint = exports.isIdentifierStart = exports.isValidEscape = exports.isNameCodePoint = exports.isWhiteSpace = exports.isHex = exports.isDigit = exports.FLAG_NUMBER = exports.FLAG_INTEGER = exports.FLAG_ID = exports.FLAG_UNRESTRICTED = void 0;
|
|
5
5
|
const css_line_break_1 = require("css-line-break");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const BACKSPACE = 0x0008;
|
|
47
|
-
const LINE_TABULATION = 0x000b;
|
|
48
|
-
const SHIFT_OUT = 0x000e;
|
|
49
|
-
const INFORMATION_SEPARATOR_ONE = 0x001f;
|
|
50
|
-
const DELETE = 0x007f;
|
|
51
|
-
const EOF = -1;
|
|
52
|
-
const ZERO = 0x0030;
|
|
53
|
-
const a = 0x0061;
|
|
54
|
-
const e = 0x0065;
|
|
55
|
-
const f = 0x0066;
|
|
56
|
-
const u = 0x0075;
|
|
57
|
-
const z = 0x007a;
|
|
58
|
-
const A = 0x0041;
|
|
59
|
-
const E = 0x0045;
|
|
60
|
-
const F = 0x0046;
|
|
61
|
-
const U = 0x0055;
|
|
62
|
-
const Z = 0x005a;
|
|
63
|
-
const isDigit = (codePoint) => codePoint >= ZERO && codePoint <= 0x0039;
|
|
64
|
-
const isSurrogateCodePoint = (codePoint) => codePoint >= 0xd800 && codePoint <= 0xdfff;
|
|
65
|
-
const isHex = (codePoint) => isDigit(codePoint) || (codePoint >= A && codePoint <= F) || (codePoint >= a && codePoint <= f);
|
|
66
|
-
const isLowerCaseLetter = (codePoint) => codePoint >= a && codePoint <= z;
|
|
67
|
-
const isUpperCaseLetter = (codePoint) => codePoint >= A && codePoint <= Z;
|
|
68
|
-
const isLetter = (codePoint) => isLowerCaseLetter(codePoint) || isUpperCaseLetter(codePoint);
|
|
69
|
-
const isNonASCIICodePoint = (codePoint) => codePoint >= CONTROL;
|
|
70
|
-
const isWhiteSpace = (codePoint) => codePoint === LINE_FEED || codePoint === CHARACTER_TABULATION || codePoint === SPACE;
|
|
71
|
-
const isNameStartCodePoint = (codePoint) => isLetter(codePoint) || isNonASCIICodePoint(codePoint) || codePoint === LOW_LINE;
|
|
72
|
-
const isNameCodePoint = (codePoint) => isNameStartCodePoint(codePoint) || isDigit(codePoint) || codePoint === HYPHEN_MINUS;
|
|
73
|
-
const isNonPrintableCodePoint = (codePoint) => {
|
|
74
|
-
return ((codePoint >= NULL && codePoint <= BACKSPACE) ||
|
|
75
|
-
codePoint === LINE_TABULATION ||
|
|
76
|
-
(codePoint >= SHIFT_OUT && codePoint <= INFORMATION_SEPARATOR_ONE) ||
|
|
77
|
-
codePoint === DELETE);
|
|
78
|
-
};
|
|
79
|
-
const isValidEscape = (c1, c2) => {
|
|
80
|
-
if (c1 !== REVERSE_SOLIDUS) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
return c2 !== LINE_FEED;
|
|
84
|
-
};
|
|
85
|
-
const isIdentifierStart = (c1, c2, c3) => {
|
|
86
|
-
if (c1 === HYPHEN_MINUS) {
|
|
87
|
-
return isNameStartCodePoint(c2) || isValidEscape(c2, c3);
|
|
88
|
-
}
|
|
89
|
-
else if (isNameStartCodePoint(c1)) {
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
else if (c1 === REVERSE_SOLIDUS && isValidEscape(c1, c2)) {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
return false;
|
|
96
|
-
};
|
|
97
|
-
const isNumberStart = (c1, c2, c3) => {
|
|
98
|
-
if (c1 === PLUS_SIGN || c1 === HYPHEN_MINUS) {
|
|
99
|
-
if (isDigit(c2)) {
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
return c2 === FULL_STOP && isDigit(c3);
|
|
103
|
-
}
|
|
104
|
-
if (c1 === FULL_STOP) {
|
|
105
|
-
return isDigit(c2);
|
|
106
|
-
}
|
|
107
|
-
return isDigit(c1);
|
|
108
|
-
};
|
|
109
|
-
const stringToNumber = (codePoints) => {
|
|
110
|
-
let c = 0;
|
|
111
|
-
let sign = 1;
|
|
112
|
-
if (codePoints[c] === PLUS_SIGN || codePoints[c] === HYPHEN_MINUS) {
|
|
113
|
-
if (codePoints[c] === HYPHEN_MINUS) {
|
|
114
|
-
sign = -1;
|
|
115
|
-
}
|
|
116
|
-
c++;
|
|
117
|
-
}
|
|
118
|
-
const integers = [];
|
|
119
|
-
while (isDigit(codePoints[c])) {
|
|
120
|
-
integers.push(codePoints[c++]);
|
|
121
|
-
}
|
|
122
|
-
const int = integers.length ? parseInt((0, css_line_break_1.fromCodePoint)(...integers), 10) : 0;
|
|
123
|
-
if (codePoints[c] === FULL_STOP) {
|
|
124
|
-
c++;
|
|
125
|
-
}
|
|
126
|
-
const fraction = [];
|
|
127
|
-
while (isDigit(codePoints[c])) {
|
|
128
|
-
fraction.push(codePoints[c++]);
|
|
129
|
-
}
|
|
130
|
-
const fracd = fraction.length;
|
|
131
|
-
const frac = fracd ? parseInt((0, css_line_break_1.fromCodePoint)(...fraction), 10) : 0;
|
|
132
|
-
if (codePoints[c] === E || codePoints[c] === e) {
|
|
133
|
-
c++;
|
|
134
|
-
}
|
|
135
|
-
let expsign = 1;
|
|
136
|
-
if (codePoints[c] === PLUS_SIGN || codePoints[c] === HYPHEN_MINUS) {
|
|
137
|
-
if (codePoints[c] === HYPHEN_MINUS) {
|
|
138
|
-
expsign = -1;
|
|
139
|
-
}
|
|
140
|
-
c++;
|
|
141
|
-
}
|
|
142
|
-
const exponent = [];
|
|
143
|
-
while (isDigit(codePoints[c])) {
|
|
144
|
-
exponent.push(codePoints[c++]);
|
|
145
|
-
}
|
|
146
|
-
const exp = exponent.length ? parseInt((0, css_line_break_1.fromCodePoint)(...exponent), 10) : 0;
|
|
147
|
-
return sign * (int + frac * Math.pow(10, -fracd)) * Math.pow(10, expsign * exp);
|
|
148
|
-
};
|
|
149
|
-
const LEFT_PARENTHESIS_TOKEN = {
|
|
150
|
-
type: 2 /* TokenType.LEFT_PARENTHESIS_TOKEN */
|
|
151
|
-
};
|
|
152
|
-
const RIGHT_PARENTHESIS_TOKEN = {
|
|
153
|
-
type: 3 /* TokenType.RIGHT_PARENTHESIS_TOKEN */
|
|
154
|
-
};
|
|
155
|
-
const COMMA_TOKEN = { type: 4 /* TokenType.COMMA_TOKEN */ };
|
|
156
|
-
const SUFFIX_MATCH_TOKEN = { type: 13 /* TokenType.SUFFIX_MATCH_TOKEN */ };
|
|
157
|
-
const PREFIX_MATCH_TOKEN = { type: 8 /* TokenType.PREFIX_MATCH_TOKEN */ };
|
|
158
|
-
const COLUMN_TOKEN = { type: 21 /* TokenType.COLUMN_TOKEN */ };
|
|
159
|
-
const DASH_MATCH_TOKEN = { type: 9 /* TokenType.DASH_MATCH_TOKEN */ };
|
|
160
|
-
const INCLUDE_MATCH_TOKEN = { type: 10 /* TokenType.INCLUDE_MATCH_TOKEN */ };
|
|
161
|
-
const LEFT_CURLY_BRACKET_TOKEN = {
|
|
162
|
-
type: 11 /* TokenType.LEFT_CURLY_BRACKET_TOKEN */
|
|
163
|
-
};
|
|
164
|
-
const RIGHT_CURLY_BRACKET_TOKEN = {
|
|
165
|
-
type: 12 /* TokenType.RIGHT_CURLY_BRACKET_TOKEN */
|
|
166
|
-
};
|
|
167
|
-
const SUBSTRING_MATCH_TOKEN = { type: 14 /* TokenType.SUBSTRING_MATCH_TOKEN */ };
|
|
168
|
-
const BAD_URL_TOKEN = { type: 23 /* TokenType.BAD_URL_TOKEN */ };
|
|
169
|
-
const BAD_STRING_TOKEN = { type: 1 /* TokenType.BAD_STRING_TOKEN */ };
|
|
170
|
-
const CDO_TOKEN = { type: 25 /* TokenType.CDO_TOKEN */ };
|
|
171
|
-
const CDC_TOKEN = { type: 24 /* TokenType.CDC_TOKEN */ };
|
|
172
|
-
const COLON_TOKEN = { type: 26 /* TokenType.COLON_TOKEN */ };
|
|
173
|
-
const SEMICOLON_TOKEN = { type: 27 /* TokenType.SEMICOLON_TOKEN */ };
|
|
174
|
-
const LEFT_SQUARE_BRACKET_TOKEN = {
|
|
175
|
-
type: 28 /* TokenType.LEFT_SQUARE_BRACKET_TOKEN */
|
|
176
|
-
};
|
|
177
|
-
const RIGHT_SQUARE_BRACKET_TOKEN = {
|
|
178
|
-
type: 29 /* TokenType.RIGHT_SQUARE_BRACKET_TOKEN */
|
|
179
|
-
};
|
|
180
|
-
const WHITESPACE_TOKEN = { type: 31 /* TokenType.WHITESPACE_TOKEN */ };
|
|
181
|
-
exports.EOF_TOKEN = { type: 32 /* TokenType.EOF_TOKEN */ };
|
|
6
|
+
const token_types_1 = require("./token-types");
|
|
7
|
+
const token_constants_1 = require("./token-constants");
|
|
8
|
+
const token_constants_2 = require("./token-constants");
|
|
9
|
+
const token_singletons_1 = require("./token-singletons");
|
|
10
|
+
var token_types_2 = require("./token-types");
|
|
11
|
+
Object.defineProperty(exports, "FLAG_UNRESTRICTED", { enumerable: true, get: function () { return token_types_2.FLAG_UNRESTRICTED; } });
|
|
12
|
+
Object.defineProperty(exports, "FLAG_ID", { enumerable: true, get: function () { return token_types_2.FLAG_ID; } });
|
|
13
|
+
Object.defineProperty(exports, "FLAG_INTEGER", { enumerable: true, get: function () { return token_types_2.FLAG_INTEGER; } });
|
|
14
|
+
Object.defineProperty(exports, "FLAG_NUMBER", { enumerable: true, get: function () { return token_types_2.FLAG_NUMBER; } });
|
|
15
|
+
var token_constants_3 = require("./token-constants");
|
|
16
|
+
Object.defineProperty(exports, "isDigit", { enumerable: true, get: function () { return token_constants_3.isDigit; } });
|
|
17
|
+
Object.defineProperty(exports, "isHex", { enumerable: true, get: function () { return token_constants_3.isHex; } });
|
|
18
|
+
Object.defineProperty(exports, "isWhiteSpace", { enumerable: true, get: function () { return token_constants_3.isWhiteSpace; } });
|
|
19
|
+
Object.defineProperty(exports, "isNameCodePoint", { enumerable: true, get: function () { return token_constants_3.isNameCodePoint; } });
|
|
20
|
+
Object.defineProperty(exports, "isValidEscape", { enumerable: true, get: function () { return token_constants_3.isValidEscape; } });
|
|
21
|
+
Object.defineProperty(exports, "isIdentifierStart", { enumerable: true, get: function () { return token_constants_3.isIdentifierStart; } });
|
|
22
|
+
Object.defineProperty(exports, "isNameStartCodePoint", { enumerable: true, get: function () { return token_constants_3.isNameStartCodePoint; } });
|
|
23
|
+
Object.defineProperty(exports, "isNumberStart", { enumerable: true, get: function () { return token_constants_3.isNumberStart; } });
|
|
24
|
+
var token_singletons_2 = require("./token-singletons");
|
|
25
|
+
Object.defineProperty(exports, "COMMA_TOKEN", { enumerable: true, get: function () { return token_singletons_2.COMMA_TOKEN; } });
|
|
26
|
+
Object.defineProperty(exports, "COLON_TOKEN", { enumerable: true, get: function () { return token_singletons_2.COLON_TOKEN; } });
|
|
27
|
+
Object.defineProperty(exports, "SEMICOLON_TOKEN", { enumerable: true, get: function () { return token_singletons_2.SEMICOLON_TOKEN; } });
|
|
28
|
+
Object.defineProperty(exports, "LEFT_PARENTHESIS_TOKEN", { enumerable: true, get: function () { return token_singletons_2.LEFT_PARENTHESIS_TOKEN; } });
|
|
29
|
+
Object.defineProperty(exports, "RIGHT_PARENTHESIS_TOKEN", { enumerable: true, get: function () { return token_singletons_2.RIGHT_PARENTHESIS_TOKEN; } });
|
|
30
|
+
Object.defineProperty(exports, "LEFT_CURLY_BRACKET_TOKEN", { enumerable: true, get: function () { return token_singletons_2.LEFT_CURLY_BRACKET_TOKEN; } });
|
|
31
|
+
Object.defineProperty(exports, "RIGHT_CURLY_BRACKET_TOKEN", { enumerable: true, get: function () { return token_singletons_2.RIGHT_CURLY_BRACKET_TOKEN; } });
|
|
32
|
+
Object.defineProperty(exports, "LEFT_SQUARE_BRACKET_TOKEN", { enumerable: true, get: function () { return token_singletons_2.LEFT_SQUARE_BRACKET_TOKEN; } });
|
|
33
|
+
Object.defineProperty(exports, "RIGHT_SQUARE_BRACKET_TOKEN", { enumerable: true, get: function () { return token_singletons_2.RIGHT_SQUARE_BRACKET_TOKEN; } });
|
|
34
|
+
Object.defineProperty(exports, "WHITESPACE_TOKEN", { enumerable: true, get: function () { return token_singletons_2.WHITESPACE_TOKEN; } });
|
|
35
|
+
Object.defineProperty(exports, "EOF_TOKEN", { enumerable: true, get: function () { return token_singletons_2.EOF_TOKEN; } });
|
|
36
|
+
Object.defineProperty(exports, "BAD_URL_TOKEN", { enumerable: true, get: function () { return token_singletons_2.BAD_URL_TOKEN; } });
|
|
37
|
+
Object.defineProperty(exports, "BAD_STRING_TOKEN", { enumerable: true, get: function () { return token_singletons_2.BAD_STRING_TOKEN; } });
|
|
38
|
+
Object.defineProperty(exports, "CDC_TOKEN", { enumerable: true, get: function () { return token_singletons_2.CDC_TOKEN; } });
|
|
39
|
+
Object.defineProperty(exports, "CDO_TOKEN", { enumerable: true, get: function () { return token_singletons_2.CDO_TOKEN; } });
|
|
40
|
+
Object.defineProperty(exports, "PREFIX_MATCH_TOKEN", { enumerable: true, get: function () { return token_singletons_2.PREFIX_MATCH_TOKEN; } });
|
|
41
|
+
Object.defineProperty(exports, "SUFFIX_MATCH_TOKEN", { enumerable: true, get: function () { return token_singletons_2.SUFFIX_MATCH_TOKEN; } });
|
|
42
|
+
Object.defineProperty(exports, "SUBSTRING_MATCH_TOKEN", { enumerable: true, get: function () { return token_singletons_2.SUBSTRING_MATCH_TOKEN; } });
|
|
43
|
+
Object.defineProperty(exports, "DASH_MATCH_TOKEN", { enumerable: true, get: function () { return token_singletons_2.DASH_MATCH_TOKEN; } });
|
|
44
|
+
Object.defineProperty(exports, "INCLUDE_MATCH_TOKEN", { enumerable: true, get: function () { return token_singletons_2.INCLUDE_MATCH_TOKEN; } });
|
|
45
|
+
Object.defineProperty(exports, "COLUMN_TOKEN", { enumerable: true, get: function () { return token_singletons_2.COLUMN_TOKEN; } });
|
|
182
46
|
class Tokenizer {
|
|
183
47
|
static get() {
|
|
184
48
|
return Tokenizer._pool.pop() || new Tokenizer();
|
|
@@ -201,7 +65,7 @@ class Tokenizer {
|
|
|
201
65
|
read() {
|
|
202
66
|
const tokens = [];
|
|
203
67
|
let token = this.consumeToken();
|
|
204
|
-
while (token !==
|
|
68
|
+
while (token !== token_singletons_1.EOF_TOKEN) {
|
|
205
69
|
tokens.push(token);
|
|
206
70
|
token = this.consumeToken();
|
|
207
71
|
}
|
|
@@ -210,165 +74,169 @@ class Tokenizer {
|
|
|
210
74
|
consumeToken() {
|
|
211
75
|
const codePoint = this.consumeCodePoint();
|
|
212
76
|
switch (codePoint) {
|
|
213
|
-
case QUOTATION_MARK:
|
|
214
|
-
return this.consumeStringToken(QUOTATION_MARK);
|
|
215
|
-
case NUMBER_SIGN:
|
|
77
|
+
case token_constants_1.QUOTATION_MARK:
|
|
78
|
+
return this.consumeStringToken(token_constants_1.QUOTATION_MARK);
|
|
79
|
+
case token_constants_1.NUMBER_SIGN: {
|
|
216
80
|
const c1 = this.peekCodePoint(0);
|
|
217
81
|
const c2 = this.peekCodePoint(1);
|
|
218
82
|
const c3 = this.peekCodePoint(2);
|
|
219
|
-
if (isNameCodePoint(c1) || isValidEscape(c2, c3)) {
|
|
220
|
-
const flags = isIdentifierStart(c1, c2, c3) ?
|
|
83
|
+
if ((0, token_constants_2.isNameCodePoint)(c1) || (0, token_constants_2.isValidEscape)(c2, c3)) {
|
|
84
|
+
const flags = (0, token_constants_2.isIdentifierStart)(c1, c2, c3) ? token_types_1.FLAG_ID : token_types_1.FLAG_UNRESTRICTED;
|
|
221
85
|
const value = this.consumeName();
|
|
222
86
|
return { type: 5 /* TokenType.HASH_TOKEN */, value, flags };
|
|
223
87
|
}
|
|
224
88
|
break;
|
|
225
|
-
|
|
226
|
-
|
|
89
|
+
}
|
|
90
|
+
case token_constants_1.DOLLAR_SIGN:
|
|
91
|
+
if (this.peekCodePoint(0) === token_constants_1.EQUALS_SIGN) {
|
|
227
92
|
this.consumeCodePoint();
|
|
228
|
-
return SUFFIX_MATCH_TOKEN;
|
|
93
|
+
return token_singletons_1.SUFFIX_MATCH_TOKEN;
|
|
229
94
|
}
|
|
230
95
|
break;
|
|
231
|
-
case APOSTROPHE:
|
|
232
|
-
return this.consumeStringToken(APOSTROPHE);
|
|
233
|
-
case LEFT_PARENTHESIS:
|
|
234
|
-
return LEFT_PARENTHESIS_TOKEN;
|
|
235
|
-
case RIGHT_PARENTHESIS:
|
|
236
|
-
return RIGHT_PARENTHESIS_TOKEN;
|
|
237
|
-
case ASTERISK:
|
|
238
|
-
if (this.peekCodePoint(0) === EQUALS_SIGN) {
|
|
96
|
+
case token_constants_1.APOSTROPHE:
|
|
97
|
+
return this.consumeStringToken(token_constants_1.APOSTROPHE);
|
|
98
|
+
case token_constants_1.LEFT_PARENTHESIS:
|
|
99
|
+
return token_singletons_1.LEFT_PARENTHESIS_TOKEN;
|
|
100
|
+
case token_constants_1.RIGHT_PARENTHESIS:
|
|
101
|
+
return token_singletons_1.RIGHT_PARENTHESIS_TOKEN;
|
|
102
|
+
case token_constants_1.ASTERISK:
|
|
103
|
+
if (this.peekCodePoint(0) === token_constants_1.EQUALS_SIGN) {
|
|
239
104
|
this.consumeCodePoint();
|
|
240
|
-
return SUBSTRING_MATCH_TOKEN;
|
|
105
|
+
return token_singletons_1.SUBSTRING_MATCH_TOKEN;
|
|
241
106
|
}
|
|
242
107
|
break;
|
|
243
|
-
case PLUS_SIGN:
|
|
244
|
-
if (isNumberStart(codePoint, this.peekCodePoint(0), this.peekCodePoint(1))) {
|
|
108
|
+
case token_constants_1.PLUS_SIGN:
|
|
109
|
+
if ((0, token_constants_2.isNumberStart)(codePoint, this.peekCodePoint(0), this.peekCodePoint(1))) {
|
|
245
110
|
this.reconsumeCodePoint(codePoint);
|
|
246
111
|
return this.consumeNumericToken();
|
|
247
112
|
}
|
|
248
113
|
break;
|
|
249
|
-
case COMMA:
|
|
250
|
-
return COMMA_TOKEN;
|
|
251
|
-
case HYPHEN_MINUS:
|
|
114
|
+
case token_constants_1.COMMA:
|
|
115
|
+
return token_singletons_1.COMMA_TOKEN;
|
|
116
|
+
case token_constants_1.HYPHEN_MINUS: {
|
|
252
117
|
const e1 = codePoint;
|
|
253
118
|
const e2 = this.peekCodePoint(0);
|
|
254
119
|
const e3 = this.peekCodePoint(1);
|
|
255
|
-
if (isNumberStart(e1, e2, e3)) {
|
|
120
|
+
if ((0, token_constants_2.isNumberStart)(e1, e2, e3)) {
|
|
256
121
|
this.reconsumeCodePoint(codePoint);
|
|
257
122
|
return this.consumeNumericToken();
|
|
258
123
|
}
|
|
259
|
-
if (isIdentifierStart(e1, e2, e3)) {
|
|
124
|
+
if ((0, token_constants_2.isIdentifierStart)(e1, e2, e3)) {
|
|
260
125
|
this.reconsumeCodePoint(codePoint);
|
|
261
126
|
return this.consumeIdentLikeToken();
|
|
262
127
|
}
|
|
263
|
-
if (e2 === HYPHEN_MINUS && e3 === GREATER_THAN_SIGN) {
|
|
128
|
+
if (e2 === token_constants_1.HYPHEN_MINUS && e3 === token_constants_1.GREATER_THAN_SIGN) {
|
|
264
129
|
this.consumeCodePoint();
|
|
265
130
|
this.consumeCodePoint();
|
|
266
|
-
return CDC_TOKEN;
|
|
131
|
+
return token_singletons_1.CDC_TOKEN;
|
|
267
132
|
}
|
|
268
133
|
break;
|
|
269
|
-
|
|
270
|
-
|
|
134
|
+
}
|
|
135
|
+
case token_constants_1.FULL_STOP:
|
|
136
|
+
if ((0, token_constants_2.isNumberStart)(codePoint, this.peekCodePoint(0), this.peekCodePoint(1))) {
|
|
271
137
|
this.reconsumeCodePoint(codePoint);
|
|
272
138
|
return this.consumeNumericToken();
|
|
273
139
|
}
|
|
274
140
|
break;
|
|
275
|
-
case SOLIDUS:
|
|
276
|
-
if (this.peekCodePoint(0) === ASTERISK) {
|
|
141
|
+
case token_constants_1.SOLIDUS:
|
|
142
|
+
if (this.peekCodePoint(0) === token_constants_1.ASTERISK) {
|
|
277
143
|
this.consumeCodePoint();
|
|
278
144
|
while (true) {
|
|
279
145
|
let c = this.consumeCodePoint();
|
|
280
|
-
if (c === ASTERISK) {
|
|
146
|
+
if (c === token_constants_1.ASTERISK) {
|
|
281
147
|
c = this.consumeCodePoint();
|
|
282
|
-
if (c === SOLIDUS) {
|
|
148
|
+
if (c === token_constants_1.SOLIDUS) {
|
|
283
149
|
return this.consumeToken();
|
|
284
150
|
}
|
|
285
151
|
}
|
|
286
|
-
if (c === EOF) {
|
|
152
|
+
if (c === token_constants_1.EOF) {
|
|
287
153
|
return this.consumeToken();
|
|
288
154
|
}
|
|
289
155
|
}
|
|
290
156
|
}
|
|
291
157
|
break;
|
|
292
|
-
case COLON:
|
|
293
|
-
return COLON_TOKEN;
|
|
294
|
-
case SEMICOLON:
|
|
295
|
-
return SEMICOLON_TOKEN;
|
|
296
|
-
case LESS_THAN_SIGN:
|
|
297
|
-
if (this.peekCodePoint(0) === EXCLAMATION_MARK &&
|
|
298
|
-
this.peekCodePoint(1) === HYPHEN_MINUS &&
|
|
299
|
-
this.peekCodePoint(2) === HYPHEN_MINUS) {
|
|
158
|
+
case token_constants_1.COLON:
|
|
159
|
+
return token_singletons_1.COLON_TOKEN;
|
|
160
|
+
case token_constants_1.SEMICOLON:
|
|
161
|
+
return token_singletons_1.SEMICOLON_TOKEN;
|
|
162
|
+
case token_constants_1.LESS_THAN_SIGN:
|
|
163
|
+
if (this.peekCodePoint(0) === token_constants_1.EXCLAMATION_MARK &&
|
|
164
|
+
this.peekCodePoint(1) === token_constants_1.HYPHEN_MINUS &&
|
|
165
|
+
this.peekCodePoint(2) === token_constants_1.HYPHEN_MINUS) {
|
|
300
166
|
this.consumeCodePoint();
|
|
301
167
|
this.consumeCodePoint();
|
|
302
|
-
return CDO_TOKEN;
|
|
168
|
+
return token_singletons_1.CDO_TOKEN;
|
|
303
169
|
}
|
|
304
170
|
break;
|
|
305
|
-
case COMMERCIAL_AT:
|
|
171
|
+
case token_constants_1.COMMERCIAL_AT: {
|
|
306
172
|
const a1 = this.peekCodePoint(0);
|
|
307
173
|
const a2 = this.peekCodePoint(1);
|
|
308
174
|
const a3 = this.peekCodePoint(2);
|
|
309
|
-
if (isIdentifierStart(a1, a2, a3)) {
|
|
175
|
+
if ((0, token_constants_2.isIdentifierStart)(a1, a2, a3)) {
|
|
310
176
|
const value = this.consumeName();
|
|
311
177
|
return { type: 7 /* TokenType.AT_KEYWORD_TOKEN */, value };
|
|
312
178
|
}
|
|
313
179
|
break;
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
180
|
+
}
|
|
181
|
+
case token_constants_1.LEFT_SQUARE_BRACKET:
|
|
182
|
+
return token_singletons_1.LEFT_SQUARE_BRACKET_TOKEN;
|
|
183
|
+
case token_constants_1.REVERSE_SOLIDUS:
|
|
184
|
+
if ((0, token_constants_2.isValidEscape)(codePoint, this.peekCodePoint(0))) {
|
|
318
185
|
this.reconsumeCodePoint(codePoint);
|
|
319
186
|
return this.consumeIdentLikeToken();
|
|
320
187
|
}
|
|
321
188
|
break;
|
|
322
|
-
case RIGHT_SQUARE_BRACKET:
|
|
323
|
-
return RIGHT_SQUARE_BRACKET_TOKEN;
|
|
324
|
-
case CIRCUMFLEX_ACCENT:
|
|
325
|
-
if (this.peekCodePoint(0) === EQUALS_SIGN) {
|
|
189
|
+
case token_constants_1.RIGHT_SQUARE_BRACKET:
|
|
190
|
+
return token_singletons_1.RIGHT_SQUARE_BRACKET_TOKEN;
|
|
191
|
+
case token_constants_1.CIRCUMFLEX_ACCENT:
|
|
192
|
+
if (this.peekCodePoint(0) === token_constants_1.EQUALS_SIGN) {
|
|
326
193
|
this.consumeCodePoint();
|
|
327
|
-
return PREFIX_MATCH_TOKEN;
|
|
194
|
+
return token_singletons_1.PREFIX_MATCH_TOKEN;
|
|
328
195
|
}
|
|
329
196
|
break;
|
|
330
|
-
case LEFT_CURLY_BRACKET:
|
|
331
|
-
return LEFT_CURLY_BRACKET_TOKEN;
|
|
332
|
-
case RIGHT_CURLY_BRACKET:
|
|
333
|
-
return RIGHT_CURLY_BRACKET_TOKEN;
|
|
334
|
-
case u:
|
|
335
|
-
case U:
|
|
197
|
+
case token_constants_1.LEFT_CURLY_BRACKET:
|
|
198
|
+
return token_singletons_1.LEFT_CURLY_BRACKET_TOKEN;
|
|
199
|
+
case token_constants_1.RIGHT_CURLY_BRACKET:
|
|
200
|
+
return token_singletons_1.RIGHT_CURLY_BRACKET_TOKEN;
|
|
201
|
+
case token_constants_1.u:
|
|
202
|
+
case token_constants_1.U: {
|
|
336
203
|
const u1 = this.peekCodePoint(0);
|
|
337
204
|
const u2 = this.peekCodePoint(1);
|
|
338
|
-
if (u1 === PLUS_SIGN && (isHex(u2) || u2 === QUESTION_MARK)) {
|
|
205
|
+
if (u1 === token_constants_1.PLUS_SIGN && ((0, token_constants_2.isHex)(u2) || u2 === token_constants_1.QUESTION_MARK)) {
|
|
339
206
|
this.consumeCodePoint();
|
|
340
207
|
this.consumeUnicodeRangeToken();
|
|
341
208
|
}
|
|
342
209
|
this.reconsumeCodePoint(codePoint);
|
|
343
210
|
return this.consumeIdentLikeToken();
|
|
344
|
-
|
|
345
|
-
|
|
211
|
+
}
|
|
212
|
+
case token_constants_1.VERTICAL_LINE:
|
|
213
|
+
if (this.peekCodePoint(0) === token_constants_1.EQUALS_SIGN) {
|
|
346
214
|
this.consumeCodePoint();
|
|
347
|
-
return DASH_MATCH_TOKEN;
|
|
215
|
+
return token_singletons_1.DASH_MATCH_TOKEN;
|
|
348
216
|
}
|
|
349
|
-
if (this.peekCodePoint(0) === VERTICAL_LINE) {
|
|
217
|
+
if (this.peekCodePoint(0) === token_constants_1.VERTICAL_LINE) {
|
|
350
218
|
this.consumeCodePoint();
|
|
351
|
-
return COLUMN_TOKEN;
|
|
219
|
+
return token_singletons_1.COLUMN_TOKEN;
|
|
352
220
|
}
|
|
353
221
|
break;
|
|
354
|
-
case TILDE:
|
|
355
|
-
if (this.peekCodePoint(0) === EQUALS_SIGN) {
|
|
222
|
+
case token_constants_1.TILDE:
|
|
223
|
+
if (this.peekCodePoint(0) === token_constants_1.EQUALS_SIGN) {
|
|
356
224
|
this.consumeCodePoint();
|
|
357
|
-
return INCLUDE_MATCH_TOKEN;
|
|
225
|
+
return token_singletons_1.INCLUDE_MATCH_TOKEN;
|
|
358
226
|
}
|
|
359
227
|
break;
|
|
360
|
-
case EOF:
|
|
361
|
-
return
|
|
228
|
+
case token_constants_1.EOF:
|
|
229
|
+
return token_singletons_1.EOF_TOKEN;
|
|
362
230
|
}
|
|
363
|
-
if (isWhiteSpace(codePoint)) {
|
|
231
|
+
if ((0, token_constants_2.isWhiteSpace)(codePoint)) {
|
|
364
232
|
this.consumeWhiteSpace();
|
|
365
|
-
return WHITESPACE_TOKEN;
|
|
233
|
+
return token_singletons_1.WHITESPACE_TOKEN;
|
|
366
234
|
}
|
|
367
|
-
if (isDigit(codePoint)) {
|
|
235
|
+
if ((0, token_constants_2.isDigit)(codePoint)) {
|
|
368
236
|
this.reconsumeCodePoint(codePoint);
|
|
369
237
|
return this.consumeNumericToken();
|
|
370
238
|
}
|
|
371
|
-
if (isNameStartCodePoint(codePoint)) {
|
|
239
|
+
if ((0, token_constants_2.isNameStartCodePoint)(codePoint)) {
|
|
372
240
|
this.reconsumeCodePoint(codePoint);
|
|
373
241
|
return this.consumeIdentLikeToken();
|
|
374
242
|
}
|
|
@@ -390,27 +258,27 @@ class Tokenizer {
|
|
|
390
258
|
consumeUnicodeRangeToken() {
|
|
391
259
|
const digits = [];
|
|
392
260
|
let codePoint = this.consumeCodePoint();
|
|
393
|
-
while (isHex(codePoint) && digits.length < 6) {
|
|
261
|
+
while ((0, token_constants_2.isHex)(codePoint) && digits.length < 6) {
|
|
394
262
|
digits.push(codePoint);
|
|
395
263
|
codePoint = this.consumeCodePoint();
|
|
396
264
|
}
|
|
397
265
|
let questionMarks = false;
|
|
398
|
-
while (codePoint === QUESTION_MARK && digits.length < 6) {
|
|
266
|
+
while (codePoint === token_constants_1.QUESTION_MARK && digits.length < 6) {
|
|
399
267
|
digits.push(codePoint);
|
|
400
268
|
codePoint = this.consumeCodePoint();
|
|
401
269
|
questionMarks = true;
|
|
402
270
|
}
|
|
403
271
|
if (questionMarks) {
|
|
404
|
-
const start = parseInt((0, css_line_break_1.fromCodePoint)(...digits.map((digit) => (digit === QUESTION_MARK ? ZERO : digit))), 16);
|
|
405
|
-
const end = parseInt((0, css_line_break_1.fromCodePoint)(...digits.map((digit) => (digit === QUESTION_MARK ? F : digit))), 16);
|
|
272
|
+
const start = parseInt((0, css_line_break_1.fromCodePoint)(...digits.map((digit) => (digit === token_constants_1.QUESTION_MARK ? token_constants_1.ZERO : digit))), 16);
|
|
273
|
+
const end = parseInt((0, css_line_break_1.fromCodePoint)(...digits.map((digit) => (digit === token_constants_1.QUESTION_MARK ? token_constants_1.F : digit))), 16);
|
|
406
274
|
return { type: 30 /* TokenType.UNICODE_RANGE_TOKEN */, start, end };
|
|
407
275
|
}
|
|
408
276
|
const start = parseInt((0, css_line_break_1.fromCodePoint)(...digits), 16);
|
|
409
|
-
if (this.peekCodePoint(0) === HYPHEN_MINUS && isHex(this.peekCodePoint(1))) {
|
|
277
|
+
if (this.peekCodePoint(0) === token_constants_1.HYPHEN_MINUS && (0, token_constants_2.isHex)(this.peekCodePoint(1))) {
|
|
410
278
|
this.consumeCodePoint();
|
|
411
279
|
codePoint = this.consumeCodePoint();
|
|
412
280
|
const endDigits = [];
|
|
413
|
-
while (isHex(codePoint) && endDigits.length < 6) {
|
|
281
|
+
while ((0, token_constants_2.isHex)(codePoint) && endDigits.length < 6) {
|
|
414
282
|
endDigits.push(codePoint);
|
|
415
283
|
codePoint = this.consumeCodePoint();
|
|
416
284
|
}
|
|
@@ -423,11 +291,11 @@ class Tokenizer {
|
|
|
423
291
|
}
|
|
424
292
|
consumeIdentLikeToken() {
|
|
425
293
|
const value = this.consumeName();
|
|
426
|
-
if (value.toLowerCase() === 'url' && this.peekCodePoint(0) === LEFT_PARENTHESIS) {
|
|
294
|
+
if (value.toLowerCase() === 'url' && this.peekCodePoint(0) === token_constants_1.LEFT_PARENTHESIS) {
|
|
427
295
|
this.consumeCodePoint();
|
|
428
296
|
return this.consumeUrlToken();
|
|
429
297
|
}
|
|
430
|
-
else if (this.peekCodePoint(0) === LEFT_PARENTHESIS) {
|
|
298
|
+
else if (this.peekCodePoint(0) === token_constants_1.LEFT_PARENTHESIS) {
|
|
431
299
|
this.consumeCodePoint();
|
|
432
300
|
return { type: 19 /* TokenType.FUNCTION_TOKEN */, value };
|
|
433
301
|
}
|
|
@@ -436,50 +304,50 @@ class Tokenizer {
|
|
|
436
304
|
consumeUrlToken() {
|
|
437
305
|
const value = [];
|
|
438
306
|
this.consumeWhiteSpace();
|
|
439
|
-
if (this.peekCodePoint(0) === EOF) {
|
|
307
|
+
if (this.peekCodePoint(0) === token_constants_1.EOF) {
|
|
440
308
|
return { type: 22 /* TokenType.URL_TOKEN */, value: '' };
|
|
441
309
|
}
|
|
442
310
|
const next = this.peekCodePoint(0);
|
|
443
|
-
if (next === APOSTROPHE || next === QUOTATION_MARK) {
|
|
311
|
+
if (next === token_constants_1.APOSTROPHE || next === token_constants_1.QUOTATION_MARK) {
|
|
444
312
|
const stringToken = this.consumeStringToken(this.consumeCodePoint());
|
|
445
313
|
if (stringToken.type === 0 /* TokenType.STRING_TOKEN */) {
|
|
446
314
|
this.consumeWhiteSpace();
|
|
447
|
-
if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {
|
|
315
|
+
if (this.peekCodePoint(0) === token_constants_1.EOF || this.peekCodePoint(0) === token_constants_1.RIGHT_PARENTHESIS) {
|
|
448
316
|
this.consumeCodePoint();
|
|
449
317
|
return { type: 22 /* TokenType.URL_TOKEN */, value: stringToken.value };
|
|
450
318
|
}
|
|
451
319
|
}
|
|
452
320
|
this.consumeBadUrlRemnants();
|
|
453
|
-
return BAD_URL_TOKEN;
|
|
321
|
+
return token_singletons_1.BAD_URL_TOKEN;
|
|
454
322
|
}
|
|
455
323
|
while (true) {
|
|
456
324
|
const codePoint = this.consumeCodePoint();
|
|
457
|
-
if (codePoint === EOF || codePoint === RIGHT_PARENTHESIS) {
|
|
325
|
+
if (codePoint === token_constants_1.EOF || codePoint === token_constants_1.RIGHT_PARENTHESIS) {
|
|
458
326
|
return { type: 22 /* TokenType.URL_TOKEN */, value: (0, css_line_break_1.fromCodePoint)(...value) };
|
|
459
327
|
}
|
|
460
|
-
else if (isWhiteSpace(codePoint)) {
|
|
328
|
+
else if ((0, token_constants_2.isWhiteSpace)(codePoint)) {
|
|
461
329
|
this.consumeWhiteSpace();
|
|
462
|
-
if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {
|
|
330
|
+
if (this.peekCodePoint(0) === token_constants_1.EOF || this.peekCodePoint(0) === token_constants_1.RIGHT_PARENTHESIS) {
|
|
463
331
|
this.consumeCodePoint();
|
|
464
332
|
return { type: 22 /* TokenType.URL_TOKEN */, value: (0, css_line_break_1.fromCodePoint)(...value) };
|
|
465
333
|
}
|
|
466
334
|
this.consumeBadUrlRemnants();
|
|
467
|
-
return BAD_URL_TOKEN;
|
|
335
|
+
return token_singletons_1.BAD_URL_TOKEN;
|
|
468
336
|
}
|
|
469
|
-
else if (codePoint === QUOTATION_MARK ||
|
|
470
|
-
codePoint === APOSTROPHE ||
|
|
471
|
-
codePoint === LEFT_PARENTHESIS ||
|
|
472
|
-
isNonPrintableCodePoint(codePoint)) {
|
|
337
|
+
else if (codePoint === token_constants_1.QUOTATION_MARK ||
|
|
338
|
+
codePoint === token_constants_1.APOSTROPHE ||
|
|
339
|
+
codePoint === token_constants_1.LEFT_PARENTHESIS ||
|
|
340
|
+
(0, token_constants_2.isNonPrintableCodePoint)(codePoint)) {
|
|
473
341
|
this.consumeBadUrlRemnants();
|
|
474
|
-
return BAD_URL_TOKEN;
|
|
342
|
+
return token_singletons_1.BAD_URL_TOKEN;
|
|
475
343
|
}
|
|
476
|
-
else if (codePoint === REVERSE_SOLIDUS) {
|
|
477
|
-
if (isValidEscape(codePoint, this.peekCodePoint(0))) {
|
|
344
|
+
else if (codePoint === token_constants_1.REVERSE_SOLIDUS) {
|
|
345
|
+
if ((0, token_constants_2.isValidEscape)(codePoint, this.peekCodePoint(0))) {
|
|
478
346
|
value.push(this.consumeEscapedCodePoint());
|
|
479
347
|
}
|
|
480
348
|
else {
|
|
481
349
|
this.consumeBadUrlRemnants();
|
|
482
|
-
return BAD_URL_TOKEN;
|
|
350
|
+
return token_singletons_1.BAD_URL_TOKEN;
|
|
483
351
|
}
|
|
484
352
|
}
|
|
485
353
|
else {
|
|
@@ -488,17 +356,17 @@ class Tokenizer {
|
|
|
488
356
|
}
|
|
489
357
|
}
|
|
490
358
|
consumeWhiteSpace() {
|
|
491
|
-
while (isWhiteSpace(this.peekCodePoint(0))) {
|
|
359
|
+
while ((0, token_constants_2.isWhiteSpace)(this.peekCodePoint(0))) {
|
|
492
360
|
this.consumeCodePoint();
|
|
493
361
|
}
|
|
494
362
|
}
|
|
495
363
|
consumeBadUrlRemnants() {
|
|
496
364
|
while (true) {
|
|
497
365
|
const codePoint = this.consumeCodePoint();
|
|
498
|
-
if (codePoint === RIGHT_PARENTHESIS || codePoint === EOF) {
|
|
366
|
+
if (codePoint === token_constants_1.RIGHT_PARENTHESIS || codePoint === token_constants_1.EOF) {
|
|
499
367
|
return;
|
|
500
368
|
}
|
|
501
|
-
if (isValidEscape(codePoint, this.peekCodePoint(0))) {
|
|
369
|
+
if ((0, token_constants_2.isValidEscape)(codePoint, this.peekCodePoint(0))) {
|
|
502
370
|
this.consumeEscapedCodePoint();
|
|
503
371
|
}
|
|
504
372
|
}
|
|
@@ -519,23 +387,23 @@ class Tokenizer {
|
|
|
519
387
|
let i = 0;
|
|
520
388
|
do {
|
|
521
389
|
const codePoint = this._value[i];
|
|
522
|
-
if (codePoint === EOF || codePoint === undefined || codePoint === endingCodePoint) {
|
|
390
|
+
if (codePoint === token_constants_1.EOF || codePoint === undefined || codePoint === endingCodePoint) {
|
|
523
391
|
value += this.consumeStringSlice(i);
|
|
524
392
|
return { type: 0 /* TokenType.STRING_TOKEN */, value };
|
|
525
393
|
}
|
|
526
|
-
if (codePoint === LINE_FEED) {
|
|
394
|
+
if (codePoint === token_constants_1.LINE_FEED) {
|
|
527
395
|
this._value.splice(0, i);
|
|
528
|
-
return BAD_STRING_TOKEN;
|
|
396
|
+
return token_singletons_1.BAD_STRING_TOKEN;
|
|
529
397
|
}
|
|
530
|
-
if (codePoint === REVERSE_SOLIDUS) {
|
|
398
|
+
if (codePoint === token_constants_1.REVERSE_SOLIDUS) {
|
|
531
399
|
const next = this._value[i + 1];
|
|
532
|
-
if (next !== EOF && next !== undefined) {
|
|
533
|
-
if (next === LINE_FEED) {
|
|
400
|
+
if (next !== token_constants_1.EOF && next !== undefined) {
|
|
401
|
+
if (next === token_constants_1.LINE_FEED) {
|
|
534
402
|
value += this.consumeStringSlice(i);
|
|
535
403
|
i = -1;
|
|
536
404
|
this._value.shift();
|
|
537
405
|
}
|
|
538
|
-
else if (isValidEscape(codePoint, next)) {
|
|
406
|
+
else if ((0, token_constants_2.isValidEscape)(codePoint, next)) {
|
|
539
407
|
value += this.consumeStringSlice(i);
|
|
540
408
|
value += (0, css_line_break_1.fromCodePoint)(this.consumeEscapedCodePoint());
|
|
541
409
|
i = -1;
|
|
@@ -547,45 +415,45 @@ class Tokenizer {
|
|
|
547
415
|
}
|
|
548
416
|
consumeNumber() {
|
|
549
417
|
const repr = [];
|
|
550
|
-
let type =
|
|
418
|
+
let type = token_types_1.FLAG_INTEGER;
|
|
551
419
|
let c1 = this.peekCodePoint(0);
|
|
552
|
-
if (c1 === PLUS_SIGN || c1 === HYPHEN_MINUS) {
|
|
420
|
+
if (c1 === token_constants_1.PLUS_SIGN || c1 === token_constants_1.HYPHEN_MINUS) {
|
|
553
421
|
repr.push(this.consumeCodePoint());
|
|
554
422
|
}
|
|
555
|
-
while (isDigit(this.peekCodePoint(0))) {
|
|
423
|
+
while ((0, token_constants_2.isDigit)(this.peekCodePoint(0))) {
|
|
556
424
|
repr.push(this.consumeCodePoint());
|
|
557
425
|
}
|
|
558
426
|
c1 = this.peekCodePoint(0);
|
|
559
427
|
let c2 = this.peekCodePoint(1);
|
|
560
|
-
if (c1 === FULL_STOP && isDigit(c2)) {
|
|
428
|
+
if (c1 === token_constants_1.FULL_STOP && (0, token_constants_2.isDigit)(c2)) {
|
|
561
429
|
repr.push(this.consumeCodePoint(), this.consumeCodePoint());
|
|
562
|
-
type =
|
|
563
|
-
while (isDigit(this.peekCodePoint(0))) {
|
|
430
|
+
type = token_types_1.FLAG_NUMBER;
|
|
431
|
+
while ((0, token_constants_2.isDigit)(this.peekCodePoint(0))) {
|
|
564
432
|
repr.push(this.consumeCodePoint());
|
|
565
433
|
}
|
|
566
434
|
}
|
|
567
435
|
c1 = this.peekCodePoint(0);
|
|
568
436
|
c2 = this.peekCodePoint(1);
|
|
569
437
|
const c3 = this.peekCodePoint(2);
|
|
570
|
-
if ((c1 === E || c1 === e) && (((c2 === PLUS_SIGN || c2 === HYPHEN_MINUS) && isDigit(c3)) || isDigit(c2))) {
|
|
438
|
+
if ((c1 === token_constants_1.E || c1 === token_constants_1.e) && (((c2 === token_constants_1.PLUS_SIGN || c2 === token_constants_1.HYPHEN_MINUS) && (0, token_constants_2.isDigit)(c3)) || (0, token_constants_2.isDigit)(c2))) {
|
|
571
439
|
repr.push(this.consumeCodePoint(), this.consumeCodePoint());
|
|
572
|
-
type =
|
|
573
|
-
while (isDigit(this.peekCodePoint(0))) {
|
|
440
|
+
type = token_types_1.FLAG_NUMBER;
|
|
441
|
+
while ((0, token_constants_2.isDigit)(this.peekCodePoint(0))) {
|
|
574
442
|
repr.push(this.consumeCodePoint());
|
|
575
443
|
}
|
|
576
444
|
}
|
|
577
|
-
return [stringToNumber(repr), type];
|
|
445
|
+
return [(0, token_constants_2.stringToNumber)(repr), type];
|
|
578
446
|
}
|
|
579
447
|
consumeNumericToken() {
|
|
580
448
|
const [number, flags] = this.consumeNumber();
|
|
581
449
|
const c1 = this.peekCodePoint(0);
|
|
582
450
|
const c2 = this.peekCodePoint(1);
|
|
583
451
|
const c3 = this.peekCodePoint(2);
|
|
584
|
-
if (isIdentifierStart(c1, c2, c3)) {
|
|
452
|
+
if ((0, token_constants_2.isIdentifierStart)(c1, c2, c3)) {
|
|
585
453
|
const unit = this.consumeName();
|
|
586
454
|
return { type: 15 /* TokenType.DIMENSION_TOKEN */, number, flags, unit };
|
|
587
455
|
}
|
|
588
|
-
if (c1 === PERCENTAGE_SIGN) {
|
|
456
|
+
if (c1 === token_constants_1.PERCENTAGE_SIGN) {
|
|
589
457
|
this.consumeCodePoint();
|
|
590
458
|
return { type: 16 /* TokenType.PERCENTAGE_TOKEN */, number, flags };
|
|
591
459
|
}
|
|
@@ -593,22 +461,22 @@ class Tokenizer {
|
|
|
593
461
|
}
|
|
594
462
|
consumeEscapedCodePoint() {
|
|
595
463
|
const codePoint = this.consumeCodePoint();
|
|
596
|
-
if (isHex(codePoint)) {
|
|
464
|
+
if ((0, token_constants_2.isHex)(codePoint)) {
|
|
597
465
|
let hex = (0, css_line_break_1.fromCodePoint)(codePoint);
|
|
598
|
-
while (isHex(this.peekCodePoint(0)) && hex.length < 6) {
|
|
466
|
+
while ((0, token_constants_2.isHex)(this.peekCodePoint(0)) && hex.length < 6) {
|
|
599
467
|
hex += (0, css_line_break_1.fromCodePoint)(this.consumeCodePoint());
|
|
600
468
|
}
|
|
601
|
-
if (isWhiteSpace(this.peekCodePoint(0))) {
|
|
469
|
+
if ((0, token_constants_2.isWhiteSpace)(this.peekCodePoint(0))) {
|
|
602
470
|
this.consumeCodePoint();
|
|
603
471
|
}
|
|
604
472
|
const hexCodePoint = parseInt(hex, 16);
|
|
605
|
-
if (hexCodePoint === 0 || isSurrogateCodePoint(hexCodePoint) || hexCodePoint > 0x10ffff) {
|
|
606
|
-
return REPLACEMENT_CHARACTER;
|
|
473
|
+
if (hexCodePoint === 0 || (0, token_constants_2.isSurrogateCodePoint)(hexCodePoint) || hexCodePoint > 0x10ffff) {
|
|
474
|
+
return token_constants_1.REPLACEMENT_CHARACTER;
|
|
607
475
|
}
|
|
608
476
|
return hexCodePoint;
|
|
609
477
|
}
|
|
610
|
-
if (codePoint === EOF) {
|
|
611
|
-
return REPLACEMENT_CHARACTER;
|
|
478
|
+
if (codePoint === token_constants_1.EOF) {
|
|
479
|
+
return token_constants_1.REPLACEMENT_CHARACTER;
|
|
612
480
|
}
|
|
613
481
|
return codePoint;
|
|
614
482
|
}
|
|
@@ -616,10 +484,10 @@ class Tokenizer {
|
|
|
616
484
|
let result = '';
|
|
617
485
|
while (true) {
|
|
618
486
|
const codePoint = this.consumeCodePoint();
|
|
619
|
-
if (isNameCodePoint(codePoint)) {
|
|
487
|
+
if ((0, token_constants_2.isNameCodePoint)(codePoint)) {
|
|
620
488
|
result += (0, css_line_break_1.fromCodePoint)(codePoint);
|
|
621
489
|
}
|
|
622
|
-
else if (isValidEscape(codePoint, this.peekCodePoint(0))) {
|
|
490
|
+
else if ((0, token_constants_2.isValidEscape)(codePoint, this.peekCodePoint(0))) {
|
|
623
491
|
result += (0, css_line_break_1.fromCodePoint)(this.consumeEscapedCodePoint());
|
|
624
492
|
}
|
|
625
493
|
else {
|