Kevin Luo
12/02/2021, 4:38 PMuseEffectWithCleanup
hook has been removed. I still need it to detach and reattach event listeners for my web page i.e.
useEffectWithCleanup(listOf(dep1)) {
addEventListener(element...);
return@useEffectWithCleanup removeEventListener(element...);
}
is there an alternative with the newest version of the kotlin-react library?andylamax
12/04/2021, 7:00 AMPiotr Krzemiński
12/06/2021, 9:56 AMRealBackendClient
and MockedBackendClient
without the necessity to change code when using Webpack dev server. For now I found out that webpackHotUpdatefrontend_react
function (my module is called frontend-react
) is defined in window
, but it seems hacky. Is there any more elegant way?Gabriel Duncan
12/07/2021, 2:15 PMGabriel Duncan
12/09/2021, 4:40 PMjsBrowserDevelopment
task now causes two browser reloads. When i save a file:
1. the re-compile step starts BUT at the same time it looks like the websocket for webpack gets a reload signal
2. so, the browser reloads for webpack dev server websocket signal
3. then it reloads AGAIN when the kotlin compiler finishes the jsMainClasses
task
Is anyone else seeing this and if so is there a fix?atsushieno
12/10/2021, 7:36 AMjs(BOTH)
? ("Can't use executable()
with 'both' compiler type")ephemient
12/10/2021, 8:35 AMjsTest
run main()
? none of the other targets have this behavior, but with
// commonMain
fun main() {
println("Hello, world!")
}
running ./gradlew allTests
prints out
> Task :jsNodeTest
Hello, world!
sample project attachedPiotr Krzemiński
12/10/2021, 10:49 AM[2021-12-10T10:37:29.209Z] > Task :frontend-react:browserTest
[2021-12-10T10:37:29.209Z] Cannot start ChromeHeadless
[2021-12-10T10:37:29.209Z] [1210/103728.346077:ERROR:<http://zygote_host_impl_linux.cc|zygote_host_impl_linux.cc>(90)] Running as root without --no-sandbox is not supported. See <https://crbug.com/638180>.
[2021-12-10T10:37:29.209Z] ChromeHeadless stdout:
[2021-12-10T10:37:29.209Z] ChromeHeadless stderr: [1210/103728.346077:ERROR:<http://zygote_host_impl_linux.cc|zygote_host_impl_linux.cc>(90)] Running as root without --no-sandbox is not supported. See <https://crbug.com/638180>.
I told Gradle plugin to look into `karma.config.d`:
testTask {
useKarma {
useConfigDirectory("karma.config.d")
}
}
and there I have
module.exports = function(config) {
config.set({
browsers: ['ChromeHeadlessNoSandbox'],
// you can define custom flags
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
}
})
}
but I'm not even sure if this config is picked up. Too bad Kotlin/JS's Gradle plugin does't allow building on top of available configs. E.g. if I could define:
fun useChromeHeadlessNoSandbox() {
config.customLaunchers["ChromeHeadlessNoSandbox"] = CustomLauncher("ChromeHeadless").apply {
flags.add("--no-sandbox")
}
useChromeLike("ChromeHeadlessNoSandbox")
}
it could work fine and without defining any extra files. Unfortunately, config
is private nowNikolai Sviridov
12/10/2021, 5:13 PMState
. I want to create function which changes state in different Component classes.
// external interface as example, but it will not work
external interface StateWithError: State {
var error: Throwable?
}
fun <S : StateWithError> Component<*, S>.someFunction(){
setState {
error = Throwable("Some msg")
}
}
I tried to use external interface
and abstract class
(even with @JsName("error")
), but always getting name mangling. Is there a way to create such function?Nikolai Sviridov
12/10/2021, 5:20 PM<ForceGraph2D
...
nodePointerAreaPaint={(node, color, ctx) => {
...
// this case
bckgDimensions && ctx.fillRect(node.x - bckgDimensions[0] / 2, node.y - bckgDimensions[1] / 2, ...bckgDimensions);
}}
/>
How to wrap bckgDimensions && ctx.fillRect(...)
? bckgDimension
is array of 2 Numbers.LeoColman
12/11/2021, 3:31 PMTomasz Krakowiak
12/12/2021, 8:55 AMbod
12/12/2021, 1:42 PMIR
compiler - and unfortunately I experience some errors at runtime. Calling some APIs result in "No matching signature" errors
TypeError: Error in invocation of bookmarks.create(bookmarks.CreateDetails bookmark, optional function callback): No matching signature.
I know IR
is still beta but wondering if that rings a bell to anyone. (Not sure how easy it would be for me to create a simple repo project)simon ballantyne
12/13/2021, 3:41 PMIrfan
12/13/2021, 6:38 PMRhiad Jaffar
12/14/2021, 12:47 PMmain
or components in your kotlin code.
Many thanks!Robert Jaros
12/14/2021, 6:54 PMkotlin-js-store
directory in the root dir of my every project. It's probably related to KT-34014
, but shouldn't it be optional?Rob Murdock
12/14/2021, 9:35 PMyarn.ignoreScripts = false
in your build.gradle.kts fileTomasz Krakowiak
12/15/2021, 6:02 PMandylamax
12/16/2021, 12:54 AMpackage pimonitor.evaluation.businesses
sealed class BusinessesIntent {
object LoadBusinesses : BusinessesIntent()
object ShowCreateBusinessForm : BusinessesIntent()
object ExitDialog : BusinessesIntent()
data class ShowInviteToShareReportsForm(val monitored: MonitoredBusiness) : BusinessesIntent()
}
whose generated .d.ts looks like this
export namespace pimonitor.evaluation.businesses {
class BusinessesIntent {
private constructor();
readonly LoadBusinesses: {
} & pimonitor.evaluation.businesses.BusinessesIntent;
readonly ShowCreateBusinessForm: {
} & pimonitor.evaluation.businesses.BusinessesIntent;
readonly ExitDialog: {
} & pimonitor.evaluation.businesses.BusinessesIntent;
}
namespace BusinessesIntent {
class ShowInviteToShareReportsForm extends pimonitor.evaluation.businesses.BusinessesIntent {
constructor(monitored: pimonitor.monitored.MonitoredBusiness);
readonly monitored: pimonitor.monitored.MonitoredBusiness;
}
}
}
The class has been compiled inside a nested namespace which makes it so easy to use. However the objects which are now readonly members of BusinessIntent can never be used at all. It is impossible to even instance check
import { SDK } from "path-to-out-published-lib"
const Intent = SDK.pimonitor.pimonitor.evaluation.businesses.BusinessIntent;
const intent : BusinessIntent = getBusinessIntent()
if(intent instaceof Intent.ShowInviteToShareReportsForm) { // works like charm
}
if (intent instanceof Intent.LoadBusinesses) { // tsc won't even compile
}
cosole.log(intent == intent.LoadBusinesses) // prints false
console.log(intent) // shows it is an instance of LoadBusinesses, prints: LoadBusinesses_1
console.log(intent.LoadBusinesses) // prints: undefined
This whole shenanigan makes using sealed classes with objects unusable from the js/ts side.
Expected behaviour
if (intent instanceof Intent.LoadBusinesses) { // tsc should be able to compile
}
I am currently on
Kotlin 1.5.31,
and yes this is a KMP project.
Anyone seen this before? Is there a ticket associated with this? if not I will have to create on and would ask you guys to help me up vote itsolonovamax
12/16/2021, 7:39 PMrequire
calls at the start of the kotlin main function.
But, I want to add more assets as well as pages to the website. For this, I don't want to have to keep adding require
calls to the start of my main .kt
file. Instead, I'd like if webpack took my pebble template as input and used that to resolve assets. (But, there are some other assets, eg. icons, which must be processed even if not included in the source)
What's the best way to go about this? I've had quite the difficulty in figuring out how I should do it.
Also, I'm fine with moving to another templating language, but the templates need to be rendered server side and not by the javascript. I want clients that can't run javascript to be able to view a fully functioning page.calrissian
12/17/2021, 3:55 AMjsonClient.get(endpoint + "/")
I am getting a NoTransformationFoundException .. I noticed that the content type is text/html but not sure if that is the cause of the issue..
any help would be appreciated..
also I configured my httpClient like this
val jsonClient = HttpClient {
install(JsonFeature) { serializer = KotlinxSerializer() }
followRedirects = true
}
Nikola Milovic
12/18/2021, 12:55 PMvar renderCustomHeader: (Date, (Int) -> Unit, (Int) -> Unit,
() -> Unit, () -> Unit,
Boolean,
Boolean) -> ReactNode?
And I use it like so
attrs.renderCustomHeader = {
date,
changeYear,
changeMonth,
decreaseMonth,
increaseMonth,
prevMonthButtonDisabled,
nextMonthButtonDisabled,
->
div {
//other stuff
}
}
I tried using createElement, but then the changeYear, changeMonth
aren't usable
Uncaught TypeError: this._$changeMonth is not a function
Tomasz Krakowiak
12/19/2021, 3:21 AMRescribet
12/20/2021, 4:15 PM@JsExport
data class Shape(val type: String, val sides: Int)
const a = new Shape("square", 4)
const obj = {...a}
Expected: { type: "square", sides: 4 }
Actual: { _type_1: "square", _sides: 4 }
Derek Ellis
12/20/2021, 8:18 PMjsBrowserWebpack
which just says "See log for details", but I don't see any webpack output in the log. Is there some other log to check? I was able to figure out that the error was caused by a webpack config error through other means, but I'm still confused why there was no errors in the log output.
Stacktrace:
Caused by: java.lang.IllegalStateException: Error occurred. See log for details.
at org.jetbrains.kotlin.gradle.internal.ExecKt$execWithErrorLogger$1.invoke(exec.kt:83)
at org.jetbrains.kotlin.gradle.internal.ExecKt$execWithErrorLogger$1.invoke(exec.kt:76)
at org.jetbrains.kotlin.gradle.internal.ProgressKt.operation(progress.kt:21)
at org.jetbrains.kotlin.gradle.internal.ProgressKt.operation$default(progress.kt:12)
at org.jetbrains.kotlin.gradle.internal.ExecKt.execWithErrorLogger(exec.kt:76)
at org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackRunner.execute(KotlinWebpackRunner.kt:31)
at org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack.doExecute(KotlinWebpack.kt:287)
Rescribet
12/21/2021, 3:43 PMjsBrowserProductionWebpack
)
There are 22 lines in the bundle which are actually related to Shape
which on their own just work as expected (47kB vs 600 byte)
@JsExport
data class Shape(val type: String, val sides: Int)
Nicolas Lidin
12/22/2021, 10:33 AMephemient
12/28/2021, 3:43 AMmodule.exports = function...
Nikola Milovic
12/29/2021, 8:50 AMimport { Transition } from '@headlessui/react'
<Transition.Child />
OR
<motion.div
As JsName doesn't accept .
, tried some shenanginas with extension functions but cannot get it to workNikola Milovic
12/29/2021, 8:50 AMimport { Transition } from '@headlessui/react'
<Transition.Child />
OR
<motion.div
As JsName doesn't accept .
, tried some shenanginas with extension functions but cannot get it to workBig Chungus
12/29/2021, 9:05 AM@JsModule("@headlessui/react")
external object HeadlessUI {
class Transition {
class Child
}
}
// Usage
HeadlessUI.Transition.Child
@file:JsModule("@headlessui/react")
class Transition {
class Child
}
// Usage
Transition.Child
Nikola Milovic
12/29/2021, 9:25 AM@file:JsModule("@headlessui/react")
external class Transition: ComponentClass<TransitionProps> {
class Child : ComponentClass<TransitionChildProps> {}
}
external interface TransitionProps : Props {
}
Something along these lines? But now I have to implement the Component Class
Tried FC<P> instead of ComponentClass but I lose the ability for this kind of syntax
Transition.Child {
attrs. ... = ...
}
andylamax
12/29/2021, 9:30 AMTransitionChild
syntax instead of Transition.Child
Nikola Milovic
12/29/2021, 9:33 AMandylamax
12/29/2021, 9:36 AM@JsModule("@headlessui/react")
external val Transition : ComponentType<TransitionProps>
val TransitionChild : ComponentType<TransitionChildProps> = Transition.asDynamic().Child
turansky
12/29/2021, 12:20 PMheadlessui
?Daniel Rampelt
01/03/2022, 3:14 PMBig Chungus
01/03/2022, 3:16 PMDaniel Rampelt
01/03/2022, 6:42 PM