ansi-to-react
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -8,3 +8,2 @@ 'use strict'; | ||
var React = require('react'); | ||
var PropTypes = require('prop-types'); | ||
var Anser = require('anser'); | ||
@@ -75,8 +74,3 @@ var escapeCarriageReturn = require('escape-carriage'); | ||
Ansi.propTypes = { | ||
children: PropTypes.string, | ||
className: PropTypes.string | ||
}; | ||
module.exports = Ansi; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "ansi-to-react", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "ANSI to React Elements", | ||
@@ -9,5 +9,8 @@ "main": "lib/index.js", | ||
"prepublish": "npm run build", | ||
"test": "mocha --compilers js:babel-core/register 'test/**/*.js'", | ||
"test": "npm run test:unit && npm run test:flow", | ||
"test:flow": "flow", | ||
"test:unit": "mocha --compilers js:babel-core/register 'test/**/*.js'", | ||
"test:watch": "npm run test -- --watch", | ||
"build": "npm run build:es5", | ||
"build": "npm run build:es5 && npm run build:flow", | ||
"build:flow": "flow-copy-source -v -i '**/tests/**' src lib", | ||
"build:es5": "babel src --out-dir lib/ --source-maps", | ||
@@ -29,2 +32,5 @@ "clean": "rimraf lib/*" | ||
"react" | ||
], | ||
"plugins": [ | ||
"transform-flow-strip-types" | ||
] | ||
@@ -39,3 +45,2 @@ }, | ||
"peerDependencies": { | ||
"prop-types": "^15.5.9", | ||
"react": "^15.0.0-0" | ||
@@ -46,2 +51,3 @@ }, | ||
"babel-core": "^6.8.0", | ||
"babel-plugin-transform-flow-strip-types": "^6.22.0", | ||
"babel-preset-es2015": "^6.6.0", | ||
@@ -52,2 +58,4 @@ "babel-preset-react": "^6.5.0", | ||
"enzyme": "^2.2.0", | ||
"flow-bin": "^0.46.0", | ||
"flow-copy-source": "^1.1.0", | ||
"mkdirp": "0.5.1", | ||
@@ -58,5 +66,4 @@ "mocha": "^3.2.0", | ||
"react-dom": "^15.0.1", | ||
"rimraf": "^2.5.2", | ||
"should": "^11.1.2" | ||
"rimraf": "^2.5.2" | ||
} | ||
} |
@@ -0,6 +1,28 @@ | ||
/* @flow */ | ||
const React = require('react'); | ||
const PropTypes = require('prop-types'); | ||
const Anser = require('anser'); | ||
const escapeCarriageReturn = require('escape-carriage'); | ||
type AnserJsonEntry = { | ||
content: string, | ||
fg: string, | ||
bg: string, | ||
fg_truecolor: string, | ||
bg_truecolor: string, | ||
clearLine: boolean, | ||
was_processed: boolean, | ||
isEmpty: () => boolean | ||
}; | ||
type AnserJson = Array<AnserJsonEntry>; | ||
type AnsiBundle = { | ||
content: string, | ||
style: { | ||
color?: string, | ||
backgroundColor?: string | ||
} | ||
}; | ||
/** | ||
@@ -15,3 +37,3 @@ * ansiToJson | ||
*/ | ||
function ansiToJSON(input) { | ||
function ansiToJSON(input: string): AnserJson { | ||
input = escapeCarriageReturn(input); | ||
@@ -24,3 +46,3 @@ return Anser.ansiToJson(input, { | ||
function ansiJSONtoStyleBundle(ansiBundle) { | ||
function ansiJSONtoStyleBundle(ansiBundle: AnserJsonEntry): AnsiBundle { | ||
const style = {}; | ||
@@ -39,7 +61,7 @@ if (ansiBundle.bg) { | ||
function ansiToInlineStyle(text) { | ||
function ansiToInlineStyle(text: string): Array<AnsiBundle> { | ||
return ansiToJSON(text).map(ansiJSONtoStyleBundle); | ||
} | ||
function linkifyBundle(bundle) { | ||
function linkifyBundle(bundle: AnsiBundle) { | ||
return { | ||
@@ -74,3 +96,3 @@ ...bundle, | ||
function Ansi(props) { | ||
function Ansi(props: {children: string, className?: string}) { | ||
return React.createElement( | ||
@@ -87,7 +109,2 @@ 'code', | ||
Ansi.propTypes = { | ||
children: PropTypes.string, | ||
className: PropTypes.string | ||
}; | ||
module.exports = Ansi; |
Sorry, the diff of this file is not supported yet
17012
3
10
210
16