feat: init

This commit is contained in:
2026-02-13 22:02:30 +01:00
commit 8f9ff830fb
16711 changed files with 3307340 additions and 0 deletions

63
node_modules/@isaacs/cliui/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,63 @@
Several modules are vendored under `./src`, which are used and
distributed according to their respective licenses, each provided
in the same directory as the code.
Everything else is released under the following license.
----
# Blue Oak Model License
Version 1.0.0
## Purpose
This license gives everyone as much permission to work with
this software as possible, while protecting contributors
from liability.
## Acceptance
In order to receive this license, you must agree to its
rules. The rules of this license are both obligations
under that agreement and conditions to your license.
You must not do anything with this software that triggers
a rule that you cannot or will not follow.
## Copyright
Each contributor licenses you to do everything with this
software that would otherwise infringe that contributor's
copyright in it.
## Notices
You must ensure that everyone who gets a copy of
any part of this software from you, with or without
changes, also gets the text of this license or a link to
<https://blueoakcouncil.org/license/1.0.0>.
## Excuse
If anyone notifies you in writing that you have not
complied with [Notices](#notices), you can keep your
license by taking all practical steps to comply within 30
days after the notice. If you do not do so, your license
ends immediately.
## Patent
Each contributor licenses you to do everything with this
software that would otherwise infringe any patent claims
they can license or become able to license.
## Reliability
No contributor can revoke this license.
## No Liability
**_As far as the law allows, this software comes as is,
without any warranty or condition, and no contributor
will be liable to anyone for any damages related to this
software or this license, under any kind of legal claim._**

151
node_modules/@isaacs/cliui/README.md generated vendored Normal file
View File

@@ -0,0 +1,151 @@
# @isaacs/cliui
Fork of [cliui](http://npm.im/cliui). Fully CommonJS/ESM
hybridized, with all dependencies vendored and optimized for
minimal bundle size without sacrificing functionality.
easily create complex multi-column command-line-interfaces.
## Changes in v9
The default export is no longer exported. So, intead of `import
cliui from '@isaacs/cliui'`, you'll do `import { cliui } from
'@isaacs/cliui'`. This is done in order to minimize typescript
oddness between the CommonJS and ESM versions.
A minified export is provided at `@isaacs/cliui/min`. If you are
concerned about bundle size, that's the thing to use.
## Example
```js
import { cliui } from '@isaacs/cliui'
// or: const { cliui } = require('cliui')
const ui = cliui()
ui.div('Usage: $0 [command] [options]')
ui.div({
text: 'Options:',
padding: [2, 0, 1, 0],
})
ui.div(
{
text: '-f, --file',
width: 20,
padding: [0, 4, 0, 4],
},
{
text:
'the file to load.' +
chalk.green('(if this description is long it wraps).'),
width: 20,
},
{
text: chalk.red('[required]'),
align: 'right',
},
)
console.log(ui.toString())
```
## Deno/ESM Support
Load the minified version from unpkg.
```typescript
import { cliui } from 'https://unpkg.com/@isaacs/cliui/dist/esm/index.min.js'
const ui = cliui({})
ui.div('Usage: $0 [command] [options]')
ui.div({
text: 'Options:',
padding: [2, 0, 1, 0],
})
ui.div({
text: '-f, --file',
width: 20,
padding: [0, 4, 0, 4],
})
console.log(ui.toString())
```
<img width="500" src="screenshot.png">
## Layout DSL
cliui exposes a simple layout DSL:
If you create a single `ui.div`, passing a string rather than an
object:
- `\n`: characters will be interpreted as new rows.
- `\t`: characters will be interpreted as new columns.
- `\s`: characters will be interpreted as padding.
**as an example...**
```js
var ui = require('./')({
width: 60,
})
ui.div(
'Usage: node ./bin/foo.js\n' +
' <regex>\t provide a regex\n' +
' <glob>\t provide a glob\t [required]',
)
console.log(ui.toString())
```
**will output:**
```shell
Usage: node ./bin/foo.js
<regex> provide a regex
<glob> provide a glob [required]
```
## Methods
```js
cliui = require('@isaacs/cliui')
```
### cliui({width: integer})
Specify the maximum width of the UI being generated.
If no width is provided, cliui will try to get the current window's width and use it, and if that doesn't work, width will be set to `80`.
### cliui({wrap: boolean})
Enable or disable the wrapping of text in a column.
### cliui.div(column, column, column)
Create a row with any number of columns, a column
can either be a string, or an object with the following
options:
- **text:** some text to place in the column.
- **width:** the width of a column.
- **align:** alignment, `right` or `center`.
- **padding:** `[top, right, bottom, left]`.
- **border:** should a border be placed around the div?
### cliui.span(column, column, column)
Similar to `div`, except the next row will be appended without
a new line being created.
### cliui.resetOutput()
Resets the UI elements of the current cliui instance, maintaining the values
set for `width` and `wrap`.

View File

@@ -0,0 +1,4 @@
export declare const ansiRegex: ({ onlyFirst }?: {
onlyFirst?: boolean | undefined;
}) => RegExp;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ansi-regex/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,GAAI;;CAA0B,WAcnD,CAAC"}

View File

@@ -0,0 +1,16 @@
"use strict";
// TODO! cut this down? do we need the onlyFirst option?
Object.defineProperty(exports, "__esModule", { value: true });
exports.ansiRegex = void 0;
const ansiRegex = ({ onlyFirst = false } = {}) => {
// Valid string terminator sequences are BEL, ESC\, and 0x9c
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
// OSC sequences only: ESC ] ... ST (non-greedy until the first ST)
const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
// CSI and related: ESC/C1, optional intermediates, optional params (supports ; and :) then final byte
const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
const pattern = `${osc}|${csi}`;
return new RegExp(pattern, onlyFirst ? undefined : "g");
};
exports.ansiRegex = ansiRegex;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ansi-regex/index.ts"],"names":[],"mappings":";AAAA,wDAAwD;;;AAEjD,MAAM,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE;IACtD,4DAA4D;IAC5D,MAAM,EAAE,GAAG,oCAAoC,CAAC;IAEhD,mEAAmE;IACnE,MAAM,GAAG,GAAG,0BAA0B,EAAE,GAAG,CAAC;IAE5C,sGAAsG;IACtG,MAAM,GAAG,GACP,oFAAoF,CAAC;IAEvF,MAAM,OAAO,GAAG,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IAEhC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC,CAAC;AAdW,QAAA,SAAS,aAcpB","sourcesContent":["// TODO! cut this down? do we need the onlyFirst option?\n\nexport const ansiRegex = ({ onlyFirst = false } = {}) => {\n // Valid string terminator sequences are BEL, ESC\\, and 0x9c\n const ST = \"(?:\\\\u0007|\\\\u001B\\\\u005C|\\\\u009C)\";\n\n // OSC sequences only: ESC ] ... ST (non-greedy until the first ST)\n const osc = `(?:\\\\u001B\\\\][\\\\s\\\\S]*?${ST})`;\n\n // CSI and related: ESC/C1, optional intermediates, optional params (supports ; and :) then final byte\n const csi =\n \"[\\\\u001B\\\\u009B][[\\\\]()#;?]*(?:\\\\d{1,4}(?:[;:]\\\\d{0,4})*)?[\\\\dA-PR-TZcf-nq-uy=><~]\";\n\n const pattern = `${osc}|${csi}`;\n\n return new RegExp(pattern, onlyFirst ? undefined : \"g\");\n};\n"]}

View File

@@ -0,0 +1,34 @@
export declare const modifierNames: string[];
export declare const foregroundColorNames: string[];
export declare const backgroundColorNames: string[];
export declare const colorNames: string[];
export declare const codes: Map<number, number>;
export declare const ansiStyles: {
[x: string]: unknown;
codes: Map<number, number>;
modifier: {
[k: string]: {
open: string;
close: string;
};
};
color: {
close: string;
ansi: (code: number) => string;
ansi256: (code: number) => string;
ansi16m: (red: number, green: number, blue: number) => string;
};
bgColor: {
close: string;
ansi: (code: number) => string;
ansi256: (code: number) => string;
ansi16m: (red: number, green: number, blue: number) => string;
};
rgbToAnsi256(red: number, green: number, blue: number): number;
hexToRgb(hex: number): [number, number, number];
hexToAnsi256(hex: number): number;
ansi256ToAnsi(code: number): number;
rgbToAnsi(red: number, green: number, blue: number): number;
hexToAnsi(hex: number): number;
};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ansi-styles/index.ts"],"names":[],"mappings":"AA2DA,eAAO,MAAM,aAAa,UAA+B,CAAC;AAC1D,eAAO,MAAM,oBAAoB,UAA4B,CAAC;AAC9D,eAAO,MAAM,oBAAoB,UAA8B,CAAC;AAChE,eAAO,MAAM,UAAU,UAAqD,CAAC;AAK7E,eAAO,MAAM,KAAK,qBAA4B,CAAC;AAe/C,eAAO,MAAM,UAAU;;;;;;;;;;;qBAQN,MAAM;wBACH,MAAM;uBACP,MAAM,SAAS,MAAM,QAAQ,MAAM;;;;qBAOrC,MAAM;wBACH,MAAM;uBACP,MAAM,SAAS,MAAM,QAAQ,MAAM;;sBAIlC,MAAM,SAAS,MAAM,QAAQ,MAAM;kBAiBvC,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;sBAuB7B,MAAM;wBAGJ,MAAM;mBA2CX,MAAM,SAAS,MAAM,QAAQ,MAAM;mBAGnC,MAAM;CAGnB,CAAC"}

View File

@@ -0,0 +1,170 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ansiStyles = exports.codes = exports.colorNames = exports.backgroundColorNames = exports.foregroundColorNames = exports.modifierNames = void 0;
const styles = {
modifier: {
reset: [0, 0],
// 21 isn't widely supported and 22 does the same thing
bold: [1, 22],
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
overline: [53, 55],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29],
},
color: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
// Bright color
blackBright: [90, 39],
gray: [90, 39], // Alias of `blackBright`
grey: [90, 39], // Alias of `blackBright`
redBright: [91, 39],
greenBright: [92, 39],
yellowBright: [93, 39],
blueBright: [94, 39],
magentaBright: [95, 39],
cyanBright: [96, 39],
whiteBright: [97, 39],
},
bgColor: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49],
// Bright color
bgBlackBright: [100, 49],
bgGray: [100, 49], // Alias of `bgBlackBright`
bgGrey: [100, 49], // Alias of `bgBlackBright`
bgRedBright: [101, 49],
bgGreenBright: [102, 49],
bgYellowBright: [103, 49],
bgBlueBright: [104, 49],
bgMagentaBright: [105, 49],
bgCyanBright: [106, 49],
bgWhiteBright: [107, 49],
},
};
exports.modifierNames = Object.keys(styles.modifier);
exports.foregroundColorNames = Object.keys(styles.color);
exports.backgroundColorNames = Object.keys(styles.bgColor);
exports.colorNames = [...exports.foregroundColorNames, ...exports.backgroundColorNames];
class AnsiStyles {
}
exports.codes = new Map();
const ingest = (set) => Object.fromEntries(Object.entries(set).map(([key, [open, close]]) => {
exports.codes.set(open, close);
return [
key,
(AnsiStyles.prototype[key] = {
open: `\u001B[${open}m`,
close: `\u001B[${close}m`,
}),
];
}));
exports.ansiStyles = new (class extends AnsiStyles {
codes = exports.codes;
modifier = ingest(styles.modifier);
color = {
...ingest(styles.color),
close: "\x1B[39m",
ansi: (code) => `\u001B[${code}m`,
ansi256: (code) => `\u001B[${38};5;${code}m`,
ansi16m: (red, green, blue) => `\u001B[${38};2;${red};${green};${blue}m`,
};
bgColor = {
...ingest(styles.bgColor),
close: "\u001B[49m",
ansi: (code) => `\u001B[${code + 10}m`,
ansi256: (code) => `\u001B[${48};5;${code}m`,
ansi16m: (red, green, blue) => `\u001B[${48};2;${red};${green};${blue}m`,
};
rgbToAnsi256(red, green, blue) {
// We use the extended greyscale palette here, with the exception of
// black and white. normal palette only has 4 greyscale shades.
if (red === green && green === blue) {
if (red < 8)
return 16;
if (red > 248)
return 231;
return Math.round(((red - 8) / 247) * 24) + 232;
}
return (16 +
36 * Math.round((red / 255) * 5) +
6 * Math.round((green / 255) * 5) +
Math.round((blue / 255) * 5));
}
hexToRgb(hex) {
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
if (!matches) {
return [0, 0, 0];
}
let [colorString] = matches;
if (colorString.length === 3) {
colorString = [...colorString]
.map((character) => character + character)
.join("");
}
const integer = Number.parseInt(colorString, 16);
return [
(integer >> 16) & 0xff,
(integer >> 8) & 0xff,
integer & 0xff,
];
}
hexToAnsi256(hex) {
return this.rgbToAnsi256(...this.hexToRgb(hex));
}
ansi256ToAnsi(code) {
if (code < 8) {
return 30 + code;
}
if (code < 16) {
return 90 + (code - 8);
}
let red;
let green;
let blue;
if (code >= 232) {
red = ((code - 232) * 10 + 8) / 255;
green = red;
blue = red;
}
else {
code -= 16;
const remainder = code % 36;
red = Math.floor(code / 36) / 5;
green = Math.floor(remainder / 6) / 5;
blue = (remainder % 6) / 5;
}
const value = Math.max(red, green, blue) * 2;
if (value === 0) {
return 30;
}
let result = 30 +
((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
if (value === 2) {
result += 60;
}
return result;
}
rgbToAnsi(red, green, blue) {
return this.ansi256ToAnsi(this.rgbToAnsi256(red, green, blue));
}
hexToAnsi(hex) {
return this.ansi256ToAnsi(this.hexToAnsi256(hex));
}
})();
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
export declare const eastAsianWidth: (character: string) => "F" | "H" | "W" | "Na" | "A" | "N";
export declare const characterLength: (character: string) => 2 | 1;
export declare const stringToArray: (str: string) => RegExpMatchArray | [];
export declare const length: (str: string) => number;
export declare const slice: (text: string, start: number, end: number) => string;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/eastasianwidth/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,GAAI,WAAW,MAAM,uCAqQ/C,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,WAAW,MAAM,UAOhD,CAAC;AAGF,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,0BAExC,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,WAOjC,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,EAAE,KAAK,MAAM,WAyB7D,CAAC"}

View File

@@ -0,0 +1,307 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.slice = exports.length = exports.stringToArray = exports.characterLength = exports.eastAsianWidth = void 0;
const eastAsianWidth = (character) => {
var x = character.charCodeAt(0);
var y = character.length == 2 ? character.charCodeAt(1) : 0;
var codePoint = x;
if (0xd800 <= x && x <= 0xdbff && 0xdc00 <= y && y <= 0xdfff) {
x &= 0x3ff;
y &= 0x3ff;
codePoint = (x << 10) | y;
codePoint += 0x10000;
}
if (0x3000 == codePoint ||
(0xff01 <= codePoint && codePoint <= 0xff60) ||
(0xffe0 <= codePoint && codePoint <= 0xffe6)) {
return "F";
}
if (0x20a9 == codePoint ||
(0xff61 <= codePoint && codePoint <= 0xffbe) ||
(0xffc2 <= codePoint && codePoint <= 0xffc7) ||
(0xffca <= codePoint && codePoint <= 0xffcf) ||
(0xffd2 <= codePoint && codePoint <= 0xffd7) ||
(0xffda <= codePoint && codePoint <= 0xffdc) ||
(0xffe8 <= codePoint && codePoint <= 0xffee)) {
return "H";
}
if ((0x1100 <= codePoint && codePoint <= 0x115f) ||
(0x11a3 <= codePoint && codePoint <= 0x11a7) ||
(0x11fa <= codePoint && codePoint <= 0x11ff) ||
(0x2329 <= codePoint && codePoint <= 0x232a) ||
(0x2e80 <= codePoint && codePoint <= 0x2e99) ||
(0x2e9b <= codePoint && codePoint <= 0x2ef3) ||
(0x2f00 <= codePoint && codePoint <= 0x2fd5) ||
(0x2ff0 <= codePoint && codePoint <= 0x2ffb) ||
(0x3001 <= codePoint && codePoint <= 0x303e) ||
(0x3041 <= codePoint && codePoint <= 0x3096) ||
(0x3099 <= codePoint && codePoint <= 0x30ff) ||
(0x3105 <= codePoint && codePoint <= 0x312d) ||
(0x3131 <= codePoint && codePoint <= 0x318e) ||
(0x3190 <= codePoint && codePoint <= 0x31ba) ||
(0x31c0 <= codePoint && codePoint <= 0x31e3) ||
(0x31f0 <= codePoint && codePoint <= 0x321e) ||
(0x3220 <= codePoint && codePoint <= 0x3247) ||
(0x3250 <= codePoint && codePoint <= 0x32fe) ||
(0x3300 <= codePoint && codePoint <= 0x4dbf) ||
(0x4e00 <= codePoint && codePoint <= 0xa48c) ||
(0xa490 <= codePoint && codePoint <= 0xa4c6) ||
(0xa960 <= codePoint && codePoint <= 0xa97c) ||
(0xac00 <= codePoint && codePoint <= 0xd7a3) ||
(0xd7b0 <= codePoint && codePoint <= 0xd7c6) ||
(0xd7cb <= codePoint && codePoint <= 0xd7fb) ||
(0xf900 <= codePoint && codePoint <= 0xfaff) ||
(0xfe10 <= codePoint && codePoint <= 0xfe19) ||
(0xfe30 <= codePoint && codePoint <= 0xfe52) ||
(0xfe54 <= codePoint && codePoint <= 0xfe66) ||
(0xfe68 <= codePoint && codePoint <= 0xfe6b) ||
(0x1b000 <= codePoint && codePoint <= 0x1b001) ||
(0x1f200 <= codePoint && codePoint <= 0x1f202) ||
(0x1f210 <= codePoint && codePoint <= 0x1f23a) ||
(0x1f240 <= codePoint && codePoint <= 0x1f248) ||
(0x1f250 <= codePoint && codePoint <= 0x1f251) ||
(0x20000 <= codePoint && codePoint <= 0x2f73f) ||
(0x2b740 <= codePoint && codePoint <= 0x2fffd) ||
(0x30000 <= codePoint && codePoint <= 0x3fffd)) {
return "W";
}
if ((0x0020 <= codePoint && codePoint <= 0x007e) ||
(0x00a2 <= codePoint && codePoint <= 0x00a3) ||
(0x00a5 <= codePoint && codePoint <= 0x00a6) ||
0x00ac == codePoint ||
0x00af == codePoint ||
(0x27e6 <= codePoint && codePoint <= 0x27ed) ||
(0x2985 <= codePoint && codePoint <= 0x2986)) {
return "Na";
}
if (0x00a1 == codePoint ||
0x00a4 == codePoint ||
(0x00a7 <= codePoint && codePoint <= 0x00a8) ||
0x00aa == codePoint ||
(0x00ad <= codePoint && codePoint <= 0x00ae) ||
(0x00b0 <= codePoint && codePoint <= 0x00b4) ||
(0x00b6 <= codePoint && codePoint <= 0x00ba) ||
(0x00bc <= codePoint && codePoint <= 0x00bf) ||
0x00c6 == codePoint ||
0x00d0 == codePoint ||
(0x00d7 <= codePoint && codePoint <= 0x00d8) ||
(0x00de <= codePoint && codePoint <= 0x00e1) ||
0x00e6 == codePoint ||
(0x00e8 <= codePoint && codePoint <= 0x00ea) ||
(0x00ec <= codePoint && codePoint <= 0x00ed) ||
0x00f0 == codePoint ||
(0x00f2 <= codePoint && codePoint <= 0x00f3) ||
(0x00f7 <= codePoint && codePoint <= 0x00fa) ||
0x00fc == codePoint ||
0x00fe == codePoint ||
0x0101 == codePoint ||
0x0111 == codePoint ||
0x0113 == codePoint ||
0x011b == codePoint ||
(0x0126 <= codePoint && codePoint <= 0x0127) ||
0x012b == codePoint ||
(0x0131 <= codePoint && codePoint <= 0x0133) ||
0x0138 == codePoint ||
(0x013f <= codePoint && codePoint <= 0x0142) ||
0x0144 == codePoint ||
(0x0148 <= codePoint && codePoint <= 0x014b) ||
0x014d == codePoint ||
(0x0152 <= codePoint && codePoint <= 0x0153) ||
(0x0166 <= codePoint && codePoint <= 0x0167) ||
0x016b == codePoint ||
0x01ce == codePoint ||
0x01d0 == codePoint ||
0x01d2 == codePoint ||
0x01d4 == codePoint ||
0x01d6 == codePoint ||
0x01d8 == codePoint ||
0x01da == codePoint ||
0x01dc == codePoint ||
0x0251 == codePoint ||
0x0261 == codePoint ||
0x02c4 == codePoint ||
0x02c7 == codePoint ||
(0x02c9 <= codePoint && codePoint <= 0x02cb) ||
0x02cd == codePoint ||
0x02d0 == codePoint ||
(0x02d8 <= codePoint && codePoint <= 0x02db) ||
0x02dd == codePoint ||
0x02df == codePoint ||
(0x0300 <= codePoint && codePoint <= 0x036f) ||
(0x0391 <= codePoint && codePoint <= 0x03a1) ||
(0x03a3 <= codePoint && codePoint <= 0x03a9) ||
(0x03b1 <= codePoint && codePoint <= 0x03c1) ||
(0x03c3 <= codePoint && codePoint <= 0x03c9) ||
0x0401 == codePoint ||
(0x0410 <= codePoint && codePoint <= 0x044f) ||
0x0451 == codePoint ||
0x2010 == codePoint ||
(0x2013 <= codePoint && codePoint <= 0x2016) ||
(0x2018 <= codePoint && codePoint <= 0x2019) ||
(0x201c <= codePoint && codePoint <= 0x201d) ||
(0x2020 <= codePoint && codePoint <= 0x2022) ||
(0x2024 <= codePoint && codePoint <= 0x2027) ||
0x2030 == codePoint ||
(0x2032 <= codePoint && codePoint <= 0x2033) ||
0x2035 == codePoint ||
0x203b == codePoint ||
0x203e == codePoint ||
0x2074 == codePoint ||
0x207f == codePoint ||
(0x2081 <= codePoint && codePoint <= 0x2084) ||
0x20ac == codePoint ||
0x2103 == codePoint ||
0x2105 == codePoint ||
0x2109 == codePoint ||
0x2113 == codePoint ||
0x2116 == codePoint ||
(0x2121 <= codePoint && codePoint <= 0x2122) ||
0x2126 == codePoint ||
0x212b == codePoint ||
(0x2153 <= codePoint && codePoint <= 0x2154) ||
(0x215b <= codePoint && codePoint <= 0x215e) ||
(0x2160 <= codePoint && codePoint <= 0x216b) ||
(0x2170 <= codePoint && codePoint <= 0x2179) ||
0x2189 == codePoint ||
(0x2190 <= codePoint && codePoint <= 0x2199) ||
(0x21b8 <= codePoint && codePoint <= 0x21b9) ||
0x21d2 == codePoint ||
0x21d4 == codePoint ||
0x21e7 == codePoint ||
0x2200 == codePoint ||
(0x2202 <= codePoint && codePoint <= 0x2203) ||
(0x2207 <= codePoint && codePoint <= 0x2208) ||
0x220b == codePoint ||
0x220f == codePoint ||
0x2211 == codePoint ||
0x2215 == codePoint ||
0x221a == codePoint ||
(0x221d <= codePoint && codePoint <= 0x2220) ||
0x2223 == codePoint ||
0x2225 == codePoint ||
(0x2227 <= codePoint && codePoint <= 0x222c) ||
0x222e == codePoint ||
(0x2234 <= codePoint && codePoint <= 0x2237) ||
(0x223c <= codePoint && codePoint <= 0x223d) ||
0x2248 == codePoint ||
0x224c == codePoint ||
0x2252 == codePoint ||
(0x2260 <= codePoint && codePoint <= 0x2261) ||
(0x2264 <= codePoint && codePoint <= 0x2267) ||
(0x226a <= codePoint && codePoint <= 0x226b) ||
(0x226e <= codePoint && codePoint <= 0x226f) ||
(0x2282 <= codePoint && codePoint <= 0x2283) ||
(0x2286 <= codePoint && codePoint <= 0x2287) ||
0x2295 == codePoint ||
0x2299 == codePoint ||
0x22a5 == codePoint ||
0x22bf == codePoint ||
0x2312 == codePoint ||
(0x2460 <= codePoint && codePoint <= 0x24e9) ||
(0x24eb <= codePoint && codePoint <= 0x254b) ||
(0x2550 <= codePoint && codePoint <= 0x2573) ||
(0x2580 <= codePoint && codePoint <= 0x258f) ||
(0x2592 <= codePoint && codePoint <= 0x2595) ||
(0x25a0 <= codePoint && codePoint <= 0x25a1) ||
(0x25a3 <= codePoint && codePoint <= 0x25a9) ||
(0x25b2 <= codePoint && codePoint <= 0x25b3) ||
(0x25b6 <= codePoint && codePoint <= 0x25b7) ||
(0x25bc <= codePoint && codePoint <= 0x25bd) ||
(0x25c0 <= codePoint && codePoint <= 0x25c1) ||
(0x25c6 <= codePoint && codePoint <= 0x25c8) ||
0x25cb == codePoint ||
(0x25ce <= codePoint && codePoint <= 0x25d1) ||
(0x25e2 <= codePoint && codePoint <= 0x25e5) ||
0x25ef == codePoint ||
(0x2605 <= codePoint && codePoint <= 0x2606) ||
0x2609 == codePoint ||
(0x260e <= codePoint && codePoint <= 0x260f) ||
(0x2614 <= codePoint && codePoint <= 0x2615) ||
0x261c == codePoint ||
0x261e == codePoint ||
0x2640 == codePoint ||
0x2642 == codePoint ||
(0x2660 <= codePoint && codePoint <= 0x2661) ||
(0x2663 <= codePoint && codePoint <= 0x2665) ||
(0x2667 <= codePoint && codePoint <= 0x266a) ||
(0x266c <= codePoint && codePoint <= 0x266d) ||
0x266f == codePoint ||
(0x269e <= codePoint && codePoint <= 0x269f) ||
(0x26be <= codePoint && codePoint <= 0x26bf) ||
(0x26c4 <= codePoint && codePoint <= 0x26cd) ||
(0x26cf <= codePoint && codePoint <= 0x26e1) ||
0x26e3 == codePoint ||
(0x26e8 <= codePoint && codePoint <= 0x26ff) ||
0x273d == codePoint ||
0x2757 == codePoint ||
(0x2776 <= codePoint && codePoint <= 0x277f) ||
(0x2b55 <= codePoint && codePoint <= 0x2b59) ||
(0x3248 <= codePoint && codePoint <= 0x324f) ||
(0xe000 <= codePoint && codePoint <= 0xf8ff) ||
(0xfe00 <= codePoint && codePoint <= 0xfe0f) ||
0xfffd == codePoint ||
(0x1f100 <= codePoint && codePoint <= 0x1f10a) ||
(0x1f110 <= codePoint && codePoint <= 0x1f12d) ||
(0x1f130 <= codePoint && codePoint <= 0x1f169) ||
(0x1f170 <= codePoint && codePoint <= 0x1f19a) ||
(0xe0100 <= codePoint && codePoint <= 0xe01ef) ||
(0xf0000 <= codePoint && codePoint <= 0xffffd) ||
(0x100000 <= codePoint && codePoint <= 0x10fffd)) {
return "A";
}
return "N";
};
exports.eastAsianWidth = eastAsianWidth;
const characterLength = (character) => {
var code = (0, exports.eastAsianWidth)(character);
if (code == "F" || code == "W" || code == "A") {
return 2;
}
else {
return 1;
}
};
exports.characterLength = characterLength;
// Split a string considering surrogate-pairs.
const stringToArray = (str) => {
return str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
};
exports.stringToArray = stringToArray;
const length = (str) => {
var characters = (0, exports.stringToArray)(str);
var len = 0;
for (const char of characters) {
len = len + (0, exports.characterLength)(char);
}
return len;
};
exports.length = length;
const slice = (text, start, end) => {
const textLen = (0, exports.length)(text);
start = start ? start : 0;
end = end ? end : 1;
if (start < 0) {
start = textLen + start;
}
if (end < 0) {
end = textLen + end;
}
var result = "";
var eawLen = 0;
var chars = (0, exports.stringToArray)(text);
for (const char of chars) {
var charLen = (0, exports.length)(char);
if (eawLen >= start - (charLen == 2 ? 1 : 0)) {
if (eawLen + charLen <= end) {
result += char;
}
else {
break;
}
}
eawLen += charLen;
}
return result;
};
exports.slice = slice;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export declare const emojiRegex: () => RegExp;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/emoji-regex/index.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,cAC2we,CAAC"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

41
node_modules/@isaacs/cliui/dist/commonjs/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,41 @@
export type UIOptions = {
width: number;
wrap?: boolean;
rows?: string[];
};
export type Column = {
text: string;
width?: number;
align?: 'right' | 'left' | 'center';
padding?: number[];
border?: boolean;
};
export type ColumnArray = Column[] & {
span?: boolean;
};
export type Line = {
hidden?: boolean;
text: string;
span?: boolean;
};
export declare class UI {
width: number;
wrap: boolean;
rows: ColumnArray[];
constructor(opts: UIOptions);
span(...args: ColumnArray): void;
resetOutput(): void;
div(...args: (Column | string)[]): ColumnArray;
shouldApplyLayoutDSL(...args: (Column | string)[]): boolean;
applyLayoutDSL(str: string): ColumnArray;
colFromString(text: string): Column;
measurePadding(str: string): number[];
toString(): string;
rowToString(row: ColumnArray, lines: Line[]): Line[];
renderInline(source: string, previousLine: Line): string;
rasterize(row: ColumnArray): string[][];
negatePadding(col: Column): number;
columnWidths(row: ColumnArray): number[];
}
export declare const cliui: (opts?: Partial<UIOptions>) => UI;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAA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js/index.js generated vendored Normal file
View File

@@ -0,0 +1,322 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cliui = exports.UI = void 0;
const index_js_1 = require("./string-width/index.js");
const index_js_2 = require("./strip-ansi/index.js");
const index_js_3 = require("./wrap-ansi/index.js");
const align = {
right: (str, width) => `${' '.repeat(Math.max(0, width - (0, index_js_1.stringWidth)(str)))}${str}`,
center: (str, width) => `${' '.repeat(Math.max(0, width - (0, index_js_1.stringWidth)(str)) >> 1)}${str}`,
};
const top = 0;
const right = 1;
const bottom = 2;
const left = 3;
class UI {
width;
wrap;
rows;
constructor(opts) {
this.width = opts.width;
/* c8 ignore start */
this.wrap = opts.wrap ?? true;
/* c8 ignore stop */
this.rows = [];
}
span(...args) {
const cols = this.div(...args);
cols.span = true;
}
resetOutput() {
this.rows = [];
}
div(...args) {
if (args.length === 0) {
this.div('');
}
if (this.wrap &&
this.shouldApplyLayoutDSL(...args) &&
typeof args[0] === 'string') {
return this.applyLayoutDSL(args[0]);
}
const cols = Object.assign(args.map(arg => {
if (typeof arg === 'string') {
return this.colFromString(arg);
}
return arg;
}), { span: false });
this.rows.push(cols);
return cols;
}
shouldApplyLayoutDSL(...args) {
return (args.length === 1 &&
typeof args[0] === 'string' &&
/[\t\n]/.test(args[0]));
}
applyLayoutDSL(str) {
const rows = str.split('\n').map(row => row.split('\t'));
let leftColumnWidth = 0;
// simple heuristic for layout, make sure the
// second column lines up along the left-hand.
// don't allow the first column to take up more
// than 50% of the screen.
rows.forEach(columns => {
if (columns.length > 1 &&
(0, index_js_1.stringWidth)(String(columns[0])) > leftColumnWidth) {
leftColumnWidth = Math.min(Math.floor(this.width * 0.5), (0, index_js_1.stringWidth)(String(columns[0])));
}
});
// generate a table:
// replacing ' ' with padding calculations.
// using the algorithmically generated width.
rows.forEach(columns => {
this.div(...columns.map((r, i) => {
return {
text: r.trim(),
padding: this.measurePadding(r),
width: i === 0 && columns.length > 1 ? leftColumnWidth : undefined,
};
}));
});
const row = this.rows[this.rows.length - 1];
/* c8 ignore start */
if (!row) {
throw new Error('no rows found');
}
/* c8 ignore stop */
return row;
}
colFromString(text) {
return {
text,
padding: this.measurePadding(text),
};
}
measurePadding(str) {
// measure padding without ansi escape codes
const noAnsi = (0, index_js_2.stripAnsi)(str);
const [right = '', left = ''] = [
noAnsi.match(/\s*$/)?.[0],
noAnsi.match(/^\s*/)?.[0],
];
return [0, right.length, 0, left.length];
}
toString() {
const lines = [];
this.rows.forEach(row => {
this.rowToString(row, lines);
});
// don't display any lines with the
// hidden flag set.
return lines
.filter(line => !line.hidden)
.map(line => line.text)
.join('\n');
}
rowToString(row, lines) {
this.rasterize(row).forEach((rrow, r) => {
let str = '';
rrow.forEach((col, c) => {
const column = row[c];
const { width } = column; // the width with padding.
const wrapWidth = this.negatePadding(column); // the width without padding.
let ts = col; // temporary string used during alignment/padding.
if (wrapWidth > (0, index_js_1.stringWidth)(col)) {
ts += ' '.repeat(wrapWidth - (0, index_js_1.stringWidth)(col));
}
// align the string within its column.
if (column.align && column.align !== 'left' && this.wrap) {
const fn = align[column.align];
ts = fn(ts.trim(), wrapWidth);
if ((0, index_js_1.stringWidth)(ts) < wrapWidth) {
/* c8 ignore start */
const w = width || 0;
/* c8 ignore stop */
ts += ' '.repeat(w - (0, index_js_1.stringWidth)(ts) - 1);
}
}
// apply border and padding to string.
const padding = column.padding || [0, 0, 0, 0];
if (padding[left]) {
str += ' '.repeat(padding[left]);
}
str += addBorder(column, ts, '| ');
str += ts;
str += addBorder(column, ts, ' |');
if (padding[right]) {
str += ' '.repeat(padding[right]);
}
// if prior row is span, try to render the
// current row on the prior line.
if (r === 0 && lines.length > 0) {
const lastLine = lines[lines.length - 1];
/* c8 ignore start */
if (!lastLine) {
throw new Error('last line not found');
}
/* c8 ignore stop */
str = this.renderInline(str, lastLine);
}
});
// remove trailing whitespace.
lines.push({
text: str.replace(/ +$/, ''),
span: row.span,
});
});
return lines;
}
// if the full 'source' can render in
// the target line, do so.
renderInline(source, previousLine) {
const match = source.match(/^ */);
/* c8 ignore start */
const leadingWhitespace = match ? match[0].length : 0;
/* c8 ignore stop */
const target = previousLine.text;
const targetTextWidth = (0, index_js_1.stringWidth)(target.trimEnd());
if (!previousLine.span) {
return source;
}
// if we're not applying wrapping logic,
// just always append to the span.
if (!this.wrap) {
previousLine.hidden = true;
return target + source;
}
if (leadingWhitespace < targetTextWidth) {
return source;
}
previousLine.hidden = true;
return (target.trimEnd() +
' '.repeat(leadingWhitespace - targetTextWidth) +
source.trimStart());
}
rasterize(row) {
const rrows = [];
const widths = this.columnWidths(row);
let wrapped;
// word wrap all columns, and create
// a data-structure that is easy to rasterize.
row.forEach((col, c) => {
// leave room for left and right padding.
col.width = widths[c];
if (this.wrap) {
wrapped = (0, index_js_3.wrap)(col.text, this.negatePadding(col), {
hard: true,
}).split('\n');
}
else {
wrapped = col.text.split('\n');
}
if (col.border) {
wrapped.unshift('.' + '-'.repeat(this.negatePadding(col) + 2) + '.');
wrapped.push("'" + '-'.repeat(this.negatePadding(col) + 2) + "'");
}
// add top and bottom padding.
if (col.padding) {
wrapped.unshift(...new Array(col.padding[top] || 0).fill(''));
wrapped.push(...new Array(col.padding[bottom] || 0).fill(''));
}
wrapped.forEach((str, r) => {
if (!rrows[r]) {
rrows.push([]);
}
/* c8 ignore start */
const rrow = rrows[r] ?? [];
/* c8 ignore stop */
for (let i = 0; i < c; i++) {
if (rrow[i] === undefined) {
rrow.push('');
}
}
rrow.push(str);
});
});
return rrows;
}
negatePadding(col) {
/* c8 ignore start */
let wrapWidth = col.width || 0;
/* c8 ignore stop */
if (col.padding) {
wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
}
if (col.border) {
wrapWidth -= 4;
}
return wrapWidth;
}
columnWidths(row) {
if (!this.wrap) {
return row.map(col => {
return col.width || (0, index_js_1.stringWidth)(col.text);
});
}
let unset = row.length;
let remainingWidth = this.width;
// column widths can be set in config.
const widths = row.map(col => {
if (col.width) {
unset--;
remainingWidth -= col.width;
return col.width;
}
return undefined;
});
// any unset widths should be calculated.
/* c8 ignore start */
const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
/* c8 ignore stop */
return widths.map((w, i) => {
if (w === undefined) {
/* c8 ignore start */
const col = row[i] ?? { text: '', padding: [] };
/* c8 ignore stop */
return Math.max(unsetWidth, _minWidth(col));
}
return w;
});
}
}
exports.UI = UI;
const addBorder = (col, ts, style) => {
if (col.border) {
if (/[.']-+[.']/.test(ts)) {
return '';
}
if (ts.trim().length !== 0) {
return style;
}
return ' ';
}
return '';
};
// calculates the minimum width of
// a column, based on padding preferences.
const _minWidth = (col) => {
const padding = col.padding || [];
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
if (col.border) {
return minWidth + 4;
}
return minWidth;
};
const getWindowWidth = () => {
/* c8 ignore start */
if (typeof process === 'object' &&
process.stdout &&
process.stdout.columns) {
return process.stdout.columns;
}
return 80;
};
/* c8 ignore stop */
const cliui = (opts = {}) => new UI({
/* c8 ignore start */
width: opts?.width || getWindowWidth(),
wrap: opts?.wrap,
/* c8 ignore stop */
});
exports.cliui = cliui;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

12
node_modules/@isaacs/cliui/dist/commonjs/index.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
{
"type": "commonjs"
}

View File

@@ -0,0 +1,5 @@
export type Options = {
ambiguousIsNarrow?: boolean;
};
export declare function stringWidth(str: string, options?: Options): number;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/string-width/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,OAAO,GAAG;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,OAAY,UAqD7D"}

View File

@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringWidth = stringWidth;
const index_js_1 = require("../strip-ansi/index.js");
const index_js_2 = require("../eastasianwidth/index.js");
const index_js_3 = require("../emoji-regex/index.js");
function stringWidth(str, options = {}) {
if (typeof str !== "string" || str.length === 0) {
return 0;
}
options = {
ambiguousIsNarrow: true,
...options,
};
str = (0, index_js_1.stripAnsi)(str);
if (str.length === 0) {
return 0;
}
str = str.replace((0, index_js_3.emojiRegex)(), " ");
const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;
let width = 0;
for (const character of str) {
const codePoint = character.codePointAt(0);
// Ignore control characters
if (!codePoint ||
codePoint <= 0x1f ||
(codePoint >= 0x7f && codePoint <= 0x9f)) {
continue;
}
// Ignore combining characters
if (codePoint >= 0x300 && codePoint <= 0x36f) {
continue;
}
const code = (0, index_js_2.eastAsianWidth)(character);
switch (code) {
case "F":
case "W":
width += 2;
break;
case "A":
width += ambiguousCharacterWidth;
break;
default:
width += 1;
}
}
return width;
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/string-width/index.ts"],"names":[],"mappings":";;AAQA,kCAqDC;AA7DD,qDAAmD;AACnD,yDAA4D;AAC5D,sDAAqD;AAMrD,SAAgB,WAAW,CAAC,GAAW,EAAE,UAAmB,EAAE;IAC5D,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,GAAG;QACR,iBAAiB,EAAE,IAAI;QACvB,GAAG,OAAO;KACX,CAAC;IAEF,GAAG,GAAG,IAAA,oBAAS,EAAC,GAAG,CAAC,CAAC;IAErB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAA,qBAAU,GAAE,EAAE,IAAI,CAAC,CAAC;IAEtC,MAAM,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,KAAK,MAAM,SAAS,IAAI,GAAG,EAAE,CAAC;QAC5B,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAE3C,4BAA4B;QAC5B,IACE,CAAC,SAAS;YACV,SAAS,IAAI,IAAI;YACjB,CAAC,SAAS,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,CAAC,EACxC,CAAC;YACD,SAAS;QACX,CAAC;QAED,8BAA8B;QAC9B,IAAI,SAAS,IAAI,KAAK,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;YAC7C,SAAS;QACX,CAAC;QAED,MAAM,IAAI,GAAG,IAAA,yBAAc,EAAC,SAAS,CAAC,CAAC;QACvC,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,GAAG,CAAC;YACT,KAAK,GAAG;gBACN,KAAK,IAAI,CAAC,CAAC;gBACX,MAAM;YACR,KAAK,GAAG;gBACN,KAAK,IAAI,uBAAuB,CAAC;gBACjC,MAAM;YACR;gBACE,KAAK,IAAI,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { stripAnsi } from \"../strip-ansi/index.js\";\nimport { eastAsianWidth } from \"../eastasianwidth/index.js\";\nimport { emojiRegex } from \"../emoji-regex/index.js\";\n\nexport type Options = {\n ambiguousIsNarrow?: boolean;\n};\n\nexport function stringWidth(str: string, options: Options = {}) {\n if (typeof str !== \"string\" || str.length === 0) {\n return 0;\n }\n\n options = {\n ambiguousIsNarrow: true,\n ...options,\n };\n\n str = stripAnsi(str);\n\n if (str.length === 0) {\n return 0;\n }\n\n str = str.replace(emojiRegex(), \" \");\n\n const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;\n let width = 0;\n\n for (const character of str) {\n const codePoint = character.codePointAt(0);\n\n // Ignore control characters\n if (\n !codePoint ||\n codePoint <= 0x1f ||\n (codePoint >= 0x7f && codePoint <= 0x9f)\n ) {\n continue;\n }\n\n // Ignore combining characters\n if (codePoint >= 0x300 && codePoint <= 0x36f) {\n continue;\n }\n\n const code = eastAsianWidth(character);\n switch (code) {\n case \"F\":\n case \"W\":\n width += 2;\n break;\n case \"A\":\n width += ambiguousCharacterWidth;\n break;\n default:\n width += 1;\n }\n }\n\n return width;\n}\n"]}

View File

@@ -0,0 +1,2 @@
export declare const stripAnsi: (str: string) => string;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/strip-ansi/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,WAA2B,CAAC"}

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stripAnsi = void 0;
const index_js_1 = require("../ansi-regex/index.js");
const regex = (0, index_js_1.ansiRegex)();
const stripAnsi = (str) => str.replace(regex, "");
exports.stripAnsi = stripAnsi;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/strip-ansi/index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AACnD,MAAM,KAAK,GAAG,IAAA,oBAAS,GAAE,CAAC;AACnB,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAApD,QAAA,SAAS,aAA2C","sourcesContent":["import { ansiRegex } from \"../ansi-regex/index.js\";\nconst regex = ansiRegex();\nexport const stripAnsi = (str: string) => str.replace(regex, \"\");\n"]}

View File

@@ -0,0 +1,7 @@
export type Options = {
trim?: boolean;
wordWrap?: boolean;
hard?: boolean;
};
export declare const wrap: (str: string, columns: number, options: Options) => string;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wrap-ansi/index.ts"],"names":[],"mappings":"AAuGA,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAuH7E,eAAO,MAAM,IAAI,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,EAAE,SAAS,OAAO,WAMpD,CAAC"}

View File

@@ -0,0 +1,176 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrap = void 0;
const index_js_1 = require("../string-width/index.js");
const index_js_2 = require("../strip-ansi/index.js");
const index_js_3 = require("../ansi-styles/index.js");
const ESCAPES = new Set(["\u001B", "\u009B"]);
const END_CODE = 39;
const ANSI_ESCAPE_BELL = "\u0007";
const ANSI_CSI = "[";
const ANSI_OSC = "]";
const ANSI_SGR_TERMINATOR = "m";
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
const wrapAnsiCode = (code) => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
const wrapAnsiHyperlink = (uri) => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${uri}${ANSI_ESCAPE_BELL}`;
// Calculate the length of words split on ' ', ignoring
// the extra characters added by ansi escape codes
const wordLengths = (str) => str.split(" ").map((character) => (0, index_js_1.stringWidth)(character));
// Wrap a long word across multiple rows
// Ansi escape codes do not count towards length
const wrapWord = (rows, word, columns) => {
const characters = [...word];
let isInsideEscape = false;
let isInsideLinkEscape = false;
let visible = (0, index_js_1.stringWidth)((0, index_js_2.stripAnsi)(String(rows[rows.length - 1])));
for (const [index, character] of characters.entries()) {
const characterLength = (0, index_js_1.stringWidth)(character);
if (visible + characterLength <= columns) {
rows[rows.length - 1] += character;
}
else {
rows.push(character);
visible = 0;
}
if (ESCAPES.has(character)) {
isInsideEscape = true;
isInsideLinkEscape = characters
.slice(index + 1)
.join("")
.startsWith(ANSI_ESCAPE_LINK);
}
if (isInsideEscape) {
if (isInsideLinkEscape) {
if (character === ANSI_ESCAPE_BELL) {
isInsideEscape = false;
isInsideLinkEscape = false;
}
}
else if (character === ANSI_SGR_TERMINATOR) {
isInsideEscape = false;
}
continue;
}
visible += characterLength;
if (visible === columns && index < characters.length - 1) {
rows.push("");
visible = 0;
}
}
// It's possible that the last row we copy over is only
// ansi escape characters, handle this edge-case
if (!visible && String(rows[rows.length - 1]).length > 0 && rows.length > 1) {
rows[rows.length - 2] = String(rows[rows.length - 1]) + rows.pop();
}
};
// Trims spaces from a string ignoring invisible sequences
const stringVisibleTrimSpacesRight = (str) => {
const words = str.split(" ");
let last = words.length;
while (last > 0) {
if ((0, index_js_1.stringWidth)(String(words[last - 1])) > 0) {
break;
}
last--;
}
if (last === words.length) {
return str;
}
return words.slice(0, last).join(" ") + words.slice(last).join("");
};
const exec = (str, columns, options = {}) => {
if (options.trim !== false && str.trim() === "") {
return "";
}
let returnValue = "";
let escapeCode;
let escapeUrl;
const lengths = wordLengths(str);
let rows = [""];
for (const [index, word] of str.split(" ").entries()) {
if (options.trim !== false) {
rows[rows.length - 1] = String(rows[rows.length - 1]).trimStart();
}
let rowLength = (0, index_js_1.stringWidth)(String(rows[rows.length - 1]));
if (index !== 0) {
if (rowLength >= columns &&
(options.wordWrap === false || options.trim === false)) {
// If we start with a new word but the current row length equals the length of the columns, add a new row
rows.push("");
rowLength = 0;
}
if (rowLength > 0 || options.trim === false) {
rows[rows.length - 1] += " ";
rowLength++;
}
}
// In 'hard' wrap mode, the length of a line is never allowed to extend past 'columns'
const len = Number(lengths[index]);
if (options.hard && len > columns) {
const remainingColumns = columns - rowLength;
const breaksStartingThisLine = 1 + Math.floor((len - remainingColumns - 1) / columns);
const breaksStartingNextLine = Math.floor((len - 1) / columns);
if (breaksStartingNextLine < breaksStartingThisLine) {
rows.push("");
}
wrapWord(rows, word, columns);
continue;
}
if (rowLength + len > columns && rowLength > 0 && len > 0) {
if (options.wordWrap === false && rowLength < columns) {
wrapWord(rows, word, columns);
continue;
}
rows.push("");
}
if (rowLength + len > columns && options.wordWrap === false) {
wrapWord(rows, word, columns);
continue;
}
rows[rows.length - 1] += word;
}
if (options.trim !== false) {
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
}
const pre = [...rows.join("\n")];
for (const [index, character] of pre.entries()) {
returnValue += character;
if (ESCAPES.has(character)) {
const { groups } = (new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(pre.slice(index).join("")) || { groups: {} });
if (groups.code !== undefined) {
const code = Number.parseFloat(groups.code);
escapeCode = code === END_CODE ? undefined : code;
}
else if (groups.uri !== undefined) {
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
}
}
const code = index_js_3.ansiStyles.codes.get(Number(escapeCode));
if (pre[index + 1] === "\n") {
if (escapeUrl) {
returnValue += wrapAnsiHyperlink("");
}
if (escapeCode && code) {
returnValue += wrapAnsiCode(code);
}
}
else if (character === "\n") {
if (escapeCode && code) {
returnValue += wrapAnsiCode(escapeCode);
}
if (escapeUrl) {
returnValue += wrapAnsiHyperlink(escapeUrl);
}
}
}
return returnValue;
};
// For each newline, invoke the method separately
const wrap = (str, columns, options) => String(str)
.normalize()
.replace(/\r\n/g, "\n")
.split("\n")
.map((line) => exec(line, columns, options))
.join("\n");
exports.wrap = wrap;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
export declare const ansiRegex: ({ onlyFirst }?: {
onlyFirst?: boolean | undefined;
}) => RegExp;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ansi-regex/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,GAAI;;CAA0B,WAcnD,CAAC"}

View File

@@ -0,0 +1,12 @@
// TODO! cut this down? do we need the onlyFirst option?
export const ansiRegex = ({ onlyFirst = false } = {}) => {
// Valid string terminator sequences are BEL, ESC\, and 0x9c
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
// OSC sequences only: ESC ] ... ST (non-greedy until the first ST)
const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
// CSI and related: ESC/C1, optional intermediates, optional params (supports ; and :) then final byte
const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
const pattern = `${osc}|${csi}`;
return new RegExp(pattern, onlyFirst ? undefined : "g");
};
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ansi-regex/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE;IACtD,4DAA4D;IAC5D,MAAM,EAAE,GAAG,oCAAoC,CAAC;IAEhD,mEAAmE;IACnE,MAAM,GAAG,GAAG,0BAA0B,EAAE,GAAG,CAAC;IAE5C,sGAAsG;IACtG,MAAM,GAAG,GACP,oFAAoF,CAAC;IAEvF,MAAM,OAAO,GAAG,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IAEhC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC,CAAC","sourcesContent":["// TODO! cut this down? do we need the onlyFirst option?\n\nexport const ansiRegex = ({ onlyFirst = false } = {}) => {\n // Valid string terminator sequences are BEL, ESC\\, and 0x9c\n const ST = \"(?:\\\\u0007|\\\\u001B\\\\u005C|\\\\u009C)\";\n\n // OSC sequences only: ESC ] ... ST (non-greedy until the first ST)\n const osc = `(?:\\\\u001B\\\\][\\\\s\\\\S]*?${ST})`;\n\n // CSI and related: ESC/C1, optional intermediates, optional params (supports ; and :) then final byte\n const csi =\n \"[\\\\u001B\\\\u009B][[\\\\]()#;?]*(?:\\\\d{1,4}(?:[;:]\\\\d{0,4})*)?[\\\\dA-PR-TZcf-nq-uy=><~]\";\n\n const pattern = `${osc}|${csi}`;\n\n return new RegExp(pattern, onlyFirst ? undefined : \"g\");\n};\n"]}

View File

@@ -0,0 +1,34 @@
export declare const modifierNames: string[];
export declare const foregroundColorNames: string[];
export declare const backgroundColorNames: string[];
export declare const colorNames: string[];
export declare const codes: Map<number, number>;
export declare const ansiStyles: {
[x: string]: unknown;
codes: Map<number, number>;
modifier: {
[k: string]: {
open: string;
close: string;
};
};
color: {
close: string;
ansi: (code: number) => string;
ansi256: (code: number) => string;
ansi16m: (red: number, green: number, blue: number) => string;
};
bgColor: {
close: string;
ansi: (code: number) => string;
ansi256: (code: number) => string;
ansi16m: (red: number, green: number, blue: number) => string;
};
rgbToAnsi256(red: number, green: number, blue: number): number;
hexToRgb(hex: number): [number, number, number];
hexToAnsi256(hex: number): number;
ansi256ToAnsi(code: number): number;
rgbToAnsi(red: number, green: number, blue: number): number;
hexToAnsi(hex: number): number;
};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ansi-styles/index.ts"],"names":[],"mappings":"AA2DA,eAAO,MAAM,aAAa,UAA+B,CAAC;AAC1D,eAAO,MAAM,oBAAoB,UAA4B,CAAC;AAC9D,eAAO,MAAM,oBAAoB,UAA8B,CAAC;AAChE,eAAO,MAAM,UAAU,UAAqD,CAAC;AAK7E,eAAO,MAAM,KAAK,qBAA4B,CAAC;AAe/C,eAAO,MAAM,UAAU;;;;;;;;;;;qBAQN,MAAM;wBACH,MAAM;uBACP,MAAM,SAAS,MAAM,QAAQ,MAAM;;;;qBAOrC,MAAM;wBACH,MAAM;uBACP,MAAM,SAAS,MAAM,QAAQ,MAAM;;sBAIlC,MAAM,SAAS,MAAM,QAAQ,MAAM;kBAiBvC,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;sBAuB7B,MAAM;wBAGJ,MAAM;mBA2CX,MAAM,SAAS,MAAM,QAAQ,MAAM;mBAGnC,MAAM;CAGnB,CAAC"}

View File

@@ -0,0 +1,167 @@
const styles = {
modifier: {
reset: [0, 0],
// 21 isn't widely supported and 22 does the same thing
bold: [1, 22],
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
overline: [53, 55],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29],
},
color: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
// Bright color
blackBright: [90, 39],
gray: [90, 39], // Alias of `blackBright`
grey: [90, 39], // Alias of `blackBright`
redBright: [91, 39],
greenBright: [92, 39],
yellowBright: [93, 39],
blueBright: [94, 39],
magentaBright: [95, 39],
cyanBright: [96, 39],
whiteBright: [97, 39],
},
bgColor: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49],
// Bright color
bgBlackBright: [100, 49],
bgGray: [100, 49], // Alias of `bgBlackBright`
bgGrey: [100, 49], // Alias of `bgBlackBright`
bgRedBright: [101, 49],
bgGreenBright: [102, 49],
bgYellowBright: [103, 49],
bgBlueBright: [104, 49],
bgMagentaBright: [105, 49],
bgCyanBright: [106, 49],
bgWhiteBright: [107, 49],
},
};
export const modifierNames = Object.keys(styles.modifier);
export const foregroundColorNames = Object.keys(styles.color);
export const backgroundColorNames = Object.keys(styles.bgColor);
export const colorNames = [...foregroundColorNames, ...backgroundColorNames];
class AnsiStyles {
}
export const codes = new Map();
const ingest = (set) => Object.fromEntries(Object.entries(set).map(([key, [open, close]]) => {
codes.set(open, close);
return [
key,
(AnsiStyles.prototype[key] = {
open: `\u001B[${open}m`,
close: `\u001B[${close}m`,
}),
];
}));
export const ansiStyles = new (class extends AnsiStyles {
codes = codes;
modifier = ingest(styles.modifier);
color = {
...ingest(styles.color),
close: "\x1B[39m",
ansi: (code) => `\u001B[${code}m`,
ansi256: (code) => `\u001B[${38};5;${code}m`,
ansi16m: (red, green, blue) => `\u001B[${38};2;${red};${green};${blue}m`,
};
bgColor = {
...ingest(styles.bgColor),
close: "\u001B[49m",
ansi: (code) => `\u001B[${code + 10}m`,
ansi256: (code) => `\u001B[${48};5;${code}m`,
ansi16m: (red, green, blue) => `\u001B[${48};2;${red};${green};${blue}m`,
};
rgbToAnsi256(red, green, blue) {
// We use the extended greyscale palette here, with the exception of
// black and white. normal palette only has 4 greyscale shades.
if (red === green && green === blue) {
if (red < 8)
return 16;
if (red > 248)
return 231;
return Math.round(((red - 8) / 247) * 24) + 232;
}
return (16 +
36 * Math.round((red / 255) * 5) +
6 * Math.round((green / 255) * 5) +
Math.round((blue / 255) * 5));
}
hexToRgb(hex) {
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
if (!matches) {
return [0, 0, 0];
}
let [colorString] = matches;
if (colorString.length === 3) {
colorString = [...colorString]
.map((character) => character + character)
.join("");
}
const integer = Number.parseInt(colorString, 16);
return [
(integer >> 16) & 0xff,
(integer >> 8) & 0xff,
integer & 0xff,
];
}
hexToAnsi256(hex) {
return this.rgbToAnsi256(...this.hexToRgb(hex));
}
ansi256ToAnsi(code) {
if (code < 8) {
return 30 + code;
}
if (code < 16) {
return 90 + (code - 8);
}
let red;
let green;
let blue;
if (code >= 232) {
red = ((code - 232) * 10 + 8) / 255;
green = red;
blue = red;
}
else {
code -= 16;
const remainder = code % 36;
red = Math.floor(code / 36) / 5;
green = Math.floor(remainder / 6) / 5;
blue = (remainder % 6) / 5;
}
const value = Math.max(red, green, blue) * 2;
if (value === 0) {
return 30;
}
let result = 30 +
((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
if (value === 2) {
result += 60;
}
return result;
}
rgbToAnsi(red, green, blue) {
return this.ansi256ToAnsi(this.rgbToAnsi256(red, green, blue));
}
hexToAnsi(hex) {
return this.ansi256ToAnsi(this.hexToAnsi256(hex));
}
})();
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
export declare const eastAsianWidth: (character: string) => "F" | "H" | "W" | "Na" | "A" | "N";
export declare const characterLength: (character: string) => 2 | 1;
export declare const stringToArray: (str: string) => RegExpMatchArray | [];
export declare const length: (str: string) => number;
export declare const slice: (text: string, start: number, end: number) => string;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/eastasianwidth/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,GAAI,WAAW,MAAM,uCAqQ/C,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,WAAW,MAAM,UAOhD,CAAC;AAGF,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,0BAExC,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,WAOjC,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,EAAE,KAAK,MAAM,WAyB7D,CAAC"}

View File

@@ -0,0 +1,299 @@
export const eastAsianWidth = (character) => {
var x = character.charCodeAt(0);
var y = character.length == 2 ? character.charCodeAt(1) : 0;
var codePoint = x;
if (0xd800 <= x && x <= 0xdbff && 0xdc00 <= y && y <= 0xdfff) {
x &= 0x3ff;
y &= 0x3ff;
codePoint = (x << 10) | y;
codePoint += 0x10000;
}
if (0x3000 == codePoint ||
(0xff01 <= codePoint && codePoint <= 0xff60) ||
(0xffe0 <= codePoint && codePoint <= 0xffe6)) {
return "F";
}
if (0x20a9 == codePoint ||
(0xff61 <= codePoint && codePoint <= 0xffbe) ||
(0xffc2 <= codePoint && codePoint <= 0xffc7) ||
(0xffca <= codePoint && codePoint <= 0xffcf) ||
(0xffd2 <= codePoint && codePoint <= 0xffd7) ||
(0xffda <= codePoint && codePoint <= 0xffdc) ||
(0xffe8 <= codePoint && codePoint <= 0xffee)) {
return "H";
}
if ((0x1100 <= codePoint && codePoint <= 0x115f) ||
(0x11a3 <= codePoint && codePoint <= 0x11a7) ||
(0x11fa <= codePoint && codePoint <= 0x11ff) ||
(0x2329 <= codePoint && codePoint <= 0x232a) ||
(0x2e80 <= codePoint && codePoint <= 0x2e99) ||
(0x2e9b <= codePoint && codePoint <= 0x2ef3) ||
(0x2f00 <= codePoint && codePoint <= 0x2fd5) ||
(0x2ff0 <= codePoint && codePoint <= 0x2ffb) ||
(0x3001 <= codePoint && codePoint <= 0x303e) ||
(0x3041 <= codePoint && codePoint <= 0x3096) ||
(0x3099 <= codePoint && codePoint <= 0x30ff) ||
(0x3105 <= codePoint && codePoint <= 0x312d) ||
(0x3131 <= codePoint && codePoint <= 0x318e) ||
(0x3190 <= codePoint && codePoint <= 0x31ba) ||
(0x31c0 <= codePoint && codePoint <= 0x31e3) ||
(0x31f0 <= codePoint && codePoint <= 0x321e) ||
(0x3220 <= codePoint && codePoint <= 0x3247) ||
(0x3250 <= codePoint && codePoint <= 0x32fe) ||
(0x3300 <= codePoint && codePoint <= 0x4dbf) ||
(0x4e00 <= codePoint && codePoint <= 0xa48c) ||
(0xa490 <= codePoint && codePoint <= 0xa4c6) ||
(0xa960 <= codePoint && codePoint <= 0xa97c) ||
(0xac00 <= codePoint && codePoint <= 0xd7a3) ||
(0xd7b0 <= codePoint && codePoint <= 0xd7c6) ||
(0xd7cb <= codePoint && codePoint <= 0xd7fb) ||
(0xf900 <= codePoint && codePoint <= 0xfaff) ||
(0xfe10 <= codePoint && codePoint <= 0xfe19) ||
(0xfe30 <= codePoint && codePoint <= 0xfe52) ||
(0xfe54 <= codePoint && codePoint <= 0xfe66) ||
(0xfe68 <= codePoint && codePoint <= 0xfe6b) ||
(0x1b000 <= codePoint && codePoint <= 0x1b001) ||
(0x1f200 <= codePoint && codePoint <= 0x1f202) ||
(0x1f210 <= codePoint && codePoint <= 0x1f23a) ||
(0x1f240 <= codePoint && codePoint <= 0x1f248) ||
(0x1f250 <= codePoint && codePoint <= 0x1f251) ||
(0x20000 <= codePoint && codePoint <= 0x2f73f) ||
(0x2b740 <= codePoint && codePoint <= 0x2fffd) ||
(0x30000 <= codePoint && codePoint <= 0x3fffd)) {
return "W";
}
if ((0x0020 <= codePoint && codePoint <= 0x007e) ||
(0x00a2 <= codePoint && codePoint <= 0x00a3) ||
(0x00a5 <= codePoint && codePoint <= 0x00a6) ||
0x00ac == codePoint ||
0x00af == codePoint ||
(0x27e6 <= codePoint && codePoint <= 0x27ed) ||
(0x2985 <= codePoint && codePoint <= 0x2986)) {
return "Na";
}
if (0x00a1 == codePoint ||
0x00a4 == codePoint ||
(0x00a7 <= codePoint && codePoint <= 0x00a8) ||
0x00aa == codePoint ||
(0x00ad <= codePoint && codePoint <= 0x00ae) ||
(0x00b0 <= codePoint && codePoint <= 0x00b4) ||
(0x00b6 <= codePoint && codePoint <= 0x00ba) ||
(0x00bc <= codePoint && codePoint <= 0x00bf) ||
0x00c6 == codePoint ||
0x00d0 == codePoint ||
(0x00d7 <= codePoint && codePoint <= 0x00d8) ||
(0x00de <= codePoint && codePoint <= 0x00e1) ||
0x00e6 == codePoint ||
(0x00e8 <= codePoint && codePoint <= 0x00ea) ||
(0x00ec <= codePoint && codePoint <= 0x00ed) ||
0x00f0 == codePoint ||
(0x00f2 <= codePoint && codePoint <= 0x00f3) ||
(0x00f7 <= codePoint && codePoint <= 0x00fa) ||
0x00fc == codePoint ||
0x00fe == codePoint ||
0x0101 == codePoint ||
0x0111 == codePoint ||
0x0113 == codePoint ||
0x011b == codePoint ||
(0x0126 <= codePoint && codePoint <= 0x0127) ||
0x012b == codePoint ||
(0x0131 <= codePoint && codePoint <= 0x0133) ||
0x0138 == codePoint ||
(0x013f <= codePoint && codePoint <= 0x0142) ||
0x0144 == codePoint ||
(0x0148 <= codePoint && codePoint <= 0x014b) ||
0x014d == codePoint ||
(0x0152 <= codePoint && codePoint <= 0x0153) ||
(0x0166 <= codePoint && codePoint <= 0x0167) ||
0x016b == codePoint ||
0x01ce == codePoint ||
0x01d0 == codePoint ||
0x01d2 == codePoint ||
0x01d4 == codePoint ||
0x01d6 == codePoint ||
0x01d8 == codePoint ||
0x01da == codePoint ||
0x01dc == codePoint ||
0x0251 == codePoint ||
0x0261 == codePoint ||
0x02c4 == codePoint ||
0x02c7 == codePoint ||
(0x02c9 <= codePoint && codePoint <= 0x02cb) ||
0x02cd == codePoint ||
0x02d0 == codePoint ||
(0x02d8 <= codePoint && codePoint <= 0x02db) ||
0x02dd == codePoint ||
0x02df == codePoint ||
(0x0300 <= codePoint && codePoint <= 0x036f) ||
(0x0391 <= codePoint && codePoint <= 0x03a1) ||
(0x03a3 <= codePoint && codePoint <= 0x03a9) ||
(0x03b1 <= codePoint && codePoint <= 0x03c1) ||
(0x03c3 <= codePoint && codePoint <= 0x03c9) ||
0x0401 == codePoint ||
(0x0410 <= codePoint && codePoint <= 0x044f) ||
0x0451 == codePoint ||
0x2010 == codePoint ||
(0x2013 <= codePoint && codePoint <= 0x2016) ||
(0x2018 <= codePoint && codePoint <= 0x2019) ||
(0x201c <= codePoint && codePoint <= 0x201d) ||
(0x2020 <= codePoint && codePoint <= 0x2022) ||
(0x2024 <= codePoint && codePoint <= 0x2027) ||
0x2030 == codePoint ||
(0x2032 <= codePoint && codePoint <= 0x2033) ||
0x2035 == codePoint ||
0x203b == codePoint ||
0x203e == codePoint ||
0x2074 == codePoint ||
0x207f == codePoint ||
(0x2081 <= codePoint && codePoint <= 0x2084) ||
0x20ac == codePoint ||
0x2103 == codePoint ||
0x2105 == codePoint ||
0x2109 == codePoint ||
0x2113 == codePoint ||
0x2116 == codePoint ||
(0x2121 <= codePoint && codePoint <= 0x2122) ||
0x2126 == codePoint ||
0x212b == codePoint ||
(0x2153 <= codePoint && codePoint <= 0x2154) ||
(0x215b <= codePoint && codePoint <= 0x215e) ||
(0x2160 <= codePoint && codePoint <= 0x216b) ||
(0x2170 <= codePoint && codePoint <= 0x2179) ||
0x2189 == codePoint ||
(0x2190 <= codePoint && codePoint <= 0x2199) ||
(0x21b8 <= codePoint && codePoint <= 0x21b9) ||
0x21d2 == codePoint ||
0x21d4 == codePoint ||
0x21e7 == codePoint ||
0x2200 == codePoint ||
(0x2202 <= codePoint && codePoint <= 0x2203) ||
(0x2207 <= codePoint && codePoint <= 0x2208) ||
0x220b == codePoint ||
0x220f == codePoint ||
0x2211 == codePoint ||
0x2215 == codePoint ||
0x221a == codePoint ||
(0x221d <= codePoint && codePoint <= 0x2220) ||
0x2223 == codePoint ||
0x2225 == codePoint ||
(0x2227 <= codePoint && codePoint <= 0x222c) ||
0x222e == codePoint ||
(0x2234 <= codePoint && codePoint <= 0x2237) ||
(0x223c <= codePoint && codePoint <= 0x223d) ||
0x2248 == codePoint ||
0x224c == codePoint ||
0x2252 == codePoint ||
(0x2260 <= codePoint && codePoint <= 0x2261) ||
(0x2264 <= codePoint && codePoint <= 0x2267) ||
(0x226a <= codePoint && codePoint <= 0x226b) ||
(0x226e <= codePoint && codePoint <= 0x226f) ||
(0x2282 <= codePoint && codePoint <= 0x2283) ||
(0x2286 <= codePoint && codePoint <= 0x2287) ||
0x2295 == codePoint ||
0x2299 == codePoint ||
0x22a5 == codePoint ||
0x22bf == codePoint ||
0x2312 == codePoint ||
(0x2460 <= codePoint && codePoint <= 0x24e9) ||
(0x24eb <= codePoint && codePoint <= 0x254b) ||
(0x2550 <= codePoint && codePoint <= 0x2573) ||
(0x2580 <= codePoint && codePoint <= 0x258f) ||
(0x2592 <= codePoint && codePoint <= 0x2595) ||
(0x25a0 <= codePoint && codePoint <= 0x25a1) ||
(0x25a3 <= codePoint && codePoint <= 0x25a9) ||
(0x25b2 <= codePoint && codePoint <= 0x25b3) ||
(0x25b6 <= codePoint && codePoint <= 0x25b7) ||
(0x25bc <= codePoint && codePoint <= 0x25bd) ||
(0x25c0 <= codePoint && codePoint <= 0x25c1) ||
(0x25c6 <= codePoint && codePoint <= 0x25c8) ||
0x25cb == codePoint ||
(0x25ce <= codePoint && codePoint <= 0x25d1) ||
(0x25e2 <= codePoint && codePoint <= 0x25e5) ||
0x25ef == codePoint ||
(0x2605 <= codePoint && codePoint <= 0x2606) ||
0x2609 == codePoint ||
(0x260e <= codePoint && codePoint <= 0x260f) ||
(0x2614 <= codePoint && codePoint <= 0x2615) ||
0x261c == codePoint ||
0x261e == codePoint ||
0x2640 == codePoint ||
0x2642 == codePoint ||
(0x2660 <= codePoint && codePoint <= 0x2661) ||
(0x2663 <= codePoint && codePoint <= 0x2665) ||
(0x2667 <= codePoint && codePoint <= 0x266a) ||
(0x266c <= codePoint && codePoint <= 0x266d) ||
0x266f == codePoint ||
(0x269e <= codePoint && codePoint <= 0x269f) ||
(0x26be <= codePoint && codePoint <= 0x26bf) ||
(0x26c4 <= codePoint && codePoint <= 0x26cd) ||
(0x26cf <= codePoint && codePoint <= 0x26e1) ||
0x26e3 == codePoint ||
(0x26e8 <= codePoint && codePoint <= 0x26ff) ||
0x273d == codePoint ||
0x2757 == codePoint ||
(0x2776 <= codePoint && codePoint <= 0x277f) ||
(0x2b55 <= codePoint && codePoint <= 0x2b59) ||
(0x3248 <= codePoint && codePoint <= 0x324f) ||
(0xe000 <= codePoint && codePoint <= 0xf8ff) ||
(0xfe00 <= codePoint && codePoint <= 0xfe0f) ||
0xfffd == codePoint ||
(0x1f100 <= codePoint && codePoint <= 0x1f10a) ||
(0x1f110 <= codePoint && codePoint <= 0x1f12d) ||
(0x1f130 <= codePoint && codePoint <= 0x1f169) ||
(0x1f170 <= codePoint && codePoint <= 0x1f19a) ||
(0xe0100 <= codePoint && codePoint <= 0xe01ef) ||
(0xf0000 <= codePoint && codePoint <= 0xffffd) ||
(0x100000 <= codePoint && codePoint <= 0x10fffd)) {
return "A";
}
return "N";
};
export const characterLength = (character) => {
var code = eastAsianWidth(character);
if (code == "F" || code == "W" || code == "A") {
return 2;
}
else {
return 1;
}
};
// Split a string considering surrogate-pairs.
export const stringToArray = (str) => {
return str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
};
export const length = (str) => {
var characters = stringToArray(str);
var len = 0;
for (const char of characters) {
len = len + characterLength(char);
}
return len;
};
export const slice = (text, start, end) => {
const textLen = length(text);
start = start ? start : 0;
end = end ? end : 1;
if (start < 0) {
start = textLen + start;
}
if (end < 0) {
end = textLen + end;
}
var result = "";
var eawLen = 0;
var chars = stringToArray(text);
for (const char of chars) {
var charLen = length(char);
if (eawLen >= start - (charLen == 2 ? 1 : 0)) {
if (eawLen + charLen <= end) {
result += char;
}
else {
break;
}
}
eawLen += charLen;
}
return result;
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export declare const emojiRegex: () => RegExp;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/emoji-regex/index.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,cAC2we,CAAC"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

41
node_modules/@isaacs/cliui/dist/esm/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,41 @@
export type UIOptions = {
width: number;
wrap?: boolean;
rows?: string[];
};
export type Column = {
text: string;
width?: number;
align?: 'right' | 'left' | 'center';
padding?: number[];
border?: boolean;
};
export type ColumnArray = Column[] & {
span?: boolean;
};
export type Line = {
hidden?: boolean;
text: string;
span?: boolean;
};
export declare class UI {
width: number;
wrap: boolean;
rows: ColumnArray[];
constructor(opts: UIOptions);
span(...args: ColumnArray): void;
resetOutput(): void;
div(...args: (Column | string)[]): ColumnArray;
shouldApplyLayoutDSL(...args: (Column | string)[]): boolean;
applyLayoutDSL(str: string): ColumnArray;
colFromString(text: string): Column;
measurePadding(str: string): number[];
toString(): string;
rowToString(row: ColumnArray, lines: Line[]): Line[];
renderInline(source: string, previousLine: Line): string;
rasterize(row: ColumnArray): string[][];
negatePadding(col: Column): number;
columnWidths(row: ColumnArray): number[];
}
export declare const cliui: (opts?: Partial<UIOptions>) => UI;
//# sourceMappingURL=index.d.ts.map

1
node_modules/@isaacs/cliui/dist/esm/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAA;IACnC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,EAAE,GAAG;IACnC,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAED,MAAM,MAAM,IAAI,GAAG;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAED,qBAAa,EAAE;IACb,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,WAAW,EAAE,CAAA;gBAEP,IAAI,EAAE,SAAS;IAQ3B,IAAI,CAAC,GAAG,IAAI,EAAE,WAAW;IAKzB,WAAW;IAIX,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,WAAW;IA2B9C,oBAAoB,CAAC,GAAG,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO;IAQ3D,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW;IA6CxC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAOnC,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE;IAUrC,QAAQ,IAAI,MAAM;IAelB,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE;IAgE3C,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI;IAgC/C,SAAS,CAAC,GAAG,EAAE,WAAW;IAqD1B,aAAa,CAAC,GAAG,EAAE,MAAM;IAezB,YAAY,CAAC,GAAG,EAAE,WAAW;CAqC9B;AA2CD,eAAO,MAAM,KAAK,GAAI,OAAM,OAAO,CAAC,SAAS,CAAM,OAM/C,CAAA"}

317
node_modules/@isaacs/cliui/dist/esm/index.js generated vendored Normal file
View File

@@ -0,0 +1,317 @@
import { stringWidth } from './string-width/index.js';
import { stripAnsi } from './strip-ansi/index.js';
import { wrap } from './wrap-ansi/index.js';
const align = {
right: (str, width) => `${' '.repeat(Math.max(0, width - stringWidth(str)))}${str}`,
center: (str, width) => `${' '.repeat(Math.max(0, width - stringWidth(str)) >> 1)}${str}`,
};
const top = 0;
const right = 1;
const bottom = 2;
const left = 3;
export class UI {
width;
wrap;
rows;
constructor(opts) {
this.width = opts.width;
/* c8 ignore start */
this.wrap = opts.wrap ?? true;
/* c8 ignore stop */
this.rows = [];
}
span(...args) {
const cols = this.div(...args);
cols.span = true;
}
resetOutput() {
this.rows = [];
}
div(...args) {
if (args.length === 0) {
this.div('');
}
if (this.wrap &&
this.shouldApplyLayoutDSL(...args) &&
typeof args[0] === 'string') {
return this.applyLayoutDSL(args[0]);
}
const cols = Object.assign(args.map(arg => {
if (typeof arg === 'string') {
return this.colFromString(arg);
}
return arg;
}), { span: false });
this.rows.push(cols);
return cols;
}
shouldApplyLayoutDSL(...args) {
return (args.length === 1 &&
typeof args[0] === 'string' &&
/[\t\n]/.test(args[0]));
}
applyLayoutDSL(str) {
const rows = str.split('\n').map(row => row.split('\t'));
let leftColumnWidth = 0;
// simple heuristic for layout, make sure the
// second column lines up along the left-hand.
// don't allow the first column to take up more
// than 50% of the screen.
rows.forEach(columns => {
if (columns.length > 1 &&
stringWidth(String(columns[0])) > leftColumnWidth) {
leftColumnWidth = Math.min(Math.floor(this.width * 0.5), stringWidth(String(columns[0])));
}
});
// generate a table:
// replacing ' ' with padding calculations.
// using the algorithmically generated width.
rows.forEach(columns => {
this.div(...columns.map((r, i) => {
return {
text: r.trim(),
padding: this.measurePadding(r),
width: i === 0 && columns.length > 1 ? leftColumnWidth : undefined,
};
}));
});
const row = this.rows[this.rows.length - 1];
/* c8 ignore start */
if (!row) {
throw new Error('no rows found');
}
/* c8 ignore stop */
return row;
}
colFromString(text) {
return {
text,
padding: this.measurePadding(text),
};
}
measurePadding(str) {
// measure padding without ansi escape codes
const noAnsi = stripAnsi(str);
const [right = '', left = ''] = [
noAnsi.match(/\s*$/)?.[0],
noAnsi.match(/^\s*/)?.[0],
];
return [0, right.length, 0, left.length];
}
toString() {
const lines = [];
this.rows.forEach(row => {
this.rowToString(row, lines);
});
// don't display any lines with the
// hidden flag set.
return lines
.filter(line => !line.hidden)
.map(line => line.text)
.join('\n');
}
rowToString(row, lines) {
this.rasterize(row).forEach((rrow, r) => {
let str = '';
rrow.forEach((col, c) => {
const column = row[c];
const { width } = column; // the width with padding.
const wrapWidth = this.negatePadding(column); // the width without padding.
let ts = col; // temporary string used during alignment/padding.
if (wrapWidth > stringWidth(col)) {
ts += ' '.repeat(wrapWidth - stringWidth(col));
}
// align the string within its column.
if (column.align && column.align !== 'left' && this.wrap) {
const fn = align[column.align];
ts = fn(ts.trim(), wrapWidth);
if (stringWidth(ts) < wrapWidth) {
/* c8 ignore start */
const w = width || 0;
/* c8 ignore stop */
ts += ' '.repeat(w - stringWidth(ts) - 1);
}
}
// apply border and padding to string.
const padding = column.padding || [0, 0, 0, 0];
if (padding[left]) {
str += ' '.repeat(padding[left]);
}
str += addBorder(column, ts, '| ');
str += ts;
str += addBorder(column, ts, ' |');
if (padding[right]) {
str += ' '.repeat(padding[right]);
}
// if prior row is span, try to render the
// current row on the prior line.
if (r === 0 && lines.length > 0) {
const lastLine = lines[lines.length - 1];
/* c8 ignore start */
if (!lastLine) {
throw new Error('last line not found');
}
/* c8 ignore stop */
str = this.renderInline(str, lastLine);
}
});
// remove trailing whitespace.
lines.push({
text: str.replace(/ +$/, ''),
span: row.span,
});
});
return lines;
}
// if the full 'source' can render in
// the target line, do so.
renderInline(source, previousLine) {
const match = source.match(/^ */);
/* c8 ignore start */
const leadingWhitespace = match ? match[0].length : 0;
/* c8 ignore stop */
const target = previousLine.text;
const targetTextWidth = stringWidth(target.trimEnd());
if (!previousLine.span) {
return source;
}
// if we're not applying wrapping logic,
// just always append to the span.
if (!this.wrap) {
previousLine.hidden = true;
return target + source;
}
if (leadingWhitespace < targetTextWidth) {
return source;
}
previousLine.hidden = true;
return (target.trimEnd() +
' '.repeat(leadingWhitespace - targetTextWidth) +
source.trimStart());
}
rasterize(row) {
const rrows = [];
const widths = this.columnWidths(row);
let wrapped;
// word wrap all columns, and create
// a data-structure that is easy to rasterize.
row.forEach((col, c) => {
// leave room for left and right padding.
col.width = widths[c];
if (this.wrap) {
wrapped = wrap(col.text, this.negatePadding(col), {
hard: true,
}).split('\n');
}
else {
wrapped = col.text.split('\n');
}
if (col.border) {
wrapped.unshift('.' + '-'.repeat(this.negatePadding(col) + 2) + '.');
wrapped.push("'" + '-'.repeat(this.negatePadding(col) + 2) + "'");
}
// add top and bottom padding.
if (col.padding) {
wrapped.unshift(...new Array(col.padding[top] || 0).fill(''));
wrapped.push(...new Array(col.padding[bottom] || 0).fill(''));
}
wrapped.forEach((str, r) => {
if (!rrows[r]) {
rrows.push([]);
}
/* c8 ignore start */
const rrow = rrows[r] ?? [];
/* c8 ignore stop */
for (let i = 0; i < c; i++) {
if (rrow[i] === undefined) {
rrow.push('');
}
}
rrow.push(str);
});
});
return rrows;
}
negatePadding(col) {
/* c8 ignore start */
let wrapWidth = col.width || 0;
/* c8 ignore stop */
if (col.padding) {
wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
}
if (col.border) {
wrapWidth -= 4;
}
return wrapWidth;
}
columnWidths(row) {
if (!this.wrap) {
return row.map(col => {
return col.width || stringWidth(col.text);
});
}
let unset = row.length;
let remainingWidth = this.width;
// column widths can be set in config.
const widths = row.map(col => {
if (col.width) {
unset--;
remainingWidth -= col.width;
return col.width;
}
return undefined;
});
// any unset widths should be calculated.
/* c8 ignore start */
const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
/* c8 ignore stop */
return widths.map((w, i) => {
if (w === undefined) {
/* c8 ignore start */
const col = row[i] ?? { text: '', padding: [] };
/* c8 ignore stop */
return Math.max(unsetWidth, _minWidth(col));
}
return w;
});
}
}
const addBorder = (col, ts, style) => {
if (col.border) {
if (/[.']-+[.']/.test(ts)) {
return '';
}
if (ts.trim().length !== 0) {
return style;
}
return ' ';
}
return '';
};
// calculates the minimum width of
// a column, based on padding preferences.
const _minWidth = (col) => {
const padding = col.padding || [];
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
if (col.border) {
return minWidth + 4;
}
return minWidth;
};
const getWindowWidth = () => {
/* c8 ignore start */
if (typeof process === 'object' &&
process.stdout &&
process.stdout.columns) {
return process.stdout.columns;
}
return 80;
};
/* c8 ignore stop */
export const cliui = (opts = {}) => new UI({
/* c8 ignore start */
width: opts?.width || getWindowWidth(),
wrap: opts?.wrap,
/* c8 ignore stop */
});
//# sourceMappingURL=index.js.map

1
node_modules/@isaacs/cliui/dist/esm/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

12
node_modules/@isaacs/cliui/dist/esm/index.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

7
node_modules/@isaacs/cliui/dist/esm/index.min.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

3
node_modules/@isaacs/cliui/dist/esm/package.json generated vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"type": "module"
}

View File

@@ -0,0 +1,5 @@
export type Options = {
ambiguousIsNarrow?: boolean;
};
export declare function stringWidth(str: string, options?: Options): number;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/string-width/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,OAAO,GAAG;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,OAAY,UAqD7D"}

View File

@@ -0,0 +1,46 @@
import { stripAnsi } from "../strip-ansi/index.js";
import { eastAsianWidth } from "../eastasianwidth/index.js";
import { emojiRegex } from "../emoji-regex/index.js";
export function stringWidth(str, options = {}) {
if (typeof str !== "string" || str.length === 0) {
return 0;
}
options = {
ambiguousIsNarrow: true,
...options,
};
str = stripAnsi(str);
if (str.length === 0) {
return 0;
}
str = str.replace(emojiRegex(), " ");
const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;
let width = 0;
for (const character of str) {
const codePoint = character.codePointAt(0);
// Ignore control characters
if (!codePoint ||
codePoint <= 0x1f ||
(codePoint >= 0x7f && codePoint <= 0x9f)) {
continue;
}
// Ignore combining characters
if (codePoint >= 0x300 && codePoint <= 0x36f) {
continue;
}
const code = eastAsianWidth(character);
switch (code) {
case "F":
case "W":
width += 2;
break;
case "A":
width += ambiguousCharacterWidth;
break;
default:
width += 1;
}
}
return width;
}
//# sourceMappingURL=index.js.map

View File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AG,cAAc,CAAC,SAAS,CAAC,CAAC;QACvC,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,GAAG,CAAC;YACT,KAAK,GAAG;gBACN,KAAK,IAAI,CAAC,CAAC;gBACX,MAAM;YACR,KAAK,GAAG;gBACN,KAAK,IAAI,uBAAuB,CAAC;gBACjC,MAAM;YACR;gBACE,KAAK,IAAI,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { stripAnsi } from \"../strip-ansi/index.js\";\nimport { eastAsianWidth } from \"../eastasianwidth/index.js\";\nimport { emojiRegex } from \"../emoji-regex/index.js\";\n\nexport type Options = {\n ambiguousIsNarrow?: boolean;\n};\n\nexport function stringWidth(str: string, options: Options = {}) {\n if (typeof str !== \"string\" || str.length === 0) {\n return 0;\n }\n\n options = {\n ambiguousIsNarrow: true,\n ...options,\n };\n\n str = stripAnsi(str);\n\n if (str.length === 0) {\n return 0;\n }\n\n str = str.replace(emojiRegex(), \" \");\n\n const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;\n let width = 0;\n\n for (const character of str) {\n const codePoint = character.codePointAt(0);\n\n // Ignore control characters\n if (\n !codePoint ||\n codePoint <= 0x1f ||\n (codePoint >= 0x7f && codePoint <= 0x9f)\n ) {\n continue;\n }\n\n // Ignore combining characters\n if (codePoint >= 0x300 && codePoint <= 0x36f) {\n continue;\n }\n\n const code = eastAsianWidth(character);\n switch (code) {\n case \"F\":\n case \"W\":\n width += 2;\n break;\n case \"A\":\n width += ambiguousCharacterWidth;\n break;\n default:\n width += 1;\n }\n }\n\n return width;\n}\n"]}

View File

@@ -0,0 +1,2 @@
export declare const stripAnsi: (str: string) => string;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/strip-ansi/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,WAA2B,CAAC"}

View File

@@ -0,0 +1,4 @@
import { ansiRegex } from "../ansi-regex/index.js";
const regex = ansiRegex();
export const stripAnsi = (str) => str.replace(regex, "");
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/strip-ansi/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,MAAM,KAAK,GAAG,SAAS,EAAE,CAAC;AAC1B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC","sourcesContent":["import { ansiRegex } from \"../ansi-regex/index.js\";\nconst regex = ansiRegex();\nexport const stripAnsi = (str: string) => str.replace(regex, \"\");\n"]}

View File

@@ -0,0 +1,7 @@
export type Options = {
trim?: boolean;
wordWrap?: boolean;
hard?: boolean;
};
export declare const wrap: (str: string, columns: number, options: Options) => string;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wrap-ansi/index.ts"],"names":[],"mappings":"AAuGA,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAuH7E,eAAO,MAAM,IAAI,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,EAAE,SAAS,OAAO,WAMpD,CAAC"}

172
node_modules/@isaacs/cliui/dist/esm/wrap-ansi/index.js generated vendored Normal file
View File

@@ -0,0 +1,172 @@
import { stringWidth } from "../string-width/index.js";
import { stripAnsi } from "../strip-ansi/index.js";
import { ansiStyles } from "../ansi-styles/index.js";
const ESCAPES = new Set(["\u001B", "\u009B"]);
const END_CODE = 39;
const ANSI_ESCAPE_BELL = "\u0007";
const ANSI_CSI = "[";
const ANSI_OSC = "]";
const ANSI_SGR_TERMINATOR = "m";
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
const wrapAnsiCode = (code) => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
const wrapAnsiHyperlink = (uri) => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${uri}${ANSI_ESCAPE_BELL}`;
// Calculate the length of words split on ' ', ignoring
// the extra characters added by ansi escape codes
const wordLengths = (str) => str.split(" ").map((character) => stringWidth(character));
// Wrap a long word across multiple rows
// Ansi escape codes do not count towards length
const wrapWord = (rows, word, columns) => {
const characters = [...word];
let isInsideEscape = false;
let isInsideLinkEscape = false;
let visible = stringWidth(stripAnsi(String(rows[rows.length - 1])));
for (const [index, character] of characters.entries()) {
const characterLength = stringWidth(character);
if (visible + characterLength <= columns) {
rows[rows.length - 1] += character;
}
else {
rows.push(character);
visible = 0;
}
if (ESCAPES.has(character)) {
isInsideEscape = true;
isInsideLinkEscape = characters
.slice(index + 1)
.join("")
.startsWith(ANSI_ESCAPE_LINK);
}
if (isInsideEscape) {
if (isInsideLinkEscape) {
if (character === ANSI_ESCAPE_BELL) {
isInsideEscape = false;
isInsideLinkEscape = false;
}
}
else if (character === ANSI_SGR_TERMINATOR) {
isInsideEscape = false;
}
continue;
}
visible += characterLength;
if (visible === columns && index < characters.length - 1) {
rows.push("");
visible = 0;
}
}
// It's possible that the last row we copy over is only
// ansi escape characters, handle this edge-case
if (!visible && String(rows[rows.length - 1]).length > 0 && rows.length > 1) {
rows[rows.length - 2] = String(rows[rows.length - 1]) + rows.pop();
}
};
// Trims spaces from a string ignoring invisible sequences
const stringVisibleTrimSpacesRight = (str) => {
const words = str.split(" ");
let last = words.length;
while (last > 0) {
if (stringWidth(String(words[last - 1])) > 0) {
break;
}
last--;
}
if (last === words.length) {
return str;
}
return words.slice(0, last).join(" ") + words.slice(last).join("");
};
const exec = (str, columns, options = {}) => {
if (options.trim !== false && str.trim() === "") {
return "";
}
let returnValue = "";
let escapeCode;
let escapeUrl;
const lengths = wordLengths(str);
let rows = [""];
for (const [index, word] of str.split(" ").entries()) {
if (options.trim !== false) {
rows[rows.length - 1] = String(rows[rows.length - 1]).trimStart();
}
let rowLength = stringWidth(String(rows[rows.length - 1]));
if (index !== 0) {
if (rowLength >= columns &&
(options.wordWrap === false || options.trim === false)) {
// If we start with a new word but the current row length equals the length of the columns, add a new row
rows.push("");
rowLength = 0;
}
if (rowLength > 0 || options.trim === false) {
rows[rows.length - 1] += " ";
rowLength++;
}
}
// In 'hard' wrap mode, the length of a line is never allowed to extend past 'columns'
const len = Number(lengths[index]);
if (options.hard && len > columns) {
const remainingColumns = columns - rowLength;
const breaksStartingThisLine = 1 + Math.floor((len - remainingColumns - 1) / columns);
const breaksStartingNextLine = Math.floor((len - 1) / columns);
if (breaksStartingNextLine < breaksStartingThisLine) {
rows.push("");
}
wrapWord(rows, word, columns);
continue;
}
if (rowLength + len > columns && rowLength > 0 && len > 0) {
if (options.wordWrap === false && rowLength < columns) {
wrapWord(rows, word, columns);
continue;
}
rows.push("");
}
if (rowLength + len > columns && options.wordWrap === false) {
wrapWord(rows, word, columns);
continue;
}
rows[rows.length - 1] += word;
}
if (options.trim !== false) {
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
}
const pre = [...rows.join("\n")];
for (const [index, character] of pre.entries()) {
returnValue += character;
if (ESCAPES.has(character)) {
const { groups } = (new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(pre.slice(index).join("")) || { groups: {} });
if (groups.code !== undefined) {
const code = Number.parseFloat(groups.code);
escapeCode = code === END_CODE ? undefined : code;
}
else if (groups.uri !== undefined) {
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
}
}
const code = ansiStyles.codes.get(Number(escapeCode));
if (pre[index + 1] === "\n") {
if (escapeUrl) {
returnValue += wrapAnsiHyperlink("");
}
if (escapeCode && code) {
returnValue += wrapAnsiCode(code);
}
}
else if (character === "\n") {
if (escapeCode && code) {
returnValue += wrapAnsiCode(escapeCode);
}
if (escapeUrl) {
returnValue += wrapAnsiHyperlink(escapeUrl);
}
}
}
return returnValue;
};
// For each newline, invoke the method separately
export const wrap = (str, columns, options) => String(str)
.normalize()
.replace(/\r\n/g, "\n")
.split("\n")
.map((line) => exec(line, columns, options))
.join("\n");
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

163
node_modules/@isaacs/cliui/package.json generated vendored Normal file
View File

@@ -0,0 +1,163 @@
{
"name": "@isaacs/cliui",
"version": "9.0.0",
"description": "easily create complex multi-column command-line-interfaces",
"type": "module",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/commonjs/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
},
"./ansi-regex": {
"import": {
"types": "./dist/esm/ansi-regex/index.d.ts",
"default": "./dist/esm/ansi-regex/index.js"
},
"require": {
"types": "./dist/commonjs/ansi-regex/index.d.ts",
"default": "./dist/commonjs/ansi-regex/index.js"
}
},
"./ansi-styles": {
"import": {
"types": "./dist/esm/ansi-styles/index.d.ts",
"default": "./dist/esm/ansi-styles/index.js"
},
"require": {
"types": "./dist/commonjs/ansi-styles/index.d.ts",
"default": "./dist/commonjs/ansi-styles/index.js"
}
},
"./eastasianwidth": {
"import": {
"types": "./dist/esm/eastasianwidth/index.d.ts",
"default": "./dist/esm/eastasianwidth/index.js"
},
"require": {
"types": "./dist/commonjs/eastasianwidth/index.d.ts",
"default": "./dist/commonjs/eastasianwidth/index.js"
}
},
"./emoji-regex": {
"import": {
"types": "./dist/esm/emoji-regex/index.d.ts",
"default": "./dist/esm/emoji-regex/index.js"
},
"require": {
"types": "./dist/commonjs/emoji-regex/index.d.ts",
"default": "./dist/commonjs/emoji-regex/index.js"
}
},
"./string-width": {
"import": {
"types": "./dist/esm/string-width/index.d.ts",
"default": "./dist/esm/string-width/index.js"
},
"require": {
"types": "./dist/commonjs/string-width/index.d.ts",
"default": "./dist/commonjs/string-width/index.js"
}
},
"./strip-ansi": {
"import": {
"types": "./dist/esm/strip-ansi/index.d.ts",
"default": "./dist/esm/strip-ansi/index.js"
},
"require": {
"types": "./dist/commonjs/strip-ansi/index.d.ts",
"default": "./dist/commonjs/strip-ansi/index.js"
}
},
"./wrap-ansi": {
"import": {
"types": "./dist/esm/wrap-ansi/index.d.ts",
"default": "./dist/esm/wrap-ansi/index.js"
},
"require": {
"types": "./dist/commonjs/wrap-ansi/index.d.ts",
"default": "./dist/commonjs/wrap-ansi/index.js"
}
},
"./min": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.min.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.min.js"
}
}
},
"scripts": {
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
"prepare": "tshy && bash build.sh",
"pretest": "npm run prepare",
"presnap": "npm run prepare",
"test": "tap",
"snap": "tap",
"format": "prettier --write . --log-level warn",
"typedoc": "typedoc"
},
"repository": "git+ssh://git@github.com:isaacs/cliui",
"keywords": [
"cli",
"command-line",
"layout",
"design",
"console",
"wrap",
"table"
],
"license": "BlueOak-1.0.0",
"devDependencies": {
"@types/node": "^25.2.1",
"esbuild": "^0.27.2",
"prettier": "^3.8.1",
"tap": "^21.5.0",
"tshy": "^3.1.0",
"typedoc": "^0.28.16"
},
"files": [
"dist"
],
"engines": {
"node": ">=18"
},
"tshy": {
"selfLink": false,
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts",
"./ansi-regex": "./src/ansi-regex/index.ts",
"./ansi-styles": "./src/ansi-styles/index.ts",
"./eastasianwidth": "./src/eastasianwidth/index.ts",
"./emoji-regex": "./src/emoji-regex/index.ts",
"./string-width": "./src/string-width/index.ts",
"./strip-ansi": "./src/strip-ansi/index.ts",
"./wrap-ansi": "./src/wrap-ansi/index.ts",
"./min": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.min.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.min.js"
}
}
}
}
}

15
node_modules/@isaacs/fs-minipass/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

71
node_modules/@isaacs/fs-minipass/README.md generated vendored Normal file
View File

@@ -0,0 +1,71 @@
# fs-minipass
Filesystem streams based on [minipass](http://npm.im/minipass).
4 classes are exported:
- ReadStream
- ReadStreamSync
- WriteStream
- WriteStreamSync
When using `ReadStreamSync`, all of the data is made available
immediately upon consuming the stream. Nothing is buffered in memory
when the stream is constructed. If the stream is piped to a writer,
then it will synchronously `read()` and emit data into the writer as
fast as the writer can consume it. (That is, it will respect
backpressure.) If you call `stream.read()` then it will read the
entire file and return the contents.
When using `WriteStreamSync`, every write is flushed to the file
synchronously. If your writes all come in a single tick, then it'll
write it all out in a single tick. It's as synchronous as you are.
The async versions work much like their node builtin counterparts,
with the exception of introducing significantly less Stream machinery
overhead.
## USAGE
It's just streams, you pipe them or read() them or write() to them.
```js
import { ReadStream, WriteStream } from 'fs-minipass'
// or: const { ReadStream, WriteStream } = require('fs-minipass')
const readStream = new ReadStream('file.txt')
const writeStream = new WriteStream('output.txt')
writeStream.write('some file header or whatever\n')
readStream.pipe(writeStream)
```
## ReadStream(path, options)
Path string is required, but somewhat irrelevant if an open file
descriptor is passed in as an option.
Options:
- `fd` Pass in a numeric file descriptor, if the file is already open.
- `readSize` The size of reads to do, defaults to 16MB
- `size` The size of the file, if known. Prevents zero-byte read()
call at the end.
- `autoClose` Set to `false` to prevent the file descriptor from being
closed when the file is done being read.
## WriteStream(path, options)
Path string is required, but somewhat irrelevant if an open file
descriptor is passed in as an option.
Options:
- `fd` Pass in a numeric file descriptor, if the file is already open.
- `mode` The mode to create the file with. Defaults to `0o666`.
- `start` The position in the file to start reading. If not
specified, then the file will start writing at position zero, and be
truncated by default.
- `autoClose` Set to `false` to prevent the file descriptor from being
closed when the stream is ended.
- `flags` Flags to use when opening the file. Irrelevant if `fd` is
passed in, since file won't be opened in that case. Defaults to
`'a'` if a `pos` is specified, or `'w'` otherwise.

View File

@@ -0,0 +1,118 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import EE from 'events';
import { Minipass } from 'minipass';
declare const _autoClose: unique symbol;
declare const _close: unique symbol;
declare const _ended: unique symbol;
declare const _fd: unique symbol;
declare const _finished: unique symbol;
declare const _flags: unique symbol;
declare const _flush: unique symbol;
declare const _handleChunk: unique symbol;
declare const _makeBuf: unique symbol;
declare const _mode: unique symbol;
declare const _needDrain: unique symbol;
declare const _onerror: unique symbol;
declare const _onopen: unique symbol;
declare const _onread: unique symbol;
declare const _onwrite: unique symbol;
declare const _open: unique symbol;
declare const _path: unique symbol;
declare const _pos: unique symbol;
declare const _queue: unique symbol;
declare const _read: unique symbol;
declare const _readSize: unique symbol;
declare const _reading: unique symbol;
declare const _remain: unique symbol;
declare const _size: unique symbol;
declare const _write: unique symbol;
declare const _writing: unique symbol;
declare const _defaultFlag: unique symbol;
declare const _errored: unique symbol;
export type ReadStreamOptions = Minipass.Options<Minipass.ContiguousData> & {
fd?: number;
readSize?: number;
size?: number;
autoClose?: boolean;
};
export type ReadStreamEvents = Minipass.Events<Minipass.ContiguousData> & {
open: [fd: number];
};
export declare class ReadStream extends Minipass<Minipass.ContiguousData, Buffer, ReadStreamEvents> {
[_errored]: boolean;
[_fd]?: number;
[_path]: string;
[_readSize]: number;
[_reading]: boolean;
[_size]: number;
[_remain]: number;
[_autoClose]: boolean;
constructor(path: string, opt: ReadStreamOptions);
get fd(): number | undefined;
get path(): string;
write(): void;
end(): void;
[_open](): void;
[_onopen](er?: NodeJS.ErrnoException | null, fd?: number): void;
[_makeBuf](): Buffer;
[_read](): void;
[_onread](er?: NodeJS.ErrnoException | null, br?: number, buf?: Buffer): void;
[_close](): void;
[_onerror](er: NodeJS.ErrnoException): void;
[_handleChunk](br: number, buf: Buffer): boolean;
emit<Event extends keyof ReadStreamEvents>(ev: Event, ...args: ReadStreamEvents[Event]): boolean;
}
export declare class ReadStreamSync extends ReadStream {
[_open](): void;
[_read](): void;
[_close](): void;
}
export type WriteStreamOptions = {
fd?: number;
autoClose?: boolean;
mode?: number;
captureRejections?: boolean;
start?: number;
flags?: string;
};
export declare class WriteStream extends EE {
readable: false;
writable: boolean;
[_errored]: boolean;
[_writing]: boolean;
[_ended]: boolean;
[_queue]: Buffer[];
[_needDrain]: boolean;
[_path]: string;
[_mode]: number;
[_autoClose]: boolean;
[_fd]?: number;
[_defaultFlag]: boolean;
[_flags]: string;
[_finished]: boolean;
[_pos]?: number;
constructor(path: string, opt: WriteStreamOptions);
emit(ev: string, ...args: any[]): boolean;
get fd(): number | undefined;
get path(): string;
[_onerror](er: NodeJS.ErrnoException): void;
[_open](): void;
[_onopen](er?: null | NodeJS.ErrnoException, fd?: number): void;
end(buf: string, enc?: BufferEncoding): this;
end(buf?: Buffer, enc?: undefined): this;
write(buf: string, enc?: BufferEncoding): boolean;
write(buf: Buffer, enc?: undefined): boolean;
[_write](buf: Buffer): void;
[_onwrite](er?: null | NodeJS.ErrnoException, bw?: number): void;
[_flush](): void;
[_close](): void;
}
export declare class WriteStreamSync extends WriteStream {
[_open](): void;
[_close](): void;
[_write](buf: Buffer): void;
}
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAInC,QAAA,MAAM,UAAU,eAAuB,CAAA;AACvC,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,GAAG,eAAgB,CAAA;AACzB,QAAA,MAAM,SAAS,eAAsB,CAAA;AACrC,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,YAAY,eAAyB,CAAA;AAC3C,QAAA,MAAM,QAAQ,eAAqB,CAAA;AACnC,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,UAAU,eAAuB,CAAA;AACvC,QAAA,MAAM,QAAQ,eAAqB,CAAA;AACnC,QAAA,MAAM,OAAO,eAAoB,CAAA;AACjC,QAAA,MAAM,OAAO,eAAoB,CAAA;AACjC,QAAA,MAAM,QAAQ,eAAqB,CAAA;AACnC,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,IAAI,eAAiB,CAAA;AAC3B,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,SAAS,eAAsB,CAAA;AACrC,QAAA,MAAM,QAA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EAAE,EAAE,CAAC,EAAE,MAAM;IAwBzD,CAAC,MAAM,CAAC;IAgBR,CAAC,MAAM,CAAC;CAST;AAED,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,CAAC,KAAK,CAAC,IAAI,IAAI;IAsBf,CAAC,MAAM,CAAC;IASR,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM;CAmBrB"}

430
node_modules/@isaacs/fs-minipass/dist/commonjs/index.js generated vendored Normal file
View File

@@ -0,0 +1,430 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WriteStreamSync = exports.WriteStream = exports.ReadStreamSync = exports.ReadStream = void 0;
const events_1 = __importDefault(require("events"));
const fs_1 = __importDefault(require("fs"));
const minipass_1 = require("minipass");
const writev = fs_1.default.writev;
const _autoClose = Symbol('_autoClose');
const _close = Symbol('_close');
const _ended = Symbol('_ended');
const _fd = Symbol('_fd');
const _finished = Symbol('_finished');
const _flags = Symbol('_flags');
const _flush = Symbol('_flush');
const _handleChunk = Symbol('_handleChunk');
const _makeBuf = Symbol('_makeBuf');
const _mode = Symbol('_mode');
const _needDrain = Symbol('_needDrain');
const _onerror = Symbol('_onerror');
const _onopen = Symbol('_onopen');
const _onread = Symbol('_onread');
const _onwrite = Symbol('_onwrite');
const _open = Symbol('_open');
const _path = Symbol('_path');
const _pos = Symbol('_pos');
const _queue = Symbol('_queue');
const _read = Symbol('_read');
const _readSize = Symbol('_readSize');
const _reading = Symbol('_reading');
const _remain = Symbol('_remain');
const _size = Symbol('_size');
const _write = Symbol('_write');
const _writing = Symbol('_writing');
const _defaultFlag = Symbol('_defaultFlag');
const _errored = Symbol('_errored');
class ReadStream extends minipass_1.Minipass {
[_errored] = false;
[_fd];
[_path];
[_readSize];
[_reading] = false;
[_size];
[_remain];
[_autoClose];
constructor(path, opt) {
opt = opt || {};
super(opt);
this.readable = true;
this.writable = false;
if (typeof path !== 'string') {
throw new TypeError('path must be a string');
}
this[_errored] = false;
this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined;
this[_path] = path;
this[_readSize] = opt.readSize || 16 * 1024 * 1024;
this[_reading] = false;
this[_size] = typeof opt.size === 'number' ? opt.size : Infinity;
this[_remain] = this[_size];
this[_autoClose] =
typeof opt.autoClose === 'boolean' ? opt.autoClose : true;
if (typeof this[_fd] === 'number') {
this[_read]();
}
else {
this[_open]();
}
}
get fd() {
return this[_fd];
}
get path() {
return this[_path];
}
//@ts-ignore
write() {
throw new TypeError('this is a readable stream');
}
//@ts-ignore
end() {
throw new TypeError('this is a readable stream');
}
[_open]() {
fs_1.default.open(this[_path], 'r', (er, fd) => this[_onopen](er, fd));
}
[_onopen](er, fd) {
if (er) {
this[_onerror](er);
}
else {
this[_fd] = fd;
this.emit('open', fd);
this[_read]();
}
}
[_makeBuf]() {
return Buffer.allocUnsafe(Math.min(this[_readSize], this[_remain]));
}
[_read]() {
if (!this[_reading]) {
this[_reading] = true;
const buf = this[_makeBuf]();
/* c8 ignore start */
if (buf.length === 0) {
return process.nextTick(() => this[_onread](null, 0, buf));
}
/* c8 ignore stop */
fs_1.default.read(this[_fd], buf, 0, buf.length, null, (er, br, b) => this[_onread](er, br, b));
}
}
[_onread](er, br, buf) {
this[_reading] = false;
if (er) {
this[_onerror](er);
}
else if (this[_handleChunk](br, buf)) {
this[_read]();
}
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs_1.default.close(fd, er => er ? this.emit('error', er) : this.emit('close'));
}
}
[_onerror](er) {
this[_reading] = true;
this[_close]();
this.emit('error', er);
}
[_handleChunk](br, buf) {
let ret = false;
// no effect if infinite
this[_remain] -= br;
if (br > 0) {
ret = super.write(br < buf.length ? buf.subarray(0, br) : buf);
}
if (br === 0 || this[_remain] <= 0) {
ret = false;
this[_close]();
super.end();
}
return ret;
}
emit(ev, ...args) {
switch (ev) {
case 'prefinish':
case 'finish':
return false;
case 'drain':
if (typeof this[_fd] === 'number') {
this[_read]();
}
return false;
case 'error':
if (this[_errored]) {
return false;
}
this[_errored] = true;
return super.emit(ev, ...args);
default:
return super.emit(ev, ...args);
}
}
}
exports.ReadStream = ReadStream;
class ReadStreamSync extends ReadStream {
[_open]() {
let threw = true;
try {
this[_onopen](null, fs_1.default.openSync(this[_path], 'r'));
threw = false;
}
finally {
if (threw) {
this[_close]();
}
}
}
[_read]() {
let threw = true;
try {
if (!this[_reading]) {
this[_reading] = true;
do {
const buf = this[_makeBuf]();
/* c8 ignore start */
const br = buf.length === 0
? 0
: fs_1.default.readSync(this[_fd], buf, 0, buf.length, null);
/* c8 ignore stop */
if (!this[_handleChunk](br, buf)) {
break;
}
} while (true);
this[_reading] = false;
}
threw = false;
}
finally {
if (threw) {
this[_close]();
}
}
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs_1.default.closeSync(fd);
this.emit('close');
}
}
}
exports.ReadStreamSync = ReadStreamSync;
class WriteStream extends events_1.default {
readable = false;
writable = true;
[_errored] = false;
[_writing] = false;
[_ended] = false;
[_queue] = [];
[_needDrain] = false;
[_path];
[_mode];
[_autoClose];
[_fd];
[_defaultFlag];
[_flags];
[_finished] = false;
[_pos];
constructor(path, opt) {
opt = opt || {};
super(opt);
this[_path] = path;
this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined;
this[_mode] = opt.mode === undefined ? 0o666 : opt.mode;
this[_pos] = typeof opt.start === 'number' ? opt.start : undefined;
this[_autoClose] =
typeof opt.autoClose === 'boolean' ? opt.autoClose : true;
// truncating makes no sense when writing into the middle
const defaultFlag = this[_pos] !== undefined ? 'r+' : 'w';
this[_defaultFlag] = opt.flags === undefined;
this[_flags] = opt.flags === undefined ? defaultFlag : opt.flags;
if (this[_fd] === undefined) {
this[_open]();
}
}
emit(ev, ...args) {
if (ev === 'error') {
if (this[_errored]) {
return false;
}
this[_errored] = true;
}
return super.emit(ev, ...args);
}
get fd() {
return this[_fd];
}
get path() {
return this[_path];
}
[_onerror](er) {
this[_close]();
this[_writing] = true;
this.emit('error', er);
}
[_open]() {
fs_1.default.open(this[_path], this[_flags], this[_mode], (er, fd) => this[_onopen](er, fd));
}
[_onopen](er, fd) {
if (this[_defaultFlag] &&
this[_flags] === 'r+' &&
er &&
er.code === 'ENOENT') {
this[_flags] = 'w';
this[_open]();
}
else if (er) {
this[_onerror](er);
}
else {
this[_fd] = fd;
this.emit('open', fd);
if (!this[_writing]) {
this[_flush]();
}
}
}
end(buf, enc) {
if (buf) {
//@ts-ignore
this.write(buf, enc);
}
this[_ended] = true;
// synthetic after-write logic, where drain/finish live
if (!this[_writing] &&
!this[_queue].length &&
typeof this[_fd] === 'number') {
this[_onwrite](null, 0);
}
return this;
}
write(buf, enc) {
if (typeof buf === 'string') {
buf = Buffer.from(buf, enc);
}
if (this[_ended]) {
this.emit('error', new Error('write() after end()'));
return false;
}
if (this[_fd] === undefined || this[_writing] || this[_queue].length) {
this[_queue].push(buf);
this[_needDrain] = true;
return false;
}
this[_writing] = true;
this[_write](buf);
return true;
}
[_write](buf) {
fs_1.default.write(this[_fd], buf, 0, buf.length, this[_pos], (er, bw) => this[_onwrite](er, bw));
}
[_onwrite](er, bw) {
if (er) {
this[_onerror](er);
}
else {
if (this[_pos] !== undefined && typeof bw === 'number') {
this[_pos] += bw;
}
if (this[_queue].length) {
this[_flush]();
}
else {
this[_writing] = false;
if (this[_ended] && !this[_finished]) {
this[_finished] = true;
this[_close]();
this.emit('finish');
}
else if (this[_needDrain]) {
this[_needDrain] = false;
this.emit('drain');
}
}
}
}
[_flush]() {
if (this[_queue].length === 0) {
if (this[_ended]) {
this[_onwrite](null, 0);
}
}
else if (this[_queue].length === 1) {
this[_write](this[_queue].pop());
}
else {
const iovec = this[_queue];
this[_queue] = [];
writev(this[_fd], iovec, this[_pos], (er, bw) => this[_onwrite](er, bw));
}
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs_1.default.close(fd, er => er ? this.emit('error', er) : this.emit('close'));
}
}
}
exports.WriteStream = WriteStream;
class WriteStreamSync extends WriteStream {
[_open]() {
let fd;
// only wrap in a try{} block if we know we'll retry, to avoid
// the rethrow obscuring the error's source frame in most cases.
if (this[_defaultFlag] && this[_flags] === 'r+') {
try {
fd = fs_1.default.openSync(this[_path], this[_flags], this[_mode]);
}
catch (er) {
if (er?.code === 'ENOENT') {
this[_flags] = 'w';
return this[_open]();
}
else {
throw er;
}
}
}
else {
fd = fs_1.default.openSync(this[_path], this[_flags], this[_mode]);
}
this[_onopen](null, fd);
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs_1.default.closeSync(fd);
this.emit('close');
}
}
[_write](buf) {
// throw the original, but try to close if it fails
let threw = true;
try {
this[_onwrite](null, fs_1.default.writeSync(this[_fd], buf, 0, buf.length, this[_pos]));
threw = false;
}
finally {
if (threw) {
try {
this[_close]();
}
catch {
// ok error
}
}
}
}
}
exports.WriteStreamSync = WriteStreamSync;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
{
"type": "commonjs"
}

118
node_modules/@isaacs/fs-minipass/dist/esm/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,118 @@
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import EE from 'events';
import { Minipass } from 'minipass';
declare const _autoClose: unique symbol;
declare const _close: unique symbol;
declare const _ended: unique symbol;
declare const _fd: unique symbol;
declare const _finished: unique symbol;
declare const _flags: unique symbol;
declare const _flush: unique symbol;
declare const _handleChunk: unique symbol;
declare const _makeBuf: unique symbol;
declare const _mode: unique symbol;
declare const _needDrain: unique symbol;
declare const _onerror: unique symbol;
declare const _onopen: unique symbol;
declare const _onread: unique symbol;
declare const _onwrite: unique symbol;
declare const _open: unique symbol;
declare const _path: unique symbol;
declare const _pos: unique symbol;
declare const _queue: unique symbol;
declare const _read: unique symbol;
declare const _readSize: unique symbol;
declare const _reading: unique symbol;
declare const _remain: unique symbol;
declare const _size: unique symbol;
declare const _write: unique symbol;
declare const _writing: unique symbol;
declare const _defaultFlag: unique symbol;
declare const _errored: unique symbol;
export type ReadStreamOptions = Minipass.Options<Minipass.ContiguousData> & {
fd?: number;
readSize?: number;
size?: number;
autoClose?: boolean;
};
export type ReadStreamEvents = Minipass.Events<Minipass.ContiguousData> & {
open: [fd: number];
};
export declare class ReadStream extends Minipass<Minipass.ContiguousData, Buffer, ReadStreamEvents> {
[_errored]: boolean;
[_fd]?: number;
[_path]: string;
[_readSize]: number;
[_reading]: boolean;
[_size]: number;
[_remain]: number;
[_autoClose]: boolean;
constructor(path: string, opt: ReadStreamOptions);
get fd(): number | undefined;
get path(): string;
write(): void;
end(): void;
[_open](): void;
[_onopen](er?: NodeJS.ErrnoException | null, fd?: number): void;
[_makeBuf](): Buffer;
[_read](): void;
[_onread](er?: NodeJS.ErrnoException | null, br?: number, buf?: Buffer): void;
[_close](): void;
[_onerror](er: NodeJS.ErrnoException): void;
[_handleChunk](br: number, buf: Buffer): boolean;
emit<Event extends keyof ReadStreamEvents>(ev: Event, ...args: ReadStreamEvents[Event]): boolean;
}
export declare class ReadStreamSync extends ReadStream {
[_open](): void;
[_read](): void;
[_close](): void;
}
export type WriteStreamOptions = {
fd?: number;
autoClose?: boolean;
mode?: number;
captureRejections?: boolean;
start?: number;
flags?: string;
};
export declare class WriteStream extends EE {
readable: false;
writable: boolean;
[_errored]: boolean;
[_writing]: boolean;
[_ended]: boolean;
[_queue]: Buffer[];
[_needDrain]: boolean;
[_path]: string;
[_mode]: number;
[_autoClose]: boolean;
[_fd]?: number;
[_defaultFlag]: boolean;
[_flags]: string;
[_finished]: boolean;
[_pos]?: number;
constructor(path: string, opt: WriteStreamOptions);
emit(ev: string, ...args: any[]): boolean;
get fd(): number | undefined;
get path(): string;
[_onerror](er: NodeJS.ErrnoException): void;
[_open](): void;
[_onopen](er?: null | NodeJS.ErrnoException, fd?: number): void;
end(buf: string, enc?: BufferEncoding): this;
end(buf?: Buffer, enc?: undefined): this;
write(buf: string, enc?: BufferEncoding): boolean;
write(buf: Buffer, enc?: undefined): boolean;
[_write](buf: Buffer): void;
[_onwrite](er?: null | NodeJS.ErrnoException, bw?: number): void;
[_flush](): void;
[_close](): void;
}
export declare class WriteStreamSync extends WriteStream {
[_open](): void;
[_close](): void;
[_write](buf: Buffer): void;
}
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAInC,QAAA,MAAM,UAAU,eAAuB,CAAA;AACvC,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,GAAG,eAAgB,CAAA;AACzB,QAAA,MAAM,SAAS,eAAsB,CAAA;AACrC,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,YAAY,eAAyB,CAAA;AAC3C,QAAA,MAAM,QAAQ,eAAqB,CAAA;AACnC,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,UAAU,eAAuB,CAAA;AACvC,QAAA,MAAM,QAAQ,eAAqB,CAAA;AACnC,QAAA,MAAM,OAAO,eAAoB,CAAA;AACjC,QAAA,MAAM,OAAO,eAAoB,CAAA;AACjC,QAAA,MAAM,QAAQ,eAAqB,CAAA;AACnC,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,IAAI,eAAi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S,GAAG,OAAO;IAsB5C,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM;IAWpB,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,cAAc,EAAE,EAAE,CAAC,EAAE,MAAM;IAwBzD,CAAC,MAAM,CAAC;IAgBR,CAAC,MAAM,CAAC;CAST;AAED,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,CAAC,KAAK,CAAC,IAAI,IAAI;IAsBf,CAAC,MAAM,CAAC;IASR,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM;CAmBrB"}

420
node_modules/@isaacs/fs-minipass/dist/esm/index.js generated vendored Normal file
View File

@@ -0,0 +1,420 @@
import EE from 'events';
import fs from 'fs';
import { Minipass } from 'minipass';
const writev = fs.writev;
const _autoClose = Symbol('_autoClose');
const _close = Symbol('_close');
const _ended = Symbol('_ended');
const _fd = Symbol('_fd');
const _finished = Symbol('_finished');
const _flags = Symbol('_flags');
const _flush = Symbol('_flush');
const _handleChunk = Symbol('_handleChunk');
const _makeBuf = Symbol('_makeBuf');
const _mode = Symbol('_mode');
const _needDrain = Symbol('_needDrain');
const _onerror = Symbol('_onerror');
const _onopen = Symbol('_onopen');
const _onread = Symbol('_onread');
const _onwrite = Symbol('_onwrite');
const _open = Symbol('_open');
const _path = Symbol('_path');
const _pos = Symbol('_pos');
const _queue = Symbol('_queue');
const _read = Symbol('_read');
const _readSize = Symbol('_readSize');
const _reading = Symbol('_reading');
const _remain = Symbol('_remain');
const _size = Symbol('_size');
const _write = Symbol('_write');
const _writing = Symbol('_writing');
const _defaultFlag = Symbol('_defaultFlag');
const _errored = Symbol('_errored');
export class ReadStream extends Minipass {
[_errored] = false;
[_fd];
[_path];
[_readSize];
[_reading] = false;
[_size];
[_remain];
[_autoClose];
constructor(path, opt) {
opt = opt || {};
super(opt);
this.readable = true;
this.writable = false;
if (typeof path !== 'string') {
throw new TypeError('path must be a string');
}
this[_errored] = false;
this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined;
this[_path] = path;
this[_readSize] = opt.readSize || 16 * 1024 * 1024;
this[_reading] = false;
this[_size] = typeof opt.size === 'number' ? opt.size : Infinity;
this[_remain] = this[_size];
this[_autoClose] =
typeof opt.autoClose === 'boolean' ? opt.autoClose : true;
if (typeof this[_fd] === 'number') {
this[_read]();
}
else {
this[_open]();
}
}
get fd() {
return this[_fd];
}
get path() {
return this[_path];
}
//@ts-ignore
write() {
throw new TypeError('this is a readable stream');
}
//@ts-ignore
end() {
throw new TypeError('this is a readable stream');
}
[_open]() {
fs.open(this[_path], 'r', (er, fd) => this[_onopen](er, fd));
}
[_onopen](er, fd) {
if (er) {
this[_onerror](er);
}
else {
this[_fd] = fd;
this.emit('open', fd);
this[_read]();
}
}
[_makeBuf]() {
return Buffer.allocUnsafe(Math.min(this[_readSize], this[_remain]));
}
[_read]() {
if (!this[_reading]) {
this[_reading] = true;
const buf = this[_makeBuf]();
/* c8 ignore start */
if (buf.length === 0) {
return process.nextTick(() => this[_onread](null, 0, buf));
}
/* c8 ignore stop */
fs.read(this[_fd], buf, 0, buf.length, null, (er, br, b) => this[_onread](er, br, b));
}
}
[_onread](er, br, buf) {
this[_reading] = false;
if (er) {
this[_onerror](er);
}
else if (this[_handleChunk](br, buf)) {
this[_read]();
}
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs.close(fd, er => er ? this.emit('error', er) : this.emit('close'));
}
}
[_onerror](er) {
this[_reading] = true;
this[_close]();
this.emit('error', er);
}
[_handleChunk](br, buf) {
let ret = false;
// no effect if infinite
this[_remain] -= br;
if (br > 0) {
ret = super.write(br < buf.length ? buf.subarray(0, br) : buf);
}
if (br === 0 || this[_remain] <= 0) {
ret = false;
this[_close]();
super.end();
}
return ret;
}
emit(ev, ...args) {
switch (ev) {
case 'prefinish':
case 'finish':
return false;
case 'drain':
if (typeof this[_fd] === 'number') {
this[_read]();
}
return false;
case 'error':
if (this[_errored]) {
return false;
}
this[_errored] = true;
return super.emit(ev, ...args);
default:
return super.emit(ev, ...args);
}
}
}
export class ReadStreamSync extends ReadStream {
[_open]() {
let threw = true;
try {
this[_onopen](null, fs.openSync(this[_path], 'r'));
threw = false;
}
finally {
if (threw) {
this[_close]();
}
}
}
[_read]() {
let threw = true;
try {
if (!this[_reading]) {
this[_reading] = true;
do {
const buf = this[_makeBuf]();
/* c8 ignore start */
const br = buf.length === 0
? 0
: fs.readSync(this[_fd], buf, 0, buf.length, null);
/* c8 ignore stop */
if (!this[_handleChunk](br, buf)) {
break;
}
} while (true);
this[_reading] = false;
}
threw = false;
}
finally {
if (threw) {
this[_close]();
}
}
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs.closeSync(fd);
this.emit('close');
}
}
}
export class WriteStream extends EE {
readable = false;
writable = true;
[_errored] = false;
[_writing] = false;
[_ended] = false;
[_queue] = [];
[_needDrain] = false;
[_path];
[_mode];
[_autoClose];
[_fd];
[_defaultFlag];
[_flags];
[_finished] = false;
[_pos];
constructor(path, opt) {
opt = opt || {};
super(opt);
this[_path] = path;
this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined;
this[_mode] = opt.mode === undefined ? 0o666 : opt.mode;
this[_pos] = typeof opt.start === 'number' ? opt.start : undefined;
this[_autoClose] =
typeof opt.autoClose === 'boolean' ? opt.autoClose : true;
// truncating makes no sense when writing into the middle
const defaultFlag = this[_pos] !== undefined ? 'r+' : 'w';
this[_defaultFlag] = opt.flags === undefined;
this[_flags] = opt.flags === undefined ? defaultFlag : opt.flags;
if (this[_fd] === undefined) {
this[_open]();
}
}
emit(ev, ...args) {
if (ev === 'error') {
if (this[_errored]) {
return false;
}
this[_errored] = true;
}
return super.emit(ev, ...args);
}
get fd() {
return this[_fd];
}
get path() {
return this[_path];
}
[_onerror](er) {
this[_close]();
this[_writing] = true;
this.emit('error', er);
}
[_open]() {
fs.open(this[_path], this[_flags], this[_mode], (er, fd) => this[_onopen](er, fd));
}
[_onopen](er, fd) {
if (this[_defaultFlag] &&
this[_flags] === 'r+' &&
er &&
er.code === 'ENOENT') {
this[_flags] = 'w';
this[_open]();
}
else if (er) {
this[_onerror](er);
}
else {
this[_fd] = fd;
this.emit('open', fd);
if (!this[_writing]) {
this[_flush]();
}
}
}
end(buf, enc) {
if (buf) {
//@ts-ignore
this.write(buf, enc);
}
this[_ended] = true;
// synthetic after-write logic, where drain/finish live
if (!this[_writing] &&
!this[_queue].length &&
typeof this[_fd] === 'number') {
this[_onwrite](null, 0);
}
return this;
}
write(buf, enc) {
if (typeof buf === 'string') {
buf = Buffer.from(buf, enc);
}
if (this[_ended]) {
this.emit('error', new Error('write() after end()'));
return false;
}
if (this[_fd] === undefined || this[_writing] || this[_queue].length) {
this[_queue].push(buf);
this[_needDrain] = true;
return false;
}
this[_writing] = true;
this[_write](buf);
return true;
}
[_write](buf) {
fs.write(this[_fd], buf, 0, buf.length, this[_pos], (er, bw) => this[_onwrite](er, bw));
}
[_onwrite](er, bw) {
if (er) {
this[_onerror](er);
}
else {
if (this[_pos] !== undefined && typeof bw === 'number') {
this[_pos] += bw;
}
if (this[_queue].length) {
this[_flush]();
}
else {
this[_writing] = false;
if (this[_ended] && !this[_finished]) {
this[_finished] = true;
this[_close]();
this.emit('finish');
}
else if (this[_needDrain]) {
this[_needDrain] = false;
this.emit('drain');
}
}
}
}
[_flush]() {
if (this[_queue].length === 0) {
if (this[_ended]) {
this[_onwrite](null, 0);
}
}
else if (this[_queue].length === 1) {
this[_write](this[_queue].pop());
}
else {
const iovec = this[_queue];
this[_queue] = [];
writev(this[_fd], iovec, this[_pos], (er, bw) => this[_onwrite](er, bw));
}
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs.close(fd, er => er ? this.emit('error', er) : this.emit('close'));
}
}
}
export class WriteStreamSync extends WriteStream {
[_open]() {
let fd;
// only wrap in a try{} block if we know we'll retry, to avoid
// the rethrow obscuring the error's source frame in most cases.
if (this[_defaultFlag] && this[_flags] === 'r+') {
try {
fd = fs.openSync(this[_path], this[_flags], this[_mode]);
}
catch (er) {
if (er?.code === 'ENOENT') {
this[_flags] = 'w';
return this[_open]();
}
else {
throw er;
}
}
}
else {
fd = fs.openSync(this[_path], this[_flags], this[_mode]);
}
this[_onopen](null, fd);
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs.closeSync(fd);
this.emit('close');
}
}
[_write](buf) {
// throw the original, but try to close if it fails
let threw = true;
try {
this[_onwrite](null, fs.writeSync(this[_fd], buf, 0, buf.length, this[_pos]));
threw = false;
}
finally {
if (threw) {
try {
this[_close]();
}
catch {
// ok error
}
}
}
}
}
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
{
"type": "module"
}

72
node_modules/@isaacs/fs-minipass/package.json generated vendored Normal file
View File

@@ -0,0 +1,72 @@
{
"name": "@isaacs/fs-minipass",
"version": "4.0.1",
"main": "./dist/commonjs/index.js",
"scripts": {
"prepare": "tshy",
"pretest": "npm run prepare",
"test": "tap",
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
"format": "prettier --write . --loglevel warn",
"typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts"
},
"keywords": [],
"author": "Isaac Z. Schlueter",
"license": "ISC",
"repository": {
"type": "git",
"url": "https://github.com/npm/fs-minipass.git"
},
"description": "fs read and write streams based on minipass",
"dependencies": {
"minipass": "^7.0.4"
},
"devDependencies": {
"@types/node": "^20.11.30",
"mutate-fs": "^2.1.1",
"prettier": "^3.2.5",
"tap": "^18.7.1",
"tshy": "^1.12.0",
"typedoc": "^0.25.12"
},
"files": [
"dist"
],
"engines": {
"node": ">=18.0.0"
},
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
},
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"types": "./dist/commonjs/index.d.ts",
"type": "module",
"prettier": {
"semi": false,
"printWidth": 75,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"jsxSingleQuote": false,
"bracketSameLine": true,
"arrowParens": "avoid",
"endOfLine": "lf"
}
}