bun-types 1.1.28-canary.20240917T140517 → 1.1.28-canary.20240919T140511

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 +57 -0
  2. package/package.json +1 -1
package/ffi.d.ts CHANGED
@@ -337,6 +337,9 @@ declare module "bun:ffi" {
337
337
  */
338
338
  u64_fast = 16,
339
339
  function = 17,
340
+
341
+ napi_env = 18,
342
+ napi_value = 19,
340
343
  }
341
344
 
342
345
  type Pointer = number & { __pointer__: null };
@@ -372,6 +375,8 @@ declare module "bun:ffi" {
372
375
  [FFIType.i64_fast]: number | bigint;
373
376
  [FFIType.u64_fast]: number | bigint;
374
377
  [FFIType.function]: Pointer | JSCallback; // cannot be null
378
+ [FFIType.napi_env]: unknown;
379
+ [FFIType.napi_value]: unknown;
375
380
  }
376
381
  interface FFITypeToReturnsType {
377
382
  [FFIType.char]: number;
@@ -404,6 +409,8 @@ declare module "bun:ffi" {
404
409
  [FFIType.i64_fast]: number | bigint;
405
410
  [FFIType.u64_fast]: number | bigint;
406
411
  [FFIType.function]: Pointer | null;
412
+ [FFIType.napi_env]: unknown;
413
+ [FFIType.napi_value]: unknown;
407
414
  }
408
415
  interface FFITypeStringToType {
409
416
  ["char"]: FFIType.char;
@@ -436,6 +443,8 @@ declare module "bun:ffi" {
436
443
  ["function"]: FFIType.pointer; // for now
437
444
  ["usize"]: FFIType.uint64_t; // for now
438
445
  ["callback"]: FFIType.pointer; // for now
446
+ ["napi_env"]: never;
447
+ ["napi_value"]: unknown;
439
448
  }
440
449
 
441
450
  type FFITypeOrString = FFIType | keyof FFITypeStringToType;
@@ -659,6 +668,54 @@ declare module "bun:ffi" {
659
668
  * Map of symbols to load where the key is the symbol name and the value is the {@link FFIFunction}
660
669
  */
661
670
  symbols: Fns;
671
+
672
+ /**
673
+ * Map of symbols to define where the key is the symbol name and the value is the symbol value
674
+ *
675
+ * Equivalent to `-D` option in gcc/clang.
676
+ *
677
+ * @example
678
+ * ```js
679
+ * import { cc } from "bun:ffi";
680
+ * const {symbols: {hello}} = cc({
681
+ * source: hello,
682
+ * define: {
683
+ * "NDEBUG": "1",
684
+ * },
685
+ * symbols: {
686
+ * hello: {
687
+ * returns: "cstring",
688
+ * args: [],
689
+ * },
690
+ * },
691
+ * });
692
+ * ```
693
+ */
694
+ define?: Record<string, string>;
695
+
696
+ /**
697
+ * Flags to pass to the compiler. Note: we do not make gurantees about which specific version of the compiler is used.
698
+ *
699
+ * @default "-std=c11 -Wl,--export-all-symbols -g -O2"
700
+ *
701
+ * This is useful for passing macOS frameworks to link against. Or if there are other options you want to pass to the compiler.
702
+ *
703
+ * @example
704
+ * ```js
705
+ * import { cc } from "bun:ffi";
706
+ * const {symbols: {hello}} = cc({
707
+ * source: hello,
708
+ * flags: ["-framework CoreFoundation", "-framework Security"],
709
+ * symbols: {
710
+ * hello: {
711
+ * returns: "cstring",
712
+ * args: [],
713
+ * },
714
+ * },
715
+ * });
716
+ * ```
717
+ */
718
+ flags?: string | string[];
662
719
  }): Library<Fns>;
663
720
 
664
721
  /**
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.28-canary.20240917T140517",
2
+ "version": "1.1.28-canary.20240919T140511",
3
3
  "name": "bun-types",
4
4
  "license": "MIT",
5
5
  "main": "",