Comparing version 6.3.1 to 7.0.0
@@ -1,7 +0,7 @@ | ||
import {SpinnerName} from 'cli-spinners'; | ||
import {type SpinnerName} from 'cli-spinners'; | ||
export interface Spinner { | ||
export type Spinner = { | ||
readonly interval?: number; | ||
readonly frames: string[]; | ||
} | ||
}; | ||
@@ -23,3 +23,3 @@ export type Color = | ||
export interface Options { | ||
export type Options = { | ||
/** | ||
@@ -118,5 +118,5 @@ Text to display after the spinner. | ||
readonly discardStdin?: boolean; | ||
} | ||
}; | ||
export interface PersistOptions { | ||
export type PersistOptions = { | ||
/** | ||
@@ -149,5 +149,5 @@ Symbol to replace the spinner with. | ||
readonly suffixText?: string | SuffixTextGenerator; | ||
} | ||
}; | ||
export interface PromiseOptions<T> extends Options { | ||
export type PromiseOptions<T> = { | ||
/** | ||
@@ -166,4 +166,5 @@ The new text of the spinner when the promise is resolved. | ||
failText?: string | ((error: Error) => string) | undefined; | ||
} | ||
} & Options; | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
export interface Ora { | ||
@@ -170,0 +171,0 @@ /** |
51
index.js
@@ -7,3 +7,3 @@ import process from 'node:process'; | ||
import stripAnsi from 'strip-ansi'; | ||
import wcwidth from 'wcwidth'; | ||
import stringWidth from 'string-width'; | ||
import isInteractive from 'is-interactive'; | ||
@@ -102,7 +102,7 @@ import isUnicodeSupported from 'is-unicode-supported'; | ||
this.#indent = indent; | ||
this.updateLineCount(); | ||
this.#updateLineCount(); | ||
} | ||
get interval() { | ||
return this.#initialInterval || this.#spinner.interval || 100; | ||
return this.#initialInterval ?? this.#spinner.interval ?? 100; | ||
} | ||
@@ -140,5 +140,5 @@ | ||
set text(value) { | ||
this.#text = value || ''; | ||
this.updateLineCount(); | ||
set text(value = '') { | ||
this.#text = value; | ||
this.#updateLineCount(); | ||
} | ||
@@ -150,5 +150,5 @@ | ||
set prefixText(value) { | ||
this.#prefixText = value || ''; | ||
this.updateLineCount(); | ||
set prefixText(value = '') { | ||
this.#prefixText = value; | ||
this.#updateLineCount(); | ||
} | ||
@@ -160,5 +160,5 @@ | ||
set suffixText(value) { | ||
this.#suffixText = value || ''; | ||
this.updateLineCount(); | ||
set suffixText(value = '') { | ||
this.#suffixText = value; | ||
this.#updateLineCount(); | ||
} | ||
@@ -170,4 +170,3 @@ | ||
// TODO: Use private methods when targeting Node.js 14. | ||
getFullPrefixText(prefixText = this.#prefixText, postfix = ' ') { | ||
#getFullPrefixText(prefixText = this.#prefixText, postfix = ' ') { | ||
if (typeof prefixText === 'string' && prefixText !== '') { | ||
@@ -184,3 +183,3 @@ return prefixText + postfix; | ||
getFullSuffixText(suffixText = this.#suffixText, prefix = ' ') { | ||
#getFullSuffixText(suffixText = this.#suffixText, prefix = ' ') { | ||
if (typeof suffixText === 'string' && suffixText !== '') { | ||
@@ -197,6 +196,6 @@ return prefix + suffixText; | ||
updateLineCount() { | ||
const columns = this.#stream.columns || 80; | ||
const fullPrefixText = this.getFullPrefixText(this.#prefixText, '-'); | ||
const fullSuffixText = this.getFullSuffixText(this.#suffixText, '-'); | ||
#updateLineCount() { | ||
const columns = this.#stream.columns ?? 80; | ||
const fullPrefixText = this.#getFullPrefixText(this.#prefixText, '-'); | ||
const fullSuffixText = this.#getFullSuffixText(this.#suffixText, '-'); | ||
const fullText = ' '.repeat(this.#indent) + fullPrefixText + '--' + this.#text + '--' + fullSuffixText; | ||
@@ -206,3 +205,3 @@ | ||
for (const line of stripAnsi(fullText).split('\n')) { | ||
this.#lineCount += Math.max(1, Math.ceil(wcwidth(line) / columns)); | ||
this.#lineCount += Math.max(1, Math.ceil(stringWidth(line, {countAnsiEscapeCodes: true}) / columns)); | ||
} | ||
@@ -366,12 +365,12 @@ } | ||
const prefixText = options.prefixText || this.#prefixText; | ||
const fullPrefixText = this.getFullPrefixText(prefixText, ' '); | ||
const prefixText = options.prefixText ?? this.#prefixText; | ||
const fullPrefixText = this.#getFullPrefixText(prefixText, ' '); | ||
const symbolText = options.symbol || ' '; | ||
const symbolText = options.symbol ?? ' '; | ||
const text = options.text || this.text; | ||
const text = options.text ?? this.text; | ||
const fullText = (typeof text === 'string') ? ' ' + text : ''; | ||
const suffixText = options.suffixText !== undefined ? options.suffixText : this.#suffixText; | ||
const fullSuffixText = this.getFullSuffixText(suffixText, ' '); | ||
const suffixText = options.suffixText ?? this.#suffixText; | ||
const fullSuffixText = this.#getFullSuffixText(suffixText, ' '); | ||
@@ -378,0 +377,0 @@ const textToWrite = fullPrefixText + symbolText + fullText + fullSuffixText + '\n'; |
{ | ||
"name": "ora", | ||
"version": "6.3.1", | ||
"version": "7.0.0", | ||
"description": "Elegant terminal spinner", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
"node": ">=16" | ||
}, | ||
@@ -43,20 +43,24 @@ "scripts": { | ||
"dependencies": { | ||
"chalk": "^5.0.0", | ||
"chalk": "^5.3.0", | ||
"cli-cursor": "^4.0.0", | ||
"cli-spinners": "^2.6.1", | ||
"cli-spinners": "^2.9.0", | ||
"is-interactive": "^2.0.0", | ||
"is-unicode-supported": "^1.1.0", | ||
"is-unicode-supported": "^1.3.0", | ||
"log-symbols": "^5.1.0", | ||
"stdin-discarder": "^0.1.0", | ||
"strip-ansi": "^7.0.1", | ||
"wcwidth": "^1.0.1" | ||
"strip-ansi": "^7.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^17.0.18", | ||
"ava": "^4.0.1", | ||
"get-stream": "^6.0.1", | ||
"@types/node": "^20.4.5", | ||
"ava": "^5.3.1", | ||
"get-stream": "^7.0.1", | ||
"transform-tty": "^1.0.11", | ||
"tsd": "^0.19.1", | ||
"xo": "^0.48.0" | ||
"tsd": "^0.28.1", | ||
"xo": "^0.55.0" | ||
}, | ||
"xo": { | ||
"rules": { | ||
"@typescript-eslint/no-redundant-type-constituents": "off" | ||
} | ||
} | ||
} |
26801
8
- Removedwcwidth@^1.0.1
- Removedclone@1.0.4(transitive)
- Removeddefaults@1.0.4(transitive)
- Removedwcwidth@1.0.1(transitive)
Updatedchalk@^5.3.0
Updatedcli-spinners@^2.9.0
Updatedis-unicode-supported@^1.3.0
Updatedstrip-ansi@^7.1.0