Compare commits

...

392 Commits

Author SHA1 Message Date
Ashcon Partovi
147826d93c Add todoIf, fixme, and fixmeIf to bun:test 2024-02-21 17:16:04 -08:00
Ashcon Partovi
c0a2073dd5 Read .env file in .vscode/launch.json 2024-02-21 16:17:48 -08:00
Jarred Sumner
a0be3cb2ff Slightly reduce code duplication in expect (#9018)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-20 18:58:33 -08:00
dave caruso
5c6b9ea9b6 change how bunx caches things (#8921)
* some things

* yeah

* ok

* fix compilation error

* fix on windows

* ok

* username
2024-02-20 18:58:12 -08:00
Eemeli Palotie
48e7c0fb8e fix: install vendored node_modules when using hardlinks (#9007)
* fix: install vendored node_modules when using hardlinks

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-19 22:50:24 -08:00
Zack Radisic
2656418e50 Don't immediately delimit command substitution result (#9005) 2024-02-19 21:26:50 -08:00
Zack Radisic
7056384702 Fix file redirect stdin not working (#9000)
* Open with proper perms when redirecting file to stdin

* Add test for redirecting file to stdin

* Extract redirect flags -> bun.Mode logic to function

* Remove dead code

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-19 14:56:32 -08:00
Meghan Denny
5712ba8b3b debug: introduce bun.callmod_inline (#9001) 2024-02-19 14:43:42 -08:00
dave caruso
6f1939621c fix astro (#8999)
* fix astro

* set undefined

* [autofix.ci] apply automated fixes

* Fix astro

* Fix test

* Remove bad assertion

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-19 13:48:08 -08:00
Yannik Schröder
182d052d4b events.on: Add compatibility with readline module (#8885)
* fix: make event.on work with for...await of readline module

* fix: queueing events before next() call and multiple event vals

* test: add tests for events.on and readline for await...of

* style, docs

* [autofix.ci] apply automated fixes

* refactor: use removeListeners instead of check for done

* test: merge test files

* test: remove todo comment

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-19 11:44:09 -08:00
Jarred Sumner
42d15ea853 Fixes #8964 (#8978)
* Fixes #8964

* Fix test.each when used with test.only

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-19 10:36:08 -08:00
Jarred Sumner
7407080628 Bump 2024-02-19 10:28:05 -08:00
Jarred Sumner
7ec9ad5cb7 Add test for #7864 (#8997)
* Add test for #7864

* Add napi-rs/canvas

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-19 10:27:12 -08:00
Meghan Denny
141140ef7c windows: pass more tests (#8938)
* windows: implement bun.isWritable

* windows: pass test/cli/run/as-node.test.ts
C:\Users\dave\AppData\Local\Temp\bun-node-a2ae984c3\node.exe is a hardlink on windows so it will not resolve to C:\bun\build\bun-debug.exe
skip the first param since that is not the behavior this test is supposed to be testing

* windows: pass test/js/node/dns/node-dns.test.js

* windows: pass test/js/node/process/process.test.js

* windows: pass test/js/web/streams/streams.test.js

* windows: pass test/js/workerd/html-rewriter.test.js
Closes #8459

* windows: fix node:util.inspect

* windows: these pass now

* windows: pass test/js/node/stream/node-stream.test.js

* disable http sendfile on windows

* use url.origin here

* more sendfile removal

* windows: pass test/js/web/websocket/websocket.test.js

* test/js/deno/performance/performance.test.ts is flaky, come back to it

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-19 10:23:31 -08:00
Cameron Haley
8c7972fdc8 Don't rely on stored napiRef; Always create a new one in napi_create_reference (#8995) 2024-02-19 09:07:15 -08:00
Jarred Sumner
80e4712662 Skip sqlite math fns test on macOS 2024-02-18 12:08:17 -08:00
3λiȯ+
3221bfeeb7 docs: Fix unclosed code block in the example for WebSocketHandler (#8971) 2024-02-17 18:11:22 -08:00
Dale Seo
89641f2e4a chore: add types for date mocking api of jest (#8387) 2024-02-17 08:05:16 -08:00
Risu
bc74154536 docs: use consistent tsconfig for both in docs and bun init (#8953) 2024-02-17 08:04:03 -08:00
Jarred Sumner
a6acb257c1 Fixes #8940 (#8957)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-17 05:48:36 -08:00
Risu
c34bbb2e3f fix: organize tsconfig (#8654)
* fix: organize tsconfig

* fix: remove unnecessary comments in tsconfig

* docs: revert changes on comments and md text

* docs: fix case
2024-02-16 22:19:31 -08:00
Jarred Sumner
f9b12300d4 Make shell errors slightly better (#8945)
* Make shell errors slightly better

* Update shell.ts

* Fix the failing tests

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-16 20:43:42 -08:00
Jarred Sumner
abf1239976 feat: Support async generator functions in Response and Request for bodies (#8941) 2024-02-16 20:02:22 -08:00
argosphil
e2c92c69b5 fix: make sure Bun.sleep(Date) doesn't resolve prematurely (#8950)
* fix: make sure Bun.sleep(Date) doesn't return prematurely

Fixes #8834.

This makes Bun.sleep(new Date(x)) fulfill its promise only when
Date.now() >= x.

* resolve test now #8834 is fixed

11 ms is in fact the right limit.

---------

Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
2024-02-16 18:32:37 -08:00
Tony Zhang
135de4dff7 fix(sqlite): enable math functions (#8944)
* fix(sqlite): enable math functions

* fix(sqlite): enable math function flag in CMakeLists

* test: add math function tests

---------

Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
2024-02-16 18:24:55 -08:00
Dmitri
fe8ec29f1f Add fs.exists[util.promisify.custom] (#8936)
* Add fs.exists[util.promisify.custom]

fs.exists doesn't follow the error-first-callback convention, so it
needs a custom implementation for util.promisify.

* Simplify

---------

Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
2024-02-16 18:24:04 -08:00
Ashcon Partovi
27eed543ef Add .env to .gitignore 2024-02-16 14:13:19 -08:00
John-David Dalton
17e01a284b Add url unit tests with failing tests TODO commented-out (#8933)
Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
2024-02-16 11:32:08 -08:00
Zack Radisic
2b56451a11 Shell changes/fixes (#8846)
* Fix #8403

* Throw on error by default

* Add the shell promise utilities to `ShellOutput` and `ShellError`

* Fix tests

* [autofix.ci] apply automated fixes

* Fix memleak

* [autofix.ci] apply automated fixes

* Woops

* `Bun.gc(true)` in fd leak test

* fd leak test should check if `fd <= baseline`

* wtf

* oob check

* [autofix.ci] apply automated fixes

* Fix double free

* Fix #8550

* increase mem threshold for linux

* Requested changes and make not throw on by default

* [autofix.ci] apply automated fixes

* more requested changes

* Do destructuring in function definition

* delete

* Change shell output test to enable throwing

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-16 05:01:55 -08:00
Zack Radisic
0e2a3a0197 fix(glob): fix patterns starting with * #8817 (#8847)
* Fix #8817

* [autofix.ci] apply automated fixes

* yoops

* fix broken stuff from merge

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-16 04:12:12 -08:00
Zack Radisic
ebaeafbc89 feat: More robust and faster shell escaping (#8904)
* wip

* Proper escaping algorithm

* Don't use `$` for js obj/string referencs

* [autofix.ci] apply automated fixes

* Changes

* Changes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-16 04:09:34 -08:00
Meghan Denny
2b335d72e7 windows: make websocket-client.test.ts pass (#8935) 2024-02-16 04:07:06 -08:00
guest271314
dcda49a271 Missing toWeb (#8937)
https://github.com/oven-sh/bun/issues/3927
2024-02-15 21:41:46 -08:00
John-David Dalton
d49cb0b98e chore: Add PrivateRecursive type annotations (#8291) 2024-02-15 17:35:08 -08:00
dave caruso
bb31e768de docs: update windows build instructions
this removes the WSL codegen step as it is no longer supported, and some other notes i am aware of now
2024-02-15 16:54:03 -08:00
Jake Gordon
099825e5ac Common HTTP server usage guide (#8732)
Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
2024-02-15 16:30:59 -08:00
Henrikh Kantuni
fc05cbfedc Fix typo (#8930)
"Buns supports" → "Bun supports"

Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
2024-02-15 16:20:55 -08:00
argosphil
c920919c42 fix: distinguish getters and setters in Bun.inspect() (#8858)
* Bun.inspect: distinguish [Getter], [Setter], [Getter/Setter]

fixes #8853

NOTE: this modifies files which were auto-generated at one point, but
which are now maintained as part of the Bun sources.

* test for #8853

---------

Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
2024-02-15 13:09:13 -08:00
Georgijs
da78103b1c fix typo (#8929) 2024-02-15 13:07:07 -08:00
dave caruso
a2ae984c3e disable some tests that are failing in ci (#8922)
* try to make ci green

* fix a crash in debug mode

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-15 07:09:44 -08:00
Jarred Sumner
151512dcc9 Release weak refs before responding to websocket messages (#8898)
* Release weak refs before responding to websocket messages

* Yes

* Wrap the methods instead of the callers

* oops

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-15 07:09:10 -08:00
Toby Cm
1b945ba2ef fix: Update URL in non-avx warning message (#8435)
`https://github.com/oven-sh/bun/release/bun-v1.0.25/bun-linux-x64-baseline.zip`

->

`https://github.com/oven-sh/bun/releases/download/bun-v1.0.25/bun-linux-x64-baseline.zip`
2024-02-15 03:57:22 -08:00
dave caruso
e8dff7b029 chore: random acts of cleanup to tests (#8915)
* random acts of cleanup to tests

* nerf the watchFile test, is CI slow?

* more things

* [autofix.ci] apply automated fixes

* a

* remove a log

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-14 22:40:50 -08:00
Jarred Sumner
d936f365c8 Fixes #8909 (#8911)
* Fixes #8909

* Add it

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-14 18:57:20 -08:00
Jarred Sumner
48c0d7aadc Fix incorrect type definition in usockets loop (#8912)
* Fix incorrect type definition

* Remove dead code

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-14 18:57:07 -08:00
dave caruso
cf054456ce fix build on all platforms 2024-02-14 18:38:20 -08:00
Jarred Sumner
57b1e545f8 This debug code should not have been committed 2024-02-14 18:36:24 -08:00
Meghan Denny
12f83cf48b make V8StackTraceIterator frame parser more robust (#8814)
* make V8StackTraceIterator frame parser more robust

* remove StringView_count and only call StringView::find as many times as we need
2024-02-14 18:25:30 -08:00
Lei
b0f9e03230 Fix coverage.md (#8864)
See lines 264/271 of bunfig.zig
2024-02-14 18:20:37 -08:00
argosphil
7481a29f4e fix: brotli decompression's multi-packet case (#8881)
* fix: reset buffer pointer (misleadingly named total_in) for brotly

Fixes #8017

* fix: panic if brotli decompressor misbehaves
2024-02-14 18:19:46 -08:00
argosphil
0714b3a06b fix: throw on gunzipSync/inflateSync error (#8901)
* fix: zlib functions should throw an error if appropriate

Fixes #8887.

* Tests for #8887

* fix: drive-by fix to avoid unreachable code being reached on error
2024-02-14 18:01:05 -08:00
Dylan Conway
08c2148000 fix(windows): console-iterator.test.ts fix (#8879)
* fix console iterator tests on windows

* rename and size only when bytes is active

* assert size > 0
2024-02-14 17:59:19 -08:00
James Anderson
00cc2eae67 Fix tsconfig path longest prefix matching (#8892) 2024-02-14 08:23:45 -08:00
Dylan Conway
82a07430ed fix(windows): use allocated memory for \\\\.\\NUL replacement on windows (#8889)
* use allocated memory for /dev/null

* deinit
2024-02-13 22:23:54 -08:00
Georgijs
636a8f1f0a Prevent open but inactive http connections from keeping alive http server (#8829)
* unref uv handle after creating uws socket

* unref sockets between http requests to allow the event loop to exit

* remove stale comment
2024-02-13 22:22:44 -08:00
7f8ddd
05d33c39cd fix: Add charset to text/css mime type (#8825)
* Add charset to text/css mime type

Standard: https://www.iana.org/assignments/media-types/text/css

More info: https://stackoverflow.com/questions/70643383/which-mime-types-contain-charset-utf-8-directive

Fixes the warning in Edge that says to include utf-8 when Bun returns a stylesheet.

* Add test

* Change "content type" to "mime-type"
2024-02-13 20:47:02 -08:00
dave caruso
aba37525a6 windows: fix bundler reliability and nuke WSL-based codegen scripts (#8890)
* bruh

* yeaaahhhhhhhhhhhhhhhhhhhhhhhhhhh

* revisions

* yeah

* fix

* make no codegen do less things
2024-02-13 20:33:24 -08:00
dave caruso
04a6ebaa17 fix: allow opening win32 device files in node:fs and bun.file (#8801)
* support opening device files in node:fs and bun.file

* tidy tests

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-13 18:24:14 -08:00
Augie
7405c5a615 feat: make curl install script run the windows installer (if run through cygwin) (#8875)
This updates the *nix install script to run the Windows Powershell install script if it detects it's on Windows.
2024-02-13 11:35:17 -08:00
Jarred Sumner
d0903f6b71 Cherry-pick 570fe762c8 (#8830)
This cherry-picks 570fe762c8

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
2024-02-13 10:58:27 -08:00
Ciro Spaciari
d0b6218bdf fix(fetch) redirects bodies should be handled (#8874)
* redirects bodies should be handled

* [autofix.ci] apply automated fixes

* Update src/http.zig

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-12 21:14:00 -08:00
Meghan Denny
8afcb39055 windows: more tests are passing (#8873) 2024-02-12 17:52:14 -08:00
Meghan Denny
b2a697f264 scripts/codegen.ps1: update wsl call (#8871) 2024-02-12 16:46:26 -08:00
Zack Radisic
aca936515a Make glob work for windows (#8382)
* Fix some related to paths and string encoding

* Fix relative paths with glob

* Fix scan tests

* Fix glob scan test

* [autofix.ci] apply automated fixes

* Fix leak test

* clean up post merge

* [autofix.ci] apply automated fixes

* clean up glob getcwd

* remove old struct

* fix open on posix

* feat: Add win32 path.toNamespacedPath and align rest of node:path with Node (#8469)

* restore zls file change

* [autofix.ci] apply automated fixes

* switch to using fs.top_level_dir in glob

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
Co-authored-by: Georgijs Vilums <georgijs@bun.sh>
Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
2024-02-12 16:30:58 -08:00
Zack Radisic
6ba146c3e0 Run zig fmt 2024-02-12 17:40:36 -06:00
Georgijs
a80b3569b4 disable quiet logs when BUN_DEBUG_LOG is set to 0 (#8866) 2024-02-12 15:20:38 -08:00
argosphil
8b5cac1ea1 chore: use shell-independent globbing in bun run fmt:zig (#8861)
* fix: use shell-independent globbing in bun run fmt:zig

* Erase experimental creature escaped from @paperdave's lab.

See https://github.com/oven-sh/bun/pull/8861#discussion_r1485747297
2024-02-12 14:51:39 -08:00
John-David Dalton
96e7227087 feat: Add win32 path.toNamespacedPath and align rest of node:path with Node (#8469) 2024-02-12 14:27:26 -08:00
Dale Seo
f88855da4f docs: non-null assertion is needed on document.getElementById (#8540) 2024-02-11 20:10:17 -08:00
Ujjwal gupta
19cb3ab6ff fix: ws.publish() not working (#8855)
* fix: ws.publish() not working

* fixes
2024-02-11 13:56:06 -08:00
argosphil
862d35d832 fix: bun test -t (#8845) 2024-02-11 08:39:27 -08:00
argosphil
a0bcd0f946 Fix expect().toBeGreaterThan() not throwing when ANSI is disabled (#8838) 2024-02-10 14:00:16 -08:00
guest271314
2264bb3d04 Substitute js/ for test/js/ (404) (#8808) 2024-02-10 10:44:22 -08:00
Ciro Spaciari
3e1231deb4 fix(crypto) fix KeyObjectkey handling (#8824)
* ref/deref buffer

* Clean up this code

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-09 21:14:35 -08:00
dave caruso
dfcac563bc fix error message in bun.serve (#8828)
* fix error message in bun.serve

* ok
2024-02-09 17:24:46 -08:00
Ciro Spaciari
90fd322b5c fix timer tests (#8804) 2024-02-09 14:00:47 -08:00
Zack Radisic
f77b217abf Correct shell docs for $.escape() 2024-02-09 11:41:59 -06:00
Risu
7c2be6a877 Fix bun-types/index.d.ts (#8802) 2024-02-09 08:46:42 -08:00
Dylan Conway
a3c3dad351 wrap (#8812) 2024-02-09 03:42:03 -08:00
Travis Cooper
98b438d0a4 Update bunfig.md (#8807) 2024-02-09 01:54:00 -08:00
cirospaciari
58d22b063c Unmark tests that are now passing on Windows 2024-02-08 23:02:32 -03:00
Ciro Spaciari
8cd1db9cda [windows] fix crypto (#8797)
* fix password

* refactor

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-08 18:00:22 -08:00
dave caruso
2d7df726fd fix: get bun build working on window (#8712)
* work on bundler

* a

* YAAAAYYAYAYAYYAYA

* get some more bundler tests working

* Update src/bundler/bundle_v2.zig

* rev

* ok

* i converted the cmakelists into LF

* personal review

* we didnt win

* okey they pass

* revert :(

* a

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-08 17:56:26 -08:00
Ashcon Partovi
1ccf0c2e9c Fix some errors not showing up in GitHub annotations (#8799)
* Remove dead code now that `expect()` can be used outside of tests

* Fix some errors not being rendered to GitHub annotations

* [autofix.ci] apply automated fixes

* Update jest.zig

Try `execCallback`

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-08 17:52:58 -08:00
cirospaciari
db85e04ade Unmark tests that are now passing on Windows 2024-02-08 22:19:31 -03:00
Ciro Spaciari
c2936b205d [windows] fix(fetch) file:///, keepalive and tests on Windows (#8784)
* fix file:/// on windows

* skip fifo test

* fix keepalive

* fixes

* avoid std.os.getcwd on POSIX
2024-02-08 17:11:06 -08:00
dave caruso
8680641c23 make process.test.js pass (#8798) 2024-02-08 16:54:09 -08:00
Ciro Spaciari
e77db8ebac [windows] fix which (#8791)
* fix which

* [autofix.ci] apply automated fixes

* refactor

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-08 15:44:56 -08:00
Steven Roussey
dfbedd6a10 fix: flaky test (#8796)
This often fails in CI (and on my machine) non-deterministically.

The 1ms + the 5000 is likely setting up a race condition in tasks/microtasks. Just changing it to to +10ms instead of +1ms is enough.
2024-02-08 15:17:14 -08:00
Ashcon Partovi
8624a86eba Unmark tests that are now passing on Windows 2024-02-08 13:42:13 -08:00
Georgijs
bfc6091faf correctly unblock all signals (#8792) 2024-02-08 12:09:33 -08:00
Joe
9d0a88ab82 docs: quick note on dependencies for C++ (#8772)
* quick note on dependencies for C++

* note Ubuntu C++ standard lib issue and anchor link to troubleshooting

* clarify ubuntu distros
2024-02-08 11:18:37 -08:00
Jarred Sumner
2f8f77eeb7 Ignore panic in reload (#8778)
* Ignore panic in reload

* Use

* Update c-bindings.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-08 00:29:08 -08:00
Steven Roussey
7b6e0f7164 fix: Increase max depth of expect diffs (#8771)
Fix Issue #6519
2024-02-07 16:07:20 -08:00
Ciro Spaciari
5df59cb02b [windows] fix(fs.watch) (#8746)
* clean fixes

* [autofix.ci] apply automated fixes

* more tests passing

* EPERM instead of AccessDenied

* [autofix.ci] apply automated fixes

* fix test on windows

* cleanup

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-07 15:44:07 -08:00
Jarred Sumner
b61282e290 Fix async module mocking (#8769)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-07 15:40:10 -08:00
Dylan Conway
dd3227c436 fix: crash in release builds (#8773)
* zig

* unreachable

* more comment
2024-02-07 15:38:14 -08:00
Georgijs
a9a4bbcd24 remap 0.0.0.0 to localhost on windows (#8770) 2024-02-07 15:17:24 -08:00
Georgijs
55aa35ee35 Fix watch attempting to reuse ports that are not yet released by the old process (#8764)
* windows watcher start new process only after previous terminated

* simplify env setup in spawnWatcherChild
2024-02-07 15:11:28 -08:00
dave caruso
a99459ffdc fix: symlinked files as entry points do not show Bun.main (#8762) 2024-02-07 13:06:11 -08:00
Jake Gordon
08f957d33b fix glob example to be recursive as stated (#8755) 2024-02-07 12:53:28 -08:00
Georgijs
2bd4fe578e Make HTTP shutdowns more robust, speed up connection to localhost (#8730)
* http use arraylist to handle shutdowns

* on windows use wsaconnectbyname to speed up localhost connections

* use arbitrary port

* close socket on setsockopt error

* use null timeout in wsaconnectbyname

* Update src/http.zig

* fix zig compile

* update hostname on linux

* [autofix.ci] apply automated fixes

* fix getpeername failing after connecting with socket

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-07 12:19:41 -08:00
Georgijs
d672309547 c-ares dns on windows (#8737)
* c_ares dns on windows works

* handle errors

* fix invalid hostnames test
2024-02-07 16:26:53 -03:00
argosphil
e171f04ce6 Fix ref-counting of Bun.file(0) etc. (#8687) (#8741)
* Test for #8687

* Fix reference counting of Bun.file(0) etc. (#8687)

Fixes #8687.
2024-02-06 18:11:25 -08:00
Ciro Spaciari
651d5699a0 [windows] fix(fs.watchFile) (#8735)
* fix fs.watchFile

* oopsie

* fix bigint and persistent

* use repeat to make watchFile tests more reliable

* [autofix.ci] apply automated fixes

* follow the pattern

* add increment

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-06 18:10:28 -08:00
Meghan Denny
d0d4d8bf85 windows: enable more passing tests (#8711)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-06 16:08:49 -08:00
Ciro Spaciari
53814dda00 [windows] fix(http2) (#8734)
* fix win http2

* add includes

* cleanup

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-06 15:37:39 -08:00
Meghan Denny
d3d5c7a1d6 tidy: access env map through getter rather than direct field (#8716) 2024-02-06 11:25:45 -08:00
Jarred Sumner
972a7b7080 skip some tests 2024-02-05 19:51:08 -08:00
Jarred Sumner
e3759bbbfe Update bun-windows.yml 2024-02-05 18:46:18 -08:00
Jarred Sumner
f722236978 [windows] Make child_process.spawn not say "TODO: IPC" when IPC isn't used 2024-02-05 17:39:47 -08:00
dave caruso
e366921e90 fix(windows): make fs.symlink normalize forward slashes to backslashes (#8710)
* fix fs.symlink()

* update comment

* .

* add todo
2024-02-05 16:09:50 -08:00
Georgijs
bd2779b029 Fix --hot with empty file, make --hot faster on windows (#8708)
* reduce watcher timeout in windows, fix hot reload with empty files

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-05 14:40:18 -08:00
Ashcon Partovi
a05ef0aeb1 Remove unintentional commit
This reverts commit 23b292ac21.
2024-02-05 12:50:09 -08:00
Ashcon Partovi
264142e756 Add isWindows and related helpers to test harness 2024-02-05 12:47:52 -08:00
Ashcon Partovi
51def5f5d6 Use biome in bun-types 2024-02-05 12:22:39 -08:00
Ashcon Partovi
23b292ac21 T 2024-02-05 12:22:39 -08:00
dave caruso
48ed1dfb65 less (#8651)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-05 10:06:23 -08:00
Drake Semchyshyn
bd4d0d15db Update plugins.md (#8674)
Updated Custom Plugins section (Svelte) so that the import name, and the name that was used, matches each other.
2024-02-04 01:19:00 -08:00
Jarred Sumner
1f0c1c81e9 Fix test 2024-02-04 00:42:40 -08:00
Jarred Sumner
e93eb6c1ab Add event loop debug assertion for Promise.resolve() and Promise.reject() 2024-02-04 00:03:45 -08:00
Jarred Sumner
1009b07807 Implement server.unref() and server.ref() (#8675)
* Implement server.ref() and server.unref()

* Update dns_resolver.zig

* Update server.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-03 23:57:34 -08:00
Georgijs
1a695f13bf Async file copying on windows (#8649)
* rework and simplify file opening in windows

* fix tests

* symlink tests pass

* update error handling

* remove outdated normalization check

* fix mac build

* apply suggested fixes

* fix path tests

* remove debug print

* fix windows compile
2024-02-03 22:33:35 -08:00
Jarred Sumner
c75e768a6c Assert we drained the microtask queue since the last time we called into JavaScript (#8646)
* Add checks that we drain the microtask queue whenever we call into JavaScript

* Drain microtasks in more places

* Tweak assertions for entering/exiting the event loop

* Drain more

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-03 07:40:15 -08:00
Dylan Conway
7d86f9e590 fix(test): strict equals and deleted properties (#8663)
* deleted properties size

* dont need count if structure id is eql

* more test

* fix slow path

* oops forgot this
2024-02-03 06:35:13 -08:00
Dylan Conway
a8600b0878 upgrade 2024-02-03 06:20:24 -08:00
Dylan Conway
5b228256f9 method and comment 2024-02-03 04:24:20 -08:00
Dylan Conway
ba4daee7e5 fix: statement joining and tmpdir on windows (#8659)
* drive letter

* joinwithcomma bundle

* tmpdir update

* same order as os.tmpdir
2024-02-03 04:17:12 -08:00
Jarred Sumner
2c0c562d1d Fixes #4746 (#8661)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-03 03:38:59 -08:00
Jarred Sumner
683a03d8c7 Set a default value for Error.prepareStackTrace to align with Node (#8657)
* Set a default value for `Error.prepareStackTrace` to align with Node

* Ensure we never set negative line/column numbers in error.stack (#8656)

* fix(windows): fix macros (#8653)

* fix macro tests

* path format options

* remove failing comment

* fix buffer toString memcpy length

* Ensure we never set negative line/column numbers in error.stack

---------

Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2024-02-03 02:04:58 -08:00
Dylan Conway
e0c0fe235a fix(windows): fix macros (#8653)
* fix macro tests

* path format options

* remove failing comment

* fix buffer toString memcpy length
2024-02-03 00:35:25 -08:00
Jarred Sumner
d16ac87347 Export compile_commands.json 2024-02-02 23:25:07 -08:00
Dylan Conway
5934b17f00 fix(windows): fix a few more tests (#8644)
* fix regression tests

* fix fs.test.ts bigintstats

* enable transpiler cache lol

* remove failing

* fix filesystem router

* update

* fix run-unicode test

* update comment

* add updated snapshot

* fix remaining node-module-module tests

* fixup

* [autofix.ci] apply automated fixes

* fix tty tests

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-02 18:58:16 -08:00
Ashcon Partovi
eedf008c80 Fix formatting not always working 2024-02-02 14:25:53 -08:00
Meghan Denny
3a6318b67c windows: fix module.paths getter causing a crash (#8633)
* windows: fix module.paths getter causing a crash

* use the buffer that was there before
2024-02-02 01:29:50 -08:00
dave caruso
647b15e4f3 fix(windows): initialize uv allocators earlier (#8631)
* uv loop is thread local

* hi

* stuff so far

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-02 00:18:28 -08:00
ふかねこ
625b172a71 docs: Update binary-data.md (#8635)
Binary notation ("0b") is appropriate instead of hexadecimal notation ("0x").

Sorry for the omission of the correction in this [PR](https://github.com/oven-sh/bun/pull/8619).
2024-02-02 00:16:14 -08:00
Meghan Denny
4959c7d363 remove ZigString.Slice.from .init is the exact same thing (#8632)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-01 20:35:47 -08:00
Meghan Denny
8808437a02 meta: remove remaining references to prettierrc.cjs (#8634) 2024-02-01 19:24:17 -08:00
Tiramify (A.K. Daniel)
330a4744de chore: fix compiling fd.zig on linux (#8630) 2024-02-01 17:31:54 -08:00
Ashcon Partovi
3a1229d03d Add mysql2 integration test (#8075) 2024-02-01 15:04:49 -08:00
Ashcon Partovi
63a9a8b015 Improve .vscode extensions, tasks, and configuration (#8511) 2024-02-01 14:55:35 -08:00
dave caruso
f73bde79c7 fix(debug): get the result for fd debug message before we close it (#8626) 2024-02-01 14:26:20 -08:00
Meghan Denny
3a7df3f6c7 windows: add more passing test (#8615) 2024-02-01 13:45:47 -08:00
dave caruso
0037dc2537 chore: update webkit 2024-02-01 13:38:09 -08:00
ふかねこ
c0fe042102 Update binary-data.md (#8619)
Binary notation ("0b") is appropriate instead of hexadecimal notation ("0x").
2024-02-01 12:38:54 -08:00
Andres Guarneros
ce1eba1954 Update quickstart.md (#8622)
Update index.ts code snippet for consistency in quickstart.md.
2024-02-01 12:38:21 -08:00
Dylan Conway
8191fbd970 fix: id instead of path (#8617)
* use id

* another path
2024-02-01 02:19:18 -08:00
Dylan Conway
2af7cdedc2 path should be dirname 2024-02-01 00:34:34 -08:00
Dylan Conway
4f98336f86 fix(windows): fix installing non-ascii paths and make normalizeBuf generic (#8608)
* comptime type normalizeStringBuf

* delete

* revert

* revert revert

* revert

* remove unused

* remove unnecessary assert

* add comment

* remove normalize, need ../

* use Output.err

* update error message

* generic T suffix

* fix windows build

* more fix build

* more fix build

* mkdiratZ

* update test

* [autofix.ci] apply automated fixes

* update snapshot again

* fix merge

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-31 22:44:23 -08:00
dave caruso
91cfd614ca fix(window): some more bin things (#8612)
* allow linking bins that do not exist.

* fix some things
2024-01-31 22:37:03 -08:00
Meghan Denny
42e4cd8408 get more bundler tests passing on windows (#8560)
* get test/bundler/bundler_naming.test.ts passing on windows

* move platformToPosixInPlace to bun.path and use the vector'd version

* only resolve rel_path if it contains '/./', most of the time './' needs to be preserved

* fix another file too

* move kernel32 extern to better location

* [autofix.ci] apply automated fixes

* use bun.path.posixToPlatformInPlace here

* rewrite this whole section to stay in utf16 and handle errors

* remove dead comments

* fix a typo

* undo these relative changes

* preserve path.pretty from getting lost

* use bun's instead of zig's resolve here

* both side of this loop need the inplace normal

* use existing generic dirname function

* make path inplace functions generic

* we might need to modify this so copy on windows

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>

* don't assume the prefix we get from this

* more robust path traversal

* don't mangle absolute paths

* do this bit in a loop

* this line is a u16

* dont forget to compile before pushing

* this was wrong

* look into this later

* check pointer math first since its faster

* posix syscalls support path traversal, don't do the work for them

* its already inside stable, no need to change

* used the online editor

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-31 22:29:33 -08:00
dave caruso
dbe0a4a978 do more assertions (#8610) 2024-01-31 22:14:03 -08:00
Georgijs
350cc1178a --watch and --hot on windows (#8607)
* draft impl of windows watcher

* synchronous watcher

* working standalone watcher

* in progress changes to watcher

* make watcher non-global

* prepare watcher for windows impl

* add windows watcher scaffold and clean up imports

* fix inotify

* make watch code more generic over platforms

* fix visibility

* watcher starts without error

* printing changes works

* basic windows watching works

* handle process exit from watcher

* cleanup in process cloning

* clean up logging and panic handling

* fix hot reload test on windows

* misc cleanup around watcher

* make watch test actually useful

* [autofix.ci] apply automated fixes

* remove old files

* clean up watchers

* update .gitignore

* rework windows watcher into single watcher instance watching top level project dir

* use non-strict utf16 conversion

* change to contains

* fix mac and linux compile

* add baseline in crash report (#8606)

* allow linking bins that do not exist. (#8605)

* fix linux compile

* fix linux compile (again)

* remove outdated todo

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
2024-01-31 22:06:33 -08:00
Jarred Sumner
dccabd9423 Make test work better on windows 2024-01-31 22:03:52 -08:00
dave caruso
345a061d3b fix(windows): make process.env case-insensitive (#8578)
* yay!!!!!!

* [autofix.ci] apply automated fixes

* ok

* do not use reflect here

* ok

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-31 21:52:50 -08:00
3λiȯ+
690346b30b docs: Fix typo in code example for Transpiler.transformSync (#8553)
* Docs: Fix typo in code example for transformSync

* Remove await since transformSync is synchronous

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-31 21:18:57 -08:00
huseeiin
16b7b94aea Update bun.d.ts (#8595)
Add `string | ArrayBuffer` to compressing/uncompression functions
2024-01-31 21:13:12 -08:00
Meghan Denny
fcf0047763 windows: pass ws.test.ts (#8611) 2024-01-31 21:08:19 -08:00
dave caruso
af1a124831 allow linking bins that do not exist. (#8605) 2024-01-31 19:08:50 -08:00
dave caruso
f5754e3c19 add baseline in crash report (#8606) 2024-01-31 18:13:39 -08:00
Joe
4e09f8ef8f Issue-6526 - clarify web docs for the use of .only() (#8600)
* Update writing.md

clarify the use of `.only()`

* Update test.d.ts

Small clarification in JSDoc
2024-01-31 14:12:26 -08:00
Luke Ingalls
1969204fa5 docs: remove outdated callout (#8584)
seems like this is already patched https://github.com/oven-sh/bun/issues/5394
2024-01-31 00:08:26 -08:00
dave caruso
2d9db9b28f fix napi-rs libraries on windows (#8583)
* yay

* a

* ok

* typo

* un-CRLFify these files
2024-01-30 20:21:52 -08:00
dave caruso
0333c7b0bf Fix "__dirname" on windows (#8579) 2024-01-30 16:17:32 -08:00
Dylan Conway
82829c5925 fix crash 2024-01-30 13:44:00 -08:00
dave caruso
8fdb46cb91 ok 2024-01-30 10:04:06 -08:00
vinnichase
0aba51230c dx: create symlink on every execution (#8568)
Symlink is not created on first setup.
2024-01-30 09:41:18 -08:00
Dylan Conway
ca801a35fe fix(windows): fix win32 errors (#8569)
* translate eexist

* use SystemErrno translation

* update
2024-01-30 06:49:59 -08:00
vinnichase
692fb220a4 Update launch.json to use ${workspaceFolder}/build/bun-debug (#8570) 2024-01-29 22:38:43 -08:00
dave caruso
cf1c849e4a fix(windows): more reliable extracting (#8567)
* finally

* a

* Update src/install/extract_tarball.zig

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>

* fix compilation

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-29 20:03:02 -08:00
Jarred Sumner
2eede4f435 Fixes #8555 (#8566)
* Fixes #8555

* Make this closer to what npm does

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-29 17:52:08 -08:00
dave caruso
4989ef88b8 docs: mark PerformanceEntry and friends as implemented (#8466)
* docs: mark PerformanceEntry and friends as implemented

* Update docs/runtime/nodejs-apis.md

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-29 15:49:06 -08:00
Jarred Sumner
9fa26e6a09 Close more file descriptors in bun --watch (#8533)
* Close more file descriptors in `bun --watch`

* Reset signals

* Add comment

* Update bun.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-29 15:48:26 -08:00
Jarred Sumner
413aaaff33 [bun:sqlite] Support multiple statements in db.run() (#8541)
* [bun:sqlite] Support multiple statements in db.run()

* Update sqlite.test.js

* Update JSSQLStatement.cpp

* Another test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-29 15:17:51 -08:00
Dylan Conway
c538bf87d1 fix(windows): transpiler cache and other test fixes (#8471)
* umask

* process args

* update reportError.test.ts

* file exists

* transpiler cache

* back to const

* remove failing comments

* [autofix.ci] apply automated fixes

* update comment

* debug assert and remmove branch

* oops

* escape

* path sep

* seekTo

* disable

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-29 15:17:23 -08:00
dave caruso
1e9b44adda internal: report all failing tests to our internal feed (#8563)
* yeah

* oop

* yeahh
2024-01-29 15:17:14 -08:00
dave caruso
3046b0ee39 feat(windows): allow open and Bun.file() with /dev/null (#8499)
* DEV NULL

* oops

* ok
2024-01-29 11:08:09 -08:00
dave caruso
01d41838c5 fix(builtin-bundler): do not replace globals when extending classes (#8557)
* fix(builtin-bundler): do not replace globals when extending classes

* format
2024-01-29 11:07:39 -08:00
dave caruso
bc7e7027e4 windows: some random things (#8521)
* swaggin

* fix(bun_shim_impl): support exe names that are shorter than four characters

* hi

* a
2024-01-29 10:50:24 -08:00
João V. Farias
eaea6dea54 chore(build): adjust arch/manjaro linux auto detect to include artix (#8510) 2024-01-29 09:41:58 -08:00
Jarred Sumner
d0b759f784 Remove references to bun-types 2024-01-29 08:10:14 -08:00
Dale Seo
dbfc62e288 docs: include .jsx (#8542) 2024-01-28 10:00:54 -08:00
Yahya Jirari
34ae040d95 docs: remove unnecessary await in lines() example (#8537) 2024-01-28 06:36:29 -08:00
Ben Limmer
3caa846988 docs: expect.extend is implemented (#8525) 2024-01-27 20:39:46 -08:00
Dylan Conway
5a0ae3c256 not on windows 2024-01-27 07:32:06 -08:00
Dylan Conway
568f87eb8f fix(windows): bun link, unlink, and fix tests in test/cli/install (#8517)
* link and unlink

* valid git dependency cache path

* windows global link

* not git

* update some tests

* update more tests

* update

* update log

* fix snapshots

* more tests

* fix bun pm ls

* make it possible to delete cache dir

* normalize

* fix bun-create tests

* update bun-remove tests

* silent

* bun-run update

* update more tests

* update more

* update

* [autofix.ci] apply automated fixes

* update simdutf for getFdPath

* update test

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-27 04:22:04 -08:00
dave caruso
968c21d80a feat(windows): support bun build --compile (#8503)
* alright

* were winning

* WAOOOOOO
2024-01-26 20:56:08 -08:00
dave caruso
6faeef6dc2 Workaround https://github.com/microsoft/terminal/issues/16606 (#8506)
Fixes #8504
2024-01-26 20:55:48 -08:00
Georgijs
08c9511acc [windows] nodefs (#8509)
* 100 passing fs tests

* 111 fs tests passing

* 114 passing fs tests

* 115 passing (TODO: fix path normalization for windows ntCreateFile

* all fs tests passing

* [autofix.ci] apply automated fixes

* make windows path norm smarter, fix tests

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-26 20:07:33 -08:00
Meghan Denny
1644f341f9 windows: setInterval.test.js is passing now (#8508) 2024-01-26 14:11:03 -08:00
nullun
17fc1e7be1 chore: Remove trailing whitespace (#8502) 2024-01-26 07:25:45 -08:00
Jarred Sumner
7492b3a203 [windows] Remove no longer failing tests from being marked as failing 2024-01-25 21:59:11 -08:00
Jarred Sumner
681baedab2 Track hasInstallScript and libc in NPM registry api (#8495)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-25 20:38:20 -08:00
Jarred Sumner
c7c3ae381b Make this test less flaky on Windows 2024-01-25 20:37:41 -08:00
Jarred Sumner
7543da0bb3 Always normalize the carriage returns in the bundler tests 2024-01-25 20:27:58 -08:00
dave caruso
83ac4f0c33 windows: fix bun plugin (#8485)
* plugins work now

* real

* Update src/js/builtins/BundlerPlugin.ts

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-25 19:34:51 -08:00
Jarred Sumner
3c42dfd42b [internal] Tweak jsonc formatting 2024-01-25 19:19:32 -08:00
Jarred Sumner
e3188c918a use Biome to format Bun's codebase instead of Prettier (#8494)
* Ignore

* Create biome.json

* Ignore

* biome

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-25 19:15:26 -08:00
Jarred Sumner
045672cf67 Force \n instead of \r\n on Windows CI 2024-01-25 19:05:47 -08:00
Dale Seo
345ed18454 fix: mock() should work with no arguments (#8492) 2024-01-25 17:06:36 -08:00
Jarred Sumner
5462ca01fd Typo 2024-01-25 16:33:07 -08:00
Jarred Sumner
4bfd8a8cef Make this test less flaky on Windows 2024-01-25 16:30:25 -08:00
Jarred Sumner
a2a12b5802 Make this test less flaky on Windows 2024-01-25 15:09:32 -08:00
Jarred Sumner
b6c1dc1fa8 Use native AbortController & AbortSignal when abort-controller is loaded (#8489)
* Nationalize `abort-controller`

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-25 15:01:29 -08:00
Jarred Sumner
f4f8bb377a Make this test less flaky on Windows 2024-01-25 14:53:20 -08:00
Jarred Sumner
5c21695db6 Bump + ci autofix (#8490)
* Bump

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-25 13:58:59 -08:00
Adam Dimitry Enzo Ambrosino
2c16b204ff Fix type definition for Array.fromAsync (#8486) 2024-01-25 10:32:47 -07:00
dave caruso
20f7fd5b08 fix(windows): do not use GetTempPath2W (#8477) 2024-01-25 08:13:36 -08:00
dave caruso
c9a7d24538 windows(install): add bun_shim (support bin linking, bin shebangs, etc) (#8265)
* shim v1 TODO

* fix BunXShimData

* wip

* put a little bit of the sa u c e on it

* wow

* wat

* a

* swag

* swag

* allllllllllllright

* Update src/install/bin.zig

Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>

* [autofix.ci] apply automated fixes

* swag

* swag

* finis

* fix submodules

* ok

* omg it works again

* silly

* ok

* OK

* update laucnh jsn

* swaaaaaaaaaaaaag

* remove debug

---------

Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-25 07:38:55 -08:00
Jarred Sumner
108cae5189 Disable dead code elimination when code coverage is enabled (#8473)
This should hopefully make source mappings more accurate

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-25 05:31:44 -08:00
dave caruso
358be9e727 docs: update the windows build documentation and list it on the docs site 2024-01-25 04:15:41 -08:00
Jarred Sumner
2a6388d50b Silence log when ENOTCONN
When using sendfile() to stream, if the user aborted the request it may appear as `ENOTCONN`, which we were logging to the terminal. We really shouldn't be logging anything here, but it's a little unclear what kind of error to emit. It's not a fatal error.
2024-01-25 01:03:29 -08:00
Jarred Sumner
aa901a22c2 Update types.zig 2024-01-24 23:11:58 -08:00
Jarred Sumner
562495b878 [windows] Mark as known failing 2024-01-24 23:11:55 -08:00
Jarred Sumner
875728da83 [windows] Make more things panic 2024-01-24 22:47:40 -08:00
Jarred Sumner
47e7e004b1 Remove @known-failing-on-windows for tests which are no longer failing on windows 2024-01-24 21:03:32 -08:00
Georgijs
80bd3254cc fix argv parsing on windows (#8458)
* fix argv parsing on windows

* directly use zig stdlib

* remove debug comments, fix double deinit

* change bun.argv() to return slices, not null-terminated pointers

* fix test on windows to escape file paths correctly

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-24 20:54:01 -08:00
Jonathan Deiss
0bf8a25d50 Clarifies bun shebang in bunx documentation (#8437)
* Update bunx.md

* better phrasing of shebang
2024-01-24 19:59:56 -08:00
Meghan Denny
effb8f189b windows: fix some websocket tests (#8433)
* windows: fix some websocket tests

* this file should work now, report any errors

* make this change later

* add back running this with node

* add as const to these

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-24 19:40:59 -08:00
Johann
7eeefc1497 chore(password): fix sha256 typo (#8461) 2024-01-24 19:27:29 -08:00
Georgijs
025a5ba140 fix sys.dup on windows and make console-iterator work (#8463)
* fix sys.dup on windows and make console-iterator work

* fix(windows): fix console async iterator to not include the \r

* fix kill on windows again. and report the right errno

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-01-24 19:25:45 -08:00
Ashcon Partovi
885d705d55 Fix bun-types version being incorrect 2024-01-24 15:21:10 -07:00
dave caruso
3447bc2ed3 fixy 2024-01-24 03:16:23 -08:00
Jarred Sumner
f1f861fd74 [windows] Fix panic in server 2024-01-24 02:20:29 -08:00
dave caruso
58ba802ca6 ci(windows): install the profile build 2024-01-24 02:12:16 -08:00
Zachary Huang
73f3b92dc9 fix(ci): fix MacOS build when OpenSSL is also installed (#7759)
Co-authored-by: dave caruso <me@paperdave.net>
2024-01-24 01:44:04 -08:00
dave caruso
eeb10f3f7d fix(windows): fix node:url pathFromFileURL and fileURLFromPath and file url tests (#8442)
* yay for file urls

* swag

* oops

* merge conf

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-24 01:19:47 -08:00
dave caruso
8544f8ae68 ci(windows): debug info in the binaries + ship a version on github (#8443)
* debug info yaaaaaaaaaaaaaaaaaay

* fix the build
2024-01-24 01:16:17 -08:00
Jarred Sumner
9f5ce53544 Normalize another newline 2024-01-23 23:44:38 -08:00
Jarred Sumner
82b6a42a3c Normalize more paths 2024-01-23 20:48:48 -08:00
Jarred Sumner
0974479655 Normalize slashes 2024-01-23 20:47:37 -08:00
Jarred Sumner
918e1878a5 Normalize newlines 2024-01-23 20:45:37 -08:00
Jarred Sumner
17deafd05f Add TypeScript issue template 2024-01-23 20:39:08 -08:00
Dylan Conway
b7ae984ca1 fix(windows): update some bundler tests (#8440)
* replace invalid path character

* windows paths
2024-01-23 20:23:01 -08:00
Jarred Sumner
e848c3f226 Get Bun.write tests to pass on Windows and bun:sqlite tests to pass (#8393)
* Move ReadFile and WriteFile to separate file

* Use libuv for Bun.write()

* Update windows_event_loop.zig

* build

* Get bun-write tests to pass. Implement Bun.write with two files.

* UPdate

* Update

* Update failing test list

* update

* More

* More

* More

* More

* Mark the rest

* ok

* oops

* Update bun-write.test.js

* Update blob.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Dave Caruso <me@paperdave.net>
Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
2024-01-23 20:03:56 -08:00
Dylan Conway
cd3de9c788 fix(windows): fix text-decoder.test.js (#8436)
* use with_errors

* remove comment

* use correct index
2024-01-23 19:28:54 -08:00
dave caruso
945ad77bce window: fix runtime.js build process (#8438)
Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
2024-01-23 19:27:57 -08:00
Chen Yufei
04a99deb0e copy_file: ioctl_ficlone EACCES, EPERM as not supported. (#8425)
ioctl_ficlone may return EPERM (in LXC container), EACCESS (in Android).
Those error should be taken as ficlone being not supported instead of
error.

Refer to this coreutils bug report https://bugs.gnu.org/62404
2024-01-23 18:24:54 -08:00
Ciro Spaciari
cff5dc0ee8 fix close on spawn and watch (#8426)
* fix close on spawn and watch

* add check closed, and fixes

* fix subprocess close
2024-01-23 18:09:13 -08:00
Dylan Conway
77ccf77e35 Revert "Revert "fix(windows): a bunch of install test fixes"" (#8431)
* keep cache dir path, use correct buffer

* make it work more better

* more working

* more fix

* more update

* more fix

* fix test

* update

* fix

* update pointers

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-01-23 18:00:18 -08:00
DidaS
864a726249 Improve bun-types (#8195) 2024-01-23 13:51:45 -07:00
Jarred Sumner
1407683f95 Revert "fix(windows): a bunch of install test fixes" (#8408) 2024-01-23 06:38:13 -08:00
dave caruso
1f928e9b6e goddamn (#8405) 2024-01-23 06:37:14 -08:00
Dylan Conway
e0cf77c660 fix(windows): a bunch of install test fixes (#8402)
* keep cache dir path, use correct buffer

* make it work more better

* more working

* more fix

* more update

* more fix

* fix test

* update tests

* comment and fix test

* one more fix

* fix build

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-01-23 06:36:53 -08:00
dave caruso
07a685bd3d feat(windows): implement the rest of node:os (#8399)
* feat(windows): implement os.networkInterfaces

* we are cooking (os tests almost pass)

* os

* fix version struct

* oops

* [autofix.ci] apply automated fixes

* fix the submodules

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-23 05:06:51 -08:00
dave caruso
80ad8d57f2 windows: fix a path resolution case (#8392)
* fix resolving certain filepaths

* extra

* swag

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-22 21:53:34 -08:00
Jarred Sumner
41b45599c6 Delete some dead code (#8391)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-22 21:06:13 -08:00
Ciro Spaciari
416e896c63 [windows] Implement fs.watch on Windows (#8379)
* implement fs watch

* fix unref

* fixes

* actually use bun.New

* fix destroy, use another buffer for joinPath, remove Win prefix

* oopsie
2024-01-22 20:29:46 -08:00
Dylan Conway
2d1e0dc240 trim correctly (#8388)
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-22 19:57:20 -08:00
Meghan Denny
c52e7c57d2 add another launch config for windows bun test (#8389) 2024-01-22 19:45:39 -08:00
Georgijs
c4a60f9059 fix to enqueue bundler tasks in correct event loop (#8386)
* fix to enqueue bundler tasks in correct event loop

* fix posix build

---------

Co-authored-by: Georgijs Vilums <georgijs@bun.sh>
2024-01-22 19:45:24 -08:00
Dale Seo
15fe30ac41 docs: remove unncessary use of async in bun test examples (#8341) 2024-01-22 17:57:02 -08:00
Dale Seo
a014f1c566 docs: correct imports (#8380) 2024-01-22 17:14:55 -08:00
Jarred Sumner
73b0b35a42 Make the dev-server test more reliable 2024-01-22 17:09:47 -08:00
Georgijs
75524d0ae3 Fix eqlComptimeCheckLenWithKnownType (#8377)
* fix some env tests

* fix and simplify comptime string equality

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-22 16:41:30 -08:00
John-David Dalton
c21dc25a65 Change type for expect().toThrow(unknown) (#8373) 2024-01-22 13:27:25 -07:00
Georgijs Vilums
3bc0f90a7c skip invalid stringWidth test 2024-01-22 12:25:49 -08:00
Jarred Sumner
eaa1cd5553 Add shell-spawn microbenchmark 2024-01-22 03:23:47 -08:00
Jarred Sumner
6019665d4b Fixes #8276 (#8346)
* Fixes #8276

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-21 20:25:00 -08:00
Jarred Sumner
b7b0e28b10 Rename bun.zig to BunObject.zig (#8344)
* Rename `bun.zig` to `BunObject.zig`

* Rename `bun.classes.ts` to `BunObject.classes.ts`

* Update references to `bun.zig`

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-21 19:55:24 -08:00
moznion
c577c64aa7 docs: add description how to parse the CLI ARGV by the built-in parseArg (#8345)
Signed-off-by: moznion <moznion@mail.moznion.net>
2024-01-21 19:54:49 -08:00
Jarred Sumner
1560a866fe Skip stringWidth tests for now 2024-01-21 19:25:57 -08:00
Dale Seo
5b9e1e5708 docs: fix a typo (#8338) 2024-01-21 17:17:55 -08:00
Jarred Sumner
353f724a9c Update bun.d.ts 2024-01-21 06:11:49 -08:00
Jarred Sumner
a8ff7be642 Disable Bun.stringWidth until failing test case passes 2024-01-21 06:10:07 -08:00
Jarred Sumner
af67ee77a0 Bump 2024-01-21 04:48:55 -08:00
Jarred Sumner
b82656d9fc Introduce Bun.stringWidth (#8327)
* Introduce `Bun.stringWidth`

* [autofix.ci] apply automated fixes

* Update utils.md

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-21 04:47:36 -08:00
Jarred Sumner
7b9201a0fc Fixup 2024-01-21 04:23:18 -08:00
Jarred Sumner
627d60c6c7 Fix crash in fs.readFile
We were default-initializing the vm pointer to undefined
2024-01-21 04:19:33 -08:00
Jarred Sumner
c00f0787f0 [types][bun:sqlite] Make SQLiteError a class instead of an interface 2024-01-21 03:57:38 -08:00
Jarred Sumner
3ca0fcb67a [node:vm] Add missing createScript function 2024-01-21 03:57:17 -08:00
Jarred Sumner
43107f48fa Add onLongTimeout callback for WebSocket (#8323)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-21 03:49:28 -08:00
Dylan Conway
b1273e53d8 windows(install): fix linking workspaces and file: dependencies (#8289)
* install workspaces with junctions

* fix #8272

* symlink auto type

* fix file: dependencies

* a better fix

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-20 23:00:29 -08:00
Jarred Sumner
10e57fdc1e windows pipes (#8230)
* spawn sync investigation, pipe closed before uv_read_start is called

* oopsie

* win rusage

* oopsie

* Fix some things

* readable stream now works without FIFO like solution

* blob, ArrayBuffer, Buffer stdin now works

* remove unused

* add UVStreamSink

* update headers.j

* more bindings

* now works yay

* fix rusage on windows

* oops

* fix rare data

* win getUserName

* [autofix.ci] apply automated fixes

* fix build

* oopsie

* fix linux/macos

* exit code fix

* fix kill for win

* disable Bun__crashReportDumpStackTrace on Windows

* remove windows stack dump in report.zig and increase windows test timeout

* condition instead of assertion

* remove IPC again

* fix blob writer when not using TTY

* bump windows tests time again

* bump time again so we see how much we need (this is probably too much)

---------

Co-authored-by: cirospaciari <ciro.spaciai@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
2024-01-20 22:58:01 -08:00
Bjön Limell
fad3db84f0 (docs) Fixed color in node compat (#8299)
`node:module` was green, when it should be yellow.
2024-01-20 22:54:30 -08:00
Dylan Conway
fccab2f0da fix(node:child_process): fix crash with ipc (#8319)
* make sure `onLongTimeout` doesn't happen

* add `onLongTimeout` handler
2024-01-20 22:53:16 -08:00
Dylan Conway
885f9372f4 fix(transpiler): loose equality folding bugfix (#8317)
* fix #8311

* fix `bigint` comparison

* cleanup

* couple tests

* fix `"-0" == 0`

* Update transpiler.test.js

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-20 22:52:53 -08:00
Hanaasagi
509a2c5a69 fix: fix the invalid free pointer in toStringWithBytes. (#8322)
Close: #8264
2024-01-20 22:26:58 -08:00
Meghan Denny
b433beb016 8096 isnt 8kb, 8192 is (#8296)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-19 23:16:11 -08:00
Dylan Conway
c71bad205c Update shell.md 2024-01-19 22:15:23 -08:00
Dylan Conway
d4794bbac8 Update shell.md 2024-01-19 20:05:22 -08:00
Dylan Conway
6fa35839c3 remove .only, update shell.md 2024-01-19 19:59:06 -08:00
Jarred Sumner
35d551c174 Fix passing undefined to $().cwd() and $().env() 2024-01-19 19:55:26 -08:00
Jarred Sumner
4674ee16a1 Simplify $.escape 2024-01-19 19:55:26 -08:00
Jarred Sumner
ce2ef65122 Small docs tweaks for shell 2024-01-19 19:55:26 -08:00
Dylan Conway
0d88dcb0fa Update shell.md 2024-01-19 19:21:26 -08:00
Jarred Sumner
15f727dc2f Update shell.md 2024-01-19 19:05:54 -08:00
Jarred Sumner
dcfec52b11 Update nav.ts 2024-01-19 18:55:29 -08:00
Meghan Denny
7ca4ca8972 copy_file: this TODO is no longer a compiler bug (#8294)
* copy_file: this TODO is no longer a compiler bug

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-19 18:45:59 -08:00
Dylan Conway
76ed8d8086 fix(install): remove invalid bin symlinks (#8293)
* handle invalid bin symlink

* test
2024-01-19 18:37:03 -08:00
Jarred Sumner
1f126cd91a Fix benchmark in node 2024-01-19 18:36:00 -08:00
Jarred Sumner
5e520884cd Add to docs 2024-01-19 18:35:46 -08:00
Max Milton
1c5b318207 feat: Carry over node isIPv4/isIPv6 performance improvements (#8271)
Copy over the `isIPv4`/`isIPv6` performance improvements from
<https://github.com/nodejs/node/pull/49568>.
2024-01-19 17:31:52 -08:00
Zack Radisic
1b1760a9c9 feat: Bun shell (#7748)
* bring in shell impl

* add `$` to global bun scope

* Expose shell parse func on debug mode

* Expose lex tokens and add tests

* refactor parser to have better ast

* assigns and export

* pipeline kinda working

* Decouple Subprocess spawning code from JS stuff

* Subprocess works!

* Conditional execution

* Support JS objects in template expression

* More complete redirection

* Properly drain stdin/stdout/stderr and fix crash from deallocating JSC memory

* Return errors in parser

* Support command substitution

* wip brace expansion stuff

* Rearrange some files

* expansion wip

* Brace expansion working

* wip brace expansion

* refactor brace algorithm

* wip brace expansion on shell

* fix brace expansion

* Working nested brace expansion!

* brace expansion in shell variable assignment only set the last expanded

* stuff

* Small little perf things

* benchmark and test and stuff

* stuff

* fix nested braces but its also kinda broken

* attempt to fix complicated nested braces

* test

* Use fast tokenized algorithm for non nested braces, use parsed algorithm for nested braces

* fix nested braces one and for all

* small stuff

* Not sure if that made a difference

* revert that

* good speed optimization

* rip

* Environment variables, builtin/native shell cmds

* Fix tests

* Support `cd`, `pwd`, add boilerplate for glob expansion

* Support `which`

* Support `rm`

* wip

* wip

* escaping and abstract shell char iterator

* strpool unicode

* Brace expansion support unicode, disallow invalid surrogates in shell script

* shell choose ascii or unicode lexer depending on input

* fix bugs write tests

* kinda start async stuff

* HOLY SHIT big refactor of Subprocess

woops forget to commit this

...and this

* HOLY MOLY it works

* Refactor some stuff, start eval word expansion

* interpret all the nodes

* stuff

* stuff

* stuff

* kind of works but doesnt

* Buffered output works

* no need to heap allocate autosizer

* Fix bug

* Fix some stuff

* unprotect

* move out dummy shell thing

* Bring back assignments

* create expansion state so it can be non blocking for expansions that need IO (glob, cmd subst)

* glob back in action

* Setup builtin non blocking IO commands and implement export

big issue is control flow is really fcked up here need to fix that

* make Cmd state machine use a loop so control flow is a bit more clear

* rename stuff

* move that

* Implement the echo builtin again

* implement cd again but non blocking io

* Fix ls and use proper write function to prevent blockign writes

* Implement which

* holy moly big port std.fs.deleteTree

* fix compile errors

* Okay that works

* rm works thatsnice

* damn

* split it out

* rm async implementation

* fix rm bug for nested

* Work on files as well

* prevent root from being deleted

* rm error handling

* oops

* pwd and fix some script exec bug

* Implement `mv`

* stub out mv to work accross filesystems

* move it around

* woops

* boilerplate for ls and options

* more boilerplate

* stuff

* that got lost in merge

* upgrade shell stuff zig 0.12.0-dev.1828+225fe6ddb

* Implement basic ls

* smol cleanup

* Fix stream, response redirect stdin

* No longer need spawn to be abstract

* Custom promise

* move around some stuff

* shell promise returns shell output

* make tht work for builtins

* refactor IO abstractions to work with JS or mini event loop

* woops

* scaffolding for refactor

* refactor builtins to make event loop refactor easier

* Fix parsing edge case on assignments, fix expansion on cmd assignments

* change subproc to work with any event loop

* Finish refactoring subproc

* move global abstraction out

* big refactor boys

* holy moly: integrate into cli and fix allll the compile errors

* okay works in bun run now

* actually tick the event loop lol

* Fix more stuff

* Support comments

* Fix some tests

* delete that

* Properly report errors when failing to spawn command

* fix a whole bunch of tests

* fix a whole bunch of tests again

* .

* Fix rm

* Fix some exit code bugs, write force rm from deno, fix ls stderr

* fix `rm -d`

* fix `rm -d`

* Fix boolean logic

* error on subshells (e.g. `true && (echo hi && echo lol)`)

* Move out shell state from interpreter struct

* Cmd substitution supports arbitrary script, not just a single cmd

* Some escaping/quotation tests

* Fix stuff add more tests:

- cmd substitution quotations
- escape backticks in single quots

* ALOT of stuff:

- fix proper subshell inheritance of env for cmd subst
- fix: was wrong, assignments don't run in subshell in conditionals
- fix lexing chained vars `$VAR$VAR`
- more tests

* Fix subtle bugs

* Fix crazy redirect to arraybuffer bug

* more crazy echo edgecases

* Proper lexer errors instead of just panicking lol

* yoops

* Proper parsing errors

* Errors for bun run shell script

* Fix redirecting to file

* More test fix bugs yay

* Fix redirect on builtins

* Open redirection fds with O_TRUNC

* Fix lexing invalid variables and add ability to change cwd from JS api

* yoops

* Fix `.cwd()`

* `$PWD` and fix redirection bugs

* `$PWD` and fix redirection bugs

* Get rid of  some `FIXME`s

* throw errors in some places instead of panicking

* Print some errors to stderr

* Get rid of some more panics again

* Handle errors on glob

* pwd test

* `.env()`

* copy-on-write abstraction

* Reference counted env strings + fix some tests

* deinit cwd

* Put commands into a pipeline properly

* deinit Expansion and Assigns properly

* comments

* Comments

* Make it compile

* Update types

* [autofix.ci] apply automated fixes

* Only one WaiterThread

* Fix lifetimes and clean up interface

* Update shell.ts

* Add lazy test

* Remove some dead code

* Update shell.zig

* Fix memory leak

* Fix crash with empty braces

* [autofix.ci] apply automated fixes

* Linux build + bun.sh

* Update subproc.zig

* Update interpreter.zig

* Update interpreter.zig

* Fix some stuff that broke

* Fix Windows compile errors

* Fix some fd leaks

* Fix ls

* Fix a bunch of stuff

* Fix quiet

* Update leak tests fix rm bug

* More reproducible tests

* [autofix.ci] apply automated fixes

* more mem leak tests

* [autofix.ci] apply automated fixes

* Fix merge conflict

* Fix test not actually using temp directory

* Update bunshell.test.ts

* Shell instance

* Capture async context

* Increase test timeouts

* [autofix.ci] apply automated fixes

* Escape

* [autofix.ci] apply automated fixes

* Fix crash

* Add more methods

* [autofix.ci] apply automated fixes

* Fix leak

* Treat file(path) blobs as a file path string

* Create bunshell-file.test.ts

* Support Blob input

* Fix leak + organize imports

* doc

* Update shell.md

* Update shell.md

* Update shell.md

* Update shell.md

* Update CMakeLists.txt

* Fix segfault by cloning error path so it's not freed by arena

* deinit ShellErr

* Delete dead code

* fix really stupid segfault

* don't deinit shell ls task in event loop

* Fix ls bug

* Fix tests

* make truly lazy

* allow more things in the shell substitution and escape whitespace

* Fix newline and exit when finishing shell in `bun run`

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-19 17:30:57 -08:00
Lukas Kastern
751ff68268 feat: Add async support to Bun.serve onError (#8233)
* WIP

* Support not immediately fullfilled promises

* Typo

* Add tests

* Fix test

* Rename test

* Remove file

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-19 16:01:09 -03:00
Jarred Sumner
3c785c88fb Fix issue with perf_hooks in canary (#8279)
* Update perf_hooks.ts

* Update perf_hooks.test.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-19 05:22:06 -08:00
Dylan Conway
8efa01bd62 fix(bun:test): toContain and toContainEqual string fix (#8270)
* update toContain, toContainEqual, and tests

* fix build, use cursor

* `strings.indexOf` and `jsType` once
2024-01-18 20:13:57 -08:00
Ashcon Partovi
e17709a2d3 Fix bun --inspect with fully-qualified URL (#8267) 2024-01-18 18:32:51 -08:00
Alexandre Seo
c50400e186 Fix bug in string handling in toContain and return undefined in all matchers (#7692)
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
2024-01-18 14:14:16 -08:00
guest271314
ff965af067 Update comment to include "except a built-in" (#8251)
build.module() throws for "buffer"

 9 |   setup(build) {
10 |     build.module(
         ^
error: module() cannot be used to override builtin module "buffer"
2024-01-18 03:29:10 -08:00
Jarred Sumner
48d642e9e0 Add a note about timeouts and max payload size 2024-01-18 03:14:03 -08:00
Jarred Sumner
e197b7c3a0 Fix crash in socket (#8241)
* Fix crash in socket

* Fix Socket timeout issue

* Add test for socket timeout

* Update socket.test.ts

* Fix linux tests

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-18 02:19:58 -08:00
Jarred Sumner
95e466628b Add a note about reading directories 2024-01-17 22:16:34 -08:00
dave caruso
41dda11802 fix: upgrade_command compilation error 2024-01-17 22:08:02 -08:00
dave caruso
8ba332b43a fix(windows): Implement bun.sys.renameat on Windows and fix crash during bun upgrade (#8242)
* fix #7989

* doc

* oops
2024-01-17 22:01:53 -08:00
Michael H
52894121ea bun run: "package.json scripts" at bottom (#8224)
* `bun run`: put "package.json" scripts at bottom & better errors

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-17 18:18:40 -08:00
Jarred Sumner
a5e83189df Stub more of perf_hooks (#8239)
* Stub more of perf_hooks

* Update perf_hooks.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-17 17:41:47 -08:00
dave caruso
405e2d1517 windows: implement os.hostname (#8223)
* windows: implement os.hostname

* oops

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-17 17:33:02 -08:00
Meghan Denny
483b73c4bf absorb bun.fdcast into FileDescriptor and remove (#8240) 2024-01-17 17:32:03 -08:00
Cena Kopahi
cb97baed22 Update docs for @types/bun (#8160)
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
2024-01-16 23:26:50 -07:00
Jarred Sumner
01df0e6ef0 Fix prettier 2024-01-16 20:20:30 -08:00
dave caruso
08aa40c570 fix windows CI (use -MD again) (#8220)
* chore: upgrade webkit again

* fix submodules
2024-01-16 19:26:32 -08:00
dave caruso
82fcb38005 fix(windows): support utf16-le files in the bundler and in Bun.file (#8219)
* support utf16-le files

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-16 17:15:16 -08:00
Jarred Sumner
fc80683256 In fs.ReadStream, use $isObject to check options (#8218)
* In fs.ReadStream, use `$isObject` to check if function or object rather than typeof options === "object"

* Update fs.js

* Add test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-16 16:41:24 -08:00
Jarred Sumner
54be1d7705 Fix decimal -> integer conversion bug in process.exit & process.exitCode (#8216)
* Fix process.exit to allow numbers which were previously decimals

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-16 16:19:33 -08:00
Emre Cakiroglu
7eed9d893e fix: handle encoding deconstruction in node:fs (#8212) 2024-01-16 15:56:02 -08:00
Yusup Hambali
e77f9036e0 Fix title in dataview-to-string guide (#8209) 2024-01-16 15:27:38 -08:00
Lukas Kastern
5a6ef045aa fix: Hang when recursively logging via ConsoleObject.messageWithTypeAndLevel (#8213)
* Avoid deadlock in messageWithTypeAndLevel by adding a recursion counter

* Add test for recursive logs

* Do not rely on output of console-recursive.test.js

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-16 15:26:23 -08:00
Aarav Juneja
9350f6bc0b fix: match node's path.parse on dotfiles. (#8142)
* Fix #8090

* Fix bug from modification order.
2024-01-16 14:12:18 -08:00
dave caruso
4ccf6fb284 chore: fix building mimalloc debug with valgrind support (#8199)
* fix valgrind mimalloc

* thens
2024-01-16 00:06:10 -08:00
Jarred Sumner
83f2432da6 Update prettier (#8198)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-15 23:47:13 -08:00
Jarred Sumner
f673a84c75 Update nodejs-apis.md 2024-01-15 23:46:12 -08:00
Jarred Sumner
51680dbfdc Update nodejs-apis.md 2024-01-15 23:45:10 -08:00
Jarred Sumner
1aa36e27cb Update nodejs-apis.md 2024-01-15 23:44:09 -08:00
Jarred Sumner
e6285a1cc8 Update nodejs-apis.md 2024-01-15 23:43:52 -08:00
Meghan Denny
a064ae71ad make node:fs/promises.open return a FileHandle and expose fdatasync (#8141)
* make node:fs/promises.open return a FileHandle and expose fdatasync

* node_fs: add fn spacing

* fix this assert usage too

* move primordial preservation higher

* use expect().toBe() instead of assert

* ensure top level node:fs/promises functions always receive fd's as a number

* add needed fixture

* [autofix.ci] apply automated fixes

* this was the wrong fix for a different thing
will look into it later

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-15 23:20:20 -08:00
dave caruso
f9e78c419f feat: Implement using keyword (explicit resource management) (#8151)
* port 'initial support for using declarations'

1:1 port of this commit:

56a3e01244

* port 'initial support for await using declarations'

1:1 port of this commit:
1634a0b5ad

* fix cmake config for local jsc

* add global defines for symbols

* begin porting lowering implementation

based off of
https://github.com/evanw/esbuild/pull/3192

* [autofix.ci] apply automated fixes

* add some fun webkit scripts

* fix the minification bug

* refactor runtime_js, etc

* rename test file

* finished yapping

* silly silyl

* Update src/bundler.zig

* ok

* a

* Fix crash

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-15 23:14:41 -08:00
Jarred Sumner
0fb864e0ca Bump WebKit 2024-01-15 20:28:05 -08:00
Jarred Sumner
a4da0acb0e Document additions to import.meta 2024-01-15 19:53:49 -08:00
Jarred Sumner
f47def8515 Update run_command.zig 2024-01-15 19:50:05 -08:00
Jarred Sumner
14398ae27e Upgrade to Node.js v21.6.0 2024-01-15 19:50:05 -08:00
Jarred Sumner
64d351b102 Upgrade to SQLite v3.45.0 (#8196)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-15 19:45:14 -08:00
Meghan Denny
6b577a3970 implement events.on (#8190)
* exit event loop if there's unhandled errors

* move FixedQueue to a special package

* require(events) is also EventEmitter

* implement events.on

* move fixed_queue to internal and make it lazy in node:events

* use better Promise intrinsics

* move $shared to internal/shared

* make test not dependent on cwd
2024-01-15 18:54:37 -08:00
Lukas Kastern
a159850cce fix: Bun.serve logging error when fetch returns rejected promise (#8169)
* Handle rejected promise returned from onResponse

* Add test

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-15 18:26:08 -08:00
Jarred Sumner
87eedc29d5 Move the standalone executable page 2024-01-15 18:13:28 -08:00
Lukas Kastern
124392ee98 fix: Report error and close event when creating WebSocket fails (#8186)
* Defer websocket error/close when websocket client is null

* Rename test

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-15 18:08:34 -08:00
Jarred Sumner
e5421c56b1 feat: Support import db from './my.db' with {type: "sqlite"} (#8178)
* Support SQLite imports

* Docs

* Update executables.md

* Update loaders.md

* Update js_parser.zig

* Update loaders.md

* Update CMakeLists.txt

* Update Module.ts

* JSC got rid of `$trunc`?

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-15 17:56:02 -08:00
Lukas Kastern
407f42718c Only integrate loop us_loop once (#8187) 2024-01-15 17:37:21 -08:00
Jarred Sumner
a36355cefb Some Windows tweaks (#8118)
* Some windows tweaks

* Make this pub

* Update bundle_v2.zig

* Fix woopsie

* Make this error better

* Add assertion for using allocator for HTTP client from another thread.

* Do fewer copies in readdir()

* Fix crash/failing tests

* Update tests

* Fix windows build

* Update loop.c

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-15 17:33:33 -08:00
Ashcon Partovi
2d21567271 Update debugger things (#8180)
* T

* Update Debug Adapter Protocol

* Update JSC and V8 debugger protocols

* Update inspector-frontend

* Fix empty keys not being printed in `console.log`

* Add `bun --inspect` tests and fix edge cases

* bun install --exact
2024-01-15 17:00:29 -08:00
Jarred Sumner
611b296a6a Fixes #8170 2024-01-14 21:01:51 -08:00
Jarred Sumner
317998fdd6 Make toBunString increment the reference count (#8146)
* Make `toBunString` increment the reference count

* Fix WASI

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-14 05:36:31 -08:00
Jarred Sumner
ab40b0e054 Fix file descriptor leak in ipc (#8165)
* Fix file descriptor leak in ipc

* Do not assume sequential file descriptors

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-14 02:57:44 -08:00
Jarred Sumner
2c3dc5176b Upgrade uWebSockets & usockets (#8164)
* Upgrade uWebSockets & usockets

* Update HttpRouter.h

* Defensively prevent sending to blocking sockets

* Add test for receiving large amounts of data

* Large data optimization

* Update loop.c

* Avoid extra system call before entering event loop

* Update internal.h

* 1 less pointer lookup

* Fix error

* Update socket-huge-fixture.js

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-14 02:04:30 -08:00
dave caruso
5fc4538477 windows: support bun:ffi (#8114)
* compile tcc

* initial linking

* ffi and stuff

* swag

* wala

* Update settings.json

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-13 19:14:29 -08:00
Meghan Denny
be0896e204 remove while loops where a for would be more efficient (#8131)
* remove while loops where a for would be more efficient

* this needs to be a stack copy

* this can use the better loop

* this was translated wrong

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-13 19:13:54 -08:00
Jarred Sumner
56f1e5a362 Hide some noisy stack frames (#8148)
* Hide some noisy stack frames

* Update javascript.zig

* Add `asyncModuleEvaluation` to the list

* Sort

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-13 19:11:01 -08:00
Jarred Sumner
702da52312 Fix rawMode regression (#8163)
* Fix rawMode regression

* arg0

* Update ProcessBindingTTYWrap.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-13 19:10:33 -08:00
Jarred Sumner
2a8956a268 Use one isosubspace for all generated constructors (#8162)
* Use one Isosubspace for constructors

* Update generate-classes.ts

* Update generate-classes.ts

* Update generate-classes.ts

* Update generate-classes.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-13 18:50:09 -08:00
Jarred Sumner
86b1aa02b3 Update CMakeLists.txt 2024-01-13 00:57:45 -08:00
Meghan Denny
065eae5a95 tidy: use std.mem.zeroes instead of loop or memset (#8138)
* use std.mem.zeroes instead of loop or memset

* Update src/bun.js/api/bun.zig

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-12 23:56:51 -08:00
Meghan Denny
9fa13aec09 fix signalNumberToNameMap assignment for SIGINFO (#8132) 2024-01-12 23:53:35 -08:00
Jarred Sumner
3e703c4c76 For build scripts, symlink zig.exe to zig on posix (#8147)
* Add `zig.exe` as a symlink of `zig` on posix

* Update scripts/download-zig.sh

Co-authored-by: dave caruso <me@paperdave.net>

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
2024-01-12 23:52:07 -08:00
Jarred Sumner
01453be2d1 Move function from a header to a .cpp file 2024-01-12 23:48:14 -08:00
Jarred Sumner
9b32516bcb Implement tty_wrap in process.binding (#8130)
* Implement `tty_wrap` in process.binding

Fixes #4694

* [autofix.ci] apply automated fixes

* Rename some things

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-12 23:31:18 -08:00
Jarred Sumner
7e787d2a5a Move console methods from exports.zig to ConsoleObject.zig (#8145)
* ZigConsoleClient -> ConsoleObject

* Rename more

* Rename more

* ZigConsoleClientFormatter -> ConsoleObject

* More renaming

* Wire up console.profile?

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-12 23:15:36 -08:00
dave caruso
b7a32b87ab fix(bundler): improve external require transpilation on all targets (#8057)
* fix(build): do not emit import.meta.require for browsers/node.js

* update test snapshots

* sweep

* prefer require ref instead of `import.meta.require`

* remove option i did not use

* stuff

* remove rewrite_require_resolve

* ok

* ok

* wooooo

* [autofix.ci] apply automated fixes

* fix bugs

* ok

* [autofix.ci] apply automated fixes

* OOOOOPPPPPPPPPPPPS

* fix Bun.Transpiler regressions

* fix(bundler): make --splitting ensure --outdir

* fix final

* oops

* [autofix.ci] apply automated fixes

* use require.resolve

* revert but ... it no longer crashes there

* ok

* [autofix.ci] apply automated fixes

* fix fetch test

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2024-01-12 22:15:51 -08:00
Meghan Denny
0491ff4186 tidy: remove some redundant bun.toFD calls (#8136)
* remove some redundant bun.toFD calls

* windows fix
2024-01-12 19:46:56 -08:00
Meghan Denny
943c72c8a1 allow StringOrTinyString to hold 31 bytes (#8134) 2024-01-12 19:43:50 -08:00
Meghan Denny
cb6f4b9f4d tidy: remove if(false) dead block (#8129)
* remove if(false) dead block

* remove if (true) {...}

---------

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
2024-01-12 18:18:19 -08:00
Meghan Denny
45bd2264e3 more small undefined fixes (#8133) 2024-01-12 18:17:53 -08:00
Meghan Denny
8733748eb6 remove bun.assertDefined, comparing against undefined is UB (#8137) 2024-01-12 18:16:04 -08:00
Kaio Duarte
66fa317390 fix(node:url): handle url with missing host on url.parse (#8126)
* fix(node:url): handle url with missing host on `url.parse`

* lazy load punycode module

* use URL class

* add comment and also extra sanity check tests

* extra test

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-01-12 18:11:10 -08:00
Dylan Conway
ef0e96a2b2 fix(install): add warning and skip patched packages (#8143)
* add warning and skip patched packages

* also overrides

* comment
2024-01-12 18:03:30 -08:00
Meghan Denny
b0d326dfb9 zig_backend stage1 doesnt exist anymore (#8140) 2024-01-12 17:44:03 -08:00
Meghan Denny
517d5ecde9 remove more big endian handling (#8139) 2024-01-12 17:43:30 -08:00
dave caruso
072f2f15ea ci: run windows tests and also run them concurrently (#7758) 2024-01-12 17:02:20 -08:00
Georgijs
0cd7fa1a63 fix(webkit:performance): correctly track size of measures map (#8128)
Co-authored-by: Georgijs Vilums <georgijs@bun.sh>
2024-01-12 14:58:05 -08:00
Ashcon Partovi
2fe0f90d36 Fix loose comparisons and incorrect tag length in semver (#8108) 2024-01-12 15:31:58 -07:00
Jarred Sumner
0783b4bf0e Implement import.meta.{dirname, filename} for Node.js compatibility (#8127)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-12 14:26:50 -08:00
Kaio Duarte
4f96bc416b fix(bun-install): gracefully handle missing package removal (#8091)
* fix(bun-install): gracefully handle missing package removal

* update bun remove test
2024-01-12 14:08:58 -08:00
hugo-syn
f43ecd8aa2 chore: Fix multiple typos (#8121) 2024-01-12 14:07:40 -08:00
Ashcon Partovi
31db26b054 Fix error when null/undefined is passed to stdio in spawn/spawnSync (#8110)
* Fix error when null/undefined is passed to stdio in spawn/spawnSync

* Change conditional
2024-01-12 14:05:55 -08:00
Aayush
f5675284c7 fix(docs): prisma not installed as dev dependency (#8119) 2024-01-12 03:23:47 -08:00
Dylan Conway
98d253d9bb fix(install): incremental support for windows (#7991)
* update for windows

* use correct sizes

* mode

* fchmod and correct error checking

* some progress

* walker_skippable.zig for windows

* no segfault

* comptime only

* normalize

* create files in .bin

* bun.sys.write

* string formatters in bun.fmt, diriterator enum

* isAllASCII comptime

* update more

* some cleanup

* fix 1

* fix 2

* simlink

* cast

* remove normalize

* to zig err

* update fchmod

* fixup

* fix running bin files

* --bun for running binaries

* --bun for scripts

* remove binary linking

* update

* remove todo

* todos

* fix

* simlink

* cast

* more cast
2024-01-11 22:00:47 -08:00
Meghan Denny
9846383b01 all: make bun.FileDescriptor a unique type (#8022)
* all: make bun.FileDescriptor a unique type

# Conflicts:
#	src/bun.js/api/bun/socket.zig
#	src/bun.js/api/bun/spawn.zig
#	src/deps/uws.zig

* need this change too

* convert another bun.FD.asDir call

* more fixes + linux

* fix this size

* accidentally flipped these fd numbers

* more fixes + windows

# Conflicts:
#	src/deps/uws.zig

* dont include type name in serialization

* add another TODO

* resolve review comments

* address more pr comments

* build fixes post-rebase

* another rebase fix

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-11 19:59:48 -08:00
Dylan Conway
fbe4ed206a More bun install hoisting tests (#8112)
* hoisting tests

* more comments on hoistDependency

* fix test
2024-01-11 16:57:24 -08:00
Erik
15263664b6 fix: #7932 (#8038)
* updating package with child peerDependency doesn't keep old version

* [autofix.ci] apply automated fixes

* fixed TODO test

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-11 16:38:39 -08:00
Ciro Spaciari
4611b84352 incremental(windows) add TransmitFile and some fixes for fetch, h2 and http (#8089)
* fix win header decoding zig issue

* fix libuv file read lifecycle

* upload working without sendfile (yet)

* undo

* oops uncoment expect

* add TransmitFile aka sendfile on windows

* cleanup

* [autofix.ci] apply automated fixes

---------

Co-authored-by: cirospaciari <ciro.spaciai@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-11 16:38:13 -08:00
hugo-syn
922ff08a80 chore: Fix multiple typos (#8105) 2024-01-11 16:37:36 -08:00
Jarred Sumner
4c933f733b Fixes #7001 (#7861)
* Fixes #7001

* One more test

* Use `disturbed`

* [autofix.ci] apply automated fixes

* Fix failing test

* Test is no longer todo!

* Make bodyUsed work too

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-11 16:25:26 -08:00
Ciro Spaciari
f1c3e87a06 incremental(windows) setTimeout, setInterval and setImmediate should work (#8101)
* fix compilation and types for FD option using usockets

* comment

* clarify HOST_MAME_MAX on windows

* use libuv for timers on windows

* [autofix.ci] apply automated fixes

* fix linux build

---------

Co-authored-by: cirospaciari <ciro.spaciai@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-11 15:09:40 -08:00
Jarred Sumner
0bfe3760f6 Remove musl libraries from trusted dependencies because bun doesn't support musl yet 2024-01-10 21:13:20 -08:00
Ashcon Partovi
68bc548dce Fix 'Not a string or buffer' from zlibBufferSync (#8085)
* Fix 'Not a string or buffer' from zlibBufferSync

* Use `Buffer2`
2024-01-10 15:13:53 -08:00
Dylan Conway
7d4cef53a8 construct package paths without getFdPath for lifecycle scripts (#8056)
* use abs paths instead of getFdPath for lifecycle scripts

* fix aliased packages

* oops

* logs

* remove assert
2024-01-09 23:30:41 -08:00
Jarred Sumner
b400b36ca5 Bump! 2024-01-09 15:40:28 -08:00
Hanaasagi
36d4f09d28 fix(socket): fix 0.0.0.0 binding address (#7366)
* fix(socket): fix `0.0.0.0` binding address
Close: #7355

* test

* test

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-01-09 13:48:56 -08:00
Jarred Sumner
e77e1c1a58 perf: 5% - 10% faster new Headers(object) & new URLSearchParams(object) (#8028)
* 5%-10% faster `new Headers(object)`

* Add another test

* Remove extra parentheses

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-09 13:45:45 -08:00
Aarvin R
6e1ef49ad4 fix #8067 plugin fileapis (#8068)
- use Bun.file() instead of readFileSync
2024-01-09 13:00:31 -08:00
Jarred Sumner
2daade39a9 Don't close the file descriptor since close_range will get it anyway 2024-01-09 03:33:58 -08:00
Jarred Sumner
ae78441b25 Fixes #8010 (#8064)
* Don't use posix_spawn on Linux

* Make it work

* Avoid closing inherited file descriptors

* Hopefully fix test failures

* Reset close-on-exec flag

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-09 03:11:31 -08:00
741 changed files with 74823 additions and 29989 deletions

View File

@@ -0,0 +1,45 @@
name: 🇹 TypeScript Type Bug Report
description: Report an issue with TypeScript types
labels: [bug, typescript]
body:
- type: markdown
attributes:
value: |
Thank you for submitting a bug report. It helps make Bun better.
If you need help or support using Bun, and are not reporting a bug, please
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can ask questions in the [`#help`](https://discord.gg/32EtH6p7HN) forum.
Make sure you are running the [latest](https://bun.sh/docs/installation#upgrading) version of Bun.
The bug you are experiencing may already have been fixed.
Please try to include as much information as possible.
- type: input
attributes:
label: What version of Bun is running?
description: Copy the output of `bun --revision`
- type: input
attributes:
label: What platform is your computer?
description: |
For MacOS and Linux: copy the output of `uname -mprs`
For Windows: copy the output of `"$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"` in the PowerShell console
- type: textarea
attributes:
label: What steps can reproduce the bug?
description: Explain the bug and provide a code snippet that can reproduce it.
validations:
required: true
- type: textarea
attributes:
label: What is the expected behavior?
description: If possible, please provide text instead of a screenshot.
- type: textarea
attributes:
label: What do you see instead?
description: If possible, please provide text instead of a screenshot.
- type: textarea
attributes:
label: Additional information
description: Is there anything else you think we should know?

View File

@@ -259,6 +259,8 @@ jobs:
bun install --cwd=test --verbose
bun install --cwd=packages/bun-internal-test --verbose
bun install --cwd=test/js/third_party/prisma --verbose
# This is disabled because the cores are ~5.5gb each
# so it is easy to hit 50gb coredump downloads. Only enable if you need to retrive one

View File

@@ -379,7 +379,8 @@ jobs:
name: macOS Test
runs-on: ${{ matrix.runner }}
needs: [macOS]
if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
# if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
if: false
permissions:
pull-requests: write
timeout-minutes: 30

View File

@@ -111,9 +111,15 @@ jobs:
with:
node-version: latest
- name: Setup Bun
if: ${{ env.BUN_VERSION != 'canary' }}
uses: oven-sh/setup-bun@v1
with:
bun-version: "1.0.21"
- name: Setup Bun
if: ${{ env.BUN_VERSION == 'canary' }}
uses: oven-sh/setup-bun@v1
with:
bun-version: "canary" # Must be 'canary' so tag is correct
- name: Install Dependencies
run: bun install
- name: Setup Tag
@@ -131,14 +137,14 @@ jobs:
if: ${{ env.BUN_VERSION == 'canary' }}
uses: JS-DevTools/npm-publish@v1
with:
package: packages/bun-types/dist/package.json
package: packages/bun-types/package.json
token: ${{ secrets.NPM_TOKEN }}
tag: canary
- name: Release (latest)
if: ${{ env.BUN_LATEST == 'true' }}
uses: JS-DevTools/npm-publish@v1
with:
package: packages/bun-types/dist/package.json
package: packages/bun-types/package.json
token: ${{ secrets.NPM_TOKEN }}
docker:
name: Release to Dockerhub

View File

@@ -1,7 +1,7 @@
name: bun-windows-x64
name: bun-windows
concurrency:
group: bun-windows-x64-${{ github.ref }}
group: bun-windows-${{ github.ref }}
cancel-in-progress: true
env:
@@ -9,7 +9,7 @@ env:
LLVM_VERSION: 16.0.6
BUN_DOWNLOAD_URL_BASE: https://pub-5e11e972747a44bf9aaf9394f185a982.r2.dev/releases/latest
tag: bun-windows-x64
tag: bun-windows
# TODO: wire this up to workflow_dispatch.
# github's expression syntax makes this hard to set a default to true
canary: true
@@ -57,6 +57,7 @@ jobs:
timeout-minutes: 60
if: github.repository_owner == 'oven-sh'
steps:
- run: git config --global core.autocrlf false && git config --global core.eol lf
- uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
@@ -103,7 +104,7 @@ jobs:
- name: Upload Zig Object
uses: actions/upload-artifact@v3
with:
name: ${{ env.tag }}-zig${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-zig${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: ${{runner.temp}}/release/bun-zig.o
windows-dependencies:
@@ -116,6 +117,7 @@ jobs:
cpu: [haswell, nehalem]
arch: [x86_64]
steps:
- run: git config --global core.autocrlf false && git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v4
- name: Clone Submodules
@@ -127,7 +129,8 @@ jobs:
git submodule | Where-Object { $_ -notmatch 'WebKit' }
clang --version
rustc --version
Get-Content -Path (Get-ChildItem -Path 'scripts/build*.sh', 'scripts/all-dependencies.sh' | Sort-Object -Property Name).FullName | Out-String
Get-Content -Path (Get-ChildItem -Path 'scripts/build*.ps1', 'scripts/all-dependencies.ps1', 'scripts/env.ps1' | Sort-Object -Property Name).FullName | Out-String
echo 1
})"
$hash = ( -join ((New-Object -TypeName System.Security.Cryptography.SHA1CryptoServiceProvider).ComputeHash([System.Text.Encoding]::UTF8.GetBytes($data)) | ForEach-Object { $_.ToString("x2") } )).Substring(0, 10)
echo "sha=${hash}" >> $env:GITHUB_OUTPUT
@@ -138,7 +141,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: bun-deps
key: bun-deps-${{ env.tag }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-${{ steps.submodule-versions.outputs.sha }}
key: bun-deps-${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-${{ steps.submodule-versions.outputs.sha }}
- name: Install LLVM ${{ env.LLVM_VERSION }}
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
@@ -164,7 +167,7 @@ jobs:
- name: Upload Dependencies
uses: actions/upload-artifact@v3
with:
name: ${{ env.tag }}-deps${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-deps${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: bun-deps/
- name: Cache Dependencies
@@ -175,11 +178,20 @@ jobs:
path: bun-deps
key: ${{ steps.cache-deps-restore.outputs.cache-primary-key }}
# TODO(@paperdave): stop relying on this and use bun.exe to build itself.
# we cant do that now because there isn't a tagged release to use.
#
# and at the time of writing, the minimum canary required to work is not
# yet released as it is the one *this* commit.
windows-codegen:
name: Codegen
runs-on: ubuntu-latest
timeout-minutes: 10
if: github.repository_owner == 'oven-sh'
strategy:
fail-fast: false
matrix:
arch: [x86_64]
steps:
- uses: actions/checkout@v4
- run: |
@@ -194,7 +206,7 @@ jobs:
echo "canary_revision=$(GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" bash ./scripts/calculate-canary-revision.sh --raw)" > build-codegen-win32-x64/.canary_revision
- uses: actions/upload-artifact@v3
with:
name: ${{ env.tag }}-codegen
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-codegen
path: build-codegen-win32-x64/
windows-cpp:
@@ -209,6 +221,7 @@ jobs:
cpu: [haswell, nehalem]
arch: [x86_64]
steps:
- run: git config --global core.autocrlf false && git config --global core.eol lf
- uses: actions/checkout@v4
- uses: KyleMayes/install-llvm-action@1a3da29f56261a1e1f937ec88f0856a9b8321d7e
with:
@@ -217,7 +230,7 @@ jobs:
- name: Download Codegen
uses: actions/download-artifact@v3
with:
name: ${{ env.tag }}-codegen
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-codegen
path: build
- name: Build C++
run: |
@@ -252,7 +265,7 @@ jobs:
if ($LASTEXITCODE -ne 0) { throw "C++ compilation failed" }
- uses: actions/upload-artifact@v3
with:
name: ${{ env.tag }}-cpp${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-cpp${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: build/bun-cpp-objects.a
windows-link:
@@ -263,11 +276,12 @@ jobs:
arch: [x86_64]
name: Link
needs: [windows-dependencies, windows-codegen, windows-cpp, windows-zig]
runs-on: windows-latest
runs-on: windows-small
if: github.repository_owner == 'oven-sh'
timeout-minutes: 30
permissions: write-all
steps:
- run: git config --global core.autocrlf false && git config --global core.eol lf
- uses: actions/checkout@v4
- uses: KyleMayes/install-llvm-action@1a3da29f56261a1e1f937ec88f0856a9b8321d7e
with:
@@ -276,22 +290,22 @@ jobs:
- name: Download Codegen
uses: actions/download-artifact@v3
with:
name: ${{ env.tag }}-codegen
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-codegen
path: build
- name: Download Dependencies
uses: actions/download-artifact@v3
with:
name: ${{ env.tag }}-deps${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-deps${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: bun-deps
- name: Download Zig Object
uses: actions/download-artifact@v3
with:
name: ${{ env.tag }}-zig${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-zig${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: bun-zig
- name: Download C++ Objects
uses: actions/download-artifact@v3
with:
name: ${{ env.tag }}-cpp${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-cpp${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: bun-cpp
- name: Link
run: |
@@ -313,13 +327,23 @@ jobs:
if ($LASTEXITCODE -ne 0) { throw "Link failed!" }
- name: Package
run: |
$Dist = mkdir -Force "${{ env.tag }}"
$Dist = mkdir -Force "${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}"
cp -r build\bun.exe "$Dist\bun.exe"
Compress-Archive $Dist ${{ env.tag }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}.zip
Compress-Archive "$Dist" "${Dist}.zip"
$Dist = "$Dist-profile"
MkDir -Force "$Dist"
cp -r build\bun.exe "$Dist\bun.exe"
cp -r build\bun.pdb "$Dist\bun.pdb"
Compress-Archive "$Dist" "$Dist.zip"
- uses: actions/upload-artifact@v3
with:
name: ${{ env.tag }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: ${{ env.tag }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}.zip
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}.zip
- uses: actions/upload-artifact@v3
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile
path: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile.zip
- name: Release
id: release
uses: ncipollo/release-action@v1
@@ -336,7 +360,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
name: "Canary (${{github.sha}})"
tag: "canary"
artifacts: "${{env.tag}}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}.zip"
artifacts: "${{env.tag}}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}.zip,${{env.tag}}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile.zip"
- uses: sarisia/actions-status-discord@v1
if: failure() && github.repository_owner == 'oven-sh' && github.event_name == 'pull_request'
with:
@@ -346,13 +370,128 @@ jobs:
noprefix: true
nocontext: true
description: |
Pull Request
### [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}
Build failed on ${{ env.tag }}:
Build failed on Windows ${{ matrix.arch }}${{ matrix.cpu == 'nehalem' && ' Baseline' || '' }}
**[View build output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
**[Build Output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})** | [Commit](https://github.com/oven-sh/bun/commits/${{github.sha}})
windows-test:
name: Test
runs-on: windows-small
needs: [windows-link]
if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
permissions:
pull-requests: write
timeout-minutes: 180
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}
failing_tests_count: ${{ steps.test.outputs.failing_tests_count }}
strategy:
fail-fast: false
matrix:
# TODO: test baseline, disabled due to noise
cpu: [haswell]
arch: [x86_64]
steps:
- run: git config --global core.autocrlf false && git config --global core.eol lf
- id: checkout
name: Checkout
uses: actions/checkout@v3
with:
submodules: false
- id: download
name: Download Release
uses: actions/download-artifact@v3
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile
path: ${{runner.temp}}/release
- name: Install Bun
run: |
cd ${{runner.temp}}/release
unzip ${{env.tag}}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile.zip
cd ${{env.tag}}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile
pwd >> $env:GITHUB_PATH
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: |
# bun install --verbose
# bun install --cwd=test --verbose
# bun install --cwd=packages/bun-internal-test --verbose
[Commit ${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})
npm install
cd test && npm install
cd ../packages/bun-internal-test && npm install
cd ../..
- id: test
name: Run tests
env:
SMTP_SENDGRID_SENDER: ${{ secrets.SMTP_SENDGRID_SENDER }}
TLS_MONGODB_DATABASE_URL: ${{ secrets.TLS_MONGODB_DATABASE_URL }}
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
run: |
try {
$ErrorActionPreference = "SilentlyContinue"
$null = node packages/bun-internal-test/src/runner.node.mjs ${{runner.temp}}/release/${{env.tag}}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile/bun.exe || $true
} catch {}
$ErrorActionPreference = "Stop"
- uses: sarisia/actions-status-discord@v1
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK_WINTEST }}
status: "failure"
noprefix: true
nocontext: true
description: |
### ❌🪟 [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}, there are **${{ steps.test.outputs.failing_test_count }} failing tests** on Windows ${{ matrix.arch }}${{ matrix.cpu == 'nehalem' && ' Baseline' || '' }}
${{ steps.test.outputs.failing_tests }}
[Full Test Output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})
- uses: sarisia/actions-status-discord@v1
if: always() && steps.test.outputs.regressing_tests != '' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: "failure"
noprefix: true
nocontext: true
description: |
### ❌🪟 [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}, there are **${{ steps.test.outputs.regressing_test_count }} test regressions** on Windows ${{ matrix.arch }}${{ matrix.cpu == 'nehalem' && ' Baseline' || '' }}
${{ steps.test.outputs.regressing_tests }}
[Full Test Output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})
- name: Comment on PR
if: always() && steps.test.outputs.regressing_tests != '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: test-windows-${{ matrix.arch }}-${{ matrix.cpu }}
message: |
### ❌🪟 @${{ github.actor }}, there are **${{ steps.test.outputs.regressing_test_count }} test regressions** on Windows ${{ matrix.arch }}${{ matrix.cpu == 'nehalem' && ' Baseline' || '' }}
${{ steps.test.outputs.regressing_tests }}
[Full Test Output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})
- name: Uncomment on PR
if: steps.test.outputs.regressing_tests == '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: test-windows-${{ matrix.arch }}-${{ matrix.cpu }}
mode: upsert
create_if_not_exists: false
message: |
✅🪟 Test regressions on Windows ${{ matrix.arch }}${{ matrix.cpu == 'nehalem' && ' Baseline' || '' }} have been resolved.
- id: fail
name: Fail the build
if: steps.test.outputs.regressing_tests != '' && github.event_name == 'pull_request'
run: exit 1

332
.gitignore vendored
View File

@@ -1,164 +1,168 @@
.DS_Store
zig-cache
packages/*/*.wasm
*.o
*.a
profile.json
node_modules
.envrc
.swcrc
yarn.lock
dist
*.tmp
*.log
*.out.js
*.out.refresh.js
**/package-lock.json
build
*.wat
zig-out
pnpm-lock.yaml
README.md.template
src/deps/zig-clap/example
src/deps/zig-clap/README.md
src/deps/zig-clap/.github
src/deps/zig-clap/.gitattributes
out
outdir
.trace
cover
coverage
coverv
*.trace
github
out.*
out
.parcel-cache
esbuilddir
*.bun
parceldist
esbuilddir
outdir/
outcss
.next
txt.js
.idea
.vscode/cpp*
.vscode/clang*
node_modules_*
*.jsb
*.zip
bun-zigld
bun-singlehtreaded
bun-nomimalloc
bun-mimalloc
examples/lotta-modules/bun-yday
examples/lotta-modules/bun-old
examples/lotta-modules/bun-nofscache
src/node-fallbacks/out/*
src/node-fallbacks/node_modules
sign.json
release/
*.dmg
sign.*.json
packages/debug-*
packages/bun-cli/postinstall.js
packages/bun-*/bun
packages/bun-*/bun-profile
packages/bun-*/debug-bun
packages/bun-*/*.o
packages/bun-cli/postinstall.js
packages/bun-cli/bin/*
bun-test-scratch
misctools/fetch
src/deps/libiconv
src/deps/openssl
src/tests.zig
*.blob
src/deps/s2n-tls
.npm
.npm.gz
bun-binary
src/deps/PLCrashReporter/
*.dSYM
*.crash
misctools/sha
packages/bun-wasm/*.mjs
packages/bun-wasm/*.cjs
packages/bun-wasm/*.map
packages/bun-wasm/*.js
packages/bun-wasm/*.d.ts
packages/bun-wasm/*.d.cts
packages/bun-wasm/*.d.mts
*.bc
src/fallback.version
src/runtime.version
*.sqlite
*.database
*.db
misctools/machbench
*.big
.eslintcache
/bun-webkit
src/deps/c-ares/build
src/bun.js/bindings-obj
src/bun.js/debug-bindings-obj
failing-tests.txt
test.txt
myscript.sh
cold-jsc-start
cold-jsc-start.d
/test.ts
/test.js
src/js/out/modules*
src/js/out/functions*
src/js/out/tmp
src/js/out/DebugPath.h
make-dev-stats.csv
.uuid
tsconfig.tsbuildinfo
test/js/bun/glob/fixtures
*.lib
*.pdb
CMakeFiles
build.ninja
.ninja_deps
.ninja_log
CMakeCache.txt
cmake_install.cmake
compile_commands.json
*.lib
x64
**/*.vcxproj*
**/*.sln*
**/*.dir
**/*.pdb
/.webkit-cache
/.cache
/src/deps/libuv
/build-*/
.vs
**/.verdaccio-db.json
.DS_Store
zig-cache
packages/*/*.wasm
*.o
*.a
profile.json
.env
node_modules
.envrc
.swcrc
yarn.lock
dist
*.tmp
*.log
*.out.js
*.out.refresh.js
**/package-lock.json
build
*.wat
zig-out
pnpm-lock.yaml
README.md.template
src/deps/zig-clap/example
src/deps/zig-clap/README.md
src/deps/zig-clap/.github
src/deps/zig-clap/.gitattributes
out
outdir
.trace
cover
coverage
coverv
*.trace
github
out.*
out
.parcel-cache
esbuilddir
*.bun
parceldist
esbuilddir
outdir/
outcss
.next
txt.js
.idea
.vscode/cpp*
.vscode/clang*
node_modules_*
*.jsb
*.zip
bun-zigld
bun-singlehtreaded
bun-nomimalloc
bun-mimalloc
examples/lotta-modules/bun-yday
examples/lotta-modules/bun-old
examples/lotta-modules/bun-nofscache
src/node-fallbacks/out/*
src/node-fallbacks/node_modules
sign.json
release/
*.dmg
sign.*.json
packages/debug-*
packages/bun-cli/postinstall.js
packages/bun-*/bun
packages/bun-*/bun-profile
packages/bun-*/debug-bun
packages/bun-*/*.o
packages/bun-cli/postinstall.js
packages/bun-cli/bin/*
bun-test-scratch
misctools/fetch
src/deps/libiconv
src/deps/openssl
src/tests.zig
*.blob
src/deps/s2n-tls
.npm
.npm.gz
bun-binary
src/deps/PLCrashReporter/
*.dSYM
*.crash
misctools/sha
packages/bun-wasm/*.mjs
packages/bun-wasm/*.cjs
packages/bun-wasm/*.map
packages/bun-wasm/*.js
packages/bun-wasm/*.d.ts
packages/bun-wasm/*.d.cts
packages/bun-wasm/*.d.mts
*.bc
src/fallback.version
src/runtime.version
*.sqlite
*.database
*.db
misctools/machbench
*.big
.eslintcache
/bun-webkit
src/deps/c-ares/build
src/bun.js/bindings-obj
src/bun.js/debug-bindings-obj
failing-tests.txt
test.txt
myscript.sh
cold-jsc-start
cold-jsc-start.d
/testdir
/test.ts
/test.js
src/js/out/modules*
src/js/out/functions*
src/js/out/tmp
src/js/out/DebugPath.h
make-dev-stats.csv
.uuid
tsconfig.tsbuildinfo
test/js/bun/glob/fixtures
*.lib
*.pdb
CMakeFiles
build.ninja
.ninja_deps
.ninja_log
CMakeCache.txt
cmake_install.cmake
compile_commands.json
*.lib
x64
**/*.vcxproj*
**/*.sln*
**/*.dir
**/*.pdb
/.webkit-cache
/.cache
/src/deps/libuv
/build-*/
.vs
**/.verdaccio-db.json
/test-report.md
/test-report.json

View File

@@ -1,13 +0,0 @@
src/fallback.html
src/bun.js/WebKit
src/js/out
src/*.out.js
src/*out.*.js
src/deps
src/test/fixtures
src/react-refresh.js
test/snapshots
test/snapshots-no-hmr
test/js/deno/*.test.ts
test/js/deno/**/*.test.ts
bench/react-hello-world/react-hello-world.node.js

View File

@@ -1,15 +0,0 @@
module.exports = {
arrowParens: "avoid",
printWidth: 120,
trailingComma: "all",
useTabs: false,
quoteProps: "preserve",
overrides: [
{
files: ["*.md"],
options: {
printWidth: 80,
},
},
],
};

View File

@@ -3,6 +3,7 @@
{
"name": "Debug",
"forcedInclude": ["${workspaceFolder}/src/bun.js/bindings/root.h"],
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"includePath": [
"${workspaceFolder}/build/bun-webkit/include",
"${workspaceFolder}/build/codegen",

View File

@@ -1,10 +1,33 @@
{
"recommendations": [
// Zig
"ziglang.vscode-zig",
"esbenp.prettier-vscode",
// C/C++
"clang.clangd",
"ms-vscode.cmake-tools",
"xaver.clang-format",
"vadimcn.vscode-lldb",
// JavaScript
"oven.bun-vscode",
"biomejs.biome",
// TypeScript
"better-ts-errors.better-ts-errors",
"MylesMurphy.prettify-ts",
// Markdown
"bierner.markdown-preview-github-styles",
"bierner.markdown-emoji",
"bierner.emojisense",
"bierner.markdown-checkbox",
"bierner.jsdoc-markdown-highlighting",
// TOML
"tamasfe.even-better-toml",
// Other
"bierner.comment-tagged-templates",
"ms-vscode.cpptools"
]
}

1213
.vscode/launch.json generated vendored

File diff suppressed because it is too large Load Diff

228
.vscode/settings.json vendored
View File

@@ -1,48 +1,89 @@
{
"git.autoRepositoryDetection": "openEditors",
// Editor
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
// Search
"search.quickOpen.includeSymbols": false,
"search.seedWithNearestWord": true,
"search.smartCase": true,
"search.exclude": {
"node_modules": true,
"src/bun.js/WebKit": true,
".git": true,
"src/bun.js/WebKit": true,
"src/deps/*/**": true
},
"search.followSymlinks": false,
"search.useIgnoreFiles": true,
// Git
"git.autoRepositoryDetection": "openEditors",
"git.ignoreSubmodules": true,
"git.ignoreLimitWarning": true,
// Zig
"zig.initialSetupDone": true,
"zig.buildOnSave": false,
"zig.formattingProvider": "zls",
"zig.buildOption": "build",
"zig.buildFilePath": "${workspaceFolder}/build.zig",
"zig.initialSetupDone": true,
"editor.formatOnSave": true,
"zig.path": "${workspaceFolder}/.cache/zig/zig.exe",
"zig.formattingProvider": "zls",
"zig.zls.enableInlayHints": false,
"[zig]": {
"editor.tabSize": 4,
"editor.useTabStops": false,
"editor.defaultFormatter": "ziglang.vscode-zig"
},
"[ts]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
// C++
"lldb.verboseLogging": false,
"cmake.configureOnOpen": false,
"C_Cpp.errorSquiggles": "enabled",
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"[js]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"[c]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"zig.zls.enableInlayHints": false,
"zig.path": "${workspaceFolder}/.cache/zig/zig",
"git.ignoreSubmodules": true,
"[jsx]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"[h]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"[tsx]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
// JavaScript
"prettier.enable": false,
"eslint.workingDirectories": ["${workspaceFolder}/packages/bun-types"],
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome",
},
"[yaml]": {},
"[javascriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
// TypeScript
"typescript.tsdk": "${workspaceFolder}/node_modules/typescript/lib",
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
// JSON
"[json]": {
"editor.defaultFormatter": "biomejs.biome",
},
"[jsonc]": {
"editor.defaultFormatter": "biomejs.biome",
},
// Markdown
"[markdown]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.unicodeHighlight.ambiguousCharacters": false,
"editor.unicodeHighlight.invisibleCharacters": false,
"diffEditor.ignoreTrimWhitespace": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.wordWrap": "on",
"editor.quickSuggestions": {
"comments": "off",
@@ -50,7 +91,18 @@
"other": "off"
}
},
"lldb.verboseLogging": false,
// TOML
"[toml]": {
"editor.defaultFormatter": "biomejs.biome",
},
// YAML
"[yaml]": {
"editor.defaultFormatter": "biomejs.biome",
},
// Files
"files.exclude": {
"**/.git": true,
"**/.svn": true,
@@ -60,7 +112,6 @@
"**/Thumbs.db": true,
"**/*.xcworkspacedata": true,
"**/*.xcscheme": true,
"**/*.pem": true,
"**/*.xcodeproj": true,
"src/bun.js/WebKit": true,
"src/deps/libarchive": true,
@@ -75,7 +126,10 @@
"src/deps/tinycc": true,
"src/deps/zstd": true,
"**/*.i": true,
"packages/bun-uws/fuzzing/seed-corpus/**/*": true
"packages/bun-uws/fuzzing/seed-corpus": true
},
"files.associations": {
"*.idl": "cpp"
},
"C_Cpp.files.exclude": {
"**/.vscode": true,
@@ -95,136 +149,4 @@
"WebKit/WebKitBuild": true,
"WebKit/WebInspectorUI": true
},
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"[h]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"[c]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"files.associations": {
"*.lock": "yarnlock",
"*.idl": "cpp",
"memory": "cpp",
"iostream": "cpp",
"algorithm": "cpp",
"random": "cpp",
"ios": "cpp",
"filesystem": "cpp",
"__locale": "cpp",
"type_traits": "cpp",
"__mutex_base": "cpp",
"__string": "cpp",
"string": "cpp",
"string_view": "cpp",
"typeinfo": "cpp",
"__config": "cpp",
"__nullptr": "cpp",
"exception": "cpp",
"__bit_reference": "cpp",
"atomic": "cpp",
"utility": "cpp",
"sstream": "cpp",
"__functional_base": "cpp",
"new": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__hash_table": "cpp",
"__node_handle": "cpp",
"__split_buffer": "cpp",
"__threading_support": "cpp",
"__tuple": "cpp",
"array": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"fstream": "cpp",
"functional": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"locale": "cpp",
"mutex": "cpp",
"optional": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"stack": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"__bits": "cpp",
"__tree": "cpp",
"map": "cpp",
"numeric": "cpp",
"set": "cpp",
"__memory": "cpp",
"memory_resource": "cpp",
"*.tcc": "cpp",
"list": "cpp",
"shared_mutex": "cpp",
"cinttypes": "cpp",
"variant": "cpp",
"sysctl.h": "c",
"queue": "cpp",
"compare": "cpp",
"concepts": "cpp",
"typeindex": "cpp",
"__verbose_abort": "cpp",
"__std_stream": "cpp",
"any": "cpp",
"charconv": "cpp",
"csignal": "cpp",
"format": "cpp",
"forward_list": "cpp",
"future": "cpp",
"regex": "cpp",
"span": "cpp",
"valarray": "cpp",
"codecvt": "cpp",
"xtr1common": "cpp",
"stop_token": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstring": "cpp",
"xtree": "cpp",
"xutility": "cpp"
},
"C_Cpp.errorSquiggles": "enabled",
"eslint.workingDirectories": ["packages/bun-types"],
"typescript.tsdk": "node_modules/typescript/lib",
"cmake.configureOnOpen": false
}

49
.vscode/tasks.json vendored
View File

@@ -2,10 +2,51 @@
"version": "2.0.0",
"tasks": [
{
"label": "Rebuild Debug",
"command": "ninja",
"args": ["-Cbuild"],
"type": "process",
}
"label": "Install Dependencies",
"command": "scripts/all-dependencies.sh",
"windows": {
"command": "scripts/all-dependencies.ps1"
},
"icon": {
"id": "arrow-down"
},
"options": {
"cwd": "${workspaceFolder}"
},
},
{
"type": "process",
"label": "Setup Environment",
"dependsOn": ["Install Dependencies"],
"command": "scripts/setup.sh",
"windows": {
"command": "scripts/setup.ps1"
},
"icon": {
"id": "check"
},
"options": {
"cwd": "${workspaceFolder}"
},
},
{
"type": "process",
"label": "Build Bun",
"dependsOn": ["Setup Environment"],
"command": "bun",
"args": ["run", "build"],
"icon": {
"id": "gear"
},
"options": {
"cwd": "${workspaceFolder}"
},
"isBuildCommand": true,
"runOptions": {
"instanceLimit": 1,
"reevaluateOnRerun": true,
},
},
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -290,7 +290,6 @@ ENV CCACHE_DIR=/ccache
COPY Makefile ${BUN_DIR}/Makefile
COPY src/deps/zstd ${BUN_DIR}/src/deps/zstd
COPY .prettierrc.cjs ${BUN_DIR}/.prettierrc.cjs
WORKDIR $BUN_DIR
@@ -378,9 +377,9 @@ RUN --mount=type=cache,target=/ccache mkdir ${BUN_DIR}/build \
FROM bun-base-with-zig as bun-codegen-for-zig
COPY package.json bun.lockb Makefile .gitmodules .prettierrc.cjs ${BUN_DIR}/
COPY package.json bun.lockb Makefile .gitmodules ${BUN_DIR}/
COPY src/runtime ${BUN_DIR}/src/runtime
COPY src/runtime.js src/runtime.footer*.js src/react-refresh.js ${BUN_DIR}/src/
COPY src/runtime.js src/runtime.bun.js ${BUN_DIR}/src/
COPY packages/bun-error ${BUN_DIR}/packages/bun-error
COPY src/fallback.ts ${BUN_DIR}/src/fallback.ts
COPY src/api ${BUN_DIR}/src/api

View File

@@ -673,7 +673,7 @@ assert-deps:
@echo "You have the dependencies installed! Woo"
# the following allows you to run `make submodule` to update or init submodules. but we will exclude webkit
# unless you explicity clone it yourself (a huge download)
# unless you explicitly clone it yourself (a huge download)
SUBMODULE_NAMES=$(shell cat .gitmodules | grep 'path = ' | awk '{print $$3}')
ifeq ("$(wildcard src/bun.js/WebKit/.git)", "")
SUBMODULE_NAMES := $(filter-out src/bun.js/WebKit, $(SUBMODULE_NAMES))
@@ -823,7 +823,6 @@ fmt: fmt-cpp fmt-zig
api:
./node_modules/.bin/peechy --schema src/api/schema.peechy --esm src/api/schema.js --ts src/api/schema.d.ts --zig src/api/schema.zig
$(ZIG) fmt src/api/schema.zig
$(PRETTIER) --config=.prettierrc.cjs --write src/api/schema.js src/api/schema.d.ts
.PHONY: node-fallbacks
node-fallbacks:
@@ -836,17 +835,7 @@ fallback_decoder:
.PHONY: runtime_js
runtime_js:
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV=\"production\" --target=esnext --bundle src/runtime/index.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.out.js; cat src/runtime.footer.js >> src/runtime.out.js
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV=\"production\" --target=esnext --bundle src/runtime/index-with-refresh.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.out.refresh.js; cat src/runtime.footer.with-refresh.js >> src/runtime.out.refresh.js
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV=\"production\" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.node.pre.out.js; cat src/runtime.node.pre.out.js src/runtime.footer.node.js > src/runtime.node.out.js
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV=\"production\" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.bun.pre.out.js; cat src/runtime.bun.pre.out.js src/runtime.footer.bun.js > src/runtime.bun.out.js
.PHONY: runtime_js_dev
runtime_js_dev:
@NODE_ENV=development $(ESBUILD) --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.out.js; cat src/runtime.footer.js >> src/runtime.out.js
@NODE_ENV=development $(ESBUILD) --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index-with-refresh.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.out.refresh.js; cat src/runtime.footer.with-refresh.js >> src/runtime.out.refresh.js
@NODE_ENV=development $(ESBUILD) --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.node.pre.out.js; cat src/runtime.node.pre.out.js src/runtime.footer.node.js > src/runtime.node.out.js
@NODE_ENV=development $(ESBUILD) --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.bun.pre.out.js; cat src/runtime.bun.pre.out.js src/runtime.footer.bun.js > src/runtime.bun.out.js
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV=\"production\" --target=esnext --bundle src/runtime.bun.js --format=esm --platform=node --minify --external:/bun:* > src/runtime.out.js
.PHONY: bun_error
bun_error:
@@ -1733,7 +1722,7 @@ sizegen:
# Linux uses bundled SQLite3
ifeq ($(OS_NAME),linux)
sqlite:
$(CC) $(EMIT_LLVM_FOR_RELEASE) $(CFLAGS) $(INCLUDE_DIRS) -DSQLITE_ENABLE_COLUMN_METADATA= -DSQLITE_MAX_VARIABLE_NUMBER=250000 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_JSON1=1 $(SRC_DIR)/sqlite/sqlite3.c -c -o $(SQLITE_OBJECT)
$(CC) $(EMIT_LLVM_FOR_RELEASE) $(CFLAGS) $(INCLUDE_DIRS) -DSQLITE_ENABLE_COLUMN_METADATA= -DSQLITE_MAX_VARIABLE_NUMBER=250000 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_MATH_FUNCTIONS=1 $(SRC_DIR)/sqlite/sqlite3.c -c -o $(SQLITE_OBJECT)
endif
picohttp:

Binary file not shown.

View File

@@ -1,7 +1,7 @@
import { bench, run } from "mitata";
import { groupForEmitter } from "./implementations.mjs";
// Psuedo RNG is derived from https://stackoverflow.com/a/424445
// Pseudo RNG is derived from https://stackoverflow.com/a/424445
let rngState = 123456789;
function nextInt() {
const m = 0x80000000; // 2**31;

37
bench/glob/braces.mjs Normal file
View File

@@ -0,0 +1,37 @@
import braces from "braces";
import { group, bench, run } from "mitata";
// const iterations = 1000;
const iterations = 100;
const simplePattern = "foo.{js,jsx,ts,tsx}";
const complexPattern = "{a,b,HI{c,e,LMAO{d,f}Q}} wow {a,b}";
const veryComplexPattern = "{a,b,HI{c,e,LMAO{d,f}Q}}{1,2,{3,4},5}";
console.log(braces(complexPattern, { expand: true }));
function benchPattern(pattern, name) {
group({ name: `${name} pattern: "${pattern}"`, summary: true }, () => {
if (typeof Bun !== "undefined")
bench("Bun", () => {
for (let i = 0; i < iterations; i++) {
Bun.$.braces(pattern);
}
});
bench("micromatch/braces", () => {
for (let i = 0; i < iterations; i++) {
braces(pattern, { expand: true });
}
});
});
}
benchPattern(simplePattern, "simple");
benchPattern(complexPattern, "complex");
benchPattern(veryComplexPattern, "very complex pattern");
await run({
avg: true,
min_max: true,
percentiles: true,
});

View File

@@ -25,7 +25,7 @@ pub var all_timestamps: [RUN_COUNT + 1]usize = undefined;
// 1. file path
// 2. Byte offset in file
// 3. ms update interval
var color_buf: [8096 + SIMULATE_LONG_FILE.len]u8 = undefined;
var color_buf: [8192 + SIMULATE_LONG_FILE.len]u8 = undefined;
pub fn main() anyerror!void {
var allocator = std.heap.c_allocator;

View File

@@ -25,7 +25,7 @@ pub var all_timestamps: [RUN_COUNT + 1]usize = undefined;
// 1. file path
// 2. Byte offset in file
// 3. ms update interval
var color_buf: [8096 + SIMULATE_LONG_FILE.len]u8 = undefined;
var color_buf: [8192 + SIMULATE_LONG_FILE.len]u8 = undefined;
pub fn main() anyerror!void {
var allocator = std.heap.c_allocator;

View File

@@ -7,280 +7,166 @@
"version": "0.0.34"
},
"timestamps": [
16336202536562, 16336202536908, 16336202537294, 16336202537705,
16336202538114, 16336202538534, 16336202538941, 16336202539323,
16336202539742, 16336202540159, 16336202540877, 16336202541310,
16336202541749, 16336202542159, 16336202542565, 16336202542996,
16336202543333, 16336202543761, 16336202544159, 16336202544534,
16336202544944, 16336202545345, 16336202545744, 16336202546159,
16336202546573, 16336202546986, 16336202547399, 16336202547781,
16336202548202, 16336202548564, 16336202548949, 16336202549329,
16336202549762, 16336202550168, 16336202550534, 16336202550887,
16336202551305, 16336202551659, 16336202552060, 16336202552449,
16336202552854, 16336202553270, 16336202553609, 16336202554034,
16336202554437, 16336202554783, 16336202555191, 16336202555623,
16336202556034, 16336202556449, 16336202556890, 16336202557283,
16336202557669, 16336202558084, 16336202558496, 16336202558863,
16336202559271, 16336202559659, 16336202560051, 16336202560452,
16336202560873, 16336202561290, 16336202561659, 16336202562035,
16336202562440, 16336202562862, 16336202563284, 16336202563659,
16336202564034, 16336202564444, 16336202564853, 16336202565245,
16336202565659, 16336202566034, 16336202566455, 16336202566873,
16336202567284, 16336202567659, 16336202568034, 16336202568386,
16336202568790, 16336202569204, 16336202569620, 16336202570384,
16336202570768, 16336202571188, 16336202571551, 16336202572327,
16336202572717, 16336202573116, 16336202573541, 16336202573959,
16336202574319, 16336202574682, 16336202575040, 16336202575375,
16336202577001, 16336202577342, 16336202577680, 16336202578066,
16336202578451, 16336202579166, 16336202579534, 16336202579960,
16336202580370, 16336202580789, 16336202581159, 16336202581576,
16336202581949, 16336202582294, 16336202583087, 16336202583496,
16336202583858, 16336202584203, 16336202584606, 16336202585034,
16336202585386, 16336202585788, 16336202586211, 16336202586604,
16336202587034, 16336202587459, 16336202587869, 16336202588295,
16336202588668, 16336202589092, 16336202589452, 16336202589831,
16336202590197, 16336202590608, 16336202591034, 16336202591460,
16336202591880, 16336202592295, 16336202592727, 16336202593172,
16336202593567, 16336202593994, 16336202594397, 16336202594795,
16336202595224, 16336202595659, 16336202596058, 16336202596463,
16336202596890, 16336202597322, 16336202597732, 16336202598159,
16336202598534, 16336202598951, 16336202599365, 16336202599785,
16336202600159, 16336202600593, 16336202601005, 16336202601402,
16336202601807, 16336202602214, 16336202602556, 16336202602895,
16336202603307, 16336202603661, 16336202604075, 16336202604491,
16336202604853, 16336202605268, 16336202605670, 16336202606034,
16336202606393, 16336202606748, 16336202607170, 16336202607568,
16336202607982, 16336202608411, 16336202608836, 16336202609197,
16336202609596, 16336202609965, 16336202610333, 16336202610740,
16336202611159, 16336202611573, 16336202611975, 16336202612317,
16336202612691, 16336202613060, 16336202613474, 16336202613903,
16336202614341, 16336202614707, 16336202615094, 16336202615534,
16336202615883, 16336202616296, 16336202616671, 16336202617034,
16336202617391, 16336202617727, 16336202618159, 16336202618534,
16336202618937, 16336202619360, 16336202619770, 16336202620179,
16336202620716, 16336202621143, 16336202621534, 16336202622303,
16336202622659, 16336202623085, 16336202623498, 16336202623850,
16336202624220, 16336202624606, 16336202625034, 16336202625387,
16336202625805, 16336202626210, 16336202626599, 16336202627034,
16336202627386, 16336202627748, 16336202628159, 16336202628534,
16336202628954, 16336202629373, 16336202629809, 16336202630197,
16336202630535, 16336202630916, 16336202631290, 16336202631666,
16336202632034, 16336202632369, 16336202633152, 16336202633534,
16336202633883, 16336202634309, 16336202634717, 16336202635106,
16336202635871, 16336202636253, 16336202636671, 16336202637070,
16336202637434, 16336202637798, 16336202638184, 16336202638539,
16336202638938, 16336202639307, 16336202639666, 16336202640095,
16336202640534, 16336202640962, 16336202641307, 16336202641659,
16336202642087, 16336202642521, 16336202642886, 16336202643309,
16336202643662, 16336202644067, 16336202644491, 16336202644853,
16336202645226, 16336202645659, 16336202646074, 16336202646497,
16336202646890, 16336202647311, 16336202647749, 16336202648169,
16336202648976, 16336202649378, 16336202649810, 16336202650165,
16336202650534, 16336202650875, 16336202651250, 16336202651659,
16336202652093, 16336202652516, 16336202652921, 16336202653332,
16336202653722, 16336202654142, 16336202654534, 16336202654880,
16336202655221, 16336202655562, 16336202655997, 16336202656378,
16336202656811, 16336202657161, 16336202657588, 16336202657944,
16336202658360, 16336202658708, 16336202659089, 16336202659428,
16336202659849, 16336202660273, 16336202660685, 16336202661105,
16336202661534, 16336202661873, 16336202662228, 16336202662658,
16336202663438, 16336202663843, 16336202664219, 16336202664646,
16336202665050, 16336202665487, 16336202665838, 16336202666211,
16336202666573, 16336202666927, 16336202667334, 16336202667746,
16336202668158, 16336202668563, 16336202668980, 16336202669406,
16336202669753, 16336202670192, 16336202670554, 16336202670903,
16336202671324, 16336202671734, 16336202672159, 16336202672573,
16336202672982, 16336202673346, 16336202673680, 16336202674087,
16336202674499, 16336202674909, 16336202675260, 16336202676110,
16336202676535, 16336202676913, 16336202677312, 16336202677658,
16336202678044, 16336202678413, 16336202678793, 16336202679208,
16336202679604, 16336202680034, 16336202680385, 16336202680799,
16336202681213, 16336202681595, 16336202682004, 16336202682346,
16336202682726, 16336202683158, 16336202683586, 16336202683990,
16336202684323, 16336202684742, 16336202685175, 16336202685578,
16336202685979, 16336202686805, 16336202687206, 16336202687614,
16336202688038, 16336202688473, 16336202688848, 16336202689221,
16336202689559, 16336202689971, 16336202690368, 16336202690776,
16336202691159, 16336202691585, 16336202692010, 16336202692373,
16336202692780, 16336202693179, 16336202693580, 16336202693991,
16336202694324, 16336202694727, 16336202695159, 16336202695588,
16336202695991, 16336202696335, 16336202697160, 16336202697542,
16336202697929, 16336202698323, 16336202698674, 16336202699060,
16336202699492, 16336202699835, 16336202700238, 16336202700658,
16336202701059, 16336202701420, 16336202701815, 16336202702229,
16336202702659, 16336202703857, 16336202704256, 16336202704659,
16336202705497, 16336202706309, 16336202706660, 16336202707085,
16336202707511, 16336202707866, 16336202708210, 16336202708552,
16336202708925, 16336202709287, 16336202709670, 16336202710045,
16336202710402, 16336202710802, 16336202711167, 16336202711533,
16336202712249, 16336202712660, 16336202713088, 16336202713519,
16336202713936, 16336202714355, 16336202714740, 16336202715160,
16336202715533, 16336202715878, 16336202716290, 16336202716708,
16336202717102, 16336202718290, 16336202718699, 16336202719052,
16336202719388, 16336202719808, 16336202720225, 16336202720659,
16336202721052, 16336202721414, 16336202721828, 16336202722925,
16336202723664, 16336202724063, 16336202724405, 16336202726003,
16336202726736, 16336202727158, 16336202727543, 16336202727930,
16336202728336, 16336202728703, 16336202729061, 16336202729483,
16336202729832, 16336202730222, 16336202730659, 16336202731084,
16336202731500, 16336202731911, 16336202732326, 16336202733158,
16336202733585, 16336202734001, 16336202734691, 16336202735042,
16336202735442, 16336202735863, 16336202736255, 16336202736671,
16336202737043, 16336202737884, 16336202738671, 16336202739110,
16336202739533, 16336202739886, 16336202740283, 16336202740706,
16336202741143, 16336202741534, 16336202741942, 16336202742352,
16336202742697, 16336202743103, 16336202743940, 16336202745172,
16336202745542, 16336202745937, 16336202746339, 16336202746758,
16336202747531, 16336202747877, 16336202748232, 16336202748658,
16336202749055, 16336202749468, 16336202749859, 16336202750416,
16336202750839, 16336202751178, 16336202751572, 16336202752002,
16336202752419, 16336202753269, 16336202753678, 16336202754086,
16336202754432, 16336202754835, 16336202755260, 16336202755683,
16336202756059, 16336202756402, 16336202756837, 16336202758084,
16336202758507, 16336202758879, 16336202759270, 16336202759674,
16336202760044, 16336202760400, 16336202760801, 16336202761659,
16336202762053, 16336202762397, 16336202763199, 16336202763547,
16336202763948, 16336202764714, 16336202765113, 16336202765947,
16336202766329, 16336202766664, 16336202767085, 16336202768233,
16336202769056, 16336202769758, 16336202770178, 16336202770585,
16336202770929, 16336202771325, 16336202772158, 16336202772594,
16336202773033, 16336202773403, 16336202773801, 16336202774179,
16336202774555, 16336202774989, 16336202775393, 16336202775809,
16336202776209, 16336202776618, 16336202777033, 16336202777421,
16336202777845, 16336202778246, 16336202778658, 16336202779055,
16336202779411, 16336202779761, 16336202780175, 16336202780594,
16336202781002, 16336202781848, 16336202782658, 16336202783033,
16336202783857, 16336202784211, 16336202784557, 16336202784972,
16336202785377, 16336202785810, 16336202786172, 16336202786934,
16336202787343, 16336202787765, 16336202788201, 16336202788563,
16336202788970, 16336202789329, 16336202789672, 16336202790055,
16336202790456, 16336202790802, 16336202791580, 16336202791920,
16336202792326, 16336202793158, 16336202793953, 16336202794368,
16336202795187, 16336202795622, 16336202796033, 16336202796393,
16336202796777, 16336202797173, 16336202797540, 16336202797975,
16336202798317, 16336202798739, 16336202799158, 16336202799567,
16336202799966, 16336202800378, 16336202800803, 16336202801232,
16336202801658, 16336202802033, 16336202802374, 16336202802759,
16336202803158, 16336202803533, 16336202803947, 16336202804354,
16336202804729, 16336202805158, 16336202805534, 16336202805950,
16336202806390, 16336202806805, 16336202807219, 16336202807643,
16336202808033, 16336202808377, 16336202808790, 16336202809211,
16336202809560, 16336202809920, 16336202810355, 16336202810758,
16336202811187, 16336202811596, 16336202811943, 16336202812348,
16336202812710, 16336202813060, 16336202813398, 16336202813791,
16336202814158, 16336202814533, 16336202814878, 16336202815246,
16336202815658, 16336202816079, 16336202816851, 16336202817202,
16336202817540, 16336202817905, 16336202818244, 16336202818663,
16336202819068, 16336202819418, 16336202819777, 16336202820193,
16336202820599, 16336202821033, 16336202821395, 16336202821745,
16336202822158, 16336202822590, 16336202822996, 16336202823396,
16336202823804, 16336202824210, 16336202824581, 16336202824991,
16336202825406, 16336202825806, 16336202826210, 16336202826598,
16336202827033, 16336202827446, 16336202827839, 16336202828201,
16336202828577, 16336202828968, 16336202829362, 16336202829709,
16336202830096, 16336202830533, 16336202830917, 16336202831290,
16336202831699, 16336202832035, 16336202832406, 16336202832804,
16336202833200, 16336202833604, 16336202834033, 16336202834386,
16336202834759, 16336202835190, 16336202835621, 16336202836033,
16336202836405, 16336202837191, 16336202837613, 16336202838033,
16336202838374, 16336202838798, 16336202839200, 16336202839603,
16336202840034, 16336202840389, 16336202840783, 16336202841200,
16336202841617, 16336202842034, 16336202842390, 16336202842737,
16336202843158, 16336202843585, 16336202843923, 16336202844313,
16336202844724, 16336202845158, 16336202845576, 16336202845939,
16336202846368, 16336202846728, 16336202847158, 16336202847568,
16336202847911, 16336202848291, 16336202848695, 16336202849103,
16336202849533, 16336202849942, 16336202850368, 16336202850747,
16336202851158, 16336202851549, 16336202851978, 16336202852383,
16336202852725, 16336202853158, 16336202853554, 16336202853961,
16336202854308, 16336202854704, 16336202855060, 16336202855418,
16336202855776, 16336202856203, 16336202856617, 16336202857036,
16336202857455, 16336202857884, 16336202858262, 16336202858658,
16336202859071, 16336202859847, 16336202860237, 16336202860658,
16336202861037, 16336202861452, 16336202861869, 16336202862218,
16336202862590, 16336202863001, 16336202863422, 16336202863857,
16336202864219, 16336202864658, 16336202865047, 16336202865404,
16336202865789, 16336202866210, 16336202866624, 16336202867033,
16336202867380, 16336202867797, 16336202868227, 16336202868658,
16336202869083, 16336202869500, 16336202869906, 16336202870246,
16336202870658, 16336202871086, 16336202871441, 16336202871820,
16336202872204, 16336202872546, 16336202872943, 16336202873380,
16336202873811, 16336202874213, 16336202874566, 16336202874918,
16336202875261, 16336202875655, 16336202876047, 16336202876771,
16336202877202, 16336202877612, 16336202878033, 16336202878412,
16336202878846, 16336202879241, 16336202879658, 16336202880072,
16336202880508, 16336202880901, 16336202881308, 16336202881725,
16336202882158, 16336202882579, 16336202882945, 16336202883286,
16336202883657, 16336202884048, 16336202884404, 16336202884752,
16336202885158, 16336202885533, 16336202885938, 16336202886364,
16336202886759, 16336202887175, 16336202887585, 16336202887929,
16336202888345, 16336202888743, 16336202889157, 16336202889570,
16336202889970, 16336202890382, 16336202890761, 16336202891187,
16336202891600, 16336202892033, 16336202892454, 16336202892794,
16336202893178, 16336202893533, 16336202893903, 16336202894264,
16336202894668, 16336202895049, 16336202895400, 16336202895774,
16336202896157, 16336202896537, 16336202896883, 16336202897232,
16336202897658, 16336202898065, 16336202898493, 16336202898884,
16336202899251, 16336202899673, 16336202900047, 16336202900467,
16336202900883, 16336202901300, 16336202901676, 16336202902068,
16336202902479, 16336202902902, 16336202903260, 16336202903675,
16336202904094, 16336202904476, 16336202904824, 16336202905158,
16336202905533, 16336202905934, 16336202906289, 16336202906717,
16336202907158, 16336202907547, 16336202907904, 16336202908294,
16336202908717, 16336202909157, 16336202909582, 16336202910005,
16336202910399, 16336202910800, 16336202911220, 16336202911657,
16336202912064, 16336202912405, 16336202912779, 16336202913158,
16336202913553, 16336202913966, 16336202914376, 16336202914719,
16336202915091, 16336202915515, 16336202915887, 16336202916293,
16336202916649, 16336202917438, 16336202917869, 16336202918221,
16336202919053, 16336202919425, 16336202919833, 16336202920234,
16336202920658, 16336202921033, 16336202921433, 16336202921801,
16336202922161, 16336202922589, 16336202923017, 16336202923418,
16336202923804, 16336202924199, 16336202924593, 16336202925033,
16336202925449, 16336202925818, 16336202926223, 16336202926662,
16336202927431, 16336202927812, 16336202928227, 16336202928658,
16336202929061, 16336202929473, 16336202929891, 16336202930241,
16336202930657, 16336202931057, 16336202931396, 16336202931811,
16336202932225, 16336202932657, 16336202933058, 16336202933445,
16336202933790, 16336202934157, 16336202934562, 16336202934988,
16336202935391, 16336202935777, 16336202936160, 16336202936562,
16336202936986, 16336202937396, 16336202937751, 16336202938158,
16336202938578, 16336202938985, 16336202939396, 16336202939752,
16336202940157, 16336202940585
16336202536562, 16336202536908, 16336202537294, 16336202537705, 16336202538114, 16336202538534, 16336202538941,
16336202539323, 16336202539742, 16336202540159, 16336202540877, 16336202541310, 16336202541749, 16336202542159,
16336202542565, 16336202542996, 16336202543333, 16336202543761, 16336202544159, 16336202544534, 16336202544944,
16336202545345, 16336202545744, 16336202546159, 16336202546573, 16336202546986, 16336202547399, 16336202547781,
16336202548202, 16336202548564, 16336202548949, 16336202549329, 16336202549762, 16336202550168, 16336202550534,
16336202550887, 16336202551305, 16336202551659, 16336202552060, 16336202552449, 16336202552854, 16336202553270,
16336202553609, 16336202554034, 16336202554437, 16336202554783, 16336202555191, 16336202555623, 16336202556034,
16336202556449, 16336202556890, 16336202557283, 16336202557669, 16336202558084, 16336202558496, 16336202558863,
16336202559271, 16336202559659, 16336202560051, 16336202560452, 16336202560873, 16336202561290, 16336202561659,
16336202562035, 16336202562440, 16336202562862, 16336202563284, 16336202563659, 16336202564034, 16336202564444,
16336202564853, 16336202565245, 16336202565659, 16336202566034, 16336202566455, 16336202566873, 16336202567284,
16336202567659, 16336202568034, 16336202568386, 16336202568790, 16336202569204, 16336202569620, 16336202570384,
16336202570768, 16336202571188, 16336202571551, 16336202572327, 16336202572717, 16336202573116, 16336202573541,
16336202573959, 16336202574319, 16336202574682, 16336202575040, 16336202575375, 16336202577001, 16336202577342,
16336202577680, 16336202578066, 16336202578451, 16336202579166, 16336202579534, 16336202579960, 16336202580370,
16336202580789, 16336202581159, 16336202581576, 16336202581949, 16336202582294, 16336202583087, 16336202583496,
16336202583858, 16336202584203, 16336202584606, 16336202585034, 16336202585386, 16336202585788, 16336202586211,
16336202586604, 16336202587034, 16336202587459, 16336202587869, 16336202588295, 16336202588668, 16336202589092,
16336202589452, 16336202589831, 16336202590197, 16336202590608, 16336202591034, 16336202591460, 16336202591880,
16336202592295, 16336202592727, 16336202593172, 16336202593567, 16336202593994, 16336202594397, 16336202594795,
16336202595224, 16336202595659, 16336202596058, 16336202596463, 16336202596890, 16336202597322, 16336202597732,
16336202598159, 16336202598534, 16336202598951, 16336202599365, 16336202599785, 16336202600159, 16336202600593,
16336202601005, 16336202601402, 16336202601807, 16336202602214, 16336202602556, 16336202602895, 16336202603307,
16336202603661, 16336202604075, 16336202604491, 16336202604853, 16336202605268, 16336202605670, 16336202606034,
16336202606393, 16336202606748, 16336202607170, 16336202607568, 16336202607982, 16336202608411, 16336202608836,
16336202609197, 16336202609596, 16336202609965, 16336202610333, 16336202610740, 16336202611159, 16336202611573,
16336202611975, 16336202612317, 16336202612691, 16336202613060, 16336202613474, 16336202613903, 16336202614341,
16336202614707, 16336202615094, 16336202615534, 16336202615883, 16336202616296, 16336202616671, 16336202617034,
16336202617391, 16336202617727, 16336202618159, 16336202618534, 16336202618937, 16336202619360, 16336202619770,
16336202620179, 16336202620716, 16336202621143, 16336202621534, 16336202622303, 16336202622659, 16336202623085,
16336202623498, 16336202623850, 16336202624220, 16336202624606, 16336202625034, 16336202625387, 16336202625805,
16336202626210, 16336202626599, 16336202627034, 16336202627386, 16336202627748, 16336202628159, 16336202628534,
16336202628954, 16336202629373, 16336202629809, 16336202630197, 16336202630535, 16336202630916, 16336202631290,
16336202631666, 16336202632034, 16336202632369, 16336202633152, 16336202633534, 16336202633883, 16336202634309,
16336202634717, 16336202635106, 16336202635871, 16336202636253, 16336202636671, 16336202637070, 16336202637434,
16336202637798, 16336202638184, 16336202638539, 16336202638938, 16336202639307, 16336202639666, 16336202640095,
16336202640534, 16336202640962, 16336202641307, 16336202641659, 16336202642087, 16336202642521, 16336202642886,
16336202643309, 16336202643662, 16336202644067, 16336202644491, 16336202644853, 16336202645226, 16336202645659,
16336202646074, 16336202646497, 16336202646890, 16336202647311, 16336202647749, 16336202648169, 16336202648976,
16336202649378, 16336202649810, 16336202650165, 16336202650534, 16336202650875, 16336202651250, 16336202651659,
16336202652093, 16336202652516, 16336202652921, 16336202653332, 16336202653722, 16336202654142, 16336202654534,
16336202654880, 16336202655221, 16336202655562, 16336202655997, 16336202656378, 16336202656811, 16336202657161,
16336202657588, 16336202657944, 16336202658360, 16336202658708, 16336202659089, 16336202659428, 16336202659849,
16336202660273, 16336202660685, 16336202661105, 16336202661534, 16336202661873, 16336202662228, 16336202662658,
16336202663438, 16336202663843, 16336202664219, 16336202664646, 16336202665050, 16336202665487, 16336202665838,
16336202666211, 16336202666573, 16336202666927, 16336202667334, 16336202667746, 16336202668158, 16336202668563,
16336202668980, 16336202669406, 16336202669753, 16336202670192, 16336202670554, 16336202670903, 16336202671324,
16336202671734, 16336202672159, 16336202672573, 16336202672982, 16336202673346, 16336202673680, 16336202674087,
16336202674499, 16336202674909, 16336202675260, 16336202676110, 16336202676535, 16336202676913, 16336202677312,
16336202677658, 16336202678044, 16336202678413, 16336202678793, 16336202679208, 16336202679604, 16336202680034,
16336202680385, 16336202680799, 16336202681213, 16336202681595, 16336202682004, 16336202682346, 16336202682726,
16336202683158, 16336202683586, 16336202683990, 16336202684323, 16336202684742, 16336202685175, 16336202685578,
16336202685979, 16336202686805, 16336202687206, 16336202687614, 16336202688038, 16336202688473, 16336202688848,
16336202689221, 16336202689559, 16336202689971, 16336202690368, 16336202690776, 16336202691159, 16336202691585,
16336202692010, 16336202692373, 16336202692780, 16336202693179, 16336202693580, 16336202693991, 16336202694324,
16336202694727, 16336202695159, 16336202695588, 16336202695991, 16336202696335, 16336202697160, 16336202697542,
16336202697929, 16336202698323, 16336202698674, 16336202699060, 16336202699492, 16336202699835, 16336202700238,
16336202700658, 16336202701059, 16336202701420, 16336202701815, 16336202702229, 16336202702659, 16336202703857,
16336202704256, 16336202704659, 16336202705497, 16336202706309, 16336202706660, 16336202707085, 16336202707511,
16336202707866, 16336202708210, 16336202708552, 16336202708925, 16336202709287, 16336202709670, 16336202710045,
16336202710402, 16336202710802, 16336202711167, 16336202711533, 16336202712249, 16336202712660, 16336202713088,
16336202713519, 16336202713936, 16336202714355, 16336202714740, 16336202715160, 16336202715533, 16336202715878,
16336202716290, 16336202716708, 16336202717102, 16336202718290, 16336202718699, 16336202719052, 16336202719388,
16336202719808, 16336202720225, 16336202720659, 16336202721052, 16336202721414, 16336202721828, 16336202722925,
16336202723664, 16336202724063, 16336202724405, 16336202726003, 16336202726736, 16336202727158, 16336202727543,
16336202727930, 16336202728336, 16336202728703, 16336202729061, 16336202729483, 16336202729832, 16336202730222,
16336202730659, 16336202731084, 16336202731500, 16336202731911, 16336202732326, 16336202733158, 16336202733585,
16336202734001, 16336202734691, 16336202735042, 16336202735442, 16336202735863, 16336202736255, 16336202736671,
16336202737043, 16336202737884, 16336202738671, 16336202739110, 16336202739533, 16336202739886, 16336202740283,
16336202740706, 16336202741143, 16336202741534, 16336202741942, 16336202742352, 16336202742697, 16336202743103,
16336202743940, 16336202745172, 16336202745542, 16336202745937, 16336202746339, 16336202746758, 16336202747531,
16336202747877, 16336202748232, 16336202748658, 16336202749055, 16336202749468, 16336202749859, 16336202750416,
16336202750839, 16336202751178, 16336202751572, 16336202752002, 16336202752419, 16336202753269, 16336202753678,
16336202754086, 16336202754432, 16336202754835, 16336202755260, 16336202755683, 16336202756059, 16336202756402,
16336202756837, 16336202758084, 16336202758507, 16336202758879, 16336202759270, 16336202759674, 16336202760044,
16336202760400, 16336202760801, 16336202761659, 16336202762053, 16336202762397, 16336202763199, 16336202763547,
16336202763948, 16336202764714, 16336202765113, 16336202765947, 16336202766329, 16336202766664, 16336202767085,
16336202768233, 16336202769056, 16336202769758, 16336202770178, 16336202770585, 16336202770929, 16336202771325,
16336202772158, 16336202772594, 16336202773033, 16336202773403, 16336202773801, 16336202774179, 16336202774555,
16336202774989, 16336202775393, 16336202775809, 16336202776209, 16336202776618, 16336202777033, 16336202777421,
16336202777845, 16336202778246, 16336202778658, 16336202779055, 16336202779411, 16336202779761, 16336202780175,
16336202780594, 16336202781002, 16336202781848, 16336202782658, 16336202783033, 16336202783857, 16336202784211,
16336202784557, 16336202784972, 16336202785377, 16336202785810, 16336202786172, 16336202786934, 16336202787343,
16336202787765, 16336202788201, 16336202788563, 16336202788970, 16336202789329, 16336202789672, 16336202790055,
16336202790456, 16336202790802, 16336202791580, 16336202791920, 16336202792326, 16336202793158, 16336202793953,
16336202794368, 16336202795187, 16336202795622, 16336202796033, 16336202796393, 16336202796777, 16336202797173,
16336202797540, 16336202797975, 16336202798317, 16336202798739, 16336202799158, 16336202799567, 16336202799966,
16336202800378, 16336202800803, 16336202801232, 16336202801658, 16336202802033, 16336202802374, 16336202802759,
16336202803158, 16336202803533, 16336202803947, 16336202804354, 16336202804729, 16336202805158, 16336202805534,
16336202805950, 16336202806390, 16336202806805, 16336202807219, 16336202807643, 16336202808033, 16336202808377,
16336202808790, 16336202809211, 16336202809560, 16336202809920, 16336202810355, 16336202810758, 16336202811187,
16336202811596, 16336202811943, 16336202812348, 16336202812710, 16336202813060, 16336202813398, 16336202813791,
16336202814158, 16336202814533, 16336202814878, 16336202815246, 16336202815658, 16336202816079, 16336202816851,
16336202817202, 16336202817540, 16336202817905, 16336202818244, 16336202818663, 16336202819068, 16336202819418,
16336202819777, 16336202820193, 16336202820599, 16336202821033, 16336202821395, 16336202821745, 16336202822158,
16336202822590, 16336202822996, 16336202823396, 16336202823804, 16336202824210, 16336202824581, 16336202824991,
16336202825406, 16336202825806, 16336202826210, 16336202826598, 16336202827033, 16336202827446, 16336202827839,
16336202828201, 16336202828577, 16336202828968, 16336202829362, 16336202829709, 16336202830096, 16336202830533,
16336202830917, 16336202831290, 16336202831699, 16336202832035, 16336202832406, 16336202832804, 16336202833200,
16336202833604, 16336202834033, 16336202834386, 16336202834759, 16336202835190, 16336202835621, 16336202836033,
16336202836405, 16336202837191, 16336202837613, 16336202838033, 16336202838374, 16336202838798, 16336202839200,
16336202839603, 16336202840034, 16336202840389, 16336202840783, 16336202841200, 16336202841617, 16336202842034,
16336202842390, 16336202842737, 16336202843158, 16336202843585, 16336202843923, 16336202844313, 16336202844724,
16336202845158, 16336202845576, 16336202845939, 16336202846368, 16336202846728, 16336202847158, 16336202847568,
16336202847911, 16336202848291, 16336202848695, 16336202849103, 16336202849533, 16336202849942, 16336202850368,
16336202850747, 16336202851158, 16336202851549, 16336202851978, 16336202852383, 16336202852725, 16336202853158,
16336202853554, 16336202853961, 16336202854308, 16336202854704, 16336202855060, 16336202855418, 16336202855776,
16336202856203, 16336202856617, 16336202857036, 16336202857455, 16336202857884, 16336202858262, 16336202858658,
16336202859071, 16336202859847, 16336202860237, 16336202860658, 16336202861037, 16336202861452, 16336202861869,
16336202862218, 16336202862590, 16336202863001, 16336202863422, 16336202863857, 16336202864219, 16336202864658,
16336202865047, 16336202865404, 16336202865789, 16336202866210, 16336202866624, 16336202867033, 16336202867380,
16336202867797, 16336202868227, 16336202868658, 16336202869083, 16336202869500, 16336202869906, 16336202870246,
16336202870658, 16336202871086, 16336202871441, 16336202871820, 16336202872204, 16336202872546, 16336202872943,
16336202873380, 16336202873811, 16336202874213, 16336202874566, 16336202874918, 16336202875261, 16336202875655,
16336202876047, 16336202876771, 16336202877202, 16336202877612, 16336202878033, 16336202878412, 16336202878846,
16336202879241, 16336202879658, 16336202880072, 16336202880508, 16336202880901, 16336202881308, 16336202881725,
16336202882158, 16336202882579, 16336202882945, 16336202883286, 16336202883657, 16336202884048, 16336202884404,
16336202884752, 16336202885158, 16336202885533, 16336202885938, 16336202886364, 16336202886759, 16336202887175,
16336202887585, 16336202887929, 16336202888345, 16336202888743, 16336202889157, 16336202889570, 16336202889970,
16336202890382, 16336202890761, 16336202891187, 16336202891600, 16336202892033, 16336202892454, 16336202892794,
16336202893178, 16336202893533, 16336202893903, 16336202894264, 16336202894668, 16336202895049, 16336202895400,
16336202895774, 16336202896157, 16336202896537, 16336202896883, 16336202897232, 16336202897658, 16336202898065,
16336202898493, 16336202898884, 16336202899251, 16336202899673, 16336202900047, 16336202900467, 16336202900883,
16336202901300, 16336202901676, 16336202902068, 16336202902479, 16336202902902, 16336202903260, 16336202903675,
16336202904094, 16336202904476, 16336202904824, 16336202905158, 16336202905533, 16336202905934, 16336202906289,
16336202906717, 16336202907158, 16336202907547, 16336202907904, 16336202908294, 16336202908717, 16336202909157,
16336202909582, 16336202910005, 16336202910399, 16336202910800, 16336202911220, 16336202911657, 16336202912064,
16336202912405, 16336202912779, 16336202913158, 16336202913553, 16336202913966, 16336202914376, 16336202914719,
16336202915091, 16336202915515, 16336202915887, 16336202916293, 16336202916649, 16336202917438, 16336202917869,
16336202918221, 16336202919053, 16336202919425, 16336202919833, 16336202920234, 16336202920658, 16336202921033,
16336202921433, 16336202921801, 16336202922161, 16336202922589, 16336202923017, 16336202923418, 16336202923804,
16336202924199, 16336202924593, 16336202925033, 16336202925449, 16336202925818, 16336202926223, 16336202926662,
16336202927431, 16336202927812, 16336202928227, 16336202928658, 16336202929061, 16336202929473, 16336202929891,
16336202930241, 16336202930657, 16336202931057, 16336202931396, 16336202931811, 16336202932225, 16336202932657,
16336202933058, 16336202933445, 16336202933790, 16336202934157, 16336202934562, 16336202934988, 16336202935391,
16336202935777, 16336202936160, 16336202936562, 16336202936986, 16336202937396, 16336202937751, 16336202938158,
16336202938578, 16336202938985, 16336202939396, 16336202939752, 16336202940157, 16336202940585
],
"frameTimes": [
346, 411, 420, 382, 417, 433, 410, 431, 428, 375, 401, 415, 413, 382, 362,
380, 406, 353, 354, 389, 416, 425, 346, 432, 415, 393, 415, 367, 388, 401,
417, 376, 422, 375, 410, 392, 375, 418, 375, 352, 414, 764, 420, 776, 399,
418, 363, 335, 341, 386, 715, 426, 419, 417, 345, 409, 345, 428, 402, 393,
425, 426, 424, 379, 411, 426, 415, 445, 427, 398, 435, 405, 432, 427, 417,
420, 434, 397, 407, 339, 354, 416, 415, 364, 355, 398, 429, 361, 369, 407,
414, 342, 369, 429, 366, 440, 413, 363, 336, 375, 423, 409, 427, 769, 426,
352, 386, 353, 405, 435, 362, 375, 419, 388, 381, 376, 335, 382, 426, 389,
382, 399, 364, 355, 369, 429, 428, 352, 434, 423, 405, 362, 433, 423, 421,
420, 402, 355, 341, 409, 423, 411, 420, 346, 341, 381, 350, 356, 348, 339,
424, 420, 339, 430, 405, 427, 437, 373, 354, 412, 405, 426, 439, 349, 410,
414, 364, 407, 410, 850, 378, 346, 369, 415, 430, 414, 382, 342, 432, 404,
419, 403, 826, 408, 435, 373, 412, 408, 426, 363, 399, 411, 403, 429, 344,
382, 394, 386, 343, 420, 361, 414, 1198, 403, 812, 425, 355, 342, 362, 375,
400, 366, 411, 431, 419, 420, 345, 418, 1188, 353, 420, 434, 362, 1097, 399,
1598, 422, 387, 367, 422, 390, 425, 411, 832, 416, 351, 421, 416, 841, 439,
353, 423, 391, 410, 406, 1232, 395, 419, 346, 426, 413, 557, 339, 430, 850,
408, 403, 423, 343, 1247, 372, 404, 356, 858, 344, 348, 766, 834, 335, 1148,
702, 407, 396, 436, 370, 378, 434, 416, 409, 388, 401, 397, 350, 419, 846,
375, 354, 415, 433, 762, 422, 362, 359, 383, 346, 340, 832, 415, 435, 360,
396, 435, 422, 409, 412, 429, 375, 385, 375, 407, 429, 416, 415, 424, 344,
421, 360, 403, 409, 405, 350, 393, 375, 368, 421, 351, 365, 419, 350, 416,
434, 350, 432, 400, 406, 410, 400, 388, 413, 362, 391, 347, 437, 373, 336,
398, 404, 353, 431, 412, 786, 420, 424, 403, 355, 417, 417, 347, 427, 390,
434, 363, 360, 410, 380, 408, 409, 379, 391, 405, 433, 407, 396, 358, 427,
419, 429, 396, 776, 421, 415, 349, 411, 435, 439, 357, 421, 409, 417, 431,
417, 340, 428, 379, 342, 437, 402, 352, 394, 724, 410, 379, 395, 414, 393,
417, 421, 341, 391, 348, 375, 426, 416, 344, 398, 413, 412, 426, 433, 340,
355, 361, 381, 374, 380, 349, 407, 391, 422, 420, 417, 392, 423, 415, 382,
334, 401, 428, 389, 390, 440, 423, 401, 437, 341, 379, 413, 343, 424, 406,
789, 352, 372, 401, 375, 368, 428, 401, 395, 440, 369, 439, 381, 431, 412,
350, 400, 415, 432, 387, 367, 426, 386, 402, 410, 407, 407, 356, 428
346, 411, 420, 382, 417, 433, 410, 431, 428, 375, 401, 415, 413, 382, 362, 380, 406, 353, 354, 389, 416, 425, 346,
432, 415, 393, 415, 367, 388, 401, 417, 376, 422, 375, 410, 392, 375, 418, 375, 352, 414, 764, 420, 776, 399, 418,
363, 335, 341, 386, 715, 426, 419, 417, 345, 409, 345, 428, 402, 393, 425, 426, 424, 379, 411, 426, 415, 445, 427,
398, 435, 405, 432, 427, 417, 420, 434, 397, 407, 339, 354, 416, 415, 364, 355, 398, 429, 361, 369, 407, 414, 342,
369, 429, 366, 440, 413, 363, 336, 375, 423, 409, 427, 769, 426, 352, 386, 353, 405, 435, 362, 375, 419, 388, 381,
376, 335, 382, 426, 389, 382, 399, 364, 355, 369, 429, 428, 352, 434, 423, 405, 362, 433, 423, 421, 420, 402, 355,
341, 409, 423, 411, 420, 346, 341, 381, 350, 356, 348, 339, 424, 420, 339, 430, 405, 427, 437, 373, 354, 412, 405,
426, 439, 349, 410, 414, 364, 407, 410, 850, 378, 346, 369, 415, 430, 414, 382, 342, 432, 404, 419, 403, 826, 408,
435, 373, 412, 408, 426, 363, 399, 411, 403, 429, 344, 382, 394, 386, 343, 420, 361, 414, 1198, 403, 812, 425, 355,
342, 362, 375, 400, 366, 411, 431, 419, 420, 345, 418, 1188, 353, 420, 434, 362, 1097, 399, 1598, 422, 387, 367,
422, 390, 425, 411, 832, 416, 351, 421, 416, 841, 439, 353, 423, 391, 410, 406, 1232, 395, 419, 346, 426, 413, 557,
339, 430, 850, 408, 403, 423, 343, 1247, 372, 404, 356, 858, 344, 348, 766, 834, 335, 1148, 702, 407, 396, 436, 370,
378, 434, 416, 409, 388, 401, 397, 350, 419, 846, 375, 354, 415, 433, 762, 422, 362, 359, 383, 346, 340, 832, 415,
435, 360, 396, 435, 422, 409, 412, 429, 375, 385, 375, 407, 429, 416, 415, 424, 344, 421, 360, 403, 409, 405, 350,
393, 375, 368, 421, 351, 365, 419, 350, 416, 434, 350, 432, 400, 406, 410, 400, 388, 413, 362, 391, 347, 437, 373,
336, 398, 404, 353, 431, 412, 786, 420, 424, 403, 355, 417, 417, 347, 427, 390, 434, 363, 360, 410, 380, 408, 409,
379, 391, 405, 433, 407, 396, 358, 427, 419, 429, 396, 776, 421, 415, 349, 411, 435, 439, 357, 421, 409, 417, 431,
417, 340, 428, 379, 342, 437, 402, 352, 394, 724, 410, 379, 395, 414, 393, 417, 421, 341, 391, 348, 375, 426, 416,
344, 398, 413, 412, 426, 433, 340, 355, 361, 381, 374, 380, 349, 407, 391, 422, 420, 417, 392, 423, 415, 382, 334,
401, 428, 389, 390, 440, 423, 401, 437, 341, 379, 413, 343, 424, 406, 789, 352, 372, 401, 375, 368, 428, 401, 395,
440, 369, 439, 381, 431, 412, 350, 400, 415, 432, 387, 367, 426, 386, 402, 410, 407, 407, 356, 428
],
"percentileMs": {
"50": 40.7,

View File

@@ -5,11 +5,15 @@
"@babel/preset-react": "^7.16.7",
"@swc/core": "^1.2.133",
"benchmark": "^2.1.4",
"braces": "^3.0.2",
"esbuild": "^0.14.12",
"eventemitter3": "^5.0.0",
"execa": "^8.0.1",
"fast-glob": "3.3.1",
"fdir": "^6.1.0",
"mitata": "^0.1.6"
"mitata": "^0.1.6",
"string-width": "^7.0.0",
"zx": "^7.2.3"
},
"scripts": {
"ffi": "cd ffi && bun run deps && bun run build && bun run bench",
@@ -21,6 +25,5 @@
},
"devDependencies": {
"fast-deep-equal": "^3.1.3"
},
"prettier": "../.prettierrc.cjs"
}
}

View File

@@ -16,8 +16,8 @@ for (let size of [32, 2048, 1024 * 16, 1024 * 1024 * 2, 1024 * 1024 * 16]) {
size > 1024 * 1024
? new Intl.NumberFormat(undefined, { unit: "megabyte", style: "unit" })
: size > 1024
? new Intl.NumberFormat(undefined, { unit: "kilobyte", style: "unit" })
: new Intl.NumberFormat(undefined, { unit: "byte", style: "unit" });
? new Intl.NumberFormat(undefined, { unit: "kilobyte", style: "unit" })
: new Intl.NumberFormat(undefined, { unit: "byte", style: "unit" });
bench(
`Buffer.concat(${fmt.format(

View File

@@ -1,9 +1,9 @@
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
// pure JS implementation will optimze this out
// bench("new Headers", function () {
// return new Headers();
// });
bench("new Headers", function () {
return new Headers();
});
var big = new Headers({
"Content-Type": "text/plain",
@@ -17,17 +17,128 @@ var big = new Headers({
"X-Yet-Another-Custom-Headz": "Hello Worlda",
});
// bench("Header.get", function () {
// return big.get("Content-Type");
// });
bench("new Headers([])", () => {
return new Headers([]);
});
// bench("Header.set (standard)", function () {
// return big.set("Content-Type", "text/html");
// });
bench("new Headers({})", () => {
return new Headers({});
});
// bench("Header.set (non-standard)", function () {
// return big.set("X-My-Custom", "text/html123");
// });
bench("new Headers(object)", () => {
return new Headers({
"Content-Type": "text/plain",
"Content-Length": "123",
"User-Agent": "node-fetch/1.0",
});
});
bench("new Headers(hugeObject)", () => {
return new Headers({
"Accept": "123",
"Accept-Charset": "123",
"Accept-Language": "123",
"Accept-Encoding": "123",
"Accept-Ranges": "123",
"Access-Control-Allow-Credentials": "123",
"Access-Control-Allow-Headers": "123",
"Access-Control-Allow-Methods": "123",
"Access-Control-Allow-Origin": "123",
"Access-Control-Expose-Headers": "123",
"Access-Control-Max-Age": "123",
"Access-Control-Request-Headers": "123",
"Access-Control-Request-Method": "123",
"Age": "123",
"Authorization": "123",
"Cache-Control": "123",
"Connection": "123",
"Content-Disposition": "123",
"Content-Encoding": "123",
"Content-Language": "123",
"Content-Length": "123",
"Content-Location": "123",
"Content-Security-Policy": "123",
"Content-Security-Policy-Report-Only": "123",
"Content-Type": "123",
"Content-Range": "123",
"Cookie": "123",
"Cookie2": "123",
"Cross-Origin-Embedder-Policy": "123",
"Cross-Origin-Embedder-Policy-Report-Only": "123",
"Cross-Origin-Opener-Policy": "123",
"Cross-Origin-Opener-Policy-Report-Only": "123",
"Cross-Origin-Resource-Policy": "123",
"Date": "123",
"DNT": "123",
"Default-Style": "123",
"ETag": "123",
"Expect": "123",
"Expires": "123",
"Host": "123",
"If-Match": "123",
"If-Modified-Since": "123",
"If-None-Match": "123",
"If-Range": "123",
"If-Unmodified-Since": "123",
"Keep-Alive": "123",
"Last-Event-ID": "123",
"Last-Modified": "123",
"Link": "123",
"Location": "123",
"Origin": "123",
"Ping-From": "123",
"Ping-To": "123",
"Purpose": "123",
"Pragma": "123",
"Proxy-Authorization": "123",
"Range": "123",
"Referer": "123",
"Referrer-Policy": "123",
"Refresh": "123",
"Report-To": "123",
"Sec-Fetch-Dest": "123",
"Sec-Fetch-Mode": "123",
"Sec-WebSocket-Accept": "123",
"Sec-WebSocket-Extensions": "123",
"Sec-WebSocket-Key": "123",
"Sec-WebSocket-Protocol": "123",
"Sec-WebSocket-Version": "123",
"Server-Timing": "123",
"Service-Worker": "123",
"Service-Worker-Allowed": "123",
"Service-Worker-Navigation-Preload": "123",
"Set-Cookie": "123",
"Set-Cookie2": "123",
"SourceMap": "123",
"TE": "123",
"Timing-Allow-Origin": "123",
"Trailer": "123",
"Transfer-Encoding": "123",
"Upgrade": "123",
"Upgrade-Insecure-Requests": "123",
"User-Agent": "123",
"Vary": "123",
"Via": "123",
"X-Content-Type-Options": "123",
"X-DNS-Prefetch-Control": "123",
"X-Frame-Options": "123",
"X-SourceMap": "123",
"X-XSS-Protection": "123",
"X-Temp-Tablet": "123",
});
});
bench("Header.get", function () {
return big.get("Content-Type");
});
bench("Header.set (standard)", function () {
return big.set("Content-Type", "text/html");
});
bench("Header.set (non-standard)", function () {
return big.set("X-My-Custom", "text/html123");
});
if (big.toJSON)
bench("Headers.toJSON", function () {
@@ -42,4 +153,4 @@ bench("Object.fromEntries(headers)", function () {
return Object.fromEntries(big);
});
run();
await run();

View File

@@ -0,0 +1,37 @@
import { $ as zx } from "zx";
import { $ as execa$ } from "execa";
import { bench, run, group } from "./runner.mjs";
const execa = execa$({ stdio: "ignore", cwd: import.meta.dirname });
group("echo hi", () => {
if (typeof Bun !== "undefined")
bench("$`echo hi`", async () => {
await Bun.$`echo hi`.quiet();
});
bench("execa`echo hi`", async () => {
await execa`echo hi`;
});
bench("zx`echo hi`", async () => {
await zx`echo hi`.quiet();
});
});
group("ls .", () => {
if (typeof Bun !== "undefined")
bench("$`ls .`", async () => {
await Bun.$`ls .`.quiet();
});
bench("execa`ls .`", async () => {
await execa`ls .`;
});
bench("zx`ls .`", async () => {
await zx`ls .`.quiet();
});
});
await run();

View File

@@ -0,0 +1,44 @@
import { bench, run } from "./runner.mjs";
import npmStringWidth from "string-width";
const bunStringWidth = globalThis?.Bun?.stringWidth;
bench("npm/string-width (ansi + emoji + ascii)", () => {
npmStringWidth("hello there! 😀\u001b[31m😀😀");
});
bench("npm/string-width (ansi + emoji)", () => {
npmStringWidth("😀\u001b[31m😀😀");
});
bench("npm/string-width (ansi + ascii)", () => {
npmStringWidth("\u001b[31mhello there!");
});
if (bunStringWidth) {
bench("Bun.stringWidth (ansi + emoji + ascii)", () => {
bunStringWidth("hello there! 😀\u001b[31m😀😀");
});
bench("Bun.stringWidth (ansi + emoji)", () => {
bunStringWidth("😀\u001b[31m😀😀");
});
bench("Bun.stringWidth (ansi + ascii)", () => {
bunStringWidth("\u001b[31mhello there!");
});
if (npmStringWidth("😀\u001b[31m😀😀") !== bunStringWidth("😀\u001b[31m😀😀")) {
console.error("string-width mismatch");
}
if (npmStringWidth("hello there! 😀\u001b[31m😀😀") !== bunStringWidth("hello there! 😀\u001b[31m😀😀")) {
console.error("string-width mismatch");
}
if (npmStringWidth("\u001b[31mhello there!") !== bunStringWidth("\u001b[31mhello there!")) {
console.error("string-width mismatch");
}
}
await run();

View File

@@ -0,0 +1,113 @@
import { bench, run } from "./runner.mjs";
// bench("new URLSearchParams({})", () => {
// return new URLSearchParams({});
// });
bench("new URLSearchParams(obj)", () => {
return new URLSearchParams({
"Content-Type": "text/plain",
"Content-Length": "123",
"User-Agent": "node-fetch/1.0",
"Accept-Encoding": "gzip,deflate",
"Content-Length": "0",
"Content-Range": "bytes 0-9/10",
});
});
bench("new URLSearchParams(absurdlyHugeObject)", () => {
return new URLSearchParams({
"Accept": "123",
"Accept-Charset": "123",
"Accept-Language": "123",
"Accept-Encoding": "123",
"Accept-Ranges": "123",
"Access-Control-Allow-Credentials": "123",
"Access-Control-Allow-Headers": "123",
"Access-Control-Allow-Methods": "123",
"Access-Control-Allow-Origin": "123",
"Access-Control-Expose-Headers": "123",
"Access-Control-Max-Age": "123",
"Access-Control-Request-Headers": "123",
"Access-Control-Request-Method": "123",
"Age": "123",
"Authorization": "123",
"Cache-Control": "123",
"Connection": "123",
"Content-Disposition": "123",
"Content-Encoding": "123",
"Content-Language": "123",
"Content-Length": "123",
"Content-Location": "123",
"Content-Security-Policy": "123",
"Content-Security-Policy-Report-Only": "123",
"Content-Type": "123",
"Content-Range": "123",
"Cookie": "123",
"Cookie2": "123",
"Cross-Origin-Embedder-Policy": "123",
"Cross-Origin-Embedder-Policy-Report-Only": "123",
"Cross-Origin-Opener-Policy": "123",
"Cross-Origin-Opener-Policy-Report-Only": "123",
"Cross-Origin-Resource-Policy": "123",
"Date": "123",
"DNT": "123",
"Default-Style": "123",
"ETag": "123",
"Expect": "123",
"Expires": "123",
"Host": "123",
"If-Match": "123",
"If-Modified-Since": "123",
"If-None-Match": "123",
"If-Range": "123",
"If-Unmodified-Since": "123",
"Keep-Alive": "123",
"Last-Event-ID": "123",
"Last-Modified": "123",
"Link": "123",
"Location": "123",
"Origin": "123",
"Ping-From": "123",
"Ping-To": "123",
"Purpose": "123",
"Pragma": "123",
"Proxy-Authorization": "123",
"Range": "123",
"Referer": "123",
"Referrer-Policy": "123",
"Refresh": "123",
"Report-To": "123",
"Sec-Fetch-Dest": "123",
"Sec-Fetch-Mode": "123",
"Sec-WebSocket-Accept": "123",
"Sec-WebSocket-Extensions": "123",
"Sec-WebSocket-Key": "123",
"Sec-WebSocket-Protocol": "123",
"Sec-WebSocket-Version": "123",
"Server-Timing": "123",
"Service-Worker": "123",
"Service-Worker-Allowed": "123",
"Service-Worker-Navigation-Preload": "123",
"Set-Cookie": "123",
"Set-Cookie2": "123",
"SourceMap": "123",
"TE": "123",
"Timing-Allow-Origin": "123",
"Trailer": "123",
"Transfer-Encoding": "123",
"Upgrade": "123",
"Upgrade-Insecure-Requests": "123",
"User-Agent": "123",
"Vary": "123",
"Via": "123",
"X-Content-Type-Options": "123",
"X-DNS-Prefetch-Control": "123",
"X-Frame-Options": "123",
"X-SourceMap": "123",
"X-XSS-Protection": "123",
"X-Temp-Tablet": "123",
});
});
await run();

70
biome.json Normal file
View File

@@ -0,0 +1,70 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": false
},
"javascript": {
"parser": {
"unsafeParameterDecoratorsEnabled": true
},
"formatter": {
"arrowParentheses": "asNeeded",
"quoteProperties": "preserve",
"semicolons": "always",
"trailingComma": "all",
"indentStyle": "space",
"quoteStyle": "double"
}
},
"json": {
"formatter": {
"indentStyle": "space"
},
"parser": {
"allowComments": true,
"allowTrailingCommas": true
}
},
"vcs": {
"clientKind": "git",
"enabled": false,
"root": "./"
},
"files": {
"maxSize": 9128312873
},
"formatter": {
"enabled": true,
"indentWidth": 2,
"lineEnding": "lf",
"formatWithErrors": true,
"lineWidth": 120,
"indentStyle": "space",
"ignore": [
"node_modules/**",
"test/snapshots",
"test/fixtures",
".next",
"test/js/deno",
"./src/deps",
"./src/bun.js/WebKit/**",
"packages/bun-polyfills",
"./build-*",
"./build",
".cache",
"out/",
"test/transpiler/property-non-ascii-fixture.js",
"test/transpiler/macro-test.test.ts",
"test/transpiler/decorator-metadata.test.ts",
"src/react-refresh.js",
"bindings-obj/*",
"src/deps/**",
"./bench/react-hello-world/react-hello-world.node.js",
"./test/cli/run/require-cache-bug-leak-fixture-large-ast.js",
"./test/cli/run/esm-leak-fixture-large-ast.mjs"
]
}
}

View File

@@ -79,6 +79,7 @@ const BunBuildOptions = struct {
fallback_html_version: u64 = 0,
tinycc: bool = true,
project: [:0]const u8 = "",
pub fn updateRuntime(this: *BunBuildOptions) anyerror!void {
if (std.fs.cwd().openFile("src/runtime.out.js", .{ .mode = .read_only })) |file| {
@@ -192,16 +193,30 @@ pub fn build_(b: *Build) !void {
const bin_label = if (optimize == std.builtin.OptimizeMode.Debug) "packages/debug-bun-" else "packages/bun-";
var triplet_buf: [64]u8 = undefined;
var os_tagname = @tagName(target.getOs().tag);
const arch: std.Target.Cpu.Arch = target.getCpuArch();
if (std.mem.eql(u8, os_tagname, "macos")) {
os_tagname = "darwin";
target.os_version_min = std.zig.CrossTarget.OsVersion{ .semver = .{ .major = 11, .minor = 0, .patch = 0 } };
} else if (target.isLinux()) {
target.setGnuLibCVersion(2, 27, 0);
var os_tagname = @tagName(target.getOs().tag);
switch (target.getOs().tag) {
.macos => {
os_tagname = "darwin";
target.os_version_min = std.zig.CrossTarget.OsVersion{ .semver = .{ .major = 11, .minor = 0, .patch = 0 } };
},
.windows => {
target.os_version_min = std.zig.CrossTarget.OsVersion{
// Windows 1809
// Minimum version for a syscall related to bun.sys.renameat
// if you update this please update install.ps1
.windows = .win10_rs5,
};
},
.linux => {
target.setGnuLibCVersion(2, 27, 0);
},
else => {},
}
@memcpy(triplet_buf[0..].ptr, os_tagname);
const osname = triplet_buf[0..os_tagname.len];
triplet_buf[osname.len] = '-';
@@ -330,10 +345,12 @@ pub fn build_(b: *Build) !void {
obj.target.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 };
} else if (arch.isX86()) {
obj.target.cpu_model = .{ .explicit = &std.Target.x86.cpu.haswell };
} else if (arch.isAARCH64() and target.isDarwin()) {
obj.target.cpu_model = .{ .explicit = &std.Target.aarch64.cpu.apple_m1 };
} else if (arch.isAARCH64() and target.isLinux()) {
obj.target.cpu_model = .{ .explicit = &std.Target.aarch64.cpu.generic };
} else if (arch.isAARCH64()) {
if (target.isDarwin()) {
obj.target.cpu_model = .{ .explicit = &std.Target.aarch64.cpu.apple_m1 };
} else {
obj.target.cpu_model = .{ .explicit = &std.Target.aarch64.cpu.generic };
}
}
try default_build_options.updateRuntime();
@@ -362,6 +379,7 @@ pub fn build_(b: *Build) !void {
actual_build_options.sizegen = true;
}
actual_build_options.project = "bun";
obj.addOptions("build_options", actual_build_options.step(b));
// Generated Code
@@ -573,6 +591,7 @@ pub fn build_(b: *Build) !void {
\\For more info, see https://bun.sh/docs/project/contributing
\\
});
b.default_step.dependOn(&mistake_message.step);
}

BIN
bun.lockb

Binary file not shown.

View File

@@ -65,19 +65,19 @@ Below we create a new `DataView` and set the first byte to 5.
```ts
const buf = new ArrayBuffer(4);
// [0x0, 0x0, 0x0, 0x0]
// [0b00000000, 0b00000000, 0b00000000, 0b00000000]
const dv = new DataView(buf);
dv.setUint8(0, 3); // write value 3 at byte offset 0
dv.getUint8(0); // => 3
// [0x11, 0x0, 0x0, 0x0]
// [0b00000011, 0b00000000, 0b00000000, 0b00000000]
```
Now let's write a `Uint16` at byte offset `1`. This requires two bytes. We're using the value `513`, which is `2 * 256 + 1`; in bytes, that's `00000010 00000001`.
```ts
dv.setUint16(1, 513);
// [0x11, 0x10, 0x1, 0x0]
// [0b00000011, 0b00000010, 0b00000001, 0b00000000]
console.log(dv.getUint16(1)); // => 513
```

View File

@@ -249,6 +249,42 @@ writer.unref();
writer.ref();
```
## Directories
Bun's implementation of `node:fs` is fast, and we haven't implemented a Bun-specific API for reading directories just yet. For now, you should use `node:fs` for working with directories in Bun.
### Reading directories (readdir)
To read a directory in Bun, use `readdir` from `node:fs`.
```ts
import { readdir } from "node:fs/promises";
// read all the files in the current directory
const files = await readdir(import.meta.dir);
```
#### Reading directories recursively
To recursively read a directory in Bun, use `readdir` with `recursive: true`.
```ts
import { readdir } from "node:fs/promises";
// read all the files in the current directory, recursively
const files = await readdir("../", { recursive: true });
```
### Creating directories (mkdir)
To recursively create a directory, use `mkdir` in `node:fs`:
```ts
import { mkdir } from "node:fs/promises";
await mkdir("path/to/dir", { recursive: true });
```
## Benchmarks
The following is a 3-line implementation of the Linux `cat` command.

View File

@@ -7,7 +7,7 @@ Bun includes a fast native implementation of file globbing.
```ts
import { Glob } from "bun";
const glob = new Glob("*.ts");
const glob = new Glob("**/*.ts");
// Scans the current working directory and each of its sub-directories recursively
for await (const file of glob.scan(".")) {

View File

@@ -23,6 +23,11 @@ import.meta.resolveSync("zod")
---
- `import.meta.dirname`
- An alias to `import.meta.dir`, for Node.js compatibility
---
- `import.meta.file`
- The name of the current file, e.g. `index.tsx`
@@ -33,6 +38,16 @@ import.meta.resolveSync("zod")
---
- `import.meta.filename`
- An alias to `import.meta.path`, for Node.js compatibility
---
- `import.meta.url`
- A string url to the current file, e.g. `file:///path/to/project/index.tx`
---
- `import.meta.main`
- `boolean` Indicates whether the current file is the entrypoint to the current `bun` process. Is the file being directly executed by `bun run` or is it being imported?

View File

@@ -57,6 +57,23 @@ import { Database } from "bun:sqlite";
const db = new Database("mydb.sqlite", { create: true });
```
### Load via ES module import
You can also use an import attribute to load a database.
```ts
import db from "./mydb.sqlite" with {"type": "sqlite"};
console.log(db.query("select * from users LIMIT 1").get());
```
This is equivalent to the following:
```ts
import { Database } from "bun:sqlite";
const db = new Database("./mydb.sqlite");
```
### `.close()`
To close a database:

View File

@@ -56,6 +56,45 @@ const stream = new ReadableStream({
When using a direct `ReadableStream`, all chunk queueing is handled by the destination. The consumer of the stream receives exactly what is passed to `controller.write()`, without any encoding or modification.
## Async generator streams
Bun also supports async generator functions as a source for `Response` and `Request`. This is an easy way to create a `ReadableStream` that fetches data from an asynchronous source.
```ts
const response = new Response(async function* () {
yield "hello";
yield "world";
}());
await response.text(); // "helloworld"
```
You can also use `[Symbol.asyncIterator]` directly.
```ts
const response = new Response({
[Symbol.asyncIterator]: async function* () {
yield "hello";
yield "world";
},
});
await response.text(); // "helloworld"
```
If you need more granular control over the stream, `yield` will return the direct ReadableStream controller.
```ts
const response = new Response({
[Symbol.asyncIterator]: async function* () {
const controller = yield "hello";
await controller.end();
},
});
await response.text(); // "hello"
```
## `Bun.ArrayBufferSink`
The `Bun.ArrayBufferSink` class is a fast incremental writer for constructing an `ArrayBuffer` of unknown size.

View File

@@ -50,7 +50,7 @@ export default jsx(
To override the default loader specified in the `new Bun.Transpiler()` constructor, pass a second argument to `.transformSync()`.
```ts
await transpiler.transform("<div>hi!</div>", "tsx");
transpiler.transformSync("<div>hi!</div>", "tsx");
```
{% details summary="Nitty gritty" %}

View File

@@ -261,6 +261,24 @@ This function is optimized for large input. On an M1X, it processes 480 MB/s -
20 GB/s, depending on how much data is being escaped and whether there is non-ascii
text. Non-string types will be converted to a string before escaping.
## `Bun.stringWidth()`
```ts
Bun.stringWidth(input: string, options?: { countAnsiEscapeCodes?: boolean = false }): number
```
Returns the number of columns required to display a string. This is useful for aligning text in a terminal. By default, ANSI escape codes are removed before measuring the string. To include them, pass `{ countAnsiEscapeCodes: true }` as the second argument.
```ts
Bun.stringWidth("hello"); // => 5
Bun.stringWidth("\u001b[31mhello\u001b[0m"); // => 5
Bun.stringWidth("\u001b[31mhello\u001b[0m", { countAnsiEscapeCodes: true }); // => 12
```
Compared with the popular `string-width` npm package, `bun`'s implementation is > [100x faster](https://github.com/oven-sh/bun/blob/8abd1fb088bcf2e78bd5d0d65ba4526872d2ab61/bench/snippets/string-width.mjs#L22)
<!-- ## `Bun.enableANSIColors()` -->
## `Bun.fileURLToPath()`

View File

@@ -182,12 +182,12 @@ const server = Bun.serve<{ username: string }>({
open(ws) {
const msg = `${ws.data.username} has entered the chat`;
ws.subscribe("the-group-chat");
ws.publish("the-group-chat", msg);
server.publish("the-group-chat", msg);
},
message(ws, message) {
// this is a group chat
// so the server re-broadcasts incoming message to everyone
ws.publish("the-group-chat", `${ws.data.username}: ${message}`);
server.publish("the-group-chat", `${ws.data.username}: ${message}`);
},
close(ws) {
const msg = `${ws.data.username} has left the chat`;
@@ -245,6 +245,34 @@ The `.send(message)` method of `ServerWebSocket` returns a `number` indicating t
This gives you better control over backpressure in your server.
### Timeouts and limits
By default, Bun will close a WebSocket connection if it is idle for 120 seconds. This can be configured with the `idleTimeout` parameter.
```ts
Bun.serve({
fetch(req, server) {}, // upgrade logic
websocket: {
idleTimeout: 60, // 60 seconds
// ...
},
});
```
Bun will also close a WebSocket connection if it receives a message that is larger than 16 MB. This can be configured with the `maxPayloadLength` parameter.
```ts
Bun.serve({
fetch(req, server) {}, // upgrade logic
websocket: {
maxPayloadLength: 1024 * 1024, // 1 MB
// ...
},
});
```
## Connect to a `Websocket` server
Bun implements the `WebSocket` class. To create a WebSocket client that connects to a `ws://` or `wss://` server, create an instance of `WebSocket`, as you would in the browser.
@@ -296,6 +324,14 @@ namespace Bun {
close?: (ws: ServerWebSocket) => void;
error?: (ws: ServerWebSocket, error: Error) => void;
drain?: (ws: ServerWebSocket) => void;
maxPayloadLength?: number; // default: 16 * 1024 * 1024 = 16 MB
idleTimeout?: number; // default: 120 (seconds)
backpressureLimit?: number; // default: 1024 * 1024 = 1 MB
closeOnBackpressureLimit?: boolean; // default: false
sendPings?: boolean; // default: true
publishToSelf?: boolean; // default: false
perMessageDeflate?:
| boolean
| {

View File

@@ -32,6 +32,25 @@ All imported files and packages are bundled into the executable, along with a co
{% /callout %}
## SQLite
You can use `bun:sqlite` imports with `bun build --compile`.
By default, the database is resolved relative to the current working directory of the process.
```js
import db from './my.db' with {type: "sqlite"};
console.log(db.query("select * from users LIMIT 1").get());
```
That means if the executable is located at `/usr/bin/hello`, the user's terminal is located at `/home/me/Desktop`, it will look for `/home/me/Desktop/my.db`.
```
$ cd /home/me/Desktop
$ ./hello
```
## Embedding files
Standalone executables support embedding files.
@@ -55,6 +74,30 @@ You may need to specify a `--loader` for it to be treated as a `"file"` loader (
Embedded files can be read using `Bun.file`'s functions or the Node.js `fs.readFile` function (in `"node:fs"`).
### Embedding SQLite databases
If your application wants to embed a SQLite database, set `type: "sqlite"` in the import attribute and the `embed` attribute to `"true"`.
```js
import myEmbeddedDb from "./my.db" with {type: "sqlite", embed: "true"};
console.log(myEmbeddedDb.query("select * from users LIMIT 1").get());
```
This database is read-write, but all changes are lost when the executable exits (since it's stored in memory).
### Embedding N-API Addons
As of Bun v1.0.23, you can embed `.node` files into executables.
```js
const addon = require("./addon.node");
console.log(addon.hello());
```
Unfortunately, if you're using `@mapbox/node-pre-gyp` or other similar tools, you'll need to make sure the `.node` file is directly required or it won't bundle correctly.
## Minification
To trim down the size of the executable a little, pass `--minify` to `bun build --compile`. This uses Bun's minifier to reduce the code size. Overall though, Bun's binary is still way too big and we need to make it smaller.

View File

@@ -43,7 +43,7 @@ Let's build our first bundle. You have the following two files, which implement
import * as ReactDOM from 'react-dom/client';
import {Component} from "./Component"
const root = ReactDOM.createRoot(document.getElementById('root'));
const root = ReactDOM.createRoot(document.getElementById('root')!);
root.render(<Component message="Sup!" />)
```
@@ -155,7 +155,7 @@ Like the Bun runtime, the bundler supports an array of file types out of the box
---
- `.js` `.cjs` `.mjs` `.mts` `.cts` `.ts` `.tsx`
- `.js` `.jsx`, `.cjs` `.mjs` `.mts` `.cts` `.ts` `.tsx`
- Uses Bun's built-in transpiler to parse the file and transpile TypeScript/JSX syntax to vanilla JavaScript. The bundler executes a set of default transforms, including dead code elimination, tree shaking, and environment variable inlining. At the moment Bun does not attempt to down-convert syntax; if you use recently ECMAScript syntax, that will be reflected in the bundled code.
---

View File

@@ -171,6 +171,41 @@ console.log(addon);
In the bundler, `.node` files are handled using the [`file`](#file) loader.
### `sqlite`
**SQLite loader**. `with { "type": "sqlite" }` import attribute
In the runtime and bundler, SQLite databases can be directly imported. This will load the database using [`bun:sqlite`](/docs/api/sqlite.md).
```ts
import db from "./my.db" with {type: "sqlite"};
```
This is only supported when the `target` is `bun`.
By default, the database is external to the bundle (so that you can potentially use a database loaded elsewhere), so the database file on-disk won't be bundled into the final output.
You can change this behavior with the `"embed"` attribute:
```ts
// embed the database into the bundle
import db from "./my.db" with {type: "sqlite", embed: "true"};
```
When using a [standalone executable](/docs/bundler/executables), the database is embedded into the single-file executable.
Otherwise, the database to embed is copied into the `outdir` with a hashed filename.
### `bunshell` loader
**Bun Shell loader**. Default for `.bun.sh` files
This loader is used to parse [Bun Shell](/docs/runtime/shell) scripts. It's only supported when starting bun itself, so it's not available in the bundler or in the runtime.
```sh
$ bun run ./script.bun.sh
```
### `file`
**File loader**. Default for all unrecognized file types.

View File

@@ -1,116 +0,0 @@
Bundling is currently an important mechanism for building complex web apps.
Modern apps typically consist of a large number of files and package dependencies. Despite the fact that modern browsers support [ES Module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) imports, it's still too slow to fetch each file via individual HTTP requests. _Bundling_ is the process of concatenating several source files into a single large file that can be loaded in a single request.
{% callout %}
**On bundling** — Despite recent advances like [`modulepreload`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/modulepreload) and [HTTP/3](https://en.wikipedia.org/wiki/HTTP/3), bundling is still the most performant approach.
{% /callout %}
## Bundling your app
Bun's approach to bundling is a little different from other bundlers. Start by passing your app's entrypoint to `bun bun`.
```bash
$ bun bun ./app.js
```
Your entrypoint can be any `js|jsx|ts|tsx|html` file. With this file as a starting point, Bun will construct a graph of imported files and packages, transpile everything, and generate a file called `node_modules.bun`.
## What is `.bun`?
{% callout %}
**Note** — [This format may change soon](https://github.com/oven-sh/bun/issues/121)
{% /callout %}
A `.bun` file contains the pre-transpiled source code of your application, plus a bunch of binary-encoded metadata about your application's structure. as a contains:
- all the bundled source code
- all the bundled source code metadata
- project metadata & configuration
Here are some of the questions `.bun` files answer:
- when I import `react/index.js`, where in the `.bun` is the code for that? (not resolving, just the code)
- what modules of a package are used?
- what framework is used? (e.g., Next.js)
- where is the routes directory?
- how big is each imported dependency?
- what is the hash of the bundles contents? (for etags)
- what is the name & version of every npm package exported in this bundle?
- what modules from which packages are used in this project? ("project" is defined as all the entry points used to generate the .bun)
All in one file.
Its a little like a build cache, but designed for reuse across builds.
{% details summary="Position-independent code" %}
From a design perspective, the most important part of the `.bun` format is how code is organized. Each module is exported by a hash like this:
```js
// preact/dist/preact.module.js
export var $eb6819b = $$m({
"preact/dist/preact.module.js": (module, exports) => {
let n, l, u, i, t, o, r, f, e = {}, c = [], s = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
// ... rest of code
```
This makes bundled modules [position-independent](https://en.wikipedia.org/wiki/Position-independent_code). In theory, one could import only the exact modules in-use without reparsing code and without generating a new bundle. One bundle can dynamically become many bundles comprising only the modules in use on the webpage. Thanks to the metadata with the byte offsets, a web server can send each module to browsers [zero-copy](https://en.wikipedia.org/wiki/Zero-copy) using [sendfile](https://man7.org/linux/man-pages/man2/sendfile.2.html). Bun itself is not quite this smart yet, but these optimizations would be useful in production and potentially very useful for React Server Components.
To see the schema inside, have a look at [`JavascriptBundleContainer`](./src/api/schema.d.ts#:~:text=export%20interface-,JavascriptBundleContainer,-%7B). You can find JavaScript bindings to read the metadata in [src/api/schema.js](./src/api/schema.js). This is not really an API yet. Its missing the part where it gets the binary data from the bottom of the file. Someday, I want this to be usable by other tools too.
{% /details %}
## Where is the code?
`.bun` files are marked as executable.
To print out the code, run `./node_modules.bun` in your terminal or run `bun ./path-to-node_modules.bun`.
Here is a copy-pastable example:
```bash
$ ./node_modules.bun > node_modules.js
```
This works because every `.bun` file starts with this:
```
#!/usr/bin/env bun
```
To deploy to production with Bun, youll want to get the code from the `.bun` file and stick that somewhere your web server can find it (or if youre using Vercel or a Rails app, in a `public` folder).
Note that `.bun` is a binary file format, so just opening it in VSCode or vim might render strangely.
## Advanced
By default, `bun bun` only bundles external dependencies that are `import`ed or `require`d in either app code or another external dependency. An "external dependency" is defined as, "A JavaScript-like file that has `/node_modules/` in the resolved file path and a corresponding `package.json`".
To force Bun to bundle packages which are not located in a `node_modules` folder (i.e., the final, resolved path following all symlinks), add a `bun` section to the root projects `package.json` with `alwaysBundle` set to an array of package names to always bundle. Heres an example:
```json
{
"name": "my-package-name-in-here",
"bun": {
"alwaysBundle": ["@mybigcompany/my-workspace-package"]
}
}
```
Bundled dependencies are not eligible for Hot Module Reloading. The code is served to browsers & Bun.js verbatim. But, in the future, it may be sectioned off into only parts of the bundle being used. Thats possible in the current version of the `.bun` file (so long as you know which files are necessary), but its not implemented yet. Longer-term, it will include all `import` and `export` of each module inside.
## What is the module ID hash?
The `$eb6819b` hash used here:
```js
export var $eb6819b = $$m({
```
Is generated like this:
1. Murmur3 32-bit hash of `package.name@package.version`. This is the hash uniquely identifying the npm package.
2. Wyhash 64 of the `package.hash` + `package_path`. `package_path` means "relative to the root of the npm package, where is the module imported?". For example, if you imported `react/jsx-dev-runtime.js`, the `package_path` is `jsx-dev-runtime.js`. `react-dom/cjs/react-dom.development.js` would be `cjs/react-dom.development.js`
3. Truncate the hash generated above to a `u32`
The implementation details of this module ID hash will vary between versions of Bun. The important part is the metadata contains the module IDs, the package paths, and the package hashes, so it shouldnt really matter in practice if other tooling wants to make use of any of this.

View File

@@ -63,6 +63,12 @@ $ bunx --bun my-cli # good
$ bunx my-cli --bun # bad
```
To force bun to always be used with a script, use a shebang.
```
#!/usr/bin/env bun
```
<!-- ## Environment variables
Bun automatically loads environment variables from `.env` files before running a file, script, or executable. The following files are checked, in order:

View File

@@ -35,6 +35,6 @@ It creates:
If you pass `-y` or `--yes`, it will assume you want to continue without asking questions.
At the end, it runs `bun install` to install `bun-types`.
At the end, it runs `bun install` to install `@types/bun`.
{% /details %}

View File

@@ -103,7 +103,7 @@ Bun supports the following lifecycle hooks:
| `afterEach` | Runs after each test. |
| `afterAll` | Runs once after all tests. |
These hooks can be define inside test files, or in a separate file that is preloaded with the `--preload` flag.
These hooks can be defined inside test files, or in a separate file that is preloaded with the `--preload` flag.
```ts
$ bun test --preload ./setup.ts
@@ -113,17 +113,13 @@ See [Test > Lifecycle](/docs/test/lifecycle) for complete documentation.
## Mocks
{% callout %}
Module mocking (`jest.mock()`) is not yet supported. Track support for it [here](https://github.com/oven-sh/bun/issues/5394).
{% /callout %}
Create mock functions with the `mock` function. Mocks are automatically reset between tests.
```ts
import { test, expect, mock } from "bun:test";
const random = mock(() => Math.random());
test("random", async () => {
test("random", () => {
const val = random();
expect(val).toBeGreaterThan(0);
expect(random).toHaveBeenCalled();
@@ -151,7 +147,7 @@ Snapshots are supported by `bun test`.
// example usage of toMatchSnapshot
import { test, expect } from "bun:test";
test("snapshot", async () => {
test("snapshot", () => {
expect({ a: 1 }).toMatchSnapshot();
});
```

View File

@@ -1,5 +1,5 @@
---
name: Convert a Uint8Array to a string
name: Convert a DataView to a string
---
If a [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) contains ASCII-encoded text, you can convert it to a string using the [`TextDecoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder) class.

View File

@@ -21,7 +21,8 @@ $ bun init
Then install the Prisma CLI (`prisma`) and Prisma Client (`@prisma/client`) as dependencies.
```bash
$ bun add prisma @prisma/client
$ bun add -d prisma
$ bun add @prisma/client
```
---

View File

@@ -0,0 +1,46 @@
---
name: Common HTTP server usage
---
This starts an HTTP server listening on port `3000`. It demonstates basic routing with a number of common responses and also handles POST data from standard forms or as JSON.
See [`Bun.serve`](/docs/api/http) for details.
```ts
const server = Bun.serve({
async fetch (req) {
const path = new URL(req.url).pathname;
// respond with text/html
if (path === "/") return new Response("Welcome to Bun!");
// redirect
if (path === "/abc") return Response.redirect("/source", 301);
// send back a file (in this case, *this* file)
if (path === "/source") return new Response(Bun.file(import.meta.file));
// respond with JSON
if (path === "/api") return Response.json({ some: "buns", for: "you" });
// receive JSON data to a POST request
if (req.method === "POST" && path === "/api/post") {
const data = await req.json();
console.log("Received JSON:", data);
return Response.json({ success: true, data });
}
// receive POST data from a form
if (req.method === "POST" && path === "/form") {
const data = await req.formData();
console.log(data.get("someField"));
return new Response("Success");
}
// 404s
return new Response("Page not found", { status: 404 });
}
})
console.log(`Listening on ${server.url}`);
```

View File

@@ -19,4 +19,39 @@ $ bun run cli.tsx --flag1 --flag2 value
---
To parse `argv` into a more useful format, consider using [minimist](https://github.com/minimistjs/minimist) or [commander](https://github.com/tj/commander.js).
To parse `argv` into a more useful format, `util.parseArgs` would be helpful.
Example:
```ts#cli.ts
import { parseArgs } from "util";
const { values, positionals } = parseArgs({
args: Bun.argv,
options: {
flag1: {
type: 'boolean',
},
flag2: {
type: 'string',
},
},
strict: true,
allowPositionals: true,
});
console.log(values);
console.log(positionals);
```
then it outputs
```
$ bun run cli.tsx --flag1 --flag2 value
{
flag1: true,
flag2: "value",
}
[ "/path/to/bun", "/path/to/cli.ts" ]
```

View File

@@ -15,13 +15,13 @@ Below is the full set of recommended `compilerOptions` for a Bun project. With t
```jsonc
{
"compilerOptions": {
// enable latest features
// Enable latest features
"lib": ["ESNext"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx", // support JSX
"allowJs": true, // allow importing `.js` from `.ts`
"jsx": "react-jsx",
"allowJs": true,
// Bundler mode
"moduleResolution": "bundler",
@@ -32,12 +32,11 @@ Below is the full set of recommended `compilerOptions` for a Bun project. With t
// Best practices
"strict": true,
"skipLibCheck": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
// Some stricter flags
"useUnknownInCatchVariables": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noPropertyAccessFromIndexSignature": true
}
}

View File

@@ -93,7 +93,7 @@ $ bun test --timeout 10000
Many other flags become irrelevant or obsolete when using `bun test`.
- `transform` — Buns supports TypeScript & JSX. Other file types can be configured with [Plugins](/docs/runtime/plugins).
- `transform` — Bun supports TypeScript & JSX. Other file types can be configured with [Plugins](/docs/runtime/plugins).
- `extensionsToTreatAsEsm`
- `haste` — Bun uses it's own internal source maps
- `watchman`, `watchPlugins`, `watchPathIgnorePatterns` — use `--watch` to run tests in watch mode

View File

@@ -20,11 +20,11 @@ const server = Bun.serve<{ username: string }>({
open(ws) {
const msg = `${ws.data.username} has entered the chat`;
ws.subscribe("the-group-chat");
ws.publish("the-group-chat", msg);
server.publish("the-group-chat", msg);
},
message(ws, message) {
// the server re-broadcasts incoming messages to everyone
ws.publish("the-group-chat", `${ws.data.username}: ${message}`);
server.publish("the-group-chat", `${ws.data.username}: ${message}`);
},
close(ws) {
const msg = `${ws.data.username} has left the chat`;

View File

@@ -39,6 +39,10 @@ $ proto install bun
### Windows
{% callout %}
Bun requires a minimum of Windows 10 version 1809
{% /callout %}
Bun provides a _limited, experimental_ native build for Windows. It is recommended to use Bun within [Windows Subsystem for Linux](https://learn.microsoft.com/en-us/windows/wsl/install) and follow the above instructions. To help catch bugs, the experimental build enables many debugging assertions, which will make the binary slower than what the stable version will be.
To install, paste this into a terminal:
@@ -229,6 +233,10 @@ If you need to remove Bun from your system, use the following commands.
$ rm -rf ~/.bun # for macOS, Linux, and WSL
```
```bash#Windows
$ Remove-Item ~\.bun -Recurse
```
```bash#NPM
$ npm uninstall -g bun
```

View File

@@ -116,6 +116,9 @@ export default {
page("runtime/nodejs-apis", "Node.js compatibility", {
description: `Bun aims for full Node.js compatibility. This page tracks the current compatibility status.`,
}),
page("bundler/executables", "Single-file executable", {
description: "Compile a TypeScript or JavaScript file to a standalone executable",
}),
page("runtime/plugins", "Plugins", {
description: `Implement custom loaders and module resolution logic with Bun's plugin system.`,
}),
@@ -204,9 +207,6 @@ export default {
page("bundler/plugins", "Plugins", {
description: `Implement custom loaders and module resolution logic with Bun's plugin system.`,
}),
page("bundler/executables", "Executables", {
description: "Compile a TypeScript or JavaScript file to a standalone executable",
}),
page("bundler/macros", "Macros", {
description: `Run JavaScript functions at bundle-time and inline the results into your bundle`,
}),
@@ -309,6 +309,9 @@ export default {
page("api/globals", "Globals", {
description: `Bun implements a range of Web APIs, Node.js APIs, and Bun-native APIs that are available in the global scope.`,
}), // "`Bun.write`"),
page("runtime/shell", "$ Shell", {
description: `Bun's cross-platform shell-scripting API makes shell scripting with JavaScript fun`,
}), // "`Bun.$`"),
page("api/spawn", "Child processes", {
description: `Spawn sync and async child processes with easily configurable input and output streams.`,
}), // "`Bun.spawn`"),
@@ -366,6 +369,9 @@ export default {
page("project/contributing", "Contributing", {
description: "Learn how to contribute to Bun and get your local development environment up and running.",
}),
page("project/building-windows", "Building Windows", {
description: "Learn how to setup a development environment for contributing to the Windows build of Bun.",
}),
page("project/licensing", "License", {
description: `Bun is a MIT-licensed project with a large number of statically-linked dependencies with various licenses.`,
}),

View File

@@ -1,13 +1,15 @@
The following document is not yet complete, please join the [#windows channel on our Discord](http://bun.sh/discord) for help.
This document describes the build process for Windows. If you run into problems, please join the [#windows channel on our Discord](http://bun.sh/discord) for help.
It is strongly recommended to use [PowerShell 7 (`pwsh.exe`)](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.4) instead of the default `powershell.exe`.
## Prerequisites
<!--
{% details summary="Extra notes for Bun Core Team Members" %}
Here are the extra steps I ran on my fresh windows machine (some of these are a little opiniated)
- Change user to a local account (set username to `window` and empty password)
- (Empty password will disable the password and auto-login on boot)
- Change user to a local account (set username to `window` and 'bun!')
- Set Windows Terminal as default terminal
- Install latest version of Powershell
- Display scale to 100%
@@ -30,17 +32,11 @@ Here are the extra steps I ran on my fresh windows machine (some of these are a
I recommend using VSCode through SSH instead of Tunnels or the Tailscale extension, it seems to be more reliable.
{% /details %}
Make sure to use powershell with the proper shell environment loaded. To do so, you can run:
```ps1
.\scripts\env.ps1
```
{% /details %} -->
### Enable Scripts
By default, scripts are blocked.
By default, running unverified scripts are blocked.
```ps1
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
@@ -48,8 +44,14 @@ Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
### System Dependencies
- Bun 1.1 or later. We use Bun to run it's own code generators.
```ps1
irm bun.sh/install.ps1 | iex
```
- [Visual Studio](https://visualstudio.microsoft.com) with the "Desktop Development with C++" workload.
- Install Git and CMake from here, if not already installed.
- Install Git and CMake from this installer, if not already installed.
After Visual Studio, you need the following:
@@ -59,25 +61,31 @@ After Visual Studio, you need the following:
- NASM
- Perl
- Ruby
- Node.js (until bun is stable enough on windows)
- Node.js
[Scoop](https://scoop.sh) can be used to install these easily.
{% callout %}
The Zig compiler is automatically downloaded, installed, and updated by the building process.
{% /callout %}
[Scoop](https://scoop.sh) can be used to install these remaining tools easily:
```ps1
irm https://get.scoop.sh | iex
```bash
scoop install nodejs-lts go rust nasm ruby perl
scoop llvm@16.0.4 # scoop bug if you install llvm and the rest at the same time
```
If you intend on building WebKit locally (optional), you should install some more packages:
If you intend on building WebKit locally (optional), you should install these packages:
```bash
```ps1
scoop install make cygwin python
```
From here on out, it is **expected you use a Developer PowerShell Terminal with `.\scripts\env.ps1 sourced**. This script is available in the Bun repository and can be loaded by executing it.
From here on out, it is **expected you use a PowerShell Terminal with `.\scripts\env.ps1` sourced**. This script is available in the Bun repository and can be loaded by executing it:
```ps1
$ .\scripts\env.ps1
.\scripts\env.ps1
```
To verify, you can check for an MSVC-only command line such as `mt.exe`
@@ -86,55 +94,55 @@ To verify, you can check for an MSVC-only command line such as `mt.exe`
Get-Command mt
```
### Zig
Bun pins a version of Zig. As the compiler is still in development, breaking changes happen often that will break the build. It is recommended to use [Zigup](https://github.com/marler8997/zigup/releases) as it can quickly switch to any version by name, but you can also [manually download Zig](https://ziglang.org/download/).
```bash
$ zigup 0.12.0-dev.1604+caae40c21
```
{% callout %}
We last updated Zig on **October 26th, 2023**
It is not recommended to install `ninja` / `cmake` into your global path, because you may run into a situation where you try to build bun without .\scripts\env.ps1 sourced.
{% /callout %}
### Codegen
On Unix platforms, we depend on an existing build of Bun to generate code for itself. Since the Windows build is not stable enough for this to run the code generators, you currently need to use another computer or WSL to generate this:
```bash
$ wsl --install # run twice if it doesnt install
# in the linux environment
$ sudo apt install unzip
$ curl -fsSL https://bun.sh/install | bash
```
Whenever codegen-related things are updated, please re-run
```ps1
$ .\scripts\codegen.ps1
```
## Building
```ps1
npm install
bun install
.\scripts\env.ps1
.\scripts\update-submodules.ps1
.\scripts\all-dependencies.ps1
.\scripts\codegen.ps1
.\scripts\update-submodules.ps1 # this syncs git submodule state
.\scripts\all-dependencies.ps1 # this builds all dependencies
.\scripts\make-old-js.ps1 # runs some old code generators
cd build # this was created by the codegen.ps1 script in the prerequisites
# Configure build environment
cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Debug
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug
ninja
# Build bun
ninja -Cbuild
```
If this was successful, you should have a `bun-debug.exe` in the `build` folder.
```ps1
.\bun-debug.exe --version
.\build\bun-debug.exe --revision
```
You should add this to `$Env:PATH`. The simplest way to do so is to open the start menu, type "Path", and then navigate the environment variables menu to add `C:\.....\bun\build` to the user environment variable `PATH`. You should then restart your editor (if it does not update still, log out and log back in).
## Extra paths
- WebKit is extracted to `build/bun-webkit`
- Zig is extracted to `.cache/zig/zig.exe`
## Tests
You can run the test suite either using `bun test`, or by using the wrapper script `packages\bun-internal-test`. The internal test package is a wrapper cli to run every test file in a separate instance of bun.exe, to prevent a crash in the test runner from stopping the entire suite.
```ps1
# Setup
bun i --cwd packages\bun-internal-test
# Run the entire test suite with reporter
# the package.json script "test" uses "build/bun-debug.exe" by default
bun run test
# Run an individual test file:
bun-debug test node\fs
bun-debug test "C:\bun\test\js\bun\resolve\import-meta.test.js"
```
## Troubleshooting

View File

@@ -105,6 +105,8 @@ $ export PATH="$PATH:/usr/lib/llvm16/bin"
{% /codetabs %}
> ⚠️ Ubuntu distributions may require installation of the C++ standard library independently. See the [troubleshooting section](#span-file-not-found-on-ubuntu) for more information.
## Building Bun
After cloning the repository, run the following command to run the first build. This may take a while as it will clone submodules and build dependencies.
@@ -252,6 +254,16 @@ fatal error: 'span' file not found
^~~~~~
```
The issue may manifest when initially running `bun setup` as Clang being unable to compile a simple program:
```
The C++ compiler
"/usr/bin/clang++-16"
is not able to compile a simple test program.
```
To fix the error, we need to update the GCC version to 11. To do this, we'll need to check if the latest version is available in the distribution's official repositories or use a third-party repository that provides GCC 11 packages. Here are general steps:
```bash

View File

@@ -45,18 +45,25 @@ console.log(`Listening on http://localhost:${server.port} ...`);
{% details summary="Seeing TypeScript errors on `Bun`?" %}
If you used `bun init`, Bun will have automatically installed Bun's TypeScript declarations and configured your `tsconfig.json`. If you're trying out Bun in an existing project, you may see a type error on the `Bun` global.
To fix this, first install `bun-types` as a dev dependency.
To fix this, first install `@types/bun` as a dev dependency.
```sh
$ bun add -d bun-types
$ bun add -d @types/bun
```
Then add the following line to your `compilerOptions` in `tsconfig.json`.
Then add the following to your `compilerOptions` in `tsconfig.json`:
```json-diff#tsconfig.json
```json#tsconfig.json
{
"compilerOptions": {
+ "types": ["bun-types"]
"lib": ["ESNext"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
}
}
```
@@ -85,7 +92,7 @@ Bun can also execute `"scripts"` from your `package.json`. Add the following scr
+ "start": "bun run index.ts"
+ },
"devDependencies": {
"bun-types": "^0.7.0"
"@types/bun": "^1.0.0"
}
}
```
@@ -117,12 +124,12 @@ Update `index.ts` to use `figlet` in the `fetch` handler.
+ import figlet from "figlet";
const server = Bun.serve({
fetch() {
port: 3000,
fetch(req) {
+ const body = figlet.textSync("Bun!");
+ return new Response(body);
- return new Response("Bun!");
},
port: 3000,
});
```

View File

@@ -298,7 +298,7 @@ Valid values are:
---
- `"fallback"`
- Check local `node_modules` first, the auto-install any packages that aren't found. You can enable this from the CLI with `bun -i`.
- Check local `node_modules` first, then auto-install any packages that aren't found. You can enable this from the CLI with `bun -i`.
{% /table %}

View File

@@ -80,6 +80,17 @@ $ bun run ./my-wasm-app.whatever
**Note** — WASI support is based on [wasi-js](https://github.com/sagemathinc/cowasm/tree/main/core/wasi-js). Currently, it only supports WASI binaries that use the `wasi_snapshot_preview1` or `wasi_unstable` APIs. Bun's implementation is not fully optimized for performance; this will become more of a priority as WASM grows in popularity.
{% /callout %}
## SQLite
You can import sqlite databases directly into your code. Bun will automatically load the database and return a `Database` object.
```ts
import db from "./my.db" with {type: "sqlite"};
console.log(db.query("select * from users LIMIT 1").get());
```
This uses [`bun:sqlite`](/docs/api/sqlite).
## Custom loaders
Support for additional file types can be implemented with plugins. Refer to [Runtime > Plugins](/docs/bundler/plugins) for full documentation.

View File

@@ -52,11 +52,11 @@ Some methods are not optimized yet.
### [`node:events`](https://nodejs.org/api/events.html)
🟡 Missing `on` `addAbortListener` `getMaxListeners`
🟡 Missing `addAbortListener` `events.getMaxListeners`
### [`node:fs`](https://nodejs.org/api/fs.html)
🟡 Missing `Dir` `fdatasync` `fdatasyncSync` `openAsBlob` `opendir` `opendirSync` `statfs` `statfsSync`. `fs.promises.open` incorrectly returns a file descriptor instead of a `FileHandle`.
🟡 Missing `Dir` `openAsBlob` `opendir` `opendirSync` `statfs` `statfsSync`
### [`node:http`](https://nodejs.org/api/http.html)
@@ -76,11 +76,11 @@ Some methods are not optimized yet.
### [`node:module`](https://nodejs.org/api/module.html)
🟢 Missing `runMain` `syncBuiltinESMExports`, `Module#load()`. Attempts to override or patch the module cache will fail.
🟡 Missing `runMain` `syncBuiltinESMExports`, `Module#load()`. Attempts to override or patch the module cache will fail.
### [`node:net`](https://nodejs.org/api/net.html)
🟡 Missing `BlockList` `SocketAddress` `Stream` `getDefaultAutoSelectFamily` `getDefaultAutoSelectFamilyAttemptTimeout` `setDefaultAutoSelectFamily` `setDefaultAutoSelectFamilyAttemptTimeout` `Server#ref()` `Server#unref()` `Socket#ref()` `Socket#unref()`.
🟡 Missing `BlockList` `SocketAddress` `Stream` `getDefaultAutoSelectFamily` `getDefaultAutoSelectFamilyAttemptTimeout` `setDefaultAutoSelectFamily` `setDefaultAutoSelectFamilyAttemptTimeout`
### [`node:os`](https://nodejs.org/api/os.html)
@@ -92,7 +92,7 @@ Some methods are not optimized yet.
### [`node:perf_hooks`](https://nodejs.org/api/perf_hooks.html)
🟡 Only `perf_hooks.performance.now()` and `perf_hooks.performance.timeOrigin` are implemented. Missing `Performance` `PerformanceMark` `PerformanceMeasure` `PerformanceObserverEntryList` `PerformanceResourceTiming` `createHistogram` `monitorEventLoopDelay`. It's recommended to use `performance` global instead of `perf_hooks.performance`.
🟡 Missing `createHistogram` `monitorEventLoopDelay`. It's recommended to use `performance` global instead of `perf_hooks.performance`.
### [`node:process`](https://nodejs.org/api/process.html)
@@ -116,7 +116,7 @@ Some methods are not optimized yet.
### [`node:stream`](https://nodejs.org/api/stream.html)
🟡 Missing `getDefaultHighWaterMark` `setDefaultHighWaterMark`
🟡 Missing `getDefaultHighWaterMark` `setDefaultHighWaterMark` `toWeb`
### [`node:string_decoder`](https://nodejs.org/api/string_decoder.html)
@@ -168,7 +168,7 @@ Some methods are not optimized yet.
### [`node:worker_threads`](https://nodejs.org/api/worker_threads.html)
🟡 `Worker` doesn't support the following options: `eval` `argv` `execArgv` `stdin` `stdout` `stderr` `trackedUnmanagedFds` `resourceLimits`. Missing `markAsUntransferable` `moveMessagePortToContext` `getHeapSnapshot`.
🟡 `Worker` doesn't support the following options: `eval` `stdin` `stdout` `stderr` `trackedUnmanagedFds` `resourceLimits`. Missing `markAsUntransferable` `moveMessagePortToContext` `getHeapSnapshot`.
### [`node:zlib`](https://nodejs.org/api/zlib.html)
@@ -312,23 +312,23 @@ The table below lists all globals implemented by Node.js and Bun's current compa
### [`PerformanceEntry`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry)
🔴 Not implemented.
🟢 Fully implemented.
### [`PerformanceMark`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMark)
🔴 Not implemented.
🟢 Fully implemented.
### [`PerformanceMeasure`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMeasure)
🔴 Not implemented.
🟢 Fully implemented.
### [`PerformanceObserver`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver)
🔴 Not implemented.
🟢 Fully implemented.
### [`PerformanceObserverEntryList`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserverEntryList)
🔴 Not implemented.
🟢 Fully implemented.
### [`PerformanceResourceTiming`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming)
@@ -340,7 +340,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa
### [`process`](https://nodejs.org/api/process.html)
🟡 Missing `domain` `hasUncaughtExceptionCaptureCallback` `initgroups` `report` `resourceUsage` `setUncaughtExceptionCaptureCallback` `setegid` `seteuid` `setgid` `setgroups` `setuid` `allowedNodeEnvironmentFlags` `getActiveResourcesInfo` `setActiveResourcesInfo` `moduleLoadList` `setSourceMapsEnabled` `channel`. `process.binding` is partially implemented.
🟡 Missing `domain` `hasUncaughtExceptionCaptureCallback` `initgroups` `resourceUsage` `setUncaughtExceptionCaptureCallback` `setegid` `seteuid` `setgid` `setgroups` `setuid` `allowedNodeEnvironmentFlags` `getActiveResourcesInfo` `setActiveResourcesInfo` `moduleLoadList` `setSourceMapsEnabled` `channel`. `process.binding` is partially implemented.
### [`queueMicrotask()`](https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask)
@@ -356,11 +356,11 @@ The table below lists all globals implemented by Node.js and Bun's current compa
### [`ReadableStreamBYOBReader`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBReader)
🔴 Not implemented.
🟢 Fully implemented.
### [`ReadableStreamBYOBRequest`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBRequest)
🔴 Not implemented.
🟢 Fully implemented.
### [`ReadableStreamDefaultController`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultController)

View File

@@ -67,13 +67,12 @@ plugin({
name: "YAML",
async setup(build) {
const { load } = await import("js-yaml");
const { readFileSync } = await import("fs");
// when a .yaml file is imported...
build.onLoad({ filter: /\.(yaml|yml)$/ }, (args) => {
build.onLoad({ filter: /\.(yaml|yml)$/ }, async (args) => {
// read and parse the file
const text = readFileSync(args.path, "utf8");
const text = await Bun.file(args.path).text();
const exports = load(text) as Record<string, any>;
// and returns it as a module
@@ -184,13 +183,12 @@ plugin({
name: "svelte loader",
async setup(build) {
const { compile } = await import("svelte/compiler");
const { readFileSync } = await import("fs");
// when a .svelte file is imported...
build.onLoad({ filter: /\.svelte$/ }, ({ path }) => {
build.onLoad({ filter: /\.svelte$/ }, async ({ path }) => {
// read and compile it with the Svelte compiler
const file = readFileSync(path, "utf8");
const file = await Bun.file(path).text();
const contents = compile(file, {
filename: path,
generate: "ssr",
@@ -216,7 +214,7 @@ With this plugin, Svelte components can now be directly imported and consumed.
import "./sveltePlugin.ts";
import MySvelteComponent from "./component.svelte";
console.log(mySvelteComponent.render());
console.log(MySvelteComponent.render());
```
## Virtual Modules
@@ -239,7 +237,7 @@ plugin({
setup(build) {
build.module(
// The specifier, which can be any string
// The specifier, which can be any string - except a built-in, such as "buffer"
"my-transpiled-virtual-module",
// The callback to run when the module is imported or required for the first time
() => {

370
docs/runtime/shell.md Normal file
View File

@@ -0,0 +1,370 @@
Bun Shell makes shell scripting with JavaScript & TypeScript fun. It's a cross-platform bash-like shell with seamless JavaScript interop.
{% callout type="note" %}
**Alpha-quality software**: Bun Shell is an unstable API still under development. If you have feature requests or run into bugs, please open an issue. There may be breaking changes in the future.
{% /callout %}
Quickstart:
```js
import { $ } from "bun";
const response = await fetch("https://example.com");
// Use Response as stdin.
await $`echo < ${response} > wc -c`; // 120
```
## Features:
- **Cross-platform**: works on Windows, Linux & macOS. Instead of `rimraf` or `cross-env`', you can use Bun Shell without installing extra dependencies. Common shell commands like `ls`, `cd`, `rm` are implemented natively.
- **Familiar**: Bun Shell is a bash-like shell, supporting redirection, pipes, environment variables and more.
- **Globs**: Glob patterns are supported natively, including `**`, `*`, `{expansion}`, and more.
- **Template literals**: Template literals are used to execute shell commands. This allows for easy interpolation of variables and expressions.
- **Safety**: Bun Shell escapes all strings by default, preventing shell injection attacks.
- **JavaScript interop**: Use `Response`, `ArrayBuffer`, `Blob`, `Bun.file(path)` and other JavaScript objects as stdin, stdout, and stderr.
## Getting started
The simplest shell command is `echo`. To run it, use the `$` template literal tag:
```js
import { $ } from "bun";
await $`echo "Hello World!"`; // Hello World!
```
By default, shell commands print to stdout. To quiet the output, call `.quiet()`:
```js
import { $ } from "bun";
await $`echo "Hello World!"`.quiet(); // No output
```
What if you want to access the output of the command as text? Use `.text()`:
```js
import { $ } from "bun";
// .text() automatically calls .quiet() for you
const welcome = await $`echo "Hello World!"`.text();
console.log(welcome); // Hello World!\n
```
To get stdout, stderr, and the exit code, use await or `.run`:
```js
import { $ } from "bun";
const { stdout, stderr, exitCode } = await $`echo "Hello World!"`.quiet();
console.log(stdout); // Buffer(6) [ 72, 101, 108, 108, 111, 32 ]
console.log(stderr); // Buffer(0) []
console.log(exitCode); // 0
```
## Redirection
Bun Shell supports redirection with `<`, `>`, and `|` operators.
### To JavaScript objects (`>`)
To redirect stdout to a JavaScript object, use the `>` operator:
```js
import { $ } from "bun";
const buffer = Buffer.alloc(100);
const result = await $`echo "Hello World!" > ${buffer}`;
console.log(result.exitCode); // 0
console.log(buffer.toString()); // Hello World!\n
```
The following JavaScript objects are supported for redirection to:
- `Buffer`, `Uint8Array`, `Uint16Array`, `Uint32Array`, `Int8Array`, `Int16Array`, `Int32Array`, `Float32Array`, `Float64Array`, `ArrayBuffer`, `SharedArrayBuffer` (writes to the underlying buffer)
- `Bun.file(path)`, `Bun.file(fd)` (writes to the file)
### From JavaScript objects (`<`)
To redirect the output from JavaScript objects to stdin, use the `<` operator:
```js
import { $, file } from "bun";
const response = new Response("hello i am a response body");
const result = await $`cat < ${response}`.text();
console.log(result); // hello i am a response body
```
The following JavaScript objects are supported for redirection from:
- `Buffer`, `Uint8Array`, `Uint16Array`, `Uint32Array`, `Int8Array`, `Int16Array`, `Int32Array`, `Float32Array`, `Float64Array`, `ArrayBuffer`, `SharedArrayBuffer` (reads from the underlying buffer)
- `Bun.file(path)`, `Bun.file(fd)` (reads from the file)
- `Response` (reads from the body)
### Piping (`|`)
Like in bash, you can pipe the output of one command to another:
```js
import { $ } from "bun";
const result = await $`echo "Hello World!" | wc -w`.text();
console.log(result); // 2\n
```
You can also pipe with JavaScript objects:
```js
import { $ } from "bun";
const response = new Response("hello i am a response body");
const result = await $`cat < ${response} | wc -w`.text();
console.log(result); // 6\n
```
## Environment variables
Environment variables can be set like in bash:
```js
import { $ } from "bun";
await $`FOO=foo bun -e 'console.log(process.env.FOO)'`; // foo\n
```
You can use string interpolation to set environment variables:
```js
import { $ } from "bun";
const foo = "bar123";
await $`FOO=${foo + "456"} bun -e 'console.log(process.env.FOO)'`; // bar123456\n
```
Input is escaped by default, preventing shell injection attacks:
```js
import { $ } from "bun";
const foo = "bar123; rm -rf /tmp";
await $`FOO=${foo} bun -e 'console.log(process.env.FOO)'`; // bar123; rm -rf /tmp\n
```
### Changing the environment variables
By default, `process.env` is used as the environment variables for all commands.
You can change the environment variables for a single command by calling `.env()`:
```js
import { $ } from "bun";
await $`echo $FOO`.env({ ...process.env, FOO: "bar" }); // bar
```
You can change the default environment variables for all commands by calling `$.env`:
```js
import { $ } from "bun";
$.env({ FOO: "bar" });
// the globally-set $FOO
await $`echo $FOO`; // bar
// the locally-set $FOO
await $`echo $FOO`.env({ FOO: "baz" }); // baz
```
You can reset the environment variables to the default by calling `$.env()` with no arguments:
```js
import { $ } from "bun";
$.env({ FOO: "bar" });
// the globally-set $FOO
await $`echo $FOO`; // bar
// the locally-set $FOO
await $`echo $FOO`.env(undefined); // ""
```
### Changing the working directory
You can change the working directory of a command by passing a string to `.cwd()`:
```js
import { $ } from "bun";
await $`pwd`.cwd("/tmp"); // /tmp
```
You can change the default working directory for all commands by calling `$.cwd`:
```js
import { $ } from "bun";
$.cwd("/tmp");
// the globally-set working directory
await $`pwd`; // /tmp
// the locally-set working directory
await $`pwd`.cwd("/"); // /
```
## Reading output
To read the output of a command as a string, use `.text()`:
```js
import { $ } from "bun";
const result = await $`echo "Hello World!"`.text();
console.log(result); // Hello World!\n
```
### Reading output as JSON
To read the output of a command as JSON, use `.json()`:
```js
import { $ } from "bun";
const result = await $`echo '{"foo": "bar"}'`.json();
console.log(result); // { foo: "bar" }
```
### Reading output line-by-line
To read the output of a command line-by-line, use `.lines()`:
```js
import { $ } from "bun";
for await (let line of $`echo "Hello World!"`.lines()) {
console.log(line); // Hello World!
}
```
You can also use `.lines()` on a completed command:
```js
import { $ } from "bun";
const search = "bun";
for await (let line of $`cat list.txt | grep ${search}`.lines()) {
console.log(line);
}
```
### Reading output as a Blob
To read the output of a command as a Blob, use `.blob()`:
```js
import { $ } from "bun";
const result = await $`echo "Hello World!"`.blob();
console.log(result); // Blob(13) { size: 13, type: "text/plain" }
```
## Builtin Commands
For cross-platform compatibility, Bun Shell implements a set of builtin commands, in addition to reading commands from the PATH environment variable.
- `cd`: change the working directory
- `ls`: list files in a directory
- `rm`: remove files and directories
- `echo`: print text
- `pwd`: print the working directory
- `bun`: run bun in bun
**Partially** implemented:
- `mv`: move files and directories (missing cross-device support)
**Not** implemented yet, but planned:
- `mkdir`: create directories
- `cp`: copy files and directories
- `cat`: concatenate files
## Utilities
Bun Shell also implements a set of utilities for working with shells.
### `$.braces` (brace expansion)
This function implements simple [brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html) for shell commands:
```js
import { $ } from "bun";
await $.braces(`echo {1,2,3}`);
// => ["echo 1", "echo 2", "echo 3"]
```
### `$.escape` (escape strings)
Exposes Bun Shell's escaping logic as a function:
```js
import { $ } from "bun";
console.log($.escape('$(foo) `bar` "baz"'))
// => \$(foo) \`bar\` \"baz\"
```
If you do not want your string to be escaped, wrap it in a `{ raw: 'str' }` object:
```js
import { $ } from "bun";
await $`echo ${{ raw: '$(foo) `bar` "baz"' }}`
// => bun: command not found: foo
// => bun: command not found: bar
// => baz
```
## .bun.sh file loader
For simple shell scripts, instead of `sh`, you can use Bun Shell to run shell scripts.
To do that, run any file with bun that ends with `.bun.sh`:
```sh
$ echo "echo Hello World!" > script.bun.sh
$ bun ./script.bun.sh
> Hello World!
```
On Windows, Bun Shell is used automatically to run `.sh` files when using Bun:
```sh
$ echo "echo Hello World!" > script.sh
# On windows, .bun.sh is not needed, just .sh
$ bun ./script.sh
> Hello World!
```
## Credits
Large parts of this API were inspired by [zx](https://github.com/google/zx), [dax](https://github.com/dsherret/dax), and [bnx](https://github.com/wobsoriano/bnx). Thank you to the authors of those projects.

View File

@@ -52,7 +52,7 @@ It is possible to specify a coverage threshold in `bunfig.toml`. If your test su
coverageThreshold = 0.9
# to set different thresholds for lines and functions
coverageThreshold = { line = 0.9, function = 0.9 }
coverageThreshold = { lines = 0.9, functions = 0.9 }
```
### Sourcemaps

View File

@@ -60,7 +60,7 @@ test("unlike in jest", () => {
To reset the system time, pass no arguments to `setSystemTime`:
```ts
import { setSystemTime, beforeAll } from "bun:test";
import { setSystemTime, expect, test } from "bun:test";
test("it was 2020, for a moment.", () => {
// Set it to something!

View File

@@ -109,7 +109,7 @@ $ bun test --todo
## `test.only`
To run a particular test or suite of tests use `test.only()` or `describe.only()`. Once declared, running `bun test --only` will only execute tests/suites that have been marked with `.only()`.
To run a particular test or suite of tests use `test.only()` or `describe.only()`. Once declared, running `bun test --only` will only execute tests/suites that have been marked with `.only()`. Running `bun test` without the `--only` option with `test.only()` declared will result in all tests in the given suite being executed _up to_ the test with `.only()`. `describe.only()` functions the same in both execution scenarios.
```ts
import { test, describe } from "bun:test";
@@ -135,6 +135,12 @@ The following command will only execute tests #2 and #3.
$ bun test --only
```
The following command will only execute tests #1, #2 and #3.
```sh
$ bun test
```
## `test.if`
To run a test conditionally, use `test.if()`. The test will run if the condition is truthy. This is particularly useful for tests that should only run on specific architectures or operating systems.
@@ -301,7 +307,7 @@ Bun implements the following matchers. Full Jest compatibility is on the roadmap
---
-
-
- [`.extend`](https://jestjs.io/docs/expect#expectextendmatchers)
---

View File

@@ -16,9 +16,9 @@ If you see an error like this:
![image](https://user-images.githubusercontent.com/709451/141210854-89434678-d21b-42f4-b65a-7df3b785f7b9.png)
It usually means the max number of open file descriptors is being explicitly set to a low number. By default, Bun requests the max number of file descriptors available (which on macOS, is something like 32,000). But, if you previously ran into ulimit issues with, e.g., Chokidar, someone on The Internet may have advised you to run `ulimit -n 8096`.
It usually means the max number of open file descriptors is being explicitly set to a low number. By default, Bun requests the max number of file descriptors available (which on macOS, is something like 32,000). But, if you previously ran into ulimit issues with, e.g., Chokidar, someone on The Internet may have advised you to run `ulimit -n 8192`.
That advice unfortunately **lowers** the hard limit to `8096`. This can be a problem in large repositories or projects with lots of dependencies. Chokidar (and other watchers) dont seem to call `setrlimit`, which means theyre reliant on the (much lower) soft limit.
That advice unfortunately **lowers** the hard limit to `8192`. This can be a problem in large repositories or projects with lots of dependencies. Chokidar (and other watchers) dont seem to call `setrlimit`, which means theyre reliant on the (much lower) soft limit.
To fix this issue:

View File

@@ -17,13 +17,13 @@ Bun supports things like top-level await, JSX, and extensioned `.ts` imports, wh
```jsonc
{
"compilerOptions": {
// enable latest features
// Enable latest features
"lib": ["ESNext"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx", // support JSX
"allowJs": true, // allow importing `.js` from `.ts`
"jsx": "react-jsx",
"allowJs": true,
// Bundler mode
"moduleResolution": "bundler",
@@ -34,18 +34,17 @@ Bun supports things like top-level await, JSX, and extensioned `.ts` imports, wh
// Best practices
"strict": true,
"skipLibCheck": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
// Some stricter flags
"useUnknownInCatchVariables": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noPropertyAccessFromIndexSignature": true
}
}
```
If you run `bun init` in a new directory, this `tsconfig.json` will be generated for you.
If you run `bun init` in a new directory, this `tsconfig.json` will be generated for you. (The stricter flags are disabled by default.)
```sh
$ bun init

192
misctools/ntquery.cpp Normal file
View File

@@ -0,0 +1,192 @@
#include <ntstatus.h>
#include <stdio.h>
#include <windows.h>
#include <winternl.h>
typedef struct _FILE_DIRECTORY_INFORMATION {
ULONG NextEntryOffset;
ULONG FileIndex;
LARGE_INTEGER CreationTime;
LARGE_INTEGER LastAccessTime;
LARGE_INTEGER LastWriteTime;
LARGE_INTEGER ChangeTime;
LARGE_INTEGER EndOfFile;
LARGE_INTEGER AllocationSize;
ULONG FileAttributes;
ULONG FileNameLength;
WCHAR FileName[1];
} FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION;
typedef struct _FILE_BOTH_DIR_INFORMATION {
ULONG NextEntryOffset;
ULONG FileIndex;
LARGE_INTEGER CreationTime;
LARGE_INTEGER LastAccessTime;
LARGE_INTEGER LastWriteTime;
LARGE_INTEGER ChangeTime;
LARGE_INTEGER EndOfFile;
LARGE_INTEGER AllocationSize;
ULONG FileAttributes;
ULONG FileNameLength;
ULONG EaSize;
CHAR ShortNameLength;
WCHAR ShortName[12];
WCHAR FileName[1];
} FILE_BOTH_DIR_INFORMATION, *PFILE_BOTH_DIR_INFORMATION;
int main_using_file_directory_information(int argc, char *argv[]) {
if (argc != 2) {
printf("Usage: ntquery <filename>\n");
return 1;
}
auto *NtQueryDirectoryFile = (NTSTATUS(WINAPI *)(
HANDLE, HANDLE, PVOID, PVOID, PVOID, PVOID, DWORD, FILE_INFORMATION_CLASS,
BOOLEAN, PVOID, BOOLEAN))GetProcAddress(GetModuleHandle("ntdll.dll"),
"NtQueryDirectoryFile");
if (NtQueryDirectoryFile == NULL) {
printf("Error getting NtQueryDirectoryFile\n");
return 1;
}
// open the current working directory using NT API
HANDLE hFile = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
// use NtQueryDirectoryFile
char buffer[64096];
IO_STATUS_BLOCK ioStatusBlock;
NTSTATUS status = NtQueryDirectoryFile(
hFile, NULL, NULL, NULL, &ioStatusBlock, buffer, sizeof(buffer),
FileDirectoryInformation, FALSE, NULL, FALSE);
if (status != STATUS_SUCCESS) {
printf("Error querying directory\n");
return 1;
}
PFILE_DIRECTORY_INFORMATION pDirInfo = (PFILE_DIRECTORY_INFORMATION)buffer;
while (TRUE) {
printf("%S\n", pDirInfo->FileName);
if (pDirInfo->NextEntryOffset == 0) {
// if no more entries, continue to next query directory call
status = NtQueryDirectoryFile(
hFile, NULL, NULL, NULL, &ioStatusBlock, buffer, sizeof(buffer),
FileDirectoryInformation, FALSE, NULL, FALSE);
pDirInfo = (PFILE_DIRECTORY_INFORMATION)buffer;
if (status == STATUS_NO_MORE_FILES) {
break;
} else if (status != STATUS_SUCCESS) {
printf("Error querying directory: %x\n", status);
return 1;
} else {
continue;
}
}
pDirInfo = (PFILE_DIRECTORY_INFORMATION)((LPBYTE)pDirInfo +
pDirInfo->NextEntryOffset);
}
CloseHandle(hFile);
return 0;
}
#define FileBothDirectoryInformation static_cast<FILE_INFORMATION_CLASS>(3)
int main_using_file_both_information(int argc, char *argv[]) {
if (argc != 2) {
printf("Usage: ntquery <filename>\n");
return 1;
}
auto *NtQueryDirectoryFile = (NTSTATUS(WINAPI *)(
HANDLE, HANDLE, PVOID, PVOID, PVOID, PVOID, DWORD, FILE_INFORMATION_CLASS,
BOOLEAN, PVOID, BOOLEAN))GetProcAddress(GetModuleHandle("ntdll.dll"),
"NtQueryDirectoryFile");
if (NtQueryDirectoryFile == NULL) {
printf("Error getting NtQueryDirectoryFile\n");
return 1;
}
// open the current working directory using NT API
HANDLE hFile = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
// use NtQueryDirectoryFile
char buffer[64096];
IO_STATUS_BLOCK ioStatusBlock;
NTSTATUS status = NtQueryDirectoryFile(
hFile, NULL, NULL, NULL, &ioStatusBlock, buffer, sizeof(buffer),
FileBothDirectoryInformation, FALSE, NULL, FALSE);
if (status != STATUS_SUCCESS) {
printf("Error querying directory\n");
return 1;
}
PFILE_BOTH_DIR_INFORMATION pDirInfo = (PFILE_BOTH_DIR_INFORMATION)buffer;
while (TRUE) {
printf("%S\n", pDirInfo->FileName);
if (pDirInfo->NextEntryOffset == 0) {
// if no more entries, continue to next query directory call
status = NtQueryDirectoryFile(
hFile, NULL, NULL, NULL, &ioStatusBlock, buffer, sizeof(buffer),
FileBothDirectoryInformation, FALSE, NULL, FALSE);
pDirInfo = (PFILE_BOTH_DIR_INFORMATION)buffer;
if (status == STATUS_NO_MORE_FILES) {
break;
} else if (status != STATUS_SUCCESS) {
printf("Error querying directory: %x\n", status);
return 1;
} else {
continue;
}
}
pDirInfo = (PFILE_BOTH_DIR_INFORMATION)((LPBYTE)pDirInfo +
pDirInfo->NextEntryOffset);
}
CloseHandle(hFile);
return 0;
}
int main_using_findfirstfile_ex(int argc, char *argv[]) {
if (argc != 2) {
printf("Usage: ntquery <filename>\n");
return 1;
}
// open the current working directory using NT API
HANDLE hFile = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
char buffer[64096];
WIN32_FIND_DATA findData;
HANDLE hFind = FindFirstFileEx(argv[1], FindExInfoBasic, &findData,
FindExSearchNameMatch, NULL, 0);
if (hFind == INVALID_HANDLE_VALUE) {
printf("Error querying directory\n");
return 1;
}
do {
char szPath[MAX_PATH];
printf("%s\n", findData.cFileName);
} while (FindNextFile(hFind, &findData));
FindClose(hFind);
return 0;
}
int main(int argc, char *argv[]) {
return main_using_findfirstfile_ex(argc, argv);
}

View File

@@ -20,7 +20,7 @@ pub fn main() anyerror!void {
Output.Source.set(&output_source);
defer Output.flush();
var args_buffer: [8096 * 2]u8 = undefined;
var args_buffer: [8192 * 2]u8 = undefined;
var fixed_buffer = std.heap.FixedBufferAllocator.init(&args_buffer);
var allocator = fixed_buffer.allocator();

View File

@@ -20,7 +20,7 @@ pub fn main() anyerror!void {
Output.Source.set(&output_source);
defer Output.flush();
var args_buffer: [8096 * 2]u8 = undefined;
var args_buffer: [8192 * 2]u8 = undefined;
var fixed_buffer = std.heap.FixedBufferAllocator.init(&args_buffer);
var allocator = fixed_buffer.allocator();

View File

@@ -1,19 +1,25 @@
{
"private": true,
"name": "bun",
"dependencies": {
"@biomejs/biome": "1.5.3",
"@vscode/debugadapter": "^1.61.0",
"esbuild": "^0.17.15",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.5.0",
"mitata": "^0.1.3",
"peechy": "0.4.34",
"prettier": "^2.4.1",
"prettier": "3.2.2",
"react": "next",
"react-dom": "next",
"source-map-js": "^1.0.2",
"typescript": "^5.0.2"
},
"private": true,
"devDependencies": {
"@types/react": "^18.0.25",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0"
},
"scripts": {
"setup": "./scripts/setup.sh",
"build": "if [ ! -e build ]; then bun setup; fi && ninja -C build",
@@ -21,16 +27,12 @@
"build:release": "cmake . -DCMAKE_BUILD_TYPE=Release -GNinja -Bbuild-release && ninja -Cbuild-release",
"build:safe": "cmake . -DZIG_OPTIMIZE=ReleaseSafe -DUSE_DEBUG_JSC=ON -DCMAKE_BUILD_TYPE=Release -GNinja -Bbuild-safe && ninja -Cbuild-safe",
"typecheck": "tsc --noEmit && cd test && bun run typecheck",
"fmt": "prettier --write --cache './{src,test,bench,packages/{bun-types,bun-inspector-*,bun-vscode,bun-debug-adapter-protocol}}/**/*.{mjs,ts,tsx,js,jsx}'",
"fmt:zig": "zig fmt src/*.zig src/**/*.zig",
"fmt": "biome format --write {.vscode,src,test,bench,packages/{bun-types,bun-inspector-*,bun-vscode,bun-debug-adapter-protocol}}",
"fmt:zig": "zig fmt src/*.zig src/*/*.zig src/*/*/*.zig src/*/*/*/*.zig",
"lint": "eslint './**/*.d.ts' --cache",
"lint:fix": "eslint './**/*.d.ts' --cache --fix"
},
"devDependencies": {
"@types/react": "^18.0.25",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0"
},
"version": "0.0.0",
"prettier": "./.prettierrc.cjs"
"lint:fix": "eslint './**/*.d.ts' --cache --fix",
"test": "node packages/bun-internal-test/src/runner.node.mjs ./build/bun-debug",
"test:release": "node packages/bun-internal-test/src/runner.node.mjs ./build-release/bun",
"update-known-failures": "node packages/bun-internal-test/src/update-known-windows-failures.mjs"
}
}

View File

@@ -2215,7 +2215,7 @@ export namespace DAP {
*/
instructionReference: string;
/**
* The offset from the instruction reference.
* The offset from the instruction reference in bytes.
* This can be negative.
*/
offset?: number;
@@ -2278,6 +2278,13 @@ export namespace DAP {
* This can be negative.
*/
offset?: number;
/**
* A machine-readable explanation of why a breakpoint may not be verified. If a breakpoint is verified or a specific reason is not known, the adapter should omit this property. Possible values include:
*
* - `pending`: Indicates a breakpoint might be verified in the future, but the adapter cannot verify it in the current state.
* - `failed`: Indicates a breakpoint was not able to be verified, and the adapter does not believe it can be verified without intervention.
*/
reason?: "pending" | "failed";
};
/**
* The granularity of one 'step' in the stepping requests `next`, `stepIn`, `stepOut`, and `stepBack`.
@@ -2587,6 +2594,12 @@ export namespace DAP {
* The end column of the range that corresponds to this instruction, if any.
*/
endColumn?: number;
/**
* A hint for how to present the instruction in the UI.
*
* A value of `invalid` may be used to indicate this instruction is 'filler' and cannot be reached by the program. For example, unreadable memory addresses may be presented is 'invalid.'
*/
presentationHint?: "normal" | "invalid";
};
/**
* Logical areas that can be invalidated by the `invalidated` event.

View File

@@ -3420,7 +3420,7 @@
},
"offset": {
"type": "integer",
"description": "The offset from the instruction reference.\nThis can be negative."
"description": "The offset from the instruction reference in bytes.\nThis can be negative."
},
"condition": {
"type": "string",
@@ -3467,6 +3467,11 @@
"offset": {
"type": "integer",
"description": "The offset from the instruction reference.\nThis can be negative."
},
"reason": {
"type": "string",
"description": "A machine-readable explanation of why a breakpoint may not be verified. If a breakpoint is verified or a specific reason is not known, the adapter should omit this property. Possible values include:\n\n- `pending`: Indicates a breakpoint might be verified in the future, but the adapter cannot verify it in the current state.\n - `failed`: Indicates a breakpoint was not able to be verified, and the adapter does not believe it can be verified without intervention.",
"enum": ["pending", "failed"]
}
},
"required": ["verified"]
@@ -3750,6 +3755,11 @@
"endColumn": {
"type": "integer",
"description": "The end column of the range that corresponds to this instruction, if any."
},
"presentationHint": {
"type": "string",
"description": "A hint for how to present the instruction in the UI.\n\nA value of `invalid` may be used to indicate this instruction is 'filler' and cannot be reached by the program. For example, unreadable memory addresses may be presented is 'invalid.'",
"enum": ["normal", "invalid"]
}
},
"required": ["address", "instruction"]

View File

@@ -11,11 +11,7 @@ import type {
StackFrame,
WebsocketMessageBuildFailure,
} from "../../src/api/schema";
import {
messagesToMarkdown,
problemsToMarkdown,
withBunInfo,
} from "./markdown";
import { messagesToMarkdown, problemsToMarkdown, withBunInfo } from "./markdown";
import { fetchAllMappings, remapPosition, sourceMappings } from "./sourcemap";
export enum StackFrameScope {
@@ -82,9 +78,7 @@ enum ErrorTagType {
}
const ErrorTag = ({ type }: { type: ErrorTagType }) => (
<div className={`BunError-ErrorTag BunError-ErrorTag--${ErrorTagType[type]}`}>
{ErrorTagType[type]}
</div>
<div className={`BunError-ErrorTag BunError-ErrorTag--${ErrorTagType[type]}`}>{ErrorTagType[type]}</div>
);
const errorTags = [
@@ -133,11 +127,7 @@ function hasColumnOrLine(filename: string) {
return /:\d+/.test(filename);
}
function appendLineColumnIfNeeded(
base: string,
line?: number,
column?: number,
) {
function appendLineColumnIfNeeded(base: string, line?: number, column?: number) {
if (hasColumnOrLine(base)) return base;
return appendLineColumn(base, line, column);
@@ -155,11 +145,7 @@ function appendLineColumn(base: string, line?: number, column?: number) {
return base;
}
const blobFileURL = (
filename: string,
line?: number,
column?: number,
): string => {
const blobFileURL = (filename: string, line?: number, column?: number): string => {
var base = `/blob:${filename}`;
base = appendLineColumnIfNeeded(base, line, column);
@@ -167,11 +153,7 @@ const blobFileURL = (
return new URL(base, globalThis.location.href).href;
};
const maybeBlobFileURL = (
filename: string,
line?: number,
column?: number,
): string => {
const maybeBlobFileURL = (filename: string, line?: number, column?: number): string => {
if (filename.includes(".bun")) {
return blobFileURL(filename, line, column);
}
@@ -183,9 +165,7 @@ const maybeBlobFileURL = (
return srcFileURL(filename, line, column);
};
const openWithoutFlashOfNewTab: React.MouseEventHandler<HTMLAnchorElement> = (
event,
) => {
const openWithoutFlashOfNewTab: React.MouseEventHandler<HTMLAnchorElement> = event => {
const target = event.currentTarget;
const href = target.getAttribute("href");
if (!href || event.button !== 0) {
@@ -216,18 +196,13 @@ const openWithoutFlashOfNewTab: React.MouseEventHandler<HTMLAnchorElement> = (
})
.then(
() => {},
(er) => {},
er => {},
);
return false;
};
const srcFileURL = (
filename: string,
line?: number,
column?: number,
): string => {
if (filename.startsWith("http://") || filename.startsWith("https://"))
return appendLineColumnIfNeeded(filename);
const srcFileURL = (filename: string, line?: number, column?: number): string => {
if (filename.startsWith("http://") || filename.startsWith("https://")) return appendLineColumnIfNeeded(filename);
if (filename.endsWith(".bun")) {
return new URL("/" + filename, globalThis.location.href).href;
@@ -272,10 +247,7 @@ class FancyTypeError {
const nextWord = /(["a-zA-Z0-9_\.]+)\)$/.exec(partial);
if (nextWord && nextWord[0]) {
this.runtimeTypeName = nextWord[0];
this.runtimeTypeName = this.runtimeTypeName.substring(
0,
this.runtimeTypeName.length - 1,
);
this.runtimeTypeName = this.runtimeTypeName.substring(0, this.runtimeTypeName.length - 1);
switch (this.runtimeTypeName.toLowerCase()) {
case "undefined": {
this.runtimeType = RuntimeType.Undefined;
@@ -312,15 +284,12 @@ class FancyTypeError {
}
}
this.message = exception.message.substring(0, i);
this.message = this.message.substring(
0,
this.message.lastIndexOf("(In "),
);
this.message = this.message.substring(0, this.message.lastIndexOf("(In "));
}
}
}
export const clientURL = (filename) => {
export const clientURL = filename => {
if (filename.includes(".bun")) {
return `/${filename.replace(/^(\/)?/g, "")}`;
}
@@ -368,22 +337,17 @@ const AsyncSourceLines = ({
Accept: "text/plain",
},
})
.then((resp) => {
.then(resp => {
return resp.text();
})
.then((text) => {
.then(text => {
if (cancelled) return;
// TODO: make this faster
const lines = text.split("\n");
const startLineNumber = Math.max(
Math.min(Math.max(highlight - 4, 0), lines.length - 1),
0,
);
const startLineNumber = Math.max(Math.min(Math.max(highlight - 4, 0), lines.length - 1), 0);
const endLineNumber = Math.min(startLineNumber + 8, lines.length);
const sourceLines: SourceLine[] = new Array(
endLineNumber - startLineNumber,
);
const sourceLines: SourceLine[] = new Array(endLineNumber - startLineNumber);
var index = 0;
for (let i = startLineNumber; i < endLineNumber; i++) {
const currentLine = lines[i - 1];
@@ -394,14 +358,10 @@ const AsyncSourceLines = ({
};
}
setSourceLines(
index !== sourceLines.length
? sourceLines.slice(0, index)
: sourceLines,
);
setSourceLines(index !== sourceLines.length ? sourceLines.slice(0, index) : sourceLines);
setLoadState(LoadState.loaded);
})
.catch((err) => {
.catch(err => {
if (!cancelled) {
console.error(err);
setLoadState(LoadState.failed);
@@ -499,8 +459,7 @@ const SourceLines = ({
}
}
const leftPad =
maxLineNumber.toString(10).length - minLineNumber.toString(10).length;
const leftPad = maxLineNumber.toString(10).length - minLineNumber.toString(10).length;
const _sourceLines = sourceLines.slice(start, end);
const lines = new Array(_sourceLines.length + React.Children.count(children));
@@ -520,15 +479,10 @@ const SourceLines = ({
data-line={line}
data-column={classes.highlight ? highlightColumnStart : dedent}
title={`Open line ${line} in editor`}
href={buildURL(
line,
classes.highlight ? highlightColumnStart : dedent,
)}
href={buildURL(line, classes.highlight ? highlightColumnStart : dedent)}
onClickCapture={openWithoutFlashOfNewTab}
key={"highlight-number-" + line}
className={`BunError-SourceLine-number ${
classes.empty ? "BunError-SourceLine-number--empty" : ""
} ${
className={`BunError-SourceLine-number ${classes.empty ? "BunError-SourceLine-number--empty" : ""} ${
classes.highlight ? "BunError-SourceLine-number--highlight" : ""
}`}
>
@@ -536,9 +490,9 @@ const SourceLines = ({
</a>
<div
tabIndex={i}
className={`BunError-SourceLine-text ${
classes.empty ? "BunError-SourceLine-text--empty" : ""
} ${classes.highlight ? "BunError-SourceLine-text--highlight" : ""}`}
className={`BunError-SourceLine-text ${classes.empty ? "BunError-SourceLine-text--empty" : ""} ${
classes.highlight ? "BunError-SourceLine-text--highlight" : ""
}`}
>
{_text}
</div>
@@ -549,9 +503,7 @@ const SourceLines = ({
return (
<IndentationContext.Provider value={dedent}>
<div className="BunError-SourceLines">
<div
className={`BunError-SourceLines-highlighter--${highlightI}`}
></div>
<div className={`BunError-SourceLines-highlighter--${highlightI}`}></div>
{lines}
</div>
@@ -568,10 +520,7 @@ const BuildErrorSourceLines = ({
}) => {
const { line, line_text, column } = location;
const sourceLines: SourceLine[] = [{ line, text: line_text }];
const buildURL = React.useCallback(
(line, column) => srcFileURL(filename, line, column),
[srcFileURL, filename],
);
const buildURL = React.useCallback((line, column) => srcFileURL(filename, line, column), [srcFileURL, filename]);
return (
<SourceLines
sourceLines={sourceLines}
@@ -613,8 +562,7 @@ export const StackFrameIdentifier = ({
}) => {
switch (scope) {
case StackFrameScope.Constructor: {
functionName =
markdown && functionName ? "`" + functionName + "`" : functionName;
functionName = markdown && functionName ? "`" + functionName + "`" : functionName;
return functionName ? `new ${functionName}` : "new (anonymous)";
}
@@ -636,16 +584,12 @@ export const StackFrameIdentifier = ({
case StackFrameScope.Function:
default: {
return functionName
? markdown
? "`" + functionName + "`"
: functionName
: "λ()";
return functionName ? (markdown ? "`" + functionName + "`" : functionName) : "λ()";
}
}
};
const getNativeStackFrameIdentifier = (frame) => {
const getNativeStackFrameIdentifier = frame => {
const { file, function_name: functionName, scope } = frame;
return StackFrameIdentifier({
@@ -673,11 +617,7 @@ const NativeStackFrame = ({
} = frame;
const fileName = normalizedFilename(file, cwd);
return (
<div
className={`BunError-StackFrame ${
fileName.endsWith(".bun") ? "BunError-StackFrame--muted" : ""
}`}
>
<div className={`BunError-StackFrame ${fileName.endsWith(".bun") ? "BunError-StackFrame--muted" : ""}`}>
<div
title={StackFrameScope[scope]}
className="BunError-StackFrame-identifier"
@@ -700,9 +640,7 @@ const NativeStackFrame = ({
<div className="BunError-StackFrame-link-content">
<div className={`BunError-StackFrame-file`}>{fileName}</div>
{line > -1 && <div className="BunError-StackFrame-line">:{line}</div>}
{column > -1 && (
<div className="BunError-StackFrame-column">:{column}</div>
)}
{column > -1 && <div className="BunError-StackFrame-column">:{column}</div>}
</div>
</a>
</div>
@@ -714,21 +652,11 @@ const NativeStackFrames = ({ frames, urlBuilder }) => {
var maxLength = 0;
for (let i = 0; i < frames.length; i++) {
maxLength = Math.max(
getNativeStackFrameIdentifier(frames[i]).length,
maxLength,
);
maxLength = Math.max(getNativeStackFrameIdentifier(frames[i]).length, maxLength);
}
for (let i = 0; i < frames.length; i++) {
items[i] = (
<NativeStackFrame
maxLength={maxLength}
urlBuilder={urlBuilder}
key={i}
frame={frames[i]}
/>
);
items[i] = <NativeStackFrame maxLength={maxLength} urlBuilder={urlBuilder} key={i} frame={frames[i]} />;
}
return (
@@ -756,10 +684,7 @@ const NativeStackTrace = ({
const filename = normalizedFilename(file, cwd);
const urlBuilder = isClient ? clientURL : maybeBlobFileURL;
const ref = React.useRef<HTMLDivElement>(null);
const buildURL = React.useCallback(
(line, column) => urlBuilder(file, line, column),
[file, urlBuilder],
);
const buildURL = React.useCallback((line, column) => urlBuilder(file, line, column), [file, urlBuilder]);
return (
<div ref={ref} className={`BunError-NativeStackTrace`}>
@@ -797,9 +722,7 @@ const NativeStackTrace = ({
{children}
</AsyncSourceLines>
)}
{frames.length > 1 && (
<NativeStackFrames urlBuilder={urlBuilder} frames={frames} />
)}
{frames.length > 1 && <NativeStackFrames urlBuilder={urlBuilder} frames={frames} />}
</div>
);
};
@@ -822,9 +745,7 @@ const JSException = ({
isClient: boolean;
}) => {
const tag = isClient ? ErrorTagType.client : ErrorTagType.server;
const [sourceLines, _setSourceLines] = React.useState(
value?.stack?.source_lines ?? [],
);
const [sourceLines, _setSourceLines] = React.useState(value?.stack?.source_lines ?? []);
var message = value.message || "";
var name = value.name || "";
if (!name && !message) {
@@ -849,25 +770,17 @@ const JSException = ({
if (fancyTypeError.runtimeType !== RuntimeType.Nothing) {
return (
<div
className={`BunError-JSException BunError-JSException--TypeError`}
>
<div className={`BunError-JSException BunError-JSException--TypeError`}>
<div className="BunError-error-header">
<div className={`BunError-error-code`}>TypeError</div>
{errorTags[tag]}
</div>
<div className={`BunError-error-message`}>
{fancyTypeError.message}
</div>
<div className={`BunError-error-message`}>{fancyTypeError.message}</div>
{fancyTypeError.runtimeTypeName.length && (
<div className={`BunError-error-subtitle`}>
It's{" "}
<span className="BunError-error-typename">
{fancyTypeError.runtimeTypeName}
</span>
.
It's <span className="BunError-error-typename">{fancyTypeError.runtimeTypeName}</span>.
</div>
)}
@@ -879,9 +792,7 @@ const JSException = ({
setSourceLines={setSourceLines}
>
<Indent by={value.stack.frames[0].position.column_start}>
<span className="BunError-error-typename">
{fancyTypeError.runtimeTypeName}
</span>
<span className="BunError-error-typename">{fancyTypeError.runtimeTypeName}</span>
</Indent>
</NativeStackTrace>
)}
@@ -956,17 +867,8 @@ const Summary = ({
{errorCount}&nbsp;error{errorCount > 1 ? "s" : ""}&nbsp;on this page
</div>
<a
href="https://bun.sh/discord"
target="_blank"
className="BunError-Summary-help"
>
<svg
width="18"
viewBox="0 0 71 55"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<a href="https://bun.sh/discord" target="_blank" className="BunError-Summary-help">
<svg width="18" viewBox="0 0 71 55" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0)">
<path
d="M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z"
@@ -1005,13 +907,9 @@ const BuildError = ({ message }: { message: Message }) => {
<div className={`BunError-error-message`}>{title}</div>
{subtitle.length > 0 && (
<div className={`BunError-error-subtitle`}>{subtitle}</div>
)}
{subtitle.length > 0 && <div className={`BunError-error-subtitle`}>{subtitle}</div>}
{message.data.location && (
<BuildErrorStackTrace location={message.data.location} />
)}
{message.data.location && <BuildErrorStackTrace location={message.data.location} />}
</div>
);
};
@@ -1034,16 +932,12 @@ const ResolveError = ({ message }: { message: Message }) => {
<div className={`BunError-error-message`}>
Can't import{" "}
<span className="BunError-error-message--mono BunError-error-message--quoted">
"{message.on.resolve}"
</span>
<span className="BunError-error-message--mono BunError-error-message--quoted">"{message.on.resolve}"</span>
</div>
{subtitle && <div className={`BunError-error-subtitle`}>{subtitle}</div>}
{message.data.location && (
<BuildErrorStackTrace location={message.data.location} />
)}
{message.data.location && <BuildErrorStackTrace location={message.data.location} />}
</div>
);
};
@@ -1052,9 +946,7 @@ const OverlayMessageContainer = ({
reason,
isClient = false,
}: FallbackMessageContainer & { isClient: boolean }) => {
const errorCount = problems
? problems.exceptions.length + problems.build.errors
: 0;
const errorCount = problems ? problems.exceptions.length + problems.build.errors : 0;
return (
<div id="BunErrorOverlay-container">
<div className="BunError-content">
@@ -1086,7 +978,7 @@ function copyToClipboard(input: string | Promise<string>) {
if (!input) return;
if (typeof input === "object" && "then" in input) {
return input.then((str) => copyToClipboard(str));
return input.then(str => copyToClipboard(str));
}
return navigator.clipboard.writeText(input).then(() => {});
@@ -1148,9 +1040,7 @@ function renderWithFunc(func) {
reactRoot = document.createElement("div");
reactRoot.id = BUN_ERROR_CONTAINER_ID;
const fallbackStyleSheet = document.querySelector(
"style[data-has-bun-fallback-style]",
);
const fallbackStyleSheet = document.querySelector("style[data-has-bun-fallback-style]");
if (!fallbackStyleSheet) {
reactRoot.style.visibility = "hidden";
}
@@ -1204,7 +1094,7 @@ import { parse as getStackTrace } from "./stack-trace-parser";
var runtimeErrorController: AbortController | null = null;
var pending: { stopped: boolean }[] = [];
var onIdle = globalThis.requestIdleCallback || ((cb) => setTimeout(cb, 32));
var onIdle = globalThis.requestIdleCallback || (cb => setTimeout(cb, 32));
function clearSourceMappings() {
sourceMappings.clear();
}
@@ -1270,8 +1160,7 @@ export function renderRuntimeError(error: Error) {
exception.stack.frames[0].position.line = error[lineNumberProperty];
if (Number.isFinite(error[columnNumberProperty])) {
exception.stack.frames[0].position.column_start =
error[columnNumberProperty];
exception.stack.frames[0].position.column_start = error[columnNumberProperty];
}
}
}
@@ -1308,20 +1197,18 @@ export function renderRuntimeError(error: Error) {
// Rely on the cached ones
// and don't fetch them again
const framePromises = fetchAllMappings(
exception.stack.frames.map((frame) =>
normalizedFilename(frame.file, thisCwd),
),
exception.stack.frames.map(frame => normalizedFilename(frame.file, thisCwd)),
signal,
)
.map((frame, i) => {
if (stopThis.stopped) return null;
return [frame, i];
})
.map((result) => {
.map(result => {
if (!result) return;
const [mappings, frameIndex] = result;
if (mappings?.then) {
return mappings.then((mappings) => {
return mappings.then(mappings => {
if (!mappings || stopThis.stopped) {
return null;
}
@@ -1391,10 +1278,7 @@ export function dismissError() {
}
}
export const renderBuildFailure = (
failure: WebsocketMessageBuildFailure,
cwd: string,
) => {
export const renderBuildFailure = (failure: WebsocketMessageBuildFailure, cwd: string) => {
thisCwd = cwd;
renderWithFunc(() => (
<ErrorGroupContext.Provider value={{ cwd }}>

View File

@@ -1,15 +1,5 @@
import {
normalizedFilename,
StackFrameIdentifier,
thisCwd,
StackFrameScope,
} from "./index";
import type {
JSException,
JSException as JSExceptionType,
Message,
Problems,
} from "../../src/api/schema";
import { normalizedFilename, StackFrameIdentifier, thisCwd, StackFrameScope } from "./index";
import type { JSException, JSException as JSExceptionType, Message, Problems } from "../../src/api/schema";
export function problemsToMarkdown(problems: Problems) {
var markdown = "";
@@ -27,14 +17,14 @@ export function problemsToMarkdown(problems: Problems) {
export function messagesToMarkdown(messages: Message[]): string {
return messages
.map(messageToMarkdown)
.map((a) => a.trim())
.map(a => a.trim())
.join("\n");
}
export function exceptionsToMarkdown(exceptions: JSExceptionType[]): string {
return exceptions
.map(exceptionToMarkdown)
.map((a) => a.trim())
.map(a => a.trim())
.join("\n");
}
@@ -73,11 +63,7 @@ function exceptionToMarkdown(exception: JSException): string {
const {
file: _file = "",
function_name = "",
position: {
line = -1,
column_start: column = -1,
column_stop: columnEnd = column,
} = {
position: { line = -1, column_start: column = -1, column_stop: columnEnd = column } = {
line: -1,
column_start: -1,
column_stop: -1,
@@ -114,23 +100,17 @@ function exceptionToMarkdown(exception: JSException): string {
markdown += "\n```";
markdown += extname;
markdown += "\n";
stack.source_lines.forEach((sourceLine) => {
stack.source_lines.forEach(sourceLine => {
const lineText = sourceLine.text.trimEnd();
markdown += lineText + "\n";
if (sourceLine.line === line && stack.source_lines.length > 1) {
// the comment should start at the first non-whitespace character
// ideally it should be length the original line
// but it may not be
var prefix = "".padStart(
lineText.length - lineText.trimStart().length,
" ",
);
var prefix = "".padStart(lineText.length - lineText.trimStart().length, " ");
prefix +=
"/* ".padEnd(column - 1 - prefix.length, " ") +
"^ happened here ";
markdown +=
prefix.padEnd(Math.max(lineText.length, 1) - 1, " ") + "*/\n";
prefix += "/* ".padEnd(column - 1 - prefix.length, " ") + "^ happened here ";
markdown += prefix.padEnd(Math.max(lineText.length, 1) - 1, " ") + "*/\n";
}
});
markdown = markdown.trimEnd() + "\n```";
@@ -240,11 +220,9 @@ function messageToMarkdown(message: Message): string {
if (message.data.location.line_text.length) {
const extnameI = message.data.location.file.lastIndexOf(".");
const extname =
extnameI > -1 ? message.data.location.file.slice(extnameI + 1) : "";
const extname = extnameI > -1 ? message.data.location.file.slice(extnameI + 1) : "";
markdown +=
"\n```" + extname + "\n" + message.data.location.line_text + "\n```\n";
markdown += "\n```" + extname + "\n" + message.data.location.line_text + "\n```\n";
} else {
markdown += "\n";
}
@@ -257,14 +235,14 @@ function messageToMarkdown(message: Message): string {
return markdown;
}
export const withBunInfo = (text) => {
export const withBunInfo = text => {
const bunInfo = getBunInfo();
const trimmed = text.trim();
if (bunInfo && "then" in bunInfo) {
return bunInfo.then(
(info) => {
info => {
const markdown = bunInfoToMarkdown(info).trim();
return trimmed + "\n" + markdown + "\n";
},
@@ -379,8 +357,8 @@ function getBunInfo() {
Accept: "application/json",
},
})
.then((resp) => resp.json())
.then((bunInfo) => {
.then(resp => resp.json())
.then(bunInfo => {
clearTimeout(id);
bunInfoMemoized = bunInfo;
if ("sessionStorage" in globalThis) {

View File

@@ -1,10 +1,6 @@
// Based on https://github.com/stacktracejs/error-stack-parser/blob/master/error-stack-parser.js
import type {
StackFrame as StackFrameType,
StackFramePosition,
StackFrameScope,
} from "../../src/api/schema";
import type { StackFrame as StackFrameType, StackFramePosition, StackFrameScope } from "../../src/api/schema";
export class StackFrame implements StackFrameType {
function_name: string;
@@ -89,9 +85,7 @@ export default class RuntimeError {
return filtered.map(function (line) {
if (line.indexOf("(eval ") > -1) {
// Throw away eval information until we implement stacktrace.js/stackframe#8
line = line
.replace(/eval code/g, "eval")
.replace(/(\(eval at [^()]*)|(\),.*$)/g, "");
line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(\),.*$)/g, "");
}
var sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(");
@@ -100,20 +94,13 @@ export default class RuntimeError {
var location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
// remove the parenthesized location from the line, if it was matched
sanitizedLine = location
? sanitizedLine.replace(location[0], "")
: sanitizedLine;
sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
var tokens = sanitizedLine.split(/\s+/).slice(1);
// if a location was matched, pass it to extractLocation() otherwise pop the last token
var locationParts = this.extractLocation(
location ? location[1] : tokens.pop(),
);
var locationParts = this.extractLocation(location ? location[1] : tokens.pop());
var functionName = tokens.join(" ") || undefined;
var fileName =
["eval", "<anonymous>"].indexOf(locationParts[0]) > -1
? undefined
: locationParts[0];
var fileName = ["eval", "<anonymous>"].indexOf(locationParts[0]) > -1 ? undefined : locationParts[0];
return new StackFrame({
functionName: functionName,
@@ -133,10 +120,7 @@ export default class RuntimeError {
return filtered.map(function (line) {
// Throw away eval information until we implement stacktrace.js/stackframe#8
if (line.indexOf(" > eval") > -1) {
line = line.replace(
/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,
":$1",
);
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
}
if (line.indexOf("@") === -1 && line.indexOf(":") === -1) {
@@ -148,9 +132,7 @@ export default class RuntimeError {
var functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
var matches = line.match(functionNameRegex);
var functionName = matches && matches[1] ? matches[1] : undefined;
var locationParts = this.extractLocation(
line.replace(functionNameRegex, ""),
);
var locationParts = this.extractLocation(line.replace(functionNameRegex, ""));
return new StackFrame({
functionName: functionName,

View File

@@ -1,7 +1,6 @@
// Accelerate VLQ decoding with a lookup table
const vlqTable = new Uint8Array(128);
const vlqChars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
vlqTable.fill(0xff);
for (let i = 0; i < vlqChars.length; i++) vlqTable[vlqChars.charCodeAt(i)] = i;
@@ -10,10 +9,7 @@ export function parseSourceMap(json) {
throw new Error("Invalid source map");
}
if (
!(json.sources instanceof Array) ||
json.sources.some((x) => typeof x !== "string")
) {
if (!(json.sources instanceof Array) || json.sources.some(x => typeof x !== "string")) {
throw new Error("Invalid source map");
}
@@ -147,8 +143,7 @@ export function decodeMappings(mappings, sourcesCount) {
// Read the original source
const originalSourceDelta = decodeVLQ();
originalSource += originalSourceDelta;
if (originalSource < 0 || originalSource >= sourcesCount)
decodeError("Invalid original source");
if (originalSource < 0 || originalSource >= sourcesCount) decodeError("Invalid original source");
// Read the original line
const originalLineDelta = decodeVLQ();
@@ -211,11 +206,7 @@ export function decodeMappings(mappings, sourcesCount) {
return data.subarray(0, dataLength);
}
export function remapPosition(
decodedMappings: Int32Array,
line: number,
column: number,
) {
export function remapPosition(decodedMappings: Int32Array, line: number, column: number) {
if (!(decodedMappings instanceof Int32Array)) {
throw new Error("decodedMappings must be an Int32Array");
}
@@ -260,7 +251,7 @@ export function fetchMappings(file, signal) {
return sourceMappings.get(file);
}
return fetchRemoteSourceMap(file, signal).then((json) => {
return fetchRemoteSourceMap(file, signal).then(json => {
if (!json) return null;
const { data } = parseSourceMap(json);
sourceMappings.set(file, data);
@@ -285,11 +276,11 @@ export function fetchAllMappings(files, signal) {
var resolvers = [];
for (let i = 0; i < indices.length; i++) {
results[indices[i]] = new Promise((resolve, reject) => {
resolvers[i] = (res) => resolve(res ? [res, i] : null);
resolvers[i] = res => resolve(res ? [res, i] : null);
});
}
mapped.finally((a) => {
mapped.finally(a => {
for (let resolve of resolvers) {
try {
resolve(a);
@@ -320,10 +311,7 @@ function indexOfMapping(mappings: Int32Array, line: number, column: number) {
var i = index + step;
// this multiply is slow but it's okay for now
var j = i * 6;
if (
mappings[j] < line ||
(mappings[j] == line && mappings[j + 1] <= column)
) {
if (mappings[j] < line || (mappings[j] == line && mappings[j + 1] <= column)) {
index = i + 1;
count -= step + 1;
} else {

View File

@@ -17,12 +17,7 @@ export function parse(stackString): StackFrame[] {
const lines = stackString.split("\n");
return lines.reduce((stack, line) => {
const parseResult =
parseChrome(line) ||
parseWinjs(line) ||
parseGecko(line) ||
parseNode(line) ||
parseJSC(line);
const parseResult = parseChrome(line) || parseWinjs(line) || parseGecko(line) || parseNode(line) || parseJSC(line);
if (parseResult) {
stack.push(parseResult);
@@ -32,15 +27,14 @@ export function parse(stackString): StackFrame[] {
}, []);
}
const formatFile = (file) => {
const formatFile = file => {
if (!file) {
return "";
}
if (file.startsWith("blob:")) {
if (globalThis["__BUN"]?.client) {
const replacement =
globalThis["__BUN"]?.client.dependencies.getFilePathFromBlob(file);
const replacement = globalThis["__BUN"]?.client.dependencies.getFilePathFromBlob(file);
if (replacement) {
file = replacement;
}
@@ -146,8 +140,7 @@ function parseGecko(line) {
};
}
const javaScriptCoreRe =
/^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;
const javaScriptCoreRe = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;
function parseJSC(line) {
const parts = javaScriptCoreRe.exec(line);
@@ -166,8 +159,7 @@ function parseJSC(line) {
};
}
const nodeRe =
/^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;
const nodeRe = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;
function parseNode(line) {
const parts = nodeRe.exec(line);

View File

@@ -3,11 +3,11 @@ import { copyFileSync, mkdirSync, readdirSync, rmSync, statSync } from "fs";
import { join } from "path";
try {
const basePath = join(import.meta.dir, "../../src/bun.js/WebKit/Source/WebInspectorUI/UserInterface");
const basePath = join(import.meta.dir, "../../../src/bun.js/WebKit/Source/WebInspectorUI/UserInterface");
const htmlPath = join(basePath, "Main.html");
const backendCommands = join(
import.meta.dir,
"../../src/bun.js/WebKit/WebKitBuild/Release/JavaScriptCore/DerivedSources/inspector/InspectorBackendCommands.js",
"../../../src/bun.js/WebKit/WebKitBuild/Release/JavaScriptCore/DerivedSources/inspector/InspectorBackendCommands.js",
);
const scriptsToBundle = [];
const stylesToBundle = [];

View File

@@ -3047,6 +3047,10 @@ export namespace JSC {
* Whether the expression should be considered to be in a user gesture or not.
*/
emulateUserGesture?: boolean | undefined;
/**
* Whether to automatically await returned promise.
*/
awaitPromise?: boolean | undefined;
};
/**
* Calls function with given declaration on the given object. Object group of the result is inherited from the target object.

View File

@@ -48,10 +48,7 @@
"id": "Channel",
"description": "Logging channel.",
"type": "object",
"properties": [
{ "name": "source", "$ref": "ChannelSource" },
{ "name": "level", "$ref": "ChannelLevel" }
]
"properties": [{ "name": "source", "$ref": "ChannelSource" }, { "name": "level", "$ref": "ChannelLevel" }]
},
{
"id": "ConsoleMessage",
@@ -1142,10 +1139,7 @@
{
"name": "snapshot",
"description": "Take a heap snapshot.",
"returns": [
{ "name": "timestamp", "type": "number" },
{ "name": "snapshotData", "$ref": "HeapSnapshotData" }
]
"returns": [{ "name": "timestamp", "type": "number" }, { "name": "snapshotData", "$ref": "HeapSnapshotData" }]
},
{
"name": "startTracking",
@@ -1235,10 +1229,7 @@
{ "name": "evaluateForTestInFrontend", "parameters": [{ "name": "script", "type": "string" }] },
{
"name": "inspect",
"parameters": [
{ "name": "object", "$ref": "Runtime.RemoteObject" },
{ "name": "hints", "type": "object" }
]
"parameters": [{ "name": "object", "$ref": "Runtime.RemoteObject" }, { "name": "hints", "type": "object" }]
}
]
},
@@ -2751,6 +2742,12 @@
"type": "boolean",
"optional": true,
"description": "Whether the expression should be considered to be in a user gesture or not."
},
{
"name": "awaitPromise",
"type": "boolean",
"optional": true,
"description": "Whether to automatically await returned promise."
}
],
"returns": [
@@ -2761,7 +2758,8 @@
"optional": true,
"description": "True if the result was thrown during the evaluation."
}
]
],
"async": true
},
{
"name": "getPreview",

View File

@@ -812,7 +812,8 @@ export namespace V8 {
| "WarnSameSiteLaxCrossDowngradeLax"
| "WarnAttributeValueExceedsMaxSize"
| "WarnDomainNonASCII"
| "WarnThirdPartyPhaseout";
| "WarnThirdPartyPhaseout"
| "WarnCrossSiteRedirectDowngradeChangesInclusion";
export type CookieOperation = "SetCookie" | "ReadCookie";
/**
* This information is currently necessary, as the front-end has a difficult
@@ -865,6 +866,7 @@ export namespace V8 {
| "Script"
| "ServiceWorker"
| "SharedWorker"
| "SpeculationRules"
| "Stylesheet"
| "Track"
| "Video"
@@ -1091,6 +1093,16 @@ export namespace V8 {
export type BounceTrackingIssueDetails = {
trackingSites: string[];
};
/**
* This issue warns about third-party sites that are accessing cookies on the
* current page, and have been permitted due to having a global metadata grant.
* Note that in this context 'site' means eTLD+1. For example, if the URL
* `https://example.test:80/web_page` was accessing cookies, the site reported
* would be `example.test`.
*/
export type CookieDeprecationMetadataIssueDetails = {
allowedSites: string[];
};
export type ClientHintIssueReason = "MetaTagAllowListInvalidOrigin" | "MetaTagModifiedHTML";
export type FederatedAuthRequestIssueDetails = {
federatedAuthRequestIssueReason: FederatedAuthRequestIssueReason;
@@ -1130,6 +1142,8 @@ export namespace V8 {
| "IdTokenHttpNotFound"
| "IdTokenNoResponse"
| "IdTokenInvalidResponse"
| "IdTokenIdpErrorResponse"
| "IdTokenCrossSiteIdpErrorResponse"
| "IdTokenInvalidRequest"
| "IdTokenInvalidContentType"
| "ErrorIdToken"
@@ -1234,6 +1248,7 @@ export namespace V8 {
| "ClientHintIssue"
| "FederatedAuthRequestIssue"
| "BounceTrackingIssue"
| "CookieDeprecationMetadataIssue"
| "StylesheetLoadingIssue"
| "FederatedAuthUserInfoRequestIssue"
| "PropertyRuleIssue";
@@ -1259,6 +1274,7 @@ export namespace V8 {
clientHintIssueDetails?: ClientHintIssueDetails | undefined;
federatedAuthRequestIssueDetails?: FederatedAuthRequestIssueDetails | undefined;
bounceTrackingIssueDetails?: BounceTrackingIssueDetails | undefined;
cookieDeprecationMetadataIssueDetails?: CookieDeprecationMetadataIssueDetails | undefined;
stylesheetLoadingIssueDetails?: StylesheetLoadingIssueDetails | undefined;
propertyRuleIssueDetails?: PropertyRuleIssueDetails | undefined;
federatedAuthUserInfoRequestIssueDetails?: FederatedAuthUserInfoRequestIssueDetails | undefined;
@@ -1472,6 +1488,10 @@ export namespace V8 {
* The filling strategy
*/
fillingStrategy: FillingStrategy;
/**
* The form field's DOM node
*/
fieldId: DOM.BackendNodeId;
};
/**
* Emitted when an address form is filled.
@@ -1703,6 +1723,7 @@ export namespace V8 {
| "audioCapture"
| "backgroundSync"
| "backgroundFetch"
| "capturedSurfaceControl"
| "clipboardReadWrite"
| "clipboardSanitizedWrite"
| "displayCapture"
@@ -1729,7 +1750,7 @@ export namespace V8 {
export type PermissionSetting = "granted" | "denied" | "prompt";
/**
* Definition of PermissionDescriptor defined in the Permissions API:
* https://w3c.github.io/permissions/#dictdef-permissiondescriptor.
* https://w3c.github.io/permissions/#dom-permissiondescriptor.
*/
export type PermissionDescriptor = {
/**
@@ -3082,6 +3103,10 @@ export namespace V8 {
* Font's family name reported by platform.
*/
familyName: string;
/**
* Font's PostScript name reported by platform.
*/
postScriptName: string;
/**
* Indicates if the font was downloaded or resolved locally.
*/
@@ -3212,6 +3237,28 @@ export namespace V8 {
inherits: boolean;
syntax: string;
};
/**
* CSS font-palette-values rule representation.
*/
export type CSSFontPaletteValuesRule = {
/**
* The css style sheet identifier (absent for user agent stylesheet and user-specified
* stylesheet rules) this rule came from.
*/
styleSheetId?: StyleSheetId | undefined;
/**
* Parent stylesheet's origin.
*/
origin: StyleSheetOrigin;
/**
* Associated font palette name.
*/
fontPaletteName: Value;
/**
* Associated style declaration.
*/
style: CSSStyle;
};
/**
* CSS property at-rule representation.
*/
@@ -3335,6 +3382,12 @@ export namespace V8 {
* Text position of a new rule in the target style sheet.
*/
location: SourceRange;
/**
* NodeId for the DOM node in whose context custom property declarations for registered properties should be
* validated. If omitted, declarations in the new rule text can only be validated statically, which may produce
* incorrect results if the declaration contains a var() for example.
*/
nodeForPropertySyntaxValidation?: DOM.NodeId | undefined;
};
/**
* Inserts a new rule with the given `ruleText` in a stylesheet with given `styleSheetId`, at the
@@ -3552,6 +3605,10 @@ export namespace V8 {
* A list of CSS property registrations matching this node.
*/
cssPropertyRegistrations?: CSSPropertyRegistration[] | undefined;
/**
* A font-palette-values rule matching this node.
*/
cssFontPaletteValuesRule?: CSSFontPaletteValuesRule | undefined;
/**
* Id of the first parent element that does not have display: contents.
*/
@@ -3838,6 +3895,12 @@ export namespace V8 {
*/
export type SetStyleTextsRequest = {
edits: StyleDeclarationEdit[];
/**
* NodeId for the DOM node in whose context custom property declarations for registered properties should be
* validated. If omitted, declarations in the new rule text can only be validated statically, which may produce
* incorrect results if the declaration contains a var() for example.
*/
nodeForPropertySyntaxValidation?: DOM.NodeId | undefined;
};
/**
* Applies specified style edits one after another in the given order.
@@ -6666,6 +6729,12 @@ export namespace V8 {
*/
maskLength: number;
};
export type DevicePosture = {
/**
* Current posture of the device
*/
type: "continuous" | "folded";
};
export type MediaFeature = {
name: string;
value: string;
@@ -6706,6 +6775,44 @@ export namespace V8 {
bitness?: string | undefined;
wow64?: boolean | undefined;
};
/**
* Used to specify sensor types to emulate.
* See https://w3c.github.io/sensors/#automation for more information.
*/
export type SensorType =
| "absolute-orientation"
| "accelerometer"
| "ambient-light"
| "gravity"
| "gyroscope"
| "linear-acceleration"
| "magnetometer"
| "proximity"
| "relative-orientation";
export type SensorMetadata = {
available?: boolean | undefined;
minimumFrequency?: number | undefined;
maximumFrequency?: number | undefined;
};
export type SensorReadingSingle = {
value: number;
};
export type SensorReadingXYZ = {
x: number;
y: number;
z: number;
};
export type SensorReadingQuaternion = {
x: number;
y: number;
z: number;
w: number;
};
export type SensorReading = {
single?: SensorReadingSingle | undefined;
xyz?: SensorReadingXYZ | undefined;
quaternion?: SensorReadingQuaternion | undefined;
};
/**
* Enum of image types that can be disabled.
*/
@@ -6886,6 +6993,11 @@ export namespace V8 {
* is turned-off.
*/
displayFeature?: DisplayFeature | undefined;
/**
* If set, the posture of a foldable device. If not set the posture is set
* to continuous.
*/
devicePosture?: DevicePosture | undefined;
};
/**
* Overrides the values of device screen dimensions (window.screen.width, window.screen.height,
@@ -7010,6 +7122,57 @@ export namespace V8 {
* @response `Emulation.setGeolocationOverride`
*/
export type SetGeolocationOverrideResponse = {};
/**
* undefined
* @request `Emulation.getOverriddenSensorInformation`
*/
export type GetOverriddenSensorInformationRequest = {
type: SensorType;
};
/**
* undefined
* @response `Emulation.getOverriddenSensorInformation`
*/
export type GetOverriddenSensorInformationResponse = {
requestedSamplingFrequency: number;
};
/**
* Overrides a platform sensor of a given type. If |enabled| is true, calls to
* Sensor.start() will use a virtual sensor as backend rather than fetching
* data from a real hardware sensor. Otherwise, existing virtual
* sensor-backend Sensor objects will fire an error event and new calls to
* Sensor.start() will attempt to use a real sensor instead.
* @request `Emulation.setSensorOverrideEnabled`
*/
export type SetSensorOverrideEnabledRequest = {
enabled: boolean;
type: SensorType;
metadata?: SensorMetadata | undefined;
};
/**
* Overrides a platform sensor of a given type. If |enabled| is true, calls to
* Sensor.start() will use a virtual sensor as backend rather than fetching
* data from a real hardware sensor. Otherwise, existing virtual
* sensor-backend Sensor objects will fire an error event and new calls to
* Sensor.start() will attempt to use a real sensor instead.
* @response `Emulation.setSensorOverrideEnabled`
*/
export type SetSensorOverrideEnabledResponse = {};
/**
* Updates the sensor readings reported by a sensor type previously overriden
* by setSensorOverrideEnabled.
* @request `Emulation.setSensorOverrideReadings`
*/
export type SetSensorOverrideReadingsRequest = {
type: SensorType;
reading: SensorReading;
};
/**
* Updates the sensor readings reported by a sensor type previously overriden
* by setSensorOverrideEnabled.
* @response `Emulation.setSensorOverrideReadings`
*/
export type SetSensorOverrideReadingsResponse = {};
/**
* Overrides the Idle state.
* @request `Emulation.setIdleOverride`
@@ -7231,7 +7394,7 @@ export namespace V8 {
*/
userAgent: string;
/**
* Browser langugage to emulate.
* Browser language to emulate.
*/
acceptLanguage?: string | undefined;
/**
@@ -7313,9 +7476,13 @@ export namespace V8 {
*/
export type LoginState = "SignIn" | "SignUp";
/**
* Whether the dialog shown is an account chooser or an auto re-authentication dialog.
* The types of FedCM dialogs.
*/
export type DialogType = "AccountChooser" | "AutoReauthn" | "ConfirmIdpLogin";
export type DialogType = "AccountChooser" | "AutoReauthn" | "ConfirmIdpLogin" | "Error";
/**
* The buttons on the FedCM dialog.
*/
export type DialogButton = "ConfirmIdpLoginContinue" | "ErrorGotIt" | "ErrorMoreDetails";
/**
* Corresponds to IdentityRequestAccount
*/
@@ -7349,6 +7516,14 @@ export namespace V8 {
title: string;
subtitle?: string | undefined;
};
/**
* Triggered when a dialog is closed, either by user action, JS abort,
* or a command below.
* @event `FedCm.dialogClosed`
*/
export type DialogClosedEvent = {
dialogId: string;
};
/**
* undefined
* @request `FedCm.enable`
@@ -7390,19 +7565,18 @@ export namespace V8 {
*/
export type SelectAccountResponse = {};
/**
* Only valid if the dialog type is ConfirmIdpLogin. Acts as if the user had
* clicked the continue button.
* @request `FedCm.confirmIdpLogin`
* undefined
* @request `FedCm.clickDialogButton`
*/
export type ConfirmIdpLoginRequest = {
export type ClickDialogButtonRequest = {
dialogId: string;
dialogButton: DialogButton;
};
/**
* Only valid if the dialog type is ConfirmIdpLogin. Acts as if the user had
* clicked the continue button.
* @response `FedCm.confirmIdpLogin`
* undefined
* @response `FedCm.clickDialogButton`
*/
export type ConfirmIdpLoginResponse = {};
export type ClickDialogButtonResponse = {};
/**
* undefined
* @request `FedCm.dismissDialog`
@@ -9967,6 +10141,23 @@ export namespace V8 {
*/
outlineColor?: DOM.RGBA | undefined;
};
/**
* Configuration for Window Controls Overlay
*/
export type WindowControlsOverlayConfig = {
/**
* Whether the title bar CSS should be shown when emulating the Window Controls Overlay.
*/
showCSS: boolean;
/**
* Seleted platforms to show the overlay.
*/
selectedPlatform: string;
/**
* The theme color defined in app manifest.
*/
themeColor: string;
};
export type ContainerQueryHighlightConfig = {
/**
* A descriptor for the highlight appearance of container query containers.
@@ -10564,6 +10755,21 @@ export namespace V8 {
* @response `Overlay.setShowIsolatedElements`
*/
export type SetShowIsolatedElementsResponse = {};
/**
* Show Window Controls Overlay for PWA
* @request `Overlay.setShowWindowControlsOverlay`
*/
export type SetShowWindowControlsOverlayRequest = {
/**
* Window Controls Overlay data, null means hide Window Controls Overlay
*/
windowControlsOverlayConfig?: WindowControlsOverlayConfig | undefined;
};
/**
* Show Window Controls Overlay for PWA
* @response `Overlay.setShowWindowControlsOverlay`
*/
export type SetShowWindowControlsOverlayResponse = {};
}
export namespace Page {
/**
@@ -10622,6 +10828,7 @@ export namespace V8 {
| "bluetooth"
| "browsing-topics"
| "camera"
| "captured-surface-control"
| "ch-dpr"
| "ch-device-memory"
| "ch-downlink"
@@ -10677,6 +10884,7 @@ export namespace V8 {
| "private-aggregation"
| "private-state-token-issuance"
| "private-state-token-redemption"
| "publickey-credentials-create"
| "publickey-credentials-get"
| "run-ad-auction"
| "screen-wake-lock"
@@ -10686,10 +10894,13 @@ export namespace V8 {
| "shared-storage-select-url"
| "smart-card"
| "storage-access"
| "sub-apps"
| "sync-xhr"
| "unload"
| "usb"
| "usb-unrestricted"
| "vertical-scroll"
| "web-printing"
| "web-share"
| "window-management"
| "window-placement"
@@ -11307,6 +11518,9 @@ export namespace V8 {
| "WebRTCSticky"
| "WebTransportSticky"
| "WebSocketSticky"
| "SmartCard"
| "LiveMediaStreamTrack"
| "UnloadHandler"
| "ContentSecurityHandler"
| "ContentWebAuthenticationAPI"
| "ContentFileChooser"
@@ -11336,6 +11550,24 @@ export namespace V8 {
* Types of not restored reasons for back-forward cache.
*/
export type BackForwardCacheNotRestoredReasonType = "SupportPending" | "PageSupportNeeded" | "Circumstantial";
export type BackForwardCacheBlockingDetails = {
/**
* Url of the file where blockage happened. Optional because of tests.
*/
url?: string | undefined;
/**
* Function name where blockage happened. Optional because of anonymous functions and tests.
*/
function?: string | undefined;
/**
* Line number in the script (0-based).
*/
lineNumber: number;
/**
* Column number in the script (0-based).
*/
columnNumber: number;
};
export type BackForwardCacheNotRestoredExplanation = {
/**
* Type of the reason
@@ -11351,6 +11583,7 @@ export namespace V8 {
* - EmbedderExtensionSentMessageToCachedFrame: the extension ID.
*/
context?: string | undefined;
details?: BackForwardCacheBlockingDetails[] | undefined;
};
export type BackForwardCacheNotRestoredExplanationTree = {
/**
@@ -12054,25 +12287,6 @@ export namespace V8 {
*/
adScriptId?: AdScriptId | undefined;
};
/**
* Returns all browser cookies for the page and all of its subframes. Depending
* on the backend support, will return detailed cookie information in the
* `cookies` field.
* @request `Page.getCookies`
*/
export type GetCookiesRequest = {};
/**
* Returns all browser cookies for the page and all of its subframes. Depending
* on the backend support, will return detailed cookie information in the
* `cookies` field.
* @response `Page.getCookies`
*/
export type GetCookiesResponse = {
/**
* Array of cookie objects.
*/
cookies: Network.Cookie[];
};
/**
* Returns present frame tree structure.
* @request `Page.getFrameTree`
@@ -12360,6 +12574,10 @@ export namespace V8 {
* Whether or not to generate tagged (accessible) PDF. Defaults to embedder choice.
*/
generateTaggedPDF?: boolean | undefined;
/**
* Whether or not to embed the document outline into the PDF.
*/
generateDocumentOutline?: boolean | undefined;
};
/**
* Print page as PDF.
@@ -13313,7 +13531,6 @@ export namespace V8 {
| "MemoryPressureOnTrigger"
| "MemoryPressureAfterTriggered"
| "PrerenderingDisabledByDevTools"
| "ResourceLoadBlockedByClient"
| "SpeculationRuleRemoved"
| "ActivatedWithAuxiliaryBrowsingContexts"
| "MaxNumOfRunningEagerPrerendersExceeded"
@@ -13339,7 +13556,8 @@ export namespace V8 {
| "PrefetchFailedNetError"
| "PrefetchFailedNon2XX"
| "PrefetchFailedPerPageLimitExceeded"
| "PrefetchEvicted"
| "PrefetchEvictedAfterCandidateRemoved"
| "PrefetchEvictedForNewerPrefetch"
| "PrefetchHeldback"
| "PrefetchIneligibleRetryAfter"
| "PrefetchIsPrivacyDecoy"
@@ -13362,6 +13580,14 @@ export namespace V8 {
| "PrefetchResponseUsed"
| "PrefetchSuccessfulButNotUsed"
| "PrefetchNotUsedProbeFailed";
/**
* Information of headers to be displayed when the header mismatch occurred.
*/
export type PrerenderMismatchedHeaders = {
headerName: string;
initialValue?: string | undefined;
activationValue?: string | undefined;
};
/**
* Upsert. Currently, it is only emitted when a rule set added.
* @event `Preload.ruleSetUpdated`
@@ -13415,6 +13641,7 @@ export namespace V8 {
* that is incompatible with prerender and has caused the cancellation of the attempt.
*/
disallowedMojoInterface?: string | undefined;
mismatchedHeaders?: PrerenderMismatchedHeaders[] | undefined;
};
/**
* Send a list of sources for all preloading attempts in a document.
@@ -13837,6 +14064,7 @@ export namespace V8 {
scriptResponseTime?: number | undefined;
controlledClients?: Target.TargetID[] | undefined;
targetId?: Target.TargetID | undefined;
routerRules?: string | undefined;
};
/**
* ServiceWorker error message.
@@ -14241,6 +14469,17 @@ export namespace V8 {
key: string;
values: string[];
};
export type AttributionReportingFilterConfig = {
filterValues: AttributionReportingFilterDataEntry[];
/**
* duration in seconds
*/
lookbackWindow?: number | undefined;
};
export type AttributionReportingFilterPair = {
filters: AttributionReportingFilterConfig[];
notFilters: AttributionReportingFilterConfig[];
};
export type AttributionReportingAggregationKeysEntry = {
key: string;
value: UnsignedInt128AsBase16;
@@ -14255,13 +14494,22 @@ export namespace V8 {
*/
ends: number[];
};
export type AttributionReportingTriggerSpec = {
/**
* number instead of integer because not all uint32 can be represented by
* int
*/
triggerData: number[];
eventReportWindows: AttributionReportingEventReportWindows;
};
export type AttributionReportingTriggerDataMatching = "exact" | "modulus";
export type AttributionReportingSourceRegistration = {
time: Network.TimeSinceEpoch;
/**
* duration in seconds
*/
expiry: number;
eventReportWindows: AttributionReportingEventReportWindows;
triggerSpecs: AttributionReportingTriggerSpec[];
/**
* duration in seconds
*/
@@ -14275,6 +14523,7 @@ export namespace V8 {
filterData: AttributionReportingFilterDataEntry[];
aggregationKeys: AttributionReportingAggregationKeysEntry[];
debugKey?: UnsignedInt64AsBase10 | undefined;
triggerDataMatching: AttributionReportingTriggerDataMatching;
};
export type AttributionReportingSourceRegistrationResult =
| "success"
@@ -14289,6 +14538,77 @@ export namespace V8 {
| "destinationBothLimitsReached"
| "reportingOriginsPerSiteLimitReached"
| "exceedsMaxChannelCapacity";
export type AttributionReportingSourceRegistrationTimeConfig = "include" | "exclude";
export type AttributionReportingAggregatableValueEntry = {
key: string;
/**
* number instead of integer because not all uint32 can be represented by
* int
*/
value: number;
};
export type AttributionReportingEventTriggerData = {
data: UnsignedInt64AsBase10;
priority: SignedInt64AsBase10;
dedupKey?: UnsignedInt64AsBase10 | undefined;
filters: AttributionReportingFilterPair;
};
export type AttributionReportingAggregatableTriggerData = {
keyPiece: UnsignedInt128AsBase16;
sourceKeys: string[];
filters: AttributionReportingFilterPair;
};
export type AttributionReportingAggregatableDedupKey = {
dedupKey?: UnsignedInt64AsBase10 | undefined;
filters: AttributionReportingFilterPair;
};
export type AttributionReportingTriggerRegistration = {
filters: AttributionReportingFilterPair;
debugKey?: UnsignedInt64AsBase10 | undefined;
aggregatableDedupKeys: AttributionReportingAggregatableDedupKey[];
eventTriggerData: AttributionReportingEventTriggerData[];
aggregatableTriggerData: AttributionReportingAggregatableTriggerData[];
aggregatableValues: AttributionReportingAggregatableValueEntry[];
debugReporting: boolean;
aggregationCoordinatorOrigin?: string | undefined;
sourceRegistrationTimeConfig: AttributionReportingSourceRegistrationTimeConfig;
triggerContextId?: string | undefined;
};
export type AttributionReportingEventLevelResult =
| "success"
| "successDroppedLowerPriority"
| "internalError"
| "noCapacityForAttributionDestination"
| "noMatchingSources"
| "deduplicated"
| "excessiveAttributions"
| "priorityTooLow"
| "neverAttributedSource"
| "excessiveReportingOrigins"
| "noMatchingSourceFilterData"
| "prohibitedByBrowserPolicy"
| "noMatchingConfigurations"
| "excessiveReports"
| "falselyAttributedSource"
| "reportWindowPassed"
| "notRegistered"
| "reportWindowNotStarted"
| "noMatchingTriggerData";
export type AttributionReportingAggregatableResult =
| "success"
| "internalError"
| "noCapacityForAttributionDestination"
| "noMatchingSources"
| "excessiveAttributions"
| "excessiveReportingOrigins"
| "noHistograms"
| "insufficientBudget"
| "noMatchingSourceFilterData"
| "notRegistered"
| "prohibitedByBrowserPolicy"
| "deduplicated"
| "reportWindowPassed"
| "excessiveReports";
/**
* A cache's contents have been modified.
* @event `Storage.cacheStorageContentUpdated`
@@ -14426,14 +14746,22 @@ export namespace V8 {
bucketId: string;
};
/**
* TODO(crbug.com/1458532): Add other Attribution Reporting events, e.g.
* trigger registration.
* undefined
* @event `Storage.attributionReportingSourceRegistered`
*/
export type AttributionReportingSourceRegisteredEvent = {
registration: AttributionReportingSourceRegistration;
result: AttributionReportingSourceRegistrationResult;
};
/**
* undefined
* @event `Storage.attributionReportingTriggerRegistered`
*/
export type AttributionReportingTriggerRegisteredEvent = {
registration: AttributionReportingTriggerRegistration;
eventLevel: AttributionReportingEventLevelResult;
aggregatable: AttributionReportingAggregatableResult;
};
/**
* Returns a storage key given a frame id.
* @request `Storage.getStorageKeyForFrame`
@@ -16297,6 +16625,18 @@ export namespace V8 {
* Defaults to false.
*/
isUserVerified?: boolean | undefined;
/**
* Credentials created by this authenticator will have the backup
* eligibility (BE) flag set to this value. Defaults to false.
* https://w3c.github.io/webauthn/#sctn-credential-backup
*/
defaultBackupEligibility?: boolean | undefined;
/**
* Credentials created by this authenticator will have the backup state
* (BS) flag set to this value. Defaults to false.
* https://w3c.github.io/webauthn/#sctn-credential-backup
*/
defaultBackupState?: boolean | undefined;
};
export type Credential = {
credentialId: string;
@@ -16569,6 +16909,7 @@ export namespace V8 {
"DOMStorage.domStorageItemsCleared": DOMStorage.DomStorageItemsClearedEvent;
"Emulation.virtualTimeBudgetExpired": Emulation.VirtualTimeBudgetExpiredEvent;
"FedCm.dialogShown": FedCm.DialogShownEvent;
"FedCm.dialogClosed": FedCm.DialogClosedEvent;
"Fetch.requestPaused": Fetch.RequestPausedEvent;
"Fetch.authRequired": Fetch.AuthRequiredEvent;
"Input.dragIntercepted": Input.DragInterceptedEvent;
@@ -16633,6 +16974,7 @@ export namespace V8 {
"Storage.storageBucketCreatedOrUpdated": Storage.StorageBucketCreatedOrUpdatedEvent;
"Storage.storageBucketDeleted": Storage.StorageBucketDeletedEvent;
"Storage.attributionReportingSourceRegistered": Storage.AttributionReportingSourceRegisteredEvent;
"Storage.attributionReportingTriggerRegistered": Storage.AttributionReportingTriggerRegisteredEvent;
"Target.attachedToTarget": Target.AttachedToTargetEvent;
"Target.detachedFromTarget": Target.DetachedFromTargetEvent;
"Target.receivedMessageFromTarget": Target.ReceivedMessageFromTargetEvent;
@@ -16845,6 +17187,9 @@ export namespace V8 {
"Emulation.setEmulatedMedia": Emulation.SetEmulatedMediaRequest;
"Emulation.setEmulatedVisionDeficiency": Emulation.SetEmulatedVisionDeficiencyRequest;
"Emulation.setGeolocationOverride": Emulation.SetGeolocationOverrideRequest;
"Emulation.getOverriddenSensorInformation": Emulation.GetOverriddenSensorInformationRequest;
"Emulation.setSensorOverrideEnabled": Emulation.SetSensorOverrideEnabledRequest;
"Emulation.setSensorOverrideReadings": Emulation.SetSensorOverrideReadingsRequest;
"Emulation.setIdleOverride": Emulation.SetIdleOverrideRequest;
"Emulation.clearIdleOverride": Emulation.ClearIdleOverrideRequest;
"Emulation.setNavigatorOverrides": Emulation.SetNavigatorOverridesRequest;
@@ -16865,7 +17210,7 @@ export namespace V8 {
"FedCm.enable": FedCm.EnableRequest;
"FedCm.disable": FedCm.DisableRequest;
"FedCm.selectAccount": FedCm.SelectAccountRequest;
"FedCm.confirmIdpLogin": FedCm.ConfirmIdpLoginRequest;
"FedCm.clickDialogButton": FedCm.ClickDialogButtonRequest;
"FedCm.dismissDialog": FedCm.DismissDialogRequest;
"FedCm.resetCooldown": FedCm.ResetCooldownRequest;
"Fetch.disable": Fetch.DisableRequest;
@@ -16949,6 +17294,7 @@ export namespace V8 {
"Overlay.setShowViewportSizeOnResize": Overlay.SetShowViewportSizeOnResizeRequest;
"Overlay.setShowHinge": Overlay.SetShowHingeRequest;
"Overlay.setShowIsolatedElements": Overlay.SetShowIsolatedElementsRequest;
"Overlay.setShowWindowControlsOverlay": Overlay.SetShowWindowControlsOverlayRequest;
"Page.addScriptToEvaluateOnLoad": Page.AddScriptToEvaluateOnLoadRequest;
"Page.addScriptToEvaluateOnNewDocument": Page.AddScriptToEvaluateOnNewDocumentRequest;
"Page.bringToFront": Page.BringToFrontRequest;
@@ -16966,7 +17312,6 @@ export namespace V8 {
"Page.getManifestIcons": Page.GetManifestIconsRequest;
"Page.getAppId": Page.GetAppIdRequest;
"Page.getAdScriptId": Page.GetAdScriptIdRequest;
"Page.getCookies": Page.GetCookiesRequest;
"Page.getFrameTree": Page.GetFrameTreeRequest;
"Page.getLayoutMetrics": Page.GetLayoutMetricsRequest;
"Page.getNavigationHistory": Page.GetNavigationHistoryRequest;
@@ -17296,6 +17641,9 @@ export namespace V8 {
"Emulation.setEmulatedMedia": Emulation.SetEmulatedMediaResponse;
"Emulation.setEmulatedVisionDeficiency": Emulation.SetEmulatedVisionDeficiencyResponse;
"Emulation.setGeolocationOverride": Emulation.SetGeolocationOverrideResponse;
"Emulation.getOverriddenSensorInformation": Emulation.GetOverriddenSensorInformationResponse;
"Emulation.setSensorOverrideEnabled": Emulation.SetSensorOverrideEnabledResponse;
"Emulation.setSensorOverrideReadings": Emulation.SetSensorOverrideReadingsResponse;
"Emulation.setIdleOverride": Emulation.SetIdleOverrideResponse;
"Emulation.clearIdleOverride": Emulation.ClearIdleOverrideResponse;
"Emulation.setNavigatorOverrides": Emulation.SetNavigatorOverridesResponse;
@@ -17316,7 +17664,7 @@ export namespace V8 {
"FedCm.enable": FedCm.EnableResponse;
"FedCm.disable": FedCm.DisableResponse;
"FedCm.selectAccount": FedCm.SelectAccountResponse;
"FedCm.confirmIdpLogin": FedCm.ConfirmIdpLoginResponse;
"FedCm.clickDialogButton": FedCm.ClickDialogButtonResponse;
"FedCm.dismissDialog": FedCm.DismissDialogResponse;
"FedCm.resetCooldown": FedCm.ResetCooldownResponse;
"Fetch.disable": Fetch.DisableResponse;
@@ -17400,6 +17748,7 @@ export namespace V8 {
"Overlay.setShowViewportSizeOnResize": Overlay.SetShowViewportSizeOnResizeResponse;
"Overlay.setShowHinge": Overlay.SetShowHingeResponse;
"Overlay.setShowIsolatedElements": Overlay.SetShowIsolatedElementsResponse;
"Overlay.setShowWindowControlsOverlay": Overlay.SetShowWindowControlsOverlayResponse;
"Page.addScriptToEvaluateOnLoad": Page.AddScriptToEvaluateOnLoadResponse;
"Page.addScriptToEvaluateOnNewDocument": Page.AddScriptToEvaluateOnNewDocumentResponse;
"Page.bringToFront": Page.BringToFrontResponse;
@@ -17417,7 +17766,6 @@ export namespace V8 {
"Page.getManifestIcons": Page.GetManifestIconsResponse;
"Page.getAppId": Page.GetAppIdResponse;
"Page.getAdScriptId": Page.GetAdScriptIdResponse;
"Page.getCookies": Page.GetCookiesResponse;
"Page.getFrameTree": Page.GetFrameTreeResponse;
"Page.getLayoutMetrics": Page.GetLayoutMetricsResponse;
"Page.getNavigationHistory": Page.GetNavigationHistoryResponse;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
console.log(process.execArgv);

View File

@@ -79,10 +79,7 @@
"env": {
"NAME": "Bun"
},
"args": [
"--jsx-import-source",
"src/middleware/jsx/jsx-dev-runtime"
],
"args": ["--jsx-import-source", "src/middleware/jsx/jsx-dev-runtime"],
"path": "runtime_tests/bun/index.test.tsx"
}
},

View File

@@ -1,41 +1,49 @@
import * as action from "@actions/core";
import { spawnSync } from "child_process";
import { spawn, spawnSync } from "child_process";
import { rmSync, writeFileSync, readFileSync } from "fs";
import { readFile } from "fs/promises";
import { readdirSync } from "node:fs";
import { resolve, basename } from "node:path";
import { totalmem } from "os";
import { cpus, hostname, totalmem, userInfo } from "os";
import { fileURLToPath } from "url";
const run_start = new Date();
const windows = process.platform === "win32";
const nativeMemory = totalmem();
const BUN_JSC_forceRAMSizeNumber = parseInt(process.env["BUN_JSC_forceRAMSize"] || "0", 10);
let BUN_JSC_forceRAMSize = Number(BigInt(nativeMemory) >> BigInt(2)) + "";
if (!(Number.isSafeInteger(BUN_JSC_forceRAMSizeNumber) && BUN_JSC_forceRAMSizeNumber > 0)) {
BUN_JSC_forceRAMSize = BUN_JSC_forceRAMSizeNumber + "";
const force_ram_size_input = parseInt(process.env["BUN_JSC_forceRAMSize"] || "0", 10);
let force_ram_size = Number(BigInt(nativeMemory) >> BigInt(2)) + "";
if (!(Number.isSafeInteger(force_ram_size_input) && force_ram_size_input > 0)) {
force_ram_size = force_ram_size_input + "";
}
const cwd = resolve(fileURLToPath(import.meta.url), "../../../../");
process.chdir(cwd);
const isAction = !!process.env["GITHUB_ACTION"];
const ci = !!process.env["GITHUB_ACTIONS"];
const enableProgressBar = !ci;
let testList = [];
if (process.platform == "win32") {
testList = readFileSync("test/windows-test-allowlist.txt", "utf8")
.replaceAll("\r", "")
.split("\n")
.map(x => x.trim().replaceAll("/", "\\"))
.filter(x => !!x && !x.startsWith("#"));
function defaultConcurrency() {
// Concurrency causes more flaky tests, only enable it by default on windows
// See https://github.com/oven-sh/bun/issues/8071
if (windows) {
return Math.floor((cpus().length - 2) / 2);
}
return 1;
}
const run_concurrency = Math.max(Number(process.env["BUN_TEST_CONCURRENCY"] || defaultConcurrency(), 10), 1);
const extensions = [".js", ".ts", ".jsx", ".tsx"];
const git_sha =
process.env["GITHUB_SHA"] ?? spawnSync("git", ["rev-parse", "HEAD"], { encoding: "utf-8" }).stdout.trim();
function isTest(path) {
if (!basename(path).includes(".test.") || !extensions.some(ext => path.endsWith(ext))) {
return false;
}
if (testList.length > 0) {
return testList.some(testPattern => path.includes(testPattern));
}
return true;
}
@@ -50,103 +58,368 @@ function* findTests(dir, query) {
}
}
var failingTests = [];
let bunExe = process.argv[2] ?? "bun";
try {
const { error } = spawnSync(bunExe, ["--revision"]);
if (error) throw error;
} catch {
console.error(bunExe + " is not installed");
// pick the last one, kind of a hack to allow 'bun run test bun-release' to test the release build
let bunExe = (process.argv.length > 2 ? process.argv[process.argv.length - 1] : null) ?? "bun";
const { error, stdout: revision_stdout } = spawnSync(bunExe, ["--revision"], {
env: { ...process.env, BUN_DEBUG_QUIET_LOGS: 1 },
});
if (error) {
if (error.code !== "ENOENT") throw error;
console.error(`\x1b[31merror\x1b[0;2m:\x1b[0m Could not find Bun executable at '${bunExe}'`);
process.exit(1);
}
const revision = revision_stdout.toString().trim();
const ntStatusPath = 'C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\shared\\ntstatus.h';
let ntStatusHCached = null;
const { error: error2, stdout: argv0_stdout } = spawnSync(bunExe, ["-e", "console.log(process.argv[0])"], {
env: { ...process.env, BUN_DEBUG_QUIET_LOGS: 1 },
});
if (error2) throw error2;
const argv0 = argv0_stdout.toString().trim();
console.log(`Testing ${argv0} v${revision}`);
const ntStatusPath = "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\shared\\ntstatus.h";
let ntstatus_header_cache = null;
function lookupWindowsError(code) {
if (ntStatusHCached === null) {
if (ntstatus_header_cache === null) {
try {
ntStatusHCached = readFileSync(ntStatusPath, 'utf-8');
ntstatus_header_cache = readFileSync(ntStatusPath, "utf-8");
} catch {
console.error(`could not find ntstatus.h to lookup error code: ${ntStatusPath}`);
ntStatusHCached = '';
ntstatus_header_cache = "";
}
}
const match = ntStatusHCached.match(new RegExp(`(STATUS_\\w+).*0x${code.toString(16)}`, 'i'));
const match = ntstatus_header_cache.match(new RegExp(`(STATUS_\\w+).*0x${code.toString(16)}`, "i"));
if (match) {
return match[1];
}
return `unknown`;
return null;
}
const failing_tests = [];
const passing_tests = [];
const fixes = [];
const regressions = [];
async function runTest(path) {
const name = path.replace(cwd, "").slice(1);
try {
var {
stdout,
stderr,
status: exitCode,
signal,
error: timedOut,
} = spawnSync(bunExe, ["test", resolve(path)], {
stdio: "inherit",
let exitCode, signal, err, output;
const expected_crash_reason = windows
? await readFile(resolve(path), "utf-8").then(data => {
const match = data.match(/@known-failing-on-windows:(.*)\n/);
return match ? match[1].trim() : null;
})
: null;
const start = Date.now();
await new Promise((done, reject) => {
const proc = spawn(bunExe, ["test", resolve(path)], {
stdio: ["ignore", "pipe", "pipe"],
timeout: 1000 * 60 * 3,
env: {
...process.env,
FORCE_COLOR: "1",
BUN_GARBAGE_COLLECTOR_LEVEL: "1",
BUN_JSC_forceRAMSize,
BUN_JSC_forceRAMSize: force_ram_size,
BUN_RUNTIME_TRANSPILER_CACHE_PATH: "0",
// reproduce CI results locally
GITHUB_ACTION: process.env.GITHUB_ACTION ?? "true",
GITHUB_ACTIONS: process.env.GITHUB_ACTIONS ?? "true",
BUN_DEBUG_QUIET_LOGS: "1",
},
});
} catch (e) {
console.error(e);
}
if(signal) {
console.error(`Test ${name} was killed by signal ${signal}`);
}
const chunks = [];
proc.stdout.on("data", chunk => {
chunks.push(chunk);
if (run_concurrency === 1) process.stdout.write(chunk);
});
proc.stderr.on("data", chunk => {
chunks.push(chunk);
if (run_concurrency === 1) process.stderr.write(chunk);
});
if(process.platform === 'win32' && exitCode > 256) {
console.error(`Test ${name} crashed with exit code ${exitCode.toString(16)} (${lookupWindowsError(exitCode)})`);
}
proc.on("exit", (code_, signal_) => {
exitCode = code_;
signal = signal_;
output = Buffer.concat(chunks).toString();
done();
});
proc.on("error", err_ => {
err = err_;
done();
});
});
const passed = exitCode === 0 && !timedOut;
const passed = exitCode === 0 && !err && !signal;
let reason = "";
if (!passed) {
failingTests.push(name);
if (timedOut) console.error(timedOut);
}
}
var tests = [];
var testFileNames = [];
for (const path of findTests(resolve(cwd, "test"))) {
testFileNames.push(path);
tests.push(runTest(path).catch(console.error));
}
await Promise.allSettled(tests);
rmSync("failing-tests.txt", { force: true });
if (isAction) {
if (failingTests.length > 0) {
action.setFailed(`${failingTests.length} files with failing tests`);
}
action.setOutput("failing_tests", failingTests.map(a => `- \`${a}\``).join("\n"));
action.setOutput("failing_tests_count", failingTests.length);
action.summary.addHeading(`${tests.length} files with tests ran`).addList(testFileNames);
await action.summary.write();
} else {
if (failingTests.length > 0) {
console.log(`${failingTests.length} files with failing tests:`);
for (const test of failingTests) {
console.log(`- ${resolve(test)}`);
let match;
if (err && err.message.includes("timed")) {
reason = "hang";
} else if ((match = output && output.match(/thread \d+ panic: (.*)\n/))) {
reason = 'panic "' + match[1] + '"';
} else if (err) {
reason = (err.name || "Error") + ": " + err.message;
} else if (signal) {
reason = signal;
} else if (exitCode === 1) {
const failMatch = output.match(/\x1b\[31m\s(\d+) fail/);
if (failMatch) {
reason = failMatch[1] + " failing";
} else {
reason = "code 1";
}
} else {
const x = windows && lookupWindowsError(exitCode);
if (x) {
if (x === "STATUS_BREAKPOINT") {
if (output.includes("Segmentation fault at address")) {
reason = "STATUS_ACCESS_VIOLATION";
}
}
reason = x;
} else {
reason = "code " + exitCode;
}
}
}
writeFileSync("failing-tests.txt", failingTests.join("\n"));
const duration = (Date.now() - start) / 1000;
if (run_concurrency !== 1 && enableProgressBar) {
// clear line
process.stdout.write("\x1b[2K\r");
}
console.log(
`\x1b[2m${formatTime(duration).padStart(6, " ")}\x1b[0m ${passed ? "\x1b[32m✔" : expected_crash_reason ? "\x1b[33m⚠" : "\x1b[31m✖"
} ${name}\x1b[0m${reason ? ` (${reason})` : ""}`,
);
finished++;
if (run_concurrency !== 1 && enableProgressBar) {
writeProgressBar();
}
if (run_concurrency > 1 && ci) {
process.stderr.write(output);
}
if (!passed) {
if (reason) {
if (windows && !expected_crash_reason) {
regressions.push({ path: name, reason, output });
}
}
failing_tests.push({ path: name, reason, output, expected_crash_reason });
if (err) console.error(err);
} else {
if (windows && expected_crash_reason !== null) {
fixes.push({ path: name, output, expected_crash_reason });
}
passing_tests.push(name);
}
}
process.exit(Math.min(failingTests.length, 127));
const queue = [...findTests(resolve(cwd, "test"))];
let running = 0;
let total = queue.length;
let finished = 0;
let on_entry_finish = null;
function writeProgressBar() {
const barWidth = Math.min(process.stdout.columns || 40, 80) - 2;
const percent = (finished / total) * 100;
const bar = "=".repeat(Math.floor(percent / 2));
const str1 = `[${finished}/${total}] [${bar}`;
process.stdout.write(`\r${str1}${" ".repeat(barWidth - str1.length)}]`);
}
while (queue.length > 0) {
if (running >= run_concurrency) {
await new Promise(resolve => (on_entry_finish = resolve));
continue;
}
const path = queue.shift();
running++;
runTest(path)
.catch(e => {
console.error("Bug in bun-internal-test");
console.error(e);
process.exit(1);
})
.finally(() => {
running--;
if (on_entry_finish) {
on_entry_finish();
on_entry_finish = null;
}
});
}
while (running > 0) {
await Promise.race([
new Promise(resolve => (on_entry_finish = resolve)),
new Promise(resolve => setTimeout(resolve, 1000)),
]);
}
console.log("\n");
function linkToGH(linkTo) {
return `https://github.com/oven-sh/bun/blob/${git_sha}/${linkTo}`;
}
function sectionLink(linkTo) {
return "#" + linkTo.replace(/[^a-zA-Z0-9_-]/g, "").toLowerCase();
}
const failingTestDisplay = failing_tests
.filter(({ reason }) => !regressions.some(({ path }) => path === path))
.map(({ path, reason }) => `- [\`${path}\`](${sectionLink(path)})${reason ? ` ${reason}` : ""}`)
.join("\n");
// const passingTestDisplay = passing_tests.map(path => `- \`${path}\``).join("\n");
rmSync("report.md", { force: true });
const uptime = process.uptime();
function formatTime(seconds) {
if (seconds < 60) {
return seconds.toFixed(1) + "s";
} else if (seconds < 60 * 60) {
return (seconds / 60).toFixed(0) + "m " + formatTime(seconds % 60);
} else {
return (seconds / 60 / 60).toFixed(0) + "h " + formatTime(seconds % (60 * 60));
}
}
const header = `
host: ${process.env["GITHUB_RUN_ID"] ? "GitHub Actions: " : ""}${userInfo().username}@${hostname()}
platform: ${process.platform} ${process.arch}
bun: ${argv0}
version: v${revision}
date: ${run_start.toISOString()}
duration: ${formatTime(uptime)}
total: ${total} files
failing: ${failing_tests.length} files
passing: ${passing_tests.length} files
percent: ${((passing_tests.length / total) * 100).toFixed(2)}%
`.trim();
console.log("\n" + "-".repeat(Math.min(process.stdout.columns || 40, 80)) + "\n");
console.log(header);
console.log("\n" + "-".repeat(Math.min(process.stdout.columns || 40, 80)) + "\n");
let report = `# bun test on ${process.env["GITHUB_REF"] ??
spawnSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], { encoding: "utf-8" }).stdout.trim()
}
\`\`\`
${header}
\`\`\`
`;
if (fixes.length > 0) {
report += `## Fixes\n\n`;
report += "The following tests had @known-failing-on-windows but now pass:\n\n";
report += fixes
.map(
({ path, expected_crash_reason }) => `- [\`${path}\`](${sectionLink(path)}) (before: ${expected_crash_reason})`,
)
.join("\n");
report += "\n\n";
}
if (regressions.length > 0) {
report += `## Regressions\n\n`;
report += regressions
.map(
({ path, reason, expected_crash_reason }) =>
`- [\`${path}\`](${sectionLink(path)}) ${reason}${expected_crash_reason ? ` (expected: ${expected_crash_reason})` : ""
}`,
)
.join("\n");
report += "\n\n";
}
if (failingTestDisplay.length > 0) {
report += `## ${windows ? "Known " : ""}Failing tests\n\n`;
report += failingTestDisplay;
report += "\n\n";
}
// if(passingTestDisplay.length > 0) {
// report += `## Passing tests\n\n`;
// report += passingTestDisplay;
// report += "\n\n";
// }
if (failing_tests.length) {
report += `## Failing tests log output\n\n`;
for (const { path, output, reason, expected_crash_reason } of failing_tests) {
report += `### ${path}\n\n`;
report += "[Link to file](" + linkToGH(path) + ")\n\n";
if (windows && reason !== expected_crash_reason) {
report += `To mark this as a known failing test, add this to the start of the file:\n`;
report += `\`\`\`ts\n`;
report += `// @known-failing-on-windows: ${reason}\n`;
report += `\`\`\`\n\n`;
} else {
report += `${reason}\n\n`;
}
report += "```\n";
report += output
.replace(/\x1b\[[0-9;]*m/g, "")
.replace(/^::(group|endgroup|error|warning|set-output|add-matcher|remove-matcher).*$/gm, "");
report += "```\n\n";
}
}
writeFileSync("test-report.md", report);
writeFileSync(
"test-report.json",
JSON.stringify({
failing_tests,
passing_tests,
fixes,
regressions,
}),
);
console.log("-> test-report.md, test-report.json");
if (ci) {
if (windows) {
action.setOutput("regressing_tests", regressions.map(({ path }) => `- \`${path}\``).join("\n"));
action.setOutput("regressing_test_count", regressions.length);
}
if (failing_tests.length > 0) {
action.setFailed(`${failing_tests.length} files with failing tests`);
}
action.setOutput("failing_tests", failingTestDisplay);
action.setOutput("failing_tests_count", failing_tests.length);
let truncated_report = report;
if (truncated_report.length > 512 * 1000) {
truncated_report = truncated_report.slice(0, 512 * 1000) + "\n\n...truncated...";
}
action.summary.addRaw(truncated_report);
await action.summary.write();
} else {
if (windows && (regressions.length > 0 || fixes.length > 0)) {
console.log(
"\n\x1b[34mnote\x1b[0;2m:\x1b[0m If you would like to update the @known-failing-on-windows annotations, run `bun update-known-failures`",
);
}
}
process.exit(failing_tests.length ? 1 : 0);

View File

@@ -0,0 +1,49 @@
import assert from "assert";
import { existsSync, readFileSync, writeFileSync } from "fs";
import { join } from "path";
import { fileURLToPath } from "url";
if (process.platform !== "win32") {
console.log("This script is only intended to be run on Windows.");
process.exit(1);
}
process.chdir(join(fileURLToPath(import.meta.url), "../../../../"));
if (!existsSync("test-report.json")) {
console.log("No test report found. Please run `bun run test` first.");
process.exit(1);
}
const test_report = JSON.parse(readFileSync("test-report.json", "utf8"));
assert(Array.isArray(test_report.failing_tests));
for (const { path, reason, expected_crash_reason } of test_report.failing_tests) {
assert(path);
assert(reason);
if (expected_crash_reason !== reason) {
const old_content = readFileSync(path, "utf8");
if (!old_content.includes("// @known-failing-on-windows")) {
let content = old_content.replace(/\/\/\s*@known-failing-on-windows:.*\n/, "");
if (reason) {
content = `// @known-failing-on-windows: ${reason}\n` + content;
}
writeFileSync(path, content, "utf8");
console.log(path);
}
}
}
for (const { path } of test_report.fixes) {
assert(path);
const old_content = readFileSync(path, "utf8");
let content = old_content.replace(/\/\/\s*@known-failing-on-windows:.*\n/, "");
if (content !== old_content) {
writeFileSync(path, content, "utf8");
console.log(path);
}
}

View File

@@ -279,7 +279,7 @@ async function sendResponse(response: unknown): Promise<void> {
}
await fetch(`runtime/invocation/${requestId}/response`, {
method: "POST",
body: response === null ? null : (typeof response === 'string' ? response : JSON.stringify(response)),
body: response === null ? null : typeof response === "string" ? response : JSON.stringify(response),
});
}
@@ -594,8 +594,8 @@ class LambdaServer implements Server {
typeof options.port === "number"
? options.port
: typeof options.port === "string"
? parseInt(options.port)
: this.port;
? parseInt(options.port)
: this.port;
this.hostname = options.hostname ?? this.hostname;
this.development = options.development ?? this.development;
}

View File

@@ -87,12 +87,13 @@ export class BuildCommand extends Command {
this.log("Saving...", output);
const archiveBuffer = await archive
.generateAsync({
type: 'blob',
type: "blob",
compression: "DEFLATE",
compressionOptions: {
level: 9,
},
}).then(blob => blob.arrayBuffer());
})
.then(blob => blob.arrayBuffer());
writeFileSync(output, archiveBuffer);
this.log("Saved");
}

View File

@@ -32,54 +32,60 @@ export class PublishCommand extends BuildCommand {
}
const { layer, region, arch, output, public: isPublic } = flags;
if (region.includes("*")) {
// prettier-ignore
const result = this.#aws([
"ec2",
"describe-regions",
"--query", "Regions[].RegionName",
"--output", "json"
]);
// biome-ignore: format ignore
const result = this.#aws(["ec2", "describe-regions", "--query", "Regions[].RegionName", "--output", "json"]);
region.length = 0;
for (const name of JSON.parse(result)) {
region.push(name);
}
} else if (!region.length) {
// prettier-ignore
region.push(this.#aws([
"configure",
"get",
"region"
]));
// biome-ignore: format ignore
region.push(this.#aws(["configure", "get", "region"]));
}
this.log("Publishing...");
for (const regionName of region) {
for (const layerName of layer) {
// prettier-ignore
// biome-ignore: format ignore
const result = this.#aws([
"lambda",
"publish-layer-version",
"--layer-name", layerName,
"--region", regionName,
"--description", "Bun is an incredibly fast JavaScript runtime, bundler, transpiler, and package manager.",
"--license-info", "MIT",
"--compatible-architectures", arch === "x64" ? "x86_64" : "arm64",
"--compatible-runtimes", "provided.al2", "provided",
"--zip-file", `fileb://${output}`,
"--output", "json",
"--layer-name",
layerName,
"--region",
regionName,
"--description",
"Bun is an incredibly fast JavaScript runtime, bundler, transpiler, and package manager.",
"--license-info",
"MIT",
"--compatible-architectures",
arch === "x64" ? "x86_64" : "arm64",
"--compatible-runtimes",
"provided.al2",
"provided",
"--zip-file",
`fileb://${output}`,
"--output",
"json",
]);
const { LayerVersionArn } = JSON.parse(result);
this.log("Published", LayerVersionArn);
if (isPublic) {
// prettier-ignore
// biome-ignore: format ignore
this.#aws([
"lambda",
"add-layer-version-permission",
"--layer-name", layerName,
"--region", regionName,
"--version-number", LayerVersionArn.split(":").pop(),
"--statement-id", `${layerName}-public`,
"--action", "lambda:GetLayerVersion",
"--principal", "*",
"--layer-name",
layerName,
"--region",
regionName,
"--version-number",
LayerVersionArn.split(":").pop(),
"--statement-id",
`${layerName}-public`,
"--action",
"lambda:GetLayerVersion",
"--principal",
"*",
]);
}
}

View File

@@ -359,7 +359,7 @@ export const spawnSync = ((...args): SyncSubprocess => {
}
let input: ArrayBufferView | string | undefined;
if (opts.stdio[0] && typeof opts.stdio[0] !== 'string') {
stdio[0] = null; // will be overriden by chp.spawnSync "input" option
stdio[0] = null; // will be overridden by chp.spawnSync "input" option
//! Due to the fully async nature of Blobs, Responses and Requests,
//! we can't synchronously get the data out of them here in userland.
if (opts.stdio[0] instanceof Blob) throw new NotImplementedError('Bun.spawnSync({ stdin: <Blob> })', spawnSync);

View File

@@ -32,9 +32,7 @@ for (const asset of release.assets) {
const url = asset.browser_download_url;
const response = await fetch(url);
if (!response.ok) {
throw new Error(
`Failed to download asset: ${response.status} ${url}`
);
throw new Error(`Failed to download asset: ${response.status} ${url}`);
}
const name = asset.name;
let contentType: string;
@@ -86,9 +84,7 @@ async function uploadToS3({
headers,
});
if (!response.ok) {
throw new Error(
`Failed to upload to S3: ${response.status} ${response.statusText}`
);
throw new Error(`Failed to upload to S3: ${response.status} ${response.statusText}`);
}
}

View File

@@ -1,6 +0,0 @@
{
"arrowParens": "avoid",
"printWidth": 80,
"trailingComma": "all",
"useTabs": false
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

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