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

Method onModulesUnloaded

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

Source from the content-addressed store, hash-verified

2910 it = _pendingModulesToReload.erase(it);
2911 }
2912 });
2913}
2914
2915void JavaScriptRuntime::unloadModulesAndDependentModules(const std::vector<ResourceId>& resourceIds,
2916 bool isHotReloading) {
2917 dispatchOnJsThreadUnattributed([=](JavaScriptEntryParameters& entry) {
2918 for (const auto& jsWorker : getAllWorkers()) {
2919 jsWorker->unloadModulesAndDependentModules(resourceIds, isHotReloading);
2920 }
2921
2922 doUnloadModulesAndDependentModules(resourceIds, isHotReloading, entry);
2923 if (isHotReloading) {
2924 reevalUnloadedModulesIfNeeded();
2925 }
2926 });
2927}
2928
2929bool JavaScriptRuntime::isJsModuleLoaded(const ResourceId& resourceId) {
2930 bool loaded = false;
2931
2932 dispatchSynchronouslyOnJsThread([&](JavaScriptEntryParameters& entry) {
2933 auto pathResult = entry.jsContext.newStringUTF8(resourceId.toAbsolutePath(), entry.exceptionTracker);
2934 if (!entry.exceptionTracker) {
2935 onRecoverableError("isJsModuleLoaded", entry.exceptionTracker);
2936 return;
2937 }
2938
2939 JSFunctionCallContext params(entry.jsContext, &pathResult, 1, entry.exceptionTracker);
2940 auto result = entry.jsContext.callObjectProperty(
2941 _moduleLoader.get(), _propertyNameIndex.getJsName(kIsLoadedPropertyName), params);
2942 if (!entry.exceptionTracker) {
2943 onRecoverableError("isJsModuleLoaded", entry.exceptionTracker);
2944 return;
2945 }
2946
2947 auto convertResult =
2948 jsValueToValue(entry.jsContext, result.get(), ReferenceInfoBuilder(), entry.exceptionTracker);
2949 if (!entry.exceptionTracker) {
2950 onRecoverableError("isJsModuleLoaded", entry.exceptionTracker);
2951 return;
2952 }
2953
2954 loaded = convertResult.toBool();
2955 });

Callers

nothing calls this directly

Calls 12

jsValueToValueFunction · 0.85
getArrayRefMethod · 0.80
didUnloadMethod · 0.80
errorMethod · 0.65
insertMethod · 0.65
containsMethod · 0.65
endMethod · 0.65
ErrorInterface · 0.50
toStringBoxMethod · 0.45
findMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected