SecretX
02/29/2024, 11:49 PMGilles Barbier
03/01/2024, 8:26 AMMatt Nelson
03/01/2024, 5:05 PMjava.io.OutputStream
???Edoardo Luppi
03/01/2024, 6:59 PMtypealias Done = (err: Any? /* use undefined for default */) -> Unit
typealias Func = (/* this: Context, */ done: Done) -> Unit
external class Test : Runnable {
constructor(title: String, fn: Func)
}
And this usage:
val fn: Func = {
inst.example()
}
suite.addTest(Test("example", fn))
The outputted code for val fn: Func
is:
return function (it) {
$inst.example_3o7jbu_k$();
return Unit_getInstance();
};
Note the it
argument is present even if it's not used.
This is problematic when the JS code checks the number of arguments of the function.
Should the JS compiler get rid of unused arguments like in this case?Edoardo Luppi
03/02/2024, 2:32 PMnode
or browser
?
Example:
compilations.configureEach {
binaries.forEach {
// Here I can get jsDevelopmentLibraryDistribution, but I'm missing the Node or Browser disambiguation
val distributionTaskName = distributionTaskName(it)
soufianehamama9
03/02/2024, 9:12 PMsunnat629
03/03/2024, 10:09 PMKevin Burgmann
03/05/2024, 9:07 AM@JsExport
), is there any possibility to set the module name, which by default is packageA.packageB.packageC.packackgeD.theClassName
? For example, the code using a Kotlin npm module right now has to look like the screenshot attached, is there any option to maybe drop the whole long package name?Edoardo Luppi
03/05/2024, 11:33 AMKotlinTest
and KotlinJsTestFramework
. Is extending those base classes the way?Chrys
03/05/2024, 12:01 PMMatthias Geisler
03/06/2024, 7:20 AMRichard Ulysse
03/06/2024, 4:49 PMzyfuni
03/07/2024, 10:36 AMstatic _createHelper(SubHasher) {
let result = (message, cfg) => new SubHasher(cfg).finalize(message);
result.loadWasm = async () => {
if (!SubHasher.wasm) {
await SubHasher.loadWasm();
}
};
result.outputSize = SubHasher.outputSize;
return result;
}
And I found a official doc, but it not tell me how to invoke MyClass as Function
https://kotlinlang.org/docs/js-interop.html#declare-static-members-of-a-class
In JavaScript you can define members either on a prototype or a class itself:
function MyClass() { ... }
MyClass.sharedMember = function() { /* implementation */ };
MyClass.prototype.ownMember = function() { /* implementation */ };
There is no such syntax in Kotlin. However, in Kotlin we have companion
objects. Kotlin treats companion objects of external
classes in a special way: instead of expecting an object, it assumes members of companion objects to be members of the class itself. MyClass
from the example above can be described as follows:
external class MyClass {
companion object {
fun sharedMember()
}
fun ownMember()
}
Robert Jaros
03/11/2024, 11:13 PMCsászár Ákos
03/13/2024, 1:38 PMindex.html
file to the resources directory and then I tried to run the jsBrowserRun
task.
How can I add my kotlin code as a script to the html file?
I assume I need to generate a .js file or it is done automatically when I run jsBrowserRun.
Can someone explain to me how it works?Erik
03/13/2024, 4:21 PMRobert Jaros
03/14/2024, 1:27 PMwebpack.config.d
so probably I can create a custom gradle task to do the same, but is there any other option?Rafał Kuźmiński
03/14/2024, 3:48 PMEdoardo Luppi
03/14/2024, 4:21 PM-Xir-generate-inline-anonymous-functions
introduced? I can't find resources on it on the internet.Edoardo Luppi
03/14/2024, 9:20 PMBernhard
03/15/2024, 9:46 AMCsászár Ákos
03/15/2024, 11:54 AMkotlinx.datetime
with @js-joda/timezone
and then to run jsBrowserProductionWebpack
. Every time I need to add "@js-joda/core": "3.2.0"
as dependency to the generated package.json
file, otherwise I will get an error (Module not found: Error: Can't resolve '@js-joda/core'
) in the project where I imported the library.
Is there any way to make that dependency visible for the client application?Bernhard
03/15/2024, 1:34 PMStefan Oltmann
03/15/2024, 2:15 PMStefan Oltmann
03/15/2024, 9:19 PMBernhard
03/15/2024, 9:31 PMhikamaeng
03/17/2024, 11:27 AMrootProject.plugins.withType<NodeJsRootPlugin> {
rootProject.the<NodeJsRootExtension>().npmInstallTaskProvider.configure{
inputs.files("package.json", "yarn.lock")
outputs.dir("node_modules")
}
}
rootProject.plugins.withType<YarnPlugin>{
rootProject.the<YarnRootExtension>().yarnLockMismatchReport = YarnLockMismatchReport.NONE
rootProject.the<YarnRootExtension>().reportNewYarnLock = false
rootProject.the<YarnRootExtension>().yarnLockAutoReplace = false
}
After this setting, the build time for KotlinJS has dramatically decreased.
Especially, the configuration of npmInstallTaskProvider was effective.Bernhard
03/17/2024, 4:12 PMStefan Oltmann
03/18/2024, 8:03 AMKim.readMetadata(bytes).toString()
should be enough to verify.Seth Madison
03/19/2024, 4:36 AMexternal interface
of the args to allow for js-style object arguments? I’m imagining:
@JsConstructor
@JsExport
data class ImportantData(foo: String, bar: Int)
Would end up generating JS-only code like:
external interface ImportantDataArgs {
val foo: String
val bar: Int
}
inline fun createImportantData(args: ImportantDataArgs): ImportantData {
return ImportantData(foo = args.foo, bar = args.bar)
}
That would ultimately generate a JS function that would be typed so that you could do:
createImportantData({
foo: "hello",
bar: 123
});
Does something like this already exist?