diff --git a/.gitignore b/.gitignore index fc93437..09198a4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ target/ .bsp/ .vscode/ metals.sbt +*.semanticdb +/*/yarn.lock diff --git a/build.sbt b/build.sbt index aced115..a5383bb 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,24 @@ +import _root_.io.github.nafg.scalacoptions._ import sbtdynver.GitDirtySuffix +def myScalacOptions(version: String) = + ScalacOptions.all(version)( + (opts: options.Common) => + opts.deprecation ++ + opts.unchecked ++ + opts.feature, + (_: options.V2).explaintypes, + (_: options.V2_13).Xlint("_"), + (opts: options.V2_13_6_+) => + opts.WdeadCode ++ + opts.WextraImplicit ++ + opts.WnumericWiden ++ + opts.XlintUnused ++ + opts.WvalueDiscard ++ + opts.Xsource("3") + ) + inThisBuild(List( organization := "io.github.nafg.scalajs-facades", homepage := Some(url("https://github.com/nafg/scalajs-facades")), @@ -8,25 +26,9 @@ inThisBuild(List( developers := List( Developer("nafg", "Naftoli Gugenheim", "98384+nafg@users.noreply.github.com", url("https://github.com/nafg")) ), - crossScalaVersions := Seq("2.12.15", "2.13.7"), + crossScalaVersions := Seq("2.13.7", "3.0.2"), scalaVersion := (ThisBuild / crossScalaVersions).value.last, - scalacOptions ++= Seq( - "-deprecation", - "-feature", - "-unchecked", - "-explaintypes", - "-Xlint:_", - "-Ywarn-dead-code", - "-Ywarn-extra-implicit", - "-Ywarn-numeric-widen", - "-Ywarn-unused:_", - "-Ywarn-value-discard" - ), - scalacOptions ++= - (if (scalaVersion.value.startsWith("2.12.")) - List("-language:higherKinds", "-Xfuture", "-Ypartial-unification") - else - Nil), + scalacOptions ++= myScalacOptions(scalaVersion.value), dynverGitDescribeOutput ~= (_.map(o => o.copy(dirtySuffix = GitDirtySuffix("")))), dynverSonatypeSnapshots := true, githubWorkflowJobSetup += @@ -60,7 +62,8 @@ lazy val simpleFacade = sjsCrossTarget, sonatypeProfileName := "io.github.nafg", libraryDependencies ++= Seq( - "com.github.japgolly.scalajs-react" %%% "extra" % "1.7.7", + "com.github.japgolly.scalajs-react" %%% "core" % "2.0.0", + "com.github.japgolly.scalajs-react" %%% "extra" % "2.0.0", "me.shadaj" %%% "slinky-readwrite" % "0.7.0", "org.scalameta" %%% "munit" % "0.7.29" % Test ) @@ -79,7 +82,6 @@ def moduleConfig(npmName: String, npmVersion: String): Project => Project = useYarn := true, sonatypeProfileName := "io.github.nafg", Compile / npmDependencies += npmName -> npmVersion, - libraryDependencies += "com.github.japgolly.scalajs-react" %%% "extra" % "1.7.7", scalacOptions ++= (if (scalaJSVersion.startsWith("0.6.")) Seq("-P:scalajs:sjsDefinedByDefault") else Nil) ) diff --git a/project/FacadeGenerator.scala b/project/FacadeGenerator.scala index a8da471..e19d31d 100644 --- a/project/FacadeGenerator.scala +++ b/project/FacadeGenerator.scala @@ -127,7 +127,7 @@ object FacadeGenerator { |${imports.map("import " + _).mkString("\n")} |import scala.scalajs.js |import scala.scalajs.js.annotation.JSImport - |import japgolly.scalajs.react.raw.React.ElementType + |import japgolly.scalajs.react.facade.React.ElementType |import io.github.nafg.simplefacade.{FacadeModule, ${if (factoryMethods.isEmpty || info.maybeChildrenProp.isDefined) "" else "Factory, "}PropTypes} | | diff --git a/project/build-build.sbt b/project/build-build.sbt index e23ce3e..b78497e 100644 --- a/project/build-build.sbt +++ b/project/build-build.sbt @@ -1,2 +1,3 @@ libraryDependencies += "com.lihaoyi" %% "os-lib" % "0.8.0" libraryDependencies += "com.lihaoyi" %% "ujson" % "1.4.4" +libraryDependencies += "io.github.nafg.scalac-options" %% "scalac-options" % "0.1.9" diff --git a/reactPhoneNumberInput/src/main/scala/io/github/nafg/scalajs/facades/reactphonenumberinput/ReactPhoneNumberInput.scala b/reactPhoneNumberInput/src/main/scala/io/github/nafg/scalajs/facades/reactphonenumberinput/ReactPhoneNumberInput.scala index 4afb4dd..d5307c0 100644 --- a/reactPhoneNumberInput/src/main/scala/io/github/nafg/scalajs/facades/reactphonenumberinput/ReactPhoneNumberInput.scala +++ b/reactPhoneNumberInput/src/main/scala/io/github/nafg/scalajs/facades/reactphonenumberinput/ReactPhoneNumberInput.scala @@ -4,7 +4,7 @@ import scala.scalajs.js import scala.scalajs.js.annotation.JSImport import japgolly.scalajs.react.Callback -import japgolly.scalajs.react.raw.React.ElementType +import japgolly.scalajs.react.facade.React.ElementType import io.github.nafg.simplefacade.Implicits.{callbackToWriter, elementTypeWriter} import io.github.nafg.simplefacade.{FacadeModule, PropTypes} diff --git a/reactSelect/src/main/scala/io/github/nafg/scalajs/facades/reactselect/OptGroup.scala b/reactSelect/src/main/scala/io/github/nafg/scalajs/facades/reactselect/OptGroup.scala index 3204ce0..e2903e2 100644 --- a/reactSelect/src/main/scala/io/github/nafg/scalajs/facades/reactselect/OptGroup.scala +++ b/reactSelect/src/main/scala/io/github/nafg/scalajs/facades/reactselect/OptGroup.scala @@ -1,6 +1,11 @@ package io.github.nafg.scalajs.facades.reactselect import scala.scalajs.js +import scala.scalajs.js.JSConverters._ class OptGroup[A](val label: String, val options: js.Array[A]) extends js.Object +object OptGroup { + def apply[A](label: String)(options: Seq[A]): Opt[A] = + new OptGroup[A](label, options.toJSArray) +} diff --git a/reactSelect/src/main/scala/io/github/nafg/scalajs/facades/reactselect/package.scala b/reactSelect/src/main/scala/io/github/nafg/scalajs/facades/reactselect/package.scala index eaa6ba7..145e75e 100644 --- a/reactSelect/src/main/scala/io/github/nafg/scalajs/facades/reactselect/package.scala +++ b/reactSelect/src/main/scala/io/github/nafg/scalajs/facades/reactselect/package.scala @@ -3,7 +3,6 @@ package io.github.nafg.scalajs.facades import scala.concurrent.Future import scala.language.implicitConversions import scala.scalajs.js -import scala.scalajs.js.JSConverters._ import scala.scalajs.js.| import slinky.readwrite.{Reader, Writer} @@ -14,14 +13,11 @@ package object reactselect { implicit def readOptA[A]: Reader[Opt[A]] = _.asInstanceOf[Opt[A]] implicit def writeOptA[A]: Writer[Opt[A]] = _.asInstanceOf[js.Object] - def OptGroup[A](label: String)(options: Seq[A]): Opt[A] = - new OptGroup[A](label, options.toJSArray) - def Opt[A](value: A): Opt[A] = value implicit class Opt_fold[A](self: Opt[A]) { def foldRaw[R](groupF: OptGroup[A] => R, optionF: A => R): R = - if (self.isInstanceOf[OptGroup[_]]) + if ((self: Any).isInstanceOf[OptGroup[_]]) groupF(self.asInstanceOf[OptGroup[A]]) else optionF(self.asInstanceOf[A]) diff --git a/simpleFacade/src/main/scala/io/github/nafg/simplefacade/Implicits.scala b/simpleFacade/src/main/scala/io/github/nafg/simplefacade/Implicits.scala index 2c65fc8..09a7f8e 100644 --- a/simpleFacade/src/main/scala/io/github/nafg/simplefacade/Implicits.scala +++ b/simpleFacade/src/main/scala/io/github/nafg/simplefacade/Implicits.scala @@ -3,8 +3,8 @@ package io.github.nafg.simplefacade import scala.scalajs.js import japgolly.scalajs.react.CallbackTo -import japgolly.scalajs.react.raw.React -import japgolly.scalajs.react.raw.React.ElementType +import japgolly.scalajs.react.facade.React +import japgolly.scalajs.react.facade.React.ElementType import japgolly.scalajs.react.vdom.VdomElement import japgolly.scalajs.react.vdom.html_<^.VdomNode diff --git a/simpleFacade/src/main/scala/io/github/nafg/simplefacade/PropTypes.scala b/simpleFacade/src/main/scala/io/github/nafg/simplefacade/PropTypes.scala index edb93db..f31036f 100644 --- a/simpleFacade/src/main/scala/io/github/nafg/simplefacade/PropTypes.scala +++ b/simpleFacade/src/main/scala/io/github/nafg/simplefacade/PropTypes.scala @@ -37,7 +37,8 @@ object PropTypes { raw.addClassNameToProps() new Multiple( raw.nonEmptyChildren.toList.map(new Single("children", _)) :+ - new Multiple(raw.props.asInstanceOf[AnyDict].map { case (k, v) => new Single(k, v) }) + // see https://github.com/lampepfl/dotty/issues/14244 + new Multiple(raw.props.asInstanceOf[AnyDict].toIterable.map { case (k, v) => new Single(k, v) }) ) }