KMbed 1.8.3 is out now! :slightly_smiling_face: - ...
# feed
a
KMbed 1.8.3 is out now! ๐Ÿ™‚ โ€ข Experimental support for JS and JVM targets โ€ข The
R
global has been renamed to
Res
in order to not clash with Android down the line once support is added โ€ข KDoc for the runtime APIs โ€ข Added
kmbed
project extension to Gradle Plugin for fine grained configuration of the resource compiler (see README examples) https://github.com/karmakrafts/KMbed/releases/tag/1.8.3
kodee happy 5
๐Ÿš€ 7
K 7
โค๏ธ 1
u
Wow, If I understand correctly, I can use it to create a module that embeds the native of gstreamer for mac and windows for my library ?
โœ… 1
a
Yes, you can use this to include shared objects in a kotlin library :)
๐Ÿš€ 1
u
Wow ๐Ÿคฉ Thanks a lot !
a
any type of file really. i even provide a function specifically with native libs in mind.
The JS and JVM targets don't support it right now tho, i should fix that! :D
u
Wow that would be so cool, because I need it for the jvm!
a
Actually, i'll do you one better. Just had a great idea.
u
??
a
I'll add an extension to the JVM runtime impl so you can load native libs directly from a resource without handling the file stuff yourself
๐Ÿคฉ 2
I could use that myself too
u
I'll wait then!
a
Building a snapshot :)
๐Ÿ‘ 2
m
What about Wasm support?
๐Ÿ‘€ 1
a
That shouldn't be a problem! Gonna add it next snapshot ๐Ÿ™‚ Also adding an optional kmbed-ktor module so you can static-route your resources too ^^
K 4
s
That would be so awesome if this library actually can bundle GStreamer for the Compose Media Player lib on Linux & macOS ๐Ÿคฉ
u
@Stefan Oltmann You mean windows and mac os? Gstreamer is already integrated into linux ๐Ÿ™‚
But yes that would be an easier way to do it.
s
Ah, yes, you mentioned that gstreamer comes pre-installed with the system. So my question was about bundle GStreamer with the macOS version. Itโ€™s great if this tooling enables that. :)
s
@Alexander Hinze awesomeโ€ฆ.The README mentions using zlib. Does this mean that binaries compiled with kmbed require zlib to be available on desktop platforms, especially Windows?
s
AFAIK Kotlin Native comes bundled with zlib. At least the native binaries of Ashampoo Kim use it and there is no extra step. ๐Ÿค”
๐Ÿ‘ 1
a
@Michael Paus 1.8.5.36-SNAPSHOT is ready to try, i added WASM support :)
๐Ÿ‘ 1
m
How is zlib compression handled in Wasm?
a
As of right now, i use pako for JS and WASM, but i am open for suggestions/improvements :)
m
Just because of some discussion in another thread. How much is the extra size of pako in your case?
a
Pako unpacked size is ~1.64MB according to NPM, i can measure the actual difference in a built klib if you like :)
The reason i used it is mainly because its almost as fast as the zlib c impl on modern JS engines
m
Thatโ€™s strange. Are we talking about different things? According to https://bundlephobia.com/package/pako@2.1.0 it is just 14.2 kB compressed.
a
Nope that's the one i mean, i meant the uncompressed size before :)
At least that's what NPM shows me
m
It canโ€™t be that much for the part that you actually have to bundle and download if you use it in a browser web app. A competitor advertises, e.g., that it can be done in just 8 kB. https://www.jsdelivr.com/package/npm/fflate
๐Ÿ‘ 1
a
That's really nice then, as i said, i just regurgetated what NPM told me, i can measure the real world impact in a bit ^^
m
I couldnโ€™t resist. I just downloaded pako.min.js from here https://www.jsdelivr.one/package/npm/pako?tab=files and it has exactly 47kB. Is this not all you need for this functionality?
a
I only use the inflate() function so probably. Not sure, i just added it as a default implementation(npm(...)) and went with it. The size i told you is just what i could read off the net. I did not check to minify that yet.
I will check on this later, if i can make it smaller, i will ๐Ÿ™‚
m
So, we are talking about a size range from 8kB to 1640kB here or a ratio of 1:205 ๐Ÿง. ๐Ÿ˜‰
a
According to what NPM told me, yes.
s
My metadata library also uses pako for zlib compression. Itโ€™s the best I found so far.
๐Ÿ™Œ 1
It would still be great if someone sits down and implementing this in pure Kotlin. Before choosing pako I tried to do that, but the math is beyond m understanding. I hope some of the guys inventing the 101th logging framework for Kotlin would instead do that. ๐Ÿ˜„
๐Ÿ˜ 1
@TheArchitect123 What about you? ๐Ÿ˜„
a
I actually started a fully multiplatform zlib library for Kotlin a while ago i eventually want to use in KMbed too.
I could easily port the C code but the math is mostly beyond me as well
s
The pako version is a bit easier to understand I think.
a
I'm more of a C/C++ than web person so idk if that applies to me tbh ๐Ÿ˜‚
But fair point
s
This gaming framework korge has a zlib Kotlin implementation, but I was unable to extract it out there.
a
Hahaha i started mine for my Kotlin/Native game engine too ๐Ÿ˜‚
t
Well actually since you're talking about a logging framework, I already built one for Microsoft AppInsights (KMP) ๐Ÿ˜‚ ๐Ÿคฃ https://github.com/TheArchitect123/KmpAppInsights
a
We were not talking about a log framework
s
The maker of korge did a lot of useful things, but somehow cramped them all together so that they are not usable on its own.
๐Ÿ‘ 1
t
But logging frameworks, there's too many of them. I only built this one for a commercial project because I needed it. Since nothing else like it existed
s
Yeah, nobody needs just another logging framework. We have way too many.
a
Yeeep, i make my stuff as modular as possible
๐Ÿ‘ 1
I built my own logging framework for my engine too, but just because most KMP logger frameworks have no good native support
it even supports Logcat and ULS for native
s
@TheArchitect123 The quest was to make a zlib implementation.
I wouldnโ€™t mind multiple zlib implementations, if you build both one and I can compare, benchmark and choose. I like choice ๐Ÿ˜„
โœ… 1
a
Yep, choice is always good ๐Ÿ™‚
@TheArchitect123 if you are curious: https://git.karmakrafts.dev/kk/skroll
s
Having three good libraries for everything is fine. ๐Ÿ˜„ The issue with logging is that we already have 30 and people keep making more.
๐Ÿ˜‚ 1
a
I plan to officially release it soon
๐Ÿ’ฏ 1
I plan to add a slf4j-like bridge so you can use my impl with other logging APIs eventually
but that's only a thought so far
The README of the logger is just very out of date rn
s
Yes, a slf4j pendant is helpful. We discussed that in another thread. It would be best if JetBrains would make a choice and integrate one logging framework into the Stdlib , so people will stop making more ๐Ÿ˜„
โœ… 1
a
I just felt forced to do it because most logging frameworks don't offer much beyond println() appenders on Kotlin/Native ๐Ÿ˜•
s
Yeah, we have some very simple ones, but also some more advanced ones. Of course I would choose something thatโ€™s like slf4j with log4j backend.
๐Ÿ‘ 1
a
For JVM, definitly
s
Just that it must work on all platforms, yes. And have the option to swap out the backend.
a
Yeah
s
Right now, because there are too many, I actually donโ€™t use a logging framework. My side projects donโ€™t have logging at all and Ashampoo Photo Organizer uses Sentry directly. Too much choice can lead to failing making a decision at all. Especially back then all options were lacking, like you mentioned.
a
Totally understandable, my case is very purpose driven, but it wouldn't hurt to be able to generalize this kinda stuff like in the JVM world
s
We have some things like pure Kotlin zlib that are missing at all, which I wish people would concentrate on.
a
For now, my zlib Kotlib lib will wrap native zlib on native, Deflater/Inflater on JVM/Android and pako on JS/WASM. I'll give writing a pure Kotlin impl a shot this weekend ^^ I'll report back on the success/failure :D
๐Ÿ’ฏ 1
I mostly relied on the native impl since Kotlin/Native already has commonized bindings for it
m
Here you can see where this missing zlib support leads to. https://github.com/square/okio/issues/1442#issuecomment-2650498015
๐Ÿ‘ 1
a
I mean, to be honest, i don't agree with not including something like pako for JS for whatever reason, it doesn't make a real difference if you have JS impl or a Kotlin common impl, but i see the point of having more code to maintain without a common wrapper.
s
Nice! ๐Ÿ˜„ I feel like I am becoming a ecosystem coordinator ๐Ÿ˜ฌ Our hero Elie G. also made a logging library (https://github.com/kdroidFilter/KmpRealTimeLogger) before I was able convince him to use his skills to bring use the first-ever Compose Media Player ๐Ÿ˜… I guess I will now look around who else crafts logging frameworks and see if they can make something thatโ€™s really missing in the ecosystem instead. ๐Ÿ˜œ For example I also have a Kotlin native polybool implementation on my list, too. ๐Ÿ™‚
๐Ÿ‘€ 1
๐Ÿคฃ 1
a
That's cool! ^^ I just recently started taking my purpose driven Kotlin/Native only libs and making them fully multiplatform, i see lots of empty spaces for very rudimentary things and i would love to help plug those holes. Especially being able to offer a choice as you said.
๐Ÿ‘ 2
s
Thatโ€™s the right spirit! I think with kmbed you already just solved a big issue, because Eli G. was not sure how Compose Media Player can bundle the required native libs to play back video. According to his comment you brought a solution. ๐ŸŽ‰ ๐Ÿ™๐Ÿป
โค๏ธ 2
a
I am actually working on integrating KMbed into CMP at the moment hahaha, gonna make a PR once everything's working. It's a good real-world test for my code too.
๐Ÿ‘ 1
m
No kidding. I just started an internal project with the name
EmmentalerDemo
because Kotlin multiplatform has more holes than a piece of swiss cheese.
๐Ÿ˜‚ 2
a
Hahahahaha, that's a great name xD
t
If you guys need Compile time Dependency injection for your projects you can use mine. Supports All Platforms including Wasm. https://github.com/TheArchitect123/Atlas
a
We were talking about resource embedding but that looks really neat
s
I mean, to be honest, i don't agree with not including something like pako for JS for whatever reason, it doesn't make a real difference if you have JS impl or a Kotlin common impl, but i see the point of having more code to maintain without a common wrapper.
For Ashampoo Kim I would have preferred not to include that extra lib. Especially because I need to tell people to extra include that using
implementation(npm("pako", "2.1.0"))
a
I mean, one could also declare it as api(...) and just go with it that way
but not everyone wants that
s
I tried that first and it did not work.
Maybe it works now, didnโ€™t try for a long time.
a
Oh, that's odd, maybe that's a Kotlin/JS specific thing, not my domain of expertise
Fair enough, worth a try
s
Mine neither.
I would love to have pure Kotlin code and that pako thing annoys me.
a
Understandable, working with JS bindings sucks in general, which doesn't help
๐Ÿ’ฏ 2
s
@TheArchitect123 I asked you to craft a pure Kotlin zlib library. Can you do that or not?
t
I'm working AS FAST AS I CAN!! ๐Ÿ˜‚ ๐Ÿคฃ Hold on baby!!! @Stefan Oltmann
๐Ÿ‘ 1
๐Ÿ˜‚ 3
s
Oh, yes, I needed a lot of help from this Slack to get that working. Zalim gave me the code to integrate with pako. For me itโ€™s black magic.
t
๐Ÿ˜‚
o
I guess I will now look around who else crafts logging frameworks and see if they can make something thatโ€™s really missing in the ecosystem instead. ๐Ÿ˜œ
@Stefan Oltmann Sorry for hijacking the thread (again), but what if it's the other way around and someone(me) wants to create a logging framework just because it looks easier (in reality it's not) than other projects they work on? ๐Ÿ™‚
๐Ÿ˜„ 2
a
The less browser/JS stuff i have to do, the better ๐Ÿ˜‚
๐Ÿ’ฏ 2
t
I'm adding BrowserJS & Wasm support to my other library. Soon web will allot simpler @Alexander Hinze https://github.com/TheArchitect123/KmpEssentials
s
@Oleg Yukhnevich Yeah, I guess youโ€™re right about that. ๐Ÿ˜„ It became the first library to start, like a hello world. ๐Ÿ˜…
a
@TheArchitect123 That's neat ๐Ÿ™‚ But i will probably stick to my own impls since i want very specific features/APIs for my game engine. I will however definitly give it a look, maybe i can use it at work.
Left a star and a follow ๐Ÿ™‚
โค๏ธ 1
You know what? Imma clean up my zlib library and publish a build for testing multiplatform support. I'll post about it when its one ๐Ÿ™‚
๐ŸŽ‰ 3
I could really use it too, since KMbed AND my engine needs it internally
I'll provide kotlinx.io integration out of the box
๐Ÿ’ฏ 1
s
That sounds promising ๐Ÿ‘
a
Small update: rather than using pako on JS and introducing an additional dep, i will use the Compression Streams API: https://developer.mozilla.org/en-US/docs/Web/API/Compression_Streams_API
That way i still have a wrapper but i don't need an extra dep and extra lib/file size
its supported in all major browsers throughout
m
Thatโ€™s exactly what I proposed for Okio too (https://github.com/square/okio/issues/1442#issuecomment-2662720249) but I was told that this wonโ€™t work because of its non-blocking API. Would that be no problem for you?
๐Ÿ‘€ 2
๐Ÿ™Œ 1
a
No, it would not, i'll offer suspend AND non-suspend APIs. on web, i'll just wrap the Compression Streams API using runBlocking, seems absolutely acceptable to me in this case
m
No,
runBlocking
is not supported on wasmJs.
๐Ÿ‘€ 1
a
OH, i did not know that! I will only offer the blocking variants on supporting platforms then. Since this is an IO task more or less, we are fine with the API being suspend, not a problem.