# {{npm_name}}

{{description}}

A Perry "native library" package — a Rust crate exporting `extern "C"` symbols that the [Perry TypeScript-to-native compiler](https://github.com/PerryTS/perry) links into your TypeScript program.

## Install

```sh
bun add {{npm_name}}
# or
npm install {{npm_name}}
```

The package's `package.json` declares a `perry.nativeLibrary` block (see the [manifest spec](https://github.com/PerryTS/perry/blob/main/docs/src/native-libraries/manifest-v1.md)) that Perry's compiler reads at link time to discover the staticlib + `extern "C"` symbols.

## Usage

```typescript
import { hello } from "{{npm_name}}";

console.log(hello("perry"));  // → "Hello, perry!"
```

## Development

This package was scaffolded by `perry native init`. To add new bindings:

1. Add a `js_<name>` function in `src/lib.rs` with `#[no_mangle] pub extern "C"`. Use only `perry_ffi` types — never reach into `perry-runtime` directly.
2. Add the matching `declare function js_<name>(...)` to `src/index.ts`, then export a wrapper that calls that `js_*` symbol.
3. Add the function to the `perry.nativeLibrary.functions[]` array in `package.json` so the Perry compiler knows the calling convention.
4. Run `perry native validate` to confirm symbols + signatures match between the three.

```sh
# Build the staticlib
cargo build --release

# Diff symbols against the manifest
perry native validate
```

## License

MIT — see [LICENSE](./LICENSE).
