Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sidepelican/WasmCallableKit
https://github.com/sidepelican/WasmCallableKit
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sidepelican/WasmCallableKit
- Owner: sidepelican
- License: mit
- Created: 2022-04-15T10:27:19.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-26T11:40:54.000Z (8 months ago)
- Last Synced: 2024-03-26T12:54:39.789Z (8 months ago)
- Language: Swift
- Size: 74.2 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WasmCallableKit
Use Swift library in TypeScript through WebAssembly!
## Example
A Swift class
```swift
public enum FenceOrientation: String, Codable {
case horizontal
case vertical
}public struct FencePoint: Codable {
public var x: Int
public var y: Int
public var orientation: FenceOrientation
}public struct Board: Codable {
...
public var fences: [FencePoint]
}public class QuoridorGame {
private var state: ...
public init() {}public func putFence(position: FencePoint) throws { ... }
public func currentBoard() -> Board { ... }
}
```Can be used in TypeScript using WasmCallableKit.
```ts
const game = new QuoridorGame();
game.putFence({
x: 1, y: 4, orientation: "horizontal"
});
const board = game.currentBoard();
board.fences.map(...);
```## Setup
It is recommended to undestand SwiftWasm book deeply.
https://book.swiftwasm.org🚧 WIP 🚧
You can see [example](https://github.com/sidepelican/WasmCallableKit/tree/main/example) project to understand basic usage.