From bcf2d73a850bfa90605fe9fefba0511b180b227c Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Tue, 24 Sep 2024 14:01:23 -0400 Subject: [PATCH] Remove Wasm... again (#2317) There is no rush, and it is in my way right now. --- CHANGELOG.md | 2 +- .../buildsupport/RedwoodBuildPlugin.kt | 2 - redwood-compose/api/redwood-compose.klib.api | 2 +- .../api/redwood-layout-api.klib.api | 2 +- .../api/redwood-layout-compose.klib.api | 2 +- .../api/redwood-layout-modifiers.klib.api | 2 +- .../api/redwood-layout-testing.klib.api | 2 +- .../api/redwood-layout-widget.klib.api | 2 +- .../api/redwood-lazylayout-api.klib.api | 2 +- .../api/redwood-lazylayout-compose.klib.api | 2 +- .../api/redwood-lazylayout-testing.klib.api | 2 +- .../api/redwood-lazylayout-widget.klib.api | 2 +- .../api/redwood-leak-detector.klib.api | 2 +- redwood-leak-detector/build.gradle | 12 ------ .../kotlin/app/cash/redwood/leaks/Gc.kt | 36 ------------------ .../app/cash/redwood/leaks/WeakReference.kt | 37 ------------------- .../app/cash/redwood/leaks/delayForGc.kt | 28 -------------- .../api/redwood-protocol-guest.klib.api | 2 +- .../api/redwood-protocol-host.klib.api | 2 +- .../api/redwood-protocol.klib.api | 2 +- redwood-runtime/api/redwood-runtime.klib.api | 2 +- .../kotlin/app/cash/redwood/ui/density.kt | 18 --------- redwood-testing/api/redwood-testing.klib.api | 2 +- .../api/redwood-widget-compose.klib.api | 2 +- .../api/redwood-widget-testing.klib.api | 2 +- redwood-widget/api/redwood-widget.klib.api | 2 +- 26 files changed, 20 insertions(+), 153 deletions(-) delete mode 100644 redwood-leak-detector/src/wasmJsMain/kotlin/app/cash/redwood/leaks/Gc.kt delete mode 100644 redwood-leak-detector/src/wasmJsMain/kotlin/app/cash/redwood/leaks/WeakReference.kt delete mode 100644 redwood-leak-detector/src/wasmJsTest/kotlin/app/cash/redwood/leaks/delayForGc.kt delete mode 100644 redwood-runtime/src/wasmJsMain/kotlin/app/cash/redwood/ui/density.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 93a043d0fc..e70f18dd13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ New: - `ResizableWidget` is an interface that `UIView` widgets must use if their intrinsic sizes may change dynamically. It notifies any enclosing parent views to trigger a new layout. Changed: -- Nothing yet! +- Removed Wasm JS target. We are not ready to support it yet. Fixed: - Breaking the last remaining retain cycle in `UIViewLazyList`. diff --git a/build-support/src/main/kotlin/app/cash/redwood/buildsupport/RedwoodBuildPlugin.kt b/build-support/src/main/kotlin/app/cash/redwood/buildsupport/RedwoodBuildPlugin.kt index 085554c5d5..0e294876b7 100644 --- a/build-support/src/main/kotlin/app/cash/redwood/buildsupport/RedwoodBuildPlugin.kt +++ b/build-support/src/main/kotlin/app/cash/redwood/buildsupport/RedwoodBuildPlugin.kt @@ -310,7 +310,6 @@ private class RedwoodBuildExtensionImpl(private val project: Project) : RedwoodB iosTargets() modifiedGroup[JsTests, NodeJs].applyTo(js()) jvm() - wasmJs().nodejs() } // Needed for lint in downstream Android projects to analyze this dependency. project.plugins.apply("com.android.lint") @@ -322,7 +321,6 @@ private class RedwoodBuildExtensionImpl(private val project: Project) : RedwoodB iosTargets() modifiedGroup[JsTests, NodeJs].applyTo(js()) jvm() - wasmJs().nodejs() } } Tooling -> { diff --git a/redwood-compose/api/redwood-compose.klib.api b/redwood-compose/api/redwood-compose.klib.api index 4c67089be0..4d0dcfd0e5 100644 --- a/redwood-compose/api/redwood-compose.klib.api +++ b/redwood-compose/api/redwood-compose.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Alias: ios => [iosArm64, iosSimulatorArm64, iosX64] // Rendering settings: // - Signature version: 2 diff --git a/redwood-layout-api/api/redwood-layout-api.klib.api b/redwood-layout-api/api/redwood-layout-api.klib.api index 610e2f7821..ef1c04de2d 100644 --- a/redwood-layout-api/api/redwood-layout-api.klib.api +++ b/redwood-layout-api/api/redwood-layout-api.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-layout-compose/api/redwood-layout-compose.klib.api b/redwood-layout-compose/api/redwood-layout-compose.klib.api index 6928b9cda4..50e7bec190 100644 --- a/redwood-layout-compose/api/redwood-layout-compose.klib.api +++ b/redwood-layout-compose/api/redwood-layout-compose.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-layout-modifiers/api/redwood-layout-modifiers.klib.api b/redwood-layout-modifiers/api/redwood-layout-modifiers.klib.api index deb13e07fc..6abacfeb67 100644 --- a/redwood-layout-modifiers/api/redwood-layout-modifiers.klib.api +++ b/redwood-layout-modifiers/api/redwood-layout-modifiers.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-layout-testing/api/redwood-layout-testing.klib.api b/redwood-layout-testing/api/redwood-layout-testing.klib.api index 19b0f256b0..dd0a895ad9 100644 --- a/redwood-layout-testing/api/redwood-layout-testing.klib.api +++ b/redwood-layout-testing/api/redwood-layout-testing.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-layout-widget/api/redwood-layout-widget.klib.api b/redwood-layout-widget/api/redwood-layout-widget.klib.api index 8075c41f4a..a4bb9dd083 100644 --- a/redwood-layout-widget/api/redwood-layout-widget.klib.api +++ b/redwood-layout-widget/api/redwood-layout-widget.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-lazylayout-api/api/redwood-lazylayout-api.klib.api b/redwood-lazylayout-api/api/redwood-lazylayout-api.klib.api index 10be941aea..da302e7823 100644 --- a/redwood-lazylayout-api/api/redwood-lazylayout-api.klib.api +++ b/redwood-lazylayout-api/api/redwood-lazylayout-api.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-lazylayout-compose/api/redwood-lazylayout-compose.klib.api b/redwood-lazylayout-compose/api/redwood-lazylayout-compose.klib.api index 60ff61cbdc..2c45d04c1c 100644 --- a/redwood-lazylayout-compose/api/redwood-lazylayout-compose.klib.api +++ b/redwood-lazylayout-compose/api/redwood-lazylayout-compose.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-lazylayout-testing/api/redwood-lazylayout-testing.klib.api b/redwood-lazylayout-testing/api/redwood-lazylayout-testing.klib.api index f8ee083570..f739bfa54c 100644 --- a/redwood-lazylayout-testing/api/redwood-lazylayout-testing.klib.api +++ b/redwood-lazylayout-testing/api/redwood-lazylayout-testing.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-lazylayout-widget/api/redwood-lazylayout-widget.klib.api b/redwood-lazylayout-widget/api/redwood-lazylayout-widget.klib.api index b44652151b..b851c4017a 100644 --- a/redwood-lazylayout-widget/api/redwood-lazylayout-widget.klib.api +++ b/redwood-lazylayout-widget/api/redwood-lazylayout-widget.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-leak-detector/api/redwood-leak-detector.klib.api b/redwood-leak-detector/api/redwood-leak-detector.klib.api index 6254f086d0..8ad3ad745e 100644 --- a/redwood-leak-detector/api/redwood-leak-detector.klib.api +++ b/redwood-leak-detector/api/redwood-leak-detector.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-leak-detector/build.gradle b/redwood-leak-detector/build.gradle index 2a0ce94910..ce9a36f01e 100644 --- a/redwood-leak-detector/build.gradle +++ b/redwood-leak-detector/build.gradle @@ -18,18 +18,6 @@ kotlin { } } } - wasmJs { - nodejs { - testTask { - useMocha { - // We use up to 10s of wall clock time to test leaks. - timeout = '15s' - // Required for access to V8 GC function. - nodeJsArgs.add('--expose-gc') - } - } - } - } sourceSets { commonMain { diff --git a/redwood-leak-detector/src/wasmJsMain/kotlin/app/cash/redwood/leaks/Gc.kt b/redwood-leak-detector/src/wasmJsMain/kotlin/app/cash/redwood/leaks/Gc.kt deleted file mode 100644 index 678760833e..0000000000 --- a/redwood-leak-detector/src/wasmJsMain/kotlin/app/cash/redwood/leaks/Gc.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2024 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 - * - * http://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 app.cash.redwood.leaks - -private external val globalThis: GlobalThis - -private external class GlobalThis { - fun hasOwnProperty(name: String): Boolean - fun gc() -} - -internal actual fun detectGc(): Gc { - if (globalThis.hasOwnProperty("gc")) { - return GlobalThisGc() - } - return Gc.None -} - -private class GlobalThisGc : Gc { - override suspend fun collect() { - globalThis.gc() - } -} diff --git a/redwood-leak-detector/src/wasmJsMain/kotlin/app/cash/redwood/leaks/WeakReference.kt b/redwood-leak-detector/src/wasmJsMain/kotlin/app/cash/redwood/leaks/WeakReference.kt deleted file mode 100644 index c4e6bf2fb2..0000000000 --- a/redwood-leak-detector/src/wasmJsMain/kotlin/app/cash/redwood/leaks/WeakReference.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2024 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 - * - * http://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. - */ -@file:Suppress("NOTHING_TO_INLINE") - -package app.cash.redwood.leaks - -internal actual inline fun hasWeakReference(): Boolean { - return true -} - -internal actual class WeakReference -private constructor( - private val real: WeakRef>, -) { - actual constructor(referred: T) : this(WeakRef(referred.toJsReference())) - - actual fun get(): T? { - return real.deref()?.get() - } -} - -private external class WeakRef(reference: T) { - fun deref(): T? -} diff --git a/redwood-leak-detector/src/wasmJsTest/kotlin/app/cash/redwood/leaks/delayForGc.kt b/redwood-leak-detector/src/wasmJsTest/kotlin/app/cash/redwood/leaks/delayForGc.kt deleted file mode 100644 index ff2742f3be..0000000000 --- a/redwood-leak-detector/src/wasmJsTest/kotlin/app/cash/redwood/leaks/delayForGc.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2024 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 - * - * http://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 app.cash.redwood.leaks - -import kotlin.time.Duration -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.delay -import kotlinx.coroutines.withContext - -internal actual suspend fun delayForGc(duration: Duration) { - // Force a wall clock delay for JS Gc. - withContext(Dispatchers.Default) { - delay(duration) - } -} diff --git a/redwood-protocol-guest/api/redwood-protocol-guest.klib.api b/redwood-protocol-guest/api/redwood-protocol-guest.klib.api index 257fa3136f..639566f456 100644 --- a/redwood-protocol-guest/api/redwood-protocol-guest.klib.api +++ b/redwood-protocol-guest/api/redwood-protocol-guest.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-protocol-host/api/redwood-protocol-host.klib.api b/redwood-protocol-host/api/redwood-protocol-host.klib.api index 080892a31f..b373982e90 100644 --- a/redwood-protocol-host/api/redwood-protocol-host.klib.api +++ b/redwood-protocol-host/api/redwood-protocol-host.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-protocol/api/redwood-protocol.klib.api b/redwood-protocol/api/redwood-protocol.klib.api index f44fa18db3..9caf13558c 100644 --- a/redwood-protocol/api/redwood-protocol.klib.api +++ b/redwood-protocol/api/redwood-protocol.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-runtime/api/redwood-runtime.klib.api b/redwood-runtime/api/redwood-runtime.klib.api index 86007f79e6..e518000307 100644 --- a/redwood-runtime/api/redwood-runtime.klib.api +++ b/redwood-runtime/api/redwood-runtime.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Alias: ios => [iosArm64, iosSimulatorArm64, iosX64] // Rendering settings: // - Signature version: 2 diff --git a/redwood-runtime/src/wasmJsMain/kotlin/app/cash/redwood/ui/density.kt b/redwood-runtime/src/wasmJsMain/kotlin/app/cash/redwood/ui/density.kt deleted file mode 100644 index 4d3a7460d3..0000000000 --- a/redwood-runtime/src/wasmJsMain/kotlin/app/cash/redwood/ui/density.kt +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (C) 2023 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 - * - * http://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 app.cash.redwood.ui - -internal actual const val DENSITY_MULTIPLIER = 1.0 diff --git a/redwood-testing/api/redwood-testing.klib.api b/redwood-testing/api/redwood-testing.klib.api index 4167d6ef5d..2e1192c468 100644 --- a/redwood-testing/api/redwood-testing.klib.api +++ b/redwood-testing/api/redwood-testing.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-widget-compose/api/redwood-widget-compose.klib.api b/redwood-widget-compose/api/redwood-widget-compose.klib.api index 28a2a46c1d..1325c3a8a5 100644 --- a/redwood-widget-compose/api/redwood-widget-compose.klib.api +++ b/redwood-widget-compose/api/redwood-widget-compose.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-widget-testing/api/redwood-widget-testing.klib.api b/redwood-widget-testing/api/redwood-widget-testing.klib.api index 7b2326ccc7..7c7c38a184 100644 --- a/redwood-widget-testing/api/redwood-widget-testing.klib.api +++ b/redwood-widget-testing/api/redwood-widget-testing.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-widget/api/redwood-widget.klib.api b/redwood-widget/api/redwood-widget.klib.api index a10f064d40..3c6403497a 100644 --- a/redwood-widget/api/redwood-widget.klib.api +++ b/redwood-widget/api/redwood-widget.klib.api @@ -1,5 +1,5 @@ // Klib ABI Dump -// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js] // Alias: ios => [iosArm64, iosSimulatorArm64, iosX64] // Rendering settings: // - Signature version: 2