Xript.Runtime 0.4.1

dotnet add package Xript.Runtime --version 0.4.1
                    
NuGet\Install-Package Xript.Runtime -Version 0.4.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Xript.Runtime" Version="0.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Xript.Runtime" Version="0.4.1" />
                    
Directory.Packages.props
<PackageReference Include="Xript.Runtime" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Xript.Runtime --version 0.4.1
                    
#r "nuget: Xript.Runtime, 0.4.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Xript.Runtime@0.4.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Xript.Runtime&version=0.4.1
                    
Install as a Cake Addin
#tool nuget:?package=Xript.Runtime&version=0.4.1
                    
Install as a Cake Tool

Xript.Runtime

C# runtime for xript: sandboxed JavaScript execution via Jint, a pure C# JavaScript interpreter. No native dependencies.

NuGet

Install

dotnet add package Xript.Runtime

Usage

using System.Text.Json;
using Xript.Runtime;

var manifest = """
{
    "xript": "0.1",
    "name": "my-app",
    "bindings": {
        "greet": {
            "description": "Returns a greeting.",
            "params": [{ "name": "name", "type": "string" }],
            "returns": "string"
        }
    }
}
""";

var bindings = new HostBindings();
bindings.AddFunction("greet", args =>
{
    var name = args.Length > 0 ? args[0].GetString() : "World";
    return JsonSerializer.SerializeToElement($"Hello, {name}!");
});

using var runtime = XriptRuntime.Create(manifest, new RuntimeOptions
{
    HostBindings = bindings,
    Capabilities = [],
    Console = new ConsoleHandler
    {
        Log = msg => Console.WriteLine(msg),
        Warn = msg => Console.WriteLine($"WARN: {msg}"),
        Error = msg => Console.Error.WriteLine(msg),
    },
});

var result = runtime.Execute("greet(\"World\")");
// result.Value => "Hello, World!"
// result.DurationMs => 0.1 (approx)

What it does

  • Runs user-provided JavaScript inside a Jint sandbox (pure C#, no native interop)
  • Only functions declared in the manifest are available to scripts; everything else is blocked
  • Supports capability-gated bindings, namespace bindings, hooks, and resource limits
  • Fragment processing with data-bind and data-if support
  • Mod loading via LoadMod() with cross-validation against the host manifest
  • No eval, no Function, no access to the host environment

API

XriptRuntime.Create(manifestJson, options?) -> XriptRuntime

Creates a sandboxed runtime from a JSON manifest string. Validates the manifest on creation.

XriptRuntime.CreateFromFile(path, options?) -> XriptRuntime

Reads a manifest JSON file from disk and creates a runtime.

XriptRuntime.CreateFromValue(doc, options?) -> XriptRuntime

Creates a runtime from a JsonDocument.

runtime.Execute(code) -> ExecutionResult

Executes JavaScript code in the sandbox. Returns ExecutionResult { Value, DurationMs }.

runtime.FireHook(name, options?) -> JsonElement[]

Fires a hook by name, calling all registered handlers. Returns an array of handler return values.

runtime.LoadMod(modManifestJson, fragmentSources?) -> ModInstance

Loads a mod manifest, cross-validates it against the host manifest, and returns a ModInstance with fragment sources.

runtime.Dispose()

Releases sandbox resources. XriptRuntime implements IDisposable, so using works.

When to use this vs other runtimes

Xript.Runtime xript-runtime (Rust) @xriptjs/runtime @xriptjs/runtime-node
Language C# Rust JavaScript/TypeScript JavaScript/TypeScript
Runs in browser No No Yes No
Sandbox mechanism Jint (pure C#) QuickJS (native) QuickJS WASM Node.js vm module
Best for .NET apps, Unity, game engines Rust apps, native tools Cross-platform, browser, edge Node.js servers, CLI tools
Async bindings Not yet Not yet Via asyncify WASM Native async/await

Use this package when your host application is .NET. Use xript-runtime for Rust hosts. Use @xriptjs/runtime for JavaScript environments that need universal portability. Use @xriptjs/runtime-node for Node.js-only applications.

Documentation

xript.dev: full docs, getting started guide, and live demos.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.1 88 3/29/2026
0.3.1 84 3/19/2026
0.1.0 99 2/12/2026