Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ eab1bde834682e787e35a8b749e4f1b3a15362bc

# Scala Steward: Reformat with scalafmt 3.11.0
3fdd041a599a7b2fcec3513c38103289d9ccc8d4

# Scala Steward: Reformat with scalafmt 3.11.2
170073b2f783a10d063aa1cfc317955904d1b1cd
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.11.1
version = 3.11.2
project.layout = StandardConvention
runner.dialect = scala3
maxColumn = 100
Expand Down
7 changes: 2 additions & 5 deletions examples/electron-app/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@ lazy val commonSettings = Seq(
_.withModuleKind(ModuleKind.ESModule)
},
// Neither module has a `main` entry point; both export functions instead.
scalaJSUseMainModuleInitializer := false,
scalaJSUseMainModuleInitializer := false,
libraryDependencies += "org.wvlet.uni" %%% "uni" % uniVersion
)

lazy val api = project
.in(file("api"))
.enablePlugins(ScalaJSPlugin)
.settings(commonSettings)
lazy val api = project.in(file("api")).enablePlugins(ScalaJSPlugin).settings(commonSettings)

lazy val main = project
.in(file("main"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import scala.scalajs.js.annotation.JSExportTopLevel

/**
* The renderer (UI) process. It installs the Electron IPC channel so that every Uni HTTP/RPC call
* is tunneled to the main process through the preload bridge, then renders a small counter UI whose
* buttons drive the [[CounterApi]].
* is tunneled to the main process through the preload bridge, then renders a small counter UI
* whose buttons drive the [[CounterApi]].
*/
object RendererApp:

Expand All @@ -28,8 +28,12 @@ object RendererApp:
private lazy val client = Http.client.newAsyncClient

private def get(): Rx[CounterState] = rpc.callAsync[CounterState](client, "get", Seq.empty)
private def increment(amount: Int): Rx[CounterState] =
rpc.callAsync[CounterState](client, "increment", Seq(amount))
private def increment(amount: Int): Rx[CounterState] = rpc.callAsync[CounterState](
client,
"increment",
Seq(amount)
)

private def reset(): Rx[CounterState] = rpc.callAsync[CounterState](client, "reset", Seq.empty)

@JSExportTopLevel("main")
Expand All @@ -42,7 +46,8 @@ object RendererApp:
private def el[E <: html.Element](tag: String, classes: String, text: String = ""): E =
val e = dom.document.createElement(tag).asInstanceOf[E]
e.className = classes
if text.nonEmpty then e.textContent = text
if text.nonEmpty then
e.textContent = text
e

private def renderUI(): Unit =
Expand Down Expand Up @@ -82,23 +87,27 @@ object RendererApp:
display.textContent = state.value.toString
display.className =
"mb-8 text-7xl font-bold tabular-nums text-indigo-400 transition-transform scale-110"
dom.window.setTimeout(
() =>
display.className =
"mb-8 text-7xl font-bold tabular-nums text-indigo-400 transition-transform",
120
)
dom
.window
.setTimeout(
() =>
display.className =
"mb-8 text-7xl font-bold tabular-nums text-indigo-400 transition-transform",
120
)

val row = el[html.Div]("div", "flex items-center justify-center gap-3")
row.appendChild(button("+1", "bg-indigo-600 hover:bg-indigo-500 active:bg-indigo-700")(
increment(1).run(show)
))
row.appendChild(button("+10", "bg-indigo-700 hover:bg-indigo-600 active:bg-indigo-800")(
increment(10).run(show)
))
row.appendChild(button("Reset", "bg-slate-600 hover:bg-slate-500 active:bg-slate-700")(
reset().run(show)
))
row.appendChild(
button("+1", "bg-indigo-600 hover:bg-indigo-500 active:bg-indigo-700")(increment(1).run(show))
)
row.appendChild(
button("+10", "bg-indigo-700 hover:bg-indigo-600 active:bg-indigo-800")(
increment(10).run(show)
)
)
row.appendChild(
button("Reset", "bg-slate-600 hover:bg-slate-500 active:bg-slate-700")(reset().run(show))
)

card.appendChild(title)
card.appendChild(subtitle)
Expand Down
2 changes: 1 addition & 1 deletion sbt-uni-crossproject/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.11.1
version = 3.11.2
project.layout = StandardConvention
runner.dialect = scala3
maxColumn = 100
Expand Down
4 changes: 2 additions & 2 deletions sbt-uni-crossproject/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ ThisBuild / publishTo := {
// Both plugins are published for sbt 2.x under the `_sbt2_3` coordinate suffix. The plugin enables
// ScalaJSPlugin / ScalaNativePlugin on the JS / Native platform projects, so it compiles against
// these and consumers get them transitively.
val SCALAJS_VERSION = "1.22.0"
val SCALA_NATIVE_VERSION = "0.5.12"
val SCALAJS_VERSION = "1.22.0"
val SCALA_NATIVE_VERSION = "0.5.12"

lazy val sbtUniCrossProject = project
.in(file("."))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,51 @@ import scala.quoted.*
* sub-projects `coreJVM`, `coreJS`, `coreNative`. The enclosing-val lookup mirrors sbt's
* `KeyMacro.definingValName` so it behaves identically.
*/
private[crossproject] object CrossProjectMacro {
private[crossproject] object CrossProjectMacro:

def crossProjectImpl(platforms: Expr[Seq[Platform]])(using Quotes): Expr[CrossProject.Builder] = {
def crossProjectImpl(platforms: Expr[Seq[Platform]])(using Quotes): Expr[CrossProject.Builder] =
val name = definingValName(
"crossProject must be directly assigned to a val, " +
"such as `val x = crossProject(JVMPlatform, JSPlatform)`."
)
'{ CrossProject(${ name }, new java.io.File(${ name }))(${ platforms }*) }
}
'{
CrossProject(
${
name
},
new java.io.File(
${
name
}
)
)(
${
platforms
}*
)
}

private def definingValName(errorMsg: String)(using Quotes): Expr[String] = {
private def definingValName(errorMsg: String)(using Quotes): Expr[String] =
import quotes.reflect.*
val term = enclosingTerm
if term.isValDef then Expr(term.name) else report.errorAndAbort(errorMsg)
}
if term.isValDef then
Expr(term.name)
else
report.errorAndAbort(errorMsg)

private def enclosingTerm(using qctx: Quotes): qctx.reflect.Symbol = {
private def enclosingTerm(using qctx: Quotes): qctx.reflect.Symbol =
import qctx.reflect.*
@tailrec
def enclosingTerm0(sym: Symbol): Symbol = sym match {
case sym if sym.flags.is(Flags.Macro) => enclosingTerm0(sym.owner)
case sym if sym.flags.is(Flags.Synthetic) => enclosingTerm0(sym.owner)
case sym if !sym.isTerm => enclosingTerm0(sym.owner)
case _ => sym
}
def enclosingTerm0(sym: Symbol): Symbol =
sym match
case sym if sym.flags.is(Flags.Macro) =>
enclosingTerm0(sym.owner)
case sym if sym.flags.is(Flags.Synthetic) =>
enclosingTerm0(sym.owner)
case sym if !sym.isTerm =>
enclosingTerm0(sym.owner)
case _ =>
sym
enclosingTerm0(Symbol.spliceOwner)
}

}
end CrossProjectMacro
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ lazy val app = crossProject(JVMPlatform, JSPlatform, NativePlatform)
TaskKey[Unit]("checkVersions") := {
assert((core.jvm / version).value == "0.1.0-jvm", s"jvm: ${(core.jvm / version).value}")
assert((core.js / version).value == "0.1.0-js", s"js: ${(core.js / version).value}")
assert((core.native / version).value == "0.1.0-native", s"native: ${(core.native / version).value}")
assert(
(core.native / version).value == "0.1.0-native",
s"native: ${(core.native / version).value}"
)
}
2 changes: 1 addition & 1 deletion sbt-uni-playwright/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.11.1
version = 3.11.2
project.layout = StandardConvention
runner.dialect = scala3
maxColumn = 100
Expand Down
9 changes: 3 additions & 6 deletions sbt-uni-playwright/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ lazy val jsenv = project
scalaVersion := SCALA_3,
libraryDependencies ++=
Seq(
"org.scala-js" %% "scalajs-js-envs" % SCALAJS_JS_ENVS_VERSION,
"com.microsoft.playwright" % "playwright" % PLAYWRIGHT_VERSION
"org.scala-js" %% "scalajs-js-envs" % SCALAJS_JS_ENVS_VERSION,
"com.microsoft.playwright" % "playwright" % PLAYWRIGHT_VERSION
)
)

Expand All @@ -82,7 +82,4 @@ lazy val plugin = project
scriptedBufferLog := false
)

