269 questions
0
votes
0
answers
58
views
Why can't I use @JsExport in commonMain? Workaround with expect/actual seems to work fine
So I'm working on a Kotlin Multiplatform project and ran into this weird limitation - you can't use @JsExport in commonMain, only in jsMain. This seems really counterintuitive since the whole point of ...
0
votes
1
answer
38
views
How do you set a string resource to document.title in Kotlin/Wasm?
I'm trying to set a string resource to the document title (browser tab title).
I've tried wrapping the call in a coroutine and LaunchEffect but neither works.
@OptIn(ExperimentalComposeUiApi::class)
...
0
votes
1
answer
57
views
Kotlin/JS app doesn't terminate after library usage
I'm currently working on a Kotlin multi-platform project also targeting NodeJs.
Building and executing tests of the project with Gradle so far worked well and without problems.
Lately I tried to use ...
0
votes
0
answers
292
views
sqldelight isn't generate the database with Compose Multiplatform with JS compiler
I have a proyect with compose multiplatform using sqldelight to manage the data base, Ios and Android are working fine but the JS web, execute fine but the database isn't init with the configured ...
1
vote
1
answer
724
views
Koin: inject object returned by suspend function
I have object which created by suspend function like:
suspend fun someSuspendFunction(): MyPreciousObject
And I need to provide it for later injection using koin, like:
val myModule = module {
...
2
votes
0
answers
470
views
Unresolved reference: multiplatformResources in Kotlin Multiplatform Project using MOKO Resources
`I am working on a Kotlin Multiplatform project and trying to integrate MOKO Resources. I followed the installation instructions according to the official documentation, but I'm encountering an "...
1
vote
0
answers
978
views
Kotlin Multiplatform: composeApp:wasmJsMain: Could not resolve org.jetbrains.compose.html:html-core:1.6.11
I am trying to include the following dependency (org.jetbrains.compose.html:html-core:1.6.11) into my build.gradle.kts file under composeMain so i can use the Video Composable to load a video on my ...
1
vote
0
answers
255
views
How to handle suspend functions in Kotlin Multiplatform targeting JS?
We are developing a Kotlin Multiplatform SDK that uses Ktor as the network client to handle all network calls and authentication. This SDK is intended for use across Android, iOS, and web applications....
0
votes
1
answer
432
views
how can I use ui jetpack compose in an existing web project?
I have a set of ui components using jetpack compose. I want to use them in an existing web project.
How can i do this?
Is it possible to configure a kmp project for a wasm target and make it a library ...
0
votes
1
answer
198
views
How to create a Kotlin Map from Javascript?
I have a Kotlin Multiplatform method that takes a Map as an argument. How can I call it from JavaScript?
I have seen utility functions to create a Set or List from JavaScript but cannot figure out how ...
0
votes
1
answer
69
views
How to create an anchor in Jetpack Compose Web?
How to create the equivalent compose code for an HTML anchor tag?
HTML code
<a href="https://www.w3schools.com">Visit W3Schools.com!</a>
0
votes
1
answer
893
views
How to do synchonous HTTP requests using ktor-client-js version 2.x (without lots of boilerplate code)
import io.ktor.client.request.*
...
val response: HttpResponse = client.get("https://example.com/version")
The code above uses ktor-client-js and the get and does asynchronous HTTP requests....
1
vote
0
answers
4k
views
Include external ES modules in the bundle
I'm getting an error when running esbuild complaining:
You can mark the path "hiom" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in ...
0
votes
0
answers
167
views
How to use JS/React Libraries with Kotlin/JS?
I’m exploring Kotlin/JS at the moment and still very new to it.
Currently I’m exploring React with Kotlin/JS. I’m wondering if there are any step by step guide on how I could use and integrate ...
0
votes
1
answer
155
views
how to initialize style in i html element in kotlin/js?
val Welcome = FC<WelcomeProps> { props ->
var name by useState(props.name)
div {
css {
width = 100.pct
height = 500.px
margin = 0.px
padding = 0.px
...
0
votes
1
answer
250
views
Kotlin multiplatform js react - how to use redux Store Provider?
While using kotlin-multiplatform/js with react-redux, after the release, old way of setting-up the Redux Store Provider is deprecated (and may work only in kotlin-react-legacy lib). It was not easy to ...
5
votes
1
answer
532
views
Is it possible to use in JavaScript interface created in Kotlin.js?
I try to reduce my codebase by using a KMM library compiled for Jvm, Android and Javascript.
The simplest code in Kotlin:
@JsExport
actual interface DataTransferObject {
actual val _type: String
...
1
vote
1
answer
801
views
How to call suspending function in class that implements an interface with non-suspending functions in Kotlin/JS
I'm writing a Kotlin Multiplatform library using version 1.9.0-RC, and targeting JVM, Native, and JavaScript.
I want to create a class that implements an interface from a dependency.
// this interface ...
0
votes
1
answer
210
views
No output when compiling kotlin-js IR using kotlinc cli
I'm trying to compile a kotlin file test.kt using kotlinc-js:
fun main() {
println("Hello world!")
val a = add(7, 22)
println("Added to get $a")
}
fun add(x: Int, y: ...
1
vote
1
answer
244
views
Kotlin/JS browserDevelopmentWebpack doesn't generates build/distributions
I am trying to bundle kotlin/js artifacts through webpack, in a Kotlin/JS project.
The documentation here Set up a Kotlin/JS project says that
For building executable JavaScript artifacts through ...
1
vote
2
answers
288
views
Clipboard copy with formatting in Kotlin/JS
I am working on a Kotlin multiplatform project.
I want to support copy action with formatting.
There are a plenty of page in the web implementing it in javascript. All of them are almost same and do ...
2
votes
1
answer
298
views
Using external CSS library in Kotlin/JS
I am not a frontend developer and not familiar with npm, yarn and this sort of tools.
However I want to render some data in a Kotlin/JS project.
Particularly, I want to use font-awesome icons in my ...
3
votes
0
answers
285
views
Specify module kind for kotlin/js compiler in multiplatform project
As stated in here, it is possible to compile Kotlin/JS to different modules. However, proposed solution doesn't work. When trying to add this block of code:
tasks.named<KotlinJsCompile>("...
2
votes
2
answers
126
views
window.getSelection() in Kotlin/JS
There is window.getSelection() in JS.
What is the equivalent in Kotlin/JS?
There is nothing in Kotlin Window API.
0
votes
0
answers
406
views
In Kotlin/JS(Kotlin Multiplatform), how can I get the API Key listed in local.properties?
In Kotlin/JS, how can I get the API Key written in local.properties?
There is a lot of information on how to get the API Key described in local.properties in Android, but I don't know how to get it in ...
0
votes
1
answer
141
views
How to integrate Google GSI with Kotlin/JS
Am trying to implement Google on-tap sign-in in a Kotlin/Js project.
Is there any kotlin-wrapper like library available to use https://accounts.google.com/gsi/client in a Kotlin/Js project?
Or is ...
0
votes
1
answer
263
views
Kotlin/JS - external val from npm package is undefined
I'm trying to use React components from the CKEditor package in my kotlin/js code.
In javascript, I would import these like this:
import { CKEditor } from '@ckeditor/ckeditor5-react';
import ...
2
votes
1
answer
229
views
How to add a react component from an external js library?
I'm trying to add a component from an external library to my react project, but I get an error when I open the page in the browser:
Error: Element type is invalid: expected a string (for built-in ...
1
vote
1
answer
173
views
Kotlin/JS JAR-files contains no JS-files when downloaded manually. Why?
If I download a Kotlin/JS JAR-files manually from https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-serialization-core/1.3.3/pom or https://mvnrepository.com/artifact/org.jetbrains....
0
votes
1
answer
96
views
Using functions that take an interface without creating a class the implements said interface
building alot of binding libraries for a kotlin js project.
i have a ton of interfaces that look like this:
external interface FullscreenControlProps {
var containerId: String?
var position: ...
1
vote
1
answer
632
views
How do I call a suspend function from a React button onClick event in Kotlin/JS?
I want to fetch some data when a button is pressed. I know how to do it using promises and continuations (see the sample below) but I'd like to learn how to do it using suspend functions.
As an ...
2
votes
1
answer
851
views
Problems with Kotlin react router dom element attribuute for binding a react component to URL
I'm currently working on a sample application to learn Kotlin/Js with the react library. When using the normal JSX syntax, a component can be set to be triggered when a specific URL hits using the ...
0
votes
1
answer
123
views
Need help creating a kotlin js wrapper for mapbox-gl-draw
so i am trying to create a wrapper for mapbox-gl-draw in my kotlin react project.
my starter wrapper looks like this
@JsName("default")
external fun mapboxDraw()
i am trying to base it off ...
1
vote
1
answer
347
views
Transforming a Flow<Byte> to a Flow<String> in Kotlin
Consider I have a cold source of UTF-8 bytes (e. g.: reading a file on disk, or the body of an HTTP response), in a form of a Flow<Byte>. How do I convert the above source to a flow of strings?
...
0
votes
1
answer
321
views
Compiling for both Kotlin/Java and Kotlin/JS?
I'd like to write some of my code in Kotlin such that it can be used by both a JVM-based backend and a JS-based frontend.
To do the former (with the new IR complier), the classes have to be annotated ...
1
vote
0
answers
79
views
KotlinJs: Unable to run jsBrowserTest in Google Cloudbuild due to "ReferenceError: setMetadataFor is not defined"
We have a very simple test in kotlinJs to check that a function we have in Javascript is read into kotlin and returns something:
JS code:
function: makeKey = (num) => { return 1000 + num }
Kotlin ...
1
vote
2
answers
260
views
Kotlin Multiplatform/JS Unresolved reference Document.evaluate()
Context: Kotlin Multiplatform JavaScript.
I'm trying to use a Document.evaluate() but getting Unresolved reference: evaluate and Unresolved reference: XPathResult.
import org.w3c.dom.Document
import ...
1
vote
1
answer
276
views
How to pass pass values to constructor when instantiate kotlin class
Assuming I have a class like this
class Foo(private val someVal: String) : RComponent<SomeProp, SomeState>(){
...
}
which I instantiate like so
child(
Foo::class
) {
attrs.bar = props....
1
vote
1
answer
153
views
How can I add my own version of dukat in intellij idea
I am trying to generate external Declaration for a NPM package but it is giving errors
But when I tried the same with dukat@next version it worked
Tell me either how can I include my generated ...
0
votes
1
answer
64
views
why doesn't "is" operator honor inheritance in kotlinjs
I'm developing a kotlinjs react project.
plugins {
kotlin("js") version "1.8.0"
}
and I've written this class:
class Percentage(private val number: Number) : Number() {
...
1
vote
1
answer
265
views
kotlinc-js 1.8 doesn't seem to support IR
When compiling using the kotlin 1.8 sdk, for example :
kotlinc-js -version
One gets the following:
info: kotlinc-js 1.8.0 (JRE 19.0.1)
error: ==========
This project currently uses the Kotlin/JS ...
0
votes
1
answer
320
views
callback function called from coroutine does not run with KotlinJS
I am trying to write a Kotlin function that executes a HTTP request, then gives the result back to JavaScript.
Because with the IR compiler I cannot use a suspended function from JavaScript, I am ...
1
vote
0
answers
239
views
Possible to create a kotlin js app gradle config without webpack/npm/yarn?
Is it possible to create a gradle config that uses the kotlin multiplatform plugin to create a project with a kotlin js client (and ktor/jvm back end) that does required the webpack/npm/yarn ...
0
votes
1
answer
267
views
Using async func in Compose Web
I should use Ktor client in Compose Web. But, It can't be called in Compose Web due to async/non-async problem.
Environment is template project made by IntelliJ IDEA.
First, I use this:
val client=...
1
vote
1
answer
621
views
Kotlin/JS fails to build inside of Docker because of backslashes in package.json
I have a multi-project gradle build that I'm trying to build inside of docker. One of the projects is a Kotlin multiplatform project that builds to JVM and JS. Building the library is fine on my ...
0
votes
1
answer
247
views
Destructuring props passed to functional component in kotlin
In JavaScript, the destructuring of an object is something common.
const foo = {
a: 1
b: 2
c: 3
};
const {a, b, c } = foo;
console.log(a)
1
Is something like this possigle with KotlinJS ...
0
votes
0
answers
151
views
Kotlin/React component not updating
external interface SquareProps: Props {
var value: String
var theHandleClick: () -> Unit
}
val Square: FC<SquareProps> = FC<SquareProps> {props ->
button {
+&...
1
vote
1
answer
211
views
Module not found: Error: Can't resolve 'firebase/app' in Kotlin/JS
In a Kotlin/JS project, I have added the Firebase dependency -
implementation(npm("firebase", "9.14.0"))
Added the external declaration file:
@file:JsModule("firebase/app&...
0
votes
1
answer
213
views
How to set MUI breakpoint values in KotlinJS
I am using https://github.com/JetBrains/kotlin-wrappers/tree/master/kotlin-mui which is a KotlinJS wrapper around Material UI for React.
I am trying to port the following code to Kotlin:
<Grid ...
2
votes
1
answer
656
views
Typescript: Exporting Enum classes to JS produces compilation error
I trying to export Kotlin Enum classes to JS
@OptIn(ExperimentalJsExport::class)
@JsExport
enum class interEnum {
SAMPLE
}
But in Angular Project, after importing as NPM module, the respective TS ...