Compare commits

..

53 Commits

Author SHA1 Message Date
Meghan Denny
4e711ff26a fix the args order here 2024-09-06 23:26:01 -07:00
Meghan Denny
25f998f024 bring back this error handling 2024-09-06 23:25:50 -07:00
Meghan Denny
bfd22b81c4 make this not a magic number 2024-09-06 20:31:44 -07:00
Meghan Denny
6d9554c220 add emulation of these internal fields 2024-09-06 20:31:33 -07:00
Meghan Denny
18660fad49 align internal name of zlib.Base to be ZlibBase like node 2024-09-06 19:32:56 -07:00
Meghan Denny
8a432bd1f2 fix memory leak when passing strings to zlib.crc32 2024-09-06 19:31:57 -07:00
Meghan Denny
8cd515f533 node:zlib: move deflate and gzip into native code (#11770)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-09-06 18:49:19 -07:00
Jarred Sumner
1458fcca4a Run formatter 2024-09-06 18:13:08 -07:00
Jarred Sumner
4dbd246c49 Update 7-install-crash-report.yml 2024-09-06 18:01:03 -07:00
Jarred Sumner
17553e8ea3 Update 7-install-crash-report.yml 2024-09-06 18:00:14 -07:00
Jarred Sumner
2507ff515a Update 7-install-crash-report.yml 2024-09-06 17:58:58 -07:00
Ciro Spaciari
1011b44d78 fix(node:http) implement request.setTimeout and server.setTimeout (#13772)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-09-06 17:52:38 -07:00
Ashcon Partovi
cbb57e5c5b Fix bun run being terminated randomly in CI
This was basically a chaos monkey in our CI
2024-09-06 17:37:49 -07:00
Jarred Sumner
ed6554314e github actions 2024-09-06 17:28:19 -07:00
Jarred Sumner
bd38aaab36 Update sqlite3_local.h 2024-09-06 17:25:51 -07:00
Jarred Sumner
6fe2d99a51 Github actions 2024-09-06 17:18:28 -07:00
Jarred Sumner
e8c65a009f clang fmt github action (#13724) 2024-09-06 17:15:07 -07:00
Jarred Sumner
3f9ad7cefc Add a debug assertion 2024-09-06 16:58:08 -07:00
Jarred Sumner
69f97cecf0 Ensure shell keeps process alive while running (#13777) 2024-09-06 16:28:50 -07:00
Meghan Denny
ed7741a662 node:https: provide proper Agent definition (#11826)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-09-06 16:11:19 -07:00
Jarred Sumner
9adf42b373 Handle oom in Buffer.byteLength (#13746) 2024-09-06 14:38:55 -07:00
Jarred Sumner
d3bc0ca722 Add if workers spawned / terminated to crash reports (#13763) 2024-09-06 14:34:33 -07:00
Jarred Sumner
debaa2cc34 Fix CTRL + C behavior in bun run so it doesn't ^[[A (#13762) 2024-09-06 13:54:01 -07:00
Jarred Sumner
ea12db4084 Deflake a test 2024-09-06 13:49:26 -07:00
Meghan Denny
981f1d4a60 fix bad translation in child-process-exec-timeout-kill.test.js (#13765) 2024-09-06 13:26:57 -07:00
Pham Minh Triet
419277f691 fix small typo in semver.md (#13767) 2024-09-06 13:26:20 -07:00
190n
da2a5661af Increase randomIntegrityAuditRate from 0.05 to 1.0 in CI (#13775) 2024-09-06 13:03:23 -07:00
Ciro Spaciari
d8e2c24d70 fix(fetch) fix lifecycle of SSL Proxy, fix lifecycle of tls_props, fix handling chunked encoded redirects when proxing. (#13752) 2024-09-06 01:50:02 -07:00
マルコメ
6010c33137 Add .toml extension to .gitattributes (#13761) 2024-09-05 23:52:12 -07:00
Ciro Spaciari
36c5f843ec feat(tls) add duplex upgrade (#13718) 2024-09-05 19:37:31 -07:00
Jarred Sumner
d38fc909e3 Support ReadableStream in request.clone & response.clone() (#13744) 2024-09-05 17:55:59 -07:00
Solomon ogu
cd7f6a1589 fix: typo in docs and types for sqlite (#13727) 2024-09-04 15:46:05 -07:00
Jarred Sumner
a9cf463eeb Introduce fast path for buffered ReadableStream (#13704)
Co-authored-by: Jarred-Sumner <Jarred-Sumner@users.noreply.github.com>
2024-09-04 04:16:47 -07:00
Jarred Sumner
f3da37e486 Fixes #13725 2024-09-04 03:26:11 -07:00
Jarred Sumner
ebe070487b github actions 2024-09-03 21:51:04 -07:00
Jarred Sumner
f4539431a0 Update format.yml 2024-09-03 21:44:29 -07:00
Jarred Sumner
c91afdb35c Github actions 2024-09-03 21:43:34 -07:00
Jarred Sumner
128d69dcbe Update format.yml 2024-09-03 21:34:52 -07:00
Jarred Sumner
cd6785771e run prettier and add back format action (#13722) 2024-09-03 21:32:52 -07:00
Jarred Sumner
5108e3e0d9 Add snapshot tests for dependency/version parsing (#13658) 2024-09-02 15:12:00 -07:00
Wilmer Paulino
bd3e62df40 Use JSMapIterator and JSSetIterator for deep equal comparisons (#13674) 2024-09-02 15:10:33 -07:00
Jarred Sumner
1668fde0a9 Support hot reloading when .css or any other imported file changes (#13665) 2024-09-02 15:07:25 -07:00
Jarred Sumner
12174e0577 Call cancel on ReadableStream when Bun.serve() response is aborted (#13687) 2024-09-02 09:40:03 -07:00
Jarred Sumner
c50f8d82d5 Remove outdated callout
Still very active! More stable though.
2024-09-02 05:07:05 -07:00
Jarred Sumner
d30767ea68 Fix crash when throwing an exception from napi (#13664) 2024-09-02 05:00:46 -07:00
Jarred Sumner
6b30c1b30d Add missing OOM exception check in Bun.escapeHTML (#13677) 2024-09-01 23:37:07 -07:00
Jarred Sumner
b64f1e15b5 Fixes #13629 (#13660) 2024-09-01 22:40:31 -07:00
Jarred Sumner
5f6015bb79 Fixes #13657 (#13667) 2024-09-01 18:21:34 -07:00
Jarred Sumner
f123814d87 Fix missing ERR_INVALID_ARG_TYPE in 2 buffer methods (#13617) 2024-09-01 04:40:14 -07:00
Jarred Sumner
ef4bcb314c Use -mmacos-version-min instead of -mmacosx-version-min (#13640) 2024-09-01 04:39:32 -07:00
Mohit Srivastava
fd2ad27b6f Change contributing docs to use llvm 18 on macos (#13651) 2024-09-01 00:31:45 -07:00
Jarred Sumner
03de99afcf Add tests for static routes + support server.reload for static routes (#13643) 2024-08-31 03:32:08 -07:00
Wilmer Paulino
9ba63eb522 Fix AES-GCM encryption of empty messages (#13646) 2024-08-31 02:29:16 -07:00
895 changed files with 13611 additions and 8449 deletions

1
.gitattributes vendored
View File

@@ -7,6 +7,7 @@
*.cpp text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.cc text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.yml text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.toml text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.zig text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.rs text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.h text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2

View File

@@ -2,11 +2,18 @@ name: bun install crash report
description: Report a crash in bun install
labels:
- npm
- crash
body:
- type: markdown
attributes:
value: |
**Thank you so much** for submitting a crash report. You're helping us make Bun more reliable for everyone!
- type: textarea
id: package_json
attributes:
label: `package.json` file
description: Can you upload your `package.json` file? This helps us reproduce the crash.
render: json
- type: textarea
id: repro
attributes:

View File

@@ -42,7 +42,7 @@ runs:
canary) release="canary";;
*) release="bun-v${{ inputs.bun-version }}";;
esac
curl -LO "${{ inputs.download-url }}/${release}/${target}.zip"
curl -LO "${{ inputs.download-url }}/${release}/${target}.zip" --retry 5
unzip ${target}.zip
mkdir -p ${{ runner.temp }}/.bun/bin
mv ${target}/bun* ${{ runner.temp }}/.bun/bin/

61
.github/workflows/format.yml vendored Normal file
View File

@@ -0,0 +1,61 @@
name: Format
permissions:
contents: write
concurrency:
group: format-${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && inputs.run-id || github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
run-id:
type: string
description: The workflow ID to download artifacts (skips the build step)
pull_request:
jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
.prettierrc-ci
.github
.vscode
src
scripts
packages
test
bench
package.json
bun.lockb
.clang-format
- name: Setup Bun
uses: ./.github/actions/setup-bun
with:
bun-version: "1.1.25"
- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0
- name: Install Dependencies
run: |
bun install
- name: Format
run: |
bun fmt
- name: Format Zig
run: |
bun fmt:zig
- name: Format Cpp
run: |
bun fmt:cpp
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Apply formatting changes

View File

@@ -14,22 +14,26 @@ jobs:
format:
name: Format
runs-on: ubuntu-latest
if: ${{ github.ref != 'refs/heads/main' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
.prettierrc-ci
.github
.vscode
src
scripts
packages
test
bench
package.json
bun.lockb
.clang-format
- name: Setup Bun
uses: ./.github/actions/setup-bun
with:
bun-version: "1.1.20"
bun-version: "1.1.25"
- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
@@ -43,9 +47,9 @@ jobs:
- name: Format Zig
run: |
bun fmt:zig
- name: Generate submodule versions
- name: Format Cpp
run: |
bash ./scripts/write-versions.sh
bun fmt:cpp
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v5
with:

View File

@@ -5,3 +5,6 @@ test/js/deno
test/node.js
src/react-refresh.js
*.min.js
test/js/node/test/fixtures
test/js/node/test/common
test/snippets

31
.prettierrc-ci Normal file
View File

@@ -0,0 +1,31 @@
{
"arrowParens": "avoid",
"printWidth": 120,
"trailingComma": "all",
"useTabs": false,
"quoteProps": "preserve",
"plugins": [
"prettier-plugin-organize-imports"
],
"overrides": [
{
"files": [
".vscode/*.json"
],
"options": {
"parser": "jsonc",
"quoteProps": "preserve",
"singleQuote": false,
"trailingComma": "all"
}
},
{
"files": [
"*.md"
],
"options": {
"printWidth": 80
}
}
]
}

View File

@@ -61,6 +61,7 @@
"[h]": {
"editor.defaultFormatter": "xaver.clang-format",
},
"clangd.arguments": ["-header-insertion=never"],
// JavaScript
"prettier.enable": true,

View File

@@ -1378,19 +1378,6 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT WIN32 AND NOT ASSERT_ENABLED)
)
endif()
if(WIN32)
# Kill all instances of bun before linking.
# This is necessary because the file is locked by the process.
add_custom_command(
TARGET ${bun}
PRE_LINK
COMMAND
"powershell"
"/C"
"Stop-Process -Name '${bun}' -Force -ErrorAction SilentlyContinue; exit 0"
)
endif()
# --- Dependencies ---
if(USE_CUSTOM_ZLIB)
include_directories(${BUN_DEPS_DIR}/zlib)

View File

@@ -63,7 +63,7 @@ Bun requires LLVM 16 (`clang` is part of LLVM). This version requirement is to m
{% codetabs %}
```bash#macOS (Homebrew)
$ brew install llvm@16
$ brew install llvm@18
```
```bash#Ubuntu/Debian

View File

@@ -366,7 +366,7 @@ ifeq ($(OS_NAME),linux)
endif
ifeq ($(OS_NAME),darwin)
MACOS_MIN_FLAG=-mmacosx-version-min=$(MIN_MACOS_VERSION)
MACOS_MIN_FLAG=-mmacos-version-min=$(MIN_MACOS_VERSION)
POSIX_PKG_MANAGER=brew
INCLUDE_DIRS += $(MAC_INCLUDE_DIRS)
endif

View File

@@ -24,8 +24,6 @@
## What is Bun?
> **Bun is under active development.** Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions. We're working on more complete Node.js compatibility and integration with existing frameworks. Join the [Discord](https://bun.sh/discord) and watch the [GitHub repository](https://github.com/oven-sh/bun) to keep tabs on future releases.
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called `bun`.
At its core is the _Bun runtime_, a fast JavaScript runtime designed as a drop-in replacement for Node.js. It's written in Zig and powered by JavaScriptCore under the hood, dramatically reducing startup times and memory usage.
@@ -87,16 +85,19 @@ bun upgrade --canary
## Quick links
- Intro
- [What is Bun?](https://bun.sh/docs/index)
- [Installation](https://bun.sh/docs/installation)
- [Quickstart](https://bun.sh/docs/quickstart)
- [TypeScript](https://bun.sh/docs/typescript)
- Templating
- [`bun init`](https://bun.sh/docs/cli/init)
- [`bun create`](https://bun.sh/docs/cli/bun-create)
- Runtime
- [`bun run`](https://bun.sh/docs/cli/run)
- [File types](https://bun.sh/docs/runtime/loaders)
- [TypeScript](https://bun.sh/docs/runtime/typescript)
@@ -115,6 +116,7 @@ bun upgrade --canary
- [Framework API](https://bun.sh/docs/runtime/framework)
- Package manager
- [`bun install`](https://bun.sh/docs/cli/install)
- [`bun add`](https://bun.sh/docs/cli/add)
- [`bun remove`](https://bun.sh/docs/cli/remove)
@@ -130,6 +132,7 @@ bun upgrade --canary
- [Overrides and resolutions](https://bun.sh/docs/install/overrides)
- Bundler
- [`Bun.build`](https://bun.sh/docs/bundler)
- [Loaders](https://bun.sh/docs/bundler/loaders)
- [Plugins](https://bun.sh/docs/bundler/plugins)
@@ -137,6 +140,7 @@ bun upgrade --canary
- [vs esbuild](https://bun.sh/docs/bundler/vs-esbuild)
- Test runner
- [`bun test`](https://bun.sh/docs/cli/test)
- [Writing tests](https://bun.sh/docs/test/writing)
- [Watch mode](https://bun.sh/docs/test/hot)
@@ -148,9 +152,11 @@ bun upgrade --canary
- [Code coverage](https://bun.sh/docs/test/coverage)
- Package runner
- [`bunx`](https://bun.sh/docs/cli/bunx)
- API
- [HTTP server](https://bun.sh/docs/api/http)
- [WebSockets](https://bun.sh/docs/api/websockets)
- [Workers](https://bun.sh/docs/api/workers)
@@ -183,9 +189,10 @@ bun upgrade --canary
- [Building Windows](https://bun.sh/docs/project/building-windows)
- [License](https://bun.sh/docs/project/licensing)
## Guides
## Guides
- Binary
- Binary
- [Convert a Blob to a DataView](https://bun.sh/guides/binary/blob-to-dataview)
- [Convert a Blob to a ReadableStream](https://bun.sh/guides/binary/blob-to-stream)
- [Convert a Blob to a string](https://bun.sh/guides/binary/blob-to-string)
@@ -209,7 +216,8 @@ bun upgrade --canary
- [Convert an ArrayBuffer to a Uint8Array](https://bun.sh/guides/binary/arraybuffer-to-typedarray)
- [Convert an ArrayBuffer to an array of numbers](https://bun.sh/guides/binary/arraybuffer-to-array)
- Ecosystem
- Ecosystem
- [Build a frontend using Vite and Bun](https://bun.sh/guides/ecosystem/vite)
- [Build an app with Astro and Bun](https://bun.sh/guides/ecosystem/astro)
- [Build an app with Next.js and Bun](https://bun.sh/guides/ecosystem/nextjs)
@@ -236,7 +244,8 @@ bun upgrade --canary
- [Use React and JSX](https://bun.sh/guides/ecosystem/react)
- [Add Sentry to a Bun app](https://bun.sh/guides/ecosystem/sentry)
- HTTP
- HTTP
- [Common HTTP server usage](https://bun.sh/guides/http/server)
- [Configure TLS on an HTTP server](https://bun.sh/guides/http/tls)
- [fetch with unix domain sockets in Bun](https://bun.sh/guides/http/fetch-unix)
@@ -250,7 +259,8 @@ bun upgrade --canary
- [Upload files via HTTP using FormData](https://bun.sh/guides/http/file-uploads)
- [Write a simple HTTP server](https://bun.sh/guides/http/simple)
- Install
- Install
- [Add a dependency](https://bun.sh/guides/install/add)
- [Add a development dependency](https://bun.sh/guides/install/add-dev)
- [Add a Git dependency](https://bun.sh/guides/install/add-git)
@@ -268,7 +278,8 @@ bun upgrade --canary
- [Using bun install with an Azure Artifacts npm registry](https://bun.sh/guides/install/azure-artifacts)
- [Using bun install with Artifactory](https://bun.sh/guides/install/jfrog-artifactory)
- Process
- Process
- [Get the process uptime in nanoseconds](https://bun.sh/guides/process/nanoseconds)
- [Listen for CTRL+C](https://bun.sh/guides/process/ctrl-c)
- [Listen to OS signals](https://bun.sh/guides/process/os-signals)
@@ -279,7 +290,8 @@ bun upgrade --canary
- [Spawn a child process](https://bun.sh/guides/process/spawn)
- [Spawn a child process and communicate using IPC](https://bun.sh/guides/process/ipc)
- Read file
- Read file
- [Check if a file exists](https://bun.sh/guides/read-file/exists)
- [Get the MIME type of a file](https://bun.sh/guides/read-file/mime)
- [Read a file as a ReadableStream](https://bun.sh/guides/read-file/stream)
@@ -290,7 +302,8 @@ bun upgrade --canary
- [Read a JSON file](https://bun.sh/guides/read-file/json)
- [Watch a directory for changes](https://bun.sh/guides/read-file/watch)
- Runtime
- Runtime
- [Debugging Bun with the VS Code extension](https://bun.sh/guides/runtime/vscode-debugger)
- [Debugging Bun with the web debugger](https://bun.sh/guides/runtime/web-debugger)
- [Define and replace static globals & constants](https://bun.sh/guides/runtime/define-constant)
@@ -305,7 +318,8 @@ bun upgrade --canary
- [Set a time zone in Bun](https://bun.sh/guides/runtime/timezone)
- [Set environment variables](https://bun.sh/guides/runtime/set-env)
- Streams
- Streams
- [Convert a Node.js Readable to a Blob](https://bun.sh/guides/streams/node-readable-to-blob)
- [Convert a Node.js Readable to a string](https://bun.sh/guides/streams/node-readable-to-string)
- [Convert a Node.js Readable to an ArrayBuffer](https://bun.sh/guides/streams/node-readable-to-arraybuffer)
@@ -318,7 +332,8 @@ bun upgrade --canary
- [Convert a ReadableStream to an ArrayBuffer](https://bun.sh/guides/streams/to-arraybuffer)
- [Convert a ReadableStream to JSON](https://bun.sh/guides/streams/to-json)
- Test
- Test
- [Bail early with the Bun test runner](https://bun.sh/guides/test/bail)
- [Generate code coverage reports with the Bun test runner](https://bun.sh/guides/test/coverage)
- [Mark a test as a "todo" with the Bun test runner](https://bun.sh/guides/test/todo-tests)
@@ -336,7 +351,8 @@ bun upgrade --canary
- [Use snapshot testing in `bun test`](https://bun.sh/guides/test/snapshot)
- [Write browser DOM tests with Bun and happy-dom](https://bun.sh/guides/test/happy-dom)
- Util
- Util
- [Check if the current file is the entrypoint](https://bun.sh/guides/util/entrypoint)
- [Check if two objects are deeply equal](https://bun.sh/guides/util/deep-equals)
- [Compress and decompress data with DEFLATE](https://bun.sh/guides/util/deflate)
@@ -355,13 +371,14 @@ bun upgrade --canary
- [Hash a password](https://bun.sh/guides/util/hash-a-password)
- [Sleep for a fixed number of milliseconds](https://bun.sh/guides/util/sleep)
- WebSocket
- WebSocket
- [Build a publish-subscribe WebSocket server](https://bun.sh/guides/websocket/pubsub)
- [Build a simple WebSocket server](https://bun.sh/guides/websocket/simple)
- [Enable compression for WebSocket messages](https://bun.sh/guides/websocket/compression)
- [Set per-socket contextual data on a WebSocket](https://bun.sh/guides/websocket/context)
- Write file
- Write file
- [Append content to a file](https://bun.sh/guides/write-file/append)
- [Copy a file to another location](https://bun.sh/guides/write-file/file-cp)
- [Delete a file](https://bun.sh/guides/write-file/unlink)

View File

@@ -1,4 +1,4 @@
import { run, bench } from "mitata";
import { bench, run } from "mitata";
bench("sync", () => {});
bench("async", async () => {});

View File

@@ -1,4 +1,4 @@
import { run, bench } from "../node_modules/mitata/src/cli.mjs";
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
bench("sync", () => {});
bench("async", async () => {});

View File

@@ -1,4 +1,4 @@
import { run, bench } from "mitata";
import { bench, run } from "mitata";
bench("sync", () => {});
bench("async", async () => {});

View File

@@ -1,5 +1,5 @@
import { copyFileSync, writeFileSync, readFileSync, statSync } from "node:fs";
import { bench, run } from "mitata";
import { copyFileSync, statSync, writeFileSync } from "node:fs";
function runner(ready) {
for (let size of [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) {

27
bench/deepEqual/map.js Normal file
View File

@@ -0,0 +1,27 @@
import { expect } from "bun:test";
import { bench, run } from "mitata";
const MAP_SIZE = 10_000;
function* genPairs(count) {
for (let i = 0; i < MAP_SIZE; i++) {
yield ["k" + i, "v" + i];
}
}
class CustomMap extends Map {
abc = 123;
constructor(iterable) {
super(iterable);
}
}
const a = new Map(genPairs());
const b = new Map(genPairs());
bench("deepEqual Map", () => expect(a).toEqual(b));
const x = new CustomMap(genPairs());
const y = new CustomMap(genPairs());
bench("deepEqual CustomMap", () => expect(x).toEqual(y));
await run();

27
bench/deepEqual/set.js Normal file
View File

@@ -0,0 +1,27 @@
import { expect } from "bun:test";
import { bench, run } from "mitata";
const SET_SIZE = 10_000;
function* genValues(count) {
for (let i = 0; i < SET_SIZE; i++) {
yield "v" + i;
}
}
class CustomSet extends Set {
abc = 123;
constructor(iterable) {
super(iterable);
}
}
const a = new Set(genValues());
const b = new Set(genValues());
bench("deepEqual Set", () => expect(a).toEqual(b));
const x = new CustomSet(genValues());
const y = new CustomSet(genValues());
bench("deepEqual CustomSet", () => expect(x).toEqual(y));
await run();

View File

@@ -1,4 +1,3 @@
import EventEmitter3 from "eventemitter3";
import { group } from "mitata";
import EventEmitterNative from "node:events";

View File

@@ -1,5 +1,5 @@
// bun:test automatically rewrites this import to bun:test when run in bun
import { test, expect } from "@jest/globals";
import { expect, test } from "@jest/globals";
const N = parseInt(process.env.RUN_COUNT || "10000", 10);
if (!Number.isSafeInteger(N)) {

View File

@@ -1,4 +1,4 @@
import { test, expect } from "vitest";
import { expect, test } from "vitest";
const N = parseInt(process.env.RUN_COUNT || "10000", 10);
if (!Number.isSafeInteger(N)) {

View File

@@ -1,5 +1,5 @@
import { ptr, dlopen, CString, toBuffer } from "bun:ffi";
import { run, bench, group } from "mitata";
import { CString, dlopen, ptr } from "bun:ffi";
import { bench, group, run } from "mitata";
const { napiNoop, napiHash, napiString } = require(import.meta.dir + "/src/ffi_napi_bench.node");

View File

@@ -1,4 +1,4 @@
import { run, bench, group } from "../node_modules/mitata/src/cli.mjs";
import { bench, group, run } from "../node_modules/mitata/src/cli.mjs";
const extension = "darwin" !== Deno.build.os ? "so" : "dylib";
const path = new URL("src/target/release/libffi_napi_bench." + extension, import.meta.url).pathname;

View File

@@ -1,4 +1,4 @@
import { run, bench, group } from "mitata";
import { bench, group, run } from "mitata";
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);

View File

@@ -1,5 +1,5 @@
import braces from "braces";
import { group, bench, run } from "mitata";
import { bench, group, run } from "mitata";
// const iterations = 1000;
const iterations = 100;

View File

@@ -1,6 +1,6 @@
import { run, bench, group } from "mitata";
import fg from "fast-glob";
import { fdir } from "fdir";
import { bench, group, run } from "mitata";
const normalPattern = "*.ts";
const recursivePattern = "**/*.ts";

View File

@@ -1,5 +1,5 @@
import { run, bench, group } from "mitata";
import { gzipSync, gunzipSync } from "bun";
import { gunzipSync, gzipSync } from "bun";
import { bench, group, run } from "mitata";
const data = await Bun.file(require.resolve("@babel/standalone/babel.min.js")).arrayBuffer();

View File

@@ -1,4 +1,4 @@
import { run, bench } from "../node_modules/mitata/src/cli.mjs";
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
const data = new TextEncoder().encode("Hello World!".repeat(9999));

View File

@@ -1,7 +1,7 @@
import { run, bench } from "mitata";
import { gzipSync, gunzipSync } from "zlib";
import { createRequire } from "module";
import { readFileSync } from "fs";
import { bench, run } from "mitata";
import { createRequire } from "module";
import { gunzipSync, gzipSync } from "zlib";
const require = createRequire(import.meta.url);
const data = readFileSync(require.resolve("@babel/standalone/babel.min.js"));

View File

@@ -1,6 +1,5 @@
import { Main } from "./main";
import classNames from "classnames";
import ReactDOM from "react-dom";
import { Main } from "./main";
const Base = ({}) => {
const name = typeof location !== "undefined" ? decodeURIComponent(location.search.substring(1)) : null;

View File

@@ -4,11 +4,11 @@
* For more information, see https://remix.run/docs/en/main/file-conventions/entry.server
*/
import { PassThrough } from "node:stream";
import type { EntryContext } from "@remix-run/node";
import { Response } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import isbot from "isbot";
import { PassThrough } from "node:stream";
import { renderToPipeableStream } from "react-dom/server";
const ABORT_DELAY = 5_000;

View File

@@ -1,21 +1,21 @@
import { bench, run } from "mitata";
import {
arch,
cpus,
endianness,
arch,
uptime,
networkInterfaces,
getPriority,
totalmem,
freemem,
getPriority,
homedir,
hostname,
loadavg,
networkInterfaces,
platform,
release,
setPriority,
tmpdir,
totalmem,
type,
uptime,
userInfo,
version,
} from "node:os";

View File

@@ -1,21 +1,21 @@
import { bench, run } from "mitata";
import {
arch,
cpus,
endianness,
arch,
uptime,
networkInterfaces,
getPriority,
totalmem,
freemem,
getPriority,
homedir,
hostname,
loadavg,
networkInterfaces,
platform,
release,
setPriority,
tmpdir,
totalmem,
type,
uptime,
userInfo,
version,
} from "node:os";

View File

@@ -1,5 +1,5 @@
import { renderToReadableStream } from "https://esm.run/react-dom/server";
import * as React from "https://esm.run/react";
import { renderToReadableStream } from "https://esm.run/react-dom/server";
const App = () => (
<html>

View File

@@ -1,6 +1,6 @@
// react-ssr.tsx
import { renderToPipeableStream } from "react-dom/server.node";
import React from "react";
import { renderToPipeableStream } from "react-dom/server.node";
const http = require("http");
const App = () => (
<html>

View File

@@ -1,5 +1,5 @@
import type { ActionFunction, LoaderFunction } from "remix";
import { useParams } from "remix";
import type { LoaderFunction, ActionFunction } from "remix";
export const loader: LoaderFunction = async ({ params }) => {
console.log(params.postId);

View File

@@ -1,5 +1,5 @@
import { bench, group, run } from "./runner.mjs";
import * as assert from "assert";
import { bench, run } from "./runner.mjs";
bench("deepEqual", () => {
assert.deepEqual({ foo: "123", bar: "baz" }, { foo: "123", bar: "baz" });

View File

@@ -1,7 +1,7 @@
// @runtime bun,node,deno
import { bench, run } from "./runner.mjs";
import process from "node:process";
import { Buffer } from "node:buffer";
import process from "node:process";
import { bench, run } from "./runner.mjs";
const N = parseInt(process.env.RUN_COUNTER ?? "10000", 10);
var isBuffer = new Buffer(0);

View File

@@ -1,6 +1,6 @@
import { bench, run } from "./runner.mjs";
import { Buffer } from "node:buffer";
import crypto from "node:crypto";
import { bench, run } from "./runner.mjs";
const bigBuffer = Buffer.from("hello world".repeat(10000));
const converted = bigBuffer.toString("base64");

View File

@@ -1,6 +1,6 @@
import { bench, group, run } from "./runner.mjs";
import { readFileSync } from "fs";
import { allocUnsafe } from "bun";
import { readFileSync } from "fs";
import { bench, group, run } from "./runner.mjs";
function polyfill(chunks) {
var size = 0;

View File

@@ -1,6 +1,6 @@
// so it can run in environments without node module resolution
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
import crypto from "node:crypto";
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
var foo = new Uint8Array(65536);
bench("crypto.getRandomValues(65536)", () => {
crypto.getRandomValues(foo);

View File

@@ -1,5 +1,5 @@
import { bench, group, run } from "./runner.mjs";
import fastDeepEquals from "fast-deep-equal/es6/index";
import { bench, group, run } from "./runner.mjs";
// const Date = globalThis.Date;
function func1() {}

View File

@@ -1,5 +1,5 @@
import { dns } from "bun";
import { bench, run, group } from "./runner.mjs";
import { bench, group, run } from "./runner.mjs";
async function forEachBackend(name, fn) {
group(name, () => {

View File

@@ -1,4 +1,4 @@
import { run, bench } from "../node_modules/mitata/src/cli.mjs";
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
const encoder = new TextEncoder();

View File

@@ -1,7 +1,4 @@
import { group } from "./runner.mjs";
import { bench, run } from "./runner.mjs";
import { encode as htmlEntityEncode } from "html-entities";
import { escape as heEscape } from "he";
import { bench, group, run } from "./runner.mjs";
var bunEscapeHTML = globalThis.escapeHTML || Bun.escapeHTML;

View File

@@ -1,4 +1,4 @@
import { viewSource, dlopen, CString, ptr, toBuffer, toArrayBuffer, FFIType, callback } from "bun:ffi";
import { dlopen } from "bun:ffi";
import { bench, group, run } from "./runner.mjs";
const types = {

View File

@@ -1,5 +1,5 @@
import { bench, run } from "./runner.mjs";
import { IncomingMessage } from "node:http";
import { bench, run } from "./runner.mjs";
const headers = {
date: "Mon, 06 Nov 2023 05:12:49 GMT",

View File

@@ -1,6 +1,6 @@
// @runtime node, bun
import { bench, run } from "./runner.mjs";
import * as vm from "node:vm";
import { bench, run } from "./runner.mjs";
const context = {
animal: "cat",

View File

@@ -24,7 +24,7 @@ const obj = {
w: 23,
};
import { bench, group, run } from "./runner.mjs";
import { bench, run } from "./runner.mjs";
var val = 0;
bench("Object.values(literal)", () => {

View File

@@ -1,4 +1,4 @@
import { pbkdf2, pbkdf2Sync } from "node:crypto";
import { pbkdf2 } from "node:crypto";
import { bench, run } from "./runner.mjs";

View File

@@ -1,5 +1,5 @@
import { bench, run } from "mitata";
import { peek } from "bun";
import { bench, run } from "mitata";
let pending = Bun.sleep(1000);
let resolved = Promise.resolve(1);

View File

@@ -1,4 +1,3 @@
import { group } from "./runner.mjs";
import { bench, run } from "./runner.mjs";
bench("performance.now x 1000", () => {
for (let i = 0; i < 1000; i++) {

View File

@@ -1,5 +1,5 @@
import { bench, run } from "./runner.mjs";
import { performance } from "perf_hooks";
import { bench, run } from "./runner.mjs";
bench("process.memoryUsage()", () => {
process.memoryUsage();

View File

@@ -1,6 +1,6 @@
import { bench, group, run } from "./runner.mjs";
import { renderToReadableStream } from "react-dom/server.browser";
import { renderToReadableStream as renderToReadableStreamBun } from "react-dom/server";
import { renderToReadableStream } from "react-dom/server.browser";
import { bench, group, run } from "./runner.mjs";
const App = () => (
<div>

View File

@@ -1,7 +1,7 @@
import { tmpdir } from "node:os";
import { bench, group, run } from "./runner.mjs";
import { createReadStream, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { sep } from "node:path";
import { bench, run } from "./runner.mjs";
if (!Promise.withResolvers) {
Promise.withResolvers = function () {

View File

@@ -1,10 +1,10 @@
import { readdirSync, readdir as readdirCb } from "fs";
import { createHash } from "crypto";
import { readdirSync } from "fs";
import { readdir } from "fs/promises";
import { bench, run } from "./runner.mjs";
import { relative, resolve } from "path";
import { argv } from "process";
import { fileURLToPath } from "url";
import { relative, resolve } from "path";
import { createHash } from "crypto";
import { bench, run } from "./runner.mjs";
let dir = resolve(argv.length > 2 ? argv[2] : fileURLToPath(new URL("../../node_modules", import.meta.url)));
if (dir.includes(process.cwd())) {

View File

@@ -1,6 +1,6 @@
import { bench, run } from "./runner.mjs";
import { readFileSync, existsSync } from "node:fs";
import { readFileSync } from "node:fs";
import { readFile } from "node:fs/promises";
import { bench, run } from "./runner.mjs";
bench(`readFileSync(/tmp/404-not-found)`, () => {
try {

View File

@@ -1,7 +1,7 @@
import { realpathSync } from "node:fs";
import { bench, run } from "./runner.mjs";
const count = parseInt(process.env.ITERATIONS || "1", 10) || 1;
const arg = process.argv[process.argv.length - 1];
import { bench, run } from "./runner.mjs";
bench("realpathSync x " + count, () => {
for (let i = 0; i < count; i++) realpathSync(arg, "utf-8");

View File

@@ -1,4 +1,4 @@
import decoding from "./jsx-entity-decoding";
import ReactDOMServer from "react-dom/server.browser";
import decoding from "./jsx-entity-decoding";
console.log(ReactDOMServer.renderToString(decoding));

View File

@@ -1,7 +1,6 @@
import { bench, run } from "./runner.mjs";
import { builtinModules } from "node:module";
import { writeFile } from "node:fs/promises";
import { spawnSync } from "child_process";
import { writeFile } from "node:fs/promises";
import { builtinModules } from "node:module";
for (let builtin of builtinModules) {
const path = `/tmp/require.${builtin.replaceAll("/", "_")}.cjs`;

View File

@@ -1,5 +1,5 @@
import { existsSync, mkdirSync, promises } from "node:fs";
import { tmpdir } from "node:os";
import { promises, existsSync, mkdirSync } from "node:fs";
const count = 1024 * 12;
var queue = new Array(count);

View File

@@ -1,9 +1,9 @@
// note: this isn't done yet
// we look for `// @runtime` in the file to determine which runtimes to run the benchmark in
import { spawnSync } from "bun";
import { readdirSync, readFileSync } from "node:fs";
import { Database } from "bun:sqlite";
import { extname, basename } from "path";
import { readdirSync, readFileSync } from "node:fs";
import { basename, extname } from "path";
const exts = [".js", ".ts", ".mjs", ".tsx"];

View File

@@ -1,5 +1,5 @@
import * as Mitata from "../node_modules/mitata/src/cli.mjs";
import process from "node:process";
import * as Mitata from "../node_modules/mitata/src/cli.mjs";
const asJSON = !!process?.env?.BENCHMARK_RUNNER;

View File

@@ -1,4 +1,4 @@
import { serialize, deserialize } from "node:v8";
import { deserialize, serialize } from "node:v8";
import { bench, run } from "./runner.mjs";
const obj = {
"id": 1296269,

View File

@@ -1,5 +1,3 @@
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
let count = 20_000_000;
const batchSize = 1_000_000;
console.time("Run");

View File

@@ -1,5 +1,5 @@
import { bench, run } from "./runner.mjs";
import { SHA512 } from "bun";
import { bench, run } from "./runner.mjs";
bench('SHA512.hash("hello world")', () => {
SHA512.hash("hello world");

View File

@@ -1,5 +1,5 @@
import { bench, run } from "./runner.mjs";
import { createHash } from "crypto";
import { bench, run } from "./runner.mjs";
bench('createHash("sha256").update("hello world").digest()', () => {
createHash("sha256").update("hello world").digest();

View File

@@ -1,6 +1,6 @@
import { $ as zx } from "zx";
import { $ as execa$ } from "execa";
import { bench, run, group } from "./runner.mjs";
import { $ as zx } from "zx";
import { bench, group, run } from "./runner.mjs";
const execa = execa$({ stdio: "ignore", cwd: import.meta.dirname });

View File

@@ -1,6 +1,6 @@
import { readdirSync, statSync } from "fs";
import { bench, run } from "./runner.mjs";
import { statSync } from "fs";
import { argv } from "process";
import { bench, run } from "./runner.mjs";
const dir = argv.length > 2 ? argv[2] : "/tmp";

View File

@@ -1,4 +1,4 @@
import { run, bench } from "./runner.mjs";
import { bench, run } from "./runner.mjs";
var writer = globalThis.Bun ? Bun.stderr.writer() : undefined;
if (writer)

View File

@@ -1,5 +1,5 @@
import { bench, run } from "./runner.mjs";
import { StringDecoder } from "string_decoder";
import { bench, run } from "./runner.mjs";
var short = Buffer.from("Hello World!");
var shortUTF16 = Buffer.from("Hello World 💕💕💕");

View File

@@ -1,5 +1,5 @@
import { bench, run } from "./runner.mjs";
import npmStringWidth from "string-width";
import { bench, run } from "./runner.mjs";
const bunStringWidth = globalThis?.Bun?.stringWidth;

View File

@@ -1,4 +1,4 @@
import { listen, connect } from "bun";
import { connect, listen } from "bun";
var counter = 0;
const msg = "Hello World!";

View File

@@ -1,8 +1,8 @@
import { readFileSync } from "fs";
import { createRequire } from "module";
import { dirname } from "path";
import { fileURLToPath } from "url";
import { bench, run, group } from "./runner.mjs";
import { createRequire } from "module";
import { bench, group, run } from "./runner.mjs";
const require = createRequire(import.meta.url);
const esbuild_ = require("esbuild/lib/main");
const swc_ = require("@swc/core");

View File

@@ -1,4 +1,4 @@
import { readFileSync, writeFileSync } from "node:fs";
import { writeFileSync } from "node:fs";
import { bench, run } from "./runner.mjs";
var short = "Hello World!";

View File

@@ -1,6 +1,6 @@
import { bench, run } from "./runner.mjs";
import { write } from "bun";
import { openSync } from "fs";
import { bench, run } from "./runner.mjs";
bench('write(/tmp/foo.txt, "short string")', async () => {
await write("/tmp/foo.txt", "short string");

View File

@@ -1,9 +1,8 @@
// @runtime node, bun, deno
import { bench, run } from "./runner.mjs";
import { Buffer } from "node:buffer";
import { openSync } from "node:fs";
import { openSync, writeSync as write } from "node:fs";
import { writeFile } from "node:fs/promises";
import { writeSync as write } from "node:fs";
import { bench, run } from "./runner.mjs";
bench("writeFile(/tmp/foo.txt, short string)", async () => {
await writeFile("/tmp/foo.txt", "short string", "utf8");

View File

@@ -1,4 +1,4 @@
import { run, bench } from "mitata";
import { bench, run } from "mitata";
import { createRequire } from "module";
const require = createRequire(import.meta.url);

View File

@@ -1,5 +1,5 @@
import { run, bench } from "mitata";
import { Database } from "bun:sqlite";
import { bench, run } from "mitata";
import { join } from "path";
const db = Database.open(join(import.meta.dir, "src", "northwind.sqlite"));

View File

@@ -1,5 +1,5 @@
import { Database } from "https://deno.land/x/sqlite3@0.11.1/mod.ts";
import { run, bench } from "../node_modules/mitata/src/cli.mjs";
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
const db = new Database("./src/northwind.sqlite");

View File

@@ -1,6 +1,6 @@
// Run `node --experimental-sqlite bench/sqlite/node.mjs` to run the script.
// You will need `--experimental-sqlite` flag to run this script and node v22.5.0 or higher.
import { run, bench } from "mitata";
import { bench, run } from "mitata";
import { DatabaseSync as Database } from "node:sqlite";
const db = new Database("./src/northwind.sqlite");

7
bench/tsconfig.json Normal file
View File

@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
// For the organize imports plugin
"jsx": "react"
}
}

BIN
bun.lockb

Binary file not shown.

View File

@@ -70,16 +70,37 @@ const server = Bun.serve({
});
```
### `static` responses
### Static routes
Serve static responses by route with the `static` option
Use the `static` option to serve static `Response` objects by route.
```ts
// Bun v1.1.27+ required
Bun.serve({
static: {
// health-check endpoint
"/api/health-check": new Response("All good!"),
// redirect from /old-link to /new-link
"/old-link": Response.redirect("/new-link", 301),
// serve static text
"/": new Response("Hello World"),
// server a file by buffering it in memory
"/index.html": new Response(await Bun.file("./index.html").bytes(), {
headers: {
"Content-Type": "text/html",
},
}),
"/favicon.ico": new Response(await Bun.file("./favicon.ico").bytes(), {
headers: {
"Content-Type": "image/x-icon",
},
}),
// serve JSON
"/api/version.json": Response.json({ version: "1.0.0" }),
},
fetch(req) {
@@ -88,10 +109,77 @@ Bun.serve({
});
```
Static routes support headers, status code, and other `Response` options.
```ts
Bun.serve({
static: {
"/api/time": new Response(new Date().toISOString(), {
headers: {
"X-Custom-Header": "Bun!",
},
}),
},
fetch(req) {
return new Response("404!");
},
});
```
Static routes can serve Response bodies faster than `fetch` handlers because they don't create `Request` objects, they don't create `AbortSignal`, they don't create additional `Response` objects. The only per-request memory allocation is the TCP/TLS socket data needed for each request.
{% note %}
`static` is experimental and may change in the future.
`static` is experimental
{% /note %}
Static route responses are cached for the lifetime of the server object. To reload static routes, call `server.reload(options)`.
```ts
const server = Bun.serve({
static: {
"/api/time": new Response(new Date().toISOString()),
},
fetch(req) {
return new Response("404!");
},
});
// Update the time every second.
setInterval(() => {
server.reload({
static: {
"/api/time": new Response(new Date().toISOString()),
},
fetch(req) {
return new Response("404!");
},
});
}, 1000);
```
Reloading static routes only impact the next request. In-flight requests continue to use the old static routes. After in-flight requests to old static routes are finished, the old static routes are freed from memory.
To simplify error handling, static routes do not support streaming response bodies from `ReadableStream` or an `AsyncIterator`. Fortunately, you can still buffer the response in memory first:
```ts
const time = await fetch("https://api.example.com/v1/data");
// Buffer the response in memory first.
const blob = await time.blob();
const server = Bun.serve({
static: {
"/api/data": new Response(blob),
},
fetch(req) {
return new Response("404!");
},
});
```
### Changing the `port` and `hostname`
To configure which port and hostname the server will listen on, set `port` and `hostname` in the options object.
@@ -348,7 +436,24 @@ Bun.serve({
});
```
## Object syntax
## idleTimeout
To configure the idle timeout, set the `idleTimeout` field in Bun.serve.
```ts
Bun.serve({
// 10 seconds:
idleTimeout: 10,
fetch(req) {
return new Response("Bun!");
},
});
```
This is the maximum amount of time a connection is allowed to be idle before the server closes it. A connection is idling if there is no data sent or received.
## export default syntax
Thus far, the examples on this page have used the explicit `Bun.serve` API. Bun also supports an alternate syntax.

View File

@@ -4,7 +4,7 @@ It's about 20x faster than `node-semver`.
![Benchmark](https://github.com/oven-sh/bun/assets/709451/94746adc-8aba-4baf-a143-3c355f8e0f78)
Currently, this API is two functions.
Currently, this API provides two functions :
#### `Bun.semver.satisfies(version: string, range: string): boolean`

View File

@@ -419,7 +419,7 @@ const results = query.all("hello", "goodbye");
sqlite supports signed 64 bit integers, but JavaScript only supports signed 52 bit integers or arbitrary precision integers with `bigint`.
`bigint` input is supported everywhere, but by default `bun:sqlite` returns integers as `number` types. If you need to handle integers larger than 2^53, set `safeInteger` option to `true` when creating a `Database` instance. This also validates that `bigint` passed to `bun:sqlite` do not exceed 64 bits.
`bigint` input is supported everywhere, but by default `bun:sqlite` returns integers as `number` types. If you need to handle integers larger than 2^53, set `safeIntegers` option to `true` when creating a `Database` instance. This also validates that `bigint` passed to `bun:sqlite` do not exceed 64 bits.
By default, `bun:sqlite` returns integers as `number` types. If you need to handle integers larger than 2^53, you can use the `bigint` type.

View File

@@ -16,10 +16,6 @@ $ bun test # run tests
$ bunx cowsay 'Hello, world!' # execute a package
```
{% callout type="note" %}
**Bun is still under development.** Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions. We're working on more complete Node.js compatibility and integration with existing frameworks. Join the [Discord](https://bun.sh/discord) and watch the [GitHub repository](https://github.com/oven-sh/bun) to keep tabs on future releases.
{% /callout %}
Get started with one of the quick links below, or read on to learn more about Bun.
{% block className="gap-2 grid grid-flow-row grid-cols-1 md:grid-cols-2" %}

View File

@@ -27,4 +27,4 @@ To configure a private registry scoped to a particular organization:
### `.npmrc`
Bun does not currently read `.npmrc` files. For private registries, migrate your registry configuration to `bunfig.toml` as documented above.
Bun also reads `.npmrc` files, [learn more](/docs/install/npmrc).

22
jsconfig.json Normal file
View File

@@ -0,0 +1,22 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"importsNotUsedAsValues": "preserve"
},
"include": [".", "packages/bun-types/index.d.ts"],
"exclude": [
"src/test",
"src/js/out",
// "src/js/builtins",
"packages",
"bench",
"examples/*/*",
"test",
"src/deps",
"bun-webkit",
"src/bun.js/WebKit",
"src/api/demo",
"node_modules"
],
"files": ["src/js/builtins.d.ts"]
}

View File

@@ -5,6 +5,10 @@
"./packages/bun-types"
],
"devDependencies": {
"@types/bun": "^1.1.3",
"@types/react": "^18.3.3",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"@vscode/debugadapter": "^1.65.0",
"esbuild": "^0.21.4",
"eslint": "^9.4.0",
@@ -12,14 +16,11 @@
"mitata": "^0.1.11",
"peechy": "0.4.34",
"prettier": "^3.2.5",
"prettier-plugin-organize-imports": "^4.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"source-map-js": "^1.2.0",
"typescript": "^5.4.5",
"@types/bun": "^1.1.3",
"@types/react": "^18.3.3",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0"
"typescript": "^5.4.5"
},
"resolutions": {
"bun-types": "workspace:packages/bun-types"
@@ -39,8 +40,9 @@
"build:windows": "cmake -B build -S . -G Ninja -DCMAKE_BUILD_TYPE=Debug && ninja -Cbuild",
"build:windows:release": "cmake -B build-release -S . -G Ninja -DCMAKE_BUILD_TYPE=Release && ninja -Cbuild-release",
"typecheck": "tsc --noEmit && cd test && bun run typecheck",
"fmt": "prettier --write --cache './{.vscode,src,test,bench,packages/{bun-types,bun-inspector-*,bun-vscode,bun-debug-adapter-protocol}}/**/*.{mjs,ts,tsx,js,jsx}'",
"fmt": "prettier --config=.prettierrc-ci --write --cache './{.vscode,src,test,bench,packages/{bun-types,bun-inspector-*,bun-vscode,bun-debug-adapter-protocol}}/**/*.{mjs,ts,tsx,js,jsx}'",
"fmt:zig": "zig fmt src/*.zig src/*/*.zig src/*/*/*.zig src/*/*/*/*.zig",
"fmt:cpp": "clang-format -i src/bun.js/bindings/**/*.{cpp,h} --verbose",
"lint": "eslint './**/*.d.ts' --cache",
"lint:fix": "eslint './**/*.d.ts' --cache --fix",
"test": "node scripts/runner.node.mjs ./build/bun-debug",

View File

@@ -1,3 +1,3 @@
export type * from "./src/protocol";
export * from "./src/debugger/adapter";
export * from "./src/debugger/signal";
export type * from "./src/protocol";

View File

@@ -1,6 +1,6 @@
import type { Protocol, Type } from "../src/protocol/schema";
import { writeFileSync } from "node:fs";
import { spawnSync } from "node:child_process";
import { writeFileSync } from "node:fs";
import type { Protocol, Type } from "../src/protocol/schema";
run().catch(console.error);

View File

@@ -1,13 +1,13 @@
import type { DAP } from "../protocol";
import type { JSC } from "../../../bun-inspector-protocol/src/protocol";
import type { InspectorEventMap } from "../../../bun-inspector-protocol/src/inspector";
import type { JSC } from "../../../bun-inspector-protocol/src/protocol";
import type { DAP } from "../protocol";
// @ts-ignore
import { WebSocketInspector, remoteObjectToString } from "../../../bun-inspector-protocol/index";
import type { ChildProcess } from "node:child_process";
import { spawn } from "node:child_process";
import { Location, SourceMap } from "./sourcemap";
import { EventEmitter } from "node:events";
import { WebSocketInspector, remoteObjectToString } from "../../../bun-inspector-protocol/index";
import { UnixSignal, randomUnixPath } from "./signal";
import { Location, SourceMap } from "./sourcemap";
const capabilities: DAP.Capabilities = {
supportsConfigurationDoneRequest: true,

View File

@@ -1,8 +1,8 @@
import { tmpdir } from "node:os";
import { join } from "node:path";
import { EventEmitter } from "node:events";
import type { Server } from "node:net";
import { createServer } from "node:net";
import { EventEmitter } from "node:events";
import { tmpdir } from "node:os";
import { join } from "node:path";
const isDebug = process.env.NODE_ENV === "development";

View File

@@ -1,4 +1,4 @@
import { test, expect } from "bun:test";
import { expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { SourceMap } from "./sourcemap";

View File

@@ -1,4 +1,3 @@
import { build } from "esbuild";
import { copyFileSync, mkdirSync, readdirSync, rmSync, statSync } from "fs";
import { join } from "path";

View File

@@ -1,4 +1,4 @@
export type * from "./src/protocol";
export type * from "./src/inspector";
export * from "./src/util/preview";
export * from "./src/inspector/websocket";
export type * from "./src/protocol";
export * from "./src/util/preview";

View File

@@ -1,6 +1,6 @@
import type { Protocol, Domain, Property } from "../src/protocol/schema";
import { readFileSync, writeFileSync } from "node:fs";
import { spawnSync } from "node:child_process";
import { readFileSync, writeFileSync } from "node:fs";
import type { Domain, Property, Protocol } from "../src/protocol/schema";
run().catch(console.error);

View File

@@ -1,7 +1,7 @@
import type { Inspector, InspectorEventMap } from ".";
import type { JSC } from "../protocol";
import { EventEmitter } from "node:events";
import { WebSocket } from "ws";
import type { Inspector, InspectorEventMap } from ".";
import type { JSC } from "../protocol";
/**
* An inspector that communicates with a debugger over a WebSocket.

View File

@@ -1,7 +1,7 @@
import { describe, test, expect, mock, beforeAll, afterAll } from "bun:test";
import { WebSocketInspector } from "../../src/inspector/websocket";
import type { Server } from "bun";
import { serve } from "bun";
import { afterAll, beforeAll, describe, expect, mock, test } from "bun:test";
import { WebSocketInspector } from "../../src/inspector/websocket";
let server: Server;
let url: URL;

Some files were not shown because too many files have changed in this diff Show More