Skip to content

Commit

Permalink
Converted AnsiUp to ESM / ES6 Module
Browse files Browse the repository at this point in the history
  • Loading branch information
drudru committed Jul 31, 2023
1 parent a30bb48 commit e30f8c6
Show file tree
Hide file tree
Showing 13 changed files with 921 additions and 1,114 deletions.
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@

SOURCE = *.ts
TESTS = test/*.js
SOURCE = *.ts
TESTS = test/*.js
REPORTER = dot

typescript:
./node_modules/.bin/tsc -p .
cat ./umd.header ./dist/ansi_up.js ./umd.footer > ansi_up.js
mv ./dist/ansi_up.js ./dist/ansi_up.js.include
node ./scripts/fix-typings.js


test:
@NODE_ENV=test ./node_modules/.bin/mocha \
--require should \
Expand Down
44 changes: 12 additions & 32 deletions ansi_up.d.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,33 @@
interface AU_Color {
rgb: number[];
class_name: string;
}
interface TextWithAttr {
fg: AU_Color;
bg: AU_Color;
bold: boolean;
text: string;
}
declare enum PacketKind {
EOS = 0,
Text = 1,
Incomplete = 2,
ESC = 3,
Unknown = 4,
SGR = 5,
OSCURL = 6
}
interface TextPacket {
kind: PacketKind;
text: string;
url: string;
}
export declare class AnsiUp {
VERSION: string;
private ansi_colors;
private palette_256;
private fg;
private bg;
private bold;
private italic;
private underline;
private _use_classes;
private _escape_for_html;
private _csi_regex;
private _osc_st;
private _osc_regex;
private _url_whitelist;
private _escape_html;
private _buffer;
constructor();
use_classes: boolean;
escape_for_html: boolean;
url_whitelist: {};
set use_classes(arg: boolean);
get use_classes(): boolean;
set url_whitelist(arg: {});
get url_whitelist(): {};
set escape_html(arg: boolean);
get escape_html(): boolean;
private setup_palettes;
private escape_txt_for_html;
append_buffer(txt: string): void;
get_next_packet(): TextPacket;
private append_buffer;
private get_next_packet;
ansi_to_html(txt: string): string;
private with_state;
private process_ansi;
transform_to_html(fragment: TextWithAttr): string;
private transform_to_html;
private process_hyperlink;
}
export {};
240 changes: 98 additions & 142 deletions ansi_up.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ansi_up.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ansi_up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ interface TextPacket {
// MAIN CLASS
//

class AnsiUp
export class AnsiUp
{
VERSION = "5.2.1";

Expand Down
61 changes: 0 additions & 61 deletions dist/ansi_up.d.ts

This file was deleted.

Loading

0 comments on commit e30f8c6

Please sign in to comment.