aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js')
-rw-r--r--src/bun.js/api/JSBundler.zig4
-rw-r--r--src/bun.js/api/JSTranspiler.zig2
-rw-r--r--src/bun.js/api/bun.zig11
-rw-r--r--src/bun.js/api/bun/dns_resolver.zig15
-rw-r--r--src/bun.js/api/bun/spawn.zig2
-rw-r--r--src/bun.js/api/bun/subprocess.zig114
-rw-r--r--src/bun.js/api/ffi.zig6
-rw-r--r--src/bun.js/api/filesystem_router.zig2
-rw-r--r--src/bun.js/api/html_rewriter.zig8
-rw-r--r--src/bun.js/api/server.zig45
-rw-r--r--src/bun.js/base.zig12
-rw-r--r--src/bun.js/bindings/bindings.zig15
-rw-r--r--src/bun.js/bindings/headers.zig600
-rw-r--r--src/bun.js/config.zig2
-rw-r--r--src/bun.js/javascript.zig2
-rw-r--r--src/bun.js/module_loader.zig6
-rw-r--r--src/bun.js/node/dir_iterator.zig38
-rw-r--r--src/bun.js/node/node_fs.zig211
-rw-r--r--src/bun.js/node/node_os.zig21
-rw-r--r--src/bun.js/node/path_watcher.zig10
-rw-r--r--src/bun.js/node/syscall.zig487
-rw-r--r--src/bun.js/node/types.zig66
-rw-r--r--src/bun.js/rare_data.zig14
-rw-r--r--src/bun.js/test/jest.zig3
-rw-r--r--src/bun.js/test/snapshot.zig8
-rw-r--r--src/bun.js/webcore/blob.zig171
-rw-r--r--src/bun.js/webcore/body.zig3
-rw-r--r--src/bun.js/webcore/encoding.zig3
-rw-r--r--src/bun.js/webcore/request.zig5
-rw-r--r--src/bun.js/webcore/response.zig23
-rw-r--r--src/bun.js/webcore/streams.zig203
31 files changed, 1421 insertions, 691 deletions
diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig
index f5c3793ed..4a4d10f0f 100644
--- a/src/bun.js/api/JSBundler.zig
+++ b/src/bun.js/api/JSBundler.zig
@@ -1,6 +1,6 @@
const std = @import("std");
const Api = @import("../../api/schema.zig").Api;
-const http = @import("../../http.zig");
+const http = @import("../../bun_dev_http_server.zig");
const JavaScript = @import("../javascript.zig");
const QueryStringMap = @import("../../url.zig").QueryStringMap;
const CombinedScanner = @import("../../url.zig").CombinedScanner;
@@ -287,7 +287,7 @@ pub const JSBundler = struct {
defer dir.close();
var rootdir_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
- this.rootdir.appendSliceExact(try bun.getFdPath(dir.fd, &rootdir_buf)) catch unreachable;
+ this.rootdir.appendSliceExact(try bun.getFdPath(bun.toFD(dir.fd), &rootdir_buf)) catch unreachable;
}
if (try config.getArray(globalThis, "external")) |externals| {
diff --git a/src/bun.js/api/JSTranspiler.zig b/src/bun.js/api/JSTranspiler.zig
index c31354712..8cec025eb 100644
--- a/src/bun.js/api/JSTranspiler.zig
+++ b/src/bun.js/api/JSTranspiler.zig
@@ -1,6 +1,6 @@
const std = @import("std");
const Api = @import("../../api/schema.zig").Api;
-const http = @import("../../http.zig");
+const http = @import("../../bun_dev_http_server.zig");
const JavaScript = @import("../javascript.zig");
const QueryStringMap = @import("../../url.zig").QueryStringMap;
const CombinedScanner = @import("../../url.zig").CombinedScanner;
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig
index 71b065993..cf984c81a 100644
--- a/src/bun.js/api/bun.zig
+++ b/src/bun.js/api/bun.zig
@@ -179,7 +179,7 @@ const ServerEntryPoint = bun.bundler.ServerEntryPoint;
const js_printer = bun.js_printer;
const js_parser = bun.js_parser;
const js_ast = bun.JSAst;
-const http = @import("../../http.zig");
+const http = @import("../../bun_dev_http_server.zig");
const NodeFallbackModules = @import("../../node_fallbacks.zig");
const ImportKind = ast.ImportKind;
const Analytics = @import("../../analytics/analytics_thread.zig");
@@ -2738,6 +2738,11 @@ pub fn mmapFile(
globalThis: *JSC.JSGlobalObject,
callframe: *JSC.CallFrame,
) callconv(.C) JSC.JSValue {
+ if (comptime Environment.isWindows) {
+ globalThis.throwTODO("mmapFile is not supported on Windows");
+ return JSC.JSValue.zero;
+ }
+
const arguments_ = callframe.arguments(2);
var args = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments_.slice());
defer args.deinit();
@@ -2789,7 +2794,7 @@ pub fn mmapFile(
flags |= std.os.MAP.SHARED;
}
- const map = switch (JSC.Node.Syscall.mmapFile(buf_z, flags, map_size, offset)) {
+ const map = switch (bun.sys.mmapFile(buf_z, flags, map_size, offset)) {
.result => |map| map,
.err => |err| {
@@ -2800,7 +2805,7 @@ pub fn mmapFile(
return JSC.C.JSObjectMakeTypedArrayWithBytesNoCopy(globalThis, JSC.C.JSTypedArrayType.kJSTypedArrayTypeUint8Array, @as(?*anyopaque, @ptrCast(map.ptr)), map.len, struct {
pub fn x(ptr: ?*anyopaque, size: ?*anyopaque) callconv(.C) void {
- _ = JSC.Node.Syscall.munmap(@as([*]align(std.mem.page_size) u8, @ptrCast(@alignCast(ptr)))[0..@intFromPtr(size)]);
+ _ = bun.sys.munmap(@as([*]align(std.mem.page_size) u8, @ptrCast(@alignCast(ptr)))[0..@intFromPtr(size)]);
}
}.x, @as(?*anyopaque, @ptrFromInt(map.len)), null).?.value();
}
diff --git a/src/bun.js/api/bun/dns_resolver.zig b/src/bun.js/api/bun/dns_resolver.zig
index 5c9be467f..1a370cd60 100644
--- a/src/bun.js/api/bun/dns_resolver.zig
+++ b/src/bun.js/api/bun/dns_resolver.zig
@@ -225,6 +225,11 @@ pub fn addressToJS(
address: std.net.Address,
globalThis: *JSC.JSGlobalObject,
) JSC.JSValue {
+ if (comptime Environment.isWindows) {
+ globalThis.throwTODO("TODO: windows");
+ return .zero;
+ }
+
return addressToString(allocator, address).toValueGC(globalThis);
}
@@ -823,6 +828,10 @@ pub const GetAddrInfoRequest = struct {
query: GetAddrInfo,
pub fn run(this: *@This()) void {
+ if (comptime Environment.isWindows) {
+ bun.todo(@src(), {});
+ return;
+ }
const query = this.query;
defer bun.default_allocator.free(bun.constStrToU8(query.name));
var hints = query.options.toLibC();
@@ -842,7 +851,7 @@ pub const GetAddrInfoRequest = struct {
if (hints) |*hint| hint else null,
&addrinfo,
);
- JSC.Node.Syscall.syslog("getaddrinfo({s}, {d}) = {d} ({any})", .{
+ bun.sys.syslog("getaddrinfo({s}, {d}) = {d} ({any})", .{
query.name,
port,
err,
@@ -1043,7 +1052,7 @@ pub const DNSLookup = struct {
const error_value = brk: {
if (err == .ESERVFAIL) {
- break :brk JSC.Node.Syscall.Error.fromCode(std.c.getErrno(-1), .getaddrinfo).toJSC(globalThis);
+ break :brk bun.sys.Error.fromCode(bun.C.getErrno(-1), .getaddrinfo).toJSC(globalThis);
}
const error_value = globalThis.createErrorInstance("DNS lookup failed: {s}", .{err.label()});
error_value.put(
@@ -1435,7 +1444,7 @@ pub const DNSResolver = struct {
var poll_entry = this.polls.getOrPut(fd) catch unreachable;
if (!poll_entry.found_existing) {
- poll_entry.value_ptr.* = JSC.FilePoll.init(vm, fd, .{}, DNSResolver, this);
+ poll_entry.value_ptr.* = JSC.FilePoll.init(vm, bun.toFD(fd), .{}, DNSResolver, this);
}
var poll = poll_entry.value_ptr.*.?;
diff --git a/src/bun.js/api/bun/spawn.zig b/src/bun.js/api/bun/spawn.zig
index be354c7f0..e5678ec44 100644
--- a/src/bun.js/api/bun/spawn.zig
+++ b/src/bun.js/api/bun/spawn.zig
@@ -206,7 +206,7 @@ pub const PosixSpawn = struct {
envp,
);
if (comptime bun.Environment.allow_assert)
- JSC.Node.Syscall.syslog("posix_spawn({s}) = {d} ({d})", .{
+ bun.sys.syslog("posix_spawn({s}) = {d} ({d})", .{
path,
rc,
pid,
diff --git a/src/bun.js/api/bun/subprocess.zig b/src/bun.js/api/bun/subprocess.zig
index f2e33cf78..77cf3886e 100644
--- a/src/bun.js/api/bun/subprocess.zig
+++ b/src/bun.js/api/bun/subprocess.zig
@@ -23,7 +23,7 @@ pub const Subprocess = struct {
pid: std.os.pid_t,
// on macOS, this is nothing
// on linux, it's a pidfd
- pidfd: std.os.fd_t = std.math.maxInt(std.os.fd_t),
+ pidfd: if (Environment.isLinux) bun.FileDescriptor else u0 = std.math.maxInt(if (Environment.isLinux) bun.FileDescriptor else u0),
stdin: Writable,
stdout: Readable,
@@ -36,7 +36,7 @@ pub const Subprocess = struct {
exit_code: ?u8 = null,
signal_code: ?SignalCode = null,
- waitpid_err: ?JSC.Node.Syscall.Error = null,
+ waitpid_err: ?bun.sys.Error = null,
has_waitpid_task: bool = false,
notification_task: JSC.AnyTask = undefined,
@@ -210,7 +210,7 @@ pub const Subprocess = struct {
};
}
- pub fn onClose(this: *Readable, _: ?JSC.Node.Syscall.Error) void {
+ pub fn onClose(this: *Readable, _: ?bun.sys.Error) void {
this.* = .closed;
}
@@ -221,7 +221,7 @@ pub const Subprocess = struct {
pub fn close(this: *Readable) void {
switch (this.*) {
.fd => |fd| {
- _ = JSC.Node.Syscall.close(fd);
+ _ = bun.sys.close(fd);
},
.pipe => {
this.pipe.done();
@@ -233,7 +233,7 @@ pub const Subprocess = struct {
pub fn finalize(this: *Readable) void {
switch (this.*) {
.fd => |fd| {
- _ = JSC.Node.Syscall.close(fd);
+ _ = bun.sys.close(fd);
},
.pipe => {
if (this.pipe == .stream and this.pipe.stream.ptr == .File) {
@@ -355,7 +355,7 @@ pub const Subprocess = struct {
if (comptime Environment.isLinux) {
// should this be handled differently?
// this effectively shouldn't happen
- if (this.pidfd == std.math.maxInt(std.os.fd_t)) {
+ if (this.pidfd == bun.invalid_fd) {
return .{ .result = {} };
}
@@ -366,16 +366,16 @@ pub const Subprocess = struct {
const errno = std.os.linux.getErrno(rc);
// if the process was already killed don't throw
if (errno != .SRCH)
- return .{ .err = JSC.Node.Syscall.Error.fromCode(errno, .kill) };
+ return .{ .err = bun.sys.Error.fromCode(errno, .kill) };
}
} else {
const err = std.c.kill(this.pid, sig);
if (err != 0) {
- const errno = std.c.getErrno(err);
+ const errno = bun.C.getErrno(err);
// if the process was already killed don't throw
if (errno != .SRCH)
- return .{ .err = JSC.Node.Syscall.Error.fromCode(errno, .kill) };
+ return .{ .err = bun.sys.Error.fromCode(errno, .kill) };
}
}
@@ -394,9 +394,9 @@ pub const Subprocess = struct {
const pidfd = this.pidfd;
- this.pidfd = std.math.maxInt(std.os.fd_t);
+ this.pidfd = bun.invalid_fd;
- if (pidfd != std.math.maxInt(std.os.fd_t)) {
+ if (pidfd != bun.invalid_fd) {
_ = std.os.close(pidfd);
}
}
@@ -492,7 +492,7 @@ pub const Subprocess = struct {
}
while (to_write.len > 0) {
- switch (JSC.Node.Syscall.write(this.fd, to_write)) {
+ switch (bun.sys.write(this.fd, to_write)) {
.err => |e| {
if (e.isRetry()) {
log("write({d}) retry", .{
@@ -546,7 +546,7 @@ pub const Subprocess = struct {
}
if (this.fd != bun.invalid_fd) {
- _ = JSC.Node.Syscall.close(this.fd);
+ _ = bun.sys.close(this.fd);
this.fd = bun.invalid_fd;
}
}
@@ -576,7 +576,7 @@ pub const Subprocess = struct {
pub const Status = union(enum) {
pending: void,
done: void,
- err: JSC.Node.Syscall.Error,
+ err: bun.sys.Error,
};
pub fn init(fd: bun.FileDescriptor) BufferedOutput {
@@ -619,7 +619,7 @@ pub const Subprocess = struct {
if (err == .Error) {
this.status = .{ .err = err.Error };
} else {
- this.status = .{ .err = JSC.Node.Syscall.Error.fromCode(.CANCELED, .read) };
+ this.status = .{ .err = bun.sys.Error.fromCode(.CANCELED, .read) };
}
this.fifo.close();
@@ -838,7 +838,7 @@ pub const Subprocess = struct {
// When the stream has closed we need to be notified to prevent a use-after-free
// We can test for this use-after-free by enabling hot module reloading on a file and then saving it twice
- pub fn onClose(this: *Writable, _: ?JSC.Node.Syscall.Error) void {
+ pub fn onClose(this: *Writable, _: ?bun.sys.Error) void {
this.* = .{
.ignore = {},
};
@@ -916,7 +916,7 @@ pub const Subprocess = struct {
_ = pipe_to_readable_stream.pipe.end(null);
},
.fd => |fd| {
- _ = JSC.Node.Syscall.close(fd);
+ _ = bun.sys.close(fd);
this.* = .{ .ignore = {} };
},
.buffered_input => {
@@ -934,7 +934,7 @@ pub const Subprocess = struct {
_ = pipe_to_readable_stream.pipe.end(null);
},
.fd => |fd| {
- _ = JSC.Node.Syscall.close(fd);
+ _ = bun.sys.close(fd);
this.* = .{ .ignore = {} };
},
.buffered_input => {
@@ -1035,6 +1035,11 @@ pub const Subprocess = struct {
secondaryArgsValue: ?JSValue,
comptime is_sync: bool,
) JSValue {
+ if (comptime Environment.isWindows) {
+ globalThis.throwTODO("spawn() is not yet implemented on Windows");
+ return .zero;
+ }
+
var arena = @import("root").bun.ArenaAllocator.init(bun.default_allocator);
defer arena.deinit();
var allocator = arena.allocator();
@@ -1204,7 +1209,7 @@ pub const Subprocess = struct {
if (stdio_val.jsType().isArray()) {
var stdio_iter = stdio_val.arrayIterator(globalThis);
stdio_iter.len = @min(stdio_iter.len, 3);
- var i: usize = 0;
+ var i: u32 = 0;
while (stdio_iter.next()) |value| : (i += 1) {
if (!extractStdio(globalThis, i, value, &stdio))
return JSC.JSValue.jsUndefined();
@@ -1216,17 +1221,17 @@ pub const Subprocess = struct {
}
} else {
if (args.get(globalThis, "stdin")) |value| {
- if (!extractStdio(globalThis, std.os.STDIN_FILENO, value, &stdio))
+ if (!extractStdio(globalThis, bun.STDIN_FD, value, &stdio))
return .zero;
}
if (args.get(globalThis, "stderr")) |value| {
- if (!extractStdio(globalThis, std.os.STDERR_FILENO, value, &stdio))
+ if (!extractStdio(globalThis, bun.STDERR_FD, value, &stdio))
return .zero;
}
if (args.get(globalThis, "stdout")) |value| {
- if (!extractStdio(globalThis, std.os.STDOUT_FILENO, value, &stdio))
+ if (!extractStdio(globalThis, bun.STDOUT_FD, value, &stdio))
return .zero;
}
}
@@ -1282,19 +1287,19 @@ pub const Subprocess = struct {
stdio[0].setUpChildIoPosixSpawn(
&actions,
stdin_pipe,
- std.os.STDIN_FILENO,
+ bun.STDIN_FD,
) catch |err| return globalThis.handleError(err, "in configuring child stdin");
stdio[1].setUpChildIoPosixSpawn(
&actions,
stdout_pipe,
- std.os.STDOUT_FILENO,
+ bun.STDOUT_FD,
) catch |err| return globalThis.handleError(err, "in configuring child stdout");
stdio[2].setUpChildIoPosixSpawn(
&actions,
stderr_pipe,
- std.os.STDERR_FILENO,
+ bun.STDERR_FD,
) catch |err| return globalThis.handleError(err, "in configuring child stderr");
actions.chdir(cwd) catch |err| return globalThis.handleError(err, "in chdir()");
@@ -1313,15 +1318,15 @@ pub const Subprocess = struct {
const pid = brk: {
defer {
if (stdio[0].isPiped()) {
- _ = JSC.Node.Syscall.close(stdin_pipe[0]);
+ _ = bun.sys.close(stdin_pipe[0]);
}
if (stdio[1].isPiped()) {
- _ = JSC.Node.Syscall.close(stdout_pipe[1]);
+ _ = bun.sys.close(stdout_pipe[1]);
}
if (stdio[2].isPiped()) {
- _ = JSC.Node.Syscall.close(stderr_pipe[1]);
+ _ = bun.sys.close(stderr_pipe[1]);
}
}
@@ -1332,8 +1337,8 @@ pub const Subprocess = struct {
};
const pidfd: std.os.fd_t = brk: {
- if (Environment.isMac) {
- break :brk @as(std.os.fd_t, @intCast(pid));
+ if (!Environment.isLinux) {
+ break :brk pid;
}
const kernel = @import("../../../analytics.zig").GenerateHeader.GeneratePlatform.kernelVersion();
@@ -1352,7 +1357,7 @@ pub const Subprocess = struct {
switch (std.os.linux.getErrno(fd)) {
.SUCCESS => break :brk @as(std.os.fd_t, @intCast(fd)),
else => |err| {
- globalThis.throwValue(JSC.Node.Syscall.Error.fromCode(err, .open).toJSC(globalThis));
+ globalThis.throwValue(bun.sys.Error.fromCode(err, .open).toJSC(globalThis));
var status: u32 = 0;
// ensure we don't leak the child process on error
_ = std.os.linux.waitpid(pid, &status, 0);
@@ -1370,14 +1375,14 @@ pub const Subprocess = struct {
subprocess.* = Subprocess{
.globalThis = globalThis,
.pid = pid,
- .pidfd = pidfd,
- .stdin = Writable.init(stdio[std.os.STDIN_FILENO], stdin_pipe[1], globalThis) catch {
+ .pidfd = @truncate(pidfd),
+ .stdin = Writable.init(stdio[bun.STDIN_FD], stdin_pipe[1], globalThis) catch {
globalThis.throw("out of memory", .{});
return .zero;
},
// stdout and stderr only uses allocator and default_max_buffer_size if they are pipes and not a array buffer
- .stdout = Readable.init(stdio[std.os.STDOUT_FILENO], stdout_pipe[0], jsc_vm.allocator, default_max_buffer_size),
- .stderr = Readable.init(stdio[std.os.STDERR_FILENO], stderr_pipe[0], jsc_vm.allocator, default_max_buffer_size),
+ .stdout = Readable.init(stdio[bun.STDOUT_FD], stdout_pipe[0], jsc_vm.allocator, default_max_buffer_size),
+ .stderr = Readable.init(stdio[bun.STDERR_FD], stderr_pipe[0], jsc_vm.allocator, default_max_buffer_size),
.on_exit_callback = if (on_exit_callback != .zero) JSC.Strong.create(on_exit_callback, globalThis) else .{},
.is_sync = is_sync,
};
@@ -1393,9 +1398,10 @@ pub const Subprocess = struct {
subprocess.this_jsvalue = out;
var send_exit_notification = false;
+ const watchfd = if (comptime Environment.isLinux) pidfd else pid;
if (comptime !is_sync) {
- var poll = JSC.FilePoll.init(jsc_vm, pidfd, .{}, Subprocess, subprocess);
+ var poll = JSC.FilePoll.init(jsc_vm, watchfd, .{}, Subprocess, subprocess);
subprocess.poll_ref = poll;
switch (subprocess.poll_ref.?.register(
jsc_vm.uws_event_loop.?,
@@ -1458,7 +1464,7 @@ pub const Subprocess = struct {
subprocess.closeIO(.stdin);
{
- var poll = JSC.FilePoll.init(jsc_vm, pidfd, .{}, Subprocess, subprocess);
+ var poll = JSC.FilePoll.init(jsc_vm, watchfd, .{}, Subprocess, subprocess);
subprocess.poll_ref = poll;
switch (subprocess.poll_ref.?.register(
jsc_vm.uws_event_loop.?,
@@ -1680,7 +1686,7 @@ pub const Subprocess = struct {
try actions.dup2(fd, std_fileno);
},
.path => |pathlike| {
- const flag = if (std_fileno == std.os.STDIN_FILENO) @as(u32, os.O.RDONLY) else @as(u32, std.os.O.WRONLY);
+ const flag = if (std_fileno == bun.STDIN_FD) @as(u32, os.O.RDONLY) else @as(u32, std.os.O.WRONLY);
try actions.open(std_fileno, pathlike.slice(), flag | std.os.O.CREAT, 0o664);
},
.inherit => {
@@ -1692,7 +1698,7 @@ pub const Subprocess = struct {
},
.ignore => {
- const flag = if (std_fileno == std.os.STDIN_FILENO) @as(u32, os.O.RDONLY) else @as(u32, std.os.O.WRONLY);
+ const flag = if (std_fileno == bun.STDIN_FD) @as(u32, os.O.RDONLY) else @as(u32, std.os.O.WRONLY);
try actions.openZ(std_fileno, "/dev/null", flag, 0o664);
},
}
@@ -1702,25 +1708,27 @@ pub const Subprocess = struct {
fn extractStdioBlob(
globalThis: *JSC.JSGlobalObject,
blob: JSC.WebCore.AnyBlob,
- i: usize,
+ i: u32,
stdio_array: []Stdio,
) bool {
+ const fd = bun.stdio(i);
+
if (blob.needsToReadFile()) {
if (blob.store()) |store| {
if (store.data.file.pathlike == .fd) {
- if (store.data.file.pathlike.fd == @as(bun.FileDescriptor, @intCast(i))) {
+ if (store.data.file.pathlike.fd == fd) {
stdio_array[i] = Stdio{ .inherit = {} };
} else {
- switch (@as(std.os.fd_t, @intCast(i))) {
- std.os.STDIN_FILENO => {
- if (i == std.os.STDERR_FILENO or i == std.os.STDOUT_FILENO) {
+ switch (bun.FDTag.get(i)) {
+ .stdin => {
+ if (i == 1 or i == 2) {
globalThis.throwInvalidArguments("stdin cannot be used for stdout or stderr", .{});
return false;
}
},
- std.os.STDOUT_FILENO, std.os.STDERR_FILENO => {
- if (i == std.os.STDIN_FILENO) {
+ .stdout, .stderr => {
+ if (i == 0) {
globalThis.throwInvalidArguments("stdout and stderr cannot be used for stdin", .{});
return false;
}
@@ -1745,7 +1753,7 @@ pub const Subprocess = struct {
fn extractStdio(
globalThis: *JSC.JSGlobalObject,
- i: usize,
+ i: u32,
value: JSValue,
stdio_array: []Stdio,
) bool {
@@ -1776,16 +1784,16 @@ pub const Subprocess = struct {
const fd = @as(bun.FileDescriptor, @intCast(fd_));
- switch (@as(std.os.fd_t, @intCast(i))) {
- std.os.STDIN_FILENO => {
- if (i == std.os.STDERR_FILENO or i == std.os.STDOUT_FILENO) {
+ switch (bun.FDTag.get(fd)) {
+ .stdin => {
+ if (i == bun.STDERR_FD or i == bun.STDOUT_FD) {
globalThis.throwInvalidArguments("stdin cannot be used for stdout or stderr", .{});
return false;
}
},
- std.os.STDOUT_FILENO, std.os.STDERR_FILENO => {
- if (i == std.os.STDIN_FILENO) {
+ .stdout, .stderr => {
+ if (i == bun.STDIN_FD) {
globalThis.throwInvalidArguments("stdout and stderr cannot be used for stdin", .{});
return false;
}
@@ -1806,7 +1814,7 @@ pub const Subprocess = struct {
return extractStdioBlob(globalThis, req.getBodyValue().useAsAnyBlob(), i, stdio_array);
} else if (JSC.WebCore.ReadableStream.fromJS(value, globalThis)) |req_const| {
var req = req_const;
- if (i == std.os.STDIN_FILENO) {
+ if (i == bun.STDIN_FD) {
if (req.toAnyBlob(globalThis)) |blob| {
return extractStdioBlob(globalThis, blob, i, stdio_array);
}
diff --git a/src/bun.js/api/ffi.zig b/src/bun.js/api/ffi.zig
index 1b265af11..097b66d35 100644
--- a/src/bun.js/api/ffi.zig
+++ b/src/bun.js/api/ffi.zig
@@ -25,7 +25,7 @@ const ServerEntryPoint = bun.bundler.ServerEntryPoint;
const js_printer = bun.js_printer;
const js_parser = bun.js_parser;
const js_ast = bun.JSAst;
-const http = @import("../../http.zig");
+const http = @import("../../bun_dev_http_server.zig");
const NodeFallbackModules = @import("../../node_fallbacks.zig");
const ImportKind = ast.ImportKind;
const Analytics = @import("../../analytics/analytics_thread.zig");
@@ -722,7 +722,7 @@ pub const FFI = struct {
var runtime_path = std.fs.path.join(default_allocator, &[_]string{ dir, "FFI.h" }) catch unreachable;
const file = std.fs.openFileAbsolute(runtime_path, .{}) catch @panic("Missing bun/src/bun.js/api/FFI.h.");
defer file.close();
- return file.readToEndAlloc(default_allocator, (file.stat() catch unreachable).size) catch unreachable;
+ return file.readToEndAlloc(default_allocator, file.getEndPos() catch unreachable) catch unreachable;
} else {
return FFI_HEADER;
}
@@ -937,7 +937,7 @@ pub const FFI = struct {
var ffi_wrapper = Bun__createFFICallbackFunction(js_context, js_function);
try this.printCallbackSourceCode(js_context, ffi_wrapper, &source_code_writer);
- if (comptime Environment.allow_assert) {
+ if (comptime Environment.allow_assert and Environment.isPosix) {
debug_write: {
const fd = std.os.open("/tmp/bun-ffi-callback-source.c", std.os.O.WRONLY | std.os.O.CREAT, 0o644) catch break :debug_write;
_ = std.os.write(fd, source_code.items) catch break :debug_write;
diff --git a/src/bun.js/api/filesystem_router.zig b/src/bun.js/api/filesystem_router.zig
index c15826c31..f33066298 100644
--- a/src/bun.js/api/filesystem_router.zig
+++ b/src/bun.js/api/filesystem_router.zig
@@ -1,6 +1,6 @@
const std = @import("std");
const Api = @import("../../api/schema.zig").Api;
-const http = @import("../../http.zig");
+const http = @import("../../bun_dev_http_server.zig");
const JavaScript = @import("../javascript.zig");
const QueryStringMap = @import("../../url.zig").QueryStringMap;
const CombinedScanner = @import("../../url.zig").CombinedScanner;
diff --git a/src/bun.js/api/html_rewriter.zig b/src/bun.js/api/html_rewriter.zig
index fd0b5dd9e..86c2c4b53 100644
--- a/src/bun.js/api/html_rewriter.zig
+++ b/src/bun.js/api/html_rewriter.zig
@@ -199,7 +199,7 @@ pub const HTMLRewriter = struct {
this.finalized = true;
}
- pub fn fail(this: *HTMLRewriterLoader, err: JSC.Node.Syscall.Error) void {
+ pub fn fail(this: *HTMLRewriterLoader, err: bun.sys.Error) void {
this.signal.close(err);
this.output.end(err);
this.failed = true;
@@ -213,7 +213,7 @@ pub const HTMLRewriter = struct {
pub fn writeToDestination(this: *HTMLRewriterLoader, bytes: []const u8) void {
if (this.backpressure.count > 0) {
this.backpressure.write(bytes) catch {
- this.fail(JSC.Node.Syscall.Error.oom);
+ this.fail(bun.sys.Error.oom);
this.finalize();
};
return;
@@ -287,9 +287,9 @@ pub const HTMLRewriter = struct {
return JSC.WebCore.Sink.init(this);
}
- fn writeBytes(this: *HTMLRewriterLoader, bytes: bun.ByteList, comptime deinit_: bool) ?JSC.Node.Syscall.Error {
+ fn writeBytes(this: *HTMLRewriterLoader, bytes: bun.ByteList, comptime deinit_: bool) ?bun.sys.Error {
this.rewriter.write(bytes.slice()) catch {
- return JSC.Node.Syscall.Error{
+ return bun.sys.Error{
.errno = 1,
// TODO: make this a union
.path = bun.default_allocator.dupe(u8, LOLHTML.HTMLString.lastError().slice()) catch unreachable,
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig
index 01f06ebf2..ffe24f0f6 100644
--- a/src/bun.js/api/server.zig
+++ b/src/bun.js/api/server.zig
@@ -24,7 +24,7 @@ const ServerEntryPoint = bun.bundler.ServerEntryPoint;
const js_printer = bun.js_printer;
const js_parser = bun.js_parser;
const js_ast = bun.JSAst;
-const http = @import("../../http.zig");
+const http = @import("../../bun_dev_http_server.zig");
const NodeFallbackModules = @import("../../node_fallbacks.zig");
const ImportKind = ast.ImportKind;
const Analytics = @import("../../analytics/analytics_thread.zig");
@@ -80,7 +80,7 @@ const Blob = JSC.WebCore.Blob;
const BoringSSL = @import("root").bun.BoringSSL;
const Arena = @import("../../mimalloc_arena.zig").Arena;
const SendfileContext = struct {
- fd: i32,
+ fd: bun.FileDescriptor,
socket_fd: i32 = 0,
remain: Blob.SizeType = 0,
offset: Blob.SizeType = 0,
@@ -1182,7 +1182,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
defer_deinit_until_callback_completes: ?*bool = null,
// TODO: support builtin compression
- const can_sendfile = !ssl_enabled;
+ // TODO: Use TransmitFile on Windows
+ const can_sendfile = !ssl_enabled and !bun.Environment.isWindows;
pub inline fn isAsync(this: *const RequestContext) bool {
return this.defer_deinit_until_callback_completes == null;
@@ -1744,7 +1745,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
// use node syscall so that we don't segfault on BADF
if (this.sendfile.auto_close)
- _ = JSC.Node.Syscall.close(this.sendfile.fd);
+ _ = bun.sys.close(this.sendfile.fd);
this.sendfile = undefined;
this.finalize();
}
@@ -1837,8 +1838,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
return true;
}
- pub fn sendWritableBytesForBlob(this: *RequestContext, bytes_: []const u8, write_offset: c_ulong, resp: *App.Response) bool {
+ pub fn sendWritableBytesForBlob(this: *RequestContext, bytes_: []const u8, write_offset_: c_ulong, resp: *App.Response) bool {
std.debug.assert(this.resp == resp);
+ const write_offset: usize = write_offset_;
var bytes = bytes_[@min(bytes_.len, @as(usize, @truncate(write_offset)))..];
if (resp.tryEnd(bytes, bytes_.len, this.shouldCloseConnection())) {
@@ -1851,7 +1853,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
}
- pub fn sendWritableBytesForCompleteResponseBuffer(this: *RequestContext, bytes_: []const u8, write_offset: c_ulong, resp: *App.Response) bool {
+ pub fn sendWritableBytesForCompleteResponseBuffer(this: *RequestContext, bytes_: []const u8, write_offset_: c_ulong, resp: *App.Response) bool {
+ const write_offset: usize = write_offset_;
std.debug.assert(this.resp == resp);
var bytes = bytes_[@min(bytes_.len, @as(usize, @truncate(write_offset)))..];
@@ -1882,7 +1885,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
const auto_close = file.pathlike != .fd;
const fd = if (!auto_close)
file.pathlike.fd
- else switch (JSC.Node.Syscall.open(file.pathlike.path.sliceZ(&file_buf), std.os.O.RDONLY | std.os.O.NONBLOCK | std.os.O.CLOEXEC, 0)) {
+ else switch (bun.sys.open(file.pathlike.path.sliceZ(&file_buf), std.os.O.RDONLY | std.os.O.NONBLOCK | std.os.O.CLOEXEC, 0)) {
.result => |_fd| _fd,
.err => |err| return this.runErrorHandler(err.withPath(file.pathlike.path.slice()).toSystemError().toErrorInstance(
this.server.globalThis,
@@ -1890,27 +1893,27 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
};
// stat only blocks if the target is a file descriptor
- const stat: std.os.Stat = switch (JSC.Node.Syscall.fstat(fd)) {
+ const stat: bun.Stat = switch (bun.sys.fstat(fd)) {
.result => |result| result,
.err => |err| {
this.runErrorHandler(err.withPathLike(file.pathlike).toSystemError().toErrorInstance(
this.server.globalThis,
));
if (auto_close) {
- _ = JSC.Node.Syscall.close(fd);
+ _ = bun.sys.close(fd);
}
return;
},
};
if (Environment.isMac) {
- if (!std.os.S.ISREG(stat.mode)) {
+ if (!bun.isRegularFile(stat.mode)) {
if (auto_close) {
- _ = JSC.Node.Syscall.close(fd);
+ _ = bun.sys.close(fd);
}
- var err = JSC.Node.Syscall.Error{
- .errno = @as(JSC.Node.Syscall.Error.Int, @intCast(@intFromEnum(std.os.E.INVAL))),
+ var err = bun.sys.Error{
+ .errno = @as(bun.sys.Error.Int, @intCast(@intFromEnum(std.os.E.INVAL))),
.syscall = .sendfile,
};
var sys = err.withPathLike(file.pathlike).toSystemError();
@@ -1923,13 +1926,13 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
if (Environment.isLinux) {
- if (!(std.os.S.ISREG(stat.mode) or std.os.S.ISFIFO(stat.mode))) {
+ if (!(bun.isRegularFile(stat.mode) or std.os.S.ISFIFO(stat.mode))) {
if (auto_close) {
- _ = JSC.Node.Syscall.close(fd);
+ _ = bun.sys.close(fd);
}
- var err = JSC.Node.Syscall.Error{
- .errno = @as(JSC.Node.Syscall.Error.Int, @intCast(@intFromEnum(std.os.E.INVAL))),
+ var err = bun.sys.Error{
+ .errno = @as(bun.sys.Error.Int, @intCast(@intFromEnum(std.os.E.INVAL))),
.syscall = .sendfile,
};
var sys = err.withPathLike(file.pathlike).toSystemError();
@@ -1943,7 +1946,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
const original_size = this.blob.Blob.size;
const stat_size = @as(Blob.SizeType, @intCast(stat.size));
- this.blob.Blob.size = if (std.os.S.ISREG(stat.mode))
+ this.blob.Blob.size = if (bun.isRegularFile(stat.mode))
stat_size
else
@min(original_size, stat_size);
@@ -1961,12 +1964,12 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
// if we are sending only part of a file, include the content-range header
// only include content-range automatically when using a file path instead of an fd
// this is to better support manually controlling the behavior
- if (std.os.S.ISREG(stat.mode) and auto_close) {
+ if (bun.isRegularFile(stat.mode) and auto_close) {
this.flags.needs_content_range = (this.sendfile.remain -| this.sendfile.offset) != stat_size;
}
// we know the bounds when we are sending a regular file
- if (std.os.S.ISREG(stat.mode)) {
+ if (bun.isRegularFile(stat.mode)) {
this.sendfile.offset = @min(this.sendfile.offset, stat_size);
this.sendfile.remain = @min(@max(this.sendfile.remain, this.sendfile.offset), stat_size) -| this.sendfile.offset;
}
@@ -2035,7 +2038,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
// this is used by content-range
this.sendfile = .{
- .fd = @as(i32, @truncate(bun.invalid_fd)),
+ .fd = bun.invalid_fd,
.remain = @as(Blob.SizeType, @truncate(result.result.buf.len)),
.offset = this.blob.Blob.offset,
.auto_close = false,
diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig
index 66cc50f5d..44f33d670 100644
--- a/src/bun.js/base.zig
+++ b/src/bun.js/base.zig
@@ -1696,7 +1696,7 @@ const KQueueGenerationNumber = if (Environment.isMac and Environment.allow_asser
pub const FilePoll = struct {
var max_generation_number: KQueueGenerationNumber = 0;
- fd: u32 = invalid_fd,
+ fd: bun.UFileDescriptor = invalid_fd,
flags: Flags.Set = Flags.Set{},
owner: Owner = undefined,
@@ -2009,7 +2009,7 @@ pub const FilePoll = struct {
pub fn initWithOwner(vm: *JSC.VirtualMachine, fd: bun.FileDescriptor, flags: Flags.Struct, owner: Owner) *FilePoll {
var poll = vm.rareData().filePolls(vm).get();
- poll.fd = @as(u32, @intCast(fd));
+ poll.fd = @intCast(fd);
poll.flags = Flags.Set.init(flags);
poll.owner = owner;
if (KQueueGenerationNumber != u0) {
@@ -2194,11 +2194,11 @@ pub const FilePoll = struct {
if (errno != .SUCCESS) {
return JSC.Maybe(void){
- .err = JSC.Node.Syscall.Error.fromCode(errno, .kqueue),
+ .err = bun.sys.Error.fromCode(errno, .kqueue),
};
}
} else {
- @compileError("TODO: Pollable");
+ bun.todo(@src(), {});
}
if (this.canActivate())
this.activate(loop);
@@ -2220,7 +2220,7 @@ pub const FilePoll = struct {
return this.unregisterWithFd(loop, this.fd);
}
- pub fn unregisterWithFd(this: *FilePoll, loop: *uws.Loop, fd: u64) JSC.Maybe(void) {
+ pub fn unregisterWithFd(this: *FilePoll, loop: *uws.Loop, fd: bun.UFileDescriptor) JSC.Maybe(void) {
if (!(this.flags.contains(.poll_readable) or this.flags.contains(.poll_writable) or this.flags.contains(.poll_process) or this.flags.contains(.poll_machport))) {
// no-op
return JSC.Maybe(void).success;
@@ -2338,7 +2338,7 @@ pub const FilePoll = struct {
else => {},
}
} else {
- @compileError("TODO: Pollable");
+ bun.todo(@src(), {});
}
this.flags.remove(.needs_rearm);
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig
index c8c87648a..870b78738 100644
--- a/src/bun.js/bindings/bindings.zig
+++ b/src/bun.js/bindings/bindings.zig
@@ -2499,6 +2499,12 @@ pub const JSGlobalObject = extern struct {
this.throwValue(this.createErrorInstance("Out of memory", .{}));
}
+ pub fn throwTODO(this: *JSGlobalObject, msg: []const u8) void {
+ const err = this.createErrorInstance("{s}", .{msg});
+ err.put(this, ZigString.static("name"), bun.String.static("TODOError").toJSConst(this));
+ this.throwValue(err);
+ }
+
extern fn JSGlobalObject__clearTerminationException(this: *JSGlobalObject) void;
extern fn JSGlobalObject__throwTerminationException(this: *JSGlobalObject) void;
pub const throwTerminationException = JSGlobalObject__throwTerminationException;
@@ -3763,7 +3769,14 @@ pub const JSValue = enum(JSValueReprInt) {
else => jsNumberFromInt64(@as(i64, @intCast(number))),
},
// u0 => jsNumberFromInt32(0),
- else => @compileError("Type transformation missing for number of type: " ++ @typeName(Number)),
+ else => {
+ // windows
+ if (comptime Number == std.os.fd_t) {
+ return jsNumber(bun.toFD(number));
+ }
+
+ @compileError("Type transformation missing for number of type: " ++ @typeName(Number));
+ },
};
}
diff --git a/src/bun.js/bindings/headers.zig b/src/bun.js/bindings/headers.zig
index a696e86b1..6d8f0e774 100644
--- a/src/bun.js/bindings/headers.zig
+++ b/src/bun.js/bindings/headers.zig
@@ -81,303 +81,303 @@ pub const JSC__JSObject = bJSC__JSObject;
pub const JSC__JSCell = bJSC__JSCell;
pub const JSC__JSGlobalObject = bJSC__JSGlobalObject;
pub const JSC__JSInternalPromise = bJSC__JSInternalPromise;
-pub extern fn JSC__JSObject__create(arg0: *bindings.JSGlobalObject, arg1: usize, arg2: ?*anyopaque, ArgFn3: ?*const fn (?*anyopaque, [*c]bindings.JSObject, *bindings.JSGlobalObject) callconv(.C) void) JSC__JSValue;
-pub extern fn JSC__JSObject__getArrayLength(arg0: [*c]bindings.JSObject) usize;
-pub extern fn JSC__JSObject__getDirect(arg0: [*c]bindings.JSObject, arg1: *bindings.JSGlobalObject, arg2: [*c]const ZigString) JSC__JSValue;
-pub extern fn JSC__JSObject__getIndex(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: u32) JSC__JSValue;
-pub extern fn JSC__JSObject__putRecord(arg0: [*c]bindings.JSObject, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString, arg3: [*c]ZigString, arg4: usize) void;
-pub extern fn ZigString__external(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject, arg2: ?*anyopaque, ArgFn3: ?*const fn (?*anyopaque, ?*anyopaque, usize) callconv(.C) void) JSC__JSValue;
-pub extern fn ZigString__to16BitValue(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toAtomicValue(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toErrorInstance(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toExternalU16(arg0: [*c]const u16, arg1: usize, arg2: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toExternalValue(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toExternalValueWithCallback(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject, ArgFn2: ?*const fn (?*anyopaque, ?*anyopaque, usize) callconv(.C) void) JSC__JSValue;
-pub extern fn ZigString__toRangeErrorInstance(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toSyntaxErrorInstance(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toTypeErrorInstance(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toValue(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toValueGC(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn WebCore__DOMURL__cast_(JSValue0: JSC__JSValue, arg1: *bindings.VM) ?*bindings.DOMURL;
-pub extern fn WebCore__DOMURL__fileSystemPath(arg0: ?*bindings.DOMURL) BunString;
-pub extern fn WebCore__DOMURL__href_(arg0: ?*bindings.DOMURL, arg1: [*c]ZigString) void;
-pub extern fn WebCore__DOMURL__pathname_(arg0: ?*bindings.DOMURL, arg1: [*c]ZigString) void;
-pub extern fn WebCore__DOMFormData__append(arg0: ?*bindings.DOMFormData, arg1: [*c]ZigString, arg2: [*c]ZigString) void;
-pub extern fn WebCore__DOMFormData__appendBlob(arg0: ?*bindings.DOMFormData, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString, arg3: ?*anyopaque, arg4: [*c]ZigString) void;
-pub extern fn WebCore__DOMFormData__count(arg0: ?*bindings.DOMFormData) usize;
-pub extern fn WebCore__DOMFormData__create(arg0: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn WebCore__DOMFormData__createFromURLQuery(arg0: *bindings.JSGlobalObject, arg1: [*c]ZigString) JSC__JSValue;
-pub extern fn WebCore__DOMFormData__fromJS(JSValue0: JSC__JSValue) ?*bindings.DOMFormData;
-pub extern fn WebCore__FetchHeaders__append(arg0: ?*bindings.FetchHeaders, arg1: [*c]const ZigString, arg2: [*c]const ZigString, arg3: *bindings.JSGlobalObject) void;
-pub extern fn WebCore__FetchHeaders__cast_(JSValue0: JSC__JSValue, arg1: *bindings.VM) ?*bindings.FetchHeaders;
-pub extern fn WebCore__FetchHeaders__clone(arg0: ?*bindings.FetchHeaders, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn WebCore__FetchHeaders__cloneThis(arg0: ?*bindings.FetchHeaders, arg1: *bindings.JSGlobalObject) ?*bindings.FetchHeaders;
-pub extern fn WebCore__FetchHeaders__copyTo(arg0: ?*bindings.FetchHeaders, arg1: [*c]StringPointer, arg2: [*c]StringPointer, arg3: [*c]u8) void;
-pub extern fn WebCore__FetchHeaders__count(arg0: ?*bindings.FetchHeaders, arg1: [*c]u32, arg2: [*c]u32) void;
-pub extern fn WebCore__FetchHeaders__createEmpty(...) ?*bindings.FetchHeaders;
-pub extern fn WebCore__FetchHeaders__createFromJS(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*bindings.FetchHeaders;
-pub extern fn WebCore__FetchHeaders__createFromPicoHeaders_(arg0: ?*const anyopaque) ?*bindings.FetchHeaders;
-pub extern fn WebCore__FetchHeaders__createFromUWS(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) ?*bindings.FetchHeaders;
-pub extern fn WebCore__FetchHeaders__createValue(arg0: *bindings.JSGlobalObject, arg1: [*c]StringPointer, arg2: [*c]StringPointer, arg3: [*c]const ZigString, arg4: u32) JSC__JSValue;
-pub extern fn WebCore__FetchHeaders__deref(arg0: ?*bindings.FetchHeaders) void;
-pub extern fn WebCore__FetchHeaders__fastGet_(arg0: ?*bindings.FetchHeaders, arg1: u8, arg2: [*c]ZigString) void;
-pub extern fn WebCore__FetchHeaders__fastHas_(arg0: ?*bindings.FetchHeaders, arg1: u8) bool;
-pub extern fn WebCore__FetchHeaders__fastRemove_(arg0: ?*bindings.FetchHeaders, arg1: u8) void;
-pub extern fn WebCore__FetchHeaders__get_(arg0: ?*bindings.FetchHeaders, arg1: [*c]const ZigString, arg2: [*c]ZigString, arg3: *bindings.JSGlobalObject) void;
-pub extern fn WebCore__FetchHeaders__has(arg0: ?*bindings.FetchHeaders, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) bool;
-pub extern fn WebCore__FetchHeaders__isEmpty(arg0: ?*bindings.FetchHeaders) bool;
-pub extern fn WebCore__FetchHeaders__put_(arg0: ?*bindings.FetchHeaders, arg1: [*c]const ZigString, arg2: [*c]const ZigString, arg3: *bindings.JSGlobalObject) void;
-pub extern fn WebCore__FetchHeaders__remove(arg0: ?*bindings.FetchHeaders, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) void;
-pub extern fn WebCore__FetchHeaders__toJS(arg0: ?*bindings.FetchHeaders, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn WebCore__FetchHeaders__toUWSResponse(arg0: ?*bindings.FetchHeaders, arg1: bool, arg2: ?*anyopaque) void;
-pub extern fn SystemError__toErrorInstance(arg0: [*c]const SystemError, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSCell__getObject(arg0: [*c]bindings.JSCell) [*c]bindings.JSObject;
-pub extern fn JSC__JSCell__getType(arg0: [*c]bindings.JSCell) u8;
-pub extern fn JSC__JSString__eql(arg0: [*c]const JSC__JSString, arg1: *bindings.JSGlobalObject, arg2: [*c]bindings.JSString) bool;
-pub extern fn JSC__JSString__is8Bit(arg0: [*c]const JSC__JSString) bool;
-pub extern fn JSC__JSString__iterator(arg0: [*c]bindings.JSString, arg1: *bindings.JSGlobalObject, arg2: ?*anyopaque) void;
-pub extern fn JSC__JSString__length(arg0: [*c]const JSC__JSString) usize;
-pub extern fn JSC__JSString__toObject(arg0: [*c]bindings.JSString, arg1: *bindings.JSGlobalObject) [*c]bindings.JSObject;
-pub extern fn JSC__JSString__toZigString(arg0: [*c]bindings.JSString, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString) void;
-pub extern fn JSC__JSModuleLoader__evaluate(arg0: *bindings.JSGlobalObject, arg1: [*c]const u8, arg2: usize, arg3: [*c]const u8, arg4: usize, arg5: [*c]const u8, arg6: usize, JSValue7: JSC__JSValue, arg8: [*c]bindings.JSValue) JSC__JSValue;
-pub extern fn JSC__JSModuleLoader__loadAndEvaluateModule(arg0: *bindings.JSGlobalObject, arg1: [*c]const BunString) [*c]bindings.JSInternalPromise;
-pub extern fn WebCore__AbortSignal__aborted(arg0: ?*bindings.AbortSignal) bool;
-pub extern fn WebCore__AbortSignal__abortReason(arg0: ?*bindings.AbortSignal) JSC__JSValue;
-pub extern fn WebCore__AbortSignal__addListener(arg0: ?*bindings.AbortSignal, arg1: ?*anyopaque, ArgFn2: ?*const fn (?*anyopaque, JSC__JSValue) callconv(.C) void) ?*bindings.AbortSignal;
-pub extern fn WebCore__AbortSignal__cleanNativeBindings(arg0: ?*bindings.AbortSignal, arg1: ?*anyopaque) void;
-pub extern fn WebCore__AbortSignal__create(arg0: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn WebCore__AbortSignal__createAbortError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn WebCore__AbortSignal__createTimeoutError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn WebCore__AbortSignal__fromJS(JSValue0: JSC__JSValue) ?*bindings.AbortSignal;
-pub extern fn WebCore__AbortSignal__ref(arg0: ?*bindings.AbortSignal) ?*bindings.AbortSignal;
-pub extern fn WebCore__AbortSignal__signal(arg0: ?*bindings.AbortSignal, JSValue1: JSC__JSValue) ?*bindings.AbortSignal;
-pub extern fn WebCore__AbortSignal__toJS(arg0: ?*bindings.AbortSignal, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn WebCore__AbortSignal__unref(arg0: ?*bindings.AbortSignal) ?*bindings.AbortSignal;
-pub extern fn JSC__JSPromise__asValue(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSPromise__create(arg0: *bindings.JSGlobalObject) ?*bindings.JSPromise;
-pub extern fn JSC__JSPromise__isHandled(arg0: [*c]const JSC__JSPromise, arg1: *bindings.VM) bool;
-pub extern fn JSC__JSPromise__reject(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSPromise__rejectAsHandled(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSPromise__rejectAsHandledException(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, arg2: [*c]bindings.Exception) void;
-pub extern fn JSC__JSPromise__rejectedPromise(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*bindings.JSPromise;
-pub extern fn JSC__JSPromise__rejectedPromiseValue(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__JSPromise__rejectOnNextTickWithHandled(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue, arg3: bool) void;
-pub extern fn JSC__JSPromise__rejectWithCaughtException(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, arg2: bJSC__ThrowScope) void;
-pub extern fn JSC__JSPromise__resolve(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSPromise__resolvedPromise(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*bindings.JSPromise;
-pub extern fn JSC__JSPromise__resolvedPromiseValue(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__JSPromise__resolveOnNextTick(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSPromise__result(arg0: ?*bindings.JSPromise, arg1: *bindings.VM) JSC__JSValue;
-pub extern fn JSC__JSPromise__setHandled(arg0: ?*bindings.JSPromise, arg1: *bindings.VM) void;
-pub extern fn JSC__JSPromise__status(arg0: [*c]const JSC__JSPromise, arg1: *bindings.VM) u32;
-pub extern fn JSC__JSInternalPromise__create(arg0: *bindings.JSGlobalObject) [*c]bindings.JSInternalPromise;
-pub extern fn JSC__JSInternalPromise__isHandled(arg0: [*c]const JSC__JSInternalPromise, arg1: *bindings.VM) bool;
-pub extern fn JSC__JSInternalPromise__reject(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSInternalPromise__rejectAsHandled(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSInternalPromise__rejectAsHandledException(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.JSGlobalObject, arg2: [*c]bindings.Exception) void;
-pub extern fn JSC__JSInternalPromise__rejectedPromise(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) [*c]bindings.JSInternalPromise;
-pub extern fn JSC__JSInternalPromise__rejectWithCaughtException(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.JSGlobalObject, arg2: bJSC__ThrowScope) void;
-pub extern fn JSC__JSInternalPromise__resolve(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSInternalPromise__resolvedPromise(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) [*c]bindings.JSInternalPromise;
-pub extern fn JSC__JSInternalPromise__result(arg0: [*c]const JSC__JSInternalPromise, arg1: *bindings.VM) JSC__JSValue;
-pub extern fn JSC__JSInternalPromise__setHandled(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.VM) void;
-pub extern fn JSC__JSInternalPromise__status(arg0: [*c]const JSC__JSInternalPromise, arg1: *bindings.VM) u32;
-pub extern fn JSC__JSFunction__optimizeSoon(JSValue0: JSC__JSValue) void;
-pub extern fn JSC__JSGlobalObject__bunVM(arg0: *bindings.JSGlobalObject) ?*bindings.VirtualMachine;
-pub extern fn JSC__JSGlobalObject__createAggregateError(arg0: *bindings.JSGlobalObject, arg1: [*c]*anyopaque, arg2: u16, arg3: [*c]const ZigString) JSC__JSValue;
-pub extern fn JSC__JSGlobalObject__createSyntheticModule_(arg0: *bindings.JSGlobalObject, arg1: [*c]ZigString, arg2: usize, arg3: [*c]bindings.JSValue, arg4: usize) void;
-pub extern fn JSC__JSGlobalObject__deleteModuleRegistryEntry(arg0: *bindings.JSGlobalObject, arg1: [*c]ZigString) void;
-pub extern fn JSC__JSGlobalObject__generateHeapSnapshot(arg0: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSGlobalObject__getCachedObject(arg0: *bindings.JSGlobalObject, arg1: [*c]const ZigString) JSC__JSValue;
-pub extern fn JSC__JSGlobalObject__handleRejectedPromises(arg0: *bindings.JSGlobalObject) void;
-pub extern fn JSC__JSGlobalObject__putCachedObject(arg0: *bindings.JSGlobalObject, arg1: [*c]const ZigString, JSValue2: JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__JSGlobalObject__queueMicrotaskJob(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue, JSValue3: JSC__JSValue) void;
-pub extern fn JSC__JSGlobalObject__reload(arg0: *bindings.JSGlobalObject) void;
-pub extern fn JSC__JSGlobalObject__startRemoteInspector(arg0: *bindings.JSGlobalObject, arg1: [*c]u8, arg2: u16) bool;
-pub extern fn JSC__JSGlobalObject__vm(arg0: *bindings.JSGlobalObject) *bindings.VM;
-pub extern fn JSC__JSMap__create(arg0: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSMap__get_(arg0: ?*bindings.JSMap, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__JSMap__has(arg0: ?*bindings.JSMap, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool;
-pub extern fn JSC__JSMap__remove(arg0: ?*bindings.JSMap, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool;
-pub extern fn JSC__JSMap__set(arg0: ?*bindings.JSMap, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue, JSValue3: JSC__JSValue) void;
-pub extern fn JSC__JSValue___then(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue, ArgFn3: ?*const fn (*bindings.JSGlobalObject, *bindings.CallFrame) callconv(.C) JSC__JSValue, ArgFn4: ?*const fn (*bindings.JSGlobalObject, *bindings.CallFrame) callconv(.C) JSC__JSValue) void;
-pub extern fn JSC__JSValue__asArrayBuffer_(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: ?*Bun__ArrayBuffer) bool;
-pub extern fn JSC__JSValue__asBigIntCompare(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) u8;
-pub extern fn JSC__JSValue__asCell(JSValue0: JSC__JSValue) [*c]bindings.JSCell;
-pub extern fn JSC__JSValue__asInternalPromise(JSValue0: JSC__JSValue) [*c]bindings.JSInternalPromise;
-pub extern fn JSC__JSValue__asNumber(JSValue0: JSC__JSValue) f64;
-pub extern fn JSC__JSValue__asObject(JSValue0: JSC__JSValue) bJSC__JSObject;
-pub extern fn JSC__JSValue__asPromise(JSValue0: JSC__JSValue) ?*bindings.JSPromise;
-pub extern fn JSC__JSValue__asString(JSValue0: JSC__JSValue) [*c]bindings.JSString;
-pub extern fn JSC__JSValue__coerceToDouble(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) f64;
-pub extern fn JSC__JSValue__coerceToInt32(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) i32;
-pub extern fn JSC__JSValue__coerceToInt64(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) i64;
-pub extern fn JSC__JSValue__createEmptyArray(arg0: *bindings.JSGlobalObject, arg1: usize) JSC__JSValue;
-pub extern fn JSC__JSValue__createEmptyObject(arg0: *bindings.JSGlobalObject, arg1: usize) JSC__JSValue;
-pub extern fn JSC__JSValue__createInternalPromise(arg0: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__createObject2(arg0: *bindings.JSGlobalObject, arg1: [*c]const ZigString, arg2: [*c]const ZigString, JSValue3: JSC__JSValue, JSValue4: JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__JSValue__createRangeError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__createRopeString(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__createStringArray(arg0: *bindings.JSGlobalObject, arg1: [*c]const ZigString, arg2: usize, arg3: bool) JSC__JSValue;
-pub extern fn JSC__JSValue__createTypeError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__createUninitializedUint8Array(arg0: *bindings.JSGlobalObject, arg1: usize) JSC__JSValue;
-pub extern fn JSC__JSValue__deepEquals(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject) bool;
-pub extern fn JSC__JSValue__deepMatch(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject, arg3: bool) bool;
-pub extern fn JSC__JSValue__eqlCell(JSValue0: JSC__JSValue, arg1: [*c]bindings.JSCell) bool;
-pub extern fn JSC__JSValue__eqlValue(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__fastGet_(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: u8) JSC__JSValue;
-pub extern fn JSC__JSValue__fastGetDirect_(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: u8) JSC__JSValue;
-pub extern fn JSC__JSValue__forEach(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: ?*anyopaque, ArgFn3: ?*const fn (*bindings.VM, *bindings.JSGlobalObject, ?*anyopaque, JSC__JSValue) callconv(.C) void) void;
-pub extern fn JSC__JSValue__forEachProperty(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: ?*anyopaque, ArgFn3: ?*const fn (*bindings.JSGlobalObject, ?*anyopaque, [*c]ZigString, JSC__JSValue, bool) callconv(.C) void) void;
-pub extern fn JSC__JSValue__forEachPropertyOrdered(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: ?*anyopaque, ArgFn3: ?*const fn (*bindings.JSGlobalObject, ?*anyopaque, [*c]ZigString, JSC__JSValue, bool) callconv(.C) void) void;
-pub extern fn JSC__JSValue__fromEntries(arg0: *bindings.JSGlobalObject, arg1: [*c]ZigString, arg2: [*c]ZigString, arg3: usize, arg4: bool) JSC__JSValue;
-pub extern fn JSC__JSValue__fromInt64NoTruncate(arg0: *bindings.JSGlobalObject, arg1: i64) JSC__JSValue;
-pub extern fn JSC__JSValue__fromUInt64NoTruncate(arg0: *bindings.JSGlobalObject, arg1: u64) JSC__JSValue;
-pub extern fn JSC__JSValue__getClassName(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString) void;
-pub extern fn JSC__JSValue__getErrorsProperty(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__getIfPropertyExistsFromPath(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__JSValue__getIfPropertyExistsImpl(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]const u8, arg3: u32) JSC__JSValue;
-pub extern fn JSC__JSValue__getLengthIfPropertyExistsInternal(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) f64;
-pub extern fn JSC__JSValue__getNameProperty(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString) void;
-pub extern fn JSC__JSValue__getPrototype(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__getSymbolDescription(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString) void;
-pub extern fn JSC__JSValue__getUnixTimestamp(JSValue0: JSC__JSValue) f64;
-pub extern fn JSC__JSValue__isAggregateError(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) bool;
-pub extern fn JSC__JSValue__isAnyError(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isAnyInt(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isBigInt(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isBigInt32(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isBoolean(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isCallable(JSValue0: JSC__JSValue, arg1: *bindings.VM) bool;
-pub extern fn JSC__JSValue__isClass(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) bool;
-pub extern fn JSC__JSValue__isConstructor(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isCustomGetterSetter(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isError(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isException(JSValue0: JSC__JSValue, arg1: *bindings.VM) bool;
-pub extern fn JSC__JSValue__isGetterSetter(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isHeapBigInt(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isInstanceOf(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isInt32(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isInt32AsAnyInt(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isIterable(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) bool;
-pub extern fn JSC__JSValue__isNumber(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isObject(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isPrimitive(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isSameValue(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject) bool;
-pub extern fn JSC__JSValue__isSymbol(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isTerminationException(JSValue0: JSC__JSValue, arg1: *bindings.VM) bool;
-pub extern fn JSC__JSValue__isUInt32AsAnyInt(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__jestDeepEquals(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject) bool;
-pub extern fn JSC__JSValue__jestDeepMatch(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject, arg3: bool) bool;
-pub extern fn JSC__JSValue__jestStrictDeepEquals(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject) bool;
-pub extern fn JSC__JSValue__jsBoolean(arg0: bool) JSC__JSValue;
-pub extern fn JSC__JSValue__jsDoubleNumber(arg0: f64) JSC__JSValue;
-pub extern fn JSC__JSValue__jsNull(...) JSC__JSValue;
-pub extern fn JSC__JSValue__jsNumberFromChar(arg0: u8) JSC__JSValue;
-pub extern fn JSC__JSValue__jsNumberFromDouble(arg0: f64) JSC__JSValue;
-pub extern fn JSC__JSValue__jsNumberFromInt64(arg0: i64) JSC__JSValue;
-pub extern fn JSC__JSValue__jsNumberFromU16(arg0: u16) JSC__JSValue;
-pub extern fn JSC__JSValue__jsonStringify(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: u32, arg3: [*c]BunString) void;
-pub extern fn JSC__JSValue__jsTDZValue(...) JSC__JSValue;
-pub extern fn JSC__JSValue__jsType(JSValue0: JSC__JSValue) u8;
-pub extern fn JSC__JSValue__jsUndefined(...) JSC__JSValue;
-pub extern fn JSC__JSValue__makeWithNameAndPrototype(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque, arg2: ?*anyopaque, arg3: [*c]const ZigString) JSC__JSValue;
-pub extern fn JSC__JSValue__parseJSON(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__push(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSValue__put(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]const ZigString, JSValue3: JSC__JSValue) void;
-pub extern fn JSC__JSValue__putIndex(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: u32, JSValue3: JSC__JSValue) void;
-pub extern fn JSC__JSValue__putRecord(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString, arg3: [*c]ZigString, arg4: usize) void;
-pub extern fn JSC__JSValue__strictDeepEquals(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject) bool;
-pub extern fn JSC__JSValue__stringIncludes(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__symbolFor(arg0: *bindings.JSGlobalObject, arg1: [*c]ZigString) JSC__JSValue;
-pub extern fn JSC__JSValue__symbolKeyFor(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString) bool;
-pub extern fn JSC__JSValue__toBoolean(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__toBooleanSlow(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) bool;
-pub extern fn JSC__JSValue__toError_(JSValue0: JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__JSValue__toInt32(JSValue0: JSC__JSValue) i32;
-pub extern fn JSC__JSValue__toInt64(JSValue0: JSC__JSValue) i64;
-pub extern fn JSC__JSValue__toMatch(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__toObject(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) [*c]bindings.JSObject;
-pub extern fn JSC__JSValue__toString(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) [*c]bindings.JSString;
-pub extern fn JSC__JSValue__toStringOrNull(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) [*c]bindings.JSString;
-pub extern fn JSC__JSValue__toUInt64NoTruncate(JSValue0: JSC__JSValue) u64;
-pub extern fn JSC__JSValue__toZigException(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigException) void;
-pub extern fn JSC__JSValue__toZigString(JSValue0: JSC__JSValue, arg1: [*c]ZigString, arg2: *bindings.JSGlobalObject) void;
-pub extern fn JSC__Exception__create(arg0: *bindings.JSGlobalObject, arg1: [*c]bindings.JSObject, StackCaptureAction2: u8) [*c]bindings.Exception;
-pub extern fn JSC__Exception__getStackTrace(arg0: [*c]bindings.Exception, arg1: [*c]ZigStackTrace) void;
-pub extern fn JSC__Exception__value(arg0: [*c]bindings.Exception) JSC__JSValue;
-pub extern fn JSC__VM__blockBytesAllocated(arg0: *bindings.VM) usize;
-pub extern fn JSC__VM__clearExecutionTimeLimit(arg0: *bindings.VM) void;
-pub extern fn JSC__VM__collectAsync(arg0: *bindings.VM) void;
-pub extern fn JSC__VM__create(HeapType0: u8) *bindings.VM;
-pub extern fn JSC__VM__deferGC(arg0: *bindings.VM, arg1: ?*anyopaque, ArgFn2: ?*const fn (?*anyopaque) callconv(.C) void) void;
-pub extern fn JSC__VM__deinit(arg0: *bindings.VM, arg1: *bindings.JSGlobalObject) void;
-pub extern fn JSC__VM__deleteAllCode(arg0: *bindings.VM, arg1: *bindings.JSGlobalObject) void;
-pub extern fn JSC__VM__drainMicrotasks(arg0: *bindings.VM) void;
-pub extern fn JSC__VM__executionForbidden(arg0: *bindings.VM) bool;
-pub extern fn JSC__VM__externalMemorySize(arg0: *bindings.VM) usize;
-pub extern fn JSC__VM__heapSize(arg0: *bindings.VM) usize;
-pub extern fn JSC__VM__holdAPILock(arg0: *bindings.VM, arg1: ?*anyopaque, ArgFn2: ?*const fn (?*anyopaque) callconv(.C) void) void;
-pub extern fn JSC__VM__isEntered(arg0: *bindings.VM) bool;
-pub extern fn JSC__VM__isJITEnabled(...) bool;
-pub extern fn JSC__VM__notifyNeedDebuggerBreak(arg0: *bindings.VM) void;
-pub extern fn JSC__VM__notifyNeedShellTimeoutCheck(arg0: *bindings.VM) void;
-pub extern fn JSC__VM__notifyNeedTermination(arg0: *bindings.VM) void;
-pub extern fn JSC__VM__notifyNeedWatchdogCheck(arg0: *bindings.VM) void;
-pub extern fn JSC__VM__releaseWeakRefs(arg0: *bindings.VM) void;
-pub extern fn JSC__VM__runGC(arg0: *bindings.VM, arg1: bool) JSC__JSValue;
-pub extern fn JSC__VM__setControlFlowProfiler(arg0: *bindings.VM, arg1: bool) void;
-pub extern fn JSC__VM__setExecutionForbidden(arg0: *bindings.VM, arg1: bool) void;
-pub extern fn JSC__VM__setExecutionTimeLimit(arg0: *bindings.VM, arg1: f64) void;
-pub extern fn JSC__VM__shrinkFootprint(arg0: *bindings.VM) void;
-pub extern fn JSC__VM__throwError(arg0: *bindings.VM, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__VM__whenIdle(arg0: *bindings.VM, ArgFn1: ?*const fn (...) callconv(.C) void) void;
-pub extern fn JSC__ThrowScope__clearException(arg0: [*c]bindings.ThrowScope) void;
-pub extern fn JSC__ThrowScope__declare(arg0: *bindings.VM, arg1: [*c]u8, arg2: [*c]u8, arg3: usize) bJSC__ThrowScope;
-pub extern fn JSC__ThrowScope__exception(arg0: [*c]bindings.ThrowScope) [*c]bindings.Exception;
-pub extern fn JSC__ThrowScope__release(arg0: [*c]bindings.ThrowScope) void;
-pub extern fn JSC__CatchScope__clearException(arg0: [*c]bindings.CatchScope) void;
-pub extern fn JSC__CatchScope__declare(arg0: *bindings.VM, arg1: [*c]u8, arg2: [*c]u8, arg3: usize) bJSC__CatchScope;
-pub extern fn JSC__CatchScope__exception(arg0: [*c]bindings.CatchScope) [*c]bindings.Exception;
-pub extern fn FFI__ptr__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Reader__u8__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Reader__u16__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Reader__u32__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Reader__ptr__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Reader__i8__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Reader__i16__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Reader__i32__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Reader__f32__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Reader__f64__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Reader__i64__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Reader__u64__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Reader__intptr__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
-pub extern fn Zig__GlobalObject__create(arg0: ?*anyopaque, arg1: i32, arg2: bool, arg3: ?*anyopaque) *bindings.JSGlobalObject;
-pub extern fn Zig__GlobalObject__getModuleRegistryMap(arg0: *bindings.JSGlobalObject) ?*anyopaque;
-pub extern fn Zig__GlobalObject__resetModuleRegistryMap(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) bool;
-pub extern fn Bun__Path__create(arg0: *bindings.JSGlobalObject, arg1: bool) JSC__JSValue;
-pub extern fn ArrayBufferSink__assignToStream(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, arg2: ?*anyopaque, arg3: [*c]*anyopaque) JSC__JSValue;
-pub extern fn ArrayBufferSink__createObject(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) JSC__JSValue;
-pub extern fn ArrayBufferSink__detachPtr(JSValue0: JSC__JSValue) void;
-pub extern fn ArrayBufferSink__fromJS(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*anyopaque;
-pub extern fn ArrayBufferSink__onClose(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) void;
-pub extern fn ArrayBufferSink__onReady(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue) void;
-pub extern fn HTTPSResponseSink__assignToStream(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, arg2: ?*anyopaque, arg3: [*c]*anyopaque) JSC__JSValue;
-pub extern fn HTTPSResponseSink__createObject(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) JSC__JSValue;
-pub extern fn HTTPSResponseSink__detachPtr(JSValue0: JSC__JSValue) void;
-pub extern fn HTTPSResponseSink__fromJS(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*anyopaque;
-pub extern fn HTTPSResponseSink__onClose(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) void;
-pub extern fn HTTPSResponseSink__onReady(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue) void;
-pub extern fn HTTPResponseSink__assignToStream(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, arg2: ?*anyopaque, arg3: [*c]*anyopaque) JSC__JSValue;
-pub extern fn HTTPResponseSink__createObject(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) JSC__JSValue;
-pub extern fn HTTPResponseSink__detachPtr(JSValue0: JSC__JSValue) void;
-pub extern fn HTTPResponseSink__fromJS(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*anyopaque;
-pub extern fn HTTPResponseSink__onClose(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) void;
-pub extern fn HTTPResponseSink__onReady(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue) void;
-pub extern fn FileSink__assignToStream(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, arg2: ?*anyopaque, arg3: [*c]*anyopaque) JSC__JSValue;
-pub extern fn FileSink__createObject(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) JSC__JSValue;
-pub extern fn FileSink__detachPtr(JSValue0: JSC__JSValue) void;
-pub extern fn FileSink__fromJS(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*anyopaque;
-pub extern fn FileSink__onClose(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) void;
-pub extern fn FileSink__onReady(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue) void;
-pub extern fn ZigException__fromException(arg0: [*c]bindings.Exception) ZigException;
+pub extern "C" fn JSC__JSObject__create(arg0: *bindings.JSGlobalObject, arg1: usize, arg2: ?*anyopaque, ArgFn3: ?*const fn (?*anyopaque, [*c]bindings.JSObject, *bindings.JSGlobalObject) callconv(.C) void) JSC__JSValue;
+pub extern "C" fn JSC__JSObject__getArrayLength(arg0: [*c]bindings.JSObject) usize;
+pub extern "C" fn JSC__JSObject__getDirect(arg0: [*c]bindings.JSObject, arg1: *bindings.JSGlobalObject, arg2: [*c]const ZigString) JSC__JSValue;
+pub extern "C" fn JSC__JSObject__getIndex(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: u32) JSC__JSValue;
+pub extern "C" fn JSC__JSObject__putRecord(arg0: [*c]bindings.JSObject, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString, arg3: [*c]ZigString, arg4: usize) void;
+pub extern "C" fn ZigString__external(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject, arg2: ?*anyopaque, ArgFn3: ?*const fn (?*anyopaque, ?*anyopaque, usize) callconv(.C) void) JSC__JSValue;
+pub extern "C" fn ZigString__to16BitValue(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn ZigString__toAtomicValue(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn ZigString__toErrorInstance(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn ZigString__toExternalU16(arg0: [*c]const u16, arg1: usize, arg2: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn ZigString__toExternalValue(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn ZigString__toExternalValueWithCallback(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject, ArgFn2: ?*const fn (?*anyopaque, ?*anyopaque, usize) callconv(.C) void) JSC__JSValue;
+pub extern "C" fn ZigString__toRangeErrorInstance(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn ZigString__toSyntaxErrorInstance(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn ZigString__toTypeErrorInstance(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn ZigString__toValue(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn ZigString__toValueGC(arg0: [*c]const ZigString, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn WebCore__DOMURL__cast_(JSValue0: JSC__JSValue, arg1: *bindings.VM) ?*bindings.DOMURL;
+pub extern "C" fn WebCore__DOMURL__fileSystemPath(arg0: ?*bindings.DOMURL) BunString;
+pub extern "C" fn WebCore__DOMURL__href_(arg0: ?*bindings.DOMURL, arg1: [*c]ZigString) void;
+pub extern "C" fn WebCore__DOMURL__pathname_(arg0: ?*bindings.DOMURL, arg1: [*c]ZigString) void;
+pub extern "C" fn WebCore__DOMFormData__append(arg0: ?*bindings.DOMFormData, arg1: [*c]ZigString, arg2: [*c]ZigString) void;
+pub extern "C" fn WebCore__DOMFormData__appendBlob(arg0: ?*bindings.DOMFormData, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString, arg3: ?*anyopaque, arg4: [*c]ZigString) void;
+pub extern "C" fn WebCore__DOMFormData__count(arg0: ?*bindings.DOMFormData) usize;
+pub extern "C" fn WebCore__DOMFormData__create(arg0: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn WebCore__DOMFormData__createFromURLQuery(arg0: *bindings.JSGlobalObject, arg1: [*c]ZigString) JSC__JSValue;
+pub extern "C" fn WebCore__DOMFormData__fromJS(JSValue0: JSC__JSValue) ?*bindings.DOMFormData;
+pub extern "C" fn WebCore__FetchHeaders__append(arg0: ?*bindings.FetchHeaders, arg1: [*c]const ZigString, arg2: [*c]const ZigString, arg3: *bindings.JSGlobalObject) void;
+pub extern "C" fn WebCore__FetchHeaders__cast_(JSValue0: JSC__JSValue, arg1: *bindings.VM) ?*bindings.FetchHeaders;
+pub extern "C" fn WebCore__FetchHeaders__clone(arg0: ?*bindings.FetchHeaders, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn WebCore__FetchHeaders__cloneThis(arg0: ?*bindings.FetchHeaders, arg1: *bindings.JSGlobalObject) ?*bindings.FetchHeaders;
+pub extern "C" fn WebCore__FetchHeaders__copyTo(arg0: ?*bindings.FetchHeaders, arg1: [*c]StringPointer, arg2: [*c]StringPointer, arg3: [*c]u8) void;
+pub extern "C" fn WebCore__FetchHeaders__count(arg0: ?*bindings.FetchHeaders, arg1: [*c]u32, arg2: [*c]u32) void;
+pub extern "C" fn WebCore__FetchHeaders__createEmpty(...) ?*bindings.FetchHeaders;
+pub extern "C" fn WebCore__FetchHeaders__createFromJS(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*bindings.FetchHeaders;
+pub extern "C" fn WebCore__FetchHeaders__createFromPicoHeaders_(arg0: ?*const anyopaque) ?*bindings.FetchHeaders;
+pub extern "C" fn WebCore__FetchHeaders__createFromUWS(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) ?*bindings.FetchHeaders;
+pub extern "C" fn WebCore__FetchHeaders__createValue(arg0: *bindings.JSGlobalObject, arg1: [*c]StringPointer, arg2: [*c]StringPointer, arg3: [*c]const ZigString, arg4: u32) JSC__JSValue;
+pub extern "C" fn WebCore__FetchHeaders__deref(arg0: ?*bindings.FetchHeaders) void;
+pub extern "C" fn WebCore__FetchHeaders__fastGet_(arg0: ?*bindings.FetchHeaders, arg1: u8, arg2: [*c]ZigString) void;
+pub extern "C" fn WebCore__FetchHeaders__fastHas_(arg0: ?*bindings.FetchHeaders, arg1: u8) bool;
+pub extern "C" fn WebCore__FetchHeaders__fastRemove_(arg0: ?*bindings.FetchHeaders, arg1: u8) void;
+pub extern "C" fn WebCore__FetchHeaders__get_(arg0: ?*bindings.FetchHeaders, arg1: [*c]const ZigString, arg2: [*c]ZigString, arg3: *bindings.JSGlobalObject) void;
+pub extern "C" fn WebCore__FetchHeaders__has(arg0: ?*bindings.FetchHeaders, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) bool;
+pub extern "C" fn WebCore__FetchHeaders__isEmpty(arg0: ?*bindings.FetchHeaders) bool;
+pub extern "C" fn WebCore__FetchHeaders__put_(arg0: ?*bindings.FetchHeaders, arg1: [*c]const ZigString, arg2: [*c]const ZigString, arg3: *bindings.JSGlobalObject) void;
+pub extern "C" fn WebCore__FetchHeaders__remove(arg0: ?*bindings.FetchHeaders, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) void;
+pub extern "C" fn WebCore__FetchHeaders__toJS(arg0: ?*bindings.FetchHeaders, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn WebCore__FetchHeaders__toUWSResponse(arg0: ?*bindings.FetchHeaders, arg1: bool, arg2: ?*anyopaque) void;
+pub extern "C" fn SystemError__toErrorInstance(arg0: [*c]const SystemError, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn JSC__JSCell__getObject(arg0: [*c]bindings.JSCell) [*c]bindings.JSObject;
+pub extern "C" fn JSC__JSCell__getType(arg0: [*c]bindings.JSCell) u8;
+pub extern "C" fn JSC__JSString__eql(arg0: [*c]const JSC__JSString, arg1: *bindings.JSGlobalObject, arg2: [*c]bindings.JSString) bool;
+pub extern "C" fn JSC__JSString__is8Bit(arg0: [*c]const JSC__JSString) bool;
+pub extern "C" fn JSC__JSString__iterator(arg0: [*c]bindings.JSString, arg1: *bindings.JSGlobalObject, arg2: ?*anyopaque) void;
+pub extern "C" fn JSC__JSString__length(arg0: [*c]const JSC__JSString) usize;
+pub extern "C" fn JSC__JSString__toObject(arg0: [*c]bindings.JSString, arg1: *bindings.JSGlobalObject) [*c]bindings.JSObject;
+pub extern "C" fn JSC__JSString__toZigString(arg0: [*c]bindings.JSString, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString) void;
+pub extern "C" fn JSC__JSModuleLoader__evaluate(arg0: *bindings.JSGlobalObject, arg1: [*c]const u8, arg2: usize, arg3: [*c]const u8, arg4: usize, arg5: [*c]const u8, arg6: usize, JSValue7: JSC__JSValue, arg8: [*c]bindings.JSValue) JSC__JSValue;
+pub extern "C" fn JSC__JSModuleLoader__loadAndEvaluateModule(arg0: *bindings.JSGlobalObject, arg1: [*c]const BunString) [*c]bindings.JSInternalPromise;
+pub extern "C" fn WebCore__AbortSignal__aborted(arg0: ?*bindings.AbortSignal) bool;
+pub extern "C" fn WebCore__AbortSignal__abortReason(arg0: ?*bindings.AbortSignal) JSC__JSValue;
+pub extern "C" fn WebCore__AbortSignal__addListener(arg0: ?*bindings.AbortSignal, arg1: ?*anyopaque, ArgFn2: ?*const fn (?*anyopaque, JSC__JSValue) callconv(.C) void) ?*bindings.AbortSignal;
+pub extern "C" fn WebCore__AbortSignal__cleanNativeBindings(arg0: ?*bindings.AbortSignal, arg1: ?*anyopaque) void;
+pub extern "C" fn WebCore__AbortSignal__create(arg0: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn WebCore__AbortSignal__createAbortError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn WebCore__AbortSignal__createTimeoutError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn WebCore__AbortSignal__fromJS(JSValue0: JSC__JSValue) ?*bindings.AbortSignal;
+pub extern "C" fn WebCore__AbortSignal__ref(arg0: ?*bindings.AbortSignal) ?*bindings.AbortSignal;
+pub extern "C" fn WebCore__AbortSignal__signal(arg0: ?*bindings.AbortSignal, JSValue1: JSC__JSValue) ?*bindings.AbortSignal;
+pub extern "C" fn WebCore__AbortSignal__toJS(arg0: ?*bindings.AbortSignal, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn WebCore__AbortSignal__unref(arg0: ?*bindings.AbortSignal) ?*bindings.AbortSignal;
+pub extern "C" fn JSC__JSPromise__asValue(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn JSC__JSPromise__create(arg0: *bindings.JSGlobalObject) ?*bindings.JSPromise;
+pub extern "C" fn JSC__JSPromise__isHandled(arg0: [*c]const JSC__JSPromise, arg1: *bindings.VM) bool;
+pub extern "C" fn JSC__JSPromise__reject(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
+pub extern "C" fn JSC__JSPromise__rejectAsHandled(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
+pub extern "C" fn JSC__JSPromise__rejectAsHandledException(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, arg2: [*c]bindings.Exception) void;
+pub extern "C" fn JSC__JSPromise__rejectedPromise(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*bindings.JSPromise;
+pub extern "C" fn JSC__JSPromise__rejectedPromiseValue(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) JSC__JSValue;
+pub extern "C" fn JSC__JSPromise__rejectOnNextTickWithHandled(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue, arg3: bool) void;
+pub extern "C" fn JSC__JSPromise__rejectWithCaughtException(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, arg2: bJSC__ThrowScope) void;
+pub extern "C" fn JSC__JSPromise__resolve(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
+pub extern "C" fn JSC__JSPromise__resolvedPromise(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*bindings.JSPromise;
+pub extern "C" fn JSC__JSPromise__resolvedPromiseValue(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) JSC__JSValue;
+pub extern "C" fn JSC__JSPromise__resolveOnNextTick(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
+pub extern "C" fn JSC__JSPromise__result(arg0: ?*bindings.JSPromise, arg1: *bindings.VM) JSC__JSValue;
+pub extern "C" fn JSC__JSPromise__setHandled(arg0: ?*bindings.JSPromise, arg1: *bindings.VM) void;
+pub extern "C" fn JSC__JSPromise__status(arg0: [*c]const JSC__JSPromise, arg1: *bindings.VM) u32;
+pub extern "C" fn JSC__JSInternalPromise__create(arg0: *bindings.JSGlobalObject) [*c]bindings.JSInternalPromise;
+pub extern "C" fn JSC__JSInternalPromise__isHandled(arg0: [*c]const JSC__JSInternalPromise, arg1: *bindings.VM) bool;
+pub extern "C" fn JSC__JSInternalPromise__reject(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
+pub extern "C" fn JSC__JSInternalPromise__rejectAsHandled(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
+pub extern "C" fn JSC__JSInternalPromise__rejectAsHandledException(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.JSGlobalObject, arg2: [*c]bindings.Exception) void;
+pub extern "C" fn JSC__JSInternalPromise__rejectedPromise(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) [*c]bindings.JSInternalPromise;
+pub extern "C" fn JSC__JSInternalPromise__rejectWithCaughtException(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.JSGlobalObject, arg2: bJSC__ThrowScope) void;
+pub extern "C" fn JSC__JSInternalPromise__resolve(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
+pub extern "C" fn JSC__JSInternalPromise__resolvedPromise(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) [*c]bindings.JSInternalPromise;
+pub extern "C" fn JSC__JSInternalPromise__result(arg0: [*c]const JSC__JSInternalPromise, arg1: *bindings.VM) JSC__JSValue;
+pub extern "C" fn JSC__JSInternalPromise__setHandled(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.VM) void;
+pub extern "C" fn JSC__JSInternalPromise__status(arg0: [*c]const JSC__JSInternalPromise, arg1: *bindings.VM) u32;
+pub extern "C" fn JSC__JSFunction__optimizeSoon(JSValue0: JSC__JSValue) void;
+pub extern "C" fn JSC__JSGlobalObject__bunVM(arg0: *bindings.JSGlobalObject) ?*bindings.VirtualMachine;
+pub extern "C" fn JSC__JSGlobalObject__createAggregateError(arg0: *bindings.JSGlobalObject, arg1: [*c]*anyopaque, arg2: u16, arg3: [*c]const ZigString) JSC__JSValue;
+pub extern "C" fn JSC__JSGlobalObject__createSyntheticModule_(arg0: *bindings.JSGlobalObject, arg1: [*c]ZigString, arg2: usize, arg3: [*c]bindings.JSValue, arg4: usize) void;
+pub extern "C" fn JSC__JSGlobalObject__deleteModuleRegistryEntry(arg0: *bindings.JSGlobalObject, arg1: [*c]ZigString) void;
+pub extern "C" fn JSC__JSGlobalObject__generateHeapSnapshot(arg0: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn JSC__JSGlobalObject__getCachedObject(arg0: *bindings.JSGlobalObject, arg1: [*c]const ZigString) JSC__JSValue;
+pub extern "C" fn JSC__JSGlobalObject__handleRejectedPromises(arg0: *bindings.JSGlobalObject) void;
+pub extern "C" fn JSC__JSGlobalObject__putCachedObject(arg0: *bindings.JSGlobalObject, arg1: [*c]const ZigString, JSValue2: JSC__JSValue) JSC__JSValue;
+pub extern "C" fn JSC__JSGlobalObject__queueMicrotaskJob(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue, JSValue3: JSC__JSValue) void;
+pub extern "C" fn JSC__JSGlobalObject__reload(arg0: *bindings.JSGlobalObject) void;
+pub extern "C" fn JSC__JSGlobalObject__startRemoteInspector(arg0: *bindings.JSGlobalObject, arg1: [*c]u8, arg2: u16) bool;
+pub extern "C" fn JSC__JSGlobalObject__vm(arg0: *bindings.JSGlobalObject) *bindings.VM;
+pub extern "C" fn JSC__JSMap__create(arg0: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn JSC__JSMap__get_(arg0: ?*bindings.JSMap, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) JSC__JSValue;
+pub extern "C" fn JSC__JSMap__has(arg0: ?*bindings.JSMap, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSMap__remove(arg0: ?*bindings.JSMap, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSMap__set(arg0: ?*bindings.JSMap, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue, JSValue3: JSC__JSValue) void;
+pub extern "C" fn JSC__JSValue___then(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue, ArgFn3: ?*const fn (*bindings.JSGlobalObject, *bindings.CallFrame) callconv(.C) JSC__JSValue, ArgFn4: ?*const fn (*bindings.JSGlobalObject, *bindings.CallFrame) callconv(.C) JSC__JSValue) void;
+pub extern "C" fn JSC__JSValue__asArrayBuffer_(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: ?*Bun__ArrayBuffer) bool;
+pub extern "C" fn JSC__JSValue__asBigIntCompare(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) u8;
+pub extern "C" fn JSC__JSValue__asCell(JSValue0: JSC__JSValue) [*c]bindings.JSCell;
+pub extern "C" fn JSC__JSValue__asInternalPromise(JSValue0: JSC__JSValue) [*c]bindings.JSInternalPromise;
+pub extern "C" fn JSC__JSValue__asNumber(JSValue0: JSC__JSValue) f64;
+pub extern "C" fn JSC__JSValue__asObject(JSValue0: JSC__JSValue) bJSC__JSObject;
+pub extern "C" fn JSC__JSValue__asPromise(JSValue0: JSC__JSValue) ?*bindings.JSPromise;
+pub extern "C" fn JSC__JSValue__asString(JSValue0: JSC__JSValue) [*c]bindings.JSString;
+pub extern "C" fn JSC__JSValue__coerceToDouble(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) f64;
+pub extern "C" fn JSC__JSValue__coerceToInt32(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) i32;
+pub extern "C" fn JSC__JSValue__coerceToInt64(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) i64;
+pub extern "C" fn JSC__JSValue__createEmptyArray(arg0: *bindings.JSGlobalObject, arg1: usize) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__createEmptyObject(arg0: *bindings.JSGlobalObject, arg1: usize) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__createInternalPromise(arg0: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__createObject2(arg0: *bindings.JSGlobalObject, arg1: [*c]const ZigString, arg2: [*c]const ZigString, JSValue3: JSC__JSValue, JSValue4: JSC__JSValue) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__createRangeError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__createRopeString(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__createStringArray(arg0: *bindings.JSGlobalObject, arg1: [*c]const ZigString, arg2: usize, arg3: bool) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__createTypeError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__createUninitializedUint8Array(arg0: *bindings.JSGlobalObject, arg1: usize) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__deepEquals(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject) bool;
+pub extern "C" fn JSC__JSValue__deepMatch(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject, arg3: bool) bool;
+pub extern "C" fn JSC__JSValue__eqlCell(JSValue0: JSC__JSValue, arg1: [*c]bindings.JSCell) bool;
+pub extern "C" fn JSC__JSValue__eqlValue(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__fastGet_(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: u8) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__fastGetDirect_(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: u8) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__forEach(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: ?*anyopaque, ArgFn3: ?*const fn (*bindings.VM, *bindings.JSGlobalObject, ?*anyopaque, JSC__JSValue) callconv(.C) void) void;
+pub extern "C" fn JSC__JSValue__forEachProperty(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: ?*anyopaque, ArgFn3: ?*const fn (*bindings.JSGlobalObject, ?*anyopaque, [*c]ZigString, JSC__JSValue, bool) callconv(.C) void) void;
+pub extern "C" fn JSC__JSValue__forEachPropertyOrdered(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: ?*anyopaque, ArgFn3: ?*const fn (*bindings.JSGlobalObject, ?*anyopaque, [*c]ZigString, JSC__JSValue, bool) callconv(.C) void) void;
+pub extern "C" fn JSC__JSValue__fromEntries(arg0: *bindings.JSGlobalObject, arg1: [*c]ZigString, arg2: [*c]ZigString, arg3: usize, arg4: bool) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__fromInt64NoTruncate(arg0: *bindings.JSGlobalObject, arg1: i64) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__fromUInt64NoTruncate(arg0: *bindings.JSGlobalObject, arg1: u64) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__getClassName(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString) void;
+pub extern "C" fn JSC__JSValue__getErrorsProperty(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__getIfPropertyExistsFromPath(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__getIfPropertyExistsImpl(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]const u8, arg3: u32) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__getLengthIfPropertyExistsInternal(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) f64;
+pub extern "C" fn JSC__JSValue__getNameProperty(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString) void;
+pub extern "C" fn JSC__JSValue__getPrototype(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__getSymbolDescription(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString) void;
+pub extern "C" fn JSC__JSValue__getUnixTimestamp(JSValue0: JSC__JSValue) f64;
+pub extern "C" fn JSC__JSValue__isAggregateError(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) bool;
+pub extern "C" fn JSC__JSValue__isAnyError(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isAnyInt(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isBigInt(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isBigInt32(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isBoolean(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isCallable(JSValue0: JSC__JSValue, arg1: *bindings.VM) bool;
+pub extern "C" fn JSC__JSValue__isClass(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) bool;
+pub extern "C" fn JSC__JSValue__isConstructor(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isCustomGetterSetter(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isError(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isException(JSValue0: JSC__JSValue, arg1: *bindings.VM) bool;
+pub extern "C" fn JSC__JSValue__isGetterSetter(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isHeapBigInt(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isInstanceOf(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isInt32(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isInt32AsAnyInt(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isIterable(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) bool;
+pub extern "C" fn JSC__JSValue__isNumber(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isObject(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isPrimitive(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isSameValue(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject) bool;
+pub extern "C" fn JSC__JSValue__isSymbol(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__isTerminationException(JSValue0: JSC__JSValue, arg1: *bindings.VM) bool;
+pub extern "C" fn JSC__JSValue__isUInt32AsAnyInt(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__jestDeepEquals(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject) bool;
+pub extern "C" fn JSC__JSValue__jestDeepMatch(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject, arg3: bool) bool;
+pub extern "C" fn JSC__JSValue__jestStrictDeepEquals(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject) bool;
+pub extern "C" fn JSC__JSValue__jsBoolean(arg0: bool) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__jsDoubleNumber(arg0: f64) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__jsNull(...) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__jsNumberFromChar(arg0: u8) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__jsNumberFromDouble(arg0: f64) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__jsNumberFromInt64(arg0: i64) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__jsNumberFromU16(arg0: u16) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__jsonStringify(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: u32, arg3: [*c]BunString) void;
+pub extern "C" fn JSC__JSValue__jsTDZValue(...) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__jsType(JSValue0: JSC__JSValue) u8;
+pub extern "C" fn JSC__JSValue__jsUndefined(...) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__makeWithNameAndPrototype(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque, arg2: ?*anyopaque, arg3: [*c]const ZigString) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__parseJSON(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__push(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
+pub extern "C" fn JSC__JSValue__put(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]const ZigString, JSValue3: JSC__JSValue) void;
+pub extern "C" fn JSC__JSValue__putIndex(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: u32, JSValue3: JSC__JSValue) void;
+pub extern "C" fn JSC__JSValue__putRecord(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString, arg3: [*c]ZigString, arg4: usize) void;
+pub extern "C" fn JSC__JSValue__strictDeepEquals(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: *bindings.JSGlobalObject) bool;
+pub extern "C" fn JSC__JSValue__stringIncludes(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__symbolFor(arg0: *bindings.JSGlobalObject, arg1: [*c]ZigString) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__symbolKeyFor(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigString) bool;
+pub extern "C" fn JSC__JSValue__toBoolean(JSValue0: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__toBooleanSlow(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) bool;
+pub extern "C" fn JSC__JSValue__toError_(JSValue0: JSC__JSValue) JSC__JSValue;
+pub extern "C" fn JSC__JSValue__toInt32(JSValue0: JSC__JSValue) i32;
+pub extern "C" fn JSC__JSValue__toInt64(JSValue0: JSC__JSValue) i64;
+pub extern "C" fn JSC__JSValue__toMatch(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool;
+pub extern "C" fn JSC__JSValue__toObject(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) [*c]bindings.JSObject;
+pub extern "C" fn JSC__JSValue__toString(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) [*c]bindings.JSString;
+pub extern "C" fn JSC__JSValue__toStringOrNull(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject) [*c]bindings.JSString;
+pub extern "C" fn JSC__JSValue__toUInt64NoTruncate(JSValue0: JSC__JSValue) u64;
+pub extern "C" fn JSC__JSValue__toZigException(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: [*c]ZigException) void;
+pub extern "C" fn JSC__JSValue__toZigString(JSValue0: JSC__JSValue, arg1: [*c]ZigString, arg2: *bindings.JSGlobalObject) void;
+pub extern "C" fn JSC__Exception__create(arg0: *bindings.JSGlobalObject, arg1: [*c]bindings.JSObject, StackCaptureAction2: u8) [*c]bindings.Exception;
+pub extern "C" fn JSC__Exception__getStackTrace(arg0: [*c]bindings.Exception, arg1: [*c]ZigStackTrace) void;
+pub extern "C" fn JSC__Exception__value(arg0: [*c]bindings.Exception) JSC__JSValue;
+pub extern "C" fn JSC__VM__blockBytesAllocated(arg0: *bindings.VM) usize;
+pub extern "C" fn JSC__VM__clearExecutionTimeLimit(arg0: *bindings.VM) void;
+pub extern "C" fn JSC__VM__collectAsync(arg0: *bindings.VM) void;
+pub extern "C" fn JSC__VM__create(HeapType0: u8) *bindings.VM;
+pub extern "C" fn JSC__VM__deferGC(arg0: *bindings.VM, arg1: ?*anyopaque, ArgFn2: ?*const fn (?*anyopaque) callconv(.C) void) void;
+pub extern "C" fn JSC__VM__deinit(arg0: *bindings.VM, arg1: *bindings.JSGlobalObject) void;
+pub extern "C" fn JSC__VM__deleteAllCode(arg0: *bindings.VM, arg1: *bindings.JSGlobalObject) void;
+pub extern "C" fn JSC__VM__drainMicrotasks(arg0: *bindings.VM) void;
+pub extern "C" fn JSC__VM__executionForbidden(arg0: *bindings.VM) bool;
+pub extern "C" fn JSC__VM__externalMemorySize(arg0: *bindings.VM) usize;
+pub extern "C" fn JSC__VM__heapSize(arg0: *bindings.VM) usize;
+pub extern "C" fn JSC__VM__holdAPILock(arg0: *bindings.VM, arg1: ?*anyopaque, ArgFn2: ?*const fn (?*anyopaque) callconv(.C) void) void;
+pub extern "C" fn JSC__VM__isEntered(arg0: *bindings.VM) bool;
+pub extern "C" fn JSC__VM__isJITEnabled(...) bool;
+pub extern "C" fn JSC__VM__notifyNeedDebuggerBreak(arg0: *bindings.VM) void;
+pub extern "C" fn JSC__VM__notifyNeedShellTimeoutCheck(arg0: *bindings.VM) void;
+pub extern "C" fn JSC__VM__notifyNeedTermination(arg0: *bindings.VM) void;
+pub extern "C" fn JSC__VM__notifyNeedWatchdogCheck(arg0: *bindings.VM) void;
+pub extern "C" fn JSC__VM__releaseWeakRefs(arg0: *bindings.VM) void;
+pub extern "C" fn JSC__VM__runGC(arg0: *bindings.VM, arg1: bool) JSC__JSValue;
+pub extern "C" fn JSC__VM__setControlFlowProfiler(arg0: *bindings.VM, arg1: bool) void;
+pub extern "C" fn JSC__VM__setExecutionForbidden(arg0: *bindings.VM, arg1: bool) void;
+pub extern "C" fn JSC__VM__setExecutionTimeLimit(arg0: *bindings.VM, arg1: f64) void;
+pub extern "C" fn JSC__VM__shrinkFootprint(arg0: *bindings.VM) void;
+pub extern "C" fn JSC__VM__throwError(arg0: *bindings.VM, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void;
+pub extern "C" fn JSC__VM__whenIdle(arg0: *bindings.VM, ArgFn1: ?*const fn (...) callconv(.C) void) void;
+pub extern "C" fn JSC__ThrowScope__clearException(arg0: [*c]bindings.ThrowScope) void;
+pub extern "C" fn JSC__ThrowScope__declare(arg0: *bindings.VM, arg1: [*c]u8, arg2: [*c]u8, arg3: usize) bJSC__ThrowScope;
+pub extern "C" fn JSC__ThrowScope__exception(arg0: [*c]bindings.ThrowScope) [*c]bindings.Exception;
+pub extern "C" fn JSC__ThrowScope__release(arg0: [*c]bindings.ThrowScope) void;
+pub extern "C" fn JSC__CatchScope__clearException(arg0: [*c]bindings.CatchScope) void;
+pub extern "C" fn JSC__CatchScope__declare(arg0: *bindings.VM, arg1: [*c]u8, arg2: [*c]u8, arg3: usize) bJSC__CatchScope;
+pub extern "C" fn JSC__CatchScope__exception(arg0: [*c]bindings.CatchScope) [*c]bindings.Exception;
+pub extern "C" fn FFI__ptr__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
+pub extern "C" fn Reader__u8__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
+pub extern "C" fn Reader__u16__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
+pub extern "C" fn Reader__u32__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
+pub extern "C" fn Reader__ptr__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
+pub extern "C" fn Reader__i8__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
+pub extern "C" fn Reader__i16__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
+pub extern "C" fn Reader__i32__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
+pub extern "C" fn Reader__f32__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
+pub extern "C" fn Reader__f64__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
+pub extern "C" fn Reader__i64__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
+pub extern "C" fn Reader__u64__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
+pub extern "C" fn Reader__intptr__put(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) void;
+pub extern "C" fn Zig__GlobalObject__create(arg0: ?*anyopaque, arg1: i32, arg2: bool, arg3: ?*anyopaque) *bindings.JSGlobalObject;
+pub extern "C" fn Zig__GlobalObject__getModuleRegistryMap(arg0: *bindings.JSGlobalObject) ?*anyopaque;
+pub extern "C" fn Zig__GlobalObject__resetModuleRegistryMap(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) bool;
+pub extern "C" fn Bun__Path__create(arg0: *bindings.JSGlobalObject, arg1: bool) JSC__JSValue;
+pub extern "C" fn ArrayBufferSink__assignToStream(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, arg2: ?*anyopaque, arg3: [*c]*anyopaque) JSC__JSValue;
+pub extern "C" fn ArrayBufferSink__createObject(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) JSC__JSValue;
+pub extern "C" fn ArrayBufferSink__detachPtr(JSValue0: JSC__JSValue) void;
+pub extern "C" fn ArrayBufferSink__fromJS(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*anyopaque;
+pub extern "C" fn ArrayBufferSink__onClose(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) void;
+pub extern "C" fn ArrayBufferSink__onReady(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue) void;
+pub extern "C" fn HTTPSResponseSink__assignToStream(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, arg2: ?*anyopaque, arg3: [*c]*anyopaque) JSC__JSValue;
+pub extern "C" fn HTTPSResponseSink__createObject(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) JSC__JSValue;
+pub extern "C" fn HTTPSResponseSink__detachPtr(JSValue0: JSC__JSValue) void;
+pub extern "C" fn HTTPSResponseSink__fromJS(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*anyopaque;
+pub extern "C" fn HTTPSResponseSink__onClose(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) void;
+pub extern "C" fn HTTPSResponseSink__onReady(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue) void;
+pub extern "C" fn HTTPResponseSink__assignToStream(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, arg2: ?*anyopaque, arg3: [*c]*anyopaque) JSC__JSValue;
+pub extern "C" fn HTTPResponseSink__createObject(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) JSC__JSValue;
+pub extern "C" fn HTTPResponseSink__detachPtr(JSValue0: JSC__JSValue) void;
+pub extern "C" fn HTTPResponseSink__fromJS(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*anyopaque;
+pub extern "C" fn HTTPResponseSink__onClose(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) void;
+pub extern "C" fn HTTPResponseSink__onReady(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue) void;
+pub extern "C" fn FileSink__assignToStream(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, arg2: ?*anyopaque, arg3: [*c]*anyopaque) JSC__JSValue;
+pub extern "C" fn FileSink__createObject(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) JSC__JSValue;
+pub extern "C" fn FileSink__detachPtr(JSValue0: JSC__JSValue) void;
+pub extern "C" fn FileSink__fromJS(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*anyopaque;
+pub extern "C" fn FileSink__onClose(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) void;
+pub extern "C" fn FileSink__onReady(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue) void;
+pub extern "C" fn ZigException__fromException(arg0: [*c]bindings.Exception) ZigException;
diff --git a/src/bun.js/config.zig b/src/bun.js/config.zig
index f95146c6d..e8fdaeba8 100644
--- a/src/bun.js/config.zig
+++ b/src/bun.js/config.zig
@@ -18,7 +18,7 @@ const Api = @import("../api/schema.zig").Api;
const options = @import("../options.zig");
const Bundler = bun.bundler.ServeBundler;
const js_printer = bun.js_printer;
-const http = @import("../http.zig");
+const http = @import("../bun_dev_http_server.zig");
pub const DefaultBunDefines = struct {
pub const Keys = struct {
diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig
index fc2bd7a05..f1ef15b73 100644
--- a/src/bun.js/javascript.zig
+++ b/src/bun.js/javascript.zig
@@ -32,7 +32,7 @@ const ServerEntryPoint = bun.bundler.ServerEntryPoint;
const js_printer = bun.js_printer;
const js_parser = bun.js_parser;
const js_ast = bun.JSAst;
-const http = @import("../http.zig");
+const http = @import("../bun_dev_http_server.zig");
const NodeFallbackModules = @import("../node_fallbacks.zig");
const ImportKind = ast.ImportKind;
const Analytics = @import("../analytics/analytics_thread.zig");
diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig
index 755e16647..e165b20fa 100644
--- a/src/bun.js/module_loader.zig
+++ b/src/bun.js/module_loader.zig
@@ -31,7 +31,7 @@ const ServerEntryPoint = bun.bundler.ServerEntryPoint;
const js_printer = bun.js_printer;
const js_parser = bun.js_parser;
const js_ast = bun.JSAst;
-const http = @import("../http.zig");
+const http = @import("../bun_dev_http_server.zig");
const NodeFallbackModules = @import("../node_fallbacks.zig");
const ImportKind = ast.ImportKind;
const Analytics = @import("../analytics/analytics_thread.zig");
@@ -408,7 +408,7 @@ pub const RuntimeTranspilerStore = struct {
defer {
if (should_close_input_file_fd and input_file_fd != 0) {
- _ = bun.JSC.Node.Syscall.close(input_file_fd);
+ _ = bun.sys.close(input_file_fd);
input_file_fd = 0;
}
}
@@ -1444,7 +1444,7 @@ pub const ModuleLoader = struct {
};
defer {
if (should_close_input_file_fd and input_file_fd != 0) {
- _ = bun.JSC.Node.Syscall.close(input_file_fd);
+ _ = bun.sys.close(input_file_fd);
input_file_fd = 0;
}
}
diff --git a/src/bun.js/node/dir_iterator.zig b/src/bun.js/node/dir_iterator.zig
index 968fde001..994ddaa31 100644
--- a/src/bun.js/node/dir_iterator.zig
+++ b/src/bun.js/node/dir_iterator.zig
@@ -11,6 +11,7 @@ const os = std.os;
const Dir = std.fs.Dir;
const JSC = @import("root").bun.JSC;
const PathString = JSC.PathString;
+const bun = @import("root").bun;
const IteratorError = error{ AccessDenied, SystemResources } || os.UnexpectedError;
const mem = std.mem;
@@ -188,11 +189,37 @@ pub const Iterator = switch (builtin.os.tag) {
if (io.Information == 0) return .{ .result = null };
self.index = 0;
self.end_index = io.Information;
- switch (rc) {
- .SUCCESS => {},
- .ACCESS_DENIED => return error.AccessDenied, // Double-check that the Dir was opened with iteration ability
+ // If the handle is not a directory, we'll get STATUS_INVALID_PARAMETER.
+ if (rc == .INVALID_PARAMETER) {
+ return .{
+ .err = .{
+ .errno = @as(bun.sys.Error.Int, @truncate(@intFromEnum(bun.C.SystemErrno.ENOTDIR))),
+ .syscall = .NtQueryDirectoryFile,
+ },
+ };
+ }
+
+ if (rc == .NO_MORE_FILES) {
+ self.end_index = self.index;
+ return .{ .result = null };
+ }
+
+ if (rc != .SUCCESS) {
+ if ((bun.windows.Win32Error.fromNTStatus(rc).toSystemErrno())) |errno| {
+ return .{
+ .err = .{
+ .errno = @truncate(@intFromEnum(errno)),
+ .syscall = .NtQueryDirectoryFile,
+ },
+ };
+ }
- else => return w.unexpectedStatus(rc),
+ return .{
+ .err = .{
+ .errno = @truncate(@intFromEnum(bun.C.SystemErrno.EUNKNOWN)),
+ .syscall = .NtQueryDirectoryFile,
+ },
+ };
}
}
@@ -208,8 +235,7 @@ pub const Iterator = switch (builtin.os.tag) {
if (mem.eql(u16, name_utf16le, &[_]u16{'.'}) or mem.eql(u16, name_utf16le, &[_]u16{ '.', '.' }))
continue;
// Trust that Windows gives us valid UTF-16LE
- const name_utf8_len = std.unicode.utf16leToUtf8(self.name_data[0..], name_utf16le) catch unreachable;
- const name_utf8 = self.name_data[0..name_utf8_len];
+ const name_utf8 = strings.fromWPath(self.name_data[0..], name_utf16le);
const kind = blk: {
const attrs = dir_info.FileAttributes;
if (attrs & w.FILE_ATTRIBUTE_DIRECTORY != 0) break :blk Entry.Kind.directory;
diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig
index 130ab8cdc..01952dc68 100644
--- a/src/bun.js/node/node_fs.zig
+++ b/src/bun.js/node/node_fs.zig
@@ -31,9 +31,9 @@ const StringOrBuffer = JSC.Node.StringOrBuffer;
const ArgumentsSlice = JSC.Node.ArgumentsSlice;
const TimeLike = JSC.Node.TimeLike;
const Mode = JSC.Node.Mode;
-
-const uid_t = std.os.uid_t;
-const gid_t = std.os.gid_t;
+const E = C.E;
+const uid_t = if (Environment.isPosix) std.os.uid_t else i32;
+const gid_t = if (Environment.isPosix) std.os.gid_t else i32;
/// u63 to allow one null bit
const ReadPosition = i64;
@@ -44,12 +44,16 @@ pub const FlavoredIO = struct {
io: *AsyncIO,
};
-pub const default_permission = Syscall.S.IRUSR |
- Syscall.S.IWUSR |
- Syscall.S.IRGRP |
- Syscall.S.IWGRP |
- Syscall.S.IROTH |
- Syscall.S.IWOTH;
+pub const default_permission = if (Environment.isPosix)
+ Syscall.S.IRUSR |
+ Syscall.S.IWUSR |
+ Syscall.S.IRGRP |
+ Syscall.S.IWGRP |
+ Syscall.S.IROTH |
+ Syscall.S.IWOTH
+else
+ // TODO:
+ 0;
const ArrayBuffer = JSC.MarkedArrayBuffer;
const Buffer = JSC.Buffer;
@@ -1212,7 +1216,9 @@ pub const Arguments = struct {
// be absolute. When using 'junction', the target argument
// will automatically be normalized to absolute path.
if (next_val.isString()) {
- comptime if (Environment.isWindows) @compileError("Add support for type argument on Windows");
+ if (comptime Environment.isWindows) {
+ bun.todo(@src(), {});
+ }
arguments.eat();
}
}
@@ -2174,7 +2180,7 @@ pub const Arguments = struct {
mode: Mode = 0o666,
file: PathOrFileDescriptor,
data: StringOrBuffer,
- dirfd: FileDescriptor = @as(FileDescriptor, @intCast(std.fs.cwd().fd)),
+ dirfd: FileDescriptor,
pub fn deinit(self: WriteFile) void {
self.file.deinit();
@@ -2290,6 +2296,7 @@ pub const Arguments = struct {
.flag = flag,
.mode = mode,
.data = data,
+ .dirfd = bun.toFD(std.fs.cwd().fd),
};
}
};
@@ -3058,6 +3065,10 @@ pub const NodeFS = struct {
pub const ReturnType = Return;
pub fn access(this: *NodeFS, args: Arguments.Access, comptime _: Flavor) Maybe(Return.Access) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Access).todo;
+ }
+
var path = args.path.sliceZ(&this.sync_error_buf);
const rc = Syscall.system.access(path, @intFromEnum(args.mode));
return Maybe(Return.Access).errnoSysP(rc, .access, path) orelse Maybe(Return.Access).success;
@@ -3391,6 +3402,10 @@ pub const NodeFS = struct {
}
pub fn chown(this: *NodeFS, args: Arguments.Chown, comptime flavor: Flavor) Maybe(Return.Chown) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Fchmod).todo;
+ }
+
const path = args.path.sliceZ(&this.sync_error_buf);
switch (comptime flavor) {
@@ -3403,6 +3418,10 @@ pub const NodeFS = struct {
/// This should almost never be async
pub fn chmod(this: *NodeFS, args: Arguments.Chmod, comptime flavor: Flavor) Maybe(Return.Chmod) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Fchmod).todo;
+ }
+
const path = args.path.sliceZ(&this.sync_error_buf);
switch (comptime flavor) {
@@ -3418,6 +3437,10 @@ pub const NodeFS = struct {
/// This should almost never be async
pub fn fchmod(_: *NodeFS, args: Arguments.FChmod, comptime flavor: Flavor) Maybe(Return.Fchmod) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Fchmod).todo;
+ }
+
switch (comptime flavor) {
.sync => {
return Syscall.fchmod(args.fd, args.mode);
@@ -3428,6 +3451,10 @@ pub const NodeFS = struct {
return Maybe(Return.Fchmod).todo;
}
pub fn fchown(_: *NodeFS, args: Arguments.Fchown, comptime flavor: Flavor) Maybe(Return.Fchown) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Fchown).todo;
+ }
+
switch (comptime flavor) {
.sync => {
return Maybe(Return.Fchown).errnoSys(C.fchown(args.fd, args.uid, args.gid), .fchown) orelse
@@ -3439,6 +3466,9 @@ pub const NodeFS = struct {
return Maybe(Return.Fchown).todo;
}
pub fn fdatasync(_: *NodeFS, args: Arguments.FdataSync, comptime flavor: Flavor) Maybe(Return.Fdatasync) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Fdatasync).todo;
+ }
switch (comptime flavor) {
.sync => return Maybe(Return.Fdatasync).errnoSys(system.fdatasync(args.fd), .fdatasync) orelse
Maybe(Return.Fdatasync).success,
@@ -3448,12 +3478,18 @@ pub const NodeFS = struct {
return Maybe(Return.Fdatasync).todo;
}
pub fn fstat(_: *NodeFS, args: Arguments.Fstat, comptime flavor: Flavor) Maybe(Return.Fstat) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Fstat).todo;
+ }
+
switch (comptime flavor) {
.sync => {
- return switch (Syscall.fstat(args.fd)) {
- .result => |result| Maybe(Return.Fstat){ .result = Stats.init(result, false) },
- .err => |err| Maybe(Return.Fstat){ .err = err },
- };
+ if (comptime Environment.isPosix) {
+ return switch (Syscall.fstat(args.fd)) {
+ .result => |result| Maybe(Return.Fstat){ .result = Stats.init(result, false) },
+ .err => |err| Maybe(Return.Fstat){ .err = err },
+ };
+ }
},
else => {},
}
@@ -3462,6 +3498,10 @@ pub const NodeFS = struct {
}
pub fn fsync(_: *NodeFS, args: Arguments.Fsync, comptime flavor: Flavor) Maybe(Return.Fsync) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Fsync).todo;
+ }
+
switch (comptime flavor) {
.sync => return Maybe(Return.Fsync).errnoSys(system.fsync(args.fd), .fsync) orelse
Maybe(Return.Fsync).success,
@@ -3472,8 +3512,7 @@ pub const NodeFS = struct {
}
pub fn ftruncateSync(args: Arguments.FTruncate) Maybe(Return.Ftruncate) {
- return Maybe(Return.Ftruncate).errnoSys(system.ftruncate(args.fd, args.len orelse 0), .ftruncate) orelse
- Maybe(Return.Ftruncate).success;
+ return Syscall.ftruncate(args.fd, args.len orelse 0);
}
pub fn ftruncate(_: *NodeFS, args: Arguments.FTruncate, comptime flavor: Flavor) Maybe(Return.Ftruncate) {
@@ -3485,6 +3524,10 @@ pub const NodeFS = struct {
return Maybe(Return.Ftruncate).todo;
}
pub fn futimes(_: *NodeFS, args: Arguments.Futimes, comptime flavor: Flavor) Maybe(Return.Futimes) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Futimes).todo;
+ }
+
var times = [2]std.os.timespec{
.{
.tv_sec = args.mtime,
@@ -3508,6 +3551,10 @@ pub const NodeFS = struct {
}
pub fn lchmod(this: *NodeFS, args: Arguments.LCHmod, comptime flavor: Flavor) Maybe(Return.Lchmod) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Lchmod).todo;
+ }
+
const path = args.path.sliceZ(&this.sync_error_buf);
switch (comptime flavor) {
@@ -3522,6 +3569,10 @@ pub const NodeFS = struct {
}
pub fn lchown(this: *NodeFS, args: Arguments.LChown, comptime flavor: Flavor) Maybe(Return.Lchown) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Lchown).todo;
+ }
+
const path = args.path.sliceZ(&this.sync_error_buf);
switch (comptime flavor) {
@@ -3550,6 +3601,10 @@ pub const NodeFS = struct {
return Maybe(Return.Link).todo;
}
pub fn lstat(this: *NodeFS, args: Arguments.Lstat, comptime flavor: Flavor) Maybe(Return.Lstat) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Lstat).todo;
+ }
+
_ = flavor;
return switch (Syscall.lstat(
args.path.sliceZ(
@@ -3589,7 +3644,7 @@ pub const NodeFS = struct {
// TODO: verify this works correctly with unicode codepoints
pub fn mkdirRecursive(this: *NodeFS, args: Arguments.Mkdir, comptime flavor: Flavor) Maybe(Return.Mkdir) {
const Option = Maybe(Return.Mkdir);
- if (comptime Environment.isWindows) @compileError("This needs to be implemented on Windows.");
+ if (comptime Environment.isWindows) return Option.todo;
switch (comptime flavor) {
// The sync version does no allocation except when returning the path
@@ -3822,6 +3877,7 @@ pub const NodeFS = struct {
}
pub fn read(this: *NodeFS, args: Arguments.Read, comptime flavor: Flavor) Maybe(Return.Read) {
+ if (comptime Environment.isWindows) return Maybe(Return.Read).todo;
return if (args.position != null)
this._pread(
args,
@@ -3835,14 +3891,17 @@ pub const NodeFS = struct {
}
pub fn readv(this: *NodeFS, args: Arguments.Readv, comptime flavor: Flavor) Maybe(Return.Read) {
+ if (comptime Environment.isWindows) return Maybe(Return.Read).todo;
return if (args.position != null) _preadv(this, args, flavor) else _readv(this, args, flavor);
}
pub fn writev(this: *NodeFS, args: Arguments.Writev, comptime flavor: Flavor) Maybe(Return.Write) {
+ if (comptime Environment.isWindows) return Maybe(Return.Write).todo;
return if (args.position != null) _pwritev(this, args, flavor) else _writev(this, args, flavor);
}
pub fn write(this: *NodeFS, args: Arguments.Write, comptime flavor: Flavor) Maybe(Return.Write) {
+ if (comptime Environment.isWindows) return Maybe(Return.Write).todo;
return if (args.position != null) _pwrite(this, args, flavor) else _write(this, args, flavor);
}
fn _write(_: *NodeFS, args: Arguments.Write, comptime flavor: Flavor) Maybe(Return.Write) {
@@ -4023,7 +4082,7 @@ pub const NodeFS = struct {
}
var entries = std.ArrayList(ExpectedType).init(bun.default_allocator);
- var dir = std.fs.Dir{ .fd = fd };
+ var dir = std.fs.Dir{ .fd = bun.fdcast(fd) };
var iterator = DirIterator.iterate(dir);
var entry = iterator.next();
while (switch (entry) {
@@ -4159,9 +4218,8 @@ pub const NodeFS = struct {
// Only used in DOMFormData
if (args.offset > 0) {
- std.os.lseek_SET(fd, args.offset) catch {};
+ _ = Syscall.setFileOffset(fd, args.offset);
}
-
// For certain files, the size might be 0 but the file might still have contents.
const size = @as(
u64,
@@ -4318,13 +4376,13 @@ pub const NodeFS = struct {
0
else brk: {
// on linux, it's absolutely positioned
- const pos = JSC.Node.Syscall.system.lseek(
+ const pos = bun.sys.system.lseek(
fd,
@as(std.os.off_t, @intCast(0)),
std.os.linux.SEEK.CUR,
);
- switch (JSC.Node.Syscall.getErrno(pos)) {
+ switch (bun.sys.getErrno(pos)) {
.SUCCESS => break :brk @as(usize, @intCast(pos)),
else => break :preallocate,
}
@@ -4551,7 +4609,7 @@ pub const NodeFS = struct {
else => .FAULT,
};
return Maybe(Return.Rm){
- .err = JSC.Node.Syscall.Error.fromCode(errno, .rmdir),
+ .err = bun.sys.Error.fromCode(errno, .rmdir),
};
};
@@ -4617,10 +4675,10 @@ pub const NodeFS = struct {
return Maybe(Return.Rm).success;
}
- } else if (comptime Environment.isLinux) {
+ } else if (comptime Environment.isLinux or Environment.isWindows) {
if (args.recursive) {
std.fs.cwd().deleteTree(args.path.slice()) catch |err| {
- const errno: std.os.E = switch (err) {
+ const errno: E = switch (err) {
error.InvalidHandle => .BADF,
error.AccessDenied => .PERM,
error.FileTooBig => .FBIG,
@@ -4650,15 +4708,15 @@ pub const NodeFS = struct {
return Maybe(Return.Rm).success;
}
return Maybe(Return.Rm){
- .err = JSC.Node.Syscall.Error.fromCode(errno, .unlink),
+ .err = bun.sys.Error.fromCode(errno, .unlink),
};
};
return Maybe(Return.Rm).success;
}
}
- {
- var dest = args.path.sliceZ(&this.sync_error_buf);
+ if (comptime Environment.isPosix) {
+ var dest = args.path.osPath(&this.sync_error_buf);
std.os.unlinkZ(dest) catch |er| {
// empircally, it seems to return AccessDenied when the
// file is actually a directory on macOS.
@@ -4670,7 +4728,7 @@ pub const NodeFS = struct {
return Maybe(Return.Rm).success;
}
- const code: std.os.E = switch (err) {
+ const code: E = switch (err) {
error.AccessDenied => .PERM,
error.SymLinkLoop => .LOOP,
error.NameTooLong => .NAMETOOLONG,
@@ -4684,7 +4742,7 @@ pub const NodeFS = struct {
};
return .{
- .err = JSC.Node.Syscall.Error.fromCode(
+ .err = bun.sys.Error.fromCode(
code,
.rmdir,
),
@@ -4699,7 +4757,7 @@ pub const NodeFS = struct {
}
{
- const code: std.os.E = switch (er) {
+ const code: E = switch (er) {
error.AccessDenied => .PERM,
error.SymLinkLoop => .LOOP,
error.NameTooLong => .NAMETOOLONG,
@@ -4713,7 +4771,66 @@ pub const NodeFS = struct {
};
return .{
- .err = JSC.Node.Syscall.Error.fromCode(
+ .err = bun.sys.Error.fromCode(
+ code,
+ .unlink,
+ ),
+ };
+ }
+ };
+
+ return Maybe(Return.Rm).success;
+ }
+
+ if (comptime Environment.isWindows) {
+ var dest = args.path.osPath(&this.sync_error_buf);
+ std.os.windows.DeleteFile(dest, .{
+ .dir = null,
+ .remove_dir = brk: {
+ const file_attrs = std.os.windows.GetFileAttributesW(dest.ptr) catch |err| {
+ if (args.force) {
+ return Maybe(Return.Rm).success;
+ }
+
+ const code: E = switch (err) {
+ error.FileNotFound => .NOENT,
+ error.PermissionDenied => .PERM,
+ else => .INVAL,
+ };
+
+ return .{
+ .err = bun.sys.Error.fromCode(
+ code,
+ .unlink,
+ ),
+ };
+ };
+ // TODO: check FILE_ATTRIBUTE_INVALID
+ break :brk (file_attrs & std.os.windows.FILE_ATTRIBUTE_DIRECTORY) != 0;
+ },
+ }) catch |er| {
+ // empircally, it seems to return AccessDenied when the
+ // file is actually a directory on macOS.
+
+ if (args.force) {
+ return Maybe(Return.Rm).success;
+ }
+
+ {
+ const code: E = switch (er) {
+ error.FileNotFound => .NOENT,
+ error.AccessDenied => .PERM,
+ error.NameTooLong => .INVAL,
+ error.FileBusy => .BUSY,
+ error.NotDir => .NOTDIR,
+ error.IsDir => .ISDIR,
+ error.DirNotEmpty => .INVAL,
+ error.NetworkNotFound => .NOENT,
+ else => .UNKNOWN,
+ };
+
+ return .{
+ .err = bun.sys.Error.fromCode(
code,
.unlink,
),
@@ -4730,6 +4847,9 @@ pub const NodeFS = struct {
return Maybe(Return.Rm).todo;
}
pub fn stat(this: *NodeFS, args: Arguments.Stat, comptime flavor: Flavor) Maybe(Return.Stat) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Stat).todo;
+ }
_ = flavor;
return @as(Maybe(Return.Stat), switch (Syscall.stat(
@@ -4748,6 +4868,10 @@ pub const NodeFS = struct {
}
pub fn symlink(this: *NodeFS, args: Arguments.Symlink, comptime flavor: Flavor) Maybe(Return.Symlink) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Symlink).todo;
+ }
+
var to_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
switch (comptime flavor) {
@@ -4763,6 +4887,10 @@ pub const NodeFS = struct {
return Maybe(Return.Symlink).todo;
}
fn _truncate(this: *NodeFS, path: PathLike, len: JSC.WebCore.Blob.SizeType, comptime flavor: Flavor) Maybe(Return.Truncate) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Truncate).todo;
+ }
+
switch (comptime flavor) {
.sync => {
return Maybe(Return.Truncate).errno(C.truncate(path.sliceZ(&this.sync_error_buf), len)) orelse
@@ -4787,6 +4915,10 @@ pub const NodeFS = struct {
};
}
pub fn unlink(this: *NodeFS, args: Arguments.Unlink, comptime flavor: Flavor) Maybe(Return.Unlink) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Unlink).todo;
+ }
+
switch (comptime flavor) {
.sync => {
return Maybe(Return.Unlink).errnoSysP(system.unlink(args.path.sliceZ(&this.sync_error_buf)), .unlink, args.path.slice()) orelse
@@ -4801,6 +4933,10 @@ pub const NodeFS = struct {
return Maybe(Return.UnwatchFile).todo;
}
pub fn utimes(this: *NodeFS, args: Arguments.Utimes, comptime flavor: Flavor) Maybe(Return.Utimes) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Utimes).todo;
+ }
+
var times = [2]std.c.timeval{
.{
.tv_sec = args.mtime,
@@ -4829,6 +4965,10 @@ pub const NodeFS = struct {
}
pub fn lutimes(this: *NodeFS, args: Arguments.Lutimes, comptime flavor: Flavor) Maybe(Return.Lutimes) {
+ if (comptime Environment.isWindows) {
+ return Maybe(Return.Lutimes).todo;
+ }
+
var times = [2]std.c.timeval{
.{
.tv_sec = args.mtime,
@@ -4856,6 +4996,11 @@ pub const NodeFS = struct {
return Maybe(Return.Lutimes).todo;
}
pub fn watch(_: *NodeFS, args: Arguments.Watch, comptime _: Flavor) Maybe(Return.Watch) {
+ if (comptime Environment.isWindows) {
+ args.global_this.throwTODO("watch is not supported on Windows yet");
+ return Maybe(Return.Watch){ .result = JSC.JSValue.undefined };
+ }
+
const watcher = args.createFSWatcher() catch |err| {
var buf = std.fmt.allocPrint(bun.default_allocator, "{s} watching {}", .{ @errorName(err), strings.QuotedFormatter{ .text = args.path.slice() } }) catch unreachable;
defer bun.default_allocator.free(buf);
diff --git a/src/bun.js/node/node_os.zig b/src/bun.js/node/node_os.zig
index a4efe4454..07dec1c7d 100644
--- a/src/bun.js/node/node_os.zig
+++ b/src/bun.js/node/node_os.zig
@@ -359,7 +359,12 @@ pub const Os = struct {
pub fn hostname(globalThis: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
JSC.markBinding(@src());
- var name_buffer: [std.os.HOST_NAME_MAX]u8 = undefined;
+ if (comptime Environment.isWindows) {
+ globalThis.throwTODO("hostname() is not implemented on Windows");
+ return .zero;
+ }
+
+ var name_buffer: [bun.HOST_NAME_MAX]u8 = undefined;
return JSC.ZigString.init(std.os.gethostname(&name_buffer) catch "unknown").withEncoding().toValueGC(globalThis);
}
@@ -369,14 +374,18 @@ pub const Os = struct {
const result = C.getSystemLoadavg();
return JSC.JSArray.from(globalThis, &.{
- JSC.JSValue.jsDoubleNumber(result[0]),
- JSC.JSValue.jsDoubleNumber(result[1]),
- JSC.JSValue.jsDoubleNumber(result[2]),
+ JSC.JSValue.jsNumber(result[0]),
+ JSC.JSValue.jsNumber(result[1]),
+ JSC.JSValue.jsNumber(result[2]),
});
}
pub fn networkInterfaces(globalThis: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
JSC.markBinding(@src());
+ if (comptime Environment.isWindows) {
+ globalThis.throwTODO("networkInterfaces() is not implemented on Windows");
+ return .zero;
+ }
// getifaddrs sets a pointer to a linked list
var interface_start: ?*C.ifaddrs = null;
@@ -558,7 +567,7 @@ pub const Os = struct {
pub fn release(globalThis: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
JSC.markBinding(@src());
- var name_buffer: [std.os.HOST_NAME_MAX]u8 = undefined;
+ var name_buffer: [bun.HOST_NAME_MAX]u8 = undefined;
return JSC.ZigString.init(C.getRelease(&name_buffer)).withEncoding().toValueGC(globalThis);
}
@@ -680,7 +689,7 @@ pub const Os = struct {
pub fn version(globalThis: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
JSC.markBinding(@src());
- var name_buffer: [std.os.HOST_NAME_MAX]u8 = undefined;
+ var name_buffer: [bun.HOST_NAME_MAX]u8 = undefined;
return JSC.ZigString.init(C.getVersion(&name_buffer)).withEncoding().toValueGC(globalThis);
}
diff --git a/src/bun.js/node/path_watcher.zig b/src/bun.js/node/path_watcher.zig
index 1f1b9d1a1..4f44a68ff 100644
--- a/src/bun.js/node/path_watcher.zig
+++ b/src/bun.js/node/path_watcher.zig
@@ -437,6 +437,10 @@ pub const PathWatcherManager = struct {
watcher: *PathWatcher,
buf: *[bun.MAX_PATH_BYTES + 1]u8,
) !void {
+ if (comptime Environment.isWindows) {
+ bun.todo(@src(), "implement directory watching on windows");
+ return;
+ }
const manager = this.manager;
const path = this.path;
const fd = path.fd;
@@ -480,6 +484,10 @@ pub const PathWatcherManager = struct {
}
fn run(this: *DirectoryRegisterTask) void {
+ if (comptime Environment.isWindows) {
+ return bun.todo(@src(), {});
+ }
+
var buf: [bun.MAX_PATH_BYTES + 1]u8 = undefined;
while (this.getNext()) |watcher| {
@@ -656,7 +664,7 @@ pub const PathWatcherManager = struct {
var it = this.file_paths.iterator();
while (it.next()) |*entry| {
const path = entry.value_ptr.*;
- std.os.close(path.fd);
+ _ = bun.sys.close(path.fd);
bun.default_allocator.free(path.path);
}
diff --git a/src/bun.js/node/syscall.zig b/src/bun.js/node/syscall.zig
index 13158481f..95c343f1f 100644
--- a/src/bun.js/node/syscall.zig
+++ b/src/bun.js/node/syscall.zig
@@ -15,15 +15,16 @@ const fd_t = bun.FileDescriptor;
const C = @import("root").bun.C;
const linux = os.linux;
const Maybe = JSC.Maybe;
+const kernel32 = bun.windows;
const log = bun.Output.scoped(.SYS, false);
pub const syslog = log;
// On Linux AARCh64, zig is missing stat & lstat syscalls
const use_libc = !(Environment.isLinux and Environment.isX64);
-pub const system = if (Environment.isLinux) linux else @import("root").bun.AsyncIO.darwin;
+pub const system = if (Environment.isLinux) linux else @import("root").bun.AsyncIO.system;
pub const S = struct {
- pub usingnamespace if (Environment.isLinux) linux.S else std.os.S;
+ pub usingnamespace if (Environment.isLinux) linux.S else if (Environment.isPosix) std.os.S else struct {};
};
const sys = std.os.system;
@@ -48,9 +49,11 @@ else if (Environment.isLinux)
else
@compileError("STAT");
+const windows = bun.windows;
+
pub const Tag = enum(u8) {
TODO,
-
+ dup,
access,
chmod,
chown,
@@ -110,6 +113,8 @@ pub const Tag = enum(u8) {
pwritev,
readv,
preadv,
+ NtQueryDirectoryFile,
+
pub var strings = std.EnumMap(Tag, JSC.C.JSStringRef).initFull(null);
};
const PathString = @import("root").bun.PathString;
@@ -130,43 +135,92 @@ pub fn getcwd(buf: *[bun.MAX_PATH_BYTES]u8) Maybe([]const u8) {
Result.errnoSys(0, .getcwd).?;
}
-pub fn fchmod(fd: bun.FileDescriptor, mode: JSC.Node.Mode) Maybe(void) {
+pub fn fchmod(fd_: bun.FileDescriptor, mode: JSC.Node.Mode) Maybe(void) {
+ const fd = bun.fdcast(fd_);
return Maybe(void).errnoSys(C.fchmod(fd, mode), .fchmod) orelse
Maybe(void).success;
}
-pub fn chdir(destination: [:0]const u8) Maybe(void) {
- const rc = sys.chdir(destination);
- return Maybe(void).errnoSys(rc, .chdir) orelse Maybe(void).success;
+pub fn chdirOSPath(destination: bun.OSPathSlice) Maybe(void) {
+ if (comptime Environment.isPosix) {
+ const rc = sys.chdir(destination);
+ return Maybe(void).errnoSys(rc, .chdir) orelse Maybe(void).success;
+ }
+
+ if (comptime Environment.isWindows) {
+ if (kernel32.SetCurrentDirectory(destination) != 0) {
+ return Maybe(void).errnoSys(0, .chdir) orelse Maybe(void).success;
+ }
+
+ return Maybe(void).success;
+ }
+
+ @compileError("Not implemented yet");
+}
+
+pub fn chdir(destination: anytype) Maybe(void) {
+ const Type = @TypeOf(destination);
+
+ if (comptime Environment.isPosix) {
+ if (comptime Type == []u8 or Type == []const u8) {
+ return chdirOSPath(
+ &(std.os.toPosixPath(destination) catch return .{ .err = .{
+ .errno = @intFromEnum(bun.C.SystemErrno.EINVAL),
+ .syscall = .chdir,
+ } }),
+ );
+ }
+
+ return chdirOSPath(destination);
+ }
+
+ if (comptime Environment.isWindows) {
+ if (comptime Type == bun.OSPathSlice or Type == [:0]u16) {
+ return chdirOSPath(@as(bun.OSPathSlice, destination));
+ }
+
+ if (comptime Type == *[*:0]u16) {
+ if (kernel32.SetCurrentDirectory(destination) != 0) {
+ return Maybe(void).errnoSys(0, .chdir) orelse Maybe(void).success;
+ }
+
+ return Maybe(void).success;
+ }
+
+ var wbuf: bun.MAX_WPATH = undefined;
+ return chdirOSPath(bun.strings.toWPath(&wbuf, destination));
+ }
+
+ return Maybe(void).todo;
}
-pub fn stat(path: [:0]const u8) Maybe(os.Stat) {
- var stat_ = mem.zeroes(os.Stat);
+pub fn stat(path: [:0]const u8) Maybe(bun.Stat) {
+ var stat_ = mem.zeroes(bun.Stat);
const rc = statSym(path, &stat_);
if (comptime Environment.allow_assert)
log("stat({s}) = {d}", .{ bun.asByteSlice(path), rc });
- if (Maybe(os.Stat).errnoSys(rc, .stat)) |err| return err;
- return Maybe(os.Stat){ .result = stat_ };
+ if (Maybe(bun.Stat).errnoSys(rc, .stat)) |err| return err;
+ return Maybe(bun.Stat){ .result = stat_ };
}
-pub fn lstat(path: [:0]const u8) Maybe(os.Stat) {
- var stat_ = mem.zeroes(os.Stat);
- if (Maybe(os.Stat).errnoSys(lstat64(path, &stat_), .lstat)) |err| return err;
- return Maybe(os.Stat){ .result = stat_ };
+pub fn lstat(path: [:0]const u8) Maybe(bun.Stat) {
+ var stat_ = mem.zeroes(bun.Stat);
+ if (Maybe(bun.Stat).errnoSys(lstat64(path, &stat_), .lstat)) |err| return err;
+ return Maybe(bun.Stat){ .result = stat_ };
}
-pub fn fstat(fd: bun.FileDescriptor) Maybe(os.Stat) {
- var stat_ = mem.zeroes(os.Stat);
+pub fn fstat(fd: bun.FileDescriptor) Maybe(bun.Stat) {
+ var stat_ = mem.zeroes(bun.Stat);
const rc = fstatSym(fd, &stat_);
if (comptime Environment.allow_assert)
log("fstat({d}) = {d}", .{ fd, rc });
- if (Maybe(os.Stat).errnoSys(rc, .fstat)) |err| return err;
- return Maybe(os.Stat){ .result = stat_ };
+ if (Maybe(bun.Stat).errnoSys(rc, .fstat)) |err| return err;
+ return Maybe(bun.Stat){ .result = stat_ };
}
pub fn mkdir(file_path: [:0]const u8, flags: JSC.Node.Mode) Maybe(void) {
@@ -177,16 +231,29 @@ pub fn mkdir(file_path: [:0]const u8, flags: JSC.Node.Mode) Maybe(void) {
if (comptime Environment.isLinux) {
return Maybe(void).errnoSysP(linux.mkdir(file_path, flags), .mkdir, file_path) orelse Maybe(void).success;
}
+ var wbuf: bun.MAX_WPATH = undefined;
+ _ = kernel32.CreateDirectoryW(bun.strings.toWPath(&wbuf, file_path).ptr, null);
+
+ return Maybe(void).errnoSysP(0, .mkdir, file_path) orelse Maybe(void).success;
}
-pub fn fcntl(fd: bun.FileDescriptor, cmd: i32, arg: usize) Maybe(usize) {
+pub fn fcntl(fd_: bun.FileDescriptor, cmd: i32, arg: usize) Maybe(usize) {
+ const fd = bun.fdcast(fd_);
const result = fcntl_symbol(fd, cmd, arg);
if (Maybe(usize).errnoSys(result, .fcntl)) |err| return err;
return .{ .result = @as(usize, @intCast(result)) };
}
-pub fn getErrno(rc: anytype) std.os.E {
- if (comptime Environment.isMac) return std.os.errno(rc);
+pub fn getErrno(rc: anytype) bun.C.E {
+ if (comptime Environment.isWindows) {
+ if (bun.windows.Win32Error.get().toSystemErrno()) |e| {
+ return e.toE();
+ }
+
+ return bun.C.E.UNKNOWN;
+ }
+
+ if (comptime use_libc) return std.os.errno(rc);
const Type = @TypeOf(rc);
return switch (Type) {
@@ -196,7 +263,139 @@ pub fn getErrno(rc: anytype) std.os.E {
};
}
-pub fn openat(dirfd: bun.FileDescriptor, file_path: [:0]const u8, flags: JSC.Node.Mode, perm: JSC.Node.Mode) Maybe(bun.FileDescriptor) {
+// pub fn openOptionsFromFlagsWindows(flags: u32) windows.OpenFileOptions {
+// const w = windows;
+// const O = std.os.O;
+
+// var access_mask: w.ULONG = w.READ_CONTROL | w.FILE_WRITE_ATTRIBUTES | w.SYNCHRONIZE;
+// if (flags & O.RDWR != 0) {
+// access_mask |= w.GENERIC_READ | w.GENERIC_WRITE;
+// } else if (flags & O.WRONLY != 0) {
+// access_mask |= w.GENERIC_WRITE;
+// } else {
+// access_mask |= w.GENERIC_READ | w.GENERIC_WRITE;
+// }
+
+// const filter: windows.OpenFileOptions.Filter = if (flags & O.DIRECTORY != 0) .dir_only else .file_only;
+// const follow_symlinks: bool = flags & O.NOFOLLOW == 0;
+
+// const creation: w.ULONG = blk: {
+// if (flags & O.CREAT != 0) {
+// if (flags & O.EXCL != 0) {
+// break :blk w.FILE_CREATE;
+// }
+// }
+// break :blk w.FILE_OPEN;
+// };
+
+// return .{
+// .access_mask = access_mask,
+// .io_mode = .blocking,
+// .creation = creation,
+// .filter = filter,
+// .follow_symlinks = follow_symlinks,
+// };
+// }
+const O = std.os.O;
+const w = std.os.windows;
+
+pub fn openatWindows(dirfD: bun.FileDescriptor, path: []const u16, flags: JSC.Node.Mode) Maybe(bun.FileDescriptor) {
+ const nonblock = flags & O.NONBLOCK != 0;
+
+ var access_mask: w.ULONG = w.READ_CONTROL | w.FILE_WRITE_ATTRIBUTES | w.SYNCHRONIZE;
+
+ if (flags & O.RDWR != 0) {
+ access_mask |= w.GENERIC_READ | w.GENERIC_WRITE;
+ } else if (flags & O.WRONLY != 0) {
+ access_mask |= w.GENERIC_WRITE;
+ } else if (flags & O.APPEND != 0) {
+ access_mask |= w.FILE_APPEND_DATA;
+ } else {
+ access_mask |= w.GENERIC_READ;
+ }
+
+ var result: windows.HANDLE = undefined;
+
+ const path_len_bytes = std.math.cast(u16, path.len * 2) orelse return .{
+ .err = .{
+ .errno = @intFromEnum(bun.C.E.NOMEM),
+ .syscall = .open,
+ },
+ };
+ var nt_name = windows.UNICODE_STRING{
+ .Length = path_len_bytes,
+ .MaximumLength = path_len_bytes,
+ .Buffer = @constCast(path.ptr),
+ };
+ var attr = windows.OBJECT_ATTRIBUTES{
+ .Length = @sizeOf(windows.OBJECT_ATTRIBUTES),
+ .RootDirectory = if (dirfD == bun.invalid_fd or std.fs.path.isAbsoluteWindowsWTF16(path)) null else bun.fdcast(dirfD),
+ .Attributes = 0, // Note we do not use OBJ_CASE_INSENSITIVE here.
+ .ObjectName = &nt_name,
+ .SecurityDescriptor = null,
+ .SecurityQualityOfService = null,
+ };
+ var io: windows.IO_STATUS_BLOCK = undefined;
+ const blocking_flag: windows.ULONG = if (!nonblock) windows.FILE_SYNCHRONOUS_IO_NONALERT else 0;
+ const file_or_dir_flag: windows.ULONG = switch (flags & O.DIRECTORY != 0) {
+ // .file_only => windows.FILE_NON_DIRECTORY_FILE,
+ true => windows.FILE_DIRECTORY_FILE,
+ false => 0,
+ };
+ const follow_symlinks = flags & O.NOFOLLOW == 0;
+ const creation: w.ULONG = blk: {
+ if (flags & O.CREAT != 0) {
+ if (flags & O.EXCL != 0) {
+ break :blk w.FILE_CREATE;
+ }
+ }
+ break :blk w.FILE_OPEN;
+ };
+
+ const wflags: windows.ULONG = if (follow_symlinks) file_or_dir_flag | blocking_flag else file_or_dir_flag | windows.FILE_OPEN_REPARSE_POINT;
+
+ while (true) {
+ const rc = windows.ntdll.NtCreateFile(
+ &result,
+ access_mask,
+ &attr,
+ &io,
+ null,
+ w.FILE_ATTRIBUTE_NORMAL,
+ w.FILE_SHARE_WRITE | w.FILE_SHARE_READ | w.FILE_SHARE_DELETE,
+ creation,
+ wflags,
+ null,
+ 0,
+ );
+ switch (windows.Win32Error.fromNTStatus(rc)) {
+ .SUCCESS => {
+ return JSC.Maybe(bun.FileDescriptor){
+ .result = bun.toFD(result),
+ };
+ },
+ else => |code| {
+ if (code.toSystemErrno()) |sys_err| {
+ return .{
+ .err = .{
+ .errno = @truncate(@intFromEnum(sys_err)),
+ .syscall = .open,
+ },
+ };
+ }
+
+ return .{
+ .err = .{
+ .errno = @intFromEnum(bun.C.E.UNKNOWN),
+ .syscall = .open,
+ },
+ };
+ },
+ }
+ }
+}
+
+pub fn openatOSPath(dirfd: bun.FileDescriptor, file_path: bun.OSPathSlice, flags: JSC.Node.Mode, perm: JSC.Node.Mode) Maybe(bun.FileDescriptor) {
if (comptime Environment.isMac) {
// https://opensource.apple.com/source/xnu/xnu-7195.81.3/libsyscall/wrappers/open-base.c
const rc = bun.AsyncIO.darwin.@"openat$NOCANCEL"(dirfd, file_path.ptr, @as(c_uint, @intCast(flags)), @as(c_int, @intCast(perm)));
@@ -213,6 +412,10 @@ pub fn openat(dirfd: bun.FileDescriptor, file_path: [:0]const u8, flags: JSC.Nod
};
}
+ if (comptime Environment.isWindows) {
+ return openatWindows(dirfd, file_path, flags);
+ }
+
while (true) {
const rc = Syscall.system.openat(@as(Syscall.system.fd_t, @intCast(dirfd)), file_path, flags, perm);
log("openat({d}, {s}) = {d}", .{ dirfd, file_path, rc });
@@ -233,14 +436,23 @@ pub fn openat(dirfd: bun.FileDescriptor, file_path: [:0]const u8, flags: JSC.Nod
unreachable;
}
+pub fn openat(dirfd: bun.FileDescriptor, file_path: [:0]const u8, flags: JSC.Node.Mode, perm: JSC.Node.Mode) Maybe(bun.FileDescriptor) {
+ if (comptime Environment.isWindows) {
+ var wbuf: bun.MAX_WPATH = undefined;
+ return openatWindows(dirfd, bun.strings.toWPath(&wbuf, file_path), flags);
+ }
+
+ return openatOSPath(dirfd, file_path, flags, perm);
+}
+
pub fn open(file_path: [:0]const u8, flags: JSC.Node.Mode, perm: JSC.Node.Mode) Maybe(bun.FileDescriptor) {
// this is what open() does anyway.
- return openat(@as(bun.FileDescriptor, @intCast(std.fs.cwd().fd)), file_path, flags, perm);
+ return openat(bun.toFD((std.fs.cwd().fd)), file_path, flags, perm);
}
/// This function will prevent stdout and stderr from being closed.
-pub fn close(fd: std.os.fd_t) ?Syscall.Error {
- if (fd == std.os.STDOUT_FILENO or fd == std.os.STDERR_FILENO) {
+pub fn close(fd: bun.FileDescriptor) ?Syscall.Error {
+ if (fd == bun.STDOUT_FD or fd == bun.STDERR_FD) {
log("close({d}) SKIPPED", .{fd});
return null;
}
@@ -248,7 +460,7 @@ pub fn close(fd: std.os.fd_t) ?Syscall.Error {
return closeAllowingStdoutAndStderr(fd);
}
-pub fn closeAllowingStdoutAndStderr(fd: std.os.fd_t) ?Syscall.Error {
+pub fn closeAllowingStdoutAndStderr(fd: bun.FileDescriptor) ?Syscall.Error {
log("close({d})", .{fd});
std.debug.assert(fd != bun.invalid_fd);
if (comptime std.meta.trait.isSignedInt(@TypeOf(fd)))
@@ -269,6 +481,14 @@ pub fn closeAllowingStdoutAndStderr(fd: std.os.fd_t) ?Syscall.Error {
};
}
+ if (comptime Environment.isWindows) {
+ if (kernel32.CloseHandle(bun.fdcast(fd)) == 0) {
+ return Syscall.Error{ .errno = @intFromEnum(os.E.BADF), .syscall = .close };
+ }
+
+ return null;
+ }
+
@compileError("Not implemented yet");
}
@@ -278,7 +498,8 @@ const max_count = switch (builtin.os.tag) {
else => std.math.maxInt(isize),
};
-pub fn write(fd: os.fd_t, bytes: []const u8) Maybe(usize) {
+pub fn write(fd_: bun.FileDescriptor, bytes: []const u8) Maybe(usize) {
+ const fd = bun.fdcast(fd_);
const adjusted_len = @min(max_count, bytes.len);
if (comptime Environment.isMac) {
@@ -314,7 +535,8 @@ fn veclen(buffers: anytype) usize {
return len;
}
-pub fn writev(fd: os.fd_t, buffers: []std.os.iovec) Maybe(usize) {
+pub fn writev(fd_: bun.FileDescriptor, buffers: []std.os.iovec) Maybe(usize) {
+ const fd = bun.fdcast(fd_);
if (comptime Environment.isMac) {
const rc = writev_sym(fd, @as([*]std.os.iovec_const, @ptrCast(buffers.ptr)), @as(i32, @intCast(buffers.len)));
if (comptime Environment.allow_assert)
@@ -342,7 +564,8 @@ pub fn writev(fd: os.fd_t, buffers: []std.os.iovec) Maybe(usize) {
}
}
-pub fn pwritev(fd: os.fd_t, buffers: []std.os.iovec, position: isize) Maybe(usize) {
+pub fn pwritev(fd_: bun.FileDescriptor, buffers: []std.os.iovec, position: isize) Maybe(usize) {
+ const fd = bun.fdcast(fd_);
if (comptime Environment.isMac) {
const rc = pwritev_sym(fd, @as([*]std.os.iovec_const, @ptrCast(buffers.ptr)), @as(i32, @intCast(buffers.len)), position);
if (comptime Environment.allow_assert)
@@ -370,7 +593,8 @@ pub fn pwritev(fd: os.fd_t, buffers: []std.os.iovec, position: isize) Maybe(usiz
}
}
-pub fn readv(fd: os.fd_t, buffers: []std.os.iovec) Maybe(usize) {
+pub fn readv(fd_: bun.FileDescriptor, buffers: []std.os.iovec) Maybe(usize) {
+ const fd = bun.fdcast(fd_);
if (comptime Environment.isMac) {
const rc = readv_sym(fd, buffers.ptr, @as(i32, @intCast(buffers.len)));
if (comptime Environment.allow_assert)
@@ -398,7 +622,8 @@ pub fn readv(fd: os.fd_t, buffers: []std.os.iovec) Maybe(usize) {
}
}
-pub fn preadv(fd: os.fd_t, buffers: []std.os.iovec, position: isize) Maybe(usize) {
+pub fn preadv(fd_: bun.FileDescriptor, buffers: []std.os.iovec, position: isize) Maybe(usize) {
+ const fd = bun.fdcast(fd_);
if (comptime Environment.isMac) {
const rc = preadv_sym(fd, buffers.ptr, @as(i32, @intCast(buffers.len)), position);
if (comptime Environment.allow_assert)
@@ -463,8 +688,10 @@ else
const fcntl_symbol = system.fcntl;
-pub fn pread(fd: os.fd_t, buf: []u8, offset: i64) Maybe(usize) {
+pub fn pread(fd_: bun.FileDescriptor, buf: []u8, offset: i64) Maybe(usize) {
+ const fd = bun.fdcast(fd_);
const adjusted_len = @min(buf.len, max_count);
+
const ioffset = @as(i64, @bitCast(offset)); // the OS treats this as unsigned
while (true) {
const rc = pread_sym(fd, buf.ptr, adjusted_len, ioffset);
@@ -482,7 +709,8 @@ const pwrite_sym = if (builtin.os.tag == .linux and builtin.link_libc)
else
sys.pwrite;
-pub fn pwrite(fd: os.fd_t, bytes: []const u8, offset: i64) Maybe(usize) {
+pub fn pwrite(fd_: bun.FileDescriptor, bytes: []const u8, offset: i64) Maybe(usize) {
+ const fd = bun.fdcast(fd_);
const adjusted_len = @min(bytes.len, max_count);
const ioffset = @as(i64, @bitCast(offset)); // the OS treats this as unsigned
@@ -499,7 +727,8 @@ pub fn pwrite(fd: os.fd_t, bytes: []const u8, offset: i64) Maybe(usize) {
unreachable;
}
-pub fn read(fd: os.fd_t, buf: []u8) Maybe(usize) {
+pub fn read(fd_: bun.FileDescriptor, buf: []u8) Maybe(usize) {
+ const fd = bun.fdcast(fd_);
const debug_timer = bun.Output.DebugTimer.start();
const adjusted_len = @min(buf.len, max_count);
if (comptime Environment.isMac) {
@@ -526,7 +755,8 @@ pub fn read(fd: os.fd_t, buf: []u8) Maybe(usize) {
unreachable;
}
-pub fn recv(fd: os.fd_t, buf: []u8, flag: u32) Maybe(usize) {
+pub fn recv(fd_: bun.FileDescriptor, buf: []u8, flag: u32) Maybe(usize) {
+ const fd = bun.fdcast(fd_);
const adjusted_len = @min(buf.len, max_count);
if (comptime Environment.isMac) {
@@ -553,7 +783,8 @@ pub fn recv(fd: os.fd_t, buf: []u8, flag: u32) Maybe(usize) {
unreachable;
}
-pub fn send(fd: os.fd_t, buf: []const u8, flag: u32) Maybe(usize) {
+pub fn send(fd_: bun.FileDescriptor, buf: []const u8, flag: u32) Maybe(usize) {
+ const fd = bun.fdcast(fd_);
if (comptime Environment.isMac) {
const rc = system.@"sendto$NOCANCEL"(fd, buf.ptr, buf.len, flag, null, 0);
if (Maybe(usize).errnoSys(rc, .send)) |err| {
@@ -589,6 +820,13 @@ pub fn readlink(in: [:0]const u8, buf: []u8) Maybe(usize) {
}
pub fn ftruncate(fd: fd_t, size: isize) Maybe(void) {
+ if (comptime Environment.isWindows) {
+ if (kernel32.SetFileValidData(bun.fdcast(fd), size) == 0) {
+ return Maybe(void).errnoSys(0, .ftruncate) orelse Maybe(void).success;
+ }
+
+ return Maybe(void).success;
+ }
while (true) {
if (Maybe(void).errnoSys(sys.ftruncate(fd, size), .ftruncate)) |err| {
if (err.getErrno() == .INTR) continue;
@@ -682,18 +920,17 @@ pub fn unlink(from: [:0]const u8) Maybe(void) {
unreachable;
}
-pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) Maybe([]u8) {
+pub fn getFdPath(fd_: bun.FileDescriptor, out_buffer: *[MAX_PATH_BYTES]u8) Maybe([]u8) {
+ const fd = bun.fdcast(fd_);
switch (comptime builtin.os.tag) {
.windows => {
- const windows = std.os.windows;
var wide_buf: [windows.PATH_MAX_WIDE]u16 = undefined;
- const wide_slice = windows.GetFinalPathNameByHandle(fd, .{}, wide_buf[0..]) catch {
- return Maybe([]u8){ .err = .{ .errno = .EBADF } };
+ const wide_slice = std.os.windows.GetFinalPathNameByHandle(fd, .{}, wide_buf[0..]) catch {
+ return Maybe([]u8){ .err = .{ .errno = @intFromEnum(bun.C.SystemErrno.EBADF) } };
};
// Trust that Windows gives us valid UTF-16LE.
- const end_index = std.unicode.utf16leToUtf8(out_buffer, wide_slice) catch unreachable;
- return .{ .result = out_buffer[0..end_index] };
+ return .{ .result = @constCast(bun.strings.fromWPath(out_buffer, wide_slice)) };
},
.macos, .ios, .watchos, .tvos => {
// On macOS, we can use F.GETPATH fcntl command to query the OS for
@@ -738,9 +975,10 @@ fn mmap(
length: usize,
prot: u32,
flags: u32,
- fd: os.fd_t,
+ fd_: bun.FileDescriptor,
offset: u64,
) Maybe([]align(mem.page_size) u8) {
+ const fd = bun.fdcast(fd_);
const ioffset = @as(i64, @bitCast(offset)); // the OS treats this as unsigned
const rc = std.c.mmap(ptr, length, prot, flags, fd, ioffset);
const fail = std.c.MAP.FAILED;
@@ -793,9 +1031,10 @@ pub fn munmap(memory: []align(mem.page_size) const u8) Maybe(void) {
}
pub const Error = struct {
+ const E = bun.C.E;
const max_errno_value = brk: {
- const errno_values = std.enums.values(os.E);
- var err = @intFromEnum(os.E.SUCCESS);
+ const errno_values = std.enums.values(E);
+ var err = @intFromEnum(E.SUCCESS);
for (errno_values) |errn| {
err = @max(err, @intFromEnum(errn));
}
@@ -806,13 +1045,13 @@ pub const Error = struct {
errno: Int,
syscall: Syscall.Tag = @as(Syscall.Tag, @enumFromInt(0)),
path: []const u8 = "",
- fd: i32 = -1,
+ fd: bun.FileDescriptor = bun.invalid_fd,
pub inline fn isRetry(this: *const Error) bool {
return this.getErrno() == .AGAIN;
}
- pub fn fromCode(errno: os.E, syscall: Syscall.Tag) Error {
+ pub fn fromCode(errno: E, syscall: Syscall.Tag) Error {
return .{ .errno = @as(Int, @truncate(@intFromEnum(errno))), .syscall = syscall };
}
@@ -820,20 +1059,20 @@ pub const Error = struct {
try self.toSystemError().format(fmt, opts, writer);
}
- pub const oom = fromCode(os.E.NOMEM, .read);
+ pub const oom = fromCode(E.NOMEM, .read);
pub const retry = Error{
.errno = if (Environment.isLinux)
- @as(Int, @intCast(@intFromEnum(os.E.AGAIN)))
+ @as(Int, @intCast(@intFromEnum(E.AGAIN)))
else if (Environment.isMac)
- @as(Int, @intCast(@intFromEnum(os.E.WOULDBLOCK)))
+ @as(Int, @intCast(@intFromEnum(E.WOULDBLOCK)))
else
- @as(Int, @intCast(@intFromEnum(os.E.INTR))),
+ @as(Int, @intCast(@intFromEnum(E.INTR))),
.syscall = .retry,
};
- pub inline fn getErrno(this: Error) os.E {
- return @as(os.E, @enumFromInt(this.errno));
+ pub inline fn getErrno(this: Error) E {
+ return @as(E, @enumFromInt(this.errno));
}
pub inline fn withPath(this: Error, path: anytype) Error {
@@ -848,7 +1087,7 @@ pub const Error = struct {
return Error{
.errno = this.errno,
.syscall = this.syscall,
- .fd = @as(i32, @intCast(fd)),
+ .fd = @intCast(fd),
};
}
@@ -889,8 +1128,10 @@ pub const Error = struct {
err.path = bun.String.create(this.path);
}
- if (this.fd != -1) {
- err.fd = this.fd;
+ if (this.fd != bun.invalid_fd) {
+ if (this.fd <= std.math.maxInt(i32)) {
+ err.fd = @intCast(this.fd);
+ }
}
return err;
@@ -905,7 +1146,8 @@ pub const Error = struct {
}
};
-pub fn setPipeCapacityOnLinux(fd: bun.FileDescriptor, capacity: usize) Maybe(usize) {
+pub fn setPipeCapacityOnLinux(fd_: bun.FileDescriptor, capacity: usize) Maybe(usize) {
+ const fd = bun.fdcast(fd_);
if (comptime !Environment.isLinux) @compileError("Linux-only");
std.debug.assert(capacity > 0);
@@ -941,16 +1183,16 @@ pub fn getMaxPipeSizeOnLinux() usize {
fn once() c_int {
const strings = bun.strings;
const default_out_size = 512 * 1024;
- const pipe_max_size_fd = switch (JSC.Node.Syscall.open("/proc/sys/fs/pipe-max-size", std.os.O.RDONLY, 0)) {
+ const pipe_max_size_fd = switch (bun.sys.open("/proc/sys/fs/pipe-max-size", std.os.O.RDONLY, 0)) {
.result => |fd2| fd2,
.err => |err| {
log("Failed to open /proc/sys/fs/pipe-max-size: {d}\n", .{err.errno});
return default_out_size;
},
};
- defer _ = JSC.Node.Syscall.close(pipe_max_size_fd);
+ defer _ = bun.sys.close(pipe_max_size_fd);
var max_pipe_size_buf: [128]u8 = undefined;
- const max_pipe_size = switch (JSC.Node.Syscall.read(pipe_max_size_fd, max_pipe_size_buf[0..])) {
+ const max_pipe_size = switch (bun.sys.read(pipe_max_size_fd, max_pipe_size_buf[0..])) {
.result => |bytes_read| std.fmt.parseInt(i64, strings.trim(max_pipe_size_buf[0..bytes_read], "\n"), 10) catch |err| {
log("Failed to parse /proc/sys/fs/pipe-max-size: {any}\n", .{@errorName(err)});
return default_out_size;
@@ -968,3 +1210,126 @@ pub fn getMaxPipeSizeOnLinux() usize {
}.once, c_int)),
);
}
+
+pub fn existsOSPath(path: bun.OSPathSlice) bool {
+ if (comptime Environment.isPosix) {
+ return system.access(path, 0) == 0;
+ }
+
+ if (comptime Environment.isWindows) {
+ const rc = kernel32.GetFileAttributesW(path) != windows.INVALID_FILE_ATTRIBUTES;
+ if (rc == windows.FALSE) {
+ return false;
+ }
+ return true;
+ }
+
+ @compileError("TODO: existsOSPath");
+}
+
+pub fn isExecutableFileOSPath(path: bun.OSPathSlice) bool {
+ if (comptime Environment.isPosix) {
+ return bun.is_executable_fileZ(path);
+ }
+
+ if (comptime Environment.isWindows) {
+ var out: windows.DWORD = 8;
+ const rc = kernel32.GetBinaryTypeW(path, &out);
+ log("GetBinaryTypeW({}) = {d}", .{ bun.String.init(path), out });
+
+ if (rc == windows.FALSE) {
+ return false;
+ }
+
+ return switch (out) {
+ kernel32.SCS_32BIT_BINARY,
+ kernel32.SCS_64BIT_BINARY,
+ kernel32.SCS_DOS_BINARY,
+ kernel32.SCS_OS216_BINARY,
+ kernel32.SCS_PIF_BINARY,
+ kernel32.SCS_POSIX_BINARY,
+ => true,
+ else => false,
+ };
+ }
+
+ @compileError("TODO: isExecutablePath");
+}
+
+pub fn isExecutableFilePath(path: anytype) bool {
+ const Type = @TypeOf(path);
+ if (comptime Environment.isPosix) {
+ switch (Type) {
+ *[*:0]const u8, *[*:0]u8, [*:0]const u8, [*:0]u8 => return bun.is_executable_fileZ(path),
+ [:0]const u8, [:0]u8 => return bun.is_executable_fileZ(path.ptr),
+ []const u8, []u8 => return bun.is_executable_fileZ(&(std.os.toPosixPath(path) catch return false)),
+ else => @compileError("TODO: isExecutableFilePath"),
+ }
+ }
+
+ if (comptime Environment.isWindows) {
+ var buf: [(bun.MAX_PATH_BYTES / 2) + 1]u16 = undefined;
+ return isExecutableFileOSPath(bun.strings.toWPath(&buf, path));
+ }
+
+ @compileError("TODO: isExecutablePath");
+}
+
+pub fn setFileOffset(fd: bun.FileDescriptor, offset: usize) Maybe(void) {
+ if (comptime Environment.isLinux) {
+ return Maybe(void).errnoSysFd(
+ linux.lseek(@intCast(fd), @intCast(offset), os.SEEK.SET),
+ .lseek,
+ @as(bun.FileDescriptor, @intCast(fd)),
+ ) orelse Maybe(void).success;
+ }
+
+ if (comptime Environment.isMac) {
+ return Maybe(void).errnoSysFd(
+ std.c.lseek(fd, @as(std.c.off_t, @intCast(offset)), os.SEEK.SET),
+ .lseek,
+ @as(bun.FileDescriptor, @intCast(fd)),
+ ) orelse Maybe(void).success;
+ }
+
+ if (comptime Environment.isWindows) {
+ const offset_high: u64 = @as(u32, @intCast(offset >> 32));
+ const offset_low: u64 = @as(u32, @intCast(offset & 0xFFFFFFFF));
+ var plarge_integer: i64 = @bitCast(offset_high);
+ const rc = kernel32.SetFilePointerEx(
+ bun.fdcast(fd),
+ @as(windows.LARGE_INTEGER, @bitCast(offset_low)),
+ &plarge_integer,
+ windows.FILE_BEGIN,
+ );
+ if (rc == windows.FALSE) {
+ return Maybe(void).errnoSys(0, .lseek) orelse Maybe(void).success;
+ }
+ return Maybe(void).success;
+ }
+}
+
+pub fn dup(fd: bun.FileDescriptor) Maybe(bun.FileDescriptor) {
+ if (comptime Environment.isWindows) {
+ var target: *windows.HANDLE = undefined;
+ const process = kernel32.GetCurrentProcess();
+ const out = kernel32.DuplicateHandle(
+ process,
+ bun.fdcast(fd),
+ process,
+ target,
+ 0,
+ w.TRUE,
+ w.DUPLICATE_SAME_ACCESS,
+ );
+ if (out == 0) {
+ if (Maybe(bun.FileDescriptor).errnoSysFd(0, .dup, fd)) |err| {
+ return err;
+ }
+ }
+ return Maybe(bun.FileDescriptor){ .result = bun.toFD(out) };
+ }
+
+ const out = std.c.dup(fd);
+ return Maybe(bun.FileDescriptor).errnoSysFd(out, .dup, fd) orelse Maybe(bun.FileDescriptor){ .result = bun.toFD(out) };
+}
diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig
index 6c4ee9f51..51094d629 100644
--- a/src/bun.js/node/types.zig
+++ b/src/bun.js/node/types.zig
@@ -20,7 +20,7 @@ const is_bindgen: bool = std.meta.globalOption("bindgen", bool) orelse false;
const meta = bun.meta;
/// Time in seconds. Not nanos!
pub const TimeLike = c_int;
-pub const Mode = if (Environment.isLinux) u32 else std.os.mode_t;
+pub const Mode = bun.C.Mode;
const heap_allocator = bun.default_allocator;
pub fn DeclEnum(comptime T: type) type {
const fieldInfos = std.meta.declarations(T);
@@ -83,6 +83,12 @@ pub fn Maybe(comptime ResultType: type) type {
pub const todo: @This() = @This(){ .err = Syscall.Error.todo };
+ pub fn throw(this: @This()) !void {
+ if (this == .err) {
+ return bun.AsyncIO.asError(this.err.errno);
+ }
+ }
+
pub fn toJS(this: @This(), globalThis: *JSC.JSGlobalObject) JSC.JSValue {
switch (this) {
.err => |e| {
@@ -171,7 +177,7 @@ pub fn Maybe(comptime ResultType: type) type {
.err = .{
.errno = @as(Syscall.Error.Int, @truncate(@intFromEnum(err))),
.syscall = syscall,
- .fd = @as(i32, @intCast(fd)),
+ .fd = @intCast(bun.toFD(fd)),
},
},
};
@@ -687,6 +693,18 @@ pub const PathLike = union(Tag) {
return sliceZWithForceCopy(this, buf, false);
}
+ pub inline fn sliceW(this: PathLike, buf: *[bun.MAX_PATH_BYTES]u8) [:0]const u16 {
+ return bun.strings.toWPath(@alignCast(std.mem.bytesAsSlice(u16, buf)), this.slice());
+ }
+
+ pub inline fn osPath(this: PathLike, buf: *[bun.MAX_PATH_BYTES]u8) bun.OSPathSlice {
+ if (comptime Environment.isWindows) {
+ return sliceW(this, buf);
+ }
+
+ return sliceZWithForceCopy(this, buf, false);
+ }
+
pub inline fn sliceZAssume(
this: PathLike,
) [:0]const u8 {
@@ -772,7 +790,7 @@ pub const PathLike = union(Tag) {
};
pub const Valid = struct {
- pub fn fileDescriptor(fd: bun.FileDescriptor, ctx: JSC.C.JSContextRef, exception: JSC.C.ExceptionRef) bool {
+ pub fn fileDescriptor(fd: i64, ctx: JSC.C.JSContextRef, exception: JSC.C.ExceptionRef) bool {
if (fd < 0) {
JSC.throwInvalidArguments("Invalid file descriptor, must not be negative number", .{}, ctx, exception);
return false;
@@ -985,12 +1003,12 @@ pub const ArgumentsSlice = struct {
pub fn fileDescriptorFromJS(ctx: JSC.C.JSContextRef, value: JSC.JSValue, exception: JSC.C.ExceptionRef) ?bun.FileDescriptor {
if (!value.isNumber() or value.isBigInt()) return null;
- const fd = value.toInt32();
+ const fd = value.toInt64();
if (!Valid.fileDescriptor(fd, ctx, exception)) {
return null;
}
- return @as(bun.FileDescriptor, @truncate(fd));
+ return @as(bun.FileDescriptor, @intCast(fd));
}
// Node.js docs:
@@ -1427,26 +1445,46 @@ pub fn StatType(comptime Big: bool) type {
}
pub fn isBlockDevice(this: *This) JSC.JSValue {
+ if (comptime Environment.isWindows) {
+ JSC.VirtualMachine.get().global.throwTODO(comptime @src().fn_name ++ " is not implemented yet");
+ return .zero;
+ }
return JSC.JSValue.jsBoolean(os.S.ISBLK(@as(Mode, @intCast(this.modeInternal()))));
}
pub fn isCharacterDevice(this: *This) JSC.JSValue {
+ if (comptime Environment.isWindows) {
+ JSC.VirtualMachine.get().global.throwTODO(comptime @src().fn_name ++ " is not implemented yet");
+ return .zero;
+ }
return JSC.JSValue.jsBoolean(os.S.ISCHR(@as(Mode, @intCast(this.modeInternal()))));
}
pub fn isDirectory(this: *This) JSC.JSValue {
+ if (comptime Environment.isWindows) {
+ JSC.VirtualMachine.get().global.throwTODO(comptime @src().fn_name ++ " is not implemented yet");
+ return .zero;
+ }
return JSC.JSValue.jsBoolean(os.S.ISDIR(@as(Mode, @intCast(this.modeInternal()))));
}
pub fn isFIFO(this: *This) JSC.JSValue {
+ if (comptime Environment.isWindows) {
+ JSC.VirtualMachine.get().global.throwTODO(comptime @src().fn_name ++ " is not implemented yet");
+ return .zero;
+ }
return JSC.JSValue.jsBoolean(os.S.ISFIFO(@as(Mode, @intCast(this.modeInternal()))));
}
pub fn isFile(this: *This) JSC.JSValue {
- return JSC.JSValue.jsBoolean(os.S.ISREG(@as(Mode, @intCast(this.modeInternal()))));
+ return JSC.JSValue.jsBoolean(bun.isRegularFile(@as(Mode, @intCast(this.modeInternal()))));
}
pub fn isSocket(this: *This) JSC.JSValue {
+ if (comptime Environment.isWindows) {
+ JSC.VirtualMachine.get().global.throwTODO(comptime @src().fn_name ++ " is not implemented yet");
+ return .zero;
+ }
return JSC.JSValue.jsBoolean(os.S.ISSOCK(@as(Mode, @intCast(this.modeInternal()))));
}
@@ -1456,6 +1494,10 @@ pub fn StatType(comptime Big: bool) type {
///
/// See https://nodejs.org/api/fs.html#statsissymboliclink
pub fn isSymbolicLink(this: *This) JSC.JSValue {
+ if (comptime Environment.isWindows) {
+ JSC.VirtualMachine.get().global.throwTODO(comptime @src().fn_name ++ " is not implemented yet");
+ return .zero;
+ }
return JSC.JSValue.jsBoolean(os.S.ISLNK(@as(Mode, @intCast(this.modeInternal()))));
}
@@ -1465,7 +1507,7 @@ pub fn StatType(comptime Big: bool) type {
bun.default_allocator.destroy(this);
}
- pub fn init(stat_: os.Stat) This {
+ pub fn init(stat_: bun.Stat) This {
const aTime = stat_.atime();
const mTime = stat_.mtime();
const cTime = stat_.ctime();
@@ -1495,7 +1537,7 @@ pub fn StatType(comptime Big: bool) type {
};
}
- pub fn initWithAllocator(allocator: std.mem.Allocator, stat: std.os.Stat) *This {
+ pub fn initWithAllocator(allocator: std.mem.Allocator, stat: bun.Stat) *This {
var this = allocator.create(This) catch unreachable;
this.* = init(stat);
return this;
@@ -1558,7 +1600,7 @@ pub const Stats = union(enum) {
big: StatsBig,
small: StatsSmall,
- pub inline fn init(stat_: os.Stat, big: bool) Stats {
+ pub inline fn init(stat_: bun.Stat, big: bool) Stats {
if (big) {
return .{ .big = StatsBig.init(stat_) };
} else {
@@ -2285,7 +2327,7 @@ pub const Path = struct {
pub const Process = struct {
pub fn getArgv0(globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue {
- return JSC.ZigString.fromUTF8(bun.span(std.os.argv[0])).toValueGC(globalObject);
+ return JSC.ZigString.fromUTF8(bun.span(bun.argv()[0])).toValueGC(globalObject);
}
pub fn getExecPath(globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue {
@@ -2305,13 +2347,13 @@ pub const Process = struct {
JSC.ZigString,
// argv omits "bun" because it could be "bun run" or "bun" and it's kind of ambiguous
// argv also omits the script name
- std.os.argv.len -| 1,
+ bun.argv().len -| 1,
) catch unreachable;
defer allocator.free(args);
var used: usize = 0;
const offset: usize = 1;
- for (std.os.argv[@min(std.os.argv.len, offset)..]) |arg_| {
+ for (bun.argv()[@min(bun.argv().len, offset)..]) |arg_| {
const arg = bun.span(arg_);
if (arg.len == 0)
continue;
diff --git a/src/bun.js/rare_data.zig b/src/bun.js/rare_data.zig
index ab9cc9ea4..30adeabe3 100644
--- a/src/bun.js/rare_data.zig
+++ b/src/bun.js/rare_data.zig
@@ -225,7 +225,7 @@ pub fn stderr(rare: *RareData) *Blob.Store {
return rare.stderr_store orelse brk: {
var store = default_allocator.create(Blob.Store) catch unreachable;
var mode: JSC.Node.Mode = 0;
- switch (Syscall.fstat(std.os.STDERR_FILENO)) {
+ switch (Syscall.fstat(bun.STDERR_FD)) {
.result => |stat| {
mode = stat.mode;
},
@@ -238,7 +238,7 @@ pub fn stderr(rare: *RareData) *Blob.Store {
.data = .{
.file = Blob.FileStore{
.pathlike = .{
- .fd = std.os.STDERR_FILENO,
+ .fd = bun.STDERR_FD,
},
.is_atty = Output.stderr_descriptor_type == .terminal,
.mode = mode,
@@ -255,7 +255,7 @@ pub fn stdout(rare: *RareData) *Blob.Store {
return rare.stdout_store orelse brk: {
var store = default_allocator.create(Blob.Store) catch unreachable;
var mode: JSC.Node.Mode = 0;
- switch (Syscall.fstat(std.os.STDOUT_FILENO)) {
+ switch (Syscall.fstat(bun.STDOUT_FD)) {
.result => |stat| {
mode = stat.mode;
},
@@ -267,7 +267,7 @@ pub fn stdout(rare: *RareData) *Blob.Store {
.data = .{
.file = Blob.FileStore{
.pathlike = .{
- .fd = std.os.STDOUT_FILENO,
+ .fd = bun.STDOUT_FD,
},
.is_atty = Output.stdout_descriptor_type == .terminal,
.mode = mode,
@@ -283,7 +283,7 @@ pub fn stdin(rare: *RareData) *Blob.Store {
return rare.stdin_store orelse brk: {
var store = default_allocator.create(Blob.Store) catch unreachable;
var mode: JSC.Node.Mode = 0;
- switch (Syscall.fstat(std.os.STDIN_FILENO)) {
+ switch (Syscall.fstat(bun.STDIN_FD)) {
.result => |stat| {
mode = stat.mode;
},
@@ -295,9 +295,9 @@ pub fn stdin(rare: *RareData) *Blob.Store {
.data = .{
.file = Blob.FileStore{
.pathlike = .{
- .fd = std.os.STDIN_FILENO,
+ .fd = bun.STDIN_FD,
},
- .is_atty = std.os.isatty(std.os.STDIN_FILENO),
+ .is_atty = std.os.isatty(bun.fdcast(bun.STDIN_FD)),
.mode = mode,
},
},
diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig
index 77cd79d21..e52c9f0e2 100644
--- a/src/bun.js/test/jest.zig
+++ b/src/bun.js/test/jest.zig
@@ -3,8 +3,7 @@ const bun = @import("root").bun;
const js_parser = bun.js_parser;
const js_ast = bun.JSAst;
const Api = @import("../../api/schema.zig").Api;
-const RequestContext = @import("../../http.zig").RequestContext;
-const MimeType = @import("../../http.zig").MimeType;
+const MimeType = @import("../../bun_dev_http_server.zig").MimeType;
const ZigURL = @import("../../url.zig").URL;
const HTTPClient = @import("root").bun.HTTP;
const NetworkThread = HTTPClient.NetworkThread;
diff --git a/src/bun.js/test/snapshot.zig b/src/bun.js/test/snapshot.zig
index 12c7b3c36..072194b11 100644
--- a/src/bun.js/test/snapshot.zig
+++ b/src/bun.js/test/snapshot.zig
@@ -227,11 +227,11 @@ pub const Snapshots = struct {
if (this.snapshot_dir_path == null or !strings.eqlLong(dir_path, this.snapshot_dir_path.?, true)) {
remain[0] = 0;
const snapshot_dir_path = snapshot_file_path_buf[0 .. snapshot_file_path_buf.len - remain.len :0];
- switch (JSC.Node.Syscall.mkdir(snapshot_dir_path, 0o777)) {
+ switch (bun.sys.mkdir(snapshot_dir_path, 0o777)) {
.result => this.snapshot_dir_path = dir_path,
.err => |err| {
switch (err.getErrno()) {
- std.os.E.EXIST => this.snapshot_dir_path = dir_path,
+ .EXIST => this.snapshot_dir_path = dir_path,
else => return JSC.Maybe(void){
.err = err,
},
@@ -249,7 +249,7 @@ pub const Snapshots = struct {
var flags: JSC.Node.Mode = std.os.O.CREAT | std.os.O.RDWR;
if (this.update_snapshots) flags |= std.os.O.TRUNC;
- const fd = switch (JSC.Node.Syscall.open(snapshot_file_path, flags, 0o644)) {
+ const fd = switch (bun.sys.open(snapshot_file_path, flags, 0o644)) {
.result => |_fd| _fd,
.err => |err| return JSC.Maybe(void){
.err = err,
@@ -258,7 +258,7 @@ pub const Snapshots = struct {
var file: File = .{
.id = file_id,
- .file = .{ .handle = fd },
+ .file = .{ .handle = bun.fdcast(fd) },
};
if (this.update_snapshots) {
diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig
index c8d842a21..f30a4a3d3 100644
--- a/src/bun.js/webcore/blob.zig
+++ b/src/bun.js/webcore/blob.zig
@@ -1,8 +1,7 @@
const std = @import("std");
const Api = @import("../../api/schema.zig").Api;
const bun = @import("root").bun;
-const RequestContext = @import("../../http.zig").RequestContext;
-const MimeType = @import("../../http.zig").MimeType;
+const MimeType = @import("../../bun_dev_http_server.zig").MimeType;
const ZigURL = @import("../../url.zig").URL;
const HTTPClient = @import("root").bun.HTTP;
const NetworkThread = HTTPClient.NetworkThread;
@@ -331,7 +330,7 @@ pub const Blob = struct {
switch (pathlike_tag) {
.fd => {
- const fd = @as(i32, @intCast(try reader.readIntNative(u32)));
+ const fd = @as(bun.FileDescriptor, @intCast(try reader.readIntNative(bun.FileDescriptor)));
var blob = try allocator.create(Blob);
blob.* = Blob.findOrCreateFileFromPath(
@@ -1021,7 +1020,7 @@ pub const Blob = struct {
) JSC.JSValue {
const fd: bun.FileDescriptor = if (comptime !needs_open) pathlike.fd else brk: {
var file_path: [bun.MAX_PATH_BYTES]u8 = undefined;
- switch (JSC.Node.Syscall.open(
+ switch (bun.sys.open(
pathlike.path.sliceZ(&file_path),
// we deliberately don't use O_TRUNC here
// it's a perf optimization
@@ -1046,11 +1045,11 @@ pub const Blob = struct {
// we only truncate if it's a path
// if it's a file descriptor, we assume they want manual control over that behavior
if (truncate) {
- _ = JSC.Node.Syscall.system.ftruncate(fd, @as(i64, @intCast(written)));
+ _ = bun.sys.ftruncate(fd, @as(i64, @intCast(written)));
}
if (needs_open) {
- _ = JSC.Node.Syscall.close(fd);
+ _ = bun.sys.close(fd);
}
}
if (!str.isEmpty()) {
@@ -1059,7 +1058,7 @@ pub const Blob = struct {
var remain = decoded.slice();
while (remain.len > 0) {
- const result = JSC.Node.Syscall.write(fd, remain);
+ const result = bun.sys.write(fd, remain);
switch (result) {
.result => |res| {
written += res;
@@ -1091,7 +1090,7 @@ pub const Blob = struct {
) JSC.JSValue {
const fd: bun.FileDescriptor = if (comptime !needs_open) pathlike.fd else brk: {
var file_path: [bun.MAX_PATH_BYTES]u8 = undefined;
- switch (JSC.Node.Syscall.open(
+ switch (bun.sys.open(
pathlike.path.sliceZ(&file_path),
// we deliberately don't use O_TRUNC here
// it's a perf optimization
@@ -1112,11 +1111,11 @@ pub const Blob = struct {
var written: usize = 0;
defer {
if (truncate) {
- _ = JSC.Node.Syscall.system.ftruncate(fd, @as(i64, @intCast(written)));
+ _ = bun.sys.ftruncate(fd, @as(i64, @intCast(written)));
}
if (needs_open) {
- _ = JSC.Node.Syscall.close(fd);
+ _ = bun.sys.close(fd);
}
}
@@ -1124,7 +1123,7 @@ pub const Blob = struct {
const end = remain.ptr + remain.len;
while (remain.ptr != end) {
- const result = JSC.Node.Syscall.write(fd, remain);
+ const result = bun.sys.write(fd, remain);
switch (result) {
.result => |res| {
written += res;
@@ -1321,16 +1320,16 @@ pub const Blob = struct {
};
},
.fd => {
- switch (path_.fd) {
- std.os.STDIN_FILENO => return Blob.initWithStore(
+ switch (bun.FDTag.get(path_.fd)) {
+ .stdin => return Blob.initWithStore(
vm.rareData().stdin(),
globalThis,
),
- std.os.STDERR_FILENO => return Blob.initWithStore(
+ .stderr => return Blob.initWithStore(
vm.rareData().stderr(),
globalThis,
),
- std.os.STDOUT_FILENO => return Blob.initWithStore(
+ .stdout => return Blob.initWithStore(
vm.rareData().stdout(),
globalThis,
),
@@ -1509,7 +1508,7 @@ pub const Blob = struct {
var path = path_string.sliceZ(&buf);
- this.opened_fd = switch (JSC.Node.Syscall.open(path, open_flags_, JSC.Node.default_permission)) {
+ this.opened_fd = switch (bun.sys.open(path, open_flags_, JSC.Node.default_permission)) {
.result => |fd| fd,
.err => |err| {
this.errno = AsyncIO.asError(err.errno);
@@ -1563,23 +1562,45 @@ pub const Blob = struct {
var path_buffer = completion.operation.open.path;
defer bun.default_allocator.free(bun.span(path_buffer));
defer bun.default_allocator.destroy(state);
- this.opened_fd = result catch {
- this.errno = AsyncIO.asError(-completion.result);
- // do not use path_buffer here because it is a temporary
- var path_string = if (@hasField(This, "file_store"))
- this.file_store.pathlike.path
- else
- this.file_blob.store.?.data.file.pathlike.path;
-
- this.system_error = (JSC.Node.Syscall.Error{
- .errno = @as(JSC.Node.Syscall.Error.Int, @intCast(-completion.result)),
- .path = path_string.slice(),
- .syscall = .open,
- }).toSystemError();
-
- callback(this, null_fd);
- return;
- };
+ if (comptime Environment.isPosix) {
+ this.opened_fd = result catch {
+ this.errno = AsyncIO.asError(-completion.result);
+ // do not use path_buffer here because it is a temporary
+ var path_string = if (@hasField(This, "file_store"))
+ this.file_store.pathlike.path
+ else
+ this.file_blob.store.?.data.file.pathlike.path;
+
+ this.system_error = (bun.sys.Error{
+ .errno = @as(bun.sys.Error.Int, @intCast(-completion.result)),
+ .path = path_string.slice(),
+ .syscall = .open,
+ }).toSystemError();
+
+ callback(this, null_fd);
+ return;
+ };
+ } else if (comptime Environment.isWindows) {
+ this.opened_fd = result catch |err| {
+ this.errno = err;
+ // do not use path_buffer here because it is a temporary
+ var path_string = if (@hasField(This, "file_store"))
+ this.file_store.pathlike.path
+ else
+ this.file_blob.store.?.data.file.pathlike.path;
+
+ this.system_error = (bun.sys.Error{
+ .errno = @as(bun.sys.Error.Int, @intFromEnum(bun.C.SystemErrno.fromError(err).?)),
+ .path = path_string.slice(),
+ .syscall = .open,
+ }).toSystemError();
+
+ callback(this, null_fd);
+ return;
+ };
+ } else {
+ @compileError("Unsupported platform");
+ }
callback(this, this.opened_fd);
}
@@ -1771,8 +1792,8 @@ pub const Blob = struct {
this.read_len = @as(SizeType, @truncate(result catch |err| {
if (@hasField(HTTPClient.NetworkThread.Completion, "result")) {
this.errno = AsyncIO.asError(-completion.result);
- this.system_error = (JSC.Node.Syscall.Error{
- .errno = @as(JSC.Node.Syscall.Error.Int, @intCast(-completion.result)),
+ this.system_error = (bun.sys.Error{
+ .errno = @as(bun.sys.Error.Int, @intCast(-completion.result)),
.syscall = .read,
}).toSystemError();
} else {
@@ -1821,7 +1842,12 @@ pub const Blob = struct {
}
fn resolveSizeAndLastModified(this: *ReadFile, fd: bun.FileDescriptor) void {
- const stat: std.os.Stat = switch (JSC.Node.Syscall.fstat(fd)) {
+ if (comptime Environment.isWindows) {
+ bun.todo(@src(), {});
+ return;
+ }
+
+ const stat: bun.Stat = switch (bun.sys.fstat(fd)) {
.result => |result| result,
.err => |err| {
this.errno = AsyncIO.asError(err.errno);
@@ -1850,14 +1876,14 @@ pub const Blob = struct {
return;
}
- if (stat.size > 0 and std.os.S.ISREG(stat.mode)) {
+ if (stat.size > 0 and bun.isRegularFile(stat.mode)) {
this.size = @min(
@as(SizeType, @truncate(@as(SizeType, @intCast(@max(@as(i64, @intCast(stat.size)), 0))))),
this.max_length,
);
// read up to 4k at a time if
// they didn't explicitly set a size and we're reading from something that's not a regular file
- } else if (stat.size == 0 and !std.os.S.ISREG(stat.mode)) {
+ } else if (stat.size == 0 and !bun.isRegularFile(stat.mode)) {
this.size = if (this.max_length == Blob.max_size)
4096
else
@@ -2206,14 +2232,14 @@ pub const Blob = struct {
pub fn doCloseFile(this: *CopyFile, comptime which: IOWhich) void {
switch (which) {
.both => {
- _ = JSC.Node.Syscall.close(this.destination_fd);
- _ = JSC.Node.Syscall.close(this.source_fd);
+ _ = bun.sys.close(this.destination_fd);
+ _ = bun.sys.close(this.source_fd);
},
.destination => {
- _ = JSC.Node.Syscall.close(this.destination_fd);
+ _ = bun.sys.close(this.destination_fd);
},
.source => {
- _ = JSC.Node.Syscall.close(this.source_fd);
+ _ = bun.sys.close(this.source_fd);
},
}
}
@@ -2226,7 +2252,7 @@ pub const Blob = struct {
// open source file first
// if it fails, we don't want the extra destination file hanging out
if (which == .both or which == .source) {
- this.source_fd = switch (JSC.Node.Syscall.open(
+ this.source_fd = switch (bun.sys.open(
this.source_file_store.pathlike.path.sliceZAssume(),
open_source_flags,
0,
@@ -2240,7 +2266,7 @@ pub const Blob = struct {
}
if (which == .both or which == .destination) {
- this.destination_fd = switch (JSC.Node.Syscall.open(
+ this.destination_fd = switch (bun.sys.open(
this.destination_file_store.pathlike.path.sliceZAssume(),
open_destination_flags,
JSC.Node.default_permission,
@@ -2248,7 +2274,7 @@ pub const Blob = struct {
.result => |result| result,
.err => |errno| {
if (which == .both) {
- _ = JSC.Node.Syscall.close(this.source_fd);
+ _ = bun.sys.close(this.source_fd);
this.source_fd = 0;
}
@@ -2264,7 +2290,7 @@ pub const Blob = struct {
copy_file_range,
splice,
- pub const tag = std.EnumMap(TryWith, JSC.Node.Syscall.Tag).init(.{
+ pub const tag = std.EnumMap(TryWith, bun.sys.Tag).init(.{
.sendfile = .sendfile,
.copy_file_range = .copy_file_range,
.splice = .splice,
@@ -2366,15 +2392,15 @@ pub const Blob = struct {
}
}
- this.system_error = (JSC.Node.Syscall.Error{
- .errno = @as(JSC.Node.Syscall.Error.Int, @intCast(@intFromEnum(linux.E.INVAL))),
+ this.system_error = (bun.sys.Error{
+ .errno = @as(bun.sys.Error.Int, @intCast(@intFromEnum(linux.E.INVAL))),
.syscall = TryWith.tag.get(use).?,
}).toSystemError();
return AsyncIO.asError(linux.E.INVAL);
},
else => |errno| {
- this.system_error = (JSC.Node.Syscall.Error{
- .errno = @as(JSC.Node.Syscall.Error.Int, @intCast(@intFromEnum(errno))),
+ this.system_error = (bun.sys.Error{
+ .errno = @as(bun.sys.Error.Int, @intCast(@intFromEnum(errno))),
.syscall = TryWith.tag.get(use).?,
}).toSystemError();
return AsyncIO.asError(errno);
@@ -2389,7 +2415,7 @@ pub const Blob = struct {
}
pub fn doFCopyFile(this: *CopyFile) anyerror!void {
- switch (JSC.Node.Syscall.fcopyfile(this.source_fd, this.destination_fd, os.system.COPYFILE_DATA)) {
+ switch (bun.sys.fcopyfile(this.source_fd, this.destination_fd, os.system.COPYFILE_DATA)) {
.err => |errno| {
this.system_error = errno.toSystemError();
@@ -2403,7 +2429,7 @@ pub const Blob = struct {
var source_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
var dest_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
- switch (JSC.Node.Syscall.clonefile(
+ switch (bun.sys.clonefile(
this.source_file_store.pathlike.path.sliceZ(&source_buf),
this.destination_file_store.pathlike.path.sliceZ(
&dest_buf,
@@ -2420,7 +2446,7 @@ pub const Blob = struct {
pub fn runAsync(this: *CopyFile) void {
// defer task.onFinish();
- var stat_: ?std.os.Stat = null;
+ var stat_: ?bun.Stat = null;
if (this.destination_file_store.pathlike == .fd) {
this.destination_fd = this.destination_file_store.pathlike.fd;
@@ -2430,6 +2456,15 @@ pub const Blob = struct {
this.source_fd = this.source_file_store.pathlike.fd;
}
+ if (comptime Environment.isWindows) {
+ this.system_error = SystemError{
+ .code = bun.String.static("TODO"),
+ .syscall = bun.String.static("CopyFileEx"),
+ .message = bun.String.static("Not implemented on Windows yet"),
+ };
+ return;
+ }
+
// Do we need to open both files?
if (this.destination_fd == null_fd and this.source_fd == null_fd) {
@@ -2441,7 +2476,7 @@ pub const Blob = struct {
// stat the output file, make sure it:
// 1. Exists
- switch (JSC.Node.Syscall.stat(this.source_file_store.pathlike.path.sliceZAssume())) {
+ switch (bun.sys.stat(this.source_file_store.pathlike.path.sliceZAssume())) {
.result => |result| {
stat_ = result;
@@ -2506,7 +2541,7 @@ pub const Blob = struct {
if (this.destination_file_store.pathlike == .fd) {}
- const stat: std.os.Stat = stat_ orelse switch (JSC.Node.Syscall.fstat(this.source_fd)) {
+ const stat: bun.Stat = stat_ orelse switch (bun.sys.fstat(this.source_fd)) {
.result => |result| result,
.err => |err| {
this.doClose();
@@ -2612,7 +2647,7 @@ pub const Blob = struct {
}
if (this.mode != 0) {
- return std.os.S.ISREG(this.mode);
+ return bun.isRegularFile(this.mode);
}
return null;
@@ -2787,9 +2822,14 @@ pub const Blob = struct {
return JSValue.jsBoolean(true);
}
+ if (comptime Environment.isWindows) {
+ this.globalThis.throwTODO("exists is not implemented on Windows");
+ return JSValue.jsUndefined();
+ }
+
// We say regular files and pipes exist.
// This is mostly meant for "Can we use this in new Response(file)?"
- return JSValue.jsBoolean(std.os.S.ISREG(store.data.file.mode) or std.os.S.ISFIFO(store.data.file.mode));
+ return JSValue.jsBoolean(bun.isRegularFile(store.data.file.mode) or std.os.S.ISFIFO(store.data.file.mode));
}
// This mostly means 'can it be read?'
@@ -3150,30 +3190,35 @@ pub const Blob = struct {
/// resolve file stat like size, last_modified
fn resolveFileStat(store: *Store) void {
+ if (comptime Environment.isWindows) {
+ bun.todo(@src(), {});
+ return;
+ }
+
if (store.data.file.pathlike == .path) {
var buffer: [bun.MAX_PATH_BYTES]u8 = undefined;
- switch (JSC.Node.Syscall.stat(store.data.file.pathlike.path.sliceZ(&buffer))) {
+ switch (bun.sys.stat(store.data.file.pathlike.path.sliceZ(&buffer))) {
.result => |stat| {
- store.data.file.max_size = if (std.os.S.ISREG(stat.mode) or stat.size > 0)
+ store.data.file.max_size = if (bun.isRegularFile(stat.mode) or stat.size > 0)
@as(SizeType, @truncate(@as(u64, @intCast(@max(stat.size, 0)))))
else
Blob.max_size;
store.data.file.mode = stat.mode;
- store.data.file.seekable = std.os.S.ISREG(stat.mode);
+ store.data.file.seekable = bun.isRegularFile(stat.mode);
store.data.file.last_modified = toJSTime(stat.mtime().tv_sec, stat.mtime().tv_nsec);
},
// the file may not exist yet. Thats's okay.
else => {},
}
} else if (store.data.file.pathlike == .fd) {
- switch (JSC.Node.Syscall.fstat(store.data.file.pathlike.fd)) {
+ switch (bun.sys.fstat(store.data.file.pathlike.fd)) {
.result => |stat| {
- store.data.file.max_size = if (std.os.S.ISREG(stat.mode) or stat.size > 0)
+ store.data.file.max_size = if (bun.isRegularFile(stat.mode) or stat.size > 0)
@as(SizeType, @truncate(@as(u64, @intCast(@max(stat.size, 0)))))
else
Blob.max_size;
store.data.file.mode = stat.mode;
- store.data.file.seekable = std.os.S.ISREG(stat.mode);
+ store.data.file.seekable = bun.isRegularFile(stat.mode);
store.data.file.last_modified = toJSTime(stat.mtime().tv_sec, stat.mtime().tv_nsec);
},
// the file may not exist yet. Thats's okay.
diff --git a/src/bun.js/webcore/body.zig b/src/bun.js/webcore/body.zig
index 2cf4de874..1519ef148 100644
--- a/src/bun.js/webcore/body.zig
+++ b/src/bun.js/webcore/body.zig
@@ -1,8 +1,7 @@
const std = @import("std");
const Api = @import("../../api/schema.zig").Api;
const bun = @import("root").bun;
-const RequestContext = @import("../../http.zig").RequestContext;
-const MimeType = @import("../../http.zig").MimeType;
+const MimeType = @import("../../bun_dev_http_server.zig").MimeType;
const ZigURL = @import("../../url.zig").URL;
const HTTPClient = @import("root").bun.HTTP;
const NetworkThread = HTTPClient.NetworkThread;
diff --git a/src/bun.js/webcore/encoding.zig b/src/bun.js/webcore/encoding.zig
index 890dad7bd..6f31fef82 100644
--- a/src/bun.js/webcore/encoding.zig
+++ b/src/bun.js/webcore/encoding.zig
@@ -1,7 +1,6 @@
const std = @import("std");
const Api = @import("../../api/schema.zig").Api;
-const RequestContext = @import("../../http.zig").RequestContext;
-const MimeType = @import("../../http.zig").MimeType;
+const MimeType = @import("../../bun_dev_http_server.zig").MimeType;
const ZigURL = @import("../../url.zig").URL;
const HTTPClient = @import("root").bun.HTTP;
const NetworkThread = HTTPClient.NetworkThread;
diff --git a/src/bun.js/webcore/request.zig b/src/bun.js/webcore/request.zig
index aaa3f6b79..fc38e1825 100644
--- a/src/bun.js/webcore/request.zig
+++ b/src/bun.js/webcore/request.zig
@@ -1,8 +1,8 @@
const std = @import("std");
const Api = @import("../../api/schema.zig").Api;
const bun = @import("root").bun;
-const RequestContext = @import("../../http.zig").RequestContext;
-const MimeType = @import("../../http.zig").MimeType;
+const RequestContext = @import("../../bun_dev_http_server.zig").RequestContext;
+const MimeType = @import("../../bun_dev_http_server.zig").MimeType;
const ZigURL = @import("../../url.zig").URL;
const HTTPClient = @import("root").bun.HTTP;
const NetworkThread = HTTPClient.NetworkThread;
@@ -176,6 +176,7 @@ pub const Request = struct {
}
pub fn fromRequestContext(ctx: *RequestContext) !Request {
+ if (comptime Environment.isWindows) unreachable;
var req = Request{
.url = bun.String.create(ctx.full_url),
.body = try InitRequestBodyValue(.{ .Null = {} }),
diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig
index df92dff15..2164062a1 100644
--- a/src/bun.js/webcore/response.zig
+++ b/src/bun.js/webcore/response.zig
@@ -1,8 +1,8 @@
const std = @import("std");
const Api = @import("../../api/schema.zig").Api;
const bun = @import("root").bun;
-const RequestContext = @import("../../http.zig").RequestContext;
-const MimeType = @import("../../http.zig").MimeType;
+const RequestContext = @import("../../bun_dev_http_server.zig").RequestContext;
+const MimeType = @import("../../bun_dev_http_server.zig").MimeType;
const ZigURL = @import("../../url.zig").URL;
const HTTPClient = @import("root").bun.HTTP;
const FetchRedirect = HTTPClient.FetchRedirect;
@@ -293,10 +293,13 @@ pub const Response = struct {
}
pub fn mimeType(response: *const Response, request_ctx_: ?*const RequestContext) string {
+ if (comptime Environment.isWindows) unreachable;
return mimeTypeWithDefault(response, MimeType.other, request_ctx_);
}
pub fn mimeTypeWithDefault(response: *const Response, default: MimeType, request_ctx_: ?*const RequestContext) string {
+ if (comptime Environment.isWindows) unreachable;
+
if (response.header(.ContentType)) |content_type| {
return content_type;
}
@@ -679,7 +682,7 @@ pub const Fetch = struct {
.AnyBlob => this.AnyBlob.detach(),
.Sendfile => {
if (@max(this.Sendfile.offset, this.Sendfile.remain) > 0)
- _ = JSC.Node.Syscall.close(this.Sendfile.fd);
+ _ = bun.sys.close(this.Sendfile.fd);
this.Sendfile.offset = 0;
this.Sendfile.remain = 0;
},
@@ -1750,8 +1753,8 @@ pub const Fetch = struct {
if (body.needsToReadFile()) {
prepare_body: {
const opened_fd_res: JSC.Node.Maybe(bun.FileDescriptor) = switch (body.Blob.store.?.data.file.pathlike) {
- .fd => |fd| JSC.Node.Maybe(bun.FileDescriptor).errnoSysFd(JSC.Node.Syscall.system.dup(fd), .open, fd) orelse .{ .result = fd },
- .path => |path| JSC.Node.Syscall.open(path.sliceZ(&globalThis.bunVM().nodeFS().sync_error_buf), std.os.O.RDONLY | std.os.O.NOCTTY, 0),
+ .fd => |fd| bun.sys.dup(fd),
+ .path => |path| bun.sys.open(path.sliceZ(&globalThis.bunVM().nodeFS().sync_error_buf), std.os.O.RDONLY | std.os.O.NOCTTY, 0),
};
const opened_fd = switch (opened_fd_res) {
@@ -1772,7 +1775,7 @@ pub const Fetch = struct {
if (proxy == null and bun.HTTP.Sendfile.isEligible(url)) {
use_sendfile: {
- const stat: std.os.Stat = switch (JSC.Node.Syscall.fstat(opened_fd)) {
+ const stat: bun.Stat = switch (bun.sys.fstat(opened_fd)) {
.result => |result| result,
// bail out for any reason
.err => break :use_sendfile,
@@ -1780,7 +1783,7 @@ pub const Fetch = struct {
if (Environment.isMac) {
// macOS only supports regular files for sendfile()
- if (!std.os.S.ISREG(stat.mode)) {
+ if (!bun.isRegularFile(stat.mode)) {
break :use_sendfile;
}
}
@@ -1792,7 +1795,7 @@ pub const Fetch = struct {
const original_size = body.Blob.size;
const stat_size = @as(Blob.SizeType, @intCast(stat.size));
- const blob_size = if (std.os.S.ISREG(stat.mode))
+ const blob_size = if (bun.isRegularFile(stat.mode))
stat_size
else
@min(original_size, stat_size);
@@ -1806,7 +1809,7 @@ pub const Fetch = struct {
},
};
- if (std.os.S.ISREG(stat.mode)) {
+ if (bun.isRegularFile(stat.mode)) {
http_body.Sendfile.offset = @min(http_body.Sendfile.offset, stat_size);
http_body.Sendfile.remain = @min(@max(http_body.Sendfile.remain, http_body.Sendfile.offset), stat_size) -| http_body.Sendfile.offset;
}
@@ -1829,7 +1832,7 @@ pub const Fetch = struct {
);
if (body.Blob.store.?.data.file.pathlike == .path) {
- _ = JSC.Node.Syscall.close(opened_fd);
+ _ = bun.sys.close(opened_fd);
}
switch (res) {
diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig
index b3415c4f7..94f10925f 100644
--- a/src/bun.js/webcore/streams.zig
+++ b/src/bun.js/webcore/streams.zig
@@ -1,8 +1,7 @@
const std = @import("std");
const Api = @import("../../api/schema.zig").Api;
const bun = @import("root").bun;
-const RequestContext = @import("../../http.zig").RequestContext;
-const MimeType = @import("../../http.zig").MimeType;
+const MimeType = @import("../../bun_dev_http_server.zig").MimeType;
const ZigURL = @import("../../url.zig").URL;
const HTTPClient = @import("root").bun.HTTP;
const NetworkThread = HTTPClient.NetworkThread;
@@ -35,7 +34,7 @@ const JSPromise = JSC.JSPromise;
const JSValue = JSC.JSValue;
const JSError = JSC.JSError;
const JSGlobalObject = JSC.JSGlobalObject;
-
+const E = bun.C.E;
const VirtualMachine = JSC.VirtualMachine;
const Task = JSC.Task;
const JSPrinter = bun.js_printer;
@@ -46,7 +45,7 @@ const Blob = JSC.WebCore.Blob;
const Response = JSC.WebCore.Response;
const Request = JSC.WebCore.Request;
const assert = std.debug.assert;
-const Syscall = JSC.Node.Syscall;
+const Syscall = bun.sys;
const AnyBlob = JSC.WebCore.AnyBlob;
pub const ReadableStream = struct {
@@ -451,12 +450,20 @@ pub const StreamStart = union(Tag) {
.FileSink => {
var chunk_size: JSC.WebCore.Blob.SizeType = 0;
- if (value.get(globalThis, "highWaterMark")) |chunkSize| {
+ if (value.getTruthy(globalThis, "highWaterMark")) |chunkSize| {
if (chunkSize.isNumber())
chunk_size = @as(JSC.WebCore.Blob.SizeType, @intCast(@max(0, @as(i51, @truncate(chunkSize.toInt64())))));
}
- if (value.get(globalThis, "path")) |path| {
+ if (value.getTruthy(globalThis, "path")) |path| {
+ if (!path.isString()) {
+ return .{
+ .err = Syscall.Error{
+ .errno = @intFromEnum(bun.C.SystemErrno.EINVAL),
+ },
+ };
+ }
+
return .{
.FileSink = .{
.chunk_size = chunk_size,
@@ -465,12 +472,28 @@ pub const StreamStart = union(Tag) {
},
},
};
- } else if (value.get(globalThis, "fd")) |fd| {
+ } else if (value.getTruthy(globalThis, "fd")) |fd_value| {
+ if (!fd_value.isAnyInt()) {
+ return .{
+ .err = Syscall.Error{
+ .errno = @intFromEnum(bun.C.SystemErrno.EBADF),
+ },
+ };
+ }
+ const fd = fd_value.toInt64();
+ if (fd < 0) {
+ return .{
+ .err = Syscall.Error{
+ .errno = @intFromEnum(bun.C.SystemErrno.EBADF),
+ },
+ };
+ }
+
return .{
.FileSink = .{
.chunk_size = chunk_size,
.input_path = .{
- .fd = fd.toInt32(),
+ .fd = @as(bun.FileDescriptor, @intCast(fd)),
},
},
};
@@ -487,7 +510,7 @@ pub const StreamStart = union(Tag) {
var empty = true;
var chunk_size: JSC.WebCore.Blob.SizeType = 2048;
- if (value.get(globalThis, "highWaterMark")) |chunkSize| {
+ if (value.getTruthy(globalThis, "highWaterMark")) |chunkSize| {
if (chunkSize.isNumber()) {
empty = false;
chunk_size = @as(JSC.WebCore.Blob.SizeType, @intCast(@max(256, @as(i51, @truncate(chunkSize.toInt64())))));
@@ -1189,24 +1212,24 @@ pub const FileSink = struct {
const auto_close = this.auto_close;
const fd = if (!auto_close)
input_path.fd
- else switch (JSC.Node.Syscall.open(input_path.path.toSliceZ(&file_buf), std.os.O.WRONLY | std.os.O.NONBLOCK | std.os.O.CLOEXEC | std.os.O.CREAT, mode)) {
+ else switch (bun.sys.open(input_path.path.toSliceZ(&file_buf), std.os.O.WRONLY | std.os.O.NONBLOCK | std.os.O.CLOEXEC | std.os.O.CREAT, mode)) {
.result => |_fd| _fd,
.err => |err| return .{ .err = err.withPath(input_path.path.slice()) },
};
if (this.poll_ref == null) {
- const stat: std.os.Stat = switch (JSC.Node.Syscall.fstat(fd)) {
+ const stat: bun.Stat = switch (bun.sys.fstat(fd)) {
.result => |result| result,
.err => |err| {
if (auto_close) {
- _ = JSC.Node.Syscall.close(fd);
+ _ = bun.sys.close(fd);
}
return .{ .err = err.withPathLike(input_path) };
},
};
this.mode = stat.mode;
- this.auto_truncate = this.auto_truncate and (std.os.S.ISREG(this.mode));
+ this.auto_truncate = this.auto_truncate and (bun.isRegularFile(this.mode));
} else {
this.auto_truncate = false;
this.max_write_size = max_fifo_size;
@@ -1259,7 +1282,7 @@ pub const FileSink = struct {
// On Linux, we can adjust the pipe size to avoid blocking.
this.has_adjusted_pipe_size_on_linux = true;
- switch (JSC.Node.Syscall.setPipeCapacityOnLinux(fd, @min(Syscall.getMaxPipeSizeOnLinux(), remain_len))) {
+ switch (bun.sys.setPipeCapacityOnLinux(fd, @min(Syscall.getMaxPipeSizeOnLinux(), remain_len))) {
.result => |len| {
if (len > 0) {
this.max_write_size = len;
@@ -1358,11 +1381,11 @@ pub const FileSink = struct {
if (max_to_write > 0) {
while (remain.len > 0) {
const write_buf = remain[0..@min(remain.len, max_to_write)];
- const res = JSC.Node.Syscall.write(fd, write_buf);
+ const res = bun.sys.write(fd, write_buf);
if (res == .err) {
const retry =
- std.os.E.AGAIN;
+ E.AGAIN;
switch (res.err.getErrno()) {
retry => {
@@ -1461,10 +1484,10 @@ pub const FileSink = struct {
}
if (this.auto_truncate)
- std.os.ftruncate(fd, total) catch {};
+ std.os.ftruncate(bun.fdcast(fd), total) catch {};
if (this.auto_close) {
- _ = JSC.Node.Syscall.close(fd);
+ _ = bun.sys.close(fd);
this.fd = bun.invalid_fd;
}
}
@@ -1501,7 +1524,7 @@ pub const FileSink = struct {
this.scheduled_count = 0;
}
- _ = JSC.Node.Syscall.close(this.fd);
+ _ = bun.sys.close(this.fd);
this.fd = bun.invalid_fd;
}
}
@@ -1668,7 +1691,7 @@ pub const FileSink = struct {
this.fd = bun.invalid_fd;
if (this.auto_close)
- _ = JSC.Node.Syscall.close(fd);
+ _ = bun.sys.close(fd);
}
this.pending.result = .done;
@@ -2461,7 +2484,8 @@ pub fn HTTPServerWritable(comptime ssl: bool) type {
return this.buffer.ptr[this.offset..this.buffer.cap][0..this.buffer.len];
}
- pub fn onWritable(this: *@This(), write_offset: c_ulong, _: *UWSResponse) callconv(.C) bool {
+ pub fn onWritable(this: *@This(), write_offset_: c_ulong, _: *UWSResponse) callconv(.C) bool {
+ const write_offset: u64 = @as(u64, write_offset_);
log("onWritable ({d})", .{write_offset});
if (this.done) {
@@ -3681,7 +3705,7 @@ pub const FIFO = struct {
buf: []u8 = &[_]u8{},
view: JSC.Strong = .{},
poll_ref: ?*JSC.FilePoll = null,
- fd: bun.FileDescriptor = 0,
+ fd: bun.FileDescriptor = bun.invalid_fd,
to_read: ?u32 = null,
close_on_empty_read: bool = false,
auto_sizer: ?*AutoSizer = null,
@@ -3720,7 +3744,7 @@ pub const FIFO = struct {
if (signal_close) {
this.fd = bun.invalid_fd;
if (this.auto_close)
- _ = JSC.Node.Syscall.close(fd);
+ _ = bun.sys.close(fd);
}
this.to_read = null;
@@ -3783,7 +3807,7 @@ pub const FIFO = struct {
if (!is_readable and (this.close_on_empty_read or poll.isHUP())) {
// it might be readable actually
this.close_on_empty_read = true;
- switch (bun.isReadable(@as(std.os.fd_t, @intCast(poll.fd)))) {
+ switch (bun.isReadable(@intCast(poll.fd))) {
.ready => {
this.close_on_empty_read = false;
return null;
@@ -3806,7 +3830,7 @@ pub const FIFO = struct {
// this happens if we've registered a watcher but we haven't
// ticked the event loop since registering it
- switch (bun.isReadable(@as(std.os.fd_t, @intCast(poll.fd)))) {
+ switch (bun.isReadable(@intCast(poll.fd))) {
.ready => {
poll.flags.insert(.readable);
return null;
@@ -3991,8 +4015,8 @@ pub const FIFO = struct {
) ReadResult {
switch (Syscall.read(this.fd, buf)) {
.err => |err| {
- const retry = std.os.E.AGAIN;
- const errno: std.os.E = brk: {
+ const retry = E.AGAIN;
+ const errno: E = brk: {
const _errno = err.getErrno();
if (comptime Environment.isLinux) {
@@ -4113,69 +4137,86 @@ pub const File = struct {
},
};
- if ((file.is_atty orelse false) or (fd < 3 and std.os.isatty(fd))) {
- var termios = std.mem.zeroes(std.os.termios);
- _ = std.c.tcgetattr(fd, &termios);
- bun.C.cfmakeraw(&termios);
- file.is_atty = true;
+ if ((file.is_atty orelse false) or (fd < 3 and std.os.isatty(bun.fdcast(fd)))) {
+ if (comptime Environment.isPosix) {
+ var termios = std.mem.zeroes(std.os.termios);
+ _ = std.c.tcgetattr(fd, &termios);
+ bun.C.cfmakeraw(&termios);
+ file.is_atty = true;
+ }
}
if (!auto_close and !(file.is_atty orelse false)) {
+ if (comptime Environment.isWindows) {
+ bun.todo(@src(), {});
+ } else {
+ // ensure we have non-blocking IO set
+ switch (Syscall.fcntl(fd, std.os.F.GETFL, 0)) {
+ .err => return .{ .err = Syscall.Error.fromCode(E.BADF, .fcntl) },
+ .result => |flags| {
+ // if we do not, clone the descriptor and set non-blocking
+ // it is important for us to clone it so we don't cause Weird Things to happen
+ if ((flags & std.os.O.NONBLOCK) == 0) {
+ auto_close = true;
+ fd = switch (Syscall.fcntl(fd, std.os.F.DUPFD, 0)) {
+ .result => |_fd| @as(@TypeOf(fd), @intCast(_fd)),
+ .err => |err| return .{ .err = err },
+ };
- // ensure we have non-blocking IO set
- switch (Syscall.fcntl(fd, std.os.F.GETFL, 0)) {
- .err => return .{ .err = Syscall.Error.fromCode(std.os.E.BADF, .fcntl) },
- .result => |flags| {
- // if we do not, clone the descriptor and set non-blocking
- // it is important for us to clone it so we don't cause Weird Things to happen
- if ((flags & std.os.O.NONBLOCK) == 0) {
- auto_close = true;
- fd = switch (Syscall.fcntl(fd, std.os.F.DUPFD, 0)) {
- .result => |_fd| @as(@TypeOf(fd), @intCast(_fd)),
- .err => |err| return .{ .err = err },
- };
-
- switch (Syscall.fcntl(fd, std.os.F.SETFL, flags | std.os.O.NONBLOCK)) {
- .err => |err| return .{ .err = err },
- .result => |_| {},
+ switch (Syscall.fcntl(fd, std.os.F.SETFL, flags | std.os.O.NONBLOCK)) {
+ .err => |err| return .{ .err = err },
+ .result => |_| {},
+ }
}
- }
- },
+ },
+ }
}
}
+ var size: Blob.SizeType = 0;
+ if (comptime Environment.isPosix) {
+ const stat: bun.Stat = switch (Syscall.fstat(fd)) {
+ .result => |result| result,
+ .err => |err| {
+ if (auto_close) {
+ _ = Syscall.close(fd);
+ }
+ return .{ .err = err };
+ },
+ };
- const stat: std.os.Stat = switch (Syscall.fstat(fd)) {
- .result => |result| result,
- .err => |err| {
+ if (std.os.S.ISDIR(stat.mode)) {
if (auto_close) {
_ = Syscall.close(fd);
}
- return .{ .err = err };
- },
- };
-
- if (std.os.S.ISDIR(stat.mode)) {
- if (auto_close) {
- _ = Syscall.close(fd);
+ return .{ .err = Syscall.Error.fromCode(.ISDIR, .fstat) };
}
- return .{ .err = Syscall.Error.fromCode(.ISDIR, .fstat) };
- }
- if (std.os.S.ISSOCK(stat.mode)) {
- if (auto_close) {
- _ = Syscall.close(fd);
+ if (std.os.S.ISSOCK(stat.mode)) {
+ if (auto_close) {
+ _ = Syscall.close(fd);
+ }
+ return .{ .err = Syscall.Error.fromCode(.INVAL, .fstat) };
}
- return .{ .err = Syscall.Error.fromCode(.INVAL, .fstat) };
- }
- file.mode = @as(JSC.Node.Mode, @intCast(stat.mode));
- this.mode = file.mode;
+ file.mode = @as(JSC.Node.Mode, @intCast(stat.mode));
+ this.mode = file.mode;
- this.seekable = std.os.S.ISREG(stat.mode);
- file.seekable = this.seekable;
+ this.seekable = bun.isRegularFile(stat.mode);
+ file.seekable = this.seekable;
+ size = @intCast(stat.size);
+ } else if (comptime Environment.isWindows) outer: {
+ const std_file = std.fs.File{
+ .handle = bun.fdcast(fd),
+ };
+ size = @intCast(std_file.getEndPos() catch {
+ this.seekable = false;
+ break :outer;
+ });
+ this.seekable = true;
+ }
if (this.seekable) {
- this.remaining_bytes = @as(Blob.SizeType, @intCast(stat.size));
+ this.remaining_bytes = size;
file.max_size = this.remaining_bytes;
if (this.remaining_bytes == 0) {
@@ -4250,7 +4291,7 @@ pub const File = struct {
const to_read = @min(@as(usize, this.concurrent.chunk_size), remaining.len);
switch (Syscall.read(this.fd, remaining[0..to_read])) {
.err => |err| {
- const retry = std.os.E.AGAIN;
+ const retry = E.AGAIN;
switch (err.getErrno()) {
retry => break,
@@ -4381,7 +4422,7 @@ pub const File = struct {
pub fn doRead(this: *File, buf: []u8) ReadResult {
switch (Syscall.read(this.fd, buf)) {
.err => |err| {
- const retry = std.os.E.AGAIN;
+ const retry = bun.C.E.AGAIN;
const errno = err.getErrno();
switch (errno) {
@@ -4596,8 +4637,14 @@ pub const FileReader = struct {
return result;
}
+ const is_fifo = if (comptime Environment.isPosix)
+ std.os.S.ISFIFO(readable_file.mode) or std.os.S.ISCHR(readable_file.mode)
+ else
+ // TODO: windows
+ bun.todo(@src(), false);
+
// for our purposes, ISCHR and ISFIFO are the same
- if (std.os.S.ISFIFO(readable_file.mode) or std.os.S.ISCHR(readable_file.mode)) {
+ if (is_fifo) {
this.lazy_readable = .{
.readable = .{
.FIFO = .{
@@ -4743,6 +4790,10 @@ pub fn NewReadyWatcher(
}
if (comptime @hasField(Context, "mode")) {
+ if (comptime Environment.isWindows) {
+ return bun.todo(@src(), false);
+ }
+
return std.os.S.ISFIFO(this.mode);
}
@@ -4784,7 +4835,7 @@ pub fn NewReadyWatcher(
}
pub fn watch(this: *Context, fd_: anytype) void {
- const fd = @as(c_int, @intCast(fd_));
+ const fd = @as(bun.FileDescriptor, @intCast(fd_));
var poll_ref: *JSC.FilePoll = this.poll_ref orelse brk: {
this.poll_ref = JSC.FilePoll.init(
JSC.VirtualMachine.get(),