Move Bun to JSC.API

This commit is contained in:
Jarred Sumner
2022-03-17 18:28:24 -07:00
parent d5613308f9
commit 86a4ab704d
8 changed files with 1667 additions and 1420 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -450,7 +450,7 @@ pub fn getScriptSrcString(
// instead, we just store a boolean saying whether we should generate this whenever the script is requested
// this is kind of bad. we should consider instead a way to inline the contents of the script.
if (client_framework_enabled) {
JavaScript.Bun.getPublicPath(
JSC.API.Bun.getPublicPath(
Bundler.ClientEntryPoint.generateEntryPointPath(
&entry_point_tempbuf,
Fs.PathName.init(file_path),
@@ -460,7 +460,7 @@ pub fn getScriptSrcString(
writer,
);
} else {
JavaScript.Bun.getPublicPath(file_path, VirtualMachine.vm.origin, Writer, writer);
JSC.API.Bun.getPublicPath(file_path, VirtualMachine.vm.origin, Writer, writer);
}
}

View File

@@ -1252,7 +1252,7 @@ pub const ZigConsoleClient = struct {
// Temporary workaround
// console.log(process.env) shows up as [class JSCallbackObject]
// We want to print it like an object
if (CAPI.JSValueIsObjectOfClass(globalThis.ref(), value.asObjectRef(), JSC.Bun.EnvironmentVariables.Class.get().?[0])) {
if (CAPI.JSValueIsObjectOfClass(globalThis.ref(), value.asObjectRef(), JSC.API.Bun.EnvironmentVariables.Class.get().?[0])) {
return .{
.tag = .Object,
.cell = js_type,
@@ -2472,7 +2472,7 @@ comptime {
@export(ErrorCode.JSErrorObject, .{ .name = "Zig_ErrorCodeJSErrorObject" });
}
const Bun = @import("../javascript.zig").Bun;
const Bun = @import("../api/bun.zig");
pub const BunTimer = Bun.Timer;
pub const Formatter = ZigConsoleClient.Formatter;

File diff suppressed because it is too large Load Diff

View File

@@ -1670,9 +1670,12 @@ pub const Blob = struct {
return true;
const prev_content_type = this.content_type;
defer if (this.content_type_allocated) bun.default_allocator.free(prev_content_type);
var content_type_buf = getAllocator(ctx).alloc(u8, slice.len) catch unreachable;
this.content_type = strings.copyLowercase(slice, content_type_buf);
{
defer if (this.content_type_allocated) bun.default_allocator.free(prev_content_type);
var content_type_buf = getAllocator(ctx).alloc(u8, slice.len) catch unreachable;
this.content_type = strings.copyLowercase(slice, content_type_buf);
}
this.content_type_allocated = true;
return true;
}

View File

@@ -6,7 +6,7 @@ const MimeType = @import("../../../http.zig").MimeType;
const ZigURL = @import("../../../url.zig").URL;
const HTTPClient = @import("http");
const NetworkThread = HTTPClient.NetworkThread;
const bun = @import("../../global.zig");
const JSC = @import("../../../jsc.zig");
const js = JSC.C;
@@ -131,8 +131,9 @@ pub const DOMURL = struct {
var input = value.toSlice(globalThis, bun.default_allocator);
defer input.deinit();
const buf = input.slice();
const host_len = copy.parseHost(buf) orelse return false;
_ = copy.parseHost(buf) orelse return false;
var temp_clone = std.fmt.allocPrint("{}://{s}/{s}", .{ this.url.displayProtocol(), copy.displayHost(), strings.trimLeadingChar(this.url.pathname, '/') }) catch return false;
this.url = URL.parse(temp_clone);
this.m_string = JSC.VirtualMachine.vm.refCountedString(temp_clone, null, false);
if (this.m_string.ptr != temp_clone.ptr) {
bun.default_allocator.free(temp_clone);