svg-eslint-parser 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -110,7 +110,7 @@ traverseAST(document, {
110
110
 
111
111
  #### `parseForESLint(code: string, options?: ParserOptions)`
112
112
 
113
- Returns an ESLint-compatible result with AST, visitor keys, and services.
113
+ Returns an ESLint-compatible result with AST, visitor keys, and services. Recoverable parser diagnostics are available on `services.errors` and `services.warnings`.
114
114
 
115
115
  #### `parse(code: string, options?: ParserOptions)`
116
116
 
package/dist/index.d.ts CHANGED
@@ -1,12 +1,32 @@
1
1
  import { SourceCode } from "eslint";
2
2
 
3
3
  //#region src/meta.d.ts
4
+ /**
5
+ * Package metadata exposed to parser consumers.
6
+ */
4
7
  declare const meta: {
5
8
  name: string;
6
9
  version: string;
7
10
  };
8
11
  //#endregion
9
12
  //#region src/parser/error.d.ts
13
+ /**
14
+ * parse error options
15
+ */
16
+ interface ParseErrorOptions extends ErrorOptions {
17
+ /**
18
+ * The index of the error in the source code
19
+ */
20
+ column: number;
21
+ /**
22
+ * The line number of the error in the source code
23
+ */
24
+ line: number;
25
+ /**
26
+ * The offset of the error in the source code
27
+ */
28
+ offset: number;
29
+ }
10
30
  /**
11
31
  * parse error
12
32
  */
@@ -14,6 +34,7 @@ declare class ParseError extends SyntaxError {
14
34
  index: number;
15
35
  lineNumber: number;
16
36
  column: number;
37
+ constructor(message: string, options: ParseErrorOptions);
17
38
  constructor(message: string, offset: number, line: number, column: number);
18
39
  }
19
40
  //#endregion
@@ -36,26 +57,29 @@ declare const XML_DECLARATION_START = "<?xml";
36
57
  declare const XML_DECLARATION_END = "?>";
37
58
  /**
38
59
  * regexp for open tag start
39
- * @regex101 https://regex101.com/?regex=%5E%3C%5Cw&flavor=javascript
60
+ * @regex101 https://regex101.com/?regex=%5E%3C%5Cw&flags=u&flavor=javascript
40
61
  */
41
62
  declare const RE_OPEN_TAG_START: RegExp;
42
63
  /**
43
64
  * regexp for open tag name
44
- * @regex101 https://regex101.com/?regex=%5E%3C%28%5CS%2B%29&flavor=javascript
65
+ * @regex101 https://regex101.com/?regex=%5E%3C%28%3F%3CtagName%3E%5CS%2B%29&flags=u&flavor=javascript
45
66
  */
46
67
  declare const RE_OPEN_TAG_NAME: RegExp;
47
68
  /**
48
69
  * regexp for close tag name
49
- * @regex101 https://regex101.com/?regex=%5E%3C%5C%2F%28%28%3F%3A.%7C%5Cr%3F%5Cn%29*%29%3E%24&flavor=javascript
70
+ * @regex101 https://regex101.com/?regex=%5E%3C%5C%2F%28%3F%3CtagName%3E%28%3F%3A.%7C%5Cr%3F%5Cn%29*%29%3E%24&flags=u&flavor=javascript
50
71
  */
51
72
  declare const RE_CLOSE_TAG_NAME: RegExp;
52
73
  /**
53
74
  * regexp for incomplete closing tag
54
- * @regex101 https://regex101.com/?regex=%3C%5C%2F%5B%5E%3E%5D%2B%24&flavor=javascript
75
+ * @regex101 https://regex101.com/?regex=%3C%5C%2F%5B%5E%3E%5D%2B%24&flags=u&flavor=javascript
55
76
  */
56
77
  declare const RE_INCOMPLETE_CLOSING_TAG: RegExp;
57
78
  //#endregion
58
79
  //#region src/constants/nodeTypes.d.ts
80
+ /**
81
+ * AST node type names emitted by the parser.
82
+ */
59
83
  declare enum NodeTypes {
60
84
  Attribute = "Attribute",
61
85
  AttributeKey = "AttributeKey",
@@ -76,6 +100,9 @@ declare enum NodeTypes {
76
100
  }
77
101
  //#endregion
78
102
  //#region src/constants/tokenTypes.d.ts
103
+ /**
104
+ * Token type names emitted by tokenizer contexts.
105
+ */
79
106
  declare enum TokenTypes {
80
107
  /**
81
108
  * @pg Content tokens
@@ -122,6 +149,9 @@ declare enum TokenTypes {
122
149
  }
123
150
  //#endregion
124
151
  //#region src/constants/specialChar.d.ts
152
+ /**
153
+ * Character constants used by tokenizer handlers.
154
+ */
125
155
  declare const SPECIAL_CHAR: {
126
156
  closingCorner: string;
127
157
  colon: string;
@@ -158,6 +188,9 @@ declare const DEPRECATED_SVG_ELEMENTS: Set<string>;
158
188
  declare const SELF_CLOSING_ELEMENTS: Set<string>;
159
189
  //#endregion
160
190
  //#region src/constants/tokenizerContextTypes.d.ts
191
+ /**
192
+ * Tokenizer state machine contexts.
193
+ */
161
194
  declare enum TokenizerContextTypes {
162
195
  AttributeKey = "AttributeKey",
163
196
  Attributes = "Attributes",
@@ -185,6 +218,9 @@ declare enum TokenizerContextTypes {
185
218
  }
186
219
  //#endregion
187
220
  //#region src/constants/constructTreeContextTypes.d.ts
221
+ /**
222
+ * AST construction state machine contexts.
223
+ */
188
224
  declare enum ConstructTreeContextTypes {
189
225
  Attribute = "Attribute",
190
226
  Attributes = "Attributes",
@@ -203,10 +239,16 @@ declare enum ConstructTreeContextTypes {
203
239
  }
204
240
  //#endregion
205
241
  //#region src/types/ast/common.d.ts
242
+ /**
243
+ * AST node source range and location metadata.
244
+ */
206
245
  interface Locations {
207
246
  loc: SourceLocation;
208
247
  range: Range;
209
248
  }
249
+ /**
250
+ * One-based line and zero-based column position.
251
+ */
210
252
  interface Position {
211
253
  /**
212
254
  * 0 based index (>= 0)
@@ -217,7 +259,13 @@ interface Position {
217
259
  */
218
260
  line: number;
219
261
  }
262
+ /**
263
+ * Character offset range in `[start, end]` form.
264
+ */
220
265
  type Range = [number, number];
266
+ /**
267
+ * Start and end positions for a node or token.
268
+ */
221
269
  interface SourceLocation {
222
270
  /**
223
271
  * end position of source
@@ -231,11 +279,11 @@ interface SourceLocation {
231
279
  //#endregion
232
280
  //#region src/types/ast/token.d.ts
233
281
  /**
234
- * any token
282
+ * Union of all tokenizer output token shapes.
235
283
  */
236
284
  type AnyToken = Token<TokenTypes.AttributeAssignment> | Token<TokenTypes.AttributeKey> | Token<TokenTypes.AttributeValue> | Token<TokenTypes.AttributeValueWrapperEnd> | Token<TokenTypes.AttributeValueWrapperStart> | Token<TokenTypes.CloseTag> | Token<TokenTypes.CommentClose> | Token<TokenTypes.CommentContent> | Token<TokenTypes.CommentOpen> | Token<TokenTypes.DoctypeAttributeValue> | Token<TokenTypes.DoctypeAttributeWrapperEnd> | Token<TokenTypes.DoctypeAttributeWrapperStart> | Token<TokenTypes.DoctypeClose> | Token<TokenTypes.DoctypeOpen> | Token<TokenTypes.OpenTagEnd> | Token<TokenTypes.OpenTagStart> | Token<TokenTypes.Text> | Token<TokenTypes.XMLDeclarationAttributeAssignment> | Token<TokenTypes.XMLDeclarationAttributeKey> | Token<TokenTypes.XMLDeclarationAttributeValue> | Token<TokenTypes.XMLDeclarationAttributeValueWrapperEnd> | Token<TokenTypes.XMLDeclarationAttributeValueWrapperStart> | Token<TokenTypes.XMLDeclarationClose> | Token<TokenTypes.XMLDeclarationOpen>;
237
285
  /**
238
- * token
286
+ * Source token emitted by the tokenizer.
239
287
  */
240
288
  interface Token<T extends TokenTypes> extends Locations {
241
289
  /**
@@ -249,55 +297,76 @@ interface Token<T extends TokenTypes> extends Locations {
249
297
  }
250
298
  //#endregion
251
299
  //#region src/types/ast/node.d.ts
300
+ /**
301
+ * Base shape shared by all AST nodes.
302
+ */
252
303
  interface BaseNode extends Locations {
253
304
  type: NodeTypes;
254
305
  }
306
+ /**
307
+ * Leaf AST node that stores a string value.
308
+ */
255
309
  interface SimpleNode<T extends NodeTypes> extends BaseNode {
256
310
  type: T;
257
311
  value: string;
258
312
  }
313
+ /**
314
+ * Text content between SVG/XML nodes.
315
+ */
259
316
  type TextNode = SimpleNode<NodeTypes.Text>;
317
+ /**
318
+ * ESLint-compatible comment object.
319
+ */
260
320
  interface ESLintComment extends Locations {
261
321
  type: 'Block' | 'Line';
262
322
  value: string;
263
323
  }
264
324
  /**
265
- * attribute nodes
266
- * @pg
325
+ * Attribute key node.
267
326
  */
268
327
  type AttributeKeyNode = SimpleNode<NodeTypes.AttributeKey>;
328
+ /**
329
+ * Attribute value node.
330
+ */
269
331
  type AttributeValueNode = SimpleNode<NodeTypes.AttributeValue>;
332
+ /**
333
+ * Element attribute node.
334
+ */
270
335
  interface AttributeNode extends BaseNode {
271
336
  key: AttributeKeyNode;
272
337
  type: NodeTypes.Attribute;
273
- value?: AttributeValueNode;
274
338
  quoteChar?: '"' | "'" | undefined;
339
+ value?: AttributeValueNode;
275
340
  }
276
341
  /**
277
- * comment nodes
278
- * @pg
342
+ * SVG/XML comment node.
279
343
  */
280
344
  interface CommentNode extends BaseNode {
281
345
  content: string;
282
346
  type: NodeTypes.Comment;
347
+ value: string;
283
348
  }
284
349
  /**
285
- * doctype nodes
286
- * @pg
350
+ * Doctype attribute value node.
287
351
  */
288
352
  type DoctypeAttributeValueNode = SimpleNode<NodeTypes.DoctypeAttributeValue>;
353
+ /**
354
+ * Doctype attribute node.
355
+ */
289
356
  interface DoctypeAttributeNode extends BaseNode {
290
357
  type: NodeTypes.DoctypeAttribute;
291
358
  quoteChar?: '"' | "'" | undefined;
292
359
  value?: DoctypeAttributeValueNode;
293
360
  }
361
+ /**
362
+ * Doctype declaration node.
363
+ */
294
364
  interface DoctypeNode extends BaseNode {
295
365
  attributes: DoctypeAttributeNode[];
296
366
  type: NodeTypes.Doctype;
297
367
  }
298
368
  /**
299
- * element nodes
300
- * @pg
369
+ * SVG/XML element node.
301
370
  */
302
371
  interface ElementNode extends BaseNode {
303
372
  attributes: AttributeNode[];
@@ -307,23 +376,31 @@ interface ElementNode extends BaseNode {
307
376
  type: NodeTypes.Element;
308
377
  }
309
378
  /**
310
- * XML declaration nodes
379
+ * XML declaration attribute key node.
311
380
  */
312
381
  type XMLDeclarationAttributeKeyNode = SimpleNode<NodeTypes.XMLDeclarationAttributeKey>;
382
+ /**
383
+ * XML declaration attribute value node.
384
+ */
313
385
  type XMLDeclarationAttributeValueNode = SimpleNode<NodeTypes.XMLDeclarationAttributeValue>;
386
+ /**
387
+ * XML declaration attribute node.
388
+ */
314
389
  interface XMLDeclarationAttributeNode extends BaseNode {
315
390
  key: XMLDeclarationAttributeKeyNode;
316
391
  type: NodeTypes.XMLDeclarationAttribute;
317
- value?: XMLDeclarationAttributeValueNode;
318
392
  quoteChar?: '"' | "'" | undefined;
393
+ value?: XMLDeclarationAttributeValueNode;
319
394
  }
395
+ /**
396
+ * XML declaration node.
397
+ */
320
398
  interface XMLDeclarationNode extends BaseNode {
321
399
  attributes: XMLDeclarationAttributeNode[];
322
400
  type: NodeTypes.XMLDeclaration;
323
401
  }
324
402
  /**
325
- * error nodes
326
- * @pg
403
+ * Parser recovery error node.
327
404
  */
328
405
  interface ErrorNode extends BaseNode {
329
406
  code: string;
@@ -332,14 +409,15 @@ interface ErrorNode extends BaseNode {
332
409
  recoveredNode?: AnyNode;
333
410
  }
334
411
  /**
335
- * child node
336
- * @pg
412
+ * Node types allowed as direct document children.
337
413
  */
338
- type DocumentChildNode = XMLDeclarationNode | DoctypeNode | ElementNode | CommentNode | TextNode;
339
- type ElementChildNode = ElementNode | CommentNode | TextNode;
414
+ type DocumentChildNode = CommentNode | DoctypeNode | ElementNode | TextNode | XMLDeclarationNode;
340
415
  /**
341
- * program
342
- * @pg
416
+ * Node types allowed as element children.
417
+ */
418
+ type ElementChildNode = CommentNode | ElementNode | TextNode;
419
+ /**
420
+ * ESLint program wrapper around the SVG document.
343
421
  */
344
422
  interface Program extends BaseNode {
345
423
  body: [];
@@ -348,17 +426,66 @@ interface Program extends BaseNode {
348
426
  tokens: AnyToken[];
349
427
  type: NodeTypes.Program;
350
428
  }
429
+ /**
430
+ * Root SVG document node.
431
+ */
351
432
  interface DocumentNode extends BaseNode {
352
433
  children: DocumentChildNode[];
353
434
  type: NodeTypes.Document;
354
435
  }
355
436
  /**
356
- * any node
357
- * @pg
437
+ * Union of every parser AST node.
358
438
  */
359
439
  type AnyNode = AttributeKeyNode | AttributeNode | AttributeValueNode | CommentNode | DoctypeAttributeNode | DoctypeAttributeValueNode | DoctypeNode | DocumentNode | ElementNode | ErrorNode | Program | TextNode | XMLDeclarationAttributeKeyNode | XMLDeclarationAttributeNode | XMLDeclarationAttributeValueNode | XMLDeclarationNode;
360
440
  //#endregion
441
+ //#region src/types/errors.d.ts
442
+ /**
443
+ * Categories of recoverable parse diagnostics.
444
+ */
445
+ declare enum ParseErrorType {
446
+ InvalidAttribute = "InvalidAttribute",
447
+ InvalidCharacter = "InvalidCharacter",
448
+ InvalidDoctypeAttribute = "InvalidDoctypeAttribute",
449
+ InvalidXMLDeclaration = "InvalidXMLDeclaration",
450
+ MalformedComment = "MalformedComment",
451
+ MismatchedTag = "MismatchedTag",
452
+ UnclosedTag = "UnclosedTag",
453
+ UnexpectedToken = "UnexpectedToken",
454
+ UnmatchedQuote = "UnmatchedQuote"
455
+ }
456
+ /**
457
+ * Recoverable parser diagnostic with source location information.
458
+ */
459
+ interface ParseError$1 {
460
+ loc: SourceLocation;
461
+ message: string;
462
+ range: Range;
463
+ type: ParseErrorType;
464
+ recovery?: string;
465
+ }
466
+ /**
467
+ * Collector interface used while building parser diagnostics.
468
+ */
469
+ interface ErrorContext {
470
+ errors: ParseError$1[];
471
+ warnings: ParseError$1[];
472
+ addError(error: Omit<ParseError$1, 'type'> & {
473
+ type: ParseErrorType;
474
+ }): void;
475
+ addWarning(warning: Omit<ParseError$1, 'type'> & {
476
+ type: ParseErrorType;
477
+ }): void;
478
+ clear(): void;
479
+ getErrors(): ParseError$1[];
480
+ getWarnings(): ParseError$1[];
481
+ hasErrors(): boolean;
482
+ hasWarnings(): boolean;
483
+ }
484
+ //#endregion
361
485
  //#region src/types/parse.d.ts
486
+ /**
487
+ * Parser options accepted by direct and ESLint parse entry points.
488
+ */
362
489
  interface Options {
363
490
  comment?: boolean;
364
491
  /**
@@ -380,81 +507,190 @@ interface Options {
380
507
  interface ParseForESLintResult {
381
508
  ast: Program;
382
509
  scopeManager: any;
510
+ visitorKeys: SourceCode.VisitorKeys;
383
511
  services: {
512
+ errors: ParseError$1[];
384
513
  isSVG: boolean;
514
+ warnings: ParseError$1[];
385
515
  };
386
- visitorKeys: SourceCode.VisitorKeys;
387
516
  }
517
+ /**
518
+ * Result returned by the direct parser entry point.
519
+ */
388
520
  interface ParseResult {
389
521
  ast: DocumentNode;
522
+ errors: ParseError$1[];
390
523
  tokens: AnyToken[];
524
+ warnings: ParseError$1[];
391
525
  }
392
526
  //#endregion
393
527
  //#region src/types/contextualNode.d.ts
528
+ /**
529
+ * Union of AST nodes while they are still being constructed.
530
+ */
394
531
  type AnyContextualNode = ContextualAttributeNode | ContextualCommentNode | ContextualDoctypeAttributeNode | ContextualDoctypeNode | ContextualDocumentNode | ContextualElementNode | ContextualXMLDeclarationAttributeNode | ContextualXMLDeclarationNode;
532
+ /**
533
+ * Attribute node with key/value filled as tokens are consumed.
534
+ */
395
535
  type ContextualAttributeNode = ContextualNode<AttributeNode, 'key' | 'value'>;
396
- type ContextualCommentNode = ContextualNode<CommentNode, 'content'>;
536
+ /**
537
+ * Comment node before comment content has been finalized.
538
+ */
539
+ type ContextualCommentNode = ContextualNode<CommentNode, 'content' | 'value'>;
540
+ /**
541
+ * Doctype attribute node before value has been finalized.
542
+ */
397
543
  type ContextualDoctypeAttributeNode = ContextualNode<DoctypeAttributeNode, 'type' | 'value'>;
544
+ /**
545
+ * Doctype node while its attributes are being collected.
546
+ */
398
547
  type ContextualDoctypeNode = ContextualNode<DoctypeNode, 'attributes'> & {
399
548
  attributes: ContextualDoctypeAttributeNode[];
400
549
  };
550
+ /**
551
+ * Document root while child nodes are being attached.
552
+ */
401
553
  type ContextualDocumentNode = Omit<ContextualNode<DocumentNode, never>, 'children'> & {
402
- children: Array<DocumentNode['children'][number] | ContextualCommentNode | ContextualDoctypeNode | ContextualElementNode | ContextualXMLDeclarationNode>;
554
+ children: Array<ContextualCommentNode | ContextualDoctypeNode | ContextualElementNode | ContextualXMLDeclarationNode | DocumentNode['children'][number]>;
403
555
  };
556
+ /**
557
+ * Construction-time node with selected fields allowed to be incomplete.
558
+ */
404
559
  type ContextualNode<T extends AnyNode, K extends keyof T> = PartialBy<T, K> & {
405
560
  parentRef?: any;
406
561
  };
562
+ /**
563
+ * Element node while name, attributes, and children are being collected.
564
+ */
407
565
  type ContextualElementNode = ContextualNode<ElementNode, 'attributes' | 'children' | 'name' | 'selfClosing'> & {
408
566
  attributes: ContextualAttributeNode[];
409
567
  children: Array<ContextualCommentNode | ContextualElementNode | ElementNode['children'][number]>;
410
568
  };
569
+ /**
570
+ * XML declaration attribute node before key/value are finalized.
571
+ */
411
572
  type ContextualXMLDeclarationAttributeNode = ContextualNode<XMLDeclarationAttributeNode, 'key' | 'value'>;
573
+ /**
574
+ * XML declaration node while attributes are being collected.
575
+ */
412
576
  type ContextualXMLDeclarationNode = ContextualNode<XMLDeclarationNode, 'attributes'> & {
413
577
  attributes: ContextualXMLDeclarationAttributeNode[];
414
578
  };
579
+ /**
580
+ * Make selected keys optional while leaving the rest of a type intact.
581
+ */
415
582
  type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
416
583
  //#endregion
417
584
  //#region src/tokenizer/chars.d.ts
585
+ /**
586
+ * Buffered source characters with their source range.
587
+ */
418
588
  declare class Chars {
419
589
  value: string;
420
590
  range: Range;
421
591
  constructor(value: string, range: Range);
422
- concat(chars: Chars): void;
592
+ /**
593
+ * Append adjacent characters into this range.
594
+ */
595
+ append(chars: Chars): void;
596
+ /**
597
+ * Compare the buffered value with raw text.
598
+ */
423
599
  equals(chars: string): boolean;
600
+ /**
601
+ * Get the buffered string length.
602
+ */
424
603
  length(): number;
425
604
  }
426
605
  //#endregion
427
606
  //#region src/tokenizer/charsBuffer.d.ts
607
+ /**
608
+ * Mutable buffer used by tokenizer handlers while deciding token boundaries.
609
+ */
428
610
  declare class CharsBuffer {
429
611
  charsBuffer: Chars[];
612
+ /**
613
+ * Append a character wrapper to the buffer.
614
+ */
430
615
  concat(chars: Chars): void;
616
+ /**
617
+ * Append another buffer without merging its entries.
618
+ */
431
619
  concatBuffer(buffer: CharsBuffer): void;
620
+ /**
621
+ * Get the total buffered character length.
622
+ */
432
623
  length(): number;
624
+ /**
625
+ * Clear all buffered characters.
626
+ */
433
627
  clear(): void;
628
+ /**
629
+ * Get the concatenated buffered string.
630
+ */
434
631
  value(): string;
632
+ /**
633
+ * Get the last buffered character wrapper.
634
+ */
435
635
  last(): Chars;
636
+ /**
637
+ * Get the first buffered character wrapper.
638
+ */
436
639
  first(): Chars;
640
+ /**
641
+ * Remove the last buffered entry.
642
+ */
437
643
  removeLast(): void;
644
+ /**
645
+ * Remove the first buffered entry.
646
+ */
438
647
  removeFirst(): void;
648
+ /**
649
+ * Replace this buffer with a copy of another buffer.
650
+ */
439
651
  replace(other: CharsBuffer): void;
440
652
  }
441
653
  //#endregion
442
654
  //#region src/tokenizer/sourceCode.d.ts
655
+ /**
656
+ * Cursor-based view over source text for tokenizer handlers.
657
+ */
443
658
  declare class SourceCode$1 {
444
659
  readonly source: string;
445
660
  private charsList;
446
661
  private charsIndex;
447
662
  constructor(source: string);
663
+ /**
664
+ * Convert a character range to source locations.
665
+ */
448
666
  getLocationOf(range: Range): SourceLocation;
667
+ /**
668
+ * Get the current character wrapper.
669
+ */
449
670
  current(): Chars;
671
+ /**
672
+ * Advance to the next character.
673
+ */
450
674
  next(): void;
675
+ /**
676
+ * Move back to the previous character.
677
+ */
451
678
  prev(): void;
679
+ /**
680
+ * Check whether the cursor has reached the end of source.
681
+ */
452
682
  isEof(): boolean;
683
+ /**
684
+ * Get the current zero-based character index.
685
+ */
453
686
  index(): number;
454
687
  private createCharsList;
455
688
  }
456
689
  //#endregion
457
690
  //#region src/types/tokenizerState.d.ts
691
+ /**
692
+ * Mutable state shared by tokenizer handlers.
693
+ */
458
694
  type TokenizerState = {
459
695
  accumulatedContent: CharsBuffer;
460
696
  contextParams: ContextParams;
@@ -484,9 +720,13 @@ type ContextParams = {
484
720
  };
485
721
  //#endregion
486
722
  //#region src/types/constructTreeState.d.ts
723
+ /**
724
+ * Mutable state shared by AST construction handlers.
725
+ */
487
726
  type ConstructTreeState<Node extends AnyContextualNode> = {
488
727
  caretPosition: number;
489
728
  currentNode: Node;
729
+ errorHandler: ErrorContext;
490
730
  rootNode: DocumentNode;
491
731
  currentContext: {
492
732
  type: ConstructTreeContextTypes;
@@ -496,20 +736,32 @@ type ConstructTreeState<Node extends AnyContextualNode> = {
496
736
  };
497
737
  //#endregion
498
738
  //#region src/types/constructTreeHandler.d.ts
739
+ /**
740
+ * Constructor handler for a single AST construction context.
741
+ */
499
742
  interface ConstructTreeHandler {
500
743
  construct: (token: AnyToken, state: ConstructTreeState<any>) => ConstructTreeState<any>;
501
744
  }
502
745
  //#endregion
503
746
  //#region src/types/tokenizerContextHandler.d.ts
747
+ /**
748
+ * Tokenizer handler for a single tokenizer context.
749
+ */
504
750
  interface TokenizeHandler {
505
751
  parse: (chars: CharsBuffer, state: TokenizerState) => void;
506
752
  handleContentEnd?: (state: TokenizerState) => void;
507
753
  }
508
754
  declare namespace index_d_exports {
509
- export { AnyContextualNode, AnyNode, AnyToken, AttributeKeyNode, AttributeNode, AttributeValueNode, BaseNode, CommentNode, ConstructTreeHandler, ConstructTreeState, ContextualAttributeNode, ContextualCommentNode, ContextualDoctypeAttributeNode, ContextualDoctypeNode, ContextualDocumentNode, ContextualElementNode, ContextualNode, ContextualXMLDeclarationAttributeNode, ContextualXMLDeclarationNode, DoctypeAttributeNode, DoctypeAttributeValueNode, DoctypeNode, DocumentChildNode, DocumentNode, ESLintComment, ElementChildNode, ElementNode, ErrorNode, Locations, Options, ParseForESLintResult, ParseResult, PartialBy, Position, Program, Range, SimpleNode, SourceLocation, TextNode, Token, TokenizeHandler, TokenizerState, XMLDeclarationAttributeKeyNode, XMLDeclarationAttributeNode, XMLDeclarationAttributeValueNode, XMLDeclarationNode };
755
+ export { AnyContextualNode, AnyNode, AnyToken, AttributeKeyNode, AttributeNode, AttributeValueNode, BaseNode, CommentNode, ConstructTreeHandler, ConstructTreeState, ContextualAttributeNode, ContextualCommentNode, ContextualDoctypeAttributeNode, ContextualDoctypeNode, ContextualDocumentNode, ContextualElementNode, ContextualNode, ContextualXMLDeclarationAttributeNode, ContextualXMLDeclarationNode, DoctypeAttributeNode, DoctypeAttributeValueNode, DoctypeNode, DocumentChildNode, DocumentNode, ESLintComment, ElementChildNode, ElementNode, ErrorContext, ErrorNode, Locations, Options, ParseError$1 as ParseError, ParseErrorType, ParseForESLintResult, ParseResult, PartialBy, Position, Program, Range, SimpleNode, SourceLocation, TextNode, Token, TokenizeHandler, TokenizerState, XMLDeclarationAttributeKeyNode, XMLDeclarationAttributeNode, XMLDeclarationAttributeValueNode, XMLDeclarationNode };
510
756
  }
511
757
  //#endregion
512
758
  //#region src/parser/parseForESLint.d.ts
759
+ /**
760
+ * Parse SVG source into an ESLint-compatible parser result.
761
+ * @param source - SVG source code
762
+ * @param options - Parser options forwarded to the base parser
763
+ * @returns ESLint parser result with visitor keys, services, tokens, and comments
764
+ */
513
765
  declare function parseForESLint(source: string, options?: Options): ParseForESLintResult;
514
766
  //#endregion
515
767
  //#region src/utils/cloneNode.d.ts
@@ -622,8 +874,20 @@ declare function findNodeByType<T extends NodeTypes>(node: AnyNode, type: T): An
622
874
  declare function findFirstNodeByType<T extends NodeTypes>(node: AnyNode, type: T): AnyNode | undefined;
623
875
  //#endregion
624
876
  //#region src/index.d.ts
877
+ /**
878
+ * Parser package name.
879
+ */
625
880
  declare const name: string;
881
+ /**
882
+ * ESLint visitor keys for parser-specific nodes.
883
+ */
626
884
  declare const VisitorKeys: import("eslint").SourceCode.VisitorKeys;
885
+ /**
886
+ * Parse SVG source and return the document node directly.
887
+ * @param code - SVG source code
888
+ * @param options - Parser options
889
+ * @returns Parsed SVG document node
890
+ */
627
891
  declare function parse(code: string, options?: Options): DocumentNode;
628
892
  //#endregion
629
- export { type index_d_exports as AST, type ASTVisitor, AnyContextualNode, AnyNode, AnyToken, AttributeKeyNode, AttributeNode, AttributeValueNode, BaseNode, COMMENT_END, COMMENT_START, CommentNode, ConstructTreeContextTypes, ConstructTreeHandler, ConstructTreeState, ContextualAttributeNode, ContextualCommentNode, ContextualDoctypeAttributeNode, ContextualDoctypeNode, ContextualDocumentNode, ContextualElementNode, ContextualNode, ContextualXMLDeclarationAttributeNode, ContextualXMLDeclarationNode, DEPRECATED_SVG_ELEMENTS, DoctypeAttributeNode, DoctypeAttributeValueNode, DoctypeNode, DocumentChildNode, DocumentNode, ESLintComment, ElementChildNode, ElementNode, ErrorNode, Locations, NodeTypes, Options, ParseError, ParseForESLintResult, ParseResult, PartialBy, Position, Program, RE_CLOSE_TAG_NAME, RE_INCOMPLETE_CLOSING_TAG, RE_OPEN_TAG_NAME, RE_OPEN_TAG_START, Range, SELF_CLOSING_ELEMENTS, SPECIAL_CHAR, SVG_ELEMENTS, SimpleNode, SourceLocation, TextNode, Token, TokenTypes, TokenizeHandler, TokenizerContextTypes, TokenizerState, VisitorKeys, XMLDeclarationAttributeKeyNode, XMLDeclarationAttributeNode, XMLDeclarationAttributeValueNode, XMLDeclarationNode, XML_DECLARATION_END, XML_DECLARATION_START, cloneNode, cloneNodeWithParent, countNodes, filterNodes, findFirstNodeByType, findNodeByType, getNodeDepth, getParentChain, isNodeType, mapNodes, meta, name, parse, parseForESLint, traverseAST, validateNode, walkAST };
893
+ export { type index_d_exports as AST, type ASTVisitor, AnyContextualNode, AnyNode, AnyToken, AttributeKeyNode, AttributeNode, AttributeValueNode, BaseNode, COMMENT_END, COMMENT_START, CommentNode, ConstructTreeContextTypes, ConstructTreeHandler, ConstructTreeState, ContextualAttributeNode, ContextualCommentNode, ContextualDoctypeAttributeNode, ContextualDoctypeNode, ContextualDocumentNode, ContextualElementNode, ContextualNode, ContextualXMLDeclarationAttributeNode, ContextualXMLDeclarationNode, DEPRECATED_SVG_ELEMENTS, DoctypeAttributeNode, DoctypeAttributeValueNode, DoctypeNode, DocumentChildNode, DocumentNode, ESLintComment, ElementChildNode, ElementNode, ErrorContext, ErrorNode, Locations, NodeTypes, Options, ParseError, ParseErrorType, ParseForESLintResult, ParseResult, PartialBy, Position, Program, RE_CLOSE_TAG_NAME, RE_INCOMPLETE_CLOSING_TAG, RE_OPEN_TAG_NAME, RE_OPEN_TAG_START, Range, SELF_CLOSING_ELEMENTS, SPECIAL_CHAR, SVG_ELEMENTS, SimpleNode, SourceLocation, TextNode, Token, TokenTypes, TokenizeHandler, TokenizerContextTypes, TokenizerState, VisitorKeys, XMLDeclarationAttributeKeyNode, XMLDeclarationAttributeNode, XMLDeclarationAttributeValueNode, XMLDeclarationNode, XML_DECLARATION_END, XML_DECLARATION_START, cloneNode, cloneNodeWithParent, countNodes, filterNodes, findFirstNodeByType, findNodeByType, getNodeDepth, getParentChain, isNodeType, mapNodes, meta, name, parse, parseForESLint, traverseAST, validateNode, walkAST };