@visulima/ansi 3.0.2 → 3.0.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,37 @@
1
+ ## @visulima/ansi [3.0.4](https://github.com/visulima/visulima/compare/@visulima/ansi@3.0.3...@visulima/ansi@3.0.4) (2025-11-12)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **deps:** update type-fest dependency across multiple packages ([93e13be](https://github.com/visulima/visulima/commit/93e13be5248207968a96303710db2a0604d16b9b))
6
+ * update package configurations and TypeScript definitions ([b59aa59](https://github.com/visulima/visulima/commit/b59aa59dac1508216b944f4b917fb4a7ab1f70a4))
7
+
8
+ ### Miscellaneous Chores
9
+
10
+ * Add jsr file to all packages for release ([#565](https://github.com/visulima/visulima/issues/565)) ([ec91652](https://github.com/visulima/visulima/commit/ec91652b4e4112adf14ba152c1239a7703ba425a))
11
+ * update license files and clean up TypeScript definitions ([fe668cc](https://github.com/visulima/visulima/commit/fe668cc26de23591d4df54a0954455ebbe31b22d))
12
+
13
+
14
+ ### Dependencies
15
+
16
+ * **@visulima/colorize:** upgraded to 1.4.28
17
+ * **@visulima/path:** upgraded to 2.0.4
18
+
19
+ ## @visulima/ansi [3.0.3](https://github.com/visulima/visulima/compare/@visulima/ansi@3.0.2...@visulima/ansi@3.0.3) (2025-11-07)
20
+
21
+ ### Bug Fixes
22
+
23
+ * update TypeScript configurations and improve linting across multiple packages ([6f25ec7](https://github.com/visulima/visulima/commit/6f25ec7841da7246f8f9166efc5292a7089d37ee))
24
+
25
+ ### Miscellaneous Chores
26
+
27
+ * update npm and pnpm configurations for monorepo optimization ([#564](https://github.com/visulima/visulima/issues/564)) ([5512b42](https://github.com/visulima/visulima/commit/5512b42f672c216b6a3c9e39035199a4ebd9a4b8))
28
+
29
+
30
+ ### Dependencies
31
+
32
+ * **@visulima/colorize:** upgraded to 1.4.27
33
+ * **@visulima/path:** upgraded to 2.0.3
34
+
1
35
  ## @visulima/ansi [3.0.2](https://github.com/visulima/visulima/compare/@visulima/ansi@3.0.1...@visulima/ansi@3.0.2) (2025-11-05)
2
36
 
3
37
  ### Bug Fixes
package/LICENSE.md CHANGED
@@ -122,11 +122,14 @@ Repository: https://github.com/tapjs/signal-exit.git
122
122
  <!-- TYPE_DEPENDENCIES -->
123
123
 
124
124
  # Licenses of bundled types
125
+
125
126
  The published @visulima/ansi artifact additionally contains code with the following licenses:
126
127
  MIT
127
128
 
128
129
  # Bundled types:
130
+
129
131
  ## restore-cursor
132
+
130
133
  License: MIT
131
134
  By: Sindre Sorhus
132
135
  Repository: sindresorhus/restore-cursor
@@ -1,6 +1,74 @@
1
- declare const ALT_SCREEN_ON: string;
2
- declare const ALT_SCREEN_OFF: string;
3
- declare const alternativeScreenOn: () => string;
4
- declare const alternativeScreenOff: () => string;
5
-
6
- export { ALT_SCREEN_OFF, ALT_SCREEN_ON, alternativeScreenOff, alternativeScreenOn };
1
+ /**
2
+ * ANSI escape sequence to enable the alternative screen buffer.
3
+ *
4
+ * This sequence (`CSI ?1049h`) instructs the terminal to switch to the alternative screen buffer.
5
+ * This is a common practice for full-screen terminal applications (e.g., vim, less, htop)
6
+ * to provide a separate screen area for their interface, leaving the original shell content
7
+ * undisturbed and restoring it upon exit.
8
+ * When this mode is activated, the original screen content is typically saved by the terminal,
9
+ * and a blank screen is presented. Operations then occur on this alternative buffer.
10
+ *
11
+ * The specific behavior (like whether the screen is cleared on switch) can sometimes vary
12
+ * slightly between terminal emulators. `?1049h` generally includes saving the cursor position
13
+ * along with the screen content and clearing the alternative screen.
14
+ * It is closely related to mode `?47h`, which also switches to an alternative buffer but might
15
+ * have different semantics regarding screen clearing and cursor saving.
16
+ * Mode `?1049h` is generally preferred for a more robust alternative screen experience.
17
+ * @see {@link ALT_SCREEN_OFF} for the sequence to disable the alternative screen buffer.
18
+ * @see {@link alternativeScreenOn} for a function that returns this sequence.
19
+ * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer} Xterm Control Sequences documentation.
20
+ * @see {@link https://vt100.net/docs/vt510-rm/DECSLPP.html} (related DEC modes, though 1049 is more common for this behavior).
21
+ */
22
+ export declare const ALT_SCREEN_ON: string;
23
+ /**
24
+ * ANSI escape sequence to disable the alternative screen buffer.
25
+ *
26
+ * This sequence (`CSI ?1049l`) instructs the terminal to switch back from the alternative
27
+ * screen buffer to the main screen buffer. When this occurs, the terminal typically
28
+ * restores the screen content and cursor position that were saved when the alternative
29
+ * buffer was activated by {@link ALT_SCREEN_ON}.
30
+ *
31
+ * This is used when a full-screen application exits, allowing the user to return to their
32
+ * previous shell session seamlessly.
33
+ * @see {@link ALT_SCREEN_ON} for the sequence to enable the alternative screen buffer.
34
+ * @see {@link alternativeScreenOff} for a function that returns this sequence.
35
+ */
36
+ export declare const ALT_SCREEN_OFF: string;
37
+ /**
38
+ * Returns the ANSI escape sequence to enable the alternative screen buffer.
39
+ *
40
+ * This function is a convenience wrapper around the {@link ALT_SCREEN_ON} constant.
41
+ * It provides a more descriptive way to obtain the sequence for enabling the
42
+ * alternative screen, often used at the initialization phase of a full-screen
43
+ * terminal application.
44
+ * @returns The ANSI escape sequence (`CSI ?1049h`) for enabling the alternative screen buffer.
45
+ * @example
46
+ * ```typescript
47
+ * import { alternativeScreenOn } from '@visulima/ansi/alternative-screen';
48
+ *
49
+ * process.stdout.write(alternativeScreenOn());
50
+ * // Terminal switches to the alternative screen buffer.
51
+ * ```
52
+ * @see {@link ALT_SCREEN_ON}
53
+ * @see {@link alternativeScreenOff}
54
+ */
55
+ export declare const alternativeScreenOn: () => string;
56
+ /**
57
+ * Returns the ANSI escape sequence to disable the alternative screen buffer.
58
+ *
59
+ * This function is a convenience wrapper around the {@link ALT_SCREEN_OFF} constant.
60
+ * It provides a more descriptive way to obtain the sequence for disabling the
61
+ * alternative screen, typically used when a full-screen terminal application is exiting
62
+ * to restore the user's original terminal state.
63
+ * @returns The ANSI escape sequence (`CSI ?1049l`) for disabling the alternative screen buffer.
64
+ * @example
65
+ * ```typescript
66
+ * import { alternativeScreenOff } from '@visulima/ansi/alternative-screen';
67
+ *
68
+ * process.stdout.write(alternativeScreenOff());
69
+ * // Terminal switches back to the main screen buffer, restoring previous content.
70
+ * ```
71
+ * @see {@link ALT_SCREEN_OFF}
72
+ * @see {@link alternativeScreenOn}
73
+ */
74
+ export declare const alternativeScreenOff: () => string;
package/dist/clear.d.ts CHANGED
@@ -1,6 +1,77 @@
1
- declare const clearScreenFromTopLeft: string;
2
- declare const clearLineAndHomeCursor: string;
3
- declare const clearScreenAndHomeCursor: string;
4
- declare const resetTerminal: string;
5
-
6
- export { clearLineAndHomeCursor, clearScreenAndHomeCursor, clearScreenFromTopLeft, resetTerminal };
1
+ /**
2
+ * Moves the cursor to the top-left (0,0 in 0-indexed terms) and erases from the cursor to the end of the screen.
3
+ *
4
+ * This sequence is a combination of:
5
+ * 1. {@link cursorTo}(0, 0): Moves the cursor to the first row, first column.
6
+ * (Equivalent to `CSI 1;1H` as `cursorTo` uses 0-indexed arguments which are converted to 1-indexed for the sequence).
7
+ * 2. {@link eraseDisplay}({@link EraseDisplayMode.ToEnd}): Erases from the cursor position to the end of the screen (`CSI 0J` or `CSI J`).
8
+ *
9
+ * Effective combined sequence: `CSI 1;1H CSI J` (or `CSI 1;1H CSI 0J`).
10
+ * @see {@link cursorTo}
11
+ * @see {@link eraseDisplay}
12
+ * @see {@link EraseDisplayMode.ToEnd}
13
+ */
14
+ export declare const clearScreenFromTopLeft: string;
15
+ /**
16
+ * Erases the entire current line and moves the cursor to the beginning of that line (column 1).
17
+ *
18
+ * This sequence is a combination of:
19
+ * 1. {@link eraseInLine}({@link EraseLineMode.EntireLine}): Erases the entire current line (`CSI 2K`).
20
+ * 2. `CSI G`: Moves the cursor to column 1 of the current line (Cursor Horizontal Absolute).
21
+ * Alternatively, a carriage return (`\r`) could achieve a similar cursor move to the start of the line on many systems.
22
+ *
23
+ * Effective combined sequence: `CSI 2K CSI G`.
24
+ * @see {@link eraseInLine}
25
+ * @see {@link EraseLineMode.EntireLine}
26
+ */
27
+ export declare const clearLineAndHomeCursor: string;
28
+ /**
29
+ * Homes the cursor to the top-left position (row 1, column 1) and erases the entire screen.
30
+ *
31
+ * This sequence is a combination of:
32
+ * 1. `CSI H`: Moves the cursor to the home position (top-left, equivalent to `CSI 1;1H`).
33
+ * 2. {@link eraseDisplay}({@link EraseDisplayMode.EntireScreen}): Erases the entire screen (`CSI 2J`).
34
+ *
35
+ * Effective combined sequence: `CSI H CSI 2J`.
36
+ * @remarks This is a very common sequence for clearing the visible terminal window.
37
+ * @see {@link cursorPosition} (which `CSI H` relates to)
38
+ * @see {@link eraseDisplay}
39
+ * @see {@link EraseDisplayMode.EntireScreen}
40
+ */
41
+ export declare const clearScreenAndHomeCursor: string;
42
+ /**
43
+ * Clears the entire terminal display, including the scrollback buffer on supported terminals,
44
+ * and attempts to reset the terminal to its initial (or a more pristine) state.
45
+ *
46
+ * This is generally a more comprehensive and forceful clear operation than just erasing the
47
+ * visible screen content (like {@link clearScreenAndHomeCursor}).
48
+ *
49
+ * The exact behavior and sequences used can vary by terminal and operating system:
50
+ *
51
+ * - **On Windows:**
52
+ * It typically uses `CSI 2J` (erase entire screen) followed by `CSI 0f`.
53
+ * `CSI 0f` (or `CSI ;f`, `CSI 0;0f`) is an SGR sequence that also often acts as a cursor home command,
54
+ * though its standardization can be less consistent than `CSI H`.
55
+ * The primary goal is to clear the screen and move the cursor to the top-left.
56
+ *
57
+ * - **On other platforms (e.g., Linux, macOS with XTerm-like terminals):**
58
+ * A more robust combination is used:
59
+ * 1. {@link eraseDisplay}({@link EraseDisplayMode.EntireScreen}) (`CSI 2J`): Erases the entire visible screen.
60
+ * 2. {@link eraseDisplay}({@link EraseDisplayMode.EntireScreenAndScrollback}) (`CSI 3J`): Erases the scrollback buffer (XTerm-specific, but widely supported).
61
+ * 3. `CSI H`: Moves the cursor to the home position (top-left).
62
+ * 4. `ESC c` (RIS - Reset to Initial State): This is the most powerful reset sequence. It typically resets the terminal
63
+ * to its power-on state, clearing character sets, SGR attributes, modes, and more.
64
+ * @returns A string containing the ANSI escape sequence(s) for resetting the terminal.
65
+ * @example
66
+ * ```typescript
67
+ * import { resetTerminal } from '@visulima/ansi/clear';
68
+ *
69
+ * process.stdout.write(resetTerminal);
70
+ * // The terminal attempts a full reset.
71
+ * ```
72
+ * @see {@link eraseDisplay}
73
+ * @see {@link EraseDisplayMode.EntireScreen}
74
+ * @see {@link EraseDisplayMode.EntireScreenAndScrollback}
75
+ * @see {@link https://vt100.net/docs/vt510-rm/RIS.html} RIS documentation.
76
+ */
77
+ export declare const resetTerminal: string;
@@ -0,0 +1,20 @@
1
+ /** Escape character (\u001B). */
2
+ export declare const ESC: string;
3
+ /** Control Sequence Introducer (ESC [). */
4
+ export declare const CSI: string;
5
+ /** Operating System Command (ESC ]). */
6
+ export declare const OSC: string;
7
+ /** Bell character (\u0007). Often used to terminate OSC sequences. */
8
+ export declare const BEL: string;
9
+ /** Separator used in some ANSI sequences, typically a semicolon. */
10
+ export declare const SEP: string;
11
+ /** Device Control String (ESC P). */
12
+ export declare const DCS: string;
13
+ /** String Terminator (ESC \\). Used to terminate DCS, SOS, PM, APC sequences. */
14
+ export declare const ST: string;
15
+ /** Application Program Command (ESC _). */
16
+ export declare const APC: string;
17
+ /** Start of String (ESC X). */
18
+ export declare const SOS: string;
19
+ /** Privacy Message (ESC ^). */
20
+ export declare const PM: string;