@travisennis/acai 0.0.3 → 0.0.5
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 +225 -6
- package/dist/api/exa/index.d.ts +177 -0
- package/dist/api/exa/index.d.ts.map +1 -0
- package/dist/api/exa/index.js +439 -0
- package/dist/cli.d.ts +3 -2
- package/dist/cli.d.ts.map +1 -0
- package/dist/commands/application-log-command.d.ts +1 -0
- package/dist/commands/application-log-command.d.ts.map +1 -0
- package/dist/commands/application-log-command.js +5 -3
- package/dist/commands/clear-command.d.ts +1 -0
- package/dist/commands/clear-command.d.ts.map +1 -0
- package/dist/commands/clear-command.js +2 -3
- package/dist/commands/compact-command.d.ts +1 -0
- package/dist/commands/compact-command.d.ts.map +1 -0
- package/dist/commands/compact-command.js +1 -1
- package/dist/commands/copy-command.d.ts +1 -0
- package/dist/commands/copy-command.d.ts.map +1 -0
- package/dist/commands/copy-command.js +3 -2
- package/dist/commands/edit-command.d.ts +1 -0
- package/dist/commands/edit-command.d.ts.map +1 -0
- package/dist/commands/edit-command.js +7 -5
- package/dist/commands/edit-prompt-command.d.ts +2 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -0
- package/dist/commands/edit-prompt-command.js +15 -7
- package/dist/commands/exit-command.d.ts +13 -2
- package/dist/commands/exit-command.d.ts.map +1 -0
- package/dist/commands/exit-command.js +14 -2
- package/dist/commands/files-command.d.ts +1 -0
- package/dist/commands/files-command.d.ts.map +1 -0
- package/dist/commands/files-command.js +9 -8
- package/dist/commands/generate-rules-command.d.ts +1 -0
- package/dist/commands/generate-rules-command.d.ts.map +1 -0
- package/dist/commands/generate-rules-command.js +4 -3
- package/dist/commands/health-command.d.ts +3 -1
- package/dist/commands/health-command.d.ts.map +1 -0
- package/dist/commands/health-command.js +42 -5
- package/dist/commands/help-command.d.ts +1 -0
- package/dist/commands/help-command.d.ts.map +1 -0
- package/dist/commands/help-command.js +2 -3
- package/dist/commands/init-command.d.ts +1 -0
- package/dist/commands/init-command.d.ts.map +1 -0
- package/dist/commands/init-command.js +1 -2
- package/dist/commands/last-log-command.d.ts +1 -0
- package/dist/commands/last-log-command.d.ts.map +1 -0
- package/dist/commands/last-log-command.js +12 -17
- package/dist/commands/list-tools-command.d.ts +3 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -0
- package/dist/commands/list-tools-command.js +61 -0
- package/dist/commands/manager.d.ts +7 -2
- package/dist/commands/manager.d.ts.map +1 -0
- package/dist/commands/manager.js +43 -6
- package/dist/commands/model-command.d.ts +1 -0
- package/dist/commands/model-command.d.ts.map +1 -0
- package/dist/commands/model-command.js +5 -5
- package/dist/commands/paste-command.d.ts +1 -0
- package/dist/commands/paste-command.d.ts.map +1 -0
- package/dist/commands/paste-command.js +6 -5
- package/dist/commands/prompt-command.d.ts +2 -1
- package/dist/commands/prompt-command.d.ts.map +1 -0
- package/dist/commands/prompt-command.js +62 -8
- package/dist/commands/reset-command.d.ts +1 -0
- package/dist/commands/reset-command.d.ts.map +1 -0
- package/dist/commands/reset-command.js +1 -1
- package/dist/commands/rules-command.d.ts +1 -0
- package/dist/commands/rules-command.d.ts.map +1 -0
- package/dist/commands/rules-command.js +5 -3
- package/dist/commands/save-command.d.ts +1 -0
- package/dist/commands/save-command.d.ts.map +1 -0
- package/dist/commands/save-command.js +1 -1
- package/dist/commands/shell-command.d.ts +3 -0
- package/dist/commands/shell-command.d.ts.map +1 -0
- package/dist/commands/shell-command.js +60 -0
- package/dist/commands/types.d.ts +9 -6
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/usage-command.d.ts +1 -0
- package/dist/commands/usage-command.d.ts.map +1 -0
- package/dist/commands/usage-command.js +2 -3
- package/dist/config.d.ts +22 -34
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +61 -15
- package/dist/conversation-analyzer.d.ts +2 -1
- package/dist/conversation-analyzer.d.ts.map +1 -0
- package/dist/dedent.d.ts +1 -0
- package/dist/dedent.d.ts.map +1 -0
- package/dist/execution/index.d.ts +112 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +432 -0
- package/dist/formatting.d.ts +2 -13
- package/dist/formatting.d.ts.map +1 -0
- package/dist/formatting.js +5 -64
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -4
- package/dist/logger.d.ts +1 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/mentions.d.ts +4 -0
- package/dist/mentions.d.ts.map +1 -0
- package/dist/mentions.js +42 -10
- package/dist/messages.d.ts +8 -20
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +33 -53
- package/dist/middleware/audit-message.d.ts +1 -0
- package/dist/middleware/audit-message.d.ts.map +1 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/rate-limit.d.ts +1 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/models/ai-config.d.ts +1 -0
- package/dist/models/ai-config.d.ts.map +1 -0
- package/dist/models/anthropic-provider.d.ts +1 -0
- package/dist/models/anthropic-provider.d.ts.map +1 -0
- package/dist/models/deepseek-provider.d.ts +1 -0
- package/dist/models/deepseek-provider.d.ts.map +1 -0
- package/dist/models/google-provider.d.ts +1 -0
- package/dist/models/google-provider.d.ts.map +1 -0
- package/dist/models/groq-provider.d.ts +20 -0
- package/dist/models/groq-provider.d.ts.map +1 -0
- package/dist/models/groq-provider.js +31 -0
- package/dist/models/manager.d.ts +1 -0
- package/dist/models/manager.d.ts.map +1 -0
- package/dist/models/openai-provider.d.ts +2 -1
- package/dist/models/openai-provider.d.ts.map +1 -0
- package/dist/models/openrouter-provider.d.ts +31 -22
- package/dist/models/openrouter-provider.d.ts.map +1 -0
- package/dist/models/openrouter-provider.js +115 -1
- package/dist/models/providers.d.ts +4 -5
- package/dist/models/providers.d.ts.map +1 -0
- package/dist/models/providers.js +7 -3
- package/dist/models/xai-provider.d.ts +1 -0
- package/dist/models/xai-provider.d.ts.map +1 -0
- package/dist/parsing.d.ts +2 -1
- package/dist/parsing.d.ts.map +1 -0
- package/dist/prompts/manager.d.ts +14 -2
- package/dist/prompts/manager.d.ts.map +1 -0
- package/dist/prompts.d.ts +1 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +17 -11
- package/dist/repl/display-tool-messages.d.ts +4 -0
- package/dist/repl/display-tool-messages.d.ts.map +1 -0
- package/dist/repl/display-tool-messages.js +55 -0
- package/dist/repl/display-tool-use.d.ts +14 -0
- package/dist/repl/display-tool-use.d.ts.map +1 -0
- package/dist/repl/display-tool-use.js +63 -0
- package/dist/repl/get-prompt-header.d.ts +8 -0
- package/dist/repl/get-prompt-header.d.ts.map +1 -0
- package/dist/repl/get-prompt-header.js +38 -0
- package/dist/repl/tool-call-repair.d.ts +4 -0
- package/dist/repl/tool-call-repair.d.ts.map +1 -0
- package/dist/repl/tool-call-repair.js +50 -0
- package/dist/repl-prompt.d.ts +1 -0
- package/dist/repl-prompt.d.ts.map +1 -0
- package/dist/repl.d.ts +8 -4
- package/dist/repl.d.ts.map +1 -0
- package/dist/repl.js +108 -252
- package/dist/terminal/ansi-styles.d.ts +77 -0
- package/dist/terminal/ansi-styles.d.ts.map +1 -0
- package/dist/terminal/ansi-styles.js +215 -0
- package/dist/terminal/checkbox-prompt.d.ts +36 -0
- package/dist/terminal/checkbox-prompt.d.ts.map +1 -0
- package/dist/terminal/checkbox-prompt.js +362 -0
- package/dist/terminal/default-theme.d.ts +6 -0
- package/dist/terminal/default-theme.d.ts.map +1 -0
- package/dist/terminal/default-theme.js +182 -0
- package/dist/terminal/east-asian-width.d.ts +8 -0
- package/dist/terminal/east-asian-width.d.ts.map +1 -0
- package/dist/terminal/east-asian-width.js +409 -0
- package/dist/terminal/editor-prompt.d.ts +10 -0
- package/dist/terminal/editor-prompt.d.ts.map +1 -0
- package/dist/terminal/editor-prompt.js +61 -0
- package/dist/terminal/errors.d.ts +19 -0
- package/dist/terminal/errors.d.ts.map +1 -0
- package/dist/terminal/errors.js +37 -0
- package/dist/terminal/formatting.d.ts +1 -11
- package/dist/terminal/formatting.d.ts.map +1 -0
- package/dist/terminal/formatting.js +4 -20
- package/dist/terminal/highlight/index.d.ts +53 -0
- package/dist/terminal/highlight/index.d.ts.map +1 -0
- package/dist/terminal/highlight/index.js +90 -0
- package/dist/terminal/highlight/theme.d.ts +233 -0
- package/dist/terminal/highlight/theme.d.ts.map +1 -0
- package/dist/terminal/highlight/theme.js +83 -0
- package/dist/terminal/index.d.ts +16 -9
- package/dist/terminal/index.d.ts.map +1 -0
- package/dist/terminal/index.js +42 -126
- package/dist/terminal/input-prompt.d.ts +16 -0
- package/dist/terminal/input-prompt.d.ts.map +1 -0
- package/dist/terminal/input-prompt.js +181 -0
- package/dist/terminal/markdown-utils.d.ts +1 -0
- package/dist/terminal/markdown-utils.d.ts.map +1 -0
- package/dist/terminal/markdown.d.ts +1 -0
- package/dist/terminal/markdown.d.ts.map +1 -0
- package/dist/terminal/markdown.js +17 -12
- package/dist/terminal/search-prompt.d.ts +20 -0
- package/dist/terminal/search-prompt.d.ts.map +1 -0
- package/dist/terminal/search-prompt.js +279 -0
- package/dist/terminal/select-prompt.d.ts +26 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -0
- package/dist/terminal/select-prompt.js +298 -0
- package/dist/terminal/string-width.d.ts +7 -0
- package/dist/terminal/string-width.d.ts.map +1 -0
- package/dist/terminal/string-width.js +61 -0
- package/dist/terminal/strip-ansi.d.ts +2 -0
- package/dist/terminal/strip-ansi.d.ts.map +1 -0
- package/dist/terminal/strip-ansi.js +20 -0
- package/dist/terminal/style.d.ts +191 -0
- package/dist/terminal/style.d.ts.map +1 -0
- package/dist/terminal/style.js +259 -0
- package/dist/terminal/supports-color.d.ts +1 -0
- package/dist/terminal/supports-color.d.ts.map +1 -0
- package/dist/terminal/supports-hyperlinks.d.ts +1 -3
- package/dist/terminal/supports-hyperlinks.d.ts.map +1 -0
- package/dist/terminal/supports-hyperlinks.js +1 -1
- package/dist/terminal/types.d.ts +1 -37
- package/dist/terminal/types.d.ts.map +1 -0
- package/dist/terminal/wrap-ansi.d.ts +8 -0
- package/dist/terminal/wrap-ansi.d.ts.map +1 -0
- package/dist/terminal/wrap-ansi.js +190 -0
- package/dist/{token-utils.d.ts → tokens/counter.d.ts} +1 -0
- package/dist/tokens/counter.d.ts.map +1 -0
- package/dist/{token-utils.js → tokens/counter.js} +1 -1
- package/dist/tokens/manage-output.d.ts +34 -0
- package/dist/tokens/manage-output.d.ts.map +1 -0
- package/dist/tokens/manage-output.js +44 -0
- package/dist/{token-tracker.d.ts → tokens/tracker.d.ts} +1 -0
- package/dist/tokens/tracker.d.ts.map +1 -0
- package/dist/tool-executor.d.ts +28 -0
- package/dist/tool-executor.d.ts.map +1 -0
- package/dist/tool-executor.js +74 -0
- package/dist/tools/agent.d.ts +3 -2
- package/dist/tools/agent.d.ts.map +1 -0
- package/dist/tools/agent.js +7 -4
- package/dist/tools/bash-utils.d.ts +7 -0
- package/dist/tools/bash-utils.d.ts.map +1 -0
- package/dist/tools/bash-utils.js +212 -0
- package/dist/tools/bash.d.ts +9 -7
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +95 -212
- package/dist/tools/code-interpreter.d.ts +1 -0
- package/dist/tools/code-interpreter.d.ts.map +1 -0
- package/dist/tools/code-interpreter.js +33 -8
- package/dist/tools/delete-file.d.ts +5 -3
- package/dist/tools/delete-file.d.ts.map +1 -0
- package/dist/tools/delete-file.js +47 -33
- package/dist/tools/directory-tree.d.ts +10 -1
- package/dist/tools/directory-tree.d.ts.map +1 -0
- package/dist/tools/directory-tree.js +91 -8
- package/dist/tools/dynamic-tool-loader.d.ts +12 -0
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -0
- package/dist/tools/dynamic-tool-loader.js +280 -0
- package/dist/tools/dynamic-tool-parser.d.ts +20 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -0
- package/dist/tools/dynamic-tool-parser.js +21 -0
- package/dist/tools/edit-file.d.ts +10 -2
- package/dist/tools/edit-file.d.ts.map +1 -0
- package/dist/tools/edit-file.js +117 -40
- package/dist/tools/file-editing-utils.d.ts +2 -0
- package/dist/tools/file-editing-utils.d.ts.map +1 -0
- package/dist/tools/file-editing-utils.js +135 -0
- package/dist/tools/filesystem-utils.d.ts +6 -21
- package/dist/tools/filesystem-utils.d.ts.map +1 -0
- package/dist/tools/filesystem-utils.js +96 -148
- package/dist/tools/git-utils.d.ts +1 -0
- package/dist/tools/git-utils.d.ts.map +1 -0
- package/dist/tools/grep.d.ts +5 -3
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +67 -27
- package/dist/tools/index.d.ts +10 -14
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +33 -22
- package/dist/tools/move-file.d.ts +1 -0
- package/dist/tools/move-file.d.ts.map +1 -0
- package/dist/tools/move-file.js +12 -5
- package/dist/tools/read-file.d.ts +2 -1
- package/dist/tools/read-file.d.ts.map +1 -0
- package/dist/tools/read-file.js +13 -6
- package/dist/tools/read-multiple-files.d.ts +2 -1
- package/dist/tools/read-multiple-files.d.ts.map +1 -0
- package/dist/tools/read-multiple-files.js +90 -9
- package/dist/tools/save-file.d.ts +5 -3
- package/dist/tools/save-file.d.ts.map +1 -0
- package/dist/tools/save-file.js +64 -36
- package/dist/tools/think.d.ts +1 -0
- package/dist/tools/think.d.ts.map +1 -0
- package/dist/tools/think.js +5 -1
- package/dist/tools/types.d.ts +14 -1
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/web-fetch.d.ts +4 -2
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +2 -2
- package/dist/tools/web-search.d.ts +2 -1
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +46 -11
- package/dist/utils/filesystem.d.ts +23 -0
- package/dist/utils/filesystem.d.ts.map +1 -0
- package/dist/utils/filesystem.js +140 -0
- package/dist/utils/filetype-detection.d.ts +3 -0
- package/dist/utils/filetype-detection.d.ts.map +1 -0
- package/dist/utils/filetype-detection.js +112 -0
- package/dist/utils/glob.d.ts +52 -0
- package/dist/utils/glob.d.ts.map +1 -0
- package/dist/utils/glob.js +376 -0
- package/dist/utils/ignore.d.ts +104 -0
- package/dist/utils/ignore.d.ts.map +1 -0
- package/dist/utils/ignore.js +649 -0
- package/dist/utils/process.d.ts +10 -1
- package/dist/utils/process.d.ts.map +1 -0
- package/dist/utils/process.js +104 -5
- package/dist/utils/zod-utils.d.ts +4 -0
- package/dist/utils/zod-utils.d.ts.map +1 -0
- package/dist/utils/zod-utils.js +7 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +32 -30
- package/dist/tools/command-validation.d.ts +0 -12
- package/dist/tools/command-validation.js +0 -113
- /package/dist/{token-tracker.js → tokens/tracker.js} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Inline from sindresorhus/strip-ansi v7.1.0
|
|
2
|
+
const ansiRegex = ({ onlyFirst = false } = {}) => {
|
|
3
|
+
// Valid string terminator sequences are BEL, ESC\, and 0x9c
|
|
4
|
+
const St = "(?:\\\\u0007|\\\\u001B\\\\u005C|\\\\u009C)";
|
|
5
|
+
// OSC sequences only: ESC ] ... ST (non-greedy until the first ST)
|
|
6
|
+
const osc = `(?:\\\\u001B\\\\][\\\\s\\\\S]*?${St})`;
|
|
7
|
+
// CSI and related: ESC/C1, optional intermediates, optional params (supports ; and :) then final byte
|
|
8
|
+
const csi = "[\\\\u001B\\\\u009B][[\\\\]()#;?]*(?:\\\\d{1,4}(?:[;:]\\\\d{0,4})*)?[\\\\dA-PR-TZcf-nq-uy=>~]";
|
|
9
|
+
const pattern = `${osc}|${csi}`;
|
|
10
|
+
return new RegExp(pattern, onlyFirst ? undefined : "g");
|
|
11
|
+
};
|
|
12
|
+
export default function stripAnsi(string) {
|
|
13
|
+
if (typeof string !== "string") {
|
|
14
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
15
|
+
}
|
|
16
|
+
// Even though the regex is global, we don't need to reset the `.lastIndex`
|
|
17
|
+
// because unlike `.exec()` and `.test()`, `.replace()` does it automatically
|
|
18
|
+
// and doing it manually has a performance penalty.
|
|
19
|
+
return string.replace(ansiRegex(), "");
|
|
20
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
interface Options {
|
|
2
|
+
/**
|
|
3
|
+
* Specify the color support for Style.
|
|
4
|
+
*
|
|
5
|
+
* By default, color support is automatically detected based on the environment.
|
|
6
|
+
*
|
|
7
|
+
* Levels:
|
|
8
|
+
* - `0` - All colors disabled.
|
|
9
|
+
* - `1` - Basic 16 colors support.
|
|
10
|
+
* - `2` - ANSI 256 colors support.
|
|
11
|
+
* - `3` - Truecolor 16 million colors support.
|
|
12
|
+
*/
|
|
13
|
+
readonly level?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface StyleInstance {
|
|
16
|
+
(...text: unknown[]): string;
|
|
17
|
+
/**
|
|
18
|
+
* The color support for Style.
|
|
19
|
+
*
|
|
20
|
+
* By default, color support is automatically detected based on the environment.
|
|
21
|
+
*
|
|
22
|
+
* Levels:
|
|
23
|
+
* - `0` - All colors disabled.
|
|
24
|
+
* - `1` - Basic 16 colors support.
|
|
25
|
+
* - `2` - ANSI 256 colors support.
|
|
26
|
+
* - `3` - Truecolor 16 million colors support.
|
|
27
|
+
*/
|
|
28
|
+
level: number;
|
|
29
|
+
/**
|
|
30
|
+
* Use RGB values to set text color.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```
|
|
34
|
+
* import { style } from './terminal/style';
|
|
35
|
+
*
|
|
36
|
+
* style.rgb(222, 173, 237)('Hello');
|
|
37
|
+
* //=> '\u001B[38;2;222;173;237mHello\u001B[39m'
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
rgb: (red: number, green: number, blue: number) => StyleInstance;
|
|
41
|
+
/**
|
|
42
|
+
* Use HEX value to set text color.
|
|
43
|
+
*
|
|
44
|
+
* @param color - Hexadecimal value representing the desired color.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```
|
|
48
|
+
* import { style } from './terminal/style';
|
|
49
|
+
*
|
|
50
|
+
* style.hex('#DEADED')('Hello');
|
|
51
|
+
* //=> '\u001B[38;2;222;173;237mHello\u001B[39m'
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
hex: (color: string) => StyleInstance;
|
|
55
|
+
/**
|
|
56
|
+
* Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```
|
|
60
|
+
* import { style } from './terminal/style';
|
|
61
|
+
*
|
|
62
|
+
* style.ansi256(201)('Hello');
|
|
63
|
+
* //=> '\u001B[38;5;201mHello\u001B[39m'
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
ansi256: (index: number) => StyleInstance;
|
|
67
|
+
/**
|
|
68
|
+
* Use RGB values to set background color.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```
|
|
72
|
+
* import { style } from './terminal/style';
|
|
73
|
+
*
|
|
74
|
+
* style.bgRgb(222, 173, 237)('Hello');
|
|
75
|
+
* //=> '\u001B[48;2;222;173;237mHello\u001B[49m'
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
bgRgb: (red: number, green: number, blue: number) => StyleInstance;
|
|
79
|
+
/**
|
|
80
|
+
* Use HEX value to set background color.
|
|
81
|
+
*
|
|
82
|
+
* @param color - Hexadecimal value representing the desired color.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```
|
|
86
|
+
* import { style } from './terminal/style';
|
|
87
|
+
*
|
|
88
|
+
* style.bgHex('#DEADED')('Hello');
|
|
89
|
+
* //=> '\u001B[48;2;222;173;237mHello\u001B[49m'
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
bgHex: (color: string) => StyleInstance;
|
|
93
|
+
/**
|
|
94
|
+
* Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```
|
|
98
|
+
* import { style } from './terminal/style';
|
|
99
|
+
*
|
|
100
|
+
* style.bgAnsi256(201)('Hello');
|
|
101
|
+
* //=> '\u001B[48;5;201mHello\u001B[49m'
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
bgAnsi256: (index: number) => StyleInstance;
|
|
105
|
+
/**
|
|
106
|
+
* Modifier: Reset the current style.
|
|
107
|
+
*/
|
|
108
|
+
readonly reset: StyleInstance;
|
|
109
|
+
/**
|
|
110
|
+
* Modifier: Make the text bold.
|
|
111
|
+
*/
|
|
112
|
+
readonly bold: StyleInstance;
|
|
113
|
+
/**
|
|
114
|
+
* Modifier: Make the text have lower opacity.
|
|
115
|
+
*/
|
|
116
|
+
readonly dim: StyleInstance;
|
|
117
|
+
/**
|
|
118
|
+
* Modifier: Make the text italic. *(Not widely supported)*
|
|
119
|
+
*/
|
|
120
|
+
readonly italic: StyleInstance;
|
|
121
|
+
/**
|
|
122
|
+
* Modifier: Put a horizontal line below the text. *(Not widely supported)*
|
|
123
|
+
*/
|
|
124
|
+
readonly underline: StyleInstance;
|
|
125
|
+
/**
|
|
126
|
+
* Modifier: Put a horizontal line above the text. *(Not widely supported)*
|
|
127
|
+
*/
|
|
128
|
+
readonly overline: StyleInstance;
|
|
129
|
+
/**
|
|
130
|
+
* Modifier: Invert background and foreground colors.
|
|
131
|
+
*/
|
|
132
|
+
readonly inverse: StyleInstance;
|
|
133
|
+
/**
|
|
134
|
+
* Modifier: Print the text but make it invisible.
|
|
135
|
+
*/
|
|
136
|
+
readonly hidden: StyleInstance;
|
|
137
|
+
/**
|
|
138
|
+
* Modifier: Puts a horizontal line through the center of the text. *(Not widely supported)*
|
|
139
|
+
*/
|
|
140
|
+
readonly strikethrough: StyleInstance;
|
|
141
|
+
/**
|
|
142
|
+
* Modifier: Print the text only when Style has a color level above zero.
|
|
143
|
+
*
|
|
144
|
+
* Can be useful for things that are purely cosmetic.
|
|
145
|
+
*/
|
|
146
|
+
readonly visible: StyleInstance;
|
|
147
|
+
readonly black: StyleInstance;
|
|
148
|
+
readonly red: StyleInstance;
|
|
149
|
+
readonly green: StyleInstance;
|
|
150
|
+
readonly yellow: StyleInstance;
|
|
151
|
+
readonly blue: StyleInstance;
|
|
152
|
+
readonly magenta: StyleInstance;
|
|
153
|
+
readonly cyan: StyleInstance;
|
|
154
|
+
readonly white: StyleInstance;
|
|
155
|
+
readonly gray: StyleInstance;
|
|
156
|
+
readonly grey: StyleInstance;
|
|
157
|
+
readonly blackBright: StyleInstance;
|
|
158
|
+
readonly redBright: StyleInstance;
|
|
159
|
+
readonly greenBright: StyleInstance;
|
|
160
|
+
readonly yellowBright: StyleInstance;
|
|
161
|
+
readonly blueBright: StyleInstance;
|
|
162
|
+
readonly magentaBright: StyleInstance;
|
|
163
|
+
readonly cyanBright: StyleInstance;
|
|
164
|
+
readonly whiteBright: StyleInstance;
|
|
165
|
+
readonly bgBlack: StyleInstance;
|
|
166
|
+
readonly bgRed: StyleInstance;
|
|
167
|
+
readonly bgGreen: StyleInstance;
|
|
168
|
+
readonly bgYellow: StyleInstance;
|
|
169
|
+
readonly bgBlue: StyleInstance;
|
|
170
|
+
readonly bgMagenta: StyleInstance;
|
|
171
|
+
readonly bgCyan: StyleInstance;
|
|
172
|
+
readonly bgWhite: StyleInstance;
|
|
173
|
+
readonly bgGray: StyleInstance;
|
|
174
|
+
readonly bgGrey: StyleInstance;
|
|
175
|
+
readonly bgBlackBright: StyleInstance;
|
|
176
|
+
readonly bgRedBright: StyleInstance;
|
|
177
|
+
readonly bgGreenBright: StyleInstance;
|
|
178
|
+
readonly bgYellowBright: StyleInstance;
|
|
179
|
+
readonly bgBlueBright: StyleInstance;
|
|
180
|
+
readonly bgMagentaBright: StyleInstance;
|
|
181
|
+
readonly bgCyanBright: StyleInstance;
|
|
182
|
+
readonly bgWhiteBright: StyleInstance;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Create a Style prototype with the given options.
|
|
186
|
+
*/
|
|
187
|
+
declare function createStyle(options?: Options): StyleInstance;
|
|
188
|
+
declare const style: StyleInstance;
|
|
189
|
+
export { createStyle };
|
|
190
|
+
export default style;
|
|
191
|
+
//# sourceMappingURL=style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../source/terminal/style.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
// Converted from https://raw.githubusercontent.com/chalk/chalk/refs/heads/main/source/vendor/supports-color/index.js to modern TypeScript
|
|
2
|
+
// Renamed from chalk to style for internal use
|
|
3
|
+
import { ansiStyles } from "./ansi-styles.js";
|
|
4
|
+
import { supportsColor } from "./supports-color.js";
|
|
5
|
+
const { stdout: stdoutColor } = supportsColor;
|
|
6
|
+
const GENERATOR = Symbol("GENERATOR");
|
|
7
|
+
const STYLER = Symbol("STYLER");
|
|
8
|
+
const IS_EMPTY = Symbol("IS_EMPTY");
|
|
9
|
+
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
|
10
|
+
const levelMapping = ["ansi", "ansi", "ansi256", "ansi16m"];
|
|
11
|
+
const styles = Object.create(null);
|
|
12
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic object assignment needed for style compatibility
|
|
13
|
+
const applyOptions = (object, options = {}) => {
|
|
14
|
+
if (options.level !== undefined &&
|
|
15
|
+
!(Number.isInteger(options.level) &&
|
|
16
|
+
options.level >= 0 &&
|
|
17
|
+
options.level <= 3)) {
|
|
18
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
19
|
+
}
|
|
20
|
+
// Detect level if not set manually
|
|
21
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
22
|
+
object.level = options.level === undefined ? colorLevel : options.level;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Factory function to create a new Style instance.
|
|
26
|
+
*/
|
|
27
|
+
const styleFactory = (options) => {
|
|
28
|
+
const style = ((...strings) => strings.join(" "));
|
|
29
|
+
applyOptions(style, options);
|
|
30
|
+
Object.setPrototypeOf(style, createStyle.prototype);
|
|
31
|
+
return style;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Create a Style prototype with the given options.
|
|
35
|
+
*/
|
|
36
|
+
function createStyle(options) {
|
|
37
|
+
return styleFactory(options);
|
|
38
|
+
}
|
|
39
|
+
Object.setPrototypeOf(createStyle.prototype, Function.prototype);
|
|
40
|
+
// Define styles as getters on the prototype
|
|
41
|
+
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
42
|
+
if (styleName === "modifier" ||
|
|
43
|
+
styleName === "color" ||
|
|
44
|
+
styleName === "bgColor") {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const styleObj = style;
|
|
48
|
+
styles[styleName] = {
|
|
49
|
+
get() {
|
|
50
|
+
const builder = createBuilder(this,
|
|
51
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol access needed for style compatibility
|
|
52
|
+
createStyler(styleObj.open, styleObj.close, this[STYLER]),
|
|
53
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol access needed for style compatibility
|
|
54
|
+
this[IS_EMPTY]);
|
|
55
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
56
|
+
return builder;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic property assignment needed for style compatibility
|
|
61
|
+
styles["visible"] = {
|
|
62
|
+
get() {
|
|
63
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol access needed for style compatibility
|
|
64
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
65
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
66
|
+
return builder;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
const getModelAnsi = (model, level, type, ...args) => {
|
|
70
|
+
if (model === "rgb") {
|
|
71
|
+
if (level === "ansi16m") {
|
|
72
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic method access needed for style compatibility
|
|
73
|
+
return ansiStyles[type].ansi16m(...args);
|
|
74
|
+
}
|
|
75
|
+
if (level === "ansi256") {
|
|
76
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic method access needed for style compatibility
|
|
77
|
+
return ansiStyles[type].ansi256(
|
|
78
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic method access needed for style compatibility
|
|
79
|
+
ansiStyles.rgbToAnsi256(...args));
|
|
80
|
+
}
|
|
81
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic method access needed for style compatibility
|
|
82
|
+
return ansiStyles[type].ansi(
|
|
83
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic method access needed for style compatibility
|
|
84
|
+
ansiStyles.rgbToAnsi(...args));
|
|
85
|
+
}
|
|
86
|
+
if (model === "hex") {
|
|
87
|
+
return getModelAnsi("rgb", level, type,
|
|
88
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic method access needed for style compatibility
|
|
89
|
+
...ansiStyles.hexToRgb(...args));
|
|
90
|
+
}
|
|
91
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic method access needed for style compatibility
|
|
92
|
+
return ansiStyles[type][model](...args);
|
|
93
|
+
};
|
|
94
|
+
const usedModels = ["rgb", "hex", "ansi256"];
|
|
95
|
+
for (const model of usedModels) {
|
|
96
|
+
styles[model] = {
|
|
97
|
+
get() {
|
|
98
|
+
const { level } = this;
|
|
99
|
+
return function (...args) {
|
|
100
|
+
const styler = createStyler(
|
|
101
|
+
// biome-ignore lint/style/noNonNullAssertion: Level is guaranteed to be valid for style compatibility
|
|
102
|
+
getModelAnsi(model, levelMapping[level], "color", ...args),
|
|
103
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic property access needed for style compatibility
|
|
104
|
+
ansiStyles.color.close,
|
|
105
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol access needed for style compatibility
|
|
106
|
+
this[STYLER]);
|
|
107
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol access needed for style compatibility
|
|
108
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
// biome-ignore lint/style/noNonNullAssertion: Model string is guaranteed to be valid for style compatibility
|
|
113
|
+
const bgModel = `bg${model[0].toUpperCase()}${model.slice(1)}`;
|
|
114
|
+
styles[bgModel] = {
|
|
115
|
+
get() {
|
|
116
|
+
const { level } = this;
|
|
117
|
+
return function (...args) {
|
|
118
|
+
const styler = createStyler(
|
|
119
|
+
// biome-ignore lint/style/noNonNullAssertion: Level is guaranteed to be valid for style compatibility
|
|
120
|
+
getModelAnsi(model, levelMapping[level], "bgColor", ...args),
|
|
121
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic property access needed for style compatibility
|
|
122
|
+
ansiStyles.bgColor.close,
|
|
123
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol access needed for style compatibility
|
|
124
|
+
this[STYLER]);
|
|
125
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol access needed for style compatibility
|
|
126
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const proto = Object.defineProperties(() => { }, {
|
|
132
|
+
...styles,
|
|
133
|
+
level: {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
get() {
|
|
136
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol access needed for style compatibility
|
|
137
|
+
return this[GENERATOR].level;
|
|
138
|
+
},
|
|
139
|
+
set(level) {
|
|
140
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol access needed for style compatibility
|
|
141
|
+
this[GENERATOR].level = level;
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
/**
|
|
146
|
+
* Create a styler object for chaining styles.
|
|
147
|
+
*/
|
|
148
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic parent type needed for style compatibility
|
|
149
|
+
const createStyler = (open, close, parent) => {
|
|
150
|
+
let openAll;
|
|
151
|
+
let closeAll;
|
|
152
|
+
if (parent === undefined) {
|
|
153
|
+
openAll = open;
|
|
154
|
+
closeAll = close;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
openAll = parent.openAll + open;
|
|
158
|
+
closeAll = close + parent.closeAll;
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
open,
|
|
162
|
+
close,
|
|
163
|
+
openAll,
|
|
164
|
+
closeAll,
|
|
165
|
+
parent,
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Create a builder function for applying styles.
|
|
170
|
+
*/
|
|
171
|
+
const createBuilder = (self,
|
|
172
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic styler type needed for style compatibility
|
|
173
|
+
_styler, _isEmpty) => {
|
|
174
|
+
// Single argument is hot path, implicit coercion is faster than anything
|
|
175
|
+
// eslint-disable-next-line no-implicit-coercion
|
|
176
|
+
const builder = (...args) => applyStyle(builder, args.length === 1 ? `${args[0]}` : args.join(" "));
|
|
177
|
+
// We alter the prototype because we must return a function, but there is
|
|
178
|
+
// no way to create a function with a different prototype
|
|
179
|
+
Object.setPrototypeOf(builder, proto);
|
|
180
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol assignment needed for style compatibility
|
|
181
|
+
builder[GENERATOR] = self;
|
|
182
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol assignment needed for style compatibility
|
|
183
|
+
builder[STYLER] = _styler;
|
|
184
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol assignment needed for style compatibility
|
|
185
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
186
|
+
return builder;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Apply the style to the string.
|
|
190
|
+
*/
|
|
191
|
+
const applyStyle = (self, stringParam) => {
|
|
192
|
+
let string = stringParam;
|
|
193
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic property access needed for style compatibility
|
|
194
|
+
if (self.level <= 0 || !string) {
|
|
195
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol access needed for style compatibility
|
|
196
|
+
return self[IS_EMPTY] ? "" : string;
|
|
197
|
+
}
|
|
198
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic symbol access needed for style compatibility
|
|
199
|
+
let styler = self[STYLER];
|
|
200
|
+
if (styler === undefined) {
|
|
201
|
+
return string;
|
|
202
|
+
}
|
|
203
|
+
const { openAll, closeAll } = styler;
|
|
204
|
+
if (string.includes("\u001B")) {
|
|
205
|
+
while (styler !== undefined) {
|
|
206
|
+
// Replace any instances already present with a re-opening code
|
|
207
|
+
// otherwise only the part of the string until said closing code
|
|
208
|
+
// will be colored, and the rest will simply be 'plain'.
|
|
209
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
210
|
+
styler = styler.parent;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// We can move both next actions out of loop, because remaining actions in loop won't have
|
|
214
|
+
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
|
215
|
+
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
|
216
|
+
const lfIndex = string.indexOf("\n");
|
|
217
|
+
if (lfIndex !== -1) {
|
|
218
|
+
string = stringEncaseCrlfWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
219
|
+
}
|
|
220
|
+
return openAll + string + closeAll;
|
|
221
|
+
};
|
|
222
|
+
// Utility functions from utilities.js (integrated here for self-containment)
|
|
223
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
224
|
+
let index = string.indexOf(substring);
|
|
225
|
+
if (index === -1) {
|
|
226
|
+
return string;
|
|
227
|
+
}
|
|
228
|
+
const substringLength = substring.length;
|
|
229
|
+
let endIndex = 0;
|
|
230
|
+
let returnValue = "";
|
|
231
|
+
do {
|
|
232
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
233
|
+
endIndex = index + substringLength;
|
|
234
|
+
index = string.indexOf(substring, endIndex);
|
|
235
|
+
} while (index !== -1);
|
|
236
|
+
returnValue += string.slice(endIndex);
|
|
237
|
+
return returnValue;
|
|
238
|
+
}
|
|
239
|
+
function stringEncaseCrlfWithFirstIndex(string, prefix, postfix, indexParam) {
|
|
240
|
+
let index = indexParam;
|
|
241
|
+
let endIndex = 0;
|
|
242
|
+
let returnValue = "";
|
|
243
|
+
do {
|
|
244
|
+
const gotCr = string[index - 1] === "\r";
|
|
245
|
+
returnValue +=
|
|
246
|
+
string.slice(endIndex, gotCr ? index - 1 : index) +
|
|
247
|
+
prefix +
|
|
248
|
+
(gotCr ? "\r\n" : "\n") +
|
|
249
|
+
postfix;
|
|
250
|
+
endIndex = index + 1;
|
|
251
|
+
index = string.indexOf("\n", endIndex);
|
|
252
|
+
} while (index !== -1);
|
|
253
|
+
returnValue += string.slice(endIndex);
|
|
254
|
+
return returnValue;
|
|
255
|
+
}
|
|
256
|
+
Object.defineProperties(createStyle.prototype, styles);
|
|
257
|
+
const style = createStyle();
|
|
258
|
+
export { createStyle };
|
|
259
|
+
export default style;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supports-color.d.ts","sourceRoot":"","sources":["../../source/terminal/supports-color.ts"],"names":[],"mappings":"AAiCA,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;CACjB;AAgID,wBAAgB,mBAAmB,CACjC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,EAC3B,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACtC,YAAY,GAAG,KAAK,CAOtB;AAED,eAAO,MAAM,aAAa;;;CAGzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supports-hyperlinks.d.ts","sourceRoot":"","sources":["../../source/terminal/supports-hyperlinks.ts"],"names":[],"mappings":"AAyIA,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC"}
|
|
@@ -20,7 +20,7 @@ function parseVersion(versionString = "") {
|
|
|
20
20
|
patch: versions[2] ?? 0,
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
function createSupportsHyperlinks(stream) {
|
|
24
24
|
const { CI, CURSOR_TRACE_ID, FORCE_HYPERLINK, NETLIFY, TEAMCITY_VERSION, TERM_PROGRAM, TERM_PROGRAM_VERSION, VTE_VERSION, TERM, } = process.env;
|
|
25
25
|
if (FORCE_HYPERLINK) {
|
|
26
26
|
return !(FORCE_HYPERLINK.length > 0 && Number.parseInt(FORCE_HYPERLINK, 10) === 0);
|
package/dist/terminal/types.d.ts
CHANGED
|
@@ -31,41 +31,5 @@ export interface TerminalConfig {
|
|
|
31
31
|
*/
|
|
32
32
|
maxWidth?: number | undefined;
|
|
33
33
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Spinner instance for progress indicators
|
|
36
|
-
*/
|
|
37
|
-
export interface SpinnerInstance {
|
|
38
|
-
/**
|
|
39
|
-
* Spinner identifier
|
|
40
|
-
*/
|
|
41
|
-
id: string;
|
|
42
|
-
/**
|
|
43
|
-
* Update spinner text
|
|
44
|
-
*/
|
|
45
|
-
update(text: string): SpinnerInstance;
|
|
46
|
-
/**
|
|
47
|
-
* Mark spinner as successful and stop
|
|
48
|
-
*/
|
|
49
|
-
succeed(text?: string): SpinnerInstance;
|
|
50
|
-
/**
|
|
51
|
-
* Mark spinner as failed and stop
|
|
52
|
-
*/
|
|
53
|
-
fail(text?: string): SpinnerInstance;
|
|
54
|
-
/**
|
|
55
|
-
* Mark spinner with warning and stop
|
|
56
|
-
*/
|
|
57
|
-
warn(text?: string): SpinnerInstance;
|
|
58
|
-
/**
|
|
59
|
-
* Mark spinner with info and stop
|
|
60
|
-
*/
|
|
61
|
-
info(text?: string): SpinnerInstance;
|
|
62
|
-
/**
|
|
63
|
-
* Clear spinner without any indicator
|
|
64
|
-
*/
|
|
65
|
-
clear(): SpinnerInstance;
|
|
66
|
-
/**
|
|
67
|
-
* Stop spinner without any indicator
|
|
68
|
-
*/
|
|
69
|
-
stop(): SpinnerInstance;
|
|
70
|
-
}
|
|
71
34
|
export {};
|
|
35
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../source/terminal/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,KAAK,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,KAAK,EAAE,aAAa,CAAC;IAErB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrap-ansi.d.ts","sourceRoot":"","sources":["../../source/terminal/wrap-ansi.ts"],"names":[],"mappings":"AAIA,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA6OD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,MAAM,CAOR"}
|