@qodalis/cli 2.0.0-beta.9 → 2.0.0-rc.1
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 +227 -19
- package/assets/cli-panel.css +406 -0
- package/assets/styles.css +8 -0
- package/package.json +6 -6
- package/public-api.d.mts +2058 -341
- package/public-api.d.ts +2058 -341
- package/public-api.js +13080 -6227
- package/public-api.js.map +1 -1
- package/public-api.mjs +13339 -6589
- package/public-api.mjs.map +1 -1
- package/wasm/qodalis_cli_wasm_bg.wasm +0 -0
package/public-api.d.ts
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.1";
|
|
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,19 @@ 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
|
+
private extractPositionalValue;
|
|
1613
|
+
private guardDenial;
|
|
1309
1614
|
private processorOwnsParameter;
|
|
1310
1615
|
}
|
|
1311
1616
|
|
|
@@ -1323,81 +1628,55 @@ declare const helpGlobalParameter: ICliGlobalParameterHandler;
|
|
|
1323
1628
|
declare const contextGlobalParameter: ICliGlobalParameterHandler;
|
|
1324
1629
|
|
|
1325
1630
|
/**
|
|
1326
|
-
* A
|
|
1631
|
+
* A terminal writer wrapper that captures "stdout-equivalent" output
|
|
1632
|
+
* (`write`, `writeln`, `writeJson`, `writeObjectsAsTable`, `writeTable`)
|
|
1633
|
+
* while passing everything through to the underlying writer unchanged.
|
|
1327
1634
|
*
|
|
1328
|
-
*
|
|
1329
|
-
*
|
|
1330
|
-
* - `useFactory` : registers a factory function, invoked once on first `get`
|
|
1331
|
-
* - `useClass` : registers a class constructor, instantiated once on first `get`
|
|
1635
|
+
* Diagnostic methods (`writeError`, `writeWarning`, `writeInfo`, `writeSuccess`)
|
|
1636
|
+
* are NOT captured — they are the equivalent of stderr.
|
|
1332
1637
|
*
|
|
1333
|
-
*
|
|
1334
|
-
*
|
|
1638
|
+
* After a command finishes, the executor can retrieve the captured data to use
|
|
1639
|
+
* as implicit pipeline output when the command did not call `process.output()`.
|
|
1640
|
+
*
|
|
1641
|
+
* `muted` (output going into a pipe or a file) captures stdout-equivalent
|
|
1642
|
+
* output without showing it; diagnostics are still shown.
|
|
1335
1643
|
*/
|
|
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);
|
|
1644
|
+
declare class CapturingTerminalWriter implements ICliTerminalWriter {
|
|
1645
|
+
private readonly inner;
|
|
1646
|
+
/** Raw text lines captured from write/writeln calls. */
|
|
1647
|
+
private _lines;
|
|
1648
|
+
/** Structured data captured from writeJson calls. */
|
|
1649
|
+
private _jsonValues;
|
|
1650
|
+
/** Structured data captured from writeObjectsAsTable calls. */
|
|
1651
|
+
private _tableObjects;
|
|
1652
|
+
/** Raw text lines captured from writeError/writeWarning calls. */
|
|
1653
|
+
private _stderrLines;
|
|
1654
|
+
/** Number of writeError calls (warnings excluded). */
|
|
1655
|
+
private _errorCount;
|
|
1656
|
+
private readonly muted;
|
|
1657
|
+
constructor(inner: ICliTerminalWriter, options?: {
|
|
1658
|
+
muted?: boolean;
|
|
1659
|
+
});
|
|
1660
|
+
/** Show stdout-equivalent output unless muted. */
|
|
1661
|
+
private show;
|
|
1662
|
+
private captureText;
|
|
1384
1663
|
write(text: string): void;
|
|
1385
1664
|
writeln(text?: string): void;
|
|
1665
|
+
writeJson(json: any): void;
|
|
1666
|
+
writeObjectsAsTable(objects: any[]): void;
|
|
1667
|
+
writeTable(headers: string[], rows: string[][]): void;
|
|
1386
1668
|
writeSuccess(message: string): void;
|
|
1387
1669
|
writeInfo(message: string): void;
|
|
1388
1670
|
writeWarning(message: string): void;
|
|
1389
1671
|
writeError(message: string): void;
|
|
1390
|
-
|
|
1672
|
+
wrapInColor(text: string, color: CliForegroundColor): string;
|
|
1673
|
+
wrapInBackgroundColor(text: string, color: CliBackgroundColor): string;
|
|
1674
|
+
writeToFile(fileName: string, content: string): void;
|
|
1391
1675
|
writeDivider(options?: {
|
|
1392
1676
|
color?: CliForegroundColor;
|
|
1393
1677
|
length?: number;
|
|
1394
1678
|
char?: string;
|
|
1395
1679
|
}): 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
1680
|
writeList(items: string[], options?: {
|
|
1402
1681
|
ordered?: boolean;
|
|
1403
1682
|
prefix?: string;
|
|
@@ -1418,18 +1697,384 @@ declare class CliTerminalWriter implements ICliTerminalWriter {
|
|
|
1418
1697
|
padding?: number;
|
|
1419
1698
|
}): void;
|
|
1420
1699
|
writeIndented(text: string, level?: number): void;
|
|
1421
|
-
|
|
1700
|
+
/**
|
|
1701
|
+
* Returns true if any stdout-equivalent output was captured.
|
|
1702
|
+
*/
|
|
1703
|
+
hasOutput(): boolean;
|
|
1704
|
+
/**
|
|
1705
|
+
* Returns the captured data in the most useful form:
|
|
1706
|
+
*
|
|
1707
|
+
* 1. If structured JSON was written (via `writeJson`), return the last
|
|
1708
|
+
* JSON value (preserving its original type — object, array, etc.).
|
|
1709
|
+
* 2. If objects were written as a table, return the last array of objects.
|
|
1710
|
+
* 3. Otherwise return the captured text lines joined with newlines,
|
|
1711
|
+
* with ANSI codes stripped and whitespace trimmed.
|
|
1712
|
+
* 4. Returns `undefined` if nothing was captured.
|
|
1713
|
+
*/
|
|
1714
|
+
getCapturedData(): any | undefined;
|
|
1715
|
+
/** Whether the command wrote an error message itself. */
|
|
1716
|
+
hasErrors(): boolean;
|
|
1717
|
+
/**
|
|
1718
|
+
* Returns true if any stderr-equivalent output was captured.
|
|
1719
|
+
*/
|
|
1720
|
+
hasStderr(): boolean;
|
|
1721
|
+
/**
|
|
1722
|
+
* Returns captured stderr text joined with newlines, or undefined if empty.
|
|
1723
|
+
*/
|
|
1724
|
+
getCapturedStderr(): string | undefined;
|
|
1422
1725
|
}
|
|
1423
1726
|
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1727
|
+
/**
|
|
1728
|
+
* Write stdout data to a file (overwrite mode).
|
|
1729
|
+
*/
|
|
1730
|
+
declare function writeOutputToFile(filePath: string, context: ICliExecutionContext): Promise<void>;
|
|
1731
|
+
/**
|
|
1732
|
+
* Append stdout data to a file.
|
|
1733
|
+
*/
|
|
1734
|
+
declare function appendOutputToFile(filePath: string, context: ICliExecutionContext): Promise<void>;
|
|
1735
|
+
/**
|
|
1736
|
+
* Write stderr data to a file (overwrite mode).
|
|
1737
|
+
*/
|
|
1738
|
+
declare function writeStderrToFile(filePath: string, context: ICliExecutionContext, capturingWriter?: CapturingTerminalWriter): Promise<void>;
|
|
1739
|
+
/**
|
|
1740
|
+
* Append stderr data to a file.
|
|
1741
|
+
*/
|
|
1742
|
+
declare function appendStderrToFile(filePath: string, context: ICliExecutionContext, capturingWriter?: CapturingTerminalWriter): Promise<void>;
|
|
1430
1743
|
|
|
1431
|
-
|
|
1432
|
-
|
|
1744
|
+
/**
|
|
1745
|
+
* Attempt to execute a file path as a script.
|
|
1746
|
+
* Returns true if the file was found and executed, false otherwise.
|
|
1747
|
+
* Requires the @qodalis/cli-files plugin for filesystem access.
|
|
1748
|
+
*/
|
|
1749
|
+
declare function tryExecuteScript(filePath: string, context: ICliExecutionHost, executeCommand: (command: string, context: ICliExecutionContext) => Promise<void>): Promise<boolean>;
|
|
1750
|
+
/**
|
|
1751
|
+
* Substitute script-local variables ($VAR / ${VAR}) in a string.
|
|
1752
|
+
*/
|
|
1753
|
+
declare function substituteVars(input: string, variables: Record<string, string>): string;
|
|
1754
|
+
/**
|
|
1755
|
+
* Expand `$VAR` and `${VAR}` references using the global environment store, `$?`
|
|
1756
|
+
* to the last exit status, and a leading `~` (alone or as `~/…`) to `$HOME`.
|
|
1757
|
+
* Nothing is expanded inside single-quoted strings (like bash).
|
|
1758
|
+
*/
|
|
1759
|
+
declare function expandEnvironmentVars(command: string, context: ICliExecutionContext, lastExitCode?: number): string;
|
|
1760
|
+
|
|
1761
|
+
/**
|
|
1762
|
+
* Shell-style script runner shared by `sh <file>` / `source` (files plugin)
|
|
1763
|
+
* and `./script.sh` (the executor).
|
|
1764
|
+
*
|
|
1765
|
+
* Supported (a POSIX sh subset):
|
|
1766
|
+
* - one command per line or several separated by `;` (pipes, `&&`, `||`
|
|
1767
|
+
* and redirects are left to the executor)
|
|
1768
|
+
* - `# comments`, blank lines, `\` line continuation
|
|
1769
|
+
* - `set -e` (default) / `set +e`, `VAR=value` (script-scoped), `exit [n]`
|
|
1770
|
+
* - `if cmd; then ...; elif cmd; then ...; else ...; fi`
|
|
1771
|
+
* - `for NAME in words...; do ...; done` (words after `$VAR` and wildcard
|
|
1772
|
+
* expansion; NAME is set for this terminal)
|
|
1773
|
+
* - `while cmd; do ...; done`, `until cmd; do ...; done`
|
|
1774
|
+
* - `break [n]`, `continue [n]`, `! cmd` (negated status)
|
|
1775
|
+
*
|
|
1776
|
+
* Every simple command runs through the executor; its status is
|
|
1777
|
+
* `context.process.exitCode` (0 or undefined = success).
|
|
1778
|
+
*/
|
|
1779
|
+
/** Service token under which the engine provides the runner (for plugins). */
|
|
1780
|
+
declare const ICliScriptRunner_TOKEN: any;
|
|
1781
|
+
interface ICliScriptRunOptions {
|
|
1782
|
+
/** Prefix for error messages (`sh: line 4: ...`). Default `sh`. */
|
|
1783
|
+
name?: string;
|
|
1784
|
+
/** Runs one command line. Default `context.executor.executeCommand`. */
|
|
1785
|
+
executeCommand?: (command: string, context: ICliExecutionContext) => Promise<void>;
|
|
1786
|
+
/** Loop iterations allowed before a `while`/`until` is stopped. Default 10000. */
|
|
1787
|
+
maxLoopIterations?: number;
|
|
1788
|
+
/** Stop at the first failing command (`set -e`). Default true; false for typed lines. */
|
|
1789
|
+
stopOnError?: boolean;
|
|
1790
|
+
}
|
|
1791
|
+
interface ICliScriptRunner {
|
|
1792
|
+
/** Run script `content`; resolves to its exit status. */
|
|
1793
|
+
run(content: string, context: ICliExecutionContext, options?: ICliScriptRunOptions): Promise<number>;
|
|
1794
|
+
}
|
|
1795
|
+
/** The runner as a service value. */
|
|
1796
|
+
declare const cliScriptRunner: ICliScriptRunner;
|
|
1797
|
+
interface CommandNode {
|
|
1798
|
+
type: 'command';
|
|
1799
|
+
text: string;
|
|
1800
|
+
line: number;
|
|
1801
|
+
negate: boolean;
|
|
1802
|
+
}
|
|
1803
|
+
interface IfNode {
|
|
1804
|
+
type: 'if';
|
|
1805
|
+
line: number;
|
|
1806
|
+
branches: {
|
|
1807
|
+
condition: ScriptNode[];
|
|
1808
|
+
body: ScriptNode[];
|
|
1809
|
+
}[];
|
|
1810
|
+
elseBody?: ScriptNode[];
|
|
1811
|
+
}
|
|
1812
|
+
interface ForNode {
|
|
1813
|
+
type: 'for';
|
|
1814
|
+
line: number;
|
|
1815
|
+
name: string;
|
|
1816
|
+
words: string;
|
|
1817
|
+
body: ScriptNode[];
|
|
1818
|
+
}
|
|
1819
|
+
interface WhileNode {
|
|
1820
|
+
type: 'while';
|
|
1821
|
+
line: number;
|
|
1822
|
+
until: boolean;
|
|
1823
|
+
condition: ScriptNode[];
|
|
1824
|
+
body: ScriptNode[];
|
|
1825
|
+
}
|
|
1826
|
+
type ScriptNode = CommandNode | IfNode | ForNode | WhileNode;
|
|
1827
|
+
/** A syntax error found while parsing. */
|
|
1828
|
+
declare class CliScriptSyntaxError extends Error {
|
|
1829
|
+
readonly line: number;
|
|
1830
|
+
readonly detail: string;
|
|
1831
|
+
constructor(line: number, detail: string);
|
|
1832
|
+
}
|
|
1833
|
+
/** Parse script content (throws {@link CliScriptSyntaxError}). */
|
|
1834
|
+
declare function parseScript(content: string): ScriptNode[];
|
|
1835
|
+
/** Split a line into words, removing quotes (empty quoted words are kept). */
|
|
1836
|
+
declare function splitWords(text: string): string[];
|
|
1837
|
+
/**
|
|
1838
|
+
* Run script content with shell control flow. Resolves to the exit status
|
|
1839
|
+
* (also set as the context's process exit code).
|
|
1840
|
+
*/
|
|
1841
|
+
declare function runScript(content: string, context: ICliExecutionContext, options?: ICliScriptRunOptions): Promise<number>;
|
|
1842
|
+
|
|
1843
|
+
/** The file system calls glob expansion needs (`@qodalis/cli-files`). */
|
|
1844
|
+
interface GlobFileSystem {
|
|
1845
|
+
getCurrentDirectory(): string;
|
|
1846
|
+
resolvePath(path: string): string;
|
|
1847
|
+
listDirectory(path: string): {
|
|
1848
|
+
name: string;
|
|
1849
|
+
type: 'file' | 'directory';
|
|
1850
|
+
}[];
|
|
1851
|
+
exists(path: string): boolean;
|
|
1852
|
+
isDirectory(path: string): boolean;
|
|
1853
|
+
}
|
|
1854
|
+
/**
|
|
1855
|
+
* Expand `*`, `?` and `[...]` in unquoted arguments to the matching paths,
|
|
1856
|
+
* as a shell does: `rm *.txt`, `cat docs/*.md`. The command name and flags
|
|
1857
|
+
* are left alone, names starting with `.` match only a pattern that starts
|
|
1858
|
+
* with `.`, and a pattern that matches nothing is kept as typed.
|
|
1859
|
+
* Without the files plugin the command is returned unchanged.
|
|
1860
|
+
*/
|
|
1861
|
+
declare function expandGlobs(command: string, context: ICliExecutionContext): string;
|
|
1862
|
+
/** Paths matching `pattern`, sorted, relative when the pattern is. */
|
|
1863
|
+
declare function matchGlob(fs: GlobFileSystem, pattern: string): string[];
|
|
1864
|
+
/**
|
|
1865
|
+
* Brace expansion, as a shell does before wildcards: `file.{ts,js}` is
|
|
1866
|
+
* `file.ts file.js`, `img{1..3}.png` is `img1.png img2.png img3.png`
|
|
1867
|
+
* (letters too: `{a..c}`). Only unquoted words with a `,` or `..` inside
|
|
1868
|
+
* balanced braces; `${VAR}` and quoted text are left alone. Works without
|
|
1869
|
+
* the files plugin.
|
|
1870
|
+
*/
|
|
1871
|
+
declare function expandBraces(command: string): string;
|
|
1872
|
+
|
|
1873
|
+
/**
|
|
1874
|
+
* Replace `$(command)` and `` `command` `` with the command's output, as a
|
|
1875
|
+
* shell does: `echo "Today: $(date)"`. Not inside single quotes; inside
|
|
1876
|
+
* double quotes yes. Trailing newlines of the output are removed, and the
|
|
1877
|
+
* output is escaped so it is only ever text: inside double quotes `"`, `\`,
|
|
1878
|
+
* `$` and `` ` ``; outside quotes every shell character but spaces (which
|
|
1879
|
+
* still separate words), so quotes, operators, `$`, wildcards and braces in
|
|
1880
|
+
* the output are not interpreted.
|
|
1881
|
+
*/
|
|
1882
|
+
declare function substituteCommands(command: string, run: (inner: string) => Promise<string>): Promise<string>;
|
|
1883
|
+
|
|
1884
|
+
/**
|
|
1885
|
+
* A simple Map-based service container implementing ICliServiceProvider.
|
|
1886
|
+
*
|
|
1887
|
+
* Supports three provider types:
|
|
1888
|
+
* - `useValue` : registers a static value
|
|
1889
|
+
* - `useFactory` : registers a factory function, invoked once on the first `get`
|
|
1890
|
+
* - `useClass` : registers a class constructor, instantiated once on the first `get`
|
|
1891
|
+
*
|
|
1892
|
+
* Factories and classes are created lazily, so their `deps` only have to be
|
|
1893
|
+
* registered by the time the service is first used. Add `transient: true` to
|
|
1894
|
+
* create a new instance on every `get`.
|
|
1895
|
+
*
|
|
1896
|
+
* When `multi: true`, multiple providers for the same token are accumulated
|
|
1897
|
+
* and `getAll()` returns all of them.
|
|
1898
|
+
*
|
|
1899
|
+
* Registering a single token again overrides it; removing that registration
|
|
1900
|
+
* (`remove(token, provider)`, e.g. when a module is unloaded) makes the
|
|
1901
|
+
* previous one active again.
|
|
1902
|
+
*/
|
|
1903
|
+
declare class CliServiceContainer implements ICliServiceProvider {
|
|
1904
|
+
/** Single-value registrations; the last one is active. */
|
|
1905
|
+
private readonly services;
|
|
1906
|
+
/** Multi-provider registrations, in registration order. */
|
|
1907
|
+
private readonly multiServices;
|
|
1908
|
+
/** Tokens that cannot be overwritten by subsequent `set()` calls. */
|
|
1909
|
+
private readonly sealedTokens;
|
|
1910
|
+
/** Stores provider recipes for transient tokens (re-resolved on every get). */
|
|
1911
|
+
private readonly transientRecipes;
|
|
1912
|
+
private disposed;
|
|
1913
|
+
/** Registrations being created, to report dependency cycles. */
|
|
1914
|
+
private readonly resolving;
|
|
1915
|
+
/**
|
|
1916
|
+
* Retrieve a service by its token.
|
|
1917
|
+
* Returns `undefined` when no provider is registered for the token.
|
|
1918
|
+
* For multi-provider tokens, returns the last registered value (use `getAll` for the full array).
|
|
1919
|
+
*
|
|
1920
|
+
* @param token The token used to register the service.
|
|
1921
|
+
* @returns The resolved service instance, or `undefined` if not registered.
|
|
1922
|
+
*/
|
|
1923
|
+
get<T>(token: CliToken<T>): T | undefined;
|
|
1924
|
+
get<T>(token: any): T | undefined;
|
|
1925
|
+
/**
|
|
1926
|
+
* Retrieve all registered services for a multi-provider token.
|
|
1927
|
+
* Returns an empty array when no provider is registered for the token.
|
|
1928
|
+
*
|
|
1929
|
+
* @param token The token used to register the service.
|
|
1930
|
+
* @returns Array of all resolved service instances.
|
|
1931
|
+
*/
|
|
1932
|
+
getAll<T>(token: CliToken<T>): T[];
|
|
1933
|
+
getAll<T>(token: any): T[];
|
|
1934
|
+
/**
|
|
1935
|
+
* Retrieve a service by its token, throwing if not registered.
|
|
1936
|
+
* Use this when the service is required and its absence is a programming error.
|
|
1937
|
+
* For multi-provider tokens, returns the last registered value (use `getAll` for the full array).
|
|
1938
|
+
*
|
|
1939
|
+
* @param token The token used to register the service.
|
|
1940
|
+
* @returns The resolved service instance.
|
|
1941
|
+
* @throws Error if the token has not been registered.
|
|
1942
|
+
*/
|
|
1943
|
+
getRequired<T>(token: CliToken<T>): T;
|
|
1944
|
+
getRequired<T>(token: any): T;
|
|
1945
|
+
/**
|
|
1946
|
+
* Check whether a service is registered for the given token.
|
|
1947
|
+
*/
|
|
1948
|
+
has(token: any): boolean;
|
|
1949
|
+
/**
|
|
1950
|
+
* Mark a token as sealed so it cannot be overwritten by future `set()` calls.
|
|
1951
|
+
* Only available on the concrete container — not exposed on `ICliServiceProvider`.
|
|
1952
|
+
*/
|
|
1953
|
+
seal(token: any): void;
|
|
1954
|
+
/**
|
|
1955
|
+
* Mark multiple tokens as sealed at once.
|
|
1956
|
+
*/
|
|
1957
|
+
sealAll(tokens: any[]): void;
|
|
1958
|
+
/**
|
|
1959
|
+
* Check whether a token is sealed.
|
|
1960
|
+
*/
|
|
1961
|
+
isSealed(token: any): boolean;
|
|
1962
|
+
/**
|
|
1963
|
+
* Register one or more providers.
|
|
1964
|
+
*
|
|
1965
|
+
* @param definition A single CliProvider or an array of CliProviders.
|
|
1966
|
+
*/
|
|
1967
|
+
set(definition: CliProvider | CliProvider[]): void;
|
|
1968
|
+
/**
|
|
1969
|
+
* Remove a registration. With `provider` (the provider object passed to
|
|
1970
|
+
* `set`, or the registered value), only that registration is removed: for
|
|
1971
|
+
* a single token the previous registration becomes active again, for a
|
|
1972
|
+
* multi token the others remain. Without it, every registration of the
|
|
1973
|
+
* token is removed.
|
|
1974
|
+
*
|
|
1975
|
+
* @throws Error if the token is sealed.
|
|
1976
|
+
* @returns Whether something was removed.
|
|
1977
|
+
*/
|
|
1978
|
+
remove(token: any, provider?: unknown): boolean;
|
|
1979
|
+
/**
|
|
1980
|
+
* Dispose the services the container created (`useFactory` / `useClass`)
|
|
1981
|
+
* that have a `dispose()` method. Values registered with `useValue`
|
|
1982
|
+
* belong to whoever registered them and are not disposed. Registrations
|
|
1983
|
+
* are kept, so late callbacks still find their services. Called when the
|
|
1984
|
+
* engine is destroyed; later calls do nothing.
|
|
1985
|
+
*/
|
|
1986
|
+
dispose(): void;
|
|
1987
|
+
/**
|
|
1988
|
+
* Returns all registered service tokens (single + multi providers).
|
|
1989
|
+
*/
|
|
1990
|
+
getRegisteredTokens(): string[];
|
|
1991
|
+
/**
|
|
1992
|
+
* Returns detailed info for each registered service: token name, value type, and multi flag.
|
|
1993
|
+
* Services not created yet are listed as `lazy(Name)` (listing does not create them).
|
|
1994
|
+
*/
|
|
1995
|
+
getRegisteredServiceDetails(): {
|
|
1996
|
+
token: string;
|
|
1997
|
+
type: string;
|
|
1998
|
+
multi: boolean;
|
|
1999
|
+
}[];
|
|
2000
|
+
/**
|
|
2001
|
+
* Convert a token to a human-readable string for diagnostics/errors.
|
|
2002
|
+
*/
|
|
2003
|
+
private tokenToString;
|
|
2004
|
+
private describeRegistration;
|
|
2005
|
+
/**
|
|
2006
|
+
* Describe a resolved value for diagnostic display.
|
|
2007
|
+
*/
|
|
2008
|
+
private describeValue;
|
|
2009
|
+
/** Whether `registration` is the one `provider` refers to. */
|
|
2010
|
+
private matches;
|
|
2011
|
+
/**
|
|
2012
|
+
* Register a single provider.
|
|
2013
|
+
*/
|
|
2014
|
+
private registerProvider;
|
|
2015
|
+
/** The value of a registration, created on first use. */
|
|
2016
|
+
private resolve;
|
|
2017
|
+
/**
|
|
2018
|
+
* Resolve a provider definition to a concrete value, resolving its `deps`
|
|
2019
|
+
* from the container.
|
|
2020
|
+
*/
|
|
2021
|
+
private resolveProvider;
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
declare class CliTerminalWriter implements ICliTerminalWriter {
|
|
2025
|
+
readonly terminal: Terminal;
|
|
2026
|
+
constructor(terminal: Terminal);
|
|
2027
|
+
write(text: string): void;
|
|
2028
|
+
writeln(text?: string): void;
|
|
2029
|
+
writeSuccess(message: string): void;
|
|
2030
|
+
writeInfo(message: string): void;
|
|
2031
|
+
writeWarning(message: string): void;
|
|
2032
|
+
writeError(message: string): void;
|
|
2033
|
+
private writeLog;
|
|
2034
|
+
writeDivider(options?: {
|
|
2035
|
+
color?: CliForegroundColor;
|
|
2036
|
+
length?: number;
|
|
2037
|
+
char?: string;
|
|
2038
|
+
}): void;
|
|
2039
|
+
wrapInColor(text: string, color: CliForegroundColor): string;
|
|
2040
|
+
wrapInBackgroundColor(text: string, color: CliBackgroundColor): string;
|
|
2041
|
+
writeJson(json: any): void;
|
|
2042
|
+
writeToFile(fileName: string, content: string): void;
|
|
2043
|
+
writeObjectsAsTable(objects: any[]): void;
|
|
2044
|
+
writeList(items: string[], options?: {
|
|
2045
|
+
ordered?: boolean;
|
|
2046
|
+
prefix?: string;
|
|
2047
|
+
color?: CliForegroundColor;
|
|
2048
|
+
}): void;
|
|
2049
|
+
writeKeyValue(entries: Record<string, string> | [string, string][], options?: {
|
|
2050
|
+
separator?: string;
|
|
2051
|
+
keyColor?: CliForegroundColor;
|
|
2052
|
+
}): void;
|
|
2053
|
+
writeColumns(items: string[], options?: {
|
|
2054
|
+
columns?: number;
|
|
2055
|
+
padding?: number;
|
|
2056
|
+
}): void;
|
|
2057
|
+
writeLink(text: string, url: string): void;
|
|
2058
|
+
writeBox(content: string | string[], options?: {
|
|
2059
|
+
title?: string;
|
|
2060
|
+
borderColor?: CliForegroundColor;
|
|
2061
|
+
padding?: number;
|
|
2062
|
+
}): void;
|
|
2063
|
+
writeIndented(text: string, level?: number): void;
|
|
2064
|
+
/** One block per row, header names as keys; used when a table cannot fit the terminal. */
|
|
2065
|
+
private writeRecords;
|
|
2066
|
+
writeTable(headers: string[], rows: string[][], options?: CliTableOptions): void;
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
declare class CliClipboard implements ICliClipboard {
|
|
2070
|
+
private readonly context;
|
|
2071
|
+
constructor(context: ICliExecutionContext);
|
|
2072
|
+
write(text: string): Promise<void>;
|
|
2073
|
+
read(): Promise<string>;
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
declare class CliLogger implements ICliLogger {
|
|
2077
|
+
private CliLogLevel;
|
|
1433
2078
|
constructor();
|
|
1434
2079
|
setCliLogLevel(level: CliLogLevel): void;
|
|
1435
2080
|
log(...args: any[]): void;
|
|
@@ -1490,11 +2135,22 @@ declare class CliTerminalTextAnimator implements ICliTextAnimator {
|
|
|
1490
2135
|
isRunning: boolean;
|
|
1491
2136
|
context?: ICliExecutionContext;
|
|
1492
2137
|
private animationInterval?;
|
|
2138
|
+
/** Characters of the current animation still visible on the line. */
|
|
2139
|
+
private visibleChars;
|
|
2140
|
+
/** Ends the current `showText` promise early (set while it runs). */
|
|
2141
|
+
private finish?;
|
|
1493
2142
|
private text;
|
|
1494
2143
|
private textColor;
|
|
1495
2144
|
constructor(terminal: Terminal);
|
|
1496
2145
|
show(text?: string): void;
|
|
1497
2146
|
showText(text: string, options?: CliTextAnimatorOptions): Promise<void>;
|
|
2147
|
+
/** Cursor position as `row:col`, or `null` when unavailable. */
|
|
2148
|
+
private cursorPosition;
|
|
2149
|
+
/**
|
|
2150
|
+
* Stop the animation, erase the text it wrote and resolve its `showText`
|
|
2151
|
+
* promise. Used when the user starts typing over the greeting.
|
|
2152
|
+
*/
|
|
2153
|
+
cancel(): void;
|
|
1498
2154
|
/**
|
|
1499
2155
|
* Hide the animation and reset the state.
|
|
1500
2156
|
*/
|
|
@@ -1511,6 +2167,101 @@ interface ICliWelcomeModule extends ICliModule {
|
|
|
1511
2167
|
configure(config: CliWelcomeMessageConfig): ICliModule;
|
|
1512
2168
|
}
|
|
1513
2169
|
declare const welcomeModule: ICliWelcomeModule;
|
|
2170
|
+
/**
|
|
2171
|
+
* Animated, time-based greeting on the first prompt. Runs after every other
|
|
2172
|
+
* module's `onAfterBoot` hook (setup and sign-in prompts come first), and
|
|
2173
|
+
* only when the welcome banner was shown.
|
|
2174
|
+
*/
|
|
2175
|
+
declare const greetingModule: ICliModule;
|
|
2176
|
+
|
|
2177
|
+
interface CliBootLogOptions {
|
|
2178
|
+
/** Steps taking at least this long are highlighted as slow. */
|
|
2179
|
+
slowStepMs?: number;
|
|
2180
|
+
/** When boot started (ms since epoch); defaults to now. */
|
|
2181
|
+
startedAt?: number;
|
|
2182
|
+
}
|
|
2183
|
+
/**
|
|
2184
|
+
* Live boot report written to the terminal while the CLI starts: a list of
|
|
2185
|
+
* the steps (terminal, services, servers, modules) with a thin progress bar
|
|
2186
|
+
* and percentage pinned below it.
|
|
2187
|
+
*
|
|
2188
|
+
* Anything else written to the terminal meanwhile is captured and the bar
|
|
2189
|
+
* steps aside for it. When boot is complete the report is cleared so the
|
|
2190
|
+
* regular terminal takes over; warnings, errors and other output (plugin
|
|
2191
|
+
* warnings) are written again in order. First-run setup prompts, answered
|
|
2192
|
+
* while the report is suspended, are cleared with it.
|
|
2193
|
+
*
|
|
2194
|
+
* A disabled log records problems but writes nothing.
|
|
2195
|
+
*/
|
|
2196
|
+
declare class CliBootLog {
|
|
2197
|
+
private readonly terminal;
|
|
2198
|
+
readonly enabled: boolean;
|
|
2199
|
+
private readonly startedAt;
|
|
2200
|
+
private readonly slowStepMs;
|
|
2201
|
+
private readonly problems;
|
|
2202
|
+
private finished;
|
|
2203
|
+
private totalSteps;
|
|
2204
|
+
private completedSteps;
|
|
2205
|
+
private current;
|
|
2206
|
+
private barVisible;
|
|
2207
|
+
private cursorHidden;
|
|
2208
|
+
private suspended;
|
|
2209
|
+
private startRow;
|
|
2210
|
+
/** Output written by others during boot, replayed after the report is cleared. */
|
|
2211
|
+
private readonly captured;
|
|
2212
|
+
private originalWrite?;
|
|
2213
|
+
private originalWriteln?;
|
|
2214
|
+
private redrawScheduled;
|
|
2215
|
+
/** The last setup output did not end its line (cursor after a prompt). */
|
|
2216
|
+
private promptOpen;
|
|
2217
|
+
constructor(terminal: Terminal | undefined, enabled: boolean, options?: CliBootLogOptions);
|
|
2218
|
+
/** Milliseconds since boot started. */
|
|
2219
|
+
get elapsedMs(): number;
|
|
2220
|
+
/** Whether `finish()` was called; later entries are ignored. */
|
|
2221
|
+
get isFinished(): boolean;
|
|
2222
|
+
/** Completed share of the planned steps, 0–100. */
|
|
2223
|
+
get percent(): number;
|
|
2224
|
+
/** Announce `count` more steps that will each be completed with `completeStep`. */
|
|
2225
|
+
addSteps(count: number): void;
|
|
2226
|
+
/** Name what is being set up now (shown next to the bar). */
|
|
2227
|
+
setCurrent(text: string): void;
|
|
2228
|
+
/** Mark one planned step as done (successfully or not). */
|
|
2229
|
+
completeStep(): void;
|
|
2230
|
+
/**
|
|
2231
|
+
* Step aside for interactive output (e.g. a module's first-run setup
|
|
2232
|
+
* prompt): remove the bar and show the cursor until `resume()`.
|
|
2233
|
+
*/
|
|
2234
|
+
suspend(): void;
|
|
2235
|
+
/** Bring the bar back after `suspend()`. */
|
|
2236
|
+
resume(): void;
|
|
2237
|
+
info(text: string): void;
|
|
2238
|
+
/** A completed step, optionally with how long it took. */
|
|
2239
|
+
ok(text: string, durationMs?: number): void;
|
|
2240
|
+
warn(text: string): void;
|
|
2241
|
+
error(text: string): void;
|
|
2242
|
+
/**
|
|
2243
|
+
* Write the summary line, then hand the screen over to the terminal:
|
|
2244
|
+
* clear the report (unless `keep`), then write warnings, errors and the
|
|
2245
|
+
* output captured during boot again. The report is not cleared when the
|
|
2246
|
+
* terminal already held something before boot started.
|
|
2247
|
+
*/
|
|
2248
|
+
finish(summary: string, keep?: boolean): Promise<void>;
|
|
2249
|
+
private write;
|
|
2250
|
+
/** Redraw the bar on the line below the list (the cursor stays on it). */
|
|
2251
|
+
private drawBar;
|
|
2252
|
+
/** First output: remember where the report starts and capture other writes. */
|
|
2253
|
+
private begin;
|
|
2254
|
+
private stopCapture;
|
|
2255
|
+
/** Someone else writes during boot: move the bar aside and keep a copy. */
|
|
2256
|
+
private onExternalWrite;
|
|
2257
|
+
/** Write without being captured. */
|
|
2258
|
+
private out;
|
|
2259
|
+
private hideBar;
|
|
2260
|
+
private format;
|
|
2261
|
+
private absoluteRow;
|
|
2262
|
+
/** Resolve once xterm has parsed everything written so far. */
|
|
2263
|
+
private flush;
|
|
2264
|
+
}
|
|
1514
2265
|
|
|
1515
2266
|
declare class CliBoot {
|
|
1516
2267
|
private readonly registry;
|
|
@@ -1520,13 +2271,60 @@ declare class CliBoot {
|
|
|
1520
2271
|
private readonly moduleRegistry;
|
|
1521
2272
|
private readonly bootedModules;
|
|
1522
2273
|
private readonly initializedProcessors;
|
|
2274
|
+
/** Services and guards each module registered, removed when it is unloaded. */
|
|
2275
|
+
private readonly moduleProviders;
|
|
2276
|
+
/** Context modules were booted with (passed to `onDestroy` on unload). */
|
|
2277
|
+
private context?;
|
|
2278
|
+
/** Boot report of the startup boot. */
|
|
2279
|
+
private bootLogRef?;
|
|
2280
|
+
/** The boot report while startup is still in progress, else `undefined`. */
|
|
2281
|
+
private get bootLog();
|
|
1523
2282
|
constructor(registry: ICliCommandProcessorRegistry, services: ICliServiceProvider);
|
|
1524
2283
|
/**
|
|
1525
2284
|
* Get the module registry for external access.
|
|
1526
2285
|
*/
|
|
1527
2286
|
getModuleRegistry(): CliModuleRegistry;
|
|
1528
|
-
boot(context: CliExecutionContext, modules: ICliModule[]): Promise<void>;
|
|
2287
|
+
boot(context: CliExecutionContext, modules: ICliModule[], bootLog?: CliBootLog): Promise<void>;
|
|
2288
|
+
private bootAll;
|
|
2289
|
+
/**
|
|
2290
|
+
* Boot one module: declarations (services, guards, permissions,
|
|
2291
|
+
* translations), lifecycle (`onInit`, first-run `onSetup`), then its
|
|
2292
|
+
* commands. Modules already booted or with missing dependencies are skipped.
|
|
2293
|
+
*/
|
|
1529
2294
|
private bootModule;
|
|
2295
|
+
private dependenciesLoaded;
|
|
2296
|
+
/** Services, guards, permissions and translations the module declares. */
|
|
2297
|
+
private registerDeclarations;
|
|
2298
|
+
/** `onInit` runs before the module's commands are registered. */
|
|
2299
|
+
private runOnInit;
|
|
2300
|
+
/** `onSetup` runs once per browser (first-run flow), until it succeeds. */
|
|
2301
|
+
private runFirstSetup;
|
|
2302
|
+
/** Register and initialize the module's commands; returns how many. */
|
|
2303
|
+
private registerCommands;
|
|
2304
|
+
/** One boot-log line per module that does something at boot. */
|
|
2305
|
+
private reportModule;
|
|
2306
|
+
/**
|
|
2307
|
+
* Unload a module (`pkg remove`, or before `pkg update` boots the new
|
|
2308
|
+
* version): its commands, guards and permissions are removed at once,
|
|
2309
|
+
* then `onDestroy` runs, then its services are removed (so `onDestroy`
|
|
2310
|
+
* can still use them). Services are removed by registration, so a newer
|
|
2311
|
+
* version registered meanwhile keeps its own.
|
|
2312
|
+
*/
|
|
2313
|
+
private unloadModule;
|
|
2314
|
+
private removeProviders;
|
|
2315
|
+
/** Publish on the event bus; never lets the bus break booting. */
|
|
2316
|
+
private emitEvent;
|
|
2317
|
+
/** Boot warning: into the boot log when it is shown, else the terminal. */
|
|
2318
|
+
private warn;
|
|
2319
|
+
/** Boot error: into the boot log when it is shown, else the terminal. */
|
|
2320
|
+
private fail;
|
|
2321
|
+
/**
|
|
2322
|
+
* Sub-processors of an `extendsProcessor` processor are merged into the
|
|
2323
|
+
* processor it extends, so they belong to that one: re-parent them so they
|
|
2324
|
+
* inherit its access rules (`requiredPermissions` etc.) and help/root
|
|
2325
|
+
* lookups resolve to the registered processor.
|
|
2326
|
+
*/
|
|
2327
|
+
private adoptMergedSubProcessors;
|
|
1530
2328
|
private buildCoreModule;
|
|
1531
2329
|
/**
|
|
1532
2330
|
* Topologically sort modules by their dependencies using DFS.
|
|
@@ -1686,91 +2484,7 @@ declare class CliInputReader implements ICliInputReader {
|
|
|
1686
2484
|
readFile(prompt: string, options?: CliFilePickerOptions): Promise<CliFileResult[] | null>;
|
|
1687
2485
|
}
|
|
1688
2486
|
|
|
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";
|
|
2487
|
+
declare const CliProcessRegistry_TOKEN: any;
|
|
1774
2488
|
declare class CliProcessRegistry implements ICliProcessRegistry {
|
|
1775
2489
|
private nextPid;
|
|
1776
2490
|
private processes;
|
|
@@ -1789,7 +2503,7 @@ declare class CliProcessRegistry implements ICliProcessRegistry {
|
|
|
1789
2503
|
}
|
|
1790
2504
|
|
|
1791
2505
|
/**
|
|
1792
|
-
*
|
|
2506
|
+
* Environment variables for the CLI.
|
|
1793
2507
|
*
|
|
1794
2508
|
* Variables set here are available to all commands via `$VAR` / `${VAR}`
|
|
1795
2509
|
* substitution in the executor. Commands can also read/write the store
|
|
@@ -1798,29 +2512,106 @@ declare class CliProcessRegistry implements ICliProcessRegistry {
|
|
|
1798
2512
|
interface ICliEnvironment {
|
|
1799
2513
|
/** Get a variable value (undefined if not set). */
|
|
1800
2514
|
get(name: string): string | undefined;
|
|
1801
|
-
/**
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
2515
|
+
/**
|
|
2516
|
+
* Set a variable: for the signed-in user (`'user'`, the default, saved),
|
|
2517
|
+
* for everyone (`'global'`, saved) or for this terminal only (`'session'`).
|
|
2518
|
+
*/
|
|
2519
|
+
set(name: string, value: string, scope?: CliEnvironmentScope): void;
|
|
2520
|
+
/**
|
|
2521
|
+
* Remove a variable. Without a scope it is removed for this terminal and
|
|
2522
|
+
* the user (and hidden when it still comes from a shared or built-in
|
|
2523
|
+
* value); `'global'` removes the shared value.
|
|
2524
|
+
*/
|
|
2525
|
+
unset(name: string, scope?: CliEnvironmentScope): void;
|
|
1805
2526
|
/** Get all variables as a record. */
|
|
1806
2527
|
getAll(): Record<string, string>;
|
|
1807
2528
|
/** Check if a variable is set. */
|
|
1808
2529
|
has(name: string): boolean;
|
|
1809
|
-
|
|
1810
|
-
|
|
2530
|
+
/** Where the current value of `name` comes from. */
|
|
2531
|
+
scopeOf?(name: string): CliEnvironmentSource | undefined;
|
|
2532
|
+
}
|
|
2533
|
+
declare const ICliEnvironment_TOKEN: any;
|
|
2534
|
+
/** Where a variable is set: this terminal, the signed-in user, or everyone. */
|
|
2535
|
+
type CliEnvironmentScope = 'session' | 'user' | 'global';
|
|
2536
|
+
/** Where a value comes from: a scope, or computed / built in (`HOME`, `SHELL`, …). */
|
|
2537
|
+
type CliEnvironmentSource = CliEnvironmentScope | 'builtin';
|
|
2538
|
+
/** What one user (or the signed-out session, key '') changed: values set and defaults removed. */
|
|
2539
|
+
interface CliEnvironmentProfile {
|
|
2540
|
+
vars: Record<string, string>;
|
|
2541
|
+
unset: string[];
|
|
2542
|
+
}
|
|
2543
|
+
/** Saved environment: one profile per user name ('' when nobody is signed in). */
|
|
2544
|
+
type CliEnvironmentSnapshot = Record<string, CliEnvironmentProfile>;
|
|
2545
|
+
/**
|
|
2546
|
+
* One saved change, applied by the host to the latest saved state (so two
|
|
2547
|
+
* tabs changing different variables never overwrite each other).
|
|
2548
|
+
*/
|
|
2549
|
+
type CliEnvironmentChange = {
|
|
2550
|
+
scope: 'user';
|
|
2551
|
+
profile: string;
|
|
2552
|
+
name: string;
|
|
2553
|
+
value: string;
|
|
2554
|
+
} | {
|
|
2555
|
+
scope: 'user';
|
|
2556
|
+
profile: string;
|
|
2557
|
+
name: string;
|
|
2558
|
+
unset: true;
|
|
2559
|
+
hide: boolean;
|
|
2560
|
+
} | {
|
|
2561
|
+
scope: 'global';
|
|
2562
|
+
name: string;
|
|
2563
|
+
value: string;
|
|
2564
|
+
} | {
|
|
2565
|
+
scope: 'global';
|
|
2566
|
+
name: string;
|
|
2567
|
+
unset: true;
|
|
2568
|
+
};
|
|
1811
2569
|
/**
|
|
1812
2570
|
* Default in-memory implementation.
|
|
1813
|
-
*
|
|
2571
|
+
*
|
|
2572
|
+
* A variable resolves, in order, from this terminal's variables
|
|
2573
|
+
* (`NAME=value`), the current user's own (`export`), the shared ones
|
|
2574
|
+
* (`export --global`), then bound live values (USER, HOME, PWD follow the
|
|
2575
|
+
* session and directory), then the standard variables seeded on
|
|
2576
|
+
* construction. Each user has a separate set, so `su`/`login` switch
|
|
2577
|
+
* environments, and `onChange` lets the host save each change.
|
|
1814
2578
|
*/
|
|
1815
2579
|
declare class CliEnvironment implements ICliEnvironment {
|
|
1816
|
-
private readonly
|
|
2580
|
+
private readonly defaults;
|
|
2581
|
+
/** Variables computed on read; a user's own value wins over them. */
|
|
2582
|
+
private readonly bound;
|
|
2583
|
+
private readonly profiles;
|
|
2584
|
+
private readonly global;
|
|
2585
|
+
private readonly session;
|
|
2586
|
+
private profileKey;
|
|
2587
|
+
/** Called after every saved change (user or global), to persist it. */
|
|
2588
|
+
onChange?: (change: CliEnvironmentChange) => void;
|
|
1817
2589
|
constructor();
|
|
2590
|
+
/** Compute a variable on every read; the seeded value is the fallback while it returns nothing. */
|
|
2591
|
+
bind(name: string, resolver: () => string | null | undefined): void;
|
|
2592
|
+
/** Pick whose changes apply (the signed-in user's name, '' when signed out). */
|
|
2593
|
+
setProfileResolver(resolver: () => string | null | undefined): void;
|
|
2594
|
+
/** Restore saved profiles and shared variables (replaces the saved ones in memory). */
|
|
2595
|
+
load(snapshot: CliEnvironmentSnapshot | undefined, global?: Record<string, string>): void;
|
|
2596
|
+
snapshot(): CliEnvironmentSnapshot;
|
|
2597
|
+
/** The shared variables. */
|
|
2598
|
+
globals(): Record<string, string>;
|
|
1818
2599
|
get(name: string): string | undefined;
|
|
1819
|
-
|
|
1820
|
-
|
|
2600
|
+
scopeOf(name: string): CliEnvironmentSource | undefined;
|
|
2601
|
+
set(name: string, value: string, scope?: CliEnvironmentScope): void;
|
|
2602
|
+
unset(name: string, scope?: CliEnvironmentScope): void;
|
|
1821
2603
|
getAll(): Record<string, string>;
|
|
1822
2604
|
has(name: string): boolean;
|
|
1823
|
-
|
|
2605
|
+
private profileOf;
|
|
2606
|
+
}
|
|
2607
|
+
/** Apply one change to saved state (the host does this under the cross-tab lock). */
|
|
2608
|
+
declare function applyEnvironmentChange(state: {
|
|
2609
|
+
profiles?: CliEnvironmentSnapshot;
|
|
2610
|
+
global?: Record<string, string>;
|
|
2611
|
+
}, change: CliEnvironmentChange): {
|
|
2612
|
+
profiles: CliEnvironmentSnapshot;
|
|
2613
|
+
global: Record<string, string>;
|
|
2614
|
+
};
|
|
1824
2615
|
|
|
1825
2616
|
declare class CliDragDropService implements ICliDragDropService {
|
|
1826
2617
|
private readonly _container;
|
|
@@ -1832,6 +2623,58 @@ declare class CliDragDropService implements ICliDragDropService {
|
|
|
1832
2623
|
destroy(): void;
|
|
1833
2624
|
}
|
|
1834
2625
|
|
|
2626
|
+
/**
|
|
2627
|
+
* Default HTTP client implementation.
|
|
2628
|
+
*
|
|
2629
|
+
* Wraps the global `fetch()` and automatically merges an abort signal
|
|
2630
|
+
* so that in-flight requests are cancelled when the user presses Ctrl+C.
|
|
2631
|
+
*
|
|
2632
|
+
* Created per-command by the executor — each instance is bound to the
|
|
2633
|
+
* command's own AbortSignal.
|
|
2634
|
+
*/
|
|
2635
|
+
declare class CliHttpClient implements ICliHttpClient {
|
|
2636
|
+
private readonly signal?;
|
|
2637
|
+
constructor(signal?: AbortSignal | undefined);
|
|
2638
|
+
fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
2639
|
+
get<T = any>(url: string, options?: CliHttpRequestOptions): Promise<T>;
|
|
2640
|
+
post<T = any>(url: string, body?: any, options?: CliHttpRequestOptions): Promise<T>;
|
|
2641
|
+
put<T = any>(url: string, body?: any, options?: CliHttpRequestOptions): Promise<T>;
|
|
2642
|
+
patch<T = any>(url: string, body?: any, options?: CliHttpRequestOptions): Promise<T>;
|
|
2643
|
+
delete<T = any>(url: string, options?: CliHttpRequestOptions): Promise<T>;
|
|
2644
|
+
head(url: string, options?: CliHttpRequestOptions): Promise<Response>;
|
|
2645
|
+
options<T = any>(url: string, options?: CliHttpRequestOptions): Promise<T>;
|
|
2646
|
+
private jsonRequest;
|
|
2647
|
+
private isRawBody;
|
|
2648
|
+
/**
|
|
2649
|
+
* Merge the command signal with any additional signals (caller, timeout).
|
|
2650
|
+
* Uses AbortSignal.any() when available, falls back to a manual composite
|
|
2651
|
+
* controller for older browsers (pre-Chrome 116 / Safari 17.4).
|
|
2652
|
+
*/
|
|
2653
|
+
private mergeSignal;
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
declare class CliNotifier implements ICliNotifier {
|
|
2657
|
+
private _current;
|
|
2658
|
+
private readonly _change$;
|
|
2659
|
+
readonly change$: rxjs.Observable<any>;
|
|
2660
|
+
get current(): CliNotification | undefined;
|
|
2661
|
+
info(message: string): void;
|
|
2662
|
+
success(message: string): void;
|
|
2663
|
+
warn(message: string): void;
|
|
2664
|
+
error(message: string): void;
|
|
2665
|
+
clear(): void;
|
|
2666
|
+
private set;
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
/** Default {@link ICliPermissionRegistry}: permissions declared by modules. */
|
|
2670
|
+
declare class CliPermissionRegistry implements ICliPermissionRegistry {
|
|
2671
|
+
private readonly definitions;
|
|
2672
|
+
register(definitions: CliPermissionDefinition[], module?: string): void;
|
|
2673
|
+
unregister(module: string): void;
|
|
2674
|
+
list(): CliPermissionDefinition[];
|
|
2675
|
+
get(name: string): CliPermissionDefinition | undefined;
|
|
2676
|
+
}
|
|
2677
|
+
|
|
1835
2678
|
declare class OverlayAddon implements ITerminalAddon {
|
|
1836
2679
|
private terminal;
|
|
1837
2680
|
private overlayNode;
|
|
@@ -1843,8 +2686,6 @@ declare class OverlayAddon implements ITerminalAddon {
|
|
|
1843
2686
|
}
|
|
1844
2687
|
|
|
1845
2688
|
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
2689
|
declare const hotkeysInfo: {
|
|
1849
2690
|
key: string;
|
|
1850
2691
|
description: string;
|
|
@@ -1888,28 +2729,140 @@ declare class CliKeyValueStore implements ICliKeyValueStore {
|
|
|
1888
2729
|
declare class CliStateStore implements ICliStateStore {
|
|
1889
2730
|
private readonly services;
|
|
1890
2731
|
readonly name: string;
|
|
1891
|
-
private readonly initialState;
|
|
1892
2732
|
private state$;
|
|
1893
|
-
|
|
1894
|
-
|
|
2733
|
+
/** Signed-in user, for `scope: 'user'` stores. */
|
|
2734
|
+
private user?;
|
|
2735
|
+
private initialState;
|
|
2736
|
+
private options;
|
|
2737
|
+
/** The first load from storage (see `initialize`). */
|
|
2738
|
+
private loading?;
|
|
2739
|
+
private loaded;
|
|
2740
|
+
/** Keys changed before the saved state was loaded: they win over it. */
|
|
2741
|
+
private readonly changedBeforeLoad;
|
|
2742
|
+
/** Keys changed since the last save (only these are written). */
|
|
2743
|
+
private readonly unsaved;
|
|
2744
|
+
/** When each key was last changed here (`updateState`), to tell local edits from synced ones. */
|
|
2745
|
+
private readonly editedAt;
|
|
2746
|
+
private edits;
|
|
2747
|
+
/** `reset()` since the last save: the whole state is written. */
|
|
2748
|
+
private replaceOnSave;
|
|
2749
|
+
/**
|
|
2750
|
+
* Each key as last loaded, saved or received (JSON), to also find keys
|
|
2751
|
+
* changed in place without `updateState`.
|
|
2752
|
+
*/
|
|
2753
|
+
private baseline;
|
|
2754
|
+
private persistScheduled;
|
|
2755
|
+
/**
|
|
2756
|
+
* Called after the state was saved (set by the store manager to share it
|
|
2757
|
+
* with other tabs).
|
|
2758
|
+
*/
|
|
2759
|
+
onPersisted?: (storageKey: string, state: CliState) => void;
|
|
2760
|
+
constructor(services: ICliServiceProvider, name: string, initialState: CliState, options?: CliStateStoreOptions);
|
|
2761
|
+
/** Key the state is saved under. */
|
|
2762
|
+
get key(): string;
|
|
2763
|
+
/**
|
|
2764
|
+
* Saved per store, or per signed-in user for `scope: 'user'` (signed
|
|
2765
|
+
* out, the state is shared like a global store).
|
|
2766
|
+
*/
|
|
2767
|
+
private get storageKey();
|
|
2768
|
+
/**
|
|
2769
|
+
* The signed-in user changed: a `scope: 'user'` store switches to that
|
|
2770
|
+
* user's saved state (unsaved changes of the previous user are dropped,
|
|
2771
|
+
* so save before switching users).
|
|
2772
|
+
*/
|
|
2773
|
+
setUser(user: string | undefined): void;
|
|
2774
|
+
/** Whether changes saved by other tabs are applied to this store. */
|
|
2775
|
+
get syncAcrossTabs(): boolean;
|
|
2776
|
+
/** A session store lives in this terminal only and is never saved. */
|
|
2777
|
+
private get isSession();
|
|
1895
2778
|
getState<T extends CliState = CliState>(): T;
|
|
1896
2779
|
updateState(newState: Partial<CliState>): void;
|
|
1897
2780
|
select<K>(selector: (state: CliState) => K): Observable<K>;
|
|
1898
2781
|
subscribe(callback: (state: CliState) => void): Subscription;
|
|
1899
2782
|
reset(): void;
|
|
2783
|
+
/**
|
|
2784
|
+
* Save the state. The saved state is loaded first, so saving before the
|
|
2785
|
+
* store was loaded never replaces data with the initial state.
|
|
2786
|
+
*/
|
|
1900
2787
|
persist(): Promise<void>;
|
|
2788
|
+
/**
|
|
2789
|
+
* Change the state from its latest saved value and save it, atomically:
|
|
2790
|
+
* under the cross-tab lock, `change` gets the state as saved (plus this
|
|
2791
|
+
* terminal's unsaved changes) and its result is merged and written. Two
|
|
2792
|
+
* terminals updating the same key never lose each other's change, e.g.
|
|
2793
|
+
* both adding an item to a list. Without storage (or for a session
|
|
2794
|
+
* store) it is a plain `updateState`.
|
|
2795
|
+
*/
|
|
2796
|
+
update(change: (state: CliState) => Partial<CliState>): Promise<void>;
|
|
1901
2797
|
initialize(): Promise<void>;
|
|
2798
|
+
reload(): Promise<void>;
|
|
2799
|
+
/**
|
|
2800
|
+
* Add defaults for keys the store does not have yet (when it was first
|
|
2801
|
+
* created without them, e.g. read before its command registered).
|
|
2802
|
+
*/
|
|
2803
|
+
applyDefaults(defaults: CliState): void;
|
|
2804
|
+
/** Merge store options (later options win). */
|
|
2805
|
+
setOptions(options: CliStateStoreOptions): void;
|
|
2806
|
+
/**
|
|
2807
|
+
* State saved by another tab or terminal: apply it without saving again,
|
|
2808
|
+
* keeping the keys changed here and not saved yet.
|
|
2809
|
+
*/
|
|
2810
|
+
applySaved(state: CliState): void;
|
|
2811
|
+
/**
|
|
2812
|
+
* Another tab or terminal saved this store: apply what is saved now.
|
|
2813
|
+
* Messages can arrive out of order (one sent before this terminal's own
|
|
2814
|
+
* save can arrive after it), so storage, not the message, is the truth.
|
|
2815
|
+
* Reads are chained so the last one applied is the latest.
|
|
2816
|
+
*/
|
|
2817
|
+
refreshFromStorage(fallback?: CliState): Promise<void>;
|
|
2818
|
+
private refreshing;
|
|
1902
2819
|
/**
|
|
1903
2820
|
* Complete the BehaviorSubject so all subscribers are notified
|
|
1904
2821
|
* and no further emissions occur. Called during engine teardown.
|
|
1905
2822
|
*/
|
|
1906
2823
|
dispose(): void;
|
|
2824
|
+
private load;
|
|
2825
|
+
/**
|
|
2826
|
+
* Save the keys changed here, merged into the saved state (the whole
|
|
2827
|
+
* state after `reset()` or a migration). Runs under a lock shared by all
|
|
2828
|
+
* tabs, so two terminals saving at once do not lose each other's keys.
|
|
2829
|
+
* Keys others saved meanwhile are applied here.
|
|
2830
|
+
*/
|
|
2831
|
+
private write;
|
|
2832
|
+
/** Keys changed here since the last load, save or received state. */
|
|
2833
|
+
private changedKeys;
|
|
2834
|
+
private setBaseline;
|
|
2835
|
+
private pick;
|
|
2836
|
+
private get versionKey();
|
|
2837
|
+
/** With `autoPersist`, save once after the changes of this tick. */
|
|
2838
|
+
private schedulePersist;
|
|
1907
2839
|
}
|
|
1908
2840
|
|
|
1909
2841
|
interface CliEngineOptions extends CliOptions {
|
|
1910
2842
|
terminalOptions?: Partial<ITerminalOptions & ITerminalInitOnlyOptions>;
|
|
1911
2843
|
/** Optional snapshot to restore on start() */
|
|
1912
2844
|
snapshot?: CliEngineSnapshot;
|
|
2845
|
+
/**
|
|
2846
|
+
* Explicit URL of `qodalis_cli_wasm_bg.wasm` (optional accelerator). When
|
|
2847
|
+
* omitted it is looked up next to the page (`document.baseURI`), then at
|
|
2848
|
+
* `/assets/wasm/` and `/wasm/`; the CLI works without it.
|
|
2849
|
+
*/
|
|
2850
|
+
wasmUrl?: string;
|
|
2851
|
+
/**
|
|
2852
|
+
* The welcome banner and greeting shown at startup. `false` starts with
|
|
2853
|
+
* just the prompt (embedded terminals, playgrounds, terminals driven by
|
|
2854
|
+
* `execute()`); an object configures the banner like
|
|
2855
|
+
* `welcomeModule.configure()`.
|
|
2856
|
+
* @default true
|
|
2857
|
+
*/
|
|
2858
|
+
welcome?: boolean | CliWelcomeMessageConfig;
|
|
2859
|
+
/**
|
|
2860
|
+
* Focus the terminal when it starts. Turn it off when the terminal sits
|
|
2861
|
+
* next to other inputs that should keep the keyboard (an editor that
|
|
2862
|
+
* rebuilds the terminal while the user types); `focus()` still works.
|
|
2863
|
+
* @default true
|
|
2864
|
+
*/
|
|
2865
|
+
autoFocus?: boolean;
|
|
1913
2866
|
}
|
|
1914
2867
|
declare class CliEngine {
|
|
1915
2868
|
private readonly container;
|
|
@@ -1928,6 +2881,11 @@ declare class CliEngine {
|
|
|
1928
2881
|
private resizeScheduled;
|
|
1929
2882
|
private bootService?;
|
|
1930
2883
|
private dragDropService?;
|
|
2884
|
+
private _startedAt?;
|
|
2885
|
+
private terminalOptions;
|
|
2886
|
+
private _isBooted;
|
|
2887
|
+
private resolveBooted;
|
|
2888
|
+
private readonly bootedPromise;
|
|
1931
2889
|
constructor(container: HTMLElement, options?: CliEngineOptions | undefined);
|
|
1932
2890
|
/**
|
|
1933
2891
|
* Register a CLI module to be loaded on start().
|
|
@@ -1938,25 +2896,55 @@ declare class CliEngine {
|
|
|
1938
2896
|
*/
|
|
1939
2897
|
registerModules(modules: ICliModule[]): void;
|
|
1940
2898
|
/**
|
|
1941
|
-
* Register a
|
|
1942
|
-
*
|
|
2899
|
+
* Register a service to be available in the service container before
|
|
2900
|
+
* any module boots. Must be called before start(). Services a module
|
|
2901
|
+
* needs for itself belong in its `services`.
|
|
1943
2902
|
*/
|
|
1944
|
-
|
|
2903
|
+
registerService(token: string, value: any): void;
|
|
1945
2904
|
/**
|
|
1946
|
-
*
|
|
1947
|
-
*
|
|
2905
|
+
* Start the CLI: set up the terminal and services, boot the modules
|
|
2906
|
+
* (reporting progress in the terminal), then hand over to the prompt.
|
|
2907
|
+
*
|
|
2908
|
+
* Phases, in order:
|
|
2909
|
+
* 1. terminal xterm.js in the container
|
|
2910
|
+
* 2. services service container, executor, execution context
|
|
2911
|
+
* 3. boot report hold typed keys, show the boot log
|
|
2912
|
+
* 4. runtime environment, background services, servers
|
|
2913
|
+
* 5. modules core + welcome + server + user modules
|
|
2914
|
+
* 6. completion tab-completion providers
|
|
2915
|
+
* 7. ready clear the report, replay typed keys, `isBooted`
|
|
2916
|
+
* 8. after boot `onAfterBoot` hooks (welcome message), snapshot
|
|
1948
2917
|
*/
|
|
1949
|
-
|
|
2918
|
+
start(): Promise<void>;
|
|
2919
|
+
/** 1. Wait for the container to have a size, then create xterm.js. */
|
|
2920
|
+
private setupTerminal;
|
|
2921
|
+
/** 2. Service container, boot service, executor and execution context. */
|
|
2922
|
+
private setupServices;
|
|
1950
2923
|
/**
|
|
1951
|
-
*
|
|
1952
|
-
*
|
|
1953
|
-
* @deprecated Use registerModule() with services instead.
|
|
2924
|
+
* 3. Keep what the user types until the terminal is ready (replayed at
|
|
2925
|
+
* the first prompt) and start the boot report (configurable).
|
|
1954
2926
|
*/
|
|
1955
|
-
|
|
2927
|
+
private beginBootReport;
|
|
2928
|
+
/** 4. Environment variables, background services, server auth and manager. */
|
|
2929
|
+
private registerRuntimeServices;
|
|
2930
|
+
/** 4. Connect to the configured servers, one boot step each. */
|
|
2931
|
+
private connectServers;
|
|
1956
2932
|
/**
|
|
1957
|
-
*
|
|
2933
|
+
* 5. Built-in welcome and server modules, the app's modules, and the
|
|
2934
|
+
* greeting, which runs after every other `onAfterBoot` hook.
|
|
1958
2935
|
*/
|
|
1959
|
-
|
|
2936
|
+
private modulesToBoot;
|
|
2937
|
+
/** Whether startup shows the welcome banner (which also shows the first prompt). */
|
|
2938
|
+
private get showsWelcome();
|
|
2939
|
+
/** 7. Replace the boot report with the terminal and mark the CLI booted. */
|
|
2940
|
+
private completeBoot;
|
|
2941
|
+
/**
|
|
2942
|
+
* Boot threw: never leave the terminal unusable. Keep the report with the
|
|
2943
|
+
* error on screen, show the cursor and hand over typed keys.
|
|
2944
|
+
*/
|
|
2945
|
+
private failBoot;
|
|
2946
|
+
/** 8. `onAfterBoot` hooks by priority (lower first); one failing hook does not stop the rest. */
|
|
2947
|
+
private runAfterBootHooks;
|
|
1960
2948
|
/**
|
|
1961
2949
|
* Clean up terminal and event listeners.
|
|
1962
2950
|
*/
|
|
@@ -1978,7 +2966,23 @@ declare class CliEngine {
|
|
|
1978
2966
|
*/
|
|
1979
2967
|
getRegistry(): CliCommandProcessorRegistry;
|
|
1980
2968
|
/**
|
|
1981
|
-
*
|
|
2969
|
+
* `true` once boot has completed: modules are set up and the terminal
|
|
2970
|
+
* accepts input. `onAfterBoot` hooks (welcome message) run right after.
|
|
2971
|
+
*/
|
|
2972
|
+
get isBooted(): boolean;
|
|
2973
|
+
/**
|
|
2974
|
+
* Resolves when boot has completed (see `isBooted`). Never rejects; if
|
|
2975
|
+
* `start()` fails it stays pending.
|
|
2976
|
+
*/
|
|
2977
|
+
get booted(): Promise<void>;
|
|
2978
|
+
/**
|
|
2979
|
+
* Timestamp (ms since epoch) when the engine finished starting.
|
|
2980
|
+
*/
|
|
2981
|
+
get startedAt(): number | undefined;
|
|
2982
|
+
/**
|
|
2983
|
+
* Execute a command programmatically, behaving the same as if the user
|
|
2984
|
+
* typed it and pressed Enter: echoes the command, adds it to history,
|
|
2985
|
+
* executes it, and shows a new prompt afterwards.
|
|
1982
2986
|
*/
|
|
1983
2987
|
execute(command: string): Promise<void>;
|
|
1984
2988
|
/**
|
|
@@ -1992,8 +2996,6 @@ declare class CliEngine {
|
|
|
1992
2996
|
* source, the restored content may reflow differently.
|
|
1993
2997
|
*/
|
|
1994
2998
|
private restoreSnapshot;
|
|
1995
|
-
private getTerminalOptions;
|
|
1996
|
-
private initializeTerminal;
|
|
1997
2999
|
private handleResize;
|
|
1998
3000
|
/**
|
|
1999
3001
|
* Call fitAddon.fit() only when the container has non-zero dimensions.
|
|
@@ -2007,55 +3009,216 @@ declare class CliEngine {
|
|
|
2007
3009
|
* so intermediate resize events cannot leave stale artefacts.
|
|
2008
3010
|
*/
|
|
2009
3011
|
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
3012
|
}
|
|
2019
3013
|
|
|
3014
|
+
interface TerminalSetupResult {
|
|
3015
|
+
terminal: Terminal;
|
|
3016
|
+
fitAddon: FitAddon;
|
|
3017
|
+
serializeAddon: SerializeAddon;
|
|
3018
|
+
dragDropService: CliDragDropService;
|
|
3019
|
+
wheelListener: (e: WheelEvent) => void;
|
|
3020
|
+
}
|
|
3021
|
+
/**
|
|
3022
|
+
* Default terminal font size: 20px, or 14px on phone-sized viewports so a
|
|
3023
|
+
* line still fits a useful number of columns (about 26 at 20px on a 390px screen).
|
|
3024
|
+
*/
|
|
3025
|
+
declare function defaultFontSize(): number;
|
|
3026
|
+
/**
|
|
3027
|
+
* Merge user-supplied terminal options with sensible defaults.
|
|
3028
|
+
*/
|
|
3029
|
+
declare function getTerminalOptions(userOptions?: Partial<ITerminalOptions & ITerminalInitOnlyOptions>): ITerminalOptions & ITerminalInitOnlyOptions;
|
|
3030
|
+
/**
|
|
3031
|
+
* Create and configure an xterm.js Terminal with all required addons,
|
|
3032
|
+
* open it into the given container, and return the instances.
|
|
3033
|
+
*/
|
|
3034
|
+
declare function initializeTerminal(container: HTMLElement, opts: ITerminalOptions & ITerminalInitOnlyOptions, focus?: boolean): TerminalSetupResult;
|
|
3035
|
+
/**
|
|
3036
|
+
* Wait until the container element has non-zero dimensions.
|
|
3037
|
+
* xterm.js requires the host element to be laid out before open() is called.
|
|
3038
|
+
* Rejects after {@link LAYOUT_TIMEOUT_MS} if the container stays hidden.
|
|
3039
|
+
*/
|
|
3040
|
+
declare function waitForLayout(container: HTMLElement): Promise<void>;
|
|
3041
|
+
|
|
3042
|
+
/**
|
|
3043
|
+
* In-memory publish/subscribe bus of one terminal. Handlers run
|
|
3044
|
+
* synchronously in subscription order; a throwing handler is reported to
|
|
3045
|
+
* `onHandlerError` and does not stop delivery. Keeps the last
|
|
3046
|
+
* {@link CLI_EVENT_HISTORY_SIZE} events; nothing is persisted.
|
|
3047
|
+
*/
|
|
3048
|
+
declare class CliEventBus implements ICliEventBus {
|
|
3049
|
+
private readonly onHandlerError;
|
|
3050
|
+
private readonly historySize;
|
|
3051
|
+
private readonly subject;
|
|
3052
|
+
private readonly recent;
|
|
3053
|
+
private disposed;
|
|
3054
|
+
constructor(onHandlerError?: (error: unknown, event: CliEvent) => void, historySize?: number);
|
|
3055
|
+
emit<K extends CliEventType>(type: K, data: CliEventMap[K], options?: CliEmitOptions): void;
|
|
3056
|
+
emit<T = unknown, K extends string = string>(type: K & CustomEventType<K>, data?: T, options?: CliEmitOptions): void;
|
|
3057
|
+
on<K extends CliEventType>(pattern: K, handler: CliEventHandler<CliEventMap[K]>): () => void;
|
|
3058
|
+
on<T = unknown>(pattern: string, handler: CliEventHandler<T>): () => void;
|
|
3059
|
+
once<K extends CliEventType>(pattern: K, handler: CliEventHandler<CliEventMap[K]>): () => void;
|
|
3060
|
+
once<T = unknown>(pattern: string, handler: CliEventHandler<T>): () => void;
|
|
3061
|
+
events$<K extends CliEventType>(pattern: K): Observable<CliEvent<CliEventMap[K]>>;
|
|
3062
|
+
events$<T = unknown>(pattern?: string): Observable<CliEvent<T>>;
|
|
3063
|
+
history<K extends CliEventType>(pattern: K, limit?: number): CliEvent<CliEventMap[K]>[];
|
|
3064
|
+
history<T = unknown>(pattern?: string, limit?: number): CliEvent<T>[];
|
|
3065
|
+
/** Stop delivering events and complete all observables. */
|
|
3066
|
+
dispose(): void;
|
|
3067
|
+
}
|
|
3068
|
+
|
|
3069
|
+
/**
|
|
3070
|
+
* Default implementation of the translation service.
|
|
3071
|
+
*
|
|
3072
|
+
* Maintains a map of locale -> flat key-value translations.
|
|
3073
|
+
* The 'en' locale is always implicitly available via defaultValue fallbacks.
|
|
3074
|
+
* Supports simple {param} interpolation.
|
|
3075
|
+
*/
|
|
3076
|
+
declare class CliTranslationService implements ICliTranslationService {
|
|
3077
|
+
private locale;
|
|
3078
|
+
private readonly translations;
|
|
3079
|
+
t(key: string, defaultValue: string, params?: Record<string, string | number>): string;
|
|
3080
|
+
getLocale(): string;
|
|
3081
|
+
setLocale(locale: string): void;
|
|
3082
|
+
addTranslations(locale: string, translations: Record<string, string>): void;
|
|
3083
|
+
getAvailableLocales(): string[];
|
|
3084
|
+
}
|
|
3085
|
+
|
|
3086
|
+
interface InitializeServicesOptions {
|
|
3087
|
+
registry: CliCommandProcessorRegistry;
|
|
3088
|
+
pendingServices: CliProvider[];
|
|
3089
|
+
dragDropService?: CliDragDropService;
|
|
3090
|
+
}
|
|
3091
|
+
interface InitializeServicesResult {
|
|
3092
|
+
services: CliServiceContainer;
|
|
3093
|
+
events: CliEventBus;
|
|
3094
|
+
logger: CliLogger;
|
|
3095
|
+
commandHistory: CliCommandHistory;
|
|
3096
|
+
stateStoreManager: CliStateStoreManager;
|
|
3097
|
+
processRegistry: CliProcessRegistry;
|
|
3098
|
+
translator: CliTranslationService;
|
|
3099
|
+
}
|
|
3100
|
+
/**
|
|
3101
|
+
* Build and populate the service container with all core services.
|
|
3102
|
+
* Takes the registry, pending (user-registered) services, and the drag-drop
|
|
3103
|
+
* service instance, and returns all initialized services ready for wiring
|
|
3104
|
+
* into the execution context.
|
|
3105
|
+
*/
|
|
3106
|
+
declare function initializeServices(options: InitializeServicesOptions): Promise<InitializeServicesResult>;
|
|
3107
|
+
|
|
3108
|
+
/** Service token holding the name of the framework hosting the CLI. */
|
|
3109
|
+
declare const CLI_FRAMEWORK_SERVICE = "cli-framework";
|
|
3110
|
+
/** What a framework wrapper passes to an engine: shared by components, providers and config contexts. */
|
|
3111
|
+
interface CliHostConfig {
|
|
3112
|
+
modules?: ICliModule[];
|
|
3113
|
+
options?: CliEngineOptions;
|
|
3114
|
+
/** Extra services registered by token before start. */
|
|
3115
|
+
services?: Record<string, any>;
|
|
3116
|
+
}
|
|
3117
|
+
interface CreateCliEngineConfig extends CliHostConfig {
|
|
3118
|
+
/** Reported by `version`, `debug` and `feedback`, e.g. 'React'. */
|
|
3119
|
+
framework?: string;
|
|
3120
|
+
/** Terminal state to restore on start. */
|
|
3121
|
+
snapshot?: CliEngineSnapshot;
|
|
3122
|
+
}
|
|
3123
|
+
/**
|
|
3124
|
+
* Create an engine for `container` with the services and modules of a
|
|
3125
|
+
* wrapper registered (in that order). Call `start()` on it.
|
|
3126
|
+
*/
|
|
3127
|
+
declare function createCliEngine(container: HTMLElement, config?: CreateCliEngineConfig): CliEngine;
|
|
3128
|
+
/**
|
|
3129
|
+
* Resolve a component's config: each field set locally wins over the one
|
|
3130
|
+
* inherited from a surrounding config provider.
|
|
3131
|
+
*/
|
|
3132
|
+
declare function resolveCliHostConfig(local: CliHostConfig, inherited?: CliHostConfig | null): CliHostConfig;
|
|
3133
|
+
/** Merge option objects key by key: `local` overrides `inherited`. */
|
|
3134
|
+
declare function mergeCliOptions<T extends object>(local: T | undefined, inherited: object | undefined): T | undefined;
|
|
3135
|
+
|
|
2020
3136
|
declare class CliServerConnection {
|
|
2021
3137
|
private readonly _config;
|
|
2022
3138
|
private readonly _backgroundServices?;
|
|
2023
3139
|
private readonly _logger?;
|
|
3140
|
+
private readonly _authService?;
|
|
2024
3141
|
private _connected;
|
|
2025
3142
|
private _commands;
|
|
2026
3143
|
private _capabilities;
|
|
2027
3144
|
private _eventSocket;
|
|
3145
|
+
private _apiVersion;
|
|
3146
|
+
private _basePath;
|
|
3147
|
+
private _wsReconnectAttempts;
|
|
3148
|
+
private _wsReconnectTimer;
|
|
3149
|
+
/** True once this connection registered its `server-events:<name>` background service */
|
|
3150
|
+
private _eventServiceRegistered;
|
|
3151
|
+
private static readonly WS_MAX_RECONNECT_ATTEMPTS;
|
|
3152
|
+
private static readonly WS_MAX_RECONNECT_DELAY_MS;
|
|
3153
|
+
private _healthCheckTimer;
|
|
3154
|
+
private _healthCheckAttempts;
|
|
3155
|
+
private static readonly HEALTH_CHECK_INTERVAL_MS;
|
|
3156
|
+
private static readonly HEALTH_CHECK_MAX_ATTEMPTS;
|
|
2028
3157
|
onDisconnect?: () => void;
|
|
2029
|
-
|
|
3158
|
+
onReconnected?: () => void;
|
|
3159
|
+
constructor(_config: CliServerConfig, _backgroundServices?: ICliBackgroundServiceRegistry, _logger?: ICliLogger, _authService?: ICliServerAuthService);
|
|
2030
3160
|
get config(): CliServerConfig;
|
|
2031
3161
|
get connected(): boolean;
|
|
2032
3162
|
get commands(): CliServerCommandDescriptor[];
|
|
2033
3163
|
get capabilities(): CliServerCapabilities | null;
|
|
3164
|
+
get apiVersion(): number;
|
|
3165
|
+
/**
|
|
3166
|
+
* Resolve auth headers for this server connection.
|
|
3167
|
+
* Uses the auth service (which merges config headers with registered
|
|
3168
|
+
* ICliServerAuthTokenProviders), or falls back to config headers directly.
|
|
3169
|
+
*/
|
|
3170
|
+
resolveAuthHeaders(): Record<string, string>;
|
|
3171
|
+
/**
|
|
3172
|
+
* WebSocket URL for this server with auth: single-use upgrade params from
|
|
3173
|
+
* auth providers when available, otherwise headers copied into the URL.
|
|
3174
|
+
*/
|
|
3175
|
+
buildWebSocketUrl(path: string): Promise<string>;
|
|
2034
3176
|
connect(): Promise<void>;
|
|
2035
3177
|
disconnect(): void;
|
|
3178
|
+
startHealthCheck(): void;
|
|
3179
|
+
private scheduleNextHealthCheck;
|
|
3180
|
+
stopHealthCheck(): void;
|
|
2036
3181
|
fetchCommands(): Promise<CliServerCommandDescriptor[]>;
|
|
2037
3182
|
fetchCapabilities(): Promise<CliServerCapabilities | null>;
|
|
2038
3183
|
execute(command: CliProcessCommand): Promise<CliServerResponse>;
|
|
3184
|
+
executeStream(command: CliProcessCommand, onOutput: (output: CliServerOutput) => void): Promise<{
|
|
3185
|
+
exitCode: number;
|
|
3186
|
+
}>;
|
|
2039
3187
|
ping(): Promise<boolean>;
|
|
3188
|
+
/** Whether the server answers HTTP at all (any status: it is running). */
|
|
3189
|
+
private answers;
|
|
2040
3190
|
private connectEventSocket;
|
|
2041
3191
|
private connectEventSocketDirect;
|
|
3192
|
+
private connectEventSocketDirectAsync;
|
|
3193
|
+
/**
|
|
3194
|
+
* The server closes the event socket with 4401 when the session behind it
|
|
3195
|
+
* ended (logout, revoke, expiry). Retrying with the same credentials cannot
|
|
3196
|
+
* succeed; the auth layer reconnects the server when the session changes.
|
|
3197
|
+
*/
|
|
3198
|
+
private isSessionEndedClose;
|
|
2042
3199
|
private handleServerDisconnect;
|
|
2043
3200
|
private closeEventSocket;
|
|
2044
3201
|
private closeEventSocketDirect;
|
|
3202
|
+
private scheduleWsReconnect;
|
|
3203
|
+
private httpFetchWithRetry;
|
|
2045
3204
|
private httpFetch;
|
|
2046
3205
|
private normalizeUrl;
|
|
2047
3206
|
private toWebSocketUrl;
|
|
2048
3207
|
}
|
|
2049
3208
|
|
|
2050
3209
|
/**
|
|
2051
|
-
*
|
|
2052
|
-
* Shared by both single-proxy and multi-proxy processors.
|
|
3210
|
+
* Render a single CliServerOutput to the terminal.
|
|
2053
3211
|
*/
|
|
2054
|
-
declare function
|
|
3212
|
+
declare function renderSingleOutput(output: CliServerOutput, context: ICliExecutionContext): void;
|
|
2055
3213
|
/**
|
|
2056
3214
|
* Render a CliServerResponse to the terminal.
|
|
2057
3215
|
*/
|
|
2058
3216
|
declare function renderServerResponse(response: CliServerResponse, context: ICliExecutionContext): void;
|
|
3217
|
+
/**
|
|
3218
|
+
* Execute a command on a specific server connection and render the response.
|
|
3219
|
+
* Shared by both single-proxy and multi-proxy processors.
|
|
3220
|
+
*/
|
|
3221
|
+
declare function executeOnServer(connection: CliServerConnection, serverName: string, descriptor: CliServerCommandDescriptor, command: CliProcessCommand, context: ICliExecutionContext, commandPath?: string[]): Promise<void>;
|
|
2059
3222
|
declare class CliServerProxyProcessor implements ICliCommandProcessor {
|
|
2060
3223
|
private readonly connection;
|
|
2061
3224
|
private readonly descriptor;
|
|
@@ -2065,9 +3228,12 @@ declare class CliServerProxyProcessor implements ICliCommandProcessor {
|
|
|
2065
3228
|
description?: string;
|
|
2066
3229
|
version?: string;
|
|
2067
3230
|
metadata?: CliProcessorMetadata;
|
|
2068
|
-
parameters?: ICliCommandParameterDescriptor[];
|
|
3231
|
+
parameters?: ICliCommandParameterDescriptor$1[];
|
|
2069
3232
|
processors?: ICliCommandProcessor[];
|
|
2070
|
-
|
|
3233
|
+
acceptsRawInput?: boolean;
|
|
3234
|
+
/** Full command path from root to this processor (e.g. ["aws", "lambda", "list"]) */
|
|
3235
|
+
private readonly commandPath;
|
|
3236
|
+
constructor(connection: CliServerConnection, descriptor: CliServerCommandDescriptor, serverName: string, isNested?: boolean, parentPath?: string[]);
|
|
2071
3237
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
2072
3238
|
}
|
|
2073
3239
|
|
|
@@ -2091,22 +3257,30 @@ declare class CliServerMultiProxyProcessor implements ICliCommandProcessor {
|
|
|
2091
3257
|
command: string;
|
|
2092
3258
|
description?: string;
|
|
2093
3259
|
metadata?: CliProcessorMetadata;
|
|
2094
|
-
parameters?: ICliCommandParameterDescriptor[];
|
|
3260
|
+
parameters?: ICliCommandParameterDescriptor$1[];
|
|
2095
3261
|
processors?: ICliCommandProcessor[];
|
|
2096
|
-
|
|
3262
|
+
acceptsRawInput?: boolean;
|
|
3263
|
+
/** Full command path from root to this processor */
|
|
3264
|
+
private readonly commandPath;
|
|
3265
|
+
constructor(entries: MultiProxyEntry[], provider: DefaultServerProvider, parentPath?: string[]);
|
|
2097
3266
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
2098
3267
|
}
|
|
2099
3268
|
|
|
2100
|
-
declare const CliServerManager_TOKEN
|
|
3269
|
+
declare const CliServerManager_TOKEN: any;
|
|
2101
3270
|
declare class CliServerManager implements DefaultServerProvider {
|
|
2102
3271
|
private readonly registry;
|
|
3272
|
+
private readonly authService?;
|
|
3273
|
+
private readonly events?;
|
|
2103
3274
|
readonly connections: Map<string, CliServerConnection>;
|
|
2104
3275
|
private _logger?;
|
|
2105
3276
|
private _cliLogger?;
|
|
2106
3277
|
private _defaultServer;
|
|
3278
|
+
/** Bare-name aliases this manager registered (only these are ever removed) */
|
|
3279
|
+
private readonly _bareAliases;
|
|
2107
3280
|
private _backgroundServices?;
|
|
2108
|
-
constructor(registry: ICliCommandProcessorRegistry);
|
|
3281
|
+
constructor(registry: ICliCommandProcessorRegistry, authService?: ICliServerAuthService, events?: ICliEventBus);
|
|
2109
3282
|
get defaultServer(): string | null;
|
|
3283
|
+
preferredServer(): string | null;
|
|
2110
3284
|
setDefaultServer(name: string | null): void;
|
|
2111
3285
|
connectAll(servers: CliServerConfig[], logger?: {
|
|
2112
3286
|
warn(msg: string): void;
|
|
@@ -2117,6 +3291,7 @@ declare class CliServerManager implements DefaultServerProvider {
|
|
|
2117
3291
|
commandCount: number;
|
|
2118
3292
|
}>;
|
|
2119
3293
|
getConnection(name: string): CliServerConnection | undefined;
|
|
3294
|
+
private emitConnected;
|
|
2120
3295
|
private handleDisconnect;
|
|
2121
3296
|
private unregisterServerProcessors;
|
|
2122
3297
|
private unregisterBareAliases;
|
|
@@ -2126,37 +3301,60 @@ declare class CliServerManager implements DefaultServerProvider {
|
|
|
2126
3301
|
|
|
2127
3302
|
declare function createServerModule(): ICliModule;
|
|
2128
3303
|
|
|
3304
|
+
/**
|
|
3305
|
+
* `server`: the servers this terminal is connected to (configured by the
|
|
3306
|
+
* app in `options.servers`). Their commands are available directly (`echo`)
|
|
3307
|
+
* and namespaced (`node:echo`).
|
|
3308
|
+
*/
|
|
2129
3309
|
declare class CliServerCommandProcessor implements ICliCommandProcessor {
|
|
2130
3310
|
command: string;
|
|
3311
|
+
aliases: string[];
|
|
2131
3312
|
description: string;
|
|
2132
3313
|
metadata: {
|
|
2133
|
-
icon:
|
|
3314
|
+
icon: any;
|
|
2134
3315
|
module: string;
|
|
2135
3316
|
sealed: boolean;
|
|
2136
3317
|
};
|
|
3318
|
+
stateConfiguration: CliStateConfiguration;
|
|
2137
3319
|
processors: ICliCommandChildProcessor[];
|
|
3320
|
+
/** Restore the default server saved by `server default <name>`. */
|
|
3321
|
+
initialize(context: ICliExecutionContext): Promise<void>;
|
|
3322
|
+
/** `server` alone: the servers, then what can be done with them. */
|
|
2138
3323
|
processCommand(_command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
3324
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
2139
3325
|
}
|
|
2140
3326
|
|
|
2141
3327
|
declare class CliSshCommandProcessor implements ICliCommandProcessor {
|
|
2142
3328
|
command: string;
|
|
3329
|
+
aliases: string[];
|
|
2143
3330
|
description: string;
|
|
2144
3331
|
acceptsRawInput: boolean;
|
|
2145
3332
|
valueRequired: boolean;
|
|
2146
3333
|
metadata: CliProcessorMetadata;
|
|
2147
|
-
parameters?: ICliCommandParameterDescriptor[];
|
|
2148
|
-
private socket;
|
|
2149
|
-
private context;
|
|
3334
|
+
parameters?: ICliCommandParameterDescriptor$1[];
|
|
2150
3335
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
3336
|
+
/**
|
|
3337
|
+
* Full-screen handler for one session: input, resize and disposal go to
|
|
3338
|
+
* that session's socket only.
|
|
3339
|
+
*/
|
|
3340
|
+
private fullScreenHandler;
|
|
2154
3341
|
private resolveServer;
|
|
3342
|
+
/** Why `name` cannot be used: unknown, unreachable or without a shell. */
|
|
3343
|
+
private writeWhyNotAvailable;
|
|
3344
|
+
/** No server has a shell: say whether none is configured, connected or shell-enabled. */
|
|
3345
|
+
private writeNoShellServers;
|
|
3346
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
2155
3347
|
private executeInteractive;
|
|
2156
3348
|
private executeOneShot;
|
|
3349
|
+
/** `ssh <server> <cmd...>` → `<cmd...>` exactly as typed */
|
|
3350
|
+
private remoteCommandFromRaw;
|
|
2157
3351
|
private buildShellUrl;
|
|
2158
3352
|
private cleanup;
|
|
2159
3353
|
}
|
|
3354
|
+
declare function describeShellClose(event: {
|
|
3355
|
+
code?: number;
|
|
3356
|
+
reason?: string;
|
|
3357
|
+
}, serverName: string): string | null;
|
|
2160
3358
|
|
|
2161
3359
|
/**
|
|
2162
3360
|
* Result of executing a command through the test harness.
|
|
@@ -2202,20 +3400,30 @@ declare class CliTestHarness {
|
|
|
2202
3400
|
readonly registry: CliCommandProcessorRegistry;
|
|
2203
3401
|
readonly executor: CliCommandExecutor;
|
|
2204
3402
|
readonly services: CliServiceContainer;
|
|
3403
|
+
/** Shared by every command: add a language pack and switch locale to test translations. */
|
|
3404
|
+
readonly translator: CliTranslationService;
|
|
2205
3405
|
private readonly stateStoreManager;
|
|
3406
|
+
private readonly initialized;
|
|
2206
3407
|
private readonly processRegistry;
|
|
2207
3408
|
/** Current user session — set via setUserSession() */
|
|
2208
3409
|
userSession?: ICliUserSession;
|
|
2209
3410
|
/** Reader responses — set via setReaderResponses() for interactive commands */
|
|
2210
3411
|
private readerResponses;
|
|
3412
|
+
private userSessionProvider?;
|
|
2211
3413
|
constructor();
|
|
3414
|
+
/**
|
|
3415
|
+
* Resolve `context.userSession` on every command from this function
|
|
3416
|
+
* (e.g. a session service), instead of the value set via setUserSession().
|
|
3417
|
+
*/
|
|
3418
|
+
setUserSessionProvider(provider: () => ICliUserSession | undefined): void;
|
|
2212
3419
|
/**
|
|
2213
3420
|
* Register a service in the test container.
|
|
2214
3421
|
*/
|
|
2215
3422
|
registerService(token: any, value: any): void;
|
|
2216
3423
|
/**
|
|
2217
3424
|
* Register a command processor. If the processor has an `initialize()`
|
|
2218
|
-
* method, it
|
|
3425
|
+
* method, it is called (with the processor's own state store, as in the
|
|
3426
|
+
* engine) before the first `execute()`, or by `initializeProcessors()`.
|
|
2219
3427
|
*/
|
|
2220
3428
|
registerProcessor(processor: ICliCommandProcessor): void;
|
|
2221
3429
|
/**
|
|
@@ -2227,6 +3435,8 @@ declare class CliTestHarness {
|
|
|
2227
3435
|
* Call this after registering all services and processors.
|
|
2228
3436
|
*/
|
|
2229
3437
|
initializeProcessors(): Promise<void>;
|
|
3438
|
+
/** As the engine's boot: link sub-commands to their parent, then initialize. */
|
|
3439
|
+
private initializeTree;
|
|
2230
3440
|
/**
|
|
2231
3441
|
* Set the active user session. Commands that check `context.userSession`
|
|
2232
3442
|
* will see this session.
|
|
@@ -2301,4 +3511,511 @@ declare function getAccelerator(): ICliWasmAccelerator;
|
|
|
2301
3511
|
*/
|
|
2302
3512
|
declare function isWasmAccelerated(): boolean;
|
|
2303
3513
|
|
|
2304
|
-
|
|
3514
|
+
/** One terminal inside a tab. */
|
|
3515
|
+
interface CliPanelPane {
|
|
3516
|
+
id: number;
|
|
3517
|
+
widthPercent: number;
|
|
3518
|
+
/** Snapshot to restore when the pane's engine starts (used by "Duplicate"). */
|
|
3519
|
+
snapshot?: CliEngineSnapshot;
|
|
3520
|
+
}
|
|
3521
|
+
/** One tab of the panel: a title and one or more panes side by side. */
|
|
3522
|
+
interface CliPanelTab {
|
|
3523
|
+
id: number;
|
|
3524
|
+
title: string;
|
|
3525
|
+
isEditing: boolean;
|
|
3526
|
+
panes: CliPanelPane[];
|
|
3527
|
+
}
|
|
3528
|
+
interface CliPanelContextMenu {
|
|
3529
|
+
visible: boolean;
|
|
3530
|
+
x: number;
|
|
3531
|
+
y: number;
|
|
3532
|
+
tabId: number;
|
|
3533
|
+
}
|
|
3534
|
+
interface CliPanelServiceDetail {
|
|
3535
|
+
name: string;
|
|
3536
|
+
status: string;
|
|
3537
|
+
description?: string;
|
|
3538
|
+
}
|
|
3539
|
+
interface CliPanelServerDetail {
|
|
3540
|
+
name: string;
|
|
3541
|
+
url: string;
|
|
3542
|
+
connected: boolean;
|
|
3543
|
+
apiVersion?: string;
|
|
3544
|
+
commandCount?: number;
|
|
3545
|
+
}
|
|
3546
|
+
type CliPanelExecutionState = 'idle' | 'running';
|
|
3547
|
+
type CliPanelServerState = 'connected' | 'disconnected' | 'none';
|
|
3548
|
+
/** Status derived from the engines of a single tab. */
|
|
3549
|
+
interface CliPanelTabStatus {
|
|
3550
|
+
executionState: CliPanelExecutionState;
|
|
3551
|
+
lastCommand: {
|
|
3552
|
+
name: string;
|
|
3553
|
+
success: boolean;
|
|
3554
|
+
} | null;
|
|
3555
|
+
notification: CliNotification | null;
|
|
3556
|
+
}
|
|
3557
|
+
/** Status derived from the first engine of the active tab. */
|
|
3558
|
+
interface CliPanelGlobalStatus {
|
|
3559
|
+
serviceCount: {
|
|
3560
|
+
running: number;
|
|
3561
|
+
total: number;
|
|
3562
|
+
};
|
|
3563
|
+
serviceDetails: CliPanelServiceDetail[];
|
|
3564
|
+
serverState: CliPanelServerState;
|
|
3565
|
+
serverDetails: CliPanelServerDetail[];
|
|
3566
|
+
/** Milliseconds since the engine started, 0 when unknown. */
|
|
3567
|
+
uptime: number;
|
|
3568
|
+
}
|
|
3569
|
+
declare const DEFAULT_TAB_STATUS: CliPanelTabStatus;
|
|
3570
|
+
declare const DEFAULT_GLOBAL_STATUS: CliPanelGlobalStatus;
|
|
3571
|
+
/**
|
|
3572
|
+
* Values a host may control from the outside. A defined value wins over the
|
|
3573
|
+
* panel's own state; `undefined` leaves the panel uncontrolled for that field.
|
|
3574
|
+
*/
|
|
3575
|
+
interface CliPanelControlledState {
|
|
3576
|
+
collapsed?: boolean;
|
|
3577
|
+
hidden?: boolean;
|
|
3578
|
+
maximized?: boolean;
|
|
3579
|
+
activeTabId?: number;
|
|
3580
|
+
position?: CliPanelPosition;
|
|
3581
|
+
height?: number;
|
|
3582
|
+
width?: number;
|
|
3583
|
+
}
|
|
3584
|
+
/** Change notifications and structural events, mapped by each framework wrapper. */
|
|
3585
|
+
interface CliPanelCallbacks {
|
|
3586
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
3587
|
+
onHiddenChange?: (hidden: boolean) => void;
|
|
3588
|
+
onMaximizedChange?: (maximized: boolean) => void;
|
|
3589
|
+
onActiveTabIdChange?: (tabId: number) => void;
|
|
3590
|
+
onPositionChange?: (position: CliPanelPosition) => void;
|
|
3591
|
+
onHeightChange?: (height: number) => void;
|
|
3592
|
+
onWidthChange?: (width: number) => void;
|
|
3593
|
+
onClose?: () => void;
|
|
3594
|
+
onTabAdded?: (event: {
|
|
3595
|
+
tabId: number;
|
|
3596
|
+
}) => void;
|
|
3597
|
+
onTabClosed?: (event: {
|
|
3598
|
+
tabId: number;
|
|
3599
|
+
}) => void;
|
|
3600
|
+
onPaneSplit?: (event: {
|
|
3601
|
+
paneId: number;
|
|
3602
|
+
tabId: number;
|
|
3603
|
+
}) => void;
|
|
3604
|
+
onPaneClosed?: (event: {
|
|
3605
|
+
paneId: number;
|
|
3606
|
+
}) => void;
|
|
3607
|
+
}
|
|
3608
|
+
interface CliPanelViewport {
|
|
3609
|
+
width: number;
|
|
3610
|
+
height: number;
|
|
3611
|
+
}
|
|
3612
|
+
interface CliPanelControllerOptions {
|
|
3613
|
+
/** Panel configuration (initial state, chrome buttons, theme sync). */
|
|
3614
|
+
config?: CliPanelConfig;
|
|
3615
|
+
callbacks?: CliPanelCallbacks;
|
|
3616
|
+
controlled?: CliPanelControlledState;
|
|
3617
|
+
/** Viewport size used for maximize and resize clamping. Defaults to `window`. */
|
|
3618
|
+
viewport?: () => CliPanelViewport;
|
|
3619
|
+
/**
|
|
3620
|
+
* Restore and persist the position through localStorage.
|
|
3621
|
+
* @default true
|
|
3622
|
+
*/
|
|
3623
|
+
persistPosition?: boolean;
|
|
3624
|
+
}
|
|
3625
|
+
/**
|
|
3626
|
+
* Immutable view of the whole panel. A new object is produced on every
|
|
3627
|
+
* change, so views can compare by reference.
|
|
3628
|
+
*/
|
|
3629
|
+
interface CliPanelSnapshot {
|
|
3630
|
+
visible: boolean;
|
|
3631
|
+
/** True once the first tab has been created (content rendered). */
|
|
3632
|
+
initialized: boolean;
|
|
3633
|
+
collapsed: boolean;
|
|
3634
|
+
hidden: boolean;
|
|
3635
|
+
maximized: boolean;
|
|
3636
|
+
position: CliPanelPosition;
|
|
3637
|
+
height: number;
|
|
3638
|
+
width: number;
|
|
3639
|
+
isHorizontal: boolean;
|
|
3640
|
+
/** Status text is shown in the header for top/bottom, compact dots otherwise. */
|
|
3641
|
+
showStatusIndicators: boolean;
|
|
3642
|
+
panelResizing: boolean;
|
|
3643
|
+
themeStyles: Record<string, string>;
|
|
3644
|
+
closable: boolean;
|
|
3645
|
+
resizable: boolean;
|
|
3646
|
+
hideable: boolean;
|
|
3647
|
+
hideAlignment: CliPanelHideAlignment;
|
|
3648
|
+
syncTheme: boolean;
|
|
3649
|
+
tabs: readonly CliPanelTab[];
|
|
3650
|
+
activeTabId: number;
|
|
3651
|
+
activePaneId: number;
|
|
3652
|
+
paneResizing: boolean;
|
|
3653
|
+
contextMenu: CliPanelContextMenu;
|
|
3654
|
+
positionDropdownOpen: boolean;
|
|
3655
|
+
servicesDropdownOpen: boolean;
|
|
3656
|
+
servicesDropdownStyle: Record<string, string>;
|
|
3657
|
+
serversDropdownOpen: boolean;
|
|
3658
|
+
serversDropdownStyle: Record<string, string>;
|
|
3659
|
+
/** Status of the active tab. */
|
|
3660
|
+
status: CliPanelTabStatus;
|
|
3661
|
+
tabStatuses: Readonly<Record<number, CliPanelTabStatus>>;
|
|
3662
|
+
global: CliPanelGlobalStatus;
|
|
3663
|
+
formattedUptime: string;
|
|
3664
|
+
}
|
|
3665
|
+
|
|
3666
|
+
declare const MIN_PANE_WIDTH_PERCENT = 10;
|
|
3667
|
+
declare const MIN_PANEL_SIZE = 100;
|
|
3668
|
+
declare const DEFAULT_PANEL_HEIGHT = 600;
|
|
3669
|
+
declare const DEFAULT_PANEL_WIDTH = 400;
|
|
3670
|
+
declare const PANEL_POSITIONS: readonly CliPanelPosition[];
|
|
3671
|
+
/** Scale pane widths so they add up to 100. Returns new pane objects. */
|
|
3672
|
+
declare function normalizePaneWidths(panes: readonly CliPanelPane[]): CliPanelPane[];
|
|
3673
|
+
/** Give every pane the same width. Returns new pane objects. */
|
|
3674
|
+
declare function distributePaneWidths(panes: readonly CliPanelPane[]): CliPanelPane[];
|
|
3675
|
+
/**
|
|
3676
|
+
* Move the divider between pane `dividerIndex` and `dividerIndex + 1` by
|
|
3677
|
+
* `deltaPercent`, keeping both panes at least `MIN_PANE_WIDTH_PERCENT` wide.
|
|
3678
|
+
*/
|
|
3679
|
+
declare function resizePaneWidths(startWidths: readonly number[], dividerIndex: number, deltaPercent: number): number[];
|
|
3680
|
+
/** Clamp a dragged panel size between the minimum and the viewport. */
|
|
3681
|
+
declare function clampPanelSize(size: number, max: number): number;
|
|
3682
|
+
/**
|
|
3683
|
+
* New panel size for a drag that started at `start` and moved by
|
|
3684
|
+
* (`deltaX`, `deltaY`). Only the axis matching the position matters.
|
|
3685
|
+
*/
|
|
3686
|
+
declare function resizedPanelSize(position: CliPanelPosition, start: {
|
|
3687
|
+
width: number;
|
|
3688
|
+
height: number;
|
|
3689
|
+
}, deltaX: number, deltaY: number, viewport: CliPanelViewport): {
|
|
3690
|
+
width?: number;
|
|
3691
|
+
height?: number;
|
|
3692
|
+
};
|
|
3693
|
+
interface AnchorRect {
|
|
3694
|
+
top: number;
|
|
3695
|
+
bottom: number;
|
|
3696
|
+
left: number;
|
|
3697
|
+
right: number;
|
|
3698
|
+
}
|
|
3699
|
+
/**
|
|
3700
|
+
* Fixed-position style for a dropdown opened from `anchor`, placed on the
|
|
3701
|
+
* side of the panel that faces the page.
|
|
3702
|
+
*/
|
|
3703
|
+
declare function dropdownAnchorStyle(anchor: AnchorRect, position: CliPanelPosition, viewport: CliPanelViewport): Record<string, string>;
|
|
3704
|
+
/** "12m", "1h05m"-style uptime label. */
|
|
3705
|
+
declare function formatUptime(ms: number): string;
|
|
3706
|
+
declare function isHorizontalPosition(position: CliPanelPosition): boolean;
|
|
3707
|
+
|
|
3708
|
+
/** Poll interval for execution state, last command and notifications. */
|
|
3709
|
+
declare const EXEC_POLL_MS = 300;
|
|
3710
|
+
/** Poll interval for services, servers and uptime. */
|
|
3711
|
+
declare const GLOBAL_POLL_MS = 2000;
|
|
3712
|
+
/** Status of a tab from all of its pane engines. */
|
|
3713
|
+
declare function computeTabStatus(engines: Iterable<CliEngine>): CliPanelTabStatus;
|
|
3714
|
+
/** Services, servers and uptime of one engine. */
|
|
3715
|
+
declare function computeGlobalStatus(engine: CliEngine | undefined, now?: number): CliPanelGlobalStatus;
|
|
3716
|
+
interface CliPanelStatusTrackerListener {
|
|
3717
|
+
onTabStatus(tabId: number, status: CliPanelTabStatus): void;
|
|
3718
|
+
onGlobalStatus(status: CliPanelGlobalStatus): void;
|
|
3719
|
+
}
|
|
3720
|
+
/**
|
|
3721
|
+
* Watches the engines of every tab and reports status changes. Execution
|
|
3722
|
+
* state is polled quickly, services and servers slowly; engine events
|
|
3723
|
+
* (notifier, background services) trigger an immediate refresh.
|
|
3724
|
+
*/
|
|
3725
|
+
declare class CliPanelStatusTracker {
|
|
3726
|
+
private readonly listener;
|
|
3727
|
+
private tabs;
|
|
3728
|
+
private activeTabId?;
|
|
3729
|
+
private globalStatus;
|
|
3730
|
+
private execTimer?;
|
|
3731
|
+
private globalTimer?;
|
|
3732
|
+
constructor(listener: CliPanelStatusTrackerListener);
|
|
3733
|
+
registerEngine(tabId: number, paneId: number, engine: CliEngine): void;
|
|
3734
|
+
unregisterPane(paneId: number): void;
|
|
3735
|
+
unregisterTab(tabId: number): void;
|
|
3736
|
+
setActiveTab(tabId: number): void;
|
|
3737
|
+
/** Recompute everything now. */
|
|
3738
|
+
refresh(): void;
|
|
3739
|
+
destroy(): void;
|
|
3740
|
+
private ensurePolling;
|
|
3741
|
+
private stopPolling;
|
|
3742
|
+
private refreshTab;
|
|
3743
|
+
private refreshGlobal;
|
|
3744
|
+
}
|
|
3745
|
+
|
|
3746
|
+
/**
|
|
3747
|
+
* Framework-agnostic state and behaviour of the collapsible CLI panel:
|
|
3748
|
+
* tabs and panes, chrome (collapse, hide, maximize, position, size),
|
|
3749
|
+
* menus, drag resizing, theme sync and the status bar.
|
|
3750
|
+
*
|
|
3751
|
+
* Views subscribe with {@link subscribe} and render {@link getSnapshot};
|
|
3752
|
+
* every change produces a new immutable snapshot. Hosts may control any of
|
|
3753
|
+
* the bindable values through {@link setControlled}; the matching
|
|
3754
|
+
* `onXChange` callback is invoked whenever the panel wants to change it.
|
|
3755
|
+
*/
|
|
3756
|
+
declare class CliPanelController implements ICliPanelRef<CliEngine> {
|
|
3757
|
+
callbacks: CliPanelCallbacks;
|
|
3758
|
+
private snapshot;
|
|
3759
|
+
private internal;
|
|
3760
|
+
private controlled;
|
|
3761
|
+
private readonly listeners;
|
|
3762
|
+
private readonly engines;
|
|
3763
|
+
private readonly tracker;
|
|
3764
|
+
private readonly viewport;
|
|
3765
|
+
private readonly persistPosition;
|
|
3766
|
+
private nextTabId;
|
|
3767
|
+
private nextPaneId;
|
|
3768
|
+
private preHideCollapsed;
|
|
3769
|
+
private previousHeight;
|
|
3770
|
+
private previousWidth;
|
|
3771
|
+
private panelDrag?;
|
|
3772
|
+
private paneDrag?;
|
|
3773
|
+
private documentListenersAttached;
|
|
3774
|
+
private rootElement;
|
|
3775
|
+
private themeObserver?;
|
|
3776
|
+
constructor(options?: CliPanelControllerOptions);
|
|
3777
|
+
readonly subscribe: (listener: () => void) => (() => void);
|
|
3778
|
+
readonly getSnapshot: () => CliPanelSnapshot;
|
|
3779
|
+
/** Apply a new panel configuration (chrome buttons, theme sync). */
|
|
3780
|
+
setOptions(config: CliPanelConfig | undefined): void;
|
|
3781
|
+
/** Replace the change callbacks (wrappers call this when their props change). */
|
|
3782
|
+
setCallbacks(callbacks: CliPanelCallbacks): void;
|
|
3783
|
+
/** Update host-controlled values. Unchanged values are ignored. */
|
|
3784
|
+
setControlled(values: CliPanelControlledState): void;
|
|
3785
|
+
/** Element containing the terminals, used for theme sync. */
|
|
3786
|
+
setRootElement(element: ParentNode | null): void;
|
|
3787
|
+
/**
|
|
3788
|
+
* Stop timers, observers and document listeners. Engines are not
|
|
3789
|
+
* destroyed (their views own them). Registering an engine again
|
|
3790
|
+
* restarts status tracking, so a remounted view can reuse the controller.
|
|
3791
|
+
*/
|
|
3792
|
+
destroy(): void;
|
|
3793
|
+
/** Header collapse button: expand (creating the first tab) or collapse. */
|
|
3794
|
+
toggle(): void;
|
|
3795
|
+
open(): void;
|
|
3796
|
+
collapse(): void;
|
|
3797
|
+
toggleCollapse(): void;
|
|
3798
|
+
hide(): void;
|
|
3799
|
+
unhide(): void;
|
|
3800
|
+
toggleHide(): void;
|
|
3801
|
+
close(): void;
|
|
3802
|
+
maximize(): void;
|
|
3803
|
+
restore(): void;
|
|
3804
|
+
toggleMaximize(): void;
|
|
3805
|
+
resize(dimensions: {
|
|
3806
|
+
height?: number;
|
|
3807
|
+
width?: number;
|
|
3808
|
+
}): void;
|
|
3809
|
+
setPosition(position: CliPanelPosition): void;
|
|
3810
|
+
addTab(title?: string): number;
|
|
3811
|
+
closeTab(tabId: number): void;
|
|
3812
|
+
selectTab(tabId: number): void;
|
|
3813
|
+
renameTab(tabId: number, title: string): void;
|
|
3814
|
+
/** Switch a tab's title into inline editing. */
|
|
3815
|
+
startRename(tabId: number): void;
|
|
3816
|
+
/** Finish inline editing; an empty value keeps the old title. */
|
|
3817
|
+
commitRename(tabId: number, value: string): void;
|
|
3818
|
+
cancelRename(): void;
|
|
3819
|
+
/** Open a new tab next to `tabId` with a copy of its first terminal's content. */
|
|
3820
|
+
duplicateTab(tabId: number): number;
|
|
3821
|
+
closeOtherTabs(tabId: number): void;
|
|
3822
|
+
closeTabsToTheRight(tabId: number): void;
|
|
3823
|
+
closeAllTabs(): void;
|
|
3824
|
+
splitPane(tabId?: number): number;
|
|
3825
|
+
closePane(paneId: number): void;
|
|
3826
|
+
/** A pane was clicked: make it (and its tab) active and focus its terminal. */
|
|
3827
|
+
activatePane(tabId: number, paneId: number): void;
|
|
3828
|
+
/** Called by the view once a pane's terminal engine is running. */
|
|
3829
|
+
registerEngine(tabId: number, paneId: number, engine: CliEngine): void;
|
|
3830
|
+
getEngine(paneId?: number): CliEngine | undefined;
|
|
3831
|
+
getState(): CliPanelState;
|
|
3832
|
+
openContextMenu(tabId: number, x: number, y: number): void;
|
|
3833
|
+
closeContextMenu(): void;
|
|
3834
|
+
togglePositionDropdown(): void;
|
|
3835
|
+
/** `anchor` is the clicked status item; the dropdown is placed next to it. */
|
|
3836
|
+
toggleServicesDropdown(anchor?: Element | null): void;
|
|
3837
|
+
toggleServersDropdown(anchor?: Element | null): void;
|
|
3838
|
+
/** Close the context menu and every dropdown. */
|
|
3839
|
+
closeMenus(): void;
|
|
3840
|
+
/** Mouse down on the panel's resize bar. */
|
|
3841
|
+
startPanelResize(clientX: number, clientY: number): void;
|
|
3842
|
+
/** Mouse down on the divider before pane `dividerIndex + 1` of a tab. */
|
|
3843
|
+
startPaneResize(tabId: number, dividerIndex: number, clientX: number, containerWidth: number): void;
|
|
3844
|
+
private readonly onPanelResizeMove;
|
|
3845
|
+
private readonly onPanelResizeEnd;
|
|
3846
|
+
private endPanelResize;
|
|
3847
|
+
private readonly onPaneResizeMove;
|
|
3848
|
+
private readonly onPaneResizeEnd;
|
|
3849
|
+
private endPaneResize;
|
|
3850
|
+
private readonly onDocumentClick;
|
|
3851
|
+
private readonly onDocumentKeydown;
|
|
3852
|
+
private syncDocumentListeners;
|
|
3853
|
+
private detachDocumentListeners;
|
|
3854
|
+
/** Read the first terminal's theme and derive the panel colours from it. */
|
|
3855
|
+
syncThemeFromEngine(): void;
|
|
3856
|
+
/**
|
|
3857
|
+
* Sync now and follow the first terminal's container: the `theme`
|
|
3858
|
+
* command restyles it, which re-derives the panel colours.
|
|
3859
|
+
* Engines are registered after they start, so their theme is set.
|
|
3860
|
+
*/
|
|
3861
|
+
private startThemeSync;
|
|
3862
|
+
private stopThemeSync;
|
|
3863
|
+
private ensureInitialized;
|
|
3864
|
+
private updateCollapsed;
|
|
3865
|
+
private updateHidden;
|
|
3866
|
+
private updateMaximized;
|
|
3867
|
+
private updateHeight;
|
|
3868
|
+
private updateWidth;
|
|
3869
|
+
private updateActiveTabId;
|
|
3870
|
+
private findTab;
|
|
3871
|
+
private patchTab;
|
|
3872
|
+
/** Remove tabs without touching collapsed/initialized state. */
|
|
3873
|
+
private removeTabs;
|
|
3874
|
+
private releaseTab;
|
|
3875
|
+
private releasePane;
|
|
3876
|
+
private focusPane;
|
|
3877
|
+
private anchorStyle;
|
|
3878
|
+
private setTabStatus;
|
|
3879
|
+
private configFields;
|
|
3880
|
+
/** Resolve controlled values and derived fields on top of a snapshot. */
|
|
3881
|
+
private derive;
|
|
3882
|
+
private commit;
|
|
3883
|
+
}
|
|
3884
|
+
|
|
3885
|
+
/**
|
|
3886
|
+
* Geometry of the panel's SVG icons, shared by every framework wrapper.
|
|
3887
|
+
* All icons use a 24x24 view box, `stroke="currentColor"`, round caps and
|
|
3888
|
+
* joins, and no fill unless a shape says otherwise.
|
|
3889
|
+
*/
|
|
3890
|
+
interface SvgShape {
|
|
3891
|
+
tag: 'polyline' | 'line' | 'rect';
|
|
3892
|
+
attrs: Record<string, string>;
|
|
3893
|
+
}
|
|
3894
|
+
interface SvgIcon {
|
|
3895
|
+
size: number;
|
|
3896
|
+
strokeWidth: number;
|
|
3897
|
+
shapes: SvgShape[];
|
|
3898
|
+
}
|
|
3899
|
+
declare const SVG_VIEW_BOX = "0 0 24 24";
|
|
3900
|
+
declare const SVG_COMMON_ATTRS: Record<string, string>;
|
|
3901
|
+
declare const TERMINAL_ICON: SvgIcon;
|
|
3902
|
+
declare const HIDE_TAB_TERMINAL_ICON: SvgIcon;
|
|
3903
|
+
declare const MAXIMIZE_ICON: SvgIcon;
|
|
3904
|
+
declare const RESTORE_ICON: SvgIcon;
|
|
3905
|
+
declare const CLOSE_ICON: SvgIcon;
|
|
3906
|
+
declare const HIDE_ICON: SvgIcon;
|
|
3907
|
+
/** Chevron that points where the panel body will go when the collapse button is pressed. */
|
|
3908
|
+
declare function collapseChevronIcon(position: CliPanelPosition, collapsed: boolean): SvgIcon;
|
|
3909
|
+
/** Chevron on the small "show CLI" tab, pointing into the page. */
|
|
3910
|
+
declare function hideTabChevronIcon(position: CliPanelPosition): SvgIcon;
|
|
3911
|
+
/** Square with a filled bar on the side the panel is docked to. */
|
|
3912
|
+
declare function positionIcon(position: CliPanelPosition, size?: number): SvgIcon;
|
|
3913
|
+
/** Attributes for the `<svg>` element of an icon. */
|
|
3914
|
+
declare function svgAttrs(icon: SvgIcon): Record<string, string>;
|
|
3915
|
+
|
|
3916
|
+
/**
|
|
3917
|
+
* View helpers shared by the React, Vue and Angular panels: class names,
|
|
3918
|
+
* inline styles, labels and the lists the header and menus are built from.
|
|
3919
|
+
*/
|
|
3920
|
+
declare const PANEL_LABELS: {
|
|
3921
|
+
readonly title: "CLI";
|
|
3922
|
+
readonly showCli: "Show CLI";
|
|
3923
|
+
readonly movePanel: "Move panel";
|
|
3924
|
+
readonly hide: "Hide";
|
|
3925
|
+
readonly maximize: "Maximize";
|
|
3926
|
+
readonly restore: "Restore";
|
|
3927
|
+
readonly expand: "Expand";
|
|
3928
|
+
readonly collapse: "Collapse";
|
|
3929
|
+
readonly close: "Close";
|
|
3930
|
+
readonly newTerminal: "New terminal";
|
|
3931
|
+
readonly closeTab: "Close tab";
|
|
3932
|
+
readonly closePane: "Close pane";
|
|
3933
|
+
readonly servicesHeader: "Background Services";
|
|
3934
|
+
readonly servicesEmpty: "No services registered";
|
|
3935
|
+
readonly serversHeader: "Server Connections";
|
|
3936
|
+
readonly serversEmpty: "No servers configured";
|
|
3937
|
+
};
|
|
3938
|
+
declare const SERVICES_ICON = "\u2699";
|
|
3939
|
+
declare const UPTIME_ICON = "\u2191";
|
|
3940
|
+
declare const SUCCESS_ICON = "\u2713";
|
|
3941
|
+
declare const ERROR_ICON = "\u2717";
|
|
3942
|
+
declare const CLOSE_GLYPH = "\u00D7";
|
|
3943
|
+
declare function capitalize(value: string): string;
|
|
3944
|
+
declare function joinClasses(...classes: Array<string | false | null | undefined>): string;
|
|
3945
|
+
declare function panelWrapperClass(s: CliPanelSnapshot, extra?: string): string;
|
|
3946
|
+
declare function panelTabClass(s: CliPanelSnapshot, tab: CliPanelTab): string;
|
|
3947
|
+
/** Activity dot of a tab: running, last command failed, or idle. */
|
|
3948
|
+
declare function tabDotClass(status: CliPanelTabStatus | undefined): string;
|
|
3949
|
+
declare function panelTabDotClass(s: CliPanelSnapshot, tab: CliPanelTab): string;
|
|
3950
|
+
declare function panesContainerClass(s: CliPanelSnapshot): string;
|
|
3951
|
+
declare function paneClass(s: CliPanelSnapshot, tabId: number, paneId: number): string;
|
|
3952
|
+
declare function glowLineClass(s: CliPanelSnapshot): string;
|
|
3953
|
+
declare function positionDropdownItemClass(s: CliPanelSnapshot, position: CliPanelPosition): string;
|
|
3954
|
+
/** Size, visibility and theme variables of the panel wrapper. */
|
|
3955
|
+
declare function panelWrapperStyle(s: CliPanelSnapshot): Record<string, string>;
|
|
3956
|
+
declare function paneStyle(widthPercent: number): Record<string, string>;
|
|
3957
|
+
declare function contextMenuStyle(s: CliPanelSnapshot): Record<string, string>;
|
|
3958
|
+
interface PanelStatusIndicator {
|
|
3959
|
+
key: 'execution' | 'services' | 'lastCommand' | 'servers' | 'uptime' | 'notification';
|
|
3960
|
+
/** Extra classes on the full item (top/bottom positions). */
|
|
3961
|
+
itemClass: string;
|
|
3962
|
+
/** Extra classes on the compact item (left/right positions). */
|
|
3963
|
+
compactClass: string;
|
|
3964
|
+
/** Class of the leading dot, when the indicator shows a dot. */
|
|
3965
|
+
dotClass?: string;
|
|
3966
|
+
/** Glyph shown before the label, when the indicator shows an icon. */
|
|
3967
|
+
icon?: string;
|
|
3968
|
+
iconClass?: string;
|
|
3969
|
+
label: string;
|
|
3970
|
+
/** Tooltip of the compact variant. */
|
|
3971
|
+
title: string;
|
|
3972
|
+
/** Compact variant shows only this dot (notifications). */
|
|
3973
|
+
compactDotClass?: string;
|
|
3974
|
+
/** Which dropdown a click opens. */
|
|
3975
|
+
dropdown?: 'services' | 'servers';
|
|
3976
|
+
}
|
|
3977
|
+
/** Items of the header status bar, in display order. */
|
|
3978
|
+
declare function statusIndicators(s: CliPanelSnapshot): PanelStatusIndicator[];
|
|
3979
|
+
interface PanelPositionOption {
|
|
3980
|
+
position: CliPanelPosition;
|
|
3981
|
+
label: string;
|
|
3982
|
+
className: string;
|
|
3983
|
+
}
|
|
3984
|
+
declare function positionOptions(s: CliPanelSnapshot): PanelPositionOption[];
|
|
3985
|
+
type PanelContextMenuAction = 'rename' | 'duplicate' | 'split-right' | 'close' | 'close-others' | 'close-right' | 'close-all';
|
|
3986
|
+
interface PanelContextMenuItem {
|
|
3987
|
+
action: PanelContextMenuAction;
|
|
3988
|
+
label: string;
|
|
3989
|
+
disabled: boolean;
|
|
3990
|
+
destructive: boolean;
|
|
3991
|
+
/** Draw a separator above this item. */
|
|
3992
|
+
separatorBefore: boolean;
|
|
3993
|
+
}
|
|
3994
|
+
declare function contextMenuItems(s: CliPanelSnapshot): PanelContextMenuItem[];
|
|
3995
|
+
/** Run a context-menu action against the tab the menu was opened for. */
|
|
3996
|
+
declare function runContextMenuAction(controller: CliPanelController, action: PanelContextMenuAction): void;
|
|
3997
|
+
/** Enter commits, Escape cancels an inline tab rename. */
|
|
3998
|
+
declare function handleRenameKey(controller: CliPanelController, tabId: number, key: string, value: string): void;
|
|
3999
|
+
/** Width of the panes container the divider belongs to, for drag math. */
|
|
4000
|
+
declare function panesContainerWidth(target: EventTarget | null): number;
|
|
4001
|
+
interface PanelDropdownRow {
|
|
4002
|
+
key: string;
|
|
4003
|
+
dotClass: string;
|
|
4004
|
+
name: string;
|
|
4005
|
+
description?: string;
|
|
4006
|
+
status: string;
|
|
4007
|
+
/** Extra lines under the status (servers: API version, command count). */
|
|
4008
|
+
meta: string[];
|
|
4009
|
+
}
|
|
4010
|
+
interface PanelStatusDropdown {
|
|
4011
|
+
kind: 'services' | 'servers';
|
|
4012
|
+
header: string;
|
|
4013
|
+
emptyText: string;
|
|
4014
|
+
style: Record<string, string>;
|
|
4015
|
+
rows: PanelDropdownRow[];
|
|
4016
|
+
}
|
|
4017
|
+
/** The open services or servers dropdown, or null when neither is open. */
|
|
4018
|
+
declare function openStatusDropdown(s: CliPanelSnapshot): PanelStatusDropdown | null;
|
|
4019
|
+
|
|
4020
|
+
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 };
|
|
4021
|
+
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 };
|