本文整理汇总了Scala中scala.scalajs.js.annotation.JSImport类的典型用法代码示例。如果您正苦于以下问题:Scala JSImport类的具体用法?Scala JSImport怎么用?Scala JSImport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JSImport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: React
//设置package包名称以及导入依赖的类
package io.taig.react4s.mui.facade
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
@js.native
@JSImport( "react", JSImport.Namespace )
object React extends js.Object {
def createClass( specification: js.Dictionary[js.Any] ): js.Dynamic =
js.native
def createElement(
element: js.Any,
props: js.Dictionary[js.Any] = null,
children: js.Any = null
): js.Dynamic = js.native
}
示例2: apply
//设置package包名称以及导入依赖的类
package io.scalajs.npm.brake
import io.scalajs.RawOptions
import io.scalajs.nodejs.stream.{Readable, Writable}
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSImport, ScalaJSDefined}
import scala.scalajs.js.|
/**
* brake - throttle a stream with backpressure
* @see https://www.npmjs.com/package/brake
* @author [email protected]
*/
@js.native
trait Brake extends js.Object {
/**
* Return a transform stream b that applies backpressure when more data than the rate allows is written.
* @param rate the throttle rate
* @param options the throttle options
* @return a [[Readable]] / [[Writable]] instance
*/
def apply(rate: Double, options: ThrottleOptions | RawOptions = js.native): Readable with Writable = js.native
}
/**
* Brake Singleton
* @author [email protected]
*/
@js.native
@JSImport("brake", JSImport.Namespace)
object Brake extends Brake
/**
* Throttle Options
* @param rate How many bytes to emit for each interval of length period
* @param period How often to check the output length in milliseconds. Default value: 1000.
*/
@ScalaJSDefined
class ThrottleOptions(var rate: js.UndefOr[Double] = js.undefined,
var period: js.UndefOr[Int] = js.undefined) extends js.Object
示例3: uuid
//设置package包名称以及导入依赖的类
package de.mukis.js
import scala.annotation.meta.field
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport.Namespace
import scala.scalajs.js.annotation.{JSExport, JSImport}
import scala.scalajs.js.|
@JSImport("node-uuid/uuid", Namespace)
@js.native
object uuid extends UUID
@js.native
trait UUID extends js.Object {
def v1(options: js.UndefOr[UUIDOptions] = js.undefined): String = js.native
def v1(
options: UUIDOptions,
buffer: js.Array[Double],
offset: js.UndefOr[Double]
): js.Array[Double] = js.native
def v4(options: js.UndefOr[UUIDOptions] = js.undefined): String = js.native
def v4(
options: UUIDOptions,
buffer: js.Array[Double],
offset: js.UndefOr[Double]
): js.Array[Double] = js.native
def parse(
id: String,
buffer: js.UndefOr[js.Array[Double]] = js.undefined,
offset: js.UndefOr[Double] = js.undefined
): js.Array[Double] = js.native
def unparse(
buffer: js.Array[Double],
offset: js.UndefOr[Double] = js.undefined
): String = js.native
}
case class UUIDOptions(
@(JSExport @field) node: js.UndefOr[js.Array[js.Any]] = js.undefined,
@(JSExport @field) clockseq: js.UndefOr[Double] = js.undefined,
@(JSExport @field) msecs: js.UndefOr[Double | js.Date] = js.undefined,
@(JSExport @field) nsecs: js.UndefOr[Double] = js.undefined
)
示例4: JQueryStatic
//设置package包名称以及导入依赖的类
package drt.client.components
import org.scalajs.dom._
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSImport, JSName}
@js.native
trait JQueryEventObject extends Event {
var data: js.Any = js.native
}
@js.native
//@JSName("wtf")
@JSImport("expose-loader?jQuery!jquery", JSImport.Namespace)
object JQueryStatic extends js.Object {
def apply(element: Element): JQuery = js.native
}
@js.native
trait JQuery extends js.Object {
def on(events: String, selector: js.Any, data: js.Any, handler: js.Function1[JQueryEventObject, js.Any]): JQuery = js.native
def off(events: String): JQuery = js.native
}
示例5: JpegJs
//设置package包名称以及导入依赖的类
package org.bruchez.tessel
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
import scala.scalajs.js.typedarray.Uint8Array
import scala.scalajs.js.|
@js.native
@JSImport("jpeg-js", JSImport.Namespace)
object JpegJs extends js.Object {
def decode(buffer: Buffer, asUint8Array: Boolean = false): JpegJsResult = js.native
}
@js.native
trait JpegJsResult extends js.Object {
val width : Int = js.native
val height : Int = js.native
val data : Uint8Array | Buffer = js.native
}
示例6: HeaderBtn
//设置package包名称以及导入依赖的类
package weatherApp.components
import japgolly.scalajs.react.ScalaFnComponent
import japgolly.scalajs.react.vdom.html_<^._
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
object HeaderBtn {
@JSImport("../../assets/images/github.png", JSImport.Namespace)
@js.native
object GithubLogo extends js.Any
case class Props(text: String, url: String, isLogin: Boolean = false)
val Component = ScalaFnComponent[Props](props => {
val icon = if (props.isLogin) <.img(^.width := 25.px, ^.marginRight := 5.px, ^.src := GithubLogo.asInstanceOf[String])
else <.div()
<.div(
^.display := "flex",
^.justifyContent := "flex-end",
<.a(
^.cls := "header-btn",
^.display := "flex",
^.justifyContent := "center",
^.alignItems := "center",
^.border := "1px solid black",
^.borderRadius := 3.px,
^.padding := 5.px,
^.textDecoration := "none",
^.href := props.url,
icon,
props.text
)
)
})
def apply(props: Props) = {
GithubLogo
Component(props)
}
}
示例7: MapMarker
//设置package包名称以及导入依赖的类
package weatherApp.components
import scala.scalajs.js
import japgolly.scalajs.react._
import japgolly.scalajs.react.vdom.html_<^._
import scala.scalajs.js.annotation.JSImport
object MapMarker {
@JSImport("../../assets/images/marker.png", JSImport.Namespace)
@js.native
object MarkerImage extends js.Any
val Component = ScalaFnComponent[js.Dynamic](props => {
<.div(
^.title := "Map Marker",
<.img(
^.width := 60.px,
^.src := MarkerImage.asInstanceOf[String]
)
)
})
def apply(props: js.Dynamic) = {
MarkerImage
Component(props)
}
}
示例8: uuid
//设置package包名称以及导入依赖的类
package net.gutefrage
import scala.annotation.meta.field
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport.Namespace
import scala.scalajs.js.annotation.{JSExport, JSImport}
import scala.scalajs.js.|
@JSImport("node-uuid/uuid", Namespace)
@js.native
object uuid extends UUID
@js.native
trait UUID extends js.Object {
def v1(options: js.UndefOr[UUIDOptions] = js.undefined): String = js.native
def v1(
options: UUIDOptions,
buffer: js.Array[Double],
offset: js.UndefOr[Double]
): js.Array[Double] = js.native
def v4(options: js.UndefOr[UUIDOptions] = js.undefined): String = js.native
def v4(
options: UUIDOptions,
buffer: js.Array[Double],
offset: js.UndefOr[Double]
): js.Array[Double] = js.native
def parse(
id: String,
buffer: js.UndefOr[js.Array[Double]] = js.undefined,
offset: js.UndefOr[Double] = js.undefined
): js.Array[Double] = js.native
def unparse(
buffer: js.Array[Double],
offset: js.UndefOr[Double] = js.undefined
): String = js.native
}
case class UUIDOptions(
@(JSExport @field) node: js.UndefOr[js.Array[js.Any]] = js.undefined,
@(JSExport @field) clockseq: js.UndefOr[Double] = js.undefined,
@(JSExport @field) msecs: js.UndefOr[Double | js.Date] = js.undefined,
@(JSExport @field) nsecs: js.UndefOr[Double] = js.undefined
)
示例9: PeerId
//设置package包名称以及导入依赖的类
package eu.devtty.peerid
import io.scalajs.nodejs.buffer.Buffer
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
@js.native
@JSImport("peer-id", JSImport.Namespace)
class PeerId extends js.Object {
def toHexString: String = js.native
def toBytes: Buffer = js.native
def toB58String: String = js.native
def toJSON: PeerIdObject = js.native
def toPrint: PeerIdObject = js.native
def inEqual(id: PeerId): Boolean = js.native
def inEqual(id: Buffer): Boolean = js.native
}
@js.native
trait PeerIdObject extends js.Object {
val privKey: String = js.native
}
示例10: stat
//设置package包名称以及导入依赖的类
package eu.devtty.ipfs
import eu.devtty.cid.CID
import io.scalajs.nodejs.buffer.Buffer
import scala.concurrent.Future
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
trait BlockApi {
def stat(cid: Buffer): Future[BlockStat]
}
@js.native
trait BlockStat extends js.Object {
val key: String = js.native
val size: Int = js.native //Long appears to be broken by scalajs, may need some deeper lok
}
@js.native
@JSImport("ipfs-block", JSImport.Namespace)
class Block(val data: Buffer, val cid: CID) extends js.Object
@js.native
@JSImport("ipfs-block", JSImport.Namespace)
object Block extends js.Object {
def isBlock(other: js.Any): Boolean = js.native
}
示例11: PeerInfo
//设置package包名称以及导入依赖的类
package eu.devtty.peerinfo
import eu.devtty.multiaddr.Multiaddr
import eu.devtty.peerid.PeerId
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
@js.native
@JSImport("peer-info", JSImport.Namespace)
object PeerInfo extends js.Object {
def create(id: PeerId, callBack: js.Function1[PeerInfo, _]): Unit = js.native
def create(callBack: js.Function1[PeerInfo, _]): Unit = js.native
}
@js.native
@JSImport("peer-info", JSImport.Namespace)
class PeerInfo(id: PeerId) extends js.Object {
val multiaddrs: MultiaddrSet = js.native
def connect(ma: Multiaddr): Unit = js.native
def disconnect(): Unit = js.native
def isConnected: Boolean = js.native
}
@js.native
trait MultiaddrSet extends js.Object {
def replace(existing: Multiaddr, fresh: Multiaddr): Unit = js.native
}
示例12: MultiHash
//设置package包名称以及导入依赖的类
package eu.devtty.multihash
import io.scalajs.nodejs.buffer.Buffer
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
@js.native
@JSImport("multihashes", JSImport.Namespace)
object MultiHash extends js.Object {
def validate(multihash: Buffer): Unit = js.native
}
@js.native
trait DecodedMultiHash extends js.Object {
val code: Int = js.native
val name: String = js.native
val length: Int = js.native
val digest: Buffer = js.native
}
示例13: snabbdom
//设置package包名称以及导入依赖的类
package snabbdom
import org.scalajs.dom.{Element, Text}
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
import scala.scalajs.js.annotation.JSImport.Namespace
import scala.scalajs.js.|
@JSImport("snabbdom", Namespace)
@js.native
object snabbdom extends js.Object {
def init(modules: js.Array[js.Object]): js.Function2[VNode | Element, VNode, VNode] = js.native
}
@JSImport("snabbdom/h", Namespace)
@js.native
object h extends js.Function3[String, js.UndefOr[js.Any], js.UndefOr[js.Any], VNode] {
def apply(selector: String, b: js.UndefOr[js.Any] = js.undefined, c: js.UndefOr[js.Any] = js.undefined): VNode = js.native
}
@js.native
class VNode(
selector: js.UndefOr[String],
data: js.UndefOr[VNodeData],
children: js.UndefOr[js.Array[VNode | String]],
text: js.UndefOr[String],
elm: js.UndefOr[Element | Text],
key: js.UndefOr[String | Double]
) extends js.Object
@js.native
class VNodeData extends js.Object
示例14: props
//设置package包名称以及导入依赖的类
package snabbdom.modules
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
import scala.scalajs.js.annotation.JSImport.Namespace
@JSImport("snabbdom/modules/class", Namespace)
@js.native
object `class` extends js.Object
@JSImport("snabbdom/modules/props", Namespace)
@js.native
object props extends js.Object
@JSImport("snabbdom/modules/style", Namespace)
@js.native
object style extends js.Object
@JSImport("snabbdom/modules/eventlisteners", Namespace)
@js.native
object eventlisteners extends js.Object
示例15: uuid
//设置package包名称以及导入依赖的类
package uuid
import scala.annotation.meta.field
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport.Namespace
import scala.scalajs.js.annotation.{JSExport, JSImport}
import scala.scalajs.js.|
@JSImport("node-uuid/uuid", Namespace)
@js.native
object uuid extends UUID
@js.native
trait UUID extends js.Object {
def v1(options: js.UndefOr[UUIDOptions] = js.undefined): String = js.native
def v1(
options: UUIDOptions,
buffer: js.Array[Double],
offset: js.UndefOr[Double]
): js.Array[Double] = js.native
def v4(options: js.UndefOr[UUIDOptions] = js.undefined): String = js.native
def v4(
options: UUIDOptions,
buffer: js.Array[Double],
offset: js.UndefOr[Double]
): js.Array[Double] = js.native
def parse(
id: String,
buffer: js.UndefOr[js.Array[Double]] = js.undefined,
offset: js.UndefOr[Double] = js.undefined
): js.Array[Double] = js.native
def unparse(
buffer: js.Array[Double],
offset: js.UndefOr[Double] = js.undefined
): String = js.native
}
case class UUIDOptions(
@(JSExport @field) node: js.UndefOr[js.Array[js.Any]] = js.undefined,
@(JSExport @field) clockseq: js.UndefOr[Double] = js.undefined,
@(JSExport @field) msecs: js.UndefOr[Double | js.Date] = js.undefined,
@(JSExport @field) nsecs: js.UndefOr[Double] = js.undefined
)