Skip to content

Zaitonn/Yilduz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yilduz

wakatime NuGet Version

An extension library for Jint that adds Web API implementations such as ReadableStream, localStorage, fetch, setTimeout, etc.

Usage

dotnet add package Yilduz
using Jint;
using Yilduz;

using var cts = new CancellationTokenSource();
using var engine = new Engine((o) => o.CancellationToken(cts.Token)).InitializeWebApi(
    new() { CancellationToken = cts.Token }
);

engine.Execute(
    """
    console.log('Hello world!');
    setTimeout(() => console.log('I can use `setTimeout`!'), 2000);
    """
);

cts.Cancel();

Development Progress

Click to expand
  • Aborting
    • AbortController
    • AbortSignal
  • Base64
    • atob()
    • btoa()
  • Compression
    • CompressionStream
    • DecompressionStream
  • Console
    • console
  • Data
    • Blob
    • Document
    • File
    • FileReader
    • FileReaderSync
    • FormData
  • DOM
    • DOMError
    • DOMException
  • Encoding
    • TextDecoder
    • TextDecoderStream
    • TextEncoder
    • TextEncoderStream
  • Events
    • CloseEvent
    • Event
    • EventTarget
    • MessageEvent
    • ProgressEvent
  • Network
    • fetch()
    • Headers
    • Request
    • Response
    • WebSocket
    • XMLHttpRequest
    • XMLHttpRequestEventTarget
    • XMLHttpRequestUpload
  • Streams
    • ByteLengthQueuingStrategy
    • CountQueuingStrategy
    • ReadableByteStreamController
    • ReadableStream
      • Async iteration is not implemented yet in Jint
    • ReadableStreamBYOBReader
    • ReadableStreamBYOBRequest
    • ReadableStreamDefaultReader
    • ReadableStreamDefaultController
    • WritableStream
    • WritableStreamDefaultWriter
    • WritableStreamDefaultController
    • TransformStream
    • TransformStreamDefaultController
  • Storages
    • localStorage
    • sessionStorage
  • Timers
    • setTimeout()
    • setInterval()
    • clearTimeout()
    • clearInterval()
  • URLs
    • URL
    • URLSearchParams

Try Yilduz.Repl

Want to try these features right now?

Just use Yilduz.Repl, a JavaScript REPL (Read-Eval-Print-Loop) program with Web API support, syntax error hints and syntax highlighting. Grab the latest artifact from the build workflow.

repl

Known Issues

Encoding Support

The TextDecoder implementation supports common character encodings including UTF-8, UTF-16, ASCII, and ISO-8859-1.

If you need to use additional character encodings beyond the common ones, you'll need to install the System.Text.Encoding.CodePages NuGet package and register the encoding providers:

using System.Text;

var engine = new Engine().InitializeWebApi(new() { CancellationToken = token });
// engine.Evaluate("new TextDecoder('gb_2312').encoding"); // throws an error

// Register additional encoding providers
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

engine.Evaluate("new TextDecoder('gb_2312').encoding"); // = 'gbk'

This enables support for legacy encodings such as Windows-1252, Shift-JIS, and other code page encodings.

Compression Support

By default, Yilduz supports the following compression formats specified in the WHATWG standard:

Format Underlying .NET Implementation Note
gzip System.IO.Compression.GZipStream
deflate-raw System.IO.Compression.DeflateStream
deflate System.IO.Compression.ZLibStream Available in .NET 6+

Additionally, you can completely customize the underlying compression implementations or add new formats (such as Brotli) by overriding Options.Compression.CompressorFactory and Options.Compression.DecompressorFactory during initialization. You can turn to CustomProviderTests.cs for examples of how to do this.

Spec Deviations

Some behaviors may differ slightly from Web specs because certain features wrap .NET types; we're working through these gaps.

Origin of the name

It was chosen arbitrarily.

The name comes from a little-known alternative name for the North Star.

About

An extension library for Jint that adds Web API implementations such as ReadableStream, localStorage, fetch, setTimeout, etc.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages