mirror of
https://github.com/oven-sh/bun
synced 2026-02-25 02:57:27 +01:00
Compare commits
15 Commits
codex/upda
...
pfg/util-i
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91225b53c1 | ||
|
|
d533b602e5 | ||
|
|
43f780618d | ||
|
|
3fb9ff5b53 | ||
|
|
d2011e4f98 | ||
|
|
344264dbdc | ||
|
|
5e864d6e47 | ||
|
|
5f05a8ba74 | ||
|
|
5354232e77 | ||
|
|
ebbb6b63fa | ||
|
|
94afa51dde | ||
|
|
ecbb0384bc | ||
|
|
16518f54a2 | ||
|
|
1429f68c99 | ||
|
|
3d59e35db2 |
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -54,4 +54,3 @@ test/js/node/test/common linguist-vendored
|
||||
test/js/bun/css/files linguist-vendored
|
||||
|
||||
.vscode/*.json linguist-language=JSON-with-Comments
|
||||
src/cli/init/tsconfig.default.json linguist-language=JSON-with-Comments
|
||||
27
.github/workflows/labeled.yml
vendored
27
.github/workflows/labeled.yml
vendored
@@ -69,6 +69,7 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
LABELS=$(bun scripts/read-issue.ts)
|
||||
echo "labels=$LABELS" >> $GITHUB_OUTPUT
|
||||
bun scripts/is-outdated.ts
|
||||
|
||||
if [[ -f "is-outdated.txt" ]]; then
|
||||
@@ -76,19 +77,12 @@ jobs:
|
||||
fi
|
||||
|
||||
if [[ -f "outdated.txt" ]]; then
|
||||
echo "outdated=$(cat outdated.txt)" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
if [[ -f "is-very-outdated.txt" ]]; then
|
||||
echo "is-very-outdated=true" >> $GITHUB_OUTPUT
|
||||
LABELS="$LABELS,old-version"
|
||||
else
|
||||
echo "is-very-outdated=false" >> $GITHUB_OUTPUT
|
||||
echo "oudated=$(cat outdated.txt)" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
echo "latest=$(cat LATEST)" >> $GITHUB_OUTPUT
|
||||
echo "labels=$LABELS" >> $GITHUB_OUTPUT
|
||||
rm -rf is-outdated.txt outdated.txt latest.txt is-very-outdated.txt
|
||||
|
||||
rm -rf is-outdated.txt outdated.txt latest.txt
|
||||
- name: Generate comment text with Sentry Link
|
||||
if: github.event.label.name == 'crash'
|
||||
# ignore if fail
|
||||
@@ -108,14 +102,7 @@ jobs:
|
||||
if [[ -f "sentry-id.txt" ]]; then
|
||||
echo "sentry-id=$(cat sentry-id.txt)" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
- name: Remove old labels
|
||||
uses: actions-cool/issues-helper@v3
|
||||
if: github.event.label.name == 'crash' && steps.add-labels.outputs.is-very-outdated == 'false'
|
||||
with:
|
||||
actions: "remove-labels"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
labels: old-version
|
||||
|
||||
- name: Add labels
|
||||
uses: actions-cool/issues-helper@v3
|
||||
if: github.event.label.name == 'crash'
|
||||
@@ -132,7 +119,7 @@ jobs:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
body: |
|
||||
@${{ github.event.issue.user.login }}, the latest version of Bun is v${{ steps.add-labels.outputs.latest }}, but this crash was reported on Bun v${{ steps.add-labels.outputs.outdated }}.
|
||||
@${{ github.event.issue.user.login }}, the latest version of Bun is v${{ steps.add-labels.outputs.latest }}, but this crash was reported on Bun v${{ steps.add-labels.outputs.oudated }}.
|
||||
|
||||
Are you able to reproduce this crash on the latest version of Bun?
|
||||
|
||||
@@ -147,7 +134,7 @@ jobs:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
body: |
|
||||
@${{ github.event.issue.user.login }}, thank you for reporting this crash. The latest version of Bun is v${{ steps.add-labels.outputs.latest }}, but this crash was reported on Bun v${{ steps.add-labels.outputs.outdated }}.
|
||||
@${{ github.event.issue.user.login }}, thank you for reporting this crash. The latest version of Bun is v${{ steps.add-labels.outputs.latest }}, but this crash was reported on Bun v${{ steps.add-labels.outputs.oudated }}.
|
||||
|
||||
Are you able to reproduce this crash on the latest version of Bun?
|
||||
|
||||
|
||||
11
.vscode/launch.json
generated
vendored
11
.vscode/launch.json
generated
vendored
@@ -1113,17 +1113,6 @@
|
||||
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
|
||||
},
|
||||
},
|
||||
{
|
||||
"type": "bun",
|
||||
"name": "[JS] bun run [file]",
|
||||
"runtime": "${workspaceFolder}/build/debug/bun-debug",
|
||||
"runtimeArgs": ["run", "${file}"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"BUN_DEBUG_QUIET_LOGS": "1",
|
||||
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
|
||||
},
|
||||
},
|
||||
{
|
||||
"type": "midas-rr",
|
||||
"request": "attach",
|
||||
|
||||
36
AGENTS.md
36
AGENTS.md
@@ -1,36 +0,0 @@
|
||||
## bun tests
|
||||
|
||||
**IMPORTANT**: use the `bun agent` command instead of the `bun` command. For example:
|
||||
|
||||
✅ Good
|
||||
|
||||
```sh
|
||||
bun agent test internal/ban-words.test.ts
|
||||
bun agent ./foo.ts
|
||||
```
|
||||
|
||||
The `bun agent` command runs the DEBUG build. If you forget to run the debug build, your changes will not be reflected..
|
||||
|
||||
### Run a file
|
||||
|
||||
To run a file, you can use the `bun agent <file-path>` command.
|
||||
|
||||
```sh
|
||||
bun agent ./foo.ts
|
||||
```
|
||||
|
||||
### Run tests
|
||||
|
||||
To run a single test, you need to use the `bun agent test <test-name>` command.
|
||||
|
||||
```sh
|
||||
bun agent test internal/ban-words.test.ts
|
||||
```
|
||||
|
||||
You must ALWAYS make sure to pass a file path to the `bun agent test <file-path>` command. DO NOT try to run ALL the tests at once unless you're in a specific subdirectory.
|
||||
|
||||
### Run a Node.js test
|
||||
|
||||
```sh
|
||||
bun agent --silent node:test test-fs-link
|
||||
```
|
||||
254
README.md
254
README.md
@@ -96,14 +96,10 @@ bun upgrade --canary
|
||||
- [`bun init`](https://bun.sh/docs/cli/init)
|
||||
- [`bun create`](https://bun.sh/docs/cli/bun-create)
|
||||
|
||||
- CLI
|
||||
|
||||
- [`bun upgrade`](https://bun.sh/docs/cli/bun-upgrade)
|
||||
|
||||
- Runtime
|
||||
|
||||
- [`bun run`](https://bun.sh/docs/cli/run)
|
||||
- [File types (Loaders)](https://bun.sh/docs/runtime/loaders)
|
||||
- [File types](https://bun.sh/docs/runtime/loaders)
|
||||
- [TypeScript](https://bun.sh/docs/runtime/typescript)
|
||||
- [JSX](https://bun.sh/docs/runtime/jsx)
|
||||
- [Environment variables](https://bun.sh/docs/runtime/env)
|
||||
@@ -112,12 +108,12 @@ bun upgrade --canary
|
||||
- [Node.js compatibility](https://bun.sh/docs/runtime/nodejs-apis)
|
||||
- [Single-file executable](https://bun.sh/docs/bundler/executables)
|
||||
- [Plugins](https://bun.sh/docs/runtime/plugins)
|
||||
- [Watch mode / Hot Reloading](https://bun.sh/docs/runtime/hot)
|
||||
- [Watch mode](https://bun.sh/docs/runtime/hot)
|
||||
- [Module resolution](https://bun.sh/docs/runtime/modules)
|
||||
- [Auto-install](https://bun.sh/docs/runtime/autoimport)
|
||||
- [bunfig.toml](https://bun.sh/docs/runtime/bunfig)
|
||||
- [Debugger](https://bun.sh/docs/runtime/debugger)
|
||||
- [$ Shell](https://bun.sh/docs/runtime/shell)
|
||||
- [Framework API](https://bun.sh/docs/runtime/framework)
|
||||
|
||||
- Package manager
|
||||
|
||||
@@ -126,12 +122,7 @@ bun upgrade --canary
|
||||
- [`bun remove`](https://bun.sh/docs/cli/remove)
|
||||
- [`bun update`](https://bun.sh/docs/cli/update)
|
||||
- [`bun link`](https://bun.sh/docs/cli/link)
|
||||
- [`bun unlink`](https://bun.sh/docs/cli/unlink)
|
||||
- [`bun pm`](https://bun.sh/docs/cli/pm)
|
||||
- [`bun outdated`](https://bun.sh/docs/cli/outdated)
|
||||
- [`bun publish`](https://bun.sh/docs/cli/publish)
|
||||
- [`bun patch`](https://bun.sh/docs/install/patch)
|
||||
- [`bun patch-commit`](https://bun.sh/docs/cli/patch-commit)
|
||||
- [Global cache](https://bun.sh/docs/install/cache)
|
||||
- [Workspaces](https://bun.sh/docs/install/workspaces)
|
||||
- [Lifecycle scripts](https://bun.sh/docs/install/lifecycle)
|
||||
@@ -139,7 +130,6 @@ bun upgrade --canary
|
||||
- [Lockfile](https://bun.sh/docs/install/lockfile)
|
||||
- [Scopes and registries](https://bun.sh/docs/install/registries)
|
||||
- [Overrides and resolutions](https://bun.sh/docs/install/overrides)
|
||||
- [`.npmrc`](https://bun.sh/docs/install/npmrc)
|
||||
|
||||
- Bundler
|
||||
|
||||
@@ -148,11 +138,6 @@ bun upgrade --canary
|
||||
- [Plugins](https://bun.sh/docs/bundler/plugins)
|
||||
- [Macros](https://bun.sh/docs/bundler/macros)
|
||||
- [vs esbuild](https://bun.sh/docs/bundler/vs-esbuild)
|
||||
- [Single-file executable](https://bun.sh/docs/bundler/executables)
|
||||
- [CSS](https://bun.sh/docs/bundler/css)
|
||||
- [HTML](https://bun.sh/docs/bundler/html)
|
||||
- [Hot Module Replacement (HMR)](https://bun.sh/docs/bundler/hmr)
|
||||
- [Full-stack with HTML imports](https://bun.sh/docs/bundler/fullstack)
|
||||
|
||||
- Test runner
|
||||
|
||||
@@ -165,10 +150,6 @@ bun upgrade --canary
|
||||
- [Dates and times](https://bun.sh/docs/test/time)
|
||||
- [DOM testing](https://bun.sh/docs/test/dom)
|
||||
- [Code coverage](https://bun.sh/docs/test/coverage)
|
||||
- [Configuration](https://bun.sh/docs/test/configuration)
|
||||
- [Discovery](https://bun.sh/docs/test/discovery)
|
||||
- [Reporters](https://bun.sh/docs/test/reporters)
|
||||
- [Runtime Behavior](https://bun.sh/docs/test/runtime-behavior)
|
||||
|
||||
- Package runner
|
||||
|
||||
@@ -176,235 +157,219 @@ bun upgrade --canary
|
||||
|
||||
- API
|
||||
|
||||
- [HTTP server (`Bun.serve`)](https://bun.sh/docs/api/http)
|
||||
- [HTTP server](https://bun.sh/docs/api/http)
|
||||
- [WebSockets](https://bun.sh/docs/api/websockets)
|
||||
- [Workers](https://bun.sh/docs/api/workers)
|
||||
- [Binary data](https://bun.sh/docs/api/binary-data)
|
||||
- [Streams](https://bun.sh/docs/api/streams)
|
||||
- [File I/O (`Bun.file`)](https://bun.sh/docs/api/file-io)
|
||||
- [File I/O](https://bun.sh/docs/api/file-io)
|
||||
- [import.meta](https://bun.sh/docs/api/import-meta)
|
||||
- [SQLite (`bun:sqlite`)](https://bun.sh/docs/api/sqlite)
|
||||
- [PostgreSQL (`Bun.sql`)](https://bun.sh/docs/api/sql)
|
||||
- [Redis (`Bun.redis`)](https://bun.sh/docs/api/redis)
|
||||
- [S3 Client (`Bun.s3`)](https://bun.sh/docs/api/s3)
|
||||
- [SQLite](https://bun.sh/docs/api/sqlite)
|
||||
- [FileSystemRouter](https://bun.sh/docs/api/file-system-router)
|
||||
- [TCP sockets](https://bun.sh/docs/api/tcp)
|
||||
- [UDP sockets](https://bun.sh/docs/api/udp)
|
||||
- [Globals](https://bun.sh/docs/api/globals)
|
||||
- [$ Shell](https://bun.sh/docs/runtime/shell)
|
||||
- [Child processes (spawn)](https://bun.sh/docs/api/spawn)
|
||||
- [Transpiler (`Bun.Transpiler`)](https://bun.sh/docs/api/transpiler)
|
||||
- [Child processes](https://bun.sh/docs/api/spawn)
|
||||
- [Transpiler](https://bun.sh/docs/api/transpiler)
|
||||
- [Hashing](https://bun.sh/docs/api/hashing)
|
||||
- [Colors (`Bun.color`)](https://bun.sh/docs/api/color)
|
||||
- [Console](https://bun.sh/docs/api/console)
|
||||
- [FFI (`bun:ffi`)](https://bun.sh/docs/api/ffi)
|
||||
- [C Compiler (`bun:ffi` cc)](https://bun.sh/docs/api/cc)
|
||||
- [FFI](https://bun.sh/docs/api/ffi)
|
||||
- [HTMLRewriter](https://bun.sh/docs/api/html-rewriter)
|
||||
- [Testing (`bun:test`)](https://bun.sh/docs/api/test)
|
||||
- [Cookies (`Bun.Cookie`)](https://bun.sh/docs/api/cookie)
|
||||
- [Testing](https://bun.sh/docs/api/test)
|
||||
- [Utils](https://bun.sh/docs/api/utils)
|
||||
- [Node-API](https://bun.sh/docs/api/node-api)
|
||||
- [Glob (`Bun.Glob`)](https://bun.sh/docs/api/glob)
|
||||
- [Semver (`Bun.semver`)](https://bun.sh/docs/api/semver)
|
||||
- [DNS](https://bun.sh/docs/api/dns)
|
||||
- [fetch API extensions](https://bun.sh/docs/api/fetch)
|
||||
- [Glob](https://bun.sh/docs/api/glob)
|
||||
- [Semver](https://bun.sh/docs/api/semver)
|
||||
|
||||
- Project
|
||||
- [Roadmap](https://bun.sh/docs/project/roadmap)
|
||||
- [Benchmarking](https://bun.sh/docs/project/benchmarking)
|
||||
- [Contributing](https://bun.sh/docs/project/contributing)
|
||||
- [Building Windows](https://bun.sh/docs/project/building-windows)
|
||||
- [License](https://bun.sh/docs/project/licensing)
|
||||
|
||||
## Guides
|
||||
|
||||
- Binary
|
||||
|
||||
- [Convert a Blob to a string](https://bun.sh/guides/binary/blob-to-string)
|
||||
- [Convert a Buffer to a blob](https://bun.sh/guides/binary/buffer-to-blob)
|
||||
- [Convert a Blob to a DataView](https://bun.sh/guides/binary/blob-to-dataview)
|
||||
- [Convert a Buffer to a string](https://bun.sh/guides/binary/buffer-to-string)
|
||||
- [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)
|
||||
- [Convert a Blob to a Uint8Array](https://bun.sh/guides/binary/blob-to-typedarray)
|
||||
- [Convert a Blob to an ArrayBuffer](https://bun.sh/guides/binary/blob-to-arraybuffer)
|
||||
- [Convert a Buffer to a blob](https://bun.sh/guides/binary/buffer-to-blob)
|
||||
- [Convert a Buffer to a ReadableStream](https://bun.sh/guides/binary/buffer-to-readablestream)
|
||||
- [Convert a Buffer to a string](https://bun.sh/guides/binary/buffer-to-string)
|
||||
- [Convert a Buffer to a Uint8Array](https://bun.sh/guides/binary/buffer-to-typedarray)
|
||||
- [Convert a Buffer to an ArrayBuffer](https://bun.sh/guides/binary/buffer-to-arraybuffer)
|
||||
- [Convert a DataView to a string](https://bun.sh/guides/binary/dataview-to-string)
|
||||
- [Convert a Uint8Array to a Blob](https://bun.sh/guides/binary/typedarray-to-blob)
|
||||
- [Convert a Blob to an ArrayBuffer](https://bun.sh/guides/binary/blob-to-arraybuffer)
|
||||
- [Convert an ArrayBuffer to a Blob](https://bun.sh/guides/binary/arraybuffer-to-blob)
|
||||
- [Convert a Buffer to a Uint8Array](https://bun.sh/guides/binary/buffer-to-typedarray)
|
||||
- [Convert a Uint8Array to a Buffer](https://bun.sh/guides/binary/typedarray-to-buffer)
|
||||
- [Convert a Uint8Array to a DataView](https://bun.sh/guides/binary/typedarray-to-dataview)
|
||||
- [Convert a Uint8Array to a ReadableStream](https://bun.sh/guides/binary/typedarray-to-readablestream)
|
||||
- [Convert a Uint8Array to a string](https://bun.sh/guides/binary/typedarray-to-string)
|
||||
- [Convert a Buffer to an ArrayBuffer](https://bun.sh/guides/binary/buffer-to-arraybuffer)
|
||||
- [Convert a Uint8Array to an ArrayBuffer](https://bun.sh/guides/binary/typedarray-to-arraybuffer)
|
||||
- [Convert an ArrayBuffer to a Blob](https://bun.sh/guides/binary/arraybuffer-to-blob)
|
||||
- [Convert an ArrayBuffer to a Buffer](https://bun.sh/guides/binary/arraybuffer-to-buffer)
|
||||
- [Convert an ArrayBuffer to a string](https://bun.sh/guides/binary/arraybuffer-to-string)
|
||||
- [Convert a Uint8Array to a DataView](https://bun.sh/guides/binary/typedarray-to-dataview)
|
||||
- [Convert a Buffer to a ReadableStream](https://bun.sh/guides/binary/buffer-to-readablestream)
|
||||
- [Convert a Uint8Array to an ArrayBuffer](https://bun.sh/guides/binary/typedarray-to-arraybuffer)
|
||||
- [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)
|
||||
- [Convert a Uint8Array to a ReadableStream](https://bun.sh/guides/binary/typedarray-to-readablestream)
|
||||
|
||||
- Ecosystem
|
||||
|
||||
- [Use React and JSX](https://bun.sh/guides/ecosystem/react)
|
||||
- [Use EdgeDB with Bun](https://bun.sh/guides/ecosystem/edgedb)
|
||||
- [Use Prisma with Bun](https://bun.sh/guides/ecosystem/prisma)
|
||||
- [Add Sentry to a Bun app](https://bun.sh/guides/ecosystem/sentry)
|
||||
- [Create a Discord bot](https://bun.sh/guides/ecosystem/discordjs)
|
||||
- [Run Bun as a daemon with PM2](https://bun.sh/guides/ecosystem/pm2)
|
||||
- [Use Drizzle ORM with Bun](https://bun.sh/guides/ecosystem/drizzle)
|
||||
- [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)
|
||||
- [Build an app with Nuxt and Bun](https://bun.sh/guides/ecosystem/nuxt)
|
||||
- [Build an app with Qwik and Bun](https://bun.sh/guides/ecosystem/qwik)
|
||||
- [Build an app with Astro and Bun](https://bun.sh/guides/ecosystem/astro)
|
||||
- [Build an app with Remix and Bun](https://bun.sh/guides/ecosystem/remix)
|
||||
- [Build a frontend using Vite and Bun](https://bun.sh/guides/ecosystem/vite)
|
||||
- [Build an app with Next.js and Bun](https://bun.sh/guides/ecosystem/nextjs)
|
||||
- [Run Bun as a daemon with systemd](https://bun.sh/guides/ecosystem/systemd)
|
||||
- [Deploy a Bun application on Render](https://bun.sh/guides/ecosystem/render)
|
||||
- [Build an HTTP server using Hono and Bun](https://bun.sh/guides/ecosystem/hono)
|
||||
- [Build an app with SvelteKit and Bun](https://bun.sh/guides/ecosystem/sveltekit)
|
||||
- [Build an app with SolidStart and Bun](https://bun.sh/guides/ecosystem/solidstart)
|
||||
- [Build an app with SvelteKit and Bun](https://bun.sh/guides/ecosystem/sveltekit)
|
||||
- [Build an HTTP server using Elysia and Bun](https://bun.sh/guides/ecosystem/elysia)
|
||||
- [Build an HTTP server using Express and Bun](https://bun.sh/guides/ecosystem/express)
|
||||
- [Build an HTTP server using Hono and Bun](https://bun.sh/guides/ecosystem/hono)
|
||||
- [Build an HTTP server using StricJS and Bun](https://bun.sh/guides/ecosystem/stric)
|
||||
- [Containerize a Bun application with Docker](https://bun.sh/guides/ecosystem/docker)
|
||||
- [Build an HTTP server using Express and Bun](https://bun.sh/guides/ecosystem/express)
|
||||
- [Use Neon Postgres through Drizzle ORM](https://bun.sh/guides/ecosystem/neon-drizzle)
|
||||
- [Server-side render (SSR) a React component](https://bun.sh/guides/ecosystem/ssr-react)
|
||||
- [Create a Discord bot](https://bun.sh/guides/ecosystem/discordjs)
|
||||
- [Deploy a Bun application on Render](https://bun.sh/guides/ecosystem/render)
|
||||
- [Read and write data to MongoDB using Mongoose and Bun](https://bun.sh/guides/ecosystem/mongoose)
|
||||
- [Run Bun as a daemon with PM2](https://bun.sh/guides/ecosystem/pm2)
|
||||
- [Run Bun as a daemon with systemd](https://bun.sh/guides/ecosystem/systemd)
|
||||
- [Server-side render (SSR) a React component](https://bun.sh/guides/ecosystem/ssr-react)
|
||||
- [Use Drizzle ORM with Bun](https://bun.sh/guides/ecosystem/drizzle)
|
||||
- [Use EdgeDB with Bun](https://bun.sh/guides/ecosystem/edgedb)
|
||||
- [Use Neon's Serverless Postgres with Bun](https://bun.sh/guides/ecosystem/neon-serverless-postgres)
|
||||
|
||||
- HTMLRewriter
|
||||
|
||||
- [Extract links from a webpage using HTMLRewriter](https://bun.sh/guides/html-rewriter/extract-links)
|
||||
- [Extract social share images and Open Graph tags](https://bun.sh/guides/html-rewriter/extract-social-meta)
|
||||
- [Use Prisma with Bun](https://bun.sh/guides/ecosystem/prisma)
|
||||
- [Use React and JSX](https://bun.sh/guides/ecosystem/react)
|
||||
- [Add Sentry to a Bun app](https://bun.sh/guides/ecosystem/sentry)
|
||||
|
||||
- HTTP
|
||||
|
||||
- [Hot reload an HTTP server](https://bun.sh/guides/http/hot)
|
||||
- [Common HTTP server usage](https://bun.sh/guides/http/server)
|
||||
- [Write a simple HTTP server](https://bun.sh/guides/http/simple)
|
||||
- [Configure TLS on an HTTP server](https://bun.sh/guides/http/tls)
|
||||
- [Send an HTTP request using fetch](https://bun.sh/guides/http/fetch)
|
||||
- [fetch with unix domain sockets in Bun](https://bun.sh/guides/http/fetch-unix)
|
||||
- [Hot reload an HTTP server](https://bun.sh/guides/http/hot)
|
||||
- [Proxy HTTP requests using fetch()](https://bun.sh/guides/http/proxy)
|
||||
- [Send an HTTP request using fetch](https://bun.sh/guides/http/fetch)
|
||||
- [Start a cluster of HTTP servers](https://bun.sh/guides/http/cluster)
|
||||
- [Stream a file as an HTTP Response](https://bun.sh/guides/http/stream-file)
|
||||
- [fetch with unix domain sockets in Bun](https://bun.sh/guides/http/fetch-unix)
|
||||
- [Upload files via HTTP using FormData](https://bun.sh/guides/http/file-uploads)
|
||||
- [Streaming HTTP Server with Async Iterators](https://bun.sh/guides/http/stream-iterator)
|
||||
- [Streaming HTTP Server with Node.js Streams](https://bun.sh/guides/http/stream-node-streams-in-bun)
|
||||
- [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
|
||||
|
||||
- [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)
|
||||
- [Add a peer dependency](https://bun.sh/guides/install/add-peer)
|
||||
- [Add a trusted dependency](https://bun.sh/guides/install/trusted)
|
||||
- [Add a development dependency](https://bun.sh/guides/install/add-dev)
|
||||
- [Add a tarball dependency](https://bun.sh/guides/install/add-tarball)
|
||||
- [Add a trusted dependency](https://bun.sh/guides/install/trusted)
|
||||
- [Add an optional dependency](https://bun.sh/guides/install/add-optional)
|
||||
- [Generate a yarn-compatible lockfile](https://bun.sh/guides/install/yarnlock)
|
||||
- [Configure a private registry for an organization scope with bun install](https://bun.sh/guides/install/registry-scope)
|
||||
- [Configure git to diff Bun's lockb lockfile](https://bun.sh/guides/install/git-diff-bun-lockfile)
|
||||
- [Configuring a monorepo using workspaces](https://bun.sh/guides/install/workspaces)
|
||||
- [Generate a human-readable lockfile](https://bun.sh/guides/install/yarnlock)
|
||||
- [Install a package under a different name](https://bun.sh/guides/install/npm-alias)
|
||||
- [Install dependencies with Bun in GitHub Actions](https://bun.sh/guides/install/cicd)
|
||||
- [Using bun install with Artifactory](https://bun.sh/guides/install/jfrog-artifactory)
|
||||
- [Configure git to diff Bun's lockb lockfile](https://bun.sh/guides/install/git-diff-bun-lockfile)
|
||||
- [Override the default npm registry for bun install](https://bun.sh/guides/install/custom-registry)
|
||||
- [Using bun install with an Azure Artifacts npm registry](https://bun.sh/guides/install/azure-artifacts)
|
||||
- [Migrate from npm install to bun install](https://bun.sh/guides/install/from-npm-install-to-bun-install)
|
||||
- [Configure a private registry for an organization scope with bun install](https://bun.sh/guides/install/registry-scope)
|
||||
- [Using bun install with Artifactory](https://bun.sh/guides/install/jfrog-artifactory)
|
||||
|
||||
- Process
|
||||
|
||||
- [Read from stdin](https://bun.sh/guides/process/stdin)
|
||||
- [Get the process uptime in nanoseconds](https://bun.sh/guides/process/nanoseconds)
|
||||
- [Listen for CTRL+C](https://bun.sh/guides/process/ctrl-c)
|
||||
- [Spawn a child process](https://bun.sh/guides/process/spawn)
|
||||
- [Listen to OS signals](https://bun.sh/guides/process/os-signals)
|
||||
- [Parse command-line arguments](https://bun.sh/guides/process/argv)
|
||||
- [Read from stdin](https://bun.sh/guides/process/stdin)
|
||||
- [Read stderr from a child process](https://bun.sh/guides/process/spawn-stderr)
|
||||
- [Read stdout from a child process](https://bun.sh/guides/process/spawn-stdout)
|
||||
- [Get the process uptime in nanoseconds](https://bun.sh/guides/process/nanoseconds)
|
||||
- [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 a JSON file](https://bun.sh/guides/read-file/json)
|
||||
- [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)
|
||||
- [Read a file as a string](https://bun.sh/guides/read-file/string)
|
||||
- [Read a file to a Buffer](https://bun.sh/guides/read-file/buffer)
|
||||
- [Get the MIME type of a file](https://bun.sh/guides/read-file/mime)
|
||||
- [Watch a directory for changes](https://bun.sh/guides/read-file/watch)
|
||||
- [Read a file as a ReadableStream](https://bun.sh/guides/read-file/stream)
|
||||
- [Read a file to a Uint8Array](https://bun.sh/guides/read-file/uint8array)
|
||||
- [Read a file to an ArrayBuffer](https://bun.sh/guides/read-file/arraybuffer)
|
||||
- [Read a JSON file](https://bun.sh/guides/read-file/json)
|
||||
- [Watch a directory for changes](https://bun.sh/guides/read-file/watch)
|
||||
|
||||
- Runtime
|
||||
|
||||
- [Delete files](https://bun.sh/guides/runtime/delete-file)
|
||||
- [Run a Shell Command](https://bun.sh/guides/runtime/shell)
|
||||
- [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)
|
||||
- [Import a JSON file](https://bun.sh/guides/runtime/import-json)
|
||||
- [Import a TOML file](https://bun.sh/guides/runtime/import-toml)
|
||||
- [Import HTML file as text](https://bun.sh/guides/runtime/import-html)
|
||||
- [Install and run Bun in GitHub Actions](https://bun.sh/guides/runtime/cicd)
|
||||
- [Install TypeScript declarations for Bun](https://bun.sh/guides/runtime/typescript)
|
||||
- [Re-map import paths](https://bun.sh/guides/runtime/tsconfig-paths)
|
||||
- [Read environment variables](https://bun.sh/guides/runtime/read-env)
|
||||
- [Run a Shell Command](https://bun.sh/guides/runtime/shell)
|
||||
- [Set a time zone in Bun](https://bun.sh/guides/runtime/timezone)
|
||||
- [Set environment variables](https://bun.sh/guides/runtime/set-env)
|
||||
- [Re-map import paths](https://bun.sh/guides/runtime/tsconfig-paths)
|
||||
- [Delete directories](https://bun.sh/guides/runtime/delete-directory)
|
||||
- [Read environment variables](https://bun.sh/guides/runtime/read-env)
|
||||
- [Import a HTML file as text](https://bun.sh/guides/runtime/import-html)
|
||||
- [Install and run Bun in GitHub Actions](https://bun.sh/guides/runtime/cicd)
|
||||
- [Debugging Bun with the web debugger](https://bun.sh/guides/runtime/web-debugger)
|
||||
- [Install TypeScript declarations for Bun](https://bun.sh/guides/runtime/typescript)
|
||||
- [Debugging Bun with the VS Code extension](https://bun.sh/guides/runtime/vscode-debugger)
|
||||
- [Inspect memory usage using V8 heap snapshots](https://bun.sh/guides/runtime/heap-snapshot)
|
||||
- [Define and replace static globals & constants](https://bun.sh/guides/runtime/define-constant)
|
||||
- [Codesign a single-file JavaScript executable on macOS](https://bun.sh/guides/runtime/codesign-macos-executable)
|
||||
|
||||
- Streams
|
||||
|
||||
- [Convert a ReadableStream to JSON](https://bun.sh/guides/streams/to-json)
|
||||
- [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)
|
||||
- [Convert a Node.js Readable to JSON](https://bun.sh/guides/streams/node-readable-to-json)
|
||||
- [Convert a ReadableStream to a Blob](https://bun.sh/guides/streams/to-blob)
|
||||
- [Convert a ReadableStream to a Buffer](https://bun.sh/guides/streams/to-buffer)
|
||||
- [Convert a ReadableStream to a string](https://bun.sh/guides/streams/to-string)
|
||||
- [Convert a ReadableStream to a Uint8Array](https://bun.sh/guides/streams/to-typedarray)
|
||||
- [Convert a ReadableStream to an array of chunks](https://bun.sh/guides/streams/to-array)
|
||||
- [Convert a Node.js Readable to JSON](https://bun.sh/guides/streams/node-readable-to-json)
|
||||
- [Convert a ReadableStream to an ArrayBuffer](https://bun.sh/guides/streams/to-arraybuffer)
|
||||
- [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 Uint8Array](https://bun.sh/guides/streams/node-readable-to-uint8array)
|
||||
- [Convert a Node.js Readable to an ArrayBuffer](https://bun.sh/guides/streams/node-readable-to-arraybuffer)
|
||||
- [Convert a ReadableStream to JSON](https://bun.sh/guides/streams/to-json)
|
||||
|
||||
- Test
|
||||
|
||||
- [Spy on methods in `bun test`](https://bun.sh/guides/test/spy-on)
|
||||
- [Bail early with the Bun test runner](https://bun.sh/guides/test/bail)
|
||||
- [Mock functions in `bun test`](https://bun.sh/guides/test/mock-functions)
|
||||
- [Run tests in watch mode with Bun](https://bun.sh/guides/test/watch-mode)
|
||||
- [Use snapshot testing in `bun test`](https://bun.sh/guides/test/snapshot)
|
||||
- [Skip tests with the Bun test runner](https://bun.sh/guides/test/skip-tests)
|
||||
- [Using Testing Library with Bun](https://bun.sh/guides/test/testing-library)
|
||||
- [Update snapshots in `bun test`](https://bun.sh/guides/test/update-snapshots)
|
||||
- [Run your tests with the Bun test runner](https://bun.sh/guides/test/run-tests)
|
||||
- [Set the system time in Bun's test runner](https://bun.sh/guides/test/mock-clock)
|
||||
- [Set a per-test timeout with the Bun test runner](https://bun.sh/guides/test/timeout)
|
||||
- [Migrate from Jest to Bun's test runner](https://bun.sh/guides/test/migrate-from-jest)
|
||||
- [Write browser DOM tests with Bun and happy-dom](https://bun.sh/guides/test/happy-dom)
|
||||
- [Mark a test as a "todo" with the Bun test runner](https://bun.sh/guides/test/todo-tests)
|
||||
- [Re-run tests multiple times with the Bun test runner](https://bun.sh/guides/test/rerun-each)
|
||||
- [Generate code coverage reports with the Bun test runner](https://bun.sh/guides/test/coverage)
|
||||
- [import, require, and test Svelte components with bun test](https://bun.sh/guides/test/svelte-test)
|
||||
- [Mark a test as a "todo" with the Bun test runner](https://bun.sh/guides/test/todo-tests)
|
||||
- [Migrate from Jest to Bun's test runner](https://bun.sh/guides/test/migrate-from-jest)
|
||||
- [Mock functions in `bun test`](https://bun.sh/guides/test/mock-functions)
|
||||
- [Re-run tests multiple times with the Bun test runner](https://bun.sh/guides/test/rerun-each)
|
||||
- [Run tests in watch mode with Bun](https://bun.sh/guides/test/watch-mode)
|
||||
- [Run your tests with the Bun test runner](https://bun.sh/guides/test/run-tests)
|
||||
- [Set a code coverage threshold with the Bun test runner](https://bun.sh/guides/test/coverage-threshold)
|
||||
- [Set a per-test timeout with the Bun test runner](https://bun.sh/guides/test/timeout)
|
||||
- [Set the system time in Bun's test runner](https://bun.sh/guides/test/mock-clock)
|
||||
- [Skip tests with the Bun test runner](https://bun.sh/guides/test/skip-tests)
|
||||
- [Spy on methods in `bun test`](https://bun.sh/guides/test/spy-on)
|
||||
- [Update snapshots in `bun test`](https://bun.sh/guides/test/update-snapshots)
|
||||
- [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
|
||||
|
||||
- [Generate a UUID](https://bun.sh/guides/util/javascript-uuid)
|
||||
- [Hash a password](https://bun.sh/guides/util/hash-a-password)
|
||||
- [Escape an HTML string](https://bun.sh/guides/util/escape-html)
|
||||
- [Get the current Bun version](https://bun.sh/guides/util/version)
|
||||
- [Encode and decode base64 strings](https://bun.sh/guides/util/base64)
|
||||
- [Compress and decompress data with gzip](https://bun.sh/guides/util/gzip)
|
||||
- [Sleep for a fixed number of milliseconds](https://bun.sh/guides/util/sleep)
|
||||
- [Detect when code is executed with Bun](https://bun.sh/guides/util/detect-bun)
|
||||
- [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)
|
||||
- [Get the absolute path to the current entrypoint](https://bun.sh/guides/util/main)
|
||||
- [Get the directory of the current file](https://bun.sh/guides/util/import-meta-dir)
|
||||
- [Check if the current file is the entrypoint](https://bun.sh/guides/util/entrypoint)
|
||||
- [Get the file name of the current file](https://bun.sh/guides/util/import-meta-file)
|
||||
- [Compress and decompress data with gzip](https://bun.sh/guides/util/gzip)
|
||||
- [Convert a file URL to an absolute path](https://bun.sh/guides/util/file-url-to-path)
|
||||
- [Convert an absolute path to a file URL](https://bun.sh/guides/util/path-to-file-url)
|
||||
- [Detect when code is executed with Bun](https://bun.sh/guides/util/detect-bun)
|
||||
- [Encode and decode base64 strings](https://bun.sh/guides/util/base64)
|
||||
- [Escape an HTML string](https://bun.sh/guides/util/escape-html)
|
||||
- [Get the absolute path of the current file](https://bun.sh/guides/util/import-meta-path)
|
||||
- [Get the absolute path to the current entrypoint](https://bun.sh/guides/util/main)
|
||||
- [Get the current Bun version](https://bun.sh/guides/util/version)
|
||||
- [Get the directory of the current file](https://bun.sh/guides/util/import-meta-dir)
|
||||
- [Get the file name of the current file](https://bun.sh/guides/util/import-meta-file)
|
||||
- [Get the path to an executable bin file](https://bun.sh/guides/util/which-path-to-executable-bin)
|
||||
- [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
|
||||
|
||||
@@ -414,17 +379,16 @@ bun upgrade --canary
|
||||
- [Set per-socket contextual data on a WebSocket](https://bun.sh/guides/websocket/context)
|
||||
|
||||
- Write file
|
||||
|
||||
- [Delete a file](https://bun.sh/guides/write-file/unlink)
|
||||
- [Write to stdout](https://bun.sh/guides/write-file/stdout)
|
||||
- [Write a file to stdout](https://bun.sh/guides/write-file/cat)
|
||||
- [Write a Blob to a file](https://bun.sh/guides/write-file/blob)
|
||||
- [Write a string to a file](https://bun.sh/guides/write-file/basic)
|
||||
- [Append content to a file](https://bun.sh/guides/write-file/append)
|
||||
- [Write a file incrementally](https://bun.sh/guides/write-file/filesink)
|
||||
- [Write a Response to a file](https://bun.sh/guides/write-file/response)
|
||||
- [Copy a file to another location](https://bun.sh/guides/write-file/file-cp)
|
||||
- [Delete a file](https://bun.sh/guides/write-file/unlink)
|
||||
- [Write a Blob to a file](https://bun.sh/guides/write-file/blob)
|
||||
- [Write a file incrementally](https://bun.sh/guides/write-file/filesink)
|
||||
- [Write a file to stdout](https://bun.sh/guides/write-file/cat)
|
||||
- [Write a ReadableStream to a file](https://bun.sh/guides/write-file/stream)
|
||||
- [Write a Response to a file](https://bun.sh/guides/write-file/response)
|
||||
- [Write a string to a file](https://bun.sh/guides/write-file/basic)
|
||||
- [Write to stdout](https://bun.sh/guides/write-file/stdout)
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Enable latest features
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
"module": "Preserve",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Enable latest features
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
"module": "Preserve",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
|
||||
@@ -8,9 +8,9 @@ for (let builtin of builtinModules) {
|
||||
path,
|
||||
`
|
||||
const builtin = ${JSON.stringify(builtin)};
|
||||
const now = performance.now();
|
||||
const now = require("perf_hooks").performance.now();
|
||||
require(builtin);
|
||||
const end = performance.now();
|
||||
const end = require("perf_hooks").performance.now();
|
||||
process.stdout.write(JSON.stringify({builtin, time: end - now}) + "\\n");
|
||||
`,
|
||||
);
|
||||
|
||||
@@ -8,5 +8,4 @@ packages/bun-usockets/src/quic.c
|
||||
packages/bun-usockets/src/socket.c
|
||||
packages/bun-usockets/src/udp.c
|
||||
src/bun.js/bindings/uv-posix-polyfills.c
|
||||
src/bun.js/bindings/uv-posix-stubs.c
|
||||
src/asan-config.c
|
||||
src/bun.js/bindings/uv-posix-stubs.c
|
||||
@@ -4,7 +4,7 @@ register_repository(
|
||||
REPOSITORY
|
||||
ebiggers/libdeflate
|
||||
COMMIT
|
||||
96836d7d9d10e3e0d53e6edb54eb908514e336c4
|
||||
78051988f96dc8d8916310d8b24021f01bd9e102
|
||||
)
|
||||
|
||||
register_cmake_command(
|
||||
|
||||
@@ -38,11 +38,7 @@ if(WIN32)
|
||||
set(MIMALLOC_LIBRARY mimalloc-static)
|
||||
endif()
|
||||
elseif(DEBUG)
|
||||
if (ENABLE_ASAN)
|
||||
set(MIMALLOC_LIBRARY mimalloc-asan-debug)
|
||||
else()
|
||||
set(MIMALLOC_LIBRARY mimalloc-debug)
|
||||
endif()
|
||||
set(MIMALLOC_LIBRARY mimalloc-debug)
|
||||
else()
|
||||
set(MIMALLOC_LIBRARY mimalloc)
|
||||
endif()
|
||||
|
||||
@@ -79,10 +79,7 @@ else()
|
||||
set(WEBKIT_SUFFIX "${WEBKIT_SUFFIX}")
|
||||
endif()
|
||||
|
||||
if(ENABLE_ASAN)
|
||||
# We cannot mix and match ASan Bun + non-ASan WebKit, or vice versa, because some WebKit classes
|
||||
# change their layout according to whether ASan is used, for example:
|
||||
# https://github.com/oven-sh/WebKit/blob/eda8b0fb4fb1aa23db9c2b00933df8b58bcdd289/Source/WTF/wtf/Vector.h#L682
|
||||
if(ENABLE_ASAN AND ((APPLE AND DEBUG AND ARCH STREQUAL "aarch64") OR (LINUX AND RELEASE)))
|
||||
set(WEBKIT_SUFFIX "${WEBKIT_SUFFIX}-asan")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -40,32 +40,3 @@ At the end, it runs `bun install` to install `@types/bun`.
|
||||
{% /details %}
|
||||
|
||||
{% bunCLIUsage command="init" /%}
|
||||
|
||||
## React
|
||||
|
||||
The `--react` flag will scaffold a React project:
|
||||
|
||||
```bash
|
||||
$ bun init --react
|
||||
```
|
||||
|
||||
The `--react` flag accepts the following values:
|
||||
|
||||
- `tailwind` - Scaffold a React project with Tailwind CSS
|
||||
- `shadcn` - Scaffold a React project with Shadcn/UI and Tailwind CSS
|
||||
|
||||
### React + TailwindCSS
|
||||
|
||||
This will create a React project with Tailwind CSS configured with Bun's bundler and dev server.
|
||||
|
||||
```bash
|
||||
$ bun init --react=tailwind
|
||||
```
|
||||
|
||||
### React + @shadcn/ui
|
||||
|
||||
This will create a React project with shadcn/ui and Tailwind CSS configured with Bun's bundler and dev server.
|
||||
|
||||
```bash
|
||||
$ bun init --react=shadcn
|
||||
```
|
||||
|
||||
@@ -18,7 +18,7 @@ Below is the full set of recommended `compilerOptions` for a Bun project. With t
|
||||
// Environment setup & latest features
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
"module": "Preserve",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
@@ -34,7 +34,6 @@ Below is the full set of recommended `compilerOptions` for a Bun project. With t
|
||||
"skipLibCheck": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
|
||||
@@ -58,7 +58,7 @@ Then add the following to your `compilerOptions` in `tsconfig.json`:
|
||||
"compilerOptions": {
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
"module": "Preserve",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
|
||||
@@ -20,7 +20,7 @@ Bun supports things like top-level await, JSX, and extensioned `.ts` imports, wh
|
||||
// Environment setup & latest features
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
"module": "Preserve",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
@@ -36,7 +36,6 @@ Bun supports things like top-level await, JSX, and extensioned `.ts` imports, wh
|
||||
"skipLibCheck": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
|
||||
20
package.json
20
package.json
@@ -3,12 +3,20 @@
|
||||
"name": "bun",
|
||||
"version": "1.2.14",
|
||||
"workspaces": [
|
||||
"./packages/bun-types",
|
||||
"./packages/@types/bun"
|
||||
"./packages/bun-types"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@mdn/browser-compat-data": "~5.5.28",
|
||||
"@types/bun": "*",
|
||||
"@types/react": "^18.3.3",
|
||||
"@typescript-eslint/eslint-plugin": "^7.11.0",
|
||||
"@typescript-eslint/parser": "^7.11.0",
|
||||
"@vscode/debugadapter": "^1.65.0",
|
||||
"autoprefixer": "^10.4.19",
|
||||
"caniuse-lite": "^1.0.30001620",
|
||||
"esbuild": "^0.21.4",
|
||||
"eslint": "^9.4.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"mitata": "^0.1.11",
|
||||
"peechy": "0.4.34",
|
||||
"prettier": "^3.5.3",
|
||||
@@ -19,16 +27,14 @@
|
||||
"typescript": "^5.7.2"
|
||||
},
|
||||
"resolutions": {
|
||||
"bun-types": "workspace:packages/bun-types",
|
||||
"@types/bun": "workspace:packages/@types/bun"
|
||||
"bun-types": "workspace:packages/bun-types"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "bun run build:debug",
|
||||
"watch": "zig build check --watch -fincremental --prominent-compile-errors --global-cache-dir build/debug/zig-check-cache --zig-lib-dir vendor/zig/lib",
|
||||
"watch-windows": "zig build check-windows --watch -fincremental --prominent-compile-errors --global-cache-dir build/debug/zig-check-cache --zig-lib-dir vendor/zig/lib",
|
||||
"agent": "(bun run --silent build:debug &> /tmp/bun.debug.build.log || (cat /tmp/bun.debug.build.log && rm -rf /tmp/bun.debug.build.log && exit 1)) && rm -f /tmp/bun.debug.build.log && ./build/debug/bun-debug",
|
||||
"bd": "(bun run --silent build:debug &> /tmp/bun.debug.build.log || (cat /tmp/bun.debug.build.log && rm -rf /tmp/bun.debug.build.log && exit 1)) && rm -f /tmp/bun.debug.build.log && ./build/debug/bun-debug",
|
||||
"build:debug": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Debug -B build/debug",
|
||||
"build:debug:asan": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Debug -DENABLE_ASAN=ON -B build/debug-asan",
|
||||
"build:valgrind": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Debug -DENABLE_BASELINE=ON -ENABLE_VALGRIND=ON -B build/debug-valgrind",
|
||||
"build:release": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -B build/release",
|
||||
"build:ci": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DCI=true -B build/release-ci --verbose --fresh",
|
||||
@@ -72,7 +78,7 @@
|
||||
"clang-tidy:diff": "bun run analysis --target clang-tidy-diff",
|
||||
"zig-format": "bun run analysis:no-llvm --target zig-format",
|
||||
"zig-format:check": "bun run analysis:no-llvm --target zig-format-check",
|
||||
"prettier": "bunx prettier@latest --plugin=prettier-plugin-organize-imports --config .prettierrc --write scripts packages src docs 'test/**/*.{test,spec}.{ts,tsx,js,jsx,mts,mjs,cjs,cts}' '!test/**/*fixture*.*'",
|
||||
"prettier": "bunx prettier@latest --plugin=prettier-plugin-organize-imports --config .prettierrc --write src docs 'test/**/*.{test,spec}.{ts,tsx,js,jsx,mts,mjs,cjs,cts}' '!test/**/*fixture*.*'",
|
||||
"node:test": "node ./scripts/runner.node.mjs --quiet --exec-path=$npm_execpath --node-tests ",
|
||||
"clean:zig": "rm -rf build/debug/cache/zig build/debug/CMakeCache.txt 'build/debug/*.o' .zig-cache zig-out || true"
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
@@ -1,3 +0,0 @@
|
||||
# @types/bun alias
|
||||
|
||||
This is an internal alias of the DefinitelyTyped `@types/bun` package. This alias exists to skip downloading the @types/bun package in Bun's own CI.
|
||||
1
packages/@types/bun/index.d.ts
vendored
1
packages/@types/bun/index.d.ts
vendored
@@ -1 +0,0 @@
|
||||
/// <reference types="bun-types" />
|
||||
@@ -1,58 +0,0 @@
|
||||
{
|
||||
"name": "@types/bun",
|
||||
"version": "1.2.2",
|
||||
"description": "TypeScript definitions for bun",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/bun",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Jarred Sumner",
|
||||
"githubUsername": "Jarred-Sumner",
|
||||
"url": "https://github.com/Jarred-Sumner"
|
||||
},
|
||||
{
|
||||
"name": "Ashcon Partovi",
|
||||
"githubUsername": "electroid",
|
||||
"url": "https://github.com/electroid"
|
||||
},
|
||||
{
|
||||
"name": "Chloe Caruso",
|
||||
"githubUsername": "paperclover",
|
||||
"url": "https://github.com/paperclover"
|
||||
},
|
||||
{
|
||||
"name": "Robobun",
|
||||
"githubUsername": "robobun",
|
||||
"url": "https://github.com/robobun"
|
||||
},
|
||||
{
|
||||
"name": "Dylan Conway",
|
||||
"githubUsername": "dylan-conway",
|
||||
"url": "https://github.com/dylan-conway"
|
||||
},
|
||||
{
|
||||
"name": "Meghan Denny",
|
||||
"githubUsername": "nektro",
|
||||
"url": "https://github.com/nektro"
|
||||
},
|
||||
{
|
||||
"name": "Michael H",
|
||||
"githubUsername": "RiskyMH",
|
||||
"url": "https://github.com/RiskyMH"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/bun"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"bun-types": "workspace:"
|
||||
},
|
||||
"peerDependencies": {},
|
||||
"typesPublisherContentHash": "caeb56f2d4753af08a8e57856ec5e9d86ad3542da2171a68e19698ec4539995a",
|
||||
"typeScriptVersion": "5.0"
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import test from "ava";
|
||||
import test from 'ava'
|
||||
|
||||
import { sum } from "../index.js";
|
||||
import { sum } from '../index.js'
|
||||
|
||||
test("sum from native", t => {
|
||||
t.is(sum(1, 2), 3);
|
||||
});
|
||||
test('sum from native', (t) => {
|
||||
t.is(sum(1, 2), 3)
|
||||
})
|
||||
|
||||
@@ -15,4 +15,4 @@
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,4 +15,4 @@
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,4 +18,4 @@
|
||||
"libc": [
|
||||
"glibc"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -18,4 +18,4 @@
|
||||
"libc": [
|
||||
"musl"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -18,4 +18,4 @@
|
||||
"libc": [
|
||||
"glibc"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -18,4 +18,4 @@
|
||||
"libc": [
|
||||
"musl"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -15,4 +15,4 @@
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,4 +34,4 @@
|
||||
"universal": "napi universal",
|
||||
"version": "napi version"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
:host {
|
||||
--bun-error-color: #e33737;
|
||||
--bun-error-monospace:
|
||||
ui-monospace, Menlo, Monaco, "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace",
|
||||
--bun-error-monospace: ui-monospace, Menlo, Monaco, "Cascadia Mono",
|
||||
"Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace",
|
||||
"Source Code Pro", "Fira Mono", "Droid Sans Mono", "Courier New", monospace;
|
||||
--bun-error-width: 512px;
|
||||
}
|
||||
@@ -15,9 +15,7 @@
|
||||
text-decoration: underline;
|
||||
}
|
||||
#BunErrorOverlay-container {
|
||||
box-shadow:
|
||||
0px 16px 24px rgba(0, 0, 0, 0.06),
|
||||
0px 2px 6px rgba(0, 0, 0, 0.1),
|
||||
box-shadow: 0px 16px 24px rgba(0, 0, 0, 0.06), 0px 2px 6px rgba(0, 0, 0, 0.1),
|
||||
0px 0px 1px rgba(0, 0, 0, 0.04);
|
||||
backdrop-filter: blur(42px);
|
||||
backface-visibility: visible;
|
||||
@@ -31,9 +29,8 @@
|
||||
right: 48px;
|
||||
z-index: 999999;
|
||||
|
||||
font-family:
|
||||
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji",
|
||||
"Segoe UI Emoji", "Segoe UI Symbol";
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
|
||||
Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||
}
|
||||
|
||||
.BunErrorRoot--FullPage #BunErrorOverlay-container {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { createContext, useContext } from "react";
|
||||
import React from "react";
|
||||
import { useContext, createContext } from "react";
|
||||
import { render, unmountComponentAtNode } from "react-dom";
|
||||
import type {
|
||||
FallbackMessageContainer,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { normalizedFilename, StackFrameIdentifier, thisCwd, StackFrameScope } from "./index";
|
||||
import type { JSException, JSException as JSExceptionType, Message, Problems } from "../../src/api/schema";
|
||||
import { normalizedFilename, StackFrameIdentifier, StackFrameScope, thisCwd } from "./index";
|
||||
|
||||
export function problemsToMarkdown(problems: Problems) {
|
||||
var markdown = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Based on https://github.com/stacktracejs/error-stack-parser/blob/master/error-stack-parser.js
|
||||
|
||||
import type { StackFramePosition, StackFrameScope, StackFrame as StackFrameType } from "../../src/api/schema";
|
||||
import type { StackFrame as StackFrameType, StackFramePosition, StackFrameScope } from "../../src/api/schema";
|
||||
|
||||
export class StackFrame implements StackFrameType {
|
||||
function_name: string;
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
const UNKNOWN_FUNCTION = "<unknown>";
|
||||
import type { StackFrame } from "../../src/api/schema";
|
||||
import type {
|
||||
FallbackMessageContainer,
|
||||
JSException,
|
||||
Location,
|
||||
Message,
|
||||
SourceLine,
|
||||
StackFrame,
|
||||
WebsocketMessageBuildFailure,
|
||||
} from "../../src/api/schema";
|
||||
|
||||
/**
|
||||
* This parses the different stack traces and puts them into one format
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"jsx": "react",
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"DOM"
|
||||
],
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true
|
||||
"allowSyntheticDefaultImports": true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
export type * from "./src/inspector/index";
|
||||
export * from "./src/inspector/node-socket";
|
||||
export * from "./src/inspector/websocket";
|
||||
export * from "./src/inspector/node-socket";
|
||||
export type * from "./src/protocol/index";
|
||||
export * from "./src/util/preview";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { readFileSync, realpathSync, writeFileSync } from "node:fs";
|
||||
import { readFileSync, writeFileSync, realpathSync } from "node:fs";
|
||||
import type { Domain, Property, Protocol } from "../src/protocol/schema";
|
||||
import path from "node:path";
|
||||
import type { Property, Protocol } from "../src/protocol/schema";
|
||||
|
||||
function formatProtocol(protocol: Protocol, extraTs?: string): string {
|
||||
const { name, domains } = protocol;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
||||
import { describe, test, expect } from "bun:test";
|
||||
import { tmpdir } from "node:os";
|
||||
import { mkdtempSync, mkdirSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import type { FindTestOptions, ParseTestResult, RunTestResult } from "./runner";
|
||||
import { bunSpawn, findTests, nodeSpawn, runTest, runTests } from "./runner";
|
||||
import { bunSpawn, nodeSpawn, findTests, runTest, runTests } from "./runner";
|
||||
|
||||
describe("runTests()", () => {
|
||||
const cwd = createFs({
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
//
|
||||
// In the future, a version of this will be built-in to Bun.
|
||||
|
||||
import { spawn } from "node:child_process";
|
||||
import { fsyncSync, readdirSync, symlinkSync, unlinkSync, writeSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { readdirSync, writeSync, fsyncSync, symlinkSync, unlinkSync } from "node:fs";
|
||||
import { spawn } from "node:child_process";
|
||||
|
||||
export type TestInfo = {
|
||||
name: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { BunExpect } from "bun-test";
|
||||
import type { Assert } from "./qunit.d";
|
||||
import type { BunExpect } from "bun-test";
|
||||
|
||||
export { $Assert as Assert };
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { deepEquals, inspect } from "bun";
|
||||
import type { TestContext } from "bun-test";
|
||||
import { Assert } from "./assert";
|
||||
import type { DataInit, EachFn, Fn, Hooks, HooksFn, ModuleFn, TestEachFn, TestFn, TestOrEachFn } from "./qunit.d";
|
||||
import type { TestContext } from "bun-test";
|
||||
import { inspect, deepEquals } from "bun";
|
||||
import { Assert } from "./assert";
|
||||
|
||||
type Status = "todo" | "skip" | "only" | undefined;
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { a, br, code, count, duration, h, table, ul } from "html";
|
||||
import { appendFileSync } from "node:fs";
|
||||
import { basename, resolve } from "node:path";
|
||||
import { TestError, TestStatus, printTest, runTests } from "runner";
|
||||
import { resolve, basename } from "node:path";
|
||||
import { a, h, count, duration, table, br, ul, code } from "html";
|
||||
import { TestError, TestStatus, printTest } from "runner";
|
||||
import { runTests } from "runner";
|
||||
|
||||
const cwd = resolve(import.meta.dir, "..", "..", "..", "test");
|
||||
const filters = process.argv.slice(2); // TODO
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { a, br, code, count, details, duration, h, percent, table, ul } from "html";
|
||||
import { readFileSync, existsSync, appendFileSync } from "node:fs";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { appendFileSync, existsSync, readFileSync } from "node:fs";
|
||||
import { Test, TestError, TestFile, TestStatus, TestSummary, printTest, runTests } from "runner";
|
||||
import { TestSummary, TestError, TestStatus, TestFile, Test, printTest } from "runner";
|
||||
import { runTests } from "runner";
|
||||
import { a, br, code, count, details, duration, h, percent, table, ul } from "html";
|
||||
|
||||
const [filter] = process.argv.slice(2);
|
||||
const packagesText = readFileSync(resolve("resources/packages.json"), "utf8");
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as action from "@actions/core";
|
||||
import { spawn, spawnSync } from "child_process";
|
||||
import { closeSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync } from "fs";
|
||||
import { rmSync, writeFileSync, readFileSync, mkdirSync, openSync, closeSync } from "fs";
|
||||
import { readdirSync } from "node:fs";
|
||||
import { basename, resolve } from "node:path";
|
||||
import { resolve, basename } from "node:path";
|
||||
import { cpus, hostname, tmpdir, totalmem, userInfo } from "os";
|
||||
import PQueue from "p-queue";
|
||||
import { join, normalize, posix, relative } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import PQueue from "p-queue";
|
||||
|
||||
const run_start = new Date();
|
||||
const TIMEOUT_DURATION = 1000 * 60 * 5;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { afterAll, afterEach, beforeAll, beforeEach, describe, Expect, test } from "bun:test";
|
||||
import type { Expect, test, describe, beforeAll, beforeEach, afterAll, afterEach } from "bun:test";
|
||||
|
||||
export type BunExpect = (value: unknown) => Expect;
|
||||
export type BunDescribe = typeof describe;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AwsClient } from "aws4fetch";
|
||||
import type { Server, ServerWebSocket } from "bun";
|
||||
import { AwsClient } from "aws4fetch";
|
||||
|
||||
type Lambda = {
|
||||
fetch: (request: Request, server: Server) => Promise<Response | undefined>;
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
process.stdout.getWindowSize = () => [80, 80];
|
||||
process.stderr.getWindowSize = () => [80, 80];
|
||||
|
||||
import { Command, Flags } from "@oclif/core";
|
||||
import JSZip from "jszip";
|
||||
import { createReadStream, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { Command, Flags } from "@oclif/core";
|
||||
import JSZip from "jszip";
|
||||
|
||||
export class BuildCommand extends Command {
|
||||
static summary = "Build a custom Lambda layer for Bun.";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { describe, it, expect } from "bun:test";
|
||||
import { SveltePlugin } from "./index";
|
||||
|
||||
describe("SveltePlugin", () => {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { BuildConfig, BunPlugin, OnLoadResult } from "bun";
|
||||
import type { BunPlugin, BuildConfig, OnLoadResult } from "bun";
|
||||
import { basename } from "node:path";
|
||||
import { compile, compileModule } from "svelte/compiler";
|
||||
import {
|
||||
getBaseCompileOptions,
|
||||
getBaseModuleCompileOptions,
|
||||
hash,
|
||||
validateOptions,
|
||||
type SvelteOptions,
|
||||
hash,
|
||||
getBaseModuleCompileOptions,
|
||||
} from "./options";
|
||||
|
||||
const kEmptyObject = Object.create(null);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, beforeAll, it, expect } from "bun:test";
|
||||
import type { BuildConfig } from "bun";
|
||||
import { beforeAll, describe, expect, it } from "bun:test";
|
||||
import type { CompileOptions } from "svelte/compiler";
|
||||
|
||||
import { getBaseCompileOptions, validateOptions, type SvelteOptions } from "./options";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type BuildConfig } from "bun";
|
||||
import { strict as assert } from "node:assert";
|
||||
import { type BuildConfig } from "bun";
|
||||
import type { CompileOptions, ModuleCompileOptions } from "svelte/compiler";
|
||||
|
||||
type OverrideCompileOptions = Pick<CompileOptions, "customElement" | "runes" | "modernAst" | "namespace">;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { BuildOutput } from "bun";
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it } from "bun:test";
|
||||
import { describe, beforeAll, it, expect, afterEach, afterAll } from "bun:test";
|
||||
import path from "node:path";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { render } from "svelte/server";
|
||||
import { SveltePlugin } from "../src";
|
||||
import type { BuildOutput } from "bun";
|
||||
|
||||
const fixturePath = (...segs: string[]) => path.join(import.meta.dirname, "fixtures", ...segs);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { test, expect } from "bun:test";
|
||||
import YamlPlugin from ".";
|
||||
import data from "./data.yml";
|
||||
|
||||
test("yaml loader - no plugin", async () => {
|
||||
expect(async () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { importBun, optimizeBun } from "../src/npm/install";
|
||||
import { execFileSync } from "child_process";
|
||||
import { importBun } from "../src/npm/install";
|
||||
|
||||
importBun()
|
||||
.then(bun => {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { confirm, exit, log, stdin, warn } from "../src/console";
|
||||
import { fetch } from "../src/fetch";
|
||||
import { basename, blob, hash, join, rm, tmp, write } from "../src/fs";
|
||||
import { getRelease, uploadAsset } from "../src/github";
|
||||
import { fetch } from "../src/fetch";
|
||||
import { spawn } from "../src/spawn";
|
||||
import { confirm, exit, log, stdin, warn } from "../src/console";
|
||||
import { hash, join, rm, tmp, write, basename, blob } from "../src/fs";
|
||||
|
||||
const [tag, ...paths] = process.argv.slice(2);
|
||||
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import { expect } from "bun:test";
|
||||
import type { BuildOptions } from "esbuild";
|
||||
import { buildSync, formatMessagesSync } from "esbuild";
|
||||
import { mkdirSync, rmSync } from "fs";
|
||||
import { join, copy, exists, chmod, write, writeJson } from "../src/fs";
|
||||
import { mkdtemp } from "fs/promises";
|
||||
import type { JSZipObject } from "jszip";
|
||||
import { loadAsync } from "jszip";
|
||||
import { rmSync, mkdirSync } from "fs";
|
||||
import { tmpdir } from "os";
|
||||
import { dirname } from "path";
|
||||
import { debug, error, log } from "../src/console";
|
||||
import { fetch } from "../src/fetch";
|
||||
import { chmod, copy, exists, join, write, writeJson } from "../src/fs";
|
||||
import { getRelease, getSemver } from "../src/github";
|
||||
import { spawn } from "../src/spawn";
|
||||
import type { Platform } from "../src/platform";
|
||||
import { platforms } from "../src/platform";
|
||||
import { spawn } from "../src/spawn";
|
||||
import { getSemver } from "../src/github";
|
||||
import { getRelease } from "../src/github";
|
||||
import type { BuildOptions } from "esbuild";
|
||||
import { buildSync, formatMessagesSync } from "esbuild";
|
||||
import type { JSZipObject } from "jszip";
|
||||
import { loadAsync } from "jszip";
|
||||
import { debug, log, error } from "../src/console";
|
||||
import { expect } from "bun:test";
|
||||
|
||||
const module = "bun";
|
||||
const owner = "@oven";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AwsClient } from "aws4fetch";
|
||||
import { join, tmp } from "../src/fs";
|
||||
import { getBuild, getRelease, getSemver, getSha } from "../src/github";
|
||||
import { join, tmp } from "../src/fs";
|
||||
|
||||
// The source of truth for the git sha is what's in the local build, extracted from features.json
|
||||
// NOT the git tag revision.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createInterface } from "readline";
|
||||
import { isatty } from "tty";
|
||||
import { createInterface } from "readline";
|
||||
|
||||
export const isAction = !!process.env["GITHUB_ACTION"];
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import crypto from "crypto";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
import crypto from "crypto";
|
||||
import { debug } from "./console";
|
||||
|
||||
export function join(...paths: (string | string[])[]): string {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Endpoints, RequestParameters, Route } from "@octokit/types";
|
||||
import { Octokit } from "octokit";
|
||||
import { debug, error, log, warn } from "./console";
|
||||
import { fetch } from "./fetch";
|
||||
import { debug, log, warn, error } from "./console";
|
||||
|
||||
const [owner, repo] = process.env["GITHUB_REPOSITORY"]?.split("/") ?? ["oven-sh", "bun"];
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { unzipSync } from "zlib";
|
||||
import { debug, error } from "../console";
|
||||
import { fetch } from "../fetch";
|
||||
import { chmod, join, rename, rm, tmp, write } from "../fs";
|
||||
import type { Platform } from "../platform";
|
||||
import { abi, arch, os, supportedPlatforms } from "../platform";
|
||||
import { spawn } from "../spawn";
|
||||
import { chmod, join, rename, rm, tmp, write } from "../fs";
|
||||
import { unzipSync } from "zlib";
|
||||
import type { Platform } from "../platform";
|
||||
import { os, arch, abi, supportedPlatforms } from "../platform";
|
||||
import { debug, error } from "../console";
|
||||
|
||||
declare const version: string;
|
||||
declare const module: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { debug } from "./console";
|
||||
import { exists, read } from "./fs";
|
||||
import { spawn } from "./spawn";
|
||||
import { exists, read } from "./fs";
|
||||
import { debug } from "./console";
|
||||
|
||||
export const os = process.platform;
|
||||
|
||||
|
||||
@@ -10,5 +10,8 @@
|
||||
"strict": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["src", "scripts"]
|
||||
"include": [
|
||||
"src",
|
||||
"scripts"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
"@types/node": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^1.5.3",
|
||||
"@definitelytyped/dtslint": "^0.0.199",
|
||||
"@definitelytyped/eslint-plugin": "^0.0.197",
|
||||
"typescript": "^5.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -2,6 +2,13 @@ import { join } from "node:path";
|
||||
|
||||
import pkg from "../package.json";
|
||||
|
||||
const BUN_VERSION = (process.env.BUN_VERSION || Bun.version || process.versions.bun).replace(/^.*v/, "");
|
||||
const BUN_VERSION = (
|
||||
process.env.BUN_VERSION ||
|
||||
Bun.version ||
|
||||
process.versions.bun
|
||||
).replace(/^.*v/, "");
|
||||
|
||||
Bun.write(join(import.meta.dir, "..", "package.json"), JSON.stringify({ version: BUN_VERSION, ...pkg }, null, 2));
|
||||
Bun.write(
|
||||
join(import.meta.dir, "..", "package.json"),
|
||||
JSON.stringify({ version: BUN_VERSION, ...pkg }, null, 2),
|
||||
);
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
# libusockets.h
|
||||
|
||||
This is the only header you include. Following documentation has been extracted from this header. It may be outdated, go read the header directly for up-to-date documentation.
|
||||
|
||||
These interfaces are "beta" and subject to smaller changes. Last updated **2019-06-11**.
|
||||
|
||||
# A quick note on compilation
|
||||
|
||||
Major differences in performance can be seen based solely on compiler and/or linker options. Important is to compile with some kind of link-time-optimization mode, preferably with static linking of this library such as including all C source files in the user program build step itself. Proper compilation and linking can lead to over 25% performance increase (in my case, YMMV).
|
||||
|
||||
# Cross-platform benchmarks
|
||||
|
||||
While the library is compatible with many platforms, Linux in particular is the preferred production system. Benchmarking has been done on Windows, Linux and macOS where Linux clearly stood out as significant winner. Windows performed about half that of Linux and macOS was not much better than Windows. Do run your production systems on Linux.
|
||||
|
||||
# us_loop_t - The root per-thread resource and callback emitter
|
||||
|
||||
```c
|
||||
/* Returns a new event loop with user data extension */
|
||||
WIN32_EXPORT struct us_loop_t *us_create_loop(void *hint, void (*wakeup_cb)(struct us_loop_t *loop), void (*pre_cb)(struct us_loop_t *loop), void (*post_cb)(struct us_loop_t *loop), unsigned int ext_size);
|
||||
@@ -39,7 +35,6 @@ WIN32_EXPORT long long us_loop_iteration_number(struct us_loop_t *loop);
|
||||
```
|
||||
|
||||
# us_socket_context_t - The per-behavior group of networking sockets
|
||||
|
||||
```c
|
||||
struct us_socket_context_options_t {
|
||||
const char *key_file_name;
|
||||
@@ -92,7 +87,6 @@ WIN32_EXPORT struct us_socket_context_t *us_create_child_socket_context(int ssl,
|
||||
```
|
||||
|
||||
# us_socket_t - The network connection (SSL or non-SSL)
|
||||
|
||||
```c
|
||||
/* Write up to length bytes of data. Returns actual bytes written. Will call the on_writable callback of active socket context on failure to write everything off in one go.
|
||||
* Set hint msg_more if you have more immediate data to write. */
|
||||
@@ -151,7 +145,6 @@ WIN32_EXPORT struct us_loop_t *us_timer_loop(struct us_timer_t *t);
|
||||
```
|
||||
|
||||
## us_poll_t - The eventing foundation of a socket or anything that has a file descriptor
|
||||
|
||||
```c
|
||||
/* A fallthrough poll does not keep the loop running, it falls through */
|
||||
WIN32_EXPORT struct us_poll_t *us_create_poll(struct us_loop_t *loop, int fallthrough, unsigned int ext_size);
|
||||
|
||||
@@ -12,7 +12,6 @@ It comes with built-in pub/sub support, URL routing, TLS 1.3, SNI, IPv6, permess
|
||||
Unlike other "pub/sub brokers", µWS does not assume or push any particular application protocol but only operates over raw, standard WebSockets. You need nothing but a standards compliant web browser and a handful of standards compliant JavaScript to communicate with it. No particular client library is needed or enforced - this unlike inadequate solutions like Socket.IO where you end up locked to a set of proprietary non-standard protocols with horrible performance.
|
||||
|
||||
### Performant
|
||||
|
||||
The implementation is header-only C++17 (but examples use C++20 features for brevity and elegance!), cross-platform and compiles down to a tiny binary of a handful kilobytes.
|
||||
It depends on µSockets, which is a standard C project for Linux, macOS & Windows.
|
||||
|
||||
@@ -21,7 +20,6 @@ Performance wise you can expect to outperform, or equal, just about anything sim
|
||||
We've [openly presented](https://medium.com/swlh/100k-secure-websockets-with-raspberry-pi-4-1ba5d2127a23) detailed cases where a single Raspberry Pi 4 can serve more than 100k very active TLS 1.3 WebSockets, simultaneously, with excellent stability. This is entirely impossible with the vast majority of alternative solutions. Most solutions cramp up and become unreliable at a tiny fraction of this load, on such a limited hardware. We also have measurements where we [serve 12x the HTTP requests per second](https://levelup.gitconnected.com/serving-100k-requests-second-from-a-fanless-raspberry-pi-4-over-ethernet-fdd2c2e05a1e) as compared to Node.js.
|
||||
|
||||
### Simple to use
|
||||
|
||||
Another goal of the project is minimalism, simplicity and elegance.
|
||||
Design wise it follows an ExpressJS-like interface where you attach callbacks to different URL routes.
|
||||
This way you can easily build complete REST/WebSocket services in a few lines of code.
|
||||
@@ -31,26 +29,23 @@ Boilerplate logic like heartbeat timeouts, backpressure handling, ping/pong and
|
||||
The project is async only and runs local to one thread. You scale it as individual threads much like Node.js scales as individual processes. That is, the implementation only sees a single thread and is not thread-safe. There are simple ways to do threading via async delegates though, if you really need to.
|
||||
|
||||
## Compiling
|
||||
|
||||
µWebSockets is 100% standard header-only C++17 - it compiles on any platform. However, it depends on µSockets in all cases, which is platform-specific C code that runs on Linux, Windows and macOS.
|
||||
|
||||
There are a few compilation flags for µSockets (see its documentation), but common between µSockets and µWebSockets flags are as follows:
|
||||
|
||||
- LIBUS_NO_SSL - disable OpenSSL dependency/functionality for uSockets and uWebSockets builds
|
||||
- UWS_NO_ZLIB - disable Zlib dependency/functionality for uWebSockets
|
||||
* LIBUS_NO_SSL - disable OpenSSL dependency/functionality for uSockets and uWebSockets builds
|
||||
* UWS_NO_ZLIB - disable Zlib dependency/functionality for uWebSockets
|
||||
|
||||
You can use the Makefile on Linux and macOS. It is simple to use and builds the examples for you. `WITH_OPENSSL=1 make` builds all examples with SSL enabled. Examples will fail to listen if cert and key cannot be found, so make sure to specify a path that works for you.
|
||||
|
||||
## User manual
|
||||
|
||||
### uWS::App & uWS::SSLApp
|
||||
|
||||
You begin your journey by constructing an "App". Either an SSL-app or a regular TCP-only App. The uWS::SSLApp constructor takes a struct holding SSL options such as cert and key. Interfaces for both apps are identical, so let's call them both "App" from now on.
|
||||
|
||||
Apps follow the builder pattern, member functions return the App so that you can chain calls.
|
||||
|
||||
### App.get, post, put, [...] and any routes
|
||||
|
||||
You attach behavior to "URL routes". A lambda is paired with a "method" (Http method that is) and a pattern (the URL matching pattern).
|
||||
|
||||
Methods are many, but most common are probably get & post. They all have the same signature, let's look at one example:
|
||||
@@ -72,44 +67,40 @@ Data that you capture in a res follows RAII and is move-only so you can properly
|
||||
The "any" route will match any method.
|
||||
|
||||
#### Pattern matching
|
||||
|
||||
Routes are matched in **order of specificity**, not by the order you register them:
|
||||
|
||||
- Highest priority - static routes, think "/hello/this/is/static".
|
||||
- Middle priority - parameter routes, think "/candy/:kind", where value of :kind is retrieved by req.getParameter(0).
|
||||
- Lowest priority - wildcard routes, think "/hello/\*".
|
||||
* Highest priority - static routes, think "/hello/this/is/static".
|
||||
* Middle priority - parameter routes, think "/candy/:kind", where value of :kind is retrieved by req.getParameter(0).
|
||||
* Lowest priority - wildcard routes, think "/hello/*".
|
||||
|
||||
In other words, the more specific a route is, the earlier it will match. This allows you to define wildcard routes that match a wide range of URLs and then "carve" out more specific behavior from that.
|
||||
|
||||
"Any" routes, those who match any HTTP method, will match with lower priority than routes which specify their specific HTTP method (such as GET) if and only if the two routes otherwise are equally specific.
|
||||
|
||||
#### Middlewares
|
||||
|
||||
A very commonly asked question is how to achieve something like middlewares. We don't support middlewares as something built into the router itself. Partly because routes cannot pass data to other routes, partly because the HttpRequest object being stack-allocated and only valid in one single callback invocation, but most importantly - you can **easily** achieve the same function-chaining that is middlewares by instead using simple high-order functions and functional programming. There are tons of examples of this under Discussions (since it is a commonly asked question). A middleware isn't really something that has to be built-in to the server library itself, it really is just **a regular function**. By passing functions to other functions you can build chains of behaviors in very elegant and efficient ways.
|
||||
|
||||
Whether this library should keep a set of commonly used functions is another question - we might do that in the future and we might add an example of its usage but right now there is nothing like this provided. We aim to provide an easy to use server implementation that you can build things on. Not complete business logic puzzle pieces.
|
||||
|
||||
#### Streaming data
|
||||
|
||||
You should never call res.end(huge buffer). res.end guarantees sending so backpressure will probably spike. Instead you should use res.tryEnd to stream huge data part by part. Use in combination with res.onWritable and res.onAborted callbacks.
|
||||
|
||||
Tip: Check out the JavaScript project, it has many useful examples of async streaming of huge data.
|
||||
|
||||
#### Corking
|
||||
|
||||
It is very important to understand the corking mechanism, as that is responsible for efficiently formatting, packing and sending data. Without corking your app will still work reliably, but can perform very bad and use excessive networking. In some cases the performance can be dreadful without proper corking.
|
||||
|
||||
That's why your sockets will be corked by default in most simple cases, including all of the examples provided. However there are cases where default corking cannot happen automatically.
|
||||
|
||||
- Whenever your registered business logic (your callbacks) are called from the library, such as when receiving a message or when a socket opens, you'll be corked by default. Whatever you do with the socket inside of that callback will be efficient and properly corked.
|
||||
* Whenever your registered business logic (your callbacks) are called from the library, such as when receiving a message or when a socket opens, you'll be corked by default. Whatever you do with the socket inside of that callback will be efficient and properly corked.
|
||||
|
||||
- If you have callbacks registered to some other library, say libhiredis, those callbacks will not be called with corked sockets (how could **we** know when to cork the socket if we don't control the third-party library!?).
|
||||
* If you have callbacks registered to some other library, say libhiredis, those callbacks will not be called with corked sockets (how could **we** know when to cork the socket if we don't control the third-party library!?).
|
||||
|
||||
- Only one single socket can be corked at any point in time (isolated per thread, of course). It is efficient to cork-and-uncork.
|
||||
* Only one single socket can be corked at any point in time (isolated per thread, of course). It is efficient to cork-and-uncork.
|
||||
|
||||
- Whenever your callback is a coroutine, such as the JavaScript async/await, automatic corking can only happen in the very first portion of the coroutine (consider await a separator which essentially cuts the coroutine into smaller segments). Only the first "segment" of the coroutine will be called from µWS, the following async segments will be called by the JavaScript runtime at a later point in time and will thus not be under our control with default corking enabled.
|
||||
* Whenever your callback is a coroutine, such as the JavaScript async/await, automatic corking can only happen in the very first portion of the coroutine (consider await a separator which essentially cuts the coroutine into smaller segments). Only the first "segment" of the coroutine will be called from µWS, the following async segments will be called by the JavaScript runtime at a later point in time and will thus not be under our control with default corking enabled.
|
||||
|
||||
- Corking is important even for calls which seem to be "atomic" and only send one chunk. res->end, res->tryEnd, res->writeStatus, res->writeHeader will most likely send multiple chunks of data and is very important to properly cork.
|
||||
* Corking is important even for calls which seem to be "atomic" and only send one chunk. res->end, res->tryEnd, res->writeStatus, res->writeHeader will most likely send multiple chunks of data and is very important to properly cork.
|
||||
|
||||
You can make sure corking is enabled, even for cases where default corking would be enabled, by wrapping whatever sending function calls in a lambda like so:
|
||||
|
||||
@@ -124,7 +115,6 @@ The above res->end call will actually call three separate send functions; res->w
|
||||
Keep this in mind, corking is by far the single most important performance trick to use. Even when streaming huge amounts of data it can be useful to cork. At least in the very tip of the response, as that holds the headers and status.
|
||||
|
||||
### The App.ws route
|
||||
|
||||
WebSocket "routes" are registered similarly, but not identically.
|
||||
|
||||
Every websocket route has the same pattern and pattern matching as for Http, but instead of one single callback you have a whole set of them, here's an example:
|
||||
@@ -165,47 +155,39 @@ WebSocket routes specify a user data type that should be used to keep per-websoc
|
||||
which should belong to the websocket by putting the pointer and the user data in a std::map. That's wrong! Don't do that!
|
||||
|
||||
#### Use the WebSocket.getUserData() feature
|
||||
|
||||
You should use the provided user data feature to store and attach any per-socket user data. Going from user data to WebSocket is possible if you make your user data hold a pointer to WebSocket, and hook things up in the WebSocket open handler. Your user data memory is valid while your WebSocket is.
|
||||
|
||||
If you want to create something more elaborate you could have the user data hold a pointer to some dynamically allocated memory block that keeps a boolean whether the WebSocket is still valid or not. Sky is the limit here, you should never need any std::map for this.
|
||||
|
||||
#### WebSockets are valid from open to close
|
||||
|
||||
All given WebSocket pointers are guaranteed to live from open event (where you got your WebSocket) until close event is called. So is the user data memory. One open event will always end in exactly one close event, they are 1-to-1 and will always be balanced no matter what. Use them to drive your RAII data types, they can be seen as constructor and destructor.
|
||||
|
||||
Message events will never emit outside of open/close. Calling WebSocket.close or WebSocket.end will immediately call the close handler.
|
||||
|
||||
#### Backpressure in websockets
|
||||
|
||||
Similarly to for Http, methods such as ws.send(...) can cause backpressure. Make sure to check ws.getBufferedAmount() before sending, and check the return value of ws.send before sending any more data. WebSockets do not have .onWritable, but instead make use of the .drain handler of the websocket route handler.
|
||||
|
||||
Inside of .drain event you should check ws.getBufferedAmount(), it might have drained, or even increased. Most likely drained but don't assume that it has, .drain event is only a hint that it has changed.
|
||||
|
||||
#### Ping/pongs "heartbeats"
|
||||
|
||||
The library will automatically send pings to clients according to the `idleTimeout` specified. If you set idleTimeout = 120 seconds a ping will go out a few seconds before this timeout unless the client has sent something to the server recently. If the client responds to the ping, the socket will stay open. When client fails to respond in time, the socket will be forcefully closed and the close event will trigger. On disconnect all resources are freed, including subscriptions to topics and any backpressure. You can easily let the browser reconnect using 3-lines-or-so of JavaScript if you want to.
|
||||
|
||||
#### Backpressure
|
||||
|
||||
Sending on a WebSocket can build backpressure. WebSocket::send returns an enum of BACKPRESSURE, SUCCESS or DROPPED. When send returns BACKPRESSURE it means you should stop sending data until the drain event fires and WebSocket::getBufferedAmount() returns a reasonable amount of bytes. But in case you specified a maxBackpressure when creating the WebSocketContext, this limit will automatically be enforced. That means an attempt at sending a message which would result in too much backpressure will be canceled and send will return DROPPED. This means the message was dropped and will not be put in the queue. maxBackpressure is an essential setting when using pub/sub as a slow receiver otherwise could build up a lot of backpressure. By setting maxBackpressure the library will automatically manage an enforce a maximum allowed backpressure per socket for you.
|
||||
|
||||
#### Threading
|
||||
|
||||
The library is single threaded. You cannot, absolutely not, mix threads. A socket created from an App on thread 1 cannot be used in any way from thread 2. The only function in the whole entire library which is thread-safe and can be used from any thread is Loop:defer. Loop::defer takes a function (such as a lambda with data) and defers the execution of said function until the specified loop's thread is ready to execute the function in a single-threaded fashion on correct thread. So in case you want to publish a message under a topic, or send on some other thread's sockets you can, but it requires a bit of indirection. You should aim for having as isolated apps and threads as possible.
|
||||
|
||||
#### Settings
|
||||
|
||||
Compression (permessage-deflate) has three main modes; uWS::DISABLED, uWS::SHARED_COMPRESSOR and any of the uWS::DEDICATED_COMPRESSOR_xKB. Disabled and shared options require no memory, while dedicated compressor requires the amount of memory you selected. For instance, uWS::DEDICATED_COMPRESSOR_4KB adds an overhead of 4KB per WebSocket while uWS::DEDICATED_COMPRESSOR_256KB adds - you guessed it - 256KB!
|
||||
|
||||
Compressing using shared means that every WebSocket message is an isolated compression stream, it does not have a sliding compression window, kept between multiple send calls like the dedicated variants do.
|
||||
|
||||
You probably want shared compressor if dealing with larger JSON messages, or 4kb dedicated compressor if dealing with smaller JSON messages and if doing binary messaging you probably want to disable it completely.
|
||||
|
||||
- idleTimeout is roughly the amount of seconds that may pass between messages. Being idle for more than this, and the connection is severed. This means you should make your clients send small ping messages every now and then, to keep the connection alive. You can also make the server send ping messages but I would definitely put that labor on the client side. (outdated text - this is not entirely true anymore. The server will automatically send pings in case it needs to).
|
||||
* idleTimeout is roughly the amount of seconds that may pass between messages. Being idle for more than this, and the connection is severed. This means you should make your clients send small ping messages every now and then, to keep the connection alive. You can also make the server send ping messages but I would definitely put that labor on the client side. (outdated text - this is not entirely true anymore. The server will automatically send pings in case it needs to).
|
||||
|
||||
### Listening on a port
|
||||
|
||||
Once you have defined your routes and their behavior, it is time to start listening for new connections. You do this by calling
|
||||
|
||||
```c++
|
||||
@@ -217,7 +199,6 @@ App.listen(port, [](auto *listenSocket) {
|
||||
Canceling listening is done with the uSockets function call `us_listen_socket_close`.
|
||||
|
||||
### App.run and fallthrough
|
||||
|
||||
When you are done and want to enter the event loop, you call, once and only once, App.run.
|
||||
This will block the calling thread until "fallthrough". The event loop will block until no more async work is scheduled, just like for Node.js.
|
||||
|
||||
@@ -250,7 +231,6 @@ If you want to, you can simply take the previous example, put it inside of a few
|
||||
Recent Node.js versions may scale using multiple threads, via the new Worker threads support. Scaling using that feature is identical to scaling using multiple threads in C++.
|
||||
|
||||
### Compression
|
||||
|
||||
We aren't as careful with resources as we used to be. Just look at, how many web developers represent time - it is not uncommon for web developers to send an entire textual representation of time as 30-something actual letters inside a JSON document with an actual textual key. This is just awful. We have had standardized, time-zone neutral representation of time in binary, efficient, 4-byte (or more commonly the 8 byte variant) representation since the 1970s. It's called unix timestamp and is an elegant and efficient way of representing time-zone neutral time down to the seconds.
|
||||
|
||||
This is just an example of how we have regressed in our algorithmic thinking. Today it is common to use textual representations such as bloated JSON to represent data, even though most of that bloat is obvious repetitions and inefficient in nature. But we don't care because we have compression. True, even the most bloated source format can be compressed down to a small payload with few repetitions - however - this comes at TREMENDOUS cost.
|
||||
@@ -268,5 +248,4 @@ It is true that we can do more permessage-deflate messages/second than many othe
|
||||
So you might say - hey - that's too complex. Well build an SDK for your users then. Just wrap that "complex" protocol up in a JavaScript library that internally knows about this palette and exposes only simple-to-use functions for the end user. It's not that hard of a problem to solve.
|
||||
|
||||
##### What about TLS/SSL then? I still have to encrypt!
|
||||
|
||||
TLS is nothing like compression. With TLS 1.3 you're still looking at around 80% performance retention over non-TLS. This because TLS is block based and efficiently maps to modern CPUs. Modern CPUs also have hardware offloads for this. It's not that demanding to encrypt traffic using modern encryption standards. Compression is by far the most CPU-demanding thing you can do with your connection, and it requires TONS of per-socket memory.
|
||||
|
||||
@@ -32,11 +32,6 @@
|
||||
#include <iostream>
|
||||
#include "MoveOnlyFunction.h"
|
||||
#include "HttpParser.h"
|
||||
#include <span>
|
||||
#include <array>
|
||||
#include <mutex>
|
||||
|
||||
|
||||
namespace uWS {
|
||||
template<bool> struct HttpResponse;
|
||||
|
||||
@@ -53,78 +48,6 @@ private:
|
||||
/* Minimum allowed receive throughput per second (clients uploading less than 16kB/sec get dropped) */
|
||||
static constexpr int HTTP_RECEIVE_THROUGHPUT_BYTES = 16 * 1024;
|
||||
|
||||
|
||||
#define FOR_EACH_HTTP_METHOD(MACRO) \
|
||||
MACRO("ACL") \
|
||||
MACRO("BIND") \
|
||||
MACRO("CHECKOUT") \
|
||||
MACRO("CONNECT") \
|
||||
MACRO("COPY") \
|
||||
MACRO("DELETE") \
|
||||
MACRO("GET") \
|
||||
MACRO("HEAD") \
|
||||
MACRO("LINK") \
|
||||
MACRO("LOCK") \
|
||||
MACRO("M-SEARCH") \
|
||||
MACRO("MERGE") \
|
||||
MACRO("MKACTIVITY") \
|
||||
MACRO("MKCALENDAR") \
|
||||
MACRO("MKCOL") \
|
||||
MACRO("MOVE") \
|
||||
MACRO("NOTIFY") \
|
||||
MACRO("OPTIONS") \
|
||||
MACRO("PATCH") \
|
||||
MACRO("POST") \
|
||||
MACRO("PROPFIND") \
|
||||
MACRO("PROPPATCH") \
|
||||
MACRO("PURGE") \
|
||||
MACRO("PUT") \
|
||||
MACRO("QUERY") \
|
||||
MACRO("REBIND") \
|
||||
MACRO("REPORT") \
|
||||
MACRO("SEARCH") \
|
||||
MACRO("SOURCE") \
|
||||
MACRO("SUBSCRIBE") \
|
||||
MACRO("TRACE") \
|
||||
MACRO("UNBIND") \
|
||||
MACRO("UNLINK") \
|
||||
MACRO("UNLOCK") \
|
||||
MACRO("UNSUBSCRIBE") \
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
static constexpr std::array<const std::string, 35> HTTP_METHODS = {
|
||||
#define MACRO(name) std::string {name},
|
||||
FOR_EACH_HTTP_METHOD(MACRO)
|
||||
#undef MACRO
|
||||
};
|
||||
static std::span<const std::string> getAllHttpMethods() {
|
||||
return {HTTP_METHODS.data(), HTTP_METHODS.size()};
|
||||
}
|
||||
#else
|
||||
// Windows, and older C++ can't do constexpr std::array<const std::string, 35>
|
||||
static constexpr std::array<const char*, 35> HTTP_METHODS = {
|
||||
#define MACRO(name) name,
|
||||
FOR_EACH_HTTP_METHOD(MACRO)
|
||||
#undef MACRO
|
||||
};
|
||||
|
||||
static std::span<const std::string> getAllHttpMethods() {
|
||||
static std::once_flag flag;
|
||||
static std::array<std::string, 35> methods;
|
||||
std::call_once(flag, []() {
|
||||
methods = {
|
||||
#define MACRO(name) std::string {name},
|
||||
FOR_EACH_HTTP_METHOD(MACRO)
|
||||
#undef MACRO
|
||||
};
|
||||
});
|
||||
return {methods.data(), methods.size()};
|
||||
}
|
||||
#endif
|
||||
#undef FOR_EACH_HTTP_METHOD
|
||||
|
||||
|
||||
us_socket_context_t *getSocketContext() {
|
||||
return (us_socket_context_t *) this;
|
||||
}
|
||||
@@ -581,23 +504,13 @@ public:
|
||||
void onHttp(std::string_view method, std::string_view pattern, MoveOnlyFunction<void(HttpResponse<SSL> *, HttpRequest *)> &&handler, bool upgrade = false) {
|
||||
HttpContextData<SSL> *httpContextData = getSocketContextData();
|
||||
|
||||
std::span<const std::string> methods;
|
||||
std::array<std::string, 1> methods_buffer;
|
||||
// When it's NOT node:http, allow the uWS default precedence ordering.
|
||||
if (method == "*" && !httpContextData->flags.useStrictMethodValidation) {
|
||||
methods = getAllHttpMethods();
|
||||
} else {
|
||||
methods_buffer[0] = std::string(method);
|
||||
methods = {methods_buffer.data(), 1};
|
||||
}
|
||||
std::vector<std::string> methods{std::string(method)};
|
||||
|
||||
uint32_t priority = method == "*" ? httpContextData->currentRouter->LOW_PRIORITY : (upgrade ? httpContextData->currentRouter->HIGH_PRIORITY : httpContextData->currentRouter->MEDIUM_PRIORITY);
|
||||
|
||||
/* If we are passed nullptr then remove this */
|
||||
if (!handler) {
|
||||
for (const auto &method : methods) {
|
||||
httpContextData->currentRouter->remove(method, pattern, priority);
|
||||
}
|
||||
httpContextData->currentRouter->remove(methods[0], pattern, priority);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <span>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "MoveOnlyFunction.h"
|
||||
@@ -278,7 +278,7 @@ public:
|
||||
}
|
||||
|
||||
/* Adds the corresponding entires in matching tree and handler list */
|
||||
void add(const std::span<const std::string> &methods, std::string_view pattern, MoveOnlyFunction<bool(HttpRouter *)> &&handler, uint32_t priority = MEDIUM_PRIORITY) {
|
||||
void add(const std::vector<std::string> &methods, std::string_view pattern, MoveOnlyFunction<bool(HttpRouter *)> &&handler, uint32_t priority = MEDIUM_PRIORITY) {
|
||||
/* First remove existing handler */
|
||||
remove(methods[0], pattern, priority);
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
"title": "JSON schema for bun.lock files.",
|
||||
"allowTrailingCommas": true,
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
@@ -1,129 +1,69 @@
|
||||
.mtk1 {
|
||||
color: #cccccc;
|
||||
}
|
||||
.mtk2 {
|
||||
color: #1f1f1f;
|
||||
}
|
||||
.mtk3 {
|
||||
color: #d4d4d4;
|
||||
}
|
||||
.mtk4 {
|
||||
color: #000080;
|
||||
}
|
||||
.mtk5 {
|
||||
color: #6a9955;
|
||||
}
|
||||
.mtk6 {
|
||||
color: #569cd6;
|
||||
}
|
||||
.mtk7 {
|
||||
color: #b5cea8;
|
||||
}
|
||||
.mtk8 {
|
||||
color: #646695;
|
||||
}
|
||||
.mtk9 {
|
||||
color: #d7ba7d;
|
||||
}
|
||||
.mtk10 {
|
||||
color: #9cdcfe;
|
||||
}
|
||||
.mtk11 {
|
||||
color: #f44747;
|
||||
}
|
||||
.mtk12 {
|
||||
color: #ce9178;
|
||||
}
|
||||
.mtk13 {
|
||||
color: #6796e6;
|
||||
}
|
||||
.mtk14 {
|
||||
color: #808080;
|
||||
}
|
||||
.mtk15 {
|
||||
color: #d16969;
|
||||
}
|
||||
.mtk16 {
|
||||
color: #dcdcaa;
|
||||
}
|
||||
.mtk17 {
|
||||
color: #4ec9b0;
|
||||
}
|
||||
.mtk18 {
|
||||
color: #c586c0;
|
||||
}
|
||||
.mtk19 {
|
||||
color: #4fc1ff;
|
||||
}
|
||||
.mtk20 {
|
||||
color: #c8c8c8;
|
||||
}
|
||||
.mtk21 {
|
||||
color: #606060;
|
||||
}
|
||||
.mtk22 {
|
||||
color: #ffffff;
|
||||
}
|
||||
.mtk23 {
|
||||
color: #cd9731;
|
||||
}
|
||||
.mtk24 {
|
||||
color: #b267e6;
|
||||
}
|
||||
.mtki {
|
||||
font-style: italic;
|
||||
}
|
||||
.mtkb {
|
||||
font-weight: bold;
|
||||
}
|
||||
.mtku {
|
||||
text-decoration: underline;
|
||||
text-underline-position: under;
|
||||
}
|
||||
.mtks {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
.mtks.mtku {
|
||||
text-decoration: underline line-through;
|
||||
text-underline-position: under;
|
||||
}
|
||||
.mtk1 { color: #cccccc; }
|
||||
.mtk2 { color: #1f1f1f; }
|
||||
.mtk3 { color: #d4d4d4; }
|
||||
.mtk4 { color: #000080; }
|
||||
.mtk5 { color: #6a9955; }
|
||||
.mtk6 { color: #569cd6; }
|
||||
.mtk7 { color: #b5cea8; }
|
||||
.mtk8 { color: #646695; }
|
||||
.mtk9 { color: #d7ba7d; }
|
||||
.mtk10 { color: #9cdcfe; }
|
||||
.mtk11 { color: #f44747; }
|
||||
.mtk12 { color: #ce9178; }
|
||||
.mtk13 { color: #6796e6; }
|
||||
.mtk14 { color: #808080; }
|
||||
.mtk15 { color: #d16969; }
|
||||
.mtk16 { color: #dcdcaa; }
|
||||
.mtk17 { color: #4ec9b0; }
|
||||
.mtk18 { color: #c586c0; }
|
||||
.mtk19 { color: #4fc1ff; }
|
||||
.mtk20 { color: #c8c8c8; }
|
||||
.mtk21 { color: #606060; }
|
||||
.mtk22 { color: #ffffff; }
|
||||
.mtk23 { color: #cd9731; }
|
||||
.mtk24 { color: #b267e6; }
|
||||
.mtki { font-style: italic; }
|
||||
.mtkb { font-weight: bold; }
|
||||
.mtku { text-decoration: underline; text-underline-position: under; }
|
||||
.mtks { text-decoration: line-through; }
|
||||
.mtks.mtku { text-decoration: underline line-through; text-underline-position: under; }
|
||||
|
||||
.bunlock {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.lines {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 30px;
|
||||
margin-right: 15px;
|
||||
text-align: right;
|
||||
opacity: 0.5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 30px;
|
||||
margin-right: 15px;
|
||||
text-align: right;
|
||||
opacity: 0.5;
|
||||
|
||||
font-size: var(--vscode-editor-font-size);
|
||||
font-weight: var(--vscode-editor-font-weight);
|
||||
font-family: var(--vscode-editor-font-family);
|
||||
background-color: var(--vscode-editor-background);
|
||||
font-size: var(--vscode-editor-font-size);
|
||||
font-weight: var(--vscode-editor-font-weight);
|
||||
font-family: var(--vscode-editor-font-family);
|
||||
background-color: var(--vscode-editor-background);
|
||||
}
|
||||
|
||||
.lines > span {
|
||||
margin-top: 1px;
|
||||
margin-bottom: 1px;
|
||||
margin-top: 1px;
|
||||
margin-bottom: 1px;
|
||||
}
|
||||
|
||||
code {
|
||||
white-space: pre;
|
||||
white-space: pre;
|
||||
|
||||
font-size: var(--vscode-editor-font-size);
|
||||
font-weight: var(--vscode-editor-font-weight);
|
||||
font-family: var(--vscode-editor-font-family);
|
||||
background-color: var(--vscode-editor-background);
|
||||
font-size: var(--vscode-editor-font-size);
|
||||
font-weight: var(--vscode-editor-font-weight);
|
||||
font-family: var(--vscode-editor-font-family);
|
||||
background-color: var(--vscode-editor-background);
|
||||
}
|
||||
|
||||
code > span {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
margin-top: 1px;
|
||||
margin-bottom: 1px;
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
margin-top: 1px;
|
||||
margin-bottom: 1px;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
"use client";
|
||||
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
function App() {
|
||||
const [count, setCount] = useState(null);
|
||||
const [count, setCount] = useState(null);
|
||||
|
||||
return (
|
||||
<>
|
||||
return (
|
||||
<>
|
||||
{/* @ts-expect-error */}
|
||||
<button onClick={() => setCount(count => count.charAt(0))}>count is {count}</button>
|
||||
</>
|
||||
);
|
||||
<button onClick={() => setCount(count => count.charAt(0))}>count is {count}</button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
export default App;
|
||||
@@ -32,5 +32,5 @@ describe("example", () => {
|
||||
test("can run with special chars :)", () => {
|
||||
// if this test runs, it's a success.
|
||||
// a failure is if it's either skipped or fails the runner
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
@@ -379,4 +379,4 @@
|
||||
"../bun-debug-adapter-protocol",
|
||||
"../bun-inspector-protocol"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ export function registerDebugger(context: vscode.ExtensionContext, factory?: vsc
|
||||
);
|
||||
|
||||
if (getConfig("debugTerminal.enabled")) {
|
||||
injectDebugTerminal2().then(context.subscriptions.push);
|
||||
injectDebugTerminal2().then(context.subscriptions.push)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,17 +136,15 @@ async function injectDebugTerminal(terminal: vscode.Terminal): Promise<void> {
|
||||
}
|
||||
|
||||
async function injectDebugTerminal2() {
|
||||
const jsDebugExt =
|
||||
vscode.extensions.getExtension("ms-vscode.js-debug-nightly") ||
|
||||
vscode.extensions.getExtension("ms-vscode.js-debug");
|
||||
const jsDebugExt = vscode.extensions.getExtension('ms-vscode.js-debug-nightly') || vscode.extensions.getExtension('ms-vscode.js-debug');
|
||||
if (!jsDebugExt) {
|
||||
return vscode.window.onDidOpenTerminal(injectDebugTerminal);
|
||||
return vscode.window.onDidOpenTerminal(injectDebugTerminal)
|
||||
}
|
||||
|
||||
await jsDebugExt.activate();
|
||||
const jsDebug: import("@vscode/js-debug").IExports = jsDebugExt.exports;
|
||||
await jsDebugExt.activate()
|
||||
const jsDebug: import('@vscode/js-debug').IExports = jsDebugExt.exports;
|
||||
if (!jsDebug) {
|
||||
return vscode.window.onDidOpenTerminal(injectDebugTerminal);
|
||||
return vscode.window.onDidOpenTerminal(injectDebugTerminal)
|
||||
}
|
||||
|
||||
return jsDebug.registerDebugTerminalOptionsProvider({
|
||||
@@ -333,7 +331,7 @@ class FileDebugSession extends DebugSession {
|
||||
}
|
||||
|
||||
this.adapter.on("Adapter.reverseRequest", ({ command, arguments: args }) =>
|
||||
this.sendRequest(command, args, 5000, () => {}),
|
||||
this.sendRequest(command, args, 5000, () => { }),
|
||||
);
|
||||
|
||||
adapters.set(url, this);
|
||||
|
||||
@@ -10,8 +10,8 @@ import {
|
||||
UnixSignal,
|
||||
} from "../../../../bun-debug-adapter-protocol";
|
||||
import type { JSC } from "../../../../bun-inspector-protocol";
|
||||
import { getConfig } from "../../extension";
|
||||
import { typedGlobalState } from "../../global-state";
|
||||
import { getConfig } from "../../extension";
|
||||
|
||||
const output = vscode.window.createOutputChannel("Bun - Diagnostics");
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import * as vscode from "vscode";
|
||||
import { getConfig } from "../../extension";
|
||||
import { styleLockfile } from "./lockfile.style";
|
||||
import { getConfig } from "../../extension";
|
||||
|
||||
export type BunLockfile = vscode.CustomDocument & {
|
||||
readonly preview: string;
|
||||
@@ -38,8 +38,8 @@ export class BunLockfileEditorProvider implements vscode.CustomReadonlyEditorPro
|
||||
|
||||
function renderLockfile({ webview }: vscode.WebviewPanel, preview: string, extensionUri: vscode.Uri): void {
|
||||
if (!getConfig("bunlockb.enabled")) {
|
||||
webview.html = "<code>bun.bunlockb</code> config option is disabled.";
|
||||
return;
|
||||
webview.html = "<code>bun.bunlockb</code> config option is disabled."
|
||||
return
|
||||
}
|
||||
|
||||
const styleVSCodeUri = webview.asWebviewUri(vscode.Uri.joinPath(extensionUri, "assets", "vscode.css"));
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import * as vscode from "vscode";
|
||||
import { debugCommand } from "../debug";
|
||||
import { BunTask } from "./tasks";
|
||||
import { getConfig } from "../../extension";
|
||||
|
||||
/**
|
||||
* Parses tasks defined in the package.json.
|
||||
|
||||
@@ -204,6 +204,7 @@ export function registerTestRunner(context: vscode.ExtensionContext) {
|
||||
context.subscriptions.push(watchTestCommand);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Escape any special characters in the input string, so that regex-matching on it
|
||||
* will work as expected.
|
||||
|
||||
62
packages/bun-vscode/src/vscode-js-debug.d.ts
vendored
62
packages/bun-vscode/src/vscode-js-debug.d.ts
vendored
@@ -2,38 +2,38 @@
|
||||
* Copyright (C) Microsoft Corporation. All rights reserved.
|
||||
*--------------------------------------------------------*/
|
||||
|
||||
declare module "@vscode/js-debug" {
|
||||
import type * as vscode from "vscode";
|
||||
declare module '@vscode/js-debug' {
|
||||
import type * as vscode from 'vscode';
|
||||
|
||||
/** @see {IExports.registerDebugTerminalOptionsProvider} */
|
||||
export interface IDebugTerminalOptionsProvider {
|
||||
/**
|
||||
* Called when the user creates a JavaScript Debug Terminal. It's called
|
||||
* with the options js-debug wants to use to create the terminal. It should
|
||||
* modify and return the options to use in the terminal.
|
||||
*
|
||||
* In order to avoid conflicting with existing logic, participants should
|
||||
* try to modify options in a additive way. For example prefer appending
|
||||
* to rather than reading and overwriting `options.env.PATH`.
|
||||
*/
|
||||
provideTerminalOptions(options: vscode.TerminalOptions): vscode.ProviderResult<vscode.TerminalOptions>;
|
||||
}
|
||||
|
||||
/** @see {IExports.registerDebugTerminalOptionsProvider} */
|
||||
export interface IDebugTerminalOptionsProvider {
|
||||
/**
|
||||
* Called when the user creates a JavaScript Debug Terminal. It's called
|
||||
* with the options js-debug wants to use to create the terminal. It should
|
||||
* modify and return the options to use in the terminal.
|
||||
* Defines the exports of the `js-debug` extension. Once you have this typings
|
||||
* file, these can be acquired in your extension using the following code:
|
||||
*
|
||||
* In order to avoid conflicting with existing logic, participants should
|
||||
* try to modify options in a additive way. For example prefer appending
|
||||
* to rather than reading and overwriting `options.env.PATH`.
|
||||
* ```
|
||||
* const jsDebugExt = vscode.extensions.getExtension('ms-vscode.js-debug-nightly')
|
||||
* || vscode.extensions.getExtension('ms-vscode.js-debug');
|
||||
* await jsDebugExt.activate()
|
||||
* const jsDebug: import('@vscode/js-debug').IExports = jsDebug.exports;
|
||||
* ```
|
||||
*/
|
||||
provideTerminalOptions(options: vscode.TerminalOptions): vscode.ProviderResult<vscode.TerminalOptions>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the exports of the `js-debug` extension. Once you have this typings
|
||||
* file, these can be acquired in your extension using the following code:
|
||||
*
|
||||
* ```
|
||||
* const jsDebugExt = vscode.extensions.getExtension('ms-vscode.js-debug-nightly')
|
||||
* || vscode.extensions.getExtension('ms-vscode.js-debug');
|
||||
* await jsDebugExt.activate()
|
||||
* const jsDebug: import('@vscode/js-debug').IExports = jsDebug.exports;
|
||||
* ```
|
||||
*/
|
||||
export interface IExports {
|
||||
/**
|
||||
* Registers a participant used when the user creates a JavaScript Debug Terminal.
|
||||
*/
|
||||
registerDebugTerminalOptionsProvider(provider: IDebugTerminalOptionsProvider): vscode.Disposable;
|
||||
}
|
||||
}
|
||||
export interface IExports {
|
||||
/**
|
||||
* Registers a participant used when the user creates a JavaScript Debug Terminal.
|
||||
*/
|
||||
registerDebugTerminalOptionsProvider(provider: IDebugTerminalOptionsProvider): vscode.Disposable;
|
||||
}
|
||||
}
|
||||
@@ -77,8 +77,10 @@ const Wasi = {
|
||||
},
|
||||
proc_exit() {},
|
||||
|
||||
fd_seek(fd: number, offset_bigint: bigint, whence: unknown, newOffset: unknown) {},
|
||||
fd_write(fd: unknown, iov: unknown, iovcnt: unknown, pnum: unknown) {},
|
||||
fd_seek(fd: number, offset_bigint: bigint, whence: unknown, newOffset: unknown) {
|
||||
},
|
||||
fd_write(fd: unknown, iov: unknown, iovcnt: unknown, pnum: unknown) {
|
||||
},
|
||||
};
|
||||
|
||||
const env = {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { readFileSync } from "fs";
|
||||
import { getTests, init } from "../index.mjs";
|
||||
import { init, getTests } from "../index.mjs";
|
||||
|
||||
const filePath = process.argv[2];
|
||||
if (!filePath) throw new Error("Usage: node node.mjs <file>");
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
"baseUrl": ".",
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["./node_modules/peechy", "./schema.d.ts", "./index.ts", "./schema.js"],
|
||||
"include": [
|
||||
"./node_modules/peechy",
|
||||
"./schema.d.ts",
|
||||
"./index.ts",
|
||||
"./schema.js"
|
||||
],
|
||||
"exclude": []
|
||||
}
|
||||
|
||||
6
repro.js
Normal file
6
repro.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const sym = Symbol();
|
||||
const obj1 = { [sym]: 1 };
|
||||
const obj4 = {};
|
||||
Object.defineProperty(obj4, sym, { value: 1 }); // non-enumerable
|
||||
|
||||
console.log(Bun.deepEquals(obj1, obj4)); // should be 'false'
|
||||
@@ -2,27 +2,27 @@
|
||||
|
||||
// An agent that starts buildkite-agent and runs others services.
|
||||
|
||||
import { realpathSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { parseArgs } from "node:util";
|
||||
import { realpathSync } from "node:fs";
|
||||
import {
|
||||
isWindows,
|
||||
getOs,
|
||||
getArch,
|
||||
getKernel,
|
||||
getAbi,
|
||||
getAbiVersion,
|
||||
getArch,
|
||||
getCloud,
|
||||
getCloudMetadataTag,
|
||||
getDistro,
|
||||
getDistroVersion,
|
||||
getEnv,
|
||||
getHostname,
|
||||
getKernel,
|
||||
getOs,
|
||||
isWindows,
|
||||
mkdir,
|
||||
spawnSafe,
|
||||
getCloud,
|
||||
getCloudMetadataTag,
|
||||
which,
|
||||
getEnv,
|
||||
writeFile,
|
||||
spawnSafe,
|
||||
mkdir,
|
||||
} from "./utils.mjs";
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
/**
|
||||
* @param {"install" | "start"} action
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawn as nodeSpawn } from "node:child_process";
|
||||
import { chmodSync, cpSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
||||
import { existsSync, readFileSync, mkdirSync, cpSync, chmodSync } from "node:fs";
|
||||
import { basename, join, relative, resolve } from "node:path";
|
||||
import {
|
||||
formatAnnotationToHtml,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @bun
|
||||
// Used to generate a features.json file after building Bun.
|
||||
|
||||
import { crash_handler } from "bun:internal-for-testing";
|
||||
import { writeFileSync } from "node:fs";
|
||||
import { crash_handler } from "bun:internal-for-testing";
|
||||
|
||||
writeFileSync("./features.json", JSON.stringify(crash_handler.getFeatureData()));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Glob, file, write } from "bun";
|
||||
import { join, relative, resolve } from "path";
|
||||
import { write, Glob, file } from "bun";
|
||||
import { join, resolve, relative } from "path";
|
||||
import { normalize } from "path/posix";
|
||||
|
||||
const root = resolve(import.meta.dirname, "..");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { $, getUsernameForDistro, spawnSafe, which } from "./utils.mjs";
|
||||
import { $, spawnSafe, which, getUsernameForDistro } from "./utils.mjs";
|
||||
|
||||
export const google = {
|
||||
get cloud() {
|
||||
|
||||
@@ -7,11 +7,9 @@ if (!body) {
|
||||
const latest = (await Bun.file(join(import.meta.dir, "..", "LATEST")).text()).trim();
|
||||
|
||||
const lines = body.split("\n").reverse();
|
||||
|
||||
for (let line of lines) {
|
||||
line = line.trim().toLowerCase();
|
||||
if (line.startsWith("bun v") && line.includes(" on ")) {
|
||||
const version = line.slice("bun v".length, line.indexOf(" ", "bun v".length)).toLowerCase().trim();
|
||||
for (const line of lines) {
|
||||
if (line.startsWith("Bun v") && line.includes(" on ")) {
|
||||
const version = line.slice("Bun v".length, line.indexOf(" ", "Bun v".length)).toLowerCase();
|
||||
|
||||
// Check if valid version
|
||||
if (version.includes("canary")) {
|
||||
@@ -27,26 +25,9 @@ for (let line of lines) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
console.log({
|
||||
latest,
|
||||
version,
|
||||
});
|
||||
|
||||
if (Bun.semver.order(latest, version) === 1) {
|
||||
const [major, minor, patch, ...rest] = version.split(".").map(Number);
|
||||
const [latestMajor, latestMinor, latestPatch, ...latestRest] = latest.split(".").map(Number);
|
||||
|
||||
await Bun.write("is-outdated.txt", "true");
|
||||
await Bun.write("outdated.txt", version);
|
||||
|
||||
const isVeryOutdated =
|
||||
major !== latestMajor || minor !== latestMinor || (latestPatch > patch && latestPatch - patch > 3);
|
||||
|
||||
if (isVeryOutdated) {
|
||||
console.log("Very outdated");
|
||||
await Bun.write("is-very-outdated.txt", "true");
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +1,48 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { existsSync, mkdtempSync, readdirSync } from "node:fs";
|
||||
import { basename, extname, join, relative, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { inspect, parseArgs } from "node:util";
|
||||
import { docker } from "./docker.mjs";
|
||||
import { google } from "./google.mjs";
|
||||
import { orbstack } from "./orbstack.mjs";
|
||||
import { tart } from "./tart.mjs";
|
||||
import {
|
||||
$,
|
||||
copyFile,
|
||||
curlSafe,
|
||||
escapePowershell,
|
||||
getBootstrapVersion,
|
||||
getBuildNumber,
|
||||
getGithubApiUrl,
|
||||
getGithubUrl,
|
||||
getSecret,
|
||||
getUsernameForDistro,
|
||||
homedir,
|
||||
isCI,
|
||||
isMacOS,
|
||||
isWindows,
|
||||
mkdir,
|
||||
mkdtemp,
|
||||
parseArch,
|
||||
parseOs,
|
||||
readFile,
|
||||
rm,
|
||||
setupUserData,
|
||||
sha256,
|
||||
spawn,
|
||||
spawnSafe,
|
||||
spawnSsh,
|
||||
spawnSshSafe,
|
||||
spawnSyncSafe,
|
||||
startGroup,
|
||||
spawnSshSafe,
|
||||
spawnSsh,
|
||||
tmpdir,
|
||||
waitForPort,
|
||||
which,
|
||||
escapePowershell,
|
||||
getGithubUrl,
|
||||
getGithubApiUrl,
|
||||
curlSafe,
|
||||
mkdtemp,
|
||||
writeFile,
|
||||
copyFile,
|
||||
isMacOS,
|
||||
mkdir,
|
||||
rm,
|
||||
homedir,
|
||||
isWindows,
|
||||
setupUserData,
|
||||
sha256,
|
||||
isPrivileged,
|
||||
getUsernameForDistro,
|
||||
} from "./utils.mjs";
|
||||
import { basename, extname, join, relative, resolve } from "node:path";
|
||||
import { existsSync, mkdtempSync, readdirSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { orbstack } from "./orbstack.mjs";
|
||||
import { docker } from "./docker.mjs";
|
||||
import { google } from "./google.mjs";
|
||||
import { tart } from "./tart.mjs";
|
||||
|
||||
const aws = {
|
||||
get name() {
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
// bun ./scripts/nav2readme.ts
|
||||
//
|
||||
//
|
||||
import nav from "../docs/nav";
|
||||
import { readdirSync } from "fs";
|
||||
import path from "path";
|
||||
import nav from "../docs/nav";
|
||||
function getQuickLinks() {
|
||||
let md = "";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { inspect } from "node:util";
|
||||
import { $, mkdtemp, rm, spawnSafe, writeFile, getUsernameForDistro, spawnSshSafe, setupUserData } from "./utils.mjs";
|
||||
import { getUserData } from "./machine.mjs";
|
||||
import { $, getUsernameForDistro, mkdtemp, rm, setupUserData, spawnSafe, spawnSshSafe, writeFile } from "./utils.mjs";
|
||||
|
||||
/**
|
||||
* @link https://docs.orbstack.dev/
|
||||
|
||||
@@ -14,21 +14,21 @@ import {
|
||||
appendFileSync,
|
||||
existsSync,
|
||||
constants as fs,
|
||||
linkSync,
|
||||
mkdirSync,
|
||||
mkdtempSync,
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
realpathSync,
|
||||
statSync,
|
||||
symlinkSync,
|
||||
unlink,
|
||||
unlinkSync,
|
||||
writeFileSync,
|
||||
linkSync,
|
||||
symlinkSync,
|
||||
} from "node:fs";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { userInfo } from "node:os";
|
||||
import { basename, dirname, extname, join, relative, sep } from "node:path";
|
||||
import { basename, dirname, join, relative, sep, extname } from "node:path";
|
||||
import { parseArgs } from "node:util";
|
||||
import {
|
||||
getAbi,
|
||||
@@ -132,7 +132,7 @@ const { values: options, positionals: filters } = parseArgs({
|
||||
},
|
||||
["retries"]: {
|
||||
type: "string",
|
||||
default: isCI ? "3" : "0", // N retries = N+1 attempts
|
||||
default: isCI ? "4" : "0", // N retries = N+1 attempts
|
||||
},
|
||||
["junit"]: {
|
||||
type: "boolean",
|
||||
@@ -749,8 +749,7 @@ async function spawnSafe(options) {
|
||||
(error = /(Illegal instruction) at address/i.exec(buffer)) ||
|
||||
(error = /panic: (.*) at address/i.exec(buffer)) ||
|
||||
(error = /oh no: Bun has crashed/i.exec(buffer)) ||
|
||||
(error = /(ERROR: AddressSanitizer)/.exec(buffer)) ||
|
||||
(error = /(SIGABRT)/.exec(buffer))
|
||||
(error = /(ERROR: AddressSanitizer)/.exec(buffer))
|
||||
) {
|
||||
const [, message] = error || [];
|
||||
error = message ? message.split("\n")[0].toLowerCase() : "crash";
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
writeFileSync,
|
||||
} from "node:fs";
|
||||
import { connect } from "node:net";
|
||||
import { hostname, homedir as nodeHomedir, tmpdir as nodeTmpdir, release, userInfo } from "node:os";
|
||||
import { hostname, tmpdir as nodeTmpdir, homedir as nodeHomedir, userInfo, release } from "node:os";
|
||||
import { dirname, join, relative, resolve } from "node:path";
|
||||
import { normalize as normalizeWindows } from "node:path/win32";
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#include "wtf/Compiler.h"
|
||||
|
||||
#if ASAN_ENABLED
|
||||
const char* __asan_default_options(void)
|
||||
{
|
||||
// detect_stack_use_after_return causes some stack allocations to be made on the heap instead,
|
||||
// which breaks some JSC classes that have to be on the stack:
|
||||
// ASSERTION FAILED: Thread::currentSingleton().stack().contains(this)
|
||||
// cache/webkit-eda8b0fb4fb1aa23/include/JavaScriptCore/JSGlobalObjectInlines.h(63) : JSC::JSGlobalObject::GlobalPropertyInfo::GlobalPropertyInfo(const Identifier &, JSValue, unsigned int)
|
||||
return "detect_stack_use_after_return=0";
|
||||
}
|
||||
#endif
|
||||
@@ -1432,13 +1432,12 @@ fn deferRequest(
|
||||
resp: AnyResponse,
|
||||
) !void {
|
||||
const deferred = dev.deferred_request_pool.get();
|
||||
const method = bun.http.Method.which(req.method()) orelse .POST;
|
||||
deferred.data = .{
|
||||
.route_bundle_index = route_bundle_index,
|
||||
.handler = switch (kind) {
|
||||
.bundled_html_page => .{ .bundled_html_page = .{ .response = resp, .method = method } },
|
||||
.bundled_html_page => .{ .bundled_html_page = .{ .response = resp, .method = bun.http.Method.which(req.method()) orelse .POST } },
|
||||
.server_handler => .{
|
||||
.server_handler = dev.server.?.prepareAndSaveJsRequestContext(req, resp, dev.vm.global, method) orelse return,
|
||||
.server_handler = dev.server.?.prepareAndSaveJsRequestContext(req, resp, dev.vm.global) orelse return,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -7289,12 +7288,10 @@ pub const EntryPointList = struct {
|
||||
/// This structure does not increment the reference count of its contents, as
|
||||
/// the lifetime of them are all tied to the underling Bun.serve instance.
|
||||
const HTMLRouter = struct {
|
||||
map: Map,
|
||||
|
||||
map: bun.StringHashMapUnmanaged(*HTMLBundle.HTMLBundleRoute),
|
||||
/// If a catch-all route exists, it is not stored in map, but here.
|
||||
fallback: ?*HTMLBundle.HTMLBundleRoute,
|
||||
|
||||
pub const Map = bun.StringHashMapUnmanaged(*HTMLBundle.HTMLBundleRoute);
|
||||
pub const empty: HTMLRouter = .{
|
||||
.map = .empty,
|
||||
.fallback = null,
|
||||
|
||||
@@ -525,7 +525,7 @@ pub fn buildWithVm(ctx: bun.CLI.Command.Context, cwd: []const u8, vm: *VirtualMa
|
||||
if (params_buf.items.len > 0) {
|
||||
const param_info_array = JSValue.createEmptyArray(global, params_buf.items.len);
|
||||
for (params_buf.items, 0..) |param, i| {
|
||||
param_info_array.putIndex(global, @intCast(params_buf.items.len - i - 1), bun.String.createUTF8ForJS(global, param));
|
||||
param_info_array.putIndex(global, @intCast(params_buf.items.len - i - 1), JSValue.toJSString(global, param));
|
||||
}
|
||||
route_param_info.putIndex(global, @intCast(nav_index), param_info_array);
|
||||
} else {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user