Skip to content

Commit d2a1739

Browse files
lgeigerrgbkrk
authored andcommitted
fix(flow): Remove flow typings (#29)
to fix nteract/nteract#1704 (comment)
1 parent ba949b6 commit d2a1739

File tree

1 file changed

+11
-26
lines changed

1 file changed

+11
-26
lines changed

src/index.js

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,6 @@ const React = require('react');
44
const Anser = require('anser');
55
const escapeCarriageReturn = require('escape-carriage');
66

7-
type AnserJsonEntry = {
8-
content: string,
9-
fg: string,
10-
bg: string,
11-
fg_truecolor: string,
12-
bg_truecolor: string,
13-
clearLine: boolean,
14-
was_processed: boolean,
15-
isEmpty: () => boolean
16-
};
17-
18-
type AnserJson = Array<AnserJsonEntry>;
19-
20-
type AnsiBundle = {
21-
content: string,
22-
style: {
23-
color?: string,
24-
backgroundColor?: string
25-
}
26-
};
27-
287
/**
298
* ansiToJson
309
* Convert ANSI strings into JSON output.
@@ -34,15 +13,15 @@ type AnsiBundle = {
3413
* @param {String} input The input string.
3514
* @return {Array} The parsed input.
3615
*/
37-
function ansiToJSON(input: string): AnserJson {
16+
function ansiToJSON(input) {
3817
input = escapeCarriageReturn(input);
3918
return Anser.ansiToJson(input, {
4019
json: true,
4120
remove_empty: true,
4221
});
4322
}
4423

45-
function ansiJSONtoStyleBundle(ansiBundle: AnserJsonEntry): AnsiBundle {
24+
function ansiJSONtoStyleBundle(ansiBundle) {
4625
const style = {};
4726
if (ansiBundle.bg) {
4827
style.backgroundColor = `rgb(${ansiBundle.bg})`;
@@ -56,11 +35,11 @@ function ansiJSONtoStyleBundle(ansiBundle: AnserJsonEntry): AnsiBundle {
5635
};
5736
}
5837

59-
function ansiToInlineStyle(text: string): Array<AnsiBundle> {
38+
function ansiToInlineStyle(text) {
6039
return ansiToJSON(text).map(ansiJSONtoStyleBundle);
6140
}
6241

63-
function linkifyBundle(bundle: AnsiBundle) {
42+
function linkifyBundle(bundle) {
6443
return {
6544
...bundle,
6645
content: bundle.content.split(' ').reduce((result, word, index) => [
@@ -90,7 +69,13 @@ function inlineBundleToReact(bundle, key) {
9069
}, bundle.content);
9170
}
9271

93-
function Ansi(props: {children: string, className?: string}) {
72+
type Props = {
73+
children?: React$Element<any>,
74+
className?: string,
75+
linkify?: boolean
76+
};
77+
78+
function Ansi(props: Props) {
9479
return React.createElement(
9580
'code',
9681
{className: props.className},

0 commit comments

Comments
 (0)