@aardarch/aardink-web 0.9.0 → 0.10.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/index.d.ts +237 -15
- package/index.js +103 -29
- package/kotlin/aardink-web.mjs +2 -0
- package/kotlin/aardink-web.wasm +0 -0
- package/package.json +1 -1
- package/kotlin/js-reexport-symbols.mjs +0 -999
- package/kotlin/skikod8.mjs +0 -1118
package/index.d.ts
CHANGED
|
@@ -20,11 +20,57 @@ export interface AardinkOptions {
|
|
|
20
20
|
value?: string;
|
|
21
21
|
/** A language id: kotlin, typescript, json, toml, xml, html, css, markdown, plaintext. */
|
|
22
22
|
language?: string;
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* vscode-dark (or Monaco's `vs-dark`), vscode-light (or `vs`), hc-black, hc-light, material-dark,
|
|
25
|
+
* material-light, midnight-ocean, solarized-dark, or a name given to `defineTheme`.
|
|
26
|
+
*/
|
|
24
27
|
theme?: string;
|
|
25
28
|
/** In CSS pixels. */
|
|
26
29
|
fontSize?: number;
|
|
27
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Monaco's `fontFamily`, a CSS font list: the first name in it given to `registerFont` is the
|
|
32
|
+
* editor's font, else the bundled JetBrains Mono. A font the page has only in CSS is not seen: the
|
|
33
|
+
* editor draws on a canvas, with the fonts it was given.
|
|
34
|
+
*/
|
|
35
|
+
fontFamily?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Monaco's `wordWrap`: `'on'` wraps at the edge of the view, `'wordWrapColumn'` and `'bounded'`
|
|
38
|
+
* at `wordWrapColumn` or the edge, whichever comes first. `'off'` by default, as Monaco's (on
|
|
39
|
+
* before 0.10).
|
|
40
|
+
*/
|
|
41
|
+
wordWrap?: 'on' | 'off' | 'wordWrapColumn' | 'bounded';
|
|
42
|
+
/** Where `wordWrap: 'wordWrapColumn'` or `'bounded'` wraps. 80 by default. */
|
|
43
|
+
wordWrapColumn?: number;
|
|
44
|
+
/** How wrapped rows are indented, as Monaco's. `'none'` by default, where Monaco's is `'same'`. */
|
|
45
|
+
wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent';
|
|
46
|
+
/**
|
|
47
|
+
* Monaco's `lineNumbers`: `'relative'` counts from the caret's line, `'interval'` shows every
|
|
48
|
+
* tenth and the caret's. Monaco's function form is not taken: it counts as `'on'`.
|
|
49
|
+
*/
|
|
50
|
+
lineNumbers?: 'on' | 'off' | 'relative' | 'interval';
|
|
51
|
+
/** Columns with a vertical line. Monaco's `{ column, color }` takes its column; the colour is the theme's. */
|
|
52
|
+
rulers?: Array<number | { column: number; color?: string | null }>;
|
|
53
|
+
/**
|
|
54
|
+
* Monaco's `guides`: `indentation`, a faint line down each level of indentation (the caret's
|
|
55
|
+
* block's stronger), and `bracketPairs`, a line from each bracket to its partner (`'active'`
|
|
56
|
+
* shows them all). Both off by default, where Monaco's indentation guides are on.
|
|
57
|
+
*/
|
|
58
|
+
guides?: { indentation?: boolean; bracketPairs?: boolean | 'active' };
|
|
59
|
+
/** The caret's shape. `'line'` by default. */
|
|
60
|
+
cursorStyle?: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin';
|
|
61
|
+
/** How the caret blinks; `'phase'` and `'expand'` fade as `'smooth'` does. `'blink'` by default. */
|
|
62
|
+
cursorBlinking?: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid';
|
|
63
|
+
/** The editor's own scrolls (to the caret, Page Up and Down) animate. Off by default. */
|
|
64
|
+
smoothScrolling?: boolean;
|
|
65
|
+
/** The last line can scroll up to the top of the view. Off by default, where Monaco's is on. */
|
|
66
|
+
scrollBeyondLastLine?: boolean;
|
|
67
|
+
/** Lines kept visible above and below the caret as it moves. 0 by default. */
|
|
68
|
+
cursorSurroundingLines?: number;
|
|
69
|
+
/**
|
|
70
|
+
* A selection dragged with the mouse moves; with Ctrl (Alt on macOS) held, copies. Off by
|
|
71
|
+
* default, where Monaco's is on.
|
|
72
|
+
*/
|
|
73
|
+
dragAndDrop?: boolean;
|
|
28
74
|
readOnly?: boolean;
|
|
29
75
|
showGutter?: boolean;
|
|
30
76
|
showLineNumbers?: boolean;
|
|
@@ -73,6 +119,20 @@ export interface AardinkOptions {
|
|
|
73
119
|
* default, where Monaco's is on.
|
|
74
120
|
*/
|
|
75
121
|
codeLens?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Typing one of `autoFormatTriggerCharacters` asks `provideOnTypeFormattingEdits` (or a language
|
|
124
|
+
* server) to tidy the text around it, as Monaco's `formatOnType`. Undo takes the edits back and
|
|
125
|
+
* keeps what was typed. Off by default.
|
|
126
|
+
*/
|
|
127
|
+
formatOnType?: boolean;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** What `onSearchWorkspace` is called with: VS Code's Find in Files arguments. */
|
|
131
|
+
export interface AardinkWorkspaceSearch {
|
|
132
|
+
query: string;
|
|
133
|
+
isRegex: boolean;
|
|
134
|
+
isCaseSensitive: boolean;
|
|
135
|
+
matchWholeWord: boolean;
|
|
76
136
|
}
|
|
77
137
|
|
|
78
138
|
/**
|
|
@@ -247,7 +307,8 @@ export interface AardinkEditor {
|
|
|
247
307
|
* `editor.action.addCommentLine`, `editor.action.removeCommentLine`, `editor.action.blockComment`,
|
|
248
308
|
* `editor.action.insertLineAfter` and `Before`, `expandLineSelection`,
|
|
249
309
|
* `editor.action.showColorPicker`, `editor.action.inlineSuggest.commit`, `.showNext`,
|
|
250
|
-
* `.showPrevious` and `.hide`,
|
|
310
|
+
* `.showPrevious` and `.hide`, VS Code's `workbench.action.findInFiles` (with an
|
|
311
|
+
* `onSearchWorkspace` listener), and
|
|
251
312
|
* `editor.action.insertSnippet` with `{ snippet }`. `source` is accepted for Monaco's shape.
|
|
252
313
|
* Returns whether it ran.
|
|
253
314
|
*/
|
|
@@ -300,6 +361,14 @@ export interface AardinkEditor {
|
|
|
300
361
|
* nothing. Returns a disposable.
|
|
301
362
|
*/
|
|
302
363
|
onOpenLink(listener: (target: string) => void): { dispose(): void };
|
|
364
|
+
/**
|
|
365
|
+
* Called when the editor hands a search to the page, by Ctrl/Cmd+Shift+F, the find panel's
|
|
366
|
+
* "Search all files" button or `trigger('workbench.action.findInFiles')`, with VS Code's Find in
|
|
367
|
+
* Files arguments: the selection on one line, else the find panel's query, and its options. While
|
|
368
|
+
* there is no listener, the button is not shown and the key is left to the page. Returns a
|
|
369
|
+
* disposable.
|
|
370
|
+
*/
|
|
371
|
+
onSearchWorkspace(listener: (search: AardinkWorkspaceSearch) => void): { dispose(): void };
|
|
303
372
|
/** Measures the container again now; the editor follows its container's size by itself. */
|
|
304
373
|
layout(): void;
|
|
305
374
|
/**
|
|
@@ -704,29 +773,170 @@ export interface AardinkLanguageProviders {
|
|
|
704
773
|
* What is shown in a row above the line each `range` starts on, as Monaco's `provideCodeLenses`,
|
|
705
774
|
* with the `codeLens` option on. It is about the whole text, and asked after a pause in typing;
|
|
706
775
|
* between answers each lens moves with its text. Lenses on one line share a row. An array, with no
|
|
707
|
-
* `{ lenses }` around it
|
|
776
|
+
* `{ lenses }` around it. A lens without a `command` is given to `resolveCodeLens`, if there is
|
|
777
|
+
* one, as the answer comes (at most 100 of them), and left out if it still has none. With
|
|
708
778
|
* `extends`, the base language's are added, less any with this one's position and title. With a
|
|
709
779
|
* language server these are shown after a second if it has not answered by then.
|
|
710
780
|
*/
|
|
711
781
|
provideCodeLenses?(text: string): AardinkCodeLens[] | null | Promise<AardinkCodeLens[] | null>;
|
|
712
782
|
/**
|
|
713
|
-
* A lens from `provideCodeLenses` was clicked or tapped
|
|
714
|
-
* `
|
|
715
|
-
*
|
|
783
|
+
* A lens from `provideCodeLenses` was clicked or tapped, or a code action from `provideCodeActions`
|
|
784
|
+
* with a `command` chosen (after its edits): the command's `id`, and its `arguments`, `[]` when it
|
|
785
|
+
* has none. As they passed through JSON, they hold only what JSON can. There is no command
|
|
786
|
+
* registry behind this: a lens or an action does what this does with its `id`.
|
|
716
787
|
*/
|
|
717
788
|
runCodeLensCommand?(id: string, args: unknown[]): void | Promise<void>;
|
|
789
|
+
/**
|
|
790
|
+
* The characters whose typing asks `provideOnTypeFormattingEdits`, as on Monaco's
|
|
791
|
+
* `OnTypeFormattingEditProvider`: `'}'`, `';'`, or `'\n'` for Enter.
|
|
792
|
+
*/
|
|
793
|
+
autoFormatTriggerCharacters?: string[];
|
|
794
|
+
/**
|
|
795
|
+
* Edits that tidy the text around what was just typed, as Monaco's `provideOnTypeFormattingEdits`,
|
|
796
|
+
* with the `formatOnType` option on. `line` and `column` are the caret's, after the character `ch`;
|
|
797
|
+
* the edits are applied as an undo step of their own, and dropped if the text changed while they
|
|
798
|
+
* were worked out. With `extends`, the base language's apply when this answers none.
|
|
799
|
+
*/
|
|
800
|
+
provideOnTypeFormattingEdits?(
|
|
801
|
+
text: string,
|
|
802
|
+
line: number,
|
|
803
|
+
column: number,
|
|
804
|
+
ch: string,
|
|
805
|
+
options: { tabSize: number; insertSpaces: boolean },
|
|
806
|
+
): AardinkTextEdit[] | null | Promise<AardinkTextEdit[] | null>;
|
|
807
|
+
/**
|
|
808
|
+
* Where the symbol at a 1-based `line` and `column` is defined, as Monaco's `provideDefinition`,
|
|
809
|
+
* for F12 and Ctrl/Cmd+click: a location, an array of them (the first is followed) or Monaco's
|
|
810
|
+
* `LocationLink`s. A location without `uri` is in this text; one with a `uri` is another file's,
|
|
811
|
+
* which the editor does not open.
|
|
812
|
+
*/
|
|
813
|
+
provideDefinition?(text: string, line: number, column: number): AardinkLocation | AardinkLocation[] | null | Promise<AardinkLocation | AardinkLocation[] | null>;
|
|
814
|
+
/** The references to the symbol at a place, as Monaco's `provideReferences`, for Shift+F12's list. */
|
|
815
|
+
provideReferences?(text: string, line: number, column: number): AardinkLocation[] | null | Promise<AardinkLocation[] | null>;
|
|
816
|
+
/**
|
|
817
|
+
* Edits that format the whole text, as Monaco's `provideDocumentFormattingEdits`, for Format
|
|
818
|
+
* Document (Shift+Alt+F) and `format()`. With `extends`, the base language formats when this
|
|
819
|
+
* changes nothing.
|
|
820
|
+
*/
|
|
821
|
+
provideDocumentFormattingEdits?(text: string, options: { tabSize: number; insertSpaces: boolean }): AardinkTextEdit[] | null | Promise<AardinkTextEdit[] | null>;
|
|
822
|
+
/** Edits that format `range`, as Monaco's `provideDocumentRangeFormattingEdits`, for Format Selection. */
|
|
823
|
+
provideDocumentRangeFormattingEdits?(
|
|
824
|
+
text: string,
|
|
825
|
+
range: AardinkRange,
|
|
826
|
+
options: { tabSize: number; insertSpaces: boolean },
|
|
827
|
+
): AardinkTextEdit[] | null | Promise<AardinkTextEdit[] | null>;
|
|
828
|
+
/**
|
|
829
|
+
* Accepted for Monaco's shape. The editor asks `provideSignatureHelp` whenever the caret is
|
|
830
|
+
* inside a call's arguments, so no character has to start it.
|
|
831
|
+
*/
|
|
832
|
+
signatureHelpTriggerCharacters?: string[];
|
|
833
|
+
/**
|
|
834
|
+
* The signatures of the call at a place, as Monaco's `provideSignatureHelp`: its
|
|
835
|
+
* `SignatureHelpResult` (`{ value }`) or the `SignatureHelp` in it. A parameter's `label` is its
|
|
836
|
+
* text or `[start, end]` in the signature's label.
|
|
837
|
+
*/
|
|
838
|
+
provideSignatureHelp?(text: string, line: number, column: number): AardinkSignatureHelp | { value: AardinkSignatureHelp } | null | Promise<AardinkSignatureHelp | { value: AardinkSignatureHelp } | null>;
|
|
839
|
+
/**
|
|
840
|
+
* Quick fixes and refactorings for `range`, as Monaco's `provideCodeActions`, with the markers of
|
|
841
|
+
* `provideDiagnostics`' last answer that touch it. An action with edits to another file (a
|
|
842
|
+
* `resource`) is left out; its `command` goes to `runCodeLensCommand` after its edits.
|
|
843
|
+
*/
|
|
844
|
+
provideCodeActions?(
|
|
845
|
+
text: string,
|
|
846
|
+
range: AardinkRange,
|
|
847
|
+
context: { markers: AardinkDiagnostic[] },
|
|
848
|
+
): AardinkCodeAction[] | { actions: AardinkCodeAction[] } | null | Promise<AardinkCodeAction[] | { actions: AardinkCodeAction[] } | null>;
|
|
849
|
+
/**
|
|
850
|
+
* The edits that rename the symbol at a place to `newName`, as Monaco's `provideRenameEdits`, for
|
|
851
|
+
* F2. Its presence offers rename. `{ rejectReason }`, or edits to another file, rename nothing.
|
|
852
|
+
*/
|
|
853
|
+
provideRenameEdits?(text: string, line: number, column: number, newName: string): AardinkWorkspaceEdit | { rejectReason: string } | null | Promise<AardinkWorkspaceEdit | { rejectReason: string } | null>;
|
|
854
|
+
/**
|
|
855
|
+
* What F2 would rename at a place, as Monaco's `resolveRenameLocation`: `{ range, text }`, or
|
|
856
|
+
* `{ rejectReason }` where nothing can be. Without it, the word at the caret.
|
|
857
|
+
*/
|
|
858
|
+
resolveRenameLocation?(text: string, line: number, column: number): { range: AardinkRange; text: string } | { rejectReason: string } | null | Promise<{ range: AardinkRange; text: string } | { rejectReason: string } | null>;
|
|
859
|
+
/**
|
|
860
|
+
* The text's folds, as Monaco's `provideFoldingRanges`: 1-based `start` and `end` lines. They
|
|
861
|
+
* replace the language's own (by indentation, or the base language's).
|
|
862
|
+
*/
|
|
863
|
+
provideFoldingRanges?(text: string): { start: number; end: number; kind?: 'comment' | 'imports' | 'region' }[] | null | Promise<{ start: number; end: number; kind?: 'comment' | 'imports' | 'region' }[] | null>;
|
|
864
|
+
/**
|
|
865
|
+
* What `provideDocumentSemanticTokens` numbers stand for, as Monaco's `getLegend()`. The token
|
|
866
|
+
* types are named as a theme colours them, as a language server's are: `class` as `type.class`,
|
|
867
|
+
* `parameter` as `variable.parameter`, `method` as `function.method`.
|
|
868
|
+
*/
|
|
869
|
+
getLegend?(): { tokenTypes: string[]; tokenModifiers: string[] };
|
|
870
|
+
/** The legend as data, in place of `getLegend`. */
|
|
871
|
+
legend?: { tokenTypes: string[]; tokenModifiers: string[] };
|
|
872
|
+
/**
|
|
873
|
+
* The text's semantic tokens, as Monaco's `provideDocumentSemanticTokens`: `{ data }`, five
|
|
874
|
+
* integers a token, coloured over the syntax's with the `semanticHighlighting` option on.
|
|
875
|
+
*/
|
|
876
|
+
provideDocumentSemanticTokens?(text: string): { data: ArrayLike<number>; resultId?: string } | null | Promise<{ data: ArrayLike<number>; resultId?: string } | null>;
|
|
877
|
+
/**
|
|
878
|
+
* More of an item, as Monaco's `resolveCompletionItem`: called with the item as
|
|
879
|
+
* `provideCompletionItems` gave it when it is selected in the list; its `documentation` and
|
|
880
|
+
* `detail` replace what the item had.
|
|
881
|
+
*/
|
|
882
|
+
resolveCompletionItem?(item: AardinkCompletionItem): AardinkCompletionItem | null | Promise<AardinkCompletionItem | null>;
|
|
883
|
+
/** A lens that came without a `command`, with one, as Monaco's `resolveCodeLens`. */
|
|
884
|
+
resolveCodeLens?(text: string, lens: AardinkCodeLens): AardinkCodeLens | null | Promise<AardinkCodeLens | null>;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/** Monaco's `Location`: `uri` left out for a place in this text. */
|
|
888
|
+
export interface AardinkLocation {
|
|
889
|
+
uri?: string;
|
|
890
|
+
range: AardinkRange;
|
|
718
891
|
}
|
|
719
892
|
|
|
720
|
-
/** Monaco's `
|
|
893
|
+
/** Monaco's `SignatureHelp`. */
|
|
894
|
+
export interface AardinkSignatureHelp {
|
|
895
|
+
signatures: {
|
|
896
|
+
label: string;
|
|
897
|
+
documentation?: string | { value: string };
|
|
898
|
+
parameters: { label: string | [number, number]; documentation?: string | { value: string } }[];
|
|
899
|
+
}[];
|
|
900
|
+
activeSignature: number;
|
|
901
|
+
activeParameter: number;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
/** Monaco's `WorkspaceEdit`, for this text: an edit with a `resource` is another file's. */
|
|
905
|
+
export interface AardinkWorkspaceEdit {
|
|
906
|
+
edits: { resource?: unknown; textEdit: AardinkTextEdit }[];
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/** Monaco's `CodeAction`, as far as the editor reads one. */
|
|
910
|
+
export interface AardinkCodeAction {
|
|
911
|
+
title: string;
|
|
912
|
+
/** `'quickfix'`, `'refactor...'` or `'source.organizeImports'`. */
|
|
913
|
+
kind?: string;
|
|
914
|
+
isPreferred?: boolean;
|
|
915
|
+
edit?: AardinkWorkspaceEdit;
|
|
916
|
+
command?: { id: string; title?: string; arguments?: unknown[] };
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/** Monaco's `TextEdit`: `text` in place of `range`. */
|
|
920
|
+
export interface AardinkTextEdit {
|
|
921
|
+
range: AardinkRange;
|
|
922
|
+
text: string | null;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Monaco's `CodeLens`: a title in a row above the line `range` starts on. One without a `command`
|
|
927
|
+
* is shown once `resolveCodeLens` gives it one.
|
|
928
|
+
*/
|
|
721
929
|
export interface AardinkCodeLens {
|
|
722
930
|
range: AardinkRange;
|
|
723
|
-
command
|
|
931
|
+
command?: { id: string; title: string; arguments?: unknown[] };
|
|
724
932
|
}
|
|
725
933
|
|
|
726
934
|
/** Monaco's `InlayHint`, as far as the editor draws it: a label at a position, in front of the character there. */
|
|
727
935
|
export interface AardinkInlayHint {
|
|
728
936
|
position: AardinkPosition;
|
|
729
937
|
label: string;
|
|
938
|
+
/** Shown, as Markdown, in a card under a mouse resting on the label; Monaco's `{ value }` too. */
|
|
939
|
+
tooltip?: string | { value: string };
|
|
730
940
|
}
|
|
731
941
|
|
|
732
942
|
/** Monaco's `IColorInformation`: where a colour is written, and the colour, each channel from 0 to 1. */
|
|
@@ -742,7 +952,12 @@ export function registerLanguage(definition: AardinkLanguageDefinition, provider
|
|
|
742
952
|
* Monaco's `defineTheme` data. Token rules name tokens as Monaco does, and the longest matching
|
|
743
953
|
* prefix wins: `tag` also colours `tag.aardflex`, `comment.doc` only documentation comments. A
|
|
744
954
|
* rule's `fontStyle` (`'bold'`, `'italic'`, `'underline'`, `'strikethrough'`, or `''` for none)
|
|
745
|
-
* applies too
|
|
955
|
+
* applies too, and its `background` is drawn behind the token's text; the empty token's sets the
|
|
956
|
+
* editor's. `colors` takes VS Code's keys, the editor's chrome too (`minimap.background`,
|
|
957
|
+
* `scrollbarSlider.background`, `editorIndentGuide.background1`, `editorRuler.foreground`,
|
|
958
|
+
* `editorWidget.background`, `.foreground` and `.border`, `editorInlayHint.foreground`,
|
|
959
|
+
* `editorCodeLens.foreground`, `editorGhostText.foreground`...). `hc-black` and `hc-light` fill in
|
|
960
|
+
* from the high-contrast themes.
|
|
746
961
|
*/
|
|
747
962
|
export interface AardinkThemeData {
|
|
748
963
|
base: 'vs' | 'vs-dark' | 'hc-black' | 'hc-light';
|
|
@@ -761,8 +976,8 @@ export function registerTheme(name: string, theme: AardinkThemeData | object): P
|
|
|
761
976
|
* generated `file:///aardink/` URI.
|
|
762
977
|
*
|
|
763
978
|
* What the server knows joins what the language has. The providers of a language from
|
|
764
|
-
* `registerLanguage` answer first
|
|
765
|
-
* the server's. Either way Enter, closing pairs and surrounding a selection stay the language's,
|
|
979
|
+
* `registerLanguage` answer first, the server fills in, and the language it extends comes last; a
|
|
980
|
+
* built-in language's answers come after the server's. Either way Enter, closing pairs and surrounding a selection stay the language's,
|
|
766
981
|
* even where it does nothing, and an editor with no language service, such as plain text, types as
|
|
767
982
|
* it does without a server. Completions, diagnostics, code actions, references, links and colours
|
|
768
983
|
* come from both, and what a server pushes shows after a pause in typing.
|
|
@@ -781,8 +996,9 @@ export interface AardinkInlineCompletions {
|
|
|
781
996
|
}
|
|
782
997
|
|
|
783
998
|
/**
|
|
784
|
-
* Monaco's `InlineCompletion`, as far as the editor shows it. `
|
|
785
|
-
*
|
|
999
|
+
* Monaco's `InlineCompletion`, as far as the editor shows it. A `{ snippet }` shows what it expands
|
|
1000
|
+
* to (a placeholder as its default text, a choice as its first), and accepting it replaces the whole
|
|
1001
|
+
* `range` with the snippet, as in Monaco, so Tab then steps through its tab stops.
|
|
786
1002
|
*
|
|
787
1003
|
* `range` is what it replaces, and must hold the caret. What `insertText` repeats of it is not shown
|
|
788
1004
|
* again: over `)`, the text `x) {` shows `x` before the bracket and ` {` after it, which is how ghost
|
|
@@ -796,7 +1012,7 @@ export interface AardinkInlineCompletions {
|
|
|
796
1012
|
* or past it, shows nothing.
|
|
797
1013
|
*/
|
|
798
1014
|
export interface AardinkInlineCompletion {
|
|
799
|
-
insertText: string;
|
|
1015
|
+
insertText: string | { snippet: string };
|
|
800
1016
|
range?: AardinkRange;
|
|
801
1017
|
}
|
|
802
1018
|
|
|
@@ -834,6 +1050,12 @@ export function registerInlineCompletionsProvider(
|
|
|
834
1050
|
/** Monaco's name for `registerTheme`. */
|
|
835
1051
|
export const defineTheme: typeof registerTheme;
|
|
836
1052
|
|
|
1053
|
+
/**
|
|
1054
|
+
* Adds a font for the `fontFamily` option: a TrueType or OpenType file, by URL (fetched) or as its
|
|
1055
|
+
* bytes. Editors naming it change to it at once. A monospaced font is meant.
|
|
1056
|
+
*/
|
|
1057
|
+
export function registerFont(name: string, urlOrBytes: string | URL | ArrayBuffer | ArrayBufferView): Promise<void>;
|
|
1058
|
+
|
|
837
1059
|
/**
|
|
838
1060
|
* Mounts an editor that fills `container`. Loads the WebAssembly module on first use (see
|
|
839
1061
|
* `preloadAardink`). `onChange` is registered as the first content listener.
|
package/index.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
// Adapts the Kotlin module's integer-handle exports (aardinkCreate, aardinkGetValue, ...) into
|
|
18
18
|
// the Monaco-shaped object described in index.d.ts.
|
|
19
19
|
|
|
20
|
-
export const version = '0.
|
|
20
|
+
export const version = '0.10.0';
|
|
21
21
|
|
|
22
22
|
/** Monaco's flags for a completion's `insertText`. */
|
|
23
23
|
export const CompletionItemInsertTextRule = Object.freeze({ None: 0, KeepWhitespace: 1, InsertAsSnippet: 4 });
|
|
@@ -162,8 +162,32 @@ const PROVIDERS = new Map([
|
|
|
162
162
|
['codeLenses', (providers) => providers.provideCodeLenses],
|
|
163
163
|
// A click is about a command, so no text comes with it.
|
|
164
164
|
['runCodeLensCommand', (providers) => providers.runCodeLensCommand && ((_text, id, args) => providers.runCodeLensCommand(id, args))],
|
|
165
|
+
['formatOnType', (providers) => providers.provideOnTypeFormattingEdits],
|
|
166
|
+
['definition', (providers) => providers.provideDefinition],
|
|
167
|
+
['references', (providers) => providers.provideReferences],
|
|
168
|
+
['formatDocument', (providers) => providers.provideDocumentFormattingEdits],
|
|
169
|
+
['formatRange', (providers) => providers.provideDocumentRangeFormattingEdits],
|
|
170
|
+
['signatureHelp', (providers) => providers.provideSignatureHelp],
|
|
171
|
+
// Monaco's context: the markers as Monaco has them.
|
|
172
|
+
['codeActions', (providers) => providers.provideCodeActions &&
|
|
173
|
+
((text, range, markers) => providers.provideCodeActions(text, range, { markers: markers.map(fromKotlinDiagnostic) }))],
|
|
174
|
+
['rename', (providers) => providers.provideRenameEdits],
|
|
175
|
+
['resolveRename', (providers) => providers.resolveRenameLocation],
|
|
176
|
+
['foldingRanges', (providers) => providers.provideFoldingRanges],
|
|
177
|
+
// A Uint32Array's JSON is an object, so the numbers go as an array.
|
|
178
|
+
['semanticTokens', (providers) => providers.provideDocumentSemanticTokens &&
|
|
179
|
+
((text) => Promise.resolve(providers.provideDocumentSemanticTokens(text))
|
|
180
|
+
.then((tokens) => (tokens == null ? null : { ...tokens, data: Array.from(tokens.data ?? []) })))],
|
|
181
|
+
['resolveCompletionItem', (providers) => providers.resolveCompletionItem && ((_text, item) => providers.resolveCompletionItem(item))],
|
|
182
|
+
['resolveCodeLens', (providers) => providers.resolveCodeLens],
|
|
165
183
|
]);
|
|
166
184
|
|
|
185
|
+
/** Monaco's legend of a semantic tokens provider: `getLegend()`, or a `legend` given as data. */
|
|
186
|
+
function semanticLegend(providers) {
|
|
187
|
+
if (!providers.provideDocumentSemanticTokens) return undefined;
|
|
188
|
+
return typeof providers.getLegend === 'function' ? providers.getLegend() : providers.legend;
|
|
189
|
+
}
|
|
190
|
+
|
|
167
191
|
/** A provider's answer (a value or a Promise of one) as the Promise of JSON the Kotlin side awaits. */
|
|
168
192
|
function answer(provider, ...args) {
|
|
169
193
|
if (!provider) return Promise.resolve(null);
|
|
@@ -191,6 +215,10 @@ export async function registerLanguage(definition, providers = {}) {
|
|
|
191
215
|
configuration: JSON.parse(JSON.stringify(definition.configuration ?? null, regexAsPattern)),
|
|
192
216
|
// On the providers, as on Monaco's completion provider; the Kotlin side reads it with the definition.
|
|
193
217
|
triggerCharacters: providers.triggerCharacters,
|
|
218
|
+
autoFormatTriggerCharacters: providers.provideOnTypeFormattingEdits ? providers.autoFormatTriggerCharacters : undefined,
|
|
219
|
+
semanticTokensLegend: semanticLegend(providers),
|
|
220
|
+
// Which providers there are: whether there is one decides whether a rename is offered and whose folds show.
|
|
221
|
+
provided: [...PROVIDERS.keys()].filter((name) => PROVIDERS.get(name)(providers)),
|
|
194
222
|
grammar,
|
|
195
223
|
}),
|
|
196
224
|
(method, text, argsJson) => answer(PROVIDERS.get(method)?.(providers), text, ...JSON.parse(argsJson)),
|
|
@@ -221,31 +249,13 @@ export async function registerInlineCompletionsProvider(languageId, provider) {
|
|
|
221
249
|
return { dispose: () => k.aardinkDisposeInlineCompletionsProvider(id) };
|
|
222
250
|
}
|
|
223
251
|
|
|
224
|
-
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return {
|
|
229
|
-
type: base === 'vscode-light' ? 'light' : 'dark',
|
|
230
|
-
base: theme.inherit === false ? undefined : base,
|
|
231
|
-
colors: theme.colors ?? {},
|
|
232
|
-
// A rule's colour and font style; its background is not drawn.
|
|
233
|
-
tokenColors: theme.rules
|
|
234
|
-
.filter((rule) => rule.foreground || rule.fontStyle !== undefined)
|
|
235
|
-
.map((rule) => ({
|
|
236
|
-
scope: rule.token,
|
|
237
|
-
settings: {
|
|
238
|
-
...(rule.foreground ? { foreground: `#${rule.foreground.replace(/^#/, '')}` } : {}),
|
|
239
|
-
...(rule.fontStyle !== undefined ? { fontStyle: rule.fontStyle } : {}),
|
|
240
|
-
},
|
|
241
|
-
})),
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/** Adds a theme for createEditor's `theme` option, from Monaco's defineTheme data or VS Code theme JSON. */
|
|
252
|
+
/**
|
|
253
|
+
* Adds a theme for createEditor's `theme` option, from Monaco's defineTheme data or VS Code theme
|
|
254
|
+
* JSON, each as it is: the Kotlin side tells them apart by Monaco's `rules`.
|
|
255
|
+
*/
|
|
246
256
|
export async function registerTheme(name, theme) {
|
|
247
257
|
const k = await load();
|
|
248
|
-
const error = k.aardinkRegisterTheme(name, JSON.stringify(
|
|
258
|
+
const error = k.aardinkRegisterTheme(name, JSON.stringify(theme));
|
|
249
259
|
if (error) throw new Error(`Aardink: ${error}`);
|
|
250
260
|
}
|
|
251
261
|
|
|
@@ -253,15 +263,63 @@ export async function registerTheme(name, theme) {
|
|
|
253
263
|
export const defineTheme = registerTheme;
|
|
254
264
|
|
|
255
265
|
/**
|
|
256
|
-
*
|
|
257
|
-
*
|
|
266
|
+
* Adds a font for the `fontFamily` option, from a URL (fetched) or a font file's bytes (an
|
|
267
|
+
* ArrayBuffer or a typed array). Resolves once the editors can use it; rejects for what is not a
|
|
268
|
+
* TrueType or OpenType font.
|
|
269
|
+
*/
|
|
270
|
+
export async function registerFont(name, urlOrBytes) {
|
|
271
|
+
const k = await load();
|
|
272
|
+
let bytes = urlOrBytes;
|
|
273
|
+
if (typeof urlOrBytes === 'string' || urlOrBytes instanceof URL) {
|
|
274
|
+
const response = await fetch(urlOrBytes);
|
|
275
|
+
if (!response.ok) throw new Error(`Aardink: could not fetch the font ${name}: ${response.status}`);
|
|
276
|
+
bytes = await response.arrayBuffer();
|
|
277
|
+
}
|
|
278
|
+
const view = ArrayBuffer.isView(bytes) ? new Int8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength) : new Int8Array(bytes);
|
|
279
|
+
const error = k.aardinkRegisterFont(name, view);
|
|
280
|
+
if (error) throw new Error(`Aardink: ${error}`);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Monaco's names for the built-in themes, as Aardink's. */
|
|
284
|
+
const MONACO_THEMES = { vs: 'vscode-light', 'vs-dark': 'vscode-dark' };
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Keeps only the fields the Kotlin side knows, translating Monaco's wordWrap ('on', 'off',
|
|
288
|
+
* 'wordWrapColumn', 'bounded'), its { enabled } objects for minimap and stickyScroll (a plain
|
|
289
|
+
* boolean works too), its guides and its lineNumbers.
|
|
258
290
|
*/
|
|
259
291
|
function toKotlinOptions(options) {
|
|
260
292
|
const out = {};
|
|
261
|
-
for (const key of ['language', '
|
|
293
|
+
for (const key of ['language', 'fontSize', 'readOnly', 'showGutter', 'showLineNumbers', 'showFoldMarkers', 'tabSize', 'insertSpaces', 'highlightCurrentLine', 'renderWhitespace']) {
|
|
294
|
+
if (options[key] !== undefined) out[key] = options[key];
|
|
295
|
+
}
|
|
296
|
+
if (options.theme !== undefined) out.theme = MONACO_THEMES[options.theme] ?? options.theme;
|
|
297
|
+
if (options.wordWrap !== undefined) {
|
|
298
|
+
const bounded = options.wordWrap === 'wordWrapColumn' || options.wordWrap === 'bounded';
|
|
299
|
+
out.wordWrap = options.wordWrap === 'on' || options.wordWrap === true || bounded;
|
|
300
|
+
out.wordWrapColumn = bounded ? options.wordWrapColumn ?? 80 : null;
|
|
301
|
+
} else if (options.wordWrapColumn !== undefined) {
|
|
302
|
+
out.wordWrapColumn = options.wordWrapColumn;
|
|
303
|
+
}
|
|
304
|
+
if (options.lineNumbers !== undefined) {
|
|
305
|
+
// A function, Monaco's other form, cannot cross to the Kotlin side: it counts as 'on'.
|
|
306
|
+
out.lineNumbers = typeof options.lineNumbers === 'string' ? options.lineNumbers : 'on';
|
|
307
|
+
}
|
|
308
|
+
if (options.guides !== undefined && options.guides !== null) {
|
|
309
|
+
if (options.guides.indentation !== undefined) out.indentGuides = !!options.guides.indentation;
|
|
310
|
+
// Monaco's 'active' shows only the caret's pair; here it shows them all.
|
|
311
|
+
if (options.guides.bracketPairs !== undefined) out.bracketPairGuides = !!options.guides.bracketPairs;
|
|
312
|
+
}
|
|
313
|
+
if (options.rulers !== undefined) {
|
|
314
|
+
// Monaco's { column, color } rulers keep their column; one colour comes from the theme.
|
|
315
|
+
out.rulers = (options.rulers ?? []).map((r) => (typeof r === 'number' ? r : r?.column)).filter((c) => Number.isInteger(c));
|
|
316
|
+
}
|
|
317
|
+
for (const key of ['cursorStyle', 'cursorBlinking', 'wrappingIndent', 'cursorSurroundingLines', 'fontFamily']) {
|
|
262
318
|
if (options[key] !== undefined) out[key] = options[key];
|
|
263
319
|
}
|
|
264
|
-
|
|
320
|
+
for (const key of ['smoothScrolling', 'scrollBeyondLastLine', 'dragAndDrop']) {
|
|
321
|
+
if (options[key] !== undefined) out[key] = !!options[key];
|
|
322
|
+
}
|
|
265
323
|
if (options.renderLineHighlight !== undefined) out.highlightCurrentLine = options.renderLineHighlight !== 'none';
|
|
266
324
|
if (options.quickSuggestions !== undefined) {
|
|
267
325
|
// Monaco's { other, comments, strings }: the editor opens the list in code, so `other` decides.
|
|
@@ -273,7 +331,7 @@ function toKotlinOptions(options) {
|
|
|
273
331
|
if (options.overviewRuler !== undefined) out.overviewRuler = !!options.overviewRuler;
|
|
274
332
|
if (options.occurrencesHighlight !== undefined) out.occurrencesHighlight = options.occurrencesHighlight !== false && options.occurrencesHighlight !== 'off';
|
|
275
333
|
if (options.fontLigatures !== undefined) out.fontLigatures = options.fontLigatures !== false && options.fontLigatures !== 'off';
|
|
276
|
-
for (const key of ['linkedEditing', 'colorDecorators', 'breadcrumbs', 'semanticHighlighting', 'codeLens']) {
|
|
334
|
+
for (const key of ['linkedEditing', 'colorDecorators', 'breadcrumbs', 'semanticHighlighting', 'codeLens', 'formatOnType']) {
|
|
277
335
|
if (options[key] !== undefined) out[key] = !!options[key];
|
|
278
336
|
}
|
|
279
337
|
if (options.inlayHints !== undefined) {
|
|
@@ -345,6 +403,11 @@ export async function createEditor(container, onChange, options = {}) {
|
|
|
345
403
|
// opens http and https links itself. It does that in the click, which a popup blocker wants.
|
|
346
404
|
const linkListeners = new Set();
|
|
347
405
|
const openLink = (target) => linkListeners.forEach((listener) => listener(target));
|
|
406
|
+
const searchListeners = new Set();
|
|
407
|
+
const searchWorkspace = (json) => {
|
|
408
|
+
const args = JSON.parse(json);
|
|
409
|
+
searchListeners.forEach((listener) => listener(args));
|
|
410
|
+
};
|
|
348
411
|
|
|
349
412
|
// Decorations: those set through deltaDecorations, with their ids, and each collection's own.
|
|
350
413
|
let deltaDecorations = [];
|
|
@@ -439,6 +502,16 @@ export async function createEditor(container, onChange, options = {}) {
|
|
|
439
502
|
scrollListeners.add(listener);
|
|
440
503
|
return () => scrollListeners.delete(listener);
|
|
441
504
|
},
|
|
505
|
+
onSearchWorkspace(listener) {
|
|
506
|
+
if (searchListeners.size === 0) k.aardinkOnSearchWorkspace(id, searchWorkspace);
|
|
507
|
+
searchListeners.add(listener);
|
|
508
|
+
return {
|
|
509
|
+
dispose() {
|
|
510
|
+
searchListeners.delete(listener);
|
|
511
|
+
if (searchListeners.size === 0 && !disposed) k.aardinkOnSearchWorkspace(id, null);
|
|
512
|
+
},
|
|
513
|
+
};
|
|
514
|
+
},
|
|
442
515
|
onOpenLink(listener) {
|
|
443
516
|
if (linkListeners.size === 0) k.aardinkOnOpenLink(id, openLink);
|
|
444
517
|
linkListeners.add(listener);
|
|
@@ -531,6 +604,7 @@ export async function createEditor(container, onChange, options = {}) {
|
|
|
531
604
|
blurListeners.clear();
|
|
532
605
|
scrollListeners.clear();
|
|
533
606
|
linkListeners.clear();
|
|
607
|
+
searchListeners.clear();
|
|
534
608
|
k.aardinkDispose(id);
|
|
535
609
|
},
|
|
536
610
|
};
|
package/kotlin/aardink-web.mjs
CHANGED
|
@@ -95,6 +95,7 @@ export const {
|
|
|
95
95
|
aardinkGetScrollHeight,
|
|
96
96
|
aardinkOnScrollChange,
|
|
97
97
|
aardinkOnOpenLink,
|
|
98
|
+
aardinkOnSearchWorkspace,
|
|
98
99
|
aardinkLayout,
|
|
99
100
|
aardinkSetDecorations,
|
|
100
101
|
aardinkGetDecorationRanges,
|
|
@@ -107,6 +108,7 @@ export const {
|
|
|
107
108
|
aardinkRegisterInlineCompletionsProvider,
|
|
108
109
|
aardinkDisposeInlineCompletionsProvider,
|
|
109
110
|
aardinkRegisterTheme,
|
|
111
|
+
aardinkRegisterFont,
|
|
110
112
|
aardinkOnContentChange,
|
|
111
113
|
aardinkOnSelectionChange,
|
|
112
114
|
aardinkOnFocusChange,
|
package/kotlin/aardink-web.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED