Izmjenjena struktura, dodan backand

This commit is contained in:
GotPPay
2017-10-16 11:19:46 +02:00
parent 1ec88afacb
commit 048e32c4aa
37153 changed files with 2975854 additions and 1 deletions

21
web/node_modules/anser/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2012-17 Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)
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.

344
web/node_modules/anser/README.md generated vendored Normal file
View File

@@ -0,0 +1,344 @@
# anser
[![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [![Travis](https://img.shields.io/travis/IonicaBizau/anser.svg)](https://travis-ci.org/IonicaBizau/anser/) [![Version](https://img.shields.io/npm/v/anser.svg)](https://www.npmjs.com/package/anser) [![Downloads](https://img.shields.io/npm/dt/anser.svg)](https://www.npmjs.com/package/anser)
> A low level parser for ANSI sequences.
## :rocket: Features
- Converts text containing [ANSI color escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) into equivalent HTML elements.
- Allows converting the input into JSON output.
- HTML escaping
- Converts links into HTML elements
- Friendly APIs to use with virtual dom libraries
## :cloud: Installation
```sh
$ npm i --save anser
```
## :clipboard: Example
```js
const Anser = require("anser");
const txt = "\u001b[38;5;196mHello\u001b[39m \u001b[48;5;226mWorld\u001b[49m";
console.log(Anser.ansiToHtml(txt));
// <span style="color:rgb(255, 0, 0)">Hello</span> <span style="background-color:rgb(255, 255, 0)">World</span>
console.log(Anser.ansiToHtml(txt, { use_classes: true }));
// <span class="ansi-palette-196-fg">Hello</span> <span class="ansi-palette-226-bg">World</span>
console.log(Anser.ansiToJson(txt));
// [ { content: '',
// fg: null,
// bg: null,
// fg_truecolor: null,
// bg_truecolor: null,
// clearLine: undefined,
// decoration: null,
// was_processed: false,
// isEmpty: [Function: isEmpty] },
// { content: 'Hello',
// fg: '255, 0, 0',
// bg: null,
// fg_truecolor: null,
// bg_truecolor: null,
// clearLine: false,
// decoration: null,
// was_processed: true,
// isEmpty: [Function: isEmpty] },
// { content: ' ',
// fg: null,
// bg: null,
// fg_truecolor: null,
// bg_truecolor: null,
// clearLine: false,
// decoration: null,
// was_processed: false,
// isEmpty: [Function: isEmpty] },
// { content: 'World',
// fg: null,
// bg: '255, 255, 0',
// fg_truecolor: null,
// bg_truecolor: null,
// clearLine: false,
// decoration: null,
// was_processed: true,
// isEmpty: [Function: isEmpty] },
// { content: '',
// fg: null,
// bg: null,
// fg_truecolor: null,
// bg_truecolor: null,
// clearLine: false,
// decoration: null,
// was_processed: false,
// isEmpty: [Function: isEmpty] } ]
```
When using **Typescript** you can do the following:
```ts
import Anser from 'anser'; // make sure to NOT use curly braces!
const txt = "\u001b[38;5;196mHello\u001b[39m \u001b[48;5;226mWorld\u001b[49m";
console.log(Anser.ansiToHtml(txt));
// <span style="color:rgb(255, 0, 0)">Hello</span> <span style="background-color:rgb(255, 255, 0)">World</span>
```
## :question: Get Help
There are few ways to get help:
1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question.
2. For bug reports and feature requests, open issues. :bug:
3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:
## :memo: Documentation
### `Anser.escapeForHtml(txt)`
Escape the input HTML.
This does the minimum escaping of text to make it compliant with HTML.
In particular, the '&','<', and '>' characters are escaped. This should
be run prior to `ansiToHtml`.
#### Params
- **String** `txt`: The input text (containing the ANSI snippets).
#### Return
- **String** The escaped html.
### `Anser.linkify(txt)`
Adds the links in the HTML.
This replaces any links in the text with anchor tags that display the
link. The links should have at least one whitespace character
surrounding it. Also, you should apply this after you have run
`ansiToHtml` on the text.
#### Params
- **String** `txt`: The input text.
#### Return
- **String** The HTML containing the <a> tags (unescaped).
### `Anser.ansiToHtml(txt, options)`
This replaces ANSI terminal escape codes with SPAN tags that wrap the
content.
This function only interprets ANSI SGR (Select Graphic Rendition) codes
that can be represented in HTML.
For example, cursor movement codes are ignored and hidden from output.
The default style uses colors that are very close to the prescribed
standard. The standard assumes that the text will have a black
background. These colors are set as inline styles on the SPAN tags.
Another option is to set `use_classes: true` in the options argument.
This will instead set classes on the spans so the colors can be set via
CSS. The class names used are of the format `ansi-*-fg/bg` and
`ansi-bright-*-fg/bg` where `*` is the color name,
i.e black/red/green/yellow/blue/magenta/cyan/white.
#### Params
- **String** `txt`: The input text.
- **Object** `options`: The options passed to the ansiToHTML method.
#### Return
- **String** The HTML output.
### `Anser.ansiToJson(txt, options)`
Converts ANSI input into JSON output.
#### Params
- **String** `txt`: The input text.
- **Object** `options`: The options passed to the ansiToHTML method.
#### Return
- **String** The HTML output.
### `Anser.ansiToText(txt)`
Converts ANSI input into text output.
#### Params
- **String** `txt`: The input text.
#### Return
- **String** The text output.
### `Anser()`
The `Anser` class.
#### Return
- **Anser**
### `setupPalette()`
Sets up the palette.
### `escapeForHtml(txt)`
Escapes the input text.
#### Params
- **String** `txt`: The input text.
#### Return
- **String** The escpaed HTML output.
### `linkify(txt)`
Adds HTML link elements.
#### Params
- **String** `txt`: The input text.
#### Return
- **String** The HTML output containing link elements.
### `ansiToHtml(txt, options)`
Converts ANSI input into HTML output.
#### Params
- **String** `txt`: The input text.
- **Object** `options`: The options passed ot the `process` method.
#### Return
- **String** The HTML output.
### `ansiToJson(txt, options)`
Converts ANSI input into HTML output.
#### Params
- **String** `txt`: The input text.
- **Object** `options`: The options passed ot the `process` method.
#### Return
- **String** The JSON output.
### `ansiToText(txt)`
Converts ANSI input into HTML output.
#### Params
- **String** `txt`: The input text.
#### Return
- **String** The text output.
### `process(txt, options, markup)`
Processes the input.
#### Params
- **String** `txt`: The input text.
- **Object** `options`: An object passed to `processChunk` method, extended with:
- `json` (Boolean): If `true`, the result will be an object.
- `use_classes` (Boolean): If `true`, HTML classes will be appended to the HTML output.
- **Boolean** `markup`:
### `processChunkJson(text, options, markup)`
Processes the current chunk into json output.
#### Params
- **String** `text`: The input text.
- **Object** `options`: An object containing the following fields:
- `json` (Boolean): If `true`, the result will be an object.
- `use_classes` (Boolean): If `true`, HTML classes will be appended to the HTML output.
- **Boolean** `markup`: If false, the colors will not be parsed.
#### Return
- **Object** The result object:
- `content` (String): The text.
- `fg` (String|null): The foreground color.
- `bg` (String|null): The background color.
- `fg_truecolor` (String|null): The foreground true color (if 16m color is enabled).
- `bg_truecolor` (String|null): The background true color (if 16m color is enabled).
- `clearLine` (Boolean): `true` if a carriageReturn \r was fount at end of line.
- `was_processed` (Bolean): `true` if the colors were processed, `false` otherwise.
- `isEmpty` (Function): A function returning `true` if the content is empty, or `false` otherwise.
### `processChunk(text, options, markup)`
Processes the current chunk of text.
#### Params
- **String** `text`: The input text.
- **Object** `options`: An object containing the following fields:
- `json` (Boolean): If `true`, the result will be an object.
- `use_classes` (Boolean): If `true`, HTML classes will be appended to the HTML output.
- **Boolean** `markup`: If false, the colors will not be parsed.
#### Return
- **Object|String** The result (object if `json` is wanted back or string otherwise).
## :yum: How to contribute
Have an idea? Found a bug? See [how to contribute][contributing].
## :sparkling_heart: Support my projects
I open-source almost everything I can, and I try to reply everyone needing help using these projects. Obviously,
this takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute (even resell it).
However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:
- Starring and sharing the projects you like :rocket:
- [![PayPal][badge_paypal]][paypal-donations]—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:
- [![Support me on Patreon][badge_patreon]][patreon]—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).
- **Bitcoin**—You can send me bitcoins at this address (or scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`
![](https://i.imgur.com/z6OQI95.png)
Thanks! :heart:
## :cake: Thanks
This project is highly based on [`ansi_up`](https://github.com/drudru/ansi_up), by [@drudru](https://github.com/drudru/). Thanks! :cake:
## :dizzy: Where is this library used?
If you are using this library in one of your projects, add it in this list. :sparkles:
- [`ansi-html-themed`](https://npmjs.com/package/ansi-html-themed) (by Joe Haddad)—Turns chalked code into pretty html.
- [`ansi-to-json`](https://github.com/IonicaBizau/ansi-to-json#readme)—Convert ANSI strings into JSON output.
- [`ansi-to-react`](https://github.com/nteract/ansi-to-react#readme) (by Kyle Kelley)—ANSI to React Elements
- [`ansi-to-react-with-classes`](https://npmjs.com/package/ansi-to-react-with-classes) (by Kyle Kelley)—ANSI to React Elements
- [`cycle-dev-utils`](https://github.com/cyclejs-community/create-cycle-app#readme) (by Nick Balestra)—undefined
- [`inferno-dev-utils`](https://github.com/infernojs/create-inferno-app#readme)—Webpack utilities used by Create Inferno App
- [`lambda-dev-utils`](https://github.com/channl/create-lambda-app#readme)—Webpack utilities used by Create Lambda App
- [`nterm`](https://github.com/dariushuntly/nterm/issues) (by Darius Huntly)—A Node Terminal
- [`react-dev-utils`](https://github.com/facebookincubator/create-react-app#readme)—Webpack utilities used by Create React App
- [`react-dev-utils-extra`](https://github.com/facebookincubator/create-react-app-extra#readme)—Webpack utilities used by Create React App
- [`react-dev-utils-sebfl-update`](https://github.com/facebookincubator/create-react-app#readme)—Webpack utilities used by Create React App
- [`react-error-overlay`](https://github.com/facebookincubator/create-react-app#readme) (by Joe Haddad)—An overlay for displaying stack frames.
- [`singularityui-tailer`](https://github.com/HubSpot/Singularity#readme) (by Danny Wolf)—A robust log tailer
- [`stack-frame-overlay`](https://npmjs.com/package/stack-frame-overlay) (by Joe Haddad)—An overlay for displaying stack frames.
- [`timer-react-dev-utils`](https://github.com/facebookincubator/create-react-app#readme)—Webpack utilities used by Create React App
- [`transformime`](https://github.com/nteract/transformime#readme) (by nteract)—Transforms MIMEtypes to HTML Elements
- [`uyun-react-dev-utils`](https://github.com/facebookincubator/create-react-app#readme)—Webpack utilities used by Create React App
- [`webpack-isomorphic-dev-middleware`](https://github.com/moxystudio/webpack-isomorphic-dev-middleware) (by André Cruz)—The webpack-dev-middleware, but for isomorphic applications.
## :scroll: License
[MIT][license] © [Ionică Bizău][website]
[badge_patreon]: http://ionicabizau.github.io/badges/patreon.svg
[badge_amazon]: http://ionicabizau.github.io/badges/amazon.svg
[badge_paypal]: http://ionicabizau.github.io/badges/paypal.svg
[badge_paypal_donate]: http://ionicabizau.github.io/badges/paypal_donate.svg
[patreon]: https://www.patreon.com/ionicabizau
[amazon]: http://amzn.eu/hRo9sIZ
[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW
[donate-now]: http://i.imgur.com/6cMbHOC.png
[license]: http://showalicense.com/?fullname=Ionic%C4%83%20Biz%C4%83u%20%3Cbizauionica%40gmail.com%3E%20(https%3A%2F%2Fionicabizau.net)&year=2012#license-mit
[website]: https://ionicabizau.net
[contributing]: /CONTRIBUTING.md
[docs]: /DOCUMENTATION.md

30
web/node_modules/anser/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,30 @@
// Type definitions for Anser
// Project: https://github.com/IonicaBizau/anser
export interface AnserJsonEntry {
content: string;
fg: string;
bg: string;
fg_truecolor: string;
bg_truecolor: string;
clearLine: boolean;
was_processed: boolean;
isEmpty(): boolean;
}
export interface AnserOptions {
use_classes?: boolean;
}
export default class Anser {
static ansiToJson(txt: string, options?: AnserOptions): AnserJsonEntry[];
static ansiToHtml(txt: string, options?: AnserOptions): string;
static ansiToText(txt: string, options?: AnserOptions): string;
static escapeForHtml(txt: string): string;
static linkify(txt: string): string;
}

630
web/node_modules/anser/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,630 @@
"use strict";
// This file was originally written by @drudru (https://github.com/drudru/ansi_up), MIT, 2011
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require("babel-runtime/helpers/createClass");
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var ANSI_COLORS = [[{ color: "0, 0, 0", "class": "ansi-black" }, { color: "187, 0, 0", "class": "ansi-red" }, { color: "0, 187, 0", "class": "ansi-green" }, { color: "187, 187, 0", "class": "ansi-yellow" }, { color: "0, 0, 187", "class": "ansi-blue" }, { color: "187, 0, 187", "class": "ansi-magenta" }, { color: "0, 187, 187", "class": "ansi-cyan" }, { color: "255,255,255", "class": "ansi-white" }], [{ color: "85, 85, 85", "class": "ansi-bright-black" }, { color: "255, 85, 85", "class": "ansi-bright-red" }, { color: "0, 255, 0", "class": "ansi-bright-green" }, { color: "255, 255, 85", "class": "ansi-bright-yellow" }, { color: "85, 85, 255", "class": "ansi-bright-blue" }, { color: "255, 85, 255", "class": "ansi-bright-magenta" }, { color: "85, 255, 255", "class": "ansi-bright-cyan" }, { color: "255, 255, 255", "class": "ansi-bright-white" }]];
var Anser = function () {
(0, _createClass3.default)(Anser, null, [{
key: "escapeForHtml",
/**
* Anser.escapeForHtml
* Escape the input HTML.
*
* This does the minimum escaping of text to make it compliant with HTML.
* In particular, the '&','<', and '>' characters are escaped. This should
* be run prior to `ansiToHtml`.
*
* @name Anser.escapeForHtml
* @function
* @param {String} txt The input text (containing the ANSI snippets).
* @returns {String} The escaped html.
*/
value: function escapeForHtml(txt) {
return new Anser().escapeForHtml(txt);
}
/**
* Anser.linkify
* Adds the links in the HTML.
*
* This replaces any links in the text with anchor tags that display the
* link. The links should have at least one whitespace character
* surrounding it. Also, you should apply this after you have run
* `ansiToHtml` on the text.
*
* @name Anser.linkify
* @function
* @param {String} txt The input text.
* @returns {String} The HTML containing the <a> tags (unescaped).
*/
}, {
key: "linkify",
value: function linkify(txt) {
return new Anser().linkify(txt);
}
/**
* Anser.ansiToHtml
* This replaces ANSI terminal escape codes with SPAN tags that wrap the
* content.
*
* This function only interprets ANSI SGR (Select Graphic Rendition) codes
* that can be represented in HTML.
* For example, cursor movement codes are ignored and hidden from output.
* The default style uses colors that are very close to the prescribed
* standard. The standard assumes that the text will have a black
* background. These colors are set as inline styles on the SPAN tags.
*
* Another option is to set `use_classes: true` in the options argument.
* This will instead set classes on the spans so the colors can be set via
* CSS. The class names used are of the format `ansi-*-fg/bg` and
* `ansi-bright-*-fg/bg` where `*` is the color name,
* i.e black/red/green/yellow/blue/magenta/cyan/white.
*
* @name Anser.ansiToHtml
* @function
* @param {String} txt The input text.
* @param {Object} options The options passed to the ansiToHTML method.
* @returns {String} The HTML output.
*/
}, {
key: "ansiToHtml",
value: function ansiToHtml(txt, options) {
return new Anser().ansiToHtml(txt, options);
}
/**
* Anser.ansiToJson
* Converts ANSI input into JSON output.
*
* @name Anser.ansiToJson
* @function
* @param {String} txt The input text.
* @param {Object} options The options passed to the ansiToHTML method.
* @returns {String} The HTML output.
*/
}, {
key: "ansiToJson",
value: function ansiToJson(txt, options) {
return new Anser().ansiToJson(txt, options);
}
/**
* Anser.ansiToText
* Converts ANSI input into text output.
*
* @name Anser.ansiToText
* @function
* @param {String} txt The input text.
* @returns {String} The text output.
*/
}, {
key: "ansiToText",
value: function ansiToText(txt) {
return new Anser().ansiToText(txt);
}
/**
* Anser
* The `Anser` class.
*
* @name Anser
* @function
* @returns {Anser}
*/
}]);
function Anser() {
(0, _classCallCheck3.default)(this, Anser);
this.fg = this.bg = this.fg_truecolor = this.bg_truecolor = null;
this.bright = 0;
}
/**
* setupPalette
* Sets up the palette.
*
* @name setupPalette
* @function
*/
(0, _createClass3.default)(Anser, [{
key: "setupPalette",
value: function setupPalette() {
this.PALETTE_COLORS = [];
// Index 0..15 : System color
for (var i = 0; i < 2; ++i) {
for (var j = 0; j < 8; ++j) {
this.PALETTE_COLORS.push(ANSI_COLORS[i][j].color);
}
}
// Index 16..231 : RGB 6x6x6
// https://gist.github.com/jasonm23/2868981#file-xterm-256color-yaml
var levels = [0, 95, 135, 175, 215, 255];
var format = function format(r, g, b) {
return levels[r] + ", " + levels[g] + ", " + levels[b];
};
var r = void 0,
g = void 0,
b = void 0;
for (var _r = 0; _r < 6; ++_r) {
for (var _g = 0; _g < 6; ++_g) {
for (var _b = 0; _b < 6; ++_b) {
this.PALETTE_COLORS.push(format(_r, _g, _b));
}
}
}
// Index 232..255 : Grayscale
var level = 8;
for (var _i = 0; _i < 24; ++_i, level += 10) {
this.PALETTE_COLORS.push(format(level, level, level));
}
}
/**
* escapeForHtml
* Escapes the input text.
*
* @name escapeForHtml
* @function
* @param {String} txt The input text.
* @returns {String} The escpaed HTML output.
*/
}, {
key: "escapeForHtml",
value: function escapeForHtml(txt) {
return txt.replace(/[&<>]/gm, function (str) {
return str == "&" ? "&amp;" : str == "<" ? "&lt;" : str == ">" ? "&gt;" : "";
});
}
/**
* linkify
* Adds HTML link elements.
*
* @name linkify
* @function
* @param {String} txt The input text.
* @returns {String} The HTML output containing link elements.
*/
}, {
key: "linkify",
value: function linkify(txt) {
return txt.replace(/(https?:\/\/[^\s]+)/gm, function (str) {
return "<a href=\"" + str + "\">" + str + "</a>";
});
}
/**
* ansiToHtml
* Converts ANSI input into HTML output.
*
* @name ansiToHtml
* @function
* @param {String} txt The input text.
* @param {Object} options The options passed ot the `process` method.
* @returns {String} The HTML output.
*/
}, {
key: "ansiToHtml",
value: function ansiToHtml(txt, options) {
return this.process(txt, options, true);
}
/**
* ansiToJson
* Converts ANSI input into HTML output.
*
* @name ansiToJson
* @function
* @param {String} txt The input text.
* @param {Object} options The options passed ot the `process` method.
* @returns {String} The JSON output.
*/
}, {
key: "ansiToJson",
value: function ansiToJson(txt, options) {
options = options || {};
options.json = true;
options.clearLine = false;
return this.process(txt, options, true);
}
/**
* ansiToText
* Converts ANSI input into HTML output.
*
* @name ansiToText
* @function
* @param {String} txt The input text.
* @returns {String} The text output.
*/
}, {
key: "ansiToText",
value: function ansiToText(txt) {
return this.process(txt, {}, false);
}
/**
* process
* Processes the input.
*
* @name process
* @function
* @param {String} txt The input text.
* @param {Object} options An object passed to `processChunk` method, extended with:
*
* - `json` (Boolean): If `true`, the result will be an object.
* - `use_classes` (Boolean): If `true`, HTML classes will be appended to the HTML output.
*
* @param {Boolean} markup
*/
}, {
key: "process",
value: function process(txt, options, markup) {
var _this = this;
var self = this;
var raw_text_chunks = txt.split(/\033\[/);
var first_chunk = raw_text_chunks.shift(); // the first chunk is not the result of the split
if (options === undefined || options === null) {
options = {};
}
options.clearLine = /\r/.test(txt); // check for Carriage Return
var color_chunks = raw_text_chunks.map(function (chunk) {
return _this.processChunk(chunk, options, markup);
});
if (options && options.json) {
var first = self.processChunkJson("");
first.content = first_chunk;
first.clearLine = options.clearLine;
color_chunks.unshift(first);
if (options.remove_empty) {
color_chunks = color_chunks.filter(function (c) {
return !c.isEmpty();
});
}
return color_chunks;
} else {
color_chunks.unshift(first_chunk);
}
return color_chunks.join("");
}
/**
* processChunkJson
* Processes the current chunk into json output.
*
* @name processChunkJson
* @function
* @param {String} text The input text.
* @param {Object} options An object containing the following fields:
*
* - `json` (Boolean): If `true`, the result will be an object.
* - `use_classes` (Boolean): If `true`, HTML classes will be appended to the HTML output.
*
* @param {Boolean} markup If false, the colors will not be parsed.
* @return {Object} The result object:
*
* - `content` (String): The text.
* - `fg` (String|null): The foreground color.
* - `bg` (String|null): The background color.
* - `fg_truecolor` (String|null): The foreground true color (if 16m color is enabled).
* - `bg_truecolor` (String|null): The background true color (if 16m color is enabled).
* - `clearLine` (Boolean): `true` if a carriageReturn \r was fount at end of line.
* - `was_processed` (Bolean): `true` if the colors were processed, `false` otherwise.
* - `isEmpty` (Function): A function returning `true` if the content is empty, or `false` otherwise.
*
*/
}, {
key: "processChunkJson",
value: function processChunkJson(text, options, markup) {
// Are we using classes or styles?
options = typeof options == "undefined" ? {} : options;
var use_classes = options.use_classes = typeof options.use_classes != "undefined" && options.use_classes;
var key = options.key = use_classes ? "class" : "color";
var result = {
content: text,
fg: null,
bg: null,
fg_truecolor: null,
bg_truecolor: null,
clearLine: options.clearLine,
decoration: null,
was_processed: false,
isEmpty: function isEmpty() {
return !result.content;
}
};
// Each "chunk" is the text after the CSI (ESC + "[") and before the next CSI/EOF.
//
// This regex matches four groups within a chunk.
//
// The first and third groups match code type.
// We supported only SGR command. It has empty first group and "m" in third.
//
// The second group matches all of the number+semicolon command sequences
// before the "m" (or other trailing) character.
// These are the graphics or SGR commands.
//
// The last group is the text (including newlines) that is colored by
// the other group"s commands.
var matches = text.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);
if (!matches) return result;
var orig_txt = result.content = matches[4];
var nums = matches[2].split(";");
// We currently support only "SGR" (Select Graphic Rendition)
// Simply ignore if not a SGR command.
if (matches[1] !== "" || matches[3] !== "m") {
return result;
}
if (!markup) {
return result;
}
var self = this;
self.decoration = null;
while (nums.length > 0) {
var num_str = nums.shift();
var num = parseInt(num_str);
if (isNaN(num) || num === 0) {
self.fg = self.bg = self.decoration = null;
} else if (num === 1) {
self.decoration = "bold";
} else if (num === 2) {
self.decoration = "dim";
// Enable code 2 to get string
} else if (num == 3) {
self.decoration = "italic";
} else if (num == 4) {
self.decoration = "underline";
} else if (num == 5) {
self.decoration = "blink";
} else if (num === 7) {
self.decoration = "reverse";
} else if (num === 8) {
self.decoration = "hidden";
// Enable code 9 to get strikethrough
} else if (num === 9) {
self.decoration = "strikethrough";
} else if (num == 39) {
self.fg = null;
} else if (num == 49) {
self.bg = null;
// Foreground color
} else if (num >= 30 && num < 38) {
self.fg = ANSI_COLORS[0][num % 10][key];
// Foreground bright color
} else if (num >= 90 && num < 98) {
self.fg = ANSI_COLORS[1][num % 10][key];
// Background color
} else if (num >= 40 && num < 48) {
self.bg = ANSI_COLORS[0][num % 10][key];
// Background bright color
} else if (num >= 100 && num < 108) {
self.bg = ANSI_COLORS[1][num % 10][key];
} else if (num === 38 || num === 48) {
// extend color (38=fg, 48=bg)
var is_foreground = num === 38;
if (nums.length >= 1) {
var mode = nums.shift();
if (mode === "5" && nums.length >= 1) {
// palette color
var palette_index = parseInt(nums.shift());
if (palette_index >= 0 && palette_index <= 255) {
if (!use_classes) {
if (!this.PALETTE_COLORS) {
self.setupPalette();
}
if (is_foreground) {
self.fg = this.PALETTE_COLORS[palette_index];
} else {
self.bg = this.PALETTE_COLORS[palette_index];
}
} else {
var klass = palette_index >= 16 ? "ansi-palette-" + palette_index : ANSI_COLORS[palette_index > 7 ? 1 : 0][palette_index % 8]["class"];
if (is_foreground) {
self.fg = klass;
} else {
self.bg = klass;
}
}
}
} else if (mode === "2" && nums.length >= 3) {
// true color
var r = parseInt(nums.shift());
var g = parseInt(nums.shift());
var b = parseInt(nums.shift());
if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) {
var color = r + ", " + g + ", " + b;
if (!use_classes) {
if (is_foreground) {
self.fg = color;
} else {
self.bg = color;
}
} else {
if (is_foreground) {
self.fg = "ansi-truecolor";
self.fg_truecolor = color;
} else {
self.bg = "ansi-truecolor";
self.bg_truecolor = color;
}
}
}
}
}
}
}
if (self.fg === null && self.bg === null && self.decoration === null) {
return result;
} else {
var styles = [];
var classes = [];
var data = {};
result.fg = self.fg;
result.bg = self.bg;
result.fg_truecolor = self.fg_truecolor;
result.bg_truecolor = self.bg_truecolor;
result.decoration = self.decoration;
result.was_processed = true;
return result;
}
}
/**
* processChunk
* Processes the current chunk of text.
*
* @name processChunk
* @function
* @param {String} text The input text.
* @param {Object} options An object containing the following fields:
*
* - `json` (Boolean): If `true`, the result will be an object.
* - `use_classes` (Boolean): If `true`, HTML classes will be appended to the HTML output.
*
* @param {Boolean} markup If false, the colors will not be parsed.
* @return {Object|String} The result (object if `json` is wanted back or string otherwise).
*/
}, {
key: "processChunk",
value: function processChunk(text, options, markup) {
var _this2 = this;
var self = this;
options = options || {};
var jsonChunk = this.processChunkJson(text, options, markup);
if (options.json) {
return jsonChunk;
}
if (jsonChunk.isEmpty()) {
return "";
}
if (!jsonChunk.was_processed) {
return jsonChunk.content;
}
var use_classes = options.use_classes;
var styles = [];
var classes = [];
var data = {};
var render_data = function render_data(data) {
var fragments = [];
var key = void 0;
for (key in data) {
if (data.hasOwnProperty(key)) {
fragments.push("data-" + key + "=\"" + _this2.escapeForHtml(data[key]) + "\"");
}
}
return fragments.length > 0 ? " " + fragments.join(" ") : "";
};
if (jsonChunk.fg) {
if (use_classes) {
classes.push(jsonChunk.fg + "-fg");
if (jsonChunk.fg_truecolor !== null) {
data["ansi-truecolor-fg"] = jsonChunk.fg_truecolor;
jsonChunk.fg_truecolor = null;
}
} else {
styles.push("color:rgb(" + jsonChunk.fg + ")");
}
}
if (jsonChunk.bg) {
if (use_classes) {
classes.push(jsonChunk.bg + "-bg");
if (jsonChunk.bg_truecolor !== null) {
data["ansi-truecolor-bg"] = jsonChunk.bg_truecolor;
jsonChunk.bg_truecolor = null;
}
} else {
styles.push("background-color:rgb(" + jsonChunk.bg + ")");
}
}
if (jsonChunk.decoration) {
if (use_classes) {
classes.push("ansi-" + jsonChunk.decoration);
} else if (jsonChunk.decoration === "bold") {
styles.push("font-weight:bold");
} else if (jsonChunk.decoration === "dim") {
styles.push("opacity:0.5");
} else if (jsonChunk.decoration === "italic") {
styles.push("font-style:italic");
// underline and blink are treated bellow
} else if (jsonChunk.decoration === "reverse") {
styles.push("filter:invert(100%)");
} else if (jsonChunk.decoration === "hidden") {
styles.push("visibility:hidden");
} else if (jsonChunk.decoration === "strikethrough") {
styles.push("text-decoration:line-through");
} else {
styles.push("text-decoration:" + jsonChunk.decoration);
}
}
if (use_classes) {
return "<span class=\"" + classes.join(" ") + "\"" + render_data(data) + ">" + jsonChunk.content + "</span>";
} else {
return "<span style=\"" + styles.join(";") + "\"" + render_data(data) + ">" + jsonChunk.content + "</span>";
}
}
}]);
return Anser;
}();
;
module.exports = Anser;

108
web/node_modules/anser/package.json generated vendored Normal file
View File

@@ -0,0 +1,108 @@
{
"_from": "anser@1.4.1",
"_id": "anser@1.4.1",
"_inBundle": false,
"_integrity": "sha1-w2QYY6lizr75Qeoshwbyy08HFr0=",
"_location": "/anser",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "anser@1.4.1",
"name": "anser",
"escapedName": "anser",
"rawSpec": "1.4.1",
"saveSpec": null,
"fetchSpec": "1.4.1"
},
"_requiredBy": [
"/react-dev-utils",
"/react-error-overlay"
],
"_resolved": "https://registry.npmjs.org/anser/-/anser-1.4.1.tgz",
"_shasum": "c3641863a962cebef941ea2c8706f2cb4f0716bd",
"_spec": "anser@1.4.1",
"_where": "/home/bilal/Saburly/slucajna-televizija/node_modules/react-dev-utils",
"author": {
"name": "Ionică Bizău",
"email": "bizauionica@gmail.com",
"url": "https://ionicabizau.net"
},
"blah": {
"description": [
{
"h2": ":rocket: Features"
},
{
"ul": [
"Converts text containing [ANSI color escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) into equivalent HTML elements.",
"Allows converting the input into JSON output.",
"HTML escaping",
"Converts links into HTML elements",
"Friendly APIs to use with virtual dom libraries"
]
}
],
"example": [
"When using **Typescript** you can do the following:",
{
"code": {
"content": [
"import Anser from 'anser'; // make sure to NOT use curly braces!",
"const txt = \"\\u001b[38;5;196mHello\\u001b[39m \\u001b[48;5;226mWorld\\u001b[49m\";",
"console.log(Anser.ansiToHtml(txt));",
"// <span style=\"color:rgb(255, 0, 0)\">Hello</span> <span style=\"background-color:rgb(255, 255, 0)\">World</span>"
],
"language": "ts"
}
}
],
"thanks": "This project is highly based on [`ansi_up`](https://github.com/drudru/ansi_up), by [@drudru](https://github.com/drudru/). Thanks! :cake:"
},
"bugs": {
"url": "http://github.com/IonicaBizau/anser/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "A low level parser for ANSI sequences.",
"devDependencies": {
"jshint": "*",
"jslint": "*",
"mocha": "*",
"should": "*"
},
"directories": {
"example": "examples",
"test": "test"
},
"files": [
"bin/",
"app/",
"lib/",
"dist/",
"src/",
"scripts/",
"resources/",
"menu/",
"cli.js",
"index.js"
],
"homepage": "https://github.com/IonicaBizau/anser#readme",
"keywords": [
"ansi",
"html"
],
"license": "MIT",
"main": "lib/index.js",
"name": "anser",
"repository": {
"type": "git",
"url": "git://github.com/IonicaBizau/anser.git"
},
"scripts": {
"test": "mocha"
},
"types": "lib/index.d.ts",
"version": "1.4.1"
}