@vitest/utils 2.1.1 → 2.1.2
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/{chunk-display.js → chunk-_commonjsHelpers.js} +5 -1
- package/dist/diff.js +809 -798
- package/dist/error.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +370 -354
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
export { assertTypes, clone, createDefer, createSimpleStackTrace, deepClone, getCallLastIndex, getOwnProperties, getType, isNegativeNaN, isObject, isPrimitive, noop, notNullish, objectAttr, parseRegexp, slash, toArray } from './helpers.js';
|
2
|
-
|
2
|
+
import { g as getDefaultExportFromCjs } from './chunk-_commonjsHelpers.js';
|
3
|
+
export { f as format, i as inspect, o as objDisplay, s as stringify } from './chunk-_commonjsHelpers.js';
|
3
4
|
import c from 'tinyrainbow';
|
4
5
|
import 'loupe';
|
5
6
|
import '@vitest/pretty-format';
|
@@ -99,400 +100,405 @@ function offsetToLineNumber(source, offset) {
|
|
99
100
|
return line + 1;
|
100
101
|
}
|
101
102
|
|
102
|
-
|
103
|
-
|
104
|
-
}
|
103
|
+
var jsTokens_1;
|
104
|
+
var hasRequiredJsTokens;
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
Identifier
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
value: match[0],
|
155
|
-
closed: match[1] !== void 0 && match[1] !== "\\"
|
156
|
-
});
|
157
|
-
continue;
|
158
|
-
}
|
159
|
-
}
|
160
|
-
Punctuator.lastIndex = lastIndex;
|
161
|
-
if (match = Punctuator.exec(input)) {
|
162
|
-
punctuator = match[0];
|
163
|
-
nextLastIndex = Punctuator.lastIndex;
|
164
|
-
nextLastSignificantToken = punctuator;
|
165
|
-
switch (punctuator) {
|
166
|
-
case "(":
|
167
|
-
if (lastSignificantToken === "?NonExpressionParenKeyword") {
|
168
|
-
stack.push({
|
169
|
-
tag: "JSNonExpressionParen",
|
170
|
-
nesting: parenNesting
|
171
|
-
});
|
172
|
-
}
|
173
|
-
parenNesting++;
|
174
|
-
postfixIncDec = false;
|
175
|
-
break;
|
176
|
-
case ")":
|
177
|
-
parenNesting--;
|
106
|
+
function requireJsTokens () {
|
107
|
+
if (hasRequiredJsTokens) return jsTokens_1;
|
108
|
+
hasRequiredJsTokens = 1;
|
109
|
+
// Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
|
110
|
+
// License: MIT.
|
111
|
+
var Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
|
112
|
+
RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\\]).|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/yu;
|
113
|
+
Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
|
114
|
+
Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/yu;
|
115
|
+
StringLiteral = /(['"])(?:(?!\1)[^\\\n\r]|\\(?:\r\n|[^]))*(\1)?/y;
|
116
|
+
NumericLiteral = /(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\d)*n|(?:(?:0(?!\d)|0\d*[89]\d*|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?|0[0-7]+/y;
|
117
|
+
Template = /[`}](?:[^`\\$]|\\[^]|\$(?!\{))*(`|\$\{)?/y;
|
118
|
+
WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/yu;
|
119
|
+
LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
|
120
|
+
MultiLineComment = /\/\*(?:[^*]|\*(?!\/))*(\*\/)?/y;
|
121
|
+
SingleLineComment = /\/\/.*/y;
|
122
|
+
JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
|
123
|
+
JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/yu;
|
124
|
+
JSXString = /(['"])(?:(?!\1)[^])*(\1)?/y;
|
125
|
+
JSXText = /[^<>{}]+/y;
|
126
|
+
TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/;
|
127
|
+
TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/;
|
128
|
+
KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/;
|
129
|
+
KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/;
|
130
|
+
Newline = RegExp(LineTerminatorSequence.source);
|
131
|
+
jsTokens_1 = function*(input, {jsx = false} = {}) {
|
132
|
+
var braces, firstCodePoint, isExpression, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack;
|
133
|
+
({length} = input);
|
134
|
+
lastIndex = 0;
|
135
|
+
lastSignificantToken = "";
|
136
|
+
stack = [
|
137
|
+
{tag: "JS"}
|
138
|
+
];
|
139
|
+
braces = [];
|
140
|
+
parenNesting = 0;
|
141
|
+
postfixIncDec = false;
|
142
|
+
while (lastIndex < length) {
|
143
|
+
mode = stack[stack.length - 1];
|
144
|
+
switch (mode.tag) {
|
145
|
+
case "JS":
|
146
|
+
case "JSNonExpressionParen":
|
147
|
+
case "InterpolationInTemplate":
|
148
|
+
case "InterpolationInJSX":
|
149
|
+
if (input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
|
150
|
+
RegularExpressionLiteral.lastIndex = lastIndex;
|
151
|
+
if (match = RegularExpressionLiteral.exec(input)) {
|
152
|
+
lastIndex = RegularExpressionLiteral.lastIndex;
|
153
|
+
lastSignificantToken = match[0];
|
178
154
|
postfixIncDec = true;
|
179
|
-
|
180
|
-
|
181
|
-
|
155
|
+
yield ({
|
156
|
+
type: "RegularExpressionLiteral",
|
157
|
+
value: match[0],
|
158
|
+
closed: match[1] !== void 0 && match[1] !== "\\"
|
159
|
+
});
|
160
|
+
continue;
|
161
|
+
}
|
162
|
+
}
|
163
|
+
Punctuator.lastIndex = lastIndex;
|
164
|
+
if (match = Punctuator.exec(input)) {
|
165
|
+
punctuator = match[0];
|
166
|
+
nextLastIndex = Punctuator.lastIndex;
|
167
|
+
nextLastSignificantToken = punctuator;
|
168
|
+
switch (punctuator) {
|
169
|
+
case "(":
|
170
|
+
if (lastSignificantToken === "?NonExpressionParenKeyword") {
|
171
|
+
stack.push({
|
172
|
+
tag: "JSNonExpressionParen",
|
173
|
+
nesting: parenNesting
|
174
|
+
});
|
175
|
+
}
|
176
|
+
parenNesting++;
|
182
177
|
postfixIncDec = false;
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
178
|
+
break;
|
179
|
+
case ")":
|
180
|
+
parenNesting--;
|
181
|
+
postfixIncDec = true;
|
182
|
+
if (mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting) {
|
183
|
+
stack.pop();
|
184
|
+
nextLastSignificantToken = "?NonExpressionParenEnd";
|
185
|
+
postfixIncDec = false;
|
186
|
+
}
|
187
|
+
break;
|
188
|
+
case "{":
|
189
|
+
Punctuator.lastIndex = 0;
|
190
|
+
isExpression = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken));
|
191
|
+
braces.push(isExpression);
|
192
|
+
postfixIncDec = false;
|
193
|
+
break;
|
194
|
+
case "}":
|
195
|
+
switch (mode.tag) {
|
196
|
+
case "InterpolationInTemplate":
|
197
|
+
if (braces.length === mode.nesting) {
|
198
|
+
Template.lastIndex = lastIndex;
|
199
|
+
match = Template.exec(input);
|
200
|
+
lastIndex = Template.lastIndex;
|
201
|
+
lastSignificantToken = match[0];
|
202
|
+
if (match[1] === "${") {
|
203
|
+
lastSignificantToken = "?InterpolationInTemplate";
|
204
|
+
postfixIncDec = false;
|
205
|
+
yield ({
|
206
|
+
type: "TemplateMiddle",
|
207
|
+
value: match[0]
|
208
|
+
});
|
209
|
+
} else {
|
210
|
+
stack.pop();
|
211
|
+
postfixIncDec = true;
|
212
|
+
yield ({
|
213
|
+
type: "TemplateTail",
|
214
|
+
value: match[0],
|
215
|
+
closed: match[1] === "`"
|
216
|
+
});
|
217
|
+
}
|
218
|
+
continue;
|
219
|
+
}
|
220
|
+
break;
|
221
|
+
case "InterpolationInJSX":
|
222
|
+
if (braces.length === mode.nesting) {
|
207
223
|
stack.pop();
|
208
|
-
|
224
|
+
lastIndex += 1;
|
225
|
+
lastSignificantToken = "}";
|
209
226
|
yield ({
|
210
|
-
type: "
|
211
|
-
value:
|
212
|
-
closed: match[1] === "`"
|
227
|
+
type: "JSXPunctuator",
|
228
|
+
value: "}"
|
213
229
|
});
|
230
|
+
continue;
|
214
231
|
}
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
}
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
value: punctuator
|
248
|
-
});
|
249
|
-
continue;
|
250
|
-
}
|
251
|
-
postfixIncDec = false;
|
252
|
-
break;
|
253
|
-
default:
|
254
|
-
postfixIncDec = false;
|
255
|
-
}
|
256
|
-
lastIndex = nextLastIndex;
|
257
|
-
lastSignificantToken = nextLastSignificantToken;
|
258
|
-
yield ({
|
259
|
-
type: "Punctuator",
|
260
|
-
value: punctuator
|
261
|
-
});
|
262
|
-
continue;
|
263
|
-
}
|
264
|
-
Identifier.lastIndex = lastIndex;
|
265
|
-
if (match = Identifier.exec(input)) {
|
266
|
-
lastIndex = Identifier.lastIndex;
|
267
|
-
nextLastSignificantToken = match[0];
|
268
|
-
switch (match[0]) {
|
269
|
-
case "for":
|
270
|
-
case "if":
|
271
|
-
case "while":
|
272
|
-
case "with":
|
273
|
-
if (lastSignificantToken !== "." && lastSignificantToken !== "?.") {
|
274
|
-
nextLastSignificantToken = "?NonExpressionParenKeyword";
|
275
|
-
}
|
276
|
-
}
|
277
|
-
lastSignificantToken = nextLastSignificantToken;
|
278
|
-
postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]);
|
279
|
-
yield ({
|
280
|
-
type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName",
|
281
|
-
value: match[0]
|
282
|
-
});
|
283
|
-
continue;
|
284
|
-
}
|
285
|
-
StringLiteral.lastIndex = lastIndex;
|
286
|
-
if (match = StringLiteral.exec(input)) {
|
287
|
-
lastIndex = StringLiteral.lastIndex;
|
288
|
-
lastSignificantToken = match[0];
|
289
|
-
postfixIncDec = true;
|
290
|
-
yield ({
|
291
|
-
type: "StringLiteral",
|
292
|
-
value: match[0],
|
293
|
-
closed: match[2] !== void 0
|
294
|
-
});
|
295
|
-
continue;
|
296
|
-
}
|
297
|
-
NumericLiteral.lastIndex = lastIndex;
|
298
|
-
if (match = NumericLiteral.exec(input)) {
|
299
|
-
lastIndex = NumericLiteral.lastIndex;
|
300
|
-
lastSignificantToken = match[0];
|
301
|
-
postfixIncDec = true;
|
302
|
-
yield ({
|
303
|
-
type: "NumericLiteral",
|
304
|
-
value: match[0]
|
305
|
-
});
|
306
|
-
continue;
|
307
|
-
}
|
308
|
-
Template.lastIndex = lastIndex;
|
309
|
-
if (match = Template.exec(input)) {
|
310
|
-
lastIndex = Template.lastIndex;
|
311
|
-
lastSignificantToken = match[0];
|
312
|
-
if (match[1] === "${") {
|
313
|
-
lastSignificantToken = "?InterpolationInTemplate";
|
314
|
-
stack.push({
|
315
|
-
tag: "InterpolationInTemplate",
|
316
|
-
nesting: braces.length
|
232
|
+
}
|
233
|
+
postfixIncDec = braces.pop();
|
234
|
+
nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}";
|
235
|
+
break;
|
236
|
+
case "]":
|
237
|
+
postfixIncDec = true;
|
238
|
+
break;
|
239
|
+
case "++":
|
240
|
+
case "--":
|
241
|
+
nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec";
|
242
|
+
break;
|
243
|
+
case "<":
|
244
|
+
if (jsx && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
|
245
|
+
stack.push({tag: "JSXTag"});
|
246
|
+
lastIndex += 1;
|
247
|
+
lastSignificantToken = "<";
|
248
|
+
yield ({
|
249
|
+
type: "JSXPunctuator",
|
250
|
+
value: punctuator
|
251
|
+
});
|
252
|
+
continue;
|
253
|
+
}
|
254
|
+
postfixIncDec = false;
|
255
|
+
break;
|
256
|
+
default:
|
257
|
+
postfixIncDec = false;
|
258
|
+
}
|
259
|
+
lastIndex = nextLastIndex;
|
260
|
+
lastSignificantToken = nextLastSignificantToken;
|
261
|
+
yield ({
|
262
|
+
type: "Punctuator",
|
263
|
+
value: punctuator
|
317
264
|
});
|
318
|
-
|
265
|
+
continue;
|
266
|
+
}
|
267
|
+
Identifier.lastIndex = lastIndex;
|
268
|
+
if (match = Identifier.exec(input)) {
|
269
|
+
lastIndex = Identifier.lastIndex;
|
270
|
+
nextLastSignificantToken = match[0];
|
271
|
+
switch (match[0]) {
|
272
|
+
case "for":
|
273
|
+
case "if":
|
274
|
+
case "while":
|
275
|
+
case "with":
|
276
|
+
if (lastSignificantToken !== "." && lastSignificantToken !== "?.") {
|
277
|
+
nextLastSignificantToken = "?NonExpressionParenKeyword";
|
278
|
+
}
|
279
|
+
}
|
280
|
+
lastSignificantToken = nextLastSignificantToken;
|
281
|
+
postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]);
|
319
282
|
yield ({
|
320
|
-
type: "
|
283
|
+
type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName",
|
321
284
|
value: match[0]
|
322
285
|
});
|
323
|
-
|
286
|
+
continue;
|
287
|
+
}
|
288
|
+
StringLiteral.lastIndex = lastIndex;
|
289
|
+
if (match = StringLiteral.exec(input)) {
|
290
|
+
lastIndex = StringLiteral.lastIndex;
|
291
|
+
lastSignificantToken = match[0];
|
324
292
|
postfixIncDec = true;
|
325
293
|
yield ({
|
326
|
-
type: "
|
294
|
+
type: "StringLiteral",
|
327
295
|
value: match[0],
|
328
|
-
closed: match[
|
296
|
+
closed: match[2] !== void 0
|
329
297
|
});
|
298
|
+
continue;
|
330
299
|
}
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
postfixIncDec = true;
|
349
|
-
} else {
|
350
|
-
stack.push({tag: "JSXChildren"});
|
351
|
-
}
|
352
|
-
break;
|
353
|
-
case "{":
|
300
|
+
NumericLiteral.lastIndex = lastIndex;
|
301
|
+
if (match = NumericLiteral.exec(input)) {
|
302
|
+
lastIndex = NumericLiteral.lastIndex;
|
303
|
+
lastSignificantToken = match[0];
|
304
|
+
postfixIncDec = true;
|
305
|
+
yield ({
|
306
|
+
type: "NumericLiteral",
|
307
|
+
value: match[0]
|
308
|
+
});
|
309
|
+
continue;
|
310
|
+
}
|
311
|
+
Template.lastIndex = lastIndex;
|
312
|
+
if (match = Template.exec(input)) {
|
313
|
+
lastIndex = Template.lastIndex;
|
314
|
+
lastSignificantToken = match[0];
|
315
|
+
if (match[1] === "${") {
|
316
|
+
lastSignificantToken = "?InterpolationInTemplate";
|
354
317
|
stack.push({
|
355
|
-
tag: "
|
318
|
+
tag: "InterpolationInTemplate",
|
356
319
|
nesting: braces.length
|
357
320
|
});
|
358
|
-
nextLastSignificantToken = "?InterpolationInJSX";
|
359
321
|
postfixIncDec = false;
|
360
|
-
|
361
|
-
|
362
|
-
|
322
|
+
yield ({
|
323
|
+
type: "TemplateHead",
|
324
|
+
value: match[0]
|
325
|
+
});
|
326
|
+
} else {
|
327
|
+
postfixIncDec = true;
|
328
|
+
yield ({
|
329
|
+
type: "NoSubstitutionTemplate",
|
330
|
+
value: match[0],
|
331
|
+
closed: match[1] === "`"
|
332
|
+
});
|
333
|
+
}
|
334
|
+
continue;
|
335
|
+
}
|
336
|
+
break;
|
337
|
+
case "JSXTag":
|
338
|
+
case "JSXTagEnd":
|
339
|
+
JSXPunctuator.lastIndex = lastIndex;
|
340
|
+
if (match = JSXPunctuator.exec(input)) {
|
341
|
+
lastIndex = JSXPunctuator.lastIndex;
|
342
|
+
nextLastSignificantToken = match[0];
|
343
|
+
switch (match[0]) {
|
344
|
+
case "<":
|
345
|
+
stack.push({tag: "JSXTag"});
|
346
|
+
break;
|
347
|
+
case ">":
|
363
348
|
stack.pop();
|
364
|
-
if (
|
349
|
+
if (lastSignificantToken === "/" || mode.tag === "JSXTagEnd") {
|
350
|
+
nextLastSignificantToken = "?JSX";
|
351
|
+
postfixIncDec = true;
|
352
|
+
} else {
|
353
|
+
stack.push({tag: "JSXChildren"});
|
354
|
+
}
|
355
|
+
break;
|
356
|
+
case "{":
|
357
|
+
stack.push({
|
358
|
+
tag: "InterpolationInJSX",
|
359
|
+
nesting: braces.length
|
360
|
+
});
|
361
|
+
nextLastSignificantToken = "?InterpolationInJSX";
|
362
|
+
postfixIncDec = false;
|
363
|
+
break;
|
364
|
+
case "/":
|
365
|
+
if (lastSignificantToken === "<") {
|
365
366
|
stack.pop();
|
367
|
+
if (stack[stack.length - 1].tag === "JSXChildren") {
|
368
|
+
stack.pop();
|
369
|
+
}
|
370
|
+
stack.push({tag: "JSXTagEnd"});
|
366
371
|
}
|
367
|
-
|
368
|
-
|
369
|
-
}
|
370
|
-
lastSignificantToken = nextLastSignificantToken;
|
371
|
-
yield ({
|
372
|
-
type: "JSXPunctuator",
|
373
|
-
value: match[0]
|
374
|
-
});
|
375
|
-
continue;
|
376
|
-
}
|
377
|
-
JSXIdentifier.lastIndex = lastIndex;
|
378
|
-
if (match = JSXIdentifier.exec(input)) {
|
379
|
-
lastIndex = JSXIdentifier.lastIndex;
|
380
|
-
lastSignificantToken = match[0];
|
381
|
-
yield ({
|
382
|
-
type: "JSXIdentifier",
|
383
|
-
value: match[0]
|
384
|
-
});
|
385
|
-
continue;
|
386
|
-
}
|
387
|
-
JSXString.lastIndex = lastIndex;
|
388
|
-
if (match = JSXString.exec(input)) {
|
389
|
-
lastIndex = JSXString.lastIndex;
|
390
|
-
lastSignificantToken = match[0];
|
391
|
-
yield ({
|
392
|
-
type: "JSXString",
|
393
|
-
value: match[0],
|
394
|
-
closed: match[2] !== void 0
|
395
|
-
});
|
396
|
-
continue;
|
397
|
-
}
|
398
|
-
break;
|
399
|
-
case "JSXChildren":
|
400
|
-
JSXText.lastIndex = lastIndex;
|
401
|
-
if (match = JSXText.exec(input)) {
|
402
|
-
lastIndex = JSXText.lastIndex;
|
403
|
-
lastSignificantToken = match[0];
|
404
|
-
yield ({
|
405
|
-
type: "JSXText",
|
406
|
-
value: match[0]
|
407
|
-
});
|
408
|
-
continue;
|
409
|
-
}
|
410
|
-
switch (input[lastIndex]) {
|
411
|
-
case "<":
|
412
|
-
stack.push({tag: "JSXTag"});
|
413
|
-
lastIndex++;
|
414
|
-
lastSignificantToken = "<";
|
372
|
+
}
|
373
|
+
lastSignificantToken = nextLastSignificantToken;
|
415
374
|
yield ({
|
416
375
|
type: "JSXPunctuator",
|
417
|
-
value:
|
376
|
+
value: match[0]
|
418
377
|
});
|
419
378
|
continue;
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
379
|
+
}
|
380
|
+
JSXIdentifier.lastIndex = lastIndex;
|
381
|
+
if (match = JSXIdentifier.exec(input)) {
|
382
|
+
lastIndex = JSXIdentifier.lastIndex;
|
383
|
+
lastSignificantToken = match[0];
|
384
|
+
yield ({
|
385
|
+
type: "JSXIdentifier",
|
386
|
+
value: match[0]
|
424
387
|
});
|
425
|
-
|
426
|
-
|
427
|
-
|
388
|
+
continue;
|
389
|
+
}
|
390
|
+
JSXString.lastIndex = lastIndex;
|
391
|
+
if (match = JSXString.exec(input)) {
|
392
|
+
lastIndex = JSXString.lastIndex;
|
393
|
+
lastSignificantToken = match[0];
|
428
394
|
yield ({
|
429
|
-
type: "
|
430
|
-
value:
|
395
|
+
type: "JSXString",
|
396
|
+
value: match[0],
|
397
|
+
closed: match[2] !== void 0
|
431
398
|
});
|
432
399
|
continue;
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
400
|
+
}
|
401
|
+
break;
|
402
|
+
case "JSXChildren":
|
403
|
+
JSXText.lastIndex = lastIndex;
|
404
|
+
if (match = JSXText.exec(input)) {
|
405
|
+
lastIndex = JSXText.lastIndex;
|
406
|
+
lastSignificantToken = match[0];
|
407
|
+
yield ({
|
408
|
+
type: "JSXText",
|
409
|
+
value: match[0]
|
410
|
+
});
|
411
|
+
continue;
|
412
|
+
}
|
413
|
+
switch (input[lastIndex]) {
|
414
|
+
case "<":
|
415
|
+
stack.push({tag: "JSXTag"});
|
416
|
+
lastIndex++;
|
417
|
+
lastSignificantToken = "<";
|
418
|
+
yield ({
|
419
|
+
type: "JSXPunctuator",
|
420
|
+
value: "<"
|
421
|
+
});
|
422
|
+
continue;
|
423
|
+
case "{":
|
424
|
+
stack.push({
|
425
|
+
tag: "InterpolationInJSX",
|
426
|
+
nesting: braces.length
|
427
|
+
});
|
428
|
+
lastIndex++;
|
429
|
+
lastSignificantToken = "?InterpolationInJSX";
|
430
|
+
postfixIncDec = false;
|
431
|
+
yield ({
|
432
|
+
type: "JSXPunctuator",
|
433
|
+
value: "{"
|
434
|
+
});
|
435
|
+
continue;
|
436
|
+
}
|
450
437
|
}
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
438
|
+
WhiteSpace.lastIndex = lastIndex;
|
439
|
+
if (match = WhiteSpace.exec(input)) {
|
440
|
+
lastIndex = WhiteSpace.lastIndex;
|
441
|
+
yield ({
|
442
|
+
type: "WhiteSpace",
|
443
|
+
value: match[0]
|
444
|
+
});
|
445
|
+
continue;
|
446
|
+
}
|
447
|
+
LineTerminatorSequence.lastIndex = lastIndex;
|
448
|
+
if (match = LineTerminatorSequence.exec(input)) {
|
449
|
+
lastIndex = LineTerminatorSequence.lastIndex;
|
461
450
|
postfixIncDec = false;
|
462
451
|
if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
|
463
452
|
lastSignificantToken = "?NoLineTerminatorHere";
|
464
453
|
}
|
454
|
+
yield ({
|
455
|
+
type: "LineTerminatorSequence",
|
456
|
+
value: match[0]
|
457
|
+
});
|
458
|
+
continue;
|
465
459
|
}
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
460
|
+
MultiLineComment.lastIndex = lastIndex;
|
461
|
+
if (match = MultiLineComment.exec(input)) {
|
462
|
+
lastIndex = MultiLineComment.lastIndex;
|
463
|
+
if (Newline.test(match[0])) {
|
464
|
+
postfixIncDec = false;
|
465
|
+
if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
|
466
|
+
lastSignificantToken = "?NoLineTerminatorHere";
|
467
|
+
}
|
468
|
+
}
|
469
|
+
yield ({
|
470
|
+
type: "MultiLineComment",
|
471
|
+
value: match[0],
|
472
|
+
closed: match[1] !== void 0
|
473
|
+
});
|
474
|
+
continue;
|
475
|
+
}
|
476
|
+
SingleLineComment.lastIndex = lastIndex;
|
477
|
+
if (match = SingleLineComment.exec(input)) {
|
478
|
+
lastIndex = SingleLineComment.lastIndex;
|
479
|
+
postfixIncDec = false;
|
480
|
+
yield ({
|
481
|
+
type: "SingleLineComment",
|
482
|
+
value: match[0]
|
483
|
+
});
|
484
|
+
continue;
|
485
|
+
}
|
486
|
+
firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex));
|
487
|
+
lastIndex += firstCodePoint.length;
|
488
|
+
lastSignificantToken = firstCodePoint;
|
476
489
|
postfixIncDec = false;
|
477
490
|
yield ({
|
478
|
-
type: "
|
479
|
-
value:
|
491
|
+
type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid",
|
492
|
+
value: firstCodePoint
|
480
493
|
});
|
481
|
-
continue;
|
482
494
|
}
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
yield ({
|
488
|
-
type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid",
|
489
|
-
value: firstCodePoint
|
490
|
-
});
|
491
|
-
}
|
492
|
-
return void 0;
|
493
|
-
};
|
495
|
+
return void 0;
|
496
|
+
};
|
497
|
+
return jsTokens_1;
|
498
|
+
}
|
494
499
|
|
495
|
-
var
|
500
|
+
var jsTokensExports = requireJsTokens();
|
501
|
+
var jsTokens = /*@__PURE__*/getDefaultExportFromCjs(jsTokensExports);
|
496
502
|
|
497
503
|
// src/index.ts
|
498
504
|
var reservedWords = {
|
@@ -628,4 +634,14 @@ function highlight(code, options = { jsx: false }) {
|
|
628
634
|
});
|
629
635
|
}
|
630
636
|
|
631
|
-
|
637
|
+
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
638
|
+
function nanoid(size = 21) {
|
639
|
+
let id = "";
|
640
|
+
let i = size;
|
641
|
+
while (i--) {
|
642
|
+
id += urlAlphabet[Math.random() * 64 | 0];
|
643
|
+
}
|
644
|
+
return id;
|
645
|
+
}
|
646
|
+
|
647
|
+
export { getSafeTimers, highlight, lineSplitRE, nanoid, offsetToLineNumber, positionToOffset, setSafeTimers, shuffle };
|