@finos/legend-application 10.2.11 → 10.2.13
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/lib/application/LegendApplication.d.ts.map +1 -1
- package/lib/application/LegendApplication.js +1 -2
- package/lib/application/LegendApplication.js.map +1 -1
- package/lib/components/ActionAlert.d.ts +1 -0
- package/lib/components/ActionAlert.d.ts.map +1 -1
- package/lib/components/BlockingAlert.d.ts +1 -0
- package/lib/components/BlockingAlert.d.ts.map +1 -1
- package/lib/components/LegendApplicationComponentFrameworkProvider.d.ts +6 -0
- package/lib/components/LegendApplicationComponentFrameworkProvider.d.ts.map +1 -1
- package/lib/components/LegendApplicationComponentFrameworkProvider.js +21 -13
- package/lib/components/LegendApplicationComponentFrameworkProvider.js.map +1 -1
- package/lib/components/NotificationManager.d.ts +1 -0
- package/lib/components/NotificationManager.d.ts.map +1 -1
- package/lib/components/VirtualAssistant.d.ts +1 -0
- package/lib/components/VirtualAssistant.d.ts.map +1 -1
- package/lib/components/shared/TabManager.d.ts +1 -0
- package/lib/components/shared/TabManager.d.ts.map +1 -1
- package/lib/components/shared/TextSearchAdvancedConfigMenu.d.ts +1 -0
- package/lib/components/shared/TextSearchAdvancedConfigMenu.d.ts.map +1 -1
- package/lib/const.d.ts +1 -1
- package/lib/const.d.ts.map +1 -1
- package/lib/const.js +1 -1
- package/lib/const.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/stores/ApplicationEvent.d.ts +1 -0
- package/lib/stores/ApplicationEvent.d.ts.map +1 -1
- package/lib/stores/ApplicationEvent.js +1 -0
- package/lib/stores/ApplicationEvent.js.map +1 -1
- package/lib/stores/ApplicationStore.d.ts +2 -0
- package/lib/stores/ApplicationStore.d.ts.map +1 -1
- package/lib/stores/ApplicationStore.js +3 -0
- package/lib/stores/ApplicationStore.js.map +1 -1
- package/lib/stores/CommandCenter.d.ts +1 -0
- package/lib/stores/CommandCenter.d.ts.map +1 -1
- package/lib/stores/CommandCenter.js.map +1 -1
- package/lib/stores/KeyboardShortcutsService.d.ts +4 -10
- package/lib/stores/KeyboardShortcutsService.d.ts.map +1 -1
- package/lib/stores/KeyboardShortcutsService.js +36 -33
- package/lib/stores/KeyboardShortcutsService.js.map +1 -1
- package/lib/stores/LegendApplicationDocumentation.d.ts +1 -0
- package/lib/stores/LegendApplicationDocumentation.d.ts.map +1 -1
- package/lib/stores/LegendApplicationDocumentation.js +1 -0
- package/lib/stores/LegendApplicationDocumentation.js.map +1 -1
- package/lib/stores/PureLanguageSupport.d.ts.map +1 -1
- package/lib/stores/PureLanguageSupport.js +14 -1
- package/lib/stores/PureLanguageSupport.js.map +1 -1
- package/lib/stores/TerminalService.d.ts +23 -0
- package/lib/stores/TerminalService.d.ts.map +1 -0
- package/lib/stores/TerminalService.js +25 -0
- package/lib/stores/TerminalService.js.map +1 -0
- package/lib/stores/terminal/Terminal.d.ts +155 -0
- package/lib/stores/terminal/Terminal.d.ts.map +1 -0
- package/lib/stores/terminal/Terminal.js +171 -0
- package/lib/stores/terminal/Terminal.js.map +1 -0
- package/lib/stores/terminal/XTerm.d.ts +91 -0
- package/lib/stores/terminal/XTerm.d.ts.map +1 -0
- package/lib/stores/terminal/XTerm.js +693 -0
- package/lib/stores/terminal/XTerm.js.map +1 -0
- package/package.json +19 -13
- package/src/application/LegendApplication.tsx +5 -2
- package/src/components/LegendApplicationComponentFrameworkProvider.tsx +24 -18
- package/src/const.ts +1 -1
- package/src/index.ts +1 -0
- package/src/stores/ApplicationEvent.ts +1 -0
- package/src/stores/ApplicationStore.ts +4 -1
- package/src/stores/CommandCenter.ts +1 -0
- package/src/stores/KeyboardShortcutsService.ts +43 -48
- package/src/stores/LegendApplicationDocumentation.ts +1 -0
- package/src/stores/PureLanguageSupport.ts +15 -1
- package/src/stores/TerminalService.ts +30 -0
- package/src/stores/terminal/Terminal.ts +259 -0
- package/src/stores/terminal/XTerm.ts +880 -0
- package/tsconfig.json +3 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { GenericLegendApplicationStore } from '../ApplicationStore.js';
|
|
18
|
+
import { action, makeObservable, observable } from 'mobx';
|
|
19
|
+
|
|
20
|
+
// NOTE: using Unicode for ANSI escape
|
|
21
|
+
// See https://stackoverflow.com/questions/26153308/best-ansi-escape-beginning
|
|
22
|
+
// See https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
|
|
23
|
+
export enum DISPLAY_ANSI_ESCAPE {
|
|
24
|
+
RESET = '\x1b[0m', // color off
|
|
25
|
+
|
|
26
|
+
// text decoration
|
|
27
|
+
BOLD = '\x1b[1m',
|
|
28
|
+
DIM = '\x1b[2m',
|
|
29
|
+
ITALIC = '\x1b[3m',
|
|
30
|
+
UNDERLINE = '\x1b[4m',
|
|
31
|
+
BLINKING = '\x1b[5m',
|
|
32
|
+
STRIKETHROUGH = '\x1b[9m',
|
|
33
|
+
|
|
34
|
+
// foreground
|
|
35
|
+
BLACK = '\x1b[30m',
|
|
36
|
+
RED = '\x1b[31m',
|
|
37
|
+
GREEN = '\x1b[32m',
|
|
38
|
+
YELLOW = '\x1b[33m',
|
|
39
|
+
BLUE = '\x1b[34m',
|
|
40
|
+
MAGENTA = '\x1b[35m',
|
|
41
|
+
CYAN = '\x1b[36m',
|
|
42
|
+
WHITE = '\x1b[37m',
|
|
43
|
+
|
|
44
|
+
BRIGHT_BLACK = `\x1b[1;30m`,
|
|
45
|
+
BRIGHT_RED = '\x1b[1;31m',
|
|
46
|
+
BRIGHT_GREEN = '\x1b[1;32m',
|
|
47
|
+
BRIGHT_YELLOW = '\x1b[1;33m',
|
|
48
|
+
BRIGHT_BLUE = '\x1b[1;34m',
|
|
49
|
+
BRIGHT_MAGENTA = '\x1b[1;35m',
|
|
50
|
+
BRIGHT_CYAN = '\x1b[1;36m',
|
|
51
|
+
BRIGHT_WHITE = '\x1b[1;37m',
|
|
52
|
+
|
|
53
|
+
DIMMED_BLACK = `\x1b[2;30m`,
|
|
54
|
+
DIMMED_RED = '\x1b[2;31m',
|
|
55
|
+
DIMMED_GREEN = '\x1b[2;32m',
|
|
56
|
+
DIMMED_YELLOW = '\x1b[2;33m',
|
|
57
|
+
DIMMED_BLUE = '\x1b[2;34m',
|
|
58
|
+
DIMMED_MAGENTA = '\x1b[2;35m',
|
|
59
|
+
DIMMED_CYAN = '\x1b[2;36m',
|
|
60
|
+
DIMMED_WHITE = '\x1b[2;37m',
|
|
61
|
+
|
|
62
|
+
// background
|
|
63
|
+
BLACK_BG = '\x1b[40m',
|
|
64
|
+
RED_BG = '\x1b[41m',
|
|
65
|
+
GREEN_BG = '\x1b[42m',
|
|
66
|
+
YELLOW_BG = '\x1b[43m',
|
|
67
|
+
BLUE_BG = '\x1b[44m',
|
|
68
|
+
MAGENTA_BG = '\x1b[45m',
|
|
69
|
+
CYAN_BG = '\x1b[46m',
|
|
70
|
+
WHITE_BG = '\x1b[47m',
|
|
71
|
+
|
|
72
|
+
BRIGHT_BLACK_BG = `\x1b[1;40m`,
|
|
73
|
+
BRIGHT_RED_BG = '\x1b[1;41m',
|
|
74
|
+
BRIGHT_GREEN_BG = '\x1b[1;42m',
|
|
75
|
+
BRIGHT_YELLOW_BG = '\x1b[1;43m',
|
|
76
|
+
BRIGHT_BLUE_BG = '\x1b[1;44m',
|
|
77
|
+
BRIGHT_MAGENTA_BG = '\x1b[1;45m',
|
|
78
|
+
BRIGHT_CYAN_BG = '\x1b[1;46m',
|
|
79
|
+
BRIGHT_WHITE_BG = '\x1b[1;47m',
|
|
80
|
+
|
|
81
|
+
DIMMED_BLACK_BG = `\x1b[2;40m`,
|
|
82
|
+
DIMMED_RED_BG = '\x1b[2;41m',
|
|
83
|
+
DIMMED_GREEN_BG = '\x1b[2;42m',
|
|
84
|
+
DIMMED_YELLOW_BG = '\x1b[2;43m',
|
|
85
|
+
DIMMED_BLUE_BG = '\x1b[2;44m',
|
|
86
|
+
DIMMED_MAGENTA_BG = '\x1b[2;45m',
|
|
87
|
+
DIMMED_CYAN_BG = '\x1b[2;46m',
|
|
88
|
+
DIMMED_WHITE_BG = '\x1b[2;47m',
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* NOTE: this is the line and the column of the viewport of the terminal;
|
|
93
|
+
* Also, line and column start from 1
|
|
94
|
+
*/
|
|
95
|
+
export const ANSI_moveCursor = (line: number, column: number): string =>
|
|
96
|
+
`\x1b[${line};${column}H`;
|
|
97
|
+
export const ANSI_moveCursorUp = (val: number, start?: boolean): string =>
|
|
98
|
+
start ? `\x1b[${val}F` : `\x1b[${val}A`;
|
|
99
|
+
export const ANSI_moveCursorDown = (val: number, start?: boolean): string =>
|
|
100
|
+
start ? `\x1b[${val}E` : `\x1b[${val}B`;
|
|
101
|
+
export const ANSI_moveCursorRight = (val: number): string => `\x1b[${val}C`;
|
|
102
|
+
export const ANSI_moveCursorLeft = (val: number): string => `\x1b[${val}D`;
|
|
103
|
+
export const ANSI_moveCursorToColumn = (val: number): string => `\x1b[${val}G`;
|
|
104
|
+
|
|
105
|
+
class ConsoleSearchConfiguration {
|
|
106
|
+
private searchInput?: HTMLInputElement | undefined;
|
|
107
|
+
|
|
108
|
+
searchText = '';
|
|
109
|
+
|
|
110
|
+
useRegex = false;
|
|
111
|
+
matchWholeWord = false;
|
|
112
|
+
matchCaseSensitive = false;
|
|
113
|
+
|
|
114
|
+
resultCount?: number | undefined;
|
|
115
|
+
currentResultIndex?: number | undefined;
|
|
116
|
+
|
|
117
|
+
constructor() {
|
|
118
|
+
makeObservable(this, {
|
|
119
|
+
searchText: observable,
|
|
120
|
+
|
|
121
|
+
useRegex: observable,
|
|
122
|
+
matchWholeWord: observable,
|
|
123
|
+
matchCaseSensitive: observable,
|
|
124
|
+
|
|
125
|
+
resultCount: observable,
|
|
126
|
+
currentResultIndex: observable,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
setSearchInput(el: HTMLInputElement | undefined): void {
|
|
131
|
+
this.searchInput = el;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
focus(): void {
|
|
135
|
+
this.searchInput?.focus();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export abstract class Console {
|
|
140
|
+
readonly applicationStore: GenericLegendApplicationStore;
|
|
141
|
+
|
|
142
|
+
readonly searchConfig = new ConsoleSearchConfiguration();
|
|
143
|
+
|
|
144
|
+
constructor(applicationStore: GenericLegendApplicationStore) {
|
|
145
|
+
makeObservable(this, {
|
|
146
|
+
setSearchText: action,
|
|
147
|
+
|
|
148
|
+
setSearchRegex: action,
|
|
149
|
+
setSearchWholeWord: action,
|
|
150
|
+
setSearchCaseSensitive: action,
|
|
151
|
+
|
|
152
|
+
setSearchResultCount: action,
|
|
153
|
+
setSearchCurrentResultIndex: action,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
this.applicationStore = applicationStore;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
setSearchText(val: string): void {
|
|
160
|
+
this.searchConfig.searchText = val;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
setSearchRegex(val: boolean): void {
|
|
164
|
+
this.searchConfig.useRegex = val;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
setSearchWholeWord(val: boolean): void {
|
|
168
|
+
this.searchConfig.matchWholeWord = val;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
setSearchCaseSensitive(val: boolean): void {
|
|
172
|
+
this.searchConfig.matchCaseSensitive = val;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
setSearchResultCount(val: number | undefined): void {
|
|
176
|
+
this.searchConfig.resultCount = val;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
setSearchCurrentResultIndex(val: number | undefined): void {
|
|
180
|
+
this.searchConfig.currentResultIndex = val;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
abstract mount(container: HTMLElement): void;
|
|
184
|
+
abstract dispose(): void;
|
|
185
|
+
abstract autoResize(): void;
|
|
186
|
+
abstract clear(): void;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export abstract class OutputConsole extends Console {}
|
|
190
|
+
|
|
191
|
+
export interface TerminalWriteOption {
|
|
192
|
+
systemCommand?: string | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* Whether to clear the console prior to writing
|
|
195
|
+
*/
|
|
196
|
+
clear?: boolean | undefined;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface TerminalWebLinkProviderConfiguration {
|
|
200
|
+
handler: (event: MouseEvent, text: string) => void;
|
|
201
|
+
regex: RegExp;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface TerminalCommandConfiguration {
|
|
205
|
+
command: string;
|
|
206
|
+
description: string;
|
|
207
|
+
usage: string;
|
|
208
|
+
aliases?: string[] | undefined;
|
|
209
|
+
handler: (args: string[], command: string, text: string) => Promise<void>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface TerminalSetupConfiguration {
|
|
213
|
+
// NOTE: since xterm do not support web-link provider, we need to override the default addon
|
|
214
|
+
// the more ideal strategy is to implement additional buffer parser
|
|
215
|
+
// See https://github.com/xtermjs/xterm.js/issues/3746
|
|
216
|
+
webLinkProvider?: TerminalWebLinkProviderConfiguration | undefined;
|
|
217
|
+
commands?: TerminalCommandConfiguration[] | undefined;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export abstract class Terminal extends Console {
|
|
221
|
+
preserveLog = false;
|
|
222
|
+
protected commandRegistry = new Map<string, TerminalCommandConfiguration>();
|
|
223
|
+
|
|
224
|
+
constructor(applicationStore: GenericLegendApplicationStore) {
|
|
225
|
+
super(applicationStore);
|
|
226
|
+
|
|
227
|
+
makeObservable(this, {
|
|
228
|
+
preserveLog: observable,
|
|
229
|
+
setPreserveLog: action,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
setPreserveLog(val: boolean): void {
|
|
234
|
+
this.preserveLog = val;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
abstract get isSetup(): boolean;
|
|
238
|
+
abstract setup(configuration?: TerminalSetupConfiguration | undefined): void;
|
|
239
|
+
abstract focus(): void;
|
|
240
|
+
|
|
241
|
+
showHelp(): void {
|
|
242
|
+
// do nothing
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
showCommonANSIEscapeSequences(): void {
|
|
246
|
+
// do nothing
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
abstract abort(): void;
|
|
250
|
+
abstract fail(error: string, opts?: TerminalWriteOption): void;
|
|
251
|
+
abstract output(val: string, opts?: TerminalWriteOption): void;
|
|
252
|
+
|
|
253
|
+
abstract isFocused(): boolean;
|
|
254
|
+
|
|
255
|
+
abstract search(val: string): void;
|
|
256
|
+
abstract clearSearch(): void;
|
|
257
|
+
abstract findPrevious(): void;
|
|
258
|
+
abstract findNext(): void;
|
|
259
|
+
}
|