Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 23 06:34
    @sjrd banned @Rebeka58_gitlab
  • Jun 08 2020 20:43
    @sjrd banned @sw7240614
  • Sep 29 2019 08:35
    @sjrd banned @8bitpitRBX_twitter
  • May 23 2019 13:44
    @sjrd banned @BIGCRYPTO001_gitlab
  • May 01 2019 14:31
    @sjrd banned @Certificates1_gitlab
  • Apr 22 2019 15:31
    @sjrd banned @lerbatax
  • Jan 31 2019 23:04
    sjrd commented #3555
  • Jan 31 2019 22:56
    sjrd review_requested #3555
  • Jan 31 2019 22:56
    sjrd opened #3555
  • Jan 31 2019 21:06

    sjrd on 0.6.x

    Remove dead code: specific coll… Adapt the signature of `js.Arra… Merge pull request #3554 from s… (compare)

  • Jan 31 2019 21:06
    sjrd closed #3554
  • Jan 31 2019 20:54
    erikvanoosten commented #2665
  • Jan 31 2019 16:33
    sjrd commented #3538
  • Jan 31 2019 15:54

    sjrd on master

    Fix analyzer cycle detection to… Add toString methods to analyze… Do not provide linked ClassInfo… and 1 more (compare)

  • Jan 31 2019 15:54
    sjrd closed #3552
  • Jan 31 2019 15:54

    sjrd on master

    Remove Logger.success It is un… Make level helpers final Clean-up ScalaConsoleLogger cod… and 1 more (compare)

  • Jan 31 2019 15:54
    sjrd closed #3553
  • Jan 31 2019 15:33
    sjrd commented #2665
  • Jan 31 2019 15:30
    erikvanoosten commented #2665
  • Jan 31 2019 10:41
    sjrd review_requested #3554
nafg
@nafg
//build.sbt
// ...
val scalaJsAsAsset = settingKey[Boolean]("Include scalaJs as an sbt-web asset of app_common")
// ...
commands += Command.command("backendDev")("set app_common/scalaJsAsAsset := true; ~app_lrbcol/reStart" :: _)
// ...
lazy val app_common =
// ...
  .settings(
// ...
    scalaJsAsAsset := insideCI.value,
    scalaJSProjects := Seq(app_js),
    Assets / WebKeys.packagePrefix := "public/",
    Assets / pipelineStages := {
      val asAsset = scalaJsAsAsset.value
      println("Evaluating pipelineStages, scalaJsAsAsset = " + asAsset)
      (if (asAsset) Seq(scalaJSPipeline) else Nil) ++
        (if (insideCI.value) Seq(digest, gzip) else Nil)
    }
  )
August Nagro
@AugustNagro
@darkfrog26 Is Scala.js released for Scala RC1? And how does one know this? Because I don't know what to look for on search.maven.org. The github release notes don't seem to mention.
Sébastien Doeraene
@sjrd
Scala 3.0.0-RC1 has support for Scala.js, yes. There's nothing on Maven Central; it's in the compiler. You know because the latest Scala.js always works with the latest Scala. Always. (Sometimes up to 12 hours after the release, but that's it.)
August Nagro
@AugustNagro
That's great to know
Matt Hicks
@darkfrog26
@sjrd any idea when ScalaTest will support it?
Sébastien Doeraene
@sjrd
You'll have to ask that to ScalaTest maintainers.
Matt Hicks
@darkfrog26
@sjrd okay, just thought you might have the inside track. :o
kubinio123
@kubinio123
Hello! I'am trying to extract some message from JS web socket ws.onerror callback which accepts Event object. I cannot pattern match Event and trying to cast it to ErrorEvent causes errors. Maybe there's some other way of extracting some meaningful message in this callback?
ws.onerror = (e: Event) => {
      val msg: String = ???
}
Chris Stewart
@Christewart

Hi, I'm trying to understanding how to skip publishing of scala-js artifacts. The configuration seems simple, I am adding skip.in(publish) := true to my commonJsSettings

however, when i go to try and run unit tests with this setting, i get immediate failures in the build. If I remove this setting, I get linking failures (which I expect).

https://github.com/bitcoin-s/bitcoin-s/pull/2731/commits/ba54261346b6c679ec198762585c4674bcb894f9

You can see the test case in this commit as well, which is BCryptoTest that does not have any external dependencies on the bitcoin-s project (just scalatest)

To be more concise, why am i getting different failures based on the skip.in(publish) := true setting? This seems entirely irrelevant to getting a unit test to pass
Eric K Richardson
@ekrich
I have been using publish / skip := true.
9 replies
In sbt 1.4.7
and earlier
eikek
@eikek:matrix.org
[m]
Hi! I'm a newbie to scalajs, hope it's ok to ask this here, couldn't find the info I need. I have a sbt multi-project build where one contains code I want to use in other scala/jvm sbt projects and also in the browser. So I build it using scalajs, too, and the js file (using fullOptJS) is loaded in the webapp. I added JSExportTopLevel and JSExportAll to a case class and JSExportTopLevel to an object containing a function. I can call the one function that seems to return an instance of such a case class in the browser. However, the returned value is obfuscated in js, so I can't get reliably a hold on the object properties. How can I make it better accessible from plain javascript (not using scalajs in the browser :-/)?
Sébastien Doeraene
@sjrd
@eikek:matrix.org The @JSExportAll should make the members of the annotated class available to JS. What's your code, what have you tried, and what error do you observe?
eikek
@eikek:matrix.org
[m]

@sjrd thanks! I created these two classes

@JSExportTopLevel("DsItemQueryParser")
object ItemQueryParser {

  @JSExport
  def parse(input: String): Either[ParseFailure, ItemQuery] =
    ...
}

@JSExportAll@JSExportTopLevel("ParseFailure")
final case class ParseFailure(
    input: String,
    failedAt: Int,
    messages: Nel[ParseFailure.Message]
) {

  def render: String = {
    val items = messages.map(_.msg).toList.mkString(", ")
    s"Failed to read input near $failedAt: $input\nDetails: $items"
  }
}

I then use the fullOptJS task to create a js file that I add to the html page. In the browser console I find this:

(sorry, posted the image above, still learning this chat client…) In the browser I can call my code, but the resulting object is containing these "weird" property names Kj, Lj where I was guessing that this comes from some obfuscation/minifying process…
eikek
@eikek:matrix.org
[m]
I can also share the url to my embarrassing attempts for the full picture; I'm sure screwing up somewhere
Sébastien Doeraene
@sjrd
That's expected. The fields will still have mangled names, which you cannot and should not try to access. However, the objects have properties with a getter with nice names. Your debugging console would show them in the prototype somewhere, if at all.
eikek
@eikek:matrix.org
[m]
Ahh…! thanks! forgot that js has methods… thanks! In my debugger, i only have things like .x() and .y() one of them says "Left" or "Right". Does this mean the Either is encoded that way? Should I create rather a custom type?
eikek
@eikek:matrix.org
[m]
It looks better when avoiding Either. Then the debugger shows me the case class fields as "fields" (unsure about correct js term, but it's not a function, I can "directly" access them in js). Still looks strange when a NonEmptyList is used or an Option. But I can now keep discovering further :) thank you!
eikek
@eikek:matrix.org
[m]
fyi I found the cause… I was using the scala types, like scala.List/Array in case classes which get translated into an object with properties, but these are not very usable – once finding out about the js native variants e.g. scala.scalajs.js.Array things look much better now. I was not aware of these, because I first set Crossproject.Pure where I don't have access.
Martijn
@martijnhoekstra:matrix.org
[m]
when trying to generate a coverage report with sbt-scoverage, it tries to download a wrong version of its runtime, not found: https://repo1.maven.org/maven2/org/scoverage/scalac-scoverage-runtime_sjs1.5_2.13/1.4.1/scalac-scoverage-runtime_sjs1.5_2.13-1.4.1.pom
does that ring a bell for anyone as to what I might be doing wrong?
I see the sjs1.5_2.13 part, which maybe should be sjs1_2.13
nafg
@nafg
@martijnhoekstra:matrix.org when was the last time you got it working?
Martijn
@martijnhoekstra:matrix.org
[m]
@nafg: I never got it working, I'm trying to set it up
in this instance, I want it for scalajs in particular, because they are tests testing whether my implementation is equivalent to some implementation in node. I had the impression it should(tm) work
Hanns Holger Rutz
@Sciss
I don't know if I've asked this before. Given the apparent similarity between java.awt.Graphics2D and the web's CanvasRenderingContext2D – is anyone aware of a Scala graphics library that can abstract these two?
August Nagro
@AugustNagro
@eikek:matrix.org I made a small Scala 3 library that makes it easier to convert between native JavaScript types and Scala/Scala.js: https://github.com/AugustNagro/native-converter
N.S. Cutler
@godenji

What's the state of the art in scala.js wrt building reactive (in the rxjs sense) frontend applications? Is everyone just going with a Scala.js/React wrapper library and calling it a day, or has there been any movement on the native Scala.js framework/library front?

Having spent the last couple of years working with TypeScript on the frontend I've grown to appreciate the amazing JS interop and tooling, but otherwise really miss the power of Scala/Scala.js.

3 replies
nafg
@nafg
@martijnhoekstra:matrix.org I haven't gotten scoverge working with scalajs in eons
Martijn
@martijnhoekstra:matrix.org
[m]
ah, that explains then @nafg
I'll see if I have time to minimize something (e.g. whether the problem is with sbt-scoverage or with scoverage)
Martijn
@martijnhoekstra:matrix.org
[m]
N.S. Cutler
@godenji
According to the replies, Laminar seems like worth taking a look at -- thanks...
Martin Utama
@inmyth

Hello all. So I'm wondering if there are exceptions Scalajs Try doesn't catch ?
On my test it doesn't appear to catch index out of bound exception. Or for something like this:

import scala.util._

val a = Try {
  "aaa".split(" ")(2)
}

val b = Try {
  Integer.parseInt("aaa")
}

b will work but a will crash the program.

Sébastien Doeraene
@sjrd
Undefined behavior exceptions are not caught.
Because they're fatal exceptions.
Martin Utama
@inmyth
I see. Thanks !
Felix Palludan Hargreaves
@hejfelix
Hi all, can someone clarify the status of Scala 3 support? It's tough to find "official" information
Felix Palludan Hargreaves
@hejfelix
also: If anyone can point me to an example of Scala3 with scalajs
August Nagro
@AugustNagro

@hejfelix it's working really well so far, add this to your plugins.sbt:

addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.3")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0")

In build.sbt set the scala version:

scalaVersion := "3.0.0-RC1"

And everything should be good to go. Whenever a new RC is released you need to check if new plugin versions have been released.

Sébastien Doeraene
@sjrd
Scala 3 officially supports Scala.js, yes. Make sure to use recent versions of Scala 3, sbt-dotty and sbt-scalajs, as mentioned above, and everything is going to work as expected.
Victor Hiairrassary
@vhiairrassary
Screenshot 2021-03-08 at 15.28.32.png
Hi there. Is it expected to have the latest commit from GitHub mentioned in https://scalacenter.github.io/scalajs-bundler homepage? (see above screenshot)
Sébastien Doeraene
@sjrd
No, I broke that yesterday with the auto-publishing of docs on merge. I'll fix it ASAP.
The latest version is 0.20.0, btw.