GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - colemancda/JavaScriptKit: Swift framework to interact with JavaScript through WebAssembly.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

77 Commits
77 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
Example
Example
 
 
IntegrationTests
IntegrationTests
 
 
Runtime
Runtime
 
 
Sources
Sources
 
 
Tests
Tests
 
 
.gitignore
.gitignore
 
 
.swift-version
.swift-version
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
Package.swift
Package.swift
 
 
README.md
README.md
 
 

Repository files navigation

JavaScriptKit

Run unit tests

Swift framework to interact with JavaScript through WebAssembly.

Requirements

This library only supports swiftwasm/swift distribution toolchain. Please install Swift for WebAssembly toolchain from Release Page

The toolchains can be installed via swiftenv like official nightly toolchain.

e.g.

$ swiftenv install https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2020-05-10-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2020-05-10-a-osx.tar.gz
$ swift --version
Swift version 5.3-dev (LLVM 47c28180d7, Swift 5f96d487e0)
Target: x86_64-apple-darwin19.3.0

Usage

This JavaScript code

const alert = window.alert
const document = window.document

const divElement = document.createElement("div")
divElement.innerText = "Hello, world"
const body = document.body
body.appendChild(divElement)

const pet = {
  age: 3,
  owner: {
    name: "Mike",
  },
}

alert("JavaScript is running on browser!")

Can be written in Swift using JavaScriptKit

import JavaScriptKit

let alert = JSObjectRef.global.alert.function!
let document = JSObjectRef.global.document.object!

let divElement = document.createElement!("div").object!
divElement.innerText = "Hello, world"
let body = document.body.object!
_ = body.appendChild!(divElement)

struct Owner: Codable {
  let name: String
}

struct Pet: Codable {
  let age: Int
  let owner: Owner
}

let jsPet = JSObjectRef.global.pet
let swiftPet: Pet = JSValueDecoder().decode(from: jsPet)

alert("Swift is running on browser!")

Please see Example directory for more information

About

Swift framework to interact with JavaScript through WebAssembly.

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.