Coder Social home page Coder Social logo

swiftwasm / swiftwasm-pad Goto Github PK

View Code? Open in Web Editor NEW
56.0 5.0 1.0 109.58 MB

swiftwasm-pad is a online playground to help developers learn about Swift on Web.

Home Page: https://pad.swiftwasm.org

License: MIT License

Swift 54.81% JavaScript 11.55% HTML 0.57% CSS 4.33% Dockerfile 7.28% Shell 13.41% C 8.05%
swiftwasm tokamak javascriptkit playground

swiftwasm-pad's Introduction

swiftwasm-pad

Build and deploy

swiftwasm-pad is a online playground to help developers learn about Swift on Web.

https://swiftwasm-pad.netlify.app

Run

Using docker-compose

$ docker-compose up

Manual start up

# Build PreviewSystem
$ ./PreviewSystem/build-script.sh

# Start frontend
$ cd Frontend
$ npm install
$ npm run start

# Start backend
$ cd CompileAPI
$ export LOCAL_LAMBDA_SERVER_ENABLED=true
$ export LAMBDA_PREVIEW_STUB_PACKAGE=$(pwd)/../PreviewSystem/distribution/PreviewStub
$ export LAMBDA_SWIFTC=$(dirname $(pwd))/.toolchain/darwin/$(cat ../.swift-version)/usr/bin/swiftc
$ swift run CompileSwiftWasm

CompileAPI

CompileAPI is deployed with SwiftWasm toolchain built on Amazon Linux 2 and PreviewSystem. .swiftmodule files in PreviewSystem are used to compile user input code that can use Tokamak or JavaScriptKit. This API returns not an executable wasm binary but an object file. The object file will be linked with prebuilt library on browser.

Frontend

Frontend web application sends requests to CompilerAPI, link compiled object files and shared library and run linked executable wasm. library.so.wasm is the shared library combined with Swift Standard Library, Tokamak and JavaScriptKit. The library is built by ./PreviewSystem/build-script.sh This frontend application uses WebAssembly linker implemented by Swift named chibi-link to reduce CompileAPI's load and also reduce transfer data size. The linker is executed in Web Worker to avoid blocking UI.

Related Projects

swiftwasm-pad's People

Contributors

dependabot[bot] avatar kateinoigakukun avatar maxdesiatov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

astrotuna201

swiftwasm-pad's Issues

Counter Example Won't Run on Chrome

https://pad.swiftwasm.org/ isn't working on Chrome. If you click "Run" with the default example it throws a DOMException:

Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': ArrayBuffer is not detachable and could not be cloned.
at writeOutput (https://pad.swiftwasm.org/main.worker.js:1:188854)
at https://pad.swiftwasm.org/SwiftWasmPad.wasm:wasm-function[3372]:0xa25fe
at https://pad.swiftwasm.org/SwiftWasmPad.wasm:wasm-function[27]:0xf44a
at t.start (https://pad.swiftwasm.org/main.worker.js:1:47953)
at https://pad.swiftwasm.org/main.worker.js:1:189018

Make it available on a custom domain

I would like to make this available on pad.swiftwasm.org. Would we need to set this up on Netlify, or re-deploy to GitHub Pages? @kateinoigakukun please let me know what do you think would be the best way to approach this.

Pre-load the Counter example if the URL query is empty

Our users are highly likely to compile the Counter sample code anyway if the URL query doesn't contain any other code. We could pre-compile that Counter view and pre-load it and run it immediately. Then users would have access to running this basic example code as soon as possible.

Firefox support

Looks like this doesn't fully work on Firefox, I get these errors:

library.so.wasm was downloaded main.js:1:388339

main.js:1:388339
Info: Reading /tmp/main.o main.worker.js:1:187727

main.worker.js:1:187727
Warning: Custom section 'target_features' is currently not supported main.worker.js:1:187727

main.worker.js:1:187727
Info: Reading /tmp/library.so.wasm main.worker.js:1:187727

main.worker.js:1:187727
Warning: Linking subsection 'comdatInfo' is not supported now main.worker.js:1:187727

main.worker.js:1:187727
Warning: Custom section 'producers' is currently not supported main.worker.js:1:187727

main.worker.js:1:187727
TypeError: cannot transfer WebAssembly/asm.js ArrayBuffer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.