Cocoar.JsEval.TypeScript
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Cocoar.JsEval.TypeScript --version 1.0.0
NuGet\Install-Package Cocoar.JsEval.TypeScript -Version 1.0.0
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="Cocoar.JsEval.TypeScript" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cocoar.JsEval.TypeScript" Version="1.0.0" />
<PackageReference Include="Cocoar.JsEval.TypeScript" />
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 Cocoar.JsEval.TypeScript --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Cocoar.JsEval.TypeScript, 1.0.0"
#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 Cocoar.JsEval.TypeScript@1.0.0
#: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=Cocoar.JsEval.TypeScript&version=1.0.0
#tool nuget:?package=Cocoar.JsEval.TypeScript&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Cocoar.JsEval
JavaScript/TypeScript execution library for .NET, built on Jint.
Features
- JavaScript execution via Jint (ES2025 support)
- Four execution methods:
ExecuteAsync()(standard),Evaluate(),Evaluate(prepared),EvaluateAsync() - Pre-parsed scripts (
Prepare()) for maximum throughput - TypeScript 6.0 transpilation with embedded compiler
fetch()API with opt-in sandboxing- Automatic .NET
Task→ JSPromiseinterop console.log/warn/error/debugviaILoggersetTimeout/setIntervalsupport- Extensible module system (HTTP, Database, SMTP, Templates, and more)
.d.tsgeneration for IntelliSense supportIJsEngineinterface for testability and mocking- Built for .NET 10
Quick Start
dotnet add package Cocoar.JsEval.Engine
Basic JavaScript Execution
services.AddJsEval();
var engine = sp.GetRequiredService<IJsEngine>();
engine.SetValue("name", "World");
engine.Evaluate("var greeting = 'Hello, ' + name + '!';");
var result = engine.GetValue<string>("greeting"); // "Hello, World!"
With ES Modules
services.AddJsEval(b => b
.AddModule<CommonModule>()
.AddModule<HttpModule>()
);
var engine = sp.GetRequiredService<IJsEngine>();
await engine.ExecuteAsync(@"
import * as common from 'common'
export const id = common.Guid.New();
");
Pre-Parsed Scripts (for repeated execution)
// Parse once (thread-safe, cacheable)
var prepared = JsEngine.Prepare("query.WhereResponsible(ctx.UserId);");
// Execute many times — no re-parsing
engine.SetValue("ctx", accessContext);
engine.SetValue("query", queryBuilder);
engine.Evaluate(prepared);
TypeScript Transpilation
dotnet add package Cocoar.JsEval.TypeScript
services.AddTsTranspiler();
var transpiler = sp.GetRequiredService<TsTranspiler>();
var js = transpiler.Transpile(tsCode); // transpile once
await engine.ExecuteAsync(js); // execute
fetch()
services.AddJsEval(b => b.EnableFetch());
const response = await fetch('https://api.example.com/data');
const body = await response.text();
console.log(response.status, response.ok);
.NET async → JS Promise (automatic)
engine.SetValue("loadData", new Func<string, Task<string>>(async id => {
return await db.FindAsync(id);
}));
const data = await loadData('item-123'); // .NET Task becomes a Promise
Execution Methods
| Method | Module System | async | Prepared | Use Case |
|---|---|---|---|---|
ExecuteAsync(string) |
Yes | Yes | No | Standard -- use when you don't know what's in the script |
Evaluate(string) |
No | No | No | Lightweight sync -- when you control the script |
Evaluate(JsPreparedScript) |
No | No | Yes | Max performance -- pre-parsed, reusable |
EvaluateAsync(string) |
No | Yes | No | Lightweight async -- no modules but needs await |
ExecuteAsync is the default/standard method -- it provides the full module system and is always safe. Evaluate is a conscious opt-in for a restricted execution mode -- choose it when you know your scripts don't need modules.
Packages
| Package | Description |
|---|---|
Cocoar.JsEval |
Core: interfaces, helpers, JsFunction |
Cocoar.JsEval.Engine |
JsEngine + fetch() + DI registration |
Cocoar.JsEval.TypeScript |
TypeScript 6.0 transpiler |
Cocoar.JsEval.TsDefinition |
.d.ts generation for IntelliSense |
Cocoar.JsEval.Expressions |
Expression Tree helpers for LINQ-compatible filters |
Cocoar.JsEval.Module.Common |
Guid, Sleep, Random |
Cocoar.JsEval.Module.Http |
Fluent HTTP client |
Cocoar.JsEval.Module.Database |
SQL Server + PostgreSQL |
Cocoar.JsEval.Module.Smtp |
Email via MailKit |
Cocoar.JsEval.Module.AngleSharp |
HTML parsing |
Cocoar.JsEval.Module.Template |
Scriban templates |
Cocoar.JsEval.Module.Logging |
Microsoft.Extensions.Logging |
Cocoar.JsEval.Module.VirtualFileSystem |
Zio VFS |
License
Apache-2.0 — COCOAR e.U.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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.
-
net10.0
- Cocoar.JsEval (>= 1.0.0)
- Jint (>= 4.8.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.6)
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 |
|---|---|---|
| 3.3.0 | 98 | 4/27/2026 |
| 3.3.0-beta.11 | 51 | 4/27/2026 |
| 3.3.0-beta.10 | 71 | 4/27/2026 |
| 3.3.0-beta.5 | 49 | 4/26/2026 |
| 3.3.0-beta.2 | 59 | 4/25/2026 |
| 3.3.0-beta.1 | 51 | 4/25/2026 |
| 3.2.0 | 94 | 4/24/2026 |
| 3.2.0-tsdefinition-short-na... | 51 | 4/19/2026 |
| 3.1.4 | 170 | 4/20/2026 |
| 3.1.3 | 102 | 4/19/2026 |
| 3.1.2 | 94 | 4/18/2026 |
| 3.1.1 | 95 | 4/18/2026 |
| 3.1.0 | 93 | 4/17/2026 |
| 3.0.0 | 90 | 4/17/2026 |
| 2.1.0-alpha.1 | 52 | 4/17/2026 |
| 2.0.0 | 104 | 4/17/2026 |
| 1.0.0 | 98 | 4/15/2026 |
| 0.2.0-alpha.4 | 55 | 4/15/2026 |
| 0.0.0-tsdefinition-short-na... | 53 | 4/19/2026 |
| 0.0.0-tsdefinition-short-na... | 56 | 4/19/2026 |