Skip to content

Commit

Permalink
Upgrade to Jint 3.0.2
Browse files Browse the repository at this point in the history
Remove obsolete STJ integration helpers
  • Loading branch information
lahma committed Apr 5, 2024
1 parent 5f65445 commit 0561562
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 92 deletions.
2 changes: 1 addition & 1 deletion src/OrchardCore.Build/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<PackageManagement Include="GraphQL.DataLoader" Version="7.8.0" />
<PackageManagement Include="GraphQL.MicrosoftDI" Version="7.8.0" />
<PackageManagement Include="GraphQL.SystemTextJson" Version="7.8.0" />
<PackageManagement Include="Jint" Version="3.0.1" />
<PackageManagement Include="Jint" Version="3.0.2" />
<PackageManagement Include="JsonPath.Net" Version="1.0.0" />
<PackageManagement Include="HtmlSanitizer" Version="8.1.860-beta" />
<PackageManagement Include="Irony.Core" Version="1.0.7" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,7 @@ public JavaScriptEngine(IMemoryCache memoryCache)

public IScriptingScope CreateScope(IEnumerable<GlobalMethod> methods, IServiceProvider serviceProvider, IFileProvider fileProvider, string basePath)
{
var engine = new Engine(options =>
{
// Make JsonArray behave like JS array.
options.SetWrapObjectHandler(static (e, target, type) =>
{
if (target is JsonArray)
{
var wrapped = new ObjectWrapper(e, target)
{
Prototype = e.Intrinsics.Array.PrototypeObject
};
return wrapped;
}

return new ObjectWrapper(e, target);
});

options.AddObjectConverter<JsonValueConverter>();

// We cannot access this[string] with anything else than JsonObject, otherwise itw will throw.
options.SetTypeResolver(new TypeResolver
{
MemberFilter = static info =>
{
if (info.ReflectedType != typeof(JsonObject) && info.Name == "Item" && info is PropertyInfo p)
{
var parameters = p.GetIndexParameters();
return parameters.Length != 1 || parameters[0].ParameterType != typeof(string);
}

return true;
}
});
});
var engine = new Engine();

foreach (var method in methods)
{
Expand All @@ -78,7 +45,7 @@ static void ThrowInvalidScopeTypeException()
ThrowInvalidScopeTypeException();
}

var parsedAst = _memoryCache.GetOrCreate(script, static entry => Engine.PrepareScript((string)entry.Key));
var parsedAst = _memoryCache.GetOrCreate(script, static entry => Engine.PrepareScript((string) entry.Key));

var result = jsScope.Engine.Evaluate(parsedAst).ToObject();

Expand Down

This file was deleted.

0 comments on commit 0561562

Please sign in to comment.