Static assets for the XS programming language.
<script src="https://static.xslang.org/xs.js"></script>
<script>
(async () => {
const xs = await loadXS()
const output = await xs.run(`println("hello world")`)
console.log(output)
})()
</script>
The default highlighter is a small regex tokeniser. For AST-aware
highlighting (and the groundwork for editor tooling) call
xsHighlight.useTreeSitter(), which loads the 350 KB XS
grammar plus the 200 KB tree-sitter runtime on demand:
<script src="https://static.xslang.org/xs-highlight.js"></script>
<script>
await xsHighlight.useTreeSitter({ baseUrl: "https://static.xslang.org" })
const html = xsHighlight.highlight(xsCode)
</script>
Raw sockets aren't available under wasi, so net.http_get
returns null in the browser. Use xs.fetch(url, path) to
pipe a remote body into the VFS and then read it back from XS:
const xs = await loadXS()
await xs.fetch("https://api.github.com/zen", "zen.txt")
await xs.run(`import fs; println(fs.read("zen.txt"))`)
// or batch:
await xs.fetchAll({
"data.json": "https://example.com/data.json",
"schema.toml": "https://example.com/schema.toml",
})