frank
06/27/2020, 11:41 AMFoso
06/27/2020, 2:28 PMDeactivated User
06/28/2020, 11:11 AM@Test
fun testFailingIr2() {
val v = 1L shl 62
assertEquals("$v", v.toString())
}
Mina Eweida
06/29/2020, 5:01 PMbuild/js
found in root folder and publishing each package individually by checking the generated package.json which have workspaces
so I know how to navigate with my script through each package in workspaces and publish. But is there a better way to do it? I mean through gradle? Also when I checked the artifact generated for js per module, the package.json did not have dependencies with other modules in the same project which will be hard, that’s why I checked the build/js
folder instead.Justin Shapiro
07/01/2020, 5:08 PMkotlin.browser.window.setInterval
I get the following error:
ReferenceError: window is not defined
I thought I was only targeting browser
js("browser") {
browser {}
}
and that those tests are executed by karma in chrome. Am I wrong? Is there more to only targeting browsers and getting the tests to run in the headless browser?rnentjes
07/03/2020, 8:50 AMexternal interface AudioWorkletProcessor {
fun process(
inputs: dynamic,
outputs: dynamic,
parameters: dynamic
): Boolean
}
This is the actual class:
class MyAudioProcessor : AudioWorkletProcessor {
override fun process(
inputs: dynamic,
outputs: dynamic,
parameters: dynamic
): Boolean {
println("process")
if (outputs.isNotEmpty()) {
if (outputs[0].size == 2) {
println("found one output with 2 channels")
}
}
return true
}
}
The registerProcessor function expects a class constructor, I use ::MyAudioProcessor. Maybe that should be something else?
Btw, firefox gives this error message:
TypeError: Return value of AudioWorkletProcessorConstructor does not implement interface AudioWorkletProcessor.zeugederunity
07/03/2020, 10:34 AMInt8Array(data as ArrayBuffer).let {
ByteArray(it.length){ i ->
it[i]
}
}
Use case: I am using CBOR and plain ByteArrays to communicate via websocket.jean
07/03/2020, 6:41 PMBig Chungus
07/06/2020, 3:50 PMx == y -> true
haviing
val x = {null}
val y = {null}
Sebastian Aigner
07/06/2020, 5:02 PMnpm
dependencies in Gradle now require versions to be specified explicitly. If you want to just take whatever version, you can specify *
– but that’s not recommended for obvious reasons.
- cssSettings
gets renamed to cssSupport
, and isn’t enabled by default anymore. To turn on CSS support, set cssSupport.enabled = true
in your webpackTask
, runTask
and testTask
.
- kotlin.dom
and kotlin.browser
are moving to kotlinx.dom
and kotlinx.browser
. Same APIs, different packages, so all that is needed is to adjust your import
statements.
We’ll lay out the rationale for these changes in the next blog post as well. Happy experimenting!
Find the full changelog at https://github.com/JetBrains/kotlin/blob/1.4-M3/ChangeLog.md#js-toolszeugederunity
07/07/2020, 11:13 AMexport type
thing, i dont get how to wrap this for KotlinJS)frank
07/07/2020, 12:59 PMnpm()
function in my Gradle but throw error:
Execution failed for task ':kotlinNpmInstall'.
> Cannot find kotlin@1.4.0-M2 in yarn.lock
In yarn exists 1.4.0-M2 version (attach img.)
dependencies {
implementation(npm("kotlin", "1.4.0-M2"))
}
frank
07/08/2020, 2:37 PMkotlin-react-dom:16.13.1-pre.109-kotlin-1.4-M3
throws error cant find kotlinx-html-js:0.7.1-1.4-M3
.
I solved it implement kotlinx-html-js:0.7.1
in my Gradle.
@Ivan Kubyshkin [JetBrains] , Is there a repository where it is hosted `kotlinx-html-js:0.7.1-1.4-M3`*?*
Error:
Could not determine the dependencies of task ':webapp:packageJson'.
> Could not find org.jetbrains.kotlinx:kotlinx-html-js:0.7.1-1.4-M3.
Required by:
project :webapp > org.jetbrains:kotlin-react-dom:16.13.1-pre.109-kotlin-1.4-M3
project :webapp > org.jetbrains:kotlin-styled:1.0.0-pre.109-kotlin-1.4-M3
Gradle Repositories:
allprojects { // :parent module
repositories {
maven("<https://dl.bintray.com/kotlin/kotlin-eap>")
jcenter()
mavenCentral()
}
}
repositories { // :webapp module
maven("<https://kotlin.bintray.com/kotlin-js-wrappers/>")
}
Sean Najera
07/08/2020, 6:29 PM// MPP - JS & common dependencies
sourceSets["commonMain"].dependencies {
implementation(kotlin("stdlib-common", Versions.KOTLIN))
implementation(Deps.Ktor.COMMON_CORE)
implementation(Deps.Ktor.COMMON_JSON)
implementation(Deps.Coroutines.COMMON)
implementation(Deps.MP_SETTINGS)
implementation(Deps.Ktor.COMMON_SERIALIZER)
implementation(Deps.Serialization.COMMON)
implementation(Deps.Stately.COMMON)
implementation(Deps.Stately.CONCURRENCY)
}
sourceSets["jsMain"].dependencies {
implementation((kotlin("stdlib-js", Versions.KOTLIN)))
implementation(Deps.Ktor.JS_CORE)
implementation(Deps.Ktor.JS_JSON)
implementation(Deps.Coroutines.JS)
implementation(Deps.Ktor.JS_SERIALIZER)
implementation(Deps.Serialization.JS)
}
// Front-End react app dependencies
implementation(kotlin("stdlib-js"))
//React, React DOM + Wrappers (chapter 3)
implementation("org.jetbrains:kotlin-react:16.13.0-pre.94-kotlin-1.3.70")
implementation("org.jetbrains:kotlin-react-dom:16.13.0-pre.94-kotlin-1.3.70")
implementation(npm("react", "16.13.1"))
implementation(npm("react-dom", "16.13.1"))
//Kotlin Styled (chapter 3)
implementation("org.jetbrains:kotlin-styled:1.0.0-pre.94-kotlin-1.3.70")
implementation(npm("styled-components"))
implementation(npm("inline-style-prefixer"))
//Video Player (chapter 7)
implementation(npm("react-player"))
//Share Buttons (chapter 7)
implementation(npm("react-share"))
// Shared Library: Nautilus
implementation(project(":MarianaKit"))
//Coroutines (chapter 8)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.7")
When I import the javascript library into the Jetbrains starter React app, the dev distribution size 27MiB and the production distribution size is 1.5 MiB. Is anyone else having such large distribution sizes? Is this normal? Or am I doing something on my end to cause this?frank
07/08/2020, 9:48 PMEnter
key onkeyup()
but dont work. Any suggestions why it is failing?
Kotlin code:
attrs.onKeyUpFunction = {
it.preventDefault()
if (it.asDynamic().key === "Enter" || it.asDynamic().keyCode === 13) onLoginButtonClicked()
}
Javascript Generated:
function loginWindow$lambda$lambda$lambda$lambda(closure$onLoginButtonClicked) {
return function (it) {
it.preventDefault();
if (it.key === 'Enter' || it.keyCode === 13)
closure$onLoginButtonClicked();
return Unit;
};
}
BearDev
07/09/2020, 6:53 AMprivate external var postMessage: dynamic
data class MessageToMain(
val text: String
)
fun testInWorker() {
val message = MessageToMain("Hello world!")
postMessage(message)
}
And here's code that is ran in the main js thread:
worker.onmessage = {
val data = it.data
console.log(data)
val typed = data as MessageToMain
println(typed)
Unit
}
console.log outputs {text: "Hello world!"}
, but trying to cast it to MessageToMain unsurprisingly results in ClassCastException
being thrown. Considering that the actual javascript object in data
should satisfy the class definition of MessageToMain, I am wondering if there is a way to forcefully cast it.christophsturm
07/09/2020, 5:12 PMjanvladimirmostert
07/09/2020, 7:11 PMmoduleB: 1.0.0
under dependencies instead of a relative / absolute path like the other Kotlin std lib dependencies
is there a way to automatically include the generated JS from moduleB into moduleA or at least have that package installed somewhere? In the maven world, you would run mvn install
, does the node ecosystem have something similar ?Alexander Weickmann
07/10/2020, 8:49 AMconst ProductHomeExample = () => (
<ProductHome siteTitle="test" />
);
export default () => (
<SomeComponent
renderProductHome={ProductHomeExample}
/>
);
I am trying like this:
val ProductHomeExample = {
ProductHome {
attrs.siteTitle = "Test"
}
}
SomeComponent {
attrs.renderProductHome = ProductHomeExample
}
but this leads to error:
Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component
Edit: From looking at the type signature in the js file, I can see renderProductHome is of type React.ComponentType<{}>. So the question simplifies, how to create such a React.ComponentType<{}> instance?christophsturm
07/10/2020, 10:05 AMK("first", "second")
, then cast it to dynamic and pass it to a javascript method, does it look like this: `{a: "first", b:"second"}`(possibly with more fields) ?Alexander Weickmann
07/10/2020, 1:39 PM<Button
{...triggerProps}
isSelected={isOpen}
onClick={() => setIsOpen(!isOpen)}
iconBefore={<MediaServicesAddCommentIcon label="Add" />}
/>
How can I achieve this "injection" of triggerProps into my component in KotlinJS?spierce7
07/10/2020, 4:47 PMredbassett
07/11/2020, 5:08 AMchristophsturm
07/11/2020, 9:44 AMkotlin.js.Promise
(using the IR compiler) do i just have to add coroutines-core as npm dependency to frontend project?patrickdelconte
07/12/2020, 12:18 PMcollection.map { it.unsafeCast<SomeExternalInterface> }
which is undestood by the compiler and transpiled efficiently? It is something that comes up from time to time when interacting with js libs and last time I checked the resulting code was a for loop instead of a no-opBruno_
07/12/2020, 2:22 PM/home/.../IdeaProjects/.../build/js/node_modules/kotlinx-html-js/kotlinx-html-js.js:11
}(this, function (_, Kotlin) {
^
ReferenceError: HTMLLegendElement is not defined
at /home/.../IdeaProjects/.../build/js/node_modules/kotlinx-html-js/kotlinx-html-js.js:65:29
at /home/.../IdeaProjects/.../build/js/node_modules/kotlinx-html-js/kotlinx-html-js.js:5:5
at Object.<anonymous> (/home/.../IdeaProjects/.../build/js/node_modules/kotlinx-html-js/kotlinx-html-js.js:11:2)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/home/.../IdeaProjects/.../build/js/node_modules/kotlin-wrappers-kotlin-react-dom-jsLegacy/kotlin-wrappers-kotlin-react-dom-jsLegacy.js:2472:106)
FAILURE: Build failed with an exception.
Ian Stewart
07/13/2020, 12:10 PMDeclaration of such kind (enum class) cant be exported to JS
Why are enum classes no longer supported (e.g. enum class Color { Red, Green, Blue }
)? Previously, a class was generated, and only the typescript would be lacking (maps to ‘any’). Now, it does not compile…spierce7
07/14/2020, 4:53 PMFudge
07/15/2020, 9:39 AMgradlew run
no browser window opens. What am I supposed to do to show the app on a browser? (1.4-M3)thana
07/16/2020, 12:17 PM> Task :kotlinNpmInstall FAILED
error package.json: Name contains illegal characters
Any idea what to do? it's the autogenerated package.json (i suspect) from the kotlin compiler. im clueless what to do now ;(thana
07/16/2020, 12:17 PM> Task :kotlinNpmInstall FAILED
error package.json: Name contains illegal characters
Any idea what to do? it's the autogenerated package.json (i suspect) from the kotlin compiler. im clueless what to do now ;(willyrs
07/16/2020, 12:25 PMRobert Jaros
07/16/2020, 12:25 PMthana
07/16/2020, 12:28 PM{
"private": true,
"workspaces": [
"packages/SomeName SomeOtherName Shared Kernel",
"packages/SomeName SomeOtherName Shared Kernel-test",
"packages_imported/klock-root-klock/1.8.1",
"packages_imported/kotlin/1.3.70",
"packages_imported/assertk/0.20.0",
"packages_imported/opentest4k/1.1.3",
"packages_imported/kotlin-test-nodejs-runner/1.3.40",
"packages_imported/kotlin-test/1.3.70",
"packages_imported/kotlinx-serialization-kotlinx-serialization-runtime/0.20.0",
"packages_imported/kotlin-test-js-runner/1.3.70"
],
"devDependencies": {},
"dependencies": {},
"peerDependencies": {},
"optionalDependencies": {},
"bundledDependencies": [],
"name": "SomeName SomeOtherName Shared Kernel",
"version": "0.2.0"
}
willyrs
07/16/2020, 12:29 PMthana
07/16/2020, 12:30 PMRobert Jaros
07/16/2020, 12:35 PMIlya Goncharov [JB]
07/16/2020, 12:35 PMrootProject.name
in settings.gradle
file, and it will be getthana
07/16/2020, 12:40 PMaraqnid
07/17/2020, 1:02 PM