GithubHelp home page GithubHelp logo

peter-gy / clingo-wasm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from domoritz/clingo-wasm

0.0 0.0 0.0 8.01 MB

Clingo on the web

Home Page: https://domoritz.github.io/clingo-wasm

License: Apache License 2.0

Shell 18.81% JavaScript 15.31% TypeScript 60.30% HTML 5.59%

clingo-wasm's Introduction

Clingo WebAssembly

npm version CDN Clingo version Lua version Emscripten version Build WASM

Clingo compiled to WebAssembly with Emscripten. Try it online at https://observablehq.com/@cmudig/clingo or https://domoritz.github.io/clingo-wasm.

The API is not finalized and may change.

This repo combines work from two previous repos: https://github.com/Aluriak/webclingo-example and https://github.com/domoritz/wasm-clingo.

Installation and Usage

Node

npm install clingo-wasm or yarn add clingo-wasm.

const clingo = require("clingo-wasm");

clingo.run("a. b:- a.").then(console.log);

In the Browser

Load Clingo from the JSDelivr CDN.

<script src="https://cdn.jsdelivr.net/npm/clingo-wasm@VERSION"></script>

We expose an UMD bundle that runs Clingo in a separate worker thread. Therefore, all commands need to be asynchronous.

<script>
  async function main() {
    // optionally pass URL to WASM file:
    // await clingo.init("https://cdn.jsdelivr.net/npm/clingo-wasm@VERSION/dist/clingo.wasm")
    console.log(await clingo.run("a. b :- a."));
    console.log(await clingo.run("{a; b; c}.", 0));
  }

  main();
</script>

Developers

Build WASM file

Run yarn build:wasm if you have Docker. For testing purposes, you can run scripts/build_clingo.sh from the root directory of the project.

Build and Test JavaScript

Run yarn build to build the js files. Run yarn test to run tests in node.

Update Lua, Clingo, or Emscripten

Update the versions in scripts/versions.sh and in the badges in this README.md. Then push to a new branch and let GitHub actions build the new WASM file.

clingo-wasm's People

Contributors

d4hines avatar dependabot-preview[bot] avatar dependabot[bot] avatar domoritz avatar peter-gy avatar

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.