| 2910 | it = _pendingModulesToReload.erase(it); |
| 2911 | } |
| 2912 | }); |
| 2913 | } |
| 2914 | |
| 2915 | void 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 | |
| 2929 | bool 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 | }); |
nothing calls this directly
no test coverage detected