{"id":25695470,"url":"https://github.com/birnadinerick/cauri","last_synced_at":"2026-05-02T20:32:26.135Z","repository":{"id":278970916,"uuid":"937090564","full_name":"BirnadinErick/cauri","owner":"BirnadinErick","description":"tauri-like c/cxx framework (educational purpose)","archived":false,"fork":false,"pushed_at":"2025-02-22T22:12:27.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-22T22:21:34.328Z","etag":null,"topics":["c","cpp","javascript","native","webapp"],"latest_commit_sha":null,"homepage":"https://www.methebe.com/","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/BirnadinErick.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":"2025-02-22T10:07:03.000Z","updated_at":"2025-02-22T22:12:31.000Z","dependencies_parsed_at":"2025-02-22T22:31:43.861Z","dependency_job_id":null,"html_url":"https://github.com/BirnadinErick/cauri","commit_stats":null,"previous_names":["birnadinerick/cauri"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirnadinErick%2Fcauri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirnadinErick%2Fcauri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirnadinErick%2Fcauri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirnadinErick%2Fcauri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BirnadinErick","download_url":"https://codeload.github.com/BirnadinErick/cauri/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240582048,"owners_count":19824146,"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":["c","cpp","javascript","native","webapp"],"created_at":"2025-02-25T00:51:53.411Z","updated_at":"2026-05-02T20:32:16.122Z","avatar_url":"https://github.com/BirnadinErick.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CAURI: documentation\n\n**CAURI** is a Tauri-inspired but using C language. Why? Because.\n\nthis is just a tracking of what I learned about the workings of cauri.\nthis is to serve as a future reference. the documentation is not necessarily\ntechnical and accurate. the descriptions explain what I perceive.\n\n## TODO\n\n- [x] window creation\n- [x] load a view\n- [x] communicate with backend\n- [ ] navigate to another view\n- [ ] navigate back\n- [ ] create view workflow\n- [ ] preserve view state during navigation\n- [ ] how-to bootstrap a new project\n- [ ] other-platform setup \n\n---\n\n## Skeleton\n\n```c\nint main(void) {\n    const webview_t window = webview_create((int)DEBUG, NULL);\n\n    webview_set_title(window, \"cauri-test\");\n    webview_set_size(window, 640, 480, WEBVIEW_HINT_NONE);\n\n    webview_set_html(window, home);\n    webview_run(window);\n\n    webview_destroy(window);\n    exit(EXIT_SUCCESS);\n}\n```\n\n#### window handle creation\n\n`webview_create` creates a webview window. takes 2 arguments. \n\n1. DEBUG: whether to allow debugging capabilities in the frontend\n2. NULL: a window handle to embed the view.\n\n\u003e DEBUG: only works if the underlying view engine (e.g. GTK, WebView2 etc.) \n\u003e supports *Inspect Element* functionality\n\n#### decorating the window\n\nfollowing functions decorates the native window:\n\n- webview_set_title: sets the title of the native window bar\n- webview_set_size: sets the initial window size, user can resize the window\n\n#### window content\n\n`webview_set_html` sets the content inside to the *window*\n\n#### initialize \u0026 bookkeeping\n\n`webview_run` \u0026 `webview_destroy` are bookkeeping functions. there is nothing\nmore to say here.\n\n---\n\n## Communicating with backend\n\nthough webview allows 2-way communication, for now I am only focusing\non 1-way (i.e. Frontend -\u003e Backend).\n\napart from skeleton, we need 3 things:\n\n1. callback: a function to call; this will do the intended work\n2. bind: let frontend know this callback exists\n3. callback_arg: an argument struct that we need to give to the callback\n\n### callback_arg\n\nat least, we need to pass in the current webview window handle.\n\n```c\ntypedef struct {\n    webview_t window;\n    // other stuff we need\n} context_t;\n```\n\n### bind\n\nwe use the `webview_bind` method which takes 4 arguments in order:\n\n1. w: the window handle\n2. name: a name of the command to expose to the frontend\n3. callback: the callback (as a function pointer)\n4. arg: reference to the argument of the callback\n\n```c\n// context for binding\nstatic long _count = 0;\ncontext_t context = {.w = window, .count = _count};\n\n// bind methods\nwebview_bind(window, \"incr\", increment, \u0026context);\n```\n\n\u003e the `name` will be what we would call in the frontend. (e.g. `window.incr()`).\n\u003e the bound method will be available in global *window* object in javascript\n\n### callback\n\na function that we want to be called from the frontend. a *callback* takes 3\narguments:\n\n1. id: an id of the request (to differentiate from multiple requests)\n2. req: a JSON string that was passed from the frontend\n3. arg: arg we passed during the binding (here, `context_t context`)\n\n```c \nvoid increment(const char* id, const char* req, void* arg)\n{\n    context_t* context = (context_t*)arg;\n    \n    context-\u003ecount += 1;\n    char result[4] = {0};\n    (void)sprintf(result, \"%ld\", context-\u003ecount);\n    \n    webview_return(context-\u003ew, id, 0, result);\n}\n```\n\nto let the frontend know of the result, we use `webview_return` as\n`webview_return(context-\u003ew, id, 0, result)` (documentation WIP).\n\n\u003e[info] the *callback* can be also multithreaded. (documentation WIP);\n\n\n## License: MIT License\n\nCopyright (c) 2025 Birnadin Erick\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n ---\n\n## Tschau\n\nI hope this helps you in any way. if you have a comment, open an issue\nand let me know, no matter how harsh it is.\n\nMade in Deggendorf with 🥨 and 🍺;\n\nTill then, it is methebe, signing off.\nTschau!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirnadinerick%2Fcauri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbirnadinerick%2Fcauri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirnadinerick%2Fcauri/lists"}