aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/bun-deploy-site.yml17
-rw-r--r--.github/workflows/bun-linux-aarch64.yml25
-rw-r--r--.github/workflows/bun-release-canary.yml86
-rw-r--r--.github/workflows/bun-release-types-canary.yml53
-rw-r--r--.github/workflows/prettier-fmt.yml76
-rw-r--r--.github/workflows/zig-fmt.yml87
-rw-r--r--.prettierignore7
-rw-r--r--.prettierrc14
-rw-r--r--.prettierrc.cjs14
-rw-r--r--.vscode/settings.json3
-rw-r--r--Makefile8
-rw-r--r--bench/cat/cat.mjs5
-rw-r--r--bench/copyfile/node.mitata.mjs12
-rw-r--r--bench/expect-to-equal/index.ts2
-rw-r--r--bench/fetch/bun.js4
-rw-r--r--bench/fetch/deno.js4
-rw-r--r--bench/fetch/node.mjs4
-rw-r--r--bench/ffi/deno.js5
-rw-r--r--bench/hot-module-reloading/css-stress-test/browser.js24
-rw-r--r--bench/hot-module-reloading/css-stress-test/read-frames.js24
-rw-r--r--bench/hot-module-reloading/css-stress-test/src/index.tsx5
-rw-r--r--bench/hot-module-reloading/css-stress-test/src/main.tsx20
-rw-r--r--bench/json-stringify/bun.js8
-rw-r--r--bench/log/bun.js4
-rw-r--r--bench/module-loader/create.js12
-rw-r--r--bench/modules/node_os/bun.js21
-rw-r--r--bench/modules/node_os/node.mjs21
-rw-r--r--bench/package.json3
-rw-r--r--bench/react-hello-world/react-hello-world.deno.jsx4
-rw-r--r--bench/react-hello-world/react-hello-world.node.js3285
-rw-r--r--bench/react-hello-world/react-hello-world.node.jsx4
-rw-r--r--bench/scanner/scan-imports-only.js4
-rw-r--r--bench/snippets/array-map.mjs42
-rw-r--r--bench/snippets/assert.mjs5
-rw-r--r--bench/snippets/async-overhead.mjs11
-rw-r--r--bench/snippets/buffer-read.js4
-rw-r--r--bench/snippets/buffer.js9
-rw-r--r--bench/snippets/callbacks-overhead.mjs22
-rw-r--r--bench/snippets/concat.js34
-rw-r--r--bench/snippets/console-log.mjs9
-rw-r--r--bench/snippets/deep-equals.js14
-rw-r--r--bench/snippets/define-properties.mjs9
-rw-r--r--bench/snippets/dns.node.mjs14
-rw-r--r--bench/snippets/dns.ts56
-rw-r--r--bench/snippets/escapeHTML.js9
-rw-r--r--bench/snippets/ffi-overhead.mjs31
-rw-r--r--bench/snippets/index-of.mjs2
-rw-r--r--bench/snippets/package.json3
-rw-r--r--bench/snippets/react-dom-render.bun.js56
-rw-r--r--bench/snippets/return-await.mjs1
-rw-r--r--bench/snippets/transpiler.mjs6
-rw-r--r--bench/websocket-server/chat-client.mjs15
-rw-r--r--bench/websocket-server/chat-server.bun.js9
-rw-r--r--bench/websocket-server/chat-server.deno.mjs9
-rw-r--r--bench/websocket-server/chat-server.node.mjs8
-rw-r--r--docs/api/file-io.md4
-rw-r--r--docs/api/sqlite.md4
-rw-r--r--docs/ecosystem/nodejs.md2
-rw-r--r--docs/ecosystem/react.md19
-rw-r--r--docs/nav.ts178
-rw-r--r--examples/html-rewriter.ts23
-rw-r--r--examples/lambda.ts130
-rw-r--r--examples/macros/components/covid19.tsx11
-rw-r--r--examples/macros/components/example.jsx12
-rw-r--r--examples/macros/fetchCSV.tsx6
-rw-r--r--examples/macros/matchInFile.tsx4
-rw-r--r--examples/macros/mystery-box.ts5
-rw-r--r--examples/openInEditor.js3
-rw-r--r--examples/react-fast-refresh-test/src/main.tsx15
-rw-r--r--examples/react-file-system-router/index.tsx22
-rw-r--r--examples/react-file-system-router/pages/index.tsx6
-rw-r--r--examples/react-file-system-router/pages/one.tsx2
-rw-r--r--examples/react-file-system-router/pages/two.tsx2
-rw-r--r--examples/sha.js15
-rw-r--r--examples/spawn.ts4
-rw-r--r--misctools/gen-unicode-table.js40
-rw-r--r--misctools/headers-cleaner.js43
-rw-r--r--misctools/mime.js23
-rw-r--r--misctools/publish-examples.js51
-rw-r--r--package.json5
-rw-r--r--packages/bun-test/src/runner.ts6
-rw-r--r--packages/bun-types/bun.d.ts36
-rwxr-xr-xpackages/bun-types/bun.lockbbin37964 -> 38313 bytes
-rw-r--r--packages/bun-types/ffi.d.ts149
-rw-r--r--packages/bun-types/fs.d.ts7
-rw-r--r--packages/bun-types/fs/promises.d.ts37
-rw-r--r--packages/bun-types/globals.d.ts6
-rw-r--r--packages/bun-types/package.json5
-rw-r--r--packages/bun-types/tests/ffi.test-d.ts96
-rw-r--r--packages/bun-types/tests/fs.test-d.ts6
-rw-r--r--src/api/demo/lib/api.ts18
-rw-r--r--src/api/demo/pages/index.tsx12
-rw-r--r--src/api/demo/pages/scan.tsx14
-rw-r--r--src/api/demo/schema.d.ts319
-rw-r--r--src/api/demo/schema.js137
-rw-r--r--src/bun.js/api/bun.zig28
-rw-r--r--src/bun.js/api/bun/subprocess.zig2
-rw-r--r--src/bun.js/api/server.zig124
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp18
-rw-r--r--src/bun.js/bindings/bindings.cpp33
-rw-r--r--src/bun.js/bindings/bindings.zig37
-rw-r--r--src/bun.js/bindings/headers-cpp.h18
-rw-r--r--src/bun.js/bindings/headers.h36
-rw-r--r--src/bun.js/bindings/headers.zig24
-rw-r--r--src/bun.js/bindings/sqlite/JSSQLStatement.cpp16
-rw-r--r--src/bun.js/http.exports.js94
-rw-r--r--src/bun.js/javascript.zig77
-rw-r--r--src/bun.js/javascript_core_c_api.zig3
-rw-r--r--src/bun.js/module_loader.zig1
-rw-r--r--src/bun.js/node-dns.exports.js43
-rw-r--r--src/bun.js/node-tls.exports.js1
-rw-r--r--src/bun.js/node/node_os.zig174
-rw-r--r--src/bun.js/wasi-runner.js11
-rw-r--r--src/bun.js/webcore.zig1
-rw-r--r--src/bun.js/webcore/blob.zig25
-rw-r--r--src/bun.js/webcore/body.zig22
-rw-r--r--src/bun.js/webcore/request.zig15
-rw-r--r--src/bun.js/webcore/response.zig16
-rw-r--r--src/bun.js/webcore/streams.zig2
-rw-r--r--src/bun_js.zig50
-rw-r--r--src/bundler/entry_points.zig11
-rw-r--r--src/bunfig.zig32
-rw-r--r--src/cli.zig62
-rw-r--r--src/cli/run_command.zig29
-rw-r--r--src/cli/test_command.zig3
-rw-r--r--src/darwin_c.zig40
-rw-r--r--src/deps/uws.zig4
-rw-r--r--src/fallback.ts9
-rw-r--r--src/http.zig4
-rw-r--r--src/http_client_async.zig14
-rw-r--r--src/linux_c.zig3
-rw-r--r--src/node-fallbacks/@vercel_fetch.js8
-rw-r--r--src/node-fallbacks/crypto.js15
-rw-r--r--src/node-fallbacks/events.js71
-rw-r--r--src/node-fallbacks/url.js81
-rw-r--r--src/runtime.footer.bun.js6
-rw-r--r--src/runtime.footer.js6
-rw-r--r--src/runtime.footer.node.js3
-rw-r--r--src/runtime.footer.with-refresh.js6
-rw-r--r--src/runtime.js43
-rw-r--r--src/runtime/errors.ts6
-rw-r--r--src/runtime/hmr.ts314
-rw-r--r--src/runtime/regenerator.ts41
-rw-r--r--src/sha.zig141
-rw-r--r--src/string_immutable.zig2
-rw-r--r--src/test/fixtures/double-export-default-bug.jsx12
-rw-r--r--src/test/fixtures/simple-150x.jsx42
-rw-r--r--src/test/fixtures/simple.jsx30
-rw-r--r--test/bun.js/.prettierignore2
-rw-r--r--test/bun.js/baz.js1
-rw-r--r--test/bun.js/body-stream.test.ts2
-rw-r--r--test/bun.js/buffer.test.js5
-rw-r--r--test/bun.js/bun-server.test.ts120
-rw-r--r--test/bun.js/bun-write.test.js8
-rw-r--r--test/bun.js/disabled-module.test.js94
-rw-r--r--test/bun.js/emptyFile0
-rw-r--r--test/bun.js/event-emitter.test.ts2
-rw-r--r--test/bun.js/fetch.test.js274
-rw-r--r--test/bun.js/fetch_headers.test.js20
-rw-r--r--test/bun.js/fs.test.ts (renamed from test/bun.js/fs.test.js)53
-rw-r--r--test/bun.js/gc.ts (renamed from test/bun.js/gc.js)4
-rw-r--r--test/bun.js/inspect.test.js2
-rw-r--r--test/bun.js/install/bun-install.test.ts124
-rw-r--r--test/bun.js/install/dummy.registry.ts2
-rw-r--r--test/bun.js/install/moo-0.1.0.tgzbin0 -> 197 bytes
-rw-r--r--test/bun.js/node-http.test.ts145
-rw-r--r--test/bun.js/os.test.js9
-rw-r--r--test/bun.js/package.json3
-rw-r--r--test/bun.js/preload-test.test.js227
-rw-r--r--test/bun.js/repro_2005.test.js1
-rw-r--r--test/bun.js/sleep.js2
-rw-r--r--test/bun.js/sleepSync.test.ts32
-rw-r--r--test/bun.js/sqlite.test.js23
-rw-r--r--test/snippets/code-simplification-neql-define.js20
-rw-r--r--test/snippets/export.js5
-rw-r--r--test/snippets/jsx-entities.jsx5
-rw-r--r--test/snippets/latin1-chars-in-regexp.js34
-rw-r--r--test/snippets/optional-chain-with-function.js8
-rw-r--r--test/snippets/package.json3
-rw-r--r--test/snippets/react-context-value-func.tsx2
-rw-r--r--test/snippets/simple-lit-example.ts8
-rw-r--r--test/snippets/spread_with_key.tsx7
-rw-r--r--test/snippets/string-escapes.js34
-rw-r--r--test/snippets/styledcomponents-output.js20
-rw-r--r--test/snippets/template-literal.js15
-rw-r--r--test/snippets/type-only-imports.ts3
-rw-r--r--tsconfig.json3
187 files changed, 3907 insertions, 5044 deletions
diff --git a/.github/workflows/bun-deploy-site.yml b/.github/workflows/bun-deploy-site.yml
new file mode 100644
index 000000000..1fe647a3d
--- /dev/null
+++ b/.github/workflows/bun-deploy-site.yml
@@ -0,0 +1,17 @@
+# redeploy Vercel site when a file in `docs` changes
+# using VERCEL_DEPLOY_HOOK environment variable
+
+name: Deploy site
+on:
+ push:
+ paths:
+ - "docs/**"
+ branches: [main]
+
+jobs:
+ deploy:
+ name: Deploy site
+ runs-on: ubuntu-latest
+ steps:
+ - name: Trigger Vercel build
+ run: curl ${{ secrets.VERCEL_DEPLOY_HOOK }} \ No newline at end of file
diff --git a/.github/workflows/bun-linux-aarch64.yml b/.github/workflows/bun-linux-aarch64.yml
index 89ea3622d..d450e7aaf 100644
--- a/.github/workflows/bun-linux-aarch64.yml
+++ b/.github/workflows/bun-linux-aarch64.yml
@@ -128,3 +128,28 @@ jobs:
name: "Canary (${{github.sha}})"
tag: "canary"
artifacts: "${{runner.temp}}/release/bun-${{matrix.tag}}.zip,${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip"
+ linux-test:
+ name: linux-aarch64-test
+ needs: [linux]
+ runs-on: linux-arm64
+ timeout-minutes: 10
+ defaults:
+ run:
+ working-directory: packages/bun-test
+ steps:
+ - id: checkout
+ name: Checkout
+ uses: actions/checkout@v3
+ with:
+ submodules: recursive
+ - id: setup
+ name: Setup
+ uses: oven-sh/setup-bun@v1
+ with:
+ bun-version: action:${{github.run_id}}
+ - id: install
+ name: Install
+ run: bun install
+ - id: test
+ name: Test
+ run: bun run test
diff --git a/.github/workflows/bun-release-canary.yml b/.github/workflows/bun-release-canary.yml
index 1422842fb..7c7a8bea2 100644
--- a/.github/workflows/bun-release-canary.yml
+++ b/.github/workflows/bun-release-canary.yml
@@ -29,49 +29,49 @@ jobs:
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@v1
- with:
- bun-version: canary
- - id: bun-install
- name: Install Dependencies
- run: 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
+ # 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@v1
+ # with:
+ # bun-version: canary
+ # - id: bun-install
+ # name: Install Dependencies
+ # run: 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
diff --git a/.github/workflows/bun-release-types-canary.yml b/.github/workflows/bun-release-types-canary.yml
new file mode 100644
index 000000000..1962011a7
--- /dev/null
+++ b/.github/workflows/bun-release-types-canary.yml
@@ -0,0 +1,53 @@
+name: bun-release-canary
+concurrency: release-canary
+on:
+ push:
+ branches:
+ - main
+ paths:
+ - "packages/bun-types/**"
+ workflow_dispatch:
+jobs:
+ 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@v1
+ with:
+ bun-version: canary
+ - id: bun-install
+ name: Install Dependencies
+ run: 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%dT%H%M%S')"
+ 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
diff --git a/.github/workflows/prettier-fmt.yml b/.github/workflows/prettier-fmt.yml
new file mode 100644
index 000000000..877b34a6f
--- /dev/null
+++ b/.github/workflows/prettier-fmt.yml
@@ -0,0 +1,76 @@
+name: prettier
+
+on:
+ pull_request:
+ branches:
+ - main
+ - jarred/test-actions
+ # Allows you to run this workflow manually from the Actions tab
+ workflow_dispatch:
+
+jobs:
+ prettier-fmt:
+ name: prettier
+ runs-on: ubuntu-latest
+ outputs:
+ prettier_fmt_errs: ${{ steps.fmt.outputs.prettier_fmt_errs }}
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ submodules: recursive
+
+ - id: setup
+ name: Setup
+ uses: oven-sh/setup-bun@v1
+ with:
+ bun-version: latest
+ - id: install
+ name: Install prettier
+ run: bun install
+ - name: Run prettier
+ id: fmt
+ run: |
+ rm -f .failed
+ bun prettier --check "./bench/**/*.{ts,tsx,js,jsx,mjs}" "./test/**/*.{ts,tsx,js,jsx,mjs}" "./src/**/*.{ts,tsx,js,jsx}" --config .prettierrc.cjs 2> prettier-fmt.err > prettier-fmt1.err || echo 'failed' > .failed
+
+ if [ -s .failed ]; then
+ delimiter="$(openssl rand -hex 8)"
+ echo "prettier_fmt_errs<<${delimiter}" >> "${GITHUB_OUTPUT}"
+ cat prettier-fmt.err >> "${GITHUB_OUTPUT}"
+ cat prettier-fmt1.err >> "${GITHUB_OUTPUT}"
+ echo "${delimiter}" >> "${GITHUB_OUTPUT}"
+ fi
+ - name: Comment on PR
+ if: steps.fmt.outputs.prettier_fmt_errs != ''
+ uses: thollander/actions-comment-pull-request@v2
+ with:
+ comment_tag: prettier-fmt
+ message: |
+ ❌ @${{ github.actor }} `prettier` reported errors
+
+ ```js
+ ${{ steps.fmt.outputs.prettier_fmt_errs }}
+ ```
+
+ To one-off fix this manually, run:
+ ```sh
+ bun fmt
+ ```
+
+ You might need to run `bun install` locally and configure your text editor to [auto-format on save](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode).
+
+ <sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
+ - name: Uncomment on PR
+ if: steps.fmt.outputs.prettier_fmt_errs == ''
+ uses: thollander/actions-comment-pull-request@v2
+ with:
+ comment_tag: prettier-fmt
+ mode: upsert
+ create_if_not_exists: false
+ message: |
+ ✅ `prettier` errors have been resolved. Thank you.
+
+ <sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
+ - name: Fail the job
+ if: steps.fmt.outputs.prettier_fmt_errs != ''
+ run: exit 1
diff --git a/.github/workflows/zig-fmt.yml b/.github/workflows/zig-fmt.yml
new file mode 100644
index 000000000..9f4e2207a
--- /dev/null
+++ b/.github/workflows/zig-fmt.yml
@@ -0,0 +1,87 @@
+name: zig-fmt
+
+env:
+ ZIG_VERSION: 0.11.0-dev.1783+436e99d13
+
+on:
+ pull_request:
+ branches:
+ - main
+ - jarred/test-actions
+ paths:
+ - "src/**/*.zig"
+ - "src/*.zig"
+ # Allows you to run this workflow manually from the Actions tab
+ workflow_dispatch:
+
+jobs:
+ zig-fmt:
+ name: zig fmt
+ runs-on: ubuntu-latest
+ outputs:
+ zig_fmt_errs: ${{ steps.fmt.outputs.zig_fmt_errs }}
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ submodules: recursive
+ - name: Install zig
+ run: |
+ curl https://ziglang.org/builds/zig-linux-x86_64-${{env.ZIG_VERSION}}.tar.xz -L -o zig.tar.xz
+ tar -xf zig.tar.xz
+ sudo mv zig-linux-x86_64-${{env.ZIG_VERSION}}/zig /usr/local/bin
+ - name: Run zig fmt
+ id: fmt
+ run: |
+ zig fmt --check src/*.zig src/**/*.zig 2> zig-fmt.err > zig-fmt.err2 || echo "Failed"
+ delimiter="$(openssl rand -hex 8)"
+ echo "zig_fmt_errs<<${delimiter}" >> "${GITHUB_OUTPUT}"
+
+ if [ -s zig-fmt.err ]; then
+ echo "// The following errors occurred:" >> "${GITHUB_OUTPUT}"
+ cat zig-fmt.err >> "${GITHUB_OUTPUT}"
+ fi
+
+ if [ -s zig-fmt.err2 ]; then
+ echo "// The following files were not formatted:" >> "${GITHUB_OUTPUT}"
+ cat zig-fmt.err2 >> "${GITHUB_OUTPUT}"
+ fi
+
+ echo "${delimiter}" >> "${GITHUB_OUTPUT}"
+ - name: Comment on PR
+ if: steps.fmt.outputs.zig_fmt_errs != ''
+ uses: thollander/actions-comment-pull-request@v2
+ with:
+ comment_tag: zig-fmt
+ message: |
+ ❌ @${{ github.actor }} `zig fmt` reported errors. Consider configuring your text editor to [auto-format on save](https://github.com/ziglang/vscode-zig)
+
+ ```zig
+ // # zig fmt --check src/*.zig src/**/*.zig
+ ${{ steps.fmt.outputs.zig_fmt_errs }}
+ ```
+
+ To one-off fix this manually, run:
+
+ ```sh
+ zig fmt src/*.zig src/**/*.zig
+ ```
+
+ <sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
+ <sup>zig v${{env.ZIG_VERSION}}</sup>
+
+ - name: Uncomment on PR
+ if: steps.fmt.outputs.zig_fmt_errs == ''
+ uses: thollander/actions-comment-pull-request@v2
+ with:
+ comment_tag: zig-fmt
+ mode: upsert
+ create_if_not_exists: false
+ message: |
+ ✅ `zig fmt` errors have been resolved. Thank you.
+
+ <sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
+ <sup>zig v${{env.ZIG_VERSION}}</sup>
+
+ - name: Fail the job
+ if: steps.fmt.outputs.zig_fmt_errs != ''
+ run: exit 1
diff --git a/.prettierignore b/.prettierignore
index 1283490d0..b9249b91c 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -6,3 +6,10 @@ test/bun.js/bundled
# src/api/demo
test/snapshots
test/snapshots-no-hmr
+src/bun.js/WebKit
+src/bun.js/builtins/js
+src/*.out.js
+src/*out.*.js
+src/deps
+src/test/fixtures
+src/react-refresh.js
diff --git a/.prettierrc b/.prettierrc
deleted file mode 100644
index eab23fd80..000000000
--- a/.prettierrc
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "arrowParens": "avoid",
- "printWidth": 120,
- "trailingComma": "all",
- "useTabs": false,
- "overrides": [
- {
- "files": "README.md",
- "options": {
- "printWidth": 80
- }
- }
- ]
-}
diff --git a/.prettierrc.cjs b/.prettierrc.cjs
new file mode 100644
index 000000000..c264d0d28
--- /dev/null
+++ b/.prettierrc.cjs
@@ -0,0 +1,14 @@
+module.exports = {
+ arrowParens: "avoid",
+ printWidth: 120,
+ trailingComma: "all",
+ useTabs: false,
+ overrides: [
+ {
+ files: "README.md",
+ options: {
+ printWidth: 80,
+ },
+ },
+ ],
+};
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 3236532e0..b535a1bd5 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -32,6 +32,9 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
+ "[yaml]": {
+ "editor.formatOnSave": true
+ },
"zig.beforeDebugCmd": "make build-unit ${file} ${filter} ${bin}",
"zig.testCmd": "make test ${file} ${filter} ${bin}",
"[markdown]": {
diff --git a/Makefile b/Makefile
index e271239a7..e194e9587 100644
--- a/Makefile
+++ b/Makefile
@@ -569,7 +569,11 @@ c-ares:
rm -rf $(BUN_DEPS_DIR)/c-ares/build && \
mkdir $(BUN_DEPS_DIR)/c-ares/build && \
cd $(BUN_DEPS_DIR)/c-ares/build && \
- cmake $(CMAKE_FLAGS) -DCMAKE_C_FLAGS="$(CFLAGS) -flto=full" -DCMAKE_BUILD_TYPE=Release -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCARES_SHARED=OFF -G "Ninja" .. && \
+ cmake $(CMAKE_FLAGS) -DCMAKE_C_FLAGS="$(CFLAGS) -flto=full" \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_LIBDIR=lib \
+ -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCARES_SHARED=OFF \
+ -G "Ninja" .. && \
ninja && cp lib/libcares.a $(BUN_DEPS_OUT_DIR)/libcares.a
.PHONY: prepare-types
@@ -832,7 +836,7 @@ fetch: $(IO_FILES)
.PHONY: sha
sha:
$(ZIG) build -Doptimize=ReleaseFast sha-bench-obj
- $(CXX) $(PACKAGE_DIR)/sha.o -g $(OPTIMIZATION_LEVEL) -o ./misctools/sha $(DEFAULT_LINKER_FLAGS) -lc $(MINIMUM_ARCHIVE_FILES)
+ $(CXX) $(PACKAGE_DIR)/sha.o -I$(BUN_DEPS_DIR) -g $(OPTIMIZATION_LEVEL) -o ./misctools/sha $(DEFAULT_LINKER_FLAGS) -lc $(MINIMUM_ARCHIVE_FILES)
rm -rf $(PACKAGE_DIR)/sha.o
.PHONY: fetch-debug
diff --git a/bench/cat/cat.mjs b/bench/cat/cat.mjs
index fc8719829..1dd8186fd 100644
--- a/bench/cat/cat.mjs
+++ b/bench/cat/cat.mjs
@@ -6,7 +6,4 @@ const arg = process.argv.slice(1);
// TODO: remove Buffer.from() when readFileSync() returns Buffer
-for (let i = 0; i < count; i++)
- console.log(
- arg.map((file) => Buffer.from(readFileSync(file, "utf8"))).join("")
- );
+for (let i = 0; i < count; i++) console.log(arg.map(file => Buffer.from(readFileSync(file, "utf8"))).join(""));
diff --git a/bench/copyfile/node.mitata.mjs b/bench/copyfile/node.mitata.mjs
index aa77245e1..379150487 100644
--- a/bench/copyfile/node.mitata.mjs
+++ b/bench/copyfile/node.mitata.mjs
@@ -7,14 +7,8 @@ function runner(ready) {
for (let i = 0; i < size; i++) {
rand[i] = (Math.random() * 1024 * 1024) | 0;
}
- const dest = `/tmp/fs-test-copy-file-${(
- (Math.random() * 10000000 + 100) |
- 0
- ).toString(32)}`;
- const src = `/tmp/fs-test-copy-file-${(
- (Math.random() * 10000000 + 100) |
- 0
- ).toString(32)}`;
+ const dest = `/tmp/fs-test-copy-file-${((Math.random() * 10000000 + 100) | 0).toString(32)}`;
+ const src = `/tmp/fs-test-copy-file-${((Math.random() * 10000000 + 100) | 0).toString(32)}`;
writeFileSync(src, Buffer.from(rand.buffer), { encoding: "buffer" });
const { size: fileSize } = statSync(src);
if (fileSize !== rand.byteLength) {
@@ -35,6 +29,6 @@ runner((src, dest, rand) =>
// );
// }
// }
- })
+ }),
);
await run();
diff --git a/bench/expect-to-equal/index.ts b/bench/expect-to-equal/index.ts
index f67b2c645..2a5e4b80c 100644
--- a/bench/expect-to-equal/index.ts
+++ b/bench/expect-to-equal/index.ts
@@ -1 +1 @@
-console.log("Hello via Bun!"); \ No newline at end of file
+console.log("Hello via Bun!");
diff --git a/bench/fetch/bun.js b/bench/fetch/bun.js
index 7559b467e..96e7275a8 100644
--- a/bench/fetch/bun.js
+++ b/bench/fetch/bun.js
@@ -6,9 +6,7 @@ bench(`fetch(https://example.com) x ${count}`, async () => {
const requests = new Array(count);
for (let i = 0; i < requests.length; i++) {
- requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then((r) =>
- r.text(),
- );
+ requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then(r => r.text());
}
await Promise.all(requests);
diff --git a/bench/fetch/deno.js b/bench/fetch/deno.js
index 3eef41698..1117a38df 100644
--- a/bench/fetch/deno.js
+++ b/bench/fetch/deno.js
@@ -6,9 +6,7 @@ bench(`fetch(https://example.com) x ${count}`, async () => {
const requests = new Array(count);
for (let i = 0; i < requests.length; i++) {
- requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then((r) =>
- r.text(),
- );
+ requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then(r => r.text());
}
await Promise.all(requests);
diff --git a/bench/fetch/node.mjs b/bench/fetch/node.mjs
index f61eeb0c6..96e7275a8 100644
--- a/bench/fetch/node.mjs
+++ b/bench/fetch/node.mjs
@@ -6,9 +6,7 @@ bench(`fetch(https://example.com) x ${count}`, async () => {
const requests = new Array(count);
for (let i = 0; i < requests.length; i++) {
- requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then((r) =>
- r.text()
- );
+ requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then(r => r.text());
}
await Promise.all(requests);
diff --git a/bench/ffi/deno.js b/bench/ffi/deno.js
index 8f4c76ca2..63ba6358c 100644
--- a/bench/ffi/deno.js
+++ b/bench/ffi/deno.js
@@ -1,10 +1,7 @@
import { run, bench, group } from "../node_modules/mitata/src/cli.mjs";
const extension = "darwin" !== Deno.build.os ? "so" : "dylib";
-const path = new URL(
- "src/target/release/libffi_napi_bench." + extension,
- import.meta.url,
-).pathname;
+const path = new URL("src/target/release/libffi_napi_bench." + extension, import.meta.url).pathname;
const {
symbols: { ffi_noop, ffi_hash, ffi_string },
diff --git a/bench/hot-module-reloading/css-stress-test/browser.js b/bench/hot-module-reloading/css-stress-test/browser.js
index 15938dff2..d6bce108f 100644
--- a/bench/hot-module-reloading/css-stress-test/browser.js
+++ b/bench/hot-module-reloading/css-stress-test/browser.js
@@ -24,7 +24,7 @@ if (process.env.PROJECT === "bun") {
// bunProcess.stderr.pipe(process.stderr);
// bunProcess.stdout.pipe(process.stdout);
- bunProcess.once("error", (err) => {
+ bunProcess.once("error", err => {
console.error("❌ bun error", err);
process.exit(1);
});
@@ -32,19 +32,15 @@ if (process.env.PROJECT === "bun") {
bunProcess?.kill(0);
});
} else if (process.env.PROJECT === "next") {
- const bunProcess = child_process.spawn(
- "./node_modules/.bin/next",
- ["--port", "8080"],
- {
- cwd: process.cwd(),
- stdio: "ignore",
- env: {
- ...process.env,
- },
-
- shell: false,
+ const bunProcess = child_process.spawn("./node_modules/.bin/next", ["--port", "8080"], {
+ cwd: process.cwd(),
+ stdio: "ignore",
+ env: {
+ ...process.env,
},
- );
+
+ shell: false,
+ });
}
const delay = new Promise((resolve, reject) => {
@@ -111,7 +107,7 @@ async function main() {
return runPage();
}
-main().catch((error) =>
+main().catch(error =>
setTimeout(() => {
throw error;
}),
diff --git a/bench/hot-module-reloading/css-stress-test/read-frames.js b/bench/hot-module-reloading/css-stress-test/read-frames.js
index 9e264b4df..089e97e83 100644
--- a/bench/hot-module-reloading/css-stress-test/read-frames.js
+++ b/bench/hot-module-reloading/css-stress-test/read-frames.js
@@ -4,9 +4,7 @@ const path = require("path");
const PROJECT = process.env.PROJECT || "bun";
const percentile = require("percentile");
const PACKAGE_NAME = process.env.PACKAGE_NAME;
-const label = `${PACKAGE_NAME}@${
- require(PACKAGE_NAME + "/package.json").version
-}`;
+const label = `${PACKAGE_NAME}@${require(PACKAGE_NAME + "/package.json").version}`;
const BASEFOLDER = path.resolve(PROJECT);
const OUTFILE = path.join(process.cwd(), process.env.OUTFILE);
@@ -20,10 +18,10 @@ const TOTAL_FRAMES = VALID_TIMES.length;
const timings = fs
.readFileSync(BASEFOLDER + "/frames.all.clean", "utf8")
.split("\n")
- .map((a) => a.replace(/[Ran:'\.]?/gm, "").trim())
- .filter((a) => parseInt(a, 10))
- .filter((a) => a.length > 0 && VALID_TIMES.includes(BigInt(parseInt(a, 10))))
- .map((num) => BigInt(num));
+ .map(a => a.replace(/[Ran:'\.]?/gm, "").trim())
+ .filter(a => parseInt(a, 10))
+ .filter(a => a.length > 0 && VALID_TIMES.includes(BigInt(parseInt(a, 10))))
+ .map(num => BigInt(num));
timings.sort();
@@ -47,7 +45,7 @@ const report = {
name: PACKAGE_NAME,
version: require(PACKAGE_NAME + "/package.json").version,
},
- timestamps: timings.map((a) => Number(a)),
+ timestamps: timings.map(a => Number(a)),
frameTimes: frameTime,
percentileMs: {
50: percentile(50, frameTime) / 10,
@@ -67,9 +65,7 @@ fs.writeFileSync(
"." +
process.env.SLEEP_INTERVAL +
"ms." +
- `${process.platform}-${
- process.arch === "arm64" ? "aarch64" : process.arch
- }` +
+ `${process.platform}-${process.arch === "arm64" ? "aarch64" : process.arch}` +
".json",
),
JSON.stringify(report, null, 2),
@@ -99,9 +95,5 @@ console.log(
timings.length,
"/",
TOTAL_FRAMES,
- "(" +
- Math.round(
- Math.max(Math.min(1.0, timings.length / TOTAL_FRAMES), 0) * 100,
- ) +
- "%)",
+ "(" + Math.round(Math.max(Math.min(1.0, timings.length / TOTAL_FRAMES), 0) * 100) + "%)",
);
diff --git a/bench/hot-module-reloading/css-stress-test/src/index.tsx b/bench/hot-module-reloading/css-stress-test/src/index.tsx
index 35e7fceab..7ca290f48 100644
--- a/bench/hot-module-reloading/css-stress-test/src/index.tsx
+++ b/bench/hot-module-reloading/css-stress-test/src/index.tsx
@@ -3,10 +3,7 @@ import classNames from "classnames";
import ReactDOM from "react-dom";
const Base = ({}) => {
- const name =
- typeof location !== "undefined"
- ? decodeURIComponent(location.search.substring(1))
- : null;
+ const name = typeof location !== "undefined" ? decodeURIComponent(location.search.substring(1)) : null;
return <Main productName={name} />;
};
diff --git a/bench/hot-module-reloading/css-stress-test/src/main.tsx b/bench/hot-module-reloading/css-stress-test/src/main.tsx
index 2093d924f..9707deaae 100644
--- a/bench/hot-module-reloading/css-stress-test/src/main.tsx
+++ b/bench/hot-module-reloading/css-stress-test/src/main.tsx
@@ -4,8 +4,8 @@ export const Main = (props: { productName: string; cssInJS?: string }) => {
<header>
<div className="Title">CSS HMR Stress Test!</div>
<p className="Description">
- This page visually tests how quickly a bundler can update{" "}
- {props.cssInJS ? "CSS-in-JS" : "CSS"} over Hot Module Reloading.
+ This page visually tests how quickly a bundler can update {props.cssInJS ? "CSS-in-JS" : "CSS"} over Hot
+ Module Reloading.
</p>
</header>
<main className="main">
@@ -19,9 +19,7 @@ export const Main = (props: { productName: string; cssInJS?: string }) => {
<div className="ProgressBar-container">
<div className="ProgressBar"></div>
</div>
- <div className="SectionLabel">
- The progress bar should move from left to right smoothly.
- </div>
+ <div className="SectionLabel">The progress bar should move from left to right smoothly.</div>
</section>
<section>
@@ -42,21 +40,15 @@ export const Main = (props: { productName: string; cssInJS?: string }) => {
<div className="Spinner"></div>
</div>
</div>
- <div className="SectionLabel">
- The spinners should rotate &amp; change color smoothly.
- </div>
+ <div className="SectionLabel">The spinners should rotate &amp; change color smoothly.</div>
</section>
</main>
<footer>
- <div className="SectionLabel FooterLabel">
- There are no CSS animations on this page.
- </div>
+ <div className="SectionLabel FooterLabel">There are no CSS animations on this page.</div>
<div className="Bundler-container">
<div className="Bundler">{props.productName}</div>
- <div className="Bundler-updateRate">
- {props.cssInJS ? "CSS-in-JS framework: " + props.cssInJS : ""}
- </div>
+ <div className="Bundler-updateRate">{props.cssInJS ? "CSS-in-JS framework: " + props.cssInJS : ""}</div>
</div>
</footer>
</>
diff --git a/bench/json-stringify/bun.js b/bench/json-stringify/bun.js
index 8c9893794..22f29deb4 100644
--- a/bench/json-stringify/bun.js
+++ b/bench/json-stringify/bun.js
@@ -1,12 +1,8 @@
import { bench, run } from "mitata";
-bench("JSON.stringify({hello: 'world'})", () =>
- JSON.stringify({ hello: "world" }),
-);
+bench("JSON.stringify({hello: 'world'})", () => JSON.stringify({ hello: "world" }));
const otherUint8Array = new Uint8Array(1024);
-bench("Uint8Array.from(otherUint8Array)", () =>
- Uint8Array.from(otherUint8Array),
-);
+bench("Uint8Array.from(otherUint8Array)", () => Uint8Array.from(otherUint8Array));
run();
diff --git a/bench/log/bun.js b/bench/log/bun.js
index a2f5dd73e..43728fd64 100644
--- a/bench/log/bun.js
+++ b/bench/log/bun.js
@@ -1,7 +1,5 @@
import { bench, run } from "mitata";
bench("console.log('hello')", () => console.log("hello"));
-bench("console.log({ hello: 'object' })", () =>
- console.log({ hello: "object" }),
-);
+bench("console.log({ hello: 'object' })", () => console.log({ hello: "object" }));
await run();
diff --git a/bench/module-loader/create.js b/bench/module-loader/create.js
index 8c20307af..a26e2a61e 100644
--- a/bench/module-loader/create.js
+++ b/bench/module-loader/create.js
@@ -47,11 +47,7 @@ fs.writeFileSync(
output + `/file${count}.mjs`,
`
export const THE_END = true;
- ${
- saveStack
- ? `globalThis.evaluationOrder.push("${output}/file${count}.mjs");`
- : ""
- }
+ ${saveStack ? `globalThis.evaluationOrder.push("${output}/file${count}.mjs");` : ""}
`,
"utf8",
);
@@ -60,11 +56,7 @@ fs.writeFileSync(
output + `/file${count}.js`,
`
module.exports.THE_END = true;
- ${
- saveStack
- ? `globalThis.evaluationOrder.push("${output}/file${count}.js");`
- : ""
- }
+ ${saveStack ? `globalThis.evaluationOrder.push("${output}/file${count}.js");` : ""}
`,
"utf8",
);
diff --git a/bench/modules/node_os/bun.js b/bench/modules/node_os/bun.js
index 0047b77e7..217fae47d 100644
--- a/bench/modules/node_os/bun.js
+++ b/bench/modules/node_os/bun.js
@@ -1,5 +1,24 @@
import { bench, run } from "mitata";
-import { cpus, endianness, arch, uptime, networkInterfaces, getPriority, totalmem, freemem, homedir, hostname, loadavg, platform, release, setPriority, tmpdir, type, userInfo, version } from "node:os";
+import {
+ cpus,
+ endianness,
+ arch,
+ uptime,
+ networkInterfaces,
+ getPriority,
+ totalmem,
+ freemem,
+ homedir,
+ hostname,
+ loadavg,
+ platform,
+ release,
+ setPriority,
+ tmpdir,
+ type,
+ userInfo,
+ version,
+} from "node:os";
bench("cpus()", () => cpus());
bench("networkInterfaces()", () => networkInterfaces());
diff --git a/bench/modules/node_os/node.mjs b/bench/modules/node_os/node.mjs
index 0047b77e7..217fae47d 100644
--- a/bench/modules/node_os/node.mjs
+++ b/bench/modules/node_os/node.mjs
@@ -1,5 +1,24 @@
import { bench, run } from "mitata";
-import { cpus, endianness, arch, uptime, networkInterfaces, getPriority, totalmem, freemem, homedir, hostname, loadavg, platform, release, setPriority, tmpdir, type, userInfo, version } from "node:os";
+import {
+ cpus,
+ endianness,
+ arch,
+ uptime,
+ networkInterfaces,
+ getPriority,
+ totalmem,
+ freemem,
+ homedir,
+ hostname,
+ loadavg,
+ platform,
+ release,
+ setPriority,
+ tmpdir,
+ type,
+ userInfo,
+ version,
+} from "node:os";
bench("cpus()", () => cpus());
bench("networkInterfaces()", () => networkInterfaces());
diff --git a/bench/package.json b/bench/package.json
index 3129defe8..9cd47e043 100644
--- a/bench/package.json
+++ b/bench/package.json
@@ -17,5 +17,6 @@
},
"devDependencies": {
"fast-deep-equal": "^3.1.3"
- }
+ },
+ "prettier": "../.prettierrc.cjs"
}
diff --git a/bench/react-hello-world/react-hello-world.deno.jsx b/bench/react-hello-world/react-hello-world.deno.jsx
index fabbfcfcb..0bea2574a 100644
--- a/bench/react-hello-world/react-hello-world.deno.jsx
+++ b/bench/react-hello-world/react-hello-world.deno.jsx
@@ -18,8 +18,8 @@ const headers = {
};
Deno.serve(
- async (req) => {
+ async req => {
return new Response(await renderToReadableStream(<App />), headers);
},
- { port: 8080 }
+ { port: 8080 },
);
diff --git a/bench/react-hello-world/react-hello-world.node.js b/bench/react-hello-world/react-hello-world.node.js
index df9f0eaee..f2c7ae635 100644
--- a/bench/react-hello-world/react-hello-world.node.js
+++ b/bench/react-hello-world/react-hello-world.node.js
@@ -17,15 +17,9 @@ var Kd = (e, n, i, s) => {
return e;
};
var Dc = (e, n, i) => (
- (i = e != null ? Gd(Jd(e)) : {}),
- Kd(
- n || !e || !e.__esModule
- ? Ac(i, "default", { value: e, enumerable: !0 })
- : i,
- e
- )
+ (i = e != null ? Gd(Jd(e)) : {}), Kd(n || !e || !e.__esModule ? Ac(i, "default", { value: e, enumerable: !0 }) : i, e)
);
-var Nc = an(($) => {
+var Nc = an($ => {
"use strict";
var Ai = Symbol.for("react.element"),
qd = Symbol.for("react.portal"),
@@ -42,8 +36,7 @@ var Nc = an(($) => {
function up(e) {
return e === null || typeof e != "object"
? null
- : ((e = (Oc && e[Oc]) || e["@@iterator"]),
- typeof e == "function" ? e : null);
+ : ((e = (Oc && e[Oc]) || e["@@iterator"]), typeof e == "function" ? e : null);
}
var Bc = {
isMounted: function () {
@@ -56,16 +49,13 @@ var Nc = an(($) => {
Uc = Object.assign,
jc = {};
function sa(e, n, i) {
- (this.props = e),
- (this.context = n),
- (this.refs = jc),
- (this.updater = i || Bc);
+ (this.props = e), (this.context = n), (this.refs = jc), (this.updater = i || Bc);
}
sa.prototype.isReactComponent = {};
sa.prototype.setState = function (e, n) {
if (typeof e != "object" && typeof e != "function" && e != null)
throw Error(
- "setState(...): takes an object of state variables to update or a function which returns an object of state variables."
+ "setState(...): takes an object of state variables to update or a function which returns an object of state variables.",
);
this.updater.enqueueSetState(this, e, n, "setState");
};
@@ -75,10 +65,7 @@ var Nc = an(($) => {
function Hc() {}
Hc.prototype = sa.prototype;
function Hu(e, n, i) {
- (this.props = e),
- (this.context = n),
- (this.refs = jc),
- (this.updater = i || Bc);
+ (this.props = e), (this.context = n), (this.refs = jc), (this.updater = i || Bc);
}
var Wu = (Hu.prototype = new Hc());
Wu.constructor = Hu;
@@ -94,9 +81,7 @@ var Nc = an(($) => {
c = null,
m = null;
if (n != null)
- for (s in (n.ref !== void 0 && (m = n.ref),
- n.key !== void 0 && (c = "" + n.key),
- n))
+ for (s in (n.ref !== void 0 && (m = n.ref), n.key !== void 0 && (c = "" + n.key), n))
Wc.call(n, s) && !zc.hasOwnProperty(s) && (v[s] = n[s]);
var S = arguments.length - 2;
if (S === 1) v.children = i;
@@ -104,8 +89,7 @@ var Nc = an(($) => {
for (var E = Array(S), x = 0; x < S; x++) E[x] = arguments[x + 2];
v.children = E;
}
- if (e && e.defaultProps)
- for (s in ((S = e.defaultProps), S)) v[s] === void 0 && (v[s] = S[s]);
+ if (e && e.defaultProps) for (s in ((S = e.defaultProps), S)) v[s] === void 0 && (v[s] = S[s]);
return {
$$typeof: Ai,
type: e,
@@ -139,9 +123,7 @@ var Nc = an(($) => {
}
var Lc = /\/+/g;
function ju(e, n) {
- return typeof e == "object" && e !== null && e.key != null
- ? fp("" + e.key)
- : n.toString(36);
+ return typeof e == "object" && e !== null && e.key != null ? fp("" + e.key) : n.toString(36);
}
function Ml(e, n, i, s, v) {
var c = typeof e;
@@ -174,14 +156,7 @@ var Nc = an(($) => {
}))
: v != null &&
($u(v) &&
- (v = cp(
- v,
- i +
- (!v.key || (m && m.key === v.key)
- ? ""
- : ("" + v.key).replace(Lc, "$&/") + "/") +
- e
- )),
+ (v = cp(v, i + (!v.key || (m && m.key === v.key) ? "" : ("" + v.key).replace(Lc, "$&/") + "/") + e)),
n.push(v)),
1
);
@@ -192,17 +167,14 @@ var Nc = an(($) => {
m += Ml(c, n, i, E, v);
}
else if (((E = up(e)), typeof E == "function"))
- for (e = E.call(e), S = 0; !(c = e.next()).done; )
- (c = c.value), (E = s + ju(c, S++)), (m += Ml(c, n, i, E, v));
+ for (e = E.call(e), S = 0; !(c = e.next()).done; ) (c = c.value), (E = s + ju(c, S++)), (m += Ml(c, n, i, E, v));
else if (c === "object")
throw (
((n = String(e)),
Error(
"Objects are not valid as a React child (found: " +
- (n === "[object Object]"
- ? "object with keys {" + Object.keys(e).join(", ") + "}"
- : n) +
- "). If you meant to render a collection of children, use an array instead."
+ (n === "[object Object]" ? "object with keys {" + Object.keys(e).join(", ") + "}" : n) +
+ "). If you meant to render a collection of children, use an array instead.",
))
);
return m;
@@ -224,13 +196,11 @@ var Nc = an(($) => {
(n = n()),
n.then(
function (i) {
- (e._status === 0 || e._status === -1) &&
- ((e._status = 1), (e._result = i));
+ (e._status === 0 || e._status === -1) && ((e._status = 1), (e._result = i));
},
function (i) {
- (e._status === 0 || e._status === -1) &&
- ((e._status = 2), (e._result = i));
- }
+ (e._status === 0 || e._status === -1) && ((e._status = 2), (e._result = i));
+ },
),
e._status === -1 && ((e._status = 0), (e._result = n));
}
@@ -252,7 +222,7 @@ var Nc = an(($) => {
function () {
n.apply(this, arguments);
},
- i
+ i,
);
},
count: function (e) {
@@ -272,10 +242,7 @@ var Nc = an(($) => {
);
},
only: function (e) {
- if (!$u(e))
- throw Error(
- "React.Children.only expected to receive a single React element child."
- );
+ if (!$u(e)) throw Error("React.Children.only expected to receive a single React element child.");
return e;
},
};
@@ -288,11 +255,7 @@ var Nc = an(($) => {
$.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = pp;
$.cloneElement = function (e, n, i) {
if (e == null)
- throw Error(
- "React.cloneElement(...): The argument must be a React element, but you passed " +
- e +
- "."
- );
+ throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + e + ".");
var s = Uc({}, e.props),
v = e.key,
c = e.ref,
@@ -304,10 +267,7 @@ var Nc = an(($) => {
e.type && e.type.defaultProps)
)
var S = e.type.defaultProps;
- for (E in n)
- Wc.call(n, E) &&
- !zc.hasOwnProperty(E) &&
- (s[E] = n[E] === void 0 && S !== void 0 ? S[E] : n[E]);
+ for (E in n) Wc.call(n, E) && !zc.hasOwnProperty(E) && (s[E] = n[E] === void 0 && S !== void 0 ? S[E] : n[E]);
}
var E = arguments.length - 2;
if (E === 1) s.children = i;
@@ -415,8 +375,7 @@ var Vc = an((N, Bl) => {
(function () {
"use strict";
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" &&
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ==
- "function" &&
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" &&
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
var e = "18.2.0",
n = Symbol.for("react.element"),
@@ -475,23 +434,13 @@ var Vc = an((N, Bl) => {
(ft.ReactDebugCurrentFrame = _e), (ft.ReactCurrentActQueue = q);
function Me(h) {
{
- for (
- var b = arguments.length, k = new Array(b > 1 ? b - 1 : 0), T = 1;
- T < b;
- T++
- )
- k[T - 1] = arguments[T];
+ for (var b = arguments.length, k = new Array(b > 1 ? b - 1 : 0), T = 1; T < b; T++) k[T - 1] = arguments[T];
Er("warn", h, k);
}
}
function B(h) {
{
- for (
- var b = arguments.length, k = new Array(b > 1 ? b - 1 : 0), T = 1;
- T < b;
- T++
- )
- k[T - 1] = arguments[T];
+ for (var b = arguments.length, k = new Array(b > 1 ? b - 1 : 0), T = 1; T < b; T++) k[T - 1] = arguments[T];
Er("error", h, k);
}
}
@@ -503,8 +452,7 @@ var Vc = an((N, Bl) => {
var U = k.map(function (M) {
return String(M);
});
- U.unshift("Warning: " + b),
- Function.prototype.apply.call(console[h], console, U);
+ U.unshift("Warning: " + b), Function.prototype.apply.call(console[h], console, U);
}
}
var tt = {};
@@ -517,7 +465,7 @@ var Vc = an((N, Bl) => {
B(
"Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",
b,
- T
+ T,
),
(tt[I] = !0);
}
@@ -540,16 +488,13 @@ var Vc = an((N, Bl) => {
er = {};
Object.freeze(er);
function re(h, b, k) {
- (this.props = h),
- (this.context = b),
- (this.refs = er),
- (this.updater = k || bt);
+ (this.props = h), (this.context = b), (this.refs = er), (this.updater = k || bt);
}
(re.prototype.isReactComponent = {}),
(re.prototype.setState = function (h, b) {
if (typeof h != "object" && typeof h != "function" && h != null)
throw new Error(
- "setState(...): takes an object of state variables to update or a function which returns an object of state variables."
+ "setState(...): takes an object of state variables to update or a function which returns an object of state variables.",
);
this.updater.enqueueSetState(this, h, b, "setState");
}),
@@ -570,11 +515,7 @@ var Vc = an((N, Bl) => {
tr = function (h, b) {
Object.defineProperty(re.prototype, h, {
get: function () {
- Me(
- "%s(...) is deprecated in plain JavaScript React classes. %s",
- b[0],
- b[1]
- );
+ Me("%s(...) is deprecated in plain JavaScript React classes. %s", b[0], b[1]);
},
});
};
@@ -583,15 +524,10 @@ var Vc = an((N, Bl) => {
function nr() {}
nr.prototype = re.prototype;
function Rr(h, b, k) {
- (this.props = h),
- (this.context = b),
- (this.refs = er),
- (this.updater = k || bt);
+ (this.props = h), (this.context = b), (this.refs = er), (this.updater = k || bt);
}
var St = (Rr.prototype = new nr());
- (St.constructor = Rr),
- Le(St, re.prototype),
- (St.isPureReactComponent = !0);
+ (St.constructor = Rr), Le(St, re.prototype), (St.isPureReactComponent = !0);
function so() {
var h = { current: null };
return Object.seal(h), h;
@@ -622,7 +558,7 @@ var Vc = an((N, Bl) => {
return (
B(
"The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",
- ve(h)
+ ve(h),
),
or(h)
);
@@ -641,7 +577,7 @@ var Vc = an((N, Bl) => {
if (
(typeof h.tag == "number" &&
B(
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.",
),
typeof h == "function")
)
@@ -713,11 +649,10 @@ var Vc = an((N, Bl) => {
((lr = !0),
B(
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",
- b
+ b,
));
};
- (k.isReactWarning = !0),
- Object.defineProperty(h, "key", { get: k, configurable: !0 });
+ (k.isReactWarning = !0), Object.defineProperty(h, "key", { get: k, configurable: !0 });
}
function va(h, b) {
var k = function () {
@@ -725,25 +660,19 @@ var Vc = an((N, Bl) => {
((fn = !0),
B(
"%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",
- b
+ b,
));
};
- (k.isReactWarning = !0),
- Object.defineProperty(h, "ref", { get: k, configurable: !0 });
+ (k.isReactWarning = !0), Object.defineProperty(h, "ref", { get: k, configurable: !0 });
}
function ga(h) {
- if (
- typeof h.ref == "string" &&
- xe.current &&
- h.__self &&
- xe.current.stateNode !== h.__self
- ) {
+ if (typeof h.ref == "string" && xe.current && h.__self && xe.current.stateNode !== h.__self) {
var b = dt(xe.current.type);
sr[b] ||
(B(
'Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',
b,
- h.ref
+ h.ref,
),
(sr[b] = !0));
}
@@ -799,8 +728,7 @@ var Vc = an((N, Bl) => {
for (T in ee) I[T] === void 0 && (I[T] = ee[T]);
}
if (U || M) {
- var fe =
- typeof h == "function" ? h.displayName || h.name || "Unknown" : h;
+ var fe = typeof h == "function" ? h.displayName || h.name || "Unknown" : h;
U && po(I, fe), M && va(I, fe);
}
return dn(h, U, M, H, z, xe.current, I);
@@ -811,11 +739,7 @@ var Vc = an((N, Bl) => {
}
function pn(h, b, k) {
if (h == null)
- throw new Error(
- "React.cloneElement(...): The argument must be a React element, but you passed " +
- h +
- "."
- );
+ throw new Error("React.cloneElement(...): The argument must be a React element, but you passed " + h + ".");
var T,
I = Le({}, h.props),
U = h.key,
@@ -824,20 +748,16 @@ var Vc = an((N, Bl) => {
z = h._source,
Y = h._owner;
if (b != null) {
- pt(b) && ((M = b.ref), (Y = xe.current)),
- ke(b) && (je(b.key), (U = "" + b.key));
+ pt(b) && ((M = b.ref), (Y = xe.current)), ke(b) && (je(b.key), (U = "" + b.key));
var Q;
h.type && h.type.defaultProps && (Q = h.type.defaultProps);
for (T in b)
- ir.call(b, T) &&
- !fo.hasOwnProperty(T) &&
- (b[T] === void 0 && Q !== void 0 ? (I[T] = Q[T]) : (I[T] = b[T]));
+ ir.call(b, T) && !fo.hasOwnProperty(T) && (b[T] === void 0 && Q !== void 0 ? (I[T] = Q[T]) : (I[T] = b[T]));
}
var K = arguments.length - 2;
if (K === 1) I.children = k;
else if (K > 1) {
- for (var ee = Array(K), fe = 0; fe < K; fe++)
- ee[fe] = arguments[fe + 2];
+ for (var ee = Array(K), fe = 0; fe < K; fe++) ee[fe] = arguments[fe + 2];
I.children = ee;
}
return dn(h.type, U, M, H, z, Y, I);
@@ -861,9 +781,7 @@ var Vc = an((N, Bl) => {
return h.replace(hn, "$&/");
}
function Ir(h, b) {
- return typeof h == "object" && h !== null && h.key != null
- ? (je(h.key), go("" + h.key))
- : b.toString(36);
+ return typeof h == "object" && h !== null && h.key != null ? (je(h.key), go("" + h.key)) : b.toString(36);
}
function ur(h, b, k, T, I) {
var U = typeof h;
@@ -897,14 +815,7 @@ var Vc = an((N, Bl) => {
z != null &&
(wt(z) &&
(z.key && (!H || H.key !== z.key) && je(z.key),
- (z = ma(
- z,
- k +
- (z.key && (!H || H.key !== z.key)
- ? vn("" + z.key) + "/"
- : "") +
- Y
- ))),
+ (z = ma(z, k + (z.key && (!H || H.key !== z.key) ? vn("" + z.key) + "/" : "") + Y))),
b.push(z));
return 1;
}
@@ -912,31 +823,22 @@ var Vc = an((N, Bl) => {
ee,
fe = 0,
Se = T === "" ? Te : T + vo;
- if (ye(h))
- for (var yr = 0; yr < h.length; yr++)
- (K = h[yr]), (ee = Se + Ir(K, yr)), (fe += ur(K, b, k, ee, I));
+ if (ye(h)) for (var yr = 0; yr < h.length; yr++) (K = h[yr]), (ee = Se + Ir(K, yr)), (fe += ur(K, b, k, ee, I));
else {
var Pn = P(h);
if (typeof Pn == "function") {
var Wr = h;
Pn === Wr.entries &&
- (xt ||
- Me(
- "Using Maps as children is not supported. Use an array of keyed ReactElements instead."
- ),
+ (xt || Me("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),
(xt = !0));
for (var Co = Pn.call(Wr), zr, Oa = 0; !(zr = Co.next()).done; )
- (K = zr.value),
- (ee = Se + Ir(K, Oa++)),
- (fe += ur(K, b, k, ee, I));
+ (K = zr.value), (ee = Se + Ir(K, Oa++)), (fe += ur(K, b, k, ee, I));
} else if (U === "object") {
var Eo = String(h);
throw new Error(
"Objects are not valid as a React child (found: " +
- (Eo === "[object Object]"
- ? "object with keys {" + Object.keys(h).join(", ") + "}"
- : Eo) +
- "). If you meant to render a collection of children, use an array instead."
+ (Eo === "[object Object]" ? "object with keys {" + Object.keys(h).join(", ") + "}" : Eo) +
+ "). If you meant to render a collection of children, use an array instead.",
);
}
}
@@ -968,7 +870,7 @@ var Vc = an((N, Bl) => {
function () {
b.apply(this, arguments);
},
- k
+ k,
);
}
function mo(h) {
@@ -979,10 +881,7 @@ var Vc = an((N, Bl) => {
);
}
function Ut(h) {
- if (!wt(h))
- throw new Error(
- "React.Children.only expected to receive a single React element child."
- );
+ if (!wt(h)) throw new Error("React.Children.only expected to receive a single React element child.");
return h;
}
function gn(h) {
@@ -1009,7 +908,7 @@ var Vc = an((N, Bl) => {
T ||
((T = !0),
B(
- "Rendering <Context.Consumer.Provider> is not supported and will be removed in a future major release. Did you mean to render <Context.Provider> instead?"
+ "Rendering <Context.Consumer.Provider> is not supported and will be removed in a future major release. Did you mean to render <Context.Provider> instead?",
)),
b.Provider
);
@@ -1048,7 +947,7 @@ var Vc = an((N, Bl) => {
k ||
((k = !0),
B(
- "Rendering <Context.Consumer.Consumer> is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?"
+ "Rendering <Context.Consumer.Consumer> is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?",
)),
b.Consumer
);
@@ -1062,7 +961,7 @@ var Vc = an((N, Bl) => {
I ||
(Me(
"Setting `displayName` on Context.Consumer has no effect. You should set it directly on the context with Context.displayName = '%s'.",
- M
+ M,
),
(I = !0));
},
@@ -1093,7 +992,7 @@ var Vc = an((N, Bl) => {
var M = h;
(M._status = Sa), (M._result = U);
}
- }
+ },
),
h._status === jt)
) {
@@ -1112,7 +1011,7 @@ Your code should look like:
const MyComponent = lazy(() => import('./MyComponent'))
Did you accidentally put curly braces around the import?`,
- I
+ I,
),
"default" in I ||
B(
@@ -1120,7 +1019,7 @@ Did you accidentally put curly braces around the import?`,
Your code should look like:
const MyComponent = lazy(() => import('./MyComponent'))`,
- I
+ I,
),
I.default
);
@@ -1139,7 +1038,7 @@ Your code should look like:
},
set: function (U) {
B(
- "React.lazy(...): It is not supported to assign `defaultProps` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it."
+ "React.lazy(...): It is not supported to assign `defaultProps` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it.",
),
(T = U),
Object.defineProperty(k, "defaultProps", { enumerable: !0 });
@@ -1152,7 +1051,7 @@ Your code should look like:
},
set: function (U) {
B(
- "React.lazy(...): It is not supported to assign `propTypes` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it."
+ "React.lazy(...): It is not supported to assign `propTypes` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it.",
),
(I = U),
Object.defineProperty(k, "propTypes", { enumerable: !0 });
@@ -1165,25 +1064,22 @@ Your code should look like:
function ka(h) {
h != null && h.$$typeof === D
? B(
- "forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
+ "forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...)).",
)
: typeof h != "function"
- ? B(
- "forwardRef requires a render function but was given %s.",
- h === null ? "null" : typeof h
- )
+ ? B("forwardRef requires a render function but was given %s.", h === null ? "null" : typeof h)
: h.length !== 0 &&
h.length !== 2 &&
B(
"forwardRef render functions accept exactly two parameters: props and ref. %s",
h.length === 1
? "Did you forget to use the ref parameter?"
- : "Any additional parameter will be undefined."
+ : "Any additional parameter will be undefined.",
),
h != null &&
(h.defaultProps != null || h.propTypes != null) &&
B(
- "forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?"
+ "forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?",
);
var b = { $$typeof: E, render: h };
{
@@ -1231,10 +1127,7 @@ Your code should look like:
}
function Ta(h, b) {
yo(h) ||
- B(
- "memo: The first argument must be a component. Instead received: %s",
- h === null ? "null" : typeof h
- );
+ B("memo: The first argument must be a component. Instead received: %s", h === null ? "null" : typeof h);
var k = { $$typeof: D, type: h, compare: b === void 0 ? null : b };
{
var T;
@@ -1269,11 +1162,11 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
var k = h._context;
k.Consumer === h
? B(
- "Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be removed in a future major release. Did you mean to call useContext(Context) instead?"
+ "Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be removed in a future major release. Did you mean to call useContext(Context) instead?",
)
: k.Provider === h &&
B(
- "Calling useContext(Context.Provider) is not supported. Did you mean to call useContext(Context) instead?"
+ "Calling useContext(Context.Provider) is not supported. Did you mean to call useContext(Context) instead?",
);
}
return b.useContext(h);
@@ -1389,10 +1282,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
groupEnd: Le({}, h, { value: Et }),
});
}
- Tt < 0 &&
- B(
- "disabledDepth fell below zero. This is a bug in React. Please file an issue."
- );
+ Tt < 0 && B("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
}
}
var Ee = ft.ReactCurrentDispatcher,
@@ -1489,9 +1379,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
`
` + H[Y].replace(" at new ", " at ");
return (
- h.displayName &&
- K.includes("<anonymous>") &&
- (K = K.replace("<anonymous>", h.displayName)),
+ h.displayName && K.includes("<anonymous>") && (K = K.replace("<anonymous>", h.displayName)),
typeof h == "function" && Br.set(h, K),
K
);
@@ -1566,18 +1454,11 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
M +
"` is invalid; it must be a function, usually from the `prop-types` package, but received `" +
typeof h[M] +
- "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
+ "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.",
);
throw ((z.name = "Invariant Violation"), z);
}
- H = h[M](
- b,
- M,
- T,
- k,
- null,
- "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"
- );
+ H = h[M](b, M, T, k, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
} catch (Y) {
H = Y;
}
@@ -1589,15 +1470,12 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
T || "React class",
k,
M,
- typeof H
+ typeof H,
),
pr(null)),
H instanceof Error &&
!(H.message in Ce) &&
- ((Ce[H.message] = !0),
- pr(I),
- B("Failed %s type: %s", k, H.message),
- pr(null));
+ ((Ce[H.message] = !0), pr(I), B("Failed %s type: %s", k, H.message), pr(null));
}
}
}
@@ -1665,15 +1543,12 @@ Check the top-level render call using <` +
if (!Ur[k]) {
Ur[k] = !0;
var T = "";
- h &&
- h._owner &&
- h._owner !== xe.current &&
- (T = " It was passed a child from " + dt(h._owner.type) + "."),
+ h && h._owner && h._owner !== xe.current && (T = " It was passed a child from " + dt(h._owner.type) + "."),
It(h),
B(
'Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',
k,
- T
+ T,
),
It(null);
}
@@ -1690,8 +1565,7 @@ Check the top-level render call using <` +
else if (h) {
var I = P(h);
if (typeof I == "function" && I !== h.entries)
- for (var U = I.call(h), M; !(M = U.next()).done; )
- wt(M.value) && Je(M.value, b);
+ for (var U = I.call(h), M; !(M = U.next()).done; ) wt(M.value) && Je(M.value, b);
}
}
}
@@ -1701,11 +1575,7 @@ Check the top-level render call using <` +
if (b == null || typeof b == "string") return;
var k;
if (typeof b == "function") k = b.propTypes;
- else if (
- typeof b == "object" &&
- (b.$$typeof === E || b.$$typeof === D)
- )
- k = b.propTypes;
+ else if (typeof b == "object" && (b.$$typeof === E || b.$$typeof === D)) k = b.propTypes;
else return;
if (k) {
var T = dt(b);
@@ -1715,13 +1585,13 @@ Check the top-level render call using <` +
var I = dt(b);
B(
"Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",
- I || "Unknown"
+ I || "Unknown",
);
}
typeof b.getDefaultProps == "function" &&
!b.getDefaultProps.isReactClassApproved &&
B(
- "getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."
+ "getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.",
);
}
}
@@ -1733,26 +1603,20 @@ Check the top-level render call using <` +
It(h),
B(
"Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",
- T
+ T,
),
It(null);
break;
}
}
- h.ref !== null &&
- (It(h),
- B("Invalid attribute `ref` supplied to `React.Fragment`."),
- It(null));
+ h.ref !== null && (It(h), B("Invalid attribute `ref` supplied to `React.Fragment`."), It(null));
}
}
function kn(h, b, k) {
var T = yo(h);
if (!T) {
var I = "";
- (h === void 0 ||
- (typeof h == "object" &&
- h !== null &&
- Object.keys(h).length === 0)) &&
+ (h === void 0 || (typeof h == "object" && h !== null && Object.keys(h).length === 0)) &&
(I +=
" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
var U = vt(b);
@@ -1764,13 +1628,12 @@ Check the top-level render call using <` +
? (M = "array")
: h !== void 0 && h.$$typeof === n
? ((M = "<" + (dt(h.type) || "Unknown") + " />"),
- (I =
- " Did you accidentally export a JSX literal instead of a component?"))
+ (I = " Did you accidentally export a JSX literal instead of a component?"))
: (M = typeof h),
B(
"React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",
M,
- I
+ I,
);
}
var H = ho.apply(this, arguments);
@@ -1786,15 +1649,13 @@ Check the top-level render call using <` +
Tn ||
((Tn = !0),
Me(
- "React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead."
+ "React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.",
)),
Object.defineProperty(b, "type", {
enumerable: !1,
get: function () {
return (
- Me(
- "Factory.type is deprecated. Access the class directly before passing it to createFactory."
- ),
+ Me("Factory.type is deprecated. Access the class directly before passing it to createFactory."),
Object.defineProperty(this, "type", { value: h }),
h
);
@@ -1804,12 +1665,7 @@ Check the top-level render call using <` +
);
}
function ko(h, b, k) {
- for (
- var T = pn.apply(this, arguments), I = 2;
- I < arguments.length;
- I++
- )
- xn(arguments[I], T.type);
+ for (var T = pn.apply(this, arguments), I = 2; I < arguments.length; I++) xn(arguments[I], T.type);
return gr(T), T;
}
function To(h, b) {
@@ -1824,7 +1680,7 @@ Check the top-level render call using <` +
var I = T._updatedFibers.size;
I > 10 &&
Me(
- "Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
+ "Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.",
),
T._updatedFibers.clear();
}
@@ -1844,7 +1700,7 @@ Check the top-level render call using <` +
((Cn = !0),
typeof MessageChannel > "u" &&
B(
- "This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."
+ "This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning.",
));
var U = new MessageChannel();
(U.port1.onmessage = I), U.port2.postMessage(void 0);
@@ -1861,11 +1717,7 @@ Check the top-level render call using <` +
var k = q.isBatchingLegacy,
T;
try {
- if (
- ((q.isBatchingLegacy = !0),
- (T = h()),
- !k && q.didScheduleLegacyUpdate)
- ) {
+ if (((q.isBatchingLegacy = !0), (T = h()), !k && q.didScheduleLegacyUpdate)) {
var I = q.current;
I !== null && ((q.didScheduleLegacyUpdate = !1), Rn(I));
}
@@ -1874,11 +1726,7 @@ Check the top-level render call using <` +
} finally {
q.isBatchingLegacy = k;
}
- if (
- T !== null &&
- typeof T == "object" &&
- typeof T.then == "function"
- ) {
+ if (T !== null && typeof T == "object" && typeof T.then == "function") {
var U = T,
M = !1,
H = {
@@ -1890,7 +1738,7 @@ Check the top-level render call using <` +
},
function (Se) {
mr(b), fe(Se);
- }
+ },
);
},
};
@@ -1903,7 +1751,7 @@ Check the top-level render call using <` +
M ||
((Hr = !0),
B(
- "You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
+ "You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);",
));
}),
H
@@ -1915,9 +1763,7 @@ Check the top-level render call using <` +
Y !== null && (Rn(Y), (q.current = null));
var Q = {
then: function (ee, fe) {
- q.current === null
- ? ((q.current = []), Be(z, ee, fe))
- : ee(z);
+ q.current === null ? ((q.current = []), Be(z, ee, fe)) : ee(z);
},
};
return Q;
@@ -1935,7 +1781,7 @@ Check the top-level render call using <` +
function mr(h) {
h !== gt - 1 &&
B(
- "You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
+ "You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. ",
),
(gt = h);
}
@@ -2013,20 +1859,15 @@ Check the top-level render call using <` +
(N.useTransition = Ar),
(N.version = e),
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" &&
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ==
- "function" &&
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(
- new Error()
- );
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" &&
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
})();
});
var ua = an((_v, Nu) => {
"use strict";
- process.env.NODE_ENV === "production"
- ? (Nu.exports = Nc())
- : (Nu.exports = Vc());
+ process.env.NODE_ENV === "production" ? (Nu.exports = Nc()) : (Nu.exports = Vc());
});
-var Wf = an((ca) => {
+var Wf = an(ca => {
"use strict";
var pf = ua(),
hp = require("stream"),
@@ -2036,13 +1877,7 @@ var Wf = an((ca) => {
Yc = {},
Gc = {};
function hf(e) {
- return qe.call(Gc, e)
- ? !0
- : qe.call(Yc, e)
- ? !1
- : vp.test(e)
- ? (Gc[e] = !0)
- : ((Yc[e] = !0), !1);
+ return qe.call(Gc, e) ? !0 : qe.call(Yc, e) ? !1 : vp.test(e) ? (Gc[e] = !0) : ((Yc[e] = !0), !1);
}
function Ge(e, n, i, s, v, c, m) {
(this.acceptsBooleans = n === 2 || n === 3 || n === 4),
@@ -2072,12 +1907,7 @@ var Wf = an((ca) => {
["contentEditable", "draggable", "spellCheck", "value"].forEach(function (e) {
Fe[e] = new Ge(e, 2, !1, e.toLowerCase(), null, !1, !1);
});
- [
- "autoReverse",
- "externalResourcesRequired",
- "focusable",
- "preserveAlpha",
- ].forEach(function (e) {
+ ["autoReverse", "externalResourcesRequired", "focusable", "preserveAlpha"].forEach(function (e) {
Fe[e] = new Ge(e, 2, !1, e, null, !1, !1);
});
"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope"
@@ -2107,12 +1937,10 @@ var Wf = an((ca) => {
var n = e.replace(qu, ec);
Fe[n] = new Ge(n, 1, !1, e, null, !1, !1);
});
- "xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type"
- .split(" ")
- .forEach(function (e) {
- var n = e.replace(qu, ec);
- Fe[n] = new Ge(n, 1, !1, e, "http://www.w3.org/1999/xlink", !1, !1);
- });
+ "xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function (e) {
+ var n = e.replace(qu, ec);
+ Fe[n] = new Ge(n, 1, !1, e, "http://www.w3.org/1999/xlink", !1, !1);
+ });
["xml:base", "xml:lang", "xml:space"].forEach(function (e) {
var n = e.replace(qu, ec);
Fe[n] = new Ge(n, 1, !1, e, "http://www.w3.org/XML/1998/namespace", !1, !1);
@@ -2120,15 +1948,7 @@ var Wf = an((ca) => {
["tabIndex", "crossOrigin"].forEach(function (e) {
Fe[e] = new Ge(e, 1, !1, e.toLowerCase(), null, !1, !1);
});
- Fe.xlinkHref = new Ge(
- "xlinkHref",
- 1,
- !1,
- "xlink:href",
- "http://www.w3.org/1999/xlink",
- !0,
- !1
- );
+ Fe.xlinkHref = new Ge("xlinkHref", 1, !1, "xlink:href", "http://www.w3.org/1999/xlink", !0, !1);
["src", "href", "action", "formAction"].forEach(function (e) {
Fe[e] = new Ge(e, 1, !1, e.toLowerCase(), null, !0, !0);
});
@@ -2251,7 +2071,7 @@ var Wf = an((ca) => {
function vf(e, n, i) {
if (typeof i != "object")
throw Error(
- "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX."
+ "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX.",
);
n = !0;
for (var s in i)
@@ -2264,20 +2084,11 @@ var Wf = an((ca) => {
} else {
c = s;
var m = Xc.get(c);
- m !== void 0 ||
- ((m = Ye(c.replace(yp, "-$1").toLowerCase().replace(bp, "-ms-"))),
- Xc.set(c, m)),
+ m !== void 0 || ((m = Ye(c.replace(yp, "-$1").toLowerCase().replace(bp, "-ms-"))), Xc.set(c, m)),
(c = m),
- (v =
- typeof v == "number"
- ? v === 0 || qe.call(Hl, s)
- ? "" + v
- : v + "px"
- : Ye(("" + v).trim()));
+ (v = typeof v == "number" ? (v === 0 || qe.call(Hl, s) ? "" + v : v + "px") : Ye(("" + v).trim()));
}
- n
- ? ((n = !1), e.push(' style="', c, ":", v))
- : e.push(";", c, ":", v);
+ n ? ((n = !1), e.push(' style="', c, ":", v)) : e.push(";", c, ":", v);
}
}
n || e.push('"');
@@ -2294,11 +2105,7 @@ var Wf = an((ca) => {
case "suppressHydrationWarning":
return;
}
- if (
- !(2 < i.length) ||
- (i[0] !== "o" && i[0] !== "O") ||
- (i[1] !== "n" && i[1] !== "N")
- ) {
+ if (!(2 < i.length) || (i[0] !== "o" && i[0] !== "O") || (i[1] !== "n" && i[1] !== "N")) {
if (((n = Fe.hasOwnProperty(i) ? Fe[i] : null), n !== null)) {
switch (typeof s) {
case "function":
@@ -2312,9 +2119,7 @@ var Wf = an((ca) => {
s && e.push(" ", i, '=""');
break;
case 4:
- s === !0
- ? e.push(" ", i, '=""')
- : s !== !1 && e.push(" ", i, '="', Ye(s), '"');
+ s === !0 ? e.push(" ", i, '=""') : s !== !1 && e.push(" ", i, '="', Ye(s), '"');
break;
case 5:
isNaN(s) || e.push(" ", i, '="', Ye(s), '"');
@@ -2331,11 +2136,7 @@ var Wf = an((ca) => {
case "symbol":
return;
case "boolean":
- if (
- ((n = i.toLowerCase().slice(0, 5)),
- n !== "data-" && n !== "aria-")
- )
- return;
+ if (((n = i.toLowerCase().slice(0, 5)), n !== "data-" && n !== "aria-")) return;
}
e.push(" ", i, '="', Ye(s), '"');
}
@@ -2343,13 +2144,10 @@ var Wf = an((ca) => {
}
function Wl(e, n, i) {
if (n != null) {
- if (i != null)
- throw Error(
- "Can only set one of `children` or `props.dangerouslySetInnerHTML`."
- );
+ if (i != null) throw Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
if (typeof n != "object" || !("__html" in n))
throw Error(
- "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information."
+ "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information.",
);
(n = n.__html), n != null && e.push("" + n);
}
@@ -2382,9 +2180,7 @@ var Wf = an((ca) => {
it(e, s, c, m);
}
}
- return (
- e.push(">"), Wl(e, v, i), typeof i == "string" ? (e.push(Ye(i)), null) : i
- );
+ return e.push(">"), Wl(e, v, i), typeof i == "string" ? (e.push(Ye(i)), null) : i;
}
var xp = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,
Zc = new Map();
@@ -2471,19 +2267,13 @@ var Wf = an((ca) => {
m = E;
break;
case "dangerouslySetInnerHTML":
- throw Error(
- "`dangerouslySetInnerHTML` does not make sense on <textarea>."
- );
+ throw Error("`dangerouslySetInnerHTML` does not make sense on <textarea>.");
default:
it(e, s, S, E);
}
if ((c === null && m !== null && (c = m), e.push(">"), R != null)) {
- if (c != null)
- throw Error(
- "If you supply `defaultValue` on a <textarea>, do not pass children."
- );
- if (Xu(R) && 1 < R.length)
- throw Error("<textarea> can only have at most one child.");
+ if (c != null) throw Error("If you supply `defaultValue` on a <textarea>, do not pass children.");
+ if (Xu(R) && 1 < R.length) throw Error("<textarea> can only have at most one child.");
c = "" + R;
}
return (
@@ -2504,7 +2294,7 @@ var Wf = an((ca) => {
case "children":
case "dangerouslySetInnerHTML":
throw Error(
- "input is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`."
+ "input is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.",
);
case "defaultChecked":
E = x;
@@ -2522,12 +2312,8 @@ var Wf = an((ca) => {
it(e, s, m, x);
}
return (
- R !== null
- ? it(e, s, "checked", R)
- : E !== null && it(e, s, "checked", E),
- c !== null
- ? it(e, s, "value", c)
- : S !== null && it(e, s, "value", S),
+ R !== null ? it(e, s, "checked", R) : E !== null && it(e, s, "checked", E),
+ c !== null ? it(e, s, "value", c) : S !== null && it(e, s, "value", S),
e.push("/>"),
null
);
@@ -2538,9 +2324,7 @@ var Wf = an((ca) => {
switch (V) {
case "children":
case "dangerouslySetInnerHTML":
- throw Error(
- "menuitems cannot have `children` nor `dangerouslySetInnerHTML`."
- );
+ throw Error("menuitems cannot have `children` nor `dangerouslySetInnerHTML`.");
default:
it(e, s, V, c);
}
@@ -2554,9 +2338,7 @@ var Wf = an((ca) => {
c = m;
break;
case "dangerouslySetInnerHTML":
- throw Error(
- "`dangerouslySetInnerHTML` does not make sense on <title>."
- );
+ throw Error("`dangerouslySetInnerHTML` does not make sense on <title>.");
default:
it(e, s, D, m);
}
@@ -2577,13 +2359,10 @@ var Wf = an((ca) => {
it(e, s, E, S);
}
if ((e.push(">"), m != null)) {
- if (c != null)
- throw Error(
- "Can only set one of `children` or `props.dangerouslySetInnerHTML`."
- );
+ if (c != null) throw Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
if (typeof m != "object" || !("__html" in m))
throw Error(
- "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information."
+ "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information.",
);
(i = m.__html),
i != null &&
@@ -2595,7 +2374,7 @@ var Wf = an((ca) => {
? e.push(
`
`,
- i
+ i,
)
: e.push("" + i));
}
@@ -2629,8 +2408,7 @@ var Wf = an((ca) => {
case "children":
case "dangerouslySetInnerHTML":
throw Error(
- n +
- " is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`."
+ n + " is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.",
);
default:
it(e, s, te, c);
@@ -2646,12 +2424,9 @@ var Wf = an((ca) => {
case "missing-glyph":
return Vu(e, i, n, s);
case "html":
- return (
- v.insertionMode === 0 && e.push("<!DOCTYPE html>"), Vu(e, i, n, s)
- );
+ return v.insertionMode === 0 && e.push("<!DOCTYPE html>"), Vu(e, i, n, s);
default:
- if (n.indexOf("-") === -1 && typeof i.is != "string")
- return Vu(e, i, n, s);
+ if (n.indexOf("-") === -1 && typeof i.is != "string") return Vu(e, i, n, s);
e.push(Jt(n)), (m = c = null);
for (x in i)
if (qe.call(i, x) && ((S = i[x]), S != null))
@@ -2669,32 +2444,21 @@ var Wf = an((ca) => {
case "suppressHydrationWarning":
break;
default:
- hf(x) &&
- typeof S != "function" &&
- typeof S != "symbol" &&
- e.push(" ", x, '="', Ye(S), '"');
+ hf(x) && typeof S != "function" && typeof S != "symbol" && e.push(" ", x, '="', Ye(S), '"');
}
return e.push(">"), Wl(e, m, c), c;
}
}
function Jc(e, n, i) {
if ((e.push('<!--$?--><template id="'), i === null))
- throw Error(
- "An ID must have been assigned before we can complete the boundary."
- );
+ throw Error("An ID must have been assigned before we can complete the boundary.");
return e.push(i), e.push('"></template>');
}
function Tp(e, n, i, s) {
switch (i.insertionMode) {
case 0:
case 1:
- return (
- e.push('<div hidden id="'),
- e.push(n.segmentPrefix),
- (n = s.toString(16)),
- e.push(n),
- e.push('">')
- );
+ return e.push('<div hidden id="'), e.push(n.segmentPrefix), (n = s.toString(16)), e.push(n), e.push('">');
case 2:
return (
e.push('<svg aria-hidden="true" style="display:none" id="'),
@@ -2712,36 +2476,16 @@ var Wf = an((ca) => {
e.push('">')
);
case 4:
- return (
- e.push('<table hidden id="'),
- e.push(n.segmentPrefix),
- (n = s.toString(16)),
- e.push(n),
- e.push('">')
- );
+ return e.push('<table hidden id="'), e.push(n.segmentPrefix), (n = s.toString(16)), e.push(n), e.push('">');
case 5:
return (
- e.push('<table hidden><tbody id="'),
- e.push(n.segmentPrefix),
- (n = s.toString(16)),
- e.push(n),
- e.push('">')
+ e.push('<table hidden><tbody id="'), e.push(n.segmentPrefix), (n = s.toString(16)), e.push(n), e.push('">')
);
case 6:
- return (
- e.push('<table hidden><tr id="'),
- e.push(n.segmentPrefix),
- (n = s.toString(16)),
- e.push(n),
- e.push('">')
- );
+ return e.push('<table hidden><tr id="'), e.push(n.segmentPrefix), (n = s.toString(16)), e.push(n), e.push('">');
case 7:
return (
- e.push('<table hidden><colgroup id="'),
- e.push(n.segmentPrefix),
- (n = s.toString(16)),
- e.push(n),
- e.push('">')
+ e.push('<table hidden><colgroup id="'), e.push(n.segmentPrefix), (n = s.toString(16)), e.push(n), e.push('">')
);
default:
throw Error("Unknown insertion mode. This is a bug in React.");
@@ -2780,7 +2524,7 @@ var Wf = an((ca) => {
return "\\u2029";
default:
throw Error(
- "escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React"
+ "escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React",
);
}
});
@@ -2809,10 +2553,7 @@ var Wf = an((ca) => {
function Qc(e, n, i, s) {
return i.generateStaticMarkup
? (e.push(Ye(n)), !1)
- : (n === ""
- ? (e = s)
- : (s && e.push("<!-- -->"), e.push(Ye(n)), (e = !0)),
- e);
+ : (n === "" ? (e = s) : (s && e.push("<!-- -->"), e.push(Ye(n)), (e = !0)), e);
}
var Mi = Object.assign,
Rp = Symbol.for("react.element"),
@@ -2860,15 +2601,11 @@ var Wf = an((ca) => {
var n = e.render;
return (
(e = e.displayName),
- e ||
- ((e = n.displayName || n.name || ""),
- (e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef")),
+ e || ((e = n.displayName || n.name || ""), (e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef")),
e
);
case Rf:
- return (
- (n = e.displayName || null), n !== null ? n : Zu(e.type) || "Memo"
- );
+ return (n = e.displayName || null), n !== null ? n : Zu(e.type) || "Memo";
case tc:
(n = e._payload), (e = e._init);
try {
@@ -2891,46 +2628,31 @@ var Wf = an((ca) => {
(e.context._currentValue2 = e.parentValue), (e = e.parent);
var i = n.parent;
if (e === null) {
- if (i !== null)
- throw Error(
- "The stacks must reach the root at the same time. This is a bug in React."
- );
+ if (i !== null) throw Error("The stacks must reach the root at the same time. This is a bug in React.");
} else {
- if (i === null)
- throw Error(
- "The stacks must reach the root at the same time. This is a bug in React."
- );
+ if (i === null) throw Error("The stacks must reach the root at the same time. This is a bug in React.");
Jl(e, i);
}
n.context._currentValue2 = n.value;
}
}
function _f(e) {
- (e.context._currentValue2 = e.parentValue),
- (e = e.parent),
- e !== null && _f(e);
+ (e.context._currentValue2 = e.parentValue), (e = e.parent), e !== null && _f(e);
}
function Pf(e) {
var n = e.parent;
n !== null && Pf(n), (e.context._currentValue2 = e.value);
}
function Ff(e, n) {
- if (
- ((e.context._currentValue2 = e.parentValue), (e = e.parent), e === null)
- )
- throw Error(
- "The depth must equal at least at zero before reaching the root. This is a bug in React."
- );
+ if (((e.context._currentValue2 = e.parentValue), (e = e.parent), e === null))
+ throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");
e.depth === n.depth ? Jl(e, n) : Ff(e, n);
}
function Af(e, n) {
var i = n.parent;
if (i === null)
- throw Error(
- "The depth must equal at least at zero before reaching the root. This is a bug in React."
- );
- e.depth === i.depth ? Jl(e, i) : Af(e, i),
- (n.context._currentValue2 = n.value);
+ throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");
+ e.depth === i.depth ? Jl(e, i) : Af(e, i), (n.context._currentValue2 = n.value);
}
function Vl(e) {
var n = ro;
@@ -2967,35 +2689,21 @@ var Wf = an((ca) => {
if (
((e.context = typeof m == "object" && m !== null ? m._currentValue2 : s),
(m = n.getDerivedStateFromProps),
- typeof m == "function" &&
- ((m = m(i, v)), (v = m == null ? v : Mi({}, v, m)), (e.state = v)),
+ typeof m == "function" && ((m = m(i, v)), (v = m == null ? v : Mi({}, v, m)), (e.state = v)),
typeof n.getDerivedStateFromProps != "function" &&
typeof e.getSnapshotBeforeUpdate != "function" &&
- (typeof e.UNSAFE_componentWillMount == "function" ||
- typeof e.componentWillMount == "function"))
+ (typeof e.UNSAFE_componentWillMount == "function" || typeof e.componentWillMount == "function"))
)
if (
((n = e.state),
typeof e.componentWillMount == "function" && e.componentWillMount(),
- typeof e.UNSAFE_componentWillMount == "function" &&
- e.UNSAFE_componentWillMount(),
+ typeof e.UNSAFE_componentWillMount == "function" && e.UNSAFE_componentWillMount(),
n !== e.state && ef.enqueueReplaceState(e, e.state, null),
c.queue !== null && 0 < c.queue.length)
)
- if (
- ((n = c.queue),
- (m = c.replace),
- (c.queue = null),
- (c.replace = !1),
- m && n.length === 1)
- )
- e.state = n[0];
+ if (((n = c.queue), (m = c.replace), (c.queue = null), (c.replace = !1), m && n.length === 1)) e.state = n[0];
else {
- for (
- c = m ? n[0] : e.state, v = !0, m = m ? 1 : 0;
- m < n.length;
- m++
- ) {
+ for (c = m ? n[0] : e.state, v = !0, m = m ? 1 : 0; m < n.length; m++) {
var S = n[m];
(S = typeof S == "function" ? S.call(e, c, i, s) : S),
S != null && (v ? ((v = !1), (c = Mi({}, c, S))) : Mi(c, S));
@@ -3051,8 +2759,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return kr;
}
function rf() {
- if (0 < Ql)
- throw Error("Rendered more hooks than during the previous render");
+ if (0 < Ql) throw Error("Rendered more hooks than during the previous render");
return { memoizedState: null, queue: null, next: null };
}
function nc() {
@@ -3085,14 +2792,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return [oe.memoizedState, n];
}
return (
- (e =
- e === Df
- ? typeof n == "function"
- ? n()
- : n
- : i !== void 0
- ? i(n)
- : n),
+ (e = e === Df ? (typeof n == "function" ? n() : n) : i !== void 0 ? i(n) : n),
(oe.memoizedState = e),
(e = oe.queue = { last: null, dispatch: null }),
(e = e.dispatch = Up.bind(null, kr, e)),
@@ -3100,9 +2800,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
);
}
function of(e, n) {
- if (
- ((kr = to()), (oe = nc()), (n = n === void 0 ? null : n), oe !== null)
- ) {
+ if (((kr = to()), (oe = nc()), (n = n === void 0 ? null : n), oe !== null)) {
var i = oe.memoizedState;
if (i !== null && n !== null) {
var s = i[1];
@@ -3121,18 +2819,9 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return (e = e()), (oe.memoizedState = [e, n]), e;
}
function Up(e, n, i) {
- if (25 <= Ql)
- throw Error(
- "Too many re-renders. React limits the number of renders to prevent an infinite loop."
- );
+ if (25 <= Ql) throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");
if (e === kr)
- if (
- ((Yl = !0),
- (e = { action: i, next: null }),
- ln === null && (ln = new Map()),
- (i = ln.get(n)),
- i === void 0)
- )
+ if (((Yl = !0), (e = { action: i, next: null }), ln === null && (ln = new Map()), (i = ln.get(n)), i === void 0))
ln.set(n, e);
else {
for (n = i; n.next !== null; ) n = n.next;
@@ -3182,15 +2871,8 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
(e = e.id), (e = (e & ~(1 << (32 - zl(e) - 1))).toString(32) + n);
var i = Nl;
if (i === null)
- throw Error(
- "Invalid hook call. Hooks can only be called inside of the body of a function component."
- );
- return (
- (n = Li++),
- (e = ":" + i.idPrefix + "R" + e),
- 0 < n && (e += "H" + n.toString(32)),
- e + ":"
- );
+ throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component.");
+ return (n = Li++), (e = ":" + i.idPrefix + "R" + e), 0 < n && (e += "H" + n.toString(32)), e + ":";
},
useMutableSource: function (e, n) {
return to(), n(e._source);
@@ -3198,15 +2880,13 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
useSyncExternalStore: function (e, n, i) {
if (i === void 0)
throw Error(
- "Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering."
+ "Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering.",
);
return i();
},
},
Nl = null,
- Gu =
- pf.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
- .ReactCurrentDispatcher;
+ Gu = pf.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;
function Hp(e) {
return console.error(e), null;
}
@@ -3279,7 +2959,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
throw Error(
'onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "' +
typeof e +
- '" instead'
+ '" instead',
);
return e;
}
@@ -3288,13 +2968,10 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
i(n),
(i = e.onFatalError),
i(n),
- e.destination !== null
- ? ((e.status = 2), e.destination.destroy(n))
- : ((e.status = 1), (e.fatalError = n));
+ e.destination !== null ? ((e.status = 2), e.destination.destroy(n)) : ((e.status = 1), (e.fatalError = n));
}
function lf(e, n, i, s, v) {
- for (kr = {}, rc = n, Li = 0, e = i(s, v); Yl; )
- (Yl = !1), (Li = 0), (Ql += 1), (oe = null), (e = i(s, v));
+ for (kr = {}, rc = n, Li = 0, e = i(s, v); Yl; ) (Yl = !1), (Li = 0), (Ql += 1), (oe = null), (e = i(s, v));
return oc(), e;
}
function sf(e, n, i, s) {
@@ -3308,10 +2985,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
for (var S in i)
if (!(S in c))
throw Error(
- (Zu(s) || "Unknown") +
- '.getChildContext(): key "' +
- S +
- '" is not defined in childContextTypes.'
+ (Zu(s) || "Unknown") + '.getChildContext(): key "' + S + '" is not defined in childContextTypes.',
);
s = Mi({}, m, i);
}
@@ -3331,21 +3005,11 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
if (i.prototype && i.prototype.isReactComponent) {
v = qc(i, n.legacyContext);
var c = i.contextType;
- (c = new i(
- s,
- typeof c == "object" && c !== null ? c._currentValue2 : v
- )),
- tf(c, i, s, v),
- sf(e, n, c, i);
+ (c = new i(s, typeof c == "object" && c !== null ? c._currentValue2 : v)), tf(c, i, s, v), sf(e, n, c, i);
} else {
(c = qc(i, n.legacyContext)), (v = lf(e, n, i, s, c));
var m = Li !== 0;
- if (
- typeof v == "object" &&
- v !== null &&
- typeof v.render == "function" &&
- v.$$typeof === void 0
- )
+ if (typeof v == "object" && v !== null && typeof v.render == "function" && v.$$typeof === void 0)
tf(v, i, s, c), sf(e, n, v, i);
else if (m) {
(s = n.treeContext), (n.treeContext = Ju(s, 1, 0));
@@ -3403,11 +3067,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
throw Error("ReactDOMServer does not yet support scope components.");
case Cf:
e: {
- (i = n.blockedBoundary),
- (v = n.blockedSegment),
- (c = s.fallback),
- (s = s.children),
- (m = new Set());
+ (i = n.blockedBoundary), (v = n.blockedSegment), (c = s.fallback), (s = s.children), (m = new Set());
var S = {
id: null,
rootSegmentID: -1,
@@ -3422,30 +3082,23 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
E = Gl(e, v.chunks.length, S, v.formatContext, !1, !1);
v.children.push(E), (v.lastPushedText = !1);
var x = Gl(e, 0, null, v.formatContext, !1, !1);
- (x.parentFlushed = !0),
- (n.blockedBoundary = S),
- (n.blockedSegment = x);
+ (x.parentFlushed = !0), (n.blockedBoundary = S), (n.blockedSegment = x);
try {
if (
(Ku(e, n, s),
e.responseState.generateStaticMarkup ||
- (x.lastPushedText &&
- x.textEmbedded &&
- x.chunks.push("<!-- -->")),
+ (x.lastPushedText && x.textEmbedded && x.chunks.push("<!-- -->")),
(x.status = 1),
Zl(S, x),
S.pendingTasks === 0)
)
break e;
} catch (R) {
- (x.status = 4),
- (S.forceClientRender = !0),
- (S.errorDigest = Bi(e, R));
+ (x.status = 4), (S.forceClientRender = !0), (S.errorDigest = Bi(e, R));
} finally {
(n.blockedBoundary = i), (n.blockedSegment = v);
}
- (n = ac(e, c, i, E, m, n.legacyContext, n.context, n.treeContext)),
- e.pingedTasks.push(n);
+ (n = ac(e, c, i, E, m, n.legacyContext, n.context, n.treeContext)), e.pingedTasks.push(n);
}
return;
}
@@ -3485,12 +3138,9 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
(e = ro),
e === null)
)
- throw Error(
- "Tried to pop a Context at the root of the app. This is a bug in React."
- );
+ throw Error("Tried to pop a Context at the root of the app. This is a bug in React.");
(s = e.parentValue),
- (e.context._currentValue2 =
- s === Fp ? e.context._defaultValue : s),
+ (e.context._currentValue2 = s === Fp ? e.context._defaultValue : s),
(e = ro = e.parent),
(n.context = e);
return;
@@ -3498,15 +3148,12 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
(s = s.children), (s = s(i._currentValue2)), lt(e, n, s);
return;
case tc:
- (v = i._init),
- (i = v(i._payload)),
- (s = uf(i, s)),
- Qu(e, n, i, s, void 0);
+ (v = i._init), (i = v(i._payload)), (s = uf(i, s)), Qu(e, n, i, s, void 0);
return;
}
throw Error(
"Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " +
- ((i == null ? i : typeof i) + ".")
+ ((i == null ? i : typeof i) + "."),
);
}
}
@@ -3518,7 +3165,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return;
case yf:
throw Error(
- "Portals are not currently supported by the server renderer. Render them conditionally so that they only appear on the client render."
+ "Portals are not currently supported by the server renderer. Render them conditionally so that they only appear on the client render.",
);
case tc:
var s = i._init;
@@ -3532,8 +3179,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
if (
(i === null || typeof i != "object"
? (s = null)
- : ((s = (Kc && i[Kc]) || i["@@iterator"]),
- (s = typeof s == "function" ? s : null)),
+ : ((s = (Kc && i[Kc]) || i["@@iterator"]), (s = typeof s == "function" ? s : null)),
s && (s = s.call(i)))
) {
if (((i = s.next()), !i.done)) {
@@ -3548,29 +3194,16 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
((e = Object.prototype.toString.call(i)),
Error(
"Objects are not valid as a React child (found: " +
- (e === "[object Object]"
- ? "object with keys {" + Object.keys(i).join(", ") + "}"
- : e) +
- "). If you meant to render a collection of children, use an array instead."
+ (e === "[object Object]" ? "object with keys {" + Object.keys(i).join(", ") + "}" : e) +
+ "). If you meant to render a collection of children, use an array instead.",
))
);
}
typeof i == "string"
- ? ((s = n.blockedSegment),
- (s.lastPushedText = Qc(
- n.blockedSegment.chunks,
- i,
- e.responseState,
- s.lastPushedText
- )))
+ ? ((s = n.blockedSegment), (s.lastPushedText = Qc(n.blockedSegment.chunks, i, e.responseState, s.lastPushedText)))
: typeof i == "number" &&
((s = n.blockedSegment),
- (s.lastPushedText = Qc(
- n.blockedSegment.chunks,
- "" + i,
- e.responseState,
- s.lastPushedText
- )));
+ (s.lastPushedText = Qc(n.blockedSegment.chunks, "" + i, e.responseState, s.lastPushedText)));
}
function cf(e, n, i) {
for (var s = i.length, v = 0; v < s; v++) {
@@ -3590,45 +3223,19 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
try {
return lt(e, n, i);
} catch (E) {
- if (
- (oc(),
- typeof E == "object" && E !== null && typeof E.then == "function")
- ) {
+ if ((oc(), typeof E == "object" && E !== null && typeof E.then == "function")) {
i = E;
var m = n.blockedSegment,
- S = Gl(
- e,
- m.chunks.length,
- null,
- m.formatContext,
- m.lastPushedText,
- !0
- );
+ S = Gl(e, m.chunks.length, null, m.formatContext, m.lastPushedText, !0);
m.children.push(S),
(m.lastPushedText = !1),
- (e = ac(
- e,
- n.node,
- n.blockedBoundary,
- S,
- n.abortSet,
- n.legacyContext,
- n.context,
- n.treeContext
- ).ping),
+ (e = ac(e, n.node, n.blockedBoundary, S, n.abortSet, n.legacyContext, n.context, n.treeContext).ping),
i.then(e, e),
(n.blockedSegment.formatContext = s),
(n.legacyContext = v),
(n.context = c),
Vl(c);
- } else
- throw (
- ((n.blockedSegment.formatContext = s),
- (n.legacyContext = v),
- (n.context = c),
- Vl(c),
- E)
- );
+ } else throw ((n.blockedSegment.formatContext = s), (n.legacyContext = v), (n.context = c), Vl(c), E);
}
}
function Wp(e) {
@@ -3639,19 +3246,12 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
var s = e.blockedBoundary;
(e.blockedSegment.status = 3),
s === null
- ? (n.allPendingTasks--,
- n.status !== 2 &&
- ((n.status = 2),
- n.destination !== null && n.destination.push(null)))
+ ? (n.allPendingTasks--, n.status !== 2 && ((n.status = 2), n.destination !== null && n.destination.push(null)))
: (s.pendingTasks--,
s.forceClientRender ||
((s.forceClientRender = !0),
(s.errorDigest = n.onError(
- i === void 0
- ? Error(
- "The render was aborted by the server without a reason."
- )
- : i
+ i === void 0 ? Error("The render was aborted by the server without a reason.") : i,
)),
s.parentFlushed && n.clientRenderedBoundaries.push(s)),
s.fallbackAbortableTasks.forEach(function (v) {
@@ -3662,11 +3262,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
n.allPendingTasks === 0 && ((e = n.onAllReady), e()));
}
function Zl(e, n) {
- if (
- n.chunks.length === 0 &&
- n.children.length === 1 &&
- n.children[0].boundary === null
- ) {
+ if (n.chunks.length === 0 && n.children.length === 1 && n.children[0].boundary === null) {
var i = n.children[0];
(i.id = n.id), (i.parentFlushed = !0), i.status === 1 && Zl(e, i);
} else e.completedSegments.push(n);
@@ -3674,15 +3270,10 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
function Lf(e, n, i) {
if (n === null) {
if (i.parentFlushed) {
- if (e.completedRootSegment !== null)
- throw Error(
- "There can only be one root segment. This is a bug in React."
- );
+ if (e.completedRootSegment !== null) throw Error("There can only be one root segment. This is a bug in React.");
e.completedRootSegment = i;
}
- e.pendingRootTasks--,
- e.pendingRootTasks === 0 &&
- ((e.onShellError = Oi), (n = e.onShellReady), n());
+ e.pendingRootTasks--, e.pendingRootTasks === 0 && ((e.onShellError = Oi), (n = e.onShellReady), n());
} else
n.pendingTasks--,
n.forceClientRender ||
@@ -3693,10 +3284,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
n.fallbackAbortableTasks.clear())
: i.parentFlushed &&
i.status === 1 &&
- (Zl(n, i),
- n.completedSegments.length === 1 &&
- n.parentFlushed &&
- e.partialBoundaries.push(n)));
+ (Zl(n, i), n.completedSegments.length === 1 && n.parentFlushed && e.partialBoundaries.push(n)));
e.allPendingTasks--, e.allPendingTasks === 0 && ((e = e.onAllReady), e());
}
function ic(e) {
@@ -3718,19 +3306,12 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
try {
lt(S, m, m.node),
S.responseState.generateStaticMarkup ||
- (E.lastPushedText &&
- E.textEmbedded &&
- E.chunks.push("<!-- -->")),
+ (E.lastPushedText && E.textEmbedded && E.chunks.push("<!-- -->")),
m.abortSet.delete(m),
(E.status = 1),
Lf(S, m.blockedBoundary, E);
} catch (J) {
- if (
- (oc(),
- typeof J == "object" &&
- J !== null &&
- typeof J.then == "function")
- ) {
+ if ((oc(), typeof J == "object" && J !== null && typeof J.then == "function")) {
var x = m.ping;
J.then(x, x);
} else {
@@ -3793,7 +3374,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return c < s.length && (v = n.push(s[c])), v;
default:
throw Error(
- "Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React."
+ "Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React.",
);
}
}
@@ -3813,8 +3394,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
e
);
if (0 < s.pendingTasks) {
- (s.rootSegmentID = e.nextSegmentId++),
- 0 < s.completedSegments.length && e.partialBoundaries.push(s);
+ (s.rootSegmentID = e.nextSegmentId++), 0 < s.completedSegments.length && e.partialBoundaries.push(s);
var v = e.responseState,
c = v.nextSuspenseID++;
return (
@@ -3833,30 +3413,15 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
jl(e, n, i),
n.push("<!--/$-->")
);
- if (
- (e.responseState.generateStaticMarkup || n.push("<!--$-->"),
- (i = s.completedSegments),
- i.length !== 1)
- )
- throw Error(
- "A previously unvisited boundary must have exactly one root segment. This is a bug in React."
- );
- return (
- Kl(e, n, i[0]),
- (e = e.responseState.generateStaticMarkup ? !0 : n.push("<!--/$-->")),
- e
- );
+ if ((e.responseState.generateStaticMarkup || n.push("<!--$-->"), (i = s.completedSegments), i.length !== 1))
+ throw Error("A previously unvisited boundary must have exactly one root segment. This is a bug in React.");
+ return Kl(e, n, i[0]), (e = e.responseState.generateStaticMarkup ? !0 : n.push("<!--/$-->")), e;
}
function ff(e, n, i) {
- return (
- Tp(n, e.responseState, i.formatContext, i.id),
- Kl(e, n, i),
- Cp(n, i.formatContext)
- );
+ return Tp(n, e.responseState, i.formatContext, i.id), Kl(e, n, i), Cp(n, i.formatContext);
}
function df(e, n, i) {
- for (var s = i.completedSegments, v = 0; v < s.length; v++)
- Bf(e, n, i, s[v]);
+ for (var s = i.completedSegments, v = 0; v < s.length; v++) Bf(e, n, i, s[v]);
if (
((s.length = 0),
(e = e.responseState),
@@ -3867,30 +3432,19 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
? n.push('$RC("')
: ((e.sentCompleteBoundaryFunction = !0),
n.push(
- 'function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("'
+ 'function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("',
)),
s === null)
)
- throw Error(
- "An ID must have been assigned before we can complete the boundary."
- );
- return (
- (i = i.toString(16)),
- n.push(s),
- n.push('","'),
- n.push(e.segmentPrefix),
- n.push(i),
- n.push('")</script>')
- );
+ throw Error("An ID must have been assigned before we can complete the boundary.");
+ return (i = i.toString(16)), n.push(s), n.push('","'), n.push(e.segmentPrefix), n.push(i), n.push('")</script>');
}
function Bf(e, n, i, s) {
if (s.status === 2) return !0;
var v = s.id;
if (v === -1) {
if ((s.id = i.rootSegmentID) === -1)
- throw Error(
- "A root segment ID must have been assigned by now. This is a bug in React."
- );
+ throw Error("A root segment ID must have been assigned by now. This is a bug in React.");
return ff(e, n, s);
}
return (
@@ -3901,7 +3455,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
? n.push('$RS("')
: ((e.sentCompleteSegmentFunction = !0),
n.push(
- 'function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'
+ 'function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("',
)),
n.push(e.segmentPrefix),
(v = v.toString(16)),
@@ -3937,13 +3491,11 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
? s.push('$RX("')
: ((S.sentClientRenderFunction = !0),
s.push(
- 'function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("'
+ 'function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("',
)),
E === null)
)
- throw Error(
- "An ID must have been assigned before we can complete the boundary."
- );
+ throw Error("An ID must have been assigned before we can complete the boundary.");
if ((s.push(E), s.push('"'), x || R || D)) {
s.push(",");
var V = Yu(x || "");
@@ -4048,7 +3600,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
S = !0;
},
void 0,
- void 0
+ void 0,
)),
ic(e),
Uf(e, s),
@@ -4065,14 +3617,12 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
throw c;
if (!S)
throw Error(
- "A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition."
+ "A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition.",
);
return m;
}
function $p(e, n) {
- (e.prototype = Object.create(n.prototype)),
- (e.prototype.constructor = e),
- (e.__proto__ = n);
+ (e.prototype = Object.create(n.prototype)), (e.prototype.constructor = e), (e.__proto__ = n);
}
var Np = (function (e) {
function n() {
@@ -4104,7 +3654,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
(i.startedFlowing = !0), sc(s, i);
},
void 0,
- void 0
+ void 0,
);
return (i.request = s), ic(s), i;
}
@@ -4116,7 +3666,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
e,
n,
!0,
- 'The server used "renderToStaticMarkup" which does not support Suspense. If you intended to have the server wait for the suspended component please switch to "renderToPipeableStream" which supports Suspense on the server'
+ 'The server used "renderToStaticMarkup" which does not support Suspense. If you intended to have the server wait for the suspended component please switch to "renderToPipeableStream" which supports Suspense on the server',
);
};
ca.renderToStaticNodeStream = function (e, n) {
@@ -4127,12 +3677,12 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
e,
n,
!1,
- 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToPipeableStream" which supports Suspense on the server'
+ 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToPipeableStream" which supports Suspense on the server',
);
};
ca.version = "18.2.0";
});
-var jd = an((_c) => {
+var jd = an(_c => {
"use strict";
var Yp = require("util"),
hd = ua(),
@@ -4143,36 +3693,22 @@ var jd = an((_c) => {
if (typeof n == "string") {
if (n.length !== 0)
if (2048 < 3 * n.length)
- 0 < le &&
- (Tr(e, pe.subarray(0, le)), (pe = new Uint8Array(2048)), (le = 0)),
- Tr(e, ts.encode(n));
+ 0 < le && (Tr(e, pe.subarray(0, le)), (pe = new Uint8Array(2048)), (le = 0)), Tr(e, ts.encode(n));
else {
var i = pe;
0 < le && (i = pe.subarray(le)), (i = ts.encodeInto(n, i));
var s = i.read;
(le += i.written),
- s < n.length &&
- (Tr(e, pe),
- (pe = new Uint8Array(2048)),
- (le = ts.encodeInto(n.slice(s), pe).written)),
+ s < n.length && (Tr(e, pe), (pe = new Uint8Array(2048)), (le = ts.encodeInto(n.slice(s), pe).written)),
le === 2048 && (Tr(e, pe), (pe = new Uint8Array(2048)), (le = 0));
}
} else
n.byteLength !== 0 &&
(2048 < n.byteLength
- ? (0 < le &&
- (Tr(e, pe.subarray(0, le)),
- (pe = new Uint8Array(2048)),
- (le = 0)),
- Tr(e, n))
+ ? (0 < le && (Tr(e, pe.subarray(0, le)), (pe = new Uint8Array(2048)), (le = 0)), Tr(e, n))
: ((i = pe.length - le),
i < n.byteLength &&
- (i === 0
- ? Tr(e, pe)
- : (pe.set(n.subarray(0, i), le),
- (le += i),
- Tr(e, pe),
- (n = n.subarray(i))),
+ (i === 0 ? Tr(e, pe) : (pe.set(n.subarray(0, i), le), (le += i), Tr(e, pe), (n = n.subarray(i))),
(pe = new Uint8Array(2048)),
(le = 0)),
pe.set(n, le),
@@ -4186,10 +3722,7 @@ var jd = an((_c) => {
return L(e, n), da;
}
function zf(e) {
- pe && 0 < le && e.write(pe.subarray(0, le)),
- (pe = null),
- (le = 0),
- (da = !0);
+ pe && 0 < le && e.write(pe.subarray(0, le)), (pe = null), (le = 0), (da = !0);
}
var ts = new Yp.TextEncoder();
function A(e) {
@@ -4201,13 +3734,7 @@ var jd = an((_c) => {
$f = {},
Nf = {};
function vd(e) {
- return et.call(Nf, e)
- ? !0
- : et.call($f, e)
- ? !1
- : Gp.test(e)
- ? (Nf[e] = !0)
- : (($f[e] = !0), !1);
+ return et.call(Nf, e) ? !0 : et.call($f, e) ? !1 : Gp.test(e) ? (Nf[e] = !0) : (($f[e] = !0), !1);
}
function Xe(e, n, i, s, v, c, m) {
(this.acceptsBooleans = n === 2 || n === 3 || n === 4),
@@ -4237,12 +3764,7 @@ var jd = an((_c) => {
["contentEditable", "draggable", "spellCheck", "value"].forEach(function (e) {
De[e] = new Xe(e, 2, !1, e.toLowerCase(), null, !1, !1);
});
- [
- "autoReverse",
- "externalResourcesRequired",
- "focusable",
- "preserveAlpha",
- ].forEach(function (e) {
+ ["autoReverse", "externalResourcesRequired", "focusable", "preserveAlpha"].forEach(function (e) {
De[e] = new Xe(e, 2, !1, e, null, !1, !1);
});
"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope"
@@ -4272,12 +3794,10 @@ var jd = an((_c) => {
var n = e.replace(Sc, wc);
De[n] = new Xe(n, 1, !1, e, null, !1, !1);
});
- "xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type"
- .split(" ")
- .forEach(function (e) {
- var n = e.replace(Sc, wc);
- De[n] = new Xe(n, 1, !1, e, "http://www.w3.org/1999/xlink", !1, !1);
- });
+ "xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function (e) {
+ var n = e.replace(Sc, wc);
+ De[n] = new Xe(n, 1, !1, e, "http://www.w3.org/1999/xlink", !1, !1);
+ });
["xml:base", "xml:lang", "xml:space"].forEach(function (e) {
var n = e.replace(Sc, wc);
De[n] = new Xe(n, 1, !1, e, "http://www.w3.org/XML/1998/namespace", !1, !1);
@@ -4285,15 +3805,7 @@ var jd = an((_c) => {
["tabIndex", "crossOrigin"].forEach(function (e) {
De[e] = new Xe(e, 1, !1, e.toLowerCase(), null, !1, !1);
});
- De.xlinkHref = new Xe(
- "xlinkHref",
- 1,
- !1,
- "xlink:href",
- "http://www.w3.org/1999/xlink",
- !0,
- !1
- );
+ De.xlinkHref = new Xe("xlinkHref", 1, !1, "xlink:href", "http://www.w3.org/1999/xlink", !0, !1);
["src", "href", "action", "formAction"].forEach(function (e) {
De[e] = new Xe(e, 1, !1, e.toLowerCase(), null, !0, !0);
});
@@ -4432,7 +3944,7 @@ var jd = an((_c) => {
function gd(e, n, i) {
if (typeof i != "object")
throw Error(
- "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX."
+ "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX.",
);
n = !0;
for (var s in i)
@@ -4445,18 +3957,9 @@ var jd = an((_c) => {
} else {
c = s;
var m = Gf.get(c);
- m !== void 0 ||
- ((m = A(
- Ae(c.replace(Jp, "-$1").toLowerCase().replace(Qp, "-ms-"))
- )),
- Gf.set(c, m)),
+ m !== void 0 || ((m = A(Ae(c.replace(Jp, "-$1").toLowerCase().replace(Qp, "-ms-")))), Gf.set(c, m)),
(c = m),
- (v =
- typeof v == "number"
- ? v === 0 || et.call(rs, s)
- ? "" + v
- : v + "px"
- : Ae(("" + v).trim()));
+ (v = typeof v == "number" ? (v === 0 || et.call(rs, s) ? "" + v : v + "px") : Ae(("" + v).trim()));
}
n ? ((n = !1), e.push(ah, c, Xf, v)) : e.push(ih, c, Xf, v);
}
@@ -4479,11 +3982,7 @@ var jd = an((_c) => {
case "suppressHydrationWarning":
return;
}
- if (
- !(2 < i.length) ||
- (i[0] !== "o" && i[0] !== "O") ||
- (i[1] !== "n" && i[1] !== "N")
- ) {
+ if (!(2 < i.length) || (i[0] !== "o" && i[0] !== "O") || (i[1] !== "n" && i[1] !== "N")) {
if (((n = De.hasOwnProperty(i) ? De[i] : null), n !== null)) {
switch (typeof s) {
case "function":
@@ -4497,9 +3996,7 @@ var jd = an((_c) => {
s && e.push(sn, i, Zf);
break;
case 4:
- s === !0
- ? e.push(sn, i, Zf)
- : s !== !1 && e.push(sn, i, fa, Ae(s), no);
+ s === !0 ? e.push(sn, i, Zf) : s !== !1 && e.push(sn, i, fa, Ae(s), no);
break;
case 5:
isNaN(s) || e.push(sn, i, fa, Ae(s), no);
@@ -4516,11 +4013,7 @@ var jd = an((_c) => {
case "symbol":
return;
case "boolean":
- if (
- ((n = i.toLowerCase().slice(0, 5)),
- n !== "data-" && n !== "aria-")
- )
- return;
+ if (((n = i.toLowerCase().slice(0, 5)), n !== "data-" && n !== "aria-")) return;
}
e.push(sn, i, fa, Ae(s), no);
}
@@ -4530,13 +4023,10 @@ var jd = an((_c) => {
Jf = A("/>");
function ns(e, n, i) {
if (n != null) {
- if (i != null)
- throw Error(
- "Can only set one of `children` or `props.dangerouslySetInnerHTML`."
- );
+ if (i != null) throw Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
if (typeof n != "object" || !("__html" in n))
throw Error(
- "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information."
+ "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information.",
);
(n = n.__html), n != null && e.push("" + n);
}
@@ -4570,9 +4060,7 @@ var jd = an((_c) => {
st(e, s, c, m);
}
}
- return (
- e.push(un), ns(e, v, i), typeof i == "string" ? (e.push(Ae(i)), null) : i
- );
+ return e.push(un), ns(e, v, i), typeof i == "string" ? (e.push(Ae(i)), null) : i;
}
var fc = A(`
`),
@@ -4662,19 +4150,13 @@ var jd = an((_c) => {
m = E;
break;
case "dangerouslySetInnerHTML":
- throw Error(
- "`dangerouslySetInnerHTML` does not make sense on <textarea>."
- );
+ throw Error("`dangerouslySetInnerHTML` does not make sense on <textarea>.");
default:
st(e, s, S, E);
}
if ((c === null && m !== null && (c = m), e.push(un), R != null)) {
- if (c != null)
- throw Error(
- "If you supply `defaultValue` on a <textarea>, do not pass children."
- );
- if (vc(R) && 1 < R.length)
- throw Error("<textarea> can only have at most one child.");
+ if (c != null) throw Error("If you supply `defaultValue` on a <textarea>, do not pass children.");
+ if (vc(R) && 1 < R.length) throw Error("<textarea> can only have at most one child.");
c = "" + R;
}
return (
@@ -4694,7 +4176,7 @@ var jd = an((_c) => {
case "children":
case "dangerouslySetInnerHTML":
throw Error(
- "input is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`."
+ "input is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.",
);
case "defaultChecked":
E = x;
@@ -4712,12 +4194,8 @@ var jd = an((_c) => {
st(e, s, m, x);
}
return (
- R !== null
- ? st(e, s, "checked", R)
- : E !== null && st(e, s, "checked", E),
- c !== null
- ? st(e, s, "value", c)
- : S !== null && st(e, s, "value", S),
+ R !== null ? st(e, s, "checked", R) : E !== null && st(e, s, "checked", E),
+ c !== null ? st(e, s, "value", c) : S !== null && st(e, s, "value", S),
e.push(Jf),
null
);
@@ -4728,9 +4206,7 @@ var jd = an((_c) => {
switch (V) {
case "children":
case "dangerouslySetInnerHTML":
- throw Error(
- "menuitems cannot have `children` nor `dangerouslySetInnerHTML`."
- );
+ throw Error("menuitems cannot have `children` nor `dangerouslySetInnerHTML`.");
default:
st(e, s, V, c);
}
@@ -4744,9 +4220,7 @@ var jd = an((_c) => {
c = m;
break;
case "dangerouslySetInnerHTML":
- throw Error(
- "`dangerouslySetInnerHTML` does not make sense on <title>."
- );
+ throw Error("`dangerouslySetInnerHTML` does not make sense on <title>.");
default:
st(e, s, D, m);
}
@@ -4767,13 +4241,10 @@ var jd = an((_c) => {
st(e, s, E, S);
}
if ((e.push(un), m != null)) {
- if (c != null)
- throw Error(
- "Can only set one of `children` or `props.dangerouslySetInnerHTML`."
- );
+ if (c != null) throw Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
if (typeof m != "object" || !("__html" in m))
throw Error(
- "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information."
+ "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information.",
);
(i = m.__html),
i != null &&
@@ -4814,8 +4285,7 @@ var jd = an((_c) => {
case "children":
case "dangerouslySetInnerHTML":
throw Error(
- n +
- " is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`."
+ n + " is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.",
);
default:
st(e, s, te, c);
@@ -4833,8 +4303,7 @@ var jd = an((_c) => {
case "html":
return v.insertionMode === 0 && e.push(uh), cc(e, i, n, s);
default:
- if (n.indexOf("-") === -1 && typeof i.is != "string")
- return cc(e, i, n, s);
+ if (n.indexOf("-") === -1 && typeof i.is != "string") return cc(e, i, n, s);
e.push(Kt(n)), (m = c = null);
for (x in i)
if (et.call(i, x) && ((S = i[x]), S != null))
@@ -4852,10 +4321,7 @@ var jd = an((_c) => {
case "suppressHydrationWarning":
break;
default:
- vd(x) &&
- typeof S != "function" &&
- typeof S != "symbol" &&
- e.push(sn, x, fa, Ae(S), no);
+ vd(x) && typeof S != "function" && typeof S != "symbol" && e.push(sn, x, fa, Ae(S), no);
}
return e.push(un), ns(e, m, c), c;
}
@@ -4876,10 +4342,7 @@ var jd = an((_c) => {
A(' data-stck="');
var kh = A("></template>");
function Kf(e, n, i) {
- if ((L(e, gh), i === null))
- throw Error(
- "An ID must have been assigned before we can complete the boundary."
- );
+ if ((L(e, gh), i === null)) throw Error("An ID must have been assigned before we can complete the boundary.");
return L(e, i), se(e, mh);
}
var Th = A('<div hidden id="'),
@@ -4946,19 +4409,19 @@ var jd = an((_c) => {
}
}
var Gh = A(
- 'function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'
+ 'function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("',
),
Xh = A('$RS("'),
Zh = A('","'),
Jh = A('")</script>'),
Qh = A(
- 'function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("'
+ 'function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("',
),
Kh = A('$RC("'),
qh = A('","'),
ev = A('")</script>'),
tv = A(
- 'function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("'
+ 'function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("',
),
rv = A('$RX("'),
nv = A('"'),
@@ -4976,7 +4439,7 @@ var jd = an((_c) => {
return "\\u2029";
default:
throw Error(
- "escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React"
+ "escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React",
);
}
});
@@ -5027,15 +4490,11 @@ var jd = an((_c) => {
var n = e.render;
return (
(e = e.displayName),
- e ||
- ((e = n.displayName || n.name || ""),
- (e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef")),
+ e || ((e = n.displayName || n.name || ""), (e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef")),
e
);
case Ed:
- return (
- (n = e.displayName || null), n !== null ? n : gc(e.type) || "Memo"
- );
+ return (n = e.displayName || null), n !== null ? n : gc(e.type) || "Memo";
case kc:
(n = e._payload), (e = e._init);
try {
@@ -5058,24 +4517,16 @@ var jd = an((_c) => {
(e.context._currentValue = e.parentValue), (e = e.parent);
var i = n.parent;
if (e === null) {
- if (i !== null)
- throw Error(
- "The stacks must reach the root at the same time. This is a bug in React."
- );
+ if (i !== null) throw Error("The stacks must reach the root at the same time. This is a bug in React.");
} else {
- if (i === null)
- throw Error(
- "The stacks must reach the root at the same time. This is a bug in React."
- );
+ if (i === null) throw Error("The stacks must reach the root at the same time. This is a bug in React.");
ds(e, i);
}
n.context._currentValue = n.value;
}
}
function Id(e) {
- (e.context._currentValue = e.parentValue),
- (e = e.parent),
- e !== null && Id(e);
+ (e.context._currentValue = e.parentValue), (e = e.parent), e !== null && Id(e);
}
function _d(e) {
var n = e.parent;
@@ -5083,19 +4534,14 @@ var jd = an((_c) => {
}
function Pd(e, n) {
if (((e.context._currentValue = e.parentValue), (e = e.parent), e === null))
- throw Error(
- "The depth must equal at least at zero before reaching the root. This is a bug in React."
- );
+ throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");
e.depth === n.depth ? ds(e, n) : Pd(e, n);
}
function Fd(e, n) {
var i = n.parent;
if (i === null)
- throw Error(
- "The depth must equal at least at zero before reaching the root. This is a bug in React."
- );
- e.depth === i.depth ? ds(e, i) : Fd(e, i),
- (n.context._currentValue = n.value);
+ throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");
+ e.depth === i.depth ? ds(e, i) : Fd(e, i), (n.context._currentValue = n.value);
}
function ls(e) {
var n = ao;
@@ -5132,35 +4578,21 @@ var jd = an((_c) => {
if (
((e.context = typeof m == "object" && m !== null ? m._currentValue : s),
(m = n.getDerivedStateFromProps),
- typeof m == "function" &&
- ((m = m(i, v)), (v = m == null ? v : Hi({}, v, m)), (e.state = v)),
+ typeof m == "function" && ((m = m(i, v)), (v = m == null ? v : Hi({}, v, m)), (e.state = v)),
typeof n.getDerivedStateFromProps != "function" &&
typeof e.getSnapshotBeforeUpdate != "function" &&
- (typeof e.UNSAFE_componentWillMount == "function" ||
- typeof e.componentWillMount == "function"))
+ (typeof e.UNSAFE_componentWillMount == "function" || typeof e.componentWillMount == "function"))
)
if (
((n = e.state),
typeof e.componentWillMount == "function" && e.componentWillMount(),
- typeof e.UNSAFE_componentWillMount == "function" &&
- e.UNSAFE_componentWillMount(),
+ typeof e.UNSAFE_componentWillMount == "function" && e.UNSAFE_componentWillMount(),
n !== e.state && td.enqueueReplaceState(e, e.state, null),
c.queue !== null && 0 < c.queue.length)
)
- if (
- ((n = c.queue),
- (m = c.replace),
- (c.queue = null),
- (c.replace = !1),
- m && n.length === 1)
- )
- e.state = n[0];
+ if (((n = c.queue), (m = c.replace), (c.queue = null), (c.replace = !1), m && n.length === 1)) e.state = n[0];
else {
- for (
- c = m ? n[0] : e.state, v = !0, m = m ? 1 : 0;
- m < n.length;
- m++
- ) {
+ for (c = m ? n[0] : e.state, v = !0, m = m ? 1 : 0; m < n.length; m++) {
var S = n[m];
(S = typeof S == "function" ? S.call(e, c, i, s) : S),
S != null && (v ? ((v = !1), (c = Hi({}, c, S))) : Hi(c, S));
@@ -5216,8 +4648,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return Cr;
}
function nd() {
- if (0 < ps)
- throw Error("Rendered more hooks than during the previous render");
+ if (0 < ps) throw Error("Rendered more hooks than during the previous render");
return { memoizedState: null, queue: null, next: null };
}
function Cc() {
@@ -5250,14 +4681,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return [ae.memoizedState, n];
}
return (
- (e =
- e === Ad
- ? typeof n == "function"
- ? n()
- : n
- : i !== void 0
- ? i(n)
- : n),
+ (e = e === Ad ? (typeof n == "function" ? n() : n) : i !== void 0 ? i(n) : n),
(ae.memoizedState = e),
(e = ae.queue = { last: null, dispatch: null }),
(e = e.dispatch = mv.bind(null, Cr, e)),
@@ -5265,9 +4689,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
);
}
function ad(e, n) {
- if (
- ((Cr = oo()), (ae = Cc()), (n = n === void 0 ? null : n), ae !== null)
- ) {
+ if (((Cr = oo()), (ae = Cc()), (n = n === void 0 ? null : n), ae !== null)) {
var i = ae.memoizedState;
if (i !== null && n !== null) {
var s = i[1];
@@ -5286,18 +4708,9 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return (e = e()), (ae.memoizedState = [e, n]), e;
}
function mv(e, n, i) {
- if (25 <= ps)
- throw Error(
- "Too many re-renders. React limits the number of renders to prevent an infinite loop."
- );
+ if (25 <= ps) throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");
if (e === Cr)
- if (
- ((ss = !0),
- (e = { action: i, next: null }),
- cn === null && (cn = new Map()),
- (i = cn.get(n)),
- i === void 0)
- )
+ if (((ss = !0), (e = { action: i, next: null }), cn === null && (cn = new Map()), (i = cn.get(n)), i === void 0))
cn.set(n, e);
else {
for (n = i; n.next !== null; ) n = n.next;
@@ -5347,15 +4760,8 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
(e = e.id), (e = (e & ~(1 << (32 - os(e) - 1))).toString(32) + n);
var i = is;
if (i === null)
- throw Error(
- "Invalid hook call. Hooks can only be called inside of the body of a function component."
- );
- return (
- (n = Wi++),
- (e = ":" + i.idPrefix + "R" + e),
- 0 < n && (e += "H" + n.toString(32)),
- e + ":"
- );
+ throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component.");
+ return (n = Wi++), (e = ":" + i.idPrefix + "R" + e), 0 < n && (e += "H" + n.toString(32)), e + ":";
},
useMutableSource: function (e, n) {
return oo(), n(e._source);
@@ -5363,15 +4769,13 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
useSyncExternalStore: function (e, n, i) {
if (i === void 0)
throw Error(
- "Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering."
+ "Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering.",
);
return i();
},
},
is = null,
- hc =
- hd.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
- .ReactCurrentDispatcher;
+ hc = hd.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;
function bv(e) {
return console.error(e), null;
}
@@ -5419,7 +4823,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
throw Error(
'onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "' +
typeof e +
- '" instead'
+ '" instead',
);
return e;
}
@@ -5428,13 +4832,10 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
i(n),
(i = e.onFatalError),
i(n),
- e.destination !== null
- ? ((e.status = 2), e.destination.destroy(n))
- : ((e.status = 1), (e.fatalError = n));
+ e.destination !== null ? ((e.status = 2), e.destination.destroy(n)) : ((e.status = 1), (e.fatalError = n));
}
function ld(e, n, i, s, v) {
- for (Cr = {}, Tc = n, Wi = 0, e = i(s, v); ss; )
- (ss = !1), (Wi = 0), (ps += 1), (ae = null), (e = i(s, v));
+ for (Cr = {}, Tc = n, Wi = 0, e = i(s, v); ss; ) (ss = !1), (Wi = 0), (ps += 1), (ae = null), (e = i(s, v));
return Ec(), e;
}
function sd(e, n, i, s) {
@@ -5448,10 +4849,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
for (var S in i)
if (!(S in c))
throw Error(
- (gc(s) || "Unknown") +
- '.getChildContext(): key "' +
- S +
- '" is not defined in childContextTypes.'
+ (gc(s) || "Unknown") + '.getChildContext(): key "' + S + '" is not defined in childContextTypes.',
);
s = Hi({}, m, i);
}
@@ -5471,21 +4869,11 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
if (i.prototype && i.prototype.isReactComponent) {
v = ed(i, n.legacyContext);
var c = i.contextType;
- (c = new i(
- s,
- typeof c == "object" && c !== null ? c._currentValue : v
- )),
- rd(c, i, s, v),
- sd(e, n, c, i);
+ (c = new i(s, typeof c == "object" && c !== null ? c._currentValue : v)), rd(c, i, s, v), sd(e, n, c, i);
} else {
(c = ed(i, n.legacyContext)), (v = ld(e, n, i, s, c));
var m = Wi !== 0;
- if (
- typeof v == "object" &&
- v !== null &&
- typeof v.render == "function" &&
- v.$$typeof === void 0
- )
+ if (typeof v == "object" && v !== null && typeof v.render == "function" && v.$$typeof === void 0)
rd(v, i, s, c), sd(e, n, v, i);
else if (m) {
(s = n.treeContext), (n.treeContext = mc(s, 1, 0));
@@ -5543,11 +4931,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
throw Error("ReactDOMServer does not yet support scope components.");
case Td:
e: {
- (i = n.blockedBoundary),
- (v = n.blockedSegment),
- (c = s.fallback),
- (s = s.children),
- (m = new Set());
+ (i = n.blockedBoundary), (v = n.blockedSegment), (c = s.fallback), (s = s.children), (m = new Set());
var S = {
id: null,
rootSegmentID: -1,
@@ -5562,9 +4946,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
E = us(e, v.chunks.length, S, v.formatContext, !1, !1);
v.children.push(E), (v.lastPushedText = !1);
var x = us(e, 0, null, v.formatContext, !1, !1);
- (x.parentFlushed = !0),
- (n.blockedBoundary = S),
- (n.blockedSegment = x);
+ (x.parentFlushed = !0), (n.blockedBoundary = S), (n.blockedSegment = x);
try {
if (
(bc(e, n, s),
@@ -5575,14 +4957,11 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
)
break e;
} catch (R) {
- (x.status = 4),
- (S.forceClientRender = !0),
- (S.errorDigest = zi(e, R));
+ (x.status = 4), (S.forceClientRender = !0), (S.errorDigest = zi(e, R));
} finally {
(n.blockedBoundary = i), (n.blockedSegment = v);
}
- (n = Rc(e, c, i, E, m, n.legacyContext, n.context, n.treeContext)),
- e.pingedTasks.push(n);
+ (n = Rc(e, c, i, E, m, n.legacyContext, n.context, n.treeContext)), e.pingedTasks.push(n);
}
return;
}
@@ -5622,12 +5001,9 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
(e = ao),
e === null)
)
- throw Error(
- "Tried to pop a Context at the root of the app. This is a bug in React."
- );
+ throw Error("Tried to pop a Context at the root of the app. This is a bug in React.");
(s = e.parentValue),
- (e.context._currentValue =
- s === cv ? e.context._defaultValue : s),
+ (e.context._currentValue = s === cv ? e.context._defaultValue : s),
(e = ao = e.parent),
(n.context = e);
return;
@@ -5635,15 +5011,12 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
(s = s.children), (s = s(i._currentValue)), ut(e, n, s);
return;
case kc:
- (v = i._init),
- (i = v(i._payload)),
- (s = ud(i, s)),
- yc(e, n, i, s, void 0);
+ (v = i._init), (i = v(i._payload)), (s = ud(i, s)), yc(e, n, i, s, void 0);
return;
}
throw Error(
"Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " +
- ((i == null ? i : typeof i) + ".")
+ ((i == null ? i : typeof i) + "."),
);
}
}
@@ -5655,7 +5028,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return;
case md:
throw Error(
- "Portals are not currently supported by the server renderer. Render them conditionally so that they only appear on the client render."
+ "Portals are not currently supported by the server renderer. Render them conditionally so that they only appear on the client render.",
);
case kc:
var s = i._init;
@@ -5669,8 +5042,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
if (
(i === null || typeof i != "object"
? (s = null)
- : ((s = (qf && i[qf]) || i["@@iterator"]),
- (s = typeof s == "function" ? s : null)),
+ : ((s = (qf && i[qf]) || i["@@iterator"]), (s = typeof s == "function" ? s : null)),
s && (s = s.call(i)))
) {
if (((i = s.next()), !i.done)) {
@@ -5685,29 +5057,16 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
((e = Object.prototype.toString.call(i)),
Error(
"Objects are not valid as a React child (found: " +
- (e === "[object Object]"
- ? "object with keys {" + Object.keys(i).join(", ") + "}"
- : e) +
- "). If you meant to render a collection of children, use an array instead."
+ (e === "[object Object]" ? "object with keys {" + Object.keys(i).join(", ") + "}" : e) +
+ "). If you meant to render a collection of children, use an array instead.",
))
);
}
typeof i == "string"
- ? ((s = n.blockedSegment),
- (s.lastPushedText = Yf(
- n.blockedSegment.chunks,
- i,
- e.responseState,
- s.lastPushedText
- )))
+ ? ((s = n.blockedSegment), (s.lastPushedText = Yf(n.blockedSegment.chunks, i, e.responseState, s.lastPushedText)))
: typeof i == "number" &&
((s = n.blockedSegment),
- (s.lastPushedText = Yf(
- n.blockedSegment.chunks,
- "" + i,
- e.responseState,
- s.lastPushedText
- )));
+ (s.lastPushedText = Yf(n.blockedSegment.chunks, "" + i, e.responseState, s.lastPushedText)));
}
function cd(e, n, i) {
for (var s = i.length, v = 0; v < s; v++) {
@@ -5727,45 +5086,19 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
try {
return ut(e, n, i);
} catch (E) {
- if (
- (Ec(),
- typeof E == "object" && E !== null && typeof E.then == "function")
- ) {
+ if ((Ec(), typeof E == "object" && E !== null && typeof E.then == "function")) {
i = E;
var m = n.blockedSegment,
- S = us(
- e,
- m.chunks.length,
- null,
- m.formatContext,
- m.lastPushedText,
- !0
- );
+ S = us(e, m.chunks.length, null, m.formatContext, m.lastPushedText, !0);
m.children.push(S),
(m.lastPushedText = !1),
- (e = Rc(
- e,
- n.node,
- n.blockedBoundary,
- S,
- n.abortSet,
- n.legacyContext,
- n.context,
- n.treeContext
- ).ping),
+ (e = Rc(e, n.node, n.blockedBoundary, S, n.abortSet, n.legacyContext, n.context, n.treeContext).ping),
i.then(e, e),
(n.blockedSegment.formatContext = s),
(n.legacyContext = v),
(n.context = c),
ls(c);
- } else
- throw (
- ((n.blockedSegment.formatContext = s),
- (n.legacyContext = v),
- (n.context = c),
- ls(c),
- E)
- );
+ } else throw ((n.blockedSegment.formatContext = s), (n.legacyContext = v), (n.context = c), ls(c), E);
}
}
function wv(e) {
@@ -5776,18 +5109,12 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
var s = e.blockedBoundary;
(e.blockedSegment.status = 3),
s === null
- ? (n.allPendingTasks--,
- n.status !== 2 &&
- ((n.status = 2), n.destination !== null && n.destination.end()))
+ ? (n.allPendingTasks--, n.status !== 2 && ((n.status = 2), n.destination !== null && n.destination.end()))
: (s.pendingTasks--,
s.forceClientRender ||
((s.forceClientRender = !0),
(s.errorDigest = n.onError(
- i === void 0
- ? Error(
- "The render was aborted by the server without a reason."
- )
- : i
+ i === void 0 ? Error("The render was aborted by the server without a reason.") : i,
)),
s.parentFlushed && n.clientRenderedBoundaries.push(s)),
s.fallbackAbortableTasks.forEach(function (v) {
@@ -5798,11 +5125,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
n.allPendingTasks === 0 && ((e = n.onAllReady), e()));
}
function fs(e, n) {
- if (
- n.chunks.length === 0 &&
- n.children.length === 1 &&
- n.children[0].boundary === null
- ) {
+ if (n.chunks.length === 0 && n.children.length === 1 && n.children[0].boundary === null) {
var i = n.children[0];
(i.id = n.id), (i.parentFlushed = !0), i.status === 1 && fs(e, i);
} else e.completedSegments.push(n);
@@ -5810,15 +5133,10 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
function Od(e, n, i) {
if (n === null) {
if (i.parentFlushed) {
- if (e.completedRootSegment !== null)
- throw Error(
- "There can only be one root segment. This is a bug in React."
- );
+ if (e.completedRootSegment !== null) throw Error("There can only be one root segment. This is a bug in React.");
e.completedRootSegment = i;
}
- e.pendingRootTasks--,
- e.pendingRootTasks === 0 &&
- ((e.onShellError = ji), (n = e.onShellReady), n());
+ e.pendingRootTasks--, e.pendingRootTasks === 0 && ((e.onShellError = ji), (n = e.onShellReady), n());
} else
n.pendingTasks--,
n.forceClientRender ||
@@ -5829,10 +5147,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
n.fallbackAbortableTasks.clear())
: i.parentFlushed &&
i.status === 1 &&
- (fs(n, i),
- n.completedSegments.length === 1 &&
- n.parentFlushed &&
- e.partialBoundaries.push(n)));
+ (fs(n, i), n.completedSegments.length === 1 && n.parentFlushed && e.partialBoundaries.push(n)));
e.allPendingTasks--, e.allPendingTasks === 0 && ((e = e.onAllReady), e());
}
function Md(e) {
@@ -5858,12 +5173,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
(E.status = 1),
Od(S, m.blockedBoundary, E);
} catch (J) {
- if (
- (Ec(),
- typeof J == "object" &&
- J !== null &&
- typeof J.then == "function")
- ) {
+ if ((Ec(), typeof J == "object" && J !== null && typeof J.then == "function")) {
var x = m.ping;
J.then(x, x);
} else {
@@ -5926,7 +5236,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return c < s.length && (v = se(n, s[c])), v;
default:
throw Error(
- "Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React."
+ "Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React.",
);
}
}
@@ -5934,85 +5244,51 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
var s = i.boundary;
if (s === null) return es(e, n, i);
if (((s.parentFlushed = !0), s.forceClientRender))
- (s = s.errorDigest),
- se(n, yh),
- L(n, Sh),
- s && (L(n, xh), L(n, Ae(s)), L(n, wh)),
- se(n, kh),
- es(e, n, i);
+ (s = s.errorDigest), se(n, yh), L(n, Sh), s && (L(n, xh), L(n, Ae(s)), L(n, wh)), se(n, kh), es(e, n, i);
else if (0 < s.pendingTasks) {
- (s.rootSegmentID = e.nextSegmentId++),
- 0 < s.completedSegments.length && e.partialBoundaries.push(s);
+ (s.rootSegmentID = e.nextSegmentId++), 0 < s.completedSegments.length && e.partialBoundaries.push(s);
var v = e.responseState,
c = v.nextSuspenseID++;
- (v = A(v.boundaryPrefix + c.toString(16))),
- (s = s.id = v),
- Kf(n, e.responseState, s),
- es(e, n, i);
+ (v = A(v.boundaryPrefix + c.toString(16))), (s = s.id = v), Kf(n, e.responseState, s), es(e, n, i);
} else if (s.byteSize > e.progressiveChunkSize)
- (s.rootSegmentID = e.nextSegmentId++),
- e.completedBoundaries.push(s),
- Kf(n, e.responseState, s.id),
- es(e, n, i);
+ (s.rootSegmentID = e.nextSegmentId++), e.completedBoundaries.push(s), Kf(n, e.responseState, s.id), es(e, n, i);
else {
if ((se(n, vh), (i = s.completedSegments), i.length !== 1))
- throw Error(
- "A previously unvisited boundary must have exactly one root segment. This is a bug in React."
- );
+ throw Error("A previously unvisited boundary must have exactly one root segment. This is a bug in React.");
hs(e, n, i[0]);
}
return se(n, bh);
}
function fd(e, n, i) {
- return (
- Vh(n, e.responseState, i.formatContext, i.id),
- hs(e, n, i),
- Yh(n, i.formatContext)
- );
+ return Vh(n, e.responseState, i.formatContext, i.id), hs(e, n, i), Yh(n, i.formatContext);
}
function dd(e, n, i) {
- for (var s = i.completedSegments, v = 0; v < s.length; v++)
- Ld(e, n, i, s[v]);
+ for (var s = i.completedSegments, v = 0; v < s.length; v++) Ld(e, n, i, s[v]);
if (
((s.length = 0),
(e = e.responseState),
(s = i.id),
(i = i.rootSegmentID),
L(n, e.startInlineScript),
- e.sentCompleteBoundaryFunction
- ? L(n, Kh)
- : ((e.sentCompleteBoundaryFunction = !0), L(n, Qh)),
+ e.sentCompleteBoundaryFunction ? L(n, Kh) : ((e.sentCompleteBoundaryFunction = !0), L(n, Qh)),
s === null)
)
- throw Error(
- "An ID must have been assigned before we can complete the boundary."
- );
- return (
- (i = i.toString(16)),
- L(n, s),
- L(n, qh),
- L(n, e.segmentPrefix),
- L(n, i),
- se(n, ev)
- );
+ throw Error("An ID must have been assigned before we can complete the boundary.");
+ return (i = i.toString(16)), L(n, s), L(n, qh), L(n, e.segmentPrefix), L(n, i), se(n, ev);
}
function Ld(e, n, i, s) {
if (s.status === 2) return !0;
var v = s.id;
if (v === -1) {
if ((s.id = i.rootSegmentID) === -1)
- throw Error(
- "A root segment ID must have been assigned by now. This is a bug in React."
- );
+ throw Error("A root segment ID must have been assigned by now. This is a bug in React.");
return fd(e, n, s);
}
return (
fd(e, n, s),
(e = e.responseState),
L(n, e.startInlineScript),
- e.sentCompleteSegmentFunction
- ? L(n, Xh)
- : ((e.sentCompleteSegmentFunction = !0), L(n, Gh)),
+ e.sentCompleteSegmentFunction ? L(n, Xh) : ((e.sentCompleteSegmentFunction = !0), L(n, Gh)),
L(n, e.segmentPrefix),
(v = v.toString(16)),
L(n, v),
@@ -6044,14 +5320,10 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
D = m.errorComponentStack;
if (
(L(s, S.startInlineScript),
- S.sentClientRenderFunction
- ? L(s, rv)
- : ((S.sentClientRenderFunction = !0), L(s, tv)),
+ S.sentClientRenderFunction ? L(s, rv) : ((S.sentClientRenderFunction = !0), L(s, tv)),
E === null)
)
- throw Error(
- "An ID must have been assigned before we can complete the boundary."
- );
+ throw Error("An ID must have been assigned before we can complete the boundary.");
if (
(L(s, E),
L(s, nv),
@@ -6153,8 +5425,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
v = n ? n.bootstrapScriptContent : void 0,
c = n ? n.bootstrapScripts : void 0,
m = n ? n.bootstrapModules : void 0;
- (i = i === void 0 ? "" : i),
- (s = s === void 0 ? Kp : A('<script nonce="' + Ae(s) + '">'));
+ (i = i === void 0 ? "" : i), (s = s === void 0 ? Kp : A('<script nonce="' + Ae(s) + '">'));
var S = [];
if ((v !== void 0 && S.push(s, ("" + v).replace(rh, nh), qp), c !== void 0))
for (v = 0; v < c.length; v++) S.push(eh, Ae(c[v]), Vf);
@@ -6172,14 +5443,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
sentClientRenderFunction: !1,
}),
(c = n ? n.namespaceURI : void 0),
- (c = Qt(
- c === "http://www.w3.org/2000/svg"
- ? 2
- : c === "http://www.w3.org/1998/Math/MathML"
- ? 3
- : 0,
- null
- )),
+ (c = Qt(c === "http://www.w3.org/2000/svg" ? 2 : c === "http://www.w3.org/1998/Math/MathML" ? 3 : 0, null)),
(v = n ? n.progressiveChunkSize : void 0),
(s = n ? n.onError : void 0),
(S = n ? n.onAllReady : void 0);
@@ -6223,18 +5487,12 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
xv(i),
{
pipe: function (v) {
- if (s)
- throw Error(
- "React currently only supports piping to one writable stream."
- );
+ if (s) throw Error("React currently only supports piping to one writable stream.");
return (
(s = !0),
Bd(i, v),
v.on("drain", kv(v, i)),
- v.on(
- "error",
- pd(i, Error("The destination stream errored while writing data."))
- ),
+ v.on("error", pd(i, Error("The destination stream errored while writing data."))),
v.on("close", pd(i, Error("The destination stream closed early."))),
v
);
@@ -6247,7 +5505,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
};
_c.version = "18.2.0";
});
-var Hd = an((pa) => {
+var Hd = an(pa => {
"use strict";
process.env.NODE_ENV !== "production" &&
(function () {
@@ -6258,23 +5516,13 @@ var Hd = an((pa) => {
s = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function v(t) {
{
- for (
- var r = arguments.length, l = new Array(r > 1 ? r - 1 : 0), u = 1;
- u < r;
- u++
- )
- l[u - 1] = arguments[u];
+ for (var r = arguments.length, l = new Array(r > 1 ? r - 1 : 0), u = 1; u < r; u++) l[u - 1] = arguments[u];
m("warn", t, l);
}
}
function c(t) {
{
- for (
- var r = arguments.length, l = new Array(r > 1 ? r - 1 : 0), u = 1;
- u < r;
- u++
- )
- l[u - 1] = arguments[u];
+ for (var r = arguments.length, l = new Array(r > 1 ? r - 1 : 0), u = 1; u < r; u++) l[u - 1] = arguments[u];
m("error", t, l);
}
}
@@ -6286,8 +5534,7 @@ var Hd = an((pa) => {
var g = l.map(function (y) {
return String(y);
});
- g.unshift("Warning: " + r),
- Function.prototype.apply.call(console[t], console, g);
+ g.unshift("Warning: " + r), Function.prototype.apply.call(console[t], console, g);
}
}
function S(t) {
@@ -6336,7 +5583,7 @@ var Hd = an((pa) => {
c(
"The provided `%s` attribute is an unsupported type %s. This value must be coerced to a string before before using it here.",
r,
- P(t)
+ P(t),
),
W(t)
);
@@ -6347,7 +5594,7 @@ var Hd = an((pa) => {
c(
"The provided `%s` CSS property is an unsupported type %s. This value must be coerced to a string before before using it here.",
r,
- P(t)
+ P(t),
),
W(t)
);
@@ -6357,7 +5604,7 @@ var Hd = an((pa) => {
return (
c(
"The provided HTML markup uses a value of unsupported type %s. This value must be coerced to a string before before using it here.",
- P(t)
+ P(t),
),
W(t)
);
@@ -6438,17 +5685,10 @@ var Hd = an((pa) => {
l = t[1];
ce[r] = new re(r, ct, !1, l, null, !1, !1);
}),
- ["contentEditable", "draggable", "spellCheck", "value"].forEach(
- function (t) {
- ce[t] = new re(t, qt, !1, t.toLowerCase(), null, !1, !1);
- }
- ),
- [
- "autoReverse",
- "externalResourcesRequired",
- "focusable",
- "preserveAlpha",
- ].forEach(function (t) {
+ ["contentEditable", "draggable", "spellCheck", "value"].forEach(function (t) {
+ ce[t] = new re(t, qt, !1, t.toLowerCase(), null, !1, !1);
+ }),
+ ["autoReverse", "externalResourcesRequired", "focusable", "preserveAlpha"].forEach(function (t) {
ce[t] = new re(t, qt, !1, t, null, !1, !1);
}),
[
@@ -6572,42 +5812,21 @@ var Hd = an((pa) => {
var r = t.replace(rr, nr);
ce[r] = new re(r, ct, !1, t, null, !1, !1);
}),
- [
- "xlink:actuate",
- "xlink:arcrole",
- "xlink:role",
- "xlink:show",
- "xlink:title",
- "xlink:type",
- ].forEach(function (t) {
+ ["xlink:actuate", "xlink:arcrole", "xlink:role", "xlink:show", "xlink:title", "xlink:type"].forEach(function (
+ t,
+ ) {
var r = t.replace(rr, nr);
ce[r] = new re(r, ct, !1, t, "http://www.w3.org/1999/xlink", !1, !1);
}),
["xml:base", "xml:lang", "xml:space"].forEach(function (t) {
var r = t.replace(rr, nr);
- ce[r] = new re(
- r,
- ct,
- !1,
- t,
- "http://www.w3.org/XML/1998/namespace",
- !1,
- !1
- );
+ ce[r] = new re(r, ct, !1, t, "http://www.w3.org/XML/1998/namespace", !1, !1);
}),
["tabIndex", "crossOrigin"].forEach(function (t) {
ce[t] = new re(t, ct, !1, t.toLowerCase(), null, !1, !1);
});
var Rr = "xlinkHref";
- (ce[Rr] = new re(
- "xlinkHref",
- ct,
- !1,
- "xlink:href",
- "http://www.w3.org/1999/xlink",
- !0,
- !1
- )),
+ (ce[Rr] = new re("xlinkHref", ct, !1, "xlink:href", "http://www.w3.org/1999/xlink", !0, !1)),
["src", "href", "action", "formAction"].forEach(function (t) {
ce[t] = new re(t, ct, !1, t.toLowerCase(), null, !0, !0);
});
@@ -6682,14 +5901,14 @@ var Hd = an((pa) => {
r.disabled ||
r.value == null ||
c(
- "You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`."
+ "You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.",
),
r.onChange ||
r.readOnly ||
r.disabled ||
r.checked == null ||
c(
- "You provided a `checked` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultChecked`. Otherwise, set either `onChange` or `readOnly`."
+ "You provided a `checked` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultChecked`. Otherwise, set either `onChange` or `readOnly`.",
);
}
function co(t, r) {
@@ -6770,30 +5989,17 @@ var Hd = an((pa) => {
u = or.hasOwnProperty(l) ? l : null;
if (u == null)
return (
- c(
- "Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.",
- r
- ),
- (je[r] = !0),
- !0
- );
- if (r !== u)
- return (
- c("Invalid ARIA attribute `%s`. Did you mean `%s`?", r, u),
+ c("Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.", r),
(je[r] = !0),
!0
);
+ if (r !== u) return c("Invalid ARIA attribute `%s`. Did you mean `%s`?", r, u), (je[r] = !0), !0;
}
if (ha.test(r)) {
var p = r.toLowerCase(),
g = or.hasOwnProperty(p) ? p : null;
if (g == null) return (je[r] = !0), !1;
- if (r !== g)
- return (
- c("Unknown ARIA attribute `%s`. Did you mean `%s`?", r, g),
- (je[r] = !0),
- !0
- );
+ if (r !== g) return c("Unknown ARIA attribute `%s`. Did you mean `%s`?", r, g), (je[r] = !0), !0;
}
}
return !0;
@@ -6811,16 +6017,12 @@ var Hd = an((pa) => {
})
.join(", ");
l.length === 1
- ? c(
- "Invalid aria prop %s on <%s> tag. For details, see https://reactjs.org/link/invalid-aria-props",
- g,
- t
- )
+ ? c("Invalid aria prop %s on <%s> tag. For details, see https://reactjs.org/link/invalid-aria-props", g, t)
: l.length > 1 &&
c(
"Invalid aria props %s on <%s> tag. For details, see https://reactjs.org/link/invalid-aria-props",
g,
- t
+ t,
);
}
}
@@ -6838,11 +6040,11 @@ var Hd = an((pa) => {
t === "select" && r.multiple
? c(
"`value` prop on `%s` should not be null. Consider using an empty array when `multiple` is set to `true` to clear the component or `undefined` for uncontrolled components.",
- t
+ t,
)
: c(
"`value` prop on `%s` should not be null. Consider using an empty string to clear the component or `undefined` for uncontrolled components.",
- t
+ t,
));
}
}
@@ -7346,7 +6548,7 @@ var Hd = an((pa) => {
if (p === "onfocusin" || p === "onfocusout")
return (
c(
- "React uses onFocus and onBlur instead of onFocusIn and onFocusOut. All React events are normalized to bubble, so onFocusIn and onFocusOut are not needed/supported by React."
+ "React uses onFocus and onBlur instead of onFocusIn and onFocusOut. All React events are normalized to bubble, so onFocusIn and onFocusOut are not needed/supported by React.",
),
(ke[r] = !0),
!0
@@ -7356,31 +6558,14 @@ var Hd = an((pa) => {
y = u.possibleRegistrationNames;
if (g.hasOwnProperty(r)) return !0;
var w = y.hasOwnProperty(p) ? y[p] : null;
- if (w != null)
- return (
- c(
- "Invalid event handler property `%s`. Did you mean `%s`?",
- r,
- w
- ),
- (ke[r] = !0),
- !0
- );
- if (po.test(r))
- return (
- c(
- "Unknown event handler property `%s`. It will be ignored.",
- r
- ),
- (ke[r] = !0),
- !0
- );
+ if (w != null) return c("Invalid event handler property `%s`. Did you mean `%s`?", r, w), (ke[r] = !0), !0;
+ if (po.test(r)) return c("Unknown event handler property `%s`. It will be ignored.", r), (ke[r] = !0), !0;
} else if (po.test(r))
return (
va.test(r) &&
c(
"Invalid event handler property `%s`. React events use the camelCase naming convention, for example `onClick`.",
- r
+ r,
),
(ke[r] = !0),
!0
@@ -7389,7 +6574,7 @@ var Hd = an((pa) => {
if (p === "innerhtml")
return (
c(
- "Directly setting property `innerHTML` is not permitted. For more information, lookup documentation on `dangerouslySetInnerHTML`."
+ "Directly setting property `innerHTML` is not permitted. For more information, lookup documentation on `dangerouslySetInnerHTML`.",
),
(ke[r] = !0),
!0
@@ -7397,7 +6582,7 @@ var Hd = an((pa) => {
if (p === "aria")
return (
c(
- "The `aria` attribute is reserved for future use in React. Pass individual `aria-` attributes instead."
+ "The `aria` attribute is reserved for future use in React. Pass individual `aria-` attributes instead.",
),
(ke[r] = !0),
!0
@@ -7406,17 +6591,14 @@ var Hd = an((pa) => {
return (
c(
"Received a `%s` for a string attribute `is`. If this is expected, cast the value to a string.",
- typeof l
+ typeof l,
),
(ke[r] = !0),
!0
);
if (typeof l == "number" && isNaN(l))
return (
- c(
- "Received NaN for the `%s` attribute. If this is expected, cast the value to a string.",
- r
- ),
+ c("Received NaN for the `%s` attribute. If this is expected, cast the value to a string.", r),
(ke[r] = !0),
!0
);
@@ -7424,18 +6606,13 @@ var Hd = an((pa) => {
_ = C !== null && C.type === F;
if (sr.hasOwnProperty(p)) {
var O = sr[p];
- if (O !== r)
- return (
- c("Invalid DOM property `%s`. Did you mean `%s`?", r, O),
- (ke[r] = !0),
- !0
- );
+ if (O !== r) return c("Invalid DOM property `%s`. Did you mean `%s`?", r, O), (ke[r] = !0), !0;
} else if (!_ && r !== p)
return (
c(
"React does not recognize the `%s` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `%s` instead. If you accidentally passed it from a parent component, remove it from the DOM element.",
r,
- p
+ p,
),
(ke[r] = !0),
!0
@@ -7448,7 +6625,7 @@ var Hd = an((pa) => {
r,
r,
l,
- r
+ r,
)
: c(
'Received `%s` for a non-boolean attribute `%s`.\n\nIf you want to write it to the DOM, pass a string instead: %s="%s" or %s={value.toString()}.\n\nIf you used to conditionally omit it with %s={condition && value}, pass %s={condition ? value : undefined} instead.',
@@ -7458,7 +6635,7 @@ var Hd = an((pa) => {
l,
r,
r,
- r
+ r,
),
(ke[r] = !0),
!0)
@@ -7477,7 +6654,7 @@ var Hd = an((pa) => {
? "The browser will interpret it as a truthy value."
: 'Although this works, it will not work as expected if you pass the string "false".',
r,
- l
+ l,
),
(ke[r] = !0)),
!0);
@@ -7499,13 +6676,13 @@ var Hd = an((pa) => {
? c(
"Invalid value for prop %s on <%s> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM. For details, see https://reactjs.org/link/attribute-behavior ",
y,
- t
+ t,
)
: u.length > 1 &&
c(
"Invalid values for props %s on <%s> tag. Either remove them from the element, or pass a string or number value to keep them in the DOM. For details, see https://reactjs.org/link/attribute-behavior ",
y,
- t
+ t,
);
}
};
@@ -7529,12 +6706,7 @@ var Hd = an((pa) => {
},
_r = function (t) {
(xt.hasOwnProperty(t) && xt[t]) ||
- ((xt[t] = !0),
- c(
- "Unsupported style property %s. Did you mean %s?",
- t,
- ur(t.replace(Te, "ms-"))
- ));
+ ((xt[t] = !0), c("Unsupported style property %s. Did you mean %s?", t, ur(t.replace(Te, "ms-"))));
},
ya = function (t) {
(xt.hasOwnProperty(t) && xt[t]) ||
@@ -7542,42 +6714,23 @@ var Hd = an((pa) => {
c(
"Unsupported vendor-prefixed style property %s. Did you mean %s?",
t,
- t.charAt(0).toUpperCase() + t.slice(1)
+ t.charAt(0).toUpperCase() + t.slice(1),
));
},
ba = function (t, r) {
(hn.hasOwnProperty(r) && hn[r]) ||
((hn[r] = !0),
- c(
- `Style property values shouldn't contain a semicolon. Try "%s: %s" instead.`,
- t,
- r.replace(go, "")
- ));
+ c(`Style property values shouldn't contain a semicolon. Try "%s: %s" instead.`, t, r.replace(go, "")));
},
mo = function (t, r) {
- vn ||
- ((vn = !0),
- c(
- "`NaN` is an invalid value for the `%s` css style property.",
- t
- ));
+ vn || ((vn = !0), c("`NaN` is an invalid value for the `%s` css style property.", t));
},
Ut = function (t, r) {
- Ir ||
- ((Ir = !0),
- c(
- "`Infinity` is an invalid value for the `%s` css style property.",
- t
- ));
+ Ir || ((Ir = !0), c("`Infinity` is an invalid value for the `%s` css style property.", t));
};
pn = function (t, r) {
- t.indexOf("-") > -1
- ? _r(t)
- : wt.test(t)
- ? ya(t)
- : go.test(r) && ba(t, r),
- typeof r == "number" &&
- (isNaN(r) ? mo(t, r) : isFinite(r) || Ut(t, r));
+ t.indexOf("-") > -1 ? _r(t) : wt.test(t) ? ya(t) : go.test(r) && ba(t, r),
+ typeof r == "number" && (isNaN(r) ? mo(t, r) : isFinite(r) || Ut(t, r));
};
}
var gn = pn,
@@ -7632,7 +6785,7 @@ var Hd = an((pa) => {
((mn = !0),
c(
"A future version of React will block javascript: URLs as a security precaution. Use event handlers instead if you can. If you need to generate unsafe HTML try using dangerouslySetInnerHTML instead. React was passed %s.",
- JSON.stringify(t)
+ JSON.stringify(t),
));
}
var Ta = Array.isArray;
@@ -7657,8 +6810,7 @@ var Hd = an((pa) => {
w = [];
if ((l !== void 0 && w.push(y, So(l), Ca), u !== void 0))
for (var C = 0; C < u.length; C++) w.push(Ea, ge(u[C]), bo);
- if (p !== void 0)
- for (var _ = 0; _ < p.length; _++) w.push(Ra, ge(p[_]), bo);
+ if (p !== void 0) for (var _ = 0; _ < p.length; _++) w.push(Ra, ge(p[_]), bo);
return {
bootstrapChunks: w,
startInlineScript: y,
@@ -7704,9 +6856,7 @@ var Hd = an((pa) => {
case "tr":
return He(Tt, null);
}
- return t.insertionMode >= fr || t.insertionMode === Fr
- ? He(kt, null)
- : t;
+ return t.insertionMode >= fr || t.insertionMode === Fr ? He(kt, null) : t;
}
var Ct = null;
function Wt(t) {
@@ -7741,7 +6891,7 @@ var Hd = an((pa) => {
function wo(t, r, l) {
if (typeof l != "object")
throw new Error(
- "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX."
+ "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX.",
);
var u = !0;
for (var p in l)
@@ -7782,13 +6932,7 @@ var Hd = an((pa) => {
case "suppressHydrationWarning":
return;
}
- if (
- !(
- l.length > 2 &&
- (l[0] === "o" || l[0] === "O") &&
- (l[1] === "n" || l[1] === "N")
- )
- ) {
+ if (!(l.length > 2 && (l[0] === "o" || l[0] === "O") && (l[1] === "n" || l[1] === "N"))) {
var p = er(l);
if (p !== null) {
switch (typeof u) {
@@ -7805,9 +6949,7 @@ var Hd = an((pa) => {
u && t.push(We, y, $t);
return;
case Mt:
- u === !0
- ? t.push(We, y, $t)
- : u === !1 || t.push(We, y, Rt, ge(u), ht);
+ u === !0 ? t.push(We, y, $t) : u === !1 || t.push(We, y, Rt, ge(u), ht);
return;
case Lt:
isNaN(u) || t.push(We, y, Rt, ge(u), ht);
@@ -7816,8 +6958,7 @@ var Hd = an((pa) => {
!isNaN(u) && u >= 1 && t.push(We, y, Rt, ge(u), ht);
break;
default:
- p.sanitizeURL && (q(u, g), (u = "" + u), yo(u)),
- t.push(We, y, Rt, ge(u), ht);
+ p.sanitizeURL && (q(u, g), (u = "" + u), yo(u)), t.push(We, y, Rt, ge(u), ht);
}
} else if (bt(l)) {
switch (typeof u) {
@@ -7837,13 +6978,10 @@ var Hd = an((pa) => {
pr = "/>";
function hr(t, r, l) {
if (r != null) {
- if (l != null)
- throw new Error(
- "Can only set one of `children` or `props.dangerouslySetInnerHTML`."
- );
+ if (l != null) throw new Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
if (typeof r != "object" || !("__html" in r))
throw new Error(
- "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information."
+ "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information.",
);
var u = r.__html;
u != null && (_e(u), t.push("" + u));
@@ -7862,16 +7000,10 @@ var Hd = an((pa) => {
if (l != null) {
var u = me(l);
t.multiple && !u
- ? c(
- "The `%s` prop supplied to <select> must be an array if `multiple` is true.",
- r
- )
+ ? c("The `%s` prop supplied to <select> must be an array if `multiple` is true.", r)
: !t.multiple &&
u &&
- c(
- "The `%s` prop supplied to <select> must be a scalar value if `multiple` is false.",
- r
- );
+ c("The `%s` prop supplied to <select> must be a scalar value if `multiple` is false.", r);
}
}
}
@@ -7883,7 +7015,7 @@ var Hd = an((pa) => {
r.defaultValue !== void 0 &&
!Ze &&
(c(
- "Select elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled select element and remove one of these props. More info: https://reactjs.org/link/controlled-components"
+ "Select elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled select element and remove one of these props. More info: https://reactjs.org/link/controlled-components",
),
(Ze = !0)),
t.push(Be("select"));
@@ -7921,7 +7053,7 @@ var Hd = an((pa) => {
typeof l != "number" &&
((vt = !0),
c(
- "Cannot infer the option value of complex children. Pass a `value` prop or use a plain string as children to <option>."
+ "Cannot infer the option value of complex children. Pass a `value` prop or use a plain string as children to <option>.",
)));
}),
r
@@ -7947,7 +7079,7 @@ var Hd = an((pa) => {
(w = O),
Re ||
(c(
- "Use the `defaultValue` or `value` props on <select> instead of setting `selected` on <option>."
+ "Use the `defaultValue` or `value` props on <select> instead of setting `selected` on <option>.",
),
(Re = !0));
break;
@@ -7970,7 +7102,7 @@ var Hd = an((pa) => {
(Ur ||
((Ur = !0),
c(
- "Pass a `value` prop if you set dangerouslyInnerHTML so React knows which value should be selected."
+ "Pass a `value` prop if you set dangerouslyInnerHTML so React knows which value should be selected.",
))),
(j = gr(g))),
me(p))
@@ -7995,7 +7127,7 @@ var Hd = an((pa) => {
(c(
"%s contains an input of type %s with both checked and defaultChecked props. Input elements must be either controlled or uncontrolled (specify either the checked prop, or the defaultChecked prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://reactjs.org/link/controlled-components",
"A component",
- r.type
+ r.type,
),
(vr = !0)),
r.value !== void 0 &&
@@ -8004,7 +7136,7 @@ var Hd = an((pa) => {
(c(
"%s contains an input of type %s with both value and defaultValue props. Input elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://reactjs.org/link/controlled-components",
"A component",
- r.type
+ r.type,
),
(It = !0)),
t.push(Be("input"));
@@ -8020,7 +7152,7 @@ var Hd = an((pa) => {
case "children":
case "dangerouslySetInnerHTML":
throw new Error(
- "input is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`."
+ "input is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.",
);
case "defaultChecked":
y = C;
@@ -8040,12 +7172,8 @@ var Hd = an((pa) => {
}
}
return (
- g !== null
- ? Ce(t, l, "checked", g)
- : y !== null && Ce(t, l, "checked", y),
- u !== null
- ? Ce(t, l, "value", u)
- : p !== null && Ce(t, l, "value", p),
+ g !== null ? Ce(t, l, "checked", g) : y !== null && Ce(t, l, "checked", y),
+ u !== null ? Ce(t, l, "value", u) : p !== null && Ce(t, l, "value", p),
t.push(pr),
null
);
@@ -8056,7 +7184,7 @@ var Hd = an((pa) => {
r.defaultValue !== void 0 &&
!_t &&
(c(
- "Textarea elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled textarea and remove one of these props. More info: https://reactjs.org/link/controlled-components"
+ "Textarea elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled textarea and remove one of these props. More info: https://reactjs.org/link/controlled-components",
),
(_t = !0)),
t.push(Be("textarea"));
@@ -8078,27 +7206,17 @@ var Hd = an((pa) => {
p = w;
break;
case "dangerouslySetInnerHTML":
- throw new Error(
- "`dangerouslySetInnerHTML` does not make sense on <textarea>."
- );
+ throw new Error("`dangerouslySetInnerHTML` does not make sense on <textarea>.");
default:
Ce(t, l, y, w);
break;
}
}
if ((u === null && p !== null && (u = p), t.push(rt), g != null)) {
- if (
- (c(
- "Use the `defaultValue` or `value` props instead of setting children on <textarea>."
- ),
- u != null)
- )
- throw new Error(
- "If you supply `defaultValue` on a <textarea>, do not pass children."
- );
+ if ((c("Use the `defaultValue` or `value` props instead of setting children on <textarea>."), u != null))
+ throw new Error("If you supply `defaultValue` on a <textarea>, do not pass children.");
if (me(g)) {
- if (g.length > 1)
- throw new Error("<textarea> can only have at most one child.");
+ if (g.length > 1) throw new Error("<textarea> can only have at most one child.");
_e(g[0]), (u = "" + g[0]);
}
_e(g), (u = "" + g);
@@ -8123,8 +7241,7 @@ var Hd = an((pa) => {
case "children":
case "dangerouslySetInnerHTML":
throw new Error(
- l +
- " is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`."
+ l + " is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.",
);
default:
Ce(t, u, p, g);
@@ -8142,9 +7259,7 @@ var Hd = an((pa) => {
switch (u) {
case "children":
case "dangerouslySetInnerHTML":
- throw new Error(
- "menuitems cannot have `children` nor `dangerouslySetInnerHTML`."
- );
+ throw new Error("menuitems cannot have `children` nor `dangerouslySetInnerHTML`.");
default:
Ce(t, l, u, p);
break;
@@ -8164,9 +7279,7 @@ var Hd = an((pa) => {
u = g;
break;
case "dangerouslySetInnerHTML":
- throw new Error(
- "`dangerouslySetInnerHTML` does not make sense on <title>."
- );
+ throw new Error("`dangerouslySetInnerHTML` does not make sense on <title>.");
default:
Ce(t, l, p, g);
break;
@@ -8177,17 +7290,17 @@ var Hd = an((pa) => {
var y = Array.isArray(u) && u.length < 2 ? u[0] || null : u;
Array.isArray(u) && u.length > 1
? c(
- "A title element received an array with more than 1 element as children. In browsers title Elements can only have Text Nodes as children. If the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering"
+ "A title element received an array with more than 1 element as children. In browsers title Elements can only have Text Nodes as children. If the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering",
)
: y != null && y.$$typeof != null
? c(
- "A title element received a React element for children. In the browser title Elements can only have Text Nodes as children. If the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering"
+ "A title element received a React element for children. In the browser title Elements can only have Text Nodes as children. If the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering",
)
: y != null &&
typeof y != "string" &&
typeof y != "number" &&
c(
- "A title element received a value that was not a string or number for children. In the browser title Elements can only have Text Nodes as children. If the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering"
+ "A title element received a value that was not a string or number for children. In the browser title Elements can only have Text Nodes as children. If the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering",
);
}
return u;
@@ -8212,11 +7325,7 @@ var Hd = an((pa) => {
break;
}
}
- return (
- t.push(rt),
- hr(t, g, p),
- typeof p == "string" ? (t.push(Et(p)), null) : p
- );
+ return t.push(rt), hr(t, g, p), typeof p == "string" ? (t.push(Et(p)), null) : p;
}
function Pa(t, r, l, u) {
t.push(Be(l));
@@ -8240,10 +7349,7 @@ var Hd = an((pa) => {
case "suppressHydrationWarning":
break;
default:
- bt(y) &&
- typeof w != "function" &&
- typeof w != "symbol" &&
- t.push(We, y, Rt, ge(w), ht);
+ bt(y) && typeof w != "function" && typeof w != "symbol" && t.push(We, y, Rt, ge(w), ht);
break;
}
}
@@ -8272,13 +7378,10 @@ var Hd = an((pa) => {
}
}
if ((t.push(rt), g != null)) {
- if (p != null)
- throw new Error(
- "Can only set one of `children` or `props.dangerouslySetInnerHTML`."
- );
+ if (p != null) throw new Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
if (typeof g != "object" || !("__html" in g))
throw new Error(
- "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information."
+ "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information.",
);
var C = g.__html;
C != null &&
@@ -8319,7 +7422,7 @@ var Hd = an((pa) => {
l.contentEditable &&
l.children != null &&
c(
- "A component is `contentEditable` and contains `children` managed by React. It is now your responsibility to guarantee that none of those nodes are unexpectedly modified or duplicated. This is probably not intentional."
+ "A component is `contentEditable` and contains `children` managed by React. It is now your responsibility to guarantee that none of those nodes are unexpectedly modified or duplicated. This is probably not intentional.",
),
p.insertionMode !== Ar &&
p.insertionMode !== Dr &&
@@ -8328,7 +7431,7 @@ var Hd = an((pa) => {
r.toLowerCase() !== r &&
c(
"<%s /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.",
- r
+ r,
),
r)
) {
@@ -8374,9 +7477,7 @@ var Hd = an((pa) => {
case "html":
return p.insertionMode === Fr && t.push(En), Pt(t, l, r, u);
default:
- return r.indexOf("-") === -1 && typeof l.is != "string"
- ? Pt(t, l, r, u)
- : Pa(t, l, r, u);
+ return r.indexOf("-") === -1 && typeof l.is != "string" ? Pt(t, l, r, u) : Pa(t, l, r, u);
}
}
var Aa = "</",
@@ -8404,8 +7505,7 @@ var Hd = an((pa) => {
}
}
function _n(t, r) {
- for (var l = r.bootstrapChunks, u = 0; u < l.length - 1; u++)
- x(t, l[u]);
+ for (var l = r.bootstrapChunks, u = 0; u < l.length - 1; u++) x(t, l[u]);
return u < l.length ? R(t, l[u]) : !0;
}
var h = '<template id="',
@@ -8431,9 +7531,7 @@ var Hd = an((pa) => {
}
function yr(t, r, l) {
if ((x(t, I), l === null))
- throw new Error(
- "An ID must have been assigned before we can complete the boundary."
- );
+ throw new Error("An ID must have been assigned before we can complete the boundary.");
return x(t, l), R(t, U);
}
function Pn(t, r, l, u, p) {
@@ -8482,33 +7580,19 @@ var Hd = an((pa) => {
switch (l.insertionMode) {
case Fr:
case kt:
- return (
- x(t, Oa), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, Eo)
- );
+ return x(t, Oa), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, Eo);
case Ar:
- return (
- x(t, vs), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, gs)
- );
+ return x(t, vs), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, gs);
case Dr:
- return (
- x(t, ms), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, ys)
- );
+ return x(t, ms), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, ys);
case fr:
- return (
- x(t, bs), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, Ss)
- );
+ return x(t, bs), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, Ss);
case yn:
- return (
- x(t, xs), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, ks)
- );
+ return x(t, xs), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, ks);
case Tt:
- return (
- x(t, Cs), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, Es)
- );
+ return x(t, Cs), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, Es);
case Or:
- return (
- x(t, Is), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, _s)
- );
+ return x(t, Is), x(t, r.segmentPrefix), x(t, u.toString(16)), R(t, _s);
default:
throw new Error("Unknown insertion mode. This is a bug in React.");
}
@@ -8546,9 +7630,7 @@ var Hd = an((pa) => {
js = '")</script>';
function Hs(t, r, l) {
x(t, r.startInlineScript),
- r.sentCompleteSegmentFunction
- ? x(t, Bs)
- : ((r.sentCompleteSegmentFunction = !0), x(t, Ls)),
+ r.sentCompleteSegmentFunction ? x(t, Bs) : ((r.sentCompleteSegmentFunction = !0), x(t, Ls)),
x(t, r.segmentPrefix);
var u = l.toString(16);
return x(t, u), x(t, Us), x(t, r.placeholderPrefix), x(t, u), R(t, js);
@@ -8560,14 +7642,10 @@ var Hd = an((pa) => {
function Vs(t, r, l, u) {
if (
(x(t, r.startInlineScript),
- r.sentCompleteBoundaryFunction
- ? x(t, zs)
- : ((r.sentCompleteBoundaryFunction = !0), x(t, Ws)),
+ r.sentCompleteBoundaryFunction ? x(t, zs) : ((r.sentCompleteBoundaryFunction = !0), x(t, Ws)),
l === null)
)
- throw new Error(
- "An ID must have been assigned before we can complete the boundary."
- );
+ throw new Error("An ID must have been assigned before we can complete the boundary.");
var p = u.toString(16);
return x(t, l), x(t, $s), x(t, r.segmentPrefix), x(t, p), R(t, Ns);
}
@@ -8579,14 +7657,10 @@ var Hd = an((pa) => {
function Js(t, r, l, u, p, g) {
if (
(x(t, r.startInlineScript),
- r.sentClientRenderFunction
- ? x(t, Gs)
- : ((r.sentClientRenderFunction = !0), x(t, Ys)),
+ r.sentClientRenderFunction ? x(t, Gs) : ((r.sentClientRenderFunction = !0), x(t, Ys)),
l === null)
)
- throw new Error(
- "An ID must have been assigned before we can complete the boundary."
- );
+ throw new Error("An ID must have been assigned before we can complete the boundary.");
return (
x(t, l),
x(t, Xs),
@@ -8609,7 +7683,7 @@ var Hd = an((pa) => {
return "\\u2029";
default:
throw new Error(
- "escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React"
+ "escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React",
);
}
});
@@ -8689,7 +7763,7 @@ var Hd = an((pa) => {
if (
(typeof t.tag == "number" &&
c(
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.",
),
typeof t == "function")
)
@@ -8788,10 +7862,7 @@ var Hd = an((pa) => {
groupEnd: Qe({}, t, { value: Ga }),
});
}
- Nr < 0 &&
- c(
- "disabledDepth fell below zero. This is a bug in React. Please file an issue."
- );
+ Nr < 0 && c("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
}
}
var Za = s.ReactCurrentDispatcher,
@@ -8888,9 +7959,7 @@ var Hd = an((pa) => {
`
` + w[_].replace(" at new ", " at ");
return (
- t.displayName &&
- j.includes("<anonymous>") &&
- (j = j.replace("<anonymous>", t.displayName)),
+ t.displayName && j.includes("<anonymous>") && (j = j.replace("<anonymous>", t.displayName)),
typeof t == "function" && Nt.set(t, j),
j
);
@@ -8968,18 +8037,11 @@ var Hd = an((pa) => {
y +
"` is invalid; it must be a function, usually from the `prop-types` package, but received `" +
typeof t[y] +
- "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
+ "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.",
);
throw ((C.name = "Invariant Violation"), C);
}
- w = t[y](
- r,
- y,
- u,
- l,
- null,
- "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"
- );
+ w = t[y](r, y, u, l, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
} catch (_) {
w = _;
}
@@ -8991,15 +8053,12 @@ var Hd = an((pa) => {
u || "React class",
l,
y,
- typeof w
+ typeof w,
),
Ln(null)),
w instanceof Error &&
!(w.message in rl) &&
- ((rl[w.message] = !0),
- Ln(p),
- c("Failed %s type: %s", l, w.message),
- Ln(null));
+ ((rl[w.message] = !0), Ln(p), c("Failed %s type: %s", l, w.message), Ln(null));
}
}
}
@@ -9030,7 +8089,7 @@ var Hd = an((pa) => {
c(
"%s.childContextTypes is specified but there is no getChildContext() method on the instance. You can either define getChildContext() on %s or remove childContextTypes from it.",
p,
- p
+ p,
));
}
return l;
@@ -9039,10 +8098,7 @@ var Hd = an((pa) => {
for (var y in g)
if (!(y in u))
throw new Error(
- (ie(r) || "Unknown") +
- '.getChildContext(): key "' +
- y +
- '" is not defined in childContextTypes.'
+ (ie(r) || "Unknown") + '.getChildContext(): key "' + y + '" is not defined in childContextTypes.',
);
{
var w = ie(r) || "Unknown";
@@ -9067,15 +8123,9 @@ var Hd = an((pa) => {
var l = t.parent,
u = r.parent;
if (l === null) {
- if (u !== null)
- throw new Error(
- "The stacks must reach the root at the same time. This is a bug in React."
- );
+ if (u !== null) throw new Error("The stacks must reach the root at the same time. This is a bug in React.");
} else {
- if (u === null)
- throw new Error(
- "The stacks must reach the root at the same time. This is a bug in React."
- );
+ if (u === null) throw new Error("The stacks must reach the root at the same time. This is a bug in React.");
Zr(l, u);
}
Ft(r);
@@ -9094,17 +8144,13 @@ var Hd = an((pa) => {
qa(t);
var l = t.parent;
if (l === null)
- throw new Error(
- "The depth must equal at least at zero before reaching the root. This is a bug in React."
- );
+ throw new Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");
l.depth === r.depth ? Zr(l, r) : ei(l, r);
}
function ti(t, r) {
var l = r.parent;
if (l === null)
- throw new Error(
- "The depth must equal at least at zero before reaching the root. This is a bug in React."
- );
+ throw new Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");
t.depth === l.depth ? Zr(t, l) : ti(t, l), Ft(r);
}
function jn(t) {
@@ -9130,7 +8176,7 @@ var Hd = an((pa) => {
t._currentRenderer2 !== null &&
t._currentRenderer2 !== Xr &&
c(
- "Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported."
+ "Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.",
),
(t._currentRenderer2 = Xr);
var u = nt,
@@ -9145,24 +8191,16 @@ var Hd = an((pa) => {
}
function Lo(t) {
var r = nt;
- if (r === null)
- throw new Error(
- "Tried to pop a Context at the root of the app. This is a bug in React."
- );
- r.context !== t &&
- c(
- "The parent context is not the expected context. This is probably a bug in React."
- );
+ if (r === null) throw new Error("Tried to pop a Context at the root of the app. This is a bug in React.");
+ r.context !== t && c("The parent context is not the expected context. This is probably a bug in React.");
{
var l = r.parentValue;
- l === ru
- ? (r.context._currentValue2 = r.context._defaultValue)
- : (r.context._currentValue2 = l),
+ l === ru ? (r.context._currentValue2 = r.context._defaultValue) : (r.context._currentValue2 = l),
t._currentRenderer2 !== void 0 &&
t._currentRenderer2 !== null &&
t._currentRenderer2 !== Xr &&
c(
- "Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported."
+ "Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.",
),
(t._currentRenderer2 = Xr);
}
@@ -9209,7 +8247,7 @@ var Hd = an((pa) => {
c(
"%s(...): Expected the last optional `callback` argument to be a function. Instead received: %s.",
r,
- t
+ t,
));
}
}),
@@ -9220,7 +8258,7 @@ var Hd = an((pa) => {
($n.add(l),
c(
"%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. You have returned undefined.",
- l
+ l,
));
}
});
@@ -9237,7 +8275,7 @@ var Hd = an((pa) => {
Please check the code for the %s component.`,
r,
r,
- u
+ u,
),
(Bo[p] = !0);
}
@@ -9248,9 +8286,7 @@ Please check the code for the %s component.`,
},
enqueueSetState: function (t, r, l) {
var u = ri(t);
- u.queue === null
- ? $o(t, "setState")
- : (u.queue.push(r), l != null && Jr(l, "setState"));
+ u.queue === null ? $o(t, "setState") : (u.queue.push(r), l != null && Jr(l, "setState"));
},
enqueueReplaceState: function (t, r, l) {
var u = ri(t);
@@ -9258,9 +8294,7 @@ Please check the code for the %s component.`,
},
enqueueForceUpdate: function (t, r) {
var l = ri(t);
- l.queue === null
- ? $o(t, "forceUpdate")
- : r != null && Jr(r, "setState");
+ l.queue === null ? $o(t, "forceUpdate") : r != null && Jr(r, "setState");
},
};
function al(t, r, l, u, p) {
@@ -9273,9 +8307,7 @@ Please check the code for the %s component.`,
var u = Bn,
p = t.contextType;
if ("contextType" in t) {
- var g =
- p === null ||
- (p !== void 0 && p.$$typeof === Io && p._context === void 0);
+ var g = p === null || (p !== void 0 && p.$$typeof === Io && p._context === void 0);
if (!g && !Nn.has(t)) {
Nn.add(t);
var y = "";
@@ -9288,24 +8320,18 @@ Please check the code for the %s component.`,
? (y = " Did you accidentally pass the Context.Provider instead?")
: p._context !== void 0
? (y = " Did you accidentally pass the Context.Consumer instead?")
- : (y =
- " However, it is set to an object with keys {" +
- Object.keys(p).join(", ") +
- "}."),
+ : (y = " However, it is set to an object with keys {" + Object.keys(p).join(", ") + "}."),
c(
"%s defines an invalid contextType. contextType should point to the Context object returned by React.createContext().%s",
ie(t) || "Component",
- y
+ y,
);
}
}
typeof p == "object" && p !== null ? (u = Hn(p)) : (u = l);
var w = new t(r, u);
{
- if (
- typeof t.getDerivedStateFromProps == "function" &&
- (w.state === null || w.state === void 0)
- ) {
+ if (typeof t.getDerivedStateFromProps == "function" && (w.state === null || w.state === void 0)) {
var C = ie(t) || "Component";
Uo.has(C) ||
(Uo.add(C),
@@ -9313,32 +8339,24 @@ Please check the code for the %s component.`,
"`%s` uses `getDerivedStateFromProps` but its initial state is %s. This is not recommended. Instead, define the initial state by assigning an object to `this.state` in the constructor of `%s`. This ensures that `getDerivedStateFromProps` arguments have a consistent shape.",
C,
w.state === null ? "null" : "undefined",
- C
+ C,
));
}
- if (
- typeof t.getDerivedStateFromProps == "function" ||
- typeof w.getSnapshotBeforeUpdate == "function"
- ) {
+ if (typeof t.getDerivedStateFromProps == "function" || typeof w.getSnapshotBeforeUpdate == "function") {
var _ = null,
O = null,
j = null;
if (
- (typeof w.componentWillMount == "function" &&
- w.componentWillMount.__suppressDeprecationWarning !== !0
+ (typeof w.componentWillMount == "function" && w.componentWillMount.__suppressDeprecationWarning !== !0
? (_ = "componentWillMount")
- : typeof w.UNSAFE_componentWillMount == "function" &&
- (_ = "UNSAFE_componentWillMount"),
+ : typeof w.UNSAFE_componentWillMount == "function" && (_ = "UNSAFE_componentWillMount"),
typeof w.componentWillReceiveProps == "function" &&
w.componentWillReceiveProps.__suppressDeprecationWarning !== !0
? (O = "componentWillReceiveProps")
- : typeof w.UNSAFE_componentWillReceiveProps == "function" &&
- (O = "UNSAFE_componentWillReceiveProps"),
- typeof w.componentWillUpdate == "function" &&
- w.componentWillUpdate.__suppressDeprecationWarning !== !0
+ : typeof w.UNSAFE_componentWillReceiveProps == "function" && (O = "UNSAFE_componentWillReceiveProps"),
+ typeof w.componentWillUpdate == "function" && w.componentWillUpdate.__suppressDeprecationWarning !== !0
? (j = "componentWillUpdate")
- : typeof w.UNSAFE_componentWillUpdate == "function" &&
- (j = "UNSAFE_componentWillUpdate"),
+ : typeof w.UNSAFE_componentWillUpdate == "function" && (j = "UNSAFE_componentWillUpdate"),
_ !== null || O !== null || j !== null)
) {
var Z = ie(t) || "Component",
@@ -9368,7 +8386,7 @@ https://reactjs.org/link/unsafe-component-lifecycles`,
j !== null
? `
` + j
- : ""
+ : "",
));
}
}
@@ -9383,39 +8401,39 @@ https://reactjs.org/link/unsafe-component-lifecycles`,
(r.prototype && typeof r.prototype.render == "function"
? c(
"%s(...): No `render` method found on the returned component instance: did you accidentally return an object from the constructor?",
- u
+ u,
)
: c(
"%s(...): No `render` method found on the returned component instance: you may have forgotten to define `render`.",
- u
+ u,
)),
t.getInitialState &&
!t.getInitialState.isReactClassApproved &&
!t.state &&
c(
"getInitialState was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Did you mean to define a state property instead?",
- u
+ u,
),
t.getDefaultProps &&
!t.getDefaultProps.isReactClassApproved &&
c(
"getDefaultProps was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Use a static property to define defaultProps instead.",
- u
+ u,
),
t.propTypes &&
c(
"propTypes was defined as an instance property on %s. Use a static property to define propTypes instead.",
- u
+ u,
),
t.contextType &&
c(
"contextType was defined as an instance property on %s. Use a static property to define contextType instead.",
- u
+ u,
),
t.contextTypes &&
c(
"contextTypes was defined as an instance property on %s. Use a static property to define contextTypes instead.",
- u
+ u,
),
r.contextType &&
r.contextTypes &&
@@ -9423,39 +8441,36 @@ https://reactjs.org/link/unsafe-component-lifecycles`,
(Qr.add(r),
c(
"%s declares both contextTypes and contextType static properties. The legacy contextTypes property will be ignored.",
- u
+ u,
)),
typeof t.componentShouldUpdate == "function" &&
c(
"%s has a method called componentShouldUpdate(). Did you mean shouldComponentUpdate()? The name is phrased as a question because the function is expected to return a value.",
- u
+ u,
),
r.prototype &&
r.prototype.isPureReactComponent &&
typeof t.shouldComponentUpdate < "u" &&
c(
"%s has a method called shouldComponentUpdate(). shouldComponentUpdate should not be used when extending React.PureComponent. Please extend React.Component if shouldComponentUpdate is used.",
- ie(r) || "A pure component"
+ ie(r) || "A pure component",
),
typeof t.componentDidUnmount == "function" &&
c(
"%s has a method called componentDidUnmount(). But there is no such lifecycle method. Did you mean componentWillUnmount()?",
- u
+ u,
),
typeof t.componentDidReceiveProps == "function" &&
c(
"%s has a method called componentDidReceiveProps(). But there is no such lifecycle method. If you meant to update the state in response to changing props, use componentWillReceiveProps(). If you meant to fetch data or run side-effects or mutations after React has updated the UI, use componentDidUpdate().",
- u
+ u,
),
typeof t.componentWillRecieveProps == "function" &&
- c(
- "%s has a method called componentWillRecieveProps(). Did you mean componentWillReceiveProps()?",
- u
- ),
+ c("%s has a method called componentWillRecieveProps(). Did you mean componentWillReceiveProps()?", u),
typeof t.UNSAFE_componentWillRecieveProps == "function" &&
c(
"%s has a method called UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?",
- u
+ u,
);
var g = t.props !== l;
t.props !== void 0 &&
@@ -9463,13 +8478,13 @@ https://reactjs.org/link/unsafe-component-lifecycles`,
c(
"%s(...): When calling super() in `%s`, make sure to pass up the same props that your component's constructor was passed.",
u,
- u
+ u,
),
t.defaultProps &&
c(
"Setting defaultProps as an instance property on %s is not supported and will be ignored. Instead, define defaultProps as a static property on %s.",
u,
- u
+ u,
),
typeof t.getSnapshotBeforeUpdate == "function" &&
typeof t.componentDidUpdate != "function" &&
@@ -9477,33 +8492,28 @@ https://reactjs.org/link/unsafe-component-lifecycles`,
(jo.add(r),
c(
"%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). This component defines getSnapshotBeforeUpdate() only.",
- ie(r)
+ ie(r),
)),
typeof t.getDerivedStateFromProps == "function" &&
c(
"%s: getDerivedStateFromProps() is defined as an instance method and will be ignored. Instead, declare it as a static method.",
- u
+ u,
),
typeof t.getDerivedStateFromError == "function" &&
c(
"%s: getDerivedStateFromError() is defined as an instance method and will be ignored. Instead, declare it as a static method.",
- u
+ u,
),
typeof r.getSnapshotBeforeUpdate == "function" &&
c(
"%s: getSnapshotBeforeUpdate() is defined as a static method and will be ignored. Instead, declare it as an instance method.",
- u
+ u,
);
var y = t.state;
- y &&
- (typeof y != "object" || me(y)) &&
- c("%s.state: must be set to an object or null", u),
+ y && (typeof y != "object" || me(y)) && c("%s.state: must be set to an object or null", u),
typeof t.getChildContext == "function" &&
typeof r.childContextTypes != "object" &&
- c(
- "%s.getChildContext(): childContextTypes must be defined in order to use getChildContext().",
- u
- );
+ c("%s.getChildContext(): childContextTypes must be defined in order to use getChildContext().", u);
}
}
function cu(t, r) {
@@ -9518,18 +8528,17 @@ https://reactjs.org/link/unsafe-component-lifecycles`,
* Move code from componentWillMount to componentDidMount (preferred in most cases) or the constructor.
Please update the following components: %s`,
- u
+ u,
),
(ol[u] = !0));
}
r.componentWillMount();
}
- typeof r.UNSAFE_componentWillMount == "function" &&
- r.UNSAFE_componentWillMount(),
+ typeof r.UNSAFE_componentWillMount == "function" && r.UNSAFE_componentWillMount(),
l !== r.state &&
(c(
"%s.componentWillMount(): Assigning directly to this.state is deprecated (except inside a component's constructor). Use setState instead.",
- ie(t) || "Component"
+ ie(t) || "Component",
),
ni.enqueueReplaceState(r, r.state, null));
}
@@ -9537,14 +8546,9 @@ Please update the following components: %s`,
if (t.queue !== null && t.queue.length > 0) {
var p = t.queue,
g = t.replace;
- if (((t.queue = null), (t.replace = !1), g && p.length === 1))
- r.state = p[0];
+ if (((t.queue = null), (t.replace = !1), g && p.length === 1)) r.state = p[0];
else {
- for (
- var y = g ? p[0] : r.state, w = !0, C = g ? 1 : 0;
- C < p.length;
- C++
- ) {
+ for (var y = g ? p[0] : r.state, w = !0, C = g ? 1 : 0; C < p.length; C++) {
var _ = p[C],
O = typeof _ == "function" ? _.call(r, y, l, u) : _;
O != null && (w ? ((w = !1), (y = Qe({}, y, O))) : Qe(y, O));
@@ -9560,26 +8564,20 @@ Please update the following components: %s`,
var g = { queue: [], replace: !1 };
Wn(t, g);
var y = r.contextType;
- if (
- (typeof y == "object" && y !== null
- ? (t.context = Hn(y))
- : (t.context = u),
- t.state === l)
- ) {
+ if ((typeof y == "object" && y !== null ? (t.context = Hn(y)) : (t.context = u), t.state === l)) {
var w = ie(r) || "Component";
Wo.has(w) ||
(Wo.add(w),
c(
"%s: It is not recommended to assign props directly to state because updates to props won't be reflected in state. In most cases, it is better to use props directly.",
- w
+ w,
));
}
var C = r.getDerivedStateFromProps;
typeof C == "function" && (t.state = al(t, r, C, p, l)),
typeof r.getDerivedStateFromProps != "function" &&
typeof t.getSnapshotBeforeUpdate != "function" &&
- (typeof t.UNSAFE_componentWillMount == "function" ||
- typeof t.componentWillMount == "function") &&
+ (typeof t.UNSAFE_componentWillMount == "function" || typeof t.componentWillMount == "function") &&
(cu(r, t), fu(g, t, l, u));
}
var du = { id: 1, overflow: "" };
@@ -9628,9 +8626,7 @@ Please update the following components: %s`,
return r === 0 ? 32 : (31 - ((pu(r) / hu) | 0)) | 0;
}
function gu(t, r) {
- return (
- (t === r && (t !== 0 || 1 / t === 1 / r)) || (t !== t && r !== r)
- );
+ return (t === r && (t !== 0 || 1 / t === 1 / r)) || (t !== t && r !== r);
}
var mu = typeof Object.is == "function" ? Object.is : gu,
At = null,
@@ -9655,7 +8651,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return (
$e &&
c(
- "Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://reactjs.org/link/rules-of-hooks"
+ "Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://reactjs.org/link/rules-of-hooks",
),
At
);
@@ -9665,7 +8661,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return (
c(
"%s received a final argument during this render, but not during the previous render. Even though the final argument is optional, its type cannot change between renders.",
- Kr
+ Kr,
),
!1
);
@@ -9677,17 +8673,13 @@ Previous: %s
Incoming: %s`,
Kr,
"[" + t.join(", ") + "]",
- "[" + r.join(", ") + "]"
+ "[" + r.join(", ") + "]",
);
- for (var l = 0; l < r.length && l < t.length; l++)
- if (!mu(t[l], r[l])) return !1;
+ for (var l = 0; l < r.length && l < t.length; l++) if (!mu(t[l], r[l])) return !1;
return !0;
}
function Xt() {
- if (Sr > 0)
- throw new Error(
- "Rendered more hooks than during the previous render"
- );
+ if (Sr > 0) throw new Error("Rendered more hooks than during the previous render");
return { memoizedState: null, queue: null, next: null };
}
function li() {
@@ -9714,20 +8706,13 @@ Incoming: %s`,
return t;
}
function ui() {
- ($e = !1),
- (At = null),
- (ii = null),
- (G = !1),
- (Ke = null),
- (Sr = 0),
- (ot = null),
- (X = null);
+ ($e = !1), (At = null), (ii = null), (G = !1), (Ke = null), (Sr = 0), (ot = null), (X = null);
}
function fl(t) {
return (
$e &&
c(
- "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()."
+ "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().",
),
Hn(t)
);
@@ -9762,9 +8747,7 @@ Incoming: %s`,
} else {
$e = !0;
var _;
- t === fi
- ? (_ = typeof r == "function" ? r() : r)
- : (_ = l !== void 0 ? l(r) : r),
+ t === fi ? (_ = typeof r == "function" ? r() : r) : (_ = l !== void 0 ? l(r) : r),
($e = !1),
(X.memoizedState = _);
var O = (X.queue = { last: null, dispatch: null }),
@@ -9797,14 +8780,12 @@ Incoming: %s`,
function hl(t, r) {
(Kr = "useLayoutEffect"),
c(
- "useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes."
+ "useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes.",
);
}
function bu(t, r, l) {
if (Sr >= Gt)
- throw new Error(
- "Too many re-renders. React limits the number of renders to prevent an infinite loop."
- );
+ throw new Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");
if (t === At) {
G = !0;
var u = { action: l, next: null };
@@ -9828,7 +8809,7 @@ Incoming: %s`,
function xu(t, r, l) {
if (l === void 0)
throw new Error(
- "Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering."
+ "Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering.",
);
return l();
}
@@ -9836,9 +8817,7 @@ Incoming: %s`,
return Ie(), t;
}
function Tu() {
- throw new Error(
- "startTransition cannot be called during server rendering."
- );
+ throw new Error("startTransition cannot be called during server rendering.");
}
function Cu() {
return Ie(), [!1, Tu];
@@ -9848,9 +8827,7 @@ Incoming: %s`,
r = sl(t.treeContext),
l = en;
if (l === null)
- throw new Error(
- "Invalid hook call. Hooks can only be called inside of the body of a function component."
- );
+ throw new Error("Invalid hook call. Hooks can only be called inside of the body of a function component.");
var u = Yt++;
return zt(l, r, u);
}
@@ -9974,8 +8951,7 @@ Error generating stack: ` +
};
}
function mi(t, r, l, u, p, g, y, w) {
- t.allPendingTasks++,
- l === null ? t.pendingRootTasks++ : l.pendingTasks++;
+ t.allPendingTasks++, l === null ? t.pendingRootTasks++ : l.pendingTasks++;
var C = {
node: r,
ping: function () {
@@ -10006,9 +8982,7 @@ Error generating stack: ` +
}
var at = null;
function nn() {
- return at === null || at.componentStack === null
- ? ""
- : pi(at.componentStack);
+ return at === null || at.componentStack === null ? "" : pi(at.componentStack);
}
function Ne(t, r) {
t.componentStack = { tag: 0, parent: t.componentStack, type: r };
@@ -10021,20 +8995,14 @@ Error generating stack: ` +
}
function Dt(t) {
t.componentStack === null
- ? c(
- "Unexpectedly popped too many stack frames. This is a bug in React."
- )
+ ? c("Unexpectedly popped too many stack frames. This is a bug in React.")
: (t.componentStack = t.componentStack.parent);
}
var Zn = null;
function mt(t, r) {
{
var l;
- typeof r == "string"
- ? (l = r)
- : r && typeof r.message == "string"
- ? (l = r.message)
- : (l = String(r));
+ typeof r == "string" ? (l = r) : r && typeof r.message == "string" ? (l = r.message) : (l = String(r));
var u = Zn || nn();
(Zn = null), (t.errorMessage = l), (t.errorComponentStack = u);
}
@@ -10045,7 +9013,7 @@ Error generating stack: ` +
throw new Error(
'onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "' +
typeof l +
- '" instead'
+ '" instead',
);
return l;
}
@@ -10053,10 +9021,7 @@ Error generating stack: ` +
var l = t.onShellError;
l(r);
var u = t.onFatalError;
- u(r),
- t.destination !== null
- ? ((t.status = tn), Oe(t.destination, r))
- : ((t.status = gi), (t.fatalError = r));
+ u(r), t.destination !== null ? ((t.status = tn), Oe(t.destination, r)) : ((t.status = gi), (t.fatalError = r));
}
function Jn(t, r, l) {
Ne(r, "Suspense");
@@ -10083,10 +9048,7 @@ Error generating stack: ` +
return;
}
} catch (de) {
- (j.status = vi),
- (C.forceClientRender = !0),
- (C.errorDigest = Ot(t, de)),
- mt(C, de);
+ (j.status = vi), (C.forceClientRender = !0), (C.errorDigest = Ot(t, de)), mt(C, de);
} finally {
(r.blockedBoundary = u), (r.blockedSegment = p);
}
@@ -10121,7 +9083,7 @@ Error generating stack: ` +
(Si ||
c(
"It looks like %s is reassigning its own `this.props` while rendering. This is not supported and can lead to confusing bugs.",
- ie(u) || "a component"
+ ie(u) || "a component",
),
(Si = !0));
{
@@ -10151,44 +9113,30 @@ Error generating stack: ` +
ki = !1;
function xl(t, r, l, u) {
var p;
- if (
- ((p = Do(l, r.legacyContext)),
- Qo(r, l),
- l.prototype && typeof l.prototype.render == "function")
- ) {
+ if (((p = Do(l, r.legacyContext)), Qo(r, l), l.prototype && typeof l.prototype.render == "function")) {
var g = ie(l) || "Unknown";
yi[g] ||
(c(
"The <%s /> component appears to have a render method, but doesn't extend React.Component. This is likely to cause errors. Change %s to extend React.Component instead.",
g,
- g
+ g,
),
(yi[g] = !0));
}
var y = bl(t, r, l, u, p),
w = cl();
- if (
- typeof y == "object" &&
- y !== null &&
- typeof y.render == "function" &&
- y.$$typeof === void 0
- ) {
+ if (typeof y == "object" && y !== null && typeof y.render == "function" && y.$$typeof === void 0) {
var C = ie(l) || "Unknown";
qo[C] ||
(c(
"The <%s /> component appears to be a function component that returns a class instance. Change %s to a class that extends React.Component instead. If you can't use a class try assigning the prototype on the function as a workaround. `%s.prototype = React.Component.prototype`. Don't use an arrow function since it cannot be called with `new` by React.",
C,
C,
- C
+ C,
),
(qo[C] = !0));
}
- if (
- typeof y == "object" &&
- y !== null &&
- typeof y.render == "function" &&
- y.$$typeof === void 0
- ) {
+ if (typeof y == "object" && y !== null && typeof y.render == "function" && y.$$typeof === void 0) {
{
var _ = ie(l) || "Unknown";
qo[_] ||
@@ -10196,7 +9144,7 @@ Error generating stack: ` +
"The <%s /> component appears to be a function component that returns a class instance. Change %s to a class that extends React.Component instead. If you can't use a class try assigning the prototype on the function as a workaround. `%s.prototype = React.Component.prototype`. Don't use an arrow function since it cannot be called with `new` by React.",
_,
_,
- _
+ _,
),
(qo[_] = !0));
}
@@ -10221,23 +9169,16 @@ Error generating stack: ` +
t.childContextTypes &&
c(
"%s(...): childContextTypes cannot be defined on a function component.",
- t.displayName || t.name || "Component"
+ t.displayName || t.name || "Component",
),
typeof t.getDerivedStateFromProps == "function")
) {
var r = ie(t) || "Unknown";
- Qn[r] ||
- (c(
- "%s: Function components do not support getDerivedStateFromProps.",
- r
- ),
- (Qn[r] = !0));
+ Qn[r] || (c("%s: Function components do not support getDerivedStateFromProps.", r), (Qn[r] = !0));
}
if (typeof t.contextType == "object" && t.contextType !== null) {
var l = ie(t) || "Unknown";
- bi[l] ||
- (c("%s: Function components do not support contextType.", l),
- (bi[l] = !0));
+ bi[l] || (c("%s: Function components do not support contextType.", l), (bi[l] = !0));
}
}
}
@@ -10278,13 +9219,13 @@ Error generating stack: ` +
(ki ||
((ki = !0),
c(
- "Rendering <Context> directly is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?"
+ "Rendering <Context> directly is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?",
)))
: (l = l._context);
var p = u.children;
typeof p != "function" &&
c(
- "A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it."
+ "A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it.",
);
var g = Hn(l),
y = p(g);
@@ -10300,9 +9241,7 @@ Error generating stack: ` +
Pe(t, r, y),
(r.context = Lo(p)),
w !== r.context &&
- c(
- "Popping the context provider did not return back to the original snapshot. This is a bug in React."
- );
+ c("Popping the context provider did not return back to the original snapshot. This is a bug in React.");
}
function Au(t, r, l, u, p) {
Ne(r, "Lazy");
@@ -10339,9 +9278,7 @@ Error generating stack: ` +
return;
}
case za:
- throw new Error(
- "ReactDOMServer does not yet support scope components."
- );
+ throw new Error("ReactDOMServer does not yet support scope components.");
case An: {
Jn(t, r, u);
return;
@@ -10372,15 +9309,12 @@ Error generating stack: ` +
}
var g = "";
throw (
- ((l === void 0 ||
- (typeof l == "object" &&
- l !== null &&
- Object.keys(l).length === 0)) &&
+ ((l === void 0 || (typeof l == "object" && l !== null && Object.keys(l).length === 0)) &&
(g +=
" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),
new Error(
"Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) " +
- ("but got: " + (l == null ? l : typeof l) + "." + g)
+ ("but got: " + (l == null ? l : typeof l) + "." + g),
))
);
}
@@ -10389,14 +9323,11 @@ Error generating stack: ` +
t[Symbol.toStringTag] === "Generator" &&
(wi ||
c(
- "Using Generators as children is unsupported and will likely yield unexpected results because enumerating a generator mutates it. You may convert it to an array with `Array.from()` or the `[...spread]` operator before rendering. Keep in mind you might need to polyfill these features for older browsers."
+ "Using Generators as children is unsupported and will likely yield unexpected results because enumerating a generator mutates it. You may convert it to an array with `Array.from()` or the `[...spread]` operator before rendering. Keep in mind you might need to polyfill these features for older browsers.",
),
(wi = !0)),
t.entries === r &&
- (xi ||
- c(
- "Using Maps as children is not supported. Use an array of keyed ReactElements instead."
- ),
+ (xi || c("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),
(xi = !0));
}
function Pe(t, r, l) {
@@ -10404,11 +9335,7 @@ Error generating stack: ` +
return Ou(t, r, l);
} catch (u) {
throw (
- ((typeof u == "object" &&
- u !== null &&
- typeof u.then == "function") ||
- (Zn = Zn !== null ? Zn : nn()),
- u)
+ ((typeof u == "object" && u !== null && typeof u.then == "function") || (Zn = Zn !== null ? Zn : nn()), u)
);
}
}
@@ -10425,7 +9352,7 @@ Error generating stack: ` +
}
case ze:
throw new Error(
- "Portals are not currently supported by the server renderer. Render them conditionally so that they only appear on the client render."
+ "Portals are not currently supported by the server renderer. Render them conditionally so that they only appear on the client render.",
);
case $r: {
var w = l,
@@ -10435,13 +9362,7 @@ Error generating stack: ` +
try {
O = _(C);
} catch (la) {
- throw (
- (typeof la == "object" &&
- la !== null &&
- typeof la.then == "function" &&
- Ne(r, "Lazy"),
- la)
- );
+ throw (typeof la == "object" && la !== null && typeof la.then == "function" && Ne(r, "Lazy"), la);
}
Pe(t, r, O);
return;
@@ -10470,35 +9391,23 @@ Error generating stack: ` +
var aa = Object.prototype.toString.call(l);
throw new Error(
"Objects are not valid as a React child (found: " +
- (aa === "[object Object]"
- ? "object with keys {" + Object.keys(l).join(", ") + "}"
- : aa) +
- "). If you meant to render a collection of children, use an array instead."
+ (aa === "[object Object]" ? "object with keys {" + Object.keys(l).join(", ") + "}" : aa) +
+ "). If you meant to render a collection of children, use an array instead.",
);
}
if (typeof l == "string") {
var ia = r.blockedSegment;
- ia.lastPushedText = Xi(
- r.blockedSegment.chunks,
- l,
- t.responseState,
- ia.lastPushedText
- );
+ ia.lastPushedText = Xi(r.blockedSegment.chunks, l, t.responseState, ia.lastPushedText);
return;
}
if (typeof l == "number") {
var Dl = r.blockedSegment;
- Dl.lastPushedText = Xi(
- r.blockedSegment.chunks,
- "" + l,
- t.responseState,
- Dl.lastPushedText
- );
+ Dl.lastPushedText = Xi(r.blockedSegment.chunks, "" + l, t.responseState, Dl.lastPushedText);
return;
}
typeof l == "function" &&
c(
- "Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it."
+ "Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.",
);
}
function Ue(t, r, l) {
@@ -10517,18 +9426,8 @@ Error generating stack: ` +
p = u.chunks.length,
g = Jo(t, p, null, u.formatContext, u.lastPushedText, !0);
u.children.push(g), (u.lastPushedText = !1);
- var y = mi(
- t,
- r.node,
- r.blockedBoundary,
- g,
- r.abortSet,
- r.legacyContext,
- r.context,
- r.treeContext
- );
- r.componentStack !== null &&
- (y.componentStack = r.componentStack.parent);
+ var y = mi(t, r.node, r.blockedBoundary, g, r.abortSet, r.legacyContext, r.context, r.treeContext);
+ r.componentStack !== null && (y.componentStack = r.componentStack.parent);
var w = y.ping;
l.then(w, w);
}
@@ -10541,10 +9440,7 @@ Error generating stack: ` +
try {
return Pe(t, r, l);
} catch (w) {
- if (
- (ui(),
- typeof w == "object" && w !== null && typeof w.then == "function")
- ) {
+ if ((ui(), typeof w == "object" && w !== null && typeof w.then == "function")) {
Mu(t, r, w),
(r.blockedSegment.formatContext = u),
(r.legacyContext = p),
@@ -10591,24 +9487,15 @@ Error generating stack: ` +
var u = t.blockedBoundary,
p = t.blockedSegment;
if (((p.status = wr), u === null))
- r.allPendingTasks--,
- r.status !== tn &&
- ((r.status = tn), r.destination !== null && V(r.destination));
+ r.allPendingTasks--, r.status !== tn && ((r.status = tn), r.destination !== null && V(r.destination));
else {
if ((u.pendingTasks--, !u.forceClientRender)) {
u.forceClientRender = !0;
- var g =
- l === void 0
- ? new Error(
- "The render was aborted by the server without a reason."
- )
- : l;
+ var g = l === void 0 ? new Error("The render was aborted by the server without a reason.") : l;
u.errorDigest = r.onError(g);
{
var y = "The server did not finish this Suspense boundary: ";
- g && typeof g.message == "string"
- ? (g = y + g.message)
- : (g = y + String(g));
+ g && typeof g.message == "string" ? (g = y + g.message) : (g = y + String(g));
var w = at;
at = t;
try {
@@ -10633,11 +9520,7 @@ Error generating stack: ` +
}
}
function ta(t, r) {
- if (
- r.chunks.length === 0 &&
- r.children.length === 1 &&
- r.children[0].boundary === null
- ) {
+ if (r.chunks.length === 0 && r.children.length === 1 && r.children[0].boundary === null) {
var l = r.children[0];
(l.id = r.id), (l.parentFlushed = !0), l.status === Zt && ta(t, l);
} else {
@@ -10649,9 +9532,7 @@ Error generating stack: ` +
if (r === null) {
if (l.parentFlushed) {
if (t.completedRootSegment !== null)
- throw new Error(
- "There can only be one root segment. This is a bug in React."
- );
+ throw new Error("There can only be one root segment. This is a bug in React.");
t.completedRootSegment = l;
}
if ((t.pendingRootTasks--, t.pendingRootTasks === 0)) {
@@ -10689,16 +9570,10 @@ Error generating stack: ` +
(l.status = Zt),
Ei(t, r.blockedBoundary, l);
} catch (g) {
- if (
- (ui(),
- typeof g == "object" && g !== null && typeof g.then == "function")
- ) {
+ if ((ui(), typeof g == "object" && g !== null && typeof g.then == "function")) {
var p = r.ping;
g.then(p, p);
- } else
- r.abortSet.delete(r),
- (l.status = vi),
- Lu(t, r.blockedBoundary, l, g);
+ } else r.abortSet.delete(r), (l.status = vi), Lu(t, r.blockedBoundary, l, g);
} finally {
at = u;
}
@@ -10724,10 +9599,7 @@ Error generating stack: ` +
} catch (C) {
Ot(t, C), on(t, C);
} finally {
- di(p),
- (Xo.current = l),
- (hi.getCurrentStack = u),
- l === vl && jn(r);
+ di(p), (Xo.current = l), (hi.getCurrentStack = u), l === vl && jn(r);
}
}
}
@@ -10735,19 +9607,11 @@ Error generating stack: ` +
switch (((l.parentFlushed = !0), l.status)) {
case Vn: {
var u = (l.id = t.nextSegmentId++);
- return (
- (l.lastPushedText = !1),
- (l.textEmbedded = !1),
- k(r, t.responseState, u)
- );
+ return (l.lastPushedText = !1), (l.textEmbedded = !1), k(r, t.responseState, u);
}
case Zt: {
l.status = Zo;
- for (
- var p = !0, g = l.chunks, y = 0, w = l.children, C = 0;
- C < w.length;
- C++
- ) {
+ for (var p = !0, g = l.chunks, y = 0, w = l.children, C = 0; C < w.length; C++) {
for (var _ = w[C]; y < _.index; y++) x(r, g[y]);
p = Kn(t, r, _);
}
@@ -10756,7 +9620,7 @@ Error generating stack: ` +
}
default:
throw new Error(
- "Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React."
+ "Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React.",
);
}
}
@@ -10765,19 +9629,12 @@ Error generating stack: ` +
if (u === null) return na(t, r, l);
if (((u.parentFlushed = !0), u.forceClientRender))
return (
- qs(
- r,
- t.responseState,
- u.errorDigest,
- u.errorMessage,
- u.errorComponentStack
- ),
+ qs(r, t.responseState, u.errorDigest, u.errorMessage, u.errorComponentStack),
na(t, r, l),
eu(r, t.responseState)
);
if (u.pendingTasks > 0) {
- (u.rootSegmentID = t.nextSegmentId++),
- u.completedSegments.length > 0 && t.partialBoundaries.push(u);
+ (u.rootSegmentID = t.nextSegmentId++), u.completedSegments.length > 0 && t.partialBoundaries.push(u);
var p = (u.id = Wt(t.responseState));
return yr(r, t.responseState, p), na(t, r, l), Co(r, t.responseState);
} else {
@@ -10793,28 +9650,17 @@ Error generating stack: ` +
var g = u.completedSegments;
if (g.length !== 1)
throw new Error(
- "A previously unvisited boundary must have exactly one root segment. This is a bug in React."
+ "A previously unvisited boundary must have exactly one root segment. This is a bug in React.",
);
var y = g[0];
return Kn(t, r, y), Ua(r, t.responseState);
}
}
function oa(t, r, l) {
- return Js(
- r,
- t.responseState,
- l.id,
- l.errorDigest,
- l.errorMessage,
- l.errorComponentStack
- );
+ return Js(r, t.responseState, l.id, l.errorDigest, l.errorMessage, l.errorComponentStack);
}
function qn(t, r, l) {
- return (
- Fs(r, t.responseState, l.formatContext, l.id),
- Kn(t, r, l),
- As(r, l.formatContext)
- );
+ return Fs(r, t.responseState, l.formatContext, l.id), Kn(t, r, l), As(r, l.formatContext);
}
function Rl(t, r, l) {
for (var u = l.completedSegments, p = 0; p < u.length; p++) {
@@ -10835,10 +9681,7 @@ Error generating stack: ` +
var p = u.id;
if (p === -1) {
var g = (u.id = l.rootSegmentID);
- if (g === -1)
- throw new Error(
- "A root segment ID must have been assigned by now. This is a bug in React."
- );
+ if (g === -1) throw new Error("A root segment ID must have been assigned by now. This is a bug in React.");
return qn(t, r, u);
} else return qn(t, r, u), Hs(r, t.responseState, p);
}
@@ -10847,9 +9690,7 @@ Error generating stack: ` +
var l = t.completedRootSegment;
l !== null &&
t.pendingRootTasks === 0 &&
- (Kn(t, r, l),
- (t.completedRootSegment = null),
- _n(r, t.responseState));
+ (Kn(t, r, l), (t.completedRootSegment = null), _n(r, t.responseState));
var u = t.clientRenderedBoundaries,
p;
for (p = 0; p < u.length; p++) {
@@ -10893,9 +9734,7 @@ Error generating stack: ` +
t.clientRenderedBoundaries.length === 0 &&
t.completedBoundaries.length === 0 &&
(t.abortableTasks.size !== 0 &&
- c(
- "There was still abortable task at the root when we closed. This is a bug in React."
- ),
+ c("There was still abortable task at the root when we closed. This is a bug in React."),
V(r));
}
}
@@ -10947,39 +9786,22 @@ Error generating stack: ` +
function _() {
C = !0;
}
- var O = yl(
- t,
- Yi(l, r ? r.identifierPrefix : void 0),
- Gi(),
- 1 / 0,
- Pl,
- void 0,
- _,
- void 0,
- void 0
- );
+ var O = yl(t, Yi(l, r ? r.identifierPrefix : void 0), Gi(), 1 / 0, Pl, void 0, _, void 0, void 0);
if ((Pi(O), _l(O, u), eo(O, w), p)) throw g;
if (!C)
throw new Error(
- "A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition."
+ "A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition.",
);
return y;
}
function Bu(t, r) {
- (t.prototype = Object.create(r.prototype)),
- (t.prototype.constructor = t),
- (t.__proto__ = r);
+ (t.prototype = Object.create(r.prototype)), (t.prototype.constructor = t), (t.__proto__ = r);
}
var Fl = (function (t) {
Bu(r, t);
function r() {
var u;
- return (
- (u = t.call(this, {}) || this),
- (u.request = null),
- (u.startedFlowing = !1),
- u
- );
+ return (u = t.call(this, {}) || this), (u.request = null), (u.startedFlowing = !1), u;
}
var l = r.prototype;
return (
@@ -10998,25 +9820,11 @@ Error generating stack: ` +
(p.startedFlowing = !0), eo(g, p);
}
var p = new Fl(),
- g = yl(
- t,
- Yi(!1, r ? r.identifierPrefix : void 0),
- Gi(),
- 1 / 0,
- Uu,
- u,
- void 0,
- void 0
- );
+ g = yl(t, Yi(!1, r ? r.identifierPrefix : void 0), Gi(), 1 / 0, Uu, u, void 0, void 0);
return (p.request = g), Pi(g), p;
}
function o(t, r) {
- return (
- c(
- "renderToNodeStream is deprecated. Use renderToPipeableStream instead."
- ),
- Al(t, r)
- );
+ return c("renderToNodeStream is deprecated. Use renderToPipeableStream instead."), Al(t, r);
}
function a(t, r) {
return Al(t, r);
@@ -11026,7 +9834,7 @@ Error generating stack: ` +
t,
r,
!1,
- 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToPipeableStream" which supports Suspense on the server'
+ 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToPipeableStream" which supports Suspense on the server',
);
}
function d(t, r) {
@@ -11034,7 +9842,7 @@ Error generating stack: ` +
t,
r,
!0,
- 'The server used "renderToStaticMarkup" which does not support Suspense. If you intended to have the server wait for the suspended component please switch to "renderToPipeableStream" which supports Suspense on the server'
+ 'The server used "renderToStaticMarkup" which does not support Suspense. If you intended to have the server wait for the suspended component please switch to "renderToPipeableStream" which supports Suspense on the server',
);
}
(pa.renderToNodeStream = o),
@@ -11044,7 +9852,7 @@ Error generating stack: ` +
(pa.version = i);
})();
});
-var Wd = an((Pc) => {
+var Wd = an(Pc => {
"use strict";
process.env.NODE_ENV !== "production" &&
(function () {
@@ -11055,23 +9863,13 @@ var Wd = an((Pc) => {
s = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function v(o) {
{
- for (
- var a = arguments.length, f = new Array(a > 1 ? a - 1 : 0), d = 1;
- d < a;
- d++
- )
- f[d - 1] = arguments[d];
+ for (var a = arguments.length, f = new Array(a > 1 ? a - 1 : 0), d = 1; d < a; d++) f[d - 1] = arguments[d];
m("warn", o, f);
}
}
function c(o) {
{
- for (
- var a = arguments.length, f = new Array(a > 1 ? a - 1 : 0), d = 1;
- d < a;
- d++
- )
- f[d - 1] = arguments[d];
+ for (var a = arguments.length, f = new Array(a > 1 ? a - 1 : 0), d = 1; d < a; d++) f[d - 1] = arguments[d];
m("error", o, f);
}
}
@@ -11083,8 +9881,7 @@ var Wd = an((Pc) => {
var r = f.map(function (l) {
return String(l);
});
- r.unshift("Warning: " + a),
- Function.prototype.apply.call(console[o], console, r);
+ r.unshift("Warning: " + a), Function.prototype.apply.call(console[o], console, r);
}
}
function S(o) {
@@ -11103,9 +9900,7 @@ var Wd = an((Pc) => {
function J(o, a) {
if (a.length !== 0) {
if (a.length * 3 > x) {
- D > 0 &&
- (ue(o, R.subarray(0, D)), (R = new Uint8Array(x)), (D = 0)),
- ue(o, _e.encode(a));
+ D > 0 && (ue(o, R.subarray(0, D)), (R = new Uint8Array(x)), (D = 0)), ue(o, _e.encode(a));
return;
}
var f = R;
@@ -11114,30 +9909,20 @@ var Wd = an((Pc) => {
t = d.read,
r = d.written;
(D += r),
- t < a.length &&
- (ue(o, R),
- (R = new Uint8Array(x)),
- (D = _e.encodeInto(a.slice(t), R).written)),
+ t < a.length && (ue(o, R), (R = new Uint8Array(x)), (D = _e.encodeInto(a.slice(t), R).written)),
D === x && (ue(o, R), (R = new Uint8Array(x)), (D = 0));
}
}
function Oe(o, a) {
if (a.byteLength !== 0) {
if (a.byteLength > x) {
- D > 0 &&
- (ue(o, R.subarray(0, D)), (R = new Uint8Array(x)), (D = 0)),
- ue(o, a);
+ D > 0 && (ue(o, R.subarray(0, D)), (R = new Uint8Array(x)), (D = 0)), ue(o, a);
return;
}
var f = a,
d = R.length - D;
d < f.byteLength &&
- (d === 0
- ? ue(o, R)
- : (R.set(f.subarray(0, d), D),
- (D += d),
- ue(o, R),
- (f = f.subarray(d))),
+ (d === 0 ? ue(o, R) : (R.set(f.subarray(0, d), D), (D += d), ue(o, R), (f = f.subarray(d))),
(R = new Uint8Array(x)),
(D = 0)),
R.set(f, D),
@@ -11194,7 +9979,7 @@ var Wd = an((Pc) => {
c(
"The provided `%s` attribute is an unsupported type %s. This value must be coerced to a string before before using it here.",
a,
- qt(o)
+ qt(o),
),
Mt(o)
);
@@ -11205,7 +9990,7 @@ var Wd = an((Pc) => {
c(
"The provided `%s` CSS property is an unsupported type %s. This value must be coerced to a string before before using it here.",
a,
- qt(o)
+ qt(o),
),
Mt(o)
);
@@ -11215,7 +10000,7 @@ var Wd = an((Pc) => {
return (
c(
"The provided HTML markup uses a value of unsupported type %s. This value must be coerced to a string before before using it here.",
- qt(o)
+ qt(o),
),
Mt(o)
);
@@ -11296,17 +10081,10 @@ var Wd = an((Pc) => {
f = o[1];
ve[a] = new ye(a, tt, !1, f, null, !1, !1);
}),
- ["contentEditable", "draggable", "spellCheck", "value"].forEach(
- function (o) {
- ve[o] = new ye(o, Bt, !1, o.toLowerCase(), null, !1, !1);
- }
- ),
- [
- "autoReverse",
- "externalResourcesRequired",
- "focusable",
- "preserveAlpha",
- ].forEach(function (o) {
+ ["contentEditable", "draggable", "spellCheck", "value"].forEach(function (o) {
+ ve[o] = new ye(o, Bt, !1, o.toLowerCase(), null, !1, !1);
+ }),
+ ["autoReverse", "externalResourcesRequired", "focusable", "preserveAlpha"].forEach(function (o) {
ve[o] = new ye(o, Bt, !1, o, null, !1, !1);
}),
[
@@ -11430,42 +10208,21 @@ var Wd = an((Pc) => {
var a = o.replace(or, je);
ve[a] = new ye(a, tt, !1, o, null, !1, !1);
}),
- [
- "xlink:actuate",
- "xlink:arcrole",
- "xlink:role",
- "xlink:show",
- "xlink:title",
- "xlink:type",
- ].forEach(function (o) {
+ ["xlink:actuate", "xlink:arcrole", "xlink:role", "xlink:show", "xlink:title", "xlink:type"].forEach(function (
+ o,
+ ) {
var a = o.replace(or, je);
ve[a] = new ye(a, tt, !1, o, "http://www.w3.org/1999/xlink", !1, !1);
}),
["xml:base", "xml:lang", "xml:space"].forEach(function (o) {
var a = o.replace(or, je);
- ve[a] = new ye(
- a,
- tt,
- !1,
- o,
- "http://www.w3.org/XML/1998/namespace",
- !1,
- !1
- );
+ ve[a] = new ye(a, tt, !1, o, "http://www.w3.org/XML/1998/namespace", !1, !1);
}),
["tabIndex", "crossOrigin"].forEach(function (o) {
ve[o] = new ye(o, tt, !1, o.toLowerCase(), null, !1, !1);
});
var ha = "xlinkHref";
- (ve[ha] = new ye(
- "xlinkHref",
- tt,
- !1,
- "xlink:href",
- "http://www.w3.org/1999/xlink",
- !0,
- !1
- )),
+ (ve[ha] = new ye("xlinkHref", tt, !1, "xlink:href", "http://www.w3.org/1999/xlink", !0, !1)),
["src", "href", "action", "formAction"].forEach(function (o) {
ve[o] = new ye(o, tt, !1, o.toLowerCase(), null, !0, !0);
});
@@ -11540,14 +10297,14 @@ var Wd = an((Pc) => {
a.disabled ||
a.value == null ||
c(
- "You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`."
+ "You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.",
),
a.onChange ||
a.readOnly ||
a.disabled ||
a.checked == null ||
c(
- "You provided a `checked` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultChecked`. Otherwise, set either `onChange` or `readOnly`."
+ "You provided a `checked` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultChecked`. Otherwise, set either `onChange` or `readOnly`.",
);
}
function fn(o, a) {
@@ -11628,30 +10385,17 @@ var Wd = an((Pc) => {
d = sr.hasOwnProperty(f) ? f : null;
if (d == null)
return (
- c(
- "Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.",
- a
- ),
- (pt[a] = !0),
- !0
- );
- if (a !== d)
- return (
- c("Invalid ARIA attribute `%s`. Did you mean `%s`?", a, d),
+ c("Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.", a),
(pt[a] = !0),
!0
);
+ if (a !== d) return c("Invalid ARIA attribute `%s`. Did you mean `%s`?", a, d), (pt[a] = !0), !0;
}
if (ke.test(a)) {
var t = a.toLowerCase(),
r = sr.hasOwnProperty(t) ? t : null;
if (r == null) return (pt[a] = !0), !1;
- if (a !== r)
- return (
- c("Unknown ARIA attribute `%s`. Did you mean `%s`?", a, r),
- (pt[a] = !0),
- !0
- );
+ if (a !== r) return c("Unknown ARIA attribute `%s`. Did you mean `%s`?", a, r), (pt[a] = !0), !0;
}
}
return !0;
@@ -11669,16 +10413,12 @@ var Wd = an((Pc) => {
})
.join(", ");
f.length === 1
- ? c(
- "Invalid aria prop %s on <%s> tag. For details, see https://reactjs.org/link/invalid-aria-props",
- r,
- o
- )
+ ? c("Invalid aria prop %s on <%s> tag. For details, see https://reactjs.org/link/invalid-aria-props", r, o)
: f.length > 1 &&
c(
"Invalid aria props %s on <%s> tag. For details, see https://reactjs.org/link/invalid-aria-props",
r,
- o
+ o,
);
}
}
@@ -11696,11 +10436,11 @@ var Wd = an((Pc) => {
o === "select" && a.multiple
? c(
"`value` prop on `%s` should not be null. Consider using an empty array when `multiple` is set to `true` to clear the component or `undefined` for uncontrolled components.",
- o
+ o,
)
: c(
"`value` prop on `%s` should not be null. Consider using an empty string to clear the component or `undefined` for uncontrolled components.",
- o
+ o,
));
}
}
@@ -12204,7 +10944,7 @@ var Wd = an((Pc) => {
if (t === "onfocusin" || t === "onfocusout")
return (
c(
- "React uses onFocus and onBlur instead of onFocusIn and onFocusOut. All React events are normalized to bubble, so onFocusIn and onFocusOut are not needed/supported by React."
+ "React uses onFocus and onBlur instead of onFocusIn and onFocusOut. All React events are normalized to bubble, so onFocusIn and onFocusOut are not needed/supported by React.",
),
(Te[a] = !0),
!0
@@ -12214,31 +10954,14 @@ var Wd = an((Pc) => {
l = d.possibleRegistrationNames;
if (r.hasOwnProperty(a)) return !0;
var u = l.hasOwnProperty(t) ? l[t] : null;
- if (u != null)
- return (
- c(
- "Invalid event handler property `%s`. Did you mean `%s`?",
- a,
- u
- ),
- (Te[a] = !0),
- !0
- );
- if (vo.test(a))
- return (
- c(
- "Unknown event handler property `%s`. It will be ignored.",
- a
- ),
- (Te[a] = !0),
- !0
- );
+ if (u != null) return c("Invalid event handler property `%s`. Did you mean `%s`?", a, u), (Te[a] = !0), !0;
+ if (vo.test(a)) return c("Unknown event handler property `%s`. It will be ignored.", a), (Te[a] = !0), !0;
} else if (vo.test(a))
return (
go.test(a) &&
c(
"Invalid event handler property `%s`. React events use the camelCase naming convention, for example `onClick`.",
- a
+ a,
),
(Te[a] = !0),
!0
@@ -12247,7 +10970,7 @@ var Wd = an((Pc) => {
if (t === "innerhtml")
return (
c(
- "Directly setting property `innerHTML` is not permitted. For more information, lookup documentation on `dangerouslySetInnerHTML`."
+ "Directly setting property `innerHTML` is not permitted. For more information, lookup documentation on `dangerouslySetInnerHTML`.",
),
(Te[a] = !0),
!0
@@ -12255,7 +10978,7 @@ var Wd = an((Pc) => {
if (t === "aria")
return (
c(
- "The `aria` attribute is reserved for future use in React. Pass individual `aria-` attributes instead."
+ "The `aria` attribute is reserved for future use in React. Pass individual `aria-` attributes instead.",
),
(Te[a] = !0),
!0
@@ -12264,17 +10987,14 @@ var Wd = an((Pc) => {
return (
c(
"Received a `%s` for a string attribute `is`. If this is expected, cast the value to a string.",
- typeof f
+ typeof f,
),
(Te[a] = !0),
!0
);
if (typeof f == "number" && isNaN(f))
return (
- c(
- "Received NaN for the `%s` attribute. If this is expected, cast the value to a string.",
- a
- ),
+ c("Received NaN for the `%s` attribute. If this is expected, cast the value to a string.", a),
(Te[a] = !0),
!0
);
@@ -12282,18 +11002,13 @@ var Wd = an((Pc) => {
g = p !== null && p.type === Er;
if (pn.hasOwnProperty(t)) {
var y = pn[t];
- if (y !== a)
- return (
- c("Invalid DOM property `%s`. Did you mean `%s`?", a, y),
- (Te[a] = !0),
- !0
- );
+ if (y !== a) return c("Invalid DOM property `%s`. Did you mean `%s`?", a, y), (Te[a] = !0), !0;
} else if (!g && a !== t)
return (
c(
"React does not recognize the `%s` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `%s` instead. If you accidentally passed it from a parent component, remove it from the DOM element.",
a,
- t
+ t,
),
(Te[a] = !0),
!0
@@ -12306,7 +11021,7 @@ var Wd = an((Pc) => {
a,
a,
f,
- a
+ a,
)
: c(
'Received `%s` for a non-boolean attribute `%s`.\n\nIf you want to write it to the DOM, pass a string instead: %s="%s" or %s={value.toString()}.\n\nIf you used to conditionally omit it with %s={condition && value}, pass %s={condition ? value : undefined} instead.',
@@ -12316,7 +11031,7 @@ var Wd = an((Pc) => {
f,
a,
a,
- a
+ a,
),
(Te[a] = !0),
!0)
@@ -12335,7 +11050,7 @@ var Wd = an((Pc) => {
? "The browser will interpret it as a truthy value."
: 'Although this works, it will not work as expected if you pass the string "false".',
a,
- f
+ f,
),
(Te[a] = !0)),
!0);
@@ -12357,13 +11072,13 @@ var Wd = an((Pc) => {
? c(
"Invalid value for prop %s on <%s> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM. For details, see https://reactjs.org/link/attribute-behavior ",
l,
- o
+ o,
)
: d.length > 1 &&
c(
"Invalid values for props %s on <%s> tag. Either remove them from the element, or pass a string or number value to keep them in the DOM. For details, see https://reactjs.org/link/attribute-behavior ",
l,
- o
+ o,
);
}
};
@@ -12387,12 +11102,7 @@ var Wd = an((Pc) => {
},
Sa = function (o) {
(Ut.hasOwnProperty(o) && Ut[o]) ||
- ((Ut[o] = !0),
- c(
- "Unsupported style property %s. Did you mean %s?",
- o,
- ge(o.replace(ya, "ms-"))
- ));
+ ((Ut[o] = !0), c("Unsupported style property %s. Did you mean %s?", o, ge(o.replace(ya, "ms-"))));
},
wa = function (o) {
(Ut.hasOwnProperty(o) && Ut[o]) ||
@@ -12400,42 +11110,23 @@ var Wd = an((Pc) => {
c(
"Unsupported vendor-prefixed style property %s. Did you mean %s?",
o,
- o.charAt(0).toUpperCase() + o.slice(1)
+ o.charAt(0).toUpperCase() + o.slice(1),
));
},
xa = function (o, a) {
(gn.hasOwnProperty(a) && gn[a]) ||
((gn[a] = !0),
- c(
- `Style property values shouldn't contain a semicolon. Try "%s: %s" instead.`,
- o,
- a.replace(mo, "")
- ));
+ c(`Style property values shouldn't contain a semicolon. Try "%s: %s" instead.`, o, a.replace(mo, "")));
},
ka = function (o, a) {
- jt ||
- ((jt = !0),
- c(
- "`NaN` is an invalid value for the `%s` css style property.",
- o
- ));
+ jt || ((jt = !0), c("`NaN` is an invalid value for the `%s` css style property.", o));
},
mn = function (o, a) {
- Pr ||
- ((Pr = !0),
- c(
- "`Infinity` is an invalid value for the `%s` css style property.",
- o
- ));
+ Pr || ((Pr = !0), c("`Infinity` is an invalid value for the `%s` css style property.", o));
};
ur = function (o, a) {
- o.indexOf("-") > -1
- ? Sa(o)
- : _r.test(o)
- ? wa(o)
- : mo.test(a) && xa(o, a),
- typeof a == "number" &&
- (isNaN(a) ? ka(o, a) : isFinite(a) || mn(o, a));
+ o.indexOf("-") > -1 ? Sa(o) : _r.test(o) ? wa(o) : mo.test(a) && xa(o, a),
+ typeof a == "number" && (isNaN(a) ? ka(o, a) : isFinite(a) || mn(o, a));
};
}
var yo = ur,
@@ -12490,7 +11181,7 @@ var Wd = an((Pc) => {
((So = !0),
c(
"A future version of React will block javascript: URLs as a security precaution. Use event handlers instead if you can. If you need to generate unsafe HTML try using dangerouslySetInnerHTML instead. React was passed %s.",
- JSON.stringify(o)
+ JSON.stringify(o),
));
}
var _a = Array.isArray;
@@ -12515,8 +11206,7 @@ var Wd = an((Pc) => {
u = [];
if ((f !== void 0 && u.push(l, yn(f), kt), d !== void 0))
for (var p = 0; p < d.length; p++) u.push(Ar, be(d[p]), fr);
- if (t !== void 0)
- for (var g = 0; g < t.length; g++) u.push(Dr, be(t[g]), fr);
+ if (t !== void 0) for (var g = 0; g < t.length; g++) u.push(Dr, be(t[g]), fr);
return {
bootstrapChunks: u,
startInlineScript: l,
@@ -12542,12 +11232,7 @@ var Wd = an((Pc) => {
return { insertionMode: o, selectedValue: a };
}
function wn(o) {
- var a =
- o === "http://www.w3.org/2000/svg"
- ? Wt
- : o === "http://www.w3.org/1998/Math/MathML"
- ? zt
- : Ht;
+ var a = o === "http://www.w3.org/2000/svg" ? Wt : o === "http://www.w3.org/1998/Math/MathML" ? zt : Ht;
return Ee(a, null);
}
function Mr(o, a, f) {
@@ -12571,9 +11256,7 @@ var Wd = an((Pc) => {
case "tr":
return Ee(bn, null);
}
- return o.insertionMode >= Et || o.insertionMode === Ht
- ? Ee(Ct, null)
- : o;
+ return o.insertionMode >= Et || o.insertionMode === Ht ? Ee(Ct, null) : o;
}
var Lr = null;
function Br(o) {
@@ -12608,7 +11291,7 @@ var Wd = an((Pc) => {
function vr(o, a, f) {
if (typeof f != "object")
throw new Error(
- "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX."
+ "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX.",
);
var d = !0;
for (var t in f)
@@ -12649,13 +11332,7 @@ var Wd = an((Pc) => {
case "suppressHydrationWarning":
return;
}
- if (
- !(
- f.length > 2 &&
- (f[0] === "o" || f[0] === "O") &&
- (f[1] === "n" || f[1] === "N")
- )
- ) {
+ if (!(f.length > 2 && (f[0] === "o" || f[0] === "O") && (f[1] === "n" || f[1] === "N"))) {
var t = uo(f);
if (t !== null) {
switch (typeof d) {
@@ -12672,9 +11349,7 @@ var Wd = an((Pc) => {
d && o.push(Ze, l, Ur);
return;
case Le:
- d === !0
- ? o.push(Ze, l, Ur)
- : d === !1 || o.push(Ze, l, _t, be(d), vt);
+ d === !0 ? o.push(Ze, l, Ur) : d === !1 || o.push(Ze, l, _t, be(d), vt);
return;
case er:
isNaN(d) || o.push(Ze, l, _t, be(d), vt);
@@ -12683,8 +11358,7 @@ var Wd = an((Pc) => {
!isNaN(d) && d >= 1 && o.push(Ze, l, _t, be(d), vt);
break;
default:
- t.sanitizeURL && (Lt(d, r), (d = "" + d), Ia(d)),
- o.push(Ze, l, _t, be(d), vt);
+ t.sanitizeURL && (Lt(d, r), (d = "" + d), Ia(d)), o.push(Ze, l, _t, be(d), vt);
}
} else if (St(f)) {
switch (typeof d) {
@@ -12704,13 +11378,10 @@ var Wd = an((Pc) => {
xn = F("/>");
function gr(o, a, f) {
if (a != null) {
- if (f != null)
- throw new Error(
- "Can only set one of `children` or `props.dangerouslySetInnerHTML`."
- );
+ if (f != null) throw new Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
if (typeof a != "object" || !("__html" in a))
throw new Error(
- "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information."
+ "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information.",
);
var d = a.__html;
d != null && (Me(d), o.push("" + d));
@@ -12729,16 +11400,10 @@ var Wd = an((Pc) => {
if (f != null) {
var d = cr(f);
o.multiple && !d
- ? c(
- "The `%s` prop supplied to <select> must be an array if `multiple` is true.",
- a
- )
+ ? c("The `%s` prop supplied to <select> must be an array if `multiple` is true.", a)
: !o.multiple &&
d &&
- c(
- "The `%s` prop supplied to <select> must be a scalar value if `multiple` is false.",
- a
- );
+ c("The `%s` prop supplied to <select> must be a scalar value if `multiple` is false.", a);
}
}
}
@@ -12750,7 +11415,7 @@ var Wd = an((Pc) => {
a.defaultValue !== void 0 &&
!Tn &&
(c(
- "Select elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled select element and remove one of these props. More info: https://reactjs.org/link/controlled-components"
+ "Select elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled select element and remove one of these props. More info: https://reactjs.org/link/controlled-components",
),
(Tn = !0)),
o.push(T("select"));
@@ -12788,7 +11453,7 @@ var Wd = an((Pc) => {
typeof f != "number" &&
((ko = !0),
c(
- "Cannot infer the option value of complex children. Pass a `value` prop or use a plain string as children to <option>."
+ "Cannot infer the option value of complex children. Pass a `value` prop or use a plain string as children to <option>.",
)));
}),
a
@@ -12814,7 +11479,7 @@ var Wd = an((Pc) => {
(u = y),
Cn ||
(c(
- "Use the `defaultValue` or `value` props on <select> instead of setting `selected` on <option>."
+ "Use the `defaultValue` or `value` props on <select> instead of setting `selected` on <option>.",
),
(Cn = !0));
break;
@@ -12837,7 +11502,7 @@ var Wd = an((Pc) => {
(To ||
((To = !0),
c(
- "Pass a `value` prop if you set dangerouslyInnerHTML so React knows which value should be selected."
+ "Pass a `value` prop if you set dangerouslyInnerHTML so React knows which value should be selected.",
))),
(w = gt(r))),
cr(t))
@@ -12862,7 +11527,7 @@ var Wd = an((Pc) => {
(c(
"%s contains an input of type %s with both checked and defaultChecked props. Input elements must be either controlled or uncontrolled (specify either the checked prop, or the defaultChecked prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://reactjs.org/link/controlled-components",
"A component",
- a.type
+ a.type,
),
(kn = !0)),
a.value !== void 0 &&
@@ -12871,7 +11536,7 @@ var Wd = an((Pc) => {
(c(
"%s contains an input of type %s with both value and defaultValue props. Input elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://reactjs.org/link/controlled-components",
"A component",
- a.type
+ a.type,
),
(jr = !0)),
o.push(T("input"));
@@ -12887,7 +11552,7 @@ var Wd = an((Pc) => {
case "children":
case "dangerouslySetInnerHTML":
throw new Error(
- "input is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`."
+ "input is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.",
);
case "defaultChecked":
l = p;
@@ -12907,12 +11572,8 @@ var Wd = an((Pc) => {
}
}
return (
- r !== null
- ? Re(o, f, "checked", r)
- : l !== null && Re(o, f, "checked", l),
- d !== null
- ? Re(o, f, "value", d)
- : t !== null && Re(o, f, "value", t),
+ r !== null ? Re(o, f, "checked", r) : l !== null && Re(o, f, "checked", l),
+ d !== null ? Re(o, f, "value", d) : t !== null && Re(o, f, "value", t),
o.push(xn),
null
);
@@ -12923,7 +11584,7 @@ var Wd = an((Pc) => {
a.defaultValue !== void 0 &&
!xo &&
(c(
- "Textarea elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled textarea and remove one of these props. More info: https://reactjs.org/link/controlled-components"
+ "Textarea elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled textarea and remove one of these props. More info: https://reactjs.org/link/controlled-components",
),
(xo = !0)),
o.push(T("textarea"));
@@ -12945,27 +11606,17 @@ var Wd = an((Pc) => {
t = u;
break;
case "dangerouslySetInnerHTML":
- throw new Error(
- "`dangerouslySetInnerHTML` does not make sense on <textarea>."
- );
+ throw new Error("`dangerouslySetInnerHTML` does not make sense on <textarea>.");
default:
Re(o, f, l, u);
break;
}
}
if ((d === null && t !== null && (d = t), o.push(Je), r != null)) {
- if (
- (c(
- "Use the `defaultValue` or `value` props instead of setting children on <textarea>."
- ),
- d != null)
- )
- throw new Error(
- "If you supply `defaultValue` on a <textarea>, do not pass children."
- );
+ if ((c("Use the `defaultValue` or `value` props instead of setting children on <textarea>."), d != null))
+ throw new Error("If you supply `defaultValue` on a <textarea>, do not pass children.");
if (cr(r)) {
- if (r.length > 1)
- throw new Error("<textarea> can only have at most one child.");
+ if (r.length > 1) throw new Error("<textarea> can only have at most one child.");
Me(r[0]), (d = "" + r[0]);
}
Me(r), (d = "" + r);
@@ -12990,8 +11641,7 @@ var Wd = an((Pc) => {
case "children":
case "dangerouslySetInnerHTML":
throw new Error(
- f +
- " is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`."
+ f + " is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.",
);
default:
Re(o, d, t, r);
@@ -13009,9 +11659,7 @@ var Wd = an((Pc) => {
switch (d) {
case "children":
case "dangerouslySetInnerHTML":
- throw new Error(
- "menuitems cannot have `children` nor `dangerouslySetInnerHTML`."
- );
+ throw new Error("menuitems cannot have `children` nor `dangerouslySetInnerHTML`.");
default:
Re(o, f, d, t);
break;
@@ -13031,9 +11679,7 @@ var Wd = an((Pc) => {
d = r;
break;
case "dangerouslySetInnerHTML":
- throw new Error(
- "`dangerouslySetInnerHTML` does not make sense on <title>."
- );
+ throw new Error("`dangerouslySetInnerHTML` does not make sense on <title>.");
default:
Re(o, f, t, r);
break;
@@ -13044,17 +11690,17 @@ var Wd = an((Pc) => {
var l = Array.isArray(d) && d.length < 2 ? d[0] || null : d;
Array.isArray(d) && d.length > 1
? c(
- "A title element received an array with more than 1 element as children. In browsers title Elements can only have Text Nodes as children. If the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering"
+ "A title element received an array with more than 1 element as children. In browsers title Elements can only have Text Nodes as children. If the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering",
)
: l != null && l.$$typeof != null
? c(
- "A title element received a React element for children. In the browser title Elements can only have Text Nodes as children. If the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering"
+ "A title element received a React element for children. In the browser title Elements can only have Text Nodes as children. If the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering",
)
: l != null &&
typeof l != "string" &&
typeof l != "number" &&
c(
- "A title element received a value that was not a string or number for children. In the browser title Elements can only have Text Nodes as children. If the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering"
+ "A title element received a value that was not a string or number for children. In the browser title Elements can only have Text Nodes as children. If the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering",
);
}
return d;
@@ -13079,11 +11725,7 @@ var Wd = an((Pc) => {
break;
}
}
- return (
- o.push(Je),
- gr(o, r, t),
- typeof t == "string" ? (o.push(We(t)), null) : t
- );
+ return o.push(Je), gr(o, r, t), typeof t == "string" ? (o.push(We(t)), null) : t;
}
function Da(o, a, f, d) {
o.push(T(f));
@@ -13107,10 +11749,7 @@ var Wd = an((Pc) => {
case "suppressHydrationWarning":
break;
default:
- St(l) &&
- typeof u != "function" &&
- typeof u != "symbol" &&
- o.push(Ze, l, _t, be(u), vt);
+ St(l) && typeof u != "function" && typeof u != "symbol" && o.push(Ze, l, _t, be(u), vt);
break;
}
}
@@ -13139,13 +11778,10 @@ var Wd = an((Pc) => {
}
}
if ((o.push(Je), r != null)) {
- if (t != null)
- throw new Error(
- "Can only set one of `children` or `props.dangerouslySetInnerHTML`."
- );
+ if (t != null) throw new Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
if (typeof r != "object" || !("__html" in r))
throw new Error(
- "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information."
+ "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information.",
);
var p = r.__html;
p != null &&
@@ -13186,7 +11822,7 @@ var Wd = an((Pc) => {
f.contentEditable &&
f.children != null &&
c(
- "A component is `contentEditable` and contains `children` managed by React. It is now your responsibility to guarantee that none of those nodes are unexpectedly modified or duplicated. This is probably not intentional."
+ "A component is `contentEditable` and contains `children` managed by React. It is now your responsibility to guarantee that none of those nodes are unexpectedly modified or duplicated. This is probably not intentional.",
),
t.insertionMode !== Wt &&
t.insertionMode !== zt &&
@@ -13195,7 +11831,7 @@ var Wd = an((Pc) => {
a.toLowerCase() !== a &&
c(
"<%s /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.",
- a
+ a,
),
a)
) {
@@ -13241,9 +11877,7 @@ var Wd = an((Pc) => {
case "html":
return t.insertionMode === Ht && o.push(I), In(o, f, a, d);
default:
- return a.indexOf("-") === -1 && typeof f.is != "string"
- ? In(o, f, a, d)
- : Da(o, f, a, d);
+ return a.indexOf("-") === -1 && typeof f.is != "string" ? In(o, f, a, d) : Da(o, f, a, d);
}
}
var M = F("</"),
@@ -13271,8 +11905,7 @@ var Wd = an((Pc) => {
}
}
function Y(o, a) {
- for (var f = a.bootstrapChunks, d = 0; d < f.length - 1; d++)
- P(o, f[d]);
+ for (var f = a.bootstrapChunks, d = 0; d < f.length - 1; d++) P(o, f[d]);
return d < f.length ? W(o, f[d]) : !0;
}
var Q = F('<template id="'),
@@ -13298,9 +11931,7 @@ var Wd = an((Pc) => {
}
function Ni(o, a, f) {
if ((P(o, Se), f === null))
- throw new Error(
- "An ID must have been assigned before we can complete the boundary."
- );
+ throw new Error("An ID must have been assigned before we can complete the boundary.");
return P(o, f), W(o, yr);
}
function ms(o, a, f, d, t) {
@@ -13349,33 +11980,19 @@ var Wd = an((Pc) => {
switch (f.insertionMode) {
case Ht:
case Ct:
- return (
- P(o, Ss), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, ws)
- );
+ return P(o, Ss), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, ws);
case Wt:
- return (
- P(o, ks), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, Ts)
- );
+ return P(o, ks), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, Ts);
case zt:
- return (
- P(o, Es), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, Rs)
- );
+ return P(o, Es), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, Rs);
case Et:
- return (
- P(o, _s), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, Ps)
- );
+ return P(o, _s), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, Ps);
case dr:
- return (
- P(o, As), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, Ds)
- );
+ return P(o, As), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, Ds);
case bn:
- return (
- P(o, Ms), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, Ls)
- );
+ return P(o, Ms), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, Ls);
case Sn:
- return (
- P(o, Us), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, js)
- );
+ return P(o, Us), P(o, a.segmentPrefix), P(o, d.toString(16)), W(o, js);
default:
throw new Error("Unknown insertion mode. This is a bug in React.");
}
@@ -13413,9 +12030,7 @@ var Wd = an((Pc) => {
Zs = F('")</script>');
function La(o, a, f) {
P(o, a.startInlineScript),
- a.sentCompleteSegmentFunction
- ? P(o, Gs)
- : ((a.sentCompleteSegmentFunction = !0), P(o, Ys)),
+ a.sentCompleteSegmentFunction ? P(o, Gs) : ((a.sentCompleteSegmentFunction = !0), P(o, Ys)),
P(o, a.segmentPrefix);
var d = f.toString(16);
return P(o, d), P(o, Xs), P(o, a.placeholderPrefix), P(o, d), W(o, Zs);
@@ -13427,14 +12042,10 @@ var Wd = an((Pc) => {
function Gi(o, a, f, d) {
if (
(P(o, a.startInlineScript),
- a.sentCompleteBoundaryFunction
- ? P(o, Qs)
- : ((a.sentCompleteBoundaryFunction = !0), P(o, Js)),
+ a.sentCompleteBoundaryFunction ? P(o, Qs) : ((a.sentCompleteBoundaryFunction = !0), P(o, Js)),
f === null)
)
- throw new Error(
- "An ID must have been assigned before we can complete the boundary."
- );
+ throw new Error("An ID must have been assigned before we can complete the boundary.");
var t = d.toString(16);
return P(o, f), P(o, Ba), P(o, a.segmentPrefix), P(o, t), W(o, Yi);
}
@@ -13446,14 +12057,10 @@ var Wd = an((Pc) => {
function eu(o, a, f, d, t, r) {
if (
(P(o, a.startInlineScript),
- a.sentClientRenderFunction
- ? P(o, Zi)
- : ((a.sentClientRenderFunction = !0), P(o, Xi)),
+ a.sentClientRenderFunction ? P(o, Zi) : ((a.sentClientRenderFunction = !0), P(o, Xi)),
f === null)
)
- throw new Error(
- "An ID must have been assigned before we can complete the boundary."
- );
+ throw new Error("An ID must have been assigned before we can complete the boundary.");
return (
P(o, f),
P(o, Ks),
@@ -13476,7 +12083,7 @@ var Wd = an((Pc) => {
return "\\u2029";
default:
throw new Error(
- "escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React"
+ "escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React",
);
}
});
@@ -13519,7 +12126,7 @@ var Wd = an((Pc) => {
if (
(typeof o.tag == "number" &&
c(
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.",
),
typeof o == "function")
)
@@ -13618,10 +12225,7 @@ var Wd = an((Pc) => {
groupEnd: ze({}, o, { value: el }),
});
}
- Vr < 0 &&
- c(
- "disabledDepth fell below zero. This is a bug in React. Please file an issue."
- );
+ Vr < 0 && c("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
}
}
var br = s.ReactCurrentDispatcher,
@@ -13718,9 +12322,7 @@ var Wd = an((Pc) => {
`
` + u[g].replace(" at new ", " at ");
return (
- o.displayName &&
- w.includes("<anonymous>") &&
- (w = w.replace("<anonymous>", o.displayName)),
+ o.displayName && w.includes("<anonymous>") && (w = w.replace("<anonymous>", o.displayName)),
typeof o == "function" && Yr.set(o, w),
w
);
@@ -13798,18 +12400,11 @@ var Wd = an((Pc) => {
l +
"` is invalid; it must be a function, usually from the `prop-types` package, but received `" +
typeof o[l] +
- "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
+ "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.",
);
throw ((p.name = "Invariant Violation"), p);
}
- u = o[l](
- a,
- l,
- d,
- f,
- null,
- "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"
- );
+ u = o[l](a, l, d, f, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
} catch (g) {
u = g;
}
@@ -13821,15 +12416,12 @@ var Wd = an((Pc) => {
d || "React class",
f,
l,
- typeof u
+ typeof u,
),
Gr(null)),
u instanceof Error &&
!(u.message in Ln) &&
- ((Ln[u.message] = !0),
- Gr(t),
- c("Failed %s type: %s", f, u.message),
- Gr(null));
+ ((Ln[u.message] = !0), Gr(t), c("Failed %s type: %s", f, u.message), Gr(null));
}
}
}
@@ -13860,7 +12452,7 @@ var Wd = an((Pc) => {
c(
"%s.childContextTypes is specified but there is no getChildContext() method on the instance. You can either define getChildContext() on %s or remove childContextTypes from it.",
t,
- t
+ t,
));
}
return f;
@@ -13869,10 +12461,7 @@ var Wd = an((Pc) => {
for (var l in r)
if (!(l in d))
throw new Error(
- (ne(a) || "Unknown") +
- '.getChildContext(): key "' +
- l +
- '" is not defined in childContextTypes.'
+ (ne(a) || "Unknown") + '.getChildContext(): key "' + l + '" is not defined in childContextTypes.',
);
{
var u = ne(a) || "Unknown";
@@ -13897,15 +12486,9 @@ var Wd = an((Pc) => {
var f = o.parent,
d = a.parent;
if (f === null) {
- if (d !== null)
- throw new Error(
- "The stacks must reach the root at the same time. This is a bug in React."
- );
+ if (d !== null) throw new Error("The stacks must reach the root at the same time. This is a bug in React.");
} else {
- if (d === null)
- throw new Error(
- "The stacks must reach the root at the same time. This is a bug in React."
- );
+ if (d === null) throw new Error("The stacks must reach the root at the same time. This is a bug in React.");
Un(f, d);
}
Mo(a);
@@ -13924,17 +12507,13 @@ var Wd = an((Pc) => {
Zr(o);
var f = o.parent;
if (f === null)
- throw new Error(
- "The depth must equal at least at zero before reaching the root. This is a bug in React."
- );
+ throw new Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");
f.depth === a.depth ? Un(f, a) : jn(f, a);
}
function nl(o, a) {
var f = a.parent;
if (f === null)
- throw new Error(
- "The depth must equal at least at zero before reaching the root. This is a bug in React."
- );
+ throw new Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");
o.depth === f.depth ? Un(o, f) : nl(o, f), Mo(a);
}
function Lo(o) {
@@ -13960,7 +12539,7 @@ var Wd = an((Pc) => {
o._currentRenderer !== null &&
o._currentRenderer !== nt &&
c(
- "Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported."
+ "Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.",
),
(o._currentRenderer = nt);
var d = Ft,
@@ -13975,24 +12554,16 @@ var Wd = an((Pc) => {
}
function Hn(o) {
var a = Ft;
- if (a === null)
- throw new Error(
- "Tried to pop a Context at the root of the app. This is a bug in React."
- );
- a.context !== o &&
- c(
- "The parent context is not the expected context. This is probably a bug in React."
- );
+ if (a === null) throw new Error("Tried to pop a Context at the root of the app. This is a bug in React.");
+ a.context !== o && c("The parent context is not the expected context. This is probably a bug in React.");
{
var f = a.parentValue;
- f === nu
- ? (a.context._currentValue = a.context._defaultValue)
- : (a.context._currentValue = f),
+ f === nu ? (a.context._currentValue = a.context._defaultValue) : (a.context._currentValue = f),
o._currentRenderer !== void 0 &&
o._currentRenderer !== null &&
o._currentRenderer !== nt &&
c(
- "Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported."
+ "Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.",
),
(o._currentRenderer = nt);
}
@@ -14039,7 +12610,7 @@ var Wd = an((Pc) => {
c(
"%s(...): Expected the last optional `callback` argument to be a function. Instead received: %s.",
a,
- o
+ o,
));
}
}),
@@ -14050,7 +12621,7 @@ var Wd = an((Pc) => {
(Jr.add(f),
c(
"%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. You have returned undefined.",
- f
+ f,
));
}
});
@@ -14067,7 +12638,7 @@ var Wd = an((Pc) => {
Please check the code for the %s component.`,
a,
a,
- d
+ d,
),
(Uo[t] = !0);
}
@@ -14078,9 +12649,7 @@ Please check the code for the %s component.`,
},
enqueueSetState: function (o, a, f) {
var d = Bo(o);
- d.queue === null
- ? al(o, "setState")
- : (d.queue.push(a), f != null && Qr(f, "setState"));
+ d.queue === null ? al(o, "setState") : (d.queue.push(a), f != null && Qr(f, "setState"));
},
enqueueReplaceState: function (o, a, f) {
var d = Bo(o);
@@ -14088,9 +12657,7 @@ Please check the code for the %s component.`,
},
enqueueForceUpdate: function (o, a) {
var f = Bo(o);
- f.queue === null
- ? al(o, "forceUpdate")
- : a != null && Qr(a, "setState");
+ f.queue === null ? al(o, "forceUpdate") : a != null && Qr(a, "setState");
},
};
function uu(o, a, f, d, t) {
@@ -14103,9 +12670,7 @@ Please check the code for the %s component.`,
var d = Oo,
t = o.contextType;
if ("contextType" in o) {
- var r =
- t === null ||
- (t !== void 0 && t.$$typeof === An && t._context === void 0);
+ var r = t === null || (t !== void 0 && t.$$typeof === An && t._context === void 0);
if (!r && !$o.has(o)) {
$o.add(o);
var l = "";
@@ -14118,24 +12683,18 @@ Please check the code for the %s component.`,
? (l = " Did you accidentally pass the Context.Provider instead?")
: t._context !== void 0
? (l = " Did you accidentally pass the Context.Consumer instead?")
- : (l =
- " However, it is set to an object with keys {" +
- Object.keys(t).join(", ") +
- "}."),
+ : (l = " However, it is set to an object with keys {" + Object.keys(t).join(", ") + "}."),
c(
"%s defines an invalid contextType. contextType should point to the Context object returned by React.createContext().%s",
ne(o) || "Component",
- l
+ l,
);
}
}
typeof t == "object" && t !== null ? (d = Wn(t)) : (d = f);
var u = new o(a, d);
{
- if (
- typeof o.getDerivedStateFromProps == "function" &&
- (u.state === null || u.state === void 0)
- ) {
+ if (typeof o.getDerivedStateFromProps == "function" && (u.state === null || u.state === void 0)) {
var p = ne(o) || "Component";
zn.has(p) ||
(zn.add(p),
@@ -14143,32 +12702,24 @@ Please check the code for the %s component.`,
"`%s` uses `getDerivedStateFromProps` but its initial state is %s. This is not recommended. Instead, define the initial state by assigning an object to `this.state` in the constructor of `%s`. This ensures that `getDerivedStateFromProps` arguments have a consistent shape.",
p,
u.state === null ? "null" : "undefined",
- p
+ p,
));
}
- if (
- typeof o.getDerivedStateFromProps == "function" ||
- typeof u.getSnapshotBeforeUpdate == "function"
- ) {
+ if (typeof o.getDerivedStateFromProps == "function" || typeof u.getSnapshotBeforeUpdate == "function") {
var g = null,
y = null,
w = null;
if (
- (typeof u.componentWillMount == "function" &&
- u.componentWillMount.__suppressDeprecationWarning !== !0
+ (typeof u.componentWillMount == "function" && u.componentWillMount.__suppressDeprecationWarning !== !0
? (g = "componentWillMount")
- : typeof u.UNSAFE_componentWillMount == "function" &&
- (g = "UNSAFE_componentWillMount"),
+ : typeof u.UNSAFE_componentWillMount == "function" && (g = "UNSAFE_componentWillMount"),
typeof u.componentWillReceiveProps == "function" &&
u.componentWillReceiveProps.__suppressDeprecationWarning !== !0
? (y = "componentWillReceiveProps")
- : typeof u.UNSAFE_componentWillReceiveProps == "function" &&
- (y = "UNSAFE_componentWillReceiveProps"),
- typeof u.componentWillUpdate == "function" &&
- u.componentWillUpdate.__suppressDeprecationWarning !== !0
+ : typeof u.UNSAFE_componentWillReceiveProps == "function" && (y = "UNSAFE_componentWillReceiveProps"),
+ typeof u.componentWillUpdate == "function" && u.componentWillUpdate.__suppressDeprecationWarning !== !0
? (w = "componentWillUpdate")
- : typeof u.UNSAFE_componentWillUpdate == "function" &&
- (w = "UNSAFE_componentWillUpdate"),
+ : typeof u.UNSAFE_componentWillUpdate == "function" && (w = "UNSAFE_componentWillUpdate"),
g !== null || y !== null || w !== null)
) {
var C = ne(o) || "Component",
@@ -14198,7 +12749,7 @@ https://reactjs.org/link/unsafe-component-lifecycles`,
w !== null
? `
` + w
- : ""
+ : "",
));
}
}
@@ -14213,39 +12764,39 @@ https://reactjs.org/link/unsafe-component-lifecycles`,
(a.prototype && typeof a.prototype.render == "function"
? c(
"%s(...): No `render` method found on the returned component instance: did you accidentally return an object from the constructor?",
- d
+ d,
)
: c(
"%s(...): No `render` method found on the returned component instance: you may have forgotten to define `render`.",
- d
+ d,
)),
o.getInitialState &&
!o.getInitialState.isReactClassApproved &&
!o.state &&
c(
"getInitialState was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Did you mean to define a state property instead?",
- d
+ d,
),
o.getDefaultProps &&
!o.getDefaultProps.isReactClassApproved &&
c(
"getDefaultProps was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Use a static property to define defaultProps instead.",
- d
+ d,
),
o.propTypes &&
c(
"propTypes was defined as an instance property on %s. Use a static property to define propTypes instead.",
- d
+ d,
),
o.contextType &&
c(
"contextType was defined as an instance property on %s. Use a static property to define contextType instead.",
- d
+ d,
),
o.contextTypes &&
c(
"contextTypes was defined as an instance property on %s. Use a static property to define contextTypes instead.",
- d
+ d,
),
a.contextType &&
a.contextTypes &&
@@ -14253,39 +12804,36 @@ https://reactjs.org/link/unsafe-component-lifecycles`,
(zo.add(a),
c(
"%s declares both contextTypes and contextType static properties. The legacy contextTypes property will be ignored.",
- d
+ d,
)),
typeof o.componentShouldUpdate == "function" &&
c(
"%s has a method called componentShouldUpdate(). Did you mean shouldComponentUpdate()? The name is phrased as a question because the function is expected to return a value.",
- d
+ d,
),
a.prototype &&
a.prototype.isPureReactComponent &&
typeof o.shouldComponentUpdate < "u" &&
c(
"%s has a method called shouldComponentUpdate(). shouldComponentUpdate should not be used when extending React.PureComponent. Please extend React.Component if shouldComponentUpdate is used.",
- ne(a) || "A pure component"
+ ne(a) || "A pure component",
),
typeof o.componentDidUnmount == "function" &&
c(
"%s has a method called componentDidUnmount(). But there is no such lifecycle method. Did you mean componentWillUnmount()?",
- d
+ d,
),
typeof o.componentDidReceiveProps == "function" &&
c(
"%s has a method called componentDidReceiveProps(). But there is no such lifecycle method. If you meant to update the state in response to changing props, use componentWillReceiveProps(). If you meant to fetch data or run side-effects or mutations after React has updated the UI, use componentDidUpdate().",
- d
+ d,
),
typeof o.componentWillRecieveProps == "function" &&
- c(
- "%s has a method called componentWillRecieveProps(). Did you mean componentWillReceiveProps()?",
- d
- ),
+ c("%s has a method called componentWillRecieveProps(). Did you mean componentWillReceiveProps()?", d),
typeof o.UNSAFE_componentWillRecieveProps == "function" &&
c(
"%s has a method called UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?",
- d
+ d,
);
var r = o.props !== f;
o.props !== void 0 &&
@@ -14293,13 +12841,13 @@ https://reactjs.org/link/unsafe-component-lifecycles`,
c(
"%s(...): When calling super() in `%s`, make sure to pass up the same props that your component's constructor was passed.",
d,
- d
+ d,
),
o.defaultProps &&
c(
"Setting defaultProps as an instance property on %s is not supported and will be ignored. Instead, define defaultProps as a static property on %s.",
d,
- d
+ d,
),
typeof o.getSnapshotBeforeUpdate == "function" &&
typeof o.componentDidUpdate != "function" &&
@@ -14307,33 +12855,28 @@ https://reactjs.org/link/unsafe-component-lifecycles`,
($n.add(a),
c(
"%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). This component defines getSnapshotBeforeUpdate() only.",
- ne(a)
+ ne(a),
)),
typeof o.getDerivedStateFromProps == "function" &&
c(
"%s: getDerivedStateFromProps() is defined as an instance method and will be ignored. Instead, declare it as a static method.",
- d
+ d,
),
typeof o.getDerivedStateFromError == "function" &&
c(
"%s: getDerivedStateFromError() is defined as an instance method and will be ignored. Instead, declare it as a static method.",
- d
+ d,
),
typeof a.getSnapshotBeforeUpdate == "function" &&
c(
"%s: getSnapshotBeforeUpdate() is defined as a static method and will be ignored. Instead, declare it as an instance method.",
- d
+ d,
);
var l = o.state;
- l &&
- (typeof l != "object" || cr(l)) &&
- c("%s.state: must be set to an object or null", d),
+ l && (typeof l != "object" || cr(l)) && c("%s.state: must be set to an object or null", d),
typeof o.getChildContext == "function" &&
typeof a.childContextTypes != "object" &&
- c(
- "%s.getChildContext(): childContextTypes must be defined in order to use getChildContext().",
- d
- );
+ c("%s.getChildContext(): childContextTypes must be defined in order to use getChildContext().", d);
}
}
function ll(o, a) {
@@ -14348,18 +12891,17 @@ https://reactjs.org/link/unsafe-component-lifecycles`,
* Move code from componentWillMount to componentDidMount (preferred in most cases) or the constructor.
Please update the following components: %s`,
- d
+ d,
),
(jo[d] = !0));
}
a.componentWillMount();
}
- typeof a.UNSAFE_componentWillMount == "function" &&
- a.UNSAFE_componentWillMount(),
+ typeof a.UNSAFE_componentWillMount == "function" && a.UNSAFE_componentWillMount(),
f !== a.state &&
(c(
"%s.componentWillMount(): Assigning directly to this.state is deprecated (except inside a component's constructor). Use setState instead.",
- ne(o) || "Component"
+ ne(o) || "Component",
),
il.enqueueReplaceState(a, a.state, null));
}
@@ -14367,14 +12909,9 @@ Please update the following components: %s`,
if (o.queue !== null && o.queue.length > 0) {
var t = o.queue,
r = o.replace;
- if (((o.queue = null), (o.replace = !1), r && t.length === 1))
- a.state = t[0];
+ if (((o.queue = null), (o.replace = !1), r && t.length === 1)) a.state = t[0];
else {
- for (
- var l = r ? t[0] : a.state, u = !0, p = r ? 1 : 0;
- p < t.length;
- p++
- ) {
+ for (var l = r ? t[0] : a.state, u = !0, p = r ? 1 : 0; p < t.length; p++) {
var g = t[p],
y = typeof g == "function" ? g.call(a, l, f, d) : g;
y != null && (u ? ((u = !1), (l = ze({}, l, y))) : ze(l, y));
@@ -14390,26 +12927,20 @@ Please update the following components: %s`,
var r = { queue: [], replace: !1 };
ol(o, r);
var l = a.contextType;
- if (
- (typeof l == "object" && l !== null
- ? (o.context = Wn(l))
- : (o.context = d),
- o.state === f)
- ) {
+ if ((typeof l == "object" && l !== null ? (o.context = Wn(l)) : (o.context = d), o.state === f)) {
var u = ne(a) || "Component";
Nn.has(u) ||
(Nn.add(u),
c(
"%s: It is not recommended to assign props directly to state because updates to props won't be reflected in state. In most cases, it is better to use props directly.",
- u
+ u,
));
}
var p = a.getDerivedStateFromProps;
typeof p == "function" && (o.state = uu(o, a, p, t, f)),
typeof a.getDerivedStateFromProps != "function" &&
typeof o.getSnapshotBeforeUpdate != "function" &&
- (typeof o.UNSAFE_componentWillMount == "function" ||
- typeof o.componentWillMount == "function") &&
+ (typeof o.UNSAFE_componentWillMount == "function" || typeof o.componentWillMount == "function") &&
(ll(a, o), du(r, o, f, d));
}
var oi = { id: 1, overflow: "" };
@@ -14458,9 +12989,7 @@ Please update the following components: %s`,
return a === 0 ? 32 : (31 - ((vu(a) / gu) | 0)) | 0;
}
function At(o, a) {
- return (
- (o === a && (o !== 0 || 1 / o === 1 / a)) || (o !== o && a !== a)
- );
+ return (o === a && (o !== 0 || 1 / o === 1 / a)) || (o !== o && a !== a);
}
var ii = typeof Object.is == "function" ? Object.is : At,
Ke = null,
@@ -14485,7 +13014,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return (
Ie &&
c(
- "Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://reactjs.org/link/rules-of-hooks"
+ "Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://reactjs.org/link/rules-of-hooks",
),
Ke
);
@@ -14495,7 +13024,7 @@ See https://reactjs.org/link/invalid-hook-call for tips about how to debug and f
return (
c(
"%s received a final argument during this render, but not during the previous render. Even though the final argument is optional, its type cannot change between renders.",
- qr
+ qr,
),
!1
);
@@ -14507,17 +13036,13 @@ Previous: %s
Incoming: %s`,
qr,
"[" + o.join(", ") + "]",
- "[" + a.join(", ") + "]"
+ "[" + a.join(", ") + "]",
);
- for (var f = 0; f < a.length && f < o.length; f++)
- if (!ii(o[f], a[f])) return !1;
+ for (var f = 0; f < a.length && f < o.length; f++) if (!ii(o[f], a[f])) return !1;
return !0;
}
function ul() {
- if ($e > 0)
- throw new Error(
- "Rendered more hooks than during the previous render"
- );
+ if ($e > 0) throw new Error("Rendered more hooks than during the previous render");
return { memoizedState: null, queue: null, next: null };
}
function si() {
@@ -14544,20 +13069,13 @@ Incoming: %s`,
return o;
}
function ci() {
- (Ie = !1),
- (Ke = null),
- (X = null),
- (ot = !1),
- (Vt = null),
- ($e = 0),
- (Gt = null),
- (G = null);
+ (Ie = !1), (Ke = null), (X = null), (ot = !1), (Vt = null), ($e = 0), (Gt = null), (G = null);
}
function fi(o) {
return (
Ie &&
c(
- "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()."
+ "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().",
),
Wn(o)
);
@@ -14592,9 +13110,7 @@ Incoming: %s`,
} else {
Ie = !0;
var g;
- o === Yo
- ? (g = typeof a == "function" ? a() : a)
- : (g = f !== void 0 ? f(a) : a),
+ o === Yo ? (g = typeof a == "function" ? a() : a) : (g = f !== void 0 ? f(a) : a),
(Ie = !1),
(G.memoizedState = g);
var y = (G.queue = { last: null, dispatch: null }),
@@ -14627,14 +13143,12 @@ Incoming: %s`,
function Su(o, a) {
(qr = "useLayoutEffect"),
c(
- "useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes."
+ "useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes.",
);
}
function wu(o, a, f) {
if ($e >= Kr)
- throw new Error(
- "Too many re-renders. React limits the number of renders to prevent an infinite loop."
- );
+ throw new Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");
if (o === Ke) {
ot = !0;
var d = { action: f, next: null };
@@ -14658,7 +13172,7 @@ Incoming: %s`,
function Tu(o, a, f) {
if (f === void 0)
throw new Error(
- "Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering."
+ "Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering.",
);
return f();
}
@@ -14666,9 +13180,7 @@ Incoming: %s`,
return Xt(), o;
}
function Eu() {
- throw new Error(
- "startTransition cannot be called during server rendering."
- );
+ throw new Error("startTransition cannot be called during server rendering.");
}
function Go() {
return Xt(), [!1, Eu];
@@ -14678,9 +13190,7 @@ Incoming: %s`,
a = No(o.treeContext),
f = pi;
if (f === null)
- throw new Error(
- "Invalid hook call. Hooks can only be called inside of the body of a function component."
- );
+ throw new Error("Invalid hook call. Hooks can only be called inside of the body of a function component.");
var d = Sr++;
return wo(f, a, d);
}
@@ -14804,8 +13314,7 @@ Error generating stack: ` +
};
}
function at(o, a, f, d, t, r, l, u) {
- o.allPendingTasks++,
- f === null ? o.pendingRootTasks++ : f.pendingTasks++;
+ o.allPendingTasks++, f === null ? o.pendingRootTasks++ : f.pendingTasks++;
var p = {
node: a,
ping: function () {
@@ -14836,9 +13345,7 @@ Error generating stack: ` +
}
var Ne = null;
function Qo() {
- return Ne === null || Ne.componentStack === null
- ? ""
- : hi(Ne.componentStack);
+ return Ne === null || Ne.componentStack === null ? "" : hi(Ne.componentStack);
}
function Xn(o, a) {
o.componentStack = { tag: 0, parent: o.componentStack, type: a };
@@ -14851,20 +13358,14 @@ Error generating stack: ` +
}
function mt(o) {
o.componentStack === null
- ? c(
- "Unexpectedly popped too many stack frames. This is a bug in React."
- )
+ ? c("Unexpectedly popped too many stack frames. This is a bug in React.")
: (o.componentStack = o.componentStack.parent);
}
var Ot = null;
function on(o, a) {
{
var f;
- typeof a == "string"
- ? (f = a)
- : a && typeof a.message == "string"
- ? (f = a.message)
- : (f = String(a));
+ typeof a == "string" ? (f = a) : a && typeof a.message == "string" ? (f = a.message) : (f = String(a));
var d = Ot || Qo();
(Ot = null), (o.errorMessage = f), (o.errorComponentStack = d);
}
@@ -14875,7 +13376,7 @@ Error generating stack: ` +
throw new Error(
'onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "' +
typeof f +
- '" instead'
+ '" instead',
);
return f;
}
@@ -14883,10 +13384,7 @@ Error generating stack: ` +
var f = o.onShellError;
f(a);
var d = o.onFatalError;
- d(a),
- o.destination !== null
- ? ((o.status = rn), ct(o.destination, a))
- : ((o.status = ml), (o.fatalError = a));
+ d(a), o.destination !== null ? ((o.status = rn), ct(o.destination, a)) : ((o.status = ml), (o.fatalError = a));
}
function Iu(o, a, f) {
Xn(a, "Suspense");
@@ -14913,10 +13411,7 @@ Error generating stack: ` +
return;
}
} catch (_) {
- (w.status = gi),
- (p.forceClientRender = !0),
- (p.errorDigest = Jn(o, _)),
- on(p, _);
+ (w.status = gi), (p.forceClientRender = !0), (p.errorDigest = Jn(o, _)), on(p, _);
} finally {
(a.blockedBoundary = d), (a.blockedSegment = t);
}
@@ -14951,7 +13446,7 @@ Error generating stack: ` +
(xi ||
c(
"It looks like %s is reassigning its own `this.props` while rendering. This is not supported and can lead to confusing bugs.",
- ne(d) || "a component"
+ ne(d) || "a component",
),
(xi = !0));
{
@@ -14981,44 +13476,30 @@ Error generating stack: ` +
kl = !1;
function Tl(o, a, f, d) {
var t;
- if (
- ((t = Xr(f, a.legacyContext)),
- Dt(a, f),
- f.prototype && typeof f.prototype.render == "function")
- ) {
+ if (((t = Xr(f, a.legacyContext)), Dt(a, f), f.prototype && typeof f.prototype.render == "function")) {
var r = ne(f) || "Unknown";
bi[r] ||
(c(
"The <%s /> component appears to have a render method, but doesn't extend React.Component. This is likely to cause errors. Change %s to extend React.Component instead.",
r,
- r
+ r,
),
(bi[r] = !0));
}
var l = wl(o, a, f, d, t),
u = fl();
- if (
- typeof l == "object" &&
- l !== null &&
- typeof l.render == "function" &&
- l.$$typeof === void 0
- ) {
+ if (typeof l == "object" && l !== null && typeof l.render == "function" && l.$$typeof === void 0) {
var p = ne(f) || "Unknown";
Qn[p] ||
(c(
"The <%s /> component appears to be a function component that returns a class instance. Change %s to a class that extends React.Component instead. If you can't use a class try assigning the prototype on the function as a workaround. `%s.prototype = React.Component.prototype`. Don't use an arrow function since it cannot be called with `new` by React.",
p,
p,
- p
+ p,
),
(Qn[p] = !0));
}
- if (
- typeof l == "object" &&
- l !== null &&
- typeof l.render == "function" &&
- l.$$typeof === void 0
- ) {
+ if (typeof l == "object" && l !== null && typeof l.render == "function" && l.$$typeof === void 0) {
{
var g = ne(f) || "Unknown";
Qn[g] ||
@@ -15026,7 +13507,7 @@ Error generating stack: ` +
"The <%s /> component appears to be a function component that returns a class instance. Change %s to a class that extends React.Component instead. If you can't use a class try assigning the prototype on the function as a workaround. `%s.prototype = React.Component.prototype`. Don't use an arrow function since it cannot be called with `new` by React.",
g,
g,
- g
+ g,
),
(Qn[g] = !0));
}
@@ -15051,23 +13532,16 @@ Error generating stack: ` +
o.childContextTypes &&
c(
"%s(...): childContextTypes cannot be defined on a function component.",
- o.displayName || o.name || "Component"
+ o.displayName || o.name || "Component",
),
typeof o.getDerivedStateFromProps == "function")
) {
var a = ne(o) || "Unknown";
- wi[a] ||
- (c(
- "%s: Function components do not support getDerivedStateFromProps.",
- a
- ),
- (wi[a] = !0));
+ wi[a] || (c("%s: Function components do not support getDerivedStateFromProps.", a), (wi[a] = !0));
}
if (typeof o.contextType == "object" && o.contextType !== null) {
var f = ne(o) || "Unknown";
- Si[f] ||
- (c("%s: Function components do not support contextType.", f),
- (Si[f] = !0));
+ Si[f] || (c("%s: Function components do not support contextType.", f), (Si[f] = !0));
}
}
}
@@ -15108,13 +13582,13 @@ Error generating stack: ` +
(kl ||
((kl = !0),
c(
- "Rendering <Context> directly is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?"
+ "Rendering <Context> directly is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?",
)))
: (f = f._context);
var t = d.children;
typeof t != "function" &&
c(
- "A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it."
+ "A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it.",
);
var r = Wn(f),
l = t(r);
@@ -15130,9 +13604,7 @@ Error generating stack: ` +
Ue(o, a, l),
(a.context = Hn(t)),
u !== a.context &&
- c(
- "Popping the context provider did not return back to the original snapshot. This is a bug in React."
- );
+ c("Popping the context provider did not return back to the original snapshot. This is a bug in React.");
}
function Du(o, a, f, d, t) {
Xn(a, "Lazy");
@@ -15169,9 +13641,7 @@ Error generating stack: ` +
return;
}
case tu:
- throw new Error(
- "ReactDOMServer does not yet support scope components."
- );
+ throw new Error("ReactDOMServer does not yet support scope components.");
case On: {
Iu(o, a, d);
return;
@@ -15202,15 +13672,12 @@ Error generating stack: ` +
}
var r = "";
throw (
- ((f === void 0 ||
- (typeof f == "object" &&
- f !== null &&
- Object.keys(f).length === 0)) &&
+ ((f === void 0 || (typeof f == "object" && f !== null && Object.keys(f).length === 0)) &&
(r +=
" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),
new Error(
"Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) " +
- ("but got: " + (f == null ? f : typeof f) + "." + r)
+ ("but got: " + (f == null ? f : typeof f) + "." + r),
))
);
}
@@ -15219,14 +13686,11 @@ Error generating stack: ` +
o[Symbol.toStringTag] === "Generator" &&
(ki ||
c(
- "Using Generators as children is unsupported and will likely yield unexpected results because enumerating a generator mutates it. You may convert it to an array with `Array.from()` or the `[...spread]` operator before rendering. Keep in mind you might need to polyfill these features for older browsers."
+ "Using Generators as children is unsupported and will likely yield unexpected results because enumerating a generator mutates it. You may convert it to an array with `Array.from()` or the `[...spread]` operator before rendering. Keep in mind you might need to polyfill these features for older browsers.",
),
(ki = !0)),
o.entries === a &&
- (xl ||
- c(
- "Using Maps as children is not supported. Use an array of keyed ReactElements instead."
- ),
+ (xl || c("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),
(xl = !0));
}
function Ue(o, a, f) {
@@ -15234,11 +13698,7 @@ Error generating stack: ` +
return Mu(o, a, f);
} catch (d) {
throw (
- ((typeof d == "object" &&
- d !== null &&
- typeof d.then == "function") ||
- (Ot = Ot !== null ? Ot : Qo()),
- d)
+ ((typeof d == "object" && d !== null && typeof d.then == "function") || (Ot = Ot !== null ? Ot : Qo()), d)
);
}
}
@@ -15255,7 +13715,7 @@ Error generating stack: ` +
}
case Ha:
throw new Error(
- "Portals are not currently supported by the server renderer. Render them conditionally so that they only appear on the client render."
+ "Portals are not currently supported by the server renderer. Render them conditionally so that they only appear on the client render.",
);
case _o: {
var u = f,
@@ -15265,13 +13725,7 @@ Error generating stack: ` +
try {
y = g(p);
} catch (we) {
- throw (
- (typeof we == "object" &&
- we !== null &&
- typeof we.then == "function" &&
- Xn(a, "Lazy"),
- we)
- );
+ throw (typeof we == "object" && we !== null && typeof we.then == "function" && Xn(a, "Lazy"), we);
}
Ue(o, a, y);
return;
@@ -15300,35 +13754,23 @@ Error generating stack: ` +
var j = Object.prototype.toString.call(f);
throw new Error(
"Objects are not valid as a React child (found: " +
- (j === "[object Object]"
- ? "object with keys {" + Object.keys(f).join(", ") + "}"
- : j) +
- "). If you meant to render a collection of children, use an array instead."
+ (j === "[object Object]" ? "object with keys {" + Object.keys(f).join(", ") + "}" : j) +
+ "). If you meant to render a collection of children, use an array instead.",
);
}
if (typeof f == "string") {
var Z = a.blockedSegment;
- Z.lastPushedText = ht(
- a.blockedSegment.chunks,
- f,
- o.responseState,
- Z.lastPushedText
- );
+ Z.lastPushedText = ht(a.blockedSegment.chunks, f, o.responseState, Z.lastPushedText);
return;
}
if (typeof f == "number") {
var de = a.blockedSegment;
- de.lastPushedText = ht(
- a.blockedSegment.chunks,
- "" + f,
- o.responseState,
- de.lastPushedText
- );
+ de.lastPushedText = ht(a.blockedSegment.chunks, "" + f, o.responseState, de.lastPushedText);
return;
}
typeof f == "function" &&
c(
- "Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it."
+ "Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.",
);
}
function ea(o, a, f) {
@@ -15347,18 +13789,8 @@ Error generating stack: ` +
t = d.chunks.length,
r = nn(o, t, null, d.formatContext, d.lastPushedText, !0);
d.children.push(r), (d.lastPushedText = !1);
- var l = at(
- o,
- a.node,
- a.blockedBoundary,
- r,
- a.abortSet,
- a.legacyContext,
- a.context,
- a.treeContext
- );
- a.componentStack !== null &&
- (l.componentStack = a.componentStack.parent);
+ var l = at(o, a.node, a.blockedBoundary, r, a.abortSet, a.legacyContext, a.context, a.treeContext);
+ a.componentStack !== null && (l.componentStack = a.componentStack.parent);
var u = l.ping;
f.then(u, u);
}
@@ -15371,10 +13803,7 @@ Error generating stack: ` +
try {
return Ue(o, a, f);
} catch (u) {
- if (
- (ci(),
- typeof u == "object" && u !== null && typeof u.then == "function")
- ) {
+ if ((ci(), typeof u == "object" && u !== null && typeof u.then == "function")) {
Lu(o, a, u),
(a.blockedSegment.formatContext = d),
(a.legacyContext = t),
@@ -15421,24 +13850,15 @@ Error generating stack: ` +
var d = o.blockedBoundary,
t = o.blockedSegment;
if (((t.status = gl), d === null))
- a.allPendingTasks--,
- a.status !== rn &&
- ((a.status = rn), a.destination !== null && xe(a.destination));
+ a.allPendingTasks--, a.status !== rn && ((a.status = rn), a.destination !== null && xe(a.destination));
else {
if ((d.pendingTasks--, !d.forceClientRender)) {
d.forceClientRender = !0;
- var r =
- f === void 0
- ? new Error(
- "The render was aborted by the server without a reason."
- )
- : f;
+ var r = f === void 0 ? new Error("The render was aborted by the server without a reason.") : f;
d.errorDigest = a.onError(r);
{
var l = "The server did not finish this Suspense boundary: ";
- r && typeof r.message == "string"
- ? (r = l + r.message)
- : (r = l + String(r));
+ r && typeof r.message == "string" ? (r = l + r.message) : (r = l + String(r));
var u = Ne;
Ne = o;
try {
@@ -15463,11 +13883,7 @@ Error generating stack: ` +
}
}
function ra(o, a) {
- if (
- a.chunks.length === 0 &&
- a.children.length === 1 &&
- a.children[0].boundary === null
- ) {
+ if (a.chunks.length === 0 && a.children.length === 1 && a.children[0].boundary === null) {
var f = a.children[0];
(f.id = a.id), (f.parentFlushed = !0), f.status === wr && ra(o, f);
} else {
@@ -15479,9 +13895,7 @@ Error generating stack: ` +
if (a === null) {
if (f.parentFlushed) {
if (o.completedRootSegment !== null)
- throw new Error(
- "There can only be one root segment. This is a bug in React."
- );
+ throw new Error("There can only be one root segment. This is a bug in React.");
o.completedRootSegment = f;
}
if ((o.pendingRootTasks--, o.pendingRootTasks === 0)) {
@@ -15519,16 +13933,10 @@ Error generating stack: ` +
(f.status = wr),
Ri(o, a.blockedBoundary, f);
} catch (r) {
- if (
- (ci(),
- typeof r == "object" && r !== null && typeof r.then == "function")
- ) {
+ if ((ci(), typeof r == "object" && r !== null && typeof r.then == "function")) {
var t = a.ping;
r.then(t, t);
- } else
- a.abortSet.delete(a),
- (f.status = gi),
- El(o, a.blockedBoundary, f, r);
+ } else a.abortSet.delete(a), (f.status = gi), El(o, a.blockedBoundary, f, r);
} finally {
Ne = d;
}
@@ -15554,10 +13962,7 @@ Error generating stack: ` +
} catch (p) {
Jn(o, p), Ko(o, p);
} finally {
- Xo(t),
- (Vn.current = f),
- (Zt.getCurrentStack = d),
- f === di && Lo(a);
+ Xo(t), (Vn.current = f), (Zt.getCurrentStack = d), f === di && Lo(a);
}
}
}
@@ -15565,19 +13970,11 @@ Error generating stack: ` +
switch (((f.parentFlushed = !0), f.status)) {
case Zo: {
var d = (f.id = o.nextSegmentId++);
- return (
- (f.lastPushedText = !1),
- (f.textEmbedded = !1),
- ee(a, o.responseState, d)
- );
+ return (f.lastPushedText = !1), (f.textEmbedded = !1), ee(a, o.responseState, d);
}
case wr: {
f.status = vi;
- for (
- var t = !0, r = f.chunks, l = 0, u = f.children, p = 0;
- p < u.length;
- p++
- ) {
+ for (var t = !0, r = f.chunks, l = 0, u = f.children, p = 0; p < u.length; p++) {
for (var g = u[p]; l < g.index; l++) P(a, r[l]);
t = qn(o, a, g);
}
@@ -15586,7 +13983,7 @@ Error generating stack: ` +
}
default:
throw new Error(
- "Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React."
+ "Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React.",
);
}
}
@@ -15595,19 +13992,12 @@ Error generating stack: ` +
if (d === null) return oa(o, a, f);
if (((d.parentFlushed = !0), d.forceClientRender))
return (
- ms(
- a,
- o.responseState,
- d.errorDigest,
- d.errorMessage,
- d.errorComponentStack
- ),
+ ms(a, o.responseState, d.errorDigest, d.errorMessage, d.errorComponentStack),
oa(o, a, f),
bs(a, o.responseState)
);
if (d.pendingTasks > 0) {
- (d.rootSegmentID = o.nextSegmentId++),
- d.completedSegments.length > 0 && o.partialBoundaries.push(d);
+ (d.rootSegmentID = o.nextSegmentId++), d.completedSegments.length > 0 && o.partialBoundaries.push(d);
var t = (d.id = Br(o.responseState));
return Ni(a, o.responseState, t), oa(o, a, f), Vi(a, o.responseState);
} else {
@@ -15623,28 +14013,17 @@ Error generating stack: ` +
var r = d.completedSegments;
if (r.length !== 1)
throw new Error(
- "A previously unvisited boundary must have exactly one root segment. This is a bug in React."
+ "A previously unvisited boundary must have exactly one root segment. This is a bug in React.",
);
var l = r[0];
return qn(o, a, l), ys(a, o.responseState);
}
}
function Rl(o, a, f) {
- return eu(
- a,
- o.responseState,
- f.id,
- f.errorDigest,
- f.errorMessage,
- f.errorComponentStack
- );
+ return eu(a, o.responseState, f.id, f.errorDigest, f.errorMessage, f.errorComponentStack);
}
function Il(o, a, f) {
- return (
- Ws(a, o.responseState, f.formatContext, f.id),
- qn(o, a, f),
- zs(a, f.formatContext)
- );
+ return Ws(a, o.responseState, f.formatContext, f.id), qn(o, a, f), zs(a, f.formatContext);
}
function Ii(o, a, f) {
for (var d = f.completedSegments, t = 0; t < d.length; t++) {
@@ -15665,10 +14044,7 @@ Error generating stack: ` +
var t = d.id;
if (t === -1) {
var r = (d.id = f.rootSegmentID);
- if (r === -1)
- throw new Error(
- "A root segment ID must have been assigned by now. This is a bug in React."
- );
+ if (r === -1) throw new Error("A root segment ID must have been assigned by now. This is a bug in React.");
return Il(o, a, d);
} else return Il(o, a, d), La(a, o.responseState, t);
}
@@ -15678,9 +14054,7 @@ Error generating stack: ` +
var f = o.completedRootSegment;
f !== null &&
o.pendingRootTasks === 0 &&
- (qn(o, a, f),
- (o.completedRootSegment = null),
- Y(a, o.responseState));
+ (qn(o, a, f), (o.completedRootSegment = null), Y(a, o.responseState));
var d = o.clientRenderedBoundaries,
t;
for (t = 0; t < d.length; t++) {
@@ -15726,9 +14100,7 @@ Error generating stack: ` +
o.clientRenderedBoundaries.length === 0 &&
o.completedBoundaries.length === 0 &&
(o.abortableTasks.size !== 0 &&
- c(
- "There was still abortable task at the root when we closed. This is a bug in React."
- ),
+ c("There was still abortable task at the root when we closed. This is a bug in React."),
xe(a));
}
}
@@ -15781,7 +14153,7 @@ Error generating stack: ` +
a ? a.nonce : void 0,
a ? a.bootstrapScriptContent : void 0,
a ? a.bootstrapScripts : void 0,
- a ? a.bootstrapModules : void 0
+ a ? a.bootstrapModules : void 0,
),
wn(a ? a.namespaceURI : void 0),
a ? a.progressiveChunkSize : void 0,
@@ -15789,7 +14161,7 @@ Error generating stack: ` +
a ? a.onAllReady : void 0,
a ? a.onShellReady : void 0,
a ? a.onShellError : void 0,
- void 0
+ void 0,
);
}
function Al(o, a) {
@@ -15799,27 +14171,13 @@ Error generating stack: ` +
_l(f),
{
pipe: function (t) {
- if (d)
- throw new Error(
- "React currently only supports piping to one writable stream."
- );
+ if (d) throw new Error("React currently only supports piping to one writable stream.");
return (
(d = !0),
Pl(f, t),
t.on("drain", Bu(t, f)),
- t.on(
- "error",
- Fl(
- f,
- new Error(
- "The destination stream errored while writing data."
- )
- )
- ),
- t.on(
- "close",
- Fl(f, new Error("The destination stream closed early."))
- ),
+ t.on("error", Fl(f, new Error("The destination stream errored while writing data."))),
+ t.on("close", Fl(f, new Error("The destination stream closed early."))),
t
);
},
@@ -15832,12 +14190,10 @@ Error generating stack: ` +
(Pc.renderToPipeableStream = Al), (Pc.version = i);
})();
});
-var zd = an((lo) => {
+var zd = an(lo => {
"use strict";
var io, Fc;
- process.env.NODE_ENV === "production"
- ? ((io = Wf()), (Fc = jd()))
- : ((io = Hd()), (Fc = Wd()));
+ process.env.NODE_ENV === "production" ? ((io = Wf()), (Fc = jd())) : ((io = Hd()), (Fc = Wd()));
lo.version = io.version;
lo.renderToString = io.renderToString;
lo.renderToStaticMarkup = io.renderToStaticMarkup;
@@ -15852,11 +14208,7 @@ var Nd = Dc(zd()),
$i.default.createElement(
"html",
null,
- $i.default.createElement(
- "body",
- null,
- $i.default.createElement("h1", null, "Hello World")
- )
+ $i.default.createElement("body", null, $i.default.createElement("h1", null, "Hello World")),
),
$d = !1;
Cv.createServer(function (e, n) {
@@ -15868,10 +14220,7 @@ Cv.createServer(function (e, n) {
i.pipe(n);
},
onShellError(s) {
- (n.statusCode = 500),
- n.send(
- '<!doctype html><p>Loading...</p><script src="clientrender.js"></script>'
- );
+ (n.statusCode = 500), n.send('<!doctype html><p>Loading...</p><script src="clientrender.js"></script>');
},
onAllReady() {},
onError(s) {
diff --git a/bench/react-hello-world/react-hello-world.node.jsx b/bench/react-hello-world/react-hello-world.node.jsx
index b267bbd4d..2f3c06149 100644
--- a/bench/react-hello-world/react-hello-world.node.jsx
+++ b/bench/react-hello-world/react-hello-world.node.jsx
@@ -24,9 +24,7 @@ http
onShellError(error) {
// Something errored before we could complete the shell so we emit an alternative shell.
res.statusCode = 500;
- res.send(
- '<!doctype html><p>Loading...</p><script src="clientrender.js"></script>'
- );
+ res.send('<!doctype html><p>Loading...</p><script src="clientrender.js"></script>');
},
onAllReady() {
// If you don't want streaming, use this instead of onShellReady.
diff --git a/bench/scanner/scan-imports-only.js b/bench/scanner/scan-imports-only.js
index 53222d57c..3cd55fe2c 100644
--- a/bench/scanner/scan-imports-only.js
+++ b/bench/scanner/scan-imports-only.js
@@ -8,8 +8,6 @@ const transpiler = new Bun.Transpiler({
console.time("Get exports");
const ITERATIONS = parseInt(process.env.ITERATIONS || "1") || 1;
for (let i = 0; i < ITERATIONS; i++) {
- const imports = transpiler.scanImports(
- readFileSync("remix-route.ts", "utf8")
- );
+ const imports = transpiler.scanImports(readFileSync("remix-route.ts", "utf8"));
}
console.timeEnd("Get exports");
diff --git a/bench/snippets/array-map.mjs b/bench/snippets/array-map.mjs
index 2b6f4f669..615770220 100644
--- a/bench/snippets/array-map.mjs
+++ b/bench/snippets/array-map.mjs
@@ -1,7 +1,7 @@
// https://github.com/oven-sh/bun/issues/1096
import { bench, run } from "mitata";
-const identity = (x) => x;
+const identity = x => x;
for (let i = 0; i < 20; i++) {
var array = new Array(i);
@@ -22,35 +22,15 @@ bench("inline Array.map x 6", () => [1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 7", () => [1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 8", () => [1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 9", () => [1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
-bench("inline Array.map x 10", () =>
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
-);
-bench("inline Array.map x 11", () =>
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
-);
-bench("inline Array.map x 12", () =>
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
-);
-bench("inline Array.map x 13", () =>
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
-);
-bench("inline Array.map x 14", () =>
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
-);
-bench("inline Array.map x 15", () =>
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
-);
-bench("inline Array.map x 16", () =>
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
-);
-bench("inline Array.map x 17", () =>
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
-);
-bench("inline Array.map x 18", () =>
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
-);
-bench("inline Array.map x 19", () =>
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
-);
+bench("inline Array.map x 10", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
+bench("inline Array.map x 11", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
+bench("inline Array.map x 12", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
+bench("inline Array.map x 13", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
+bench("inline Array.map x 14", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
+bench("inline Array.map x 15", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
+bench("inline Array.map x 16", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
+bench("inline Array.map x 17", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
+bench("inline Array.map x 18", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
+bench("inline Array.map x 19", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
await run();
diff --git a/bench/snippets/assert.mjs b/bench/snippets/assert.mjs
index bbc36d1ea..dc6c98d2e 100644
--- a/bench/snippets/assert.mjs
+++ b/bench/snippets/assert.mjs
@@ -6,10 +6,7 @@ bench("deepEqual", () => {
});
bench("deepStrictEqual", () => {
- assert.deepStrictEqual(
- { foo: "123", beep: "boop" },
- { foo: "123", beep: "boop" },
- );
+ assert.deepStrictEqual({ foo: "123", beep: "boop" }, { foo: "123", beep: "boop" });
});
await run();
diff --git a/bench/snippets/async-overhead.mjs b/bench/snippets/async-overhead.mjs
index bec278b56..753af1632 100644
--- a/bench/snippets/async-overhead.mjs
+++ b/bench/snippets/async-overhead.mjs
@@ -19,13 +19,10 @@ bench("promise.nextTick", async function () {
});
bench("await new Promise(resolve => resolve())", async function () {
- await new Promise((resolve) => resolve());
+ await new Promise(resolve => resolve());
+});
+bench("Promise.all(Array.from({length: 100}, () => new Promise((resolve) => resolve())))", async function () {
+ return Promise.all(Array.from({ length: 100 }, () => Promise.resolve(1)));
});
-bench(
- "Promise.all(Array.from({length: 100}, () => new Promise((resolve) => resolve())))",
- async function () {
- return Promise.all(Array.from({ length: 100 }, () => Promise.resolve(1)));
- },
-);
await run();
diff --git a/bench/snippets/buffer-read.js b/bench/snippets/buffer-read.js
index 5da645153..46c64b59f 100644
--- a/bench/snippets/buffer-read.js
+++ b/bench/snippets/buffer-read.js
@@ -23,9 +23,7 @@ time("Uint8Array[]", () => array[0]);
console.log("");
time("Buffer.getBigInt64BE ", () => buf.readBigInt64BE(0));
-time("DataView.getBigInt64 (BE)", () =>
- view.getBigInt64(0, false).toString(10)
-);
+time("DataView.getBigInt64 (BE)", () => view.getBigInt64(0, false).toString(10));
console.log("");
time("Buffer.readBigInt64LE ", () => buf.readBigInt64LE(0));
diff --git a/bench/snippets/buffer.js b/bench/snippets/buffer.js
index 9ababbf35..22dad8e34 100644
--- a/bench/snippets/buffer.js
+++ b/bench/snippets/buffer.js
@@ -10,18 +10,13 @@ var time = (name, fn) => {
console.timeEnd(name.padEnd('Buffer.write(string, "latin1")'.length));
};
-console.log(
- `Run ${new Intl.NumberFormat().format(INTERVAL)} times with a warmup:`,
- "\n"
-);
+console.log(`Run ${new Intl.NumberFormat().format(INTERVAL)} times with a warmup:`, "\n");
const stringToWrite = "hellooooohellooooo";
time('Buffer.write(string, "utf8")', () => buf.write(stringToWrite, "utf8"));
time('Buffer.write(string, "ascii")', () => buf.write(stringToWrite, "ascii"));
-time('Buffer.write(string, "latin1")', () =>
- buf.write(stringToWrite, "latin1")
-);
+time('Buffer.write(string, "latin1")', () => buf.write(stringToWrite, "latin1"));
time("Buffer.readBigInt64BE ", () => buf.readBigInt64BE(0));
// time("DataView.getBigInt64 (BE)", () => view.getBigInt64(0, false));
// console.log("");
diff --git a/bench/snippets/callbacks-overhead.mjs b/bench/snippets/callbacks-overhead.mjs
index 65171145c..4bc535ecd 100644
--- a/bench/snippets/callbacks-overhead.mjs
+++ b/bench/snippets/callbacks-overhead.mjs
@@ -35,40 +35,26 @@ async function test(log) {
{
const a = performance.now();
await tests.async(0);
- if (log)
- console.log(
- `async/await: ${(report.async = (performance.now() - a).toFixed(4))}ms`
- );
+ if (log) console.log(`async/await: ${(report.async = (performance.now() - a).toFixed(4))}ms`);
}
{
const a = performance.now();
tests.callback(0, function () {
- if (log)
- console.log(
- `callback: ${(report.callback = (performance.now() - a).toFixed(
- 4
- ))}ms`
- );
+ if (log) console.log(`callback: ${(report.callback = (performance.now() - a).toFixed(4))}ms`);
});
}
{
const a = performance.now();
await tests.then(0);
- if (log)
- console.log(
- `then: ${(report.then = (performance.now() - a).toFixed(4))}ms`
- );
+ if (log) console.log(`then: ${(report.then = (performance.now() - a).toFixed(4))}ms`);
}
{
const a = performance.now();
tests.sync(0);
- if (log)
- console.log(
- `sync: ${(report.sync = (performance.now() - a).toFixed(4))}ms`
- );
+ if (log) console.log(`sync: ${(report.sync = (performance.now() - a).toFixed(4))}ms`);
}
}
diff --git a/bench/snippets/concat.js b/bench/snippets/concat.js
index 46c6e0f7d..310e67c37 100644
--- a/bench/snippets/concat.js
+++ b/bench/snippets/concat.js
@@ -34,33 +34,25 @@ function polyfillUninitialized(chunks) {
const chunkGroups = [
[Uint8Array.from([123]), Uint8Array.from([456]), Uint8Array.from([789])],
- Array.from(readFileSync(import.meta.path)).map((a) => Uint8Array.from([a])),
+ Array.from(readFileSync(import.meta.path)).map(a => Uint8Array.from([a])),
[readFileSync(import.meta.path)],
Array.from({ length: 42 }, () => readFileSync(import.meta.path)),
- Array.from({ length: 2 }, () =>
- new TextEncoder().encode(readFileSync(import.meta.path, "utf8").repeat(100))
- ),
+ Array.from({ length: 2 }, () => new TextEncoder().encode(readFileSync(import.meta.path, "utf8").repeat(100))),
];
for (const chunks of chunkGroups) {
- group(
- `${chunks.reduce(
- (prev, curr, i, a) => prev + curr.byteLength,
- 0
- )} bytes for ${chunks.length} chunks`,
- () => {
- bench("Bun.concatArrayBuffers", () => {
- Bun.concatArrayBuffers(chunks);
- });
- bench("Uint8Array.set", () => {
- polyfill(chunks);
- });
+ group(`${chunks.reduce((prev, curr, i, a) => prev + curr.byteLength, 0)} bytes for ${chunks.length} chunks`, () => {
+ bench("Bun.concatArrayBuffers", () => {
+ Bun.concatArrayBuffers(chunks);
+ });
+ bench("Uint8Array.set", () => {
+ polyfill(chunks);
+ });
- bench("Uint8Array.set (uninitialized memory)", () => {
- polyfillUninitialized(chunks);
- });
- }
- );
+ bench("Uint8Array.set (uninitialized memory)", () => {
+ polyfillUninitialized(chunks);
+ });
+ });
}
await run();
diff --git a/bench/snippets/console-log.mjs b/bench/snippets/console-log.mjs
index 9105c71db..b95533f01 100644
--- a/bench/snippets/console-log.mjs
+++ b/bench/snippets/console-log.mjs
@@ -9,8 +9,7 @@ const json = {
url: "https://api.github.com/users/wongmjane",
html_url: "https://github.com/wongmjane",
followers_url: "https://api.github.com/users/wongmjane/followers",
- following_url:
- "https://api.github.com/users/wongmjane/following{/other_user}",
+ following_url: "https://api.github.com/users/wongmjane/following{/other_user}",
gists_url: "https://api.github.com/users/wongmjane/gists{/gist_id}",
starred_url: "https://api.github.com/users/wongmjane/starred{/owner}{/repo}",
subscriptions_url: "https://api.github.com/users/wongmjane/subscriptions",
@@ -37,11 +36,7 @@ const json = {
};
const inspect =
- "Bun" in globalThis
- ? Bun.inspect
- : "Deno" in globalThis
- ? Deno.inspect
- : (await import("util")).inspect;
+ "Bun" in globalThis ? Bun.inspect : "Deno" in globalThis ? Deno.inspect : (await import("util")).inspect;
bench("big json object", () => {
console.error(json);
});
diff --git a/bench/snippets/deep-equals.js b/bench/snippets/deep-equals.js
index a56704721..bbb663113 100644
--- a/bench/snippets/deep-equals.js
+++ b/bench/snippets/deep-equals.js
@@ -259,15 +259,13 @@ const fixture = [
equal: false,
},
{
- description:
- "objects with different `toString` functions returning same values are equal",
+ description: "objects with different `toString` functions returning same values are equal",
value1: { toString: () => "Hello world!" },
value2: { toString: () => "Hello world!" },
equal: true,
},
{
- description:
- "objects with `toString` functions returning different values are not equal",
+ description: "objects with `toString` functions returning different values are not equal",
value1: { toString: () => "Hello world!" },
value2: { toString: () => "Hi!" },
equal: false,
@@ -311,13 +309,13 @@ const fixture = [
{
description: "equal arrays of objects",
value1: [
- ...Array.from({ length: 200000 }, (i) => ({
+ ...Array.from({ length: 200000 }, i => ({
a: 1,
b: 2,
})),
],
value2: [
- ...Array.from({ length: 200000 }, (i) => ({
+ ...Array.from({ length: 200000 }, i => ({
a: 1,
b: 2,
})),
@@ -495,9 +493,7 @@ for (let { tests, description } of fixture) {
bench(equalsFn.name, () => {
expected = equalsFn(value1, value2);
if (expected !== equal) {
- throw new Error(
- `Expected ${expected} to be ${equal} for ${description}`,
- );
+ throw new Error(`Expected ${expected} to be ${equal} for ${description}`);
}
});
}
diff --git a/bench/snippets/define-properties.mjs b/bench/snippets/define-properties.mjs
index 935737b2d..6a10ab183 100644
--- a/bench/snippets/define-properties.mjs
+++ b/bench/snippets/define-properties.mjs
@@ -19,14 +19,7 @@ const properties = {
writable: {
get() {
const w = this._writableState;
- return (
- !!w &&
- w.writable !== false &&
- !w.destroyed &&
- !w.errored &&
- !w.ending &&
- !w.ended
- );
+ return !!w && w.writable !== false && !w.destroyed && !w.errored && !w.ending && !w.ended;
},
set(val) {
if (this._writableState) {
diff --git a/bench/snippets/dns.node.mjs b/bench/snippets/dns.node.mjs
index 1a27afd0d..2796ad702 100644
--- a/bench/snippets/dns.node.mjs
+++ b/bench/snippets/dns.node.mjs
@@ -7,7 +7,7 @@ bench("(cached) dns.lookup remote x 50", async () => {
const total = 50;
var remain = total;
var done;
- await new Promise((resolve) => {
+ await new Promise(resolve => {
for (var i = 0; i < total; i++)
run().finally(() => {
remain--;
@@ -25,7 +25,7 @@ bench("(cached in batch) dns.lookup remote x 50", async () => {
const total = 50;
var remain = total;
var done;
- await new Promise((resolve) => {
+ await new Promise(resolve => {
for (var i = 0; i < total; i++)
run().finally(() => {
remain--;
@@ -40,10 +40,9 @@ bench("(cached in batch) dns.lookup remote x 50", async () => {
bench("dns.lookup remote x 50", async () => {
var remain = 50;
var done;
- const run = () =>
- lookup(Math.random().toString() + ".example.com").catch(() => {});
+ const run = () => lookup(Math.random().toString() + ".example.com").catch(() => {});
- await new Promise((resolve) => {
+ await new Promise(resolve => {
for (var i = 0; i < 50; i++)
run().finally(() => {
remain--;
@@ -58,10 +57,9 @@ bench("dns.lookup remote x 50", async () => {
bench("dns.resolve remote x 50", async () => {
var remain = 50;
var done;
- const run = () =>
- resolve(Math.random().toString() + ".example.com").catch(() => {});
+ const run = () => resolve(Math.random().toString() + ".example.com").catch(() => {});
- await new Promise((resolve) => {
+ await new Promise(resolve => {
for (var i = 0; i < 50; i++)
run().finally(() => {
remain--;
diff --git a/bench/snippets/dns.ts b/bench/snippets/dns.ts
index 308d54b6a..930cd3b83 100644
--- a/bench/snippets/dns.ts
+++ b/bench/snippets/dns.ts
@@ -3,23 +3,16 @@ import { bench, run, group } from "mitata";
async function forEachBackend(name, fn) {
group(name, () => {
- for (let backend of [
- "libc",
- "c-ares",
- process.platform === "darwin" ? "system" : "",
- ].filter(Boolean))
+ for (let backend of ["libc", "c-ares", process.platform === "darwin" ? "system" : ""].filter(Boolean))
bench(backend, fn(backend));
});
}
-forEachBackend("dns.lookup remote x 50", (backend) => async () => {
- const run = () =>
- dns
- .lookup(Math.random().toString(16) + ".example.com", { backend })
- .catch(() => {});
+forEachBackend("dns.lookup remote x 50", backend => async () => {
+ const run = () => dns.lookup(Math.random().toString(16) + ".example.com", { backend }).catch(() => {});
var remain = 16;
var done;
- await new Promise((resolve) => {
+ await new Promise(resolve => {
for (var i = 0; i < 16; i++)
run().finally(() => {
remain--;
@@ -31,7 +24,7 @@ forEachBackend("dns.lookup remote x 50", (backend) => async () => {
});
});
-forEachBackend("(cached) dns.lookup remote x 50", (backend) => {
+forEachBackend("(cached) dns.lookup remote x 50", backend => {
var tld = "example.com";
const run = () => dns.lookup(tld, { backend }).catch(() => {});
@@ -39,7 +32,7 @@ forEachBackend("(cached) dns.lookup remote x 50", (backend) => {
const total = 50;
var remain = total;
var done;
- await new Promise((resolve) => {
+ await new Promise(resolve => {
for (var i = 0; i < total; i++)
run().finally(() => {
remain--;
@@ -52,25 +45,22 @@ forEachBackend("(cached) dns.lookup remote x 50", (backend) => {
};
});
-forEachBackend(
- "(cached in batch) dns.lookup remote x 50",
- (backend) => async () => {
- var tld = Math.random().toString(16) + ".example.com";
- const run = () => dns.lookup(tld, { backend }).catch(() => {});
- const total = 50;
- var remain = total;
- var done;
- await new Promise((resolve) => {
- for (var i = 0; i < total; i++)
- run().finally(() => {
- remain--;
- if (remain === 0) {
- done();
- }
- });
- done = resolve;
- });
- },
-);
+forEachBackend("(cached in batch) dns.lookup remote x 50", backend => async () => {
+ var tld = Math.random().toString(16) + ".example.com";
+ const run = () => dns.lookup(tld, { backend }).catch(() => {});
+ const total = 50;
+ var remain = total;
+ var done;
+ await new Promise(resolve => {
+ for (var i = 0; i < total; i++)
+ run().finally(() => {
+ remain--;
+ if (remain === 0) {
+ done();
+ }
+ });
+ done = resolve;
+ });
+});
await run();
diff --git a/bench/snippets/escapeHTML.js b/bench/snippets/escapeHTML.js
index f186b1d2f..19570b9f6 100644
--- a/bench/snippets/escapeHTML.js
+++ b/bench/snippets/escapeHTML.js
@@ -8,7 +8,7 @@ var bunEscapeHTML = globalThis.escapeHTML || Bun.escapeHTML;
const FIXTURE = require("fs")
.readFileSync(import.meta.dir + "/_fixture.txt", "utf8")
.split("")
- .map((a) => {
+ .map(a => {
if (a.charCodeAt(0) > 127) {
return "a";
}
@@ -16,10 +16,7 @@ const FIXTURE = require("fs")
})
.join("");
-const FIXTURE_WITH_UNICODE = require("fs").readFileSync(
- import.meta.dir + "/_fixture.txt",
- "utf8"
-);
+const FIXTURE_WITH_UNICODE = require("fs").readFileSync(import.meta.dir + "/_fixture.txt", "utf8");
// from react-dom:
const matchHtmlRegExp = /["'&<>]/;
@@ -116,7 +113,7 @@ for (let input of [
// bench(`html-entities.encode`, () => htmlEntityEncode(input));
// bench(`he.escape`, () => heEscape(input));
bench(`Bun.escapeHTML`, () => bunEscapeHTML(input));
- }
+ },
);
}
await run();
diff --git a/bench/snippets/ffi-overhead.mjs b/bench/snippets/ffi-overhead.mjs
index dcceef7ba..382300ac6 100644
--- a/bench/snippets/ffi-overhead.mjs
+++ b/bench/snippets/ffi-overhead.mjs
@@ -1,13 +1,4 @@
-import {
- viewSource,
- dlopen,
- CString,
- ptr,
- toBuffer,
- toArrayBuffer,
- FFIType,
- callback,
-} from "bun:ffi";
+import { viewSource, dlopen, CString, ptr, toBuffer, toArrayBuffer, FFIType, callback } from "bun:ffi";
import { bench, group, run } from "mitata";
const types = {
@@ -235,9 +226,7 @@ var opened;
try {
opened = dlopen("/tmp/bun-ffi-test.dylib", types);
} catch (e) {
- throw new Error(
- "Please run `make compile-ffi-test` to compile the ffi test library"
- );
+ throw new Error("Please run `make compile-ffi-test` to compile the ffi test library");
}
const {
@@ -403,10 +392,10 @@ group("returns_true", () => {
group("return_a_function_ptr_to_function_that_returns_true", () => {
bench("return_a_function_ptr_to_function_that_returns_true (raw)", () =>
- raw_return_a_function_ptr_to_function_that_returns_true()
+ raw_return_a_function_ptr_to_function_that_returns_true(),
);
bench("return_a_function_ptr_to_function_that_returns_true", () =>
- return_a_function_ptr_to_function_that_returns_true()
+ return_a_function_ptr_to_function_that_returns_true(),
);
});
group("returns_42_float", () => {
@@ -427,8 +416,7 @@ group("identity_double", () => {
});
var raw_return_a_function_ptr_to_function_that_returns_true =
- return_a_function_ptr_to_function_that_returns_true.native ??
- return_a_function_ptr_to_function_that_returns_true;
+ return_a_function_ptr_to_function_that_returns_true.native ?? return_a_function_ptr_to_function_that_returns_true;
var raw_returns_42_float = returns_42_float.native ?? returns_42_float;
var raw_returns_42_double = returns_42_double.native ?? returns_42_double;
var raw_identity_float = identity_float.native ?? identity_float;
@@ -437,14 +425,11 @@ var raw_returns_true = returns_true.native ?? returns_true;
var raw_returns_false = returns_false.native ?? returns_false;
var raw_returns_42_char = returns_42_char.native ?? returns_42_char;
var raw_returns_42_uint8_t = returns_42_uint8_t.native ?? returns_42_uint8_t;
-var raw_returns_neg_42_int8_t =
- returns_neg_42_int8_t.native ?? returns_neg_42_int8_t;
+var raw_returns_neg_42_int8_t = returns_neg_42_int8_t.native ?? returns_neg_42_int8_t;
var raw_returns_42_uint16_t = returns_42_uint16_t.native ?? returns_42_uint16_t;
var raw_returns_42_uint32_t = returns_42_uint32_t.native ?? returns_42_uint32_t;
-var raw_returns_neg_42_int16_t =
- returns_neg_42_int16_t.native ?? returns_neg_42_int16_t;
-var raw_returns_neg_42_int32_t =
- returns_neg_42_int32_t.native ?? returns_neg_42_int32_t;
+var raw_returns_neg_42_int16_t = returns_neg_42_int16_t.native ?? returns_neg_42_int16_t;
+var raw_returns_neg_42_int32_t = returns_neg_42_int32_t.native ?? returns_neg_42_int32_t;
var raw_identity_char = identity_char.native ?? identity_char;
var raw_identity_bool = identity_bool.native ?? identity_bool;
var raw_identity_bool = identity_bool.native ?? identity_bool;
diff --git a/bench/snippets/index-of.mjs b/bench/snippets/index-of.mjs
index a7aad7a1e..8f501454d 100644
--- a/bench/snippets/index-of.mjs
+++ b/bench/snippets/index-of.mjs
@@ -2,7 +2,7 @@ import { bench, run } from "mitata";
const input =
"Hello, World! foo bar baz qux quux corge grault garply waldo fred plugh xyzzy thud z a b c d e f g h i j k l m n o p q r s t u v w x y z".split(
- " "
+ " ",
);
bench(`Array.indexOf`, () => {
diff --git a/bench/snippets/package.json b/bench/snippets/package.json
index b66157182..6244001a8 100644
--- a/bench/snippets/package.json
+++ b/bench/snippets/package.json
@@ -2,5 +2,6 @@
"dependencies": {
"eventemitter3": "^5.0.0",
"tiny-typed-emitter": "latest"
- }
+ },
+ "prettier": "../../.prettierrc.cjs"
}
diff --git a/bench/snippets/react-dom-render.bun.js b/bench/snippets/react-dom-render.bun.js
index f23848ad8..7b53210e2 100644
--- a/bench/snippets/react-dom-render.bun.js
+++ b/bench/snippets/react-dom-render.bun.js
@@ -5,64 +5,30 @@ import { renderToReadableStream as renderToReadableStreamBun } from "../test/bun
const App = () => (
<div>
<h1>Hello, world!</h1>
- <p>
- This is a React component This is a React component This is a React
- component This is a React component.
- </p>
- <p>
- This is a React component This is a React component This is a React
- component This is a React component.
- </p>
- <p>
- This is a React component This is a React component This is a React
- component This is a React component.
- </p>
- <p>
- This is a React component This is a React component This is a React
- component This is a React component.
- </p>
- <p>
- This is a React component This is a React component This is a React
- component This is a React component.
- </p>
+ <p>This is a React component This is a React component This is a React component This is a React component.</p>
+ <p>This is a React component This is a React component This is a React component This is a React component.</p>
+ <p>This is a React component This is a React component This is a React component This is a React component.</p>
+ <p>This is a React component This is a React component This is a React component This is a React component.</p>
+ <p>This is a React component This is a React component This is a React component This is a React component.</p>
</div>
);
group("new Response(stream).text()", () => {
- bench(
- "react-dom/server.browser",
- async () => await new Response(await renderToReadableStream(<App />)).text()
- );
- bench(
- "react-dom/server.bun",
- async () =>
- await new Response(await renderToReadableStreamBun(<App />)).text()
- );
+ bench("react-dom/server.browser", async () => await new Response(await renderToReadableStream(<App />)).text());
+ bench("react-dom/server.bun", async () => await new Response(await renderToReadableStreamBun(<App />)).text());
});
group("new Response(stream).arrayBuffer()", () => {
bench(
"react-dom/server.browser",
- async () =>
- await new Response(await renderToReadableStream(<App />)).arrayBuffer()
- );
- bench(
- "react-dom/server.bun",
- async () =>
- await new Response(await renderToReadableStreamBun(<App />)).arrayBuffer()
+ async () => await new Response(await renderToReadableStream(<App />)).arrayBuffer(),
);
+ bench("react-dom/server.bun", async () => await new Response(await renderToReadableStreamBun(<App />)).arrayBuffer());
});
group("new Response(stream).blob()", () => {
- bench(
- "react-dom/server.browser",
- async () => await new Response(await renderToReadableStream(<App />)).blob()
- );
- bench(
- "react-dom/server.bun",
- async () =>
- await new Response(await renderToReadableStreamBun(<App />)).blob()
- );
+ bench("react-dom/server.browser", async () => await new Response(await renderToReadableStream(<App />)).blob());
+ bench("react-dom/server.bun", async () => await new Response(await renderToReadableStreamBun(<App />)).blob());
});
await run();
diff --git a/bench/snippets/return-await.mjs b/bench/snippets/return-await.mjs
index 1df17a22d..079eb4bdd 100644
--- a/bench/snippets/return-await.mjs
+++ b/bench/snippets/return-await.mjs
@@ -12,5 +12,4 @@ bench("return await 1", async function () {
return await 1;
});
-
await run();
diff --git a/bench/snippets/transpiler.mjs b/bench/snippets/transpiler.mjs
index 2facfeab7..ab4b29dc5 100644
--- a/bench/snippets/transpiler.mjs
+++ b/bench/snippets/transpiler.mjs
@@ -8,11 +8,7 @@ const esbuild_ = require("esbuild/lib/main");
const swc_ = require("@swc/core");
const babel_ = require("@babel/core");
-const code = readFileSync(
- dirname(fileURLToPath(import.meta.url)) +
- "/../../src/test/fixtures/simple.jsx",
- "utf-8",
-);
+const code = readFileSync(dirname(fileURLToPath(import.meta.url)) + "/../../src/test/fixtures/simple.jsx", "utf-8");
async function getWithName(name) {
let transformSync;
diff --git a/bench/websocket-server/chat-client.mjs b/bench/websocket-server/chat-client.mjs
index 786ebde1c..510c08836 100644
--- a/bench/websocket-server/chat-client.mjs
+++ b/bench/websocket-server/chat-client.mjs
@@ -1,9 +1,4 @@
-const env =
- "process" in globalThis
- ? process.env
- : "Deno" in globalThis
- ? Deno.env.toObject()
- : {};
+const env = "process" in globalThis ? process.env : "Deno" in globalThis ? Deno.env.toObject() : {};
const SERVER = env.SERVER || "ws://0.0.0.0:4001";
const WebSocket = globalThis.WebSocket || (await import("ws")).WebSocket;
@@ -105,10 +100,10 @@ for (let i = 0; i < CLIENTS_TO_WAIT_FOR; i++) {
clients[i] = new WebSocket(`${SERVER}?name=${NAMES[i]}`);
promises.push(
new Promise((resolve, reject) => {
- clients[i].onmessage = (event) => {
+ clients[i].onmessage = event => {
resolve();
};
- })
+ }),
);
}
@@ -121,7 +116,7 @@ var more = false;
var remaining;
for (let i = 0; i < CLIENTS_TO_WAIT_FOR; i++) {
- clients[i].onmessage = (event) => {
+ clients[i].onmessage = event => {
if (LOG_MESSAGES) console.log(event.data);
received++;
remaining--;
@@ -160,7 +155,7 @@ setInterval(() => {
received = 0;
console.log(
last,
- `messages per second (${CLIENTS_TO_WAIT_FOR} clients x ${MESSAGES_TO_SEND.length} msg, min delay: ${DELAY}ms)`
+ `messages per second (${CLIENTS_TO_WAIT_FOR} clients x ${MESSAGES_TO_SEND.length} msg, min delay: ${DELAY}ms)`,
);
if (runs.length >= 10) {
diff --git a/bench/websocket-server/chat-server.bun.js b/bench/websocket-server/chat-server.bun.js
index b015dec7e..b4c71a6dc 100644
--- a/bench/websocket-server/chat-server.bun.js
+++ b/bench/websocket-server/chat-server.bun.js
@@ -38,9 +38,7 @@ const server = Bun.serve({
if (
server.upgrade(req, {
data: {
- name:
- new URL(req.url).searchParams.get("name") ||
- "Client #" + (CLIENTS_TO_WAIT_FOR - remainingClients),
+ name: new URL(req.url).searchParams.get("name") || "Client #" + (CLIENTS_TO_WAIT_FOR - remainingClients),
},
})
)
@@ -50,7 +48,4 @@ const server = Bun.serve({
},
});
-console.log(
- `Waiting for ${remainingClients} clients to connect...\n`,
- ` http://${server.hostname}:${port}/`
-);
+console.log(`Waiting for ${remainingClients} clients to connect...\n`, ` http://${server.hostname}:${port}/`);
diff --git a/bench/websocket-server/chat-server.deno.mjs b/bench/websocket-server/chat-server.deno.mjs
index 3cea9cf2f..5b2130bf2 100644
--- a/bench/websocket-server/chat-server.deno.mjs
+++ b/bench/websocket-server/chat-server.deno.mjs
@@ -1,7 +1,6 @@
// See ./README.md for instructions on how to run this benchmark.
const port = Deno.env.get("PORT") || 4001;
-const CLIENTS_TO_WAIT_FOR =
- parseInt(Deno.env.get("CLIENTS_COUNT") || "", 10) || 16;
+const CLIENTS_TO_WAIT_FOR = parseInt(Deno.env.get("CLIENTS_COUNT") || "", 10) || 16;
var clients = [];
async function reqHandler(req) {
@@ -13,11 +12,9 @@ async function reqHandler(req) {
clients.push(client);
const name = new URL(req.url).searchParams.get("name");
- console.log(
- `${name} connected (${CLIENTS_TO_WAIT_FOR - clients.length} remain)`
- );
+ console.log(`${name} connected (${CLIENTS_TO_WAIT_FOR - clients.length} remain)`);
- client.onmessage = (event) => {
+ client.onmessage = event => {
const msg = `${name}: ${event.data}`;
for (let client of clients) {
client.send(msg);
diff --git a/bench/websocket-server/chat-server.node.mjs b/bench/websocket-server/chat-server.node.mjs
index e57b9b982..5b74e5fbd 100644
--- a/bench/websocket-server/chat-server.node.mjs
+++ b/bench/websocket-server/chat-server.node.mjs
@@ -16,12 +16,8 @@ var WebSocketServer = require("ws").Server,
var clients = [];
wss.on("connection", function (ws, { url }) {
- const name = new URL(new URL(url, "http://localhost:3000")).searchParams.get(
- "name"
- );
- console.log(
- `${name} connected (${CLIENTS_TO_WAIT_FOR - clients.length} remain)`
- );
+ const name = new URL(new URL(url, "http://localhost:3000")).searchParams.get("name");
+ console.log(`${name} connected (${CLIENTS_TO_WAIT_FOR - clients.length} remain)`);
clients.push(ws);
ws.on("message", function (message) {
diff --git a/docs/api/file-io.md b/docs/api/file-io.md
index 18bd5ad3a..4c432300e 100644
--- a/docs/api/file-io.md
+++ b/docs/api/file-io.md
@@ -8,7 +8,7 @@ Bun provides a set of optimized APIs for reading and writing files.
`Bun.file(path): BunFile`
-Create a `BunFile` instance with the `Bun.file(path)` function. A `BunFile` represents represents a lazily-loaded file; initializing it does not actually read the file from disk.
+Create a `BunFile` instance with the `Bun.file(path)` function. A `BunFile` represents a lazily-loaded file; initializing it does not actually read the file from disk.
```ts
const foo = Bun.file("foo.txt"); // relative to cwd
@@ -45,7 +45,7 @@ The default MIME type is `text/plain;charset=utf-8`, but it can be overridden by
```ts
const notreal = Bun.file("notreal.json", { type: "application/json" });
-notreal.type; // => "text/plain;charset=utf-8"
+notreal.type; // => "application/json;charset=utf-8"
```
For convenience, Bun exposes `stdin`, `stdout` and `stderr` as instances of `BunFile`.
diff --git a/docs/api/sqlite.md b/docs/api/sqlite.md
index 67debe05b..89a6e27ef 100644
--- a/docs/api/sqlite.md
+++ b/docs/api/sqlite.md
@@ -211,7 +211,7 @@ Queries can contain parameters. These can be numerical (`?1`) or named (`$param`
```ts#Query
const query = db.query("SELECT * FROM foo WHERE bar = $bar");
-const results = await query.all({
+const results = query.all({
$bar: "bar",
});
```
@@ -230,7 +230,7 @@ Numbered (positional) parameters work too:
```ts#Query
const query = db.query("SELECT ?1, ?2");
-const results = await query.all("hello", "goodbye");
+const results = query.all("hello", "goodbye");
```
```ts#Results
diff --git a/docs/ecosystem/nodejs.md b/docs/ecosystem/nodejs.md
index 8a5532f3b..d74acc8ca 100644
--- a/docs/ecosystem/nodejs.md
+++ b/docs/ecosystem/nodejs.md
@@ -419,7 +419,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa
- {% anchor id="node_formdata" %} [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) {% /anchor %}
- 🟢
-- Fully implemented. Added in Bun 0.7.0.
+- Fully implemented. Added in Bun 0.5.7.
---
diff --git a/docs/ecosystem/react.md b/docs/ecosystem/react.md
index 1be0bcdbb..c0904421a 100644
--- a/docs/ecosystem/react.md
+++ b/docs/ecosystem/react.md
@@ -1,6 +1,6 @@
Bun supports `.jsx` and `.tsx` files out of the box. Bun's internal transpiler converts JSX syntax into vanilla JavaScript before execution.
-```ts#react.tsx
+```tsx#react.tsx
function Component(props: {message: string}) {
return (
<body>
@@ -19,6 +19,23 @@ $ bun run react.tsx
<Component message="Hello world!" />
```
+### Prop punning
+
+The Bun runtime also supports "prop punning for JSX. This is a shorthand syntax useful for assigning a variable to a prop with the same name.
+
+```tsx
+function Div(props: {className: string;}) {
+ const {className} = props;
+
+ // without punning
+ return <div className={className} />;
+ // with punning
+ return <div {className} />;
+
+}
+```
+
+### Server-side rendering
To server-side render (SSR) React in an [HTTP server](/docs/api/http):
```tsx#ssr.tsx
diff --git a/docs/nav.ts b/docs/nav.ts
index 149867506..c5ff4b426 100644
--- a/docs/nav.ts
+++ b/docs/nav.ts
@@ -15,30 +15,50 @@ type NavDivider = {
title: string;
};
-
-function page(slug: string, title: string, props?: {disabled?: boolean; href?: string}): NavPage {
+function page(slug: string, title: string, props: { disabled?: boolean; href?: string; description: string }): NavPage {
return { type: "page", slug, title, ...props };
}
function divider(title: string): NavDivider {
return { type: "divider", title };
}
-
export default {
items: [
divider("Intro"),
- page("index", "What is Bun?"),
- page("installation", "Installation"),
- page("quickstart", "Quickstart"),
+ page("index", "What is Bun?", {
+ description:
+ "Bun is an all-in-one runtime for JavaScript and TypeScript apps. Run, bundle, and test apps with one fast tool.",
+ }),
+ page("installation", "Installation", {
+ description: "Install Bun with npm, Homebrew, Docker, or the official install script.",
+ }),
+ page("quickstart", "Quickstart", {
+ description: "Get started with Bun by building and running a simple HTTP server in 5 lines of TypeScript.",
+ }),
// page("typescript", "TypeScript"),
divider("CLI"),
- page("cli/run", "`bun run`"),
- page("cli/install", "`bun install`"),
- page("cli/test", "`bun test`"),
- page("cli/create", "`bun create`"),
- page("cli/bunx", "`bunx`"),
- page("cli/deploy", "`bun deploy`", {disabled: true}),
+ page("cli/run", "`bun run`", {
+ description:
+ "Use `bun run` to execute JavaScript/TypeScript files, package.json scripts, and executable packages.",
+ }),
+ page("cli/install", "`bun install`", {
+ description: "A 100x faster npm client with workspaces, git dependencies, and private registry support.",
+ }),
+ page("cli/test", "`bun test`", {
+ description: "Bun's test runner uses Jest-compatible syntax but runs 100x faster.",
+ }),
+ page("cli/create", "`bun create`", {
+ description: "Scaffold a new Bun project from an official template or GitHub repo.",
+ }),
+ page("cli/bunx", "`bunx`", {
+ description:
+ "Use `bunx` to auto-install and run executable packages from npm, or use locally installed command-line tools.",
+ }),
+ page("cli/deploy", "`bun deploy`", {
+ disabled: true,
+ description: "Deploy your Bun app to the cloud (eventually)",
+ }),
// page("bundler", "Bundler"),
// page("cli/bun-install", "`bun install`"),
@@ -51,44 +71,100 @@ export default {
// page("benchmarks", "Benchmarks"),
divider("Runtime"),
- page("runtime/index", "Runtime"),
+ page("runtime/index", "Runtime", {
+ description: `Bun is a new JavaScript runtime designed to be a faster, leaner, more modern replacement for Node.js.`,
+ }),
// page("runtime/web-apis", "Web APIs"),
- page("runtime/modules", "Module resolution"),
- page("runtime/hot", "Hot reloading"),
+ page("runtime/modules", "Module resolution", {
+ description: `Bun uses ESM and implements an extended version of the Node.js module resolution algorithm.`,
+ }),
+ page("runtime/hot", "Hot reloading", {
+ description: `Reload a running application without restarting the Bun process.`,
+ }),
// page("runtime/loaders", "Loaders"),
- page("runtime/plugins", "Plugins"),
- page("runtime/framework", "Framework API", {disabled: true}),
+ page("runtime/plugins", "Plugins", {
+ description: `Implement custom loaders and module resolution logic with Bun's plugin system.`,
+ }),
+ page("runtime/framework", "Framework API", {
+ disabled: true,
+ description:
+ "Coming soon. Use the Framework API to build a fast, cloud-ready framework on top of Bun's bundler and runtime.",
+ }),
// page("runtime/nodejs", "Node.js APIs"),
divider("Ecosystem"),
- page("ecosystem/nodejs", "Node.js"),
- page("ecosystem/typescript", "TypeScript"),
- page("ecosystem/react", "React"),
- page("ecosystem/elysia", "Elysia"),
- page("ecosystem/hono", "Hono"),
- page("ecosystem/express", "Express"),
+ page("ecosystem/nodejs", "Node.js", {
+ description: `Track the status of Bun's API compatibility with Node.js.`,
+ }),
+ page("ecosystem/typescript", "TypeScript", {
+ description: `Bun can directly execute TypeScript files without additional configuration.`,
+ }),
+ page("ecosystem/react", "React", {
+ description: `The Bun runtime supports JSX syntax out of the box and optimizes server-side rendering.`,
+ }),
+ page("ecosystem/elysia", "Elysia", {
+ description: `Get started with Elysia, a Bun-native framework designed for the edge.`,
+ }),
+ page("ecosystem/hono", "Hono", {
+ description: `Hono is an ultra-fast, Bun-friendly web framework designed for edge environments.`,
+ }),
+ page("ecosystem/express", "Express", {
+ description: `Servers built with Express and other major Node.js HTTP libraries work out of the box.`,
+ }),
page("ecosystem/awesome", "Awesome", {
- href:"https://github.com/apvarun/awesome-bun"
+ href: "https://github.com/apvarun/awesome-bun",
+ description: ``,
}),
divider("API"),
- page("api/http", "HTTP"), // "`Bun.serve`"),
- page("api/websockets", "WebSockets"), // "`Bun.serve`"),
- page("api/tcp", "TCP Sockets"), // "`Bun.{listen|connect}`"),
- page("api/file-io", "File I/O"), // "`Bun.write`"),
- page("api/sqlite", "SQLite"), // "`bun:sqlite`"),
- page("api/file-system-router", "FileSystemRouter"), // "`Bun.FileSystemRouter`"),
- page("api/globals", "Globals"), // "`Bun.write`"),
- page("api/spawn", "Spawn"), // "`Bun.spawn`"),
- page("api/transpiler", "Transpiler"), // "`Bun.Transpiler`"),
- page("api/console", "Console"), // "`Node-API`"),
- page("api/ffi", "FFI"), // "`bun:ffi`"),
- page("api/html-rewriter", "HTMLRewriter"), // "`HTMLRewriter`"),
- page("api/test", "Testing"), // "`bun:test`"),
- page("api/utils", "Utils"), // "`Bun.peek`"),
- page("api/dns", "DNS"), // "`bun:dns`"),
- page("api/node-api", "Node-API"), // "`Node-API`"),
-
+ page("api/http", "HTTP", {
+ description: `Bun implements Web-standard fetch, plus a Bun-native API for building fast HTTP servers.`,
+ }), // "`Bun.serve`"),
+ page("api/websockets", "WebSockets", {
+ description: `Bun supports server-side WebSockets with on-the-fly compression, TLS support, and a Bun-native pubsub API.`,
+ }), // "`Bun.serve`"),
+ page("api/tcp", "TCP Sockets", {
+ description: `Bun's native API implements Web-standard TCP Sockets, plus a Bun-native API for building fast TCP servers.`,
+ }), // "`Bun.{listen|connect}`"),
+ page("api/file-io", "File I/O", {
+ description: `Read and write files fast with Bun's heavily optimized file system API.`,
+ }), // "`Bun.write`"),
+ page("api/sqlite", "SQLite", {
+ description: `The fastest SQLite driver for JavaScript is baked directly into Bun.`,
+ }), // "`bun:sqlite`"),
+ page("api/file-system-router", "FileSystemRouter", {
+ description: `Resolve incoming HTTP requests against a local file system directory with Bun's fast, Next.js-compatible router.`,
+ }), // "`Bun.FileSystemRouter`"),
+ page("api/globals", "Globals", {
+ description: `Bun implements a range of Web APIs, Node.js APIs, and Bun-native APIs that are available in the global scope.`,
+ }), // "`Bun.write`"),
+ page("api/spawn", "Spawn", {
+ description: `Spawn sync and async child processes with easily configurable input and output streams.`,
+ }), // "`Bun.spawn`"),
+ page("api/transpiler", "Transpiler", {
+ description: `Bun exposes its internal transpiler as a pluggable API.`,
+ }), // "`Bun.Transpiler`"),
+ page("api/console", "Console", {
+ description: `Bun implements a Node.js-compatible \`console\` object with colorized output and deep pretty-printing.`,
+ }), // "`Node-API`"),
+ page("api/ffi", "FFI", {
+ description: `Call native code from JavaScript with Bun's foreign function interface (FFI) API.`,
+ }), // "`bun:ffi`"),
+ page("api/html-rewriter", "HTMLRewriter", {
+ description: `Parse and transform HTML with Bun's native HTMLRewriter API, inspired by Cloudflare Workers.`,
+ }), // "`HTMLRewriter`"),
+ page("api/test", "Testing", {
+ description: `Bun's built-in test runner is fast and uses Jest-compatible syntax.`,
+ }), // "`bun:test`"),
+ page("api/utils", "Utils", {
+ description: `Bun implements a set of utilities that are commonly required by developers.`,
+ }), // "`Bun.peek`"),
+ page("api/dns", "DNS", {
+ description: `Resolve domain names to IP addresses.`,
+ }), // "`bun:dns`"),
+ page("api/node-api", "Node-API", {
+ description: `Bun implements the Node-API spec for building native addons.`,
+ }), // "`Node-API`"),
// divider("Dev Server"),
// page("bun-dev", "Vanilla"),
@@ -98,11 +174,21 @@ export default {
// page("dev/cra", "Create React App"),
divider("Project"),
- page("project/roadmap", "Roadmap"),
- page("project/configuration", "Configuration"),
- page("project/profiling", "Profiling"),
- page("project/developing", "Development"),
- page("project/licensing", "License"),
+ page("project/roadmap", "Roadmap", {
+ description: `Track Bun's near-term and long-term goals.`,
+ }),
+ page("project/configuration", "Configuration", {
+ description: `Bun's runtime is configurable with environment variables and the bunfig.toml config file.`,
+ }),
+ page("project/profiling", "Profiling", {
+ description: `Bun is designed for performance. Learn how to benchmark and profile Bun yourself.`,
+ }),
+ page("project/developing", "Development", {
+ description: "Learn how to contribute to Bun and get your local development environment up and running.",
+ }),
+ page("project/licensing", "License", {
+ description: `Bun is a MIT-licensed project with a large number of statically-linked dependencies with various licenses.`,
+ }),
// misc
// page("roadmap", "Roadmap"),
diff --git a/examples/html-rewriter.ts b/examples/html-rewriter.ts
index 877b957b7..3017350e7 100644
--- a/examples/html-rewriter.ts
+++ b/examples/html-rewriter.ts
@@ -3,29 +3,18 @@
Bun.serve({
async fetch(req) {
const { pathname } = new URL(req.url);
- if (
- !(pathname.startsWith("/https://") || pathname.startsWith("/http://"))
- ) {
- return new Response(
- "Enter a path that starts with https:// or http://\n",
- {
- status: 400,
- },
- );
+ if (!(pathname.startsWith("/https://") || pathname.startsWith("/http://"))) {
+ return new Response("Enter a path that starts with https:// or http://\n", {
+ status: 400,
+ });
}
- const response = await fetch(
- req.url.substring("http://localhost:3000/".length),
- req.clone(),
- );
+ const response = await fetch(req.url.substring("http://localhost:3000/".length), req.clone());
return new HTMLRewriter()
.on("a[href]", {
element(element) {
- element.setAttribute(
- "href",
- "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
- );
+ element.setAttribute("href", "https://www.youtube.com/watch?v=dQw4w9WgXcQ");
},
})
.transform(response);
diff --git a/examples/lambda.ts b/examples/lambda.ts
index da1a7d9ee..66746ecad 100644
--- a/examples/lambda.ts
+++ b/examples/lambda.ts
@@ -38,21 +38,17 @@ try {
} catch (e: any) {
console.error("Error loading sourcefile:", e);
try {
- await fetch(
- new URL(`http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/init/error`)
- .href,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- errorMessage: e.message,
- errorType: e.name,
- stackTrace: e?.stack?.split("\n") ?? [],
- }),
+ await fetch(new URL(`http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/init/error`).href, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
},
- );
+ body: JSON.stringify({
+ errorMessage: e.message,
+ errorType: e.name,
+ stackTrace: e?.stack?.split("\n") ?? [],
+ }),
+ });
} catch (e2) {
console.error("Error sending error to runtime:", e2);
}
@@ -79,21 +75,17 @@ export default {
console.error(e);
try {
- await fetch(
- new URL(`http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/init/error`)
- .href,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- errorMessage: e.message,
- errorType: e.name,
- stackTrace: e?.stack?.split("\n") ?? [],
- }),
+ await fetch(new URL(`http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/init/error`).href, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
},
- );
+ body: JSON.stringify({
+ errorMessage: e.message,
+ errorType: e.name,
+ stackTrace: e?.stack?.split("\n") ?? [],
+ }),
+ });
} catch (e2) {
console.error("Error sending error to runtime:", e2);
}
@@ -112,21 +104,17 @@ try {
} catch (e: any) {
console.error("Error parsing baseURI:", e);
try {
- await fetch(
- new URL(`http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/init/error`)
- .href,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- errorMessage: e.message,
- errorType: e.name,
- stackTrace: e?.stack?.split("\n") || [],
- }),
+ await fetch(new URL(`http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/init/error`).href, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
},
- );
+ body: JSON.stringify({
+ errorMessage: e.message,
+ errorType: e.name,
+ stackTrace: e?.stack?.split("\n") || [],
+ }),
+ });
} catch (e2) {
console.error("Error sending error to runtime:", e2);
}
@@ -140,10 +128,7 @@ async function runHandler(response: Response) {
var request = new Request(baseURL.href, {
method,
headers: response.headers,
- body:
- parseInt(response.headers.get("Content-Length") || "0", 10) > 0
- ? await response.blob()
- : undefined,
+ body: parseInt(response.headers.get("Content-Length") || "0", 10) > 0 ? await response.blob() : undefined,
});
// we are done with the Response object here
// allow it to be GC'd
@@ -162,18 +147,15 @@ async function runHandler(response: Response) {
if (typeof process.env.VERBOSE !== "undefined") {
console.error(`[${traceID}] Error running handler:`, e1);
}
- fetch(
- `http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/${requestID}/error`,
- {
- method: "POST",
-
- body: JSON.stringify({
- errorMessage: e1.message,
- errorType: e1.name,
- stackTrace: e1?.stack?.split("\n") ?? [],
- }),
- },
- ).finally(noop);
+ fetch(`http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/${requestID}/error`, {
+ method: "POST",
+
+ body: JSON.stringify({
+ errorMessage: e1.message,
+ errorType: e1.name,
+ stackTrace: e1?.stack?.split("\n") ?? [],
+ }),
+ }).finally(noop);
return;
} finally {
if (typeof process.env.VERBOSE !== "undefined") {
@@ -182,28 +164,22 @@ async function runHandler(response: Response) {
}
if (!result || !("headers" in result)) {
- await fetch(
- `http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/${requestID}/error`,
- {
- method: "POST",
- body: JSON.stringify({
- errorMessage: "Expected Response object",
- errorType: "ExpectedResponseObject",
- stackTrace: [],
- }),
- },
- );
+ await fetch(`http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/${requestID}/error`, {
+ method: "POST",
+ body: JSON.stringify({
+ errorMessage: "Expected Response object",
+ errorType: "ExpectedResponseObject",
+ stackTrace: [],
+ }),
+ });
return;
}
- await fetch(
- `http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/${requestID}/response`,
- {
- method: "POST",
- headers: result.headers,
- body: await result.blob(),
- },
- );
+ await fetch(`http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/${requestID}/response`, {
+ method: "POST",
+ headers: result.headers,
+ body: await result.blob(),
+ });
(result as any) = undefined;
}
diff --git a/examples/macros/components/covid19.tsx b/examples/macros/components/covid19.tsx
index 330661c82..16877b5ce 100644
--- a/examples/macros/components/covid19.tsx
+++ b/examples/macros/components/covid19.tsx
@@ -1,13 +1,10 @@
import { fetchCSV } from "macro:fetchCSV";
export const Covid19 = () => {
- const rows = fetchCSV(
- "https://covid19.who.int/WHO-COVID-19-global-data.csv",
- {
- last: 100,
- columns: ["New_cases", "Date_reported", "Country"],
- },
- );
+ const rows = fetchCSV("https://covid19.who.int/WHO-COVID-19-global-data.csv", {
+ last: 100,
+ columns: ["New_cases", "Date_reported", "Country"],
+ });
return (
<div>
diff --git a/examples/macros/components/example.jsx b/examples/macros/components/example.jsx
index 84d2d92e9..6f2760b76 100644
--- a/examples/macros/components/example.jsx
+++ b/examples/macros/components/example.jsx
@@ -5,13 +5,11 @@ export const IPAddresses = () => (
<div>
<h2>recent ip addresses</h2>
<div className="Lines">
- {matchInFile("access.log", /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}/).map(
- (ipAddress, index) => (
- <div className="Line" key={index}>
- {ipAddress}
- </div>
- ),
- )}
+ {matchInFile("access.log", /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}/).map((ipAddress, index) => (
+ <div className="Line" key={index}>
+ {ipAddress}
+ </div>
+ ))}
</div>
</div>
);
diff --git a/examples/macros/fetchCSV.tsx b/examples/macros/fetchCSV.tsx
index b06b1e03e..55a12bc42 100644
--- a/examples/macros/fetchCSV.tsx
+++ b/examples/macros/fetchCSV.tsx
@@ -36,12 +36,12 @@ export async function fetchCSV(callExpression) {
rows = rows
.slice(Math.max(limit, rows.length) - limit)
.reverse()
- .filter((columns) => columns.every(Boolean));
+ .filter(columns => columns.every(Boolean));
const value = (
<array>
- {rows.map((columns) => (
+ {rows.map(columns => (
<array>
- {columnIndices.map((columnIndex) => (
+ {columnIndices.map(columnIndex => (
<string value={columns[columnIndex]} />
))}
</array>
diff --git a/examples/macros/matchInFile.tsx b/examples/macros/matchInFile.tsx
index bd1c92dea..e434d1dec 100644
--- a/examples/macros/matchInFile.tsx
+++ b/examples/macros/matchInFile.tsx
@@ -12,10 +12,10 @@ export function matchInFile(callExpression: BunAST.CallExpression) {
<array>
{file
.split("\n")
- .map((line) => line.match(matcher))
+ .map(line => line.match(matcher))
.filter(Boolean)
.reverse()
- .map((line) => (
+ .map(line => (
<string value={line[0]} />
))}
</array>
diff --git a/examples/macros/mystery-box.ts b/examples/macros/mystery-box.ts
index 6583c9868..c686f82c3 100644
--- a/examples/macros/mystery-box.ts
+++ b/examples/macros/mystery-box.ts
@@ -6,10 +6,7 @@ export function mysteryBox(callExpression) {
const count: number = parseInt(countString, 10);
// validate
- if (!(count >= 1 && count <= 1000))
- return new Error(
- `Argument ${countString} is expected to be between 1 and 1000`,
- );
+ if (!(count >= 1 && count <= 1000)) return new Error(`Argument ${countString} is expected to be between 1 and 1000`);
// return a value
return (Math.random() * count) | 0;
diff --git a/examples/openInEditor.js b/examples/openInEditor.js
index 59282c098..3c67f02c2 100644
--- a/examples/openInEditor.js
+++ b/examples/openInEditor.js
@@ -3,8 +3,7 @@ import { parse } from "querystring";
export default {
fetch(req) {
- if (req.url === "/favicon.ico")
- return new Response("nooo dont open favicon in editor", { status: 404 });
+ if (req.url === "/favicon.ico") return new Response("nooo dont open favicon in editor", { status: 404 });
var pathname = req.url.substring(1);
const q = pathname.indexOf("?");
diff --git a/examples/react-fast-refresh-test/src/main.tsx b/examples/react-fast-refresh-test/src/main.tsx
index 1a9948fe8..928d64b72 100644
--- a/examples/react-fast-refresh-test/src/main.tsx
+++ b/examples/react-fast-refresh-test/src/main.tsx
@@ -6,8 +6,7 @@ export const Main = ({ productName }) => {
<header>
<div className="Title">CSS HMR Stress Test</div>
<p className="Description">
- This page visually tests how quickly a bundler can update CSS over Hot
- Module Reloading.
+ This page visually tests how quickly a bundler can update CSS over Hot Module Reloading.
</p>
</header>
<main className="main">
@@ -21,9 +20,7 @@ export const Main = ({ productName }) => {
<div className="ProgressBar-container">
<div className="ProgressBar"></div>
</div>
- <div className="SectionLabel">
- The progress bar should move from left to right smoothly.
- </div>
+ <div className="SectionLabel">The progress bar should move from left to right smoothly.</div>
</section>
<section>
@@ -44,15 +41,11 @@ export const Main = ({ productName }) => {
<div className="Spinner"></div>
</div>
</div>
- <div className="SectionLabel">
- The spinners should rotate &amp; change color smoothly.
- </div>
+ <div className="SectionLabel">The spinners should rotate &amp; change color smoothly.</div>
</section>
</main>
<footer>
- <div className="SectionLabel FooterLabel">
- There are no CSS animations on this page.
- </div>
+ <div className="SectionLabel FooterLabel">There are no CSS animations on this page.</div>
<div className="Bundler-container">
<div className="Bundler">{productName}</div>
diff --git a/examples/react-file-system-router/index.tsx b/examples/react-file-system-router/index.tsx
index a784c393b..62d1151d5 100644
--- a/examples/react-file-system-router/index.tsx
+++ b/examples/react-file-system-router/index.tsx
@@ -1,24 +1,20 @@
// 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'
+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"
- })
+ style: "nextjs",
+ });
- const route = router.match(request)
+ const route = router.match(request);
- const { default: Root } = await import(route.filePath)
- return new Response(
- await renderToReadableStream(
- <Root {...route.params} />
- )
- )
- }
-} \ No newline at end of file
+ const { default: Root } = await import(route.filePath);
+ return new Response(await renderToReadableStream(<Root {...route.params} />));
+ },
+};
diff --git a/examples/react-file-system-router/pages/index.tsx b/examples/react-file-system-router/pages/index.tsx
index b2d9e735e..f1fe2a2e1 100644
--- a/examples/react-file-system-router/pages/index.tsx
+++ b/examples/react-file-system-router/pages/index.tsx
@@ -7,11 +7,11 @@ export default () => (
</head>
<body>
<h1>
- <a href="/one" >one</a>
+ <a href="/one">one</a>
</h1>
<h1>
- <a href="/two" >two</a>
+ <a href="/two">two</a>
</h1>
</body>
</html>
-) \ No newline at end of file
+);
diff --git a/examples/react-file-system-router/pages/one.tsx b/examples/react-file-system-router/pages/one.tsx
index 68c9fb4b9..b65a32f6c 100644
--- a/examples/react-file-system-router/pages/one.tsx
+++ b/examples/react-file-system-router/pages/one.tsx
@@ -9,4 +9,4 @@ export default () => (
<p>one</p>
</body>
</html>
-) \ No newline at end of file
+);
diff --git a/examples/react-file-system-router/pages/two.tsx b/examples/react-file-system-router/pages/two.tsx
index 09be9fa5c..c3d8beef9 100644
--- a/examples/react-file-system-router/pages/two.tsx
+++ b/examples/react-file-system-router/pages/two.tsx
@@ -9,4 +9,4 @@ export default () => (
<p>two</p>
</body>
</html>
-) \ No newline at end of file
+);
diff --git a/examples/sha.js b/examples/sha.js
index 0155aecc4..bb7382a03 100644
--- a/examples/sha.js
+++ b/examples/sha.js
@@ -1,20 +1,9 @@
-import {
- SHA1,
- SHA256,
- SHA512,
- SHA384,
- SHA512_256,
- MD5,
- MD4,
- RIPEMD160,
- sha,
-} from "bun";
+import { SHA1, SHA256, SHA512, SHA384, SHA512_256, MD5, MD4, RIPEMD160, sha } from "bun";
const input = "Hello World";
const [first, second] = input.split(" ");
-const log = (name, ...args) =>
- console.log(`${name}:`.padStart("SHA512_256: ".length), ...args);
+const log = (name, ...args) => console.log(`${name}:`.padStart("SHA512_256: ".length), ...args);
console.log("");
// This is SHA512-256:
diff --git a/examples/spawn.ts b/examples/spawn.ts
index d72a118b9..520fa60ff 100644
--- a/examples/spawn.ts
+++ b/examples/spawn.ts
@@ -7,9 +7,7 @@ const repo = process.argv.at(3) || "TheoBr/vercel-vite-demo";
const target = basename(repo) + "-main";
console.log("Downloading", repo, "to", "/tmp/" + target);
-const archive = await fetch(
- `https://github.com/${repo}/archive/refs/heads/main.tar.gz`,
-);
+const archive = await fetch(`https://github.com/${repo}/archive/refs/heads/main.tar.gz`);
// remove the directory if it already exists locally
rmSync("/tmp/" + target, { recursive: true, force: true });
diff --git a/misctools/gen-unicode-table.js b/misctools/gen-unicode-table.js
index ad38a0ec5..1696a4b9e 100644
--- a/misctools/gen-unicode-table.js
+++ b/misctools/gen-unicode-table.js
@@ -58,18 +58,12 @@ const idContinueESNext = require("@unicode/unicode-13.0.0/Binary_Property/ID_Con
const idContinueESNextSet = new Set(idContinueESNext);
// These identifiers are valid in both ES5 and ES6+ (i.e. an intersection of both)
-const idStartES5AndESNext = idStartES5.filter((n) => idStartESNextSet.has(n));
-const idContinueES5AndESNext = idContinueES5.filter((n) =>
- idContinueESNextSet.has(n),
-);
+const idStartES5AndESNext = idStartES5.filter(n => idStartESNextSet.has(n));
+const idContinueES5AndESNext = idContinueES5.filter(n => idContinueESNextSet.has(n));
// These identifiers are valid in either ES5 or ES6+ (i.e. a union of both)
-const idStartES5OrESNext = [...new Set(idStartES5.concat(idStartESNext))].sort(
- (a, b) => a - b,
-);
-const idContinueES5OrESNext = [
- ...new Set(idContinueES5.concat(idContinueESNext)),
-].sort((a, b) => a - b);
+const idStartES5OrESNext = [...new Set(idStartES5.concat(idStartESNext))].sort((a, b) => a - b);
+const idContinueES5OrESNext = [...new Set(idContinueES5.concat(idContinueESNext))].sort((a, b) => a - b);
function generateRangeTable(codePoints) {
let lines = [];
@@ -86,11 +80,7 @@ function generateRangeTable(codePoints) {
while (index < codePoints.length && codePoints[index] < 0x1000) {
let start = codePoints[index];
index++;
- while (
- index < codePoints.length &&
- codePoints[index] < 0x1000 &&
- codePoints[index] === codePoints[index - 1] + 1
- ) {
+ while (index < codePoints.length && codePoints[index] < 0x1000 && codePoints[index] === codePoints[index - 1] + 1) {
index++;
}
let end = codePoints[index - 1];
@@ -103,10 +93,7 @@ function generateRangeTable(codePoints) {
while (index < codePoints.length) {
let start = codePoints[index];
index++;
- while (
- index < codePoints.length &&
- codePoints[index] === codePoints[index - 1] + 1
- ) {
+ while (index < codePoints.length && codePoints[index] === codePoints[index - 1] + 1) {
index++;
}
let end = codePoints[index - 1];
@@ -132,11 +119,7 @@ function generateBigSwitchStatement(codePoints) {
while (index < codePoints.length && codePoints[index] < 0x1000) {
let start = codePoints[index];
index++;
- while (
- index < codePoints.length &&
- codePoints[index] < 0x1000 &&
- codePoints[index] === codePoints[index - 1] + 1
- ) {
+ while (index < codePoints.length && codePoints[index] < 0x1000 && codePoints[index] === codePoints[index - 1] + 1) {
index++;
}
let end = codePoints[index - 1];
@@ -147,10 +130,7 @@ function generateBigSwitchStatement(codePoints) {
while (index < codePoints.length) {
let start = codePoints[index];
index++;
- while (
- index < codePoints.length &&
- codePoints[index] === codePoints[index - 1] + 1
- ) {
+ while (index < codePoints.length && codePoints[index] === codePoints[index - 1] + 1) {
index++;
}
let end = codePoints[index - 1];
@@ -165,9 +145,7 @@ function generateBigSwitchStatement(codePoints) {
fs.writeFileSync(
path.join(__dirname, "..", "src", "js_lexer", "unicode.zig"),
- `// This file was automatically generated by ${path.basename(
- __filename,
- )}. Do not edit.
+ `// This file was automatically generated by ${path.basename(__filename)}. Do not edit.
const RangeTable = @import("./range_table.zig");
diff --git a/misctools/headers-cleaner.js b/misctools/headers-cleaner.js
index 0f003cc5c..9c74e1ba3 100644
--- a/misctools/headers-cleaner.js
+++ b/misctools/headers-cleaner.js
@@ -3,10 +3,7 @@ var { readFileSync, writeFileSync } = require("fs");
var { join } = require("path");
const destination = join(__dirname, "../src/bun.js/bindings/headers.zig");
-const replacements = join(
- __dirname,
- "../src/bun.js/bindings/headers-replacements.zig",
-);
+const replacements = join(__dirname, "../src/bun.js/bindings/headers-replacements.zig");
console.log("Writing to", destination);
var output = "// GENERATED CODE - DO NOT MODIFY BY HAND\n\n";
@@ -16,16 +13,9 @@ const first_extern = input.indexOf("extern fn");
const first_extern_line = input.indexOf("\n", first_extern - 128);
const last_extern_fn = input.lastIndexOf("extern");
const last_extern_fn_line = input.indexOf("\n", last_extern_fn);
-const keep = (
- input.substring(0, first_extern_line) + input.substring(last_extern_fn_line)
-)
+const keep = (input.substring(0, first_extern_line) + input.substring(last_extern_fn_line))
.split("\n")
- .filter(
- (a) =>
- /const (JSC|WTF|Web)_/gi.test(a) &&
- !a.includes("JSValue") &&
- !a.includes("CatchScope"),
- )
+ .filter(a => /const (JSC|WTF|Web)_/gi.test(a) && !a.includes("JSValue") && !a.includes("CatchScope"))
.join("\n")
.trim();
@@ -34,21 +24,12 @@ input = input.replaceAll("*WebCore__", "*bindings.");
input = input.replaceAll("*JSC__", "*bindings.");
input = input.replaceAll("[*c] JSC__", "[*c]bindings.");
input = input.replaceAll("[*c]JSC__", "[*c]bindings.");
-input = input.replaceAll(
- "[*c]bindings.JSGlobalObject",
- "*bindings.JSGlobalObject",
-);
+input = input.replaceAll("[*c]bindings.JSGlobalObject", "*bindings.JSGlobalObject");
input = input.replaceAll("[*c]bindings.JSPromise", "?*bindings.JSPromise");
-input = input.replaceAll(
- "[*c]const bindings.JSPromise",
- "?*const bindings.JSPromise",
-);
+input = input.replaceAll("[*c]const bindings.JSPromise", "?*const bindings.JSPromise");
input = input.replaceAll("[*c] const JSC__", "[*c]const bindings.");
-input = input.replaceAll(
- "[*c]Inspector__ScriptArguments",
- "[*c]bindings.ScriptArguments",
-);
+input = input.replaceAll("[*c]Inspector__ScriptArguments", "[*c]bindings.ScriptArguments");
input = input
.replaceAll("VirtualMachine", "bindings.VirtualMachine")
@@ -104,14 +85,6 @@ for (let i = 0; i < lines.length; i++) {
continue;
}
}
-input = lines.filter((a) => a.length > 0).join("\n");
+input = lines.filter(a => a.length > 0).join("\n");
-writeFileSync(
- destination,
- output +
- "\n" +
- readFileSync(replacements, "utf8").trim() +
- "\n" +
- input.trim() +
- "\n",
-);
+writeFileSync(destination, output + "\n" + readFileSync(replacements, "utf8").trim() + "\n" + input.trim() + "\n");
diff --git a/misctools/mime.js b/misctools/mime.js
index 6f46a711f..27b58a5b7 100644
--- a/misctools/mime.js
+++ b/misctools/mime.js
@@ -1,17 +1,6 @@
-const json = await (
- await fetch("https://raw.githubusercontent.com/jshttp/mime-db/master/db.json")
-).json();
-
-json["application/javascript"].extensions.push(
- `ts`,
- `tsx`,
- `mts`,
- `mtsx`,
- `cts`,
- `cjs`,
- `mjs`,
- `js`,
-);
+const json = await (await fetch("https://raw.githubusercontent.com/jshttp/mime-db/master/db.json")).json();
+
+json["application/javascript"].extensions.push(`ts`, `tsx`, `mts`, `mtsx`, `cts`, `cjs`, `mjs`, `js`);
delete json["application/node"];
delete json["application/deno"];
@@ -28,11 +17,11 @@ for (let key of Object.keys(json).sort()) {
const withExtensions = [
...new Set([
...Object.keys(json)
- .filter((key) => {
+ .filter(key => {
return !!json[key]?.extensions?.length;
})
- .flatMap((mime) => {
- return [...new Set([...json[mime].extensions])].map((ext) => {
+ .flatMap(mime => {
+ return [...new Set([...json[mime].extensions])].map(ext => {
return [`.{.@"${ext}", all.@"${mime}"}`];
});
})
diff --git a/misctools/publish-examples.js b/misctools/publish-examples.js
index 4124d0785..dcbb0d3eb 100644
--- a/misctools/publish-examples.js
+++ b/misctools/publish-examples.js
@@ -14,10 +14,7 @@ const DRY_RUN = !!process.env.DRY_RUN;
var count = 0;
-const examplesFolderEntries = fs.readdirSync(
- path.join(process.cwd(), "examples"),
- { withFileTypes: true },
-);
+const examplesFolderEntries = fs.readdirSync(path.join(process.cwd(), "examples"), { withFileTypes: true });
const packageNames = [];
@@ -28,10 +25,7 @@ for (let folder of examplesFolderEntries) {
let packageJSONText;
try {
- packageJSONText = fs.readFileSync(
- path.join(absolute, "package.json"),
- "utf8",
- );
+ packageJSONText = fs.readFileSync(path.join(absolute, "package.json"), "utf8");
} catch {
continue;
}
@@ -43,9 +37,7 @@ for (let folder of examplesFolderEntries) {
var version = "0.0.1";
try {
- const _versions = exec(`npm view ${packageJSON.name} versions --json`)
- .toString()
- .trim();
+ const _versions = exec(`npm view ${packageJSON.name} versions --json`).toString().trim();
if (_versions.length > 0) {
const versionsArray = JSON.parse(_versions);
@@ -70,10 +62,7 @@ for (let folder of examplesFolderEntries) {
} catch (exception) {}
try {
- fs.copyFileSync(
- path.join(absolute, ".gitignore"),
- path.join(absolute, "gitignore"),
- );
+ fs.copyFileSync(path.join(absolute, ".gitignore"), path.join(absolute, "gitignore"));
} catch (exception) {}
restart: while (retryCount-- > 0) {
@@ -85,18 +74,13 @@ for (let folder of examplesFolderEntries) {
delete packageJSON.main;
}
- fs.writeFileSync(
- path.join(absolute, "package.json"),
- JSON.stringify(packageJSON, null, 2),
- );
+ fs.writeFileSync(path.join(absolute, "package.json"), JSON.stringify(packageJSON, null, 2));
try {
exec(`npm version patch --force --no-commit-hooks --no-git-tag-version`, {
cwd: absolute,
});
- packageJSON = JSON.parse(
- fs.readFileSync(path.join(absolute, "package.json"), "utf8"),
- );
+ packageJSON = JSON.parse(fs.readFileSync(path.join(absolute, "package.json"), "utf8"));
version = packageJSON.version;
} catch (e) {
if (e.code !== "E404") {
@@ -105,12 +89,9 @@ for (let folder of examplesFolderEntries) {
}
try {
- exec(
- `npm publish ${
- DRY_RUN ? "--dry-run" : ""
- } --access public --registry https://registry.npmjs.org/`,
- { cwd: absolute },
- );
+ exec(`npm publish ${DRY_RUN ? "--dry-run" : ""} --access public --registry https://registry.npmjs.org/`, {
+ cwd: absolute,
+ });
packageNames.push([
packageJSON.name,
{
@@ -147,16 +128,10 @@ if (packageNames.length > 0) {
recursive: true,
});
} catch (exception) {}
- fs.writeFileSync(
- path.join(dir, "package.json"),
- JSON.stringify(packageJSON, null, 2),
- );
- exec(
- `npm publish ${
- DRY_RUN ? "--dry-run" : ""
- } --access public --registry https://registry.npmjs.org/`,
- { cwd: dir },
- );
+ fs.writeFileSync(path.join(dir, "package.json"), JSON.stringify(packageJSON, null, 2));
+ exec(`npm publish ${DRY_RUN ? "--dry-run" : ""} --access public --registry https://registry.npmjs.org/`, {
+ cwd: dir,
+ });
}
console.log(`Published ${count} packages`);
diff --git a/package.json b/package.json
index b8eadefe1..37d02bca0 100644
--- a/package.json
+++ b/package.json
@@ -15,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}' --config .prettierrc",
+ "fmt": "prettier --write './test/**/*.{mjs,ts,tsx,js,jsx}' './src/*.{mjs,ts,tsx,js,jsx}' './src/*/*.{mjs,ts,tsx,js,jsx}' './src/*/*/*.{mjs,ts,tsx,js,jsx}' './bench/*.{mjs,ts,tsx,js,jsx}' --config .prettierrc.cjs",
"lint": "eslint './**/*.d.ts' --cache",
"lint:fix": "eslint './**/*.d.ts' --cache --fix"
},
@@ -25,5 +25,6 @@
"@typescript-eslint/parser": "^5.31.0",
"bun-webkit": "0.0.1-595dd33692e02001631f6c3ab6f2bbb199278d26"
},
- "version": "0.0.0"
+ "version": "0.0.0",
+ "prettier": "./.prettierrc.cjs"
}
diff --git a/packages/bun-test/src/runner.ts b/packages/bun-test/src/runner.ts
index 256d0c87f..f3add7385 100644
--- a/packages/bun-test/src/runner.ts
+++ b/packages/bun-test/src/runner.ts
@@ -22,9 +22,13 @@ async function runTest(path: string): Promise<void> {
const name = path.replace(cwd, "").slice(1);
const runner = await spawn({
cwd,
- cmd: ["bun", "wiptest", path],
+ cmd: ["bun", "test", path],
stdout: "pipe",
stderr: "pipe",
+ env: {
+ ...process.env,
+ FORCE_COLOR: "1",
+ }
});
const exitCode = await Promise.race([
new Promise((resolve) => {
diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts
index 965a66c82..abcf36f0e 100644
--- a/packages/bun-types/bun.d.ts
+++ b/packages/bun-types/bun.d.ts
@@ -395,7 +395,9 @@ declare module "bun" {
stream?: boolean;
}): void;
- write(chunk: string | ArrayBufferView | ArrayBuffer): number;
+ write(
+ chunk: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
+ ): number;
/**
* Flush the internal buffer
*
@@ -534,7 +536,9 @@ declare module "bun" {
*
* If the file descriptor is not writable yet, the data is buffered.
*/
- write(chunk: string | ArrayBufferView | ArrayBuffer): number;
+ write(
+ chunk: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
+ ): number;
/**
* Flush the internal buffer, committing the data to disk or the pipe.
*/
@@ -650,38 +654,38 @@ declare module "bun" {
* @param seed The seed to use.
*/
export const hash: ((
- data: string | ArrayBufferView | ArrayBuffer,
+ data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
seed?: number,
) => number | bigint) &
Hash;
interface Hash {
wyhash: (
- data: string | ArrayBufferView | ArrayBuffer,
+ data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
seed?: number,
) => number | bigint;
crc32: (
- data: string | ArrayBufferView | ArrayBuffer,
+ data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
seed?: number,
) => number | bigint;
adler32: (
- data: string | ArrayBufferView | ArrayBuffer,
+ data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
seed?: number,
) => number | bigint;
cityHash32: (
- data: string | ArrayBufferView | ArrayBuffer,
+ data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
seed?: number,
) => number | bigint;
cityHash64: (
- data: string | ArrayBufferView | ArrayBuffer,
+ data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
seed?: number,
) => number | bigint;
murmur32v3: (
- data: string | ArrayBufferView | ArrayBuffer,
+ data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
seed?: number,
) => number | bigint;
murmur64v2: (
- data: string | ArrayBufferView | ArrayBuffer,
+ data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
seed?: number,
) => number | bigint;
}
@@ -989,7 +993,7 @@ declare module "bun" {
*
*/
send(
- data: string | ArrayBufferView | ArrayBuffer,
+ data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
compress?: boolean,
): ServerWebSocketSendStatus;
@@ -1101,7 +1105,7 @@ declare module "bun" {
*/
publish(
topic: string,
- data: string | ArrayBufferView | ArrayBuffer,
+ data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
compress?: boolean,
): ServerWebSocketSendStatus;
@@ -1739,7 +1743,7 @@ declare module "bun" {
*/
publish(
topic: string,
- data: string | ArrayBufferView | ArrayBuffer,
+ data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
compress?: boolean,
): ServerWebSocketSendStatus;
@@ -1944,7 +1948,7 @@ declare module "bun" {
* @param level
* @returns The previous level
*/
- gcAggressionLevel(level: 0 | 1 | 2): 0 | 1 | 2;
+ gcAggressionLevel(level?: 0 | 1 | 2): 0 | 1 | 2;
}
export const unsafe: unsafe;
@@ -2474,7 +2478,7 @@ declare module "bun" {
/**
* The source code of the module
*/
- contents: string | ArrayBufferView | ArrayBuffer;
+ contents: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer;
/**
* The loader to use for this file
*
@@ -3353,7 +3357,7 @@ type TimeLike = string | number | Date;
type StringOrBuffer = string | TypedArray | ArrayBufferLike;
type PathLike = string | TypedArray | ArrayBufferLike | URL;
type PathOrFileDescriptor = PathLike | number;
-type NoParamCallback = VoidFunction;
+type NoParamCallback = (err: ErrnoException | null) => void;
type BufferEncoding =
| "buffer"
| "utf8"
diff --git a/packages/bun-types/bun.lockb b/packages/bun-types/bun.lockb
index b95880249..e764f6a0c 100755
--- a/packages/bun-types/bun.lockb
+++ b/packages/bun-types/bun.lockb
Binary files differ
diff --git a/packages/bun-types/ffi.d.ts b/packages/bun-types/ffi.d.ts
index 19337fab1..3e7e91534 100644
--- a/packages/bun-types/ffi.d.ts
+++ b/packages/bun-types/ffi.d.ts
@@ -345,6 +345,74 @@ declare module "bun:ffi" {
*/
u64_fast = 16,
}
+
+ type UNTYPED = never;
+ export type Pointer = number & {};
+
+ interface FFITypeToType {
+ [FFIType.char]: number;
+ [FFIType.int8_t]: number;
+ [FFIType.i8]: number;
+ [FFIType.uint8_t]: number;
+ [FFIType.u8]: number;
+ [FFIType.int16_t]: number;
+ [FFIType.i16]: number;
+ [FFIType.uint16_t]: number;
+ [FFIType.u16]: number;
+ [FFIType.int32_t]: number;
+ [FFIType.i32]: number;
+ [FFIType.int]: number;
+ [FFIType.uint32_t]: number;
+ [FFIType.u32]: number;
+ [FFIType.int64_t]: UNTYPED;
+ [FFIType.i64]: UNTYPED;
+ [FFIType.uint64_t]: UNTYPED;
+ [FFIType.u64]: UNTYPED;
+ [FFIType.double]: UNTYPED;
+ [FFIType.f64]: UNTYPED;
+ [FFIType.float]: UNTYPED;
+ [FFIType.f32]: UNTYPED;
+ [FFIType.bool]: boolean;
+ [FFIType.ptr]: Pointer;
+ [FFIType.pointer]: Pointer;
+ [FFIType.void]: UNTYPED;
+ [FFIType.cstring]: CString;
+ [FFIType.i64_fast]: number | bigint;
+ [FFIType.u64_fast]: number | bigint;
+ }
+ interface FFITypeStringToType {
+ ["char"]: FFIType.char;
+ ["int8_t"]: FFIType.int8_t;
+ ["i8"]: FFIType.i8;
+ ["uint8_t"]: FFIType.uint8_t;
+ ["u8"]: FFIType.u8;
+ ["int16_t"]: FFIType.int16_t;
+ ["i16"]: FFIType.i16;
+ ["uint16_t"]: FFIType.uint16_t;
+ ["u16"]: FFIType.u16;
+ ["int32_t"]: FFIType.int32_t;
+ ["i32"]: FFIType.i32;
+ ["int"]: FFIType.int;
+ ["uint32_t"]: FFIType.uint32_t;
+ ["u32"]: FFIType.u32;
+ ["int64_t"]: FFIType.int64_t;
+ ["i64"]: FFIType.i64;
+ ["uint64_t"]: FFIType.uint64_t;
+ ["u64"]: FFIType.u64;
+ ["double"]: FFIType.double;
+ ["f64"]: FFIType.f64;
+ ["float"]: FFIType.float;
+ ["f32"]: FFIType.f32;
+ ["bool"]: FFIType.bool;
+ ["ptr"]: FFIType.ptr;
+ ["pointer"]: FFIType.pointer;
+ ["void"]: FFIType.void;
+ ["cstring"]: FFIType.cstring;
+ ["function"]: FFIType.pointer; // for now
+ ["usize"]: FFIType.uint64_t; // for now
+ ["callback"]: FFIType.pointer; // for now
+ }
+
export type FFITypeOrString =
| FFIType
| "char"
@@ -388,12 +456,16 @@ declare module "bun:ffi" {
*
* @example
* From JavaScript:
- * ```js
- * const lib = dlopen('add', {
- * // FFIType can be used or you can pass string labels.
- * args: [FFIType.i32, "i32"],
- * returns: "i32",
- * });
+ * ```ts
+ * import { dlopen, FFIType, suffix } from "bun:ffi"
+ *
+ * const lib = dlopen(`adder.${suffix}`, {
+ * add: {
+ * // FFIType can be used or you can pass string labels.
+ * args: [FFIType.i32, "i32"],
+ * returns: "i32",
+ * },
+ * })
* lib.symbols.add(1, 2)
* ```
* In C:
@@ -413,7 +485,9 @@ declare module "bun:ffi" {
*
* @example
* From JavaScript:
- * ```js
+ * ```ts
+ * import { dlopen, CString } from "bun:ffi"
+ *
* const lib = dlopen('z', {
* version: {
* returns: "ptr",
@@ -470,16 +544,8 @@ declare module "bun:ffi" {
// */
// export function callback(ffi: FFIFunction, cb: Function): number;
- export interface Library {
- symbols: Record<
- string,
- CallableFunction & {
- /**
- * The function without a wrapper
- */
- native: CallableFunction;
- }
- >;
+ export interface Library<Fns extends Record<string, Narrow<FFIFunction>>> {
+ symbols: ConvertFns<Fns>;
/**
* `dlclose` the library, unloading the symbols and freeing allocated memory.
@@ -491,6 +557,32 @@ declare module "bun:ffi" {
close(): void;
}
+ type ToFFIType<T extends FFITypeOrString> = T extends FFIType
+ ? T
+ : T extends string
+ ? FFITypeStringToType[T]
+ : never;
+
+ type _Narrow<T, U> = [U] extends [T] ? U : Extract<T, U>;
+ type Narrow<T = unknown> =
+ | _Narrow<T, 0 | (number & {})>
+ | _Narrow<T, 0n | (bigint & {})>
+ | _Narrow<T, "" | (string & {})>
+ | _Narrow<T, boolean>
+ | _Narrow<T, symbol>
+ | _Narrow<T, []>
+ | _Narrow<T, { [_: PropertyKey]: Narrow }>
+ | (T extends object ? { [K in keyof T]: Narrow<T[K]> } : never)
+ | Extract<{} | null | undefined, T>;
+
+ type ConvertFns<Fns extends Record<string, FFIFunction>> = {
+ [K in keyof Fns]: (
+ ...args: Fns[K]["args"] extends infer A extends FFITypeOrString[]
+ ? { [L in keyof A]: FFITypeToType[ToFFIType<A[L]>] }
+ : never
+ ) => FFITypeToType[ToFFIType<NonNullable<Fns[K]["returns"]>>];
+ };
+
/**
* Open a library using `"bun:ffi"`
*
@@ -518,7 +610,10 @@ declare module "bun:ffi" {
* goes to Fabrice Bellard and TinyCC maintainers for making this possible.
*
*/
- export function dlopen(name: string, symbols: Symbols): Library;
+ export function dlopen<Fns extends Record<string, Narrow<FFIFunction>>>(
+ name: string,
+ symbols: Fns,
+ ): Library<Fns>;
/**
* Turn a native library's function pointer into a JavaScript function
@@ -548,7 +643,7 @@ declare module "bun:ffi" {
*
*/
export function CFunction(
- fn: FFIFunction & { ptr: number | bigint },
+ fn: FFIFunction & { ptr: Pointer },
): CallableFunction & {
/**
* Free the memory allocated by the wrapping function
@@ -608,7 +703,9 @@ declare module "bun:ffi" {
* goes to Fabrice Bellard and TinyCC maintainers for making this possible.
*
*/
- export function linkSymbols(symbols: Symbols): Library;
+ export function linkSymbols<Fns extends Record<string, Narrow<FFIFunction>>>(
+ symbols: Fns,
+ ): Library<Fns>;
/**
* Read a pointer as a {@link Buffer}
@@ -626,7 +723,7 @@ declare module "bun:ffi" {
*
*/
export function toBuffer(
- ptr: number,
+ ptr: Pointer,
byteOffset?: number,
byteLength?: number,
): Buffer;
@@ -646,7 +743,7 @@ declare module "bun:ffi" {
* undefined behavior. Use with care!
*/
export function toArrayBuffer(
- ptr: number,
+ ptr: Pointer,
byteOffset?: number,
byteLength?: number,
): ArrayBuffer;
@@ -681,7 +778,7 @@ declare module "bun:ffi" {
export function ptr(
view: TypedArray | ArrayBufferLike | DataView,
byteOffset?: number,
- ): number;
+ ): Pointer;
/**
* Get a string from a UTF-8 encoded C string
@@ -734,7 +831,7 @@ declare module "bun:ffi" {
* reading beyond the bounds of the pointer will crash the program or cause
* undefined behavior. Use with care!
*/
- constructor(ptr: number, byteOffset?: number, byteLength?: number);
+ constructor(ptr: Pointer, byteOffset?: number, byteLength?: number);
/**
* The ptr to the C string
@@ -743,7 +840,7 @@ declare module "bun:ffi" {
* is safe to continue using this instance after the `ptr` has been
* freed.
*/
- ptr: number;
+ ptr: Pointer;
byteOffset?: number;
byteLength?: number;
@@ -772,7 +869,7 @@ declare module "bun:ffi" {
*
* Becomes `null` once {@link JSCallback.prototype.close} is called
*/
- readonly ptr: number | null;
+ readonly ptr: Pointer | null;
/**
* Can the callback be called from a different thread?
diff --git a/packages/bun-types/fs.d.ts b/packages/bun-types/fs.d.ts
index 7e34d5873..14c5c1d1d 100644
--- a/packages/bun-types/fs.d.ts
+++ b/packages/bun-types/fs.d.ts
@@ -20,10 +20,11 @@
declare module "fs" {
import * as stream from "stream";
import type { SystemError, ArrayBufferView } from "bun";
-
interface ObjectEncodingOptions {
encoding?: BufferEncoding | null | undefined;
}
+
+ const promises: Awaited<typeof import("fs/promises")>;
type EncodingOption =
| ObjectEncodingOptions
| BufferEncoding
@@ -1517,6 +1518,7 @@ declare module "fs" {
* See the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details.
* @since v0.0.67
*/
+
function mkdirSync(
path: PathLike,
options: MakeDirectoryOptions & {
@@ -3930,6 +3932,5 @@ declare module "fs" {
}
declare module "node:fs" {
- import * as fs from "fs";
- export = fs;
+ export * from "fs";
}
diff --git a/packages/bun-types/fs/promises.d.ts b/packages/bun-types/fs/promises.d.ts
index 164ef8db9..997896b01 100644
--- a/packages/bun-types/fs/promises.d.ts
+++ b/packages/bun-types/fs/promises.d.ts
@@ -9,7 +9,7 @@
*/
declare module "fs/promises" {
import { ArrayBufferView } from "bun";
- import {
+ import type {
Stats,
BigIntStats,
StatOptions,
@@ -25,6 +25,7 @@ declare module "fs/promises" {
SimlinkType,
Abortable,
RmOptions,
+ RmDirOptions,
} from "node:fs";
interface FlagAndOpenMode {
@@ -677,9 +678,39 @@ declare module "fs/promises" {
* @since v14.14.0
*/
export function rm(path: PathLike, options?: RmOptions): Promise<void>;
+
+ /**
+ * Asynchronously test whether or not the given path exists by checking with the file system.
+ *
+ * ```ts
+ * import { exists } from 'fs/promises';
+ *
+ * const e = await exists('/etc/passwd');
+ * e; // boolean
+ * ```
+ */
+ function exists(path: PathLike): Promise<boolean>;
+
+ /**
+ * @deprecated Use `fs.promises.rm()` instead.
+ *
+ * Asynchronously remove a directory.
+ *
+ * ```ts
+ * import { rmdir } from 'fs/promises';
+ *
+ * // remove a directory
+ * await rmdir('/tmp/mydir'); // Promise<void>
+ * ```
+ *
+ * To remove a directory recursively, use `fs.promises.rm()` instead, with the `recursive` option set to `true`.
+ */
+ function rmdir(
+ path: PathLike,
+ options?: Omit<RmDirOptions, "recursive">,
+ ): Promise<void>;
}
declare module "node:fs/promises" {
- import * as fsPromises from "fs/promises";
- export = fsPromises;
+ export * from "fs/promises";
}
diff --git a/packages/bun-types/globals.d.ts b/packages/bun-types/globals.d.ts
index 3e677b458..72c8495dc 100644
--- a/packages/bun-types/globals.d.ts
+++ b/packages/bun-types/globals.d.ts
@@ -842,7 +842,7 @@ interface RequestInit {
/**
* A string indicating how the request will interact with the browser's cache to set request's cache.
*
- * Note: as of Bun v0.0.74, this is not implemented yet.
+ * Note: as of Bun v0.5.7, this is not implemented yet.
*/
cache?: RequestCache;
/**
@@ -856,7 +856,7 @@ interface RequestInit {
/**
* A cryptographic hash of the resource to be fetched by request. Sets request's integrity.
*
- * Note: as of Bun v0.0.74, this is not implemented yet.
+ * Note: as of Bun v0.5.7, this is not implemented yet.
*/
integrity?: string;
/**
@@ -889,8 +889,6 @@ interface RequestInit {
referrerPolicy?: ReferrerPolicy;
/**
* An AbortSignal to set request's signal.
- *
- * Note: as of Bun v0.0.74, this is not implemented yet.
*/
signal?: AbortSignal | null;
/**
diff --git a/packages/bun-types/package.json b/packages/bun-types/package.json
index ada826752..2dbf1839d 100644
--- a/packages/bun-types/package.json
+++ b/packages/bun-types/package.json
@@ -10,8 +10,9 @@
"fmt": "prettier --write './**/*.{ts,tsx,js,jsx}'"
},
"devDependencies": {
- "tsd": "^0.22.0",
- "prettier": "^2.4.1"
+ "conditional-type-checks": "^1.0.6",
+ "prettier": "^2.4.1",
+ "tsd": "^0.22.0"
},
"tsd": {
"directory": "tests"
diff --git a/packages/bun-types/tests/ffi.test-d.ts b/packages/bun-types/tests/ffi.test-d.ts
new file mode 100644
index 000000000..105736134
--- /dev/null
+++ b/packages/bun-types/tests/ffi.test-d.ts
@@ -0,0 +1,96 @@
+import { dlopen, FFIType, suffix, CString, Pointer } from "bun:ffi";
+import * as tsd from "tsd";
+import * as tc from "conditional-type-checks";
+
+// `suffix` is either "dylib", "so", or "dll" depending on the platform
+// you don't have to use "suffix", it's just there for convenience
+const path = `libsqlite3.${suffix}`;
+
+const lib = dlopen(
+ path, // a library name or file path
+ {
+ sqlite3_libversion: {
+ // no arguments, returns a string
+ args: [],
+ returns: FFIType.cstring,
+ },
+ add: {
+ args: [FFIType.i32, FFIType.i32],
+ returns: FFIType.i32,
+ },
+ allArgs: {
+ args: [
+ FFIType.char, // string
+ FFIType.int8_t,
+ FFIType.i8,
+ FFIType.uint8_t,
+ FFIType.u8,
+ FFIType.int16_t,
+ FFIType.i16,
+ FFIType.uint16_t,
+ FFIType.u16,
+ FFIType.int32_t,
+ FFIType.i32,
+ FFIType.int,
+ FFIType.uint32_t,
+ FFIType.u32,
+ FFIType.int64_t,
+ FFIType.i64,
+ FFIType.uint64_t,
+ FFIType.u64,
+ FFIType.double,
+ FFIType.f64,
+ FFIType.float,
+ FFIType.f32,
+ FFIType.bool,
+ FFIType.ptr,
+ FFIType.pointer,
+ FFIType.void,
+ FFIType.cstring,
+ FFIType.i64_fast,
+ FFIType.u64_fast,
+ ],
+ returns: FFIType.void,
+ },
+ },
+);
+
+tsd.expectType<CString>(lib.symbols.sqlite3_libversion());
+tsd.expectType<number>(lib.symbols.add(1, 2));
+
+tc.assert<
+ tc.IsExact<
+ typeof lib["symbols"]["allArgs"],
+ [
+ number,
+ number,
+ number,
+ number,
+ number,
+ number,
+ number,
+ number,
+ number,
+ number,
+ number,
+ number,
+ number,
+ number,
+ never,
+ never,
+ never,
+ never,
+ never,
+ never,
+ never,
+ never,
+ boolean,
+ Pointer,
+ Pointer,
+ never,
+ CString,
+ number | bigint,
+ number | bigint,
+ ]
+ >
+>;
diff --git a/packages/bun-types/tests/fs.test-d.ts b/packages/bun-types/tests/fs.test-d.ts
new file mode 100644
index 000000000..1ef14a2f8
--- /dev/null
+++ b/packages/bun-types/tests/fs.test-d.ts
@@ -0,0 +1,6 @@
+import * as tsd from "tsd";
+import * as fs from "fs";
+import { exists } from "fs/promises";
+
+tsd.expectType<Promise<boolean>>(exists("/etc/passwd"));
+tsd.expectType<Promise<boolean>>(fs.promises.exists("/etc/passwd"));
diff --git a/src/api/demo/lib/api.ts b/src/api/demo/lib/api.ts
index d06bfd35b..88dd71001 100644
--- a/src/api/demo/lib/api.ts
+++ b/src/api/demo/lib/api.ts
@@ -13,9 +13,7 @@ export interface WebAssemblyModule {
}
const wasm_imports_sym: symbol | string =
- process.env.NODE_ENV === "development"
- ? "wasm_imports"
- : Symbol("wasm_imports");
+ process.env.NODE_ENV === "development" ? "wasm_imports" : Symbol("wasm_imports");
const ptr_converter = new ArrayBuffer(16);
const ptr_float = new BigUint64Array(ptr_converter);
@@ -150,10 +148,10 @@ export class Bun {
return;
}
- Bun.wasm_source = await globalThis.WebAssembly.instantiateStreaming(
- fetch(url),
- { env: Bun[wasm_imports_sym], wasi_snapshot_preview1: Wasi },
- );
+ Bun.wasm_source = await globalThis.WebAssembly.instantiateStreaming(fetch(url), {
+ env: Bun[wasm_imports_sym],
+ wasi_snapshot_preview1: Wasi,
+ });
const res = Bun.wasm_exports.init();
if (res < 0) {
@@ -225,11 +223,7 @@ export class Bun {
return response;
}
- static scan(
- content: Uint8Array | string,
- file_name: string,
- loader?: Loader,
- ) {
+ static scan(content: Uint8Array | string, file_name: string, loader?: Loader) {
if (!Bun.has_initialized) {
throw "Please run await Bun.init(wasm_url) before using this.";
}
diff --git a/src/api/demo/pages/index.tsx b/src/api/demo/pages/index.tsx
index 24577acb3..1f6e4bb82 100644
--- a/src/api/demo/pages/index.tsx
+++ b/src/api/demo/pages/index.tsx
@@ -14,10 +14,7 @@ export async function getStaticProps(ctx) {
return {
props: {
// not tested
- code: readFile(
- "/Users/jarred/Build/es-module-lexer/test/samples/magic-string.js",
- { encoding: "utf-8" },
- ),
+ code: readFile("/Users/jarred/Build/es-module-lexer/test/samples/magic-string.js", { encoding: "utf-8" }),
},
};
}
@@ -33,11 +30,8 @@ export default function Home({ code }) {
}, []);
const runBuild = React.useCallback(
- (event) => {
- globalThis.Run.transform(
- event.target.value,
- fileNameRef?.current?.value,
- ).then((result) => {
+ event => {
+ globalThis.Run.transform(event.target.value, fileNameRef?.current?.value).then(result => {
setEsbuildResult(result.esbuild.code);
setBunResult(textDecoder.decode(result.bun.files[0].data));
setSWCResult(result.swc.code);
diff --git a/src/api/demo/pages/scan.tsx b/src/api/demo/pages/scan.tsx
index 87cebd64d..656629dda 100644
--- a/src/api/demo/pages/scan.tsx
+++ b/src/api/demo/pages/scan.tsx
@@ -13,10 +13,7 @@ export async function getStaticProps(ctx) {
return {
props: {
// not tested
- code: readFile(
- "/Users/jarred/Build/es-module-lexer/test/samples/magic-string.js",
- { encoding: "utf-8" },
- ),
+ code: readFile("/Users/jarred/Build/es-module-lexer/test/samples/magic-string.js", { encoding: "utf-8" }),
defaultFile: "magic-string.js",
},
};
@@ -33,11 +30,8 @@ export default function Home({ code, defaultFile }) {
}, []);
const runBuild = React.useCallback(
- (event) => {
- globalThis.Scan.transform(
- event.target.value,
- fileNameRef?.current?.value,
- ).then((result) => {
+ event => {
+ globalThis.Scan.transform(event.target.value, fileNameRef?.current?.value).then(result => {
setLexer(JSON.stringify(result.lexer, null, 2));
setBunResult(JSON.stringify(result.bun, null, 2));
}, console.error);
@@ -59,7 +53,7 @@ export default function Home({ code, defaultFile }) {
type="text"
placeholder="filename"
value={file}
- onChange={(event) => setFile(event.target.value)}
+ onChange={event => setFile(event.target.value)}
ref={fileNameRef}
/>
<textarea onChange={runBuild} defaultValue={code}></textarea>
diff --git a/src/api/demo/schema.d.ts b/src/api/demo/schema.d.ts
index ae4551128..6f3949c77 100644
--- a/src/api/demo/schema.d.ts
+++ b/src/api/demo/schema.d.ts
@@ -683,228 +683,90 @@ export interface BunInstall {
global_bin_dir?: string;
}
-export declare function encodeStackFrame(
- message: StackFrame,
- bb: ByteBuffer,
-): void;
+export declare function encodeStackFrame(message: StackFrame, bb: ByteBuffer): void;
export declare function decodeStackFrame(buffer: ByteBuffer): StackFrame;
-export declare function encodeStackFramePosition(
- message: StackFramePosition,
- bb: ByteBuffer,
-): void;
-export declare function decodeStackFramePosition(
- buffer: ByteBuffer,
-): StackFramePosition;
-export declare function encodeSourceLine(
- message: SourceLine,
- bb: ByteBuffer,
-): void;
+export declare function encodeStackFramePosition(message: StackFramePosition, bb: ByteBuffer): void;
+export declare function decodeStackFramePosition(buffer: ByteBuffer): StackFramePosition;
+export declare function encodeSourceLine(message: SourceLine, bb: ByteBuffer): void;
export declare function decodeSourceLine(buffer: ByteBuffer): SourceLine;
-export declare function encodeStackTrace(
- message: StackTrace,
- bb: ByteBuffer,
-): void;
+export declare function encodeStackTrace(message: StackTrace, bb: ByteBuffer): void;
export declare function decodeStackTrace(buffer: ByteBuffer): StackTrace;
-export declare function encodeJSException(
- message: JSException,
- bb: ByteBuffer,
-): void;
+export declare function encodeJSException(message: JSException, bb: ByteBuffer): void;
export declare function decodeJSException(buffer: ByteBuffer): JSException;
export declare function encodeProblems(message: Problems, bb: ByteBuffer): void;
export declare function decodeProblems(buffer: ByteBuffer): Problems;
export declare function encodeRouter(message: Router, bb: ByteBuffer): void;
export declare function decodeRouter(buffer: ByteBuffer): Router;
-export declare function encodeFallbackMessageContainer(
- message: FallbackMessageContainer,
- bb: ByteBuffer,
-): void;
-export declare function decodeFallbackMessageContainer(
- buffer: ByteBuffer,
-): FallbackMessageContainer;
+export declare function encodeFallbackMessageContainer(message: FallbackMessageContainer, bb: ByteBuffer): void;
+export declare function decodeFallbackMessageContainer(buffer: ByteBuffer): FallbackMessageContainer;
export declare function encodeJSX(message: JSX, bb: ByteBuffer): void;
export declare function decodeJSX(buffer: ByteBuffer): JSX;
-export declare function encodeStringPointer(
- message: StringPointer,
- bb: ByteBuffer,
-): void;
+export declare function encodeStringPointer(message: StringPointer, bb: ByteBuffer): void;
export declare function decodeStringPointer(buffer: ByteBuffer): StringPointer;
-export declare function encodeJavascriptBundledModule(
- message: JavascriptBundledModule,
- bb: ByteBuffer,
-): void;
-export declare function decodeJavascriptBundledModule(
- buffer: ByteBuffer,
-): JavascriptBundledModule;
-export declare function encodeJavascriptBundledPackage(
- message: JavascriptBundledPackage,
- bb: ByteBuffer,
-): void;
-export declare function decodeJavascriptBundledPackage(
- buffer: ByteBuffer,
-): JavascriptBundledPackage;
-export declare function encodeJavascriptBundle(
- message: JavascriptBundle,
- bb: ByteBuffer,
-): void;
-export declare function decodeJavascriptBundle(
- buffer: ByteBuffer,
-): JavascriptBundle;
-export declare function encodeJavascriptBundleContainer(
- message: JavascriptBundleContainer,
- bb: ByteBuffer,
-): void;
-export declare function decodeJavascriptBundleContainer(
- buffer: ByteBuffer,
-): JavascriptBundleContainer;
-export declare function encodeModuleImportRecord(
- message: ModuleImportRecord,
- bb: ByteBuffer,
-): void;
-export declare function decodeModuleImportRecord(
- buffer: ByteBuffer,
-): ModuleImportRecord;
+export declare function encodeJavascriptBundledModule(message: JavascriptBundledModule, bb: ByteBuffer): void;
+export declare function decodeJavascriptBundledModule(buffer: ByteBuffer): JavascriptBundledModule;
+export declare function encodeJavascriptBundledPackage(message: JavascriptBundledPackage, bb: ByteBuffer): void;
+export declare function decodeJavascriptBundledPackage(buffer: ByteBuffer): JavascriptBundledPackage;
+export declare function encodeJavascriptBundle(message: JavascriptBundle, bb: ByteBuffer): void;
+export declare function decodeJavascriptBundle(buffer: ByteBuffer): JavascriptBundle;
+export declare function encodeJavascriptBundleContainer(message: JavascriptBundleContainer, bb: ByteBuffer): void;
+export declare function decodeJavascriptBundleContainer(buffer: ByteBuffer): JavascriptBundleContainer;
+export declare function encodeModuleImportRecord(message: ModuleImportRecord, bb: ByteBuffer): void;
+export declare function decodeModuleImportRecord(buffer: ByteBuffer): ModuleImportRecord;
export declare function encodeModule(message: Module, bb: ByteBuffer): void;
export declare function decodeModule(buffer: ByteBuffer): Module;
-export declare function encodeStringMap(
- message: StringMap,
- bb: ByteBuffer,
-): void;
+export declare function encodeStringMap(message: StringMap, bb: ByteBuffer): void;
export declare function decodeStringMap(buffer: ByteBuffer): StringMap;
-export declare function encodeLoaderMap(
- message: LoaderMap,
- bb: ByteBuffer,
-): void;
+export declare function encodeLoaderMap(message: LoaderMap, bb: ByteBuffer): void;
export declare function decodeLoaderMap(buffer: ByteBuffer): LoaderMap;
-export declare function encodeEnvConfig(
- message: EnvConfig,
- bb: ByteBuffer,
-): void;
+export declare function encodeEnvConfig(message: EnvConfig, bb: ByteBuffer): void;
export declare function decodeEnvConfig(buffer: ByteBuffer): EnvConfig;
-export declare function encodeLoadedEnvConfig(
- message: LoadedEnvConfig,
- bb: ByteBuffer,
-): void;
-export declare function decodeLoadedEnvConfig(
- buffer: ByteBuffer,
-): LoadedEnvConfig;
-export declare function encodeFrameworkConfig(
- message: FrameworkConfig,
- bb: ByteBuffer,
-): void;
-export declare function decodeFrameworkConfig(
- buffer: ByteBuffer,
-): FrameworkConfig;
-export declare function encodeFrameworkEntryPoint(
- message: FrameworkEntryPoint,
- bb: ByteBuffer,
-): void;
-export declare function decodeFrameworkEntryPoint(
- buffer: ByteBuffer,
-): FrameworkEntryPoint;
-export declare function encodeFrameworkEntryPointMap(
- message: FrameworkEntryPointMap,
- bb: ByteBuffer,
-): void;
-export declare function decodeFrameworkEntryPointMap(
- buffer: ByteBuffer,
-): FrameworkEntryPointMap;
-export declare function encodeFrameworkEntryPointMessage(
- message: FrameworkEntryPointMessage,
- bb: ByteBuffer,
-): void;
-export declare function decodeFrameworkEntryPointMessage(
- buffer: ByteBuffer,
-): FrameworkEntryPointMessage;
-export declare function encodeLoadedFramework(
- message: LoadedFramework,
- bb: ByteBuffer,
-): void;
-export declare function decodeLoadedFramework(
- buffer: ByteBuffer,
-): LoadedFramework;
-export declare function encodeLoadedRouteConfig(
- message: LoadedRouteConfig,
- bb: ByteBuffer,
-): void;
-export declare function decodeLoadedRouteConfig(
- buffer: ByteBuffer,
-): LoadedRouteConfig;
-export declare function encodeRouteConfig(
- message: RouteConfig,
- bb: ByteBuffer,
-): void;
+export declare function encodeLoadedEnvConfig(message: LoadedEnvConfig, bb: ByteBuffer): void;
+export declare function decodeLoadedEnvConfig(buffer: ByteBuffer): LoadedEnvConfig;
+export declare function encodeFrameworkConfig(message: FrameworkConfig, bb: ByteBuffer): void;
+export declare function decodeFrameworkConfig(buffer: ByteBuffer): FrameworkConfig;
+export declare function encodeFrameworkEntryPoint(message: FrameworkEntryPoint, bb: ByteBuffer): void;
+export declare function decodeFrameworkEntryPoint(buffer: ByteBuffer): FrameworkEntryPoint;
+export declare function encodeFrameworkEntryPointMap(message: FrameworkEntryPointMap, bb: ByteBuffer): void;
+export declare function decodeFrameworkEntryPointMap(buffer: ByteBuffer): FrameworkEntryPointMap;
+export declare function encodeFrameworkEntryPointMessage(message: FrameworkEntryPointMessage, bb: ByteBuffer): void;
+export declare function decodeFrameworkEntryPointMessage(buffer: ByteBuffer): FrameworkEntryPointMessage;
+export declare function encodeLoadedFramework(message: LoadedFramework, bb: ByteBuffer): void;
+export declare function decodeLoadedFramework(buffer: ByteBuffer): LoadedFramework;
+export declare function encodeLoadedRouteConfig(message: LoadedRouteConfig, bb: ByteBuffer): void;
+export declare function decodeLoadedRouteConfig(buffer: ByteBuffer): LoadedRouteConfig;
+export declare function encodeRouteConfig(message: RouteConfig, bb: ByteBuffer): void;
export declare function decodeRouteConfig(buffer: ByteBuffer): RouteConfig;
-export declare function encodeTransformOptions(
- message: TransformOptions,
- bb: ByteBuffer,
-): void;
-export declare function decodeTransformOptions(
- buffer: ByteBuffer,
-): TransformOptions;
-export declare function encodeFileHandle(
- message: FileHandle,
- bb: ByteBuffer,
-): void;
+export declare function encodeTransformOptions(message: TransformOptions, bb: ByteBuffer): void;
+export declare function decodeTransformOptions(buffer: ByteBuffer): TransformOptions;
+export declare function encodeFileHandle(message: FileHandle, bb: ByteBuffer): void;
export declare function decodeFileHandle(buffer: ByteBuffer): FileHandle;
-export declare function encodeTransform(
- message: Transform,
- bb: ByteBuffer,
-): void;
+export declare function encodeTransform(message: Transform, bb: ByteBuffer): void;
export declare function decodeTransform(buffer: ByteBuffer): Transform;
export declare function encodeScan(message: Scan, bb: ByteBuffer): void;
export declare function decodeScan(buffer: ByteBuffer): Scan;
-export declare function encodeScanResult(
- message: ScanResult,
- bb: ByteBuffer,
-): void;
+export declare function encodeScanResult(message: ScanResult, bb: ByteBuffer): void;
export declare function decodeScanResult(buffer: ByteBuffer): ScanResult;
-export declare function encodeScannedImport(
- message: ScannedImport,
- bb: ByteBuffer,
-): void;
+export declare function encodeScannedImport(message: ScannedImport, bb: ByteBuffer): void;
export declare function decodeScannedImport(buffer: ByteBuffer): ScannedImport;
-export declare function encodeOutputFile(
- message: OutputFile,
- bb: ByteBuffer,
-): void;
+export declare function encodeOutputFile(message: OutputFile, bb: ByteBuffer): void;
export declare function decodeOutputFile(buffer: ByteBuffer): OutputFile;
-export declare function encodeTransformResponse(
- message: TransformResponse,
- bb: ByteBuffer,
-): void;
-export declare function decodeTransformResponse(
- buffer: ByteBuffer,
-): TransformResponse;
+export declare function encodeTransformResponse(message: TransformResponse, bb: ByteBuffer): void;
+export declare function decodeTransformResponse(buffer: ByteBuffer): TransformResponse;
export declare function encodeLocation(message: Location, bb: ByteBuffer): void;
export declare function decodeLocation(buffer: ByteBuffer): Location;
-export declare function encodeMessageData(
- message: MessageData,
- bb: ByteBuffer,
-): void;
+export declare function encodeMessageData(message: MessageData, bb: ByteBuffer): void;
export declare function decodeMessageData(buffer: ByteBuffer): MessageData;
-export declare function encodeMessageMeta(
- message: MessageMeta,
- bb: ByteBuffer,
-): void;
+export declare function encodeMessageMeta(message: MessageMeta, bb: ByteBuffer): void;
export declare function decodeMessageMeta(buffer: ByteBuffer): MessageMeta;
export declare function encodeMessage(message: Message, bb: ByteBuffer): void;
export declare function decodeMessage(buffer: ByteBuffer): Message;
export declare function encodeLog(message: Log, bb: ByteBuffer): void;
export declare function decodeLog(buffer: ByteBuffer): Log;
-export declare function encodeWebsocketMessage(
- message: WebsocketMessage,
- bb: ByteBuffer,
-): void;
-export declare function decodeWebsocketMessage(
- buffer: ByteBuffer,
-): WebsocketMessage;
-export declare function encodeWebsocketMessageWelcome(
- message: WebsocketMessageWelcome,
- bb: ByteBuffer,
-): void;
-export declare function decodeWebsocketMessageWelcome(
- buffer: ByteBuffer,
-): WebsocketMessageWelcome;
+export declare function encodeWebsocketMessage(message: WebsocketMessage, bb: ByteBuffer): void;
+export declare function decodeWebsocketMessage(buffer: ByteBuffer): WebsocketMessage;
+export declare function encodeWebsocketMessageWelcome(message: WebsocketMessageWelcome, bb: ByteBuffer): void;
+export declare function decodeWebsocketMessageWelcome(buffer: ByteBuffer): WebsocketMessageWelcome;
export declare function encodeWebsocketMessageFileChangeNotification(
message: WebsocketMessageFileChangeNotification,
bb: ByteBuffer,
@@ -912,69 +774,26 @@ export declare function encodeWebsocketMessageFileChangeNotification(
export declare function decodeWebsocketMessageFileChangeNotification(
buffer: ByteBuffer,
): WebsocketMessageFileChangeNotification;
-export declare function encodeWebsocketCommand(
- message: WebsocketCommand,
- bb: ByteBuffer,
-): void;
-export declare function decodeWebsocketCommand(
- buffer: ByteBuffer,
-): WebsocketCommand;
-export declare function encodeWebsocketCommandBuild(
- message: WebsocketCommandBuild,
- bb: ByteBuffer,
-): void;
-export declare function decodeWebsocketCommandBuild(
- buffer: ByteBuffer,
-): WebsocketCommandBuild;
-export declare function encodeWebsocketCommandManifest(
- message: WebsocketCommandManifest,
- bb: ByteBuffer,
-): void;
-export declare function decodeWebsocketCommandManifest(
- buffer: ByteBuffer,
-): WebsocketCommandManifest;
-export declare function encodeWebsocketMessageBuildSuccess(
- message: WebsocketMessageBuildSuccess,
- bb: ByteBuffer,
-): void;
-export declare function decodeWebsocketMessageBuildSuccess(
- buffer: ByteBuffer,
-): WebsocketMessageBuildSuccess;
-export declare function encodeWebsocketMessageBuildFailure(
- message: WebsocketMessageBuildFailure,
- bb: ByteBuffer,
-): void;
-export declare function decodeWebsocketMessageBuildFailure(
- buffer: ByteBuffer,
-): WebsocketMessageBuildFailure;
+export declare function encodeWebsocketCommand(message: WebsocketCommand, bb: ByteBuffer): void;
+export declare function decodeWebsocketCommand(buffer: ByteBuffer): WebsocketCommand;
+export declare function encodeWebsocketCommandBuild(message: WebsocketCommandBuild, bb: ByteBuffer): void;
+export declare function decodeWebsocketCommandBuild(buffer: ByteBuffer): WebsocketCommandBuild;
+export declare function encodeWebsocketCommandManifest(message: WebsocketCommandManifest, bb: ByteBuffer): void;
+export declare function decodeWebsocketCommandManifest(buffer: ByteBuffer): WebsocketCommandManifest;
+export declare function encodeWebsocketMessageBuildSuccess(message: WebsocketMessageBuildSuccess, bb: ByteBuffer): void;
+export declare function decodeWebsocketMessageBuildSuccess(buffer: ByteBuffer): WebsocketMessageBuildSuccess;
+export declare function encodeWebsocketMessageBuildFailure(message: WebsocketMessageBuildFailure, bb: ByteBuffer): void;
+export declare function decodeWebsocketMessageBuildFailure(buffer: ByteBuffer): WebsocketMessageBuildFailure;
export declare function encodeWebsocketCommandBuildWithFilePath(
message: WebsocketCommandBuildWithFilePath,
bb: ByteBuffer,
): void;
-export declare function decodeWebsocketCommandBuildWithFilePath(
- buffer: ByteBuffer,
-): WebsocketCommandBuildWithFilePath;
-export declare function encodeWebsocketMessageResolveID(
- message: WebsocketMessageResolveID,
- bb: ByteBuffer,
-): void;
-export declare function decodeWebsocketMessageResolveID(
- buffer: ByteBuffer,
-): WebsocketMessageResolveID;
-export declare function encodeNPMRegistry(
- message: NPMRegistry,
- bb: ByteBuffer,
-): void;
+export declare function decodeWebsocketCommandBuildWithFilePath(buffer: ByteBuffer): WebsocketCommandBuildWithFilePath;
+export declare function encodeWebsocketMessageResolveID(message: WebsocketMessageResolveID, bb: ByteBuffer): void;
+export declare function decodeWebsocketMessageResolveID(buffer: ByteBuffer): WebsocketMessageResolveID;
+export declare function encodeNPMRegistry(message: NPMRegistry, bb: ByteBuffer): void;
export declare function decodeNPMRegistry(buffer: ByteBuffer): NPMRegistry;
-export declare function encodeNPMRegistryMap(
- message: NPMRegistryMap,
- bb: ByteBuffer,
-): void;
-export declare function decodeNPMRegistryMap(
- buffer: ByteBuffer,
-): NPMRegistryMap;
-export declare function encodeBunInstall(
- message: BunInstall,
- bb: ByteBuffer,
-): void;
+export declare function encodeNPMRegistryMap(message: NPMRegistryMap, bb: ByteBuffer): void;
+export declare function decodeNPMRegistryMap(buffer: ByteBuffer): NPMRegistryMap;
+export declare function encodeBunInstall(message: BunInstall, bb: ByteBuffer): void;
export declare function decodeBunInstall(buffer: ByteBuffer): BunInstall;
diff --git a/src/api/demo/schema.js b/src/api/demo/schema.js
index 2c31d9512..7bdd13b65 100644
--- a/src/api/demo/schema.js
+++ b/src/api/demo/schema.js
@@ -118,12 +118,7 @@ function encodeStackFrame(message, bb) {
var value = message["scope"];
if (value != null) {
var encoded = StackFrameScope[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " +
- JSON.stringify(value) +
- ' for enum "StackFrameScope"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "StackFrameScope"');
bb.writeByte(encoded);
} else {
throw new Error('Missing required field "scope"');
@@ -500,10 +495,7 @@ function encodeFallbackMessageContainer(message, bb) {
if (value != null) {
bb.writeByte(3);
var encoded = FallbackStep[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "FallbackStep"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "FallbackStep"');
bb.writeByte(encoded);
}
@@ -612,10 +604,7 @@ function encodeJSX(message, bb) {
var value = message["runtime"];
if (value != null) {
var encoded = JSXRuntime[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "JSXRuntime"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "JSXRuntime"');
bb.writeByte(encoded);
} else {
throw new Error('Missing required field "runtime"');
@@ -775,12 +764,10 @@ function decodeJavascriptBundle(bb) {
var length = bb.readVarUint();
var values = (result["modules"] = Array(length));
- for (var i = 0; i < length; i++)
- values[i] = decodeJavascriptBundledModule(bb);
+ for (var i = 0; i < length; i++) values[i] = decodeJavascriptBundledModule(bb);
var length = bb.readVarUint();
var values = (result["packages"] = Array(length));
- for (var i = 0; i < length; i++)
- values[i] = decodeJavascriptBundledPackage(bb);
+ for (var i = 0; i < length; i++) values[i] = decodeJavascriptBundledPackage(bb);
result["etag"] = bb.readByteArray();
result["generated_at"] = bb.readUint32();
result["app_package_json_dependencies_hash"] = bb.readByteArray();
@@ -834,9 +821,7 @@ function encodeJavascriptBundle(message, bb) {
if (value != null) {
bb.writeByteArray(value);
} else {
- throw new Error(
- 'Missing required field "app_package_json_dependencies_hash"',
- );
+ throw new Error('Missing required field "app_package_json_dependencies_hash"');
}
var value = message["import_from_name"];
@@ -958,12 +943,7 @@ function encodeModuleImportRecord(message, bb) {
var value = message["kind"];
if (value != null) {
var encoded = ModuleImportType[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " +
- JSON.stringify(value) +
- ' for enum "ModuleImportType"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "ModuleImportType"');
bb.writeByte(encoded);
} else {
throw new Error('Missing required field "kind"');
@@ -1090,10 +1070,7 @@ function encodeLoaderMap(message, bb) {
for (var i = 0; i < n; i++) {
value = values[i];
var encoded = Loader[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "Loader"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Loader"');
bb.writeByte(encoded);
}
} else {
@@ -1167,10 +1144,7 @@ function encodeLoadedEnvConfig(message, bb) {
var value = message["dotenv"];
if (value != null) {
var encoded = DotEnvBehavior[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "DotEnvBehavior"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "DotEnvBehavior"');
bb.writeVarUint(encoded);
} else {
throw new Error('Missing required field "dotenv"');
@@ -1272,12 +1246,7 @@ function encodeFrameworkConfig(message, bb) {
if (value != null) {
bb.writeByte(6);
var encoded = CSSInJSBehavior[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " +
- JSON.stringify(value) +
- ' for enum "CSSInJSBehavior"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "CSSInJSBehavior"');
bb.writeByte(encoded);
}
@@ -1309,11 +1278,7 @@ function encodeFrameworkEntryPoint(message, bb) {
if (value != null) {
var encoded = FrameworkEntryPointType[value];
if (encoded === void 0)
- throw new Error(
- "Invalid value " +
- JSON.stringify(value) +
- ' for enum "FrameworkEntryPointType"',
- );
+ throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "FrameworkEntryPointType"');
bb.writeByte(encoded);
} else {
throw new Error('Missing required field "kind"');
@@ -1462,12 +1427,7 @@ function encodeLoadedFramework(message, bb) {
var value = message["client_css_in_js"];
if (value != null) {
var encoded = CSSInJSBehavior[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " +
- JSON.stringify(value) +
- ' for enum "CSSInJSBehavior"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "CSSInJSBehavior"');
bb.writeByte(encoded);
} else {
throw new Error('Missing required field "client_css_in_js"');
@@ -1747,10 +1707,7 @@ function encodeTransformOptions(message, bb) {
if (value != null) {
bb.writeByte(3);
var encoded = ResolveMode[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "ResolveMode"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "ResolveMode"');
bb.writeByte(encoded);
}
@@ -1848,10 +1805,7 @@ function encodeTransformOptions(message, bb) {
if (value != null) {
bb.writeByte(15);
var encoded = Platform[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "Platform"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Platform"');
bb.writeByte(encoded);
}
@@ -1925,10 +1879,7 @@ function encodeTransformOptions(message, bb) {
if (value != null) {
bb.writeByte(26);
var encoded = MessageLevel[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "MessageLevel"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "MessageLevel"');
bb.writeVarUint(encoded);
}
bb.writeByte(0);
@@ -2023,10 +1974,7 @@ function encodeTransform(message, bb) {
if (value != null) {
bb.writeByte(4);
var encoded = Loader[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "Loader"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Loader"');
bb.writeByte(encoded);
}
@@ -2081,10 +2029,7 @@ function encodeScan(message, bb) {
if (value != null) {
bb.writeByte(3);
var encoded = Loader[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "Loader"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Loader"');
bb.writeByte(encoded);
}
bb.writeByte(0);
@@ -2149,10 +2094,7 @@ function encodeScannedImport(message, bb) {
var value = message["kind"];
if (value != null) {
var encoded = ImportKind[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "ImportKind"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "ImportKind"');
bb.writeByte(encoded);
} else {
throw new Error('Missing required field "kind"');
@@ -2249,11 +2191,7 @@ function encodeTransformResponse(message, bb) {
if (value != null) {
var encoded = TransformResponseStatus[value];
if (encoded === void 0)
- throw new Error(
- "Invalid value " +
- JSON.stringify(value) +
- ' for enum "TransformResponseStatus"',
- );
+ throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "TransformResponseStatus"');
bb.writeVarUint(encoded);
} else {
throw new Error('Missing required field "status"');
@@ -2464,10 +2402,7 @@ function encodeMessage(message, bb) {
var value = message["level"];
if (value != null) {
var encoded = MessageLevel[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "MessageLevel"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "MessageLevel"');
bb.writeVarUint(encoded);
} else {
throw new Error('Missing required field "level"');
@@ -2629,11 +2564,7 @@ function encodeWebsocketMessage(message, bb) {
if (value != null) {
var encoded = WebsocketMessageKind[value];
if (encoded === void 0)
- throw new Error(
- "Invalid value " +
- JSON.stringify(value) +
- ' for enum "WebsocketMessageKind"',
- );
+ throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "WebsocketMessageKind"');
bb.writeByte(encoded);
} else {
throw new Error('Missing required field "kind"');
@@ -2660,10 +2591,7 @@ function encodeWebsocketMessageWelcome(message, bb) {
var value = message["javascriptReloader"];
if (value != null) {
var encoded = Reloader[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "Reloader"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Reloader"');
bb.writeByte(encoded);
} else {
throw new Error('Missing required field "javascriptReloader"');
@@ -2696,10 +2624,7 @@ function encodeWebsocketMessageFileChangeNotification(message, bb) {
var value = message["loader"];
if (value != null) {
var encoded = Loader[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "Loader"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Loader"');
bb.writeByte(encoded);
} else {
throw new Error('Missing required field "loader"');
@@ -2719,11 +2644,7 @@ function encodeWebsocketCommand(message, bb) {
if (value != null) {
var encoded = WebsocketCommandKind[value];
if (encoded === void 0)
- throw new Error(
- "Invalid value " +
- JSON.stringify(value) +
- ' for enum "WebsocketCommandKind"',
- );
+ throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "WebsocketCommandKind"');
bb.writeByte(encoded);
} else {
throw new Error('Missing required field "kind"');
@@ -2798,10 +2719,7 @@ function encodeWebsocketMessageBuildSuccess(message, bb) {
var value = message["loader"];
if (value != null) {
var encoded = Loader[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "Loader"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Loader"');
bb.writeByte(encoded);
} else {
throw new Error('Missing required field "loader"');
@@ -2851,10 +2769,7 @@ function encodeWebsocketMessageBuildFailure(message, bb) {
var value = message["loader"];
if (value != null) {
var encoded = Loader[value];
- if (encoded === void 0)
- throw new Error(
- "Invalid value " + JSON.stringify(value) + ' for enum "Loader"',
- );
+ if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Loader"');
bb.writeByte(encoded);
} else {
throw new Error('Missing required field "loader"');
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig
index 1c991eece..5dc3abcf9 100644
--- a/src/bun.js/api/bun.zig
+++ b/src/bun.js/api/bun.zig
@@ -861,12 +861,32 @@ pub fn sleepSync(
arguments: []const js.JSValueRef,
_: js.ExceptionRef,
) js.JSValueRef {
- if (js.JSValueIsNumber(ctx, arguments[0])) {
- const seconds = JSValue.fromRef(arguments[0]).asNumber();
- if (seconds > 0 and std.math.isFinite(seconds)) std.time.sleep(@floatToInt(u64, seconds * 1000) * std.time.ns_per_ms);
+ // This function always returns undefined
+ const ret = js.JSValueMakeUndefined(ctx);
+
+ // Expect at least one argument. We allow more than one but ignore them; this
+ // is useful for supporting things like `[1, 2].map(sleepSync)`
+ if (arguments.len < 1) {
+ ctx.throwInvalidArguments("expected one argument, got {}", .{arguments.len});
+ return ret;
}
+ const arg = JSValue.fromRef(arguments[0]);
- return js.JSValueMakeUndefined(ctx);
+ // The argument must be a number
+ if (!arg.isNumber()) {
+ ctx.throwInvalidArguments("argument to sleepSync must be a number, got {}", .{arg.jsTypeLoose()});
+ return ret;
+ }
+
+ //NOTE: if argument is > max(i32) then it will be truncated
+ const milliseconds = arg.coerce(i32, ctx);
+ if (milliseconds < 0) {
+ ctx.throwInvalidArguments("argument to sleepSync must not be negative, got {}", .{milliseconds});
+ return ret;
+ }
+
+ std.time.sleep(@intCast(u64, milliseconds) * std.time.ns_per_ms);
+ return ret;
}
pub fn createNodeFS(
diff --git a/src/bun.js/api/bun/subprocess.zig b/src/bun.js/api/bun/subprocess.zig
index 7e7f827fa..ea693d110 100644
--- a/src/bun.js/api/bun/subprocess.zig
+++ b/src/bun.js/api/bun/subprocess.zig
@@ -1480,7 +1480,7 @@ pub const Subprocess = struct {
jsc_vm.tick();
jsc_vm.eventLoop().autoTick();
}
- // subprocess.wait(true);
+
const exitCode = subprocess.exit_code orelse 1;
const stdout = subprocess.stdout.toBufferedValue(globalThis);
const stderr = subprocess.stderr.toBufferedValue(globalThis);
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig
index 546350679..bb2f251a2 100644
--- a/src/bun.js/api/server.zig
+++ b/src/bun.js/api/server.zig
@@ -635,6 +635,7 @@ pub fn NewRequestContextStackAllocator(comptime RequestContext: type, comptime c
fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comptime ThisServer: type) type {
return struct {
const RequestContext = @This();
+ const ctxLog = Output.scoped(.RequestContext, false);
const App = uws.NewApp(ssl_enabled);
pub threadlocal var pool: ?*RequestContext.RequestContextStackAllocator = null;
pub threadlocal var pool_allocator: std.mem.Allocator = undefined;
@@ -649,6 +650,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
/// this prevents an extra pthread_getspecific() call which shows up in profiling
allocator: std.mem.Allocator,
req: *uws.Request,
+ signal: ?*JSC.WebCore.AbortSignal = null,
method: HTTP.Method,
aborted: bool = false,
finalized: bun.DebugOnly(bool) = bun.DebugOnlyDefault(false),
@@ -697,11 +699,24 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn onResolve(_: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue {
+ ctxLog("onResolve", .{});
+
const arguments = callframe.arguments(2);
var ctx = arguments.ptr[1].asPromisePtr(@This());
const result = arguments.ptr[0];
result.ensureStillAlive();
+ if (ctx.request_js_object != null and ctx.signal == null) {
+ var request_js = ctx.request_js_object.?.value();
+ request_js.ensureStillAlive();
+ if (request_js.as(Request)) |request_object| {
+ if (request_object.signal) |signal| {
+ ctx.signal = signal;
+ _ = signal.ref();
+ }
+ }
+ }
+
ctx.pending_promises_for_abort -|= 1;
if (ctx.aborted) {
ctx.finalizeForAbort();
@@ -738,15 +753,29 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn finalizeForAbort(this: *RequestContext) void {
+ streamLog("finalizeForAbort", .{});
this.pending_promises_for_abort -|= 1;
if (this.pending_promises_for_abort == 0) this.finalize();
}
pub fn onReject(_: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue {
+ ctxLog("onReject", .{});
+
const arguments = callframe.arguments(2);
var ctx = arguments.ptr[1].asPromisePtr(@This());
const err = arguments.ptr[0];
+ if (ctx.request_js_object != null and ctx.signal == null) {
+ var request_js = ctx.request_js_object.?.value();
+ request_js.ensureStillAlive();
+ if (request_js.as(Request)) |request_object| {
+ if (request_object.signal) |signal| {
+ ctx.signal = signal;
+ _ = signal.ref();
+ }
+ }
+ }
+
ctx.pending_promises_for_abort -|= 1;
if (ctx.aborted) {
@@ -988,8 +1017,26 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
pub fn onAbort(this: *RequestContext, resp: *App.Response) void {
std.debug.assert(this.resp == resp);
std.debug.assert(!this.aborted);
+ //mark request as aborted
this.aborted = true;
+ // if signal is not aborted, abort the signal
+ if (this.signal) |signal| {
+ this.signal = null;
+ if (!signal.aborted()) {
+ const reason = JSC.WebCore.AbortSignal.createAbortError(JSC.ZigString.static("The user aborted a request"), &JSC.ZigString.Empty, this.server.globalThis);
+ reason.ensureStillAlive();
+ _ = signal.signal(reason);
+ }
+ _ = signal.unref();
+ }
+
+ //if have sink, call onAborted on sink
+ if (this.sink) |wrapper| {
+ wrapper.sink.abort();
+ return;
+ }
+
// if we can, free the request now.
if (this.isDeadRequest()) {
this.finalizeWithoutDeinit();
@@ -1010,14 +1057,6 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
// User called .blob(), .json(), text(), or .arrayBuffer() on the Request object
// but we received nothing or the connection was aborted
if (request_js.as(Request)) |req| {
- if (req.signal) |signal| {
- // if signal is not aborted, abort the signal
- if (!signal.aborted()) {
- const reason = JSC.AbortSignal.createAbortError(JSC.ZigString.static("The user aborted a request"), &JSC.ZigString.Empty, this.server.globalThis);
- reason.ensureStillAlive();
- _ = signal.signal(reason);
- }
- }
// the promise is pending
if (req.body == .Locked and (req.body.Locked.action != .none or req.body.Locked.promise != null)) {
@@ -1062,6 +1101,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
// This function may be called multiple times
// so it's important that we can safely do that
pub fn finalizeWithoutDeinit(this: *RequestContext) void {
+ ctxLog("finalizeWithoutDeinit", .{});
this.blob.detach();
if (comptime Environment.allow_assert) {
@@ -1070,6 +1110,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
if (!this.response_jsvalue.isEmpty()) {
+ ctxLog("finalizeWithoutDeinit: response_jsvalue != .zero", .{});
if (this.response_protected) {
this.response_jsvalue.unprotect();
this.response_protected = false;
@@ -1077,7 +1118,20 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
this.response_jsvalue = JSC.JSValue.zero;
}
+ // if signal is not aborted, abort the signal
+ if (this.signal) |signal| {
+ this.signal = null;
+ if (this.aborted and !signal.aborted()) {
+ const reason = JSC.WebCore.AbortSignal.createAbortError(JSC.ZigString.static("The user aborted a request"), &JSC.ZigString.Empty, this.server.globalThis);
+ reason.ensureStillAlive();
+ _ = signal.signal(reason);
+ }
+ _ = signal.unref();
+ }
+
if (this.request_js_object != null) {
+ ctxLog("finalizeWithoutDeinit: request_js_object != null", .{});
+
var request_js = this.request_js_object.?.value();
request_js.ensureStillAlive();
@@ -1087,14 +1141,6 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
// User called .blob(), .json(), text(), or .arrayBuffer() on the Request object
// but we received nothing or the connection was aborted
if (request_js.as(Request)) |req| {
- if (req.signal) |signal| {
- // if signal is not aborted, abort the signal
- if (!signal.aborted()) {
- const reason = JSC.AbortSignal.createAbortError(JSC.ZigString.static("The user aborted a request"), &JSC.ZigString.Empty, this.server.globalThis);
- reason.ensureStillAlive();
- _ = signal.signal(reason);
- }
- }
// the promise is pending
if (req.body == .Locked and req.body.Locked.action != .none and req.body.Locked.promise != null) {
req.body.toErrorInstance(JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis), this.server.globalThis);
@@ -1104,6 +1150,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
if (this.promise) |promise| {
+ ctxLog("finalizeWithoutDeinit: this.promise != null", .{});
this.promise = null;
if (promise.asAnyPromise()) |prom| {
@@ -1113,22 +1160,27 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
if (this.byte_stream) |stream| {
+ ctxLog("finalizeWithoutDeinit: stream != null", .{});
+
this.byte_stream = null;
stream.unpipe();
}
if (this.pathname.len > 0) {
+ ctxLog("finalizeWithoutDeinit: this.pathname.len > 0 null", .{});
this.allocator.free(bun.constStrToU8(this.pathname));
this.pathname = "";
}
}
pub fn finalize(this: *RequestContext) void {
+ ctxLog("finalize", .{});
this.finalizeWithoutDeinit();
this.markComplete();
this.deinit();
}
pub fn deinit(this: *RequestContext) void {
+ ctxLog("deinit", .{});
if (comptime Environment.allow_assert)
std.debug.assert(this.finalized);
@@ -1577,8 +1629,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
streamLog("returned a promise", .{});
switch (promise.status(this.server.globalThis.vm())) {
.Pending => {
+ streamLog("promise still Pending", .{});
// TODO: should this timeout?
- this.resp.onAborted(*ResponseStream, ResponseStream.onAborted, &response_stream.sink);
+ this.setAbortHandler();
this.response_ptr.?.body.value = .{
.Locked = .{
.readable = stream,
@@ -1595,9 +1648,11 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
},
.Fulfilled => {
+ streamLog("promise Fulfilled", .{});
this.handleResolveStream();
},
.Rejected => {
+ streamLog("promise Rejected", .{});
this.handleRejectStream(this.server.globalThis, promise.result(this.server.globalThis.vm()));
},
}
@@ -1631,7 +1686,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
}
- this.resp.onAborted(*ResponseStream, ResponseStream.onAborted, &response_stream.sink);
+ this.setAbortHandler();
streamLog("is in progress, but did not return a Promise. Finalizing request context", .{});
this.finalize();
stream.value.unprotect();
@@ -1709,6 +1764,12 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
switch (promise.status(vm.global.vm())) {
.Pending => {},
.Fulfilled => {
+ if (ctx.signal == null) {
+ if (request_object.signal) |signal| {
+ ctx.signal = signal;
+ _ = signal.ref();
+ }
+ }
const fulfilled_value = promise.result(vm.global.vm());
// if you return a Response object or a Promise<Response>
@@ -1751,6 +1812,12 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
return;
},
.Rejected => {
+ if (ctx.signal == null) {
+ if (request_object.signal) |signal| {
+ ctx.signal = signal;
+ _ = signal.ref();
+ }
+ }
ctx.handleReject(promise.result(vm.global.vm()));
return;
},
@@ -1790,7 +1857,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn handleResolveStream(req: *RequestContext) void {
- streamLog("onResolve", .{});
+ streamLog("handleResolveStream", .{});
+
var wrote_anything = false;
if (req.sink) |wrapper| {
wrapper.sink.pending_flush = null;
@@ -1810,6 +1878,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
}
+ streamLog("onResolve({any})", .{wrote_anything});
+
+ //aborted so call finalizeForAbort
if (req.aborted) {
req.finalizeForAbort();
return;
@@ -1821,7 +1892,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
req.resp.clearAborted();
req.renderMissing();
return;
- } else if (!responded and wrote_anything and !req.aborted) {
+ } else if (!responded and wrote_anything) {
req.resp.clearAborted();
req.resp.endStream(req.shouldCloseConnection());
}
@@ -1830,12 +1901,14 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn onResolveStream(_: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue {
+ streamLog("onResolveStream", .{});
var args = callframe.arguments(2);
var req: *@This() = args.ptr[args.len - 1].asPromisePtr(@This());
req.handleResolveStream();
return JSValue.jsUndefined();
}
pub fn onRejectStream(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue {
+ streamLog("onRejectStream", .{});
const args = callframe.arguments(2);
var req = args.ptr[args.len - 1].asPromisePtr(@This());
var err = args.ptr[0];
@@ -1844,6 +1917,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn handleRejectStream(req: *@This(), globalThis: *JSC.JSGlobalObject, err: JSValue) void {
+ streamLog("handleRejectStream", .{});
var wrote_anything = req.has_written_status;
if (req.sink) |wrapper| {
@@ -1866,6 +1940,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
streamLog("onReject({any})", .{wrote_anything});
+ //aborted so call finalizeForAbort
if (req.aborted) {
req.finalizeForAbort();
return;
@@ -2056,6 +2131,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn doRender(this: *RequestContext) void {
+ ctxLog("render", .{});
+
if (this.aborted) {
this.finalizeForAbort();
return;
@@ -2295,6 +2372,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn render(this: *RequestContext, response: *JSC.WebCore.Response) void {
+ ctxLog("render", .{});
this.response_ptr = response;
this.doRender();
@@ -4669,8 +4747,12 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
ctx.request_js_object = args[0].asObjectRef();
const request_value = args[0];
request_value.ensureStillAlive();
- const response_value = this.config.onRequest.callWithThis(this.globalThis, this.thisObject, &args);
+ const response_value = this.config.onRequest.callWithThis(this.globalThis, this.thisObject, &args);
+ if (request_object.signal) |signal| {
+ ctx.signal = signal;
+ _ = signal.ref();
+ }
ctx.onResponse(
this,
req,
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp
index c4b63869e..7878b96a7 100644
--- a/src/bun.js/bindings/ZigGlobalObject.cpp
+++ b/src/bun.js/bindings/ZigGlobalObject.cpp
@@ -181,7 +181,7 @@ constexpr size_t DEFAULT_ERROR_STACK_TRACE_LIMIT = 10;
// #include <iostream>
static bool has_loaded_jsc = false;
-extern "C" void JSCInitialize()
+extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(const char* ptr, size_t length))
{
if (has_loaded_jsc)
return;
@@ -208,6 +208,22 @@ extern "C" void JSCInitialize()
JSC::Options::useResizableArrayBuffer() = true;
JSC::Options::showPrivateScriptsInStackTraces() = true;
JSC::Options::useSetMethods() = true;
+
+ if (LIKELY(envc > 0)) {
+ while (envc--) {
+ const char* env = (const char*)envp[envc];
+ // need to check for \0 so we might as well make this single pass
+ // strlen would check the end of the string
+ if (LIKELY(!(env[0] == 'B' && env[1] == 'U' && env[2] == 'N' && env[3] == '_' && env[4] == 'J' && env[5] == 'S' && env[6] == 'C' && env[7] == '_'))) {
+ continue;
+ }
+
+ if (UNLIKELY(!JSC::Options::setOption(env + 8))) {
+ onCrash(env, strlen(env));
+ }
+ }
+ }
+
JSC::Options::assertOptionsAreCoherent();
}
}
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp
index 114b59163..62c184893 100644
--- a/src/bun.js/bindings/bindings.cpp
+++ b/src/bun.js/bindings/bindings.cpp
@@ -3358,8 +3358,11 @@ JSC__JSValue JSC__VM__runGC(JSC__VM* vm, bool sync)
vm->finalizeSynchronousJSExecution();
+ WTF::releaseFastMallocFreeMemory();
+
if (sync) {
vm->heap.collectNow(JSC::Sync, JSC::CollectionScope::Full);
+ WTF::releaseFastMallocFreeMemory();
} else {
vm->heap.collectSync(JSC::CollectionScope::Full);
}
@@ -3819,22 +3822,22 @@ extern "C" void JSC__JSGlobalObject__queueMicrotaskJob(JSC__JSGlobalObject* arg0
JSC::JSValue::decode(JSValue4));
}
-extern "C" JSC__JSValue JSC__AbortSignal__create(JSC__JSGlobalObject* globalObject)
+extern "C" JSC__JSValue WebCore__AbortSignal__create(JSC__JSGlobalObject* globalObject)
{
Zig::GlobalObject* thisObject = JSC::jsCast<Zig::GlobalObject*>(globalObject);
auto* context = thisObject->scriptExecutionContext();
auto abortSignal = WebCore::AbortSignal::create(context);
- return JSValue::encode(toJSNewlyCreated<IDLInterface<JSC__AbortSignal>>(*globalObject, *jsCast<JSDOMGlobalObject*>(globalObject), WTFMove(abortSignal)));
+ return JSValue::encode(toJSNewlyCreated<IDLInterface<WebCore__AbortSignal>>(*globalObject, *jsCast<JSDOMGlobalObject*>(globalObject), WTFMove(abortSignal)));
}
-extern "C" JSC__JSValue JSC__AbortSignal__toJS(JSC__AbortSignal* arg0, JSC__JSGlobalObject* globalObject)
+extern "C" JSC__JSValue WebCore__AbortSignal__toJS(WebCore__AbortSignal* arg0, JSC__JSGlobalObject* globalObject)
{
WebCore::AbortSignal* abortSignal = reinterpret_cast<WebCore::AbortSignal*>(arg0);
- return JSValue::encode(toJS<IDLInterface<JSC__AbortSignal>>(*globalObject, *jsCast<JSDOMGlobalObject*>(globalObject), *abortSignal));
+ return JSValue::encode(toJS<IDLInterface<WebCore__AbortSignal>>(*globalObject, *jsCast<JSDOMGlobalObject*>(globalObject), *abortSignal));
}
-extern "C" JSC__AbortSignal* JSC__AbortSignal__signal(JSC__AbortSignal* arg0, JSC__JSValue JSValue1)
+extern "C" WebCore__AbortSignal* WebCore__AbortSignal__signal(WebCore__AbortSignal* arg0, JSC__JSValue JSValue1)
{
WebCore::AbortSignal* abortSignal = reinterpret_cast<WebCore::AbortSignal*>(arg0);
@@ -3842,38 +3845,38 @@ extern "C" JSC__AbortSignal* JSC__AbortSignal__signal(JSC__AbortSignal* arg0, JS
return arg0;
}
-extern "C" bool JSC__AbortSignal__aborted(JSC__AbortSignal* arg0)
+extern "C" bool WebCore__AbortSignal__aborted(WebCore__AbortSignal* arg0)
{
WebCore::AbortSignal* abortSignal = reinterpret_cast<WebCore::AbortSignal*>(arg0);
return abortSignal->aborted();
}
-extern "C" JSC__JSValue JSC__AbortSignal__abortReason(JSC__AbortSignal* arg0)
+extern "C" JSC__JSValue WebCore__AbortSignal__abortReason(WebCore__AbortSignal* arg0)
{
WebCore::AbortSignal* abortSignal = reinterpret_cast<WebCore::AbortSignal*>(arg0);
return JSC::JSValue::encode(abortSignal->reason().getValue());
}
-extern "C" JSC__AbortSignal* JSC__AbortSignal__ref(JSC__AbortSignal* arg0)
+extern "C" WebCore__AbortSignal* WebCore__AbortSignal__ref(WebCore__AbortSignal* arg0)
{
WebCore::AbortSignal* abortSignal = reinterpret_cast<WebCore::AbortSignal*>(arg0);
abortSignal->ref();
return arg0;
}
-extern "C" JSC__AbortSignal* JSC__AbortSignal__unref(JSC__AbortSignal* arg0)
+extern "C" WebCore__AbortSignal* WebCore__AbortSignal__unref(WebCore__AbortSignal* arg0)
{
WebCore::AbortSignal* abortSignal = reinterpret_cast<WebCore::AbortSignal*>(arg0);
abortSignal->deref();
return arg0;
}
-extern "C" void JSC__AbortSignal__cleanNativeBindings(JSC__AbortSignal* arg0, void* arg1)
+extern "C" void WebCore__AbortSignal__cleanNativeBindings(WebCore__AbortSignal* arg0, void* arg1)
{
WebCore::AbortSignal* abortSignal = reinterpret_cast<WebCore::AbortSignal*>(arg0);
abortSignal->cleanNativeBindings(arg1);
}
-extern "C" JSC__AbortSignal* JSC__AbortSignal__addListener(JSC__AbortSignal* arg0, void* ctx, void (*callback)(void* ctx, JSC__JSValue reason))
+extern "C" WebCore__AbortSignal* WebCore__AbortSignal__addListener(WebCore__AbortSignal* arg0, void* ctx, void (*callback)(void* ctx, JSC__JSValue reason))
{
WebCore::AbortSignal* abortSignal = reinterpret_cast<WebCore::AbortSignal*>(arg0);
@@ -3886,7 +3889,7 @@ extern "C" JSC__AbortSignal* JSC__AbortSignal__addListener(JSC__AbortSignal* arg
return arg0;
}
-extern "C" JSC__AbortSignal* JSC__AbortSignal__fromJS(JSC__JSValue value)
+extern "C" WebCore__AbortSignal* WebCore__AbortSignal__fromJS(JSC__JSValue value)
{
JSC::JSValue decodedValue = JSC::JSValue::decode(value);
if (decodedValue.isEmpty())
@@ -3895,10 +3898,10 @@ extern "C" JSC__AbortSignal* JSC__AbortSignal__fromJS(JSC__JSValue value)
if (!object)
return nullptr;
- return reinterpret_cast<JSC__AbortSignal*>(&object->wrapped());
+ return reinterpret_cast<WebCore__AbortSignal*>(&object->wrapped());
}
static auto ABORT_ERROR_NAME = MAKE_STATIC_STRING_IMPL("AbortError");
-extern "C" JSC__JSValue JSC__AbortSignal__createAbortError(const ZigString* message, const ZigString* arg1,
+extern "C" JSC__JSValue WebCore__AbortSignal__createAbortError(const ZigString* message, const ZigString* arg1,
JSC__JSGlobalObject* globalObject)
{
JSC::VM& vm = globalObject->vm();
@@ -3920,7 +3923,7 @@ extern "C" JSC__JSValue JSC__AbortSignal__createAbortError(const ZigString* mess
}
static auto TIMEOUT_ERROR_NAME = MAKE_STATIC_STRING_IMPL("TimeoutError");
-extern "C" JSC__JSValue JSC__AbortSignal__createTimeoutError(const ZigString* message, const ZigString* arg1,
+extern "C" JSC__JSValue WebCore__AbortSignal__createTimeoutError(const ZigString* message, const ZigString* arg1,
JSC__JSGlobalObject* globalObject)
{
JSC::VM& vm = globalObject->vm();
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig
index 1479ef977..b44df1103 100644
--- a/src/bun.js/bindings/bindings.zig
+++ b/src/bun.js/bindings/bindings.zig
@@ -1684,11 +1684,11 @@ pub fn PromiseCallback(comptime Type: type, comptime CallbackFunction: fn (*Type
}
pub const AbortSignal = extern opaque {
- pub const shim = Shimmer("JSC", "AbortSignal", @This());
+ pub const shim = Shimmer("WebCore", "AbortSignal", @This());
const cppFn = shim.cppFn;
- pub const include = "WebCore/AbortSignal.h";
- pub const name = "JSC::AbortSignal";
- pub const namespace = "JSC";
+ pub const include = "webcore/AbortSignal.h";
+ pub const name = "WebCore::AbortSignal";
+ pub const namespace = "WebCore";
pub fn listen(
this: *AbortSignal,
@@ -4720,3 +4720,32 @@ pub const DOMCalls = .{
@import("../api/bun.zig").FFI.Reader,
@import("../webcore.zig").Crypto,
};
+
+extern "c" fn JSCInitialize(env: [*]const [*:0]u8, count: usize, cb: *const fn ([*]const u8, len: usize) callconv(.C) void) void;
+pub fn initialize() void {
+ JSC.markBinding(@src());
+ JSCInitialize(
+ std.os.environ.ptr,
+ std.os.environ.len,
+ struct {
+ pub fn callback(name: [*]const u8, len: usize) callconv(.C) void {
+ Output.prettyErrorln(
+ \\<r><red>error<r><d>:<r> invalid JSC environment variable
+ \\
+ \\ <b>{s}<r>
+ \\
+ \\For a list of options, see this file:
+ \\
+ \\ https://github.com/oven-sh/webkit/blob/main/Source/JavaScriptCore/runtime/OptionsList.h
+ \\
+ \\Environment variables must be prefixed with "BUN_JSC_". This code runs before .env files are loaded, so those won't work here.
+ \\
+ \\Warning: options change between releases of Bun and WebKit without notice. This is not a stable API, you should not rely on it beyond debugging something, and it may be removed entirely in a future version of Bun.
+ ,
+ .{name[0..len]},
+ );
+ bun.Global.exit(1);
+ }
+ }.callback,
+ );
+}
diff --git a/src/bun.js/bindings/headers-cpp.h b/src/bun.js/bindings/headers-cpp.h
index b15dd8ba2..4b195d756 100644
--- a/src/bun.js/bindings/headers-cpp.h
+++ b/src/bun.js/bindings/headers-cpp.h
@@ -1,4 +1,4 @@
-//-- AUTOGENERATED FILE -- 1677221832
+//-- AUTOGENERATED FILE -- 1677776166
// clang-format off
#pragma once
@@ -56,13 +56,13 @@ extern "C" const size_t JSC__JSString_object_align_ = alignof(JSC::JSString);
extern "C" const size_t JSC__JSModuleLoader_object_size_ = sizeof(JSC::JSModuleLoader);
extern "C" const size_t JSC__JSModuleLoader_object_align_ = alignof(JSC::JSModuleLoader);
-#ifndef INCLUDED_WebCore_AbortSignal_h
-#define INCLUDED_WebCore_AbortSignal_h
-#include "WebCore/AbortSignal.h"
+#ifndef INCLUDED_webcore_AbortSignal_h
+#define INCLUDED_webcore_AbortSignal_h
+#include "webcore/AbortSignal.h"
#endif
-extern "C" const size_t JSC__AbortSignal_object_size_ = sizeof(JSC::AbortSignal);
-extern "C" const size_t JSC__AbortSignal_object_align_ = alignof(JSC::AbortSignal);
+extern "C" const size_t WebCore__AbortSignal_object_size_ = sizeof(WebCore::AbortSignal);
+extern "C" const size_t WebCore__AbortSignal_object_align_ = alignof(WebCore::AbortSignal);
#ifndef INCLUDED_JavaScriptCore_JSPromise_h
#define INCLUDED_JavaScriptCore_JSPromise_h
@@ -168,8 +168,8 @@ extern "C" const size_t Zig__ConsoleClient_object_align_ = alignof(Zig::ConsoleC
extern "C" const size_t Bun__Timer_object_size_ = sizeof(Bun__Timer);
extern "C" const size_t Bun__Timer_object_align_ = alignof(Bun__Timer);
-const size_t sizes[40] = {sizeof(JSC::JSObject), sizeof(WebCore::DOMURL), sizeof(WebCore::DOMFormData), sizeof(WebCore::FetchHeaders), sizeof(SystemError), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(JSC::JSModuleLoader), sizeof(JSC::AbortSignal), sizeof(JSC::JSPromise), sizeof(JSC::JSInternalPromise), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(JSC::JSValue), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::CatchScope), sizeof(FFI__ptr), sizeof(Reader__u8), sizeof(Reader__u16), sizeof(Reader__u32), sizeof(Reader__ptr), sizeof(Reader__i8), sizeof(Reader__i16), sizeof(Reader__i32), sizeof(Reader__f32), sizeof(Reader__f64), sizeof(Reader__i64), sizeof(Reader__u64), sizeof(Reader__intptr), sizeof(Crypto__getRandomValues), sizeof(Crypto__randomUUID), sizeof(Crypto__timingSafeEqual), sizeof(Zig::GlobalObject), sizeof(Bun__Path), sizeof(ArrayBufferSink), sizeof(HTTPSResponseSink), sizeof(HTTPResponseSink), sizeof(FileSink)};
+const size_t sizes[40] = {sizeof(JSC::JSObject), sizeof(WebCore::DOMURL), sizeof(WebCore::DOMFormData), sizeof(WebCore::FetchHeaders), sizeof(SystemError), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(JSC::JSModuleLoader), sizeof(WebCore::AbortSignal), sizeof(JSC::JSPromise), sizeof(JSC::JSInternalPromise), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(JSC::JSValue), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::CatchScope), sizeof(FFI__ptr), sizeof(Reader__u8), sizeof(Reader__u16), sizeof(Reader__u32), sizeof(Reader__ptr), sizeof(Reader__i8), sizeof(Reader__i16), sizeof(Reader__i32), sizeof(Reader__f32), sizeof(Reader__f64), sizeof(Reader__i64), sizeof(Reader__u64), sizeof(Reader__intptr), sizeof(Crypto__getRandomValues), sizeof(Crypto__randomUUID), sizeof(Crypto__timingSafeEqual), sizeof(Zig::GlobalObject), sizeof(Bun__Path), sizeof(ArrayBufferSink), sizeof(HTTPSResponseSink), sizeof(HTTPResponseSink), sizeof(FileSink)};
-const char* names[40] = {"JSC__JSObject", "WebCore__DOMURL", "WebCore__DOMFormData", "WebCore__FetchHeaders", "SystemError", "JSC__JSCell", "JSC__JSString", "JSC__JSModuleLoader", "JSC__AbortSignal", "JSC__JSPromise", "JSC__JSInternalPromise", "JSC__JSFunction", "JSC__JSGlobalObject", "JSC__JSValue", "JSC__Exception", "JSC__VM", "JSC__ThrowScope", "JSC__CatchScope", "FFI__ptr", "Reader__u8", "Reader__u16", "Reader__u32", "Reader__ptr", "Reader__i8", "Reader__i16", "Reader__i32", "Reader__f32", "Reader__f64", "Reader__i64", "Reader__u64", "Reader__intptr", "Crypto__getRandomValues", "Crypto__randomUUID", "Crypto__timingSafeEqual", "Zig__GlobalObject", "Bun__Path", "ArrayBufferSink", "HTTPSResponseSink", "HTTPResponseSink", "FileSink"};
+const char* names[40] = {"JSC__JSObject", "WebCore__DOMURL", "WebCore__DOMFormData", "WebCore__FetchHeaders", "SystemError", "JSC__JSCell", "JSC__JSString", "JSC__JSModuleLoader", "WebCore__AbortSignal", "JSC__JSPromise", "JSC__JSInternalPromise", "JSC__JSFunction", "JSC__JSGlobalObject", "JSC__JSValue", "JSC__Exception", "JSC__VM", "JSC__ThrowScope", "JSC__CatchScope", "FFI__ptr", "Reader__u8", "Reader__u16", "Reader__u32", "Reader__ptr", "Reader__i8", "Reader__i16", "Reader__i32", "Reader__f32", "Reader__f64", "Reader__i64", "Reader__u64", "Reader__intptr", "Crypto__getRandomValues", "Crypto__randomUUID", "Crypto__timingSafeEqual", "Zig__GlobalObject", "Bun__Path", "ArrayBufferSink", "HTTPSResponseSink", "HTTPResponseSink", "FileSink"};
-const size_t aligns[40] = {alignof(JSC::JSObject), alignof(WebCore::DOMURL), alignof(WebCore::DOMFormData), alignof(WebCore::FetchHeaders), alignof(SystemError), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(JSC::JSModuleLoader), alignof(JSC::AbortSignal), alignof(JSC::JSPromise), alignof(JSC::JSInternalPromise), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(JSC::JSValue), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::CatchScope), alignof(FFI__ptr), alignof(Reader__u8), alignof(Reader__u16), alignof(Reader__u32), alignof(Reader__ptr), alignof(Reader__i8), alignof(Reader__i16), alignof(Reader__i32), alignof(Reader__f32), alignof(Reader__f64), alignof(Reader__i64), alignof(Reader__u64), alignof(Reader__intptr), alignof(Crypto__getRandomValues), alignof(Crypto__randomUUID), alignof(Crypto__timingSafeEqual), alignof(Zig::GlobalObject), alignof(Bun__Path), alignof(ArrayBufferSink), alignof(HTTPSResponseSink), alignof(HTTPResponseSink), alignof(FileSink)};
+const size_t aligns[40] = {alignof(JSC::JSObject), alignof(WebCore::DOMURL), alignof(WebCore::DOMFormData), alignof(WebCore::FetchHeaders), alignof(SystemError), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(JSC::JSModuleLoader), alignof(WebCore::AbortSignal), alignof(JSC::JSPromise), alignof(JSC::JSInternalPromise), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(JSC::JSValue), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::CatchScope), alignof(FFI__ptr), alignof(Reader__u8), alignof(Reader__u16), alignof(Reader__u32), alignof(Reader__ptr), alignof(Reader__i8), alignof(Reader__i16), alignof(Reader__i32), alignof(Reader__f32), alignof(Reader__f64), alignof(Reader__i64), alignof(Reader__u64), alignof(Reader__intptr), alignof(Crypto__getRandomValues), alignof(Crypto__randomUUID), alignof(Crypto__timingSafeEqual), alignof(Zig::GlobalObject), alignof(Bun__Path), alignof(ArrayBufferSink), alignof(HTTPSResponseSink), alignof(HTTPResponseSink), alignof(FileSink)};
diff --git a/src/bun.js/bindings/headers.h b/src/bun.js/bindings/headers.h
index 79a4ef24b..422a71a70 100644
--- a/src/bun.js/bindings/headers.h
+++ b/src/bun.js/bindings/headers.h
@@ -1,5 +1,5 @@
// clang-format off
-//-- AUTOGENERATED FILE -- 1677221832
+//-- AUTOGENERATED FILE -- 1677776166
#pragma once
#include <stddef.h>
@@ -54,8 +54,8 @@ typedef void* JSClassRef;
typedef ErrorableZigString ErrorableZigString;
typedef bJSC__JSObject JSC__JSObject; // JSC::JSObject
typedef WebSocketClient WebSocketClient;
+ typedef struct WebCore__AbortSignal WebCore__AbortSignal; // WebCore::AbortSignal
typedef WebSocketHTTPSClient WebSocketHTTPSClient;
- typedef struct JSC__AbortSignal JSC__AbortSignal; // JSC::AbortSignal
typedef JSClassRef JSClassRef;
typedef bJSC__VM JSC__VM; // JSC::VM
typedef Bun__ArrayBuffer Bun__ArrayBuffer;
@@ -86,7 +86,6 @@ typedef void* JSClassRef;
class JSGlobalObject;
class JSPromise;
class Exception;
- class AbortSignal;
class JSString;
class JSInternalPromise;
class CatchScope;
@@ -97,6 +96,7 @@ typedef void* JSClassRef;
namespace WebCore {
class DOMFormData;
class DOMURL;
+ class AbortSignal;
class FetchHeaders;
}
@@ -118,7 +118,6 @@ typedef void* JSClassRef;
using JSC__JSGlobalObject = JSC::JSGlobalObject;
using JSC__JSPromise = JSC::JSPromise;
using JSC__Exception = JSC::Exception;
- using JSC__AbortSignal = JSC::AbortSignal;
using JSC__JSString = JSC::JSString;
using JSC__JSInternalPromise = JSC::JSInternalPromise;
using JSC__CatchScope = JSC::CatchScope;
@@ -127,6 +126,7 @@ typedef void* JSClassRef;
using JSC__ThrowScope = JSC::ThrowScope;
using WebCore__DOMFormData = WebCore::DOMFormData;
using WebCore__DOMURL = WebCore::DOMURL;
+ using WebCore__AbortSignal = WebCore::AbortSignal;
using WebCore__FetchHeaders = WebCore::FetchHeaders;
#endif
@@ -205,20 +205,20 @@ CPP_DECL void JSC__JSString__toZigString(JSC__JSString* arg0, JSC__JSGlobalObjec
CPP_DECL JSC__JSValue JSC__JSModuleLoader__evaluate(JSC__JSGlobalObject* arg0, const unsigned char* arg1, size_t arg2, const unsigned char* arg3, size_t arg4, const unsigned char* arg5, size_t arg6, JSC__JSValue JSValue7, JSC__JSValue* arg8);
CPP_DECL JSC__JSInternalPromise* JSC__JSModuleLoader__loadAndEvaluateModule(JSC__JSGlobalObject* arg0, const ZigString* arg1);
-#pragma mark - JSC::AbortSignal
-
-CPP_DECL bool JSC__AbortSignal__aborted(JSC__AbortSignal* arg0);
-CPP_DECL JSC__JSValue JSC__AbortSignal__abortReason(JSC__AbortSignal* arg0);
-CPP_DECL JSC__AbortSignal* JSC__AbortSignal__addListener(JSC__AbortSignal* arg0, void* arg1, void(* ArgFn2)(void* arg0, JSC__JSValue JSValue1)) __attribute__((nonnull (2)));
-CPP_DECL void JSC__AbortSignal__cleanNativeBindings(JSC__AbortSignal* arg0, void* arg1);
-CPP_DECL JSC__JSValue JSC__AbortSignal__create(JSC__JSGlobalObject* arg0);
-CPP_DECL JSC__JSValue JSC__AbortSignal__createAbortError(const ZigString* arg0, const ZigString* arg1, JSC__JSGlobalObject* arg2);
-CPP_DECL JSC__JSValue JSC__AbortSignal__createTimeoutError(const ZigString* arg0, const ZigString* arg1, JSC__JSGlobalObject* arg2);
-CPP_DECL JSC__AbortSignal* JSC__AbortSignal__fromJS(JSC__JSValue JSValue0);
-CPP_DECL JSC__AbortSignal* JSC__AbortSignal__ref(JSC__AbortSignal* arg0);
-CPP_DECL JSC__AbortSignal* JSC__AbortSignal__signal(JSC__AbortSignal* arg0, JSC__JSValue JSValue1);
-CPP_DECL JSC__JSValue JSC__AbortSignal__toJS(JSC__AbortSignal* arg0, JSC__JSGlobalObject* arg1);
-CPP_DECL JSC__AbortSignal* JSC__AbortSignal__unref(JSC__AbortSignal* arg0);
+#pragma mark - WebCore::AbortSignal
+
+CPP_DECL bool WebCore__AbortSignal__aborted(WebCore__AbortSignal* arg0);
+CPP_DECL JSC__JSValue WebCore__AbortSignal__abortReason(WebCore__AbortSignal* arg0);
+CPP_DECL WebCore__AbortSignal* WebCore__AbortSignal__addListener(WebCore__AbortSignal* arg0, void* arg1, void(* ArgFn2)(void* arg0, JSC__JSValue JSValue1)) __attribute__((nonnull (2)));
+CPP_DECL void WebCore__AbortSignal__cleanNativeBindings(WebCore__AbortSignal* arg0, void* arg1);
+CPP_DECL JSC__JSValue WebCore__AbortSignal__create(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__JSValue WebCore__AbortSignal__createAbortError(const ZigString* arg0, const ZigString* arg1, JSC__JSGlobalObject* arg2);
+CPP_DECL JSC__JSValue WebCore__AbortSignal__createTimeoutError(const ZigString* arg0, const ZigString* arg1, JSC__JSGlobalObject* arg2);
+CPP_DECL WebCore__AbortSignal* WebCore__AbortSignal__fromJS(JSC__JSValue JSValue0);
+CPP_DECL WebCore__AbortSignal* WebCore__AbortSignal__ref(WebCore__AbortSignal* arg0);
+CPP_DECL WebCore__AbortSignal* WebCore__AbortSignal__signal(WebCore__AbortSignal* arg0, JSC__JSValue JSValue1);
+CPP_DECL JSC__JSValue WebCore__AbortSignal__toJS(WebCore__AbortSignal* arg0, JSC__JSGlobalObject* arg1);
+CPP_DECL WebCore__AbortSignal* WebCore__AbortSignal__unref(WebCore__AbortSignal* arg0);
#pragma mark - JSC::JSPromise
diff --git a/src/bun.js/bindings/headers.zig b/src/bun.js/bindings/headers.zig
index 1e0e56dcb..0c968d362 100644
--- a/src/bun.js/bindings/headers.zig
+++ b/src/bun.js/bindings/headers.zig
@@ -135,18 +135,18 @@ pub extern fn JSC__JSString__toObject(arg0: [*c]bindings.JSString, arg1: *bindin
pub extern fn JSC__JSString__toZigString(arg0: [*c]bindings.JSString, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString) void;
pub extern fn JSC__JSModuleLoader__evaluate(arg0: *bindings.JSGlobalObject, arg1: [*c]const u8, arg2: usize, arg3: [*c]const u8, arg4: usize, arg5: [*c]const u8, arg6: usize, JSValue7: JSC__JSValue, arg8: [*c]bindings.JSValue) JSC__JSValue;
pub extern fn JSC__JSModuleLoader__loadAndEvaluateModule(arg0: *bindings.JSGlobalObject, arg1: [*c]const ZigString) [*c]bindings.JSInternalPromise;
-pub extern fn JSC__AbortSignal__aborted(arg0: ?*bindings.AbortSignal) bool;
-pub extern fn JSC__AbortSignal__abortReason(arg0: ?*bindings.AbortSignal) JSC__JSValue;
-pub extern fn JSC__AbortSignal__addListener(arg0: ?*bindings.AbortSignal, arg1: ?*anyopaque, ArgFn2: ?*const fn (?*anyopaque, JSC__JSValue) callconv(.C) void) ?*bindings.AbortSignal;
-pub extern fn JSC__AbortSignal__cleanNativeBindings(arg0: ?*bindings.AbortSignal, arg1: ?*anyopaque) void;
-pub extern fn JSC__AbortSignal__create(arg0: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__AbortSignal__createAbortError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__AbortSignal__createTimeoutError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__AbortSignal__fromJS(JSValue0: JSC__JSValue) ?*bindings.AbortSignal;
-pub extern fn JSC__AbortSignal__ref(arg0: ?*bindings.AbortSignal) ?*bindings.AbortSignal;
-pub extern fn JSC__AbortSignal__signal(arg0: ?*bindings.AbortSignal, JSValue1: JSC__JSValue) ?*bindings.AbortSignal;
-pub extern fn JSC__AbortSignal__toJS(arg0: ?*bindings.AbortSignal, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__AbortSignal__unref(arg0: ?*bindings.AbortSignal) ?*bindings.AbortSignal;
+pub extern fn WebCore__AbortSignal__aborted(arg0: ?*bindings.AbortSignal) bool;
+pub extern fn WebCore__AbortSignal__abortReason(arg0: ?*bindings.AbortSignal) JSC__JSValue;
+pub extern fn WebCore__AbortSignal__addListener(arg0: ?*bindings.AbortSignal, arg1: ?*anyopaque, ArgFn2: ?*const fn (?*anyopaque, JSC__JSValue) callconv(.C) void) ?*bindings.AbortSignal;
+pub extern fn WebCore__AbortSignal__cleanNativeBindings(arg0: ?*bindings.AbortSignal, arg1: ?*anyopaque) void;
+pub extern fn WebCore__AbortSignal__create(arg0: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern fn WebCore__AbortSignal__createAbortError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern fn WebCore__AbortSignal__createTimeoutError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern fn WebCore__AbortSignal__fromJS(JSValue0: JSC__JSValue) ?*bindings.AbortSignal;
+pub extern fn WebCore__AbortSignal__ref(arg0: ?*bindings.AbortSignal) ?*bindings.AbortSignal;
+pub extern fn WebCore__AbortSignal__signal(arg0: ?*bindings.AbortSignal, JSValue1: JSC__JSValue) ?*bindings.AbortSignal;
+pub extern fn WebCore__AbortSignal__toJS(arg0: ?*bindings.AbortSignal, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern fn WebCore__AbortSignal__unref(arg0: ?*bindings.AbortSignal) ?*bindings.AbortSignal;
pub extern fn JSC__JSPromise__asValue(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject) JSC__JSValue;
pub extern fn JSC__JSPromise__create(arg0: *bindings.JSGlobalObject) ?*bindings.JSPromise;
pub extern fn JSC__JSPromise__isHandled(arg0: [*c]const JSC__JSPromise, arg1: *bindings.VM) bool;
diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp
index f375233dc..46d8a2442 100644
--- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp
+++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp
@@ -701,8 +701,8 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteFunction, (JSC::JSGlobalObject * l
rc = sqlite3_prepare16_v3(db, sqlString.characters16(), sqlString.length() * 2, 0, &statement, nullptr);
}
- if (rc != SQLITE_OK || statement == nullptr) {
- throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errmsg(db))));
+ if (UNLIKELY(rc != SQLITE_OK || statement == nullptr)) {
+ throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, rc == SQLITE_OK ? "Query contained no valid SQL statement; likely empty query."_s : WTF::String::fromUTF8(sqlite3_errmsg(db))));
// sqlite3 handles when the pointer is null
sqlite3_finalize(statement);
return JSValue::encode(JSC::jsUndefined());
@@ -731,7 +731,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteFunction, (JSC::JSGlobalObject * l
rc = sqlite3_step(statement);
}
- if (rc != SQLITE_DONE) {
+ if (UNLIKELY(rc != SQLITE_DONE && rc != SQLITE_OK)) {
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(rc))));
// we finalize after just incase something about error messages in
// sqlite depends on the existence of the most recent statement i don't
@@ -1241,7 +1241,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionAll, (JSC::JSGlob
}
}
- if (UNLIKELY(status != SQLITE_DONE)) {
+ if (UNLIKELY(status != SQLITE_DONE && status != SQLITE_OK)) {
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(status))));
sqlite3_reset(stmt);
return JSValue::encode(jsUndefined());
@@ -1290,7 +1290,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionGet, (JSC::JSGlob
}
}
- if (status == SQLITE_DONE) {
+ if (status == SQLITE_DONE || status == SQLITE_OK) {
RELEASE_AND_RETURN(scope, JSValue::encode(result));
} else {
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(status))));
@@ -1338,7 +1338,7 @@ JSC_DEFINE_JIT_OPERATION(jsSQLStatementExecuteStatementFunctionGetWithoutTypeChe
}
}
- if (status == SQLITE_DONE) {
+ if (status == SQLITE_DONE || status == SQLITE_OK) {
RELEASE_AND_RETURN(scope, JSValue::encode(result));
} else {
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(status))));
@@ -1419,7 +1419,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRows, (JSC::JSGlo
}
}
- if (UNLIKELY(status != SQLITE_DONE)) {
+ if (UNLIKELY(status != SQLITE_DONE && status != SQLITE_OK)) {
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(status))));
sqlite3_reset(stmt);
return JSValue::encode(jsUndefined());
@@ -1465,7 +1465,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRun, (JSC::JSGlob
status = sqlite3_step(stmt);
}
- if (UNLIKELY(status != SQLITE_DONE)) {
+ if (UNLIKELY(status != SQLITE_DONE && status != SQLITE_OK)) {
sqlite3_reset(stmt);
throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(status))));
return JSValue::encode(jsUndefined());
diff --git a/src/bun.js/http.exports.js b/src/bun.js/http.exports.js
index 61bb77e04..d21f768d4 100644
--- a/src/bun.js/http.exports.js
+++ b/src/bun.js/http.exports.js
@@ -1,16 +1,22 @@
const { EventEmitter } = import.meta.require("node:events");
const { Readable, Writable } = import.meta.require("node:stream");
+const { URL } = import.meta.require("node:url");
const { newArrayWithSize, String, Object, Array } = import.meta.primordials;
const globalReportError = globalThis.reportError;
const setTimeout = globalThis.setTimeout;
const fetch = Bun.fetch;
const nop = () => {};
-const debug = process.env.BUN_JS_DEBUG ? (...args) => console.log("node:http", ...args) : nop;
+
+const __DEBUG__ = process.env.__DEBUG__;
+const debug = __DEBUG__ ? (...args) => console.log("node:http", ...args) : nop;
const kEmptyObject = Object.freeze(Object.create(null));
const kOutHeaders = Symbol.for("kOutHeaders");
const kEndCalled = Symbol.for("kEndCalled");
+const kAbortController = Symbol.for("kAbortController");
+const kClearTimeout = Symbol("kClearTimeout");
+
const kCorked = Symbol.for("kCorked");
const searchParamsSymbol = Symbol.for("query"); // This is the symbol used in Node
@@ -233,13 +239,13 @@ export class Server extends EventEmitter {
if (typeof port === "function") {
onListen = port;
} else if (typeof port === "object") {
- port?.signal?.addEventListener("abort", ()=> {
+ port?.signal?.addEventListener("abort", () => {
this.close();
});
host = port?.host;
port = port?.port;
-
+
if (typeof port?.callback === "function") onListen = port?.callback;
}
const ResponseClass = this.#options.ServerResponse || ServerResponse;
@@ -546,8 +552,6 @@ function write_(msg, chunk, encoding, callback, fromEnd) {
return true;
}
-const kClearTimeout = Symbol("kClearTimeout");
-
export class OutgoingMessage extends Writable {
#headers;
headersSent = false;
@@ -559,6 +563,7 @@ export class OutgoingMessage extends Writable {
#fakeSocket;
#timeoutTimer = null;
+ [kAbortController] = null;
// For compat with IncomingRequest
get headers() {
@@ -652,7 +657,6 @@ export class OutgoingMessage extends Writable {
}
}
- // TODO: Use fetch AbortSignal when implemented
setTimeout(msecs, callback) {
if (this.#timeoutTimer) return this;
if (callback) {
@@ -660,8 +664,9 @@ export class OutgoingMessage extends Writable {
}
this.#timeoutTimer = setTimeout(async () => {
- this.emit("timeout");
this.#timeoutTimer = null;
+ this[kAbortController]?.abort();
+ this.emit("timeout");
}, msecs);
return this;
@@ -885,8 +890,6 @@ export class ServerResponse extends Writable {
export class ClientRequest extends OutgoingMessage {
#timeout;
#res = null;
- #aborted = false;
- #timeoutCb = null;
#upgradeOrConnect = false;
#parser = null;
#maxHeadersCount = null;
@@ -903,6 +906,8 @@ export class ClientRequest extends OutgoingMessage {
#body = null;
#fetchRequest;
+ #signal = null;
+ [kAbortController] = null;
#options;
#finished;
@@ -947,12 +952,24 @@ export class ClientRequest extends OutgoingMessage {
_final(callback) {
this.#finished = true;
+ this[kAbortController] = new AbortController();
+ this[kAbortController].signal.addEventListener("abort", () => {
+ this[kClearTimeout]();
+ });
+ if (this.#signal?.aborted) {
+ this[kAbortController].abort();
+ }
+
+ var method = this.#method,
+ body = this.#body;
+
this.#fetchRequest = fetch(`${this.#protocol}//${this.#host}:${this.#port}${this.#path}`, {
- method: this.#method,
+ method,
headers: this.getHeaders(),
- body: this.#body,
+ body: body && method !== "GET" && method !== "HEAD" && method !== "OPTIONS" ? body : undefined,
redirect: "manual",
- verbose: Boolean(process.env.BUN_JS_DEBUG),
+ verbose: Boolean(__DEBUG__),
+ signal: this[kAbortController].signal,
})
.then(response => {
var res = (this.#res = new IncomingMessage(response, {
@@ -961,7 +978,7 @@ export class ClientRequest extends OutgoingMessage {
this.emit("response", res);
})
.catch(err => {
- if (process.env.BUN_JS_DEBUG) globalReportError(err);
+ if (__DEBUG__) globalReportError(err);
this.emit("error", err);
})
.finally(() => {
@@ -970,19 +987,15 @@ export class ClientRequest extends OutgoingMessage {
});
callback();
-
- // TODO: Clear timeout here
}
get aborted() {
- return this.#aborted;
+ return this.#signal?.aborted || !!this[kAbortController]?.signal.aborted;
}
- // TODO: Use fetch AbortSignal when implemented
abort() {
- if (this.#aborted) return;
- this.#aborted = true;
- this[kClearTimeout]();
+ if (this.aborted) return;
+ this[kAbortController].abort();
// TODO: Close stream if body streaming
}
@@ -992,7 +1005,7 @@ export class ClientRequest extends OutgoingMessage {
if (typeof input === "string") {
const urlStr = input;
input = urlToHttpOptions(new URL(urlStr));
- } else if (input && input[searchParamsSymbol] && input[searchParamsSymbol][searchParamsSymbol]) {
+ } else if (input && typeof input === "object" && input instanceof URL) {
// url.URL instance
input = urlToHttpOptions(input);
} else {
@@ -1009,8 +1022,7 @@ export class ClientRequest extends OutgoingMessage {
}
const defaultAgent = options._defaultAgent || Agent.globalAgent;
- const protocol = (this.#protocol = options.protocol || defaultAgent.protocol);
- const expectedProtocol = defaultAgent.protocol;
+ const protocol = (this.#protocol = options.protocol ||= defaultAgent.protocol);
if (options.path) {
const path = String(options.path);
@@ -1021,14 +1033,14 @@ export class ClientRequest extends OutgoingMessage {
}
}
- if (protocol !== expectedProtocol) {
+ // Since we don't implement Agent, we don't need this
+ if (protocol !== "http:" && protocol !== "https:" && protocol) {
+ const expectedProtocol = defaultAgent?.protocol ?? "http:";
throw new Error(`Protocol mismatch. Expected: ${expectedProtocol}. Got: ${protocol}`);
// throw new ERR_INVALID_PROTOCOL(protocol, expectedProtocol);
}
- const defaultPort = options.defaultPort || (this.#agent && this.#agent.defaultPort);
-
- this.#port = options.port = options.port || defaultPort || 80;
+ this.#port = options.port || options.defaultPort || this.#agent?.defaultPort || 80;
const host =
(this.#host =
options.host =
@@ -1038,13 +1050,15 @@ export class ClientRequest extends OutgoingMessage {
this.#socketPath = options.socketPath;
- // if (options.timeout !== undefined)
- // this.timeout = getTimerDuration(options.timeout, "timeout");
+ if (options.timeout !== undefined) this.setTimeout(options.timeout, null);
const signal = options.signal;
if (signal) {
- // TODO: Implement this when AbortSignal binding is available from Zig (required for fetch)
- // addAbortSignal(signal, this);
+ //We still want to control abort function and timeout so signal call our AbortController
+ signal.addEventListener("abort", () => {
+ this[kAbortController]?.abort();
+ });
+ this.#signal = signal;
}
let method = options.method;
const methodIsString = typeof method === "string";
@@ -1091,7 +1105,8 @@ export class ClientRequest extends OutgoingMessage {
this.once("response", cb);
}
- debug(`new ClientRequest: ${this.#method} ${this.#protocol}//${this.#host}:${this.#port}${this.#path}`);
+ __DEBUG__ &&
+ debug(`new ClientRequest: ${this.#method} ${this.#protocol}//${this.#host}:${this.#port}${this.#path}`);
// if (
// method === "GET" ||
@@ -1108,8 +1123,6 @@ export class ClientRequest extends OutgoingMessage {
this.#finished = false;
this.#res = null;
- this.#aborted = false;
- this.#timeoutCb = null;
this.#upgradeOrConnect = false;
this.#parser = null;
this.#maxHeadersCount = null;
@@ -1185,13 +1198,13 @@ export class ClientRequest extends OutgoingMessage {
}
setSocketKeepAlive(enable = true, initialDelay = 0) {
- debug(`${NODE_HTTP_WARNING}\n`, "WARN: ClientRequest.setSocketKeepAlive is a no-op");
+ __DEBUG__ && debug(`${NODE_HTTP_WARNING}\n`, "WARN: ClientRequest.setSocketKeepAlive is a no-op");
}
}
function urlToHttpOptions(url) {
var { protocol, hostname, hash, search, pathname, href, port, username, password } = url;
- const options = {
+ return {
protocol,
hostname:
typeof hostname === "string" && StringPrototypeStartsWith.call(hostname, "[")
@@ -1202,14 +1215,9 @@ function urlToHttpOptions(url) {
pathname,
path: `${pathname || ""}${search || ""}`,
href,
+ port: port ? Number(port) : protocol === "https:" ? 443 : protocol === "http:" ? 80 : undefined,
+ auth: username || password ? `${decodeURIComponent(username)}:${decodeURIComponent(password)}` : undefined,
};
- if (port !== "") {
- options.port = Number(port);
- }
- if (username || password) {
- options.auth = `${decodeURIComponent(username)}:${decodeURIComponent(password)}`;
- }
- return options;
}
function validateHost(host, name) {
diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig
index efa42deb5..445f30233 100644
--- a/src/bun.js/javascript.zig
+++ b/src/bun.js/javascript.zig
@@ -361,6 +361,7 @@ pub const VirtualMachine = struct {
timer: Bun.Timer = Bun.Timer{},
uws_event_loop: ?*uws.Loop = null,
pending_unref_counter: i32 = 0,
+ preload: []const string = &[_][]const u8{},
/// hide bun:wrap from stack traces
/// bun:wrap is very noisy
@@ -990,8 +991,7 @@ pub const VirtualMachine = struct {
)) {
.success => |r| r,
.failure => |e| e,
- .pending => unreachable,
- .not_found => if (!retry_on_not_found)
+ .pending, .not_found => if (!retry_on_not_found)
error.ModuleNotFound
else {
retry_on_not_found = false;
@@ -1441,7 +1441,12 @@ pub const VirtualMachine = struct {
pub fn reloadEntryPoint(this: *VirtualMachine, entry_path: []const u8) !*JSInternalPromise {
this.main = entry_path;
- try this.entry_point.generate(this.bun_watcher != null, Fs.PathName.init(entry_path), main_file_name);
+ try this.entry_point.generate(
+ this.allocator,
+ this.bun_watcher != null,
+ Fs.PathName.init(entry_path),
+ main_file_name,
+ );
this.eventLoop().ensureWaker();
var promise: *JSInternalPromise = undefined;
@@ -1460,6 +1465,72 @@ pub const VirtualMachine = struct {
return promise;
}
+ for (this.preload) |preload| {
+ var result = switch (this.bundler.resolver.resolveAndAutoInstall(
+ this.bundler.fs.top_level_dir,
+ normalizeSource(preload),
+ .stmt,
+ .read_only,
+ )) {
+ .success => |r| r,
+ .failure => |e| {
+ this.log.addErrorFmt(
+ null,
+ logger.Loc.Empty,
+ this.allocator,
+ "{s} resolving preload {any}",
+ .{
+ @errorName(e),
+ js_printer.formatJSONString(preload),
+ },
+ ) catch unreachable;
+ return e;
+ },
+ .pending, .not_found => {
+ this.log.addErrorFmt(
+ null,
+ logger.Loc.Empty,
+ this.allocator,
+ "preload not found {any}",
+ .{
+ js_printer.formatJSONString(preload),
+ },
+ ) catch unreachable;
+ return error.ModuleNotFound;
+ },
+ };
+ promise = JSModuleLoader.loadAndEvaluateModule(this.global, &ZigString.init(result.path().?.text));
+ this.pending_internal_promise = promise;
+
+ // pending_internal_promise can change if hot module reloading is enabled
+ if (this.bun_watcher != null) {
+ this.eventLoop().performGC();
+ switch (this.pending_internal_promise.status(this.global.vm())) {
+ JSC.JSPromise.Status.Pending => {
+ while (this.pending_internal_promise.status(this.global.vm()) == .Pending) {
+ this.eventLoop().tick();
+
+ if (this.pending_internal_promise.status(this.global.vm()) == .Pending) {
+ this.eventLoop().autoTick();
+ }
+ }
+ },
+ else => {},
+ }
+ } else {
+ this.eventLoop().performGC();
+ this.waitForPromise(JSC.AnyPromise{
+ .Internal = promise,
+ });
+ }
+
+ if (promise.status(this.global.vm()) == .Rejected)
+ return promise;
+ }
+
+ // only load preloads once
+ this.preload.len = 0;
+
promise = JSModuleLoader.loadAndEvaluateModule(this.global, ZigString.static(main_file_name));
this.pending_internal_promise = promise;
} else {
diff --git a/src/bun.js/javascript_core_c_api.zig b/src/bun.js/javascript_core_c_api.zig
index a0c9fc29e..32414829b 100644
--- a/src/bun.js/javascript_core_c_api.zig
+++ b/src/bun.js/javascript_core_c_api.zig
@@ -515,7 +515,4 @@ const JSStringIterator_ = extern struct {
write16: JStringIteratorWriteCallback,
};
-// not official api functions
-pub extern "c" fn JSCInitialize() void;
-
pub extern "c" fn JSObjectGetProxyTarget(JSObjectRef) JSObjectRef;
diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig
index 0a7fe2fb6..adfa88cb1 100644
--- a/src/bun.js/module_loader.zig
+++ b/src/bun.js/module_loader.zig
@@ -1585,6 +1585,7 @@ pub const ModuleLoader = struct {
opts.features.dynamic_require = true;
opts.can_import_from_bundle = bundler.options.node_modules_bundle != null;
opts.features.hot_module_reloading = false;
+ opts.features.top_level_await = true;
opts.features.react_fast_refresh = false;
opts.filepath_hash_for_hmr = 0;
opts.warn_about_unbundled_modules = false;
diff --git a/src/bun.js/node-dns.exports.js b/src/bun.js/node-dns.exports.js
index 025728eb6..f7516923a 100644
--- a/src/bun.js/node-dns.exports.js
+++ b/src/bun.js/node-dns.exports.js
@@ -169,9 +169,9 @@ function lookupService(address, port, callback) {
}
var InternalResolver = class Resolver {
- constructor(options) { }
+ constructor(options) {}
- cancel() { }
+ cancel() {}
getServers() {
return [];
@@ -192,11 +192,7 @@ var InternalResolver = class Resolver {
switch (rrtype?.toLowerCase()) {
case "a":
case "aaaa":
- callback(
- null,
- hostname,
- results.map(mapResolveX),
- );
+ callback(null, hostname, results.map(mapResolveX));
break;
default:
callback(null, results);
@@ -221,10 +217,7 @@ var InternalResolver = class Resolver {
dns.lookup(hostname, { family: 4 }).then(
addresses => {
- callback(
- null,
- options?.ttl ? addresses : addresses.map(mapResolveX),
- );
+ callback(null, options?.ttl ? addresses : addresses.map(mapResolveX));
},
error => {
callback(error);
@@ -244,10 +237,7 @@ var InternalResolver = class Resolver {
dns.lookup(hostname, { family: 6 }).then(
addresses => {
- callback(
- null,
- options?.ttl ? addresses : addresses.map(({ address }) => address),
- );
+ callback(null, options?.ttl ? addresses : addresses.map(({ address }) => address));
},
error => {
callback(error);
@@ -397,7 +387,7 @@ var InternalResolver = class Resolver {
callback(null, []);
}
- setServers(servers) { }
+ setServers(servers) {}
};
function resolve(hostname, rrtype, callback) {
@@ -454,8 +444,8 @@ export var {
resolveTxt,
} = InternalResolver.prototype;
-function setDefaultResultOrder() { }
-function setServers() { }
+function setDefaultResultOrder() {}
+function setServers() {}
const promisifyLookup = res => {
res.sort((a, b) => a.family - b.family);
@@ -467,8 +457,7 @@ const mapResolveX = a => a.address;
const promisifyResolveX = res => {
return res?.map(mapResolveX);
-}
-
+};
// promisified versions
export const promises = {
@@ -497,14 +486,14 @@ export const promises = {
if (options?.ttl) {
return dns.lookup(hostname, { family: 4 });
}
- return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX)
+ return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);
},
resolve6(hostname, options) {
if (options?.ttl) {
return dns.lookup(hostname, { family: 6 });
}
- return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX)
+ return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);
},
resolveSrv(hostname) {
@@ -537,9 +526,9 @@ export const promises = {
},
Resolver: class Resolver {
- constructor(options) { }
+ constructor(options) {}
- cancel() { }
+ cancel() {}
getServers() {
return [];
@@ -562,14 +551,14 @@ export const promises = {
if (options?.ttl) {
return dns.lookup(hostname, { family: 4 });
}
- return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX)
+ return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);
}
resolve6(hostname, options) {
if (options?.ttl) {
return dns.lookup(hostname, { family: 6 });
}
- return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX)
+ return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);
}
resolveAny(hostname) {
@@ -616,7 +605,7 @@ export const promises = {
return Promise.resolve([]);
}
- setServers(servers) { }
+ setServers(servers) {}
},
};
for (const key of ["resolveAny", "reverse"]) {
diff --git a/src/bun.js/node-tls.exports.js b/src/bun.js/node-tls.exports.js
index 74a64cca4..46301ae77 100644
--- a/src/bun.js/node-tls.exports.js
+++ b/src/bun.js/node-tls.exports.js
@@ -154,4 +154,5 @@ var exports = {
};
export default exports;
+
export { createSecureContext, parseCertString, TLSSocket, SecureContext };
diff --git a/src/bun.js/node/node_os.zig b/src/bun.js/node/node_os.zig
index 9bf1bbb86..8c59de8a2 100644
--- a/src/bun.js/node/node_os.zig
+++ b/src/bun.js/node/node_os.zig
@@ -67,8 +67,7 @@ pub const Os = struct {
const fields = comptime std.meta.fieldNames(CPUTimes);
const ret = JSC.JSValue.createEmptyObject(globalThis, fields.len);
inline for (fields) |fieldName| {
- ret.put(globalThis, JSC.ZigString.static(fieldName),
- JSC.JSValue.jsNumberFromUint64(@field(self, fieldName)));
+ ret.put(globalThis, JSC.ZigString.static(fieldName), JSC.JSValue.jsNumberFromUint64(@field(self, fieldName)));
}
return ret;
}
@@ -78,27 +77,27 @@ pub const Os = struct {
JSC.markBinding(@src());
return if (comptime Environment.isLinux)
- cpusImplLinux(globalThis) catch {
- const err = JSC.SystemError{
- .message = JSC.ZigString.init("Failed to get cpu information"),
- .code = JSC.ZigString.init(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))),
- };
-
- globalThis.vm().throwError(globalThis, err.toErrorInstance(globalThis));
- return JSC.JSValue.jsUndefined();
- }
- else if (comptime Environment.isMac)
- cpusImplDarwin(globalThis) catch {
- const err = JSC.SystemError{
- .message = JSC.ZigString.init("Failed to get cpu information"),
- .code = JSC.ZigString.init(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))),
- };
-
- globalThis.vm().throwError(globalThis, err.toErrorInstance(globalThis));
- return JSC.JSValue.jsUndefined();
- }
- else
- JSC.JSValue.createEmptyArray(globalThis, 0);
+ cpusImplLinux(globalThis) catch {
+ const err = JSC.SystemError{
+ .message = JSC.ZigString.init("Failed to get cpu information"),
+ .code = JSC.ZigString.init(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))),
+ };
+
+ globalThis.vm().throwError(globalThis, err.toErrorInstance(globalThis));
+ return JSC.JSValue.jsUndefined();
+ }
+ else if (comptime Environment.isMac)
+ cpusImplDarwin(globalThis) catch {
+ const err = JSC.SystemError{
+ .message = JSC.ZigString.init("Failed to get cpu information"),
+ .code = JSC.ZigString.init(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))),
+ };
+
+ globalThis.vm().throwError(globalThis, err.toErrorInstance(globalThis));
+ return JSC.JSValue.jsUndefined();
+ }
+ else
+ JSC.JSValue.createEmptyArray(globalThis, 0);
}
fn cpusImplLinux(globalThis: *JSC.JSGlobalObject) !JSC.JSValue {
@@ -107,7 +106,7 @@ pub const Os = struct {
var num_cpus: u32 = 0;
// Use a large line buffer because the /proc/stat file can have a very long list of interrupts
- var line_buffer: [1024*8]u8 = undefined;
+ var line_buffer: [1024 * 8]u8 = undefined;
// Read /proc/stat to get number of CPUs and times
if (std.fs.openFileAbsolute("/proc/stat", .{})) |file| {
@@ -131,10 +130,10 @@ pub const Os = struct {
var times = CPUTimes{};
times.user = scale * try std.fmt.parseInt(u64, toks.next() orelse return error.eol, 10);
times.nice = scale * try std.fmt.parseInt(u64, toks.next() orelse return error.eol, 10);
- times.sys = scale * try std.fmt.parseInt(u64, toks.next() orelse return error.eol, 10);
+ times.sys = scale * try std.fmt.parseInt(u64, toks.next() orelse return error.eol, 10);
times.idle = scale * try std.fmt.parseInt(u64, toks.next() orelse return error.eol, 10);
_ = try (toks.next() orelse error.eol); // skip iowait
- times.irq = scale * try std.fmt.parseInt(u64, toks.next() orelse return error.eol, 10);
+ times.irq = scale * try std.fmt.parseInt(u64, toks.next() orelse return error.eol, 10);
// Actually create the JS object representing the CPU
const cpu = JSC.JSValue.createEmptyObject(globalThis, 3);
@@ -161,13 +160,11 @@ pub const Os = struct {
const digits = std.mem.trim(u8, line[key_processor.len..], " \t\n");
cpu_index = try std.fmt.parseInt(u32, digits, 10);
if (cpu_index >= num_cpus) return error.too_may_cpus;
-
} else if (std.mem.startsWith(u8, line, key_model_name)) {
// If this is the model name, extract it and store on the current cpu
const model_name = line[key_model_name.len..];
const cpu = JSC.JSObject.getIndex(values, globalThis, cpu_index);
- cpu.put(globalThis, JSC.ZigString.static("model"),
- JSC.ZigString.init(model_name).withEncoding().toValueGC(globalThis));
+ cpu.put(globalThis, JSC.ZigString.static("model"), JSC.ZigString.init(model_name).withEncoding().toValueGC(globalThis));
}
//TODO: special handling for ARM64 (no model name)?
}
@@ -175,8 +172,7 @@ pub const Os = struct {
// Initialize model name to "unknown"
var it = values.arrayIterator(globalThis);
while (it.next()) |cpu| {
- cpu.put(globalThis, JSC.ZigString.static("model"),
- JSC.ZigString.static("unknown").withEncoding().toValue(globalThis));
+ cpu.put(globalThis, JSC.ZigString.static("model"), JSC.ZigString.static("unknown").withEncoding().toValue(globalThis));
}
}
@@ -212,11 +208,7 @@ pub const Os = struct {
var num_cpus: c.natural_t = 0;
var info: [*]local_bindings.processor_cpu_load_info = undefined;
var info_size: std.c.mach_msg_type_number_t = 0;
- if (local_bindings.host_processor_info(
- std.c.mach_host_self(),
- local_bindings.PROCESSOR_CPU_LOAD_INFO,
- &num_cpus, @ptrCast(*local_bindings.processor_info_array_t, &info),
- &info_size) != .SUCCESS) {
+ if (local_bindings.host_processor_info(std.c.mach_host_self(), local_bindings.PROCESSOR_CPU_LOAD_INFO, &num_cpus, @ptrCast(*local_bindings.processor_info_array_t, &info), &info_size) != .SUCCESS) {
return error.no_processor_info;
}
defer _ = std.c.vm_deallocate(std.c.mach_task_self(), @ptrToInt(info), info_size);
@@ -226,13 +218,13 @@ pub const Os = struct {
return error.broken_process_info;
}
-
// Get CPU model name
var model_name_buf: [512]u8 = undefined;
var len: usize = model_name_buf.len;
// Try brand_string first and if it fails try hw.model
if (!(std.c.sysctlbyname("machdep.cpu.brand_string", &model_name_buf, &len, null, 0) == 0 or
- std.c.sysctlbyname("hw.model", &model_name_buf, &len, null, 0) == 0)) {
+ std.c.sysctlbyname("hw.model", &model_name_buf, &len, null, 0) == 0))
+ {
return error.no_processor_info;
}
//NOTE: sysctlbyname doesn't update len if it was large enough, so we
@@ -240,7 +232,6 @@ pub const Os = struct {
// model name.
const model_name = JSC.ZigString.init(std.mem.sliceTo(&model_name_buf, 0)).withEncoding().toValueGC(globalThis);
-
// Get CPU speed
var speed: u64 = 0;
len = @sizeOf(@TypeOf(speed));
@@ -252,9 +243,10 @@ pub const Os = struct {
speed = 2_400_000_000;
}
-
// Get the multiplier; this is the number of ms/tick
- const unistd = @cImport({@cInclude("unistd.h");});
+ const unistd = @cImport({
+ @cInclude("unistd.h");
+ });
const ticks: i64 = unistd.sysconf(unistd._SC_CLK_TCK);
const multiplier = 1000 / @intCast(u64, ticks);
@@ -265,9 +257,9 @@ pub const Os = struct {
const times = CPUTimes{
.user = info[cpu_index].cpu_ticks[0] * multiplier,
.nice = info[cpu_index].cpu_ticks[3] * multiplier,
- .sys = info[cpu_index].cpu_ticks[1] * multiplier,
+ .sys = info[cpu_index].cpu_ticks[1] * multiplier,
.idle = info[cpu_index].cpu_ticks[2] * multiplier,
- .irq = 0, // not available
+ .irq = 0, // not available
};
const cpu = JSC.JSValue.createEmptyObject(globalThis, 3);
@@ -397,7 +389,6 @@ pub const Os = struct {
}
defer C.freeifaddrs(interface_start);
-
const helpers = struct {
// We'll skip interfaces that aren't actually available
pub fn skip(iface: *C.ifaddrs) bool {
@@ -414,10 +405,11 @@ pub const Os = struct {
pub fn isLinkLayer(iface: *C.ifaddrs) bool {
if (iface.ifa_addr == null) return false;
return if (comptime Environment.isLinux)
- return iface.ifa_addr.*.sa_family == std.os.AF.PACKET
- else if (comptime Environment.isMac)
- return iface.ifa_addr.?.*.family == std.os.AF.LINK
- else unreachable;
+ return iface.ifa_addr.*.sa_family == std.os.AF.PACKET
+ else if (comptime Environment.isMac)
+ return iface.ifa_addr.?.*.family == std.os.AF.LINK
+ else
+ unreachable;
}
pub fn isLoopback(iface: *C.ifaddrs) bool {
@@ -425,7 +417,6 @@ pub const Os = struct {
}
};
-
// The list currently contains entries for link-layer interfaces
// and the IPv4, IPv6 interfaces. We only want to return the latter two
// but need the link-layer entries to determine MAC address.
@@ -459,7 +450,7 @@ pub const Os = struct {
const maybe_suffix: ?u8 = switch (addr.any.family) {
std.os.AF.INET => netmaskToCIDRSuffix(netmask.in.sa.addr),
std.os.AF.INET6 => netmaskToCIDRSuffix(@bitCast(u128, netmask.in6.sa.addr)),
- else => null
+ else => null,
};
// Format the address and then, if valid, the CIDR suffix; both
@@ -472,14 +463,13 @@ pub const Os = struct {
//NOTE addr_str might not start at buf[0] due to slicing in formatAddress
const start = @ptrToInt(addr_str.ptr) - @ptrToInt(&buf[0]);
// Start writing the suffix immediately after the address
- const suffix_str = std.fmt.bufPrint(buf[start + addr_str.len..], "/{}", .{ suffix }) catch unreachable;
+ const suffix_str = std.fmt.bufPrint(buf[start + addr_str.len ..], "/{}", .{suffix}) catch unreachable;
// The full cidr value is the address + the suffix
- const cidr_str = buf[start..start + addr_str.len + suffix_str.len];
+ const cidr_str = buf[start .. start + addr_str.len + suffix_str.len];
cidr = JSC.ZigString.init(cidr_str).withEncoding().toValueGC(globalThis);
}
- interface.put(globalThis, JSC.ZigString.static("address"),
- JSC.ZigString.init(addr_str).withEncoding().toValueGC(globalThis));
+ interface.put(globalThis, JSC.ZigString.static("address"), JSC.ZigString.init(addr_str).withEncoding().toValueGC(globalThis));
interface.put(globalThis, JSC.ZigString.static("cidr"), cidr);
}
@@ -487,18 +477,15 @@ pub const Os = struct {
{
var buf: [64]u8 = undefined;
const str = formatAddress(netmask, &buf) catch unreachable;
- interface.put(globalThis, JSC.ZigString.static("netmask"),
- JSC.ZigString.init(str).withEncoding().toValueGC(globalThis));
+ interface.put(globalThis, JSC.ZigString.static("netmask"), JSC.ZigString.init(str).withEncoding().toValueGC(globalThis));
}
// family <string> Either IPv4 or IPv6
- interface.put(globalThis, JSC.ZigString.static("family"),
- (switch (addr.any.family) {
- std.os.AF.INET => JSC.ZigString.static("IPv4"),
- std.os.AF.INET6 => JSC.ZigString.static("IPv6"),
- else => JSC.ZigString.static("unknown"),
- }).toValue(globalThis)
- );
+ interface.put(globalThis, JSC.ZigString.static("family"), (switch (addr.any.family) {
+ std.os.AF.INET => JSC.ZigString.static("IPv4"),
+ std.os.AF.INET6 => JSC.ZigString.static("IPv6"),
+ else => JSC.ZigString.static("unknown"),
+ }).toValue(globalThis));
// mac <string> The MAC address of the network interface
{
@@ -524,32 +511,23 @@ pub const Os = struct {
// Encode its link-layer address. We need 2*6 bytes for the
// hex characters and 5 for the colon separators
var mac_buf: [17]u8 = undefined;
- var addr_data = if (comptime Environment.isLinux) ll_addr.addr
- else if (comptime Environment.isMac) ll_addr.sdl_data[ll_addr.sdl_nlen..]
- else unreachable;
- const mac = std.fmt.bufPrint(&mac_buf,
- "{x:0>2}:{x:0>2}:{x:0>2}:{x:0>2}:{x:0>2}:{x:0>2}",
- .{
- addr_data[0], addr_data[1], addr_data[2],
- addr_data[3], addr_data[4], addr_data[5],
- }
- ) catch unreachable;
- interface.put(globalThis, JSC.ZigString.static("mac"),
- JSC.ZigString.init(mac).withEncoding().toValueGC(globalThis));
+ var addr_data = if (comptime Environment.isLinux) ll_addr.addr else if (comptime Environment.isMac) ll_addr.sdl_data[ll_addr.sdl_nlen..] else unreachable;
+ const mac = std.fmt.bufPrint(&mac_buf, "{x:0>2}:{x:0>2}:{x:0>2}:{x:0>2}:{x:0>2}:{x:0>2}", .{
+ addr_data[0], addr_data[1], addr_data[2],
+ addr_data[3], addr_data[4], addr_data[5],
+ }) catch unreachable;
+ interface.put(globalThis, JSC.ZigString.static("mac"), JSC.ZigString.init(mac).withEncoding().toValueGC(globalThis));
}
}
// internal <boolean> true if the network interface is a loopback or similar interface that is not remotely accessible; otherwise false
- interface.put(globalThis, JSC.ZigString.static("internal"),
- JSC.JSValue.jsBoolean(helpers.isLoopback(iface)));
+ interface.put(globalThis, JSC.ZigString.static("internal"), JSC.JSValue.jsBoolean(helpers.isLoopback(iface)));
// scopeid <number> The numeric IPv6 scope ID (only specified when family is IPv6)
if (addr.any.family == std.os.AF.INET6) {
- interface.put(globalThis, JSC.ZigString.static("scope_id"),
- JSC.JSValue.jsNumber(addr.in6.sa.scope_id));
+ interface.put(globalThis, JSC.ZigString.static("scope_id"), JSC.JSValue.jsNumber(addr.in6.sa.scope_id));
}
-
// Does this entry already exist?
if (ret.get(globalThis, interface_name)) |array| {
// Add this interface entry to the existing array
@@ -567,7 +545,6 @@ pub const Os = struct {
return ret;
}
-
pub fn platform(globalThis: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
JSC.markBinding(@src());
@@ -656,7 +633,8 @@ pub const Os = struct {
break :brk systemdir_ ++ "\\temp";
}
} else {
- break :brk bun.asByteSlice(bun.getenvZ("TMPDIR") orelse bun.getenvZ("TMP") orelse bun.getenvZ("TEMP") orelse "/tmp");
+ const dir = bun.asByteSlice(bun.getenvZ("TMPDIR") orelse bun.getenvZ("TMP") orelse bun.getenvZ("TEMP") orelse "/tmp");
+ break :brk strings.withoutTrailingSlash(dir);
}
break :brk "unknown";
@@ -756,8 +734,8 @@ fn formatAddress(address: std.net.Address, into: []u8) ![]u8 {
result = result[0..colon];
}
// Strip brackets
- if (result[0] == '[' and result[result.len-1] == ']') {
- result = result[1..result.len-1];
+ if (result[0] == '[' and result[result.len - 1] == ']') {
+ result = result[1 .. result.len - 1];
}
return result;
}
@@ -782,20 +760,20 @@ test "netmaskToCIDRSuffix" {
.{ "255.255.255.254", 31 },
.{ "255.255.255.252", 30 },
.{ "255.255.255.128", 25 },
- .{ "255.255.255.0", 24 },
- .{ "255.255.128.0", 17 },
- .{ "255.255.0.0", 16 },
- .{ "255.128.0.0", 9 },
- .{ "255.0.0.0", 8 },
- .{ "224.0.0.0", 3 },
- .{ "192.0.0.0", 2 },
- .{ "128.0.0.0", 1 },
- .{ "0.0.0.0", 0 },
+ .{ "255.255.255.0", 24 },
+ .{ "255.255.128.0", 17 },
+ .{ "255.255.0.0", 16 },
+ .{ "255.128.0.0", 9 },
+ .{ "255.0.0.0", 8 },
+ .{ "224.0.0.0", 3 },
+ .{ "192.0.0.0", 2 },
+ .{ "128.0.0.0", 1 },
+ .{ "0.0.0.0", 0 },
// invalid masks
.{ "255.0.0.255", null },
.{ "128.0.0.255", null },
- .{ "128.0.0.1", null },
+ .{ "128.0.0.1", null },
};
inline for (ipv4_tests) |t| {
const addr = try std.net.Address.parseIp4(t[0], 0);
@@ -804,12 +782,12 @@ test "netmaskToCIDRSuffix" {
const ipv6_tests = .{
.{ "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", 128 },
- .{ "ffff:ffff:ffff:ffff::", 64 },
- .{ "::", 0 },
+ .{ "ffff:ffff:ffff:ffff::", 64 },
+ .{ "::", 0 },
// invalid masks
- .{ "ff00:1::", null },
- .{ "0:1::", null },
+ .{ "ff00:1::", null },
+ .{ "0:1::", null },
};
inline for (ipv6_tests) |t| {
const addr = try std.net.Address.parseIp6(t[0], 0);
diff --git a/src/bun.js/wasi-runner.js b/src/bun.js/wasi-runner.js
index 24ff0a678..6a89510b1 100644
--- a/src/bun.js/wasi-runner.js
+++ b/src/bun.js/wasi-runner.js
@@ -3,21 +3,14 @@
const filePath = process.argv.at(1);
if (!filePath) {
- var err = new Error(
- "To run a wasm file with Bun, the first argument must be a path to a .wasm file",
- );
+ var err = new Error("To run a wasm file with Bun, the first argument must be a path to a .wasm file");
err.name = "WasmFileNotFound";
throw err;
}
// The module specifier is the resolved path to the wasm file
-var {
- WASM_CWD = process.cwd(),
- WASM_ROOT_DIR = "/",
- WASM_ENV_STR = undefined,
- WASM_USE_ASYNC_INIT = "",
-} = process.env;
+var { WASM_CWD = process.cwd(), WASM_ROOT_DIR = "/", WASM_ENV_STR = undefined, WASM_USE_ASYNC_INIT = "" } = process.env;
var env = process.env;
if (WASM_ENV_STR?.length) {
diff --git a/src/bun.js/webcore.zig b/src/bun.js/webcore.zig
index ebb81f928..c65c02ffd 100644
--- a/src/bun.js/webcore.zig
+++ b/src/bun.js/webcore.zig
@@ -8,6 +8,7 @@ pub usingnamespace @import("./webcore/body.zig");
const JSC = @import("bun").JSC;
const std = @import("std");
const bun = @import("bun");
+pub const AbortSignal = @import("./bindings/bindings.zig").AbortSignal;
pub const Lifetime = enum {
clone,
diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig
index 9e5ad4ec2..ae60ef01f 100644
--- a/src/bun.js/webcore/blob.zig
+++ b/src/bun.js/webcore/blob.zig
@@ -73,6 +73,8 @@ const PathOrBlob = union(enum) {
};
pub const Blob = struct {
+ const bloblog = Output.scoped(.Blob, false);
+
pub usingnamespace JSC.Codegen.JSBlob;
size: SizeType = 0,
@@ -435,6 +437,7 @@ pub const Blob = struct {
},
// .InlineBlob,
.InternalBlob,
+ .Null,
.Empty,
.Blob,
=> {
@@ -665,6 +668,7 @@ pub const Blob = struct {
.Used,
.Empty,
.Blob,
+ .Null,
=> {
break :brk response.body.use();
},
@@ -699,6 +703,7 @@ pub const Blob = struct {
.Used,
.Empty,
.Blob,
+ .Null,
=> {
break :brk request.body.use();
},
@@ -1428,9 +1433,10 @@ pub const Blob = struct {
this.doClose();
}
- var io_task = this.io_task.?;
- this.io_task = null;
- io_task.onFinish();
+ if (this.io_task) |io_task| {
+ io_task.onFinish();
+ this.io_task = null;
+ }
}
fn resolveSize(this: *ReadFile, fd: bun.FileDescriptor) void {
@@ -1652,9 +1658,10 @@ pub const Blob = struct {
this.doClose();
}
- var io_task = this.io_task.?;
- this.io_task = null;
- io_task.onFinish();
+ if (this.io_task) |io_task| {
+ io_task.onFinish();
+ this.io_task = null;
+ }
}
fn runWithFD(this: *WriteFile, fd: bun.FileDescriptor) void {
@@ -2822,6 +2829,8 @@ pub const Blob = struct {
}
pub fn doReadFile(this: *Blob, comptime Function: anytype, global: *JSGlobalObject) JSValue {
+ bloblog("doReadFile", .{});
+
const Handler = NewReadFileHandler(Function);
var promise = JSPromise.create(global);
@@ -2846,6 +2855,7 @@ pub const Blob = struct {
) catch unreachable;
var read_file_task = Store.ReadFile.ReadFileTask.createOnJSThread(bun.default_allocator, global, file_read) catch unreachable;
read_file_task.schedule();
+ bloblog("doReadFile: read_file_task scheduled", .{});
return promise_value;
}
@@ -3006,12 +3016,13 @@ pub const Blob = struct {
}
pub fn toArrayBuffer(this: *Blob, global: *JSGlobalObject, comptime lifetime: Lifetime) JSValue {
+ bloblog("toArrayBuffer", .{});
if (this.needsToReadFile()) {
return this.doReadFile(toArrayBufferWithBytes, global);
}
var view_ = this.sharedView();
-
+ bloblog("sharedView {d}", .{view_.len});
if (view_.len == 0)
return JSC.ArrayBuffer.create(global, "", .ArrayBuffer);
diff --git a/src/bun.js/webcore/body.zig b/src/bun.js/webcore/body.zig
index f76587f74..97c9f7874 100644
--- a/src/bun.js/webcore/body.zig
+++ b/src/bun.js/webcore/body.zig
@@ -294,6 +294,7 @@ pub const Body = struct {
Used: void,
Empty: void,
Error: JSValue,
+ Null: void,
pub fn toBlobIfPossible(this: *Value) void {
if (this.* != .Locked)
@@ -355,6 +356,7 @@ pub const Body = struct {
Used,
Empty,
Error,
+ Null,
};
// pub const empty = Value{ .Empty = void{} };
@@ -363,12 +365,12 @@ pub const Body = struct {
JSC.markBinding(@src());
switch (this.*) {
- .Empty => {
- return JSValue.jsNull();
- },
- .Used => {
+ .Used, .Empty => {
return JSC.WebCore.ReadableStream.empty(globalThis);
},
+ .Null => {
+ return JSValue.null;
+ },
.InternalBlob,
.Blob,
// .InlineBlob,
@@ -436,12 +438,15 @@ pub const Body = struct {
}
}
- pub fn fromJS(globalThis: *JSGlobalObject, value: JSValue) ?Value {
+ pub fn fromJS(
+ globalThis: *JSGlobalObject,
+ value: JSValue,
+ ) ?Value {
value.ensureStillAlive();
if (value.isEmptyOrUndefinedOrNull()) {
return Body.Value{
- .Empty = void{},
+ .Null = void{},
};
}
@@ -976,10 +981,6 @@ pub fn BodyMixin(comptime Type: type) type {
) callconv(.C) JSValue {
var body: *Body.Value = this.getBodyValue();
- if (body.* == .Empty) {
- return JSValue.jsNull();
- }
-
if (body.* == .Used) {
// TODO: make this closed
return JSC.WebCore.ReadableStream.empty(globalThis);
@@ -1001,7 +1002,6 @@ pub fn BodyMixin(comptime Type: type) type {
_: *JSC.CallFrame,
) callconv(.C) JSC.JSValue {
var value: *Body.Value = this.getBodyValue();
-
if (value.* == .Used) {
return handleBodyAlreadyUsed(globalObject);
}
diff --git a/src/bun.js/webcore/request.zig b/src/bun.js/webcore/request.zig
index 1a3bc1e4c..e1fa4a9bb 100644
--- a/src/bun.js/webcore/request.zig
+++ b/src/bun.js/webcore/request.zig
@@ -12,7 +12,7 @@ const js = JSC.C;
const Method = @import("../../http/method.zig").Method;
const FetchHeaders = JSC.FetchHeaders;
-const AbortSignal = JSC.AbortSignal;
+const AbortSignal = JSC.WebCore.AbortSignal;
const ObjectPool = @import("../../pool.zig").ObjectPool;
const SystemError = JSC.SystemError;
const Output = @import("bun").Output;
@@ -189,7 +189,7 @@ pub const Request = struct {
},
.InternalBlob => return this.body.InternalBlob.contentType(),
// .InlineBlob => return this.body.InlineBlob.contentType(),
- .Error, .Used, .Locked, .Empty => return MimeType.other.value,
+ .Null, .Error, .Used, .Locked, .Empty => return MimeType.other.value,
}
}
@@ -395,6 +395,9 @@ pub const Request = struct {
return null;
}).slice();
request.url_was_allocated = request.url.len > 0;
+ request.body = .{
+ .Null = {},
+ };
} else {
if (Body.Init.init(getAllocator(globalThis), globalThis, arguments[0], url_or_object_type) catch null) |req_init| {
request.headers = req_init.headers;
@@ -408,6 +411,10 @@ pub const Request = struct {
request.finalizeWithoutDeinit();
return null;
}
+ } else {
+ request.body = .{
+ .Null = {},
+ };
}
if (urlOrObject.fastGet(globalThis, .url)) |url| {
@@ -444,6 +451,10 @@ pub const Request = struct {
request.finalizeWithoutDeinit();
return null;
}
+ } else {
+ request.body = .{
+ .Null = {},
+ };
}
request.url = (arguments[0].toSlice(globalThis, bun.default_allocator).cloneIfNeeded(bun.default_allocator) catch {
diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig
index 96b7e2409..06323d790 100644
--- a/src/bun.js/webcore/response.zig
+++ b/src/bun.js/webcore/response.zig
@@ -331,7 +331,7 @@ pub const Response = struct {
return response.body.value.InternalBlob.contentType();
},
- .Used, .Locked, .Empty, .Error => return default.value,
+ .Null, .Used, .Locked, .Empty, .Error => return default.value,
}
}
@@ -625,7 +625,7 @@ pub const Fetch = struct {
/// We always clone url and proxy (if informed)
url_proxy_buffer: []const u8 = "",
- signal: ?*JSC.AbortSignal = null,
+ signal: ?*JSC.WebCore.AbortSignal = null,
aborted: std.atomic.Atomic(bool) = std.atomic.Atomic(bool).init(false),
// must be stored because AbortSignal stores reason weakly
@@ -715,12 +715,12 @@ pub const Fetch = struct {
if (this.result.isTimeout()) {
// Timeout without reason
- return JSC.AbortSignal.createTimeoutError(JSC.ZigString.static("The operation timed out"), &JSC.ZigString.Empty, this.global_this);
+ return JSC.WebCore.AbortSignal.createTimeoutError(JSC.ZigString.static("The operation timed out"), &JSC.ZigString.Empty, this.global_this);
}
if (this.result.isAbort()) {
// Abort without reason
- return JSC.AbortSignal.createAbortError(JSC.ZigString.static("The user aborted a request"), &JSC.ZigString.Empty, this.global_this);
+ return JSC.WebCore.AbortSignal.createAbortError(JSC.ZigString.static("The user aborted a request"), &JSC.ZigString.Empty, this.global_this);
}
const fetch_error = JSC.SystemError{
@@ -864,7 +864,7 @@ pub const Fetch = struct {
follow_redirects: bool = true,
proxy: ?ZigURL = null,
url_proxy_buffer: []const u8 = "",
- signal: ?*JSC.AbortSignal = null,
+ signal: ?*JSC.WebCore.AbortSignal = null,
globalThis: ?*JSGlobalObject,
};
@@ -928,7 +928,7 @@ pub const Fetch = struct {
var verbose = false;
var proxy: ?ZigURL = null;
var follow_redirects = true;
- var signal: ?*JSC.AbortSignal = null;
+ var signal: ?*JSC.WebCore.AbortSignal = null;
var url_proxy_buffer: []const u8 = undefined;
@@ -998,7 +998,7 @@ pub const Fetch = struct {
verbose = verb.toBoolean();
}
if (options.get(globalThis, "signal")) |signal_arg| {
- if (signal_arg.as(JSC.AbortSignal)) |signal_| {
+ if (signal_arg.as(JSC.WebCore.AbortSignal)) |signal_| {
_ = signal_.ref();
signal = signal_;
}
@@ -1117,7 +1117,7 @@ pub const Fetch = struct {
verbose = verb.toBoolean();
}
if (options.get(globalThis, "signal")) |signal_arg| {
- if (signal_arg.as(JSC.AbortSignal)) |signal_| {
+ if (signal_arg.as(JSC.WebCore.AbortSignal)) |signal_| {
_ = signal_.ref();
signal = signal_;
}
diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig
index 0a38c7ed0..1de209b69 100644
--- a/src/bun.js/webcore/streams.zig
+++ b/src/bun.js/webcore/streams.zig
@@ -2758,7 +2758,7 @@ pub fn HTTPServerWritable(comptime ssl: bool) type {
return Sink.init(this);
}
- pub fn onAborted(this: *@This(), _: *UWSResponse) void {
+ pub fn abort(this: *@This()) void {
log("onAborted()", .{});
this.signal.close(null);
this.done = true;
diff --git a/src/bun_js.zig b/src/bun_js.zig
index 2b3e514e6..f13568390 100644
--- a/src/bun_js.zig
+++ b/src/bun_js.zig
@@ -44,14 +44,19 @@ pub const Run = struct {
arena: Arena = undefined,
any_unhandled: bool = false,
- pub fn boot(ctx: Command.Context, file: std.fs.File, entry_path: string) !void {
+ pub fn boot(ctx_: Command.Context, file: std.fs.File, entry_path: string) !void {
+ var ctx = ctx_;
JSC.markBinding(@src());
- @import("bun.js/javascript_core_c_api.zig").JSCInitialize();
+ bun.JSC.initialize();
js_ast.Expr.Data.Store.create(default_allocator);
js_ast.Stmt.Data.Store.create(default_allocator);
var arena = try Arena.init();
+ if (!ctx.debug.loaded_bunfig) {
+ try bun.CLI.Arguments.loadConfigPath(ctx.allocator, true, "bunfig.toml", &ctx, .RunCommand);
+ }
+
run = .{
.vm = try VirtualMachine.init(arena.allocator(), ctx.args, null, ctx.log, null),
.file = file,
@@ -59,9 +64,10 @@ pub const Run = struct {
.ctx = ctx,
.entry_path = entry_path,
};
+
var vm = run.vm;
var b = &vm.bundler;
-
+ vm.preload = ctx.preloads;
vm.argv = ctx.passthrough;
vm.arena = &run.arena;
vm.allocator = arena.allocator();
@@ -144,23 +150,35 @@ pub const Run = struct {
if (this.ctx.debug.hot_reload) {
JSC.HotReloader.enableHotModuleReloading(vm);
}
- var promise = vm.loadEntryPoint(this.entry_path) catch return;
-
- if (promise.status(vm.global.vm()) == .Rejected) {
- vm.runErrorHandler(promise.result(vm.global.vm()), null);
- Global.exit(1);
- }
+ if (vm.loadEntryPoint(this.entry_path)) |promise| {
+ if (promise.status(vm.global.vm()) == .Rejected) {
+ vm.runErrorHandler(promise.result(vm.global.vm()), null);
+ Global.exit(1);
+ }
- _ = promise.result(vm.global.vm());
+ _ = promise.result(vm.global.vm());
- if (vm.log.msgs.items.len > 0) {
- if (Output.enable_ansi_colors) {
- vm.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true) catch {};
+ if (vm.log.msgs.items.len > 0) {
+ if (Output.enable_ansi_colors) {
+ vm.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true) catch {};
+ } else {
+ vm.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false) catch {};
+ }
+ Output.prettyErrorln("\n", .{});
+ Output.flush();
+ }
+ } else |err| {
+ if (vm.log.msgs.items.len > 0) {
+ if (Output.enable_ansi_colors) {
+ vm.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true) catch {};
+ } else {
+ vm.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false) catch {};
+ }
+ Output.flush();
} else {
- vm.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false) catch {};
+ Output.prettyErrorln("Error occurred loading entry point: {s}", .{@errorName(err)});
}
- Output.prettyErrorln("\n", .{});
- Output.flush();
+ Global.exit(1);
}
// don't run the GC if we don't actually need to
diff --git a/src/bundler/entry_points.zig b/src/bundler/entry_points.zig
index a501bcddb..a4068d2af 100644
--- a/src/bundler/entry_points.zig
+++ b/src/bundler/entry_points.zig
@@ -157,12 +157,11 @@ pub const ClientEntryPoint = struct {
};
pub const ServerEntryPoint = struct {
- code_buffer: [bun.MAX_PATH_BYTES * 2 + 500]u8 = undefined,
- output_code_buffer: [bun.MAX_PATH_BYTES * 8 + 500]u8 = undefined,
source: logger.Source = undefined,
pub fn generate(
entry: *ServerEntryPoint,
+ allocator: std.mem.Allocator,
is_hot_reload_enabled: bool,
original_path: Fs.PathName,
name: string,
@@ -182,8 +181,8 @@ pub const ServerEntryPoint = struct {
const code = brk: {
if (is_hot_reload_enabled) {
- break :brk try std.fmt.bufPrint(
- &entry.code_buffer,
+ break :brk try std.fmt.allocPrint(
+ allocator,
\\//Auto-generated file
\\var cjsSymbol = Symbol.for("CommonJS");
\\var hmrSymbol = Symbol.for("BunServerHMR");
@@ -225,8 +224,8 @@ pub const ServerEntryPoint = struct {
},
);
}
- break :brk try std.fmt.bufPrint(
- &entry.code_buffer,
+ break :brk try std.fmt.allocPrint(
+ allocator,
\\//Auto-generated file
\\var cjsSymbol = Symbol.for("CommonJS");
\\import * as start from '{s}{s}';
diff --git a/src/bunfig.zig b/src/bunfig.zig
index 4a341ef20..c6ecb7c10 100644
--- a/src/bunfig.zig
+++ b/src/bunfig.zig
@@ -169,6 +169,22 @@ pub const Bunfig = struct {
}
}
}
+
+ if (json.get("preload")) |expr| {
+ if (expr.asArray()) |array_| {
+ var array = array_;
+ var preloads = try std.ArrayList(string).initCapacity(allocator, array.array.items.len);
+ errdefer preloads.deinit();
+ while (array.next()) |item| {
+ try this.expect(item, .e_string);
+ if (item.data.e_string.len() > 0)
+ preloads.appendAssumeCapacity(try item.data.e_string.string(allocator));
+ }
+ this.ctx.preloads = preloads.items;
+ } else if (expr.data != .e_null) {
+ try this.addError(expr.loc, "Expected preload to be an array");
+ }
+ }
}
if (comptime cmd == .DevCommand or cmd == .AutoCommand) {
@@ -196,6 +212,22 @@ pub const Bunfig = struct {
if (test_.get("root")) |root| {
this.ctx.debug.test_directory = root.asString(this.allocator) orelse "";
}
+
+ if (test_.get("preload")) |expr| {
+ if (expr.asArray()) |array_| {
+ var array = array_;
+ var preloads = try std.ArrayList(string).initCapacity(allocator, array.array.items.len);
+ errdefer preloads.deinit();
+ while (array.next()) |item| {
+ try this.expect(item, .e_string);
+ if (item.data.e_string.len() > 0)
+ preloads.appendAssumeCapacity(try item.data.e_string.string(allocator));
+ }
+ this.ctx.preloads = preloads.items;
+ } else if (expr.data != .e_null) {
+ try this.addError(expr.loc, "Expected preload to be an array");
+ }
+ }
}
}
diff --git a/src/cli.zig b/src/cli.zig
index 33569c33e..e05bd113d 100644
--- a/src/cli.zig
+++ b/src/cli.zig
@@ -177,6 +177,7 @@ pub const Arguments = struct {
clap.parseParam("--jsx-import-source <STR> Declares the module specifier to be used for importing the jsx and jsxs factory functions. Default: \"react\"") catch unreachable,
clap.parseParam("--jsx-production Use jsx instead of jsxDEV (default) for the automatic runtime") catch unreachable,
clap.parseParam("--jsx-runtime <STR> \"automatic\" (default) or \"classic\"") catch unreachable,
+ clap.parseParam("-r, --preload <STR>... Import a module before other modules are loaded") catch unreachable,
clap.parseParam("--main-fields <STR>... Main fields to lookup in package.json. Defaults to --platform dependent") catch unreachable,
clap.parseParam("--no-summary Don't print a summary (when generating .bun") catch unreachable,
clap.parseParam("-v, --version Print version and exit") catch unreachable,
@@ -222,14 +223,16 @@ pub const Arguments = struct {
Global.exit(0);
}
- fn loadConfigPath(allocator: std.mem.Allocator, auto_loaded: bool, config_path: [:0]const u8, ctx: *Command.Context, comptime cmd: Command.Tag) !void {
- var config_file = std.fs.openFileAbsoluteZ(config_path, .{ .mode = .read_only }) catch |err| {
- if (auto_loaded) return;
- Output.prettyErrorln("<r><red>error<r>: {s} opening config \"{s}\"", .{
- @errorName(err),
- config_path,
- });
- Global.exit(1);
+ pub fn loadConfigPath(allocator: std.mem.Allocator, auto_loaded: bool, config_path: [:0]const u8, ctx: *Command.Context, comptime cmd: Command.Tag) !void {
+ var config_file = std.fs.File{
+ .handle = std.os.openZ(config_path, std.os.O.RDONLY, 0) catch |err| {
+ if (auto_loaded) return;
+ Output.prettyErrorln("<r><red>error<r>: {s} opening config \"{s}\"", .{
+ @errorName(err),
+ config_path,
+ });
+ Global.exit(1);
+ },
};
defer config_file.close();
var contents = config_file.readToEndAlloc(allocator, std.math.maxInt(usize)) catch |err| {
@@ -263,12 +266,15 @@ pub const Arguments = struct {
return null;
}
-
pub fn loadConfig(allocator: std.mem.Allocator, user_config_path_: ?string, ctx: *Command.Context, comptime cmd: Command.Tag) !void {
var config_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
if (comptime cmd.readGlobalConfig()) {
- if (getHomeConfigPath(&config_buf)) |path| {
- try loadConfigPath(allocator, true, path, ctx, comptime cmd);
+ if (!ctx.has_loaded_global_config) {
+ ctx.has_loaded_global_config = true;
+
+ if (getHomeConfigPath(&config_buf)) |path| {
+ try loadConfigPath(allocator, true, path, ctx, comptime cmd);
+ }
}
}
@@ -290,7 +296,7 @@ pub const Arguments = struct {
if (config_path_.len == 0) {
return;
}
-
+ defer ctx.debug.loaded_bunfig = true;
var config_path: [:0]u8 = undefined;
if (config_path_[0] == '/') {
@memcpy(&config_buf, config_path_.ptr, config_path_.len);
@@ -421,6 +427,18 @@ pub const Arguments = struct {
opts.no_summary = args.flag("--no-summary");
opts.disable_hmr = args.flag("--disable-hmr");
+ if (cmd != .DevCommand) {
+ const preloads = args.options("--preload");
+ if (ctx.preloads.len > 0 and preloads.len > 0) {
+ var all = std.ArrayList(string).initCapacity(ctx.allocator, ctx.preloads.len + preloads.len) catch unreachable;
+ all.appendSliceAssumeCapacity(ctx.preloads);
+ all.appendSliceAssumeCapacity(preloads);
+ ctx.preloads = all.items;
+ } else if (preloads.len > 0) {
+ ctx.preloads = preloads;
+ }
+ }
+
ctx.debug.silent = args.flag("--silent");
if (opts.port != null and opts.origin == null) {
opts.origin = try std.fmt.allocPrint(allocator, "http://localhost:{d}/", .{opts.port.?});
@@ -831,6 +849,7 @@ pub const Command = struct {
global_cache: options.GlobalCache = .auto,
offline_mode_setting: ?Bunfig.OfflineMode = null,
run_in_bun: bool = false,
+ loaded_bunfig: bool = false,
// technical debt
macros: ?MacroMap = null,
@@ -851,6 +870,9 @@ pub const Command = struct {
debug: DebugOptions = DebugOptions{},
+ preloads: []const string = &[_]string{},
+ has_loaded_global_config: bool = false,
+
const _ctx = Command.Context{
.args = std.mem.zeroes(Api.TransformOptions),
.log = undefined,
@@ -1237,6 +1259,15 @@ pub const Command = struct {
break :brk options.Loader.js;
}
+ if (extension.len > 0) {
+ if (!ctx.debug.loaded_bunfig) {
+ try bun.CLI.Arguments.loadConfigPath(ctx.allocator, true, "bunfig.toml", &ctx, .RunCommand);
+ }
+
+ if (ctx.preloads.len > 0)
+ break :brk options.Loader.js;
+ }
+
break :brk null;
};
@@ -1288,7 +1319,7 @@ pub const Command = struct {
}
}
- fn maybeOpenWithBunJS(ctx: *const Command.Context) bool {
+ fn maybeOpenWithBunJS(ctx: *Command.Context) bool {
if (ctx.args.entry_points.len == 0)
return false;
@@ -1337,6 +1368,11 @@ pub const Command = struct {
// the case where this doesn't work is if the script name on disk doesn't end with a known JS-like file extension
var absolute_script_path = bun.getFdPath(file.handle, &script_name_buf) catch return false;
+
+ if (!ctx.debug.loaded_bunfig) {
+ bun.CLI.Arguments.loadConfigPath(ctx.allocator, true, "bunfig.toml", ctx, .RunCommand) catch {};
+ }
+
BunJS.Run.boot(
ctx.*,
file,
diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig
index 8c5b98b0f..80840f7c9 100644
--- a/src/cli/run_command.zig
+++ b/src/cli/run_command.zig
@@ -836,7 +836,8 @@ pub const RunCommand = struct {
return shell_out;
}
- pub fn exec(ctx: Command.Context, comptime bin_dirs_only: bool, comptime log_errors: bool) !bool {
+ pub fn exec(ctx_: Command.Context, comptime bin_dirs_only: bool, comptime log_errors: bool) !bool {
+ var ctx = ctx_;
// Step 1. Figure out what we're trying to run
var positionals = ctx.positionals;
if (positionals.len > 0 and strings.eqlComptime(positionals[0], "run") or strings.eqlComptime(positionals[0], "r")) {
@@ -855,12 +856,20 @@ pub const RunCommand = struct {
if (log_errors or force_using_bun) {
if (script_name_to_search.len > 0) {
possibly_open_with_bun_js: {
+ const ext = std.fs.path.extension(script_name_to_search);
+ var has_loader = false;
if (!force_using_bun) {
- if (options.defaultLoaders.get(std.fs.path.extension(script_name_to_search))) |load| {
+ if (options.defaultLoaders.get(ext)) |load| {
+ has_loader = true;
if (!load.canBeRunByBun())
break :possibly_open_with_bun_js;
+ // if there are preloads, allow weirdo file extensions
} else {
- break :possibly_open_with_bun_js;
+ // you can have package.json scripts with file extensions in the name
+ // eg "foo.zip"
+ // in those cases, we don't know
+ if (ext.len == 0 or strings.containsChar(script_name_to_search, ':'))
+ break :possibly_open_with_bun_js;
}
}
@@ -888,8 +897,20 @@ pub const RunCommand = struct {
const file = file_ catch break :possibly_open_with_bun_js;
- // ignore the shebang if they explicitly passed `--bun`
if (!force_using_bun) {
+ // Due to preload, we don't know if they intend to run
+ // this as a script or as a regular file
+ // once we know it's a file, check if they have any preloads
+ if (ext.len > 0 and !has_loader) {
+ if (!ctx.debug.loaded_bunfig) {
+ try bun.CLI.Arguments.loadConfigPath(ctx.allocator, true, "bunfig.toml", &ctx, .RunCommand);
+ }
+
+ if (ctx.preloads.len == 0)
+ break :possibly_open_with_bun_js;
+ }
+
+ // ignore the shebang if they explicitly passed `--bun`
// "White space after #! is optional."
var shebang_buf: [64]u8 = undefined;
const shebang_size = file.pread(&shebang_buf, 0) catch |err| {
diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig
index fbdf73ba3..445398fea 100644
--- a/src/cli/test_command.zig
+++ b/src/cli/test_command.zig
@@ -362,7 +362,7 @@ pub const TestCommand = struct {
loader.* = DotEnv.Loader.init(map, ctx.allocator);
break :brk loader;
};
- JSC.C.JSCInitialize();
+ bun.JSC.initialize();
HTTPThread.init() catch {};
var reporter = try ctx.allocator.create(CommandLineReporter);
@@ -388,6 +388,7 @@ pub const TestCommand = struct {
js_ast.Stmt.Data.Store.create(default_allocator);
var vm = try JSC.VirtualMachine.init(ctx.allocator, ctx.args, null, ctx.log, env_loader);
vm.argv = ctx.passthrough;
+ vm.preload = ctx.preloads;
try vm.bundler.configureDefines();
vm.bundler.options.rewrite_jest_for_tests = true;
diff --git a/src/darwin_c.zig b/src/darwin_c.zig
index d62e665b9..313ecc368 100644
--- a/src/darwin_c.zig
+++ b/src/darwin_c.zig
@@ -559,13 +559,11 @@ pub const CPU_STATE_MAX = 4;
pub const processor_cpu_load_info = extern struct {
cpu_ticks: [CPU_STATE_MAX]c_uint,
};
-pub const PROCESSOR_CPU_LOAD_INFO_COUNT = @as(std.c.mach_msg_type_number_t,
- @sizeOf(processor_cpu_load_info)/@sizeOf(std.c.natural_t));
+pub const PROCESSOR_CPU_LOAD_INFO_COUNT = @as(std.c.mach_msg_type_number_t, @sizeOf(processor_cpu_load_info) / @sizeOf(std.c.natural_t));
pub const processor_info_array_t = [*]c_int;
pub const PROCESSOR_INFO_MAX = 1024;
-pub extern fn host_processor_info(host: std.c.host_t , flavor: processor_flavor_t , out_processor_count: *std.c.natural_t , out_processor_info: *processor_info_array_t, out_processor_infoCnt: *std.c.mach_msg_type_number_t) std.c.E;
-
+pub extern fn host_processor_info(host: std.c.host_t, flavor: processor_flavor_t, out_processor_count: *std.c.natural_t, out_processor_info: *processor_info_array_t, out_processor_infoCnt: *std.c.mach_msg_type_number_t) std.c.E;
pub extern fn getuid(...) std.os.uid_t;
pub extern fn getgid(...) std.os.gid_t;
@@ -754,30 +752,32 @@ pub extern fn removefileat(fd: c_int, path: [*c]const u8, state: ?*removefile_st
// As of Zig v0.11.0-dev.1393+38eebf3c4, ifaddrs.h is not included in the headers
pub const ifaddrs = extern struct {
- ifa_next: ?*ifaddrs,
- ifa_name: [*:0]u8,
- ifa_flags: c_uint,
- ifa_addr: ?*std.os.sockaddr,
- ifa_netmask: ?*std.os.sockaddr,
- ifa_dstaddr: ?*std.os.sockaddr,
- ifa_data: *anyopaque,
+ ifa_next: ?*ifaddrs,
+ ifa_name: [*:0]u8,
+ ifa_flags: c_uint,
+ ifa_addr: ?*std.os.sockaddr,
+ ifa_netmask: ?*std.os.sockaddr,
+ ifa_dstaddr: ?*std.os.sockaddr,
+ ifa_data: *anyopaque,
};
pub extern fn getifaddrs(*?*ifaddrs) c_int;
pub extern fn freeifaddrs(?*ifaddrs) void;
-const net_if_h = @cImport({ @cInclude("net/if.h"); });
+const net_if_h = @cImport({
+ @cInclude("net/if.h");
+});
pub const IFF_RUNNING = net_if_h.IFF_RUNNING;
pub const IFF_UP = net_if_h.IFF_UP;
pub const IFF_LOOPBACK = net_if_h.IFF_LOOPBACK;
pub const sockaddr_dl = extern struct {
- sdl_len: u8, // Total length of sockaddr */
- sdl_family: u8, // AF_LINK */
- sdl_index: u16, // if != 0, system given index for interface */
- sdl_type: u8, // interface type */
- sdl_nlen: u8, // interface name length, no trailing 0 reqd. */
- sdl_alen: u8, // link level address length */
- sdl_slen: u8, // link layer selector length */
- sdl_data: [12]u8, // minimum work area, can be larger; contains both if name and ll address */
+ sdl_len: u8, // Total length of sockaddr */
+ sdl_family: u8, // AF_LINK */
+ sdl_index: u16, // if != 0, system given index for interface */
+ sdl_type: u8, // interface type */
+ sdl_nlen: u8, // interface name length, no trailing 0 reqd. */
+ sdl_alen: u8, // link level address length */
+ sdl_slen: u8, // link layer selector length */
+ sdl_data: [12]u8, // minimum work area, can be larger; contains both if name and ll address */
//#ifndef __APPLE__
// /* For TokenRing */
// u_short sdl_rcf; /* source routing control */
diff --git a/src/deps/uws.zig b/src/deps/uws.zig
index 58a5b1b93..5ebbfcc51 100644
--- a/src/deps/uws.zig
+++ b/src/deps/uws.zig
@@ -319,9 +319,7 @@ pub fn NewSocketHandler(comptime ssl: bool) type {
}
pub fn from(socket: *Socket) ThisSocket {
- return ThisSocket {
- .socket = socket
- };
+ return ThisSocket{ .socket = socket };
}
pub fn adopt(
diff --git a/src/fallback.ts b/src/fallback.ts
index 964ed4e92..1893fde36 100644
--- a/src/fallback.ts
+++ b/src/fallback.ts
@@ -1,15 +1,10 @@
declare var document: any;
import { ByteBuffer } from "peechy";
import { FallbackStep } from "./api/schema";
-import {
- decodeFallbackMessageContainer,
- FallbackMessageContainer,
-} from "./api/schema";
+import { decodeFallbackMessageContainer, FallbackMessageContainer } from "./api/schema";
function getFallbackInfo(): FallbackMessageContainer {
- const binary_string = globalThis.atob(
- document.getElementById("__bunfallback").textContent.trim(),
- );
+ const binary_string = globalThis.atob(document.getElementById("__bunfallback").textContent.trim());
var len = binary_string.length;
var bytes = new Uint8Array(len);
diff --git a/src/http.zig b/src/http.zig
index 746e843b9..6b34adac4 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -1461,7 +1461,7 @@ pub const RequestContext = struct {
handler.start_timer = std.time.Timer.start() catch unreachable;
Output.Source.configureThread();
- @import("bun.js/javascript_core_c_api.zig").JSCInitialize();
+ bun.JSC.initialize();
js_ast.Stmt.Data.Store.create(bun.default_allocator);
js_ast.Expr.Data.Store.create(bun.default_allocator);
@@ -3506,7 +3506,7 @@ pub const Server = struct {
const addr = listener.listen_address;
if (server.bundler.options.origin.getPort() != addr.getPort()) {
- server.bundler.options.origin = ZigURL.parse(try std.fmt.allocPrint(server.allocator, "{s}://{s}:{d}", .{server.bundler.options.origin.displayProtocol(), server.bundler.options.origin.displayHostname(), addr.getPort()}));
+ server.bundler.options.origin = ZigURL.parse(try std.fmt.allocPrint(server.allocator, "{s}://{s}:{d}", .{ server.bundler.options.origin.displayProtocol(), server.bundler.options.origin.displayHostname(), addr.getPort() }));
}
const start_time = Global.getStartTime();
diff --git a/src/http_client_async.zig b/src/http_client_async.zig
index 0f6045bbb..945406448 100644
--- a/src/http_client_async.zig
+++ b/src/http_client_async.zig
@@ -1029,13 +1029,13 @@ aborted: ?*std.atomic.Atomic(bool) = null,
async_http_id: u32 = 0,
pub fn init(allocator: std.mem.Allocator, method: Method, url: URL, header_entries: Headers.Entries, header_buf: string, signal: ?*std.atomic.Atomic(bool)) HTTPClient {
- return HTTPClient {
- .allocator = allocator,
- .method = method,
- .url = url,
- .header_entries = header_entries,
- .header_buf = header_buf,
- .aborted = signal,
+ return HTTPClient{
+ .allocator = allocator,
+ .method = method,
+ .url = url,
+ .header_entries = header_entries,
+ .header_buf = header_buf,
+ .aborted = signal,
};
}
diff --git a/src/linux_c.zig b/src/linux_c.zig
index ae9300477..129161579 100644
--- a/src/linux_c.zig
+++ b/src/linux_c.zig
@@ -481,10 +481,9 @@ pub fn posix_spawn_file_actions_addchdir_np(actions: *posix_spawn_file_actions_t
pub extern fn vmsplice(fd: c_int, iovec: [*]const std.os.iovec, iovec_count: usize, flags: u32) isize;
-
const net_c = @cImport({
@cInclude("ifaddrs.h"); // getifaddrs, freeifaddrs
- @cInclude("net/if.h"); // IFF_RUNNING, IFF_UP
+ @cInclude("net/if.h"); // IFF_RUNNING, IFF_UP
});
pub const ifaddrs = net_c.ifaddrs;
pub const getifaddrs = net_c.getifaddrs;
diff --git a/src/node-fallbacks/@vercel_fetch.js b/src/node-fallbacks/@vercel_fetch.js
index f75604b2b..a8de45222 100644
--- a/src/node-fallbacks/@vercel_fetch.js
+++ b/src/node-fallbacks/@vercel_fetch.js
@@ -1,15 +1,11 @@
// This is just a no-op. Intent is to prevent importing a bunch of stuff that isn't relevant.
-module.exports = (
- wrapper = "Bun" in globalThis ? Bun.fetch : globalThis.fetch,
-) => {
+module.exports = (wrapper = "Bun" in globalThis ? Bun.fetch : globalThis.fetch) => {
async function vercelFetch(url, opts = {}) {
// Convert Object bodies to JSON if they are JS objects
if (
opts.body &&
typeof opts.body === "object" &&
- (!("buffer" in opts.body) ||
- typeof opts.body.buffer !== "object" ||
- !(opts.body.buffer instanceof ArrayBuffer))
+ (!("buffer" in opts.body) || typeof opts.body.buffer !== "object" || !(opts.body.buffer instanceof ArrayBuffer))
) {
opts.body = JSON.stringify(opts.body);
// Content length will automatically be set
diff --git a/src/node-fallbacks/crypto.js b/src/node-fallbacks/crypto.js
index 4a0e4c735..8c83b6c87 100644
--- a/src/node-fallbacks/crypto.js
+++ b/src/node-fallbacks/crypto.js
@@ -3,7 +3,7 @@ export * from "crypto-browserify";
export var DEFAULT_ENCODING = "buffer";
// we deliberately reference crypto. directly here because we want to preserve the This binding
-export const getRandomValues = (array) => {
+export const getRandomValues = array => {
return crypto.getRandomValues(array);
};
@@ -16,10 +16,7 @@ export const timingSafeEqual =
? (a, b) => {
const { byteLength: byteLengthA } = a;
const { byteLength: byteLengthB } = b;
- if (
- typeof byteLengthA !== "number" ||
- typeof byteLengthB !== "number"
- ) {
+ if (typeof byteLengthA !== "number" || typeof byteLengthB !== "number") {
throw new TypeError("Input must be an array buffer view");
}
@@ -37,9 +34,7 @@ export const scryptSync =
"scryptSync" in crypto
? (password, salt, keylen, options) => {
const res = crypto.scryptSync(password, salt, keylen, options);
- return DEFAULT_ENCODING !== "buffer"
- ? new Buffer(res).toString(DEFAULT_ENCODING)
- : new Buffer(res);
+ return DEFAULT_ENCODING !== "buffer" ? new Buffer(res).toString(DEFAULT_ENCODING) : new Buffer(res);
}
: undefined;
@@ -62,9 +57,7 @@ export const scrypt =
process.nextTick(
callback,
null,
- DEFAULT_ENCODING !== "buffer"
- ? new Buffer(result).toString(DEFAULT_ENCODING)
- : new Buffer(result),
+ DEFAULT_ENCODING !== "buffer" ? new Buffer(result).toString(DEFAULT_ENCODING) : new Buffer(result),
);
} catch (err) {
throw err;
diff --git a/src/node-fallbacks/events.js b/src/node-fallbacks/events.js
index 738bf1f15..70f47eb53 100644
--- a/src/node-fallbacks/events.js
+++ b/src/node-fallbacks/events.js
@@ -34,9 +34,7 @@ if (R && typeof R.ownKeys === "function") {
ReflectOwnKeys = R.ownKeys;
} else if (Object.getOwnPropertySymbols) {
ReflectOwnKeys = function ReflectOwnKeys(target) {
- return Object.getOwnPropertyNames(target).concat(
- Object.getOwnPropertySymbols(target),
- );
+ return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
};
} else {
ReflectOwnKeys = function ReflectOwnKeys(target) {
@@ -71,10 +69,7 @@ var defaultMaxListeners = 10;
function checkListener(listener) {
if (typeof listener !== "function") {
- throw new TypeError(
- 'The "listener" argument must be of type Function. Received type ' +
- typeof listener,
- );
+ throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
}
}
@@ -86,9 +81,7 @@ Object.defineProperty(EventEmitter, "defaultMaxListeners", {
set: function (arg) {
if (typeof arg !== "number" || arg < 0 || NumberIsNaN(arg)) {
throw new RangeError(
- 'The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' +
- arg +
- ".",
+ 'The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + ".",
);
}
defaultMaxListeners = arg;
@@ -96,10 +89,7 @@ Object.defineProperty(EventEmitter, "defaultMaxListeners", {
});
EventEmitter.init = function () {
- if (
- this._events === undefined ||
- this._events === Object.getPrototypeOf(this)._events
- ) {
+ if (this._events === undefined || this._events === Object.getPrototypeOf(this)._events) {
this._events = Object.create(null);
this._eventsCount = 0;
}
@@ -111,11 +101,7 @@ EventEmitter.init = function () {
// that to be increased. Set to zero for unlimited.
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
if (typeof n !== "number" || n < 0 || NumberIsNaN(n)) {
- throw new RangeError(
- 'The value of "n" is out of range. It must be a non-negative number. Received ' +
- n +
- ".",
- );
+ throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + ".");
}
this._maxListeners = n;
return this;
@@ -149,9 +135,7 @@ EventEmitter.prototype.emit = function emit(type) {
throw er; // Unhandled 'error' event
}
// At least give some kind of context to the user
- var err = new Error(
- "Unhandled error." + (er ? " (" + er.message + ")" : ""),
- );
+ var err = new Error("Unhandled error." + (er ? " (" + er.message + ")" : ""));
err.context = er;
throw err; // Unhandled 'error' event
}
@@ -186,11 +170,7 @@ function _addListener(target, type, listener, prepend) {
// To avoid recursion in the case that type === "newListener"! Before
// adding it to the listeners, first emit "newListener".
if (events.newListener !== undefined) {
- target.emit(
- "newListener",
- type,
- listener.listener ? listener.listener : listener,
- );
+ target.emit("newListener", type, listener.listener ? listener.listener : listener);
// Re-assign `events` because a newListener handler could have caused the
// this._events to be assigned to a new object
@@ -206,9 +186,7 @@ function _addListener(target, type, listener, prepend) {
} else {
if (typeof existing === "function") {
// Adding the second element, need to change to array.
- existing = events[type] = prepend
- ? [listener, existing]
- : [existing, listener];
+ existing = events[type] = prepend ? [listener, existing] : [existing, listener];
// If we've already got an array, just append.
} else if (prepend) {
existing.unshift(listener);
@@ -248,10 +226,7 @@ EventEmitter.prototype.addListener = function addListener(type, listener) {
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
-EventEmitter.prototype.prependListener = function prependListener(
- type,
- listener,
-) {
+EventEmitter.prototype.prependListener = function prependListener(type, listener) {
return _addListener(this, type, listener, true);
};
@@ -284,20 +259,14 @@ EventEmitter.prototype.once = function once(type, listener) {
return this;
};
-EventEmitter.prototype.prependOnceListener = function prependOnceListener(
- type,
- listener,
-) {
+EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
checkListener(listener);
this.prependListener(type, _onceWrap(this, type, listener));
return this;
};
// Emits a 'removeListener' event if and only if the listener was removed.
-EventEmitter.prototype.removeListener = function removeListener(
- type,
- listener,
-) {
+EventEmitter.prototype.removeListener = function removeListener(type, listener) {
var list, events, position, i, originalListener;
checkListener(listener);
@@ -312,8 +281,7 @@ EventEmitter.prototype.removeListener = function removeListener(
if (--this._eventsCount === 0) this._events = Object.create(null);
else {
delete events[type];
- if (events.removeListener)
- this.emit("removeListener", type, list.listener || listener);
+ if (events.removeListener) this.emit("removeListener", type, list.listener || listener);
}
} else if (typeof list !== "function") {
position = -1;
@@ -335,8 +303,7 @@ EventEmitter.prototype.removeListener = function removeListener(
if (list.length === 1) events[type] = list[0];
- if (events.removeListener !== undefined)
- this.emit("removeListener", type, originalListener || listener);
+ if (events.removeListener !== undefined) this.emit("removeListener", type, originalListener || listener);
}
return this;
@@ -399,12 +366,9 @@ function _listeners(target, type, unwrap) {
var evlistener = events[type];
if (evlistener === undefined) return [];
- if (typeof evlistener === "function")
- return unwrap ? [evlistener.listener || evlistener] : [evlistener];
+ if (typeof evlistener === "function") return unwrap ? [evlistener.listener || evlistener] : [evlistener];
- return unwrap
- ? unwrapListeners(evlistener)
- : arrayClone(evlistener, evlistener.length);
+ return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
}
EventEmitter.prototype.listeners = function listeners(type) {
@@ -509,10 +473,7 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
listener(arg);
});
} else {
- throw new TypeError(
- 'The "emitter" argument must be of type EventEmitter. Received type ' +
- typeof emitter,
- );
+ throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
}
}
diff --git a/src/node-fallbacks/url.js b/src/node-fallbacks/url.js
index 10f1b889a..81c78001d 100644
--- a/src/node-fallbacks/url.js
+++ b/src/node-fallbacks/url.js
@@ -203,10 +203,7 @@ Url.prototype.parse = function (url, parseQueryString, slashesDenoteHost) {
}
}
- if (
- !hostlessProtocol[proto] &&
- (slashes || (proto && !slashedProtocol[proto]))
- ) {
+ if (!hostlessProtocol[proto] && (slashes || (proto && !slashedProtocol[proto]))) {
// there's a hostname.
// the first instance of /, ?, ;, or # ends the host.
//
@@ -270,9 +267,7 @@ Url.prototype.parse = function (url, parseQueryString, slashesDenoteHost) {
// if hostname begins with [ and ends with ]
// assume that it's an IPv6 address.
- var ipv6Hostname =
- this.hostname[0] === "[" &&
- this.hostname[this.hostname.length - 1] === "]";
+ var ipv6Hostname = this.hostname[0] === "[" && this.hostname[this.hostname.length - 1] === "]";
// validate a little.
if (!ipv6Hostname) {
@@ -423,21 +418,13 @@ Url.prototype.format = function () {
if (this.host) {
host = auth + this.host;
} else if (this.hostname) {
- host =
- auth +
- (this.hostname.indexOf(":") === -1
- ? this.hostname
- : "[" + this.hostname + "]");
+ host = auth + (this.hostname.indexOf(":") === -1 ? this.hostname : "[" + this.hostname + "]");
if (this.port) {
host += ":" + this.port;
}
}
- if (
- this.query &&
- util_isObject(this.query) &&
- Object.keys(this.query).length
- ) {
+ if (this.query && util_isObject(this.query) && Object.keys(this.query).length) {
query = querystring.stringify(this.query);
}
@@ -447,10 +434,7 @@ Url.prototype.format = function () {
// only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
// unless they had them to begin with.
- if (
- this.slashes ||
- ((!protocol || slashedProtocol[protocol]) && host !== false)
- ) {
+ if (this.slashes || ((!protocol || slashedProtocol[protocol]) && host !== false)) {
host = "//" + (host || "");
if (pathname && pathname.charAt(0) !== "/") pathname = "/" + pathname;
} else if (!host) {
@@ -515,11 +499,7 @@ Url.prototype.resolveObject = function (relative) {
}
//urlParse appends trailing / to urls like http://www.example.com
- if (
- slashedProtocol[result.protocol] &&
- result.hostname &&
- !result.pathname
- ) {
+ if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) {
result.path = result.pathname = "/";
}
@@ -576,9 +556,7 @@ Url.prototype.resolveObject = function (relative) {
}
var isSourceAbs = result.pathname && result.pathname.charAt(0) === "/",
- isRelAbs =
- relative.host ||
- (relative.pathname && relative.pathname.charAt(0) === "/"),
+ isRelAbs = relative.host || (relative.pathname && relative.pathname.charAt(0) === "/"),
mustEndAbs = isRelAbs || isSourceAbs || (result.host && relative.pathname),
removeAllDots = mustEndAbs,
srcPath = (result.pathname && result.pathname.split("/")) || [],
@@ -612,12 +590,8 @@ Url.prototype.resolveObject = function (relative) {
if (isRelAbs) {
// it's absolute.
- result.host =
- relative.host || relative.host === "" ? relative.host : result.host;
- result.hostname =
- relative.hostname || relative.hostname === ""
- ? relative.hostname
- : result.hostname;
+ result.host = relative.host || relative.host === "" ? relative.host : result.host;
+ result.hostname = relative.hostname || relative.hostname === "" ? relative.hostname : result.hostname;
result.search = relative.search;
result.query = relative.query;
srcPath = relPath;
@@ -639,10 +613,7 @@ Url.prototype.resolveObject = function (relative) {
//occationaly the auth can get stuck only in host
//this especially happens in cases like
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
- var authInHost =
- result.host && result.host.indexOf("@") > 0
- ? result.host.split("@")
- : false;
+ var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : false;
if (authInHost) {
result.auth = authInHost.shift();
result.host = result.hostname = authInHost.shift();
@@ -652,9 +623,7 @@ Url.prototype.resolveObject = function (relative) {
result.query = relative.query;
//to support http.request
if (!util_isNull(result.pathname) || !util_isNull(result.search)) {
- result.path =
- (result.pathname ? result.pathname : "") +
- (result.search ? result.search : "");
+ result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : "");
}
result.href = result.format();
return result;
@@ -679,9 +648,7 @@ Url.prototype.resolveObject = function (relative) {
// then it must NOT get a trailing slash.
var last = srcPath.slice(-1)[0];
var hasTrailingSlash =
- ((result.host || relative.host || srcPath.length > 1) &&
- (last === "." || last === "..")) ||
- last === "";
+ ((result.host || relative.host || srcPath.length > 1) && (last === "." || last === "..")) || last === "";
// strip single dots, resolve double dots to parent dir
// if the path tries to go above the root, `up` ends up > 0
@@ -706,11 +673,7 @@ Url.prototype.resolveObject = function (relative) {
}
}
- if (
- mustEndAbs &&
- srcPath[0] !== "" &&
- (!srcPath[0] || srcPath[0].charAt(0) !== "/")
- ) {
+ if (mustEndAbs && srcPath[0] !== "" && (!srcPath[0] || srcPath[0].charAt(0) !== "/")) {
srcPath.unshift("");
}
@@ -718,23 +681,15 @@ Url.prototype.resolveObject = function (relative) {
srcPath.push("");
}
- var isAbsolute =
- srcPath[0] === "" || (srcPath[0] && srcPath[0].charAt(0) === "/");
+ var isAbsolute = srcPath[0] === "" || (srcPath[0] && srcPath[0].charAt(0) === "/");
// put the host back
if (psychotic) {
- result.hostname = result.host = isAbsolute
- ? ""
- : srcPath.length
- ? srcPath.shift()
- : "";
+ result.hostname = result.host = isAbsolute ? "" : srcPath.length ? srcPath.shift() : "";
//occationaly the auth can get stuck only in host
//this especially happens in cases like
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
- var authInHost =
- result.host && result.host.indexOf("@") > 0
- ? result.host.split("@")
- : false;
+ var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : false;
if (authInHost) {
result.auth = authInHost.shift();
result.host = result.hostname = authInHost.shift();
@@ -756,9 +711,7 @@ Url.prototype.resolveObject = function (relative) {
//to support request.http
if (!util_isNull(result.pathname) || !util_isNull(result.search)) {
- result.path =
- (result.pathname ? result.pathname : "") +
- (result.search ? result.search : "");
+ result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : "");
}
result.auth = relative.auth || result.auth;
result.slashes = result.slashes || relative.slashes;
diff --git a/src/runtime.footer.bun.js b/src/runtime.footer.bun.js
index 0c83ebc49..56da601b4 100644
--- a/src/runtime.footer.bun.js
+++ b/src/runtime.footer.bun.js
@@ -14,8 +14,7 @@ export var __merge = BUN_RUNTIME.__merge;
export var __decorateClass = BUN_RUNTIME.__decorateClass;
export var __decorateParam = BUN_RUNTIME.__decorateParam;
export var $$bun_runtime_json_parse = JSON.parse;
-export var __internalIsCommonJSNamespace =
- BUN_RUNTIME.__internalIsCommonJSNamespace;
+export var __internalIsCommonJSNamespace = BUN_RUNTIME.__internalIsCommonJSNamespace;
export var __require = (globalThis.require ||= function (moduleId) {
if (typeof moduleId === "string") {
@@ -25,5 +24,4 @@ export var __require = (globalThis.require ||= function (moduleId) {
return BUN_RUNTIME.__require(moduleId);
});
__require.d ||= BUN_RUNTIME.__require.d;
-globalThis.__internalIsCommonJSNamespace ||=
- BUN_RUNTIME.__internalIsCommonJSNamespace;
+globalThis.__internalIsCommonJSNamespace ||= BUN_RUNTIME.__internalIsCommonJSNamespace;
diff --git a/src/runtime.footer.js b/src/runtime.footer.js
index 062961b1f..ceeab055d 100644
--- a/src/runtime.footer.js
+++ b/src/runtime.footer.js
@@ -1,8 +1,7 @@
// ---
// Public exports from runtime
// Compatible with bun's Runtime Environment and web browsers.
-export var $$m =
- "$primordials" in globalThis ? $primordials.require : BUN_RUNTIME.$$m;
+export var $$m = "$primordials" in globalThis ? $primordials.require : BUN_RUNTIME.$$m;
export var __HMRModule = BUN_RUNTIME.__HMRModule;
export var __FastRefreshModule = BUN_RUNTIME.__FastRefreshModule;
export var __HMRClient = BUN_RUNTIME.__HMRClient;
@@ -22,8 +21,7 @@ export var __merge = BUN_RUNTIME.__merge;
export var __decorateClass = BUN_RUNTIME.__decorateClass;
export var __decorateParam = BUN_RUNTIME.__decorateParam;
export var $$bun_runtime_json_parse = JSON.parse;
-export var __internalIsCommonJSNamespace =
- BUN_RUNTIME.__internalIsCommonJSNamespace;
+export var __internalIsCommonJSNamespace = BUN_RUNTIME.__internalIsCommonJSNamespace;
globalThis.__internalIsCommonJSNamespace ||= __internalIsCommonJSNamespace;
globalThis.require ||= BUN_RUNTIME.__require;
diff --git a/src/runtime.footer.node.js b/src/runtime.footer.node.js
index b32dc78fa..ef28d3b31 100644
--- a/src/runtime.footer.node.js
+++ b/src/runtime.footer.node.js
@@ -15,8 +15,7 @@ export var __exportDefault = BUN_RUNTIME.__exportDefault;
export var __decorateClass = BUN_RUNTIME.__decorateClass;
export var __decorateParam = BUN_RUNTIME.__decorateParam;
export var $$bun_runtime_json_parse = JSON.parse;
-export var __internalIsCommonJSNamespace =
- BUN_RUNTIME.__internalIsCommonJSNamespace;
+export var __internalIsCommonJSNamespace = BUN_RUNTIME.__internalIsCommonJSNamespace;
var require = __$module.createRequire(import.meta.url);
var process =
globalThis.process ||
diff --git a/src/runtime.footer.with-refresh.js b/src/runtime.footer.with-refresh.js
index a5b5a3b79..784f5f8fa 100644
--- a/src/runtime.footer.with-refresh.js
+++ b/src/runtime.footer.with-refresh.js
@@ -1,8 +1,7 @@
// ---
// Public exports from runtime
// Compatible with bun's Runtime Environment and web browsers.
-export var $$m =
- "$primordials" in globalThis ? $primordials.require : BUN_RUNTIME.$$m;
+export var $$m = "$primordials" in globalThis ? $primordials.require : BUN_RUNTIME.$$m;
export var __HMRModule = BUN_RUNTIME.__HMRModule;
export var __FastRefreshModule = BUN_RUNTIME.__FastRefreshModule;
export var __HMRClient = BUN_RUNTIME.__HMRClient;
@@ -22,8 +21,7 @@ export var __decorateClass = BUN_RUNTIME.__decorateClass;
export var __decorateParam = BUN_RUNTIME.__decorateParam;
export var $$bun_runtime_json_parse = JSON.parse;
export var __FastRefreshRuntime = BUN_RUNTIME.__FastRefreshRuntime;
-export var __internalIsCommonJSNamespace =
- BUN_RUNTIME.__internalIsCommonJSNamespace;
+export var __internalIsCommonJSNamespace = BUN_RUNTIME.__internalIsCommonJSNamespace;
globalThis.__internalIsCommonJSNamespace ||= __internalIsCommonJSNamespace;
globalThis.require ||= BUN_RUNTIME.__require;
diff --git a/src/runtime.js b/src/runtime.js
index b39eaed9d..537ea9eed 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -21,8 +21,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
// return __objectFreezePolyfill.has(obj);
// };
-export var __markAsModule = (target) =>
- __defProp(target, "__esModule", { value: true, configurable: true });
+export var __markAsModule = target => __defProp(target, "__esModule", { value: true, configurable: true });
// lazy require to prevent loading one icon from a design system
export var $$lzy = (target, module, props) => {
@@ -37,7 +36,7 @@ export var $$lzy = (target, module, props) => {
return target;
};
-export var __toModule = (module) => {
+export var __toModule = module => {
return __reExport(
__markAsModule(
__defProp(
@@ -81,15 +80,9 @@ export var __commonJS = (cb, name) => {
return origExports.apply(this, arguments);
};
Object.setPrototypeOf(mod_exports, __getProtoOf(origExports));
- Object.defineProperties(
- mod_exports,
- Object.getOwnPropertyDescriptors(origExports),
- );
+ Object.defineProperties(mod_exports, Object.getOwnPropertyDescriptors(origExports));
} else {
- mod_exports = __create(
- __getProtoOf(mod_exports),
- Object.getOwnPropertyDescriptors(mod_exports),
- );
+ mod_exports = __create(__getProtoOf(mod_exports), Object.getOwnPropertyDescriptors(mod_exports));
}
}
@@ -134,14 +127,13 @@ export var __commonJS = (cb, name) => {
export var __cJS2eSM = __commonJS;
-export var __internalIsCommonJSNamespace = (namespace) =>
+export var __internalIsCommonJSNamespace = namespace =>
namespace != null &&
typeof namespace === "object" &&
- ((namespace.default && namespace.default[cjsRequireSymbol]) ||
- namespace[cjsRequireSymbol]);
+ ((namespace.default && namespace.default[cjsRequireSymbol]) || namespace[cjsRequireSymbol]);
// require()
-export var __require = (namespace) => {
+export var __require = namespace => {
if (__internalIsCommonJSNamespace(namespace)) {
return namespace.default();
}
@@ -152,7 +144,7 @@ export var __require = (namespace) => {
// require().default
// this currently does nothing
// get rid of this wrapper once we're more confident we do not need special handling for default
-__require.d = (namespace) => {
+__require.d = namespace => {
return namespace;
};
@@ -176,7 +168,7 @@ export var __export = (target, all) => {
get: all[name],
enumerable: true,
configurable: true,
- set: (newValue) => (all[name] = () => newValue),
+ set: newValue => (all[name] = () => newValue),
});
};
@@ -184,7 +176,7 @@ export var __exportValue = (target, all) => {
for (var name in all) {
__defProp(target, name, {
get: () => all[name],
- set: (newValue) => (all[name] = newValue),
+ set: newValue => (all[name] = newValue),
enumerable: true,
configurable: true,
});
@@ -194,7 +186,7 @@ export var __exportValue = (target, all) => {
export var __exportDefault = (target, value) => {
__defProp(target, "default", {
get: () => value,
- set: (newValue) => (value = newValue),
+ set: newValue => (value = newValue),
enumerable: true,
configurable: true,
});
@@ -207,8 +199,7 @@ export var __reExport = (target, module, desc) => {
__defProp(target, key, {
get: () => module[key],
configurable: true,
- enumerable:
- !(desc = __getOwnPropDesc(module, key)) || desc.enumerable,
+ enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable,
});
return target;
};
@@ -237,15 +228,11 @@ export var __merge = (props, defaultProps) => {
};
export var __decorateClass = (decorators, target, key, kind) => {
- var result =
- kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
for (var i = decorators.length - 1, decorator; i >= 0; i--)
- if ((decorator = decorators[i]))
- result =
- (kind ? decorator(target, key, result) : decorator(result)) || result;
+ if ((decorator = decorators[i])) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
if (kind && result) __defProp(target, key, result);
return result;
};
-export var __decorateParam = (index, decorator) => (target, key) =>
- decorator(target, key, index);
+export var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
diff --git a/src/runtime/errors.ts b/src/runtime/errors.ts
index 5affd14f1..e2973db91 100644
--- a/src/runtime/errors.ts
+++ b/src/runtime/errors.ts
@@ -76,8 +76,4 @@ var __ImportKind;
__ImportKind = ImportKind;
}
-export {
- __ResolveError as ResolveError,
- __BuildError as BuildError,
- __ImportKind as ImportKind,
-};
+export { __ResolveError as ResolveError, __BuildError as BuildError, __ImportKind as ImportKind };
diff --git a/src/runtime/hmr.ts b/src/runtime/hmr.ts
index 96122feba..5aff4389d 100644
--- a/src/runtime/hmr.ts
+++ b/src/runtime/hmr.ts
@@ -79,8 +79,7 @@ if (typeof window !== "undefined") {
// if they set a CSP header, that could cause this to fail
try {
let linkTag = document.querySelector("link[rel='icon']");
- BunError.previousFavicon =
- (linkTag && linkTag.getAttribute("href")) || "/favicon.ico";
+ BunError.previousFavicon = (linkTag && linkTag.getAttribute("href")) || "/favicon.ico";
if (!linkTag) {
linkTag = document.createElement("link");
linkTag.setAttribute("rel", "icon");
@@ -119,19 +118,15 @@ if (typeof window !== "undefined") {
if (!BunError.module) {
if (BunError.prom) return;
- BunError.prom = import("/bun:error.js").then((mod) => {
+ BunError.prom = import("/bun:error.js").then(mod => {
BunError.module = mod;
- !BunError.cancel &&
- BunError.render(BunError.lastError[0], BunError.lastError[1]);
+ !BunError.cancel && BunError.render(BunError.lastError[0], BunError.lastError[1]);
});
return;
}
const { renderBuildFailure, renderRuntimeError } = BunError.module;
- if (
- typeof BunError.lastError[0] === "string" ||
- BunError.lastError[0] instanceof Error
- ) {
+ if (typeof BunError.lastError[0] === "string" || BunError.lastError[0] instanceof Error) {
renderRuntimeError(BunError.lastError[0], BunError.lastError[1]);
} else {
renderBuildFailure(BunError.lastError[0], BunError.lastError[1]);
@@ -192,26 +187,17 @@ if (typeof window !== "undefined") {
const endIDRegion = rule.conditionText.indexOf(")", startIndex);
if (endIDRegion === -1) return null;
- const int = parseInt(
- rule.conditionText.substring(startIndex, endIDRegion),
- 10,
- );
+ const int = parseInt(rule.conditionText.substring(startIndex, endIDRegion), 10);
if (int !== id) {
return null;
}
- let startFileRegion = rule.conditionText.indexOf(
- '(hmr-file:"',
- endIDRegion,
- );
+ let startFileRegion = rule.conditionText.indexOf('(hmr-file:"', endIDRegion);
if (startFileRegion === -1) return null;
startFileRegion += '(hmr-file:"'.length + 1;
- const endFileRegion = rule.conditionText.indexOf(
- '"',
- startFileRegion,
- );
+ const endFileRegion = rule.conditionText.indexOf('"', startFileRegion);
if (endFileRegion === -1) return null;
// Empty file strings are invalid
if (endFileRegion - startFileRegion <= 0) return null;
@@ -219,10 +205,7 @@ if (typeof window !== "undefined") {
CSSLoader.cssLoadId.id = int;
CSSLoader.cssLoadId.node = sheet.ownerNode as HTMLStylableElement;
CSSLoader.cssLoadId.sheet = sheet;
- CSSLoader.cssLoadId.file = rule.conditionText.substring(
- startFileRegion - 1,
- endFileRegion,
- );
+ CSSLoader.cssLoadId.file = rule.conditionText.substring(startFileRegion - 1, endFileRegion);
return CSSLoader.cssLoadId;
}
@@ -265,33 +248,20 @@ if (typeof window !== "undefined") {
}
const bundleIdRule = cssRules[0] as CSSSupportsRule;
- if (
- bundleIdRule.type !== 12 ||
- !bundleIdRule.conditionText.startsWith("(hmr-bid:")
- ) {
+ if (bundleIdRule.type !== 12 || !bundleIdRule.conditionText.startsWith("(hmr-bid:")) {
continue;
}
- const bundleIdEnd = bundleIdRule.conditionText.indexOf(
- ")",
- "(hmr-bid:".length + 1,
- );
+ const bundleIdEnd = bundleIdRule.conditionText.indexOf(")", "(hmr-bid:".length + 1);
if (bundleIdEnd === -1) continue;
CSSLoader.cssLoadId.bundle_id = parseInt(
- bundleIdRule.conditionText.substring(
- "(hmr-bid:".length,
- bundleIdEnd,
- ),
+ bundleIdRule.conditionText.substring("(hmr-bid:".length, bundleIdEnd),
10,
);
for (let j = 1; j < ruleCount && match === null; j++) {
- match = this.findMatchingSupportsRule(
- cssRules[j] as CSSSupportsRule,
- id,
- sheet,
- );
+ match = this.findMatchingSupportsRule(cssRules[j] as CSSSupportsRule, id, sheet);
}
}
}
@@ -318,17 +288,11 @@ if (typeof window !== "undefined") {
}
const bundleIdRule = cssRules[0] as CSSSupportsRule;
- if (
- bundleIdRule.type !== 12 ||
- !bundleIdRule.conditionText.startsWith("(hmr-bid:")
- ) {
+ if (bundleIdRule.type !== 12 || !bundleIdRule.conditionText.startsWith("(hmr-bid:")) {
continue;
}
- const bundleIdEnd = bundleIdRule.conditionText.indexOf(
- ")",
- "(hmr-bid:".length + 1,
- );
+ const bundleIdEnd = bundleIdRule.conditionText.indexOf(")", "(hmr-bid:".length + 1);
if (bundleIdEnd === -1) continue;
CSSLoader.cssLoadId.bundle_id = parseInt(
@@ -337,11 +301,7 @@ if (typeof window !== "undefined") {
);
for (let j = 1; j < ruleCount && match === null; j++) {
- match = this.findMatchingSupportsRule(
- cssRules[j] as CSSSupportsRule,
- id,
- sheet,
- );
+ match = this.findMatchingSupportsRule(cssRules[j] as CSSSupportsRule, id, sheet);
}
}
@@ -356,11 +316,7 @@ if (typeof window !== "undefined") {
return match;
}
- handleBuildSuccess(
- bytes: Uint8Array,
- build: API.WebsocketMessageBuildSuccess,
- timestamp: number,
- ) {
+ handleBuildSuccess(bytes: Uint8Array, build: API.WebsocketMessageBuildSuccess, timestamp: number) {
const start = performance.now();
var update = this.findCSSLinkTag(build.id);
// The last 4 bytes of the build message are the hash of the module
@@ -386,12 +342,7 @@ if (typeof window !== "undefined") {
function onLoadHandler() {
const localDuration = formatDuration(performance.now() - start);
const fsDuration = _timestamp - from_timestamp;
- __hmrlog.log(
- "Reloaded in",
- `${localDuration + fsDuration}ms`,
- "-",
- filepath,
- );
+ __hmrlog.log("Reloaded in", `${localDuration + fsDuration}ms`, "-", filepath);
update = null;
filepath = null;
@@ -421,10 +372,7 @@ if (typeof window !== "undefined") {
// This is an adoptedStyleSheet, call replaceSync and be done with it.
if (!update.node || update.node.tagName === "HTML") {
update.sheet.replaceSync(this.decoder.decode(bytes));
- } else if (
- update.node.tagName === "LINK" ||
- update.node.tagName === "STYLE"
- ) {
+ } else if (update.node.tagName === "LINK" || update.node.tagName === "STYLE") {
// This might cause CSS specifity issues....
// I'm not 100% sure this is a safe operation
const sheet = new CSSStyleSheet();
@@ -433,10 +381,7 @@ if (typeof window !== "undefined") {
sheet.replaceSync(decoded);
update.node.remove();
- document.adoptedStyleSheets = [
- ...document.adoptedStyleSheets,
- sheet,
- ];
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
}
break;
}
@@ -445,9 +390,7 @@ if (typeof window !== "undefined") {
bytes = null;
}
- filePath(
- file_change_notification: API.WebsocketMessageFileChangeNotification,
- ): string | null {
+ filePath(file_change_notification: API.WebsocketMessageFileChangeNotification): string | null {
if (file_change_notification.loader !== API.Loader.css) return null;
const tag = this.findCSSLinkTag(file_change_notification.id);
@@ -481,9 +424,7 @@ if (typeof window !== "undefined") {
start() {
if (runOnce) {
- __hmrlog.warn(
- "Attempted to start HMR client multiple times. This may be a bug.",
- );
+ __hmrlog.warn("Attempted to start HMR client multiple times. This may be a bug.");
return;
}
@@ -508,23 +449,18 @@ if (typeof window !== "undefined") {
debouncedReconnect = () => {
if (
this.socket &&
- (this.socket.readyState == this.socket.OPEN ||
- this.socket.readyState == this.socket.CONNECTING)
+ (this.socket.readyState == this.socket.OPEN || this.socket.readyState == this.socket.CONNECTING)
)
return;
- this.nextReconnectAttempt = setTimeout(
- this.attemptReconnect,
- this.reconnectDelay,
- );
+ this.nextReconnectAttempt = setTimeout(this.attemptReconnect, this.reconnectDelay);
};
attemptReconnect = () => {
globalThis.clearTimeout(this.nextReconnectAttempt);
if (
this.socket &&
- (this.socket.readyState == this.socket.OPEN ||
- this.socket.readyState == this.socket.CONNECTING)
+ (this.socket.readyState == this.socket.OPEN || this.socket.readyState == this.socket.CONNECTING)
)
return;
this.connect();
@@ -534,8 +470,7 @@ if (typeof window !== "undefined") {
connect() {
if (
this.socket &&
- (this.socket.readyState == this.socket.OPEN ||
- this.socket.readyState == this.socket.CONNECTING)
+ (this.socket.readyState == this.socket.OPEN || this.socket.readyState == this.socket.CONNECTING)
)
return;
@@ -583,10 +518,7 @@ if (typeof window !== "undefined") {
case CSSImportState.Pending: {
this.cssState = CSSImportState.Loading;
// This means we can import without risk of FOUC
- if (
- document.documentElement.innerText === "" &&
- !HMRClient.cssAutoFOUC
- ) {
+ if (document.documentElement.innerText === "" && !HMRClient.cssAutoFOUC) {
if (document.body) document.body.style.visibility = "hidden";
HMRClient.cssAutoFOUC = true;
}
@@ -670,11 +602,8 @@ if (typeof window !== "undefined") {
resolve();
};
- link.onerror = (evt) => {
- console.error(
- `[CSS Importer] Error loading CSS file: ${urlString}\n`,
- evt.toString(),
- );
+ link.onerror = evt => {
+ console.error(`[CSS Importer] Error loading CSS file: ${urlString}\n`, evt.toString());
reject();
};
document.head.appendChild(link);
@@ -683,21 +612,14 @@ if (typeof window !== "undefined") {
}
static onError(event: ErrorEvent) {
if ("error" in event && !!event.error) {
- BunError.render(
- event.error,
- HMRClient.client ? HMRClient.client.cwd : "",
- );
+ BunError.render(event.error, HMRClient.client ? HMRClient.client.cwd : "");
}
}
static activate(verboseOrFastRefresh: boolean = false) {
// Support browser-like envirnments where location and WebSocket exist
// Maybe it'll work in Deno! Who knows.
- if (
- this.client ||
- !("location" in globalThis) ||
- !("WebSocket" in globalThis)
- ) {
+ if (this.client || !("location" in globalThis) || !("WebSocket" in globalThis)) {
return;
}
@@ -757,9 +679,7 @@ if (typeof window !== "undefined") {
reportBuildFailure(failure: API.WebsocketMessageBuildFailure) {
BunError.render(failure, this.cwd);
- console.group(
- `Build failed: ${failure.module_path} (${failure.log.errors} errors)`,
- );
+ console.group(`Build failed: ${failure.module_path} (${failure.log.errors} errors)`);
this.needsConsoleClear = true;
for (let msg of failure.log.msgs) {
var logFunction;
@@ -830,13 +750,8 @@ if (typeof window !== "undefined") {
return;
}
var bytes =
- buffer.data.byteOffset + buffer.index + build.blob_length <=
- buffer.data.buffer.byteLength
- ? new Uint8Array(
- buffer.data.buffer,
- buffer.data.byteOffset + buffer.index,
- build.blob_length,
- )
+ buffer.data.byteOffset + buffer.index + build.blob_length <= buffer.data.buffer.byteLength
+ ? new Uint8Array(buffer.data.buffer, buffer.data.byteOffset + buffer.index, build.blob_length)
: (empty ||= new Uint8Array(0));
if (build.loader === API.Loader.css) {
@@ -876,22 +791,13 @@ if (typeof window !== "undefined") {
}
if (end > 4 && buffer.data.length >= end + 4) {
- new Uint8Array(this.hashBuffer.buffer).set(
- buffer.data.subarray(end, end + 4),
- );
+ new Uint8Array(this.hashBuffer.buffer).set(buffer.data.subarray(end, end + 4));
hash = this.hashBuffer[0];
}
// These are the bytes!!
- var reload = new HotReload(
- build.id,
- index,
- build,
- bytes,
- ReloadBehavior.hotReload,
- hash || 0,
- );
+ var reload = new HotReload(build.id, index, build, bytes, ReloadBehavior.hotReload, hash || 0);
bytes = null;
reload.timings.notify = timestamp - build.from_timestamp;
@@ -910,17 +816,10 @@ if (typeof window !== "undefined") {
this.needsConsoleClear = false;
}
- __hmrlog.log(
- `[${formatDuration(timings.total)}ms] Reloaded`,
- filepath,
- );
+ __hmrlog.log(`[${formatDuration(timings.total)}ms] Reloaded`, filepath);
},
- (err) => {
- if (
- typeof err === "object" &&
- err &&
- err instanceof ThrottleModuleUpdateError
- ) {
+ err => {
+ if (typeof err === "object" && err && err instanceof ThrottleModuleUpdateError) {
return;
}
__hmrlog.error("Hot Module Reload failed!", err);
@@ -940,13 +839,8 @@ if (typeof window !== "undefined") {
}
}
- handleFileChangeNotification(
- buffer: ByteBuffer,
- timestamp: number,
- copy_file_path: boolean,
- ) {
- const notification =
- API.decodeWebsocketMessageFileChangeNotification(buffer);
+ handleFileChangeNotification(buffer: ByteBuffer, timestamp: number, copy_file_path: boolean) {
+ const notification = API.decodeWebsocketMessageFileChangeNotification(buffer);
let file_path = "";
switch (notification.loader) {
case API.Loader.css: {
@@ -974,12 +868,7 @@ if (typeof window !== "undefined") {
}
}
- return this.handleFileChangeNotificationBase(
- timestamp,
- notification,
- file_path,
- copy_file_path,
- );
+ return this.handleFileChangeNotificationBase(timestamp, notification, file_path, copy_file_path);
}
private handleFileChangeNotificationBase(
@@ -1052,9 +941,7 @@ if (typeof window !== "undefined") {
this.buildCommandBufWithFilePath = new Uint8Array(4096 + 256);
}
- const writeBuffer = !copy_file_path
- ? this.buildCommandBuf
- : this.buildCommandBufWithFilePath;
+ const writeBuffer = !copy_file_path ? this.buildCommandBuf : this.buildCommandBufWithFilePath;
writeBuffer[0] = !copy_file_path
? API.WebsocketCommandKind.build
: API.WebsocketCommandKind.build_with_file_path;
@@ -1071,13 +958,8 @@ if (typeof window !== "undefined") {
this.buildCommandUArray[0] = file_path.length;
writeBuffer.set(this.buildCommandUArrayEight, 9);
- const out = textEncoder.encodeInto(
- file_path,
- writeBuffer.subarray(13),
- );
- this.socket.send(
- this.buildCommandBufWithFilePath.subarray(0, 13 + out.written),
- );
+ const out = textEncoder.encodeInto(file_path, writeBuffer.subarray(13));
+ this.socket.send(this.buildCommandBufWithFilePath.subarray(0, 13 + out.written));
} else {
this.socket.send(this.buildCommandBuf);
}
@@ -1118,9 +1000,7 @@ if (typeof window !== "undefined") {
const data = new Uint8Array(event.data);
const message_header_byte_buffer = new ByteBuffer(data);
const header = API.decodeWebsocketMessage(message_header_byte_buffer);
- const buffer = new ByteBuffer(
- data.subarray(message_header_byte_buffer.index),
- );
+ const buffer = new ByteBuffer(data.subarray(message_header_byte_buffer.index));
switch (header.kind) {
case API.WebsocketMessageKind.build_fail: {
@@ -1141,9 +1021,7 @@ if (typeof window !== "undefined") {
return;
}
- const index = HMRModule.dependencies.graph
- .subarray(0, HMRModule.dependencies.graph_used)
- .indexOf(id);
+ const index = HMRModule.dependencies.graph.subarray(0, HMRModule.dependencies.graph_used).indexOf(id);
var file_path: string = "";
var loader = API.Loader.js;
if (index > -1) {
@@ -1203,12 +1081,7 @@ if (typeof window !== "undefined") {
}
}
- this.handleFileChangeNotificationBase(
- timestamp,
- { id, loader },
- file_path,
- true,
- );
+ this.handleFileChangeNotificationBase(timestamp, { id, loader }, file_path, true);
break;
}
case API.WebsocketMessageKind.file_change_notification: {
@@ -1231,27 +1104,15 @@ if (typeof window !== "undefined") {
switch (this.javascriptReloader) {
case API.Reloader.fast_refresh: {
- __hmrlog.log(
- "HMR connected in",
- formatDuration(now - clientStartTime),
- "ms",
- );
+ __hmrlog.log("HMR connected in", formatDuration(now - clientStartTime), "ms");
break;
}
case API.Reloader.live: {
- __hmrlog.log(
- "Live reload connected in",
- formatDuration(now - clientStartTime),
- "ms",
- );
+ __hmrlog.log("Live reload connected in", formatDuration(now - clientStartTime), "ms");
break;
}
default: {
- __hmrlog.log(
- "Bun connected in",
- formatDuration(now - clientStartTime),
- "ms",
- );
+ __hmrlog.log("Bun connected in", formatDuration(now - clientStartTime), "ms");
break;
}
}
@@ -1339,8 +1200,7 @@ if (typeof window !== "undefined") {
const oldGraphUsed = HMRModule.dependencies.graph_used;
var oldModule =
- HMRModule.dependencies.modules.length > this.module_index &&
- HMRModule.dependencies.modules[this.module_index];
+ HMRModule.dependencies.modules.length > this.module_index && HMRModule.dependencies.modules[this.module_index];
HMRModule.dependencies = orig_deps.fork(this.module_index);
var blobURL = "";
@@ -1361,10 +1221,9 @@ if (typeof window !== "undefined") {
: "";
try {
- const blob = new Blob(
- sourceMapURL.length > 0 ? [this.bytes, sourceMapURL] : [this.bytes],
- { type: "text/javascript" },
- );
+ const blob = new Blob(sourceMapURL.length > 0 ? [this.bytes, sourceMapURL] : [this.bytes], {
+ type: "text/javascript",
+ });
blobURL = URL.createObjectURL(blob);
HMRModule.dependencies.blobToID.set(blobURL, this.module_id);
await import(blobURL);
@@ -1378,11 +1237,7 @@ if (typeof window !== "undefined") {
this.bytes = null;
if ("__BunRenderHMRError" in globalThis) {
- globalThis.__BunRenderHMRError(
- exception,
- oldModule.file_path,
- oldModule.id,
- );
+ globalThis.__BunRenderHMRError(exception, oldModule.file_path, oldModule.id);
}
oldModule = null;
@@ -1436,26 +1291,18 @@ if (typeof window !== "undefined") {
if (!isOldModuleDead) {
oldModule.boundUpdate ||= oldModule.update.bind(oldModule);
- if (thisMod.additional_updaters)
- thisMod.additional_updaters.add(oldModule.boundUpdate);
- else
- thisMod.additional_updaters = new Set([
- oldModule.boundUpdate,
- ]);
+ if (thisMod.additional_updaters) thisMod.additional_updaters.add(oldModule.boundUpdate);
+ else thisMod.additional_updaters = new Set([oldModule.boundUpdate]);
thisMod.previousVersion = oldModule;
} else {
- if (oldModule.previousVersion)
- thisMod.previousVersion = oldModule.previousVersion;
+ if (oldModule.previousVersion) thisMod.previousVersion = oldModule.previousVersion;
thisMod.additional_updaters = origUpdaters;
}
}
- const end = Math.min(
- this.module_index + 1,
- HMRModule.dependencies.graph_used,
- );
+ const end = Math.min(this.module_index + 1, HMRModule.dependencies.graph_used);
// -- For generic hot reloading --
// ES Modules delay execution until all imports are parsed
// They execute depth-first
@@ -1505,10 +1352,7 @@ if (typeof window !== "undefined") {
// By the time we get here, it's entirely possible that another update is waiting
// Instead of scheduling it, we are going to just ignore this update.
// But we still need to re-initialize modules regardless because otherwise a dependency may not reload properly
- if (
- pendingUpdateCount === currentPendingUpdateCount &&
- foundBoundary
- ) {
+ if (pendingUpdateCount === currentPendingUpdateCount && foundBoundary) {
FastRefreshLoader.RefreshRuntime.performReactRefresh();
// Remove potential memory leak
if (isOldModuleDead) oldModule.previousVersion = null;
@@ -1527,8 +1371,7 @@ if (typeof window !== "undefined") {
}
} catch (exception) {
HMRModule.dependencies = orig_deps;
- HMRModule.dependencies.modules[this.module_index].additional_updaters =
- origUpdaters;
+ HMRModule.dependencies.modules[this.module_index].additional_updaters = origUpdaters;
throw exception;
}
this.timings.callbacks = performance.now() - callbacksStart;
@@ -1544,12 +1387,8 @@ if (typeof window !== "undefined") {
}
orig_deps = null;
- this.timings.total =
- this.timings.import + this.timings.callbacks + this.timings.notify;
- return Promise.resolve([
- HMRModule.dependencies.modules[this.module_index],
- this.timings,
- ]);
+ this.timings.total = this.timings.import + this.timings.callbacks + this.timings.notify;
+ return Promise.resolve([HMRModule.dependencies.modules[this.module_index], this.timings]);
}
}
@@ -1625,9 +1464,7 @@ if (typeof window !== "undefined") {
// Grow the dependencies graph
if (HMRModule.dependencies.graph.length <= this.graph_index) {
- const new_graph = new Uint32Array(
- HMRModule.dependencies.graph.length * 4,
- );
+ const new_graph = new Uint32Array(HMRModule.dependencies.graph.length * 4);
new_graph.set(HMRModule.dependencies.graph);
HMRModule.dependencies.graph = new_graph;
@@ -1712,11 +1549,8 @@ if (typeof window !== "undefined") {
// 4,000,000,000 in base36 occupies 7 characters
// file path is probably longer
// small strings are better strings
- this.refreshRuntimeBaseID =
- (this.file_path.length > 7 ? this.id.toString(36) : this.file_path) +
- "/";
- FastRefreshLoader.RefreshRuntime =
- FastRefreshLoader.RefreshRuntime || RefreshRuntime;
+ this.refreshRuntimeBaseID = (this.file_path.length > 7 ? this.id.toString(36) : this.file_path) + "/";
+ FastRefreshLoader.RefreshRuntime = FastRefreshLoader.RefreshRuntime || RefreshRuntime;
if (!FastRefreshLoader.hasInjectedFastRefresh) {
RefreshRuntime.injectIntoGlobalHook(globalThis);
@@ -1729,10 +1563,7 @@ if (typeof window !== "undefined") {
// $RefreshReg$
$r_(Component: any, id: string) {
- FastRefreshLoader.RefreshRuntime.register(
- Component,
- this.refreshRuntimeBaseID + id,
- );
+ FastRefreshLoader.RefreshRuntime.register(Component, this.refreshRuntimeBaseID + id);
}
// $RefreshReg$(Component, Component.name || Component.displayName)
$r(Component: any) {
@@ -1767,12 +1598,7 @@ if (typeof window !== "undefined") {
// Ensure exported React components always have names
// This is for simpler debugging
- if (
- Component &&
- typeof Component === "function" &&
- !("name" in Component) &&
- Object.isExtensible(Component)
- ) {
+ if (Component && typeof Component === "function" && !("name" in Component) && Object.isExtensible(Component)) {
const named = {
get() {
return key;
@@ -1791,9 +1617,7 @@ if (typeof window !== "undefined") {
} catch (exception) {}
}
- if (
- !FastRefreshLoader.RefreshRuntime.isLikelyComponentType(Component)
- ) {
+ if (!FastRefreshLoader.RefreshRuntime.isLikelyComponentType(Component)) {
onlyExportsComponents = false;
// We can't stop here because we may have other exports which are components that need to be registered.
continue;
diff --git a/src/runtime/regenerator.ts b/src/runtime/regenerator.ts
index 0940fb9f1..a3a7ba75e 100644
--- a/src/runtime/regenerator.ts
+++ b/src/runtime/regenerator.ts
@@ -37,8 +37,7 @@ var runtime = (function (exports) {
function wrap(innerFn, outerFn, self, tryLocsList) {
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
- var protoGenerator =
- outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
var generator = Object.create(protoGenerator.prototype);
var context = new Context(tryLocsList || []);
@@ -104,18 +103,11 @@ var runtime = (function (exports) {
IteratorPrototype = NativeIteratorPrototype;
}
- var Gp =
- (GeneratorFunctionPrototype.prototype =
- Generator.prototype =
- Object.create(IteratorPrototype));
+ var Gp = (GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype));
GeneratorFunction.prototype = GeneratorFunctionPrototype;
define(Gp, "constructor", GeneratorFunctionPrototype);
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
- GeneratorFunction.displayName = define(
- GeneratorFunctionPrototype,
- toStringTagSymbol,
- "GeneratorFunction",
- );
+ GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
// Helper for defining the .next, .throw, and .return methods of the
// Iterator interface in terms of a single ._invoke method.
@@ -164,11 +156,7 @@ var runtime = (function (exports) {
} else {
var result = record.arg;
var value = result.value;
- if (
- value &&
- typeof value === "object" &&
- hasOwn.call(value, "__await")
- ) {
+ if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
return PromiseImpl.resolve(value.__await).then(
function (value) {
invoke("next", value, resolve, reject);
@@ -245,10 +233,7 @@ var runtime = (function (exports) {
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
if (PromiseImpl === void 0) PromiseImpl = Promise;
- var iter = new AsyncIterator(
- wrap(innerFn, outerFn, self, tryLocsList),
- PromiseImpl,
- );
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
return exports.isGeneratorFunction(outerFn)
? iter // If outerFn is a generator, return the full iterator.
@@ -358,9 +343,7 @@ var runtime = (function (exports) {
}
context.method = "throw";
- context.arg = new TypeError(
- "The iterator does not provide a 'throw' method",
- );
+ context.arg = new TypeError("The iterator does not provide a 'throw' method");
}
return ContinueSentinel;
@@ -551,11 +534,7 @@ var runtime = (function (exports) {
if (!skipTempReset) {
for (var name in this) {
// Not sure about the optimal order of these conditions:
- if (
- name.charAt(0) === "t" &&
- hasOwn.call(this, name) &&
- !isNaN(+name.slice(1))
- ) {
+ if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
this[name] = undefined;
}
}
@@ -634,11 +613,7 @@ var runtime = (function (exports) {
abrupt: function (type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
- if (
- entry.tryLoc <= this.prev &&
- hasOwn.call(entry, "finallyLoc") &&
- this.prev < entry.finallyLoc
- ) {
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
diff --git a/src/sha.zig b/src/sha.zig
index fec9d68bd..214ca0445 100644
--- a/src/sha.zig
+++ b/src/sha.zig
@@ -1,5 +1,6 @@
const BoringSSL = @import("bun").BoringSSL;
const std = @import("std");
+pub const bun = @import("./bun.zig");
fn NewHasher(comptime digest_size: comptime_int, comptime ContextType: type, comptime Full: anytype, comptime Init: anytype, comptime Update: anytype, comptime Final: anytype) type {
return struct {
@@ -85,6 +86,7 @@ pub const EVP = struct {
pub const SHA256 = NewEVP(std.crypto.hash.sha2.Sha256.digest_length, "EVP_sha256");
pub const SHA512_256 = NewEVP(std.crypto.hash.sha2.Sha512256.digest_length, "EVP_sha512_256");
pub const MD5_SHA1 = NewEVP(std.crypto.hash.Sha1.digest_length, "EVP_md5_sha1");
+ pub const Blake2 = NewEVP(256 / 8, "EVP_blake2b256");
};
pub const SHA1 = EVP.SHA1;
@@ -160,6 +162,8 @@ const boring = [_]type{
Hashers.SHA384,
Hashers.SHA256,
Hashers.SHA512_256,
+ void,
+ void,
};
const zig = [_]type{
@@ -168,6 +172,8 @@ const zig = [_]type{
std.crypto.hash.sha2.Sha384,
std.crypto.hash.sha2.Sha256,
std.crypto.hash.sha2.Sha512256,
+ std.crypto.hash.blake2.Blake2b256,
+ std.crypto.hash.Blake3,
};
const evp = [_]type{
@@ -176,6 +182,8 @@ const evp = [_]type{
EVP.SHA384,
EVP.SHA256,
EVP.SHA512_256,
+ EVP.Blake2,
+ void,
};
const labels = [_][]const u8{
@@ -184,6 +192,8 @@ const labels = [_][]const u8{
"SHA384",
"SHA256",
"SHA512_256",
+ "Blake2",
+ "Blake3",
};
pub fn main() anyerror!void {
var file = try std.fs.cwd().openFileZ(std.os.argv[std.os.argv.len - 1], .{});
@@ -191,52 +201,121 @@ pub fn main() anyerror!void {
var engine = BoringSSL.ENGINE_new().?;
- inline for (boring, 0..) |BoringHasher, i| {
- const ZigHasher = zig[i];
+ std.debug.print(
+ "Hashing {any:3}\n\n",
+ .{bun.fmt.size(bytes.len)},
+ );
+
+ {
+ var clock1 = try std.time.Timer.start();
+ std.mem.doNotOptimizeAway(std.hash.Wyhash.hash(0, bytes));
+ const zig_time = clock1.read();
std.debug.print(
- comptime labels[i] ++ " - hashing {.3f}:\n",
- .{std.fmt.fmtIntSizeBin(bytes.len)},
+ "Wyhash:\n\n zig: {any}\n\n",
+ .{std.fmt.fmtDuration(zig_time)},
);
- var digest1: BoringHasher.Digest = undefined;
- var digest2: BoringHasher.Digest = undefined;
- var digest3: BoringHasher.Digest = undefined;
- var digest4: BoringHasher.Digest = undefined;
+ }
+ {
var clock1 = try std.time.Timer.start();
- ZigHasher.hash(bytes, &digest1, .{});
+ std.mem.doNotOptimizeAway(std.hash.XxHash64.hash(bytes));
const zig_time = clock1.read();
-
- var clock2 = try std.time.Timer.start();
- BoringHasher.hash(bytes, &digest2);
- const boring_time = clock2.read();
-
- var clock3 = try std.time.Timer.start();
- evp[i].hash(bytes, &digest3, engine);
- const evp_time = clock3.read();
-
- var evp_in = evp[i].init();
- var clock4 = try std.time.Timer.start();
- evp_in.update(bytes);
- evp_in.final(&digest4);
- const evp_in_time = clock4.read();
-
std.debug.print(
- " zig: {}\n",
+ "xxhash:\n\n zig: {any}\n\n",
.{std.fmt.fmtDuration(zig_time)},
);
+ }
+
+ {
+ var clock1 = try std.time.Timer.start();
+ std.mem.doNotOptimizeAway(std.hash.Murmur2_64.hash(bytes));
+ const zig_time = clock1.read();
std.debug.print(
- " boring: {}\n",
- .{std.fmt.fmtDuration(boring_time)},
+ "Murmur2_64:\n\n zig: {any}\n\n",
+ .{std.fmt.fmtDuration(zig_time)},
);
+ }
+
+ inline for (evp, 0..) |BoringHasher, i| {
+ const ZigHasher = zig[i];
std.debug.print(
- " evp: {}\n",
- .{std.fmt.fmtDuration(evp_time)},
+ comptime labels[i] ++ ":\n\n",
+ .{},
);
+ const DigestType = if (BoringHasher != void) BoringHasher.Digest else [32]u8;
+ var digest1: DigestType = undefined;
+ var digest2: DigestType = undefined;
+ var digest3: DigestType = undefined;
+ var digest4: DigestType = undefined;
+ @memset(&digest1, 0, @sizeOf(DigestType));
+ @memset(&digest2, 0, @sizeOf(DigestType));
+ @memset(&digest3, 0, @sizeOf(DigestType));
+ @memset(&digest4, 0, @sizeOf(DigestType));
+ defer {
+ std.mem.doNotOptimizeAway(&digest1);
+ std.mem.doNotOptimizeAway(&digest2);
+ std.mem.doNotOptimizeAway(&digest3);
+ std.mem.doNotOptimizeAway(&digest4);
+ }
+
+ var clock1 = try std.time.Timer.start();
+ ZigHasher.hash(bytes, &digest1, .{});
+ const zig_time = clock1.read();
+
+ const boring_time = brk: {
+ if (BoringHasher != void) {
+ var clock2 = try std.time.Timer.start();
+ BoringHasher.hash(bytes, &digest2, engine);
+ break :brk clock2.read();
+ } else {
+ break :brk 0;
+ }
+ };
+
+ const evp_time: usize = brk: {
+ if (evp[i] != void) {
+ var clock3 = try std.time.Timer.start();
+ evp[i].hash(bytes, &digest3, engine);
+ break :brk clock3.read();
+ }
+
+ break :brk 0;
+ };
+
+ const evp_in_time: usize = brk: {
+ if (evp[i] != void) {
+ var evp_in = evp[i].init();
+ var clock4 = try std.time.Timer.start();
+ evp_in.update(bytes);
+ evp_in.final(&digest4);
+ break :brk clock4.read();
+ }
+
+ break :brk 0;
+ };
+
std.debug.print(
- " evp in: {}\n\n",
- .{std.fmt.fmtDuration(evp_in_time)},
+ " zig: {}\n",
+ .{std.fmt.fmtDuration(zig_time)},
);
+ if (boring_time > 0)
+ std.debug.print(
+ " boring: {}\n",
+ .{std.fmt.fmtDuration(boring_time)},
+ );
+ if (evp_time > 0)
+ std.debug.print(
+ " evp: {}\n",
+ .{std.fmt.fmtDuration(evp_time)},
+ );
+
+ if (evp_in_time > 0)
+ std.debug.print(
+ " evp in: {}\n\n",
+ .{std.fmt.fmtDuration(evp_in_time)},
+ );
+
if (!std.mem.eql(u8, &digest3, &digest2)) {
@panic("\ndigests don't match! for " ++ labels[i]);
}
diff --git a/src/string_immutable.zig b/src/string_immutable.zig
index e5a37006a..e85fc4ef8 100644
--- a/src/string_immutable.zig
+++ b/src/string_immutable.zig
@@ -588,7 +588,7 @@ pub inline fn endsWithChar(self: string, char: u8) bool {
pub fn withoutTrailingSlash(this: string) []const u8 {
var href = this;
while (href.len > 1 and href[href.len - 1] == '/') {
- href = href[0 .. href.len - 1];
+ href.len -= 1;
}
return href;
diff --git a/src/test/fixtures/double-export-default-bug.jsx b/src/test/fixtures/double-export-default-bug.jsx
index 3db411bb0..18f5165f9 100644
--- a/src/test/fixtures/double-export-default-bug.jsx
+++ b/src/test/fixtures/double-export-default-bug.jsx
@@ -20,8 +20,7 @@ export default function Home() {
</h1>
<p className={styles.description}>
- Get started by editing{" "}
- <code className={styles.code}>pages/index.js</code>
+ Get started by editing <code className={styles.code}>pages/index.js</code>
</p>
<div className={styles.grid}>
@@ -35,10 +34,7 @@ export default function Home() {
<p>Learn about Next.js in an interactive course with quizzes!</p>
</a>
- <a
- href="https://github.com/vercel/next.js/tree/master/examples"
- className={styles.card}
- >
+ <a href="https://github.com/vercel/next.js/tree/master/examples" className={styles.card}>
<h2>Examples &rarr;</h2>
<p>Discover and deploy boilerplate example Next.js projects.</p>
</a>
@@ -48,9 +44,7 @@ export default function Home() {
className={styles.card}
>
<h2>Deploy &rarr;</h2>
- <p>
- Instantly deploy your Next.js site to a public URL with Vercel.
- </p>
+ <p>Instantly deploy your Next.js site to a public URL with Vercel.</p>
</a>
</div>
</main>
diff --git a/src/test/fixtures/simple-150x.jsx b/src/test/fixtures/simple-150x.jsx
index 64cb88b1b..3ec65431c 100644
--- a/src/test/fixtures/simple-150x.jsx
+++ b/src/test/fixtures/simple-150x.jsx
@@ -27,19 +27,10 @@ import { SPACING } from "../helpers/styles";
return (
<Link route={buildProfileURL(profile.id)}>
<a className="Profile">
- <img
- src={_.first(profile.photos)}
- srcSet={buildImgSrcSet(_.first(profile.photos), 250)}
- />
+ <img src={_.first(profile.photos)} srcSet={buildImgSrcSet(_.first(profile.photos), 250)} />
<div className="Text">
<div className="Title">
- <Text
- font="sans-serif"
- lineHeight="20px"
- weight="semiBold"
- size="18px"
- color="#000"
- >
+ <Text font="sans-serif" lineHeight="20px" weight="semiBold" size="18px" color="#000">
{profile.name}
</Text>
</div>
@@ -111,18 +102,16 @@ import { SPACING } from "../helpers/styles";
};
}
- setEmail = (evt) => this.setState({ email: evt.target.value });
+ setEmail = evt => this.setState({ email: evt.target.value });
componentDidMount() {
Router.prefetchRoute(`/sign-up/verify`);
}
- handleSubmit = (evt) => {
+ handleSubmit = evt => {
evt.preventDefault();
- Router.pushRoute(
- `/sign-up/verify?${qs.stringify({ email: this.state.email })}`,
- );
+ Router.pushRoute(`/sign-up/verify?${qs.stringify({ email: this.state.email })}`);
};
render() {
@@ -223,24 +212,15 @@ import { SPACING } from "../helpers/styles";
<article>
<main>
<div className="Copy">
- <img
- className="Logo Logo-Home"
- src="/static/animatedlogo.gif"
- />
+ <img className="Logo Logo-Home" src="/static/animatedlogo.gif" />
<div className="Copy-title">
- <Text
- font="serif"
- size="36px"
- lineHeight="44px"
- weight="bold"
- >
+ <Text font="serif" size="36px" lineHeight="44px" weight="bold">
Your own game of The Bachelor(ette)
</Text>
</div>
<div className="Copy-body">
<Text size="16px" lineHeight="24px" font="sans-serif">
- Create a page where people apply to go on a date with you.
- You pick the winners.
+ Create a page where people apply to go on a date with you. You pick the winners.
</Text>
</div>
@@ -282,9 +262,7 @@ import { SPACING } from "../helpers/styles";
{this.state.isLoadingProfiles && <div className="Spinner" />}
<div className="FeaturedProfiles">
{!_.isEmpty(this.state.profiles) &&
- this.state.profiles.map((profile) => (
- <FeaturedProfile key={profile.id} profile={profile} />
- ))}
+ this.state.profiles.map(profile => <FeaturedProfile key={profile.id} profile={profile} />)}
</div>
</div>
</footer>
@@ -438,7 +416,7 @@ import { SPACING } from "../helpers/styles";
}
}
- const HomepageWithStore = withRedux(initStore, null, (dispatch) =>
+ const HomepageWithStore = withRedux(initStore, null, dispatch =>
bindActionCreators({ updateEntities, setCurrentUser }, dispatch),
)(LoginGate(Homepage));
})();
diff --git a/src/test/fixtures/simple.jsx b/src/test/fixtures/simple.jsx
index 63873fe8d..98d01235b 100644
--- a/src/test/fixtures/simple.jsx
+++ b/src/test/fixtures/simple.jsx
@@ -25,19 +25,10 @@ const FeaturedProfile = ({ profile }) => {
return (
<Link route={buildProfileURL(profile.id)}>
<a className="Profile">
- <img
- src={_.first(profile.photos)}
- srcSet={buildImgSrcSet(_.first(profile.photos), 250)}
- />
+ <img src={_.first(profile.photos)} srcSet={buildImgSrcSet(_.first(profile.photos), 250)} />
<div className="Text">
<div className="Title">
- <Text
- font="sans-serif"
- lineHeight="20px"
- weight="semiBold"
- size="18px"
- color="#000"
- >
+ <Text font="sans-serif" lineHeight="20px" weight="semiBold" size="18px" color="#000">
{profile.name}
</Text>
</div>
@@ -109,18 +100,16 @@ class SignupForm extends React.Component {
};
}
- setEmail = (evt) => this.setState({ email: evt.target.value });
+ setEmail = evt => this.setState({ email: evt.target.value });
componentDidMount() {
Router.prefetchRoute(`/sign-up/verify`);
}
- handleSubmit = (evt) => {
+ handleSubmit = evt => {
evt.preventDefault();
- Router.pushRoute(
- `/sign-up/verify?${qs.stringify({ email: this.state.email })}`,
- );
+ Router.pushRoute(`/sign-up/verify?${qs.stringify({ email: this.state.email })}`);
};
render() {
@@ -229,8 +218,7 @@ class Homepage extends React.Component {
</div>
<div className="Copy-body">
<Text size="16px" lineHeight="24px" font="sans-serif">
- Create a page where people apply to go on a date with you. You
- pick the winners.
+ Create a page where people apply to go on a date with you. You pick the winners.
</Text>
</div>
@@ -272,9 +260,7 @@ class Homepage extends React.Component {
{this.state.isLoadingProfiles && <div className="Spinner" />}
<div className="FeaturedProfiles">
{!_.isEmpty(this.state.profiles) &&
- this.state.profiles.map((profile) => (
- <FeaturedProfile key={profile.id} profile={profile} />
- ))}
+ this.state.profiles.map(profile => <FeaturedProfile key={profile.id} profile={profile} />)}
</div>
</div>
</footer>
@@ -428,7 +414,7 @@ class Homepage extends React.Component {
}
}
-const HomepageWithStore = withRedux(initStore, null, (dispatch) =>
+const HomepageWithStore = withRedux(initStore, null, dispatch =>
bindActionCreators({ updateEntities, setCurrentUser }, dispatch),
)(LoginGate(Homepage));
diff --git a/test/bun.js/.prettierignore b/test/bun.js/.prettierignore
new file mode 100644
index 000000000..91b589eb2
--- /dev/null
+++ b/test/bun.js/.prettierignore
@@ -0,0 +1,2 @@
+node_modules
+third-party
diff --git a/test/bun.js/baz.js b/test/bun.js/baz.js
index 5837bb3bb..58a9bb4b0 100644
--- a/test/bun.js/baz.js
+++ b/test/bun.js/baz.js
@@ -1,2 +1,3 @@
// this file is used in resolve.test.js
+//
export default {};
diff --git a/test/bun.js/body-stream.test.ts b/test/bun.js/body-stream.test.ts
index 9a68ad3bc..1cd932ed9 100644
--- a/test/bun.js/body-stream.test.ts
+++ b/test/bun.js/body-stream.test.ts
@@ -3,7 +3,7 @@ import { file, gc, serve, ServeOptions } from "bun";
import { afterAll, afterEach, describe, expect, it, test } from "bun:test";
import { readFileSync } from "fs";
-var port = 4021;
+var port = 0;
{
const BodyMixin = [
diff --git a/test/bun.js/buffer.test.js b/test/bun.js/buffer.test.js
index 0dcf96816..b8fade4d2 100644
--- a/test/bun.js/buffer.test.js
+++ b/test/bun.js/buffer.test.js
@@ -2552,7 +2552,10 @@ it("should not perform out-of-bound access on invalid UTF-8 byte sequence", () =
});
it("repro #2063", () => {
- const buf = Buffer.from("eyJlbWFpbCI6Ijg3MTg4NDYxN0BxcS5jb20iLCJpZCI6OCwicm9sZSI6Im5vcm1hbCIsImlhdCI6MTY3NjI4NDQyMSwiZXhwIjoxNjc2ODg5MjIxfQ", 'base64');
+ const buf = Buffer.from(
+ "eyJlbWFpbCI6Ijg3MTg4NDYxN0BxcS5jb20iLCJpZCI6OCwicm9sZSI6Im5vcm1hbCIsImlhdCI6MTY3NjI4NDQyMSwiZXhwIjoxNjc2ODg5MjIxfQ",
+ "base64",
+ );
expect(buf.length).toBe(85);
expect(buf[82]).toBe(50);
expect(buf[83]).toBe(49);
diff --git a/test/bun.js/bun-server.test.ts b/test/bun.js/bun-server.test.ts
index d5aae537e..52574d2a3 100644
--- a/test/bun.js/bun-server.test.ts
+++ b/test/bun.js/bun-server.test.ts
@@ -48,4 +48,124 @@ describe("Server", () => {
server.stop(true);
}
});
+
+ test("abort signal on server should only fire if aborted", async () => {
+ {
+ const abortController = new AbortController();
+
+ let signalOnServer = false;
+ const server = Bun.serve({
+ async fetch(req) {
+ req.signal.addEventListener("abort", () => {
+ signalOnServer = true;
+ });
+ return new Response("Hello");
+ },
+ port: 0,
+ });
+
+ try {
+ await fetch(`http://${server.hostname}:${server.port}`, { signal: abortController.signal });
+ } catch {}
+ expect(signalOnServer).toBe(false);
+ server.stop(true);
+ }
+ });
+
+ test("abort signal on server with direct stream", async () => {
+ {
+ let signalOnServer = false;
+ const abortController = new AbortController();
+
+ const server = Bun.serve({
+ async fetch(req) {
+ req.signal.addEventListener("abort", () => {
+ signalOnServer = true;
+ });
+ return new Response(
+ new ReadableStream({
+ type: "direct",
+ async pull(controller) {
+ abortController.abort();
+
+ const buffer = await Bun.file(import.meta.dir + "/fixture.html.gz").arrayBuffer();
+ controller.write(buffer);
+
+ //wait to detect the connection abortion
+ await Bun.sleep(15);
+
+ controller.close();
+ },
+ }),
+ {
+ headers: {
+ "Content-Encoding": "gzip",
+ "Content-Type": "text/html; charset=utf-8",
+ "Content-Length": "1",
+ },
+ },
+ );
+ },
+ port: 0,
+ });
+
+ try {
+ await fetch(`http://${server.hostname}:${server.port}`, { signal: abortController.signal });
+ } catch {}
+ await Bun.sleep(10);
+ expect(signalOnServer).toBe(true);
+ server.stop(true);
+ }
+ });
+
+ test("abort signal on server with stream", async () => {
+ {
+ let signalOnServer = false;
+ const abortController = new AbortController();
+
+ const server = Bun.serve({
+ async fetch(req) {
+ req.signal.addEventListener("abort", () => {
+ signalOnServer = true;
+ });
+ return new Response(
+ new ReadableStream({
+ async pull(controller) {
+ console.trace("here");
+ abortController.abort();
+
+ const buffer = await Bun.file(import.meta.dir + "/fixture.html.gz").arrayBuffer();
+ console.trace("here");
+ controller.enqueue(buffer);
+ console.trace("here");
+
+ //wait to detect the connection abortion
+ await Bun.sleep(15);
+ controller.close();
+ },
+ }),
+ {
+ headers: {
+ "Content-Encoding": "gzip",
+ "Content-Type": "text/html; charset=utf-8",
+ "Content-Length": "1",
+ },
+ },
+ );
+ },
+ port: 0,
+ });
+
+ try {
+ console.trace("here");
+ await fetch(`http://${server.hostname}:${server.port}`, { signal: abortController.signal });
+ } catch {}
+ await Bun.sleep(10);
+ console.trace("here");
+ expect(signalOnServer).toBe(true);
+ console.trace("here");
+ server.stop(true);
+ console.trace("here");
+ }
+ });
});
diff --git a/test/bun.js/bun-write.test.js b/test/bun.js/bun-write.test.js
index 7e1d43059..c324d36a0 100644
--- a/test/bun.js/bun-write.test.js
+++ b/test/bun.js/bun-write.test.js
@@ -139,6 +139,14 @@ it("Bun.file", async () => {
await gcTick();
});
+it("Bun.file empty file", async () => {
+ const file = path.join(import.meta.dir, "emptyFile");
+ await gcTick();
+ const buffer = await Bun.file(file).arrayBuffer();
+ expect(buffer.byteLength).toBe(0);
+ await gcTick();
+});
+
it("Bun.file as a Blob", async () => {
const filePath = path.join(import.meta.path, "../fetch.js.txt");
const fixture = fs.readFileSync(filePath, "utf8");
diff --git a/test/bun.js/disabled-module.test.js b/test/bun.js/disabled-module.test.js
index c12676959..61411aa44 100644
--- a/test/bun.js/disabled-module.test.js
+++ b/test/bun.js/disabled-module.test.js
@@ -1,38 +1,72 @@
import { expect, test } from "bun:test";
-test("not implemented yet module masquerades as undefined and throws an error", () => {
- const worker_threads = import.meta.require("worker_threads");
+// test("not implemented yet module masquerades as undefined and throws an error", () => {
+// const worker_threads = import.meta.require("worker_threads");
- expect(typeof worker_threads).toBe("undefined");
- expect(typeof worker_threads.getEnvironmentData).toBe("undefined");
+// expect(typeof worker_threads).toBe("undefined");
+// expect(typeof worker_threads.getEnvironmentData).toBe("undefined");
+// });
+
+test("AsyncContext", async done => {
+ const { AsyncContext } = import.meta.require("async_hooks");
+ console.log("here");
+ const ctx = new AsyncContext();
+ ctx
+ .run(1234, async () => {
+ expect(ctx.get()).toBe(1234);
+ console.log("here");
+ await 1;
+ console.log("ctx", ctx.get());
+ const setTimeoutResult = await ctx.run(
+ 2345,
+ () =>
+ new Promise(resolve => {
+ queueMicrotask(() => {
+ console.log("queueMicrotask", ctx.get());
+ resolve(ctx.get());
+ });
+ }),
+ );
+ expect(setTimeoutResult).toBe(2345);
+ expect(ctx.get()).toBe(1234);
+ return "final result";
+ })
+ .then(result => {
+ expect(result).toBe("final result");
+ // The code that generated the Promise has access to the 1234
+ // value provided to ctx.run above, but consumers of the Promise
+ // do not automatically inherit it.
+ expect(ctx.get()).toBeUndefined();
+ done();
+ });
});
-test("AsyncLocalStorage polyfill", () => {
- const { AsyncLocalStorage } = import.meta.require("async_hooks");
+// test("AsyncLocalStorage polyfill", () => {
+// const { AsyncLocalStorage } = import.meta.require("async_hooks");
- const store = new AsyncLocalStorage();
- var called = false;
- expect(store.getStore()).toBe(null);
- store.run({ foo: "bar" }, () => {
- expect(store.getStore()).toEqual({ foo: "bar" });
- called = true;
- });
- expect(store.getStore()).toBe(null);
- expect(called).toBe(true);
-});
+// const store = new AsyncLocalStorage();
+// var called = false;
+// expect(store.getStore()).toBe(null);
+// store.run({ foo: "bar" }, () => {
+// expect(store.getStore()).toEqual({ foo: "bar" });
+// called = true;
+// });
+// expect(store.getStore()).toBe(null);
+// expect(called).toBe(true);
+// });
-test("AsyncResource polyfill", () => {
- const { AsyncResource } = import.meta.require("async_hooks");
+// test("AsyncResource polyfill", () => {
+// const { AsyncResource } = import.meta.require("async_hooks");
- const resource = new AsyncResource("test");
- var called = false;
- resource.runInAsyncScope(
- () => {
- called = true;
- },
- null,
- "foo",
- "bar",
- );
- expect(called).toBe(true);
-});
+// const resource = new AsyncResource("test");
+// var called = false;
+// resource.runInAsyncScope(
+// () => {
+// called = true;
+// },
+// null,
+// "foo",
+// "bar",
+// );
+// expect(called).toBe(true);
+// });
diff --git a/test/bun.js/emptyFile b/test/bun.js/emptyFile
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test/bun.js/emptyFile
diff --git a/test/bun.js/event-emitter.test.ts b/test/bun.js/event-emitter.test.ts
index cd1eaeaf2..2bb891778 100644
--- a/test/bun.js/event-emitter.test.ts
+++ b/test/bun.js/event-emitter.test.ts
@@ -150,7 +150,7 @@ test("EventEmitter GCs", () => {
(function () {
Bun.gc(true);
- function EventEmitterSubclass() {
+ function EventEmitterSubclass(this: any) {
EventEmitter.call(this);
}
diff --git a/test/bun.js/fetch.test.js b/test/bun.js/fetch.test.js
index 1c27c53a0..be64a0109 100644
--- a/test/bun.js/fetch.test.js
+++ b/test/bun.js/fetch.test.js
@@ -27,115 +27,6 @@ afterEach(() => {
const payload = new Uint8Array(1024 * 1024 * 2);
crypto.getRandomValues(payload);
-describe("AbortSignalStreamTest", async () => {
- async function abortOnStage(body, stage) {
- let error = undefined;
- var abortController = new AbortController();
- {
- const server = getServer({
- async fetch(request) {
- let chunk_count = 0;
- const reader = request.body.getReader();
- return Response(
- new ReadableStream({
- async pull(controller) {
- while (true) {
- chunk_count++;
-
- const { done, value } = await reader.read();
- if (chunk_count == stage) {
- abortController.abort();
- }
-
- if (done) {
- controller.close();
- return;
- }
- controller.enqueue(value);
- }
- },
- }),
- );
- },
- });
-
- try {
- const signal = abortController.signal;
-
- await fetch(`http://127.0.0.1:${server.port}`, { method: "POST", body, signal: signal }).then(res =>
- res.arrayBuffer(),
- );
- } catch (ex) {
- error = ex;
- }
- expect(error.name).toBe("AbortError");
- expect(error.message).toBe("The operation was aborted.");
- expect(error instanceof DOMException).toBeTruthy();
- }
- }
-
- for (let i = 1; i < 7; i++) {
- it(`Abort after ${i} chunks`, async () => {
- await abortOnStage(payload, i);
- });
- }
-});
-
-describe("AbortSignalDirectStreamTest", () => {
- async function abortOnStage(body, stage) {
- let error = undefined;
- var abortController = new AbortController();
- {
- const server = getServer({
- async fetch(request) {
- let chunk_count = 0;
- const reader = request.body.getReader();
- return Response(
- new ReadableStream({
- type: "direct",
- async pull(controller) {
- while (true) {
- chunk_count++;
-
- const { done, value } = await reader.read();
- if (chunk_count == stage) {
- abortController.abort();
- }
-
- if (done) {
- controller.end();
- return;
- }
- controller.write(value);
- }
- },
- }),
- );
- },
- });
-
- try {
- const signal = abortController.signal;
-
- await fetch(`http://127.0.0.1:${server.port}`, { method: "POST", body, signal: signal }).then(res =>
- res.arrayBuffer(),
- );
- } catch (ex) {
- error = ex;
- }
- expect(error.name).toBe("AbortError");
- expect(error.message).toBe("The operation was aborted.");
- expect(error instanceof DOMException).toBeTruthy();
- }
- }
-
- for (let i = 1; i < 7; i++) {
- it(`Abort after ${i} chunks`, async () => {
- await abortOnStage(payload, i);
- });
- }
-});
-
describe("AbortSignal", () => {
var server;
beforeEach(() => {
@@ -523,31 +414,33 @@ function testBlobInterface(blobbyConstructor, hasBlobFn) {
if (withGC) gc();
});
- it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer -> json${withGC ? " (with gc) " : ""
- }`, async () => {
- if (withGC) gc();
- var response = blobbyConstructor(new TextEncoder().encode(JSON.stringify(jsonObject)));
- if (withGC) gc();
- expect(JSON.stringify(await response.json())).toBe(JSON.stringify(jsonObject));
- if (withGC) gc();
- });
+ it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer -> json${
+ withGC ? " (with gc) " : ""
+ }`, async () => {
+ if (withGC) gc();
+ var response = blobbyConstructor(new TextEncoder().encode(JSON.stringify(jsonObject)));
+ if (withGC) gc();
+ expect(JSON.stringify(await response.json())).toBe(JSON.stringify(jsonObject));
+ if (withGC) gc();
+ });
- it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer -> invalid json${withGC ? " (with gc) " : ""
- }`, async () => {
- if (withGC) gc();
- var response = blobbyConstructor(
- new TextEncoder().encode(JSON.stringify(jsonObject) + " NOW WE ARE INVALID JSON"),
- );
- if (withGC) gc();
- var failed = false;
- try {
- await response.json();
- } catch (e) {
- failed = true;
- }
- expect(failed).toBe(true);
- if (withGC) gc();
- });
+ it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer -> invalid json${
+ withGC ? " (with gc) " : ""
+ }`, async () => {
+ if (withGC) gc();
+ var response = blobbyConstructor(
+ new TextEncoder().encode(JSON.stringify(jsonObject) + " NOW WE ARE INVALID JSON"),
+ );
+ if (withGC) gc();
+ var failed = false;
+ try {
+ await response.json();
+ } catch (e) {
+ failed = true;
+ }
+ expect(failed).toBe(true);
+ if (withGC) gc();
+ });
it(`${jsonObject.hello === true ? "latin1" : "utf16"} text${withGC ? " (with gc) " : ""}`, async () => {
if (withGC) gc();
@@ -557,14 +450,15 @@ function testBlobInterface(blobbyConstructor, hasBlobFn) {
if (withGC) gc();
});
- it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer -> text${withGC ? " (with gc) " : ""
- }`, async () => {
- if (withGC) gc();
- var response = blobbyConstructor(new TextEncoder().encode(JSON.stringify(jsonObject)));
- if (withGC) gc();
- expect(await response.text()).toBe(JSON.stringify(jsonObject));
- if (withGC) gc();
- });
+ it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer -> text${
+ withGC ? " (with gc) " : ""
+ }`, async () => {
+ if (withGC) gc();
+ var response = blobbyConstructor(new TextEncoder().encode(JSON.stringify(jsonObject)));
+ if (withGC) gc();
+ expect(await response.text()).toBe(JSON.stringify(jsonObject));
+ if (withGC) gc();
+ });
it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer${withGC ? " (with gc) " : ""}`, async () => {
if (withGC) gc();
@@ -589,29 +483,30 @@ function testBlobInterface(blobbyConstructor, hasBlobFn) {
if (withGC) gc();
});
- it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer -> arrayBuffer${withGC ? " (with gc) " : ""
- }`, async () => {
- if (withGC) gc();
+ it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer -> arrayBuffer${
+ withGC ? " (with gc) " : ""
+ }`, async () => {
+ if (withGC) gc();
- var response = blobbyConstructor(new TextEncoder().encode(JSON.stringify(jsonObject)));
- if (withGC) gc();
+ var response = blobbyConstructor(new TextEncoder().encode(JSON.stringify(jsonObject)));
+ if (withGC) gc();
- const bytes = new TextEncoder().encode(JSON.stringify(jsonObject));
- if (withGC) gc();
+ const bytes = new TextEncoder().encode(JSON.stringify(jsonObject));
+ if (withGC) gc();
- const compare = new Uint8Array(await response.arrayBuffer());
- if (withGC) gc();
+ const compare = new Uint8Array(await response.arrayBuffer());
+ if (withGC) gc();
- withoutAggressiveGC(() => {
- for (let i = 0; i < compare.length; i++) {
- if (withGC) gc();
+ withoutAggressiveGC(() => {
+ for (let i = 0; i < compare.length; i++) {
+ if (withGC) gc();
- expect(compare[i]).toBe(bytes[i]);
- if (withGC) gc();
- }
- });
- if (withGC) gc();
+ expect(compare[i]).toBe(bytes[i]);
+ if (withGC) gc();
+ }
});
+ if (withGC) gc();
+ });
hasBlobFn &&
it(`${jsonObject.hello === true ? "latin1" : "utf16"} blob${withGC ? " (with gc) " : ""}`, async () => {
@@ -654,11 +549,12 @@ function testBlobInterface(blobbyConstructor, hasBlobFn) {
describe("Bun.file", () => {
const tempdir = require("os").tmpdir();
+ const { join } = require("path");
var callCount = 0;
testBlobInterface(data => {
const blob = new Blob([data]);
const buffer = Bun.peek(blob.arrayBuffer());
- const path = tempdir + "-" + callCount++ + ".bytes";
+ const path = join(tempdir, "tmp-" + callCount++ + ".bytes");
require("fs").writeFileSync(path, buffer);
const file = Bun.file(path);
expect(blob.size).toBe(file.size);
@@ -668,7 +564,7 @@ describe("Bun.file", () => {
it("size is Infinity on a fifo", () => {
try {
unlinkSync("/tmp/test-fifo");
- } catch (e) { }
+ } catch (e) {}
mkfifo("/tmp/test-fifo");
const { size } = Bun.file("/tmp/test-fifo");
@@ -686,14 +582,14 @@ describe("Bun.file", () => {
beforeAll(async () => {
try {
unlinkSync("/tmp/my-new-file");
- } catch { }
+ } catch {}
await Bun.write("/tmp/my-new-file", "hey");
chmodSync("/tmp/my-new-file", 0o000);
});
afterAll(() => {
try {
unlinkSync("/tmp/my-new-file");
- } catch { }
+ } catch {}
});
forEachMethod(m => () => {
@@ -706,7 +602,7 @@ describe("Bun.file", () => {
beforeAll(() => {
try {
unlinkSync("/tmp/does-not-exist");
- } catch { }
+ } catch {}
});
forEachMethod(m => async () => {
@@ -857,12 +753,6 @@ describe("Response", () => {
expect(response.status).toBe(407);
});
- it("body nullable", () => {
- expect(new Response(null).body).toBeNull();
- expect(new Response(undefined).body).toBeNull();
- expect(new Response().body).toBeNull();
- });
-
it("supports headers", () => {
var response = Response.json("hello", {
headers: {
@@ -978,29 +868,6 @@ describe("Request", () => {
expect(await clone.text()).toBe("<div>hello</div>");
});
- it("body nullable", async () => {
- gc();
- {
- const req = new Request("https://hello.com", { body: null });
- expect(req.body).toBeNull();
- }
- gc();
- {
- const req = new Request("https://hello.com", { body: undefined });
- expect(req.body).toBeNull();
- }
- gc();
- {
- const req = new Request("https://hello.com");
- expect(req.body).toBeNull();
- }
- gc();
- {
- const req = new Request("https://hello.com", { body: "" });
- expect(req.body).toBeNull();
- }
- });
-
it("signal", async () => {
gc();
const controller = new AbortController();
@@ -1059,3 +926,26 @@ describe("Headers", () => {
gc();
});
});
+
+it("body nullable", async () => {
+ gc();
+ {
+ const req = new Request("https://hello.com", { body: null });
+ expect(req.body).toBeNull();
+ }
+ gc();
+ {
+ const req = new Request("https://hello.com", { body: undefined });
+ expect(req.body).toBeNull();
+ }
+ gc();
+ {
+ const req = new Request("https://hello.com");
+ expect(req.body).toBeNull();
+ }
+ gc();
+ {
+ const req = new Request("https://hello.com", { body: "" });
+ expect(req.body).not.toBeNull();
+ }
+});
diff --git a/test/bun.js/fetch_headers.test.js b/test/bun.js/fetch_headers.test.js
index 7f8fab188..2e5b9fa52 100644
--- a/test/bun.js/fetch_headers.test.js
+++ b/test/bun.js/fetch_headers.test.js
@@ -19,17 +19,17 @@ describe("Headers", async () => {
});
it("Headers should work", async () => {
- expect(await fetchContent({"x-test": "header 1"})).toBe("header 1");
+ expect(await fetchContent({ "x-test": "header 1" })).toBe("header 1");
});
it("Header names must be valid", async () => {
- expect(() => fetch(url, {headers: {"a\tb:c": "foo" }})).toThrow("Invalid header name: 'a\tb:c'");
- expect(() => fetch(url, {headers: {"❤️": "foo" }})).toThrow("Invalid header name: '❤️'");
+ expect(() => fetch(url, { headers: { "a\tb:c": "foo" } })).toThrow("Invalid header name: 'a\tb:c'");
+ expect(() => fetch(url, { headers: { "❤️": "foo" } })).toThrow("Invalid header name: '❤️'");
});
it("Header values must be valid", async () => {
- expect(() => fetch(url, {headers: {"x-test": "\0" }})).toThrow("Header 'x-test' has invalid value: '\0'");
- expect(() => fetch(url, {headers: {"x-test": "❤️" }})).toThrow("Header 'x-test' has invalid value: '❤️'");
+ expect(() => fetch(url, { headers: { "x-test": "\0" } })).toThrow("Header 'x-test' has invalid value: '\0'");
+ expect(() => fetch(url, { headers: { "x-test": "❤️" } })).toThrow("Header 'x-test' has invalid value: '❤️'");
});
it("repro 1602", async () => {
@@ -42,17 +42,13 @@ describe("Headers", async () => {
expect(roundTripString).toBe(origString);
// This one will pass
- expect(await fetchContent({"x-test": roundTripString})).toBe(roundTripString);
+ expect(await fetchContent({ "x-test": roundTripString })).toBe(roundTripString);
// This would hang
- expect(await fetchContent({"x-test": origString})).toBe(origString);
+ expect(await fetchContent({ "x-test": origString })).toBe(origString);
});
});
async function fetchContent(headers) {
- const res = await fetch(
- url,
- { headers: headers },
- { verbose: true }
- );
+ const res = await fetch(url, { headers: headers }, { verbose: true });
return await res.text();
}
diff --git a/test/bun.js/fs.test.js b/test/bun.js/fs.test.ts
index ce5209c53..4c847d25a 100644
--- a/test/bun.js/fs.test.js
+++ b/test/bun.js/fs.test.ts
@@ -26,6 +26,9 @@ import fs, {
Dirent,
Stats,
} from "node:fs";
+
+import _promises from "node:fs/promises";
+
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -49,7 +52,7 @@ describe("copyFileSync", () => {
it("should work for files < 128 KB", () => {
const tempdir = `/tmp/fs.test.js/${Date.now()}/1234/hi`;
expect(existsSync(tempdir)).toBe(false);
- expect(tempdir.includes(mkdirSync(tempdir, { recursive: true }))).toBe(true);
+ expect(tempdir.includes(mkdirSync(tempdir, { recursive: true })!)).toBe(true);
// that don't exist
copyFileSync(import.meta.path, tempdir + "/copyFileSync.js");
@@ -67,7 +70,7 @@ describe("copyFileSync", () => {
it("should work for files > 128 KB ", () => {
const tempdir = `/tmp/fs.test.js/${Date.now()}-1/1234/hi`;
expect(existsSync(tempdir)).toBe(false);
- expect(tempdir.includes(mkdirSync(tempdir, { recursive: true }))).toBe(true);
+ expect(tempdir.includes(mkdirSync(tempdir, { recursive: true })!)).toBe(true);
var buffer = new Int32Array(128 * 1024);
for (let i = 0; i < buffer.length; i++) {
buffer[i] = i % 256;
@@ -92,7 +95,7 @@ describe("mkdirSync", () => {
it("should create a directory", () => {
const tempdir = `/tmp/fs.test.js/${Date.now()}/1234/hi`;
expect(existsSync(tempdir)).toBe(false);
- expect(tempdir.includes(mkdirSync(tempdir, { recursive: true }))).toBe(true);
+ expect(tempdir.includes(mkdirSync(tempdir, { recursive: true })!)).toBe(true);
expect(existsSync(tempdir)).toBe(true);
});
});
@@ -135,6 +138,7 @@ it("mkdtempSync, readdirSync, rmdirSync and unlinkSync with non-ascii", () => {
});
it("mkdtempSync() empty name", () => {
+ // @ts-ignore-next-line
const tempdir = mkdtempSync();
expect(existsSync(tempdir)).toBe(true);
writeFileSync(tempdir + "/non-ascii-👍.txt", "hello");
@@ -188,7 +192,7 @@ it("readdirSync throws when given a file path", () => {
try {
readdirSync(import.meta.path);
throw new Error("should not get here");
- } catch (exception) {
+ } catch (exception: any) {
expect(exception.name).toBe("ENOTDIR");
}
});
@@ -197,7 +201,7 @@ it("readdirSync throws when given a path that doesn't exist", () => {
try {
readdirSync(import.meta.path + "/does-not-exist/really");
throw new Error("should not get here");
- } catch (exception) {
+ } catch (exception: any) {
expect(exception.name).toBe("ENOTDIR");
}
});
@@ -206,7 +210,7 @@ it("readdirSync throws when given a file path with trailing slash", () => {
try {
readdirSync(import.meta.path + "/");
throw new Error("should not get here");
- } catch (exception) {
+ } catch (exception: any) {
expect(exception.name).toBe("ENOTDIR");
}
});
@@ -455,7 +459,7 @@ describe("stat", () => {
try {
statSync("/tmp/doesntexist");
throw "statSync should throw";
- } catch (e) {
+ } catch (e: any) {
expect(e.code).toBe("ENOENT");
}
});
@@ -499,8 +503,8 @@ describe("rmdir", () => {
rmdir(path, err => {
try {
expect(err).toBeDefined();
- expect(err.code).toBe("EPERM");
- expect(err.message).toBe("Operation not permitted");
+ expect(err!.code).toBe("EPERM");
+ expect(err!.message).toBe("Operation not permitted");
expect(existsSync(path)).toBe(true);
} catch (e) {
return done(e);
@@ -621,6 +625,7 @@ describe("fs.WriteStream", () => {
});
it("should be constructable", () => {
+ // @ts-ignore-next-line
const stream = new fs.WriteStream("test.txt");
expect(stream instanceof fs.WriteStream).toBe(true);
});
@@ -630,6 +635,7 @@ describe("fs.WriteStream", () => {
mkdirForce(pathToDir);
const path = join(pathToDir, `fs-writestream-test.txt`);
+ // @ts-ignore-next-line
const stream = new fs.WriteStream(path, { flags: "w+" });
stream.write("Test file written successfully");
stream.end();
@@ -645,6 +651,7 @@ describe("fs.WriteStream", () => {
});
it("should work if re-exported by name", () => {
+ // @ts-ignore-next-line
const stream = new WriteStream_("test.txt");
expect(stream instanceof WriteStream_).toBe(true);
expect(stream instanceof WriteStreamStar_).toBe(true);
@@ -652,6 +659,7 @@ describe("fs.WriteStream", () => {
});
it("should work if re-exported by name, called without new", () => {
+ // @ts-ignore-next-line
const stream = WriteStream_("test.txt");
expect(stream instanceof WriteStream_).toBe(true);
expect(stream instanceof WriteStreamStar_).toBe(true);
@@ -659,6 +667,7 @@ describe("fs.WriteStream", () => {
});
it("should work if re-exported, as export * from ...", () => {
+ // @ts-ignore-next-line
const stream = new WriteStreamStar_("test.txt");
expect(stream instanceof WriteStream_).toBe(true);
expect(stream instanceof WriteStreamStar_).toBe(true);
@@ -666,6 +675,7 @@ describe("fs.WriteStream", () => {
});
it("should work if re-exported, as export * from..., called without new", () => {
+ // @ts-ignore-next-line
const stream = WriteStreamStar_("test.txt");
expect(stream instanceof WriteStream_).toBe(true);
expect(stream instanceof WriteStreamStar_).toBe(true);
@@ -676,7 +686,7 @@ describe("fs.WriteStream", () => {
const pathToDir = `${tmpdir()}/${Date.now()}`;
mkdirForce(pathToDir);
const path = join(pathToDir, `fs-writestream-re-exported-test.txt`);
-
+ // @ts-ignore-next-line
const stream = new WriteStream_(path, { flags: "w+" });
stream.write("Test file written successfully");
stream.end();
@@ -698,6 +708,7 @@ describe("fs.ReadStream", () => {
});
it("should be constructable", () => {
+ // @ts-ignore-next-line
const stream = new fs.ReadStream("test.txt");
expect(stream instanceof fs.ReadStream).toBe(true);
});
@@ -711,7 +722,7 @@ describe("fs.ReadStream", () => {
encoding: "utf8",
flag: "w+",
});
-
+ // @ts-ignore-next-line
const stream = new fs.ReadStream(path);
stream.setEncoding("utf8");
stream.on("error", e => {
@@ -731,6 +742,7 @@ describe("fs.ReadStream", () => {
});
it("should work if re-exported by name", () => {
+ // @ts-ignore-next-line
const stream = new ReadStream_("test.txt");
expect(stream instanceof ReadStream_).toBe(true);
expect(stream instanceof ReadStreamStar_).toBe(true);
@@ -738,6 +750,7 @@ describe("fs.ReadStream", () => {
});
it("should work if re-exported by name, called without new", () => {
+ // @ts-ignore-next-line
const stream = ReadStream_("test.txt");
expect(stream instanceof ReadStream_).toBe(true);
expect(stream instanceof ReadStreamStar_).toBe(true);
@@ -745,6 +758,7 @@ describe("fs.ReadStream", () => {
});
it("should work if re-exported as export * from ...", () => {
+ // @ts-ignore-next-line
const stream = new ReadStreamStar_("test.txt");
expect(stream instanceof ReadStreamStar_).toBe(true);
expect(stream instanceof ReadStream_).toBe(true);
@@ -752,6 +766,7 @@ describe("fs.ReadStream", () => {
});
it("should work if re-exported as export * from ..., called without new", () => {
+ // @ts-ignore-next-line
const stream = ReadStreamStar_("test.txt");
expect(stream instanceof ReadStreamStar_).toBe(true);
expect(stream instanceof ReadStream_).toBe(true);
@@ -768,6 +783,7 @@ describe("fs.ReadStream", () => {
flag: "w+",
});
+ // @ts-ignore-next-line
const stream = new ReadStream_(path);
stream.setEncoding("utf8");
stream.on("error", e => {
@@ -812,7 +828,7 @@ describe("createWriteStream", () => {
try {
stream.write(null);
expect(() => {}).toThrow(Error);
- } catch (exception) {
+ } catch (exception: any) {
expect(exception.code).toBe("ERR_STREAM_NULL_VALUES");
}
});
@@ -820,12 +836,13 @@ describe("createWriteStream", () => {
it("writing null throws ERR_STREAM_NULL_VALUES (objectMode: true)", async () => {
const path = `/tmp/fs.test.js/${Date.now()}.createWriteStreamNulls.txt`;
const stream = createWriteStream(path, {
+ // @ts-ignore-next-line
objectMode: true,
});
try {
stream.write(null);
expect(() => {}).toThrow(Error);
- } catch (exception) {
+ } catch (exception: any) {
expect(exception.code).toBe("ERR_STREAM_NULL_VALUES");
}
});
@@ -836,7 +853,7 @@ describe("createWriteStream", () => {
try {
stream.write(false);
expect(() => {}).toThrow(Error);
- } catch (exception) {
+ } catch (exception: any) {
expect(exception.code).toBe("ERR_INVALID_ARG_TYPE");
}
});
@@ -844,12 +861,13 @@ describe("createWriteStream", () => {
it("writing false throws ERR_INVALID_ARG_TYPE (objectMode: true)", async () => {
const path = `/tmp/fs.test.js/${Date.now()}.createWriteStreamFalse.txt`;
const stream = createWriteStream(path, {
+ // @ts-ignore-next-line
objectMode: true,
});
try {
stream.write(false);
expect(() => {}).toThrow(Error);
- } catch (exception) {
+ } catch (exception: any) {
expect(exception.code).toBe("ERR_INVALID_ARG_TYPE");
}
});
@@ -893,7 +911,7 @@ describe("fs/promises", () => {
for (const args of fizz) {
try {
// check it doens't segfault when called with invalid arguments
- await promises.readdir(...args);
+ await promises.readdir(...(args as [any, ...any[]]));
} catch (e) {
// check that producing the error doesn't cause any crashes
Bun.inspect(e);
@@ -909,7 +927,7 @@ describe("fs/promises", () => {
try {
await rmdir(path);
expect(() => {}).toThrow();
- } catch (err) {
+ } catch (err: any) {
expect(err.code).toBe("ENOTDIR");
// expect(err.message).toBe("Operation not permitted");
expect(await exists(path)).toBe(true);
@@ -992,6 +1010,7 @@ it("fs.Stats", () => {
it("repro 1516: can use undefined/null to specify default flag", () => {
const path = "/tmp/repro_1516.txt";
writeFileSync(path, "b", { flag: undefined });
+ // @ts-ignore-next-line
expect(readFileSync(path, { encoding: "utf8", flag: null })).toBe("b");
rmSync(path);
});
diff --git a/test/bun.js/gc.js b/test/bun.js/gc.ts
index 3f9678f92..b9d80116d 100644
--- a/test/bun.js/gc.js
+++ b/test/bun.js/gc.ts
@@ -1,5 +1,5 @@
-export function gc() {
- Bun.gc(true);
+export function gc(force: boolean = true) {
+ Bun.gc(force);
}
// we must ensure that finalizers are run
diff --git a/test/bun.js/inspect.test.js b/test/bun.js/inspect.test.js
index 243f23cdc..024a976a3 100644
--- a/test/bun.js/inspect.test.js
+++ b/test/bun.js/inspect.test.js
@@ -275,7 +275,7 @@ const fixture = [
}),
() => require("events"),
() => {
- return new import.meta.require("events").EventEmitter();
+ return new (import.meta.require("events").EventEmitter)();
},
async () => await import("node:assert"),
async () => await import("./empty.js"),
diff --git a/test/bun.js/install/bun-install.test.ts b/test/bun.js/install/bun-install.test.ts
index 6f7a13433..1fb015a59 100644
--- a/test/bun.js/install/bun-install.test.ts
+++ b/test/bun.js/install/bun-install.test.ts
@@ -1304,6 +1304,108 @@ it("should not hoist if name collides with alias", async () => {
await access(join(package_dir, "bun.lockb"));
});
+it("should handle unscoped alias on scoped dependency", async () => {
+ const urls: string[] = [];
+ setHandler(dummyRegistry(urls, { "0.1.0": {} }));
+ await writeFile(
+ join(package_dir, "package.json"),
+ JSON.stringify({
+ name: "foo",
+ version: "0.0.1",
+ dependencies: {
+ "@barn/moo": "latest",
+ moo: "npm:@barn/moo",
+ },
+ }),
+ );
+ const { stdout, stderr, exited } = spawn({
+ cmd: [bunExe(), "install", "--config", import.meta.dir + "/basic.toml"],
+ cwd: package_dir,
+ stdout: null,
+ stdin: "pipe",
+ stderr: "pipe",
+ env,
+ });
+ expect(stderr).toBeDefined();
+ const err = await new Response(stderr).text();
+ expect(err).toContain("Saved lockfile");
+ expect(stdout).toBeDefined();
+ const out = await new Response(stdout).text();
+ expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([
+ " + @barn/moo@0.1.0",
+ " + moo@0.1.0",
+ "",
+ " 1 packages installed",
+ ]);
+ expect(await exited).toBe(0);
+ expect(urls.sort()).toEqual([`${root_url}/@barn/moo`, `${root_url}/@barn/moo-0.1.0.tgz`]);
+ expect(requested).toBe(2);
+ expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".cache", "@barn", "moo"]);
+ expect(await readdirSorted(join(package_dir, "node_modules", "@barn"))).toEqual(["moo"]);
+ expect(await readdirSorted(join(package_dir, "node_modules", "@barn", "moo"))).toEqual(["package.json"]);
+ expect(await file(join(package_dir, "node_modules", "moo", "package.json")).json()).toEqual({
+ name: "@barn/moo",
+ version: "0.1.0",
+ });
+ expect(await readdirSorted(join(package_dir, "node_modules", "moo"))).toEqual(["package.json"]);
+ expect(await file(join(package_dir, "node_modules", "moo", "package.json")).json()).toEqual({
+ name: "@barn/moo",
+ version: "0.1.0",
+ });
+ await access(join(package_dir, "bun.lockb"));
+});
+
+it("should handle scoped alias on unscoped dependency", async () => {
+ const urls: string[] = [];
+ setHandler(dummyRegistry(urls));
+ await writeFile(
+ join(package_dir, "package.json"),
+ JSON.stringify({
+ name: "foo",
+ version: "0.0.1",
+ dependencies: {
+ "@baz/bar": "npm:bar",
+ bar: "latest",
+ },
+ }),
+ );
+ const { stdout, stderr, exited } = spawn({
+ cmd: [bunExe(), "install", "--config", import.meta.dir + "/basic.toml"],
+ cwd: package_dir,
+ stdout: null,
+ stdin: "pipe",
+ stderr: "pipe",
+ env,
+ });
+ expect(stderr).toBeDefined();
+ const err = await new Response(stderr).text();
+ expect(err).toContain("Saved lockfile");
+ expect(stdout).toBeDefined();
+ const out = await new Response(stdout).text();
+ expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([
+ " + @baz/bar@0.0.2",
+ " + bar@0.0.2",
+ "",
+ " 1 packages installed",
+ ]);
+ expect(await exited).toBe(0);
+ expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]);
+ expect(requested).toBe(2);
+ expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".cache", "@baz", "bar"]);
+ expect(await readdirSorted(join(package_dir, "node_modules", "@baz"))).toEqual(["bar"]);
+ expect(await readdirSorted(join(package_dir, "node_modules", "@baz", "bar"))).toEqual(["package.json"]);
+ expect(await file(join(package_dir, "node_modules", "@baz", "bar", "package.json")).json()).toEqual({
+ name: "bar",
+ version: "0.0.2",
+ });
+ expect(await readdirSorted(join(package_dir, "node_modules", "bar"))).toEqual(["package.json"]);
+ expect(await file(join(package_dir, "node_modules", "bar", "package.json")).json()).toEqual({
+ name: "bar",
+ version: "0.0.2",
+ });
+ await access(join(package_dir, "bun.lockb"));
+});
+
it("should handle GitHub URL in dependencies (user/repo)", async () => {
const urls: string[] = [];
setHandler(dummyRegistry(urls));
@@ -2440,11 +2542,11 @@ it("should prefer optionalDependencies over dependencies of the same name", asyn
name: "foo",
version: "0.0.1",
dependencies: {
- "baz": "0.0.5",
+ baz: "0.0.5",
},
optionalDependencies: {
- "baz": "0.0.3",
- }
+ baz: "0.0.3",
+ },
}),
);
const { stdout, stderr, exited } = spawn({
@@ -2466,10 +2568,7 @@ it("should prefer optionalDependencies over dependencies of the same name", asyn
" 1 packages installed",
]);
expect(await exited).toBe(0);
- expect(urls.sort()).toEqual([
- `${root_url}/baz`,
- `${root_url}/baz-0.0.3.tgz`,
- ]);
+ expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.3.tgz`]);
expect(requested).toBe(2);
expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".cache", "baz"]);
expect(await readdirSorted(join(package_dir, "node_modules", "baz"))).toEqual(["index.js", "package.json"]);
@@ -2496,11 +2595,11 @@ it("should prefer dependencies over peerDependencies of the same name", async ()
name: "foo",
version: "0.0.1",
dependencies: {
- "baz": "0.0.5",
+ baz: "0.0.5",
},
peerDependencies: {
- "baz": "0.0.3",
- }
+ baz: "0.0.3",
+ },
}),
);
const { stdout, stderr, exited } = spawn({
@@ -2522,10 +2621,7 @@ it("should prefer dependencies over peerDependencies of the same name", async ()
" 1 packages installed",
]);
expect(await exited).toBe(0);
- expect(urls.sort()).toEqual([
- `${root_url}/baz`,
- `${root_url}/baz-0.0.5.tgz`,
- ]);
+ expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.5.tgz`]);
expect(requested).toBe(2);
expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".cache", "baz"]);
expect(await readdirSorted(join(package_dir, "node_modules", "baz"))).toEqual(["index.js", "package.json"]);
diff --git a/test/bun.js/install/dummy.registry.ts b/test/bun.js/install/dummy.registry.ts
index bc4554a47..a0a215db8 100644
--- a/test/bun.js/install/dummy.registry.ts
+++ b/test/bun.js/install/dummy.registry.ts
@@ -19,7 +19,7 @@ export function dummyRegistry(urls, info: any = { "0.0.2": {} }) {
);
expect(request.headers.get("npm-auth-type")).toBe(null);
expect(await request.text()).toBe("");
- const name = request.url.slice(request.url.lastIndexOf("/") + 1);
+ const name = request.url.slice(request.url.indexOf("/", root_url.length) + 1);
const versions = {};
let version;
for (version in info) {
diff --git a/test/bun.js/install/moo-0.1.0.tgz b/test/bun.js/install/moo-0.1.0.tgz
new file mode 100644
index 000000000..72efff27b
--- /dev/null
+++ b/test/bun.js/install/moo-0.1.0.tgz
Binary files differ
diff --git a/test/bun.js/node-http.test.ts b/test/bun.js/node-http.test.ts
index 3ba383c2e..7818fba62 100644
--- a/test/bun.js/node-http.test.ts
+++ b/test/bun.js/node-http.test.ts
@@ -81,6 +81,7 @@ describe("node:http", () => {
describe("request", () => {
let server;
+ let serverPort;
let timer = null;
beforeAll(() => {
server = createServer((req, res) => {
@@ -89,7 +90,7 @@ describe("node:http", () => {
if (reqUrl.pathname === "/redirect") {
// Temporary redirect
res.writeHead(301, {
- Location: "http://localhost:8126/redirected",
+ Location: `http://localhost:${serverPort}/redirected`,
});
res.end("Got redirect!\n");
return;
@@ -137,7 +138,9 @@ describe("node:http", () => {
res.end("Hello World");
}
});
- server.listen(8126);
+ server.listen({ port: 0 }, (_, __, port) => {
+ serverPort = port;
+ });
});
afterAll(() => {
server.close();
@@ -145,7 +148,7 @@ describe("node:http", () => {
});
it("should make a standard GET request when passed string as first arg", done => {
- const req = request("http://localhost:8126", res => {
+ const req = request(`http://localhost:${serverPort}`, res => {
let data = "";
res.setEncoding("utf8");
res.on("data", chunk => {
@@ -160,8 +163,24 @@ describe("node:http", () => {
req.end();
});
+ it("should make a https:// GET request when passed string as first arg", done => {
+ const req = request("https://example.com", res => {
+ let data = "";
+ res.setEncoding("utf8");
+ res.on("data", chunk => {
+ data += chunk;
+ });
+ res.on("end", () => {
+ expect(data).toContain("This domain is for use in illustrative examples in documents");
+ done();
+ });
+ res.on("error", err => done(err));
+ });
+ req.end();
+ });
+
it("should make a POST request when provided POST method, even without a body", done => {
- const req = request({ host: "localhost", port: 8126, method: "POST" }, res => {
+ const req = request({ host: "localhost", port: serverPort, method: "POST" }, res => {
let data = "";
res.setEncoding("utf8");
res.on("data", chunk => {
@@ -177,7 +196,7 @@ describe("node:http", () => {
});
it("should correctly handle a POST request with a body", done => {
- const req = request({ host: "localhost", port: 8126, method: "POST" }, res => {
+ const req = request({ host: "localhost", port: serverPort, method: "POST" }, res => {
let data = "";
res.setEncoding("utf8");
res.on("data", chunk => {
@@ -194,7 +213,7 @@ describe("node:http", () => {
});
it("should noop request.setSocketKeepAlive without error", () => {
- const req = request("http://localhost:8126");
+ const req = request(`http://localhost:${serverPort}`);
req.setSocketKeepAlive(true, 1000);
req.end();
expect(true).toBe(true);
@@ -209,7 +228,7 @@ describe("node:http", () => {
const req1 = request(
{
host: "localhost",
- port: 8126,
+ port: serverPort,
path: "/timeout",
timeout: 500,
},
@@ -222,7 +241,7 @@ describe("node:http", () => {
const req2 = request(
{
host: "localhost",
- port: 8126,
+ port: serverPort,
path: "/timeout",
},
res => {
@@ -242,7 +261,7 @@ describe("node:http", () => {
const req1Done = createDone();
const req2Done = createDone();
- const req1 = request("http://localhost:8126/pathTest", res => {
+ const req1 = request(`http://localhost:${serverPort}/pathTest`, res => {
let data = "";
res.setEncoding("utf8");
res.on("data", chunk => {
@@ -255,7 +274,7 @@ describe("node:http", () => {
res.on("error", err => req1Done(err));
});
- const req2 = request("http://localhost:8126", { path: "/pathTest" }, res => {
+ const req2 = request(`http://localhost:${serverPort}`, { path: "/pathTest" }, res => {
let data = "";
res.setEncoding("utf8");
res.on("data", chunk => {
@@ -276,7 +295,7 @@ describe("node:http", () => {
});
it("should emit response when response received", done => {
- const req = request("http://localhost:8126");
+ const req = request(`http://localhost:${serverPort}`);
req.on("response", res => {
expect(res.statusCode).toBe(200);
@@ -287,7 +306,7 @@ describe("node:http", () => {
// NOTE: Node http.request doesn't follow redirects by default
it("should handle redirects properly", done => {
- const req = request("http://localhost:8126/redirect", res => {
+ const req = request(`http://localhost:${serverPort}/redirect`, res => {
let data = "";
res.setEncoding("utf8");
res.on("data", chunk => {
@@ -303,7 +322,7 @@ describe("node:http", () => {
});
it("should correctly attach headers to request", done => {
- const req = request({ host: "localhost", port: 8126, headers: { "X-Test": "test" } }, res => {
+ const req = request({ host: "localhost", port: serverPort, headers: { "X-Test": "test" } }, res => {
let data = "";
res.setEncoding("utf8");
res.on("data", chunk => {
@@ -320,7 +339,7 @@ describe("node:http", () => {
});
it("should correct casing of method param", done => {
- const req = request({ host: "localhost", port: 8126, method: "get" }, res => {
+ const req = request({ host: "localhost", port: serverPort, method: "get" }, res => {
let data = "";
res.setEncoding("utf8");
res.on("data", chunk => {
@@ -336,7 +355,7 @@ describe("node:http", () => {
});
it("should allow for port as a string", done => {
- const req = request({ host: "localhost", port: "8126", method: "GET" }, res => {
+ const req = request({ host: "localhost", port: `${serverPort}`, method: "GET" }, res => {
let data = "";
res.setEncoding("utf8");
res.on("data", chunk => {
@@ -350,10 +369,51 @@ describe("node:http", () => {
});
req.end();
});
+
+ it("should allow us to pass a URL object", done => {
+ const req = request(new URL(`http://localhost:${serverPort}`), { method: "POST" }, res => {
+ let data = "";
+ res.setEncoding("utf8");
+ res.on("data", chunk => {
+ data += chunk;
+ });
+ res.on("end", () => {
+ expect(data).toBe("Hello WorldPOST\nHello World");
+ done();
+ });
+ res.on("error", err => done(err));
+ });
+ req.write("Hello World");
+ req.end();
+ });
+
+ it("should ignore body when method is GET/HEAD/OPTIONS", done => {
+ const createDone = createDoneDotAll(done);
+ const methods = ["GET", "HEAD", "OPTIONS"];
+ const dones = {};
+ for (const method of methods) {
+ dones[method] = createDone();
+ }
+ for (const method of methods) {
+ const req = request(`http://localhost:${serverPort}`, { method }, res => {
+ let data = "";
+ res.setEncoding("utf8");
+ res.on("data", chunk => {
+ data += chunk;
+ });
+ res.on("end", () => {
+ expect(data).toBe(method === "GET" ? "Maybe GET maybe not\nHello World" : "");
+ dones[method]();
+ });
+ res.on("error", err => dones[method](err));
+ });
+ req.write("BODY");
+ req.end();
+ }
+ });
});
describe("signal", () => {
-
it("should abort and close the server", done => {
const server = createServer((req, res) => {
res.writeHead(200, { "Content-Type": "text/plain" });
@@ -361,19 +421,19 @@ describe("node:http", () => {
});
//force timeout to not hang tests
- const interval = setTimeout(()=> {
+ const interval = setTimeout(() => {
expect(false).toBe(true);
server.close();
- done()
+ done();
}, 100);
-
+
const signal = AbortSignal.timeout(30);
- signal.addEventListener("abort", ()=> {
+ signal.addEventListener("abort", () => {
clearTimeout(interval);
expect(true).toBe(true);
- done()
+ done();
});
-
+
server.listen({ signal, port: 8130 });
});
});
@@ -457,4 +517,45 @@ describe("node:http", () => {
expect(globalAgent instanceof Agent).toBe(true);
});
});
+
+ describe("ClientRequest.signal", () => {
+ let server;
+ let server_port;
+ let server_host;
+ beforeAll(() => {
+ server = createServer((req, res) => {
+ Bun.sleep(10).then(() => {
+ res.writeHead(200, { "Content-Type": "text/plain" });
+ res.end("Hello World");
+ });
+ });
+ server.listen({ port: 0 }, (_err, host, port) => {
+ server_port = port;
+ server_host = host;
+ });
+ });
+ afterAll(() => {
+ server.close();
+ });
+ it("should attempt to make a standard GET request and abort", done => {
+ get(`http://127.0.0.1:${server_port}`, { signal: AbortSignal.timeout(5) }, res => {
+ let data = "";
+ res.setEncoding("utf8");
+ res.on("data", chunk => {
+ data += chunk;
+ });
+ res.on("end", () => {
+ expect(true).toBeFalsy();
+ done();
+ });
+ res.on("error", _ => {
+ expect(true).toBeFalsy();
+ done();
+ });
+ }).on("error", err => {
+ expect(err?.name).toBe("AbortError");
+ done();
+ });
+ });
+ });
});
diff --git a/test/bun.js/os.test.js b/test/bun.js/os.test.js
index 122969337..ea685cdb7 100644
--- a/test/bun.js/os.test.js
+++ b/test/bun.js/os.test.js
@@ -42,7 +42,11 @@ it("tmpdir", () => {
expect(os.tmpdir()).toBe(process.env.TEMP || process.env.TMP);
expect(os.tmpdir()).toBe(`${process.env.SystemRoot || process.env.windir}\\temp`);
} else {
- expect(os.tmpdir()).toBe(process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp");
+ let dir = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp";
+ if (dir.length > 1 && dir.endsWith("/")) {
+ dir = dir.substring(0, dir.length - 1);
+ }
+ expect(os.tmpdir()).toBe(dir);
}
});
@@ -110,7 +114,8 @@ it("networkInterfaces", () => {
expect(typeof nI.family === "string").toBe(true);
expect(typeof nI.mac === "string").toBe(true);
expect(typeof nI.internal === "boolean").toBe(true);
- if (nI.cidr) // may be null
+ if (nI.cidr)
+ // may be null
expect(typeof nI.cidr).toBe("string");
}
}
diff --git a/test/bun.js/package.json b/test/bun.js/package.json
index 4b47715bb..709dc6602 100644
--- a/test/bun.js/package.json
+++ b/test/bun.js/package.json
@@ -5,5 +5,6 @@
"uuid": "^9.0.0",
"tiny-typed-emitter": "^1.0.0",
"svelte": "^3.52.0"
- }
+ },
+ "prettier": "../../.prettierrc.cjs"
}
diff --git a/test/bun.js/preload-test.test.js b/test/bun.js/preload-test.test.js
new file mode 100644
index 000000000..76603b3a0
--- /dev/null
+++ b/test/bun.js/preload-test.test.js
@@ -0,0 +1,227 @@
+import { spawnSync } from "bun";
+import { describe, expect, test } from "bun:test";
+import { mkdirSync, realpathSync } from "fs";
+import { tmpdir } from "os";
+import { join } from "path";
+import { bunEnv } from "./bunEnv";
+import { bunExe } from "./bunExe";
+const preloadModule = `
+import {plugin} from 'bun';
+
+plugin({
+ setup(build) {
+ build.onResolve({ filter: /.*\.txt$/, }, async (args) => {
+ return {
+ path: args.path,
+ namespace: 'boop'
+ }
+ });
+ build.onResolve({ namespace: "boop", filter: /.*/ }, async (args) => {
+ return {
+ path: args.path,
+ namespace: 'boop'
+ }
+ });
+ build.onLoad({ namespace: "boop", filter: /.*/ }, async (args) => {
+ return {
+ contents: '"hello world"',
+ loader: 'json'
+ }
+ });
+ }
+});
+ `;
+
+const mainModule = `
+ import hey from './hey.txt';
+
+ if (hey !== 'hello world') {
+ throw new Error('preload test failed');
+ }
+
+ console.log('Test passed');
+ process.exit(0);
+`;
+
+const bunfig = `preload = ["./preload.js"]`;
+
+describe("preload", () => {
+ test("works", async () => {
+ const preloadDir = join(realpathSync(tmpdir()), "bun-preload-test");
+ mkdirSync(preloadDir, { recursive: true });
+ const preloadPath = join(preloadDir, "preload.js");
+ const mainPath = join(preloadDir, "main.js");
+ const bunfigPath = join(preloadDir, "bunfig.toml");
+ await Bun.write(preloadPath, preloadModule);
+ await Bun.write(mainPath, mainModule);
+ await Bun.write(bunfigPath, bunfig);
+
+ const cmds = [
+ [bunExe(), "run", mainPath],
+ [bunExe(), mainPath],
+ ];
+
+ for (let cmd of cmds) {
+ const { stderr, exitCode, stdout } = spawnSync({
+ cmd,
+ cwd: preloadDir,
+ stderr: "pipe",
+ stdout: "pipe",
+ env: bunEnv,
+ });
+
+ expect(exitCode).toBe(0);
+ expect(stderr.toString()).toBe("");
+ expect(stdout.toString()).toContain("Test passed");
+ }
+ });
+
+ test("works from CLI", async () => {
+ const preloadDir = join(realpathSync(tmpdir()), "bun-preload-test4");
+ mkdirSync(preloadDir, { recursive: true });
+ const preloadPath = join(preloadDir, "preload.js");
+ const mainPath = join(preloadDir, "main.js");
+ await Bun.write(preloadPath, preloadModule);
+ await Bun.write(mainPath, mainModule);
+
+ const cmds = [
+ [bunExe(), "-r=" + preloadPath, "run", mainPath],
+ [bunExe(), "-r=" + preloadPath, mainPath],
+ ];
+
+ for (let cmd of cmds) {
+ const { stderr, exitCode, stdout } = spawnSync({
+ cmd,
+ cwd: preloadDir,
+ stderr: "pipe",
+ stdout: "pipe",
+ env: bunEnv,
+ });
+
+ expect(exitCode).toBe(0);
+ expect(stderr.toString()).toBe("");
+ expect(stdout.toString()).toContain("Test passed");
+ }
+ });
+
+ describe("as entry point", () => {
+ const preloadModule = `
+import {plugin} from 'bun';
+
+plugin({
+ setup(build) {
+ build.onResolve({ filter: /.*\.txt$/, }, async (args) => {
+ return {
+ path: args.path,
+ namespace: 'boop'
+ }
+ });
+ build.onResolve({ namespace: "boop", filter: /.*/ }, async (args) => {
+ return {
+ path: args.path,
+ namespace: 'boop'
+ }
+ });
+ build.onLoad({ namespace: "boop", filter: /.*/ }, async (args) => {
+ return {
+ contents: 'console.log("Test passed")',
+ loader: 'js'
+ }
+ });
+ }
+});
+ `;
+
+ test("works from CLI", async () => {
+ const preloadDir = join(realpathSync(tmpdir()), "bun-preload-test6");
+ mkdirSync(preloadDir, { recursive: true });
+ const preloadPath = join(preloadDir, "preload.js");
+ const mainPath = join(preloadDir, "boop.txt");
+ await Bun.write(preloadPath, preloadModule);
+ await Bun.write(mainPath, "beep");
+
+ const cmds = [
+ [bunExe(), "-r=" + preloadPath, "run", mainPath],
+ [bunExe(), "-r=" + preloadPath, mainPath],
+ ];
+
+ for (let cmd of cmds) {
+ const { stderr, exitCode, stdout } = spawnSync({
+ cmd,
+ cwd: preloadDir,
+ stderr: "pipe",
+ stdout: "pipe",
+ env: bunEnv,
+ });
+
+ expect(stderr.toString()).toBe("");
+ expect(stdout.toString()).toContain("Test passed");
+ expect(exitCode).toBe(0);
+ }
+ });
+ });
+
+ test("throws an error when preloaded module fails to execute", async () => {
+ const preloadModule = "throw new Error('preload test failed');";
+
+ const preloadDir = join(realpathSync(tmpdir()), "bun-preload-test3");
+ mkdirSync(preloadDir, { recursive: true });
+ const preloadPath = join(preloadDir, "preload.js");
+ const mainPath = join(preloadDir, "main.js");
+ const bunfigPath = join(preloadDir, "bunfig.toml");
+ await Bun.write(preloadPath, preloadModule);
+ await Bun.write(mainPath, mainModule);
+ await Bun.write(bunfigPath, bunfig);
+
+ const cmds = [
+ [bunExe(), "run", mainPath],
+ [bunExe(), mainPath],
+ ];
+
+ for (let cmd of cmds) {
+ const { stderr, exitCode, stdout } = spawnSync({
+ cmd,
+ cwd: preloadDir,
+ stderr: "pipe",
+ stdout: "pipe",
+ env: bunEnv,
+ });
+
+ expect(stderr.toString()).toContain("preload test failed");
+ expect(stdout.toString()).toBe("");
+ expect(exitCode).toBe(1);
+ }
+ });
+
+ test("throws an error when preloaded module not found", async () => {
+ const bunfig = `preload = ["./bad-file.js"]`;
+
+ const preloadDir = join(realpathSync(tmpdir()), "bun-preload-test2");
+ mkdirSync(preloadDir, { recursive: true });
+ const preloadPath = join(preloadDir, "preload.js");
+ const mainPath = join(preloadDir, "main.js");
+ const bunfigPath = join(preloadDir, "bunfig.toml");
+ await Bun.write(preloadPath, preloadModule);
+ await Bun.write(mainPath, mainModule);
+ await Bun.write(bunfigPath, bunfig);
+
+ const cmds = [
+ [bunExe(), "run", mainPath],
+ [bunExe(), mainPath],
+ ];
+
+ for (let cmd of cmds) {
+ const { stderr, exitCode, stdout } = spawnSync({
+ cmd,
+ cwd: preloadDir,
+ stderr: "pipe",
+ stdout: "pipe",
+ env: bunEnv,
+ });
+
+ expect(stderr.toString()).toContain("preload not found ");
+ expect(stdout.toString()).toBe("");
+ expect(exitCode).toBe(1);
+ }
+ });
+});
diff --git a/test/bun.js/repro_2005.test.js b/test/bun.js/repro_2005.test.js
index bd80ab7dd..dc0cd9a97 100644
--- a/test/bun.js/repro_2005.test.js
+++ b/test/bun.js/repro_2005.test.js
@@ -8,5 +8,4 @@ it("regex literal with non-Latin1 should work", () => {
//Incorrect result: 这是一段要替换的文字
expect(text.replace(/要替换/, "")).toBe("这是一段的文字");
-
});
diff --git a/test/bun.js/sleep.js b/test/bun.js/sleep.js
index 080597424..1ec79e79d 100644
--- a/test/bun.js/sleep.js
+++ b/test/bun.js/sleep.js
@@ -1,4 +1,4 @@
-const interval = 0.01;
+const interval = 10;
const now = performance.now();
console.time("Slept");
Bun.sleepSync(interval);
diff --git a/test/bun.js/sleepSync.test.ts b/test/bun.js/sleepSync.test.ts
new file mode 100644
index 000000000..dd2e8818a
--- /dev/null
+++ b/test/bun.js/sleepSync.test.ts
@@ -0,0 +1,32 @@
+import { it, expect } from "bun:test";
+import { sleepSync } from "bun";
+
+it("sleepSync uses milliseconds", async () => {
+ const start = Date.now();
+ sleepSync(5);
+ const end = Date.now();
+ expect(end - start).toBeGreaterThanOrEqual(5);
+ expect(end - start).toBeLessThan(10);
+});
+
+it("sleepSync with no arguments throws", async () => {
+ expect(() => sleepSync()).toThrow();
+});
+
+it("sleepSync with non-numbers throws", async () => {
+ expect(() => sleepSync(true)).toThrow();
+ expect(() => sleepSync(false)).toThrow();
+ expect(() => sleepSync("hi")).toThrow();
+ expect(() => sleepSync({})).toThrow();
+ expect(() => sleepSync([])).toThrow();
+ expect(() => sleepSync(undefined)).toThrow();
+ expect(() => sleepSync(null)).toThrow();
+});
+
+it("sleepSync with negative number throws", async () => {
+ expect(() => sleepSync(-10)).toThrow();
+});
+
+it("can map with sleepSync", async () => {
+ [1, 2, 3].map(sleepSync);
+});
diff --git a/test/bun.js/sqlite.test.js b/test/bun.js/sqlite.test.js
index 3120283f4..408fa5a26 100644
--- a/test/bun.js/sqlite.test.js
+++ b/test/bun.js/sqlite.test.js
@@ -504,3 +504,26 @@ it("latin1 supplement chars", () => {
},
]);
});
+
+describe("Database.run", () => {
+ it("should not throw error `not an error` when provided query containing only whitespace", () => {
+ const db = Database.open(":memory:");
+ db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)");
+
+ expect(db[Symbol.for("Bun.Database.cache.count")]).toBe(0);
+
+ var q = db.query("SELECT * FROM test WHERE name = ?");
+ expect(q.get("Hello") === null).toBe(true);
+
+ db.exec('INSERT INTO test (name) VALUES ("Hello")');
+ db.exec('INSERT INTO test (name) VALUES ("World")');
+
+ try {
+ db.run(" ");
+ expect(true).toBeFalsy();
+ } catch (e) {
+ expect(e.message).not.toBe("not an error");
+ expect(e.message).toBe("Query contained no valid SQL statement; likely empty query.");
+ }
+ });
+});
diff --git a/test/snippets/code-simplification-neql-define.js b/test/snippets/code-simplification-neql-define.js
index c7676dc9b..bd7ab9207 100644
--- a/test/snippets/code-simplification-neql-define.js
+++ b/test/snippets/code-simplification-neql-define.js
@@ -2,7 +2,7 @@ var testFailed = false;
const invariant = () => {
testFailed = true;
};
-var $$m = (arg) => {
+var $$m = arg => {
var module = { exports: {} },
exports = module.exports;
return arg(module, exports);
@@ -12,31 +12,19 @@ var size = 100,
export var $f332019d = $$m(
{
- "relay-runtime/lib/network/RelayQueryResponseCache.js": (
- module,
- exports,
- ) => {
+ "relay-runtime/lib/network/RelayQueryResponseCache.js": (module, exports) => {
var RelayQueryResponseCache = function () {
var foo = function RelayQueryResponseCache(_ref) {
var size = _ref.size,
ttl = _ref.ttl;
!(size > 0)
? process.env.NODE_ENV !== "production"
- ? invariant(
- false,
- "RelayQueryResponseCache: Expected the max cache size to be > 0, got " +
- "`%s`.",
- size,
- )
+ ? invariant(false, "RelayQueryResponseCache: Expected the max cache size to be > 0, got " + "`%s`.", size)
: invariant(false)
: void 0;
!(ttl > 0)
? process.env.NODE_ENV !== "production"
- ? invariant(
- false,
- "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.",
- ttl,
- )
+ ? invariant(false, "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.", ttl)
: invariant(false)
: void 0;
};
diff --git a/test/snippets/export.js b/test/snippets/export.js
index 2a757269f..bf334f025 100644
--- a/test/snippets/export.js
+++ b/test/snippets/export.js
@@ -21,9 +21,6 @@ export function test() {
if (where.default !== "hi") {
throw new Error(`_auth import is incorrect.`);
}
- console.assert(
- powerLevel.description === "9001",
- "Symbol is not exported correctly",
- );
+ console.assert(powerLevel.description === "9001", "Symbol is not exported correctly");
return testDone(import.meta.url);
}
diff --git a/test/snippets/jsx-entities.jsx b/test/snippets/jsx-entities.jsx
index ac5d32225..7123fd674 100644
--- a/test/snippets/jsx-entities.jsx
+++ b/test/snippets/jsx-entities.jsx
@@ -926,10 +926,7 @@ export function test() {
key = txt.value;
}
- console.assert(
- elements[rawKey] === key.codePointAt(0),
- `${key} is not ${elements[rawKey]}`,
- );
+ console.assert(elements[rawKey] === key.codePointAt(0), `${key} is not ${elements[rawKey]}`);
}
return testDone(import.meta.url);
diff --git a/test/snippets/latin1-chars-in-regexp.js b/test/snippets/latin1-chars-in-regexp.js
index 1a533b1e1..0ba85d100 100644
--- a/test/snippets/latin1-chars-in-regexp.js
+++ b/test/snippets/latin1-chars-in-regexp.js
@@ -10,40 +10,24 @@
export var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
export var re_btou = new RegExp(
- [
- "[\xC0-\xDF][\x80-\xBF]",
- "[\xE0-\xEF][\x80-\xBF]{2}",
- "[\xF0-\xF7][\x80-\xBF]{3}",
- ].join("|"),
+ ["[\xC0-\xDF][\x80-\xBF]", "[\xE0-\xEF][\x80-\xBF]{2}", "[\xF0-\xF7][\x80-\xBF]{3}"].join("|"),
"g",
);
const encoder = new TextEncoder();
-const realLines = [
- "[\xC0-\xDF][\x80-\xBF]",
- "[\xE0-\xEF][\x80-\xBF]{2}",
- "[\xF0-\xF7][\x80-\xBF]{3}",
-];
-const real = realLines.map((input) => Array.from(encoder.encode(input)));
+const realLines = ["[\xC0-\xDF][\x80-\xBF]", "[\xE0-\xEF][\x80-\xBF]{2}", "[\xF0-\xF7][\x80-\xBF]{3}"];
+const real = realLines.map(input => Array.from(encoder.encode(input)));
const expected = [
[91, 195, 128, 45, 195, 159, 93, 91, 194, 128, 45, 194, 191, 93],
- [
- 91, 195, 160, 45, 195, 175, 93, 91, 194, 128, 45, 194, 191, 93, 123, 50,
- 125,
- ],
- [
- 91, 195, 176, 45, 195, 183, 93, 91, 194, 128, 45, 194, 191, 93, 123, 51,
- 125,
- ],
+ [91, 195, 160, 45, 195, 175, 93, 91, 194, 128, 45, 194, 191, 93, 123, 50, 125],
+ [91, 195, 176, 45, 195, 183, 93, 91, 194, 128, 45, 194, 191, 93, 123, 51, 125],
];
const newlinePreserved = `\n`;
export function test() {
- if (
- !real.every((point, i) => point.every((val, j) => val === expected[i][j]))
- ) {
+ if (!real.every((point, i) => point.every((val, j) => val === expected[i][j]))) {
throw new Error(
`test failed
${JSON.stringify({ expected, real }, null, 2)}`,
@@ -55,11 +39,7 @@ ${JSON.stringify({ expected, real }, null, 2)}`,
}
const decoder = new TextDecoder("utf8");
- if (
- !realLines.every(
- (line, i) => decoder.decode(Uint8Array.from(expected[i])) === line,
- )
- ) {
+ if (!realLines.every((line, i) => decoder.decode(Uint8Array.from(expected[i])) === line)) {
throw new Error(
`test failed. Lines did not match.
${JSON.stringify({ expected, real }, null, 2)}`,
diff --git a/test/snippets/optional-chain-with-function.js b/test/snippets/optional-chain-with-function.js
index 82ad51d46..841c8a584 100644
--- a/test/snippets/optional-chain-with-function.js
+++ b/test/snippets/optional-chain-with-function.js
@@ -3,10 +3,10 @@ export function test() {
const multipleSecondaryValues = undefined;
const ratings = ["123"];
- var bar = multipleSecondaryValues?.map((value) => false);
- bar = bar?.multipleSecondaryValues?.map((value) => false);
- bar = bar?.bar?.multipleSecondaryValues?.map((value) => false);
- bar = {}?.bar?.multipleSecondaryValues?.map((value) => false);
+ var bar = multipleSecondaryValues?.map(value => false);
+ bar = bar?.multipleSecondaryValues?.map(value => false);
+ bar = bar?.bar?.multipleSecondaryValues?.map(value => false);
+ bar = {}?.bar?.multipleSecondaryValues?.map(value => false);
} catch (e) {
throw e;
}
diff --git a/test/snippets/package.json b/test/snippets/package.json
index 0c05b97be..478234d5c 100644
--- a/test/snippets/package.json
+++ b/test/snippets/package.json
@@ -10,5 +10,6 @@
"react-dom": "^17.0.2",
"redux": "^4.1.1",
"styled-components": "^5.3.1"
- }
+ },
+ "prettier": "../../.prettierrc.cjs"
}
diff --git a/test/snippets/react-context-value-func.tsx b/test/snippets/react-context-value-func.tsx
index e7ced1292..800ad428d 100644
--- a/test/snippets/react-context-value-func.tsx
+++ b/test/snippets/react-context-value-func.tsx
@@ -12,7 +12,7 @@ const ContextProvider = ({ children }) => {
const ContextValue = ({}) => (
<Context.Consumer>
- {(foo) => {
+ {foo => {
if (foo) {
return <div>Worked!</div>;
}
diff --git a/test/snippets/simple-lit-example.ts b/test/snippets/simple-lit-example.ts
index 3c53f03ab..1b10b61db 100644
--- a/test/snippets/simple-lit-example.ts
+++ b/test/snippets/simple-lit-example.ts
@@ -3,7 +3,7 @@ import { LitElement, html, css } from "lit";
import { customElement, property, eventOptions } from "lit/decorators.js";
var loadedResolve;
-var loadedPromise = new Promise((resolve) => {
+var loadedPromise = new Promise(resolve => {
loadedResolve = resolve;
});
@@ -35,11 +35,7 @@ export class MyElement extends LitElement {
@property() planet = "Earth";
render() {
- return html`
- <span @click=${this.togglePlanet} class="planet" id="planet-id"
- >${this.planet}</span
- >
- `;
+ return html` <span @click=${this.togglePlanet} class="planet" id="planet-id">${this.planet}</span> `;
}
@eventOptions({ once: true })
diff --git a/test/snippets/spread_with_key.tsx b/test/snippets/spread_with_key.tsx
index d9f842d27..2dc0c7072 100644
--- a/test/snippets/spread_with_key.tsx
+++ b/test/snippets/spread_with_key.tsx
@@ -4,12 +4,7 @@ import React from "react";
export function SpreadWithTheKey({ className }: Props) {
const rest = {};
return (
- <div
- className={className}
- key="spread-with-the-key"
- {...rest}
- onClick={() => console.log("click")}
- >
+ <div className={className} key="spread-with-the-key" {...rest} onClick={() => console.log("click")}>
Rendered component containing warning
</div>
);
diff --git a/test/snippets/string-escapes.js b/test/snippets/string-escapes.js
index 436140939..5fbc8da6c 100644
--- a/test/snippets/string-escapes.js
+++ b/test/snippets/string-escapes.js
@@ -30,31 +30,23 @@ const encoder = new TextEncoder();
const encodedObj = encoder.encode(JSON.stringify(obj));
// ------------------------------------------------------------
const correctEncodedObj = [
- 123, 34, 92, 114, 92, 110, 34, 58, 34, 92, 114, 92, 110, 34, 44, 34, 92, 110,
- 34, 58, 34, 92, 110, 34, 44, 34, 92, 116, 34, 58, 34, 92, 116, 34, 44, 34, 92,
- 102, 34, 58, 34, 92, 102, 34, 44, 34, 92, 117, 48, 48, 48, 98, 34, 58, 34, 92,
- 117, 48, 48, 48, 98, 34, 44, 34, 226, 128, 168, 34, 58, 34, 226, 128, 168, 34,
- 44, 34, 226, 128, 169, 34, 58, 34, 226, 128, 169, 34, 44, 34, 92, 117, 48, 48,
- 48, 48, 34, 58, 34, 92, 117, 48, 48, 48, 48, 194, 160, 110, 117, 108, 108, 32,
- 98, 121, 116, 101, 34, 44, 34, 240, 159, 152, 138, 34, 58, 34, 240, 159, 152,
- 138, 34, 44, 34, 240, 159, 152, 131, 34, 58, 34, 240, 159, 152, 131, 34, 44,
- 34, 240, 159, 149, 181, 240, 159, 143, 189, 226, 128, 141, 226, 153, 130, 239,
- 184, 143, 34, 58, 34, 240, 159, 149, 181, 240, 159, 143, 189, 226, 128, 141,
- 226, 153, 130, 239, 184, 143, 34, 44, 34, 227, 139, 161, 34, 58, 34, 227, 139,
- 161, 34, 44, 34, 226, 152, 186, 34, 58, 34, 226, 152, 186, 34, 44, 34, 227,
- 130, 183, 34, 58, 34, 227, 130, 183, 34, 44, 34, 240, 159, 145, 139, 34, 58,
- 34, 240, 159, 145, 139, 34, 44, 34, 102, 34, 58, 34, 226, 130, 135, 34, 44,
- 34, 226, 152, 185, 34, 58, 34, 226, 152, 185, 34, 44, 34, 226, 152, 187, 34,
- 58, 34, 226, 152, 187, 34, 44, 34, 99, 104, 105, 108, 100, 114, 101, 110, 34,
- 58, 49, 50, 51, 125,
+ 123, 34, 92, 114, 92, 110, 34, 58, 34, 92, 114, 92, 110, 34, 44, 34, 92, 110, 34, 58, 34, 92, 110, 34, 44, 34, 92,
+ 116, 34, 58, 34, 92, 116, 34, 44, 34, 92, 102, 34, 58, 34, 92, 102, 34, 44, 34, 92, 117, 48, 48, 48, 98, 34, 58, 34,
+ 92, 117, 48, 48, 48, 98, 34, 44, 34, 226, 128, 168, 34, 58, 34, 226, 128, 168, 34, 44, 34, 226, 128, 169, 34, 58, 34,
+ 226, 128, 169, 34, 44, 34, 92, 117, 48, 48, 48, 48, 34, 58, 34, 92, 117, 48, 48, 48, 48, 194, 160, 110, 117, 108, 108,
+ 32, 98, 121, 116, 101, 34, 44, 34, 240, 159, 152, 138, 34, 58, 34, 240, 159, 152, 138, 34, 44, 34, 240, 159, 152, 131,
+ 34, 58, 34, 240, 159, 152, 131, 34, 44, 34, 240, 159, 149, 181, 240, 159, 143, 189, 226, 128, 141, 226, 153, 130, 239,
+ 184, 143, 34, 58, 34, 240, 159, 149, 181, 240, 159, 143, 189, 226, 128, 141, 226, 153, 130, 239, 184, 143, 34, 44, 34,
+ 227, 139, 161, 34, 58, 34, 227, 139, 161, 34, 44, 34, 226, 152, 186, 34, 58, 34, 226, 152, 186, 34, 44, 34, 227, 130,
+ 183, 34, 58, 34, 227, 130, 183, 34, 44, 34, 240, 159, 145, 139, 34, 58, 34, 240, 159, 145, 139, 34, 44, 34, 102, 34,
+ 58, 34, 226, 130, 135, 34, 44, 34, 226, 152, 185, 34, 58, 34, 226, 152, 185, 34, 44, 34, 226, 152, 187, 34, 58, 34,
+ 226, 152, 187, 34, 44, 34, 99, 104, 105, 108, 100, 114, 101, 110, 34, 58, 49, 50, 51, 125,
];
export const jsxVariants = (
<>
- "\r\n": "\r\n", "\n": "\n", "\t": "\t", "\f": "\f", "\v": "\v", "\u2028":
- "\u2028", "\u2029": "\u2029", "😊": "😊", "😃": "😃", "🕵🏽‍♂️": "🕵🏽‍♂️", "㋡":
- "㋡", "☺": "☺", シ: "シ", "👋": "👋", f: f, "☹": "☹", "☻": "☻", children:
- 123,
+ "\r\n": "\r\n", "\n": "\n", "\t": "\t", "\f": "\f", "\v": "\v", "\u2028": "\u2028", "\u2029": "\u2029", "😊": "😊",
+ "😃": "😃", "🕵🏽‍♂️": "🕵🏽‍♂️", "㋡": "㋡", "☺": "☺", シ: "シ", "👋": "👋", f: f, "☹": "☹", "☻": "☻", children: 123,
<div data="\r\n" />
<div data="\n" />
<div data="\t" />
diff --git a/test/snippets/styledcomponents-output.js b/test/snippets/styledcomponents-output.js
index fca6e8407..91c871770 100644
--- a/test/snippets/styledcomponents-output.js
+++ b/test/snippets/styledcomponents-output.js
@@ -3,8 +3,7 @@ import React from "react";
import ReactDOM from "react-dom";
const ErrorScreenRoot = styled.div`
- font-family: "Muli", -apple-system, BlinkMacSystemFont, Helvetica, Arial,
- sans-serif;
+ font-family: "Muli", -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
position: fixed;
top: 0;
left: 0;
@@ -18,8 +17,7 @@ const ErrorScreenRoot = styled.div`
text-align: center;
background-color: #0b2988;
color: #fff;
- font-family: "Muli", -apple-system, BlinkMacSystemFont, Helvetica, Arial,
- sans-serif;
+ font-family: "Muli", -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
line-height: 1.5em;
& > p {
@@ -35,23 +33,15 @@ export function test() {
if (typeof window !== "undefined") {
const reactEl = document.createElement("div");
document.body.appendChild(reactEl);
- ReactDOM.render(
- <ErrorScreenRoot id="error-el">
- The react child should have this text
- </ErrorScreenRoot>,
- reactEl,
- );
+ ReactDOM.render(<ErrorScreenRoot id="error-el">The react child should have this text</ErrorScreenRoot>, reactEl);
const style = document.querySelector("style[data-styled]");
console.assert(style, "style tag should exist");
console.assert(
- style.textContent.split("").every((a) => a.codePointAt(0) < 128),
+ style.textContent.split("").every(a => a.codePointAt(0) < 128),
"style tag should not contain invalid unicode codepoints",
);
- console.assert(
- document.querySelector("#error-el").textContent ===
- "The react child should have this text",
- );
+ console.assert(document.querySelector("#error-el").textContent === "The react child should have this text");
ReactDOM.unmountComponentAtNode(reactEl);
reactEl.remove();
diff --git a/test/snippets/template-literal.js b/test/snippets/template-literal.js
index a5749a555..8d8f64917 100644
--- a/test/snippets/template-literal.js
+++ b/test/snippets/template-literal.js
@@ -1,4 +1,4 @@
-const css = (templ) => templ.toString();
+const css = templ => templ.toString();
const fooNoBracesUTF8 = css`
before
@@ -25,8 +25,7 @@ const fooUTF16 = css`
`;
-const templateLiteralWhichDefinesAFunction = ((...args) =>
- args[args.length - 1]().toString())`
+const templateLiteralWhichDefinesAFunction = ((...args) => args[args.length - 1]().toString())`
before
🙃 ${() => true}
after
@@ -35,17 +34,11 @@ const templateLiteralWhichDefinesAFunction = ((...args) =>
export function test() {
for (let foo of [fooNoBracesUT16, fooNoBracesUTF8, fooUTF16, fooUTF8]) {
- console.assert(
- foo.includes("before"),
- `Expected ${foo} to include "before"`,
- );
+ console.assert(foo.includes("before"), `Expected ${foo} to include "before"`);
console.assert(foo.includes("after"), `Expected ${foo} to include "after"`);
}
- console.assert(
- templateLiteralWhichDefinesAFunction.includes("true"),
- "Expected fooFunction to include 'true'",
- );
+ console.assert(templateLiteralWhichDefinesAFunction.includes("true"), "Expected fooFunction to include 'true'");
return testDone(import.meta.url);
}
diff --git a/test/snippets/type-only-imports.ts b/test/snippets/type-only-imports.ts
index c43fcf278..38d02c743 100644
--- a/test/snippets/type-only-imports.ts
+++ b/test/snippets/type-only-imports.ts
@@ -3,8 +3,7 @@ import type Bacon from "tree";
import type { SilentSymbolCollisionsAreOkayInTypeScript } from "./app";
export const baconator: Bacon = true;
-export const SilentSymbolCollisionsAreOkayInTypeScript: SilentSymbolCollisionsAreOkayInTypeScript =
- true;
+export const SilentSymbolCollisionsAreOkayInTypeScript: SilentSymbolCollisionsAreOkayInTypeScript = true;
export function test() {
console.assert(SilentSymbolCollisionsAreOkayInTypeScript);
diff --git a/tsconfig.json b/tsconfig.json
index 2777ef03f..518dca2c1 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -18,8 +18,11 @@
"examples/macros",
"test/bun.js/solid-dom-fixtures",
"test/bun.js/bundled",
+ "src/deps",
+ "bun-webkit",
// JavaScriptCore builtins use a non-standard "@" symbol to indicate a private identifier which no other tool supports
"src/bun.js/builtins",
+ "src/bun.js/WebKit",
"src/api/demo",
"test/snapshots",
"test/snapshots-no-hmr",