{"id":15723198,"url":"https://github.com/insality/defold-proto","last_synced_at":"2025-05-12T13:45:35.541Z","repository":{"id":251112447,"uuid":"836408359","full_name":"Insality/defold-proto","owner":"Insality","description":"Defold Protobuf Library to encode, decode and verifying messages","archived":false,"fork":false,"pushed_at":"2024-07-31T19:46:14.000Z","size":904,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-11T13:42:46.731Z","etag":null,"topics":["defold","defold-editor-script","defold-extension","defold-library","defold-module","defold-native-extension","proto","protobuf"],"latest_commit_sha":null,"homepage":"","language":"C","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/Insality.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"insality","ko_fi":"insality","buy_me_a_coffee":"insality"}},"created_at":"2024-07-31T19:33:37.000Z","updated_at":"2025-04-29T00:07:27.000Z","dependencies_parsed_at":"2024-08-01T00:53:43.014Z","dependency_job_id":null,"html_url":"https://github.com/Insality/defold-proto","commit_stats":null,"previous_names":["insality/defold-proto"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insality%2Fdefold-proto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insality%2Fdefold-proto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insality%2Fdefold-proto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Insality%2Fdefold-proto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Insality","download_url":"https://codeload.github.com/Insality/defold-proto/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253749933,"owners_count":21958222,"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":["defold","defold-editor-script","defold-extension","defold-library","defold-module","defold-native-extension","proto","protobuf"],"created_at":"2024-10-03T22:10:37.966Z","updated_at":"2025-05-12T13:45:35.519Z","avatar_url":"https://github.com/Insality.png","language":"C","funding_links":["https://github.com/sponsors/insality","https://ko-fi.com/insality","https://buymeacoffee.com/insality","https://www.buymeacoffee.com/insality"],"categories":[],"sub_categories":[],"readme":"![](media/logo.png)\n\n[![GitHub release (latest by date)](https://img.shields.io/github/v/tag/insality/defold-proto?style=for-the-badge\u0026label=Release)](https://github.com/Insality/defold-proto/tags)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/insality/defold-proto/ci_workflow.yml?style=for-the-badge)](https://github.com/Insality/defold-proto/actions)\n[![codecov](https://img.shields.io/codecov/c/github/Insality/defold-proto?style=for-the-badge)](https://codecov.io/gh/Insality/defold-proto)\n\n[![Github-sponsors](https://img.shields.io/badge/sponsor-30363D?style=for-the-badge\u0026logo=GitHub-Sponsors\u0026logoColor=#EA4AAA)](https://github.com/sponsors/insality) [![Ko-Fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge\u0026logo=ko-fi\u0026logoColor=white)](https://ko-fi.com/insality) [![BuyMeACoffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge\u0026logo=buy-me-a-coffee\u0026logoColor=black)](https://www.buymeacoffee.com/insality)\n\n# Proto\n\n**Proto** - a [Defold](https://defold.com/) library for working with protocol buffers (_protobuf_ or _proto_). The library provides functions for encoding, decoding, and verifying protocol buffer messages. Verification is used to ensure that the lua table matches the protocol buffer definition. If the table data does not match the definition, the missing fields are set to default values, and the extra fields are removed. Verification also supports nested messages.\n\n## Features\n\n- **Encoding**: Encode a table with data to a binary string by proto definition.\n- **Decoding**: Decode a binary string to a table with data by proto definition.\n- **Verification**: Verify a table with data to match the proto definition.\n- **Annotations**: Editor script to generate Lua annotations from proto files.\n\n## Setup\n\n### [Dependency](https://www.defold.com/manuals/libraries/)\n\nOpen your `game.project` file and add the following line to the dependencies field under the project section:\n\n**[Defold Proto](https://github.com/Insality/defold-proto/archive/refs/tags/1.zip)**\n\n```\nhttps://github.com/Insality/defold-proto/archive/refs/tags/1.zip\n```\n\nAfter that, select `Project ▸ Fetch Libraries` to update [library dependencies]((https://defold.com/manuals/libraries/#setting-up-library-dependencies)). This happens automatically whenever you open a project so you will only need to do this if the dependencies change without re-opening the project.\n\n### Library Size\n\n\u003e **Note:** The library size is calculated based on the build report per platform\n\n| Platform         | Library Size |\n| ---------------- | ------------ |\n| HTML5            | **11.70 KB**  |\n| Desktop / Mobile | **18.81 KB**  |\n\n\n### Configuration [optional]\n\nYou can configure the **Proto** module in the `game.project` file:\n\n```ini\n[proto]\nskip_default_nest_messages = 1\n```\n\nThis configuration section for `game.project` file has the following options:\n\n- **skip_default_nest_messages**: If the value is `1`, the module will skip the default values for nested messages. If the value is `0`, the module will set the default values for all nested messages. Default value is `0`. Since it's library additional feature, I want to give the ability to disable it.\n\n\n### Proto File Paths\n\nThe Proto module uses the `.proto` files to define the protocol buffer messages. You can specify the paths to the proto files in a JSON file or a lua table. Here is an example of a JSON file:\n\n```js\n// /resources/proto.json\n{\n\t\"/resources/proto\": [\n\t\t\"game.proto\"\n\t]\n}\n```\n\n```lua\nproto.init(\"/resources/proto.json\")\n```\n\nHere is an example of passing a lua table directly instead of a JSON file:\n\n```lua\nproto.init({\n\t[\"/resources/proto\"]: {\n\t\t\"game.proto\"\n\t}\n})\n```\n\nThe JSON file or lua table should have the following format:\n- **Key**: The path to folder with proto files. This folder should be in the custom resources.\n- **Value**: A list of proto file names in the folder.\n\nThe module uses `sys.load_resource` to load the files. Place your files inside your [custom resources folder](https://defold.com/manuals/project-settings/#custom-resources) to ensure they are included in the build.\n\n\n### Proto File\n\nThe Proto module uses the `.proto` files to define the protocol buffer messages. Here is an example of a `.proto` file:\n\n```proto\nsyntax = \"proto3\";\n\npackage game;\n\nmessage data {\n\tstring id = 1;\n\tuint32 number = 2;\n\tbool flag = 3;\n\tnested_data nested = 4;\n}\n\nmessage nested_data {\n\tstring id = 1;\n\tuint32 number = 2;\n}\n```\n\n\n## API Reference\n\n### Quick API Reference\n\n```lua\nproto.init(config_or_path)\nproto.get(proto_type)\nproto.encode(proto_type, data)\nproto.decode(proto_type, data)\nproto.verify(proto_type, data)\nproto.set_logger(logger)\n```\n\n### API Reference\n\nRead the [API Reference](API_REFERENCE.md) file to see the full API documentation for the module.\n\n\n## Use Cases\n\nRead the [Use Cases](USE_CASES.md) file to see several examples of how to use the this module in your Defold game development projects.\n\n\n## FAQ\n\nRead the [FAQ](FAQ.md) file to see the frequently asked questions about the module.\n\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n\n## Issues and Suggestions\n\nFor any issues, questions, or suggestions, please [create an issue](https://github.com/Insality/defold-proto/issues).\n\n\n## 👏 Contributors\n\n\u003ca href=\"https://github.com/Insality/defold-proto/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contributors-img.web.app/image?repo=insality/defold-proto\"/\u003e\n\u003c/a\u003e\n\n\n## ❤️ Support project ❤️\n\nYour donation helps me stay engaged in creating valuable projects for **Defold**. If you appreciate what I'm doing, please consider supporting me!\n\n[![Github-sponsors](https://img.shields.io/badge/sponsor-30363D?style=for-the-badge\u0026logo=GitHub-Sponsors\u0026logoColor=#EA4AAA)](https://github.com/sponsors/insality) [![Ko-Fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge\u0026logo=ko-fi\u0026logoColor=white)](https://ko-fi.com/insality) [![BuyMeACoffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge\u0026logo=buy-me-a-coffee\u0026logoColor=black)](https://www.buymeacoffee.com/insality)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsality%2Fdefold-proto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finsality%2Fdefold-proto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsality%2Fdefold-proto/lists"}