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.
- Alphabetic
- By Inheritance
- JSEnv
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
val
name: String
Human-readable name for this JSEnv
-
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 orconfig
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 ofinput
cannot be supported.java.lang.IllegalArgumentException
if the value ofconfig
cannot be supported.
-
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 asr
. 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)
:- If
t
calls JSComRun#send exactly in the sequence
send(m_1), ..., send(m_n)
and
r
observesonMessage(m_k)
(k <= n) but notonMessage(m_{k+1})
,r
must observeonMessage(m_1), ..., onMessage(m_k)
exactly in this order.
- If
t
andr
keep running indefinitely andt
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.
- If
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()