Files
gpuix/scripts/package.json
Tommy D. Rossi 1d2b470936 Add bun run dev, a watch loop for the Rust side
There is no hot reload for the native half and there cannot be. require()
of a .node file calls process.dlopen, Node has no matching unload, and the
live state (the winit event loop, the wgpu device, the open window, the
selection registry) lives in thread-locals of the loaded library. A second
load would get empty thread-locals and a dead window, and napi registers
the module once per process.

The rebuild is fast enough that it does not matter. Measured after
touching one file:

    cargo check --lib             1.5s
    cargo build --lib             4.9s
    bun run build:debug (napi)   ~2s
    one vitest screenshot file   ~2s

scripts/dev.ts watches packages/native/src, rebuilds, and refreshes a
target. A Rust edit reaches fresh PNGs in about four seconds.

    bun run dev                            rebuild, re-render screenshots
    bun scripts/dev.ts --shots diff        only tests matching "diff"
    bun scripts/dev.ts --app native-text   rebuild, restart an example app

Screenshot mode is the default because Preview.app reloads a PNG on write
and, unlike a live window, the PNG can be read by an agent.

Builds are serialized: a burst of saves otherwise starts overlapping cargo
runs that then block on cargo's own lock and report confusing timings.

scripts/ gets its own package.json and tsconfig.json so the watcher is
type-checked (`bun x tsc -p scripts`) rather than only being run.
2026-08-19 22:58:22 +02:00

6 lines
70 B
JSON

{
"name": "@gpuix/scripts",
"private": true,
"type": "module"
}