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