Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikMennen committed Nov 16, 2023
1 parent 5ba4142 commit 6d77a89
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/OneWare.NetListSvgIntegration/Services/NetListSvgService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ public NetListSvgService(ILogger logger)
try
{
var engine = new Engine();

engine.Execute("const exports = {}");
engine.Execute("const window = {};");

var console = new
{
log = new Action<object>(x => Console.WriteLine(x)),
warn = new Action<object>(x => Console.WriteLine("WARN: " + x)),
error = new Action<object>(x => Console.WriteLine("ERROR: " + x))
};
engine.SetValue("console", console);


engine.Execute("const window = {};");
engine.Execute("window.Math = Math");
engine.Execute("window.Array = Array");
engine.Execute("console.log(window.Math.sqrt(9));");
engine.SetValue("window.Array", engine.GetValue("Array"));
engine.SetValue("window.Date", new Func<string, object>((input) => DateTime.Parse(input)));
engine.Execute("const exports = {}");
engine.SetValue("setTimeout", new Action<Action, int>((action, delay) =>
{
if (delay <= 0)
Expand Down

0 comments on commit 6d77a89

Please sign in to comment.