@depup/bun-types 1.3.11-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +105 -0
- package/README.md +25 -0
- package/bun.d.ts +8712 -0
- package/bun.ns.d.ts +5 -0
- package/bundle.d.ts +74 -0
- package/changes.json +5 -0
- package/deprecated.d.ts +184 -0
- package/devserver.d.ts +187 -0
- package/docs/README.md +28 -0
- package/docs/bundler/bytecode.mdx +447 -0
- package/docs/bundler/css.mdx +1024 -0
- package/docs/bundler/esbuild.mdx +304 -0
- package/docs/bundler/executables.mdx +1318 -0
- package/docs/bundler/fullstack.mdx +1086 -0
- package/docs/bundler/hot-reloading.mdx +229 -0
- package/docs/bundler/html-static.mdx +498 -0
- package/docs/bundler/index.mdx +1840 -0
- package/docs/bundler/loaders.mdx +451 -0
- package/docs/bundler/macros.mdx +328 -0
- package/docs/bundler/minifier.mdx +1286 -0
- package/docs/bundler/plugins.mdx +477 -0
- package/docs/bundler/standalone-html.mdx +314 -0
- package/docs/feedback.mdx +75 -0
- package/docs/guides/binary/arraybuffer-to-array.mdx +29 -0
- package/docs/guides/binary/arraybuffer-to-blob.mdx +26 -0
- package/docs/guides/binary/arraybuffer-to-buffer.mdx +27 -0
- package/docs/guides/binary/arraybuffer-to-string.mdx +17 -0
- package/docs/guides/binary/arraybuffer-to-typedarray.mdx +41 -0
- package/docs/guides/binary/blob-to-arraybuffer.mdx +16 -0
- package/docs/guides/binary/blob-to-dataview.mdx +16 -0
- package/docs/guides/binary/blob-to-stream.mdx +16 -0
- package/docs/guides/binary/blob-to-string.mdx +17 -0
- package/docs/guides/binary/blob-to-typedarray.mdx +16 -0
- package/docs/guides/binary/buffer-to-arraybuffer.mdx +16 -0
- package/docs/guides/binary/buffer-to-blob.mdx +16 -0
- package/docs/guides/binary/buffer-to-readablestream.mdx +43 -0
- package/docs/guides/binary/buffer-to-string.mdx +27 -0
- package/docs/guides/binary/buffer-to-typedarray.mdx +16 -0
- package/docs/guides/binary/dataview-to-string.mdx +17 -0
- package/docs/guides/binary/typedarray-to-arraybuffer.mdx +27 -0
- package/docs/guides/binary/typedarray-to-blob.mdx +18 -0
- package/docs/guides/binary/typedarray-to-buffer.mdx +16 -0
- package/docs/guides/binary/typedarray-to-dataview.mdx +16 -0
- package/docs/guides/binary/typedarray-to-readablestream.mdx +43 -0
- package/docs/guides/binary/typedarray-to-string.mdx +18 -0
- package/docs/guides/deployment/aws-lambda.mdx +204 -0
- package/docs/guides/deployment/digital-ocean.mdx +161 -0
- package/docs/guides/deployment/google-cloud-run.mdx +194 -0
- package/docs/guides/deployment/railway.mdx +145 -0
- package/docs/guides/deployment/render.mdx +82 -0
- package/docs/guides/deployment/vercel.mdx +97 -0
- package/docs/guides/ecosystem/astro.mdx +82 -0
- package/docs/guides/ecosystem/discordjs.mdx +80 -0
- package/docs/guides/ecosystem/docker.mdx +151 -0
- package/docs/guides/ecosystem/drizzle.mdx +195 -0
- package/docs/guides/ecosystem/elysia.mdx +31 -0
- package/docs/guides/ecosystem/express.mdx +43 -0
- package/docs/guides/ecosystem/gel.mdx +261 -0
- package/docs/guides/ecosystem/hono.mdx +47 -0
- package/docs/guides/ecosystem/mongoose.mdx +92 -0
- package/docs/guides/ecosystem/neon-drizzle.mdx +234 -0
- package/docs/guides/ecosystem/neon-serverless-postgres.mdx +60 -0
- package/docs/guides/ecosystem/nextjs.mdx +103 -0
- package/docs/guides/ecosystem/nuxt.mdx +96 -0
- package/docs/guides/ecosystem/pm2.mdx +55 -0
- package/docs/guides/ecosystem/prisma-postgres.mdx +169 -0
- package/docs/guides/ecosystem/prisma.mdx +164 -0
- package/docs/guides/ecosystem/qwik.mdx +114 -0
- package/docs/guides/ecosystem/react.mdx +52 -0
- package/docs/guides/ecosystem/remix.mdx +97 -0
- package/docs/guides/ecosystem/sentry.mdx +54 -0
- package/docs/guides/ecosystem/solidstart.mdx +62 -0
- package/docs/guides/ecosystem/ssr-react.mdx +49 -0
- package/docs/guides/ecosystem/stric.mdx +54 -0
- package/docs/guides/ecosystem/sveltekit.mdx +138 -0
- package/docs/guides/ecosystem/systemd.mdx +114 -0
- package/docs/guides/ecosystem/tanstack-start.mdx +791 -0
- package/docs/guides/ecosystem/upstash.mdx +87 -0
- package/docs/guides/ecosystem/vite.mdx +77 -0
- package/docs/guides/html-rewriter/extract-links.mdx +71 -0
- package/docs/guides/html-rewriter/extract-social-meta.mdx +97 -0
- package/docs/guides/http/cluster.mdx +69 -0
- package/docs/guides/http/fetch-unix.mdx +35 -0
- package/docs/guides/http/fetch.mdx +26 -0
- package/docs/guides/http/file-uploads.mdx +97 -0
- package/docs/guides/http/hot.mdx +28 -0
- package/docs/guides/http/proxy.mdx +50 -0
- package/docs/guides/http/server.mdx +48 -0
- package/docs/guides/http/simple.mdx +20 -0
- package/docs/guides/http/sse.mdx +91 -0
- package/docs/guides/http/stream-file.mdx +50 -0
- package/docs/guides/http/stream-iterator.mdx +49 -0
- package/docs/guides/http/stream-node-streams-in-bun.mdx +22 -0
- package/docs/guides/http/tls.mdx +32 -0
- package/docs/guides/index.mdx +10 -0
- package/docs/guides/install/add-dev.mdx +28 -0
- package/docs/guides/install/add-git.mdx +40 -0
- package/docs/guides/install/add-optional.mdx +27 -0
- package/docs/guides/install/add-peer.mdx +45 -0
- package/docs/guides/install/add-tarball.mdx +35 -0
- package/docs/guides/install/add.mdx +44 -0
- package/docs/guides/install/azure-artifacts.mdx +76 -0
- package/docs/guides/install/cicd.mdx +43 -0
- package/docs/guides/install/custom-registry.mdx +32 -0
- package/docs/guides/install/from-npm-install-to-bun-install.mdx +230 -0
- package/docs/guides/install/git-diff-bun-lockfile.mdx +48 -0
- package/docs/guides/install/jfrog-artifactory.mdx +28 -0
- package/docs/guides/install/npm-alias.mdx +25 -0
- package/docs/guides/install/registry-scope.mdx +40 -0
- package/docs/guides/install/trusted.mdx +52 -0
- package/docs/guides/install/workspaces.mdx +70 -0
- package/docs/guides/install/yarnlock.mdx +51 -0
- package/docs/guides/process/argv.mdx +66 -0
- package/docs/guides/process/ctrl-c.mdx +18 -0
- package/docs/guides/process/ipc.mdx +69 -0
- package/docs/guides/process/nanoseconds.mdx +15 -0
- package/docs/guides/process/os-signals.mdx +31 -0
- package/docs/guides/process/spawn-stderr.mdx +34 -0
- package/docs/guides/process/spawn-stdout.mdx +28 -0
- package/docs/guides/process/spawn.mdx +43 -0
- package/docs/guides/process/stdin.mdx +62 -0
- package/docs/guides/read-file/arraybuffer.mdx +30 -0
- package/docs/guides/read-file/buffer.mdx +21 -0
- package/docs/guides/read-file/exists.mdx +18 -0
- package/docs/guides/read-file/json.mdx +19 -0
- package/docs/guides/read-file/mime.mdx +22 -0
- package/docs/guides/read-file/stream.mdx +28 -0
- package/docs/guides/read-file/string.mdx +24 -0
- package/docs/guides/read-file/uint8array.mdx +23 -0
- package/docs/guides/read-file/watch.mdx +66 -0
- package/docs/guides/runtime/build-time-constants.mdx +295 -0
- package/docs/guides/runtime/cicd.mdx +45 -0
- package/docs/guides/runtime/codesign-macos-executable.mdx +61 -0
- package/docs/guides/runtime/define-constant.mdx +149 -0
- package/docs/guides/runtime/delete-directory.mdx +39 -0
- package/docs/guides/runtime/delete-file.mdx +21 -0
- package/docs/guides/runtime/heap-snapshot.mdx +28 -0
- package/docs/guides/runtime/import-html.mdx +15 -0
- package/docs/guides/runtime/import-json.mdx +46 -0
- package/docs/guides/runtime/import-json5.mdx +74 -0
- package/docs/guides/runtime/import-toml.mdx +32 -0
- package/docs/guides/runtime/import-yaml.mdx +104 -0
- package/docs/guides/runtime/read-env.mdx +37 -0
- package/docs/guides/runtime/set-env.mdx +51 -0
- package/docs/guides/runtime/shell.mdx +42 -0
- package/docs/guides/runtime/timezone.mdx +38 -0
- package/docs/guides/runtime/tsconfig-paths.mdx +31 -0
- package/docs/guides/runtime/typescript.mdx +51 -0
- package/docs/guides/runtime/vscode-debugger.mdx +47 -0
- package/docs/guides/runtime/web-debugger.mdx +103 -0
- package/docs/guides/streams/node-readable-to-arraybuffer.mdx +13 -0
- package/docs/guides/streams/node-readable-to-blob.mdx +13 -0
- package/docs/guides/streams/node-readable-to-json.mdx +14 -0
- package/docs/guides/streams/node-readable-to-string.mdx +14 -0
- package/docs/guides/streams/node-readable-to-uint8array.mdx +13 -0
- package/docs/guides/streams/to-array.mdx +16 -0
- package/docs/guides/streams/to-arraybuffer.mdx +16 -0
- package/docs/guides/streams/to-blob.mdx +16 -0
- package/docs/guides/streams/to-buffer.mdx +17 -0
- package/docs/guides/streams/to-json.mdx +16 -0
- package/docs/guides/streams/to-string.mdx +16 -0
- package/docs/guides/streams/to-typedarray.mdx +24 -0
- package/docs/guides/test/bail.mdx +24 -0
- package/docs/guides/test/concurrent-test-glob.mdx +146 -0
- package/docs/guides/test/coverage-threshold.mdx +67 -0
- package/docs/guides/test/coverage.mdx +49 -0
- package/docs/guides/test/happy-dom.mdx +73 -0
- package/docs/guides/test/migrate-from-jest.mdx +125 -0
- package/docs/guides/test/mock-clock.mdx +50 -0
- package/docs/guides/test/mock-functions.mdx +70 -0
- package/docs/guides/test/rerun-each.mdx +16 -0
- package/docs/guides/test/run-tests.mdx +116 -0
- package/docs/guides/test/skip-tests.mdx +43 -0
- package/docs/guides/test/snapshot.mdx +102 -0
- package/docs/guides/test/spy-on.mdx +49 -0
- package/docs/guides/test/svelte-test.mdx +113 -0
- package/docs/guides/test/testing-library.mdx +93 -0
- package/docs/guides/test/timeout.mdx +17 -0
- package/docs/guides/test/todo-tests.mdx +74 -0
- package/docs/guides/test/update-snapshots.mdx +49 -0
- package/docs/guides/test/watch-mode.mdx +24 -0
- package/docs/guides/util/base64.mdx +17 -0
- package/docs/guides/util/deep-equals.mdx +41 -0
- package/docs/guides/util/deflate.mdx +20 -0
- package/docs/guides/util/detect-bun.mdx +28 -0
- package/docs/guides/util/entrypoint.mdx +19 -0
- package/docs/guides/util/escape-html.mdx +24 -0
- package/docs/guides/util/file-url-to-path.mdx +16 -0
- package/docs/guides/util/gzip.mdx +20 -0
- package/docs/guides/util/hash-a-password.mdx +56 -0
- package/docs/guides/util/import-meta-dir.mdx +15 -0
- package/docs/guides/util/import-meta-file.mdx +15 -0
- package/docs/guides/util/import-meta-path.mdx +15 -0
- package/docs/guides/util/javascript-uuid.mdx +25 -0
- package/docs/guides/util/main.mdx +43 -0
- package/docs/guides/util/path-to-file-url.mdx +16 -0
- package/docs/guides/util/sleep.mdx +24 -0
- package/docs/guides/util/upgrade.mdx +93 -0
- package/docs/guides/util/version.mdx +23 -0
- package/docs/guides/util/which-path-to-executable-bin.mdx +17 -0
- package/docs/guides/websocket/compression.mdx +33 -0
- package/docs/guides/websocket/context.mdx +79 -0
- package/docs/guides/websocket/pubsub.mdx +43 -0
- package/docs/guides/websocket/simple.mdx +38 -0
- package/docs/guides/write-file/append.mdx +54 -0
- package/docs/guides/write-file/basic.mdx +46 -0
- package/docs/guides/write-file/blob.mdx +30 -0
- package/docs/guides/write-file/cat.mdx +19 -0
- package/docs/guides/write-file/file-cp.mdx +18 -0
- package/docs/guides/write-file/filesink.mdx +54 -0
- package/docs/guides/write-file/response.mdx +19 -0
- package/docs/guides/write-file/stdout.mdx +23 -0
- package/docs/guides/write-file/stream.mdx +19 -0
- package/docs/guides/write-file/unlink.mdx +18 -0
- package/docs/index.mdx +133 -0
- package/docs/installation.mdx +372 -0
- package/docs/pm/bunx.mdx +91 -0
- package/docs/pm/catalogs.mdx +292 -0
- package/docs/pm/cli/add.mdx +179 -0
- package/docs/pm/cli/audit.mdx +60 -0
- package/docs/pm/cli/info.mdx +70 -0
- package/docs/pm/cli/install.mdx +591 -0
- package/docs/pm/cli/link.mdx +61 -0
- package/docs/pm/cli/outdated.mdx +197 -0
- package/docs/pm/cli/patch.mdx +69 -0
- package/docs/pm/cli/pm.mdx +323 -0
- package/docs/pm/cli/publish.mdx +131 -0
- package/docs/pm/cli/remove.mdx +16 -0
- package/docs/pm/cli/update.mdx +140 -0
- package/docs/pm/cli/why.mdx +84 -0
- package/docs/pm/filter.mdx +127 -0
- package/docs/pm/global-cache.mdx +72 -0
- package/docs/pm/isolated-installs.mdx +220 -0
- package/docs/pm/lifecycle.mdx +64 -0
- package/docs/pm/lockfile.mdx +64 -0
- package/docs/pm/npmrc.mdx +245 -0
- package/docs/pm/overrides.mdx +83 -0
- package/docs/pm/scopes-registries.mdx +35 -0
- package/docs/pm/security-scanner-api.mdx +95 -0
- package/docs/pm/workspaces.mdx +115 -0
- package/docs/project/benchmarking.mdx +296 -0
- package/docs/project/bindgen.mdx +223 -0
- package/docs/project/building-windows.mdx +143 -0
- package/docs/project/contributing.mdx +366 -0
- package/docs/project/feedback.mdx +20 -0
- package/docs/project/license.mdx +78 -0
- package/docs/project/roadmap.mdx +8 -0
- package/docs/quickstart.mdx +251 -0
- package/docs/runtime/archive.mdx +452 -0
- package/docs/runtime/auto-install.mdx +97 -0
- package/docs/runtime/binary-data.mdx +846 -0
- package/docs/runtime/bun-apis.mdx +60 -0
- package/docs/runtime/bunfig.mdx +765 -0
- package/docs/runtime/c-compiler.mdx +204 -0
- package/docs/runtime/child-process.mdx +659 -0
- package/docs/runtime/color.mdx +267 -0
- package/docs/runtime/console.mdx +67 -0
- package/docs/runtime/cookies.mdx +454 -0
- package/docs/runtime/cron.mdx +358 -0
- package/docs/runtime/csrf.mdx +171 -0
- package/docs/runtime/debugger.mdx +335 -0
- package/docs/runtime/environment-variables.mdx +231 -0
- package/docs/runtime/ffi.mdx +567 -0
- package/docs/runtime/file-io.mdx +306 -0
- package/docs/runtime/file-system-router.mdx +118 -0
- package/docs/runtime/file-types.mdx +482 -0
- package/docs/runtime/glob.mdx +181 -0
- package/docs/runtime/globals.mdx +72 -0
- package/docs/runtime/hashing.mdx +315 -0
- package/docs/runtime/html-rewriter.mdx +333 -0
- package/docs/runtime/http/cookies.mdx +79 -0
- package/docs/runtime/http/error-handling.mdx +40 -0
- package/docs/runtime/http/metrics.mdx +36 -0
- package/docs/runtime/http/routing.mdx +289 -0
- package/docs/runtime/http/server.mdx +672 -0
- package/docs/runtime/http/tls.mdx +101 -0
- package/docs/runtime/http/websockets.mdx +414 -0
- package/docs/runtime/index.mdx +223 -0
- package/docs/runtime/json5.mdx +271 -0
- package/docs/runtime/jsonl.mdx +188 -0
- package/docs/runtime/jsx.mdx +115 -0
- package/docs/runtime/markdown.mdx +381 -0
- package/docs/runtime/module-resolution.mdx +374 -0
- package/docs/runtime/networking/dns.mdx +111 -0
- package/docs/runtime/networking/fetch.mdx +484 -0
- package/docs/runtime/networking/tcp.mdx +239 -0
- package/docs/runtime/networking/udp.mdx +180 -0
- package/docs/runtime/node-api.mdx +19 -0
- package/docs/runtime/nodejs-compat.mdx +468 -0
- package/docs/runtime/plugins.mdx +419 -0
- package/docs/runtime/redis.mdx +583 -0
- package/docs/runtime/repl.mdx +176 -0
- package/docs/runtime/s3.mdx +881 -0
- package/docs/runtime/secrets.mdx +340 -0
- package/docs/runtime/semver.mdx +57 -0
- package/docs/runtime/shell.mdx +637 -0
- package/docs/runtime/sql.mdx +1404 -0
- package/docs/runtime/sqlite.mdx +721 -0
- package/docs/runtime/streams.mdx +232 -0
- package/docs/runtime/templating/create.mdx +269 -0
- package/docs/runtime/templating/init.mdx +58 -0
- package/docs/runtime/toml.mdx +238 -0
- package/docs/runtime/transpiler.mdx +288 -0
- package/docs/runtime/typescript.mdx +58 -0
- package/docs/runtime/utils.mdx +1010 -0
- package/docs/runtime/watch-mode.mdx +161 -0
- package/docs/runtime/web-apis.mdx +29 -0
- package/docs/runtime/workers.mdx +314 -0
- package/docs/runtime/yaml.mdx +470 -0
- package/docs/snippets/cli/add.mdx +166 -0
- package/docs/snippets/cli/build.mdx +197 -0
- package/docs/snippets/cli/bunx.mdx +49 -0
- package/docs/snippets/cli/feedback.mdx +17 -0
- package/docs/snippets/cli/init.mdx +84 -0
- package/docs/snippets/cli/install.mdx +173 -0
- package/docs/snippets/cli/link.mdx +163 -0
- package/docs/snippets/cli/outdated.mdx +140 -0
- package/docs/snippets/cli/patch.mdx +171 -0
- package/docs/snippets/cli/publish.mdx +198 -0
- package/docs/snippets/cli/remove.mdx +146 -0
- package/docs/snippets/cli/run.mdx +305 -0
- package/docs/snippets/cli/test.mdx +105 -0
- package/docs/snippets/cli/update.mdx +144 -0
- package/docs/test/code-coverage.mdx +409 -0
- package/docs/test/configuration.mdx +574 -0
- package/docs/test/dates-times.mdx +129 -0
- package/docs/test/discovery.mdx +90 -0
- package/docs/test/dom.mdx +226 -0
- package/docs/test/index.mdx +409 -0
- package/docs/test/lifecycle.mdx +366 -0
- package/docs/test/mocks.mdx +637 -0
- package/docs/test/reporters.mdx +126 -0
- package/docs/test/runtime-behavior.mdx +342 -0
- package/docs/test/snapshots.mdx +434 -0
- package/docs/test/writing-tests.mdx +672 -0
- package/docs/typescript.mdx +54 -0
- package/extensions.d.ts +40 -0
- package/fetch.d.ts +79 -0
- package/ffi.d.ts +1154 -0
- package/globals.d.ts +2067 -0
- package/html-rewriter.d.ts +186 -0
- package/index.d.ts +32 -0
- package/jsc.d.ts +233 -0
- package/jsx.d.ts +11 -0
- package/overrides.d.ts +376 -0
- package/package.json +53 -0
- package/redis.d.ts +3352 -0
- package/s3.d.ts +1354 -0
- package/security.d.ts +101 -0
- package/serve.d.ts +1296 -0
- package/shell.d.ts +380 -0
- package/sql.d.ts +887 -0
- package/sqlite.d.ts +1322 -0
- package/test-globals.d.ts +22 -0
- package/test.d.ts +2392 -0
- package/vendor/expect-type/branding.d.ts +283 -0
- package/vendor/expect-type/index.d.ts +1207 -0
- package/vendor/expect-type/messages.d.ts +395 -0
- package/vendor/expect-type/overloads.d.ts +669 -0
- package/vendor/expect-type/utils.d.ts +431 -0
- package/wasm.d.ts +193 -0
package/bun.ns.d.ts
ADDED
package/bundle.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `bun:bundle` module provides compile-time utilities for dead-code elimination.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { feature } from "bun:bundle";
|
|
7
|
+
*
|
|
8
|
+
* if (feature("SUPER_SECRET")) {
|
|
9
|
+
* console.log("Secret feature enabled!");
|
|
10
|
+
* } else {
|
|
11
|
+
* console.log("Normal mode");
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Enable feature flags via CLI:
|
|
16
|
+
* ```bash
|
|
17
|
+
* # During build
|
|
18
|
+
* bun build --feature=SUPER_SECRET index.ts
|
|
19
|
+
*
|
|
20
|
+
* # At runtime
|
|
21
|
+
* bun run --feature=SUPER_SECRET index.ts
|
|
22
|
+
*
|
|
23
|
+
* # In tests
|
|
24
|
+
* bun test --feature=SUPER_SECRET
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @module bun:bundle
|
|
28
|
+
*/
|
|
29
|
+
declare module "bun:bundle" {
|
|
30
|
+
/**
|
|
31
|
+
* Registry for type-safe feature flags.
|
|
32
|
+
*
|
|
33
|
+
* Augment this interface to get autocomplete and type checking for your feature flags:
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* // env.d.ts
|
|
38
|
+
* declare module "bun:bundle" {
|
|
39
|
+
* interface Registry {
|
|
40
|
+
* features: "DEBUG" | "PREMIUM" | "BETA";
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Now `feature()` only accepts `"DEBUG"`, `"PREMIUM"`, or `"BETA"`:
|
|
46
|
+
* ```ts
|
|
47
|
+
* feature("DEBUG"); // OK
|
|
48
|
+
* feature("TYPO"); // Type error
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
interface Registry {}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Check if a feature flag is enabled at compile time.
|
|
55
|
+
*
|
|
56
|
+
* This function is replaced with a boolean literal (`true` or `false`) at bundle time,
|
|
57
|
+
* enabling dead-code elimination. The bundler will remove unreachable branches.
|
|
58
|
+
*
|
|
59
|
+
* @param flag - The name of the feature flag to check
|
|
60
|
+
* @returns `true` if the flag was passed via `--feature=FLAG`, `false` otherwise
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { feature } from "bun:bundle";
|
|
65
|
+
*
|
|
66
|
+
* // With --feature=DEBUG, this becomes: if (true) { ... }
|
|
67
|
+
* // Without --feature=DEBUG, this becomes: if (false) { ... }
|
|
68
|
+
* if (feature("DEBUG")) {
|
|
69
|
+
* console.log("Debug mode enabled");
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
function feature(flag: Registry extends { features: infer Features extends string } ? Features : string): boolean;
|
|
74
|
+
}
|
package/changes.json
ADDED
package/deprecated.d.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
declare module "bun" {
|
|
2
|
+
/** @deprecated This type is unused in Bun's types and might be removed in the near future */
|
|
3
|
+
type Platform =
|
|
4
|
+
| "aix"
|
|
5
|
+
| "android"
|
|
6
|
+
| "darwin"
|
|
7
|
+
| "freebsd"
|
|
8
|
+
| "haiku"
|
|
9
|
+
| "linux"
|
|
10
|
+
| "openbsd"
|
|
11
|
+
| "sunos"
|
|
12
|
+
| "win32"
|
|
13
|
+
| "cygwin"
|
|
14
|
+
| "netbsd";
|
|
15
|
+
|
|
16
|
+
/** @deprecated This type is unused in Bun's types and might be removed in the near future */
|
|
17
|
+
type Architecture = "arm" | "arm64" | "ia32" | "mips" | "mipsel" | "ppc" | "ppc64" | "s390" | "s390x" | "x64";
|
|
18
|
+
|
|
19
|
+
/** @deprecated This type is unused in Bun's types and might be removed in the near future */
|
|
20
|
+
type UncaughtExceptionListener = (error: Error, origin: UncaughtExceptionOrigin) => void;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Most of the time the unhandledRejection will be an Error, but this should not be relied upon
|
|
24
|
+
* as *anything* can be thrown/rejected, it is therefore unsafe to assume that the value is an Error.
|
|
25
|
+
*
|
|
26
|
+
* @deprecated This type is unused in Bun's types and might be removed in the near future
|
|
27
|
+
*/
|
|
28
|
+
type UnhandledRejectionListener = (reason: unknown, promise: Promise<unknown>) => void;
|
|
29
|
+
|
|
30
|
+
/** @deprecated This type is unused in Bun's types and might be removed in the near future */
|
|
31
|
+
type MultipleResolveListener = (type: MultipleResolveType, promise: Promise<unknown>, value: unknown) => void;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Consume all data from a {@link ReadableStream} until it closes or errors.
|
|
35
|
+
*
|
|
36
|
+
* Concatenate the chunks into a single {@link ArrayBuffer}.
|
|
37
|
+
*
|
|
38
|
+
* Each chunk must be a TypedArray or an ArrayBuffer. If you need to support
|
|
39
|
+
* chunks of different types, consider {@link readableStreamToBlob}
|
|
40
|
+
*
|
|
41
|
+
* @param stream The stream to consume.
|
|
42
|
+
* @returns A promise that resolves with the concatenated chunks or the concatenated chunks as a {@link Uint8Array}.
|
|
43
|
+
*
|
|
44
|
+
* @deprecated Use {@link ReadableStream.bytes}
|
|
45
|
+
*/
|
|
46
|
+
function readableStreamToBytes(
|
|
47
|
+
stream: ReadableStream<ArrayBufferView | ArrayBufferLike>,
|
|
48
|
+
): Promise<Uint8Array<ArrayBuffer>> | Uint8Array<ArrayBuffer>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Consume all data from a {@link ReadableStream} until it closes or errors.
|
|
52
|
+
*
|
|
53
|
+
* Concatenate the chunks into a single {@link Blob}.
|
|
54
|
+
*
|
|
55
|
+
* @param stream The stream to consume.
|
|
56
|
+
* @returns A promise that resolves with the concatenated chunks as a {@link Blob}.
|
|
57
|
+
*
|
|
58
|
+
* @deprecated Use {@link ReadableStream.blob}
|
|
59
|
+
*/
|
|
60
|
+
function readableStreamToBlob(stream: ReadableStream): Promise<Blob>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Consume all data from a {@link ReadableStream} until it closes or errors.
|
|
64
|
+
*
|
|
65
|
+
* Concatenate the chunks into a single string. Chunks must be a TypedArray or an ArrayBuffer. If you need to support chunks of different types, consider {@link readableStreamToBlob}.
|
|
66
|
+
*
|
|
67
|
+
* @param stream The stream to consume.
|
|
68
|
+
* @returns A promise that resolves with the concatenated chunks as a {@link String}.
|
|
69
|
+
*
|
|
70
|
+
* @deprecated Use {@link ReadableStream.text}
|
|
71
|
+
*/
|
|
72
|
+
function readableStreamToText(stream: ReadableStream): Promise<string>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Consume all data from a {@link ReadableStream} until it closes or errors.
|
|
76
|
+
*
|
|
77
|
+
* Concatenate the chunks into a single string and parse as JSON. Chunks must be a TypedArray or an ArrayBuffer. If you need to support chunks of different types, consider {@link readableStreamToBlob}.
|
|
78
|
+
*
|
|
79
|
+
* @param stream The stream to consume.
|
|
80
|
+
* @returns A promise that resolves with the concatenated chunks as a {@link String}.
|
|
81
|
+
*
|
|
82
|
+
* @deprecated Use {@link ReadableStream.json}
|
|
83
|
+
*/
|
|
84
|
+
function readableStreamToJSON(stream: ReadableStream): Promise<any>;
|
|
85
|
+
|
|
86
|
+
interface BunMessageEvent<T> {
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated
|
|
89
|
+
*/
|
|
90
|
+
initMessageEvent(
|
|
91
|
+
type: string,
|
|
92
|
+
bubbles?: boolean,
|
|
93
|
+
cancelable?: boolean,
|
|
94
|
+
data?: any,
|
|
95
|
+
origin?: string,
|
|
96
|
+
lastEventId?: string,
|
|
97
|
+
source?: null,
|
|
98
|
+
): void;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated Use {@link Serve.Options Bun.Serve.Options<T, R>} instead
|
|
103
|
+
*/
|
|
104
|
+
type ServeOptions<T = undefined, R extends string = never> = Serve.Options<T, R>;
|
|
105
|
+
|
|
106
|
+
/** @deprecated Use {@link SQL.Query Bun.SQL.Query} */
|
|
107
|
+
type SQLQuery<T = any> = SQL.Query<T>;
|
|
108
|
+
|
|
109
|
+
/** @deprecated Use {@link SQL.TransactionContextCallback Bun.SQL.TransactionContextCallback} */
|
|
110
|
+
type SQLTransactionContextCallback<T> = SQL.TransactionContextCallback<T>;
|
|
111
|
+
|
|
112
|
+
/** @deprecated Use {@link SQL.SavepointContextCallback Bun.SQL.SavepointContextCallback} */
|
|
113
|
+
type SQLSavepointContextCallback<T> = SQL.SavepointContextCallback<T>;
|
|
114
|
+
|
|
115
|
+
/** @deprecated Use {@link SQL.Options Bun.SQL.Options} */
|
|
116
|
+
type SQLOptions = SQL.Options;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @deprecated Renamed to `ErrorLike`
|
|
120
|
+
*/
|
|
121
|
+
type Errorlike = ErrorLike;
|
|
122
|
+
|
|
123
|
+
/** @deprecated This is unused in Bun's types and may be removed in the future */
|
|
124
|
+
type ShellFunction = (input: Uint8Array<ArrayBuffer>) => Uint8Array<ArrayBuffer>;
|
|
125
|
+
|
|
126
|
+
interface TLSOptions {
|
|
127
|
+
/**
|
|
128
|
+
* File path to a TLS key
|
|
129
|
+
*
|
|
130
|
+
* To enable TLS, this option is required.
|
|
131
|
+
*
|
|
132
|
+
* @deprecated since v0.6.3 - Use `key: Bun.file(path)` instead.
|
|
133
|
+
*/
|
|
134
|
+
keyFile?: string;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* File path to a TLS certificate
|
|
138
|
+
*
|
|
139
|
+
* To enable TLS, this option is required.
|
|
140
|
+
*
|
|
141
|
+
* @deprecated since v0.6.3 - Use `cert: Bun.file(path)` instead.
|
|
142
|
+
*/
|
|
143
|
+
certFile?: string;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* File path to a .pem file for a custom root CA
|
|
147
|
+
*
|
|
148
|
+
* @deprecated since v0.6.3 - Use `ca: Bun.file(path)` instead.
|
|
149
|
+
*/
|
|
150
|
+
caFile?: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** @deprecated This type is unused in Bun's declarations and may be removed in the future */
|
|
154
|
+
type ReadableIO = ReadableStream<Uint8Array<ArrayBuffer>> | number | undefined;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
declare namespace NodeJS {
|
|
158
|
+
interface Process {
|
|
159
|
+
/**
|
|
160
|
+
* @deprecated This is deprecated; use the "node:assert" module instead.
|
|
161
|
+
*/
|
|
162
|
+
assert(value: unknown, message?: string | Error): asserts value;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
interface CustomEvent<T = any> {
|
|
167
|
+
/** @deprecated */
|
|
168
|
+
initCustomEvent(type: string, bubbles?: boolean, cancelable?: boolean, detail?: T): void;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
interface DOMException {
|
|
172
|
+
/** @deprecated */
|
|
173
|
+
readonly code: number;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @deprecated Renamed to `BuildMessage`
|
|
178
|
+
*/
|
|
179
|
+
declare var BuildError: typeof BuildMessage;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @deprecated Renamed to `ResolveMessage`
|
|
183
|
+
*/
|
|
184
|
+
declare var ResolveError: typeof ResolveMessage;
|
package/devserver.d.ts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
declare module "bun" {
|
|
2
|
+
type HMREventNames =
|
|
3
|
+
| "beforeUpdate"
|
|
4
|
+
| "afterUpdate"
|
|
5
|
+
| "beforeFullReload"
|
|
6
|
+
| "beforePrune"
|
|
7
|
+
| "invalidate"
|
|
8
|
+
| "error"
|
|
9
|
+
| "ws:disconnect"
|
|
10
|
+
| "ws:connect";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The event names for the dev server
|
|
14
|
+
*/
|
|
15
|
+
type HMREvent = `bun:${HMREventNames}` | (string & {});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ImportMeta {
|
|
19
|
+
/**
|
|
20
|
+
* Hot module replacement APIs. This value is `undefined` in production and
|
|
21
|
+
* can be used in an `if` statement to check if HMR APIs are available
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* if (import.meta.hot) {
|
|
25
|
+
* // HMR APIs are available
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* However, this check is usually not needed as Bun will dead-code-eliminate
|
|
30
|
+
* calls to all of the HMR APIs in production builds.
|
|
31
|
+
*
|
|
32
|
+
* https://bun.com/docs/bundler/hmr
|
|
33
|
+
*/
|
|
34
|
+
hot: {
|
|
35
|
+
/**
|
|
36
|
+
* `import.meta.hot.data` maintains state between module instances during
|
|
37
|
+
* hot replacement, enabling data transfer from previous to new versions.
|
|
38
|
+
* When `import.meta.hot.data` is written to, Bun will mark this module as
|
|
39
|
+
* capable of self-accepting (equivalent of calling `accept()`).
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const root = import.meta.hot.data.root ??= createRoot(elem);
|
|
44
|
+
* root.render(<App />); // re-use an existing root
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* In production, `data` is inlined to be `{}`. This is handy because Bun
|
|
48
|
+
* knows it can minify `{}.prop ??= value` into `value` in production.
|
|
49
|
+
*/
|
|
50
|
+
data: any;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Indicate that this module can be replaced simply by re-evaluating the
|
|
54
|
+
* file. After a hot update, importers of this module will be
|
|
55
|
+
* automatically patched.
|
|
56
|
+
*
|
|
57
|
+
* When `import.meta.hot.accept` is not used, the page will reload when
|
|
58
|
+
* the file updates, and a console message shows which files were checked.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { getCount } from "./foo";
|
|
63
|
+
*
|
|
64
|
+
* console.log("count is ", getCount());
|
|
65
|
+
*
|
|
66
|
+
* import.meta.hot.accept();
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
accept(): void;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Indicate that this module can be replaced by evaluating the new module,
|
|
73
|
+
* and then calling the callback with the new module. In this mode, the
|
|
74
|
+
* importers do not get patched. This is to match Vite, which is unable
|
|
75
|
+
* to patch their import statements. Prefer using `import.meta.hot.accept()`
|
|
76
|
+
* without an argument as it usually makes your code easier to understand.
|
|
77
|
+
*
|
|
78
|
+
* When `import.meta.hot.accept` is not used, the page will reload when
|
|
79
|
+
* the file updates, and a console message shows which files were checked.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* export const count = 0;
|
|
84
|
+
*
|
|
85
|
+
* import.meta.hot.accept((newModule) => {
|
|
86
|
+
* if (newModule) {
|
|
87
|
+
* // newModule is undefined when SyntaxError happened
|
|
88
|
+
* console.log('updated: count is now ', newModule.count)
|
|
89
|
+
* }
|
|
90
|
+
* });
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* In production, calls to this are dead-code-eliminated.
|
|
94
|
+
*/
|
|
95
|
+
accept(cb: (newModule: any | undefined) => void): void;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Indicate that a dependency's module can be accepted. When the dependency
|
|
99
|
+
* is updated, the callback will be called with the new module.
|
|
100
|
+
*
|
|
101
|
+
* When `import.meta.hot.accept` is not used, the page will reload when
|
|
102
|
+
* the file updates, and a console message shows which files were checked.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* import.meta.hot.accept('./foo', (newModule) => {
|
|
107
|
+
* if (newModule) {
|
|
108
|
+
* // newModule is undefined when SyntaxError happened
|
|
109
|
+
* console.log('updated: count is now ', newModule.count)
|
|
110
|
+
* }
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
accept(specifier: string, callback: (newModule: any) => void): void;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Indicate that a dependency's module can be accepted. This variant
|
|
118
|
+
* accepts an array of dependencies, where the callback will receive
|
|
119
|
+
* the one updated module, and `undefined` for the rest.
|
|
120
|
+
*
|
|
121
|
+
* When `import.meta.hot.accept` is not used, the page will reload when
|
|
122
|
+
* the file updates, and a console message shows which files were checked.
|
|
123
|
+
*/
|
|
124
|
+
accept(specifiers: string[], callback: (newModules: (any | undefined)[]) => void): void;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Attach an on-dispose callback. This is called:
|
|
128
|
+
* - Just before the module is replaced with another copy (before the next is loaded)
|
|
129
|
+
* - After the module is detached (removing all imports to this module)
|
|
130
|
+
*
|
|
131
|
+
* This callback is not called on route navigation or when the browser tab closes.
|
|
132
|
+
*
|
|
133
|
+
* Returning a promise will delay module replacement until the module is
|
|
134
|
+
* disposed. All dispose callbacks are called in parallel.
|
|
135
|
+
*/
|
|
136
|
+
dispose(cb: (data: any) => void | Promise<void>): void;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* No-op
|
|
140
|
+
* @deprecated
|
|
141
|
+
*/
|
|
142
|
+
decline(): void;
|
|
143
|
+
|
|
144
|
+
// NOTE TO CONTRIBUTORS ////////////////////////////////////////
|
|
145
|
+
// Callback is currently never called for `.prune()` //
|
|
146
|
+
// so the types are commented out until we support it. //
|
|
147
|
+
////////////////////////////////////////////////////////////////
|
|
148
|
+
// /**
|
|
149
|
+
// * Attach a callback that is called when the module is removed from the module graph.
|
|
150
|
+
// *
|
|
151
|
+
// * This can be used to clean up resources that were created when the module was loaded.
|
|
152
|
+
// * Unlike `import.meta.hot.dispose()`, this pairs much better with `accept` and `data` to manage stateful resources.
|
|
153
|
+
// *
|
|
154
|
+
// * @example
|
|
155
|
+
// * ```ts
|
|
156
|
+
// * export const ws = (import.meta.hot.data.ws ??= new WebSocket(location.origin));
|
|
157
|
+
// *
|
|
158
|
+
// * import.meta.hot.prune(() => {
|
|
159
|
+
// * ws.close();
|
|
160
|
+
// * });
|
|
161
|
+
// * ```
|
|
162
|
+
// */
|
|
163
|
+
// prune(callback: () => void): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Listen for an event from the dev server
|
|
167
|
+
*
|
|
168
|
+
* For compatibility with Vite, event names are also available via vite:* prefix instead of bun:*.
|
|
169
|
+
*
|
|
170
|
+
* https://bun.com/docs/bundler/hmr#import-meta-hot-on-and-off
|
|
171
|
+
* @param event The event to listen to
|
|
172
|
+
* @param callback The callback to call when the event is emitted
|
|
173
|
+
*/
|
|
174
|
+
on(event: Bun.HMREvent, callback: () => void): void;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Stop listening for an event from the dev server
|
|
178
|
+
*
|
|
179
|
+
* For compatibility with Vite, event names are also available via vite:* prefix instead of bun:*.
|
|
180
|
+
*
|
|
181
|
+
* https://bun.com/docs/bundler/hmr#import-meta-hot-on-and-off
|
|
182
|
+
* @param event The event to stop listening to
|
|
183
|
+
* @param callback The callback to stop listening to
|
|
184
|
+
*/
|
|
185
|
+
off(event: Bun.HMREvent, callback: () => void): void;
|
|
186
|
+
};
|
|
187
|
+
}
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://bun.com">
|
|
3
|
+
<img src="https://github.com/user-attachments/assets/50282090-adfd-4ddb-9e27-c30753c6b161" alt="Logo" height="170" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
<h1 align="center">Bun Documentation</h1>
|
|
7
|
+
|
|
8
|
+
Official documentation for Bun: the fast, all-in-one JavaScript runtime.
|
|
9
|
+
|
|
10
|
+
## Development
|
|
11
|
+
|
|
12
|
+
Install the [Mintlify CLI](https://www.npmjs.com/package/mint) to preview the documentation locally:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
bun install -g mint
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Run the development server:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
mint dev
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The site will be available at `http://localhost:3000`.
|
|
25
|
+
|
|
26
|
+
## Contributing
|
|
27
|
+
|
|
28
|
+
Contributions are welcome! Please open an issue or submit a pull request.
|