From fc73eae720030b08a4fbb93429142f926a75a214 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 17 Oct 2021 23:55:25 +0000 Subject: [PATCH 1/5] Update to sjs-dom 2.0.0-RC1 --- build.sbt | 12 +++++---- .../scala/org/http4s/dom/FetchClient.scala | 15 ++++++----- .../org/http4s/dom/FetchClientBuilder.scala | 10 ++++---- .../org/http4s/dom/FetchEventContext.scala | 2 +- .../scala/org/http4s/dom/FetchOptions.scala | 10 ++++---- .../scala/org/http4s/dom/ServiceWorker.scala | 25 +++++++++---------- .../org/http4s/dom/TestServiceWorker.scala | 4 +-- .../test/scala/org/http4s/dom/DomSuite.scala | 3 +-- 8 files changed, 40 insertions(+), 41 deletions(-) diff --git a/build.sbt b/build.sbt index 3a87f840..e41ef0a5 100644 --- a/build.sbt +++ b/build.sbt @@ -23,7 +23,7 @@ import JSEnv._ name := "http4s-dom" -ThisBuild / baseVersion := "0.1" +ThisBuild / baseVersion := "0.2" ThisBuild / organization := "org.http4s" ThisBuild / organizationName := "http4s.org" @@ -39,7 +39,7 @@ ThisBuild / scmInfo := Some( url("https://github.com/http4s/http4s-dom"), "https://github.com/http4s/http4s-dom.git")) -ThisBuild / crossScalaVersions := Seq("2.12.15", "2.13.6") +ThisBuild / crossScalaVersions := Seq("2.12.15", "3.0.2", "2.13.6") replaceCommandAlias("ci", CI.AllCIs.map(_.toString).mkString) addCommandAlias("ciFirefox", CI.Firefox.toString) @@ -108,7 +108,7 @@ ThisBuild / Test / jsEnv := { val catsEffectVersion = "3.2.9" val fs2Version = "3.1.5" val http4sVersion = "0.23.6" -val scalaJSDomVersion = "1.2.0" +val scalaJSDomVersion = "2.0.0-RC1" val munitVersion = "0.7.29" val munitCEVersion = "1.0.6" @@ -125,7 +125,8 @@ lazy val dom = project "co.fs2" %%% "fs2-core" % fs2Version, "org.http4s" %%% "http4s-client" % http4sVersion, "org.scala-js" %%% "scalajs-dom" % scalaJSDomVersion - ) + ), + dependencyOverrides += "org.scala-js" %%% "scalajs-dom" % scalaJSDomVersion ) .enablePlugins(ScalaJSPlugin) @@ -139,7 +140,8 @@ lazy val tests = project libraryDependencies ++= Seq( "org.scalameta" %%% "munit" % munitVersion % Test, "org.typelevel" %%% "munit-cats-effect-3" % munitCEVersion % Test - ) + ), + dependencyOverrides += "org.scala-js" %%% "scalajs-dom" % scalaJSDomVersion ) .dependsOn(dom) .enablePlugins(ScalaJSPlugin, BuildInfoPlugin, NoPublishPlugin) diff --git a/dom/src/main/scala/org/http4s/dom/FetchClient.scala b/dom/src/main/scala/org/http4s/dom/FetchClient.scala index 9f4c16b5..e2049fb6 100644 --- a/dom/src/main/scala/org/http4s/dom/FetchClient.scala +++ b/dom/src/main/scala/org/http4s/dom/FetchClient.scala @@ -24,13 +24,12 @@ import cats.effect.syntax.all._ import cats.syntax.all._ import org.http4s.client.Client import org.http4s.headers.Referer -import org.scalajs.dom.crypto._ -import org.scalajs.dom.experimental.AbortController -import org.scalajs.dom.experimental.Fetch -import org.scalajs.dom.experimental.Headers -import org.scalajs.dom.experimental.HttpMethod -import org.scalajs.dom.experimental.RequestInit -import org.scalajs.dom.experimental.{Response => FetchResponse} +import org.scalajs.dom.AbortController +import org.scalajs.dom.Fetch +import org.scalajs.dom.Headers +import org.scalajs.dom.HttpMethod +import org.scalajs.dom.RequestInit +import org.scalajs.dom.{Response => FetchResponse} import java.util.concurrent.TimeoutException import scala.concurrent.duration._ @@ -52,7 +51,7 @@ private[dom] object FetchClient { init.method = req.method.name.asInstanceOf[HttpMethod] init.headers = new Headers(toDomHeaders(req.headers)) - body.foreach { body => init.body = arrayBuffer2BufferSource(body.toJSArrayBuffer) } + body.foreach { body => init.body = body.toJSArrayBuffer } init.signal = abortController.signal mergedOptions.cache.foreach(init.cache = _) mergedOptions.credentials.foreach(init.credentials = _) diff --git a/dom/src/main/scala/org/http4s/dom/FetchClientBuilder.scala b/dom/src/main/scala/org/http4s/dom/FetchClientBuilder.scala index 482fc328..5cb41f10 100644 --- a/dom/src/main/scala/org/http4s/dom/FetchClientBuilder.scala +++ b/dom/src/main/scala/org/http4s/dom/FetchClientBuilder.scala @@ -21,11 +21,11 @@ import cats.effect.Resource import org.http4s.client.Client import org.http4s.client.defaults import org.http4s.internal.BackendBuilder -import org.scalajs.dom.experimental.ReferrerPolicy -import org.scalajs.dom.experimental.RequestCache -import org.scalajs.dom.experimental.RequestCredentials -import org.scalajs.dom.experimental.RequestMode -import org.scalajs.dom.experimental.RequestRedirect +import org.scalajs.dom.ReferrerPolicy +import org.scalajs.dom.RequestCache +import org.scalajs.dom.RequestCredentials +import org.scalajs.dom.RequestMode +import org.scalajs.dom.RequestRedirect import scala.concurrent.duration._ diff --git a/dom/src/main/scala/org/http4s/dom/FetchEventContext.scala b/dom/src/main/scala/org/http4s/dom/FetchEventContext.scala index 1ac8c79c..b01f7d75 100644 --- a/dom/src/main/scala/org/http4s/dom/FetchEventContext.scala +++ b/dom/src/main/scala/org/http4s/dom/FetchEventContext.scala @@ -23,7 +23,7 @@ import cats.effect.SyncIO import cats.effect.kernel.Async import cats.effect.std.Supervisor import cats.syntax.all._ -import org.scalajs.dom.experimental.serviceworkers.FetchEvent +import org.scalajs.dom.FetchEvent import org.typelevel.vault.Key final class FetchEventContext[F[_]] private ( diff --git a/dom/src/main/scala/org/http4s/dom/FetchOptions.scala b/dom/src/main/scala/org/http4s/dom/FetchOptions.scala index 0346ddac..68a0ddef 100644 --- a/dom/src/main/scala/org/http4s/dom/FetchOptions.scala +++ b/dom/src/main/scala/org/http4s/dom/FetchOptions.scala @@ -17,11 +17,11 @@ package org.http4s.dom import cats.effect.SyncIO -import org.scalajs.dom.experimental.ReferrerPolicy -import org.scalajs.dom.experimental.RequestCache -import org.scalajs.dom.experimental.RequestCredentials -import org.scalajs.dom.experimental.RequestMode -import org.scalajs.dom.experimental.RequestRedirect +import org.scalajs.dom.ReferrerPolicy +import org.scalajs.dom.RequestCache +import org.scalajs.dom.RequestCredentials +import org.scalajs.dom.RequestMode +import org.scalajs.dom.RequestRedirect import org.typelevel.vault /** diff --git a/dom/src/main/scala/org/http4s/dom/ServiceWorker.scala b/dom/src/main/scala/org/http4s/dom/ServiceWorker.scala index 1f62cc85..f76f9018 100644 --- a/dom/src/main/scala/org/http4s/dom/ServiceWorker.scala +++ b/dom/src/main/scala/org/http4s/dom/ServiceWorker.scala @@ -28,13 +28,12 @@ import cats.effect.unsafe.IORuntime import cats.syntax.all._ import fs2.Chunk import fs2.Stream -import org.scalajs.dom.crypto._ -import org.scalajs.dom.experimental.Body -import org.scalajs.dom.experimental.Fetch -import org.scalajs.dom.experimental.ResponseInit -import org.scalajs.dom.experimental.serviceworkers.FetchEvent -import org.scalajs.dom.experimental.serviceworkers.ServiceWorkerGlobalScope -import org.scalajs.dom.experimental.{Response => DomResponse} +import org.scalajs.dom.Body +import org.scalajs.dom.Fetch +import org.scalajs.dom.ResponseInit +import org.scalajs.dom.FetchEvent +import org.scalajs.dom.ServiceWorkerGlobalScope +import org.scalajs.dom.{Response => DomResponse} import org.typelevel.vault.Key object ServiceWorker { @@ -91,15 +90,15 @@ object ServiceWorker { response <- routes(request) body <- OptionT.liftF( OptionT(response.body.chunkAll.filter(_.nonEmpty).compile.last).map { chunk => - arrayBuffer2BufferSource(chunk.toJSArrayBuffer) + chunk.toJSArrayBuffer }.value) } yield new DomResponse( body.getOrElse(null), - ResponseInit( - response.status.code, - response.status.reason, - toDomHeaders(response.headers) - ) + new ResponseInit { + var status = response.status.code + var statusText = response.status.reason + var headers = toDomHeaders(response.headers) + } ) } diff --git a/tests/src/main/scala/org/http4s/dom/TestServiceWorker.scala b/tests/src/main/scala/org/http4s/dom/TestServiceWorker.scala index bb28f69d..33f4d41b 100644 --- a/tests/src/main/scala/org/http4s/dom/TestServiceWorker.scala +++ b/tests/src/main/scala/org/http4s/dom/TestServiceWorker.scala @@ -18,8 +18,8 @@ package org.http4s.dom import cats.effect.IO import cats.effect.unsafe.implicits._ -import org.scalajs.dom.experimental.serviceworkers.ExtendableEvent -import org.scalajs.dom.experimental.serviceworkers.ServiceWorkerGlobalScope +import org.scalajs.dom.ExtendableEvent +import org.scalajs.dom.ServiceWorkerGlobalScope object TestServiceWorker { diff --git a/tests/src/test/scala/org/http4s/dom/DomSuite.scala b/tests/src/test/scala/org/http4s/dom/DomSuite.scala index 998bf964..b69819e2 100644 --- a/tests/src/test/scala/org/http4s/dom/DomSuite.scala +++ b/tests/src/test/scala/org/http4s/dom/DomSuite.scala @@ -26,8 +26,7 @@ import org.http4s.client.dsl.io._ import org.http4s.multipart.Multipart import org.http4s.multipart.Part import org.http4s.syntax.all._ -import org.scalajs.dom.experimental.serviceworkers._ -import org.scalajs.dom.raw.Event +import org.scalajs.dom.Event import org.scalajs.dom.window import scala.concurrent.duration._ From 527db79ec44b0ac4aae30a5d7d267e186f96577c Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 17 Oct 2021 23:57:43 +0000 Subject: [PATCH 2/5] Regenerate workflow --- .github/workflows/ci.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 188d65aa..85aa3ea3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.12.15, 2.13.6] + scala: [2.12.15, 3.0.2, 2.13.6] java: [adopt@1.8] runs-on: ${{ matrix.os }} steps: @@ -109,6 +109,16 @@ jobs: tar xf targets.tar rm targets.tar + - name: Download target directories (3.0.2) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-3.0.2-${{ matrix.java }} + + - name: Inflate target directories (3.0.2) + run: | + tar xf targets.tar + rm targets.tar + - name: Download target directories (2.13.6) uses: actions/download-artifact@v2 with: From 0cf709c9e3e0fc3729e9d5e97aa67ce70cbe8e2f Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 24 Oct 2021 02:56:02 +0000 Subject: [PATCH 3/5] Update to Scala 3.1, cleanup build --- .github/workflows/ci.yml | 12 ++++++------ build.sbt | 8 +++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85aa3ea3..14551759 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,9 +9,9 @@ name: Continuous Integration on: pull_request: - branches: [series/0.1] + branches: [series/0.2] push: - branches: [series/0.1] + branches: [series/0.2] tags: [v*] env: @@ -26,7 +26,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.12.15, 3.0.2, 2.13.6] + scala: [2.12.15, 3.1.0, 2.13.6] java: [adopt@1.8] runs-on: ${{ matrix.os }} steps: @@ -109,12 +109,12 @@ jobs: tar xf targets.tar rm targets.tar - - name: Download target directories (3.0.2) + - name: Download target directories (3.1.0) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-3.0.2-${{ matrix.java }} + name: target-${{ matrix.os }}-3.1.0-${{ matrix.java }} - - name: Inflate target directories (3.0.2) + - name: Inflate target directories (3.1.0) run: | tar xf targets.tar rm targets.tar diff --git a/build.sbt b/build.sbt index e5fd1062..012fb0f7 100644 --- a/build.sbt +++ b/build.sbt @@ -31,7 +31,7 @@ ThisBuild / publishGithubUser := "armanbilge" ThisBuild / publishFullName := "Arman Bilge" enablePlugins(SonatypeCiReleasePlugin) -ThisBuild / githubWorkflowTargetBranches := Seq("series/0.1") +ThisBuild / githubWorkflowTargetBranches := Seq("series/0.2") ThisBuild / homepage := Some(url("https://github.com/http4s/http4s-dom")) ThisBuild / scmInfo := Some( @@ -39,7 +39,7 @@ ThisBuild / scmInfo := Some( url("https://github.com/http4s/http4s-dom"), "https://github.com/http4s/http4s-dom.git")) -ThisBuild / crossScalaVersions := Seq("2.12.15", "3.0.2", "2.13.6") +ThisBuild / crossScalaVersions := Seq("2.12.15", "3.1.0", "2.13.6") replaceCommandAlias("ci", CI.AllCIs.map(_.toString).mkString) addCommandAlias("ciFirefox", CI.Firefox.toString) @@ -122,11 +122,10 @@ lazy val dom = project description := "http4s browser integrations", libraryDependencies ++= Seq( "org.typelevel" %%% "cats-effect" % catsEffectVersion, - "co.fs2" %%% "fs2-core" % fs2Version, + "co.fs2" %%% "fs2-io" % fs2Version, "org.http4s" %%% "http4s-client" % http4sVersion, "org.scala-js" %%% "scalajs-dom" % scalaJSDomVersion ), - dependencyOverrides += "org.scala-js" %%% "scalajs-dom" % scalaJSDomVersion ) .enablePlugins(ScalaJSPlugin) @@ -141,7 +140,6 @@ lazy val tests = project "org.scalameta" %%% "munit" % munitVersion % Test, "org.typelevel" %%% "munit-cats-effect-3" % munitCEVersion % Test ), - dependencyOverrides += "org.scala-js" %%% "scalajs-dom" % scalaJSDomVersion ) .dependsOn(dom) .enablePlugins(ScalaJSPlugin, BuildInfoPlugin, NoPublishPlugin) From 402779456189650f2ad84f962725162e2e61a773 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 24 Oct 2021 02:58:34 +0000 Subject: [PATCH 4/5] Bump to sjs-dom 2.0.0 final --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 012fb0f7..5aaada5f 100644 --- a/build.sbt +++ b/build.sbt @@ -108,7 +108,7 @@ ThisBuild / Test / jsEnv := { val catsEffectVersion = "3.2.9" val fs2Version = "3.2.0" val http4sVersion = "0.23.6" -val scalaJSDomVersion = "2.0.0-RC1" +val scalaJSDomVersion = "2.0.0" val munitVersion = "0.7.29" val munitCEVersion = "1.0.6" From c7ec46ba68e2cb54e2bb2fcfbccb3de26c7d6817 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 24 Oct 2021 03:00:39 +0000 Subject: [PATCH 5/5] Formatting --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 5aaada5f..b32f1512 100644 --- a/build.sbt +++ b/build.sbt @@ -125,7 +125,7 @@ lazy val dom = project "co.fs2" %%% "fs2-io" % fs2Version, "org.http4s" %%% "http4s-client" % http4sVersion, "org.scala-js" %%% "scalajs-dom" % scalaJSDomVersion - ), + ) ) .enablePlugins(ScalaJSPlugin) @@ -139,7 +139,7 @@ lazy val tests = project libraryDependencies ++= Seq( "org.scalameta" %%% "munit" % munitVersion % Test, "org.typelevel" %%% "munit-cats-effect-3" % munitCEVersion % Test - ), + ) ) .dependsOn(dom) .enablePlugins(ScalaJSPlugin, BuildInfoPlugin, NoPublishPlugin)