bun-types 1.2.10-canary.20250414T140624 → 1.2.10-canary.20250415T140641
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/bun.d.ts +369 -424
- package/devserver.d.ts +0 -2
- package/docs/api/fetch.md +1 -1
- package/docs/api/redis.md +1 -1
- package/docs/api/spawn.md +1 -1
- package/docs/cli/publish.md +1 -1
- package/docs/guides/ecosystem/nuxt.md +1 -1
- package/docs/guides/install/add-peer.md +2 -2
- package/docs/guides/install/from-npm-install-to-bun-install.md +1 -1
- package/docs/guides/test/run-tests.md +3 -3
- package/docs/guides/test/snapshot.md +3 -3
- package/docs/guides/test/update-snapshots.md +1 -1
- package/docs/guides/util/version.md +1 -1
- package/docs/installation.md +4 -4
- package/docs/runtime/debugger.md +3 -3
- package/docs/test/dom.md +1 -1
- package/globals.d.ts +83 -34
- package/index.d.ts +2 -0
- package/package.json +2 -3
- package/s3.d.ts +349 -12
- package/shell.d.ts +355 -0
- package/sqlite.d.ts +62 -66
- package/test.d.ts +6 -1
package/bun.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ declare module "bun" {
|
|
|
57
57
|
*
|
|
58
58
|
* Uses the lib.dom.d.ts definition if it exists, otherwise defines it locally.
|
|
59
59
|
*
|
|
60
|
-
* This is to avoid type conflicts between lib.dom.d.ts and
|
|
60
|
+
* This is to avoid type conflicts between lib.dom.d.ts and \@types/bun.
|
|
61
61
|
*
|
|
62
62
|
* Unfortunately some symbols cannot be defined when both Bun types and lib.dom.d.ts types are loaded,
|
|
63
63
|
* and since we can't redeclare the symbol in a way that satisfies both, we need to fallback
|
|
@@ -162,17 +162,6 @@ declare module "bun" {
|
|
|
162
162
|
open: Event;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
interface EventInit {
|
|
166
|
-
bubbles?: boolean;
|
|
167
|
-
cancelable?: boolean;
|
|
168
|
-
composed?: boolean;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
interface EventListenerOptions {
|
|
172
|
-
/** Not directly used by Node.js. Added for API completeness. Default: `false`. */
|
|
173
|
-
capture?: boolean;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
165
|
interface AddEventListenerOptions extends EventListenerOptions {
|
|
177
166
|
/** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */
|
|
178
167
|
once?: boolean;
|
|
@@ -560,7 +549,6 @@ declare module "bun" {
|
|
|
560
549
|
*
|
|
561
550
|
* @returns The width of the string in columns
|
|
562
551
|
*
|
|
563
|
-
* ## Examples
|
|
564
552
|
* @example
|
|
565
553
|
* ```ts
|
|
566
554
|
* import { stringWidth } from "bun";
|
|
@@ -571,7 +559,6 @@ declare module "bun" {
|
|
|
571
559
|
* console.log(stringWidth("\u001b[31mhello\u001b[39m", { countAnsiEscapeCodes: false })); // 5
|
|
572
560
|
* console.log(stringWidth("\u001b[31mhello\u001b[39m", { countAnsiEscapeCodes: true })); // 13
|
|
573
561
|
* ```
|
|
574
|
-
*
|
|
575
562
|
*/
|
|
576
563
|
function stringWidth(
|
|
577
564
|
/**
|
|
@@ -594,367 +581,6 @@ declare module "bun" {
|
|
|
594
581
|
},
|
|
595
582
|
): number;
|
|
596
583
|
|
|
597
|
-
type ShellFunction = (input: Uint8Array) => Uint8Array;
|
|
598
|
-
|
|
599
|
-
type ShellExpression =
|
|
600
|
-
| { toString(): string }
|
|
601
|
-
| Array<ShellExpression>
|
|
602
|
-
| string
|
|
603
|
-
| { raw: string }
|
|
604
|
-
| Subprocess
|
|
605
|
-
| SpawnOptions.Readable
|
|
606
|
-
| SpawnOptions.Writable
|
|
607
|
-
| ReadableStream;
|
|
608
|
-
|
|
609
|
-
class ShellPromise extends Promise<ShellOutput> {
|
|
610
|
-
get stdin(): WritableStream;
|
|
611
|
-
/**
|
|
612
|
-
* Change the current working directory of the shell.
|
|
613
|
-
* @param newCwd - The new working directory
|
|
614
|
-
*/
|
|
615
|
-
cwd(newCwd: string): this;
|
|
616
|
-
/**
|
|
617
|
-
* Set environment variables for the shell.
|
|
618
|
-
* @param newEnv - The new environment variables
|
|
619
|
-
*
|
|
620
|
-
* @example
|
|
621
|
-
* ```ts
|
|
622
|
-
* await $`echo $FOO`.env({ ...process.env, FOO: "LOL!" })
|
|
623
|
-
* expect(stdout.toString()).toBe("LOL!");
|
|
624
|
-
* ```
|
|
625
|
-
*/
|
|
626
|
-
env(newEnv: Record<string, string> | undefined): this;
|
|
627
|
-
/**
|
|
628
|
-
* By default, the shell will write to the current process's stdout and stderr, as well as buffering that output.
|
|
629
|
-
*
|
|
630
|
-
* This configures the shell to only buffer the output.
|
|
631
|
-
*/
|
|
632
|
-
quiet(): this;
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* Read from stdout as a string, line by line
|
|
636
|
-
*
|
|
637
|
-
* Automatically calls {@link quiet} to disable echoing to stdout.
|
|
638
|
-
*/
|
|
639
|
-
lines(): AsyncIterable<string>;
|
|
640
|
-
|
|
641
|
-
/**
|
|
642
|
-
* Read from stdout as a string
|
|
643
|
-
*
|
|
644
|
-
* Automatically calls {@link quiet} to disable echoing to stdout.
|
|
645
|
-
* @param encoding - The encoding to use when decoding the output
|
|
646
|
-
* @returns A promise that resolves with stdout as a string
|
|
647
|
-
* @example
|
|
648
|
-
*
|
|
649
|
-
* ## Read as UTF-8 string
|
|
650
|
-
*
|
|
651
|
-
* ```ts
|
|
652
|
-
* const output = await $`echo hello`.text();
|
|
653
|
-
* console.log(output); // "hello\n"
|
|
654
|
-
* ```
|
|
655
|
-
*
|
|
656
|
-
* ## Read as base64 string
|
|
657
|
-
*
|
|
658
|
-
* ```ts
|
|
659
|
-
* const output = await $`echo ${atob("hello")}`.text("base64");
|
|
660
|
-
* console.log(output); // "hello\n"
|
|
661
|
-
* ```
|
|
662
|
-
*
|
|
663
|
-
*/
|
|
664
|
-
text(encoding?: BufferEncoding): Promise<string>;
|
|
665
|
-
|
|
666
|
-
/**
|
|
667
|
-
* Read from stdout as a JSON object
|
|
668
|
-
*
|
|
669
|
-
* Automatically calls {@link quiet}
|
|
670
|
-
*
|
|
671
|
-
* @returns A promise that resolves with stdout as a JSON object
|
|
672
|
-
* @example
|
|
673
|
-
*
|
|
674
|
-
* ```ts
|
|
675
|
-
* const output = await $`echo '{"hello": 123}'`.json();
|
|
676
|
-
* console.log(output); // { hello: 123 }
|
|
677
|
-
* ```
|
|
678
|
-
*
|
|
679
|
-
*/
|
|
680
|
-
json(): Promise<any>;
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
* Read from stdout as an ArrayBuffer
|
|
684
|
-
*
|
|
685
|
-
* Automatically calls {@link quiet}
|
|
686
|
-
* @returns A promise that resolves with stdout as an ArrayBuffer
|
|
687
|
-
* @example
|
|
688
|
-
*
|
|
689
|
-
* ```ts
|
|
690
|
-
* const output = await $`echo hello`.arrayBuffer();
|
|
691
|
-
* console.log(output); // ArrayBuffer { byteLength: 6 }
|
|
692
|
-
* ```
|
|
693
|
-
*/
|
|
694
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
695
|
-
|
|
696
|
-
/**
|
|
697
|
-
* Read from stdout as a Blob
|
|
698
|
-
*
|
|
699
|
-
* Automatically calls {@link quiet}
|
|
700
|
-
* @returns A promise that resolves with stdout as a Blob
|
|
701
|
-
* @example
|
|
702
|
-
* ```ts
|
|
703
|
-
* const output = await $`echo hello`.blob();
|
|
704
|
-
* console.log(output); // Blob { size: 6, type: "" }
|
|
705
|
-
* ```
|
|
706
|
-
*/
|
|
707
|
-
blob(): Promise<Blob>;
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* Configure the shell to not throw an exception on non-zero exit codes. Throwing can be re-enabled with `.throws(true)`.
|
|
711
|
-
*
|
|
712
|
-
* By default, the shell with throw an exception on commands which return non-zero exit codes.
|
|
713
|
-
*/
|
|
714
|
-
nothrow(): this;
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
* Configure whether or not the shell should throw an exception on non-zero exit codes.
|
|
718
|
-
*
|
|
719
|
-
* By default, this is configured to `true`.
|
|
720
|
-
*/
|
|
721
|
-
throws(shouldThrow: boolean): this;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
interface ShellConstructor {
|
|
725
|
-
new (): Shell;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
interface Shell {
|
|
729
|
-
(strings: TemplateStringsArray, ...expressions: ShellExpression[]): ShellPromise;
|
|
730
|
-
|
|
731
|
-
readonly Shell: ShellConstructor;
|
|
732
|
-
readonly ShellPromise: typeof ShellPromise;
|
|
733
|
-
readonly ShellError: typeof ShellError;
|
|
734
|
-
|
|
735
|
-
/**
|
|
736
|
-
* Perform bash-like brace expansion on the given pattern.
|
|
737
|
-
* @param pattern - Brace pattern to expand
|
|
738
|
-
*
|
|
739
|
-
* @example
|
|
740
|
-
* ```js
|
|
741
|
-
* const result = braces('index.{js,jsx,ts,tsx}');
|
|
742
|
-
* console.log(result) // ['index.js', 'index.jsx', 'index.ts', 'index.tsx']
|
|
743
|
-
* ```
|
|
744
|
-
*/
|
|
745
|
-
braces(pattern: string): string[];
|
|
746
|
-
|
|
747
|
-
/**
|
|
748
|
-
* Escape strings for input into shell commands.
|
|
749
|
-
* @param input
|
|
750
|
-
*/
|
|
751
|
-
escape(input: string): string;
|
|
752
|
-
|
|
753
|
-
/**
|
|
754
|
-
*
|
|
755
|
-
* Change the default environment variables for shells created by this instance.
|
|
756
|
-
*
|
|
757
|
-
* @param newEnv Default environment variables to use for shells created by this instance.
|
|
758
|
-
* @default process.env
|
|
759
|
-
*
|
|
760
|
-
* ## Example
|
|
761
|
-
*
|
|
762
|
-
* ```js
|
|
763
|
-
* import {$} from 'bun';
|
|
764
|
-
* $.env({ BUN: "bun" });
|
|
765
|
-
* await $`echo $BUN`;
|
|
766
|
-
* // "bun"
|
|
767
|
-
* ```
|
|
768
|
-
*/
|
|
769
|
-
env(newEnv?: Record<string, string | undefined>): this;
|
|
770
|
-
|
|
771
|
-
/**
|
|
772
|
-
*
|
|
773
|
-
* @param newCwd Default working directory to use for shells created by this instance.
|
|
774
|
-
*/
|
|
775
|
-
cwd(newCwd?: string): this;
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
* Configure the shell to not throw an exception on non-zero exit codes.
|
|
779
|
-
*/
|
|
780
|
-
nothrow(): this;
|
|
781
|
-
|
|
782
|
-
/**
|
|
783
|
-
* Configure whether or not the shell should throw an exception on non-zero exit codes.
|
|
784
|
-
*/
|
|
785
|
-
throws(shouldThrow: boolean): this;
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
class ShellError extends Error implements ShellOutput {
|
|
789
|
-
readonly stdout: Buffer;
|
|
790
|
-
readonly stderr: Buffer;
|
|
791
|
-
readonly exitCode: number;
|
|
792
|
-
|
|
793
|
-
/**
|
|
794
|
-
* Read from stdout as a string
|
|
795
|
-
*
|
|
796
|
-
* @param encoding - The encoding to use when decoding the output
|
|
797
|
-
* @returns Stdout as a string with the given encoding
|
|
798
|
-
* @example
|
|
799
|
-
*
|
|
800
|
-
* ## Read as UTF-8 string
|
|
801
|
-
*
|
|
802
|
-
* ```ts
|
|
803
|
-
* const output = await $`echo hello`;
|
|
804
|
-
* console.log(output.text()); // "hello\n"
|
|
805
|
-
* ```
|
|
806
|
-
*
|
|
807
|
-
* ## Read as base64 string
|
|
808
|
-
*
|
|
809
|
-
* ```ts
|
|
810
|
-
* const output = await $`echo ${atob("hello")}`;
|
|
811
|
-
* console.log(output.text("base64")); // "hello\n"
|
|
812
|
-
* ```
|
|
813
|
-
*
|
|
814
|
-
*/
|
|
815
|
-
text(encoding?: BufferEncoding): string;
|
|
816
|
-
|
|
817
|
-
/**
|
|
818
|
-
* Read from stdout as a JSON object
|
|
819
|
-
*
|
|
820
|
-
* @returns Stdout as a JSON object
|
|
821
|
-
* @example
|
|
822
|
-
*
|
|
823
|
-
* ```ts
|
|
824
|
-
* const output = await $`echo '{"hello": 123}'`;
|
|
825
|
-
* console.log(output.json()); // { hello: 123 }
|
|
826
|
-
* ```
|
|
827
|
-
*
|
|
828
|
-
*/
|
|
829
|
-
json(): any;
|
|
830
|
-
|
|
831
|
-
/**
|
|
832
|
-
* Read from stdout as an ArrayBuffer
|
|
833
|
-
*
|
|
834
|
-
* @returns Stdout as an ArrayBuffer
|
|
835
|
-
* @example
|
|
836
|
-
*
|
|
837
|
-
* ```ts
|
|
838
|
-
* const output = await $`echo hello`;
|
|
839
|
-
* console.log(output.arrayBuffer()); // ArrayBuffer { byteLength: 6 }
|
|
840
|
-
* ```
|
|
841
|
-
*/
|
|
842
|
-
arrayBuffer(): ArrayBuffer;
|
|
843
|
-
|
|
844
|
-
/**
|
|
845
|
-
* Read from stdout as a Blob
|
|
846
|
-
*
|
|
847
|
-
* @returns Stdout as a blob
|
|
848
|
-
* @example
|
|
849
|
-
* ```ts
|
|
850
|
-
* const output = await $`echo hello`;
|
|
851
|
-
* console.log(output.blob()); // Blob { size: 6, type: "" }
|
|
852
|
-
* ```
|
|
853
|
-
*/
|
|
854
|
-
blob(): Blob;
|
|
855
|
-
|
|
856
|
-
/**
|
|
857
|
-
* Read from stdout as an Uint8Array
|
|
858
|
-
*
|
|
859
|
-
* @returns Stdout as an Uint8Array
|
|
860
|
-
* @example
|
|
861
|
-
*```ts
|
|
862
|
-
* const output = await $`echo hello`;
|
|
863
|
-
* console.log(output.bytes()); // Uint8Array { byteLength: 6 }
|
|
864
|
-
* ```
|
|
865
|
-
*/
|
|
866
|
-
bytes(): Uint8Array;
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
interface ShellOutput {
|
|
870
|
-
readonly stdout: Buffer;
|
|
871
|
-
readonly stderr: Buffer;
|
|
872
|
-
readonly exitCode: number;
|
|
873
|
-
|
|
874
|
-
/**
|
|
875
|
-
* Read from stdout as a string
|
|
876
|
-
*
|
|
877
|
-
* @param encoding - The encoding to use when decoding the output
|
|
878
|
-
* @returns Stdout as a string with the given encoding
|
|
879
|
-
* @example
|
|
880
|
-
*
|
|
881
|
-
* ## Read as UTF-8 string
|
|
882
|
-
*
|
|
883
|
-
* ```ts
|
|
884
|
-
* const output = await $`echo hello`;
|
|
885
|
-
* console.log(output.text()); // "hello\n"
|
|
886
|
-
* ```
|
|
887
|
-
*
|
|
888
|
-
* ## Read as base64 string
|
|
889
|
-
*
|
|
890
|
-
* ```ts
|
|
891
|
-
* const output = await $`echo ${atob("hello")}`;
|
|
892
|
-
* console.log(output.text("base64")); // "hello\n"
|
|
893
|
-
* ```
|
|
894
|
-
*
|
|
895
|
-
*/
|
|
896
|
-
text(encoding?: BufferEncoding): string;
|
|
897
|
-
|
|
898
|
-
/**
|
|
899
|
-
* Read from stdout as a JSON object
|
|
900
|
-
*
|
|
901
|
-
* @returns Stdout as a JSON object
|
|
902
|
-
* @example
|
|
903
|
-
*
|
|
904
|
-
* ```ts
|
|
905
|
-
* const output = await $`echo '{"hello": 123}'`;
|
|
906
|
-
* console.log(output.json()); // { hello: 123 }
|
|
907
|
-
* ```
|
|
908
|
-
*
|
|
909
|
-
*/
|
|
910
|
-
json(): any;
|
|
911
|
-
|
|
912
|
-
/**
|
|
913
|
-
* Read from stdout as an ArrayBuffer
|
|
914
|
-
*
|
|
915
|
-
* @returns Stdout as an ArrayBuffer
|
|
916
|
-
* @example
|
|
917
|
-
*
|
|
918
|
-
* ```ts
|
|
919
|
-
* const output = await $`echo hello`;
|
|
920
|
-
* console.log(output.arrayBuffer()); // ArrayBuffer { byteLength: 6 }
|
|
921
|
-
* ```
|
|
922
|
-
*/
|
|
923
|
-
arrayBuffer(): ArrayBuffer;
|
|
924
|
-
|
|
925
|
-
/**
|
|
926
|
-
* Read from stdout as an Uint8Array
|
|
927
|
-
*
|
|
928
|
-
* @returns Stdout as an Uint8Array
|
|
929
|
-
* @example
|
|
930
|
-
*
|
|
931
|
-
* ```ts
|
|
932
|
-
* const output = await $`echo hello`;
|
|
933
|
-
* console.log(output.bytes()); // Uint8Array { byteLength: 6 }
|
|
934
|
-
* ```
|
|
935
|
-
*/
|
|
936
|
-
bytes(): Uint8Array;
|
|
937
|
-
|
|
938
|
-
/**
|
|
939
|
-
* Read from stdout as a Blob
|
|
940
|
-
*
|
|
941
|
-
* @returns Stdout as a blob
|
|
942
|
-
* @example
|
|
943
|
-
* ```ts
|
|
944
|
-
* const output = await $`echo hello`;
|
|
945
|
-
* console.log(output.blob()); // Blob { size: 6, type: "" }
|
|
946
|
-
* ```
|
|
947
|
-
*/
|
|
948
|
-
blob(): Blob;
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
/**
|
|
952
|
-
* The Bun shell
|
|
953
|
-
*
|
|
954
|
-
* @category Process Management
|
|
955
|
-
*/
|
|
956
|
-
const $: Shell;
|
|
957
|
-
|
|
958
584
|
const TOML: {
|
|
959
585
|
/**
|
|
960
586
|
* Parse a TOML string into a JavaScript object.
|
|
@@ -1227,8 +853,7 @@ declare module "bun" {
|
|
|
1227
853
|
* @param multipartBoundaryExcludingDashes Optional boundary to use for multipart form data. If none is provided, assumes it is a URLEncoded form.
|
|
1228
854
|
* @returns A promise that resolves with the data encoded into a {@link FormData} object.
|
|
1229
855
|
*
|
|
1230
|
-
*
|
|
1231
|
-
*
|
|
856
|
+
* @example Multipart form data example
|
|
1232
857
|
* ```ts
|
|
1233
858
|
* // without dashes
|
|
1234
859
|
* const boundary = "WebKitFormBoundary" + Math.random().toString(16).slice(2);
|
|
@@ -1237,8 +862,8 @@ declare module "bun" {
|
|
|
1237
862
|
* const formData = await Bun.readableStreamToFormData(stream, boundary);
|
|
1238
863
|
* formData.get("foo"); // "bar"
|
|
1239
864
|
* ```
|
|
1240
|
-
* ## URL-encoded form data example
|
|
1241
865
|
*
|
|
866
|
+
* @example URL-encoded form data example
|
|
1242
867
|
* ```ts
|
|
1243
868
|
* const stream = new Response("hello=123").body;
|
|
1244
869
|
* const formData = await Bun.readableStreamToFormData(stream);
|
|
@@ -2043,22 +1668,6 @@ declare module "bun" {
|
|
|
2043
1668
|
*/
|
|
2044
1669
|
maxAge?: number;
|
|
2045
1670
|
}
|
|
2046
|
-
interface CSRF {
|
|
2047
|
-
/**
|
|
2048
|
-
* Generate a CSRF token.
|
|
2049
|
-
* @param secret The secret to use for the token. If not provided, a random default secret will be generated in memory and used.
|
|
2050
|
-
* @param options The options for the token.
|
|
2051
|
-
* @returns The generated token.
|
|
2052
|
-
*/
|
|
2053
|
-
generate(secret?: string, options?: CSRFGenerateOptions): string;
|
|
2054
|
-
/**
|
|
2055
|
-
* Verify a CSRF token.
|
|
2056
|
-
* @param token The token to verify.
|
|
2057
|
-
* @param options The options for the token.
|
|
2058
|
-
* @returns True if the token is valid, false otherwise.
|
|
2059
|
-
*/
|
|
2060
|
-
verify(token: string, options?: CSRFVerifyOptions): boolean;
|
|
2061
|
-
}
|
|
2062
1671
|
|
|
2063
1672
|
/**
|
|
2064
1673
|
* SQL client
|
|
@@ -2086,7 +1695,23 @@ declare module "bun" {
|
|
|
2086
1695
|
*
|
|
2087
1696
|
* @category Security
|
|
2088
1697
|
*/
|
|
2089
|
-
var CSRF:
|
|
1698
|
+
var CSRF: {
|
|
1699
|
+
/**
|
|
1700
|
+
* Generate a CSRF token.
|
|
1701
|
+
* @param secret The secret to use for the token. If not provided, a random default secret will be generated in memory and used.
|
|
1702
|
+
* @param options The options for the token.
|
|
1703
|
+
* @returns The generated token.
|
|
1704
|
+
*/
|
|
1705
|
+
generate(secret?: string, options?: CSRFGenerateOptions): string;
|
|
1706
|
+
|
|
1707
|
+
/**
|
|
1708
|
+
* Verify a CSRF token.
|
|
1709
|
+
* @param token The token to verify.
|
|
1710
|
+
* @param options The options for the token.
|
|
1711
|
+
* @returns True if the token is valid, false otherwise.
|
|
1712
|
+
*/
|
|
1713
|
+
verify(token: string, options?: CSRFVerifyOptions): boolean;
|
|
1714
|
+
};
|
|
2090
1715
|
|
|
2091
1716
|
/**
|
|
2092
1717
|
* This lets you use macros as regular imports
|
|
@@ -2449,6 +2074,7 @@ declare module "bun" {
|
|
|
2449
2074
|
* @see {@link publicPath} to customize the base url of linked source maps
|
|
2450
2075
|
*/
|
|
2451
2076
|
sourcemap?: "none" | "linked" | "inline" | "external" | "linked" | boolean;
|
|
2077
|
+
|
|
2452
2078
|
/**
|
|
2453
2079
|
* package.json `exports` conditions used when resolving imports
|
|
2454
2080
|
*
|
|
@@ -2477,6 +2103,7 @@ declare module "bun" {
|
|
|
2477
2103
|
* ```
|
|
2478
2104
|
*/
|
|
2479
2105
|
env?: "inline" | "disable" | `${string}*`;
|
|
2106
|
+
|
|
2480
2107
|
/**
|
|
2481
2108
|
* Whether to enable minification.
|
|
2482
2109
|
*
|
|
@@ -2492,16 +2119,19 @@ declare module "bun" {
|
|
|
2492
2119
|
syntax?: boolean;
|
|
2493
2120
|
identifiers?: boolean;
|
|
2494
2121
|
};
|
|
2122
|
+
|
|
2495
2123
|
/**
|
|
2496
2124
|
* Ignore dead code elimination/tree-shaking annotations such as @__PURE__ and package.json
|
|
2497
2125
|
* "sideEffects" fields. This should only be used as a temporary workaround for incorrect
|
|
2498
2126
|
* annotations in libraries.
|
|
2499
2127
|
*/
|
|
2500
2128
|
ignoreDCEAnnotations?: boolean;
|
|
2129
|
+
|
|
2501
2130
|
/**
|
|
2502
2131
|
* Force emitting @__PURE__ annotations even if minify.whitespace is true.
|
|
2503
2132
|
*/
|
|
2504
2133
|
emitDCEAnnotations?: boolean;
|
|
2134
|
+
|
|
2505
2135
|
// treeshaking?: boolean;
|
|
2506
2136
|
|
|
2507
2137
|
// jsx?:
|
|
@@ -2528,10 +2158,12 @@ declare module "bun" {
|
|
|
2528
2158
|
* @default false
|
|
2529
2159
|
*/
|
|
2530
2160
|
bytecode?: boolean;
|
|
2161
|
+
|
|
2531
2162
|
/**
|
|
2532
2163
|
* Add a banner to the bundled code such as "use client";
|
|
2533
2164
|
*/
|
|
2534
2165
|
banner?: string;
|
|
2166
|
+
|
|
2535
2167
|
/**
|
|
2536
2168
|
* Add a footer to the bundled code such as a comment block like
|
|
2537
2169
|
*
|
|
@@ -2562,10 +2194,9 @@ declare module "bun" {
|
|
|
2562
2194
|
* @category Security
|
|
2563
2195
|
*/
|
|
2564
2196
|
namespace Password {
|
|
2565
|
-
type AlgorithmLabel = "bcrypt" | "argon2id" | "argon2d" | "argon2i";
|
|
2566
|
-
|
|
2567
2197
|
interface Argon2Algorithm {
|
|
2568
2198
|
algorithm: "argon2id" | "argon2d" | "argon2i";
|
|
2199
|
+
|
|
2569
2200
|
/**
|
|
2570
2201
|
* Memory cost, which defines the memory usage, given in kibibytes.
|
|
2571
2202
|
*/
|
|
@@ -2579,11 +2210,14 @@ declare module "bun" {
|
|
|
2579
2210
|
|
|
2580
2211
|
interface BCryptAlgorithm {
|
|
2581
2212
|
algorithm: "bcrypt";
|
|
2213
|
+
|
|
2582
2214
|
/**
|
|
2583
2215
|
* A number between 4 and 31. The default is 10.
|
|
2584
2216
|
*/
|
|
2585
2217
|
cost?: number;
|
|
2586
2218
|
}
|
|
2219
|
+
|
|
2220
|
+
type AlgorithmLabel = (BCryptAlgorithm | Argon2Algorithm)["algorithm"];
|
|
2587
2221
|
}
|
|
2588
2222
|
|
|
2589
2223
|
/**
|
|
@@ -2594,7 +2228,7 @@ declare module "bun" {
|
|
|
2594
2228
|
* @see [Bun.password API docs](https://bun.sh/guides/util/hash-a-password)
|
|
2595
2229
|
*
|
|
2596
2230
|
* The underlying implementation of these functions are provided by the Zig
|
|
2597
|
-
* Standard Library. Thanks to
|
|
2231
|
+
* Standard Library. Thanks to \@jedisct1 and other Zig contributors for their
|
|
2598
2232
|
* work on this.
|
|
2599
2233
|
*
|
|
2600
2234
|
* ### Example with argon2
|
|
@@ -2686,9 +2320,9 @@ declare module "bun" {
|
|
|
2686
2320
|
*/
|
|
2687
2321
|
password: Bun.StringOrBuffer,
|
|
2688
2322
|
/**
|
|
2689
|
-
* @default "argon2id"
|
|
2690
|
-
*
|
|
2691
2323
|
* When using bcrypt, passwords exceeding 72 characters will be SHA512'd before
|
|
2324
|
+
*
|
|
2325
|
+
* @default "argon2id"
|
|
2692
2326
|
*/
|
|
2693
2327
|
algorithm?: Password.AlgorithmLabel | Password.Argon2Algorithm | Password.BCryptAlgorithm,
|
|
2694
2328
|
): Promise<string>;
|
|
@@ -2699,7 +2333,7 @@ declare module "bun" {
|
|
|
2699
2333
|
* instead which runs in a worker thread.
|
|
2700
2334
|
*
|
|
2701
2335
|
* The underlying implementation of these functions are provided by the Zig
|
|
2702
|
-
* Standard Library. Thanks to
|
|
2336
|
+
* Standard Library. Thanks to \@jedisct1 and other Zig contributors for their
|
|
2703
2337
|
* work on this.
|
|
2704
2338
|
*
|
|
2705
2339
|
* ### Example with argon2
|
|
@@ -2724,7 +2358,13 @@ declare module "bun" {
|
|
|
2724
2358
|
* ```
|
|
2725
2359
|
*/
|
|
2726
2360
|
verifySync(
|
|
2361
|
+
/**
|
|
2362
|
+
* The password to verify.
|
|
2363
|
+
*/
|
|
2727
2364
|
password: Bun.StringOrBuffer,
|
|
2365
|
+
/**
|
|
2366
|
+
* The hash to verify against.
|
|
2367
|
+
*/
|
|
2728
2368
|
hash: Bun.StringOrBuffer,
|
|
2729
2369
|
/**
|
|
2730
2370
|
* If not specified, the algorithm will be inferred from the hash.
|
|
@@ -2738,7 +2378,7 @@ declare module "bun" {
|
|
|
2738
2378
|
* instead which runs in a worker thread.
|
|
2739
2379
|
*
|
|
2740
2380
|
* The underlying implementation of these functions are provided by the Zig
|
|
2741
|
-
* Standard Library. Thanks to
|
|
2381
|
+
* Standard Library. Thanks to \@jedisct1 and other Zig contributors for their
|
|
2742
2382
|
* work on this.
|
|
2743
2383
|
*
|
|
2744
2384
|
* ### Example with argon2
|
|
@@ -2770,10 +2410,11 @@ declare module "bun" {
|
|
|
2770
2410
|
* mistake to hash an empty password.
|
|
2771
2411
|
*/
|
|
2772
2412
|
password: Bun.StringOrBuffer,
|
|
2413
|
+
|
|
2773
2414
|
/**
|
|
2774
|
-
* @default "argon2id"
|
|
2775
|
-
*
|
|
2776
2415
|
* When using bcrypt, passwords exceeding 72 characters will be SHA256'd before
|
|
2416
|
+
*
|
|
2417
|
+
* @default "argon2id"
|
|
2777
2418
|
*/
|
|
2778
2419
|
algorithm?: Password.AlgorithmLabel | Password.Argon2Algorithm | Password.BCryptAlgorithm,
|
|
2779
2420
|
): string;
|
|
@@ -4618,6 +4259,211 @@ declare module "bun" {
|
|
|
4618
4259
|
compact?: boolean;
|
|
4619
4260
|
}
|
|
4620
4261
|
|
|
4262
|
+
type WebSocketOptionsProtocolsOrProtocol =
|
|
4263
|
+
| {
|
|
4264
|
+
/**
|
|
4265
|
+
* Protocols to use for the WebSocket connection
|
|
4266
|
+
*/
|
|
4267
|
+
protocols?: string | string[];
|
|
4268
|
+
}
|
|
4269
|
+
| {
|
|
4270
|
+
/**
|
|
4271
|
+
* Protocol to use for the WebSocket connection
|
|
4272
|
+
*/
|
|
4273
|
+
protocol?: string;
|
|
4274
|
+
};
|
|
4275
|
+
|
|
4276
|
+
type WebSocketOptionsTLS = {
|
|
4277
|
+
/**
|
|
4278
|
+
* Options for the TLS connection
|
|
4279
|
+
*/
|
|
4280
|
+
tls?: {
|
|
4281
|
+
/**
|
|
4282
|
+
* Whether to reject the connection if the certificate is not valid
|
|
4283
|
+
*
|
|
4284
|
+
* @default true
|
|
4285
|
+
*/
|
|
4286
|
+
rejectUnauthorized?: boolean;
|
|
4287
|
+
};
|
|
4288
|
+
};
|
|
4289
|
+
|
|
4290
|
+
type WebSocketOptionsHeaders = {
|
|
4291
|
+
/**
|
|
4292
|
+
* Headers to send to the server
|
|
4293
|
+
*/
|
|
4294
|
+
headers?: import("node:http").OutgoingHttpHeaders;
|
|
4295
|
+
};
|
|
4296
|
+
|
|
4297
|
+
/**
|
|
4298
|
+
* Constructor options for the `Bun.WebSocket` client
|
|
4299
|
+
*/
|
|
4300
|
+
type WebSocketOptions = WebSocketOptionsProtocolsOrProtocol & WebSocketOptionsTLS & WebSocketOptionsHeaders;
|
|
4301
|
+
|
|
4302
|
+
interface WebSocketEventMap {
|
|
4303
|
+
close: CloseEvent;
|
|
4304
|
+
error: Event;
|
|
4305
|
+
message: MessageEvent;
|
|
4306
|
+
open: Event;
|
|
4307
|
+
}
|
|
4308
|
+
|
|
4309
|
+
/**
|
|
4310
|
+
* A WebSocket client implementation
|
|
4311
|
+
*
|
|
4312
|
+
* @example
|
|
4313
|
+
* ```ts
|
|
4314
|
+
* const ws = new WebSocket("ws://localhost:8080", {
|
|
4315
|
+
* headers: {
|
|
4316
|
+
* "x-custom-header": "hello",
|
|
4317
|
+
* },
|
|
4318
|
+
* });
|
|
4319
|
+
*
|
|
4320
|
+
* ws.addEventListener("open", () => {
|
|
4321
|
+
* console.log("Connected to server");
|
|
4322
|
+
* });
|
|
4323
|
+
*
|
|
4324
|
+
* ws.addEventListener("message", (event) => {
|
|
4325
|
+
* console.log("Received message:", event.data);
|
|
4326
|
+
* });
|
|
4327
|
+
*
|
|
4328
|
+
* ws.send("Hello, server!");
|
|
4329
|
+
* ws.terminate();
|
|
4330
|
+
* ```
|
|
4331
|
+
*/
|
|
4332
|
+
interface WebSocket extends EventTarget {
|
|
4333
|
+
/**
|
|
4334
|
+
* The URL of the WebSocket connection
|
|
4335
|
+
*/
|
|
4336
|
+
readonly url: string;
|
|
4337
|
+
|
|
4338
|
+
/**
|
|
4339
|
+
* Legacy URL property (same as url)
|
|
4340
|
+
* @deprecated Use url instead
|
|
4341
|
+
*/
|
|
4342
|
+
readonly URL: string;
|
|
4343
|
+
|
|
4344
|
+
/**
|
|
4345
|
+
* The current state of the connection
|
|
4346
|
+
*/
|
|
4347
|
+
readonly readyState:
|
|
4348
|
+
| typeof WebSocket.CONNECTING
|
|
4349
|
+
| typeof WebSocket.OPEN
|
|
4350
|
+
| typeof WebSocket.CLOSING
|
|
4351
|
+
| typeof WebSocket.CLOSED;
|
|
4352
|
+
|
|
4353
|
+
/**
|
|
4354
|
+
* The number of bytes of data that have been queued using send() but not yet transmitted to the network
|
|
4355
|
+
*/
|
|
4356
|
+
readonly bufferedAmount: number;
|
|
4357
|
+
|
|
4358
|
+
/**
|
|
4359
|
+
* The protocol selected by the server
|
|
4360
|
+
*/
|
|
4361
|
+
readonly protocol: string;
|
|
4362
|
+
|
|
4363
|
+
/**
|
|
4364
|
+
* The extensions selected by the server
|
|
4365
|
+
*/
|
|
4366
|
+
readonly extensions: string;
|
|
4367
|
+
|
|
4368
|
+
/**
|
|
4369
|
+
* The type of binary data being received.
|
|
4370
|
+
*/
|
|
4371
|
+
binaryType: "arraybuffer" | "nodebuffer";
|
|
4372
|
+
|
|
4373
|
+
/**
|
|
4374
|
+
* Event handler for open event
|
|
4375
|
+
*/
|
|
4376
|
+
onopen: ((this: WebSocket, ev: Event) => any) | null;
|
|
4377
|
+
|
|
4378
|
+
/**
|
|
4379
|
+
* Event handler for message event
|
|
4380
|
+
*/
|
|
4381
|
+
onmessage: ((this: WebSocket, ev: MessageEvent) => any) | null;
|
|
4382
|
+
|
|
4383
|
+
/**
|
|
4384
|
+
* Event handler for error event
|
|
4385
|
+
*/
|
|
4386
|
+
onerror: ((this: WebSocket, ev: Event) => any) | null;
|
|
4387
|
+
|
|
4388
|
+
/**
|
|
4389
|
+
* Event handler for close event
|
|
4390
|
+
*/
|
|
4391
|
+
onclose: ((this: WebSocket, ev: CloseEvent) => any) | null;
|
|
4392
|
+
|
|
4393
|
+
/**
|
|
4394
|
+
* Transmits data to the server
|
|
4395
|
+
* @param data The data to send to the server
|
|
4396
|
+
*/
|
|
4397
|
+
send(data: string | ArrayBufferLike | ArrayBufferView): void;
|
|
4398
|
+
|
|
4399
|
+
/**
|
|
4400
|
+
* Closes the WebSocket connection
|
|
4401
|
+
* @param code A numeric value indicating the status code
|
|
4402
|
+
* @param reason A human-readable string explaining why the connection is closing
|
|
4403
|
+
*/
|
|
4404
|
+
close(code?: number, reason?: string): void;
|
|
4405
|
+
|
|
4406
|
+
/**
|
|
4407
|
+
* Sends a ping frame to the server
|
|
4408
|
+
* @param data Optional data to include in the ping frame
|
|
4409
|
+
*/
|
|
4410
|
+
ping(data?: string | ArrayBufferLike | ArrayBufferView): void;
|
|
4411
|
+
|
|
4412
|
+
/**
|
|
4413
|
+
* Sends a pong frame to the server
|
|
4414
|
+
* @param data Optional data to include in the pong frame
|
|
4415
|
+
*/
|
|
4416
|
+
pong(data?: string | ArrayBufferLike | ArrayBufferView): void;
|
|
4417
|
+
|
|
4418
|
+
/**
|
|
4419
|
+
* Immediately terminates the connection
|
|
4420
|
+
*/
|
|
4421
|
+
terminate(): void;
|
|
4422
|
+
|
|
4423
|
+
/**
|
|
4424
|
+
* Registers an event handler of a specific event type on the WebSocket.
|
|
4425
|
+
* @param type A case-sensitive string representing the event type to listen for
|
|
4426
|
+
* @param listener The function to be called when the event occurs
|
|
4427
|
+
* @param options An options object that specifies characteristics about the event listener
|
|
4428
|
+
*/
|
|
4429
|
+
addEventListener<K extends keyof WebSocketEventMap>(
|
|
4430
|
+
type: K,
|
|
4431
|
+
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
|
|
4432
|
+
options?: boolean | AddEventListenerOptions,
|
|
4433
|
+
): void;
|
|
4434
|
+
addEventListener(
|
|
4435
|
+
type: string,
|
|
4436
|
+
listener: EventListenerOrEventListenerObject,
|
|
4437
|
+
options?: boolean | AddEventListenerOptions,
|
|
4438
|
+
): void;
|
|
4439
|
+
|
|
4440
|
+
/**
|
|
4441
|
+
* Removes an event listener previously registered with addEventListener()
|
|
4442
|
+
* @param type A case-sensitive string representing the event type to remove
|
|
4443
|
+
* @param listener The function to remove from the event target
|
|
4444
|
+
* @param options An options object that specifies characteristics about the event listener
|
|
4445
|
+
*/
|
|
4446
|
+
removeEventListener<K extends keyof WebSocketEventMap>(
|
|
4447
|
+
type: K,
|
|
4448
|
+
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
|
|
4449
|
+
options?: boolean | EventListenerOptions,
|
|
4450
|
+
): void;
|
|
4451
|
+
removeEventListener(
|
|
4452
|
+
type: string,
|
|
4453
|
+
listener: EventListenerOrEventListenerObject,
|
|
4454
|
+
options?: boolean | EventListenerOptions,
|
|
4455
|
+
): void;
|
|
4456
|
+
|
|
4457
|
+
/** @deprecated Use instance property instead */
|
|
4458
|
+
readonly CONNECTING: 0;
|
|
4459
|
+
/** @deprecated Use instance property instead */
|
|
4460
|
+
readonly OPEN: 1;
|
|
4461
|
+
/** @deprecated Use instance property instead */
|
|
4462
|
+
readonly CLOSING: 2;
|
|
4463
|
+
/** @deprecated Use instance property instead */
|
|
4464
|
+
readonly CLOSED: 3;
|
|
4465
|
+
}
|
|
4466
|
+
|
|
4621
4467
|
/**
|
|
4622
4468
|
* Pretty-print an object the same as {@link console.log} to a `string`
|
|
4623
4469
|
*
|
|
@@ -5863,6 +5709,12 @@ declare module "bun" {
|
|
|
5863
5709
|
*/
|
|
5864
5710
|
shutdown(halfClose?: boolean): void;
|
|
5865
5711
|
|
|
5712
|
+
// -1 = detached
|
|
5713
|
+
// 0 = closed
|
|
5714
|
+
// 1 = open
|
|
5715
|
+
// -2 = closing
|
|
5716
|
+
// 2 = everything else
|
|
5717
|
+
// positive = open
|
|
5866
5718
|
readonly readyState: "open" | "closing" | "closed";
|
|
5867
5719
|
|
|
5868
5720
|
/**
|
|
@@ -6206,68 +6058,159 @@ declare module "bun" {
|
|
|
6206
6058
|
}
|
|
6207
6059
|
|
|
6208
6060
|
interface SocketOptions<Data = unknown> {
|
|
6061
|
+
/**
|
|
6062
|
+
* Handlers for socket events
|
|
6063
|
+
*/
|
|
6209
6064
|
socket: SocketHandler<Data>;
|
|
6065
|
+
/**
|
|
6066
|
+
* The per-instance data context
|
|
6067
|
+
*/
|
|
6210
6068
|
data?: Data;
|
|
6211
6069
|
}
|
|
6212
|
-
// interface TCPSocketOptions<Data = undefined> extends SocketOptions<Data> {
|
|
6213
|
-
// hostname: string;
|
|
6214
|
-
// port: number;
|
|
6215
|
-
// }
|
|
6216
6070
|
|
|
6217
6071
|
interface TCPSocketListenOptions<Data = undefined> extends SocketOptions<Data> {
|
|
6072
|
+
/**
|
|
6073
|
+
* The hostname to listen on
|
|
6074
|
+
*/
|
|
6218
6075
|
hostname: string;
|
|
6076
|
+
/**
|
|
6077
|
+
* The port to listen on
|
|
6078
|
+
*/
|
|
6219
6079
|
port: number;
|
|
6080
|
+
/**
|
|
6081
|
+
* The TLS configuration object with which to create the server
|
|
6082
|
+
*/
|
|
6220
6083
|
tls?: TLSOptions;
|
|
6084
|
+
/**
|
|
6085
|
+
* Whether to use exclusive mode.
|
|
6086
|
+
*
|
|
6087
|
+
* When set to `true`, the socket binds exclusively to the specified address:port
|
|
6088
|
+
* combination, preventing other processes from binding to the same port.
|
|
6089
|
+
*
|
|
6090
|
+
* When `false` (default), other sockets may be able to bind to the same port
|
|
6091
|
+
* depending on the operating system's socket sharing capabilities and settings.
|
|
6092
|
+
*
|
|
6093
|
+
* Exclusive mode is useful in scenarios where you want to ensure only one
|
|
6094
|
+
* instance of your server can bind to a specific port at a time.
|
|
6095
|
+
*
|
|
6096
|
+
* @default false
|
|
6097
|
+
*/
|
|
6221
6098
|
exclusive?: boolean;
|
|
6099
|
+
/**
|
|
6100
|
+
* Whether to allow half-open connections.
|
|
6101
|
+
*
|
|
6102
|
+
* A half-open connection occurs when one end of the connection has called `close()`
|
|
6103
|
+
* or sent a FIN packet, while the other end remains open. When set to `true`:
|
|
6104
|
+
*
|
|
6105
|
+
* - The socket won't automatically send FIN when the remote side closes its end
|
|
6106
|
+
* - The local side can continue sending data even after the remote side has closed
|
|
6107
|
+
* - The application must explicitly call `end()` to fully close the connection
|
|
6108
|
+
*
|
|
6109
|
+
* When `false` (default), the socket automatically closes both ends of the connection
|
|
6110
|
+
* when either side closes.
|
|
6111
|
+
*
|
|
6112
|
+
* @default false
|
|
6113
|
+
*/
|
|
6222
6114
|
allowHalfOpen?: boolean;
|
|
6223
6115
|
}
|
|
6224
6116
|
|
|
6225
6117
|
interface TCPSocketConnectOptions<Data = undefined> extends SocketOptions<Data> {
|
|
6118
|
+
/**
|
|
6119
|
+
* The hostname to connect to
|
|
6120
|
+
*/
|
|
6226
6121
|
hostname: string;
|
|
6122
|
+
/**
|
|
6123
|
+
* The port to connect to
|
|
6124
|
+
*/
|
|
6227
6125
|
port: number;
|
|
6126
|
+
/**
|
|
6127
|
+
* TLS Configuration with which to create the socket
|
|
6128
|
+
*/
|
|
6228
6129
|
tls?: boolean;
|
|
6130
|
+
/**
|
|
6131
|
+
* Whether to use exclusive mode.
|
|
6132
|
+
*
|
|
6133
|
+
* When set to `true`, the socket binds exclusively to the specified address:port
|
|
6134
|
+
* combination, preventing other processes from binding to the same port.
|
|
6135
|
+
*
|
|
6136
|
+
* When `false` (default), other sockets may be able to bind to the same port
|
|
6137
|
+
* depending on the operating system's socket sharing capabilities and settings.
|
|
6138
|
+
*
|
|
6139
|
+
* Exclusive mode is useful in scenarios where you want to ensure only one
|
|
6140
|
+
* instance of your server can bind to a specific port at a time.
|
|
6141
|
+
*
|
|
6142
|
+
* @default false
|
|
6143
|
+
*/
|
|
6229
6144
|
exclusive?: boolean;
|
|
6145
|
+
/**
|
|
6146
|
+
* Whether to allow half-open connections.
|
|
6147
|
+
*
|
|
6148
|
+
* A half-open connection occurs when one end of the connection has called `close()`
|
|
6149
|
+
* or sent a FIN packet, while the other end remains open. When set to `true`:
|
|
6150
|
+
*
|
|
6151
|
+
* - The socket won't automatically send FIN when the remote side closes its end
|
|
6152
|
+
* - The local side can continue sending data even after the remote side has closed
|
|
6153
|
+
* - The application must explicitly call `end()` to fully close the connection
|
|
6154
|
+
*
|
|
6155
|
+
* When `false` (default), the socket automatically closes both ends of the connection
|
|
6156
|
+
* when either side closes.
|
|
6157
|
+
*
|
|
6158
|
+
* @default false
|
|
6159
|
+
*/
|
|
6230
6160
|
allowHalfOpen?: boolean;
|
|
6231
6161
|
}
|
|
6232
6162
|
|
|
6233
6163
|
interface UnixSocketOptions<Data = undefined> extends SocketOptions<Data> {
|
|
6234
|
-
|
|
6164
|
+
/**
|
|
6165
|
+
* The unix socket to listen on or connect to
|
|
6166
|
+
*/
|
|
6235
6167
|
unix: string;
|
|
6168
|
+
/**
|
|
6169
|
+
* TLS Configuration with which to create the socket
|
|
6170
|
+
*/
|
|
6171
|
+
tls?: TLSOptions;
|
|
6236
6172
|
}
|
|
6237
6173
|
|
|
6238
6174
|
interface FdSocketOptions<Data = undefined> extends SocketOptions<Data> {
|
|
6175
|
+
/**
|
|
6176
|
+
* TLS Configuration with which to create the socket
|
|
6177
|
+
*/
|
|
6239
6178
|
tls?: TLSOptions;
|
|
6179
|
+
/**
|
|
6180
|
+
* The file descriptor to connect to
|
|
6181
|
+
*/
|
|
6240
6182
|
fd: number;
|
|
6241
6183
|
}
|
|
6242
6184
|
|
|
6243
6185
|
/**
|
|
6244
|
-
* Create a TCP client that connects to a server
|
|
6186
|
+
* Create a TCP client that connects to a server via a TCP socket
|
|
6245
6187
|
*
|
|
6246
|
-
* @
|
|
6247
|
-
* @param options.socket The socket handler to use
|
|
6248
|
-
* @param options.data The per-instance data context
|
|
6249
|
-
* @param options.hostname The hostname to connect to
|
|
6250
|
-
* @param options.port The port to connect to
|
|
6251
|
-
* @param options.tls The TLS configuration object
|
|
6252
|
-
* @param options.unix The unix socket to connect to
|
|
6188
|
+
* @category HTTP & Networking
|
|
6253
6189
|
*/
|
|
6254
6190
|
function connect<Data = undefined>(options: TCPSocketConnectOptions<Data>): Promise<Socket<Data>>;
|
|
6191
|
+
/**
|
|
6192
|
+
* Create a TCP client that connects to a server via a unix socket
|
|
6193
|
+
*
|
|
6194
|
+
* @category HTTP & Networking
|
|
6195
|
+
*/
|
|
6255
6196
|
function connect<Data = undefined>(options: UnixSocketOptions<Data>): Promise<Socket<Data>>;
|
|
6256
6197
|
|
|
6257
6198
|
/**
|
|
6258
6199
|
* Create a TCP server that listens on a port
|
|
6259
6200
|
*
|
|
6260
|
-
* @
|
|
6261
|
-
* @param options.socket The socket handler to use
|
|
6262
|
-
* @param options.data The per-instance data context
|
|
6263
|
-
* @param options.hostname The hostname to connect to
|
|
6264
|
-
* @param options.port The port to connect to
|
|
6265
|
-
* @param options.tls The TLS configuration object
|
|
6266
|
-
* @param options.unix The unix socket to connect to
|
|
6201
|
+
* @category HTTP & Networking
|
|
6267
6202
|
*/
|
|
6268
6203
|
function listen<Data = undefined>(options: TCPSocketListenOptions<Data>): TCPSocketListener<Data>;
|
|
6204
|
+
/**
|
|
6205
|
+
* Create a TCP server that listens on a unix socket
|
|
6206
|
+
*
|
|
6207
|
+
* @category HTTP & Networking
|
|
6208
|
+
*/
|
|
6269
6209
|
function listen<Data = undefined>(options: UnixSocketOptions<Data>): UnixSocketListener<Data>;
|
|
6270
6210
|
|
|
6211
|
+
/**
|
|
6212
|
+
* @category HTTP & Networking
|
|
6213
|
+
*/
|
|
6271
6214
|
namespace udp {
|
|
6272
6215
|
type Data = string | ArrayBufferView | ArrayBufferLike;
|
|
6273
6216
|
|
|
@@ -6345,6 +6288,8 @@ declare module "bun" {
|
|
|
6345
6288
|
* @param options.port The port to listen on
|
|
6346
6289
|
* @param options.binaryType The binary type to use for the socket
|
|
6347
6290
|
* @param options.connect The hostname and port to connect to
|
|
6291
|
+
*
|
|
6292
|
+
* @category HTTP & Networking
|
|
6348
6293
|
*/
|
|
6349
6294
|
export function udpSocket<DataBinaryType extends BinaryType = "buffer">(
|
|
6350
6295
|
options: udp.SocketOptions<DataBinaryType>,
|