Artur Gniewowski
01/18/2022, 11:04 AMgaetan
01/18/2022, 11:08 AMrootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin::class.java) {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "..."
}
goncalossilva
01/18/2022, 5:28 PMNorbi
01/19/2022, 5:34 PMjsBrowserDevelopmentRun
, I get the following "internal compiler error", without any context about the cause of the problem.
Do you have any idea how can I find the root of the problem?
Besides, jsBrowserProductionRun
seems to work OK (but it is too slow to be usable instead of jsBrowserDevelopmentRun
).
java.lang.AssertionError: Assertion failed
at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.JsAstUtilsKt.translateCallArguments(jsAstUtils.kt:343)
at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.JsAstUtilsKt.translateCall(jsAstUtils.kt:111)
at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrElementToJsStatementTransformer.visitCall(IrElementToJsStatementTransformer.kt:140)
jeff
01/21/2022, 3:40 PMreadLine()
in Kotlin/JS (nodejs target)?Peter
01/22/2022, 9:31 PM.left-slide {
height: 100%;
width: 35%;
position: absolute;
top: 0;
left: 0;
transition: transform .5s ease-in-out;
}
So far I have
styledDiv {
css {
height = LinearDimension("100%")
width = LinearDimension("35%")
position = Position.absolute
top = LinearDimension("0")
left = LinearDimension("0")
transition = ???
}
...}
and I don't know how to create this transition.
Is someone able to help me ?
Thank you in advancejeff
01/24/2022, 8:00 PMkotlin {
js(IR) { ... }
}
and when I try to add ksp:
plugins {
...
kotlin("js") version "1.6.10"
id("com.google.devtools.ksp") version "1.6.10-1.0.2"
}
it gives me this error:
You already registered Kotlin/JS target with another compiler: legacy
Googling indicates that ksp does support IR, I think? What am I doing wrong?Daniel Tweedy
01/26/2022, 12:09 AMshaktiman_droid
01/26/2022, 3:10 PM1.6.10
Should we commit this file kotlin-js-store/yarn.lock
or gitignore
it?
Based on Github search, I see repos where they add it and some others where they do not keep it
And there is this comment on this channel where @Oliver.O says that the intention is to track it on version control
Can someone please clarify on this?Nikky
01/26/2022, 5:22 PMe: Could not find "org.jetbrains.kotlinx:kotlinx-serialization-json" in [C:\Users\nikky\AppData\Local\kotlin\daemon]
has anyone seen this before ?
more in :thread-please:ankushg
01/26/2022, 5:29 PM@JsExport
, and
• if there's any automated way to convert coroutines/flows to callbacksImran/Malic
01/28/2022, 8:31 AMtoASCII
here, my dependency definition looks like this
jsMain {
dependencies {
api(npm("punycode", "2.1.1"))
api(npm("urlencode", "1.1.0"))
api(npm("buffer", "6.0.3"))
api(npm("string_decoder", "1.3.0"))
}
}
and the file punycode.kt looks like this:
@JsModule("punycode")
@JsNonModule
@JsName("toASCII")
public external val toASCII: (domain: String) -> String
But it fails with:
Uncaught TypeError: toASCII is not a function
at /var/folders/qq/0zkljkj12jb9m0jnwftykyd00000gn/T/_karma_webpack_216427/commons.js:100744:17
TypeError: toASCII is not a function
at UriCompatibility.encodeDNSHost_6wfw3l_k$ (/var/folders/qq/0zkljkj12jb9m0jnwftykyd00000gn/T/_karma_webpack_216427/commons.js:100744:17)
at _no_name_provided__274.invoke_6wfw3l_k$ (/var/folders/qq/0zkljkj12jb9m0jnwftykyd00000gn/T/_karma_webpack_216427/commons.js:97821:46)
Rohan Maity
01/28/2022, 11:00 AMRohan Maity
01/29/2022, 11:28 AMKvision
and kotlin react
for building JS target in a multiplatform project ?
I am looking for Stability here as well which could work in multiplatform environment ?Nolan
01/31/2022, 4:50 PMLuca
02/01/2022, 5:38 AMweb3.eth.Contract
? Forgive me if this is a stupid question, as I am not the most familiar with js. I am more used to standard kotlin/OOP.
I've figured out that an instance of web3.eth.Contract
must be created where web3
must be an actual instance of a Web3
class (created new Web3(...)
)
So I cannot simply create a contract instance by calling new Web3.eth.Contract(...)
For example js("""new (new Web3(window.ethereum)).eth.Contract(JSON.parse('...'), '...' )""")
will create a valid instance of a Contract
But, when I attempt to create an instance of a kotlin defined contract:
@JsModule("web3-eth-contract")
@JsNonModule
open external class Contract constructor(jsonInterface: Array<AbiItem>, address: String, options: ContractOptions)
by calling
val contract = Contract (jsonInterface = abis as Array<AbiItem>, address = adr)
An instance of Contract
IS created successfully, however it is worthless because the created contract seems to rely on a parent instance of Web3
, (like in the first example I mentioned).
How can I create a Contract class in kotlin, that is instantiated in the same way as js("""new (new Web3(window.ethereum)).eth.Contract(JSON.parse('...'), '...' )""")
?janvladimirmostert
02/02/2022, 12:55 PMfunction blah(...args) { console.log(args) }
running this:
blah`testing-${1}-${2}-${3}`
I get a list of parts (separators between ${}), pre/post-fix and values
0: (4) ['testing-', '-', '-', '', raw: Array(4)]
1: 1
2: 2
3: 3
length: 4
Is there anything planned for Kotlin that would allows taking a String template and splitting it up like that at compile time?
(similar to how to trimIndent() is processed at compile time, a compile time mechanism that can decompose a String template into its static and dynamic parts)
val blah = """
testing-${1}-$var2-${var3 + 1}
""".trimIndent()
blah.decompose() // outputting the static parts, listOf("testing", "-", "-", "") and the dynamic parts, listOf(1, var2, { var3 + 1}())
Just wondering how else one would replicate what lit-html, lit-element, uhtml and many of these JS frameworks are doing in pure JavaScriptansman
02/02/2022, 3:58 PM-Xir-property-lazy-initialization
which doesn’t really do anything (actually increases our size). When paired with -Xir-per-module
it reduces the size by 75%! However, this is only because it’s missing some imports. We use 3 libraries:
• Kotlinx serialization
• Kotlinx immutable collections
• Kotlin stdlib
I see 5 JS files as expected (two for serialization) in the build directory but the module JS file only contains this:
}(module.exports, require('./kotlin-kotlin-stdlib-js-ir.js'), require('./kotlinx-serialization-kotlinx-serialization-core-js-ir.js')));
So the bundle fails because one of the kotlinx serialization (the JSON part) and the kotlinx immutable is missing from the final, webpacked, JS file. Is this a bug or did I miss something?Exerosis
02/03/2022, 10:41 AMnet
? Or do I need to write my own to use those things?andylamax
02/04/2022, 7:55 PMJs(IR) { browser() }
// or
Js(IR) { nodejs() }
Big Chungus
02/06/2022, 10:51 AMclass TSClassOne {
constructor(someProp: string) {
...
}
}
class TSClassTwo {
TSClassOne: new (someProp: string) => TSClassOne
}
How to declare it in K/JS?
external class TSClassOne(someProp: String)
external class TSClassTwo {
var TSClassOne: dynamic // actual: `new (someProp: string) => TSClassOne`, how do I tell kotlin that? `(String) -> TSClassOne` does not work as it's not invoking `new` call
}
kk57
02/07/2022, 12:40 AMAyfri
02/08/2022, 10:59 AMSean Proctor
02/08/2022, 2:40 PMgenerateExternals=true
to the gradle dependency and I get an error "Unresolved reference: JSX". Looking at the TypeScript definition, JSX is used but not imported. Is there a way to work around this?Ayfri
02/08/2022, 4:38 PMmbonnin
02/09/2022, 2:22 PMError: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
But my test needs to run longuer than 2000ms. Is there anything I can do to increase that timeout?andylamax
02/09/2022, 5:01 PM@JsExport
, properties of interfaces/abstract classes, are still mangled. It should be known that methods
are not mangled at all
Reproducer
Reproducer can be found at ManglingImplementationTestandylamax
02/09/2022, 11:29 PMsealed class WatchMode {
companion object {
val DEFAULT: WatchMode = CASUALLY
}
}
object EAGERLY : WatchMode()
object CASUALLY : WatchMode()
Generates the following type definitions
class WatchMode {
private constructor();
readonly Companion: {
readonly DEFAULT: live.WatchMode;
};
}
const EAGERLY: {
} & live.WatchMode;
const CASUALLY: {
} & live.WatchMode;
This makes it impossible to get the value of WatchMode.DEFAULT
from js/typescript impossible, because one would need to create an instance of WatchMode
(whose constructor is private) and then get the DEFAULT
property from Companion
. Why is it a property, can't it be defined on WatchMode
instead of it's prototype
?
N;B.
When the hierarchy is defined as show bellow
sealed class WatchMode {
companion object {
val DEFAULT: WatchMode = CASUALLY
}
object EAGERLY : WatchMode()
object CASUALLY : WatchMode()
}
The generated types are still unsable from js/typescript code. Funny thing is, classes work like a
class WatchMode {
private constructor();
readonly Companion: {
readonly DEFAULT: live.WatchMode;
};
readonly EAGERLY: {
} & live.WatchMode;
readonly CASUALLY: {
} & live.WatchMode;
}
Is there a known workaround for this? or a reported ticket somehow?SirNapkin1334
02/11/2022, 1:27 AMString
are deprecated in Kotlin/JS!andylamax
02/12/2022, 1:16 AM1.6.20-M1
. I gotta admint, @JsExport
got the love it truly deserves
Kudos to the whole team for such accomplishments. A lot of my issues (infact, all I have reported recently) have been already solvedandylamax
02/12/2022, 1:16 AM1.6.20-M1
. I gotta admint, @JsExport
got the love it truly deserves
Kudos to the whole team for such accomplishments. A lot of my issues (infact, all I have reported recently) have been already solvedankushg
02/12/2022, 1:54 AMandylamax
02/12/2022, 7:20 AMhfhbd
02/12/2022, 10:12 AMandylamax
02/12/2022, 9:12 PMexternal class is mapped to any
problem. Coz to me it works just fine
package battleground.problem
@JsExport
external interface User {
var name: String
var email: String
}
@JsExport
val pete: User = jso { }
Yields
export namespace battleground.problem {
interface User {
name: string;
email: string;
}
}
export namespace battleground.problem {
const pete: battleground.problem.User;
}
Promise
called a Later
, it can be found here https://github.com/aSoft-Ltd/foundation/tree/master/foundation-runtimes/laterhfhbd
02/12/2022, 10:10 PMandylamax
02/13/2022, 2:32 AMUse a classThis code
package battleground.problem
@JsExport
external class Promise<T>
@JsExport
val promise: Promise<Unit> = TODO()
generates the following types
export namespace battleground.problem {
class Promise<T> {
constructor();
}
}
export namespace battleground.problem {
const promise: battleground.problem.Promise<void>;
}
Are you sure you tried that on 1.6.20-M1
?
However, I have noticed kotlin.js.Promise<T>
is indeed exported as any // kotlin.js.Promise<T>
@JsExport
external class Promise<T> {
companion object
}
Does not compile. For it to compile, you either remove the companion object,
or @JsExport
You can't seem to have both and make it workhfhbd
02/13/2022, 11:10 AMPromise
class does not work with typescript interoperability, because it is not mapped to js.Promise
.andylamax
02/13/2022, 1:28 PMcopy
the type definition in kotlin.js.Promise
into a file that is not inside a package. This is indeed a workaround thoughGrégory Lureau
02/14/2022, 10:33 AM@JsExport
and external
on the same class? It's just for testing 1.6.20-M1 or I'm missing something?andylamax
02/14/2022, 10:49 AMWhat's the point to useIf you just declare it asand@JsExport
on the same class?external
external
the generated .d.ts
won't include its definitions. @JsExport
makes your external class types available in the generated .d.ts