by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 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
  • Jan 31 2019 10:41
    sjrd opened #3554
  • Jan 31 2019 10:05
    gzm0 synchronize #3552
Anthony Cerruti
@srnb_gitlab
      containerOrNull <- Stream.eval(ce.delay(document.getElementById("container")))
      container <- containerOrNull match {
        case null => Stream.raiseError(new IllegalStateException("No #container found"))
        case found: typings.std.Element => Stream.emit(found)
      }
Sébastien Doeraene
@sjrd
Sure
Anthony Cerruti
@srnb_gitlab
:+1: Thank you again :sweat_smile:
aappddeevv
@aappddeevv
I have a bunch of helpers for things like A|Null. Maybe they will be helpful for you. https://github.com/aappddeevv/scalajs-reaction/blob/master/jshelpers/src/main/scala/null.scala. I also encounter UndefOr[A|Null] a lot as well.
Matt Hughes
@matthughes

Trying to upgrade my app to 1.0.0 (from 0.6.33). Can’t figure out why I’m getting this with fastOptJS:

[error] Referring to non-existent method static com.app.client.Main.main([java.lang.String)void
[error]   called from core module module initializers

Tripled checked my Main object:

object Main {
  def main(args: Array[String]): Unit = {

has to be some build setting I messed up but can’t for the life of me figure out what.

Matt Hughes
@matthughes
If I make no changes to that file, but delete all other source files in my project, fastOptJS succeeds.
Anthony Cerruti
@srnb_gitlab
1.1.0 is the latest ScalaJS version, maybe that fixed something wrt linking? but I'm not sure, just a [i forget the idiom]
Matt Hughes
@matthughes
It clearly doesn’t like something in my app but error message isn’t pointing it out. I’m on 1.1 but can’t downgrade due to other libraries that published for 1.1
Matt Hughes
@matthughes
It’s getting weirder:
import org.scalajs.dom
// Links with this import commented out, fails with it uncommented
// import scala.scalajs.js._

object Main {

  def main(args: Array[String]): Unit = {
    val root = dom.document.getElementById("root")

    println(s"Hello $root")

    ()
  }
}
Anthony Cerruti
@srnb_gitlab
Oh yeah, usually you don't import js._, you import js and use js.Dynamic.global or js.Object or etc
That may be why it fails with that import: It sees Array[String] and thinks js.Array[js.String] which isn't a valid main
Matt Hughes
@matthughes
oh. my. gosh. wow thanks! It worked before because 0.6 didn’t take args: Array[String].
Anthony Cerruti
@srnb_gitlab
:+1: glad you got it figured out!
Mark Tomko
@mtomko
We have a library in our code that includes a class that does (eg, DNA) sequence alignment. To do this, it uses a bunch of scoring matrices that are defined in text files (they're in the public domain, and our code parses them). In the JVM version of our library, we bundle the the matrix files in the jar by putting them in src/main/resources, and we load them using the classloader. We're trying to cross compile this library with scala JS and we'd like to figure out how we can write code targeting the JS runtime that can load them.
Is there a way to do this? Currently the code compiles but the tests fail with linking problems like: Referring to non-existent method java.lang.Class.getResourceAsStream(java.lang.String)java.io.InputStream
Mark Tomko
@mtomko
Obviously classpath makes sense as something that doesn't exist in the JS environment but I'm curious if there's an alternative for reading out resources
Roman Janusz
@ghik
Where are you going to run that library? Browser, Node?
Mark Tomko
@mtomko
Probably in the browser
Roman Janusz
@ghik
Then you'll have to decide how are you going to load these files in the browser, e.g. separately from external URL?
You might want to look at various bundling options that webpack gives you
Mark Tomko
@mtomko
okay. so there's no way to have the scalajs compiler encode them somehow in the JS resource that it produces?
Roman Janusz
@ghik
There may be but webpack can do that for you better
Mark Tomko
@mtomko
I guess we were hoping for a common way of loading these between the JS and JVM code; if we need to use some other tool for the JS verison, we might as well split the associated classes up
unless I am not understanding you properly
Roman Janusz
@ghik
JS simply has no concept of files or classpath so you cannot avoid having two separate implementations for loading these resources
I guess the most common ground would be URLs - on JVM they could point to classpath resources while in JS they would be actual internet URLs
I guess you're asking about some potential mechanism in the Scala.js linker which emulates classpath resources but there's not such thing AFAIK
Mark Tomko
@mtomko
Yes, I guess that's what I was hoping for, but it looks like we'll have to tackle it some other way.
Roman Janusz
@ghik
webpack may really be your friend, e.g. https://webpack.js.org/loaders/file-loader/
Mark Tomko
@mtomko
I'll take a look at it, thanks
Roman Janusz
@ghik
Scala.js integrates with webpack via scalajs-bundler
aappddeevv
@aappddeevv
@mtomko If you are using webpack, then one option is webpack module aliases. You can define an alias to "Resources" that points to your project's resources folder. Then you can import the resources, whatever they are, using @JSImport("Resources/myresourcefile.conf", JSImport.Default) or whatever import makes sense for you. You can also skip the alias and add the webpack loader directly to the JSImport but that's a bit messy.
The new val/def import capabilities are real useful here if you are using 1.1
Mark Tomko
@mtomko
thanks, i'll check that out
acse-fk4517
@acse-fk4517
Hi, is there a way to compile and run scala.js code from Scala running on the JVM? I have an app written on the JVM, but I would like to take advantage of the extensive javascript charting libraries out there
Sébastien Doeraene
@sjrd
Do you really want to compile the Scala.js code on the fly doing your JVM program's execution?
Or are you satisfied with compiling the Scala.js code ahead of time, and the only thing you want is call the already compiled JavaScript code from the JVM?
For the former, you'll need to invoke scalac with the Scala.js compiler plugin, then call the Scala.js linker, all from your JVM app. Look at how ScalaFiddle does it for inspiration.
For the latter, you can just spawn a node process and communicate with it via standard in/out or TCP. You may find the NodeJSEnv class useful for that purpose.
acse-fk4517
@acse-fk4517
@sjrd thank you - I will take a look at those
acse-fk4517
@acse-fk4517
@sjrd Essentially I run some simulations and the data is output in some format. I looked at the JVM plotting options and they are poor compared to whats available in Javascript. So I guess what I wanted to do was have a well integrated plotting package that accompanies the main simulation library which sits on the JVM.
Anthony Cerruti
@srnb_gitlab
Did you see EvilPlot by any chance? @acse-fk4517 It's working towards being able to do what other languages can do
acse-fk4517
@acse-fk4517
thanks @srnb_gitlab , however I couldn't get the basic example to render on my macbook. The Java icon pops up but nothing shows up. Another one I looked at is Xcharts which seems promising
Anthony Cerruti
@srnb_gitlab
You should be able to render it to an image instead of a Java Window
And implement the draw operations
acse-fk4517
@acse-fk4517
thanks @srnb_gitlab
aappddeevv
@aappddeevv
@acse-fk4517 You could also use graal, if that type of jvm works for you.
acse-fk4517
@acse-fk4517
@aappddeevv thanks!