diff --git a/.travis.yml b/.travis.yml index e7cc18e..db8bf19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,7 @@ addons: language: scala scala: - - 2.10.7 - - 2.11.12 - - 2.12.8 + - 2.13.1 jdk: - openjdk8 diff --git a/js/js.sbt b/js/js.sbt index ee39e12..b9ca758 100644 --- a/js/js.sbt +++ b/js/js.sbt @@ -1,8 +1,6 @@ enablePlugins(Example) -libraryDependencies += "com.thoughtworks.binding" %%% "jspromisebinding" % "11.9.0" - -libraryDependencies += "com.thoughtworks.binding" %%% "dom" % "11.9.0" % Test +libraryDependencies += "com.thoughtworks.binding" %%% "jspromisebinding" % "12.0.0-M0" addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3") diff --git a/shared/build.sbt b/shared/build.sbt index 4ccd2c1..fde91b1 100644 --- a/shared/build.sbt +++ b/shared/build.sbt @@ -1,29 +1,14 @@ libraryDependencies += "org.scalatest" %%% "scalatest" % "3.1.0" % Test -libraryDependencies += "com.thoughtworks.binding" %%% "binding" % "11.9.0" +libraryDependencies += "com.thoughtworks.binding" %%% "binding" % "12.0.0-M0" -libraryDependencies += "com.thoughtworks.binding" %%% "futurebinding" % "11.9.0" +libraryDependencies += "com.thoughtworks.binding" %%% "futurebinding" % "12.0.0-M0" -libraryDependencies += "com.github.mpilquist" %%% "simulacrum" % "0.15.0" +libraryDependencies += "com.thoughtworks.binding" %%% "futurebinding" % "12.0.0-M0" -libraryDependencies += "com.thoughtworks.enableIf" %% "enableif" % "1.1.7" -// Enable macro annotation by scalac flags for Scala 2.13 -scalacOptions ++= { - import Ordering.Implicits._ - if (VersionNumber(scalaVersion.value).numbers >= Seq(2L, 13L)) { - Some("-Ymacro-annotations") - } else { - None - } -} +libraryDependencies += "org.typelevel" %% "simulacrum" % "1.0.0" + +libraryDependencies += "com.thoughtworks.enableIf" %% "enableif" % "1.1.7" -// Enable macro annotation by compiler plugins for Scala 2.12 -libraryDependencies ++= { - import Ordering.Implicits._ - if (VersionNumber(scalaVersion.value).numbers >= Seq(2L, 13L)) { - None - } else { - Some(compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full)) - } -} +scalacOptions += "-Ymacro-annotations" \ No newline at end of file diff --git a/shared/src/main/scala/com/thoughtworks/binding/bindable/package.scala b/shared/src/main/scala/com/thoughtworks/binding/bindable/package.scala index 71298ab..281ed73 100644 --- a/shared/src/main/scala/com/thoughtworks/binding/bindable/package.scala +++ b/shared/src/main/scala/com/thoughtworks/binding/bindable/package.scala @@ -5,6 +5,7 @@ import com.thoughtworks.binding.Binding._ import com.thoughtworks.enableIf import simulacrum._ import scala.language.implicitConversions +import scala.collection.immutable.ArraySeq package object bindable extends Bindable.ToBindableOps with BindableSeq.ToBindableSeqOps { implicit def bindableToBinding[From, Value](from: From)(implicit bindable: Bindable.Lt[From, Value]): Binding[Value] = @@ -28,7 +29,7 @@ package bindable { implicit def jsArrayBindableSeq[Value0]: BindableSeq.Aux[js.Array[Value0], Value0] = new BindableSeq[js.Array[Value0]] { type Value = Value0 - def toBindingSeq(from: js.Array[Value0]): BindingSeq[Value] = Constants(from: _*) + def toBindingSeq(from: js.Array[Value0]): BindingSeq[Value] = Constants(scalajs.runtime.toScalaVarArgs(from): _*) } } @@ -39,7 +40,7 @@ package bindable { type Value = Value0 def toBindingSeq(from: Binding[js.Array[Value0]]): BindingSeq[Value] = Constants(from).flatMap { from => - Constants(from.bind: _*) + Constants(scalajs.runtime.toScalaVarArgs(from.bind): _*) } } } @@ -91,54 +92,7 @@ package bindable { } - /** A dependent type class that witnesses a type that can be converted to a `Binding[Value]`. - * - * @example The implicit conversion to `Binding` can be enabled by the following `import` statement: - * - * {{{ - * import com.thoughtworks.binding.bindable._ - * }}} - * - * Then, a `@dom` XHTML template can establish data-binding on any `parameter` - * as long as a [[Bindable]] type class for the `parameter` type is available. - * - * {{{ - * @dom - * def mySection[A: Bindable.Lt[?, String]](parameter: A) = { - * - * } - * }}} - * - * Note that the `?` syntax requires the Scala plug-in - * [[https://github.com/non/kind-projector kind-projector]], - * which can be enabled by adding the following setting into your `build.sbt`: - * - *
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3")
- * - * The `mySection` method accepts any parameter who is a subtype of `Binding[String]`. - * - * {{{ - * import com.thoughtworks.binding._, Binding._ - * Binding { - * mySection(Binding("my-class-1")).bind.className should be("my-class-1") - * mySection(Constant("my-class-2")).bind.className should be("my-class-2") - * }.watch() - * }}} - * - * And the `mySection` method also accepts [[java.lang.String String]] parameter. - * {{{ - * Binding { - * mySection("my-class-3").bind.className should be("my-class-3") - * }.watch() - * }}} - * - * `mySection` should not accept irrelevant parameter types like [[scala.List]] or [[scala.Int]]. - * - * {{{ - * "mySection(List.empty)" shouldNot compile - * "mySection(42)" shouldNot compile - * }}} - */ + /** A dependent type class that witnesses a type that can be converted to a `Binding[Value]`. */ @typeclass trait Bindable[-From] { type Value @@ -171,7 +125,7 @@ package bindable { implicit def scalaArrayBindableSeq[Value0]: BindableSeq.Aux[Array[Value0], Value0] = new BindableSeq[Array[Value0]] { type Value = Value0 - def toBindingSeq(from: Array[Value0]): BindingSeq[Value] = Constants(from: _*) + def toBindingSeq(from: Array[Value0]): BindingSeq[Value] = Constants(ArraySeq.unsafeWrapArray(from): _*) } } @@ -205,7 +159,7 @@ package bindable { type Value = Value0 def toBindingSeq(from: Binding[Array[Value0]]): BindingSeq[Value] = Constants(from).flatMap { from => - Constants(from.bind: _*) + Constants(ArraySeq.unsafeWrapArray(from.bind): _*) } } @@ -220,70 +174,7 @@ package bindable { } - /** A dependent type class that witnesses a type that can be converted to a `BindingSeq[Value]`. - * - * @example The [[com.thoughtworks.binding.bindable.BindableSeq.Ops.bindSeq bindSeq]] - * can be enabled by the following `import` statement: - * - * {{{ - * import com.thoughtworks.binding.bindable._ - * }}} - * - * Then, a `@dom` XHTML template can establish data-binding on any `parameter` - * as long as a [[BindableSeq]] type class for the `parameter` type is available. - * - * {{{ - * import org.scalajs.dom.raw._ - * - * @dom - * def mySection[A: BindableSeq.Lt[?, Node]](parameter: A) = { - *
{parameter.bindSeq}
- * } - * }}} - * - * Note that the `?` syntax requires the Scala plug-in - * [[https://github.com/non/kind-projector kind-projector]], - * which can be enabled by adding the following setting into your `build.sbt`: - * - *
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3")
- * - * The `mySection` method accepts any parameter who is a subtype of `Binding[Node]` - * or `Binding[BindingSeq[Node]]`. - * - * {{{ - * import com.thoughtworks.binding._, Binding._ - * @dom def myButton: Binding[HTMLButtonElement] = - * @dom def myButtons: Binding[BindingSeq[Node]] = - * Binding { - * mySection(myButton).bind.innerHTML should be("") - * mySection(myButtons).bind.innerHTML should be("") - * }.watch() - * }}} - * - * And the `mySection` method also accepts `Node`, `BindingSeq[Node]`, `List[Node]`, `Array[Node]`, `js.Array[Node]`, or `Binding[js.Array[Node]]` parameter. - * {{{ - * import scala.scalajs.js - * @dom def test = { - * mySection().bind.innerHTML should be("") - * mySection().bind.innerHTML should be( - * "" - * ) - * mySection(List(, )).bind.innerHTML should be("") - * mySection(Array(, )).bind.innerHTML should be("") - * mySection(js.Array(, )).bind.innerHTML should be("") - * mySection(Constant(js.Array(, ))).bind.innerHTML should be("") - * } - * - * test.watch() - * }}} - * - * `mySection` should not accept irrelevant parameter types like [[scala.collection.immutable.Set]] or [[scala.Int]]. - * - * {{{ - * "mySection(Set.empty)" shouldNot compile - * "mySection(42)" shouldNot compile - * }}} - */ + /** A dependent type class that witnesses a type that can be converted to a `BindingSeq[Value]`. */ @typeclass trait BindableSeq[-From] { type Value