{"id":26465512,"url":"https://github.com/mmycin/zigport","last_synced_at":"2026-03-16T07:03:34.305Z","repository":{"id":282977324,"uuid":"949586474","full_name":"mmycin/zigport","owner":"mmycin","description":"A CLI tool that automatically generates TypeScript FFI bindings for Zig libraries, making it easy to call Zig functions from JavaScript/TypeScript in Bun projects","archived":false,"fork":false,"pushed_at":"2025-06-03T17:24:06.000Z","size":47,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-09T00:49:29.968Z","etag":null,"topics":["bun-ffi","cli","ffi","generator","zig","zig-ffi"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/zigport","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmycin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-16T19:24:11.000Z","updated_at":"2025-06-03T17:24:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"40176978-84fe-40f3-bb8d-6bf71c311366","html_url":"https://github.com/mmycin/zigport","commit_stats":null,"previous_names":["mmycin/zigport"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mmycin/zigport","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmycin%2Fzigport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmycin%2Fzigport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmycin%2Fzigport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmycin%2Fzigport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmycin","download_url":"https://codeload.github.com/mmycin/zigport/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmycin%2Fzigport/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30571194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-16T06:02:37.763Z","status":"ssl_error","status_checked_at":"2026-03-16T06:02:14.913Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun-ffi","cli","ffi","generator","zig","zig-ffi"],"created_at":"2025-03-19T10:36:33.402Z","updated_at":"2026-03-16T07:03:34.300Z","avatar_url":"https://github.com/mmycin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zigport\n\n`zigport` is an NPM package as well as a command-line tool that automates the generation of TypeScript Foreign Function Interface (FFI) bindings for **Zig** libraries created by Tahcin Ul Karim (Mycin). It simplifies the process of calling Zig functions from JavaScript/TypeScript, making it an excellent choice for **Bun**-based projects that require high-performance Zig functions. Yes, you can now summon Zig speed into your Bun app without breaking a sweat!\n\n---\n\n## Why zigport?\n\n- **Automated Zig FFI Binding Generation**: No need to manually write bindings; `zigport` does the heavy lifting for you.\n- **Seamless Integration with Bun**: Works like magic with Bun’s FFI capabilities.\n- **Efficient Type Mapping**: Zig types get mapped to TypeScript with zero headaches.\n- **Simple CLI Interface**: Generate and clean bindings with a single command. No over-engineered nonsense.\n\n## Installation\n\nYou can install `zigport` globally using `npm`, `yarn`, or `bun`:\n\n```bash\n# Using npm\nnpm install -g zigport\n\n# Using yarn\nyarn global add zigport\n\n# Using bun\nbun add -g zigport\n```\n\n## Getting Started\n\n### 1. Set Up Your Project\n\nCreate a `lib/` directory in your project root. This is where the magic happens.\n\n```bash\nmkdir -p lib/zig\n```\n\n### 2. Write Your Zig Code\n\nInside `lib/zig/`, create a Zig source file (e.g., `hello.zig`) with the following content:\n\n```zig\nconst std = @import(\"std\");\n\nexport fn say_hello() void {\n    std.debug.print(\"Hello, {s}!\\n\", .{\"World\"});\n}\n```\n\n### 3. Generate Bindings\n\nNow, let `zigport` do its thing:\n\n```bash\nzigport generate lib/\n```\n\nThis will:\n- Compile Zig files into dynamic libraries (`.so`, `.dll`, `.dylib` depending on your platform).\n- Generate TypeScript FFI bindings.\n- Create an `index.ts` file inside `lib/`.\n\n### 4. Use Zig Functions in TypeScript\n\nOnce the bindings are generated, import and use them in your TypeScript code:\n\n```typescript\nimport { sayHello } from \"./lib\";\n\nsayHello();\n```\n\n### 5. Run it!\nNote that for now it only supports **Bun**, but we’re working on supporting Deno and Node.js. For this, you'll need Bun installed on your machine.\nInstall Bun using `npm`, `yarn`, or `bun`:  \n```bash\nnpm install -g bun\n```\nNow run the file.\n\n```bash\nbun run fileName.ts\n```\n\nBoom. Zig-powered performance, Bun simplicity. Life’s good.\n\n---\n\n## CLI Commands\n\n### `zigport generate \u003cpath\u003e`\nGenerates Zig FFI bindings and compiles Zig files into dynamic libraries.\n\n```bash\nzigport generate lib/\n```\n\n### `zigport clean`\nRemoves generated files, including compiled Zig libraries and TypeScript bindings.\n\n```bash\nzigport clean\n```\n\n### `zigport help`\nDisplays the help menu with available commands.\n\n```bash\nzigport help\n```\n\n---\n\n## Advanced Usage\n\n### Passing and Returning Numbers\n\nZig can return numbers, making complex calculations lightning-fast.\n\n#### Zig Code (`math.zig`):\n\n```zig\nexport fn add_numbers(a: i32, b: i32) i32 {\n    return a + b;\n}\n```\n\nGenerate bindings:\n\n```bash\nzigport generate lib/\n```\n\n#### TypeScript Usage:\n\n```typescript\nimport { addNumbers } from \"./lib\";\n\nconsole.log(\"5 + 3 =\", addNumbers(5, 3));\n```\n\n### Passing and Returning Strings\n\nZig can return strings too! But memory management is your responsibility.\n\n#### Zig Code (`string_utils.zig`):\n\n```zig\nconst std = @import(\"std\");\n\nexport fn greet(name: [*]const u8) [*]const u8 {\n    const message = \"Hello, \" ++ name ++ \"!\";\n    return message;\n}\n```\n\nGenerate bindings:\n\n```bash\nzigport generate lib/\n```\n\n#### TypeScript Usage:\n\n```typescript\nimport { greet } from \"./lib\";\n\nconsole.log(greet(\"Alice\"));\n```\n\nZig just greeted Alice from TypeScript. Mind-blowing, right?\n\n---\n\n## Troubleshooting\n\n### 1. `zigport` fails to generate bindings\n- Ensure that **Zig** is installed.\n- Check that the `lib/zig/` directory contains valid Zig files.\n- Run `zig build` inside `lib/zig/` to diagnose compilation issues.\n\n### 2. TypeScript FFI calls fail\n- Ensure that the Zig functions are properly exported using `export`.\n- Verify that the correct function signatures are used in TypeScript.\n\n### 3. Dynamic libraries are not loading\n- On **Windows**, ensure that `.dll` files are in the correct directory.\n- On **macOS**, use `install_name_tool` to set the correct library paths.\n- On **Linux**, check `LD_LIBRARY_PATH`.\n\n---\n\n## Example Project\n\nHere’s a simple Bun project using `zigport`:\n\n### Directory Structure\n```\nmy-project/\n├── lib/\n│   ├── zig/\n│   │   ├── hello.zig\n│   │   ├── math.zig\n│   │   ├── string_utils.zig\n│   │   ├── build.zig\n├── src/\n│   ├── main.ts\n├── package.json\n```\n\n### `main.ts`\n\n```typescript\nimport { sayHello, addNumbers, greet } from \"../lib\";\n\nsayHello(\"zigport User\");\nconsole.log(addNumbers(10, 20));\nconsole.log(greet(\"Bob\"));\n```\n\n---\n\n## Contributing\n\nLove `zigport`? Want to make it even better? Feel free to open issues or submit pull requests on GitHub. If `zigport` saved you hours of headache, consider buying us a virtual coffee ☕️!\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\nNote: Also, check out [RustPort](https://github.com/mmycin/rustport) – a similar tool that generates TypeScript FFI bindings for Rust libraries. Because Rust needs love too!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmycin%2Fzigport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmycin%2Fzigport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmycin%2Fzigport/lists"}