crates/but-napi/README.md
but-napi is used to build GitButler's Node native add-on via napi-rs.
Export types and bindings for TypeScript to be able to call our Rust API.
.node binary for @gitbutler/but-sdk.but-api so auto-generated N-API exports are discoverable by napi-rs.crates/but-api are annotated with #[but_api(napi)].but_api proc macro generates *_napi wrappers (feature-gated by napi).but-napi enables this with the napi-auto feature (but-api/napi) and compiles as a cdylib.@napi-rs/cli builds this crate and writes JS + DTS + .node artifacts into packages/but-sdk/src/generated.legacy (default): enables legacy APIs required by current desktop/lite workflows.napi-auto (default): turns on auto-generated #[but_api(napi)] exports.From the repository root, use the but-sdk scripts (source of truth for local development flow):
pnpm --filter @gitbutler/but-sdk build
This will generate the native addon, JS loader, and type declarations (both generated by napi-rs and by but-ts) output in packages/but-sdk/src/generated.
crates/but-api, add #[but_api(napi)] to the API function.pnpm --filter @gitbutler/but-sdk build:napi.*Napi function appears in packages/but-sdk/src/generated/index.d.ts.crates/but-napi/.napi-rs.json defines package/target metadata.packages/but-sdk/package.json (build:napi).