@aerys/lang
v1.55.12
Published
Aerys language runtime — run .aer scripts in the browser via WebAssembly
Maintainers
Readme
@aerys/lang
The Aerys language runtime for the browser and Node. Ship and execute
real .aer programs in any JavaScript environment via a single WebAssembly
module.
Use this package when you want to run Aerys scripts from inside a web app — interactive tutorials, in-browser playgrounds, user-scripting features, rule engines, sandboxed eval. The runtime is ~200 KB gzipped and has no runtime dependencies.
Writing React components in Aerys syntax is a different package — install
@aerys/aerysxfor that.@aerys/langruns scripts,@aerys/aerysxtransforms components at build time.
Install
npm install @aerys/langQuick start — raw eval
import { createAerys } from '@aerys/lang';
const aerys = await createAerys();
const result = aerys.eval(`
let x = 10
let y = 20
return x + y
`);
console.log(result); // 30React hook
import { useAerys } from '@aerys/lang/react';
function Playground() {
const { run, output, error } = useAerys();
return (
<>
<button onClick={() => run('print("hello from aerys")')}>
Run
</button>
<pre>{output}</pre>
{error && <pre style={{ color: 'red' }}>{error}</pre>}
</>
);
}<script type="aerys"> loader
<script type="module">
import '@aerys/lang/loader';
</script>
<script type="aerys">
print("hello from a script tag")
</script>The loader finds every <script type="aerys"> on the page and executes
its contents through the runtime.
Vite plugin (for serving .aer source files)
import { defineConfig } from 'vite';
import aerys from '@aerys/lang/vite-plugin';
export default defineConfig({
plugins: [aerys()],
});Then:
import helloSource from './hello.aer?raw';
const aerys = await createAerys();
aerys.eval(helloSource);Entry points
| Import | Purpose |
|---|---|
| @aerys/lang | Core runtime — createAerys(), eval, evalJSON |
| @aerys/lang/react | React hook — useAerys() |
| @aerys/lang/vite-plugin | Vite plugin for .aer?raw imports |
| @aerys/lang/loader | <script type="aerys"> tag auto-loader |
License
Proprietary — see LICENSE. Free for personal and commercial use, no attribution required. Source code is not distributed and may not be redistributed, modified, or republished. The names "Aerys" and "AerysX" are trademarks of the copyright holder.
