Provides <script type="pluto"> and high-level APIs.
You simply need to load a suitable WASM build of libpluto, and then PlutoScript itself:
<script src="https://pluto-lang.org/wasm-builds/out/libpluto/0.12.0/libpluto.js"></script>
<script src="https://pluto-lang.org/PlutoScript/plutoscript.js"></script>
A simple example is the Base32 Encoder tool that is available online here.
Barring the script tags needed for PlutoScript’s usage, this is the entire source code:
<textarea id="plain"></textarea>
<textarea id="encoded"></textarea>
<script type="pluto">
document.getElementById("plain"):addEventListener("input", function()
document.getElementById("encoded").value = require"base32".encode(document.getElementById("plain").value)
end)
</script>
pluto_require(src)pluto_load(code)pluto_invoke(name, ...args) can be used to invoke a global Pluto functionpluto_give_file(name, data) writes a string or Uint8Array for Pluto code to read from the file with the given namejs_invoke(name, ...args) can be used to invoke a global JavaScript functionwindow.__index.__call: You can call any method on ‘window’, e.g. window.alert("Hello")document.getElementById(x) returns an Element instance with path $"#{x}"document.querySelector(x) returns an Element instance with path xElement.__index/Element.__newindex: You can read and write any property of an Element, e.g. .valueElement:addEventListener(evt, func)Element:addClass(name)Element:removeClass(name)Element:setAttribute(name, value)Element:removeAttribute(name)