react-dsl-editor 0.3.2 → 0.4.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/dist/index.d.ts +25 -12
- package/dist/react-dsl-editor.js +947 -1016
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export declare interface CSTNode<T extends string> {
|
|
|
17
17
|
|
|
18
18
|
export declare type CSTOf<T> = CSTNode<_NodeTypes<T>>;
|
|
19
19
|
|
|
20
|
+
export declare function defaultSyntaxColors(theme: keyof typeof themes): (node: CSTNode<string>) => CSSProperties | undefined;
|
|
21
|
+
|
|
20
22
|
export declare interface DSL<T extends string> {
|
|
21
23
|
cst: CSTNode<T>;
|
|
22
24
|
terminals: CSTNode<T>[];
|
|
@@ -38,29 +40,30 @@ export declare function DslEditor<T extends string>({ code, onChange, onParsed,
|
|
|
38
40
|
|
|
39
41
|
export declare interface DSLError {
|
|
40
42
|
message: string;
|
|
43
|
+
expected?: string[];
|
|
41
44
|
start: number;
|
|
42
45
|
end: number;
|
|
46
|
+
depth: number;
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
export declare class DSLParser<T extends string> {
|
|
46
50
|
private readonly grammar;
|
|
47
51
|
constructor(grammar: GrammarNode<T>);
|
|
52
|
+
private _parseStrict;
|
|
53
|
+
parseStrict(input: string): ParserSuccess<T> | undefined;
|
|
48
54
|
parse(input: string): DSL<T>;
|
|
49
55
|
}
|
|
50
56
|
|
|
51
|
-
export declare const eof: GrammarNode
|
|
57
|
+
export declare const eof: GrammarNode<never>;
|
|
52
58
|
|
|
53
|
-
export declare function error<T extends string>(param:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
got: string;
|
|
57
|
-
expected: string[];
|
|
58
|
-
};
|
|
59
|
+
export declare function error<T extends string>(param: ParserError<T>): ParserError<T>;
|
|
60
|
+
|
|
61
|
+
export declare type FaultToleranceMode = 'skip-parser' | 'skip-input' | 'fuzzy-match' | 'partial-match';
|
|
59
62
|
|
|
60
63
|
export declare interface GrammarNode<T extends string = never> {
|
|
61
64
|
type: T;
|
|
62
65
|
suggestions(): string[];
|
|
63
|
-
parse(text: string, context: ParserContext): ParserResult<T>;
|
|
66
|
+
parse(text: string, context: ParserContext<T>): ParserResult<T>;
|
|
64
67
|
children: GrammarNode<T>[];
|
|
65
68
|
meta?: Record<string, unknown>;
|
|
66
69
|
}
|
|
@@ -71,15 +74,19 @@ export declare function isParserSuccess<T extends string>(result: ParserResult<T
|
|
|
71
74
|
|
|
72
75
|
export declare function named<T extends string, K extends string>(name: T, child: GrammarNode<K>): GrammarNode<T | K>;
|
|
73
76
|
|
|
77
|
+
export declare function nodeName<T extends string>(node: {
|
|
78
|
+
grammar: GrammarNode<T>;
|
|
79
|
+
}): T | undefined;
|
|
80
|
+
|
|
74
81
|
export declare type NodeTypes<T> = _NodeTypes<T> | 'error';
|
|
75
82
|
|
|
76
83
|
declare type _NodeTypes<T> = T extends GrammarNode<infer U> ? U : never;
|
|
77
84
|
|
|
78
85
|
export declare function optional<T extends string>(child: GrammarNode<T>): GrammarNode<T>;
|
|
79
86
|
|
|
80
|
-
export declare interface ParserContext {
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
export declare interface ParserContext<T extends string> {
|
|
88
|
+
path: GrammarNode<T>[];
|
|
89
|
+
handleTerminalError(text: string, context: ParserContext<T>, grammar: GrammarNode<T>): ParserResult<T>;
|
|
83
90
|
}
|
|
84
91
|
|
|
85
92
|
export declare interface ParserError<T extends string = never> {
|
|
@@ -87,6 +94,7 @@ export declare interface ParserError<T extends string = never> {
|
|
|
87
94
|
got: string;
|
|
88
95
|
expected: string[];
|
|
89
96
|
offset: number;
|
|
97
|
+
path: GrammarNode<T>[];
|
|
90
98
|
}
|
|
91
99
|
|
|
92
100
|
export declare type ParserResult<T extends string = never> = ParserSuccess<T> | ParserError<T>;
|
|
@@ -114,10 +122,15 @@ export declare function sequence<T extends string>(...nodes: GrammarNode<T>[]):
|
|
|
114
122
|
|
|
115
123
|
export declare function success<T extends string>(param: ParserSuccess<T>): ParserSuccess<T>;
|
|
116
124
|
|
|
117
|
-
declare type SyntaxColorsProvider = (node: CSTNode<string>) => CSSProperties | undefined;
|
|
125
|
+
export declare type SyntaxColorsProvider = (node: CSTNode<string>) => CSSProperties | undefined;
|
|
118
126
|
|
|
119
127
|
export declare function term(str: string): GrammarNode<never>;
|
|
120
128
|
|
|
129
|
+
declare const themes: {
|
|
130
|
+
readonly light: string[];
|
|
131
|
+
readonly dark: string[];
|
|
132
|
+
};
|
|
133
|
+
|
|
121
134
|
export declare function visit<T extends string, V = string>(parserResult: ParserSuccess<T>, type: T[], extractor?: (node: ParserSuccess<T>) => V): V[];
|
|
122
135
|
|
|
123
136
|
export declare const ws: GrammarNode<never>;
|