Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CfW: Introduce webCommonW3C source set to fix metadata compilation while avoiding code duplication #1123

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions compose/animation/animation-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,3 @@ androidx {
android {
namespace "androidx.compose.animation.core"
}

project.tasks.configureEach {
if (name == "compileJsWasmMainKotlinMetadata") {
enabled = false
}
}
6 changes: 0 additions & 6 deletions compose/animation/animation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,3 @@ androidx {
android {
namespace "androidx.compose.animation"
}

project.tasks.configureEach {
if (name == "compileJsWasmMainKotlinMetadata") {
enabled = false
}
}
8 changes: 2 additions & 6 deletions compose/foundation/foundation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,12 @@ if (AndroidXComposePlugin.isMultiplatformEnabled(project)) {
jsWasmMain.dependsOn(jsNativeMain)

jsMain {
kotlin.srcDir("src/webCommonW3C/kotlin")
dependsOn(jsWasmMain)
}

wasmJsMain {
kotlin.srcDir("src/webCommonW3C/kotlin")
dependsOn(jsWasmMain)
}

Expand Down Expand Up @@ -244,9 +246,3 @@ androidx {
description = "Higher level abstractions of the Compose UI primitives. This library is design system agnostic, providing the high-level building blocks for both application and design-system developers"
legacyDisableKotlinStrictApiMode = true
}

project.tasks.configureEach {
if (name == "compileJsWasmMainKotlinMetadata") {
enabled = false
}
}
6 changes: 0 additions & 6 deletions compose/material/material-ripple/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,3 @@ androidx {
android {
namespace "androidx.compose.material.ripple"
}

project.tasks.configureEach {
if (name == "compileJsWasmMainKotlinMetadata") {
enabled = false
}
}
6 changes: 0 additions & 6 deletions compose/material/material/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,3 @@ android {
project.rootDir.absolutePath + "/golden/compose/material/material"
namespace "androidx.compose.material"
}

project.tasks.configureEach {
if (name == "compileJsWasmMainKotlinMetadata") {
enabled = false
}
}
12 changes: 5 additions & 7 deletions compose/material3/material3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ if(AndroidXComposePlugin.isMultiplatformEnabled(project)) {

nativeMain.dependsOn(jsNativeMain)
jsWasmMain.dependsOn(jsNativeMain)
jsMain.dependsOn(jsWasmMain)
jsMain {
kotlin.srcDir("src/webCommonW3C/kotlin")
dependsOn(jsWasmMain)
}
wasmJsMain {
kotlin.srcDir("src/webCommonW3C/kotlin")
dependsOn(jsWasmMain)
dependencies {
implementation(libs.kotlinStdlib)
Expand Down Expand Up @@ -220,9 +224,3 @@ android {
project.rootDir.absolutePath + "/golden/compose/material3/material3"
namespace "androidx.compose.material3"
}

project.tasks.configureEach {
if (name == "compileJsWasmMainKotlinMetadata") {
enabled = false
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Android Open Source Project
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
6 changes: 0 additions & 6 deletions compose/ui/ui-graphics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,3 @@ if(AndroidXComposePlugin.isMultiplatformEnabled(project)) {
systemProperties["GOLDEN_PATH"] = project.rootDir.absolutePath + "/golden"
}
}

project.tasks.configureEach {
if (name == "compileJsWasmMainKotlinMetadata") {
enabled = false
}
}
8 changes: 2 additions & 6 deletions compose/ui/ui-text/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ if(AndroidXComposePlugin.isMultiplatformEnabled(project)) {
jsWasmMain.dependsOn(jsNativeMain)

jsMain {
kotlin.srcDir("src/webCommonW3C/kotlin")
dependsOn(jsWasmMain)
}

wasmJsMain {
kotlin.srcDir("src/webCommonW3C/kotlin")
dependsOn(jsWasmMain)
dependencies {
implementation(libs.create("skikoWasm"))
Expand Down Expand Up @@ -251,12 +253,6 @@ android {
namespace "androidx.compose.ui.text"
}

project.tasks.configureEach {
if (name == "compileJsWasmMainKotlinMetadata") {
enabled = false
}
}

afterEvaluate {
tasks.withType(Test) { t ->
t.jvmArgs += ["--add-opens=java.desktop/sun.font=ALL-UNNAMED"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Android Open Source Project
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Android Open Source Project
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 The Android Open Source Project
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,6 @@
package androidx.compose.ui.text.platform

import androidx.compose.ui.text.PlatformStringDelegate
import androidx.compose.ui.text.intl.JsLocale
import androidx.compose.ui.text.intl.PlatformLocale

/**
Expand Down
8 changes: 2 additions & 6 deletions compose/ui/ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,15 @@ if(AndroidXComposePlugin.isMultiplatformEnabled(project)) {
macosMain.dependsOn(notMobileMain)

jsMain {
kotlin.srcDir("src/webCommonW3C/kotlin")
dependsOn(jsWasmMain)
dependencies {
api(libs.skikoCommon)
}
}

wasmJsMain {
kotlin.srcDir("src/webCommonW3C/kotlin")
dependsOn(jsWasmMain)
dependencies {
implementation(libs.kotlinStdlib)
Expand Down Expand Up @@ -388,9 +390,3 @@ if (!AndroidXComposePlugin.isMultiplatformEnabled(project)) {
verifyKotlinModule(variant)
}
}

project.tasks.configureEach {
if (name == "compileJsWasmMainKotlinMetadata") {
enabled = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package androidx.compose.ui.window
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.SystemTheme
import kotlinx.browser.window
import org.w3c.dom.MediaQueryList
import org.w3c.dom.Window
import org.w3c.dom.events.EventListener
Expand Down Expand Up @@ -71,5 +72,5 @@ internal class SystemThemeObserverImpl(window : Window) : SystemThemeObserver {
}
}

internal actual fun getSystemThemeObserver(window: Window): SystemThemeObserver =
internal actual fun getSystemThemeObserver(): SystemThemeObserver =
SystemThemeObserverImpl(window)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package androidx.compose.ui.window

import androidx.compose.runtime.State
import androidx.compose.ui.SystemTheme
import org.w3c.dom.Window


internal interface SystemThemeObserver {
Expand All @@ -27,4 +26,4 @@ internal interface SystemThemeObserver {
fun dispose()
}

internal expect fun getSystemThemeObserver(window: Window): SystemThemeObserver
internal expect fun getSystemThemeObserver(): SystemThemeObserver
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package androidx.compose.ui.window
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.SystemTheme
import kotlinx.browser.window
import org.w3c.dom.MediaQueryList
import org.w3c.dom.MediaQueryListEvent
import org.w3c.dom.Window
Expand Down Expand Up @@ -67,7 +68,7 @@ internal class SystemThemeObserverImpl(window : Window) : SystemThemeObserver {
}
}

internal actual fun getSystemThemeObserver(window: Window): SystemThemeObserver =
internal actual fun getSystemThemeObserver(): SystemThemeObserver =
SystemThemeObserverImpl(window)

// supported by all browsers since 2015
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 The Android Open Source Project
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Android Open Source Project
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -91,7 +91,7 @@ private class ComposeWindow(
platformContext = platformContext,
input = jsTextInputService.input
)
private val systemThemeObserver = getSystemThemeObserver(window)
private val systemThemeObserver = getSystemThemeObserver()

val canvas = document.getElementById(canvasId) as HTMLCanvasElement

Expand Down
Loading