ansi-escapes
Advanced tools
Comparing version 4.3.2 to 5.0.0
@@ -1,62 +0,60 @@ | ||
/// <reference types="node"/> | ||
/* eslint-disable @typescript-eslint/member-ordering */ | ||
import {LiteralUnion} from 'type-fest'; | ||
declare namespace ansiEscapes { | ||
interface ImageOptions { | ||
/** | ||
The width is given as a number followed by a unit, or the word `'auto'`. | ||
export interface ImageOptions { | ||
/** | ||
The width is given as a number followed by a unit, or the word `'auto'`. | ||
- `N`: N character cells. | ||
- `Npx`: N pixels. | ||
- `N%`: N percent of the session's width or height. | ||
- `auto`: The image's inherent size will be used to determine an appropriate dimension. | ||
*/ | ||
readonly width?: LiteralUnion<'auto', number | string>; | ||
- `N`: N character cells. | ||
- `Npx`: N pixels. | ||
- `N%`: N percent of the session's width or height. | ||
- `auto`: The image's inherent size will be used to determine an appropriate dimension. | ||
*/ | ||
readonly width?: LiteralUnion<'auto', number | string>; | ||
/** | ||
The height is given as a number followed by a unit, or the word `'auto'`. | ||
/** | ||
The height is given as a number followed by a unit, or the word `'auto'`. | ||
- `N`: N character cells. | ||
- `Npx`: N pixels. | ||
- `N%`: N percent of the session's width or height. | ||
- `auto`: The image's inherent size will be used to determine an appropriate dimension. | ||
*/ | ||
readonly height?: LiteralUnion<'auto', number | string>; | ||
- `N`: N character cells. | ||
- `Npx`: N pixels. | ||
- `N%`: N percent of the session's width or height. | ||
- `auto`: The image's inherent size will be used to determine an appropriate dimension. | ||
*/ | ||
readonly height?: LiteralUnion<'auto', number | string>; | ||
readonly preserveAspectRatio?: boolean; | ||
} | ||
readonly preserveAspectRatio?: boolean; | ||
} | ||
interface AnnotationOptions { | ||
/** | ||
Nonzero number of columns to annotate. | ||
export interface AnnotationOptions { | ||
/** | ||
Nonzero number of columns to annotate. | ||
Default: The remainder of the line. | ||
*/ | ||
readonly length?: number; | ||
Default: The remainder of the line. | ||
*/ | ||
readonly length?: number; | ||
/** | ||
Starting X coordinate. | ||
/** | ||
Starting X coordinate. | ||
Must be used with `y` and `length`. | ||
Must be used with `y` and `length`. | ||
Default: The cursor position | ||
*/ | ||
readonly x?: number; | ||
Default: The cursor position | ||
*/ | ||
readonly x?: number; | ||
/** | ||
Starting Y coordinate. | ||
/** | ||
Starting Y coordinate. | ||
Must be used with `x` and `length`. | ||
Must be used with `x` and `length`. | ||
Default: Cursor position. | ||
*/ | ||
readonly y?: number; | ||
Default: Cursor position. | ||
*/ | ||
readonly y?: number; | ||
/** | ||
Create a "hidden" annotation. | ||
/** | ||
Create a "hidden" annotation. | ||
Annotations created this way can be shown using the "Show Annotations" iTerm command. | ||
*/ | ||
readonly isHidden?: boolean; | ||
} | ||
Annotations created this way can be shown using the "Show Annotations" iTerm command. | ||
*/ | ||
readonly isHidden?: boolean; | ||
} | ||
@@ -221,3 +219,3 @@ | ||
*/ | ||
image(buffer: Buffer, options?: ansiEscapes.ImageOptions): string; | ||
image(buffer: Buffer, options?: ImageOptions): string; | ||
@@ -242,9 +240,6 @@ iTerm: { | ||
*/ | ||
annotation(message: string, options?: ansiEscapes.AnnotationOptions): string; | ||
annotation(message: string, options?: AnnotationOptions): string; | ||
}; | ||
// TODO: remove this in the next major version | ||
default: typeof ansiEscapes; | ||
}; | ||
export = ansiEscapes; | ||
export default ansiEscapes; |
41
index.js
@@ -1,6 +0,1 @@ | ||
'use strict'; | ||
const ansiEscapes = module.exports; | ||
// TODO: remove this in the next major version | ||
module.exports.default = ansiEscapes; | ||
const ESC = '\u001B['; | ||
@@ -12,2 +7,4 @@ const OSC = '\u001B]'; | ||
const ansiEscapes = {}; | ||
ansiEscapes.cursorTo = (x, y) => { | ||
@@ -30,17 +27,17 @@ if (typeof x !== 'number') { | ||
let ret = ''; | ||
let returnValue = ''; | ||
if (x < 0) { | ||
ret += ESC + (-x) + 'D'; | ||
returnValue += ESC + (-x) + 'D'; | ||
} else if (x > 0) { | ||
ret += ESC + x + 'C'; | ||
returnValue += ESC + x + 'C'; | ||
} | ||
if (y < 0) { | ||
ret += ESC + (-y) + 'A'; | ||
returnValue += ESC + (-y) + 'A'; | ||
} else if (y > 0) { | ||
ret += ESC + y + 'B'; | ||
returnValue += ESC + y + 'B'; | ||
} | ||
return ret; | ||
return returnValue; | ||
}; | ||
@@ -115,17 +112,17 @@ | ||
ansiEscapes.image = (buffer, options = {}) => { | ||
let ret = `${OSC}1337;File=inline=1`; | ||
let returnValue = `${OSC}1337;File=inline=1`; | ||
if (options.width) { | ||
ret += `;width=${options.width}`; | ||
returnValue += `;width=${options.width}`; | ||
} | ||
if (options.height) { | ||
ret += `;height=${options.height}`; | ||
returnValue += `;height=${options.height}`; | ||
} | ||
if (options.preserveAspectRatio === false) { | ||
ret += ';preserveAspectRatio=0'; | ||
returnValue += ';preserveAspectRatio=0'; | ||
} | ||
return ret + ':' + buffer.toString('base64') + BEL; | ||
return returnValue + ':' + buffer.toString('base64') + BEL; | ||
}; | ||
@@ -137,3 +134,3 @@ | ||
annotation: (message, options = {}) => { | ||
let ret = `${OSC}1337;`; | ||
let returnValue = `${OSC}1337;`; | ||
@@ -148,6 +145,6 @@ const hasX = typeof options.x !== 'undefined'; | ||
ret += options.isHidden ? 'AddHiddenAnnotation=' : 'AddAnnotation='; | ||
returnValue += options.isHidden ? 'AddHiddenAnnotation=' : 'AddAnnotation='; | ||
if (options.length > 0) { | ||
ret += | ||
returnValue += | ||
(hasX ? | ||
@@ -157,7 +154,9 @@ [message, options.length, options.x, options.y] : | ||
} else { | ||
ret += message; | ||
returnValue += message; | ||
} | ||
return ret + BEL; | ||
return returnValue + BEL; | ||
} | ||
}; | ||
export default ansiEscapes; |
{ | ||
"name": "ansi-escapes", | ||
"version": "4.3.2", | ||
"version": "5.0.0", | ||
"description": "ANSI escape codes for manipulating the terminal", | ||
@@ -13,4 +13,6 @@ "license": "MIT", | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=12" | ||
}, | ||
@@ -50,10 +52,10 @@ "scripts": { | ||
"dependencies": { | ||
"type-fest": "^0.21.3" | ||
"type-fest": "^1.0.2" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^13.7.7", | ||
"ava": "^2.1.0", | ||
"@types/node": "^14.14.41", | ||
"ava": "^3.15.0", | ||
"tsd": "^0.14.0", | ||
"xo": "^0.25.3" | ||
"xo": "^0.38.2" | ||
} | ||
} |
@@ -14,3 +14,3 @@ # ansi-escapes | ||
```js | ||
const ansiEscapes = require('ansi-escapes'); | ||
import ansiEscapes from 'ansi-escapes'; | ||
@@ -17,0 +17,0 @@ // Moves the cursor two rows up and to the left |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Yes
16335
307
+ Addedtype-fest@1.4.0(transitive)
- Removedtype-fest@0.21.3(transitive)
Updatedtype-fest@^1.0.2