bun-types-no-globals 1.3.4-canary.20251208T140653 → 1.3.6-canary.20260109T140758
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/lib/bun.d.ts +644 -28
- package/lib/bundle.d.ts +74 -0
- package/lib/globals.d.ts +7 -2
- package/lib/index.d.ts +1 -0
- package/lib/overrides.d.ts +16 -2
- package/lib/s3.d.ts +42 -0
- package/lib/sqlite.d.ts +17 -16
- package/lib/test.d.ts +10 -8
- package/package.json +1 -1
package/lib/bun.d.ts
CHANGED
|
@@ -625,6 +625,33 @@ declare module "bun" {
|
|
|
625
625
|
export function parse(input: string): object;
|
|
626
626
|
}
|
|
627
627
|
|
|
628
|
+
/**
|
|
629
|
+
* JSONC related APIs
|
|
630
|
+
*/
|
|
631
|
+
namespace JSONC {
|
|
632
|
+
/**
|
|
633
|
+
* Parse a JSONC (JSON with Comments) string into a JavaScript value.
|
|
634
|
+
*
|
|
635
|
+
* Supports both single-line (`//`) and block comments (`/* ... *\/`), as well as
|
|
636
|
+
* trailing commas in objects and arrays.
|
|
637
|
+
*
|
|
638
|
+
* @category Utilities
|
|
639
|
+
*
|
|
640
|
+
* @param input The JSONC string to parse
|
|
641
|
+
* @returns A JavaScript value
|
|
642
|
+
*
|
|
643
|
+
* @example
|
|
644
|
+
* ```js
|
|
645
|
+
* const result = Bun.JSONC.parse(`{
|
|
646
|
+
* // This is a comment
|
|
647
|
+
* "name": "my-app",
|
|
648
|
+
* "version": "1.0.0", // trailing comma is allowed
|
|
649
|
+
* }`);
|
|
650
|
+
* ```
|
|
651
|
+
*/
|
|
652
|
+
export function parse(input: string): unknown;
|
|
653
|
+
}
|
|
654
|
+
|
|
628
655
|
/**
|
|
629
656
|
* YAML related APIs
|
|
630
657
|
*/
|
|
@@ -815,6 +842,20 @@ declare module "bun" {
|
|
|
815
842
|
destination: BunFile,
|
|
816
843
|
input: BunFile,
|
|
817
844
|
options?: {
|
|
845
|
+
/**
|
|
846
|
+
* Set the file permissions of the destination when it is created or overwritten.
|
|
847
|
+
*
|
|
848
|
+
* Must be a valid Unix permission mode (0 to 0o777 / 511 in decimal).
|
|
849
|
+
* If omitted, defaults to the system default based on umask (typically 0o644).
|
|
850
|
+
*
|
|
851
|
+
* @throws {RangeError} If the mode is outside the valid range (0 to 0o777).
|
|
852
|
+
*
|
|
853
|
+
* @example
|
|
854
|
+
* ```ts
|
|
855
|
+
* await Bun.write(Bun.file("./secret.txt"), Bun.file("./source.txt"), { mode: 0o600 });
|
|
856
|
+
* ```
|
|
857
|
+
*/
|
|
858
|
+
mode?: number;
|
|
818
859
|
/**
|
|
819
860
|
* If `true`, create the parent directory if it doesn't exist. By default, this is `true`.
|
|
820
861
|
*
|
|
@@ -848,6 +889,20 @@ declare module "bun" {
|
|
|
848
889
|
destinationPath: PathLike,
|
|
849
890
|
input: BunFile,
|
|
850
891
|
options?: {
|
|
892
|
+
/**
|
|
893
|
+
* Set the file permissions of the destination when it is created or overwritten.
|
|
894
|
+
*
|
|
895
|
+
* Must be a valid Unix permission mode (0 to 0o777 / 511 in decimal).
|
|
896
|
+
* If omitted, defaults to the system default based on umask (typically 0o644).
|
|
897
|
+
*
|
|
898
|
+
* @throws {RangeError} If the mode is outside the valid range (0 to 0o777).
|
|
899
|
+
*
|
|
900
|
+
* @example
|
|
901
|
+
* ```ts
|
|
902
|
+
* await Bun.write("./secret.txt", Bun.file("./source.txt"), { mode: 0o600 });
|
|
903
|
+
* ```
|
|
904
|
+
*/
|
|
905
|
+
mode?: number;
|
|
851
906
|
/**
|
|
852
907
|
* If `true`, create the parent directory if it doesn't exist. By default, this is `true`.
|
|
853
908
|
*
|
|
@@ -1740,9 +1795,9 @@ declare module "bun" {
|
|
|
1740
1795
|
* @default "esm"
|
|
1741
1796
|
*/
|
|
1742
1797
|
format?: /**
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1798
|
+
* ECMAScript Module format
|
|
1799
|
+
*/
|
|
1800
|
+
| "esm"
|
|
1746
1801
|
/**
|
|
1747
1802
|
* CommonJS format
|
|
1748
1803
|
* **Experimental**
|
|
@@ -1891,6 +1946,24 @@ declare module "bun" {
|
|
|
1891
1946
|
*/
|
|
1892
1947
|
drop?: string[];
|
|
1893
1948
|
|
|
1949
|
+
/**
|
|
1950
|
+
* Enable feature flags for dead-code elimination via `import { feature } from "bun:bundle"`.
|
|
1951
|
+
*
|
|
1952
|
+
* When `feature("FLAG_NAME")` is called, it returns `true` if FLAG_NAME is in this array,
|
|
1953
|
+
* or `false` otherwise. This enables static dead-code elimination at bundle time.
|
|
1954
|
+
*
|
|
1955
|
+
* Equivalent to the CLI `--feature` flag.
|
|
1956
|
+
*
|
|
1957
|
+
* @example
|
|
1958
|
+
* ```ts
|
|
1959
|
+
* await Bun.build({
|
|
1960
|
+
* entrypoints: ['./src/index.ts'],
|
|
1961
|
+
* features: ['FEATURE_A', 'FEATURE_B'],
|
|
1962
|
+
* });
|
|
1963
|
+
* ```
|
|
1964
|
+
*/
|
|
1965
|
+
features?: string[];
|
|
1966
|
+
|
|
1894
1967
|
/**
|
|
1895
1968
|
* - When set to `true`, the returned promise rejects with an AggregateError when a build failure happens.
|
|
1896
1969
|
* - When set to `false`, returns a {@link BuildOutput} with `{success: false}`
|
|
@@ -1924,6 +1997,107 @@ declare module "bun" {
|
|
|
1924
1997
|
development?: boolean;
|
|
1925
1998
|
};
|
|
1926
1999
|
|
|
2000
|
+
/**
|
|
2001
|
+
* Enable React Fast Refresh transform.
|
|
2002
|
+
*
|
|
2003
|
+
* This adds the necessary code transformations for React Fast Refresh (hot module
|
|
2004
|
+
* replacement for React components), but does not emit hot-module code itself.
|
|
2005
|
+
*
|
|
2006
|
+
* @default false
|
|
2007
|
+
*/
|
|
2008
|
+
reactFastRefresh?: boolean;
|
|
2009
|
+
|
|
2010
|
+
/**
|
|
2011
|
+
* A map of file paths to their contents for in-memory bundling.
|
|
2012
|
+
*
|
|
2013
|
+
* This allows you to bundle virtual files that don't exist on disk, or override
|
|
2014
|
+
* the contents of files that do exist on disk. The keys are file paths (which should
|
|
2015
|
+
* match how they're imported) and the values are the file contents.
|
|
2016
|
+
*
|
|
2017
|
+
* File contents can be provided as:
|
|
2018
|
+
* - `string` - The source code as a string
|
|
2019
|
+
* - `Blob` - A Blob containing the source code
|
|
2020
|
+
* - `NodeJS.TypedArray` - A typed array (e.g., `Uint8Array`) containing the source code
|
|
2021
|
+
* - `ArrayBufferLike` - An ArrayBuffer containing the source code
|
|
2022
|
+
*
|
|
2023
|
+
* @example
|
|
2024
|
+
* ```ts
|
|
2025
|
+
* // Bundle entirely from memory (no files on disk needed)
|
|
2026
|
+
* await Bun.build({
|
|
2027
|
+
* entrypoints: ["/app/index.ts"],
|
|
2028
|
+
* files: {
|
|
2029
|
+
* "/app/index.ts": `
|
|
2030
|
+
* import { helper } from "./helper.ts";
|
|
2031
|
+
* console.log(helper());
|
|
2032
|
+
* `,
|
|
2033
|
+
* "/app/helper.ts": `
|
|
2034
|
+
* export function helper() {
|
|
2035
|
+
* return "Hello from memory!";
|
|
2036
|
+
* }
|
|
2037
|
+
* `,
|
|
2038
|
+
* },
|
|
2039
|
+
* });
|
|
2040
|
+
* ```
|
|
2041
|
+
*
|
|
2042
|
+
* @example
|
|
2043
|
+
* ```ts
|
|
2044
|
+
* // Override a file on disk with in-memory contents
|
|
2045
|
+
* await Bun.build({
|
|
2046
|
+
* entrypoints: ["./src/index.ts"],
|
|
2047
|
+
* files: {
|
|
2048
|
+
* // This will be used instead of the actual ./src/config.ts file
|
|
2049
|
+
* "./src/config.ts": `export const API_URL = "https://production.api.com";`,
|
|
2050
|
+
* },
|
|
2051
|
+
* });
|
|
2052
|
+
* ```
|
|
2053
|
+
*
|
|
2054
|
+
* @example
|
|
2055
|
+
* ```ts
|
|
2056
|
+
* // Mix disk files with in-memory files
|
|
2057
|
+
* // Entry point is on disk, but imports a virtual file
|
|
2058
|
+
* await Bun.build({
|
|
2059
|
+
* entrypoints: ["./src/index.ts"], // Real file on disk
|
|
2060
|
+
* files: {
|
|
2061
|
+
* // Virtual file that ./src/index.ts can import via "./generated.ts"
|
|
2062
|
+
* "./src/generated.ts": `export const BUILD_TIME = ${Date.now()};`,
|
|
2063
|
+
* },
|
|
2064
|
+
* });
|
|
2065
|
+
* ```
|
|
2066
|
+
*/
|
|
2067
|
+
files?: Record<string, string | Blob | NodeJS.TypedArray | ArrayBufferLike>;
|
|
2068
|
+
|
|
2069
|
+
/**
|
|
2070
|
+
* Generate a JSON file containing metadata about the build.
|
|
2071
|
+
*
|
|
2072
|
+
* The metafile contains information about inputs, outputs, imports, and exports
|
|
2073
|
+
* which can be used for bundle analysis, visualization, or integration with
|
|
2074
|
+
* other tools.
|
|
2075
|
+
*
|
|
2076
|
+
* When `true`, the metafile JSON string is included in the {@link BuildOutput.metafile} property.
|
|
2077
|
+
*
|
|
2078
|
+
* @default false
|
|
2079
|
+
*
|
|
2080
|
+
* @example
|
|
2081
|
+
* ```ts
|
|
2082
|
+
* const result = await Bun.build({
|
|
2083
|
+
* entrypoints: ['./src/index.ts'],
|
|
2084
|
+
* outdir: './dist',
|
|
2085
|
+
* metafile: true,
|
|
2086
|
+
* });
|
|
2087
|
+
*
|
|
2088
|
+
* // Write metafile to disk for analysis
|
|
2089
|
+
* if (result.metafile) {
|
|
2090
|
+
* await Bun.write('./dist/meta.json', result.metafile);
|
|
2091
|
+
* }
|
|
2092
|
+
*
|
|
2093
|
+
* // Parse and analyze the metafile
|
|
2094
|
+
* const meta = JSON.parse(result.metafile!);
|
|
2095
|
+
* console.log('Input files:', Object.keys(meta.inputs));
|
|
2096
|
+
* console.log('Output files:', Object.keys(meta.outputs));
|
|
2097
|
+
* ```
|
|
2098
|
+
*/
|
|
2099
|
+
metafile?: boolean;
|
|
2100
|
+
|
|
1927
2101
|
outdir?: string;
|
|
1928
2102
|
}
|
|
1929
2103
|
|
|
@@ -1952,6 +2126,26 @@ declare module "bun" {
|
|
|
1952
2126
|
* @default true
|
|
1953
2127
|
*/
|
|
1954
2128
|
autoloadBunfig?: boolean;
|
|
2129
|
+
/**
|
|
2130
|
+
* Whether to autoload tsconfig.json when the standalone executable runs
|
|
2131
|
+
*
|
|
2132
|
+
* Standalone-only: applies only when building/running the standalone executable.
|
|
2133
|
+
*
|
|
2134
|
+
* Equivalent CLI flags: `--compile-autoload-tsconfig`, `--no-compile-autoload-tsconfig`
|
|
2135
|
+
*
|
|
2136
|
+
* @default false
|
|
2137
|
+
*/
|
|
2138
|
+
autoloadTsconfig?: boolean;
|
|
2139
|
+
/**
|
|
2140
|
+
* Whether to autoload package.json when the standalone executable runs
|
|
2141
|
+
*
|
|
2142
|
+
* Standalone-only: applies only when building/running the standalone executable.
|
|
2143
|
+
*
|
|
2144
|
+
* Equivalent CLI flags: `--compile-autoload-package-json`, `--no-compile-autoload-package-json`
|
|
2145
|
+
*
|
|
2146
|
+
* @default false
|
|
2147
|
+
*/
|
|
2148
|
+
autoloadPackageJson?: boolean;
|
|
1955
2149
|
windows?: {
|
|
1956
2150
|
hideConsole?: boolean;
|
|
1957
2151
|
icon?: string;
|
|
@@ -2555,6 +2749,106 @@ declare module "bun" {
|
|
|
2555
2749
|
outputs: BuildArtifact[];
|
|
2556
2750
|
success: boolean;
|
|
2557
2751
|
logs: Array<BuildMessage | ResolveMessage>;
|
|
2752
|
+
/**
|
|
2753
|
+
* Metadata about the build including inputs, outputs, and their relationships.
|
|
2754
|
+
*
|
|
2755
|
+
* Only present when {@link BuildConfig.metafile} is `true`.
|
|
2756
|
+
*
|
|
2757
|
+
* The metafile contains detailed information about:
|
|
2758
|
+
* - **inputs**: All source files that were bundled, their byte sizes, imports, and format
|
|
2759
|
+
* - **outputs**: All generated output files, their byte sizes, which inputs contributed to each output, imports between chunks, and exports
|
|
2760
|
+
*
|
|
2761
|
+
* This can be used for:
|
|
2762
|
+
* - Bundle size analysis and visualization
|
|
2763
|
+
* - Detecting unused code or dependencies
|
|
2764
|
+
* - Understanding the dependency graph
|
|
2765
|
+
* - Integration with bundle analyzer tools
|
|
2766
|
+
*
|
|
2767
|
+
* @example
|
|
2768
|
+
* ```ts
|
|
2769
|
+
* const result = await Bun.build({
|
|
2770
|
+
* entrypoints: ['./src/index.ts'],
|
|
2771
|
+
* outdir: './dist',
|
|
2772
|
+
* metafile: true,
|
|
2773
|
+
* });
|
|
2774
|
+
*
|
|
2775
|
+
* if (result.metafile) {
|
|
2776
|
+
* // Analyze input files
|
|
2777
|
+
* for (const [path, input] of Object.entries(result.metafile.inputs)) {
|
|
2778
|
+
* console.log(`${path}: ${input.bytes} bytes, ${input.imports.length} imports`);
|
|
2779
|
+
* }
|
|
2780
|
+
*
|
|
2781
|
+
* // Analyze output files
|
|
2782
|
+
* for (const [path, output] of Object.entries(result.metafile.outputs)) {
|
|
2783
|
+
* console.log(`${path}: ${output.bytes} bytes`);
|
|
2784
|
+
* for (const [inputPath, info] of Object.entries(output.inputs)) {
|
|
2785
|
+
* console.log(` - ${inputPath}: ${info.bytesInOutput} bytes`);
|
|
2786
|
+
* }
|
|
2787
|
+
* }
|
|
2788
|
+
*
|
|
2789
|
+
* // Write to disk for external analysis tools
|
|
2790
|
+
* await Bun.write('./dist/meta.json', JSON.stringify(result.metafile));
|
|
2791
|
+
* }
|
|
2792
|
+
* ```
|
|
2793
|
+
*/
|
|
2794
|
+
metafile?: BuildMetafile;
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
/**
|
|
2798
|
+
* Metafile structure containing build metadata for analysis.
|
|
2799
|
+
*
|
|
2800
|
+
* @category Bundler
|
|
2801
|
+
*/
|
|
2802
|
+
interface BuildMetafile {
|
|
2803
|
+
/** Information about all input source files */
|
|
2804
|
+
inputs: {
|
|
2805
|
+
[path: string]: {
|
|
2806
|
+
/** Size of the input file in bytes */
|
|
2807
|
+
bytes: number;
|
|
2808
|
+
/** List of imports from this file */
|
|
2809
|
+
imports: Array<{
|
|
2810
|
+
/** Resolved path of the imported file */
|
|
2811
|
+
path: string;
|
|
2812
|
+
/** Type of import statement */
|
|
2813
|
+
kind: ImportKind;
|
|
2814
|
+
/** Original import specifier before resolution (if different from path) */
|
|
2815
|
+
original?: string;
|
|
2816
|
+
/** Whether this import is external to the bundle */
|
|
2817
|
+
external?: boolean;
|
|
2818
|
+
/** Import attributes (e.g., `{ type: "json" }`) */
|
|
2819
|
+
with?: Record<string, string>;
|
|
2820
|
+
}>;
|
|
2821
|
+
/** Module format of the input file */
|
|
2822
|
+
format?: "esm" | "cjs" | "json" | "css";
|
|
2823
|
+
};
|
|
2824
|
+
};
|
|
2825
|
+
/** Information about all output files */
|
|
2826
|
+
outputs: {
|
|
2827
|
+
[path: string]: {
|
|
2828
|
+
/** Size of the output file in bytes */
|
|
2829
|
+
bytes: number;
|
|
2830
|
+
/** Map of input files to their contribution in this output */
|
|
2831
|
+
inputs: {
|
|
2832
|
+
[path: string]: {
|
|
2833
|
+
/** Number of bytes this input contributed to the output */
|
|
2834
|
+
bytesInOutput: number;
|
|
2835
|
+
};
|
|
2836
|
+
};
|
|
2837
|
+
/** List of imports to other chunks */
|
|
2838
|
+
imports: Array<{
|
|
2839
|
+
/** Path to the imported chunk */
|
|
2840
|
+
path: string;
|
|
2841
|
+
/** Type of import */
|
|
2842
|
+
kind: ImportKind;
|
|
2843
|
+
}>;
|
|
2844
|
+
/** List of exported names from this output */
|
|
2845
|
+
exports: string[];
|
|
2846
|
+
/** Entry point path if this output is an entry point */
|
|
2847
|
+
entryPoint?: string;
|
|
2848
|
+
/** Path to the associated CSS bundle (for JS entry points with CSS) */
|
|
2849
|
+
cssBundle?: string;
|
|
2850
|
+
};
|
|
2851
|
+
};
|
|
2558
2852
|
}
|
|
2559
2853
|
|
|
2560
2854
|
/**
|
|
@@ -3024,16 +3318,29 @@ declare module "bun" {
|
|
|
3024
3318
|
|
|
3025
3319
|
type WebSocketOptionsTLS = {
|
|
3026
3320
|
/**
|
|
3027
|
-
* Options for the TLS connection
|
|
3321
|
+
* Options for the TLS connection.
|
|
3322
|
+
*
|
|
3323
|
+
* Supports full TLS configuration including custom CA certificates,
|
|
3324
|
+
* client certificates, and other TLS settings (same as fetch).
|
|
3325
|
+
*
|
|
3326
|
+
* @example
|
|
3327
|
+
* ```ts
|
|
3328
|
+
* // Using BunFile for certificates
|
|
3329
|
+
* const ws = new WebSocket("wss://example.com", {
|
|
3330
|
+
* tls: {
|
|
3331
|
+
* ca: Bun.file("./ca.pem")
|
|
3332
|
+
* }
|
|
3333
|
+
* });
|
|
3334
|
+
*
|
|
3335
|
+
* // Using Buffer
|
|
3336
|
+
* const ws = new WebSocket("wss://example.com", {
|
|
3337
|
+
* tls: {
|
|
3338
|
+
* ca: fs.readFileSync("./ca.pem")
|
|
3339
|
+
* }
|
|
3340
|
+
* });
|
|
3341
|
+
* ```
|
|
3028
3342
|
*/
|
|
3029
|
-
tls?:
|
|
3030
|
-
/**
|
|
3031
|
-
* Whether to reject the connection if the certificate is not valid
|
|
3032
|
-
*
|
|
3033
|
-
* @default true
|
|
3034
|
-
*/
|
|
3035
|
-
rejectUnauthorized?: boolean;
|
|
3036
|
-
};
|
|
3343
|
+
tls?: TLSOptions;
|
|
3037
3344
|
};
|
|
3038
3345
|
|
|
3039
3346
|
type WebSocketOptionsHeaders = {
|
|
@@ -3043,10 +3350,57 @@ declare module "bun" {
|
|
|
3043
3350
|
headers?: import("node:http").OutgoingHttpHeaders;
|
|
3044
3351
|
};
|
|
3045
3352
|
|
|
3353
|
+
type WebSocketOptionsProxy = {
|
|
3354
|
+
/**
|
|
3355
|
+
* HTTP proxy to use for the WebSocket connection.
|
|
3356
|
+
*
|
|
3357
|
+
* Can be a string URL or an object with `url` and optional `headers`.
|
|
3358
|
+
*
|
|
3359
|
+
* @example
|
|
3360
|
+
* ```ts
|
|
3361
|
+
* // String format
|
|
3362
|
+
* const ws = new WebSocket("wss://example.com", {
|
|
3363
|
+
* proxy: "http://proxy.example.com:8080"
|
|
3364
|
+
* });
|
|
3365
|
+
*
|
|
3366
|
+
* // With credentials
|
|
3367
|
+
* const ws = new WebSocket("wss://example.com", {
|
|
3368
|
+
* proxy: "http://user:pass@proxy.example.com:8080"
|
|
3369
|
+
* });
|
|
3370
|
+
*
|
|
3371
|
+
* // Object format with custom headers
|
|
3372
|
+
* const ws = new WebSocket("wss://example.com", {
|
|
3373
|
+
* proxy: {
|
|
3374
|
+
* url: "http://proxy.example.com:8080",
|
|
3375
|
+
* headers: {
|
|
3376
|
+
* "Proxy-Authorization": "Bearer token"
|
|
3377
|
+
* }
|
|
3378
|
+
* }
|
|
3379
|
+
* });
|
|
3380
|
+
* ```
|
|
3381
|
+
*/
|
|
3382
|
+
proxy?:
|
|
3383
|
+
| string
|
|
3384
|
+
| {
|
|
3385
|
+
/**
|
|
3386
|
+
* The proxy URL (http:// or https://)
|
|
3387
|
+
*/
|
|
3388
|
+
url: string;
|
|
3389
|
+
/**
|
|
3390
|
+
* Custom headers to send to the proxy server.
|
|
3391
|
+
* Supports plain objects or Headers class instances.
|
|
3392
|
+
*/
|
|
3393
|
+
headers?: import("node:http").OutgoingHttpHeaders | Headers;
|
|
3394
|
+
};
|
|
3395
|
+
};
|
|
3396
|
+
|
|
3046
3397
|
/**
|
|
3047
3398
|
* Constructor options for the `Bun.WebSocket` client
|
|
3048
3399
|
*/
|
|
3049
|
-
type WebSocketOptions = WebSocketOptionsProtocolsOrProtocol &
|
|
3400
|
+
type WebSocketOptions = WebSocketOptionsProtocolsOrProtocol &
|
|
3401
|
+
WebSocketOptionsTLS &
|
|
3402
|
+
WebSocketOptionsHeaders &
|
|
3403
|
+
WebSocketOptionsProxy;
|
|
3050
3404
|
|
|
3051
3405
|
interface WebSocketEventMap {
|
|
3052
3406
|
close: CloseEvent;
|
|
@@ -3316,10 +3670,10 @@ declare module "bun" {
|
|
|
3316
3670
|
function color(
|
|
3317
3671
|
input: ColorInput,
|
|
3318
3672
|
outputFormat?: /**
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3673
|
+
* True color ANSI color string, for use in terminals
|
|
3674
|
+
* @example \x1b[38;2;100;200;200m
|
|
3675
|
+
*/
|
|
3676
|
+
| "ansi"
|
|
3323
3677
|
| "ansi-16"
|
|
3324
3678
|
| "ansi-16m"
|
|
3325
3679
|
/**
|
|
@@ -3887,6 +4241,9 @@ declare module "bun" {
|
|
|
3887
4241
|
static readonly byteLength: 32;
|
|
3888
4242
|
}
|
|
3889
4243
|
|
|
4244
|
+
/** Extends the standard web formats with `brotli` and `zstd` support. */
|
|
4245
|
+
type CompressionFormat = "gzip" | "deflate" | "deflate-raw" | "brotli" | "zstd";
|
|
4246
|
+
|
|
3890
4247
|
/** Compression options for `Bun.deflateSync` and `Bun.gzipSync` */
|
|
3891
4248
|
interface ZlibCompressionOptions {
|
|
3892
4249
|
/**
|
|
@@ -5287,6 +5644,67 @@ declare module "bun" {
|
|
|
5287
5644
|
ref(): void;
|
|
5288
5645
|
unref(): void;
|
|
5289
5646
|
close(): void;
|
|
5647
|
+
/**
|
|
5648
|
+
* Enable or disable SO_BROADCAST socket option.
|
|
5649
|
+
* @param enabled Whether to enable broadcast
|
|
5650
|
+
* @returns The enabled value
|
|
5651
|
+
*/
|
|
5652
|
+
setBroadcast(enabled: boolean): boolean;
|
|
5653
|
+
/**
|
|
5654
|
+
* Set the IP_TTL socket option.
|
|
5655
|
+
* @param ttl Time to live value
|
|
5656
|
+
* @returns The TTL value
|
|
5657
|
+
*/
|
|
5658
|
+
setTTL(ttl: number): number;
|
|
5659
|
+
/**
|
|
5660
|
+
* Set the IP_MULTICAST_TTL socket option.
|
|
5661
|
+
* @param ttl Time to live value for multicast packets
|
|
5662
|
+
* @returns The TTL value
|
|
5663
|
+
*/
|
|
5664
|
+
setMulticastTTL(ttl: number): number;
|
|
5665
|
+
/**
|
|
5666
|
+
* Enable or disable IP_MULTICAST_LOOP socket option.
|
|
5667
|
+
* @param enabled Whether to enable multicast loopback
|
|
5668
|
+
* @returns The enabled value
|
|
5669
|
+
*/
|
|
5670
|
+
setMulticastLoopback(enabled: boolean): boolean;
|
|
5671
|
+
/**
|
|
5672
|
+
* Set the IP_MULTICAST_IF socket option to specify the outgoing interface
|
|
5673
|
+
* for multicast packets.
|
|
5674
|
+
* @param interfaceAddress The address of the interface to use
|
|
5675
|
+
* @returns true on success
|
|
5676
|
+
*/
|
|
5677
|
+
setMulticastInterface(interfaceAddress: string): boolean;
|
|
5678
|
+
/**
|
|
5679
|
+
* Join a multicast group.
|
|
5680
|
+
* @param multicastAddress The multicast group address
|
|
5681
|
+
* @param interfaceAddress Optional interface address to use
|
|
5682
|
+
* @returns true on success
|
|
5683
|
+
*/
|
|
5684
|
+
addMembership(multicastAddress: string, interfaceAddress?: string): boolean;
|
|
5685
|
+
/**
|
|
5686
|
+
* Leave a multicast group.
|
|
5687
|
+
* @param multicastAddress The multicast group address
|
|
5688
|
+
* @param interfaceAddress Optional interface address to use
|
|
5689
|
+
* @returns true on success
|
|
5690
|
+
*/
|
|
5691
|
+
dropMembership(multicastAddress: string, interfaceAddress?: string): boolean;
|
|
5692
|
+
/**
|
|
5693
|
+
* Join a source-specific multicast group.
|
|
5694
|
+
* @param sourceAddress The source address
|
|
5695
|
+
* @param groupAddress The multicast group address
|
|
5696
|
+
* @param interfaceAddress Optional interface address to use
|
|
5697
|
+
* @returns true on success
|
|
5698
|
+
*/
|
|
5699
|
+
addSourceSpecificMembership(sourceAddress: string, groupAddress: string, interfaceAddress?: string): boolean;
|
|
5700
|
+
/**
|
|
5701
|
+
* Leave a source-specific multicast group.
|
|
5702
|
+
* @param sourceAddress The source address
|
|
5703
|
+
* @param groupAddress The multicast group address
|
|
5704
|
+
* @param interfaceAddress Optional interface address to use
|
|
5705
|
+
* @returns true on success
|
|
5706
|
+
*/
|
|
5707
|
+
dropSourceSpecificMembership(sourceAddress: string, groupAddress: string, interfaceAddress?: string): boolean;
|
|
5290
5708
|
}
|
|
5291
5709
|
|
|
5292
5710
|
export interface ConnectedSocket<DataBinaryType extends BinaryType> extends BaseUDPSocket {
|
|
@@ -5650,17 +6068,11 @@ declare module "bun" {
|
|
|
5650
6068
|
maxBuffer?: number;
|
|
5651
6069
|
}
|
|
5652
6070
|
|
|
5653
|
-
interface SpawnSyncOptions<In extends Writable, Out extends Readable, Err extends Readable>
|
|
5654
|
-
In,
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
interface SpawnOptions<In extends Writable, Out extends Readable, Err extends Readable> extends BaseOptions<
|
|
5660
|
-
In,
|
|
5661
|
-
Out,
|
|
5662
|
-
Err
|
|
5663
|
-
> {
|
|
6071
|
+
interface SpawnSyncOptions<In extends Writable, Out extends Readable, Err extends Readable>
|
|
6072
|
+
extends BaseOptions<In, Out, Err> {}
|
|
6073
|
+
|
|
6074
|
+
interface SpawnOptions<In extends Writable, Out extends Readable, Err extends Readable>
|
|
6075
|
+
extends BaseOptions<In, Out, Err> {
|
|
5664
6076
|
/**
|
|
5665
6077
|
* If true, stdout and stderr pipes will not automatically start reading
|
|
5666
6078
|
* data. Reading will only begin when you access the `stdout` or `stderr`
|
|
@@ -5682,6 +6094,44 @@ declare module "bun" {
|
|
|
5682
6094
|
* ```
|
|
5683
6095
|
*/
|
|
5684
6096
|
lazy?: boolean;
|
|
6097
|
+
|
|
6098
|
+
/**
|
|
6099
|
+
* Spawn the subprocess with a pseudo-terminal (PTY) attached.
|
|
6100
|
+
*
|
|
6101
|
+
* When this option is provided:
|
|
6102
|
+
* - `stdin`, `stdout`, and `stderr` are all connected to the terminal
|
|
6103
|
+
* - The subprocess sees itself running in a real terminal (`isTTY = true`)
|
|
6104
|
+
* - Access the terminal via `subprocess.terminal`
|
|
6105
|
+
* - `subprocess.stdin`, `subprocess.stdout`, `subprocess.stderr` return `null`
|
|
6106
|
+
*
|
|
6107
|
+
* Only available on POSIX systems (Linux, macOS).
|
|
6108
|
+
*
|
|
6109
|
+
* @example
|
|
6110
|
+
* ```ts
|
|
6111
|
+
* const proc = Bun.spawn(["bash"], {
|
|
6112
|
+
* terminal: {
|
|
6113
|
+
* cols: 80,
|
|
6114
|
+
* rows: 24,
|
|
6115
|
+
* data: (term, data) => console.log(data.toString()),
|
|
6116
|
+
* },
|
|
6117
|
+
* });
|
|
6118
|
+
*
|
|
6119
|
+
* proc.terminal.write("echo hello\n");
|
|
6120
|
+
* await proc.exited;
|
|
6121
|
+
* proc.terminal.close();
|
|
6122
|
+
* ```
|
|
6123
|
+
*
|
|
6124
|
+
* You can also pass an existing `Terminal` object for reuse across multiple spawns:
|
|
6125
|
+
* ```ts
|
|
6126
|
+
* const terminal = new Bun.Terminal({ ... });
|
|
6127
|
+
* const proc1 = Bun.spawn(["echo", "first"], { terminal });
|
|
6128
|
+
* await proc1.exited;
|
|
6129
|
+
* const proc2 = Bun.spawn(["echo", "second"], { terminal });
|
|
6130
|
+
* await proc2.exited;
|
|
6131
|
+
* terminal.close();
|
|
6132
|
+
* ```
|
|
6133
|
+
*/
|
|
6134
|
+
terminal?: TerminalOptions | Terminal;
|
|
5685
6135
|
}
|
|
5686
6136
|
|
|
5687
6137
|
type ReadableToIO<X extends Readable> = X extends "pipe" | undefined
|
|
@@ -5796,6 +6246,24 @@ declare module "bun" {
|
|
|
5796
6246
|
readonly stdout: SpawnOptions.ReadableToIO<Out>;
|
|
5797
6247
|
readonly stderr: SpawnOptions.ReadableToIO<Err>;
|
|
5798
6248
|
|
|
6249
|
+
/**
|
|
6250
|
+
* The terminal attached to this subprocess, if spawned with the `terminal` option.
|
|
6251
|
+
* Returns `undefined` if no terminal was attached.
|
|
6252
|
+
*
|
|
6253
|
+
* When a terminal is attached, `stdin`, `stdout`, and `stderr` return `null`.
|
|
6254
|
+
* Use `terminal.write()` and the `data` callback instead.
|
|
6255
|
+
*
|
|
6256
|
+
* @example
|
|
6257
|
+
* ```ts
|
|
6258
|
+
* const proc = Bun.spawn(["bash"], {
|
|
6259
|
+
* terminal: { data: (term, data) => console.log(data.toString()) },
|
|
6260
|
+
* });
|
|
6261
|
+
*
|
|
6262
|
+
* proc.terminal?.write("echo hello\n");
|
|
6263
|
+
* ```
|
|
6264
|
+
*/
|
|
6265
|
+
readonly terminal: Terminal | undefined;
|
|
6266
|
+
|
|
5799
6267
|
/**
|
|
5800
6268
|
* Access extra file descriptors passed to the `stdio` option in the options object.
|
|
5801
6269
|
*/
|
|
@@ -6087,6 +6555,154 @@ declare module "bun" {
|
|
|
6087
6555
|
"ignore" | "inherit" | null | undefined
|
|
6088
6556
|
>;
|
|
6089
6557
|
|
|
6558
|
+
/**
|
|
6559
|
+
* Options for creating a pseudo-terminal (PTY).
|
|
6560
|
+
*/
|
|
6561
|
+
interface TerminalOptions {
|
|
6562
|
+
/**
|
|
6563
|
+
* Number of columns for the terminal.
|
|
6564
|
+
* @default 80
|
|
6565
|
+
*/
|
|
6566
|
+
cols?: number;
|
|
6567
|
+
/**
|
|
6568
|
+
* Number of rows for the terminal.
|
|
6569
|
+
* @default 24
|
|
6570
|
+
*/
|
|
6571
|
+
rows?: number;
|
|
6572
|
+
/**
|
|
6573
|
+
* Terminal name (e.g., "xterm-256color").
|
|
6574
|
+
* @default "xterm-256color"
|
|
6575
|
+
*/
|
|
6576
|
+
name?: string;
|
|
6577
|
+
/**
|
|
6578
|
+
* Callback invoked when data is received from the terminal.
|
|
6579
|
+
* @param terminal The terminal instance
|
|
6580
|
+
* @param data The data received as a Uint8Array
|
|
6581
|
+
*/
|
|
6582
|
+
data?: (terminal: Terminal, data: Uint8Array<ArrayBuffer>) => void;
|
|
6583
|
+
/**
|
|
6584
|
+
* Callback invoked when the PTY stream closes (EOF or read error).
|
|
6585
|
+
* Note: exitCode is a PTY lifecycle status (0=clean EOF, 1=error), NOT the subprocess exit code.
|
|
6586
|
+
* Use Subprocess.exited or onExit callback for actual process exit information.
|
|
6587
|
+
* @param terminal The terminal instance
|
|
6588
|
+
* @param exitCode PTY lifecycle status (0 for EOF, 1 for error)
|
|
6589
|
+
* @param signal Reserved for future signal reporting, currently null
|
|
6590
|
+
*/
|
|
6591
|
+
exit?: (terminal: Terminal, exitCode: number, signal: string | null) => void;
|
|
6592
|
+
/**
|
|
6593
|
+
* Callback invoked when the terminal is ready to receive more data.
|
|
6594
|
+
* @param terminal The terminal instance
|
|
6595
|
+
*/
|
|
6596
|
+
drain?: (terminal: Terminal) => void;
|
|
6597
|
+
}
|
|
6598
|
+
|
|
6599
|
+
/**
|
|
6600
|
+
* A pseudo-terminal (PTY) that can be used to spawn interactive terminal programs.
|
|
6601
|
+
*
|
|
6602
|
+
* @example
|
|
6603
|
+
* ```ts
|
|
6604
|
+
* await using terminal = new Bun.Terminal({
|
|
6605
|
+
* cols: 80,
|
|
6606
|
+
* rows: 24,
|
|
6607
|
+
* data(term, data) {
|
|
6608
|
+
* console.log("Received:", new TextDecoder().decode(data));
|
|
6609
|
+
* },
|
|
6610
|
+
* });
|
|
6611
|
+
*
|
|
6612
|
+
* // Spawn a shell connected to the PTY
|
|
6613
|
+
* const proc = Bun.spawn(["bash"], { terminal });
|
|
6614
|
+
*
|
|
6615
|
+
* // Write to the terminal
|
|
6616
|
+
* terminal.write("echo hello\n");
|
|
6617
|
+
*
|
|
6618
|
+
* // Wait for process to exit
|
|
6619
|
+
* await proc.exited;
|
|
6620
|
+
*
|
|
6621
|
+
* // Terminal is closed automatically by `await using`
|
|
6622
|
+
* ```
|
|
6623
|
+
*/
|
|
6624
|
+
class Terminal implements AsyncDisposable {
|
|
6625
|
+
constructor(options: TerminalOptions);
|
|
6626
|
+
|
|
6627
|
+
/**
|
|
6628
|
+
* Whether the terminal is closed.
|
|
6629
|
+
*/
|
|
6630
|
+
readonly closed: boolean;
|
|
6631
|
+
|
|
6632
|
+
/**
|
|
6633
|
+
* Write data to the terminal.
|
|
6634
|
+
* @param data The data to write (string or BufferSource)
|
|
6635
|
+
* @returns The number of bytes written
|
|
6636
|
+
*/
|
|
6637
|
+
write(data: string | BufferSource): number;
|
|
6638
|
+
|
|
6639
|
+
/**
|
|
6640
|
+
* Resize the terminal.
|
|
6641
|
+
* @param cols New number of columns
|
|
6642
|
+
* @param rows New number of rows
|
|
6643
|
+
*/
|
|
6644
|
+
resize(cols: number, rows: number): void;
|
|
6645
|
+
|
|
6646
|
+
/**
|
|
6647
|
+
* Set raw mode on the terminal.
|
|
6648
|
+
* In raw mode, input is passed directly without processing.
|
|
6649
|
+
* @param enabled Whether to enable raw mode
|
|
6650
|
+
*/
|
|
6651
|
+
setRawMode(enabled: boolean): void;
|
|
6652
|
+
|
|
6653
|
+
/**
|
|
6654
|
+
* Reference the terminal to keep the event loop alive.
|
|
6655
|
+
*/
|
|
6656
|
+
ref(): void;
|
|
6657
|
+
|
|
6658
|
+
/**
|
|
6659
|
+
* Unreference the terminal to allow the event loop to exit.
|
|
6660
|
+
*/
|
|
6661
|
+
unref(): void;
|
|
6662
|
+
|
|
6663
|
+
/**
|
|
6664
|
+
* Close the terminal.
|
|
6665
|
+
*/
|
|
6666
|
+
close(): void;
|
|
6667
|
+
|
|
6668
|
+
/**
|
|
6669
|
+
* Async dispose for use with `await using`.
|
|
6670
|
+
*/
|
|
6671
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
6672
|
+
|
|
6673
|
+
/**
|
|
6674
|
+
* Terminal input flags (c_iflag from termios).
|
|
6675
|
+
* Controls input processing behavior like ICRNL, IXON, etc.
|
|
6676
|
+
* Returns 0 if terminal is closed.
|
|
6677
|
+
* Setting returns true on success, false on failure.
|
|
6678
|
+
*/
|
|
6679
|
+
inputFlags: number;
|
|
6680
|
+
|
|
6681
|
+
/**
|
|
6682
|
+
* Terminal output flags (c_oflag from termios).
|
|
6683
|
+
* Controls output processing behavior like OPOST, ONLCR, etc.
|
|
6684
|
+
* Returns 0 if terminal is closed.
|
|
6685
|
+
* Setting returns true on success, false on failure.
|
|
6686
|
+
*/
|
|
6687
|
+
outputFlags: number;
|
|
6688
|
+
|
|
6689
|
+
/**
|
|
6690
|
+
* Terminal local flags (c_lflag from termios).
|
|
6691
|
+
* Controls local processing like ICANON, ECHO, ISIG, etc.
|
|
6692
|
+
* Returns 0 if terminal is closed.
|
|
6693
|
+
* Setting returns true on success, false on failure.
|
|
6694
|
+
*/
|
|
6695
|
+
localFlags: number;
|
|
6696
|
+
|
|
6697
|
+
/**
|
|
6698
|
+
* Terminal control flags (c_cflag from termios).
|
|
6699
|
+
* Controls hardware characteristics like CSIZE, PARENB, etc.
|
|
6700
|
+
* Returns 0 if terminal is closed.
|
|
6701
|
+
* Setting returns true on success, false on failure.
|
|
6702
|
+
*/
|
|
6703
|
+
controlFlags: number;
|
|
6704
|
+
}
|
|
6705
|
+
|
|
6090
6706
|
// Blocked on https://github.com/oven-sh/bun/issues/8329
|
|
6091
6707
|
// /**
|
|
6092
6708
|
// *
|
package/lib/bundle.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `bun:bundle` module provides compile-time utilities for dead-code elimination.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { feature } from "bun:bundle";
|
|
7
|
+
*
|
|
8
|
+
* if (feature("SUPER_SECRET")) {
|
|
9
|
+
* console.log("Secret feature enabled!");
|
|
10
|
+
* } else {
|
|
11
|
+
* console.log("Normal mode");
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Enable feature flags via CLI:
|
|
16
|
+
* ```bash
|
|
17
|
+
* # During build
|
|
18
|
+
* bun build --feature=SUPER_SECRET index.ts
|
|
19
|
+
*
|
|
20
|
+
* # At runtime
|
|
21
|
+
* bun run --feature=SUPER_SECRET index.ts
|
|
22
|
+
*
|
|
23
|
+
* # In tests
|
|
24
|
+
* bun test --feature=SUPER_SECRET
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @module bun:bundle
|
|
28
|
+
*/
|
|
29
|
+
declare module "bun:bundle" {
|
|
30
|
+
/**
|
|
31
|
+
* Registry for type-safe feature flags.
|
|
32
|
+
*
|
|
33
|
+
* Augment this interface to get autocomplete and type checking for your feature flags:
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* // env.d.ts
|
|
38
|
+
* declare module "bun:bundle" {
|
|
39
|
+
* interface Registry {
|
|
40
|
+
* features: "DEBUG" | "PREMIUM" | "BETA";
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Now `feature()` only accepts `"DEBUG"`, `"PREMIUM"`, or `"BETA"`:
|
|
46
|
+
* ```ts
|
|
47
|
+
* feature("DEBUG"); // OK
|
|
48
|
+
* feature("TYPO"); // Type error
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
interface Registry {}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Check if a feature flag is enabled at compile time.
|
|
55
|
+
*
|
|
56
|
+
* This function is replaced with a boolean literal (`true` or `false`) at bundle time,
|
|
57
|
+
* enabling dead-code elimination. The bundler will remove unreachable branches.
|
|
58
|
+
*
|
|
59
|
+
* @param flag - The name of the feature flag to check
|
|
60
|
+
* @returns `true` if the flag was passed via `--feature=FLAG`, `false` otherwise
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { feature } from "bun:bundle";
|
|
65
|
+
*
|
|
66
|
+
* // With --feature=DEBUG, this becomes: if (true) { ... }
|
|
67
|
+
* // Without --feature=DEBUG, this becomes: if (false) { ... }
|
|
68
|
+
* if (feature("DEBUG")) {
|
|
69
|
+
* console.log("Debug mode enabled");
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
function feature(flag: Registry extends { features: infer Features extends string } ? Features : string): boolean;
|
|
74
|
+
}
|
package/lib/globals.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
declare module "bun" {
|
|
2
2
|
namespace __internal {
|
|
3
|
-
type NodeCryptoWebcryptoSubtleCrypto = import("crypto").webcrypto.SubtleCrypto;
|
|
4
3
|
type NodeCryptoWebcryptoCryptoKey = import("crypto").webcrypto.CryptoKey;
|
|
5
4
|
type NodeCryptoWebcryptoCryptoKeyPair = import("crypto").webcrypto.CryptoKeyPair;
|
|
6
5
|
|
|
6
|
+
type LibEmptyOrNodeCryptoWebcryptoSubtleCrypto = LibDomIsLoaded extends true
|
|
7
|
+
? {}
|
|
8
|
+
: import("crypto").webcrypto.SubtleCrypto;
|
|
9
|
+
|
|
7
10
|
type LibWorkerOrBunWorker = LibDomIsLoaded extends true ? {} : Bun.Worker;
|
|
8
11
|
type LibEmptyOrBunWebSocket = LibDomIsLoaded extends true ? {} : Bun.WebSocket;
|
|
9
12
|
|
|
@@ -14,7 +17,9 @@ declare module "bun" {
|
|
|
14
17
|
? {}
|
|
15
18
|
: import("node:stream/web").DecompressionStream;
|
|
16
19
|
|
|
17
|
-
type LibPerformanceOrNodePerfHooksPerformance = LibDomIsLoaded extends true
|
|
20
|
+
type LibPerformanceOrNodePerfHooksPerformance = LibDomIsLoaded extends true
|
|
21
|
+
? {}
|
|
22
|
+
: import("node:perf_hooks").Performance;
|
|
18
23
|
type LibEmptyOrPerformanceEntry = LibDomIsLoaded extends true ? {} : import("node:perf_hooks").PerformanceEntry;
|
|
19
24
|
type LibEmptyOrPerformanceMark = LibDomIsLoaded extends true ? {} : import("node:perf_hooks").PerformanceMark;
|
|
20
25
|
type LibEmptyOrPerformanceMeasure = LibDomIsLoaded extends true ? {} : import("node:perf_hooks").PerformanceMeasure;
|
package/lib/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
/// <reference path="./serve.d.ts" />
|
|
21
21
|
/// <reference path="./sql.d.ts" />
|
|
22
22
|
/// <reference path="./security.d.ts" />
|
|
23
|
+
/// <reference path="./bundle.d.ts" />
|
|
23
24
|
/// <reference path="./bun.ns.d.ts" />
|
|
24
25
|
// Must disable this so it doesn't conflict with the DOM onmessage type, but still
|
|
25
26
|
// allows us to declare our own globals that Node's types can "see" and not conflict with
|
package/lib/overrides.d.ts
CHANGED
|
@@ -36,10 +36,10 @@ declare module "url" {
|
|
|
36
36
|
toJSON(): Record<string, string>;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
declare module "fs/promises" {
|
|
39
|
+
declare module "node:fs/promises" {
|
|
40
40
|
function exists(path: Bun.PathLike): Promise<boolean>;
|
|
41
41
|
}
|
|
42
|
-
declare module "tls" {
|
|
42
|
+
declare module "node:tls" {
|
|
43
43
|
interface BunConnectionOptions extends Omit<ConnectionOptions, "key" | "ca" | "tls" | "cert"> {
|
|
44
44
|
/**
|
|
45
45
|
* Optionally override the trusted CA certificates. Default is to trust
|
|
@@ -85,4 +85,18 @@ declare module "tls" {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
function connect(options: BunConnectionOptions, secureConnectListener?: () => void): TLSSocket;
|
|
88
|
+
}
|
|
89
|
+
declare module "console" {
|
|
90
|
+
interface Console {
|
|
91
|
+
/**
|
|
92
|
+
* Asynchronously read lines from standard input (fd 0)
|
|
93
|
+
*
|
|
94
|
+
* ```ts
|
|
95
|
+
* for await (const line of console) {
|
|
96
|
+
* console.log(line);
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<string>;
|
|
101
|
+
}
|
|
88
102
|
}
|
package/lib/s3.d.ts
CHANGED
|
@@ -281,6 +281,24 @@ declare module "bun" {
|
|
|
281
281
|
*/
|
|
282
282
|
type?: string;
|
|
283
283
|
|
|
284
|
+
/**
|
|
285
|
+
* The Content-Disposition header value.
|
|
286
|
+
* Controls how the file is presented when downloaded.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* // Setting attachment disposition with filename
|
|
290
|
+
* const file = s3.file("report.pdf", {
|
|
291
|
+
* contentDisposition: "attachment; filename=\"quarterly-report.pdf\""
|
|
292
|
+
* });
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* // Setting inline disposition
|
|
296
|
+
* await s3.write("image.png", imageData, {
|
|
297
|
+
* contentDisposition: "inline"
|
|
298
|
+
* });
|
|
299
|
+
*/
|
|
300
|
+
contentDisposition?: string | undefined;
|
|
301
|
+
|
|
284
302
|
/**
|
|
285
303
|
* By default, Amazon S3 uses the STANDARD Storage Class to store newly created objects.
|
|
286
304
|
*
|
|
@@ -303,6 +321,30 @@ declare module "bun" {
|
|
|
303
321
|
| "SNOW"
|
|
304
322
|
| "STANDARD_IA";
|
|
305
323
|
|
|
324
|
+
/**
|
|
325
|
+
* When set to `true`, confirms that the requester knows they will be charged
|
|
326
|
+
* for the request and data transfer costs. Required for accessing objects
|
|
327
|
+
* in Requester Pays buckets.
|
|
328
|
+
*
|
|
329
|
+
* @see https://docs.aws.amazon.com/AmazonS3/latest/userguide/RequesterPaysBuckets.html
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* // Accessing a file in a Requester Pays bucket
|
|
333
|
+
* const file = s3.file("data.csv", {
|
|
334
|
+
* bucket: "requester-pays-bucket",
|
|
335
|
+
* requestPayer: true
|
|
336
|
+
* });
|
|
337
|
+
* const content = await file.text();
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* // Uploading to a Requester Pays bucket
|
|
341
|
+
* await s3.write("output.json", data, {
|
|
342
|
+
* bucket: "requester-pays-bucket",
|
|
343
|
+
* requestPayer: true
|
|
344
|
+
* });
|
|
345
|
+
*/
|
|
346
|
+
requestPayer?: boolean;
|
|
347
|
+
|
|
306
348
|
/**
|
|
307
349
|
* @deprecated The size of the internal buffer in bytes. Defaults to 5 MiB. use `partSize` and `queueSize` instead.
|
|
308
350
|
*/
|
package/lib/sqlite.d.ts
CHANGED
|
@@ -154,12 +154,6 @@ declare module "bun:sqlite" {
|
|
|
154
154
|
* | `bigint` | `INTEGER` |
|
|
155
155
|
* | `null` | `NULL` |
|
|
156
156
|
*
|
|
157
|
-
* @example
|
|
158
|
-
* ```ts
|
|
159
|
-
* db.run("CREATE TABLE foo (bar TEXT)");
|
|
160
|
-
* db.run("INSERT INTO foo VALUES (?)", ["baz"]);
|
|
161
|
-
* ```
|
|
162
|
-
*
|
|
163
157
|
* Useful for queries like:
|
|
164
158
|
* - `CREATE TABLE`
|
|
165
159
|
* - `INSERT INTO`
|
|
@@ -180,8 +174,14 @@ declare module "bun:sqlite" {
|
|
|
180
174
|
*
|
|
181
175
|
* @param sql The SQL query to run
|
|
182
176
|
* @param bindings Optional bindings for the query
|
|
177
|
+
* @returns A `Changes` object with `changes` and `lastInsertRowid` properties
|
|
183
178
|
*
|
|
184
|
-
* @
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* db.run("CREATE TABLE foo (bar TEXT)");
|
|
182
|
+
* db.run("INSERT INTO foo VALUES (?)", ["baz"]);
|
|
183
|
+
* // => { changes: 1, lastInsertRowid: 1 }
|
|
184
|
+
* ```
|
|
185
185
|
*/
|
|
186
186
|
run<ParamsType extends SQLQueryBindings[]>(sql: string, ...bindings: ParamsType[]): Changes;
|
|
187
187
|
|
|
@@ -670,18 +670,19 @@ declare module "bun:sqlite" {
|
|
|
670
670
|
* Execute the prepared statement.
|
|
671
671
|
*
|
|
672
672
|
* @param params optional values to bind to the statement. If omitted, the statement is run with the last bound values or no parameters if there are none.
|
|
673
|
+
* @returns A `Changes` object with `changes` and `lastInsertRowid` properties
|
|
673
674
|
*
|
|
674
675
|
* @example
|
|
675
676
|
* ```ts
|
|
676
|
-
* const
|
|
677
|
-
*
|
|
678
|
-
* // =>
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
683
|
-
*
|
|
684
|
-
* // =>
|
|
677
|
+
* const insert = db.prepare("INSERT INTO users (name) VALUES (?)");
|
|
678
|
+
* insert.run("Alice");
|
|
679
|
+
* // => { changes: 1, lastInsertRowid: 1 }
|
|
680
|
+
* insert.run("Bob");
|
|
681
|
+
* // => { changes: 1, lastInsertRowid: 2 }
|
|
682
|
+
*
|
|
683
|
+
* const update = db.prepare("UPDATE users SET name = ? WHERE id = ?");
|
|
684
|
+
* update.run("Charlie", 1);
|
|
685
|
+
* // => { changes: 1, lastInsertRowid: 2 }
|
|
685
686
|
* ```
|
|
686
687
|
*
|
|
687
688
|
* The following types can be used when binding parameters:
|
package/lib/test.d.ts
CHANGED
|
@@ -428,6 +428,8 @@ declare module "bun:test" {
|
|
|
428
428
|
}
|
|
429
429
|
|
|
430
430
|
namespace __internal {
|
|
431
|
+
type IfNeverThenElse<T, Else> = [T] extends [never] ? Else : T;
|
|
432
|
+
|
|
431
433
|
type IsTuple<T> = T extends readonly unknown[]
|
|
432
434
|
? number extends T["length"]
|
|
433
435
|
? false // It's an array with unknown length, not a tuple
|
|
@@ -1097,8 +1099,8 @@ declare module "bun:test" {
|
|
|
1097
1099
|
*
|
|
1098
1100
|
* @param expected the expected value
|
|
1099
1101
|
*/
|
|
1100
|
-
toContainKey(expected: keyof T): void;
|
|
1101
|
-
toContainKey<X = T>(expected: NoInfer<keyof X>): void;
|
|
1102
|
+
toContainKey(expected: __internal.IfNeverThenElse<keyof T, PropertyKey>): void;
|
|
1103
|
+
toContainKey<X = T>(expected: __internal.IfNeverThenElse<NoInfer<keyof X>, PropertyKey>): void;
|
|
1102
1104
|
|
|
1103
1105
|
/**
|
|
1104
1106
|
* Asserts that an `object` contains all the provided keys.
|
|
@@ -1114,8 +1116,8 @@ declare module "bun:test" {
|
|
|
1114
1116
|
*
|
|
1115
1117
|
* @param expected the expected value
|
|
1116
1118
|
*/
|
|
1117
|
-
toContainAllKeys(expected: Array<keyof T
|
|
1118
|
-
toContainAllKeys<X = T>(expected: NoInfer<
|
|
1119
|
+
toContainAllKeys(expected: Array<__internal.IfNeverThenElse<keyof T, PropertyKey>>): void;
|
|
1120
|
+
toContainAllKeys<X = T>(expected: Array<__internal.IfNeverThenElse<NoInfer<keyof X>, PropertyKey>>): void;
|
|
1119
1121
|
|
|
1120
1122
|
/**
|
|
1121
1123
|
* Asserts that an `object` contains at least one of the provided keys.
|
|
@@ -1131,8 +1133,8 @@ declare module "bun:test" {
|
|
|
1131
1133
|
*
|
|
1132
1134
|
* @param expected the expected value
|
|
1133
1135
|
*/
|
|
1134
|
-
toContainAnyKeys(expected: Array<keyof T
|
|
1135
|
-
toContainAnyKeys<X = T>(expected: NoInfer<
|
|
1136
|
+
toContainAnyKeys(expected: Array<__internal.IfNeverThenElse<keyof T, PropertyKey>>): void;
|
|
1137
|
+
toContainAnyKeys<X = T>(expected: Array<__internal.IfNeverThenElse<NoInfer<keyof X>, PropertyKey>>): void;
|
|
1136
1138
|
|
|
1137
1139
|
/**
|
|
1138
1140
|
* Asserts that an `object` contain the provided value.
|
|
@@ -1224,8 +1226,8 @@ declare module "bun:test" {
|
|
|
1224
1226
|
*
|
|
1225
1227
|
* @param expected the expected value
|
|
1226
1228
|
*/
|
|
1227
|
-
toContainKeys(expected: Array<keyof T
|
|
1228
|
-
toContainKeys<X = T>(expected: NoInfer<
|
|
1229
|
+
toContainKeys(expected: Array<__internal.IfNeverThenElse<keyof T, PropertyKey>>): void;
|
|
1230
|
+
toContainKeys<X = T>(expected: Array<__internal.IfNeverThenElse<NoInfer<keyof X>, PropertyKey>>): void;
|
|
1229
1231
|
|
|
1230
1232
|
/**
|
|
1231
1233
|
* Asserts that a value contains and equals what is expected.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-types-no-globals",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6-canary.20260109T140758",
|
|
4
4
|
"main": "./generator/index.ts",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"description": "TypeScript type definitions for Bun without global types pollution",
|