Files
Sawyer Hood 16dec89cfe feat!: ship doobie as dev-browser 1.0 (#133)
* doobie: skeleton — client, daemon, vm runner, page helpers, build

Co-Authored-By: Claude <noreply@anthropic.com>

* doobie: snapshot engine, waitForLoad, docs, tests, bench, Bun-native fast client

Co-Authored-By: Claude <noreply@anthropic.com>

* doobie: fix round 1 from adversarial review (transport backpressure, profiles per mode, page mutex, bringToFront, zombie runs, shot DPR, dialogs, snapshot names/frames/boxes, docs)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: handoff notes

Co-Authored-By: Claude <noreply@anthropic.com>

* launch: mark clean exit to skip session restore, cache --no-sandbox; untrack build artifact

Co-Authored-By: Claude <noreply@anthropic.com>

* snapshot: drop [cursor=pointer] on inherently interactive roles, no row content names (HN interactive 29k -> 21k chars)

Co-Authored-By: Claude <noreply@anthropic.com>

* ci: bench tolerance on shared runners; release: npm publish only with NPM_TOKEN

Co-Authored-By: Claude <noreply@anthropic.com>

* mcp: stdio MCP server over the daemon frames (doobie mcp); ci: explicit test timeout

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: bb integration note (socket source contract)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix round 2: front lock (no stale cache), run gate covers handles/frames/popups, --connect extends only touched tabs, doobie chrome verifies launch, self-healing shim + devDependencies, snapshot name fallbacks/pointer inheritance/shadow refs, docs

Co-Authored-By: Claude <noreply@anthropic.com>

* daemon: drain active requests before exit; tests: realpath-safe and node-optional packaging tests; chrome: share sandbox helpers

Co-Authored-By: Claude <noreply@anthropic.com>

* relative file paths resolve against the caller's cwd; readFile("downloads/<name>"); TimeoutError for ref waits

Co-Authored-By: Claude <noreply@anthropic.com>

* runtime: share host Error constructors with the script realm

Co-Authored-By: Claude <noreply@anthropic.com>

* shim: sh/JS polyglot so bun-only machines run it; v0.1.1

Co-Authored-By: Claude <noreply@anthropic.com>

* launch: automation profile prefs (leak-detection dialog off, no password/autofill UI) — fixes dead input after logins in new headless

Co-Authored-By: Claude <noreply@anthropic.com>

* v0.1.2

Co-Authored-By: Claude <noreply@anthropic.com>

* client: retry when racing a shutting-down daemon (flaky stop/status on CI)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat!: make doobie the dev-browser 1.0 runtime

* ci: use Node 24 GitHub actions

* fix: isolate authenticated CDP sessions

* fix: close run gate escape paths

* fix: preserve UTF-8 across protocol chunks

* test: stabilize browser context gate coverage

* test: isolate browser context gate coverage

---------

Co-authored-by: Sawyer Hood <kirbyhood@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
2026-09-03 17:21:40 -07:00

71 lines
2.5 KiB
TypeScript

/**
* Build: (1) bundle the daemon to build/daemon.js, (2) compile the CLI into
* a single binary that embeds that bundle.
*
* bun run scripts/build.ts daemon -> build/daemon.js
* bun run scripts/build.ts all -> build/daemon.js + dist/dev-browser
* bun run scripts/build.ts all --target bun-darwin-arm64 (cross-compile)
*/
import { $ } from "bun";
import * as fs from "node:fs";
import * as path from "node:path";
const root = path.resolve(import.meta.dir, "..");
const what = process.argv[2] ?? "all";
const targetIdx = process.argv.indexOf("--target");
const target = targetIdx > 0 ? process.argv[targetIdx + 1] : undefined;
const outfileIdx = process.argv.indexOf("--outfile");
const outfile = outfileIdx > 0 ? process.argv[outfileIdx + 1]! : path.join(root, "dist", "dev-browser");
delete process.env.NODE_PATH;
fs.mkdirSync(path.join(root, "build"), { recursive: true });
fs.mkdirSync(path.join(root, "dist"), { recursive: true });
async function buildDaemon(): Promise<void> {
const t0 = Date.now();
const result = await Bun.build({
entrypoints: [path.join(root, "src/daemon/bundle.ts")],
outdir: path.join(root, "build"),
naming: "daemon.js",
target: "bun",
format: "esm",
// Keep identifiers: puppeteer-core's errors set `this.name =
// this.constructor.name`, so identifier minification turns TimeoutError
// into "B8" in every error line and in e.name inside scripts.
minify: { whitespace: true, syntax: true, identifiers: false },
sourcemap: "none",
// yauzl is bundled so `dev-browser install` works without an `unzip` binary;
// proxy-agent (optional HTTPS_PROXY support) stays out of the bundle.
external: ["proxy-agent"],
});
if (!result.success) {
for (const l of result.logs) console.error(l);
throw new Error("daemon bundle failed");
}
const size = fs.statSync(path.join(root, "build/daemon.js")).size;
console.log(`build/daemon.js ${(size / 1024).toFixed(0)} KB in ${Date.now() - t0}ms`);
}
async function compileCli(): Promise<void> {
const t0 = Date.now();
const args = [
"build",
"--compile",
"--minify-whitespace",
"--minify-syntax",
path.join(root, "src/cli/compiled-entry.ts"),
"--outfile",
outfile,
];
if (target) args.push("--target", target);
await $`bun ${args}`.cwd(root);
const size = fs.statSync(outfile).size;
console.log(`${path.relative(root, outfile)} ${(size / 1024 / 1024).toFixed(0)} MB in ${Date.now() - t0}ms`);
}
if (what === "daemon") await buildDaemon();
else {
await buildDaemon();
await compileCli();
}