{"id":21121426,"url":"https://github.com/oneofone/wjsu","last_synced_at":"2026-04-12T16:02:21.222Z","repository":{"id":57506908,"uuid":"163634626","full_name":"OneOfOne/wjsu","owner":"OneOfOne","description":"syscall/js wasm helper","archived":false,"fork":false,"pushed_at":"2021-07-25T01:53:06.000Z","size":35,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T05:25:01.735Z","etag":null,"topics":["go","golang","wasm","webassembly"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OneOfOne.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}},"created_at":"2018-12-31T03:06:12.000Z","updated_at":"2022-04-24T07:42:31.000Z","dependencies_parsed_at":"2022-08-29T20:31:38.237Z","dependency_job_id":null,"html_url":"https://github.com/OneOfOne/wjsu","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OneOfOne%2Fwjsu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OneOfOne%2Fwjsu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OneOfOne%2Fwjsu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OneOfOne%2Fwjsu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OneOfOne","download_url":"https://codeload.github.com/OneOfOne/wjsu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243566393,"owners_count":20311872,"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":["go","golang","wasm","webassembly"],"created_at":"2024-11-20T03:50:16.954Z","updated_at":"2025-10-11T23:12:18.955Z","avatar_url":"https://github.com/OneOfOne.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wjsu [![GoDoc](https://godoc.org/github.com/OneOfOne/wjsu?status.svg)](https://godoc.org/github.com/OneOfOne/wjsu)\n\nwjsu (aka Webassembly Javascript Utils) is a helper package for [`syscall/js`](https://godoc.org/syscall/js).\n\nInpsired by [honnef.co/go/js/dom](https://github.com/dominikh/go-js-dom).\n\n## Install\n\n    GOOS=js GOARCH=wasm go get -u github.com/OneOfOne/wjsu\n\n* **note**: the package requires Go 1.12 for the `syscall/js` changes.\n\n## Features\n\n* Object.\n* Array (partial).\n* console (Log, Warn and Error).\n* wrapper for loading external scripts.\n* wrapper for js.ValueOf that doesn't panic and handles slices / maps.\n\n## Usage\n\nx\n\n### main.go\n\n```go\n//+build js,wasm\n\npackage main\n\nimport (\n\t\"time\"\n\n\t\"github.com/OneOfOne/wjsu\"\n)\n\nfunc main() {\n    if err := wjsu.Initialize(); err != nil {\n        panic(err)\n    }\n\twjsu.Console.Log(\"hello console\", []int{1, -1}, map[string]float64{\"a\": 1, \"z\": -1})\n\twjsu.Document.QuerySelector(\"div#loader\").SetInnerHTML(\"hello world\")\n\n\tapp := wjsu.Document.QuerySelector(\"app\")\n\tfor t := range time.Tick(time.Second) {\n\t\tapp.SetInnerHTML(\"time (UTC): \" + t.UTC().String())\n\t}\n}\n```\n\n### index.html\n\n```html\n\u003chtml\u003e\n\t\u003chead\u003e\n\t\t\u003ctitle\u003eWASM Loader\u003c/title\u003e\n\t\t\u003cmeta charset=\"utf-8\"\u003e\n\t\t\u003cscript\u003e\n\t\t\tconst goInit = () =\u003e {\n\t\t\t\tconst go = new Go();\n\t\t\t\tWebAssembly.instantiateStreaming(fetch(\"main.wasm\"), go.importObject).then((result) =\u003e {\n\t\t\t\t\tgo.run(result.instance);\n\t\t\t\t});\n\t\t\t}\n\t\t\u003c/script\u003e\n\t\t\u003cscript defer src=\"wasm_exec.js\" onload=\"goInit()\"\u003e\u003c/script\u003e\n\t\u003c/head\u003e\n\t\u003cbody\u003e\n\t\t\u003cdiv id=\"loader\"\u003eLoading...\u003c/div\u003e\n\t\t\u003capp /\u003e\n\t\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### serve.go\n\n```go\n//+build !js\n\npackage main\n\nimport (\n\t\"net/http\"\n\t\"os/exec\"\n\t\"time\"\n\t\"log\"\n)\n\nfunc main() {\n\ttime.AfterFunc(time.Second/2, func() {\n\t\texec.Command(\"xdg-open\", \"http://localhost:8080\").Start()\n\t})\n\tlog.Fatal(http.ListenAndServe(\":8080\", http.FileServer(http.Dir(\".\"))))\n}\n```\n\n### build \u0026 run\n\n```sh\ncp \"$(go env GOROOT)/misc/wasm/wasm_exec.js\" .\nGOOS=js GOARCH=wasm go build -o main.wasm\ngo run serve.go\n```\n\n#### Tinygo\n\n```sh\n$ pacman -S tinygo\n./tiny.sh path/to/project\n```\n\n## VSCode settings\n\n```json\n{\n\t\"go.toolsEnvVars\": {\n\t\t\"GOOS\": \"js\",\n\t\t\"GOARCH\": \"wasm\"\n\t}\n}\n```\n\n## TODO\n\n* Proper documentation.\n\n## License\n\nThis project is released under the Apache v2. licence. See [LICENCE](LICENCE) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foneofone%2Fwjsu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foneofone%2Fwjsu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foneofone%2Fwjsu/lists"}