Packages

trait JSEnv extends AnyRef

A JavaScript execution environment.

This can run and interact with JavaScript code.

Any implementation is expected to be fully thread-safe.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. JSEnv
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract val name: String

    Human-readable name for this JSEnv

  2. abstract def start(input: Seq[Input], config: RunConfig): JSRun

    Starts a new (asynchronous) JS run.

    Starts a new (asynchronous) JS run.

    This may only throw if value of input is unknown or config cannot be supported. To verify whether a RunConfig can be supported in a forward compatible manner (i.e. when new options are added in later versions) implementations of JSEnvs must use RunConfig.Validator.

    This must not throw if the run cannot be started or there is a problem with the input's content (e.g. file does not exist, syntax error, etc.). In this case, JSRun#future should be failed instead.

    Exceptions thrown

    UnsupportedInputException if the value of input cannot be supported.

    java.lang.IllegalArgumentException if the value of config cannot be supported.

  3. abstract def startWithCom(input: Seq[Input], config: RunConfig, onMessage: (String) ⇒ Unit): JSComRun

    Like start, but initializes a communication channel.

    Like start, but initializes a communication channel.

    Inside the VM this is to provide a global JavaScript object named scalajsCom that can be used to interact with the message channel. Its operations are:

    // initialize com (with callback). May only be called once.
    scalajsCom.init(function(msg) { console.log("Received: " + msg); });
    
    // send a message to host system
    scalajsCom.send("my message");

    All messages, sent in both directions, must be valid UTF-16 strings, i.e., they must not contain any unpaired surrogate character. The behavior of a communication channel is unspecified if this requirement is not met.

    We describe the expected message delivery guarantees by denoting the transmitter as t and the receiver as r. Both the JVM and the JS end act once as a transmitter and once as a receiver. These two transmitter/receiver pairs (JS/JVM and JVM/JS) are independent.

    For a pair (t,r):

    send(m_1), ..., send(m_n)

    and r observes onMessage(m_k) (k <= n) but not onMessage(m_{k+1}), r must observe

    onMessage(m_1), ..., onMessage(m_k)

    exactly in this order.

    • If t and r keep running indefinitely and t sends n messages, r receives n messages.
    onMessage

    Callback invoked each time a message is received from the JS VM. The implementation may not call this anymore once JSRun#future of the returned JSComRun is completed. Further, JSRun#future may only complete with no callback in-flight.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  16. def toString(): String
    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped