From f7d21474e24920aed3831d354a194fca69ef44b2 Mon Sep 17 00:00:00 2001 From: Gaubee Date: Fri, 10 Jan 2025 20:33:53 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- next/kmp/app/androidApp/build.gradle.kts | 4 ++-- .../kotlin/org/dweb_browser/browser/scan/SmartScanNMM.kt | 2 +- next/kmp/buildSrc/src/main/kotlin/Multiplatform.kt | 2 +- .../kotlin/org/dweb_browser/core/std/http/HttpNMM.kt | 8 ++++---- .../org/dweb_browser/pure/http/ktor/KtorPureServer.kt | 5 ++--- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/next/kmp/app/androidApp/build.gradle.kts b/next/kmp/app/androidApp/build.gradle.kts index f769bb9cb..8162c9f91 100644 --- a/next/kmp/app/androidApp/build.gradle.kts +++ b/next/kmp/app/androidApp/build.gradle.kts @@ -142,8 +142,8 @@ android { // signingConfig = signingConfigs.getByName("debug") // 如果是测试benchmark需要使用debug signingConfig = signingConfigs.getByName("release") isMinifyEnabled = true // 开启代码混淆 - // setProguardFiles(listOf("proguard-rules.pro")) - setProguardFiles(emptyList()) + setProguardFiles(listOf("proguard-rules.pro")) + // setProguardFiles(emptyList()) isShrinkResources = true // 移除无用的resource configChannel(buildChannel, this) manifestPlaceholders["isTestOnly"] = "false" diff --git a/next/kmp/browser/src/commonMain/kotlin/org/dweb_browser/browser/scan/SmartScanNMM.kt b/next/kmp/browser/src/commonMain/kotlin/org/dweb_browser/browser/scan/SmartScanNMM.kt index 2af60e8de..bc5ac0fa9 100644 --- a/next/kmp/browser/src/commonMain/kotlin/org/dweb_browser/browser/scan/SmartScanNMM.kt +++ b/next/kmp/browser/src/commonMain/kotlin/org/dweb_browser/browser/scan/SmartScanNMM.kt @@ -1,7 +1,7 @@ package org.dweb_browser.browser.scan import io.ktor.http.HttpStatusCode -import io.ktor.utils.io.CancellationException +import kotlinx.coroutines.CancellationException import org.dweb_browser.browser.BrowserI18nResource import org.dweb_browser.core.help.types.DwebPermission import org.dweb_browser.core.help.types.MICRO_MODULE_CATEGORY diff --git a/next/kmp/buildSrc/src/main/kotlin/Multiplatform.kt b/next/kmp/buildSrc/src/main/kotlin/Multiplatform.kt index 67a4cd921..c86e24d26 100644 --- a/next/kmp/buildSrc/src/main/kotlin/Multiplatform.kt +++ b/next/kmp/buildSrc/src/main/kotlin/Multiplatform.kt @@ -40,7 +40,7 @@ fun KotlinCompilation<*>.configureCompilation() { freeCompilerArgs.addAll( "-Xexpect-actual-classes", "-Xcontext-receivers", - "-XXLanguage:+ExplicitBackingFields", + // "-XXLanguage:+ExplicitBackingFields", ) } } diff --git a/next/kmp/core/src/commonMain/kotlin/org/dweb_browser/core/std/http/HttpNMM.kt b/next/kmp/core/src/commonMain/kotlin/org/dweb_browser/core/std/http/HttpNMM.kt index 804916fec..eb3a7416d 100644 --- a/next/kmp/core/src/commonMain/kotlin/org/dweb_browser/core/std/http/HttpNMM.kt +++ b/next/kmp/core/src/commonMain/kotlin/org/dweb_browser/core/std/http/HttpNMM.kt @@ -7,7 +7,7 @@ import io.ktor.http.Url import io.ktor.http.hostWithPort import io.ktor.http.protocolWithAuthority import io.ktor.util.decodeBase64String -import io.ktor.utils.io.CancellationException +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.launch import kotlinx.serialization.json.Json import org.dweb_browser.core.help.types.MICRO_MODULE_CATEGORY @@ -638,9 +638,9 @@ class HttpNMM : NativeMicroModule("http.std.dweb", "HTTP Server Provider") { val x_dweb_host = query_x_dweb_host ?: header_auth_host ?: header_x_dweb_host ?: header_host return x_dweb_host?.let { host -> val isWs = request.isWebSocket - val protocol = when (is_https) { - true -> if (isWs) URLProtocol.WSS else URLProtocol.HTTPS - false -> if (isWs) URLProtocol.WS else URLProtocol.HTTP + val protocol = when { + is_https -> if (isWs) URLProtocol.WSS else URLProtocol.HTTPS + else -> if (isWs) URLProtocol.WS else URLProtocol.HTTP } DwebGatewayInfo(host, protocol) } diff --git a/next/kmp/pureHttp/src/ktorMain/kotlin/org/dweb_browser/pure/http/ktor/KtorPureServer.kt b/next/kmp/pureHttp/src/ktorMain/kotlin/org/dweb_browser/pure/http/ktor/KtorPureServer.kt index 25a79ffb0..a4db5cac3 100644 --- a/next/kmp/pureHttp/src/ktorMain/kotlin/org/dweb_browser/pure/http/ktor/KtorPureServer.kt +++ b/next/kmp/pureHttp/src/ktorMain/kotlin/org/dweb_browser/pure/http/ktor/KtorPureServer.kt @@ -15,9 +15,9 @@ import io.ktor.server.response.respond import io.ktor.server.websocket.WebSocketUpgrade import io.ktor.server.websocket.WebSockets import io.ktor.util.logging.KtorSimpleLogger -import io.ktor.utils.io.CancellationException import io.ktor.websocket.Frame import io.ktor.websocket.close +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.channels.Channel @@ -133,8 +133,7 @@ open class KtorPureServer ApplicationEngine) = - serverLock.withLock { + protected suspend inline fun startServer(createServer: () -> ApplicationEngine) = serverLock.withLock { val engine = when (val engine = serverEngine) { null -> { createServer().also { newEngine ->