@salesforce-ux/eslint-plugin-slds 0.0.11 → 0.0.12-alpha.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/build/index.js CHANGED
@@ -1,4128 +1,19 @@
1
- 'use strict';
2
-
3
- var require$$0$1 = require('fs');
4
- var require$$1 = require('path');
5
-
6
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
-
8
- var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
9
- var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
10
-
11
- function getDefaultExportFromCjs (x) {
12
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
13
- }
14
-
15
- var lib$1 = {exports: {}};
16
-
17
- var parser$2 = {};
18
-
19
- var dist = {};
20
-
21
- var parser$1 = {};
22
-
23
- var parse = {};
24
-
25
- var treeConstructor = {};
26
-
27
- var constructTree = {};
28
-
29
- var constants = {};
30
-
31
- var astTypes = {};
32
-
33
- var hasRequiredAstTypes;
34
-
35
- function requireAstTypes () {
36
- if (hasRequiredAstTypes) return astTypes;
37
- hasRequiredAstTypes = 1;
38
- Object.defineProperty(astTypes, "__esModule", { value: true });
39
- astTypes.AstTypes = void 0;
40
- var AstTypes;
41
- (function (AstTypes) {
42
- AstTypes["Document"] = "Document";
43
- AstTypes["Tag"] = "Tag";
44
- AstTypes["Text"] = "Text";
45
- AstTypes["Doctype"] = "Doctype";
46
- AstTypes["Comment"] = "Comment";
47
- AstTypes["Script"] = "Script";
48
- AstTypes["Style"] = "Style";
49
- })(AstTypes || (astTypes.AstTypes = AstTypes = {}));
50
- return astTypes;
51
- }
52
-
53
- var tokenizerContextTypes = {};
54
-
55
- var hasRequiredTokenizerContextTypes;
56
-
57
- function requireTokenizerContextTypes () {
58
- if (hasRequiredTokenizerContextTypes) return tokenizerContextTypes;
59
- hasRequiredTokenizerContextTypes = 1;
60
- Object.defineProperty(tokenizerContextTypes, "__esModule", { value: true });
61
- tokenizerContextTypes.TokenizerContextTypes = void 0;
62
- var TokenizerContextTypes;
63
- (function (TokenizerContextTypes) {
64
- TokenizerContextTypes["Data"] = "Data";
65
- TokenizerContextTypes["OpenTagStart"] = "OpenTagStart";
66
- TokenizerContextTypes["CloseTag"] = "CloseTag";
67
- TokenizerContextTypes["Attributes"] = "Attributes";
68
- TokenizerContextTypes["OpenTagEnd"] = "OpenTagEnd";
69
- TokenizerContextTypes["AttributeKey"] = "AttributeKey";
70
- TokenizerContextTypes["AttributeValue"] = "AttributeValue";
71
- TokenizerContextTypes["AttributeValueBare"] = "AttributeValueBare";
72
- TokenizerContextTypes["AttributeValueWrapped"] = "AttributeValueWrapped";
73
- TokenizerContextTypes["ScriptContent"] = "ScriptContent";
74
- TokenizerContextTypes["StyleContent"] = "StyleContent";
75
- TokenizerContextTypes["DoctypeOpen"] = "DoctypeOpen";
76
- TokenizerContextTypes["DoctypeClose"] = "DoctypeClose";
77
- TokenizerContextTypes["DoctypeAttributes"] = "DoctypeAttributes";
78
- TokenizerContextTypes["DoctypeAttributeWrapped"] = "DoctypeAttributeWrapped";
79
- TokenizerContextTypes["DoctypeAttributeBare"] = "DoctypeAttributeBare";
80
- TokenizerContextTypes["CommentOpen"] = "CommentOpen";
81
- TokenizerContextTypes["CommentContent"] = "CommentContent";
82
- TokenizerContextTypes["CommentClose"] = "CommentClose";
83
- })(TokenizerContextTypes || (tokenizerContextTypes.TokenizerContextTypes = TokenizerContextTypes = {}));
84
- return tokenizerContextTypes;
85
- }
86
-
87
- var regex = {};
88
-
89
- var hasRequiredRegex;
90
-
91
- function requireRegex () {
92
- if (hasRequiredRegex) return regex;
93
- hasRequiredRegex = 1;
94
- Object.defineProperty(regex, "__esModule", { value: true });
95
- regex.CLOSE_TAG_NAME_PATTERN = regex.OPEN_TAG_NAME_PATTERN = regex.CLOSING_STYLE_TAG_PATTERN = regex.CLOSING_SCRIPT_TAG_PATTERN = regex.INCOMPLETE_CLOSING_TAG_PATTERN = void 0;
96
- regex.INCOMPLETE_CLOSING_TAG_PATTERN = /<\/[^>]+$/;
97
- regex.CLOSING_SCRIPT_TAG_PATTERN = /<\/script\s*>/i;
98
- regex.CLOSING_STYLE_TAG_PATTERN = /<\/style\s*>/i;
99
- regex.OPEN_TAG_NAME_PATTERN = /^<(\S+)/;
100
- regex.CLOSE_TAG_NAME_PATTERN = /^<\/((?:.|\n)*)>$/;
101
- return regex;
102
- }
103
-
104
- var tokenTypes = {};
105
-
106
- var hasRequiredTokenTypes;
107
-
108
- function requireTokenTypes () {
109
- if (hasRequiredTokenTypes) return tokenTypes;
110
- hasRequiredTokenTypes = 1;
111
- Object.defineProperty(tokenTypes, "__esModule", { value: true });
112
- tokenTypes.TokenTypes = void 0;
113
- var TokenTypes;
114
- (function (TokenTypes) {
115
- TokenTypes["Text"] = "Text";
116
- TokenTypes["OpenTagStart"] = "OpenTagStart";
117
- TokenTypes["OpenTagEnd"] = "OpenTagEnd";
118
- TokenTypes["CloseTag"] = "CloseTag";
119
- TokenTypes["AttributeKey"] = "AttributeKey";
120
- TokenTypes["AttributeAssignment"] = "AttributeAssignment";
121
- TokenTypes["AttributeValueWrapperStart"] = "AttributeValueWrapperStart";
122
- TokenTypes["AttributeValue"] = "AttributeValue";
123
- TokenTypes["AttributeValueWrapperEnd"] = "AttributeValueWrapperEnd";
124
- TokenTypes["DoctypeOpen"] = "DoctypeOpen";
125
- TokenTypes["DoctypeAttributeValue"] = "DoctypeAttributeValue";
126
- TokenTypes["DoctypeAttributeWrapperStart"] = "DoctypeAttributeWrapperStart";
127
- TokenTypes["DoctypeAttributeWrapperEnd"] = "DoctypeAttributeWrapperEnd";
128
- TokenTypes["DoctypeClose"] = "DoctypeClose";
129
- TokenTypes["CommentOpen"] = "CommentOpen";
130
- TokenTypes["CommentContent"] = "CommentContent";
131
- TokenTypes["CommentClose"] = "CommentClose";
132
- TokenTypes["OpenScriptTagStart"] = "OpenScriptTagStart";
133
- TokenTypes["OpenScriptTagEnd"] = "OpenScriptTagEnd";
134
- TokenTypes["ScriptTagContent"] = "ScriptTagContent";
135
- TokenTypes["CloseScriptTag"] = "CloseScriptTag";
136
- TokenTypes["OpenStyleTagStart"] = "OpenStyleTagStart";
137
- TokenTypes["OpenStyleTagEnd"] = "OpenStyleTagEnd";
138
- TokenTypes["StyleTagContent"] = "StyleTagContent";
139
- TokenTypes["CloseStyleTag"] = "CloseStyleTag";
140
- })(TokenTypes || (tokenTypes.TokenTypes = TokenTypes = {}));
141
- return tokenTypes;
142
- }
143
-
144
- var nodeTypes$1 = {};
145
-
146
- var hasRequiredNodeTypes$1;
147
-
148
- function requireNodeTypes$1 () {
149
- if (hasRequiredNodeTypes$1) return nodeTypes$1;
150
- hasRequiredNodeTypes$1 = 1;
151
- Object.defineProperty(nodeTypes$1, "__esModule", { value: true });
152
- nodeTypes$1.NodeTypes = void 0;
153
- var NodeTypes;
154
- (function (NodeTypes) {
155
- NodeTypes["Document"] = "Document";
156
- NodeTypes["Tag"] = "Tag";
157
- NodeTypes["Text"] = "Text";
158
- NodeTypes["Doctype"] = "Doctype";
159
- NodeTypes["Comment"] = "Comment";
160
- NodeTypes["CommentOpen"] = "CommentOpen";
161
- NodeTypes["CommentClose"] = "CommentClose";
162
- NodeTypes["CommentContent"] = "CommentContent";
163
- NodeTypes["Attribute"] = "Attribute";
164
- NodeTypes["AttributeKey"] = "AttributeKey";
165
- NodeTypes["AttributeValue"] = "AttributeValue";
166
- NodeTypes["AttributeValueWrapperStart"] = "AttributeValueWrapperStart";
167
- NodeTypes["AttributeValueWrapperEnd"] = "AttributeValueWrapperEnd";
168
- NodeTypes["CloseTag"] = "CloseTag";
169
- NodeTypes["OpenTagEnd"] = "OpenTagEnd";
170
- NodeTypes["OpenTagStart"] = "OpenTagStart";
171
- NodeTypes["DoctypeOpen"] = "DoctypeOpen";
172
- NodeTypes["DoctypeAttribute"] = "DoctypeAttribute";
173
- NodeTypes["DoctypeClose"] = "DoctypeClose";
174
- NodeTypes["ScriptTag"] = "ScriptTag";
175
- NodeTypes["OpenScriptTagStart"] = "OpenScriptTagStart";
176
- NodeTypes["OpenScriptTagEnd"] = "OpenScriptTagEnd";
177
- NodeTypes["ScriptTagContent"] = "ScriptTagContent";
178
- NodeTypes["StyleTag"] = "StyleTag";
179
- NodeTypes["OpenStyleTagStart"] = "OpenStyleTagStart";
180
- NodeTypes["OpenStyleTagEnd"] = "OpenStyleTagEnd";
181
- NodeTypes["StyleTagContent"] = "StyleTagContent";
182
- NodeTypes["CloseStyleTag"] = "CloseStyleTag";
183
- NodeTypes["CloseScriptTag"] = "CloseScriptTag";
184
- NodeTypes["DoctypeAttributeValue"] = "DoctypeAttributeValue";
185
- NodeTypes["DoctypeAttributeWrapperStart"] = "DoctypeAttributeWrapperStart";
186
- NodeTypes["DoctypeAttributeWrapperEnd"] = "DoctypeAttributeWrapperEnd";
187
- })(NodeTypes || (nodeTypes$1.NodeTypes = NodeTypes = {}));
188
- return nodeTypes$1;
189
- }
190
-
191
- var constructTreeContextTypes = {};
192
-
193
- var hasRequiredConstructTreeContextTypes;
194
-
195
- function requireConstructTreeContextTypes () {
196
- if (hasRequiredConstructTreeContextTypes) return constructTreeContextTypes;
197
- hasRequiredConstructTreeContextTypes = 1;
198
- Object.defineProperty(constructTreeContextTypes, "__esModule", { value: true });
199
- constructTreeContextTypes.ConstructTreeContextTypes = void 0;
200
- var ConstructTreeContextTypes;
201
- (function (ConstructTreeContextTypes) {
202
- ConstructTreeContextTypes["TagContent"] = "TagContent";
203
- ConstructTreeContextTypes["Tag"] = "Tag";
204
- ConstructTreeContextTypes["TagName"] = "TagName";
205
- ConstructTreeContextTypes["Attributes"] = "Attributes";
206
- ConstructTreeContextTypes["Attribute"] = "Attribute";
207
- ConstructTreeContextTypes["AttributeValue"] = "AttributeValue";
208
- ConstructTreeContextTypes["Comment"] = "Comment";
209
- ConstructTreeContextTypes["Doctype"] = "Doctype";
210
- ConstructTreeContextTypes["DoctypeAttributes"] = "DoctypeAttributes";
211
- ConstructTreeContextTypes["DoctypeAttribute"] = "DoctypeAttribute";
212
- ConstructTreeContextTypes["ScriptTag"] = "ScriptTag";
213
- ConstructTreeContextTypes["StyleTag"] = "StyleTag";
214
- })(ConstructTreeContextTypes || (constructTreeContextTypes.ConstructTreeContextTypes = ConstructTreeContextTypes = {}));
215
- return constructTreeContextTypes;
216
- }
217
-
218
- var hasRequiredConstants;
219
-
220
- function requireConstants () {
221
- if (hasRequiredConstants) return constants;
222
- hasRequiredConstants = 1;
223
- (function (exports) {
224
- var __createBinding = (constants && constants.__createBinding) || (Object.create ? (function(o, m, k, k2) {
225
- if (k2 === undefined) k2 = k;
226
- var desc = Object.getOwnPropertyDescriptor(m, k);
227
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
228
- desc = { enumerable: true, get: function() { return m[k]; } };
229
- }
230
- Object.defineProperty(o, k2, desc);
231
- }) : (function(o, m, k, k2) {
232
- if (k2 === undefined) k2 = k;
233
- o[k2] = m[k];
234
- }));
235
- var __exportStar = (constants && constants.__exportStar) || function(m, exports) {
236
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
237
- };
238
- Object.defineProperty(exports, "__esModule", { value: true });
239
- __exportStar(requireAstTypes(), exports);
240
- __exportStar(requireTokenizerContextTypes(), exports);
241
- __exportStar(requireRegex(), exports);
242
- __exportStar(requireTokenTypes(), exports);
243
- __exportStar(requireNodeTypes$1(), exports);
244
- __exportStar(requireConstructTreeContextTypes(), exports);
245
- } (constants));
246
- return constants;
247
- }
248
-
249
- var utils = {};
250
-
251
- var calculateTokenCharactersRange = {};
252
-
253
- var hasRequiredCalculateTokenCharactersRange;
254
-
255
- function requireCalculateTokenCharactersRange () {
256
- if (hasRequiredCalculateTokenCharactersRange) return calculateTokenCharactersRange;
257
- hasRequiredCalculateTokenCharactersRange = 1;
258
- Object.defineProperty(calculateTokenCharactersRange, "__esModule", { value: true });
259
- calculateTokenCharactersRange.calculateTokenCharactersRange = calculateTokenCharactersRange$1;
260
- function calculateTokenCharactersRange$1(state, { keepBuffer }) {
261
- const startPosition = state.sourceCode.index() -
262
- (state.accumulatedContent.length() - 1) -
263
- state.decisionBuffer.length();
264
- let endPosition;
265
- if (!keepBuffer) {
266
- endPosition = state.sourceCode.index() - state.decisionBuffer.length();
267
- }
268
- else {
269
- endPosition = state.sourceCode.index();
270
- }
271
- return [startPosition, endPosition + 1];
272
- }
273
- return calculateTokenCharactersRange;
274
- }
275
-
276
- var isWhitespace = {};
277
-
278
- var hasRequiredIsWhitespace;
279
-
280
- function requireIsWhitespace () {
281
- if (hasRequiredIsWhitespace) return isWhitespace;
282
- hasRequiredIsWhitespace = 1;
283
- Object.defineProperty(isWhitespace, "__esModule", { value: true });
284
- isWhitespace.isWhitespace = isWhitespace$1;
285
- function isWhitespace$1(char) {
286
- return char === " " || char === "\n" || char === "\t" || char === "\r";
287
- }
288
- return isWhitespace;
289
- }
290
-
291
- var parseOpenTagName = {};
292
-
293
- var hasRequiredParseOpenTagName;
294
-
295
- function requireParseOpenTagName () {
296
- if (hasRequiredParseOpenTagName) return parseOpenTagName;
297
- hasRequiredParseOpenTagName = 1;
298
- Object.defineProperty(parseOpenTagName, "__esModule", { value: true });
299
- parseOpenTagName.parseOpenTagName = parseOpenTagName$1;
300
- const constants_1 = requireConstants();
301
- function parseOpenTagName$1(openTagStartTokenContent) {
302
- const match = openTagStartTokenContent.match(constants_1.OPEN_TAG_NAME_PATTERN);
303
- if (match === null) {
304
- throw new Error("Unable to parse open tag name.\n" +
305
- `${openTagStartTokenContent} does not match pattern of opening tag.`);
306
- }
307
- return match[1].toLowerCase();
308
- }
309
- return parseOpenTagName;
310
- }
311
-
312
- var parseCloseTagName = {};
313
-
314
- var hasRequiredParseCloseTagName;
315
-
316
- function requireParseCloseTagName () {
317
- if (hasRequiredParseCloseTagName) return parseCloseTagName;
318
- hasRequiredParseCloseTagName = 1;
319
- Object.defineProperty(parseCloseTagName, "__esModule", { value: true });
320
- parseCloseTagName.parseCloseTagName = parseCloseTagName$1;
321
- const constants_1 = requireConstants();
322
- function parseCloseTagName$1(closeTagTokenContent) {
323
- const match = closeTagTokenContent.match(constants_1.CLOSE_TAG_NAME_PATTERN);
324
- if (match === null) {
325
- throw new Error("Unable to parse close tag name.\n" +
326
- `${closeTagTokenContent} does not match pattern of closing tag.`);
327
- }
328
- return match[1].trim().toLowerCase();
329
- }
330
- return parseCloseTagName;
331
- }
332
-
333
- var clearParent = {};
334
-
335
- var hasRequiredClearParent;
336
-
337
- function requireClearParent () {
338
- if (hasRequiredClearParent) return clearParent;
339
- hasRequiredClearParent = 1;
340
- Object.defineProperty(clearParent, "__esModule", { value: true });
341
- clearParent.clearParent = clearParent$1;
342
- function clearParent$1(ast) {
343
- const cleanAst = ast;
344
- delete cleanAst.parentRef;
345
- if (Array.isArray(ast.children)) {
346
- // @ts-ignore
347
- cleanAst.children = ast.children.map((node) => {
348
- return clearParent$1(node);
349
- });
350
- }
351
- return cleanAst;
352
- }
353
- return clearParent;
354
- }
355
-
356
- var calculateTokenLocation = {};
357
-
358
- var getLineInfo = {};
359
-
360
- var hasRequiredGetLineInfo;
361
-
362
- function requireGetLineInfo () {
363
- if (hasRequiredGetLineInfo) return getLineInfo;
364
- hasRequiredGetLineInfo = 1;
365
- //https://github.com/acornjs/acorn/blob/master/acorn/src/whitespace.js
366
- Object.defineProperty(getLineInfo, "__esModule", { value: true });
367
- getLineInfo.getLineInfo = getLineInfo$1;
368
- function isNewLine(code) {
369
- return code === 10 || code === 13 || code === 0x2028 || code === 0x2029;
370
- }
371
- function nextLineBreak(code, from, end = code.length) {
372
- for (let i = from; i < end; i++) {
373
- const next = code.charCodeAt(i);
374
- if (isNewLine(next))
375
- return i < end - 1 && next === 13 && code.charCodeAt(i + 1) === 10
376
- ? i + 2
377
- : i + 1;
378
- }
379
- return -1;
380
- }
381
- function getLineInfo$1(input, offset) {
382
- for (let line = 1, cur = 0;;) {
383
- const nextBreak = nextLineBreak(input, cur, offset);
384
- if (nextBreak < 0)
385
- return { line, column: offset - cur };
386
- ++line;
387
- cur = nextBreak;
388
- }
389
- }
390
- return getLineInfo;
391
- }
392
-
393
- var hasRequiredCalculateTokenLocation;
394
-
395
- function requireCalculateTokenLocation () {
396
- if (hasRequiredCalculateTokenLocation) return calculateTokenLocation;
397
- hasRequiredCalculateTokenLocation = 1;
398
- Object.defineProperty(calculateTokenLocation, "__esModule", { value: true });
399
- calculateTokenLocation.calculateTokenLocation = calculateTokenLocation$1;
400
- const get_line_info_1 = requireGetLineInfo();
401
- function calculateTokenLocation$1(source, range) {
402
- return {
403
- start: (0, get_line_info_1.getLineInfo)(source, range[0]),
404
- end: (0, get_line_info_1.getLineInfo)(source, range[1]),
405
- };
406
- }
407
- return calculateTokenLocation;
408
- }
409
-
410
- var calculateTokenPosition = {};
411
-
412
- var hasRequiredCalculateTokenPosition;
413
-
414
- function requireCalculateTokenPosition () {
415
- if (hasRequiredCalculateTokenPosition) return calculateTokenPosition;
416
- hasRequiredCalculateTokenPosition = 1;
417
- Object.defineProperty(calculateTokenPosition, "__esModule", { value: true });
418
- calculateTokenPosition.calculateTokenPosition = calculateTokenPosition$1;
419
- const calculate_token_characters_range_1 = requireCalculateTokenCharactersRange();
420
- const calculate_token_location_1 = requireCalculateTokenLocation();
421
- function calculateTokenPosition$1(state, options) {
422
- const range = (0, calculate_token_characters_range_1.calculateTokenCharactersRange)(state, options);
423
- const loc = (0, calculate_token_location_1.calculateTokenLocation)(state.sourceCode.source, range);
424
- return {
425
- range,
426
- loc,
427
- };
428
- }
429
- return calculateTokenPosition;
430
- }
431
-
432
- var last = {};
433
-
434
- var hasRequiredLast;
435
-
436
- function requireLast () {
437
- if (hasRequiredLast) return last;
438
- hasRequiredLast = 1;
439
- Object.defineProperty(last, "__esModule", { value: true });
440
- last.last = last$1;
441
- function last$1(items) {
442
- return items[items.length - 1];
443
- }
444
- return last;
445
- }
446
-
447
- var cloneRange = {};
448
-
449
- var hasRequiredCloneRange;
450
-
451
- function requireCloneRange () {
452
- if (hasRequiredCloneRange) return cloneRange;
453
- hasRequiredCloneRange = 1;
454
- Object.defineProperty(cloneRange, "__esModule", { value: true });
455
- cloneRange.cloneRange = cloneRange$1;
456
- function cloneRange$1(range) {
457
- return [range[0], range[1]];
458
- }
459
- return cloneRange;
460
- }
461
-
462
- var createNodeFrom = {};
463
-
464
- var cloneLocation = {};
465
-
466
- var hasRequiredCloneLocation;
467
-
468
- function requireCloneLocation () {
469
- if (hasRequiredCloneLocation) return cloneLocation;
470
- hasRequiredCloneLocation = 1;
471
- Object.defineProperty(cloneLocation, "__esModule", { value: true });
472
- cloneLocation.cloneLocation = cloneLocation$1;
473
- function cloneLocation$1(loc) {
474
- return {
475
- start: {
476
- line: loc.start.line,
477
- column: loc.start.column,
478
- },
479
- end: {
480
- line: loc.end.line,
481
- column: loc.end.column,
482
- },
483
- };
484
- }
485
- return cloneLocation;
486
- }
487
-
488
- var hasRequiredCreateNodeFrom;
489
-
490
- function requireCreateNodeFrom () {
491
- if (hasRequiredCreateNodeFrom) return createNodeFrom;
492
- hasRequiredCreateNodeFrom = 1;
493
- Object.defineProperty(createNodeFrom, "__esModule", { value: true });
494
- createNodeFrom.createNodeFrom = createNodeFrom$1;
495
- const clone_location_1 = requireCloneLocation();
496
- const clone_range_1 = requireCloneRange();
497
- function createNodeFrom$1(token) {
498
- const loc = (0, clone_location_1.cloneLocation)(token.loc);
499
- const range = (0, clone_range_1.cloneRange)(token.range);
500
- const ret = {
501
- type: token.type,
502
- value: token.value,
503
- loc,
504
- range,
505
- };
506
- // @ts-ignore
507
- if (token.templates) {
508
- // @ts-ignore
509
- ret.templates = token.templates;
510
- }
511
- // @ts-ignore
512
- if (token.isTemplate) {
513
- // @ts-ignore
514
- ret.isTemplate = token.isTemplate;
515
- }
516
- return ret;
517
- }
518
- return createNodeFrom;
519
- }
520
-
521
- var updateNodeEnd = {};
522
-
523
- var hasRequiredUpdateNodeEnd;
524
-
525
- function requireUpdateNodeEnd () {
526
- if (hasRequiredUpdateNodeEnd) return updateNodeEnd;
527
- hasRequiredUpdateNodeEnd = 1;
528
- Object.defineProperty(updateNodeEnd, "__esModule", { value: true });
529
- updateNodeEnd.updateNodeEnd = updateNodeEnd$1;
530
- function updateNodeEnd$1(node, token) {
531
- node.range[1] = token.range[1];
532
- node.loc.end = Object.assign({}, token.loc.end);
533
- }
534
- return updateNodeEnd;
535
- }
536
-
537
- var first = {};
538
-
539
- var hasRequiredFirst;
540
-
541
- function requireFirst () {
542
- if (hasRequiredFirst) return first;
543
- hasRequiredFirst = 1;
544
- Object.defineProperty(first, "__esModule", { value: true });
545
- first.first = first$1;
546
- function first$1(items) {
547
- return items[0];
548
- }
549
- return first;
550
- }
551
-
552
- var initIfNone = {};
553
-
554
- var hasRequiredInitIfNone;
555
-
556
- function requireInitIfNone () {
557
- if (hasRequiredInitIfNone) return initIfNone;
558
- hasRequiredInitIfNone = 1;
559
- Object.defineProperty(initIfNone, "__esModule", { value: true });
560
- initIfNone.initChildrenIfNone = initChildrenIfNone;
561
- initIfNone.initAttributesIfNone = initAttributesIfNone;
562
- function initChildrenIfNone(node) {
563
- /* istanbul ignore next */
564
- if (!node.children) {
565
- node.children = [];
566
- }
567
- }
568
- function initAttributesIfNone(node) {
569
- /* istanbul ignore next */
570
- if (!node.attributes) {
571
- node.attributes = [];
572
- }
573
- }
574
- return initIfNone;
575
- }
576
-
577
- var hasRequiredUtils;
578
-
579
- function requireUtils () {
580
- if (hasRequiredUtils) return utils;
581
- hasRequiredUtils = 1;
582
- (function (exports) {
583
- var __createBinding = (utils && utils.__createBinding) || (Object.create ? (function(o, m, k, k2) {
584
- if (k2 === undefined) k2 = k;
585
- var desc = Object.getOwnPropertyDescriptor(m, k);
586
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
587
- desc = { enumerable: true, get: function() { return m[k]; } };
588
- }
589
- Object.defineProperty(o, k2, desc);
590
- }) : (function(o, m, k, k2) {
591
- if (k2 === undefined) k2 = k;
592
- o[k2] = m[k];
593
- }));
594
- var __exportStar = (utils && utils.__exportStar) || function(m, exports) {
595
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
596
- };
597
- Object.defineProperty(exports, "__esModule", { value: true });
598
- __exportStar(requireCalculateTokenCharactersRange(), exports);
599
- __exportStar(requireIsWhitespace(), exports);
600
- __exportStar(requireParseOpenTagName(), exports);
601
- __exportStar(requireParseCloseTagName(), exports);
602
- __exportStar(requireClearParent(), exports);
603
- __exportStar(requireCalculateTokenLocation(), exports);
604
- __exportStar(requireCalculateTokenPosition(), exports);
605
- __exportStar(requireLast(), exports);
606
- __exportStar(requireCloneRange(), exports);
607
- __exportStar(requireCreateNodeFrom(), exports);
608
- __exportStar(requireUpdateNodeEnd(), exports);
609
- __exportStar(requireGetLineInfo(), exports);
610
- __exportStar(requireFirst(), exports);
611
- __exportStar(requireCloneLocation(), exports);
612
- __exportStar(requireInitIfNone(), exports);
613
- } (utils));
614
- return utils;
615
- }
616
-
617
- var handlers$1 = {};
618
-
619
- var attributeValue$1 = {};
620
-
621
- var hasRequiredAttributeValue$1;
622
-
623
- function requireAttributeValue$1 () {
624
- if (hasRequiredAttributeValue$1) return attributeValue$1;
625
- hasRequiredAttributeValue$1 = 1;
626
- Object.defineProperty(attributeValue$1, "__esModule", { value: true });
627
- attributeValue$1.construct = construct;
628
- const constants_1 = requireConstants();
629
- const utils_1 = requireUtils();
630
- const VALUE_END_TOKENS = [
631
- constants_1.TokenTypes.OpenTagEnd,
632
- constants_1.TokenTypes.AttributeKey,
633
- constants_1.TokenTypes.AttributeAssignment,
634
- constants_1.TokenTypes.OpenScriptTagEnd,
635
- constants_1.TokenTypes.OpenStyleTagEnd,
636
- ];
637
- function getLastAttribute(state) {
638
- const attributes = state.currentNode.attributes;
639
- return attributes[attributes.length - 1];
640
- }
641
- function handleValueEnd(state) {
642
- state.currentContext = state.currentContext.parentRef;
643
- return state;
644
- }
645
- function handleAttributeValue(state, token) {
646
- const attribute = getLastAttribute(state);
647
- attribute.value = (0, utils_1.createNodeFrom)(token);
648
- (0, utils_1.updateNodeEnd)(attribute, token);
649
- state.caretPosition++;
650
- return state;
651
- }
652
- function handleAttributeValueWrapperStart(state, token) {
653
- const attribute = getLastAttribute(state);
654
- attribute.startWrapper = (0, utils_1.createNodeFrom)(token);
655
- if (!attribute.key) {
656
- attribute.range = (0, utils_1.cloneRange)(token.range);
657
- attribute.loc = (0, utils_1.cloneLocation)(token.loc);
658
- }
659
- state.caretPosition++;
660
- return state;
661
- }
662
- function handleAttributeValueWrapperEnd(state, token) {
663
- const attribute = getLastAttribute(state);
664
- attribute.endWrapper = (0, utils_1.createNodeFrom)(token);
665
- (0, utils_1.updateNodeEnd)(attribute, token);
666
- state.caretPosition++;
667
- return state;
668
- }
669
- function construct(token, state) {
670
- if (VALUE_END_TOKENS.indexOf(token.type) !== -1) {
671
- return handleValueEnd(state);
672
- }
673
- if (token.type === constants_1.TokenTypes.AttributeValue) {
674
- return handleAttributeValue(state, token);
675
- }
676
- if (token.type === constants_1.TokenTypes.AttributeValueWrapperStart) {
677
- return handleAttributeValueWrapperStart(state, token);
678
- }
679
- if (token.type === constants_1.TokenTypes.AttributeValueWrapperEnd) {
680
- return handleAttributeValueWrapperEnd(state, token);
681
- }
682
- state.caretPosition++;
683
- return state;
684
- }
685
- return attributeValue$1;
686
- }
687
-
688
- var attributes$1 = {};
689
-
690
- var hasRequiredAttributes$1;
691
-
692
- function requireAttributes$1 () {
693
- if (hasRequiredAttributes$1) return attributes$1;
694
- hasRequiredAttributes$1 = 1;
695
- Object.defineProperty(attributes$1, "__esModule", { value: true });
696
- attributes$1.construct = construct;
697
- const constants_1 = requireConstants();
698
- const utils_1 = requireUtils();
699
- const ATTRIBUTE_START_TOKENS = [
700
- constants_1.TokenTypes.AttributeKey,
701
- constants_1.TokenTypes.AttributeAssignment,
702
- ];
703
- const ATTRIBUTES_END_TOKENS = [
704
- constants_1.TokenTypes.OpenTagEnd,
705
- constants_1.TokenTypes.OpenStyleTagEnd,
706
- constants_1.TokenTypes.OpenScriptTagEnd,
707
- ];
708
- function handlerAttributeStart(state, token) {
709
- (0, utils_1.initAttributesIfNone)(state.currentNode);
710
- // new empty attribute
711
- state.currentNode.attributes.push({
712
- type: constants_1.NodeTypes.Attribute,
713
- range: (0, utils_1.cloneRange)(token.range),
714
- loc: (0, utils_1.cloneLocation)(token.loc),
715
- });
716
- state.currentContext = {
717
- parentRef: state.currentContext,
718
- type: constants_1.ConstructTreeContextTypes.Attribute,
719
- };
720
- return state;
721
- }
722
- function handleOpenTagEnd(state) {
723
- state.currentContext = state.currentContext.parentRef;
724
- return state;
725
- }
726
- function construct(token, state) {
727
- if (ATTRIBUTE_START_TOKENS.indexOf(token.type) !== -1) {
728
- return handlerAttributeStart(state, token);
729
- }
730
- if (ATTRIBUTES_END_TOKENS.indexOf(token.type) !== -1) {
731
- return handleOpenTagEnd(state);
732
- }
733
- state.caretPosition++;
734
- return state;
735
- }
736
- return attributes$1;
737
- }
738
-
739
- var attribute = {};
740
-
741
- var hasRequiredAttribute;
742
-
743
- function requireAttribute () {
744
- if (hasRequiredAttribute) return attribute;
745
- hasRequiredAttribute = 1;
746
- Object.defineProperty(attribute, "__esModule", { value: true });
747
- attribute.construct = construct;
748
- const constants_1 = requireConstants();
749
- const utils_1 = requireUtils();
750
- const OPEN_TAG_END_TOKENS = [
751
- constants_1.TokenTypes.OpenTagEnd,
752
- constants_1.TokenTypes.OpenScriptTagEnd,
753
- constants_1.TokenTypes.OpenStyleTagEnd,
754
- ];
755
- function getLastAttribute(state) {
756
- const attributes = state.currentNode.attributes;
757
- return attributes[attributes.length - 1];
758
- }
759
- function handleOpenTagEnd(state) {
760
- state.currentContext = state.currentContext.parentRef;
761
- return state;
762
- }
763
- function handleAttributeKey(state, token) {
764
- const attribute = getLastAttribute(state);
765
- if (attribute.key !== undefined || attribute.value !== undefined) {
766
- state.currentContext = state.currentContext.parentRef;
767
- return state;
768
- }
769
- attribute.key = (0, utils_1.createNodeFrom)(token);
770
- state.caretPosition++;
771
- return state;
772
- }
773
- function handleAttributeAssignment(state) {
774
- const attribute = getLastAttribute(state);
775
- if (attribute.value !== undefined) {
776
- state.currentContext = state.currentContext.parentRef;
777
- return state;
778
- }
779
- state.currentContext = {
780
- parentRef: state.currentContext,
781
- type: constants_1.ConstructTreeContextTypes.AttributeValue,
782
- };
783
- state.caretPosition++;
784
- return state;
785
- }
786
- function construct(token, state) {
787
- if (OPEN_TAG_END_TOKENS.indexOf(token.type) !== -1) {
788
- return handleOpenTagEnd(state);
789
- }
790
- if (token.type === constants_1.TokenTypes.AttributeKey) {
791
- return handleAttributeKey(state, token);
792
- }
793
- if (token.type === constants_1.TokenTypes.AttributeAssignment) {
794
- return handleAttributeAssignment(state);
795
- }
796
- state.caretPosition++;
797
- return state;
798
- }
799
- return attribute;
800
- }
801
-
802
- var comment = {};
803
-
804
- var hasRequiredComment;
805
-
806
- function requireComment () {
807
- if (hasRequiredComment) return comment;
808
- hasRequiredComment = 1;
809
- Object.defineProperty(comment, "__esModule", { value: true });
810
- comment.construct = construct;
811
- const constants_1 = requireConstants();
812
- const utils_1 = requireUtils();
813
- function handleCommentOpen(state, token) {
814
- state.currentNode.open = (0, utils_1.createNodeFrom)(token);
815
- state.caretPosition++;
816
- return state;
817
- }
818
- function handleCommentContent(state, token) {
819
- state.currentNode.value = (0, utils_1.createNodeFrom)(token);
820
- state.caretPosition++;
821
- return state;
822
- }
823
- function handleCommentClose(state, token) {
824
- state.currentNode.close = (0, utils_1.createNodeFrom)(token);
825
- (0, utils_1.updateNodeEnd)(state.currentNode, token);
826
- state.currentNode = state.currentNode.parentRef;
827
- state.currentContext = state.currentContext.parentRef;
828
- state.caretPosition++;
829
- return state;
830
- }
831
- function construct(token, state) {
832
- if (token.type === constants_1.TokenTypes.CommentOpen) {
833
- return handleCommentOpen(state, token);
834
- }
835
- if (token.type === constants_1.TokenTypes.CommentContent) {
836
- return handleCommentContent(state, token);
837
- }
838
- if (token.type === constants_1.TokenTypes.CommentClose) {
839
- return handleCommentClose(state, token);
840
- }
841
- state.caretPosition++;
842
- return state;
843
- }
844
- return comment;
845
- }
846
-
847
- var doctypeAttribute = {};
848
-
849
- var hasRequiredDoctypeAttribute;
850
-
851
- function requireDoctypeAttribute () {
852
- if (hasRequiredDoctypeAttribute) return doctypeAttribute;
853
- hasRequiredDoctypeAttribute = 1;
854
- Object.defineProperty(doctypeAttribute, "__esModule", { value: true });
855
- doctypeAttribute.construct = construct;
856
- const constants_1 = requireConstants();
857
- const utils_1 = requireUtils();
858
- function getLastAttribute(state) {
859
- const attributes = state.currentNode.attributes;
860
- return attributes[attributes.length - 1];
861
- }
862
- function handleDoctypeClose(state) {
863
- state.currentContext = state.currentContext.parentRef;
864
- return state;
865
- }
866
- function handleAttributeValue(state, token) {
867
- const attribute = getLastAttribute(state);
868
- if (attribute.value !== undefined) {
869
- state.currentContext = state.currentContext.parentRef;
870
- return state;
871
- }
872
- attribute.value = (0, utils_1.createNodeFrom)(token);
873
- if (!attribute.startWrapper) {
874
- attribute.range = (0, utils_1.cloneRange)(token.range);
875
- }
876
- state.caretPosition++;
877
- return state;
878
- }
879
- function handleAttributeWrapperStart(state, token) {
880
- const attribute = getLastAttribute(state);
881
- if (attribute.value !== undefined) {
882
- state.currentContext = state.currentContext.parentRef;
883
- return state;
884
- }
885
- attribute.startWrapper = (0, utils_1.createNodeFrom)(token);
886
- attribute.range = (0, utils_1.cloneRange)(token.range);
887
- state.caretPosition++;
888
- return state;
889
- }
890
- function handleAttributeWrapperEnd(state, token) {
891
- const attribute = getLastAttribute(state);
892
- attribute.endWrapper = (0, utils_1.createNodeFrom)(token);
893
- (0, utils_1.updateNodeEnd)(attribute, token);
894
- state.currentContext = state.currentContext.parentRef;
895
- state.caretPosition++;
896
- return state;
897
- }
898
- function construct(token, state) {
899
- if (token.type === constants_1.TokenTypes.DoctypeClose) {
900
- return handleDoctypeClose(state);
901
- }
902
- if (token.type === constants_1.TokenTypes.DoctypeAttributeWrapperStart) {
903
- return handleAttributeWrapperStart(state, token);
904
- }
905
- if (token.type === constants_1.TokenTypes.DoctypeAttributeWrapperEnd) {
906
- return handleAttributeWrapperEnd(state, token);
907
- }
908
- if (token.type === constants_1.TokenTypes.DoctypeAttributeValue) {
909
- return handleAttributeValue(state, token);
910
- }
911
- state.caretPosition++;
912
- return state;
913
- }
914
- return doctypeAttribute;
915
- }
916
-
917
- var doctypeAttributes$1 = {};
918
-
919
- var hasRequiredDoctypeAttributes$1;
920
-
921
- function requireDoctypeAttributes$1 () {
922
- if (hasRequiredDoctypeAttributes$1) return doctypeAttributes$1;
923
- hasRequiredDoctypeAttributes$1 = 1;
924
- Object.defineProperty(doctypeAttributes$1, "__esModule", { value: true });
925
- doctypeAttributes$1.construct = construct;
926
- const constants_1 = requireConstants();
927
- const utils_1 = requireUtils();
928
- const ATTRIBUTE_START_TOKENS = [
929
- constants_1.TokenTypes.DoctypeAttributeWrapperStart,
930
- constants_1.TokenTypes.DoctypeAttributeValue,
931
- ];
932
- function handleDoctypeClose(state) {
933
- state.currentContext = state.currentContext.parentRef;
934
- return state;
935
- }
936
- function handleAttribute(state, token) {
937
- (0, utils_1.initAttributesIfNone)(state.currentNode);
938
- // new empty attribute
939
- state.currentNode.attributes.push({
940
- type: constants_1.NodeTypes.DoctypeAttribute,
941
- range: (0, utils_1.cloneRange)(token.range),
942
- loc: (0, utils_1.cloneLocation)(token.loc),
943
- });
944
- state.currentContext = {
945
- type: constants_1.ConstructTreeContextTypes.DoctypeAttribute,
946
- parentRef: state.currentContext,
947
- };
948
- return state;
949
- }
950
- function construct(token, state) {
951
- if (token.type === constants_1.TokenTypes.DoctypeClose) {
952
- return handleDoctypeClose(state);
953
- }
954
- if (ATTRIBUTE_START_TOKENS.indexOf(token.type) !== -1) {
955
- return handleAttribute(state, token);
956
- }
957
- state.caretPosition++;
958
- return state;
959
- }
960
- return doctypeAttributes$1;
961
- }
962
-
963
- var doctype = {};
964
-
965
- var hasRequiredDoctype;
966
-
967
- function requireDoctype () {
968
- if (hasRequiredDoctype) return doctype;
969
- hasRequiredDoctype = 1;
970
- Object.defineProperty(doctype, "__esModule", { value: true });
971
- doctype.construct = construct;
972
- const constants_1 = requireConstants();
973
- const utils_1 = requireUtils();
974
- const ATTRIBUTES_START_TOKENS = [
975
- constants_1.TokenTypes.DoctypeAttributeWrapperStart,
976
- constants_1.TokenTypes.DoctypeAttributeValue,
977
- ];
978
- function handleDoctypeOpen(state, token) {
979
- state.currentNode.open = (0, utils_1.createNodeFrom)(token);
980
- state.caretPosition++;
981
- return state;
982
- }
983
- function handleDoctypeClose(state, token) {
984
- state.currentNode.close = (0, utils_1.createNodeFrom)(token);
985
- (0, utils_1.updateNodeEnd)(state.currentNode, token);
986
- state.currentNode = state.currentNode.parentRef;
987
- state.currentContext = state.currentContext.parentRef;
988
- state.caretPosition++;
989
- return state;
990
- }
991
- function handleDoctypeAttributes(state) {
992
- state.currentContext = {
993
- parentRef: state.currentContext,
994
- type: constants_1.ConstructTreeContextTypes.DoctypeAttributes,
995
- };
996
- return state;
997
- }
998
- function construct(token, state) {
999
- if (token.type === constants_1.TokenTypes.DoctypeOpen) {
1000
- return handleDoctypeOpen(state, token);
1001
- }
1002
- if (token.type === constants_1.TokenTypes.DoctypeClose) {
1003
- return handleDoctypeClose(state, token);
1004
- }
1005
- if (ATTRIBUTES_START_TOKENS.indexOf(token.type) !== -1) {
1006
- return handleDoctypeAttributes(state);
1007
- }
1008
- state.caretPosition++;
1009
- return state;
1010
- }
1011
- return doctype;
1012
- }
1013
-
1014
- var scriptTag = {};
1015
-
1016
- var hasRequiredScriptTag;
1017
-
1018
- function requireScriptTag () {
1019
- if (hasRequiredScriptTag) return scriptTag;
1020
- hasRequiredScriptTag = 1;
1021
- Object.defineProperty(scriptTag, "__esModule", { value: true });
1022
- scriptTag.construct = construct;
1023
- const constants_1 = requireConstants();
1024
- const utils_1 = requireUtils();
1025
- const ATTRIBUTE_START_TOKENS = [
1026
- constants_1.TokenTypes.AttributeKey,
1027
- constants_1.TokenTypes.AttributeAssignment,
1028
- ];
1029
- function handleOpenScriptTagStart(state, token) {
1030
- state.currentNode.openStart = (0, utils_1.createNodeFrom)(token);
1031
- (0, utils_1.updateNodeEnd)(state.currentNode, token);
1032
- state.caretPosition++;
1033
- return state;
1034
- }
1035
- function handleAttributeStartScript(state) {
1036
- state.currentContext = {
1037
- parentRef: state.currentContext,
1038
- type: constants_1.ConstructTreeContextTypes.Attributes,
1039
- };
1040
- return state;
1041
- }
1042
- function handleOpenScriptTagEnd(state, token) {
1043
- state.currentNode.openEnd = (0, utils_1.createNodeFrom)(token);
1044
- (0, utils_1.updateNodeEnd)(state.currentNode, token);
1045
- state.caretPosition++;
1046
- return state;
1047
- }
1048
- function handleScriptContent(state, token) {
1049
- state.currentNode.value = (0, utils_1.createNodeFrom)(token);
1050
- (0, utils_1.updateNodeEnd)(state.currentNode, token);
1051
- state.caretPosition++;
1052
- return state;
1053
- }
1054
- function handleCloseScriptTag(state, token) {
1055
- state.currentNode.close = (0, utils_1.createNodeFrom)(token);
1056
- (0, utils_1.updateNodeEnd)(state.currentNode, token);
1057
- state.currentNode = state.currentNode.parentRef;
1058
- state.currentContext = state.currentContext.parentRef;
1059
- state.caretPosition++;
1060
- return state;
1061
- }
1062
- function construct(token, state) {
1063
- if (token.type === constants_1.TokenTypes.OpenScriptTagStart) {
1064
- return handleOpenScriptTagStart(state, token);
1065
- }
1066
- if (ATTRIBUTE_START_TOKENS.indexOf(token.type) !== -1) {
1067
- return handleAttributeStartScript(state);
1068
- }
1069
- if (token.type === constants_1.TokenTypes.OpenScriptTagEnd) {
1070
- return handleOpenScriptTagEnd(state, token);
1071
- }
1072
- if (token.type === constants_1.TokenTypes.ScriptTagContent) {
1073
- return handleScriptContent(state, token);
1074
- }
1075
- if (token.type === constants_1.TokenTypes.CloseScriptTag) {
1076
- return handleCloseScriptTag(state, token);
1077
- }
1078
- state.caretPosition++;
1079
- return state;
1080
- }
1081
- return scriptTag;
1082
- }
1083
-
1084
- var styleTag = {};
1085
-
1086
- var hasRequiredStyleTag;
1087
-
1088
- function requireStyleTag () {
1089
- if (hasRequiredStyleTag) return styleTag;
1090
- hasRequiredStyleTag = 1;
1091
- Object.defineProperty(styleTag, "__esModule", { value: true });
1092
- styleTag.construct = construct;
1093
- const constants_1 = requireConstants();
1094
- const utils_1 = requireUtils();
1095
- const ATTRIBUTE_START_TOKENS = [
1096
- constants_1.TokenTypes.AttributeKey,
1097
- constants_1.TokenTypes.AttributeAssignment,
1098
- ];
1099
- function handleOpenStyleTagStart(state, token) {
1100
- state.currentNode.openStart = (0, utils_1.createNodeFrom)(token);
1101
- (0, utils_1.updateNodeEnd)(state.currentNode, token);
1102
- state.caretPosition++;
1103
- return state;
1104
- }
1105
- function handleAttributeStartStyle(state) {
1106
- state.currentContext = {
1107
- parentRef: state.currentContext,
1108
- type: constants_1.ConstructTreeContextTypes.Attributes,
1109
- };
1110
- return state;
1111
- }
1112
- function handleOpenStyleTagEnd(state, token) {
1113
- state.currentNode.openEnd = (0, utils_1.createNodeFrom)(token);
1114
- (0, utils_1.updateNodeEnd)(state.currentNode, token);
1115
- state.caretPosition++;
1116
- return state;
1117
- }
1118
- function handleStyleContent(state, token) {
1119
- state.currentNode.value = (0, utils_1.createNodeFrom)(token);
1120
- (0, utils_1.updateNodeEnd)(state.currentNode, token);
1121
- state.caretPosition++;
1122
- return state;
1123
- }
1124
- function handleCloseStyleTag(state, token) {
1125
- state.currentNode.close = (0, utils_1.createNodeFrom)(token);
1126
- (0, utils_1.updateNodeEnd)(state.currentNode, token);
1127
- state.currentNode = state.currentNode.parentRef;
1128
- state.currentContext = state.currentContext.parentRef;
1129
- state.caretPosition++;
1130
- return state;
1131
- }
1132
- function construct(token, state) {
1133
- if (token.type === constants_1.TokenTypes.OpenStyleTagStart) {
1134
- return handleOpenStyleTagStart(state, token);
1135
- }
1136
- if (ATTRIBUTE_START_TOKENS.indexOf(token.type) !== -1) {
1137
- return handleAttributeStartStyle(state);
1138
- }
1139
- if (token.type === constants_1.TokenTypes.OpenStyleTagEnd) {
1140
- return handleOpenStyleTagEnd(state, token);
1141
- }
1142
- if (token.type === constants_1.TokenTypes.StyleTagContent) {
1143
- return handleStyleContent(state, token);
1144
- }
1145
- if (token.type === constants_1.TokenTypes.CloseStyleTag) {
1146
- return handleCloseStyleTag(state, token);
1147
- }
1148
- state.caretPosition++;
1149
- return state;
1150
- }
1151
- return styleTag;
1152
- }
1153
-
1154
- var tagContent = {};
1155
-
1156
- var hasRequiredTagContent;
1157
-
1158
- function requireTagContent () {
1159
- if (hasRequiredTagContent) return tagContent;
1160
- hasRequiredTagContent = 1;
1161
- Object.defineProperty(tagContent, "__esModule", { value: true });
1162
- tagContent.construct = construct;
1163
- const constants_1 = requireConstants();
1164
- const utils_1 = requireUtils();
1165
- function handleOpenTagStart(state, token) {
1166
- (0, utils_1.initChildrenIfNone)(state.currentNode);
1167
- const tagNode = {
1168
- type: constants_1.NodeTypes.Tag,
1169
- parentRef: state.currentNode,
1170
- range: (0, utils_1.cloneRange)(token.range),
1171
- loc: (0, utils_1.cloneLocation)(token.loc),
1172
- attributes: [],
1173
- children: [],
1174
- };
1175
- state.currentNode.children.push(tagNode);
1176
- state.currentNode = tagNode;
1177
- state.currentContext = {
1178
- parentRef: state.currentContext,
1179
- type: constants_1.ConstructTreeContextTypes.Tag,
1180
- };
1181
- return state;
1182
- }
1183
- function handleCloseTag(state, token) {
1184
- const closeTagName = (0, utils_1.parseCloseTagName)(token.value);
1185
- if (closeTagName !== state.currentNode.name) {
1186
- state.caretPosition++;
1187
- return state;
1188
- }
1189
- state.currentContext = state.currentContext.parentRef;
1190
- return state;
1191
- }
1192
- function handleCommentOpen(state, token) {
1193
- (0, utils_1.initChildrenIfNone)(state.currentNode);
1194
- const commentNode = {
1195
- type: constants_1.NodeTypes.Comment,
1196
- parentRef: state.currentNode,
1197
- range: (0, utils_1.cloneRange)(token.range),
1198
- loc: (0, utils_1.cloneLocation)(token.loc),
1199
- };
1200
- state.currentNode.children.push(commentNode);
1201
- // @ts-ignore
1202
- state.currentNode = commentNode;
1203
- state.currentContext = {
1204
- parentRef: state.currentContext,
1205
- type: constants_1.ConstructTreeContextTypes.Comment,
1206
- };
1207
- return state;
1208
- }
1209
- function handleDoctypeOpen(state, token) {
1210
- (0, utils_1.initChildrenIfNone)(state.currentNode);
1211
- const doctypeNode = {
1212
- type: constants_1.NodeTypes.Doctype,
1213
- parentRef: state.currentNode,
1214
- range: (0, utils_1.cloneRange)(token.range),
1215
- loc: (0, utils_1.cloneLocation)(token.loc),
1216
- attributes: [],
1217
- };
1218
- state.currentNode.children.push(doctypeNode);
1219
- // @ts-ignore
1220
- state.currentNode = doctypeNode;
1221
- state.currentContext = {
1222
- parentRef: state.currentContext,
1223
- type: constants_1.ConstructTreeContextTypes.Doctype,
1224
- };
1225
- return state;
1226
- }
1227
- function handleText(state, token) {
1228
- (0, utils_1.initChildrenIfNone)(state.currentNode);
1229
- const textNode = (0, utils_1.createNodeFrom)(token);
1230
- state.currentNode.children.push(textNode);
1231
- state.caretPosition++;
1232
- return state;
1233
- }
1234
- function handleOpenScriptTagStart(state, token) {
1235
- (0, utils_1.initChildrenIfNone)(state.currentNode);
1236
- const scriptNode = {
1237
- type: constants_1.NodeTypes.ScriptTag,
1238
- parentRef: state.currentNode,
1239
- range: (0, utils_1.cloneRange)(token.range),
1240
- loc: (0, utils_1.cloneLocation)(token.loc),
1241
- attributes: [],
1242
- };
1243
- state.currentNode.children.push(scriptNode);
1244
- // @ts-ignore
1245
- state.currentNode = scriptNode;
1246
- state.currentContext = {
1247
- type: constants_1.ConstructTreeContextTypes.ScriptTag,
1248
- parentRef: state.currentContext,
1249
- };
1250
- return state;
1251
- }
1252
- function handleOpenStyleTagStart(state, token) {
1253
- (0, utils_1.initChildrenIfNone)(state.currentNode);
1254
- const styleNode = {
1255
- type: constants_1.NodeTypes.StyleTag,
1256
- parentRef: state.currentNode,
1257
- range: (0, utils_1.cloneRange)(token.range),
1258
- loc: (0, utils_1.cloneLocation)(token.loc),
1259
- attributes: [],
1260
- };
1261
- state.currentNode.children.push(styleNode);
1262
- // @ts-ignore
1263
- state.currentNode = styleNode;
1264
- state.currentContext = {
1265
- type: constants_1.ConstructTreeContextTypes.StyleTag,
1266
- parentRef: state.currentContext,
1267
- };
1268
- return state;
1269
- }
1270
- function construct(token, state) {
1271
- if (token.type === constants_1.TokenTypes.OpenScriptTagStart) {
1272
- return handleOpenScriptTagStart(state, token);
1273
- }
1274
- if (token.type === constants_1.TokenTypes.OpenStyleTagStart) {
1275
- return handleOpenStyleTagStart(state, token);
1276
- }
1277
- if (token.type === constants_1.TokenTypes.OpenTagStart) {
1278
- return handleOpenTagStart(state, token);
1279
- }
1280
- if (token.type === constants_1.TokenTypes.Text) {
1281
- return handleText(state, token);
1282
- }
1283
- if (token.type === constants_1.TokenTypes.CloseTag) {
1284
- return handleCloseTag(state, token);
1285
- }
1286
- if (token.type === constants_1.TokenTypes.CommentOpen) {
1287
- return handleCommentOpen(state, token);
1288
- }
1289
- if (token.type === constants_1.TokenTypes.DoctypeOpen) {
1290
- return handleDoctypeOpen(state, token);
1291
- }
1292
- state.caretPosition++;
1293
- return state;
1294
- }
1295
- return tagContent;
1296
- }
1297
-
1298
- var tagName = {};
1299
-
1300
- var hasRequiredTagName;
1301
-
1302
- function requireTagName () {
1303
- if (hasRequiredTagName) return tagName;
1304
- hasRequiredTagName = 1;
1305
- Object.defineProperty(tagName, "__esModule", { value: true });
1306
- tagName.construct = construct;
1307
- const constants_1 = requireConstants();
1308
- const utils_1 = requireUtils();
1309
- function handleTagOpenStart(state, token) {
1310
- state.currentNode.name = (0, utils_1.parseOpenTagName)(token.value);
1311
- state.currentContext = state.currentContext.parentRef;
1312
- return state;
1313
- }
1314
- function construct(token, state) {
1315
- if (token.type === constants_1.TokenTypes.OpenTagStart) {
1316
- handleTagOpenStart(state, token);
1317
- }
1318
- state.caretPosition++;
1319
- return state;
1320
- }
1321
- return tagName;
1322
- }
1323
-
1324
- var tag = {};
1325
-
1326
- var hasRequiredTag;
1327
-
1328
- function requireTag () {
1329
- if (hasRequiredTag) return tag;
1330
- hasRequiredTag = 1;
1331
- Object.defineProperty(tag, "__esModule", { value: true });
1332
- tag.construct = construct;
1333
- const constants_1 = requireConstants();
1334
- const utils_1 = requireUtils();
1335
- const ATTRIBUTE_START_TOKENS = [
1336
- constants_1.TokenTypes.AttributeKey,
1337
- constants_1.TokenTypes.AttributeAssignment,
1338
- ];
1339
- const SELF_CLOSING_TAGS = [
1340
- "area",
1341
- "base",
1342
- "br",
1343
- "col",
1344
- "embed",
1345
- "hr",
1346
- "img",
1347
- "input",
1348
- "keygen",
1349
- "link",
1350
- "meta",
1351
- "param",
1352
- "source",
1353
- "track",
1354
- "wbr",
1355
- ];
1356
- function handleOpenTagStart(state, token) {
1357
- state.currentNode.openStart = (0, utils_1.createNodeFrom)(token);
1358
- state.currentContext = {
1359
- parentRef: state.currentContext,
1360
- type: constants_1.ConstructTreeContextTypes.TagName,
1361
- };
1362
- return state;
1363
- }
1364
- function handleAttributeStart(state) {
1365
- state.currentContext = {
1366
- parentRef: state.currentContext,
1367
- type: constants_1.ConstructTreeContextTypes.Attributes,
1368
- };
1369
- return state;
1370
- }
1371
- function handleOpenTagEnd(state, token) {
1372
- const tagName = state.currentNode.name;
1373
- state.currentNode.openEnd = (0, utils_1.createNodeFrom)(token);
1374
- (0, utils_1.updateNodeEnd)(state.currentNode, token);
1375
- if (SELF_CLOSING_TAGS.indexOf(tagName) !== -1 ||
1376
- state.currentNode.openEnd.value === "/>") {
1377
- state.currentNode.selfClosing = true;
1378
- state.currentNode = state.currentNode.parentRef;
1379
- state.currentContext = state.currentContext.parentRef;
1380
- state.caretPosition++;
1381
- return state;
1382
- }
1383
- state.currentNode.selfClosing = false;
1384
- state.currentContext = {
1385
- parentRef: state.currentContext,
1386
- type: constants_1.ConstructTreeContextTypes.TagContent,
1387
- };
1388
- state.caretPosition++;
1389
- return state;
1390
- }
1391
- function handleCloseTag(state, token) {
1392
- state.currentNode.close = (0, utils_1.createNodeFrom)(token);
1393
- (0, utils_1.updateNodeEnd)(state.currentNode, token);
1394
- state.currentNode = state.currentNode.parentRef;
1395
- state.currentContext = state.currentContext.parentRef;
1396
- state.caretPosition++;
1397
- return state;
1398
- }
1399
- function construct(token, state) {
1400
- if (token.type === constants_1.TokenTypes.OpenTagStart) {
1401
- return handleOpenTagStart(state, token);
1402
- }
1403
- if (ATTRIBUTE_START_TOKENS.indexOf(token.type) !== -1) {
1404
- return handleAttributeStart(state);
1405
- }
1406
- if (token.type === constants_1.TokenTypes.OpenTagEnd) {
1407
- return handleOpenTagEnd(state, token);
1408
- }
1409
- if (token.type === constants_1.TokenTypes.CloseTag) {
1410
- return handleCloseTag(state, token);
1411
- }
1412
- state.caretPosition++;
1413
- return state;
1414
- }
1415
- return tag;
1416
- }
1417
-
1418
- var hasRequiredHandlers$1;
1419
-
1420
- function requireHandlers$1 () {
1421
- if (hasRequiredHandlers$1) return handlers$1;
1422
- hasRequiredHandlers$1 = 1;
1423
- var __createBinding = (handlers$1 && handlers$1.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1424
- if (k2 === undefined) k2 = k;
1425
- var desc = Object.getOwnPropertyDescriptor(m, k);
1426
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1427
- desc = { enumerable: true, get: function() { return m[k]; } };
1428
- }
1429
- Object.defineProperty(o, k2, desc);
1430
- }) : (function(o, m, k, k2) {
1431
- if (k2 === undefined) k2 = k;
1432
- o[k2] = m[k];
1433
- }));
1434
- var __setModuleDefault = (handlers$1 && handlers$1.__setModuleDefault) || (Object.create ? (function(o, v) {
1435
- Object.defineProperty(o, "default", { enumerable: true, value: v });
1436
- }) : function(o, v) {
1437
- o["default"] = v;
1438
- });
1439
- var __importStar = (handlers$1 && handlers$1.__importStar) || function (mod) {
1440
- if (mod && mod.__esModule) return mod;
1441
- var result = {};
1442
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1443
- __setModuleDefault(result, mod);
1444
- return result;
1445
- };
1446
- Object.defineProperty(handlers$1, "__esModule", { value: true });
1447
- handlers$1.tag = handlers$1.tagName = handlers$1.tagContent = handlers$1.styleTag = handlers$1.scriptTag = handlers$1.doctype = handlers$1.doctypeAttributes = handlers$1.doctypeAttribute = handlers$1.comment = handlers$1.attribute = handlers$1.attributes = handlers$1.attributeValue = void 0;
1448
- handlers$1.attributeValue = __importStar(requireAttributeValue$1());
1449
- handlers$1.attributes = __importStar(requireAttributes$1());
1450
- handlers$1.attribute = __importStar(requireAttribute());
1451
- handlers$1.comment = __importStar(requireComment());
1452
- handlers$1.doctypeAttribute = __importStar(requireDoctypeAttribute());
1453
- handlers$1.doctypeAttributes = __importStar(requireDoctypeAttributes$1());
1454
- handlers$1.doctype = __importStar(requireDoctype());
1455
- handlers$1.scriptTag = __importStar(requireScriptTag());
1456
- handlers$1.styleTag = __importStar(requireStyleTag());
1457
- handlers$1.tagContent = __importStar(requireTagContent());
1458
- handlers$1.tagName = __importStar(requireTagName());
1459
- handlers$1.tag = __importStar(requireTag());
1460
- return handlers$1;
1461
- }
1462
-
1463
- var hasRequiredConstructTree;
1464
-
1465
- function requireConstructTree () {
1466
- if (hasRequiredConstructTree) return constructTree;
1467
- hasRequiredConstructTree = 1;
1468
- Object.defineProperty(constructTree, "__esModule", { value: true });
1469
- constructTree.constructTree = constructTree$1;
1470
- const constants_1 = requireConstants();
1471
- const utils_1 = requireUtils();
1472
- const clone_location_1 = requireCloneLocation();
1473
- const handlers_1 = requireHandlers$1();
1474
- const contextHandlers = {
1475
- [constants_1.ConstructTreeContextTypes.TagContent]: handlers_1.tagContent,
1476
- [constants_1.ConstructTreeContextTypes.Tag]: handlers_1.tag,
1477
- [constants_1.ConstructTreeContextTypes.TagName]: handlers_1.tagName,
1478
- [constants_1.ConstructTreeContextTypes.Attribute]: handlers_1.attribute,
1479
- [constants_1.ConstructTreeContextTypes.Attributes]: handlers_1.attributes,
1480
- [constants_1.ConstructTreeContextTypes.AttributeValue]: handlers_1.attributeValue,
1481
- [constants_1.ConstructTreeContextTypes.Comment]: handlers_1.comment,
1482
- [constants_1.ConstructTreeContextTypes.Doctype]: handlers_1.doctype,
1483
- [constants_1.ConstructTreeContextTypes.DoctypeAttributes]: handlers_1.doctypeAttributes,
1484
- [constants_1.ConstructTreeContextTypes.DoctypeAttribute]: handlers_1.doctypeAttribute,
1485
- [constants_1.ConstructTreeContextTypes.ScriptTag]: handlers_1.scriptTag,
1486
- [constants_1.ConstructTreeContextTypes.StyleTag]: handlers_1.styleTag,
1487
- };
1488
- const EMPTY_RANGE = [0, 0];
1489
- const EMPTY_LOC = {
1490
- start: {
1491
- line: 1,
1492
- column: 0,
1493
- },
1494
- end: {
1495
- line: 1,
1496
- column: 0,
1497
- },
1498
- };
1499
- function constructTree$1(tokens) {
1500
- const rootContext = {
1501
- type: constants_1.ConstructTreeContextTypes.TagContent,
1502
- parentRef: undefined,
1503
- content: [],
1504
- };
1505
- const lastToken = (0, utils_1.last)(tokens);
1506
- const firstToken = (0, utils_1.first)(tokens);
1507
- const range = lastToken ? [0, lastToken.range[1]] : EMPTY_RANGE;
1508
- const loc = lastToken
1509
- ? {
1510
- start: (0, clone_location_1.cloneLocation)(firstToken.loc).start,
1511
- end: (0, clone_location_1.cloneLocation)(lastToken.loc).end,
1512
- }
1513
- : EMPTY_LOC;
1514
- loc.start.line = 1;
1515
- const rootNode = {
1516
- type: constants_1.NodeTypes.Document,
1517
- range,
1518
- children: [],
1519
- loc,
1520
- };
1521
- const state = {
1522
- caretPosition: 0,
1523
- currentContext: rootContext,
1524
- currentNode: rootNode,
1525
- rootNode,
1526
- };
1527
- const positionOffset = state.caretPosition;
1528
- processTokens(tokens, state, positionOffset);
1529
- return { state, ast: state.rootNode };
1530
- }
1531
- function processTokens(tokens, state, positionOffset) {
1532
- let tokenIndex = state.caretPosition - positionOffset;
1533
- while (tokenIndex < tokens.length) {
1534
- const token = tokens[tokenIndex];
1535
- const handler = contextHandlers[state.currentContext.type].construct;
1536
- // @ts-ignore
1537
- state = handler(token, state);
1538
- tokenIndex = state.caretPosition - positionOffset;
1539
- }
1540
- return state;
1541
- }
1542
- return constructTree;
1543
- }
1544
-
1545
- var hasRequiredTreeConstructor;
1546
-
1547
- function requireTreeConstructor () {
1548
- if (hasRequiredTreeConstructor) return treeConstructor;
1549
- hasRequiredTreeConstructor = 1;
1550
- (function (exports) {
1551
- Object.defineProperty(exports, "__esModule", { value: true });
1552
- exports.constructTree = void 0;
1553
- var construct_tree_1 = requireConstructTree();
1554
- Object.defineProperty(exports, "constructTree", { enumerable: true, get: function () { return construct_tree_1.constructTree; } });
1555
- } (treeConstructor));
1556
- return treeConstructor;
1557
- }
1558
-
1559
- var tokenizer = {};
1560
-
1561
- var tokenize = {};
1562
-
1563
- var handlers = {};
1564
-
1565
- var attributeKey = {};
1566
-
1567
- var createTemplates = {};
1568
-
1569
- var hasRequiredCreateTemplates;
1570
-
1571
- function requireCreateTemplates () {
1572
- if (hasRequiredCreateTemplates) return createTemplates;
1573
- hasRequiredCreateTemplates = 1;
1574
- Object.defineProperty(createTemplates, "__esModule", { value: true });
1575
- createTemplates.createTemplates = createTemplates$1;
1576
- function createTemplates$1(state, type) {
1577
- return state.mode === "template" && state.accumulatedContent.hasTemplate()
1578
- ? state.accumulatedContent.getTemplates().map((chars) => {
1579
- const token = {
1580
- type: type,
1581
- range: chars.range,
1582
- loc: state.sourceCode.getLocationOf(chars.range),
1583
- isTemplate: chars.isTemplate,
1584
- value: chars.value,
1585
- };
1586
- return Object.assign(Object.assign({}, token), { range: state.tokenAdapter.finalizeRange(token), loc: state.tokenAdapter.finalizeLocation(token) });
1587
- })
1588
- : [];
1589
- }
1590
- return createTemplates;
1591
- }
1592
-
1593
- var hasRequiredAttributeKey;
1594
-
1595
- function requireAttributeKey () {
1596
- if (hasRequiredAttributeKey) return attributeKey;
1597
- hasRequiredAttributeKey = 1;
1598
- Object.defineProperty(attributeKey, "__esModule", { value: true });
1599
- attributeKey.parse = parse;
1600
- const constants_1 = requireConstants();
1601
- const token_types_1 = requireTokenTypes();
1602
- const utils_1 = requireUtils();
1603
- const create_templates_1 = requireCreateTemplates();
1604
- function parse(chars, state) {
1605
- if (isKeyBreak(chars)) {
1606
- return parseKeyEnd(state);
1607
- }
1608
- state.accumulatedContent.concatBuffer(state.decisionBuffer);
1609
- state.decisionBuffer.clear();
1610
- state.sourceCode.next();
1611
- }
1612
- function isKeyBreak(chars) {
1613
- const value = chars.value();
1614
- return value === "=" || value === "/" || value === ">" || (0, utils_1.isWhitespace)(value);
1615
- }
1616
- function parseKeyEnd(state) {
1617
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
1618
- state.tokens.push({
1619
- type: token_types_1.TokenTypes.AttributeKey,
1620
- value: state.accumulatedContent.value(),
1621
- range: position.range,
1622
- loc: position.loc,
1623
- templates: (0, create_templates_1.createTemplates)(state, token_types_1.TokenTypes.AttributeKey),
1624
- });
1625
- state.accumulatedContent.clear();
1626
- state.decisionBuffer.clear();
1627
- state.currentContext = constants_1.TokenizerContextTypes.Attributes;
1628
- }
1629
- return attributeKey;
1630
- }
1631
-
1632
- var attributeValueBare = {};
1633
-
1634
- var hasRequiredAttributeValueBare;
1635
-
1636
- function requireAttributeValueBare () {
1637
- if (hasRequiredAttributeValueBare) return attributeValueBare;
1638
- hasRequiredAttributeValueBare = 1;
1639
- Object.defineProperty(attributeValueBare, "__esModule", { value: true });
1640
- attributeValueBare.parseValueEnd = parseValueEnd;
1641
- attributeValueBare.parse = parse;
1642
- const constants_1 = requireConstants();
1643
- const utils_1 = requireUtils();
1644
- const create_templates_1 = requireCreateTemplates();
1645
- function parseValueEnd(state) {
1646
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
1647
- state.tokens.push({
1648
- type: constants_1.TokenTypes.AttributeValue,
1649
- value: state.accumulatedContent.value(),
1650
- range: position.range,
1651
- loc: position.loc,
1652
- templates: (0, create_templates_1.createTemplates)(state, constants_1.TokenTypes.AttributeValue),
1653
- });
1654
- state.accumulatedContent.clear();
1655
- state.decisionBuffer.clear();
1656
- state.currentContext = constants_1.TokenizerContextTypes.Attributes;
1657
- }
1658
- function parse(chars, state) {
1659
- if ((0, utils_1.isWhitespace)(chars.value()) ||
1660
- chars.value() === ">" ||
1661
- chars.value() === "/") {
1662
- return parseValueEnd(state);
1663
- }
1664
- state.accumulatedContent.concatBuffer(state.decisionBuffer);
1665
- state.decisionBuffer.clear();
1666
- state.sourceCode.next();
1667
- }
1668
- return attributeValueBare;
1669
- }
1670
-
1671
- var attributeValueWrapped = {};
1672
-
1673
- var hasRequiredAttributeValueWrapped;
1674
-
1675
- function requireAttributeValueWrapped () {
1676
- if (hasRequiredAttributeValueWrapped) return attributeValueWrapped;
1677
- hasRequiredAttributeValueWrapped = 1;
1678
- Object.defineProperty(attributeValueWrapped, "__esModule", { value: true });
1679
- attributeValueWrapped.parse = parse;
1680
- const constants_1 = requireConstants();
1681
- const utils_1 = requireUtils();
1682
- const create_templates_1 = requireCreateTemplates();
1683
- function parse(chars, state) {
1684
- var _a;
1685
- const wrapperChar = (_a = state.contextParams[constants_1.TokenizerContextTypes.AttributeValueWrapped]) === null || _a === void 0 ? void 0 : _a.wrapper;
1686
- if (chars.value() === wrapperChar) {
1687
- return parseWrapper(state);
1688
- }
1689
- state.accumulatedContent.concatBuffer(state.decisionBuffer);
1690
- state.decisionBuffer.clear();
1691
- state.sourceCode.next();
1692
- }
1693
- function parseWrapper(state) {
1694
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
1695
- const endWrapperPosition = position.range[1];
1696
- state.tokens.push({
1697
- type: constants_1.TokenTypes.AttributeValue,
1698
- value: state.accumulatedContent.value(),
1699
- range: position.range,
1700
- loc: position.loc,
1701
- templates: (0, create_templates_1.createTemplates)(state, constants_1.TokenTypes.AttributeValue),
1702
- });
1703
- const range = [endWrapperPosition, endWrapperPosition + 1];
1704
- state.tokens.push({
1705
- type: constants_1.TokenTypes.AttributeValueWrapperEnd,
1706
- value: state.decisionBuffer.value(),
1707
- range,
1708
- loc: state.sourceCode.getLocationOf(range),
1709
- });
1710
- state.accumulatedContent.clear();
1711
- state.decisionBuffer.clear();
1712
- state.currentContext = constants_1.TokenizerContextTypes.Attributes;
1713
- state.sourceCode.next();
1714
- state.contextParams[constants_1.TokenizerContextTypes.AttributeValueWrapped] = undefined;
1715
- }
1716
- return attributeValueWrapped;
1717
- }
1718
-
1719
- var attributeValue = {};
1720
-
1721
- var hasRequiredAttributeValue;
1722
-
1723
- function requireAttributeValue () {
1724
- if (hasRequiredAttributeValue) return attributeValue;
1725
- hasRequiredAttributeValue = 1;
1726
- Object.defineProperty(attributeValue, "__esModule", { value: true });
1727
- attributeValue.parse = parse;
1728
- const constants_1 = requireConstants();
1729
- const utils_1 = requireUtils();
1730
- function parse(chars, state) {
1731
- const value = chars.value();
1732
- if (value === '"' || value === "'") {
1733
- return parseWrapper(state);
1734
- }
1735
- if (value === ">" || value === "/") {
1736
- return parseTagEnd(state);
1737
- }
1738
- if (!(0, utils_1.isWhitespace)(value)) {
1739
- return parseBare(state);
1740
- }
1741
- state.decisionBuffer.clear();
1742
- state.sourceCode.next();
1743
- }
1744
- function parseWrapper(state) {
1745
- const wrapper = state.decisionBuffer.value();
1746
- const range = [state.sourceCode.index(), state.sourceCode.index() + 1];
1747
- state.tokens.push({
1748
- type: constants_1.TokenTypes.AttributeValueWrapperStart,
1749
- value: wrapper,
1750
- range,
1751
- loc: state.sourceCode.getLocationOf(range),
1752
- });
1753
- state.accumulatedContent.clear();
1754
- state.decisionBuffer.clear();
1755
- state.currentContext = constants_1.TokenizerContextTypes.AttributeValueWrapped;
1756
- state.contextParams[constants_1.TokenizerContextTypes.AttributeValueWrapped] = {
1757
- wrapper: wrapper,
1758
- };
1759
- state.sourceCode.next();
1760
- }
1761
- function parseBare(state) {
1762
- state.accumulatedContent.replace(state.decisionBuffer);
1763
- state.decisionBuffer.clear();
1764
- state.currentContext = constants_1.TokenizerContextTypes.AttributeValueBare;
1765
- state.sourceCode.next();
1766
- }
1767
- function parseTagEnd(state) {
1768
- state.accumulatedContent.clear();
1769
- state.decisionBuffer.clear();
1770
- state.currentContext = constants_1.TokenizerContextTypes.Attributes;
1771
- }
1772
- return attributeValue;
1773
- }
1774
-
1775
- var attributes = {};
1776
-
1777
- var hasRequiredAttributes;
1778
-
1779
- function requireAttributes () {
1780
- if (hasRequiredAttributes) return attributes;
1781
- hasRequiredAttributes = 1;
1782
- Object.defineProperty(attributes, "__esModule", { value: true });
1783
- attributes.parse = parse;
1784
- const constants_1 = requireConstants();
1785
- const utils_1 = requireUtils();
1786
- function parse(chars, state) {
1787
- const value = chars.value();
1788
- if (value === ">" || value === "/") {
1789
- return parseTagEnd(state);
1790
- }
1791
- if (value === "=") {
1792
- return parseEqual(state);
1793
- }
1794
- if (!(0, utils_1.isWhitespace)(value)) {
1795
- return parseNoneWhitespace(chars, state);
1796
- }
1797
- state.decisionBuffer.clear();
1798
- state.sourceCode.next();
1799
- }
1800
- function parseTagEnd(state) {
1801
- var _a;
1802
- const tagName = (_a = state.contextParams[constants_1.TokenizerContextTypes.Attributes]) === null || _a === void 0 ? void 0 : _a.tagName;
1803
- state.accumulatedContent.clear();
1804
- state.decisionBuffer.clear();
1805
- state.currentContext = constants_1.TokenizerContextTypes.OpenTagEnd;
1806
- state.contextParams[constants_1.TokenizerContextTypes.OpenTagEnd] = { tagName: tagName };
1807
- state.contextParams[constants_1.TokenizerContextTypes.Attributes] = undefined;
1808
- }
1809
- function parseNoneWhitespace(chars, state) {
1810
- state.accumulatedContent.replace(state.decisionBuffer);
1811
- state.currentContext = constants_1.TokenizerContextTypes.AttributeKey;
1812
- state.sourceCode.next();
1813
- state.decisionBuffer.clear();
1814
- }
1815
- function parseEqual(state) {
1816
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: true });
1817
- state.tokens.push({
1818
- type: constants_1.TokenTypes.AttributeAssignment,
1819
- value: state.decisionBuffer.value(),
1820
- range: position.range,
1821
- loc: position.loc,
1822
- });
1823
- state.accumulatedContent.clear();
1824
- state.decisionBuffer.clear();
1825
- state.currentContext = constants_1.TokenizerContextTypes.AttributeValue;
1826
- state.sourceCode.next();
1827
- }
1828
- return attributes;
1829
- }
1830
-
1831
- var closeTag = {};
1832
-
1833
- var hasRequiredCloseTag;
1834
-
1835
- function requireCloseTag () {
1836
- if (hasRequiredCloseTag) return closeTag;
1837
- hasRequiredCloseTag = 1;
1838
- Object.defineProperty(closeTag, "__esModule", { value: true });
1839
- closeTag.parse = parse;
1840
- const constants_1 = requireConstants();
1841
- const utils_1 = requireUtils();
1842
- function parse(chars, state) {
1843
- const value = chars.value();
1844
- if (value === ">") {
1845
- return parseClosingCornerBrace(state);
1846
- }
1847
- state.accumulatedContent.concatBuffer(state.decisionBuffer);
1848
- state.decisionBuffer.clear();
1849
- state.sourceCode.next();
1850
- }
1851
- function parseClosingCornerBrace(state) {
1852
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: true });
1853
- state.tokens.push({
1854
- type: constants_1.TokenTypes.CloseTag,
1855
- value: state.accumulatedContent.value() + state.decisionBuffer.value(),
1856
- range: position.range,
1857
- loc: position.loc,
1858
- });
1859
- state.accumulatedContent.clear();
1860
- state.decisionBuffer.clear();
1861
- state.currentContext = constants_1.TokenizerContextTypes.Data;
1862
- state.sourceCode.next();
1863
- }
1864
- return closeTag;
1865
- }
1866
-
1867
- var commentContent = {};
1868
-
1869
- var hasRequiredCommentContent;
1870
-
1871
- function requireCommentContent () {
1872
- if (hasRequiredCommentContent) return commentContent;
1873
- hasRequiredCommentContent = 1;
1874
- Object.defineProperty(commentContent, "__esModule", { value: true });
1875
- commentContent.parse = parse;
1876
- const constants_1 = requireConstants();
1877
- const utils_1 = requireUtils();
1878
- const create_templates_1 = requireCreateTemplates();
1879
- const COMMENT_END = "-->";
1880
- function parse(chars, state) {
1881
- const value = chars.value();
1882
- if (value === "-" || value === "--") {
1883
- state.sourceCode.next();
1884
- return;
1885
- }
1886
- if (value === COMMENT_END) {
1887
- return parseCommentClose(state);
1888
- }
1889
- state.accumulatedContent.concatBuffer(state.decisionBuffer);
1890
- state.decisionBuffer.clear();
1891
- state.sourceCode.next();
1892
- }
1893
- function parseCommentClose(state) {
1894
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
1895
- const endRange = [
1896
- position.range[1],
1897
- position.range[1] + COMMENT_END.length,
1898
- ];
1899
- state.tokens.push({
1900
- type: constants_1.TokenTypes.CommentContent,
1901
- value: state.accumulatedContent.value(),
1902
- range: position.range,
1903
- loc: position.loc,
1904
- templates: (0, create_templates_1.createTemplates)(state, constants_1.TokenTypes.CommentContent),
1905
- });
1906
- state.tokens.push({
1907
- type: constants_1.TokenTypes.CommentClose,
1908
- value: state.decisionBuffer.value(),
1909
- range: endRange,
1910
- loc: state.sourceCode.getLocationOf(endRange),
1911
- });
1912
- state.accumulatedContent.clear();
1913
- state.decisionBuffer.clear();
1914
- state.currentContext = constants_1.TokenizerContextTypes.Data;
1915
- state.sourceCode.next();
1916
- }
1917
- return commentContent;
1918
- }
1919
-
1920
- var data = {};
1921
-
1922
- var hasRequiredData;
1923
-
1924
- function requireData () {
1925
- if (hasRequiredData) return data;
1926
- hasRequiredData = 1;
1927
- Object.defineProperty(data, "__esModule", { value: true });
1928
- data.parse = parse;
1929
- data.handleContentEnd = handleContentEnd;
1930
- const constants_1 = requireConstants();
1931
- const utils_1 = requireUtils();
1932
- const create_templates_1 = requireCreateTemplates();
1933
- const COMMENT_START = "<!--";
1934
- const OPEN_TAG_START_PATTERN = /^<\w/;
1935
- function parse(chars, state) {
1936
- const value = chars.value();
1937
- if (OPEN_TAG_START_PATTERN.test(value)) {
1938
- return parseOpeningCornerBraceWithText(state);
1939
- }
1940
- if (value === "</") {
1941
- return parseOpeningCornerBraceWithSlash(state);
1942
- }
1943
- if (value === "<" || value === "<!" || value === "<!-") {
1944
- state.sourceCode.next();
1945
- return;
1946
- }
1947
- if (value === COMMENT_START) {
1948
- return parseCommentOpen(state);
1949
- }
1950
- if (isIncompleteDoctype(value)) {
1951
- state.sourceCode.next();
1952
- return;
1953
- }
1954
- if (value.toUpperCase() === "<!DOCTYPE") {
1955
- return parseDoctypeOpen(state);
1956
- }
1957
- state.accumulatedContent.concatBuffer(state.decisionBuffer);
1958
- state.decisionBuffer.clear();
1959
- state.sourceCode.next();
1960
- }
1961
- function handleContentEnd(state) {
1962
- const textContent = state.accumulatedContent.value() + state.decisionBuffer.value();
1963
- if (textContent.length !== 0) {
1964
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
1965
- state.tokens.push({
1966
- type: constants_1.TokenTypes.Text,
1967
- value: textContent,
1968
- range: position.range,
1969
- loc: position.loc,
1970
- templates: (0, create_templates_1.createTemplates)(state, constants_1.TokenTypes.Text),
1971
- });
1972
- }
1973
- }
1974
- function generateTextToken(state) {
1975
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
1976
- return {
1977
- type: constants_1.TokenTypes.Text,
1978
- value: state.accumulatedContent.value(),
1979
- range: position.range,
1980
- loc: position.loc,
1981
- templates: (0, create_templates_1.createTemplates)(state, constants_1.TokenTypes.Text),
1982
- };
1983
- }
1984
- function parseOpeningCornerBraceWithText(state) {
1985
- if (state.accumulatedContent.length() !== 0) {
1986
- state.tokens.push(generateTextToken(state));
1987
- }
1988
- state.accumulatedContent.replace(state.decisionBuffer);
1989
- state.decisionBuffer.clear();
1990
- state.currentContext = constants_1.TokenizerContextTypes.OpenTagStart;
1991
- state.sourceCode.next();
1992
- }
1993
- function parseOpeningCornerBraceWithSlash(state) {
1994
- if (state.accumulatedContent.length() !== 0) {
1995
- state.tokens.push(generateTextToken(state));
1996
- }
1997
- state.accumulatedContent.replace(state.decisionBuffer);
1998
- state.decisionBuffer.clear();
1999
- state.currentContext = constants_1.TokenizerContextTypes.CloseTag;
2000
- state.sourceCode.next();
2001
- }
2002
- function isIncompleteDoctype(chars) {
2003
- const charsUpperCase = chars.toUpperCase();
2004
- return (charsUpperCase === "<!" ||
2005
- charsUpperCase === "<!D" ||
2006
- charsUpperCase === "<!DO" ||
2007
- charsUpperCase === "<!DOC" ||
2008
- charsUpperCase === "<!DOCT" ||
2009
- charsUpperCase === "<!DOCTY" ||
2010
- charsUpperCase === "<!DOCTYP");
2011
- }
2012
- function parseCommentOpen(state) {
2013
- if (state.accumulatedContent.length() !== 0) {
2014
- state.tokens.push(generateTextToken(state));
2015
- }
2016
- const range = [
2017
- state.sourceCode.index() - (COMMENT_START.length - 1),
2018
- state.sourceCode.index() + 1,
2019
- ];
2020
- state.tokens.push({
2021
- type: constants_1.TokenTypes.CommentOpen,
2022
- value: state.decisionBuffer.value(),
2023
- range: range,
2024
- loc: state.sourceCode.getLocationOf(range),
2025
- });
2026
- state.accumulatedContent.clear();
2027
- state.decisionBuffer.clear();
2028
- state.currentContext = constants_1.TokenizerContextTypes.CommentContent;
2029
- state.sourceCode.next();
2030
- }
2031
- function parseDoctypeOpen(state) {
2032
- if (state.accumulatedContent.length() !== 0) {
2033
- state.tokens.push(generateTextToken(state));
2034
- }
2035
- state.accumulatedContent.replace(state.decisionBuffer);
2036
- state.decisionBuffer.clear();
2037
- state.currentContext = constants_1.TokenizerContextTypes.DoctypeOpen;
2038
- state.sourceCode.next();
2039
- }
2040
- return data;
2041
- }
2042
-
2043
- var doctypeAttributeBare = {};
2044
-
2045
- var hasRequiredDoctypeAttributeBare;
2046
-
2047
- function requireDoctypeAttributeBare () {
2048
- if (hasRequiredDoctypeAttributeBare) return doctypeAttributeBare;
2049
- hasRequiredDoctypeAttributeBare = 1;
2050
- Object.defineProperty(doctypeAttributeBare, "__esModule", { value: true });
2051
- doctypeAttributeBare.parse = parse;
2052
- const constants_1 = requireConstants();
2053
- const utils_1 = requireUtils();
2054
- function parse(chars, state) {
2055
- if ((0, utils_1.isWhitespace)(chars.value()) || chars.value() === ">") {
2056
- return parseAttributeEnd(state);
2057
- }
2058
- state.accumulatedContent.concatBuffer(state.decisionBuffer);
2059
- state.decisionBuffer.clear();
2060
- state.sourceCode.next();
2061
- }
2062
- function parseAttributeEnd(state) {
2063
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2064
- state.tokens.push({
2065
- type: constants_1.TokenTypes.DoctypeAttributeValue,
2066
- value: state.accumulatedContent.value(),
2067
- range: position.range,
2068
- loc: position.loc,
2069
- });
2070
- state.accumulatedContent.clear();
2071
- state.decisionBuffer.clear();
2072
- state.currentContext = constants_1.TokenizerContextTypes.DoctypeAttributes;
2073
- }
2074
- return doctypeAttributeBare;
2075
- }
2076
-
2077
- var doctypeAttributeWrapped = {};
2078
-
2079
- var hasRequiredDoctypeAttributeWrapped;
2080
-
2081
- function requireDoctypeAttributeWrapped () {
2082
- if (hasRequiredDoctypeAttributeWrapped) return doctypeAttributeWrapped;
2083
- hasRequiredDoctypeAttributeWrapped = 1;
2084
- Object.defineProperty(doctypeAttributeWrapped, "__esModule", { value: true });
2085
- doctypeAttributeWrapped.parse = parse;
2086
- const constants_1 = requireConstants();
2087
- const utils_1 = requireUtils();
2088
- function parse(chars, state) {
2089
- var _a;
2090
- const wrapperChar = (_a = state.contextParams[constants_1.TokenizerContextTypes.DoctypeAttributeWrapped]) === null || _a === void 0 ? void 0 : _a.wrapper;
2091
- if (chars.value() === wrapperChar) {
2092
- return parseWrapper(state);
2093
- }
2094
- state.accumulatedContent.concatBuffer(state.decisionBuffer);
2095
- state.decisionBuffer.clear();
2096
- state.sourceCode.next();
2097
- }
2098
- function parseWrapper(state) {
2099
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2100
- const endWrapperPosition = position.range[1];
2101
- state.tokens.push({
2102
- type: constants_1.TokenTypes.DoctypeAttributeValue,
2103
- value: state.accumulatedContent.value(),
2104
- range: position.range,
2105
- loc: position.loc,
2106
- });
2107
- const range = [endWrapperPosition, endWrapperPosition + 1];
2108
- state.tokens.push({
2109
- type: constants_1.TokenTypes.DoctypeAttributeWrapperEnd,
2110
- value: state.decisionBuffer.value(),
2111
- range,
2112
- loc: state.sourceCode.getLocationOf(range),
2113
- });
2114
- state.accumulatedContent.clear();
2115
- state.decisionBuffer.clear();
2116
- state.currentContext = constants_1.TokenizerContextTypes.DoctypeAttributes;
2117
- state.sourceCode.next();
2118
- state.contextParams[constants_1.TokenizerContextTypes.DoctypeAttributeWrapped] =
2119
- undefined;
2120
- }
2121
- return doctypeAttributeWrapped;
2122
- }
2123
-
2124
- var doctypeAttributes = {};
2125
-
2126
- var hasRequiredDoctypeAttributes;
2127
-
2128
- function requireDoctypeAttributes () {
2129
- if (hasRequiredDoctypeAttributes) return doctypeAttributes;
2130
- hasRequiredDoctypeAttributes = 1;
2131
- Object.defineProperty(doctypeAttributes, "__esModule", { value: true });
2132
- doctypeAttributes.parse = parse;
2133
- const constants_1 = requireConstants();
2134
- const utils_1 = requireUtils();
2135
- function parse(chars, state) {
2136
- if (chars.value() === '"' || chars.value() === "'") {
2137
- return parseWrapper(state);
2138
- }
2139
- if (chars.value() === ">") {
2140
- return parseClosingCornerBrace(state);
2141
- }
2142
- if (!(0, utils_1.isWhitespace)(chars.value())) {
2143
- return parseBare(state);
2144
- }
2145
- state.decisionBuffer.clear();
2146
- state.sourceCode.next();
2147
- }
2148
- function parseWrapper(state) {
2149
- const wrapper = state.decisionBuffer.value();
2150
- const range = [
2151
- state.sourceCode.index(),
2152
- state.sourceCode.index() + wrapper.length,
2153
- ];
2154
- state.tokens.push({
2155
- type: constants_1.TokenTypes.DoctypeAttributeWrapperStart,
2156
- value: wrapper,
2157
- range,
2158
- loc: state.sourceCode.getLocationOf(range),
2159
- });
2160
- state.accumulatedContent.clear();
2161
- state.decisionBuffer.clear();
2162
- state.currentContext = constants_1.TokenizerContextTypes.DoctypeAttributeWrapped;
2163
- state.contextParams[constants_1.TokenizerContextTypes.DoctypeAttributeWrapped] = {
2164
- wrapper: wrapper,
2165
- };
2166
- state.sourceCode.next();
2167
- }
2168
- function parseBare(state) {
2169
- state.accumulatedContent.replace(state.decisionBuffer);
2170
- state.decisionBuffer.clear();
2171
- state.currentContext = constants_1.TokenizerContextTypes.DoctypeAttributeBare;
2172
- state.sourceCode.next();
2173
- }
2174
- function parseClosingCornerBrace(state) {
2175
- state.accumulatedContent.clear();
2176
- state.decisionBuffer.clear();
2177
- state.currentContext = constants_1.TokenizerContextTypes.DoctypeClose;
2178
- }
2179
- return doctypeAttributes;
2180
- }
2181
-
2182
- var doctypeEnd = {};
2183
-
2184
- var hasRequiredDoctypeEnd;
2185
-
2186
- function requireDoctypeEnd () {
2187
- if (hasRequiredDoctypeEnd) return doctypeEnd;
2188
- hasRequiredDoctypeEnd = 1;
2189
- Object.defineProperty(doctypeEnd, "__esModule", { value: true });
2190
- doctypeEnd.parse = parse;
2191
- const constants_1 = requireConstants();
2192
- const utils_1 = requireUtils();
2193
- function parse(chars, state) {
2194
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: true });
2195
- state.tokens.push({
2196
- type: constants_1.TokenTypes.DoctypeClose,
2197
- value: state.decisionBuffer.value(),
2198
- range: position.range,
2199
- loc: position.loc,
2200
- });
2201
- state.accumulatedContent.clear();
2202
- state.decisionBuffer.clear();
2203
- state.currentContext = constants_1.TokenizerContextTypes.Data;
2204
- state.sourceCode.next();
2205
- }
2206
- return doctypeEnd;
2207
- }
2208
-
2209
- var doctypeStart = {};
2210
-
2211
- var hasRequiredDoctypeStart;
2212
-
2213
- function requireDoctypeStart () {
2214
- if (hasRequiredDoctypeStart) return doctypeStart;
2215
- hasRequiredDoctypeStart = 1;
2216
- Object.defineProperty(doctypeStart, "__esModule", { value: true });
2217
- doctypeStart.parse = parse;
2218
- const constants_1 = requireConstants();
2219
- const utils_1 = requireUtils();
2220
- function parse(chars, state) {
2221
- const value = chars.value();
2222
- if ((0, utils_1.isWhitespace)(value)) {
2223
- return parseWhitespace(state);
2224
- }
2225
- if (value === ">") {
2226
- return parseClosingCornerBrace(state);
2227
- }
2228
- state.decisionBuffer.clear();
2229
- state.sourceCode.next();
2230
- }
2231
- function generateDoctypeOpenToken(state) {
2232
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2233
- return {
2234
- type: constants_1.TokenTypes.DoctypeOpen,
2235
- value: state.accumulatedContent.value(),
2236
- range: position.range,
2237
- loc: position.loc,
2238
- };
2239
- }
2240
- function parseWhitespace(state) {
2241
- state.tokens.push(generateDoctypeOpenToken(state));
2242
- state.accumulatedContent.clear();
2243
- state.decisionBuffer.clear();
2244
- state.currentContext = constants_1.TokenizerContextTypes.DoctypeAttributes;
2245
- }
2246
- function parseClosingCornerBrace(state) {
2247
- state.tokens.push(generateDoctypeOpenToken(state));
2248
- state.accumulatedContent.clear();
2249
- state.decisionBuffer.clear();
2250
- state.currentContext = constants_1.TokenizerContextTypes.DoctypeClose;
2251
- }
2252
- return doctypeStart;
2253
- }
2254
-
2255
- var openTagEnd = {};
2256
-
2257
- var hasRequiredOpenTagEnd;
2258
-
2259
- function requireOpenTagEnd () {
2260
- if (hasRequiredOpenTagEnd) return openTagEnd;
2261
- hasRequiredOpenTagEnd = 1;
2262
- Object.defineProperty(openTagEnd, "__esModule", { value: true });
2263
- openTagEnd.parse = parse;
2264
- const constants_1 = requireConstants();
2265
- const utils_1 = requireUtils();
2266
- const tokensMap = {
2267
- script: constants_1.TokenTypes.OpenScriptTagEnd,
2268
- style: constants_1.TokenTypes.OpenStyleTagEnd,
2269
- default: constants_1.TokenTypes.OpenTagEnd,
2270
- };
2271
- const contextsMap = {
2272
- script: constants_1.TokenizerContextTypes.ScriptContent,
2273
- style: constants_1.TokenizerContextTypes.StyleContent,
2274
- default: constants_1.TokenizerContextTypes.Data,
2275
- };
2276
- function parse(chars, state) {
2277
- if (chars.value() === ">") {
2278
- return parseClosingCornerBrace(state);
2279
- }
2280
- state.accumulatedContent.concatBuffer(state.decisionBuffer);
2281
- state.decisionBuffer.clear();
2282
- state.sourceCode.next();
2283
- }
2284
- function parseClosingCornerBrace(state) {
2285
- var _a;
2286
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: true });
2287
- const tagName = (_a = state.contextParams[constants_1.TokenizerContextTypes.OpenTagEnd]) === null || _a === void 0 ? void 0 : _a.tagName;
2288
- state.tokens.push({
2289
- type: tokensMap[tagName] || tokensMap.default,
2290
- value: state.accumulatedContent.value() + state.decisionBuffer.value(),
2291
- range: position.range,
2292
- loc: position.loc,
2293
- });
2294
- state.accumulatedContent.clear();
2295
- state.decisionBuffer.clear();
2296
- state.currentContext =
2297
- contextsMap[tagName || "default"] || contextsMap["default"];
2298
- state.sourceCode.next();
2299
- state.contextParams[constants_1.TokenizerContextTypes.OpenTagEnd] = undefined;
2300
- }
2301
- return openTagEnd;
2302
- }
2303
-
2304
- var openTagStart = {};
2305
-
2306
- var hasRequiredOpenTagStart;
2307
-
2308
- function requireOpenTagStart () {
2309
- if (hasRequiredOpenTagStart) return openTagStart;
2310
- hasRequiredOpenTagStart = 1;
2311
- Object.defineProperty(openTagStart, "__esModule", { value: true });
2312
- openTagStart.parse = parse;
2313
- const constants_1 = requireConstants();
2314
- const utils_1 = requireUtils();
2315
- const tokensMap = {
2316
- script: constants_1.TokenTypes.OpenScriptTagStart,
2317
- style: constants_1.TokenTypes.OpenStyleTagStart,
2318
- default: constants_1.TokenTypes.OpenTagStart,
2319
- };
2320
- function parse(chars, state) {
2321
- if (chars.value() === ">" || chars.value() === "/") {
2322
- return parseTagEnd(state);
2323
- }
2324
- if ((0, utils_1.isWhitespace)(chars.value())) {
2325
- return parseWhitespace(state);
2326
- }
2327
- state.accumulatedContent.concatBuffer(state.decisionBuffer);
2328
- state.decisionBuffer.clear();
2329
- state.sourceCode.next();
2330
- }
2331
- function parseWhitespace(state) {
2332
- const tagName = (0, utils_1.parseOpenTagName)(state.accumulatedContent.value());
2333
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2334
- state.tokens.push({
2335
- type: tokensMap[tagName] || tokensMap.default,
2336
- value: state.accumulatedContent.value(),
2337
- range: position.range,
2338
- loc: position.loc,
2339
- });
2340
- state.accumulatedContent.clear();
2341
- state.decisionBuffer.clear();
2342
- state.currentContext = constants_1.TokenizerContextTypes.Attributes;
2343
- state.contextParams[constants_1.TokenizerContextTypes.Attributes] = { tagName };
2344
- state.sourceCode.next();
2345
- }
2346
- function parseTagEnd(state) {
2347
- const tagName = (0, utils_1.parseOpenTagName)(state.accumulatedContent.value());
2348
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2349
- state.tokens.push({
2350
- type: tokensMap[tagName] || tokensMap.default,
2351
- value: state.accumulatedContent.value(),
2352
- range: position.range,
2353
- loc: position.loc,
2354
- });
2355
- state.decisionBuffer.clear();
2356
- state.accumulatedContent.clear();
2357
- state.currentContext = constants_1.TokenizerContextTypes.OpenTagEnd;
2358
- state.contextParams[constants_1.TokenizerContextTypes.OpenTagEnd] = { tagName };
2359
- }
2360
- return openTagStart;
2361
- }
2362
-
2363
- var scriptTagContent = {};
2364
-
2365
- var hasRequiredScriptTagContent;
2366
-
2367
- function requireScriptTagContent () {
2368
- if (hasRequiredScriptTagContent) return scriptTagContent;
2369
- hasRequiredScriptTagContent = 1;
2370
- Object.defineProperty(scriptTagContent, "__esModule", { value: true });
2371
- scriptTagContent.parse = parse;
2372
- const constants_1 = requireConstants();
2373
- const utils_1 = requireUtils();
2374
- const create_templates_1 = requireCreateTemplates();
2375
- function parse(chars, state) {
2376
- if (chars.value() === "<" ||
2377
- chars.value() === "</" ||
2378
- constants_1.INCOMPLETE_CLOSING_TAG_PATTERN.test(chars.value())) {
2379
- state.sourceCode.next();
2380
- return;
2381
- }
2382
- if (constants_1.CLOSING_SCRIPT_TAG_PATTERN.test(chars.value())) {
2383
- return parseClosingScriptTag(state);
2384
- }
2385
- state.accumulatedContent.concatBuffer(state.decisionBuffer);
2386
- state.decisionBuffer.clear();
2387
- state.sourceCode.next();
2388
- }
2389
- function parseClosingScriptTag(state) {
2390
- if (state.accumulatedContent.value() !== "") {
2391
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2392
- state.tokens.push({
2393
- type: constants_1.TokenTypes.ScriptTagContent,
2394
- value: state.accumulatedContent.value(),
2395
- range: position.range,
2396
- loc: position.loc,
2397
- templates: (0, create_templates_1.createTemplates)(state, constants_1.TokenTypes.ScriptTagContent),
2398
- });
2399
- }
2400
- const range = [
2401
- state.sourceCode.index() - (state.decisionBuffer.length() - 1),
2402
- state.sourceCode.index() + 1,
2403
- ];
2404
- state.tokens.push({
2405
- type: constants_1.TokenTypes.CloseScriptTag,
2406
- value: state.decisionBuffer.value(),
2407
- range,
2408
- loc: state.sourceCode.getLocationOf(range),
2409
- });
2410
- state.accumulatedContent.clear();
2411
- state.decisionBuffer.clear();
2412
- state.currentContext = constants_1.TokenizerContextTypes.Data;
2413
- state.sourceCode.next();
2414
- }
2415
- return scriptTagContent;
2416
- }
2417
-
2418
- var styleTagContent = {};
2419
-
2420
- var hasRequiredStyleTagContent;
2421
-
2422
- function requireStyleTagContent () {
2423
- if (hasRequiredStyleTagContent) return styleTagContent;
2424
- hasRequiredStyleTagContent = 1;
2425
- Object.defineProperty(styleTagContent, "__esModule", { value: true });
2426
- styleTagContent.parse = parse;
2427
- const constants_1 = requireConstants();
2428
- const utils_1 = requireUtils();
2429
- const create_templates_1 = requireCreateTemplates();
2430
- const CLOSING_STYLE_TAG_PATTERN = /<\/style\s*>/i;
2431
- function parse(chars, state) {
2432
- if (chars.value() === "<" ||
2433
- chars.value() === "</" ||
2434
- constants_1.INCOMPLETE_CLOSING_TAG_PATTERN.test(chars.value())) {
2435
- state.sourceCode.next();
2436
- return;
2437
- }
2438
- if (CLOSING_STYLE_TAG_PATTERN.test(chars.value())) {
2439
- return parseClosingStyleTag(state);
2440
- }
2441
- state.accumulatedContent.concatBuffer(state.decisionBuffer);
2442
- state.decisionBuffer.clear();
2443
- state.sourceCode.next();
2444
- }
2445
- function parseClosingStyleTag(state) {
2446
- if (state.accumulatedContent.value() !== "") {
2447
- const position = (0, utils_1.calculateTokenPosition)(state, { keepBuffer: false });
2448
- state.tokens.push({
2449
- type: constants_1.TokenTypes.StyleTagContent,
2450
- value: state.accumulatedContent.value(),
2451
- range: position.range,
2452
- loc: position.loc,
2453
- templates: (0, create_templates_1.createTemplates)(state, constants_1.TokenTypes.StyleTagContent),
2454
- });
2455
- }
2456
- const range = [
2457
- state.sourceCode.index() - (state.decisionBuffer.length() - 1),
2458
- state.sourceCode.index() + 1,
2459
- ];
2460
- state.tokens.push({
2461
- type: constants_1.TokenTypes.CloseStyleTag,
2462
- value: state.decisionBuffer.value(),
2463
- range,
2464
- loc: state.sourceCode.getLocationOf(range),
2465
- });
2466
- state.accumulatedContent.clear();
2467
- state.decisionBuffer.clear();
2468
- state.currentContext = constants_1.TokenizerContextTypes.Data;
2469
- state.sourceCode.next();
2470
- }
2471
- return styleTagContent;
2472
- }
2473
-
2474
- var hasRequiredHandlers;
2475
-
2476
- function requireHandlers () {
2477
- if (hasRequiredHandlers) return handlers;
2478
- hasRequiredHandlers = 1;
2479
- var __createBinding = (handlers && handlers.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2480
- if (k2 === undefined) k2 = k;
2481
- var desc = Object.getOwnPropertyDescriptor(m, k);
2482
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2483
- desc = { enumerable: true, get: function() { return m[k]; } };
2484
- }
2485
- Object.defineProperty(o, k2, desc);
2486
- }) : (function(o, m, k, k2) {
2487
- if (k2 === undefined) k2 = k;
2488
- o[k2] = m[k];
2489
- }));
2490
- var __setModuleDefault = (handlers && handlers.__setModuleDefault) || (Object.create ? (function(o, v) {
2491
- Object.defineProperty(o, "default", { enumerable: true, value: v });
2492
- }) : function(o, v) {
2493
- o["default"] = v;
2494
- });
2495
- var __importStar = (handlers && handlers.__importStar) || function (mod) {
2496
- if (mod && mod.__esModule) return mod;
2497
- var result = {};
2498
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2499
- __setModuleDefault(result, mod);
2500
- return result;
2501
- };
2502
- Object.defineProperty(handlers, "__esModule", { value: true });
2503
- handlers.noop = handlers.styleTagContent = handlers.scriptTagContent = handlers.openTagStart = handlers.openTagEnd = handlers.DoctypeOpen = handlers.DoctypeClose = handlers.doctypeAttributes = handlers.doctypeAttributeWrapped = handlers.doctypeAttributeBare = handlers.data = handlers.commentContent = handlers.closeTag = handlers.attributes = handlers.attributeValue = handlers.attributeValueWrapped = handlers.attributeValueBare = handlers.attributeKey = void 0;
2504
- handlers.attributeKey = __importStar(requireAttributeKey());
2505
- handlers.attributeValueBare = __importStar(requireAttributeValueBare());
2506
- handlers.attributeValueWrapped = __importStar(requireAttributeValueWrapped());
2507
- handlers.attributeValue = __importStar(requireAttributeValue());
2508
- handlers.attributes = __importStar(requireAttributes());
2509
- handlers.closeTag = __importStar(requireCloseTag());
2510
- handlers.commentContent = __importStar(requireCommentContent());
2511
- handlers.data = __importStar(requireData());
2512
- handlers.doctypeAttributeBare = __importStar(requireDoctypeAttributeBare());
2513
- handlers.doctypeAttributeWrapped = __importStar(requireDoctypeAttributeWrapped());
2514
- handlers.doctypeAttributes = __importStar(requireDoctypeAttributes());
2515
- handlers.DoctypeClose = __importStar(requireDoctypeEnd());
2516
- handlers.DoctypeOpen = __importStar(requireDoctypeStart());
2517
- handlers.openTagEnd = __importStar(requireOpenTagEnd());
2518
- handlers.openTagStart = __importStar(requireOpenTagStart());
2519
- handlers.scriptTagContent = __importStar(requireScriptTagContent());
2520
- handlers.styleTagContent = __importStar(requireStyleTagContent());
2521
- handlers.noop = {
2522
- parse: () => void 0,
2523
- };
2524
- return handlers;
2525
- }
2526
-
2527
- var sourceCode = {};
2528
-
2529
- var chars = {};
2530
-
2531
- var hasRequiredChars;
2532
-
2533
- function requireChars () {
2534
- if (hasRequiredChars) return chars;
2535
- hasRequiredChars = 1;
2536
- Object.defineProperty(chars, "__esModule", { value: true });
2537
- chars.Chars = void 0;
2538
- class Chars {
2539
- constructor(value, range, isTemplate) {
2540
- this.value = value;
2541
- this.range = range;
2542
- this.isTemplate = isTemplate;
2543
- }
2544
- concat(chars) {
2545
- this.value += chars.value;
2546
- this.range[1] = chars.range[1];
2547
- }
2548
- equals(chars) {
2549
- return this.value === chars;
2550
- }
2551
- length() {
2552
- return this.value.length;
2553
- }
2554
- }
2555
- chars.Chars = Chars;
2556
- return chars;
2557
- }
2558
-
2559
- var hasRequiredSourceCode;
2560
-
2561
- function requireSourceCode () {
2562
- if (hasRequiredSourceCode) return sourceCode;
2563
- hasRequiredSourceCode = 1;
2564
- Object.defineProperty(sourceCode, "__esModule", { value: true });
2565
- sourceCode.SourceCode = void 0;
2566
- const utils_1 = requireUtils();
2567
- const chars_1 = requireChars();
2568
- class SourceCode {
2569
- constructor(source, templateRanges) {
2570
- this.source = source;
2571
- this.charsIndex = 0;
2572
- this.charsList = this.createCharsList(templateRanges);
2573
- }
2574
- getLocationOf(range) {
2575
- return {
2576
- start: (0, utils_1.getLineInfo)(this.source, range[0]),
2577
- end: (0, utils_1.getLineInfo)(this.source, range[1]),
2578
- };
2579
- }
2580
- current() {
2581
- return this.charsList[this.charsIndex];
2582
- }
2583
- next() {
2584
- this.charsIndex++;
2585
- }
2586
- prev() {
2587
- this.charsIndex--;
2588
- }
2589
- isEof() {
2590
- return this.charsIndex >= this.charsList.length;
2591
- }
2592
- index() {
2593
- const current = this.current();
2594
- return current.range[1] - 1;
2595
- }
2596
- createCharsList(templateRanges) {
2597
- const charsList = [];
2598
- let sourceIndex = 0;
2599
- let templateRangeIndex = 0;
2600
- while (sourceIndex < this.source.length) {
2601
- const templateRange = templateRanges[templateRangeIndex];
2602
- if (templateRange &&
2603
- templateRange[0] <= sourceIndex &&
2604
- sourceIndex < templateRange[1]) {
2605
- charsList.push(new chars_1.Chars(this.source.slice(templateRange[0], templateRange[1]), [templateRange[0], templateRange[1]], true));
2606
- templateRangeIndex++;
2607
- sourceIndex = templateRange[1];
2608
- continue;
2609
- }
2610
- charsList.push(new chars_1.Chars(this.source[sourceIndex], [sourceIndex, sourceIndex + 1], false));
2611
- sourceIndex++;
2612
- }
2613
- return charsList;
2614
- }
2615
- }
2616
- sourceCode.SourceCode = SourceCode;
2617
- return sourceCode;
2618
- }
2619
-
2620
- var charsBuffer = {};
2621
-
2622
- var hasRequiredCharsBuffer;
2623
-
2624
- function requireCharsBuffer () {
2625
- if (hasRequiredCharsBuffer) return charsBuffer;
2626
- hasRequiredCharsBuffer = 1;
2627
- Object.defineProperty(charsBuffer, "__esModule", { value: true });
2628
- charsBuffer.CharsBuffer = void 0;
2629
- class CharsBuffer {
2630
- constructor() {
2631
- this.charsBuffer = [];
2632
- }
2633
- concat(chars) {
2634
- const last = this.last();
2635
- if (!last || last.isTemplate || chars.isTemplate) {
2636
- this.charsBuffer.push(chars);
2637
- }
2638
- else {
2639
- last.concat(chars);
2640
- }
2641
- }
2642
- concatBuffer(buffer) {
2643
- const last = this.last();
2644
- const first = buffer.first();
2645
- if ((last === null || last === void 0 ? void 0 : last.isTemplate) === false && (first === null || first === void 0 ? void 0 : first.isTemplate) === false) {
2646
- last.concat(first);
2647
- this.charsBuffer.push(...buffer.charsBuffer.slice(1));
2648
- return;
2649
- }
2650
- this.charsBuffer.push(...buffer.charsBuffer);
2651
- }
2652
- hasTemplate() {
2653
- return this.charsBuffer.some((char) => char.isTemplate);
2654
- }
2655
- getTemplates() {
2656
- return [...this.charsBuffer];
2657
- }
2658
- length() {
2659
- return this.charsBuffer
2660
- .map((chars) => chars.length())
2661
- .reduce((a, b) => a + b, 0);
2662
- }
2663
- clear() {
2664
- this.charsBuffer = [];
2665
- }
2666
- value() {
2667
- const v = this.charsBuffer.map((chars) => chars.value).join("");
2668
- return v;
2669
- }
2670
- last() {
2671
- return this.charsBuffer[this.charsBuffer.length - 1];
2672
- }
2673
- first() {
2674
- return this.charsBuffer[0];
2675
- }
2676
- removeLast() {
2677
- this.charsBuffer.splice(this.charsBuffer.length - 1, 1);
2678
- }
2679
- removeFirst() {
2680
- this.charsBuffer.splice(0, 1);
2681
- }
2682
- replace(other) {
2683
- this.charsBuffer = [...other.charsBuffer];
2684
- }
2685
- }
2686
- charsBuffer.CharsBuffer = CharsBuffer;
2687
- return charsBuffer;
2688
- }
2689
-
2690
- var hasRequiredTokenize;
2691
-
2692
- function requireTokenize () {
2693
- if (hasRequiredTokenize) return tokenize;
2694
- hasRequiredTokenize = 1;
2695
- Object.defineProperty(tokenize, "__esModule", { value: true });
2696
- tokenize.tokenize = tokenize$1;
2697
- const constants_1 = requireConstants();
2698
- const handlers_1 = requireHandlers();
2699
- const source_code_1 = requireSourceCode();
2700
- const chars_buffer_1 = requireCharsBuffer();
2701
- const contextHandlers = {
2702
- [constants_1.TokenizerContextTypes.Data]: handlers_1.data,
2703
- [constants_1.TokenizerContextTypes.OpenTagStart]: handlers_1.openTagStart,
2704
- [constants_1.TokenizerContextTypes.CloseTag]: handlers_1.closeTag,
2705
- [constants_1.TokenizerContextTypes.Attributes]: handlers_1.attributes,
2706
- [constants_1.TokenizerContextTypes.OpenTagEnd]: handlers_1.openTagEnd,
2707
- [constants_1.TokenizerContextTypes.AttributeKey]: handlers_1.attributeKey,
2708
- [constants_1.TokenizerContextTypes.AttributeValue]: handlers_1.attributeValue,
2709
- [constants_1.TokenizerContextTypes.AttributeValueBare]: handlers_1.attributeValueBare,
2710
- [constants_1.TokenizerContextTypes.AttributeValueWrapped]: handlers_1.attributeValueWrapped,
2711
- [constants_1.TokenizerContextTypes.ScriptContent]: handlers_1.scriptTagContent,
2712
- [constants_1.TokenizerContextTypes.StyleContent]: handlers_1.styleTagContent,
2713
- [constants_1.TokenizerContextTypes.DoctypeOpen]: handlers_1.DoctypeOpen,
2714
- [constants_1.TokenizerContextTypes.DoctypeClose]: handlers_1.DoctypeClose,
2715
- [constants_1.TokenizerContextTypes.DoctypeAttributes]: handlers_1.doctypeAttributes,
2716
- [constants_1.TokenizerContextTypes.DoctypeAttributeWrapped]: handlers_1.doctypeAttributeWrapped,
2717
- [constants_1.TokenizerContextTypes.DoctypeAttributeBare]: handlers_1.doctypeAttributeBare,
2718
- [constants_1.TokenizerContextTypes.CommentContent]: handlers_1.commentContent,
2719
- [constants_1.TokenizerContextTypes.CommentOpen]: handlers_1.noop,
2720
- [constants_1.TokenizerContextTypes.CommentClose]: handlers_1.noop,
2721
- };
2722
- function tokenizeChars(state) {
2723
- while (!state.sourceCode.isEof()) {
2724
- const handler = contextHandlers[state.currentContext];
2725
- state.decisionBuffer.concat(state.sourceCode.current());
2726
- handler.parse(state.decisionBuffer, state);
2727
- }
2728
- const handler = contextHandlers[state.currentContext];
2729
- state.sourceCode.prev();
2730
- if (handler.handleContentEnd !== undefined) {
2731
- handler.handleContentEnd(state);
2732
- }
2733
- }
2734
- function tokenize$1(source = "", tokenAdapter, templateRanges) {
2735
- const tokens = [];
2736
- const state = {
2737
- currentContext: constants_1.TokenizerContextTypes.Data,
2738
- contextParams: {},
2739
- mode: templateRanges ? "template" : "default",
2740
- templateRanges: templateRanges || [],
2741
- decisionBuffer: new chars_buffer_1.CharsBuffer(),
2742
- accumulatedContent: new chars_buffer_1.CharsBuffer(),
2743
- tokenAdapter,
2744
- sourceCode: new source_code_1.SourceCode(source, templateRanges || []),
2745
- tokens: {
2746
- push(token) {
2747
- tokens.push(Object.assign(Object.assign({}, token), { range: tokenAdapter.finalizeRange(token), loc: tokenAdapter.finalizeLocation(token) }));
2748
- },
2749
- },
2750
- };
2751
- tokenizeChars(state);
2752
- return { state, tokens };
2753
- }
2754
- return tokenize;
2755
- }
2756
-
2757
- var hasRequiredTokenizer;
2758
-
2759
- function requireTokenizer () {
2760
- if (hasRequiredTokenizer) return tokenizer;
2761
- hasRequiredTokenizer = 1;
2762
- (function (exports) {
2763
- Object.defineProperty(exports, "__esModule", { value: true });
2764
- exports.tokenize = void 0;
2765
- var tokenize_1 = requireTokenize();
2766
- Object.defineProperty(exports, "tokenize", { enumerable: true, get: function () { return tokenize_1.tokenize; } });
2767
- } (tokenizer));
2768
- return tokenizer;
2769
- }
2770
-
2771
- var tokenAdapter = {};
2772
-
2773
- var defaultTokenAdapter = {};
2774
-
2775
- var hasRequiredDefaultTokenAdapter;
2776
-
2777
- function requireDefaultTokenAdapter () {
2778
- if (hasRequiredDefaultTokenAdapter) return defaultTokenAdapter;
2779
- hasRequiredDefaultTokenAdapter = 1;
2780
- Object.defineProperty(defaultTokenAdapter, "__esModule", { value: true });
2781
- defaultTokenAdapter.defaultTokenAdapter = void 0;
2782
- defaultTokenAdapter.defaultTokenAdapter = {
2783
- finalizeRange(token) {
2784
- return token.range;
2785
- },
2786
- finalizeLocation(token) {
2787
- return token.loc;
2788
- },
2789
- };
2790
- return defaultTokenAdapter;
2791
- }
2792
-
2793
- var hasRequiredTokenAdapter;
2794
-
2795
- function requireTokenAdapter () {
2796
- if (hasRequiredTokenAdapter) return tokenAdapter;
2797
- hasRequiredTokenAdapter = 1;
2798
- (function (exports) {
2799
- Object.defineProperty(exports, "__esModule", { value: true });
2800
- exports.defaultTokenAdapter = void 0;
2801
- var default_token_adapter_1 = requireDefaultTokenAdapter();
2802
- Object.defineProperty(exports, "defaultTokenAdapter", { enumerable: true, get: function () { return default_token_adapter_1.defaultTokenAdapter; } });
2803
- } (tokenAdapter));
2804
- return tokenAdapter;
2805
- }
2806
-
2807
- var hasRequiredParse;
2808
-
2809
- function requireParse () {
2810
- if (hasRequiredParse) return parse;
2811
- hasRequiredParse = 1;
2812
- Object.defineProperty(parse, "__esModule", { value: true });
2813
- parse.parse = parse$1;
2814
- const tree_constructor_1 = requireTreeConstructor();
2815
- const tokenizer_1 = requireTokenizer();
2816
- const utils_1 = requireUtils();
2817
- const token_adapter_1 = requireTokenAdapter();
2818
- function parse$1(html, options) {
2819
- const tokenAdapter = (options && options.tokenAdapter) || token_adapter_1.defaultTokenAdapter;
2820
- const { tokens } = (0, tokenizer_1.tokenize)(html, tokenAdapter, options === null || options === void 0 ? void 0 : options.templateRanges);
2821
- const { ast } = (0, tree_constructor_1.constructTree)(tokens);
2822
- return {
2823
- ast: (0, utils_1.clearParent)(ast),
2824
- tokens,
2825
- };
2826
- }
2827
- return parse;
2828
- }
2829
-
2830
- var hasRequiredParser$2;
2831
-
2832
- function requireParser$2 () {
2833
- if (hasRequiredParser$2) return parser$1;
2834
- hasRequiredParser$2 = 1;
2835
- (function (exports) {
2836
- var __createBinding = (parser$1 && parser$1.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2837
- if (k2 === undefined) k2 = k;
2838
- var desc = Object.getOwnPropertyDescriptor(m, k);
2839
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2840
- desc = { enumerable: true, get: function() { return m[k]; } };
2841
- }
2842
- Object.defineProperty(o, k2, desc);
2843
- }) : (function(o, m, k, k2) {
2844
- if (k2 === undefined) k2 = k;
2845
- o[k2] = m[k];
2846
- }));
2847
- var __exportStar = (parser$1 && parser$1.__exportStar) || function(m, exports) {
2848
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2849
- };
2850
- Object.defineProperty(exports, "__esModule", { value: true });
2851
- __exportStar(requireParse(), exports);
2852
- } (parser$1));
2853
- return parser$1;
2854
- }
2855
-
2856
- var node$1 = {};
2857
-
2858
- var hasRequiredNode$1;
2859
-
2860
- function requireNode$1 () {
2861
- if (hasRequiredNode$1) return node$1;
2862
- hasRequiredNode$1 = 1;
2863
- Object.defineProperty(node$1, "__esModule", { value: true });
2864
- return node$1;
2865
- }
2866
-
2867
- var hasRequiredDist;
2868
-
2869
- function requireDist () {
2870
- if (hasRequiredDist) return dist;
2871
- hasRequiredDist = 1;
2872
- (function (exports) {
2873
- var __createBinding = (dist && dist.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2874
- if (k2 === undefined) k2 = k;
2875
- var desc = Object.getOwnPropertyDescriptor(m, k);
2876
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2877
- desc = { enumerable: true, get: function() { return m[k]; } };
2878
- }
2879
- Object.defineProperty(o, k2, desc);
2880
- }) : (function(o, m, k, k2) {
2881
- if (k2 === undefined) k2 = k;
2882
- o[k2] = m[k];
2883
- }));
2884
- var __exportStar = (dist && dist.__exportStar) || function(m, exports) {
2885
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2886
- };
2887
- Object.defineProperty(exports, "__esModule", { value: true });
2888
- exports.TokenTypes = exports.NodeTypes = exports.parse = void 0;
2889
- var parser_1 = requireParser$2();
2890
- Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parser_1.parse; } });
2891
- var constants_1 = requireConstants();
2892
- Object.defineProperty(exports, "NodeTypes", { enumerable: true, get: function () { return constants_1.NodeTypes; } });
2893
- Object.defineProperty(exports, "TokenTypes", { enumerable: true, get: function () { return constants_1.TokenTypes; } });
2894
- __exportStar(requireNode$1(), exports);
2895
- } (dist));
2896
- return dist;
2897
- }
2898
-
2899
- var nodeTypes;
2900
- var hasRequiredNodeTypes;
2901
-
2902
- function requireNodeTypes () {
2903
- if (hasRequiredNodeTypes) return nodeTypes;
2904
- hasRequiredNodeTypes = 1;
2905
- const { NodeTypes } = requireDist();
2906
-
2907
- const NODE_TYPES = NodeTypes;
2908
-
2909
- nodeTypes = {
2910
- NODE_TYPES,
2911
- };
2912
- return nodeTypes;
2913
- }
2914
-
2915
- var visitorKeys_1;
2916
- var hasRequiredVisitorKeys;
2917
-
2918
- function requireVisitorKeys () {
2919
- if (hasRequiredVisitorKeys) return visitorKeys_1;
2920
- hasRequiredVisitorKeys = 1;
2921
- const { NODE_TYPES } = requireNodeTypes();
2922
-
2923
- const visitorKeys = {
2924
- Program: ["body"],
2925
- [NODE_TYPES.Document]: ["children"],
2926
- [NODE_TYPES.Attribute]: ["key", "startWrapper", "endWrapper", "value"],
2927
- [NODE_TYPES.AttributeKey]: [],
2928
- [NODE_TYPES.AttributeValue]: [],
2929
- [NODE_TYPES.AttributeValueWrapperEnd]: [],
2930
- [NODE_TYPES.AttributeValueWrapperStart]: [],
2931
- [NODE_TYPES.CloseScriptTag]: [],
2932
- [NODE_TYPES.CloseStyleTag]: [],
2933
- [NODE_TYPES.CloseTag]: [],
2934
- [NODE_TYPES.Comment]: ["open", "close", "value"],
2935
- [NODE_TYPES.CommentContent]: [],
2936
- [NODE_TYPES.CommentOpen]: [],
2937
- [NODE_TYPES.CommentClose]: [],
2938
- [NODE_TYPES.Doctype]: ["open", "close", "attributes"],
2939
- [NODE_TYPES.DoctypeAttribute]: ["startWrapper", "value", "endWrapper"],
2940
- [NODE_TYPES.DoctypeAttributeValue]: [],
2941
- [NODE_TYPES.DoctypeAttributeWrapperEnd]: [],
2942
- [NODE_TYPES.DoctypeAttributeWrapperStart]: [],
2943
- [NODE_TYPES.DoctypeOpen]: [],
2944
- [NODE_TYPES.DoctypeClose]: [],
2945
- [NODE_TYPES.OpenScriptTagEnd]: [],
2946
- [NODE_TYPES.OpenScriptTagStart]: [],
2947
- [NODE_TYPES.OpenStyleTagEnd]: [],
2948
- [NODE_TYPES.OpenStyleTagStart]: [],
2949
- [NODE_TYPES.OpenTagEnd]: [],
2950
- [NODE_TYPES.OpenTagStart]: [],
2951
- [NODE_TYPES.ScriptTag]: [
2952
- "attributes",
2953
- "openStart",
2954
- "openEnd",
2955
- "close",
2956
- "value",
2957
- ],
2958
- [NODE_TYPES.ScriptTagContent]: [],
2959
- [NODE_TYPES.StyleTag]: [
2960
- "attributes",
2961
- "openStart",
2962
- "openEnd",
2963
- "close",
2964
- "value",
2965
- ],
2966
- [NODE_TYPES.StyleTagContent]: [],
2967
- [NODE_TYPES.Tag]: ["openStart", "openEnd", "close", "children", "attributes"],
2968
- [NODE_TYPES.Text]: [],
2969
- };
2970
-
2971
- visitorKeys_1 = {
2972
- visitorKeys,
2973
- };
2974
- return visitorKeys_1;
2975
- }
2976
-
2977
- /**
2978
- * @typedef {import("./types").AnyHTMLNode} AnyHTMLNode
2979
- */
2980
-
2981
- var traverse_1;
2982
- var hasRequiredTraverse;
2983
-
2984
- function requireTraverse () {
2985
- if (hasRequiredTraverse) return traverse_1;
2986
- hasRequiredTraverse = 1;
2987
- const { visitorKeys } = requireVisitorKeys();
2988
-
2989
- /**
2990
- *
2991
- * @param {AnyHTMLNode} node
2992
- * @param {(arg: AnyHTMLNode) => void} visitor
2993
- * @returns {void}
2994
- */
2995
- function traverse(node, visitor) {
2996
- if (!node) {
2997
- return;
2998
- }
2999
- visitor(node);
3000
- const type = node.type;
3001
- const keys = visitorKeys[type];
3002
-
3003
- if (!keys || keys.length <= 0) {
3004
- return;
3005
- }
3006
-
3007
- keys.forEach((key) => {
3008
- // @ts-ignore
3009
- const value = node[key];
3010
- if (value) {
3011
- if (Array.isArray(value)) {
3012
- value.forEach((n) => traverse(n, visitor));
3013
- } else {
3014
- traverse(value, visitor);
3015
- }
3016
- }
3017
- });
3018
- }
3019
-
3020
- traverse_1 = {
3021
- traverse,
3022
- };
3023
- return traverse_1;
3024
- }
3025
-
3026
- /**
3027
- * @typedef {import("./types").TemplateSyntax} TemplateSyntax
3028
- * @typedef {import("./types").Range} Range
3029
- * @typedef {import("./types").OpenSyntax} OpenSyntax
3030
- * @typedef {import("./types").CloseSyntax} CloseSyntax
3031
- * @typedef {import("./types").TemplateSyntaxParserResult} TemplateSyntaxParserResult
3032
- *
3033
- */
3034
-
3035
- var parser;
3036
- var hasRequiredParser$1;
3037
-
3038
- function requireParser$1 () {
3039
- if (hasRequiredParser$1) return parser;
3040
- hasRequiredParser$1 = 1;
3041
- parser = class Parser {
3042
- /**
3043
- * @param {string} code
3044
- * @param {[string, string][]} syntaxPairs
3045
- * @param {Range[]} skipRanges
3046
- */
3047
- constructor(code, syntaxPairs, skipRanges) {
3048
- /**
3049
- * @type {string}
3050
- */
3051
- this.code = code;
3052
- /**
3053
- * @type {[string, string][]}
3054
- */
3055
- this.syntaxPairs = syntaxPairs || [];
3056
- /**
3057
- * @type {Range[]}
3058
- */
3059
- this.skipRanges = skipRanges;
3060
- /**
3061
- * @type {OpenSyntax[]}
3062
- */
3063
- this.syntaxStack = [];
3064
- /**
3065
- * @type {TemplateSyntax[]}
3066
- */
3067
- this.result = [];
3068
- }
3069
-
3070
- /**
3071
- * @private
3072
- * @param {number} index
3073
- * @returns {Range | undefined}
3074
- */
3075
- findSkipRange(index) {
3076
- return this.skipRanges.find(
3077
- (range) => range[0] <= index && index < range[1]
3078
- );
3079
- }
3080
-
3081
- /**
3082
- * @param {string} syntax
3083
- * @param {number} position
3084
- * @returns {number}
3085
- */
3086
- indexOf(syntax, position) {
3087
- const index = this.code.indexOf(syntax, position);
3088
- if (index < 0) return index;
3089
- const skipRange = this.findSkipRange(index);
3090
- if (skipRange) {
3091
- return this.indexOf(syntax, skipRange[1]);
3092
- }
3093
- return index;
3094
- }
3095
-
3096
- /**
3097
- * @param {number} position
3098
- * @returns {OpenSyntax | null}
3099
- */
3100
- findOpenSyntax(position) {
3101
- /**
3102
- * @type {string | null}
3103
- */
3104
- let value = null;
3105
- let rangeStart = Infinity;
3106
- for (let i = 0; i < this.syntaxPairs.length; i++) {
3107
- const [open] = this.syntaxPairs[i];
3108
- const openIndex = this.indexOf(open, position);
3109
- if (openIndex >= 0 && openIndex < rangeStart) {
3110
- value = open;
3111
- rangeStart = openIndex;
3112
- }
3113
- }
3114
- if (!value) return null;
3115
- return {
3116
- type: "open",
3117
- value,
3118
- range: [rangeStart, rangeStart + value.length],
3119
- };
3120
- }
3121
-
3122
- /**
3123
- * @param {number} position
3124
- * @returns {CloseSyntax | null}
3125
- */
3126
- findCloseSyntax(position) {
3127
- /**
3128
- * @type {string | null}
3129
- */
3130
- let value = null;
3131
- let rangeStart = Infinity;
3132
- for (let i = 0; i < this.syntaxPairs.length; i++) {
3133
- const [, close] = this.syntaxPairs[i];
3134
- const closeIndex = this.indexOf(close, position);
3135
- if (closeIndex >= 0 && closeIndex < rangeStart) {
3136
- value = close;
3137
- rangeStart = closeIndex;
3138
- }
3139
- }
3140
- if (!value) return null;
3141
- return {
3142
- type: "close",
3143
- value,
3144
- range: [rangeStart, rangeStart + value.length],
3145
- };
3146
- }
3147
-
3148
- /**
3149
- * @returns {OpenSyntax[]}
3150
- */
3151
- findAllOpenSyntax() {
3152
- /**
3153
- * @type {OpenSyntax[]}
3154
- */
3155
- const result = [];
3156
- let position = 0;
3157
-
3158
- while (position < this.code.length) {
3159
- const openSyntax = this.findOpenSyntax(position);
3160
- if (!openSyntax) {
3161
- break;
3162
- }
3163
- result.push(openSyntax);
3164
- position = openSyntax.range[1];
3165
- }
3166
-
3167
- return result;
3168
- }
3169
-
3170
- /**
3171
- * @returns {CloseSyntax[]}
3172
- */
3173
- findAllCloseSyntax() {
3174
- /**
3175
- * @type {CloseSyntax[]}
3176
- */
3177
- const result = [];
3178
- let position = 0;
3179
-
3180
- while (position < this.code.length) {
3181
- const closeSyntax = this.findCloseSyntax(position);
3182
- if (!closeSyntax) {
3183
- break;
3184
- }
3185
- result.push(closeSyntax);
3186
- position = closeSyntax.range[1];
3187
- }
3188
-
3189
- return result;
3190
- }
3191
-
3192
- /**
3193
- * @returns {(CloseSyntax | OpenSyntax)[]}
3194
- */
3195
- findAllSyntax() {
3196
- return this.findAllOpenSyntax()
3197
- .concat(this.findAllCloseSyntax())
3198
- .sort((a, b) => a.range[0] - b.range[0]);
3199
- }
3200
-
3201
- /**
3202
- * @param {OpenSyntax} open
3203
- * @returns {string}
3204
- */
3205
- getPossibleCloseValueOf(open) {
3206
- return this.syntaxPairs.find((syntax) => syntax[0] === open.value)[1];
3207
- }
3208
-
3209
- /**
3210
- * @param {CloseSyntax | OpenSyntax} syntax
3211
- */
3212
- eatSyntax(syntax) {
3213
- if (syntax.type === "open") {
3214
- const top = this.syntaxStack.pop();
3215
- if (!top) {
3216
- this.syntaxStack.push(syntax);
3217
- } else {
3218
- throw new Error(
3219
- `Expecting "${this.getPossibleCloseValueOf(top)}", but found "${
3220
- syntax.value
3221
- }" at (${syntax.range[0]}, ${syntax.range[1]}).`
3222
- );
3223
- }
3224
- } else if (syntax.type === "close") {
3225
- const top = this.syntaxStack.pop();
3226
- if (!top) {
3227
- return;
3228
- } else if (this.getPossibleCloseValueOf(top) === syntax.value) {
3229
- this.result.push({
3230
- open: top.value,
3231
- close: syntax.value,
3232
- range: [top.range[0], syntax.range[1]],
3233
- });
3234
- }
3235
- }
3236
- }
3237
-
3238
- /**
3239
- * @returns {TemplateSyntaxParserResult}
3240
- */
3241
- parse() {
3242
- for (const syntax of this.findAllSyntax()) {
3243
- this.eatSyntax(syntax);
3244
- }
3245
- return {
3246
- syntax: this.result,
3247
- };
3248
- }
3249
- };
3250
- return parser;
3251
- }
3252
-
3253
- /**
3254
- * @typedef {import("./types").TemplateSyntaxParserConfig} TemplateSyntaxParserConfig
3255
- */
3256
-
3257
- var templateSyntaxParser;
3258
- var hasRequiredTemplateSyntaxParser;
3259
-
3260
- function requireTemplateSyntaxParser () {
3261
- if (hasRequiredTemplateSyntaxParser) return templateSyntaxParser;
3262
- hasRequiredTemplateSyntaxParser = 1;
3263
- const Parser = requireParser$1();
3264
-
3265
- /**
3266
- * @param {string} code
3267
- * @param {TemplateSyntaxParserConfig} config
3268
- */
3269
- function parse(code, config) {
3270
- const syntaxPairs = Object.entries(config.syntax) || [];
3271
- syntaxPairs.sort((syntaxA, syntaxB) => syntaxB[0].length - syntaxA[0].length);
3272
- const parser = new Parser(code, syntaxPairs, config.skipRanges || []);
3273
- return parser.parse();
3274
- }
3275
-
3276
- templateSyntaxParser = {
3277
- parse,
3278
- };
3279
- return templateSyntaxParser;
3280
- }
3281
-
3282
- var lib;
3283
- var hasRequiredLib$1;
3284
-
3285
- function requireLib$1 () {
3286
- if (hasRequiredLib$1) return lib;
3287
- hasRequiredLib$1 = 1;
3288
- const { parse } = requireTemplateSyntaxParser();
3289
- lib = {
3290
- parse,
3291
- };
3292
- return lib;
3293
- }
3294
-
3295
- /**
3296
- * @typedef {import("./types").ParserOptions} ParserOptions
3297
- */
3298
-
3299
- var hasRequiredParser;
3300
-
3301
- function requireParser () {
3302
- if (hasRequiredParser) return parser$2;
3303
- hasRequiredParser = 1;
3304
- const { parse } = requireDist();
3305
- const { visitorKeys } = requireVisitorKeys();
3306
- const { traverse } = requireTraverse();
3307
- const { NODE_TYPES } = requireNodeTypes();
3308
- const templateSyntaxParser = requireLib$1();
3309
-
3310
- /**
3311
- * @param {string} code
3312
- * @param {ParserOptions | undefined} parserOptions
3313
- * @returns {any}
3314
- */
3315
- parser$2.parseForESLint = function parseForESLint(code, parserOptions) {
3316
- const options =
3317
- (parserOptions &&
3318
- parserOptions.templateEngineSyntax && {
3319
- templateRanges: templateSyntaxParser
3320
- .parse(code, {
3321
- syntax: parserOptions.templateEngineSyntax,
3322
- })
3323
- .syntax.map((s) => s.range),
3324
- }) ||
3325
- undefined;
3326
-
3327
- const { ast, tokens } = parse(code, options);
3328
-
3329
- const programNode = {
3330
- type: "Program",
3331
- body: [ast],
3332
- loc: ast.loc,
3333
- range: ast.range,
3334
- tokens: tokens.filter(
3335
- (token) =>
3336
- token.type !== NODE_TYPES.CommentContent &&
3337
- token.type !== NODE_TYPES.CommentOpen &&
3338
- token.type !== NODE_TYPES.CommentClose
3339
- ),
3340
- comments: [],
3341
- };
3342
-
3343
- traverse(programNode, (node) => {
3344
- if (node.type === NODE_TYPES.CommentContent) {
3345
- programNode.comments.push({
3346
- type: node.type,
3347
- range: node.range,
3348
- loc: node.loc,
3349
- value: node.value,
3350
- });
3351
- }
3352
- });
3353
-
3354
- return {
3355
- ast: programNode,
3356
- visitorKeys,
3357
- scopeManager: null,
3358
- };
3359
- };
3360
- return parser$2;
3361
- }
3362
-
3363
- var name = "@html-eslint/parser";
3364
- var version = "0.34.0";
3365
- var description = "Parser for @html-eslint/eslint-plugin";
3366
- var author = "yeonjuan";
3367
- var homepage = "https://github.com/yeonjuan/html-eslint#readme";
3368
- var license = "MIT";
3369
- var main = "lib/index.js";
3370
- var types = "types/lib/index.d.ts";
3371
- var directories = {
3372
- lib: "lib",
3373
- types: "types",
3374
- test: "__tests__"
1
+ "use strict";
2
+ module.exports = {
3
+ rules: {
4
+ "enforce-bem-class": require('./rules/enforce-bem-class'),
5
+ "no-deprecated-slds-classes": require('./rules/no-deprecated-slds-classes'),
6
+ "modal-close-button-issue": require('./rules/modal-close-button-issue')
7
+ },
8
+ configs: {
9
+ recommended: {
10
+ parser: "@html-eslint/parser", // Use HTML parser
11
+ plugins: ["slds"],
12
+ rules: {
13
+ "slds/enforce-bem-class": "error",
14
+ "slds/no-deprecated-slds-classes": "error",
15
+ "slds/modal-close-button-issue": "error"
16
+ },
17
+ },
18
+ },
3375
19
  };
3376
- var files = [
3377
- "lib",
3378
- "types"
3379
- ];
3380
- var publishConfig = {
3381
- access: "public"
3382
- };
3383
- var repository = {
3384
- type: "git",
3385
- url: "git+https://github.com/yeonjuan/html-eslint.git"
3386
- };
3387
- var scripts = {
3388
- test: "jest --coverage --updateSnapshot --passWithNoTests",
3389
- ts: "tsc --noEmit",
3390
- build: "tsc -p ./tsconfig.build.json"
3391
- };
3392
- var engines = {
3393
- node: ">=8.10.0"
3394
- };
3395
- var bugs = {
3396
- url: "https://github.com/yeonjuan/html-eslint/issues"
3397
- };
3398
- var dependencies = {
3399
- "@html-eslint/template-syntax-parser": "^0.34.0",
3400
- "es-html-parser": "^1.0.0-alpha.4"
3401
- };
3402
- var devDependencies = {
3403
- typescript: "^5.7.2"
3404
- };
3405
- var gitHead = "f0401cc30d1510d6f5c7511280c0a6b9779fea0c";
3406
- var require$$0 = {
3407
- name: name,
3408
- version: version,
3409
- description: description,
3410
- author: author,
3411
- homepage: homepage,
3412
- license: license,
3413
- main: main,
3414
- types: types,
3415
- directories: directories,
3416
- files: files,
3417
- publishConfig: publishConfig,
3418
- repository: repository,
3419
- scripts: scripts,
3420
- engines: engines,
3421
- bugs: bugs,
3422
- dependencies: dependencies,
3423
- devDependencies: devDependencies,
3424
- gitHead: gitHead
3425
- };
3426
-
3427
- var meta;
3428
- var hasRequiredMeta;
3429
-
3430
- function requireMeta () {
3431
- if (hasRequiredMeta) return meta;
3432
- hasRequiredMeta = 1;
3433
- const { name, version } = require$$0;
3434
- meta = { name, version };
3435
- return meta;
3436
- }
3437
-
3438
- var templateEngineSyntaxPreset;
3439
- var hasRequiredTemplateEngineSyntaxPreset;
3440
-
3441
- function requireTemplateEngineSyntaxPreset () {
3442
- if (hasRequiredTemplateEngineSyntaxPreset) return templateEngineSyntaxPreset;
3443
- hasRequiredTemplateEngineSyntaxPreset = 1;
3444
- const HANDLEBAR = {
3445
- "{{": "}}",
3446
- };
3447
- const TWIG = {
3448
- "{{": "}}",
3449
- "{%": "%}",
3450
- "{#": "#}",
3451
- };
3452
- const ERB = {
3453
- "<%": "%>",
3454
- };
3455
-
3456
- templateEngineSyntaxPreset = {
3457
- HANDLEBAR,
3458
- TWIG,
3459
- ERB,
3460
- };
3461
- return templateEngineSyntaxPreset;
3462
- }
3463
-
3464
- var hasRequiredLib;
3465
-
3466
- function requireLib () {
3467
- if (hasRequiredLib) return lib$1.exports;
3468
- hasRequiredLib = 1;
3469
- const { parseForESLint } = requireParser();
3470
- const meta = requireMeta();
3471
- const { NODE_TYPES } = requireNodeTypes();
3472
- const TEMPLATE_ENGINE_SYNTAX = requireTemplateEngineSyntaxPreset();
3473
-
3474
- lib$1.exports.parseForESLint = parseForESLint;
3475
- lib$1.exports.NODE_TYPES = NODE_TYPES;
3476
-
3477
- lib$1.exports = {
3478
- TEMPLATE_ENGINE_SYNTAX,
3479
- parseForESLint,
3480
- NODE_TYPES,
3481
- meta,
3482
- };
3483
- return lib$1.exports;
3484
- }
3485
-
3486
- var node;
3487
- var hasRequiredNode;
3488
-
3489
- function requireNode () {
3490
- if (hasRequiredNode) return node;
3491
- hasRequiredNode = 1;
3492
- // THIS IS TAKEN FROM html-eslint
3493
-
3494
- const { NODE_TYPES } = requireLib();
3495
-
3496
- /**
3497
- * @param {TagNode | ScriptTagNode | StyleTagNode} node
3498
- * @param {string} key
3499
- * @returns {AttributeNode | undefined}
3500
- */
3501
- function findAttr(node, key) {
3502
- return node.attributes.find(
3503
- (attr) => attr.key && attr.key.value.toLowerCase() === key.toLowerCase()
3504
- );
3505
- }
3506
-
3507
- /**
3508
- * Checks whether a node's attributes is empty or not.
3509
- * @param {TagNode | ScriptTagNode | StyleTagNode} node
3510
- * @returns {boolean}
3511
- */
3512
- function isAttributesEmpty(node) {
3513
- return !node.attributes || node.attributes.length <= 0;
3514
- }
3515
-
3516
- /**
3517
- * Checks whether a node's all tokens are on the same line or not.
3518
- * @param {AnyNode} node A node to check
3519
- * @returns {boolean} `true` if a node's tokens are on the same line, otherwise `false`.
3520
- */
3521
- function isNodeTokensOnSameLine(node) {
3522
- return node.loc.start.line === node.loc.end.line;
3523
- }
3524
-
3525
- /**
3526
- *
3527
- * @param {Range} rangeA
3528
- * @param {Range} rangeB
3529
- * @returns {boolean}
3530
- */
3531
- function isRangesOverlap(rangeA, rangeB) {
3532
- return rangeA[0] < rangeB[1] && rangeB[0] < rangeA[1];
3533
- }
3534
-
3535
- /**
3536
- * @param {(TextNode | CommentContentNode)['templates']} templates
3537
- * @param {Range} range
3538
- * @returns {boolean}
3539
- */
3540
- function isOverlapWithTemplates(templates, range) {
3541
- return templates
3542
- .filter((template) => template.isTemplate)
3543
- .some((template) => isRangesOverlap(template.range, range));
3544
- }
3545
-
3546
- /**
3547
- *
3548
- * @param {TextNode | CommentContentNode} node
3549
- * @returns {LineNode[]}
3550
- */
3551
- function splitToLineNodes(node) {
3552
- let start = node.range[0];
3553
- let line = node.loc.start.line;
3554
- const startCol = node.loc.start.column;
3555
- /**
3556
- * @type {LineNode[]}
3557
- */
3558
- const lineNodes = [];
3559
- const templates = node.templates || [];
3560
- /**
3561
- *
3562
- * @param {import("../../types").Range} range
3563
- */
3564
- function shouldSkipIndentCheck(range) {
3565
- const overlappedTemplates = templates.filter(
3566
- (template) =>
3567
- template.isTemplate && isRangesOverlap(template.range, range)
3568
- );
3569
-
3570
- const isLineInTemplate = overlappedTemplates.some((template) => {
3571
- return template.range[0] <= range[0] && template.range[1] >= range[1];
3572
- });
3573
- if (isLineInTemplate) {
3574
- return true;
3575
- }
3576
- const isLineBeforeTemplate = overlappedTemplates.some((template) => {
3577
- return template.range[0] <= range[0] && template.range[1] <= range[1];
3578
- });
3579
- if (isLineBeforeTemplate) {
3580
- return true;
3581
- }
3582
- const isLineAfterTemplate = overlappedTemplates.some((template) => {
3583
- return template.range[1] <= range[0];
3584
- });
3585
- if (isLineAfterTemplate) {
3586
- return true;
3587
- }
3588
- return false;
3589
- }
3590
-
3591
- node.value.split("\n").forEach((value, index) => {
3592
- const columnStart = index === 0 ? startCol : 0;
3593
- /**
3594
- * @type {import("../../types").Range}
3595
- */
3596
- const range = [start, start + value.length];
3597
- const loc = {
3598
- start: {
3599
- line,
3600
- column: columnStart,
3601
- },
3602
- end: {
3603
- line,
3604
- column: columnStart + value.length,
3605
- },
3606
- };
3607
- /**
3608
- * @type {LineNode}
3609
- */
3610
- const lineNode = {
3611
- type: "Line",
3612
- value,
3613
- range,
3614
- loc,
3615
- skipIndentCheck: shouldSkipIndentCheck(range),
3616
- };
3617
-
3618
- start += value.length + 1;
3619
- line += 1;
3620
-
3621
- lineNodes.push(lineNode);
3622
- });
3623
-
3624
- return lineNodes;
3625
- }
3626
-
3627
- /**
3628
- * Get location between two nodes.
3629
- * @param {BaseNode} before A node placed in before
3630
- * @param {BaseNode} after A node placed in after
3631
- * @returns {Location} location between two nodes.
3632
- */
3633
- function getLocBetween(before, after) {
3634
- return {
3635
- start: before.loc.end,
3636
- end: after.loc.start,
3637
- };
3638
- }
3639
-
3640
- /**
3641
- * @param {AttributeValueNode} node
3642
- * @return {boolean}
3643
- */
3644
- function isExpressionInTemplate(node) {
3645
- if (node.type === NODE_TYPES.AttributeValue) {
3646
- return node.value.indexOf("${") === 0;
3647
- }
3648
- return false;
3649
- }
3650
-
3651
- /**
3652
- * @param {AnyNode} node
3653
- * @returns {node is TagNode}
3654
- */
3655
- function isTag(node) {
3656
- return node.type === NODE_TYPES.Tag;
3657
- }
3658
-
3659
- /**
3660
- * @param {AnyNode} node
3661
- * @returns {node is CommentNode}
3662
- */
3663
- function isComment(node) {
3664
- return node.type === NODE_TYPES.Comment;
3665
- }
3666
-
3667
- /**
3668
- * @param {AnyNode} node
3669
- * @returns {node is TextNode}
3670
- */
3671
- function isText(node) {
3672
- return node.type === NODE_TYPES.Text;
3673
- }
3674
-
3675
- const lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u;
3676
- const lineEndingPattern = new RegExp(lineBreakPattern.source, "gu");
3677
- /**
3678
- * @param {string} source
3679
- * @returns {string[]}
3680
- */
3681
- function codeToLines(source) {
3682
- return source.split(lineEndingPattern);
3683
- }
3684
-
3685
- /**
3686
- *
3687
- * @param {AnyToken[]} tokens
3688
- * @returns {((CommentContentNode | TextNode)['templates'][number])[]}
3689
- */
3690
- function getTemplateTokens(tokens) {
3691
- return (
3692
- []
3693
- .concat(
3694
- ...tokens
3695
- // @ts-ignore
3696
- .map((token) => token["templates"] || [])
3697
- )
3698
- // @ts-ignore
3699
- .filter((token) => token.isTemplate)
3700
- );
3701
- }
3702
-
3703
- node = {
3704
- findAttr,
3705
- isAttributesEmpty,
3706
- isNodeTokensOnSameLine,
3707
- splitToLineNodes,
3708
- getLocBetween,
3709
- isExpressionInTemplate,
3710
- isTag,
3711
- isComment,
3712
- isText,
3713
- isOverlapWithTemplates,
3714
- codeToLines,
3715
- isRangesOverlap,
3716
- getTemplateTokens,
3717
- };
3718
- return node;
3719
- }
3720
-
3721
- var enforceBemClass;
3722
- var hasRequiredEnforceBemClass;
3723
-
3724
- function requireEnforceBemClass () {
3725
- if (hasRequiredEnforceBemClass) return enforceBemClass;
3726
- hasRequiredEnforceBemClass = 1;
3727
- const {
3728
- findAttr,
3729
- isAttributesEmpty
3730
- } = requireNode();
3731
-
3732
- enforceBemClass = {
3733
- meta: {
3734
- type: "problem", // The rule type
3735
- docs: {
3736
- description: "Enforce consistent class naming using BEM convention",
3737
- category: "Stylistic Issues",
3738
- recommended: true,
3739
- },
3740
- fixable: "code", // This rule can be fixed automatically
3741
- schema: [
3742
- {
3743
- type: "object",
3744
- properties: {
3745
- pattern: { type: "string" }, // Regex pattern for BEM
3746
- flags: { type: "string" }, // Regex flags
3747
- },
3748
- additionalProperties: false,
3749
- },
3750
- ],
3751
- messages: {
3752
- wrongClassName:
3753
- "The class '{{actual}}' does not follow BEM naming convention.",
3754
- },
3755
- },
3756
-
3757
- create(context) {
3758
- const pattern =
3759
- /^(?:[a-z0-9]+(?:-[a-z0-9]+)*)(__[a-z0-9]+(?:-[a-z0-9]+)*)?(--[a-z0-9]+(?:-[a-z0-9]+)*)?$/;
3760
-
3761
-
3762
- const checkNaming = (name) => {
3763
-
3764
- return pattern.test(name)
3765
- };
3766
-
3767
- function check(node) {
3768
- if (isAttributesEmpty(node)) {
3769
- return;
3770
- }
3771
- const classAttr = findAttr(node, "class");
3772
- if (classAttr && classAttr.value) {
3773
- const classNames = classAttr.value.value.split(/\s+/);
3774
- classNames.forEach((className) => {
3775
- if (className && !checkNaming(className)) {
3776
-
3777
- // Find the exact location of the problematic class name
3778
- const classNameStart = classAttr.value.value.indexOf(className) +7; // 7 here is for `class= "`
3779
- const classNameEnd = classNameStart + className.length;
3780
-
3781
- // Use the loc property to get line and column from the class attribute
3782
- const startLoc = {
3783
- line: classAttr.loc.start.line,
3784
- column: classAttr.loc.start.column + classNameStart,
3785
- };
3786
- const endLoc = {
3787
- line: classAttr.loc.start.line,
3788
- column: classAttr.loc.start.column + classNameEnd,
3789
- };
3790
-
3791
- context.report({
3792
- node,
3793
- loc: { start: startLoc, end: endLoc },
3794
- data: {
3795
- actual: className,
3796
- },
3797
- messageId: "wrongClassName",
3798
- });
3799
- }
3800
- });
3801
- }
3802
- }
3803
- return {
3804
- Tag: check,
3805
- };
3806
- },
3807
- };
3808
- return enforceBemClass;
3809
- }
3810
-
3811
- var noDeprecatedSldsClasses;
3812
- var hasRequiredNoDeprecatedSldsClasses;
3813
-
3814
- function requireNoDeprecatedSldsClasses () {
3815
- if (hasRequiredNoDeprecatedSldsClasses) return noDeprecatedSldsClasses;
3816
- hasRequiredNoDeprecatedSldsClasses = 1;
3817
- const fs = require$$0__default["default"];
3818
- const path = require$$1__default["default"];
3819
- const { findAttr, isAttributesEmpty } = requireNode();
3820
-
3821
- noDeprecatedSldsClasses = {
3822
- meta: {
3823
- type: "problem", // The rule type
3824
- docs: {
3825
- description: "Disallow usage of deprecated CSS classes",
3826
- category: "Best Practices",
3827
- recommended: true,
3828
- },
3829
- schema: [], // No additional options needed
3830
- messages: {
3831
- deprecatedClass: "The class '{{className}}' is deprecated and should not be used.",
3832
- },
3833
- },
3834
-
3835
- create(context) {
3836
- let deprecatedClassesPath = path.resolve(
3837
- __dirname,
3838
- "./public/metadata/deprecatedClasses.json"
3839
- );
3840
- if(process.env.NODE_ENV === 'test')
3841
- {
3842
- // In case of testing, we grab the json from local folder.
3843
- deprecatedClassesPath = path.resolve(
3844
- __dirname,
3845
- "./../../public/metadata/deprecatedClasses.json"
3846
- );
3847
- }
3848
-
3849
- //console.log(`deprecatedClassesPath ${deprecatedClassesPath}`)
3850
-
3851
- let deprecatedClasses = [];
3852
- try {
3853
- const fileContent = fs.readFileSync(deprecatedClassesPath, "utf8");
3854
- deprecatedClasses = JSON.parse(fileContent);
3855
- } catch (error) {
3856
- console.error(`Failed to load deprecated classes JSON: ${error.message}`);
3857
- return {}; // Exit gracefully if JSON cannot be loaded
3858
- }
3859
-
3860
- function check(node) {
3861
- if (isAttributesEmpty(node)) {
3862
- return;
3863
- }
3864
-
3865
- const classAttr = findAttr(node, "class");
3866
- if (classAttr && classAttr.value) {
3867
- const classNames = classAttr.value.value.split(/\s+/);
3868
- classNames.forEach((className) => {
3869
- if (className && deprecatedClasses.includes(className)) {
3870
- // Find the exact location of the problematic class name
3871
- const classNameStart = classAttr.value.value.indexOf(className) +7; // 7 here is for `class= "`
3872
- const classNameEnd = classNameStart + className.length;
3873
-
3874
- // Use the loc property to get line and column from the class attribute
3875
- const startLoc = {
3876
- line: classAttr.loc.start.line,
3877
- column: classAttr.loc.start.column + classNameStart,
3878
- };
3879
- const endLoc = {
3880
- line: classAttr.loc.start.line,
3881
- column: classAttr.loc.start.column + classNameEnd,
3882
- };
3883
-
3884
-
3885
- context.report({
3886
- node,
3887
- loc: { start: startLoc, end: endLoc },
3888
- data: {
3889
- className,
3890
- },
3891
- messageId: "deprecatedClass",
3892
- });
3893
- }
3894
- });
3895
- }
3896
- }
3897
-
3898
- return {
3899
- Tag: check,
3900
- };
3901
- },
3902
- };
3903
- return noDeprecatedSldsClasses;
3904
- }
3905
-
3906
- var modalCloseButtonIssue;
3907
- var hasRequiredModalCloseButtonIssue;
3908
-
3909
- function requireModalCloseButtonIssue () {
3910
- if (hasRequiredModalCloseButtonIssue) return modalCloseButtonIssue;
3911
- hasRequiredModalCloseButtonIssue = 1;
3912
- const { findAttr, isAttributesEmpty } = requireNode();
3913
-
3914
- // This rule specific to CVS, find more details here https://issues.salesforce.com/issue/a028c00000zh1iqAAA/modal-close-button-is-not-visible-with-the-new-white-background-after-winter-25-release
3915
- modalCloseButtonIssue = {
3916
- meta: {
3917
- type: "problem",
3918
- docs: {
3919
- description:
3920
- "Ensure SLDS modal compliance by enforcing correct button and icon attributes.",
3921
- category: "Best Practices",
3922
- recommended: true,
3923
- },
3924
- fixable: "code",
3925
- schema: [],
3926
- messages: {
3927
- removeClass:
3928
- "Remove the class 'slds-button_icon-inverse' from SLDS Modal blueprints.",
3929
- changeVariant:
3930
- "Change 'variant' attribute from 'bare-inverse' to 'bare' in <lightning-button-icon> or <lightning-icon>.",
3931
- removeVariant:
3932
- "Remove 'variant' attribute completely in <lightning-icon> inside <button>.",
3933
- ensureButtonClasses:
3934
- "Ensure 'slds-button' and 'slds-button_icon' are in the class attribute of <button> or <lightning-button-icon>.",
3935
- ensureSizeAttribute:
3936
- "Ensure 'size' attribute is set to 'large' in <lightning-icon> or <lightning-button-icon> for correct icon sizing.",
3937
- },
3938
- },
3939
-
3940
- create(context) {
3941
- function check(node) {
3942
- if (isAttributesEmpty(node)) {
3943
- return;
3944
- }
3945
-
3946
- const tagName = node.name;
3947
-
3948
- // ✅ Scenario 1: Remove 'slds-button_icon-inverse' from <button>
3949
- // (optional) when the parent of the button has class name `slds-modal`
3950
- // and also button should have class `slds-modal__close`
3951
- if (tagName === "button") {
3952
- const classAttr = findAttr(node, "class");
3953
- if (classAttr && classAttr.value) {
3954
- const classList = classAttr.value.value.split(/\s+/);
3955
-
3956
- // ✅ Ensure button has "slds-modal__close" before proceeding
3957
- if (!classList.includes("slds-modal__close")) {
3958
- return; // Stop execution if the class is missing
3959
- }
3960
-
3961
- if (classList.includes("slds-button_icon-inverse")) {
3962
- context.report({
3963
- node,
3964
- messageId: "removeClass",
3965
- fix(fixer) {
3966
- const newClassList = classList
3967
- .filter((cls) => cls !== "slds-button_icon-inverse")
3968
- .join(" ");
3969
- return fixer.replaceText(
3970
- classAttr, // Replace the full attribute
3971
- `class="${newClassList}"` // Updated class list
3972
- );
3973
- },
3974
- });
3975
- }
3976
- }
3977
- }
3978
-
3979
- // ✅ Scenario 2: Fix <lightning-button-icon> and this should have class `slds-modal__close`
3980
- if (tagName === "lightning-button-icon" || tagName === "lightning:buttonIcon") {
3981
- const variantAttr = findAttr(node, "variant");
3982
- const sizeAttr = findAttr(node, "size");
3983
- const classAttr = findAttr(node, "class");
3984
-
3985
- if (classAttr && classAttr.value) {
3986
- const classList = classAttr.value.value.split(/\s+/);
3987
-
3988
- // ✅ Ensure button has "slds-modal__close" before proceeding
3989
- if (!classList.includes("slds-modal__close")) {
3990
- return; // Stop execution if the class is missing
3991
- }
3992
-
3993
- // Fix variant="bare-inverse" to "bare"
3994
- if (variantAttr && variantAttr.value && variantAttr.value.value === "bare-inverse") {
3995
- context.report({
3996
- node: variantAttr,
3997
- messageId: "changeVariant",
3998
- fix(fixer) {
3999
- return fixer.replaceText(variantAttr.value, `bare`);
4000
- },
4001
- });
4002
- }
4003
-
4004
- // Ensure size="large" exists
4005
- if (!sizeAttr) {
4006
- context.report({
4007
- node,
4008
- messageId: "ensureSizeAttribute",
4009
- fix(fixer) {
4010
- //return fixer.insertTextAfter(node, ' size="large"');
4011
- return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], ' size="large"')
4012
- },
4013
- });
4014
- }
4015
-
4016
- // Ensure 'slds-button' and 'slds-button_icon' are in the class attribute
4017
- if (classAttr && classAttr.value) {
4018
- const classList = classAttr.value.value.split(/\s+/);
4019
- if (!classList.includes("slds-button") || !classList.includes("slds-button_icon")) {
4020
- context.report({
4021
- node: classAttr,
4022
- messageId: "ensureButtonClasses",
4023
- fix(fixer) {
4024
- const newClassList = [
4025
- "slds-button",
4026
- "slds-button_icon",
4027
- ...classList.filter(
4028
- (cls) => cls !== "slds-button_icon-inverse"
4029
- ),
4030
- ].join(" ");
4031
- return fixer.replaceText(classAttr.value, `"${newClassList}"`);
4032
- },
4033
- });
4034
- }
4035
- }
4036
- }
4037
-
4038
- }
4039
-
4040
- // ✅ Scenario 3: Fix <lightning-icon> inside <button> & the class name of the parent name as button and it should have `slds-modal__close`
4041
- if ((tagName === "lightning-icon" || tagName === "lightning:icon") && node.parent?.name === "button") {
4042
- const parentClassAttr = findAttr(node.parent, "class");
4043
- if (parentClassAttr && parentClassAttr.value) {
4044
- const parentClassList = parentClassAttr.value.value.split(/\s+/);
4045
-
4046
- // ✅ Ensure the parent <button> has "slds-modal__close" before proceeding
4047
- if (!parentClassList.includes("slds-modal__close")) {
4048
- return; // Stop execution if the class is missing
4049
- }
4050
- const variantAttr = findAttr(node, "variant");
4051
- const sizeAttr = findAttr(node, "size");
4052
-
4053
- // Fix variant="bare-inverse" to "bare"
4054
- if (variantAttr && variantAttr.value && variantAttr.value.value === "bare-inverse") {
4055
- context.report({
4056
- node: variantAttr,
4057
- messageId: "changeVariant",
4058
- fix(fixer) {
4059
- return fixer.replaceText(variantAttr.value, `"bare"`);
4060
- },
4061
- });
4062
- }
4063
-
4064
- // Remove variant attribute completely
4065
- if (variantAttr) {
4066
- context.report({
4067
- node: variantAttr,
4068
- messageId: "removeVariant",
4069
- fix(fixer) {
4070
- return fixer.remove(variantAttr);
4071
- },
4072
- });
4073
- }
4074
-
4075
- //Ensure size="large" is set
4076
- if (!sizeAttr) {
4077
- context.report({
4078
- node,
4079
- messageId: "ensureSizeAttribute",
4080
- fix(fixer) {
4081
- //return fixer.insertTextAfter(node, ' size="large"');
4082
- return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], 'size="large"')
4083
- },
4084
- });
4085
- }
4086
- }
4087
- }
4088
- }
4089
- return {
4090
- Tag: check,
4091
- };
4092
- },
4093
- };
4094
- return modalCloseButtonIssue;
4095
- }
4096
-
4097
- var src;
4098
- var hasRequiredSrc;
4099
-
4100
- function requireSrc () {
4101
- if (hasRequiredSrc) return src;
4102
- hasRequiredSrc = 1;
4103
- src = {
4104
- rules: {
4105
- "enforce-bem-class": requireEnforceBemClass(),
4106
- "no-deprecated-slds-classes": requireNoDeprecatedSldsClasses(),
4107
- "modal-close-button-issue": requireModalCloseButtonIssue()
4108
- },
4109
- configs: {
4110
- recommended: {
4111
- parser: "@html-eslint/parser", // Use HTML parser
4112
- plugins: ["slds"],
4113
- rules: {
4114
- "slds/enforce-bem-class": "error",
4115
- "slds/no-deprecated-slds-classes": "error",
4116
- "slds/modal-close-button-issue": "error"
4117
- },
4118
- },
4119
- },
4120
- };
4121
- return src;
4122
- }
4123
-
4124
- var srcExports = requireSrc();
4125
- var index = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
4126
-
4127
- module.exports = index;
4128
- //# sourceMappingURL=index.js.map