Merge branch 'main' into zack/ssg-3

This commit is contained in:
Zack Radisic
2025-09-26 23:50:10 -07:00
201 changed files with 9736 additions and 1795 deletions

View File

@@ -236,6 +236,15 @@ pub fn writable(this: *StringBuilder) []u8 {
return ptr[this.len..this.cap];
}
/// Transfer ownership of the underlying memory to a slice.
///
/// After calling this, you are responsible for freeing the underlying memory.
/// This StringBuilder should not be used after calling this function.
pub fn moveToSlice(this: *StringBuilder, into_slice: *[]u8) void {
into_slice.* = this.allocatedSlice();
this.* = .{};
}
const std = @import("std");
const Allocator = std.mem.Allocator;

View File

@@ -217,8 +217,16 @@ pub const WTFStringImplStruct = extern struct {
pub fn hasPrefix(self: WTFStringImpl, text: []const u8) bool {
return bun.cpp.Bun__WTFStringImpl__hasPrefix(self, text.ptr, text.len);
}
pub const external_shared_descriptor = struct {
pub const ref = WTFStringImplStruct.ref;
pub const deref = WTFStringImplStruct.deref;
};
};
/// Behaves like `WTF::Ref<WTF::StringImpl>`.
pub const WTFString = bun.ptr.ExternalShared(WTFStringImplStruct);
pub const StringImplAllocator = struct {
fn alloc(ptr: *anyopaque, len: usize, _: std.mem.Alignment, _: usize) ?[*]u8 {
var this = bun.cast(WTFStringImpl, ptr);

View File

@@ -2313,7 +2313,6 @@ pub const addNTPathPrefix = paths_.addNTPathPrefix;
pub const addNTPathPrefixIfNeeded = paths_.addNTPathPrefixIfNeeded;
pub const addLongPathPrefix = paths_.addLongPathPrefix;
pub const addLongPathPrefixIfNeeded = paths_.addLongPathPrefixIfNeeded;
pub const assertIsValidWindowsPath = paths_.assertIsValidWindowsPath;
pub const charIsAnySlash = paths_.charIsAnySlash;
pub const cloneNormalizingSeparators = paths_.cloneNormalizingSeparators;
pub const fromWPath = paths_.fromWPath;

View File

@@ -288,24 +288,6 @@ fn isUNCPath(comptime T: type, path: []const T) bool {
!bun.path.Platform.windows.isSeparatorT(T, path[2]) and
path[2] != '.';
}
pub fn assertIsValidWindowsPath(comptime T: type, path: []const T) void {
if (Environment.allow_assert and Environment.isWindows) {
if (bun.path.Platform.windows.isAbsoluteT(T, path) and
isWindowsAbsolutePathMissingDriveLetter(T, path) and
// is it a null device path? that's not an error. it's just a weird file path.
!eqlComptimeT(T, path, "\\\\.\\NUL") and !eqlComptimeT(T, path, "\\\\.\\nul") and !eqlComptimeT(T, path, "\\nul") and !eqlComptimeT(T, path, "\\NUL") and !isUNCPath(T, path))
{
std.debug.panic("Internal Error: Do not pass posix paths to Windows APIs, was given '{s}'" ++ if (Environment.isDebug) " (missing a root like 'C:\\', see PosixToWinNormalizer for why this is an assertion)" else ". Please open an issue on GitHub with a reproduction.", .{
if (T == u8) path else bun.fmt.utf16(path),
});
}
if (hasPrefixComptimeType(T, path, ":/") and Environment.isDebug) {
std.debug.panic("Path passed to windows API '{s}' is almost certainly invalid. Where did the drive letter go?", .{
if (T == u8) path else bun.fmt.utf16(path),
});
}
}
}
pub fn toWPathMaybeDir(wbuf: []u16, utf8: []const u8, comptime add_trailing_lash: bool) [:0]u16 {
bun.unsafeAssert(wbuf.len > 0);
@@ -518,7 +500,6 @@ const assert = bun.assert;
const strings = bun.strings;
const copyUTF16IntoUTF8 = strings.copyUTF16IntoUTF8;
const eqlComptimeT = strings.eqlComptimeT;
const hasPrefixComptime = strings.hasPrefixComptime;
const hasPrefixComptimeType = strings.hasPrefixComptimeType;
const hasPrefixComptimeUTF16 = strings.hasPrefixComptimeUTF16;