mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 13:22:07 +00:00
Move Bun to JSC.API
This commit is contained in:
1618
src/javascript/jsc/api/bun.zig
Normal file
1618
src/javascript/jsc/api/bun.zig
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user