mirror of
https://github.com/oven-sh/bun
synced 2026-02-03 15:38:46 +00:00
Compare commits
449 Commits
dylan/gith
...
create-con
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf46115f6d | ||
|
|
ef75cd4658 | ||
|
|
af3f42e630 | ||
|
|
37186f4b0a | ||
|
|
f310d7414b | ||
|
|
739de2c9cd | ||
|
|
0db8cdf4e9 | ||
|
|
246db4fed0 | ||
|
|
aa0762e466 | ||
|
|
cdbc620104 | ||
|
|
bb2aaa36fb | ||
|
|
f4f88701c5 | ||
|
|
cc214baacf | ||
|
|
83473c60df | ||
|
|
8b4e58f3d2 | ||
|
|
30e82c5df4 | ||
|
|
9eba1e0e3f | ||
|
|
675529bd0c | ||
|
|
5528c0fa47 | ||
|
|
c208c4e319 | ||
|
|
10650cced2 | ||
|
|
8466e60e3a | ||
|
|
b1aac9ff6d | ||
|
|
ed2e0e1617 | ||
|
|
09585c4b24 | ||
|
|
5181aa54e2 | ||
|
|
995880a7ef | ||
|
|
941c6ed814 | ||
|
|
6052a3edbd | ||
|
|
6fd7c1921e | ||
|
|
119120d21c | ||
|
|
4bedd3833d | ||
|
|
2abfa8abd2 | ||
|
|
ad9d4fb0c4 | ||
|
|
523b112945 | ||
|
|
8aa29040e6 | ||
|
|
a2afb252bf | ||
|
|
abb89f489f | ||
|
|
ddec9e0bf6 | ||
|
|
4962bea4fc | ||
|
|
f31330d3e2 | ||
|
|
ee8ccca605 | ||
|
|
6fdbb25f9a | ||
|
|
b8c0554839 | ||
|
|
18807cef03 | ||
|
|
cbc28afd51 | ||
|
|
7886bce8c8 | ||
|
|
7cd26232b1 | ||
|
|
a0b0cd6844 | ||
|
|
52f9c3d05e | ||
|
|
f947987a2c | ||
|
|
30106c4f54 | ||
|
|
34b2d7fe57 | ||
|
|
153834cf5c | ||
|
|
6aea31f4fc | ||
|
|
0fd144993c | ||
|
|
6699fe14e7 | ||
|
|
add7b1101e | ||
|
|
5a19f8434b | ||
|
|
d5f3bb1c74 | ||
|
|
08e33fbd42 | ||
|
|
7ddbbc53b4 | ||
|
|
85611272c6 | ||
|
|
c40912b8dc | ||
|
|
77974f2a6e | ||
|
|
ed72bee373 | ||
|
|
05f3a22cba | ||
|
|
f5df1044d4 | ||
|
|
4329f6ad16 | ||
|
|
fd4668d97c | ||
|
|
8c4ed963ec | ||
|
|
e7f9ce47f4 | ||
|
|
98022bec1e | ||
|
|
397f559e77 | ||
|
|
ca2e708be1 | ||
|
|
8649136845 | ||
|
|
e8fe6dd2f8 | ||
|
|
df126b2f3b | ||
|
|
7d3a2ca382 | ||
|
|
b7c96bfaae | ||
|
|
a2fd20e5c0 | ||
|
|
de613baf81 | ||
|
|
4590e2b83a | ||
|
|
2758e0cab9 | ||
|
|
7d386bf1f1 | ||
|
|
164cd774f7 | ||
|
|
6469649f64 | ||
|
|
06d073003d | ||
|
|
50f1dd61a6 | ||
|
|
c64d7933a1 | ||
|
|
b289b51894 | ||
|
|
17ad8005c7 | ||
|
|
f572305013 | ||
|
|
17b4e5ce08 | ||
|
|
3933ccab3b | ||
|
|
92255d56c8 | ||
|
|
ba076b0a2b | ||
|
|
10600c4abd | ||
|
|
d16dffa2b4 | ||
|
|
65e0d10ee0 | ||
|
|
742368f03a | ||
|
|
242dcea2fe | ||
|
|
198322073d | ||
|
|
b12762af6c | ||
|
|
440a21eb1d | ||
|
|
2bc4858346 | ||
|
|
26d15cf542 | ||
|
|
8361513acf | ||
|
|
19eca76498 | ||
|
|
3c23f9ad57 | ||
|
|
76f3c9c07b | ||
|
|
3a3bf33335 | ||
|
|
69ee87d8e2 | ||
|
|
6d0fff4fab | ||
|
|
f7a93fe294 | ||
|
|
02fc87ea29 | ||
|
|
7f853af6f0 | ||
|
|
04309431bb | ||
|
|
fc712ead2f | ||
|
|
e7f2d34c44 | ||
|
|
0c3e55132c | ||
|
|
c69bbbd24f | ||
|
|
c0bfdebbd9 | ||
|
|
9c27b5d17f | ||
|
|
9973df028b | ||
|
|
a0be199b4f | ||
|
|
73d6c888b9 | ||
|
|
661fca9cde | ||
|
|
b0803298f9 | ||
|
|
6318017f84 | ||
|
|
696d4b6267 | ||
|
|
cc4326cd82 | ||
|
|
c57b37d29f | ||
|
|
b09896f06e | ||
|
|
b7816f3175 | ||
|
|
0dfde6f8c7 | ||
|
|
0788bc1d94 | ||
|
|
28a7f27633 | ||
|
|
b2daf3c982 | ||
|
|
9598868b57 | ||
|
|
79b32f80fa | ||
|
|
4bfdad2981 | ||
|
|
3ddd8b2fa5 | ||
|
|
da598a3f37 | ||
|
|
ad3295668f | ||
|
|
f9fd7e9d08 | ||
|
|
8b8bd6a405 | ||
|
|
aa10799d8a | ||
|
|
ec2c16fefa | ||
|
|
c11bb93552 | ||
|
|
5c30983d5d | ||
|
|
c9ca729493 | ||
|
|
9cd9df698a | ||
|
|
57edf3d91f | ||
|
|
f9b14dc87b | ||
|
|
a9bdc0fd44 | ||
|
|
703bee976b | ||
|
|
eb5105aa09 | ||
|
|
552a1940eb | ||
|
|
98becc3538 | ||
|
|
49d8316922 | ||
|
|
7a496fa41a | ||
|
|
4211f733d1 | ||
|
|
44eec0c5bb | ||
|
|
ac64d87a1c | ||
|
|
8e52e36846 | ||
|
|
348e72356b | ||
|
|
035d31904a | ||
|
|
192629c8ca | ||
|
|
75181ea1f3 | ||
|
|
d9c1a18776 | ||
|
|
f087388ebc | ||
|
|
48eb0c12ab | ||
|
|
fe389ad5ab | ||
|
|
97b637a0bc | ||
|
|
7e9c88aa41 | ||
|
|
07258bd559 | ||
|
|
0646efbf30 | ||
|
|
517bdbdd0c | ||
|
|
7f8be29f25 | ||
|
|
7db4b90837 | ||
|
|
cd48346ca8 | ||
|
|
1b6a99636d | ||
|
|
188c1f1f75 | ||
|
|
812490e4a4 | ||
|
|
128a293901 | ||
|
|
6557df2912 | ||
|
|
aff91436c0 | ||
|
|
8075158639 | ||
|
|
2757dc5e1b | ||
|
|
cd90342a76 | ||
|
|
8d622ad541 | ||
|
|
ed5bcf17fc | ||
|
|
9e46ca19d8 | ||
|
|
866646a98e | ||
|
|
4118c3d0a6 | ||
|
|
6029a57d0b | ||
|
|
309b741aa1 | ||
|
|
d90a00857b | ||
|
|
5ab2c8e4d6 | ||
|
|
c194f15418 | ||
|
|
3be8a4733a | ||
|
|
3243936d3e | ||
|
|
ec1ba91c38 | ||
|
|
ea55ef504b | ||
|
|
34b643e654 | ||
|
|
2e1c7f5597 | ||
|
|
6cccc0d26c | ||
|
|
0147647e06 | ||
|
|
ec010e4930 | ||
|
|
41af4b43e2 | ||
|
|
c1d05cf623 | ||
|
|
724f23c19f | ||
|
|
ddca89f425 | ||
|
|
805e87eeb6 | ||
|
|
8dc1140f43 | ||
|
|
b136125bb0 | ||
|
|
1da7f5fe5d | ||
|
|
655c19b07c | ||
|
|
ed5bcfc76b | ||
|
|
421588d631 | ||
|
|
915b46768c | ||
|
|
7169bbbb9c | ||
|
|
6d06606135 | ||
|
|
44c6ce11c4 | ||
|
|
b32b0b8736 | ||
|
|
fbe45fcb03 | ||
|
|
2c23d8736f | ||
|
|
f14032e4b4 | ||
|
|
d912214719 | ||
|
|
6c9e7de824 | ||
|
|
f8f989f667 | ||
|
|
781df80a90 | ||
|
|
b26ff0074d | ||
|
|
0a8e42a4ba | ||
|
|
b767f9a99a | ||
|
|
f61ee1ed42 | ||
|
|
a8743f0a34 | ||
|
|
468226fc90 | ||
|
|
9cb1ec2c58 | ||
|
|
0f2c9c9ff3 | ||
|
|
ed2a57fcc9 | ||
|
|
81b6878e1a | ||
|
|
325ffd70e1 | ||
|
|
d4ce045f9e | ||
|
|
7f65875406 | ||
|
|
ce38365106 | ||
|
|
a3cc911e7a | ||
|
|
ac7aff1b47 | ||
|
|
d714df48f9 | ||
|
|
fb1902448e | ||
|
|
f43b675200 | ||
|
|
e47fe2ca00 | ||
|
|
2edbf4d0ec | ||
|
|
645b7271f9 | ||
|
|
77c72b3193 | ||
|
|
34f97be86a | ||
|
|
2ffe77140e | ||
|
|
be79f6e893 | ||
|
|
bb5119f7eb | ||
|
|
6f682c6369 | ||
|
|
05b1ce39d2 | ||
|
|
6cf87d022f | ||
|
|
6c3842f67d | ||
|
|
63403741ff | ||
|
|
66643a5b57 | ||
|
|
e2f709b2a5 | ||
|
|
4ea104f5bd | ||
|
|
0fe7f7b6f0 | ||
|
|
566a2c668b | ||
|
|
ad692495a1 | ||
|
|
2c31beda75 | ||
|
|
cd684fdad0 | ||
|
|
ad40eec079 | ||
|
|
90d62ecc24 | ||
|
|
cab1f860e4 | ||
|
|
7ca867f7c8 | ||
|
|
fe03e90d80 | ||
|
|
f992942391 | ||
|
|
7420cb1d73 | ||
|
|
73961a1494 | ||
|
|
d7b5e4b901 | ||
|
|
efc024cfc4 | ||
|
|
b3533fb3a8 | ||
|
|
79c0b614ee | ||
|
|
f5cda8ff18 | ||
|
|
4570ff7780 | ||
|
|
aa456805dd | ||
|
|
efd33c398f | ||
|
|
9a2b586337 | ||
|
|
df999306c0 | ||
|
|
45296570ce | ||
|
|
f9306ff815 | ||
|
|
c530ead1e0 | ||
|
|
f6227bf6dd | ||
|
|
4f84c6bc34 | ||
|
|
d141783ebd | ||
|
|
d4ef935478 | ||
|
|
bf68df0070 | ||
|
|
407088f6ab | ||
|
|
2cce810190 | ||
|
|
eaea08ea45 | ||
|
|
4dfc09018f | ||
|
|
771db64cbe | ||
|
|
c6b941d803 | ||
|
|
3492248697 | ||
|
|
bc7192dca1 | ||
|
|
188f472ed2 | ||
|
|
befd97a891 | ||
|
|
481dbf7c6e | ||
|
|
8d692f1511 | ||
|
|
c08b546728 | ||
|
|
fefa4a1623 | ||
|
|
043e408b15 | ||
|
|
9f6658b981 | ||
|
|
5ce2b8e604 | ||
|
|
ee9893c4e1 | ||
|
|
8b0e2efd6e | ||
|
|
4d1e977399 | ||
|
|
0ee13892fd | ||
|
|
99d2d6e607 | ||
|
|
a2cfdf0e1c | ||
|
|
29a576a167 | ||
|
|
6424ce6397 | ||
|
|
fdb9472f88 | ||
|
|
17bde9bc86 | ||
|
|
fd29d05c6a | ||
|
|
f475802206 | ||
|
|
f0fa760479 | ||
|
|
24e8aa105f | ||
|
|
ed421855d7 | ||
|
|
627da44527 | ||
|
|
9955b74622 | ||
|
|
d955bfe50f | ||
|
|
b8648adf87 | ||
|
|
ff6fb587f6 | ||
|
|
e361ed4451 | ||
|
|
42e9f6e0b1 | ||
|
|
e3ed905b0a | ||
|
|
224312c014 | ||
|
|
bdf792adbc | ||
|
|
3c6616a23d | ||
|
|
ff7e984f0a | ||
|
|
3a100af876 | ||
|
|
7d7b535014 | ||
|
|
a98b1751a6 | ||
|
|
03ab4be9ee | ||
|
|
f993975ae6 | ||
|
|
53f7bd32d8 | ||
|
|
784496b773 | ||
|
|
4c0b0e2e8e | ||
|
|
bab7e63d7c | ||
|
|
3511a4b5be | ||
|
|
e485f7bb51 | ||
|
|
795cde6d62 | ||
|
|
9dfbf57397 | ||
|
|
e04fe64a82 | ||
|
|
495c70053f | ||
|
|
9bcd4952ce | ||
|
|
8745f10cd3 | ||
|
|
ac0dab3679 | ||
|
|
01c97e4033 | ||
|
|
cd5f2ab11f | ||
|
|
61736966ad | ||
|
|
8bdcded5c1 | ||
|
|
c0ec61cf16 | ||
|
|
d4e323b997 | ||
|
|
58cbd6b211 | ||
|
|
d8d148e3bb | ||
|
|
311185f6d6 | ||
|
|
7012d2fb74 | ||
|
|
2db04ef9d9 | ||
|
|
4cb6a34432 | ||
|
|
2016e8a0af | ||
|
|
0759530118 | ||
|
|
5ed46913c4 | ||
|
|
bd5b90fbf1 | ||
|
|
bba4054da3 | ||
|
|
d16951422b | ||
|
|
e0eeb1c07e | ||
|
|
216e872801 | ||
|
|
6fbf437f50 | ||
|
|
c00fadab9e | ||
|
|
9b260fb18b | ||
|
|
b931c19ba3 | ||
|
|
9e403fc8bf | ||
|
|
fd0edd7aa0 | ||
|
|
848658c533 | ||
|
|
37d2a98331 | ||
|
|
58d1ab02bd | ||
|
|
9f0d402a7d | ||
|
|
f927567b9f | ||
|
|
94ea41a60b | ||
|
|
8235e59a7f | ||
|
|
8924c521ba | ||
|
|
69875d86cd | ||
|
|
5bdc923838 | ||
|
|
25a2962186 | ||
|
|
c943dbadef | ||
|
|
aacaa9b85d | ||
|
|
74992f6f34 | ||
|
|
12b8416b64 | ||
|
|
8a5ff676ea | ||
|
|
f660f8d22f | ||
|
|
38cc947621 | ||
|
|
0546aa4fd5 | ||
|
|
b8b7ad4982 | ||
|
|
d21119b347 | ||
|
|
d3de366c67 | ||
|
|
a1b581621c | ||
|
|
274ae5de1b | ||
|
|
74b0a1939d | ||
|
|
6f432e8b7d | ||
|
|
a5f7a23307 | ||
|
|
88a8614abc | ||
|
|
b23327c283 | ||
|
|
c83d56c75d | ||
|
|
7dd28bbdd9 | ||
|
|
d54e23ca33 | ||
|
|
02f0212cbd | ||
|
|
3484502839 | ||
|
|
a345efd270 | ||
|
|
30bfb31bce | ||
|
|
eef0e8c6bf | ||
|
|
4648131c41 | ||
|
|
b0702ce7b1 | ||
|
|
ff3f5aa154 | ||
|
|
91bcfa9cb4 | ||
|
|
cf5f9df211 | ||
|
|
9eb4a4ff3a | ||
|
|
7932a55870 | ||
|
|
893ec2fb45 | ||
|
|
136014b13a | ||
|
|
d01ec47529 | ||
|
|
7fa023b8b5 | ||
|
|
aa9e56edfe | ||
|
|
88ffdc5fec | ||
|
|
fab42148e4 | ||
|
|
cce380ec37 | ||
|
|
828fd0cfea | ||
|
|
168bb1427f | ||
|
|
996ef44c02 | ||
|
|
734b5b89da | ||
|
|
490814aa35 | ||
|
|
ffa8913e54 | ||
|
|
73e9cd8e06 | ||
|
|
62cab3c719 | ||
|
|
d4f1d29393 | ||
|
|
2eac47a123 |
30
.github/workflows/bun-homebrew.yml
vendored
30
.github/workflows/bun-homebrew.yml
vendored
@@ -1,30 +0,0 @@
|
||||
name: bun-homebrew
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
- edited
|
||||
jobs:
|
||||
homebrew:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'oven-sh' && github.event.release.published_at != null
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: oven-sh/homebrew-bun
|
||||
token: ${{ env.HOMEBREW_TOKEN }}
|
||||
- id: setup-ruby
|
||||
name: Setup Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: '2.6'
|
||||
- id: update-tap
|
||||
name: Update Tap
|
||||
run: ruby scripts/release.rb "${{ github.event.release.tag_name }}"
|
||||
- id: commit-tap
|
||||
name: Commit Tap
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: Release ${{ github.event.release.tag_name }}
|
||||
165
.github/workflows/bun-linux-aarch64.yml
vendored
Normal file
165
.github/workflows/bun-linux-aarch64.yml
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
name: bun-linux
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
TEST_TAG: bun-test'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "src/**/*"
|
||||
- "test/**/*"
|
||||
- "build.zig"
|
||||
- "Makefile"
|
||||
- "Dockerfile"
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
name: ${{matrix.tag}}
|
||||
runs-on: ${{matrix.runner}}
|
||||
timeout-minutes: 90
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- cpu: native
|
||||
tag: linux-aarch64
|
||||
arch: aarch64
|
||||
build_arch: arm64
|
||||
runner: linux-arm64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-linux-arm64-lto.tar.gz"
|
||||
webkit_basename: "bun-webkit-linux-arm64-lto"
|
||||
build_machine_arch: aarch64
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: docker/setup-buildx-action@v2
|
||||
id: buildx
|
||||
with:
|
||||
install: true
|
||||
- name: Run
|
||||
run: |
|
||||
rm -rf ${{runner.temp}}/release
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: |
|
||||
mkdir -p /tmp/.buildx-cache-${{matrix.tag}}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
cache-from: type=local,src=/tmp/.buildx-cache-${{matrix.tag}}
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache-${{matrix.tag}}
|
||||
build-args: |
|
||||
ARCH=${{matrix.arch}}
|
||||
BUILDARCH=${{matrix.build_arch}}
|
||||
BUILD_MACHINE_ARCH=${{matrix.build_machine_arch}}
|
||||
CPU_TARGET=${{matrix.cpu}}
|
||||
WEBKIT_URL=${{matrix.webkit_url}}
|
||||
GIT_SHA=${{github.sha}}
|
||||
WEBKIT_BASENAME=${{matrix.webkit_basename}}
|
||||
platforms: linux/${{matrix.build_arch}}
|
||||
target: artifact
|
||||
outputs: type=local,dest=${{runner.temp}}/release
|
||||
- name: Zip
|
||||
run: |
|
||||
# if zip is not found
|
||||
if [ ! -x "$(command -v zip)" ]; then
|
||||
sudo apt-get update && sudo apt-get install -y zip --no-install-recommends
|
||||
fi
|
||||
|
||||
if [ ! -x "$(command -v strip)" ]; then
|
||||
sudo apt-get update && sudo apt-get install -y binutils --no-install-recommends
|
||||
fi
|
||||
|
||||
cd ${{runner.temp}}/release
|
||||
chmod +x bun-profile bun
|
||||
|
||||
mkdir bun-${{matrix.tag}}-profile
|
||||
mkdir bun-${{matrix.tag}}
|
||||
|
||||
strip bun
|
||||
|
||||
mv bun-profile bun-${{matrix.tag}}-profile/bun-profile
|
||||
mv bun bun-${{matrix.tag}}/bun
|
||||
|
||||
zip -r bun-${{matrix.tag}}-profile.zip bun-${{matrix.tag}}-profile
|
||||
zip -r bun-${{matrix.tag}}.zip bun-${{matrix.tag}}
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bun-${{matrix.tag}}-profile
|
||||
path: ${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bun-${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release/bun-${{matrix.tag}}.zip
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bun-obj-${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release/bun-obj
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{matrix.tag}}-dependencies
|
||||
path: ${{runner.temp}}/release/bun-dependencies
|
||||
- name: Release
|
||||
id: release
|
||||
uses: ncipollo/release-action@v1
|
||||
if: |
|
||||
github.repository_owner == 'oven-sh'
|
||||
&& github.ref == 'refs/heads/main'
|
||||
with:
|
||||
prerelease: true
|
||||
body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"
|
||||
allowUpdates: true
|
||||
replacesArtifacts: true
|
||||
generateReleaseNotes: true
|
||||
artifactErrorsFailBuild: true
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: "Canary (${{github.sha}})"
|
||||
tag: "canary"
|
||||
artifacts: "${{runner.temp}}/release/bun-${{matrix.tag}}.zip,${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip"
|
||||
- id: setup-bun
|
||||
name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v0.1.8
|
||||
if: |
|
||||
github.repository_owner == 'oven-sh'
|
||||
&& github.ref == 'refs/heads/main'
|
||||
with:
|
||||
bun-version: canary
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# - name: Sign Release
|
||||
# id: sign-release
|
||||
# if: |
|
||||
# github.repository_owner == 'oven-sh'
|
||||
# && github.ref == 'refs/heads/main'
|
||||
# env:
|
||||
# GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
|
||||
# run: |
|
||||
# echo "$GPG_PASSPHRASE" | bun run .scripts/sign-release.ts
|
||||
# - name: Release Checksum
|
||||
# id: release-checksum
|
||||
# uses: ncipollo/release-action@v1
|
||||
# if: |
|
||||
# github.repository_owner == 'oven-sh'
|
||||
# && github.ref == 'refs/heads/main'
|
||||
# with:
|
||||
# prerelease: true
|
||||
# body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"
|
||||
# allowUpdates: true
|
||||
# replacesArtifacts: true
|
||||
# generateReleaseNotes: true
|
||||
# artifactErrorsFailBuild: true
|
||||
# token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# name: "Canary (${{github.sha}})"
|
||||
# tag: "canary"
|
||||
# artifacts: "SHASUMS256.txt,SHASUMS256.txt.asc"
|
||||
39
.github/workflows/bun-linux-build.yml
vendored
39
.github/workflows/bun-linux-build.yml
vendored
@@ -32,32 +32,25 @@ jobs:
|
||||
runs-on: ${{matrix.runner}}
|
||||
timeout-minutes: 90
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- cpu: haswell
|
||||
tag: linux-x64
|
||||
arch: x86_64
|
||||
build_arch: amd64
|
||||
runner: linux-amd64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-linux-amd64-lto.tar.gz"
|
||||
runner: big-ubuntu
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-linux-amd64-lto.tar.gz"
|
||||
webkit_basename: "bun-webkit-linux-amd64-lto"
|
||||
build_machine_arch: x86_64
|
||||
- cpu: westmere
|
||||
- cpu: nehalem
|
||||
tag: linux-x64-baseline
|
||||
arch: x86_64
|
||||
build_arch: amd64
|
||||
runner: linux-amd64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-linux-amd64-lto.tar.gz"
|
||||
runner: big-ubuntu
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-linux-amd64-lto.tar.gz"
|
||||
webkit_basename: "bun-webkit-linux-amd64-lto"
|
||||
build_machine_arch: x86_64
|
||||
- cpu: native
|
||||
tag: linux-aarch64
|
||||
arch: aarch64
|
||||
build_arch: arm64
|
||||
runner: linux-arm64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-linux-arm64-lto.tar.gz"
|
||||
webkit_basename: "bun-webkit-linux-arm64-lto"
|
||||
build_machine_arch: aarch64
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -128,10 +121,20 @@ jobs:
|
||||
with:
|
||||
name: bun-${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release/bun-${{matrix.tag}}.zip
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bun-obj-${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release/bun-obj
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{matrix.tag}}-dependencies
|
||||
path: ${{runner.temp}}/release/bun-dependencies
|
||||
- name: Release
|
||||
id: release
|
||||
uses: ncipollo/release-action@v1
|
||||
if: github.ref == 'refs/heads/main'
|
||||
if: |
|
||||
github.repository_owner == 'oven-sh'
|
||||
&& github.ref == 'refs/heads/main'
|
||||
with:
|
||||
prerelease: true
|
||||
body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"
|
||||
@@ -143,11 +146,3 @@ jobs:
|
||||
name: "Canary (${{github.sha}})"
|
||||
tag: "canary"
|
||||
artifacts: "${{runner.temp}}/release/bun-${{matrix.tag}}.zip,${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip"
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bun-obj-${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release/bun-obj
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{matrix.tag}}-dependencies
|
||||
path: ${{runner.temp}}/release/bun-dependencies
|
||||
|
||||
30
.github/workflows/bun-mac-aarch64.yml
vendored
30
.github/workflows/bun-mac-aarch64.yml
vendored
@@ -27,11 +27,11 @@ on:
|
||||
jobs:
|
||||
macos-object-files:
|
||||
name: macOS Object
|
||||
runs-on: zig-object
|
||||
runs-on: med-ubuntu
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# - cpu: westmere
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-obj-darwin-x64-baseline
|
||||
# - cpu: haswell
|
||||
@@ -104,13 +104,13 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# - cpu: westmere
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# runner: macos-11
|
||||
# artifact: bun-obj-darwin-x64-baseline
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: true
|
||||
# compile_obj: false
|
||||
# - cpu: haswell
|
||||
@@ -119,16 +119,16 @@ jobs:
|
||||
# obj: bun-obj-darwin-x64
|
||||
# runner: macos-11
|
||||
# artifact: bun-obj-darwin-x64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: true
|
||||
# compile_obj: false
|
||||
# - cpu: westmere
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# runner: macos-11
|
||||
# artifact: bun-obj-darwin-x64-baseline
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: false
|
||||
# compile_obj: true
|
||||
# - cpu: haswell
|
||||
@@ -137,7 +137,7 @@ jobs:
|
||||
# obj: bun-obj-darwin-x64
|
||||
# runner: macos-11
|
||||
# artifact: bun-obj-darwin-x64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: false
|
||||
# compile_obj: true
|
||||
- cpu: native
|
||||
@@ -145,7 +145,7 @@ jobs:
|
||||
tag: bun-darwin-aarch64
|
||||
obj: bun-obj-darwin-aarch64
|
||||
artifact: bun-obj-darwin-aarch64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
runner: macos-arm64
|
||||
dependencies: true
|
||||
compile_obj: true
|
||||
@@ -242,14 +242,14 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# - cpu: westmere
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# package: bun-darwin-x64
|
||||
# runner: macos-11
|
||||
# artifact: bun-obj-darwin-x64-baseline
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
@@ -257,14 +257,14 @@ jobs:
|
||||
# package: bun-darwin-x64
|
||||
# runner: macos-11
|
||||
# artifact: bun-obj-darwin-x64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
- cpu: native
|
||||
arch: aarch64
|
||||
tag: bun-darwin-aarch64
|
||||
obj: bun-obj-darwin-aarch64
|
||||
package: bun-darwin-aarch64
|
||||
artifact: bun-obj-darwin-aarch64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
runner: macos-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -370,7 +370,9 @@ jobs:
|
||||
- name: Release
|
||||
id: release
|
||||
uses: ncipollo/release-action@v1
|
||||
if: github.ref == 'refs/heads/main'
|
||||
if: |
|
||||
github.repository_owner == 'oven-sh'
|
||||
&& github.ref == 'refs/heads/main'
|
||||
with:
|
||||
prerelease: true
|
||||
body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"
|
||||
|
||||
30
.github/workflows/bun-mac-x64-baseline.yml
vendored
30
.github/workflows/bun-mac-x64-baseline.yml
vendored
@@ -27,11 +27,11 @@ on:
|
||||
jobs:
|
||||
macos-object-files:
|
||||
name: macOS Object
|
||||
runs-on: zig-object
|
||||
runs-on: med-ubuntu
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- cpu: westmere
|
||||
- cpu: nehalem
|
||||
arch: x86_64
|
||||
tag: bun-obj-darwin-x64-baseline
|
||||
# - cpu: haswell
|
||||
@@ -104,13 +104,13 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- cpu: westmere
|
||||
- cpu: nehalem
|
||||
arch: x86_64
|
||||
tag: bun-darwin-x64-baseline
|
||||
obj: bun-obj-darwin-x64-baseline
|
||||
runner: macos-11
|
||||
artifact: bun-obj-darwin-x64-baseline
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
dependencies: true
|
||||
compile_obj: false
|
||||
# - cpu: haswell
|
||||
@@ -119,16 +119,16 @@ jobs:
|
||||
# obj: bun-obj-darwin-x64
|
||||
# runner: macos-11
|
||||
# artifact: bun-obj-darwin-x64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: true
|
||||
# compile_obj: false
|
||||
- cpu: westmere
|
||||
- cpu: nehalem
|
||||
arch: x86_64
|
||||
tag: bun-darwin-x64-baseline
|
||||
obj: bun-obj-darwin-x64-baseline
|
||||
runner: macos-11
|
||||
artifact: bun-obj-darwin-x64-baseline
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
dependencies: false
|
||||
compile_obj: true
|
||||
# - cpu: haswell
|
||||
@@ -137,7 +137,7 @@ jobs:
|
||||
# obj: bun-obj-darwin-x64
|
||||
# runner: macos-11
|
||||
# artifact: bun-obj-darwin-x64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: false
|
||||
# compile_obj: true
|
||||
# - cpu: native
|
||||
@@ -145,7 +145,7 @@ jobs:
|
||||
# tag: bun-darwin-aarch64
|
||||
# obj: bun-obj-darwin-aarch64
|
||||
# artifact: bun-obj-darwin-aarch64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# runner: macos-arm64
|
||||
# dependencies: true
|
||||
# compile_obj: true
|
||||
@@ -243,14 +243,14 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- cpu: westmere
|
||||
- cpu: nehalem
|
||||
arch: x86_64
|
||||
tag: bun-darwin-x64-baseline
|
||||
obj: bun-obj-darwin-x64-baseline
|
||||
package: bun-darwin-x64
|
||||
runner: macos-11
|
||||
artifact: bun-obj-darwin-x64-baseline
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
@@ -258,14 +258,14 @@ jobs:
|
||||
# package: bun-darwin-x64
|
||||
# runner: macos-11
|
||||
# artifact: bun-obj-darwin-x64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# - cpu: native
|
||||
# arch: aarch64
|
||||
# tag: bun-darwin-aarch64
|
||||
# obj: bun-obj-darwin-aarch64
|
||||
# package: bun-darwin-aarch64
|
||||
# artifact: bun-obj-darwin-aarch64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# runner: macos-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -374,7 +374,9 @@ jobs:
|
||||
- name: Release
|
||||
id: release
|
||||
uses: ncipollo/release-action@v1
|
||||
if: github.ref == 'refs/heads/main'
|
||||
if: |
|
||||
github.repository_owner == 'oven-sh'
|
||||
&& github.ref == 'refs/heads/main'
|
||||
with:
|
||||
prerelease: true
|
||||
body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"
|
||||
|
||||
30
.github/workflows/bun-mac-x64.yml
vendored
30
.github/workflows/bun-mac-x64.yml
vendored
@@ -27,11 +27,11 @@ on:
|
||||
jobs:
|
||||
macos-object-files:
|
||||
name: macOS Object
|
||||
runs-on: zig-object
|
||||
runs-on: med-ubuntu
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# - cpu: westmere
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-obj-darwin-x64-baseline
|
||||
- cpu: haswell
|
||||
@@ -104,13 +104,13 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# - cpu: westmere
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# runner: macos-11
|
||||
# artifact: bun-obj-darwin-x64-baseline
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: true
|
||||
# compile_obj: false
|
||||
- cpu: haswell
|
||||
@@ -119,16 +119,16 @@ jobs:
|
||||
obj: bun-obj-darwin-x64
|
||||
runner: macos-11
|
||||
artifact: bun-obj-darwin-x64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
dependencies: true
|
||||
compile_obj: false
|
||||
# - cpu: westmere
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# runner: macos-11
|
||||
# artifact: bun-obj-darwin-x64-baseline
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: false
|
||||
# compile_obj: true
|
||||
- cpu: haswell
|
||||
@@ -137,7 +137,7 @@ jobs:
|
||||
obj: bun-obj-darwin-x64
|
||||
runner: macos-11
|
||||
artifact: bun-obj-darwin-x64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
dependencies: false
|
||||
compile_obj: true
|
||||
# - cpu: native
|
||||
@@ -145,7 +145,7 @@ jobs:
|
||||
# tag: bun-darwin-aarch64
|
||||
# obj: bun-obj-darwin-aarch64
|
||||
# artifact: bun-obj-darwin-aarch64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
# runner: macos-arm64
|
||||
# dependencies: true
|
||||
# compile_obj: true
|
||||
@@ -245,14 +245,14 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# - cpu: westmere
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# package: bun-darwin-x64
|
||||
# runner: macos-11
|
||||
# artifact: bun-obj-darwin-x64-baseline
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
- cpu: haswell
|
||||
arch: x86_64
|
||||
tag: bun-darwin-x64
|
||||
@@ -260,14 +260,14 @@ jobs:
|
||||
package: bun-darwin-x64
|
||||
runner: macos-11
|
||||
artifact: bun-obj-darwin-x64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# - cpu: native
|
||||
# arch: aarch64
|
||||
# tag: bun-darwin-aarch64
|
||||
# obj: bun-obj-darwin-aarch64
|
||||
# package: bun-darwin-aarch64
|
||||
# artifact: bun-obj-darwin-aarch64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
# runner: macos-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -376,7 +376,9 @@ jobs:
|
||||
- name: Release
|
||||
id: release
|
||||
uses: ncipollo/release-action@v1
|
||||
if: github.ref == 'refs/heads/main'
|
||||
if: |
|
||||
github.repository_owner == 'oven-sh'
|
||||
&& github.ref == 'refs/heads/main'
|
||||
with:
|
||||
prerelease: true
|
||||
body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"
|
||||
|
||||
116
.github/workflows/bun-release-canary.yml
vendored
Normal file
116
.github/workflows/bun-release-canary.yml
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
name: bun-release-canary
|
||||
concurrency: release-canary
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 14 * * *" # every day at 6am PST
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
npm:
|
||||
name: Release to NPM
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-release
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: setup-bun
|
||||
name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v0.1.8
|
||||
with:
|
||||
bun-version: canary
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- id: bun-install
|
||||
name: Install Dependencies
|
||||
run: bun install
|
||||
- id: bun-run
|
||||
name: Release
|
||||
run: bun upload-npm -- canary publish
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
npm-types:
|
||||
name: Release types to NPM
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-types
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: setup-node
|
||||
name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: latest
|
||||
- id: setup-bun
|
||||
name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v0.1.8
|
||||
with:
|
||||
bun-version: canary
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- id: bun-install
|
||||
name: Install Dependencies
|
||||
run: |
|
||||
bun upgrade --canary
|
||||
bun install
|
||||
- id: setup-env
|
||||
name: Setup Environment
|
||||
run: |
|
||||
SHA=$(git rev-parse --short "$GITHUB_SHA")
|
||||
VERSION=$(bun --version)
|
||||
TAG="${VERSION}-canary.$(date '+%Y%m%d').1+${SHA}"
|
||||
echo "Setup tag: ${TAG}"
|
||||
echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
- id: bun-run
|
||||
name: Build
|
||||
run: bun run build
|
||||
env:
|
||||
BUN_VERSION: ${{ env.TAG }}
|
||||
- id: npm-publish
|
||||
name: Release
|
||||
uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
package: packages/bun-types/dist/package.json
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
tag: canary
|
||||
docker:
|
||||
name: Release to Dockerhub
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: qemu
|
||||
name: Setup Docker QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- id: buildx
|
||||
name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
- id: metadata
|
||||
name: Setup Docker metadata
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: oven/bun
|
||||
tags: canary
|
||||
- id: login
|
||||
name: Login to Docker
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- id: push
|
||||
name: Push to Docker
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: ./dockerhub
|
||||
file: ./dockerhub/Dockerfile-debian
|
||||
platforms: linux/amd64,linux/arm64
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
push: true
|
||||
tags: ${{ steps.metadata.outputs.tags }}
|
||||
labels: ${{ steps.metadata.outputs.labels }}
|
||||
210
.github/workflows/bun-release.yml
vendored
Normal file
210
.github/workflows/bun-release.yml
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
name: bun-release
|
||||
concurrency: release
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
type: string
|
||||
description: The tag to publish
|
||||
required: true
|
||||
jobs:
|
||||
sign:
|
||||
name: Sign Release
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-release
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: setup-env
|
||||
name: Setup Environment
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
|
||||
echo "Setup tag: ${TAG}"
|
||||
echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
- id: setup-bun
|
||||
name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v0.1.8
|
||||
with:
|
||||
bun-version: canary
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- id: bun-install
|
||||
name: Install Dependencies
|
||||
run: bun install
|
||||
- id: bun-run
|
||||
name: Sign Release
|
||||
run: |
|
||||
echo "$GPG_PASSPHRASE" | bun upload-assets -- "${{ env.TAG }}"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
|
||||
npm:
|
||||
name: Release to NPM
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-release
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: setup-env
|
||||
name: Setup Environment
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
|
||||
echo "Setup tag: ${TAG}"
|
||||
echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
- id: setup-bun
|
||||
name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v0.1.8
|
||||
with:
|
||||
bun-version: canary
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- id: bun-install
|
||||
name: Install Dependencies
|
||||
run: bun install
|
||||
- id: bun-run
|
||||
name: Release
|
||||
run: bun upload-npm -- "${{ env.TAG }}" publish
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
npm-types:
|
||||
name: Release types to NPM
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-types
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: setup-env
|
||||
name: Setup Environment
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
|
||||
echo "Setup tag: ${TAG}"
|
||||
echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
- id: setup-node
|
||||
name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: latest
|
||||
- id: setup-bun
|
||||
name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v0.1.8
|
||||
with:
|
||||
bun-version: canary
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- id: bun-install
|
||||
name: Install Dependencies
|
||||
run: |
|
||||
bun upgrade --canary
|
||||
bun install
|
||||
- id: bun-run
|
||||
name: Build
|
||||
run: bun run build
|
||||
env:
|
||||
BUN_VERSION: ${{ env.TAG }}
|
||||
- id: npm-publish
|
||||
name: Release
|
||||
uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
package: packages/bun-types/dist/package.json
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
docker:
|
||||
name: Release to Dockerhub
|
||||
runs-on: ubuntu-latest
|
||||
needs: sign
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: environment
|
||||
name: Setup Environment
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
|
||||
echo "Setup tag: ${TAG}"
|
||||
echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
- id: qemu
|
||||
name: Setup Docker QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- id: buildx
|
||||
name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
- id: metadata
|
||||
name: Setup Docker metadata
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: oven/bun
|
||||
tags: |
|
||||
type=match,pattern=(bun-v)?(\d.\d.\d),group=2,value=${{ env.TAG }}
|
||||
type=match,pattern=(bun-v)?(\d.\d),group=2,value=${{ env.TAG }}
|
||||
- id: login
|
||||
name: Login to Docker
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- id: push
|
||||
name: Push to Docker
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: ./dockerhub
|
||||
file: ./dockerhub/Dockerfile-debian
|
||||
platforms: linux/amd64,linux/arm64
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
push: true
|
||||
tags: ${{ steps.metadata.outputs.tags }}
|
||||
labels: ${{ steps.metadata.outputs.labels }}
|
||||
homebrew:
|
||||
name: Release to Homebrew
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: oven-sh/homebrew-bun
|
||||
token: ${{ secrets.ROBOBUN_TOKEN }}
|
||||
- id: setup-gpg
|
||||
name: Setup GPG
|
||||
uses: crazy-max/ghaction-import-gpg@v5
|
||||
with:
|
||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||
passphrase: ${{ secrets.GPG_PASSPHRASE }}
|
||||
- id: setup-env
|
||||
name: Setup Environment
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
|
||||
echo "Setup tag: ${TAG}"
|
||||
echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
- id: setup-ruby
|
||||
name: Setup Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: "2.6"
|
||||
- id: update-tap
|
||||
name: Update Tap
|
||||
run: ruby scripts/release.rb "${{ env.TAG }}"
|
||||
- id: commit-tap
|
||||
name: Commit Tap
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_options: --gpg-sign=${{ steps.setup-gpg.outputs.keyid }}
|
||||
commit_message: Release ${{ env.TAG }}
|
||||
commit_user_name: robobun
|
||||
commit_user_email: robobun@oven.sh
|
||||
commit_author: robobun <robobun@oven.sh>
|
||||
137
.github/workflows/bun-types-release.yml
vendored
137
.github/workflows/bun-types-release.yml
vendored
@@ -1,137 +0,0 @@
|
||||
name: Release
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
test-build:
|
||||
name: Test & Build
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-types
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install bun
|
||||
uses: xhyrom/setup-bun@v0.1.8
|
||||
with:
|
||||
bun-version: canary
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: latest
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
|
||||
- name: ESLint
|
||||
run: bun run lint
|
||||
|
||||
- name: Build package
|
||||
run: bun run build
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bun-types
|
||||
path: packages/bun-types/dist/*
|
||||
if-no-files-found: error
|
||||
|
||||
publish-npm:
|
||||
name: Publish on NPM
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test-build]
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-types
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: latest
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: bun-types
|
||||
path: packages/bun-types/dist
|
||||
|
||||
- name: Publish on NPM
|
||||
run: cd packages/bun-types/dist/ && npm publish --access public
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
publish-gpr:
|
||||
name: Publish on GPR
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test-build]
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-types
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: latest
|
||||
registry-url: 'https://npm.pkg.github.com/'
|
||||
scope: '@oven-sh'
|
||||
|
||||
- name: Install bun
|
||||
uses: xhyrom/setup-bun@v0.1.8
|
||||
with:
|
||||
bun-version: canary
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: bun-types
|
||||
path: dist
|
||||
|
||||
- name: Add scope to name
|
||||
run: bun scripts/gpr.ts
|
||||
|
||||
- name: Publish on GPR
|
||||
run: cd dist/ && npm publish --access public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# no need for separate releases now
|
||||
# create-release:
|
||||
# name: Create Release
|
||||
# runs-on: ubuntu-latest
|
||||
# needs: [test-build]
|
||||
# defaults:
|
||||
# run:
|
||||
# working-directory: packages/bun-types
|
||||
# if: github.repository_owner == 'oven-sh'
|
||||
|
||||
# steps:
|
||||
# - name: Download all artifacts
|
||||
# uses: actions/download-artifact@v3
|
||||
# with:
|
||||
# name: bun-types
|
||||
# path: packages/bun-types/dist
|
||||
|
||||
# - name: Set version
|
||||
# run: echo "version=$(jq --raw-output '.version' dist/package.json)" >> $GITHUB_ENV
|
||||
|
||||
# - name: Create Release
|
||||
# uses: softprops/action-gh-release@v0.1.14
|
||||
# with:
|
||||
# tag_name: "v${{ env.version }}"
|
||||
# body: "This is the release of bun-types that corresponds to the commit [${{ github.sha }}]"
|
||||
# token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# files: |
|
||||
# dist/*
|
||||
17
.github/workflows/bun-types-tests.yml
vendored
17
.github/workflows/bun-types-tests.yml
vendored
@@ -1,16 +1,16 @@
|
||||
name: TypeScript Types
|
||||
name: Test bun-types
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- packages/bun-types/**/*
|
||||
- 'packages/bun-types/**'
|
||||
branches: [main]
|
||||
pull_request:
|
||||
paths:
|
||||
- packages/bun-types/**/*
|
||||
- 'packages/bun-types/**'
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: Build and Test
|
||||
name: Build and test
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
@@ -18,12 +18,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install bun
|
||||
uses: xhyrom/setup-bun@v0.1.8
|
||||
uses: oven-sh/setup-bun@v0.1.8
|
||||
with:
|
||||
bun-version: latest
|
||||
bun-version: canary
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Install node
|
||||
@@ -37,8 +37,5 @@ jobs:
|
||||
- name: Generate package
|
||||
run: bun run build
|
||||
|
||||
- name: ESLint
|
||||
run: bun run lint
|
||||
|
||||
- name: Tests
|
||||
run: bun run test
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,7 +1,6 @@
|
||||
.DS_Store
|
||||
zig-cache
|
||||
*.wasm
|
||||
|
||||
packages/*/*.wasm
|
||||
*.o
|
||||
*.a
|
||||
profile.json
|
||||
@@ -110,3 +109,4 @@ misctools/machbench
|
||||
bun-webkit
|
||||
|
||||
src/deps/c-ares/build
|
||||
src/bun.js/debug-bindings-obj
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": false,
|
||||
"bracketSpacing": true,
|
||||
"trailingComma": "all"
|
||||
"arrowParens": "avoid",
|
||||
"printWidth": 120,
|
||||
"trailingComma": "all",
|
||||
"useTabs": false
|
||||
}
|
||||
|
||||
1
.vscode/extensions.json
vendored
1
.vscode/extensions.json
vendored
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"AugusteRame.zls-vscode",
|
||||
"JarredSumner.zig-unofficial",
|
||||
"esbenp.prettier-vscode",
|
||||
"xaver.clang-format",
|
||||
"vadimcn.vscode-lldb"
|
||||
|
||||
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -13,7 +13,7 @@
|
||||
"[zig]": {
|
||||
"editor.tabSize": 4,
|
||||
"editor.useTabStops": false,
|
||||
"editor.defaultFormatter": "tiehuis.zig",
|
||||
"editor.defaultFormatter": "JarredSumner.zig-unofficial",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[ts]": {
|
||||
@@ -182,7 +182,11 @@
|
||||
"ethernet.h": "c",
|
||||
"inet.h": "c",
|
||||
"packet.h": "c",
|
||||
"queue": "cpp"
|
||||
"queue": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"__verbose_abort": "cpp"
|
||||
},
|
||||
"cmake.configureOnOpen": false,
|
||||
"C_Cpp.errorSquiggles": "Enabled",
|
||||
|
||||
86
CONTRIBUTING.md
Normal file
86
CONTRIBUTING.md
Normal file
@@ -0,0 +1,86 @@
|
||||
# Contributing to Bun
|
||||
|
||||
All contributions need test coverage. If you are adding a new feature, please add a test. If you are fixing a bug, please add a test that fails before your fix and passes after your fix.
|
||||
|
||||
## Bun's codebase
|
||||
|
||||
Bun is written mostly in Zig, but WebKit & JavaScriptCore (the JavaScript engine) is written in C++.
|
||||
|
||||
Today (Feburary 2023), Bun's codebase has five distinct parts:
|
||||
|
||||
- JavaScript, JSX, & TypeScript transpiler, module resolver, and related code
|
||||
- JavaScript runtime (`src/bun.js/`)
|
||||
- JavaScript runtime bindings (`src/bun.zig/bindings/**/*.cpp`)
|
||||
- Package manager (`src/install/`)
|
||||
- Shared utilities (`src/string_immutable.zig`)
|
||||
|
||||
The JavaScript transpiler & module resolver is mostly independent from the runtime. It predates the runtime and is entirely in Zig. The JavaScript parser is mostly in `src/js_parser.zig`. The JavaScript AST data structures are mostly in `src/js_ast.zig`. The JavaScript lexer is in `src/js_lexer.zig`. A lot of this code started as a port of esbuild's equivalent code from Go to Zig, but has had many small changes since then.
|
||||
|
||||
## Memory management in Bun
|
||||
|
||||
For the Zig code, please:
|
||||
|
||||
1. Do your best to avoid dynamically allocating memory.
|
||||
2. If we need to allocate memory, carefully consider the owner of that memory. If it's a JavaScript object, it will need a finalizer. If it's in Zig, it will need to be freed either via an arena or manually.
|
||||
3. Prefer arenas over manual memory management. Manually freeing memory is leak & crash prone.
|
||||
4. If the memory needs to be accessed across threads, use `bun.default_allocator`. Mimalloc threadlocal heaps are not safe to free across threads.
|
||||
|
||||
The JavaScript transpiler has special-handling for memory management. The parser allocates into a single arena and the memory is recycled after each parse.
|
||||
|
||||
## JavaScript runtime
|
||||
|
||||
Most of Bun's JavaScript runtime code lives in `src/bun.js`.
|
||||
|
||||
### Calling C++ from Zig & Zig from C++
|
||||
|
||||
TODO: document this (see bindings.zig and bindings.cpp for now)
|
||||
|
||||
### Adding a new JavaScript class
|
||||
|
||||
1. Add a new file in `src/bun.js/*.classes.ts` to define the instance and static methods for the class.
|
||||
2. Add a new file in `src/bun.js/**/*.zig` and expose the struct in `src/bun.js/generated_classes_list.zig`
|
||||
3. Run `make codegen`
|
||||
|
||||
Copy from examples like `Subprocess` or `Response`.
|
||||
|
||||
### ESM modules
|
||||
|
||||
Bun implements ESM modules in a mix of native code and JavaScript.
|
||||
|
||||
Several Node.js modules are implemented in JavaScript and loosely based on browserify polyfills.
|
||||
|
||||
The ESM modules in Bun are located in `src/bun.js/*.exports.js`. Unlike other code in Bun, these files are NOT transpiled. They are loaded directly into the JavaScriptCore VM. That means `require` does not work in these files. Instead, you must use `import.meta.require`, or ideally, not use require/import other files at all.
|
||||
|
||||
The module loader is in `src/bun.js/module_loader.zig`.
|
||||
|
||||
### JavaScript Builtins
|
||||
|
||||
JavaScript builtins are located in `src/bun.js/builtins/*.js`.
|
||||
|
||||
These files support a JavaScriptCore-only syntax for internal slots. `@` is used to access an internal slot. For example: `new @Array(123)` will create a new `Array` similar to `new Array(123)`, except if a library modifies the `Array` global, it will not affect the internal slot (`@Array`). These names must be allow-listed in `BunBuiltinNames.h` (though JavaScriptCore allowlists some names by default).
|
||||
|
||||
They can not use or reference ESM-modules. The files that end with `*Internals.js` are automatically loaded globally. Most usage of internals right now are the stream implementations (which share a lot of code from Safari/WebKit) and ImportMetaObject (which is how `require` is implemented in the runtime)
|
||||
|
||||
To regenerate the builtins:
|
||||
|
||||
```sh
|
||||
make clean-bindings && make generate-builtins && make bindings -j10
|
||||
```
|
||||
|
||||
It is recommended that you have ccache installed or else you will spend a lot of time waiting for the bindings to compile.
|
||||
|
||||
### Memory management in Bun's JavaScript runtime
|
||||
|
||||
TODO: fill this out (for now, use `JSC.Strong` in most cases)
|
||||
|
||||
### Strings
|
||||
|
||||
TODO: fill this out (for now, use `JSValue.toSlice()` in most cases)
|
||||
|
||||
#### JavaScriptCore C API
|
||||
|
||||
Do not copy from examples leveraging the JavaScriptCore C API. Please do not use this in new code. We will not accept PRs that add new code that uses the JavaScriptCore C API.
|
||||
|
||||
## Testing
|
||||
|
||||
See `../test/README.md` for information on how to run tests.
|
||||
16
Dockerfile
16
Dockerfile
@@ -10,9 +10,9 @@ ARG ARCH=x86_64
|
||||
ARG BUILD_MACHINE_ARCH=x86_64
|
||||
ARG TRIPLET=${ARCH}-linux-gnu
|
||||
ARG BUILDARCH=amd64
|
||||
ARG WEBKIT_TAG=jul27-2
|
||||
ARG WEBKIT_TAG=feb9
|
||||
ARG ZIG_TAG=jul1
|
||||
ARG ZIG_VERSION="0.11.0-dev.947+cf822c6dd"
|
||||
ARG ZIG_VERSION="0.11.0-dev.1393+38eebf3c4"
|
||||
ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH"
|
||||
|
||||
ARG ZIG_FOLDERNAME=zig-linux-${BUILD_MACHINE_ARCH}-${ZIG_VERSION}
|
||||
@@ -20,7 +20,7 @@ ARG ZIG_FILENAME=${ZIG_FOLDERNAME}.tar.xz
|
||||
ARG WEBKIT_URL="https://github.com/oven-sh/WebKit/releases/download/$WEBKIT_TAG/${WEBKIT_BASENAME}.tar.gz"
|
||||
ARG ZIG_URL="https://ziglang.org/builds/${ZIG_FILENAME}"
|
||||
ARG GIT_SHA=""
|
||||
ARG BUN_BASE_VERSION=0.4
|
||||
ARG BUN_BASE_VERSION=0.5
|
||||
|
||||
FROM bitnami/minideb:bullseye as bun-base
|
||||
|
||||
@@ -122,8 +122,8 @@ ARG BUN_RELEASE_DIR
|
||||
ARG BUN_DEPS_OUT_DIR
|
||||
ARG BUN_DIR
|
||||
ARG CPU_TARGET
|
||||
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
|
||||
ENV CCACHE_DIR=/ccache
|
||||
ENV JSC_BASE_DIR=${WEBKIT_DIR}
|
||||
ENV LIB_ICU_PATH=${WEBKIT_DIR}/lib
|
||||
@@ -149,6 +149,9 @@ ARG BUN_RELEASE_DIR
|
||||
ARG BUN_DEPS_OUT_DIR
|
||||
ARG BUN_DIR
|
||||
|
||||
ARG CPU_TARGET
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
|
||||
COPY Makefile ${BUN_DIR}/Makefile
|
||||
COPY src/deps/lol-html ${BUN_DIR}/src/deps/lol-html
|
||||
|
||||
@@ -303,8 +306,6 @@ ARG BUN_RELEASE_DIR
|
||||
ARG BUN_DEPS_OUT_DIR
|
||||
ARG BUN_DIR
|
||||
ARG CPU_TARGET
|
||||
|
||||
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
|
||||
COPY Makefile ${BUN_DIR}/Makefile
|
||||
@@ -484,6 +485,9 @@ ARG BUN_RELEASE_DIR
|
||||
ARG BUN_DEPS_OUT_DIR
|
||||
ARG BUN_DIR
|
||||
|
||||
ARG CPU_TARGET
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
|
||||
ENV CCACHE_DIR=/ccache
|
||||
|
||||
COPY Makefile ${BUN_DIR}/Makefile
|
||||
|
||||
@@ -8,7 +8,7 @@ ARG BUN_RELEASE_DIR=${GITHUB_WORKSPACE}/bun-release
|
||||
ARG BUN_DEPS_OUT_DIR=${GITHUB_WORKSPACE}/bun-deps
|
||||
ARG BUN_DIR=${GITHUB_WORKSPACE}/bun
|
||||
ARG BUN_PACKAGES_DIR=${BUN_DIR}/packages
|
||||
ARG ZIG_VERSION="0.11.0-dev.947+cf822c6dd"
|
||||
ARG ZIG_VERSION="0.11.0-dev.1393+38eebf3c4"
|
||||
|
||||
ARG ZIG_FOLDERNAME=zig-linux-${ARCH}-${ZIG_VERSION}
|
||||
ARG ZIG_FILENAME=${ZIG_FOLDERNAME}.tar.xz
|
||||
@@ -99,7 +99,7 @@ RUN tar -xf ${ZIG_FILENAME} && \
|
||||
mv ${ZIG_FOLDERNAME} ${ZIG_PATH};
|
||||
|
||||
RUN cd $GITHUB_WORKSPACE && \
|
||||
curl -o bun-webkit-linux-$BUILDARCH.tar.gz -L https://github.com/oven-sh/WebKit/releases/download/dec30/bun-webkit-linux-$BUILDARCH.tar.gz && \
|
||||
curl -o bun-webkit-linux-$BUILDARCH.tar.gz -L https://github.com/oven-sh/WebKit/releases/download/feb9/bun-webkit-linux-$BUILDARCH.tar.gz && \
|
||||
tar -xzf bun-webkit-linux-$BUILDARCH.tar.gz && \
|
||||
rm bun-webkit-linux-$BUILDARCH.tar.gz && \
|
||||
cat $WEBKIT_OUT_DIR/include/cmakeconfig.h > /dev/null
|
||||
|
||||
20
Makefile
20
Makefile
@@ -35,11 +35,11 @@ DOCKER_BUILDARCH = amd64
|
||||
BREW_PREFIX_PATH = /usr/local
|
||||
DEFAULT_MIN_MACOS_VERSION = 10.14
|
||||
MARCH_NATIVE = -march=$(CPU_TARGET) -mtune=$(CPU_TARGET)
|
||||
NATIVE_OR_OLD_MARCH = -march=westmere
|
||||
NATIVE_OR_OLD_MARCH = -march=nehalem
|
||||
endif
|
||||
|
||||
MIN_MACOS_VERSION ?= $(DEFAULT_MIN_MACOS_VERSION)
|
||||
BUN_BASE_VERSION = 0.4
|
||||
BUN_BASE_VERSION = 0.5
|
||||
|
||||
AR=
|
||||
|
||||
@@ -509,6 +509,9 @@ npm-install:
|
||||
$(NPM_CLIENT) install --ignore-scripts --production
|
||||
|
||||
print-% : ; @echo $* = $($*)
|
||||
get-% : ; @echo $($*)
|
||||
print-version:
|
||||
@echo $(PACKAGE_JSON_VERSION)
|
||||
|
||||
|
||||
|
||||
@@ -922,7 +925,7 @@ headers:
|
||||
rm -f /tmp/build-jsc-headers src/bun.js/bindings/headers.zig
|
||||
touch src/bun.js/bindings/headers.zig
|
||||
$(ZIG) build headers-obj
|
||||
$(CXX) $(PLATFORM_LINKER_FLAGS) $(JSC_FILES_DEBUG) ${ICU_FLAGS} $(DEBUG_IO_FILES) $(BUN_LLD_FLAGS_WITHOUT_JSC) -g $(DEBUG_BIN)/headers.o -W -o /tmp/build-jsc-headers -lc;
|
||||
$(CXX) $(PLATFORM_LINKER_FLAGS) $(JSC_FILES_DEBUG) ${ICU_FLAGS} $(BUN_LLD_FLAGS_WITHOUT_JSC) -g $(DEBUG_BIN)/headers.o -W -o /tmp/build-jsc-headers -lc;
|
||||
/tmp/build-jsc-headers
|
||||
$(ZIG) translate-c src/bun.js/bindings/headers.h > src/bun.js/bindings/headers.zig
|
||||
$(BUN_OR_NODE) misctools/headers-cleaner.js
|
||||
@@ -1391,10 +1394,19 @@ bindings: $(DEBUG_OBJ_DIR) $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG
|
||||
.PHONY: jsc-bindings-mac
|
||||
jsc-bindings-mac: bindings
|
||||
|
||||
# lInux only
|
||||
MIMALLOC_VALGRIND_ENABLED_FLAG =
|
||||
|
||||
ifeq ($(OS_NAME),linux)
|
||||
MIMALLOC_VALGRIND_ENABLED_FLAG = -DMI_VALGRIND=ON
|
||||
endif
|
||||
|
||||
|
||||
.PHONY: mimalloc-debug
|
||||
mimalloc-debug:
|
||||
rm -rf $(BUN_DEPS_DIR)/mimalloc/CMakeCache* $(BUN_DEPS_DIR)/mimalloc/CMakeFiles
|
||||
cd $(BUN_DEPS_DIR)/mimalloc; make clean || echo ""; \
|
||||
CFLAGS="$(CFLAGS)" cmake $(CMAKE_FLAGS_WITHOUT_RELEASE) ${MIMALLOC_OVERRIDE_FLAG} \
|
||||
CFLAGS="$(CFLAGS)" cmake $(CMAKE_FLAGS_WITHOUT_RELEASE) ${MIMALLOC_OVERRIDE_FLAG} ${MIMALLOC_VALGRIND_ENABLED_FLAG} \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DMI_DEBUG_FULL=1 \
|
||||
-DMI_SKIP_COLLECT_ON_EXIT=1 \
|
||||
|
||||
92
README.md
92
README.md
@@ -23,24 +23,32 @@ Today, bun's primary focus is bun.js: bun's JavaScript runtime.
|
||||
|
||||
## Install
|
||||
|
||||
Native: (macOS x64 & Silicon, Linux x64, Windows Subsystem for Linux)
|
||||
Bun supports Linux (x64 & arm64) and macOS (x64 & Apple Silicon). If you want to use Bun on Windows, you will need to use Windows Subsystem for Linux. Bun will [soon](https://github.com/oven-sh/bun/issues/43) support Windows, natively.
|
||||
|
||||
curl:
|
||||
|
||||
```sh
|
||||
curl -fsSL https://bun.sh/install | bash
|
||||
```
|
||||
|
||||
Homebrew: (MacOS and Linux)
|
||||
npm:
|
||||
|
||||
```sh
|
||||
npm install -g bun
|
||||
```
|
||||
|
||||
Homebrew:
|
||||
|
||||
```sh
|
||||
brew tap oven-sh/bun
|
||||
brew install bun
|
||||
```
|
||||
|
||||
Docker: (Linux x64)
|
||||
Docker:
|
||||
|
||||
```sh
|
||||
docker pull jarredsumner/bun:edge
|
||||
docker run --rm --init --ulimit memlock=-1:-1 jarredsumner/bun:edge
|
||||
docker pull oven/bun
|
||||
docker run --rm --init --ulimit memlock=-1:-1 oven/bun
|
||||
```
|
||||
|
||||
If using Linux, kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1.
|
||||
@@ -175,6 +183,7 @@ bun upgrade --canary
|
||||
- [`Bun.Transpiler.scan`](#buntranspilerscan)
|
||||
- [`Bun.Transpiler.scanImports`](#buntranspilerscanimports)
|
||||
- [`Bun.peek` - read a promise same-tick](#bunpeek---read-a-promise-without-resolving-it)
|
||||
- [`Bun.dns` - lookup a domain](#bundns---lookup-a-domain)
|
||||
- [Module resolution in Bun](#module-resolution-in-bun)
|
||||
- [Environment variables](#environment-variables)
|
||||
- [Credits](#credits)
|
||||
@@ -415,6 +424,21 @@ Assuming a package.json with a `"clean"` command in `"scripts"`:
|
||||
}
|
||||
```
|
||||
|
||||
## Using bun as a WebAssembly runner
|
||||
|
||||
Bun v0.5.2 added experimental support for the [WebAssembly System Interface](https://github.com/WebAssembly/WASI) (WASI). This means you can run WebAssembly binaries in Bun.
|
||||
|
||||
To run a WASI binary, use `bun run`:
|
||||
|
||||
```bash
|
||||
bun run ./my-wasm-app.wasm
|
||||
|
||||
# you can omit "run" if the filename ends with .wasm
|
||||
bun ./my-wasm-app.wasm
|
||||
```
|
||||
|
||||
WASI support is based on [wasi-js](https://github.com/sagemathinc/cowasm/tree/main/core/wasi-js). Currently, it only supports WASI binaries that use the `wasi_snapshot_preview1` or `wasi_unstable` APIs. Bun's implementation is not optimized for performance, but if this feature gets popular, we'll definitely invest time in making it faster.
|
||||
|
||||
## Creating a Discord bot with Bun
|
||||
|
||||
### Application Commands
|
||||
@@ -580,7 +604,6 @@ You can see [Bun's Roadmap](https://github.com/oven-sh/bun/issues/159), but here
|
||||
| ------------------------------------------------------------------------------------- | -------------- |
|
||||
| Web Streams with Fetch API | bun.js |
|
||||
| Web Streams with HTMLRewriter | bun.js |
|
||||
| Package hoisting that matches npm behavior | bun install |
|
||||
| Source Maps (unbundled is supported) | JS Bundler |
|
||||
| Source Maps | CSS |
|
||||
| JavaScript Minifier | JS Transpiler |
|
||||
@@ -1254,7 +1277,7 @@ bun install --backend copyfile
|
||||
|
||||
**`symlink`** is typically only used for `file:` dependencies (and eventually `link:`) internally. To prevent infinite loops, it skips symlinking the `node_modules` folder.
|
||||
|
||||
If you install with `--backend=symlink`, Node.js won't resolve node_modules of dependencies unless each dependency has it's own node_modules folder or you pass `--preserve-symlinks` to `node`. See [Node.js documentation on `--preserve-symlinks`](https://nodejs.org/api/cli.html#--preserve-symlinks).
|
||||
If you install with `--backend=symlink`, Node.js won't resolve node_modules of dependencies unless each dependency has its own node_modules folder or you pass `--preserve-symlinks` to `node`. See [Node.js documentation on `--preserve-symlinks`](https://nodejs.org/api/cli.html#--preserve-symlinks).
|
||||
|
||||
```bash
|
||||
rm -rf node_modules
|
||||
@@ -1275,7 +1298,7 @@ bun’s usage of `Cache-Control` ignores `Age`. This improves performance, but m
|
||||
|
||||
### `bun run`
|
||||
|
||||
`bun run` is a fast `package.json` script runner. Instead of waiting 170ms for your npm client to start every time, you wait 6ms for bun.
|
||||
`bun run` is a fast `package.json` script runner and executable runner. Instead of waiting 170ms for your npm client to start every time, you wait 6ms for bun.
|
||||
|
||||
By default, `bun run` prints the script that will be invoked:
|
||||
|
||||
@@ -1290,7 +1313,7 @@ You can disable that with `--silent`
|
||||
bun run --silent clean
|
||||
```
|
||||
|
||||
`bun run ${script-name}` runs the equivalent of `npm run script-name`. For example, `bun run dev` runs the `dev` script in `package.json`, which may sometimes spin up non-bun processes.
|
||||
`bun run ${script-name}` runs the equivalent of `npm run script-name`, `npx bin-name`, and `node file-name` all in one command. For example, `bun run dev` runs the `dev` script in `package.json`, which may sometimes spin up non-bun processes.
|
||||
|
||||
`bun run ${javascript-file.js}` will run it with bun, as long as the file doesn't have a node shebang.
|
||||
|
||||
@@ -2591,7 +2614,7 @@ If you need to read from `stdout` or `stderr` synchronously, you should use `Bun
|
||||
|
||||
`Bun.spawn` returns a `Subprocess` object.
|
||||
|
||||
More complete types are available in [`bun-types`](https://github.com/oven-sh/bun-types).
|
||||
More complete types are available in [`bun-types`](https://github.com/oven-sh/bun/tree/main/packages/bun-types).
|
||||
|
||||
```ts
|
||||
interface Subprocess {
|
||||
@@ -2823,6 +2846,50 @@ queueMicrotask(() => {
|
||||
|
||||
Builtin buffering is planned in a future version of Bun.
|
||||
|
||||
## `Bun.dns` - lookup a domain
|
||||
|
||||
`Bun.dns` includes utilities to make DNS requests, similar to `node:dns`. As of Bun v0.5.0, the only implemented function is `dns.lookup`, though more will be implemented soon.
|
||||
|
||||
You can lookup the IP addresses of a hostname by using `dns.lookup`.
|
||||
|
||||
```ts
|
||||
import { dns } from "bun";
|
||||
|
||||
const [{ address }] = await dns.lookup("example.com");
|
||||
console.log(address); // "93.184.216.34"
|
||||
```
|
||||
|
||||
If you need to limit IP addresses to either IPv4 or IPv6, you can specify the `family` as an option.
|
||||
|
||||
```ts
|
||||
import { dns } from "bun";
|
||||
|
||||
const [{ address }] = await dns.lookup("example.com", { family: 6 });
|
||||
console.log(address); // "2606:2800:220:1:248:1893:25c8:1946"
|
||||
```
|
||||
|
||||
Bun supports three backends for DNS resolution:
|
||||
|
||||
- `c-ares` - This is the default on Linux, and it uses the [c-ares](https://c-ares.org/) library to perform DNS resolution.
|
||||
- `system` - Uses the system's non-blocking DNS resolver, if available. Otherwise, falls back to `getaddrinfo`. This is the default on macOS, and the same as `getaddrinfo` on Linux.
|
||||
- `getaddrinfo` - Uses the POSIX standard `getaddrinfo` function, which may cause performance issues under concurrent load.
|
||||
|
||||
You can choose a particular backend by specifying `backend` as an option.
|
||||
|
||||
```ts
|
||||
import { dns } from "bun";
|
||||
|
||||
const [{ address, ttl }] = await dns.lookup("example.com", {
|
||||
backend: "c-ares",
|
||||
});
|
||||
console.log(address); // "93.184.216.34"
|
||||
console.log(ttl); // 21237
|
||||
```
|
||||
|
||||
Note: the `ttl` property is only accurate when the `backend` is c-ares. Otherwise, `ttl` will be `0`.
|
||||
|
||||
This was added in Bun v0.5.0.
|
||||
|
||||
## `Bun.peek` - read a promise without resolving it
|
||||
|
||||
`Bun.peek` is a utility function that lets you read a promise's result without `await` or `.then`, but only if the promise has already fulfilled or rejected.
|
||||
@@ -4581,7 +4648,7 @@ It will check the lockfile for the version. If the lockfile doesn't have a versi
|
||||
|
||||
Lowlights:
|
||||
|
||||
- TypeScript type support isn't implmented yet
|
||||
- TypeScript type support isn't implemented yet
|
||||
- patch package support isn't implemented yet
|
||||
|
||||
#### Resolving packages
|
||||
@@ -4942,6 +5009,7 @@ bun also statically links these libraries:
|
||||
- [`c-ares`](https://github.com/c-ares/c-ares), which is MIT licensed
|
||||
- `libicu` 72, which can be found here: <https://github.com/unicode-org/icu/blob/main/icu4c/LICENSE>
|
||||
- A fork of [`uWebsockets`](https://github.com/jarred-sumner/uwebsockets), which is Apache 2.0 licensed
|
||||
- WASI implementation from [`wasi-js`](https://github.com/sagemathinc/cowasm/tree/main/core/wasi-js), which is BSD 3 clause licensed. Note that wasi-js is originally based on [wasmer-js](https://github.com/wasmerio/wasmer-js), which is MIT licensed. wasmer-js was based on [node-wasi](https://github.com/devsnek/node-wasi) by Gus Caplan (also MIT licensed). You can [read more about the history here](https://github.com/sagemathinc/cowasm/tree/main/core/wasi-js#history).
|
||||
|
||||
For compatibility reasons, these NPM packages are embedded into bun’s binary and injected if imported.
|
||||
|
||||
@@ -5065,7 +5133,7 @@ which clang-15
|
||||
If it is not, you will have to run this to link it:
|
||||
|
||||
```bash
|
||||
export PATH="$(brew --prefix llvm@15)/bin"
|
||||
export PATH="$PATH:$(brew --prefix llvm@15)/bin"
|
||||
export LDFLAGS="$LDFLAGS -L$(brew --prefix llvm@15)/lib"
|
||||
export CPPFLAGS="$CPPFLAGS -I$(brew --prefix llvm@15)/include"
|
||||
```
|
||||
|
||||
@@ -1,9 +1,49 @@
|
||||
import { bench, run } from "mitata";
|
||||
|
||||
const N = parseInt(process.argv.slice(2).at(0) || "10", 10);
|
||||
var isBuffer = new Buffer(0);
|
||||
var isNOtBuffer = "not a buffer";
|
||||
|
||||
bench("new Buffer(0)", () => {
|
||||
return new Buffer(0);
|
||||
bench("Buffer.isBuffer(buffer)", () => {
|
||||
return Buffer.isBuffer(isBuffer);
|
||||
});
|
||||
|
||||
{
|
||||
var j = 0;
|
||||
j += 1;
|
||||
j += eval("'ok'");
|
||||
|
||||
bench("Buffer.isBuffer(string)", () => {
|
||||
return Buffer.isBuffer(j);
|
||||
});
|
||||
}
|
||||
|
||||
bench("Buffer.from('short string')", () => {
|
||||
return Buffer.from("short string");
|
||||
});
|
||||
|
||||
const loooong = "long string".repeat(9999).split("").join(" ");
|
||||
bench("Buffer.byteLength('long string'.repeat(9999))", () => {
|
||||
return Buffer.byteLength(loooong);
|
||||
});
|
||||
|
||||
var hundred = new ArrayBuffer(100);
|
||||
bench("Buffer.from(ArrayBuffer(100))", () => {
|
||||
return Buffer.from(hundred);
|
||||
});
|
||||
|
||||
var hundredArray = new Uint8Array(100);
|
||||
bench("Buffer.from(Uint8Array(100))", () => {
|
||||
return Buffer.from(hundredArray);
|
||||
});
|
||||
|
||||
var empty = new Uint8Array(0);
|
||||
bench("Buffer.from(Uint8Array(0))", () => {
|
||||
return Buffer.from(empty);
|
||||
});
|
||||
|
||||
bench("new Buffer(Uint8Array(0))", () => {
|
||||
return new Buffer(empty);
|
||||
});
|
||||
|
||||
bench(`new Buffer(${N})`, () => {
|
||||
@@ -26,4 +66,4 @@ bench("Buffer.alloc(24_000)", () => {
|
||||
return Buffer.alloc(24_000);
|
||||
});
|
||||
|
||||
await run();
|
||||
await run({});
|
||||
|
||||
BIN
bench/snippets/bun.lockb
Executable file
BIN
bench/snippets/bun.lockb
Executable file
Binary file not shown.
@@ -21,8 +21,14 @@ bench('crypto.createHash("sha512")', () => {
|
||||
hasher.digest();
|
||||
});
|
||||
|
||||
bench('crypto.createHash("sha512")', () => {
|
||||
var hasher = crypto.createHash("sha512");
|
||||
bench('crypto.createHash("sha256")', () => {
|
||||
var hasher = crypto.createHash("sha256");
|
||||
hasher.update(foo);
|
||||
hasher.digest();
|
||||
});
|
||||
|
||||
bench('crypto.createHash("sha1")', () => {
|
||||
var hasher = crypto.createHash("sha1");
|
||||
hasher.update(foo);
|
||||
hasher.digest();
|
||||
});
|
||||
|
||||
@@ -1,71 +1,81 @@
|
||||
const EventEmitter = require("events").EventEmitter;
|
||||
const EventEmitterNative = require("events").EventEmitter;
|
||||
const TypedEmitter = require("tiny-typed-emitter").TypedEmitter;
|
||||
const EventEmitter3 = require("eventemitter3").EventEmitter;
|
||||
import { bench, run } from "mitata";
|
||||
|
||||
const emitter = new EventEmitter();
|
||||
const event = new Event("hello");
|
||||
emitter.on("hello", (event) => {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
var id = 0;
|
||||
bench("EventEmitter.emit", () => {
|
||||
emitter.emit("hello", {
|
||||
preventDefault() {
|
||||
id++;
|
||||
},
|
||||
});
|
||||
});
|
||||
for (let [EventEmitter, className] of [
|
||||
[EventEmitterNative, "EventEmitter"],
|
||||
[TypedEmitter, "TypedEmitter"],
|
||||
[EventEmitter3, "EventEmitter3"],
|
||||
]) {
|
||||
const emitter = new EventEmitter();
|
||||
|
||||
var monkey = Object.assign({}, EventEmitter.prototype);
|
||||
monkey.on("hello", (event) => {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
bench("[monkey] EventEmitter.emit", () => {
|
||||
var called = false;
|
||||
monkey.emit("hello", {
|
||||
preventDefault() {
|
||||
id++;
|
||||
called = true;
|
||||
},
|
||||
emitter.on("hello", (event) => {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
if (!called) {
|
||||
throw new Error("monkey failed");
|
||||
bench(`${className}.emit`, () => {
|
||||
emitter.emit("hello", {
|
||||
preventDefault() {
|
||||
id++;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
bench(`${className}.on x 10_000 (handler)`, () => {
|
||||
var cb = (event) => {
|
||||
event.preventDefault();
|
||||
};
|
||||
emitter.on("hey", cb);
|
||||
var called = false;
|
||||
for (let i = 0; i < 10_000; i++)
|
||||
emitter.emit("hey", {
|
||||
preventDefault() {
|
||||
id++;
|
||||
called = true;
|
||||
},
|
||||
});
|
||||
emitter.off("hey", cb);
|
||||
|
||||
if (!called) throw new Error("not called");
|
||||
});
|
||||
|
||||
if (EventEmitter !== EventEmitter3) {
|
||||
var monkey = Object.assign({}, EventEmitter.prototype);
|
||||
monkey.on("hello", (event) => {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
bench(`[monkey] ${className}.emit`, () => {
|
||||
var called = false;
|
||||
monkey.emit("hello", {
|
||||
preventDefault() {
|
||||
id++;
|
||||
called = true;
|
||||
},
|
||||
});
|
||||
|
||||
if (!called) {
|
||||
throw new Error("monkey failed");
|
||||
}
|
||||
});
|
||||
|
||||
bench(`[monkey] ${className}.on x 10_000 (handler)`, () => {
|
||||
var cb = () => {
|
||||
event.preventDefault();
|
||||
};
|
||||
monkey.on("hey", cb);
|
||||
for (let i = 0; i < 10_000; i++)
|
||||
monkey.emit("hey", {
|
||||
preventDefault() {
|
||||
id++;
|
||||
},
|
||||
});
|
||||
monkey.off("hey", cb);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
bench("EventEmitter.on x 10_000 (handler)", () => {
|
||||
var cb = (event) => {
|
||||
event.preventDefault();
|
||||
};
|
||||
emitter.on("hey", cb);
|
||||
var called = false;
|
||||
for (let i = 0; i < 10_000; i++)
|
||||
emitter.emit("hey", {
|
||||
preventDefault() {
|
||||
id++;
|
||||
called = true;
|
||||
},
|
||||
});
|
||||
emitter.off("hey", cb);
|
||||
|
||||
if (!called) throw new Error("not called");
|
||||
});
|
||||
|
||||
bench("[monkey] EventEmitter.on x 10_000 (handler)", () => {
|
||||
var cb = () => {
|
||||
event.preventDefault();
|
||||
};
|
||||
monkey.on("hey", cb);
|
||||
for (let i = 0; i < 10_000; i++)
|
||||
monkey.emit("hey", {
|
||||
preventDefault() {
|
||||
id++;
|
||||
},
|
||||
});
|
||||
monkey.off("hey", cb);
|
||||
});
|
||||
}
|
||||
|
||||
var target = new EventTarget();
|
||||
target.addEventListener("hello", (event) => {});
|
||||
|
||||
34
bench/snippets/form-data.mjs
Normal file
34
bench/snippets/form-data.mjs
Normal file
@@ -0,0 +1,34 @@
|
||||
// so it can run in environments without node module resolution
|
||||
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
|
||||
|
||||
const blob = new Blob(["foo", "bar", "baz"]);
|
||||
bench("FormData.append", () => {
|
||||
const data = new FormData();
|
||||
data.append("foo", "bar");
|
||||
data.append("baz", blob);
|
||||
});
|
||||
|
||||
const data = new FormData();
|
||||
data.append("foo", "bar");
|
||||
data.append("baz", blob);
|
||||
|
||||
const formText =
|
||||
// single field form data
|
||||
"--Form\r\n" + 'Content-Disposition: form-data; name="foo"\r\n\r\n' + "bar\r\n" + "--Form--\r\n";
|
||||
|
||||
bench("response.formData()", async () => {
|
||||
await new Response(formText, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data; boundary=Form",
|
||||
},
|
||||
}).formData();
|
||||
});
|
||||
bench("new Response(formData).text()", async () => {
|
||||
await new Response(data).text();
|
||||
});
|
||||
|
||||
bench("new Response(formData).formData()", async () => {
|
||||
await new Response(data).formData();
|
||||
});
|
||||
|
||||
await run();
|
||||
25
bench/snippets/native-overhead.mjs
Normal file
25
bench/snippets/native-overhead.mjs
Normal file
@@ -0,0 +1,25 @@
|
||||
import { bench, run } from "mitata";
|
||||
|
||||
// These are no-op C++ functions that are exported to JS.
|
||||
const lazy = globalThis[Symbol.for("Bun.lazy")];
|
||||
const noop = lazy("noop");
|
||||
const fn = noop.function;
|
||||
const regular = noop.functionRegular;
|
||||
|
||||
bench("C++ fn regular", () => {
|
||||
regular();
|
||||
});
|
||||
|
||||
bench("C++ fn", () => {
|
||||
fn();
|
||||
});
|
||||
|
||||
bench("C++ getter", () => {
|
||||
return noop.getterSetter;
|
||||
});
|
||||
|
||||
bench("C++ setter", () => {
|
||||
noop.getterSetter = 1;
|
||||
});
|
||||
|
||||
run();
|
||||
6
bench/snippets/package.json
Normal file
6
bench/snippets/package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"eventemitter3": "^5.0.0",
|
||||
"tiny-typed-emitter": "latest"
|
||||
}
|
||||
}
|
||||
17
bench/snippets/stat.mjs
Normal file
17
bench/snippets/stat.mjs
Normal file
@@ -0,0 +1,17 @@
|
||||
import { readdirSync, statSync } from "fs";
|
||||
import { bench, run } from "mitata";
|
||||
import { argv } from "process";
|
||||
|
||||
const dir = argv.length > 2 ? argv[2] : "/tmp";
|
||||
|
||||
const result = statSync(dir);
|
||||
|
||||
bench("Stat.isBlockDevice", () => result.isBlockDevice());
|
||||
bench("Stat.isCharacterDevice", () => result.isCharacterDevice());
|
||||
bench("Stat.isDirectory", () => result.isDirectory());
|
||||
bench("Stat.isFIFO", () => result.isFIFO());
|
||||
bench("Stat.isFile", () => result.isFile());
|
||||
bench("Stat.isSocket", () => result.isSocket());
|
||||
bench("Stat.isSymbolicLink", () => result.isSymbolicLink());
|
||||
|
||||
await run();
|
||||
@@ -4,23 +4,20 @@ var short = new TextEncoder().encode("Hello World!");
|
||||
var shortUTF16 = new TextEncoder().encode("Hello World 💕💕💕");
|
||||
var long = new TextEncoder().encode("Hello World!".repeat(1024));
|
||||
var longUTF16 = new TextEncoder().encode("Hello World 💕💕💕".repeat(1024));
|
||||
var decoder = new TextDecoder();
|
||||
bench(`${short.length} ascii`, () => {
|
||||
var decoder = new TextDecoder();
|
||||
decoder.decode(short);
|
||||
});
|
||||
|
||||
bench(`${short.length} utf8`, () => {
|
||||
var decoder = new TextDecoder();
|
||||
decoder.decode(shortUTF16);
|
||||
});
|
||||
|
||||
bench(`${long.length} ascii`, () => {
|
||||
var decoder = new TextDecoder();
|
||||
decoder.decode(long);
|
||||
});
|
||||
|
||||
bench(`${longUTF16.length} utf8`, () => {
|
||||
var decoder = new TextDecoder();
|
||||
decoder.decode(longUTF16);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,58 +1,102 @@
|
||||
import { readFileSync } from "fs";
|
||||
import { dirname } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { bench, run, group } from "mitata";
|
||||
import { createRequire } from "module";
|
||||
const require = createRequire(import.meta.url);
|
||||
const esbuild_ = require("esbuild/lib/main");
|
||||
const swc_ = require("@swc/core");
|
||||
const babel_ = require("@babel/core");
|
||||
|
||||
var transformSync;
|
||||
var transform;
|
||||
var opts;
|
||||
if (process.isBun) {
|
||||
const transpiler = new Bun.Transpiler({ loader: "jsx" });
|
||||
transformSync = transpiler.transformSync.bind(transpiler);
|
||||
transform = transpiler.transform.bind(transpiler);
|
||||
opts = "jsx";
|
||||
} else if (process.env["esbuild"]) {
|
||||
try {
|
||||
const esbuild = await import("esbuild");
|
||||
transformSync = esbuild.transformSync;
|
||||
transform = esbuild.transform;
|
||||
opts = { loader: "jsx" };
|
||||
} catch (exception) {
|
||||
throw exception;
|
||||
}
|
||||
} else if (process.env["swc"]) {
|
||||
try {
|
||||
const swc = await import("@swc/core");
|
||||
transformSync = swc.transformSync;
|
||||
transform = swc.transform;
|
||||
opts = {
|
||||
sourceMaps: false,
|
||||
inlineSourcesContent: false,
|
||||
jsc: {
|
||||
target: "es2022",
|
||||
parser: {
|
||||
jsx: true,
|
||||
const code = readFileSync(
|
||||
dirname(fileURLToPath(import.meta.url)) +
|
||||
"/../../src/test/fixtures/simple.jsx",
|
||||
"utf-8",
|
||||
);
|
||||
|
||||
async function getWithName(name) {
|
||||
let transformSync;
|
||||
let transform;
|
||||
let opts;
|
||||
|
||||
if (name === "bun") {
|
||||
const transpiler = new Bun.Transpiler({ loader: "jsx" });
|
||||
transformSync = transpiler.transformSync.bind(transpiler);
|
||||
transform = transpiler.transform.bind(transpiler);
|
||||
opts = "jsx";
|
||||
} else if (name === "esbuild") {
|
||||
try {
|
||||
transformSync = esbuild_.transformSync;
|
||||
transform = esbuild_.transform;
|
||||
opts = { loader: "jsx" };
|
||||
} catch (exception) {
|
||||
throw exception;
|
||||
}
|
||||
} else if (name === "swc") {
|
||||
try {
|
||||
transformSync = swc_.transformSync;
|
||||
transform = swc_.transform;
|
||||
opts = {
|
||||
sourceMaps: false,
|
||||
inlineSourcesContent: false,
|
||||
jsc: {
|
||||
target: "es2022",
|
||||
parser: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
} catch (exception) {
|
||||
throw exception;
|
||||
}
|
||||
} else if (process.env["babel"]) {
|
||||
try {
|
||||
const swc = await import("@babel/core");
|
||||
transformSync = swc.transformSync;
|
||||
transform = swc.transform;
|
||||
opts = {
|
||||
sourceMaps: false,
|
||||
presets: [(await import("@babel/preset-react")).default],
|
||||
};
|
||||
} catch (exception) {
|
||||
throw exception;
|
||||
};
|
||||
} catch (exception) {
|
||||
throw exception;
|
||||
}
|
||||
} else if (name === "babel") {
|
||||
try {
|
||||
transformSync = babel_.transformSync;
|
||||
transform = babel_.transform;
|
||||
opts = {
|
||||
sourceMaps: false,
|
||||
presets: ["@babel/preset-react"],
|
||||
};
|
||||
} catch (exception) {
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
transformSync,
|
||||
transform,
|
||||
opts,
|
||||
name,
|
||||
};
|
||||
}
|
||||
|
||||
const code = readFileSync("src/test/fixtures/simple.jsx", "utf8");
|
||||
const bun = process.isBun ? await getWithName("bun") : null;
|
||||
const esbuild = await getWithName("esbuild");
|
||||
const swc = await getWithName("swc");
|
||||
const babel = await getWithName("babel");
|
||||
|
||||
if (process.env.ASYNC) {
|
||||
console.log(await transform(code, opts));
|
||||
} else {
|
||||
console.log(transformSync(code, opts));
|
||||
}
|
||||
const transpilers = [bun, esbuild, swc, babel].filter(Boolean);
|
||||
|
||||
group("transformSync (" + ((code.length / 1024) | 0) + " KB jsx file)", () => {
|
||||
for (let { name, transformSync, opts } of transpilers) {
|
||||
bench(name, () => {
|
||||
transformSync(code, opts);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
group("tranform x 5", () => {
|
||||
for (let { name, transform, opts } of transpilers) {
|
||||
bench(name, async () => {
|
||||
return Promise.all([
|
||||
transform(code, opts),
|
||||
transform(code + "\n", opts),
|
||||
transform("\n" + code + "\n", opts),
|
||||
transform("\n" + code + "\n\n", opts),
|
||||
transform("\n\n" + code + "\n\n", opts),
|
||||
]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await run();
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
|
||||
|
||||
|
||||
[test]
|
||||
# Large monorepos (like Bun) may want to specify the test directory more specifically
|
||||
# By default, `bun wiptest` scans every single folder recurisvely which, if you
|
||||
|
||||
83
dockerhub/Dockerfile-debian
Normal file
83
dockerhub/Dockerfile-debian
Normal file
@@ -0,0 +1,83 @@
|
||||
# https://hub.docker.com/_/debian
|
||||
# https://hub.docker.com/_/ubuntu
|
||||
ARG IMAGE=debian:bullseye-slim
|
||||
|
||||
FROM $IMAGE AS base
|
||||
|
||||
# https://github.com/oven-sh/bun/releases
|
||||
ARG BUN_VERSION=latest
|
||||
|
||||
RUN apt-get update -qq \
|
||||
&& apt-get install -qq --no-install-recommends \
|
||||
ca-certificates \
|
||||
curl \
|
||||
dirmngr \
|
||||
gpg \
|
||||
gpg-agent \
|
||||
unzip \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& arch="$(dpkg --print-architecture)" \
|
||||
&& case "${arch##*-}" in \
|
||||
amd64) build="x64-baseline";; \
|
||||
arm64) build="aarch64";; \
|
||||
*) echo "error: unsupported architecture: ($arch)"; exit 1 ;; \
|
||||
esac \
|
||||
&& version="$BUN_VERSION" \
|
||||
&& case "$version" in \
|
||||
latest | canary | bun-v*) tag="$version"; ;; \
|
||||
v*) tag="bun-$version"; ;; \
|
||||
*) tag="bun-v$version"; ;; \
|
||||
esac \
|
||||
&& case "$tag" in \
|
||||
latest) release="latest/download"; ;; \
|
||||
*) release="download/$tag"; ;; \
|
||||
esac \
|
||||
&& curl "https://github.com/oven-sh/bun/releases/$release/bun-linux-$build.zip" \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
|| (echo "error: unknown release: ($tag)" && exit 1) \
|
||||
&& for key in \
|
||||
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
|
||||
; do \
|
||||
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
|
||||
|| gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
|
||||
done \
|
||||
&& gpg --update-trustdb \
|
||||
&& curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
||||
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|
||||
&& grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
|
||||
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|
||||
&& unzip "bun-linux-$build.zip" \
|
||||
&& mv "bun-linux-$build/bun" /usr/local/bin/bun \
|
||||
&& rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
|
||||
&& chmod +x /usr/local/bin/bun \
|
||||
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
|
||||
&& which bun \
|
||||
&& which bunx \
|
||||
&& bun --version
|
||||
|
||||
FROM $IMAGE
|
||||
|
||||
RUN groupadd bun \
|
||||
--gid 1000 \
|
||||
&& useradd bun \
|
||||
--uid 1000 \
|
||||
--gid bun \
|
||||
--shell /bin/sh \
|
||||
--create-home
|
||||
|
||||
COPY --from=base /usr/local/bin/bun /usr/local/bin
|
||||
COPY --from=base /usr/local/bin/bunx /usr/local/bin
|
||||
|
||||
RUN which bun \
|
||||
&& which bunx \
|
||||
&& bun --version
|
||||
|
||||
WORKDIR /home/bun/app
|
||||
CMD ["bun"]
|
||||
76
examples/http-file-extended.ts
Normal file
76
examples/http-file-extended.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { file, serve } from "bun";
|
||||
import { existsSync, statSync } from "fs";
|
||||
|
||||
serve({
|
||||
fetch(req: Request) {
|
||||
let pathname = new URL(req.url).pathname.substring(1);
|
||||
if (pathname == "") {
|
||||
pathname = import.meta.url.replace("file://", "");
|
||||
}
|
||||
|
||||
if (!existsSync(pathname)) {
|
||||
return new Response(null, { status: 404 });
|
||||
}
|
||||
|
||||
const stats = statSync(pathname);
|
||||
|
||||
// https://github.com/gornostay25/svelte-adapter-bun/blob/master/src/sirv.js
|
||||
const headers = new Headers({
|
||||
"Content-Length": "" + stats.size,
|
||||
"Last-Modified": stats.mtime.toUTCString(),
|
||||
ETag: `W/"${stats.size}-${stats.mtime.getTime()}"`,
|
||||
});
|
||||
|
||||
if (req.headers.get("if-none-match") === headers.get("ETag")) {
|
||||
return new Response(null, { status: 304 });
|
||||
}
|
||||
|
||||
const opts = { code: 200, start: 0, end: Infinity, range: false };
|
||||
|
||||
if (req.headers.has("range")) {
|
||||
opts.code = 206;
|
||||
let [x, y] = req.headers.get("range").replace("bytes=", "").split("-");
|
||||
let end = (opts.end = parseInt(y, 10) || stats.size - 1);
|
||||
let start = (opts.start = parseInt(x, 10) || 0);
|
||||
|
||||
if (start >= stats.size || end >= stats.size) {
|
||||
headers.set("Content-Range", `bytes */${stats.size}`);
|
||||
return new Response(null, {
|
||||
headers: headers,
|
||||
status: 416,
|
||||
});
|
||||
}
|
||||
|
||||
headers.set("Content-Range", `bytes ${start}-${end}/${stats.size}`);
|
||||
headers.set("Content-Length", "" + (end - start + 1));
|
||||
headers.set("Accept-Ranges", "bytes");
|
||||
opts.range = true;
|
||||
}
|
||||
|
||||
if (opts.range) {
|
||||
return new Response(file(pathname).slice(opts.start, opts.end), {
|
||||
headers,
|
||||
status: opts.code,
|
||||
});
|
||||
}
|
||||
|
||||
return new Response(file(pathname), { headers, status: opts.code });
|
||||
},
|
||||
|
||||
// this is called when fetch() throws or rejects
|
||||
// error(err: Error) {
|
||||
// return new Response("uh oh! :(" + String(err.toString()), { status: 500 });
|
||||
// },
|
||||
|
||||
// this boolean enables the bun's default error handler
|
||||
// sometime after the initial release, it will auto reload as well
|
||||
development: process.env.NODE_ENV !== "production",
|
||||
// note: this isn't node, but for compatibility bun supports process.env + more stuff in process
|
||||
|
||||
// SSL is enabled if these two are set
|
||||
// certFile: './cert.pem',
|
||||
// keyFile: './key.pem',
|
||||
|
||||
port: 3000, // number or string
|
||||
hostname: "localhost", // defaults to 0.0.0.0
|
||||
});
|
||||
BIN
examples/react-file-system-router/bun.lockb
Executable file
BIN
examples/react-file-system-router/bun.lockb
Executable file
Binary file not shown.
24
examples/react-file-system-router/index.tsx
Normal file
24
examples/react-file-system-router/index.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
// A simple way to connect FileSystemRouter to Bun#serve
|
||||
// run with `bun run index.tsx`
|
||||
|
||||
import { renderToReadableStream } from 'react-dom/server'
|
||||
import { FileSystemRouter } from 'bun'
|
||||
|
||||
export default {
|
||||
port: 3000,
|
||||
async fetch(request: Request) {
|
||||
const router = new FileSystemRouter({
|
||||
dir: process.cwd() + "/pages",
|
||||
style: "nextjs"
|
||||
})
|
||||
|
||||
const route = router.match(request)
|
||||
|
||||
const { default: Root } = await import(route.filePath)
|
||||
return new Response(
|
||||
await renderToReadableStream(
|
||||
<Root {...route.params} />
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
14
examples/react-file-system-router/package.json
Normal file
14
examples/react-file-system-router/package.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "react-routes",
|
||||
"module": "index.tsx",
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.27",
|
||||
"@types/react-dom": "^18.0.10",
|
||||
"bun-types": "^0.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
}
|
||||
}
|
||||
17
examples/react-file-system-router/pages/index.tsx
Normal file
17
examples/react-file-system-router/pages/index.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
// reachable from http://localhost:3000/
|
||||
|
||||
export default () => (
|
||||
<html>
|
||||
<head>
|
||||
<title>index</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
<a href="/one" >one</a>
|
||||
</h1>
|
||||
<h1>
|
||||
<a href="/two" >two</a>
|
||||
</h1>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
12
examples/react-file-system-router/pages/one.tsx
Normal file
12
examples/react-file-system-router/pages/one.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
// reachable from http://localhost:3000/one
|
||||
|
||||
export default () => (
|
||||
<html>
|
||||
<head>
|
||||
<title>one</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>one</p>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
12
examples/react-file-system-router/pages/two.tsx
Normal file
12
examples/react-file-system-router/pages/two.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
// reachable from http://localhost:3000/two
|
||||
|
||||
export default () => (
|
||||
<html>
|
||||
<head>
|
||||
<title>two</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>two</p>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
20
examples/react-file-system-router/tsconfig.json
Normal file
20
examples/react-file-system-router/tsconfig.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"ESNext"
|
||||
],
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
"moduleResolution": "nodenext",
|
||||
"strict": false,
|
||||
"downlevelIteration": true,
|
||||
"skipLibCheck": true,
|
||||
"jsx": "preserve",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"allowJs": true,
|
||||
"types": [
|
||||
"bun-types" // add Bun global
|
||||
]
|
||||
}
|
||||
}
|
||||
14
package.json
14
package.json
@@ -1,14 +1,12 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"express": "^4.18.2",
|
||||
"mitata": "^0.1.3",
|
||||
"peechy": "latest",
|
||||
"react": "next",
|
||||
"react-dom": "next",
|
||||
"eslint": "^8.20.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"mitata": "^0.1.3",
|
||||
"peechy": "latest",
|
||||
"prettier": "^2.4.1",
|
||||
"svelte": "^3.52.0",
|
||||
"react": "next",
|
||||
"react-dom": "next",
|
||||
"typescript": "latest"
|
||||
},
|
||||
"private": true,
|
||||
@@ -17,7 +15,7 @@
|
||||
"build-fallback": "esbuild --target=esnext --bundle src/fallback.ts --format=iife --platform=browser --minify > src/fallback.out.js",
|
||||
"postinstall": "bash .scripts/postinstall.sh",
|
||||
"typecheck": "tsc",
|
||||
"fmt": "prettier --write './**/*.{ts,tsx,js,jsx}'",
|
||||
"fmt": "prettier --write './**/*.{ts,tsx,js,jsx}' --config .prettierrc",
|
||||
"lint": "eslint './**/*.d.ts' --cache",
|
||||
"lint:fix": "eslint './**/*.d.ts' --cache --fix"
|
||||
},
|
||||
@@ -25,7 +23,7 @@
|
||||
"@types/react": "^18.0.25",
|
||||
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
||||
"@typescript-eslint/parser": "^5.31.0",
|
||||
"bun-webkit": "latest"
|
||||
"bun-webkit": "0.0.1-61ed147fdeaa0787d77bddb332177f23ad96d6fe"
|
||||
},
|
||||
"version": "0.0.0"
|
||||
}
|
||||
|
||||
3
packages/bun-ecosystem/.gitignore
vendored
Normal file
3
packages/bun-ecosystem/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
tmp
|
||||
7
packages/bun-ecosystem/README.md
Normal file
7
packages/bun-ecosystem/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# bun-ecosystem
|
||||
|
||||
A registry to test `npm` packages using Bun. This can be used as a tool to find bugs in Bun by running the test suites of these packages. In the future, we will run theses tests to catch regressions between releases.
|
||||
|
||||
```sh
|
||||
bun run test
|
||||
```
|
||||
BIN
packages/bun-ecosystem/bun.lockb
Executable file
BIN
packages/bun-ecosystem/bun.lockb
Executable file
Binary file not shown.
14
packages/bun-ecosystem/package.json
Normal file
14
packages/bun-ecosystem/package.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"globby": "^13.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bun-types": "canary",
|
||||
"prettier": "^2.8.2"
|
||||
},
|
||||
"scripts": {
|
||||
"format": "prettier --write src",
|
||||
"test": "bun run src/runner.ts"
|
||||
}
|
||||
}
|
||||
69
packages/bun-ecosystem/src/packages.ts
Normal file
69
packages/bun-ecosystem/src/packages.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
export type Package = {
|
||||
readonly name: string;
|
||||
readonly repository: string;
|
||||
readonly cwd?: string;
|
||||
readonly tests?: {
|
||||
readonly style: "jest" | "ava" | "tape" | "custom";
|
||||
readonly include: string[];
|
||||
readonly exclude?: string[];
|
||||
readonly disabled?: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
export const packages: Package[] = [
|
||||
{
|
||||
name: "lodash",
|
||||
repository: github("lodash/lodash"),
|
||||
tests: {
|
||||
style: "jest",
|
||||
include: ["test/*.js"],
|
||||
exclude: [
|
||||
"debounce.test.js", // hangs runner
|
||||
"size.test.js", // require('vm').runInNewContext()
|
||||
"merge.test.js", // failing
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "chalk",
|
||||
repository: github("chalk/chalk"),
|
||||
tests: {
|
||||
style: "ava",
|
||||
include: ["test/*.js"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "request",
|
||||
repository: github("request/request"),
|
||||
tests: {
|
||||
style: "tape",
|
||||
include: ["tests/*.js"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "commander",
|
||||
repository: github("tj/commander.js"),
|
||||
tests: {
|
||||
style: "jest",
|
||||
include: ["tests/*.js"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "express",
|
||||
repository: github("expressjs/express"),
|
||||
tests: {
|
||||
style: "jest",
|
||||
include: ["test/**/*.js"],
|
||||
exclude: [
|
||||
"test/res.sendStatus.js", // https://github.com/oven-sh/bun/issues/887
|
||||
"test/Route.js", // https://github.com/oven-sh/bun/issues/2030
|
||||
],
|
||||
// Most tests fail due to lack of "http2"
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
function github(repository: string): string {
|
||||
return `git@github.com:${repository}.git`;
|
||||
}
|
||||
92
packages/bun-ecosystem/src/runner.ts
Normal file
92
packages/bun-ecosystem/src/runner.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
import type { Package } from "./packages";
|
||||
import { packages } from "./packages";
|
||||
import { existsSync, copyFileSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { globby } from "globby";
|
||||
|
||||
for (const pkg of packages) {
|
||||
try {
|
||||
await loadPackage(pkg, "tmp");
|
||||
} catch (error) {
|
||||
console.error(pkg.name, error);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadPackage(pkg: Package, cwd?: string): Promise<void> {
|
||||
await gitClone({
|
||||
cwd,
|
||||
repository: pkg.repository,
|
||||
name: pkg.name,
|
||||
});
|
||||
const dir = join(cwd ?? "", pkg.name, pkg.cwd ?? "");
|
||||
await spawn({
|
||||
cwd: dir,
|
||||
cmd: ["bun", "install"],
|
||||
});
|
||||
if (!pkg.tests || pkg.tests.style !== "jest") {
|
||||
return;
|
||||
}
|
||||
const files = await globby(pkg.tests.include, {
|
||||
cwd: dir,
|
||||
ignore: pkg.tests.exclude ?? [crypto.randomUUID()],
|
||||
onlyFiles: true,
|
||||
caseSensitiveMatch: false,
|
||||
});
|
||||
if (!files.length) {
|
||||
throw new Error("No tests found");
|
||||
}
|
||||
for (const file of files) {
|
||||
let path = file;
|
||||
if (!file.includes(".test.")) {
|
||||
const ext = path.lastIndexOf(".");
|
||||
path = file.substring(0, ext) + ".test" + file.substring(ext);
|
||||
copyFileSync(join(dir, file), join(dir, path));
|
||||
}
|
||||
await spawn({
|
||||
cwd: dir,
|
||||
cmd: ["bun", "wiptest", path],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
type GitCloneOptions = {
|
||||
repository: string;
|
||||
cwd?: string;
|
||||
name?: string;
|
||||
};
|
||||
|
||||
async function gitClone(options: GitCloneOptions): Promise<void> {
|
||||
const name = options.name ?? dirname(options.repository);
|
||||
const cwd = options.cwd ?? process.cwd();
|
||||
const path = join(cwd, name);
|
||||
if (existsSync(path)) {
|
||||
await spawn({
|
||||
cwd: path,
|
||||
cmd: ["git", "pull"],
|
||||
});
|
||||
} else {
|
||||
const url = `${options.repository}`;
|
||||
await spawn({
|
||||
cwd,
|
||||
cmd: ["git", "clone", "--single-branch", "--depth", "1", url, name],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
type SpawnOptions = {
|
||||
cwd: string;
|
||||
cmd: string[];
|
||||
};
|
||||
|
||||
async function spawn({ cwd, cmd }: SpawnOptions) {
|
||||
const { exited } = await Bun.spawn({
|
||||
cwd,
|
||||
cmd,
|
||||
stdout: "inherit",
|
||||
stderr: "inherit",
|
||||
});
|
||||
const exitCode = await exited;
|
||||
if (exitCode !== 0) {
|
||||
throw new Error(`"${cmd.join(" ")}" exited with ${exitCode}`);
|
||||
}
|
||||
}
|
||||
16
packages/bun-ecosystem/tsconfig.json
Normal file
16
packages/bun-ecosystem/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["ESNext"],
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"types": ["bun-types"],
|
||||
"esModuleInterop": true,
|
||||
"allowJs": true,
|
||||
"strict": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
230
packages/bun-error/package-lock.json
generated
230
packages/bun-error/package-lock.json
generated
@@ -1,230 +0,0 @@
|
||||
{
|
||||
"name": "bun-error",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@types/prop-types": {
|
||||
"version": "15.7.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz",
|
||||
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/react": {
|
||||
"version": "17.0.47",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.47.tgz",
|
||||
"integrity": "sha512-mk0BL8zBinf2ozNr3qPnlu1oyVTYq+4V7WA76RgxUAtf0Em/Wbid38KN6n4abEkvO4xMTBWmnP1FtQzgkEiJoA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/prop-types": "*",
|
||||
"@types/scheduler": "*",
|
||||
"csstype": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"@types/scheduler": {
|
||||
"version": "0.16.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
|
||||
"integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==",
|
||||
"dev": true
|
||||
},
|
||||
"csstype": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.0.tgz",
|
||||
"integrity": "sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==",
|
||||
"dev": true
|
||||
},
|
||||
"esbuild": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.48.tgz",
|
||||
"integrity": "sha512-w6N1Yn5MtqK2U1/WZTX9ZqUVb8IOLZkZ5AdHkT6x3cHDMVsYWC7WPdiLmx19w3i4Rwzy5LqsEMtVihG3e4rFzA==",
|
||||
"requires": {
|
||||
"esbuild-android-64": "0.14.48",
|
||||
"esbuild-android-arm64": "0.14.48",
|
||||
"esbuild-darwin-64": "0.14.48",
|
||||
"esbuild-darwin-arm64": "0.14.48",
|
||||
"esbuild-freebsd-64": "0.14.48",
|
||||
"esbuild-freebsd-arm64": "0.14.48",
|
||||
"esbuild-linux-32": "0.14.48",
|
||||
"esbuild-linux-64": "0.14.48",
|
||||
"esbuild-linux-arm": "0.14.48",
|
||||
"esbuild-linux-arm64": "0.14.48",
|
||||
"esbuild-linux-mips64le": "0.14.48",
|
||||
"esbuild-linux-ppc64le": "0.14.48",
|
||||
"esbuild-linux-riscv64": "0.14.48",
|
||||
"esbuild-linux-s390x": "0.14.48",
|
||||
"esbuild-netbsd-64": "0.14.48",
|
||||
"esbuild-openbsd-64": "0.14.48",
|
||||
"esbuild-sunos-64": "0.14.48",
|
||||
"esbuild-windows-32": "0.14.48",
|
||||
"esbuild-windows-64": "0.14.48",
|
||||
"esbuild-windows-arm64": "0.14.48"
|
||||
}
|
||||
},
|
||||
"esbuild-android-64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.14.48.tgz",
|
||||
"integrity": "sha512-3aMjboap/kqwCUpGWIjsk20TtxVoKck8/4Tu19rubh7t5Ra0Yrpg30Mt1QXXlipOazrEceGeWurXKeFJgkPOUg==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-android-arm64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.48.tgz",
|
||||
"integrity": "sha512-vptI3K0wGALiDq+EvRuZotZrJqkYkN5282iAfcffjI5lmGG9G1ta/CIVauhY42MBXwEgDJkweiDcDMRLzBZC4g==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-darwin-64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.48.tgz",
|
||||
"integrity": "sha512-gGQZa4+hab2Va/Zww94YbshLuWteyKGD3+EsVon8EWTWhnHFRm5N9NbALNbwi/7hQ/hM1Zm4FuHg+k6BLsl5UA==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-darwin-arm64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.48.tgz",
|
||||
"integrity": "sha512-bFjnNEXjhZT+IZ8RvRGNJthLWNHV5JkCtuOFOnjvo5pC0sk2/QVk0Qc06g2PV3J0TcU6kaPC3RN9yy9w2PSLEA==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-freebsd-64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.48.tgz",
|
||||
"integrity": "sha512-1NOlwRxmOsnPcWOGTB10JKAkYSb2nue0oM1AfHWunW/mv3wERfJmnYlGzL3UAOIUXZqW8GeA2mv+QGwq7DToqA==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-freebsd-arm64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.48.tgz",
|
||||
"integrity": "sha512-gXqKdO8wabVcYtluAbikDH2jhXp+Klq5oCD5qbVyUG6tFiGhrC9oczKq3vIrrtwcxDQqK6+HDYK8Zrd4bCA9Gw==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-32": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.48.tgz",
|
||||
"integrity": "sha512-ghGyDfS289z/LReZQUuuKq9KlTiTspxL8SITBFQFAFRA/IkIvDpnZnCAKTCjGXAmUqroMQfKJXMxyjJA69c/nQ==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.48.tgz",
|
||||
"integrity": "sha512-vni3p/gppLMVZLghI7oMqbOZdGmLbbKR23XFARKnszCIBpEMEDxOMNIKPmMItQrmH/iJrL1z8Jt2nynY0bE1ug==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-arm": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.48.tgz",
|
||||
"integrity": "sha512-+VfSV7Akh1XUiDNXgqgY1cUP1i2vjI+BmlyXRfVz5AfV3jbpde8JTs5Q9sYgaoq5cWfuKfoZB/QkGOI+QcL1Tw==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-arm64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.48.tgz",
|
||||
"integrity": "sha512-3CFsOlpoxlKPRevEHq8aAntgYGYkE1N9yRYAcPyng/p4Wyx0tPR5SBYsxLKcgPB9mR8chHEhtWYz6EZ+H199Zw==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-mips64le": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.48.tgz",
|
||||
"integrity": "sha512-cs0uOiRlPp6ymknDnjajCgvDMSsLw5mST2UXh+ZIrXTj2Ifyf2aAP3Iw4DiqgnyYLV2O/v/yWBJx+WfmKEpNLA==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-ppc64le": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.48.tgz",
|
||||
"integrity": "sha512-+2F0vJMkuI0Wie/wcSPDCqXvSFEELH7Jubxb7mpWrA/4NpT+/byjxDz0gG6R1WJoeDefcrMfpBx4GFNN1JQorQ==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-riscv64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.48.tgz",
|
||||
"integrity": "sha512-BmaK/GfEE+5F2/QDrIXteFGKnVHGxlnK9MjdVKMTfvtmudjY3k2t8NtlY4qemKSizc+QwyombGWTBDc76rxePA==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-s390x": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.48.tgz",
|
||||
"integrity": "sha512-tndw/0B9jiCL+KWKo0TSMaUm5UWBLsfCKVdbfMlb3d5LeV9WbijZ8Ordia8SAYv38VSJWOEt6eDCdOx8LqkC4g==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-netbsd-64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.48.tgz",
|
||||
"integrity": "sha512-V9hgXfwf/T901Lr1wkOfoevtyNkrxmMcRHyticybBUHookznipMOHoF41Al68QBsqBxnITCEpjjd4yAos7z9Tw==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-openbsd-64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.48.tgz",
|
||||
"integrity": "sha512-+IHf4JcbnnBl4T52egorXMatil/za0awqzg2Vy6FBgPcBpisDWT2sVz/tNdrK9kAqj+GZG/jZdrOkj7wsrNTKA==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-sunos-64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.48.tgz",
|
||||
"integrity": "sha512-77m8bsr5wOpOWbGi9KSqDphcq6dFeJyun8TA+12JW/GAjyfTwVtOnN8DOt6DSPUfEV+ltVMNqtXUeTeMAxl5KA==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-windows-32": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.48.tgz",
|
||||
"integrity": "sha512-EPgRuTPP8vK9maxpTGDe5lSoIBHGKO/AuxDncg5O3NkrPeLNdvvK8oywB0zGaAZXxYWfNNSHskvvDgmfVTguhg==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-windows-64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.48.tgz",
|
||||
"integrity": "sha512-YmpXjdT1q0b8ictSdGwH3M8VCoqPpK1/UArze3X199w6u8hUx3V8BhAi1WjbsfDYRBanVVtduAhh2sirImtAvA==",
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-windows-arm64": {
|
||||
"version": "0.14.48",
|
||||
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.48.tgz",
|
||||
"integrity": "sha512-HHaOMCsCXp0rz5BT2crTka6MPWVno121NKApsGs/OIW5QC0ggC69YMGs1aJct9/9FSUF4A1xNE/cLvgB5svR4g==",
|
||||
"optional": true
|
||||
},
|
||||
"js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
|
||||
},
|
||||
"loose-envify": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
|
||||
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
|
||||
"requires": {
|
||||
"js-tokens": "^3.0.0 || ^4.0.0"
|
||||
}
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
|
||||
},
|
||||
"react": {
|
||||
"version": "17.0.2",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz",
|
||||
"integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==",
|
||||
"requires": {
|
||||
"loose-envify": "^1.1.0",
|
||||
"object-assign": "^4.1.1"
|
||||
}
|
||||
},
|
||||
"react-dom": {
|
||||
"version": "17.0.2",
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz",
|
||||
"integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==",
|
||||
"requires": {
|
||||
"loose-envify": "^1.1.0",
|
||||
"object-assign": "^4.1.1",
|
||||
"scheduler": "^0.20.2"
|
||||
}
|
||||
},
|
||||
"scheduler": {
|
||||
"version": "0.20.2",
|
||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz",
|
||||
"integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==",
|
||||
"requires": {
|
||||
"loose-envify": "^1.1.0",
|
||||
"object-assign": "^4.1.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
6
packages/bun-release/.gitignore
vendored
Normal file
6
packages/bun-release/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.DS_Store
|
||||
.env
|
||||
node_modules
|
||||
/npm/**/bin
|
||||
/npm/**/*.js
|
||||
/npm/**/.npmrc
|
||||
2
packages/bun-release/.npmrc
Normal file
2
packages/bun-release/.npmrc
Normal file
@@ -0,0 +1,2 @@
|
||||
@oven:registry=https://registry.npmjs.org/
|
||||
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
||||
15
packages/bun-release/README.md
Normal file
15
packages/bun-release/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# bun-release
|
||||
|
||||
Scripts that release Bun to npm, Dockerhub, Homebrew, etc.
|
||||
|
||||
### Running
|
||||
|
||||
```sh
|
||||
bun run npm # build assets for the latest release
|
||||
bun run npm -- <release> # build assets for the provided release
|
||||
bun run npm -- <release> [dry-run|publish] # build and publish assets to npm
|
||||
```
|
||||
|
||||
### Credits
|
||||
|
||||
- [esbuild](https://github.com/evanw/esbuild), for its npm scripts which this was largely based off of.
|
||||
BIN
packages/bun-release/bun.lockb
Executable file
BIN
packages/bun-release/bun.lockb
Executable file
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
# Bun
|
||||
|
||||
This is the macOS arm64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@oven/bun-darwin-aarch64",
|
||||
"version": "0.5.3",
|
||||
"description": "This is the macOS arm64 binary for Bun, a fast all-in-one JavaScript runtime.",
|
||||
"homepage": "https://bun.sh",
|
||||
"bugs": "https://github.com/oven-sh/issues",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/oven-sh/bun",
|
||||
"preferUnplugged": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"cpu": [
|
||||
"arm64"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Bun
|
||||
|
||||
This is the macOS x64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh
|
||||
|
||||
_Note: "Baseline" builds are for machines that do not support [AVX2](https://en.wikipedia.org/wiki/Advanced_Vector_Extensions) instructions._
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@oven/bun-darwin-x64-baseline",
|
||||
"version": "0.5.3",
|
||||
"description": "This is the macOS x64 binary for Bun, a fast all-in-one JavaScript runtime.",
|
||||
"homepage": "https://bun.sh",
|
||||
"bugs": "https://github.com/oven-sh/issues",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/oven-sh/bun",
|
||||
"preferUnplugged": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
3
packages/bun-release/npm/@oven/bun-darwin-x64/README.md
Normal file
3
packages/bun-release/npm/@oven/bun-darwin-x64/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Bun
|
||||
|
||||
This is the macOS x64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh
|
||||
16
packages/bun-release/npm/@oven/bun-darwin-x64/package.json
Normal file
16
packages/bun-release/npm/@oven/bun-darwin-x64/package.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@oven/bun-darwin-x64",
|
||||
"version": "0.5.3",
|
||||
"description": "This is the macOS x64 binary for Bun, a fast all-in-one JavaScript runtime.",
|
||||
"homepage": "https://bun.sh",
|
||||
"bugs": "https://github.com/oven-sh/issues",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/oven-sh/bun",
|
||||
"preferUnplugged": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Bun
|
||||
|
||||
This is the Linux arm64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@oven/bun-linux-aarch64",
|
||||
"version": "0.5.3",
|
||||
"description": "This is the Linux arm64 binary for Bun, a fast all-in-one JavaScript runtime.",
|
||||
"homepage": "https://bun.sh",
|
||||
"bugs": "https://github.com/oven-sh/issues",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/oven-sh/bun",
|
||||
"preferUnplugged": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"cpu": [
|
||||
"arm64"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Bun
|
||||
|
||||
This is the Linux x64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh
|
||||
|
||||
_Note: "Baseline" builds are for machines that do not support [AVX2](https://en.wikipedia.org/wiki/Advanced_Vector_Extensions) instructions._
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@oven/bun-linux-x64-baseline",
|
||||
"version": "0.5.3",
|
||||
"description": "This is the Linux x64 binary for Bun, a fast all-in-one JavaScript runtime.",
|
||||
"homepage": "https://bun.sh",
|
||||
"bugs": "https://github.com/oven-sh/issues",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/oven-sh/bun",
|
||||
"preferUnplugged": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
3
packages/bun-release/npm/@oven/bun-linux-x64/README.md
Normal file
3
packages/bun-release/npm/@oven/bun-linux-x64/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Bun
|
||||
|
||||
This is the Linux x64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh
|
||||
16
packages/bun-release/npm/@oven/bun-linux-x64/package.json
Normal file
16
packages/bun-release/npm/@oven/bun-linux-x64/package.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@oven/bun-linux-x64",
|
||||
"version": "0.5.3",
|
||||
"description": "This is the Linux x64 binary for Bun, a fast all-in-one JavaScript runtime.",
|
||||
"homepage": "https://bun.sh",
|
||||
"bugs": "https://github.com/oven-sh/issues",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/oven-sh/bun",
|
||||
"preferUnplugged": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
31
packages/bun-release/npm/bun/README.md
Normal file
31
packages/bun-release/npm/bun/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Bun
|
||||
|
||||
Bun is a fast all-in-one JavaScript runtime. https://bun.sh
|
||||
|
||||
### Install
|
||||
|
||||
```sh
|
||||
npm install -g bun
|
||||
```
|
||||
|
||||
### Upgrade
|
||||
|
||||
```sh
|
||||
bun upgrade
|
||||
```
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- [macOS, arm64 (Apple Silicon)](https://www.npmjs.com/package/@oven/bun-darwin-aarch64)
|
||||
- [macOS, x64](https://www.npmjs.com/package/@oven/bun-darwin-x64)
|
||||
- [macOS, x64 (without AVX2 instructions)](https://www.npmjs.com/package/@oven/bun-darwin-x64-baseline)
|
||||
- [Linux, arm64](https://www.npmjs.com/package/@oven/bun-linux-aarch64)
|
||||
- [Linux, x64](https://www.npmjs.com/package/@oven/bun-linux-x64)
|
||||
- [Linux, x64 (without AVX2 instructions)](https://www.npmjs.com/package/@oven/bun-linux-x64-baseline)
|
||||
- [Windows (using Windows Subsystem for Linux, aka. "WSL")](https://relatablecode.com/how-to-set-up-bun-on-a-windows-machine)
|
||||
|
||||
### Future Platforms
|
||||
|
||||
- [Windows](https://github.com/oven-sh/bun/issues/43)
|
||||
- Unix-like variants such as FreeBSD, OpenBSD, etc.
|
||||
- Android and iOS
|
||||
42
packages/bun-release/npm/bun/package.json
Normal file
42
packages/bun-release/npm/bun/package.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "bun",
|
||||
"version": "0.5.3",
|
||||
"description": "Bun is a fast all-in-one JavaScript runtime.",
|
||||
"keywords": [
|
||||
"bun",
|
||||
"bun.js",
|
||||
"node",
|
||||
"node.js",
|
||||
"runtime",
|
||||
"bundler",
|
||||
"transpiler",
|
||||
"typescript"
|
||||
],
|
||||
"homepage": "https://bun.sh",
|
||||
"bugs": "https://github.com/oven-sh/issues",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"bun": "bin/bun",
|
||||
"bunx": "bin/bun"
|
||||
},
|
||||
"repository": "https://github.com/oven-sh/bun",
|
||||
"scripts": {
|
||||
"postinstall": "node install.js"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@oven/bun-darwin-aarch64": "0.5.3",
|
||||
"@oven/bun-darwin-x64": "0.5.3",
|
||||
"@oven/bun-darwin-x64-baseline": "0.5.3",
|
||||
"@oven/bun-linux-aarch64": "0.5.3",
|
||||
"@oven/bun-linux-x64": "0.5.3",
|
||||
"@oven/bun-linux-x64-baseline": "0.5.3"
|
||||
},
|
||||
"os": [
|
||||
"darwin",
|
||||
"linux"
|
||||
],
|
||||
"cpu": [
|
||||
"arm64",
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
19
packages/bun-release/package.json
Normal file
19
packages/bun-release/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"esbuild": "^0.17.3",
|
||||
"jszip": "^3.10.1",
|
||||
"octokit": "^2.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/types": "^8.1.1",
|
||||
"bun-types": "^0.4.0",
|
||||
"prettier": "^2.8.2"
|
||||
},
|
||||
"scripts": {
|
||||
"format": "prettier --write src scripts",
|
||||
"get-version": "bun scripts/get-version.ts",
|
||||
"upload-npm": "bun scripts/upload-npm.ts",
|
||||
"upload-assets": "bun scripts/upload-assets.ts"
|
||||
}
|
||||
}
|
||||
5
packages/bun-release/scripts/get-version.ts
Normal file
5
packages/bun-release/scripts/get-version.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { log } from "../src/console";
|
||||
import { getSemver } from "../src/github";
|
||||
|
||||
log(await getSemver(process.argv[2]));
|
||||
process.exit(0); // HACK
|
||||
13
packages/bun-release/scripts/npm-exec.ts
Normal file
13
packages/bun-release/scripts/npm-exec.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { importBun } from "../src/npm/install";
|
||||
import { execFileSync } from "child_process";
|
||||
|
||||
importBun()
|
||||
.then(bun => {
|
||||
return execFileSync(bun, process.argv.slice(2), {
|
||||
stdio: "inherit",
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
10
packages/bun-release/scripts/npm-postinstall.ts
Normal file
10
packages/bun-release/scripts/npm-postinstall.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { importBun, optimizeBun } from "../src/npm/install";
|
||||
|
||||
importBun()
|
||||
.then(path => {
|
||||
optimizeBun(path);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
92
packages/bun-release/scripts/upload-assets.ts
Normal file
92
packages/bun-release/scripts/upload-assets.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
import { getRelease, uploadAsset } from "../src/github";
|
||||
import { fetch } from "../src/fetch";
|
||||
import { spawn } from "../src/spawn";
|
||||
import { confirm, exit, log, stdin, warn } from "../src/console";
|
||||
import { hash, join, rm, tmp, write, basename, blob } from "../src/fs";
|
||||
|
||||
const [tag, ...paths] = process.argv.slice(2);
|
||||
|
||||
if (!tag) {
|
||||
exit("Invalid arguments: [tag] [...assets]");
|
||||
}
|
||||
|
||||
const { tag_name, assets } = await getRelease(tag);
|
||||
log("Release:", tag_name, "\n");
|
||||
log("Existing assets:\n", ...assets.map(({ name }) => `- ${name}\n`));
|
||||
log("Updating assets:\n", ...paths.map(path => `+ ${basename(path)}\n`));
|
||||
await confirm();
|
||||
|
||||
log("Hashing assets...\n");
|
||||
const existing: Map<string, string> = new Map();
|
||||
for (const { name, browser_download_url } of assets) {
|
||||
if (name.startsWith("SHASUMS256.txt")) {
|
||||
continue;
|
||||
}
|
||||
const response = await fetch(browser_download_url);
|
||||
const buffer = Buffer.from(await response.arrayBuffer());
|
||||
existing.set(name, await hash(buffer));
|
||||
}
|
||||
const updated: Map<string, string> = new Map();
|
||||
for (const path of paths) {
|
||||
const name = basename(path);
|
||||
updated.set(name, await hash(path));
|
||||
}
|
||||
log(
|
||||
"Unchanged hashes:\n",
|
||||
...Array.from(existing.entries())
|
||||
.filter(([name]) => !updated.has(name))
|
||||
.map(([name, sha256]) => ` - ${sha256} => ${name}\n`),
|
||||
);
|
||||
log("Changed hashes:\n", ...Array.from(updated.entries()).map(([name, sha256]) => ` + ${sha256} => ${name}\n`));
|
||||
await confirm();
|
||||
|
||||
log("Signing assets...\n");
|
||||
const cwd = tmp();
|
||||
const path = join(cwd, "SHASUMS256.txt");
|
||||
const signedPath = `${path}.asc`;
|
||||
write(
|
||||
path,
|
||||
[...Array.from(updated.entries()), ...Array.from(existing.entries()).filter(([name]) => !updated.has(name))]
|
||||
.sort(([a], [b]) => a.localeCompare(b))
|
||||
.map(([name, sha256]) => `${sha256} ${name}`)
|
||||
.join("\n"),
|
||||
);
|
||||
const { stdout: keys } = spawn("gpg", ["--list-secret-keys", "--keyid-format", "long"]);
|
||||
const verifiedKeys = [
|
||||
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59", // robobun@oven.sh
|
||||
];
|
||||
if (!verifiedKeys.find(key => keys.includes(key))) {
|
||||
warn("Signature is probably wrong, key not found: robobun@oven.sh");
|
||||
}
|
||||
const passphrase = await stdin("Passphrase:");
|
||||
log();
|
||||
const { exitCode, stdout, stderr } = spawn(
|
||||
"gpg",
|
||||
["--pinentry-mode", "loopback", "--passphrase-fd", "0", "--clearsign", "--output", signedPath, path],
|
||||
{
|
||||
// @ts-ignore
|
||||
input: passphrase,
|
||||
stdout: "inherit",
|
||||
stderr: "inherit",
|
||||
},
|
||||
);
|
||||
if (exitCode !== 0) {
|
||||
exit(stdout || stderr);
|
||||
}
|
||||
|
||||
const uploads = [...paths, path, signedPath];
|
||||
log("Uploading assets:\n", ...uploads.map(path => ` + ${basename(path)}\n`));
|
||||
await confirm();
|
||||
|
||||
for (const path of uploads) {
|
||||
const name = basename(path);
|
||||
await uploadAsset(tag_name, name, blob(path));
|
||||
}
|
||||
try {
|
||||
rm(cwd);
|
||||
} catch {
|
||||
warn("Failed to cleanup:", cwd, "\n");
|
||||
}
|
||||
log("Done");
|
||||
|
||||
process.exit(0); // FIXME
|
||||
164
packages/bun-release/scripts/upload-npm.ts
Normal file
164
packages/bun-release/scripts/upload-npm.ts
Normal file
@@ -0,0 +1,164 @@
|
||||
import { join, copy, exists, chmod, write, writeJson } from "../src/fs";
|
||||
import { fetch } from "../src/fetch";
|
||||
import { spawn } from "../src/spawn";
|
||||
import type { Platform } from "../src/platform";
|
||||
import { platforms } from "../src/platform";
|
||||
import { getSemver } from "../src/github";
|
||||
import { getRelease } from "../src/github";
|
||||
import type { BuildOptions } from "esbuild";
|
||||
import { buildSync, formatMessagesSync } from "esbuild";
|
||||
import type { JSZipObject } from "jszip";
|
||||
import { loadAsync } from "jszip";
|
||||
import { debug, log, error } from "../src/console";
|
||||
|
||||
const module = "bun";
|
||||
const owner = "@oven";
|
||||
let version: string;
|
||||
|
||||
const [tag, action] = process.argv.slice(2);
|
||||
|
||||
await build(tag);
|
||||
if (action === "publish") {
|
||||
await publish();
|
||||
} else if (action === "dry-run") {
|
||||
await publish(true);
|
||||
} else if (action) {
|
||||
throw new Error(`Unknown action: ${action}`);
|
||||
}
|
||||
process.exit(0); // HACK
|
||||
|
||||
async function build(tag?: string): Promise<void> {
|
||||
const release = await getRelease(tag);
|
||||
version = await getSemver(release.tag_name);
|
||||
await buildRootModule();
|
||||
for (const platform of platforms) {
|
||||
await buildModule(release, platform);
|
||||
}
|
||||
}
|
||||
|
||||
async function publish(dryRun?: boolean): Promise<void> {
|
||||
const modules = platforms.map(({ bin }) => `${owner}/${bin}`);
|
||||
modules.push(module);
|
||||
for (const module of modules) {
|
||||
publishModule(module, dryRun);
|
||||
}
|
||||
}
|
||||
|
||||
async function buildRootModule() {
|
||||
log("Building:", `${module}@${version}`);
|
||||
const cwd = join("npm", module);
|
||||
const define = {
|
||||
version: `"${version}"`,
|
||||
module: `"${module}"`,
|
||||
owner: `"${owner}"`,
|
||||
};
|
||||
bundle(join("scripts", "npm-postinstall.ts"), join(cwd, "install.js"), {
|
||||
define,
|
||||
});
|
||||
bundle(join("scripts", "npm-exec.ts"), join(cwd, "bin", "bun"), {
|
||||
define,
|
||||
banner: {
|
||||
js: "#!/usr/bin/env node",
|
||||
},
|
||||
});
|
||||
const os = [...new Set(platforms.map(({ os }) => os))];
|
||||
const cpu = [...new Set(platforms.map(({ arch }) => arch))];
|
||||
writeJson(join(cwd, "package.json"), {
|
||||
name: module,
|
||||
version: version,
|
||||
scripts: {
|
||||
postinstall: "node install.js",
|
||||
},
|
||||
optionalDependencies: Object.fromEntries(platforms.map(({ bin }) => [`${owner}/${bin}`, version])),
|
||||
bin: {
|
||||
bun: "bin/bun",
|
||||
bunx: "bin/bun",
|
||||
},
|
||||
os,
|
||||
cpu,
|
||||
});
|
||||
if (exists(".npmrc")) {
|
||||
copy(".npmrc", join(cwd, ".npmrc"));
|
||||
}
|
||||
}
|
||||
|
||||
async function buildModule(
|
||||
release: Awaited<ReturnType<typeof getRelease>>,
|
||||
{ bin, exe, os, arch }: Platform,
|
||||
): Promise<void> {
|
||||
const module = `${owner}/${bin}`;
|
||||
log("Building:", `${module}@${version}`);
|
||||
const asset = release.assets.find(({ name }) => name === `${bin}.zip`);
|
||||
if (!asset) {
|
||||
error(`No asset found: ${bin}`);
|
||||
return;
|
||||
}
|
||||
const bun = await extractFromZip(asset.browser_download_url, `${bin}/bun`);
|
||||
const cwd = join("npm", module);
|
||||
write(join(cwd, exe), await bun.async("arraybuffer"));
|
||||
chmod(join(cwd, exe), 0o755);
|
||||
writeJson(join(cwd, "package.json"), {
|
||||
name: module,
|
||||
version: version,
|
||||
preferUnplugged: true,
|
||||
os: [os],
|
||||
cpu: [arch],
|
||||
});
|
||||
if (exists(".npmrc")) {
|
||||
copy(".npmrc", join(cwd, ".npmrc"));
|
||||
}
|
||||
}
|
||||
|
||||
function publishModule(name: string, dryRun?: boolean): void {
|
||||
log(dryRun ? "Dry-run Publishing:" : "Publishing:", `${name}@${version}`);
|
||||
const { exitCode, stdout, stderr } = spawn(
|
||||
"npm",
|
||||
[
|
||||
"publish",
|
||||
"--access",
|
||||
"public",
|
||||
"--tag",
|
||||
version.includes("canary") ? "canary" : "latest",
|
||||
...(dryRun ? ["--dry-run"] : []),
|
||||
],
|
||||
{
|
||||
cwd: join("npm", name),
|
||||
},
|
||||
);
|
||||
if (exitCode === 0) {
|
||||
error(stderr || stdout);
|
||||
}
|
||||
}
|
||||
|
||||
async function extractFromZip(url: string, filename: string): Promise<JSZipObject> {
|
||||
const response = await fetch(url);
|
||||
const buffer = await response.arrayBuffer();
|
||||
const zip = await loadAsync(buffer);
|
||||
for (const [name, file] of Object.entries(zip.files)) {
|
||||
if (!file.dir && name.startsWith(filename)) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
debug("Found files:", Object.keys(zip.files));
|
||||
throw new Error(`File not found: ${filename}`);
|
||||
}
|
||||
|
||||
function bundle(src: string, dst: string, options: BuildOptions = {}): void {
|
||||
const { errors } = buildSync({
|
||||
bundle: true,
|
||||
treeShaking: true,
|
||||
keepNames: true,
|
||||
minifySyntax: true,
|
||||
pure: ["console.debug"],
|
||||
platform: "node",
|
||||
target: "es6",
|
||||
format: "cjs",
|
||||
entryPoints: [src],
|
||||
outfile: dst,
|
||||
...options,
|
||||
});
|
||||
if (errors?.length) {
|
||||
const messages = formatMessagesSync(errors, { kind: "error" });
|
||||
throw new Error(messages.join("\n"));
|
||||
}
|
||||
}
|
||||
75
packages/bun-release/src/console.ts
Normal file
75
packages/bun-release/src/console.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { isatty } from "tty";
|
||||
import { createInterface } from "readline";
|
||||
|
||||
export const isAction = !!process.env["GITHUB_ACTION"];
|
||||
|
||||
export const isDebug =
|
||||
process.env["DEBUG"] === "1" || process.env["LOG_LEVEL"] === "debug" || process.env["RUNNER_DEBUG"] === "1";
|
||||
|
||||
export function debug(...message: any[]): void {
|
||||
if (isAction) {
|
||||
console.debug("::debug::", ...message);
|
||||
} else if (isDebug) {
|
||||
console.debug(...message);
|
||||
}
|
||||
}
|
||||
|
||||
export function log(...message: any[]): void {
|
||||
console.log(...message);
|
||||
}
|
||||
|
||||
export function warn(...message: any[]): void {
|
||||
if (isAction) {
|
||||
console.warn("::warning::", ...message);
|
||||
} else {
|
||||
console.warn(...message);
|
||||
}
|
||||
}
|
||||
|
||||
export function error(...message: any[]): void {
|
||||
if (isAction) {
|
||||
console.error("::error::", ...message);
|
||||
} else {
|
||||
console.error(...message);
|
||||
}
|
||||
}
|
||||
|
||||
export function exit(...message: any[]): never {
|
||||
error(...message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
export function isTty(): boolean {
|
||||
return isatty(process.stdout.fd);
|
||||
}
|
||||
|
||||
export async function stdin(question: string): Promise<string> {
|
||||
if (isTty()) {
|
||||
return prompt(question) || "";
|
||||
}
|
||||
const reader = createInterface({
|
||||
input: process.stdin,
|
||||
terminal: false,
|
||||
});
|
||||
let buffer = "";
|
||||
reader.on("line", line => {
|
||||
buffer += line;
|
||||
});
|
||||
return new Promise(resolve => {
|
||||
reader.once("close", () => resolve(buffer));
|
||||
});
|
||||
}
|
||||
|
||||
export async function confirm(message?: string): Promise<void> {
|
||||
if (!isTty()) {
|
||||
return;
|
||||
}
|
||||
const question = message ?? "Confirm?";
|
||||
switch (prompt(`${question} [y/n]`)) {
|
||||
case "y":
|
||||
case "Y":
|
||||
log();
|
||||
return;
|
||||
}
|
||||
exit();
|
||||
}
|
||||
70
packages/bun-release/src/fetch.ts
Normal file
70
packages/bun-release/src/fetch.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { debug, isDebug } from "./console";
|
||||
|
||||
export const fetch = "fetch" in globalThis ? webFetch : nodeFetch;
|
||||
|
||||
type Options = RequestInit & { assert?: boolean };
|
||||
|
||||
async function webFetch(url: string, options: Options = {}): Promise<Response> {
|
||||
debug("fetch request", url, options);
|
||||
const response = await globalThis.fetch(url, options, { verbose: isDebug });
|
||||
debug("fetch response", response);
|
||||
if (options?.assert !== false && !isOk(response.status)) {
|
||||
try {
|
||||
debug(await response.text());
|
||||
} catch {}
|
||||
throw new Error(`${response.status}: ${url}`);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
async function nodeFetch(url: string, options: Options = {}): Promise<Response> {
|
||||
const { get } = await import("node:http");
|
||||
return new Promise((resolve, reject) => {
|
||||
get(url, response => {
|
||||
debug("http.get", url, response.statusCode);
|
||||
const status = response.statusCode ?? 501;
|
||||
if (response.headers.location && isRedirect(status)) {
|
||||
return nodeFetch(url).then(resolve, reject);
|
||||
}
|
||||
if (options?.assert !== false && !isOk(status)) {
|
||||
return reject(new Error(`${status}: ${url}`));
|
||||
}
|
||||
const body: Buffer[] = [];
|
||||
response.on("data", chunk => {
|
||||
body.push(chunk);
|
||||
});
|
||||
response.on("end", () => {
|
||||
resolve({
|
||||
ok: isOk(status),
|
||||
status,
|
||||
async arrayBuffer() {
|
||||
return Buffer.concat(body).buffer as ArrayBuffer;
|
||||
},
|
||||
async text() {
|
||||
return Buffer.concat(body).toString("utf-8");
|
||||
},
|
||||
async json() {
|
||||
const text = Buffer.concat(body).toString("utf-8");
|
||||
return JSON.parse(text);
|
||||
},
|
||||
} as Response);
|
||||
});
|
||||
}).on("error", reject);
|
||||
});
|
||||
}
|
||||
|
||||
function isOk(status: number): boolean {
|
||||
return status >= 200 && status <= 204;
|
||||
}
|
||||
|
||||
function isRedirect(status: number): boolean {
|
||||
switch (status) {
|
||||
case 301: // Moved Permanently
|
||||
case 308: // Permanent Redirect
|
||||
case 302: // Found
|
||||
case 307: // Temporary Redirect
|
||||
case 303: // See Other
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
159
packages/bun-release/src/fs.ts
Normal file
159
packages/bun-release/src/fs.ts
Normal file
@@ -0,0 +1,159 @@
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import os from "os";
|
||||
import crypto from "crypto";
|
||||
import { debug } from "./console";
|
||||
|
||||
export function join(...paths: (string | string[])[]): string {
|
||||
return path.join(...paths.flat(2));
|
||||
}
|
||||
|
||||
export function basename(...paths: (string | string[])[]): string {
|
||||
return path.basename(join(...paths));
|
||||
}
|
||||
|
||||
export function tmp(): string {
|
||||
const tmpdir = process.env["RUNNER_TEMP"] ?? os.tmpdir();
|
||||
const dir = fs.mkdtempSync(join(tmpdir, "bun-"));
|
||||
debug("tmp", dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
export function rm(path: string): void {
|
||||
debug("rm", path);
|
||||
try {
|
||||
fs.rmSync(path, { recursive: true });
|
||||
return;
|
||||
} catch (error) {
|
||||
debug("fs.rmSync failed", error);
|
||||
// Did not exist before Node.js v14.
|
||||
// Attempt again with older, slower implementation.
|
||||
}
|
||||
let stats: fs.Stats;
|
||||
try {
|
||||
stats = fs.lstatSync(path);
|
||||
} catch (error) {
|
||||
debug("fs.lstatSync failed", error);
|
||||
// The file was likely deleted, so return early.
|
||||
return;
|
||||
}
|
||||
if (!stats.isDirectory()) {
|
||||
fs.unlinkSync(path);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
fs.rmdirSync(path, { recursive: true });
|
||||
return;
|
||||
} catch (error) {
|
||||
debug("fs.rmdirSync failed", error);
|
||||
// Recursive flag did not exist before Node.js X.
|
||||
// Attempt again with older, slower implementation.
|
||||
}
|
||||
for (const filename of fs.readdirSync(path)) {
|
||||
rm(join(path, filename));
|
||||
}
|
||||
fs.rmdirSync(path);
|
||||
}
|
||||
|
||||
export function rename(path: string, newPath: string): void {
|
||||
debug("rename", path, newPath);
|
||||
try {
|
||||
fs.renameSync(path, newPath);
|
||||
return;
|
||||
} catch (error) {
|
||||
debug("fs.renameSync failed", error);
|
||||
// If there is an error, delete the new path and try again.
|
||||
}
|
||||
try {
|
||||
rm(newPath);
|
||||
} catch (error) {
|
||||
debug("rm failed", error);
|
||||
// The path could have been deleted already.
|
||||
}
|
||||
fs.renameSync(path, newPath);
|
||||
}
|
||||
|
||||
export function write(dst: string, content: string | ArrayBuffer | ArrayBufferView): void {
|
||||
debug("write", dst);
|
||||
try {
|
||||
fs.writeFileSync(dst, content);
|
||||
return;
|
||||
} catch (error) {
|
||||
debug("fs.writeFileSync failed", error);
|
||||
// If there is an error, ensure the parent directory
|
||||
// exists and try again.
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
||||
} catch (error) {
|
||||
debug("fs.mkdirSync failed", error);
|
||||
// The directory could have been created already.
|
||||
}
|
||||
fs.writeFileSync(dst, content);
|
||||
}
|
||||
}
|
||||
|
||||
export function writeJson(path: string, json: object, force?: boolean): void {
|
||||
let value = json;
|
||||
if (!force && exists(path)) {
|
||||
try {
|
||||
const existing = JSON.parse(read(path));
|
||||
value = {
|
||||
...existing,
|
||||
...json,
|
||||
};
|
||||
} catch {
|
||||
value = json;
|
||||
}
|
||||
}
|
||||
write(path, `${JSON.stringify(value, undefined, 2)}\n`);
|
||||
}
|
||||
|
||||
export function read(path: string): string {
|
||||
debug("read", path);
|
||||
return fs.readFileSync(path, "utf-8");
|
||||
}
|
||||
|
||||
export function blob(path: string): Blob {
|
||||
debug("blob", path);
|
||||
if ("Bun" in globalThis) {
|
||||
return Bun.file(path);
|
||||
}
|
||||
const buffer = fs.readFileSync(path);
|
||||
return new Blob([buffer], {
|
||||
type: path.endsWith(".zip") ? "application/zip" : path.endsWith(".txt") ? "text/plain" : "application/octet-stream",
|
||||
});
|
||||
}
|
||||
|
||||
export function hash(content: string | crypto.BinaryLike): string {
|
||||
debug("hash", content);
|
||||
return crypto
|
||||
.createHash("sha256")
|
||||
.update(typeof content === "string" ? fs.readFileSync(content) : content)
|
||||
.digest("hex");
|
||||
}
|
||||
|
||||
export function chmod(path: string, mode: fs.Mode): void {
|
||||
debug("chmod", path, mode);
|
||||
fs.chmodSync(path, mode);
|
||||
}
|
||||
|
||||
export function copy(path: string, newPath: string): void {
|
||||
debug("copy", path, newPath);
|
||||
try {
|
||||
fs.copyFileSync(path, newPath);
|
||||
return;
|
||||
} catch (error) {
|
||||
debug("fs.copyFileSync failed", error);
|
||||
}
|
||||
write(newPath, read(path));
|
||||
}
|
||||
|
||||
export function exists(path: string): boolean {
|
||||
debug("exists", path);
|
||||
try {
|
||||
return fs.existsSync(path);
|
||||
} catch (error) {
|
||||
debug("fs.existsSync failed", error);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
120
packages/bun-release/src/github.ts
Normal file
120
packages/bun-release/src/github.ts
Normal file
@@ -0,0 +1,120 @@
|
||||
import type { Endpoints, RequestParameters, Route } from "@octokit/types";
|
||||
import { Octokit } from "octokit";
|
||||
import { fetch } from "./fetch";
|
||||
import { debug, log, warn, error } from "./console";
|
||||
|
||||
const [owner, repo] = process.env["GITHUB_REPOSITORY"]?.split("/") ?? ["oven-sh", "bun"];
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: process.env["GITHUB_TOKEN"],
|
||||
request: {
|
||||
fetch,
|
||||
},
|
||||
log: {
|
||||
debug,
|
||||
info: log,
|
||||
warn,
|
||||
error,
|
||||
},
|
||||
});
|
||||
|
||||
export async function github<R extends Route>(
|
||||
url: R | keyof Endpoints,
|
||||
options?: Omit<
|
||||
R extends keyof Endpoints ? Endpoints[R]["parameters"] & RequestParameters : RequestParameters,
|
||||
"owner" | "repo"
|
||||
>,
|
||||
): Promise<R extends keyof Endpoints ? Endpoints[R]["response"]["data"] : unknown> {
|
||||
// @ts-ignore
|
||||
const { data } = await octokit.request(url, {
|
||||
owner,
|
||||
repo,
|
||||
...options,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function getRelease(tag?: string) {
|
||||
if (!tag) {
|
||||
return github("GET /repos/{owner}/{repo}/releases/latest");
|
||||
}
|
||||
return github("GET /repos/{owner}/{repo}/releases/tags/{tag}", {
|
||||
tag: formatTag(tag),
|
||||
});
|
||||
}
|
||||
|
||||
export async function uploadAsset(tag: string, name: string, blob: Blob) {
|
||||
const release = await getRelease(tag);
|
||||
const asset = release.assets.find(asset => asset.name === name);
|
||||
// Github requires that existing assets are deleted before uploading
|
||||
// a new asset, but does not provide a rename or re-upload API?!?
|
||||
if (asset) {
|
||||
await github("DELETE /repos/{owner}/{repo}/releases/assets/{asset_id}", {
|
||||
asset_id: asset.id,
|
||||
});
|
||||
}
|
||||
return github("POST {origin}/repos/{owner}/{repo}/releases/{release_id}/assets{?name,label}", {
|
||||
baseUrl: "https://uploads.github.com",
|
||||
release_id: release.id,
|
||||
name,
|
||||
headers: {
|
||||
"content-type": blob.type,
|
||||
"content-length": blob.size,
|
||||
},
|
||||
data: Buffer.from(await blob.arrayBuffer()),
|
||||
});
|
||||
}
|
||||
|
||||
export async function downloadAsset(tag: string, name: string): Promise<Blob> {
|
||||
const release = await getRelease(tag);
|
||||
const asset = release.assets.find(asset => asset.name === name);
|
||||
if (!asset) {
|
||||
throw new Error(`Asset not found: ${name}`);
|
||||
}
|
||||
const response = await fetch(asset.browser_download_url);
|
||||
return response.blob();
|
||||
}
|
||||
|
||||
export async function getSha(tag: string, format?: "short" | "long") {
|
||||
const ref = formatTag(tag);
|
||||
const {
|
||||
object: { sha },
|
||||
} = await github("GET /repos/{owner}/{repo}/git/ref/{ref}", {
|
||||
ref: ref === "canary" ? "heads/main" : `tags/${ref}`,
|
||||
});
|
||||
return format === "short" ? sha.substring(0, 7) : sha;
|
||||
}
|
||||
|
||||
export async function getBuild(): Promise<number> {
|
||||
const date = new Date().toISOString().split("T")[0].replace(/-/g, "");
|
||||
const response = await fetch("https://registry.npmjs.org/-/package/bun/dist-tags");
|
||||
const { canary }: { canary: string } = await response.json();
|
||||
if (!canary.includes(date)) {
|
||||
return 1;
|
||||
}
|
||||
const match = /canary.[0-9]{8}\.([0-9]+)+?/.exec(canary);
|
||||
return match ? 1 + parseInt(match[1]) : 1;
|
||||
}
|
||||
|
||||
export async function getSemver(tag?: string, build?: number): Promise<string> {
|
||||
const { tag_name } = await getRelease(tag);
|
||||
if (tag_name !== "canary") {
|
||||
return tag_name.replace("bun-v", "");
|
||||
}
|
||||
if (build === undefined) {
|
||||
build = await getBuild();
|
||||
}
|
||||
const sha = await getSha(tag_name, "short");
|
||||
const date = new Date().toISOString().split("T")[0].replace(/-/g, "");
|
||||
return `${Bun.version}-canary.${date}.${build}+${sha}`;
|
||||
}
|
||||
|
||||
export function formatTag(tag: string): string {
|
||||
if (tag === "canary" || tag.startsWith("bun-v")) {
|
||||
return tag;
|
||||
}
|
||||
if (tag.startsWith("v")) {
|
||||
return tag.slice(1);
|
||||
}
|
||||
return `bun-v${tag}`;
|
||||
}
|
||||
144
packages/bun-release/src/npm/install.ts
Normal file
144
packages/bun-release/src/npm/install.ts
Normal file
@@ -0,0 +1,144 @@
|
||||
import { fetch } from "../fetch";
|
||||
import { spawn } from "../spawn";
|
||||
import { chmod, join, rename, rm, tmp, write } from "../fs";
|
||||
import { unzipSync } from "zlib";
|
||||
import type { Platform } from "../platform";
|
||||
import { os, arch, supportedPlatforms } from "../platform";
|
||||
import { debug, error } from "../console";
|
||||
|
||||
declare const version: string;
|
||||
declare const module: string;
|
||||
declare const owner: string;
|
||||
|
||||
export async function importBun(): Promise<string> {
|
||||
if (!supportedPlatforms.length) {
|
||||
throw new Error(`Unsupported platform: ${os} ${arch}`);
|
||||
}
|
||||
for (const platform of supportedPlatforms) {
|
||||
try {
|
||||
return await requireBun(platform);
|
||||
} catch (error) {
|
||||
debug("requireBun failed", error);
|
||||
}
|
||||
}
|
||||
throw new Error(`Failed to install package "${module}"`);
|
||||
}
|
||||
|
||||
async function requireBun(platform: Platform): Promise<string> {
|
||||
const module = `${owner}/${platform.bin}`;
|
||||
function resolveBun() {
|
||||
const exe = require.resolve(join(module, platform.exe));
|
||||
const { exitCode, stderr, stdout } = spawn(exe, ["--version"]);
|
||||
if (exitCode === 0) {
|
||||
return exe;
|
||||
}
|
||||
throw new Error(stderr || stdout);
|
||||
}
|
||||
try {
|
||||
return resolveBun();
|
||||
} catch (cause) {
|
||||
debug("resolveBun failed", cause);
|
||||
error(
|
||||
`Failed to find package "${module}".`,
|
||||
`You may have used the "--no-optional" flag when running "npm install".`,
|
||||
);
|
||||
}
|
||||
const cwd = join("node_modules", module);
|
||||
try {
|
||||
installBun(platform, cwd);
|
||||
} catch (cause) {
|
||||
debug("installBun failed", cause);
|
||||
error(`Failed to install package "${module}" using "npm install".`, cause);
|
||||
try {
|
||||
await downloadBun(platform, cwd);
|
||||
} catch (cause) {
|
||||
debug("downloadBun failed", cause);
|
||||
error(`Failed to download package "${module}" from "registry.npmjs.org".`, cause);
|
||||
}
|
||||
}
|
||||
return resolveBun();
|
||||
}
|
||||
|
||||
function installBun(platform: Platform, dst: string): void {
|
||||
const module = `${owner}/${platform.bin}`;
|
||||
const cwd = tmp();
|
||||
try {
|
||||
write(join(cwd, "package.json"), "{}");
|
||||
const { exitCode } = spawn(
|
||||
"npm",
|
||||
["install", "--loglevel=error", "--prefer-offline", "--no-audit", "--progress=false", `${module}@${version}`],
|
||||
{
|
||||
cwd,
|
||||
stdio: "pipe",
|
||||
env: {
|
||||
...process.env,
|
||||
npm_config_global: undefined,
|
||||
},
|
||||
},
|
||||
);
|
||||
if (exitCode === 0) {
|
||||
rename(join(cwd, "node_modules", module), dst);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
rm(cwd);
|
||||
} catch (error) {
|
||||
debug("rm failed", error);
|
||||
// There is nothing to do if the directory cannot be cleaned up.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadBun(platform: Platform, dst: string): Promise<void> {
|
||||
const response = await fetch(`https://registry.npmjs.org/${owner}/${platform.bin}/-/${platform.bin}-${version}.tgz`);
|
||||
const tgz = await response.arrayBuffer();
|
||||
let buffer: Buffer;
|
||||
try {
|
||||
buffer = unzipSync(tgz);
|
||||
} catch (cause) {
|
||||
throw new Error("Invalid gzip data", { cause });
|
||||
}
|
||||
function str(i: number, n: number): string {
|
||||
return String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
|
||||
}
|
||||
let offset = 0;
|
||||
while (offset < buffer.length) {
|
||||
const name = str(offset, 100).replace("package/", "");
|
||||
const size = parseInt(str(offset + 124, 12), 8);
|
||||
offset += 512;
|
||||
if (!isNaN(size)) {
|
||||
write(join(dst, name), buffer.subarray(offset, offset + size));
|
||||
if (name === platform.exe) {
|
||||
try {
|
||||
chmod(join(dst, name), 0o755);
|
||||
} catch (error) {
|
||||
debug("chmod failed", error);
|
||||
}
|
||||
}
|
||||
offset += (size + 511) & ~511;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function optimizeBun(path: string): void {
|
||||
if (os === "win32") {
|
||||
throw new Error(
|
||||
"You must use Windows Subsystem for Linux, aka. WSL, to run bun. Learn more: https://learn.microsoft.com/en-us/windows/wsl/install",
|
||||
);
|
||||
}
|
||||
const { npm_config_user_agent } = process.env;
|
||||
if (npm_config_user_agent && /\byarn\//.test(npm_config_user_agent)) {
|
||||
throw new Error(
|
||||
"Yarn does not support bun, because it does not allow linking to binaries. To use bun, install using the following command: curl -fsSL https://bun.sh/install | bash",
|
||||
);
|
||||
}
|
||||
try {
|
||||
rename(path, join(__dirname, "bin", "bun"));
|
||||
return;
|
||||
} catch (error) {
|
||||
debug("optimizeBun failed", error);
|
||||
}
|
||||
throw new Error(
|
||||
"Your package manager doesn't seem to support bun. To use bun, install using the following command: curl -fsSL https://bun.sh/install | bash",
|
||||
);
|
||||
}
|
||||
91
packages/bun-release/src/platform.ts
Normal file
91
packages/bun-release/src/platform.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
import { spawn } from "./spawn";
|
||||
import { read } from "./fs";
|
||||
import { debug } from "./console";
|
||||
|
||||
export const os = process.platform;
|
||||
|
||||
export const arch = os === "darwin" && process.arch === "x64" && isRosetta2() ? "arm64" : process.arch;
|
||||
|
||||
export const avx2 = (arch === "x64" && os === "linux" && isLinuxAVX2()) || (os === "darwin" && isDarwinAVX2());
|
||||
|
||||
export type Platform = {
|
||||
os: string;
|
||||
arch: string;
|
||||
avx2?: boolean;
|
||||
bin: string;
|
||||
exe: string;
|
||||
};
|
||||
|
||||
export const platforms: Platform[] = [
|
||||
{
|
||||
os: "darwin",
|
||||
arch: "arm64",
|
||||
bin: "bun-darwin-aarch64",
|
||||
exe: "bin/bun",
|
||||
},
|
||||
{
|
||||
os: "darwin",
|
||||
arch: "x64",
|
||||
avx2: true,
|
||||
bin: "bun-darwin-x64",
|
||||
exe: "bin/bun",
|
||||
},
|
||||
{
|
||||
os: "darwin",
|
||||
arch: "x64",
|
||||
bin: "bun-darwin-x64-baseline",
|
||||
exe: "bin/bun",
|
||||
},
|
||||
{
|
||||
os: "linux",
|
||||
arch: "arm64",
|
||||
bin: "bun-linux-aarch64",
|
||||
exe: "bin/bun",
|
||||
},
|
||||
{
|
||||
os: "linux",
|
||||
arch: "x64",
|
||||
avx2: true,
|
||||
bin: "bun-linux-x64",
|
||||
exe: "bin/bun",
|
||||
},
|
||||
{
|
||||
os: "linux",
|
||||
arch: "x64",
|
||||
bin: "bun-linux-x64-baseline",
|
||||
exe: "bin/bun",
|
||||
},
|
||||
];
|
||||
|
||||
export const supportedPlatforms: Platform[] = platforms
|
||||
.filter(platform => platform.os === os && platform.arch === arch && (!platform.avx2 || avx2))
|
||||
.sort((a, b) => (a.avx2 === b.avx2 ? 0 : a.avx2 ? -1 : 1));
|
||||
|
||||
function isLinuxAVX2(): boolean {
|
||||
try {
|
||||
return read("/proc/cpuinfo").includes("avx2");
|
||||
} catch (error) {
|
||||
debug("isLinuxAVX2 failed", error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isDarwinAVX2(): boolean {
|
||||
try {
|
||||
const { exitCode, stdout } = spawn("sysctl", ["-n", "machdep.cpu"]);
|
||||
return exitCode === 0 && stdout.includes("AVX2");
|
||||
} catch (error) {
|
||||
debug("isDarwinAVX2 failed", error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isRosetta2(): boolean {
|
||||
try {
|
||||
const { exitCode, stdout } = spawn("sysctl", ["-n", "sysctl.proc_translated"]);
|
||||
return exitCode === 0 && stdout.includes("1");
|
||||
} catch (error) {
|
||||
debug("isRosetta2 failed", error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
24
packages/bun-release/src/spawn.ts
Normal file
24
packages/bun-release/src/spawn.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import child_process from "child_process";
|
||||
import { debug } from "./console";
|
||||
|
||||
export function spawn(
|
||||
cmd: string,
|
||||
args: string[],
|
||||
options: child_process.SpawnOptions = {},
|
||||
): {
|
||||
exitCode: number;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
} {
|
||||
debug("spawn", [cmd, ...args].join(" "));
|
||||
const { status, stdout, stderr } = child_process.spawnSync(cmd, args, {
|
||||
stdio: "pipe",
|
||||
encoding: "utf-8",
|
||||
...options,
|
||||
});
|
||||
return {
|
||||
exitCode: status ?? 1,
|
||||
stdout,
|
||||
stderr,
|
||||
};
|
||||
}
|
||||
17
packages/bun-release/tsconfig.json
Normal file
17
packages/bun-release/tsconfig.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["ESNext"],
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"types": ["bun-types"],
|
||||
"esModuleInterop": true,
|
||||
"allowJs": true,
|
||||
"strict": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": [
|
||||
"src",
|
||||
"scripts"
|
||||
]
|
||||
}
|
||||
3
packages/bun-test/.gitignore
vendored
Normal file
3
packages/bun-test/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.DS_Store
|
||||
.env
|
||||
node_modules
|
||||
3
packages/bun-test/README.md
Normal file
3
packages/bun-test/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# bun-test
|
||||
|
||||
Scripts to run Bun's tests using `bun wiptest`.
|
||||
BIN
packages/bun-test/bun.lockb
Executable file
BIN
packages/bun-test/bun.lockb
Executable file
Binary file not shown.
13
packages/bun-test/package.json
Normal file
13
packages/bun-test/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bun-types": "canary",
|
||||
"prettier": "^2.8.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "bun run src/runner.ts"
|
||||
}
|
||||
}
|
||||
86
packages/bun-test/src/runner.ts
Normal file
86
packages/bun-test/src/runner.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
import { spawn } from "bun";
|
||||
import { readdirSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import * as action from "@actions/core";
|
||||
|
||||
const cwd = resolve("../..");
|
||||
const isAction = !!process.env["GITHUB_ACTION"];
|
||||
const errorPattern = /error: ([\S\s]*?)(?=\n.*?at (\/.*):(\d+):(\d+))/mgi;
|
||||
|
||||
function* findTests(dir: string, query?: string): Generator<string> {
|
||||
for (const entry of readdirSync(resolve(dir), { encoding: "utf-8", withFileTypes: true })) {
|
||||
const path = resolve(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
yield* findTests(path, query);
|
||||
} else if (entry.isFile() && entry.name.includes(".test.")) {
|
||||
yield path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function runTest(path: string): Promise<void> {
|
||||
const name = path.replace(cwd, "").slice(1);
|
||||
const runner = await spawn({
|
||||
cwd,
|
||||
cmd: ["bun", "wiptest", path],
|
||||
stdout: "pipe",
|
||||
stderr: "pipe",
|
||||
});
|
||||
const exitCode = await Promise.race([
|
||||
new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
runner.kill();
|
||||
resolve(124); // Timed Out
|
||||
}, 60_000);
|
||||
}),
|
||||
runner.exited,
|
||||
]);
|
||||
if (isAction) {
|
||||
const prefix = exitCode === 0
|
||||
? "PASS"
|
||||
: `FAIL (exit code ${exitCode})`;
|
||||
action.startGroup(`${prefix} - ${name}`);
|
||||
}
|
||||
for (const stdout of [runner.stdout, runner.stderr]) {
|
||||
if (!stdout) {
|
||||
continue;
|
||||
}
|
||||
const reader = stdout.getReader();
|
||||
while (true) {
|
||||
const { value, done } = await reader.read();
|
||||
if (value) {
|
||||
console.write(value);
|
||||
if (isAction) {
|
||||
findErrors(value);
|
||||
}
|
||||
}
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isAction) {
|
||||
action.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
let failed = false;
|
||||
|
||||
function findErrors(data: Uint8Array): void {
|
||||
const text = new TextDecoder().decode(data);
|
||||
for (const [message, _, path, line, col] of text.matchAll(errorPattern)) {
|
||||
failed = true;
|
||||
action.error(message, {
|
||||
file: path.replace(cwd, "").slice(1),
|
||||
startLine: parseInt(line),
|
||||
startColumn: parseInt(col),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const tests = [];
|
||||
for (const path of findTests(resolve(cwd, "test/bun.js"))) {
|
||||
tests.push(runTest(path).catch(console.error));
|
||||
}
|
||||
await Promise.allSettled(tests);
|
||||
process.exit(failed ? 1 : 0);
|
||||
16
packages/bun-test/tsconfig.json
Normal file
16
packages/bun-test/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["ESNext"],
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"types": ["bun-types"],
|
||||
"esModuleInterop": true,
|
||||
"allowJs": true,
|
||||
"strict": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
6
packages/bun-types/.prettierrc
Normal file
6
packages/bun-types/.prettierrc
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"arrowParens": "avoid",
|
||||
"printWidth": 80,
|
||||
"trailingComma": "all",
|
||||
"useTabs": false
|
||||
}
|
||||
@@ -22,10 +22,10 @@ Add this to your `tsconfig.json` or `jsconfig.json`:
|
||||
```jsonc
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["esnext"],
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"lib": ["ESNext"],
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
// "bun-types" is the important part
|
||||
"types": ["bun-types"]
|
||||
}
|
||||
|
||||
100
packages/bun-types/bun.d.ts
vendored
100
packages/bun-types/bun.d.ts
vendored
@@ -411,22 +411,22 @@ declare module "bun" {
|
||||
* ## Example
|
||||
*
|
||||
* ```js
|
||||
* const {address} = await Bun.dns.lookup('example.com');
|
||||
* const [{ address }] = await Bun.dns.lookup('example.com');
|
||||
* ```
|
||||
*
|
||||
* ### Filter results to IPv4:
|
||||
*
|
||||
* ```js
|
||||
* import {dns} from 'bun';
|
||||
* const {address} = await dns.lookup('example.com', {family: 4});
|
||||
* import { dns } from 'bun';
|
||||
* const [{ address }] = await dns.lookup('example.com', {family: 4});
|
||||
* console.log(address); // "123.122.22.126"
|
||||
* ```
|
||||
*
|
||||
* ### Filter results to IPv6:
|
||||
*
|
||||
* ```js
|
||||
* import {dns} from 'bun';
|
||||
* const {address} = await dns.lookup('example.com', {family: 6});
|
||||
* import { dns } from 'bun';
|
||||
* const [{ address }] = await dns.lookup('example.com', {family: 6});
|
||||
* console.log(address); // "2001:db8::1"
|
||||
* ```
|
||||
*
|
||||
@@ -439,8 +439,8 @@ declare module "bun" {
|
||||
*
|
||||
* To customize the DNS resolver, pass a `backend` option to `dns.lookup`:
|
||||
* ```js
|
||||
* import {dns} from 'bun';
|
||||
* const {address} = await dns.lookup('example.com', {backend: 'getaddrinfo'});
|
||||
* import { dns } from 'bun';
|
||||
* const [{ address }] = await dns.lookup('example.com', {backend: 'getaddrinfo'});
|
||||
* console.log(address); // "19.42.52.62"
|
||||
* ```
|
||||
*/
|
||||
@@ -767,7 +767,7 @@ declare module "bun" {
|
||||
* const query = UserQuery;
|
||||
* ```
|
||||
*/
|
||||
macros?: MacroMap;
|
||||
macro?: MacroMap;
|
||||
|
||||
autoImportJSX?: boolean;
|
||||
allowBunRuntime?: boolean;
|
||||
@@ -1592,11 +1592,12 @@ declare module "bun" {
|
||||
/**
|
||||
* Stop listening to prevent new connections from being accepted.
|
||||
*
|
||||
* It does not close existing connections.
|
||||
* By default, it does not cancel in-flight requests or websockets. That means it may take some time before all network activity stops.
|
||||
*
|
||||
* It may take a second or two to actually stop.
|
||||
* @param closeActiveConnections Immediately terminate in-flight requests, websockets, and stop accepting new connections.
|
||||
* @default false
|
||||
*/
|
||||
stop(): void;
|
||||
stop(closeActiveConnections?: boolean): void;
|
||||
|
||||
/**
|
||||
* Update the `fetch` and `error` handlers without restarting the server.
|
||||
@@ -1784,7 +1785,7 @@ declare module "bun" {
|
||||
*
|
||||
*/
|
||||
// tslint:disable-next-line:unified-signatures
|
||||
export function file(path: string, options?: BlobPropertyBag): FileBlob;
|
||||
export function file(path: string | URL, options?: BlobPropertyBag): FileBlob;
|
||||
|
||||
/**
|
||||
* `Blob` that leverages the fastest system calls available to operate on files.
|
||||
@@ -2150,6 +2151,40 @@ declare module "bun" {
|
||||
static readonly algorithms: SupportedCryptoAlgorithms[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a `Promise` after milliseconds. This is like
|
||||
* {@link setTimeout} except it returns a `Promise`.
|
||||
*
|
||||
* @param ms milliseconds to delay resolving the promise. This is a minimum
|
||||
* number. It may take longer. If a {@link Date} is passed, it will sleep until the
|
||||
* {@link Date} is reached.
|
||||
*
|
||||
* @example
|
||||
* ## Sleep for 1 second
|
||||
* ```ts
|
||||
* import { sleep } from "bun";
|
||||
*
|
||||
* await sleep(1000);
|
||||
* ```
|
||||
* ## Sleep for 10 milliseconds
|
||||
* ```ts
|
||||
* await Bun.sleep(10);
|
||||
* ```
|
||||
* ## Sleep until `Date`
|
||||
*
|
||||
* ```ts
|
||||
* const target = new Date();
|
||||
* target.setSeconds(target.getSeconds() + 1);
|
||||
* await Bun.sleep(target);
|
||||
* ```
|
||||
* Internally, `Bun.sleep` is the equivalent of
|
||||
* ```ts
|
||||
* await new Promise((resolve) => setTimeout(resolve, ms));
|
||||
* ```
|
||||
* As always, you can use `Bun.sleep` or the imported `sleep` function interchangeably.
|
||||
*/
|
||||
export function sleep(ms: number | Date): Promise<void>;
|
||||
|
||||
/**
|
||||
* Sleep the thread for a given number of milliseconds
|
||||
*
|
||||
@@ -2741,7 +2776,7 @@ declare module "bun" {
|
||||
}
|
||||
|
||||
interface SocketListener<Options extends SocketOptions = SocketOptions> {
|
||||
stop(): void;
|
||||
stop(closeActiveConnections?: boolean): void;
|
||||
ref(): void;
|
||||
unref(): void;
|
||||
reload(options: Pick<Partial<Options>, "socket">): void;
|
||||
@@ -2760,11 +2795,26 @@ declare module "bun" {
|
||||
interface TCPSocket extends Socket {}
|
||||
interface TLSSocket extends Socket {}
|
||||
|
||||
interface SocketHandler<Data = unknown> {
|
||||
type BinaryTypeList = {
|
||||
arraybuffer: ArrayBuffer;
|
||||
buffer: Buffer;
|
||||
uint8array: Uint8Array;
|
||||
// TODO: DataView
|
||||
// dataview: DataView;
|
||||
};
|
||||
type BinaryType = keyof BinaryTypeList;
|
||||
|
||||
interface SocketHandler<
|
||||
Data = unknown,
|
||||
DataBinaryType extends BinaryType = "buffer",
|
||||
> {
|
||||
open(socket: Socket<Data>): void | Promise<void>;
|
||||
close?(socket: Socket<Data>): void | Promise<void>;
|
||||
error?(socket: Socket<Data>, error: Error): void | Promise<void>;
|
||||
data?(socket: Socket<Data>, data: BufferSource): void | Promise<void>;
|
||||
data?(
|
||||
socket: Socket<Data>,
|
||||
data: BinaryTypeList[DataBinaryType],
|
||||
): void | Promise<void>;
|
||||
drain?(socket: Socket<Data>): void | Promise<void>;
|
||||
|
||||
/**
|
||||
@@ -2786,7 +2836,24 @@ declare module "bun" {
|
||||
* When `connectError` is not specified, the rejected promise will be added
|
||||
* to the promise rejection queue.
|
||||
*/
|
||||
connectError?(error: Error): void | Promise<void>;
|
||||
connectError?(socket: Socket<Data>, error: Error): void | Promise<void>;
|
||||
|
||||
/**
|
||||
* Choose what `ArrayBufferView` is returned in the {@link SocketHandler.data} callback.
|
||||
*
|
||||
* @default "buffer"
|
||||
*
|
||||
* @remarks
|
||||
* This lets you select the desired binary type for the `data` callback.
|
||||
* It's a small performance optimization to let you avoid creating extra
|
||||
* ArrayBufferView objects when possible.
|
||||
*
|
||||
* Bun originally defaulted to `Uint8Array` but when dealing with network
|
||||
* data, it's more useful to be able to directly read from the bytes which
|
||||
* `Buffer` allows.
|
||||
*
|
||||
*/
|
||||
binaryType?: BinaryType;
|
||||
}
|
||||
|
||||
interface SocketOptions<Data = unknown> {
|
||||
@@ -3082,6 +3149,7 @@ declare module "bun" {
|
||||
* ```
|
||||
*/
|
||||
readonly params: Record<string, string>;
|
||||
readonly filePath: string;
|
||||
readonly pathname: string;
|
||||
readonly query: Record<string, string>;
|
||||
readonly name: string;
|
||||
|
||||
Binary file not shown.
148
packages/bun-types/console.d.ts
vendored
Normal file
148
packages/bun-types/console.d.ts
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* The `console` module provides a simple debugging console that is similar to the
|
||||
* JavaScript console mechanism provided by web browsers.
|
||||
*
|
||||
* The module exports two specific components:
|
||||
*
|
||||
* * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
|
||||
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
|
||||
*
|
||||
* _**Warning**_: The global console object's methods are neither consistently
|
||||
* synchronous like the browser APIs they resemble, nor are they consistently
|
||||
* asynchronous like all other Node.js streams. See the `note on process I/O` for
|
||||
* more information.
|
||||
*
|
||||
* Example using the global `console`:
|
||||
*
|
||||
* ```js
|
||||
* console.log('hello world');
|
||||
* // Prints: hello world, to stdout
|
||||
* console.log('hello %s', 'world');
|
||||
* // Prints: hello world, to stdout
|
||||
* console.error(new Error('Whoops, something bad happened'));
|
||||
* // Prints error message and stack trace to stderr:
|
||||
* // Error: Whoops, something bad happened
|
||||
* // at [eval]:5:15
|
||||
* // at Script.runInThisContext (node:vm:132:18)
|
||||
* // at Object.runInThisContext (node:vm:309:38)
|
||||
* // at node:internal/process/execution:77:19
|
||||
* // at [eval]-wrapper:6:22
|
||||
* // at evalScript (node:internal/process/execution:76:60)
|
||||
* // at node:internal/main/eval_string:23:3
|
||||
*
|
||||
* const name = 'Will Robinson';
|
||||
* console.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to stderr
|
||||
* ```
|
||||
*
|
||||
* Example using the `Console` class:
|
||||
*
|
||||
* ```js
|
||||
* const out = getStreamSomehow();
|
||||
* const err = getStreamSomehow();
|
||||
* const myConsole = new console.Console(out, err);
|
||||
*
|
||||
* myConsole.log('hello world');
|
||||
* // Prints: hello world, to out
|
||||
* myConsole.log('hello %s', 'world');
|
||||
* // Prints: hello world, to out
|
||||
* myConsole.error(new Error('Whoops, something bad happened'));
|
||||
* // Prints: [Error: Whoops, something bad happened], to err
|
||||
*
|
||||
* const name = 'Will Robinson';
|
||||
* myConsole.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to err
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/console.js)
|
||||
*/
|
||||
declare module "console" {
|
||||
import console = require("node:console");
|
||||
export = console;
|
||||
}
|
||||
declare module "node:console" {
|
||||
// import { InspectOptions } from "node:util";
|
||||
// global {
|
||||
|
||||
/**
|
||||
* The `console` module provides a simple debugging console that is similar to the
|
||||
* JavaScript console mechanism provided by web browsers.
|
||||
*
|
||||
* The module exports two specific components:
|
||||
*
|
||||
* * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
|
||||
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
|
||||
*
|
||||
* _**Warning**_: The global console object's methods are neither consistently
|
||||
* synchronous like the browser APIs they resemble, nor are they consistently
|
||||
* asynchronous like all other Node.js streams. See the `note on process I/O` for
|
||||
* more information.
|
||||
*
|
||||
* Example using the global `console`:
|
||||
*
|
||||
* ```js
|
||||
* console.log('hello world');
|
||||
* // Prints: hello world, to stdout
|
||||
* console.log('hello %s', 'world');
|
||||
* // Prints: hello world, to stdout
|
||||
* console.error(new Error('Whoops, something bad happened'));
|
||||
* // Prints error message and stack trace to stderr:
|
||||
* // Error: Whoops, something bad happened
|
||||
* // at [eval]:5:15
|
||||
* // at Script.runInThisContext (node:vm:132:18)
|
||||
* // at Object.runInThisContext (node:vm:309:38)
|
||||
* // at node:internal/process/execution:77:19
|
||||
* // at [eval]-wrapper:6:22
|
||||
* // at evalScript (node:internal/process/execution:76:60)
|
||||
* // at node:internal/main/eval_string:23:3
|
||||
*
|
||||
* const name = 'Will Robinson';
|
||||
* console.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to stderr
|
||||
* ```
|
||||
*
|
||||
* Example using the `Console` class:
|
||||
*
|
||||
* ```js
|
||||
* const out = getStreamSomehow();
|
||||
* const err = getStreamSomehow();
|
||||
* const myConsole = new console.Console(out, err);
|
||||
*
|
||||
* myConsole.log('hello world');
|
||||
* // Prints: hello world, to out
|
||||
* myConsole.log('hello %s', 'world');
|
||||
* // Prints: hello world, to out
|
||||
* myConsole.error(new Error('Whoops, something bad happened'));
|
||||
* // Prints: [Error: Whoops, something bad happened], to err
|
||||
*
|
||||
* const name = 'Will Robinson';
|
||||
* myConsole.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to err
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/console.js)
|
||||
*/
|
||||
// import {Writable} from "node:stream";
|
||||
// namespace console {
|
||||
// interface ConsoleConstructorOptions {
|
||||
// stdout: Writable;
|
||||
// stderr?: Writable | undefined;
|
||||
// ignoreErrors?: boolean | undefined;
|
||||
// colorMode?: boolean | "auto" | undefined;
|
||||
// inspectOptions?: InspectOptions | undefined;
|
||||
// /**
|
||||
// * Set group indentation
|
||||
// * @default 2
|
||||
// */
|
||||
// groupIndentation?: number | undefined;
|
||||
// }
|
||||
// interface ConsoleConstructor {
|
||||
// prototype: Console;
|
||||
// new (stdout: Writable, stderr?: Writable, ignoreErrors?: boolean): Console;
|
||||
// new (options: ConsoleConstructorOptions): Console;
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
// const console: Console;
|
||||
|
||||
export = console;
|
||||
}
|
||||
369
packages/bun-types/dns.d.ts
vendored
369
packages/bun-types/dns.d.ts
vendored
@@ -318,127 +318,112 @@ declare module "dns" {
|
||||
hostname: string,
|
||||
callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
// export function resolve(
|
||||
// hostname: string,
|
||||
// rrtype: "A",
|
||||
// callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
// ): void;
|
||||
// export function resolve(
|
||||
// hostname: string,
|
||||
// rrtype: "AAAA",
|
||||
// callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
// ): void;
|
||||
// export function resolve(
|
||||
// hostname: string,
|
||||
// rrtype: "ANY",
|
||||
// callback: (
|
||||
// err: ErrnoException | null,
|
||||
// addresses: AnyRecord[],
|
||||
// ) => void,
|
||||
// ): void;
|
||||
// export function resolve(
|
||||
// hostname: string,
|
||||
// rrtype: "CNAME",
|
||||
// callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
// ): void;
|
||||
// export function resolve(
|
||||
// hostname: string,
|
||||
// rrtype: "MX",
|
||||
// callback: (
|
||||
// err: ErrnoException | null,
|
||||
// addresses: MxRecord[],
|
||||
// ) => void,
|
||||
// ): void;
|
||||
// export function resolve(
|
||||
// hostname: string,
|
||||
// rrtype: "NAPTR",
|
||||
// callback: (
|
||||
// err: ErrnoException | null,
|
||||
// addresses: NaptrRecord[],
|
||||
// ) => void,
|
||||
// ): void;
|
||||
// export function resolve(
|
||||
// hostname: string,
|
||||
// rrtype: "NS",
|
||||
// callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
// ): void;
|
||||
// export function resolve(
|
||||
// hostname: string,
|
||||
// rrtype: "PTR",
|
||||
// callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
// ): void;
|
||||
// export function resolve(
|
||||
// hostname: string,
|
||||
// rrtype: "SOA",
|
||||
// callback: (err: ErrnoException | null, addresses: SoaRecord) => void,
|
||||
// ): void;
|
||||
// export function resolve(
|
||||
// hostname: string,
|
||||
// rrtype: "SRV",
|
||||
// callback: (
|
||||
// err: ErrnoException | null,
|
||||
// addresses: SrvRecord[],
|
||||
// ) => void,
|
||||
// ): void;
|
||||
// export function resolve(
|
||||
// hostname: string,
|
||||
// rrtype: "TXT",
|
||||
// callback: (
|
||||
// err: ErrnoException | null,
|
||||
// addresses: string[][],
|
||||
// ) => void,
|
||||
// ): void;
|
||||
// export function resolve(
|
||||
// hostname: string,
|
||||
// rrtype: string,
|
||||
// callback: (
|
||||
// err: ErrnoException | null,
|
||||
// addresses:
|
||||
// | string[]
|
||||
// | MxRecord[]
|
||||
// | NaptrRecord[]
|
||||
// | SoaRecord
|
||||
// | SrvRecord[]
|
||||
// | string[][]
|
||||
// | AnyRecord[],
|
||||
// ) => void,
|
||||
// ): void;
|
||||
// export namespace resolve {
|
||||
// function __promisify__(
|
||||
// hostname: string,
|
||||
// rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR",
|
||||
// ): Promise<string[]>;
|
||||
// function __promisify__(
|
||||
// hostname: string,
|
||||
// rrtype: "ANY",
|
||||
// ): Promise<AnyRecord[]>;
|
||||
// function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
||||
// function __promisify__(
|
||||
// hostname: string,
|
||||
// rrtype: "NAPTR",
|
||||
// ): Promise<NaptrRecord[]>;
|
||||
// function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
||||
// function __promisify__(
|
||||
// hostname: string,
|
||||
// rrtype: "SRV",
|
||||
// ): Promise<SrvRecord[]>;
|
||||
// function __promisify__(
|
||||
// hostname: string,
|
||||
// rrtype: "TXT",
|
||||
// ): Promise<string[][]>;
|
||||
// function __promisify__(
|
||||
// hostname: string,
|
||||
// rrtype: string,
|
||||
// ): Promise<
|
||||
// | string[]
|
||||
// | MxRecord[]
|
||||
// | NaptrRecord[]
|
||||
// | SoaRecord
|
||||
// | SrvRecord[]
|
||||
// | string[][]
|
||||
// | AnyRecord[]
|
||||
// >;
|
||||
// }
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "A",
|
||||
callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "AAAA",
|
||||
callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "ANY",
|
||||
callback: (err: ErrnoException | null, addresses: AnyRecord[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "CNAME",
|
||||
callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "MX",
|
||||
callback: (err: ErrnoException | null, addresses: MxRecord[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "NAPTR",
|
||||
callback: (err: ErrnoException | null, addresses: NaptrRecord[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "NS",
|
||||
callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "PTR",
|
||||
callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "SOA",
|
||||
callback: (err: ErrnoException | null, addresses: SoaRecord) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "SRV",
|
||||
callback: (err: ErrnoException | null, addresses: SrvRecord[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "TXT",
|
||||
callback: (err: ErrnoException | null, addresses: string[][]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: string,
|
||||
callback: (
|
||||
err: ErrnoException | null,
|
||||
addresses:
|
||||
| string[]
|
||||
| MxRecord[]
|
||||
| NaptrRecord[]
|
||||
| SoaRecord
|
||||
| SrvRecord[]
|
||||
| string[][]
|
||||
| AnyRecord[],
|
||||
) => void,
|
||||
): void;
|
||||
export namespace resolve {
|
||||
function __promisify__(
|
||||
hostname: string,
|
||||
rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR",
|
||||
): Promise<string[]>;
|
||||
function __promisify__(
|
||||
hostname: string,
|
||||
rrtype: "ANY",
|
||||
): Promise<AnyRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
||||
function __promisify__(
|
||||
hostname: string,
|
||||
rrtype: "NAPTR",
|
||||
): Promise<NaptrRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
||||
function __promisify__(
|
||||
hostname: string,
|
||||
rrtype: "SRV",
|
||||
): Promise<SrvRecord[]>;
|
||||
function __promisify__(
|
||||
hostname: string,
|
||||
rrtype: "TXT",
|
||||
): Promise<string[][]>;
|
||||
function __promisify__(
|
||||
hostname: string,
|
||||
rrtype: string,
|
||||
): Promise<
|
||||
| string[]
|
||||
| MxRecord[]
|
||||
| NaptrRecord[]
|
||||
| SoaRecord
|
||||
| SrvRecord[]
|
||||
| string[][]
|
||||
| AnyRecord[]
|
||||
>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
||||
* will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
||||
@@ -512,38 +497,38 @@ declare module "dns" {
|
||||
* will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`).
|
||||
* @since v0.3.2
|
||||
*/
|
||||
// export function resolveCname(
|
||||
// hostname: string,
|
||||
// callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
// ): void;
|
||||
// export namespace resolveCname {
|
||||
// function __promisify__(hostname: string): Promise<string[]>;
|
||||
// }
|
||||
export function resolveCname(
|
||||
hostname: string,
|
||||
callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export namespace resolveCname {
|
||||
function __promisify__(hostname: string): Promise<string[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. The`addresses` argument passed to the `callback` function
|
||||
* will contain an array of certification authority authorization records
|
||||
* available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`).
|
||||
* @since v15.0.0, v14.17.0
|
||||
*/
|
||||
// export function resolveCaa(
|
||||
// hostname: string,
|
||||
// callback: (err: ErrnoException | null, records: CaaRecord[]) => void,
|
||||
// ): void;
|
||||
// export namespace resolveCaa {
|
||||
// function __promisify__(hostname: string): Promise<CaaRecord[]>;
|
||||
// }
|
||||
export function resolveCaa(
|
||||
hostname: string,
|
||||
callback: (err: ErrnoException | null, records: CaaRecord[]) => void,
|
||||
): void;
|
||||
export namespace resolveCaa {
|
||||
function __promisify__(hostname: string): Promise<CaaRecord[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* contain an array of objects containing both a `priority` and `exchange`property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
|
||||
* @since v0.1.27
|
||||
*/
|
||||
// export function resolveMx(
|
||||
// hostname: string,
|
||||
// callback: (err: ErrnoException | null, addresses: MxRecord[]) => void,
|
||||
// ): void;
|
||||
// export namespace resolveMx {
|
||||
// function __promisify__(hostname: string): Promise<MxRecord[]>;
|
||||
// }
|
||||
export function resolveMx(
|
||||
hostname: string,
|
||||
callback: (err: ErrnoException | null, addresses: MxRecord[]) => void,
|
||||
): void;
|
||||
export namespace resolveMx {
|
||||
function __promisify__(hostname: string): Promise<MxRecord[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of
|
||||
* objects with the following properties:
|
||||
@@ -567,37 +552,37 @@ declare module "dns" {
|
||||
* ```
|
||||
* @since v0.9.12
|
||||
*/
|
||||
// export function resolveNaptr(
|
||||
// hostname: string,
|
||||
// callback: (err: ErrnoException | null, addresses: NaptrRecord[]) => void,
|
||||
// ): void;
|
||||
// export namespace resolveNaptr {
|
||||
// function __promisify__(hostname: string): Promise<NaptrRecord[]>;
|
||||
// }
|
||||
export function resolveNaptr(
|
||||
hostname: string,
|
||||
callback: (err: ErrnoException | null, addresses: NaptrRecord[]) => void,
|
||||
): void;
|
||||
export namespace resolveNaptr {
|
||||
function __promisify__(hostname: string): Promise<NaptrRecord[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`).
|
||||
* @since v0.1.90
|
||||
*/
|
||||
// export function resolveNs(
|
||||
// hostname: string,
|
||||
// callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
// ): void;
|
||||
// export namespace resolveNs {
|
||||
// function __promisify__(hostname: string): Promise<string[]>;
|
||||
// }
|
||||
export function resolveNs(
|
||||
hostname: string,
|
||||
callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export namespace resolveNs {
|
||||
function __promisify__(hostname: string): Promise<string[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* be an array of strings containing the reply records.
|
||||
* @since v6.0.0
|
||||
*/
|
||||
// export function resolvePtr(
|
||||
// hostname: string,
|
||||
// callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
// ): void;
|
||||
// export namespace resolvePtr {
|
||||
// function __promisify__(hostname: string): Promise<string[]>;
|
||||
// }
|
||||
export function resolvePtr(
|
||||
hostname: string,
|
||||
callback: (err: ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export namespace resolvePtr {
|
||||
function __promisify__(hostname: string): Promise<string[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
||||
* the `hostname`. The `address` argument passed to the `callback` function will
|
||||
@@ -624,13 +609,13 @@ declare module "dns" {
|
||||
* ```
|
||||
* @since v0.11.10
|
||||
*/
|
||||
// export function resolveSoa(
|
||||
// hostname: string,
|
||||
// callback: (err: ErrnoException | null, address: SoaRecord) => void,
|
||||
// ): void;
|
||||
// export namespace resolveSoa {
|
||||
// function __promisify__(hostname: string): Promise<SoaRecord>;
|
||||
// }
|
||||
export function resolveSoa(
|
||||
hostname: string,
|
||||
callback: (err: ErrnoException | null, address: SoaRecord) => void,
|
||||
): void;
|
||||
export namespace resolveSoa {
|
||||
function __promisify__(hostname: string): Promise<SoaRecord>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* be an array of objects with the following properties:
|
||||
@@ -650,13 +635,13 @@ declare module "dns" {
|
||||
* ```
|
||||
* @since v0.1.27
|
||||
*/
|
||||
// export function resolveSrv(
|
||||
// hostname: string,
|
||||
// callback: (err: ErrnoException | null, addresses: SrvRecord[]) => void,
|
||||
// ): void;
|
||||
// export namespace resolveSrv {
|
||||
// function __promisify__(hostname: string): Promise<SrvRecord[]>;
|
||||
// }
|
||||
export function resolveSrv(
|
||||
hostname: string,
|
||||
callback: (err: ErrnoException | null, addresses: SrvRecord[]) => void,
|
||||
): void;
|
||||
export namespace resolveSrv {
|
||||
function __promisify__(hostname: string): Promise<SrvRecord[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. The `records` argument passed to the `callback` function is a
|
||||
* two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
||||
@@ -664,13 +649,13 @@ declare module "dns" {
|
||||
* treated separately.
|
||||
* @since v0.1.27
|
||||
*/
|
||||
// export function resolveTxt(
|
||||
// hostname: string,
|
||||
// callback: (err: ErrnoException | null, addresses: string[][]) => void,
|
||||
// ): void;
|
||||
// export namespace resolveTxt {
|
||||
// function __promisify__(hostname: string): Promise<string[][]>;
|
||||
// }
|
||||
export function resolveTxt(
|
||||
hostname: string,
|
||||
callback: (err: ErrnoException | null, addresses: string[][]) => void,
|
||||
): void;
|
||||
export namespace resolveTxt {
|
||||
function __promisify__(hostname: string): Promise<string[][]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
|
||||
* The `ret` argument passed to the `callback` function will be an array containing
|
||||
@@ -861,14 +846,14 @@ declare module "dns" {
|
||||
resolve4: typeof resolve4;
|
||||
resolve6: typeof resolve6;
|
||||
// resolveAny: typeof resolveAny;
|
||||
// resolveCname: typeof resolveCname;
|
||||
// resolveMx: typeof resolveMx;
|
||||
// resolveNaptr: typeof resolveNaptr;
|
||||
// resolveNs: typeof resolveNs;
|
||||
// resolvePtr: typeof resolvePtr;
|
||||
// resolveSoa: typeof resolveSoa;
|
||||
// resolveSrv: typeof resolveSrv;
|
||||
// resolveTxt: typeof resolveTxt;
|
||||
resolveCname: typeof resolveCname;
|
||||
resolveMx: typeof resolveMx;
|
||||
resolveNaptr: typeof resolveNaptr;
|
||||
resolveNs: typeof resolveNs;
|
||||
resolvePtr: typeof resolvePtr;
|
||||
resolveSoa: typeof resolveSoa;
|
||||
resolveSrv: typeof resolveSrv;
|
||||
resolveTxt: typeof resolveTxt;
|
||||
// reverse: typeof reverse;
|
||||
/**
|
||||
* The resolver instance will send its requests from the specified IP address.
|
||||
|
||||
94
packages/bun-types/dns/promises.d.ts
vendored
94
packages/bun-types/dns/promises.d.ts
vendored
@@ -10,12 +10,12 @@ declare module "dns/promises" {
|
||||
LookupOneOptions,
|
||||
LookupAllOptions,
|
||||
LookupOptions,
|
||||
// AnyRecord,
|
||||
// CaaRecord,
|
||||
// MxRecord,
|
||||
// NaptrRecord,
|
||||
// SoaRecord,
|
||||
// SrvRecord,
|
||||
AnyRecord,
|
||||
CaaRecord,
|
||||
MxRecord,
|
||||
NaptrRecord,
|
||||
SoaRecord,
|
||||
SrvRecord,
|
||||
ResolveWithTtlOptions,
|
||||
RecordWithTtl,
|
||||
ResolveOptions,
|
||||
@@ -134,30 +134,30 @@ declare module "dns/promises" {
|
||||
* @param [rrtype='A'] Resource record type.
|
||||
*/
|
||||
function resolve(hostname: string): Promise<string[]>;
|
||||
// function resolve(hostname: string, rrtype: "A"): Promise<string[]>;
|
||||
// function resolve(hostname: string, rrtype: "AAAA"): Promise<string[]>;
|
||||
// function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
||||
// function resolve(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>;
|
||||
// function resolve(hostname: string, rrtype: "CNAME"): Promise<string[]>;
|
||||
// function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
||||
// function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
||||
// function resolve(hostname: string, rrtype: "NS"): Promise<string[]>;
|
||||
// function resolve(hostname: string, rrtype: "PTR"): Promise<string[]>;
|
||||
// function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
||||
// function resolve(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
|
||||
// function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
||||
// function resolve(
|
||||
// hostname: string,
|
||||
// rrtype: string,
|
||||
// ): Promise<
|
||||
// | string[]
|
||||
// | MxRecord[]
|
||||
// | NaptrRecord[]
|
||||
// | SoaRecord
|
||||
// | SrvRecord[]
|
||||
// | string[][]
|
||||
// | AnyRecord[]
|
||||
// >;
|
||||
function resolve(hostname: string, rrtype: "A"): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: "AAAA"): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
||||
function resolve(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>;
|
||||
function resolve(hostname: string, rrtype: "CNAME"): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
||||
function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
||||
function resolve(hostname: string, rrtype: "NS"): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: "PTR"): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
||||
function resolveSrv(hostname: string): Promise<SrvRecord[]>;
|
||||
function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
||||
function resolve(
|
||||
hostname: string,
|
||||
rrtype: string,
|
||||
): Promise<
|
||||
| string[]
|
||||
| MxRecord[]
|
||||
| NaptrRecord[]
|
||||
| SoaRecord
|
||||
| SrvRecord[]
|
||||
| string[][]
|
||||
| AnyRecord[]
|
||||
>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv4
|
||||
* addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
||||
@@ -223,20 +223,20 @@ declare module "dns/promises" {
|
||||
* certification authority authorization records available for the `hostname`(e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]`).
|
||||
* @since v15.0.0, v14.17.0
|
||||
*/
|
||||
// function resolveCaa(hostname: string): Promise<CaaRecord[]>;
|
||||
function resolveCaa(hostname: string): Promise<CaaRecord[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. On success,
|
||||
* the `Promise` is resolved with an array of canonical name records available for
|
||||
* the `hostname` (e.g. `['bar.example.com']`).
|
||||
* @since v10.6.0
|
||||
*/
|
||||
// function resolveCname(hostname: string): Promise<string[]>;
|
||||
function resolveCname(hostname: string): Promise<string[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects
|
||||
* containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`).
|
||||
* @since v10.6.0
|
||||
*/
|
||||
// function resolveMx(hostname: string): Promise<MxRecord[]>;
|
||||
function resolveMx(hostname: string): Promise<MxRecord[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array
|
||||
* of objects with the following properties:
|
||||
@@ -260,19 +260,19 @@ declare module "dns/promises" {
|
||||
* ```
|
||||
* @since v10.6.0
|
||||
*/
|
||||
// function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
|
||||
function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. On success, the `Promise` is resolved with an array of name server
|
||||
* records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`).
|
||||
* @since v10.6.0
|
||||
*/
|
||||
// function resolveNs(hostname: string): Promise<string[]>;
|
||||
function resolveNs(hostname: string): Promise<string[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. On success, the `Promise` is resolved with an array of strings
|
||||
* containing the reply records.
|
||||
* @since v10.6.0
|
||||
*/
|
||||
// function resolvePtr(hostname: string): Promise<string[]>;
|
||||
function resolvePtr(hostname: string): Promise<string[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
||||
* the `hostname`. On success, the `Promise` is resolved with an object with the
|
||||
@@ -299,7 +299,7 @@ declare module "dns/promises" {
|
||||
* ```
|
||||
* @since v10.6.0
|
||||
*/
|
||||
// function resolveSoa(hostname: string): Promise<SoaRecord>;
|
||||
function resolveSoa(hostname: string): Promise<SoaRecord>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects with
|
||||
* the following properties:
|
||||
@@ -319,7 +319,7 @@ declare module "dns/promises" {
|
||||
* ```
|
||||
* @since v10.6.0
|
||||
*/
|
||||
// function resolveSrv(hostname: string): Promise<SrvRecord[]>;
|
||||
function resolveSrv(hostname: string): Promise<SrvRecord[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. On success, the `Promise` is resolved with a two-dimensional array
|
||||
* of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
||||
@@ -327,7 +327,7 @@ declare module "dns/promises" {
|
||||
* treated separately.
|
||||
* @since v10.6.0
|
||||
*/
|
||||
// function resolveTxt(hostname: string): Promise<string[][]>;
|
||||
function resolveTxt(hostname: string): Promise<string[][]>;
|
||||
/**
|
||||
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
||||
* array of host names.
|
||||
@@ -384,14 +384,14 @@ declare module "dns/promises" {
|
||||
resolve4: typeof resolve4;
|
||||
resolve6: typeof resolve6;
|
||||
// resolveAny: typeof resolveAny;
|
||||
// resolveCname: typeof resolveCname;
|
||||
// resolveMx: typeof resolveMx;
|
||||
// resolveNaptr: typeof resolveNaptr;
|
||||
// resolveNs: typeof resolveNs;
|
||||
// resolvePtr: typeof resolvePtr;
|
||||
// resolveSoa: typeof resolveSoa;
|
||||
// resolveSrv: typeof resolveSrv;
|
||||
// resolveTxt: typeof resolveTxt;
|
||||
resolveCname: typeof resolveCname;
|
||||
resolveMx: typeof resolveMx;
|
||||
resolveNaptr: typeof resolveNaptr;
|
||||
resolveNs: typeof resolveNs;
|
||||
resolvePtr: typeof resolvePtr;
|
||||
resolveSoa: typeof resolveSoa;
|
||||
resolveSrv: typeof resolveSrv;
|
||||
resolveTxt: typeof resolveTxt;
|
||||
// reverse: typeof reverse;
|
||||
// setLocalAddress(ipv4?: string, ipv6?: string): void;
|
||||
// setServers: typeof setServers;
|
||||
|
||||
7
packages/bun-types/fs/promises.d.ts
vendored
7
packages/bun-types/fs/promises.d.ts
vendored
@@ -24,6 +24,7 @@ declare module "fs/promises" {
|
||||
WriteFileOptions,
|
||||
SimlinkType,
|
||||
Abortable,
|
||||
RmOptions,
|
||||
} from "node:fs";
|
||||
|
||||
interface FlagAndOpenMode {
|
||||
@@ -670,6 +671,12 @@ declare module "fs/promises" {
|
||||
| BufferEncoding
|
||||
| null,
|
||||
): Promise<string | Buffer>;
|
||||
/**
|
||||
* Asynchronously removes files and directories (modeled on the standard POSIX `rm`utility). No arguments other than a possible exception are given to the
|
||||
* completion callback.
|
||||
* @since v14.14.0
|
||||
*/
|
||||
export function rm(path: PathLike, options?: RmOptions): Promise<void>;
|
||||
}
|
||||
|
||||
declare module "node:fs/promises" {
|
||||
|
||||
367
packages/bun-types/globals.d.ts
vendored
367
packages/bun-types/globals.d.ts
vendored
@@ -69,7 +69,7 @@ interface ArrayConstructor {
|
||||
asyncItems: AsyncIterable<T> | Iterable<T> | ArrayLike<T>,
|
||||
mapfn?: (value: any, index: number) => any,
|
||||
thisArg?: any,
|
||||
): Array<T>;
|
||||
): Promise<Array<T>>;
|
||||
}
|
||||
|
||||
interface Console {
|
||||
@@ -318,7 +318,9 @@ interface EncodeIntoResult {
|
||||
|
||||
interface Process {
|
||||
/**
|
||||
* The current version of Bun
|
||||
* A Node.js LTS version
|
||||
*
|
||||
* To see the current Bun version, use {@link Bun.version}
|
||||
*/
|
||||
version: string;
|
||||
/**
|
||||
@@ -342,7 +344,7 @@ interface Process {
|
||||
arch: Architecture;
|
||||
platform: Platform;
|
||||
argv: string[];
|
||||
// execArgv: string[];
|
||||
execArgv: string[];
|
||||
env: Bun.Env;
|
||||
|
||||
/** Whether you are using Bun */
|
||||
@@ -391,6 +393,10 @@ interface Process {
|
||||
* @returns Bun process's file mode creation mask.
|
||||
*/
|
||||
umask(mask?: number): number;
|
||||
|
||||
emitWarning(warning: string | Error /*name?: string, ctor?: Function*/): void;
|
||||
|
||||
readonly config: Object;
|
||||
}
|
||||
|
||||
declare var process: Process;
|
||||
@@ -408,6 +414,7 @@ interface BlobInterface {
|
||||
text(): Promise<string>;
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
json<TJSONReturnType = unknown>(): Promise<TJSONReturnType>;
|
||||
formData(): Promise<FormData>;
|
||||
}
|
||||
|
||||
type BlobPart = string | Blob | BufferSource | ArrayBuffer;
|
||||
@@ -495,6 +502,51 @@ type ResponseType =
|
||||
| "opaque"
|
||||
| "opaqueredirect";
|
||||
|
||||
type FormDataEntryValue = Blob | string;
|
||||
|
||||
/** Provides a way to easily construct a set of key/value pairs representing
|
||||
* form fields and their values, which can then be easily sent using the
|
||||
* XMLHttpRequest.send() method. It uses the same format a form would use if the
|
||||
* encoding type were set to "multipart/form-data".
|
||||
*/
|
||||
interface FormData {
|
||||
/**
|
||||
* Appends a new value onto an existing key inside a FormData object, or adds
|
||||
* the key if it does not already exist.
|
||||
*
|
||||
* @param name The name of the field whose data is contained in value.
|
||||
* @param value The field's value.
|
||||
* @param fileName The filename reported to the server.
|
||||
*
|
||||
* ## Upload a file
|
||||
* ```ts
|
||||
* const formData = new FormData();
|
||||
* formData.append("username", "abc123");
|
||||
* formData.append("avatar", Bun.file("avatar.png"), "avatar.png");
|
||||
* await fetch("https://example.com", { method: "POST", body: formData });
|
||||
* ```
|
||||
*/
|
||||
append(name: string, value: string | Blob, fileName?: string): void;
|
||||
delete(name: string): void;
|
||||
get(name: string): FormDataEntryValue | null;
|
||||
getAll(name: string): FormDataEntryValue[];
|
||||
has(name: string): boolean;
|
||||
set(name: string, value: string | Blob, fileName?: string): void;
|
||||
keys(): IterableIterator<string>;
|
||||
values(): IterableIterator<string>;
|
||||
entries(): IterableIterator<[string, FormDataEntryValue]>;
|
||||
[Symbol.iterator](): IterableIterator<[string, FormDataEntryValue]>;
|
||||
forEach(
|
||||
callback: (value: FormDataEntryValue, key: string, parent: this) => void,
|
||||
thisArg?: any,
|
||||
): void;
|
||||
}
|
||||
|
||||
declare var FormData: {
|
||||
prototype: FormData;
|
||||
new (): FormData;
|
||||
};
|
||||
|
||||
declare class Blob implements BlobInterface {
|
||||
/**
|
||||
* Create a new [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
|
||||
@@ -539,6 +591,20 @@ declare class Blob implements BlobInterface {
|
||||
*/
|
||||
json<TJSONReturnType = unknown>(): Promise<TJSONReturnType>;
|
||||
|
||||
/**
|
||||
* Read the data from the blob as a {@link FormData} object.
|
||||
*
|
||||
* This first decodes the data from UTF-8, then parses it as a
|
||||
* `multipart/form-data` body or a `application/x-www-form-urlencoded` body.
|
||||
*
|
||||
* The `type` property of the blob is used to determine the format of the
|
||||
* body.
|
||||
*
|
||||
* This is a non-standard addition to the `Blob` API, to make it conform more
|
||||
* closely to the `BodyMixin` API.
|
||||
*/
|
||||
formData(): Promise<FormData>;
|
||||
|
||||
type: string;
|
||||
size: number;
|
||||
}
|
||||
@@ -570,7 +636,7 @@ interface ResponseInit {
|
||||
*/
|
||||
declare class Response implements BlobInterface {
|
||||
constructor(
|
||||
body?: ReadableStream | BlobPart | BlobPart[] | null,
|
||||
body?: ReadableStream | BlobPart | BlobPart[] | null | FormData,
|
||||
options?: ResponseInit,
|
||||
);
|
||||
|
||||
@@ -685,6 +751,18 @@ declare class Response implements BlobInterface {
|
||||
*/
|
||||
blob(): Promise<Blob>;
|
||||
|
||||
/**
|
||||
* Read the data from the Response as a {@link FormData} object.
|
||||
*
|
||||
* This first decodes the data from UTF-8, then parses it as a
|
||||
* `multipart/form-data` body or a `application/x-www-form-urlencoded` body.
|
||||
*
|
||||
* If no `Content-Type` header is present, the promise will be rejected.
|
||||
*
|
||||
* @returns Promise<FormData> - The body of the response as a {@link FormData}.
|
||||
*/
|
||||
formData(): Promise<FormData>;
|
||||
|
||||
readonly ok: boolean;
|
||||
readonly redirected: boolean;
|
||||
/**
|
||||
@@ -746,10 +824,10 @@ type ReferrerPolicy =
|
||||
| "strict-origin"
|
||||
| "strict-origin-when-cross-origin"
|
||||
| "unsafe-url";
|
||||
type RequestInfo = Request | string;
|
||||
type RequestInfo = Request | string | RequestInit;
|
||||
|
||||
type BodyInit = ReadableStream | XMLHttpRequestBodyInit;
|
||||
type XMLHttpRequestBodyInit = Blob | BufferSource | string;
|
||||
type XMLHttpRequestBodyInit = Blob | BufferSource | string | FormData;
|
||||
type ReadableStreamController<T> = ReadableStreamDefaultController<T>;
|
||||
type ReadableStreamDefaultReadResult<T> =
|
||||
| ReadableStreamDefaultReadValueResult<T>
|
||||
@@ -828,6 +906,21 @@ interface RequestInit {
|
||||
timeout?: boolean;
|
||||
}
|
||||
|
||||
interface FetchRequestInit extends RequestInit {
|
||||
/**
|
||||
* Log the raw HTTP request & response to stdout. This API may be
|
||||
* removed in a future version of Bun without notice.
|
||||
* This is a custom property that is not part of the Fetch API specification.
|
||||
* It exists mostly as a debugging tool
|
||||
*/
|
||||
verbose?: boolean;
|
||||
/**
|
||||
* Override http_proxy or HTTPS_PROXY
|
||||
* This is a custom property that is not part of the Fetch API specification.
|
||||
*/
|
||||
proxy?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) represents an HTTP request.
|
||||
*
|
||||
@@ -970,9 +1063,19 @@ declare class Request implements BlobInterface {
|
||||
|
||||
/** Copy the Request object into a new Request, including the body */
|
||||
clone(): Request;
|
||||
|
||||
/**
|
||||
* Read the body from the Request as a {@link FormData} object.
|
||||
*
|
||||
* This first decodes the data from UTF-8, then parses it as a
|
||||
* `multipart/form-data` body or a `application/x-www-form-urlencoded` body.
|
||||
*
|
||||
* @returns Promise<FormData> - The body of the request as a {@link FormData}.
|
||||
*/
|
||||
formData(): Promise<FormData>;
|
||||
}
|
||||
|
||||
interface Crypto {
|
||||
declare interface Crypto {
|
||||
readonly subtle: SubtleCrypto;
|
||||
|
||||
getRandomValues<T extends BufferSource = BufferSource>(array: T): T;
|
||||
@@ -988,6 +1091,10 @@ interface Crypto {
|
||||
*/
|
||||
randomUUID(): string;
|
||||
}
|
||||
declare var Crypto: {
|
||||
prototype: Crypto;
|
||||
new (): Crypto;
|
||||
};
|
||||
|
||||
declare var crypto: Crypto;
|
||||
|
||||
@@ -1219,6 +1326,11 @@ declare function clearInterval(id?: number): void;
|
||||
* @param id timer id
|
||||
*/
|
||||
declare function clearTimeout(id?: number): void;
|
||||
/**
|
||||
* Cancel an immediate function call by its immediate ID.
|
||||
* @param id immediate id
|
||||
*/
|
||||
declare function clearImmediate(id?: number): void;
|
||||
// declare function createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>;
|
||||
// declare function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
|
||||
/**
|
||||
@@ -1231,20 +1343,10 @@ declare function clearTimeout(id?: number): void;
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare function fetch(
|
||||
url: string,
|
||||
init?: RequestInit,
|
||||
/**
|
||||
* This is a custom property that is not part of the Fetch API specification.
|
||||
* It exists mostly as a debugging tool
|
||||
*/
|
||||
bunOnlyOptions?: {
|
||||
/**
|
||||
* Log the raw HTTP request & response to stdout. This API may be
|
||||
* removed in a future version of Bun without notice.
|
||||
*/
|
||||
verbose: boolean;
|
||||
},
|
||||
url: string | URL,
|
||||
init?: FetchRequestInit,
|
||||
): Promise<Response>;
|
||||
|
||||
/**
|
||||
@@ -1258,21 +1360,7 @@ declare function fetch(
|
||||
*
|
||||
*/
|
||||
// tslint:disable-next-line:unified-signatures
|
||||
declare function fetch(
|
||||
request: Request,
|
||||
init?: RequestInit,
|
||||
/**
|
||||
* This is a custom property that is not part of the Fetch API specification.
|
||||
* It exists mostly as a debugging tool
|
||||
*/
|
||||
bunOnlyOptions?: {
|
||||
/**
|
||||
* Log the raw HTTP request & response to stdout. This API may be
|
||||
* removed in a future version of Bun without notice.
|
||||
*/
|
||||
verbose: boolean;
|
||||
},
|
||||
): Promise<Response>;
|
||||
declare function fetch(request: Request, init?: RequestInit): Promise<Response>;
|
||||
|
||||
declare function queueMicrotask(callback: (...args: any[]) => void): void;
|
||||
/**
|
||||
@@ -1621,6 +1709,27 @@ declare var MessageEvent: {
|
||||
new <T>(type: string, eventInitDict?: MessageEventInit<T>): MessageEvent<T>;
|
||||
};
|
||||
|
||||
interface CustomEventInit<T = any> extends EventInit {
|
||||
detail?: T;
|
||||
}
|
||||
|
||||
interface CustomEvent<T = any> extends Event {
|
||||
/** Returns any custom data event was created with. Typically used for synthetic events. */
|
||||
readonly detail: T;
|
||||
/** @deprecated */
|
||||
initCustomEvent(
|
||||
type: string,
|
||||
bubbles?: boolean,
|
||||
cancelable?: boolean,
|
||||
detail?: T,
|
||||
): void;
|
||||
}
|
||||
|
||||
declare var CustomEvent: {
|
||||
prototype: CustomEvent;
|
||||
new <T>(type: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>;
|
||||
};
|
||||
|
||||
/**
|
||||
* An implementation of the [WebSocket API](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)
|
||||
*/
|
||||
@@ -2281,6 +2390,43 @@ interface ErrnoException extends Error {
|
||||
syscall?: string | undefined;
|
||||
}
|
||||
|
||||
/** An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API. */
|
||||
interface DOMException extends Error {
|
||||
/** @deprecated */
|
||||
readonly code: number;
|
||||
readonly message: string;
|
||||
readonly name: string;
|
||||
readonly ABORT_ERR: number;
|
||||
readonly DATA_CLONE_ERR: number;
|
||||
readonly DOMSTRING_SIZE_ERR: number;
|
||||
readonly HIERARCHY_REQUEST_ERR: number;
|
||||
readonly INDEX_SIZE_ERR: number;
|
||||
readonly INUSE_ATTRIBUTE_ERR: number;
|
||||
readonly INVALID_ACCESS_ERR: number;
|
||||
readonly INVALID_CHARACTER_ERR: number;
|
||||
readonly INVALID_MODIFICATION_ERR: number;
|
||||
readonly INVALID_NODE_TYPE_ERR: number;
|
||||
readonly INVALID_STATE_ERR: number;
|
||||
readonly NAMESPACE_ERR: number;
|
||||
readonly NETWORK_ERR: number;
|
||||
readonly NOT_FOUND_ERR: number;
|
||||
readonly NOT_SUPPORTED_ERR: number;
|
||||
readonly NO_DATA_ALLOWED_ERR: number;
|
||||
readonly NO_MODIFICATION_ALLOWED_ERR: number;
|
||||
readonly QUOTA_EXCEEDED_ERR: number;
|
||||
readonly SECURITY_ERR: number;
|
||||
readonly SYNTAX_ERR: number;
|
||||
readonly TIMEOUT_ERR: number;
|
||||
readonly TYPE_MISMATCH_ERR: number;
|
||||
readonly URL_MISMATCH_ERR: number;
|
||||
readonly VALIDATION_ERR: number;
|
||||
readonly WRONG_DOCUMENT_ERR: number;
|
||||
}
|
||||
declare var DOMException: {
|
||||
prototype: DOMException;
|
||||
new (message?: string, name?: string): DOMException;
|
||||
};
|
||||
|
||||
declare function alert(message?: string): void;
|
||||
declare function confirm(message?: string): boolean;
|
||||
declare function prompt(message?: string, _default?: string): string | null;
|
||||
@@ -2776,3 +2922,154 @@ interface SharedArrayBuffer {
|
||||
*/
|
||||
grow(size: number): SharedArrayBuffer;
|
||||
}
|
||||
|
||||
declare namespace WebAssembly {
|
||||
interface CompileError extends Error {}
|
||||
|
||||
var CompileError: {
|
||||
prototype: CompileError;
|
||||
new (message?: string): CompileError;
|
||||
(message?: string): CompileError;
|
||||
};
|
||||
|
||||
interface Global {
|
||||
value: any;
|
||||
valueOf(): any;
|
||||
}
|
||||
|
||||
var Global: {
|
||||
prototype: Global;
|
||||
new (descriptor: GlobalDescriptor, v?: any): Global;
|
||||
};
|
||||
|
||||
interface Instance {
|
||||
readonly exports: Exports;
|
||||
}
|
||||
|
||||
var Instance: {
|
||||
prototype: Instance;
|
||||
new (module: Module, importObject?: Imports): Instance;
|
||||
};
|
||||
|
||||
interface LinkError extends Error {}
|
||||
|
||||
var LinkError: {
|
||||
prototype: LinkError;
|
||||
new (message?: string): LinkError;
|
||||
(message?: string): LinkError;
|
||||
};
|
||||
|
||||
interface Memory {
|
||||
readonly buffer: ArrayBuffer;
|
||||
grow(delta: number): number;
|
||||
}
|
||||
|
||||
var Memory: {
|
||||
prototype: Memory;
|
||||
new (descriptor: MemoryDescriptor): Memory;
|
||||
};
|
||||
|
||||
interface Module {}
|
||||
|
||||
var Module: {
|
||||
prototype: Module;
|
||||
new (bytes: BufferSource): Module;
|
||||
customSections(moduleObject: Module, sectionName: string): ArrayBuffer[];
|
||||
exports(moduleObject: Module): ModuleExportDescriptor[];
|
||||
imports(moduleObject: Module): ModuleImportDescriptor[];
|
||||
};
|
||||
|
||||
interface RuntimeError extends Error {}
|
||||
|
||||
var RuntimeError: {
|
||||
prototype: RuntimeError;
|
||||
new (message?: string): RuntimeError;
|
||||
(message?: string): RuntimeError;
|
||||
};
|
||||
|
||||
interface Table {
|
||||
readonly length: number;
|
||||
get(index: number): any;
|
||||
grow(delta: number, value?: any): number;
|
||||
set(index: number, value?: any): void;
|
||||
}
|
||||
|
||||
var Table: {
|
||||
prototype: Table;
|
||||
new (descriptor: TableDescriptor, value?: any): Table;
|
||||
};
|
||||
|
||||
interface GlobalDescriptor {
|
||||
mutable?: boolean;
|
||||
value: ValueType;
|
||||
}
|
||||
|
||||
interface MemoryDescriptor {
|
||||
initial: number;
|
||||
maximum?: number;
|
||||
shared?: boolean;
|
||||
}
|
||||
|
||||
interface ModuleExportDescriptor {
|
||||
kind: ImportExportKind;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface ModuleImportDescriptor {
|
||||
kind: ImportExportKind;
|
||||
module: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface TableDescriptor {
|
||||
element: TableKind;
|
||||
initial: number;
|
||||
maximum?: number;
|
||||
}
|
||||
|
||||
interface WebAssemblyInstantiatedSource {
|
||||
instance: Instance;
|
||||
module: Module;
|
||||
}
|
||||
|
||||
type ImportExportKind = "function" | "global" | "memory" | "table";
|
||||
type TableKind = "anyfunc" | "externref";
|
||||
type ValueType =
|
||||
| "anyfunc"
|
||||
| "externref"
|
||||
| "f32"
|
||||
| "f64"
|
||||
| "i32"
|
||||
| "i64"
|
||||
| "v128";
|
||||
type ExportValue = Function | Global | Memory | Table;
|
||||
type Exports = Record<string, ExportValue>;
|
||||
type ImportValue = ExportValue | number;
|
||||
type Imports = Record<string, ModuleImports>;
|
||||
type ModuleImports = Record<string, ImportValue>;
|
||||
function compile(bytes: BufferSource): Promise<Module>;
|
||||
// function compileStreaming(source: Response | PromiseLike<Response>): Promise<Module>;
|
||||
function instantiate(
|
||||
bytes: BufferSource,
|
||||
importObject?: Imports,
|
||||
): Promise<WebAssemblyInstantiatedSource>;
|
||||
function instantiate(
|
||||
moduleObject: Module,
|
||||
importObject?: Imports,
|
||||
): Promise<Instance>;
|
||||
// function instantiateStreaming(
|
||||
// source: Response | PromiseLike<Response>,
|
||||
// importObject?: Imports,
|
||||
// ): Promise<WebAssemblyInstantiatedSource>;
|
||||
function validate(bytes: BufferSource): boolean;
|
||||
}
|
||||
|
||||
interface NodeModule {
|
||||
exports: any;
|
||||
}
|
||||
|
||||
declare var module: NodeModule;
|
||||
|
||||
// Same as module.exports
|
||||
declare var exports: any;
|
||||
declare var global: typeof globalThis;
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
Can reference images included here in code comments, ex
|
||||
|
||||
```ts
|
||||
/**
|
||||
* ## Large headline
|
||||
*
|
||||
*
|
||||
* **Images** are relative to images/ directory
|
||||
*
|
||||
*
|
||||
*/
|
||||
export class MyUtil<T = { BOT_TOKEN: string }> {
|
||||
constructor(public config: T) {}
|
||||
}
|
||||
```
|
||||
51
packages/bun-types/index.d.ts
vendored
51
packages/bun-types/index.d.ts
vendored
@@ -5,32 +5,41 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
/// <reference no-default-lib="true" />
|
||||
/// <reference lib="esnext" />
|
||||
/// <reference path="./bun.d.ts" />
|
||||
/// <reference path="./assert.d.ts" />
|
||||
/// <reference path="./buffer.d.ts" />
|
||||
/// <reference path="./sqlite.d.ts" />
|
||||
/// <reference path="./bun-test.d.ts" />
|
||||
/// <reference path="./bun.d.ts" />
|
||||
/// <reference path="./child_process.d.ts" />
|
||||
/// <reference path="./console.d.ts" />
|
||||
/// <reference path="./constants.d.ts" />
|
||||
/// <reference path="./crypto.d.ts" />
|
||||
/// <reference path="./dns.d.ts" />
|
||||
/// <reference path="./dns/promises.d.ts" />
|
||||
/// <reference path="./domain.d.ts" />
|
||||
/// <reference path="./events.d.ts" />
|
||||
/// <reference path="./ffi.d.ts" />
|
||||
/// <reference path="./fs.d.ts" />
|
||||
/// <reference path="./fs/promises.d.ts" />
|
||||
/// <reference path="./html-rewriter.d.ts" />
|
||||
/// <reference path="./globals.d.ts" />
|
||||
/// <reference path="./path.d.ts" />
|
||||
/// <reference path="./bun-test.d.ts" />
|
||||
/// <reference path="./jsc.d.ts" />
|
||||
/// <reference path="./assert.d.ts" />
|
||||
/// <reference path="./events.d.ts" />
|
||||
/// <reference path="./os.d.ts" />
|
||||
/// <reference path="./domain.d.ts" />
|
||||
/// <reference path="./util.d.ts" />
|
||||
/// <reference path="./querystring.d.ts" />
|
||||
/// <reference path="./string_decoder.d.ts" />
|
||||
/// <reference path="./timers.d.ts" />
|
||||
/// <reference path="./stream.d.ts" />
|
||||
/// <reference path="./crypto.d.ts" />
|
||||
/// <reference path="./child_process.d.ts" />
|
||||
/// <reference path="./constants.d.ts" />
|
||||
/// <reference path="./url.d.ts" />
|
||||
/// <reference path="./tty.d.ts" />
|
||||
/// <reference path="./html-rewriter.d.ts" />
|
||||
/// <reference path="./http.d.ts" />
|
||||
/// <reference path="./jsc.d.ts" />
|
||||
/// <reference path="./module.d.ts" />
|
||||
/// <reference path="./net.d.ts" />
|
||||
/// <reference path="./os.d.ts" />
|
||||
/// <reference path="./path.d.ts" />
|
||||
/// <reference path="./perf_hooks.d.ts" />
|
||||
/// <reference path="./punycode.d.ts" />
|
||||
/// <reference path="./zlib.d.ts" />
|
||||
/// <reference path="./querystring.d.ts" />
|
||||
/// <reference path="./readline.d.ts" />
|
||||
/// <reference path="./readline/promises.d.ts" />
|
||||
/// <reference path="./sqlite.d.ts" />
|
||||
/// <reference path="./stream.d.ts" />
|
||||
/// <reference path="./string_decoder.d.ts" />
|
||||
/// <reference path="./supports-color.d.ts" />
|
||||
/// <reference path="./timers.d.ts" />
|
||||
/// <reference path="./tls.d.ts" />
|
||||
/// <reference path="./tty.d.ts" />
|
||||
/// <reference path="./url.d.ts" />
|
||||
/// <reference path="./util.d.ts" />
|
||||
/// <reference path="./zlib.d.ts" />
|
||||
|
||||
20
packages/bun-types/net.d.ts
vendored
20
packages/bun-types/net.d.ts
vendored
@@ -18,16 +18,16 @@ declare module "net" {
|
||||
Abortable,
|
||||
// EventEmitter
|
||||
} from "node:events";
|
||||
// import * as dns from "node:dns";
|
||||
// type LookupFunction = (
|
||||
// hostname: string,
|
||||
// options: dns.LookupOneOptions,
|
||||
// callback: (
|
||||
// err: NodeJS.ErrnoException | null,
|
||||
// address: string,
|
||||
// family: number,
|
||||
// ) => void,
|
||||
// ) => void;
|
||||
import * as dns from "node:dns";
|
||||
type LookupFunction = (
|
||||
hostname: string,
|
||||
options: dns.LookupOneOptions,
|
||||
callback: (
|
||||
err: ErrnoException | null,
|
||||
address: string,
|
||||
family: number,
|
||||
) => void,
|
||||
) => void;
|
||||
interface AddressInfo {
|
||||
address: string;
|
||||
family: string;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "bun-types",
|
||||
"types": "index.d.ts",
|
||||
"private": true,
|
||||
"repository": "https://github.com/oven-sh/bun-types",
|
||||
"repository": "https://github.com/oven-sh/bun",
|
||||
"scripts": {
|
||||
"build": "rm -rf ./dist && bun run bundle && bun run fmt",
|
||||
"bundle": "bun scripts/bundle.ts ./dist",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user