Matt Nelson
02/25/2026, 2:51 PMByteArray on WasmJs not being able to be used as a parameter in externally defined interfaces/classes is a huge blocker.
Anyone know if there are plans to provide access to the backing storage array that the ByteArray implementation uses?turansky
02/25/2026, 5:31 PMInt8Array ?Matt Nelson
02/25/2026, 5:36 PMByteArray.unwrap() which returns a JsAny and is only available from wasmJs source sets.
I'd simply like to mitigate the awful amount of array copying being done when bridging the gap between native Js code and Kotlin code.rnett
02/25/2026, 5:51 PMMatt Nelson
02/25/2026, 5:53 PMUint8Array(kotlinByteArray.asInt8Array().buffer) laugh cry face palmturansky
02/25/2026, 5:56 PMMatt Nelson
02/25/2026, 6:07 PMInt8Array.bufferMatt Nelson
02/25/2026, 6:09 PMByteArray.asInt8Array() << copy no
ByteArray.toInt8Array() << copy yesturansky
02/25/2026, 6:11 PMcopy noDo you need shared memory?
Matt Nelson
02/25/2026, 6:15 PMUint8Array to utilize (e.g. Node.js stream.Writable.write only added other TypedArray in version 18 , or the Crypto fill functions).
I do not want to create a new wholly separate instance. I want to create a new view for the underlying ArrayBuffer so native, externally defined functions can manipulate the ArrayBuffer , thus manipulating the ByteArray indices.
Currently, WasmJs implementation of ByteArray is just a wrapper around an internal WasmJsByteArray whereby all ByteArray calls are delegated to ByteArray.storage. It is inaccessible.turansky
02/25/2026, 6:20 PMasIntArray() - we can add it in Kotlin WrappersMatt Nelson
02/25/2026, 6:22 PMByteArray.storage value?turansky
02/25/2026, 6:23 PMturansky
02/25/2026, 6:27 PMMatt Nelson
02/25/2026, 6:27 PMMatt Nelson
02/25/2026, 6:28 PMturansky
02/25/2026, 6:31 PMHow's that?On JS and JVM you can access internal members with suppress
Matt Nelson
02/25/2026, 6:33 PMturansky
02/25/2026, 6:35 PMMatt Nelson
02/25/2026, 6:36 PMMatt Nelson
02/25/2026, 6:36 PMbashor
02/25/2026, 11:26 PMMatt Nelson
02/26/2026, 12:37 AMinternal external sealed interface SomeJsThing {
@VeryWellNamedAnnotationLol
fun update(data: ByteArray, offset: Int, len: Int)
}turansky
02/26/2026, 1:50 PMMatt Nelson
02/26/2026, 2:27 PMByteArray to externally defined things on WasmJs so that it can do it's thing and mutate, or read the data.
e.g. (source set jsWasmJsMain which is jsMain + wasmJsMain)
internal external sealed interface NodeJsFs {
fun writeSync(fd: Int, buffer: ByteArray, offset: Int, length: Int): Int
}
The above code will not work because ByteArray on wasmJs is not JsAny
It forces me to do the following
internal external sealed interface NodeJsFs {
fun writeSync(fd: Int, buffer: Uint8Array, offset: Int, length: Int): Int
}
fun write(buf: ByteArray, offset: Int, len: Int): Int {
val jsBuf = Buffer.allocUnsafe(len) // <<<< Would like to ELIMINATE
// copy buf to jsBuf
return fs.writeSync(someFd, jsBuf, 0, len)
}
Same goes for reading, or virtually any other externally defined Js thing.turansky
02/26/2026, 2:30 PMe.g. (source setwhich isjsWasmJsMain+jsMain)wasmJsMain
webMain ?Matt Nelson
02/26/2026, 2:30 PMMatt Nelson
02/26/2026, 2:30 PMturansky
02/26/2026, 2:33 PMJsByteArray can help in your caseMatt Nelson
02/26/2026, 2:34 PMJsByteArray?
Also that's not available from commonMainturansky
02/26/2026, 2:35 PMcommonMain ?Matt Nelson
02/26/2026, 2:35 PMMatt Nelson
02/26/2026, 2:37 PMJsByteArray, is that something in the standard library?turansky
02/26/2026, 2:38 PMas in JS and to in WasmJS will solve your problemturansky
02/26/2026, 2:38 PMMatt Nelson
02/26/2026, 2:39 PMas in wasmJsturansky
02/26/2026, 2:39 PMturansky
02/26/2026, 3:04 PMas/to extensions?Edoardo Luppi
04/09/2026, 6:11 PMstorage, what would you be able to do with it? Looks limited as far as I can see.Edoardo Luppi
04/09/2026, 6:11 PMUint8Array to a WebAssembly ByteArray is extremely inefficient.Edoardo Luppi
04/09/2026, 7:03 PM