mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 21:52:19 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
103
web/node_modules/slice-ansi/index.js
generated
vendored
Executable file
103
web/node_modules/slice-ansi/index.js
generated
vendored
Executable file
|
@ -0,0 +1,103 @@
|
|||
'use strict';
|
||||
const isFullwidthCodePoint = require('is-fullwidth-code-point');
|
||||
const astralRegex = require('astral-regex');
|
||||
const ansiStyles = require('ansi-styles');
|
||||
|
||||
const ESCAPES = [
|
||||
'\u001B',
|
||||
'\u009B'
|
||||
];
|
||||
|
||||
const wrapAnsi = code => `${ESCAPES[0]}[${code}m`;
|
||||
|
||||
const checkAnsi = (ansiCodes, isEscapes, endAnsiCode) => {
|
||||
let output = [];
|
||||
ansiCodes = [...ansiCodes];
|
||||
|
||||
for (let ansiCode of ansiCodes) {
|
||||
const ansiCodeOrigin = ansiCode;
|
||||
if (ansiCode.includes(';')) {
|
||||
ansiCode = ansiCode.split(';')[0][0] + '0';
|
||||
}
|
||||
|
||||
const item = ansiStyles.codes.get(Number.parseInt(ansiCode, 10));
|
||||
if (item) {
|
||||
const indexEscape = ansiCodes.indexOf(item.toString());
|
||||
if (indexEscape === -1) {
|
||||
output.push(wrapAnsi(isEscapes ? item : ansiCodeOrigin));
|
||||
} else {
|
||||
ansiCodes.splice(indexEscape, 1);
|
||||
}
|
||||
} else if (isEscapes) {
|
||||
output.push(wrapAnsi(0));
|
||||
break;
|
||||
} else {
|
||||
output.push(wrapAnsi(ansiCodeOrigin));
|
||||
}
|
||||
}
|
||||
|
||||
if (isEscapes) {
|
||||
output = output.filter((element, index) => output.indexOf(element) === index);
|
||||
|
||||
if (endAnsiCode !== undefined) {
|
||||
const fistEscapeCode = wrapAnsi(ansiStyles.codes.get(Number.parseInt(endAnsiCode, 10)));
|
||||
output = output.reduce((current, next) => next === fistEscapeCode ? [next, ...current] : [...current, next], []);
|
||||
}
|
||||
}
|
||||
|
||||
return output.join('');
|
||||
};
|
||||
|
||||
module.exports = (string, begin, end) => {
|
||||
const characters = [...string];
|
||||
const ansiCodes = [];
|
||||
|
||||
let stringEnd = typeof end === 'number' ? end : characters.length;
|
||||
let isInsideEscape = false;
|
||||
let ansiCode;
|
||||
let visible = 0;
|
||||
let output = '';
|
||||
|
||||
for (const [index, character] of characters.entries()) {
|
||||
let leftEscape = false;
|
||||
|
||||
if (ESCAPES.includes(character)) {
|
||||
const code = /\d[^m]*/.exec(string.slice(index, index + 18));
|
||||
ansiCode = code && code.length > 0 ? code[0] : undefined;
|
||||
|
||||
if (visible < stringEnd) {
|
||||
isInsideEscape = true;
|
||||
|
||||
if (ansiCode !== undefined) {
|
||||
ansiCodes.push(ansiCode);
|
||||
}
|
||||
}
|
||||
} else if (isInsideEscape && character === 'm') {
|
||||
isInsideEscape = false;
|
||||
leftEscape = true;
|
||||
}
|
||||
|
||||
if (!isInsideEscape && !leftEscape) {
|
||||
visible++;
|
||||
}
|
||||
|
||||
if (!astralRegex({exact: true}).test(character) && isFullwidthCodePoint(character.codePointAt())) {
|
||||
visible++;
|
||||
|
||||
if (typeof end !== 'number') {
|
||||
stringEnd++;
|
||||
}
|
||||
}
|
||||
|
||||
if (visible > begin && visible <= stringEnd) {
|
||||
output += character;
|
||||
} else if (visible === begin && !isInsideEscape && ansiCode !== undefined) {
|
||||
output = checkAnsi(ansiCodes);
|
||||
} else if (visible >= stringEnd) {
|
||||
output += checkAnsi(ansiCodes, true, ansiCode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
10
web/node_modules/slice-ansi/license
generated
vendored
Normal file
10
web/node_modules/slice-ansi/license
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) DC <threedeecee@gmail.com>
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://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.
|
52
web/node_modules/slice-ansi/package.json
generated
vendored
Normal file
52
web/node_modules/slice-ansi/package.json
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"name": "slice-ansi",
|
||||
"version": "4.0.0",
|
||||
"description": "Slice a string with ANSI escape codes",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/slice-ansi",
|
||||
"funding": "https://github.com/chalk/slice-ansi?sponsor=1",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"slice",
|
||||
"string",
|
||||
"ansi",
|
||||
"styles",
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"tty",
|
||||
"escape",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.0.0",
|
||||
"astral-regex": "^2.0.0",
|
||||
"is-fullwidth-code-point": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^2.1.0",
|
||||
"chalk": "^3.0.0",
|
||||
"random-item": "^3.0.0",
|
||||
"strip-ansi": "^6.0.0",
|
||||
"xo": "^0.26.1"
|
||||
}
|
||||
}
|
66
web/node_modules/slice-ansi/readme.md
generated
vendored
Normal file
66
web/node_modules/slice-ansi/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
# slice-ansi [](https://travis-ci.org/chalk/slice-ansi) [](https://github.com/xojs/xo)
|
||||
|
||||
> Slice a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install slice-ansi
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
const sliceAnsi = require('slice-ansi');
|
||||
|
||||
const string = 'The quick brown ' + chalk.red('fox jumped over ') +
|
||||
'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
|
||||
|
||||
console.log(sliceAnsi(string, 20, 30));
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### sliceAnsi(string, beginSlice, endSlice?)
|
||||
|
||||
#### string
|
||||
|
||||
Type: `string`
|
||||
|
||||
String with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk).
|
||||
|
||||
#### beginSlice
|
||||
|
||||
Type: `number`
|
||||
|
||||
Zero-based index at which to begin the slice.
|
||||
|
||||
#### endSlice
|
||||
|
||||
Type: `number`
|
||||
|
||||
Zero-based index at which to end the slice.
|
||||
|
||||
## Related
|
||||
|
||||
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
|
||||
- [cli-truncate](https://github.com/sindresorhus/cli-truncate) - Truncate a string to a specific width in the terminal
|
||||
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-slice_ansi?utm_source=npm-slice-ansi&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>
|
Loading…
Add table
Add a link
Reference in a new issue