diff --git a/build.gradle.kts b/build.gradle.kts index 384f5d5..1b68790 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("org.jetbrains.kotlin.js") version "1.3.70-eap-184" + id("org.jetbrains.kotlin.js") version "1.4.0" } group = "org.example" @@ -12,28 +12,33 @@ repositories { jcenter() } +kotlin { + js { + browser {} + binaries.executable() + } +} + dependencies { implementation(kotlin("stdlib-js")) //React, React DOM + Wrappers (chapter 3) - implementation("org.jetbrains:kotlin-react:16.9.0-pre.89-kotlin-1.3.60") - implementation("org.jetbrains:kotlin-react-dom:16.9.0-pre.89-kotlin-1.3.60") - implementation(npm("react", "16.12.0")) - implementation(npm("react-dom", "16.12.0")) + implementation("org.jetbrains:kotlin-react:16.13.1-pre.110-kotlin-1.4.0") + implementation("org.jetbrains:kotlin-react-dom:16.13.1-pre.110-kotlin-1.4.0") + implementation(npm("react", "16.13.1")) + implementation(npm("react-dom", "16.13.1")) //Kotlin Styled (chapter 3) - implementation("org.jetbrains:kotlin-styled:1.0.0-pre.90-kotlin-1.3.61") - implementation(npm("styled-components")) - implementation(npm("inline-style-prefixer")) + implementation("org.jetbrains:kotlin-styled:1.0.0-pre.110-kotlin-1.4.0") + implementation(npm("styled-components", "~5.1.1")) + implementation(npm("inline-style-prefixer", "~6.0.0")) //Video Player (chapter 7) - implementation(npm("react-player")) + implementation(npm("react-player", "~2.6.0")) //Share Buttons (chapter 7) - implementation(npm("react-share")) + implementation(npm("react-share", "~4.2.1")) //Coroutines (chapter 8) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.3") -} - -kotlin.target.browser { } \ No newline at end of file + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9") +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ba94df8..6c9a224 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/App.kt b/src/main/kotlin/App.kt new file mode 100644 index 0000000..ea4a30e --- /dev/null +++ b/src/main/kotlin/App.kt @@ -0,0 +1,96 @@ +import kotlinx.coroutines.async +import kotlinx.css.* +import react.* +import react.dom.* +import styled.css +import styled.styledDiv +import kotlinx.browser.window +import kotlinx.coroutines.* + +suspend fun fetchVideo(id: Int): Video = + window.fetch("https://my-json-server.typicode.com/kotlin-hands-on/kotlinconf-json/videos/$id") + .await() + .json() + .await() + .unsafeCast