react-dsl-editor 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +24 -5
- package/dist/react-dsl-editor.js +654 -574
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
1
2
|
import { JSX } from 'react/jsx-runtime';
|
|
2
3
|
import { TextareaHTMLAttributes } from 'react';
|
|
3
4
|
|
|
@@ -11,6 +12,7 @@ export declare interface CSTNode<T extends string> {
|
|
|
11
12
|
end: number;
|
|
12
13
|
grammar: GrammarNode<T>;
|
|
13
14
|
children?: CSTNode<T>[];
|
|
15
|
+
recoverableError: boolean;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export declare type CSTOf<T> = CSTNode<_NodeTypes<T>>;
|
|
@@ -19,28 +21,41 @@ export declare interface DSL<T extends string> {
|
|
|
19
21
|
cst: CSTNode<T>;
|
|
20
22
|
terminals: CSTNode<T>[];
|
|
21
23
|
result: ParserSuccess<T>;
|
|
24
|
+
strictResult: ParserSuccess<T> | undefined;
|
|
25
|
+
errors: DSLError[];
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
export declare function DslEditor<T extends string>({ code, onChange, onParsed, grammar, wrap, suggestions: clientSuggestions, className, ...textareaProps }: {
|
|
28
|
+
export declare function DslEditor<T extends string>({ code, onChange, onParsed, grammar, wrap, suggestions: clientSuggestions, className, syntaxColors, ...textareaProps }: {
|
|
25
29
|
code: string;
|
|
26
30
|
onChange: (text: string) => void;
|
|
27
|
-
onParsed?: (
|
|
31
|
+
onParsed?: (dsl: DSL<T>) => void;
|
|
28
32
|
grammar: GrammarNode<T>;
|
|
29
33
|
wrap?: boolean;
|
|
30
34
|
className?: string;
|
|
31
35
|
suggestions?: (node: CSTNode<T>) => string[] | undefined;
|
|
36
|
+
syntaxColors?: SyntaxColorsProvider;
|
|
32
37
|
} & Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'wrap' | 'onChange'>): JSX.Element;
|
|
33
38
|
|
|
39
|
+
export declare interface DSLError {
|
|
40
|
+
message: string;
|
|
41
|
+
start: number;
|
|
42
|
+
end: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
34
45
|
export declare class DSLParser<T extends string> {
|
|
35
46
|
private readonly grammar;
|
|
36
47
|
constructor(grammar: GrammarNode<T>);
|
|
37
|
-
private _parse;
|
|
38
48
|
parse(input: string): DSL<T>;
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
export declare const eof: GrammarNode;
|
|
42
52
|
|
|
43
|
-
export declare function error<T extends string>(param: ParserError<T>):
|
|
53
|
+
export declare function error<T extends string>(param: Omit<ParserError<T>, 'offset'>): {
|
|
54
|
+
offset: number;
|
|
55
|
+
grammar: GrammarNode<T>;
|
|
56
|
+
got: string;
|
|
57
|
+
expected: string[];
|
|
58
|
+
};
|
|
44
59
|
|
|
45
60
|
export declare interface GrammarNode<T extends string = never> {
|
|
46
61
|
type: T;
|
|
@@ -71,6 +86,7 @@ export declare interface ParserError<T extends string = never> {
|
|
|
71
86
|
grammar: GrammarNode<T>;
|
|
72
87
|
got: string;
|
|
73
88
|
expected: string[];
|
|
89
|
+
offset: number;
|
|
74
90
|
}
|
|
75
91
|
|
|
76
92
|
export declare type ParserResult<T extends string = never> = ParserSuccess<T> | ParserError<T>;
|
|
@@ -79,6 +95,7 @@ export declare interface ParserSuccess<T extends string = never> {
|
|
|
79
95
|
text: string;
|
|
80
96
|
grammar: GrammarNode<T>;
|
|
81
97
|
children: ParserSuccess<T>[];
|
|
98
|
+
recoverableError?: boolean;
|
|
82
99
|
}
|
|
83
100
|
|
|
84
101
|
export declare class ParsingError extends Error {
|
|
@@ -97,9 +114,11 @@ export declare function sequence<T extends string>(...nodes: GrammarNode<T>[]):
|
|
|
97
114
|
|
|
98
115
|
export declare function success<T extends string>(param: ParserSuccess<T>): ParserSuccess<T>;
|
|
99
116
|
|
|
117
|
+
declare type SyntaxColorsProvider = (node: CSTNode<string>) => CSSProperties | undefined;
|
|
118
|
+
|
|
100
119
|
export declare function term(str: string): GrammarNode<never>;
|
|
101
120
|
|
|
102
|
-
export declare function visit<T extends string, V = string>(parserResult: ParserSuccess<T>, type: T, extractor?: (node: ParserSuccess<T>) => V): V[];
|
|
121
|
+
export declare function visit<T extends string, V = string>(parserResult: ParserSuccess<T>, type: T[], extractor?: (node: ParserSuccess<T>) => V): V[];
|
|
103
122
|
|
|
104
123
|
export declare const ws: GrammarNode<never>;
|
|
105
124
|
|