/// <summary> /// Runs the script at the given path. /// </summary> /// <param name="sourcePath">The source path.</param> /// <param name="sourceUrl">The source URL.</param> public void RunScript(string sourcePath, string sourceUrl) { if (sourcePath == null) { throw new ArgumentNullException(nameof(sourcePath)); } if (sourceUrl == null) { throw new ArgumentNullException(nameof(sourceUrl)); } var startupCode = default(string); if (IsUnbundle(sourcePath)) { _unbundle = new FileBasedJavaScriptUnbundle(sourcePath); InstallNativeRequire(); startupCode = _unbundle.GetStartupCode(); } else if (IsIndexedUnbundle(sourcePath)) { _unbundle = new IndexedJavaScriptUnbundle(sourcePath); InstallNativeRequire(); startupCode = _unbundle.GetStartupCode(); } else { startupCode = LoadScript(sourcePath); } EvaluateScript(startupCode, sourceUrl); }
/// <summary> /// Runs the script at the given path. /// </summary> /// <param name="sourcePath">The source path.</param> /// <param name="sourceUrl">The source URL.</param> public void RunScript(string sourcePath, string sourceUrl) { if (sourcePath == null) { throw new ArgumentNullException(nameof(sourcePath)); } if (sourceUrl == null) { throw new ArgumentNullException(nameof(sourceUrl)); } var startupCode = default(string); if (IsUnbundle(sourcePath)) { _unbundle = new FileBasedJavaScriptUnbundle(sourcePath); InstallNativeRequire(); startupCode = _unbundle.GetStartupCode(); } else if (IsIndexedUnbundle(sourcePath)) { _unbundle = new IndexedJavaScriptUnbundle(sourcePath); InstallNativeRequire(); startupCode = _unbundle.GetStartupCode(); } else { startupCode = LoadScript(sourcePath); try { if (this._modifyBundle != null) { //Modify bundle function returns modified bundle. var updatedBundle = this._modifyBundle(startupCode); startupCode = updatedBundle; } } catch (Exception ex) { RnLog.Error("Native", ex, @"Exception during bundle modification."); #if DEBUG throw; #endif } } EvaluateScript(startupCode, sourceUrl); }