From 81f4852413fae8509b2c005b391a0c18baa7741b Mon Sep 17 00:00:00 2001 From: "typelevel-steward[bot]" <207424+typelevel-steward[bot]@users.noreply.github.com> Date: Fri, 3 Jun 2022 18:05:22 +0000 Subject: [PATCH 01/27] Update sbt-http4s-org to 0.13.4 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4feb1d15..7ea8c665 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -7,7 +7,7 @@ libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1" libraryDependencies += "org.http4s" %% "http4s-dsl" % http4sVersion libraryDependencies += "org.http4s" %% "http4s-blaze-server" % "0.23.12" -addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.13.2") +addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.13.4") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") From 7c9eb1b550fce5923a39f7409e2a4ecb17bb9778 Mon Sep 17 00:00:00 2001 From: "typelevel-steward[bot]" <207424+typelevel-steward[bot]@users.noreply.github.com> Date: Fri, 3 Jun 2022 18:05:53 +0000 Subject: [PATCH 02/27] Update scalafmt-core to 3.5.8 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 7e57088d..e1c3a6dd 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.5.2 +version = 3.5.8 runner.dialect = Scala213Source3 From 05b05733552205e7218773bdfc3ec92c7fefb751 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Fri, 3 Jun 2022 20:21:38 +0000 Subject: [PATCH 03/27] Chunked requests should be made strict --- .../scala/org/http4s/dom/FetchClient.scala | 97 ++++++++++--------- 1 file changed, 52 insertions(+), 45 deletions(-) diff --git a/dom/src/main/scala/org/http4s/dom/FetchClient.scala b/dom/src/main/scala/org/http4s/dom/FetchClient.scala index 5e12546f..c410e010 100644 --- a/dom/src/main/scala/org/http4s/dom/FetchClient.scala +++ b/dom/src/main/scala/org/http4s/dom/FetchClient.scala @@ -41,57 +41,64 @@ private[dom] object FetchClient { requestTimeout: Duration, options: FetchOptions )(implicit F: Async[F]): Client[F] = Client[F] { (req: Request[F]) => - Resource.eval(req.body.chunkAll.filter(_.nonEmpty).compile.last).flatMap { body => - Resource - .makeCaseFull { (poll: Poll[F]) => - F.delay(new AbortController()).flatMap { abortController => - val requestOptions = req.attributes.lookup(FetchOptions.Key) - val mergedOptions = requestOptions.fold(options)(options.merge) + Resource + .eval( + (if (req.isChunked) req.toStrict(None) else req.pure) + .mproduct(_.body.chunkAll.filter(_.nonEmpty).compile.last) + ) + .flatMap { + case (req, body) => + Resource + .makeCaseFull { (poll: Poll[F]) => + F.delay(new AbortController()).flatMap { abortController => + val requestOptions = req.attributes.lookup(FetchOptions.Key) + val mergedOptions = requestOptions.fold(options)(options.merge) - val init = new RequestInit {} + val init = new RequestInit {} - init.method = req.method.name.asInstanceOf[HttpMethod] - init.headers = new Headers(toDomHeaders(req.headers)) - body.foreach { body => init.body = body.toJSArrayBuffer } - init.signal = abortController.signal - mergedOptions.cache.foreach(init.cache = _) - mergedOptions.credentials.foreach(init.credentials = _) - mergedOptions.integrity.foreach(init.integrity = _) - mergedOptions.keepAlive.foreach(init.keepalive = _) - mergedOptions.mode.foreach(init.mode = _) - mergedOptions.redirect.foreach(init.redirect = _) - // Referer headers are forbidden in Fetch, but we make a best effort to preserve behavior across clients. - // See https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name - // If there's a Referer header, it will have more priority than the client's `referrer` (if present) - // but less priority than the request's `referrer` (if present). - requestOptions - .flatMap(_.referrer) - .orElse(req.headers.get[Referer].map(_.uri)) - .orElse(options.referrer) - .foreach(referrer => init.referrer = referrer.renderString) - mergedOptions.referrerPolicy.foreach(init.referrerPolicy = _) + init.method = req.method.name.asInstanceOf[HttpMethod] + init.headers = new Headers(toDomHeaders(req.headers)) + body.foreach { body => init.body = body.toJSArrayBuffer } + init.signal = abortController.signal + mergedOptions.cache.foreach(init.cache = _) + mergedOptions.credentials.foreach(init.credentials = _) + mergedOptions.integrity.foreach(init.integrity = _) + mergedOptions.keepAlive.foreach(init.keepalive = _) + mergedOptions.mode.foreach(init.mode = _) + mergedOptions.redirect.foreach(init.redirect = _) + // Referer headers are forbidden in Fetch, but we make a best effort to preserve behavior across clients. + // See https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name + // If there's a Referer header, it will have more priority than the client's `referrer` (if present) + // but less priority than the request's `referrer` (if present). + requestOptions + .flatMap(_.referrer) + .orElse(req.headers.get[Referer].map(_.uri)) + .orElse(options.referrer) + .foreach(referrer => init.referrer = referrer.renderString) + mergedOptions.referrerPolicy.foreach(init.referrerPolicy = _) - val fetch = poll(F.fromPromise(F.delay(Fetch.fetch(req.uri.renderString, init)))) - .onCancel(F.delay(abortController.abort())) + val fetch = + poll(F.fromPromise(F.delay(Fetch.fetch(req.uri.renderString, init)))) + .onCancel(F.delay(abortController.abort())) - requestTimeout match { - case d: FiniteDuration => - fetch.timeoutTo( - d, - F.raiseError[FetchResponse](new TimeoutException( - s"Request to ${req.uri.renderString} timed out after ${d.toMillis} ms")) - ) - case _ => - fetch + requestTimeout match { + case d: FiniteDuration => + fetch.timeoutTo( + d, + F.raiseError[FetchResponse](new TimeoutException( + s"Request to ${req.uri.renderString} timed out after ${d.toMillis} ms")) + ) + case _ => + fetch + } + } + } { + case (r, exitCase) => + OptionT.fromOption(Option(r.body)).foreachF(closeReadableStream(_, exitCase)) } - } - } { - case (r, exitCase) => - OptionT.fromOption(Option(r.body)).foreachF(closeReadableStream(_, exitCase)) - } - .evalMap(fromDomResponse[F]) + .evalMap(fromDomResponse[F]) - } + } } } From 4e4054f406c9dd1497c54cad856517f3723546f3 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Fri, 3 Jun 2022 15:10:19 -0700 Subject: [PATCH 04/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a1ba0993..7c433e3a 100644 --- a/README.md +++ b/README.md @@ -18,5 +18,5 @@ It is also possible to use the `FetchClient` in Node.js v18+, which added [exper [![http4s-dom Scala version support](https://index.scala-lang.org/http4s/http4s-dom/http4s-dom/latest.svg)](https://index.scala-lang.org/http4s/http4s-dom/http4s-dom) ```scala -libraryDependencies += "org.http4s" %%% "http4s-dom" % "0.2.2" +libraryDependencies += "org.http4s" %%% "http4s-dom" % "0.2.3" ``` From bb7a465f45d68157eeca7b9d17211284daede101 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Fri, 3 Jun 2022 22:39:25 +0000 Subject: [PATCH 05/27] Move deps to relevant example --- docs/fetch.md | 5 +++++ docs/index.md | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/fetch.md b/docs/fetch.md index cb7e86c8..6a92aa4c 100644 --- a/docs/fetch.md +++ b/docs/fetch.md @@ -4,6 +4,11 @@ The @:api(org.http4s.dom.FetchClientBuilder) creates a standard http4s @:api(org ## Example +```scala +libraryDependencies += "org.http4s" %%% "http4s-circe" % "@HTTP4S_VERSION@" +libraryDependencies += "io.circe" %%% "circe-generic" % "@CIRCE_VERSION@" +``` + ```scala mdoc:js

diff --git a/docs/index.md b/docs/index.md index 354adfca..f46516ef 100644 --- a/docs/index.md +++ b/docs/index.md @@ -21,8 +21,4 @@ libraryDependencies += "org.http4s" %%% "http4s-dom" % "@VERSION@" // recommended, brings in the latest client module libraryDependencies += "org.http4s" %%% "http4s-client" % "@HTTP4S_VERSION@" - -// optional, for JSON support -libraryDependencies += "org.http4s" %%% "http4s-circe" % "@HTTP4S_VERSION@" -libraryDependencies += "io.circe" %%% "circe-generic" % "@CIRCE_VERSION@" ``` From 0f5cc2891308d18157c281751196c79ef4c213ae Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Sat, 4 Jun 2022 20:27:02 +0000 Subject: [PATCH 06/27] Update sbt-http4s-org to 0.14.0 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 7ea8c665..982fb681 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -7,7 +7,7 @@ libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1" libraryDependencies += "org.http4s" %% "http4s-dsl" % http4sVersion libraryDependencies += "org.http4s" %% "http4s-blaze-server" % "0.23.12" -addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.13.4") +addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.0") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") From 3113a23b7f92aaecd31f1d20ad3d4f70739f683b Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Sat, 4 Jun 2022 20:27:30 +0000 Subject: [PATCH 07/27] Regenerate workflow with sbt-github-actions --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffdb596e..8902fb8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,6 +100,10 @@ jobs: if: matrix.java == 'temurin@8' run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' doc' + - name: Check scalafix lints + if: matrix.java == 'temurin@8' && !startsWith(matrix.scala, '3.') + run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' ''scalafixAll --check''' + - name: Check unused compile dependencies if: matrix.java == 'temurin@8' run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' unusedCompileDependenciesTest' From ac7fb248f93683550d9cf19ffaa4a8655222cd12 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 5 Jun 2022 00:19:50 +0000 Subject: [PATCH 08/27] scalafixAll --- .scalafix.conf | 15 +++++++++++++++ .../main/scala/org/http4s/dom/ServiceWorker.scala | 2 +- .../scala/org/http4s/dom/NodeJSFetchSuite.scala | 4 +++- .../org/http4s/dom/FetchServiceWorkerSuite.scala | 5 +++-- 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 .scalafix.conf diff --git a/.scalafix.conf b/.scalafix.conf new file mode 100644 index 00000000..44c071e0 --- /dev/null +++ b/.scalafix.conf @@ -0,0 +1,15 @@ +rules = [ + Http4sFs2Linters + Http4sGeneralLinters + Http4sUseLiteralsSyntax + LeakingImplicitClassVal + ExplicitResultTypes + OrganizeImports +] + +triggered.rules = [ + Http4sFs2Linters + Http4sGeneralLinters + Http4sUseLiteralsSyntax + LeakingImplicitClassVal +] \ No newline at end of file diff --git a/dom/src/main/scala/org/http4s/dom/ServiceWorker.scala b/dom/src/main/scala/org/http4s/dom/ServiceWorker.scala index fac860a6..1720e427 100644 --- a/dom/src/main/scala/org/http4s/dom/ServiceWorker.scala +++ b/dom/src/main/scala/org/http4s/dom/ServiceWorker.scala @@ -29,8 +29,8 @@ import cats.syntax.all._ import fs2.Chunk import fs2.Stream import org.scalajs.dom.Fetch -import org.scalajs.dom.ResponseInit import org.scalajs.dom.FetchEvent +import org.scalajs.dom.ResponseInit import org.scalajs.dom.ServiceWorkerGlobalScope import org.scalajs.dom.{Response => DomResponse} import org.typelevel.vault.Key diff --git a/tests-nodejs/src/test/scala/org/http4s/dom/NodeJSFetchSuite.scala b/tests-nodejs/src/test/scala/org/http4s/dom/NodeJSFetchSuite.scala index 52007a93..bbb66051 100644 --- a/tests-nodejs/src/test/scala/org/http4s/dom/NodeJSFetchSuite.scala +++ b/tests-nodejs/src/test/scala/org/http4s/dom/NodeJSFetchSuite.scala @@ -18,8 +18,10 @@ package org.http4s package dom import cats.effect.IO +import cats.effect.Resource +import org.http4s.client.Client import org.http4s.client.testkit.ClientRouteTestBattery class NodeJSFetchSuite extends ClientRouteTestBattery("FetchClient") { - def clientResource = FetchClientBuilder[IO].resource + def clientResource: Resource[IO,Client[IO]] = FetchClientBuilder[IO].resource } diff --git a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala index b3b36a4e..a18d6bfe 100644 --- a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala +++ b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala @@ -22,6 +22,7 @@ import cats.syntax.all._ import fs2.Stream import munit.CatsEffectSuite import org.http4s.Method._ +import org.http4s.client.Client import org.http4s.client.dsl.io._ import org.http4s.client.testkit.testroutes.GetRoutes import org.http4s.multipart.Multiparts @@ -35,9 +36,9 @@ import scala.scalajs.js class FetchServiceWorkerSuite extends CatsEffectSuite { - val client = FetchClientBuilder[IO].create + val client: Client[IO] = FetchClientBuilder[IO].create - val baseUrl = uri"/" + val baseUrl: Uri = uri"/" test("Install service worker") { IO.fromPromise { From 400aa1608a05dc490093ebc9e78a8ab3c25d752a Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 5 Jun 2022 00:21:57 +0000 Subject: [PATCH 09/27] Formatting --- .../src/test/scala/org/http4s/dom/NodeJSFetchSuite.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests-nodejs/src/test/scala/org/http4s/dom/NodeJSFetchSuite.scala b/tests-nodejs/src/test/scala/org/http4s/dom/NodeJSFetchSuite.scala index bbb66051..bdea5225 100644 --- a/tests-nodejs/src/test/scala/org/http4s/dom/NodeJSFetchSuite.scala +++ b/tests-nodejs/src/test/scala/org/http4s/dom/NodeJSFetchSuite.scala @@ -23,5 +23,5 @@ import org.http4s.client.Client import org.http4s.client.testkit.ClientRouteTestBattery class NodeJSFetchSuite extends ClientRouteTestBattery("FetchClient") { - def clientResource: Resource[IO,Client[IO]] = FetchClientBuilder[IO].resource + def clientResource: Resource[IO, Client[IO]] = FetchClientBuilder[IO].resource } From 6d20e57d4a4dee816354e1020a74f036a6a03164 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 5 Jun 2022 00:27:16 +0000 Subject: [PATCH 10/27] newline --- .scalafix.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafix.conf b/.scalafix.conf index 44c071e0..ab1b91a6 100644 --- a/.scalafix.conf +++ b/.scalafix.conf @@ -12,4 +12,4 @@ triggered.rules = [ Http4sGeneralLinters Http4sUseLiteralsSyntax LeakingImplicitClassVal -] \ No newline at end of file +] From 966a3138f9ef80911aa7a35ee50f100dea1500ce Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 4 Jun 2022 18:14:53 -0700 Subject: [PATCH 11/27] Bumpity bump --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 982fb681..007f8a84 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -7,7 +7,7 @@ libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1" libraryDependencies += "org.http4s" %% "http4s-dsl" % http4sVersion libraryDependencies += "org.http4s" %% "http4s-blaze-server" % "0.23.12" -addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.0") +addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.1") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") From 49a8e229aa0825bf991c1c8c261436c6b9d645fe Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Mon, 6 Jun 2022 02:06:48 +0000 Subject: [PATCH 12/27] Update sbt-http4s-org to 0.14.2 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 007f8a84..15d8b18f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -7,7 +7,7 @@ libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1" libraryDependencies += "org.http4s" %% "http4s-dsl" % http4sVersion libraryDependencies += "org.http4s" %% "http4s-blaze-server" % "0.23.12" -addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.1") +addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.2") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") From 0c3c5376f65031946cd5080982362541151c9bf4 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Fri, 10 Jun 2022 16:43:17 +0000 Subject: [PATCH 13/27] Update fs2-core to 3.2.8 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index e7ad15c4..7c5628f7 100644 --- a/build.sbt +++ b/build.sbt @@ -121,7 +121,7 @@ ThisBuild / Test / jsEnv := { } val catsEffectVersion = "3.3.12" -val fs2Version = "3.2.7" +val fs2Version = "3.2.8" val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project val scalaJSDomVersion = "2.2.0" val circeVersion = "0.14.2" From 9d906ed828cc66db42f3ea9211d67dc04459db11 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Fri, 10 Jun 2022 16:43:23 +0000 Subject: [PATCH 14/27] Update scala-library to 2.12.16 --- .github/workflows/ci.yml | 6 +++--- build.sbt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8902fb8e..c1c037c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,13 +29,13 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - scala: [2.12.15, 3.1.2, 2.13.8] + scala: [2.12.16, 3.1.2, 2.13.8] java: [temurin@8] jsenv: [Chrome, Firefox, NodeJS] exclude: - - scala: 2.12.15 + - scala: 2.12.16 jsenv: Firefox - - scala: 2.12.15 + - scala: 2.12.16 jsenv: NodeJS - scala: 3.1.2 jsenv: Firefox diff --git a/build.sbt b/build.sbt index e7ad15c4..72011059 100644 --- a/build.sbt +++ b/build.sbt @@ -34,7 +34,7 @@ ThisBuild / githubWorkflowTargetBranches := Seq("series/0.2") ThisBuild / tlCiReleaseBranches := Seq("series/0.2") ThisBuild / tlSitePublishBranch := Some("series/0.2") -ThisBuild / crossScalaVersions := Seq("2.12.15", "3.1.2", "2.13.8") +ThisBuild / crossScalaVersions := Seq("2.12.16", "3.1.2", "2.13.8") ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8")) val jsEnvs = List("Chrome", "Firefox", "NodeJS") From 38b053f7e544e0f2f1ed696a50632bb117300923 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Fri, 10 Jun 2022 16:43:53 +0000 Subject: [PATCH 15/27] Regenerate workflow with sbt-github-actions --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1c037c5..b72de796 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -167,12 +167,12 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - name: Download target directories (2.12.15, Chrome) + - name: Download target directories (2.12.16, Chrome) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-Chrome + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.16-Chrome - - name: Inflate target directories (2.12.15, Chrome) + - name: Inflate target directories (2.12.16, Chrome) run: | tar xf targets.tar rm targets.tar From 66ca9f3b2200cadced31f4c2c3f128b71fe0e7c8 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Sat, 11 Jun 2022 01:11:56 +0000 Subject: [PATCH 16/27] Update sbt-http4s-org to 0.14.3 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 15d8b18f..dd0e3355 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -7,7 +7,7 @@ libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1" libraryDependencies += "org.http4s" %% "http4s-dsl" % http4sVersion libraryDependencies += "org.http4s" %% "http4s-blaze-server" % "0.23.12" -addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.2") +addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.3") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") From ae0bff43897bb22724c503ea2f3a882acfd313b4 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 11 Jun 2022 01:35:00 +0000 Subject: [PATCH 17/27] Don't use `INothing` and fix as needed --- .../main/scala/org/http4s/dom/WebSocketClient.scala | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/dom/src/main/scala/org/http4s/dom/WebSocketClient.scala b/dom/src/main/scala/org/http4s/dom/WebSocketClient.scala index 41ce3dfb..3a96d225 100644 --- a/dom/src/main/scala/org/http4s/dom/WebSocketClient.scala +++ b/dom/src/main/scala/org/http4s/dom/WebSocketClient.scala @@ -26,7 +26,6 @@ import cats.effect.std.Queue import cats.effect.std.Semaphore import cats.effect.syntax.all._ import cats.syntax.all._ -import fs2.INothing import fs2.Stream import org.http4s.Method import org.http4s.client.websocket.WSClientHighLevel @@ -51,7 +50,7 @@ object WebSocketClient { dispatcher <- Dispatcher[F] messages <- Queue.unbounded[F, Option[MessageEvent]].toResource semaphore <- Semaphore[F](1).toResource - error <- F.deferred[Either[Throwable, INothing]].toResource + error <- F.deferred[Throwable].toResource close <- F.deferred[CloseEvent].toResource ws <- Resource.makeCase { F.async_[WebSocket] { cb => @@ -69,8 +68,7 @@ object WebSocketClient { ws.onopen = { _ => ws.onerror = // replace the error handler - e => - dispatcher.unsafeRunAndForget(error.complete(Left(js.JavaScriptException(e)))) + e => dispatcher.unsafeRunAndForget(error.complete(js.JavaScriptException(e))) cb(Right(ws)) } @@ -122,7 +120,7 @@ object WebSocketClient { def receive: F[Option[WSDataFrame]] = semaphore .permit .surround(OptionT(messages.take).map(decodeMessage).value) - .race(error.get.rethrow) + .race(error.get.flatMap(F.raiseError[Option[WSDataFrame]])) .map(_.merge) override def receiveStream: Stream[F, WSDataFrame] = @@ -130,7 +128,7 @@ object WebSocketClient { .resource(semaphore.permit) .flatMap(_ => Stream.fromQueueNoneTerminated(messages)) .map(decodeMessage) - .concurrently(Stream.exec(error.get.rethrow.widen)) + .concurrently(Stream.exec(error.get.flatMap(F.raiseError))) private def decodeMessage(e: MessageEvent): WSDataFrame = e.data match { @@ -156,7 +154,7 @@ object WebSocketClient { } private def errorOr(fu: F[Unit]): F[Unit] = error.tryGet.flatMap { - case Some(error) => F.fromEither[Unit](error) + case Some(error) => F.raiseError(error) case None => fu } From ec8769d5564a5cc2306197e31da4234818aead27 Mon Sep 17 00:00:00 2001 From: Filipe Regadas Date: Sat, 11 Jun 2022 10:00:44 +0100 Subject: [PATCH 18/27] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7c433e3a..b0ae7bcb 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ Use http4s in your browser with Scala.js! Check out the [interactive examples](h Features: * A [`Client` implementation](fetch.md) backed by [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) -* A [`WSClient` implementation](websocket.md) backed by [`WebSocket`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket$.html) -* A [`Service Worker` integration](serviceworker.md) to install your `HttpRoutes` as a [`FetchEvent` handler](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/onfetch) +* A [`WSClient` implementation](websocket.md) backed by [`WebSocket`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) +* A [`Service Worker` integration](serviceworker.md) to install your `HttpRoutes` as a [`FetchEvent` handler](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/fetch_event) * Encoders for [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File), [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) and [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) Notably, http4s-dom can also be used to create _serverless_ apps with [Cloudflare Workers](https://workers.cloudflare.com) which have adopted the same APIs used in the browser! From bc19b7c5953cb05f398d95c0ef82faac96bb1b10 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 11 Jun 2022 10:13:55 -0700 Subject: [PATCH 19/27] [ci skip] fix more README links --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b0ae7bcb..d2f66858 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ Use http4s in your browser with Scala.js! Check out the [interactive examples](h Features: -* A [`Client` implementation](fetch.md) backed by [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) -* A [`WSClient` implementation](websocket.md) backed by [`WebSocket`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) -* A [`Service Worker` integration](serviceworker.md) to install your `HttpRoutes` as a [`FetchEvent` handler](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/fetch_event) +* A [`Client` implementation](https://http4s.github.io/http4s-dom/fetch.html) backed by [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) +* A [`WSClient` implementation](https://http4s.github.io/http4s-dom/websocket.html) backed by [`WebSocket`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) +* A [`Service Worker` integration](https://http4s.github.io/http4s-dom/serviceworker.html) to install your `HttpRoutes` as a [`FetchEvent` handler](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/fetch_event) * Encoders for [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File), [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) and [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) Notably, http4s-dom can also be used to create _serverless_ apps with [Cloudflare Workers](https://workers.cloudflare.com) which have adopted the same APIs used in the browser! From 09ea71f4cd478ba21ac9691f4aa6404d0fb1a1c3 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 15 Jun 2022 03:17:58 +0000 Subject: [PATCH 20/27] Replace Bored API with GH API in fetch docs --- docs/fetch.md | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/docs/fetch.md b/docs/fetch.md index 6a92aa4c..2e487ba9 100644 --- a/docs/fetch.md +++ b/docs/fetch.md @@ -10,12 +10,11 @@ libraryDependencies += "io.circe" %%% "circe-generic" % "@CIRCE_VERSION@" ``` ```scala mdoc:js -
-

- I'm bored. -

- -

+
+

How many stars?

+ + +
--- import cats.effect._ @@ -27,17 +26,24 @@ import org.scalajs.dom._ val client = FetchClientBuilder[IO].create -val activityElement = document.getElementById("activity") - -case class Activity(activity: String) - -val fetchActivity: IO[Unit] = for { - _ <- IO(activityElement.innerHTML = "fetching...") - activity <- client.expect[Activity]("https://www.boredapi.com/api/activity") - _ <- IO(activityElement.innerHTML = activity.activity) +val repoName = document.getElementById("repo").asInstanceOf[HTMLInputElement] +val repoStars = document.getElementById("stars").asInstanceOf[HTMLInputElement] + +case class Repo(stargazers_count: Int) + +val fetchRepo: IO[Unit] = for { + _ <- IO(repoStars.innerHTML = "fetching...") + name <- IO(repoName.value) + repo <- client.expect[Repo](s"https://api.github.com/repos/$name").attempt + _ <- IO { + repo match { + case Right(Repo(stars)) => repoStars.innerHTML = s"$stars ★" + case Left(_) => repoStars.innerHTML = s"Not found :(" + } + } } yield () val button = document.getElementById("button").asInstanceOf[HTMLButtonElement] -button.onclick = _ => fetchActivity.unsafeRunAndForget() +button.onclick = _ => fetchRepo.unsafeRunAndForget() ``` From 61e7e043ef34c5b39025bc35c3462369c987329b Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 19 Jun 2022 19:58:55 -0700 Subject: [PATCH 21/27] Fix cast --- docs/fetch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fetch.md b/docs/fetch.md index 2e487ba9..d9050a02 100644 --- a/docs/fetch.md +++ b/docs/fetch.md @@ -27,7 +27,7 @@ import org.scalajs.dom._ val client = FetchClientBuilder[IO].create val repoName = document.getElementById("repo").asInstanceOf[HTMLInputElement] -val repoStars = document.getElementById("stars").asInstanceOf[HTMLInputElement] +val repoStars = document.getElementById("stars").asInstanceOf[HTMLElement] case class Repo(stargazers_count: Int) From 6a030ecd261a9dfbbb8e44a9c55c7cb9052992f5 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Tue, 21 Jun 2022 16:40:51 +0000 Subject: [PATCH 22/27] Update scala3-library, ... to 3.1.3 --- .github/workflows/ci.yml | 6 +++--- build.sbt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b72de796..a2ca66bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - scala: [2.12.16, 3.1.2, 2.13.8] + scala: [2.12.16, 3.1.3, 2.13.8] java: [temurin@8] jsenv: [Chrome, Firefox, NodeJS] exclude: @@ -37,9 +37,9 @@ jobs: jsenv: Firefox - scala: 2.12.16 jsenv: NodeJS - - scala: 3.1.2 + - scala: 3.1.3 jsenv: Firefox - - scala: 3.1.2 + - scala: 3.1.3 jsenv: NodeJS runs-on: ${{ matrix.os }} steps: diff --git a/build.sbt b/build.sbt index 6407fae0..33230963 100644 --- a/build.sbt +++ b/build.sbt @@ -34,7 +34,7 @@ ThisBuild / githubWorkflowTargetBranches := Seq("series/0.2") ThisBuild / tlCiReleaseBranches := Seq("series/0.2") ThisBuild / tlSitePublishBranch := Some("series/0.2") -ThisBuild / crossScalaVersions := Seq("2.12.16", "3.1.2", "2.13.8") +ThisBuild / crossScalaVersions := Seq("2.12.16", "3.1.3", "2.13.8") ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8")) val jsEnvs = List("Chrome", "Firefox", "NodeJS") From 2dc808367c41e4cc6d642d807ad3fce811db1ab9 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Tue, 21 Jun 2022 16:41:27 +0000 Subject: [PATCH 23/27] Regenerate workflow with sbt-github-actions --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2ca66bc..cf5840de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -177,12 +177,12 @@ jobs: tar xf targets.tar rm targets.tar - - name: Download target directories (3.1.2, Chrome) + - name: Download target directories (3.1.3, Chrome) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.2-Chrome + name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.3-Chrome - - name: Inflate target directories (3.1.2, Chrome) + - name: Inflate target directories (3.1.3, Chrome) run: | tar xf targets.tar rm targets.tar From 5fb61119049913decb7f2ac024cc9bdb1026b3ee Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Fri, 24 Jun 2022 20:24:21 +0000 Subject: [PATCH 24/27] Update http4s-client, ... to 0.23.13 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index dd0e3355..e3a99552 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -val http4sVersion = "0.23.12" +val http4sVersion = "0.23.13" enablePlugins(BuildInfoPlugin) buildInfoKeys += "http4sVersion" -> http4sVersion From 3f23262a1ca9f47219037e5c7b0e4e2eb1257f70 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Sat, 25 Jun 2022 16:30:25 +0000 Subject: [PATCH 25/27] Update sbt-scalajs, scalajs-compiler, ... to 1.10.1 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index e3a99552..b838f0b8 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -9,5 +9,5 @@ libraryDependencies += "org.http4s" %% "http4s-blaze-server" % "0.23.12" addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.3") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") From d5160f4aa3c50f23b6cd541df1875f81ba55b73d Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Tue, 28 Jun 2022 20:25:40 +0000 Subject: [PATCH 26/27] Update cats-effect to 3.3.13 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 33230963..3e5a448c 100644 --- a/build.sbt +++ b/build.sbt @@ -120,7 +120,7 @@ ThisBuild / Test / jsEnv := { } } -val catsEffectVersion = "3.3.12" +val catsEffectVersion = "3.3.13" val fs2Version = "3.2.8" val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project val scalaJSDomVersion = "2.2.0" From 6baf04621ad3edba6c97fd2949a44677d424430e Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Fri, 1 Jul 2022 20:26:03 +0000 Subject: [PATCH 27/27] Update fs2-core to 3.2.9 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 3e5a448c..501c97d4 100644 --- a/build.sbt +++ b/build.sbt @@ -121,7 +121,7 @@ ThisBuild / Test / jsEnv := { } val catsEffectVersion = "3.3.13" -val fs2Version = "3.2.8" +val fs2Version = "3.2.9" val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project val scalaJSDomVersion = "2.2.0" val circeVersion = "0.14.2"