Merge fa760967a2 into 58483b5ab1
This commit is contained in:
commit
151b3a70cc
4 changed files with 37 additions and 35 deletions
|
|
@ -15,7 +15,8 @@
|
||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.js",
|
||||||
"templates.js",
|
"templates.js",
|
||||||
"types/index.d.ts"
|
"types/index.d.ts",
|
||||||
|
"types/options.d.ts"
|
||||||
],
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"color",
|
"color",
|
||||||
|
|
|
||||||
42
types/index.d.ts
vendored
42
types/index.d.ts
vendored
|
|
@ -1,36 +1,14 @@
|
||||||
// Type definitions for Chalk
|
/// <reference path="./options.d.ts" />
|
||||||
// Definitions by: Thomas Sauer <https://github.com/t-sauer>
|
interface ChalkConstructor {
|
||||||
|
new (options?: Chalk.Options): Chalk;
|
||||||
export const enum Level {
|
(options?: Chalk.Options): Chalk;
|
||||||
None = 0,
|
|
||||||
Basic = 1,
|
|
||||||
Ansi256 = 2,
|
|
||||||
TrueColor = 3
|
|
||||||
}
|
}
|
||||||
|
interface Chalk {
|
||||||
export interface ChalkOptions {
|
|
||||||
enabled?: boolean;
|
|
||||||
level?: Level;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ChalkConstructor {
|
|
||||||
new (options?: ChalkOptions): Chalk;
|
|
||||||
(options?: ChalkOptions): Chalk;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ColorSupport {
|
|
||||||
level: Level;
|
|
||||||
hasBasic: boolean;
|
|
||||||
has256: boolean;
|
|
||||||
has16m: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Chalk {
|
|
||||||
(...text: string[]): string;
|
(...text: string[]): string;
|
||||||
(text: TemplateStringsArray, ...placeholders: string[]): string;
|
(text: TemplateStringsArray, ...placeholders: string[]): string;
|
||||||
constructor: ChalkConstructor;
|
constructor: ChalkConstructor;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
level: Level;
|
level: Chalk.Level;
|
||||||
rgb(r: number, g: number, b: number): this;
|
rgb(r: number, g: number, b: number): this;
|
||||||
hsl(h: number, s: number, l: number): this;
|
hsl(h: number, s: number, l: number): this;
|
||||||
hsv(h: number, s: number, v: number): this;
|
hsv(h: number, s: number, v: number): this;
|
||||||
|
|
@ -92,6 +70,10 @@ export interface Chalk {
|
||||||
readonly bgWhiteBright: this;
|
readonly bgWhiteBright: this;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare const chalk: Chalk & { supportsColor: ColorSupport };
|
interface chalk extends Chalk {
|
||||||
|
supportsColor: Chalk.ColorSupport;
|
||||||
|
default: chalk
|
||||||
|
}
|
||||||
|
declare const chalk: chalk
|
||||||
|
export = chalk
|
||||||
|
|
||||||
export default chalk
|
|
||||||
|
|
|
||||||
18
types/options.d.ts
vendored
Normal file
18
types/options.d.ts
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
declare namespace Chalk {
|
||||||
|
export const enum Level {
|
||||||
|
None = 0,
|
||||||
|
Basic = 1,
|
||||||
|
Ansi256 = 2,
|
||||||
|
TrueColor = 3
|
||||||
|
}
|
||||||
|
export interface Options {
|
||||||
|
enabled?: boolean;
|
||||||
|
level?: Chalk.Level;
|
||||||
|
}
|
||||||
|
export interface ColorSupport {
|
||||||
|
level: Level;
|
||||||
|
hasBasic: boolean;
|
||||||
|
has256: boolean;
|
||||||
|
has16m: boolean;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import chalk, {Level} from '..';
|
import chalk from '..'
|
||||||
|
import chalktr = require('..')
|
||||||
|
|
||||||
chalk.underline('foo');
|
chalk.underline('foo');
|
||||||
chalk.red('foo');
|
chalk.red('foo');
|
||||||
|
|
@ -17,16 +18,16 @@ chalk.underline.red.bgGreen('foo');
|
||||||
chalk.grey('foo');
|
chalk.grey('foo');
|
||||||
|
|
||||||
chalk.constructor({level: 1});
|
chalk.constructor({level: 1});
|
||||||
const ctx = chalk.constructor({level: Level.TrueColor });
|
const ctx = chalk.constructor({level: Chalk.Level.TrueColor });
|
||||||
ctx('foo');
|
ctx('foo');
|
||||||
ctx.red('foo');
|
ctx.red('foo');
|
||||||
ctx`foo`;
|
ctx`foo`;
|
||||||
|
|
||||||
chalk.enabled = true;
|
chalk.enabled = true;
|
||||||
chalk.level = 1;
|
chalk.level = 1;
|
||||||
chalk.level = Level.Ansi256;
|
chalk.level = Chalk.Level.Ansi256;
|
||||||
|
|
||||||
chalk.level === Level.Ansi256;
|
chalk.level === Chalk.Level.Ansi256;
|
||||||
|
|
||||||
let chalkInstance = new chalk.constructor();
|
let chalkInstance = new chalk.constructor();
|
||||||
chalkInstance = chalk.constructor();
|
chalkInstance = chalk.constructor();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue