Compare commits

..

449 Commits

Author SHA1 Message Date
Dylan Conway
cf46115f6d only if there are instance members 2023-02-13 13:44:25 -05:00
Derrick Farris
ef75cd4658 fix(FormData): make String explicit, thanks @dylan-conway (#2065) 2023-02-13 13:04:54 -05:00
Derrick Farris
af3f42e630 fix(FormData): add string literal operator (#2064) 2023-02-13 09:42:49 -08:00
Jarred Sumner
37186f4b0a Add pretty printer for FormData 2023-02-13 04:37:23 -08:00
Michał Warda
f310d7414b Add dynamic port assigning to Bun.serve (#2062) 2023-02-13 03:08:11 -08:00
Derrick Farris
739de2c9cd feat(napi): add napi_get_value_bigint_words (#2061)
* feat(napi): add `napi_get_value_bigint_words`

* fix(napi): handle `napi_get_value_bigint_words` arr too small
2023-02-13 03:07:18 -08:00
Jarred Sumner
0db8cdf4e9 Fixes https://github.com/oven-sh/bun/issues/1456 2023-02-13 03:05:26 -08:00
Jarred Sumner
246db4fed0 Add FormData bench snippet 2023-02-13 01:36:43 -08:00
Jarred Sumner
aa0762e466 Implement FormData (#2051)
* Backport std::forward change

* Implement `FormData`

* Fix io_darwin headers issue

* Implement `Blob` support in FormData

* Add test for file upload

* Fix bug with Blob not reading Content-Type

* Finish implementing FormData

* Add FormData to types

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-02-13 00:50:15 -08:00
Alex Lam S.L
cdbc620104 [install] support git://github.com/ dependencies (#2059) 2023-02-12 14:44:39 -08:00
Ashcon Partovi
bb2aaa36fb Add release signing to release workflow 2023-02-12 13:10:10 -08:00
Jarred Sumner
f4f88701c5 prettier + stop server 2023-02-12 04:41:18 -08:00
Michał Warda
cc214baacf Return server on listen (#2057) 2023-02-12 04:37:28 -08:00
Jarred Sumner
83473c60df Set require("module").globalPaths to empty array
https://github.com/oven-sh/bun/issues/1641#issuecomment-1427017442
2023-02-12 04:35:52 -08:00
Alex Lam S.L
8b4e58f3d2 fix string corruption in FS entry cache (#2055) 2023-02-11 21:35:33 -08:00
Alex Lam S.L
30e82c5df4 fix segfault during non-install script execution (#2045) 2023-02-11 20:40:18 -08:00
Derrick Farris
9eba1e0e3f [WIP] feat(napi): add napi-fatal-exception (#2054)
* feat(napi): add `napi-fatal-exception`

* fix(napi): fatal_exception - add symbol to list, don't optimize away
2023-02-11 20:20:25 -08:00
Jarred Sumner
675529bd0c Fixes https://github.com/oven-sh/bun/issues/2052 2023-02-11 18:11:09 -08:00
Jarred Sumner
5528c0fa47 Backport std::forward change 2023-02-11 17:31:16 -08:00
Justin Whear
c208c4e319 Fix #631: bun add throwing JSON lexer bug (#2041)
* add double-backslash to list of control chars

* update test

* stderr as string
2023-02-10 19:05:32 -08:00
Eric Zhang
10650cced2 Fix PATH setup in macOS setup instructions (#2044)
Very minor! I was just going through the setup instructions and had a bit of a double take.
2023-02-10 15:16:51 -08:00
Jarred Sumner
8466e60e3a update to simdutf 3.2.0
thanks @lemire
2023-02-10 15:02:30 -08:00
Derrick Farris
b1aac9ff6d fix(string_immutable): fix toUTF16Alloc for bindgen w/ use_simdutf = false (#2042) 2023-02-10 13:12:14 -08:00
Ashcon Partovi
ed2e0e1617 Add bun-ecosystem for running tests on npm packages 2023-02-10 09:47:59 -08:00
Alex Lam S.L
09585c4b24 [install] fix duplicate check on peerDependencies (#2039)
fixes #2037
2023-02-10 09:23:40 -08:00
Alex Lam S.L
5181aa54e2 drop ASCII double-scan and other minor clean-ups (#2038) 2023-02-10 09:22:24 -08:00
Jarred Sumner
995880a7ef Enable https://github.com/tc39/proposal-set-methods 2023-02-10 00:27:06 -08:00
Jarred Sumner
941c6ed814 Upgrade WebKit 2023-02-09 21:28:50 -08:00
Alex Lam S.L
6052a3edbd fix assertion failure (#2033) 2023-02-09 21:20:11 -08:00
Alex Lam S.L
6fd7c1921e [install] fix flaky tests (#2032) 2023-02-09 20:35:58 -08:00
Alex Lam S.L
119120d21c [simdutf] workaround validation OOB access (#2031) 2023-02-09 20:26:23 -08:00
Jarred Sumner
4bedd3833d Workaround https://github.com/simdutf/simdutf/issues/213 2023-02-09 19:06:20 -08:00
Alex Lam S.L
2abfa8abd2 [streams] fix byte accounting (#2029)
fixes #1939
2023-02-09 17:04:36 -08:00
Jarred Sumner
ad9d4fb0c4 Add a note about builtins 2023-02-09 14:09:50 -08:00
Jarred Sumner
523b112945 [bun:test] Auto-import jest globals in test files 2023-02-09 00:30:40 -08:00
Jarred Sumner
8aa29040e6 move some code around 2023-02-08 23:09:24 -08:00
Jarred Sumner
a2afb252bf Update CONTRIBUTING.md 2023-02-08 21:46:53 -08:00
Jarred Sumner
abb89f489f Create CONTRIBUTING.md 2023-02-08 20:47:11 -08:00
Jarred Sumner
ddec9e0bf6 handle more cases with util.isError 2023-02-08 17:18:02 -08:00
Jarred Sumner
4962bea4fc cleanup util.test 2023-02-08 17:17:40 -08:00
Alex Lam S.L
f31330d3e2 [install] pick latest tagged version by default (#2016)
* [install] pick `latest` tagged version by default

fixes #1993

* update `package.json` the same way as `npm
2023-02-08 16:28:29 -08:00
Ashcon Partovi
ee8ccca605 Remove test run workflow, for now 2023-02-08 16:11:24 -08:00
Dylan Conway
6fdbb25f9a utf16 to utf8 conversion validation (#2001)
* use replacement character for invalid surrogate pairs

* return index of non-ascii

* non-allocating case

* edge cases

* function rename

* oops

* get length once, index counter
2023-02-08 14:42:10 -08:00
RobViren
b8c0554839 Fix minor version bug for README.md (#2013)
Addresses issue #2012 and corrects the minor version to the current minor version
2023-02-08 14:39:57 -08:00
Alex Lam S.L
18807cef03 [install] assorted fixes & improvements (#2011)
- take `peerDependencies` into account during package placement
- do not recursively resolve `workspaces` (matches `npm`)
- link binaries to non-root packages correctly
- prune empty nodes during dependency tree construction
- support non-standard `workspace:` specifier
2023-02-08 14:37:14 -08:00
Ashcon Partovi
cbc28afd51 Fix 'MissingPackageJSON' in Dockerfile
Closes #2008
2023-02-07 14:33:22 -08:00
Jarred Sumner
7886bce8c8 cleanup 2023-02-07 10:51:55 -08:00
Ashcon Partovi
7cd26232b1 Update docker image in README 2023-02-07 08:46:09 -08:00
Ashcon Partovi
a0b0cd6844 Fix bugs with release script 2023-02-07 04:47:36 -08:00
Jarred Sumner
52f9c3d05e set the type 2023-02-06 23:27:18 -08:00
Jarred Sumner
f947987a2c default not configurable 2023-02-06 23:19:12 -08:00
Jarred Sumner
30106c4f54 Fix failing test in debug mode 2023-02-06 23:19:05 -08:00
Jarred Sumner
34b2d7fe57 Mark things as DontDelete 2023-02-06 23:15:32 -08:00
Jarred Sumner
153834cf5c Throw on process.binding 2023-02-06 23:15:23 -08:00
Jarred Sumner
6aea31f4fc cleanup 2023-02-06 22:41:44 -08:00
Jarred Sumner
0fd144993c Fix test failing on macOS 2023-02-06 22:41:37 -08:00
Jarred Sumner
6699fe14e7 minor cleanup 2023-02-06 22:32:10 -08:00
Jarred Sumner
add7b1101e Add bounds check 2023-02-06 22:29:24 -08:00
Alex Lam S.L
5a19f8434b [WIP] fix corner cases with aliases dependencies (#2000)
* fix corner cases with aliases dependencies

* in-memory convert legacy `bun.lockb`
2023-02-06 22:24:34 -08:00
Jarred Sumner
d5f3bb1c74 Update text-decoder.mjs 2023-02-06 22:13:05 -08:00
Colin McDonnell
08e33fbd42 Fix gaps in types (#2003)
* Add type for clearImmediate

* Expose Crypto class

* Add types for CustomEvent

* Add types for module and exports

* Add types for global

* Add types for DOMException

* Add types for WebAssembly

* Update formatting

* Fix clearTimeout

* Fix formatting

* Update formatting

* Remove log

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-02-06 21:36:36 -08:00
Jarred Sumner
7ddbbc53b4 Make Stat functions fast 2023-02-06 21:18:58 -08:00
Jarred Sumner
85611272c6 bump 2023-02-06 20:35:59 -08:00
Jarred Sumner
c40912b8dc formatting 2023-02-06 20:28:59 -08:00
Jarred Sumner
77974f2a6e tweaks to generator 2023-02-06 19:27:21 -08:00
Jarred Sumner
ed72bee373 Mark some things as not configurable 2023-02-06 19:27:16 -08:00
Jarred Sumner
05f3a22cba Use new bindings for Stat
Fixes #1999
2023-02-06 18:40:52 -08:00
Jarred Sumner
f5df1044d4 Fix build 2023-02-06 18:39:03 -08:00
Jarred Sumner
4329f6ad16 Backport https://github.com/WebKit/WebKit/pull/9713 2023-02-06 14:21:25 -08:00
Michał Warda
fd4668d97c Expose Dirent and Stats (#1998)
* Expose dirent and stats

* Expose Dirent and Stats inside fs

* Add tests for Dirent and Stats exposing

* Automatically generate bindings
2023-02-06 14:15:20 -08:00
Ciro Spaciari
8c4ed963ec fix(uWS:capi) uws_req_set_yield typo and uws_res_override_write_offset (#1996) 2023-02-06 12:59:04 -08:00
Colin McDonnell
e7f9ce47f4 Add types for node:console and node:perf_hooks (#1982)
* Add types for node:console and node:perf_hooks

* Add types for util/types

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-02-06 12:57:19 -08:00
Dylan Conway
98022bec1e mark binding 2023-02-06 12:23:59 -08:00
Cheng Shao
397f559e77 Fix URL of wasi-js (#1997) 2023-02-06 11:35:01 -08:00
Jarred Sumner
ca2e708be1 speed it up a little more 2023-02-05 07:07:35 -08:00
Jarred Sumner
8649136845 substringSharingImpl allocates, do not use 2023-02-05 06:17:21 -08:00
Jarred Sumner
e8fe6dd2f8 Faster Buffer.toString("ascii") 2023-02-05 04:14:16 -08:00
Gaurish Sethia
df126b2f3b Bump querystring-es3 (#1988)
* Add filePath property on MatchedRoute

* Fix #1880 #851

* Fix #1972 as well

* FMC

* Bump querystring-es3

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-02-04 23:15:42 -08:00
Jarred Sumner
7d3a2ca382 Add isDeepStructEqual to node:util 2023-02-04 00:34:03 -08:00
Jarred Sumner
b7c96bfaae Fixes #1978 2023-02-03 22:29:32 -08:00
Justin Whear
a2fd20e5c0 Implement os.cpus() for Linux (#1977)
* Implement os.cpus() for Linux

`os.cpus()` currently returns an empty array for all platforms.  This PR implements full functionality for Linux and has been tested on x86-64.  Other OSes will continue to return an empty array.

Note that Linux on Arm64 may report the CPU model differently; if this is the case the CPU model will currently be reported as "unknown".  As I do not have Arm64 hardware to verify and develop against, a todo has been left in the code.

* resolve issues from review
2023-02-03 18:13:33 -08:00
Jarred Sumner
de613baf81 Support passing Date to Bun.sleep 2023-02-03 17:25:25 -08:00
Jarred Sumner
4590e2b83a Add test for propagating exception 2023-02-03 17:04:47 -08:00
Jarred Sumner
2758e0cab9 Add missing crypto export
Fixes #1984
2023-02-03 16:39:16 -08:00
Jarred Sumner
7d386bf1f1 Introduce await Bun.sleep(ms) 2023-02-03 16:39:16 -08:00
Ashcon Partovi
164cd774f7 Fix types for Array.fromAsync 2023-02-03 16:29:03 -08:00
Gaurish Sethia
6469649f64 Fix/Update Typescript types (#1972)
* Add filePath property on MatchedRoute

* Fix #1880 #851

* Fix #1972 as well

* FMC

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-02-03 14:53:18 -08:00
Jarred Sumner
06d073003d fix require("perf_hooks") 2023-02-03 14:39:07 -08:00
Jarred Sumner
50f1dd61a6 allow other ArrayBufferView in Buffer functions 2023-02-03 14:39:07 -08:00
Jarred Sumner
c64d7933a1 Make it less flaky 2023-02-03 14:39:07 -08:00
Ashcon Partovi
b289b51894 Run tests on pull requests 2023-02-03 11:55:15 -08:00
Ashcon Partovi
17ad8005c7 Run tests on push 2023-02-03 11:54:31 -08:00
Dylan Conway
f572305013 another 2023-02-03 11:50:23 -08:00
Dylan Conway
17b4e5ce08 integers overflowing 2023-02-03 11:47:21 -08:00
Ashcon Partovi
3933ccab3b Attempt to debug annotations 2 2023-02-03 11:35:24 -08:00
Ashcon Partovi
92255d56c8 Attempt to debug annotations 2023-02-03 11:32:01 -08:00
Ashcon Partovi
ba076b0a2b Fix console output in bun wiptest 2023-02-03 11:23:55 -08:00
Ashcon Partovi
10600c4abd Use GitHub action SDK 2023-02-03 11:18:44 -08:00
Ashcon Partovi
d16dffa2b4 Add workflow for bun wiptest 2023-02-03 11:01:22 -08:00
Alex Lam S.L
65e0d10ee0 prettier deltas (#1973) 2023-02-02 17:29:28 -08:00
Colin McDonnell
742368f03a Update/fix types (#1955)
* WIP

* Update types

* Spacing

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-02-02 17:29:10 -08:00
Dylan Conway
242dcea2fe match formatting 2023-02-02 16:15:12 -08:00
Jarred Sumner
198322073d Update string_immutable.zig 2023-02-02 15:58:10 -08:00
Jarred Sumner
b12762af6c Fix stack overflow when console.log'ing strings 2023-02-02 15:56:16 -08:00
Ashcon Partovi
440a21eb1d Add bun-test to run bun wiptest 2023-02-02 11:57:36 -08:00
Jarred Sumner
2bc4858346 export more 2023-02-02 01:34:41 -08:00
Jarred Sumner
26d15cf542 Update build-id 2023-02-02 01:32:39 -08:00
Derrick Farris
8361513acf feat: add http.request (#1959)
* fix(node-test-helpers): make sure to call done with any Errors thrown from wrapped fn

* feat(node:http): add http.request, patch some missing apis for IncomingRequest, etc.

* fix(node:http): FakeSocket -> Socket

* refactor(node:http): only save type from IncomingMessage.options for now

* fix(node:http): remove unnecessary check for UInt8Array

* perf(node:http): globalThis.fetch -> var fetch = Bun.fetch

* todo(node:http): add notes about handling abort/timeout w/ AbortSignal

* refactor(node:http): standardize on FakeSocket and this.#fakeSocket

* fix(node:http): fix headers getter

* fix(node:http): remove _headers

* perf(node:http): make http headers lazy

* fix(node:http): return bool from keepSocketAlive
2023-02-01 19:22:29 -08:00
Dylan Conway
19eca76498 change file extension 2023-02-01 19:06:56 -08:00
Dylan Conway
3c23f9ad57 fix text encoding for utf8 (#1967)
* use character

* replacement character

* also test encoding decoded points

* increase length by 1
2023-02-01 18:48:09 -08:00
Alex Lam S.L
76f3c9c07b resolve duplicate npm dependencies correctly (#1970)
* resolve duplicate npm dependencies correctly

fixes #1952

* modify the correct reference
2023-02-01 18:13:25 -08:00
Ashcon Partovi
3a3bf33335 Stop releasing bun:0 for docker 2023-02-01 15:01:12 -08:00
Ashcon Partovi
69ee87d8e2 Add script to calculate semver for release 2023-02-01 14:53:57 -08:00
Ashcon Partovi
6d0fff4fab Fix version in bun-types canary release 2023-02-01 14:16:48 -08:00
Ashcon Partovi
f7a93fe294 Add bun-types release to canary workflow 2023-02-01 14:13:39 -08:00
Ashcon Partovi
02fc87ea29 Fix bad tag in npm publish 2023-02-01 14:03:00 -08:00
Ashcon Partovi
7f853af6f0 Add bun-types release to workflow 2023-02-01 14:00:31 -08:00
Ashcon Partovi
04309431bb Tweak commit message for robobun 2023-02-01 13:37:36 -08:00
Ashcon Partovi
fc712ead2f Add GPG key to release 2023-02-01 13:28:30 -08:00
Ashcon Partovi
e7f2d34c44 Maybe fix permissions with Homebrew 2023-02-01 12:02:43 -08:00
Ashcon Partovi
0c3e55132c Update homebrew release action 2023-02-01 11:33:08 -08:00
Ashcon Partovi
c69bbbd24f Update trustdb in Docker image 2023-02-01 11:24:12 -08:00
Ashcon Partovi
c0bfdebbd9 Fix grouping for Docker tag 2023-02-01 11:02:39 -08:00
Ashcon Partovi
9c27b5d17f Fix getting SHA for canary 2023-02-01 10:56:08 -08:00
Ashcon Partovi
9973df028b Fix missing dependency from release script 2023-02-01 10:44:19 -08:00
Ashcon Partovi
a0be199b4f Add morningly workflow to release to canary 2023-02-01 10:42:04 -08:00
Ashcon Partovi
73d6c888b9 Add bun-release package 2023-02-01 10:28:01 -08:00
Gaurish Sethia
661fca9cde Add filePath property on MatchedRoute (#1964) 2023-02-01 05:10:48 -08:00
Jarred Sumner
b0803298f9 Update javascript_core_c_api.zig 2023-02-01 00:52:45 -08:00
Jarred Sumner
6318017f84 Update module_loader.zig 2023-02-01 00:52:45 -08:00
Colin McDonnell
696d4b6267 Add target for printing version in makefile (#1957)
* Add get-*

* Add print-version target

* Webkit

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-01-31 20:35:12 -08:00
Jarred Sumner
cc4326cd82 Re-run prettier after changes 2023-01-31 17:55:16 -08:00
Jarred Sumner
c57b37d29f Handle invalid input in clear* timer 2023-01-31 17:52:17 -08:00
Jarred Sumner
b09896f06e mostly fix node:timers 2023-01-31 17:51:36 -08:00
Jarred Sumner
b7816f3175 Fixes fs.constants 2023-01-31 17:20:48 -08:00
Jarred Sumner
0dfde6f8c7 misc wasi fixes + prettier 2023-01-31 15:17:39 -08:00
Jarred Sumner
0788bc1d94 Fixes #1958 2023-01-31 15:05:52 -08:00
Jarred Sumner
28a7f27633 Remove validateion 2023-01-31 15:05:52 -08:00
Jarred Sumner
b2daf3c982 Update build-id 2023-01-31 13:32:24 -08:00
Alex Lam S.L
9598868b57 [bun add] various fixes (#1953) 2023-01-31 13:05:41 -08:00
Devin Rhode
79b32f80fa Use proper casing for tsconfig values (#1644)
See: https://share.cleanshot.com/gcB3gbXJz6RQk5tx559n
2023-01-31 12:22:50 -08:00
Jarred Sumner
4bfdad2981 Fix missing *ms getters in Stat
Related to #1949
2023-01-31 03:04:59 -08:00
Jarred Sumner
3ddd8b2fa5 Fixes #1949 2023-01-31 02:15:00 -08:00
Jarred Sumner
da598a3f37 Update build-id 2023-01-30 23:13:14 -08:00
Jarred Sumner
ad3295668f Fix crash in bun install <package-name> (#1947)
* Fix crash in `bun install <package-name>` when <package-name> already exists

* Prettier

* Add test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-01-30 23:12:41 -08:00
Jarred Sumner
f9fd7e9d08 Fixes #1928 2023-01-30 17:39:52 -08:00
Jarred Sumner
8b8bd6a405 remove log that appears in production 2023-01-30 16:14:23 -08:00
Ciro Spaciari
aa10799d8a fix utf16le fill and utf8 partial write of utf16 (#1943) 2023-01-30 12:21:23 -08:00
Alex Lam S.L
ec2c16fefa fix assert() crash (#1941) 2023-01-30 12:20:29 -08:00
Alex Lam S.L
c11bb93552 report invalid input file as test failure (#1938)
fixes #1935
2023-01-30 01:55:32 -08:00
Alex Lam S.L
5c30983d5d [bunx] fix version parsing (#1937) 2023-01-30 00:33:13 -08:00
Jarred Sumner
c9ca729493 Update buffer-create.mjs 2023-01-29 22:59:16 -08:00
Jarred Sumner
9cd9df698a Update child_process-node.test.js 2023-01-29 22:42:03 -08:00
Jarred Sumner
57edf3d91f Skip flaky test 2023-01-29 22:36:29 -08:00
Jarred Sumner
f9b14dc87b Fix flaky websocket test
cc @dylan-conway, the tests should be able to run when cwd is not the test folder
2023-01-29 22:36:24 -08:00
Jarred Sumner
a9bdc0fd44 Add check in test 2023-01-29 22:35:32 -08:00
Jarred Sumner
703bee976b [breaking] Add binaryType option to Bun.connect & Bun.listen
This is a breaking change because the default is `Buffer`, but previously the default was `Uint8Array`. While `Buffer` is a subclass of `Uint8Array`, it still technically is a breaking change because `slice` in `Uint8Array` is not semantically identical to `slice` in `Buffer`

cc @colinhacks, the .d.ts changes I made here aren't great.
2023-01-29 22:33:37 -08:00
Jarred Sumner
eb5105aa09 Update buffer.test.js 2023-01-29 21:27:52 -08:00
Jarred Sumner
552a1940eb [buffer] More passing Node.js tests 2023-01-29 21:27:42 -08:00
Jarred Sumner
98becc3538 Add another latin1 test 2023-01-29 21:23:10 -08:00
Jarred Sumner
49d8316922 Make this more careful 2023-01-29 19:01:47 -08:00
Jarred Sumner
7a496fa41a Fixes #1915 2023-01-29 19:01:39 -08:00
Jarred Sumner
4211f733d1 cleanup 2023-01-29 18:59:14 -08:00
Jarred Sumner
44eec0c5bb Fixes #1933 2023-01-29 16:29:39 -08:00
Agnieszka Stec
ac64d87a1c Update README.md (#1934)
Hi, just caught 2 small typos in Readme
2023-01-29 14:58:26 -08:00
Jarred Sumner
8e52e36846 [buffer] Buffer.byteLength passes Node.js tests 2023-01-29 03:45:58 -08:00
Jarred Sumner
348e72356b Bump WebKit 2023-01-29 01:26:16 -08:00
Jarred Sumner
035d31904a Make the build less flaky 2023-01-29 00:25:10 -08:00
Jarred Sumner
192629c8ca Fix bug in fs.openSync 2023-01-29 00:10:46 -08:00
Jarred Sumner
75181ea1f3 Add helper 2023-01-29 00:10:46 -08:00
Alex Lam S.L
d9c1a18776 [bun add] fix more corner cases (#1930) 2023-01-28 23:54:47 -08:00
Jarred Sumner
f087388ebc Support running WASI (WebAssembly) files using bun run (#1929)
* another micro bench

* Support running WASI

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-01-28 23:23:26 -08:00
Alex Lam S.L
48eb0c12ab parse git+https://github.com/ as GitHub URLs (#1926)
fixes #1921
2023-01-28 22:14:07 -08:00
Alex Lam S.L
fe389ad5ab normalise bun add package specifiers (#1924)
- fix invalid buffer references

fixes #1920
2023-01-28 21:30:46 -08:00
Alex Lam S.L
97b637a0bc fix corner cases with aliased dependencies (#1927) 2023-01-28 15:49:30 -08:00
u9g
7e9c88aa41 Fix if condition always being true (#1923) 2023-01-28 14:07:57 -08:00
Alex Lam S.L
07258bd559 [WIP] append GitHub package after fully parsed (#1911) 2023-01-28 07:05:28 -08:00
Jarred Sumner
0646efbf30 fix broken build
this breaks the build

@Electroid feel free to re-enable once it works
2023-01-28 05:47:22 -08:00
Jarred Sumner
517bdbdd0c Update bun-linux-build.yml 2023-01-28 05:03:00 -08:00
Jarred Sumner
7f8be29f25 [buffer] Use jsDynamicCast 2023-01-28 04:06:35 -08:00
Jarred Sumner
7db4b90837 commit failing tests 2023-01-28 04:03:45 -08:00
Jarred Sumner
cd48346ca8 use wrapper 2023-01-28 04:03:33 -08:00
Jarred Sumner
1b6a99636d [buffer] Do not throw in getters 2023-01-28 03:52:47 -08:00
Jarred Sumner
188c1f1f75 [buffer] Use length instead of byteLength for non-uint8array and non-arraybuffer 2023-01-28 03:50:32 -08:00
Jarred Sumner
812490e4a4 [buffer] Add missing offset property 2023-01-28 03:49:57 -08:00
Jarred Sumner
128a293901 Make the parser error in bun install look better 2023-01-28 01:09:42 -08:00
Jarred Sumner
6557df2912 Fixes #1913 2023-01-28 01:00:26 -08:00
Jarred Sumner
aff91436c0 Buffer.from doesn't need to be the Buffer constructor 2023-01-27 22:55:46 -08:00
Jarred Sumner
8075158639 Make Bun.dns lazy 2023-01-27 21:58:33 -08:00
Jarred Sumner
2757dc5e1b prettier 2023-01-27 21:56:48 -08:00
Jarred Sumner
cd90342a76 Fix flakiness 2023-01-27 21:56:34 -08:00
Jarred Sumner
8d622ad541 Fixes #1904 2023-01-27 21:39:40 -08:00
Ashcon Partovi
ed5bcf17fc Fix incorrect docker image 2023-01-27 21:21:26 -08:00
Ashcon Partovi
9e46ca19d8 Maybe fix path issue with Docker action 2023-01-27 21:09:12 -08:00
Ashcon Partovi
866646a98e Fix latest later... 2023-01-27 21:00:19 -08:00
Ashcon Partovi
4118c3d0a6 Fix invalid expression, 2nd attempt 2023-01-27 20:56:59 -08:00
Ashcon Partovi
6029a57d0b Fix invalid expression 2023-01-27 20:55:15 -08:00
Ashcon Partovi
309b741aa1 Tweak release scripts 2023-01-27 20:53:09 -08:00
Dylan Conway
d90a00857b fix sentinel mismatches 2023-01-27 20:41:15 -08:00
Ashcon Partovi
5ab2c8e4d6 Remove 'id' from each job 2023-01-27 20:39:02 -08:00
Ashcon Partovi
c194f15418 Fixup docker release 2023-01-27 20:36:13 -08:00
Ashcon Partovi
3be8a4733a Create unified release workflow 2023-01-27 20:31:18 -08:00
Jarred Sumner
3243936d3e less flaky macOS build 2023-01-27 20:25:44 -08:00
Dylan Conway
ec1ba91c38 fix import 2023-01-27 20:00:21 -08:00
Dylan Conway
ea55ef504b ensure name is allocated with toSliceClone (#1917)
* ensure name is allocated with `toSliceClone`

* shorten toSliceClone
2023-01-27 19:38:40 -08:00
Ashcon Partovi
34b643e654 Enable release signing 2023-01-27 19:14:14 -08:00
Jarred Sumner
2e1c7f5597 sentinel 2023-01-27 15:27:04 -08:00
Jarred Sumner
6cccc0d26c Update uws 2023-01-27 15:27:04 -08:00
Dylan Conway
0147647e06 fix sentinel slice 2023-01-27 14:49:12 -08:00
Jarred Sumner
ec010e4930 Update buffer.test.js 2023-01-27 14:47:13 -08:00
Dylan Conway
41af4b43e2 more websocket ref/deref tests 2023-01-27 14:22:03 -08:00
Ciro Spaciari
c1d05cf623 fix(Express.js) Express.js try to use function as hostname (#1914) 2023-01-27 13:33:53 -08:00
Jarred Sumner
724f23c19f Update watcher.zig 2023-01-27 03:54:30 -08:00
Jarred Sumner
ddca89f425 🪦 2023-01-27 03:53:01 -08:00
Jarred Sumner
805e87eeb6 Add a comment 2023-01-27 03:29:53 -08:00
Jarred SUmner
8dc1140f43 Fixup 2023-01-27 02:10:30 -08:00
Jarred Sumner
b136125bb0 [[bun hot]] More reliability improvements to macOS watcher 2023-01-27 01:56:07 -08:00
Jarred Sumner
1da7f5fe5d [bun --hot] Report exceptions in reloaded modules 2023-01-27 00:21:04 -08:00
Jarred Sumner
655c19b07c More reliable bun --hot on macOS 2023-01-27 00:15:56 -08:00
Jarred SUmner
ed5bcfc76b Another test 2023-01-26 23:21:10 -08:00
Jarred SUmner
421588d631 More reliable bun --hot on Linux 2023-01-26 23:04:37 -08:00
Jarred SUmner
915b46768c Remove usages of assumeSentinel 2023-01-26 23:04:37 -08:00
Jarred Sumner
7169bbbb9c Fixes #1907 2023-01-26 19:18:35 -08:00
Ciro Spaciari
6d06606135 Implement all pending resolve methods in DNS (#1903)
* initial steps to create generic resolve

* add soa

* add naptr

* add naptr

* add mx and fix naptr

* add resolve caa

* fix Caa test

* fix toJS from caa

* add resolveNs

* add resolvePtr

* fix resolvePtr test

* add resolveCname

* add resolve rrtype options (still missing ANY)

* fix Naptr

* fix drainPendingCares
2023-01-26 18:36:53 -08:00
Dylan Conway
44c6ce11c4 fix websocket hang (#1910)
* ref and deref, and some tests

* subprocess file

* remove deref

* use flag in test
2023-01-26 18:26:05 -08:00
Ciro Spaciari
b32b0b8736 fix large packages receive for WS client (#1909) 2023-01-26 15:08:34 -08:00
Jarred SUmner
fbe45fcb03 Fix branching on undefined 2023-01-26 05:20:53 -08:00
Jarred SUmner
2c23d8736f valgrind 2023-01-26 04:45:24 -08:00
Jarred SUmner
f14032e4b4 zig changes 2023-01-26 04:43:57 -08:00
Jarred Sumner
d912214719 Upgrade Mimalloc 2023-01-26 04:03:36 -08:00
Jarred Sumner
6c9e7de824 copy paste is harder to mess up than C macros 2023-01-26 04:02:21 -08:00
Alex Lam S.L
f8f989f667 parse package-spec from CLI correctly (#1895)
* parse package-spec from CLI correctly

fixes #861

* copy separately for `UpdateRequest.name`

fix GItHub URL reporting in results

update tests to reflect latest code changes

* better fix for GitHub URL display issue
2023-01-26 01:06:51 -08:00
Jarred Sumner
781df80a90 [bun install] Support verifying GitHub dependencies 2023-01-25 17:26:49 -08:00
Jarred Sumner
b26ff0074d [bun install] Include the resolved version for github dependencies in the hash 2023-01-25 17:26:09 -08:00
Jarred Sumner
0a8e42a4ba [bun install] For github dependencies, write a .bun-tag to mark the revision 2023-01-25 17:25:19 -08:00
Jarred Sumner
b767f9a99a Add a test 2023-01-25 13:43:23 -08:00
Jarred Sumner
f61ee1ed42 Fixes #1902 2023-01-25 13:42:31 -08:00
Jarred Sumner
a8743f0a34 Fix "failed to resolve" 2023-01-25 02:21:40 -08:00
Jarred Sumner
468226fc90 be more careful 2023-01-25 01:52:04 -08:00
Jarred Sumner
9cb1ec2c58 Undo 2023-01-25 01:10:15 -08:00
Jarred Sumner
0f2c9c9ff3 Fix "failed to resolve" bug 🫠 2023-01-25 01:09:42 -08:00
Jarred Sumner
ed2a57fcc9 Add log 2023-01-25 01:09:05 -08:00
Jarred Sumner
81b6878e1a Add assertion 2023-01-24 23:54:42 -08:00
Jarred Sumner
325ffd70e1 one less alloc 2023-01-24 23:53:03 -08:00
Jarred Sumner
d4ce045f9e More careful about the lifetime of alias 2023-01-24 23:51:48 -08:00
Jarred Sumner
7f65875406 Update base.zig 2023-01-24 23:51:02 -08:00
Jarred Sumner
ce38365106 assert defined in development 2023-01-24 23:50:35 -08:00
Jarred Sumner
a3cc911e7a get cache key for github in one pass 2023-01-24 22:27:06 -08:00
Sean Scally
ac7aff1b47 Add FileSystemRouter + React example (#1894) 2023-01-24 19:09:39 -08:00
Ashcon Partovi
d714df48f9 Add npm install -g bun to README 2023-01-24 12:42:37 -08:00
Ashcon Partovi
fb1902448e Add bunx to bin for npm installer 2023-01-24 12:04:35 -08:00
Alex Lam S.L
f43b675200 support GitHub URLs as dependencies (#1875) 2023-01-24 11:57:25 -08:00
Alex Lam S.L
e47fe2ca00 support bun link of scoped packages (#1892) 2023-01-24 11:52:47 -08:00
Ashcon Partovi
2edbf4d0ec Iterate on canary version again 2023-01-24 11:17:08 -08:00
Ashcon Partovi
645b7271f9 npm does not accept '+build' in releases :( 2023-01-24 10:31:04 -08:00
Ashcon Partovi
77c72b3193 Fix detection of canary 2023-01-24 10:06:58 -08:00
Ashcon Partovi
34f97be86a Copy .npmrc to each package 2023-01-24 09:59:58 -08:00
Ashcon Partovi
2ffe77140e Maybe fix .npmrc 2023-01-24 09:38:44 -08:00
Jarred Sumner
be79f6e893 Add failing test 2023-01-24 04:08:24 -08:00
Jarred Sumner
bb5119f7eb Add simple test for bun --hot 2023-01-24 03:30:27 -08:00
Jarred Sumner
6f682c6369 Use more specific function 2023-01-24 03:03:57 -08:00
Jarred Sumner
05b1ce39d2 Faster string length in napi 2023-01-24 03:03:44 -08:00
Jarred Sumner
6cf87d022f [napi] Clean up some string handling code 2023-01-24 02:59:51 -08:00
Jarred Sumner
6c3842f67d Update text-decoder.test.js 2023-01-24 02:31:53 -08:00
Jarred Sumner
63403741ff flaky 2023-01-24 02:31:45 -08:00
Jarred Sumner
66643a5b57 Try resolving against the path without the .js extension 2023-01-24 02:22:16 -08:00
Jarred Sumner
e2f709b2a5 Always allow importing ${package}/package.json 2023-01-24 02:21:43 -08:00
Jarred Sumner
4ea104f5bd Fix canary bug 2023-01-24 00:57:03 -08:00
Jarred Sumner
0fe7f7b6f0 Update README.md 2023-01-24 00:56:39 -08:00
Jarred Sumner
566a2c668b Sort families 2023-01-24 00:14:59 -08:00
Jarred Sumner
ad692495a1 Update class-definitions.ts 2023-01-24 00:14:59 -08:00
Jarred Sumner
2c31beda75 Fixes #1887 2023-01-24 00:14:59 -08:00
Ashcon Partovi
cd684fdad0 Tweak semver for canary again 2023-01-23 23:38:38 -08:00
Ashcon Partovi
ad40eec079 Fix ordering of github action command 2023-01-23 23:10:16 -08:00
Jarred Sumner
90d62ecc24 Add DOMJIT test 2023-01-23 23:08:31 -08:00
Ashcon Partovi
cab1f860e4 npm install bun (#1874)
* Add bun-npm package to publish and install Bun via npm

* Add newlines to patchJson

* Update version to latest release

* Tweak semver for canary

* Use GITHUB_TOKEN

* Prevent bun from being run in slow mode
2023-01-23 23:06:13 -08:00
Jarred Sumner
7ca867f7c8 3x faster Buffer.isBuffer 2023-01-23 22:34:04 -08:00
Jarred Sumner
fe03e90d80 Update build-id 2023-01-23 19:05:41 -08:00
Jarred Sumner
f992942391 Make Object.prototype.toString.call(new Buffer(0)) consistent with Node.js 2023-01-23 18:51:04 -08:00
Jarred Sumner
7420cb1d73 fix test failure in aarch64 and add test for simd code path 2023-01-23 18:03:48 -08:00
Dylan Conway
73961a1494 missing test 2023-01-23 17:39:40 -08:00
Jarred Sumner
d7b5e4b901 Update uws 2023-01-23 16:51:52 -08:00
Jarred Sumner
efc024cfc4 clean up deps 2023-01-23 16:51:48 -08:00
Ciro Spaciari
b3533fb3a8 fix(Buffer) Fix arguments in buffer.write, fix size returned from buffer.write for utf16, fix size calc for base64, fix calc for hex byte size (#1881)
* fix buffer write when more than 2 args are passed

* fix encoding parameter

* better buffer write tests

* fix ucs2/utf8 len return

* fix base64 size in Buffer write

* fix hex encoding size

* actual fix base64

* actual fix base64

* fix segfault

* add fill parameter in Buffer.alloc

* use createUnitialized when alloc have fill parameter, use RETURN_IF_EXCEPTION when static casting

* fix utf16le, ucs2 copying in Buffer write
2023-01-23 16:48:52 -08:00
Dylan Conway
79c0b614ee fix child process node test hang (#1884)
* fix test hang from skipped tests

* add error target
2023-01-23 15:59:45 -08:00
Dylan Conway
f5cda8ff18 fix constructor statement order (#1883)
* leave super alone

* more tests
2023-01-23 15:57:47 -08:00
Jarred Sumner
4570ff7780 [napi] Support defining properties with symbol as names 2023-01-23 15:09:23 -08:00
Jarred Sumner
aa456805dd [napi] Handle missing description in napi_create_symbol 2023-01-23 15:09:18 -08:00
Ciro Spaciari
efd33c398f enhancement(fetch): Merge parameters from request parameter with the second parameter for fetch, move verbose and proxy options to second parameter, add non-TLS tests for fetch (#1862)
* initial steps for proxy-server

* added http_proxy in fetch, move 3rd argument to 3nd argument options, add some non-TLS proxy tests

* some changes

* use only 1 buffer for url+proxy, merge headers on fetch

* initial steps

* change back to override headers instead of merging in fetch

* fix build response.zig

* fix conditional in merged headers on fetch

* updated with main and make proxy disabled if null is passed

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-01-23 14:38:40 -08:00
Jarred Sumner
9a2b586337 Update bench 2023-01-23 05:22:03 -08:00
Jarred Sumner
df999306c0 ✂️ duplicate code 2023-01-23 05:05:54 -08:00
Jarred Sumner
45296570ce Fix crash in DOMJIT call with empty input 2023-01-23 04:58:42 -08:00
Jarred Sumner
f9306ff815 Update transpiler.zig 2023-01-23 04:09:28 -08:00
Jarred Sumner
c530ead1e0 Add a comment 2023-01-23 04:06:01 -08:00
Jarred Sumner
f6227bf6dd Upgrade Bun.Transpiler to use new bindings 2023-01-23 04:03:01 -08:00
Jarred Sumner
4f84c6bc34 Prepare for plugins 2023-01-23 04:02:06 -08:00
Jarred Sumner
d141783ebd Sort the generated classes list 2023-01-23 04:01:45 -08:00
Jarred Sumner
d4ef935478 [bindings] Add custom field to enable writing one-off C++ in the zig class 2023-01-23 04:01:36 -08:00
Jarred Sumner
bf68df0070 fix unrefOnNextTick 2023-01-22 21:22:46 -08:00
Jarred Sumner
407088f6ab Add tests for async failure 2023-01-22 20:49:21 -08:00
Jarred Sumner
2cce810190 Add a test for zlib (thanks @jiaz) 2023-01-22 19:54:42 -08:00
Jarred Sumner
eaea08ea45 Add one gc test for eventemitter 2023-01-22 19:53:59 -08:00
Jarred Sumner
4dfc09018f [EventEmitter] Preserve this in event emitter callbacks 2023-01-22 19:52:51 -08:00
Jarred Sumner
771db64cbe [bun:sqlite] cleanup run 2023-01-22 19:35:32 -08:00
Jarred Sumner
c6b941d803 Add some more emitters to the benchmark 2023-01-22 19:11:04 -08:00
Jarred Sumner
3492248697 Fixes #1366 2023-01-22 19:09:52 -08:00
Jarred Sumner
bc7192dca1 Add extremely slow node:zlib polyfill 2023-01-22 15:34:21 -08:00
Jarred Sumner
188f472ed2 Update http.exports.js 2023-01-22 14:58:57 -08:00
Jarred Sumner
befd97a891 [node:http] Add address() and fix callback / options parsing 2023-01-22 14:58:22 -08:00
Ciro Spaciari
481dbf7c6e feat(dns) resolveSrv (#1870)
* initial steps

* in-progress resolveSrv support

* fix memory leak and ZigGlobalObject

* promise.resolve + fix priority and weight mistake

* fix node dns export

* little better test

* add poll_ref to keep alive loop in callback for resolveSrv and lookup

* add test for error case in resolveSrc

* fix Bun.dns.resolveSrv type
2023-01-22 14:31:08 -08:00
Jarred Sumner
8d692f1511 Update Makefile 2023-01-22 14:20:44 -08:00
Jarred Sumner
c08b546728 Allow very old CPUs to use Bun (~2008) 2023-01-22 14:20:25 -08:00
Jarred Sumner
fefa4a1623 Add a test for require with a query string 2023-01-22 03:24:42 -08:00
Jarred Sumner
043e408b15 cleanup execArgv a little 2023-01-22 03:24:32 -08:00
Jarred Sumner
9f6658b981 stub out process.stdin.setRawMode 2023-01-22 02:40:18 -08:00
Jarred Sumner
5ce2b8e604 Implement process.execArgv 2023-01-21 23:52:51 -08:00
Jarred Sumner
ee9893c4e1 Zig stdlib change 2023-01-21 23:13:19 -08:00
Jarred Sumner
8b0e2efd6e Bump zig 2023-01-21 23:13:04 -08:00
Jarred Sumner
4d1e977399 Update uws 2023-01-21 23:12:30 -08:00
Jarred Sumner
0ee13892fd Update buffer-create.mjs 2023-01-21 23:11:55 -08:00
Jarred Sumner
99d2d6e607 Support query string parameters in module resolution 2023-01-21 23:11:31 -08:00
Jarred Sumner
a2cfdf0e1c Refactor new Buffer to pass Node.js tests 2023-01-21 23:03:43 -08:00
Jarred Sumner
29a576a167 [Buffer] Add deprecated parent property 2023-01-21 22:55:56 -08:00
Jarred Sumner
6424ce6397 Update .gitignore 2023-01-21 20:54:31 -08:00
Jarred Sumner
fdb9472f88 Fix make headers 2023-01-21 19:42:21 -08:00
Jarred Sumner
17bde9bc86 Fix test failure due to UB 2023-01-21 15:36:51 -08:00
Alex Lam S.L
fd29d05c6a minor clean-ups (#1869)
- use `Lockfile.str()` more
- allow `child-process-stdio.test.js` to run with `bun-debug`
2023-01-21 14:02:22 -08:00
Jarred Sumner
f475802206 Update module_loader.zig 2023-01-21 13:14:02 -08:00
Alex Lam S.L
f0fa760479 [semver] parse ^ & ~ expressions correctly (#1854)
* [semver] parse `^` & `~` expressions correctly

* handle semver ranges correctly against build tags
2023-01-21 04:16:26 -08:00
Jarred Sumner
24e8aa105f Remove UB with semver.String
Thanks @MasterQ32
2023-01-21 04:11:57 -08:00
Jarred Sumner
ed421855d7 [buffer] Add faster path for Uint8Array 2023-01-21 04:06:06 -08:00
Jarred Sumner
627da44527 Handle string subclasses and new String() in new Buffer 2023-01-21 03:14:00 -08:00
Jarred Sumner
9955b74622 Make Buffer.alloc* 3ns faster 2023-01-21 03:13:45 -08:00
Jarred Sumner
d955bfe50f [buffer] Make Buffer.from pass more tests 2023-01-21 03:12:59 -08:00
Dylan Conway
b8648adf87 constructor parameter properties in class expressions (#1867) 2023-01-20 16:24:40 -08:00
Jarred Sumner
ff6fb587f6 Update transpiler.test.js 2023-01-20 04:12:03 -08:00
Jarred Sumner
e361ed4451 Update transpiler.test.js 2023-01-20 04:11:47 -08:00
Dylan Conway
42e9f6e0b1 push super before generated statements (#1856) 2023-01-20 03:25:21 -08:00
Jarred Sumner
e3ed905b0a Clear the errors 2023-01-20 02:19:23 -08:00
Jarred Sumner
224312c014 one less hash table 2023-01-20 02:19:14 -08:00
Jarred Sumner
bdf792adbc Add another test 2023-01-20 00:20:33 -08:00
Jarred Sumner
3c6616a23d fix hanging test 2023-01-20 00:07:11 -08:00
Jarred Sumner
ff7e984f0a Further cleanup buffer encoding 2023-01-20 00:06:46 -08:00
Jarred Sumner
3a100af876 Fixes #1855 2023-01-20 00:06:27 -08:00
Jarred Sumner
7d7b535014 Fix assertion failure with boringssl messages 2023-01-20 00:05:48 -08:00
Jarred Sumner
a98b1751a6 Revert "ignore sighup"
This reverts commit 03ab4be9ee.
2023-01-19 23:59:20 -08:00
Jarred Sumner
03ab4be9ee ignore sighup 2023-01-19 23:56:49 -08:00
Jarred Sumner
f993975ae6 make this code easier to read 2023-01-19 21:00:53 -08:00
Jarred Sumner
53f7bd32d8 Update types.zig 2023-01-19 20:34:06 -08:00
Jarred Sumner
784496b773 Bump 2023-01-19 20:32:38 -08:00
Jarred Sumner
4c0b0e2e8e Fix buffer encoding bug 2023-01-19 20:28:34 -08:00
Alex Lam S.L
bab7e63d7c use String.from() (#1850) 2023-01-19 19:26:10 -08:00
Jarred Sumner
3511a4b5be Bump zig 2023-01-19 19:09:25 -08:00
Jarred Sumner
e485f7bb51 make it packed 2023-01-19 19:05:29 -08:00
Jarred Sumner
795cde6d62 Bugfixes to install (#1848) 2023-01-20 04:55:22 +02:00
Alex Lam S.L
9dfbf57397 repopulate alias_map correctly (#1847) 2023-01-19 16:24:56 -08:00
Jarred Sumner
e04fe64a82 Add a comment 2023-01-19 16:19:15 -08:00
Jarred Sumner
495c70053f Add a debug safety check for UAF in AST nodes 2023-01-19 16:14:56 -08:00
Jarred Sumner
9bcd4952ce Fix UAF when opening workspaces 2023-01-19 16:14:40 -08:00
Jarred Sumner
8745f10cd3 Improve error message when a workspace is not found 2023-01-19 15:48:03 -08:00
Volodymyr Palamar
ac0dab3679 Create new example http-file-extended.ts (#1827)
New code sample with http Range and ETag support
Some code is taken from here https://github.com/gornostay25/svelte-adapter-bun/blob/master/src/sirv.js
2023-01-19 10:35:55 -08:00
Ciro Spaciari
01c97e4033 fix(fetch:HTTP_PROXY) fix support for HTTP_PROXY/HTTPS_PROXY and NO_PROXY in fetch instances (#1844)
* fix response.zig fetch

* use VM bundler env instead of DotEnv.instance

* remove unnecessary import
2023-01-19 10:34:32 -08:00
Alex Lam S.L
cd5f2ab11f parse dependency specifier correctly (#1840) 2023-01-19 06:39:01 -08:00
Alex Lam S.L
61736966ad fix stale references upon Lockfile tree cloning (#1845) 2023-01-19 06:38:08 -08:00
Alex Lam S.L
8bdcded5c1 fix memory reference issues (#1841) 2023-01-19 00:53:01 -08:00
Alex Lam S.L
c0ec61cf16 support npm dependency aliasing (#1837)
* support npm dependency aliasing

* fix variable name
2023-01-18 20:11:52 -08:00
Alex Lam S.L
d4e323b997 add fs.rmdir & friends (#1838) 2023-01-18 19:56:34 -08:00
Jarred Sumner
58cbd6b211 Regenerate lockb 2023-01-18 16:51:18 -08:00
Colin McDonnell
d8d148e3bb Fix/simplify bun-types release (#1836)
* Simplify types release

* Further simplify

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-01-18 16:22:01 -08:00
Jarred Sumner
311185f6d6 Add a test for #1831 2023-01-18 15:00:00 -08:00
Jarred Sumner
7012d2fb74 Fixes #1831 2023-01-18 14:59:39 -08:00
Jarred Sumner
2db04ef9d9 Fix crash with invalid arguments in readdir() 2023-01-18 01:16:13 -08:00
Jarred Sumner
4cb6a34432 Don't report end() because it is inherently flaky 2023-01-18 00:28:53 -08:00
Jarred Sumner
2016e8a0af micro-optimize loading process environment variables 2023-01-18 00:28:19 -08:00
Jarred Sumner
0759530118 opposite 2023-01-18 00:24:52 -08:00
Jarred Sumner
5ed46913c4 Update node-net.test.ts 2023-01-18 00:17:11 -08:00
Jarred Sumner
bd5b90fbf1 Fix lifetime issue in require.resolve 2023-01-17 23:41:17 -08:00
Colin McDonnell
bba4054da3 Use canary in CI (#1823)
* Use canary in CI

* Only publish canary when types change

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-01-17 23:06:26 -08:00
华晨
d16951422b remove redundant allowSyntheticDefaultImports (#1802) 2023-01-17 21:01:55 -08:00
Jarred Sumner
e0eeb1c07e workaround lifetime issue 2023-01-17 20:10:19 -08:00
Ashcon Partovi
216e872801 Add Bun.dns to the README 2023-01-17 18:17:12 -08:00
Ashcon Partovi
6fbf437f50 Fix Bun.dns examples to use array instead of single result 2023-01-17 18:12:49 -08:00
Ciro Spaciari
c00fadab9e feat(cli): Support HTTPS_PROXY, HTTP_PROXY, and NO_PROXY #1440 (#1814)
* WIP: http_proxy implemented, first steps for https_proxy #1440

* add HTTP_PROXY support to upgrade_command and WIP: tunneling

* WIP async handshake, stuck on WANT_READ, try to defer  + check

* create and upgrade with proxy working, TLS and non-TLS to proxy TLS working

* bun install/upgrade/create working with http(s)_proxy #1440

* add NO_PROXY support #1440

* remove commented code and add TODO

* fix getHttpProxy no_proxy

* fix formatting

* refactor catch and getHttpProxy, fix empty strngs in env for proxy

* allow optimization for handleResponseBody
2023-01-17 17:47:01 -08:00
Jarred Sumner
9b260fb18b Allow error instance in process.emitWarning 2023-01-17 17:11:08 -08:00
Colin McDonnell
b931c19ba3 Add types for readline, tls, net (#1817)
* Add readline, tls, net types

* Remove unimplemented methods

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-01-17 16:49:18 -08:00
Jarred Sumner
9e403fc8bf cleanup error message 2023-01-17 16:47:45 -08:00
Jarred Sumner
fd0edd7aa0 [process] Implement process.emitWarning 2023-01-17 16:29:08 -08:00
Jarred Sumner
848658c533 [test] Add helper for bun env 2023-01-17 16:28:49 -08:00
Jarred Sumner
37d2a98331 Update logger.zig 2023-01-17 16:27:52 -08:00
Jarred Sumner
58d1ab02bd [canary] Fix missing .env log 2023-01-17 16:27:48 -08:00
Jarred Sumner
9f0d402a7d [EventEmitter] Fix emitter.off("eventName") 2023-01-17 16:27:21 -08:00
Jarred Sumner
f927567b9f bun install tests shouldn't fail due to terminal colors 2023-01-17 16:00:21 -08:00
Derrick Farris
94ea41a60b fix(readline/promises): new Interface() -> new PromisesInterface() (#1818) 2023-01-17 15:45:15 -08:00
Dylan Conway
8235e59a7f set available 2023-01-17 15:36:19 -08:00
Jarred Sumner
8924c521ba // flaky 2023-01-17 14:00:10 -08:00
Jarred Sumner
69875d86cd Fix console.log printing multiple properties 2023-01-17 13:44:13 -08:00
Jarred Sumner
5bdc923838 dont export twice 2023-01-17 12:53:28 -08:00
Jarred Sumner
25a2962186 Expose tls.connect 2023-01-17 12:52:49 -08:00
Jarred Sumner
c943dbadef Update crypto-hasher.mjs 2023-01-17 12:52:33 -08:00
Jarred Sumner
aacaa9b85d Bun v0.5.0 2023-01-17 00:43:56 -08:00
Jarred Sumner
74992f6f34 make node-redis work 2023-01-17 00:09:04 -08:00
Dylan Conway
12b8416b64 send and disconnect 2023-01-16 23:44:09 -08:00
Jarred Sumner
8a5ff676ea Bump zig 2023-01-16 23:21:52 -08:00
Jarred Sumner
f660f8d22f Make sure the socket keeps the process alive 2023-01-16 21:43:48 -08:00
Jarred Sumner
38cc947621 Don't need to skip these now 2023-01-16 21:42:52 -08:00
Jarred Sumner
0546aa4fd5 Make entire test line dim 2023-01-16 21:37:12 -08:00
Jarred Sumner
b8b7ad4982 [bun:test] Fix dim, fix missing space 2023-01-16 21:35:19 -08:00
Dylan Conway
d21119b347 remove onClose 2023-01-16 21:20:54 -08:00
Jarred Sumner
d3de366c67 Fix some reliability issues with net.connect and Bun.connect on macOS 2023-01-16 21:14:38 -08:00
Jarred Sumner
a1b581621c guess we'll check if it's defined 2023-01-16 20:33:31 -08:00
Jarred Sumner
274ae5de1b [bun install] Make it print workspace: instead of workspace:// 2023-01-16 18:57:04 -08:00
Jarred Sumner
74b0a1939d Fixes https://github.com/oven-sh/bun/issues/1654 2023-01-16 17:48:35 -08:00
Jarred Sumner
6f432e8b7d Remove assertion 2023-01-16 17:38:04 -08:00
Jarred Sumner
a5f7a23307 Update node-dns.exports.js 2023-01-16 17:12:23 -08:00
Jarred Sumner
88a8614abc [node:dns/promises] Fix missing import 2023-01-16 17:11:00 -08:00
Jarred Sumner
b23327c283 [node] Add process.config 2023-01-16 16:47:08 -08:00
Jarred Sumner
c83d56c75d Update c-bindings.cpp 2023-01-16 16:30:33 -08:00
Jarred Sumner
7dd28bbdd9 Fix which returning directories sometimes 2023-01-16 16:28:02 -08:00
Jarred Sumner
d54e23ca33 [napi] Fix potential crash in napi_create_buffer_copy, napi_create_buffer 2023-01-16 15:48:14 -08:00
Jarred Sumner
02f0212cbd [napi] Don't assume function exists
Fixes https://github.com/oven-sh/bun/issues/1808
2023-01-16 15:47:44 -08:00
Jarred Sumner
3484502839 [JS Parser] Don't inline rope strings 2023-01-16 15:21:11 -08:00
Jarred Sumner
a345efd270 Fix getFdPath when /proc/fd is not mounted 2023-01-16 13:59:52 -08:00
Jarred Sumner
30bfb31bce wip 2023-01-16 12:59:48 -08:00
Jarred Sumner
eef0e8c6bf Fix incorrect type 2023-01-16 12:56:16 -08:00
Jarred Sumner
4648131c41 Add missing buffer module exports 2023-01-16 12:49:57 -08:00
Colin McDonnell
b0702ce7b1 Publish bun-types@canary (#1767)
* Publish bun-types@canary

* Get version from bun cli

* Get version from bun cli

* Fixes

* Fixes

* Fixes

* Finalize

* Update names

* Add token

* Remove dryrun

* Switch setup-bun

* Test noncanary publish

* Fix path for GPR

* Use latest

* Remove testing code

* Remove dry run

* Fix paths

* Update bun-types links

* Verbose logging

* Ignore lockfile

* Run install in root

* Remove debug code

* Remove debug code

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-01-16 11:58:57 -08:00
Jarred Sumner
ff3f5aa154 Don't open non-blocking on Linux 2023-01-16 11:22:54 -08:00
Jarred Sumner
91bcfa9cb4 Clean up the test 2023-01-16 11:22:54 -08:00
Jarred Sumner
cf5f9df211 Use a reusable symbol 2023-01-16 11:22:54 -08:00
Alex Lam S.L
9eb4a4ff3a [Response] reject HTTP status code correctly (#1800) 2023-01-15 03:21:34 -08:00
Alex Lam S.L
7932a55870 fix handler reset in Server.reload() (#1801) 2023-01-15 03:19:37 -08:00
Alex Lam S.L
893ec2fb45 fix life-cycle script execution (#1799)
- change current working directory for workspaces
- add `node_modules/.bin` to `PATH` before running
2023-01-14 21:37:16 -08:00
Alex Lam S.L
136014b13a fix bugs (#1795)
- segfault reading stacktrace from `fs/promises` rejections
- `Promise` rejection within `describe()` ends testing abruptly
- `FSSink.write()` incorrectly handles `objectMode`
- `FSSink.write()` throws wrong error codes
2023-01-14 16:50:55 -08:00
Jarred Sumner
d01ec47529 Fixes #1794 2023-01-14 16:37:16 -08:00
Alex Lam S.L
7fa023b8b5 support installation of NPM workspaces (#1764) 2023-01-14 07:14:48 -08:00
Jarred Sumner
aa9e56edfe [bun:test] Always dim skip 2023-01-13 13:13:01 -08:00
Jarred Sumner
88ffdc5fec [TypeScript transpiler] Fix bug with export default class implements 2023-01-13 12:48:10 -08:00
Jarred Sumner
fab42148e4 Skip failing tests 2023-01-13 11:58:44 -08:00
Jarred Sumner
cce380ec37 Fix broken test helper 2023-01-13 11:57:22 -08:00
Jarred SUmner
828fd0cfea Fix debug mode crash 2023-01-13 11:55:46 -08:00
Jarred SUmner
168bb1427f move more things 2023-01-13 11:38:16 -08:00
Jarred SUmner
996ef44c02 Split some things into more files and use bun namespace instead of import more 2023-01-13 11:27:16 -08:00
Jarred Sumner
734b5b89da Add closeActiveConnections option to types 2023-01-12 19:38:27 -08:00
Jarred Sumner
490814aa35 Update serve.test.ts 2023-01-12 19:38:27 -08:00
Jarred Sumner
ffa8913e54 Update tcp-server.test.ts 2023-01-12 19:38:27 -08:00
Jarred Sumner
73e9cd8e06 [Bun.listen] Add flag to close all connections 2023-01-12 19:38:27 -08:00
Jarred Sumner
62cab3c719 [Bun.serve] Add flag to close all connections 2023-01-12 19:38:27 -08:00
Jarred Sumner
d4f1d29393 Fix https websockets 2023-01-12 19:38:27 -08:00
Jarred Sumner
2eac47a123 Upgrade uSockets 2023-01-12 19:38:27 -08:00
520 changed files with 60976 additions and 36518 deletions

View File

@@ -1,30 +0,0 @@
name: bun-homebrew
on:
release:
types:
- published
- edited
jobs:
homebrew:
runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh' && github.event.release.published_at != null
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
with:
repository: oven-sh/homebrew-bun
token: ${{ env.HOMEBREW_TOKEN }}
- id: setup-ruby
name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.6'
- id: update-tap
name: Update Tap
run: ruby scripts/release.rb "${{ github.event.release.tag_name }}"
- id: commit-tap
name: Commit Tap
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Release ${{ github.event.release.tag_name }}

165
.github/workflows/bun-linux-aarch64.yml vendored Normal file
View File

@@ -0,0 +1,165 @@
name: bun-linux
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TEST_TAG: bun-test'
on:
push:
branches:
- main
paths:
- "src/**/*"
- "test/**/*"
- "build.zig"
- "Makefile"
- "Dockerfile"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
linux:
name: ${{matrix.tag}}
runs-on: ${{matrix.runner}}
timeout-minutes: 90
strategy:
matrix:
include:
- cpu: native
tag: linux-aarch64
arch: aarch64
build_arch: arm64
runner: linux-arm64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-linux-arm64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-arm64-lto"
build_machine_arch: aarch64
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Run
run: |
rm -rf ${{runner.temp}}/release
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
mkdir -p /tmp/.buildx-cache-${{matrix.tag}}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: false
cache-from: type=local,src=/tmp/.buildx-cache-${{matrix.tag}}
cache-to: type=local,dest=/tmp/.buildx-cache-${{matrix.tag}}
build-args: |
ARCH=${{matrix.arch}}
BUILDARCH=${{matrix.build_arch}}
BUILD_MACHINE_ARCH=${{matrix.build_machine_arch}}
CPU_TARGET=${{matrix.cpu}}
WEBKIT_URL=${{matrix.webkit_url}}
GIT_SHA=${{github.sha}}
WEBKIT_BASENAME=${{matrix.webkit_basename}}
platforms: linux/${{matrix.build_arch}}
target: artifact
outputs: type=local,dest=${{runner.temp}}/release
- name: Zip
run: |
# if zip is not found
if [ ! -x "$(command -v zip)" ]; then
sudo apt-get update && sudo apt-get install -y zip --no-install-recommends
fi
if [ ! -x "$(command -v strip)" ]; then
sudo apt-get update && sudo apt-get install -y binutils --no-install-recommends
fi
cd ${{runner.temp}}/release
chmod +x bun-profile bun
mkdir bun-${{matrix.tag}}-profile
mkdir bun-${{matrix.tag}}
strip bun
mv bun-profile bun-${{matrix.tag}}-profile/bun-profile
mv bun bun-${{matrix.tag}}/bun
zip -r bun-${{matrix.tag}}-profile.zip bun-${{matrix.tag}}-profile
zip -r bun-${{matrix.tag}}.zip bun-${{matrix.tag}}
- uses: actions/upload-artifact@v3
with:
name: bun-${{matrix.tag}}-profile
path: ${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip
- uses: actions/upload-artifact@v3
with:
name: bun-${{matrix.tag}}
path: ${{runner.temp}}/release/bun-${{matrix.tag}}.zip
- uses: actions/upload-artifact@v3
with:
name: bun-obj-${{matrix.tag}}
path: ${{runner.temp}}/release/bun-obj
- uses: actions/upload-artifact@v3
with:
name: ${{matrix.tag}}-dependencies
path: ${{runner.temp}}/release/bun-dependencies
- name: Release
id: release
uses: ncipollo/release-action@v1
if: |
github.repository_owner == 'oven-sh'
&& github.ref == 'refs/heads/main'
with:
prerelease: true
body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"
allowUpdates: true
replacesArtifacts: true
generateReleaseNotes: true
artifactErrorsFailBuild: true
token: ${{ secrets.GITHUB_TOKEN }}
name: "Canary (${{github.sha}})"
tag: "canary"
artifacts: "${{runner.temp}}/release/bun-${{matrix.tag}}.zip,${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip"
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v0.1.8
if: |
github.repository_owner == 'oven-sh'
&& github.ref == 'refs/heads/main'
with:
bun-version: canary
github-token: ${{ secrets.GITHUB_TOKEN }}
# - name: Sign Release
# id: sign-release
# if: |
# github.repository_owner == 'oven-sh'
# && github.ref == 'refs/heads/main'
# env:
# GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
# run: |
# echo "$GPG_PASSPHRASE" | bun run .scripts/sign-release.ts
# - name: Release Checksum
# id: release-checksum
# uses: ncipollo/release-action@v1
# if: |
# github.repository_owner == 'oven-sh'
# && github.ref == 'refs/heads/main'
# with:
# prerelease: true
# body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"
# allowUpdates: true
# replacesArtifacts: true
# generateReleaseNotes: true
# artifactErrorsFailBuild: true
# token: ${{ secrets.GITHUB_TOKEN }}
# name: "Canary (${{github.sha}})"
# tag: "canary"
# artifacts: "SHASUMS256.txt,SHASUMS256.txt.asc"

View File

@@ -32,32 +32,25 @@ jobs:
runs-on: ${{matrix.runner}}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
include:
- cpu: haswell
tag: linux-x64
arch: x86_64
build_arch: amd64
runner: linux-amd64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-linux-amd64-lto.tar.gz"
runner: big-ubuntu
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
build_machine_arch: x86_64
- cpu: westmere
- cpu: nehalem
tag: linux-x64-baseline
arch: x86_64
build_arch: amd64
runner: linux-amd64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-linux-amd64-lto.tar.gz"
runner: big-ubuntu
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
build_machine_arch: x86_64
- cpu: native
tag: linux-aarch64
arch: aarch64
build_arch: arm64
runner: linux-arm64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-linux-arm64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-arm64-lto"
build_machine_arch: aarch64
steps:
- uses: actions/checkout@v3
@@ -128,10 +121,20 @@ jobs:
with:
name: bun-${{matrix.tag}}
path: ${{runner.temp}}/release/bun-${{matrix.tag}}.zip
- uses: actions/upload-artifact@v3
with:
name: bun-obj-${{matrix.tag}}
path: ${{runner.temp}}/release/bun-obj
- uses: actions/upload-artifact@v3
with:
name: ${{matrix.tag}}-dependencies
path: ${{runner.temp}}/release/bun-dependencies
- name: Release
id: release
uses: ncipollo/release-action@v1
if: github.ref == 'refs/heads/main'
if: |
github.repository_owner == 'oven-sh'
&& github.ref == 'refs/heads/main'
with:
prerelease: true
body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"
@@ -143,11 +146,3 @@ jobs:
name: "Canary (${{github.sha}})"
tag: "canary"
artifacts: "${{runner.temp}}/release/bun-${{matrix.tag}}.zip,${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip"
- uses: actions/upload-artifact@v3
with:
name: bun-obj-${{matrix.tag}}
path: ${{runner.temp}}/release/bun-obj
- uses: actions/upload-artifact@v3
with:
name: ${{matrix.tag}}-dependencies
path: ${{runner.temp}}/release/bun-dependencies

View File

@@ -27,11 +27,11 @@ on:
jobs:
macos-object-files:
name: macOS Object
runs-on: zig-object
runs-on: med-ubuntu
strategy:
matrix:
include:
# - cpu: westmere
# - cpu: nehalem
# arch: x86_64
# tag: bun-obj-darwin-x64-baseline
# - cpu: haswell
@@ -104,13 +104,13 @@ jobs:
strategy:
matrix:
include:
# - cpu: westmere
# - cpu: nehalem
# arch: x86_64
# tag: bun-darwin-x64-baseline
# obj: bun-obj-darwin-x64-baseline
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: haswell
@@ -119,16 +119,16 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: westmere
# - cpu: nehalem
# arch: x86_64
# tag: bun-darwin-x64-baseline
# obj: bun-obj-darwin-x64-baseline
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: haswell
@@ -137,7 +137,7 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: native
@@ -145,7 +145,7 @@ jobs:
tag: bun-darwin-aarch64
obj: bun-obj-darwin-aarch64
artifact: bun-obj-darwin-aarch64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-arm64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
dependencies: true
compile_obj: true
@@ -242,14 +242,14 @@ jobs:
strategy:
matrix:
include:
# - cpu: westmere
# - cpu: nehalem
# arch: x86_64
# tag: bun-darwin-x64-baseline
# obj: bun-obj-darwin-x64-baseline
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
@@ -257,14 +257,14 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
- cpu: native
arch: aarch64
tag: bun-darwin-aarch64
obj: bun-obj-darwin-aarch64
package: bun-darwin-aarch64
artifact: bun-obj-darwin-aarch64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-arm64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -370,7 +370,9 @@ jobs:
- name: Release
id: release
uses: ncipollo/release-action@v1
if: github.ref == 'refs/heads/main'
if: |
github.repository_owner == 'oven-sh'
&& github.ref == 'refs/heads/main'
with:
prerelease: true
body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"

View File

@@ -27,11 +27,11 @@ on:
jobs:
macos-object-files:
name: macOS Object
runs-on: zig-object
runs-on: med-ubuntu
strategy:
matrix:
include:
- cpu: westmere
- cpu: nehalem
arch: x86_64
tag: bun-obj-darwin-x64-baseline
# - cpu: haswell
@@ -104,13 +104,13 @@ jobs:
strategy:
matrix:
include:
- cpu: westmere
- cpu: nehalem
arch: x86_64
tag: bun-darwin-x64-baseline
obj: bun-obj-darwin-x64-baseline
runner: macos-11
artifact: bun-obj-darwin-x64-baseline
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: haswell
@@ -119,16 +119,16 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: westmere
- cpu: nehalem
arch: x86_64
tag: bun-darwin-x64-baseline
obj: bun-obj-darwin-x64-baseline
runner: macos-11
artifact: bun-obj-darwin-x64-baseline
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: haswell
@@ -137,7 +137,7 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: native
@@ -145,7 +145,7 @@ jobs:
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
@@ -243,14 +243,14 @@ jobs:
strategy:
matrix:
include:
- cpu: westmere
- cpu: nehalem
arch: x86_64
tag: bun-darwin-x64-baseline
obj: bun-obj-darwin-x64-baseline
package: bun-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64-baseline
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
@@ -258,14 +258,14 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: native
# arch: aarch64
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# package: bun-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -374,7 +374,9 @@ jobs:
- name: Release
id: release
uses: ncipollo/release-action@v1
if: github.ref == 'refs/heads/main'
if: |
github.repository_owner == 'oven-sh'
&& github.ref == 'refs/heads/main'
with:
prerelease: true
body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"

View File

@@ -27,11 +27,11 @@ on:
jobs:
macos-object-files:
name: macOS Object
runs-on: zig-object
runs-on: med-ubuntu
strategy:
matrix:
include:
# - cpu: westmere
# - cpu: nehalem
# arch: x86_64
# tag: bun-obj-darwin-x64-baseline
- cpu: haswell
@@ -104,13 +104,13 @@ jobs:
strategy:
matrix:
include:
# - cpu: westmere
# - cpu: nehalem
# arch: x86_64
# tag: bun-darwin-x64-baseline
# obj: bun-obj-darwin-x64-baseline
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: haswell
@@ -119,16 +119,16 @@ jobs:
obj: bun-obj-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: westmere
# - cpu: nehalem
# arch: x86_64
# tag: bun-darwin-x64-baseline
# obj: bun-obj-darwin-x64-baseline
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: haswell
@@ -137,7 +137,7 @@ jobs:
obj: bun-obj-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: native
@@ -145,7 +145,7 @@ jobs:
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-arm64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
@@ -245,14 +245,14 @@ jobs:
strategy:
matrix:
include:
# - cpu: westmere
# - cpu: nehalem
# arch: x86_64
# tag: bun-darwin-x64-baseline
# obj: bun-obj-darwin-x64-baseline
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
- cpu: haswell
arch: x86_64
tag: bun-darwin-x64
@@ -260,14 +260,14 @@ jobs:
package: bun-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: native
# arch: aarch64
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# package: bun-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-arm64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -376,7 +376,9 @@ jobs:
- name: Release
id: release
uses: ncipollo/release-action@v1
if: github.ref == 'refs/heads/main'
if: |
github.repository_owner == 'oven-sh'
&& github.ref == 'refs/heads/main'
with:
prerelease: true
body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"

116
.github/workflows/bun-release-canary.yml vendored Normal file
View File

@@ -0,0 +1,116 @@
name: bun-release-canary
concurrency: release-canary
on:
schedule:
- cron: "0 14 * * *" # every day at 6am PST
workflow_dispatch:
jobs:
npm:
name: Release to NPM
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v0.1.8
with:
bun-version: canary
github-token: ${{ secrets.GITHUB_TOKEN }}
- id: bun-install
name: Install Dependencies
run: bun install
- id: bun-run
name: Release
run: bun upload-npm -- canary publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
npm-types:
name: Release types to NPM
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/bun-types
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-node
name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: latest
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v0.1.8
with:
bun-version: canary
github-token: ${{ secrets.GITHUB_TOKEN }}
- id: bun-install
name: Install Dependencies
run: |
bun upgrade --canary
bun install
- id: setup-env
name: Setup Environment
run: |
SHA=$(git rev-parse --short "$GITHUB_SHA")
VERSION=$(bun --version)
TAG="${VERSION}-canary.$(date '+%Y%m%d').1+${SHA}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: bun-run
name: Build
run: bun run build
env:
BUN_VERSION: ${{ env.TAG }}
- id: npm-publish
name: Release
uses: JS-DevTools/npm-publish@v1
with:
package: packages/bun-types/dist/package.json
token: ${{ secrets.NPM_TOKEN }}
tag: canary
docker:
name: Release to Dockerhub
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: qemu
name: Setup Docker QEMU
uses: docker/setup-qemu-action@v2
- id: buildx
name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
- id: metadata
name: Setup Docker metadata
uses: docker/metadata-action@v4
with:
images: oven/bun
tags: canary
- id: login
name: Login to Docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- id: push
name: Push to Docker
uses: docker/build-push-action@v3
with:
context: ./dockerhub
file: ./dockerhub/Dockerfile-debian
platforms: linux/amd64,linux/arm64
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}

210
.github/workflows/bun-release.yml vendored Normal file
View File

@@ -0,0 +1,210 @@
name: bun-release
concurrency: release
on:
release:
types:
- published
workflow_dispatch:
inputs:
tag:
type: string
description: The tag to publish
required: true
jobs:
sign:
name: Sign Release
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-env
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v0.1.8
with:
bun-version: canary
github-token: ${{ secrets.GITHUB_TOKEN }}
- id: bun-install
name: Install Dependencies
run: bun install
- id: bun-run
name: Sign Release
run: |
echo "$GPG_PASSPHRASE" | bun upload-assets -- "${{ env.TAG }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
npm:
name: Release to NPM
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-env
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v0.1.8
with:
bun-version: canary
github-token: ${{ secrets.GITHUB_TOKEN }}
- id: bun-install
name: Install Dependencies
run: bun install
- id: bun-run
name: Release
run: bun upload-npm -- "${{ env.TAG }}" publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
npm-types:
name: Release types to NPM
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/bun-types
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-env
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-node
name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: latest
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v0.1.8
with:
bun-version: canary
github-token: ${{ secrets.GITHUB_TOKEN }}
- id: bun-install
name: Install Dependencies
run: |
bun upgrade --canary
bun install
- id: bun-run
name: Build
run: bun run build
env:
BUN_VERSION: ${{ env.TAG }}
- id: npm-publish
name: Release
uses: JS-DevTools/npm-publish@v1
with:
package: packages/bun-types/dist/package.json
token: ${{ secrets.NPM_TOKEN }}
docker:
name: Release to Dockerhub
runs-on: ubuntu-latest
needs: sign
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: environment
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: qemu
name: Setup Docker QEMU
uses: docker/setup-qemu-action@v2
- id: buildx
name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
- id: metadata
name: Setup Docker metadata
uses: docker/metadata-action@v4
with:
images: oven/bun
tags: |
type=match,pattern=(bun-v)?(\d.\d.\d),group=2,value=${{ env.TAG }}
type=match,pattern=(bun-v)?(\d.\d),group=2,value=${{ env.TAG }}
- id: login
name: Login to Docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- id: push
name: Push to Docker
uses: docker/build-push-action@v3
with:
context: ./dockerhub
file: ./dockerhub/Dockerfile-debian
platforms: linux/amd64,linux/arm64
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
homebrew:
name: Release to Homebrew
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
with:
repository: oven-sh/homebrew-bun
token: ${{ secrets.ROBOBUN_TOKEN }}
- id: setup-gpg
name: Setup GPG
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- id: setup-env
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-ruby
name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.6"
- id: update-tap
name: Update Tap
run: ruby scripts/release.rb "${{ env.TAG }}"
- id: commit-tap
name: Commit Tap
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_options: --gpg-sign=${{ steps.setup-gpg.outputs.keyid }}
commit_message: Release ${{ env.TAG }}
commit_user_name: robobun
commit_user_email: robobun@oven.sh
commit_author: robobun <robobun@oven.sh>

View File

@@ -1,137 +0,0 @@
name: Release
on:
workflow_dispatch:
jobs:
test-build:
name: Test & Build
runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-types
steps:
- uses: actions/checkout@v3
- name: Install bun
uses: xhyrom/setup-bun@v0.1.8
with:
bun-version: canary
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install node
uses: actions/setup-node@v3
with:
node-version: latest
- name: Install dependencies
run: bun install
- name: ESLint
run: bun run lint
- name: Build package
run: bun run build
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: bun-types
path: packages/bun-types/dist/*
if-no-files-found: error
publish-npm:
name: Publish on NPM
runs-on: ubuntu-latest
needs: [test-build]
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-types
steps:
- uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version: latest
registry-url: 'https://registry.npmjs.org'
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
name: bun-types
path: packages/bun-types/dist
- name: Publish on NPM
run: cd packages/bun-types/dist/ && npm publish --access public
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-gpr:
name: Publish on GPR
runs-on: ubuntu-latest
needs: [test-build]
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-types
steps:
- uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version: latest
registry-url: 'https://npm.pkg.github.com/'
scope: '@oven-sh'
- name: Install bun
uses: xhyrom/setup-bun@v0.1.8
with:
bun-version: canary
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
name: bun-types
path: dist
- name: Add scope to name
run: bun scripts/gpr.ts
- name: Publish on GPR
run: cd dist/ && npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# no need for separate releases now
# create-release:
# name: Create Release
# runs-on: ubuntu-latest
# needs: [test-build]
# defaults:
# run:
# working-directory: packages/bun-types
# if: github.repository_owner == 'oven-sh'
# steps:
# - name: Download all artifacts
# uses: actions/download-artifact@v3
# with:
# name: bun-types
# path: packages/bun-types/dist
# - name: Set version
# run: echo "version=$(jq --raw-output '.version' dist/package.json)" >> $GITHUB_ENV
# - name: Create Release
# uses: softprops/action-gh-release@v0.1.14
# with:
# tag_name: "v${{ env.version }}"
# body: "This is the release of bun-types that corresponds to the commit [${{ github.sha }}]"
# token: ${{ secrets.GITHUB_TOKEN }}
# files: |
# dist/*

View File

@@ -1,16 +1,16 @@
name: TypeScript Types
name: Test bun-types
on:
push:
paths:
- packages/bun-types/**/*
- 'packages/bun-types/**'
branches: [main]
pull_request:
paths:
- packages/bun-types/**/*
- 'packages/bun-types/**'
jobs:
tests:
name: Build and Test
name: Build and test
runs-on: ubuntu-latest
defaults:
run:
@@ -18,12 +18,12 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install bun
uses: xhyrom/setup-bun@v0.1.8
uses: oven-sh/setup-bun@v0.1.8
with:
bun-version: latest
bun-version: canary
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install node
@@ -37,8 +37,5 @@ jobs:
- name: Generate package
run: bun run build
- name: ESLint
run: bun run lint
- name: Tests
run: bun run test

4
.gitignore vendored
View File

@@ -1,7 +1,6 @@
.DS_Store
zig-cache
*.wasm
packages/*/*.wasm
*.o
*.a
profile.json
@@ -110,3 +109,4 @@ misctools/machbench
bun-webkit
src/deps/c-ares/build
src/bun.js/debug-bindings-obj

View File

@@ -1,7 +1,6 @@
{
"tabWidth": 2,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": true,
"trailingComma": "all"
"arrowParens": "avoid",
"printWidth": 120,
"trailingComma": "all",
"useTabs": false
}

View File

@@ -1,6 +1,7 @@
{
"recommendations": [
"AugusteRame.zls-vscode",
"JarredSumner.zig-unofficial",
"esbenp.prettier-vscode",
"xaver.clang-format",
"vadimcn.vscode-lldb"

View File

@@ -13,7 +13,7 @@
"[zig]": {
"editor.tabSize": 4,
"editor.useTabStops": false,
"editor.defaultFormatter": "tiehuis.zig",
"editor.defaultFormatter": "JarredSumner.zig-unofficial",
"editor.formatOnSave": true
},
"[ts]": {
@@ -182,7 +182,11 @@
"ethernet.h": "c",
"inet.h": "c",
"packet.h": "c",
"queue": "cpp"
"queue": "cpp",
"compare": "cpp",
"concepts": "cpp",
"typeindex": "cpp",
"__verbose_abort": "cpp"
},
"cmake.configureOnOpen": false,
"C_Cpp.errorSquiggles": "Enabled",

86
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,86 @@
# Contributing to Bun
All contributions need test coverage. If you are adding a new feature, please add a test. If you are fixing a bug, please add a test that fails before your fix and passes after your fix.
## Bun's codebase
Bun is written mostly in Zig, but WebKit & JavaScriptCore (the JavaScript engine) is written in C++.
Today (Feburary 2023), Bun's codebase has five distinct parts:
- JavaScript, JSX, & TypeScript transpiler, module resolver, and related code
- JavaScript runtime (`src/bun.js/`)
- JavaScript runtime bindings (`src/bun.zig/bindings/**/*.cpp`)
- Package manager (`src/install/`)
- Shared utilities (`src/string_immutable.zig`)
The JavaScript transpiler & module resolver is mostly independent from the runtime. It predates the runtime and is entirely in Zig. The JavaScript parser is mostly in `src/js_parser.zig`. The JavaScript AST data structures are mostly in `src/js_ast.zig`. The JavaScript lexer is in `src/js_lexer.zig`. A lot of this code started as a port of esbuild's equivalent code from Go to Zig, but has had many small changes since then.
## Memory management in Bun
For the Zig code, please:
1. Do your best to avoid dynamically allocating memory.
2. If we need to allocate memory, carefully consider the owner of that memory. If it's a JavaScript object, it will need a finalizer. If it's in Zig, it will need to be freed either via an arena or manually.
3. Prefer arenas over manual memory management. Manually freeing memory is leak & crash prone.
4. If the memory needs to be accessed across threads, use `bun.default_allocator`. Mimalloc threadlocal heaps are not safe to free across threads.
The JavaScript transpiler has special-handling for memory management. The parser allocates into a single arena and the memory is recycled after each parse.
## JavaScript runtime
Most of Bun's JavaScript runtime code lives in `src/bun.js`.
### Calling C++ from Zig & Zig from C++
TODO: document this (see bindings.zig and bindings.cpp for now)
### Adding a new JavaScript class
1. Add a new file in `src/bun.js/*.classes.ts` to define the instance and static methods for the class.
2. Add a new file in `src/bun.js/**/*.zig` and expose the struct in `src/bun.js/generated_classes_list.zig`
3. Run `make codegen`
Copy from examples like `Subprocess` or `Response`.
### ESM modules
Bun implements ESM modules in a mix of native code and JavaScript.
Several Node.js modules are implemented in JavaScript and loosely based on browserify polyfills.
The ESM modules in Bun are located in `src/bun.js/*.exports.js`. Unlike other code in Bun, these files are NOT transpiled. They are loaded directly into the JavaScriptCore VM. That means `require` does not work in these files. Instead, you must use `import.meta.require`, or ideally, not use require/import other files at all.
The module loader is in `src/bun.js/module_loader.zig`.
### JavaScript Builtins
JavaScript builtins are located in `src/bun.js/builtins/*.js`.
These files support a JavaScriptCore-only syntax for internal slots. `@` is used to access an internal slot. For example: `new @Array(123)` will create a new `Array` similar to `new Array(123)`, except if a library modifies the `Array` global, it will not affect the internal slot (`@Array`). These names must be allow-listed in `BunBuiltinNames.h` (though JavaScriptCore allowlists some names by default).
They can not use or reference ESM-modules. The files that end with `*Internals.js` are automatically loaded globally. Most usage of internals right now are the stream implementations (which share a lot of code from Safari/WebKit) and ImportMetaObject (which is how `require` is implemented in the runtime)
To regenerate the builtins:
```sh
make clean-bindings && make generate-builtins && make bindings -j10
```
It is recommended that you have ccache installed or else you will spend a lot of time waiting for the bindings to compile.
### Memory management in Bun's JavaScript runtime
TODO: fill this out (for now, use `JSC.Strong` in most cases)
### Strings
TODO: fill this out (for now, use `JSValue.toSlice()` in most cases)
#### JavaScriptCore C API
Do not copy from examples leveraging the JavaScriptCore C API. Please do not use this in new code. We will not accept PRs that add new code that uses the JavaScriptCore C API.
## Testing
See `../test/README.md` for information on how to run tests.

View File

@@ -10,9 +10,9 @@ ARG ARCH=x86_64
ARG BUILD_MACHINE_ARCH=x86_64
ARG TRIPLET=${ARCH}-linux-gnu
ARG BUILDARCH=amd64
ARG WEBKIT_TAG=jul27-2
ARG WEBKIT_TAG=feb9
ARG ZIG_TAG=jul1
ARG ZIG_VERSION="0.11.0-dev.947+cf822c6dd"
ARG ZIG_VERSION="0.11.0-dev.1393+38eebf3c4"
ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH"
ARG ZIG_FOLDERNAME=zig-linux-${BUILD_MACHINE_ARCH}-${ZIG_VERSION}
@@ -20,7 +20,7 @@ ARG ZIG_FILENAME=${ZIG_FOLDERNAME}.tar.xz
ARG WEBKIT_URL="https://github.com/oven-sh/WebKit/releases/download/$WEBKIT_TAG/${WEBKIT_BASENAME}.tar.gz"
ARG ZIG_URL="https://ziglang.org/builds/${ZIG_FILENAME}"
ARG GIT_SHA=""
ARG BUN_BASE_VERSION=0.4
ARG BUN_BASE_VERSION=0.5
FROM bitnami/minideb:bullseye as bun-base
@@ -122,8 +122,8 @@ ARG BUN_RELEASE_DIR
ARG BUN_DEPS_OUT_DIR
ARG BUN_DIR
ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
ENV CCACHE_DIR=/ccache
ENV JSC_BASE_DIR=${WEBKIT_DIR}
ENV LIB_ICU_PATH=${WEBKIT_DIR}/lib
@@ -149,6 +149,9 @@ ARG BUN_RELEASE_DIR
ARG BUN_DEPS_OUT_DIR
ARG BUN_DIR
ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
COPY Makefile ${BUN_DIR}/Makefile
COPY src/deps/lol-html ${BUN_DIR}/src/deps/lol-html
@@ -303,8 +306,6 @@ ARG BUN_RELEASE_DIR
ARG BUN_DEPS_OUT_DIR
ARG BUN_DIR
ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
COPY Makefile ${BUN_DIR}/Makefile
@@ -484,6 +485,9 @@ ARG BUN_RELEASE_DIR
ARG BUN_DEPS_OUT_DIR
ARG BUN_DIR
ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
ENV CCACHE_DIR=/ccache
COPY Makefile ${BUN_DIR}/Makefile

View File

@@ -8,7 +8,7 @@ ARG BUN_RELEASE_DIR=${GITHUB_WORKSPACE}/bun-release
ARG BUN_DEPS_OUT_DIR=${GITHUB_WORKSPACE}/bun-deps
ARG BUN_DIR=${GITHUB_WORKSPACE}/bun
ARG BUN_PACKAGES_DIR=${BUN_DIR}/packages
ARG ZIG_VERSION="0.11.0-dev.947+cf822c6dd"
ARG ZIG_VERSION="0.11.0-dev.1393+38eebf3c4"
ARG ZIG_FOLDERNAME=zig-linux-${ARCH}-${ZIG_VERSION}
ARG ZIG_FILENAME=${ZIG_FOLDERNAME}.tar.xz
@@ -99,7 +99,7 @@ RUN tar -xf ${ZIG_FILENAME} && \
mv ${ZIG_FOLDERNAME} ${ZIG_PATH};
RUN cd $GITHUB_WORKSPACE && \
curl -o bun-webkit-linux-$BUILDARCH.tar.gz -L https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-linux-$BUILDARCH.tar.gz && \
curl -o bun-webkit-linux-$BUILDARCH.tar.gz -L https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-linux-$BUILDARCH.tar.gz && \
tar -xzf bun-webkit-linux-$BUILDARCH.tar.gz && \
rm bun-webkit-linux-$BUILDARCH.tar.gz && \
cat $WEBKIT_OUT_DIR/include/cmakeconfig.h > /dev/null

View File

@@ -35,11 +35,11 @@ DOCKER_BUILDARCH = amd64
BREW_PREFIX_PATH = /usr/local
DEFAULT_MIN_MACOS_VERSION = 10.14
MARCH_NATIVE = -march=$(CPU_TARGET) -mtune=$(CPU_TARGET)
NATIVE_OR_OLD_MARCH = -march=westmere
NATIVE_OR_OLD_MARCH = -march=nehalem
endif
MIN_MACOS_VERSION ?= $(DEFAULT_MIN_MACOS_VERSION)
BUN_BASE_VERSION = 0.4
BUN_BASE_VERSION = 0.5
AR=
@@ -509,6 +509,9 @@ npm-install:
$(NPM_CLIENT) install --ignore-scripts --production
print-% : ; @echo $* = $($*)
get-% : ; @echo $($*)
print-version:
@echo $(PACKAGE_JSON_VERSION)
@@ -922,7 +925,7 @@ headers:
rm -f /tmp/build-jsc-headers src/bun.js/bindings/headers.zig
touch src/bun.js/bindings/headers.zig
$(ZIG) build headers-obj
$(CXX) $(PLATFORM_LINKER_FLAGS) $(JSC_FILES_DEBUG) ${ICU_FLAGS} $(DEBUG_IO_FILES) $(BUN_LLD_FLAGS_WITHOUT_JSC) -g $(DEBUG_BIN)/headers.o -W -o /tmp/build-jsc-headers -lc;
$(CXX) $(PLATFORM_LINKER_FLAGS) $(JSC_FILES_DEBUG) ${ICU_FLAGS} $(BUN_LLD_FLAGS_WITHOUT_JSC) -g $(DEBUG_BIN)/headers.o -W -o /tmp/build-jsc-headers -lc;
/tmp/build-jsc-headers
$(ZIG) translate-c src/bun.js/bindings/headers.h > src/bun.js/bindings/headers.zig
$(BUN_OR_NODE) misctools/headers-cleaner.js
@@ -1391,10 +1394,19 @@ bindings: $(DEBUG_OBJ_DIR) $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG
.PHONY: jsc-bindings-mac
jsc-bindings-mac: bindings
# lInux only
MIMALLOC_VALGRIND_ENABLED_FLAG =
ifeq ($(OS_NAME),linux)
MIMALLOC_VALGRIND_ENABLED_FLAG = -DMI_VALGRIND=ON
endif
.PHONY: mimalloc-debug
mimalloc-debug:
rm -rf $(BUN_DEPS_DIR)/mimalloc/CMakeCache* $(BUN_DEPS_DIR)/mimalloc/CMakeFiles
cd $(BUN_DEPS_DIR)/mimalloc; make clean || echo ""; \
CFLAGS="$(CFLAGS)" cmake $(CMAKE_FLAGS_WITHOUT_RELEASE) ${MIMALLOC_OVERRIDE_FLAG} \
CFLAGS="$(CFLAGS)" cmake $(CMAKE_FLAGS_WITHOUT_RELEASE) ${MIMALLOC_OVERRIDE_FLAG} ${MIMALLOC_VALGRIND_ENABLED_FLAG} \
-DCMAKE_BUILD_TYPE=Debug \
-DMI_DEBUG_FULL=1 \
-DMI_SKIP_COLLECT_ON_EXIT=1 \

View File

@@ -23,24 +23,32 @@ Today, bun's primary focus is bun.js: bun's JavaScript runtime.
## Install
Native: (macOS x64 & Silicon, Linux x64, Windows Subsystem for Linux)
Bun supports Linux (x64 & arm64) and macOS (x64 & Apple Silicon). If you want to use Bun on Windows, you will need to use Windows Subsystem for Linux. Bun will [soon](https://github.com/oven-sh/bun/issues/43) support Windows, natively.
curl:
```sh
curl -fsSL https://bun.sh/install | bash
```
Homebrew: (MacOS and Linux)
npm:
```sh
npm install -g bun
```
Homebrew:
```sh
brew tap oven-sh/bun
brew install bun
```
Docker: (Linux x64)
Docker:
```sh
docker pull jarredsumner/bun:edge
docker run --rm --init --ulimit memlock=-1:-1 jarredsumner/bun:edge
docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun
```
If using Linux, kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1.
@@ -175,6 +183,7 @@ bun upgrade --canary
- [`Bun.Transpiler.scan`](#buntranspilerscan)
- [`Bun.Transpiler.scanImports`](#buntranspilerscanimports)
- [`Bun.peek` - read a promise same-tick](#bunpeek---read-a-promise-without-resolving-it)
- [`Bun.dns` - lookup a domain](#bundns---lookup-a-domain)
- [Module resolution in Bun](#module-resolution-in-bun)
- [Environment variables](#environment-variables)
- [Credits](#credits)
@@ -415,6 +424,21 @@ Assuming a package.json with a `"clean"` command in `"scripts"`:
}
```
## Using bun as a WebAssembly runner
Bun v0.5.2 added experimental support for the [WebAssembly System Interface](https://github.com/WebAssembly/WASI) (WASI). This means you can run WebAssembly binaries in Bun.
To run a WASI binary, use `bun run`:
```bash
bun run ./my-wasm-app.wasm
# you can omit "run" if the filename ends with .wasm
bun ./my-wasm-app.wasm
```
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 optimized for performance, but if this feature gets popular, we'll definitely invest time in making it faster.
## Creating a Discord bot with Bun
### Application Commands
@@ -580,7 +604,6 @@ You can see [Bun's Roadmap](https://github.com/oven-sh/bun/issues/159), but here
| ------------------------------------------------------------------------------------- | -------------- |
| Web Streams with Fetch API | bun.js |
| Web Streams with HTMLRewriter | bun.js |
| Package hoisting that matches npm behavior | bun install |
| Source Maps (unbundled is supported) | JS Bundler |
| Source Maps | CSS |
| JavaScript Minifier | JS Transpiler |
@@ -1254,7 +1277,7 @@ bun install --backend copyfile
**`symlink`** is typically only used for `file:` dependencies (and eventually `link:`) internally. To prevent infinite loops, it skips symlinking the `node_modules` folder.
If you install with `--backend=symlink`, Node.js won't resolve node_modules of dependencies unless each dependency has it's own node_modules folder or you pass `--preserve-symlinks` to `node`. See [Node.js documentation on `--preserve-symlinks`](https://nodejs.org/api/cli.html#--preserve-symlinks).
If you install with `--backend=symlink`, Node.js won't resolve node_modules of dependencies unless each dependency has its own node_modules folder or you pass `--preserve-symlinks` to `node`. See [Node.js documentation on `--preserve-symlinks`](https://nodejs.org/api/cli.html#--preserve-symlinks).
```bash
rm -rf node_modules
@@ -1275,7 +1298,7 @@ buns usage of `Cache-Control` ignores `Age`. This improves performance, but m
### `bun run`
`bun run` is a fast `package.json` script runner. Instead of waiting 170ms for your npm client to start every time, you wait 6ms for bun.
`bun run` is a fast `package.json` script runner and executable runner. Instead of waiting 170ms for your npm client to start every time, you wait 6ms for bun.
By default, `bun run` prints the script that will be invoked:
@@ -1290,7 +1313,7 @@ You can disable that with `--silent`
bun run --silent clean
```
`bun run ${script-name}` runs the equivalent of `npm run script-name`. For example, `bun run dev` runs the `dev` script in `package.json`, which may sometimes spin up non-bun processes.
`bun run ${script-name}` runs the equivalent of `npm run script-name`, `npx bin-name`, and `node file-name` all in one command. For example, `bun run dev` runs the `dev` script in `package.json`, which may sometimes spin up non-bun processes.
`bun run ${javascript-file.js}` will run it with bun, as long as the file doesn't have a node shebang.
@@ -2591,7 +2614,7 @@ If you need to read from `stdout` or `stderr` synchronously, you should use `Bun
`Bun.spawn` returns a `Subprocess` object.
More complete types are available in [`bun-types`](https://github.com/oven-sh/bun-types).
More complete types are available in [`bun-types`](https://github.com/oven-sh/bun/tree/main/packages/bun-types).
```ts
interface Subprocess {
@@ -2823,6 +2846,50 @@ queueMicrotask(() => {
Builtin buffering is planned in a future version of Bun.
## `Bun.dns` - lookup a domain
`Bun.dns` includes utilities to make DNS requests, similar to `node:dns`. As of Bun v0.5.0, the only implemented function is `dns.lookup`, though more will be implemented soon.
You can lookup the IP addresses of a hostname by using `dns.lookup`.
```ts
import { dns } from "bun";
const [{ address }] = await dns.lookup("example.com");
console.log(address); // "93.184.216.34"
```
If you need to limit IP addresses to either IPv4 or IPv6, you can specify the `family` as an option.
```ts
import { dns } from "bun";
const [{ address }] = await dns.lookup("example.com", { family: 6 });
console.log(address); // "2606:2800:220:1:248:1893:25c8:1946"
```
Bun supports three backends for DNS resolution:
- `c-ares` - This is the default on Linux, and it uses the [c-ares](https://c-ares.org/) library to perform DNS resolution.
- `system` - Uses the system's non-blocking DNS resolver, if available. Otherwise, falls back to `getaddrinfo`. This is the default on macOS, and the same as `getaddrinfo` on Linux.
- `getaddrinfo` - Uses the POSIX standard `getaddrinfo` function, which may cause performance issues under concurrent load.
You can choose a particular backend by specifying `backend` as an option.
```ts
import { dns } from "bun";
const [{ address, ttl }] = await dns.lookup("example.com", {
backend: "c-ares",
});
console.log(address); // "93.184.216.34"
console.log(ttl); // 21237
```
Note: the `ttl` property is only accurate when the `backend` is c-ares. Otherwise, `ttl` will be `0`.
This was added in Bun v0.5.0.
## `Bun.peek` - read a promise without resolving it
`Bun.peek` is a utility function that lets you read a promise's result without `await` or `.then`, but only if the promise has already fulfilled or rejected.
@@ -4581,7 +4648,7 @@ It will check the lockfile for the version. If the lockfile doesn't have a versi
Lowlights:
- TypeScript type support isn't implmented yet
- TypeScript type support isn't implemented yet
- patch package support isn't implemented yet
#### Resolving packages
@@ -4942,6 +5009,7 @@ bun also statically links these libraries:
- [`c-ares`](https://github.com/c-ares/c-ares), which is MIT licensed
- `libicu` 72, which can be found here: <https://github.com/unicode-org/icu/blob/main/icu4c/LICENSE>
- A fork of [`uWebsockets`](https://github.com/jarred-sumner/uwebsockets), which is Apache 2.0 licensed
- WASI implementation from [`wasi-js`](https://github.com/sagemathinc/cowasm/tree/main/core/wasi-js), which is BSD 3 clause licensed. Note that wasi-js is originally based on [wasmer-js](https://github.com/wasmerio/wasmer-js), which is MIT licensed. wasmer-js was based on [node-wasi](https://github.com/devsnek/node-wasi) by Gus Caplan (also MIT licensed). You can [read more about the history here](https://github.com/sagemathinc/cowasm/tree/main/core/wasi-js#history).
For compatibility reasons, these NPM packages are embedded into buns binary and injected if imported.
@@ -5065,7 +5133,7 @@ which clang-15
If it is not, you will have to run this to link it:
```bash
export PATH="$(brew --prefix llvm@15)/bin"
export PATH="$PATH:$(brew --prefix llvm@15)/bin"
export LDFLAGS="$LDFLAGS -L$(brew --prefix llvm@15)/lib"
export CPPFLAGS="$CPPFLAGS -I$(brew --prefix llvm@15)/include"
```

View File

@@ -1,9 +1,49 @@
import { bench, run } from "mitata";
const N = parseInt(process.argv.slice(2).at(0) || "10", 10);
var isBuffer = new Buffer(0);
var isNOtBuffer = "not a buffer";
bench("new Buffer(0)", () => {
return new Buffer(0);
bench("Buffer.isBuffer(buffer)", () => {
return Buffer.isBuffer(isBuffer);
});
{
var j = 0;
j += 1;
j += eval("'ok'");
bench("Buffer.isBuffer(string)", () => {
return Buffer.isBuffer(j);
});
}
bench("Buffer.from('short string')", () => {
return Buffer.from("short string");
});
const loooong = "long string".repeat(9999).split("").join(" ");
bench("Buffer.byteLength('long string'.repeat(9999))", () => {
return Buffer.byteLength(loooong);
});
var hundred = new ArrayBuffer(100);
bench("Buffer.from(ArrayBuffer(100))", () => {
return Buffer.from(hundred);
});
var hundredArray = new Uint8Array(100);
bench("Buffer.from(Uint8Array(100))", () => {
return Buffer.from(hundredArray);
});
var empty = new Uint8Array(0);
bench("Buffer.from(Uint8Array(0))", () => {
return Buffer.from(empty);
});
bench("new Buffer(Uint8Array(0))", () => {
return new Buffer(empty);
});
bench(`new Buffer(${N})`, () => {
@@ -26,4 +66,4 @@ bench("Buffer.alloc(24_000)", () => {
return Buffer.alloc(24_000);
});
await run();
await run({});

BIN
bench/snippets/bun.lockb Executable file

Binary file not shown.

View File

@@ -21,8 +21,14 @@ bench('crypto.createHash("sha512")', () => {
hasher.digest();
});
bench('crypto.createHash("sha512")', () => {
var hasher = crypto.createHash("sha512");
bench('crypto.createHash("sha256")', () => {
var hasher = crypto.createHash("sha256");
hasher.update(foo);
hasher.digest();
});
bench('crypto.createHash("sha1")', () => {
var hasher = crypto.createHash("sha1");
hasher.update(foo);
hasher.digest();
});

View File

@@ -1,71 +1,81 @@
const EventEmitter = require("events").EventEmitter;
const EventEmitterNative = require("events").EventEmitter;
const TypedEmitter = require("tiny-typed-emitter").TypedEmitter;
const EventEmitter3 = require("eventemitter3").EventEmitter;
import { bench, run } from "mitata";
const emitter = new EventEmitter();
const event = new Event("hello");
emitter.on("hello", (event) => {
event.preventDefault();
});
var id = 0;
bench("EventEmitter.emit", () => {
emitter.emit("hello", {
preventDefault() {
id++;
},
});
});
for (let [EventEmitter, className] of [
[EventEmitterNative, "EventEmitter"],
[TypedEmitter, "TypedEmitter"],
[EventEmitter3, "EventEmitter3"],
]) {
const emitter = new EventEmitter();
var monkey = Object.assign({}, EventEmitter.prototype);
monkey.on("hello", (event) => {
event.preventDefault();
});
bench("[monkey] EventEmitter.emit", () => {
var called = false;
monkey.emit("hello", {
preventDefault() {
id++;
called = true;
},
emitter.on("hello", (event) => {
event.preventDefault();
});
if (!called) {
throw new Error("monkey failed");
bench(`${className}.emit`, () => {
emitter.emit("hello", {
preventDefault() {
id++;
},
});
});
bench(`${className}.on x 10_000 (handler)`, () => {
var cb = (event) => {
event.preventDefault();
};
emitter.on("hey", cb);
var called = false;
for (let i = 0; i < 10_000; i++)
emitter.emit("hey", {
preventDefault() {
id++;
called = true;
},
});
emitter.off("hey", cb);
if (!called) throw new Error("not called");
});
if (EventEmitter !== EventEmitter3) {
var monkey = Object.assign({}, EventEmitter.prototype);
monkey.on("hello", (event) => {
event.preventDefault();
});
bench(`[monkey] ${className}.emit`, () => {
var called = false;
monkey.emit("hello", {
preventDefault() {
id++;
called = true;
},
});
if (!called) {
throw new Error("monkey failed");
}
});
bench(`[monkey] ${className}.on x 10_000 (handler)`, () => {
var cb = () => {
event.preventDefault();
};
monkey.on("hey", cb);
for (let i = 0; i < 10_000; i++)
monkey.emit("hey", {
preventDefault() {
id++;
},
});
monkey.off("hey", cb);
});
}
});
bench("EventEmitter.on x 10_000 (handler)", () => {
var cb = (event) => {
event.preventDefault();
};
emitter.on("hey", cb);
var called = false;
for (let i = 0; i < 10_000; i++)
emitter.emit("hey", {
preventDefault() {
id++;
called = true;
},
});
emitter.off("hey", cb);
if (!called) throw new Error("not called");
});
bench("[monkey] EventEmitter.on x 10_000 (handler)", () => {
var cb = () => {
event.preventDefault();
};
monkey.on("hey", cb);
for (let i = 0; i < 10_000; i++)
monkey.emit("hey", {
preventDefault() {
id++;
},
});
monkey.off("hey", cb);
});
}
var target = new EventTarget();
target.addEventListener("hello", (event) => {});

View File

@@ -0,0 +1,34 @@
// so it can run in environments without node module resolution
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
const blob = new Blob(["foo", "bar", "baz"]);
bench("FormData.append", () => {
const data = new FormData();
data.append("foo", "bar");
data.append("baz", blob);
});
const data = new FormData();
data.append("foo", "bar");
data.append("baz", blob);
const formText =
// single field form data
"--Form\r\n" + 'Content-Disposition: form-data; name="foo"\r\n\r\n' + "bar\r\n" + "--Form--\r\n";
bench("response.formData()", async () => {
await new Response(formText, {
headers: {
"Content-Type": "multipart/form-data; boundary=Form",
},
}).formData();
});
bench("new Response(formData).text()", async () => {
await new Response(data).text();
});
bench("new Response(formData).formData()", async () => {
await new Response(data).formData();
});
await run();

View File

@@ -0,0 +1,25 @@
import { bench, run } from "mitata";
// These are no-op C++ functions that are exported to JS.
const lazy = globalThis[Symbol.for("Bun.lazy")];
const noop = lazy("noop");
const fn = noop.function;
const regular = noop.functionRegular;
bench("C++ fn regular", () => {
regular();
});
bench("C++ fn", () => {
fn();
});
bench("C++ getter", () => {
return noop.getterSetter;
});
bench("C++ setter", () => {
noop.getterSetter = 1;
});
run();

View File

@@ -0,0 +1,6 @@
{
"dependencies": {
"eventemitter3": "^5.0.0",
"tiny-typed-emitter": "latest"
}
}

17
bench/snippets/stat.mjs Normal file
View File

@@ -0,0 +1,17 @@
import { readdirSync, statSync } from "fs";
import { bench, run } from "mitata";
import { argv } from "process";
const dir = argv.length > 2 ? argv[2] : "/tmp";
const result = statSync(dir);
bench("Stat.isBlockDevice", () => result.isBlockDevice());
bench("Stat.isCharacterDevice", () => result.isCharacterDevice());
bench("Stat.isDirectory", () => result.isDirectory());
bench("Stat.isFIFO", () => result.isFIFO());
bench("Stat.isFile", () => result.isFile());
bench("Stat.isSocket", () => result.isSocket());
bench("Stat.isSymbolicLink", () => result.isSymbolicLink());
await run();

View File

@@ -4,23 +4,20 @@ var short = new TextEncoder().encode("Hello World!");
var shortUTF16 = new TextEncoder().encode("Hello World 💕💕💕");
var long = new TextEncoder().encode("Hello World!".repeat(1024));
var longUTF16 = new TextEncoder().encode("Hello World 💕💕💕".repeat(1024));
var decoder = new TextDecoder();
bench(`${short.length} ascii`, () => {
var decoder = new TextDecoder();
decoder.decode(short);
});
bench(`${short.length} utf8`, () => {
var decoder = new TextDecoder();
decoder.decode(shortUTF16);
});
bench(`${long.length} ascii`, () => {
var decoder = new TextDecoder();
decoder.decode(long);
});
bench(`${longUTF16.length} utf8`, () => {
var decoder = new TextDecoder();
decoder.decode(longUTF16);
});

View File

@@ -1,58 +1,102 @@
import { readFileSync } from "fs";
import { dirname } from "path";
import { fileURLToPath } from "url";
import { bench, run, group } from "mitata";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const esbuild_ = require("esbuild/lib/main");
const swc_ = require("@swc/core");
const babel_ = require("@babel/core");
var transformSync;
var transform;
var opts;
if (process.isBun) {
const transpiler = new Bun.Transpiler({ loader: "jsx" });
transformSync = transpiler.transformSync.bind(transpiler);
transform = transpiler.transform.bind(transpiler);
opts = "jsx";
} else if (process.env["esbuild"]) {
try {
const esbuild = await import("esbuild");
transformSync = esbuild.transformSync;
transform = esbuild.transform;
opts = { loader: "jsx" };
} catch (exception) {
throw exception;
}
} else if (process.env["swc"]) {
try {
const swc = await import("@swc/core");
transformSync = swc.transformSync;
transform = swc.transform;
opts = {
sourceMaps: false,
inlineSourcesContent: false,
jsc: {
target: "es2022",
parser: {
jsx: true,
const code = readFileSync(
dirname(fileURLToPath(import.meta.url)) +
"/../../src/test/fixtures/simple.jsx",
"utf-8",
);
async function getWithName(name) {
let transformSync;
let transform;
let opts;
if (name === "bun") {
const transpiler = new Bun.Transpiler({ loader: "jsx" });
transformSync = transpiler.transformSync.bind(transpiler);
transform = transpiler.transform.bind(transpiler);
opts = "jsx";
} else if (name === "esbuild") {
try {
transformSync = esbuild_.transformSync;
transform = esbuild_.transform;
opts = { loader: "jsx" };
} catch (exception) {
throw exception;
}
} else if (name === "swc") {
try {
transformSync = swc_.transformSync;
transform = swc_.transform;
opts = {
sourceMaps: false,
inlineSourcesContent: false,
jsc: {
target: "es2022",
parser: {
jsx: true,
},
},
},
};
} catch (exception) {
throw exception;
}
} else if (process.env["babel"]) {
try {
const swc = await import("@babel/core");
transformSync = swc.transformSync;
transform = swc.transform;
opts = {
sourceMaps: false,
presets: [(await import("@babel/preset-react")).default],
};
} catch (exception) {
throw exception;
};
} catch (exception) {
throw exception;
}
} else if (name === "babel") {
try {
transformSync = babel_.transformSync;
transform = babel_.transform;
opts = {
sourceMaps: false,
presets: ["@babel/preset-react"],
};
} catch (exception) {
throw exception;
}
}
return {
transformSync,
transform,
opts,
name,
};
}
const code = readFileSync("src/test/fixtures/simple.jsx", "utf8");
const bun = process.isBun ? await getWithName("bun") : null;
const esbuild = await getWithName("esbuild");
const swc = await getWithName("swc");
const babel = await getWithName("babel");
if (process.env.ASYNC) {
console.log(await transform(code, opts));
} else {
console.log(transformSync(code, opts));
}
const transpilers = [bun, esbuild, swc, babel].filter(Boolean);
group("transformSync (" + ((code.length / 1024) | 0) + " KB jsx file)", () => {
for (let { name, transformSync, opts } of transpilers) {
bench(name, () => {
transformSync(code, opts);
});
}
});
group("tranform x 5", () => {
for (let { name, transform, opts } of transpilers) {
bench(name, async () => {
return Promise.all([
transform(code, opts),
transform(code + "\n", opts),
transform("\n" + code + "\n", opts),
transform("\n" + code + "\n\n", opts),
transform("\n\n" + code + "\n\n", opts),
]);
});
}
});
await run();

BIN
bun.lockb

Binary file not shown.

View File

@@ -1,6 +1,3 @@
[test]
# Large monorepos (like Bun) may want to specify the test directory more specifically
# By default, `bun wiptest` scans every single folder recurisvely which, if you

View File

@@ -0,0 +1,83 @@
# https://hub.docker.com/_/debian
# https://hub.docker.com/_/ubuntu
ARG IMAGE=debian:bullseye-slim
FROM $IMAGE AS base
# https://github.com/oven-sh/bun/releases
ARG BUN_VERSION=latest
RUN apt-get update -qq \
&& apt-get install -qq --no-install-recommends \
ca-certificates \
curl \
dirmngr \
gpg \
gpg-agent \
unzip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& arch="$(dpkg --print-architecture)" \
&& case "${arch##*-}" in \
amd64) build="x64-baseline";; \
arm64) build="aarch64";; \
*) echo "error: unsupported architecture: ($arch)"; exit 1 ;; \
esac \
&& version="$BUN_VERSION" \
&& case "$version" in \
latest | canary | bun-v*) tag="$version"; ;; \
v*) tag="bun-$version"; ;; \
*) tag="bun-v$version"; ;; \
esac \
&& case "$tag" in \
latest) release="latest/download"; ;; \
*) release="download/$tag"; ;; \
esac \
&& curl "https://github.com/oven-sh/bun/releases/$release/bun-linux-$build.zip" \
-fsSLO \
--compressed \
--retry 5 \
|| (echo "error: unknown release: ($tag)" && exit 1) \
&& for key in \
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
|| gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& gpg --update-trustdb \
&& curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
-fsSLO \
--compressed \
--retry 5 \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
&& grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
&& unzip "bun-linux-$build.zip" \
&& mv "bun-linux-$build/bun" /usr/local/bin/bun \
&& rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
&& chmod +x /usr/local/bin/bun \
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
&& which bun \
&& which bunx \
&& bun --version
FROM $IMAGE
RUN groupadd bun \
--gid 1000 \
&& useradd bun \
--uid 1000 \
--gid bun \
--shell /bin/sh \
--create-home
COPY --from=base /usr/local/bin/bun /usr/local/bin
COPY --from=base /usr/local/bin/bunx /usr/local/bin
RUN which bun \
&& which bunx \
&& bun --version
WORKDIR /home/bun/app
CMD ["bun"]

View File

@@ -0,0 +1,76 @@
import { file, serve } from "bun";
import { existsSync, statSync } from "fs";
serve({
fetch(req: Request) {
let pathname = new URL(req.url).pathname.substring(1);
if (pathname == "") {
pathname = import.meta.url.replace("file://", "");
}
if (!existsSync(pathname)) {
return new Response(null, { status: 404 });
}
const stats = statSync(pathname);
// https://github.com/gornostay25/svelte-adapter-bun/blob/master/src/sirv.js
const headers = new Headers({
"Content-Length": "" + stats.size,
"Last-Modified": stats.mtime.toUTCString(),
ETag: `W/"${stats.size}-${stats.mtime.getTime()}"`,
});
if (req.headers.get("if-none-match") === headers.get("ETag")) {
return new Response(null, { status: 304 });
}
const opts = { code: 200, start: 0, end: Infinity, range: false };
if (req.headers.has("range")) {
opts.code = 206;
let [x, y] = req.headers.get("range").replace("bytes=", "").split("-");
let end = (opts.end = parseInt(y, 10) || stats.size - 1);
let start = (opts.start = parseInt(x, 10) || 0);
if (start >= stats.size || end >= stats.size) {
headers.set("Content-Range", `bytes */${stats.size}`);
return new Response(null, {
headers: headers,
status: 416,
});
}
headers.set("Content-Range", `bytes ${start}-${end}/${stats.size}`);
headers.set("Content-Length", "" + (end - start + 1));
headers.set("Accept-Ranges", "bytes");
opts.range = true;
}
if (opts.range) {
return new Response(file(pathname).slice(opts.start, opts.end), {
headers,
status: opts.code,
});
}
return new Response(file(pathname), { headers, status: opts.code });
},
// this is called when fetch() throws or rejects
// error(err: Error) {
// return new Response("uh oh! :(" + String(err.toString()), { status: 500 });
// },
// this boolean enables the bun's default error handler
// sometime after the initial release, it will auto reload as well
development: process.env.NODE_ENV !== "production",
// note: this isn't node, but for compatibility bun supports process.env + more stuff in process
// SSL is enabled if these two are set
// certFile: './cert.pem',
// keyFile: './key.pem',
port: 3000, // number or string
hostname: "localhost", // defaults to 0.0.0.0
});

Binary file not shown.

View File

@@ -0,0 +1,24 @@
// A simple way to connect FileSystemRouter to Bun#serve
// run with `bun run index.tsx`
import { renderToReadableStream } from 'react-dom/server'
import { FileSystemRouter } from 'bun'
export default {
port: 3000,
async fetch(request: Request) {
const router = new FileSystemRouter({
dir: process.cwd() + "/pages",
style: "nextjs"
})
const route = router.match(request)
const { default: Root } = await import(route.filePath)
return new Response(
await renderToReadableStream(
<Root {...route.params} />
)
)
}
}

View File

@@ -0,0 +1,14 @@
{
"name": "react-routes",
"module": "index.tsx",
"type": "module",
"devDependencies": {
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"bun-types": "^0.4.0"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}

View File

@@ -0,0 +1,17 @@
// reachable from http://localhost:3000/
export default () => (
<html>
<head>
<title>index</title>
</head>
<body>
<h1>
<a href="/one" >one</a>
</h1>
<h1>
<a href="/two" >two</a>
</h1>
</body>
</html>
)

View File

@@ -0,0 +1,12 @@
// reachable from http://localhost:3000/one
export default () => (
<html>
<head>
<title>one</title>
</head>
<body>
<p>one</p>
</body>
</html>
)

View File

@@ -0,0 +1,12 @@
// reachable from http://localhost:3000/two
export default () => (
<html>
<head>
<title>two</title>
</head>
<body>
<p>two</p>
</body>
</html>
)

View File

@@ -0,0 +1,20 @@
{
"compilerOptions": {
"lib": [
"ESNext"
],
"module": "esnext",
"target": "esnext",
"moduleResolution": "nodenext",
"strict": false,
"downlevelIteration": true,
"skipLibCheck": true,
"jsx": "preserve",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"types": [
"bun-types" // add Bun global
]
}
}

View File

@@ -1,14 +1,12 @@
{
"dependencies": {
"express": "^4.18.2",
"mitata": "^0.1.3",
"peechy": "latest",
"react": "next",
"react-dom": "next",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.5.0",
"mitata": "^0.1.3",
"peechy": "latest",
"prettier": "^2.4.1",
"svelte": "^3.52.0",
"react": "next",
"react-dom": "next",
"typescript": "latest"
},
"private": true,
@@ -17,7 +15,7 @@
"build-fallback": "esbuild --target=esnext --bundle src/fallback.ts --format=iife --platform=browser --minify > src/fallback.out.js",
"postinstall": "bash .scripts/postinstall.sh",
"typecheck": "tsc",
"fmt": "prettier --write './**/*.{ts,tsx,js,jsx}'",
"fmt": "prettier --write './**/*.{ts,tsx,js,jsx}' --config .prettierrc",
"lint": "eslint './**/*.d.ts' --cache",
"lint:fix": "eslint './**/*.d.ts' --cache --fix"
},
@@ -25,7 +23,7 @@
"@types/react": "^18.0.25",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"bun-webkit": "latest"
"bun-webkit": "0.0.1-61ed147fdeaa0787d77bddb332177f23ad96d6fe"
},
"version": "0.0.0"
}

3
packages/bun-ecosystem/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
.DS_Store
node_modules
tmp

View File

@@ -0,0 +1,7 @@
# bun-ecosystem
A registry to test `npm` packages using Bun. This can be used as a tool to find bugs in Bun by running the test suites of these packages. In the future, we will run theses tests to catch regressions between releases.
```sh
bun run test
```

BIN
packages/bun-ecosystem/bun.lockb Executable file

Binary file not shown.

View File

@@ -0,0 +1,14 @@
{
"private": true,
"dependencies": {
"globby": "^13.1.3"
},
"devDependencies": {
"bun-types": "canary",
"prettier": "^2.8.2"
},
"scripts": {
"format": "prettier --write src",
"test": "bun run src/runner.ts"
}
}

View File

@@ -0,0 +1,69 @@
export type Package = {
readonly name: string;
readonly repository: string;
readonly cwd?: string;
readonly tests?: {
readonly style: "jest" | "ava" | "tape" | "custom";
readonly include: string[];
readonly exclude?: string[];
readonly disabled?: boolean;
};
};
export const packages: Package[] = [
{
name: "lodash",
repository: github("lodash/lodash"),
tests: {
style: "jest",
include: ["test/*.js"],
exclude: [
"debounce.test.js", // hangs runner
"size.test.js", // require('vm').runInNewContext()
"merge.test.js", // failing
],
},
},
{
name: "chalk",
repository: github("chalk/chalk"),
tests: {
style: "ava",
include: ["test/*.js"],
},
},
{
name: "request",
repository: github("request/request"),
tests: {
style: "tape",
include: ["tests/*.js"],
},
},
{
name: "commander",
repository: github("tj/commander.js"),
tests: {
style: "jest",
include: ["tests/*.js"],
},
},
{
name: "express",
repository: github("expressjs/express"),
tests: {
style: "jest",
include: ["test/**/*.js"],
exclude: [
"test/res.sendStatus.js", // https://github.com/oven-sh/bun/issues/887
"test/Route.js", // https://github.com/oven-sh/bun/issues/2030
],
// Most tests fail due to lack of "http2"
disabled: true,
},
},
];
function github(repository: string): string {
return `git@github.com:${repository}.git`;
}

View File

@@ -0,0 +1,92 @@
import type { Package } from "./packages";
import { packages } from "./packages";
import { existsSync, copyFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { globby } from "globby";
for (const pkg of packages) {
try {
await loadPackage(pkg, "tmp");
} catch (error) {
console.error(pkg.name, error);
}
}
async function loadPackage(pkg: Package, cwd?: string): Promise<void> {
await gitClone({
cwd,
repository: pkg.repository,
name: pkg.name,
});
const dir = join(cwd ?? "", pkg.name, pkg.cwd ?? "");
await spawn({
cwd: dir,
cmd: ["bun", "install"],
});
if (!pkg.tests || pkg.tests.style !== "jest") {
return;
}
const files = await globby(pkg.tests.include, {
cwd: dir,
ignore: pkg.tests.exclude ?? [crypto.randomUUID()],
onlyFiles: true,
caseSensitiveMatch: false,
});
if (!files.length) {
throw new Error("No tests found");
}
for (const file of files) {
let path = file;
if (!file.includes(".test.")) {
const ext = path.lastIndexOf(".");
path = file.substring(0, ext) + ".test" + file.substring(ext);
copyFileSync(join(dir, file), join(dir, path));
}
await spawn({
cwd: dir,
cmd: ["bun", "wiptest", path],
});
}
}
type GitCloneOptions = {
repository: string;
cwd?: string;
name?: string;
};
async function gitClone(options: GitCloneOptions): Promise<void> {
const name = options.name ?? dirname(options.repository);
const cwd = options.cwd ?? process.cwd();
const path = join(cwd, name);
if (existsSync(path)) {
await spawn({
cwd: path,
cmd: ["git", "pull"],
});
} else {
const url = `${options.repository}`;
await spawn({
cwd,
cmd: ["git", "clone", "--single-branch", "--depth", "1", url, name],
});
}
}
type SpawnOptions = {
cwd: string;
cmd: string[];
};
async function spawn({ cwd, cmd }: SpawnOptions) {
const { exited } = await Bun.spawn({
cwd,
cmd,
stdout: "inherit",
stderr: "inherit",
});
const exitCode = await exited;
if (exitCode !== 0) {
throw new Error(`"${cmd.join(" ")}" exited with ${exitCode}`);
}
}

View File

@@ -0,0 +1,16 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "node",
"types": ["bun-types"],
"esModuleInterop": true,
"allowJs": true,
"strict": true,
"resolveJsonModule": true
},
"include": [
"src"
]
}

View File

@@ -1,230 +0,0 @@
{
"name": "bun-error",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/prop-types": {
"version": "15.7.5",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz",
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==",
"dev": true
},
"@types/react": {
"version": "17.0.47",
"resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.47.tgz",
"integrity": "sha512-mk0BL8zBinf2ozNr3qPnlu1oyVTYq+4V7WA76RgxUAtf0Em/Wbid38KN6n4abEkvO4xMTBWmnP1FtQzgkEiJoA==",
"dev": true,
"requires": {
"@types/prop-types": "*",
"@types/scheduler": "*",
"csstype": "^3.0.2"
}
},
"@types/scheduler": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
"integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==",
"dev": true
},
"csstype": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.0.tgz",
"integrity": "sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==",
"dev": true
},
"esbuild": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.48.tgz",
"integrity": "sha512-w6N1Yn5MtqK2U1/WZTX9ZqUVb8IOLZkZ5AdHkT6x3cHDMVsYWC7WPdiLmx19w3i4Rwzy5LqsEMtVihG3e4rFzA==",
"requires": {
"esbuild-android-64": "0.14.48",
"esbuild-android-arm64": "0.14.48",
"esbuild-darwin-64": "0.14.48",
"esbuild-darwin-arm64": "0.14.48",
"esbuild-freebsd-64": "0.14.48",
"esbuild-freebsd-arm64": "0.14.48",
"esbuild-linux-32": "0.14.48",
"esbuild-linux-64": "0.14.48",
"esbuild-linux-arm": "0.14.48",
"esbuild-linux-arm64": "0.14.48",
"esbuild-linux-mips64le": "0.14.48",
"esbuild-linux-ppc64le": "0.14.48",
"esbuild-linux-riscv64": "0.14.48",
"esbuild-linux-s390x": "0.14.48",
"esbuild-netbsd-64": "0.14.48",
"esbuild-openbsd-64": "0.14.48",
"esbuild-sunos-64": "0.14.48",
"esbuild-windows-32": "0.14.48",
"esbuild-windows-64": "0.14.48",
"esbuild-windows-arm64": "0.14.48"
}
},
"esbuild-android-64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.14.48.tgz",
"integrity": "sha512-3aMjboap/kqwCUpGWIjsk20TtxVoKck8/4Tu19rubh7t5Ra0Yrpg30Mt1QXXlipOazrEceGeWurXKeFJgkPOUg==",
"optional": true
},
"esbuild-android-arm64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.48.tgz",
"integrity": "sha512-vptI3K0wGALiDq+EvRuZotZrJqkYkN5282iAfcffjI5lmGG9G1ta/CIVauhY42MBXwEgDJkweiDcDMRLzBZC4g==",
"optional": true
},
"esbuild-darwin-64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.48.tgz",
"integrity": "sha512-gGQZa4+hab2Va/Zww94YbshLuWteyKGD3+EsVon8EWTWhnHFRm5N9NbALNbwi/7hQ/hM1Zm4FuHg+k6BLsl5UA==",
"optional": true
},
"esbuild-darwin-arm64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.48.tgz",
"integrity": "sha512-bFjnNEXjhZT+IZ8RvRGNJthLWNHV5JkCtuOFOnjvo5pC0sk2/QVk0Qc06g2PV3J0TcU6kaPC3RN9yy9w2PSLEA==",
"optional": true
},
"esbuild-freebsd-64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.48.tgz",
"integrity": "sha512-1NOlwRxmOsnPcWOGTB10JKAkYSb2nue0oM1AfHWunW/mv3wERfJmnYlGzL3UAOIUXZqW8GeA2mv+QGwq7DToqA==",
"optional": true
},
"esbuild-freebsd-arm64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.48.tgz",
"integrity": "sha512-gXqKdO8wabVcYtluAbikDH2jhXp+Klq5oCD5qbVyUG6tFiGhrC9oczKq3vIrrtwcxDQqK6+HDYK8Zrd4bCA9Gw==",
"optional": true
},
"esbuild-linux-32": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.48.tgz",
"integrity": "sha512-ghGyDfS289z/LReZQUuuKq9KlTiTspxL8SITBFQFAFRA/IkIvDpnZnCAKTCjGXAmUqroMQfKJXMxyjJA69c/nQ==",
"optional": true
},
"esbuild-linux-64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.48.tgz",
"integrity": "sha512-vni3p/gppLMVZLghI7oMqbOZdGmLbbKR23XFARKnszCIBpEMEDxOMNIKPmMItQrmH/iJrL1z8Jt2nynY0bE1ug==",
"optional": true
},
"esbuild-linux-arm": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.48.tgz",
"integrity": "sha512-+VfSV7Akh1XUiDNXgqgY1cUP1i2vjI+BmlyXRfVz5AfV3jbpde8JTs5Q9sYgaoq5cWfuKfoZB/QkGOI+QcL1Tw==",
"optional": true
},
"esbuild-linux-arm64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.48.tgz",
"integrity": "sha512-3CFsOlpoxlKPRevEHq8aAntgYGYkE1N9yRYAcPyng/p4Wyx0tPR5SBYsxLKcgPB9mR8chHEhtWYz6EZ+H199Zw==",
"optional": true
},
"esbuild-linux-mips64le": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.48.tgz",
"integrity": "sha512-cs0uOiRlPp6ymknDnjajCgvDMSsLw5mST2UXh+ZIrXTj2Ifyf2aAP3Iw4DiqgnyYLV2O/v/yWBJx+WfmKEpNLA==",
"optional": true
},
"esbuild-linux-ppc64le": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.48.tgz",
"integrity": "sha512-+2F0vJMkuI0Wie/wcSPDCqXvSFEELH7Jubxb7mpWrA/4NpT+/byjxDz0gG6R1WJoeDefcrMfpBx4GFNN1JQorQ==",
"optional": true
},
"esbuild-linux-riscv64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.48.tgz",
"integrity": "sha512-BmaK/GfEE+5F2/QDrIXteFGKnVHGxlnK9MjdVKMTfvtmudjY3k2t8NtlY4qemKSizc+QwyombGWTBDc76rxePA==",
"optional": true
},
"esbuild-linux-s390x": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.48.tgz",
"integrity": "sha512-tndw/0B9jiCL+KWKo0TSMaUm5UWBLsfCKVdbfMlb3d5LeV9WbijZ8Ordia8SAYv38VSJWOEt6eDCdOx8LqkC4g==",
"optional": true
},
"esbuild-netbsd-64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.48.tgz",
"integrity": "sha512-V9hgXfwf/T901Lr1wkOfoevtyNkrxmMcRHyticybBUHookznipMOHoF41Al68QBsqBxnITCEpjjd4yAos7z9Tw==",
"optional": true
},
"esbuild-openbsd-64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.48.tgz",
"integrity": "sha512-+IHf4JcbnnBl4T52egorXMatil/za0awqzg2Vy6FBgPcBpisDWT2sVz/tNdrK9kAqj+GZG/jZdrOkj7wsrNTKA==",
"optional": true
},
"esbuild-sunos-64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.48.tgz",
"integrity": "sha512-77m8bsr5wOpOWbGi9KSqDphcq6dFeJyun8TA+12JW/GAjyfTwVtOnN8DOt6DSPUfEV+ltVMNqtXUeTeMAxl5KA==",
"optional": true
},
"esbuild-windows-32": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.48.tgz",
"integrity": "sha512-EPgRuTPP8vK9maxpTGDe5lSoIBHGKO/AuxDncg5O3NkrPeLNdvvK8oywB0zGaAZXxYWfNNSHskvvDgmfVTguhg==",
"optional": true
},
"esbuild-windows-64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.48.tgz",
"integrity": "sha512-YmpXjdT1q0b8ictSdGwH3M8VCoqPpK1/UArze3X199w6u8hUx3V8BhAi1WjbsfDYRBanVVtduAhh2sirImtAvA==",
"optional": true
},
"esbuild-windows-arm64": {
"version": "0.14.48",
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.48.tgz",
"integrity": "sha512-HHaOMCsCXp0rz5BT2crTka6MPWVno121NKApsGs/OIW5QC0ggC69YMGs1aJct9/9FSUF4A1xNE/cLvgB5svR4g==",
"optional": true
},
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
},
"loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
"requires": {
"js-tokens": "^3.0.0 || ^4.0.0"
}
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
},
"react": {
"version": "17.0.2",
"resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz",
"integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
}
},
"react-dom": {
"version": "17.0.2",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz",
"integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"scheduler": "^0.20.2"
}
},
"scheduler": {
"version": "0.20.2",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz",
"integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
}
}
}
}

6
packages/bun-release/.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
.DS_Store
.env
node_modules
/npm/**/bin
/npm/**/*.js
/npm/**/.npmrc

View File

@@ -0,0 +1,2 @@
@oven:registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=${NPM_TOKEN}

View File

@@ -0,0 +1,15 @@
# bun-release
Scripts that release Bun to npm, Dockerhub, Homebrew, etc.
### Running
```sh
bun run npm # build assets for the latest release
bun run npm -- <release> # build assets for the provided release
bun run npm -- <release> [dry-run|publish] # build and publish assets to npm
```
### Credits
- [esbuild](https://github.com/evanw/esbuild), for its npm scripts which this was largely based off of.

BIN
packages/bun-release/bun.lockb Executable file

Binary file not shown.

View File

@@ -0,0 +1,3 @@
# Bun
This is the macOS arm64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh

View File

@@ -0,0 +1,16 @@
{
"name": "@oven/bun-darwin-aarch64",
"version": "0.5.3",
"description": "This is the macOS arm64 binary for Bun, a fast all-in-one JavaScript runtime.",
"homepage": "https://bun.sh",
"bugs": "https://github.com/oven-sh/issues",
"license": "MIT",
"repository": "https://github.com/oven-sh/bun",
"preferUnplugged": true,
"os": [
"darwin"
],
"cpu": [
"arm64"
]
}

View File

@@ -0,0 +1,5 @@
# Bun
This is the macOS x64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh
_Note: "Baseline" builds are for machines that do not support [AVX2](https://en.wikipedia.org/wiki/Advanced_Vector_Extensions) instructions._

View File

@@ -0,0 +1,16 @@
{
"name": "@oven/bun-darwin-x64-baseline",
"version": "0.5.3",
"description": "This is the macOS x64 binary for Bun, a fast all-in-one JavaScript runtime.",
"homepage": "https://bun.sh",
"bugs": "https://github.com/oven-sh/issues",
"license": "MIT",
"repository": "https://github.com/oven-sh/bun",
"preferUnplugged": true,
"os": [
"darwin"
],
"cpu": [
"x64"
]
}

View File

@@ -0,0 +1,3 @@
# Bun
This is the macOS x64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh

View File

@@ -0,0 +1,16 @@
{
"name": "@oven/bun-darwin-x64",
"version": "0.5.3",
"description": "This is the macOS x64 binary for Bun, a fast all-in-one JavaScript runtime.",
"homepage": "https://bun.sh",
"bugs": "https://github.com/oven-sh/issues",
"license": "MIT",
"repository": "https://github.com/oven-sh/bun",
"preferUnplugged": true,
"os": [
"darwin"
],
"cpu": [
"x64"
]
}

View File

@@ -0,0 +1,3 @@
# Bun
This is the Linux arm64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh

View File

@@ -0,0 +1,16 @@
{
"name": "@oven/bun-linux-aarch64",
"version": "0.5.3",
"description": "This is the Linux arm64 binary for Bun, a fast all-in-one JavaScript runtime.",
"homepage": "https://bun.sh",
"bugs": "https://github.com/oven-sh/issues",
"license": "MIT",
"repository": "https://github.com/oven-sh/bun",
"preferUnplugged": true,
"os": [
"linux"
],
"cpu": [
"arm64"
]
}

View File

@@ -0,0 +1,5 @@
# Bun
This is the Linux x64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh
_Note: "Baseline" builds are for machines that do not support [AVX2](https://en.wikipedia.org/wiki/Advanced_Vector_Extensions) instructions._

View File

@@ -0,0 +1,16 @@
{
"name": "@oven/bun-linux-x64-baseline",
"version": "0.5.3",
"description": "This is the Linux x64 binary for Bun, a fast all-in-one JavaScript runtime.",
"homepage": "https://bun.sh",
"bugs": "https://github.com/oven-sh/issues",
"license": "MIT",
"repository": "https://github.com/oven-sh/bun",
"preferUnplugged": true,
"os": [
"linux"
],
"cpu": [
"x64"
]
}

View File

@@ -0,0 +1,3 @@
# Bun
This is the Linux x64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh

View File

@@ -0,0 +1,16 @@
{
"name": "@oven/bun-linux-x64",
"version": "0.5.3",
"description": "This is the Linux x64 binary for Bun, a fast all-in-one JavaScript runtime.",
"homepage": "https://bun.sh",
"bugs": "https://github.com/oven-sh/issues",
"license": "MIT",
"repository": "https://github.com/oven-sh/bun",
"preferUnplugged": true,
"os": [
"linux"
],
"cpu": [
"x64"
]
}

View File

@@ -0,0 +1,31 @@
# Bun
Bun is a fast all-in-one JavaScript runtime. https://bun.sh
### Install
```sh
npm install -g bun
```
### Upgrade
```sh
bun upgrade
```
### Supported Platforms
- [macOS, arm64 (Apple Silicon)](https://www.npmjs.com/package/@oven/bun-darwin-aarch64)
- [macOS, x64](https://www.npmjs.com/package/@oven/bun-darwin-x64)
- [macOS, x64 (without AVX2 instructions)](https://www.npmjs.com/package/@oven/bun-darwin-x64-baseline)
- [Linux, arm64](https://www.npmjs.com/package/@oven/bun-linux-aarch64)
- [Linux, x64](https://www.npmjs.com/package/@oven/bun-linux-x64)
- [Linux, x64 (without AVX2 instructions)](https://www.npmjs.com/package/@oven/bun-linux-x64-baseline)
- [Windows (using Windows Subsystem for Linux, aka. "WSL")](https://relatablecode.com/how-to-set-up-bun-on-a-windows-machine)
### Future Platforms
- [Windows](https://github.com/oven-sh/bun/issues/43)
- Unix-like variants such as FreeBSD, OpenBSD, etc.
- Android and iOS

View File

@@ -0,0 +1,42 @@
{
"name": "bun",
"version": "0.5.3",
"description": "Bun is a fast all-in-one JavaScript runtime.",
"keywords": [
"bun",
"bun.js",
"node",
"node.js",
"runtime",
"bundler",
"transpiler",
"typescript"
],
"homepage": "https://bun.sh",
"bugs": "https://github.com/oven-sh/issues",
"license": "MIT",
"bin": {
"bun": "bin/bun",
"bunx": "bin/bun"
},
"repository": "https://github.com/oven-sh/bun",
"scripts": {
"postinstall": "node install.js"
},
"optionalDependencies": {
"@oven/bun-darwin-aarch64": "0.5.3",
"@oven/bun-darwin-x64": "0.5.3",
"@oven/bun-darwin-x64-baseline": "0.5.3",
"@oven/bun-linux-aarch64": "0.5.3",
"@oven/bun-linux-x64": "0.5.3",
"@oven/bun-linux-x64-baseline": "0.5.3"
},
"os": [
"darwin",
"linux"
],
"cpu": [
"arm64",
"x64"
]
}

View File

@@ -0,0 +1,19 @@
{
"private": true,
"dependencies": {
"esbuild": "^0.17.3",
"jszip": "^3.10.1",
"octokit": "^2.0.14"
},
"devDependencies": {
"@octokit/types": "^8.1.1",
"bun-types": "^0.4.0",
"prettier": "^2.8.2"
},
"scripts": {
"format": "prettier --write src scripts",
"get-version": "bun scripts/get-version.ts",
"upload-npm": "bun scripts/upload-npm.ts",
"upload-assets": "bun scripts/upload-assets.ts"
}
}

View File

@@ -0,0 +1,5 @@
import { log } from "../src/console";
import { getSemver } from "../src/github";
log(await getSemver(process.argv[2]));
process.exit(0); // HACK

View File

@@ -0,0 +1,13 @@
import { importBun } from "../src/npm/install";
import { execFileSync } from "child_process";
importBun()
.then(bun => {
return execFileSync(bun, process.argv.slice(2), {
stdio: "inherit",
});
})
.catch(error => {
console.error(error);
process.exit(1);
});

View File

@@ -0,0 +1,10 @@
import { importBun, optimizeBun } from "../src/npm/install";
importBun()
.then(path => {
optimizeBun(path);
})
.catch(error => {
console.error(error);
process.exit(1);
});

View File

@@ -0,0 +1,92 @@
import { getRelease, uploadAsset } from "../src/github";
import { fetch } from "../src/fetch";
import { spawn } from "../src/spawn";
import { confirm, exit, log, stdin, warn } from "../src/console";
import { hash, join, rm, tmp, write, basename, blob } from "../src/fs";
const [tag, ...paths] = process.argv.slice(2);
if (!tag) {
exit("Invalid arguments: [tag] [...assets]");
}
const { tag_name, assets } = await getRelease(tag);
log("Release:", tag_name, "\n");
log("Existing assets:\n", ...assets.map(({ name }) => `- ${name}\n`));
log("Updating assets:\n", ...paths.map(path => `+ ${basename(path)}\n`));
await confirm();
log("Hashing assets...\n");
const existing: Map<string, string> = new Map();
for (const { name, browser_download_url } of assets) {
if (name.startsWith("SHASUMS256.txt")) {
continue;
}
const response = await fetch(browser_download_url);
const buffer = Buffer.from(await response.arrayBuffer());
existing.set(name, await hash(buffer));
}
const updated: Map<string, string> = new Map();
for (const path of paths) {
const name = basename(path);
updated.set(name, await hash(path));
}
log(
"Unchanged hashes:\n",
...Array.from(existing.entries())
.filter(([name]) => !updated.has(name))
.map(([name, sha256]) => ` - ${sha256} => ${name}\n`),
);
log("Changed hashes:\n", ...Array.from(updated.entries()).map(([name, sha256]) => ` + ${sha256} => ${name}\n`));
await confirm();
log("Signing assets...\n");
const cwd = tmp();
const path = join(cwd, "SHASUMS256.txt");
const signedPath = `${path}.asc`;
write(
path,
[...Array.from(updated.entries()), ...Array.from(existing.entries()).filter(([name]) => !updated.has(name))]
.sort(([a], [b]) => a.localeCompare(b))
.map(([name, sha256]) => `${sha256} ${name}`)
.join("\n"),
);
const { stdout: keys } = spawn("gpg", ["--list-secret-keys", "--keyid-format", "long"]);
const verifiedKeys = [
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59", // robobun@oven.sh
];
if (!verifiedKeys.find(key => keys.includes(key))) {
warn("Signature is probably wrong, key not found: robobun@oven.sh");
}
const passphrase = await stdin("Passphrase:");
log();
const { exitCode, stdout, stderr } = spawn(
"gpg",
["--pinentry-mode", "loopback", "--passphrase-fd", "0", "--clearsign", "--output", signedPath, path],
{
// @ts-ignore
input: passphrase,
stdout: "inherit",
stderr: "inherit",
},
);
if (exitCode !== 0) {
exit(stdout || stderr);
}
const uploads = [...paths, path, signedPath];
log("Uploading assets:\n", ...uploads.map(path => ` + ${basename(path)}\n`));
await confirm();
for (const path of uploads) {
const name = basename(path);
await uploadAsset(tag_name, name, blob(path));
}
try {
rm(cwd);
} catch {
warn("Failed to cleanup:", cwd, "\n");
}
log("Done");
process.exit(0); // FIXME

View File

@@ -0,0 +1,164 @@
import { join, copy, exists, chmod, write, writeJson } from "../src/fs";
import { fetch } from "../src/fetch";
import { spawn } from "../src/spawn";
import type { Platform } from "../src/platform";
import { platforms } from "../src/platform";
import { getSemver } from "../src/github";
import { getRelease } from "../src/github";
import type { BuildOptions } from "esbuild";
import { buildSync, formatMessagesSync } from "esbuild";
import type { JSZipObject } from "jszip";
import { loadAsync } from "jszip";
import { debug, log, error } from "../src/console";
const module = "bun";
const owner = "@oven";
let version: string;
const [tag, action] = process.argv.slice(2);
await build(tag);
if (action === "publish") {
await publish();
} else if (action === "dry-run") {
await publish(true);
} else if (action) {
throw new Error(`Unknown action: ${action}`);
}
process.exit(0); // HACK
async function build(tag?: string): Promise<void> {
const release = await getRelease(tag);
version = await getSemver(release.tag_name);
await buildRootModule();
for (const platform of platforms) {
await buildModule(release, platform);
}
}
async function publish(dryRun?: boolean): Promise<void> {
const modules = platforms.map(({ bin }) => `${owner}/${bin}`);
modules.push(module);
for (const module of modules) {
publishModule(module, dryRun);
}
}
async function buildRootModule() {
log("Building:", `${module}@${version}`);
const cwd = join("npm", module);
const define = {
version: `"${version}"`,
module: `"${module}"`,
owner: `"${owner}"`,
};
bundle(join("scripts", "npm-postinstall.ts"), join(cwd, "install.js"), {
define,
});
bundle(join("scripts", "npm-exec.ts"), join(cwd, "bin", "bun"), {
define,
banner: {
js: "#!/usr/bin/env node",
},
});
const os = [...new Set(platforms.map(({ os }) => os))];
const cpu = [...new Set(platforms.map(({ arch }) => arch))];
writeJson(join(cwd, "package.json"), {
name: module,
version: version,
scripts: {
postinstall: "node install.js",
},
optionalDependencies: Object.fromEntries(platforms.map(({ bin }) => [`${owner}/${bin}`, version])),
bin: {
bun: "bin/bun",
bunx: "bin/bun",
},
os,
cpu,
});
if (exists(".npmrc")) {
copy(".npmrc", join(cwd, ".npmrc"));
}
}
async function buildModule(
release: Awaited<ReturnType<typeof getRelease>>,
{ bin, exe, os, arch }: Platform,
): Promise<void> {
const module = `${owner}/${bin}`;
log("Building:", `${module}@${version}`);
const asset = release.assets.find(({ name }) => name === `${bin}.zip`);
if (!asset) {
error(`No asset found: ${bin}`);
return;
}
const bun = await extractFromZip(asset.browser_download_url, `${bin}/bun`);
const cwd = join("npm", module);
write(join(cwd, exe), await bun.async("arraybuffer"));
chmod(join(cwd, exe), 0o755);
writeJson(join(cwd, "package.json"), {
name: module,
version: version,
preferUnplugged: true,
os: [os],
cpu: [arch],
});
if (exists(".npmrc")) {
copy(".npmrc", join(cwd, ".npmrc"));
}
}
function publishModule(name: string, dryRun?: boolean): void {
log(dryRun ? "Dry-run Publishing:" : "Publishing:", `${name}@${version}`);
const { exitCode, stdout, stderr } = spawn(
"npm",
[
"publish",
"--access",
"public",
"--tag",
version.includes("canary") ? "canary" : "latest",
...(dryRun ? ["--dry-run"] : []),
],
{
cwd: join("npm", name),
},
);
if (exitCode === 0) {
error(stderr || stdout);
}
}
async function extractFromZip(url: string, filename: string): Promise<JSZipObject> {
const response = await fetch(url);
const buffer = await response.arrayBuffer();
const zip = await loadAsync(buffer);
for (const [name, file] of Object.entries(zip.files)) {
if (!file.dir && name.startsWith(filename)) {
return file;
}
}
debug("Found files:", Object.keys(zip.files));
throw new Error(`File not found: ${filename}`);
}
function bundle(src: string, dst: string, options: BuildOptions = {}): void {
const { errors } = buildSync({
bundle: true,
treeShaking: true,
keepNames: true,
minifySyntax: true,
pure: ["console.debug"],
platform: "node",
target: "es6",
format: "cjs",
entryPoints: [src],
outfile: dst,
...options,
});
if (errors?.length) {
const messages = formatMessagesSync(errors, { kind: "error" });
throw new Error(messages.join("\n"));
}
}

View File

@@ -0,0 +1,75 @@
import { isatty } from "tty";
import { createInterface } from "readline";
export const isAction = !!process.env["GITHUB_ACTION"];
export const isDebug =
process.env["DEBUG"] === "1" || process.env["LOG_LEVEL"] === "debug" || process.env["RUNNER_DEBUG"] === "1";
export function debug(...message: any[]): void {
if (isAction) {
console.debug("::debug::", ...message);
} else if (isDebug) {
console.debug(...message);
}
}
export function log(...message: any[]): void {
console.log(...message);
}
export function warn(...message: any[]): void {
if (isAction) {
console.warn("::warning::", ...message);
} else {
console.warn(...message);
}
}
export function error(...message: any[]): void {
if (isAction) {
console.error("::error::", ...message);
} else {
console.error(...message);
}
}
export function exit(...message: any[]): never {
error(...message);
process.exit(1);
}
export function isTty(): boolean {
return isatty(process.stdout.fd);
}
export async function stdin(question: string): Promise<string> {
if (isTty()) {
return prompt(question) || "";
}
const reader = createInterface({
input: process.stdin,
terminal: false,
});
let buffer = "";
reader.on("line", line => {
buffer += line;
});
return new Promise(resolve => {
reader.once("close", () => resolve(buffer));
});
}
export async function confirm(message?: string): Promise<void> {
if (!isTty()) {
return;
}
const question = message ?? "Confirm?";
switch (prompt(`${question} [y/n]`)) {
case "y":
case "Y":
log();
return;
}
exit();
}

View File

@@ -0,0 +1,70 @@
import { debug, isDebug } from "./console";
export const fetch = "fetch" in globalThis ? webFetch : nodeFetch;
type Options = RequestInit & { assert?: boolean };
async function webFetch(url: string, options: Options = {}): Promise<Response> {
debug("fetch request", url, options);
const response = await globalThis.fetch(url, options, { verbose: isDebug });
debug("fetch response", response);
if (options?.assert !== false && !isOk(response.status)) {
try {
debug(await response.text());
} catch {}
throw new Error(`${response.status}: ${url}`);
}
return response;
}
async function nodeFetch(url: string, options: Options = {}): Promise<Response> {
const { get } = await import("node:http");
return new Promise((resolve, reject) => {
get(url, response => {
debug("http.get", url, response.statusCode);
const status = response.statusCode ?? 501;
if (response.headers.location && isRedirect(status)) {
return nodeFetch(url).then(resolve, reject);
}
if (options?.assert !== false && !isOk(status)) {
return reject(new Error(`${status}: ${url}`));
}
const body: Buffer[] = [];
response.on("data", chunk => {
body.push(chunk);
});
response.on("end", () => {
resolve({
ok: isOk(status),
status,
async arrayBuffer() {
return Buffer.concat(body).buffer as ArrayBuffer;
},
async text() {
return Buffer.concat(body).toString("utf-8");
},
async json() {
const text = Buffer.concat(body).toString("utf-8");
return JSON.parse(text);
},
} as Response);
});
}).on("error", reject);
});
}
function isOk(status: number): boolean {
return status >= 200 && status <= 204;
}
function isRedirect(status: number): boolean {
switch (status) {
case 301: // Moved Permanently
case 308: // Permanent Redirect
case 302: // Found
case 307: // Temporary Redirect
case 303: // See Other
return true;
}
return false;
}

View File

@@ -0,0 +1,159 @@
import path from "path";
import fs from "fs";
import os from "os";
import crypto from "crypto";
import { debug } from "./console";
export function join(...paths: (string | string[])[]): string {
return path.join(...paths.flat(2));
}
export function basename(...paths: (string | string[])[]): string {
return path.basename(join(...paths));
}
export function tmp(): string {
const tmpdir = process.env["RUNNER_TEMP"] ?? os.tmpdir();
const dir = fs.mkdtempSync(join(tmpdir, "bun-"));
debug("tmp", dir);
return dir;
}
export function rm(path: string): void {
debug("rm", path);
try {
fs.rmSync(path, { recursive: true });
return;
} catch (error) {
debug("fs.rmSync failed", error);
// Did not exist before Node.js v14.
// Attempt again with older, slower implementation.
}
let stats: fs.Stats;
try {
stats = fs.lstatSync(path);
} catch (error) {
debug("fs.lstatSync failed", error);
// The file was likely deleted, so return early.
return;
}
if (!stats.isDirectory()) {
fs.unlinkSync(path);
return;
}
try {
fs.rmdirSync(path, { recursive: true });
return;
} catch (error) {
debug("fs.rmdirSync failed", error);
// Recursive flag did not exist before Node.js X.
// Attempt again with older, slower implementation.
}
for (const filename of fs.readdirSync(path)) {
rm(join(path, filename));
}
fs.rmdirSync(path);
}
export function rename(path: string, newPath: string): void {
debug("rename", path, newPath);
try {
fs.renameSync(path, newPath);
return;
} catch (error) {
debug("fs.renameSync failed", error);
// If there is an error, delete the new path and try again.
}
try {
rm(newPath);
} catch (error) {
debug("rm failed", error);
// The path could have been deleted already.
}
fs.renameSync(path, newPath);
}
export function write(dst: string, content: string | ArrayBuffer | ArrayBufferView): void {
debug("write", dst);
try {
fs.writeFileSync(dst, content);
return;
} catch (error) {
debug("fs.writeFileSync failed", error);
// If there is an error, ensure the parent directory
// exists and try again.
try {
fs.mkdirSync(path.dirname(dst), { recursive: true });
} catch (error) {
debug("fs.mkdirSync failed", error);
// The directory could have been created already.
}
fs.writeFileSync(dst, content);
}
}
export function writeJson(path: string, json: object, force?: boolean): void {
let value = json;
if (!force && exists(path)) {
try {
const existing = JSON.parse(read(path));
value = {
...existing,
...json,
};
} catch {
value = json;
}
}
write(path, `${JSON.stringify(value, undefined, 2)}\n`);
}
export function read(path: string): string {
debug("read", path);
return fs.readFileSync(path, "utf-8");
}
export function blob(path: string): Blob {
debug("blob", path);
if ("Bun" in globalThis) {
return Bun.file(path);
}
const buffer = fs.readFileSync(path);
return new Blob([buffer], {
type: path.endsWith(".zip") ? "application/zip" : path.endsWith(".txt") ? "text/plain" : "application/octet-stream",
});
}
export function hash(content: string | crypto.BinaryLike): string {
debug("hash", content);
return crypto
.createHash("sha256")
.update(typeof content === "string" ? fs.readFileSync(content) : content)
.digest("hex");
}
export function chmod(path: string, mode: fs.Mode): void {
debug("chmod", path, mode);
fs.chmodSync(path, mode);
}
export function copy(path: string, newPath: string): void {
debug("copy", path, newPath);
try {
fs.copyFileSync(path, newPath);
return;
} catch (error) {
debug("fs.copyFileSync failed", error);
}
write(newPath, read(path));
}
export function exists(path: string): boolean {
debug("exists", path);
try {
return fs.existsSync(path);
} catch (error) {
debug("fs.existsSync failed", error);
}
return false;
}

View File

@@ -0,0 +1,120 @@
import type { Endpoints, RequestParameters, Route } from "@octokit/types";
import { Octokit } from "octokit";
import { fetch } from "./fetch";
import { debug, log, warn, error } from "./console";
const [owner, repo] = process.env["GITHUB_REPOSITORY"]?.split("/") ?? ["oven-sh", "bun"];
const octokit = new Octokit({
auth: process.env["GITHUB_TOKEN"],
request: {
fetch,
},
log: {
debug,
info: log,
warn,
error,
},
});
export async function github<R extends Route>(
url: R | keyof Endpoints,
options?: Omit<
R extends keyof Endpoints ? Endpoints[R]["parameters"] & RequestParameters : RequestParameters,
"owner" | "repo"
>,
): Promise<R extends keyof Endpoints ? Endpoints[R]["response"]["data"] : unknown> {
// @ts-ignore
const { data } = await octokit.request(url, {
owner,
repo,
...options,
});
return data;
}
export async function getRelease(tag?: string) {
if (!tag) {
return github("GET /repos/{owner}/{repo}/releases/latest");
}
return github("GET /repos/{owner}/{repo}/releases/tags/{tag}", {
tag: formatTag(tag),
});
}
export async function uploadAsset(tag: string, name: string, blob: Blob) {
const release = await getRelease(tag);
const asset = release.assets.find(asset => asset.name === name);
// Github requires that existing assets are deleted before uploading
// a new asset, but does not provide a rename or re-upload API?!?
if (asset) {
await github("DELETE /repos/{owner}/{repo}/releases/assets/{asset_id}", {
asset_id: asset.id,
});
}
return github("POST {origin}/repos/{owner}/{repo}/releases/{release_id}/assets{?name,label}", {
baseUrl: "https://uploads.github.com",
release_id: release.id,
name,
headers: {
"content-type": blob.type,
"content-length": blob.size,
},
data: Buffer.from(await blob.arrayBuffer()),
});
}
export async function downloadAsset(tag: string, name: string): Promise<Blob> {
const release = await getRelease(tag);
const asset = release.assets.find(asset => asset.name === name);
if (!asset) {
throw new Error(`Asset not found: ${name}`);
}
const response = await fetch(asset.browser_download_url);
return response.blob();
}
export async function getSha(tag: string, format?: "short" | "long") {
const ref = formatTag(tag);
const {
object: { sha },
} = await github("GET /repos/{owner}/{repo}/git/ref/{ref}", {
ref: ref === "canary" ? "heads/main" : `tags/${ref}`,
});
return format === "short" ? sha.substring(0, 7) : sha;
}
export async function getBuild(): Promise<number> {
const date = new Date().toISOString().split("T")[0].replace(/-/g, "");
const response = await fetch("https://registry.npmjs.org/-/package/bun/dist-tags");
const { canary }: { canary: string } = await response.json();
if (!canary.includes(date)) {
return 1;
}
const match = /canary.[0-9]{8}\.([0-9]+)+?/.exec(canary);
return match ? 1 + parseInt(match[1]) : 1;
}
export async function getSemver(tag?: string, build?: number): Promise<string> {
const { tag_name } = await getRelease(tag);
if (tag_name !== "canary") {
return tag_name.replace("bun-v", "");
}
if (build === undefined) {
build = await getBuild();
}
const sha = await getSha(tag_name, "short");
const date = new Date().toISOString().split("T")[0].replace(/-/g, "");
return `${Bun.version}-canary.${date}.${build}+${sha}`;
}
export function formatTag(tag: string): string {
if (tag === "canary" || tag.startsWith("bun-v")) {
return tag;
}
if (tag.startsWith("v")) {
return tag.slice(1);
}
return `bun-v${tag}`;
}

View File

@@ -0,0 +1,144 @@
import { fetch } from "../fetch";
import { spawn } from "../spawn";
import { chmod, join, rename, rm, tmp, write } from "../fs";
import { unzipSync } from "zlib";
import type { Platform } from "../platform";
import { os, arch, supportedPlatforms } from "../platform";
import { debug, error } from "../console";
declare const version: string;
declare const module: string;
declare const owner: string;
export async function importBun(): Promise<string> {
if (!supportedPlatforms.length) {
throw new Error(`Unsupported platform: ${os} ${arch}`);
}
for (const platform of supportedPlatforms) {
try {
return await requireBun(platform);
} catch (error) {
debug("requireBun failed", error);
}
}
throw new Error(`Failed to install package "${module}"`);
}
async function requireBun(platform: Platform): Promise<string> {
const module = `${owner}/${platform.bin}`;
function resolveBun() {
const exe = require.resolve(join(module, platform.exe));
const { exitCode, stderr, stdout } = spawn(exe, ["--version"]);
if (exitCode === 0) {
return exe;
}
throw new Error(stderr || stdout);
}
try {
return resolveBun();
} catch (cause) {
debug("resolveBun failed", cause);
error(
`Failed to find package "${module}".`,
`You may have used the "--no-optional" flag when running "npm install".`,
);
}
const cwd = join("node_modules", module);
try {
installBun(platform, cwd);
} catch (cause) {
debug("installBun failed", cause);
error(`Failed to install package "${module}" using "npm install".`, cause);
try {
await downloadBun(platform, cwd);
} catch (cause) {
debug("downloadBun failed", cause);
error(`Failed to download package "${module}" from "registry.npmjs.org".`, cause);
}
}
return resolveBun();
}
function installBun(platform: Platform, dst: string): void {
const module = `${owner}/${platform.bin}`;
const cwd = tmp();
try {
write(join(cwd, "package.json"), "{}");
const { exitCode } = spawn(
"npm",
["install", "--loglevel=error", "--prefer-offline", "--no-audit", "--progress=false", `${module}@${version}`],
{
cwd,
stdio: "pipe",
env: {
...process.env,
npm_config_global: undefined,
},
},
);
if (exitCode === 0) {
rename(join(cwd, "node_modules", module), dst);
}
} finally {
try {
rm(cwd);
} catch (error) {
debug("rm failed", error);
// There is nothing to do if the directory cannot be cleaned up.
}
}
}
async function downloadBun(platform: Platform, dst: string): Promise<void> {
const response = await fetch(`https://registry.npmjs.org/${owner}/${platform.bin}/-/${platform.bin}-${version}.tgz`);
const tgz = await response.arrayBuffer();
let buffer: Buffer;
try {
buffer = unzipSync(tgz);
} catch (cause) {
throw new Error("Invalid gzip data", { cause });
}
function str(i: number, n: number): string {
return String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
}
let offset = 0;
while (offset < buffer.length) {
const name = str(offset, 100).replace("package/", "");
const size = parseInt(str(offset + 124, 12), 8);
offset += 512;
if (!isNaN(size)) {
write(join(dst, name), buffer.subarray(offset, offset + size));
if (name === platform.exe) {
try {
chmod(join(dst, name), 0o755);
} catch (error) {
debug("chmod failed", error);
}
}
offset += (size + 511) & ~511;
}
}
}
export function optimizeBun(path: string): void {
if (os === "win32") {
throw new Error(
"You must use Windows Subsystem for Linux, aka. WSL, to run bun. Learn more: https://learn.microsoft.com/en-us/windows/wsl/install",
);
}
const { npm_config_user_agent } = process.env;
if (npm_config_user_agent && /\byarn\//.test(npm_config_user_agent)) {
throw new Error(
"Yarn does not support bun, because it does not allow linking to binaries. To use bun, install using the following command: curl -fsSL https://bun.sh/install | bash",
);
}
try {
rename(path, join(__dirname, "bin", "bun"));
return;
} catch (error) {
debug("optimizeBun failed", error);
}
throw new Error(
"Your package manager doesn't seem to support bun. To use bun, install using the following command: curl -fsSL https://bun.sh/install | bash",
);
}

View File

@@ -0,0 +1,91 @@
import { spawn } from "./spawn";
import { read } from "./fs";
import { debug } from "./console";
export const os = process.platform;
export const arch = os === "darwin" && process.arch === "x64" && isRosetta2() ? "arm64" : process.arch;
export const avx2 = (arch === "x64" && os === "linux" && isLinuxAVX2()) || (os === "darwin" && isDarwinAVX2());
export type Platform = {
os: string;
arch: string;
avx2?: boolean;
bin: string;
exe: string;
};
export const platforms: Platform[] = [
{
os: "darwin",
arch: "arm64",
bin: "bun-darwin-aarch64",
exe: "bin/bun",
},
{
os: "darwin",
arch: "x64",
avx2: true,
bin: "bun-darwin-x64",
exe: "bin/bun",
},
{
os: "darwin",
arch: "x64",
bin: "bun-darwin-x64-baseline",
exe: "bin/bun",
},
{
os: "linux",
arch: "arm64",
bin: "bun-linux-aarch64",
exe: "bin/bun",
},
{
os: "linux",
arch: "x64",
avx2: true,
bin: "bun-linux-x64",
exe: "bin/bun",
},
{
os: "linux",
arch: "x64",
bin: "bun-linux-x64-baseline",
exe: "bin/bun",
},
];
export const supportedPlatforms: Platform[] = platforms
.filter(platform => platform.os === os && platform.arch === arch && (!platform.avx2 || avx2))
.sort((a, b) => (a.avx2 === b.avx2 ? 0 : a.avx2 ? -1 : 1));
function isLinuxAVX2(): boolean {
try {
return read("/proc/cpuinfo").includes("avx2");
} catch (error) {
debug("isLinuxAVX2 failed", error);
return false;
}
}
function isDarwinAVX2(): boolean {
try {
const { exitCode, stdout } = spawn("sysctl", ["-n", "machdep.cpu"]);
return exitCode === 0 && stdout.includes("AVX2");
} catch (error) {
debug("isDarwinAVX2 failed", error);
return false;
}
}
function isRosetta2(): boolean {
try {
const { exitCode, stdout } = spawn("sysctl", ["-n", "sysctl.proc_translated"]);
return exitCode === 0 && stdout.includes("1");
} catch (error) {
debug("isRosetta2 failed", error);
return false;
}
}

View File

@@ -0,0 +1,24 @@
import child_process from "child_process";
import { debug } from "./console";
export function spawn(
cmd: string,
args: string[],
options: child_process.SpawnOptions = {},
): {
exitCode: number;
stdout: string;
stderr: string;
} {
debug("spawn", [cmd, ...args].join(" "));
const { status, stdout, stderr } = child_process.spawnSync(cmd, args, {
stdio: "pipe",
encoding: "utf-8",
...options,
});
return {
exitCode: status ?? 1,
stdout,
stderr,
};
}

View File

@@ -0,0 +1,17 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "node",
"types": ["bun-types"],
"esModuleInterop": true,
"allowJs": true,
"strict": true,
"resolveJsonModule": true
},
"include": [
"src",
"scripts"
]
}

3
packages/bun-test/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
.DS_Store
.env
node_modules

View File

@@ -0,0 +1,3 @@
# bun-test
Scripts to run Bun's tests using `bun wiptest`.

BIN
packages/bun-test/bun.lockb Executable file

Binary file not shown.

View File

@@ -0,0 +1,13 @@
{
"private": true,
"dependencies": {
"@actions/core": "^1.10.0"
},
"devDependencies": {
"bun-types": "canary",
"prettier": "^2.8.2"
},
"scripts": {
"test": "bun run src/runner.ts"
}
}

View File

@@ -0,0 +1,86 @@
import { spawn } from "bun";
import { readdirSync } from "node:fs";
import { resolve } from "node:path";
import * as action from "@actions/core";
const cwd = resolve("../..");
const isAction = !!process.env["GITHUB_ACTION"];
const errorPattern = /error: ([\S\s]*?)(?=\n.*?at (\/.*):(\d+):(\d+))/mgi;
function* findTests(dir: string, query?: string): Generator<string> {
for (const entry of readdirSync(resolve(dir), { encoding: "utf-8", withFileTypes: true })) {
const path = resolve(dir, entry.name);
if (entry.isDirectory()) {
yield* findTests(path, query);
} else if (entry.isFile() && entry.name.includes(".test.")) {
yield path;
}
}
}
async function runTest(path: string): Promise<void> {
const name = path.replace(cwd, "").slice(1);
const runner = await spawn({
cwd,
cmd: ["bun", "wiptest", path],
stdout: "pipe",
stderr: "pipe",
});
const exitCode = await Promise.race([
new Promise((resolve) => {
setTimeout(() => {
runner.kill();
resolve(124); // Timed Out
}, 60_000);
}),
runner.exited,
]);
if (isAction) {
const prefix = exitCode === 0
? "PASS"
: `FAIL (exit code ${exitCode})`;
action.startGroup(`${prefix} - ${name}`);
}
for (const stdout of [runner.stdout, runner.stderr]) {
if (!stdout) {
continue;
}
const reader = stdout.getReader();
while (true) {
const { value, done } = await reader.read();
if (value) {
console.write(value);
if (isAction) {
findErrors(value);
}
}
if (done) {
break;
}
}
}
if (isAction) {
action.endGroup();
}
}
let failed = false;
function findErrors(data: Uint8Array): void {
const text = new TextDecoder().decode(data);
for (const [message, _, path, line, col] of text.matchAll(errorPattern)) {
failed = true;
action.error(message, {
file: path.replace(cwd, "").slice(1),
startLine: parseInt(line),
startColumn: parseInt(col),
});
}
}
const tests = [];
for (const path of findTests(resolve(cwd, "test/bun.js"))) {
tests.push(runTest(path).catch(console.error));
}
await Promise.allSettled(tests);
process.exit(failed ? 1 : 0);

View File

@@ -0,0 +1,16 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "node",
"types": ["bun-types"],
"esModuleInterop": true,
"allowJs": true,
"strict": true,
"resolveJsonModule": true
},
"include": [
"src"
]
}

View File

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

View File

@@ -22,10 +22,10 @@ Add this to your `tsconfig.json` or `jsconfig.json`:
```jsonc
{
"compilerOptions": {
"lib": ["esnext"],
"module": "esnext",
"target": "esnext",
"moduleResolution": "node",
"lib": ["ESNext"],
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "Node",
// "bun-types" is the important part
"types": ["bun-types"]
}

View File

@@ -411,22 +411,22 @@ declare module "bun" {
* ## Example
*
* ```js
* const {address} = await Bun.dns.lookup('example.com');
* const [{ address }] = await Bun.dns.lookup('example.com');
* ```
*
* ### Filter results to IPv4:
*
* ```js
* import {dns} from 'bun';
* const {address} = await dns.lookup('example.com', {family: 4});
* import { dns } from 'bun';
* const [{ address }] = await dns.lookup('example.com', {family: 4});
* console.log(address); // "123.122.22.126"
* ```
*
* ### Filter results to IPv6:
*
* ```js
* import {dns} from 'bun';
* const {address} = await dns.lookup('example.com', {family: 6});
* import { dns } from 'bun';
* const [{ address }] = await dns.lookup('example.com', {family: 6});
* console.log(address); // "2001:db8::1"
* ```
*
@@ -439,8 +439,8 @@ declare module "bun" {
*
* To customize the DNS resolver, pass a `backend` option to `dns.lookup`:
* ```js
* import {dns} from 'bun';
* const {address} = await dns.lookup('example.com', {backend: 'getaddrinfo'});
* import { dns } from 'bun';
* const [{ address }] = await dns.lookup('example.com', {backend: 'getaddrinfo'});
* console.log(address); // "19.42.52.62"
* ```
*/
@@ -767,7 +767,7 @@ declare module "bun" {
* const query = UserQuery;
* ```
*/
macros?: MacroMap;
macro?: MacroMap;
autoImportJSX?: boolean;
allowBunRuntime?: boolean;
@@ -1592,11 +1592,12 @@ declare module "bun" {
/**
* Stop listening to prevent new connections from being accepted.
*
* It does not close existing connections.
* By default, it does not cancel in-flight requests or websockets. That means it may take some time before all network activity stops.
*
* It may take a second or two to actually stop.
* @param closeActiveConnections Immediately terminate in-flight requests, websockets, and stop accepting new connections.
* @default false
*/
stop(): void;
stop(closeActiveConnections?: boolean): void;
/**
* Update the `fetch` and `error` handlers without restarting the server.
@@ -1784,7 +1785,7 @@ declare module "bun" {
*
*/
// tslint:disable-next-line:unified-signatures
export function file(path: string, options?: BlobPropertyBag): FileBlob;
export function file(path: string | URL, options?: BlobPropertyBag): FileBlob;
/**
* `Blob` that leverages the fastest system calls available to operate on files.
@@ -2150,6 +2151,40 @@ declare module "bun" {
static readonly algorithms: SupportedCryptoAlgorithms[];
}
/**
* Resolve a `Promise` after milliseconds. This is like
* {@link setTimeout} except it returns a `Promise`.
*
* @param ms milliseconds to delay resolving the promise. This is a minimum
* number. It may take longer. If a {@link Date} is passed, it will sleep until the
* {@link Date} is reached.
*
* @example
* ## Sleep for 1 second
* ```ts
* import { sleep } from "bun";
*
* await sleep(1000);
* ```
* ## Sleep for 10 milliseconds
* ```ts
* await Bun.sleep(10);
* ```
* ## Sleep until `Date`
*
* ```ts
* const target = new Date();
* target.setSeconds(target.getSeconds() + 1);
* await Bun.sleep(target);
* ```
* Internally, `Bun.sleep` is the equivalent of
* ```ts
* await new Promise((resolve) => setTimeout(resolve, ms));
* ```
* As always, you can use `Bun.sleep` or the imported `sleep` function interchangeably.
*/
export function sleep(ms: number | Date): Promise<void>;
/**
* Sleep the thread for a given number of milliseconds
*
@@ -2741,7 +2776,7 @@ declare module "bun" {
}
interface SocketListener<Options extends SocketOptions = SocketOptions> {
stop(): void;
stop(closeActiveConnections?: boolean): void;
ref(): void;
unref(): void;
reload(options: Pick<Partial<Options>, "socket">): void;
@@ -2760,11 +2795,26 @@ declare module "bun" {
interface TCPSocket extends Socket {}
interface TLSSocket extends Socket {}
interface SocketHandler<Data = unknown> {
type BinaryTypeList = {
arraybuffer: ArrayBuffer;
buffer: Buffer;
uint8array: Uint8Array;
// TODO: DataView
// dataview: DataView;
};
type BinaryType = keyof BinaryTypeList;
interface SocketHandler<
Data = unknown,
DataBinaryType extends BinaryType = "buffer",
> {
open(socket: Socket<Data>): void | Promise<void>;
close?(socket: Socket<Data>): void | Promise<void>;
error?(socket: Socket<Data>, error: Error): void | Promise<void>;
data?(socket: Socket<Data>, data: BufferSource): void | Promise<void>;
data?(
socket: Socket<Data>,
data: BinaryTypeList[DataBinaryType],
): void | Promise<void>;
drain?(socket: Socket<Data>): void | Promise<void>;
/**
@@ -2786,7 +2836,24 @@ declare module "bun" {
* When `connectError` is not specified, the rejected promise will be added
* to the promise rejection queue.
*/
connectError?(error: Error): void | Promise<void>;
connectError?(socket: Socket<Data>, error: Error): void | Promise<void>;
/**
* Choose what `ArrayBufferView` is returned in the {@link SocketHandler.data} callback.
*
* @default "buffer"
*
* @remarks
* This lets you select the desired binary type for the `data` callback.
* It's a small performance optimization to let you avoid creating extra
* ArrayBufferView objects when possible.
*
* Bun originally defaulted to `Uint8Array` but when dealing with network
* data, it's more useful to be able to directly read from the bytes which
* `Buffer` allows.
*
*/
binaryType?: BinaryType;
}
interface SocketOptions<Data = unknown> {
@@ -3082,6 +3149,7 @@ declare module "bun" {
* ```
*/
readonly params: Record<string, string>;
readonly filePath: string;
readonly pathname: string;
readonly query: Record<string, string>;
readonly name: string;

Binary file not shown.

148
packages/bun-types/console.d.ts vendored Normal file
View File

@@ -0,0 +1,148 @@
/**
* The `console` module provides a simple debugging console that is similar to the
* JavaScript console mechanism provided by web browsers.
*
* The module exports two specific components:
*
* * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
*
* _**Warning**_: The global console object's methods are neither consistently
* synchronous like the browser APIs they resemble, nor are they consistently
* asynchronous like all other Node.js streams. See the `note on process I/O` for
* more information.
*
* Example using the global `console`:
*
* ```js
* console.log('hello world');
* // Prints: hello world, to stdout
* console.log('hello %s', 'world');
* // Prints: hello world, to stdout
* console.error(new Error('Whoops, something bad happened'));
* // Prints error message and stack trace to stderr:
* // Error: Whoops, something bad happened
* // at [eval]:5:15
* // at Script.runInThisContext (node:vm:132:18)
* // at Object.runInThisContext (node:vm:309:38)
* // at node:internal/process/execution:77:19
* // at [eval]-wrapper:6:22
* // at evalScript (node:internal/process/execution:76:60)
* // at node:internal/main/eval_string:23:3
*
* const name = 'Will Robinson';
* console.warn(`Danger ${name}! Danger!`);
* // Prints: Danger Will Robinson! Danger!, to stderr
* ```
*
* Example using the `Console` class:
*
* ```js
* const out = getStreamSomehow();
* const err = getStreamSomehow();
* const myConsole = new console.Console(out, err);
*
* myConsole.log('hello world');
* // Prints: hello world, to out
* myConsole.log('hello %s', 'world');
* // Prints: hello world, to out
* myConsole.error(new Error('Whoops, something bad happened'));
* // Prints: [Error: Whoops, something bad happened], to err
*
* const name = 'Will Robinson';
* myConsole.warn(`Danger ${name}! Danger!`);
* // Prints: Danger Will Robinson! Danger!, to err
* ```
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/console.js)
*/
declare module "console" {
import console = require("node:console");
export = console;
}
declare module "node:console" {
// import { InspectOptions } from "node:util";
// global {
/**
* The `console` module provides a simple debugging console that is similar to the
* JavaScript console mechanism provided by web browsers.
*
* The module exports two specific components:
*
* * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
*
* _**Warning**_: The global console object's methods are neither consistently
* synchronous like the browser APIs they resemble, nor are they consistently
* asynchronous like all other Node.js streams. See the `note on process I/O` for
* more information.
*
* Example using the global `console`:
*
* ```js
* console.log('hello world');
* // Prints: hello world, to stdout
* console.log('hello %s', 'world');
* // Prints: hello world, to stdout
* console.error(new Error('Whoops, something bad happened'));
* // Prints error message and stack trace to stderr:
* // Error: Whoops, something bad happened
* // at [eval]:5:15
* // at Script.runInThisContext (node:vm:132:18)
* // at Object.runInThisContext (node:vm:309:38)
* // at node:internal/process/execution:77:19
* // at [eval]-wrapper:6:22
* // at evalScript (node:internal/process/execution:76:60)
* // at node:internal/main/eval_string:23:3
*
* const name = 'Will Robinson';
* console.warn(`Danger ${name}! Danger!`);
* // Prints: Danger Will Robinson! Danger!, to stderr
* ```
*
* Example using the `Console` class:
*
* ```js
* const out = getStreamSomehow();
* const err = getStreamSomehow();
* const myConsole = new console.Console(out, err);
*
* myConsole.log('hello world');
* // Prints: hello world, to out
* myConsole.log('hello %s', 'world');
* // Prints: hello world, to out
* myConsole.error(new Error('Whoops, something bad happened'));
* // Prints: [Error: Whoops, something bad happened], to err
*
* const name = 'Will Robinson';
* myConsole.warn(`Danger ${name}! Danger!`);
* // Prints: Danger Will Robinson! Danger!, to err
* ```
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/console.js)
*/
// import {Writable} from "node:stream";
// namespace console {
// interface ConsoleConstructorOptions {
// stdout: Writable;
// stderr?: Writable | undefined;
// ignoreErrors?: boolean | undefined;
// colorMode?: boolean | "auto" | undefined;
// inspectOptions?: InspectOptions | undefined;
// /**
// * Set group indentation
// * @default 2
// */
// groupIndentation?: number | undefined;
// }
// interface ConsoleConstructor {
// prototype: Console;
// new (stdout: Writable, stderr?: Writable, ignoreErrors?: boolean): Console;
// new (options: ConsoleConstructorOptions): Console;
// }
// }
// }
// const console: Console;
export = console;
}

View File

@@ -318,127 +318,112 @@ declare module "dns" {
hostname: string,
callback: (err: ErrnoException | null, addresses: string[]) => void,
): void;
// export function resolve(
// hostname: string,
// rrtype: "A",
// callback: (err: ErrnoException | null, addresses: string[]) => void,
// ): void;
// export function resolve(
// hostname: string,
// rrtype: "AAAA",
// callback: (err: ErrnoException | null, addresses: string[]) => void,
// ): void;
// export function resolve(
// hostname: string,
// rrtype: "ANY",
// callback: (
// err: ErrnoException | null,
// addresses: AnyRecord[],
// ) => void,
// ): void;
// export function resolve(
// hostname: string,
// rrtype: "CNAME",
// callback: (err: ErrnoException | null, addresses: string[]) => void,
// ): void;
// export function resolve(
// hostname: string,
// rrtype: "MX",
// callback: (
// err: ErrnoException | null,
// addresses: MxRecord[],
// ) => void,
// ): void;
// export function resolve(
// hostname: string,
// rrtype: "NAPTR",
// callback: (
// err: ErrnoException | null,
// addresses: NaptrRecord[],
// ) => void,
// ): void;
// export function resolve(
// hostname: string,
// rrtype: "NS",
// callback: (err: ErrnoException | null, addresses: string[]) => void,
// ): void;
// export function resolve(
// hostname: string,
// rrtype: "PTR",
// callback: (err: ErrnoException | null, addresses: string[]) => void,
// ): void;
// export function resolve(
// hostname: string,
// rrtype: "SOA",
// callback: (err: ErrnoException | null, addresses: SoaRecord) => void,
// ): void;
// export function resolve(
// hostname: string,
// rrtype: "SRV",
// callback: (
// err: ErrnoException | null,
// addresses: SrvRecord[],
// ) => void,
// ): void;
// export function resolve(
// hostname: string,
// rrtype: "TXT",
// callback: (
// err: ErrnoException | null,
// addresses: string[][],
// ) => void,
// ): void;
// export function resolve(
// hostname: string,
// rrtype: string,
// callback: (
// err: ErrnoException | null,
// addresses:
// | string[]
// | MxRecord[]
// | NaptrRecord[]
// | SoaRecord
// | SrvRecord[]
// | string[][]
// | AnyRecord[],
// ) => void,
// ): void;
// export namespace resolve {
// function __promisify__(
// hostname: string,
// rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR",
// ): Promise<string[]>;
// function __promisify__(
// hostname: string,
// rrtype: "ANY",
// ): Promise<AnyRecord[]>;
// function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
// function __promisify__(
// hostname: string,
// rrtype: "NAPTR",
// ): Promise<NaptrRecord[]>;
// function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
// function __promisify__(
// hostname: string,
// rrtype: "SRV",
// ): Promise<SrvRecord[]>;
// function __promisify__(
// hostname: string,
// rrtype: "TXT",
// ): Promise<string[][]>;
// function __promisify__(
// hostname: string,
// rrtype: string,
// ): Promise<
// | string[]
// | MxRecord[]
// | NaptrRecord[]
// | SoaRecord
// | SrvRecord[]
// | string[][]
// | AnyRecord[]
// >;
// }
export function resolve(
hostname: string,
rrtype: "A",
callback: (err: ErrnoException | null, addresses: string[]) => void,
): void;
export function resolve(
hostname: string,
rrtype: "AAAA",
callback: (err: ErrnoException | null, addresses: string[]) => void,
): void;
export function resolve(
hostname: string,
rrtype: "ANY",
callback: (err: ErrnoException | null, addresses: AnyRecord[]) => void,
): void;
export function resolve(
hostname: string,
rrtype: "CNAME",
callback: (err: ErrnoException | null, addresses: string[]) => void,
): void;
export function resolve(
hostname: string,
rrtype: "MX",
callback: (err: ErrnoException | null, addresses: MxRecord[]) => void,
): void;
export function resolve(
hostname: string,
rrtype: "NAPTR",
callback: (err: ErrnoException | null, addresses: NaptrRecord[]) => void,
): void;
export function resolve(
hostname: string,
rrtype: "NS",
callback: (err: ErrnoException | null, addresses: string[]) => void,
): void;
export function resolve(
hostname: string,
rrtype: "PTR",
callback: (err: ErrnoException | null, addresses: string[]) => void,
): void;
export function resolve(
hostname: string,
rrtype: "SOA",
callback: (err: ErrnoException | null, addresses: SoaRecord) => void,
): void;
export function resolve(
hostname: string,
rrtype: "SRV",
callback: (err: ErrnoException | null, addresses: SrvRecord[]) => void,
): void;
export function resolve(
hostname: string,
rrtype: "TXT",
callback: (err: ErrnoException | null, addresses: string[][]) => void,
): void;
export function resolve(
hostname: string,
rrtype: string,
callback: (
err: ErrnoException | null,
addresses:
| string[]
| MxRecord[]
| NaptrRecord[]
| SoaRecord
| SrvRecord[]
| string[][]
| AnyRecord[],
) => void,
): void;
export namespace resolve {
function __promisify__(
hostname: string,
rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR",
): Promise<string[]>;
function __promisify__(
hostname: string,
rrtype: "ANY",
): Promise<AnyRecord[]>;
function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
function __promisify__(
hostname: string,
rrtype: "NAPTR",
): Promise<NaptrRecord[]>;
function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
function __promisify__(
hostname: string,
rrtype: "SRV",
): Promise<SrvRecord[]>;
function __promisify__(
hostname: string,
rrtype: "TXT",
): Promise<string[][]>;
function __promisify__(
hostname: string,
rrtype: string,
): Promise<
| string[]
| MxRecord[]
| NaptrRecord[]
| SoaRecord
| SrvRecord[]
| string[][]
| AnyRecord[]
>;
}
/**
* Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the`hostname`. The `addresses` argument passed to the `callback` function
* will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
@@ -512,38 +497,38 @@ declare module "dns" {
* will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`).
* @since v0.3.2
*/
// export function resolveCname(
// hostname: string,
// callback: (err: ErrnoException | null, addresses: string[]) => void,
// ): void;
// export namespace resolveCname {
// function __promisify__(hostname: string): Promise<string[]>;
// }
export function resolveCname(
hostname: string,
callback: (err: ErrnoException | null, addresses: string[]) => void,
): void;
export namespace resolveCname {
function __promisify__(hostname: string): Promise<string[]>;
}
/**
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. The`addresses` argument passed to the `callback` function
* will contain an array of certification authority authorization records
* available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`).
* @since v15.0.0, v14.17.0
*/
// export function resolveCaa(
// hostname: string,
// callback: (err: ErrnoException | null, records: CaaRecord[]) => void,
// ): void;
// export namespace resolveCaa {
// function __promisify__(hostname: string): Promise<CaaRecord[]>;
// }
export function resolveCaa(
hostname: string,
callback: (err: ErrnoException | null, records: CaaRecord[]) => void,
): void;
export namespace resolveCaa {
function __promisify__(hostname: string): Promise<CaaRecord[]>;
}
/**
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
* contain an array of objects containing both a `priority` and `exchange`property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
* @since v0.1.27
*/
// export function resolveMx(
// hostname: string,
// callback: (err: ErrnoException | null, addresses: MxRecord[]) => void,
// ): void;
// export namespace resolveMx {
// function __promisify__(hostname: string): Promise<MxRecord[]>;
// }
export function resolveMx(
hostname: string,
callback: (err: ErrnoException | null, addresses: MxRecord[]) => void,
): void;
export namespace resolveMx {
function __promisify__(hostname: string): Promise<MxRecord[]>;
}
/**
* Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of
* objects with the following properties:
@@ -567,37 +552,37 @@ declare module "dns" {
* ```
* @since v0.9.12
*/
// export function resolveNaptr(
// hostname: string,
// callback: (err: ErrnoException | null, addresses: NaptrRecord[]) => void,
// ): void;
// export namespace resolveNaptr {
// function __promisify__(hostname: string): Promise<NaptrRecord[]>;
// }
export function resolveNaptr(
hostname: string,
callback: (err: ErrnoException | null, addresses: NaptrRecord[]) => void,
): void;
export namespace resolveNaptr {
function __promisify__(hostname: string): Promise<NaptrRecord[]>;
}
/**
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
* contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`).
* @since v0.1.90
*/
// export function resolveNs(
// hostname: string,
// callback: (err: ErrnoException | null, addresses: string[]) => void,
// ): void;
// export namespace resolveNs {
// function __promisify__(hostname: string): Promise<string[]>;
// }
export function resolveNs(
hostname: string,
callback: (err: ErrnoException | null, addresses: string[]) => void,
): void;
export namespace resolveNs {
function __promisify__(hostname: string): Promise<string[]>;
}
/**
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
* be an array of strings containing the reply records.
* @since v6.0.0
*/
// export function resolvePtr(
// hostname: string,
// callback: (err: ErrnoException | null, addresses: string[]) => void,
// ): void;
// export namespace resolvePtr {
// function __promisify__(hostname: string): Promise<string[]>;
// }
export function resolvePtr(
hostname: string,
callback: (err: ErrnoException | null, addresses: string[]) => void,
): void;
export namespace resolvePtr {
function __promisify__(hostname: string): Promise<string[]>;
}
/**
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
* the `hostname`. The `address` argument passed to the `callback` function will
@@ -624,13 +609,13 @@ declare module "dns" {
* ```
* @since v0.11.10
*/
// export function resolveSoa(
// hostname: string,
// callback: (err: ErrnoException | null, address: SoaRecord) => void,
// ): void;
// export namespace resolveSoa {
// function __promisify__(hostname: string): Promise<SoaRecord>;
// }
export function resolveSoa(
hostname: string,
callback: (err: ErrnoException | null, address: SoaRecord) => void,
): void;
export namespace resolveSoa {
function __promisify__(hostname: string): Promise<SoaRecord>;
}
/**
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
* be an array of objects with the following properties:
@@ -650,13 +635,13 @@ declare module "dns" {
* ```
* @since v0.1.27
*/
// export function resolveSrv(
// hostname: string,
// callback: (err: ErrnoException | null, addresses: SrvRecord[]) => void,
// ): void;
// export namespace resolveSrv {
// function __promisify__(hostname: string): Promise<SrvRecord[]>;
// }
export function resolveSrv(
hostname: string,
callback: (err: ErrnoException | null, addresses: SrvRecord[]) => void,
): void;
export namespace resolveSrv {
function __promisify__(hostname: string): Promise<SrvRecord[]>;
}
/**
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. The `records` argument passed to the `callback` function is a
* two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
@@ -664,13 +649,13 @@ declare module "dns" {
* treated separately.
* @since v0.1.27
*/
// export function resolveTxt(
// hostname: string,
// callback: (err: ErrnoException | null, addresses: string[][]) => void,
// ): void;
// export namespace resolveTxt {
// function __promisify__(hostname: string): Promise<string[][]>;
// }
export function resolveTxt(
hostname: string,
callback: (err: ErrnoException | null, addresses: string[][]) => void,
): void;
export namespace resolveTxt {
function __promisify__(hostname: string): Promise<string[][]>;
}
/**
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
* The `ret` argument passed to the `callback` function will be an array containing
@@ -861,14 +846,14 @@ declare module "dns" {
resolve4: typeof resolve4;
resolve6: typeof resolve6;
// resolveAny: typeof resolveAny;
// resolveCname: typeof resolveCname;
// resolveMx: typeof resolveMx;
// resolveNaptr: typeof resolveNaptr;
// resolveNs: typeof resolveNs;
// resolvePtr: typeof resolvePtr;
// resolveSoa: typeof resolveSoa;
// resolveSrv: typeof resolveSrv;
// resolveTxt: typeof resolveTxt;
resolveCname: typeof resolveCname;
resolveMx: typeof resolveMx;
resolveNaptr: typeof resolveNaptr;
resolveNs: typeof resolveNs;
resolvePtr: typeof resolvePtr;
resolveSoa: typeof resolveSoa;
resolveSrv: typeof resolveSrv;
resolveTxt: typeof resolveTxt;
// reverse: typeof reverse;
/**
* The resolver instance will send its requests from the specified IP address.

View File

@@ -10,12 +10,12 @@ declare module "dns/promises" {
LookupOneOptions,
LookupAllOptions,
LookupOptions,
// AnyRecord,
// CaaRecord,
// MxRecord,
// NaptrRecord,
// SoaRecord,
// SrvRecord,
AnyRecord,
CaaRecord,
MxRecord,
NaptrRecord,
SoaRecord,
SrvRecord,
ResolveWithTtlOptions,
RecordWithTtl,
ResolveOptions,
@@ -134,30 +134,30 @@ declare module "dns/promises" {
* @param [rrtype='A'] Resource record type.
*/
function resolve(hostname: string): Promise<string[]>;
// function resolve(hostname: string, rrtype: "A"): Promise<string[]>;
// function resolve(hostname: string, rrtype: "AAAA"): Promise<string[]>;
// function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
// function resolve(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>;
// function resolve(hostname: string, rrtype: "CNAME"): Promise<string[]>;
// function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
// function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
// function resolve(hostname: string, rrtype: "NS"): Promise<string[]>;
// function resolve(hostname: string, rrtype: "PTR"): Promise<string[]>;
// function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
// function resolve(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
// function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;
// function resolve(
// hostname: string,
// rrtype: string,
// ): Promise<
// | string[]
// | MxRecord[]
// | NaptrRecord[]
// | SoaRecord
// | SrvRecord[]
// | string[][]
// | AnyRecord[]
// >;
function resolve(hostname: string, rrtype: "A"): Promise<string[]>;
function resolve(hostname: string, rrtype: "AAAA"): Promise<string[]>;
function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
function resolve(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>;
function resolve(hostname: string, rrtype: "CNAME"): Promise<string[]>;
function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
function resolve(hostname: string, rrtype: "NS"): Promise<string[]>;
function resolve(hostname: string, rrtype: "PTR"): Promise<string[]>;
function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
function resolveSrv(hostname: string): Promise<SrvRecord[]>;
function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;
function resolve(
hostname: string,
rrtype: string,
): Promise<
| string[]
| MxRecord[]
| NaptrRecord[]
| SoaRecord
| SrvRecord[]
| string[][]
| AnyRecord[]
>;
/**
* Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv4
* addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
@@ -223,20 +223,20 @@ declare module "dns/promises" {
* certification authority authorization records available for the `hostname`(e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]`).
* @since v15.0.0, v14.17.0
*/
// function resolveCaa(hostname: string): Promise<CaaRecord[]>;
function resolveCaa(hostname: string): Promise<CaaRecord[]>;
/**
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. On success,
* the `Promise` is resolved with an array of canonical name records available for
* the `hostname` (e.g. `['bar.example.com']`).
* @since v10.6.0
*/
// function resolveCname(hostname: string): Promise<string[]>;
function resolveCname(hostname: string): Promise<string[]>;
/**
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects
* containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`).
* @since v10.6.0
*/
// function resolveMx(hostname: string): Promise<MxRecord[]>;
function resolveMx(hostname: string): Promise<MxRecord[]>;
/**
* Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array
* of objects with the following properties:
@@ -260,19 +260,19 @@ declare module "dns/promises" {
* ```
* @since v10.6.0
*/
// function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
/**
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. On success, the `Promise` is resolved with an array of name server
* records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`).
* @since v10.6.0
*/
// function resolveNs(hostname: string): Promise<string[]>;
function resolveNs(hostname: string): Promise<string[]>;
/**
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. On success, the `Promise` is resolved with an array of strings
* containing the reply records.
* @since v10.6.0
*/
// function resolvePtr(hostname: string): Promise<string[]>;
function resolvePtr(hostname: string): Promise<string[]>;
/**
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
* the `hostname`. On success, the `Promise` is resolved with an object with the
@@ -299,7 +299,7 @@ declare module "dns/promises" {
* ```
* @since v10.6.0
*/
// function resolveSoa(hostname: string): Promise<SoaRecord>;
function resolveSoa(hostname: string): Promise<SoaRecord>;
/**
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects with
* the following properties:
@@ -319,7 +319,7 @@ declare module "dns/promises" {
* ```
* @since v10.6.0
*/
// function resolveSrv(hostname: string): Promise<SrvRecord[]>;
function resolveSrv(hostname: string): Promise<SrvRecord[]>;
/**
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. On success, the `Promise` is resolved with a two-dimensional array
* of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
@@ -327,7 +327,7 @@ declare module "dns/promises" {
* treated separately.
* @since v10.6.0
*/
// function resolveTxt(hostname: string): Promise<string[][]>;
function resolveTxt(hostname: string): Promise<string[][]>;
/**
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
* array of host names.
@@ -384,14 +384,14 @@ declare module "dns/promises" {
resolve4: typeof resolve4;
resolve6: typeof resolve6;
// resolveAny: typeof resolveAny;
// resolveCname: typeof resolveCname;
// resolveMx: typeof resolveMx;
// resolveNaptr: typeof resolveNaptr;
// resolveNs: typeof resolveNs;
// resolvePtr: typeof resolvePtr;
// resolveSoa: typeof resolveSoa;
// resolveSrv: typeof resolveSrv;
// resolveTxt: typeof resolveTxt;
resolveCname: typeof resolveCname;
resolveMx: typeof resolveMx;
resolveNaptr: typeof resolveNaptr;
resolveNs: typeof resolveNs;
resolvePtr: typeof resolvePtr;
resolveSoa: typeof resolveSoa;
resolveSrv: typeof resolveSrv;
resolveTxt: typeof resolveTxt;
// reverse: typeof reverse;
// setLocalAddress(ipv4?: string, ipv6?: string): void;
// setServers: typeof setServers;

View File

@@ -24,6 +24,7 @@ declare module "fs/promises" {
WriteFileOptions,
SimlinkType,
Abortable,
RmOptions,
} from "node:fs";
interface FlagAndOpenMode {
@@ -670,6 +671,12 @@ declare module "fs/promises" {
| BufferEncoding
| null,
): Promise<string | Buffer>;
/**
* Asynchronously removes files and directories (modeled on the standard POSIX `rm`utility). No arguments other than a possible exception are given to the
* completion callback.
* @since v14.14.0
*/
export function rm(path: PathLike, options?: RmOptions): Promise<void>;
}
declare module "node:fs/promises" {

View File

@@ -69,7 +69,7 @@ interface ArrayConstructor {
asyncItems: AsyncIterable<T> | Iterable<T> | ArrayLike<T>,
mapfn?: (value: any, index: number) => any,
thisArg?: any,
): Array<T>;
): Promise<Array<T>>;
}
interface Console {
@@ -318,7 +318,9 @@ interface EncodeIntoResult {
interface Process {
/**
* The current version of Bun
* A Node.js LTS version
*
* To see the current Bun version, use {@link Bun.version}
*/
version: string;
/**
@@ -342,7 +344,7 @@ interface Process {
arch: Architecture;
platform: Platform;
argv: string[];
// execArgv: string[];
execArgv: string[];
env: Bun.Env;
/** Whether you are using Bun */
@@ -391,6 +393,10 @@ interface Process {
* @returns Bun process's file mode creation mask.
*/
umask(mask?: number): number;
emitWarning(warning: string | Error /*name?: string, ctor?: Function*/): void;
readonly config: Object;
}
declare var process: Process;
@@ -408,6 +414,7 @@ interface BlobInterface {
text(): Promise<string>;
arrayBuffer(): Promise<ArrayBuffer>;
json<TJSONReturnType = unknown>(): Promise<TJSONReturnType>;
formData(): Promise<FormData>;
}
type BlobPart = string | Blob | BufferSource | ArrayBuffer;
@@ -495,6 +502,51 @@ type ResponseType =
| "opaque"
| "opaqueredirect";
type FormDataEntryValue = Blob | string;
/** Provides a way to easily construct a set of key/value pairs representing
* form fields and their values, which can then be easily sent using the
* XMLHttpRequest.send() method. It uses the same format a form would use if the
* encoding type were set to "multipart/form-data".
*/
interface FormData {
/**
* Appends a new value onto an existing key inside a FormData object, or adds
* the key if it does not already exist.
*
* @param name The name of the field whose data is contained in value.
* @param value The field's value.
* @param fileName The filename reported to the server.
*
* ## Upload a file
* ```ts
* const formData = new FormData();
* formData.append("username", "abc123");
* formData.append("avatar", Bun.file("avatar.png"), "avatar.png");
* await fetch("https://example.com", { method: "POST", body: formData });
* ```
*/
append(name: string, value: string | Blob, fileName?: string): void;
delete(name: string): void;
get(name: string): FormDataEntryValue | null;
getAll(name: string): FormDataEntryValue[];
has(name: string): boolean;
set(name: string, value: string | Blob, fileName?: string): void;
keys(): IterableIterator<string>;
values(): IterableIterator<string>;
entries(): IterableIterator<[string, FormDataEntryValue]>;
[Symbol.iterator](): IterableIterator<[string, FormDataEntryValue]>;
forEach(
callback: (value: FormDataEntryValue, key: string, parent: this) => void,
thisArg?: any,
): void;
}
declare var FormData: {
prototype: FormData;
new (): FormData;
};
declare class Blob implements BlobInterface {
/**
* Create a new [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
@@ -539,6 +591,20 @@ declare class Blob implements BlobInterface {
*/
json<TJSONReturnType = unknown>(): Promise<TJSONReturnType>;
/**
* Read the data from the blob as a {@link FormData} object.
*
* This first decodes the data from UTF-8, then parses it as a
* `multipart/form-data` body or a `application/x-www-form-urlencoded` body.
*
* The `type` property of the blob is used to determine the format of the
* body.
*
* This is a non-standard addition to the `Blob` API, to make it conform more
* closely to the `BodyMixin` API.
*/
formData(): Promise<FormData>;
type: string;
size: number;
}
@@ -570,7 +636,7 @@ interface ResponseInit {
*/
declare class Response implements BlobInterface {
constructor(
body?: ReadableStream | BlobPart | BlobPart[] | null,
body?: ReadableStream | BlobPart | BlobPart[] | null | FormData,
options?: ResponseInit,
);
@@ -685,6 +751,18 @@ declare class Response implements BlobInterface {
*/
blob(): Promise<Blob>;
/**
* Read the data from the Response as a {@link FormData} object.
*
* This first decodes the data from UTF-8, then parses it as a
* `multipart/form-data` body or a `application/x-www-form-urlencoded` body.
*
* If no `Content-Type` header is present, the promise will be rejected.
*
* @returns Promise<FormData> - The body of the response as a {@link FormData}.
*/
formData(): Promise<FormData>;
readonly ok: boolean;
readonly redirected: boolean;
/**
@@ -746,10 +824,10 @@ type ReferrerPolicy =
| "strict-origin"
| "strict-origin-when-cross-origin"
| "unsafe-url";
type RequestInfo = Request | string;
type RequestInfo = Request | string | RequestInit;
type BodyInit = ReadableStream | XMLHttpRequestBodyInit;
type XMLHttpRequestBodyInit = Blob | BufferSource | string;
type XMLHttpRequestBodyInit = Blob | BufferSource | string | FormData;
type ReadableStreamController<T> = ReadableStreamDefaultController<T>;
type ReadableStreamDefaultReadResult<T> =
| ReadableStreamDefaultReadValueResult<T>
@@ -828,6 +906,21 @@ interface RequestInit {
timeout?: boolean;
}
interface FetchRequestInit extends RequestInit {
/**
* Log the raw HTTP request & response to stdout. This API may be
* removed in a future version of Bun without notice.
* This is a custom property that is not part of the Fetch API specification.
* It exists mostly as a debugging tool
*/
verbose?: boolean;
/**
* Override http_proxy or HTTPS_PROXY
* This is a custom property that is not part of the Fetch API specification.
*/
proxy?: string;
}
/**
* [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) represents an HTTP request.
*
@@ -970,9 +1063,19 @@ declare class Request implements BlobInterface {
/** Copy the Request object into a new Request, including the body */
clone(): Request;
/**
* Read the body from the Request as a {@link FormData} object.
*
* This first decodes the data from UTF-8, then parses it as a
* `multipart/form-data` body or a `application/x-www-form-urlencoded` body.
*
* @returns Promise<FormData> - The body of the request as a {@link FormData}.
*/
formData(): Promise<FormData>;
}
interface Crypto {
declare interface Crypto {
readonly subtle: SubtleCrypto;
getRandomValues<T extends BufferSource = BufferSource>(array: T): T;
@@ -988,6 +1091,10 @@ interface Crypto {
*/
randomUUID(): string;
}
declare var Crypto: {
prototype: Crypto;
new (): Crypto;
};
declare var crypto: Crypto;
@@ -1219,6 +1326,11 @@ declare function clearInterval(id?: number): void;
* @param id timer id
*/
declare function clearTimeout(id?: number): void;
/**
* Cancel an immediate function call by its immediate ID.
* @param id immediate id
*/
declare function clearImmediate(id?: number): void;
// declare function createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>;
// declare function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
/**
@@ -1231,20 +1343,10 @@ declare function clearTimeout(id?: number): void;
*
*
*/
declare function fetch(
url: string,
init?: RequestInit,
/**
* This is a custom property that is not part of the Fetch API specification.
* It exists mostly as a debugging tool
*/
bunOnlyOptions?: {
/**
* Log the raw HTTP request & response to stdout. This API may be
* removed in a future version of Bun without notice.
*/
verbose: boolean;
},
url: string | URL,
init?: FetchRequestInit,
): Promise<Response>;
/**
@@ -1258,21 +1360,7 @@ declare function fetch(
*
*/
// tslint:disable-next-line:unified-signatures
declare function fetch(
request: Request,
init?: RequestInit,
/**
* This is a custom property that is not part of the Fetch API specification.
* It exists mostly as a debugging tool
*/
bunOnlyOptions?: {
/**
* Log the raw HTTP request & response to stdout. This API may be
* removed in a future version of Bun without notice.
*/
verbose: boolean;
},
): Promise<Response>;
declare function fetch(request: Request, init?: RequestInit): Promise<Response>;
declare function queueMicrotask(callback: (...args: any[]) => void): void;
/**
@@ -1621,6 +1709,27 @@ declare var MessageEvent: {
new <T>(type: string, eventInitDict?: MessageEventInit<T>): MessageEvent<T>;
};
interface CustomEventInit<T = any> extends EventInit {
detail?: T;
}
interface CustomEvent<T = any> extends Event {
/** Returns any custom data event was created with. Typically used for synthetic events. */
readonly detail: T;
/** @deprecated */
initCustomEvent(
type: string,
bubbles?: boolean,
cancelable?: boolean,
detail?: T,
): void;
}
declare var CustomEvent: {
prototype: CustomEvent;
new <T>(type: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>;
};
/**
* An implementation of the [WebSocket API](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)
*/
@@ -2281,6 +2390,43 @@ interface ErrnoException extends Error {
syscall?: string | undefined;
}
/** An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API. */
interface DOMException extends Error {
/** @deprecated */
readonly code: number;
readonly message: string;
readonly name: string;
readonly ABORT_ERR: number;
readonly DATA_CLONE_ERR: number;
readonly DOMSTRING_SIZE_ERR: number;
readonly HIERARCHY_REQUEST_ERR: number;
readonly INDEX_SIZE_ERR: number;
readonly INUSE_ATTRIBUTE_ERR: number;
readonly INVALID_ACCESS_ERR: number;
readonly INVALID_CHARACTER_ERR: number;
readonly INVALID_MODIFICATION_ERR: number;
readonly INVALID_NODE_TYPE_ERR: number;
readonly INVALID_STATE_ERR: number;
readonly NAMESPACE_ERR: number;
readonly NETWORK_ERR: number;
readonly NOT_FOUND_ERR: number;
readonly NOT_SUPPORTED_ERR: number;
readonly NO_DATA_ALLOWED_ERR: number;
readonly NO_MODIFICATION_ALLOWED_ERR: number;
readonly QUOTA_EXCEEDED_ERR: number;
readonly SECURITY_ERR: number;
readonly SYNTAX_ERR: number;
readonly TIMEOUT_ERR: number;
readonly TYPE_MISMATCH_ERR: number;
readonly URL_MISMATCH_ERR: number;
readonly VALIDATION_ERR: number;
readonly WRONG_DOCUMENT_ERR: number;
}
declare var DOMException: {
prototype: DOMException;
new (message?: string, name?: string): DOMException;
};
declare function alert(message?: string): void;
declare function confirm(message?: string): boolean;
declare function prompt(message?: string, _default?: string): string | null;
@@ -2776,3 +2922,154 @@ interface SharedArrayBuffer {
*/
grow(size: number): SharedArrayBuffer;
}
declare namespace WebAssembly {
interface CompileError extends Error {}
var CompileError: {
prototype: CompileError;
new (message?: string): CompileError;
(message?: string): CompileError;
};
interface Global {
value: any;
valueOf(): any;
}
var Global: {
prototype: Global;
new (descriptor: GlobalDescriptor, v?: any): Global;
};
interface Instance {
readonly exports: Exports;
}
var Instance: {
prototype: Instance;
new (module: Module, importObject?: Imports): Instance;
};
interface LinkError extends Error {}
var LinkError: {
prototype: LinkError;
new (message?: string): LinkError;
(message?: string): LinkError;
};
interface Memory {
readonly buffer: ArrayBuffer;
grow(delta: number): number;
}
var Memory: {
prototype: Memory;
new (descriptor: MemoryDescriptor): Memory;
};
interface Module {}
var Module: {
prototype: Module;
new (bytes: BufferSource): Module;
customSections(moduleObject: Module, sectionName: string): ArrayBuffer[];
exports(moduleObject: Module): ModuleExportDescriptor[];
imports(moduleObject: Module): ModuleImportDescriptor[];
};
interface RuntimeError extends Error {}
var RuntimeError: {
prototype: RuntimeError;
new (message?: string): RuntimeError;
(message?: string): RuntimeError;
};
interface Table {
readonly length: number;
get(index: number): any;
grow(delta: number, value?: any): number;
set(index: number, value?: any): void;
}
var Table: {
prototype: Table;
new (descriptor: TableDescriptor, value?: any): Table;
};
interface GlobalDescriptor {
mutable?: boolean;
value: ValueType;
}
interface MemoryDescriptor {
initial: number;
maximum?: number;
shared?: boolean;
}
interface ModuleExportDescriptor {
kind: ImportExportKind;
name: string;
}
interface ModuleImportDescriptor {
kind: ImportExportKind;
module: string;
name: string;
}
interface TableDescriptor {
element: TableKind;
initial: number;
maximum?: number;
}
interface WebAssemblyInstantiatedSource {
instance: Instance;
module: Module;
}
type ImportExportKind = "function" | "global" | "memory" | "table";
type TableKind = "anyfunc" | "externref";
type ValueType =
| "anyfunc"
| "externref"
| "f32"
| "f64"
| "i32"
| "i64"
| "v128";
type ExportValue = Function | Global | Memory | Table;
type Exports = Record<string, ExportValue>;
type ImportValue = ExportValue | number;
type Imports = Record<string, ModuleImports>;
type ModuleImports = Record<string, ImportValue>;
function compile(bytes: BufferSource): Promise<Module>;
// function compileStreaming(source: Response | PromiseLike<Response>): Promise<Module>;
function instantiate(
bytes: BufferSource,
importObject?: Imports,
): Promise<WebAssemblyInstantiatedSource>;
function instantiate(
moduleObject: Module,
importObject?: Imports,
): Promise<Instance>;
// function instantiateStreaming(
// source: Response | PromiseLike<Response>,
// importObject?: Imports,
// ): Promise<WebAssemblyInstantiatedSource>;
function validate(bytes: BufferSource): boolean;
}
interface NodeModule {
exports: any;
}
declare var module: NodeModule;
// Same as module.exports
declare var exports: any;
declare var global: typeof globalThis;

View File

@@ -1,15 +0,0 @@
Can reference images included here in code comments, ex
```ts
/**
* ## Large headline
*
*
* **Images** are relative to images/ directory
*![image_description](media://image_filehere.gif)
*
*/
export class MyUtil<T = { BOT_TOKEN: string }> {
constructor(public config: T) {}
}
```

View File

@@ -5,32 +5,41 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
/// <reference path="./bun.d.ts" />
/// <reference path="./assert.d.ts" />
/// <reference path="./buffer.d.ts" />
/// <reference path="./sqlite.d.ts" />
/// <reference path="./bun-test.d.ts" />
/// <reference path="./bun.d.ts" />
/// <reference path="./child_process.d.ts" />
/// <reference path="./console.d.ts" />
/// <reference path="./constants.d.ts" />
/// <reference path="./crypto.d.ts" />
/// <reference path="./dns.d.ts" />
/// <reference path="./dns/promises.d.ts" />
/// <reference path="./domain.d.ts" />
/// <reference path="./events.d.ts" />
/// <reference path="./ffi.d.ts" />
/// <reference path="./fs.d.ts" />
/// <reference path="./fs/promises.d.ts" />
/// <reference path="./html-rewriter.d.ts" />
/// <reference path="./globals.d.ts" />
/// <reference path="./path.d.ts" />
/// <reference path="./bun-test.d.ts" />
/// <reference path="./jsc.d.ts" />
/// <reference path="./assert.d.ts" />
/// <reference path="./events.d.ts" />
/// <reference path="./os.d.ts" />
/// <reference path="./domain.d.ts" />
/// <reference path="./util.d.ts" />
/// <reference path="./querystring.d.ts" />
/// <reference path="./string_decoder.d.ts" />
/// <reference path="./timers.d.ts" />
/// <reference path="./stream.d.ts" />
/// <reference path="./crypto.d.ts" />
/// <reference path="./child_process.d.ts" />
/// <reference path="./constants.d.ts" />
/// <reference path="./url.d.ts" />
/// <reference path="./tty.d.ts" />
/// <reference path="./html-rewriter.d.ts" />
/// <reference path="./http.d.ts" />
/// <reference path="./jsc.d.ts" />
/// <reference path="./module.d.ts" />
/// <reference path="./net.d.ts" />
/// <reference path="./os.d.ts" />
/// <reference path="./path.d.ts" />
/// <reference path="./perf_hooks.d.ts" />
/// <reference path="./punycode.d.ts" />
/// <reference path="./zlib.d.ts" />
/// <reference path="./querystring.d.ts" />
/// <reference path="./readline.d.ts" />
/// <reference path="./readline/promises.d.ts" />
/// <reference path="./sqlite.d.ts" />
/// <reference path="./stream.d.ts" />
/// <reference path="./string_decoder.d.ts" />
/// <reference path="./supports-color.d.ts" />
/// <reference path="./timers.d.ts" />
/// <reference path="./tls.d.ts" />
/// <reference path="./tty.d.ts" />
/// <reference path="./url.d.ts" />
/// <reference path="./util.d.ts" />
/// <reference path="./zlib.d.ts" />

View File

@@ -18,16 +18,16 @@ declare module "net" {
Abortable,
// EventEmitter
} from "node:events";
// import * as dns from "node:dns";
// type LookupFunction = (
// hostname: string,
// options: dns.LookupOneOptions,
// callback: (
// err: NodeJS.ErrnoException | null,
// address: string,
// family: number,
// ) => void,
// ) => void;
import * as dns from "node:dns";
type LookupFunction = (
hostname: string,
options: dns.LookupOneOptions,
callback: (
err: ErrnoException | null,
address: string,
family: number,
) => void,
) => void;
interface AddressInfo {
address: string;
family: string;

View File

@@ -2,7 +2,7 @@
"name": "bun-types",
"types": "index.d.ts",
"private": true,
"repository": "https://github.com/oven-sh/bun-types",
"repository": "https://github.com/oven-sh/bun",
"scripts": {
"build": "rm -rf ./dist && bun run bundle && bun run fmt",
"bundle": "bun scripts/bundle.ts ./dist",

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