Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function run() {
write("index.d.ts", `// GENERATED - DO NOT EDIT\n${types}`);
}

function formatProtocol(protocol: Protocol, extraTs?: string): string {
function formatProtocol(protocol: Protocol): string {
const { definitions } = protocol;
const requestMap = new Map();
const responseMap = new Map();
Expand Down Expand Up @@ -86,9 +86,6 @@ function formatProtocol(protocol: Protocol, extraTs?: string): string {
body += formatMapType("RequestMap", requestMap);
body += formatMapType("ResponseMap", responseMap);
body += formatMapType("EventMap", eventMap);
if (extraTs) {
body += extraTs;
}
return body + "};";
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import type { Socket } from "node:net";
const enum FramerState {
WaitingForLength,
WaitingForMessage,
}

let socketFramerMessageLengthBuffer: Buffer;
export class SocketFramer {
state: FramerState = FramerState.WaitingForLength;
pendingLength: number = 0;
sizeBuffer: Buffer = Buffer.alloc(4);
sizeBufferIndex: number = 0;
bufferedData: Buffer = Buffer.alloc(0);
socket: Socket;
private onMessage: (message: string | string[]) => void;
Expand All @@ -26,10 +18,7 @@ export class SocketFramer {
}

reset(): void {
this.state = FramerState.WaitingForLength;
this.bufferedData = Buffer.alloc(0);
this.sizeBufferIndex = 0;
this.sizeBuffer = Buffer.alloc(4);
}

send(data: string): void {
Expand Down
27 changes: 0 additions & 27 deletions packages/bun-error/bun-error.css
Original file line number Diff line number Diff line change
Expand Up @@ -335,39 +335,12 @@
content: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPMAAAAgCAYAAADHXE6+AAABhWlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AYht+mSqVUHOwg4pChCooFURFHqWIRLJS2QqsOJpf+QZOGJMXFUXAtOPizWHVwcdbVwVUQBH9AHJ2cFF2kxO+SQos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ZD98Fe5hh0cDcJqW8aaizo1HWbSrvEujrhlhzK0ShWhq3mtMRTu/M0sWE2zSjq91sLYMscZM7IwTrtpsM0E0D74fiN74G7WL6HDLEBNlIeB/bNOYmmbowL6ftYbo9le8XWERSGy04fZkCzAfkvS0EmHUx88/Q7y/uItgC2QkB6j5OZ2x94vldSEKFW3vfoEx7QnlNluOIElQ6N1w9tKGTpafJAeji5i2DfD6NzZahn/epbV8zrlvMU/Bgl/XmuYaeQS7V362ISWpf3Ituhjo3yaj+EMHGER3A+wlluIfpO74W0jKrmXmfxZ9DRGc21U4m4OT2y6Glct4ny/XcUL5HIC1auMge8Sthuow1iqh3HyfXYaP6uc3iUdt+qgdVKkwBfTZBHVP/bVzcEU1KfDy2yXO6GHPsh+Lep6WzTv4MEWwuMbX7KYJNJVHxtuzD9xau+mTewYyEcWXaej0LIMUhH/E2PgxmLG/cduLy82bQZ4jYOmsXu5AiwTTRfH9GYO1HuN+fwO6hjglNDn9lvx1auOovPZudv2nk9SX1vPZNESvPam35QYRCT1IC+SkB7i+O4/Qt5fmjJp+hA/4HAHqO40yYZT6IAPKBeDvJ/yPce/WK32EE377FJHIANjteZ8mXL7CYb3rMyZ4u4/TarRcS76ehNxAsQa1g+qdxZXZ2LYHcJ6AdQv/uaO0bNB3HwXg8nigg0Yv7qkwmDoqfLPlWAYx18bR4Q6eiCzj5p3hJ4nDdSwv6UlBgmmHtYPHe8phTfOKPR6qHMdrIdsdXIcIiVwVoJgkVv2Bp/W3L2cqftnxOOeWUU0C/AoLy/OlRotLzAAAAAElFTkSuQmCC");
}

#BunError-SourceLine-text-highlightExpression {
font-weight: bold;
text-decoration-style: wavy;
}

.BunError-JSException--TypeError #BunError-SourceLine-text-highlightExpression {
border: 1px solid rgba(0, 0, 0, 0.2);
}
.BunError-Indented {
display: inline-block;
user-select: none;
-webkit-user-select: none;
}

.BunError-divet {
vertical-align: bottom;
user-select: none;
-webkit-user-select: none;
}

.BunError-error-typename {
font-family: var(--bun-error-monospace);
color: #e39437;
font-weight: bold;
}

.BunError-error-muted {
font-weight: normal;
user-select: none;
-webkit-user-select: none;
}

.BunError-error-muted,
.BunError-StackFrame--muted {
color: rgb(165, 165, 165);
}
Expand Down
18 changes: 1 addition & 17 deletions packages/bun-error/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,13 @@ enum LoadState {
const AsyncSourceLines = ({
highlight = -1,
highlightColumnStart = 0,
highlightColumnEnd = Infinity,
children,
buildURL,
sourceLines,
setSourceLines,
}: {
highlight: number;
highlightColumnStart: number;
highlightColumnEnd?: number;
children?: any;
buildURL: (line?: number, column?: number) => string;
sourceLines: SourceLine[];
Expand Down Expand Up @@ -396,7 +394,6 @@ const AsyncSourceLines = ({
<SourceLines
highlight={highlight}
highlightColumnStart={highlightColumnStart}
highlightColumnEnd={highlightColumnEnd}
buildURL={buildURL}
sourceLines={sourceLines}
>
Expand All @@ -414,21 +411,18 @@ const SourceLines = ({
sourceLines,
highlight = -1,
highlightColumnStart = 0,
highlightColumnEnd = Infinity,
children,
buildURL,
}: {
sourceLines: SourceLine[];
highlight: number;
highlightColumnStart: number;
highlightColumnEnd?: number;
children?: any;
buildURL: (line?: number, column?: number) => string;
}) => {
let start = sourceLines.length;
let end = 0;
let dedent = Infinity;
let _i = 0;
var minLineNumber = sourceLines.length + highlight + 1;
var maxLineNumber = 0;
for (let i = 0; i < sourceLines.length; i++) {
Expand Down Expand Up @@ -504,15 +498,7 @@ const BuildErrorSourceLines = ({ location, filename }: { location: Location; fil
const { line, line_text, column } = location;
const sourceLines: SourceLine[] = [{ line, text: line_text }];
const buildURL = useCallback((line, column) => srcFileURL(filename, line, column), [filename]);
return (
<SourceLines
sourceLines={sourceLines}
highlight={line}
buildURL={buildURL}
highlightColumnStart={column}
highlightColumnEnd={column}
/>
);
return <SourceLines sourceLines={sourceLines} highlight={line} buildURL={buildURL} highlightColumnStart={column} />;
};

const BuildErrorStackTrace = ({ location }: { location: Location }) => {
Expand Down Expand Up @@ -687,7 +673,6 @@ const NativeStackTrace = ({
sourceLines={sourceLines}
highlightColumnStart={position.column}
buildURL={buildURL}
highlightColumnEnd={position.column_stop}
>
{children}
</SourceLines>
Expand All @@ -699,7 +684,6 @@ const NativeStackTrace = ({
setSourceLines={setSourceLines}
highlightColumnStart={position.column}
buildURL={buildURL}
highlightColumnEnd={position.column_stop}
>
{children}
</AsyncSourceLines>
Expand Down
1 change: 1 addition & 0 deletions packages/bun-native-plugin-rs/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target/
headers/

This file was deleted.

7 changes: 3 additions & 4 deletions scripts/build/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { fileURLToPath } from "node:url";
import { allDeps } from "./deps/index.ts";

const cwd = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
// Machine-shared cache (ccache/cargo/tarballs/webkit). Matches resolveConfig()'s
// Machine-shared cache (ccache/tarballs/webkit). Matches resolveConfig()'s
// non-CI default. `clean` is a dev-machine tool so we don't branch on CI here.
const sharedCacheDir = resolve(process.env.BUN_INSTALL || resolve(homedir(), ".bun"), "build-cache");

Expand All @@ -31,9 +31,9 @@ presets:
release build/release/
debug-local build/debug-local/
release-local build/release-local/
rust cargo target dirs across all profiles + ~/.bun/build-cache/cargo
rust cargo target dirs across all profiles
cpp C++ obj/ + pch/ across all profiles
cache machine-shared build cache (~/.bun/build-cache: ccache, cargo,
cache machine-shared build cache (~/.bun/build-cache: ccache,
tarballs, prebuilt webkit) — affects ALL checkouts
deep build/, target/, vendor/* (except manually managed deps
like WebKit)
Expand Down Expand Up @@ -68,7 +68,6 @@ const presets: Record<string, () => string[]> = {

rust: () => [
...buildProfiles().map(p => resolve(p, "rust-target")),
resolve(sharedCacheDir, "cargo"),
// `cargo check`/`cargo clippy` run from the repo root with no
// --target-dir, so they write to the workspace-default `target/`.
resolve(cwd, "target"),
Expand Down
6 changes: 1 addition & 5 deletions scripts/build/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ export function resolveToolchain(targetOs?: OS, packageManager: PackageManager =
export interface ConfigureResult {
cfg: Config;
output: BunOutput;
/** Build.ninja absolute path. */
ninjaFile: string;
/** Env vars the caller should set before spawning ninja. */
env: Record<string, string>;
/** Wall-clock ms for the configure pass. */
Expand Down Expand Up @@ -391,10 +389,8 @@ export async function configure(input: ConfigureInput, fromNinja = false): Promi
}
mark("orderFile");

const ninjaFile = ninjaPath;

const elapsed = Math.round(performance.now() - start);
const exe = bunExeName(cfg) + (shouldStrip(cfg) ? " → bun (stripped)" : "");

return { cfg, output, ninjaFile, env: ccacheEnv(cfg), elapsed, changed, exe };
return { cfg, output, env: ccacheEnv(cfg), elapsed, changed, exe };
}
4 changes: 1 addition & 3 deletions scripts/build/tty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,20 @@ export function formatElapsed(ms: number): string {
/**
* Hash a name to a stable 256-color. Same name → same color across runs,
* so `[tinycc]` in stream output and `tinycc` in the done line match.
* zig overridden to brand orange.
*
* `color` defaults to this module's stderr-TTY check. stream.ts passes
* its own — it writes to FD 3 (a terminal when set up by build.ts) while
* its FD 2 is a ninja pipe, so the default check would wrongly disable.
*/
export function nameColor(name: string, text: string = name, color: boolean = useColor): string {
if (!color) return text;
const overrides: Record<string, number> = { zig: 214 };
const palette = [220, 184, 154, 120, 114, 86, 87, 81, 111, 147, 141, 183];
let h = 2166136261;
for (let i = 0; i < name.length; i++) {
h ^= name.charCodeAt(i);
h = Math.imul(h, 16777619);
}
const c = overrides[name] ?? palette[(h >>> 0) % palette.length];
const c = palette[(h >>> 0) % palette.length];
return `\x1b[38;5;${c}m${text}\x1b[39m`;
}

Expand Down
5 changes: 1 addition & 4 deletions src/codegen/bake-codegen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from "node:assert";
import { existsSync, readFileSync, rmSync } from "node:fs";
import { readFileSync, rmSync } from "node:fs";
import { basename, join } from "node:path";
import { argParse, writeIfNotChanged } from "./helpers";

Expand Down Expand Up @@ -204,9 +204,6 @@ async function run() {
process.exit(1);
} else {
console.log("-> bake.client.js, bake.server.js, bake.error.js");

const empty_file = join(codegenRoot, "bake_empty_file");
if (!existsSync(empty_file)) writeIfNotChanged(empty_file, "this is used to fulfill a build dependency");
}
}

Expand Down
12 changes: 2 additions & 10 deletions src/codegen/bundle-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async function processFileSplit(filename: string): Promise<{ functions: BundledB
const i = contents.indexOf("\n") + 1;
internal ||= contents.slice(0, i).includes("@internal");
contents = contents.slice(i);
} else if (match[1] === "type" || match[1] === "export type") {
} else if (match[1] === "type") {
const i = contents.search(consumeEndOfType);
contents = contents.slice(i + 1);
} else if (match[1] === "interface") {
Expand Down Expand Up @@ -281,10 +281,6 @@ async function processFileSplit(filename: string): Promise<{ functions: BundledB
for (const fn of functions) {
const tmpFile = path.join(TMP_DIR, `${basename}.${fn.name}.ts`);

// not sure if this optimization works properly in jsc builtins
// const useThis = fn.usesThis;
const useThis = true;

// TODO: we should use format=IIFE so we could bundle imports and extra functions.
writeFileSync(
tmpFile,
Expand All @@ -295,11 +291,7 @@ ${fn.enums.join("\n")}
// do not allow the bundler to rename a symbol to $
($);

$$capture_start$$(${fn.async ? "async " : ""}${
useThis
? `function(${fn.params.join(",")})`
: `${fn.params.length === 1 ? fn.params[0] : `(${fn.params.join(",")})`}=>`
} {${fn.source}}).$$capture_end$$;
$$capture_start$$(${fn.async ? "async " : ""}function(${fn.params.join(",")}) {${fn.source}}).$$capture_end$$;
`,
);
await Bun.sleep(1);
Expand Down
3 changes: 0 additions & 3 deletions src/codegen/bundle-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@ for (const entrypoint of bundledEntryPoints) {
captured =
captured
.replace(/\$\$EXPORT\$\$\((.*)\).\$\$EXPORT_END\$\$;/, "return $1")
.replace(/]\s*,\s*__(debug|assert)_end__\)/g, ")")
.replace(/]\s*,\s*__debug_end__\)/g, ")")
.replace(/import.meta.require\((.*?)\)/g, (expr, specifier) => {
throw new Error(`Builtin Bundler: do not use import.meta.require() (in ${file_path}))`);
})
Expand Down Expand Up @@ -377,7 +375,6 @@ mark("Bundle Functions");
writeIfNotChanged(
path.join(CODEGEN_DIR, "InternalModuleRegistry+numberOfModules.h"),
`#define BUN_INTERNAL_MODULE_COUNT ${moduleList.length}
#define BUN_NATIVE_MODULE_START_INDEX ${nativeStartIndex}
`,
);

Expand Down
Loading
Loading