예제 #1
0
        public static void ParseScript(JavaScriptModuleRecord module, string script)
        {
            var  buffer = Encoding.UTF8.GetBytes(script);
            uint length = (uint)buffer.Length;

            Native.ThrowIfError(Native.JsParseModuleSource(module, JavaScriptSourceContext.None, buffer, length, JavaScriptParseModuleSourceFlags.JsParseModuleSourceFlags_DataIsUTF8, out JavaScriptValue parseException));
            if (parseException.IsValid)
            {
                string ex = parseException.ToString();
                throw new InvalidOperationException($"Parse script failed with error={ex}");
            }
        }
예제 #2
0
 public static extern JavaScriptErrorCode JsSetModuleHostName(JavaScriptModuleRecord module, JavascriptModuleHostInfoKind kind, JavaScriptValue value);
예제 #3
0
 public static extern JavaScriptErrorCode JsSetFetchImportedModuleFromScriptyCallback(JavaScriptModuleRecord module, JavascriptModuleHostInfoKind kind, FetchImportedModuleFromScriptDelegate value);
예제 #4
0
 public static extern JavaScriptErrorCode JsSetModuleNotifyModuleReadyCallback(JavaScriptModuleRecord module, JavascriptModuleHostInfoKind kind, NotifyModuleReadyCallbackDelegate value);
예제 #5
0
 public static extern JavaScriptErrorCode JsSetModuleHostInfo(JavaScriptModuleRecord module, JavascriptModuleHostInfoKind kind, object value);
예제 #6
0
 public static extern JavaScriptErrorCode JsModuleEvaluation(JavaScriptModuleRecord moduel, out JavaScriptValue result);
예제 #7
0
 public static extern JavaScriptErrorCode JsParseModuleSource(JavaScriptModuleRecord moduel, JavaScriptSourceContext sourceContext, byte[] script, uint scriptLength, JavaScriptParseModuleSourceFlags flags, out JavaScriptValue parseException);
예제 #8
0
 public static extern JavaScriptErrorCode JsInitializeModuleRecord(JavaScriptModuleRecord parent, JavaScriptValue name, out JavaScriptModuleRecord result);
예제 #9
0
        public static void SetModuleName(JavaScriptModuleRecord module, string name)
        {
            JavaScriptValue value = JavaScriptValue.FromString(name);

            Native.ThrowIfError(Native.JsSetModuleHostName(module, JavascriptModuleHostInfoKind.JsModuleHostInfo_HostDefined, value));
        }
예제 #10
0
 public static void SetFetchModuleScriptCallback(JavaScriptModuleRecord module, FetchImportedModuleFromScriptDelegate callback)
 {
     Native.ThrowIfError(Native.JsSetFetchImportedModuleFromScriptyCallback(module, JavascriptModuleHostInfoKind.JsModuleHostInfo_FetchImportedModuleFromScriptCallback, callback));
 }
예제 #11
0
 public static void SetNotifyReady(JavaScriptModuleRecord module, NotifyModuleReadyCallbackDelegate callback)
 {
     Native.ThrowIfError(Native.JsSetModuleNotifyModuleReadyCallback(module, JavascriptModuleHostInfoKind.JsModuleHostInfo_NotifyModuleReadyCallback, callback));
 }
예제 #12
0
 public static void SetHostInfo(JavaScriptModuleRecord module, JavascriptModuleHostInfoKind kind, object value)
 {
     Native.ThrowIfError(Native.JsSetModuleHostInfo(module, kind, value));
 }
예제 #13
0
 public static JavaScriptValue RunModule(JavaScriptModuleRecord module)
 {
     Native.ThrowIfError(Native.JsModuleEvaluation(module, out JavaScriptValue result));
     return(result);
 }