Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sbt-scalajs, scalajs-compiler, ... to 1.17.0 #235

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [3.3.0, 2.13.11]
scala: [3.3.4, 2.13.15]
java: [temurin@17]
ci: [ciFirefox, ciChrome, ciJSDOMNodeJS]
runs-on: ${{ matrix.os }}
Expand All @@ -39,12 +39,15 @@ jobs:

- name: Setup Java (temurin@17)
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: sbt

- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Setup NodeJS v18 LTS
if: matrix.ci == 'ciJSDOMNodeJS'
uses: actions/setup-node@v3
Expand All @@ -68,7 +71,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.11]
scala: [2.13.15]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -79,10 +82,13 @@ jobs:

- name: Setup Java (temurin@17)
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: sbt

- name: Setup sbt
uses: sbt/setup-sbt@v1

- run: sbt ci-release
9 changes: 7 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version=3.7.17
runner.dialect = "scala213"
version = 3.8.4-RC3
runner.dialect = "scala213source3"
fileOverride {
"glob:**/scala-3/**" {
runner.dialect = scala3
Expand All @@ -23,3 +23,8 @@ trailingCommas = "preserve"
optIn.breaksInsideChains = true
includeCurlyBraceInSelectChains = true
align.preset = most
rewrite.scala3.convertToNewSyntax = true
runner.dialectOverride.allowAsForImportRename = true
runner.dialectOverride.allowStarWildcardImport = true
runner.dialectOverride.allowPostfixStarVarargSplices = true
runner.dialectOverride.allowQuestionMarkAsTypeWildcard = true
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# frontroute

![Maven Central](https://img.shields.io/maven-central/v/io.frontroute/frontroute_sjs1_2.13.svg?versionPrefix=0.18) ![Scala.js](https://img.shields.io/static/v1?label=built+with&message=Scala.js&color=green)
![Maven Central](https://img.shields.io/maven-central/v/io.frontroute/frontroute_sjs1_2.13.svg?versionPrefix=0.19) ![Scala.js](https://img.shields.io/static/v1?label=built+with&message=Scala.js&color=green)

`frontroute` is a front-end router library for single-page applications (SPA) built with [Scala.js](http://www.scala-js.org/) and [raquo/Laminar](https://github.com/raquo/Laminar),
with an API inspired by [Akka HTTP](https://doc.akka.io/docs/akka-http/current/).

## Important

Starting with version `0.19.1` the dependency organization name has changed from `io.frontroute` to `dev.frontroute`.

## Example project

An example is available here: https://github.com/yurique/frontroute-example
Expand Down
36 changes: 29 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ import org.openqa.selenium.remote.server.DriverFactory
import org.openqa.selenium.remote.server.DriverProvider
import org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv
import org.scalajs.jsenv.selenium.SeleniumJSEnv
import scala.Ordering.Implicits._

import java.util.concurrent.TimeUnit
import org.commonmark.parser.Parser
import org.commonmark.renderer.html.HtmlRenderer
import org.typelevel.scalacoptions.ScalaVersion.V3_0_0
import org.typelevel.scalacoptions.ScalacOptions

import xerial.sbt.Sonatype.sonatypeCentralHost

val disableWebsiteOnCI = true

Expand All @@ -32,7 +37,7 @@ Global / useJSEnv := JSEnv.NodeJS

inThisBuild(
List(
organization := "io.frontroute",
organization := "dev.frontroute",
homepage := Some(url("https://github.com/tulz-app/frontroute")),
licenses := List("MIT" -> url("https://github.com/tulz-app/frontroute/blob/main/LICENSE.md")),
scmInfo := Some(ScmInfo(url("https://github.com/tulz-app/frontroute"), "scm:[email protected]/tulz-app/frontroute.git")),
Expand All @@ -49,6 +54,8 @@ inThisBuild(
versionPolicyIntention := Compatibility.BinaryCompatible,
githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17")),
// githubWorkflowBuild += WorkflowStep.Sbt(List("versionPolicyCheck")),
sonatypeCredentialHost := sonatypeCentralHost,
// sonatypeRepository := "https://s01.oss.sonatype.org/service/local",
githubWorkflowTargetTags ++= Seq("v*"),
githubWorkflowArtifactUpload := false,
githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))),
Expand Down Expand Up @@ -127,10 +134,26 @@ inThisBuild(
)
)

lazy val commonSettings = Seq(
tpolecatScalacOptions ++= Set(
ScalacOptions.source("3-cross", _ < V3_0_0)
),
Test / tpolecatExcludeOptions ++= Set(
ScalacOptions.warnValueDiscard,
ScalacOptions.warnUnusedImports,
ScalacOptions.warnUnusedLocals,
ScalacOptions.warnUnusedImplicits,
ScalacOptions.warnUnusedPatVars,
ScalacOptions.warnDeadCode,
ScalacOptions.warnNonUnitStatement
),
)

lazy val frontroute =
project
.in(file("modules/frontroute"))
.enablePlugins(ScalaJSPlugin)
.settings(commonSettings)
.settings(
name := "frontroute",
libraryDependencies ++=
Expand All @@ -142,7 +165,6 @@ lazy val frontroute =
Dependencies.`scala-js-macrotask-executor`.value.map(_ % Test)
),
Test / parallelExecution := false,
ScalaOptions.fixOptions,
scalacOptions ++= {
val sourcesGithubUrl = s"https://raw.githubusercontent.com/tulz-app/frontroute/${git.gitHeadCommit.value.get}/"
val sourcesOptionName = CrossVersion.partialVersion(scalaVersion.value) match {
Expand All @@ -164,10 +186,10 @@ lazy val frontrouteSiteVersion: String = IO.read(file("website/.frontroute-versi
lazy val thisVersionSitePrefix = s"/v/$frontrouteSiteVersion/"

lazy val vars = Seq(
"frontrouteVersion" -> "0.18.2",
"laminarVersion" -> "16.0.0",
"scalajsVersion" -> "1.13.2",
"scala3version" -> "3.3.1",
"frontrouteVersion" -> "0.19.1",
"laminarVersion" -> "17.2.0",
"scalajsVersion" -> "1.16.0",
"scala3version" -> "3.3.4",
)

def templateVars(s: String): String =
Expand All @@ -178,7 +200,7 @@ def templateVars(s: String): String =
lazy val website = project
.in(file("website"))
.enablePlugins(ScalaJSPlugin, EmbeddedFilesPlugin, BuildInfoPlugin)
.settings(ScalaOptions.fixOptions)
.settings(commonSettings)
.settings(noPublish)
.settings(
githubWorkflowTargetTags := Seq.empty,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package frontroute

import com.raquo.laminar.api.L._
import com.raquo.laminar.api.L.*
import org.scalajs.dom

import scala.scalajs.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ trait ConjunctionMagnet[L] {

object ConjunctionMagnet {

implicit def fromDirective[L, R](other: Directive[R])(implicit composition: Composition[L, R]): ConjunctionMagnet[L] {
implicit def fromDirective[L, R](other: Directive[R])(implicit
composition: Composition[L, R]
): ConjunctionMagnet[L] {
type Out = Directive[composition.Composed]
} =
new ConjunctionMagnet[L] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package frontroute

import com.raquo.laminar.api.L._
import com.raquo.laminar.api.L.*
import frontroute.internal.UrlString

import scala.scalajs.js
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package frontroute

import com.raquo.laminar.api.L._
import com.raquo.laminar.api.L.*
import frontroute.ops.DirectiveOfOptionOps

class Directive[L](
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package frontroute

import com.raquo.laminar.api.L._
import com.raquo.laminar.api.L
import com.raquo.laminar.api.L.*

case class DocumentMeta(
title: String,
Expand Down Expand Up @@ -39,7 +38,7 @@ object DocumentMeta {
var titleElement = org.scalajs.dom.document.head.querySelector("title")
if (titleElement == null) {
titleElement = titleTag(title).ref
org.scalajs.dom.document.head.appendChild(titleElement)
val _ = org.scalajs.dom.document.head.appendChild(titleElement)
} else {
titleElement.textContent = title
}
Expand All @@ -61,7 +60,7 @@ object DocumentMeta {
case Some(value) =>
if (metaElement == null) {
metaElement = metaTag(nameAttr := metaName).ref
org.scalajs.dom.document.head.appendChild(metaElement)
val _ = org.scalajs.dom.document.head.appendChild(metaElement)
}
metaElement.setAttribute("content", value)
case None =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package frontroute

import com.raquo.laminar.api.L._
import com.raquo.laminar.api.L.*
import frontroute.internal.UrlString
import org.scalajs.dom
import scala.scalajs.js
Expand Down Expand Up @@ -32,7 +32,7 @@ object LinkHandler {
}
} else if (rel == "external") {
event.preventDefault()
dom.window.open(anchor.href)
val _ = dom.window.open(anchor.href)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package frontroute

import com.raquo.laminar.api.L._
import com.raquo.laminar.api.L.*
import com.raquo.airstream.core.EventStream
import org.scalajs.dom

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ object PathMatcher {

def provide[V](v: V): PathMatcher[V] = unit.map(_ => v)

def fail[T]: PathMatcher[T] = (consumed: List[String], in: List[String]) => PathMatchResult.Rejected(in)
def fail[T]: PathMatcher[T] = (_: List[String], in: List[String]) => PathMatchResult.Rejected(in)

}

Expand Down
6 changes: 3 additions & 3 deletions modules/frontroute/src/main/scala/frontroute/Route.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package frontroute

import com.raquo.laminar.api.L._
import com.raquo.laminar.api.L.*
import com.raquo.laminar.modifiers.Binder
import com.raquo.laminar.nodes.ReactiveElement
import frontroute.internal.LocationState
Expand All @@ -9,7 +9,7 @@ import frontroute.internal.RouterStateRef

trait Route extends ((Location, RoutingState, RoutingState) => RouteResult) with Mod[HtmlElement] {

import Route._
import Route.*

private val currentRender = Var(Option.empty[HtmlElement])
private val currentRenderState = Var(Option.empty[LocationState])
Expand Down Expand Up @@ -67,7 +67,7 @@ trait Route extends ((Location, RoutingState, RoutingState) => RouteResult) with
LocationState.init(render.ref, childState)
childState.setConsumed(consumed)

render.ref.dataset.addOne("frPath" -> consumed.mkString("/", "/", ""))
val _ = render.ref.dataset.addOne("frPath" -> consumed.mkString("/", "/", ""))
currentRender.set(Some(render))
currentRenderState.set(Some(childState))
case RouteEvent.SameRender(nextState, remaining, consumed) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package frontroute

import com.raquo.laminar.api.L._
import com.raquo.laminar.api.L.*
import frontroute.internal.RoutingState

sealed trait RouteResult extends Product with Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import scala.scalajs.js
@js.native
private[frontroute] trait WindowWithScrollXY extends js.Object {

val scrollX: js.UndefOr[Double] = js.native
val scrollY: js.UndefOr[Double] = js.native
val scrollX: js.UndefOr[Double] // = js.native
val scrollY: js.UndefOr[Double] // = js.native

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package frontroute.internal

import com.raquo.laminar.api.L._
import com.raquo.laminar.api.L.*
import frontroute.Location
import frontroute.LocationProvider
import frontroute.Route
import org.scalajs.dom

import scala.annotation.tailrec
import scala.scalajs.js
import scala.scalajs.js.UndefOr

@js.native
private[internal] trait ElementWithLocationState extends js.Any {
Expand Down Expand Up @@ -37,7 +36,8 @@ private[frontroute] object LocationState {

def withLocationProvider(lp: LocationProvider)(implicit owner: Owner): LocationState = {
var siblingMatched = false
lp.current.foreach { _ =>

val _ = lp.current.foreach { _ =>
siblingMatched = false
}

Expand All @@ -55,7 +55,7 @@ private[frontroute] object LocationState {
routerState = new RouterStateRef,
)

lp.start()
val _ = lp.start()
state
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ final private[frontroute] class RoutingState private (
override def toString: String = {
s"""state: consumed: '${consumed.mkString("/", "/", "")}' path: '$path', data: '${data
.map {
case (key, value: Var[_]) =>
case (key, value: Var[?]) =>
s"$key -> $value (${value.signal.now()})"
case (key, value) =>
s"$key -> $value"
Expand All @@ -107,7 +107,7 @@ final private[frontroute] class RoutingState private (
}

override def hashCode(): Int = {
val state = Seq(path, data)
val state: Seq[AnyRef] = Seq(path, data)
state.map(_.hashCode()).foldLeft(0)((a, b) => 31 * a + b)
}

Expand Down
6 changes: 3 additions & 3 deletions modules/frontroute/src/main/scala/frontroute/package.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import com.raquo.laminar.api.L._
import com.raquo.laminar.api.L.*

import app.tulz.tuplez.ApplyConverter
import app.tulz.tuplez.ApplyConverters
Expand Down Expand Up @@ -32,12 +32,12 @@ package object frontroute extends PathMatchers with Directives with ApplyConvert
val reject: Route = (_, _, _) => rejected

def debug(message: Any, optionalParams: Any*)(subRoute: Route): Route = { (location, previous, state) =>
dom.console.debug(message, optionalParams: _*)
dom.console.debug(message, optionalParams*)
subRoute(location, previous, state)
}

@deprecated("use firstMatch instead", "0.16.0")
def concat(routes: Route*): Route = firstMatch(routes: _*)
def concat(routes: Route*): Route = firstMatch(routes*)

def initRouting: Modifier[Element] = {
initRouting(LocationProvider.windowLocationProvider)
Expand Down
Loading
Loading