{"id":13694027,"url":"https://github.com/life4/gweb","last_synced_at":"2025-05-03T01:30:50.305Z","repository":{"id":42190042,"uuid":"238043454","full_name":"life4/gweb","owner":"life4","description":"🌐 Interact with browser from Go. Manually crafted WebAPI interoperation library.","archived":false,"fork":false,"pushed_at":"2024-02-28T08:02:24.000Z","size":6443,"stargazers_count":205,"open_issues_count":0,"forks_count":16,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-08-03T17:18:19.694Z","etag":null,"topics":["frontend","go","golang","jquery","js","react","syscalls","vue","wasm","web","web-assembly","webapi"],"latest_commit_sha":null,"homepage":"https://gweb.orsinium.dev/","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/life4.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":"2020-02-03T19:24:21.000Z","updated_at":"2024-07-28T15:40:24.000Z","dependencies_parsed_at":"2022-08-12T09:00:27.874Z","dependency_job_id":"8b419dc9-1989-47fa-881b-aa9d1e07be24","html_url":"https://github.com/life4/gweb","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/life4%2Fgweb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/life4%2Fgweb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/life4%2Fgweb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/life4%2Fgweb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/life4","download_url":"https://codeload.github.com/life4/gweb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224346182,"owners_count":17296164,"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":["frontend","go","golang","jquery","js","react","syscalls","vue","wasm","web","web-assembly","webapi"],"created_at":"2024-08-02T17:01:22.776Z","updated_at":"2024-11-12T20:31:02.022Z","avatar_url":"https://github.com/life4.png","language":"Go","readme":"# GWeb: golang + js + wasm\n\n**gweb** -- strictly typed [WebAPI](https://en.wikipedia.org/wiki/Web_API) library on top of [syscall/js](https://golang.org/pkg/syscall/js/). Like [flow](https://github.com/facebook/flow) or [TypeScript](https://www.typescriptlang.org/) but for Go. You need it if you want to interact with browser from [wasm-compiled](https://github.com/golang/go/wiki/WebAssembly) Go program.\n\n+ Examples: [gweb.orsinium.dev](https://gweb.orsinium.dev/)\n+ Mapping of JS Web API to GWeb functions: [refs.md](./refs.md)\n\n## Features\n\n+ **Strictly typed**. It's a wrapper around `syscall/js` that helps you to avoid runtime errors (you'll get them a lot with raw `syscall/js`).\n+ **Backward compatible**. Almost every type is a wrapper around `js.Value`. So if something missed, you can always fall back to the classic `syscall/js` calls.\n+ **Hand crafted**. It's hard to make a usable autogeneration of WebAPI since Go is a strictly typed language without union types. So we carefully translated everything while applying Go best practices.\n+ **Cleaned up**. The library provides only useful methods and attributes from WebAPI. No obsolete and deprecated methods, no experimental APIs that are only supported by a few engines. Only what we really need right now.\n+ **Almost the same API as in JS**. If you have experience with [vanilla JS](https://stackoverflow.com/a/20435744), you have almost learnt everything about the libray.\n+ **But better**. WebAPI has a long history of incremental changes and spaces for unimplemented dreams. However, we can see the full picture to provide a better experience and more namespaces.\n+ **Documented**. Every method is documented to save your time and reduce googling.\n\n## Installation\n\n```bash\nGOOS=js GOARCH=wasm go get github.com/life4/gweb\n```\n\nIf you're using VSCode, it's recommend to create a `.vscode/settings.json` file in your project with the following content:\n\n```json\n{\n    \"go.toolsEnvVars\": {\n        \"GOARCH\": \"wasm\",\n        \"GOOS\": \"js\",\n    },\n    \"go.testEnvVars\": {\n        \"GOARCH\": \"wasm\",\n        \"GOOS\": \"js\",\n    },\n}\n```\n\n## Error handling\n\nIn the beautiful JS world anything at any time can be `null` or `undefined`. Check it when you're not sure:\n\n```go\ndoc := web.GetWindow().Document()\nel := doc.Element(\"some-element-id\")\nif el.Type() == js.TypeNull {\n    // handle error\n}\n```\n\n## Missed API\n\nIf something is missed, use `syscall/js`-like methods (`Get`, `Set`, `Call` etc):\n\n```go\ndoc := web.GetWindow().Document()\nel := doc.Element(\"some-element-id\")\nname = el.Get(\"name\").String()\n```\n\n## Packages\n\nGWeb is a collection of a few packages:\n\n+ `web` ([docs](https://pkg.go.dev/github.com/life4/gweb/web?tab=doc)) -- window, manipulations with DOM.\n+ `audio` ([docs](https://pkg.go.dev/github.com/life4/gweb/audio?tab=doc)) -- [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API). Use `web.GetWindow().AudioContext()` as an entry point.\n+ `canvas` ([docs](https://pkg.go.dev/github.com/life4/gweb/canvas?tab=doc)) -- canvas-related objects. Use `web.GetWindow().Document().CreateCanvas()` to get started.\n+ `css` ([docs](https://pkg.go.dev/github.com/life4/gweb/css?tab=doc)) -- manage styles for HTML elements.\n\n## Contributing\n\nContributions are welcome! GWeb is a Open-Source project and you can help to make it better. Some ideas what can be improved:\n\n+ Every function and object should have short description based on [MDN Web API docs](https://developer.mozilla.org/en-US/docs/Web/API). Some descriptions are missed.\n+ Also, every function that calls a Web API method should have a link in docs for that method.\n+ Typos are very possible, don't be shy to fix it if you've spotted one.\n+ More objects and methods? Of course! Our goal is to cover everything in WebAPI! Well, excluding deprecated things. See [Features](#features) section to get feeling what should be there.\n+ Found a bug? Fix it!\n\nAnd even if you don't have spare time for making PRs, you still can help by talking to your friends and subscribers about GWeb. Thank you :heart:\n\n## Similar projects\n\n+ [webapi](https://github.com/gowebapi/webapi/) -- bindings that autogenerated from [WebIDL](https://heycam.github.io/webidl/).\n+ [godom](https://github.com/siongui/godom) -- bindings on top of [gopherjs](github.com/gopherjs/gopherjs/).\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flife4%2Fgweb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flife4%2Fgweb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flife4%2Fgweb/lists"}