in hot-reload-runtime-jvm/src/main/kotlin/org/jetbrains/compose/reload/jvm/DevelopmentEntryPoint.kt [44:107]
public fun DevelopmentEntryPoint(
window: Window? = null,
child: @Composable () -> Unit
) {
/* Checking if we're currently in the stack of a hot reload */
if (hotReloadStateLocal.current != null) {
logger.warn(
"Skipping 'DevelopmentEntryPoint': We're already in an entry point",
Exception("Nested 'DevelopmentEntryPoint'")
)
child()
return
}
val windowId = window?.let { startWindowManager(window) }
LaunchedEffect(Unit) {
orchestration.asFlow().filterIsInstance<CleanCompositionRequest>().collect { value ->
resetComposition()
}
}
LaunchedEffect(Unit) {
orchestration.asFlow().filterIsInstance<RetryFailedCompositionRequest>().collect {
resetComposition()
}
}
/* Agent */
val currentHotReloadState by hotReloadState.collectAsState()
val intercepted: @Composable () -> Unit = {
logger.debug("Composing UI: $currentHotReloadState")
runCatching {
when {
reloadEffectsEnabled -> ReloadEffects(child)
else -> child()
}
}.onFailure { exception ->
logger.error("Failed invoking 'JvmDevelopmentEntryPoint':", exception)
hotReloadState.update { state -> state.copy(uiError = exception) }
UIException(
windowId = windowId,
message = exception.message,
stacktrace = exception.stackTrace.toList()
).sendBlocking()
}.onSuccess {
hotReloadState.update { state -> state.copy(uiError = null) }
UIRendered(
windowId = windowId,
reloadRequestId = currentHotReloadState.reloadRequestId,
currentHotReloadState.iteration
).sendAsync()
}.getOrThrow()
}
CompositionLocalProvider(hotReloadStateLocal provides currentHotReloadState) {
key(currentHotReloadState.key) {
intercepted()
}
}
}