Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 23 2021 09:24
    @sjrd banned @yensaoxuan_twitter
  • Apr 18 2021 19:06
    @sjrd banned @Amitgup48798297_twitter
  • Mar 29 2021 07:47
    @sjrd banned @quangs
  • Jan 23 2021 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
Sébastien Doeraene
@sjrd
import scala.scalajs.js.JSConverters._ and then .toArray, IIRC.
nafg
@nafg
not scala arraybuffer to js array, I meant typed arraybuffer to scala array. I figured it out
at least one way
  new Int8Array(_).toArray
nafg
@nafg
oh that would be toJSArray anyway, so maybe you were thinking of typed array -> scala array but missing the arraybuffer -> typed array part
johannes karoff
@cornerman
Is there a simple way to create a js.Object for use with certain methods like js.Object.assign? There is js.Dynamic.literal(foo = "bar") or js.Dictionary("foo" -> "bar"), but they do not return a js.Object and I need to manually asInstanceOf. Another way is new js.Object { val foo = "bar" } - but that gives an unused warning. I guess I am searching for something like js.Object.literal :)
Scala.js 1.10.0 is released! It fixes a security issue in java.util.UUID.randomUUID(), registered as CVE-2022-28355. We strongly recommend all users upgrade to v1.10.0 as soon as possible.
Read more details about CVE-2022-28355 in the associated security advisory:
Also, it introduces a new split style: SmallModulesFor(packages).
kerr
@hepin1989
:clap:
NagaPreethika
@NagaPreethika
Hey i am new to scalajs developement and just started scalajs and i do not know how to resolve this issue,
"Exception in thread "main" java.lang.Error: A method defined in a native JavaScript type of a Scala.js library has been called. This is most likely because you tried to run Scala.js binaries on the JVM. Make sure you are using the JVM version of the libraries."
i have follwed all the steps as per scala.js website
Sébastien Doeraene
@sjrd
What command did you run that led to this error?
NagaPreethika
@NagaPreethika
i just pressed ´run´in the IDE and error is showing on line containing document.getElementById
Sébastien Doeraene
@sjrd
Oh I don't think IDEs understand that Scala.js projects must be run in a JavaScript engine.
Use the run command from sbt instead.
nafg
@nafg
@NagaPreethika what IDE?
NagaPreethika
@NagaPreethika
IntelliJ IDEA
and i am even facing ´ReferenceError: document is not defined´
Andriy Plokhotnyuk
@plokhotnyuk
Hi there! Please help to fix unexpected runtime errors after upgrading to Scala.js 1.9.0: https://github.com/scalameta/munit/pull/477#issuecomment-1092594981
Marc Grue
@marcgrue
@NagaPreethika - happens for instance if IntelliJ tries to run shared code as JS code - it can only run JVM code. Just go into the Run Configurations (in the dropdown in the upper right corner of your editor window) and change “Use classpath of module” to your jvm module instead (is likely set to a JS module). That should make it run (as jvm code) again. Hope that helps.
OSE-369
@OSE-369
Im new 2 scala.js.
OSE-369
@OSE-369
I wanted 2 knw if scala.js has its own special syntax n codes or it just converts scala codes to JS codes
Sébastien Doeraene
@sjrd
It compiles a dialect of Scala to JavaScript. The dialect is sufficiently close to normal Scala that virtually all Scala code works the same in Scala.js. (assuming it doesn't really on unsupported Java libraries).
If you really want to know the differences, they are documented here:
Fabio Pinheiro
@FabioPinheiro

I spent the last two days trying to understand a weird a behavior on my application.

I just realized if I switch the order in ...-entrypoint.js and bundling, the application work as expected.
On my entrypoint.js file (.../target/scala-3.1.0/scalajs-bundler/main/fmgp-ipfs-webapp-fastopt-entrypoint.js) I have something like this:

module.exports = {
  "require": (function(x0) {
    return {
      ...
      "@input-output-hk/atala-prism-sdk/dist/modules/identity": require("@input-output-hk/atala-prism-sdk/dist/modules/identity"),
      "@input-output-hk/atala-prism-sdk": require("@input-output-hk/atala-prism-sdk"),
      "@input-output-hk/atala-prism-sdk/dist/modules/crypto/derivation/KeyDerivation": require("@input-output-hk/atala-prism-sdk/dist/modules/crypto/derivation/KeyDerivation"),
     ...
    }[x0]
  })
}

After adding a line of code (that uses @input-output-hk/atala-prism-sdk/dist/modules/identity). A entry is added to entry points before @input-output-hk/atala-prism-sdk

Now everything that uses @input-output-hk/atala-prism-sdk is undefined.
On the browser console, if I call require("@input-output-hk/atala-prism-sdk"), the module exists but is mostly empty.
I switch the order it works fine.

Can someone point me to some documentation why the order matters?
Why does @input-output-hk/atala-prism-sdk/dist/modules/identity was added before @input-output-hk/atala-prism-sdk? where's the code that decides the order of this?

Fabio Pinheiro
@FabioPinheiro
Ignore the comment above there are more stuff messing things around.
I need to investigate more, and I need to first understand a bit better what webpack is doing.
Mathieu Prevel
@mprevel
Hi,
I'm trying to build a Progressive Webapp App (PWA) in scalajs. I have scalajs and npm dependencies (I use ScalaJSBundlerPlugin). I use scalajs 1.10.0.
Everything is working well, but according to the google lighthouse plugin https://chrome.google.com/webstore/detail/lighthouse/blipmdconlkpinefehnmjammfjpmpbjk the application has a poor performance (~40/100). It also seems that in order to publish a PWA on the android app store there is a requirement in terms of performance >= 80/100.
The low value seems to be due to the size of the full opt js file (size for download/ parsing/ eval). It seems that the way to fix this issue is to limit the size of js files. This means splitting the file and/ or use lazy loading.
But I had no success until now finding how to split my app file.
I've tried scalaJSLinkerConfig ~= (_.withModuleSplitStyle(...)) but it seems to work only in fastLinkJS. I get a Cannot use multiple modules with the Closure Compiler when using fullLinkJS.
The fastLinkJS does not seem to manage the node modules.
I don't know what can be done and at which step. So I have a few ideas and a bunch of questions.
I've thought to split the full opt js. But I don't know if it is possible to post process to split in chunks of 150kB for example.
Should I use the fastLinkJS with SmallestModules, but how to get my node modules back ? Is it ok to use files from fast step in production ? It is also required to group some of them to avoid thousands files.
Is it possible to get a file (or more) for the node modules dependencies, a file (or more) for the scalajs dependencies, a file for the app itself. And how to split the files that are too big ?
Sébastien Doeraene
@sjrd
Unfortunately, scalajs-bundler doesn't support multiple modules.
You could use a JavaScript bundler of your choice to gather your node modules dependencies.
Alexis Hernandez
@AlexITC
@mprevel I built a pwa which you may be interested in, I ended up keeping the service worked in js, I have been supposed to migrate it (https://github.com/wiringbits/cazadescuentos/tree/master/pwa), it has a twa wrapper published at the play store too
Mathieu Prevel
@mprevel
@AlexITC Thanks, I'll take a look.
Judith
@Judith74340563_twitter
raiacgt4
Alexey Rykhalskiy
@alexr007
Hi, Folks!
I'm trying to use ScalaJS with http4s-ember-client
The part, dependent on cats/cats-effects/fs2 works well,
but ember client (seems has some JS dependencies) requires precise configuration.
I fugured out all dependencies (buffer, crypto, net, os, punycode, stream, tls)
there is no fatal compilation errors, a lot of warnings. and it doesn't work :(
Does anybody have working configuration for any http client with scalajs ?
Here is my project git@github.com:alexr007/sjs-questions.git
evbo
@evbo

I found some JS code that uses .body getter on Document I can't seem to find equivalent feature for in Scala.JS. Why not?:

value body is not a member of org.scalajs.dom.Document

I think this is equivalently how it can be done. Just a bit more typing though:
dom.getElementsByTagName("BODY")(0).innerHTML = html
Sébastien Doeraene
@sjrd
dom.document.body
evbo
@evbo
Thought so too but:
// note: using addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0")

val dom = document.implementation.createHTMLDocument("mydom");

// this works
dom.getElementsByTagName("BODY")(0).innerHTML = html

// this doesn't: value body is not a member of org.scalajs.dom.Document
dom.document.body
// this doesn't: value body is not a member of org.scalajs.dom.Document
dom.body
evbo
@evbo

How do you access this from an anonymous function in scalajs? Like is done here:

https://github.com/ueberdosis/tiptap/blob/main/packages/core/src/extensions/keymap.ts#L12

scalavision
@scalavision

I need to create some kind of literal object with functions like this from ScalaJS:

{
    actions: {
      // action implementations
      activate: (context, event) => {
        console.log('activating...');
      },
      notifyActive: (context, event) => {
        console.log('active!');
      },
      notifyInactive: (context, event) => {
        console.log('inactive!');
      },
      sendTelemetry: (context, event) => {
        console.log('time:', Date.now());
      }
    }
  }

I am trying this:

class TAct extends js.Object {
  val x: js.Function0[Unit] = () => println("it worked")
}

val myActionObject = js.Dictionary("action" -> new TAct()).asInstanceOf[js.Object]

But it seems to me that the TAct class just turns into an empty object /undefined. I have to pass this into a function which is implemented in javascript. Is there a better way to do this?

scalavision
@scalavision
I tried first having object TAct extends js.Object, but that also gives undefined.
Sébastien Doeraene
@sjrd
val myActionObject = js.Dictionary[String, js.Function2[ContextType, EventType, Unit]](
  "activate" -> { (context, event) =>
    println("activating...")
  },
  ...
)
scalavision
@scalavision
thanks, that looks awesome! :D
Sébastien Doeraene
@sjrd
;)