This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

210
node_modules/ansi-fragments/README.md generated vendored Normal file
View File

@ -0,0 +1,210 @@
# ansi-fragments
[![Version][version]][package]
[![PRs Welcome][prs-welcome-badge]][prs-welcome]
[![MIT License][license-badge]][license]
[![Chat][chat-badge]][chat]
[![Code of Conduct][coc-badge]][coc]
A tiny library with builders to help making logs/CLI pretty with a nice DX.
- [ansi-fragments](#ansi-fragments)
- [Installation](#installation)
- [Usage](#usage)
- [API](#api)
- [`color`](#color)
- [`modifier`](#modifier)
- [`container`](#container)
- [`pad`](#pad)
- [`fixed`](#fixed)
- [`ifElse`](#ifElse)
- [`provide`](#provide)
## Installation
```bash
yarn add ansi-fragments
```
## Usage
```js
import { color, modifier, pad, container } from 'ansi-fragments';
const prettyLog = (level, message) => container(
color('green', modifier('italic', level)),
pad(1),
message
).build();
console.log(prettyLog('success', 'Yay!'));
```
## API
Each fragment implements `IFragment` interface:
```ts
interface IFragment {
build(): string;
}
```
The `build` method is responsible for traversing the tree of fragments and create a string representation with ANSI escape codes.
#### `color`
```ts
color(
ansiColor: AnsiColor,
...children: Array<string | IFragment>
): IFragment
```
Creates fragment for standard ANSI [colors](./src/fragments/Color.ts).
```js
color('red', 'Oh no');
color('bgBlue', color('brightBlue', 'Hey'));
color('green', modifier('bold', 'Sup!'));
```
#### `modifier`
```ts
modifier(
ansiModifier: AnsiModifier,
...children: Array<string | IFragment>
): IFragment
```
Creates fragment for standard ANSI [modifiers](./src/fragments/Modifier.ts): `dim`, `bold`, `hidden`, `italic`, `underline`, `strikethrough`.
```js
modifier('underline', 'Hello', 'World');
modifier('italic', modifier('bold', 'Hey'));
modifier('bold', color('green', 'Sup!'));
```
#### `container`
```ts
container(...children: Array<string | IFragment>): IFragment
```
Creates fragment, which sole purpose is to hold and build nested fragments.
```js
container(
color('gray', '[08/01/18 12:00]'),
pad(1),
color('green', 'success'),
pad(1),
'Some message'
)
```
#### `pad`
```ts
pad(count: number, separator?: string): IFragment
```
Creates fragment, which repeats given separator (default: ` `) given number of times.
```js
pad(1);
pad(2, '#')
pad(1, '\n')
```
#### `fixed`
```ts
fixed(
value: number,
bias: 'start' | 'end',
...children: Array<string | IFragment>
): IFragment
```
Creates fragment, which makes sure the children will always build to given number of non-ANSI characters. It will either trim the results or add necessary amount of spaces. The `bias` control if trimming/padding should be done at the start of the string representing built children or at the end.
```js
fixed(5, 'start', 'ERR'); // => ' ERR'
fixed(8, 'end', color('green', 'success')); // equals to color('green', 'success') + ' '
fixed(10, 'end', 'Hello', pad(2), 'World') // => 'Hello Wor'
```
#### `ifElse`
```ts
ifElse(
condition: Condition,
ifTrueFragment: string | IFragment,
elseFragment: string | IFragment
): IFragment
type ConditionValue = boolean | string | number | null | undefined;
type Condition = ConditionValue | (() => ConditionValue);
```
Change the output based on condition. Condition can ba a primitive value, which can be casted to boolean or a function. If conation or return value of condition is evaluated to `true`, the first argument - `ifTrueFragment` will be used, otherwise `elseFragment`.
```js
let condition = getConditionValue()
ifElse(
() => condition,
color('red', 'ERROR'),
color('yellow', 'WARNING')
)
```
#### `provide`
```ts
provide<T>(
value: T,
builder: (value: T) => string | IFragment
): IFragment
```
Provides given value to a builder function, which should return `string` or fragment. Useful in situations when the output is connected with some calculated value - using `provide` you only need to calculate final value once and forward it to custom styling logic.
```js
provide(getMessageFromSomewhere(), value => {
switch (value.level) {
case 'error':
return container(
color('red', modifier('bold', value.level.toUpperCase())),
pad(2),
value.log
);
case 'info':
return container(
color('blue', value.level.toUpperCase()),
pad(2),
value.log
);
default:
return container(value.level.toUpperCase(), pad(2), value.log);
}
})
```
<!-- badges (common) -->
[license-badge]: https://img.shields.io/npm/l/ansi-fragments.svg?style=flat-square
[license]: https://opensource.org/licenses/MIT
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[prs-welcome]: http://makeapullrequest.com
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
[coc]: https://github.com/zamotany/ansi-fragments/blob/master/CODE_OF_CONDUCT.md
[chat-badge]: https://img.shields.io/badge/chat-discord-brightgreen.svg?style=flat-square&colorB=7289DA&logo=discord
[chat]: https://discord.gg/zwR2Cdh
[version]: https://img.shields.io/npm/v/ansi-fragments.svg?style=flat-square
[package]: https://www.npmjs.com/package/ansi-fragments

10
node_modules/ansi-fragments/build/fragments/Color.d.ts generated vendored Normal file
View File

@ -0,0 +1,10 @@
import IFragment from './IFragment';
export declare type AnsiColor = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'brightBlack' | 'brightRed' | 'brightGreen' | 'brightYellow' | 'brightBlue' | 'brightMagenta' | 'brightCyan' | 'brightWhite' | 'gray' | 'bgBlack' | 'bgRed' | 'bgGreen' | 'bgYellow' | 'bgBlue' | 'bgMagenta' | 'bgCyan' | 'bgWhite' | 'bgBrightBlack' | 'bgBrightRed' | 'bgBrightGreen' | 'bgBrightYellow' | 'bgBrightBlue' | 'bgBrightMagenta' | 'bgBrightCyan' | 'bgBrightWhite' | 'none';
export declare function color(ansiColor: AnsiColor, ...children: Array<string | IFragment>): Color;
export declare class Color implements IFragment {
private readonly color;
private readonly children;
constructor(ansiColor: AnsiColor, children: Array<string | IFragment>);
build(): string;
}
//# sourceMappingURL=Color.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../src/fragments/Color.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC,oBAAY,SAAS,GACjB,OAAO,GACP,KAAK,GACL,OAAO,GACP,QAAQ,GACR,MAAM,GACN,SAAS,GACT,MAAM,GACN,OAAO,GACP,aAAa,GACb,WAAW,GACX,aAAa,GACb,cAAc,GACd,YAAY,GACZ,eAAe,GACf,YAAY,GACZ,aAAa,GACb,MAAM,GACN,SAAS,GACT,OAAO,GACP,SAAS,GACT,UAAU,GACV,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,SAAS,GACT,eAAe,GACf,aAAa,GACb,eAAe,GACf,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,cAAc,GACd,eAAe,GACf,MAAM,CAAC;AAEX,wBAAgB,KAAK,CACnB,SAAS,EAAE,SAAS,EACpB,GAAG,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GACrC,KAAK,CAEP;AAED,qBAAa,KAAM,YAAW,SAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;gBAEzC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;IAKrE,KAAK,IAAI,MAAM;CAYhB"}

30
node_modules/ansi-fragments/build/fragments/Color.js generated vendored Normal file
View File

@ -0,0 +1,30 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const colorette_1 = __importDefault(require("colorette"));
const utils_1 = require("./utils");
function color(ansiColor, ...children) {
return new Color(ansiColor, utils_1.toArray(children));
}
exports.color = color;
class Color {
constructor(ansiColor, children) {
this.color = ansiColor;
this.children = children;
}
build() {
const children = utils_1.buildChildren(this.children);
if (this.color === 'none') {
return children;
}
else if (this.color in colorette_1.default) {
// tslint:disable-next-line: no-unsafe-any no-any
return colorette_1.default[this.color](children);
}
throw new Error(`Color ${this.color} not found`);
}
}
exports.Color = Color;
//# sourceMappingURL=Color.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Color.js","sourceRoot":"","sources":["../../src/fragments/Color.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAElC,mCAAiD;AAsCjD,SAAgB,KAAK,CACnB,SAAoB,EACpB,GAAG,QAAmC;IAEtC,OAAO,IAAI,KAAK,CAAC,SAAS,EAAE,eAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AACjD,CAAC;AALD,sBAKC;AAED,MAAa,KAAK;IAIhB,YAAY,SAAoB,EAAE,QAAmC;QACnE,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,KAAK;QACH,MAAM,QAAQ,GAAG,qBAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,EAAE;YACzB,OAAO,QAAQ,CAAC;SACjB;aAAM,IAAI,IAAI,CAAC,KAAK,IAAI,mBAAS,EAAE;YAClC,iDAAiD;YACjD,OAAQ,mBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC;SACjD;QAED,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,KAAK,YAAY,CAAC,CAAC;IACnD,CAAC;CACF;AArBD,sBAqBC"}

View File

@ -0,0 +1,8 @@
import IFragment from './IFragment';
export declare function container(...children: Array<string | IFragment>): Container;
export declare class Container implements IFragment {
private readonly children;
constructor(children: Array<string | IFragment>);
build(): string;
}
//# sourceMappingURL=Container.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../src/fragments/Container.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC,wBAAgB,SAAS,CAAC,GAAG,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAE3E;AAED,qBAAa,SAAU,YAAW,SAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;gBAEzC,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;IAI/C,KAAK,IAAI,MAAM;CAGhB"}

View File

@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("./utils");
function container(...children) {
return new Container(children);
}
exports.container = container;
class Container {
constructor(children) {
this.children = children;
}
build() {
return utils_1.buildChildren(this.children);
}
}
exports.Container = Container;
//# sourceMappingURL=Container.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Container.js","sourceRoot":"","sources":["../../src/fragments/Container.ts"],"names":[],"mappings":";;AACA,mCAAwC;AAExC,SAAgB,SAAS,CAAC,GAAG,QAAmC;IAC9D,OAAO,IAAI,SAAS,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC;AAFD,8BAEC;AAED,MAAa,SAAS;IAGpB,YAAY,QAAmC;QAC7C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,KAAK;QACH,OAAO,qBAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;CACF;AAVD,8BAUC"}

12
node_modules/ansi-fragments/build/fragments/Fixed.d.ts generated vendored Normal file
View File

@ -0,0 +1,12 @@
import IFragment from './IFragment';
declare type Bias = 'start' | 'end';
export declare function fixed(value: number, bias: Bias, ...children: Array<string | IFragment>): Fixed;
export declare class Fixed implements IFragment {
private readonly width;
private readonly bias;
private readonly children;
constructor(width: number, bias: Bias, children: Array<string | IFragment>);
build(): string;
}
export {};
//# sourceMappingURL=Fixed.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Fixed.d.ts","sourceRoot":"","sources":["../../src/fragments/Fixed.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC,aAAK,IAAI,GAAG,OAAO,GAAG,KAAK,CAAC;AAE5B,wBAAgB,KAAK,CACnB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,IAAI,EACV,GAAG,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GACrC,KAAK,CAEP;AAED,qBAAa,KAAM,YAAW,SAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;gBAEzC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;IAM1E,KAAK,IAAI,MAAM;CAgBhB"}

31
node_modules/ansi-fragments/build/fragments/Fixed.js generated vendored Normal file
View File

@ -0,0 +1,31 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const slice_ansi_1 = __importDefault(require("slice-ansi"));
const strip_ansi_1 = __importDefault(require("strip-ansi"));
const utils_1 = require("./utils");
function fixed(value, bias, ...children) {
return new Fixed(value, bias, children);
}
exports.fixed = fixed;
class Fixed {
constructor(width, bias, children) {
this.width = width;
this.bias = bias;
this.children = children;
}
build() {
const children = utils_1.buildChildren(this.children);
const contentLength = strip_ansi_1.default(children).length;
if (contentLength <= this.width) {
return `${' '.repeat(this.bias === 'start' ? this.width - contentLength : 0)}${contentLength}${' '.repeat(this.bias === 'end' ? this.width - contentLength : 0)}`;
}
const start = this.bias === 'end' ? 0 : contentLength - this.width;
const end = this.bias === 'end' ? this.width : contentLength;
return slice_ansi_1.default(children, start, end);
}
}
exports.Fixed = Fixed;
//# sourceMappingURL=Fixed.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Fixed.js","sourceRoot":"","sources":["../../src/fragments/Fixed.ts"],"names":[],"mappings":";;;;;AAAA,4DAAmC;AACnC,4DAAmC;AAEnC,mCAAwC;AAIxC,SAAgB,KAAK,CACnB,KAAa,EACb,IAAU,EACV,GAAG,QAAmC;IAEtC,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAND,sBAMC;AAED,MAAa,KAAK;IAKhB,YAAY,KAAa,EAAE,IAAU,EAAE,QAAmC;QACxE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,KAAK;QACH,MAAM,QAAQ,GAAG,qBAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9C,MAAM,aAAa,GAAG,oBAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;QAEjD,IAAI,aAAa,IAAI,IAAI,CAAC,KAAK,EAAE;YAC/B,OAAO,GAAG,GAAG,CAAC,MAAM,CAClB,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CACvD,GAAG,aAAa,GAAG,GAAG,CAAC,MAAM,CAC5B,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CACrD,EAAE,CAAC;SACL;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC;QACnE,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC;QAC7D,OAAO,oBAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;CACF;AA3BD,sBA2BC"}

View File

@ -0,0 +1,4 @@
export default interface IFragment {
build(): string;
}
//# sourceMappingURL=IFragment.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"IFragment.d.ts","sourceRoot":"","sources":["../../src/fragments/IFragment.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,WAAW,SAAS;IAChC,KAAK,IAAI,MAAM,CAAC;CACjB"}

View File

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IFragment.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"IFragment.js","sourceRoot":"","sources":["../../src/fragments/IFragment.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,12 @@
import IFragment from './IFragment';
export declare type ConditionValue = boolean | string | number | null | undefined;
export declare type Condition = ConditionValue | (() => ConditionValue);
export declare function ifElse(condition: Condition, ifTrueFragment: string | IFragment, elseFragment?: string | IFragment): IfElse;
export declare class IfElse implements IFragment {
private readonly ifTrueFragment;
private readonly elseFragment?;
private readonly condition;
constructor(condition: Condition, ifTrueFragment: string | IFragment, elseFragment?: string | IFragment);
build(): string;
}
//# sourceMappingURL=IfElse.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"IfElse.d.ts","sourceRoot":"","sources":["../../src/fragments/IfElse.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC,oBAAY,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAC1E,oBAAY,SAAS,GAAG,cAAc,GAAG,CAAC,MAAM,cAAc,CAAC,CAAC;AAEhE,wBAAgB,MAAM,CACpB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,GAChC,MAAM,CAER;AAED,qBAAa,MAAO,YAAW,SAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAqB;IACpD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAqB;IACnD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;gBAGpC,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS;IAOnC,KAAK,IAAI,MAAM;CAShB"}

22
node_modules/ansi-fragments/build/fragments/IfElse.js generated vendored Normal file
View File

@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("./utils");
function ifElse(condition, ifTrueFragment, elseFragment) {
return new IfElse(condition, ifTrueFragment, elseFragment);
}
exports.ifElse = ifElse;
class IfElse {
constructor(condition, ifTrueFragment, elseFragment) {
this.condition = condition;
this.ifTrueFragment = ifTrueFragment;
this.elseFragment = elseFragment;
}
build() {
const value = Boolean(typeof this.condition === 'function' ? this.condition() : this.condition);
return utils_1.buildChildren([
value ? this.ifTrueFragment : this.elseFragment || '',
]);
}
}
exports.IfElse = IfElse;
//# sourceMappingURL=IfElse.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"IfElse.js","sourceRoot":"","sources":["../../src/fragments/IfElse.ts"],"names":[],"mappings":";;AACA,mCAAwC;AAKxC,SAAgB,MAAM,CACpB,SAAoB,EACpB,cAAkC,EAClC,YAAiC;IAEjC,OAAO,IAAI,MAAM,CAAC,SAAS,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;AAC7D,CAAC;AAND,wBAMC;AAED,MAAa,MAAM;IAKjB,YACE,SAAoB,EACpB,cAAkC,EAClC,YAAiC;QAEjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED,KAAK;QACH,MAAM,KAAK,GAAG,OAAO,CACnB,OAAO,IAAI,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CACzE,CAAC;QAEF,OAAO,qBAAa,CAAC;YACnB,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE;SACtD,CAAC,CAAC;IACL,CAAC;CACF;AAxBD,wBAwBC"}

View File

@ -0,0 +1,10 @@
import IFragment from './IFragment';
export declare type AnsiModifier = 'dim' | 'bold' | 'hidden' | 'italic' | 'underline' | 'strikethrough' | 'none';
export declare function modifier(ansiModifier: AnsiModifier, ...children: Array<string | IFragment>): Modifier;
export declare class Modifier implements IFragment {
private readonly modifier;
private readonly children;
constructor(ansiModifier: AnsiModifier, children: Array<string | IFragment>);
build(): string;
}
//# sourceMappingURL=Modifier.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Modifier.d.ts","sourceRoot":"","sources":["../../src/fragments/Modifier.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAIpC,oBAAY,YAAY,GACpB,KAAK,GACL,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,eAAe,GACf,MAAM,CAAC;AAEX,wBAAgB,QAAQ,CACtB,YAAY,EAAE,YAAY,EAC1B,GAAG,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GACrC,QAAQ,CAEV;AAED,qBAAa,QAAS,YAAW,SAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;gBAEzC,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;IAK3E,KAAK,IAAI,MAAM;CAWhB"}

View File

@ -0,0 +1,30 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const colorette_1 = __importDefault(require("colorette"));
const utils_1 = require("./utils");
function modifier(ansiModifier, ...children) {
return new Modifier(ansiModifier, utils_1.toArray(children));
}
exports.modifier = modifier;
class Modifier {
constructor(ansiModifier, children) {
this.modifier = ansiModifier;
this.children = children;
}
build() {
const children = utils_1.buildChildren(this.children);
if (this.modifier === 'none') {
return children;
}
else if (this.modifier in colorette_1.default) {
// tslint:disable-next-line: no-unsafe-any no-any
return colorette_1.default[this.modifier](children);
}
throw new Error(`Modifier ${this.modifier} not found`);
}
}
exports.Modifier = Modifier;
//# sourceMappingURL=Modifier.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Modifier.js","sourceRoot":"","sources":["../../src/fragments/Modifier.ts"],"names":[],"mappings":";;;;;AACA,0DAAkC;AAClC,mCAAiD;AAWjD,SAAgB,QAAQ,CACtB,YAA0B,EAC1B,GAAG,QAAmC;IAEtC,OAAO,IAAI,QAAQ,CAAC,YAAY,EAAE,eAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AACvD,CAAC;AALD,4BAKC;AAED,MAAa,QAAQ;IAInB,YAAY,YAA0B,EAAE,QAAmC;QACzE,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,KAAK;QACH,MAAM,QAAQ,GAAG,qBAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,IAAI,CAAC,QAAQ,KAAK,MAAM,EAAE;YAC5B,OAAO,QAAQ,CAAC;SACjB;aAAM,IAAI,IAAI,CAAC,QAAQ,IAAI,mBAAS,EAAE;YACrC,iDAAiD;YACjD,OAAQ,mBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC;SACpD;QAED,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,CAAC,QAAQ,YAAY,CAAC,CAAC;IACzD,CAAC;CACF;AApBD,4BAoBC"}

9
node_modules/ansi-fragments/build/fragments/Pad.d.ts generated vendored Normal file
View File

@ -0,0 +1,9 @@
import IFragment from './IFragment';
export declare function pad(count: number, separator?: string): Pad;
export declare class Pad implements IFragment {
private readonly count;
private readonly separator;
constructor(count: number, separator?: string);
build(): string;
}
//# sourceMappingURL=Pad.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Pad.d.ts","sourceRoot":"","sources":["../../src/fragments/Pad.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,GAAG,CAE1D;AAED,qBAAa,GAAI,YAAW,SAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,MAAY;IAKlD,KAAK,IAAI,MAAM;CAGhB"}

17
node_modules/ansi-fragments/build/fragments/Pad.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function pad(count, separator) {
return new Pad(count, separator);
}
exports.pad = pad;
class Pad {
constructor(count, separator = ' ') {
this.count = count;
this.separator = separator;
}
build() {
return this.separator.repeat(this.count);
}
}
exports.Pad = Pad;
//# sourceMappingURL=Pad.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Pad.js","sourceRoot":"","sources":["../../src/fragments/Pad.ts"],"names":[],"mappings":";;AAEA,SAAgB,GAAG,CAAC,KAAa,EAAE,SAAkB;IACnD,OAAO,IAAI,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACnC,CAAC;AAFD,kBAEC;AAED,MAAa,GAAG;IAId,YAAY,KAAa,EAAE,YAAoB,GAAG;QAChD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AAZD,kBAYC"}

View File

@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=fragments.spec.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"fragments.spec.d.ts","sourceRoot":"","sources":["../../../src/fragments/__tests__/fragments.spec.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,30 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Color_1 = require("../Color");
const Modifier_1 = require("../Modifier");
const Container_1 = require("../Container");
const Pad_1 = require("../Pad");
const Fixed_1 = require("../Fixed");
const colorette_1 = __importDefault(require("colorette"));
const IfElse_1 = require("../IfElse");
colorette_1.default.options.enabled = true;
test('should build fragments to string', () => {
const tree = Container_1.container(Color_1.color('red', Color_1.color('bgBlack', Color_1.color('none', 'Hello', Pad_1.pad(1), 'World'))), Pad_1.pad(2, '|'), Modifier_1.modifier('bold', Color_1.color('white', 'Something')), Pad_1.pad(1), Fixed_1.fixed(4, 'end', 'This', 'will', Color_1.color('blue', 'be trimmed')), Pad_1.pad(1), Fixed_1.fixed(10, 'start', Color_1.color('blue', 'nothing is awesome')));
const text = tree.build();
const expected = `${colorette_1.default.red(colorette_1.default.bgBlack('Hello World'))}||${colorette_1.default.bold(colorette_1.default.white('Something'))} This ${colorette_1.default.blue('is awesome')}`;
expect(JSON.stringify(text)).toEqual(JSON.stringify(expected));
});
test('ifElse fragment should render correct fragmnent', () => {
expect(IfElse_1.ifElse(true, 'Hello', 'Bye').build()).toEqual('Hello');
expect(IfElse_1.ifElse(1, 'Hello', 'Bye').build()).toEqual('Hello');
expect(IfElse_1.ifElse(undefined, 'Hello', 'Bye').build()).toEqual('Bye');
// tslint:disable-next-line: no-null-keyword
expect(IfElse_1.ifElse(null, 'Hello', 'Bye').build()).toEqual('Bye');
expect(IfElse_1.ifElse(true, 'Hello').build()).toEqual('Hello');
expect(IfElse_1.ifElse(false, 'Hello').build()).toEqual('');
expect(IfElse_1.ifElse(() => true, 'Hello', 'Bye').build()).toEqual('Hello');
});
//# sourceMappingURL=fragments.spec.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"fragments.spec.js","sourceRoot":"","sources":["../../../src/fragments/__tests__/fragments.spec.ts"],"names":[],"mappings":";;;;;AAAA,oCAAiC;AACjC,0CAAuC;AACvC,4CAAyC;AACzC,gCAA6B;AAC7B,oCAAiC;AACjC,0DAAkC;AAClC,sCAAmC;AAEnC,mBAAS,CAAC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;AAEjC,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAC5C,MAAM,IAAI,GAAG,qBAAS,CACpB,aAAK,CAAC,KAAK,EAAE,aAAK,CAAC,SAAS,EAAE,aAAK,CAAC,MAAM,EAAE,OAAO,EAAE,SAAG,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EACvE,SAAG,CAAC,CAAC,EAAE,GAAG,CAAC,EACX,mBAAQ,CAAC,MAAM,EAAE,aAAK,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,EAC7C,SAAG,CAAC,CAAC,CAAC,EACN,aAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,aAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,EAC5D,SAAG,CAAC,CAAC,CAAC,EACN,aAAK,CAAC,EAAE,EAAE,OAAO,EAAE,aAAK,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CACxD,CAAC;IAEF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;IAC1B,MAAM,QAAQ,GAAG,GAAG,mBAAS,CAAC,GAAG,CAC/B,mBAAS,CAAC,OAAO,CAAC,aAAa,CAAC,CACjC,KAAK,mBAAS,CAAC,IAAI,CAAC,mBAAS,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,SAAS,mBAAS,CAAC,IAAI,CACvE,YAAY,CACb,EAAE,CAAC;IACJ,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,iDAAiD,EAAE,GAAG,EAAE;IAC3D,MAAM,CAAC,eAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9D,MAAM,CAAC,eAAM,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,MAAM,CAAC,eAAM,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACjE,4CAA4C;IAC5C,MAAM,CAAC,eAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5D,MAAM,CAAC,eAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,MAAM,CAAC,eAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACnD,MAAM,CAAC,eAAM,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AACtE,CAAC,CAAC,CAAC"}

View File

@ -0,0 +1,4 @@
import IFragment from './IFragment';
export declare function buildChildren(children: Array<string | IFragment>): string;
export declare function toArray<T>(value: T | T[]): T[];
//# sourceMappingURL=utils.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/fragments/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,wBAAgB,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAMzE;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAE9C"}

13
node_modules/ansi-fragments/build/fragments/utils.js generated vendored Normal file
View File

@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function buildChildren(children) {
return children
.map((child) => typeof child === 'string' ? child : child.build())
.join('');
}
exports.buildChildren = buildChildren;
function toArray(value) {
return Array.isArray(value) ? value : [value];
}
exports.toArray = toArray;
//# sourceMappingURL=utils.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/fragments/utils.ts"],"names":[],"mappings":";;AAEA,SAAgB,aAAa,CAAC,QAAmC;IAC/D,OAAO,QAAQ;SACZ,GAAG,CAAC,CAAC,KAAyB,EAAE,EAAE,CACjC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAClD;SACA,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAND,sCAMC;AAED,SAAgB,OAAO,CAAI,KAAc;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAFD,0BAEC"}

7
node_modules/ansi-fragments/build/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,7 @@
export { color, AnsiColor } from './fragments/Color';
export { modifier, AnsiModifier } from './fragments/Modifier';
export { pad } from './fragments/Pad';
export { container } from './fragments/Container';
export { fixed } from './fragments/Fixed';
export { ifElse, Condition, ConditionValue } from './fragments/IfElse';
//# sourceMappingURL=index.d.ts.map

1
node_modules/ansi-fragments/build/index.d.ts.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}

15
node_modules/ansi-fragments/build/index.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Color_1 = require("./fragments/Color");
exports.color = Color_1.color;
var Modifier_1 = require("./fragments/Modifier");
exports.modifier = Modifier_1.modifier;
var Pad_1 = require("./fragments/Pad");
exports.pad = Pad_1.pad;
var Container_1 = require("./fragments/Container");
exports.container = Container_1.container;
var Fixed_1 = require("./fragments/Fixed");
exports.fixed = Fixed_1.fixed;
var IfElse_1 = require("./fragments/IfElse");
exports.ifElse = IfElse_1.ifElse;
//# sourceMappingURL=index.js.map

1
node_modules/ansi-fragments/build/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,2CAAqD;AAA5C,wBAAA,KAAK,CAAA;AACd,iDAA8D;AAArD,8BAAA,QAAQ,CAAA;AACjB,uCAAsC;AAA7B,oBAAA,GAAG,CAAA;AACZ,mDAAkD;AAAzC,gCAAA,SAAS,CAAA;AAClB,2CAA0C;AAAjC,wBAAA,KAAK,CAAA;AACd,6CAAuE;AAA9D,0BAAA,MAAM,CAAA"}

View File

@ -0,0 +1,14 @@
'use strict';
module.exports = options => {
options = Object.assign({
onlyFirst: false
}, options);
const pattern = [
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
].join('|');
return new RegExp(pattern, options.onlyFirst ? undefined : 'g');
};

View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,53 @@
{
"name": "ansi-regex",
"version": "4.1.0",
"description": "Regular expression for matching ANSI escape codes",
"license": "MIT",
"repository": "chalk/ansi-regex",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava",
"view-supported": "node fixtures/view-codes.js"
},
"files": [
"index.js"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"text",
"regex",
"regexp",
"re",
"match",
"test",
"find",
"pattern"
],
"devDependencies": {
"ava": "^0.25.0",
"xo": "^0.23.0"
}
}

View File

@ -0,0 +1,87 @@
# ansi-regex [![Build Status](https://travis-ci.org/chalk/ansi-regex.svg?branch=master)](https://travis-ci.org/chalk/ansi-regex)
> Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-ansi-regex?utm_source=npm-ansi-regex&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
---
## Install
```
$ npm install ansi-regex
```
## Usage
```js
const ansiRegex = require('ansi-regex');
ansiRegex().test('\u001B[4mcake\u001B[0m');
//=> true
ansiRegex().test('cake');
//=> false
'\u001B[4mcake\u001B[0m'.match(ansiRegex());
//=> ['\u001B[4m', '\u001B[0m']
'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true}));
//=> ['\u001B[4m']
'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex());
//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
```
## API
### ansiRegex([options])
Returns a regex for matching ANSI escape codes.
#### options
##### onlyFirst
Type: `boolean`<br>
Default: `false` *(Matches any ANSI escape codes in a string)*
Match only the first ANSI escape.
## FAQ
### Why do you test for codes not in the ECMA 48 standard?
Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. We test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them.
On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out.
## Security
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
## Maintainers
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)
## License
MIT

View File

@ -0,0 +1,15 @@
/**
Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string.
@example
```
import stripAnsi from 'strip-ansi';
stripAnsi('\u001B[4mUnicorn\u001B[0m');
//=> 'Unicorn'
stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
//=> 'Click'
```
*/
export default function stripAnsi(string: string): string;

View File

@ -0,0 +1,7 @@
'use strict';
const ansiRegex = require('ansi-regex');
const stripAnsi = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;
module.exports = stripAnsi;
module.exports.default = stripAnsi;

View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,54 @@
{
"name": "strip-ansi",
"version": "5.2.0",
"description": "Strip ANSI escape codes from a string",
"license": "MIT",
"repository": "chalk/strip-ansi",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava && tsd-check"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"strip",
"trim",
"remove",
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-regex": "^4.1.0"
},
"devDependencies": {
"ava": "^1.3.1",
"tsd-check": "^0.5.0",
"xo": "^0.24.0"
}
}

View File

@ -0,0 +1,61 @@
# strip-ansi [![Build Status](https://travis-ci.org/chalk/strip-ansi.svg?branch=master)](https://travis-ci.org/chalk/strip-ansi)
> Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-strip-ansi?utm_source=npm-strip-ansi&utm_medium=referral&utm_campaign=readme">Get professional support for 'strip-ansi' with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
---
## Install
```
$ npm install strip-ansi
```
## Usage
```js
const stripAnsi = require('strip-ansi');
stripAnsi('\u001B[4mUnicorn\u001B[0m');
//=> 'Unicorn'
stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
//=> 'Click'
```
## Security
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
## Related
- [strip-ansi-cli](https://github.com/chalk/strip-ansi-cli) - CLI for this module
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Streaming version of this module
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
## Maintainers
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)
## License
MIT

50
node_modules/ansi-fragments/package.json generated vendored Normal file
View File

@ -0,0 +1,50 @@
{
"name": "ansi-fragments",
"version": "0.2.1",
"main": "build/index.js",
"license": "MIT",
"description": "A tiny library with builders to help making logs/CLI pretty with a nice DX.",
"repository": {
"type": "git",
"url": "https://github.com/zamotany/ansi-fragments.git"
},
"keywords": [
"cli",
"ansi"
],
"author": "Paweł Trysła <zamotany.oss@gmail.com>",
"bugs": {
"url": "https://github.com/zamotany/ansi-fragments/issues"
},
"homepage": "https://github.com/zamotany/ansi-fragments",
"files": [
"build/"
],
"scripts": {
"lint": "tslint -t stylish --project tsconfig.json",
"test": "jest",
"build": "tsc --build tsconfig.json",
"clean": "del build",
"prepare": "yarn clean && yarn build"
},
"dependencies": {
"colorette": "^1.0.7",
"slice-ansi": "^2.0.0",
"strip-ansi": "^5.0.0"
},
"devDependencies": {
"@callstack/tslint-config": "^0.1.0",
"@types/jest": "^23.3.13",
"@types/slice-ansi": "^2.0.0",
"@types/strip-ansi": "^3.0.0",
"del-cli": "^1.1.0",
"jest": "^24.0.0",
"ts-jest": "^23.10.5",
"tslint": "^5.12.0",
"typescript": "^3.2.2"
},
"jest": {
"preset": "ts-jest",
"rootDir": "./src"
}
}