mirror of
https://github.com/oven-sh/bun
synced 2026-02-17 22:32:06 +00:00
revert bun.zig
This commit is contained in:
436
src/bun.zig
436
src/bun.zig
@@ -3,193 +3,12 @@
|
||||
//!
|
||||
//! Prefer adding new code into a separate file and adding an import, or putting
|
||||
//! code in the relevant namespace.
|
||||
const std = @import("std");
|
||||
pub const OOM = std.mem.Allocator.Error;
|
||||
pub const getcwd = std.posix.getcwd;
|
||||
pub const ArenaAllocator = std.heap.ArenaAllocator;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub const Async = @import("async");
|
||||
/// Translated from `c-headers-for-zig.h` for the current platform.
|
||||
pub const c = @import("translated-c-headers");
|
||||
|
||||
pub const allocators = @import("./allocators.zig");
|
||||
pub const isSliceInBuffer = allocators.isSliceInBuffer;
|
||||
pub const isSliceInBufferT = allocators.isSliceInBufferT;
|
||||
pub const MaxHeapAllocator = @import("./allocators/max_heap_allocator.zig").MaxHeapAllocator;
|
||||
pub const MimallocArena = @import("./allocators/mimalloc_arena.zig").Arena;
|
||||
pub const NullableAllocator = @import("./allocators/NullableAllocator.zig");
|
||||
pub const Analytics = @import("./analytics/analytics_thread.zig");
|
||||
pub const analytics = @import("./analytics/analytics_thread.zig");
|
||||
pub const Schema = @import("./api/schema.zig");
|
||||
pub const StringPointer = Schema.Api.StringPointer;
|
||||
pub const OffsetList = @import("./baby_list.zig").OffsetList;
|
||||
pub const BabyList = @import("./baby_list.zig").BabyList;
|
||||
pub const base64 = @import("./base64/base64.zig");
|
||||
pub const bit_set = @import("./bit_set.zig");
|
||||
pub const BoringSSL = @import("./boringssl.zig");
|
||||
pub const brotli = @import("./brotli.zig");
|
||||
pub const spawn = @import("./bun.js/api/bun/spawn.zig").PosixSpawn;
|
||||
pub const server = @import("./bun.js/api/server.zig");
|
||||
pub const simdutf = @import("./bun.js/bindings/bun-simdutf.zig");
|
||||
pub const RegularExpression = @import("./bun.js/bindings/RegularExpression.zig").RegularExpression;
|
||||
pub const DirIterator = @import("./bun.js/node/dir_iterator.zig");
|
||||
pub const validators = @import("./bun.js/node/util/validators.zig");
|
||||
pub const UnboundedQueue = @import("./bun.js/unbounded_queue.zig").UnboundedQueue;
|
||||
pub const UUID = @import("./bun.js/uuid.zig");
|
||||
pub const bun_js = @import("./bun_js.zig");
|
||||
pub const bundle_v2 = @import("./bundler/bundle_v2.zig");
|
||||
pub const BundleV2 = bundle_v2.BundleV2;
|
||||
pub const ParseTask = bundle_v2.ParseTask;
|
||||
pub const Bunfig = @import("./bunfig.zig").Bunfig;
|
||||
pub const CLI = @import("./cli.zig");
|
||||
pub const RunCommand = @import("./cli/run_command.zig").RunCommand;
|
||||
/// Modified version of Zig's ComptimeStringMap
|
||||
pub const comptime_string_map = @import("./comptime_string_map.zig");
|
||||
pub const ComptimeStringMap = comptime_string_map.ComptimeStringMap;
|
||||
pub const ComptimeStringMap16 = comptime_string_map.ComptimeStringMap16;
|
||||
pub const ComptimeStringMapWithKeyType = comptime_string_map.ComptimeStringMapWithKeyType;
|
||||
const CopyFile = @import("./copy_file.zig");
|
||||
pub const copyFileErrnoConvert = CopyFile.copyFileErrorConvert;
|
||||
pub const copyFileRange = CopyFile.copyFileRange;
|
||||
pub const canUseCopyFileRangeSyscall = CopyFile.canUseCopyFileRangeSyscall;
|
||||
pub const disableCopyFileRangeSyscall = CopyFile.disableCopyFileRangeSyscall;
|
||||
pub const can_use_ioctl_ficlone = CopyFile.can_use_ioctl_ficlone;
|
||||
pub const disable_ioctl_ficlone = CopyFile.disable_ioctl_ficlone;
|
||||
pub const copyFile = CopyFile.copyFile;
|
||||
pub const copyFileWithState = CopyFile.copyFileWithState;
|
||||
pub const CopyFileState = CopyFile.CopyFileState;
|
||||
pub const csrf = @import("./csrf.zig");
|
||||
pub const css = @import("./css/css_parser.zig");
|
||||
pub const c_ares = @import("./deps/c_ares.zig");
|
||||
pub const libdeflate = @import("./deps/libdeflate.zig");
|
||||
pub const LOLHTML = @import("./deps/lol-html.zig");
|
||||
pub const picohttp = @import("./deps/picohttp.zig");
|
||||
pub const uws = @import("./deps/uws.zig");
|
||||
pub const clap = @import("./deps/zig-clap/clap.zig");
|
||||
pub const zstd = @import("./deps/zstd.zig");
|
||||
pub const dns = @import("./dns.zig");
|
||||
pub const DotEnv = @import("./env_loader.zig");
|
||||
pub const fmt = @import("./fmt.zig");
|
||||
pub const fs = @import("./fs.zig");
|
||||
pub const Futex = @import("./futex.zig");
|
||||
pub const glob = @import("./glob.zig");
|
||||
pub const Global = @import("./Global.zig");
|
||||
pub const heap_breakdown = @import("./heap_breakdown.zig");
|
||||
pub const highway = @import("./highway.zig");
|
||||
pub const HiveArray = @import("./hive_array.zig").HiveArray;
|
||||
pub const hmac = @import("./hmac.zig");
|
||||
pub const HTTPThread = @import("./http.zig").HTTPThread;
|
||||
pub const http = @import("./http.zig");
|
||||
pub const IdentityContext = @import("./identity_context.zig").IdentityContext;
|
||||
pub const ArrayIdentityContext = @import("./identity_context.zig").ArrayIdentityContext;
|
||||
pub const ImportRecord = @import("./import_record.zig").ImportRecord;
|
||||
pub const ImportKind = @import("./import_record.zig").ImportKind;
|
||||
pub const ini = @import("./ini.zig");
|
||||
pub const install = @import("./install/install.zig");
|
||||
pub const PackageManager = install.PackageManager;
|
||||
pub const io = @import("./io/io.zig");
|
||||
pub const JSAst = @import("./js_ast.zig");
|
||||
pub const js_lexer = @import("./js_lexer.zig");
|
||||
pub const js_parser = @import("./js_parser.zig");
|
||||
pub const js_printer = @import("./js_printer.zig");
|
||||
pub const JSON = @import("./json_parser.zig");
|
||||
pub const libarchive = @import("./libarchive/libarchive.zig");
|
||||
pub const LinearFifo = @import("./linear_fifo.zig").LinearFifo;
|
||||
pub const logger = @import("./logger.zig");
|
||||
pub const macho = @import("./macho.zig");
|
||||
pub const meta = @import("./meta.zig");
|
||||
pub const MultiArrayList = @import("./multi_array_list.zig").MultiArrayList;
|
||||
pub const Mutex = @import("./Mutex.zig");
|
||||
pub const options = @import("./options.zig");
|
||||
pub const Output = @import("./output.zig");
|
||||
pub const patch = @import("./patch.zig");
|
||||
pub const perf = @import("./perf.zig");
|
||||
pub const ObjectPool = @import("./pool.zig").ObjectPool;
|
||||
/// Copied from Zig std.Progress before 0.13 rewrite
|
||||
pub const Progress = @import("./Progress.zig");
|
||||
pub const renamer = @import("./renamer.zig");
|
||||
pub const PackageJSON = @import("./resolver/package_json.zig").PackageJSON;
|
||||
pub const path = @import("./resolver/resolve_path.zig");
|
||||
pub const resolver = @import("./resolver/resolver.zig");
|
||||
pub const S3 = @import("./s3/client.zig");
|
||||
pub const Semver = @import("./semver.zig");
|
||||
pub const sha = @import("./sha.zig");
|
||||
pub const shell = @import("./shell/shell.zig");
|
||||
pub const sourcemap = @import("./sourcemap/sourcemap.zig");
|
||||
pub const StandaloneModuleGraph = @import("./StandaloneModuleGraph.zig").StandaloneModuleGraph;
|
||||
pub const StringBuilder = @import("./string.zig").StringBuilder;
|
||||
const _string = @import("./string.zig");
|
||||
pub const String = _string.String;
|
||||
pub const StringJoiner = _string.StringJoiner;
|
||||
pub const SliceWithUnderlyingString = _string.SliceWithUnderlyingString;
|
||||
pub const PathString = _string.PathString;
|
||||
pub const HashedString = _string.HashedString;
|
||||
pub const MutableString = _string.MutableString;
|
||||
pub const ThreadPool = @import("./thread_pool.zig");
|
||||
pub const default_thread_stack_size = ThreadPool.default_thread_stack_size;
|
||||
pub const tls = @import("./tls.zig");
|
||||
pub const Tmpfile = @import("./tmp.zig").Tmpfile;
|
||||
pub const tracy = @import("./tracy.zig");
|
||||
pub const trace = tracy.trace;
|
||||
/// Copied from Zig std.trait
|
||||
pub const trait = @import("./trait.zig");
|
||||
pub const transpiler = @import("./transpiler.zig");
|
||||
pub const Transpiler = transpiler.Transpiler;
|
||||
pub const URL = @import("./url.zig").URL;
|
||||
pub const FormData = @import("./url.zig").FormData;
|
||||
pub const valkey = @import("./valkey/index.zig");
|
||||
pub const Watcher = @import("./Watcher.zig");
|
||||
pub const which = @import("./which.zig").which;
|
||||
pub const Wyhash11 = @import("./wyhash.zig").Wyhash11;
|
||||
pub const zlib = @import("./zlib.zig");
|
||||
pub const AllocationScope = @import("allocators/AllocationScope.zig");
|
||||
pub const MemoryReportingAllocator = @import("allocators/MemoryReportingAllocator.zig");
|
||||
pub const Mimalloc = @import("allocators/mimalloc.zig");
|
||||
pub const bake = @import("bake/bake.zig");
|
||||
pub const bits = @import("bits.zig");
|
||||
/// "api" in this context means "the Bun APIs", as in "the exposed JS APIs"
|
||||
pub const api = @import("bun.js/api.zig");
|
||||
/// All functions and interfaces provided from Bun's `bindgen` utility.
|
||||
pub const gen = @import("bun.js/bindings/GeneratedBindings.zig");
|
||||
/// Bindings to JavaScriptCore and other JavaScript primatives.
|
||||
/// Web and runtime-specific APIs should go in `webcore` and `api`.
|
||||
pub const jsc = @import("bun.js/jsc.zig");
|
||||
/// Deprecated: Prefer the lowercase `jsc` since it is a namespace and not a struct.
|
||||
pub const JSC = jsc;
|
||||
/// JavaScript Web APIs
|
||||
pub const webcore = @import("bun.js/webcore.zig");
|
||||
pub const crash_handler = @import("crash_handler.zig");
|
||||
pub const handleErrorReturnTrace = crash_handler.handleErrorReturnTrace;
|
||||
pub const darwin = @import("darwin.zig");
|
||||
pub const detectCI = @import("ci_info.zig").detectCI;
|
||||
pub const Environment = @import("env.zig");
|
||||
pub const FD = @import("fd.zig").FD;
|
||||
/// Deprecated: Use `FD` instead.
|
||||
pub const FileDescriptor = FD;
|
||||
/// Deprecated: Rename to use `FD` instead.
|
||||
pub const StoredFileDescriptorType = FileDescriptor;
|
||||
pub const FeatureFlags = @import("feature_flags.zig");
|
||||
pub const linux = @import("linux.zig");
|
||||
pub const ptr = @import("ptr.zig");
|
||||
pub const TaggedPointer = ptr.TaggedPointer;
|
||||
pub const TaggedPointerUnion = ptr.TaggedPointerUnion;
|
||||
pub const strings = @import("string_immutable.zig");
|
||||
pub const StringTypes = @import("string_types.zig");
|
||||
pub const stringZ = StringTypes.stringZ;
|
||||
pub const string = StringTypes.string;
|
||||
pub const CodePoint = StringTypes.CodePoint;
|
||||
/// Cross-platform system APIs
|
||||
pub const sys = @import("sys.zig");
|
||||
/// Deprecated: use bun.sys.S
|
||||
pub const S = sys.S;
|
||||
pub const O = sys.O;
|
||||
pub const Mode = sys.Mode;
|
||||
const global_scope_log = sys.syslog;
|
||||
pub const windows = @import("windows.zig");
|
||||
|
||||
const bun = @This();
|
||||
const builtin = @import("builtin");
|
||||
const std = @import("std");
|
||||
|
||||
pub const Environment = @import("env.zig");
|
||||
|
||||
pub const use_mimalloc = true;
|
||||
|
||||
pub const default_allocator: std.mem.Allocator = if (!use_mimalloc)
|
||||
@@ -294,6 +113,8 @@ pub inline fn namedAllocator(comptime name: [:0]const u8) std.mem.Allocator {
|
||||
return default_allocator;
|
||||
}
|
||||
|
||||
pub const OOM = std.mem.Allocator.Error;
|
||||
|
||||
pub const JSError = error{
|
||||
/// There is an active exception on the global object.
|
||||
/// You should almost never have to construct this manually.
|
||||
@@ -304,10 +125,41 @@ pub const JSError = error{
|
||||
|
||||
pub const JSOOM = OOM || JSError;
|
||||
|
||||
pub const detectCI = @import("ci_info.zig").detectCI;
|
||||
|
||||
/// Cross-platform system APIs
|
||||
pub const sys = @import("sys.zig");
|
||||
/// Deprecated: use bun.sys.S
|
||||
pub const S = sys.S;
|
||||
pub const O = sys.O;
|
||||
pub const Mode = sys.Mode;
|
||||
|
||||
// Platform-specific system APIs. If something can be implemented on multiple
|
||||
// platforms, it does not belong in these three namespaces.
|
||||
pub const windows = @import("windows.zig");
|
||||
pub const darwin = @import("darwin.zig");
|
||||
pub const linux = @import("linux.zig");
|
||||
|
||||
/// Translated from `c-headers-for-zig.h` for the current platform.
|
||||
pub const c = @import("translated-c-headers");
|
||||
|
||||
pub const sha = @import("./sha.zig");
|
||||
pub const FeatureFlags = @import("feature_flags.zig");
|
||||
pub const meta = @import("./meta.zig");
|
||||
pub const base64 = @import("./base64/base64.zig");
|
||||
pub const path = @import("./resolver/resolve_path.zig");
|
||||
pub const resolver = @import("./resolver/resolver.zig");
|
||||
pub const DirIterator = @import("./bun.js/node/dir_iterator.zig");
|
||||
pub const PackageJSON = @import("./resolver/package_json.zig").PackageJSON;
|
||||
pub const fmt = @import("./fmt.zig");
|
||||
pub const allocators = @import("./allocators.zig");
|
||||
pub const bun_js = @import("./bun_js.zig");
|
||||
|
||||
// This file is gennerated, but cant be placed in the build/debug/codegen
|
||||
// folder because zig will complain about outside-of-module stuff
|
||||
/// All functions and interfaces provided from Bun's `bindgen` utility.
|
||||
pub const gen = @import("bun.js/bindings/GeneratedBindings.zig");
|
||||
|
||||
comptime {
|
||||
// This file is gennerated, but cant be placed in the build/debug/codegen
|
||||
// folder because zig will complain about outside-of-module stuff
|
||||
@@ -315,9 +167,40 @@ comptime {
|
||||
_ = &gen; // reference bindings
|
||||
}
|
||||
|
||||
/// Copied from Zig std.trait
|
||||
pub const trait = @import("./trait.zig");
|
||||
/// Copied from Zig std.Progress before 0.13 rewrite
|
||||
pub const Progress = @import("./Progress.zig");
|
||||
/// Modified version of Zig's ComptimeStringMap
|
||||
pub const comptime_string_map = @import("./comptime_string_map.zig");
|
||||
pub const ComptimeStringMap = comptime_string_map.ComptimeStringMap;
|
||||
pub const ComptimeStringMap16 = comptime_string_map.ComptimeStringMap16;
|
||||
pub const ComptimeStringMapWithKeyType = comptime_string_map.ComptimeStringMapWithKeyType;
|
||||
|
||||
pub const glob = @import("./glob.zig");
|
||||
pub const patch = @import("./patch.zig");
|
||||
pub const ini = @import("./ini.zig");
|
||||
pub const bits = @import("bits.zig");
|
||||
pub const css = @import("./css/css_parser.zig");
|
||||
pub const csrf = @import("./csrf.zig");
|
||||
pub const validators = @import("./bun.js/node/util/validators.zig");
|
||||
|
||||
pub const shell = @import("./shell/shell.zig");
|
||||
|
||||
pub const Output = @import("./output.zig");
|
||||
pub const Global = @import("./Global.zig");
|
||||
|
||||
pub const FD = @import("fd.zig").FD;
|
||||
|
||||
/// Deprecated: Use `FD` instead.
|
||||
pub const FileDescriptor = FD;
|
||||
|
||||
// When we are on a computer with an absurdly high number of max open file handles
|
||||
// such is often the case with macOS
|
||||
// As a useful optimization, we can store file descriptors and just keep them open...forever
|
||||
/// Deprecated: Rename to use `FD` instead.
|
||||
pub const StoredFileDescriptorType = FileDescriptor;
|
||||
|
||||
/// Thin wrapper around iovec / libuv buffer
|
||||
/// This is used for readv/writev calls.
|
||||
pub const PlatformIOVec = if (Environment.isWindows)
|
||||
@@ -355,6 +238,13 @@ pub fn platformIOVecToSlice(iovec: PlatformIOVec) []u8 {
|
||||
return iovec.base[0..iovec.len];
|
||||
}
|
||||
|
||||
pub const libarchive = @import("./libarchive/libarchive.zig");
|
||||
|
||||
pub const StringTypes = @import("string_types.zig");
|
||||
pub const stringZ = StringTypes.stringZ;
|
||||
pub const string = StringTypes.string;
|
||||
pub const CodePoint = StringTypes.CodePoint;
|
||||
|
||||
pub const MAX_PATH_BYTES: usize = if (Environment.isWasm) 1024 else std.fs.max_path_bytes;
|
||||
pub const PathBuffer = [MAX_PATH_BYTES]u8;
|
||||
pub const WPathBuffer = [std.os.windows.PATH_MAX_WIDE]u16;
|
||||
@@ -453,6 +343,8 @@ pub fn span(pointer: anytype) Span(@TypeOf(pointer)) {
|
||||
}
|
||||
}
|
||||
|
||||
pub const IdentityContext = @import("./identity_context.zig").IdentityContext;
|
||||
pub const ArrayIdentityContext = @import("./identity_context.zig").ArrayIdentityContext;
|
||||
pub const StringHashMapUnowned = struct {
|
||||
pub const Key = struct {
|
||||
hash: u64,
|
||||
@@ -476,6 +368,8 @@ pub const StringHashMapUnowned = struct {
|
||||
}
|
||||
};
|
||||
};
|
||||
pub const OffsetList = @import("./baby_list.zig").OffsetList;
|
||||
pub const BabyList = @import("./baby_list.zig").BabyList;
|
||||
pub const ByteList = BabyList(u8);
|
||||
pub const OffsetByteList = OffsetList(u8);
|
||||
|
||||
@@ -535,6 +429,10 @@ pub fn clone(item: anytype, allocator: std.mem.Allocator) !@TypeOf(item) {
|
||||
return try allocator.dupe(Child, item);
|
||||
}
|
||||
|
||||
pub const StringBuilder = @import("./string.zig").StringBuilder;
|
||||
|
||||
pub const LinearFifo = @import("./linear_fifo.zig").LinearFifo;
|
||||
|
||||
/// hash a string
|
||||
pub fn hash(content: []const u8) u64 {
|
||||
return std.hash.Wyhash.hash(0, content);
|
||||
@@ -588,10 +486,14 @@ pub fn hash32(content: []const u8) u32 {
|
||||
return @as(u32, @truncate(res));
|
||||
}
|
||||
|
||||
pub const HiveArray = @import("./hive_array.zig").HiveArray;
|
||||
|
||||
pub fn csprng(bytes: []u8) void {
|
||||
_ = BoringSSL.c.RAND_bytes(bytes.ptr, bytes.len);
|
||||
}
|
||||
|
||||
pub const ObjectPool = @import("./pool.zig").ObjectPool;
|
||||
|
||||
pub fn assertNonBlocking(fd: anytype) void {
|
||||
assert((std.posix.fcntl(fd, std.posix.F.GETFL, 0) catch unreachable) & O.NONBLOCK != 0);
|
||||
}
|
||||
@@ -601,6 +503,7 @@ pub fn ensureNonBlocking(fd: anytype) void {
|
||||
_ = std.posix.fcntl(fd, std.posix.F.SETFL, current | O.NONBLOCK) catch 0;
|
||||
}
|
||||
|
||||
const global_scope_log = sys.syslog;
|
||||
pub fn isReadable(fd: FileDescriptor) PollFlag {
|
||||
if (comptime Environment.isWindows) {
|
||||
@panic("TODO on Windows");
|
||||
@@ -692,6 +595,16 @@ pub fn StringEnum(comptime Type: type, comptime Map: anytype, value: []const u8)
|
||||
return ComptimeStringMap(Type, Map).get(value);
|
||||
}
|
||||
|
||||
pub const Bunfig = @import("./bunfig.zig").Bunfig;
|
||||
|
||||
pub const HTTPThread = @import("./http.zig").HTTPThread;
|
||||
pub const http = @import("./http.zig");
|
||||
|
||||
pub const Analytics = @import("./analytics/analytics_thread.zig");
|
||||
|
||||
pub const TaggedPointer = ptr.TaggedPointer;
|
||||
pub const TaggedPointerUnion = ptr.TaggedPointerUnion;
|
||||
|
||||
pub fn onceUnsafe(comptime function: anytype, comptime ReturnType: type) ReturnType {
|
||||
const Result = struct {
|
||||
var value: ReturnType = undefined;
|
||||
@@ -719,6 +632,12 @@ pub fn isHeapMemory(memory: anytype) bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
pub const Mimalloc = @import("allocators/mimalloc.zig");
|
||||
pub const AllocationScope = @import("allocators/AllocationScope.zig");
|
||||
|
||||
pub const isSliceInBuffer = allocators.isSliceInBuffer;
|
||||
pub const isSliceInBufferT = allocators.isSliceInBufferT;
|
||||
|
||||
pub inline fn sliceInBuffer(stable: string, value: string) string {
|
||||
if (allocators.sliceRange(stable, value)) |_| {
|
||||
return value;
|
||||
@@ -744,6 +663,30 @@ pub fn rangeOfSliceInBuffer(slice: []const u8, buffer: []const u8) ?[2]u32 {
|
||||
// Please prefer `bun.FD.Optional.none` over this
|
||||
pub const invalid_fd: FileDescriptor = .invalid;
|
||||
|
||||
pub const simdutf = @import("./bun.js/bindings/bun-simdutf.zig");
|
||||
|
||||
/// Deprecated: Prefer the lowercase `jsc` since it is a namespace and not a struct.
|
||||
pub const JSC = jsc;
|
||||
|
||||
/// Bindings to JavaScriptCore and other JavaScript primatives.
|
||||
/// Web and runtime-specific APIs should go in `webcore` and `api`.
|
||||
pub const jsc = @import("bun.js/jsc.zig");
|
||||
/// JavaScript Web APIs
|
||||
pub const webcore = @import("bun.js/webcore.zig");
|
||||
/// "api" in this context means "the Bun APIs", as in "the exposed JS APIs"
|
||||
pub const api = @import("bun.js/api.zig");
|
||||
|
||||
pub const logger = @import("./logger.zig");
|
||||
pub const ThreadPool = @import("./thread_pool.zig");
|
||||
pub const default_thread_stack_size = ThreadPool.default_thread_stack_size;
|
||||
pub const picohttp = @import("./deps/picohttp.zig");
|
||||
pub const uws = @import("./deps/uws.zig");
|
||||
pub const BoringSSL = @import("./boringssl.zig");
|
||||
pub const LOLHTML = @import("./deps/lol-html.zig");
|
||||
pub const clap = @import("./deps/zig-clap/clap.zig");
|
||||
pub const analytics = @import("./analytics/analytics_thread.zig");
|
||||
pub const zlib = @import("./zlib.zig");
|
||||
|
||||
pub var start_time: i128 = 0;
|
||||
|
||||
pub fn openFileZ(pathZ: [:0]const u8, open_flags: std.fs.File.OpenFlags) !std.fs.File {
|
||||
@@ -828,6 +771,7 @@ pub fn openDirAbsoluteNotForDeletingOrRenaming(path_: []const u8) !std.fs.Dir {
|
||||
return fd.stdDir();
|
||||
}
|
||||
|
||||
pub const MimallocArena = @import("./allocators/mimalloc_arena.zig").Arena;
|
||||
pub fn getRuntimeFeatureFlag(comptime flag: [:0]const u8) bool {
|
||||
return struct {
|
||||
const state = enum(u8) { idk, disabled, enabled };
|
||||
@@ -1070,6 +1014,17 @@ pub fn U32HashMap(comptime Type: type) type {
|
||||
return std.HashMap(u32, Type, U32HashMapContext, std.hash_map.default_max_load_percentage);
|
||||
}
|
||||
|
||||
const CopyFile = @import("./copy_file.zig");
|
||||
pub const copyFileErrnoConvert = CopyFile.copyFileErrorConvert;
|
||||
pub const copyFileRange = CopyFile.copyFileRange;
|
||||
pub const canUseCopyFileRangeSyscall = CopyFile.canUseCopyFileRangeSyscall;
|
||||
pub const disableCopyFileRangeSyscall = CopyFile.disableCopyFileRangeSyscall;
|
||||
pub const can_use_ioctl_ficlone = CopyFile.can_use_ioctl_ficlone;
|
||||
pub const disable_ioctl_ficlone = CopyFile.disable_ioctl_ficlone;
|
||||
pub const copyFile = CopyFile.copyFile;
|
||||
pub const copyFileWithState = CopyFile.copyFileWithState;
|
||||
pub const CopyFileState = CopyFile.CopyFileState;
|
||||
|
||||
pub fn parseDouble(input: []const u8) !f64 {
|
||||
if (comptime Environment.isWasm) {
|
||||
return try std.fmt.parseFloat(f64, input);
|
||||
@@ -1221,6 +1176,23 @@ pub fn isMissingIOUring() bool {
|
||||
};
|
||||
}
|
||||
|
||||
pub const CLI = @import("./cli.zig");
|
||||
|
||||
pub const install = @import("./install/install.zig");
|
||||
pub const PackageManager = install.PackageManager;
|
||||
pub const RunCommand = @import("./cli/run_command.zig").RunCommand;
|
||||
|
||||
pub const fs = @import("./fs.zig");
|
||||
pub const Transpiler = transpiler.Transpiler;
|
||||
pub const transpiler = @import("./transpiler.zig");
|
||||
pub const which = @import("./which.zig").which;
|
||||
pub const js_parser = @import("./js_parser.zig");
|
||||
pub const js_printer = @import("./js_printer.zig");
|
||||
pub const js_lexer = @import("./js_lexer.zig");
|
||||
pub const JSON = @import("./json_parser.zig");
|
||||
pub const JSAst = @import("./js_ast.zig");
|
||||
pub const bit_set = @import("./bit_set.zig");
|
||||
|
||||
pub fn enumMap(comptime T: type, comptime args: anytype) (fn (T) [:0]const u8) {
|
||||
const Map = struct {
|
||||
const vargs = args;
|
||||
@@ -1256,6 +1228,10 @@ pub fn zero(comptime Type: type) Type {
|
||||
@memset(@as([*]u8, @ptrCast(&out))[0..out.len], 0);
|
||||
return @as(Type, @bitCast(out));
|
||||
}
|
||||
pub const c_ares = @import("./deps/c_ares.zig");
|
||||
pub const URL = @import("./url.zig").URL;
|
||||
pub const FormData = @import("./url.zig").FormData;
|
||||
|
||||
var needs_proc_self_workaround: bool = false;
|
||||
|
||||
/// TODO: move to bun.sys
|
||||
@@ -1274,6 +1250,8 @@ fn getFdPathViaCWD(fd: std.posix.fd_t, buf: *bun.PathBuffer) ![]u8 {
|
||||
return std.posix.getcwd(buf);
|
||||
}
|
||||
|
||||
pub const getcwd = std.posix.getcwd;
|
||||
|
||||
pub fn getcwdAlloc(allocator: std.mem.Allocator) ![:0]u8 {
|
||||
var temp: PathBuffer = undefined;
|
||||
const temp_slice = try getcwd(&temp);
|
||||
@@ -1456,6 +1434,12 @@ pub fn sliceTo(pointer: anytype, comptime end: std.meta.Elem(@TypeOf(pointer)))
|
||||
}
|
||||
}
|
||||
|
||||
pub const Semver = @import("./semver.zig");
|
||||
pub const ImportRecord = @import("./import_record.zig").ImportRecord;
|
||||
pub const ImportKind = @import("./import_record.zig").ImportKind;
|
||||
|
||||
pub const Watcher = @import("./Watcher.zig");
|
||||
|
||||
pub fn concat(comptime T: type, dest: []T, src: []const []const T) void {
|
||||
var remain = dest;
|
||||
for (src) |group| {
|
||||
@@ -1468,7 +1452,13 @@ pub const fast_debug_build_cmd = .None;
|
||||
pub const fast_debug_build_mode = fast_debug_build_cmd != .None and
|
||||
Environment.isDebug;
|
||||
|
||||
pub const MultiArrayList = @import("./multi_array_list.zig").MultiArrayList;
|
||||
pub const NullableAllocator = @import("./allocators/NullableAllocator.zig");
|
||||
|
||||
pub const renamer = @import("./renamer.zig");
|
||||
// TODO: Rename to SourceMap as this is a struct.
|
||||
pub const sourcemap = @import("./sourcemap/sourcemap.zig");
|
||||
|
||||
/// Attempt to coerce some value into a byte slice.
|
||||
pub fn asByteSlice(buffer: anytype) []const u8 {
|
||||
return switch (@TypeOf(buffer)) {
|
||||
@@ -1700,6 +1690,7 @@ pub fn reloadProcess(
|
||||
}
|
||||
pub var auto_reload_on_crash = false;
|
||||
|
||||
pub const options = @import("./options.zig");
|
||||
pub const StringSet = struct {
|
||||
map: Map,
|
||||
|
||||
@@ -1750,6 +1741,8 @@ pub const StringSet = struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub const Schema = @import("./api/schema.zig");
|
||||
|
||||
pub const StringMap = struct {
|
||||
map: Map,
|
||||
dupe_keys: bool = false,
|
||||
@@ -1825,6 +1818,14 @@ pub const StringMap = struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub const DotEnv = @import("./env_loader.zig");
|
||||
pub const bundle_v2 = @import("./bundler/bundle_v2.zig");
|
||||
pub const BundleV2 = bundle_v2.BundleV2;
|
||||
pub const ParseTask = bundle_v2.ParseTask;
|
||||
|
||||
pub const Mutex = @import("./Mutex.zig");
|
||||
pub const UnboundedQueue = @import("./bun.js/unbounded_queue.zig").UnboundedQueue;
|
||||
|
||||
pub fn threadlocalAllocator() std.mem.Allocator {
|
||||
if (comptime use_mimalloc) {
|
||||
return MimallocArena.getThreadlocalDefault();
|
||||
@@ -1870,6 +1871,11 @@ pub fn HiveRef(comptime T: type, comptime capacity: u16) type {
|
||||
};
|
||||
}
|
||||
|
||||
pub const MaxHeapAllocator = @import("./allocators/max_heap_allocator.zig").MaxHeapAllocator;
|
||||
|
||||
pub const tracy = @import("./tracy.zig");
|
||||
pub const trace = tracy.trace;
|
||||
|
||||
pub fn openFileForPath(file_path: [:0]const u8) !std.fs.File {
|
||||
if (Environment.isWindows)
|
||||
return std.fs.cwd().openFileZ(file_path, .{});
|
||||
@@ -1898,11 +1904,28 @@ pub fn openDirForPath(file_path: [:0]const u8) !std.fs.Dir {
|
||||
|
||||
pub const Generation = u16;
|
||||
|
||||
pub const zstd = @import("./deps/zstd.zig");
|
||||
pub const StringPointer = Schema.Api.StringPointer;
|
||||
pub const StandaloneModuleGraph = @import("./StandaloneModuleGraph.zig").StandaloneModuleGraph;
|
||||
|
||||
const _string = @import("./string.zig");
|
||||
pub const strings = @import("string_immutable.zig");
|
||||
pub const String = _string.String;
|
||||
pub const StringJoiner = _string.StringJoiner;
|
||||
pub const SliceWithUnderlyingString = _string.SliceWithUnderlyingString;
|
||||
pub const PathString = _string.PathString;
|
||||
pub const HashedString = _string.HashedString;
|
||||
pub const MutableString = _string.MutableString;
|
||||
|
||||
pub const WTF = struct {
|
||||
/// The String type from WebKit's WTF library.
|
||||
pub const StringImpl = _string.WTFStringImpl;
|
||||
};
|
||||
|
||||
pub const Wyhash11 = @import("./wyhash.zig").Wyhash11;
|
||||
|
||||
pub const RegularExpression = @import("./bun.js/bindings/RegularExpression.zig").RegularExpression;
|
||||
|
||||
const TODO_LOG = Output.scoped(.TODO, false);
|
||||
pub inline fn todo(src: std.builtin.SourceLocation, value: anytype) @TypeOf(value) {
|
||||
if (comptime Environment.allow_assert) {
|
||||
@@ -2024,6 +2047,8 @@ pub fn initArgv(allocator: std.mem.Allocator) !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const spawn = @import("./bun.js/api/bun/spawn.zig").PosixSpawn;
|
||||
|
||||
pub fn isRegularFile(mode: anytype) bool {
|
||||
return S.ISREG(@intCast(mode));
|
||||
}
|
||||
@@ -2125,6 +2150,8 @@ pub fn makePathW(dir: std.fs.Dir, sub_path: []const u16) !void {
|
||||
return makePath(dir, buf[0..buf_len]);
|
||||
}
|
||||
|
||||
pub const Async = @import("async");
|
||||
|
||||
/// This is a helper for writing path string literals that are compatible with Windows.
|
||||
/// Returns the string as-is on linux, on windows replace `/` with `\`
|
||||
pub inline fn pathLiteral(comptime literal: anytype) *const [literal.len:0]u8 {
|
||||
@@ -2447,6 +2474,8 @@ pub fn create(allocator: std.mem.Allocator, comptime T: type, t: T) *T {
|
||||
return pointer;
|
||||
}
|
||||
|
||||
pub const heap_breakdown = @import("./heap_breakdown.zig");
|
||||
|
||||
/// Globally-allocate a value on the heap. Must free with `bun.destroy`.
|
||||
/// Prefer this over `default_allocator.create`
|
||||
///
|
||||
@@ -2565,6 +2594,10 @@ pub fn deleteAllPoolsForThreadExit() void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const Tmpfile = @import("./tmp.zig").Tmpfile;
|
||||
|
||||
pub const io = @import("./io/io.zig");
|
||||
|
||||
const errno_map = errno_map: {
|
||||
var max_value = 0;
|
||||
for (std.enums.values(sys.SystemErrno)) |v|
|
||||
@@ -2603,6 +2636,8 @@ pub fn errnoToZigErr(err: anytype) anyerror {
|
||||
return error.Unexpected;
|
||||
}
|
||||
|
||||
pub const brotli = @import("./brotli.zig");
|
||||
|
||||
pub fn iterateDir(dir: std.fs.Dir) DirIterator.Iterator {
|
||||
return DirIterator.iterate(dir, .u8).iter;
|
||||
}
|
||||
@@ -2799,7 +2834,14 @@ pub fn SliceIterator(comptime T: type) type {
|
||||
};
|
||||
}
|
||||
|
||||
pub const Futex = @import("./futex.zig");
|
||||
|
||||
// TODO: migrate
|
||||
pub const ArenaAllocator = std.heap.ArenaAllocator;
|
||||
|
||||
pub const crash_handler = @import("crash_handler.zig");
|
||||
pub const handleErrorReturnTrace = crash_handler.handleErrorReturnTrace;
|
||||
|
||||
const assertion_failure_msg = "Internal assertion failure";
|
||||
noinline fn assertionFailure() noreturn {
|
||||
if (@inComptime()) {
|
||||
@@ -2954,6 +2996,8 @@ pub fn unsafeAssert(condition: bool) callconv(callconv_inline) void {
|
||||
unreachable; // ASSERTION FAILURE
|
||||
}
|
||||
|
||||
pub const dns = @import("./dns.zig");
|
||||
|
||||
pub fn getRoughTickCount() timespec {
|
||||
if (comptime Environment.isMac) {
|
||||
// https://opensource.apple.com/source/xnu/xnu-2782.30.5/libsyscall/wrappers/mach_approximate_time.c.auto.html
|
||||
@@ -3151,6 +3195,8 @@ pub const timespec = extern struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub const UUID = @import("./bun.js/uuid.zig");
|
||||
|
||||
/// An abstract number of element in a sequence. The sequence has a first element.
|
||||
/// This type should be used instead of integer because 2 contradicting traditions can
|
||||
/// call a first element '0' or '1' which makes integer type ambiguous.
|
||||
@@ -3213,6 +3259,11 @@ pub fn memmove(output: []u8, input: []const u8) void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const hmac = @import("./hmac.zig");
|
||||
pub const libdeflate = @import("./deps/libdeflate.zig");
|
||||
|
||||
pub const bake = @import("bake/bake.zig");
|
||||
|
||||
/// like std.enums.tagName, except it doesn't lose the sentinel value.
|
||||
pub fn tagName(comptime Enum: type, value: Enum) ?[:0]const u8 {
|
||||
return inline for (@typeInfo(Enum).@"enum".fields) |f| {
|
||||
@@ -3483,6 +3534,7 @@ pub inline fn writeAnyToHasher(hasher: anytype, thing: anytype) void {
|
||||
hasher.update(std.mem.asBytes(&thing));
|
||||
}
|
||||
|
||||
pub const perf = @import("./perf.zig");
|
||||
pub inline fn isComptimeKnown(x: anytype) bool {
|
||||
return comptime @typeInfo(@TypeOf(.{x})).@"struct".fields[0].is_comptime;
|
||||
}
|
||||
@@ -3571,6 +3623,11 @@ pub const WPathBufferPool = if (Environment.isWindows) PathBufferPoolT(bun.WPath
|
||||
};
|
||||
pub const OSPathBufferPool = if (Environment.isWindows) WPathBufferPool else PathBufferPool;
|
||||
|
||||
pub const S3 = @import("./s3/client.zig");
|
||||
pub const ptr = @import("ptr.zig");
|
||||
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
/// Memory is typically not decommitted immediately when freed.
|
||||
/// Sensitive information that's kept in memory can be read in various ways until the OS
|
||||
/// decommits it or the memory allocator reuses it for a new allocation.
|
||||
@@ -3580,6 +3637,13 @@ pub fn freeSensitive(allocator: std.mem.Allocator, slice: anytype) void {
|
||||
allocator.free(slice);
|
||||
}
|
||||
|
||||
pub const server = @import("./bun.js/api/server.zig");
|
||||
pub const macho = @import("./macho.zig");
|
||||
pub const valkey = @import("./valkey/index.zig");
|
||||
pub const highway = @import("./highway.zig");
|
||||
|
||||
pub const MemoryReportingAllocator = @import("allocators/MemoryReportingAllocator.zig");
|
||||
|
||||
pub fn move(dest: []u8, src: []const u8) void {
|
||||
if (comptime Environment.allow_assert) {
|
||||
if (src.len != dest.len) {
|
||||
|
||||
Reference in New Issue
Block a user