sandscript.run

SandScript

SandScript is JavaScript with one addition and many restrictions. The language trades flexibility for predictability. It serves programs that need these properties:

The one addition: the grant block

The grant block is the only construct that JavaScript does not have. It asks the host for a capability. Its optional denied arm receives control when the host refuses:

grant "dom" {
  document.body.append(line);
} denied {
  // The host refused. Recover here.
}

SandScript reserves the words grant and denied. JavaScript does not reserve them. A JavaScript program that uses either word as a name is therefore not a SandScript program.

Everything else is a restriction

Outside the grant block, SandScript only removes from JavaScript. It adds no operator, no expression form, and no implicit conversion. A program that contains no grant block is a valid JavaScript program with identical semantics.

File extension and media type

A SandScript source file uses the .drone extension. Its media type is text/sandscript. The type is a programme convention, not an IANA registration. Do not serve SandScript source as text/javascript: a consumer that receives text/javascript can execute the file in a full JavaScript runtime, outside the sandbox and the grant system.

This documentation

The SandScript repository owns the authoritative reference. This site restates it for readers of the runner.