-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web: update compiler plugin test cases to make them runnable (#1447)
Co-authored-by: Oleksandr Karpovich <[email protected]>
- Loading branch information
Showing
7 changed files
with
82 additions
and
31 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
web/compose-compiler-integration/main-template/src/commonMain/kotlin/Expect.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.Composition | ||
|
||
expect fun callComposable(content: @Composable () -> Unit) |
33 changes: 33 additions & 0 deletions
33
web/compose-compiler-integration/main-template/src/jsMain/kotlin/Deps.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import androidx.compose.runtime.* | ||
import kotlinx.coroutines.* | ||
|
||
class UnitApplier : Applier<Unit> { | ||
override val current: Unit | ||
get() = Unit | ||
|
||
override fun down(node: Unit) {} | ||
override fun up() {} | ||
override fun insertTopDown(index: Int, instance: Unit) {} | ||
override fun insertBottomUp(index: Int, instance: Unit) {} | ||
override fun remove(index: Int, count: Int) {} | ||
override fun move(from: Int, to: Int, count: Int) {} | ||
override fun clear() {} | ||
} | ||
|
||
fun createRecomposer(): Recomposer { | ||
val mainScope = CoroutineScope( | ||
NonCancellable + Dispatchers.Main + DefaultMonotonicFrameClock | ||
) | ||
|
||
return Recomposer(mainScope.coroutineContext).also { | ||
mainScope.launch(start = CoroutineStart.UNDISPATCHED) { | ||
it.runRecomposeAndApplyChanges() | ||
} | ||
} | ||
} | ||
|
||
|
||
actual fun callComposable(content: @Composable () -> Unit) { | ||
val c = ControlledComposition(UnitApplier(), createRecomposer()) | ||
c.setContent(content) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters