| 2835 | if (parameters != nullptr && !parameters->empty()) { |
| 2836 | std::vector<JSValueRef> jsParameters; |
| 2837 | for (const auto& parameter : *parameters) { |
| 2838 | auto jsParameter = |
| 2839 | valueToJSValue(jsEntry.jsContext, parameter, ReferenceInfoBuilder(), jsEntry.exceptionTracker); |
| 2840 | if (!jsEntry.exceptionTracker) { |
| 2841 | return; |
| 2842 | } |
| 2843 | |
| 2844 | jsParameters.emplace_back(jsEntry.jsContext.ensureRetainedValue(std::move(jsParameter))); |
| 2845 | } |
| 2846 | |
| 2847 | JSFunctionCallContext callContext( |
| 2848 | jsEntry.jsContext, jsParameters.data(), jsParameters.size(), jsEntry.exceptionTracker); |
| 2849 | jsEntry.jsContext.callObjectProperty(moduleJsValue, functionName.toStringView(), callContext); |
| 2850 | } else { |
| 2851 | JSFunctionCallContext callContext(jsEntry.jsContext, nullptr, 0, jsEntry.exceptionTracker); |
| 2852 | jsEntry.jsContext.callObjectProperty(moduleJsValue, functionName.toStringView(), callContext); |
| 2853 | } |
| 2854 | }); |
| 2855 | } |
| 2856 | |
| 2857 | Error JavaScriptRuntime::onModuleLoadFailed(const Error& error, const ResourceId& resourceId) { |
| 2858 | return error.rethrow(STRING_FORMAT("Failed to load JS module '{}'", resourceId)); |
| 2859 | } |
| 2860 | |
| 2861 | void JavaScriptRuntime::initializeModuleLoader(JavaScriptEntryParameters& jsEntry) { |
| 2862 | loadJsModule(jsEntry.jsContext, STRING_LITERAL("valdi_core/src/Init"), true, nullptr, 0, jsEntry.exceptionTracker); |
| 2863 | if (!jsEntry.exceptionTracker) { |
| 2864 | return; |
| 2865 | } |
| 2866 | auto globalObjectResult = jsEntry.jsContext.getGlobalObject(jsEntry.exceptionTracker); |
| 2867 | if (!jsEntry.exceptionTracker) { |
| 2868 | return; |
| 2869 | } |