KV
05/09/2022, 5:22 PMDavid Corrado
05/09/2022, 11:51 PMtylerwilson
05/11/2022, 2:51 AMCouldn't find package "abort-controller@3.0.0" required by "ktor-ktor-client-core-js-ir@1.6.8" on the "npm" registry.
Anybody know how to fix this? There are a number of other bits missing too (ws, webpack, @js-joda/core)martmists
05/11/2022, 2:29 PMindex.js
in a multiplatform project? I tried it like this but it still uses the project name instead:
js("frontend", IR) {
binaries.executable()
browser {
commonWebpackConfig {
cssSupport.enabled = true
output?.library = "index" // tell it to generate as index.js
}
}
}
dazza5000
05/11/2022, 3:15 PMdazza5000
05/11/2022, 4:50 PMpeekandpoke
05/12/2022, 11:54 AM> Task :core:compileTestDevelopmentExecutableKotlinJs FAILED
e: java.lang.NullPointerException
at org.jetbrains.kotlin.ir.backend.js.ic.InvalidationKt.actualizeCacheForModule(invalidation.kt:444)
at org.jetbrains.kotlin.cli.js.K2JsIrCompiler.doExecute(K2JsIrCompiler.kt:220)
at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:178)
at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:71)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:91)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:43)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:93)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1623)
at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
It worked and suddenly stopped working. We are also not doing anything fancy here. Just a normal gradle.build configuration.
I see that the NPE is thrown here in `invalidation.kt:444`:David Smith
05/12/2022, 2:39 PMDavid Smith
05/12/2022, 3:44 PMExecution failed for task ':admin-app:kaptGenerateStubsKotlin'.
> Error while evaluating property 'filteredArgumentsMap' of task ':admin-app:kaptGenerateStubsKotlin'
> Could not resolve all files for configuration ':admin-app:kotlinCompilerPluginClasspathMain'.
> Could not find org.jetbrains.kotlin:kotlin-allopen:1.6.21.
Required by:
project :admin-app
> Could not find org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.6.21.
Required by:
project :admin-app
> Could not find org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.6.21.
Required by:
project :admin-app
Vitaly Khvostov
05/13/2022, 9:30 AMkotlin-mui-icons
broken or it's only in my environment? Firstly it broke when I bumped version of my project to 1.0.0-pre.336; then, I tried to run both a test project and Kotlin Mui Showcase (https://github.com/karakum-team/kotlin-mui-showcase) which use MUI icons, and they show an error like in the attachments.David Smith
05/13/2022, 2:37 PMcommonMain
@JsExport
data class Hello(val something: String)
and in my build.gradle.kts I have
js(IR) {
browser {
binaries.executable()
}
}
when I try to do gradle build
or I can see that something is compiled however there is no build/js
directory and I have no idea where this has been createdSergei Grishchenko
05/13/2022, 7:10 PMkotlin-wrappers
What kind of Kotlin DSL for React Context Provider do you like?
React with 👈 if you like classic syntax
CustomContext.Provider(value) {
Child {}
}
React with 👉 if you like shortcut syntax
CustomContext(value) {
Child {}
}
Thank you for feedbackGopal S Akshintala
05/15/2022, 11:38 AMRan
05/18/2022, 8:16 AMval jsMain by getting {
dependencies {
implementation(npm("bignumber.js", "9.0.2"))
}
}
Declaration:
@JsModule("bignumber.js")
@JsNonModule
external class BigNumber(raw: String) {
companion object {
var ROUND_UP: Number /* 0 */
var ROUND_DOWN: Number /* 1 */
var ROUND_CEIL: Number /* 2 */
var ROUND_FLOOR: Number /* 3 */
var ROUND_HALF_UP: Number /* 4 */
var ROUND_HALF_DOWN: Number /* 5 */
var ROUND_HALF_EVEN: Number /* 6 */
var ROUND_HALF_CEIL: Number /* 7 */
var ROUND_HALF_FLOOR: Number /* 8 */
fun config(): Config
fun set(obj: Config): Config
fun clone(obj: Config = definedExternally): Any
}
interface Config {
var DECIMAL_PLACES: Number?
get() = definedExternally
set(value) = definedExternally
var ROUNDING_MODE: Number? /* 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 */
get() = definedExternally
set(value) = definedExternally
var EXPONENTIAL_AT: dynamic /* Number? | JsTuple<Number, Number> */
get() = definedExternally
set(value) = definedExternally
var RANGE: dynamic /* Number? | JsTuple<Number, Number> */
get() = definedExternally
set(value) = definedExternally
var CRYPTO: Boolean?
get() = definedExternally
set(value) = definedExternally
var MODULO_MODE: Number? /* 0 | 1 | 3 | 6 | 9 */
get() = definedExternally
set(value) = definedExternally
var POW_PRECISION: Number?
get() = definedExternally
set(value) = definedExternally
var FORMAT: Format?
get() = definedExternally
set(value) = definedExternally
var ALPHABET: String?
get() = definedExternally
set(value) = definedExternally
}
interface Format {
var prefix: String?
get() = definedExternally
set(value) = definedExternally
var decimalSeparator: String?
get() = definedExternally
set(value) = definedExternally
var groupSeparator: String?
get() = definedExternally
set(value) = definedExternally
var groupSize: Number?
get() = definedExternally
set(value) = definedExternally
var secondaryGroupSize: Number?
get() = definedExternally
set(value) = definedExternally
var fractionGroupSeparator: String?
get() = definedExternally
set(value) = definedExternally
var fractionGroupSize: Number?
get() = definedExternally
set(value) = definedExternally
var suffix: String?
get() = definedExternally
set(value) = definedExternally
}
fun plus(number: BigNumber): BigNumber
fun minus(number: BigNumber): BigNumber
fun multipliedBy(number: BigNumber): BigNumber
fun dividedBy(number: BigNumber): BigNumber
fun modulo(number: BigNumber): BigNumber
fun comparedTo(number: BigNumber): Number?
fun toString(base: Int): String
}
Other methods work well except set
and clone
.
@Test
fun testConfig() {
println(BigNumber.config().DECIMAL_PLACES)
BigNumber.set(object : BigNumber.Config {
override var DECIMAL_PLACES: Number? = 3
})
println(BigNumber.config().DECIMAL_PLACES)
}
the set
method has no effect. The output is like the following:
> Task :jsBrowserTest
[log] 20
[log] 20
Is there anyone can tell me why the set
method doesn't work and how can I use clone
method?Ran
05/19/2022, 11:14 AMTypeError: Cannot read properties of undefined (reading 'plus_4zeyed$')
I have the declaration in common:
expect class BigDecimal(raw: String) {
fun add(bigDecimal: BigDecimal): BigDecimal
companion object {
val ONE: BigDecimal
val MAX: BigDecimal
val MIN: BigDecimal
}
}
internal val maxValue = ""
internal val max = BigDecimal(maxValue)
internal val minValue = ""
internal val min = BigDecimal(minValue)
In jsMain:
@JsModule("bignumber.js")
@JsNonModule
external class BigNumber(raw: String) {
fun plus(number: BigNumber): BigNumber
}
actual class BigDecimal actual constructor(raw: String) {
private val delegate: BigNumber = BigNumber(raw)
actual companion object {
actual val ONE: BigDecimal = one
actual val MAX: BigDecimal = max
actual val MIN: BigDecimal = min
}
actual fun add(bigDecimal: BigDecimal): BigDecimal {
return BigDecimal(delegate.plus(bigDecimal.delegate).toPlainString())
}
}
I have following unit test:
@Test
fun testOverflow() {
assertEquals(maxValue, (BigDecimal.MAX + BigDecimal.ONE).toPlainString())
}
I got the error I post when I run the unit test for js target. Is there anyone who can tell me what's wrong here?Ran
05/19/2022, 2:07 PMsourceSets {
val commonMain by getting {
dependencies {
implementation("com.calculation.multiplatform:MultiplatformBigDecimal:1.0.0-beta6")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.3.2")
}
}
}
The ios unit tests and JVM unit tests work well. But when I run js unit tests, I got the following error:
Could not determine the dependencies of task ':jsTestPackageJson'.
> Could not resolve all dependencies for configuration ':jsTestNpm'.
> Could not resolve com.calculation.multiplatform:MultiplatformBigDecimal:1.0.0-beta6.
Required by:
project :
> No matching variant of com.calculation.multiplatform:MultiplatformBigDecimal:1.0.0-beta6 was found. The consumer was configured to find a usage of 'kotlin-runtime' of a library, preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js', attribute 'org.jetbrains.kotlin.js.compiler' with value 'ir' but:
I cannot understand the message. Is there anyone who can tell me how can I solve this problem?Arjan van Wieringen
05/20/2022, 8:51 AMMihai Voicescu
05/20/2022, 11:23 AMRan
05/23/2022, 3:18 AMMihai Voicescu
05/23/2022, 1:20 PMany
in TS declarations in 1.6.20
Anybody know a fix for this?
EG:
@ExperimentalJsExport
@JsExport
fun test(): Promise<JSClient> {
TODO()
}
@ExperimentalJsExport
@JsExport
fun useClient(): JSClient? {
compiles to
export function test(): any/* Promise<JSClient> */;
export function useClient(): Nullable<JSClient>;
Alexander Sysoev
05/23/2022, 3:33 PMFunction types with receiver are prohibited in external declarations
Alexander Sysoev
05/23/2022, 5:20 PMfun <P : Props> component(builder: {ChildrenBuilder & P & Props}.() -> Unit): FC<P> {
return FC<P> {
builder()
}
}
Jan
05/23/2022, 6:16 PMJoffrey
05/24/2022, 6:31 PMThere are multiple versions of "ktor-ktor-client-core-js-legacy" used in nodejs build: 1.6.8, 2.0.0. Only latest version will be used.I have 2 independent multiplatform submodules to support Ktor 1 and Ktor 2. They are never used together. When running js tests for the module using Ktor 1.6.8, I have runtime errors because it is in fact using Ktor 2 during tests. I noticed the
build/js/packages/<module-name>/package.json
doesn't contain any dependencies, and in fact all dependencies of all subprojects are mixed together in build/js/package.json
as "workspaces", excluding collisions (so Ktor 1 is not there). Is this normal? Is there a way to change that?Jonathan Ellis
05/25/2022, 2:07 AMRan
05/25/2022, 2:44 AMsourceSets {
val jsMain by getting {
dependencies {
implementation(npm("bignumber.js", "9.0.2"))
}
}
}
I published my KMP library to my private maven and use it in my another KMP project:
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.calculation.multiplatform:MultiplatformBigDecimal:1.0.0")
}
}
}
Then I build js package in my KMP project use ./gradlew jsBrowserProductionWebpack
command. The problem is that I cannot see peerDependencies on MultiplatformBigDecimal and bignumber.jsMarius Ailinca
05/25/2022, 11:41 AMfun bytesToFile(byteArray: ByteArray){
val blob = Blob(byteArray.toTypedArray(), BlobPropertyBag("application/vnd.ms-excel"))
val link = document.createElement("a") as HTMLAnchorElement
link.href = URL.Companion.createObjectURL(blob)
link.download = "test.xlsx"
link.click()
//document.removeChild(link)
}
Any idea what it might be wrong?patrickdelconte
05/25/2022, 12:31 PMorg.khronos.webgl.WebGLRenderingContext
Are there any external types for the webgl2 api?Mihovil Ilakovac
05/25/2022, 3:08 PMjs(IR) {
browser()
binaries.executable()
}
But the build fails immediately with the error:
Caused by: org.gradle.api.internal.tasks.DefaultTaskContainer$DuplicateTaskException: Cannot add task 'clean' as a task with that name already exists.
I’m not sure how to approach this, has anyone encountered a similar error?
Gradle version: 7.3.3Jonathan Ellis
05/26/2022, 4:06 PMjs("foo") as Type
the best option? What about going the other way around, do I need to generate js("foo = [js string representation]")
? This is easy for primitives but more tedious for other objectsJonathan Ellis
05/26/2022, 4:06 PMjs("foo") as Type
the best option? What about going the other way around, do I need to generate js("foo = [js string representation]")
? This is easy for primitives but more tedious for other objectsephemient
05/26/2022, 4:12 PMexternal var foo: Type
Jonathan Ellis
05/26/2022, 4:19 PM<script>
let foo = 0.0
let bar = {}
</script>
external var foo: Double
external var bar: MutableMap<String, Any>
foo = 1.0
bar["test"] = "a"
Uncaught TypeError: tmp0_set_0.put_3mhbri_k$ is not a function
ephemient
05/26/2022, 5:50 PMMutableMap
is a Kotlin type, but {}
in JS is notexternal val bar: dynamic
bar["test"] = "a"
Jonathan Ellis
05/26/2022, 5:53 PMBig Chungus
05/26/2022, 6:07 PMJonathan Ellis
05/26/2022, 6:09 PMephemient
05/26/2022, 6:09 PMdynamic
lets you write bar.test = "a"
just like you can in JS, which you could consider a plus and/or a minusJonathan Ellis
05/26/2022, 6:10 PMBig Chungus
05/26/2022, 6:27 PMJonathan Ellis
05/26/2022, 6:32 PM