All Projects → life4 → Gweb

life4 / Gweb

Licence: mit
Interact with browser from Go. Manually-crafted WebAPI interoperation library.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects
js
455 projects

Projects that are alternatives of or similar to Gweb

Rs Asteroids
A variation on the game Asteroids, written in Rust
Stars: ✭ 146 (-10.43%)
Mutual labels:  wasm
Kvm Vmi
KVM-based Virtual Machine Introspection
Stars: ✭ 153 (-6.13%)
Mutual labels:  syscalls
Console error panic hook
A panic hook for wasm32-unknown-unknown that logs panics with console.error
Stars: ✭ 159 (-2.45%)
Mutual labels:  wasm
Libarchivejs
Archive library for browsers
Stars: ✭ 145 (-11.04%)
Mutual labels:  wasm
Wasmer Java
☕ WebAssembly runtime for Java
Stars: ✭ 152 (-6.75%)
Mutual labels:  wasm
Blazor Samples
Explore and learn Syncfusion Blazor components using large collection of demos, example applications and tutorial samples
Stars: ✭ 156 (-4.29%)
Mutual labels:  wasm
Tardis
Trace And Rewrite Delays In Syscalls: Hooking time-related Linux syscalls to warp a process's perspective of time, using ptrace.
Stars: ✭ 144 (-11.66%)
Mutual labels:  syscalls
Squark
Rust frontend framework, for web browser and more.
Stars: ✭ 162 (-0.61%)
Mutual labels:  wasm
Seed
A Rust framework for creating web apps
Stars: ✭ 3,069 (+1782.82%)
Mutual labels:  wasm
Brainfuck
Collection of BF interpreters/translators in C/C++/ASM/JS/Python/Rust + others
Stars: ✭ 157 (-3.68%)
Mutual labels:  wasm
Greact
like preact, but for go with wasm
Stars: ✭ 149 (-8.59%)
Mutual labels:  wasm
Deno Sqlite
Deno SQLite module
Stars: ✭ 151 (-7.36%)
Mutual labels:  wasm
Uno.quickstart
An Uno "Hello world!" project using Windows UWP, iOS, Android and WebAssembly
Stars: ✭ 157 (-3.68%)
Mutual labels:  wasm
Wasm Crypto
A WebAssembly (via AssemblyScript) set of cryptographic primitives for building authentication and key exchange protocols.
Stars: ✭ 146 (-10.43%)
Mutual labels:  wasm
Event Sourcing Jambo
An Hexagonal Architecture with DDD + Aggregates + Event Sourcing using .NET Core, Kafka e MongoDB (Blog Engine)
Stars: ✭ 159 (-2.45%)
Mutual labels:  webapi
Assemblyscript
A TypeScript-like language for WebAssembly.
Stars: ✭ 13,152 (+7968.71%)
Mutual labels:  wasm
Corporate Bs Generator Api
Corporate Bullshit(BuzzWord) Generator API
Stars: ✭ 155 (-4.91%)
Mutual labels:  webapi
Wasm Pdf
Generate PDF files with JavaScript and WASM (WebAssembly)
Stars: ✭ 163 (+0%)
Mutual labels:  wasm
Wain
WebAssembly implementation from scratch in Safe Rust with zero dependencies
Stars: ✭ 160 (-1.84%)
Mutual labels:  wasm
Emberclear
Encrypted Chat. No History. No Logs.
Stars: ✭ 157 (-3.68%)
Mutual labels:  wasm

GWeb: golang + js + wasm

gweb -- strictly typed WebAPI library on top of syscall/js. Like flow or TypeScript but for Go. You need it if you want to interact with browser from wasm-compiled Go program.

See examples on gweb.orsinium.dev.

Features

  • 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).
  • 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.
  • 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.
  • 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.
  • Almost the same API as in JS. If you have experience with vanilla JS, you have almost learnt everything about the libray.
  • 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.
  • Documented. Every method is documented to save your time and reduce googling.

Installation

GOOS=js GOARCH=wasm go get github.com/life4/gweb

If you're using VSCode, it's recommend to create a .vscode/settings.json file in your project with the following content:

{
    "go.toolsEnvVars": {
        "GOARCH": "wasm",
        "GOOS": "js",
    },
    "go.testEnvVars": {
        "GOARCH": "wasm",
        "GOOS": "js",
    },
}

Error handling

In the beautiful JS world anything at any time can be null or undefined. Check it when you're not sure:

doc := web.GetWindow().Document()
el := doc.Element("some-element-id")
if el.Type() == js.TypeNull {
    // handle error
}

Missed API

If something is missed, use syscall/js-like methods (Get, Set, Call etc):

doc := web.GetWindow().Document()
el := doc.Element("some-element-id")
name = el.Get("name").String()

Packages

GWeb is a collection of a few packages:

  • web (docs) -- window, manipulations with DOM.
  • audio (docs) -- Web Audio API. Use web.GetWindow().AudioContext() as an entry point.
  • canvas (docs) -- canvas-related objects. Use web.GetWindow().Document().CreateCanvas() to get started.
  • css (docs) -- manage styles for HTML elements.

Contributing

Contributions are welcome! GWeb is a Open-Source project and you can help to make it better. Some ideas what can be improved:

  • Every function and object should have short description based on MDN Web API docs. Some descriptions are missed.
  • Also, every function that calls a Web API method should have a link in docs for that method.
  • Typos are very possible, don't be shy to fix it if you've spotted one.
  • More objects and methods? Of course! Our goal is to cover everything in WebAPI! Well, excluding deprecated things. See Features section to get feeling what should be there.
  • Found a bug? Fix it!

And 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 ❤️

Similar projects

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].