bun-types 1.2.7 → 1.2.8-canary.20250328T140605
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/bun.d.ts +330 -226
- package/docs/api/fetch.md +1 -1
- package/docs/api/spawn.md +1 -1
- package/docs/api/sql.md +1 -1
- package/docs/cli/publish.md +1 -1
- package/docs/guides/ecosystem/nuxt.md +1 -1
- package/docs/guides/install/add-peer.md +2 -2
- package/docs/guides/install/from-npm-install-to-bun-install.md +1 -1
- package/docs/guides/test/run-tests.md +3 -3
- package/docs/guides/test/snapshot.md +3 -3
- package/docs/guides/test/update-snapshots.md +1 -1
- package/docs/guides/util/version.md +1 -1
- package/docs/installation.md +4 -4
- package/docs/project/contributing.md +10 -0
- package/docs/runtime/debugger.md +3 -3
- package/docs/runtime/nodejs-apis.md +1 -2
- package/docs/test/dom.md +1 -1
- package/ffi.d.ts +8 -1
- package/globals.d.ts +19 -1
- package/html-rewriter.d.ts +2 -0
- package/package.json +1 -1
- package/s3.d.ts +6 -0
- package/sqlite.d.ts +4 -0
- package/test.d.ts +6 -0
package/bun.d.ts
CHANGED
|
@@ -511,7 +511,7 @@ declare module "bun" {
|
|
|
511
511
|
threadId: number;
|
|
512
512
|
}
|
|
513
513
|
|
|
514
|
-
interface Env {
|
|
514
|
+
interface Env extends NodeJS.ProcessEnv {
|
|
515
515
|
NODE_ENV?: string;
|
|
516
516
|
/**
|
|
517
517
|
* Can be used to change the default timezone at runtime
|
|
@@ -526,7 +526,8 @@ declare module "bun" {
|
|
|
526
526
|
*
|
|
527
527
|
* Changes to `process.env` at runtime won't automatically be reflected in the default value. For that, you can pass `process.env` explicitly.
|
|
528
528
|
*/
|
|
529
|
-
const env:
|
|
529
|
+
const env: Env;
|
|
530
|
+
|
|
530
531
|
/**
|
|
531
532
|
* The raw arguments passed to the process, including flags passed to Bun. If you want to easily read flags passed to your script, consider using `process.argv` instead.
|
|
532
533
|
*/
|
|
@@ -536,9 +537,11 @@ declare module "bun" {
|
|
|
536
537
|
/**
|
|
537
538
|
* Find the path to an executable, similar to typing which in your terminal. Reads the `PATH` environment variable unless overridden with `options.PATH`.
|
|
538
539
|
*
|
|
539
|
-
* @
|
|
540
|
-
*
|
|
541
|
-
* @param
|
|
540
|
+
* @category Utilities
|
|
541
|
+
*
|
|
542
|
+
* @param command The name of the executable or script
|
|
543
|
+
* @param options.PATH Overrides the PATH environment variable
|
|
544
|
+
* @param options.cwd When given a relative path, use this path to join it.
|
|
542
545
|
*/
|
|
543
546
|
function which(command: string, options?: { PATH?: string; cwd?: string }): string | null;
|
|
544
547
|
|
|
@@ -944,19 +947,24 @@ declare module "bun" {
|
|
|
944
947
|
blob(): Blob;
|
|
945
948
|
}
|
|
946
949
|
|
|
950
|
+
/**
|
|
951
|
+
* The Bun shell
|
|
952
|
+
*
|
|
953
|
+
* @category Process Management
|
|
954
|
+
*/
|
|
947
955
|
const $: Shell;
|
|
948
956
|
|
|
949
|
-
|
|
957
|
+
const TOML: {
|
|
950
958
|
/**
|
|
951
959
|
* Parse a TOML string into a JavaScript object.
|
|
952
960
|
*
|
|
953
|
-
* @
|
|
954
|
-
*
|
|
955
|
-
* @param
|
|
961
|
+
* @category Utilities
|
|
962
|
+
*
|
|
963
|
+
* @param input The TOML string to parse
|
|
964
|
+
* @returns A JavaScript object
|
|
956
965
|
*/
|
|
957
966
|
parse(input: string): object;
|
|
958
|
-
}
|
|
959
|
-
const TOML: TOML;
|
|
967
|
+
};
|
|
960
968
|
|
|
961
969
|
/**
|
|
962
970
|
* Synchronously resolve a `moduleId` as though it were imported from `parent`
|
|
@@ -979,6 +987,8 @@ declare module "bun" {
|
|
|
979
987
|
*
|
|
980
988
|
* If `destination` exists, it must be a regular file or symlink to a file. If `destination`'s directory does not exist, it will be created by default.
|
|
981
989
|
*
|
|
990
|
+
* @category File System
|
|
991
|
+
*
|
|
982
992
|
* @param destination The file or file path to write to
|
|
983
993
|
* @param input The data to copy into `destination`.
|
|
984
994
|
* @returns A promise that resolves with the number of bytes written.
|
|
@@ -1270,6 +1280,8 @@ declare module "bun" {
|
|
|
1270
1280
|
/**
|
|
1271
1281
|
* Escape the following characters in a string:
|
|
1272
1282
|
*
|
|
1283
|
+
* @category Security
|
|
1284
|
+
*
|
|
1273
1285
|
* - `"` becomes `"""`
|
|
1274
1286
|
* - `&` becomes `"&"`
|
|
1275
1287
|
* - `'` becomes `"'"`
|
|
@@ -1290,6 +1302,8 @@ declare module "bun" {
|
|
|
1290
1302
|
* @param path The path to convert.
|
|
1291
1303
|
* @returns A {@link URL} with the file:// scheme.
|
|
1292
1304
|
*
|
|
1305
|
+
* @category File System
|
|
1306
|
+
*
|
|
1293
1307
|
* @example
|
|
1294
1308
|
* ```js
|
|
1295
1309
|
* const url = Bun.pathToFileURL("/foo/bar.txt");
|
|
@@ -1312,9 +1326,13 @@ declare module "bun" {
|
|
|
1312
1326
|
|
|
1313
1327
|
/**
|
|
1314
1328
|
* Convert a {@link URL} to a filesystem path.
|
|
1329
|
+
*
|
|
1315
1330
|
* @param url The URL to convert.
|
|
1316
1331
|
* @returns A filesystem path.
|
|
1317
1332
|
* @throws If the URL is not a URL.
|
|
1333
|
+
*
|
|
1334
|
+
* @category File System
|
|
1335
|
+
*
|
|
1318
1336
|
* @example
|
|
1319
1337
|
* ```js
|
|
1320
1338
|
* const path = Bun.fileURLToPath(new URL("file:///foo/bar.txt"));
|
|
@@ -1522,6 +1540,8 @@ declare module "bun" {
|
|
|
1522
1540
|
* - `size` will not be valid until the contents of the file are read at least once.
|
|
1523
1541
|
* - `type` is auto-set based on the file extension when possible
|
|
1524
1542
|
*
|
|
1543
|
+
* @category File System
|
|
1544
|
+
*
|
|
1525
1545
|
* @example
|
|
1526
1546
|
* ```js
|
|
1527
1547
|
* const file = Bun.file("./hello.json");
|
|
@@ -1557,7 +1577,7 @@ declare module "bun" {
|
|
|
1557
1577
|
*
|
|
1558
1578
|
* Similar to [`TypedArray.subarray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray). Does not copy the file, open the file, or modify the file.
|
|
1559
1579
|
*
|
|
1560
|
-
* If `begin` > 0, {@link Bun.write()
|
|
1580
|
+
* If `begin` > 0, {@link Bun.write}() will be slower on macOS
|
|
1561
1581
|
*
|
|
1562
1582
|
* @param begin - start offset in bytes
|
|
1563
1583
|
* @param contentType - MIME type for the new BunFile
|
|
@@ -2039,10 +2059,32 @@ declare module "bun" {
|
|
|
2039
2059
|
verify(token: string, options?: CSRFVerifyOptions): boolean;
|
|
2040
2060
|
}
|
|
2041
2061
|
|
|
2062
|
+
/**
|
|
2063
|
+
* SQL client
|
|
2064
|
+
*
|
|
2065
|
+
* @category Database
|
|
2066
|
+
*/
|
|
2042
2067
|
var sql: SQL;
|
|
2068
|
+
|
|
2069
|
+
/**
|
|
2070
|
+
* SQL client for PostgreSQL
|
|
2071
|
+
*
|
|
2072
|
+
* @category Database
|
|
2073
|
+
*/
|
|
2043
2074
|
var postgres: SQL;
|
|
2075
|
+
|
|
2076
|
+
/**
|
|
2077
|
+
* The SQL constructor
|
|
2078
|
+
*
|
|
2079
|
+
* @category Database
|
|
2080
|
+
*/
|
|
2044
2081
|
var SQL: SQL;
|
|
2045
2082
|
|
|
2083
|
+
/**
|
|
2084
|
+
* Generate and verify CSRF tokens
|
|
2085
|
+
*
|
|
2086
|
+
* @category Security
|
|
2087
|
+
*/
|
|
2046
2088
|
var CSRF: CSRF;
|
|
2047
2089
|
|
|
2048
2090
|
/**
|
|
@@ -2509,6 +2551,15 @@ declare module "bun" {
|
|
|
2509
2551
|
throw?: boolean;
|
|
2510
2552
|
}
|
|
2511
2553
|
|
|
2554
|
+
/**
|
|
2555
|
+
* Hash and verify passwords using argon2 or bcrypt
|
|
2556
|
+
*
|
|
2557
|
+
* These are fast APIs that can run in a worker thread if used asynchronously.
|
|
2558
|
+
*
|
|
2559
|
+
* @see [Bun.password API docs](https://bun.sh/guides/util/hash-a-password)
|
|
2560
|
+
*
|
|
2561
|
+
* @category Security
|
|
2562
|
+
*/
|
|
2512
2563
|
namespace Password {
|
|
2513
2564
|
type AlgorithmLabel = "bcrypt" | "argon2id" | "argon2d" | "argon2i";
|
|
2514
2565
|
|
|
@@ -2539,6 +2590,10 @@ declare module "bun" {
|
|
|
2539
2590
|
* Password hashing functions are necessarily slow, and this object will
|
|
2540
2591
|
* automatically run in a worker thread.
|
|
2541
2592
|
*
|
|
2593
|
+
* @see [Bun.password API docs](https://bun.sh/guides/util/hash-a-password)
|
|
2594
|
+
*
|
|
2595
|
+
* @category Security
|
|
2596
|
+
*
|
|
2542
2597
|
* The underlying implementation of these functions are provided by the Zig
|
|
2543
2598
|
* Standard Library. Thanks to @jedisct1 and other Zig contributors for their
|
|
2544
2599
|
* work on this.
|
|
@@ -2723,6 +2778,11 @@ declare module "bun" {
|
|
|
2723
2778
|
): string;
|
|
2724
2779
|
};
|
|
2725
2780
|
|
|
2781
|
+
/**
|
|
2782
|
+
* A build artifact represents a file that was generated by the bundler @see {@link Bun.build}
|
|
2783
|
+
*
|
|
2784
|
+
* @category Bundler
|
|
2785
|
+
*/
|
|
2726
2786
|
interface BuildArtifact extends Blob {
|
|
2727
2787
|
path: string;
|
|
2728
2788
|
loader: Loader;
|
|
@@ -2731,6 +2791,11 @@ declare module "bun" {
|
|
|
2731
2791
|
sourcemap: BuildArtifact | null;
|
|
2732
2792
|
}
|
|
2733
2793
|
|
|
2794
|
+
/**
|
|
2795
|
+
* The output of a build
|
|
2796
|
+
*
|
|
2797
|
+
* @category Bundler
|
|
2798
|
+
*/
|
|
2734
2799
|
interface BuildOutput {
|
|
2735
2800
|
outputs: BuildArtifact[];
|
|
2736
2801
|
success: boolean;
|
|
@@ -2744,220 +2809,222 @@ declare module "bun" {
|
|
|
2744
2809
|
* @returns {Promise<BuildOutput>} Promise that resolves to build output containing generated artifacts and build status
|
|
2745
2810
|
* @throws {AggregateError} When build fails and config.throw is true (default in Bun 1.2+)
|
|
2746
2811
|
*
|
|
2812
|
+
* @category Bundler
|
|
2813
|
+
*
|
|
2747
2814
|
* @example Basic usage - Bundle a single entrypoint and check results
|
|
2748
|
-
```ts
|
|
2749
|
-
const result = await Bun.build({
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
});
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
```
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2815
|
+
* ```ts
|
|
2816
|
+
* const result = await Bun.build({
|
|
2817
|
+
* entrypoints: ['./src/index.tsx'],
|
|
2818
|
+
* outdir: './dist'
|
|
2819
|
+
* });
|
|
2820
|
+
*
|
|
2821
|
+
* if (!result.success) {
|
|
2822
|
+
* console.error('Build failed:', result.logs);
|
|
2823
|
+
* process.exit(1);
|
|
2824
|
+
* }
|
|
2825
|
+
* ```
|
|
2826
|
+
* *
|
|
2827
|
+
* * @example Set up multiple entrypoints with code splitting enabled
|
|
2828
|
+
* ```ts
|
|
2829
|
+
* await Bun.build({
|
|
2830
|
+
* entrypoints: ['./src/app.tsx', './src/admin.tsx'],
|
|
2831
|
+
* outdir: './dist',
|
|
2832
|
+
* splitting: true,
|
|
2833
|
+
* sourcemap: "external"
|
|
2834
|
+
* });
|
|
2835
|
+
* ```
|
|
2836
|
+
* *
|
|
2837
|
+
* * @example Configure minification and optimization settings
|
|
2838
|
+
* ```ts
|
|
2839
|
+
* await Bun.build({
|
|
2840
|
+
* entrypoints: ['./src/index.tsx'],
|
|
2841
|
+
* outdir: './dist',
|
|
2842
|
+
* minify: {
|
|
2843
|
+
* whitespace: true,
|
|
2844
|
+
* identifiers: true,
|
|
2845
|
+
* syntax: true
|
|
2846
|
+
* },
|
|
2847
|
+
* drop: ['console', 'debugger']
|
|
2848
|
+
* });
|
|
2849
|
+
* ```
|
|
2850
|
+
* *
|
|
2851
|
+
* * @example Set up custom loaders and mark packages as external
|
|
2852
|
+
* ```ts
|
|
2853
|
+
* await Bun.build({
|
|
2854
|
+
* entrypoints: ['./src/index.tsx'],
|
|
2855
|
+
* outdir: './dist',
|
|
2856
|
+
* loader: {
|
|
2857
|
+
* '.png': 'dataurl',
|
|
2858
|
+
* '.svg': 'file',
|
|
2859
|
+
* '.txt': 'text',
|
|
2860
|
+
* '.json': 'json'
|
|
2861
|
+
* },
|
|
2862
|
+
* external: ['react', 'react-dom']
|
|
2863
|
+
* });
|
|
2864
|
+
* ```
|
|
2865
|
+
* *
|
|
2866
|
+
* * @example Configure environment variable handling with different modes
|
|
2867
|
+
* ```ts
|
|
2868
|
+
* // Inline all environment variables
|
|
2869
|
+
* await Bun.build({
|
|
2870
|
+
* entrypoints: ['./src/index.tsx'],
|
|
2871
|
+
* outdir: './dist',
|
|
2872
|
+
* env: 'inline'
|
|
2873
|
+
* });
|
|
2874
|
+
|
|
2875
|
+
* // Only include specific env vars
|
|
2876
|
+
* await Bun.build({
|
|
2877
|
+
* entrypoints: ['./src/index.tsx'],
|
|
2878
|
+
* outdir: './dist',
|
|
2879
|
+
* env: 'PUBLIC_*'
|
|
2880
|
+
* });
|
|
2881
|
+
* ```
|
|
2882
|
+
* *
|
|
2883
|
+
* * @example Set up custom naming patterns for all output types
|
|
2884
|
+
* ```ts
|
|
2885
|
+
* await Bun.build({
|
|
2886
|
+
* entrypoints: ['./src/index.tsx'],
|
|
2887
|
+
* outdir: './dist',
|
|
2888
|
+
* naming: {
|
|
2889
|
+
* entry: '[dir]/[name]-[hash].[ext]',
|
|
2890
|
+
* chunk: 'chunks/[name]-[hash].[ext]',
|
|
2891
|
+
* asset: 'assets/[name]-[hash].[ext]'
|
|
2892
|
+
* }
|
|
2893
|
+
* });
|
|
2894
|
+
* ```
|
|
2895
|
+
* @example Work with build artifacts in different formats
|
|
2896
|
+
* ```ts
|
|
2897
|
+
* const result = await Bun.build({
|
|
2898
|
+
* entrypoints: ['./src/index.tsx']
|
|
2899
|
+
* });
|
|
2900
|
+
|
|
2901
|
+
* for (const artifact of result.outputs) {
|
|
2902
|
+
* const text = await artifact.text();
|
|
2903
|
+
* const buffer = await artifact.arrayBuffer();
|
|
2904
|
+
* const bytes = await artifact.bytes();
|
|
2905
|
+
|
|
2906
|
+
* new Response(artifact);
|
|
2907
|
+
* await Bun.write(artifact.path, artifact);
|
|
2908
|
+
* }
|
|
2909
|
+
* ```
|
|
2910
|
+
* @example Implement comprehensive error handling with position info
|
|
2911
|
+
* ```ts
|
|
2912
|
+
* try {
|
|
2913
|
+
* const result = await Bun.build({
|
|
2914
|
+
* entrypoints: ['./src/index.tsx'],
|
|
2915
|
+
* });
|
|
2916
|
+
* } catch (e) {
|
|
2917
|
+
* const error = e as AggregateError;
|
|
2918
|
+
* console.error('Build failed:');
|
|
2919
|
+
* for (const msg of error.errors) {
|
|
2920
|
+
* if ('position' in msg) {
|
|
2921
|
+
* console.error(
|
|
2922
|
+
* `${msg.message} at ${msg.position?.file}:${msg.position?.line}:${msg.position?.column}`
|
|
2923
|
+
* );
|
|
2924
|
+
* } else {
|
|
2925
|
+
* console.error(msg.message);
|
|
2926
|
+
* }
|
|
2927
|
+
* }
|
|
2928
|
+
* }
|
|
2929
|
+
* ```
|
|
2930
|
+
* @example Set up Node.js target with specific configurations
|
|
2931
|
+
* ```ts
|
|
2932
|
+
* await Bun.build({
|
|
2933
|
+
* entrypoints: ['./src/server.ts'],
|
|
2934
|
+
* outdir: './dist',
|
|
2935
|
+
* target: 'node',
|
|
2936
|
+
* format: 'cjs',
|
|
2937
|
+
* sourcemap: 'external',
|
|
2938
|
+
* minify: false,
|
|
2939
|
+
* packages: 'external'
|
|
2940
|
+
* });
|
|
2941
|
+
* ```
|
|
2942
|
+
* *
|
|
2943
|
+
* * @example Configure experimental CSS bundling with multiple themes
|
|
2944
|
+
* ```ts
|
|
2945
|
+
* await Bun.build({
|
|
2946
|
+
* entrypoints: [
|
|
2947
|
+
* './src/styles.css',
|
|
2948
|
+
* './src/themes/dark.css',
|
|
2949
|
+
* './src/themes/light.css'
|
|
2950
|
+
* ],
|
|
2951
|
+
* outdir: './dist/css',
|
|
2952
|
+
* });
|
|
2953
|
+
* ```
|
|
2954
|
+
* @example Define compile-time constants and version information
|
|
2955
|
+
* ```ts
|
|
2956
|
+
* await Bun.build({
|
|
2957
|
+
* entrypoints: ['./src/index.tsx'],
|
|
2958
|
+
* outdir: './dist',
|
|
2959
|
+
* define: {
|
|
2960
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
2961
|
+
* 'CONSTANTS.VERSION': JSON.stringify('1.0.0'),
|
|
2962
|
+
* 'CONSTANTS.BUILD_TIME': JSON.stringify(new Date().toISOString())
|
|
2963
|
+
* }
|
|
2964
|
+
* });
|
|
2965
|
+
* ```
|
|
2966
|
+
* @example Create a custom plugin for handling special file types
|
|
2967
|
+
* ```ts
|
|
2968
|
+
* await Bun.build({
|
|
2969
|
+
* entrypoints: ['./src/index.tsx'],
|
|
2970
|
+
* outdir: './dist',
|
|
2971
|
+
* plugins: [
|
|
2972
|
+
* {
|
|
2973
|
+
* name: 'my-plugin',
|
|
2974
|
+
* setup(build) {
|
|
2975
|
+
* build.onLoad({ filter: /\.custom$/ }, async (args) => {
|
|
2976
|
+
* const content = await Bun.file(args.path).text();
|
|
2977
|
+
* return {
|
|
2978
|
+
* contents: `export default ${JSON.stringify(content)}`,
|
|
2979
|
+
* loader: 'js'
|
|
2980
|
+
* };
|
|
2981
|
+
* });
|
|
2982
|
+
* }
|
|
2983
|
+
* }
|
|
2984
|
+
* ]
|
|
2985
|
+
* });
|
|
2986
|
+
* ```
|
|
2987
|
+
* @example Enable bytecode generation for faster startup
|
|
2988
|
+
* ```ts
|
|
2989
|
+
* await Bun.build({
|
|
2990
|
+
* entrypoints: ['./src/server.ts'],
|
|
2991
|
+
* outdir: './dist',
|
|
2992
|
+
* target: 'bun',
|
|
2993
|
+
* format: 'cjs',
|
|
2994
|
+
* bytecode: true
|
|
2995
|
+
* });
|
|
2996
|
+
* ```
|
|
2997
|
+
* @example Add custom banner and footer to output files
|
|
2998
|
+
* ```ts
|
|
2999
|
+
* await Bun.build({
|
|
3000
|
+
* entrypoints: ['./src/index.tsx'],
|
|
3001
|
+
* outdir: './dist',
|
|
3002
|
+
* banner: '"use client";\n// Built with Bun',
|
|
3003
|
+
* footer: '// Generated on ' + new Date().toISOString()
|
|
3004
|
+
* });
|
|
3005
|
+
* ```
|
|
3006
|
+
* @example Configure CDN public path for asset loading
|
|
3007
|
+
* ```ts
|
|
3008
|
+
* await Bun.build({
|
|
3009
|
+
* entrypoints: ['./src/index.tsx'],
|
|
3010
|
+
* outdir: './dist',
|
|
3011
|
+
* publicPath: 'https://cdn.example.com/assets/',
|
|
3012
|
+
* loader: {
|
|
3013
|
+
* '.png': 'file',
|
|
3014
|
+
* '.svg': 'file'
|
|
3015
|
+
* }
|
|
3016
|
+
* });
|
|
3017
|
+
* ```
|
|
3018
|
+
* @example Set up package export conditions for different environments
|
|
3019
|
+
* ```ts
|
|
3020
|
+
* await Bun.build({
|
|
3021
|
+
* entrypoints: ['./src/index.tsx'],
|
|
3022
|
+
* outdir: './dist',
|
|
3023
|
+
* conditions: ['production', 'browser', 'module'],
|
|
3024
|
+
* packages: 'external'
|
|
3025
|
+
* });
|
|
3026
|
+
* ```
|
|
3027
|
+
*/
|
|
2961
3028
|
function build(config: BuildConfig): Promise<BuildOutput>;
|
|
2962
3029
|
/**
|
|
2963
3030
|
* A status that represents the outcome of a sent message.
|
|
@@ -2995,6 +3062,8 @@ declare module "bun" {
|
|
|
2995
3062
|
/**
|
|
2996
3063
|
* A fast WebSocket designed for servers.
|
|
2997
3064
|
*
|
|
3065
|
+
* @category HTTP & Networking
|
|
3066
|
+
*
|
|
2998
3067
|
* Features:
|
|
2999
3068
|
* - **Message compression** - Messages can be compressed
|
|
3000
3069
|
* - **Backpressure** - If the client is not ready to receive data, the server will tell you.
|
|
@@ -3263,6 +3332,8 @@ declare module "bun" {
|
|
|
3263
3332
|
/**
|
|
3264
3333
|
* Create a server-side {@link ServerWebSocket} handler for use with {@link Bun.serve}
|
|
3265
3334
|
*
|
|
3335
|
+
* @category HTTP & Networking
|
|
3336
|
+
*
|
|
3266
3337
|
* @example
|
|
3267
3338
|
* ```ts
|
|
3268
3339
|
* import { websocket, serve } from "bun";
|
|
@@ -3970,6 +4041,8 @@ declare module "bun" {
|
|
|
3970
4041
|
*
|
|
3971
4042
|
* To start the server, see {@link serve}
|
|
3972
4043
|
*
|
|
4044
|
+
* @category HTTP & Networking
|
|
4045
|
+
*
|
|
3973
4046
|
* For performance, Bun pre-allocates most of the data for 2048 concurrent requests.
|
|
3974
4047
|
* That means starting a new server allocates about 500 KB of memory. Try to
|
|
3975
4048
|
* avoid starting and stopping the server often (unless it's a new instance of bun).
|
|
@@ -4269,6 +4342,8 @@ declare module "bun" {
|
|
|
4269
4342
|
*
|
|
4270
4343
|
* @param options - Server configuration options
|
|
4271
4344
|
*
|
|
4345
|
+
* @category HTTP & Networking
|
|
4346
|
+
*
|
|
4272
4347
|
* @example Basic Usage
|
|
4273
4348
|
* ```ts
|
|
4274
4349
|
* Bun.serve({
|
|
@@ -4599,6 +4674,11 @@ declare module "bun" {
|
|
|
4599
4674
|
|
|
4600
4675
|
type StringLike = string | { toString(): string };
|
|
4601
4676
|
|
|
4677
|
+
/**
|
|
4678
|
+
* Valid inputs for {@link color}
|
|
4679
|
+
*
|
|
4680
|
+
* @category Utilities
|
|
4681
|
+
*/
|
|
4602
4682
|
type ColorInput =
|
|
4603
4683
|
| { r: number; g: number; b: number; a?: number }
|
|
4604
4684
|
| [number, number, number]
|
|
@@ -4613,6 +4693,9 @@ declare module "bun" {
|
|
|
4613
4693
|
|
|
4614
4694
|
/**
|
|
4615
4695
|
* Converts formats of colors
|
|
4696
|
+
*
|
|
4697
|
+
* @category Utilities
|
|
4698
|
+
*
|
|
4616
4699
|
* @param input A value that could possibly be a color
|
|
4617
4700
|
* @param outputFormat An optional output format
|
|
4618
4701
|
*/
|
|
@@ -5032,6 +5115,8 @@ declare module "bun" {
|
|
|
5032
5115
|
* Resolve a `Promise` after milliseconds. This is like
|
|
5033
5116
|
* {@link setTimeout} except it returns a `Promise`.
|
|
5034
5117
|
*
|
|
5118
|
+
* @category Utilities
|
|
5119
|
+
*
|
|
5035
5120
|
* @param ms milliseconds to delay resolving the promise. This is a minimum
|
|
5036
5121
|
* number. It may take longer. If a {@link Date} is passed, it will sleep until the
|
|
5037
5122
|
* {@link Date} is reached.
|
|
@@ -5074,6 +5159,8 @@ declare module "bun" {
|
|
|
5074
5159
|
/**
|
|
5075
5160
|
* Hash `input` using [SHA-2 512/256](https://en.wikipedia.org/wiki/SHA-2#Comparison_of_SHA_functions)
|
|
5076
5161
|
*
|
|
5162
|
+
* @category Utilities
|
|
5163
|
+
*
|
|
5077
5164
|
* @param input `string`, `Uint8Array`, or `ArrayBuffer` to hash. `Uint8Array` or `ArrayBuffer` will be faster
|
|
5078
5165
|
* @param hashInto optional `Uint8Array` to write the hash to. 32 bytes minimum.
|
|
5079
5166
|
*
|
|
@@ -5093,6 +5180,8 @@ declare module "bun" {
|
|
|
5093
5180
|
/**
|
|
5094
5181
|
* Hash `input` using [SHA-2 512/256](https://en.wikipedia.org/wiki/SHA-2#Comparison_of_SHA_functions)
|
|
5095
5182
|
*
|
|
5183
|
+
* @category Utilities
|
|
5184
|
+
*
|
|
5096
5185
|
* @param input `string`, `Uint8Array`, or `ArrayBuffer` to hash. `Uint8Array` or `ArrayBuffer` will be faster
|
|
5097
5186
|
* @param encoding `DigestEncoding` to return the hash in
|
|
5098
5187
|
*
|
|
@@ -5470,6 +5559,11 @@ declare module "bun" {
|
|
|
5470
5559
|
readonly __ffi_function_callable: typeof import("bun:ffi").FFIFunctionCallableSymbol;
|
|
5471
5560
|
};
|
|
5472
5561
|
|
|
5562
|
+
/**
|
|
5563
|
+
* The builder object passed to `Bun.plugin`
|
|
5564
|
+
*
|
|
5565
|
+
* @category Bundler
|
|
5566
|
+
*/
|
|
5473
5567
|
interface PluginBuilder {
|
|
5474
5568
|
/**
|
|
5475
5569
|
* Register a callback which will be invoked when bundling starts. When
|
|
@@ -5570,6 +5664,11 @@ declare module "bun" {
|
|
|
5570
5664
|
module(specifier: string, callback: () => OnLoadResult | Promise<OnLoadResult>): this;
|
|
5571
5665
|
}
|
|
5572
5666
|
|
|
5667
|
+
/**
|
|
5668
|
+
* A Bun plugin. Used for extending Bun's behavior at runtime, or with {@link Bun.build}
|
|
5669
|
+
*
|
|
5670
|
+
* @category Bundler
|
|
5671
|
+
*/
|
|
5573
5672
|
interface BunPlugin {
|
|
5574
5673
|
/**
|
|
5575
5674
|
* Human-readable name of the plugin
|
|
@@ -5586,9 +5685,10 @@ declare module "bun" {
|
|
|
5586
5685
|
*
|
|
5587
5686
|
* If unspecified, it is assumed that the plugin is compatible with all targets.
|
|
5588
5687
|
*
|
|
5589
|
-
* This field is not read by {@link Bun.plugin}
|
|
5688
|
+
* This field is not read by {@link Bun.plugin}, only {@link Bun.build} and `bun build`
|
|
5590
5689
|
*/
|
|
5591
5690
|
target?: Target;
|
|
5691
|
+
|
|
5592
5692
|
/**
|
|
5593
5693
|
* A function that will be called when the plugin is loaded.
|
|
5594
5694
|
*
|
|
@@ -6735,6 +6835,8 @@ declare module "bun" {
|
|
|
6735
6835
|
/**
|
|
6736
6836
|
* Spawn a new process
|
|
6737
6837
|
*
|
|
6838
|
+
* @category Process Management
|
|
6839
|
+
*
|
|
6738
6840
|
* ```js
|
|
6739
6841
|
* const subprocess = Bun.spawn({
|
|
6740
6842
|
* cmd: ["echo", "hello"],
|
|
@@ -6799,6 +6901,8 @@ declare module "bun" {
|
|
|
6799
6901
|
/**
|
|
6800
6902
|
* Spawn a new process
|
|
6801
6903
|
*
|
|
6904
|
+
* @category Process Management
|
|
6905
|
+
*
|
|
6802
6906
|
* ```js
|
|
6803
6907
|
* const {stdout} = Bun.spawnSync({
|
|
6804
6908
|
* cmd: ["echo", "hello"],
|
package/docs/api/fetch.md
CHANGED
|
@@ -337,7 +337,7 @@ This will print the request and response headers to your terminal:
|
|
|
337
337
|
```sh
|
|
338
338
|
[fetch] > HTTP/1.1 GET http://example.com/
|
|
339
339
|
[fetch] > Connection: keep-alive
|
|
340
|
-
[fetch] > User-Agent: Bun/1.2.
|
|
340
|
+
[fetch] > User-Agent: Bun/1.2.8-canary.20250328T140605
|
|
341
341
|
[fetch] > Accept: */*
|
|
342
342
|
[fetch] > Host: example.com
|
|
343
343
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
package/docs/api/spawn.md
CHANGED
|
@@ -120,7 +120,7 @@ You can read results from the subprocess via the `stdout` and `stderr` propertie
|
|
|
120
120
|
```ts
|
|
121
121
|
const proc = Bun.spawn(["bun", "--version"]);
|
|
122
122
|
const text = await new Response(proc.stdout).text();
|
|
123
|
-
console.log(text); // => "1.2.
|
|
123
|
+
console.log(text); // => "1.2.8-canary.20250328T140605"
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
Configure the output stream by passing one of the following values to `stdout/stderr`:
|
package/docs/api/sql.md
CHANGED
|
@@ -240,7 +240,7 @@ const result = await sql.unsafe(
|
|
|
240
240
|
|
|
241
241
|
### Execute and Cancelling Queries
|
|
242
242
|
|
|
243
|
-
Bun's SQL is lazy
|
|
243
|
+
Bun's SQL is lazy, which means it will only start executing when awaited or executed with `.execute()`.
|
|
244
244
|
You can cancel a query that is currently executing by calling the `cancel()` method on the query object.
|
|
245
245
|
|
|
246
246
|
```ts
|
package/docs/cli/publish.md
CHANGED
|
@@ -9,7 +9,7 @@ $ bunx nuxi init my-nuxt-app
|
|
|
9
9
|
✔ Which package manager would you like to use?
|
|
10
10
|
bun
|
|
11
11
|
◐ Installing dependencies...
|
|
12
|
-
bun install v1.2.
|
|
12
|
+
bun install v1.2.8-canary.20250328T140605 (16b4bf34)
|
|
13
13
|
+ @nuxt/devtools@0.8.2
|
|
14
14
|
+ nuxt@3.7.0
|
|
15
15
|
785 packages installed [2.67s]
|
|
@@ -16,7 +16,7 @@ This will add the package to `peerDependencies` in `package.json`.
|
|
|
16
16
|
```json-diff
|
|
17
17
|
{
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
+ "@types/bun": "^1.2.
|
|
19
|
+
+ "@types/bun": "^1.2.8-canary.20250328T140605"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
```
|
|
@@ -28,7 +28,7 @@ Running `bun install` will install peer dependencies by default, unless marked o
|
|
|
28
28
|
```json-diff
|
|
29
29
|
{
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@types/bun": "^1.2.
|
|
31
|
+
"@types/bun": "^1.2.8-canary.20250328T140605"
|
|
32
32
|
},
|
|
33
33
|
"peerDependenciesMeta": {
|
|
34
34
|
+ "@types/bun": {
|
|
@@ -97,7 +97,7 @@ $ bun update
|
|
|
97
97
|
$ bun update @types/bun --latest
|
|
98
98
|
|
|
99
99
|
# Update a dependency to a specific version
|
|
100
|
-
$ bun update @types/bun@1.2.
|
|
100
|
+
$ bun update @types/bun@1.2.8-canary.20250328T140605
|
|
101
101
|
|
|
102
102
|
# Update all dependencies to the latest versions
|
|
103
103
|
$ bun update --latest
|
|
@@ -21,7 +21,7 @@ Here's what the output of a typical test run looks like. In this case, there are
|
|
|
21
21
|
|
|
22
22
|
```sh
|
|
23
23
|
$ bun test
|
|
24
|
-
bun test v1.2.
|
|
24
|
+
bun test v1.2.8-canary.20250328T140605 (9c68abdb)
|
|
25
25
|
|
|
26
26
|
test.test.js:
|
|
27
27
|
✓ add [0.87ms]
|
|
@@ -47,7 +47,7 @@ To only run certain test files, pass a positional argument to `bun test`. The ru
|
|
|
47
47
|
|
|
48
48
|
```sh
|
|
49
49
|
$ bun test test3
|
|
50
|
-
bun test v1.2.
|
|
50
|
+
bun test v1.2.8-canary.20250328T140605 (9c68abdb)
|
|
51
51
|
|
|
52
52
|
test3.test.js:
|
|
53
53
|
✓ add [1.40ms]
|
|
@@ -85,7 +85,7 @@ Adding `-t add` will only run tests with "add" in the name. This works with test
|
|
|
85
85
|
|
|
86
86
|
```sh
|
|
87
87
|
$ bun test -t add
|
|
88
|
-
bun test v1.2.
|
|
88
|
+
bun test v1.2.8-canary.20250328T140605 (9c68abdb)
|
|
89
89
|
|
|
90
90
|
test.test.js:
|
|
91
91
|
✓ add [1.79ms]
|
|
@@ -18,7 +18,7 @@ The first time this test is executed, Bun will evaluate the value passed into `e
|
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
20
|
$ bun test test/snap
|
|
21
|
-
bun test v1.2.
|
|
21
|
+
bun test v1.2.8-canary.20250328T140605 (9c68abdb)
|
|
22
22
|
|
|
23
23
|
test/snap.test.ts:
|
|
24
24
|
✓ snapshot [1.48ms]
|
|
@@ -61,7 +61,7 @@ Later, when this test file is executed again, Bun will read the snapshot file an
|
|
|
61
61
|
|
|
62
62
|
```sh
|
|
63
63
|
$ bun test
|
|
64
|
-
bun test v1.2.
|
|
64
|
+
bun test v1.2.8-canary.20250328T140605 (9c68abdb)
|
|
65
65
|
|
|
66
66
|
test/snap.test.ts:
|
|
67
67
|
✓ snapshot [1.05ms]
|
|
@@ -78,7 +78,7 @@ To update snapshots, use the `--update-snapshots` flag.
|
|
|
78
78
|
|
|
79
79
|
```sh
|
|
80
80
|
$ bun test --update-snapshots
|
|
81
|
-
bun test v1.2.
|
|
81
|
+
bun test v1.2.8-canary.20250328T140605 (9c68abdb)
|
|
82
82
|
|
|
83
83
|
test/snap.test.ts:
|
|
84
84
|
✓ snapshot [0.86ms]
|
package/docs/installation.md
CHANGED
|
@@ -14,7 +14,7 @@ Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1. Us
|
|
|
14
14
|
```bash#macOS/Linux_(curl)
|
|
15
15
|
$ curl -fsSL https://bun.sh/install | bash # for macOS, Linux, and WSL
|
|
16
16
|
# to install a specific version
|
|
17
|
-
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.
|
|
17
|
+
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.8-canary.20250328T140605"
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
```bash#npm
|
|
@@ -189,10 +189,10 @@ Since Bun is a single binary, you can install older versions of Bun by re-runnin
|
|
|
189
189
|
|
|
190
190
|
### Installing a specific version of Bun on Linux/Mac
|
|
191
191
|
|
|
192
|
-
To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.
|
|
192
|
+
To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.8-canary.20250328T140605`.
|
|
193
193
|
|
|
194
194
|
```sh
|
|
195
|
-
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.
|
|
195
|
+
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.8-canary.20250328T140605"
|
|
196
196
|
```
|
|
197
197
|
|
|
198
198
|
### Installing a specific version of Bun on Windows
|
|
@@ -201,7 +201,7 @@ On Windows, you can install a specific version of Bun by passing the version num
|
|
|
201
201
|
|
|
202
202
|
```sh
|
|
203
203
|
# PowerShell:
|
|
204
|
-
$ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.
|
|
204
|
+
$ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.8-canary.20250328T140605"
|
|
205
205
|
```
|
|
206
206
|
|
|
207
207
|
## Downloading Bun binaries directly
|
|
@@ -134,6 +134,16 @@ We recommend adding `./build/debug` to your `$PATH` so that you can run `bun-deb
|
|
|
134
134
|
$ bun-debug
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
+
## Running debug builds
|
|
138
|
+
|
|
139
|
+
The `bd` package.json script compiles and runs a debug build of Bun, only printing the output of the build process if it fails.
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
$ bun bd <args>
|
|
143
|
+
$ bun bd test foo.test.ts
|
|
144
|
+
$ bun bd ./foo.ts
|
|
145
|
+
```
|
|
146
|
+
|
|
137
147
|
## Code generation scripts
|
|
138
148
|
|
|
139
149
|
Several code generation scripts are used during Bun's build process. These are run automatically when changes are made to certain files.
|
package/docs/runtime/debugger.md
CHANGED
|
@@ -124,11 +124,11 @@ await fetch("https://example.com", {
|
|
|
124
124
|
This prints the `fetch` request as a single-line `curl` command to let you copy-paste into your terminal to replicate the request.
|
|
125
125
|
|
|
126
126
|
```sh
|
|
127
|
-
[fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.
|
|
127
|
+
[fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.8-canary.20250328T140605" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
|
|
128
128
|
[fetch] > HTTP/1.1 POST https://example.com/
|
|
129
129
|
[fetch] > content-type: application/json
|
|
130
130
|
[fetch] > Connection: keep-alive
|
|
131
|
-
[fetch] > User-Agent: Bun/1.2.
|
|
131
|
+
[fetch] > User-Agent: Bun/1.2.8-canary.20250328T140605
|
|
132
132
|
[fetch] > Accept: */*
|
|
133
133
|
[fetch] > Host: example.com
|
|
134
134
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
|
@@ -170,7 +170,7 @@ This prints the following to the console:
|
|
|
170
170
|
[fetch] > HTTP/1.1 POST https://example.com/
|
|
171
171
|
[fetch] > content-type: application/json
|
|
172
172
|
[fetch] > Connection: keep-alive
|
|
173
|
-
[fetch] > User-Agent: Bun/1.2.
|
|
173
|
+
[fetch] > User-Agent: Bun/1.2.8-canary.20250328T140605
|
|
174
174
|
[fetch] > Accept: */*
|
|
175
175
|
[fetch] > Host: example.com
|
|
176
176
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
|
@@ -378,8 +378,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa
|
|
|
378
378
|
|
|
379
379
|
### [`require()`](https://nodejs.org/api/globals.html#require)
|
|
380
380
|
|
|
381
|
-
🟢 Fully implemented, including [`require.main`](https://nodejs.org/api/modules.html#requiremain), [`require.cache`](https://nodejs.org/api/modules.html#requirecache), [`require.resolve`](https://nodejs.org/api/modules.html#requireresolverequest-options).
|
|
382
|
-
|
|
381
|
+
🟢 Fully implemented, including [`require.main`](https://nodejs.org/api/modules.html#requiremain), [`require.cache`](https://nodejs.org/api/modules.html#requirecache), [`require.resolve`](https://nodejs.org/api/modules.html#requireresolverequest-options).
|
|
383
382
|
### [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
384
383
|
|
|
385
384
|
🟢 Fully implemented.
|
package/docs/test/dom.md
CHANGED
package/ffi.d.ts
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* that convert JavaScript types to C types and back. Internally,
|
|
14
14
|
* bun uses [tinycc](https://github.com/TinyCC/tinycc), so a big thanks
|
|
15
15
|
* goes to Fabrice Bellard and TinyCC maintainers for making this possible.
|
|
16
|
+
*
|
|
17
|
+
* @category FFI
|
|
16
18
|
*/
|
|
17
19
|
declare module "bun:ffi" {
|
|
18
20
|
enum FFIType {
|
|
@@ -600,6 +602,8 @@ declare module "bun:ffi" {
|
|
|
600
602
|
* that convert JavaScript types to C types and back. Internally,
|
|
601
603
|
* bun uses [tinycc](https://github.com/TinyCC/tinycc), so a big thanks
|
|
602
604
|
* goes to Fabrice Bellard and TinyCC maintainers for making this possible.
|
|
605
|
+
*
|
|
606
|
+
* @category FFI
|
|
603
607
|
*/
|
|
604
608
|
function dlopen<Fns extends Record<string, FFIFunction>>(
|
|
605
609
|
name: string | import("bun").BunFile | URL,
|
|
@@ -1018,6 +1022,8 @@ declare module "bun:ffi" {
|
|
|
1018
1022
|
* // Do something with rawPtr
|
|
1019
1023
|
* }
|
|
1020
1024
|
* ```
|
|
1025
|
+
*
|
|
1026
|
+
* @category FFI
|
|
1021
1027
|
*/
|
|
1022
1028
|
function ptr(view: NodeJS.TypedArray | ArrayBufferLike | DataView, byteOffset?: number): Pointer;
|
|
1023
1029
|
|
|
@@ -1042,8 +1048,9 @@ declare module "bun:ffi" {
|
|
|
1042
1048
|
* thing to do safely. Passing an invalid pointer can crash the program and
|
|
1043
1049
|
* reading beyond the bounds of the pointer will crash the program or cause
|
|
1044
1050
|
* undefined behavior. Use with care!
|
|
1051
|
+
*
|
|
1052
|
+
* @category FFI
|
|
1045
1053
|
*/
|
|
1046
|
-
|
|
1047
1054
|
class CString extends String {
|
|
1048
1055
|
/**
|
|
1049
1056
|
* Get a string from a UTF-8 encoded C string
|
package/globals.d.ts
CHANGED
|
@@ -1384,7 +1384,7 @@ interface Uint8ArrayConstructor {
|
|
|
1384
1384
|
interface BroadcastChannel {}
|
|
1385
1385
|
declare var BroadcastChannel: Bun.__internal.UseLibDomIfAvailable<
|
|
1386
1386
|
"BroadcastChannel",
|
|
1387
|
-
import("node:worker_threads").BroadcastChannel
|
|
1387
|
+
typeof import("node:worker_threads").BroadcastChannel
|
|
1388
1388
|
>;
|
|
1389
1389
|
|
|
1390
1390
|
declare var URL: Bun.__internal.UseLibDomIfAvailable<
|
|
@@ -1434,6 +1434,24 @@ declare var AbortSignal: Bun.__internal.UseLibDomIfAvailable<
|
|
|
1434
1434
|
{
|
|
1435
1435
|
prototype: AbortSignal;
|
|
1436
1436
|
new (): AbortSignal;
|
|
1437
|
+
/**
|
|
1438
|
+
* Create an AbortSignal that will be aborted after a timeout
|
|
1439
|
+
* @param ms The timeout in milliseconds
|
|
1440
|
+
* @returns An AbortSignal that will be aborted after the timeout
|
|
1441
|
+
*/
|
|
1442
|
+
timeout(ms: number): AbortSignal;
|
|
1443
|
+
/**
|
|
1444
|
+
* Create an immediately-aborted AbortSignal
|
|
1445
|
+
* @param reason The reason for the abort
|
|
1446
|
+
* @returns An AbortSignal that is already aborted
|
|
1447
|
+
*/
|
|
1448
|
+
abort(reason?: any): AbortSignal;
|
|
1449
|
+
/**
|
|
1450
|
+
* Create an AbortSignal that will be aborted if any of the signals are aborted
|
|
1451
|
+
* @param signals The signals to combine
|
|
1452
|
+
* @returns An AbortSignal that will be aborted if any of the signals are aborted
|
|
1453
|
+
*/
|
|
1454
|
+
any(signals: AbortSignal[]): AbortSignal;
|
|
1437
1455
|
}
|
|
1438
1456
|
>;
|
|
1439
1457
|
|
package/html-rewriter.d.ts
CHANGED
package/package.json
CHANGED
package/s3.d.ts
CHANGED
|
@@ -340,6 +340,8 @@ declare module "bun" {
|
|
|
340
340
|
/**
|
|
341
341
|
* Represents a file in an S3-compatible storage service.
|
|
342
342
|
* Extends the Blob interface for compatibility with web APIs.
|
|
343
|
+
*
|
|
344
|
+
* @category Cloud Storage
|
|
343
345
|
*/
|
|
344
346
|
interface S3File extends Blob {
|
|
345
347
|
/**
|
|
@@ -635,6 +637,8 @@ declare module "bun" {
|
|
|
635
637
|
* await bucket.write("data.json", JSON.stringify({hello: "world"}));
|
|
636
638
|
* const url = bucket.presign("file.pdf");
|
|
637
639
|
* await bucket.unlink("old.txt");
|
|
640
|
+
*
|
|
641
|
+
* @category Cloud Storage
|
|
638
642
|
*/
|
|
639
643
|
class S3Client {
|
|
640
644
|
prototype: S3Client;
|
|
@@ -820,6 +824,8 @@ declare module "bun" {
|
|
|
820
824
|
* A default instance of S3Client
|
|
821
825
|
*
|
|
822
826
|
* Pulls credentials from environment variables. Use `new Bun.S3Client()` if you need to explicitly set credentials.
|
|
827
|
+
*
|
|
828
|
+
* @category Cloud Storage
|
|
823
829
|
*/
|
|
824
830
|
var s3: S3Client;
|
|
825
831
|
}
|
package/sqlite.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ declare module "bun:sqlite" {
|
|
|
58
58
|
* ```ts
|
|
59
59
|
* const db = new Database("mydb.sqlite", {readonly: true});
|
|
60
60
|
* ```
|
|
61
|
+
*
|
|
62
|
+
* @category Database
|
|
61
63
|
*/
|
|
62
64
|
constructor(
|
|
63
65
|
filename?: string,
|
|
@@ -567,6 +569,8 @@ declare module "bun:sqlite" {
|
|
|
567
569
|
*
|
|
568
570
|
* This is returned by {@link Database.prepare} and {@link Database.query}.
|
|
569
571
|
*
|
|
572
|
+
* @category Database
|
|
573
|
+
*
|
|
570
574
|
* @example
|
|
571
575
|
* ```ts
|
|
572
576
|
* const stmt = db.prepare("SELECT * FROM foo WHERE bar = ?");
|
package/test.d.ts
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
declare module "bun:test" {
|
|
17
17
|
/**
|
|
18
18
|
* -- Mocks --
|
|
19
|
+
*
|
|
20
|
+
* @category Testing
|
|
19
21
|
*/
|
|
20
22
|
export type Mock<T extends (...args: any[]) => any> = JestMock.Mock<T>;
|
|
21
23
|
|
|
@@ -168,6 +170,8 @@ declare module "bun:test" {
|
|
|
168
170
|
*
|
|
169
171
|
* @param label the label for the tests
|
|
170
172
|
* @param fn the function that defines the tests
|
|
173
|
+
*
|
|
174
|
+
* @category Testing
|
|
171
175
|
*/
|
|
172
176
|
export interface Describe {
|
|
173
177
|
(fn: () => void): void;
|
|
@@ -352,6 +356,8 @@ declare module "bun:test" {
|
|
|
352
356
|
* @param label the label for the test
|
|
353
357
|
* @param fn the test function
|
|
354
358
|
* @param options the test timeout or options
|
|
359
|
+
*
|
|
360
|
+
* @category Testing
|
|
355
361
|
*/
|
|
356
362
|
export interface Test {
|
|
357
363
|
(
|