Franco
10/18/2021, 7:15 AMkotlin-wrappers
lib and I noticed that the React wrapper has changed quite a bit and now I'm not sure how to do the following:
route("${url}/:id") { props ->
val idParam = props.match.params.id
...
}
Does anyone know how to do this with the new API?
@turansky you might know 🙂Reuben F
10/18/2021, 12:58 PM@Test
fun example() {
var i = 0
fun asyncTask() = Promise<Boolean> { resolve, _ ->
window.setTimeout({ i = 1; resolve(true) }, 100)
}
asyncTask().then {
console.log("got result")
} // there's no await so i can't prevent it continuing
console.log("i want this to run after we've waited for the promise")
assertEquals(i, 1)
}
Tomasz Krakowiak
10/18/2021, 5:11 PMankushg
10/18/2021, 5:21 PMPromise
?julien lengrand-lambert
10/18/2021, 8:51 PMjulien lengrand-lambert
10/18/2021, 11:39 PMUncaught ReferenceError: firebase is not defined
error in the frontend.
My client is available here : https://github.com/jlengrand/kotlin-samples/blob/main/sample-firebase/src/main/kotlin/Client.kt. You can reproduce by running ./gradlew run
in the sample-firebase moduleSlackbot
10/19/2021, 12:52 PMNikola Milovic
10/19/2021, 4:39 PMjsBrowserProductionWebpack, browserProductionWebpack
, just build
which is mentioned in the official codealong from Jetbrains. Webpack generates tons of files, build just generates an index.html
and a .js
file. I am guessing that after the files are generated then it's not an entirely Kotlin related question but any pointers on where to look/ what to read, what the easiest setup to deploy the website would be appreciated. I cannot just use Heroku like in the JetBrains guide as I have some issues with that approach and I just want to get the site up and running.Andrew Reed
10/20/2021, 9:43 AMDeclaration of such kind (suspend function) cant be exported to JS
How do i get around this? im currently marking my interface as external to be able to export it to JS, but how can i export a suspending function?
Here is an example:
@JsExport
@JsName("CoolInterface")
external interface CoolInterface {
@JsName("suspendingFunc")
suspend fun suspendingFunc(root: String): String?
}
Mihai Voicescu
10/21/2021, 9:30 AMIan Alexander
10/21/2021, 8:08 PMpackForXcode
Also, is there any interoperability guide similar to kotlin/native?
Thanks!Carter
10/22/2021, 3:06 PM> Task :kotlinNpmInstall
warning workspace-aggregator-107d151b-247f-41fa-81dd-c9032d26021f > Project-lib-test > karma > ua-parser-js@0.7.29: this package has been hijacked
It looks like this is due to having karma used for my tests, e.g.
js(IR) {
browser {
testTask {
useKarma {
useChromeHeadless()
...
It sounds like this is a security issue, but what’s the solution to either force the karma or ua-parser-js implicit dependency version?Nikola Milovic
10/23/2021, 7:57 AM--env
args to my webpack, for some reason --env.value=value
nor --env value=value
don't work. One approach is from older versions, the other from the newest
(For some reason I am using newest possible webpack)
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().versions.apply{
webpack.version = "5.59.0"
webpackCli.version = "4.9.1"
webpackDevServer.version = "4.3.1"
}
...
val envTargetWebpackArgs = listOf("--env envTarget=$envTarget")
webpackTask { args.plusAssign(envTargetWebpackArgs) }
runTask { args.plusAssign(envTargetWebpackArgs) }
}
Any input on this? I should probably downgrade my versions, but it seems that all works properly except this
[webpack-cli] Error: Unknown option '--env envTarget=DEV'
[webpack-cli] Run 'webpack --help' to see available commands and options
Nikola Milovic
10/23/2021, 4:05 PMval referenceElement = useRef<HTMLElement>(null);
val popperElement = useRef<HTMLElement>(null);
val arrowElement = useRef<HTMLElement>(null);
val popper = usePopper(referenceElement.current,
popperElement.current,
object : UsePopperOptions<dynamic> {
override var modifiers: ReadonlyArray<Modifier<dynamic>> = arrayOf(js(
"{ name : 'arrow', options: {element: arrowElement}}"
))
override var onFirstUpdate: (State) -> Unit = {}
override var placement: Placement = Placement.auto
override var strategy: PositioningStrategy = PositioningStrategy.absolute
})
....
div("bg-blue-500 text-white font-bold") {
attrs.id = "tooltip"
attrs.role = "tooltip"
attrs.style = popper.styles["popper"].toString()
+"Test tooltip"
div {
attrs.id = "arrow"
this.ref = arrowElement
attrs.style = popper.styles["arrow"].toString()
}
}
Miquel Àngel Román
10/23/2021, 7:36 PMAlex Edwards
10/24/2021, 5:15 PMconst listDiscountController = new ListDiscountsController();
exports.handler = async (event, context, callback) => {
return listDiscountController.handle(event, context, callback);
};
The way I have this setup is with the constructor defined outside of the handler function to ensure asnyc init operations are only performed on a cold start and not each time the function is called. I’m trying to refactor this to be defined in kotlin (the below code works)
private val listDiscountsController = ListDiscountsController()
@JsExport
fun listDiscountsHandler(event: Any, eventContext: Context, callback: Any): Any {
return listDiscountsController.handleEvent(event, eventContext, callback)
}
the problem I have is that even if i define the entrypoints in separate kotlin files, if they are in the same gradle project they still get compiled down into the same js file. Is there a way to get kotlin (legacy not IR) gradle plugin to create multiple js files for a project (ideally 1 per kotlin file)?Ilya Kalibrov [JB]
10/25/2021, 8:30 AMAndre Barrett
10/25/2021, 1:45 PMJim
10/25/2021, 10:47 PMexternal interface
vs a regular interface
- does anyone have any thoughts on this?andylamax
10/26/2021, 11:33 AMList<T>
on my @JsExport
models. Not only the fields mangled but it almost unusable in kotlin/js
.
At the moment I am exporting every List<T>
propery with a field that exposes an array, like so
class Person(val names: List<String> = listOf("John","Doe")) {
val namesArray get() = names.toTypedArray()
}
but that is now becoming tedious. So, any one experiencing this?
I wouldn't want my properties to not be Lists, but would need them to easily be consumable from the JS side when we export our library
I have a feeling if the kotlin-stdlib-js could export type bindings for all collections, List, Map, Set e.t.c, It could have been of much help. But I wanna know how others are tackling this.
Thoughs?Sebastian Aigner
10/26/2021, 3:02 PMyarn.lock
files and fine-grained control over Yarn’s lifecycle scripts in Kotlin/JS and Kotlin Multiplatform projects directly.
https://blog.jetbrains.com/kotlin/2021/10/control-over-npm-dependencies-in-kotlin-js/shaktiman_droid
10/26/2021, 4:51 PMJSON.stringify(data class)
adds _
underscore to parameters. is there a way to avoid that?
data class Test(val email: String)
val test = Test("<mailto:abc@x.com|abc@x.com>")
val json = JSON.stringify(test)
resulting json is {"_email":"<mailto:abc@x.com|abc@x.com>"}
why is there an underscore
before email
?Rhiad Jaffar
10/28/2021, 10:32 AMkotlin-wrapper
modules:
kotlin-react
kotlin-react-dom
kotlin-styled
kotlin-react-router-dom
We had done this originally using x.x.x-pre.206-kotlin-1.5.10
versions (as this was the code created by latest IntelliJ Community Edition when we created the web project).
When trying to update to x.x.x-pre.261-kotlin-1.5.31
versions we got the following error:
> Task :jsApp:compileDevelopmentExecutableKotlinJs FAILED
e: java.lang.AssertionError: Assertion failed
at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.JsAstUtilsKt.translateCallArguments(jsAstUtils.kt:341)
at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.JsAstUtilsKt.translateCall(jsAstUtils.kt:109)
at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrElementToJsExpressionTransformer.visitCall(IrElementToJsExpressionTransformer.kt:219)
at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrElementToJsExpressionTransformer.visitCall(IrElementToJsExpressionTransformer.kt:23)
at org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl.accept(IrCallImpl.kt:47)
... etc
Turns out we needed to change a coding pattern we had used (which seems valid and the IDE does not complain about). It seems the compiler no longer supports using fun
and then passing the function reference as a prop?
- fun handleLoginPressed() {
+ val handleLoginPressed = {
loginController.handleLoginPressed()
}
@@ -49,7 +49,7 @@
child(Welcome::class){
attrs {
welcomeString = platform.platform
- goToLogin = ::handleLoginPressed
+ goToLogin = handleLoginPressed
}
}
}
Lines starting with -
cause the above error. Lines starting with +
fix it and the code compiles successfully.
So the question we have is:
Was this an intended change to the compiler? Or might this be a regression?
Happy to share more code/info if it helps.
Many thanks!Max
10/28/2021, 10:32 AMMatthieu Stombellini
10/28/2021, 10:40 PMThere is already declared version of 'webpack-cli' with version '^4.9.0' which does not intersects with another declared version '4.7.1'
Ilya Kalibrov [JB]
10/29/2021, 9:48 AMrnentjes
10/29/2021, 12:17 PMMiquel Àngel Román
10/30/2021, 1:33 PMTóth István Zoltán
11/01/2021, 7:40 AMandylamax
11/01/2021, 12:01 PMDeclaration of such kind (inline function with reified type parameters) cant be exported to JS
What is the string in the @Supress
annotation
More over, where do I look for other use cases that can be suppressed?andylamax
11/01/2021, 12:01 PMDeclaration of such kind (inline function with reified type parameters) cant be exported to JS
What is the string in the @Supress
annotation
More over, where do I look for other use cases that can be suppressed?turansky
11/01/2021, 1:05 PMandylamax
11/01/2021, 6:35 PMturansky
11/01/2021, 6:41 PMandylamax
11/01/2021, 6:43 PM