| 2219 | }); |
| 2220 | } |
| 2221 | return callContext.getContext().newUndefined(); |
| 2222 | } |
| 2223 | |
| 2224 | JSValueRef JavaScriptRuntime::runtimeSetActiveColorPalette(JSFunctionNativeCallContext& callContext) { |
| 2225 | if (!_isWorker) { |
| 2226 | auto name = callContext.getParameterAsString(0); |
| 2227 | CHECK_CALL_CONTEXT(callContext); |
| 2228 | |
| 2229 | dispatchOnMainThread([weakSelf = weakRef(this), name]() { |
| 2230 | auto self = weakSelf.lock(); |
| 2231 | if (self != nullptr) { |
| 2232 | if (auto listener = self->getListener()) { |
| 2233 | listener->setActiveColorPalette(name); |
| 2234 | } |
| 2235 | } |
| 2236 | }); |
| 2237 | } |
| 2238 | return callContext.getContext().newUndefined(); |
| 2239 | } |
| 2240 | |
| 2241 | JSValueRef JavaScriptRuntime::runtimeOnMainThreadIdle(JSFunctionNativeCallContext& callContext) { |
| 2242 | auto callback = callContext.getParameterAsFunction(0); |
| 2243 | CHECK_CALL_CONTEXT(callContext); |
| 2244 | |
| 2245 | _mainThreadManager.onIdle(callback); |
| 2246 | |
| 2247 | return callContext.getContext().newUndefined(); |
| 2248 | } |
| 2249 | |
| 2250 | JSValueRef JavaScriptRuntime::runtimeScheduleWorkItem(JSFunctionNativeCallContext& callContext) { |
| 2251 | bool interruptible = false; |
| 2252 | auto func = |
| 2253 | JSValueRefHolder::makeRetainedCallback(callContext.getContext(), |
| 2254 | callContext.getParameter(0), |
| 2255 | ReferenceInfoBuilder(callContext.getReferenceInfo()).withParameter(0), |
| 2256 | callContext.getExceptionTracker()); |
| 2257 | int64_t delayResult = 0; |
| 2258 | if (callContext.getParameterSize() > 1) { |
| 2259 | delayResult = callContext.getParameterAsInt(1); |
| 2260 | CHECK_CALL_CONTEXT(callContext); |
| 2261 | } |
| 2262 | if (callContext.getParameterSize() > 2) { |
| 2263 | interruptible = callContext.getParameterAsBool(2); |
| 2264 | CHECK_CALL_CONTEXT(callContext); |
| 2265 | } |
| 2266 | |
| 2267 | auto delayMs = std::chrono::milliseconds(static_cast<int64_t>(delayResult)); |
| 2268 | |
| 2269 | auto funcContext = func->getContext(); |
| 2270 | auto dispatchAttribution = dispatchReasonName(JsThreadDispatchReason::ScheduleWorkItem); |
| 2271 | auto dispatchFunc = makeJsThreadDispatchFunction( |
| 2272 | Ref(std::move(funcContext)), |
| 2273 | [func = std::move(func), interruptible](JavaScriptEntryParameters& jsEntry) { |
| 2274 | auto jsValue = func->getJsValue(jsEntry.jsContext, jsEntry.exceptionTracker); |
| 2275 | if (!jsEntry.exceptionTracker) { |
| 2276 | if (interruptible) { |
| 2277 | jsEntry.exceptionTracker.clearError(); |
| 2278 | } |
nothing calls this directly
no test coverage detected