-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
111 additions
and
37 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -54,5 +54,6 @@ gradleConventionsKmpDefaults { | |
KmpTarget.Ios, | ||
KmpTarget.Js, | ||
KmpTarget.Jvm, | ||
KmpTarget.WasmJs, | ||
) | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
6 changes: 6 additions & 0 deletions
6
...d/src/wasmJsMain/kotlin/com/eygraber/compose/colorpicker/sample/FixedDecimalCount.wasm.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,6 @@ | ||
package com.eygraber.compose.colorpicker.sample | ||
|
||
@JsFun("(f, d) => f.toFixed(d)") | ||
external fun toFixed(f: Float, d: Int): String | ||
|
||
actual fun Float.toFixedDecimalCount(digits: Int): String = toFixed(this, digits) |
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,46 @@ | ||
import com.eygraber.conventions.kotlin.kmp.wasmJsMain | ||
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl | ||
|
||
plugins { | ||
id("com.eygraber.conventions-kotlin-multiplatform") | ||
id("com.eygraber.conventions-detekt") | ||
id("com.eygraber.conventions-compose-jetbrains") | ||
} | ||
|
||
kotlin { | ||
kmpTargets( | ||
KmpTarget.WasmJs, | ||
project = project, | ||
binaryType = BinaryType.Executable, | ||
webOptions = KmpTarget.WebOptions( | ||
isNodeEnabled = false, | ||
isBrowserEnabled = true, | ||
moduleName = "color-picker-wasm", | ||
), | ||
ignoreDefaultTargets = true, | ||
) | ||
@OptIn(ExperimentalWasmDsl::class) | ||
wasmJs { | ||
browser { | ||
commonWebpackConfig { | ||
outputFileName = "color-picker-wasm.js" | ||
experiments += "topLevelAwait" | ||
} | ||
} | ||
} | ||
|
||
sourceSets { | ||
wasmJsMain { | ||
dependencies { | ||
implementation(compose.foundation) | ||
implementation(compose.material3) | ||
|
||
implementation(projects.sample.shared) | ||
} | ||
} | ||
} | ||
} | ||
|
||
compose.experimental { | ||
web.application {} | ||
} |
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 @@ | ||
potential-bugs: | ||
active: true | ||
MissingPackageDeclaration: | ||
active: false |
9 changes: 2 additions & 7 deletions
9
sample/js-app/src/jsMain/kotlin/main.js.kt → ...webApp/src/wasmJsMain/kotlin/main.wasm.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 |
---|---|---|
@@ -1,15 +1,10 @@ | ||
@file:Suppress("MissingPackageDeclaration") | ||
|
||
import androidx.compose.ui.ExperimentalComposeUiApi | ||
import androidx.compose.ui.window.CanvasBasedWindow | ||
import com.eygraber.compose.colorpicker.sample.Sample | ||
import org.jetbrains.skiko.wasm.onWasmReady | ||
|
||
@OptIn(ExperimentalComposeUiApi::class) | ||
fun main() { | ||
onWasmReady { | ||
CanvasBasedWindow("ColorPicker") { | ||
Sample() | ||
} | ||
CanvasBasedWindow("ColorPicker") { | ||
Sample() | ||
} | ||
} |
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,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
|
||
<title>Color Picker</title> | ||
<script type="application/javascript" src="/color-picker-wasm.js"></script> | ||
</head> | ||
<body> | ||
<canvas id="ComposeTarget"></canvas> | ||
</body> | ||
</html> |
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,14 @@ | ||
import { instantiate } from 'color-picker-wasm.uninstantiated.mjs'; | ||
|
||
await wasmSetup; | ||
|
||
let te = null; | ||
try { | ||
await instantiate({ skia: Module['asm'] }); | ||
} catch (e) { | ||
te = e; | ||
} | ||
|
||
if (te != null) { | ||
throw te; | ||
} |
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