MCPcopy Create free account
hub / github.com/Snapchat/Valdi / isJsModuleLoaded

Method isJsModuleLoaded

valdi/src/valdi/runtime/JavaScript/JavaScriptRuntime.cpp:2837–2866  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
2857Error JavaScriptRuntime::onModuleLoadFailed(const Error& error, const ResourceId& resourceId) {
2858 return error.rethrow(STRING_FORMAT("Failed to load JS module '{}'", resourceId));
2859}
2860
2861void 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 }

Callers 1

TEST_PFunction · 0.80

Calls 7

jsValueToValueFunction · 0.85
callObjectPropertyMethod · 0.80
getMethod · 0.65
newStringUTF8Method · 0.45
toAbsolutePathMethod · 0.45
toBoolMethod · 0.45

Tested by 1

TEST_PFunction · 0.64