bun-types 1.0.23 → 1.0.25
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/package.json +1 -1
- package/types.d.ts +202 -5
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Type definitions for bun 1.0.
|
|
1
|
+
// Type definitions for bun 1.0.25
|
|
2
2
|
// Project: https://github.com/oven-sh/bun
|
|
3
3
|
// Definitions by: Jarred Sumner <https://github.com/Jarred-Sumner>
|
|
4
4
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
@@ -4888,11 +4888,8 @@ declare module "bun:sqlite" {
|
|
|
4888
4888
|
/**
|
|
4889
4889
|
* Errors from SQLite have a name `SQLiteError`.
|
|
4890
4890
|
*
|
|
4891
|
-
* This class does not exist! It is not a class. It is just a type.
|
|
4892
|
-
*
|
|
4893
|
-
* To check if an `Error` is an SQLiteError, use `error.name === "SQLiteError"`
|
|
4894
4891
|
*/
|
|
4895
|
-
export
|
|
4892
|
+
export class SQLiteError extends Error {
|
|
4896
4893
|
readonly name: "SQLiteError";
|
|
4897
4894
|
|
|
4898
4895
|
/**
|
|
@@ -4980,6 +4977,181 @@ declare module "bun" {
|
|
|
4980
4977
|
options?: { PATH?: string; cwd?: string },
|
|
4981
4978
|
): string | null;
|
|
4982
4979
|
|
|
4980
|
+
export type ShellFunction = (input: Uint8Array) => Uint8Array;
|
|
4981
|
+
|
|
4982
|
+
export type ShellExpression =
|
|
4983
|
+
| string
|
|
4984
|
+
| { raw: string }
|
|
4985
|
+
| Subprocess
|
|
4986
|
+
| SpawnOptions.Readable
|
|
4987
|
+
| SpawnOptions.Writable
|
|
4988
|
+
| ReadableStream;
|
|
4989
|
+
|
|
4990
|
+
class ShellPromise extends Promise<ShellOutput> {
|
|
4991
|
+
get stdin(): WritableStream;
|
|
4992
|
+
/**
|
|
4993
|
+
* Change the current working directory of the shell.
|
|
4994
|
+
* @param newCwd - The new working directory
|
|
4995
|
+
*/
|
|
4996
|
+
cwd(newCwd: string): this;
|
|
4997
|
+
/**
|
|
4998
|
+
* Set environment variables for the shell.
|
|
4999
|
+
* @param newEnv - The new environment variables
|
|
5000
|
+
*
|
|
5001
|
+
* @example
|
|
5002
|
+
* ```ts
|
|
5003
|
+
* await $`echo $FOO`.env({ ...process.env, FOO: "LOL!" })
|
|
5004
|
+
* expect(stdout.toString()).toBe("LOL!");
|
|
5005
|
+
* ```
|
|
5006
|
+
*/
|
|
5007
|
+
env(newEnv: Record<string, string> | undefined): this;
|
|
5008
|
+
/**
|
|
5009
|
+
* By default, the shell will write to the current process's stdout and stderr, as well as buffering that output.
|
|
5010
|
+
*
|
|
5011
|
+
* This configures the shell to only buffer the output.
|
|
5012
|
+
*/
|
|
5013
|
+
quiet(): this;
|
|
5014
|
+
|
|
5015
|
+
/**
|
|
5016
|
+
* Read from stdout as a string, line by line
|
|
5017
|
+
*
|
|
5018
|
+
* Automatically calls {@link quiet} to disable echoing to stdout.
|
|
5019
|
+
*/
|
|
5020
|
+
lines(): AsyncIterable<string>;
|
|
5021
|
+
|
|
5022
|
+
/**
|
|
5023
|
+
* Read from stdout as a string
|
|
5024
|
+
*
|
|
5025
|
+
* Automatically calls {@link quiet} to disable echoing to stdout.
|
|
5026
|
+
* @param encoding - The encoding to use when decoding the output
|
|
5027
|
+
* @returns A promise that resolves with stdout as a string
|
|
5028
|
+
* @example
|
|
5029
|
+
*
|
|
5030
|
+
* ## Read as UTF-8 string
|
|
5031
|
+
*
|
|
5032
|
+
* ```ts
|
|
5033
|
+
* const output = await $`echo hello`.text();
|
|
5034
|
+
* console.log(output); // "hello\n"
|
|
5035
|
+
* ```
|
|
5036
|
+
*
|
|
5037
|
+
* ## Read as base64 string
|
|
5038
|
+
*
|
|
5039
|
+
* ```ts
|
|
5040
|
+
* const output = await $`echo ${atob("hello")}`.text("base64");
|
|
5041
|
+
* console.log(output); // "hello\n"
|
|
5042
|
+
* ```
|
|
5043
|
+
*
|
|
5044
|
+
*/
|
|
5045
|
+
text(encoding?: BufferEncoding): Promise<string>;
|
|
5046
|
+
|
|
5047
|
+
/**
|
|
5048
|
+
* Read from stdout as a JSON object
|
|
5049
|
+
*
|
|
5050
|
+
* Automatically calls {@link quiet}
|
|
5051
|
+
*
|
|
5052
|
+
* @returns A promise that resolves with stdout as a JSON object
|
|
5053
|
+
* @example
|
|
5054
|
+
*
|
|
5055
|
+
* ```ts
|
|
5056
|
+
* const output = await $`echo '{"hello": 123}'`.json();
|
|
5057
|
+
* console.log(output); // { hello: 123 }
|
|
5058
|
+
* ```
|
|
5059
|
+
*
|
|
5060
|
+
*/
|
|
5061
|
+
json(): Promise<any>;
|
|
5062
|
+
|
|
5063
|
+
/**
|
|
5064
|
+
* Read from stdout as an ArrayBuffer
|
|
5065
|
+
*
|
|
5066
|
+
* Automatically calls {@link quiet}
|
|
5067
|
+
* @returns A promise that resolves with stdout as an ArrayBuffer
|
|
5068
|
+
* @example
|
|
5069
|
+
*
|
|
5070
|
+
* ```ts
|
|
5071
|
+
* const output = await $`echo hello`.arrayBuffer();
|
|
5072
|
+
* console.log(output); // ArrayBuffer { byteLength: 6 }
|
|
5073
|
+
* ```
|
|
5074
|
+
*/
|
|
5075
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
5076
|
+
|
|
5077
|
+
/**
|
|
5078
|
+
* Read from stdout as a Blob
|
|
5079
|
+
*
|
|
5080
|
+
* Automatically calls {@link quiet}
|
|
5081
|
+
* @returns A promise that resolves with stdout as a Blob
|
|
5082
|
+
* @example
|
|
5083
|
+
* ```ts
|
|
5084
|
+
* const output = await $`echo hello`.blob();
|
|
5085
|
+
* console.log(output); // Blob { size: 6, type: "" }
|
|
5086
|
+
* ```
|
|
5087
|
+
*/
|
|
5088
|
+
blob(): Promise<Blob>;
|
|
5089
|
+
}
|
|
5090
|
+
|
|
5091
|
+
interface ShellConstructor {
|
|
5092
|
+
new (): Shell;
|
|
5093
|
+
}
|
|
5094
|
+
|
|
5095
|
+
export interface Shell {
|
|
5096
|
+
(
|
|
5097
|
+
strings: TemplateStringsArray,
|
|
5098
|
+
...expressions: ShellExpression[]
|
|
5099
|
+
): ShellPromise;
|
|
5100
|
+
|
|
5101
|
+
/**
|
|
5102
|
+
* Perform bash-like brace expansion on the given pattern.
|
|
5103
|
+
* @param pattern - Brace pattern to expand
|
|
5104
|
+
*
|
|
5105
|
+
* @example
|
|
5106
|
+
* ```js
|
|
5107
|
+
* const result = braces('index.{js,jsx,ts,tsx}');
|
|
5108
|
+
* console.log(result) // ['index.js', 'index.jsx', 'index.ts', 'index.tsx']
|
|
5109
|
+
* ```
|
|
5110
|
+
*/
|
|
5111
|
+
braces(pattern: string): string[];
|
|
5112
|
+
|
|
5113
|
+
/**
|
|
5114
|
+
* Escape strings for input into shell commands.
|
|
5115
|
+
* @param input
|
|
5116
|
+
*/
|
|
5117
|
+
escape(input: string): string;
|
|
5118
|
+
|
|
5119
|
+
/**
|
|
5120
|
+
*
|
|
5121
|
+
* Change the default environment variables for shells created by this instance.
|
|
5122
|
+
*
|
|
5123
|
+
* @param newEnv Default environment variables to use for shells created by this instance.
|
|
5124
|
+
* @default process.env
|
|
5125
|
+
*
|
|
5126
|
+
* ## Example
|
|
5127
|
+
*
|
|
5128
|
+
* ```js
|
|
5129
|
+
* import {$} from 'bun';
|
|
5130
|
+
* $.env({ BUN: "bun" });
|
|
5131
|
+
* await $`echo $BUN`;
|
|
5132
|
+
* // "bun"
|
|
5133
|
+
* ```
|
|
5134
|
+
*/
|
|
5135
|
+
env(newEnv?: Record<string, string | undefined>): this;
|
|
5136
|
+
|
|
5137
|
+
/**
|
|
5138
|
+
*
|
|
5139
|
+
* @param newCwd Default working directory to use for shells created by this instance.
|
|
5140
|
+
*/
|
|
5141
|
+
cwd(newCwd?: string): this;
|
|
5142
|
+
|
|
5143
|
+
readonly ShellPromise: typeof ShellPromise;
|
|
5144
|
+
readonly Shell: ShellConstructor;
|
|
5145
|
+
}
|
|
5146
|
+
|
|
5147
|
+
export interface ShellOutput {
|
|
5148
|
+
readonly stdout: Buffer;
|
|
5149
|
+
readonly stderr: Buffer;
|
|
5150
|
+
readonly exitCode: number;
|
|
5151
|
+
}
|
|
5152
|
+
|
|
5153
|
+
export const $: Shell;
|
|
5154
|
+
|
|
4983
5155
|
interface TOML {
|
|
4984
5156
|
/**
|
|
4985
5157
|
* Parse a TOML string into a JavaScript object.
|
|
@@ -9252,6 +9424,31 @@ declare module "bun" {
|
|
|
9252
9424
|
"ignore" | "inherit" | null | undefined
|
|
9253
9425
|
>;
|
|
9254
9426
|
|
|
9427
|
+
// Blocked on https://github.com/oven-sh/bun/issues/8329
|
|
9428
|
+
// /**
|
|
9429
|
+
// *
|
|
9430
|
+
// * Count the visible width of a string, as it would be displayed in a terminal.
|
|
9431
|
+
// *
|
|
9432
|
+
// * By default, strips ANSI escape codes before measuring the string. This is
|
|
9433
|
+
// * because ANSI escape codes are not visible characters. If passed a non-string,
|
|
9434
|
+
// * it will return 0.
|
|
9435
|
+
// *
|
|
9436
|
+
// * @param str The string to measure
|
|
9437
|
+
// * @param options
|
|
9438
|
+
// */
|
|
9439
|
+
// function stringWidth(
|
|
9440
|
+
// str: string,
|
|
9441
|
+
// options?: {
|
|
9442
|
+
// /**
|
|
9443
|
+
// * Whether to include ANSI escape codes in the width calculation
|
|
9444
|
+
// *
|
|
9445
|
+
// * Slightly faster if set to `false`, but less accurate if the string contains ANSI escape codes.
|
|
9446
|
+
// * @default false
|
|
9447
|
+
// */
|
|
9448
|
+
// countAnsiEscapeCodes?: boolean;
|
|
9449
|
+
// },
|
|
9450
|
+
// ): number;
|
|
9451
|
+
|
|
9255
9452
|
class FileSystemRouter {
|
|
9256
9453
|
/**
|
|
9257
9454
|
* Create a new {@link FileSystemRouter}.
|