bun-types 1.3.4-canary.20251201T140810 → 1.3.4-canary.20251202T140744

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.
@@ -74,6 +74,12 @@ export default defineNuxtConfig({
74
74
  });
75
75
  ```
76
76
 
77
+ Alternatively, you can set the preset via environment variable:
78
+
79
+ ```sh terminal icon="terminal"
80
+ NITRO_PRESET=bun bun run build
81
+ ```
82
+
77
83
  <Note>
78
84
  Some packages provide Bun-specific exports that Nitro will not bundle correctly using the default preset. In this
79
85
  case, you need to use Bun preset so that the packages will work correctly in production builds.
@@ -4,63 +4,59 @@ sidebarTitle: "SolidStart with Bun"
4
4
  mode: center
5
5
  ---
6
6
 
7
- <Warning>
8
- SolidStart currently relies on Node.js APIs that Bun does not yet implement. The guide below uses Bun to initialize a
9
- project and install dependencies, but it uses Node.js to run the dev server.
10
- </Warning>
11
-
12
- ---
13
-
14
- Initialize a SolidStart app with `create-solid`.
7
+ Initialize a SolidStart app with `create-solid`. You can specify the `--solidstart` flag to create a SolidStart project, and `--ts` for TypeScript support. When prompted for a template, select `basic` for a minimal starter app.
15
8
 
16
9
  ```sh terminal icon="terminal"
17
- bun create solid my-app
10
+ bun create solid my-app --solidstart --ts
18
11
  ```
19
12
 
20
13
  ```txt
21
- create-solid version 0.2.31
22
-
23
- Welcome to the SolidStart setup wizard!
24
-
25
- There are definitely bugs and some feature might not work yet.
26
- If you encounter an issue, have a look at
27
- https://github.com/solidjs/solid-start/issues and open a new one,
28
- if it is not already tracked.
29
-
30
- Which template do you want to use? › todomvc
31
- ✔ Server Side Rendering? … yes
32
- Use TypeScript? yes
33
- cloned solidjs/solid-start#main to /path/to/my-app/.solid-start
34
- Copied project files
14
+
15
+ Create-Solid v0.6.11
16
+
17
+ ◇ Project Name
18
+ │ my-app
19
+
20
+ ◇ Which template would you like to use?
21
+ │ basic
22
+
23
+ ◇ Project created 🎉
24
+
25
+ ◇ To get started, run: ─╮
26
+ │ │
27
+ │ cd my-app │
28
+ │ bun install │
29
+ │ bun dev │
30
+ │ │
31
+ ├────────────────────────╯
35
32
  ```
36
33
 
37
34
  ---
38
35
 
39
- As instructed by the `create-solid` CLI, let's install our dependencies.
36
+ As instructed by the `create-solid` CLI, install the dependencies.
40
37
 
41
38
  ```sh terminal icon="terminal"
42
39
  cd my-app
43
40
  bun install
44
41
  ```
45
42
 
46
- ---
47
-
48
- Then run the development server.
43
+ Then run the development server with `bun dev`.
49
44
 
50
45
  ```sh terminal icon="terminal"
51
- bun run dev
52
- # or, equivalently
53
- bunx solid-start dev
46
+ bun dev
54
47
  ```
55
48
 
56
- ---
49
+ ```txt
50
+ $ vinxi dev
51
+ vinxi v0.5.8
52
+ vinxi starting dev server
57
53
 
