sandbox 2.0.0-alpha5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +18 -12
- package/README.md +18 -93
- package/bin/sandbox.mjs +3 -0
- package/dist/ansi-styles-B57ln_zO.mjs +168 -0
- package/dist/ansi-styles-B57ln_zO.mjs.map +1 -0
- package/dist/app-BQds8e4O.mjs +14168 -0
- package/dist/app-BQds8e4O.mjs.map +1 -0
- package/dist/chunk-btbCw1m3.mjs +52 -0
- package/dist/cli-cursor-Dab4mDU2.mjs +348 -0
- package/dist/cli-cursor-Dab4mDU2.mjs.map +1 -0
- package/dist/cli-truncate-DMIDACmY.mjs +124 -0
- package/dist/cli-truncate-DMIDACmY.mjs.map +1 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.mjs +17 -0
- package/dist/index.mjs.map +1 -0
- package/dist/log-update-txb7Or7B.mjs +223 -0
- package/dist/log-update-txb7Or7B.mjs.map +1 -0
- package/dist/pty-server-linux-x86_64 +0 -0
- package/dist/sandbox.d.mts +1 -0
- package/dist/sandbox.mjs +647 -0
- package/dist/sandbox.mjs.map +1 -0
- package/dist/string-width-D78SVDLD.mjs +85 -0
- package/dist/string-width-D78SVDLD.mjs.map +1 -0
- package/dist/token-Bwtve9Y6.mjs +51 -0
- package/dist/token-Bwtve9Y6.mjs.map +1 -0
- package/dist/token-error-C0CafU2G.mjs +43 -0
- package/dist/token-error-C0CafU2G.mjs.map +1 -0
- package/dist/token-util-BpWskZEO.mjs +357 -0
- package/dist/token-util-BpWskZEO.mjs.map +1 -0
- package/dist/token-util-CRAtcwBI.mjs +6 -0
- package/dist/wrap-ansi-CEi7ZT5i.mjs +5 -0
- package/dist/wrap-ansi-DoQ74EEn.mjs +130 -0
- package/dist/wrap-ansi-DoQ74EEn.mjs.map +1 -0
- package/package.json +52 -31
- package/index.js +0 -29
- package/install.js +0 -5
- package/platform-target.js +0 -217
package/LICENSE
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2025 Vercel
|
|
4
4
|
|
|
5
|
-
Permission
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,106 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
# Vercel Sandbox CLI
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
A nifty JavaScript sandbox for Node.js.
|
|
5
|
-
<br />
|
|
6
|
-
<a href="https://github.com/gf3/sandbox/releases"><img src="https://img.shields.io/github/v/release/gf3/sandbox" alt="Latest Release"></a>
|
|
7
|
-
<a href="https://github.com/gf3/sandbox/actions"><img src="https://github.com/gf3/sandbox/actions/workflows/tests.yml/badge.svg?branch=main" alt="Build Status"></a>
|
|
8
|
-
</p>
|
|
3
|
+
Command line interface for Vercel Sandbox.
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
**It can...**
|
|
13
|
-
|
|
14
|
-
- [x] Be used to execute untrusted code
|
|
15
|
-
- [ ] Timeout long-running code and infinite loops
|
|
16
|
-
- [x] Handle errors gracefully
|
|
17
|
-
- [x] Run restricted code
|
|
18
|
-
- [x] Pass rich data structures back
|
|
19
|
-
- [ ] Capture console output
|
|
20
|
-
|
|
21
|
-
```js
|
|
22
|
-
const s = new Sandbox();
|
|
23
|
-
|
|
24
|
-
s.eval("const o = { answer: 4.2 }; o", function(err, res) {
|
|
25
|
-
console.log("The answer is: %d", res.answer * 10); // The answer is: 42
|
|
26
|
-
});
|
|
27
|
-
```
|
|
5
|
+
Read the full documentation at [vercel.com/docs/vercel-sandbox/cli-reference](https://vercel.com/docs/vercel-sandbox/cli-reference).
|
|
28
6
|
|
|
29
7
|
## Installation
|
|
30
8
|
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
By default the package will attempt to download the corresponding binary release
|
|
36
|
-
for your platform. If you wish to skip this action you can set the
|
|
37
|
-
`SANDBOX_SKIP_DOWNLOAD` environment variable:
|
|
38
|
-
|
|
39
|
-
```sh
|
|
40
|
-
env SANDBOX_SKIP_DOWNLOAD=1 npm install --save sandbox
|
|
9
|
+
```bash
|
|
10
|
+
pnpm i -g sandbox
|
|
41
11
|
```
|
|
42
12
|
|
|
43
13
|
## Usage
|
|
44
14
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
`sandbox` is a tool to allow safe local execution of JavaScript.
|
|
51
|
-
|
|
52
|
-
The previous version of `sandbox` attempted to accomplish this by spawning a
|
|
53
|
-
child process and running the untrusted code in a new Node.js context with known
|
|
54
|
-
exploits patched. Unfortunately this didn't work well from a security standpoint
|
|
55
|
-
and it became increasingly difficult to keep up with the whack-a-mole of
|
|
56
|
-
security vulnerabilities. In fact, the previous version still has unaddressed
|
|
57
|
-
vulnerabilities that are impossible to patch with that architecture.
|
|
58
|
-
|
|
59
|
-
The current version of `sandbox` takes a new approach—it embeds a JavaScript
|
|
60
|
-
interpreter in the library which executes code in a separate context in another
|
|
61
|
-
thread. This is made possible with the help of two incredible projects:
|
|
62
|
-
|
|
63
|
-
- [Boa][doc-boa] - a JavaScript interpreter written in [Rust][doc-rust]
|
|
64
|
-
- [Neon][doc-neon] - a library for interfacing with [Node-API][node-napi]
|
|
65
|
-
|
|
66
|
-
The major drawback to this approach is that it either requires the user to build
|
|
67
|
-
the `sandbox` locally from source (which requires the user to have the rust
|
|
68
|
-
build tools onhand) or provide pre-built binaries for every platform would need
|
|
69
|
-
to be provided. In order to make things a little more seamless for users, we've
|
|
70
|
-
opted to provided pre-built binaries for the following platforms:
|
|
71
|
-
|
|
72
|
-
- Linux x86_64
|
|
73
|
-
- MacOS arm64
|
|
74
|
-
- MacOS x86_64
|
|
75
|
-
- Windows x86_64
|
|
76
|
-
|
|
77
|
-
Given these targets we should be able to meet the needs of most users.
|
|
78
|
-
|
|
79
|
-
## Building
|
|
80
|
-
|
|
81
|
-
First, if you don't already have the rust toolchain installed you can follow the
|
|
82
|
-
instructions for installing rustup:
|
|
83
|
-
|
|
84
|
-
[Install rust][rust-install].
|
|
85
|
-
|
|
86
|
-
Next, running `npm run build` will attempt to build the project with
|
|
87
|
-
[cargo][doc-cargo] and move the compiled binary to `./index.node`.
|
|
88
|
-
|
|
89
|
-
At this point you should be able to work with `sandbox` and run the tests: `npm
|
|
90
|
-
test`.
|
|
91
|
-
|
|
92
|
-
## Learn More
|
|
15
|
+
```bash
|
|
16
|
+
sandbox create # Create a new sandbox
|
|
17
|
+
sandbox ls # List your sandboxes
|
|
18
|
+
sandbox --help # View all commands
|
|
19
|
+
```
|
|
93
20
|
|
|
94
|
-
|
|
21
|
+
## SDK
|
|
95
22
|
|
|
96
|
-
|
|
23
|
+
For programmatic access to Vercel Sandbox, use the [`@vercel/sandbox`](https://www.npmjs.com/package/@vercel/sandbox) package instead:
|
|
97
24
|
|
|
98
|
-
|
|
25
|
+
```bash
|
|
26
|
+
pnpm add @vercel/sandbox
|
|
27
|
+
```
|
|
99
28
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
[doc-node]: https://nodejs.org
|
|
104
|
-
[doc-rust]: https://www.rust-lang.org
|
|
105
|
-
[node-napi]: https://nodejs.org/dist/latest-v14.x/docs/api/n-api.html#n_api_node_api
|
|
106
|
-
[rust-install]: https://www.rust-lang.org/tools/install
|
|
29
|
+
```ts
|
|
30
|
+
import { Sandbox } from "@vercel/sandbox";
|
|
31
|
+
```
|
package/bin/sandbox.mjs
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/ansi-styles@6.2.1/node_modules/ansi-styles/index.js
|
|
2
|
+
const ANSI_BACKGROUND_OFFSET = 10;
|
|
3
|
+
const wrapAnsi16 = (offset = 0) => (code) => `\u001B[${code + offset}m`;
|
|
4
|
+
const wrapAnsi256 = (offset = 0) => (code) => `\u001B[${38 + offset};5;${code}m`;
|
|
5
|
+
const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
|
|
6
|
+
const styles = {
|
|
7
|
+
modifier: {
|
|
8
|
+
reset: [0, 0],
|
|
9
|
+
bold: [1, 22],
|
|
10
|
+
dim: [2, 22],
|
|
11
|
+
italic: [3, 23],
|
|
12
|
+
underline: [4, 24],
|
|
13
|
+
overline: [53, 55],
|
|
14
|
+
inverse: [7, 27],
|
|
15
|
+
hidden: [8, 28],
|
|
16
|
+
strikethrough: [9, 29]
|
|
17
|
+
},
|
|
18
|
+
color: {
|
|
19
|
+
black: [30, 39],
|
|
20
|
+
red: [31, 39],
|
|
21
|
+
green: [32, 39],
|
|
22
|
+
yellow: [33, 39],
|
|
23
|
+
blue: [34, 39],
|
|
24
|
+
magenta: [35, 39],
|
|
25
|
+
cyan: [36, 39],
|
|
26
|
+
white: [37, 39],
|
|
27
|
+
blackBright: [90, 39],
|
|
28
|
+
gray: [90, 39],
|
|
29
|
+
grey: [90, 39],
|
|
30
|
+
redBright: [91, 39],
|
|
31
|
+
greenBright: [92, 39],
|
|
32
|
+
yellowBright: [93, 39],
|
|
33
|
+
blueBright: [94, 39],
|
|
34
|
+
magentaBright: [95, 39],
|
|
35
|
+
cyanBright: [96, 39],
|
|
36
|
+
whiteBright: [97, 39]
|
|
37
|
+
},
|
|
38
|
+
bgColor: {
|
|
39
|
+
bgBlack: [40, 49],
|
|
40
|
+
bgRed: [41, 49],
|
|
41
|
+
bgGreen: [42, 49],
|
|
42
|
+
bgYellow: [43, 49],
|
|
43
|
+
bgBlue: [44, 49],
|
|
44
|
+
bgMagenta: [45, 49],
|
|
45
|
+
bgCyan: [46, 49],
|
|
46
|
+
bgWhite: [47, 49],
|
|
47
|
+
bgBlackBright: [100, 49],
|
|
48
|
+
bgGray: [100, 49],
|
|
49
|
+
bgGrey: [100, 49],
|
|
50
|
+
bgRedBright: [101, 49],
|
|
51
|
+
bgGreenBright: [102, 49],
|
|
52
|
+
bgYellowBright: [103, 49],
|
|
53
|
+
bgBlueBright: [104, 49],
|
|
54
|
+
bgMagentaBright: [105, 49],
|
|
55
|
+
bgCyanBright: [106, 49],
|
|
56
|
+
bgWhiteBright: [107, 49]
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const modifierNames = Object.keys(styles.modifier);
|
|
60
|
+
const foregroundColorNames = Object.keys(styles.color);
|
|
61
|
+
const backgroundColorNames = Object.keys(styles.bgColor);
|
|
62
|
+
const colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
63
|
+
function assembleStyles() {
|
|
64
|
+
const codes = /* @__PURE__ */ new Map();
|
|
65
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
66
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
67
|
+
styles[styleName] = {
|
|
68
|
+
open: `\u001B[${style[0]}m`,
|
|
69
|
+
close: `\u001B[${style[1]}m`
|
|
70
|
+
};
|
|
71
|
+
group[styleName] = styles[styleName];
|
|
72
|
+
codes.set(style[0], style[1]);
|
|
73
|
+
}
|
|
74
|
+
Object.defineProperty(styles, groupName, {
|
|
75
|
+
value: group,
|
|
76
|
+
enumerable: false
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
Object.defineProperty(styles, "codes", {
|
|
80
|
+
value: codes,
|
|
81
|
+
enumerable: false
|
|
82
|
+
});
|
|
83
|
+
styles.color.close = "\x1B[39m";
|
|
84
|
+
styles.bgColor.close = "\x1B[49m";
|
|
85
|
+
styles.color.ansi = wrapAnsi16();
|
|
86
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
87
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
88
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
89
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
90
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
91
|
+
Object.defineProperties(styles, {
|
|
92
|
+
rgbToAnsi256: {
|
|
93
|
+
value: (red, green, blue) => {
|
|
94
|
+
if (red === green && green === blue) {
|
|
95
|
+
if (red < 8) return 16;
|
|
96
|
+
if (red > 248) return 231;
|
|
97
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
|
98
|
+
}
|
|
99
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
100
|
+
},
|
|
101
|
+
enumerable: false
|
|
102
|
+
},
|
|
103
|
+
hexToRgb: {
|
|
104
|
+
value: (hex) => {
|
|
105
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
106
|
+
if (!matches) return [
|
|
107
|
+
0,
|
|
108
|
+
0,
|
|
109
|
+
0
|
|
110
|
+
];
|
|
111
|
+
let [colorString] = matches;
|
|
112
|
+
if (colorString.length === 3) colorString = [...colorString].map((character) => character + character).join("");
|
|
113
|
+
const integer = Number.parseInt(colorString, 16);
|
|
114
|
+
return [
|
|
115
|
+
integer >> 16 & 255,
|
|
116
|
+
integer >> 8 & 255,
|
|
117
|
+
integer & 255
|
|
118
|
+
];
|
|
119
|
+
},
|
|
120
|
+
enumerable: false
|
|
121
|
+
},
|
|
122
|
+
hexToAnsi256: {
|
|
123
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
124
|
+
enumerable: false
|
|
125
|
+
},
|
|
126
|
+
ansi256ToAnsi: {
|
|
127
|
+
value: (code) => {
|
|
128
|
+
if (code < 8) return 30 + code;
|
|
129
|
+
if (code < 16) return 90 + (code - 8);
|
|
130
|
+
let red;
|
|
131
|
+
let green;
|
|
132
|
+
let blue;
|
|
133
|
+
if (code >= 232) {
|
|
134
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
135
|
+
green = red;
|
|
136
|
+
blue = red;
|
|
137
|
+
} else {
|
|
138
|
+
code -= 16;
|
|
139
|
+
const remainder = code % 36;
|
|
140
|
+
red = Math.floor(code / 36) / 5;
|
|
141
|
+
green = Math.floor(remainder / 6) / 5;
|
|
142
|
+
blue = remainder % 6 / 5;
|
|
143
|
+
}
|
|
144
|
+
const value = Math.max(red, green, blue) * 2;
|
|
145
|
+
if (value === 0) return 30;
|
|
146
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
147
|
+
if (value === 2) result += 60;
|
|
148
|
+
return result;
|
|
149
|
+
},
|
|
150
|
+
enumerable: false
|
|
151
|
+
},
|
|
152
|
+
rgbToAnsi: {
|
|
153
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
154
|
+
enumerable: false
|
|
155
|
+
},
|
|
156
|
+
hexToAnsi: {
|
|
157
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
158
|
+
enumerable: false
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
return styles;
|
|
162
|
+
}
|
|
163
|
+
const ansiStyles = assembleStyles();
|
|
164
|
+
var ansi_styles_default = ansiStyles;
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
export { ansi_styles_default as t };
|
|
168
|
+
//# sourceMappingURL=ansi-styles-B57ln_zO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi-styles-B57ln_zO.mjs","names":[],"sources":["../../../node_modules/.pnpm/ansi-styles@6.2.1/node_modules/ansi-styles/index.js"],"sourcesContent":["const ANSI_BACKGROUND_OFFSET = 10;\n\nconst wrapAnsi16 = (offset = 0) => code => `\\u001B[${code + offset}m`;\n\nconst wrapAnsi256 = (offset = 0) => code => `\\u001B[${38 + offset};5;${code}m`;\n\nconst wrapAnsi16m = (offset = 0) => (red, green, blue) => `\\u001B[${38 + offset};2;${red};${green};${blue}m`;\n\nconst styles = {\n\tmodifier: {\n\t\treset: [0, 0],\n\t\t// 21 isn't widely supported and 22 does the same thing\n\t\tbold: [1, 22],\n\t\tdim: [2, 22],\n\t\titalic: [3, 23],\n\t\tunderline: [4, 24],\n\t\toverline: [53, 55],\n\t\tinverse: [7, 27],\n\t\thidden: [8, 28],\n\t\tstrikethrough: [9, 29],\n\t},\n\tcolor: {\n\t\tblack: [30, 39],\n\t\tred: [31, 39],\n\t\tgreen: [32, 39],\n\t\tyellow: [33, 39],\n\t\tblue: [34, 39],\n\t\tmagenta: [35, 39],\n\t\tcyan: [36, 39],\n\t\twhite: [37, 39],\n\n\t\t// Bright color\n\t\tblackBright: [90, 39],\n\t\tgray: [90, 39], // Alias of `blackBright`\n\t\tgrey: [90, 39], // Alias of `blackBright`\n\t\tredBright: [91, 39],\n\t\tgreenBright: [92, 39],\n\t\tyellowBright: [93, 39],\n\t\tblueBright: [94, 39],\n\t\tmagentaBright: [95, 39],\n\t\tcyanBright: [96, 39],\n\t\twhiteBright: [97, 39],\n\t},\n\tbgColor: {\n\t\tbgBlack: [40, 49],\n\t\tbgRed: [41, 49],\n\t\tbgGreen: [42, 49],\n\t\tbgYellow: [43, 49],\n\t\tbgBlue: [44, 49],\n\t\tbgMagenta: [45, 49],\n\t\tbgCyan: [46, 49],\n\t\tbgWhite: [47, 49],\n\n\t\t// Bright color\n\t\tbgBlackBright: [100, 49],\n\t\tbgGray: [100, 49], // Alias of `bgBlackBright`\n\t\tbgGrey: [100, 49], // Alias of `bgBlackBright`\n\t\tbgRedBright: [101, 49],\n\t\tbgGreenBright: [102, 49],\n\t\tbgYellowBright: [103, 49],\n\t\tbgBlueBright: [104, 49],\n\t\tbgMagentaBright: [105, 49],\n\t\tbgCyanBright: [106, 49],\n\t\tbgWhiteBright: [107, 49],\n\t},\n};\n\nexport const modifierNames = Object.keys(styles.modifier);\nexport const foregroundColorNames = Object.keys(styles.color);\nexport const backgroundColorNames = Object.keys(styles.bgColor);\nexport const colorNames = [...foregroundColorNames, ...backgroundColorNames];\n\nfunction assembleStyles() {\n\tconst codes = new Map();\n\n\tfor (const [groupName, group] of Object.entries(styles)) {\n\t\tfor (const [styleName, style] of Object.entries(group)) {\n\t\t\tstyles[styleName] = {\n\t\t\t\topen: `\\u001B[${style[0]}m`,\n\t\t\t\tclose: `\\u001B[${style[1]}m`,\n\t\t\t};\n\n\t\t\tgroup[styleName] = styles[styleName];\n\n\t\t\tcodes.set(style[0], style[1]);\n\t\t}\n\n\t\tObject.defineProperty(styles, groupName, {\n\t\t\tvalue: group,\n\t\t\tenumerable: false,\n\t\t});\n\t}\n\n\tObject.defineProperty(styles, 'codes', {\n\t\tvalue: codes,\n\t\tenumerable: false,\n\t});\n\n\tstyles.color.close = '\\u001B[39m';\n\tstyles.bgColor.close = '\\u001B[49m';\n\n\tstyles.color.ansi = wrapAnsi16();\n\tstyles.color.ansi256 = wrapAnsi256();\n\tstyles.color.ansi16m = wrapAnsi16m();\n\tstyles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);\n\tstyles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);\n\tstyles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);\n\n\t// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js\n\tObject.defineProperties(styles, {\n\t\trgbToAnsi256: {\n\t\t\tvalue: (red, green, blue) => {\n\t\t\t\t// We use the extended greyscale palette here, with the exception of\n\t\t\t\t// black and white. normal palette only has 4 greyscale shades.\n\t\t\t\tif (red === green && green === blue) {\n\t\t\t\t\tif (red < 8) {\n\t\t\t\t\t\treturn 16;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (red > 248) {\n\t\t\t\t\t\treturn 231;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn Math.round(((red - 8) / 247) * 24) + 232;\n\t\t\t\t}\n\n\t\t\t\treturn 16\n\t\t\t\t\t+ (36 * Math.round(red / 255 * 5))\n\t\t\t\t\t+ (6 * Math.round(green / 255 * 5))\n\t\t\t\t\t+ Math.round(blue / 255 * 5);\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t},\n\t\thexToRgb: {\n\t\t\tvalue: hex => {\n\t\t\t\tconst matches = /[a-f\\d]{6}|[a-f\\d]{3}/i.exec(hex.toString(16));\n\t\t\t\tif (!matches) {\n\t\t\t\t\treturn [0, 0, 0];\n\t\t\t\t}\n\n\t\t\t\tlet [colorString] = matches;\n\n\t\t\t\tif (colorString.length === 3) {\n\t\t\t\t\tcolorString = [...colorString].map(character => character + character).join('');\n\t\t\t\t}\n\n\t\t\t\tconst integer = Number.parseInt(colorString, 16);\n\n\t\t\t\treturn [\n\t\t\t\t\t/* eslint-disable no-bitwise */\n\t\t\t\t\t(integer >> 16) & 0xFF,\n\t\t\t\t\t(integer >> 8) & 0xFF,\n\t\t\t\t\tinteger & 0xFF,\n\t\t\t\t\t/* eslint-enable no-bitwise */\n\t\t\t\t];\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t},\n\t\thexToAnsi256: {\n\t\t\tvalue: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),\n\t\t\tenumerable: false,\n\t\t},\n\t\tansi256ToAnsi: {\n\t\t\tvalue: code => {\n\t\t\t\tif (code < 8) {\n\t\t\t\t\treturn 30 + code;\n\t\t\t\t}\n\n\t\t\t\tif (code < 16) {\n\t\t\t\t\treturn 90 + (code - 8);\n\t\t\t\t}\n\n\t\t\t\tlet red;\n\t\t\t\tlet green;\n\t\t\t\tlet blue;\n\n\t\t\t\tif (code >= 232) {\n\t\t\t\t\tred = (((code - 232) * 10) + 8) / 255;\n\t\t\t\t\tgreen = red;\n\t\t\t\t\tblue = red;\n\t\t\t\t} else {\n\t\t\t\t\tcode -= 16;\n\n\t\t\t\t\tconst remainder = code % 36;\n\n\t\t\t\t\tred = Math.floor(code / 36) / 5;\n\t\t\t\t\tgreen = Math.floor(remainder / 6) / 5;\n\t\t\t\t\tblue = (remainder % 6) / 5;\n\t\t\t\t}\n\n\t\t\t\tconst value = Math.max(red, green, blue) * 2;\n\n\t\t\t\tif (value === 0) {\n\t\t\t\t\treturn 30;\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tlet result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));\n\n\t\t\t\tif (value === 2) {\n\t\t\t\t\tresult += 60;\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t},\n\t\trgbToAnsi: {\n\t\t\tvalue: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),\n\t\t\tenumerable: false,\n\t\t},\n\t\thexToAnsi: {\n\t\t\tvalue: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),\n\t\t\tenumerable: false,\n\t\t},\n\t});\n\n\treturn styles;\n}\n\nconst ansiStyles = assembleStyles();\n\nexport default ansiStyles;\n"],"x_google_ignoreList":[0],"mappings":";AAAA,MAAM,yBAAyB;AAE/B,MAAM,cAAc,SAAS,OAAM,SAAQ,UAAU,OAAO,OAAO;AAEnE,MAAM,eAAe,SAAS,OAAM,SAAQ,UAAU,KAAK,OAAO,KAAK,KAAK;AAE5E,MAAM,eAAe,SAAS,OAAO,KAAK,OAAO,SAAS,UAAU,KAAK,OAAO,KAAK,IAAI,GAAG,MAAM,GAAG,KAAK;AAE1G,MAAM,SAAS;CACd,UAAU;EACT,OAAO,CAAC,GAAG,EAAE;EAEb,MAAM,CAAC,GAAG,GAAG;EACb,KAAK,CAAC,GAAG,GAAG;EACZ,QAAQ,CAAC,GAAG,GAAG;EACf,WAAW,CAAC,GAAG,GAAG;EAClB,UAAU,CAAC,IAAI,GAAG;EAClB,SAAS,CAAC,GAAG,GAAG;EAChB,QAAQ,CAAC,GAAG,GAAG;EACf,eAAe,CAAC,GAAG,GAAG;EACtB;CACD,OAAO;EACN,OAAO,CAAC,IAAI,GAAG;EACf,KAAK,CAAC,IAAI,GAAG;EACb,OAAO,CAAC,IAAI,GAAG;EACf,QAAQ,CAAC,IAAI,GAAG;EAChB,MAAM,CAAC,IAAI,GAAG;EACd,SAAS,CAAC,IAAI,GAAG;EACjB,MAAM,CAAC,IAAI,GAAG;EACd,OAAO,CAAC,IAAI,GAAG;EAGf,aAAa,CAAC,IAAI,GAAG;EACrB,MAAM,CAAC,IAAI,GAAG;EACd,MAAM,CAAC,IAAI,GAAG;EACd,WAAW,CAAC,IAAI,GAAG;EACnB,aAAa,CAAC,IAAI,GAAG;EACrB,cAAc,CAAC,IAAI,GAAG;EACtB,YAAY,CAA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