| 3576 | return; |
| 3577 | } |
| 3578 | |
| 3579 | if (_onDaemonClientEventFunction) { |
| 3580 | notifyDaemonClientEvent(jsEntry.jsContext, |
| 3581 | eventType, |
| 3582 | daemonClient, |
| 3583 | payload, |
| 3584 | _onDaemonClientEventFunction.value().get(), |
| 3585 | jsEntry.exceptionTracker); |
| 3586 | } |
| 3587 | } |
| 3588 | |
| 3589 | void JavaScriptRuntime::notifyDaemonClientEvent(IJavaScriptContext& jsContext, |
| 3590 | DaemonClientEventType eventType, |
| 3591 | const JSValue& daemonClient, |
| 3592 | const JSValue& payload, |
| 3593 | const JSValue& onDaemonClientEventFunction, |
| 3594 | JSExceptionTracker& exceptionTracker) { |
| 3595 | std::initializer_list<JSValueRef> params = { |
| 3596 | jsContext.newNumber(static_cast<int32_t>(eventType)), |
| 3597 | JSValueRef::makeUnretained(jsContext, daemonClient), |
| 3598 | JSValueRef::makeUnretained(jsContext, payload), |
| 3599 | }; |
| 3600 | |
| 3601 | JSFunctionCallContext callContext(jsContext, params.begin(), params.size(), exceptionTracker); |
| 3602 | |
| 3603 | jsContext.callObjectAsFunction(onDaemonClientEventFunction, callContext); |
| 3604 | if (!exceptionTracker) { |
| 3605 | onRecoverableError("notifyDaemonClientEvent", exceptionTracker); |
| 3606 | } |
| 3607 | } |
| 3608 | |
| 3609 | void JavaScriptRuntime::setDefaultViewManagerContext(const Ref<ViewManagerContext>& viewManagerContext) { |
| 3610 | dispatchOnJsThreadUnattributed([=](auto& /*entry*/) { _defaultViewManagerContext = viewManagerContext; }); |
| 3611 | } |
| 3612 | |
| 3613 | std::future<Result<DumpedLogs>> JavaScriptRuntime::dumpLogs(bool includeMetadata, bool includeVerbose) { |
| 3614 | auto promise = Valdi::makeShared<std::promise<Result<DumpedLogs>>>(); |
| 3615 | auto future = promise->get_future(); |
| 3616 | |
| 3617 | dispatchOnJsThreadUnattributed([promise, this, includeMetadata, includeVerbose]( |
| 3618 | JavaScriptEntryParameters& jsEntry) { |
| 3619 | auto bugReportModule = importModule(STRING_LITERAL("valdi_core/src/BugReporter"), jsEntry); |
| 3620 | if (!jsEntry.exceptionTracker) { |
| 3621 | promise->set_value(jsEntry.exceptionTracker.extractError()); |
| 3622 | return; |
| 3623 | } |
| 3624 | |
| 3625 | auto jsValue = bugReportModule->getJsValue(jsEntry.jsContext, jsEntry.exceptionTracker); |
| 3626 | if (!jsEntry.exceptionTracker) { |
| 3627 | promise->set_value(jsEntry.exceptionTracker.extractError()); |
no test coverage detected