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

Method loadJsModule

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

Source from the content-addressed store, hash-verified

1362}
1363
1364JSValueRef JavaScriptRuntime::handleViewNodeSpecificActionSync(JSFunctionNativeCallContext& callContext,
1365 Value (*handleViewNode)(ViewNode&)) {
1366 return handleViewNodeSpecificAction(
1367 callContext,
1368 [handleViewNode](ViewNode& viewNode,
1369 Function<void(const Value&)> callback) { // NOLINT(performance-unnecessary-value-param)
1370 callback(handleViewNode(viewNode));
1371 });
1372}
1373
1374JSValueRef JavaScriptRuntime::handleViewNodeSpecificActionAsync(JSFunctionNativeCallContext& callContext,
1375 void (*handleViewNode)(ViewNode&,
1376 Function<void(const Value&)>)) {
1377 return handleViewNodeSpecificAction(callContext,
1378 [handleViewNode](ViewNode& viewNode, Function<void(const Value&)> callback) {
1379 handleViewNode(viewNode, std::move(callback));
1380 });
1381}
1382
1383// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
1384JSValueRef JavaScriptRuntime::runtimeMakeOpaque(JSFunctionNativeCallContext& callContext) {
1385 return makeOpaque(callContext.getContext(),
1386 callContext.getParameter(0),
1387 ReferenceInfoBuilder(callContext.getReferenceInfo()).withReturnValue(),
1388 callContext.getExceptionTracker());
1389}
1390
1391// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
1392JSValueRef JavaScriptRuntime::runtimeBytesToString(JSFunctionNativeCallContext& callContext) {
1393 auto convertedBytes =
1394 callContext.getContext().valueToTypedArray(callContext.getParameter(0), callContext.getExceptionTracker());
1395 CHECK_CALL_CONTEXT(callContext);
1396
1397 return callContext.getContext().newStringUTF8(
1398 std::string_view(reinterpret_cast<const char*>(convertedBytes.data), convertedBytes.length),
1399 callContext.getExceptionTracker());
1400}
1401
1402JSValueRef JavaScriptRuntime::runtimeIsModuleLoaded(JSFunctionNativeCallContext& callContext) {
1403 auto moduleName = callContext.getParameterAsString(0);
1404 CHECK_CALL_CONTEXT(callContext);
1405
1406 auto moduleLoaded = _resourceManager.isBundleLoaded(moduleName);
1407 return callContext.getContext().newBool(moduleLoaded);
1408}
1409
1410JSValueRef JavaScriptRuntime::runtimeGetModuleEntry(JSFunctionNativeCallContext& callContext) {
1411 auto moduleName = callContext.getParameterAsString(0);
1412 CHECK_CALL_CONTEXT(callContext);
1413
1414 auto path = callContext.getParameterAsString(1);
1415 CHECK_CALL_CONTEXT(callContext);
1416
1417 auto asString = callContext.getParameterAsBool(2);
1418 CHECK_CALL_CONTEXT(callContext);
1419
1420 auto bundle = _resourceManager.getBundle(moduleName);
1421

Callers

nothing calls this directly

Calls 15

getGlobalFunction · 0.85
getMemoryUsageBytesFunction · 0.85
getCurrentTimestampMsFunction · 0.85
moduleLoadModeToStringFunction · 0.85
newUndefinedMethod · 0.80
getBundleMethod · 0.80
makeStringMethod · 0.80
getJsMethod · 0.80
startMethod · 0.65
onErrorMethod · 0.65
valueMethod · 0.65

Tested by

no test coverage detected