misc(core): use JsObject instead

This commit is contained in:
genteure 2023-01-20 23:57:09 +08:00
parent e8fd1fb3f4
commit 7640a865e3
3 changed files with 3 additions and 15 deletions

View File

@ -1,12 +0,0 @@
using Jint;
using Jint.Native.Object;
namespace BililiveRecorder.Core.Scripting
{
internal class PlainOldJsObject : ObjectInstance
{
public PlainOldJsObject(Engine engine) : base(engine)
{
}
}
}

View File

@ -117,11 +117,11 @@ namespace BililiveRecorder.Core.Scripting.Runtime
var respString = resp.Content.ReadAsStringAsync().Result;
#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits
var respHeaders = new PlainOldJsObject(this._engine);
var respHeaders = new JsObject(this._engine);
foreach (var respHeader in resp.Headers)
respHeaders.Set(respHeader.Key, string.Join(", ", respHeader.Value));
var result = new PlainOldJsObject(this._engine);
var result = new JsObject(this._engine);
result.Set("body", respString);
result.Set("headers", respHeaders);
result.Set("ok", resp.IsSuccessStatusCode);

View File

@ -179,7 +179,7 @@ globalThis.recorderEvents = {};
var func = this.ExecuteScriptThenGetEventHandler(log, callbackName);
if (func is null) return null;
var input = new PlainOldJsObject(func.Engine);
var input = new JsObject(func.Engine);
input.Set("roomid", roomid);
input.Set("qn", JsValue.FromObject(func.Engine, qnSetting));