@qodalis/cli 2.0.0-beta.9 → 2.0.0-rc.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/README.md +188 -529
- package/assets/cli-panel.css +406 -0
- package/assets/styles.css +8 -0
- package/package.json +6 -6
- package/public-api.d.mts +2064 -339
- package/public-api.d.ts +2064 -339
- package/public-api.js +13628 -6736
- package/public-api.js.map +1 -1
- package/public-api.mjs +13529 -6740
- package/public-api.mjs.map +1 -1
- package/wasm/qodalis_cli_wasm_bg.wasm +0 -0
package/public-api.d.mts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ICliCommandProcessor, ICliCommandParameterDescriptor, ICliCommandProcessorRegistry, ICliCommandChildProcessor, CliProcessorMetadata, CliStateConfiguration, ICliExecutionContext, CliProcessCommand, ICliCommandAuthor, CliThemeInfo, ICliExecutionProcess, ICliUserSession, ICliSpinner, ICliPercentageProgressBar, ICliTextAnimator, ICliTerminalWriter, ICliCommandExecutorService, ICliClipboard, ICliStateStore, CliOptions, ICliLogger, ICliServiceProvider, ICliTranslationService, ICliInputReader, ICliBackgroundServiceRegistry, ICliManagedInterval, ICliManagedTimer, ICliKeyValueStore, ICliCompletionProvider, ICliFilePickerProvider, ICliGlobalParameterHandler, CliProvider, CliForegroundColor, CliBackgroundColor, CliLogLevel, CliPercentageProgressBarUpdateValueOptions, CliTextAnimatorOptions, ICliModule, CliModuleRegistry, Package, ICliPingServerService, CliLineOptions, CliSelectOption, CliSelectOptions, CliMultiSelectOption, CliMultiSelectOptions, CliNumberOptions, CliDateOptions, CliFilePickerOptions, CliFileResult, ICliProcessRegistry, ICliProcessRegisterOptions, ICliProcessEntry, ICliDragDropService, CliState, CliEngineSnapshot, CliServerConfig, CliServerCommandDescriptor, CliServerCapabilities, CliServerResponse, CliIcon } from '@qodalis/cli-core';
|
|
1
|
+
import { ICliCommandProcessor, ICliCommandParameterDescriptor as ICliCommandParameterDescriptor$1, ICliCommandProcessorRegistry, ICliCommandChildProcessor, CliProcessorMetadata, CliStateConfiguration, ICliExecutionContext, CliProcessCommand, ICliCommandAuthor, CliThemeInfo, ICliExecutionProcess, ICliUserSession, ICliSpinner, ICliPercentageProgressBar, ICliTextAnimator, ICliTerminalWriter, ICliCommandExecutorService, ICliClipboard, ICliStateStore, CliOptions, ICliLogger, ICliServiceProvider, ICliTranslationService, ICliInputReader, ICliBackgroundServiceRegistry, ICliHttpClient, ICliNotifier, ICliManagedInterval, ICliManagedTimer, ICliEventBus, ICliKeyValueStore, CliStateStoreOptions, ICliCompletionProvider, ICliFilePickerProvider, CliFullScreenOptions, ICliProcessRegistry, ICliBackgroundService, ICliServiceContext, ICliBackgroundServiceInfo, ICliServiceLogEntry, CliServiceEventHandler, ICliGlobalParameterHandler, CliForegroundColor, CliBackgroundColor, CliToken, CliProvider, CliTableOptions, CliLogLevel, CliPercentageProgressBarUpdateValueOptions, CliTextAnimatorOptions, ICliModule, CliModuleRegistry, Package, ICliPingServerService, CliLineOptions, CliSelectOption, CliSelectOptions, CliMultiSelectOption, CliMultiSelectOptions, CliNumberOptions, CliDateOptions, CliFilePickerOptions, CliFileResult, ICliProcessRegisterOptions, ICliProcessEntry, ICliDragDropService, CliHttpRequestOptions, CliNotification, ICliPermissionRegistry, CliPermissionDefinition, CliState, CliEngineSnapshot, CliEvent, CliEventType, CliEventMap, CliEmitOptions, CustomEventType, CliEventHandler, CliServerConfig, ICliServerAuthService, CliServerCommandDescriptor, CliServerCapabilities, CliServerResponse, CliServerOutput, CliPanelPosition, CliPanelConfig, CliPanelHideAlignment, ICliPanelRef, CliPanelState } from '@qodalis/cli-core';
|
|
3
2
|
export { ICliUserSessionService_TOKEN, ICliUsersStoreService_TOKEN } from '@qodalis/cli-core';
|
|
4
3
|
import { ITheme, Terminal, ITerminalAddon, ITerminalOptions, ITerminalInitOnlyOptions } from '@xterm/xterm';
|
|
4
|
+
import * as rxjs from 'rxjs';
|
|
5
5
|
import { Subject, Observable, Subscription } from 'rxjs';
|
|
6
|
+
import { FitAddon } from '@xterm/addon-fit';
|
|
7
|
+
import { SerializeAddon } from '@xterm/addon-serialize';
|
|
6
8
|
|
|
7
9
|
type ParsedArg = {
|
|
8
10
|
name: string;
|
|
@@ -13,6 +15,8 @@ type ParsedToken = {
|
|
|
13
15
|
name: string;
|
|
14
16
|
value: string | number | boolean;
|
|
15
17
|
hasEquals: boolean;
|
|
18
|
+
/** Written with one dash (`-rf`), so it may be several short flags */
|
|
19
|
+
short?: boolean;
|
|
16
20
|
} | {
|
|
17
21
|
kind: 'word';
|
|
18
22
|
value: string;
|
|
@@ -70,7 +74,7 @@ declare class CliArgsParser {
|
|
|
70
74
|
* @param descriptors - Parameter descriptors from the matched processor.
|
|
71
75
|
* @returns Reconciled args array and remaining command parts.
|
|
72
76
|
*/
|
|
73
|
-
declare function reconcileArgs(tokens: ParsedToken[], descriptors: ICliCommandParameterDescriptor[] | undefined): {
|
|
77
|
+
declare function reconcileArgs(tokens: ParsedToken[], descriptors: ICliCommandParameterDescriptor$1[] | undefined): {
|
|
74
78
|
args: ParsedArg[];
|
|
75
79
|
commandParts: string[];
|
|
76
80
|
};
|
|
@@ -88,6 +92,11 @@ declare class ProcessExitedError extends Error {
|
|
|
88
92
|
|
|
89
93
|
declare class CliCommandProcessorRegistry implements ICliCommandProcessorRegistry {
|
|
90
94
|
readonly processors: ICliCommandProcessor[];
|
|
95
|
+
/**
|
|
96
|
+
* Sub-commands each extension (`extendsProcessor`) merged into an
|
|
97
|
+
* existing command, removed again when the extension is unregistered.
|
|
98
|
+
*/
|
|
99
|
+
private readonly mergedByExtension;
|
|
91
100
|
constructor(initialProcessors?: ICliCommandProcessor[]);
|
|
92
101
|
registerProcessor(processor: ICliCommandProcessor): void;
|
|
93
102
|
unregisterProcessor(processor: ICliCommandProcessor): void;
|
|
@@ -108,51 +117,72 @@ declare class CliCommandProcessorRegistry implements ICliCommandProcessorRegistr
|
|
|
108
117
|
* Framework-agnostic token for the CLI command processor registry.
|
|
109
118
|
* Used as a key in the service provider to retrieve the registry.
|
|
110
119
|
*/
|
|
111
|
-
declare const CliProcessorsRegistry_TOKEN
|
|
120
|
+
declare const CliProcessorsRegistry_TOKEN: any;
|
|
112
121
|
/**
|
|
113
122
|
* Framework-agnostic token for the CLI state store manager.
|
|
114
123
|
* Used as a key in the service provider to retrieve the state store manager.
|
|
115
124
|
*/
|
|
116
|
-
declare const CliStateStoreManager_TOKEN
|
|
125
|
+
declare const CliStateStoreManager_TOKEN: any;
|
|
117
126
|
/**
|
|
118
127
|
* Framework-agnostic token for the CLI command history service.
|
|
119
128
|
* Used as a key in the service provider to retrieve the command history.
|
|
120
129
|
*/
|
|
121
|
-
declare const CliCommandHistory_TOKEN
|
|
130
|
+
declare const CliCommandHistory_TOKEN: any;
|
|
122
131
|
/**
|
|
123
132
|
* Framework-agnostic token for the CLI ping server service.
|
|
124
133
|
* Used as a key in the service provider to retrieve the ping server service.
|
|
125
134
|
*/
|
|
126
|
-
declare const ICliPingServerService_TOKEN
|
|
135
|
+
declare const ICliPingServerService_TOKEN: any;
|
|
127
136
|
/**
|
|
128
137
|
* Framework-agnostic token for the CLI module registry.
|
|
129
138
|
* Used as a key in the service provider to retrieve the module registry.
|
|
130
139
|
*/
|
|
131
|
-
declare const CliModuleRegistry_TOKEN
|
|
140
|
+
declare const CliModuleRegistry_TOKEN: any;
|
|
141
|
+
/**
|
|
142
|
+
* The live boot report (`CliBootLog`) while the CLI starts. Processors and
|
|
143
|
+
* modules can add steps and lines from `initialize`/`onInit`; it ignores
|
|
144
|
+
* entries once boot has finished.
|
|
145
|
+
*/
|
|
146
|
+
declare const CliBootLog_TOKEN: any;
|
|
132
147
|
/**
|
|
133
148
|
* Framework-agnostic token for the CLI background service registry.
|
|
134
149
|
* Used as a key in the service provider to retrieve the background service registry.
|
|
135
150
|
*/
|
|
136
|
-
declare const CliBackgroundServiceRegistry_TOKEN
|
|
151
|
+
declare const CliBackgroundServiceRegistry_TOKEN: any;
|
|
137
152
|
/**
|
|
138
153
|
* Framework-agnostic token for the CLI package manager service.
|
|
139
154
|
* Used as a key in the service provider to retrieve the package manager.
|
|
140
155
|
*/
|
|
141
|
-
declare const CliPackageManagerService_TOKEN
|
|
156
|
+
declare const CliPackageManagerService_TOKEN: any;
|
|
157
|
+
/**
|
|
158
|
+
* Framework-agnostic token for the CLI key-value store.
|
|
159
|
+
* Used as a key in the service provider to retrieve the persistent storage.
|
|
160
|
+
*/
|
|
161
|
+
declare const CliKeyValueStore_TOKEN: any;
|
|
162
|
+
/**
|
|
163
|
+
* Framework-agnostic token for the syntax highlighter registry.
|
|
164
|
+
* Used as a key in the service provider to retrieve the syntax highlighter registry.
|
|
165
|
+
*/
|
|
166
|
+
declare const SyntaxHighlighterRegistry_TOKEN: any;
|
|
142
167
|
|
|
143
|
-
declare const LIBRARY_VERSION = "2.0.0-
|
|
168
|
+
declare const LIBRARY_VERSION = "2.0.0-rc.2";
|
|
144
169
|
declare const API_VERSION = 2;
|
|
145
170
|
|
|
146
171
|
declare class CliAliasCommandProcessor implements ICliCommandProcessor {
|
|
147
172
|
command: string;
|
|
148
|
-
author:
|
|
173
|
+
author: any;
|
|
149
174
|
description: string;
|
|
150
|
-
|
|
175
|
+
acceptsRawInput: boolean;
|
|
151
176
|
metadata?: CliProcessorMetadata | undefined;
|
|
152
177
|
stateConfiguration?: CliStateConfiguration | undefined;
|
|
178
|
+
/** Shared aliases (used when no auth module is loaded) */
|
|
153
179
|
userAliases: Record<string, string>;
|
|
180
|
+
private aliasState;
|
|
181
|
+
/** Aliases visible to the current principal */
|
|
182
|
+
aliasesFor(context: Pick<ICliExecutionContext, 'services'>): Record<string, string>;
|
|
154
183
|
private stateSubscription?;
|
|
155
|
-
|
|
184
|
+
/** `alias ls`: list the aliases visible to the current principal */
|
|
185
|
+
private listAliases;
|
|
156
186
|
writeDescription(context: ICliExecutionContext): void;
|
|
157
187
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
158
188
|
initialize(context: ICliExecutionContext): Promise<void>;
|
|
@@ -162,7 +192,7 @@ declare class CliCalCommandProcessor implements ICliCommandProcessor {
|
|
|
162
192
|
command: string;
|
|
163
193
|
aliases: string[];
|
|
164
194
|
description: string;
|
|
165
|
-
author:
|
|
195
|
+
author: any;
|
|
166
196
|
metadata?: CliProcessorMetadata;
|
|
167
197
|
parameters: {
|
|
168
198
|
name: string;
|
|
@@ -179,7 +209,7 @@ declare class CliClearCommandProcessor implements ICliCommandProcessor {
|
|
|
179
209
|
command: string;
|
|
180
210
|
aliases: string[];
|
|
181
211
|
description?: string | undefined;
|
|
182
|
-
author:
|
|
212
|
+
author: any;
|
|
183
213
|
metadata?: CliProcessorMetadata | undefined;
|
|
184
214
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
185
215
|
writeDescription(context: ICliExecutionContext): void;
|
|
@@ -189,7 +219,7 @@ declare class CliClipboardCommandProcessor implements ICliCommandProcessor {
|
|
|
189
219
|
command: string;
|
|
190
220
|
aliases: string[];
|
|
191
221
|
description: string;
|
|
192
|
-
author:
|
|
222
|
+
author: any;
|
|
193
223
|
processors?: ICliCommandProcessor[];
|
|
194
224
|
metadata?: CliProcessorMetadata;
|
|
195
225
|
constructor();
|
|
@@ -201,7 +231,7 @@ declare class CliColorCommandProcessor implements ICliCommandProcessor {
|
|
|
201
231
|
command: string;
|
|
202
232
|
aliases: string[];
|
|
203
233
|
description: string;
|
|
204
|
-
author:
|
|
234
|
+
author: any;
|
|
205
235
|
acceptsRawInput: boolean;
|
|
206
236
|
valueRequired: boolean;
|
|
207
237
|
metadata?: CliProcessorMetadata;
|
|
@@ -219,7 +249,7 @@ declare class CliConvertCommandProcessor implements ICliCommandProcessor {
|
|
|
219
249
|
command: string;
|
|
220
250
|
aliases: string[];
|
|
221
251
|
description: string;
|
|
222
|
-
author:
|
|
252
|
+
author: any;
|
|
223
253
|
acceptsRawInput: boolean;
|
|
224
254
|
valueRequired: boolean;
|
|
225
255
|
metadata?: CliProcessorMetadata;
|
|
@@ -235,11 +265,9 @@ declare class CliEchoCommandProcessor implements ICliCommandProcessor {
|
|
|
235
265
|
aliases: string[];
|
|
236
266
|
description: string;
|
|
237
267
|
acceptsRawInput: boolean;
|
|
238
|
-
author:
|
|
268
|
+
author: any;
|
|
239
269
|
metadata?: CliProcessorMetadata | undefined;
|
|
240
270
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
241
|
-
/** Remove surrounding quotes from the text. */
|
|
242
|
-
private stripQuotes;
|
|
243
271
|
/** Interpret common escape sequences like a POSIX echo -e. */
|
|
244
272
|
private interpretEscapes;
|
|
245
273
|
writeDescription(context: ICliExecutionContext): void;
|
|
@@ -249,7 +277,7 @@ declare class CliEvalCommandProcessor implements ICliCommandProcessor {
|
|
|
249
277
|
command: string;
|
|
250
278
|
aliases: string[];
|
|
251
279
|
description: string;
|
|
252
|
-
author:
|
|
280
|
+
author: any;
|
|
253
281
|
acceptsRawInput: boolean;
|
|
254
282
|
metadata?: CliProcessorMetadata | undefined;
|
|
255
283
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
@@ -259,7 +287,7 @@ declare class CliEvalCommandProcessor implements ICliCommandProcessor {
|
|
|
259
287
|
declare class CliJsonCommandProcessor implements ICliCommandProcessor {
|
|
260
288
|
command: string;
|
|
261
289
|
description: string;
|
|
262
|
-
author:
|
|
290
|
+
author: any;
|
|
263
291
|
processors?: ICliCommandProcessor[];
|
|
264
292
|
metadata?: CliProcessorMetadata;
|
|
265
293
|
constructor();
|
|
@@ -271,7 +299,7 @@ declare class CliLoremCommandProcessor implements ICliCommandProcessor {
|
|
|
271
299
|
command: string;
|
|
272
300
|
aliases: string[];
|
|
273
301
|
description: string;
|
|
274
|
-
author:
|
|
302
|
+
author: any;
|
|
275
303
|
processors?: ICliCommandProcessor[];
|
|
276
304
|
metadata?: CliProcessorMetadata;
|
|
277
305
|
constructor();
|
|
@@ -283,7 +311,7 @@ declare class CliLoremCommandProcessor implements ICliCommandProcessor {
|
|
|
283
311
|
declare class CliOpenCommandProcessor implements ICliCommandProcessor {
|
|
284
312
|
command: string;
|
|
285
313
|
description: string;
|
|
286
|
-
author:
|
|
314
|
+
author: any;
|
|
287
315
|
acceptsRawInput: boolean;
|
|
288
316
|
valueRequired: boolean;
|
|
289
317
|
metadata?: CliProcessorMetadata;
|
|
@@ -295,7 +323,7 @@ declare class CliRandomCommandProcessor implements ICliCommandProcessor {
|
|
|
295
323
|
command: string;
|
|
296
324
|
aliases: string[];
|
|
297
325
|
description: string;
|
|
298
|
-
author:
|
|
326
|
+
author: any;
|
|
299
327
|
processors?: ICliCommandProcessor[];
|
|
300
328
|
metadata?: CliProcessorMetadata;
|
|
301
329
|
constructor();
|
|
@@ -307,7 +335,7 @@ declare class CliScreenCommandProcessor implements ICliCommandProcessor {
|
|
|
307
335
|
command: string;
|
|
308
336
|
aliases: string[];
|
|
309
337
|
description: string;
|
|
310
|
-
author:
|
|
338
|
+
author: any;
|
|
311
339
|
metadata?: CliProcessorMetadata;
|
|
312
340
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
313
341
|
writeDescription(context: ICliExecutionContext): void;
|
|
@@ -317,7 +345,7 @@ declare class CliSeqCommandProcessor implements ICliCommandProcessor {
|
|
|
317
345
|
command: string;
|
|
318
346
|
aliases: string[];
|
|
319
347
|
description: string;
|
|
320
|
-
author:
|
|
348
|
+
author: any;
|
|
321
349
|
acceptsRawInput: boolean;
|
|
322
350
|
valueRequired: boolean;
|
|
323
351
|
metadata?: CliProcessorMetadata;
|
|
@@ -342,7 +370,7 @@ declare class CliSleepCommandProcessor implements ICliCommandProcessor {
|
|
|
342
370
|
command: string;
|
|
343
371
|
aliases: string[];
|
|
344
372
|
description?: string | undefined;
|
|
345
|
-
author:
|
|
373
|
+
author: any;
|
|
346
374
|
metadata?: CliProcessorMetadata | undefined;
|
|
347
375
|
valueRequired?: boolean | undefined;
|
|
348
376
|
constructor();
|
|
@@ -354,7 +382,7 @@ declare class CliTimeCommandProcessor implements ICliCommandProcessor {
|
|
|
354
382
|
command: string;
|
|
355
383
|
aliases: string[];
|
|
356
384
|
description: string;
|
|
357
|
-
author:
|
|
385
|
+
author: any;
|
|
358
386
|
version: string;
|
|
359
387
|
processors?: ICliCommandProcessor[] | undefined;
|
|
360
388
|
metadata?: CliProcessorMetadata | undefined;
|
|
@@ -367,7 +395,7 @@ declare class CliTimestampCommandProcessor implements ICliCommandProcessor {
|
|
|
367
395
|
command: string;
|
|
368
396
|
aliases: string[];
|
|
369
397
|
description: string;
|
|
370
|
-
author:
|
|
398
|
+
author: any;
|
|
371
399
|
processors?: ICliCommandProcessor[];
|
|
372
400
|
metadata?: CliProcessorMetadata;
|
|
373
401
|
constructor();
|
|
@@ -377,7 +405,7 @@ declare class CliTimestampCommandProcessor implements ICliCommandProcessor {
|
|
|
377
405
|
|
|
378
406
|
declare class CliUnAliasCommandProcessor implements ICliCommandProcessor {
|
|
379
407
|
command: string;
|
|
380
|
-
author:
|
|
408
|
+
author: any;
|
|
381
409
|
description: string;
|
|
382
410
|
valueRequired?: boolean | undefined;
|
|
383
411
|
stateConfiguration?: CliStateConfiguration | undefined;
|
|
@@ -390,7 +418,7 @@ declare class CliUnameCommandProcessor implements ICliCommandProcessor {
|
|
|
390
418
|
command: string;
|
|
391
419
|
aliases: string[];
|
|
392
420
|
description?: string | undefined;
|
|
393
|
-
author:
|
|
421
|
+
author: any;
|
|
394
422
|
metadata?: CliProcessorMetadata | undefined;
|
|
395
423
|
writeDescription(context: ICliExecutionContext): void;
|
|
396
424
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
@@ -404,7 +432,7 @@ declare class CliUnameCommandProcessor implements ICliCommandProcessor {
|
|
|
404
432
|
declare class CliUptimeCommandProcessor implements ICliCommandProcessor {
|
|
405
433
|
command: string;
|
|
406
434
|
description: string;
|
|
407
|
-
author:
|
|
435
|
+
author: any;
|
|
408
436
|
metadata?: CliProcessorMetadata;
|
|
409
437
|
initialize(context: ICliExecutionContext): Promise<void>;
|
|
410
438
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
@@ -414,7 +442,7 @@ declare class CliUptimeCommandProcessor implements ICliCommandProcessor {
|
|
|
414
442
|
declare class CliYesCommandProcessor implements ICliCommandProcessor {
|
|
415
443
|
command: string;
|
|
416
444
|
description: string;
|
|
417
|
-
author:
|
|
445
|
+
author: any;
|
|
418
446
|
acceptsRawInput: boolean;
|
|
419
447
|
metadata?: CliProcessorMetadata;
|
|
420
448
|
parameters: {
|
|
@@ -428,14 +456,49 @@ declare class CliYesCommandProcessor implements ICliCommandProcessor {
|
|
|
428
456
|
writeDescription(context: ICliExecutionContext): void;
|
|
429
457
|
}
|
|
430
458
|
|
|
459
|
+
/**
|
|
460
|
+
* `test EXPR` / `[ EXPR ]`: evaluate a condition; exit status 0 when true,
|
|
461
|
+
* 1 when false and 2 on an error. Used by `if`, `while` and `&&`/`||`.
|
|
462
|
+
*/
|
|
463
|
+
declare class CliTestCommandProcessor implements ICliCommandProcessor {
|
|
464
|
+
command: string;
|
|
465
|
+
aliases: string[];
|
|
466
|
+
description: string;
|
|
467
|
+
author: any;
|
|
468
|
+
acceptsRawInput: boolean;
|
|
469
|
+
metadata?: CliProcessorMetadata;
|
|
470
|
+
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
471
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
472
|
+
}
|
|
473
|
+
/** `true`: do nothing, successfully (also `:`). */
|
|
474
|
+
declare class CliTrueCommandProcessor implements ICliCommandProcessor {
|
|
475
|
+
command: string;
|
|
476
|
+
aliases: string[];
|
|
477
|
+
description: string;
|
|
478
|
+
author: any;
|
|
479
|
+
acceptsRawInput: boolean;
|
|
480
|
+
metadata?: CliProcessorMetadata;
|
|
481
|
+
processCommand(): Promise<void>;
|
|
482
|
+
}
|
|
483
|
+
/** `false`: do nothing, unsuccessfully (exit status 1). */
|
|
484
|
+
declare class CliFalseCommandProcessor implements ICliCommandProcessor {
|
|
485
|
+
command: string;
|
|
486
|
+
description: string;
|
|
487
|
+
author: any;
|
|
488
|
+
acceptsRawInput: boolean;
|
|
489
|
+
metadata?: CliProcessorMetadata;
|
|
490
|
+
processCommand(_command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
491
|
+
}
|
|
492
|
+
|
|
431
493
|
declare class CliCaptureCommandProcessor implements ICliCommandProcessor {
|
|
432
494
|
command: string;
|
|
433
495
|
description: string;
|
|
434
496
|
aliases: string[];
|
|
435
497
|
author: ICliCommandAuthor;
|
|
436
498
|
metadata: CliProcessorMetadata;
|
|
437
|
-
parameters: ICliCommandParameterDescriptor[];
|
|
499
|
+
parameters: ICliCommandParameterDescriptor$1[];
|
|
438
500
|
processCommand(cmd: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
501
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
439
502
|
private sanitizeCssColor;
|
|
440
503
|
private toHtml;
|
|
441
504
|
private escapeHtml;
|
|
@@ -450,6 +513,7 @@ declare class CliSnippetCommandProcessor implements ICliCommandProcessor {
|
|
|
450
513
|
metadata: CliProcessorMetadata;
|
|
451
514
|
stateConfiguration: CliStateConfiguration;
|
|
452
515
|
processors: ICliCommandChildProcessor[];
|
|
516
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
453
517
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
454
518
|
}
|
|
455
519
|
|
|
@@ -458,8 +522,9 @@ declare class CliDiffCommandProcessor implements ICliCommandProcessor {
|
|
|
458
522
|
description: string;
|
|
459
523
|
author: ICliCommandAuthor;
|
|
460
524
|
metadata: CliProcessorMetadata;
|
|
461
|
-
parameters: ICliCommandParameterDescriptor[];
|
|
525
|
+
parameters: ICliCommandParameterDescriptor$1[];
|
|
462
526
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
527
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
463
528
|
}
|
|
464
529
|
|
|
465
530
|
type DiffType = 'same' | 'add' | 'remove';
|
|
@@ -481,11 +546,17 @@ declare class CliHelpCommandProcessor implements ICliCommandProcessor {
|
|
|
481
546
|
aliases: string[];
|
|
482
547
|
description: string;
|
|
483
548
|
acceptsRawInput?: boolean | undefined;
|
|
484
|
-
author:
|
|
549
|
+
author: any;
|
|
485
550
|
metadata?: CliProcessorMetadata | undefined;
|
|
486
551
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
487
552
|
writeDescription(context: ICliExecutionContext): void;
|
|
488
553
|
private translateDescription;
|
|
554
|
+
/**
|
|
555
|
+
* Canonical path of the command being described (`server.status` for
|
|
556
|
+
* `help srv ping`), so a sub-command's translation keys include its
|
|
557
|
+
* parents: `cli.server.status.description`.
|
|
558
|
+
*/
|
|
559
|
+
private commandPath;
|
|
489
560
|
private writeProcessorDescription;
|
|
490
561
|
private formatModuleName;
|
|
491
562
|
private writeParameter;
|
|
@@ -531,44 +602,45 @@ declare class CliHotKeysCommandProcessor implements ICliCommandProcessor {
|
|
|
531
602
|
aliases: string[];
|
|
532
603
|
description: string;
|
|
533
604
|
processors?: ICliCommandProcessor[] | undefined;
|
|
534
|
-
author:
|
|
605
|
+
author: any;
|
|
535
606
|
metadata?: CliProcessorMetadata | undefined;
|
|
536
607
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
537
608
|
writeDescription(context: ICliExecutionContext): void;
|
|
538
609
|
}
|
|
539
610
|
|
|
611
|
+
/** `pkg`: install, update and remove CLI plugins at runtime from npm/CDN sources. */
|
|
540
612
|
declare class CliPackagesCommandProcessor implements ICliCommandProcessor {
|
|
541
613
|
readonly command = "pkg";
|
|
542
614
|
readonly aliases: string[];
|
|
543
615
|
description: string;
|
|
544
|
-
author:
|
|
545
|
-
readonly version = "1.0
|
|
546
|
-
readonly processors
|
|
616
|
+
author: any;
|
|
617
|
+
readonly version = "1.1.0";
|
|
618
|
+
readonly processors: ICliCommandProcessor[];
|
|
547
619
|
readonly metadata?: CliProcessorMetadata | undefined;
|
|
548
620
|
stateConfiguration?: CliStateConfiguration | undefined;
|
|
549
|
-
private
|
|
550
|
-
private
|
|
551
|
-
private
|
|
552
|
-
private registry;
|
|
553
|
-
private createAbortSignal;
|
|
621
|
+
private readonly loader;
|
|
622
|
+
private readonly manager;
|
|
623
|
+
private readonly installer;
|
|
554
624
|
constructor();
|
|
555
625
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
556
|
-
writeDescription
|
|
626
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
557
627
|
initialize(context: ICliExecutionContext): Promise<void>;
|
|
558
|
-
private
|
|
559
|
-
private
|
|
560
|
-
private
|
|
561
|
-
private
|
|
562
|
-
private
|
|
563
|
-
private
|
|
564
|
-
private
|
|
565
|
-
private
|
|
628
|
+
private lsCommand;
|
|
629
|
+
private browseCommand;
|
|
630
|
+
private addCommand;
|
|
631
|
+
private removeCommand;
|
|
632
|
+
private versionsCommand;
|
|
633
|
+
private checkCommand;
|
|
634
|
+
private updateCommand;
|
|
635
|
+
private sourceCommand;
|
|
636
|
+
/** Install as a tracked background job (visible in `services`), or inline if that fails. */
|
|
637
|
+
private installInBackground;
|
|
566
638
|
}
|
|
567
639
|
|
|
568
640
|
declare class CliDebugCommandProcessor implements ICliCommandProcessor {
|
|
569
641
|
command: string;
|
|
570
642
|
description: string;
|
|
571
|
-
author:
|
|
643
|
+
author: any;
|
|
572
644
|
metadata?: CliProcessorMetadata;
|
|
573
645
|
processors?: ICliCommandProcessor[];
|
|
574
646
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
@@ -580,7 +652,7 @@ declare class CliNanoCommandProcessor implements ICliCommandProcessor {
|
|
|
580
652
|
command: string;
|
|
581
653
|
aliases: string[];
|
|
582
654
|
description: string;
|
|
583
|
-
author:
|
|
655
|
+
author: any;
|
|
584
656
|
acceptsRawInput: boolean;
|
|
585
657
|
metadata: CliProcessorMetadata;
|
|
586
658
|
private buffer;
|
|
@@ -618,7 +690,7 @@ declare class CliServicesCommandProcessor implements ICliCommandProcessor {
|
|
|
618
690
|
command: string;
|
|
619
691
|
aliases: string[];
|
|
620
692
|
description: string;
|
|
621
|
-
author:
|
|
693
|
+
author: any;
|
|
622
694
|
processors?: ICliCommandProcessor[];
|
|
623
695
|
metadata?: CliProcessorMetadata;
|
|
624
696
|
constructor();
|
|
@@ -626,33 +698,50 @@ declare class CliServicesCommandProcessor implements ICliCommandProcessor {
|
|
|
626
698
|
writeDescription(context: ICliExecutionContext): void;
|
|
627
699
|
}
|
|
628
700
|
|
|
701
|
+
/**
|
|
702
|
+
* `events`: inspect the terminal's event bus — watch events live, show the
|
|
703
|
+
* recent ones, or emit one (for testing plugins).
|
|
704
|
+
*/
|
|
705
|
+
declare class CliEventsCommandProcessor implements ICliCommandProcessor {
|
|
706
|
+
command: string;
|
|
707
|
+
description: string;
|
|
708
|
+
author: any;
|
|
709
|
+
version: string;
|
|
710
|
+
metadata?: CliProcessorMetadata;
|
|
711
|
+
processors: ICliCommandProcessor[];
|
|
712
|
+
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
713
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
714
|
+
}
|
|
715
|
+
|
|
629
716
|
declare class CliPsCommandProcessor implements ICliCommandProcessor {
|
|
630
717
|
command: string;
|
|
631
718
|
description: string;
|
|
632
|
-
author:
|
|
719
|
+
author: any;
|
|
633
720
|
metadata: {
|
|
634
721
|
icon: string;
|
|
635
722
|
sealed: boolean;
|
|
636
723
|
};
|
|
637
724
|
processCommand(_command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
725
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
638
726
|
}
|
|
639
727
|
|
|
640
728
|
declare class CliKillCommandProcessor implements ICliCommandProcessor {
|
|
641
729
|
command: string;
|
|
642
730
|
description: string;
|
|
643
|
-
author:
|
|
731
|
+
author: any;
|
|
644
732
|
valueRequired: boolean;
|
|
645
733
|
metadata: {
|
|
646
734
|
icon: string;
|
|
647
735
|
sealed: boolean;
|
|
648
736
|
};
|
|
649
737
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
738
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
650
739
|
}
|
|
651
740
|
|
|
652
741
|
declare class CliHtopCommandProcessor implements ICliCommandProcessor {
|
|
653
742
|
command: string;
|
|
654
743
|
description: string;
|
|
655
|
-
author:
|
|
744
|
+
author: any;
|
|
656
745
|
metadata?: CliProcessorMetadata;
|
|
657
746
|
private context;
|
|
658
747
|
private registry;
|
|
@@ -701,6 +790,8 @@ declare class CliThemeCommandProcessor implements ICliCommandProcessor {
|
|
|
701
790
|
private defaultTheme;
|
|
702
791
|
constructor();
|
|
703
792
|
initialize(context: ICliExecutionContext): Promise<void>;
|
|
793
|
+
/** Apply the saved theme (or the default one when `reset` and none is saved). */
|
|
794
|
+
private applySavedTheme;
|
|
704
795
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
705
796
|
private renderThemePreview;
|
|
706
797
|
private applyStyles;
|
|
@@ -712,39 +803,7 @@ type ThemeState = {
|
|
|
712
803
|
selectedTheme?: string;
|
|
713
804
|
customOptions?: ITheme;
|
|
714
805
|
};
|
|
715
|
-
declare const themes:
|
|
716
|
-
[key: string]: ITheme;
|
|
717
|
-
default: _qodalis_cli_core.CliTheme;
|
|
718
|
-
classic: _qodalis_cli_core.CliTheme;
|
|
719
|
-
dracula: _qodalis_cli_core.CliTheme;
|
|
720
|
-
monokai: _qodalis_cli_core.CliTheme;
|
|
721
|
-
solarizedDark: _qodalis_cli_core.CliTheme;
|
|
722
|
-
solarizedLight: _qodalis_cli_core.CliTheme;
|
|
723
|
-
gruvboxDark: _qodalis_cli_core.CliTheme;
|
|
724
|
-
gruvboxLight: _qodalis_cli_core.CliTheme;
|
|
725
|
-
nord: _qodalis_cli_core.CliTheme;
|
|
726
|
-
oneDark: _qodalis_cli_core.CliTheme;
|
|
727
|
-
material: _qodalis_cli_core.CliTheme;
|
|
728
|
-
highContrastLight: _qodalis_cli_core.CliTheme;
|
|
729
|
-
tokyoNight: _qodalis_cli_core.CliTheme;
|
|
730
|
-
catppuccinMocha: _qodalis_cli_core.CliTheme;
|
|
731
|
-
catppuccinFrappe: _qodalis_cli_core.CliTheme;
|
|
732
|
-
rosePine: _qodalis_cli_core.CliTheme;
|
|
733
|
-
kanagawa: _qodalis_cli_core.CliTheme;
|
|
734
|
-
everforestDark: _qodalis_cli_core.CliTheme;
|
|
735
|
-
ayuDark: _qodalis_cli_core.CliTheme;
|
|
736
|
-
catppuccinLatte: _qodalis_cli_core.CliTheme;
|
|
737
|
-
rosePineDawn: _qodalis_cli_core.CliTheme;
|
|
738
|
-
everforestLight: _qodalis_cli_core.CliTheme;
|
|
739
|
-
githubLight: _qodalis_cli_core.CliTheme;
|
|
740
|
-
cyberpunk: _qodalis_cli_core.CliTheme;
|
|
741
|
-
retroGreen: _qodalis_cli_core.CliTheme;
|
|
742
|
-
retroAmber: _qodalis_cli_core.CliTheme;
|
|
743
|
-
matrix: _qodalis_cli_core.CliTheme;
|
|
744
|
-
synthwave: _qodalis_cli_core.CliTheme;
|
|
745
|
-
highContrastDark: _qodalis_cli_core.CliTheme;
|
|
746
|
-
yellow: _qodalis_cli_core.CliTheme;
|
|
747
|
-
};
|
|
806
|
+
declare const themes: any;
|
|
748
807
|
declare const themeInfos: Record<string, CliThemeInfo>;
|
|
749
808
|
|
|
750
809
|
declare class CliConfigureCommandProcessor implements ICliCommandProcessor {
|
|
@@ -764,7 +823,16 @@ declare class CliConfigureCommandProcessor implements ICliCommandProcessor {
|
|
|
764
823
|
private editOption;
|
|
765
824
|
private setConfigValue;
|
|
766
825
|
private getConfigValue;
|
|
826
|
+
/**
|
|
827
|
+
* The language choices are the locales loaded so far: a language pack
|
|
828
|
+
* installed after boot (`pkg add @qodalis/cli-lang-de`) adds one.
|
|
829
|
+
*/
|
|
830
|
+
private refreshLanguageOptions;
|
|
767
831
|
private getAllOptions;
|
|
832
|
+
/**
|
|
833
|
+
* @param onBoot at startup, terminal options still at their default are skipped so the
|
|
834
|
+
* host's `terminalOptions` (e.g. its own fontSize) are not overridden.
|
|
835
|
+
*/
|
|
768
836
|
private applySystemSettings;
|
|
769
837
|
private buildListProcessor;
|
|
770
838
|
private buildGetProcessor;
|
|
@@ -799,22 +867,39 @@ declare class CliPingCommandProcessor implements ICliCommandProcessor {
|
|
|
799
867
|
private sleep;
|
|
800
868
|
}
|
|
801
869
|
|
|
870
|
+
/** Permission to change shared variables, when an auth module is loaded. */
|
|
871
|
+
declare const CLI_ENV_GLOBAL_PERMISSION = "system:env:global";
|
|
872
|
+
/** Parse `A=1 B="two words" C` into assignments; bare names have no value. */
|
|
873
|
+
declare function parseAssignments(raw: string): {
|
|
874
|
+
name: string;
|
|
875
|
+
value?: string;
|
|
876
|
+
}[] | null;
|
|
802
877
|
/**
|
|
803
878
|
* `export` — set environment variables.
|
|
804
879
|
*
|
|
805
880
|
* Usage:
|
|
806
881
|
* export VAR=value
|
|
807
|
-
* export VAR="value with spaces"
|
|
882
|
+
* export VAR="value with spaces" OTHER=1
|
|
883
|
+
*
|
|
884
|
+
* Variables are saved for the signed-in user (`--global`: for everyone) and
|
|
885
|
+
* restored on the next visit. `NAME=value` alone is for this terminal only.
|
|
808
886
|
*/
|
|
809
887
|
declare class CliExportCommandProcessor implements ICliCommandProcessor {
|
|
810
888
|
command: string;
|
|
811
889
|
description: string;
|
|
812
|
-
author:
|
|
890
|
+
author: any;
|
|
813
891
|
acceptsRawInput: boolean;
|
|
814
892
|
metadata: {
|
|
815
893
|
icon: string;
|
|
816
894
|
module: string;
|
|
817
895
|
};
|
|
896
|
+
parameters: ICliCommandParameterDescriptor[];
|
|
897
|
+
stateConfiguration: CliStateConfiguration;
|
|
898
|
+
/**
|
|
899
|
+
* Restore saved variables, save every later change (export, unset) and
|
|
900
|
+
* follow changes saved in other tabs and terminals.
|
|
901
|
+
*/
|
|
902
|
+
initialize(context: ICliExecutionContext): Promise<void>;
|
|
818
903
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
819
904
|
writeDescription(context: ICliExecutionContext): void;
|
|
820
905
|
}
|
|
@@ -824,12 +909,13 @@ declare class CliExportCommandProcessor implements ICliCommandProcessor {
|
|
|
824
909
|
declare class CliUnsetCommandProcessor implements ICliCommandProcessor {
|
|
825
910
|
command: string;
|
|
826
911
|
description: string;
|
|
827
|
-
author:
|
|
912
|
+
author: any;
|
|
828
913
|
acceptsRawInput: boolean;
|
|
829
914
|
metadata: {
|
|
830
915
|
icon: string;
|
|
831
916
|
module: string;
|
|
832
917
|
};
|
|
918
|
+
parameters: any[];
|
|
833
919
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
834
920
|
writeDescription(context: ICliExecutionContext): void;
|
|
835
921
|
}
|
|
@@ -840,7 +926,7 @@ declare class CliEnvCommandProcessor implements ICliCommandProcessor {
|
|
|
840
926
|
command: string;
|
|
841
927
|
aliases: string[];
|
|
842
928
|
description: string;
|
|
843
|
-
author:
|
|
929
|
+
author: any;
|
|
844
930
|
acceptsRawInput: boolean;
|
|
845
931
|
metadata: {
|
|
846
932
|
icon: string;
|
|
@@ -858,13 +944,18 @@ declare class CliFontSizeCommandProcessor implements ICliCommandProcessor {
|
|
|
858
944
|
metadata: CliProcessorMetadata;
|
|
859
945
|
stateConfiguration: CliStateConfiguration;
|
|
860
946
|
processors: ICliCommandProcessor[];
|
|
947
|
+
/** The size the host configured (or the built-in default), restored by `font-size reset`. */
|
|
948
|
+
private hostFontSize?;
|
|
861
949
|
initialize(context: ICliExecutionContext): Promise<void>;
|
|
862
950
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
951
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
863
952
|
private getCurrent;
|
|
953
|
+
private getDefault;
|
|
954
|
+
private resetFontSize;
|
|
864
955
|
private setFontSize;
|
|
865
956
|
}
|
|
866
957
|
|
|
867
|
-
declare const miscProcessors: (
|
|
958
|
+
declare const miscProcessors: (CliClearCommandProcessor | CliEchoCommandProcessor | CliEvalCommandProcessor | CliAliasCommandProcessor | CliUnAliasCommandProcessor | CliSleepCommandProcessor | CliUnameCommandProcessor | CliTimeCommandProcessor | CliJsonCommandProcessor | CliRandomCommandProcessor | CliUptimeCommandProcessor | CliOpenCommandProcessor | CliLoremCommandProcessor | CliTimestampCommandProcessor | CliColorCommandProcessor | CliCalCommandProcessor | CliSeqCommandProcessor | CliScreenCommandProcessor | CliClipboardCommandProcessor | CliConvertCommandProcessor | CliYesCommandProcessor | CliTestCommandProcessor | CliTrueCommandProcessor | CliFalseCommandProcessor)[];
|
|
868
959
|
declare const builtinProcessors: ICliCommandProcessor[];
|
|
869
960
|
|
|
870
961
|
declare class CliExecutionProcess implements ICliExecutionProcess {
|
|
@@ -908,6 +999,8 @@ declare class CliCommandExecutionContext implements ICliExecutionContext {
|
|
|
908
999
|
translator: ICliTranslationService;
|
|
909
1000
|
reader: ICliInputReader;
|
|
910
1001
|
readonly backgroundServices: ICliBackgroundServiceRegistry;
|
|
1002
|
+
http: ICliHttpClient;
|
|
1003
|
+
notifier: ICliNotifier;
|
|
911
1004
|
get promptLength(): number;
|
|
912
1005
|
set promptLength(value: number);
|
|
913
1006
|
get currentLine(): string;
|
|
@@ -926,14 +1019,35 @@ declare class CliCommandExecutionContext implements ICliExecutionContext {
|
|
|
926
1019
|
exitFullScreenMode: () => void;
|
|
927
1020
|
createInterval: (callback: () => void, ms: number) => ICliManagedInterval;
|
|
928
1021
|
createTimeout: (callback: () => void, ms: number) => ICliManagedTimer;
|
|
1022
|
+
submitCommand: (command: string) => Promise<void>;
|
|
1023
|
+
events?: ICliEventBus;
|
|
1024
|
+
get isBooted(): boolean | undefined;
|
|
929
1025
|
constructor(context: ICliExecutionContext, processor: ICliCommandProcessor);
|
|
930
1026
|
}
|
|
931
1027
|
|
|
1028
|
+
/**
|
|
1029
|
+
* Command history, kept per user like a shell's `~/.bash_history`: each
|
|
1030
|
+
* signed-in user (by id) has their own, and the shared one is used while
|
|
1031
|
+
* nobody is signed in.
|
|
1032
|
+
*/
|
|
932
1033
|
declare class CliCommandHistory {
|
|
933
1034
|
private readonly store;
|
|
934
|
-
private readonly storageKey;
|
|
935
1035
|
private commandHistory;
|
|
1036
|
+
/** Id of the user whose history is loaded; undefined: nobody signed in */
|
|
1037
|
+
private userId;
|
|
1038
|
+
private loading;
|
|
1039
|
+
/** Counts user switches (a load for an older one is dropped) */
|
|
1040
|
+
private switches;
|
|
1041
|
+
private _generation;
|
|
936
1042
|
constructor(store: ICliKeyValueStore);
|
|
1043
|
+
/** Changes whenever the history is replaced: switched or loaded (positions into it are stale) */
|
|
1044
|
+
get generation(): number;
|
|
1045
|
+
private get storageKey();
|
|
1046
|
+
/**
|
|
1047
|
+
* Switch to the history of `userId` (undefined: nobody signed in).
|
|
1048
|
+
* Resolves once it is loaded; a no-op for the user already loaded.
|
|
1049
|
+
*/
|
|
1050
|
+
useUser(userId: string | undefined): Promise<void>;
|
|
937
1051
|
addCommand(command: string): Promise<void>;
|
|
938
1052
|
getLastIndex(): number;
|
|
939
1053
|
getHistory(): string[];
|
|
@@ -964,7 +1078,7 @@ declare class CliCommandHistory {
|
|
|
964
1078
|
|
|
965
1079
|
interface ICliStateStoreManager {
|
|
966
1080
|
getProcessorStateStore(processor: ICliCommandProcessor): ICliStateStore;
|
|
967
|
-
getStateStore(name: string, defaultState?: Record<string, any
|
|
1081
|
+
getStateStore(name: string, defaultState?: Record<string, any>, options?: CliStateStoreOptions): ICliStateStore;
|
|
968
1082
|
getStoreEntries(): {
|
|
969
1083
|
name: string;
|
|
970
1084
|
state: Record<string, any>;
|
|
@@ -974,9 +1088,25 @@ declare class CliStateStoreManager implements ICliStateStoreManager {
|
|
|
974
1088
|
private readonly services;
|
|
975
1089
|
private readonly registry;
|
|
976
1090
|
private stores;
|
|
1091
|
+
private channel?;
|
|
1092
|
+
/** The signed-in user (for `scope: 'user'` stores). */
|
|
1093
|
+
private user?;
|
|
1094
|
+
private stopFollowingUser?;
|
|
977
1095
|
constructor(services: ICliServiceProvider, registry: ICliCommandProcessorRegistry);
|
|
978
|
-
|
|
1096
|
+
/**
|
|
1097
|
+
* Get (or create) the store `name`. Defaults and options passed for a
|
|
1098
|
+
* store that already exists are added to it: a store read early (e.g.
|
|
1099
|
+
* by the boot report) still gets its command's initial state.
|
|
1100
|
+
*/
|
|
1101
|
+
getStateStore(name: string, defaultState?: Record<string, any>, options?: CliStateStoreOptions): ICliStateStore;
|
|
979
1102
|
getProcessorStateStore(processor: ICliCommandProcessor): ICliStateStore;
|
|
1103
|
+
/**
|
|
1104
|
+
* Follow the signed-in user (`session:changed` events), so `scope: 'user'`
|
|
1105
|
+
* stores switch to that user's state.
|
|
1106
|
+
*/
|
|
1107
|
+
followUser(events: ICliEventBus): void;
|
|
1108
|
+
/** Switch `scope: 'user'` stores to `user`'s saved state. */
|
|
1109
|
+
setUser(user: string | undefined): void;
|
|
980
1110
|
/**
|
|
981
1111
|
* Returns all store names and their current state values.
|
|
982
1112
|
*/
|
|
@@ -989,6 +1119,9 @@ declare class CliStateStoreManager implements ICliStateStoreManager {
|
|
|
989
1119
|
* Called during engine teardown.
|
|
990
1120
|
*/
|
|
991
1121
|
dispose(): void;
|
|
1122
|
+
/** Tell other tabs and terminals that a store was saved. */
|
|
1123
|
+
private publish;
|
|
1124
|
+
private listen;
|
|
992
1125
|
}
|
|
993
1126
|
|
|
994
1127
|
/**
|
|
@@ -1024,6 +1157,10 @@ declare class CliCompletionEngine {
|
|
|
1024
1157
|
candidates?: string[];
|
|
1025
1158
|
}>;
|
|
1026
1159
|
private buildContext;
|
|
1160
|
+
/**
|
|
1161
|
+
* Words with their start, quote-aware: `cat "my notes.txt"` has two, and an
|
|
1162
|
+
* unclosed quote runs to the end (`cat "my no` is being typed).
|
|
1163
|
+
*/
|
|
1027
1164
|
private tokenize;
|
|
1028
1165
|
private fetchCompletions;
|
|
1029
1166
|
/**
|
|
@@ -1054,6 +1191,12 @@ declare class CliLineBuffer {
|
|
|
1054
1191
|
moveEnd(): void;
|
|
1055
1192
|
clear(): void;
|
|
1056
1193
|
setText(str: string): void;
|
|
1194
|
+
/** Remove the text before the cursor (Ctrl+U); returns it */
|
|
1195
|
+
deleteToStart(): string;
|
|
1196
|
+
/** Remove the text from the cursor to the end (Ctrl+K); returns it */
|
|
1197
|
+
deleteToEnd(): string;
|
|
1198
|
+
/** Remove the whitespace-delimited word before the cursor (Ctrl+W); returns it */
|
|
1199
|
+
deleteWordBefore(): string;
|
|
1057
1200
|
}
|
|
1058
1201
|
|
|
1059
1202
|
/**
|
|
@@ -1108,6 +1251,11 @@ interface InputModeHost {
|
|
|
1108
1251
|
interface PromptOptions {
|
|
1109
1252
|
userName?: string;
|
|
1110
1253
|
hideUserName?: boolean;
|
|
1254
|
+
/**
|
|
1255
|
+
* Shown (dimmed) instead of the user name when an auth module is loaded
|
|
1256
|
+
* but nobody is signed in, e.g. `anonymous:/$`. Empty/undefined: nothing.
|
|
1257
|
+
*/
|
|
1258
|
+
anonymousName?: string;
|
|
1111
1259
|
contextProcessor?: string;
|
|
1112
1260
|
pathProvider?: () => string | null;
|
|
1113
1261
|
}
|
|
@@ -1172,7 +1320,12 @@ interface CliExecutionContextDeps {
|
|
|
1172
1320
|
declare class CliExecutionContext implements ICliExecutionContext, InputModeHost, CommandLineModeHost {
|
|
1173
1321
|
terminal: Terminal;
|
|
1174
1322
|
executor: ICliCommandExecutorService;
|
|
1175
|
-
|
|
1323
|
+
private _userSession?;
|
|
1324
|
+
/** The signed-in user; changing it emits `session:changed`. */
|
|
1325
|
+
get userSession(): ICliUserSession | undefined;
|
|
1326
|
+
set userSession(session: ICliUserSession | undefined);
|
|
1327
|
+
/** The terminal's event bus. */
|
|
1328
|
+
readonly events?: ICliEventBus;
|
|
1176
1329
|
contextProcessor?: ICliCommandProcessor;
|
|
1177
1330
|
readonly writer: ICliTerminalWriter;
|
|
1178
1331
|
readonly spinner: ICliSpinner;
|
|
@@ -1187,18 +1340,37 @@ declare class CliExecutionContext implements ICliExecutionContext, InputModeHost
|
|
|
1187
1340
|
readonly services: ICliServiceProvider;
|
|
1188
1341
|
readonly translator: ICliTranslationService;
|
|
1189
1342
|
readonly backgroundServices: ICliBackgroundServiceRegistry;
|
|
1343
|
+
http: ICliHttpClient;
|
|
1344
|
+
readonly notifier: ICliNotifier;
|
|
1190
1345
|
promptPathProvider?: () => string | null;
|
|
1191
1346
|
readonly completionEngine: CliCompletionEngine;
|
|
1192
1347
|
promptLength: number;
|
|
1193
1348
|
readonly reader: ICliInputReader;
|
|
1349
|
+
/**
|
|
1350
|
+
* Result of the most recently executed command.
|
|
1351
|
+
* Updated by the command executor after each command completes.
|
|
1352
|
+
*/
|
|
1353
|
+
lastCommandResult?: {
|
|
1354
|
+
command: string;
|
|
1355
|
+
success: boolean;
|
|
1356
|
+
};
|
|
1357
|
+
/**
|
|
1358
|
+
* Whether a command is currently being executed.
|
|
1359
|
+
* Set by the command executor at start/end of executeCommand().
|
|
1360
|
+
*/
|
|
1361
|
+
isExecuting: boolean;
|
|
1194
1362
|
readonly lineBuffer: CliLineBuffer;
|
|
1195
1363
|
readonly lineRenderer: CliTerminalLineRenderer;
|
|
1196
1364
|
readonly commandHistory: CliCommandHistory;
|
|
1197
1365
|
readonly filePickerProvider: ICliFilePickerProvider;
|
|
1198
1366
|
private readonly modeStack;
|
|
1367
|
+
/** Command-line input typed while booting; `null` when not holding. */
|
|
1368
|
+
private heldInput;
|
|
1369
|
+
private releaseHeldInputAtPrompt;
|
|
1370
|
+
private _typedDuringBoot;
|
|
1199
1371
|
private readonly stateStoreManager;
|
|
1200
|
-
private readonly
|
|
1201
|
-
private
|
|
1372
|
+
private readonly timerManager;
|
|
1373
|
+
private readonly fullScreenManager;
|
|
1202
1374
|
private windowKeydownListener?;
|
|
1203
1375
|
constructor(deps: CliExecutionContextDeps, terminal: Terminal, executor: ICliCommandExecutorService, cliOptions?: CliOptions);
|
|
1204
1376
|
writeToTerminal(text: string): void;
|
|
@@ -1208,6 +1380,25 @@ declare class CliExecutionContext implements ICliExecutionContext, InputModeHost
|
|
|
1208
1380
|
get cursorPosition(): number;
|
|
1209
1381
|
set cursorPosition(value: number);
|
|
1210
1382
|
initializeTerminalListeners(): void;
|
|
1383
|
+
private handleTerminalData;
|
|
1384
|
+
private _isBooted;
|
|
1385
|
+
/** `true` once boot has completed and the terminal is ready. */
|
|
1386
|
+
get isBooted(): boolean;
|
|
1387
|
+
/** Called by the engine when boot has completed. */
|
|
1388
|
+
markBooted(): void;
|
|
1389
|
+
/** Start keeping command-line input instead of handling it (boot). */
|
|
1390
|
+
holdInput(): void;
|
|
1391
|
+
/**
|
|
1392
|
+
* Stop holding input: what was typed is replayed at the next prompt, or
|
|
1393
|
+
* right away when `immediately` is set (e.g. no prompt will be drawn).
|
|
1394
|
+
*/
|
|
1395
|
+
releaseInput(immediately?: boolean): void;
|
|
1396
|
+
/** Whether a prompt (readLine, readSelect, ...) or full-screen mode owns the input. */
|
|
1397
|
+
get isReadingInput(): boolean;
|
|
1398
|
+
/** Whether keys were typed while input was held (boot). */
|
|
1399
|
+
get typedDuringBoot(): boolean;
|
|
1400
|
+
private replayHeldInput;
|
|
1401
|
+
private initializeWindowListeners;
|
|
1211
1402
|
setContextProcessor: (processor: ICliCommandProcessor | undefined, silent?: boolean, fullScreen?: boolean) => void;
|
|
1212
1403
|
setCurrentLine(line: string): void;
|
|
1213
1404
|
clearLine(): void;
|
|
@@ -1216,6 +1407,12 @@ declare class CliExecutionContext implements ICliExecutionContext, InputModeHost
|
|
|
1216
1407
|
newLine?: boolean;
|
|
1217
1408
|
keepCurrentLine?: boolean;
|
|
1218
1409
|
}): void;
|
|
1410
|
+
/**
|
|
1411
|
+
* Submit and execute a command — shared by interactive Enter key
|
|
1412
|
+
* and programmatic engine.execute(). Adds to history, runs the
|
|
1413
|
+
* command, and shows a new prompt afterwards.
|
|
1414
|
+
*/
|
|
1415
|
+
submitCommand(command: string): Promise<void>;
|
|
1219
1416
|
clearCurrentLine(): void;
|
|
1220
1417
|
refreshCurrentLine(previousContentLength?: number): void;
|
|
1221
1418
|
/**
|
|
@@ -1231,7 +1428,7 @@ declare class CliExecutionContext implements ICliExecutionContext, InputModeHost
|
|
|
1231
1428
|
*/
|
|
1232
1429
|
handleTerminalResize(): void;
|
|
1233
1430
|
isRawModeActive(): boolean;
|
|
1234
|
-
enterFullScreenMode(processor: ICliCommandProcessor): void;
|
|
1431
|
+
enterFullScreenMode(processor: ICliCommandProcessor, options?: CliFullScreenOptions): void;
|
|
1235
1432
|
exitFullScreenMode(): void;
|
|
1236
1433
|
createInterval(callback: () => void, ms: number): ICliManagedInterval;
|
|
1237
1434
|
createTimeout(callback: () => void, ms: number): ICliManagedTimer;
|
|
@@ -1242,7 +1439,6 @@ declare class CliExecutionContext implements ICliExecutionContext, InputModeHost
|
|
|
1242
1439
|
getPromptLength(): number;
|
|
1243
1440
|
setPromptLength(value: number): void;
|
|
1244
1441
|
getExecutionContext(): ICliExecutionContext;
|
|
1245
|
-
private clearAllManagedTimers;
|
|
1246
1442
|
/**
|
|
1247
1443
|
* Dispose all resources. Called by CliEngine.destroy() when the
|
|
1248
1444
|
* CLI component is being torn down.
|
|
@@ -1253,6 +1449,100 @@ declare class CliExecutionContext implements ICliExecutionContext, InputModeHost
|
|
|
1253
1449
|
popMode(): void;
|
|
1254
1450
|
}
|
|
1255
1451
|
|
|
1452
|
+
/**
|
|
1453
|
+
* Per-session registry that manages background service lifecycle.
|
|
1454
|
+
*/
|
|
1455
|
+
declare class CliBackgroundServiceRegistry implements ICliBackgroundServiceRegistry {
|
|
1456
|
+
private readonly state;
|
|
1457
|
+
private readonly services;
|
|
1458
|
+
private readonly writer?;
|
|
1459
|
+
private readonly entries;
|
|
1460
|
+
private readonly handlers;
|
|
1461
|
+
private isFullScreen;
|
|
1462
|
+
private notificationQueue;
|
|
1463
|
+
private processRegistry?;
|
|
1464
|
+
constructor(state: ICliStateStore, services: ICliServiceProvider, writer?: ICliTerminalWriter);
|
|
1465
|
+
/** Attach the process registry so background services get PIDs */
|
|
1466
|
+
setProcessRegistry(registry: ICliProcessRegistry): void;
|
|
1467
|
+
register(service: ICliBackgroundService): void;
|
|
1468
|
+
start(name: string): Promise<void>;
|
|
1469
|
+
stop(name: string): Promise<void>;
|
|
1470
|
+
restart(name: string): Promise<void>;
|
|
1471
|
+
startJob(name: string, task: (context: ICliServiceContext) => Promise<void>, _options?: {
|
|
1472
|
+
workerCompatible?: boolean;
|
|
1473
|
+
}): Promise<void>;
|
|
1474
|
+
getStatus(name: string): ICliBackgroundServiceInfo | undefined;
|
|
1475
|
+
list(): ICliBackgroundServiceInfo[];
|
|
1476
|
+
getLogs(name: string, limit?: number): ICliServiceLogEntry[];
|
|
1477
|
+
on(handler: CliServiceEventHandler, filter?: {
|
|
1478
|
+
source?: string;
|
|
1479
|
+
type?: string;
|
|
1480
|
+
}): () => void;
|
|
1481
|
+
destroyAll(): Promise<void>;
|
|
1482
|
+
/** Called by the execution context when entering/exiting full-screen mode */
|
|
1483
|
+
setFullScreen(isFullScreen: boolean): void;
|
|
1484
|
+
private getEntry;
|
|
1485
|
+
private toInfo;
|
|
1486
|
+
private updateStatus;
|
|
1487
|
+
private handleStartError;
|
|
1488
|
+
private dispatchEvent;
|
|
1489
|
+
/**
|
|
1490
|
+
* Publish service events on the terminal's event bus: lifecycle events as
|
|
1491
|
+
* `service:<started|stopped|...>`, events relayed from a server's event
|
|
1492
|
+
* socket as `server:event`, other custom events as `service:event`.
|
|
1493
|
+
*/
|
|
1494
|
+
private forwardToEventBus;
|
|
1495
|
+
private emitLifecycleEvent;
|
|
1496
|
+
private notify;
|
|
1497
|
+
private flushNotificationQueue;
|
|
1498
|
+
private writeNotification;
|
|
1499
|
+
private completeInProcessRegistry;
|
|
1500
|
+
private failInProcessRegistry;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
/**
|
|
1504
|
+
* Manages full-screen terminal mode (alternate screen buffer).
|
|
1505
|
+
* Used by interactive commands like nano, htop, etc.
|
|
1506
|
+
*/
|
|
1507
|
+
declare class CliFullScreenManager {
|
|
1508
|
+
private readonly terminal;
|
|
1509
|
+
private readonly backgroundServices;
|
|
1510
|
+
private resizeDisposable;
|
|
1511
|
+
constructor(terminal: Terminal, backgroundServices: CliBackgroundServiceRegistry);
|
|
1512
|
+
/**
|
|
1513
|
+
* Enter full-screen mode using the alternate screen buffer.
|
|
1514
|
+
*/
|
|
1515
|
+
enter(processor: ICliCommandProcessor, setContextProcessor: (p: ICliCommandProcessor | undefined, silent?: boolean, fullScreen?: boolean) => void, context: ICliExecutionContext, options?: CliFullScreenOptions): void;
|
|
1516
|
+
/**
|
|
1517
|
+
* Exit full-screen mode and return to the main buffer.
|
|
1518
|
+
*/
|
|
1519
|
+
exit(contextProcessor: ICliCommandProcessor | undefined, setContextProcessor: (p: ICliCommandProcessor | undefined) => void, clearTimers: () => void, showPrompt: () => void, context: ICliExecutionContext): void;
|
|
1520
|
+
/**
|
|
1521
|
+
* Dispose resize subscription.
|
|
1522
|
+
*/
|
|
1523
|
+
dispose(): void;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
/**
|
|
1527
|
+
* Manages timers and intervals with automatic cleanup.
|
|
1528
|
+
* All managed timers are cleared when the execution context is disposed.
|
|
1529
|
+
*/
|
|
1530
|
+
declare class CliTimerManager {
|
|
1531
|
+
private readonly managedTimers;
|
|
1532
|
+
/**
|
|
1533
|
+
* Create a managed interval that will be automatically cleared on dispose.
|
|
1534
|
+
*/
|
|
1535
|
+
createInterval(callback: () => void, ms: number): ICliManagedInterval;
|
|
1536
|
+
/**
|
|
1537
|
+
* Create a managed timeout that will be automatically cleared on dispose.
|
|
1538
|
+
*/
|
|
1539
|
+
createTimeout(callback: () => void, ms: number): ICliManagedTimer;
|
|
1540
|
+
/**
|
|
1541
|
+
* Clear all managed timers and intervals.
|
|
1542
|
+
*/
|
|
1543
|
+
clearAll(): void;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1256
1546
|
/**
|
|
1257
1547
|
* Extended execution context interface used internally by the command executor.
|
|
1258
1548
|
* The concrete implementation (e.g. CliExecutionContext in angular-cli) provides these.
|
|
@@ -1260,35 +1550,37 @@ declare class CliExecutionContext implements ICliExecutionContext, InputModeHost
|
|
|
1260
1550
|
interface ICliExecutionHost extends ICliExecutionContext {
|
|
1261
1551
|
contextProcessor?: ICliCommandProcessor;
|
|
1262
1552
|
abort?(): void;
|
|
1553
|
+
lastCommandResult?: {
|
|
1554
|
+
command: string;
|
|
1555
|
+
success: boolean;
|
|
1556
|
+
};
|
|
1557
|
+
isExecuting?: boolean;
|
|
1263
1558
|
}
|
|
1264
1559
|
declare class CliCommandExecutor implements ICliCommandExecutorService {
|
|
1265
1560
|
protected readonly registry: ICliCommandProcessorRegistry;
|
|
1266
1561
|
private commandParser;
|
|
1267
1562
|
private globalParameters;
|
|
1563
|
+
/** Exit status of the last command, expanded as `$?` (0 = success). */
|
|
1564
|
+
private lastExitCode;
|
|
1565
|
+
/** Command lines running per terminal (they can overlap). */
|
|
1566
|
+
private readonly running;
|
|
1567
|
+
/** Exit status of the last command line run (`$?`). */
|
|
1568
|
+
get exitStatus(): number;
|
|
1268
1569
|
constructor(registry: ICliCommandProcessorRegistry);
|
|
1269
1570
|
registerGlobalParameter(handler: ICliGlobalParameterHandler): void;
|
|
1270
|
-
getGlobalParameters(): ICliCommandParameterDescriptor[];
|
|
1571
|
+
getGlobalParameters(): ICliCommandParameterDescriptor$1[];
|
|
1271
1572
|
executeCommand(command: string, context: ICliExecutionContext): Promise<void>;
|
|
1272
|
-
|
|
1273
|
-
private
|
|
1573
|
+
/** Whether the command named first on the line takes literal input. */
|
|
1574
|
+
private isLiteralInput;
|
|
1575
|
+
/**
|
|
1576
|
+
* Run a command line and return its output as text instead of showing
|
|
1577
|
+
* it (`$(...)`); its errors and warnings are still shown.
|
|
1578
|
+
*/
|
|
1579
|
+
capture(command: string, from: ICliExecutionContext): Promise<string>;
|
|
1274
1580
|
private executeSingleCommand;
|
|
1275
1581
|
private completeProcess;
|
|
1276
1582
|
private failProcess;
|
|
1277
|
-
private writeStderrToFile;
|
|
1278
|
-
private appendStderrToFile;
|
|
1279
1583
|
showHelp(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
1280
|
-
/**
|
|
1281
|
-
* Attempt to execute a file path as a script.
|
|
1282
|
-
* Returns true if the file was found and executed, false otherwise.
|
|
1283
|
-
* Requires the @qodalis/cli-files plugin for filesystem access.
|
|
1284
|
-
*/
|
|
1285
|
-
private tryExecuteScript;
|
|
1286
|
-
private substituteVars;
|
|
1287
|
-
/**
|
|
1288
|
-
* Expand $VAR and ${VAR} references using the global environment store.
|
|
1289
|
-
* Variables inside single-quoted strings are NOT expanded (like bash).
|
|
1290
|
-
*/
|
|
1291
|
-
private expandEnvironmentVars;
|
|
1292
1584
|
/**
|
|
1293
1585
|
* Validates the command arguments before execution.
|
|
1294
1586
|
* @param context The current CLI execution context.
|
|
@@ -1306,6 +1598,27 @@ declare class CliCommandExecutor implements ICliCommandExecutorService {
|
|
|
1306
1598
|
* parameter. In that case the global handler must be skipped so the
|
|
1307
1599
|
* processor can handle the flag itself.
|
|
1308
1600
|
*/
|
|
1601
|
+
/**
|
|
1602
|
+
* Runs all registered {@link ICliCommandGuard}s that apply to this command,
|
|
1603
|
+
* in priority order. Returns the block message of the first guard that
|
|
1604
|
+
* denies the command, or `undefined` when every guard allows it.
|
|
1605
|
+
* A guard that throws is treated as a denial (fail closed).
|
|
1606
|
+
*/
|
|
1607
|
+
private runGuards;
|
|
1608
|
+
/**
|
|
1609
|
+
* The text after the word that selected `processor`, which may be its
|
|
1610
|
+
* command or one of its aliases (e.g. `pkg rm guid` -> `guid`).
|
|
1611
|
+
*/
|
|
1612
|
+
/**
|
|
1613
|
+
* Reads the words of a command left to right, matching each against the
|
|
1614
|
+
* sub-commands of the processor matched so far. A flag that takes a
|
|
1615
|
+
* value (by the parameters of the processors matched so far, nearest
|
|
1616
|
+
* first) consumes the word after it, so that word is neither a
|
|
1617
|
+
* sub-command nor part of the command's value.
|
|
1618
|
+
*/
|
|
1619
|
+
private commandWords;
|
|
1620
|
+
private extractPositionalValue;
|
|
1621
|
+
private guardDenial;
|
|
1309
1622
|
private processorOwnsParameter;
|
|
1310
1623
|
}
|
|
1311
1624
|
|
|
@@ -1323,81 +1636,55 @@ declare const helpGlobalParameter: ICliGlobalParameterHandler;
|
|
|
1323
1636
|
declare const contextGlobalParameter: ICliGlobalParameterHandler;
|
|
1324
1637
|
|
|
1325
1638
|
/**
|
|
1326
|
-
* A
|
|
1639
|
+
* A terminal writer wrapper that captures "stdout-equivalent" output
|
|
1640
|
+
* (`write`, `writeln`, `writeJson`, `writeObjectsAsTable`, `writeTable`)
|
|
1641
|
+
* while passing everything through to the underlying writer unchanged.
|
|
1327
1642
|
*
|
|
1328
|
-
*
|
|
1329
|
-
*
|
|
1330
|
-
* - `useFactory` : registers a factory function, invoked once on first `get`
|
|
1331
|
-
* - `useClass` : registers a class constructor, instantiated once on first `get`
|
|
1643
|
+
* Diagnostic methods (`writeError`, `writeWarning`, `writeInfo`, `writeSuccess`)
|
|
1644
|
+
* are NOT captured — they are the equivalent of stderr.
|
|
1332
1645
|
*
|
|
1333
|
-
*
|
|
1334
|
-
*
|
|
1646
|
+
* After a command finishes, the executor can retrieve the captured data to use
|
|
1647
|
+
* as implicit pipeline output when the command did not call `process.output()`.
|
|
1648
|
+
*
|
|
1649
|
+
* `muted` (output going into a pipe or a file) captures stdout-equivalent
|
|
1650
|
+
* output without showing it; diagnostics are still shown.
|
|
1335
1651
|
*/
|
|
1336
|
-
declare class
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
/**
|
|
1356
|
-
* Returns all registered service tokens (single + multi providers).
|
|
1357
|
-
*/
|
|
1358
|
-
getRegisteredTokens(): string[];
|
|
1359
|
-
/**
|
|
1360
|
-
* Returns detailed info for each registered service: token name, value type, and multi flag.
|
|
1361
|
-
*/
|
|
1362
|
-
getRegisteredServiceDetails(): {
|
|
1363
|
-
token: string;
|
|
1364
|
-
type: string;
|
|
1365
|
-
multi: boolean;
|
|
1366
|
-
}[];
|
|
1367
|
-
/**
|
|
1368
|
-
* Describe a resolved value for diagnostic display.
|
|
1369
|
-
*/
|
|
1370
|
-
private describeValue;
|
|
1371
|
-
/**
|
|
1372
|
-
* Register a single provider.
|
|
1373
|
-
*/
|
|
1374
|
-
private registerProvider;
|
|
1375
|
-
/**
|
|
1376
|
-
* Resolve a provider definition to a concrete value.
|
|
1377
|
-
*/
|
|
1378
|
-
private resolveProvider;
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
declare class CliTerminalWriter implements ICliTerminalWriter {
|
|
1382
|
-
readonly terminal: Terminal;
|
|
1383
|
-
constructor(terminal: Terminal);
|
|
1652
|
+
declare class CapturingTerminalWriter implements ICliTerminalWriter {
|
|
1653
|
+
private readonly inner;
|
|
1654
|
+
/** Raw text lines captured from write/writeln calls. */
|
|
1655
|
+
private _lines;
|
|
1656
|
+
/** Structured data captured from writeJson calls. */
|
|
1657
|
+
private _jsonValues;
|
|
1658
|
+
/** Structured data captured from writeObjectsAsTable calls. */
|
|
1659
|
+
private _tableObjects;
|
|
1660
|
+
/** Raw text lines captured from writeError/writeWarning calls. */
|
|
1661
|
+
private _stderrLines;
|
|
1662
|
+
/** Number of writeError calls (warnings excluded). */
|
|
1663
|
+
private _errorCount;
|
|
1664
|
+
private readonly muted;
|
|
1665
|
+
constructor(inner: ICliTerminalWriter, options?: {
|
|
1666
|
+
muted?: boolean;
|
|
1667
|
+
});
|
|
1668
|
+
/** Show stdout-equivalent output unless muted. */
|
|
1669
|
+
private show;
|
|
1670
|
+
private captureText;
|
|
1384
1671
|
write(text: string): void;
|
|
1385
1672
|
writeln(text?: string): void;
|
|
1673
|
+
writeJson(json: any): void;
|
|
1674
|
+
writeObjectsAsTable(objects: any[]): void;
|
|
1675
|
+
writeTable(headers: string[], rows: string[][]): void;
|
|
1386
1676
|
writeSuccess(message: string): void;
|
|
1387
1677
|
writeInfo(message: string): void;
|
|
1388
1678
|
writeWarning(message: string): void;
|
|
1389
1679
|
writeError(message: string): void;
|
|
1390
|
-
|
|
1680
|
+
wrapInColor(text: string, color: CliForegroundColor): string;
|
|
1681
|
+
wrapInBackgroundColor(text: string, color: CliBackgroundColor): string;
|
|
1682
|
+
writeToFile(fileName: string, content: string): void;
|
|
1391
1683
|
writeDivider(options?: {
|
|
1392
1684
|
color?: CliForegroundColor;
|
|
1393
1685
|
length?: number;
|
|
1394
1686
|
char?: string;
|
|
1395
1687
|
}): void;
|
|
1396
|
-
wrapInColor(text: string, color: CliForegroundColor): string;
|
|
1397
|
-
wrapInBackgroundColor(text: string, color: CliBackgroundColor): string;
|
|
1398
|
-
writeJson(json: any): void;
|
|
1399
|
-
writeToFile(fileName: string, content: string): void;
|
|
1400
|
-
writeObjectsAsTable(objects: any[]): void;
|
|
1401
1688
|
writeList(items: string[], options?: {
|
|
1402
1689
|
ordered?: boolean;
|
|
1403
1690
|
prefix?: string;
|
|
@@ -1418,15 +1705,381 @@ declare class CliTerminalWriter implements ICliTerminalWriter {
|
|
|
1418
1705
|
padding?: number;
|
|
1419
1706
|
}): void;
|
|
1420
1707
|
writeIndented(text: string, level?: number): void;
|
|
1421
|
-
|
|
1708
|
+
/**
|
|
1709
|
+
* Returns true if any stdout-equivalent output was captured.
|
|
1710
|
+
*/
|
|
1711
|
+
hasOutput(): boolean;
|
|
1712
|
+
/**
|
|
1713
|
+
* Returns the captured data in the most useful form:
|
|
1714
|
+
*
|
|
1715
|
+
* 1. If structured JSON was written (via `writeJson`), return the last
|
|
1716
|
+
* JSON value (preserving its original type — object, array, etc.).
|
|
1717
|
+
* 2. If objects were written as a table, return the last array of objects.
|
|
1718
|
+
* 3. Otherwise return the captured text lines joined with newlines,
|
|
1719
|
+
* with ANSI codes stripped and whitespace trimmed.
|
|
1720
|
+
* 4. Returns `undefined` if nothing was captured.
|
|
1721
|
+
*/
|
|
1722
|
+
getCapturedData(): any | undefined;
|
|
1723
|
+
/** Whether the command wrote an error message itself. */
|
|
1724
|
+
hasErrors(): boolean;
|
|
1725
|
+
/**
|
|
1726
|
+
* Returns true if any stderr-equivalent output was captured.
|
|
1727
|
+
*/
|
|
1728
|
+
hasStderr(): boolean;
|
|
1729
|
+
/**
|
|
1730
|
+
* Returns captured stderr text joined with newlines, or undefined if empty.
|
|
1731
|
+
*/
|
|
1732
|
+
getCapturedStderr(): string | undefined;
|
|
1422
1733
|
}
|
|
1423
1734
|
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1735
|
+
/**
|
|
1736
|
+
* Write stdout data to a file (overwrite mode).
|
|
1737
|
+
*/
|
|
1738
|
+
declare function writeOutputToFile(filePath: string, context: ICliExecutionContext): Promise<void>;
|
|
1739
|
+
/**
|
|
1740
|
+
* Append stdout data to a file.
|
|
1741
|
+
*/
|
|
1742
|
+
declare function appendOutputToFile(filePath: string, context: ICliExecutionContext): Promise<void>;
|
|
1743
|
+
/**
|
|
1744
|
+
* Write stderr data to a file (overwrite mode).
|
|
1745
|
+
*/
|
|
1746
|
+
declare function writeStderrToFile(filePath: string, context: ICliExecutionContext, capturingWriter?: CapturingTerminalWriter): Promise<void>;
|
|
1747
|
+
/**
|
|
1748
|
+
* Append stderr data to a file.
|
|
1749
|
+
*/
|
|
1750
|
+
declare function appendStderrToFile(filePath: string, context: ICliExecutionContext, capturingWriter?: CapturingTerminalWriter): Promise<void>;
|
|
1751
|
+
|
|
1752
|
+
/**
|
|
1753
|
+
* Attempt to execute a file path as a script.
|
|
1754
|
+
* Returns true if the file was found and executed, false otherwise.
|
|
1755
|
+
* Requires the @qodalis/cli-files plugin for filesystem access.
|
|
1756
|
+
*/
|
|
1757
|
+
declare function tryExecuteScript(filePath: string, context: ICliExecutionHost, executeCommand: (command: string, context: ICliExecutionContext) => Promise<void>): Promise<boolean>;
|
|
1758
|
+
/**
|
|
1759
|
+
* Substitute script-local variables ($VAR / ${VAR}) in a string.
|
|
1760
|
+
*/
|
|
1761
|
+
declare function substituteVars(input: string, variables: Record<string, string>): string;
|
|
1762
|
+
/**
|
|
1763
|
+
* Expand `$VAR` and `${VAR}` references using the global environment store, `$?`
|
|
1764
|
+
* to the last exit status, and a leading `~` (alone or as `~/…`) to `$HOME`.
|
|
1765
|
+
* Nothing is expanded inside single-quoted strings (like bash).
|
|
1766
|
+
*/
|
|
1767
|
+
declare function expandEnvironmentVars(command: string, context: ICliExecutionContext, lastExitCode?: number): string;
|
|
1768
|
+
|
|
1769
|
+
/**
|
|
1770
|
+
* Shell-style script runner shared by `sh <file>` / `source` (files plugin)
|
|
1771
|
+
* and `./script.sh` (the executor).
|
|
1772
|
+
*
|
|
1773
|
+
* Supported (a POSIX sh subset):
|
|
1774
|
+
* - one command per line or several separated by `;` (pipes, `&&`, `||`
|
|
1775
|
+
* and redirects are left to the executor)
|
|
1776
|
+
* - `# comments`, blank lines, `\` line continuation
|
|
1777
|
+
* - `set -e` (default) / `set +e`, `VAR=value` (script-scoped), `exit [n]`
|
|
1778
|
+
* - `if cmd; then ...; elif cmd; then ...; else ...; fi`
|
|
1779
|
+
* - `for NAME in words...; do ...; done` (words after `$VAR` and wildcard
|
|
1780
|
+
* expansion; NAME is set for this terminal)
|
|
1781
|
+
* - `while cmd; do ...; done`, `until cmd; do ...; done`
|
|
1782
|
+
* - `break [n]`, `continue [n]`, `! cmd` (negated status)
|
|
1783
|
+
*
|
|
1784
|
+
* Every simple command runs through the executor; its status is
|
|
1785
|
+
* `context.process.exitCode` (0 or undefined = success).
|
|
1786
|
+
*/
|
|
1787
|
+
/** Service token under which the engine provides the runner (for plugins). */
|
|
1788
|
+
declare const ICliScriptRunner_TOKEN: any;
|
|
1789
|
+
interface ICliScriptRunOptions {
|
|
1790
|
+
/** Prefix for error messages (`sh: line 4: ...`). Default `sh`. */
|
|
1791
|
+
name?: string;
|
|
1792
|
+
/** Runs one command line. Default `context.executor.executeCommand`. */
|
|
1793
|
+
executeCommand?: (command: string, context: ICliExecutionContext) => Promise<void>;
|
|
1794
|
+
/** Loop iterations allowed before a `while`/`until` is stopped. Default 10000. */
|
|
1795
|
+
maxLoopIterations?: number;
|
|
1796
|
+
/** Stop at the first failing command (`set -e`). Default true; false for typed lines. */
|
|
1797
|
+
stopOnError?: boolean;
|
|
1798
|
+
}
|
|
1799
|
+
interface ICliScriptRunner {
|
|
1800
|
+
/** Run script `content`; resolves to its exit status. */
|
|
1801
|
+
run(content: string, context: ICliExecutionContext, options?: ICliScriptRunOptions): Promise<number>;
|
|
1802
|
+
}
|
|
1803
|
+
/** The runner as a service value. */
|
|
1804
|
+
declare const cliScriptRunner: ICliScriptRunner;
|
|
1805
|
+
interface CommandNode {
|
|
1806
|
+
type: 'command';
|
|
1807
|
+
text: string;
|
|
1808
|
+
line: number;
|
|
1809
|
+
negate: boolean;
|
|
1810
|
+
}
|
|
1811
|
+
interface IfNode {
|
|
1812
|
+
type: 'if';
|
|
1813
|
+
line: number;
|
|
1814
|
+
branches: {
|
|
1815
|
+
condition: ScriptNode[];
|
|
1816
|
+
body: ScriptNode[];
|
|
1817
|
+
}[];
|
|
1818
|
+
elseBody?: ScriptNode[];
|
|
1819
|
+
}
|
|
1820
|
+
interface ForNode {
|
|
1821
|
+
type: 'for';
|
|
1822
|
+
line: number;
|
|
1823
|
+
name: string;
|
|
1824
|
+
words: string;
|
|
1825
|
+
body: ScriptNode[];
|
|
1826
|
+
}
|
|
1827
|
+
interface WhileNode {
|
|
1828
|
+
type: 'while';
|
|
1829
|
+
line: number;
|
|
1830
|
+
until: boolean;
|
|
1831
|
+
condition: ScriptNode[];
|
|
1832
|
+
body: ScriptNode[];
|
|
1833
|
+
}
|
|
1834
|
+
type ScriptNode = CommandNode | IfNode | ForNode | WhileNode;
|
|
1835
|
+
/** A syntax error found while parsing. */
|
|
1836
|
+
declare class CliScriptSyntaxError extends Error {
|
|
1837
|
+
readonly line: number;
|
|
1838
|
+
readonly detail: string;
|
|
1839
|
+
constructor(line: number, detail: string);
|
|
1840
|
+
}
|
|
1841
|
+
/** Parse script content (throws {@link CliScriptSyntaxError}). */
|
|
1842
|
+
declare function parseScript(content: string): ScriptNode[];
|
|
1843
|
+
/** Split a line into words, removing quotes (empty quoted words are kept). */
|
|
1844
|
+
declare function splitWords(text: string): string[];
|
|
1845
|
+
/**
|
|
1846
|
+
* Run script content with shell control flow. Resolves to the exit status
|
|
1847
|
+
* (also set as the context's process exit code).
|
|
1848
|
+
*/
|
|
1849
|
+
declare function runScript(content: string, context: ICliExecutionContext, options?: ICliScriptRunOptions): Promise<number>;
|
|
1850
|
+
|
|
1851
|
+
/** The file system calls glob expansion needs (`@qodalis/cli-files`). */
|
|
1852
|
+
interface GlobFileSystem {
|
|
1853
|
+
getCurrentDirectory(): string;
|
|
1854
|
+
resolvePath(path: string): string;
|
|
1855
|
+
listDirectory(path: string): {
|
|
1856
|
+
name: string;
|
|
1857
|
+
type: 'file' | 'directory';
|
|
1858
|
+
}[];
|
|
1859
|
+
exists(path: string): boolean;
|
|
1860
|
+
isDirectory(path: string): boolean;
|
|
1861
|
+
}
|
|
1862
|
+
/**
|
|
1863
|
+
* Expand `*`, `?` and `[...]` in unquoted arguments to the matching paths,
|
|
1864
|
+
* as a shell does: `rm *.txt`, `cat docs/*.md`. The command name and flags
|
|
1865
|
+
* are left alone, names starting with `.` match only a pattern that starts
|
|
1866
|
+
* with `.`, and a pattern that matches nothing is kept as typed.
|
|
1867
|
+
* Without the files plugin the command is returned unchanged.
|
|
1868
|
+
*/
|
|
1869
|
+
declare function expandGlobs(command: string, context: ICliExecutionContext): string;
|
|
1870
|
+
/** Paths matching `pattern`, sorted, relative when the pattern is. */
|
|
1871
|
+
declare function matchGlob(fs: GlobFileSystem, pattern: string): string[];
|
|
1872
|
+
/**
|
|
1873
|
+
* Brace expansion, as a shell does before wildcards: `file.{ts,js}` is
|
|
1874
|
+
* `file.ts file.js`, `img{1..3}.png` is `img1.png img2.png img3.png`
|
|
1875
|
+
* (letters too: `{a..c}`). Only unquoted words with a `,` or `..` inside
|
|
1876
|
+
* balanced braces; `${VAR}` and quoted text are left alone. Works without
|
|
1877
|
+
* the files plugin.
|
|
1878
|
+
*/
|
|
1879
|
+
declare function expandBraces(command: string): string;
|
|
1880
|
+
|
|
1881
|
+
/**
|
|
1882
|
+
* Replace `$(command)` and `` `command` `` with the command's output, as a
|
|
1883
|
+
* shell does: `echo "Today: $(date)"`. Not inside single quotes; inside
|
|
1884
|
+
* double quotes yes. Trailing newlines of the output are removed, and the
|
|
1885
|
+
* output is escaped so it is only ever text: inside double quotes `"`, `\`,
|
|
1886
|
+
* `$` and `` ` ``; outside quotes every shell character but spaces (which
|
|
1887
|
+
* still separate words), so quotes, operators, `$`, wildcards and braces in
|
|
1888
|
+
* the output are not interpreted.
|
|
1889
|
+
*/
|
|
1890
|
+
declare function substituteCommands(command: string, run: (inner: string) => Promise<string>): Promise<string>;
|
|
1891
|
+
|
|
1892
|
+
/**
|
|
1893
|
+
* A simple Map-based service container implementing ICliServiceProvider.
|
|
1894
|
+
*
|
|
1895
|
+
* Supports three provider types:
|
|
1896
|
+
* - `useValue` : registers a static value
|
|
1897
|
+
* - `useFactory` : registers a factory function, invoked once on the first `get`
|
|
1898
|
+
* - `useClass` : registers a class constructor, instantiated once on the first `get`
|
|
1899
|
+
*
|
|
1900
|
+
* Factories and classes are created lazily, so their `deps` only have to be
|
|
1901
|
+
* registered by the time the service is first used. Add `transient: true` to
|
|
1902
|
+
* create a new instance on every `get`.
|
|
1903
|
+
*
|
|
1904
|
+
* When `multi: true`, multiple providers for the same token are accumulated
|
|
1905
|
+
* and `getAll()` returns all of them.
|
|
1906
|
+
*
|
|
1907
|
+
* Registering a single token again overrides it; removing that registration
|
|
1908
|
+
* (`remove(token, provider)`, e.g. when a module is unloaded) makes the
|
|
1909
|
+
* previous one active again.
|
|
1910
|
+
*/
|
|
1911
|
+
declare class CliServiceContainer implements ICliServiceProvider {
|
|
1912
|
+
/** Single-value registrations; the last one is active. */
|
|
1913
|
+
private readonly services;
|
|
1914
|
+
/** Multi-provider registrations, in registration order. */
|
|
1915
|
+
private readonly multiServices;
|
|
1916
|
+
/** Tokens that cannot be overwritten by subsequent `set()` calls. */
|
|
1917
|
+
private readonly sealedTokens;
|
|
1918
|
+
/** Stores provider recipes for transient tokens (re-resolved on every get). */
|
|
1919
|
+
private readonly transientRecipes;
|
|
1920
|
+
private disposed;
|
|
1921
|
+
/** Registrations being created, to report dependency cycles. */
|
|
1922
|
+
private readonly resolving;
|
|
1923
|
+
/**
|
|
1924
|
+
* Retrieve a service by its token.
|
|
1925
|
+
* Returns `undefined` when no provider is registered for the token.
|
|
1926
|
+
* For multi-provider tokens, returns the last registered value (use `getAll` for the full array).
|
|
1927
|
+
*
|
|
1928
|
+
* @param token The token used to register the service.
|
|
1929
|
+
* @returns The resolved service instance, or `undefined` if not registered.
|
|
1930
|
+
*/
|
|
1931
|
+
get<T>(token: CliToken<T>): T | undefined;
|
|
1932
|
+
get<T>(token: any): T | undefined;
|
|
1933
|
+
/**
|
|
1934
|
+
* Retrieve all registered services for a multi-provider token.
|
|
1935
|
+
* Returns an empty array when no provider is registered for the token.
|
|
1936
|
+
*
|
|
1937
|
+
* @param token The token used to register the service.
|
|
1938
|
+
* @returns Array of all resolved service instances.
|
|
1939
|
+
*/
|
|
1940
|
+
getAll<T>(token: CliToken<T>): T[];
|
|
1941
|
+
getAll<T>(token: any): T[];
|
|
1942
|
+
/**
|
|
1943
|
+
* Retrieve a service by its token, throwing if not registered.
|
|
1944
|
+
* Use this when the service is required and its absence is a programming error.
|
|
1945
|
+
* For multi-provider tokens, returns the last registered value (use `getAll` for the full array).
|
|
1946
|
+
*
|
|
1947
|
+
* @param token The token used to register the service.
|
|
1948
|
+
* @returns The resolved service instance.
|
|
1949
|
+
* @throws Error if the token has not been registered.
|
|
1950
|
+
*/
|
|
1951
|
+
getRequired<T>(token: CliToken<T>): T;
|
|
1952
|
+
getRequired<T>(token: any): T;
|
|
1953
|
+
/**
|
|
1954
|
+
* Check whether a service is registered for the given token.
|
|
1955
|
+
*/
|
|
1956
|
+
has(token: any): boolean;
|
|
1957
|
+
/**
|
|
1958
|
+
* Mark a token as sealed so it cannot be overwritten by future `set()` calls.
|
|
1959
|
+
* Only available on the concrete container — not exposed on `ICliServiceProvider`.
|
|
1960
|
+
*/
|
|
1961
|
+
seal(token: any): void;
|
|
1962
|
+
/**
|
|
1963
|
+
* Mark multiple tokens as sealed at once.
|
|
1964
|
+
*/
|
|
1965
|
+
sealAll(tokens: any[]): void;
|
|
1966
|
+
/**
|
|
1967
|
+
* Check whether a token is sealed.
|
|
1968
|
+
*/
|
|
1969
|
+
isSealed(token: any): boolean;
|
|
1970
|
+
/**
|
|
1971
|
+
* Register one or more providers.
|
|
1972
|
+
*
|
|
1973
|
+
* @param definition A single CliProvider or an array of CliProviders.
|
|
1974
|
+
*/
|
|
1975
|
+
set(definition: CliProvider | CliProvider[]): void;
|
|
1976
|
+
/**
|
|
1977
|
+
* Remove a registration. With `provider` (the provider object passed to
|
|
1978
|
+
* `set`, or the registered value), only that registration is removed: for
|
|
1979
|
+
* a single token the previous registration becomes active again, for a
|
|
1980
|
+
* multi token the others remain. Without it, every registration of the
|
|
1981
|
+
* token is removed.
|
|
1982
|
+
*
|
|
1983
|
+
* @throws Error if the token is sealed.
|
|
1984
|
+
* @returns Whether something was removed.
|
|
1985
|
+
*/
|
|
1986
|
+
remove(token: any, provider?: unknown): boolean;
|
|
1987
|
+
/**
|
|
1988
|
+
* Dispose the services the container created (`useFactory` / `useClass`)
|
|
1989
|
+
* that have a `dispose()` method. Values registered with `useValue`
|
|
1990
|
+
* belong to whoever registered them and are not disposed. Registrations
|
|
1991
|
+
* are kept, so late callbacks still find their services. Called when the
|
|
1992
|
+
* engine is destroyed; later calls do nothing.
|
|
1993
|
+
*/
|
|
1994
|
+
dispose(): void;
|
|
1995
|
+
/**
|
|
1996
|
+
* Returns all registered service tokens (single + multi providers).
|
|
1997
|
+
*/
|
|
1998
|
+
getRegisteredTokens(): string[];
|
|
1999
|
+
/**
|
|
2000
|
+
* Returns detailed info for each registered service: token name, value type, and multi flag.
|
|
2001
|
+
* Services not created yet are listed as `lazy(Name)` (listing does not create them).
|
|
2002
|
+
*/
|
|
2003
|
+
getRegisteredServiceDetails(): {
|
|
2004
|
+
token: string;
|
|
2005
|
+
type: string;
|
|
2006
|
+
multi: boolean;
|
|
2007
|
+
}[];
|
|
2008
|
+
/**
|
|
2009
|
+
* Convert a token to a human-readable string for diagnostics/errors.
|
|
2010
|
+
*/
|
|
2011
|
+
private tokenToString;
|
|
2012
|
+
private describeRegistration;
|
|
2013
|
+
/**
|
|
2014
|
+
* Describe a resolved value for diagnostic display.
|
|
2015
|
+
*/
|
|
2016
|
+
private describeValue;
|
|
2017
|
+
/** Whether `registration` is the one `provider` refers to. */
|
|
2018
|
+
private matches;
|
|
2019
|
+
/**
|
|
2020
|
+
* Register a single provider.
|
|
2021
|
+
*/
|
|
2022
|
+
private registerProvider;
|
|
2023
|
+
/** The value of a registration, created on first use. */
|
|
2024
|
+
private resolve;
|
|
2025
|
+
/**
|
|
2026
|
+
* Resolve a provider definition to a concrete value, resolving its `deps`
|
|
2027
|
+
* from the container.
|
|
2028
|
+
*/
|
|
2029
|
+
private resolveProvider;
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
declare class CliTerminalWriter implements ICliTerminalWriter {
|
|
2033
|
+
readonly terminal: Terminal;
|
|
2034
|
+
constructor(terminal: Terminal);
|
|
2035
|
+
write(text: string): void;
|
|
2036
|
+
writeln(text?: string): void;
|
|
2037
|
+
writeSuccess(message: string): void;
|
|
2038
|
+
writeInfo(message: string): void;
|
|
2039
|
+
writeWarning(message: string): void;
|
|
2040
|
+
writeError(message: string): void;
|
|
2041
|
+
private writeLog;
|
|
2042
|
+
writeDivider(options?: {
|
|
2043
|
+
color?: CliForegroundColor;
|
|
2044
|
+
length?: number;
|
|
2045
|
+
char?: string;
|
|
2046
|
+
}): void;
|
|
2047
|
+
wrapInColor(text: string, color: CliForegroundColor): string;
|
|
2048
|
+
wrapInBackgroundColor(text: string, color: CliBackgroundColor): string;
|
|
2049
|
+
writeJson(json: any): void;
|
|
2050
|
+
writeToFile(fileName: string, content: string): void;
|
|
2051
|
+
writeObjectsAsTable(objects: any[]): void;
|
|
2052
|
+
writeList(items: string[], options?: {
|
|
2053
|
+
ordered?: boolean;
|
|
2054
|
+
prefix?: string;
|
|
2055
|
+
color?: CliForegroundColor;
|
|
2056
|
+
}): void;
|
|
2057
|
+
writeKeyValue(entries: Record<string, string> | [string, string][], options?: {
|
|
2058
|
+
separator?: string;
|
|
2059
|
+
keyColor?: CliForegroundColor;
|
|
2060
|
+
}): void;
|
|
2061
|
+
writeColumns(items: string[], options?: {
|
|
2062
|
+
columns?: number;
|
|
2063
|
+
padding?: number;
|
|
2064
|
+
}): void;
|
|
2065
|
+
writeLink(text: string, url: string): void;
|
|
2066
|
+
writeBox(content: string | string[], options?: {
|
|
2067
|
+
title?: string;
|
|
2068
|
+
borderColor?: CliForegroundColor;
|
|
2069
|
+
padding?: number;
|
|
2070
|
+
}): void;
|
|
2071
|
+
writeIndented(text: string, level?: number): void;
|
|
2072
|
+
/** One block per row, header names as keys; used when a table cannot fit the terminal. */
|
|
2073
|
+
private writeRecords;
|
|
2074
|
+
writeTable(headers: string[], rows: string[][], options?: CliTableOptions): void;
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
declare class CliClipboard implements ICliClipboard {
|
|
2078
|
+
private readonly context;
|
|
2079
|
+
constructor(context: ICliExecutionContext);
|
|
2080
|
+
write(text: string): Promise<void>;
|
|
2081
|
+
read(): Promise<string>;
|
|
2082
|
+
}
|
|
1430
2083
|
|
|
1431
2084
|
declare class CliLogger implements ICliLogger {
|
|
1432
2085
|
private CliLogLevel;
|
|
@@ -1490,11 +2143,22 @@ declare class CliTerminalTextAnimator implements ICliTextAnimator {
|
|
|
1490
2143
|
isRunning: boolean;
|
|
1491
2144
|
context?: ICliExecutionContext;
|
|
1492
2145
|
private animationInterval?;
|
|
2146
|
+
/** Characters of the current animation still visible on the line. */
|
|
2147
|
+
private visibleChars;
|
|
2148
|
+
/** Ends the current `showText` promise early (set while it runs). */
|
|
2149
|
+
private finish?;
|
|
1493
2150
|
private text;
|
|
1494
2151
|
private textColor;
|
|
1495
2152
|
constructor(terminal: Terminal);
|
|
1496
2153
|
show(text?: string): void;
|
|
1497
2154
|
showText(text: string, options?: CliTextAnimatorOptions): Promise<void>;
|
|
2155
|
+
/** Cursor position as `row:col`, or `null` when unavailable. */
|
|
2156
|
+
private cursorPosition;
|
|
2157
|
+
/**
|
|
2158
|
+
* Stop the animation, erase the text it wrote and resolve its `showText`
|
|
2159
|
+
* promise. Used when the user starts typing over the greeting.
|
|
2160
|
+
*/
|
|
2161
|
+
cancel(): void;
|
|
1498
2162
|
/**
|
|
1499
2163
|
* Hide the animation and reset the state.
|
|
1500
2164
|
*/
|
|
@@ -1511,6 +2175,101 @@ interface ICliWelcomeModule extends ICliModule {
|
|
|
1511
2175
|
configure(config: CliWelcomeMessageConfig): ICliModule;
|
|
1512
2176
|
}
|
|
1513
2177
|
declare const welcomeModule: ICliWelcomeModule;
|
|
2178
|
+
/**
|
|
2179
|
+
* Animated, time-based greeting on the first prompt. Runs after every other
|
|
2180
|
+
* module's `onAfterBoot` hook (setup and sign-in prompts come first), and
|
|
2181
|
+
* only when the welcome banner was shown.
|
|
2182
|
+
*/
|
|
2183
|
+
declare const greetingModule: ICliModule;
|
|
2184
|
+
|
|
2185
|
+
interface CliBootLogOptions {
|
|
2186
|
+
/** Steps taking at least this long are highlighted as slow. */
|
|
2187
|
+
slowStepMs?: number;
|
|
2188
|
+
/** When boot started (ms since epoch); defaults to now. */
|
|
2189
|
+
startedAt?: number;
|
|
2190
|
+
}
|
|
2191
|
+
/**
|
|
2192
|
+
* Live boot report written to the terminal while the CLI starts: a list of
|
|
2193
|
+
* the steps (terminal, services, servers, modules) with a thin progress bar
|
|
2194
|
+
* and percentage pinned below it.
|
|
2195
|
+
*
|
|
2196
|
+
* Anything else written to the terminal meanwhile is captured and the bar
|
|
2197
|
+
* steps aside for it. When boot is complete the report is cleared so the
|
|
2198
|
+
* regular terminal takes over; warnings, errors and other output (plugin
|
|
2199
|
+
* warnings) are written again in order. First-run setup prompts, answered
|
|
2200
|
+
* while the report is suspended, are cleared with it.
|
|
2201
|
+
*
|
|
2202
|
+
* A disabled log records problems but writes nothing.
|
|
2203
|
+
*/
|
|
2204
|
+
declare class CliBootLog {
|
|
2205
|
+
private readonly terminal;
|
|
2206
|
+
readonly enabled: boolean;
|
|
2207
|
+
private readonly startedAt;
|
|
2208
|
+
private readonly slowStepMs;
|
|
2209
|
+
private readonly problems;
|
|
2210
|
+
private finished;
|
|
2211
|
+
private totalSteps;
|
|
2212
|
+
private completedSteps;
|
|
2213
|
+
private current;
|
|
2214
|
+
private barVisible;
|
|
2215
|
+
private cursorHidden;
|
|
2216
|
+
private suspended;
|
|
2217
|
+
private startRow;
|
|
2218
|
+
/** Output written by others during boot, replayed after the report is cleared. */
|
|
2219
|
+
private readonly captured;
|
|
2220
|
+
private originalWrite?;
|
|
2221
|
+
private originalWriteln?;
|
|
2222
|
+
private redrawScheduled;
|
|
2223
|
+
/** The last setup output did not end its line (cursor after a prompt). */
|
|
2224
|
+
private promptOpen;
|
|
2225
|
+
constructor(terminal: Terminal | undefined, enabled: boolean, options?: CliBootLogOptions);
|
|
2226
|
+
/** Milliseconds since boot started. */
|
|
2227
|
+
get elapsedMs(): number;
|
|
2228
|
+
/** Whether `finish()` was called; later entries are ignored. */
|
|
2229
|
+
get isFinished(): boolean;
|
|
2230
|
+
/** Completed share of the planned steps, 0–100. */
|
|
2231
|
+
get percent(): number;
|
|
2232
|
+
/** Announce `count` more steps that will each be completed with `completeStep`. */
|
|
2233
|
+
addSteps(count: number): void;
|
|
2234
|
+
/** Name what is being set up now (shown next to the bar). */
|
|
2235
|
+
setCurrent(text: string): void;
|
|
2236
|
+
/** Mark one planned step as done (successfully or not). */
|
|
2237
|
+
completeStep(): void;
|
|
2238
|
+
/**
|
|
2239
|
+
* Step aside for interactive output (e.g. a module's first-run setup
|
|
2240
|
+
* prompt): remove the bar and show the cursor until `resume()`.
|
|
2241
|
+
*/
|
|
2242
|
+
suspend(): void;
|
|
2243
|
+
/** Bring the bar back after `suspend()`. */
|
|
2244
|
+
resume(): void;
|
|
2245
|
+
info(text: string): void;
|
|
2246
|
+
/** A completed step, optionally with how long it took. */
|
|
2247
|
+
ok(text: string, durationMs?: number): void;
|
|
2248
|
+
warn(text: string): void;
|
|
2249
|
+
error(text: string): void;
|
|
2250
|
+
/**
|
|
2251
|
+
* Write the summary line, then hand the screen over to the terminal:
|
|
2252
|
+
* clear the report (unless `keep`), then write warnings, errors and the
|
|
2253
|
+
* output captured during boot again. The report is not cleared when the
|
|
2254
|
+
* terminal already held something before boot started.
|
|
2255
|
+
*/
|
|
2256
|
+
finish(summary: string, keep?: boolean): Promise<void>;
|
|
2257
|
+
private write;
|
|
2258
|
+
/** Redraw the bar on the line below the list (the cursor stays on it). */
|
|
2259
|
+
private drawBar;
|
|
2260
|
+
/** First output: remember where the report starts and capture other writes. */
|
|
2261
|
+
private begin;
|
|
2262
|
+
private stopCapture;
|
|
2263
|
+
/** Someone else writes during boot: move the bar aside and keep a copy. */
|
|
2264
|
+
private onExternalWrite;
|
|
2265
|
+
/** Write without being captured. */
|
|
2266
|
+
private out;
|
|
2267
|
+
private hideBar;
|
|
2268
|
+
private format;
|
|
2269
|
+
private absoluteRow;
|
|
2270
|
+
/** Resolve once xterm has parsed everything written so far. */
|
|
2271
|
+
private flush;
|
|
2272
|
+
}
|
|
1514
2273
|
|
|
1515
2274
|
declare class CliBoot {
|
|
1516
2275
|
private readonly registry;
|
|
@@ -1520,13 +2279,60 @@ declare class CliBoot {
|
|
|
1520
2279
|
private readonly moduleRegistry;
|
|
1521
2280
|
private readonly bootedModules;
|
|
1522
2281
|
private readonly initializedProcessors;
|
|
2282
|
+
/** Services and guards each module registered, removed when it is unloaded. */
|
|
2283
|
+
private readonly moduleProviders;
|
|
2284
|
+
/** Context modules were booted with (passed to `onDestroy` on unload). */
|
|
2285
|
+
private context?;
|
|
2286
|
+
/** Boot report of the startup boot. */
|
|
2287
|
+
private bootLogRef?;
|
|
2288
|
+
/** The boot report while startup is still in progress, else `undefined`. */
|
|
2289
|
+
private get bootLog();
|
|
1523
2290
|
constructor(registry: ICliCommandProcessorRegistry, services: ICliServiceProvider);
|
|
1524
2291
|
/**
|
|
1525
2292
|
* Get the module registry for external access.
|
|
1526
2293
|
*/
|
|
1527
2294
|
getModuleRegistry(): CliModuleRegistry;
|
|
1528
|
-
boot(context: CliExecutionContext, modules: ICliModule[]): Promise<void>;
|
|
2295
|
+
boot(context: CliExecutionContext, modules: ICliModule[], bootLog?: CliBootLog): Promise<void>;
|
|
2296
|
+
private bootAll;
|
|
2297
|
+
/**
|
|
2298
|
+
* Boot one module: declarations (services, guards, permissions,
|
|
2299
|
+
* translations), lifecycle (`onInit`, first-run `onSetup`), then its
|
|
2300
|
+
* commands. Modules already booted or with missing dependencies are skipped.
|
|
2301
|
+
*/
|
|
1529
2302
|
private bootModule;
|
|
2303
|
+
private dependenciesLoaded;
|
|
2304
|
+
/** Services, guards, permissions and translations the module declares. */
|
|
2305
|
+
private registerDeclarations;
|
|
2306
|
+
/** `onInit` runs before the module's commands are registered. */
|
|
2307
|
+
private runOnInit;
|
|
2308
|
+
/** `onSetup` runs once per browser (first-run flow), until it succeeds. */
|
|
2309
|
+
private runFirstSetup;
|
|
2310
|
+
/** Register and initialize the module's commands; returns how many. */
|
|
2311
|
+
private registerCommands;
|
|
2312
|
+
/** One boot-log line per module that does something at boot. */
|
|
2313
|
+
private reportModule;
|
|
2314
|
+
/**
|
|
2315
|
+
* Unload a module (`pkg remove`, or before `pkg update` boots the new
|
|
2316
|
+
* version): its commands, guards and permissions are removed at once,
|
|
2317
|
+
* then `onDestroy` runs, then its services are removed (so `onDestroy`
|
|
2318
|
+
* can still use them). Services are removed by registration, so a newer
|
|
2319
|
+
* version registered meanwhile keeps its own.
|
|
2320
|
+
*/
|
|
2321
|
+
private unloadModule;
|
|
2322
|
+
private removeProviders;
|
|
2323
|
+
/** Publish on the event bus; never lets the bus break booting. */
|
|
2324
|
+
private emitEvent;
|
|
2325
|
+
/** Boot warning: into the boot log when it is shown, else the terminal. */
|
|
2326
|
+
private warn;
|
|
2327
|
+
/** Boot error: into the boot log when it is shown, else the terminal. */
|
|
2328
|
+
private fail;
|
|
2329
|
+
/**
|
|
2330
|
+
* Sub-processors of an `extendsProcessor` processor are merged into the
|
|
2331
|
+
* processor it extends, so they belong to that one: re-parent them so they
|
|
2332
|
+
* inherit its access rules (`requiredPermissions` etc.) and help/root
|
|
2333
|
+
* lookups resolve to the registered processor.
|
|
2334
|
+
*/
|
|
2335
|
+
private adoptMergedSubProcessors;
|
|
1530
2336
|
private buildCoreModule;
|
|
1531
2337
|
/**
|
|
1532
2338
|
* Topologically sort modules by their dependencies using DFS.
|
|
@@ -1686,91 +2492,7 @@ declare class CliInputReader implements ICliInputReader {
|
|
|
1686
2492
|
readFile(prompt: string, options?: CliFilePickerOptions): Promise<CliFileResult[] | null>;
|
|
1687
2493
|
}
|
|
1688
2494
|
|
|
1689
|
-
|
|
1690
|
-
* A terminal writer wrapper that captures "stdout-equivalent" output
|
|
1691
|
-
* (`write`, `writeln`, `writeJson`, `writeObjectsAsTable`, `writeTable`)
|
|
1692
|
-
* while passing everything through to the underlying writer unchanged.
|
|
1693
|
-
*
|
|
1694
|
-
* Diagnostic methods (`writeError`, `writeWarning`, `writeInfo`, `writeSuccess`)
|
|
1695
|
-
* are NOT captured — they are the equivalent of stderr.
|
|
1696
|
-
*
|
|
1697
|
-
* After a command finishes, the executor can retrieve the captured data to use
|
|
1698
|
-
* as implicit pipeline output when the command did not call `process.output()`.
|
|
1699
|
-
*/
|
|
1700
|
-
declare class CapturingTerminalWriter implements ICliTerminalWriter {
|
|
1701
|
-
private readonly inner;
|
|
1702
|
-
/** Raw text lines captured from write/writeln calls. */
|
|
1703
|
-
private _lines;
|
|
1704
|
-
/** Structured data captured from writeJson calls. */
|
|
1705
|
-
private _jsonValues;
|
|
1706
|
-
/** Structured data captured from writeObjectsAsTable calls. */
|
|
1707
|
-
private _tableObjects;
|
|
1708
|
-
/** Raw text lines captured from writeError/writeWarning calls. */
|
|
1709
|
-
private _stderrLines;
|
|
1710
|
-
constructor(inner: ICliTerminalWriter);
|
|
1711
|
-
write(text: string): void;
|
|
1712
|
-
writeln(text?: string): void;
|
|
1713
|
-
writeJson(json: any): void;
|
|
1714
|
-
writeObjectsAsTable(objects: any[]): void;
|
|
1715
|
-
writeTable(headers: string[], rows: string[][]): void;
|
|
1716
|
-
writeSuccess(message: string): void;
|
|
1717
|
-
writeInfo(message: string): void;
|
|
1718
|
-
writeWarning(message: string): void;
|
|
1719
|
-
writeError(message: string): void;
|
|
1720
|
-
wrapInColor(text: string, color: CliForegroundColor): string;
|
|
1721
|
-
wrapInBackgroundColor(text: string, color: CliBackgroundColor): string;
|
|
1722
|
-
writeToFile(fileName: string, content: string): void;
|
|
1723
|
-
writeDivider(options?: {
|
|
1724
|
-
color?: CliForegroundColor;
|
|
1725
|
-
length?: number;
|
|
1726
|
-
char?: string;
|
|
1727
|
-
}): void;
|
|
1728
|
-
writeList(items: string[], options?: {
|
|
1729
|
-
ordered?: boolean;
|
|
1730
|
-
prefix?: string;
|
|
1731
|
-
color?: CliForegroundColor;
|
|
1732
|
-
}): void;
|
|
1733
|
-
writeKeyValue(entries: Record<string, string> | [string, string][], options?: {
|
|
1734
|
-
separator?: string;
|
|
1735
|
-
keyColor?: CliForegroundColor;
|
|
1736
|
-
}): void;
|
|
1737
|
-
writeColumns(items: string[], options?: {
|
|
1738
|
-
columns?: number;
|
|
1739
|
-
padding?: number;
|
|
1740
|
-
}): void;
|
|
1741
|
-
writeLink(text: string, url: string): void;
|
|
1742
|
-
writeBox(content: string | string[], options?: {
|
|
1743
|
-
title?: string;
|
|
1744
|
-
borderColor?: CliForegroundColor;
|
|
1745
|
-
padding?: number;
|
|
1746
|
-
}): void;
|
|
1747
|
-
writeIndented(text: string, level?: number): void;
|
|
1748
|
-
/**
|
|
1749
|
-
* Returns true if any stdout-equivalent output was captured.
|
|
1750
|
-
*/
|
|
1751
|
-
hasOutput(): boolean;
|
|
1752
|
-
/**
|
|
1753
|
-
* Returns the captured data in the most useful form:
|
|
1754
|
-
*
|
|
1755
|
-
* 1. If structured JSON was written (via `writeJson`), return the last
|
|
1756
|
-
* JSON value (preserving its original type — object, array, etc.).
|
|
1757
|
-
* 2. If objects were written as a table, return the last array of objects.
|
|
1758
|
-
* 3. Otherwise return the captured text lines joined with newlines,
|
|
1759
|
-
* with ANSI codes stripped and whitespace trimmed.
|
|
1760
|
-
* 4. Returns `undefined` if nothing was captured.
|
|
1761
|
-
*/
|
|
1762
|
-
getCapturedData(): any | undefined;
|
|
1763
|
-
/**
|
|
1764
|
-
* Returns true if any stderr-equivalent output was captured.
|
|
1765
|
-
*/
|
|
1766
|
-
hasStderr(): boolean;
|
|
1767
|
-
/**
|
|
1768
|
-
* Returns captured stderr text joined with newlines, or undefined if empty.
|
|
1769
|
-
*/
|
|
1770
|
-
getCapturedStderr(): string | undefined;
|
|
1771
|
-
}
|
|
1772
|
-
|
|
1773
|
-
declare const CliProcessRegistry_TOKEN = "cli-process-registry";
|
|
2495
|
+
declare const CliProcessRegistry_TOKEN: any;
|
|
1774
2496
|
declare class CliProcessRegistry implements ICliProcessRegistry {
|
|
1775
2497
|
private nextPid;
|
|
1776
2498
|
private processes;
|
|
@@ -1789,7 +2511,7 @@ declare class CliProcessRegistry implements ICliProcessRegistry {
|
|
|
1789
2511
|
}
|
|
1790
2512
|
|
|
1791
2513
|
/**
|
|
1792
|
-
*
|
|
2514
|
+
* Environment variables for the CLI.
|
|
1793
2515
|
*
|
|
1794
2516
|
* Variables set here are available to all commands via `$VAR` / `${VAR}`
|
|
1795
2517
|
* substitution in the executor. Commands can also read/write the store
|
|
@@ -1798,29 +2520,106 @@ declare class CliProcessRegistry implements ICliProcessRegistry {
|
|
|
1798
2520
|
interface ICliEnvironment {
|
|
1799
2521
|
/** Get a variable value (undefined if not set). */
|
|
1800
2522
|
get(name: string): string | undefined;
|
|
1801
|
-
/**
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
2523
|
+
/**
|
|
2524
|
+
* Set a variable: for the signed-in user (`'user'`, the default, saved),
|
|
2525
|
+
* for everyone (`'global'`, saved) or for this terminal only (`'session'`).
|
|
2526
|
+
*/
|
|
2527
|
+
set(name: string, value: string, scope?: CliEnvironmentScope): void;
|
|
2528
|
+
/**
|
|
2529
|
+
* Remove a variable. Without a scope it is removed for this terminal and
|
|
2530
|
+
* the user (and hidden when it still comes from a shared or built-in
|
|
2531
|
+
* value); `'global'` removes the shared value.
|
|
2532
|
+
*/
|
|
2533
|
+
unset(name: string, scope?: CliEnvironmentScope): void;
|
|
1805
2534
|
/** Get all variables as a record. */
|
|
1806
2535
|
getAll(): Record<string, string>;
|
|
1807
2536
|
/** Check if a variable is set. */
|
|
1808
2537
|
has(name: string): boolean;
|
|
1809
|
-
|
|
1810
|
-
|
|
2538
|
+
/** Where the current value of `name` comes from. */
|
|
2539
|
+
scopeOf?(name: string): CliEnvironmentSource | undefined;
|
|
2540
|
+
}
|
|
2541
|
+
declare const ICliEnvironment_TOKEN: any;
|
|
2542
|
+
/** Where a variable is set: this terminal, the signed-in user, or everyone. */
|
|
2543
|
+
type CliEnvironmentScope = 'session' | 'user' | 'global';
|
|
2544
|
+
/** Where a value comes from: a scope, or computed / built in (`HOME`, `SHELL`, …). */
|
|
2545
|
+
type CliEnvironmentSource = CliEnvironmentScope | 'builtin';
|
|
2546
|
+
/** What one user (or the signed-out session, key '') changed: values set and defaults removed. */
|
|
2547
|
+
interface CliEnvironmentProfile {
|
|
2548
|
+
vars: Record<string, string>;
|
|
2549
|
+
unset: string[];
|
|
2550
|
+
}
|
|
2551
|
+
/** Saved environment: one profile per user name ('' when nobody is signed in). */
|
|
2552
|
+
type CliEnvironmentSnapshot = Record<string, CliEnvironmentProfile>;
|
|
2553
|
+
/**
|
|
2554
|
+
* One saved change, applied by the host to the latest saved state (so two
|
|
2555
|
+
* tabs changing different variables never overwrite each other).
|
|
2556
|
+
*/
|
|
2557
|
+
type CliEnvironmentChange = {
|
|
2558
|
+
scope: 'user';
|
|
2559
|
+
profile: string;
|
|
2560
|
+
name: string;
|
|
2561
|
+
value: string;
|
|
2562
|
+
} | {
|
|
2563
|
+
scope: 'user';
|
|
2564
|
+
profile: string;
|
|
2565
|
+
name: string;
|
|
2566
|
+
unset: true;
|
|
2567
|
+
hide: boolean;
|
|
2568
|
+
} | {
|
|
2569
|
+
scope: 'global';
|
|
2570
|
+
name: string;
|
|
2571
|
+
value: string;
|
|
2572
|
+
} | {
|
|
2573
|
+
scope: 'global';
|
|
2574
|
+
name: string;
|
|
2575
|
+
unset: true;
|
|
2576
|
+
};
|
|
1811
2577
|
/**
|
|
1812
2578
|
* Default in-memory implementation.
|
|
1813
|
-
*
|
|
2579
|
+
*
|
|
2580
|
+
* A variable resolves, in order, from this terminal's variables
|
|
2581
|
+
* (`NAME=value`), the current user's own (`export`), the shared ones
|
|
2582
|
+
* (`export --global`), then bound live values (USER, HOME, PWD follow the
|
|
2583
|
+
* session and directory), then the standard variables seeded on
|
|
2584
|
+
* construction. Each user has a separate set, so `su`/`login` switch
|
|
2585
|
+
* environments, and `onChange` lets the host save each change.
|
|
1814
2586
|
*/
|
|
1815
2587
|
declare class CliEnvironment implements ICliEnvironment {
|
|
1816
|
-
private readonly
|
|
2588
|
+
private readonly defaults;
|
|
2589
|
+
/** Variables computed on read; a user's own value wins over them. */
|
|
2590
|
+
private readonly bound;
|
|
2591
|
+
private readonly profiles;
|
|
2592
|
+
private readonly global;
|
|
2593
|
+
private readonly session;
|
|
2594
|
+
private profileKey;
|
|
2595
|
+
/** Called after every saved change (user or global), to persist it. */
|
|
2596
|
+
onChange?: (change: CliEnvironmentChange) => void;
|
|
1817
2597
|
constructor();
|
|
2598
|
+
/** Compute a variable on every read; the seeded value is the fallback while it returns nothing. */
|
|
2599
|
+
bind(name: string, resolver: () => string | null | undefined): void;
|
|
2600
|
+
/** Pick whose changes apply (the signed-in user's name, '' when signed out). */
|
|
2601
|
+
setProfileResolver(resolver: () => string | null | undefined): void;
|
|
2602
|
+
/** Restore saved profiles and shared variables (replaces the saved ones in memory). */
|
|
2603
|
+
load(snapshot: CliEnvironmentSnapshot | undefined, global?: Record<string, string>): void;
|
|
2604
|
+
snapshot(): CliEnvironmentSnapshot;
|
|
2605
|
+
/** The shared variables. */
|
|
2606
|
+
globals(): Record<string, string>;
|
|
1818
2607
|
get(name: string): string | undefined;
|
|
1819
|
-
|
|
1820
|
-
|
|
2608
|
+
scopeOf(name: string): CliEnvironmentSource | undefined;
|
|
2609
|
+
set(name: string, value: string, scope?: CliEnvironmentScope): void;
|
|
2610
|
+
unset(name: string, scope?: CliEnvironmentScope): void;
|
|
1821
2611
|
getAll(): Record<string, string>;
|
|
1822
2612
|
has(name: string): boolean;
|
|
1823
|
-
|
|
2613
|
+
private profileOf;
|
|
2614
|
+
}
|
|
2615
|
+
/** Apply one change to saved state (the host does this under the cross-tab lock). */
|
|
2616
|
+
declare function applyEnvironmentChange(state: {
|
|
2617
|
+
profiles?: CliEnvironmentSnapshot;
|
|
2618
|
+
global?: Record<string, string>;
|
|
2619
|
+
}, change: CliEnvironmentChange): {
|
|
2620
|
+
profiles: CliEnvironmentSnapshot;
|
|
2621
|
+
global: Record<string, string>;
|
|
2622
|
+
};
|
|
1824
2623
|
|
|
1825
2624
|
declare class CliDragDropService implements ICliDragDropService {
|
|
1826
2625
|
private readonly _container;
|
|
@@ -1832,6 +2631,58 @@ declare class CliDragDropService implements ICliDragDropService {
|
|
|
1832
2631
|
destroy(): void;
|
|
1833
2632
|
}
|
|
1834
2633
|
|
|
2634
|
+
/**
|
|
2635
|
+
* Default HTTP client implementation.
|
|
2636
|
+
*
|
|
2637
|
+
* Wraps the global `fetch()` and automatically merges an abort signal
|
|
2638
|
+
* so that in-flight requests are cancelled when the user presses Ctrl+C.
|
|
2639
|
+
*
|
|
2640
|
+
* Created per-command by the executor — each instance is bound to the
|
|
2641
|
+
* command's own AbortSignal.
|
|
2642
|
+
*/
|
|
2643
|
+
declare class CliHttpClient implements ICliHttpClient {
|
|
2644
|
+
private readonly signal?;
|
|
2645
|
+
constructor(signal?: AbortSignal | undefined);
|
|
2646
|
+
fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
2647
|
+
get<T = any>(url: string, options?: CliHttpRequestOptions): Promise<T>;
|
|
2648
|
+
post<T = any>(url: string, body?: any, options?: CliHttpRequestOptions): Promise<T>;
|
|
2649
|
+
put<T = any>(url: string, body?: any, options?: CliHttpRequestOptions): Promise<T>;
|
|
2650
|
+
patch<T = any>(url: string, body?: any, options?: CliHttpRequestOptions): Promise<T>;
|
|
2651
|
+
delete<T = any>(url: string, options?: CliHttpRequestOptions): Promise<T>;
|
|
2652
|
+
head(url: string, options?: CliHttpRequestOptions): Promise<Response>;
|
|
2653
|
+
options<T = any>(url: string, options?: CliHttpRequestOptions): Promise<T>;
|
|
2654
|
+
private jsonRequest;
|
|
2655
|
+
private isRawBody;
|
|
2656
|
+
/**
|
|
2657
|
+
* Merge the command signal with any additional signals (caller, timeout).
|
|
2658
|
+
* Uses AbortSignal.any() when available, falls back to a manual composite
|
|
2659
|
+
* controller for older browsers (pre-Chrome 116 / Safari 17.4).
|
|
2660
|
+
*/
|
|
2661
|
+
private mergeSignal;
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
declare class CliNotifier implements ICliNotifier {
|
|
2665
|
+
private _current;
|
|
2666
|
+
private readonly _change$;
|
|
2667
|
+
readonly change$: rxjs.Observable<any>;
|
|
2668
|
+
get current(): CliNotification | undefined;
|
|
2669
|
+
info(message: string): void;
|
|
2670
|
+
success(message: string): void;
|
|
2671
|
+
warn(message: string): void;
|
|
2672
|
+
error(message: string): void;
|
|
2673
|
+
clear(): void;
|
|
2674
|
+
private set;
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
/** Default {@link ICliPermissionRegistry}: permissions declared by modules. */
|
|
2678
|
+
declare class CliPermissionRegistry implements ICliPermissionRegistry {
|
|
2679
|
+
private readonly definitions;
|
|
2680
|
+
register(definitions: CliPermissionDefinition[], module?: string): void;
|
|
2681
|
+
unregister(module: string): void;
|
|
2682
|
+
list(): CliPermissionDefinition[];
|
|
2683
|
+
get(name: string): CliPermissionDefinition | undefined;
|
|
2684
|
+
}
|
|
2685
|
+
|
|
1835
2686
|
declare class OverlayAddon implements ITerminalAddon {
|
|
1836
2687
|
private terminal;
|
|
1837
2688
|
private overlayNode;
|
|
@@ -1843,8 +2694,6 @@ declare class OverlayAddon implements ITerminalAddon {
|
|
|
1843
2694
|
}
|
|
1844
2695
|
|
|
1845
2696
|
declare const getCliNameArt: (cols: number) => string;
|
|
1846
|
-
/** @deprecated Use getCliNameArt(cols) instead */
|
|
1847
|
-
declare const CLi_Name_Art = "\n ____ _ _ _ _____ _ _____\n / __ \\ | | | (_) / ____| | |_ _|\n | | | | ___ __| | __ _| |_ ___ | | | | | |\n | | | |/ _ \\ / _` |/ _` | | / __| | | | | | |\n | |__| | (_) | (_| | (_| | | \\__ \\ | |____| |____ _| |_\n \\___\\_\\\\___/ \\__,_|\\__,_|_|_|___/ \\_____|______|_____|\n";
|
|
1848
2697
|
declare const hotkeysInfo: {
|
|
1849
2698
|
key: string;
|
|
1850
2699
|
description: string;
|
|
@@ -1888,28 +2737,140 @@ declare class CliKeyValueStore implements ICliKeyValueStore {
|
|
|
1888
2737
|
declare class CliStateStore implements ICliStateStore {
|
|
1889
2738
|
private readonly services;
|
|
1890
2739
|
readonly name: string;
|
|
1891
|
-
private readonly initialState;
|
|
1892
2740
|
private state$;
|
|
1893
|
-
|
|
1894
|
-
|
|
2741
|
+
/** Signed-in user, for `scope: 'user'` stores. */
|
|
2742
|
+
private user?;
|
|
2743
|
+
private initialState;
|
|
2744
|
+
private options;
|
|
2745
|
+
/** The first load from storage (see `initialize`). */
|
|
2746
|
+
private loading?;
|
|
2747
|
+
private loaded;
|
|
2748
|
+
/** Keys changed before the saved state was loaded: they win over it. */
|
|
2749
|
+
private readonly changedBeforeLoad;
|
|
2750
|
+
/** Keys changed since the last save (only these are written). */
|
|
2751
|
+
private readonly unsaved;
|
|
2752
|
+
/** When each key was last changed here (`updateState`), to tell local edits from synced ones. */
|
|
2753
|
+
private readonly editedAt;
|
|
2754
|
+
private edits;
|
|
2755
|
+
/** `reset()` since the last save: the whole state is written. */
|
|
2756
|
+
private replaceOnSave;
|
|
2757
|
+
/**
|
|
2758
|
+
* Each key as last loaded, saved or received (JSON), to also find keys
|
|
2759
|
+
* changed in place without `updateState`.
|
|
2760
|
+
*/
|
|
2761
|
+
private baseline;
|
|
2762
|
+
private persistScheduled;
|
|
2763
|
+
/**
|
|
2764
|
+
* Called after the state was saved (set by the store manager to share it
|
|
2765
|
+
* with other tabs).
|
|
2766
|
+
*/
|
|
2767
|
+
onPersisted?: (storageKey: string, state: CliState) => void;
|
|
2768
|
+
constructor(services: ICliServiceProvider, name: string, initialState: CliState, options?: CliStateStoreOptions);
|
|
2769
|
+
/** Key the state is saved under. */
|
|
2770
|
+
get key(): string;
|
|
2771
|
+
/**
|
|
2772
|
+
* Saved per store, or per signed-in user for `scope: 'user'` (signed
|
|
2773
|
+
* out, the state is shared like a global store).
|
|
2774
|
+
*/
|
|
2775
|
+
private get storageKey();
|
|
2776
|
+
/**
|
|
2777
|
+
* The signed-in user changed: a `scope: 'user'` store switches to that
|
|
2778
|
+
* user's saved state (unsaved changes of the previous user are dropped,
|
|
2779
|
+
* so save before switching users).
|
|
2780
|
+
*/
|
|
2781
|
+
setUser(user: string | undefined): void;
|
|
2782
|
+
/** Whether changes saved by other tabs are applied to this store. */
|
|
2783
|
+
get syncAcrossTabs(): boolean;
|
|
2784
|
+
/** A session store lives in this terminal only and is never saved. */
|
|
2785
|
+
private get isSession();
|
|
1895
2786
|
getState<T extends CliState = CliState>(): T;
|
|
1896
2787
|
updateState(newState: Partial<CliState>): void;
|
|
1897
2788
|
select<K>(selector: (state: CliState) => K): Observable<K>;
|
|
1898
2789
|
subscribe(callback: (state: CliState) => void): Subscription;
|
|
1899
2790
|
reset(): void;
|
|
2791
|
+
/**
|
|
2792
|
+
* Save the state. The saved state is loaded first, so saving before the
|
|
2793
|
+
* store was loaded never replaces data with the initial state.
|
|
2794
|
+
*/
|
|
1900
2795
|
persist(): Promise<void>;
|
|
2796
|
+
/**
|
|
2797
|
+
* Change the state from its latest saved value and save it, atomically:
|
|
2798
|
+
* under the cross-tab lock, `change` gets the state as saved (plus this
|
|
2799
|
+
* terminal's unsaved changes) and its result is merged and written. Two
|
|
2800
|
+
* terminals updating the same key never lose each other's change, e.g.
|
|
2801
|
+
* both adding an item to a list. Without storage (or for a session
|
|
2802
|
+
* store) it is a plain `updateState`.
|
|
2803
|
+
*/
|
|
2804
|
+
update(change: (state: CliState) => Partial<CliState>): Promise<void>;
|
|
1901
2805
|
initialize(): Promise<void>;
|
|
2806
|
+
reload(): Promise<void>;
|
|
2807
|
+
/**
|
|
2808
|
+
* Add defaults for keys the store does not have yet (when it was first
|
|
2809
|
+
* created without them, e.g. read before its command registered).
|
|
2810
|
+
*/
|
|
2811
|
+
applyDefaults(defaults: CliState): void;
|
|
2812
|
+
/** Merge store options (later options win). */
|
|
2813
|
+
setOptions(options: CliStateStoreOptions): void;
|
|
2814
|
+
/**
|
|
2815
|
+
* State saved by another tab or terminal: apply it without saving again,
|
|
2816
|
+
* keeping the keys changed here and not saved yet.
|
|
2817
|
+
*/
|
|
2818
|
+
applySaved(state: CliState): void;
|
|
2819
|
+
/**
|
|
2820
|
+
* Another tab or terminal saved this store: apply what is saved now.
|
|
2821
|
+
* Messages can arrive out of order (one sent before this terminal's own
|
|
2822
|
+
* save can arrive after it), so storage, not the message, is the truth.
|
|
2823
|
+
* Reads are chained so the last one applied is the latest.
|
|
2824
|
+
*/
|
|
2825
|
+
refreshFromStorage(fallback?: CliState): Promise<void>;
|
|
2826
|
+
private refreshing;
|
|
1902
2827
|
/**
|
|
1903
2828
|
* Complete the BehaviorSubject so all subscribers are notified
|
|
1904
2829
|
* and no further emissions occur. Called during engine teardown.
|
|
1905
2830
|
*/
|
|
1906
2831
|
dispose(): void;
|
|
2832
|
+
private load;
|
|
2833
|
+
/**
|
|
2834
|
+
* Save the keys changed here, merged into the saved state (the whole
|
|
2835
|
+
* state after `reset()` or a migration). Runs under a lock shared by all
|
|
2836
|
+
* tabs, so two terminals saving at once do not lose each other's keys.
|
|
2837
|
+
* Keys others saved meanwhile are applied here.
|
|
2838
|
+
*/
|
|
2839
|
+
private write;
|
|
2840
|
+
/** Keys changed here since the last load, save or received state. */
|
|
2841
|
+
private changedKeys;
|
|
2842
|
+
private setBaseline;
|
|
2843
|
+
private pick;
|
|
2844
|
+
private get versionKey();
|
|
2845
|
+
/** With `autoPersist`, save once after the changes of this tick. */
|
|
2846
|
+
private schedulePersist;
|
|
1907
2847
|
}
|
|
1908
2848
|
|
|
1909
2849
|
interface CliEngineOptions extends CliOptions {
|
|
1910
2850
|
terminalOptions?: Partial<ITerminalOptions & ITerminalInitOnlyOptions>;
|
|
1911
2851
|
/** Optional snapshot to restore on start() */
|
|
1912
2852
|
snapshot?: CliEngineSnapshot;
|
|
2853
|
+
/**
|
|
2854
|
+
* Explicit URL of `qodalis_cli_wasm_bg.wasm` (optional accelerator). When
|
|
2855
|
+
* omitted it is looked up next to the page (`document.baseURI`), then at
|
|
2856
|
+
* `/assets/wasm/` and `/wasm/`; the CLI works without it.
|
|
2857
|
+
*/
|
|
2858
|
+
wasmUrl?: string;
|
|
2859
|
+
/**
|
|
2860
|
+
* The welcome banner and greeting shown at startup. `false` starts with
|
|
2861
|
+
* just the prompt (embedded terminals, playgrounds, terminals driven by
|
|
2862
|
+
* `execute()`); an object configures the banner like
|
|
2863
|
+
* `welcomeModule.configure()`.
|
|
2864
|
+
* @default true
|
|
2865
|
+
*/
|
|
2866
|
+
welcome?: boolean | CliWelcomeMessageConfig;
|
|
2867
|
+
/**
|
|
2868
|
+
* Focus the terminal when it starts. Turn it off when the terminal sits
|
|
2869
|
+
* next to other inputs that should keep the keyboard (an editor that
|
|
2870
|
+
* rebuilds the terminal while the user types); `focus()` still works.
|
|
2871
|
+
* @default true
|
|
2872
|
+
*/
|
|
2873
|
+
autoFocus?: boolean;
|
|
1913
2874
|
}
|
|
1914
2875
|
declare class CliEngine {
|
|
1915
2876
|
private readonly container;
|
|
@@ -1928,6 +2889,11 @@ declare class CliEngine {
|
|
|
1928
2889
|
private resizeScheduled;
|
|
1929
2890
|
private bootService?;
|
|
1930
2891
|
private dragDropService?;
|
|
2892
|
+
private _startedAt?;
|
|
2893
|
+
private terminalOptions;
|
|
2894
|
+
private _isBooted;
|
|
2895
|
+
private resolveBooted;
|
|
2896
|
+
private readonly bootedPromise;
|
|
1931
2897
|
constructor(container: HTMLElement, options?: CliEngineOptions | undefined);
|
|
1932
2898
|
/**
|
|
1933
2899
|
* Register a CLI module to be loaded on start().
|
|
@@ -1938,25 +2904,55 @@ declare class CliEngine {
|
|
|
1938
2904
|
*/
|
|
1939
2905
|
registerModules(modules: ICliModule[]): void;
|
|
1940
2906
|
/**
|
|
1941
|
-
* Register a
|
|
1942
|
-
*
|
|
2907
|
+
* Register a service to be available in the service container before
|
|
2908
|
+
* any module boots. Must be called before start(). Services a module
|
|
2909
|
+
* needs for itself belong in its `services`.
|
|
1943
2910
|
*/
|
|
1944
|
-
|
|
2911
|
+
registerService(token: string, value: any): void;
|
|
1945
2912
|
/**
|
|
1946
|
-
*
|
|
1947
|
-
*
|
|
2913
|
+
* Start the CLI: set up the terminal and services, boot the modules
|
|
2914
|
+
* (reporting progress in the terminal), then hand over to the prompt.
|
|
2915
|
+
*
|
|
2916
|
+
* Phases, in order:
|
|
2917
|
+
* 1. terminal xterm.js in the container
|
|
2918
|
+
* 2. services service container, executor, execution context
|
|
2919
|
+
* 3. boot report hold typed keys, show the boot log
|
|
2920
|
+
* 4. runtime environment, background services, servers
|
|
2921
|
+
* 5. modules core + welcome + server + user modules
|
|
2922
|
+
* 6. completion tab-completion providers
|
|
2923
|
+
* 7. ready clear the report, replay typed keys, `isBooted`
|
|
2924
|
+
* 8. after boot `onAfterBoot` hooks (welcome message), snapshot
|
|
1948
2925
|
*/
|
|
1949
|
-
|
|
2926
|
+
start(): Promise<void>;
|
|
2927
|
+
/** 1. Wait for the container to have a size, then create xterm.js. */
|
|
2928
|
+
private setupTerminal;
|
|
2929
|
+
/** 2. Service container, boot service, executor and execution context. */
|
|
2930
|
+
private setupServices;
|
|
1950
2931
|
/**
|
|
1951
|
-
*
|
|
1952
|
-
*
|
|
1953
|
-
* @deprecated Use registerModule() with services instead.
|
|
2932
|
+
* 3. Keep what the user types until the terminal is ready (replayed at
|
|
2933
|
+
* the first prompt) and start the boot report (configurable).
|
|
1954
2934
|
*/
|
|
1955
|
-
|
|
2935
|
+
private beginBootReport;
|
|
2936
|
+
/** 4. Environment variables, background services, server auth and manager. */
|
|
2937
|
+
private registerRuntimeServices;
|
|
2938
|
+
/** 4. Connect to the configured servers, one boot step each. */
|
|
2939
|
+
private connectServers;
|
|
1956
2940
|
/**
|
|
1957
|
-
*
|
|
2941
|
+
* 5. Built-in welcome and server modules, the app's modules, and the
|
|
2942
|
+
* greeting, which runs after every other `onAfterBoot` hook.
|
|
1958
2943
|
*/
|
|
1959
|
-
|
|
2944
|
+
private modulesToBoot;
|
|
2945
|
+
/** Whether startup shows the welcome banner (which also shows the first prompt). */
|
|
2946
|
+
private get showsWelcome();
|
|
2947
|
+
/** 7. Replace the boot report with the terminal and mark the CLI booted. */
|
|
2948
|
+
private completeBoot;
|
|
2949
|
+
/**
|
|
2950
|
+
* Boot threw: never leave the terminal unusable. Keep the report with the
|
|
2951
|
+
* error on screen, show the cursor and hand over typed keys.
|
|
2952
|
+
*/
|
|
2953
|
+
private failBoot;
|
|
2954
|
+
/** 8. `onAfterBoot` hooks by priority (lower first); one failing hook does not stop the rest. */
|
|
2955
|
+
private runAfterBootHooks;
|
|
1960
2956
|
/**
|
|
1961
2957
|
* Clean up terminal and event listeners.
|
|
1962
2958
|
*/
|
|
@@ -1978,7 +2974,23 @@ declare class CliEngine {
|
|
|
1978
2974
|
*/
|
|
1979
2975
|
getRegistry(): CliCommandProcessorRegistry;
|
|
1980
2976
|
/**
|
|
1981
|
-
*
|
|
2977
|
+
* `true` once boot has completed: modules are set up and the terminal
|
|
2978
|
+
* accepts input. `onAfterBoot` hooks (welcome message) run right after.
|
|
2979
|
+
*/
|
|
2980
|
+
get isBooted(): boolean;
|
|
2981
|
+
/**
|
|
2982
|
+
* Resolves when boot has completed (see `isBooted`). Never rejects; if
|
|
2983
|
+
* `start()` fails it stays pending.
|
|
2984
|
+
*/
|
|
2985
|
+
get booted(): Promise<void>;
|
|
2986
|
+
/**
|
|
2987
|
+
* Timestamp (ms since epoch) when the engine finished starting.
|
|
2988
|
+
*/
|
|
2989
|
+
get startedAt(): number | undefined;
|
|
2990
|
+
/**
|
|
2991
|
+
* Execute a command programmatically, behaving the same as if the user
|
|
2992
|
+
* typed it and pressed Enter: echoes the command, adds it to history,
|
|
2993
|
+
* executes it, and shows a new prompt afterwards.
|
|
1982
2994
|
*/
|
|
1983
2995
|
execute(command: string): Promise<void>;
|
|
1984
2996
|
/**
|
|
@@ -1992,8 +3004,6 @@ declare class CliEngine {
|
|
|
1992
3004
|
* source, the restored content may reflow differently.
|
|
1993
3005
|
*/
|
|
1994
3006
|
private restoreSnapshot;
|
|
1995
|
-
private getTerminalOptions;
|
|
1996
|
-
private initializeTerminal;
|
|
1997
3007
|
private handleResize;
|
|
1998
3008
|
/**
|
|
1999
3009
|
* Call fitAddon.fit() only when the container has non-zero dimensions.
|
|
@@ -2007,55 +3017,216 @@ declare class CliEngine {
|
|
|
2007
3017
|
* so intermediate resize events cannot leave stale artefacts.
|
|
2008
3018
|
*/
|
|
2009
3019
|
private deferResizeFix;
|
|
2010
|
-
/** Maximum time (ms) to wait for container layout before rejecting. */
|
|
2011
|
-
private static readonly LAYOUT_TIMEOUT_MS;
|
|
2012
|
-
/**
|
|
2013
|
-
* Wait until the container element has non-zero dimensions.
|
|
2014
|
-
* xterm.js requires the host element to be laid out before open() is called.
|
|
2015
|
-
* Rejects after {@link LAYOUT_TIMEOUT_MS} if the container stays hidden.
|
|
2016
|
-
*/
|
|
2017
|
-
private waitForLayout;
|
|
2018
3020
|
}
|
|
2019
3021
|
|
|
3022
|
+
interface TerminalSetupResult {
|
|
3023
|
+
terminal: Terminal;
|
|
3024
|
+
fitAddon: FitAddon;
|
|
3025
|
+
serializeAddon: SerializeAddon;
|
|
3026
|
+
dragDropService: CliDragDropService;
|
|
3027
|
+
wheelListener: (e: WheelEvent) => void;
|
|
3028
|
+
}
|
|
3029
|
+
/**
|
|
3030
|
+
* Default terminal font size: 20px, or 14px on phone-sized viewports so a
|
|
3031
|
+
* line still fits a useful number of columns (about 26 at 20px on a 390px screen).
|
|
3032
|
+
*/
|
|
3033
|
+
declare function defaultFontSize(): number;
|
|
3034
|
+
/**
|
|
3035
|
+
* Merge user-supplied terminal options with sensible defaults.
|
|
3036
|
+
*/
|
|
3037
|
+
declare function getTerminalOptions(userOptions?: Partial<ITerminalOptions & ITerminalInitOnlyOptions>): ITerminalOptions & ITerminalInitOnlyOptions;
|
|
3038
|
+
/**
|
|
3039
|
+
* Create and configure an xterm.js Terminal with all required addons,
|
|
3040
|
+
* open it into the given container, and return the instances.
|
|
3041
|
+
*/
|
|
3042
|
+
declare function initializeTerminal(container: HTMLElement, opts: ITerminalOptions & ITerminalInitOnlyOptions, focus?: boolean): TerminalSetupResult;
|
|
3043
|
+
/**
|
|
3044
|
+
* Wait until the container element has non-zero dimensions.
|
|
3045
|
+
* xterm.js requires the host element to be laid out before open() is called.
|
|
3046
|
+
* Rejects after {@link LAYOUT_TIMEOUT_MS} if the container stays hidden.
|
|
3047
|
+
*/
|
|
3048
|
+
declare function waitForLayout(container: HTMLElement): Promise<void>;
|
|
3049
|
+
|
|
3050
|
+
/**
|
|
3051
|
+
* In-memory publish/subscribe bus of one terminal. Handlers run
|
|
3052
|
+
* synchronously in subscription order; a throwing handler is reported to
|
|
3053
|
+
* `onHandlerError` and does not stop delivery. Keeps the last
|
|
3054
|
+
* {@link CLI_EVENT_HISTORY_SIZE} events; nothing is persisted.
|
|
3055
|
+
*/
|
|
3056
|
+
declare class CliEventBus implements ICliEventBus {
|
|
3057
|
+
private readonly onHandlerError;
|
|
3058
|
+
private readonly historySize;
|
|
3059
|
+
private readonly subject;
|
|
3060
|
+
private readonly recent;
|
|
3061
|
+
private disposed;
|
|
3062
|
+
constructor(onHandlerError?: (error: unknown, event: CliEvent) => void, historySize?: number);
|
|
3063
|
+
emit<K extends CliEventType>(type: K, data: CliEventMap[K], options?: CliEmitOptions): void;
|
|
3064
|
+
emit<T = unknown, K extends string = string>(type: K & CustomEventType<K>, data?: T, options?: CliEmitOptions): void;
|
|
3065
|
+
on<K extends CliEventType>(pattern: K, handler: CliEventHandler<CliEventMap[K]>): () => void;
|
|
3066
|
+
on<T = unknown>(pattern: string, handler: CliEventHandler<T>): () => void;
|
|
3067
|
+
once<K extends CliEventType>(pattern: K, handler: CliEventHandler<CliEventMap[K]>): () => void;
|
|
3068
|
+
once<T = unknown>(pattern: string, handler: CliEventHandler<T>): () => void;
|
|
3069
|
+
events$<K extends CliEventType>(pattern: K): Observable<CliEvent<CliEventMap[K]>>;
|
|
3070
|
+
events$<T = unknown>(pattern?: string): Observable<CliEvent<T>>;
|
|
3071
|
+
history<K extends CliEventType>(pattern: K, limit?: number): CliEvent<CliEventMap[K]>[];
|
|
3072
|
+
history<T = unknown>(pattern?: string, limit?: number): CliEvent<T>[];
|
|
3073
|
+
/** Stop delivering events and complete all observables. */
|
|
3074
|
+
dispose(): void;
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
/**
|
|
3078
|
+
* Default implementation of the translation service.
|
|
3079
|
+
*
|
|
3080
|
+
* Maintains a map of locale -> flat key-value translations.
|
|
3081
|
+
* The 'en' locale is always implicitly available via defaultValue fallbacks.
|
|
3082
|
+
* Supports simple {param} interpolation.
|
|
3083
|
+
*/
|
|
3084
|
+
declare class CliTranslationService implements ICliTranslationService {
|
|
3085
|
+
private locale;
|
|
3086
|
+
private readonly translations;
|
|
3087
|
+
t(key: string, defaultValue: string, params?: Record<string, string | number>): string;
|
|
3088
|
+
getLocale(): string;
|
|
3089
|
+
setLocale(locale: string): void;
|
|
3090
|
+
addTranslations(locale: string, translations: Record<string, string>): void;
|
|
3091
|
+
getAvailableLocales(): string[];
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3094
|
+
interface InitializeServicesOptions {
|
|
3095
|
+
registry: CliCommandProcessorRegistry;
|
|
3096
|
+
pendingServices: CliProvider[];
|
|
3097
|
+
dragDropService?: CliDragDropService;
|
|
3098
|
+
}
|
|
3099
|
+
interface InitializeServicesResult {
|
|
3100
|
+
services: CliServiceContainer;
|
|
3101
|
+
events: CliEventBus;
|
|
3102
|
+
logger: CliLogger;
|
|
3103
|
+
commandHistory: CliCommandHistory;
|
|
3104
|
+
stateStoreManager: CliStateStoreManager;
|
|
3105
|
+
processRegistry: CliProcessRegistry;
|
|
3106
|
+
translator: CliTranslationService;
|
|
3107
|
+
}
|
|
3108
|
+
/**
|
|
3109
|
+
* Build and populate the service container with all core services.
|
|
3110
|
+
* Takes the registry, pending (user-registered) services, and the drag-drop
|
|
3111
|
+
* service instance, and returns all initialized services ready for wiring
|
|
3112
|
+
* into the execution context.
|
|
3113
|
+
*/
|
|
3114
|
+
declare function initializeServices(options: InitializeServicesOptions): Promise<InitializeServicesResult>;
|
|
3115
|
+
|
|
3116
|
+
/** Service token holding the name of the framework hosting the CLI. */
|
|
3117
|
+
declare const CLI_FRAMEWORK_SERVICE = "cli-framework";
|
|
3118
|
+
/** What a framework wrapper passes to an engine: shared by components, providers and config contexts. */
|
|
3119
|
+
interface CliHostConfig {
|
|
3120
|
+
modules?: ICliModule[];
|
|
3121
|
+
options?: CliEngineOptions;
|
|
3122
|
+
/** Extra services registered by token before start. */
|
|
3123
|
+
services?: Record<string, any>;
|
|
3124
|
+
}
|
|
3125
|
+
interface CreateCliEngineConfig extends CliHostConfig {
|
|
3126
|
+
/** Reported by `version`, `debug` and `feedback`, e.g. 'React'. */
|
|
3127
|
+
framework?: string;
|
|
3128
|
+
/** Terminal state to restore on start. */
|
|
3129
|
+
snapshot?: CliEngineSnapshot;
|
|
3130
|
+
}
|
|
3131
|
+
/**
|
|
3132
|
+
* Create an engine for `container` with the services and modules of a
|
|
3133
|
+
* wrapper registered (in that order). Call `start()` on it.
|
|
3134
|
+
*/
|
|
3135
|
+
declare function createCliEngine(container: HTMLElement, config?: CreateCliEngineConfig): CliEngine;
|
|
3136
|
+
/**
|
|
3137
|
+
* Resolve a component's config: each field set locally wins over the one
|
|
3138
|
+
* inherited from a surrounding config provider.
|
|
3139
|
+
*/
|
|
3140
|
+
declare function resolveCliHostConfig(local: CliHostConfig, inherited?: CliHostConfig | null): CliHostConfig;
|
|
3141
|
+
/** Merge option objects key by key: `local` overrides `inherited`. */
|
|
3142
|
+
declare function mergeCliOptions<T extends object>(local: T | undefined, inherited: object | undefined): T | undefined;
|
|
3143
|
+
|
|
2020
3144
|
declare class CliServerConnection {
|
|
2021
3145
|
private readonly _config;
|
|
2022
3146
|
private readonly _backgroundServices?;
|
|
2023
3147
|
private readonly _logger?;
|
|
3148
|
+
private readonly _authService?;
|
|
2024
3149
|
private _connected;
|
|
2025
3150
|
private _commands;
|
|
2026
3151
|
private _capabilities;
|
|
2027
3152
|
private _eventSocket;
|
|
3153
|
+
private _apiVersion;
|
|
3154
|
+
private _basePath;
|
|
3155
|
+
private _wsReconnectAttempts;
|
|
3156
|
+
private _wsReconnectTimer;
|
|
3157
|
+
/** True once this connection registered its `server-events:<name>` background service */
|
|
3158
|
+
private _eventServiceRegistered;
|
|
3159
|
+
private static readonly WS_MAX_RECONNECT_ATTEMPTS;
|
|
3160
|
+
private static readonly WS_MAX_RECONNECT_DELAY_MS;
|
|
3161
|
+
private _healthCheckTimer;
|
|
3162
|
+
private _healthCheckAttempts;
|
|
3163
|
+
private static readonly HEALTH_CHECK_INTERVAL_MS;
|
|
3164
|
+
private static readonly HEALTH_CHECK_MAX_ATTEMPTS;
|
|
2028
3165
|
onDisconnect?: () => void;
|
|
2029
|
-
|
|
3166
|
+
onReconnected?: () => void;
|
|
3167
|
+
constructor(_config: CliServerConfig, _backgroundServices?: ICliBackgroundServiceRegistry, _logger?: ICliLogger, _authService?: ICliServerAuthService);
|
|
2030
3168
|
get config(): CliServerConfig;
|
|
2031
3169
|
get connected(): boolean;
|
|
2032
3170
|
get commands(): CliServerCommandDescriptor[];
|
|
2033
3171
|
get capabilities(): CliServerCapabilities | null;
|
|
3172
|
+
get apiVersion(): number;
|
|
3173
|
+
/**
|
|
3174
|
+
* Resolve auth headers for this server connection.
|
|
3175
|
+
* Uses the auth service (which merges config headers with registered
|
|
3176
|
+
* ICliServerAuthTokenProviders), or falls back to config headers directly.
|
|
3177
|
+
*/
|
|
3178
|
+
resolveAuthHeaders(): Record<string, string>;
|
|
3179
|
+
/**
|
|
3180
|
+
* WebSocket URL for this server with auth: single-use upgrade params from
|
|
3181
|
+
* auth providers when available, otherwise headers copied into the URL.
|
|
3182
|
+
*/
|
|
3183
|
+
buildWebSocketUrl(path: string): Promise<string>;
|
|
2034
3184
|
connect(): Promise<void>;
|
|
2035
3185
|
disconnect(): void;
|
|
3186
|
+
startHealthCheck(): void;
|
|
3187
|
+
private scheduleNextHealthCheck;
|
|
3188
|
+
stopHealthCheck(): void;
|
|
2036
3189
|
fetchCommands(): Promise<CliServerCommandDescriptor[]>;
|
|
2037
3190
|
fetchCapabilities(): Promise<CliServerCapabilities | null>;
|
|
2038
3191
|
execute(command: CliProcessCommand): Promise<CliServerResponse>;
|
|
3192
|
+
executeStream(command: CliProcessCommand, onOutput: (output: CliServerOutput) => void): Promise<{
|
|
3193
|
+
exitCode: number;
|
|
3194
|
+
}>;
|
|
2039
3195
|
ping(): Promise<boolean>;
|
|
3196
|
+
/** Whether the server answers HTTP at all (any status: it is running). */
|
|
3197
|
+
private answers;
|
|
2040
3198
|
private connectEventSocket;
|
|
2041
3199
|
private connectEventSocketDirect;
|
|
3200
|
+
private connectEventSocketDirectAsync;
|
|
3201
|
+
/**
|
|
3202
|
+
* The server closes the event socket with 4401 when the session behind it
|
|
3203
|
+
* ended (logout, revoke, expiry). Retrying with the same credentials cannot
|
|
3204
|
+
* succeed; the auth layer reconnects the server when the session changes.
|
|
3205
|
+
*/
|
|
3206
|
+
private isSessionEndedClose;
|
|
2042
3207
|
private handleServerDisconnect;
|
|
2043
3208
|
private closeEventSocket;
|
|
2044
3209
|
private closeEventSocketDirect;
|
|
3210
|
+
private scheduleWsReconnect;
|
|
3211
|
+
private httpFetchWithRetry;
|
|
2045
3212
|
private httpFetch;
|
|
2046
3213
|
private normalizeUrl;
|
|
2047
3214
|
private toWebSocketUrl;
|
|
2048
3215
|
}
|
|
2049
3216
|
|
|
2050
3217
|
/**
|
|
2051
|
-
*
|
|
2052
|
-
* Shared by both single-proxy and multi-proxy processors.
|
|
3218
|
+
* Render a single CliServerOutput to the terminal.
|
|
2053
3219
|
*/
|
|
2054
|
-
declare function
|
|
3220
|
+
declare function renderSingleOutput(output: CliServerOutput, context: ICliExecutionContext): void;
|
|
2055
3221
|
/**
|
|
2056
3222
|
* Render a CliServerResponse to the terminal.
|
|
2057
3223
|
*/
|
|
2058
3224
|
declare function renderServerResponse(response: CliServerResponse, context: ICliExecutionContext): void;
|
|
3225
|
+
/**
|
|
3226
|
+
* Execute a command on a specific server connection and render the response.
|
|
3227
|
+
* Shared by both single-proxy and multi-proxy processors.
|
|
3228
|
+
*/
|
|
3229
|
+
declare function executeOnServer(connection: CliServerConnection, serverName: string, descriptor: CliServerCommandDescriptor, command: CliProcessCommand, context: ICliExecutionContext, commandPath?: string[]): Promise<void>;
|
|
2059
3230
|
declare class CliServerProxyProcessor implements ICliCommandProcessor {
|
|
2060
3231
|
private readonly connection;
|
|
2061
3232
|
private readonly descriptor;
|
|
@@ -2065,9 +3236,12 @@ declare class CliServerProxyProcessor implements ICliCommandProcessor {
|
|
|
2065
3236
|
description?: string;
|
|
2066
3237
|
version?: string;
|
|
2067
3238
|
metadata?: CliProcessorMetadata;
|
|
2068
|
-
parameters?: ICliCommandParameterDescriptor[];
|
|
3239
|
+
parameters?: ICliCommandParameterDescriptor$1[];
|
|
2069
3240
|
processors?: ICliCommandProcessor[];
|
|
2070
|
-
|
|
3241
|
+
acceptsRawInput?: boolean;
|
|
3242
|
+
/** Full command path from root to this processor (e.g. ["aws", "lambda", "list"]) */
|
|
3243
|
+
private readonly commandPath;
|
|
3244
|
+
constructor(connection: CliServerConnection, descriptor: CliServerCommandDescriptor, serverName: string, isNested?: boolean, parentPath?: string[]);
|
|
2071
3245
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
2072
3246
|
}
|
|
2073
3247
|
|
|
@@ -2091,22 +3265,30 @@ declare class CliServerMultiProxyProcessor implements ICliCommandProcessor {
|
|
|
2091
3265
|
command: string;
|
|
2092
3266
|
description?: string;
|
|
2093
3267
|
metadata?: CliProcessorMetadata;
|
|
2094
|
-
parameters?: ICliCommandParameterDescriptor[];
|
|
3268
|
+
parameters?: ICliCommandParameterDescriptor$1[];
|
|
2095
3269
|
processors?: ICliCommandProcessor[];
|
|
2096
|
-
|
|
3270
|
+
acceptsRawInput?: boolean;
|
|
3271
|
+
/** Full command path from root to this processor */
|
|
3272
|
+
private readonly commandPath;
|
|
3273
|
+
constructor(entries: MultiProxyEntry[], provider: DefaultServerProvider, parentPath?: string[]);
|
|
2097
3274
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
2098
3275
|
}
|
|
2099
3276
|
|
|
2100
|
-
declare const CliServerManager_TOKEN
|
|
3277
|
+
declare const CliServerManager_TOKEN: any;
|
|
2101
3278
|
declare class CliServerManager implements DefaultServerProvider {
|
|
2102
3279
|
private readonly registry;
|
|
3280
|
+
private readonly authService?;
|
|
3281
|
+
private readonly events?;
|
|
2103
3282
|
readonly connections: Map<string, CliServerConnection>;
|
|
2104
3283
|
private _logger?;
|
|
2105
3284
|
private _cliLogger?;
|
|
2106
3285
|
private _defaultServer;
|
|
3286
|
+
/** Bare-name aliases this manager registered (only these are ever removed) */
|
|
3287
|
+
private readonly _bareAliases;
|
|
2107
3288
|
private _backgroundServices?;
|
|
2108
|
-
constructor(registry: ICliCommandProcessorRegistry);
|
|
3289
|
+
constructor(registry: ICliCommandProcessorRegistry, authService?: ICliServerAuthService, events?: ICliEventBus);
|
|
2109
3290
|
get defaultServer(): string | null;
|
|
3291
|
+
preferredServer(): string | null;
|
|
2110
3292
|
setDefaultServer(name: string | null): void;
|
|
2111
3293
|
connectAll(servers: CliServerConfig[], logger?: {
|
|
2112
3294
|
warn(msg: string): void;
|
|
@@ -2117,6 +3299,7 @@ declare class CliServerManager implements DefaultServerProvider {
|
|
|
2117
3299
|
commandCount: number;
|
|
2118
3300
|
}>;
|
|
2119
3301
|
getConnection(name: string): CliServerConnection | undefined;
|
|
3302
|
+
private emitConnected;
|
|
2120
3303
|
private handleDisconnect;
|
|
2121
3304
|
private unregisterServerProcessors;
|
|
2122
3305
|
private unregisterBareAliases;
|
|
@@ -2126,37 +3309,60 @@ declare class CliServerManager implements DefaultServerProvider {
|
|
|
2126
3309
|
|
|
2127
3310
|
declare function createServerModule(): ICliModule;
|
|
2128
3311
|
|
|
3312
|
+
/**
|
|
3313
|
+
* `server`: the servers this terminal is connected to (configured by the
|
|
3314
|
+
* app in `options.servers`). Their commands are available directly (`echo`)
|
|
3315
|
+
* and namespaced (`node:echo`).
|
|
3316
|
+
*/
|
|
2129
3317
|
declare class CliServerCommandProcessor implements ICliCommandProcessor {
|
|
2130
3318
|
command: string;
|
|
3319
|
+
aliases: string[];
|
|
2131
3320
|
description: string;
|
|
2132
3321
|
metadata: {
|
|
2133
|
-
icon:
|
|
3322
|
+
icon: any;
|
|
2134
3323
|
module: string;
|
|
2135
3324
|
sealed: boolean;
|
|
2136
3325
|
};
|
|
3326
|
+
stateConfiguration: CliStateConfiguration;
|
|
2137
3327
|
processors: ICliCommandChildProcessor[];
|
|
3328
|
+
/** Restore the default server saved by `server default <name>`. */
|
|
3329
|
+
initialize(context: ICliExecutionContext): Promise<void>;
|
|
3330
|
+
/** `server` alone: the servers, then what can be done with them. */
|
|
2138
3331
|
processCommand(_command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
3332
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
2139
3333
|
}
|
|
2140
3334
|
|
|
2141
3335
|
declare class CliSshCommandProcessor implements ICliCommandProcessor {
|
|
2142
3336
|
command: string;
|
|
3337
|
+
aliases: string[];
|
|
2143
3338
|
description: string;
|
|
2144
3339
|
acceptsRawInput: boolean;
|
|
2145
3340
|
valueRequired: boolean;
|
|
2146
3341
|
metadata: CliProcessorMetadata;
|
|
2147
|
-
parameters?: ICliCommandParameterDescriptor[];
|
|
2148
|
-
private socket;
|
|
2149
|
-
private context;
|
|
3342
|
+
parameters?: ICliCommandParameterDescriptor$1[];
|
|
2150
3343
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
3344
|
+
/**
|
|
3345
|
+
* Full-screen handler for one session: input, resize and disposal go to
|
|
3346
|
+
* that session's socket only.
|
|
3347
|
+
*/
|
|
3348
|
+
private fullScreenHandler;
|
|
2154
3349
|
private resolveServer;
|
|
3350
|
+
/** Why `name` cannot be used: unknown, unreachable or without a shell. */
|
|
3351
|
+
private writeWhyNotAvailable;
|
|
3352
|
+
/** No server has a shell: say whether none is configured, connected or shell-enabled. */
|
|
3353
|
+
private writeNoShellServers;
|
|
3354
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
2155
3355
|
private executeInteractive;
|
|
2156
3356
|
private executeOneShot;
|
|
3357
|
+
/** `ssh <server> <cmd...>` → `<cmd...>` exactly as typed */
|
|
3358
|
+
private remoteCommandFromRaw;
|
|
2157
3359
|
private buildShellUrl;
|
|
2158
3360
|
private cleanup;
|
|
2159
3361
|
}
|
|
3362
|
+
declare function describeShellClose(event: {
|
|
3363
|
+
code?: number;
|
|
3364
|
+
reason?: string;
|
|
3365
|
+
}, serverName: string): string | null;
|
|
2160
3366
|
|
|
2161
3367
|
/**
|
|
2162
3368
|
* Result of executing a command through the test harness.
|
|
@@ -2202,20 +3408,30 @@ declare class CliTestHarness {
|
|
|
2202
3408
|
readonly registry: CliCommandProcessorRegistry;
|
|
2203
3409
|
readonly executor: CliCommandExecutor;
|
|
2204
3410
|
readonly services: CliServiceContainer;
|
|
3411
|
+
/** Shared by every command: add a language pack and switch locale to test translations. */
|
|
3412
|
+
readonly translator: CliTranslationService;
|
|
2205
3413
|
private readonly stateStoreManager;
|
|
3414
|
+
private readonly initialized;
|
|
2206
3415
|
private readonly processRegistry;
|
|
2207
3416
|
/** Current user session — set via setUserSession() */
|
|
2208
3417
|
userSession?: ICliUserSession;
|
|
2209
3418
|
/** Reader responses — set via setReaderResponses() for interactive commands */
|
|
2210
3419
|
private readerResponses;
|
|
3420
|
+
private userSessionProvider?;
|
|
2211
3421
|
constructor();
|
|
3422
|
+
/**
|
|
3423
|
+
* Resolve `context.userSession` on every command from this function
|
|
3424
|
+
* (e.g. a session service), instead of the value set via setUserSession().
|
|
3425
|
+
*/
|
|
3426
|
+
setUserSessionProvider(provider: () => ICliUserSession | undefined): void;
|
|
2212
3427
|
/**
|
|
2213
3428
|
* Register a service in the test container.
|
|
2214
3429
|
*/
|
|
2215
3430
|
registerService(token: any, value: any): void;
|
|
2216
3431
|
/**
|
|
2217
3432
|
* Register a command processor. If the processor has an `initialize()`
|
|
2218
|
-
* method, it
|
|
3433
|
+
* method, it is called (with the processor's own state store, as in the
|
|
3434
|
+
* engine) before the first `execute()`, or by `initializeProcessors()`.
|
|
2219
3435
|
*/
|
|
2220
3436
|
registerProcessor(processor: ICliCommandProcessor): void;
|
|
2221
3437
|
/**
|
|
@@ -2227,6 +3443,8 @@ declare class CliTestHarness {
|
|
|
2227
3443
|
* Call this after registering all services and processors.
|
|
2228
3444
|
*/
|
|
2229
3445
|
initializeProcessors(): Promise<void>;
|
|
3446
|
+
/** As the engine's boot: link sub-commands to their parent, then initialize. */
|
|
3447
|
+
private initializeTree;
|
|
2230
3448
|
/**
|
|
2231
3449
|
* Set the active user session. Commands that check `context.userSession`
|
|
2232
3450
|
* will see this session.
|
|
@@ -2301,4 +3519,511 @@ declare function getAccelerator(): ICliWasmAccelerator;
|
|
|
2301
3519
|
*/
|
|
2302
3520
|
declare function isWasmAccelerated(): boolean;
|
|
2303
3521
|
|
|
2304
|
-
|
|
3522
|
+
/** One terminal inside a tab. */
|
|
3523
|
+
interface CliPanelPane {
|
|
3524
|
+
id: number;
|
|
3525
|
+
widthPercent: number;
|
|
3526
|
+
/** Snapshot to restore when the pane's engine starts (used by "Duplicate"). */
|
|
3527
|
+
snapshot?: CliEngineSnapshot;
|
|
3528
|
+
}
|
|
3529
|
+
/** One tab of the panel: a title and one or more panes side by side. */
|
|
3530
|
+
interface CliPanelTab {
|
|
3531
|
+
id: number;
|
|
3532
|
+
title: string;
|
|
3533
|
+
isEditing: boolean;
|
|
3534
|
+
panes: CliPanelPane[];
|
|
3535
|
+
}
|
|
3536
|
+
interface CliPanelContextMenu {
|
|
3537
|
+
visible: boolean;
|
|
3538
|
+
x: number;
|
|
3539
|
+
y: number;
|
|
3540
|
+
tabId: number;
|
|
3541
|
+
}
|
|
3542
|
+
interface CliPanelServiceDetail {
|
|
3543
|
+
name: string;
|
|
3544
|
+
status: string;
|
|
3545
|
+
description?: string;
|
|
3546
|
+
}
|
|
3547
|
+
interface CliPanelServerDetail {
|
|
3548
|
+
name: string;
|
|
3549
|
+
url: string;
|
|
3550
|
+
connected: boolean;
|
|
3551
|
+
apiVersion?: string;
|
|
3552
|
+
commandCount?: number;
|
|
3553
|
+
}
|
|
3554
|
+
type CliPanelExecutionState = 'idle' | 'running';
|
|
3555
|
+
type CliPanelServerState = 'connected' | 'disconnected' | 'none';
|
|
3556
|
+
/** Status derived from the engines of a single tab. */
|
|
3557
|
+
interface CliPanelTabStatus {
|
|
3558
|
+
executionState: CliPanelExecutionState;
|
|
3559
|
+
lastCommand: {
|
|
3560
|
+
name: string;
|
|
3561
|
+
success: boolean;
|
|
3562
|
+
} | null;
|
|
3563
|
+
notification: CliNotification | null;
|
|
3564
|
+
}
|
|
3565
|
+
/** Status derived from the first engine of the active tab. */
|
|
3566
|
+
interface CliPanelGlobalStatus {
|
|
3567
|
+
serviceCount: {
|
|
3568
|
+
running: number;
|
|
3569
|
+
total: number;
|
|
3570
|
+
};
|
|
3571
|
+
serviceDetails: CliPanelServiceDetail[];
|
|
3572
|
+
serverState: CliPanelServerState;
|
|
3573
|
+
serverDetails: CliPanelServerDetail[];
|
|
3574
|
+
/** Milliseconds since the engine started, 0 when unknown. */
|
|
3575
|
+
uptime: number;
|
|
3576
|
+
}
|
|
3577
|
+
declare const DEFAULT_TAB_STATUS: CliPanelTabStatus;
|
|
3578
|
+
declare const DEFAULT_GLOBAL_STATUS: CliPanelGlobalStatus;
|
|
3579
|
+
/**
|
|
3580
|
+
* Values a host may control from the outside. A defined value wins over the
|
|
3581
|
+
* panel's own state; `undefined` leaves the panel uncontrolled for that field.
|
|
3582
|
+
*/
|
|
3583
|
+
interface CliPanelControlledState {
|
|
3584
|
+
collapsed?: boolean;
|
|
3585
|
+
hidden?: boolean;
|
|
3586
|
+
maximized?: boolean;
|
|
3587
|
+
activeTabId?: number;
|
|
3588
|
+
position?: CliPanelPosition;
|
|
3589
|
+
height?: number;
|
|
3590
|
+
width?: number;
|
|
3591
|
+
}
|
|
3592
|
+
/** Change notifications and structural events, mapped by each framework wrapper. */
|
|
3593
|
+
interface CliPanelCallbacks {
|
|
3594
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
3595
|
+
onHiddenChange?: (hidden: boolean) => void;
|
|
3596
|
+
onMaximizedChange?: (maximized: boolean) => void;
|
|
3597
|
+
onActiveTabIdChange?: (tabId: number) => void;
|
|
3598
|
+
onPositionChange?: (position: CliPanelPosition) => void;
|
|
3599
|
+
onHeightChange?: (height: number) => void;
|
|
3600
|
+
onWidthChange?: (width: number) => void;
|
|
3601
|
+
onClose?: () => void;
|
|
3602
|
+
onTabAdded?: (event: {
|
|
3603
|
+
tabId: number;
|
|
3604
|
+
}) => void;
|
|
3605
|
+
onTabClosed?: (event: {
|
|
3606
|
+
tabId: number;
|
|
3607
|
+
}) => void;
|
|
3608
|
+
onPaneSplit?: (event: {
|
|
3609
|
+
paneId: number;
|
|
3610
|
+
tabId: number;
|
|
3611
|
+
}) => void;
|
|
3612
|
+
onPaneClosed?: (event: {
|
|
3613
|
+
paneId: number;
|
|
3614
|
+
}) => void;
|
|
3615
|
+
}
|
|
3616
|
+
interface CliPanelViewport {
|
|
3617
|
+
width: number;
|
|
3618
|
+
height: number;
|
|
3619
|
+
}
|
|
3620
|
+
interface CliPanelControllerOptions {
|
|
3621
|
+
/** Panel configuration (initial state, chrome buttons, theme sync). */
|
|
3622
|
+
config?: CliPanelConfig;
|
|
3623
|
+
callbacks?: CliPanelCallbacks;
|
|
3624
|
+
controlled?: CliPanelControlledState;
|
|
3625
|
+
/** Viewport size used for maximize and resize clamping. Defaults to `window`. */
|
|
3626
|
+
viewport?: () => CliPanelViewport;
|
|
3627
|
+
/**
|
|
3628
|
+
* Restore and persist the position through localStorage.
|
|
3629
|
+
* @default true
|
|
3630
|
+
*/
|
|
3631
|
+
persistPosition?: boolean;
|
|
3632
|
+
}
|
|
3633
|
+
/**
|
|
3634
|
+
* Immutable view of the whole panel. A new object is produced on every
|
|
3635
|
+
* change, so views can compare by reference.
|
|
3636
|
+
*/
|
|
3637
|
+
interface CliPanelSnapshot {
|
|
3638
|
+
visible: boolean;
|
|
3639
|
+
/** True once the first tab has been created (content rendered). */
|
|
3640
|
+
initialized: boolean;
|
|
3641
|
+
collapsed: boolean;
|
|
3642
|
+
hidden: boolean;
|
|
3643
|
+
maximized: boolean;
|
|
3644
|
+
position: CliPanelPosition;
|
|
3645
|
+
height: number;
|
|
3646
|
+
width: number;
|
|
3647
|
+
isHorizontal: boolean;
|
|
3648
|
+
/** Status text is shown in the header for top/bottom, compact dots otherwise. */
|
|
3649
|
+
showStatusIndicators: boolean;
|
|
3650
|
+
panelResizing: boolean;
|
|
3651
|
+
themeStyles: Record<string, string>;
|
|
3652
|
+
closable: boolean;
|
|
3653
|
+
resizable: boolean;
|
|
3654
|
+
hideable: boolean;
|
|
3655
|
+
hideAlignment: CliPanelHideAlignment;
|
|
3656
|
+
syncTheme: boolean;
|
|
3657
|
+
tabs: readonly CliPanelTab[];
|
|
3658
|
+
activeTabId: number;
|
|
3659
|
+
activePaneId: number;
|
|
3660
|
+
paneResizing: boolean;
|
|
3661
|
+
contextMenu: CliPanelContextMenu;
|
|
3662
|
+
positionDropdownOpen: boolean;
|
|
3663
|
+
servicesDropdownOpen: boolean;
|
|
3664
|
+
servicesDropdownStyle: Record<string, string>;
|
|
3665
|
+
serversDropdownOpen: boolean;
|
|
3666
|
+
serversDropdownStyle: Record<string, string>;
|
|
3667
|
+
/** Status of the active tab. */
|
|
3668
|
+
status: CliPanelTabStatus;
|
|
3669
|
+
tabStatuses: Readonly<Record<number, CliPanelTabStatus>>;
|
|
3670
|
+
global: CliPanelGlobalStatus;
|
|
3671
|
+
formattedUptime: string;
|
|
3672
|
+
}
|
|
3673
|
+
|
|
3674
|
+
declare const MIN_PANE_WIDTH_PERCENT = 10;
|
|
3675
|
+
declare const MIN_PANEL_SIZE = 100;
|
|
3676
|
+
declare const DEFAULT_PANEL_HEIGHT = 600;
|
|
3677
|
+
declare const DEFAULT_PANEL_WIDTH = 400;
|
|
3678
|
+
declare const PANEL_POSITIONS: readonly CliPanelPosition[];
|
|
3679
|
+
/** Scale pane widths so they add up to 100. Returns new pane objects. */
|
|
3680
|
+
declare function normalizePaneWidths(panes: readonly CliPanelPane[]): CliPanelPane[];
|
|
3681
|
+
/** Give every pane the same width. Returns new pane objects. */
|
|
3682
|
+
declare function distributePaneWidths(panes: readonly CliPanelPane[]): CliPanelPane[];
|
|
3683
|
+
/**
|
|
3684
|
+
* Move the divider between pane `dividerIndex` and `dividerIndex + 1` by
|
|
3685
|
+
* `deltaPercent`, keeping both panes at least `MIN_PANE_WIDTH_PERCENT` wide.
|
|
3686
|
+
*/
|
|
3687
|
+
declare function resizePaneWidths(startWidths: readonly number[], dividerIndex: number, deltaPercent: number): number[];
|
|
3688
|
+
/** Clamp a dragged panel size between the minimum and the viewport. */
|
|
3689
|
+
declare function clampPanelSize(size: number, max: number): number;
|
|
3690
|
+
/**
|
|
3691
|
+
* New panel size for a drag that started at `start` and moved by
|
|
3692
|
+
* (`deltaX`, `deltaY`). Only the axis matching the position matters.
|
|
3693
|
+
*/
|
|
3694
|
+
declare function resizedPanelSize(position: CliPanelPosition, start: {
|
|
3695
|
+
width: number;
|
|
3696
|
+
height: number;
|
|
3697
|
+
}, deltaX: number, deltaY: number, viewport: CliPanelViewport): {
|
|
3698
|
+
width?: number;
|
|
3699
|
+
height?: number;
|
|
3700
|
+
};
|
|
3701
|
+
interface AnchorRect {
|
|
3702
|
+
top: number;
|
|
3703
|
+
bottom: number;
|
|
3704
|
+
left: number;
|
|
3705
|
+
right: number;
|
|
3706
|
+
}
|
|
3707
|
+
/**
|
|
3708
|
+
* Fixed-position style for a dropdown opened from `anchor`, placed on the
|
|
3709
|
+
* side of the panel that faces the page.
|
|
3710
|
+
*/
|
|
3711
|
+
declare function dropdownAnchorStyle(anchor: AnchorRect, position: CliPanelPosition, viewport: CliPanelViewport): Record<string, string>;
|
|
3712
|
+
/** "12m", "1h05m"-style uptime label. */
|
|
3713
|
+
declare function formatUptime(ms: number): string;
|
|
3714
|
+
declare function isHorizontalPosition(position: CliPanelPosition): boolean;
|
|
3715
|
+
|
|
3716
|
+
/** Poll interval for execution state, last command and notifications. */
|
|
3717
|
+
declare const EXEC_POLL_MS = 300;
|
|
3718
|
+
/** Poll interval for services, servers and uptime. */
|
|
3719
|
+
declare const GLOBAL_POLL_MS = 2000;
|
|
3720
|
+
/** Status of a tab from all of its pane engines. */
|
|
3721
|
+
declare function computeTabStatus(engines: Iterable<CliEngine>): CliPanelTabStatus;
|
|
3722
|
+
/** Services, servers and uptime of one engine. */
|
|
3723
|
+
declare function computeGlobalStatus(engine: CliEngine | undefined, now?: number): CliPanelGlobalStatus;
|
|
3724
|
+
interface CliPanelStatusTrackerListener {
|
|
3725
|
+
onTabStatus(tabId: number, status: CliPanelTabStatus): void;
|
|
3726
|
+
onGlobalStatus(status: CliPanelGlobalStatus): void;
|
|
3727
|
+
}
|
|
3728
|
+
/**
|
|
3729
|
+
* Watches the engines of every tab and reports status changes. Execution
|
|
3730
|
+
* state is polled quickly, services and servers slowly; engine events
|
|
3731
|
+
* (notifier, background services) trigger an immediate refresh.
|
|
3732
|
+
*/
|
|
3733
|
+
declare class CliPanelStatusTracker {
|
|
3734
|
+
private readonly listener;
|
|
3735
|
+
private tabs;
|
|
3736
|
+
private activeTabId?;
|
|
3737
|
+
private globalStatus;
|
|
3738
|
+
private execTimer?;
|
|
3739
|
+
private globalTimer?;
|
|
3740
|
+
constructor(listener: CliPanelStatusTrackerListener);
|
|
3741
|
+
registerEngine(tabId: number, paneId: number, engine: CliEngine): void;
|
|
3742
|
+
unregisterPane(paneId: number): void;
|
|
3743
|
+
unregisterTab(tabId: number): void;
|
|
3744
|
+
setActiveTab(tabId: number): void;
|
|
3745
|
+
/** Recompute everything now. */
|
|
3746
|
+
refresh(): void;
|
|
3747
|
+
destroy(): void;
|
|
3748
|
+
private ensurePolling;
|
|
3749
|
+
private stopPolling;
|
|
3750
|
+
private refreshTab;
|
|
3751
|
+
private refreshGlobal;
|
|
3752
|
+
}
|
|
3753
|
+
|
|
3754
|
+
/**
|
|
3755
|
+
* Framework-agnostic state and behaviour of the collapsible CLI panel:
|
|
3756
|
+
* tabs and panes, chrome (collapse, hide, maximize, position, size),
|
|
3757
|
+
* menus, drag resizing, theme sync and the status bar.
|
|
3758
|
+
*
|
|
3759
|
+
* Views subscribe with {@link subscribe} and render {@link getSnapshot};
|
|
3760
|
+
* every change produces a new immutable snapshot. Hosts may control any of
|
|
3761
|
+
* the bindable values through {@link setControlled}; the matching
|
|
3762
|
+
* `onXChange` callback is invoked whenever the panel wants to change it.
|
|
3763
|
+
*/
|
|
3764
|
+
declare class CliPanelController implements ICliPanelRef<CliEngine> {
|
|
3765
|
+
callbacks: CliPanelCallbacks;
|
|
3766
|
+
private snapshot;
|
|
3767
|
+
private internal;
|
|
3768
|
+
private controlled;
|
|
3769
|
+
private readonly listeners;
|
|
3770
|
+
private readonly engines;
|
|
3771
|
+
private readonly tracker;
|
|
3772
|
+
private readonly viewport;
|
|
3773
|
+
private readonly persistPosition;
|
|
3774
|
+
private nextTabId;
|
|
3775
|
+
private nextPaneId;
|
|
3776
|
+
private preHideCollapsed;
|
|
3777
|
+
private previousHeight;
|
|
3778
|
+
private previousWidth;
|
|
3779
|
+
private panelDrag?;
|
|
3780
|
+
private paneDrag?;
|
|
3781
|
+
private documentListenersAttached;
|
|
3782
|
+
private rootElement;
|
|
3783
|
+
private themeObserver?;
|
|
3784
|
+
constructor(options?: CliPanelControllerOptions);
|
|
3785
|
+
readonly subscribe: (listener: () => void) => (() => void);
|
|
3786
|
+
readonly getSnapshot: () => CliPanelSnapshot;
|
|
3787
|
+
/** Apply a new panel configuration (chrome buttons, theme sync). */
|
|
3788
|
+
setOptions(config: CliPanelConfig | undefined): void;
|
|
3789
|
+
/** Replace the change callbacks (wrappers call this when their props change). */
|
|
3790
|
+
setCallbacks(callbacks: CliPanelCallbacks): void;
|
|
3791
|
+
/** Update host-controlled values. Unchanged values are ignored. */
|
|
3792
|
+
setControlled(values: CliPanelControlledState): void;
|
|
3793
|
+
/** Element containing the terminals, used for theme sync. */
|
|
3794
|
+
setRootElement(element: ParentNode | null): void;
|
|
3795
|
+
/**
|
|
3796
|
+
* Stop timers, observers and document listeners. Engines are not
|
|
3797
|
+
* destroyed (their views own them). Registering an engine again
|
|
3798
|
+
* restarts status tracking, so a remounted view can reuse the controller.
|
|
3799
|
+
*/
|
|
3800
|
+
destroy(): void;
|
|
3801
|
+
/** Header collapse button: expand (creating the first tab) or collapse. */
|
|
3802
|
+
toggle(): void;
|
|
3803
|
+
open(): void;
|
|
3804
|
+
collapse(): void;
|
|
3805
|
+
toggleCollapse(): void;
|
|
3806
|
+
hide(): void;
|
|
3807
|
+
unhide(): void;
|
|
3808
|
+
toggleHide(): void;
|
|
3809
|
+
close(): void;
|
|
3810
|
+
maximize(): void;
|
|
3811
|
+
restore(): void;
|
|
3812
|
+
toggleMaximize(): void;
|
|
3813
|
+
resize(dimensions: {
|
|
3814
|
+
height?: number;
|
|
3815
|
+
width?: number;
|
|
3816
|
+
}): void;
|
|
3817
|
+
setPosition(position: CliPanelPosition): void;
|
|
3818
|
+
addTab(title?: string): number;
|
|
3819
|
+
closeTab(tabId: number): void;
|
|
3820
|
+
selectTab(tabId: number): void;
|
|
3821
|
+
renameTab(tabId: number, title: string): void;
|
|
3822
|
+
/** Switch a tab's title into inline editing. */
|
|
3823
|
+
startRename(tabId: number): void;
|
|
3824
|
+
/** Finish inline editing; an empty value keeps the old title. */
|
|
3825
|
+
commitRename(tabId: number, value: string): void;
|
|
3826
|
+
cancelRename(): void;
|
|
3827
|
+
/** Open a new tab next to `tabId` with a copy of its first terminal's content. */
|
|
3828
|
+
duplicateTab(tabId: number): number;
|
|
3829
|
+
closeOtherTabs(tabId: number): void;
|
|
3830
|
+
closeTabsToTheRight(tabId: number): void;
|
|
3831
|
+
closeAllTabs(): void;
|
|
3832
|
+
splitPane(tabId?: number): number;
|
|
3833
|
+
closePane(paneId: number): void;
|
|
3834
|
+
/** A pane was clicked: make it (and its tab) active and focus its terminal. */
|
|
3835
|
+
activatePane(tabId: number, paneId: number): void;
|
|
3836
|
+
/** Called by the view once a pane's terminal engine is running. */
|
|
3837
|
+
registerEngine(tabId: number, paneId: number, engine: CliEngine): void;
|
|
3838
|
+
getEngine(paneId?: number): CliEngine | undefined;
|
|
3839
|
+
getState(): CliPanelState;
|
|
3840
|
+
openContextMenu(tabId: number, x: number, y: number): void;
|
|
3841
|
+
closeContextMenu(): void;
|
|
3842
|
+
togglePositionDropdown(): void;
|
|
3843
|
+
/** `anchor` is the clicked status item; the dropdown is placed next to it. */
|
|
3844
|
+
toggleServicesDropdown(anchor?: Element | null): void;
|
|
3845
|
+
toggleServersDropdown(anchor?: Element | null): void;
|
|
3846
|
+
/** Close the context menu and every dropdown. */
|
|
3847
|
+
closeMenus(): void;
|
|
3848
|
+
/** Mouse down on the panel's resize bar. */
|
|
3849
|
+
startPanelResize(clientX: number, clientY: number): void;
|
|
3850
|
+
/** Mouse down on the divider before pane `dividerIndex + 1` of a tab. */
|
|
3851
|
+
startPaneResize(tabId: number, dividerIndex: number, clientX: number, containerWidth: number): void;
|
|
3852
|
+
private readonly onPanelResizeMove;
|
|
3853
|
+
private readonly onPanelResizeEnd;
|
|
3854
|
+
private endPanelResize;
|
|
3855
|
+
private readonly onPaneResizeMove;
|
|
3856
|
+
private readonly onPaneResizeEnd;
|
|
3857
|
+
private endPaneResize;
|
|
3858
|
+
private readonly onDocumentClick;
|
|
3859
|
+
private readonly onDocumentKeydown;
|
|
3860
|
+
private syncDocumentListeners;
|
|
3861
|
+
private detachDocumentListeners;
|
|
3862
|
+
/** Read the first terminal's theme and derive the panel colours from it. */
|
|
3863
|
+
syncThemeFromEngine(): void;
|
|
3864
|
+
/**
|
|
3865
|
+
* Sync now and follow the first terminal's container: the `theme`
|
|
3866
|
+
* command restyles it, which re-derives the panel colours.
|
|
3867
|
+
* Engines are registered after they start, so their theme is set.
|
|
3868
|
+
*/
|
|
3869
|
+
private startThemeSync;
|
|
3870
|
+
private stopThemeSync;
|
|
3871
|
+
private ensureInitialized;
|
|
3872
|
+
private updateCollapsed;
|
|
3873
|
+
private updateHidden;
|
|
3874
|
+
private updateMaximized;
|
|
3875
|
+
private updateHeight;
|
|
3876
|
+
private updateWidth;
|
|
3877
|
+
private updateActiveTabId;
|
|
3878
|
+
private findTab;
|
|
3879
|
+
private patchTab;
|
|
3880
|
+
/** Remove tabs without touching collapsed/initialized state. */
|
|
3881
|
+
private removeTabs;
|
|
3882
|
+
private releaseTab;
|
|
3883
|
+
private releasePane;
|
|
3884
|
+
private focusPane;
|
|
3885
|
+
private anchorStyle;
|
|
3886
|
+
private setTabStatus;
|
|
3887
|
+
private configFields;
|
|
3888
|
+
/** Resolve controlled values and derived fields on top of a snapshot. */
|
|
3889
|
+
private derive;
|
|
3890
|
+
private commit;
|
|
3891
|
+
}
|
|
3892
|
+
|
|
3893
|
+
/**
|
|
3894
|
+
* Geometry of the panel's SVG icons, shared by every framework wrapper.
|
|
3895
|
+
* All icons use a 24x24 view box, `stroke="currentColor"`, round caps and
|
|
3896
|
+
* joins, and no fill unless a shape says otherwise.
|
|
3897
|
+
*/
|
|
3898
|
+
interface SvgShape {
|
|
3899
|
+
tag: 'polyline' | 'line' | 'rect';
|
|
3900
|
+
attrs: Record<string, string>;
|
|
3901
|
+
}
|
|
3902
|
+
interface SvgIcon {
|
|
3903
|
+
size: number;
|
|
3904
|
+
strokeWidth: number;
|
|
3905
|
+
shapes: SvgShape[];
|
|
3906
|
+
}
|
|
3907
|
+
declare const SVG_VIEW_BOX = "0 0 24 24";
|
|
3908
|
+
declare const SVG_COMMON_ATTRS: Record<string, string>;
|
|
3909
|
+
declare const TERMINAL_ICON: SvgIcon;
|
|
3910
|
+
declare const HIDE_TAB_TERMINAL_ICON: SvgIcon;
|
|
3911
|
+
declare const MAXIMIZE_ICON: SvgIcon;
|
|
3912
|
+
declare const RESTORE_ICON: SvgIcon;
|
|
3913
|
+
declare const CLOSE_ICON: SvgIcon;
|
|
3914
|
+
declare const HIDE_ICON: SvgIcon;
|
|
3915
|
+
/** Chevron that points where the panel body will go when the collapse button is pressed. */
|
|
3916
|
+
declare function collapseChevronIcon(position: CliPanelPosition, collapsed: boolean): SvgIcon;
|
|
3917
|
+
/** Chevron on the small "show CLI" tab, pointing into the page. */
|
|
3918
|
+
declare function hideTabChevronIcon(position: CliPanelPosition): SvgIcon;
|
|
3919
|
+
/** Square with a filled bar on the side the panel is docked to. */
|
|
3920
|
+
declare function positionIcon(position: CliPanelPosition, size?: number): SvgIcon;
|
|
3921
|
+
/** Attributes for the `<svg>` element of an icon. */
|
|
3922
|
+
declare function svgAttrs(icon: SvgIcon): Record<string, string>;
|
|
3923
|
+
|
|
3924
|
+
/**
|
|
3925
|
+
* View helpers shared by the React, Vue and Angular panels: class names,
|
|
3926
|
+
* inline styles, labels and the lists the header and menus are built from.
|
|
3927
|
+
*/
|
|
3928
|
+
declare const PANEL_LABELS: {
|
|
3929
|
+
readonly title: "CLI";
|
|
3930
|
+
readonly showCli: "Show CLI";
|
|
3931
|
+
readonly movePanel: "Move panel";
|
|
3932
|
+
readonly hide: "Hide";
|
|
3933
|
+
readonly maximize: "Maximize";
|
|
3934
|
+
readonly restore: "Restore";
|
|
3935
|
+
readonly expand: "Expand";
|
|
3936
|
+
readonly collapse: "Collapse";
|
|
3937
|
+
readonly close: "Close";
|
|
3938
|
+
readonly newTerminal: "New terminal";
|
|
3939
|
+
readonly closeTab: "Close tab";
|
|
3940
|
+
readonly closePane: "Close pane";
|
|
3941
|
+
readonly servicesHeader: "Background Services";
|
|
3942
|
+
readonly servicesEmpty: "No services registered";
|
|
3943
|
+
readonly serversHeader: "Server Connections";
|
|
3944
|
+
readonly serversEmpty: "No servers configured";
|
|
3945
|
+
};
|
|
3946
|
+
declare const SERVICES_ICON = "\u2699";
|
|
3947
|
+
declare const UPTIME_ICON = "\u2191";
|
|
3948
|
+
declare const SUCCESS_ICON = "\u2713";
|
|
3949
|
+
declare const ERROR_ICON = "\u2717";
|
|
3950
|
+
declare const CLOSE_GLYPH = "\u00D7";
|
|
3951
|
+
declare function capitalize(value: string): string;
|
|
3952
|
+
declare function joinClasses(...classes: Array<string | false | null | undefined>): string;
|
|
3953
|
+
declare function panelWrapperClass(s: CliPanelSnapshot, extra?: string): string;
|
|
3954
|
+
declare function panelTabClass(s: CliPanelSnapshot, tab: CliPanelTab): string;
|
|
3955
|
+
/** Activity dot of a tab: running, last command failed, or idle. */
|
|
3956
|
+
declare function tabDotClass(status: CliPanelTabStatus | undefined): string;
|
|
3957
|
+
declare function panelTabDotClass(s: CliPanelSnapshot, tab: CliPanelTab): string;
|
|
3958
|
+
declare function panesContainerClass(s: CliPanelSnapshot): string;
|
|
3959
|
+
declare function paneClass(s: CliPanelSnapshot, tabId: number, paneId: number): string;
|
|
3960
|
+
declare function glowLineClass(s: CliPanelSnapshot): string;
|
|
3961
|
+
declare function positionDropdownItemClass(s: CliPanelSnapshot, position: CliPanelPosition): string;
|
|
3962
|
+
/** Size, visibility and theme variables of the panel wrapper. */
|
|
3963
|
+
declare function panelWrapperStyle(s: CliPanelSnapshot): Record<string, string>;
|
|
3964
|
+
declare function paneStyle(widthPercent: number): Record<string, string>;
|
|
3965
|
+
declare function contextMenuStyle(s: CliPanelSnapshot): Record<string, string>;
|
|
3966
|
+
interface PanelStatusIndicator {
|
|
3967
|
+
key: 'execution' | 'services' | 'lastCommand' | 'servers' | 'uptime' | 'notification';
|
|
3968
|
+
/** Extra classes on the full item (top/bottom positions). */
|
|
3969
|
+
itemClass: string;
|
|
3970
|
+
/** Extra classes on the compact item (left/right positions). */
|
|
3971
|
+
compactClass: string;
|
|
3972
|
+
/** Class of the leading dot, when the indicator shows a dot. */
|
|
3973
|
+
dotClass?: string;
|
|
3974
|
+
/** Glyph shown before the label, when the indicator shows an icon. */
|
|
3975
|
+
icon?: string;
|
|
3976
|
+
iconClass?: string;
|
|
3977
|
+
label: string;
|
|
3978
|
+
/** Tooltip of the compact variant. */
|
|
3979
|
+
title: string;
|
|
3980
|
+
/** Compact variant shows only this dot (notifications). */
|
|
3981
|
+
compactDotClass?: string;
|
|
3982
|
+
/** Which dropdown a click opens. */
|
|
3983
|
+
dropdown?: 'services' | 'servers';
|
|
3984
|
+
}
|
|
3985
|
+
/** Items of the header status bar, in display order. */
|
|
3986
|
+
declare function statusIndicators(s: CliPanelSnapshot): PanelStatusIndicator[];
|
|
3987
|
+
interface PanelPositionOption {
|
|
3988
|
+
position: CliPanelPosition;
|
|
3989
|
+
label: string;
|
|
3990
|
+
className: string;
|
|
3991
|
+
}
|
|
3992
|
+
declare function positionOptions(s: CliPanelSnapshot): PanelPositionOption[];
|
|
3993
|
+
type PanelContextMenuAction = 'rename' | 'duplicate' | 'split-right' | 'close' | 'close-others' | 'close-right' | 'close-all';
|
|
3994
|
+
interface PanelContextMenuItem {
|
|
3995
|
+
action: PanelContextMenuAction;
|
|
3996
|
+
label: string;
|
|
3997
|
+
disabled: boolean;
|
|
3998
|
+
destructive: boolean;
|
|
3999
|
+
/** Draw a separator above this item. */
|
|
4000
|
+
separatorBefore: boolean;
|
|
4001
|
+
}
|
|
4002
|
+
declare function contextMenuItems(s: CliPanelSnapshot): PanelContextMenuItem[];
|
|
4003
|
+
/** Run a context-menu action against the tab the menu was opened for. */
|
|
4004
|
+
declare function runContextMenuAction(controller: CliPanelController, action: PanelContextMenuAction): void;
|
|
4005
|
+
/** Enter commits, Escape cancels an inline tab rename. */
|
|
4006
|
+
declare function handleRenameKey(controller: CliPanelController, tabId: number, key: string, value: string): void;
|
|
4007
|
+
/** Width of the panes container the divider belongs to, for drag math. */
|
|
4008
|
+
declare function panesContainerWidth(target: EventTarget | null): number;
|
|
4009
|
+
interface PanelDropdownRow {
|
|
4010
|
+
key: string;
|
|
4011
|
+
dotClass: string;
|
|
4012
|
+
name: string;
|
|
4013
|
+
description?: string;
|
|
4014
|
+
status: string;
|
|
4015
|
+
/** Extra lines under the status (servers: API version, command count). */
|
|
4016
|
+
meta: string[];
|
|
4017
|
+
}
|
|
4018
|
+
interface PanelStatusDropdown {
|
|
4019
|
+
kind: 'services' | 'servers';
|
|
4020
|
+
header: string;
|
|
4021
|
+
emptyText: string;
|
|
4022
|
+
style: Record<string, string>;
|
|
4023
|
+
rows: PanelDropdownRow[];
|
|
4024
|
+
}
|
|
4025
|
+
/** The open services or servers dropdown, or null when neither is open. */
|
|
4026
|
+
declare function openStatusDropdown(s: CliPanelSnapshot): PanelStatusDropdown | null;
|
|
4027
|
+
|
|
4028
|
+
export { API_VERSION, CLI_ENV_GLOBAL_PERMISSION, CLI_FRAMEWORK_SERVICE, CLOSE_GLYPH, CLOSE_ICON, CapturingTerminalWriter, CliAliasCommandProcessor, CliArgsParser, CliBackgroundServiceRegistry_TOKEN, CliBoot, CliBootLog, CliBootLog_TOKEN, CliCalCommandProcessor, CliCaptureCommandProcessor, CliClearCommandProcessor, CliClipboard, CliClipboardCommandProcessor, CliColorCommandProcessor, CliCommandExecutionContext, CliCommandExecutor, CliCommandHistory, CliCommandHistory_TOKEN, CliCommandProcessorRegistry, CliConfigureCommandProcessor, CliConvertCommandProcessor, CliDebugCommandProcessor, CliDefaultPingServerService, CliDiffCommandProcessor, CliDragDropService, CliEchoCommandProcessor, CliEngine, CliEnvCommandProcessor, CliEnvironment, CliEvalCommandProcessor, CliEventsCommandProcessor, CliExecutionContext, CliExecutionProcess, CliExportCommandProcessor, CliFalseCommandProcessor, CliFeedbackCommandProcessor, CliFontSizeCommandProcessor, CliFullScreenManager, CliHelpCommandProcessor, CliHistoryCommandProcessor, CliHotKeysCommandProcessor, CliHtopCommandProcessor, CliHttpClient, CliInputReader, CliJsonCommandProcessor, CliKeyValueStore, CliKeyValueStore_TOKEN, CliKillCommandProcessor, CliLogger, CliLoremCommandProcessor, CliModuleRegistry_TOKEN, CliNanoCommandProcessor, CliNotifier, CliOpenCommandProcessor, CliPackageManagerService, CliPackageManagerService_TOKEN, CliPackagesCommandProcessor, CliPanelController, CliPanelStatusTracker, CliPermissionRegistry, CliPingCommandProcessor, CliProcessRegistry, CliProcessRegistry_TOKEN, CliProcessorsRegistry_TOKEN, CliPsCommandProcessor, CliRandomCommandProcessor, CliScreenCommandProcessor, CliScriptSyntaxError, CliSeqCommandProcessor, CliServerCommandProcessor, CliServerConnection, CliServerManager, CliServerManager_TOKEN, CliServerMultiProxyProcessor, CliServerProxyProcessor, CliServiceContainer, CliServicesCommandProcessor, CliSleepCommandProcessor, CliSnippetCommandProcessor, CliSshCommandProcessor, CliStateStore, CliStateStoreManager, CliStateStoreManager_TOKEN, CliTerminalProgressBar, CliTerminalSpinner, CliTerminalTextAnimator, CliTerminalWriter, CliTestCommandProcessor, CliTestHarness, CliThemeCommandProcessor, CliTimeCommandProcessor, CliTimerManager, CliTimestampCommandProcessor, CliTrueCommandProcessor, CliUnAliasCommandProcessor, CliUnameCommandProcessor, CliUnsetCommandProcessor, CliUptimeCommandProcessor, CliVersionCommandProcessor, CliYesCommandProcessor, CommandParser, DEFAULT_GLOBAL_STATUS, DEFAULT_PANEL_HEIGHT, DEFAULT_PANEL_WIDTH, DEFAULT_TAB_STATUS, ERROR_ICON, EXEC_POLL_MS, GLOBAL_POLL_MS, HIDE_ICON, HIDE_TAB_TERMINAL_ICON, ICliEnvironment_TOKEN, ICliPingServerService_TOKEN, ICliScriptRunner_TOKEN, JsFallbackAccelerator, LIBRARY_VERSION, MAXIMIZE_ICON, MIN_PANEL_SIZE, MIN_PANE_WIDTH_PERCENT, OverlayAddon, PANEL_LABELS, PANEL_POSITIONS, ProcessExitedError, RESTORE_ICON, SERVICES_ICON, SUCCESS_ICON, SVG_COMMON_ATTRS, SVG_VIEW_BOX, ScriptLoaderService, SyntaxHighlighterRegistry_TOKEN, TERMINAL_ICON, UPTIME_ICON, appendOutputToFile, appendStderrToFile, applyEnvironmentChange, builtinProcessors, capitalize, clampPanelSize, cliScriptRunner, collapseChevronIcon, computeDiff, computeGlobalStatus, computeTabStatus, contextGlobalParameter, contextMenuItems, contextMenuStyle, createCliEngine, createServerModule, defaultFontSize, describeShellClose, distributePaneWidths, dropdownAnchorStyle, executeOnServer, expandBraces, expandEnvironmentVars, expandGlobs, formatDiff, formatUptime, getAccelerator, getCliNameArt, getGreetingBasedOnTime, getTerminalOptions, glowLineClass, greetingModule, groupBy, handleRenameKey, helpGlobalParameter, hideTabChevronIcon, hotkeysInfo, initWasmAccelerator, initializeServices, initializeTerminal, isHorizontalPosition, isWasmAccelerated, joinClasses, matchGlob, mergeCliOptions, miscProcessors, normalizePaneWidths, openLink, openStatusDropdown, paneClass, paneStyle, panelTabClass, panelTabDotClass, panelWrapperClass, panelWrapperStyle, panesContainerClass, panesContainerWidth, parseAssignments, parseScript, positionDropdownItemClass, positionIcon, positionOptions, reconcileArgs, renderServerResponse, renderSingleOutput, resizePaneWidths, resizedPanelSize, resolveCliHostConfig, runContextMenuAction, runScript, splitWords, statusIndicators, substituteCommands, substituteVars, svgAttrs, systemProcessors, tabDotClass, themeInfos, themes, tryExecuteScript, versionGlobalParameter, waitForLayout, welcomeModule, writeOutputToFile, writeStderrToFile };
|
|
4029
|
+
export type { AnchorRect, CdnSourceName, CliBootLogOptions, CliEngineOptions, CliEnvironmentChange, CliEnvironmentProfile, CliEnvironmentScope, CliEnvironmentSnapshot, CliEnvironmentSource, CliExecutionContextDeps, CliHostConfig, CliPanelCallbacks, CliPanelContextMenu, CliPanelControlledState, CliPanelControllerOptions, CliPanelExecutionState, CliPanelGlobalStatus, CliPanelPane, CliPanelServerDetail, CliPanelServerState, CliPanelServiceDetail, CliPanelSnapshot, CliPanelStatusTrackerListener, CliPanelTab, CliPanelTabStatus, CliPanelViewport, CliTestResult, CliWelcomeMessageConfig, CommandParserOutput, CommandPart, ConfigureState, CreateCliEngineConfig, DefaultServerProvider, DiffLine, DiffType, ICliEnvironment, ICliExecutionHost, ICliScriptRunOptions, ICliScriptRunner, ICliStateStoreManager, ICliWasmAccelerator, InitializeServicesOptions, InitializeServicesResult, MultiProxyEntry, PanelContextMenuAction, PanelContextMenuItem, PanelDropdownRow, PanelPositionOption, PanelStatusDropdown, PanelStatusIndicator, ParsedArg, ParsedToken, SvgIcon, SvgShape, TerminalSetupResult, ThemeState };
|