aboutsummaryrefslogtreecommitdiff
path: root/src/js/private.d.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/private.d.ts')
-rw-r--r--src/js/private.d.ts57
1 files changed, 55 insertions, 2 deletions
diff --git a/src/js/private.d.ts b/src/js/private.d.ts
index d59c6aad8..244187703 100644
--- a/src/js/private.d.ts
+++ b/src/js/private.d.ts
@@ -99,6 +99,7 @@ declare module "bun" {
var main: string;
var tty: Array<{ hasColors: boolean }>;
var FFI: any;
+ /** This version of fetch is untamperable */
var fetch: typeof globalThis.fetch;
}
@@ -137,6 +138,58 @@ declare interface Error {
code?: string;
}
-declare interface ImportMeta {
- primordials: {};
+/**
+ * Load an internal native module. To see implementation details, open ZigGlobalObject.cpp and cmd+f `static JSC_DEFINE_HOST_FUNCTION(functionLazyLoad`
+ *
+ * This is only valid in src/js/ as it is replaced with `globalThis[Symbol.for("Bun.lazy")]` at bundle time.
+ */
+function $lazy<T extends keyof BunLazyModules>(id: T): BunLazyModules[T];
+function $lazy(id: "createImportMeta", from: string): BunLazyModules[T];
+
+interface BunLazyModules {
+ /**
+ * Primordials is a dynamic object that contains builtin functions and values.
+ *
+ * like primordials.isPromise -> $isPromise, etc
+ * Also primordials.Bun -> $Bun, etc; untampered globals
+ *
+ * The implmentation of this is done using createBuiltin('(function (){ return @<name here>; })')
+ * Meaning you can crash bun if you try returning something like `getInternalField`
+ */
+ primordials: any;
+
+ "bun:jsc": Omit<typeof import("bun:jsc"), "jscDescribe" | "jscDescribeArray"> & {
+ describe: typeof import("bun:jsc").jscDescribe;
+ describeArray: typeof import("bun:jsc").jscDescribe;
+ };
+ "bun:stream": {
+ maybeReadMore: Function;
+ resume: Function;
+ emitReadable: Function;
+ onEofChunk: Function;
+ ReadableState: Function;
+ };
+ sqlite: any;
+ "vm": {
+ createContext: Function;
+ isContext: Function;
+ Script: typeof import("node:vm").Script;
+ runInNewContext: Function;
+ runInThisContext: Function;
+ };
+ /** typeof === 'undefined', but callable -> throws not implemented */
+ "masqueradesAsUndefined": (...args: any) => any;
+ pathToFileURL: typeof import("node:url").pathToFileURL;
+ fileURLToPath: typeof import("node:url").fileURLToPath;
+ noop: {
+ getterSetter: any;
+ function: any;
+ functionRegular: any;
+ callback: any;
+ };
+
+ // ReadableStream related
+ [1]: any;
+ [2]: any;
+ [4]: any;
}