Skip to content
Taritsyn edited this page Aug 3, 2026 · 26 revisions

JavaScriptEngineSwitcher.Yantra contains a YantraJsEngine adapter (wrapper for the YantraJS version 1.2.421).

Engine settings

You can specify a settings of JS engine during its registration:

engineSwitcher.EngineFactories.AddYantra(newYantraSettings{ConsoleCallback=(stringtype,object[]args)=>{TextWriterwriter=type=="error"?Console.Error:Console.Out;if(type!="log"){ConsoleColortypeColor;switch(type){case"warn":typeColor=ConsoleColor.Yellow;break;case"error":typeColor=ConsoleColor.Red;break;default:typeColor=ConsoleColor.White;break;}Console.ForegroundColor=typeColor;writer.Write("{0}: ",type);}Console.ForegroundColor=ConsoleColor.White;for(intargIndex=0;argIndex<args.Length;argIndex++){if(argIndex>0){writer.Write(" ");}writer.Write(args[argIndex]??"null");}writer.WriteLine();}});

If you manually create an instance of JS engine, then you can pass settings via the constructor:

IJsEngineengine=newYantraJsEngine(newYantraSettings{ConsoleCallback=(stringtype,object[]args)=>{}});

Consider in detail properties of the YantraSettings class:

Property nameData typeDefault valueDescription
ConsoleCallbackYantraJsConsoleCallback delegatenullJS debugging console callback.
DebuggerYantraJS.Debugger.JSDebuggernullInstance of JS debugger (for example, the YantraJS.Core.Debugger.V8Debugger)

Clone this wiki locally