{"id":49380130,"url":"https://github.com/rarestype/jss","last_synced_at":"2026-04-28T05:00:58.809Z","repository":{"id":313579479,"uuid":"1051916107","full_name":"rarestype/jss","owner":"rarestype","description":"A lightweight, serialization-free bridge for passing data between Swift and JavaScript in WebAssembly applications","archived":false,"fork":false,"pushed_at":"2026-04-22T07:56:35.000Z","size":53,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-22T08:27:23.924Z","etag":null,"topics":["autosync","javascript-interop","swift"],"latest_commit_sha":null,"homepage":"https://swiftinit.org/docs/jss","language":"Swift","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/rarestype.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["tayloraswift"]}},"created_at":"2025-09-07T01:59:00.000Z","updated_at":"2026-04-22T07:32:16.000Z","dependencies_parsed_at":"2025-09-07T04:09:13.922Z","dependency_job_id":"aba4e681-3692-4096-aad3-872514304ad5","html_url":"https://github.com/rarestype/jss","commit_stats":null,"previous_names":["tayloraswift/jss","rarestype/jss"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/rarestype/jss","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rarestype%2Fjss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rarestype%2Fjss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rarestype%2Fjss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rarestype%2Fjss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rarestype","download_url":"https://codeload.github.com/rarestype/jss/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rarestype%2Fjss/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32367021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"online","status_checked_at":"2026-04-28T02:00:07.250Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["autosync","javascript-interop","swift"],"created_at":"2026-04-28T05:00:33.297Z","updated_at":"2026-04-28T05:00:58.779Z","avatar_url":"https://github.com/rarestype.png","language":"Swift","funding_links":["https://github.com/sponsors/tayloraswift"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n🥖 \u0026nbsp; **jss** \u0026nbsp; 🥖\n\nA lightweight, serialization-free bridge for passing data between Swift and JavaScript in WebAssembly applications.\n\n[documentation](https://swiftinit.org/docs/jss) ·\n[license](LICENSE)\n\n\u003c/div\u003e\n\n\n## Requirements\n\nThe jss library requires Swift 6.2 or later.\n\n\u003c!-- DO NOT EDIT BELOW! AUTOSYNC CONTENT [STATUS TABLE] --\u003e\n| Platform | Status |\n| -------- | ------ |\n| 💬 Documentation | [![Status](https://raw.githubusercontent.com/rarestype/jss/refs/badges/ci/Documentation/_all/status.svg)](https://github.com/rarestype/jss/actions/workflows/Documentation.yml) |\n| 🐧 Linux | [![Status](https://raw.githubusercontent.com/rarestype/jss/refs/badges/ci/Tests/Linux/status.svg)](https://github.com/rarestype/jss/actions/workflows/Tests.yml) |\n| 🍏 Darwin | [![Status](https://raw.githubusercontent.com/rarestype/jss/refs/badges/ci/Tests/macOS/status.svg)](https://github.com/rarestype/jss/actions/workflows/Tests.yml) |\n\u003c!-- DO NOT EDIT ABOVE! AUTOSYNC CONTENT [STATUS TABLE] --\u003e\n\n\n## Why this library?\n\nWhen you compile Swift to WebAssembly, you’re essentially running Swift code in a sandboxed environment within the browser.\nThis environment doesn’t have direct access to the browser's DOM (Document Object Model) or other JavaScript APIs.\nTo interact with the web page, you need a way to pass data and call functions between Swift and JavaScript.\n\nA common approach is to serialize data into a format like JSON, pass it as a string, and then deserialize it on the other side. However, this has some drawbacks:\n\n*Performance overhead*: Serialization and deserialization can be slow, especially for large or complex data structures.\n\n*Boilerplate code*: JSON is only a subset of JavaScript, which means you often need to write additional, parallel decoding and encoding logic to handle types (such as `BigInt`) that cannot be represented in JSON.\n\n*Loss of type safety*: You’re essentially passing strings back and forth, which means you lose the benefits of Swift’s strong type system at the boundary between the two languages.\n\n\n## Direct object access without serialization\n\nThe JavaScriptKit-based abstractions in this library solve these problems by providing a way to directly access and manipulate JavaScript objects from Swift, and vice versa, without ever serializing the data. This is achieved through a set of protocols and generic types that create a powerful and flexible binding layer.\n\nHere are the key components and how they work together:\n\n\n### `JavaScriptEncodable` and `JavaScriptDecodable`\n\nThese are the two main protocols that you'll conform your Swift types to.\n\n-   `JavaScriptEncodable` allows you to “encode” a Swift object into a JavaScript object.\n-   `JavaScriptDecodable` allows you to “decode” a JavaScript object into a Swift object.\n\n### `JavaScriptEncoder` and `JavaScriptDecoder`\n\nThese are the workhorses that do the actual encoding and decoding.\n\n-   `JavaScriptEncoder` takes a Swift object and, by using key-value pairs that you define in your Swift code, it populates a new JavaScript object. The keys are typically defined in an enum with `JSString` raw values, which provides a typesafe way to refer to the JavaScript object’s properties.\n\n-   `JavaScriptDecoder` does the reverse. It wraps a `JSObject` and allows you to access its properties using the same `JSString`-backed enum to decode the values into a new Swift object.\n\n### `LoadableFromJSValue` and `ConvertibleToJSValue`\n\nThese are lower-level protocols that provide the basic machinery for converting between Swift and JavaScript types. Many of the basic Swift types (like String, Int, Double, etc.) are already extended to conform to these protocols.\n\nThe `LoadableFromJSValue` and `ConvertibleToJSValue` are generally used with `RawRepresentable` types that have `RawValue` types that already conform to these protocols.\n\nIn situations where you want to use a type’s `LosslessStringConvertible` representation, use the `LoadableFromJSString` and `ConvertibleToJSString` protocols instead.\n\n\n## Example usage\n\nHere’s a quick example of how to make a Swift struct compatible with the JavaScript binding layer.\n\nFirst, define your Swift struct:\n\n```swift\nstruct Cell {\n    let id: HexCoordinate\n    let type: String\n    let tile: PlanetTile\n}\n```\n\nNext, create an enum that defines the keys for the JavaScript object’s properties. This enum should be backed by `JSString`:\n\n```swift\nextension Cell {\n    enum ObjectKey: JSString {\n        case id\n        case type\n        case tile\n    }\n}\n```\n\nNow, conform your Cell struct to `JavaScriptEncodable` and `JavaScriptDecodable`:\n\n```swift\nextension Cell: JavaScriptEncodable {\n    func encode(to js: inout JavaScriptEncoder\u003cObjectKey\u003e) {\n        js[.id] = self.id\n        js[.type] = self.type\n        js[.tile] = self.tile\n    }\n}\n\nextension Cell: JavaScriptDecodable {\n    init(from js: borrowing JavaScriptDecoder\u003cObjectKey\u003e) throws {\n        self.init(\n            id: try js[.id].decode(),\n            type: try js[.type].decode(),\n            tile: try js[.tile]?.decode() ?? .init(),\n        )\n    }\n}\n```\n\nWith these conformances, you can now seamlessly pass `Cell` instances between your Swift and JavaScript code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frarestype%2Fjss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frarestype%2Fjss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frarestype%2Fjss/lists"}