Skip to content

Commit 6ed0f6a

Browse files
committed
feat:Release Version 1.4.0
1 parent 70440c5 commit 6ed0f6a

File tree

3 files changed

+45
-10
lines changed

3 files changed

+45
-10
lines changed

README.desktop.md

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,23 @@ This can (should) be called in the app init process and only needs to be called
99
LaunchedEffect(Unit) {
1010
Cef.init(builder = {
1111
installDir = File("jcef-bundle")
12-
})
12+
},{})
1313
}
1414
```
15+
1516
Then, run your app once and it will download the JCEF Bundle to the install directory.
1617
After that, just restart your app and it will work properly.
1718

19+
## Disposal
20+
When the app is closing, you need to dispose of the CEF Module.
21+
```kotlin
22+
DisposableEffect(Unit) {
23+
onDispose {
24+
Cef.dispose()
25+
}
26+
}
27+
```
28+
1829
> **Note**
1930
> Make sure to exclude the `installDir` from upstreaming by adding it to the `.gitignore`.
2031
> The downloaded files are platform-specific and therefore differ to each user.
@@ -24,21 +35,45 @@ Please use the following example as a reference.
2435
fun main() = application {
2536
Window(onCloseRequest = ::exitApplication) {
2637
var restartRequired by remember { mutableStateOf(false) }
38+
var downloading by remember { mutableStateOf(0F) }
39+
var initialized by remember { mutableStateOf(false) }
2740

2841
LaunchedEffect(Unit) {
29-
Cef.init(builder = {
30-
installDir = File("jcef-bundle")
31-
}, onError = {
32-
it.printStackTrace()
33-
}) {
34-
restartRequired = true
42+
withContext(Dispatchers.IO) {
43+
Cef.init(builder = {
44+
installDir = File("jcef-bundle")
45+
settings {
46+
cachePath = File("cache").absolutePath
47+
}
48+
}, initProgress = {
49+
onDownloading {
50+
downloading = max(it, 0F)
51+
}
52+
onInitialized {
53+
initialized = true
54+
}
55+
}, onError = {
56+
it.printStackTrace()
57+
}, onRestartRequired = {
58+
restartRequired = true
59+
})
3560
}
3661
}
3762

3863
if (restartRequired) {
3964
Text(text = "Restart required.")
4065
} else {
41-
MainWebView()
66+
if (initialized) {
67+
MainWebView()
68+
} else {
69+
Text(text = "Downloading $downloading%")
70+
}
71+
}
72+
73+
DisposableEffect(Unit) {
74+
onDispose {
75+
Cef.dispose()
76+
}
4277
}
4378
}
4479
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ kotlin {
382382
commonMain {
383383
dependencies {
384384
// use api since the desktop app need to access the Cef to initialize it.
385-
api("io.github.kevinnzou:compose-webview-multiplatform:1.3.0")
385+
api("io.github.kevinnzou:compose-webview-multiplatform:1.4.0")
386386
}
387387
}
388388
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ compose.version=1.5.1
2525

2626
GROUP_ID=io.github.kevinnzou
2727
ARTIFACT_ID=compose-webview-multiplatform
28-
VERSION_NAME=1.3.0
28+
VERSION_NAME=1.4.0
2929

3030

3131
POM_DESCRIPTION=WebView for JetBrains Compose Multiplatform

0 commit comments

Comments
 (0)