mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Compare commits
470 Commits
bun-v0.1.1
...
bun-v0.2.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6632135ec0 | ||
|
|
7b73dcf906 | ||
|
|
75b1ef1ef4 | ||
|
|
830f83a44d | ||
|
|
88d6615e4e | ||
|
|
cc1b340cff | ||
|
|
8ccf5a07ca | ||
|
|
10a8c6acdd | ||
|
|
2cd1d44739 | ||
|
|
de536fc953 | ||
|
|
a1456767f7 | ||
|
|
e0feff22c9 | ||
|
|
44ff09015c | ||
|
|
3c45182097 | ||
|
|
c02da2c5a6 | ||
|
|
5cd91fa1a3 | ||
|
|
d21739af1a | ||
|
|
bd372e9cf4 | ||
|
|
afe04aa8bf | ||
|
|
9b2bad8bed | ||
|
|
7622f2e339 | ||
|
|
3d05cb017d | ||
|
|
1c54deab52 | ||
|
|
28d71e2d9f | ||
|
|
02c920f4fd | ||
|
|
1b50ecc52b | ||
|
|
f8ea534f3b | ||
|
|
9aea2f90a5 | ||
|
|
38cc698b4d | ||
|
|
f13f465024 | ||
|
|
e8d6ad6d66 | ||
|
|
434f1bffad | ||
|
|
0b0db78799 | ||
|
|
b3434a8b88 | ||
|
|
223ce77eca | ||
|
|
ec9787770e | ||
|
|
360a007f16 | ||
|
|
76652ac3ca | ||
|
|
14cec299f5 | ||
|
|
55c42f1663 | ||
|
|
85808700c8 | ||
|
|
73fba0c5f1 | ||
|
|
7060008b83 | ||
|
|
ae4f2d63c8 | ||
|
|
9129309f0a | ||
|
|
c987bdcbf9 | ||
|
|
f6a451256f | ||
|
|
71b942b581 | ||
|
|
cd2e9e9dcf | ||
|
|
347309b26f | ||
|
|
8d67870da4 | ||
|
|
04e0583c31 | ||
|
|
c37d0be027 | ||
|
|
4c136cddd7 | ||
|
|
b50dc40fb8 | ||
|
|
6160dc3995 | ||
|
|
a1f40400c1 | ||
|
|
c940f00e2d | ||
|
|
97ccbc189a | ||
|
|
0a2c101c28 | ||
|
|
c526a6bce8 | ||
|
|
da9b2452a7 | ||
|
|
210ae2ffb2 | ||
|
|
9f16906499 | ||
|
|
605c429770 | ||
|
|
b064872d9a | ||
|
|
ff36fa8a53 | ||
|
|
19682b4225 | ||
|
|
536bd72de9 | ||
|
|
87ca9948ec | ||
|
|
57e5c35277 | ||
|
|
8b4c3ec0c7 | ||
|
|
9c7eb75a9a | ||
|
|
b0fe167910 | ||
|
|
6223030360 | ||
|
|
1835e4b9f9 | ||
|
|
8ca49f906a | ||
|
|
dac6c48b1e | ||
|
|
2b0694ec8c | ||
|
|
26bfc4f0a3 | ||
|
|
fbec10758b | ||
|
|
30d43b027f | ||
|
|
693b1c9b23 | ||
|
|
ce0efc37cc | ||
|
|
11c105aa1d | ||
|
|
9167aedcc8 | ||
|
|
fc4c3e3199 | ||
|
|
61a8490c66 | ||
|
|
abd6e496ab | ||
|
|
8e1b2ba32e | ||
|
|
c7fc8fdf96 | ||
|
|
7f4bb93782 | ||
|
|
a10a8e9c70 | ||
|
|
b595ddf20d | ||
|
|
4bd9b20c8a | ||
|
|
9190061ba4 | ||
|
|
41f9fd85f6 | ||
|
|
cdff2697ef | ||
|
|
ca02695993 | ||
|
|
9a2f2a94bf | ||
|
|
e22c245d08 | ||
|
|
171242680d | ||
|
|
5995f2ed71 | ||
|
|
abbde39a02 | ||
|
|
e1a17aff4c | ||
|
|
b8c5646c49 | ||
|
|
62b0b601c2 | ||
|
|
e43b4815b5 | ||
|
|
923d9c1bbb | ||
|
|
e3a6007a76 | ||
|
|
00ae8f79e4 | ||
|
|
dc1330aef5 | ||
|
|
3c1e3792d6 | ||
|
|
603164e66a | ||
|
|
f19b5ce409 | ||
|
|
f356da1b5e | ||
|
|
07a2f80cbc | ||
|
|
2888f43c8a | ||
|
|
697e105ffa | ||
|
|
5d7174d789 | ||
|
|
ab3b072249 | ||
|
|
690e79445d | ||
|
|
bce68bc898 | ||
|
|
94091a7522 | ||
|
|
2852520d90 | ||
|
|
abf3a13433 | ||
|
|
cebd351e61 | ||
|
|
19cff80af8 | ||
|
|
9830e50a29 | ||
|
|
820e6605f8 | ||
|
|
c06bba77d4 | ||
|
|
4ba217bc42 | ||
|
|
a42a9e901c | ||
|
|
3482d76175 | ||
|
|
63c9315b24 | ||
|
|
40126bbe60 | ||
|
|
70615f4036 | ||
|
|
1b1b96aff8 | ||
|
|
de1e963ffa | ||
|
|
a299b1b8e3 | ||
|
|
4cc0eebf4b | ||
|
|
b1e97edc59 | ||
|
|
a56dfe486b | ||
|
|
e9c3529476 | ||
|
|
c9a4bdf44d | ||
|
|
c6fe82018a | ||
|
|
3016723198 | ||
|
|
e453b949dd | ||
|
|
1236e3f59c | ||
|
|
c6d314e954 | ||
|
|
2c548d45f8 | ||
|
|
4c741cc8b6 | ||
|
|
4b5af13ac0 | ||
|
|
35cbfa63a6 | ||
|
|
dd84681d30 | ||
|
|
0a1fca5d7d | ||
|
|
af033c02c5 | ||
|
|
40506e33e7 | ||
|
|
b542921f3d | ||
|
|
b0a7f8df92 | ||
|
|
32e16bda23 | ||
|
|
e32ada318a | ||
|
|
b011610bb3 | ||
|
|
723c7c56dc | ||
|
|
6b7a0c1d3f | ||
|
|
22f7981cff | ||
|
|
ad29d9ffb3 | ||
|
|
8200f43a04 | ||
|
|
3fceae8070 | ||
|
|
8cd8e34719 | ||
|
|
930981c9d9 | ||
|
|
f8b22d51a9 | ||
|
|
2b1b7eb6b3 | ||
|
|
e241e503b7 | ||
|
|
39940ec1f5 | ||
|
|
f725b7e1ab | ||
|
|
da66bed946 | ||
|
|
58fe024aea | ||
|
|
6205cf3fe4 | ||
|
|
fb6c87da07 | ||
|
|
d0fb442c59 | ||
|
|
1c949354c6 | ||
|
|
3a042cdb48 | ||
|
|
a97914fff3 | ||
|
|
ec00838a03 | ||
|
|
860bd53fb3 | ||
|
|
477638435c | ||
|
|
cb384dfa29 | ||
|
|
dd15a98879 | ||
|
|
6b2637468c | ||
|
|
ab4f4bca6d | ||
|
|
73a611a3b9 | ||
|
|
c5333ab597 | ||
|
|
75e8c4699c | ||
|
|
8fcb0ff0b6 | ||
|
|
dbd569d2ab | ||
|
|
40eca63653 | ||
|
|
e7eadcde5a | ||
|
|
36adee4dc8 | ||
|
|
9fe1ad93cb | ||
|
|
8311761c82 | ||
|
|
8702f965a2 | ||
|
|
888a685e26 | ||
|
|
51c1d18e68 | ||
|
|
af6476ca74 | ||
|
|
614d256cb6 | ||
|
|
3867431ed1 | ||
|
|
1f7f5646de | ||
|
|
40623cf967 | ||
|
|
d07e4f8bd1 | ||
|
|
e4bf189e9d | ||
|
|
2292ef8d0e | ||
|
|
a114af4eea | ||
|
|
5152aebde1 | ||
|
|
1310a1d99e | ||
|
|
a20d3eaebb | ||
|
|
3cc61f8e30 | ||
|
|
ef2c9c330c | ||
|
|
5db06105ba | ||
|
|
24433ceb27 | ||
|
|
ff797f7410 | ||
|
|
cef32c1123 | ||
|
|
50d4cedd92 | ||
|
|
27ad376071 | ||
|
|
eebcd30067 | ||
|
|
1afe2f05dc | ||
|
|
170e3117d7 | ||
|
|
fc08e69039 | ||
|
|
25918ddd2a | ||
|
|
edfd2af949 | ||
|
|
dffaeaca1e | ||
|
|
88bdae8218 | ||
|
|
fdfe00452b | ||
|
|
b38d553d60 | ||
|
|
0833275f03 | ||
|
|
4252d015ca | ||
|
|
9fd0072740 | ||
|
|
4dbbdb1671 | ||
|
|
4b5c9acc72 | ||
|
|
b63218206d | ||
|
|
349ccf229b | ||
|
|
85602b406a | ||
|
|
cc6077fbf5 | ||
|
|
495534a054 | ||
|
|
57513f38d3 | ||
|
|
0b3abf2c78 | ||
|
|
9294ef73b7 | ||
|
|
36ec06493e | ||
|
|
6068ad15d4 | ||
|
|
c2c9173eff | ||
|
|
99e7856269 | ||
|
|
1355d415e9 | ||
|
|
410059c9f3 | ||
|
|
80096884f6 | ||
|
|
d2dd2ae306 | ||
|
|
5c3ce875b2 | ||
|
|
6970250b57 | ||
|
|
c880c53199 | ||
|
|
75371d1462 | ||
|
|
2c762f47c9 | ||
|
|
3246efa580 | ||
|
|
4060afb7c7 | ||
|
|
e4d3f51161 | ||
|
|
1777e9d0b1 | ||
|
|
707b454bf4 | ||
|
|
ca4c99b1bf | ||
|
|
a302549d3e | ||
|
|
1a7418e890 | ||
|
|
c1219a3b48 | ||
|
|
632e4ac6ac | ||
|
|
18ae17871d | ||
|
|
09ebb217dd | ||
|
|
dbccfc2b26 | ||
|
|
28f7240dd3 | ||
|
|
9f10956ce1 | ||
|
|
c9a50b2f2d | ||
|
|
d683d7185d | ||
|
|
fc13938fc6 | ||
|
|
f8e8b10e10 | ||
|
|
050292229f | ||
|
|
906e97223a | ||
|
|
dc10b24730 | ||
|
|
d3ef6c330a | ||
|
|
4700762132 | ||
|
|
08d606c3d7 | ||
|
|
ed82b919a0 | ||
|
|
4fa065180b | ||
|
|
cd9b47315c | ||
|
|
062c3948ba | ||
|
|
bff3b902e8 | ||
|
|
3b4900193b | ||
|
|
bab317edd1 | ||
|
|
1dac9248ad | ||
|
|
c57b32fa0c | ||
|
|
43c22b4411 | ||
|
|
bee72be733 | ||
|
|
ea159b6004 | ||
|
|
ac72f28fc8 | ||
|
|
e4e7966d64 | ||
|
|
48cb526e0b | ||
|
|
fd6d28a9fa | ||
|
|
944dc988bf | ||
|
|
2fac218a36 | ||
|
|
16c184efdf | ||
|
|
6b5c49c269 | ||
|
|
af6a43c49b | ||
|
|
18310cfd7c | ||
|
|
9046767da4 | ||
|
|
f70c83345a | ||
|
|
52f5f9545a | ||
|
|
1434fb66d3 | ||
|
|
f325a0016b | ||
|
|
9d7bcac680 | ||
|
|
8d11ab3c35 | ||
|
|
56e491ad8a | ||
|
|
9296a369de | ||
|
|
9050e6ee87 | ||
|
|
84af4f0133 | ||
|
|
6338413696 | ||
|
|
fbec7bda6a | ||
|
|
0f371a2869 | ||
|
|
c30346cf5d | ||
|
|
64ef2389dc | ||
|
|
6ec55cbeeb | ||
|
|
3430cdd91b | ||
|
|
9702568161 | ||
|
|
016a9d6535 | ||
|
|
9f10c1a805 | ||
|
|
7631a47612 | ||
|
|
b8851143f9 | ||
|
|
f3028ff6f3 | ||
|
|
3d35fae890 | ||
|
|
1636291b03 | ||
|
|
e69e8d35b9 | ||
|
|
9438540bf9 | ||
|
|
d34179b9eb | ||
|
|
90074ce98c | ||
|
|
fd0054a800 | ||
|
|
0fb5f15673 | ||
|
|
16929129f0 | ||
|
|
524e48a81d | ||
|
|
76b1a3a88d | ||
|
|
b74351e55f | ||
|
|
a1b4dc42cb | ||
|
|
5ae5125919 | ||
|
|
82a68cd3da | ||
|
|
a41150836a | ||
|
|
e637b43117 | ||
|
|
443ba0f396 | ||
|
|
71ea4a2c9b | ||
|
|
a8ab18bd50 | ||
|
|
ce91423a19 | ||
|
|
5875d1419b | ||
|
|
24a9bc23b7 | ||
|
|
97c3688788 | ||
|
|
0b915b1dd2 | ||
|
|
5fcbfa780f | ||
|
|
a736010fdd | ||
|
|
b733125085 | ||
|
|
5ef36f1b6f | ||
|
|
7cc772cd39 | ||
|
|
7ae73fad68 | ||
|
|
96dcfd3cfe | ||
|
|
9833841101 | ||
|
|
1cd67b62e9 | ||
|
|
ffde9f7842 | ||
|
|
2819509786 | ||
|
|
5b222996c8 | ||
|
|
62e22b2995 | ||
|
|
2346be55fc | ||
|
|
61d0c4042b | ||
|
|
de0b373c7c | ||
|
|
2c1926993b | ||
|
|
e14a3af491 | ||
|
|
0968fd339f | ||
|
|
2ca1861a54 | ||
|
|
ce9daa4857 | ||
|
|
e15fb6b9b2 | ||
|
|
f1ffc72a62 | ||
|
|
37eee4235d | ||
|
|
871d530d6a | ||
|
|
16b1e84138 | ||
|
|
100ce7b62f | ||
|
|
c01cba3ab5 | ||
|
|
ef1607c088 | ||
|
|
123e8c8d2b | ||
|
|
9667eec9de | ||
|
|
26625f3e2a | ||
|
|
e94e6d8d95 | ||
|
|
f0bc50eb71 | ||
|
|
6163fb830e | ||
|
|
167948f5c3 | ||
|
|
37d191bc02 | ||
|
|
da7b648971 | ||
|
|
8b7f43f855 | ||
|
|
21770eb0f3 | ||
|
|
17be8023d9 | ||
|
|
9754c5b32b | ||
|
|
a16cb39423 | ||
|
|
dfefb05b10 | ||
|
|
55bdf2682c | ||
|
|
3a50ae92ec | ||
|
|
fe77f6a2f3 | ||
|
|
cd35218141 | ||
|
|
daeef8d5b3 | ||
|
|
184230058a | ||
|
|
a08b323e61 | ||
|
|
745cc5c655 | ||
|
|
3719c3b736 | ||
|
|
0e424de684 | ||
|
|
285ef0ca01 | ||
|
|
ce0df52b7e | ||
|
|
e03204dccf | ||
|
|
0dea2d8515 | ||
|
|
31469bb05b | ||
|
|
b4f8e5cdb9 | ||
|
|
cefec77646 | ||
|
|
7c7adc1361 | ||
|
|
af6609b0a3 | ||
|
|
3ae950d829 | ||
|
|
c2f64d4da1 | ||
|
|
9b941dd800 | ||
|
|
4b9f6baf79 | ||
|
|
a675cbd13b | ||
|
|
bd77afb2df | ||
|
|
681f5a521f | ||
|
|
f55b9a8530 | ||
|
|
da6f954e0d | ||
|
|
453eaf6871 | ||
|
|
0ce709d96a | ||
|
|
fd808dec52 | ||
|
|
ac949f8181 | ||
|
|
48c2c8c049 | ||
|
|
2e2e134a1b | ||
|
|
4e8bd97d9c | ||
|
|
a31eb6a80c | ||
|
|
b0dd7bee5b | ||
|
|
a291c1676f | ||
|
|
7bfa302b75 | ||
|
|
0935ab14d6 | ||
|
|
9797b676b1 | ||
|
|
2b02f7eb99 | ||
|
|
71e2c26577 | ||
|
|
b78b36ce33 | ||
|
|
0130efeedf | ||
|
|
35b51fcbb5 | ||
|
|
9a5aa059f9 | ||
|
|
8b91360a33 | ||
|
|
85d80d8fb7 | ||
|
|
695da9ee29 | ||
|
|
d114e9040b | ||
|
|
c600196b1a | ||
|
|
3d8edcb77b | ||
|
|
f496740c19 | ||
|
|
0c2a207d82 | ||
|
|
e9c456ff5c | ||
|
|
bcbe1b410a | ||
|
|
206820d27a | ||
|
|
8d8b72cf3f | ||
|
|
a3cc9aaf6f | ||
|
|
812424bf46 | ||
|
|
8af05c28a3 | ||
|
|
970600724d | ||
|
|
c038f513d3 | ||
|
|
1e5978ad4f | ||
|
|
2dbc991af9 | ||
|
|
c4b9c12677 | ||
|
|
d7759b88ee | ||
|
|
25e4fcf5c8 | ||
|
|
ce382788b0 |
44
.github/ISSUE_TEMPLATE/1-bug-report.yml
vendored
44
.github/ISSUE_TEMPLATE/1-bug-report.yml
vendored
@@ -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.
|
||||
35
.github/ISSUE_TEMPLATE/1-install-problem.yml
vendored
Normal file
35
.github/ISSUE_TEMPLATE/1-install-problem.yml
vendored
Normal 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
44
.github/ISSUE_TEMPLATE/2-bug-report.yml
vendored
Normal 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?
|
||||
25
.github/ISSUE_TEMPLATE/2-feature-request.yml
vendored
25
.github/ISSUE_TEMPLATE/2-feature-request.yml
vendored
@@ -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?
|
||||
@@ -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
|
||||
24
.github/ISSUE_TEMPLATE/3-feature-request.yml
vendored
Normal file
24
.github/ISSUE_TEMPLATE/3-feature-request.yml
vendored
Normal 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?
|
||||
31
.github/ISSUE_TEMPLATE/4-docs-problem.yml
vendored
Normal file
31
.github/ISSUE_TEMPLATE/4-docs-problem.yml
vendored
Normal 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.
|
||||
4
.github/ISSUE_TEMPLATE/config.yml
vendored
4
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -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
2
.github/labels.yml
vendored
@@ -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
29
.github/workflows/bun-homebrew.yml
vendored
Normal 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 }}
|
||||
10
.github/workflows/bun-linux-build.yml
vendored
10
.github/workflows/bun-linux-build.yml
vendored
@@ -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}}
|
||||
|
||||
25
.github/workflows/bun-mac-aarch64.yml
vendored
25
.github/workflows/bun-mac-aarch64.yml
vendored
@@ -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 }}
|
||||
|
||||
27
.github/workflows/bun-mac-x64-baseline.yml
vendored
27
.github/workflows/bun-mac-x64-baseline.yml
vendored
@@ -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 }}
|
||||
|
||||
28
.github/workflows/bun-mac-x64.yml
vendored
28
.github/workflows/bun-mac-x64.yml
vendored
@@ -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
9
.gitmodules
vendored
@@ -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
|
||||
|
||||
23
.vscode/c_cpp_properties.json
vendored
23
.vscode/c_cpp_properties.json
vendored
@@ -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
2
.vscode/launch.json
generated
vendored
@@ -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": {
|
||||
|
||||
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -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
|
||||
}
|
||||
|
||||
54
Dockerfile
54
Dockerfile
@@ -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
|
||||
|
||||
@@ -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
129
Makefile
@@ -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
|
||||
|
||||
|
||||
17
bench/fetch/bun.js
Normal file
17
bench/fetch/bun.js
Normal 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
17
bench/fetch/deno.js
Normal 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
17
bench/fetch/node.mjs
Normal 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();
|
||||
@@ -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" },
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
56
bench/snippets/array-map.mjs
Normal file
56
bench/snippets/array-map.mjs
Normal 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
30
bench/snippets/blob.mjs
Normal 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
25
bench/snippets/crypto.mjs
Normal 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();
|
||||
12
bench/snippets/index-of.mjs
Normal file
12
bench/snippets/index-of.mjs
Normal 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();
|
||||
64
bench/snippets/object-entries.mjs
Normal file
64
bench/snippets/object-entries.mjs
Normal 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();
|
||||
13
bench/snippets/readdir.mjs
Normal file
13
bench/snippets/readdir.mjs
Normal 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);
|
||||
16
bench/snippets/return-await.mjs
Normal file
16
bench/snippets/return-await.mjs
Normal 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();
|
||||
13
bench/snippets/spawn-hugemem.mjs
Normal file
13
bench/snippets/spawn-hugemem.mjs
Normal 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();
|
||||
13
bench/snippets/spawn-hugemem.node.mjs
Normal file
13
bench/snippets/spawn-hugemem.node.mjs
Normal 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
8
bench/snippets/spawn.mjs
Normal file
@@ -0,0 +1,8 @@
|
||||
import { spawnSync } from "bun";
|
||||
import { bench, run } from "mitata";
|
||||
|
||||
bench("spawnSync echo hi", () => {
|
||||
spawnSync({ cmd: ["echo", "hi"] });
|
||||
});
|
||||
|
||||
await run();
|
||||
8
bench/snippets/spawn.node.mjs
Normal file
8
bench/snippets/spawn.node.mjs
Normal 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();
|
||||
28
bench/snippets/string-decoder.mjs
Normal file
28
bench/snippets/string-decoder.mjs
Normal 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();
|
||||
49
bench/snippets/tcp-echo.bun.ts
Normal file
49
bench/snippets/tcp-echo.bun.ts
Normal 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,
|
||||
});
|
||||
52
bench/snippets/tcp-echo.node.mjs
Normal file
52
bench/snippets/tcp-echo.node.mjs
Normal 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);
|
||||
24
bench/snippets/write.bun.js
Normal file
24
bench/snippets/write.bun.js
Normal 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();
|
||||
27
bench/snippets/write.node.mjs
Normal file
27
bench/snippets/write.node.mjs
Normal 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();
|
||||
@@ -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
169
bench/websocket-server/.gitignore
vendored
Normal 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.\*
|
||||
39
bench/websocket-server/README.md
Normal file
39
bench/websocket-server/README.md
Normal 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.
|
||||
182
bench/websocket-server/chat-client.mjs
Normal file
182
bench/websocket-server/chat-client.mjs
Normal 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();
|
||||
56
bench/websocket-server/chat-server.bun.js
Normal file
56
bench/websocket-server/chat-server.bun.js
Normal 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}/`
|
||||
);
|
||||
48
bench/websocket-server/chat-server.deno.mjs
Normal file
48
bench/websocket-server/chat-server.deno.mjs
Normal 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 });
|
||||
52
bench/websocket-server/chat-server.node.mjs
Normal file
52
bench/websocket-server/chat-server.node.mjs
Normal 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);
|
||||
}
|
||||
13
bench/websocket-server/package.json
Normal file
13
bench/websocket-server/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
@@ -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"]
|
||||
}
|
||||
19
build.zig
19
build.zig
@@ -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);
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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[]' &&
|
||||
|
||||
@@ -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
5
docs/runtime/streams.md
Normal 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`
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"name": "@bun-examples/blank",
|
||||
"version": "0.0.3",
|
||||
"module": "src/index.js",
|
||||
"devDependencies": {
|
||||
"bun-types": "latest"
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
```
|
||||
@@ -1 +0,0 @@
|
||||
console.log('Hello, World!');
|
||||
42
examples/bun-bakery/.gitignore
vendored
42
examples/bun-bakery/.gitignore
vendored
@@ -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 |
@@ -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
|
||||
@@ -1,8 +0,0 @@
|
||||
import {Router} from "@kapsonfire/bun-bakery"
|
||||
|
||||
|
||||
new Router({
|
||||
port: 3000,
|
||||
assetsPath: import.meta.dir + '/assets/',
|
||||
routesPath: import.meta.dir + '/routes/'
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": "1.0.4",
|
||||
"name": "@bun-examples/bun-bakery",
|
||||
"dependencies": {
|
||||
"@kapsonfire/bun-bakery": "^0.2.0"
|
||||
}
|
||||
}
|
||||
@@ -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>');
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"types": ["bun-types"],
|
||||
"module": "esnext",
|
||||
"moduleResolution": "Node"
|
||||
}
|
||||
}
|
||||
89
examples/bun-hot-websockets.js
Normal file
89
examples/bun-hot-websockets.js
Normal 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",
|
||||
},
|
||||
}
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
DISCORD_APP_ID=
|
||||
DISCORD_BOT_TOKEN=
|
||||
DISCORD_PUBLIC_KEY=
|
||||
88
examples/discord-interactions/.gitignore
vendored
88
examples/discord-interactions/.gitignore
vendored
@@ -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
|
||||
@@ -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.
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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()}`);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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}`;
|
||||
}
|
||||
}
|
||||
@@ -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}!`;
|
||||
}
|
||||
}
|
||||
@@ -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}`);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": "0.0.9",
|
||||
"name": "@bun-examples/discord-interactions",
|
||||
"dependencies": {
|
||||
"slash-create": "^5.7.0"
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
Error.captureStackTrace = () => {};
|
||||
Buffer.isBuffer = Buffer.isBuffer.bind(Buffer);
|
||||
@@ -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
|
||||
@@ -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 |
@@ -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/>
|
||||
@@ -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
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["ESNext"],
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
"moduleResolution": "node",
|
||||
// "bun-types" is the important part
|
||||
"types": ["bun-types"]
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
16
examples/http-request-body.ts
Normal file
16
examples/http-request-body.ts
Normal 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") });
|
||||
},
|
||||
});
|
||||
@@ -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.
@@ -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
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"restartable": "rs",
|
||||
"ignore": [".git", "node_modules/", "__tests__", "test"],
|
||||
"exec": "bun src/index.ts",
|
||||
"ext": "js, json, ts"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import KingWorld from 'kingworld'
|
||||
|
||||
new KingWorld()
|
||||
.get("/", () => "Hello KingWorld")
|
||||
.listen(3000)
|
||||
|
||||
console.log('🦊 KINGWORLD is running at :3000')
|
||||
@@ -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. */
|
||||
}
|
||||
}
|
||||
@@ -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
Reference in New Issue
Block a user