bun-types 1.1.28-canary.20240912T140608 → 1.1.28-canary.20240914T140507

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.
Files changed (2) hide show
  1. package/ffi.d.ts +60 -0
  2. package/package.json +1 -1
package/ffi.d.ts CHANGED
@@ -601,6 +601,66 @@ declare module "bun:ffi" {
601
601
  symbols: Fns,
602
602
  ): Library<Fns>;
603
603
 
604
+ /**
605
+ * **Experimental:** Compile ISO C11 source code using TinyCC, and make {@link symbols} available as functions to JavaScript.
606
+ *
607
+ * @param options
608
+ * @returns Library<Fns>
609
+ *
610
+ * @example
611
+ * ## Hello, World!
612
+ *
613
+ * JavaScript:
614
+ * ```js
615
+ * import { cc } from "bun:ffi";
616
+ * import hello from "./hello.c" with {type: "file"};
617
+ * const {symbols: {hello}} = cc({
618
+ * source: hello,
619
+ * symbols: {
620
+ * hello: {
621
+ * returns: "cstring",
622
+ * args: [],
623
+ * },
624
+ * },
625
+ * });
626
+ * // "Hello, World!"
627
+ * console.log(hello());
628
+ * ```
629
+ *
630
+ * `./hello.c`:
631
+ * ```c
632
+ * #include <stdio.h>
633
+ * const char* hello() {
634
+ * return "Hello, World!";
635
+ * }
636
+ * ```
637
+ */
638
+ function cc<Fns extends Record<string, FFIFunction>>(options: {
639
+ /**
640
+ * File path to an ISO C11 source file to compile and link
641
+ */
642
+ source: string | import("bun").BunFile | URL;
643
+
644
+ /**
645
+ * Library names to link against
646
+ *
647
+ * Equivalent to `-l` option in gcc/clang.
648
+ */
649
+ library?: string[] | string;
650
+
651
+ /**
652
+ * Include directories to pass to the compiler
653
+ *
654
+ * Equivalent to `-I` option in gcc/clang.
655
+ */
656
+ include?: string[] | string;
657
+
658
+ /**
659
+ * Map of symbols to load where the key is the symbol name and the value is the {@link FFIFunction}
660
+ */
661
+ symbols: Fns;
662
+ }): Library<Fns>;
663
+
604
664
  /**
605
665
  * Turn a native library's function pointer into a JavaScript function
606
666
  *
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.28-canary.20240912T140608",
2
+ "version": "1.1.28-canary.20240914T140507",
3
3
  "name": "bun-types",
4
4
  "license": "MIT",
5
5
  "main": "",