@ts-graphviz/ast 2.0.6 → 2.0.7-next-f8ba9a89f3ac9e916ded16f0a0618113a5eb4928
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/CHANGELOG.md +8 -0
- package/LICENSE +1 -2
- package/lib/ast.cjs +7 -3
- package/lib/ast.d.ts +12 -64
- package/lib/ast.js +7 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @ts-graphviz/ast
|
|
2
2
|
|
|
3
|
+
## 2.0.7-next-f8ba9a89f3ac9e916ded16f0a0618113a5eb4928
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1318](https://github.com/ts-graphviz/ts-graphviz/pull/1318) [`c043ba9`](https://github.com/ts-graphviz/ts-graphviz/commit/c043ba9bcc5194a89b976df1609c4e9875300f1e) Thanks [@kamiazya](https://github.com/kamiazya)! - Improve error handling and documentation in the @ts-graphviz/ast package.
|
|
8
|
+
|
|
9
|
+
The most important changes include fixing an unexpected parsing error, updating the error class used in the parse function, and enhancing the documentation for the `DotSyntaxError` class.
|
|
10
|
+
|
|
3
11
|
## 2.0.6
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/LICENSE
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
1
|
The MIT License (MIT)
|
|
3
2
|
|
|
4
|
-
Copyright (c) 2019-
|
|
3
|
+
Copyright (c) 2019-2025 Yuki Yamazaki
|
|
5
4
|
|
|
6
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/lib/ast.cjs
CHANGED
|
@@ -3106,12 +3106,16 @@ function parse(input, options) {
|
|
|
3106
3106
|
return parse$1(input, options);
|
|
3107
3107
|
} catch (e) {
|
|
3108
3108
|
if (e instanceof PeggySyntaxError) {
|
|
3109
|
-
throw new DotSyntaxError(e.message,
|
|
3109
|
+
throw new DotSyntaxError(e.message, {
|
|
3110
|
+
cause: e
|
|
3111
|
+
});
|
|
3110
3112
|
}
|
|
3111
|
-
throw
|
|
3113
|
+
throw new Error("Unexpected parse error", {
|
|
3114
|
+
cause: e
|
|
3115
|
+
});
|
|
3112
3116
|
}
|
|
3113
3117
|
}
|
|
3114
|
-
class DotSyntaxError extends
|
|
3118
|
+
class DotSyntaxError extends SyntaxError {
|
|
3115
3119
|
constructor(...args) {
|
|
3116
3120
|
super(...args);
|
|
3117
3121
|
this.name = "DotSyntaxError";
|
package/lib/ast.d.ts
CHANGED
|
@@ -8,10 +8,6 @@ import { NodeModel } from '@ts-graphviz/common';
|
|
|
8
8
|
import { RootGraphModel } from '@ts-graphviz/common';
|
|
9
9
|
import { SubgraphModel } from '@ts-graphviz/common';
|
|
10
10
|
|
|
11
|
-
declare interface AnyExpectation {
|
|
12
|
-
type: "any";
|
|
13
|
-
}
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
* ASTBaseNode is an interface that serves as the base for all AST nodes.
|
|
17
13
|
* It requires all leaf interfaces to specify a type property,
|
|
@@ -149,16 +145,6 @@ export declare interface BuilderOptions {
|
|
|
149
145
|
locationFunction: () => FileRange;
|
|
150
146
|
}
|
|
151
147
|
|
|
152
|
-
declare interface ClassExpectation {
|
|
153
|
-
type: "class";
|
|
154
|
-
parts: ClassParts;
|
|
155
|
-
inverted: boolean;
|
|
156
|
-
ignoreCase: boolean;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
declare interface ClassParts extends Array<string | ClassParts> {
|
|
160
|
-
}
|
|
161
|
-
|
|
162
148
|
/**
|
|
163
149
|
* ClusterStatementASTNode is a type used to represent a statement in a cluster graph.
|
|
164
150
|
* @group AST
|
|
@@ -394,10 +380,19 @@ export declare interface DotASTPropaties extends ASTCommonPropaties {
|
|
|
394
380
|
}
|
|
395
381
|
|
|
396
382
|
/**
|
|
383
|
+
* DotSyntaxError is a class that extends the SyntaxError class and provides additional information about the syntax error.
|
|
384
|
+
*
|
|
397
385
|
* @group Convert DOT to AST
|
|
386
|
+
*
|
|
387
|
+
* @remarks
|
|
388
|
+
* This error is thrown when a parsing error occurs.
|
|
389
|
+
* The error provides additional information about the syntax error.
|
|
390
|
+
*
|
|
391
|
+
* This is in reference to the specification
|
|
392
|
+
* that the error thrown when a parse error occurs in the {@link !JSON.parse} function is {@link !SyntaxError}.
|
|
398
393
|
*/
|
|
399
|
-
export declare class DotSyntaxError extends
|
|
400
|
-
constructor(...args: ConstructorParameters<typeof
|
|
394
|
+
export declare class DotSyntaxError extends SyntaxError {
|
|
395
|
+
constructor(...args: ConstructorParameters<typeof SyntaxError>);
|
|
401
396
|
}
|
|
402
397
|
|
|
403
398
|
/**
|
|
@@ -431,18 +426,12 @@ export declare interface EdgeASTPropaties extends ASTCommonPropaties {
|
|
|
431
426
|
*/
|
|
432
427
|
export declare type EdgeTargetASTNode = NodeRefASTNode | NodeRefGroupASTNode;
|
|
433
428
|
|
|
434
|
-
declare interface EndExpectation {
|
|
435
|
-
type: "end";
|
|
436
|
-
}
|
|
437
|
-
|
|
438
429
|
/**
|
|
439
430
|
* This type represents the EndOfLine type which is used to determine the type of line ending to be used when writing to a file.
|
|
440
431
|
* @group Convert AST to DOT
|
|
441
432
|
*/
|
|
442
433
|
export declare type EndOfLine = 'lf' | 'crlf';
|
|
443
434
|
|
|
444
|
-
declare type Expectation = LiteralExpectation | ClassExpectation | AnyExpectation | EndExpectation | OtherExpectation;
|
|
445
|
-
|
|
446
435
|
/**
|
|
447
436
|
* The FilePosition interface represents the position of a file in terms of its offset, line number, and column number.
|
|
448
437
|
*
|
|
@@ -463,12 +452,6 @@ export declare interface FilePosition {
|
|
|
463
452
|
column: number;
|
|
464
453
|
}
|
|
465
454
|
|
|
466
|
-
declare interface FilePosition_2 {
|
|
467
|
-
offset: number;
|
|
468
|
-
line: number;
|
|
469
|
-
column: number;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
455
|
/**
|
|
473
456
|
* FileRange interface represents a range of positions within a file.
|
|
474
457
|
* @group AST
|
|
@@ -484,12 +467,6 @@ export declare interface FileRange {
|
|
|
484
467
|
end: FilePosition;
|
|
485
468
|
}
|
|
486
469
|
|
|
487
|
-
declare interface FileRange_2 {
|
|
488
|
-
start: FilePosition_2;
|
|
489
|
-
end: FilePosition_2;
|
|
490
|
-
source: string;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
470
|
/**
|
|
494
471
|
* A function used to convert a DotObjectModel into an AST.
|
|
495
472
|
*
|
|
@@ -579,12 +556,6 @@ export declare interface LiteralASTPropaties<T extends string = string> extends
|
|
|
579
556
|
quoted: boolean | 'html';
|
|
580
557
|
}
|
|
581
558
|
|
|
582
|
-
declare interface LiteralExpectation {
|
|
583
|
-
type: "literal";
|
|
584
|
-
text: string;
|
|
585
|
-
ignoreCase: boolean;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
559
|
/**
|
|
589
560
|
* ModelOf is a type that determines the type of model to use depending on the value of T.
|
|
590
561
|
* @group AST
|
|
@@ -660,11 +631,6 @@ export declare interface NodeRefGroupASTNode extends ASTBaseParentNode<NodeRefAS
|
|
|
660
631
|
export declare interface NodeRefGroupASTPropaties extends ASTCommonPropaties {
|
|
661
632
|
}
|
|
662
633
|
|
|
663
|
-
declare interface OtherExpectation {
|
|
664
|
-
type: "other";
|
|
665
|
-
description: string;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
634
|
/**
|
|
669
635
|
* parse is a function that takes a string input and optional parse options and
|
|
670
636
|
* returns an ASTNode or an array of ClusterStatementASTNodes.
|
|
@@ -682,7 +648,7 @@ declare interface OtherExpectation {
|
|
|
682
648
|
* - {@link SubgraphASTNode}
|
|
683
649
|
* - {@link ClusterStatementASTNode}
|
|
684
650
|
*
|
|
685
|
-
* @throws {@link
|
|
651
|
+
* @throws {@link DotSyntaxError}
|
|
686
652
|
* @group Convert DOT to AST
|
|
687
653
|
*/
|
|
688
654
|
export declare function parse(input: string): DotASTNode;
|
|
@@ -714,24 +680,6 @@ declare interface OtherExpectation {
|
|
|
714
680
|
startRule?: T;
|
|
715
681
|
}
|
|
716
682
|
|
|
717
|
-
declare const PeggySyntaxError: typeof _PeggySyntaxError;
|
|
718
|
-
|
|
719
|
-
declare type PeggySyntaxError = _PeggySyntaxError;
|
|
720
|
-
|
|
721
|
-
declare class _PeggySyntaxError extends Error {
|
|
722
|
-
static buildMessage(expected: Expectation[], found: string | null): string;
|
|
723
|
-
message: string;
|
|
724
|
-
expected: Expectation[];
|
|
725
|
-
found: string | null;
|
|
726
|
-
location: FileRange_2;
|
|
727
|
-
name: string;
|
|
728
|
-
constructor(message: string, expected: Expectation[], found: string | null, location: FileRange_2);
|
|
729
|
-
format(sources: {
|
|
730
|
-
source?: any;
|
|
731
|
-
text: string;
|
|
732
|
-
}[]): string;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
683
|
/**
|
|
736
684
|
* PrintContext interface provides an interface for printing an ASTNode with a set of options.
|
|
737
685
|
* @group Convert AST to DOT
|
package/lib/ast.js
CHANGED
|
@@ -3104,12 +3104,16 @@ function parse(input, options) {
|
|
|
3104
3104
|
return parse$1(input, options);
|
|
3105
3105
|
} catch (e) {
|
|
3106
3106
|
if (e instanceof PeggySyntaxError) {
|
|
3107
|
-
throw new DotSyntaxError(e.message,
|
|
3107
|
+
throw new DotSyntaxError(e.message, {
|
|
3108
|
+
cause: e
|
|
3109
|
+
});
|
|
3108
3110
|
}
|
|
3109
|
-
throw
|
|
3111
|
+
throw new Error("Unexpected parse error", {
|
|
3112
|
+
cause: e
|
|
3113
|
+
});
|
|
3110
3114
|
}
|
|
3111
3115
|
}
|
|
3112
|
-
class DotSyntaxError extends
|
|
3116
|
+
class DotSyntaxError extends SyntaxError {
|
|
3113
3117
|
constructor(...args) {
|
|
3114
3118
|
super(...args);
|
|
3115
3119
|
this.name = "DotSyntaxError";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-graphviz/ast",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7-next-f8ba9a89f3ac9e916ded16f0a0618113a5eb4928",
|
|
4
4
|
"description": "Graphviz AST(Abstract Syntax Tree) Utilities",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/ts-graphviz/ts-graphviz#readme",
|