lazy val root = project
.in(file("."))
.settings(publish / skip := true)
.aggregate(jsenv, plugin)
lazy val root = project.in(file(".")).settings(publish / skip := true).aggregate(jsenv, plugin)
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ lazy val app = project
// On sbt 2.x, `%%` encodes both the Scala version and the Scala.js platform suffix (_sjs1),
// so the old `%%%` operator is no longer used.
libraryDependencies ++=
Seq(
"org.scala-js" %% "scalajs-dom" % "2.8.1",
"org.scalameta" %% "munit" % "1.1.0" % Test
),
Seq("org.scala-js" %% "scalajs-dom" % "2.8.1", "org.scalameta" %% "munit" % "1.1.0" % Test),
testFrameworks += new TestFramework("munit.Framework")
)
2 changes: 1 addition & 1 deletion sbt-uni/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.11.1
version = 3.11.2
project.layout = StandardConvention
runner.dialect = scala3
maxColumn = 100
Expand Down
7 changes: 1 addition & 6 deletions sbt-uni/src/sbt-test/restart/basic/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
lazy val app = project
.in(file("app"))
.enablePlugins(UniPlugin)
.settings(
scalaVersion := "3.8.3"
)
lazy val app = project.in(file("app")).enablePlugins(UniPlugin).settings(scalaVersion := "3.8.3")
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import java.nio.file.{Files, Paths}
/**
* Test app for `uniRestart`. Writes a marker file named after its first program argument, but only
* when the system property `uni.test.enabled=true` is set. This lets the scripted test assert that
* BOTH program args (the file name) AND JVM args after `---` (the system property) are forwarded to
* the forked JVM. It then stays alive so the test can observe a running background process and
* BOTH program args (the file name) AND JVM args after `---` (the system property) are forwarded
* to the forked JVM. It then stays alive so the test can observe a running background process and
* later stop it.
*/
object Main:
Expand Down
Loading