0.1.1 • Published 1 year ago

clingo-wasm v0.1.1

Weekly downloads
5
License
Apache-2.0
Repository
github
Last release
1 year ago

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.

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.

0.1.0

1 year ago

0.1.1

1 year ago

0.0.14

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

5 years ago