58
- Open [localhost:3000](http://localhost:3000). Any changes you make to `src/routes/index.tsx` will be hot-reloaded automatically.
54
+ Local: http://localhost:3000/
55
+ ➜ Network: use --host to expose
56
+ ```
59
57
 
60
- <Frame>
61
- ![SolidStart demo app](https://github.com/oven-sh/bun/assets/3084745/1e8043c4-49d1-498c-9add-c1eaab6c7167)
62
- </Frame>
58
+ Open [localhost:3000](http://localhost:3000). Any changes you make to `src/routes/index.tsx` will be hot-reloaded automatically.
63
59
 
64
60
  ---
65
61
 
66
- Refer to the [SolidStart website](https://start.solidjs.com/getting-started/what-is-solidstart) for complete framework documentation.
62
+ Refer to the [SolidStart website](https://docs.solidjs.com/solid-start) for complete framework documentation.
@@ -4,22 +4,25 @@ sidebarTitle: Detect Bun
4
4
  mode: center
5
5
  ---
6
6
 
7
- The recommended way to conditionally detect when code is being executed with `bun` is to check for the existence of the `Bun` global.
8
-
9
- This is similar to how you'd check for the existence of the `window` variable to detect when code is being executed in a browser.
7
+ The recommended way to detect when code is being executed with Bun is to check `process.versions.bun`. This works in both JavaScript and TypeScript without requiring any additional type definitions.
10
8
 
11
9
  ```ts
12
- if (typeof Bun !== "undefined") {
10
+ if (process.versions.bun) {
13
11
  // this code will only run when the file is run with Bun
14
12
  }
15
13
  ```
16
14
 
17
15
  ---
18
16
 
19
- In TypeScript environments, the previous approach will result in a type error unless `@types/bun` is installed. To avoid this, you can check `process.versions` instead.
17
+ Alternatively, you can check for the existence of the `Bun` global. This is similar to how you'd check for the existence of the `window` variable to detect when code is being executed in a browser.
18
+
19
+ <Note>
20
+ This approach will result in a type error in TypeScript unless `@types/bun` is installed. You can install it with `bun
21
+ add -d @types/bun`.
22
+ </Note>
20
23
 
21
24
  ```ts
22
- if (process.versions.bun) {
25
+ if (typeof Bun !== "undefined") {
23
26
  // this code will only run when the file is run with Bun
24
27
  }
25
28
  ```
@@ -0,0 +1,93 @@
1
+ ---
2
+ title: Upgrade Bun to the latest version
3
+ sidebarTitle: Upgrade Bun
4
+ mode: center
5
+ ---
6
+
7
+ Bun can upgrade itself using the built-in `bun upgrade` command. This is the fastest way to get the latest features and bug fixes.
8
+
9
+ ```bash terminal icon="terminal"
10
+ bun upgrade
11
+ ```
12
+
13
+ This downloads and installs the latest stable version of Bun, replacing the currently installed version.
14
+
15
+ <Note>To see the current version of Bun, run `bun --version`.</Note>
16
+
17
+ ---
18
+
19
+ ## Verify the upgrade
20
+
21
+ After upgrading, verify the new version:
22
+
23
+ ```bash terminal icon="terminal"
24
+ bun --version
25
+ # Output: 1.x.y
26
+
27
+ # See the exact commit of the Bun binary
28
+ bun --revision
29
+ # Output: 1.x.y+abc123def
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Upgrade to canary builds
35
+
36
+ Canary builds are automatically released on every commit to the `main` branch. These are untested but useful for trying new features or verifying bug fixes before they're released.
37
+
38
+ ```bash terminal icon="terminal"
39
+ bun upgrade --canary
40
+ ```
41
+
42
+ <Warning>Canary builds are not recommended for production use. They may contain bugs or breaking changes.</Warning>
43
+
44
+ ---
45
+
46
+ ## Switch back to stable
47
+
48
+ If you're on a canary build and want to return to the latest stable release:
49
+
50
+ ```bash terminal icon="terminal"
51
+ bun upgrade --stable
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Install a specific version
57
+
58
+ To install a specific version of Bun, use the install script with a version tag:
59
+
60
+ <Tabs>
61
+ <Tab title="macOS & Linux">
62
+ ```bash terminal icon="terminal"
63
+ curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.3"
64
+ ```
65
+ </Tab>
66
+ <Tab title="Windows">
67
+ ```powershell PowerShell icon="windows"
68
+ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.3.3"
69
+ ```
70
+ </Tab>
71
+ </Tabs>
72
+
73
+ ---
74
+
75
+ ## Package manager users
76
+
77
+ If you installed Bun via a package manager, use that package manager to upgrade instead of `bun upgrade` to avoid conflicts.
78
+
79
+ <Tip>
80
+ **Homebrew users** <br />
81
+ To avoid conflicts with Homebrew, use `brew upgrade bun` instead.
82
+
83
+ **Scoop users** <br />
84
+ To avoid conflicts with Scoop, use `scoop update bun` instead.
85
+
86
+ </Tip>
87
+
88
+ ---
89
+
90
+ ## See also
91
+
92
+ - [Installation](/docs/installation) — Install Bun for the first time
93
+ - [Update packages](/docs/pm/cli/update) — Update dependencies to latest versions
package/docs/pm/bunx.mdx CHANGED
@@ -3,6 +3,8 @@ title: "bunx"
3
3
  description: "Run packages from npm"
4
4
  ---
5
5
 
6
+ import Bunx from "/snippets/cli/bunx.mdx";
7
+
6
8
  <Note>`bunx` is an alias for `bun x`. The `bunx` CLI will be auto-installed when you install `bun`.</Note>
7
9
 
8
10
  Use `bunx` to auto-install and run packages from `npm`. It's Bun's equivalent of `npx` or `yarn dlx`.
@@ -52,6 +54,8 @@ To pass additional command-line flags and arguments through to the executable, p
52
54
  bunx my-cli --foo bar
53
55
  ```
54
56
 
57
+ ---
58
+
55
59
  ## Shebangs
56
60
 
57
61
  By default, Bun respects shebangs. If an executable is marked with `#!/usr/bin/env node`, Bun will spin up a `node` process to execute the file. However, in some cases it may be desirable to run executables using Bun's runtime, even if the executable indicates otherwise. To do so, include the `--bun` flag.
@@ -81,3 +85,7 @@ To force bun to always be used with a script, use a shebang.
81
85
  ```js dist/index.js icon="/icons/javascript.svg"
82
86
  #!/usr/bin/env bun
83
87
  ```
88
+
89
+ ---
90
+
91
+ <Bunx />
@@ -23,10 +23,11 @@ if (!githubToken) {
23
23
  name: "github-token",
24
24
  value: githubToken,
25
25
  });
26
+
26
27
  console.log("GitHub token stored");
27
28
  }
28
29
 
29
- const response = await fetch("https://api.github.com/name", {
30
+ const response = await fetch("https://api.github.com/user", {
30
31
  headers: { Authorization: `token ${githubToken}` },
31
32
  });
32
33
 
@@ -172,12 +172,25 @@ const query = db.query(`select "Hello world" as message`);
172
172
  ```
173
173
 
174
174
  <Note>
175
- Use the `.prepare()` method to prepare a query _without_ caching it on the `Database` instance.
175
+ **What does "cached" mean?**
176
176
 
177
- ```ts
178
- // compile the prepared statement
179
- const query = db.prepare("SELECT * FROM foo WHERE bar = ?");
180
- ```
177
+ The caching refers to the **compiled prepared statement** (the SQL bytecode), not the query results. When you call `db.query()` with the same SQL string multiple times, Bun returns the same cached `Statement` object instead of recompiling the SQL.
178
+
179
+ It is completely safe to reuse a cached statement with different parameter values:
180
+
181
+ ```ts
182
+ const query = db.query("SELECT * FROM users WHERE id = ?");
183
+ query.get(1); // ✓ Works
184
+ query.get(2); // ✓ Also works - parameters are bound fresh each time
185
+ query.get(3); // ✓ Still works
186
+ ```
187
+
188
+ Use `.prepare()` instead of `.query()` when you want a fresh `Statement` instance that isn't cached, for example if you're dynamically generating SQL and don't want to fill the cache with one-off queries.
189
+
190
+ ```ts
191
+ // compile the prepared statement without caching
192
+ const query = db.prepare("SELECT * FROM foo WHERE bar = ?");
193
+ ```
181
194
 
182
195
  </Note>
183
196
 
@@ -190,7 +203,7 @@ SQLite supports [write-ahead log mode](https://www.sqlite.org/wal.html) (WAL) wh
190
203
  To enable WAL mode, run this pragma query at the beginning of your application:
191
204
 
192
205
  ```ts db.ts icon="/icons/typescript.svg"
193
- db.exec("PRAGMA journal_mode = WAL;");
206
+ db.run("PRAGMA journal_mode = WAL;");
194
207
  ```
195
208
 
196
209
  <Accordion title="What is WAL mode?">
@@ -650,8 +663,8 @@ class Database {
650
663
  },
651
664
  );
652
665
 
653
- prepare<ReturnType, Params>(sql: string): Statement<ReturnType, Params>;
654
- query<ReturnType, Params>(sql: string): Statement<ReturnType, Params>;
666
+ query<ReturnType, ParamsType>(sql: string): Statement<ReturnType, ParamsType>;
667
+ prepare<ReturnType, ParamsType>(sql: string): Statement<ReturnType, ParamsType>;
655
668
  run(sql: string, params?: SQLQueryBindings): { lastInsertRowid: number; changes: number };
656
669
  exec = this.run;
657
670
 
@@ -664,14 +677,14 @@ class Database {
664
677
  close(throwOnError?: boolean): void;
665
678
  }
666
679
 
667
- class Statement<ReturnType, Params> {
668
- all(params: Params): ReturnType[];
669
- get(params: Params): ReturnType | undefined;
670
- run(params: Params): {
680
+ class Statement<ReturnType, ParamsType> {
681
+ all(...params: ParamsType[]): ReturnType[];
682
+ get(...params: ParamsType[]): ReturnType | null;
683
+ run(...params: ParamsType[]): {
671
684
  lastInsertRowid: number;
672
685
  changes: number;
673
686
  };
674
- values(params: Params): unknown[][];
687
+ values(...params: ParamsType[]): unknown[][];
675
688
 
676
689
  finalize(): void; // destroy statement and clean up resources
677
690
  toString(): string; // serialize to SQL
@@ -682,7 +695,7 @@ class Statement<ReturnType, Params> {
682
695
  paramsCount: number; // the number of parameters expected by the statement
683
696
  native: any; // the native object representing the statement
684
697
 
685
- as(Class: new () => ReturnType): this;
698
+ as<T>(Class: new (...args: any[]) => T): Statement<T, ParamsType>;
686
699
  }
687
700
 
688
701
  type SQLQueryBindings =
@@ -0,0 +1,49 @@
1
+ ## Usage
2
+
3
+ ```bash
4
+ bunx [flags] <package>[@version] [flags and arguments for the package]
5
+ ```
6
+
7
+ Execute an npm package executable (CLI), automatically installing into a global shared cache if not installed in `node_modules`.
8
+
9
+ ### Flags
10
+
11
+ <ParamField path="--bun" type="boolean">
12
+ Force the command to run with Bun instead of Node.js, even if the executable contains a Node shebang (`#!/usr/bin/env
13
+ node`)
14
+ </ParamField>
15
+
16
+ <ParamField path="-p, --package" type="string">
17
+ Specify package to install when binary name differs from package name
18
+ </ParamField>
19
+
20
+ <ParamField path="--no-install" type="boolean">
21
+ Skip installation if package is not already installed
22
+ </ParamField>
23
+
24
+ <ParamField path="--verbose" type="boolean">
25
+ Enable verbose output during installation
26
+ </ParamField>
27
+
28
+ <ParamField path="--silent" type="boolean">
29
+ Suppress output during installation
30
+ </ParamField>
31
+
32
+ ### Examples
33
+
34
+ ```bash terminal icon="terminal"
35
+ # Run Prisma migrations
36
+ bunx prisma migrate
37
+
38
+ # Format a file with Prettier
39
+ bunx prettier foo.js
40
+
41
+ # Run a specific version of a package
42
+ bunx uglify-js@3.14.0 app.js
43
+
44
+ # Use --package when binary name differs from package name
45
+ bunx -p @angular/cli ng new my-app
46
+
47
+ # Force running with Bun instead of Node.js, even if the executable contains a Node shebang
48
+ bunx --bun vite dev foo.js
49
+ ```
package/package.json CHANGED
@@ -33,5 +33,5 @@
33
33
  "bun.js",
34
34
  "types"
35
35
  ],
36
- "version": "1.3.4-canary.20251201T140810"
36
+ "version": "1.3.4-canary.20251202T140744"
37
37
  }
package/serve.d.ts CHANGED
@@ -1082,6 +1082,15 @@ declare module "bun" {
1082
1082
  */
1083
1083
  readonly hostname: string | undefined;
1084
1084
 
1085
+ /**
1086
+ * The protocol the server is listening on.
1087
+ *
1088
+ * - "http" for normal servers
1089
+ * - "https" when TLS is enabled
1090
+ * - null for unix sockets or when unavailable
1091
+ */
1092
+ readonly protocol: "http" | "https" | null;
1093
+
1085
1094
  /**
1086
1095
  * Is the server running in development mode?
1087
1096
  *
package/test.d.ts CHANGED
@@ -95,8 +95,15 @@ declare module "bun:test" {
95
95
  function fn<T extends (...args: any[]) => any>(func?: T): Mock<T>;
96
96
  function setSystemTime(now?: number | Date): void;
97
97
  function setTimeout(milliseconds: number): void;
98
- function useFakeTimers(): void;
99
- function useRealTimers(): void;
98
+ function useFakeTimers(options?: { now?: number | Date }): typeof vi;
99
+ function useRealTimers(): typeof vi;
100
+ function advanceTimersByTime(milliseconds: number): typeof vi;
101
+ function advanceTimersToNextTimer(): typeof vi;
102
+ function runAllTimers(): typeof vi;
103
+ function runOnlyPendingTimers(): typeof vi;
104
+ function getTimerCount(): number;
105
+ function clearAllTimers(): void;
106
+ function isFakeTimers(): boolean;
100
107
  function spyOn<T extends object, K extends keyof T>(
101
108
  obj: T,
102
109
  methodOrPropertyValue: K,
@@ -184,6 +191,13 @@ declare module "bun:test" {
184
191
  resetAllMocks: typeof jest.resetAllMocks;
185
192
  useFakeTimers: typeof jest.useFakeTimers;
186
193
  useRealTimers: typeof jest.useRealTimers;
194
+ advanceTimersByTime: typeof jest.advanceTimersByTime;
195
+ advanceTimersToNextTimer: typeof jest.advanceTimersToNextTimer;
196
+ runAllTimers: typeof jest.runAllTimers;
197
+ runOnlyPendingTimers: typeof jest.runOnlyPendingTimers;
198
+ getTimerCount: typeof jest.getTimerCount;
199
+ clearAllTimers: typeof jest.clearAllTimers;
200
+ isFakeTimers: typeof jest.isFakeTimers;
187
201
  };
188
202
 
189
203
  interface FunctionLike {