pdl-editor 0.30.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.
@@ -0,0 +1,117 @@
1
+ import React from 'react';
2
+ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
3
+
4
+ declare const PDL_LANGUAGE_ID = "pdl";
5
+ declare const PDL_SCOPE_NAME = "source.pdl";
6
+ declare const PDL_THEME_NAME = "pdl-playground";
7
+ declare const PDL_MARKER_OWNER = "pdl-wasm";
8
+ declare const PDL_DEFAULT_MODEL_URI = "inmemory://pdl/main.pdl";
9
+ interface TextPosition {
10
+ line: number;
11
+ character: number;
12
+ }
13
+ interface TextRange {
14
+ start: TextPosition;
15
+ end: TextPosition;
16
+ }
17
+ interface PdlEditorDiagnostic {
18
+ range: TextRange;
19
+ severity: "error" | "warning" | "info" | "hint";
20
+ code: string;
21
+ message: string;
22
+ }
23
+ interface PdlCompletion {
24
+ label: string;
25
+ insert_text: string;
26
+ detail: string;
27
+ kind: "Binding" | "Column" | "Context" | "Format" | "Function" | "Keyword" | "Stage";
28
+ }
29
+ interface PdlHover {
30
+ range: TextRange;
31
+ markdown: string;
32
+ }
33
+ interface PdlTextEdit {
34
+ range: TextRange;
35
+ new_text: string;
36
+ }
37
+ interface PdlSemanticToken {
38
+ range: TextRange;
39
+ token_type: "Keyword" | "Function" | "Variable" | "String" | "Number" | "Operator" | "BindingDeclaration" | "BindingReference" | "ColumnDefinition" | "ColumnReference" | "ContextDeclaration" | "ContextReference";
40
+ }
41
+ type PdlEditorFeatureRequest = {
42
+ kind: "diagnostics";
43
+ } | {
44
+ kind: "hover";
45
+ position: TextPosition;
46
+ } | {
47
+ kind: "completion";
48
+ position: TextPosition;
49
+ } | {
50
+ kind: "formatting";
51
+ } | {
52
+ kind: "semanticTokens";
53
+ } | {
54
+ kind: "documentSymbols";
55
+ } | {
56
+ kind: "definition";
57
+ position: TextPosition;
58
+ } | {
59
+ kind: "references";
60
+ position: TextPosition;
61
+ } | {
62
+ kind: "rename";
63
+ position: TextPosition;
64
+ newName: string;
65
+ };
66
+ interface PdlEditorServiceResult<T = unknown> {
67
+ diagnostics: PdlEditorDiagnostic[];
68
+ result: T;
69
+ error: string | null;
70
+ }
71
+ interface PdlEditorRuntime {
72
+ editorService<T = unknown>(source: string, files: Record<string, string>, request: PdlEditorFeatureRequest, programPath?: string): PdlEditorServiceResult<T>;
73
+ }
74
+ interface PdlEditorProps {
75
+ value: string;
76
+ files: Record<string, string>;
77
+ diagnostics: PdlEditorDiagnostic[];
78
+ runtime: PdlEditorRuntime | null;
79
+ onChange: (value: string) => void;
80
+ modelUri?: string;
81
+ languageId?: string;
82
+ themeName?: string;
83
+ theme?: monaco.editor.IStandaloneThemeData;
84
+ className?: string;
85
+ editorClassName?: string;
86
+ options?: monaco.editor.IStandaloneEditorConstructionOptions;
87
+ setupOptions?: SetupPdlMonacoOptions;
88
+ }
89
+ interface RegisterPdlProvidersOptions {
90
+ languageId?: string;
91
+ getRuntime: (model: monaco.editor.ITextModel) => PdlEditorRuntime | null;
92
+ getFiles: (model: monaco.editor.ITextModel) => Record<string, string>;
93
+ programPathForModel?: (model: monaco.editor.ITextModel) => string;
94
+ }
95
+ interface SetupPdlMonacoOptions {
96
+ languageId?: string;
97
+ aliases?: string[];
98
+ extensions?: string[];
99
+ scopeName?: string;
100
+ themeName?: string;
101
+ theme?: monaco.editor.IStandaloneThemeData;
102
+ grammar?: unknown;
103
+ languageConfiguration?: monaco.languages.LanguageConfiguration;
104
+ onigasmWasmUrl?: string;
105
+ configureWorker?: boolean;
106
+ }
107
+ declare function PdlEditor({ value, files, diagnostics, runtime, onChange, modelUri, languageId, themeName, theme, className, editorClassName, options, setupOptions, }: PdlEditorProps): React.ReactElement;
108
+ declare function setupPdlMonaco(options?: SetupPdlMonacoOptions): Promise<void>;
109
+ declare function registerPdlLanguage(options?: SetupPdlMonacoOptions): void;
110
+ declare function definePdlTheme(themeName?: string, theme?: monaco.editor.IStandaloneThemeData): void;
111
+ declare function defaultPdlTheme(): monaco.editor.IStandaloneThemeData;
112
+ declare function registerPdlEditorProviders(options: RegisterPdlProvidersOptions): monaco.IDisposable;
113
+ declare function programPathForModel(model: monaco.editor.ITextModel): string;
114
+ declare function setPdlMarkers(model: monaco.editor.ITextModel, diagnostics: PdlEditorDiagnostic[]): void;
115
+ declare function diagnosticToPdlMarker(diagnostic: PdlEditorDiagnostic): monaco.editor.IMarkerData;
116
+
117
+ export { PDL_DEFAULT_MODEL_URI, PDL_LANGUAGE_ID, PDL_MARKER_OWNER, PDL_SCOPE_NAME, PDL_THEME_NAME, type PdlCompletion, PdlEditor, type PdlEditorDiagnostic, type PdlEditorFeatureRequest, type PdlEditorProps, type PdlEditorRuntime, type PdlEditorServiceResult, type PdlHover, type PdlSemanticToken, type PdlTextEdit, type RegisterPdlProvidersOptions, type SetupPdlMonacoOptions, type TextPosition, type TextRange, defaultPdlTheme, definePdlTheme, diagnosticToPdlMarker, programPathForModel, registerPdlEditorProviders, registerPdlLanguage, setPdlMarkers, setupPdlMonaco };
@@ -0,0 +1,117 @@
1
+ import React from 'react';
2
+ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
3
+
4
+ declare const PDL_LANGUAGE_ID = "pdl";
5
+ declare const PDL_SCOPE_NAME = "source.pdl";
6
+ declare const PDL_THEME_NAME = "pdl-playground";
7
+ declare const PDL_MARKER_OWNER = "pdl-wasm";
8
+ declare const PDL_DEFAULT_MODEL_URI = "inmemory://pdl/main.pdl";
9
+ interface TextPosition {
10
+ line: number;
11
+ character: number;
12
+ }
13
+ interface TextRange {
14
+ start: TextPosition;
15
+ end: TextPosition;
16
+ }
17
+ interface PdlEditorDiagnostic {
18
+ range: TextRange;
19
+ severity: "error" | "warning" | "info" | "hint";
20
+ code: string;
21
+ message: string;
22
+ }
23
+ interface PdlCompletion {
24
+ label: string;
25
+ insert_text: string;
26
+ detail: string;
27
+ kind: "Binding" | "Column" | "Context" | "Format" | "Function" | "Keyword" | "Stage";
28
+ }
29
+ interface PdlHover {
30
+ range: TextRange;
31
+ markdown: string;
32
+ }
33
+ interface PdlTextEdit {
34
+ range: TextRange;
35
+ new_text: string;
36
+ }
37
+ interface PdlSemanticToken {
38
+ range: TextRange;
39
+ token_type: "Keyword" | "Function" | "Variable" | "String" | "Number" | "Operator" | "BindingDeclaration" | "BindingReference" | "ColumnDefinition" | "ColumnReference" | "ContextDeclaration" | "ContextReference";
40
+ }
41
+ type PdlEditorFeatureRequest = {
42
+ kind: "diagnostics";
43
+ } | {
44
+ kind: "hover";
45
+ position: TextPosition;
46
+ } | {
47
+ kind: "completion";
48
+ position: TextPosition;
49
+ } | {
50
+ kind: "formatting";
51
+ } | {
52
+ kind: "semanticTokens";
53
+ } | {
54
+ kind: "documentSymbols";
55
+ } | {
56
+ kind: "definition";
57
+ position: TextPosition;
58
+ } | {
59
+ kind: "references";
60
+ position: TextPosition;
61
+ } | {
62
+ kind: "rename";
63
+ position: TextPosition;
64
+ newName: string;
65
+ };
66
+ interface PdlEditorServiceResult<T = unknown> {
67
+ diagnostics: PdlEditorDiagnostic[];
68
+ result: T;
69
+ error: string | null;
70
+ }
71
+ interface PdlEditorRuntime {
72
+ editorService<T = unknown>(source: string, files: Record<string, string>, request: PdlEditorFeatureRequest, programPath?: string): PdlEditorServiceResult<T>;
73
+ }
74
+ interface PdlEditorProps {
75
+ value: string;
76
+ files: Record<string, string>;
77
+ diagnostics: PdlEditorDiagnostic[];
78
+ runtime: PdlEditorRuntime | null;
79
+ onChange: (value: string) => void;
80
+ modelUri?: string;
81
+ languageId?: string;
82
+ themeName?: string;
83
+ theme?: monaco.editor.IStandaloneThemeData;
84
+ className?: string;
85
+ editorClassName?: string;
86
+ options?: monaco.editor.IStandaloneEditorConstructionOptions;
87
+ setupOptions?: SetupPdlMonacoOptions;
88
+ }
89
+ interface RegisterPdlProvidersOptions {
90
+ languageId?: string;
91
+ getRuntime: (model: monaco.editor.ITextModel) => PdlEditorRuntime | null;
92
+ getFiles: (model: monaco.editor.ITextModel) => Record<string, string>;
93
+ programPathForModel?: (model: monaco.editor.ITextModel) => string;
94
+ }
95
+ interface SetupPdlMonacoOptions {
96
+ languageId?: string;
97
+ aliases?: string[];
98
+ extensions?: string[];
99
+ scopeName?: string;
100
+ themeName?: string;
101
+ theme?: monaco.editor.IStandaloneThemeData;
102
+ grammar?: unknown;
103
+ languageConfiguration?: monaco.languages.LanguageConfiguration;
104
+ onigasmWasmUrl?: string;
105
+ configureWorker?: boolean;
106
+ }
107
+ declare function PdlEditor({ value, files, diagnostics, runtime, onChange, modelUri, languageId, themeName, theme, className, editorClassName, options, setupOptions, }: PdlEditorProps): React.ReactElement;
108
+ declare function setupPdlMonaco(options?: SetupPdlMonacoOptions): Promise<void>;
109
+ declare function registerPdlLanguage(options?: SetupPdlMonacoOptions): void;
110
+ declare function definePdlTheme(themeName?: string, theme?: monaco.editor.IStandaloneThemeData): void;
111
+ declare function defaultPdlTheme(): monaco.editor.IStandaloneThemeData;
112
+ declare function registerPdlEditorProviders(options: RegisterPdlProvidersOptions): monaco.IDisposable;
113
+ declare function programPathForModel(model: monaco.editor.ITextModel): string;
114
+ declare function setPdlMarkers(model: monaco.editor.ITextModel, diagnostics: PdlEditorDiagnostic[]): void;
115
+ declare function diagnosticToPdlMarker(diagnostic: PdlEditorDiagnostic): monaco.editor.IMarkerData;
116
+
117
+ export { PDL_DEFAULT_MODEL_URI, PDL_LANGUAGE_ID, PDL_MARKER_OWNER, PDL_SCOPE_NAME, PDL_THEME_NAME, type PdlCompletion, PdlEditor, type PdlEditorDiagnostic, type PdlEditorFeatureRequest, type PdlEditorProps, type PdlEditorRuntime, type PdlEditorServiceResult, type PdlHover, type PdlSemanticToken, type PdlTextEdit, type RegisterPdlProvidersOptions, type SetupPdlMonacoOptions, type TextPosition, type TextRange, defaultPdlTheme, definePdlTheme, diagnosticToPdlMarker, programPathForModel, registerPdlEditorProviders, registerPdlLanguage, setPdlMarkers, setupPdlMonaco };