From 7db34776cc3b51bb4b59cf52e8cd4f5fab8cfd81 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Tue, 9 Jul 2024 19:30:30 -0400 Subject: [PATCH] Add Wasm JS as a common target (#2169) --- CHANGELOG.md | 2 +- .../redwood/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-protocol-guest.klib.api | 2 +- .../api/redwood-protocol-host.klib.api | 2 +- redwood-protocol/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 +- 21 files changed, 39 insertions(+), 19 deletions(-) create mode 100644 redwood-runtime/src/wasmJsMain/kotlin/app/cash/redwood/ui/density.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index a5a7143af6..4500566380 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ [Unreleased]: https://github.com/cashapp/redwood/compare/0.12.0...HEAD New: -- Nothing yet! +- Wasm JS added as a target for common Redwood modules. There is no Treehouse support today. Changed: - The `TreehouseApp` type is now an abstract class. This should make it easier to write unit tests for code that integrates Treehouse. 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 4b525f3669..529574ae5d 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 @@ -301,6 +301,7 @@ 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") @@ -312,6 +313,7 @@ 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 54650daccb..6a7021400d 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 58162e1229..afc878af94 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 08d99fd5d7..14614b48c7 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 6abacfeb67..deb13e07fc 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 0bef5949c8..22acaaa2fb 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 2a24781227..d016656f36 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 ebc4890077..94e7810b93 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 9bc991ec52..d29619e0b8 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 cd0c56b963..bb3889ec03 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 1cd63198c7..7f350c9a49 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true diff --git a/redwood-protocol-guest/api/redwood-protocol-guest.klib.api b/redwood-protocol-guest/api/redwood-protocol-guest.klib.api index 38939bb436..7d559c09da 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 96c18ae145..327e90bef7 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 9caf13558c..f44fa18db3 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 e479e27375..90d03a02f4 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 new file mode 100644 index 0000000000..4d3a7460d3 --- /dev/null +++ b/redwood-runtime/src/wasmJsMain/kotlin/app/cash/redwood/ui/density.kt @@ -0,0 +1,18 @@ +/* + * 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 6871c1def2..59d10afb37 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 d6bde99cb8..55b6bcb0d5 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 7c7c38a184..7b2326ccc7 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // 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 ce12f8e6b8..6d65845e96 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] +// Targets: [iosArm64, iosSimulatorArm64, iosX64, js, wasmJs] // Alias: ios => [iosArm64, iosSimulatorArm64, iosX64] // Rendering settings: // - Signature version: 2