diff --git a/wire-grpc-client/build.gradle.kts b/wire-grpc-client/build.gradle.kts index 9fdccca4fc..2b5428ba25 100644 --- a/wire-grpc-client/build.gradle.kts +++ b/wire-grpc-client/build.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl import org.jetbrains.kotlin.gradle.dsl.JsModuleKind import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile @@ -36,6 +37,16 @@ kotlin { tvosArm64() tvosSimulatorArm64() } + if (System.getProperty("kwasm", "true").toBoolean()) { + @OptIn(ExperimentalWasmDsl::class) + wasmJs { + browser() + } + @OptIn(ExperimentalWasmDsl::class) + wasmWasi { + nodejs() + } + } sourceSets { val commonMain by getting { dependencies { @@ -49,6 +60,27 @@ kotlin { api(libs.okhttp.core) } } + val nonJvmMain by creating { + dependsOn(commonMain) + } + if (System.getProperty("knative", "true").toBoolean()) { + val nativeMain by getting { + dependsOn(nonJvmMain) + } + } + if (System.getProperty("kjs", "true").toBoolean()) { + val jsMain by getting { + dependsOn(nonJvmMain) + } + } + if (System.getProperty("kwasm", "true").toBoolean()) { + val wasmJsMain by getting { + dependsOn(nonJvmMain) + } + val wasmWasiMain by getting { + dependsOn(nonJvmMain) + } + } } } diff --git a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcClient.kt b/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcClient.kt deleted file mode 100644 index bc41e15e54..0000000000 --- a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcClient.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2020 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.squareup.wire - -actual abstract class GrpcClient { - actual abstract fun newCall(method: GrpcMethod): GrpcCall - actual abstract fun newStreamingCall(method: GrpcMethod): GrpcStreamingCall - actual abstract fun newClientStreamingCall(method: GrpcMethod): GrpcClientStreamingCall - actual abstract fun newServerStreamingCall(method: GrpcMethod): GrpcServerStreamingCall -} diff --git a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcHeaders.kt b/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcHeaders.kt deleted file mode 100644 index b31a389465..0000000000 --- a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcHeaders.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2020 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.squareup.wire - -actual class GrpcHeaders { - actual operator fun get(name: String): String? = TODO() -} diff --git a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcHttpUrl.kt b/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcHttpUrl.kt deleted file mode 100644 index 69714cbf4d..0000000000 --- a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcHttpUrl.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2020 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.squareup.wire - -actual class GrpcHttpUrl { - actual fun resolve(link: String): GrpcHttpUrl? = TODO("Not yet implemented") -} - -actual fun String.toHttpUrl(): GrpcHttpUrl = TODO("Not yet implemented") diff --git a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcRequest.kt b/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcRequest.kt deleted file mode 100644 index fba5417072..0000000000 --- a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcRequest.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2020 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.squareup.wire - -actual class GrpcRequest - -actual open class GrpcRequestBuilder { - actual open fun url(url: GrpcHttpUrl): GrpcRequestBuilder = TODO("Not yet implemented") - actual open fun addHeader( - name: String, - value: String, - ): GrpcRequestBuilder = TODO("Not yet implemented") - actual open fun method( - method: String, - body: GrpcRequestBody?, - ): GrpcRequestBuilder = TODO("Not yet implemented") - actual open fun build(): GrpcRequest = TODO("Not yet implemented") -} diff --git a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcRequestBody.kt b/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcRequestBody.kt deleted file mode 100644 index 64a54e1288..0000000000 --- a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcRequestBody.kt +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (C) 2020 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.squareup.wire - -actual abstract class GrpcRequestBody diff --git a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcResponse.kt b/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcResponse.kt deleted file mode 100644 index 97da212f6c..0000000000 --- a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcResponse.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2020 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.squareup.wire - -internal actual class GrpcResponse { - actual val body: GrpcResponseBody? - get() = TODO("Not yet implemented") - - actual fun header( - name: String, - defaultValue: String?, - ): String? { - TODO("Not yet implemented") - } - - actual fun trailers(): GrpcHeaders = TODO("Not yet implemented") - - actual fun close() { - TODO("Not yet implemented") - } -} diff --git a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcResponseBody.kt b/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcResponseBody.kt deleted file mode 100644 index f46dc85c8b..0000000000 --- a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/GrpcResponseBody.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2020 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.squareup.wire - -import okio.BufferedSource - -actual abstract class GrpcResponseBody { - actual abstract fun source(): BufferedSource -} diff --git a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/internal/platform.kt b/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/internal/platform.kt deleted file mode 100644 index baf541f30c..0000000000 --- a/wire-grpc-client/src/nativeMain/kotlin/com/squareup/wire/internal/platform.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2020 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.squareup.wire.internal - -import com.squareup.wire.GrpcResponse -import okio.Sink -import okio.Source - -internal actual interface Call { - actual fun cancel() - actual fun execute(): GrpcResponse -} - -internal actual fun Sink.asGzip(): Sink = throw UnsupportedOperationException("Gzip not implemented for native") - -internal actual fun Source.asGzip(): Source = throw UnsupportedOperationException("Gzip not implemented for native") - -internal actual fun Throwable.addSuppressed(other: Throwable) { -} diff --git a/wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcClient.kt b/wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcClient.kt similarity index 100% rename from wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcClient.kt rename to wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcClient.kt diff --git a/wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcHeaders.kt b/wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcHeaders.kt similarity index 100% rename from wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcHeaders.kt rename to wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcHeaders.kt diff --git a/wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcHttpUrl.kt b/wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcHttpUrl.kt similarity index 100% rename from wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcHttpUrl.kt rename to wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcHttpUrl.kt diff --git a/wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcRequest.kt b/wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcRequest.kt similarity index 100% rename from wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcRequest.kt rename to wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcRequest.kt diff --git a/wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcRequestBody.kt b/wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcRequestBody.kt similarity index 100% rename from wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcRequestBody.kt rename to wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcRequestBody.kt diff --git a/wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcResponse.kt b/wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcResponse.kt similarity index 100% rename from wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcResponse.kt rename to wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcResponse.kt diff --git a/wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcResponseBody.kt b/wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcResponseBody.kt similarity index 100% rename from wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/GrpcResponseBody.kt rename to wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/GrpcResponseBody.kt diff --git a/wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/internal/platform.kt b/wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/internal/platform.kt similarity index 89% rename from wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/internal/platform.kt rename to wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/internal/platform.kt index 287c698521..a07fd13153 100644 --- a/wire-grpc-client/src/jsMain/kotlin/com/squareup/wire/internal/platform.kt +++ b/wire-grpc-client/src/nonJvmMain/kotlin/com/squareup/wire/internal/platform.kt @@ -24,9 +24,9 @@ internal actual interface Call { actual fun execute(): GrpcResponse } -internal actual fun Sink.asGzip(): Sink = throw UnsupportedOperationException("Gzip not implemented for JS") +internal actual fun Sink.asGzip(): Sink = throw UnsupportedOperationException("Gzip not implemented for this platform") -internal actual fun Source.asGzip(): Source = throw UnsupportedOperationException("Gzip not implemented for JS") +internal actual fun Source.asGzip(): Source = throw UnsupportedOperationException("Gzip not implemented for this platform") internal actual fun Throwable.addSuppressed(other: Throwable) { }