public static void AttachModule(JavaScriptValue module, AbstractJSModule subModule) { if (Native.JsSetProperty(module, JavaScriptPropertyId.FromString(subModule.GetId()), subModule.GetModule(), false) != JavaScriptErrorCode.NoError) { throw new Exception("Failed to attach module"); } }
protected override JavaScriptValue Main(JavaScriptValue callee, bool isConstructCall, JavaScriptValue[] arguments, ushort argumentCount, IntPtr callbackData) { string moduleKey = AbstractJSModule.JSValToString(arguments[1]); AbstractJSModule module; if (!modules.TryGetValue(moduleKey, out module)) { return(JavaScriptValue.Undefined); } return(module.GetModule()); }
public string Init() { if (Native.JsCreateRuntime(JavaScriptRuntimeAttributes.EnableIdleProcessing, null, out runtime) != JavaScriptErrorCode.NoError) { return("failed to create runtime."); } if (Native.JsCreateContext(runtime, out context) != JavaScriptErrorCode.NoError) { return("failed to create execution context."); } if (Native.JsSetCurrentContext(context) != JavaScriptErrorCode.NoError) { return("failed to set current context."); } if (Native.JsSetPromiseContinuationCallback(promiseContinuationDelegate, IntPtr.Zero) != JavaScriptErrorCode.NoError) { return("failed to setup callback for ES6 Promise"); } if (Native.JsProjectWinRTNamespace("Windows") != JavaScriptErrorCode.NoError) { return("failed to project windows namespace."); } if (Native.JsStartDebugging() != JavaScriptErrorCode.NoError) { return("failed to start debugging."); } if (Native.JsGetGlobalObject(out jsAppGlobalObject) != JavaScriptErrorCode.NoError) { return("failed to get global object"); } console = new JS.JSConsole(); require = new JS.JSRequire(); process = new JS.JSProcess(); JS.AbstractJSModule.AttachModule(jsAppGlobalObject, require); JS.AbstractJSModule.AttachModule(jsAppGlobalObject, console); JS.AbstractJSModule.AttachModule(jsAppGlobalObject, process); return("NoError"); }
public static void AttachProperty(AbstractJSModule module, JavaScriptValue method, string id) { AttachProperty(module.GetModule(), method, id); }
public static void AttachMethod(AbstractJSModule module, JavaScriptNativeFunction method, string id) { AttachMethod(module.GetModule(), method, id); }
public static void AttachModule(AbstractJSModule module, AbstractJSModule subModule) { AttachModule(module.GetModule(), subModule); }
public void AttachModule(AbstractJSModule subModule) { AttachModule(this, subModule); }
private void AddModule(AbstractJSModule module) { modules.Add(module.GetId(), module); }