Compare commits

...

470 Commits

Author SHA1 Message Date
Jarred Sumner
6632135ec0 Prefer BUN_PORT over PORT 2022-10-26 21:06:02 -07:00
Jarred Sumner
7b73dcf906 Update server.zig 2022-10-26 21:05:53 -07:00
Jarred Sumner
75b1ef1ef4 Make "tls" an explicit object we pass instead of implicit top-level options
cc @Electroid @colinhacks
2022-10-26 21:04:12 -07:00
Jarred Sumner
830f83a44d againn 2022-10-26 17:50:35 -07:00
Jarred Sumner
88d6615e4e try againn 2022-10-26 17:07:22 -07:00
Ashcon Partovi
cc1b340cff Limit concurrency for MacOS Object actions 2022-10-26 16:41:29 -07:00
Jarred Sumner
8ccf5a07ca temporary fix 2022-10-26 16:33:08 -07:00
Jarred Sumner
10a8c6acdd Fixup 2022-10-26 16:31:49 -07:00
Jarred Sumner
2cd1d44739 Move this to dependencies so the .a files upload 2022-10-26 16:30:28 -07:00
Jarred Sumner
de536fc953 Make these tests better 2022-10-26 16:29:46 -07:00
Ashcon Partovi
a1456767f7 Limit concurrency for GitHub Actions due to issues with cache poisoning
If multiple actions are running, sometimes the cache is poisoned from another action. We need to fix this, but this is an interim measure to make actions less flaky
2022-10-26 16:21:51 -07:00
Jarred Sumner
e0feff22c9 Fix issue with CryptoKey and SubtleCrypto constructors 2022-10-26 15:28:27 -07:00
João Paquim
44ff09015c Minor fixes to README.md (#1395) 2022-10-26 10:23:51 -07:00
João Paquim
3c45182097 Update Dev Containers extension name (#1393) 2022-10-26 09:23:33 -07:00
Jarred Sumner
c02da2c5a6 Fix failing macOS build 2022-10-25 23:32:04 -07:00
Jarred Sumner
5cd91fa1a3 Update Makefile 2022-10-25 23:11:42 -07:00
Jarred Sumner
d21739af1a Update Makefile 2022-10-25 23:11:42 -07:00
Jarred Sumner
bd372e9cf4 Update Makefile 2022-10-25 23:11:42 -07:00
Ashcon Partovi
afe04aa8bf Add action to deploy to Homebrew 2022-10-25 23:03:20 -07:00
Jarred Sumner
9b2bad8bed Update Makefile 2022-10-25 22:41:26 -07:00
Jarred Sumner
7622f2e339 Fix crash in TCP server 2022-10-25 21:41:20 -07:00
Jarred Sumner
3d05cb017d Update Makefile 2022-10-25 20:53:08 -07:00
Jarred Sumner
1c54deab52 Update README.md 2022-10-25 18:03:07 -07:00
zhiyuan
28d71e2d9f Fix lexer expected token error (#1387)
* fix: lexer expected token error

* fix: handle parse error through logs
2022-10-25 12:34:40 -07:00
Jarred Sumner
02c920f4fd TCP & TLS Socket API (#1374)
* TCP Socket API

* Wip

* Add snippet for StringDecoder

* Rename `close` to `stop`, replace `close` with `end`

* Add a tcp echo server test

* Some docs

* Update README.md

* Fix build

* Update README.md

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2022-10-25 00:44:25 -07:00
Dylan Conway
1b50ecc52b oniguruma regex lookbehind and multibyte hex fix (#1363)
* handle multibyte hex characters

* non extended strings used for toString() and source

* add hasIndices flags

* more tests for lookbehinds, unicode, and hex characters

* handled case when hex doesnt have enough digit, more tests

* fix adding characters out of bounds

* backslash in character class

* compile() returns object

* escape special characters in oniguruma character class
2022-10-24 19:02:56 -07:00
Jarred Sumner
f8ea534f3b Hopefully fix failing build 2022-10-24 16:38:56 -07:00
Jarred Sumner
9aea2f90a5 Maybe fix a crash 2022-10-24 16:38:32 -07:00
Jarred Sumner
38cc698b4d Update README.md 2022-10-24 04:16:52 -07:00
Jarred Sumner
f13f465024 Update README.md 2022-10-24 04:13:29 -07:00
Jarred Sumner
e8d6ad6d66 Update README.md 2022-10-24 04:13:11 -07:00
Jarred Sumner
434f1bffad Update README.md 2022-10-24 04:12:32 -07:00
Jarred Sumner
0b0db78799 Bun.peek 2022-10-24 04:10:44 -07:00
Jarred Sumner
b3434a8b88 Add fd to SystemError and fix 2 cases with invalid tagged union
cc @sno2
2022-10-23 22:29:23 -07:00
Carter Snook
223ce77eca fix(web): stop segfault on invalid fd error (#1386) 2022-10-23 22:14:37 -07:00
Jarred Sumner
ec9787770e Preserve trailing newline when updating package.json
Fixes https://github.com/oven-sh/bun/issues/1375
2022-10-23 21:53:54 -07:00
Jarred Sumner
360a007f16 Fix ReadableStream.prototype.tee 2022-10-23 21:30:50 -07:00
Jarred Sumner
76652ac3ca Add Web Crypto API (#1384)
* Add Web Crypto API

* Duplicate symbols

* Update c_cpp_properties.json

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2022-10-23 20:25:18 -07:00
Carter Snook
14cec299f5 fix(fetch): stop new Response(null) from segfaulting (#1383)
* fix(fetch): resolve segfaults with 'Response'

* nit: use shorter check
2022-10-23 18:27:03 -07:00
zhiyuan
55c42f1663 Fix spawn exitcode (#1371) 2022-10-22 09:41:56 -07:00
Jarred Sumner
85808700c8 Add sqlite to include list 2022-10-21 22:54:26 -07:00
Jarred Sumner
73fba0c5f1 Codegen 2022-10-21 22:54:17 -07:00
Jarred Sumner
7060008b83 Treat invalid buffer value as utf8 string 2022-10-21 22:53:32 -07:00
Jarred Sumner
ae4f2d63c8 Add test for fs.createReadStream 2022-10-21 22:50:23 -07:00
Jarred Sumner
9129309f0a Implement fs.createReadStream, begin fs.createWriteStream 2022-10-21 22:50:06 -07:00
Jarred Sumner
c987bdcbf9 Make Node Streams work better in Bun 2022-10-21 22:49:49 -07:00
Jarred Sumner
f6a451256f Fix error handling logic in read() 2022-10-21 22:49:19 -07:00
Jarred Sumner
71b942b581 Fix bugs in mask boolean values 2022-10-21 22:48:55 -07:00
Jarred Sumner
cd2e9e9dcf Emit errors 2022-10-21 22:47:58 -07:00
Jarred Sumner
347309b26f Add test for ResolveError.position being inspectable 2022-10-21 22:35:28 -07:00
Jarred Sumner
8d67870da4 Fix segfault when logging position object from failed nested import 2022-10-21 22:34:47 -07:00
Jarred Sumner
04e0583c31 Implement setMaxListeners and getMaxListeners 2022-10-21 21:13:50 -07:00
Jarred Sumner
c37d0be027 Fix import Foo, {bar} when from hardcoded builtin modules in runtime 2022-10-21 21:13:50 -07:00
Jarred Sumner
4c136cddd7 Fix test failure 2022-10-21 21:13:50 -07:00
Jarred Sumner
b50dc40fb8 Reload node:fs in development 2022-10-21 21:13:50 -07:00
Carter Snook
6160dc3995 chore: remove outdated var usages (#1364) 2022-10-21 09:54:13 -07:00
Jarred Sumner
a1f40400c1 Fix "/" in example 2022-10-21 01:09:37 -07:00
Jarred Sumner
c940f00e2d Fix infinite loop 2022-10-21 01:07:49 -07:00
Jarred Sumner
97ccbc189a micro-optimize 2022-10-21 01:07:49 -07:00
Ashcon Partovi
0a2c101c28 Update install script to use secure flags 2022-10-20 18:44:50 -07:00
Ashcon Partovi
c526a6bce8 Add installation method for Homebrew 2022-10-20 18:26:23 -07:00
Jarred Sumner
da9b2452a7 Fix crash in highWaterMark 2022-10-20 16:34:09 -07:00
zhiyuan
210ae2ffb2 Fix Bun.serve error handler error param (#1359) 2022-10-20 01:40:58 -07:00
Jarred Sumner
9f16906499 Fix calling ws.publish inside close when other clients are connected
This fixes https://github.com/oven-sh/bun/issues/1357
2022-10-19 19:54:20 -07:00
Lucas Garron
605c429770 Cache dir loader: Prefer $BUN_INSTALL and $XDG_CACHE_HOME to $HOME. (#1351)
This partially addresses https://github.com/oven-sh/bun/issues/696 , by using `$XDG_CACHE_HOME` for those of us who already have that env var set.
2022-10-19 16:19:50 -07:00
Ashcon Partovi
b064872d9a Improve issue templates (#1353) 2022-10-19 16:19:35 -07:00
Jarred Sumner
ff36fa8a53 Add websocket hot example 2022-10-19 02:36:22 -07:00
Jarred Sumner
19682b4225 Update README.md 2022-10-19 01:13:13 -07:00
Jarred Sumner
536bd72de9 Prettier 2022-10-19 00:18:15 -07:00
Jarred Sumner
87ca9948ec Allow returning a Response object when upgrading 2022-10-19 00:18:00 -07:00
Jarred Sumner
57e5c35277 latest 2022-10-18 23:05:23 -07:00
Jarred Sumner
8b4c3ec0c7 Add todo 2022-10-18 22:57:06 -07:00
Jarred Sumner
9c7eb75a9a websocker-server 2022-10-18 22:16:51 -07:00
Jarred Sumner
b0fe167910 Fix test 2022-10-18 22:16:51 -07:00
Aapo Alasuutari
6223030360 Use buffer type for Deno FFI binding to align with Bun usage (#1321)
* Use buffer type for Deno FFI binding to align with Bun usage

* Prettier
2022-10-18 21:12:33 -07:00
Dylan Conway
1835e4b9f9 get args fix (#1346)
* fix args.len < capacity check

* tests for args

* file name change

* switch to stdout.writer, use JSON for parsing

* bun-debug or bun

* missing arg
2022-10-18 20:11:17 -07:00
Ikko Ashimine
8ca49f906a Fix typo in datetime.zig (#1310)
containg -> contain
2022-10-18 18:48:53 -07:00
Jarred Sumner
dac6c48b1e woops 2022-10-18 18:21:53 -07:00
Jarred Sumner
2b0694ec8c Update uws 2022-10-18 17:40:34 -07:00
Jarred Sumner
26bfc4f0a3 Update uws 2022-10-18 16:57:25 -07:00
Jarred Sumner
fbec10758b Update uws 2022-10-18 16:41:13 -07:00
Jarred Sumner
30d43b027f Update javascript.zig 2022-10-18 13:48:50 -07:00
Jarred Sumner
693b1c9b23 Implement performance.timeOrigin 2022-10-18 13:36:44 -07:00
Jarred Sumner
ce0efc37cc build faiilures 2022-10-18 03:12:34 -07:00
Jarred Sumner
11c105aa1d Update uws 2022-10-18 02:44:23 -07:00
Jarred Sumner
9167aedcc8 y u no work 2022-10-18 00:32:49 -07:00
Jarred Sumner
fc4c3e3199 Fix build 2022-10-17 23:54:47 -07:00
Jarred Sumner
61a8490c66 Fix empty process.argv 2022-10-17 22:44:42 -07:00
Jarred Sumner
abd6e496ab Add oniguruma to Dockerfile
CC @dylan-conway so you have context in the future how to do this
2022-10-17 22:39:49 -07:00
Dylan Conway
8e1b2ba32e add oniguruma for regex with variable length lookbehinds (#1329)
* added pcre2 submodule

* pcre2 regex boilerplate

* tests for pcre2 regex

* flag validation, getters, construct and compile mostly working

* string escaping for source and toString(), exec, more tests

* flag sorting, match, matchAll, search, split, replace

* remove lib link

* add destructor to PCRE2RegExp

* header include

* removed ternary

* switched to oniguruma for regex library

* revert sql changes

* fix indices flag, add tests

* revert settings

* working error messages

* more tests for lastIndex, fix logic for compile and lastIndex

* move oniguruma lib to deps out dir
2022-10-17 22:37:18 -07:00
Jarred Sumner
c7fc8fdf96 Updates to UWS 2022-10-17 21:55:38 -07:00
Jarred Sumner
7f4bb93782 Slightly mroe careful TextEncoder 2022-10-17 21:49:00 -07:00
Jarred Sumner
a10a8e9c70 Load fewer copies of uWS 2022-10-17 21:48:37 -07:00
Jarred Sumner
b595ddf20d Fix error handler 2022-10-17 15:38:36 -07:00
Jarred Sumner
4bd9b20c8a Workaround crash 2022-10-17 07:25:10 -07:00
Jarred Sumner
9190061ba4 Update websocket-server.test.ts 2022-10-17 07:24:20 -07:00
Jarred Sumner
41f9fd85f6 Handle assertion faillure 2022-10-17 07:24:12 -07:00
Jarred Sumner
cdff2697ef Implement sendText, sendBinary, publishText, publishBinary 2022-10-17 06:53:18 -07:00
Jarred Sumner
ca02695993 Update README.md 2022-10-17 04:36:22 -07:00
Jarred Sumner
9a2f2a94bf Update README.md 2022-10-17 04:17:39 -07:00
Jarred Sumner
e22c245d08 Update README.md 2022-10-17 04:07:55 -07:00
Jarred Sumner
171242680d Update README.md 2022-10-17 03:58:53 -07:00
Jarred Sumner
5995f2ed71 Update README.md 2022-10-17 03:57:43 -07:00
Jarred Sumner
abbde39a02 Clean up some code 2022-10-17 03:33:37 -07:00
Jarred Sumner
e1a17aff4c Fix headers + add test 2022-10-17 03:25:50 -07:00
Jarred Sumner
b8c5646c49 More tests 2022-10-17 03:04:43 -07:00
Jarred Sumner
62b0b601c2 Implement error and binaryType 2022-10-17 03:03:46 -07:00
Jarred Sumner
e43b4815b5 Handle .zero better 2022-10-17 01:38:18 -07:00
Jarred Sumner
923d9c1bbb Redo 2022-10-17 00:41:29 -07:00
Jarred Sumner
e3a6007a76 Redo WebSocket api 2022-10-17 00:41:29 -07:00
Dennis Dudek
00ae8f79e4 Reflecting new home for bun templates (#1317)
* Reflecting new home for bun templates
https://github.com/bun-community/create-templates/

* templates now in root
2022-10-16 20:52:39 -07:00
Jarred Sumner
dc1330aef5 yml 2022-10-16 20:50:15 -07:00
Jarred Sumner
3c1e3792d6 Fix #1335 2022-10-16 20:43:43 -07:00
Jarred Sumner
603164e66a Revert "disable lto for UWS to workaround bug under load"
This reverts commit f356da1b5e.
2022-10-16 20:34:02 -07:00
Jarred Sumner
f19b5ce409 Disable InlineBlob optimization 2022-10-16 19:52:35 -07:00
Jarred Sumner
f356da1b5e disable lto for UWS to workaround bug under load 2022-10-16 19:02:20 -07:00
Jarred Sumner
07a2f80cbc Add a comment 2022-10-16 17:03:17 -07:00
Jarred Sumner
2888f43c8a Make debug logs configurable 2022-10-16 17:03:06 -07:00
Jarred Sumner
697e105ffa Name the thread 2022-10-16 17:02:56 -07:00
Jarred Sumner
5d7174d789 Changed api 2022-10-16 17:02:45 -07:00
Jarred Sumner
ab3b072249 snapshots 2022-10-16 17:02:35 -07:00
Jarred Sumner
690e79445d Update uws 2022-10-16 05:02:01 -07:00
Jarred Sumner
bce68bc898 Set Date header 2022-10-16 04:59:43 -07:00
Jarred Sumner
94091a7522 Make more sure we know what the types we are sending are 2022-10-16 00:14:07 -07:00
Jarred Sumner
2852520d90 Fix WebSocket server sending invalid data at the end 2022-10-16 00:13:51 -07:00
Jarred Sumner
abf3a13433 Fail earlier when there are encoding errors 2022-10-16 00:13:18 -07:00
Jarred Sumner
cebd351e61 Disable some logging 2022-10-15 22:55:48 -07:00
Jarred Sumner
19cff80af8 More careful code generator 2022-10-15 22:49:06 -07:00
Jarred Sumner
9830e50a29 Simplify code that turns a fetch() response into a JSResponse 2022-10-15 22:48:27 -07:00
Jarred Sumner
820e6605f8 Simplify the code that reads HTTP client request bodies 2022-10-15 22:47:18 -07:00
Jarred Sumner
c06bba77d4 Add test for body mixin error 2022-10-15 21:34:05 -07:00
Jarred Sumner
4ba217bc42 Dumber code is better code 2022-10-15 21:06:17 -07:00
Jarred Sumner
a42a9e901c Errors must return 0 instead of undefined 2022-10-15 21:06:08 -07:00
Jarred Sumner
3482d76175 Fix crash when BodyMixin functions throw
Fixes https://github.com/oven-sh/bun/issues/1331#issuecomment-1279844836
2022-10-15 21:05:15 -07:00
Jarred Sumner
63c9315b24 Add a helper for InlineBlob from two arrays 2022-10-15 21:03:40 -07:00
Jarred Sumner
40126bbe60 More logging 2022-10-15 21:02:32 -07:00
Jarred Sumner
70615f4036 Add a simple test for websocket server 2022-10-15 21:01:59 -07:00
Jarred Sumner
1b1b96aff8 add more logging 2022-10-15 21:01:50 -07:00
Jarred Sumner
de1e963ffa More forcefully clone strings 2022-10-15 05:41:57 -07:00
Jarred Sumner
a299b1b8e3 More lenient for response_value data 2022-10-15 05:34:15 -07:00
Jarred Sumner
4cc0eebf4b Rename pendingSockets to pendingWebSockets 2022-10-15 05:34:05 -07:00
Jarred Sumner
b1e97edc59 Fix memory leak in HTTP server 2022-10-15 05:33:48 -07:00
Jarred Sumner
a56dfe486b Remove unnecessary GC protect() call 2022-10-15 05:33:38 -07:00
Jarred Sumner
e9c3529476 Fix crash in WebSocketServer close 2022-10-15 05:32:52 -07:00
Jarred Sumner
c9a4bdf44d Update README.md 2022-10-15 04:48:59 -07:00
Jarred Sumner
c6fe82018a Fix bug where pong would put it in invalid state 2022-10-15 04:14:55 -07:00
Jarred Sumner
3016723198 Add some logging to WebSocket client 2022-10-15 04:14:42 -07:00
Jarred Sumner
e453b949dd Be more careful with some of the string handling code 2022-10-15 03:40:10 -07:00
Jarred Sumner
1236e3f59c Update README.md 2022-10-15 03:35:12 -07:00
Jarred Sumner
c6d314e954 Update README.md 2022-10-15 03:33:45 -07:00
Jarred Sumner
2c548d45f8 Update c_cpp_properties.json 2022-10-15 03:29:25 -07:00
Jarred Sumner
4c741cc8b6 Update README.md 2022-10-15 03:29:14 -07:00
Jarred Sumner
4b5af13ac0 WebSocket Server support 2022-10-15 03:06:41 -07:00
Jarred Sumner
35cbfa63a6 Add a way to update cached values from Zig 2022-10-15 02:57:28 -07:00
Jarred Sumner
dd84681d30 Update README.md 2022-10-15 00:30:19 -07:00
Jarred Sumner
0a1fca5d7d Update 2022-10-13 16:43:44 -07:00
Jarred Sumner
af033c02c5 Fix bench 2022-10-13 15:32:25 -07:00
Jarred Sumner
40506e33e7 Fix bench 2022-10-13 15:26:48 -07:00
zhiyuan
b542921f3d Fix import alias (#1313) 2022-10-13 05:44:08 -07:00
Jarred Sumner
b0a7f8df92 Create http-request-body.ts 2022-10-13 02:27:54 -07:00
Jarred Sumner
32e16bda23 Update react-hello-world.jsx 2022-10-13 02:18:50 -07:00
Jarred Sumner
e32ada318a Update react-hello-world.jsx 2022-10-13 02:18:25 -07:00
Jarred Sumner
b011610bb3 Update README.md 2022-10-13 02:02:48 -07:00
Jarred Sumner
723c7c56dc Add for await 2022-10-13 00:58:37 -07:00
Jarred Sumner
6b7a0c1d3f Fix crash in TextEncoder with rope strings that happens sometimes 2022-10-12 23:59:00 -07:00
Jarred Sumner
22f7981cff Regenerate builtins 2022-10-12 23:50:48 -07:00
Jarred Sumner
ad29d9ffb3 Fix cancel not working in some cases in ReadableStream 2022-10-12 23:48:41 -07:00
Jarred Sumner
8200f43a04 Fix a bug with ReadableStreamDefaultReader and "direct" controller 2022-10-12 23:48:27 -07:00
Jarred Sumner
3fceae8070 Implement ReadableStream.prototype[Symbol.asyncIterator]
cc @fabiancook
2022-10-12 23:46:15 -07:00
Jarred Sumner
8cd8e34719 Update README.md 2022-10-12 19:16:14 -07:00
Jarred Sumner
930981c9d9 Update README.md 2022-10-12 19:15:51 -07:00
Jarred Sumner
f8b22d51a9 Update README.md 2022-10-12 19:15:23 -07:00
Jarred Sumner
2b1b7eb6b3 Update README.md 2022-10-12 19:15:02 -07:00
Jarred Sumner
e241e503b7 Update README.md 2022-10-12 19:14:08 -07:00
Jarred Sumner
39940ec1f5 Update README.md 2022-10-12 19:13:40 -07:00
Jarred Sumner
f725b7e1ab Update README.md 2022-10-12 19:11:47 -07:00
Jarred Sumner
da66bed946 Update README.md 2022-10-12 19:10:01 -07:00
Jarred Sumner
58fe024aea Add --hot to completions 2022-10-12 19:07:11 -07:00
Jarred Sumner
6205cf3fe4 Update README.md 2022-10-12 18:57:28 -07:00
Jarred Sumner
fb6c87da07 Update README.md 2022-10-12 18:57:17 -07:00
Jarred Sumner
d0fb442c59 Update README.md 2022-10-12 18:55:26 -07:00
Jarred Sumner
1c949354c6 Update README.md 2022-10-12 18:17:21 -07:00
Jarred Sumner
3a042cdb48 Add a comment 2022-10-12 18:09:04 -07:00
Jarred Sumner
a97914fff3 Fix require("bun") and import("bun") when statically known 2022-10-12 18:02:18 -07:00
Jarred Sumner
ec00838a03 Update test_scope_debug.ts 2022-10-12 17:47:05 -07:00
Jarred Sumner
860bd53fb3 [bun wiptest] Ignore . folders 2022-10-12 17:10:03 -07:00
Jarred Sumner
477638435c Update README.md 2022-10-12 17:09:37 -07:00
Jarred Sumner
cb384dfa29 Add a bench 2022-10-12 17:00:17 -07:00
Jarred Sumner
dd15a98879 Add hugemem snippet 2022-10-12 16:56:49 -07:00
Jarred Sumner
6b2637468c Add snippet 2022-10-12 16:50:57 -07:00
Jarred Sumner
ab4f4bca6d Add a doc on Bun.spawn 2022-10-12 16:39:26 -07:00
Jarred Sumner
73a611a3b9 Stop keeping the process alive for too long 2022-10-12 16:39:12 -07:00
Jarred Sumner
c5333ab597 support array as first arg in Bun.spawn 2022-10-12 14:43:24 -07:00
Jarred Sumner
75e8c4699c Fix test bug 2022-10-12 01:47:48 -07:00
Jarred Sumner
8fcb0ff0b6 Remove dead code 2022-10-11 23:45:23 -07:00
Jarred Sumner
dbd569d2ab remove config struct 2022-10-11 23:44:35 -07:00
Jarred Sumner
40eca63653 Fix crash when decoding latin1 rope strings and the GC is running 2022-10-11 22:42:19 -07:00
Jarred Sumner
e7eadcde5a Implement Bun.spawnSync 2022-10-11 22:21:06 -07:00
Jarred Sumner
36adee4dc8 Make Bun.spawn work on Linux 2022-10-11 20:25:16 -07:00
Jarred Sumner
9fe1ad93cb Fixup example 2022-10-11 20:00:04 -07:00
Jarred Sumner
8311761c82 Handle eintr in uSockets 2022-10-11 15:39:58 -07:00
Jarred Sumner
8702f965a2 Add test for Bun.file() for stdin and stdout 2022-10-11 14:56:49 -07:00
Jarred Sumner
888a685e26 Maybe fix linux bug? 2022-10-11 13:53:31 -07:00
Jarred Sumner
51c1d18e68 Update server.zig 2022-10-11 01:44:14 -07:00
Jarred Sumner
af6476ca74 Work around Zig C ABI bug on Linux 2022-10-11 01:10:39 -07:00
Jarred Sumner
614d256cb6 Use poll() to check if writable 2022-10-11 00:07:13 -07:00
Jarred Sumner
3867431ed1 Add test that reads & writes stdin/stderr 2022-10-11 00:04:48 -07:00
Jarred Sumner
1f7f5646de Update bun-write.test.js 2022-10-11 00:03:37 -07:00
Jarred Sumner
40623cf967 Implement fs.rm cross-platformly 2022-10-11 00:03:32 -07:00
Jarred Sumner
d07e4f8bd1 Automatically close stdout/stderr on subprocess exit if possible 2022-10-10 22:16:19 -07:00
Jarred Sumner
e4bf189e9d Change behavior of Bun.write 2022-10-10 21:01:06 -07:00
Jarred Sumner
2292ef8d0e Keep the process alive 2022-10-10 21:00:39 -07:00
Jarred Sumner
a114af4eea Use write() and read() since not every file type supports positional 2022-10-10 20:59:34 -07:00
Jarred Sumner
5152aebde1 Handle EAGAIN in Bun.write() for short input 2022-10-10 20:58:58 -07:00
Jarred Sumner
1310a1d99e Ensure we set globalThis in the FileBlob / FileSink 2022-10-10 20:58:43 -07:00
Jarred Sumner
a20d3eaebb Support cache with same name applied to multiple getters 2022-10-10 20:58:19 -07:00
Jarred Sumner
3cc61f8e30 Fix issue with exit callback in Bun.spawn() never firing 2022-10-10 20:57:38 -07:00
Jarred Sumner
ef2c9c330c Process inherits from EventEmitter 2022-10-10 20:27:04 -07:00
Jarred Sumner
5db06105ba Add test for calling assert 2022-10-10 13:51:45 -07:00
Jarred Sumner
24433ceb27 use tweaked CJS transform 2022-10-10 13:51:25 -07:00
Jarred Sumner
ff797f7410 Poll in 2022-10-09 20:38:31 -07:00
Jarred Sumner
cef32c1123 Don't set CLOEXEC 2022-10-09 20:32:10 -07:00
Jarred Sumner
50d4cedd92 Add section about upgrading in the readme 2022-10-09 19:33:07 -07:00
Jarred Sumner
27ad376071 Bump version 2022-10-09 19:04:25 -07:00
Jarred Sumner
eebcd30067 Bun.write - truncate empty files 2022-10-09 18:57:03 -07:00
Jarred Sumner
1afe2f05dc Rename resposne.file.test.js -> bun-write.test.js + add some large file tests 2022-10-09 18:26:00 -07:00
Jarred Sumner
170e3117d7 maybe workaround C ABI issue on linux amd64 2022-10-09 14:30:00 -07:00
Jarred Sumner
fc08e69039 Missing code 2022-10-09 02:20:16 -07:00
Jarred Sumner
25918ddd2a More careful code for FileBlobLoader and FIleSink 2022-10-09 02:02:47 -07:00
Jarred Sumner
edfd2af949 Update WebKit 2022-10-09 02:02:47 -07:00
Jarred Sumner
dffaeaca1e Start to add tests for spawn 2022-10-09 02:02:47 -07:00
Jarred Sumner
88bdae8218 Add a test for server.reload() 2022-10-09 02:02:47 -07:00
Jarred Sumner
fdfe00452b Add a console.debug for the server:port when HMR is enabled 2022-10-09 02:02:47 -07:00
Jarred Sumner
b38d553d60 Update WebKit 2022-10-09 02:02:47 -07:00
Jarred Sumner
0833275f03 Buffer input & output until the user gets the stream 2022-10-09 02:02:47 -07:00
Jarred Sumner
4252d015ca soem helpers 2022-10-09 02:02:47 -07:00
Jarred Sumner
9fd0072740 Don't forget to load SQLite in Database.deserialize
Fixes https://github.com/oven-sh/bun/issues/1304
2022-10-09 02:02:47 -07:00
Jarred Sumner
4dbbdb1671 Clean up how we reload entry point a little 2022-10-09 02:02:47 -07:00
Jarred Sumner
4b5c9acc72 Update bench 2022-10-09 02:02:47 -07:00
Jarred Sumner
b63218206d Add some more bench snippets 2022-10-09 02:02:47 -07:00
Jarred Sumner
349ccf229b Fix navigator.userAgent test 2022-10-09 02:02:47 -07:00
Jarred Sumner
85602b406a Fix SQLite test 2022-10-09 02:02:47 -07:00
Jarred Sumner
cc6077fbf5 Snippet for return await 2022-10-09 02:02:47 -07:00
Jarred Sumner
495534a054 Expose Bun.version and Bun.revision 2022-10-09 02:02:46 -07:00
Jarred Sumner
57513f38d3 Add a test for Bun.version 2022-10-09 02:02:46 -07:00
Jarred Sumner
0b3abf2c78 Add a test for not logging .env 2022-10-09 02:02:46 -07:00
Jarred Sumner
9294ef73b7 Update WebKit 2022-10-09 02:02:46 -07:00
zhiyuan
36ec06493e Fix fetch response redirected (#1303)
* fix: sync codegen

* fix: generate class script

* fix: sync codegen

* fix: add response redirected property
2022-10-08 22:36:33 -07:00
zhiyuan
6068ad15d4 fix: install error when node_modules already in npm package (#1301) 2022-10-08 02:16:16 -07:00
Jarred Sumner
c2c9173eff Fix https://github.com/oven-sh/bun/issues/1263
What happened: when moving to uSockets for the http client, I forgot to call `SSL_set_tlsext_host_name` and uSockets apparently doesn't do that
2022-10-08 01:06:35 -07:00
zhiyuang
99e7856269 Fix nested modules bin executable issue (#1299) 2022-10-07 09:48:37 -07:00
Jarred Sumner
1355d415e9 Fix linux amd64 crash 2022-10-06 22:14:05 -07:00
Jarred SUmner
410059c9f3 Fix unused arg 2022-10-06 16:23:46 -07:00
Jarred SUmner
80096884f6 Add --profile to bun upgrade 2022-10-06 16:23:08 -07:00
Jarred Sumner
d2dd2ae306 Add protocol getter to Bun.serve() 2022-10-06 15:02:56 -07:00
Jarred Sumner
5c3ce875b2 Automatically support hot reloading with export default { fetch() } 2022-10-06 14:21:14 -07:00
Jarred Sumner
6970250b57 Fix Buffer.toJSON() 2022-10-06 14:18:12 -07:00
Jarred Sumner
c880c53199 Fix failing linux build 2022-10-06 03:02:07 -07:00
Jarred Sumner
75371d1462 Add WebSocket bindings for uWS 2022-10-06 00:48:55 -07:00
Jarred Sumner
2c762f47c9 Add simple Hot Module Reloading to bun's runtime 2022-10-06 00:47:03 -07:00
Jarred Sumner
3246efa580 Implement Server.reload() 2022-10-06 00:01:02 -07:00
Jarred Sumner
4060afb7c7 Implement console.count and console.countReset
Fixes https://github.com/oven-sh/bun/issues/1296
2022-10-05 18:59:58 -07:00
Jarred Sumner
e4d3f51161 move Bun.spawn into separate file 2022-10-05 18:07:41 -07:00
Jarred Sumner
1777e9d0b1 Add abstraction for ticking async event loop 2022-10-05 18:07:41 -07:00
Jarred Sumner
707b454bf4 Support buffered input in Bun.spawn 2022-10-05 18:07:41 -07:00
Jarred Sumner
ca4c99b1bf Fix interopRequireDefault issue with path :( 2022-10-05 18:07:41 -07:00
Jarred Sumner
a302549d3e Expose private @require symbol 2022-10-05 18:07:41 -07:00
Jarred Sumner
1a7418e890 Mark these strings as not needing to be GC'd 2022-10-05 18:07:41 -07:00
Jarred Sumner
c1219a3b48 [breaking] process.version lies and reports Node 18
See https://twitter.com/jarredsumner/status/1577189928294789122
2022-10-05 18:07:41 -07:00
Jarred Sumner
632e4ac6ac Improve stack traces in fs functions
This is a hack
2022-10-05 18:07:41 -07:00
Jarred Sumner
18ae17871d Export rm in fs/promises 2022-10-05 18:07:41 -07:00
Jarred Sumner
09ebb217dd Temporary hack so res.socket in node:http doesn't throw 2022-10-05 18:07:41 -07:00
Jarred Sumner
dbccfc2b26 Fix missing path/posix and path/win32 2022-10-05 18:07:41 -07:00
Jarred Sumner
28f7240dd3 Handle more edgecases in fs.rm on macOS 2022-10-05 18:07:41 -07:00
Jarred Sumner
9f10956ce1 We need to explicitly flush now 2022-10-05 18:07:41 -07:00
Jarred Sumner
c9a50b2f2d Add a test for simultaneous requests 2022-10-05 18:07:41 -07:00
Jarred Sumner
d683d7185d handle values from native in streams 2022-10-05 18:07:41 -07:00
Jarred Sumner
fc13938fc6 Fix bug with next dev showing raw html instead of the rendered page 2022-10-05 18:07:41 -07:00
Ryan Russell
f8e8b10e10 docs(thread_pool): comment readability improvements (#1241)
Signed-off-by: Ryan Russell <git@ryanrussell.org>

Signed-off-by: Ryan Russell <git@ryanrussell.org>
2022-10-05 16:49:37 -07:00
zhiyuang
050292229f fix: console.log handle circular correctly (#1293) 2022-10-05 16:49:00 -07:00
Jarred Sumner
906e97223a Fix DotEnv Loader ignoring error log level 2022-10-03 11:07:00 -07:00
Jarred Sumner
dc10b24730 Add readdir snippet 2022-10-03 01:58:57 -07:00
Jarred Sumner
d3ef6c330a node:fs implement rm on macOS
no linux yet
2022-10-03 01:10:38 -07:00
Jarred Sumner
4700762132 Bun.spawn start to implement support for buffered input (ArrayBuffer, Response, Request body) 2022-10-03 01:09:16 -07:00
Jarred Sumner
08d606c3d7 Fix undefined is not a function error in WritableStream 2022-10-03 01:07:54 -07:00
Jarred Sumner
ed82b919a0 Remove extra green 2022-10-02 18:02:54 -07:00
Jarred Sumner
4fa065180b Fix test expectation counter 2022-10-02 16:06:47 -07:00
Jarred Sumner
cd9b47315c Reduce memory usage of HTTP requests by 8 KB 2022-10-02 01:59:59 -07:00
Jarred Sumner
062c3948ba Fix test failures 2022-10-02 01:56:55 -07:00
Jarred Sumner
bff3b902e8 Fix unref'ing websocket 2022-10-01 18:06:01 -07:00
Jarred Sumner
3b4900193b Fix setTimeout(0), improve test coverage slightly, reduce memory usage of timers 2022-10-01 16:02:29 -07:00
Jarred Sumner
bab317edd1 [napi] Implement napi_remove_wrap 2022-10-01 13:23:32 -07:00
Jarred Sumner
1dac9248ad Add missing type check to napi_wrap
Fixes https://github.com/oven-sh/bun/issues/1286
2022-10-01 13:22:16 -07:00
Jarred Sumner
c57b32fa0c [bun:test] When there are lots of tests, print the failures at the bottom so you can see them easier 2022-10-01 01:46:34 -07:00
Jarred Sumner
43c22b4411 Fix release mode value semantics bug 2022-10-01 01:46:02 -07:00
Jarred Sumner
bee72be733 Increase test coverage for request body streaming
There is still one memory issue to address
2022-10-01 01:13:27 -07:00
Jarred Sumner
ea159b6004 Make setTimeout/setInterval more reliable 2022-09-30 22:12:31 -07:00
Jarred Sumner
ac72f28fc8 Fix body mixin 2022-09-30 20:38:25 -07:00
Jarred Sumner
e4e7966d64 Fix failing tests from backpressure 2022-09-30 19:43:03 -07:00
Jarred Sumner
48cb526e0b Eagerly receive incoming request bodies 2022-09-30 18:49:25 -07:00
Jarred Sumner
fd6d28a9fa Fix outdated type 2022-09-30 18:46:58 -07:00
Jarred Sumner
944dc988bf Simplify some of this 2022-09-30 18:46:50 -07:00
Jarred Sumner
2fac218a36 Delete some code 2022-09-30 18:45:02 -07:00
Jarred Sumner
16c184efdf Add a couple assertions 2022-09-30 18:44:48 -07:00
Jarred Sumner
6b5c49c269 Fix incorrect first number in byte stream 2022-09-30 18:38:36 -07:00
Jarred Sumner
af6a43c49b Attempt to address .write() bug 2022-09-30 01:27:35 -07:00
Jarred Sumner
18310cfd7c Fix unnecessary "Buffer is detached" error 2022-09-30 01:08:53 -07:00
Jarred Sumner
9046767da4 Request->url == string, not ZigString now 2022-09-30 01:08:34 -07:00
Jarred Sumner
f70c83345a Improve test coverage for Request body streaming! 2022-09-30 01:07:53 -07:00
Jarred Sumner
52f5f9545a Fix OOB when multiple headers have the same name length
Fixes https://github.com/oven-sh/bun/issues/1279
2022-09-30 01:07:35 -07:00
Jarred Sumner
1434fb66d3 Add a better wrapper function for promises 2022-09-30 01:06:42 -07:00
Jarred Sumner
f325a0016b Use poll_ref in the io tasks 2022-09-30 01:06:28 -07:00
Jarred Sumner
9d7bcac680 Support all ArrayBufferView in all hashing functions and node fs functions 2022-09-30 01:06:04 -07:00
Jarred Sumner
8d11ab3c35 Verbose flag 2022-09-30 01:05:40 -07:00
Jarred Sumner
56e491ad8a Use pollref in FileBlobLoader 2022-09-30 01:05:33 -07:00
Jarred Sumner
9296a369de Fixup Body mixin implementation 2022-09-30 01:05:10 -07:00
Jarred Sumner
9050e6ee87 Use PollRef in napi 2022-09-30 01:04:20 -07:00
Jarred Sumner
84af4f0133 more gc in fs test 2022-09-30 01:04:10 -07:00
Jarred Sumner
6338413696 Remove extraneous calls to .ref() 2022-09-30 00:44:36 -07:00
Jarred Sumner
fbec7bda6a Add hidden verbose flag to fetch (the third argument)
```js
fetch(url, {body: ""}, {verbose: true})
```
2022-09-30 00:29:31 -07:00
Jarred Sumner
0f371a2869 [internal] Use PollRef for fetch() 2022-09-30 00:27:39 -07:00
Jarred Sumner
c30346cf5d Create test_scope_debug.ts 2022-09-30 00:25:28 -07:00
Jarred Sumner
64ef2389dc fix potentially truncated encodeInto 2022-09-30 00:06:46 -07:00
Jarred Sumner
6ec55cbeeb Fixup 2022-09-29 18:20:54 -07:00
Jarred Sumner
3430cdd91b don't need to mark 2022-09-29 18:01:12 -07:00
Jarred Sumner
9702568161 Lazy URL, more explicit close() 2022-09-29 17:58:04 -07:00
Jarred Sumner
016a9d6535 Update base.zig 2022-09-29 10:52:41 -07:00
Jarred Sumner
9f10c1a805 Fix Bun.serve not keeping process alive 2022-09-29 10:26:40 -07:00
Jarred Sumner
7631a47612 Fix console.log(ModuleNamespace) 2022-09-29 00:22:51 -07:00
Jarred Sumner
b8851143f9 Update streams.zig 2022-09-28 23:56:38 -07:00
Jarred Sumner
f3028ff6f3 Use uSockets for setTimeout and setInterval 2022-09-28 23:45:31 -07:00
Jarred Sumner
3d35fae890 Add some tests for request body streaming
Need to fix an off-by-one error with Blob it seems
2022-09-28 23:43:40 -07:00
Jarred Sumner
1636291b03 /s/c_int/i32 2022-09-28 23:39:10 -07:00
Jarred Sumner
e69e8d35b9 Fix unreachable 2022-09-28 23:38:54 -07:00
Jarred Sumner
9438540bf9 Fix a crash with fetch(url, {body: arrayBuffer}) introduced with the Blob changes
cc @bwasti
2022-09-28 23:38:42 -07:00
Jarred Sumner
d34179b9eb Queue tests rather than run immediately 2022-09-28 23:38:04 -07:00
Jarred Sumner
90074ce98c Clean up WebSocket never starting 2022-09-28 23:37:40 -07:00
Jarred Sumner
fd0054a800 Outer event loop tweaks 2022-09-28 23:37:09 -07:00
Jarred Sumner
0fb5f15673 Fix a crash in HTMLRewriter caused by blob changes 2022-09-28 23:34:12 -07:00
Jarred Sumner
16929129f0 Clean up some of the event loop code 2022-09-28 23:34:03 -07:00
Jarred Sumner
524e48a81d make bun:test ~300x faster when using http server, websockets, etc
there was an event loop bug
2022-09-28 23:07:18 -07:00
Jarred Sumner
76b1a3a88d Bench snippet for Array.map 2022-09-28 14:38:15 -07:00
Jarred Sumner
b74351e55f Support a default object in CommonJS wrapper
Fixes https://github.com/oven-sh/bun/issues/1284

Related to https://github.com/oven-sh/bun/issues/1285
2022-09-28 14:37:35 -07:00
Jarred Sumner
a1b4dc42cb Implement reportExtraMemoryVisited and reportExtraMemoryAllocated in bindings 2022-09-28 14:36:44 -07:00
Jarred Sumner
5ae5125919 size estimatoor 2022-09-28 11:10:20 -07:00
Jarred Sumner
82a68cd3da fixup 2022-09-28 00:52:25 -07:00
Jarred Sumner
a41150836a Add missing commit 2022-09-28 00:20:12 -07:00
Jarred Sumner
e637b43117 Add missing commit 2022-09-28 00:18:50 -07:00
Jarred Sumner
443ba0f396 Inline blobs in the HTTP server 2022-09-28 00:12:31 -07:00
Jarred Sumner
71ea4a2c9b Fix several bugs with Request body streaming + store small response bodies without an extra memory allocation 2022-09-28 00:11:15 -07:00
Jarred Sumner
a8ab18bd50 Fix potential crash when TS code has an unexpected ")" 2022-09-27 09:40:29 -07:00
Jarred Sumner
ce91423a19 Update streams.zig 2022-09-26 20:49:44 -07:00
Jarred Sumner
5875d1419b Make Bun.spawn, FileSink and FileBlobLoader a little more reliable 2022-09-26 20:35:26 -07:00
Jarred Sumner
24a9bc23b7 [Web Streams] Add body to Response and Request (#1255)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2022-09-26 20:04:28 -07:00
Jarred Sumner
97c3688788 Make getting the body for fetch a little more reusable 2022-09-26 20:00:34 -07:00
Jarred Sumner
0b915b1dd2 Add missing ignoreUsage call 2022-09-26 19:59:38 -07:00
Jarred Sumner
5fcbfa780f Bump WebKit 2022-09-26 19:59:09 -07:00
Jarred Sumner
a736010fdd Fix crash when insufficient arguments 2022-09-26 10:30:33 -07:00
Jarred Sumner
b733125085 Fix console.log not printing an empty line
Depends on https://github.com/oven-sh/WebKit/actions/runs/3123884691/jobs/5066828848

Fixes https://github.com/oven-sh/bun/issues/1276
2022-09-25 15:49:35 -07:00
Jarred Sumner
5ef36f1b6f Implement isatty in node:tty 2022-09-25 14:56:22 -07:00
Jarred Sumner
7cc772cd39 😪 2022-09-25 13:14:23 -07:00
Jarred SUmner
7ae73fad68 Make Linux implementation work 2022-09-25 13:14:23 -07:00
Jarred Sumner
96dcfd3cfe Linux implementation 2022-09-25 13:14:23 -07:00
Jarred Sumner
9833841101 wip 2022-09-25 13:14:23 -07:00
Jarred Sumner
1cd67b62e9 Update package.json 2022-09-25 13:14:23 -07:00
Jarred Sumner
ffde9f7842 📷 2022-09-25 13:14:23 -07:00
Albert Putra Purnama
2819509786 test: Promisify basic tests (#1018)
* Promisify basic tests

* Add License header from node

* Add tests to complete existing promisify parity with node

* Update expected error message from nodejs test
2022-09-24 19:05:18 -07:00
Jarred Sumner
5b222996c8 Update bindings.zig 2022-09-23 03:21:38 -07:00
Jarred Sumner
62e22b2995 Implement Bun.which 2022-09-23 03:10:56 -07:00
Jarred Sumner
2346be55fc Fix issue with react-is in bun-framework-next 2022-09-23 00:31:45 -07:00
Jarred Sumner
61d0c4042b Use JSC heap for .arrayBuffer() 2022-09-23 00:26:23 -07:00
Jarred Sumner
de0b373c7c Update streams.zig 2022-09-22 23:53:00 -07:00
Jarred Sumner
2c1926993b Faster Blob + begin to implement FileSink 2022-09-22 23:45:02 -07:00
Jarred SUmner
e14a3af491 Fix linux build 2022-09-22 03:25:29 -07:00
Jarred Sumner
0968fd339f Add epoll to list of syscalls that can fail 2022-09-22 03:06:48 -07:00
Jarred Sumner
2ca1861a54 Remove a mutex when enqueuing concurrent tasks 2022-09-22 02:38:36 -07:00
Jarred Sumner
ce9daa4857 1 event loop per thread. Instead of 3.
uWebSockets and uSockets will need to be upgraded to match the changes.

Previously:
- Bun had a separate kqueue/eventfd just for async wakeups.
- Bun had a separate kqueue/epoll just for reading files non-blocking in the same thread

This commit unifies it into one event loop per thread
2022-09-22 02:25:32 -07:00
Jarred Sumner
e15fb6b9b2 [breaking] Bun.serve().hostname should return the hostname instead of the baseURI
Previously Bun.serve().hostname was returning the baseURI, effectively the `origin`

That was incorrect.

Instead, it should be returning the hostname
2022-09-22 01:57:06 -07:00
Jarred Sumner
f1ffc72a62 Fix bun run foo -- by ignoring -- 2022-09-22 01:56:07 -07:00
Jarred Sumner
37eee4235d Fix preact & other "classic" jsx transforms, most likely 2022-09-21 20:00:12 -07:00
Jarred Sumner
871d530d6a Fix crash with jsxFragment and jsxFactory in tsconfig.json
Fixes https://github.com/oven-sh/bun/issues/1269
2022-09-21 19:55:30 -07:00
Jarred Sumner
16b1e84138 Fix crash when creating an empty array 2022-09-21 18:52:24 -07:00
Jarred Sumner
100ce7b62f Increase macro stack size 2022-09-21 00:00:46 -07:00
Jarred Sumner
c01cba3ab5 Update types.zig 2022-09-20 23:57:45 -07:00
Jarred Sumner
ef1607c088 fixup 2022-09-20 23:57:07 -07:00
Jarred Sumner
123e8c8d2b Update WebKit 2022-09-20 23:56:08 -07:00
Jarred Sumner
9667eec9de Be more careful with process.argv 2022-09-20 23:56:08 -07:00
Hemanth Krishna
26625f3e2a fix: add destination to ADD command in Dockerfile (#1268)
Signed-off-by: Hemanth Krishna <hkpdev008@gmail.com>

Signed-off-by: Hemanth Krishna <hkpdev008@gmail.com>
2022-09-20 23:43:21 -07:00
Jarred Sumner
e94e6d8d95 Allow .env files to define the same key multiple times
Fixes https://github.com/oven-sh/bun/issues/1262
2022-09-20 01:02:15 -07:00
Jarred Sumner
f0bc50eb71 meant to include this in the previous commit 2022-09-20 00:45:19 -07:00
Jarred Sumner
6163fb830e Add navigator.userAgent , navigator.hardwareConcurrency 2022-09-20 00:44:59 -07:00
Jarred Sumner
167948f5c3 Fix incorrect hostname logic
Fixes https://github.com/oven-sh/bun/issues/1261
2022-09-20 00:07:01 -07:00
Jarred Sumner
37d191bc02 Update process.argv to more closely match node 2022-09-19 23:37:26 -07:00
Jarred Sumner
da7b648971 Pass through arguments unmodified after bun run <script> or bun <script>
Fixes https://github.com/oven-sh/bun/issues/231
2022-09-19 23:37:08 -07:00
Jarred Sumner
8b7f43f855 Handle nested files more correctly with "imports" in package.json 2022-09-19 21:02:26 -07:00
Jarred Sumner
21770eb0f3 Implement imports in package.json (#foo imports)
Fixes https://github.com/oven-sh/bun/issues/478
Fixes https://github.com/oven-sh/bun/issues/234
Fixes https://github.com/oven-sh/bun/issues/822
2022-09-19 20:03:02 -07:00
Jarred Sumner
17be8023d9 Fix broken destructors 2022-09-19 17:26:30 -07:00
Jarred Sumner
9754c5b32b Fix larger bodies 2022-09-19 05:50:10 -07:00
Jarred Sumner
a16cb39423 Improve the perf of reading HTTP request body 2022-09-18 18:45:34 -07:00
Jarred Sumner
dfefb05b10 Fix occasional crash with .json() 2022-09-18 18:37:55 -07:00
Jarred Sumner
55bdf2682c Update build-id 2022-09-18 04:09:03 -07:00
Jarred Sumner
3a50ae92ec Fix broken sending http body 2022-09-18 04:00:40 -07:00
Jarred Sumner
fe77f6a2f3 Update http_client_async.zig 2022-09-18 02:34:58 -07:00
Jarred Sumner
cd35218141 Add a way to disable timeout and keepalive 2022-09-18 02:30:52 -07:00
Jarred Sumner
daeef8d5b3 extremely minor perf nit 2022-09-17 22:14:38 -07:00
Kit PANG
184230058a feat: env loader nested values with curly braces (#1246)
* [env loader] Add support for nested value with curly braces

does not support default values for nested values, e.g., ${undefined:default}, ${undefined:-default}, or ${undefined-default}

* fix: minor fix and add more test

* [env loader] Improve nested value parsing performance

remove unnecessary branching

Co-authored-by: Like <like@ekil.sh>
2022-09-17 22:11:16 -07:00
Jarred Sumner
a08b323e61 Fix napi module registration
Fixes https://github.com/oven-sh/bun/issues/1240
2022-09-17 21:56:30 -07:00
Jarred Sumner
745cc5c655 Handle missing 0\r\n chunk in HTTP client 2022-09-17 21:45:03 -07:00
Jarred Sumner
3719c3b736 Update & configure SSL a little 2022-09-17 21:45:03 -07:00
Jarred Sumner
0e424de684 Update WebKit 2022-09-17 21:45:03 -07:00
Jarred Sumner
285ef0ca01 Explicitly enable ShadowRealm 2022-09-17 21:45:03 -07:00
Greg Brimble
ce0df52b7e Update macOS contributing instructions (#1247) 2022-09-17 17:49:46 -07:00
Jarred Sumner
e03204dccf Avoid undefined memory 2022-09-17 17:41:13 -07:00
Jarred Sumner
0dea2d8515 Smaller stack 2022-09-17 17:40:50 -07:00
Jarred Sumner
31469bb05b Prevent returning resolved promises 2022-09-17 04:39:59 -07:00
Jarred Sumner
b4f8e5cdb9 Fix default hostname 2022-09-17 04:31:29 -07:00
Jarred Sumner
cefec77646 Partially implement server.fetch() on Bun.serve 2022-09-17 04:28:32 -07:00
Hyro
7c7adc1361 chore: add napi label (#1245) 2022-09-17 02:54:41 -07:00
Jarred Sumner
af6609b0a3 [bun install] Add a package index via symlinks to ~/.bun/install/cache 2022-09-17 01:12:59 -07:00
Jarred Sumner
3ae950d829 Fix missing reason and code in CloseEvent
cc @paperdave

hardcoded right now but at least tells you why it closed
2022-09-17 00:42:20 -07:00
Jarred Sumner
c2f64d4da1 Fix crash when specifying same package name twice in bun add
Fixes https://github.com/oven-sh/bun/issues/1202
2022-09-17 00:21:10 -07:00
Jarred Sumner
9b941dd800 Update build-id 2022-09-16 22:58:31 -07:00
Jarred Sumner
4b9f6baf79 Make fetch throw a SystemError on reject 2022-09-16 22:50:46 -07:00
Jarred Sumner
a675cbd13b Fix issue with chunked transfer encoding 2022-09-16 22:38:09 -07:00
Jarred Sumner
bd77afb2df Fix issue with server not starting before exiting 2022-09-16 22:36:06 -07:00
Jarred Sumner
681f5a521f [bun install] Remove spinloop 2022-09-16 16:53:17 -07:00
Jarred Sumner
f55b9a8530 Fix origin missing protocol in URL
Fixes https://github.com/oven-sh/bun/issues/1244
2022-09-16 16:45:26 -07:00
Jarred Sumner
da6f954e0d Fix process not exiting 2022-09-16 14:28:07 -07:00
Jarred Sumner
453eaf6871 Fix crash when parsing empty JSON file 2022-09-16 03:20:28 -07:00
Jarred Sumner
0ce709d96a Make new HTTP client more stable 2022-09-16 00:53:03 -07:00
Jarred Sumner
fd808dec52 Use entropy cache for websocket mask 2022-09-14 21:35:12 -07:00
Jarred Sumner
ac949f8181 Fix issue with websockets callback not registering in canary 2022-09-14 21:34:29 -07:00
Jarred Sumner
48c2c8c049 woops that was wrong 2022-09-14 19:29:16 -07:00
Jarred Sumner
2e2e134a1b typo 2022-09-14 19:25:16 -07:00
Jarred Sumner
4e8bd97d9c Update crypto.mjs 2022-09-14 19:24:56 -07:00
Jarred Sumner
a31eb6a80c Add missing getRandomValues to crypto polyfill 2022-09-14 19:15:05 -07:00
Jarred Sumner
b0dd7bee5b Update crypto benchmark 2022-09-14 18:25:06 -07:00
Jarred Sumner
a291c1676f 5x faster crypto.randomValues() 2022-09-14 18:23:22 -07:00
Jarred Sumner
7bfa302b75 Make crypto.getRandomValues() faster + fix > 1 byte/element typed arrays
Fix crypto.getRandomValues() with > 1 byte element typed arrays

Fixes https://github.com/oven-sh/bun/issues/1237
2022-09-14 04:12:32 -07:00
Jarred Sumner
0935ab14d6 Fix Linux 200ms http client delay
https://man7.org/linux/man-pages/man2/send.2.html See the section on MSG_MORE
2022-09-13 17:47:50 -07:00
Jarred Sumner
9797b676b1 Add test 2022-09-11 17:11:23 -07:00
Jarred Sumner
2b02f7eb99 Fix bug with Buffer.from([123], "utf8")
cc @worm-emoji
2022-09-11 17:11:11 -07:00
Jarred Sumner
71e2c26577 Resolve rope strings in dynamic import paths
Fixes https://github.com/oven-sh/bun/issues/1230
2022-09-11 15:30:21 -07:00
Jarred Sumner
b78b36ce33 Fix build issue on Linux? 2022-09-11 15:01:57 -07:00
Jarred Sumner
0130efeedf Hardcode localhost on macOS 2022-09-11 14:59:48 -07:00
Jarred Sumner
35b51fcbb5 typo 2022-09-11 14:46:08 -07:00
Jarred Sumner
9a5aa059f9 New HTTP client (#1231)
* wip

* It mostly works!

* Support `bun install`

* Support `bun create`

* Support chunked transfer encoding

* Handle Keep Alive when redirecting to a different domain

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2022-09-11 13:37:17 -07:00
Zilin Zhu
8b91360a33 Fix segfault due to GC and some more helper functions (#1221)
* Fix segfault due to GC and some more helper functions

* fix upon reviews

* add visitChildren
2022-09-09 22:48:55 -07:00
Jarred Sumner
85d80d8fb7 Update README.md 2022-09-09 19:49:38 -07:00
Jarred Sumner
695da9ee29 Fix import path issue in ffi bench 2022-09-09 19:45:39 -07:00
Jarred Sumner
d114e9040b Add read to README 2022-09-09 19:45:20 -07:00
Jarred Sumner
c600196b1a [node:fs] Fix readFileSync on non-regular files
Fixes https://github.com/oven-sh/bun/issues/1220
2022-09-09 19:26:02 -07:00
Jarred Sumner
3d8edcb77b Fix potential crash when returning an empty string 2022-09-09 19:20:24 -07:00
Jarred Sumner
f496740c19 [bun:ffi] Add f32, f64, i64, u64 to read` 2022-09-09 18:10:36 -07:00
Jarred Sumner
0c2a207d82 Fix failing tests after ptr change 2022-09-09 17:19:34 -07:00
Jarred Sumner
e9c456ff5c [breaking][bun:ffi] Change the pointer representation to be a 52-bit integer
Storing the pointer this way enables DOMJIT to be used with a new API in `bun:ffi` that lets you efficiently read values from a pointer without creating a new `DataView`

```js
import {read} from 'bun:ffi';
const myPtr = myFunctionThatReturnsAPtr();

// new:
const value = read.u32(myPtr, 0);

// old:
const view = new DataView(toArrayBuffer(myPtr));
const otherValue = view.getUint32(0, true);
```

cc @bwasti this might be a breaking change for that call to `napi_add_finalizer`
2022-09-09 03:12:03 -07:00
Jarred Sumner
bcbe1b410a Last commit was missing some code 2022-09-08 23:37:59 -07:00
Jarred Sumner
206820d27a [bun:ffi] Implement read.{u8,i8,i16,i32,u16,u32,ptr,intptr}
`read` in `bun:ffi` lets you read data from a pointer without creating a new DataView/ArrayBufferView

```
import {read} from 'bun:ffi';

    expect(read.i8(ptr_, i)).toBe(view.getInt8(i, true));
    expect(read.i16(ptr_, i)).toBe(view.getInt16(i, true));
    expect(read.i32(ptr_, i)).toBe(view.getInt32(i, true));
    expect(read.u8(ptr_, i)).toBe(view.getUint8(i, true));
    expect(read.u16(ptr_, i)).toBe(view.getUint16(i, true));
    expect(read.u32(ptr_, i)).toBe(view.getUint32(i, true));
  }
```
2022-09-08 23:29:30 -07:00
Zilin Zhu
8d8b72cf3f Add native helper functions for Readable and convert ReadableState properties to getter/setter (#1218) 2022-09-08 19:52:27 -07:00
Jarred Sumner
a3cc9aaf6f Make some more globals modifiable 2022-09-08 00:00:18 -07:00
Jarred Sumner
812424bf46 Fix crash with file descriptor 2022-09-07 21:21:18 -07:00
Jarred Sumner
8af05c28a3 Add benchmark for small write() performance 2022-09-07 21:20:41 -07:00
Jarred Sumner
970600724d Helper for seeing if a File Blob is seekable 2022-09-07 21:06:00 -07:00
Jarred Sumner
c038f513d3 [Bun.write] clean up some error handling 2022-09-07 20:59:51 -07:00
Jarred Sumner
1e5978ad4f Bun.write - only truncate if its a path string 2022-09-07 19:59:49 -07:00
Jarred Sumner
2dbc991af9 More tests for Bun.write 2022-09-07 19:58:04 -07:00
Jarred Sumner
c4b9c12677 Fix flaky tests 2022-09-07 19:56:23 -07:00
Jarred Sumner
d7759b88ee Handle default better with ESM node 2022-09-07 19:56:11 -07:00
Jarred Sumner
25e4fcf5c8 Fast path for Bun.write with short-ish strings & typed arrays
Helps with https://github.com/oven-sh/bun/issues/646 but does not fully fix
2022-09-07 19:54:51 -07:00
Jarred Sumner
ce382788b0 Mild perf improvement for bindings 2022-09-07 19:53:49 -07:00
728 changed files with 55211 additions and 9636 deletions

View File

@@ -1,44 +0,0 @@
name: 🐛 Bug report
description: Create a report to help us improve
labels: [bug, need repro]
body:
- type: markdown
attributes:
value: |
Thank you for reporting an issue.
This issue tracker is for bugs and issues found within bun.
If you require more general support please reach out to our [discord server](https://bun.sh/discord).
Please fill in as much of the following form as you're able.
- type: input
attributes:
label: Version
description: Output of `bun -v`
- type: input
attributes:
label: Platform
description: |
UNIX: output of `uname -a`
Windows: output of `"$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"` in PowerShell console
- type: textarea
attributes:
label: What steps will reproduce the bug?
description: Enter details about your bug, preferably a simple code snippet that can be run using `bun` directly without installing third-party dependencies.
- type: textarea
attributes:
label: How often does it reproduce? Is there a required condition?
- type: textarea
attributes:
label: What is the expected behavior?
description: If possible, please provide textual output instead of screenshots.
- type: textarea
attributes:
label: What do you see instead?
description: If possible, please provide textual output instead of screenshots.
validations:
required: true
- type: textarea
attributes:
label: Additional information
description: Tell us anything else you think we should know.

View File

@@ -0,0 +1,35 @@
name: 📥 Install Problem
description: Report an issue during install or upgrade
labels: [bug, install]
body:
- type: markdown
attributes:
value: |
Thank you for submitting a bug report. It helps make Bun better.
If you need help or support using Bun, and are not reporting an issue, please
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can ask questions in the [`#help`](https://discord.gg/32EtH6p7HN) forum.
Please try to include as much information as possible.
- type: input
attributes:
label: What platform is your computer?
description: |
For MacOS and Linux: copy the output of `uname -mprsv`
For Windows: copy the output of `"$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"` in the PowerShell console
- type: textarea
attributes:
label: How did you attempt to install or upgrade?
description: Please provide the commands you ran to install or upgrade.
validations:
required: true
- type: textarea
attributes:
label: What do you see instead?
description: If possible, please provide text instead of a screenshot.
validations:
required: true
- type: textarea
attributes:
label: Additional information
description: Is there anything else you think we should know?

44
.github/ISSUE_TEMPLATE/2-bug-report.yml vendored Normal file
View File

@@ -0,0 +1,44 @@
name: 🐛 Bug Report
description: Report an issue that should be fixed
labels: [bug, need repro]
body:
- type: markdown
attributes:
value: |
Thank you for submitting a bug report. It helps make Bun better.
If you need help or support using Bun, and are not reporting a bug, please
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can ask questions in the [`#help`](https://discord.gg/32EtH6p7HN) forum.
Please try to include as much information as possible.
- type: input
attributes:
label: What version of Bun is running?
description: Copy the output of `bun -v`
- type: input
attributes:
label: What platform is your computer?
description: |
For MacOS and Linux: copy the output of `uname -mprsv`
For Windows: copy the output of `"$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"` in the PowerShell console
- type: textarea
attributes:
label: What steps can reproduce the bug?
description: Enter the details about your bug. If possible, please provide a small code snippet that can reproduce the issue.
- type: textarea
attributes:
label: How often does it reproduce? Is there a required condition?
- type: textarea
attributes:
label: What is the expected behavior?
description: If possible, please provide text instead of a screenshot.
- type: textarea
attributes:
label: What do you see instead?
description: If possible, please provide text instead of a screenshot.
validations:
required: true
- type: textarea
attributes:
label: Additional information
description: Is there anything else you think we should know?

View File

@@ -1,25 +0,0 @@
name: 🚀 Feature request
description: Suggest an idea for this project
labels: [enhancement]
body:
- type: markdown
attributes:
value: |
Thank you for suggesting an idea to make bun better.
Please fill in as much of the following form as you're able.
For more information on development, please reach out to our [discord server](https://bun.sh/discord).
- type: textarea
attributes:
label: What is the problem this feature will solve?
validations:
required: true
- type: textarea
attributes:
label: What is the feature you are proposing to solve the problem?
validations:
required: true
- type: textarea
attributes:
label: What alternatives have you considered?

View File

@@ -1,18 +0,0 @@
name: 📗 Open an issue regarding the bun docs
description: Let us know about any problematic documentations
labels: [documentation]
body:
- type: markdown
attributes:
value: |
Thank you for wanting to make bun better!
Please fill in as much of the following form as you're able.
- type: input
attributes:
label: Affected URL(s)
- type: textarea
attributes:
label: Description of the problem
validations:
required: true

View File

@@ -0,0 +1,24 @@
name: 🚀 Feature Request
description: Suggest an idea, feature, or enhancement
labels: [enhancement]
body:
- type: markdown
attributes:
value: |
Thank you for submitting an idea. It helps make Bun better.
If you want to discuss Bun, or learn how others are using Bun, please
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can share in the [`#feedback-ideas`](https://discord.gg/unwUnHBNqy) channel.
- type: textarea
attributes:
label: What is the problem this feature would solve?
validations:
required: true
- type: textarea
attributes:
label: What is the feature you are proposing to solve the problem?
validations:
required: true
- type: textarea
attributes:
label: What alternatives have you considered?

View File

@@ -0,0 +1,31 @@
name: 📗 Documentation Request
description: Tell us if there is missing or incorrect documentation
labels: [documentation]
body:
- type: markdown
attributes:
value: |
Thank you for submitting a documentation request. It helps make Bun better.
We are working on moving documentation from the [README](https://github.com/oven-sh/bun#table-of-contents) to a documentation website. Please report as many issues or missing content requests as you can so we can incoperate that in the new documentation.
- type: dropdown
attributes:
label: What is the type of issue?
multiple: true
options:
- Documentation is missing
- Documentation is incorrect
- Documentation is confusing
- Example code is not working
- Something else
validations:
required: true
- type: textarea
attributes:
label: What is the issue?
validations:
required: true
- type: textarea
attributes:
label: Where did you find it?
description: If possible, please provide the URL(s) where you found this issue.

View File

@@ -1,5 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Discord server
- name: 💬 Ask a Question
url: https://discord.com/invite/CXdq2DP29u
about: Please visit our Discord server for questions and support requests.
about: Join our Discord server for questions, support requests, or just to chat.

2
.github/labels.yml vendored
View File

@@ -24,6 +24,8 @@
color: 'c66037'
- name: 'node.js'
color: '0E8A16'
- name: 'napi'
color: 'BE05D2'
- name: 'esm<>cjs'
color: '7dcde3'
- name: 'performance'

29
.github/workflows/bun-homebrew.yml vendored Normal file
View File

@@ -0,0 +1,29 @@
name: bun-homebrew
on:
release:
types:
- published
jobs:
docker:
runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh'
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 }}

View File

@@ -37,21 +37,21 @@ jobs:
arch: x86_64
build_arch: amd64
runner: linux-amd64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-linux-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
- cpu: westmere
tag: linux-x64-baseline
arch: x86_64
build_arch: amd64
runner: linux-amd64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-linux-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
- cpu: native
tag: linux-aarch64
arch: aarch64
build_arch: arm64
runner: linux-arm64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-linux-arm64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-linux-arm64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-arm64-lto"
steps:
@@ -76,8 +76,8 @@ jobs:
with:
context: .
push: false
cache-from: type=registry,ref=ghcr.io/oven-sh/bun-obj:buildcache-bust-3--${{matrix.cpu}}-${{matrix.build_arch}}
cache-to: type=registry,ref=ghcr.io/oven-sh/bun-obj:buildcache-bust-3--${{matrix.cpu}}-${{matrix.build_arch}},mode=max
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
ARCH=${{matrix.arch}}
BUILDARCH=${{matrix.build_arch}}

View File

@@ -28,6 +28,7 @@ jobs:
macos-object-files:
name: macOS Object
runs-on: zig-object
concurrency: macos
strategy:
matrix:
include:
@@ -63,8 +64,8 @@ jobs:
context: .
push: false
tags: ghcr.io/oven-sh/bun-obj:${{github.sha}}-${{matrix.cpu}}-${{matrix.arch}}-macos
cache-from: type=registry,ref=ghcr.io/oven-sh/bun-obj:buildcache-bust-3--${{matrix.cpu}}-${{matrix.arch}}-macos
cache-to: type=registry,ref=ghcr.io/oven-sh/bun-obj:buildcache-bust-3--${{matrix.cpu}}-${{matrix.arch}}-macos,mode=max
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
ARCH=${{ matrix.arch }}
BUILDARCH=amd64
@@ -91,7 +92,7 @@ jobs:
# 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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: haswell
@@ -100,7 +101,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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: westmere
@@ -109,7 +110,7 @@ jobs:
# 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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: haswell
@@ -118,7 +119,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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: native
@@ -126,7 +127,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/aug27/bun-webkit-macos-arm64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
dependencies: true
compile_obj: true
@@ -194,7 +195,7 @@ jobs:
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
mkdir -p $OBJ_DIR
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
make clean-bindings
make -j $(sysctl -n hw.ncpu) release-bindings
- name: Upload C++
@@ -225,7 +226,7 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
@@ -233,14 +234,14 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/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/aug27/bun-webkit-macos-arm64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -304,7 +305,7 @@ jobs:
rm -rf packages/${{ matrix.package }}
mkdir -p packages/${{ matrix.package }}
mv ${{ runner.temp }}/release/* packages/${{ matrix.package }}/
make bun-link-lld-release copy-to-bun-release-dir-bin
make webcrypto bun-link-lld-release copy-to-bun-release-dir-bin
- name: Zip
env:
CPU_TARGET: ${{ matrix.cpu }}

View File

@@ -28,6 +28,7 @@ jobs:
macos-object-files:
name: macOS Object
runs-on: zig-object
concurrency: macos
strategy:
matrix:
include:
@@ -63,8 +64,8 @@ jobs:
context: .
push: false
tags: ghcr.io/oven-sh/bun-obj:${{github.sha}}-${{matrix.cpu}}-${{matrix.arch}}-macos-baseline
cache-from: type=registry,ref=ghcr.io/oven-sh/bun-obj:buildcache-bust-3--${{matrix.cpu}}-${{matrix.arch}}-macos-baseline
cache-to: type=registry,ref=ghcr.io/oven-sh/bun-obj:buildcache-bust-3--${{matrix.cpu}}-${{matrix.arch}}-macos-baseline,mode=max
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
ARCH=${{ matrix.arch }}
BUILDARCH=amd64
@@ -91,7 +92,7 @@ jobs:
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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: haswell
@@ -100,7 +101,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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: westmere
@@ -109,7 +110,7 @@ jobs:
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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: haswell
@@ -118,7 +119,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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: native
@@ -126,7 +127,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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
@@ -175,7 +176,7 @@ jobs:
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
mkdir -p $BUN_DEPS_OUT_DIR
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
make vendor-without-check
- name: Compile C++
if: matrix.compile_obj
@@ -189,7 +190,7 @@ jobs:
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
mkdir -p $OBJ_DIR
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
make -j $(sysctl -n hw.ncpu) release-bindings
- name: Upload C++
if: matrix.compile_obj
@@ -219,7 +220,7 @@ jobs:
package: bun-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64-baseline
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
@@ -227,14 +228,14 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -301,7 +302,7 @@ jobs:
rm -rf packages/${{ matrix.package }}
mkdir -p packages/${{ matrix.package }}
mv ${{ runner.temp }}/release/* packages/${{ matrix.package }}/
make bun-link-lld-release copy-to-bun-release-dir-bin
make webcrypto bun-link-lld-release copy-to-bun-release-dir-bin
- name: Zip
env:
CPU_TARGET: ${{ matrix.cpu }}

View File

@@ -28,6 +28,7 @@ jobs:
macos-object-files:
name: macOS Object
runs-on: zig-object
concurrency: macos
strategy:
matrix:
include:
@@ -62,9 +63,8 @@ jobs:
with:
context: .
push: false
tags: ghcr.io/oven-sh/bun-obj:${{github.sha}}-${{matrix.cpu}}-${{matrix.arch}}-macos
cache-from: type=registry,ref=ghcr.io/oven-sh/bun-obj:buildcache-bust-3--${{matrix.cpu}}-${{matrix.arch}}-macos
cache-to: type=registry,ref=ghcr.io/oven-sh/bun-obj:buildcache-bust-3--${{matrix.cpu}}-${{matrix.arch}}-macos,mode=max
cache-from: type=gha
cache-to: type=gha,mode=min
build-args: |
ARCH=${{ matrix.arch }}
BUILDARCH=amd64
@@ -91,7 +91,7 @@ jobs:
# 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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: haswell
@@ -100,7 +100,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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: westmere
@@ -109,7 +109,7 @@ jobs:
# 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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: haswell
@@ -118,7 +118,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/aug27/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: native
@@ -126,7 +126,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/aug27/bun-webkit-macos-arm64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
@@ -177,7 +177,7 @@ jobs:
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
mkdir -p $BUN_DEPS_OUT_DIR
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
make vendor-without-check
- name: Compile C++
if: matrix.compile_obj
@@ -191,7 +191,7 @@ jobs:
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
mkdir -p $OBJ_DIR
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
make -j $(sysctl -n hw.ncpu) release-bindings
- name: Upload C++
if: matrix.compile_obj
@@ -221,7 +221,7 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-amd64-lto.tar.gz"
- cpu: haswell
arch: x86_64
tag: bun-darwin-x64
@@ -229,14 +229,14 @@ jobs:
package: bun-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/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/aug27/bun-webkit-macos-arm64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct8/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -303,7 +303,7 @@ jobs:
rm -rf packages/${{ matrix.package }}
mkdir -p packages/${{ matrix.package }}
mv ${{ runner.temp }}/release/* packages/${{ matrix.package }}/
make bun-link-lld-release copy-to-bun-release-dir-bin
make webcrypto bun-link-lld-release copy-to-bun-release-dir-bin
- name: Zip
env:
CPU_TARGET: ${{ matrix.cpu }}

9
.gitmodules vendored
View File

@@ -7,7 +7,7 @@ shallow = true
fetchRecurseSubmodules = false
[submodule "src/javascript/jsc/WebKit"]
path = src/bun.js/WebKit
url = https://github.com/Jarred-Sumner/WebKit.git
url = https://github.com/oven-sh/WebKit.git
ignore = dirty
depth = 1
update = none
@@ -69,3 +69,10 @@ ignore = dirty
depth = 1
shallow = true
fetchRecurseSubmodules = false
[submodule "src/deps/oniguruma"]
path = src/deps/oniguruma
url = https://github.com/kkos/oniguruma
ignore = dirty
depth = 1
shallow = true
fetchRecurseSubmodules = false

View File

@@ -8,12 +8,21 @@
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/WTF/Headers",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/*",
"${workspaceFolder}/src/bun.js/bindings/",
"${workspaceFolder}/src/bun.js/bindings/sqlite/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/",
"${workspaceFolder}/src/deps/boringssl/include/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/openssl/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/algorithms/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/parameters/",
"${workspaceFolder}/src/bun.js/builtins/",
"${workspaceFolder}/src/bun.js/builtins/cpp",
"${workspaceFolder}/src/bun.js/bindings/WebCore/",
"${workspaceFolder}/src/bun.js/WebKit/Source/bmalloc/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/ICU/Headers/",
"${workspaceFolder}/../webkit-build/include/"
"${workspaceFolder}/../webkit-build/include/",
"${workspaceFolder}/src/deps",
"${workspaceFolder}/src/deps/uws/uSockets/src"
],
"browse": {
"path": [
@@ -25,10 +34,18 @@
"${workspaceFolder}/src/bun.js/bindings/**",
"${workspaceFolder}/src/bun.js/modules/**",
"${workspaceFolder}/src/bun.js/builtins/**",
"${workspaceFolder}/src/deps/boringssl/include/",
"${workspaceFolder}/src/bun.js/bindings/sqlite/",
"${workspaceFolder}/src/bun.js/builtins/cpp/**",
"${workspaceFolder}/src/bun.js/WebKit/Source/bmalloc/**",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/ICU/Headers/",
"${workspaceFolder}/../webkit-build/include/"
"${workspaceFolder}/src/bun.js/bindings/webcrypto/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/openssl/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/algorithms/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/parameters/",
"${workspaceFolder}/../webkit-build/include/",
"${workspaceFolder}/src/deps",
"${workspaceFolder}/src/deps/uws/uSockets/src"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ".vscode/cppdb"
@@ -45,7 +62,7 @@
"DU_DISABLE_RENAMING=1"
],
"macFrameworkPath": [],
"compilerPath": "clang++",
"compilerPath": "/opt/homebrew/opt/llvm/bin/clang++",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "macos-clang-x64"

2
.vscode/launch.json generated vendored
View File

@@ -29,7 +29,7 @@
"type": "lldb",
"request": "launch",
"name": "bun run current file",
"program": "/build/bun/packages/debug-bun-linux-x64/bun-debug",
"program": "bun-debug",
"args": ["${file}"],
"cwd": "${file}/../../",
"env": {

View File

@@ -8,8 +8,8 @@
"search.useIgnoreFiles": true,
"zig.buildOnSave": false,
"[zig]": {
"editor.tabSize": 4,
"editor.useTabStops": false,
"editor.tabSize": 4,
"editor.useTabStops": false,
"editor.defaultFormatter": "AugusteRame.zls-vscode",
"editor.formatOnSave": true
},
@@ -87,6 +87,7 @@
"editor.defaultFormatter": "xaver.clang-format"
},
"files.associations": {
"*.lock": "yarnlock",
"*.idl": "cpp",
"memory": "cpp",
"iostream": "cpp",
@@ -178,7 +179,8 @@
"ctype.h": "c",
"ethernet.h": "c",
"inet.h": "c",
"packet.h": "c"
"packet.h": "c",
"queue": "cpp"
},
"cmake.configureOnOpen": false
}

View File

@@ -16,7 +16,7 @@ ARG WEBKIT_URL="https://github.com/oven-sh/WebKit/releases/download/$WEBKIT_TAG/
ARG ZIG_URL="https://github.com/oven-sh/zig/releases/download/$ZIG_TAG/zig-linux-$BUILDARCH.zip"
ARG GIT_SHA=""
ARG BUN_BASE_VERSION=0.1
ARG BUN_BASE_VERSION=0.2
FROM bitnami/minideb:bullseye as bun-base
@@ -183,8 +183,29 @@ RUN install_packages autoconf automake libtool pkg-config
COPY Makefile ${BUN_DIR}/Makefile
COPY src/deps/libarchive ${BUN_DIR}/src/deps/libarchive
RUN cd $BUN_DIR && \
make libarchive && rm -rf src/deps/libarchive Makefile
FROM bun-base as oniguruma
ARG DEBIAN_FRONTEND
ARG GITHUB_WORKSPACE
ARG ZIG_PATH
# Directory extracts to "bun-webkit"
ARG WEBKIT_DIR
ARG BUN_RELEASE_DIR
ARG BUN_DEPS_OUT_DIR
ARG BUN_DIR
ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
RUN install_packages autoconf automake libtool pkg-config
COPY Makefile ${BUN_DIR}/Makefile
COPY src/deps/oniguruma ${BUN_DIR}/src/deps/oniguruma
WORKDIR $BUN_DIR
RUN make libarchive && rm -rf src/deps/libarchive Makefile
RUN make oniguruma && rm -rf src/deps/oniguruma Makefile
FROM bun-base as tinycc
@@ -456,20 +477,24 @@ WORKDIR $BUN_DIR
ENV JSC_BASE_DIR=${WEBKIT_DIR}
ENV LIB_ICU_PATH=${WEBKIT_DIR}/lib
COPY --from=boringssl ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=zlib ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=lolhtml ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=mimalloc ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=libarchive ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=oniguruma ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=picohttp ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=boringssl ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=uws ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=uws ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=libbacktrace ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=zlib ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=tinycc ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=base64 ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
RUN cd $BUN_DIR && mkdir -p src/bun.js/bindings-obj && rm -rf $HOME/.cache zig-cache && mkdir -p $BUN_RELEASE_DIR && \
make release-bindings -j10 && mv src/bun.js/bindings-obj/* /tmp
# Required for `make webcrypto`
COPY src/deps/boringssl/include ${BUN_DIR}/src/deps/boringssl/include
RUN cd $BUN_DIR && mkdir -p src/bun.js/bindings-obj && rm -rf $HOME/.cache zig-cache && mkdir -p $BUN_RELEASE_DIR && make webcrypto && \
make release-bindings -j10 && mv ${BUN_DEPS_OUT_DIR}/libwebcrypto.a /tmp && mv src/bun.js/bindings-obj/* /tmp
FROM prepare_release as sqlite
@@ -494,6 +519,7 @@ RUN cd $BUN_DIR && make sqlite
FROM scratch as build_release_cpp
COPY --from=compile_cpp /tmp/*.o /
COPY --from=compile_cpp /tmp/libwebcrypto.a /
FROM prepare_release as build_release
@@ -515,20 +541,22 @@ WORKDIR $BUN_DIR
ENV JSC_BASE_DIR=${WEBKIT_DIR}
ENV LIB_ICU_PATH=${WEBKIT_DIR}/lib
COPY --from=zlib ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=libarchive ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=base64 ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=boringssl ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=libbacktrace ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=lolhtml ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=mimalloc ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=libarchive ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=oniguruma ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=picohttp ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=boringssl ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=sqlite ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=tinycc ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=uws ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=uws ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=libbacktrace ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=zlib ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=tinycc ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=base64 ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=sqlite ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=build_release_obj /*.o /tmp
COPY --from=build_release_cpp /*.o ${BUN_DIR}/src/bun.js/bindings-obj/
COPY --from=build_release_cpp /*.a ${BUN_DEPS_OUT_DIR}/
RUN cd $BUN_DIR && mkdir -p ${BUN_RELEASE_DIR} && make bun-relink copy-to-bun-release-dir && \
rm -rf $HOME/.cache zig-cache misctools package.json build-id completions build.zig $(BUN_DIR)/packages

View File

@@ -88,7 +88,7 @@ RUN cd $GITHUB_WORKSPACE && \
rm zig-linux-$BUILDARCH.zip;
RUN cd $GITHUB_WORKSPACE && \
curl -o bun-webkit-linux-$BUILDARCH.tar.gz -L https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-linux-$BUILDARCH.tar.gz && \
curl -o bun-webkit-linux-$BUILDARCH.tar.gz -L https://github.com/oven-sh/WebKit/releases/download/oct8/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

129
Makefile
View File

@@ -35,6 +35,7 @@ NATIVE_OR_OLD_MARCH = -march=westmere
endif
MIN_MACOS_VERSION ?= $(DEFAULT_MIN_MACOS_VERSION)
BUN_BASE_VERSION = 0.2
AR=
@@ -50,7 +51,7 @@ RELEASE_BUN = $(PACKAGE_DIR)/bun
DEBUG_BIN = $(DEBUG_PACKAGE_DIR)/
DEBUG_BUN = $(DEBUG_BIN)/bun-debug
BUILD_ID = $(shell cat ./build-id)
PACKAGE_JSON_VERSION = 0.1.$(BUILD_ID)
PACKAGE_JSON_VERSION = $(BUN_BASE_VERSION).$(BUILD_ID)
BUN_BUILD_TAG = bun-v$(PACKAGE_JSON_VERSION)
BUN_RELEASE_BIN = $(PACKAGE_DIR)/bun
PRETTIER ?= $(shell which prettier || echo "./node_modules/.bin/prettier")
@@ -267,36 +268,39 @@ DEBUG_MODULES_OBJ_FILES := $(patsubst $(MODULES_DIR)/%.cpp,$(DEBUG_OBJ_DIR)/%.o,
BINDINGS_OBJ := $(OBJ_FILES) $(WEBCORE_OBJ_FILES) $(SQLITE_OBJ_FILES) $(NODE_OS_OBJ_FILES) $(BUILTINS_OBJ_FILES) $(IO_FILES) $(MODULES_OBJ_FILES)
DEBUG_BINDINGS_OBJ := $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG_SQLITE_OBJ_FILES) $(DEBUG_NODE_OS_OBJ_FILES) $(DEBUG_BUILTINS_OBJ_FILES) $(DEBUG_IO_FILES) $(DEBUG_MODULES_OBJ_FILES)
MAC_INCLUDE_DIRS := -I$(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders \
-I$(WEBKIT_RELEASE_DIR)/WTF/Headers \
ALL_JSC_INCLUDE_DIRS := -I$(WEBKIT_RELEASE_DIR)/WTF/Headers \
-I$(WEBKIT_RELEASE_DIR)/ICU/Headers \
-I$(WEBKIT_RELEASE_DIR)/bmalloc/Headers \
-I$(WEBKIT_RELEASE_DIR)/ \
-Isrc/bun.js/bindings/ \
-Isrc/bun.js/builtins/ \
-Isrc/bun.js/bindings/webcore \
-Isrc/bun.js/bindings/sqlite \
-Isrc/bun.js/builtins/cpp \
-Isrc/bun.js/bindings/node_os \
-Isrc/bun.js/modules \
-I$(WEBKIT_DIR)/Source/bmalloc \
-I$(WEBKIT_DIR)/Source \
-I$(WEBKIT_RELEASE_DIR)/include \
-I$(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders \
-I$(WEBKIT_RELEASE_DIR)/bmalloc/PrivateHeaders \
-I$(WEBKIT_RELEASE_DIR)/WTF/PrivateHeaders
SHARED_INCLUDE_DIR = -I$(realpath src/bun.js/bindings)/ \
-I$(realpath src/bun.js/builtins/) \
-I$(realpath src/bun.js/bindings) \
-I$(realpath src/bun.js/bindings/webcore) \
-I$(realpath src/bun.js/bindings/webcrypto) \
-I$(realpath src/bun.js/bindings/sqlite) \
-I$(realpath src/bun.js/builtins/cpp) \
-I$(realpath src/bun.js/bindings/node_os) \
-I$(realpath src/bun.js/modules) \
-I$(JSC_INCLUDE_DIR)
LINUX_INCLUDE_DIRS := -I$(JSC_INCLUDE_DIR) \
-Isrc/bun.js/builtins/ \
-Isrc/bun.js/bindings/ \
-Isrc/bun.js/bindings/webcore \
-Isrc/bun.js/bindings/sqlite \
-Isrc/bun.js/builtins/cpp \
-Isrc/bun.js/bindings/node_os \
-Isrc/bun.js/modules \
MAC_INCLUDE_DIRS := $(ALL_JSC_INCLUDE_DIRS) \
$(SHARED_INCLUDE_DIR) \
-I$(WEBKIT_DIR)/Source \
LINUX_INCLUDE_DIRS := $(ALL_JSC_INCLUDE_DIRS) \
$(SHARED_INCLUDE_DIR) \
-I$(ZLIB_INCLUDE_DIR)
UWS_INCLUDE_DIR := -I$(BUN_DEPS_DIR)/uws/uSockets/src -I$(BUN_DEPS_DIR)/uws/src -I$(BUN_DEPS_DIR)
INCLUDE_DIRS := $(UWS_INCLUDE_DIR) -I$(BUN_DEPS_DIR)/mimalloc/include -Isrc/napi
INCLUDE_DIRS := $(UWS_INCLUDE_DIR) -I$(BUN_DEPS_DIR)/mimalloc/include -Isrc/napi -I$(BUN_DEPS_DIR)/boringssl/include
ifeq ($(OS_NAME),linux)
@@ -373,7 +377,7 @@ endif
SHARED_LIB_EXTENSION = .so
JSC_BINDINGS = $(BINDINGS_OBJ) $(JSC_FILES)
JSC_BINDINGS_DEBUG = $(DEBUG_BINDINGS_OBJ) $(JSC_FILES_DEBUG)
JSC_BINDINGS_DEBUG = $(DEBUG_BINDINGS_OBJ) $(JSC_FILES_DEBUG)
RELEASE_FLAGS=
DEBUG_FLAGS=
@@ -393,7 +397,8 @@ MINIMUM_ARCHIVE_FILES = -L$(BUN_DEPS_OUT_DIR) \
-lssl \
-lcrypto \
-llolhtml \
$(BUN_DEPS_OUT_DIR)/libbacktrace.a
-lonig \
$(BUN_DEPS_OUT_DIR)/libbacktrace.a \
ARCHIVE_FILES_WITHOUT_LIBCRYPTO = $(MINIMUM_ARCHIVE_FILES) \
-larchive \
@@ -438,9 +443,9 @@ BUN_LLD_FLAGS_WITHOUT_JSC = $(ARCHIVE_FILES) \
BUN_LLD_FLAGS = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES) $(BINDINGS_OBJ)
BUN_LLD_FLAGS_DEBUG = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES_DEBUG) $(DEBUG_BINDINGS_OBJ)
BUN_LLD_FLAGS_FAST = $(BUN_LLD_FLAGS_DEBUG)
BUN_LLD_FLAGS = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES) $(BINDINGS_OBJ) -lwebcrypto
BUN_LLD_FLAGS_DEBUG = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES_DEBUG) $(DEBUG_BINDINGS_OBJ) -lwebcrypto-debug
BUN_LLD_FLAGS_FAST = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES_DEBUG) $(BINDINGS_OBJ) -lwebcrypto-debug
CLANG_VERSION = $(shell $(CC) --version | awk '/version/ {for(i=1; i<=NF; i++){if($$i=="version"){split($$(i+1),v,".");print v[1]}}}')
@@ -482,9 +487,13 @@ builtins: ## to generate builtins
$(shell which python || which python2) $(realpath $(WEBKIT_DIR)/Source/JavaScriptCore/Scripts/generate-js-builtins.py) -i $(realpath src)/bun.js/builtins/js -o $(realpath src)/bun.js/builtins/cpp --framework WebCore --force
$(shell which python || which python2) $(realpath $(WEBKIT_DIR)/Source/JavaScriptCore/Scripts/generate-js-builtins.py) -i $(realpath src)/bun.js/builtins/js -o $(realpath src)/bun.js/builtins/cpp --framework WebCore --wrappers-only
rm -rf /tmp/1.h src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h.1
echo -e '// clang-format off\nnamespace Zig { class GlobalObject; }' >> /tmp/1.h
echo -e '// clang-format off\nnamespace Zig { class GlobalObject; }\n#include "root.h"\n' >> /tmp/1.h
cat /tmp/1.h src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h > src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h.1
mv src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h.1 src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h
rm -rf /tmp/1.h src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h.1
echo -e '// clang-format off\nnamespace Zig { class GlobalObject; }\n#include "root.h"\n' >> /tmp/1.h
cat /tmp/1.h src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.cpp > src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.cpp.1
mv src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.cpp.1 src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.cpp
$(SED) -i -e 's/class JSDOMGlobalObject/using JSDOMGlobalObject = Zig::GlobalObject/' src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h
# this is the one we actually build
mv src/bun.js/builtins/cpp/*JSBuiltin*.cpp src/bun.js/builtins
@@ -493,7 +502,7 @@ builtins: ## to generate builtins
generate-builtins: builtins
.PHONY: tinycc
vendor-without-check: npm-install node-fallbacks runtime_js fallback_decoder bun_error mimalloc picohttp zlib boringssl libarchive libbacktrace lolhtml usockets uws base64 tinycc
vendor-without-check: npm-install node-fallbacks runtime_js fallback_decoder bun_error mimalloc picohttp zlib boringssl libarchive libbacktrace lolhtml usockets uws base64 tinycc oniguruma
BUN_TYPES_REPO_PATH ?= $(realpath ../bun-types)
@@ -547,6 +556,13 @@ libbacktrace:
make -j$(CPUS) && \
cp ./.libs/libbacktrace.a $(BUN_DEPS_OUT_DIR)/libbacktrace.a
.PHONY: oniguruma
oniguruma:
cd $(BUN_DEPS_DIR)/oniguruma && \
autoreconf -vfi && \
CFLAGS="$(CFLAGS)" CC=$(CC) ./configure && \
make -j${CPUS} && \
cp ./src/.libs/libonig.a $(BUN_DEPS_OUT_DIR)/libonig.a
sqlite:
@@ -807,7 +823,7 @@ ifeq ($(OS_NAME),darwin)
# Hardened runtime will not work with debugging
bun-codesign-debug:
codesign --entitlements $(realpath entitlements.plist) --force --timestamp --sign "$(CODESIGN_IDENTITY)" -vvvv --deep --strict $(DEBUG_BUN)
codesign --entitlements $(realpath entitlements.debug.plist) --force --timestamp --sign "$(CODESIGN_IDENTITY)" -vvvv --deep --strict $(DEBUG_BUN)
bun-codesign-release-local:
codesign --entitlements $(realpath entitlements.plist) --options runtime --force --timestamp --sign "$(CODESIGN_IDENTITY)" -vvvv --deep --strict $(RELEASE_BUN)
@@ -855,7 +871,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} $(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} $(DEBUG_IO_FILES) $(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
@@ -868,7 +884,7 @@ MIMALLOC_OVERRIDE_FLAG ?=
bump:
expr 0.1.0 + 1 > build-id
expr 0.2.0 + 1 > build-id
.PHONY: identifier-cache
identifier-cache:
@@ -1313,7 +1329,7 @@ release-bindings: $(OBJ_DIR) $(OBJ_FILES) $(WEBCORE_OBJ_FILES) $(SQLITE_OBJ_FILE
# Do not add $(DEBUG_DIR) to this list
# It will break caching, causing you to have to wait for every .cpp file to rebuild.
.PHONY: bindings
bindings: $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG_SQLITE_OBJ_FILES) $(DEBUG_NODE_OS_OBJ_FILES) $(DEBUG_BUILTINS_OBJ_FILES) $(DEBUG_IO_FILES) $(DEBUG_MODULES_OBJ_FILES)
bindings: $(DEBUG_OBJ_DIR) $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG_SQLITE_OBJ_FILES) $(DEBUG_NODE_OS_OBJ_FILES) $(DEBUG_BUILTINS_OBJ_FILES) $(DEBUG_IO_FILES) $(DEBUG_MODULES_OBJ_FILES)
.PHONY: jsc-bindings-mac
jsc-bindings-mac: bindings
@@ -1615,6 +1631,54 @@ $(DEBUG_OBJ_DIR)/%.o: src/bun.js/modules/%.cpp
$(EMIT_LLVM_FOR_DEBUG) \
-g3 -c -o $@ $<
$(DEBUG_OBJ_DIR)/webcrypto/%.o: src/bun.js/bindings/webcrypto/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
-fno-exceptions \
-I$(SRC_DIR) \
-fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM_FOR_DEBUG) \
-g3 -c -o $@ $<
.PHONY: webcrypto-debug-obj
# Make all the .cpp files in the webcrypto directory into .o files using Makefile substitutions
webcrypto-debug-obj: $(patsubst src/bun.js/bindings/webcrypto/%.cpp, $(DEBUG_OBJ_DIR)/webcrypto/%.o, $(wildcard src/bun.js/bindings/webcrypto/*.cpp))
.PHONY: webcrypto-debug
webcrypto-debug:
rm -rf $(DEBUG_OBJ_DIR)/webcrypto $(BUN_DEPS_OUT_DIR)/libwebcrypto-debug.a
mkdir -p $(DEBUG_OBJ_DIR)/webcrypto
make webcrypto-debug-obj -j$(CPUS)
$(AR) rcs $(BUN_DEPS_OUT_DIR)/libwebcrypto-debug.a $(DEBUG_OBJ_DIR)/webcrypto/*.o
$(OBJ_DIR)/webcrypto/%.o: src/bun.js/bindings/webcrypto/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM_FOR_RELEASE) \
-g3 -c -o $@ $<
.PHONY: webcrypto-obj
# Make all the .cpp files in the webcrypto directory into .o files using Makefile substitutions
webcrypto-obj: $(patsubst src/bun.js/bindings/webcrypto/%.cpp, $(OBJ_DIR)/webcrypto/%.o, $(wildcard src/bun.js/bindings/webcrypto/*.cpp))
.PHONY: webcrypto
webcrypto:
rm -rf $(OBJ_DIR)/webcrypto $(BUN_DEPS_OUT_DIR)/libwebcrypto.a
mkdir -p $(OBJ_DIR)/webcrypto
make webcrypto-obj -j$(CPUS)
$(AR) rcs $(BUN_DEPS_OUT_DIR)/libwebcrypto.a $(OBJ_DIR)/webcrypto/*.o
sizegen:
mkdir -p $(BUN_TMP_DIR)
$(CXX) src/bun.js/headergen/sizegen.cpp -Wl,-dead_strip -Wl,-dead_strip_dylibs -fuse-ld=lld -o $(BUN_TMP_DIR)/sizegen $(CLANG_FLAGS) -O1
@@ -1782,3 +1846,4 @@ PACKAGE_MAP = --pkg-begin thread_pool $(BUN_DIR)/src/thread_pool.zig --pkg-begin
.PHONY: bun
bun: vendor identifier-cache build-obj bun-link-lld-release bun-codesign-release-local

1016
README.md

File diff suppressed because it is too large Load Diff

17
bench/fetch/bun.js Normal file
View File

@@ -0,0 +1,17 @@
import { bench, run } from "mitata";
const count = 100;
bench(`fetch(https://example.com) x ${count}`, async () => {
const requests = new Array(count);
for (let i = 0; i < requests.length; i++) {
requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then((r) =>
r.text()
);
}
await Promise.all(requests);
});
await run();

17
bench/fetch/deno.js Normal file
View File

@@ -0,0 +1,17 @@
import { bench, run } from "https://esm.run/mitata";
const count = 100;
bench(`fetch(https://example.com) x ${count}`, async () => {
const requests = new Array(count);
for (let i = 0; i < requests.length; i++) {
requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then((r) =>
r.text()
);
}
await Promise.all(requests);
});
await run();

17
bench/fetch/node.mjs Normal file
View File

@@ -0,0 +1,17 @@
import { bench, run } from "mitata";
const count = 100;
bench(`fetch(https://example.com) x ${count}`, async () => {
const requests = new Array(count);
for (let i = 0; i < requests.length; i++) {
requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then((r) =>
r.text()
);
}
await Promise.all(requests);
});
await run();

View File

@@ -1,6 +1,8 @@
import { ptr, dlopen, CString, toBuffer } from "bun:ffi";
import { run, bench, group } from "mitata";
import { ptr, dlopen, CString } from "bun:ffi";
const { napiNoop, napiHash, napiString } = require("./src/ffi_napi_bench.node");
const { napiNoop, napiHash, napiString } = require(import.meta.dir +
"/src/ffi_napi_bench.node");
const {
symbols: {
@@ -8,7 +10,7 @@ const {
ffi_hash: { native: ffi_hash },
ffi_string: { native: ffi_string },
},
} = dlopen("./src/ffi_napi_bench.node", {
} = dlopen(import.meta.dir + "/src/ffi_napi_bench.node", {
ffi_noop: { args: [], returns: "void" },
ffi_string: { args: [], returns: "ptr" },
ffi_hash: { args: ["ptr", "u32"], returns: "u32" },

View File

@@ -11,7 +11,7 @@ const {
} = Deno.dlopen(path, {
ffi_noop: { parameters: [], result: "void" },
ffi_string: { parameters: [], result: "pointer" },
ffi_hash: { parameters: ["pointer", "u32"], result: "u32" },
ffi_hash: { parameters: ["buffer", "u32"], result: "u32" },
});
const bytes = new Uint8Array(64);
@@ -19,9 +19,7 @@ const bytes = new Uint8Array(64);
group("deno:ffi", () => {
bench("noop", () => ffi_noop());
bench("hash", () => ffi_hash(bytes, bytes.byteLength));
bench("c string", () =>
new Deno.UnsafePointerView(ffi_string()).getCString()
);
bench("c string", () => Deno.UnsafePointerView.getCString(ffi_string()));
});
await run();

View File

@@ -1,11 +1,11 @@
import { renderToReadableStream } from "https://esm.run/react-dom/server";
import { serve } from "https://deno.land/std@0.146.0/http/server.ts";
import * as React from "https://esm.run/react";
const App = () => (
<html>
<body>
<h1>Hello World</h1>
<p>This is an example.</p>
</body>
</html>
);
@@ -17,7 +17,7 @@ const headers = {
},
};
await serve(
Deno.serve(
async (req) => {
return new Response(await renderToReadableStream(<App />), headers);
},

View File

@@ -1,5 +1,5 @@
// to run this:
// bun react-hello-world.jsx --jsx-production
// bun --jsx-production react-hello-world.jsx
// This will become the official react-dom/server.bun build a little later
// It will be the default when you import from "react-dom/server"
@@ -24,7 +24,7 @@ const port = Number(process.env.PORT || 3001);
Bun.serve({
port,
async fetch(req) {
return new Response(await renderToReadableStream(<App />));
return new Response(await renderToReadableStream(<App />), headers);
},
});

View File

@@ -0,0 +1,56 @@
// https://github.com/oven-sh/bun/issues/1096
import { bench, run } from "mitata";
const identity = (x) => x;
for (let i = 0; i < 20; i++) {
var array = new Array(i);
for (let j = 0; j < i; j++) {
array[j] = 1;
}
bench("Array.map x " + i, () => array.map(identity));
}
bench("inline Array.map x 0", () => [].map(identity));
bench("inline Array.map x 1", () => [1].map(identity));
bench("inline Array.map x 2", () => [1, 1].map(identity));
bench("inline Array.map x 3", () => [1, 1, 1].map(identity));
bench("inline Array.map x 4", () => [1, 1, 1, 1].map(identity));
bench("inline Array.map x 5", () => [1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 6", () => [1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 7", () => [1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 8", () => [1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 9", () => [1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 10", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 11", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 12", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 13", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 14", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 15", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 16", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 17", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 18", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 19", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
await run();

30
bench/snippets/blob.mjs Normal file
View File

@@ -0,0 +1,30 @@
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
bench("new Blob(['hello world'])", function () {
return new Blob(["hello world"]);
});
var small = new Blob([JSON.stringify("hello world ")]);
bench("blob.text(small string)", function () {
return small.text();
});
bench("blob.arrayBuffer(small string)", function () {
return small.arrayBuffer();
});
// if (Blob.prototype.json) {
// bench("blob.json(small string)", function () {
// return small.json();
// });
// }
bench("blob.slice()", function () {
return small.slice();
});
if ((await small.text()) !== JSON.stringify("hello world ")) {
throw new Error("blob.text() failed");
}
await run();

25
bench/snippets/crypto.mjs Normal file
View File

@@ -0,0 +1,25 @@
// so it can run in environments without node module resolution
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
var crypto = globalThis.crypto;
if (!crypto) {
crypto = await import("node:crypto");
}
var foo = new Uint8Array(65536);
bench("crypto.getRandomValues(65536)", () => {
crypto.getRandomValues(foo);
});
var small = new Uint8Array(32);
bench("crypto.getRandomValues(32)", () => {
crypto.getRandomValues(small);
});
bench("crypto.randomUUID()", () => {
// node uses a rope string for each hex byte so any subsequent operation after creating it is slow
return crypto.randomUUID()[2];
});
await run();

View File

@@ -0,0 +1,12 @@
import { bench, run } from "mitata";
const input =
"Hello, World! foo bar baz qux quux corge grault garply waldo fred plugh xyzzy thud z a b c d e f g h i j k l m n o p q r s t u v w x y z".split(
" "
);
bench(`Array.indexOf`, () => {
return input.indexOf("thud");
});
await run();

View File

@@ -0,0 +1,64 @@
// so it can run in environments without node module resolution
import { bench, run } from "../../node_modules/mitata/src/cli.mjs";
const obj = {
a: 1,
b: 2,
c: 3,
d: 4,
e: 5,
f: 6,
g: 7,
h: 8,
i: 9,
j: 10,
k: 11,
l: 12,
m: 13,
n: 14,
o: 15,
p: 16,
q: 17,
r: 18,
s: 19,
t: 20,
u: 21,
v: 22,
w: 23,
x: 24,
y: 25,
z: 26,
};
bench("Object.entries(26 keys)", () => {
var k;
for (let [key, value] of Object.entries(obj)) {
value = key;
}
return k;
});
bench("Object.keys(26 keys)", () => {
var k;
for (let [key, value] of Object.keys(obj)) {
value = key;
}
return k;
});
bench("Object.entries(2 keys)", () => {
var k;
for (let [key, value] of Object.entries({ a: 1, b: 2 })) {
value = key;
}
return k;
});
bench("Object.keys(2 keys)", () => {
var k;
for (let item of Object.keys({ a: 1, b: 2 })) {
}
return k;
});
await run();

View File

@@ -0,0 +1,13 @@
import { readdirSync } from "fs";
import { bench, run } from "mitata";
import { argv } from "process";
const dir = argv.length > 2 ? argv[2] : "/tmp";
const count = readdirSync(dir).length;
bench(`readdir("${dir}")`, () => {
readdirSync(dir, { withFileTypes: true });
});
await run();
console.log("\n\nFor", count, "files/dirs in", dir);

View File

@@ -0,0 +1,16 @@
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
bench("return await Promise.resolve(1)", async function () {
return await Promise.resolve(1);
});
bench("return Promise.resolve(1) (async fn)", async function () {
return Promise.resolve(1);
});
bench("return await 1", async function () {
return await 1;
});
await run();

View File

@@ -0,0 +1,13 @@
import { spawnSync } from "bun";
import { bench, run } from "mitata";
var memory = new Uint8Array(128 * 1024 * 1024);
memory.fill(10);
// prevent memory from being garbage collected
globalThis.memory = memory;
bench("spawnSync echo hi", () => {
spawnSync({ cmd: ["echo", "hi"] });
});
await run();

View File

@@ -0,0 +1,13 @@
import { spawnSync } from "child_process";
import { bench, run } from "mitata";
var memory = new Uint8Array(128 * 1024 * 1024);
memory.fill(10);
// prevent memory from being garbage collected
globalThis.memory = memory;
bench("spawnSync echo hi", () => {
spawnSync("echo", ["hi"], { encoding: "buffer", shell: false });
});
await run();

8
bench/snippets/spawn.mjs Normal file
View File

@@ -0,0 +1,8 @@
import { spawnSync } from "bun";
import { bench, run } from "mitata";
bench("spawnSync echo hi", () => {
spawnSync({ cmd: ["echo", "hi"] });
});
await run();

View File

@@ -0,0 +1,8 @@
import { spawnSync } from "child_process";
import { bench, run } from "mitata";
bench("spawnSync echo hi", () => {
spawnSync("echo", ["hi"], { encoding: "buffer", shell: false });
});
await run();

View File

@@ -0,0 +1,28 @@
import { bench, run } from "mitata";
import { StringDecoder } from "string_decoder";
var short = Buffer.from("Hello World!");
var shortUTF16 = Buffer.from("Hello World 💕💕💕");
var long = Buffer.from("Hello World!".repeat(1024));
var longUTF16 = Buffer.from("Hello World 💕💕💕".repeat(1024));
bench(`${short.length} ascii`, () => {
var decoder = new StringDecoder();
decoder.write(short);
});
bench(`${short.length} utf8`, () => {
var decoder = new StringDecoder();
decoder.write(shortUTF16);
});
bench(`${long.length} ascii`, () => {
var decoder = new StringDecoder();
decoder.write(long);
});
bench(`${longUTF16.length} utf8`, () => {
var decoder = new StringDecoder();
decoder.write(longUTF16);
});
await run();

View File

@@ -0,0 +1,49 @@
import { listen, connect } from "bun";
var counter = 0;
const msg = "Hello World!";
const handlers = {
open(socket) {
if (!socket.data?.isServer) {
if (!socket.write(msg)) {
socket.data = { pending: msg };
}
}
},
data(socket, buffer) {
if (!socket.write(buffer)) {
socket.data = { pending: buffer };
return;
}
counter++;
},
drain(socket) {
const pending = socket.data?.pending;
if (!pending) return;
if (socket.write(pending)) {
socket.data = undefined;
counter++;
return;
}
},
};
setInterval(() => {
console.log("Wrote", counter, "messages");
counter = 0;
}, 1000);
const server = listen({
socket: handlers,
hostname: "localhost",
port: 8080,
data: {
isServer: true,
},
});
const connection = await connect({
socket: handlers,
hostname: "localhost",
port: 8080,
});

View File

@@ -0,0 +1,52 @@
import { createRequire } from "node:module";
const net = createRequire(import.meta.url)("net");
const buffer = Buffer.from("Hello World!");
var counter = 0;
const handlers = {
open() {
if (!socket.data?.isServer) {
if (!this.write(buffer)) {
socket.data = { pending: buffer };
}
}
},
data(buffer) {
if (!this.write(buffer)) {
this.data = { pending: buffer.slice() };
return;
}
counter++;
},
drain() {
const pending = this.data?.pending;
if (!pending) return;
if (this.write(pending)) {
this.data = undefined;
counter++;
return;
}
},
};
const server = net.createServer(function (socket) {
socket.data = { isServer: true };
socket.on("connection", handlers.open.bind(socket));
socket.on("data", handlers.data.bind(socket));
socket.on("drain", handlers.drain.bind(socket));
socket.setEncoding("binary");
});
setInterval(() => {
console.log("Wrote", counter, "messages");
counter = 0;
}, 1000);
server.listen(8000);
const socket = net.connect({ host: "localhost", port: 8000 }, () => {});
socket.on("connection", handlers.open.bind(socket));
socket.on("data", handlers.data.bind(socket));
socket.on("drain", handlers.drain.bind(socket));
socket.setEncoding("binary");
socket.write(buffer);

View File

@@ -0,0 +1,24 @@
import { bench, run } from "mitata";
import { write } from "bun";
import { openSync } from "fs";
bench('write(/tmp/foo.txt, "short string")', async () => {
await write("/tmp/foo.txt", "short string");
});
const buffer = Buffer.from("short string");
bench('write(/tmp/foo.txt, Buffer.from("short string"))', async () => {
await write("/tmp/foo.txt", buffer);
});
const fd = openSync("/tmp/foo.txt", "w");
bench('write(fd, "short string")', async () => {
await write(fd, "short string");
});
bench('write(fd, Buffer.from("short string"))', async () => {
await write(fd, buffer);
});
await run();

View File

@@ -0,0 +1,27 @@
import { bench, run } from "mitata";
import { openSync } from "fs";
import { writeFile } from "fs/promises";
import { writeSync as write } from "fs";
bench("writeFile(/tmp/foo.txt, short string)", async () => {
await writeFile("/tmp/foo.txt", "short string", "utf8");
});
const buffer = Buffer.from("short string");
bench("writeFile(/tmp/foo.txt, Buffer.from(short string))", async () => {
await writeFile("/tmp/foo.txt", buffer);
});
const fd = openSync("/tmp/foo.txt", "w");
bench("write(fd, short string)", () => {
const bytesWritten = write(fd, "short string", "utf8");
if (bytesWritten !== 12) throw new Error("wrote !== 12");
});
bench("write(fd, Uint8Array(short string))", () => {
const bytesWritten = write(fd, buffer);
if (bytesWritten !== 12) throw new Error("wrote !== 12");
});
await run();

View File

@@ -1,26 +1,26 @@
import { DB } from "https://deno.land/x/sqlite/mod.ts";
import { Database } from "https://deno.land/x/sqlite3@0.6.1/mod.ts";
import { run, bench } from "../node_modules/mitata/src/cli.mjs";
const db = new DB("./src/northwind.sqlite");
const db = new Database("./src/northwind.sqlite");
{
const sql = db.prepareQuery(`SELECT * FROM "Order"`);
const sql = db.prepare(`SELECT * FROM "Order"`);
bench('SELECT * FROM "Order"', () => {
sql.allEntries();
sql.all();
});
}
{
const sql = db.prepareQuery(`SELECT * FROM "Product"`);
const sql = db.prepare(`SELECT * FROM "Product"`);
bench('SELECT * FROM "Product"', () => {
sql.allEntries();
sql.all();
});
}
{
const sql = db.prepareQuery(`SELECT * FROM "OrderDetail"`);
const sql = db.prepare(`SELECT * FROM "OrderDetail"`);
bench('SELECT * FROM "OrderDetail"', () => {
sql.allEntries();
sql.all();
});
}

169
bench/websocket-server/.gitignore vendored Normal file
View File

@@ -0,0 +1,169 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
# Logs
logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# Runtime data
pids
_.pid
_.seed
\*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
\*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
\*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
\*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
.cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.\*

View File

@@ -0,0 +1,39 @@
# websocket-server
This benchmarks a websocket server intended as a simple but very active chat room.
First, start the server. By default, it will wait for 16 clients which the client script will handle.
Run in Bun (`Bun.serve`):
```bash
bun ./chat-server.bun.js
```
Run in Node (`"ws"` package):
```bash
node ./chat-server.node.mjs
```
Run in Deno (`Deno.serve`):
```bash
deno run -A --unstable ./chat-server.deno.mjs
```
Then, run the client script. By default, it will connect 16 clients. This client script can run in Bun, Node, or Deno
```bash
node ./chat-client.mjs
```
The client script loops through a list of messages for each connected client and sends a message.
For example, when the client sends `"foo"`, the server sends back `"John: foo"` so that all members of the chatroom receive the message.
The client script waits until it receives all the messages for each client before sending the next batch of messages.
TODO: once Deno lands their performance improvements, increase the client count (it was originally going to be 32 or 64, but that would've exluded Deno from the benchmark)
This project was created using `bun init` in bun v0.2.1. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.

View File

@@ -0,0 +1,182 @@
const env =
"process" in globalThis
? process.env
: "Deno" in globalThis
? Deno.env.toObject()
: {};
const SERVER = env.SERVER || "ws://0.0.0.0:4001";
const WebSocket = globalThis.WebSocket || (await import("ws")).WebSocket;
const LOG_MESSAGES = env.LOG_MESSAGES === "1";
const CLIENTS_TO_WAIT_FOR = parseInt(env.CLIENTS_COUNT || "", 10) || 16;
const DELAY = 64;
const MESSAGES_TO_SEND = Array.from({ length: 32 }, () => [
"Hello World!",
"Hello World! 1",
"Hello World! 2",
"Hello World! 3",
"Hello World! 4",
"Hello World! 5",
"Hello World! 6",
"Hello World! 7",
"Hello World! 8",
"Hello World! 9",
"What is the meaning of life?",
"where is the bathroom?",
"zoo",
"kangaroo",
"erlang",
"elixir",
"bun",
"mochi",
"typescript",
"javascript",
"Hello World! 7",
"Hello World! 8",
"Hello World! 9",
"What is the meaning of life?",
"where is the bathroom?",
"zoo",
"kangaroo",
"erlang",
"elixir",
"bun",
"mochi",
"typescript",
"javascript",
"Hello World! 7",
"Hello World! 8",
"Hello World! 9",
"What is the meaning of life?",
"Hello World! 7",
"Hello World! 8",
"Hello World! 9",
"What is the meaning of life?",
"where is the bathroom?",
"zoo",
"kangaroo",
"erlang",
"elixir",
"bun",
"mochi",
"typescript",
"javascript",
]).flat();
const NAMES = Array.from({ length: 50 }, (a, i) => [
"Alice" + i,
"Bob" + i,
"Charlie" + i,
"David" + i,
"Eve" + i,
"Frank" + i,
"Grace" + i,
"Heidi" + i,
"Ivan" + i,
"Judy" + i,
"Karl" + i,
"Linda" + i,
"Mike" + i,
"Nancy" + i,
"Oscar" + i,
"Peggy" + i,
"Quentin" + i,
"Ruth" + i,
"Steve" + i,
"Trudy" + i,
"Ursula" + i,
"Victor" + i,
"Wendy" + i,
"Xavier" + i,
"Yvonne" + i,
"Zach" + i,
])
.flat()
.slice(0, CLIENTS_TO_WAIT_FOR);
console.log(`Connecting ${CLIENTS_TO_WAIT_FOR} WebSocket clients...`);
console.time(`All ${CLIENTS_TO_WAIT_FOR} clients connected`);
var remainingClients = CLIENTS_TO_WAIT_FOR;
var promises = [];
const clients = new Array(CLIENTS_TO_WAIT_FOR);
for (let i = 0; i < CLIENTS_TO_WAIT_FOR; i++) {
clients[i] = new WebSocket(`${SERVER}?name=${NAMES[i]}`);
promises.push(
new Promise((resolve, reject) => {
clients[i].onmessage = (event) => {
resolve();
};
})
);
}
await Promise.all(promises);
console.timeEnd(`All ${clients.length} clients connected`);
var received = 0;
var total = 0;
var more = false;
var remaining;
for (let i = 0; i < CLIENTS_TO_WAIT_FOR; i++) {
clients[i].onmessage = (event) => {
if (LOG_MESSAGES) console.log(event.data);
received++;
remaining--;
if (remaining === 0) {
more = true;
remaining = total;
}
};
}
// each message is supposed to be received
// by each client
// so its an extra loop
for (let i = 0; i < CLIENTS_TO_WAIT_FOR; i++) {
for (let j = 0; j < MESSAGES_TO_SEND.length; j++) {
for (let k = 0; k < CLIENTS_TO_WAIT_FOR; k++) {
total++;
}
}
}
remaining = total;
function restart() {
for (let i = 0; i < CLIENTS_TO_WAIT_FOR; i++) {
for (let j = 0; j < MESSAGES_TO_SEND.length; j++) {
clients[i].send(MESSAGES_TO_SEND[j]);
}
}
}
var runs = [];
setInterval(() => {
const last = received;
runs.push(last);
received = 0;
console.log(
last,
`messages per second (${CLIENTS_TO_WAIT_FOR} clients x ${MESSAGES_TO_SEND.length} msg, min delay: ${DELAY}ms)`
);
if (runs.length >= 10) {
console.log("10 runs");
console.log(JSON.stringify(runs, null, 2));
if ("process" in globalThis) process.exit(0);
runs.length = 0;
}
}, 1000);
var isRestarting = false;
setInterval(() => {
if (more && !isRestarting) {
more = false;
isRestarting = true;
restart();
isRestarting = false;
}
}, DELAY);
restart();

View File

@@ -0,0 +1,56 @@
// See ./README.md for instructions on how to run this benchmark.
const CLIENTS_TO_WAIT_FOR = parseInt(process.env.CLIENTS_COUNT || "", 10) || 16;
var remainingClients = CLIENTS_TO_WAIT_FOR;
const COMPRESS = process.env.COMPRESS === "1";
const port = process.PORT || 4001;
const server = Bun.serve({
port: port,
websocket: {
open(ws) {
ws.subscribe("room");
remainingClients--;
console.log(`${ws.data.name} connected (${remainingClients} remain)`);
if (remainingClients === 0) {
console.log("All clients connected");
setTimeout(() => {
console.log('Starting benchmark by sending "ready" message');
ws.publishText("room", `ready`);
}, 100);
}
},
message(ws, msg) {
const out = `${ws.data.name}: ${msg}`;
if (ws.publishText("room", out) !== out.length) {
throw new Error("Failed to publish message");
}
},
close(ws) {
remainingClients++;
},
perMessageDeflate: false,
},
fetch(req, server) {
if (
server.upgrade(req, {
data: {
name:
new URL(req.url).searchParams.get("name") ||
"Client #" + (CLIENTS_TO_WAIT_FOR - remainingClients),
},
})
)
return;
return new Response("Error");
},
});
console.log(
`Waiting for ${remainingClients} clients to connect...\n`,
` http://${server.hostname}:${port}/`
);

View File

@@ -0,0 +1,48 @@
// See ./README.md for instructions on how to run this benchmark.
const port = Deno.env.get("PORT") || 4001;
const CLIENTS_TO_WAIT_FOR =
parseInt(Deno.env.get("CLIENTS_COUNT") || "", 10) || 16;
var clients = [];
async function reqHandler(req) {
if (req.headers.get("upgrade") != "websocket") {
return new Response(null, { status: 501 });
}
const { socket: client, response } = Deno.upgradeWebSocket(req);
clients.push(client);
const name = new URL(req.url).searchParams.get("name");
console.log(
`${name} connected (${CLIENTS_TO_WAIT_FOR - clients.length} remain)`
);
client.onmessage = (event) => {
const msg = `${name}: ${event.data}`;
for (let client of clients) {
client.send(msg);
}
};
client.onclose = () => {
clients.splice(clients.indexOf(client), 1);
};
if (clients.length === CLIENTS_TO_WAIT_FOR) {
sendReadyMessage();
}
return response;
}
function sendReadyMessage() {
console.log("All clients connected");
setTimeout(() => {
console.log("Starting benchmark");
for (let client of clients) {
client.send(`ready`);
}
}, 100);
}
console.log(`Waiting for ${CLIENTS_TO_WAIT_FOR} clients to connect..`);
Deno.serve(reqHandler, { port });

View File

@@ -0,0 +1,52 @@
// See ./README.md for instructions on how to run this benchmark.
const port = process.env.PORT || 4001;
const CLIENTS_TO_WAIT_FOR = parseInt(process.env.CLIENTS_COUNT || "", 10) || 16;
import { createRequire } from "module";
const require = createRequire(import.meta.url);
var WebSocketServer = require("ws").Server,
config = {
host: "0.0.0.0",
port,
},
wss = new WebSocketServer(config, function () {
console.log(`Waiting for ${CLIENTS_TO_WAIT_FOR} clients to connect..`);
});
var clients = [];
wss.on("connection", function (ws, { url }) {
const name = new URL(new URL(url, "http://localhost:3000")).searchParams.get(
"name"
);
console.log(
`${name} connected (${CLIENTS_TO_WAIT_FOR - clients.length} remain)`
);
clients.push(ws);
ws.on("message", function (message) {
const out = `${name}: ${message}`;
for (let client of clients) {
client.send(out);
}
});
// when a connection is closed
ws.on("close", function (ws) {
clients.splice(clients.indexOf(ws), 1);
});
if (clients.length === CLIENTS_TO_WAIT_FOR) {
sendReadyMessage();
}
});
function sendReadyMessage() {
console.log("All clients connected");
setTimeout(() => {
console.log("Starting benchmark");
for (let client of clients) {
client.send(`ready`);
}
}, 100);
}

View File

@@ -0,0 +1,13 @@
{
"name": "websocket-server",
"module": "index.ts",
"type": "module",
"devDependencies": {
"bun-types": "^0.2.0"
},
"dependencies": {
"bufferutil": "^4.0.7",
"utf-8-validate": "^5.0.10",
"ws": "^8.9.0"
}
}

View File

@@ -3,6 +3,11 @@
"lib": ["ESNext"],
"module": "esnext",
"target": "esnext",
"moduleResolution": "node",
// so that if your project isn't using TypeScript, it still has autocomplete
"allowJs": true,
// "bun-types" is the important part
"types": ["bun-types"]
}

View File

@@ -1 +1 @@
11
2

View File

@@ -132,7 +132,7 @@ fn addInternalPackages(step: *std.build.LibExeObjStep, _: std.mem.Allocator, tar
};
io.dependencies = &.{analytics};
uws.dependencies = &.{boringssl};
javascript_core.dependencies = &.{ http, strings, picohttp, io, uws };
http.dependencies = &.{
strings,
@@ -140,6 +140,7 @@ fn addInternalPackages(step: *std.build.LibExeObjStep, _: std.mem.Allocator, tar
io,
boringssl,
thread_pool,
uws,
};
thread_pool.dependencies = &.{ io, http };
http.dependencies = &.{
@@ -148,6 +149,7 @@ fn addInternalPackages(step: *std.build.LibExeObjStep, _: std.mem.Allocator, tar
io,
boringssl,
thread_pool,
uws,
};
thread_pool.dependencies = &.{ io, http };
@@ -175,6 +177,7 @@ const BunBuildOptions = struct {
sha: [:0]const u8 = "",
baseline: bool = false,
bindgen: bool = false,
sizegen: bool = false,
pub fn step(this: BunBuildOptions, b: anytype) *std.build.OptionsStep {
var opts = b.addOptions();
@@ -182,6 +185,7 @@ const BunBuildOptions = struct {
opts.addOption(@TypeOf(this.sha), "sha", this.sha);
opts.addOption(@TypeOf(this.baseline), "baseline", this.baseline);
opts.addOption(@TypeOf(this.bindgen), "bindgen", this.bindgen);
opts.addOption(@TypeOf(this.sizegen), "sizegen", this.sizegen);
return opts;
}
};
@@ -394,7 +398,13 @@ pub fn build(b: *std.build.Builder) !void {
obj.setOutputDir(output_dir);
obj.setBuildMode(mode);
obj.addOptions("build_options", default_build_options.step(b));
var actual_build_options = default_build_options;
if (b.option(bool, "generate-sizes", "Generate sizes of things") orelse false) {
actual_build_options.sizegen = true;
obj.setOutputDir(b.pathFromRoot("misctools/sizegen"));
}
obj.addOptions("build_options", actual_build_options.step(b));
obj.linkLibC();
@@ -509,12 +519,14 @@ pub fn build(b: *std.build.Builder) !void {
try configureObjectStep(b, headers_obj, target, obj.main_pkg_path.?);
try linkObjectFiles(b, headers_obj, target);
{
var before = b.addLog("\x1b[" ++ color_map.get("magenta").? ++ "\x1b[" ++ color_map.get("b").? ++ "[{s} tests]" ++ "\x1b[" ++ color_map.get("d").? ++ " ----\n\n" ++ "\x1b[0m", .{"bun"});
var after = b.addLog("\x1b[" ++ color_map.get("d").? ++ "---\n\n" ++ "\x1b[0m", .{});
headers_step.dependOn(&before.step);
headers_step.dependOn(&headers_obj.step);
headers_step.dependOn(&after.step);
headers_obj.addOptions("build_options", default_build_options.step(b));
}
for (headers_obj.packages.items) |pkg_| {
@@ -524,7 +536,10 @@ pub fn build(b: *std.build.Builder) !void {
test_.setMainPkgPath(obj.main_pkg_path.?);
test_.setTarget(target);
try configureObjectStep(b, test_, target, obj.main_pkg_path.?);
try linkObjectFiles(b, test_, target);
test_.addOptions("build_options", default_build_options.step(b));
if (pkg.dependencies) |children| {
test_.packages = std.ArrayList(std.build.Pkg).init(b.allocator);
try test_.packages.appendSlice(children);

BIN
bun.lockb

Binary file not shown.

View File

@@ -75,13 +75,16 @@ complete -c bun \
complete -c bun \
-n "not __fish_seen_subcommand_from (__fish__get_bun_bins) (__fish__get_bun_scripts) install remove add;" --no-files -s 'u' -l 'origin' -r -d 'Server URL. Rewrites import paths'
complete -c bun \
-n "not __fish_seen_subcommand_from (__fish__get_bun_bins) (__fish__get_bun_scripts) install remove add;" --no-files -s 'p' -l 'port' -r -d 'Port number to start server from'
-n "not __fish_seen_subcommand_from (__fish__get_bun_bins) (__fish__get_bun_scripts) install remove add;" --no-files -s 'p' -l 'port' -r -d 'Port number to start server from'
complete -c bun \
-n "not __fish_seen_subcommand_from (__fish__get_bun_bins) (__fish__get_bun_scripts) install remove add;" --no-files -s 'd' -l 'define' -r -d 'Substitute K:V while parsing, e.g. --define process.env.NODE_ENV:\"development\"'
complete -c bun \
-n "not __fish_seen_subcommand_from (__fish__get_bun_bins) (__fish__get_bun_scripts) install remove add;" --no-files -s 'e' -l 'external' -r -d 'Exclude module from transpilation (can use * wildcards). ex: -e react'
complete -c bun \
-n "not __fish_seen_subcommand_from (__fish__get_bun_bins) (__fish__get_bun_scripts) install remove add;" --no-files -l 'use' -r -d 'Use a framework (ex: next)'
complete -c bun \
-n "not __fish_seen_subcommand_from (__fish__get_bun_bins) (__fish__get_bun_scripts) install remove add;" --no-files -l 'hot' -r -d 'Enable hot reloading in Bun\'s JavaScript runtime'
complete -c bun \
-n "bun_fish_is_nth_token 1; and not __fish_seen_subcommand_from $bun_builtin_cmds; and not __fish_seen_subcommand_from (__fish__get_bun_bins) (__fish__get_bun_scripts) and __fish_use_subcommand" -a 'dev' -d 'Start dev server'
complete -c bun \

View File

@@ -409,6 +409,7 @@ _bun() {
'--version[Show version and exit]' \
'-V[Show version and exit]' \
'--cwd[Change directory]:cwd' \
'--hot[Enable hot reloading]' \
'--help[Show command help]' \
'-h[Show command help]' \
'--all[]' &&

View File

@@ -10,7 +10,7 @@ WORKDIR /tmp
RUN apk --no-cache add unzip
# get bun
ADD https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64.zip
ADD https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64.zip bun-linux-x64.zip
RUN unzip bun-linux-x64.zip
# get glibc

5
docs/runtime/streams.md Normal file
View File

@@ -0,0 +1,5 @@
# Streams in Bun
Bun supports Web Streams ([`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) and [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream) first and partially supports Node.js [`"stream"`](https://nodejs.org/api/stream.html).
## `ReadableStream`

View File

@@ -1,8 +0,0 @@
{
"name": "@bun-examples/blank",
"version": "0.0.3",
"module": "src/index.js",
"devDependencies": {
"bun-types": "latest"
}
}

View File

@@ -1,13 +0,0 @@
## Getting Started
### Cloning the repo
```sh
bun create blank ./NAME_HERE
```
### Execute a file (eg. src/index.js)
```sh
bun run ./src/index.js
```

View File

@@ -1 +0,0 @@
console.log('Hello, World!');

View File

@@ -1,42 +0,0 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
# vercel
.vercel
**/*.trace
**/*.zip
**/*.tar.gz
**/*.tgz
**/*.log
package-lock.json
**/*.bun

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -1,42 +0,0 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
# vercel
.vercel
**/*.trace
**/*.zip
**/*.tar.gz
**/*.tgz
**/*.log
package-lock.json
**/*.bun

View File

@@ -1,8 +0,0 @@
import {Router} from "@kapsonfire/bun-bakery"
new Router({
port: 3000,
assetsPath: import.meta.dir + '/assets/',
routesPath: import.meta.dir + '/routes/'
})

View File

@@ -1,7 +0,0 @@
{
"version": "1.0.4",
"name": "@bun-examples/bun-bakery",
"dependencies": {
"@kapsonfire/bun-bakery": "^0.2.0"
}
}

View File

@@ -1,5 +0,0 @@
import {Context} from "@kapsonfire/bun-bakery"
export async function GET(ctx: Context) {
ctx.sendHTML('<img src="/assets/bunbakery.png"><h1>Hello World!</h1>');
}

View File

@@ -1,7 +0,0 @@
{
"compilerOptions": {
"types": ["bun-types"],
"module": "esnext",
"moduleResolution": "Node"
}
}

View File

@@ -0,0 +1,89 @@
// To run this example:
//
// bun --hot bun-hot-websockets.js
//
const css = ([inner]) => {
return inner;
};
const styles = css`
#bun {
margin: 0 auto;
margin-top: 200px;
object-fit: cover;
}
html,
body {
margin: 0;
padding: 0;
}
body {
background: #f1239f;
font-family: "Inter", sans-serif;
display: flex;
align-items: center;
justify-content: center;
align-content: center;
color: white;
}
h1 {
padding: 0;
text-align: center;
font-size: 3rem;
-webkit-text-stroke: 2px black;
}
* {
box-sizing: border-box;
}
`;
export default {
websocket: {
message(ws, msg) {
ws.send(styles);
},
},
fetch(req, server) {
if (req.url.endsWith("/hot")) {
if (server.upgrade(req))
return new Response("", {
status: 101,
});
}
return new Response(
`
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebSockets</title>
</head>
<body>
<style></style>
<script>
const ws = new WebSocket("ws://localhost:3000/hot");
const style = document.querySelector("style");
ws.onmessage = (e) => {
style.innerHTML = e.data;
};
setInterval(() => {
ws.send("ping");
}, 8);
</script>
<div id="app">
<img src="https://bun.sh/logo.svg" alt="Bun" id='bun' />
<h1>bun --hot websockets</h1>
</div>
</body>
`,
{
headers: {
"Content-Type": "text/html; charset=utf-8",
},
}
);
},
};

View File

@@ -1,3 +0,0 @@
DISCORD_APP_ID=
DISCORD_BOT_TOKEN=
DISCORD_PUBLIC_KEY=

View File

@@ -1,88 +0,0 @@
/data
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
#config file
config.json
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# TernJS port file
.tern-port
# pm2
.pm2
.pm2.bak

View File

@@ -1,15 +0,0 @@
# /create with Bun runtime
A [slash-create](https://npm.im/slash-create) template, using [Bun runtime](https://bun.sh).
## Getting Started
### Cloning the repo
```sh
bun create discord-interactions interactions-bot
```
### Development
To run this locally, rename `.env.example` to `.env` and fill in the variables, then run `bun run.js` to start a local dev environment and use something similar to [ngrok](https://ngrok.com/) or [cloudflare](https://www.cloudflare.com/) to tunnel it to a URL.

View File

@@ -1,39 +0,0 @@
import { join, extname } from 'path';
import { Creator } from 'slash-create';
import { readdirSync, lstatSync } from 'fs';
import { FetchRequestHandler } from './rest.js';
export { default as BunServer } from './server.js';
export class BunSlashCreator extends Creator {
constructor(...args) {
super(...args);
this.requestHandler = new FetchRequestHandler(this);
}
async registerCommandsIn(commandPath, customExtensions = []) {
const commands = [];
const extensions = ['.js', '.ts', '.mjs', '.cjs', ...customExtensions];
for (const path of find_files_with_extension(commandPath, extensions)) {
try {
commands.push(await import(path));
} catch (error) {
this.emit('error', new Error(`Failed to load command ${filePath}: ${e}`));
}
}
return this.registerCommands(commands, true);
}
}
function find_files_with_extension(path, extensions, names = []) {
for (const name of readdirSync(path)) {
const p = join(path, name);
const stat = lstatSync(p);
if (extensions.includes(extname(name))) names.push(p);
else if (stat.isDirectory()) find_files_with_extension(p, extensions, names);
}
return names;
}

View File

@@ -1,48 +0,0 @@
import { RequestHandler } from 'slash-create';
import { MultipartData } from 'slash-create/lib/util/multipartData.js';
export class FetchRequestHandler extends RequestHandler {
toString() {
return '[RequestHandler]';
}
async request(method, url, auth = true, body, file) {
const creator = this._creator;
const headers = {
'user-agent': this.userAgent,
'x-ratelimit-precision': 'millisecond',
};
if (auth) {
headers.authorization = creator.options.token;
if (!headers.authorization) throw new Error('No token was set in the SlashCreator.');
}
if (body) {
if (method !== 'GET' && method !== 'DELETE') {
body = JSON.stringify(body);
headers['content-type'] = 'application/json';
}
}
if (file) {
if (Array.isArray(file)) {}
else if (file.file) file = [file];
else throw new Error('Invalid file object.');
const form = new MultipartData();
headers['content-type'] = `multipart/form-data; boundary=${form.boundary}`;
for (const f of file) form.attach(f.name, f.file, f.name);
if (body) form.attach('payload_json', JSON.stringify(body));
body = Buffer.concat(form.finish());
}
const res = await fetch('https://discord.com' + this.baseURL + url, { body, method, headers });
if (res.ok) return res.json();
throw new Error(`${method} got ${res.status} - ${await res.text()}`);
}
}

View File

@@ -1,79 +0,0 @@
import { Server } from 'slash-create';
import { MultipartData } from 'slash-create/lib/util/multipartData.js';
export default class BunServer extends Server {
#server = null;
#handler = null;
isWebserver = true;
constructor() {
super({ alreadyListening: true });
}
createEndpoint(path, handler) {
this.#handler = handler;
}
stop() {
if (this.#server) this.#server.close();
else throw new Error('BunServer not started');
}
listen(port, options = {}) {
const getHandler = () => this.#handler;
this.#server = Bun.serve({
port,
...options,
async fetch(req) {
const handler = getHandler();
if (!handler) return new Response('Server has no handler.', { status: 503 });
if (req.method !== 'POST') return new Response('Server only supports POST requests.', { status: 405 });
const reqHeaders = Object.fromEntries(req.headers.entries());
const reqBody = await req.json();
return await new Promise(async (ok, err) => {
try {
await handler({
request: req,
body: reqBody,
response: null,
headers: reqHeaders,
}, response => {
let body = response.body;
const headers = new Headers();
if (response.headers) {
for (const key in response.headers) {
headers.set(key, response.headers[key]);
}
}
if ('string' !== typeof body) {
body = JSON.stringify(body);
headers.set('content-type', 'application/json');
}
if (response.files) {
const form = new MultipartData();
headers.set('content-type', `multipart/form-data; boundary=${form.boundary}`);
form.attach('payload_json', body);
for (const file of response.files) form.attach(file.name, file.file, file.name);
body = Buffer.concat(form.finish());
}
ok(new Response(body, { headers, status: response.status }));
});
} catch (error) {
err(error);
}
});
},
});
}
};

View File

@@ -1,21 +0,0 @@
import { SlashCommand, ApplicationCommandType } from 'slash-create';
export default class AvatarCommand extends SlashCommand {
constructor(creator) {
super(creator, {
// You must specify a type for context menu commands, but defaults
// to `CHAT_INPUT`, or regular slash commands.
type: ApplicationCommandType.USER,
name: 'Get Avatar URL',
});
this.filePath = __filename;
}
async run(ctx) {
// The target user can be accessed from here
// You can also use `ctx.targetMember` for member properties
const target = ctx.targetUser;
return `${target.username}'s Avatar: ${target.avatarURL}`;
}
}

View File

@@ -1,21 +0,0 @@
import { SlashCommand, CommandOptionType } from 'slash-create';
export default class HelloCommand extends SlashCommand {
constructor(creator) {
super(creator, {
name: 'hello',
description: 'Says hello to you.',
options: [{
type: CommandOptionType.STRING,
name: 'food',
description: 'What food do you like?'
}]
});
this.filePath = __filename;
}
async run(ctx) {
return ctx.options.food ? `You like ${ctx.options.food}? Nice!` : `Hello, ${ctx.user.username}!`;
}
}

View File

@@ -1,51 +0,0 @@
import { SlashCommand, ComponentType, TextInputStyle } from 'slash-create';
export default class ModalCommand extends SlashCommand {
constructor(creator) {
super(creator, {
name: 'modal',
description: 'Send a cool modal.'
});
this.filePath = __filename;
}
async run(ctx) {
// You can send a modal this way
// Keep in mind providing a callback is optional, but no callback requires the custom_id to be defined.
ctx.sendModal(
{
title: 'Example Modal',
components: [
{
type: ComponentType.ACTION_ROW,
components: [
{
type: ComponentType.TEXT_INPUT,
label: 'Text Input',
style: TextInputStyle.SHORT,
custom_id: 'text_input',
placeholder: 'Type something...'
}
]
},
{
type: ComponentType.ACTION_ROW,
components: [
{
type: ComponentType.TEXT_INPUT,
label: 'Long Text Input',
style: TextInputStyle.PARAGRAPH,
custom_id: 'long_text_input',
placeholder: 'Type something...'
}
]
}
]
},
(mctx) => {
mctx.send(`Your input: ${mctx.values.text_input}\nYour long input: ${mctx.values.long_text_input}`);
}
);
}
}

View File

@@ -1,88 +0,0 @@
/data
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
#config file
config.json
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# TernJS port file
.tern-port
# pm2
.pm2
.pm2.bak

View File

@@ -1,7 +0,0 @@
{
"version": "0.0.9",
"name": "@bun-examples/discord-interactions",
"dependencies": {
"slash-create": "^5.7.0"
}
}

View File

@@ -1,2 +0,0 @@
Error.captureStackTrace = () => {};
Buffer.isBuffer = Buffer.isBuffer.bind(Buffer);

View File

@@ -1,22 +0,0 @@
// polyfill v8 and node (TODO: fix in bun)
import './polyfill.js';
import path from 'node:path';
import { BunServer, BunSlashCreator } from './bun_shim/index.js';
const client = new BunSlashCreator({
token: process.env.DISCORD_BOT_TOKEN,
publicKey: process.env.DISCORD_PUBLIC_KEY,
applicationID: process.env.DISCORD_APP_ID,
});
// client.on('debug', console.log);
client.on('error', console.error);
client.withServer(new BunServer());
await client.registerCommandsIn(path.join(__dirname, 'commands'));
client.syncCommands();
await client.server.listen(1337);
// client.server.stop(); // stop server

View File

@@ -1,14 +0,0 @@
{
"version": "1.0.4",
"name": "@bun-examples/hono",
"devDependencies": {
"bun-types": "latest"
},
"dependencies": {
"hono": "^2.0.0"
},
"scripts": {
"start": "bun run src/index.ts"
},
"module": "src/index.js"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,21 +0,0 @@
# Hono with Bun runtime
## Getting Started
### Cloning the repo
```sh
bun create hono ./NAME_HERE
```
### Development
```
bun run start
```
Open http://localhost:3000 with your browser to see the result.
### For more information
See <https://honojs.dev/>

View File

@@ -1,19 +0,0 @@
import { Hono } from "hono";
import { serveStatic } from 'hono/serve-static.bun';
const port = parseInt(process.env.PORT) || 3000;
const app = new Hono();
app.use('/favicon.ico', serveStatic({ path: './public/favicon.ico' }));
app.get("/", (c) => {
return c.json({ message: "Hello World!" });
});
console.log(`Running at http://localhost:${port}`);
export default {
port,
fetch: app.fetch
};

View File

@@ -1,10 +0,0 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "esnext",
"target": "esnext",
"moduleResolution": "node",
// "bun-types" is the important part
"types": ["bun-types"]
}
}

View File

@@ -1,8 +1,15 @@
const { serve, file, resolveSync } = Bun;
const { path } = import.meta;
import { file } from "bun";
serve({
fetch(req: Request) {
return new Response(file(new URL(req.url).pathname.substring(1)));
const pathname = new URL(req.url).pathname.substring(1);
// If the URL is empty, display this file.
if (pathname === "") {
return new Response(file(import.meta.url));
}
return new Response(file(pathname));
},
// this is called when fetch() throws or rejects

View File

@@ -0,0 +1,16 @@
import { serve } from "bun";
serve({
async fetch(req) {
// body is a ReadableStream
const body = req.body;
const writer = Bun.file(`upload.${Date.now()}.txt`).writer();
for await (const chunk of body) {
writer.write(chunk);
}
const wrote = await writer.end();
return Response.json({ wrote, type: req.headers.get("Content-Type") });
},
});

View File

@@ -1,15 +0,0 @@
# KingWorld with Bun runtime
## Getting Started
To get started with this template, simply paste this command into your terminal:
```bash
bun create kingworld ./kingworld-example
```
## Development
KingWorld uses `nodemon` for auto reload. To start the development server run:
```bash
bun run dev
```
Open http://localhost:3000/ with your browser to see the result.

Binary file not shown.

View File

@@ -1,42 +0,0 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
# vercel
.vercel
**/*.trace
**/*.zip
**/*.tar.gz
**/*.tgz
**/*.log
package-lock.json
**/*.bun

View File

@@ -1,6 +0,0 @@
{
"restartable": "rs",
"ignore": [".git", "node_modules/", "__tests__", "test"],
"exec": "bun src/index.ts",
"ext": "js, json, ts"
}

View File

@@ -1,16 +0,0 @@
{
"name": "kingworld",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "nodemon --config nodemon.json"
},
"dependencies": {
"kingworld": "latest"
},
"devDependencies": {
"bun-types": "latest",
"nodemon": "^2.0.19"
}
}

View File

@@ -1,7 +0,0 @@
import KingWorld from 'kingworld'
new KingWorld()
.get("/", () => "Hello KingWorld")
.listen(3000)
console.log('🦊 KINGWORLD is running at :3000')

View File

@@ -1,103 +0,0 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
"types": ["bun-types"], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

View File

@@ -1,3 +0,0 @@
{
"extends": "next/core-web-vitals"
}

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