{"id":20635799,"url":"https://github.com/orsinium-labs/wypes","last_synced_at":"2025-04-15T21:25:55.479Z","repository":{"id":225682238,"uuid":"766064291","full_name":"orsinium-labs/wypes","owner":"orsinium-labs","description":"Go library to define type-safe host functions in wazero and other WebAssembly runtimes.","archived":false,"fork":false,"pushed_at":"2025-04-07T15:59:53.000Z","size":79,"stargazers_count":20,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T16:46:54.871Z","etag":null,"topics":["generics","go","golang","tinygo","wasm","wazero","webassembly"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/orsinium-labs/wypes","language":"Go","has_issues":false,"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/orsinium-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2024-03-02T08:33:30.000Z","updated_at":"2025-04-07T15:59:58.000Z","dependencies_parsed_at":"2024-03-08T10:29:17.192Z","dependency_job_id":"2fd941ea-7f4b-4e5a-ae74-deb5458c2e81","html_url":"https://github.com/orsinium-labs/wypes","commit_stats":null,"previous_names":["orsinium-labs/wypes"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsinium-labs%2Fwypes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsinium-labs%2Fwypes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsinium-labs%2Fwypes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsinium-labs%2Fwypes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orsinium-labs","download_url":"https://codeload.github.com/orsinium-labs/wypes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249155846,"owners_count":21221669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["generics","go","golang","tinygo","wasm","wazero","webassembly"],"created_at":"2024-11-16T15:07:33.184Z","updated_at":"2025-04-15T21:25:55.453Z","avatar_url":"https://github.com/orsinium-labs.png","language":"Go","funding_links":[],"categories":["WebAssembly"],"sub_categories":["WASI and WASM Unknown"],"readme":"# wypes\n\nGo library to define type-safe host functions in [wazero](https://github.com/tetratelabs/wazero) and other [WebAssembly](https://webassembly.org/) runtimes.\n\nFeatures:\n\n* 🛡 Type safe\n* 🐎 Fast\n* 🔨 Works with any WebAssmebly runtime, like [wazero](https://github.com/tetratelabs/wazero) or [wasman](https://github.com/c0mm4nd/wasman)\n* 🧠 Handles for you memory operations\n* 👉 Manages external references\n* 🧼 Simple and clean API\n* 🐜 Can be compiled with TinyGo\n* 😎 No reflect, no unsafe, only generics and dedication.\n\n## 📦 Installation\n\n```bash\ngo get github.com/orsinium-labs/wypes\n```\n\n## 🔧 Usage\n\nDefine a function using provided types:\n\n```go\nfunc addI32(a wypes.Int32, b wypes.Int32) wypes.Int32 {\n    return a + b\n}\n```\n\nDefine a mapping of module and function names to function definitions:\n\n```go\nmodules := wypes.Modules{\n    \"env\": {\n        \"add_i32\": wypes.H2(addI32),\n    },\n}\n```\n\nLink the modules to the runtime. We provide a convenience method to do this for wazero:\n\n```go\nerr := modules.DefineWazero(r, nil)\n```\n\nThat's it! Now the wasm module can call the `env.add_i32` function.\n\n## 🛹 Tricks\n\nThe library provides lots of useful types that you can use in your functions. Make sure to [check the docs](https://pkg.go.dev/github.com/orsinium-labs/wypes). A few highlights:\n\n1. [Context](https://pkg.go.dev/github.com/orsinium-labs/wypes#Context) provides access to the context.Context passed into the guest function call in wazero.\n1. [Store](https://pkg.go.dev/github.com/orsinium-labs/wypes#Store) provides access to all the state: memory, stack, references.\n1. [Duration](https://pkg.go.dev/github.com/orsinium-labs/wypes#Duration) and [Time](https://pkg.go.dev/github.com/orsinium-labs/wypes#Time) to pass time.Duration and time.Time (as UNIX timestamp).\n1. [HostRef](https://pkg.go.dev/github.com/orsinium-labs/wypes#HostRef) can hold a reference to the [Refs](https://pkg.go.dev/github.com/orsinium-labs/wypes#Refs) store of host objects.\n1. [Void](https://pkg.go.dev/github.com/orsinium-labs/wypes#Void) is used as the return type for functions that return no value.\n\nSee [documentation](https://pkg.go.dev/github.com/orsinium-labs/wypes) for more.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forsinium-labs%2Fwypes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forsinium-labs%2Fwypes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forsinium-labs%2Fwypes/lists"}