From da9c1d91605a0958afb58b6434c706d5839b48c2 Mon Sep 17 00:00:00 2001 From: genteure Date: Sun, 2 Oct 2022 16:37:46 +0800 Subject: [PATCH] feat(core): update Jint --- BililiveRecorder.Core/BililiveRecorder.Core.csproj | 2 +- BililiveRecorder.Core/Scripting/UserScriptRunner.cs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/BililiveRecorder.Core/BililiveRecorder.Core.csproj b/BililiveRecorder.Core/BililiveRecorder.Core.csproj index 438b802..ccf49eb 100644 --- a/BililiveRecorder.Core/BililiveRecorder.Core.csproj +++ b/BililiveRecorder.Core/BililiveRecorder.Core.csproj @@ -13,7 +13,7 @@ - + diff --git a/BililiveRecorder.Core/Scripting/UserScriptRunner.cs b/BililiveRecorder.Core/Scripting/UserScriptRunner.cs index bc26691..791adfb 100644 --- a/BililiveRecorder.Core/Scripting/UserScriptRunner.cs +++ b/BililiveRecorder.Core/Scripting/UserScriptRunner.cs @@ -2,7 +2,6 @@ using System; using System.Threading; using BililiveRecorder.Core.Config.V3; using BililiveRecorder.Core.Scripting.Runtime; -using Esprima; using Esprima.Ast; using Jint; using Jint.Native; @@ -29,9 +28,9 @@ namespace BililiveRecorder.Core.Scripting static UserScriptRunner() { - setupScript = new JavaScriptParser(new ParserOptions()).ParseScript(@" + setupScript = Engine.PrepareScript(@" globalThis.recorderEvents = {}; -", "internalSetup.js", true); +", "internalSetup.js"); } public UserScriptRunner(GlobalConfig config) @@ -73,8 +72,7 @@ globalThis.recorderEvents = {}; return null; } - var parser = new JavaScriptParser(); - var script = parser.ParseScript(source!, "userscript.js", true); + var script = Engine.PrepareScript(source!, "userscript.js"); this.cachedScript = script; this.cachedScriptSource = source;