theapache64
02/12/2022, 6:12 AM./gradlew browserRun --continuous
to enable hot reload. The problem is, it takes some time to reflect the changes in the browser. Is there any faster way to do that?Ayfri
02/13/2022, 3:28 AMmavenCentral
and ready to be used !
For now it's a bit tricky to use as I don't added any builder helper and there are a lot of casts issues, but I'll fix these later, all types are updated to Pixi 6.2.2 ^^
To use it, simply add
implementation("io.github.ayfri:PIXI-Kotlin:0.1.1")
Please follow the Github Repository if you want to know where a new release comes out :)andylamax
02/13/2022, 5:26 AM1.6.20-M1
for the kotlin team. Please upvote and lets see if we can get it on 1.6.20
it looks like they are currently focusing on @JsExport
at the moment
This is a feature request on how companion objects of classes and interfaces should behave in kotlin/js stricly when marked with @JsExport
Current Status
1. Marking an interface that has a companion object with @JsExport
fails the build. You can get it to work with Suppress("WRONG_EXPORTED_DECLARATION")
but this leads to incorrect typescript definition generations (static getter on the interface)
2. Marking an external class that has a companion with @JsExport
fails the build even with Suppress("WRONG_EXPORTED_DECLARATION")
. I am assuming this is even why currently kotlin.js.Promise
is not marked as @JsExport
Breakdown
1. External interfaces with companion objects do not make any sense, from Kotlin and even Typescript. So @JsExport
on external interfaces should definitely not compile
2. non external interfaces that have a companion object and are marked with @JsExport
should definitely compile. Because they have meaning at least in Kotlin. Especially when used in multiplatform context. As in I can create an interface in common code, have some members in its companion object then decide to export it. Many KMP devs use this pattern
3. external classes (abstract, open, final) with companion objects should definitely be compillable because they have a solid one to one correlation between Kotlin and Typescript
Proposal
1. interfaces marked with @JsExport
should work as they are now. Only difference is when it comes to type definitions, everything found inside and including the companion object itself should just be skipped during generation of types.
2. external classes (abstract, open, final) with companion objects should definitely be exportable. I am surprised as to why the compiler currently fails to compile them
Metadata
Kotlin: 1.6.20-M1
Ticket: https://youtrack.jetbrains.com/issue/KT-51292Ayfri
02/13/2022, 3:22 PMtestImplementation(kotlin("test-js"))
testImplementation(kotlin("test-junit"))
testImplementation(kotlin("test-js-runner"))
And just using @Test
on a method and assertNotNull
, but when running I'm getting this error
Execution failed for task ':browserTest'.
> Cannot find node module "kotlin-test-js-runner/kotlin-test-karma-runner.js" in "C:\...\IdeaProjects\libs\PIXI-Kotlin\build\js\packages\PIXI-Kotlin-test"
ankushg
02/15/2022, 1:14 AMSuspendWrapper<T>
class and I want to expose a fun subscribe(onSuccess: (item: T) -> Unit, onThrow: (error: Throwable) -> Unit)
to JS
If I mark it with a @JsExport
, I’m currently getting a Exported declaration uses non-exportable parameter type: (T) -> Unit
error
Is there a way to allow this? I don’t think there’s a way to compile-time enforce that T
is also JsExport
-able, but it definitely is in this case…
Do I just @Supress
the warning?Grégory Lureau
02/15/2022, 8:19 AMfetch
and so requires AbortController/AbortSignal.Grégory Lureau
02/15/2022, 10:24 AMGlobalScope.promise
and in the my Promise I reject with nothing reject()
this is not considered as an error. I can reject(42)
or with an explicit error, but when there is nothing, it looks similar to resolve()
with no params (getCompletionExceptionOrNull
returns null, isCompleted
returns true). Is there a way to differentiate both cases? And why not considering reject()
as failed with an unknown exception from the Kotlin side?John Coleman
02/17/2022, 4:43 AMMihai Voicescu
02/17/2022, 9:38 AMPromise
?
try {
val p = window.navigator.mediaDevices.asDynamic()
.getDisplayMedia() as Promise<MediaStream>
console.log(p)
p.await()
} catch (e: Exception) {
console.error("Everything is fine")
console.error(e)
}
Ilya Kalibrov [JB]
02/17/2022, 9:41 AMSebastien Leclerc Lavallee
02/17/2022, 4:38 PMyarn add
the root package, it execute correctly.
Now I have 2 questions… how can I set the root package.json’s version? Currently it always generate to unspecified
.
And when I try to import one of the exported class, I have this error: Cannot find module or its corresponding type declarations.
Any tips on what I did wrong or what I could do to make it work?
Thanks 🙂David Otasek
02/17/2022, 10:38 PM0.0.1-pre.264-kotlin-1.5.31
. However, the targeted project is using 17.0.1-pre.148-kotlin-1.4.30
. Bringing the target project's dependencies up to date is the virtuous path to this, but it has thus far proved very difficult. The KotlinConf explorer GitHub has no record of any code referring to previous versions that I could reference either.
The following is the import 'plumbing' that works in the newer project:
@file:JsModule("react-ace")
@file:JsNonModule
package ace
import react.*
@JsName("default")
external val aceEditor: ComponentClass<AceEditorProps>
external interface AceEditorProps : Props {
var ref : MutableRefObject<Nothing>
var mode: String
var theme : String
var annotations : Array<AceAnnotation>
var markers : Array<AceMarker>
var defaultValue : String?
var value : String?
var setOptions : AceOptions
}
Is there something simple that could be done to have this work with the older version while I try to update all the dependencies?andylamax
02/17/2022, 10:55 PMStylianos Gakis
02/18/2022, 10:17 AMBrian Guertin
02/18/2022, 5:02 PMfun negate(value: Any?) = when (value) {
is Int -> {
println(value::class.simpleName)
-value
}
is Double -> -value
else -> Double.NaN
}
Calling negate(-5.6)
returns -5
. It hits the is Int
path! And the best part is, it prints "Double"ankushg
02/19/2022, 6:09 PM@JsExport
? Like a @JsHide
?
If I have a class in a KMP project that has a public suspend fun
that’s intentionally public for non-JS platforms. That class also has several other valid-for-export methods (including a callback-based API for said suspend fun
), but because of that single coroutine, I can’t currently mark the class as @JsExport
I’d love to be able to tell the compiler to export everything except that pesky suspend fun
Is my only option right now to suppress the warning? It looks like the compiler just drops a comment into the generated .d.ts
file, but it would be nice to tell it that I don’t want to export that method at allandylamax
02/21/2022, 2:03 PMMichael Evans
02/21/2022, 8:18 PMimplementation(npm("jwt-decode","3.1.2"))
In my kotlin code:
@JsModule("jwt-decode")
@JsNonModule
external fun jwt_decode(token: String): dynamic
And what I see in the console output in my browser dev tools:
GoogleAuthComponent.kt?e0b6:35 Uncaught TypeError: $module$jwt_decode is not a function
Here is the documentation of how the js library should work in vanilla javascript:
import jwt_decode from "jwt-decode";
var token = "eyJ0eXAiO.../// jwt token";
var decoded = jwt_decode(token);
Am I missing some step? I can see the jwt-decode libary got pulled into my build node_modules directory. But it doesn't appear to be packaged up with my projects js file, and it doesn't appear to get pulled down via any other network requests from my page.
Do I need to add a script tag to pull the js file down myself? And if so, is there some path at which all the node modules are available?
Is there any more in-depth documentation than this? https://kotlinlang.org/docs/using-packages-from-npm.htmlMoritz Hofmeister
02/22/2022, 9:49 AMPostState
although the migration guide lists this as a migration step
• Initialization of the PostState
is done by assigning an object
derived from PostState
to the state
in the init
block, but IntelliJ shows a warning that this object
should be an external interface
to tell the compiler that this is no Kotlin object as described in the migration guide
Are there other open source JetBrains projects (or just other projects in general) that already use the IR compiler to get some insights on how this more restrictive design is handled in these projects?Nikky
02/22/2022, 11:02 AMjsCompileClasspath - Compile classpath for compilation 'main' (target js (js)).
+--- org.jetbrains.kotlin:kotlin-stdlib:1.6.10
| \--- org.jetbrains:annotations:13.0
+--- org.jetbrains.kotlinx:kotlinx-serialization-json:{require 1.3.2; reject _} -> 1.3.2
| \--- org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.3.2
anyone ran into this or got a idea how to figure out whats causing it ?Sebastien Leclerc Lavallee
02/22/2022, 3:03 PM@JsExport
interface IAddress {
var id: String
}
What is exported in the .d.ts
file is this:
interface IAddress {
id: string;
readonly __doNotUseIt: __doNotImplementIt;
}
There is the __doNotUseIt
property that is added. How can I have this not added to the typed definition file.
I’m using Kotlin 1.6.20-M1
Thanks! 🙂ankushg
02/22/2022, 9:47 PMkotlin.js.Promise
class isn’t exported as a real JS Promise
? Feels pretty important and I haven’t seen much info about thatLukas Anda
02/23/2022, 4:15 PMJim
02/23/2022, 11:45 PMbinaries.library()
- is this on the horizon?Sunny
02/24/2022, 7:58 AM0.10.1
and kotlin multiplatform to 1.6.10
ran into this build issue. Does someone run into something similar?
Could not determine the dependencies of task ':jsPackageJson'.
> Could not resolve all dependencies for configuration ':jsNpm'.
> Could not resolve com.ccfraser.muirwik:muirwik-components:0.10.1.
Required by:
project :
> No matching variant of com.ccfraser.muirwik:muirwik-components:0.10.1 was found. The consumer was configured to find a usage of 'kotlin-runtime' of a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js', attribute 'org.jetbrains.kotlin.js.compiler' with value 'ir' but:
Moritz Hofmeister
02/24/2022, 1:59 PMAyfri
02/25/2022, 6:20 PMticker.add { code }
, but to remove it I have to have the same lambda, ticker.remove { code }
, but in Kotlin is just doesn't work as a JS function is generated for both but has a different name, so it just doesn't work
My code
fun onKeep(callback: (KeyboardEvent) -> Unit) {
fun test(keyboardEvent: KeyboardEvent) {
if (enabled) callback(keyboardEvent)
}
onPress {
ticker.add { test(it) } // correctly add the function
}
onRelease {
ticker.remove { test(it) } // can't remove function as JS result is not the same
}
}
But this very code works if translated to JS and directly run in JS, so it's a Kotlin problemNaveed
02/25/2022, 7:35 PM--continuous
or -t
as a flag when running the kotlin browser through gradle. This makes it quite challenging to get quick feedback loops when changing (especially trivial) code. Has anyone else come across this problem?xxfast
02/27/2022, 11:31 PMexternal
declaration for this uuid npm package? I tried
@JsModule("uuid")
@JsName("v4")
external fun uuidv4(): String
but getting Uncaught TypeError: v4 is not a function
on the consolePaul SOUTEYRAT
03/02/2022, 8:01 PMdelete myJson['myField'];
in Kotlin JS (Legacy) on a field of a kotlin.js.Json
.
I didn't find anything about it. Any help would be much appreciated.Paul SOUTEYRAT
03/02/2022, 8:01 PMdelete myJson['myField'];
in Kotlin JS (Legacy) on a field of a kotlin.js.Json
.
I didn't find anything about it. Any help would be much appreciated.Big Chungus
03/02/2022, 8:02 PMjs("delete myJson['myField']")
works everywhereturansky
03/02/2022, 8:03 PMimport kotlinext.js.delete
delete(myJson["myField"])
Paul SOUTEYRAT
03/02/2022, 8:04 PMturansky
03/02/2022, 8:04 PMBig Chungus
03/02/2022, 8:06 PM