Skip to content

Commit

Permalink
In JavaScriptEngineSwitcher.Yantra added support for the YantraJS ver…
Browse files Browse the repository at this point in the history
…sion 1.2.225
  • Loading branch information
Taritsyn committed Sep 1, 2024
1 parent 25c6743 commit dc92aff
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
<PackageIconFullPath>../../Icons/JavaScriptEngineSwitcher_Yantra_Logo128x128.png</PackageIconFullPath>
<Description>JavaScriptEngineSwitcher.Yantra contains a `YantraJsEngine` adapter (wrapper for the YantraJS).</Description>
<PackageTags>$(PackageCommonTags);Yantra;YantraJS</PackageTags>
<PackageReleaseNotes>YantraJS was updated to version 1.2.218.</PackageReleaseNotes>
<PackageReleaseNotes>YantraJS was updated to version 1.2.225.</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="YantraJS.Core" Version="1.2.218" />
<PackageReference Include="YantraJS.Core" Version="1.2.225" />

<ProjectReference Include="../JavaScriptEngineSwitcher.Core/JavaScriptEngineSwitcher.Core.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/JavaScriptEngineSwitcher.Yantra/PACKAGE-DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
JavaScriptEngineSwitcher.Yantra contains a `YantraJsEngine` adapter (wrapper for the [YantraJS](https://yantrajs.com) version 1.2.218).
JavaScriptEngineSwitcher.Yantra contains a `YantraJsEngine` adapter (wrapper for the [YantraJS](https://yantrajs.com) version 1.2.225).
33 changes: 18 additions & 15 deletions src/JavaScriptEngineSwitcher.Yantra/YantraJsEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public sealed class YantraJsEngine : JsEngineBase
/// <summary>
/// Version of original JS engine
/// </summary>
private const string EngineVersion = "1.2.218";
private const string EngineVersion = "1.2.225";

/// <summary>
/// Regular expression for working with the error message
Expand Down Expand Up @@ -324,20 +324,12 @@ private WrapperException WrapJsException(OriginalException originalException)
int.Parse(messageGroups["columnNumber"].Value) : 0;
}

string rawCallStack;

if (type == JsErrorType.Syntax)
{
rawCallStack = originalException.JSStackTrace.AsStringOrDefault();
}
else
{
string messageWithTypeAndCallStack = errorValue.Stack ?? errorValue["stack"].AsStringOrDefault();
rawCallStack = messageWithTypeAndCallStack
.TrimStart(messageWithType)
.TrimStart(new char[] { '\n', '\r' })
;
}
string messageWithCallStack = type == JsErrorType.Syntax ?
originalException.JSStackTrace.AsStringOrDefault()
:
errorValue.Stack ?? errorValue["stack"].AsStringOrDefault()
;
string rawCallStack = GetRawCallStack(message, messageWithType, messageWithCallStack);

callStackItems = YantraJsErrorHelpers.ParseErrorLocation(rawCallStack);
callStackItems = YantraJsErrorHelpers.FilterErrorLocationItems(callStackItems);
Expand Down Expand Up @@ -396,6 +388,17 @@ private WrapperException WrapJsException(OriginalException originalException)
return wrapperException;
}

private static string GetRawCallStack(string message, string messageWithType, string messageWithCallStack)
{
string baseMessage = messageWithCallStack.StartsWith(messageWithType) ? messageWithType : message;
string rawCallStack = messageWithCallStack
.TrimStart(baseMessage)
.TrimStart(new char[] { '\n', '\r' })
;

return rawCallStack;
}

private void OnConsoleWrite(OriginalContext context, string type, in OriginalArguments args)
{
int argCount = args.Length;
Expand Down
4 changes: 2 additions & 2 deletions src/JavaScriptEngineSwitcher.Yantra/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
DESCRIPTION
===========
JavaScriptEngineSwitcher.Yantra contains a `YantraJsEngine` adapter (wrapper for the
YantraJS (https://yantrajs.com) version 1.2.218).
YantraJS (https://yantrajs.com) version 1.2.225).

=============
RELEASE NOTES
=============
YantraJS was updated to version 1.2.218.
YantraJS was updated to version 1.2.225.

=============
DOCUMENTATION
Expand Down

0 comments on commit dc92aff

Please sign in to comment.