{"id":13805987,"url":"https://github.com/ttytm/webview","last_synced_at":"2025-04-09T18:19:18.237Z","repository":{"id":185619880,"uuid":"673831309","full_name":"ttytm/webview","owner":"ttytm","description":"V binding for webview - a tiny cross-platform library to build modern cross-platform GUI applications.","archived":false,"fork":false,"pushed_at":"2024-12-02T16:33:30.000Z","size":250,"stargazers_count":71,"open_issues_count":4,"forks_count":2,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-09T18:19:12.523Z","etag":null,"topics":["bindings","gtk","gui","gui-application","library","linux","macos","v","webkit","webkit2gtk","webview","webview2","windows"],"latest_commit_sha":null,"homepage":"https://ttytm.github.io/webview/","language":"V","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/ttytm.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":"2023-08-02T14:18:45.000Z","updated_at":"2025-03-27T09:22:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"cd8a08ed-f389-42a0-a4cc-52b6007ddc68","html_url":"https://github.com/ttytm/webview","commit_stats":null,"previous_names":["ttytm/webview"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fwebview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fwebview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fwebview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fwebview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttytm","download_url":"https://codeload.github.com/ttytm/webview/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085325,"owners_count":21045139,"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":["bindings","gtk","gui","gui-application","library","linux","macos","v","webkit","webkit2gtk","webview","webview2","windows"],"created_at":"2024-08-04T01:01:06.925Z","updated_at":"2025-04-09T18:19:18.220Z","avatar_url":"https://github.com/ttytm.png","language":"V","readme":"# webview - V Binding\n\n[![build-status](https://img.shields.io/github/actions/workflow/status/ttytm/webview/ci.yml?branch=main\u0026style=flat-rounded)](https://github.com/ttytm/webview/actions/workflows/ci.yml?query=branch%3Amain)\n[![last-commit](https://img.shields.io/github/last-commit/ttytm/webview?style=flat-rounded)](https://github.com/ttytm/webview)\n\nThis repository provides a V binding for [webview](https://github.com/webview/webview) - a tiny cross-platform library\nto build modern cross-platform GUI applications. It allows to combine V as a fast, compiled general\npurpose programming language with modern web technologies to design a graphical user interface.\n\n## Installation\n\n**Build Tools and WebKit**\n\n- Linux - Example for debian based destributions\n\n  ```sh\n  # Build tools, such as a C compiler\n  sudo apt install build-essential\n  # WebKit\n  sudo apt install libgtk-3-dev libwebkit2gtk-4.0-dev\n  ```\n\n- macOS\n\n  ```sh\n  xcode-select --install\n  ```\n\n- Windows\n\n  E.g., https://www.msys2.org/ provides instructions to install MinGW\n\n**V**\n\n- [Installing V from source](https://github.com/vlang/v#installing-v-from-source)\n\n**Webview Module**\n\n- Install the module\n\n  ```sh\n  v install ttytm.webview\n  ```\n\n- After the installation, build the webview C library to which the webview V module will bind.\\\n\n  ```sh\n  # Linux/macOS\n  v ~/.vmodules/ttytm/webview/build.vsh\n  # PowerShell\n  v $HOME/.vmodules/ttytm/webview/build.vsh\n  ```\n\n## Usage Example\n\n\u003e [!TIP]\n\u003e When running and building on Windows, it is recommended to use `gcc` for compilation. E.g.:\n\u003e\n\u003e ```sh\n\u003e v -cc gcc run .\n\u003e ```\n\n\u003cbr\u003e\n\n```v ignore\nimport ttytm.webview\n\nconst html = '\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003cstyle\u003e\n      body {\n        background: linear-gradient(to right, #274060, #1B2845);\n        color: GhostWhite;\n        font-family: sans-serif;\n        text-align: center;\n      }\n    \u003c/style\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003eYour App Content!\u003c/h1\u003e\n    \u003cbutton onclick=\"callV()\"\u003eCall V!\u003c/button\u003e\n  \u003c/body\u003e\n  \u003cscript\u003e\n    async function callV() {\n      // Call a V function that takes an argument and returns a value.\n      const res = await window.my_v_func(\\'Hello from JS!\\');\n      console.log(res);\n    }\n  \u003c/script\u003e\n\u003c/html\u003e'\n\nfn my_v_func(e \u0026webview.Event) string {\n\tprintln('Hello from V from V!')\n\te.eval(\"console.log('Hello from V from JS!');\")\n\tstr_arg := e.get_arg[string](0) or { '' } // Get string arg at index `0`\n\treturn str_arg + ' Hello back from V!'\n}\n\nw := webview.create(debug: true)\nw.bind('my_v_func', my_v_func)\nw.set_size(600, 400, .@none)\nw.set_html(html)\nw.run()\n```\n\nOutput when pressing \u003ckbd\u003eCall V!\u003c/kdb\u003e\n\n```\nHello from V from V!\nCONSOLE LOG Hello from V from JS!\nCONSOLE LOG Hello from JS! Hello back from V!\n```\n\n---\n\n### Additional Examples\n\nExamples that can be found in the [`examples/`](https://github.com/ttytm/webview/tree/master/examples) directory of the repository.\n\n1. [v-js-interop-simple](https://github.com/ttytm/webview/tree/main/examples/v-js-interop-simple) - simple example with a similar complexity as the readme example above.\n2. [v-js-interop-app](https://github.com/ttytm/webview/tree/main/examples/v-js-interop-app) - shows the basic code architecture of an application.\n3. [project-structure](https://github.com/ttytm/webview/tree/main/examples/project-structure) - organizes `2. v-js-interop-app` into a directory structure that can be used as orientation for more complex projects.\n4. [astro-project](https://github.com/ttytm/webview/tree/main/examples/astro-project) - uses a modern web framework for the UI.\n\nExternal Examples\n\n1. [LVbag](https://github.com/ttytm/LVbag/blob/main/examples/gui_project) - minimal example that automates embedding of the UI into the executable.\n2. [emoji-mart-desktop](https://github.com/ttytm/emoji-mart-desktop) - application that combines above concepts. It uses SvelteKit for the UI and embeds it inside a single executable.\n\n## Documentation\n\nAn overview of exported functions is accessible in the repositories [`src/lib.v`](https://github.com/ttytm/webview/blob/master/src/lib.v)\nfile and on its [vdoc site](https://ttytm.github.io/webview/webview.html).\n\n### Debugging\n\n\u003e [!NOTE]\n\u003e The debug feature currently works on Linux and Windows.\n\nUse the `webview_debug` flag to enable developer tools - this enables the Web Inspector (allowing\nfor e.g., _right click_ \u003ckbd\u003eInspect Element\u003c/kbd\u003e) and `console.log` prints to the terminal. E.g.:\n\n```sh\nv -d webview_debug run .\n```\n\nAlternatively, control the debug mode explicitly for a window by using the optional debug argument.\n\n```v ignore\nwebview.create() // enabled when the application was build with `-d webview_debug`\nwebview.create(debug: true) // explicitly enabled for the window\nwebview.create(debug: false) // explicitly disabled for the window, even when built with `-d webview_debug`\n```\n\n## Disclaimer\n\nUntil a stable version 1.0 is available, new features will be introduced, existing ones may change,\nor breaking changes may occur in minor(`0.\u003cminor\u003e.*`) versions.\n\n## Complementary Projects\n\n- [Dialog](https://github.com/ttytm/dialog) - Cross-platform utility library to open system dialogs - files, message boxes etc.\n- [LVbag](https://github.com/ttytm/LVbag) - Generate embedded file lists for directories.\n\n## License\n\nOpen source software under the MIT license.\n","funding_links":[],"categories":["Libraries"],"sub_categories":["User Interface toolkits"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttytm%2Fwebview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttytm%2Fwebview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttytm%2Fwebview/lists"}