{"id":20310834,"url":"https://github.com/progrium/goja-automerge","last_synced_at":"2025-04-11T16:02:08.244Z","repository":{"id":53397208,"uuid":"513967275","full_name":"progrium/goja-automerge","owner":"progrium","description":"Automerge.js in Go via goja","archived":false,"fork":false,"pushed_at":"2022-08-05T00:33:37.000Z","size":82,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T12:06:23.043Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/progrium.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":"2022-07-14T16:11:16.000Z","updated_at":"2022-11-07T20:24:07.000Z","dependencies_parsed_at":"2022-08-23T16:10:46.951Z","dependency_job_id":null,"html_url":"https://github.com/progrium/goja-automerge","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/progrium%2Fgoja-automerge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fgoja-automerge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fgoja-automerge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fgoja-automerge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/progrium","download_url":"https://codeload.github.com/progrium/goja-automerge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248438230,"owners_count":21103409,"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":[],"created_at":"2024-11-14T17:34:41.883Z","updated_at":"2025-04-11T16:02:08.215Z","avatar_url":"https://github.com/progrium.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goja-automerge\nAutomerge.js in Go via goja\n\nThis is mostly for prototyping (for what should be obvious reasons), but this package runs [automerge.js](https://github.com/automerge/automerge) in native Go (no CGO) via [goja](https://github.com/dop251/goja), wrapping the API so it feels more like a native Go library:\n\n```golang\ndoc1 := automerge.Init()\ndoc1 = automerge.Change(doc1, \"add cards\", func(doc *automerge.Object) {\n  doc.Set(\"cards\", doc.NewArray())\n  doc.Get(\"cards\").Call(\"push\", map[string]interface{}{\n    \"title\": \"Rewrite everything in Go\",\n    \"done\":  false,\n  })\n  doc.Get(\"cards\").Call(\"push\", map[string]interface{}{\n    \"title\": \"Rewrite everything in Zig\",\n    \"done\":  false,\n  })\n})\n\nb := automerge.Save(doc1)\ndoc2 := automerge.Load(b)\n\ndoc1 = automerge.Change(doc1, \"mark card as done\", func(doc *automerge.Object) {\n  doc.Get(\"cards\").Get(\"0\").Set(\"done\", true)\n})\ndoc2 = automerge.Change(doc2, \"delete card\", func(doc *automerge.Object) {\n  doc.Get(\"cards\").Delete(\"1\")\n})\n\nfinalDoc := automerge.Merge(doc1, doc2)\nd, _ := finalDoc.MarshalJSON()\nfmt.Println(string(d))\n// Output: {\"cards\":[{\"done\":true,\"title\":\"Rewrite everything in Go\"}]}\n```\n\nA more production usable version of this would probably use [automerge-rs](https://github.com/automerge/automerge-rs) via WASM (again, to avoid CGO), but somebody else can put that together. Please.\n\nThe `automerge.es5.js` file is embedded in the package to be run in goja. This file was produced by taking `automerge.min.js@1.0.1-preview.7`, adding a polyfill for TextEncoder/TextDecoder, and running through Babel to get an ES5 version that can run in current version of goja.\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrium%2Fgoja-automerge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogrium%2Fgoja-automerge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrium%2Fgoja-automerge/lists"}