Gunslingor
08/12/2020, 9:07 PMexternal interface Block {
var id: String
var label: String
var select: Boolean
var attributes: Attributes
var content: Content //string or jsObject
var activate: Boolean
}
external interface Attributes {
var `class`: String
}
external interface Content {
var type: String
}
Vampire
08/14/2020, 9:28 AM@types/semver
to my dependencies and now Dukat is super unhappy, whining with Cannot read property 'fileName' of undefined
as reported at https://github.com/Kotlin/dukat/issues/365.
Anyone any idea what goes wrong and how to work-around it?3bdoelnaggar
08/14/2020, 2:48 PMMark Iantorno
08/14/2020, 5:06 PMstyledSvg{...}
? I am not clear on how to set the .svg file as the src for the image or how to set/change the fill
property of the svg to change the color. Any advice would be appreciated.Vampire
08/14/2020, 10:53 PM@actions/http-client
and want to use HttpClient().post(...
.
The ...d.ts
has
export interface IHeaders {
[key: string]: any;
}
[...]
post(requestUrl: string, data: string, additionalHeaders?: ifm.IHeaders): Promise<ifm.IHttpClientResponse>;
Dukat made from that
external interface IHeaders {
@nativeGetter
operator fun get(key: String): Any?
@nativeSetter
operator fun set(key: String, value: Any)
}
[...]
open fun post(requestUrl: String, data: String, additionalHeaders: IHeaders = definedExternally): Promise<IHttpClientResponse>
My first approach was basically naively following the IDE autocompletion which of course does not work (no additional headers set):
val response = HttpClient().post(
requestUrl = "<http://localhost:9999/api/GetFiles>",
data = "type=ProductId&url=$productId",
additionalHeaders = object : IHeaders {
override fun get(key: String): Any? = when (key) {
"Content-Type" -> "application/x-www-form-urlencoded"
else -> null
}
override fun set(key: String, value: Any) = error("headers are read-only")
}
).await()
My next try was to do what my guts suggested and made the compiler happy:
val response = HttpClient().post(
requestUrl = "<http://localhost:9999/api/GetFiles>",
data = "type=ProductId&url=$productId",
additionalHeaders = mapOf("Content-Type" to "application/x-www-form-urlencoded") as IHeaders
).await()
IJ complains about "Unchecked cast to external interface: Map<String, String> to IHeader" and it also does not work, but sends the additional headers
_keys_up5z3z$_0: null
_values_6nw1f1$_0: null
_keys_qe2m0n$_0: null
_values_kxdlqh$_0: null
internalmap_uxhen5$_0: [object Object]
equality_vgh6cm$_0: [object Object]
_entries_7ih87x$_0: null
Vampire
08/15/2020, 8:29 AM@actions/cache
to my npm dependencies.
Now I get 2285 compile errors because Dukat is creating many duplicated declarations. 😕
Anyone seen this before and has some idea?Dhirendra Patil
08/15/2020, 9:06 AMrnentjes
08/17/2020, 7:02 PMandylamax
08/17/2020, 8:27 PMVampire
08/18/2020, 2:17 PMnodeJs
target, with 1.3.72 there was a run
task automatically.
Now with 1.4.0 there is no run
task anymore.
You can use binaries.executable()
then you at least get a nodeRun
task, but no run
task.
Is that an expected change?
I cannot remember having seen this in any of the update blog entries.Robert Jaros
08/18/2020, 4:03 PMjQuery(v)
is translated to jQuery.invoke(v)
in generated JS file. My jQuery
is defined as external val
. Of course half of my tests are failing with IR (all working fine with legacy backend). Is it a bug?Vampire
08/18/2020, 6:35 PMrequire('@vercel/ncc')(input, {
sourceMap: true
})
How do you properly formulate this as externals definition so that it can be used in Kotlin code?Robert Jaros
08/18/2020, 8:54 PMdata class Foo(val a: Int, val b: String)
we have a
and b
on the JS side. But new IR backend generates _a
and _b
. I think it will break a lot of code. Is this intentional change?Robert Jaros
08/18/2020, 11:23 PMVampire
08/18/2020, 11:58 PMkotlin { js(IR) { useCommonJs(); binaries.executable(); nodejs() }
`tasks.compileKotlinJs.get().outputFile.absolutePath`evaluates to <project dir>/build/classes/kotlin/main/<project>.js
but that there are no such files but only a folder default
with content?Vampire
08/19/2020, 12:36 AMcompileProductionExecutableKotlinJs
and compileDevelopmentExecutableKotlinJs
?
According to their outputFile
property they both write to <project dir>/build/js/packages/<project>/kotlin/<project>.js
which per-se is maybe not the best idea already.
But what is the difference, I can find neither in the docs.Vampire
08/19/2020, 9:18 AMgradlew :run
, I get ReferenceError: NodeJS is not defined
. 😞
First line where it happens is var ReadableStream = NodeJS.ReadableStream;
NodeJS.ReadableStream
comes from Dukat generated files for @actions/http-client
and is defined in kotlinx-nodejs
0.0.6
.
What do I need to do to have those included properly?
If I navigate from the http-client
file via Ctrl+Click
, a (pseudo?-)file inside the 0_NodeJS.knm
is opened that does not have any @JsModule
annotation, package NodeJS
and @file:JsQualifier("NodeJS")
.Eamonn Boyle
08/19/2020, 10:42 AMval BAT_WIDTH = 8
Other File
private val batGeometry = BoxGeometry(BAT_WIDTH, 1.0, 1.0)
The BAT_WIDTH here is undefined. I can get around the issue by putting my constants in a singleton object, but worried about initialisation order generally now. Any docs on this or anyone know how it works?
The generated JS seems to be,
var batGeometry;
...
var BAT_WIDTH;
...
batGeometry = new BoxGeometry(BAT_WIDTH, 1.0, 1.0);
...
BAT_WIDTH = 8;
Robert Jaros
08/19/2020, 12:32 PMexternal interface BtOn {
}
interface SnOn<T> : BtOn {
var self: T
}
@Suppress("UnsafeCastFromDynamic")
fun on(target: Any): SnOn<Any> {
val obj = js("{}")
obj["self"] = target
return obj
}
fun main() {
val x = on("test");
console.log(x.self);
}
It fails with x._get_self_ is not a function
. Is it a bug in the compiler backend or is my code just wrong?Robert Jaros
08/19/2020, 12:57 PMinline fun <reified T> Any?.createInstance(vararg args: dynamic): T {
val jsClass = this
val argsArray = (listOf<dynamic>(null) + args).toTypedArray()
return js("new (Function.prototype.bind.apply(jsClass, argsArray))").unsafeCast<T>()
}
like this:
external interface Ext
val constructor: Any = require("...").something // returns a function which should be called with new operator in JS
val ext: Ext = constructor.createInstance(it)
It doesn't work with IR anymore. How can I replace this?Robert Jaros
08/19/2020, 1:03 PMdynamic
property which I know is a constructor and should be used with new
. Any other way to force new
in generated JS?Joost Klitsie
08/19/2020, 3:27 PMmkosm
08/19/2020, 5:41 PM@JsName("default")
with the IR backend enabled? I'm getting this error:Robert Jaros
08/19/2020, 7:15 PMtylerwilson
08/19/2020, 8:34 PMFAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':salonbiz-library:jsTestPackageJson'.
> NPM Dependencies already resolved and installed
Derek Ellis
08/19/2020, 11:20 PMactual
implementation of a class marked with @JsExport
and some properties like id
or data
. What I'm trying to do is to make it possible for an instance of this class to be passed to some other js library that uses those properties internally. The library accepts plain JS objects, and I think it might even turn it into JSON for validation or something, but in any case the library can't see those properties since with the new IR compiler they are mangled to _id
and _data
and it can't make use of the computed properties defined on the class.
@JsExport
didn't change it, neither did external interface
, so is there any other way to work around this issue? Is this something worth opening an issue for? I don't think there's one dedicated to the name mangling in the new IR compiler yet.Eamonn Boyle
08/20/2020, 9:31 AMStan Kocken
08/20/2020, 12:10 PMrunDceJsKotlin
). I have a .js
file, but everything is obfuscated inside. I just want to have a public API for my .js
library to be used by a web-developer. The JsName
annotation is not helping.
I just want to have a simple method called compute()
that calls other kotlin code (shared with other) and callable from a web-developer through a JS library (not node) I would provide.Robert Jaros
08/20/2020, 12:48 PMError: This marker function should never been called. Looks like compiler did not eliminate it properly. Please, report an issue if you caught this exception.
How should I report this issue? There is not really much more information but I suppose it comes from serialization.iari
08/20/2020, 6:21 PMiari
08/20/2020, 6:21 PMturansky
08/20/2020, 6:57 PMString.repeat
for custom implementation