This page explains all the capabilities of the scripting engine and the runtime that powers it in order to give game authors a clue about what they can and can’t do when it comes to script execution.
Scripting language
Heyplay uses TypeScript as a programming language to let game authors build their games. TypeScript is a superset of JavaScript which means that games may be written in modern TypeScript (with types) or JavaScript (without types).
Game scripts may also import TypeScript or JavaScript libraries, as long as they are proper ES modules and they only use supported Web Standards APIs (more below). CDNs like esm.sh or deno.land/x may be used to pull in NPM libraries in ES module format.
Internally, Heyplay uses SWC (a Rust-based alternative to Babel, just 20x-70x faster) to transpile TypeScript to JavaScript. It supports all ECMAScript features, including all stage 3 proposals.
Runtime
Heyplay uses a recent version of the V8 engine as the JavaScript runtime. Currently it’s version 11.5.150.2.
This means that, aside from the TypeScript transpilation, all the modern ES standards supported by recent Chrome and NodeJS versions are natively supported by Heyplay too, including const
/let
, classes, arrow functions, destructuring assignments, template literals and multi-line strings.
Web Standards
In additoon the following selection of modern Web Standards is supported to allow more complex cases and libraries:
- text encoding:
TextDecoder
,TextEncoder
,atob
,btoa
Many other APIs like setTimeout
or console.log
are not supported either for security or performance reasons.
Heyplay is always evolving to find a perfect balance between flexibility and performace so if there’s anything that blocks you, please don’t hesitate to contact and request it.