From a127fc270a43fc895b2c1e14b7843e87900d892d Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 20 Mar 2022 05:14:10 +0000 Subject: [PATCH 01/52] Use new URLs for http4s api docs --- docs/fetch.md | 2 +- docs/websocket.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/fetch.md b/docs/fetch.md index dce39f75..803f10f5 100644 --- a/docs/fetch.md +++ b/docs/fetch.md @@ -1,6 +1,6 @@ # Fetch Client -The [`FetchClientBuilder`](https://www.javadoc.io/doc/org.http4s/http4s-dom_sjs1_2.13/latest/org/http4s/dom/FetchClientBuilder.html) creates a standard http4s [`Client`](https://http4s.org/v0.23/api/org/http4s/client/client) that is described in the [http4s documentation](https://http4s.org/v0.23/client/). +The [`FetchClientBuilder`](https://www.javadoc.io/doc/org.http4s/http4s-dom_sjs1_2.13/latest/org/http4s/dom/FetchClientBuilder.html) creates a standard http4s [`Client`](https://www.javadoc.io/doc/org.http4s/http4s-docs_2.13/@HTTP4S_VERSION@/org/http4s/client/client) that is described in the [http4s documentation](https://http4s.org/v0.23/client/). ## Example diff --git a/docs/websocket.md b/docs/websocket.md index 658a0c70..42e4b7f2 100644 --- a/docs/websocket.md +++ b/docs/websocket.md @@ -1,6 +1,6 @@ # WebSocket Client -The [`WebSocketClient`](https://www.javadoc.io/doc/org.http4s/http4s-dom_sjs1_2.13/latest/org/http4s/dom/WSClient$.html) creates a standard http4s [`WSClientHighLevel`](https://http4s.org/v0.23/api/org/http4s/client/client). +The [`WebSocketClient`](https://www.javadoc.io/doc/org.http4s/http4s-dom_sjs1_2.13/latest/org/http4s/dom/WSClient$.html) creates a standard http4s [`WSClientHighLevel`](https://www.javadoc.io/doc/org.http4s/http4s-docs_2.13/@HTTP4S_VERSION@/org/http4s/client/client). ## Example From 01816bee63d1ddf90dc4b55d0b47cbb7872a61f0 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 20 Mar 2022 05:14:45 +0000 Subject: [PATCH 02/52] scala-js-dom 1.x begone! --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 9d4596e8..e38fcf46 100644 --- a/docs/index.md +++ b/docs/index.md @@ -15,7 +15,7 @@ Notably, http4s-dom can also be used to create _serverless_ apps with [Cloudflar [![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 -// Supports http4s 0.23.x and scala-js-dom 2.x +// Supports http4s 0.23.x libraryDependencies += "org.http4s" %%% "http4s-dom" % "@VERSION@" // recommended, brings in the latest client module From 3fe538377567190bc07b62980a3dfc84ad4bada5 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 20 Mar 2022 05:41:34 +0000 Subject: [PATCH 03/52] Try out Laika's API directive --- build.sbt | 17 ++++++++++++++++- docs/fetch.md | 2 +- docs/index.md | 1 - docs/serviceworker.md | 2 +- docs/websocket.md | 2 +- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 7d966e48..8e6e3a5e 100644 --- a/build.sbt +++ b/build.sbt @@ -171,7 +171,22 @@ lazy val docs = project "HTTP4S_VERSION" -> http4sVersion, "CIRCE_VERSION" -> circeVersion ), - laikaConfig ~= { _.withRawContent }, + laikaConfig := { + import laika.rewrite.link._ + laikaConfig + .value + .withRawContent + .withConfigValue(LinkConfig(apiLinks = List( + ApiLinks( + baseUri = + s"https://www.javadoc.io/doc/org.http4s/http4s-dom_sjs1_2.13/${mdocVariables.value("VERSION")}/", + packagePrefix = "org.http4s.dom"), + ApiLinks( + baseUri = s"https://www.javadoc.io/doc/org.http4s/http4s-docs_2.13/$http4sVersion/", + packagePrefix = "org.http4s" + ) + ))) + }, tlSiteHeliumConfig ~= { // Actually, this *disables* auto-linking, to avoid duplicates with mdoc _.site.autoLinkJS() diff --git a/docs/fetch.md b/docs/fetch.md index 803f10f5..967f3866 100644 --- a/docs/fetch.md +++ b/docs/fetch.md @@ -1,6 +1,6 @@ # Fetch Client -The [`FetchClientBuilder`](https://www.javadoc.io/doc/org.http4s/http4s-dom_sjs1_2.13/latest/org/http4s/dom/FetchClientBuilder.html) creates a standard http4s [`Client`](https://www.javadoc.io/doc/org.http4s/http4s-docs_2.13/@HTTP4S_VERSION@/org/http4s/client/client) that is described in the [http4s documentation](https://http4s.org/v0.23/client/). +The @:api(org.http4s.dom.FetchClientBuilder) creates a standard http4s @:api(org.http4s.client.Client) that is described in the [http4s documentation](https://http4s.org/v0.23/docs/client.html). ## Example diff --git a/docs/index.md b/docs/index.md index e38fcf46..f3afc6c3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -15,7 +15,6 @@ Notably, http4s-dom can also be used to create _serverless_ apps with [Cloudflar [![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 -// Supports http4s 0.23.x libraryDependencies += "org.http4s" %%% "http4s-dom" % "@VERSION@" // recommended, brings in the latest client module diff --git a/docs/serviceworker.md b/docs/serviceworker.md index 6e8224de..64f4324d 100644 --- a/docs/serviceworker.md +++ b/docs/serviceworker.md @@ -1,6 +1,6 @@ # Service Worker "Server" -The [`ServiceWorker`](https://www.javadoc.io/doc/org.http4s/http4s-dom_sjs1_2.13/latest/org/http4s/dom/ServiceWorker$.html) `FetchEvent` listener integrates directly with [http4s services](https://http4s.org/v0.23/service/). You can use it to run a "proxy server" as a background process in the browser that can intercept and respond to requests made by the `FetchClient`. +The @:api(org.http4s.dom.ServiceWorker$) `FetchEvent` listener integrates directly with [http4s services](https://http4s.org/v0.23/docs/service.html). You can use it to run a "proxy server" as a background process in the browser that can intercept and respond to requests made by the `FetchClient`. ## Example diff --git a/docs/websocket.md b/docs/websocket.md index 42e4b7f2..3c2faa7c 100644 --- a/docs/websocket.md +++ b/docs/websocket.md @@ -1,6 +1,6 @@ # WebSocket Client -The [`WebSocketClient`](https://www.javadoc.io/doc/org.http4s/http4s-dom_sjs1_2.13/latest/org/http4s/dom/WSClient$.html) creates a standard http4s [`WSClientHighLevel`](https://www.javadoc.io/doc/org.http4s/http4s-docs_2.13/@HTTP4S_VERSION@/org/http4s/client/client). +The @:api(org.http4s.dom.WebSocketClient$) implements the http4s @:api(org.http4s.client.websocket.WSClientHighLevel) interface. ## Example From 6c5af314eb936b7d6c9c980f31e7b913a76f0edb Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 20 Mar 2022 05:44:24 +0000 Subject: [PATCH 04/52] Update more URLs --- CODE_OF_CONDUCT.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 43ccabb3..712cf47d 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -6,7 +6,7 @@ Everyone is expected to follow the [Scala Code of Conduct] when discussing the p ## Moderation -For any questions, concerns, or moderation requests, please contact a member of the [community staff](https://http4s.org/code-of-conduct/#moderation) +For any questions, concerns, or moderation requests, please contact a member of the [community staff](https://http4s.org/code-of-conduct.html#moderation) -[Scala Code of Conduct]: https://http4s.org/code-of-conduct/ -[Community staff]: https://http4s.org/code-of-conduct/#moderation +[Scala Code of Conduct]: https://http4s.org/code-of-conduct.html +[Community staff]: https://http4s.org/code-of-conduct.html#moderation From 6af97153f6d0dfbf3b610eee7f39f223491458bf Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 20 Mar 2022 05:44:56 +0000 Subject: [PATCH 05/52] Cleanup --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 281a2437..428ab218 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,5 @@ Notably, http4s-dom can also be used to create _serverless_ apps with [Cloudflar [![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 -// Supports http4s 0.23.x libraryDependencies += "org.http4s" %%% "http4s-dom" % "0.2.1" ``` From 59341f207947cfe7b1cbeecf78fc6a2344c7e3d8 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 25 Mar 2022 07:08:50 +0100 Subject: [PATCH 06/52] Update cats-effect to 3.3.9 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 8e6e3a5e..ab867d77 100644 --- a/build.sbt +++ b/build.sbt @@ -109,7 +109,7 @@ ThisBuild / Test / jsEnv := { } } -val catsEffectVersion = "3.3.8" +val catsEffectVersion = "3.3.9" val fs2Version = "3.2.5" val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project val scalaJSDomVersion = "2.1.0" From 1af49f18821a710df3b4f556ef001aa33cd7c310 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 27 Mar 2022 22:44:48 +0200 Subject: [PATCH 07/52] Update sbt-mdoc to 2.3.2 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 45425af0..4b1d745a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -8,6 +8,6 @@ libraryDependencies += "org.http4s" %% "http4s-dsl" % http4sVersion libraryDependencies += "org.http4s" %% "http4s-blaze-server" % http4sVersion addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.13.0") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.1") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") From 4f835bbf8ed6e70fa6ea71ac3d40e05c88ddeedd Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 28 Mar 2022 00:39:54 +0200 Subject: [PATCH 08/52] Update sbt-http4s-org to 0.13.1 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4b1d745a..a4260e8f 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" % http4sVersion -addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.13.0") +addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.13.1") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") From 38c2c8b43631afcb67d6814c7fed8cde606287e0 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Mon, 28 Mar 2022 00:53:57 +0000 Subject: [PATCH 09/52] Use sbt-tl-site settings to generate api doc url --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index ab867d77..ddac9c1b 100644 --- a/build.sbt +++ b/build.sbt @@ -28,8 +28,6 @@ ThisBuild / developers := List( tlGitHubDev("armanbilge", "Arman Bilge") ) ThisBuild / startYear := Some(2021) -ThisBuild / tlSiteApiUrl := Some(url( - "https://www.javadoc.io/doc/org.http4s/http4s-dom_sjs1_2.13/latest/org/http4s/dom/index.html")) ThisBuild / githubWorkflowTargetBranches := Seq("series/0.2") ThisBuild / tlCiReleaseBranches := Seq("series/0.2") @@ -164,6 +162,8 @@ lazy val jsdocs = lazy val docs = project .in(file("site")) .settings( + tlSiteApiModule := Some((dom / projectID).value), + tlSiteApiPackage := Some("org.http4s.dom"), tlFatalWarningsInCi := false, mdocJS := Some(jsdocs), mdocVariables ++= Map( From 537c712a2b046e56a1934df884612f5891d3eb11 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 30 Mar 2022 02:37:36 +0200 Subject: [PATCH 10/52] Update fs2-core to 3.2.6 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index ddac9c1b..05c36939 100644 --- a/build.sbt +++ b/build.sbt @@ -108,7 +108,7 @@ ThisBuild / Test / jsEnv := { } val catsEffectVersion = "3.3.9" -val fs2Version = "3.2.5" +val fs2Version = "3.2.6" val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project val scalaJSDomVersion = "2.1.0" val circeVersion = "0.15.0-M1" From 8958d16b16b5d43fbf32f50b0bc74462aa82c094 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 30 Mar 2022 16:45:12 +0200 Subject: [PATCH 11/52] Update fs2-core to 3.2.7 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 05c36939..e71b9c16 100644 --- a/build.sbt +++ b/build.sbt @@ -108,7 +108,7 @@ ThisBuild / Test / jsEnv := { } val catsEffectVersion = "3.3.9" -val fs2Version = "3.2.6" +val fs2Version = "3.2.7" val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project val scalaJSDomVersion = "2.1.0" val circeVersion = "0.15.0-M1" From a4ddf1d3d79741b72b8a911ee81f7a43c1e17015 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 2 Apr 2022 14:59:14 +0200 Subject: [PATCH 12/52] Update scalafmt-core to 3.5.0 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 2563ef7c..69583534 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.4.3 +version = 3.5.0 runner.dialect = Scala213Source3 From b50ea2dfeeab8ba90416a5b22f18b2a45be3733e Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 4 Apr 2022 01:30:42 +0200 Subject: [PATCH 13/52] Update cats-effect to 3.3.10 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index e71b9c16..bf632733 100644 --- a/build.sbt +++ b/build.sbt @@ -107,7 +107,7 @@ ThisBuild / Test / jsEnv := { } } -val catsEffectVersion = "3.3.9" +val catsEffectVersion = "3.3.10" val fs2Version = "3.2.7" val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project val scalaJSDomVersion = "2.1.0" From ea3e89ad539dd8ba6c5ebe34138040693ef18926 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 5 Apr 2022 04:42:14 +0200 Subject: [PATCH 14/52] Update sbt-scalajs, scalajs-compiler, ... to 1.10.0 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index a4260e8f..23a73b75 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -9,5 +9,5 @@ libraryDependencies += "org.http4s" %% "http4s-blaze-server" % http4sVersion addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.13.1") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") From 0e30ec2564a071ae795ebf858264d7ed9be35761 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 6 Apr 2022 01:02:56 +0200 Subject: [PATCH 15/52] Update cats-effect to 3.3.11 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index bf632733..da3dedff 100644 --- a/build.sbt +++ b/build.sbt @@ -107,7 +107,7 @@ ThisBuild / Test / jsEnv := { } } -val catsEffectVersion = "3.3.10" +val catsEffectVersion = "3.3.11" val fs2Version = "3.2.7" val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project val scalaJSDomVersion = "2.1.0" From 3b35717ab2d3cdfb92b32f290d05f8a6c98bae8f Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 7 Apr 2022 05:07:09 +0200 Subject: [PATCH 16/52] Update scalafmt-core to 3.5.1 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 69583534..c8217a51 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.5.0 +version = 3.5.1 runner.dialect = Scala213Source3 From a1beba79bb18af3acf37735292ccd3e2ec0d5485 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 12 Apr 2022 00:37:19 +0200 Subject: [PATCH 17/52] Update sbt-http4s-org to 0.13.2 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 23a73b75..cac72e97 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" % http4sVersion -addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.13.1") +addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.13.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 ecda2553153ef6b960116802a84b6cc56c38daaa Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 12 Apr 2022 19:05:53 +0200 Subject: [PATCH 18/52] Update scala3-library, ... to 3.1.2 --- .github/workflows/ci.yml | 4 ++-- build.sbt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da30bd8f..289a3a4a 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.1, 2.13.8] + scala: [2.12.15, 3.1.2, 2.13.8] java: [temurin@8] browser: [Chrome, Firefox] exclude: - scala: 2.12.15 browser: Firefox - - scala: 3.1.1 + - scala: 3.1.2 browser: Firefox runs-on: ${{ matrix.os }} steps: diff --git a/build.sbt b/build.sbt index da3dedff..4cddbfbc 100644 --- a/build.sbt +++ b/build.sbt @@ -33,7 +33,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.1", "2.13.8") +ThisBuild / crossScalaVersions := Seq("2.12.15", "3.1.2", "2.13.8") ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8")) ThisBuild / githubWorkflowBuildMatrixAdditions += "browser" -> List("Chrome", "Firefox") ThisBuild / githubWorkflowBuildSbtStepPreamble += s"set Global / useJSEnv := JSEnv.$${{ matrix.browser }}" From 4e344618ef4ec5cdc18eda8ea6a2881353445283 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 12 Apr 2022 19:06:32 +0200 Subject: [PATCH 19/52] 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 289a3a4a..2502f178 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -163,12 +163,12 @@ jobs: tar xf targets.tar rm targets.tar - - name: Download target directories (3.1.1, Chrome) + - name: Download target directories (3.1.2, Chrome) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.1-Chrome + name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.2-Chrome - - name: Inflate target directories (3.1.1, Chrome) + - name: Inflate target directories (3.1.2, Chrome) run: | tar xf targets.tar rm targets.tar From f8e89a097d0e79f9b9b3a27972651bd9848473bc Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 21 Apr 2022 10:44:08 +0200 Subject: [PATCH 20/52] Update scalafmt-core to 3.5.2 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index c8217a51..7e57088d 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.5.1 +version = 3.5.2 runner.dialect = Scala213Source3 From 51079162a96b357819d9f2d250069785aee35448 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 10 May 2022 23:30:46 +0000 Subject: [PATCH 21/52] Add calico to related projects --- build.sbt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.sbt b/build.sbt index 4cddbfbc..e6fafdb0 100644 --- a/build.sbt +++ b/build.sbt @@ -166,6 +166,9 @@ lazy val docs = project tlSiteApiPackage := Some("org.http4s.dom"), tlFatalWarningsInCi := false, mdocJS := Some(jsdocs), + tlSiteRelatedProjects ++= Seq( + "calico" -> url("https://armanbilge.github.io/calico/") + ), mdocVariables ++= Map( "js-opt" -> "fast", "HTTP4S_VERSION" -> http4sVersion, From ea2967b14ca375bd2294aaf0e28a30e4ef61481b Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 11 May 2022 22:44:45 +0000 Subject: [PATCH 22/52] Use fullname for HTMLElement and friends --- docs/fetch.md | 2 +- docs/websocket.md | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/fetch.md b/docs/fetch.md index 967f3866..cb7e86c8 100644 --- a/docs/fetch.md +++ b/docs/fetch.md @@ -32,7 +32,7 @@ val fetchActivity: IO[Unit] = for { _ <- IO(activityElement.innerHTML = activity.activity) } yield () -val button = document.getElementById("button").asInstanceOf[html.Button] +val button = document.getElementById("button").asInstanceOf[HTMLButtonElement] button.onclick = _ => fetchActivity.unsafeRunAndForget() ``` diff --git a/docs/websocket.md b/docs/websocket.md index 3c2faa7c..f38ce38a 100644 --- a/docs/websocket.md +++ b/docs/websocket.md @@ -28,15 +28,15 @@ import org.http4s.dom._ import org.http4s.syntax.all._ import org.scalajs.dom._ -val message = document.getElementById("message").asInstanceOf[html.Input] -val button = document.getElementById("button").asInstanceOf[html.Button] -val sent = document.getElementById("sent").asInstanceOf[html.Element] -val received = document.getElementById("received").asInstanceOf[html.Element] +val message = document.getElementById("message").asInstanceOf[HTMLInputElement] +val button = document.getElementById("button").asInstanceOf[HTMLButtonElement] +val sent = document.getElementById("sent").asInstanceOf[HTMLElement] +val received = document.getElementById("received").asInstanceOf[HTMLElement] val request = WSRequest(uri"wss://ws.postman-echo.com/raw") val app = WebSocketClient[IO].connectHighLevel(request).use { conn => - def log(e: html.Element, text: String): IO[Unit] = + def log(e: HTMLElement, text: String): IO[Unit] = IO { val p = document.createElement("p") p.innerHTML = text From e8e596e94c8eafe782d0565217b19ea53792a506 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 13 May 2022 12:27:22 +0200 Subject: [PATCH 23/52] Update scalajs-dom to 2.2.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index e6fafdb0..1ae418c2 100644 --- a/build.sbt +++ b/build.sbt @@ -110,7 +110,7 @@ ThisBuild / Test / jsEnv := { val catsEffectVersion = "3.3.11" val fs2Version = "3.2.7" val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project -val scalaJSDomVersion = "2.1.0" +val scalaJSDomVersion = "2.2.0" val circeVersion = "0.15.0-M1" val munitVersion = "0.7.29" val munitCEVersion = "1.0.7" From 6f6e44eb86d4e4fa9ef06ed2a1a5e3d1d4677b8f Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 14 May 2022 21:25:42 -0700 Subject: [PATCH 24/52] Fix broken URLs --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index f3afc6c3..0d70585e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,8 +4,8 @@ Use http4s in your browser with Scala.js! 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 ca2a9168b6a674dc8126facac2fe1d231542fe71 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Thu, 19 May 2022 01:01:16 +0000 Subject: [PATCH 25/52] Use named WebSocket constants --- dom/src/main/scala/org/http4s/dom/WebSocketClient.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dom/src/main/scala/org/http4s/dom/WebSocketClient.scala b/dom/src/main/scala/org/http4s/dom/WebSocketClient.scala index b6e18ede..41ce3dfb 100644 --- a/dom/src/main/scala/org/http4s/dom/WebSocketClient.scala +++ b/dom/src/main/scala/org/http4s/dom/WebSocketClient.scala @@ -108,9 +108,9 @@ object WebSocketClient { .flatMap(close.complete(_)) *> messages.offer(None) F.delay(ws.readyState).flatMap { - case 0 | 1 => shutdown // CONNECTING | OPEN - case 2 => close.get.void // CLOSING - case 3 => F.unit // CLOSED + case WebSocket.CONNECTING | WebSocket.OPEN => shutdown + case WebSocket.CLOSING => close.get.void + case WebSocket.CLOSED => F.unit case s => F.raiseError(new IllegalStateException(s"WebSocket.readyState: $s")) } } From 39e1ad19a02f2292b968ff825abaeb08582703ab Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 21 May 2022 10:02:35 +0200 Subject: [PATCH 26/52] Update cats-effect to 3.3.12 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 1ae418c2..b07ba4ae 100644 --- a/build.sbt +++ b/build.sbt @@ -107,7 +107,7 @@ ThisBuild / Test / jsEnv := { } } -val catsEffectVersion = "3.3.11" +val catsEffectVersion = "3.3.12" val fs2Version = "3.2.7" val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project val scalaJSDomVersion = "2.2.0" From ef1d03e4c194e977e5844a2f2978ce38d77791a4 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 21 May 2022 23:43:02 +0000 Subject: [PATCH 27/52] Use scalaJSLinkerOutputDirectory to get worker dir --- build.sbt | 12 +++++++++++- .../org/http4s/dom/FetchServiceWorkerSuite.scala | 7 +------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/build.sbt b/build.sbt index b07ba4ae..6ea82931 100644 --- a/build.sbt +++ b/build.sbt @@ -137,7 +137,17 @@ lazy val tests = project .settings( scalaJSUseMainModuleInitializer := true, (Test / test) := (Test / test).dependsOn(Compile / fastOptJS).value, - buildInfoKeys := Seq[BuildInfoKey](scalaVersion, fileServicePort), + buildInfoKeys := Seq[BuildInfoKey]( + fileServicePort, + BuildInfoKey("runtime" -> useJSEnv.value.toString), + BuildInfoKey( + "workerDir" -> (Compile / fastLinkJS / scalaJSLinkerOutputDirectory) + .value + .relativeTo((ThisBuild / baseDirectory).value) + .get + .toString + ) + ), buildInfoPackage := "org.http4s.dom", libraryDependencies ++= Seq( "org.scalameta" %%% "munit" % munitVersion % Test, diff --git a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala index d9f0c737..55ab788d 100644 --- a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala +++ b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala @@ -34,11 +34,6 @@ import scala.scalajs.js class FetchServiceWorkerSuite extends CatsEffectSuite { - def scalaVersion = if (BuildInfo.scalaVersion.startsWith("2")) - BuildInfo.scalaVersion.split("\\.").init.mkString(".") - else - BuildInfo.scalaVersion - val client = FetchClientBuilder[IO].create val baseUrl = uri"/" @@ -50,7 +45,7 @@ class FetchServiceWorkerSuite extends CatsEffectSuite { .navigator .serviceWorker .register( - s"/tests/target/scala-${scalaVersion}/tests-fastopt/main.js", + s"/${BuildInfo.workerDir}/main.js", js.Dynamic.literal(scope = "/") ) } From a5be5c6f2174885c28055bfc88d4fa2a6237786b Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 22 May 2022 00:04:43 +0000 Subject: [PATCH 28/52] Bump http4s, nowarn deprecation for now --- build.sbt | 6 +++++- .../test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 6ea82931..6340e2e2 100644 --- a/build.sbt +++ b/build.sbt @@ -109,12 +109,16 @@ ThisBuild / Test / jsEnv := { val catsEffectVersion = "3.3.12" val fs2Version = "3.2.7" -val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project +val http4sVersion = "0.23.11-506-d570136-SNAPSHOT" +// val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project val scalaJSDomVersion = "2.2.0" val circeVersion = "0.15.0-M1" val munitVersion = "0.7.29" val munitCEVersion = "1.0.7" +ThisBuild / resolvers += + "s01 snapshots".at("https://s01.oss.sonatype.org/content/repositories/snapshots/") + lazy val root = project.in(file(".")).aggregate(dom, tests).enablePlugins(NoPublishPlugin) diff --git a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala index 55ab788d..1b712d61 100644 --- a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala +++ b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala @@ -93,7 +93,7 @@ class FetchServiceWorkerSuite extends CatsEffectSuite { .expect[String](POST(multipart, baseUrl / "echo").withHeaders(multipart.headers)) .map(_.contains("This is text.")) .assert - } + }: @scala.annotation.nowarn GetRoutes.getPaths[IO].toList.foreach { case (path, expected) => From b7652af065f30cdf533a735b33c3a0072ab9bcfa Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 22 May 2022 00:09:29 +0000 Subject: [PATCH 29/52] Fix compile on 2.12 --- .../src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala index 1b712d61..4bc6b1a6 100644 --- a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala +++ b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala @@ -88,7 +88,7 @@ class FetchServiceWorkerSuite extends CatsEffectSuite { } test("POST a multipart body") { - val multipart = Multipart[IO](Vector(Part.formData("text", "This is text."))) + val multipart = Multipart[IO](Vector(Part.formData[IO]("text", "This is text."))) client .expect[String](POST(multipart, baseUrl / "echo").withHeaders(multipart.headers)) .map(_.contains("This is text.")) From 33e436e739ce30d5c74fd9ebead6e449a34cba01 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 22 May 2022 00:21:55 +0000 Subject: [PATCH 30/52] Switch worker to testkit routes --- build.sbt | 1 + .../src/main/scala/org/http4s/dom/TestRoutes.scala | 13 ++++++------- .../scala/org/http4s/dom/TestServiceWorker.scala | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 6340e2e2..e0c7596e 100644 --- a/build.sbt +++ b/build.sbt @@ -154,6 +154,7 @@ lazy val tests = project ), buildInfoPackage := "org.http4s.dom", libraryDependencies ++= Seq( + "org.http4s" %%% "http4s-client-testkit" % http4sVersion, "org.scalameta" %%% "munit" % munitVersion % Test, "org.typelevel" %%% "munit-cats-effect-3" % munitCEVersion % Test ) diff --git a/tests/src/main/scala/org/http4s/dom/TestRoutes.scala b/tests/src/main/scala/org/http4s/dom/TestRoutes.scala index 942b522e..7d18d697 100644 --- a/tests/src/main/scala/org/http4s/dom/TestRoutes.scala +++ b/tests/src/main/scala/org/http4s/dom/TestRoutes.scala @@ -21,21 +21,20 @@ import cats.effect._ import cats.syntax.all._ import fs2._ import org.http4s.Status._ - +import org.http4s.client.testkit.testroutes import scala.concurrent.duration._ object TestRoutes { - def apply[F[_]](implicit F: Async[F]): HttpRoutes[F] = HttpRoutes.of { + def routes: HttpRoutes[IO] = HttpRoutes.of { case request => val get = Some(request).filter(_.method == Method.GET).flatMap { r => - GetRoutes.getPaths.get(r.uri.path.segments.last.toString) + testroutes.GetRoutes.getPaths.get(r.uri.path.segments.last.toString) } - val post = Some(request).filter(_.method == Method.POST).map { r => - F.delay(Response(body = r.body)) - } + val post = + Some(request).filter(_.method == Method.POST).map(r => IO(Response(body = r.body))) - get.orElse(post).getOrElse(F.delay(Response[F](NotFound))) + get.orElse(post).getOrElse(IO(Response[IO](NotFound))) } } diff --git a/tests/src/main/scala/org/http4s/dom/TestServiceWorker.scala b/tests/src/main/scala/org/http4s/dom/TestServiceWorker.scala index 33f4d41b..7fed35e1 100644 --- a/tests/src/main/scala/org/http4s/dom/TestServiceWorker.scala +++ b/tests/src/main/scala/org/http4s/dom/TestServiceWorker.scala @@ -35,7 +35,7 @@ object TestServiceWorker { ) ) - ServiceWorker.addFetchEventListener(IO.pure(TestRoutes[IO])).void.unsafeRunSync() + ServiceWorker.addFetchEventListener(IO.pure(TestRoutes.routes)).void.unsafeRunSync() } } From 071c85a04babf543370f10116f685f6293a7185f Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 22 May 2022 00:28:54 +0000 Subject: [PATCH 31/52] Fix test router --- tests/src/main/scala/org/http4s/dom/TestRoutes.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/main/scala/org/http4s/dom/TestRoutes.scala b/tests/src/main/scala/org/http4s/dom/TestRoutes.scala index 7d18d697..2d628058 100644 --- a/tests/src/main/scala/org/http4s/dom/TestRoutes.scala +++ b/tests/src/main/scala/org/http4s/dom/TestRoutes.scala @@ -28,7 +28,7 @@ object TestRoutes { def routes: HttpRoutes[IO] = HttpRoutes.of { case request => val get = Some(request).filter(_.method == Method.GET).flatMap { r => - testroutes.GetRoutes.getPaths.get(r.uri.path.segments.last.toString) + testroutes.GetRoutes.getPaths.get(s"/${r.uri.path.segments.last}") } val post = From 2daeaefcc22fbbf5001c43460c156f45b1eb197a Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 22 May 2022 01:08:05 +0000 Subject: [PATCH 32/52] Try to materialize selenium in worker dir --- build.sbt | 30 ++++++++++++------- .../http4s/dom/FetchServiceWorkerSuite.scala | 5 +--- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/build.sbt b/build.sbt index e0c7596e..6cd89387 100644 --- a/build.sbt +++ b/build.sbt @@ -67,15 +67,19 @@ Global / fileServicePort := { case Method.GET -> Root / "ws" => wsb.build(identity) case req => - fileService[IO](FileService.Config(".")).orNotFound.run(req).map { res => - // TODO find out why mime type is not auto-inferred - if (req.uri.renderString.endsWith(".js")) - res.withHeaders( - "Service-Worker-Allowed" -> "/", - "Content-Type" -> "text/javascript" - ) - else res - } + fileService[IO](FileService.Config( + (tests / Compile / fastLinkJS / scalaJSLinkerOutputDirectory).value.toString)) + .orNotFound + .run(req) + .map { res => + // TODO find out why mime type is not auto-inferred + if (req.uri.renderString.endsWith(".js")) + res.withHeaders( + "Service-Worker-Allowed" -> "/", + "Content-Type" -> "text/javascript" + ) + else res + } } .orNotFound } @@ -92,8 +96,8 @@ ThisBuild / Test / jsEnv := { val config = SeleniumJSEnv .Config() .withMaterializeInServer( - "target/selenium", - s"http://localhost:${fileServicePort.value}/target/selenium/") + (tests / Compile / fastLinkJS / scalaJSLinkerOutputDirectory).value.toString, + s"http://localhost:${fileServicePort.value}/") useJSEnv.value match { case Chrome => @@ -140,6 +144,10 @@ lazy val tests = project .in(file("tests")) .settings( scalaJSUseMainModuleInitializer := true, + Compile / scalaJSLinkerConfig ~= { cfg => + import org.scalajs.linker.interface.OutputPatterns + cfg.withOutputPatterns(OutputPatterns.fromJSFile("worker-%s.js")) + }, (Test / test) := (Test / test).dependsOn(Compile / fastOptJS).value, buildInfoKeys := Seq[BuildInfoKey]( fileServicePort, diff --git a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala index 4bc6b1a6..3b82574b 100644 --- a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala +++ b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala @@ -44,10 +44,7 @@ class FetchServiceWorkerSuite extends CatsEffectSuite { window .navigator .serviceWorker - .register( - s"/${BuildInfo.workerDir}/main.js", - js.Dynamic.literal(scope = "/") - ) + .register("worker-main.js", js.Dynamic.literal(scope = "/")) } }.both(IO.async_[Unit] { cb => window From 7457dfe9c751af7ba5441e4ebeed4f93b75ff1d3 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 22 May 2022 01:16:53 +0000 Subject: [PATCH 33/52] Revert "Fix test router" This reverts commit 071c85a04babf543370f10116f685f6293a7185f. --- tests/src/main/scala/org/http4s/dom/TestRoutes.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/main/scala/org/http4s/dom/TestRoutes.scala b/tests/src/main/scala/org/http4s/dom/TestRoutes.scala index 2d628058..7d18d697 100644 --- a/tests/src/main/scala/org/http4s/dom/TestRoutes.scala +++ b/tests/src/main/scala/org/http4s/dom/TestRoutes.scala @@ -28,7 +28,7 @@ object TestRoutes { def routes: HttpRoutes[IO] = HttpRoutes.of { case request => val get = Some(request).filter(_.method == Method.GET).flatMap { r => - testroutes.GetRoutes.getPaths.get(s"/${r.uri.path.segments.last}") + testroutes.GetRoutes.getPaths.get(r.uri.path.segments.last.toString) } val post = From 100abf95c3b5e6ed9011784753f1e12da1288661 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Mon, 23 May 2022 09:07:20 -0700 Subject: [PATCH 34/52] Revert "Revert "Fix test router"" This reverts commit 7457dfe9c751af7ba5441e4ebeed4f93b75ff1d3. --- tests/src/main/scala/org/http4s/dom/TestRoutes.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/main/scala/org/http4s/dom/TestRoutes.scala b/tests/src/main/scala/org/http4s/dom/TestRoutes.scala index 7d18d697..2d628058 100644 --- a/tests/src/main/scala/org/http4s/dom/TestRoutes.scala +++ b/tests/src/main/scala/org/http4s/dom/TestRoutes.scala @@ -28,7 +28,7 @@ object TestRoutes { def routes: HttpRoutes[IO] = HttpRoutes.of { case request => val get = Some(request).filter(_.method == Method.GET).flatMap { r => - testroutes.GetRoutes.getPaths.get(r.uri.path.segments.last.toString) + testroutes.GetRoutes.getPaths.get(s"/${r.uri.path.segments.last}") } val post = From fb0ed703d2e6d45ff619b591ea7ca8c5040ff935 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Mon, 23 May 2022 09:07:30 -0700 Subject: [PATCH 35/52] Revert "Try to materialize selenium in worker dir" This reverts commit 2daeaefcc22fbbf5001c43460c156f45b1eb197a. --- build.sbt | 30 +++++++------------ .../http4s/dom/FetchServiceWorkerSuite.scala | 5 +++- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/build.sbt b/build.sbt index 6cd89387..e0c7596e 100644 --- a/build.sbt +++ b/build.sbt @@ -67,19 +67,15 @@ Global / fileServicePort := { case Method.GET -> Root / "ws" => wsb.build(identity) case req => - fileService[IO](FileService.Config( - (tests / Compile / fastLinkJS / scalaJSLinkerOutputDirectory).value.toString)) - .orNotFound - .run(req) - .map { res => - // TODO find out why mime type is not auto-inferred - if (req.uri.renderString.endsWith(".js")) - res.withHeaders( - "Service-Worker-Allowed" -> "/", - "Content-Type" -> "text/javascript" - ) - else res - } + fileService[IO](FileService.Config(".")).orNotFound.run(req).map { res => + // TODO find out why mime type is not auto-inferred + if (req.uri.renderString.endsWith(".js")) + res.withHeaders( + "Service-Worker-Allowed" -> "/", + "Content-Type" -> "text/javascript" + ) + else res + } } .orNotFound } @@ -96,8 +92,8 @@ ThisBuild / Test / jsEnv := { val config = SeleniumJSEnv .Config() .withMaterializeInServer( - (tests / Compile / fastLinkJS / scalaJSLinkerOutputDirectory).value.toString, - s"http://localhost:${fileServicePort.value}/") + "target/selenium", + s"http://localhost:${fileServicePort.value}/target/selenium/") useJSEnv.value match { case Chrome => @@ -144,10 +140,6 @@ lazy val tests = project .in(file("tests")) .settings( scalaJSUseMainModuleInitializer := true, - Compile / scalaJSLinkerConfig ~= { cfg => - import org.scalajs.linker.interface.OutputPatterns - cfg.withOutputPatterns(OutputPatterns.fromJSFile("worker-%s.js")) - }, (Test / test) := (Test / test).dependsOn(Compile / fastOptJS).value, buildInfoKeys := Seq[BuildInfoKey]( fileServicePort, diff --git a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala index 3b82574b..4bc6b1a6 100644 --- a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala +++ b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala @@ -44,7 +44,10 @@ class FetchServiceWorkerSuite extends CatsEffectSuite { window .navigator .serviceWorker - .register("worker-main.js", js.Dynamic.literal(scope = "/")) + .register( + s"/${BuildInfo.workerDir}/main.js", + js.Dynamic.literal(scope = "/") + ) } }.both(IO.async_[Unit] { cb => window From 4f4358b56217f39fc9bb1d71b312eb4054d83fb3 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Mon, 23 May 2022 16:40:25 +0000 Subject: [PATCH 36/52] Fix Multiparts deprecation --- .../http4s/dom/FetchServiceWorkerSuite.scala | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala index 4bc6b1a6..a962b1fd 100644 --- a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala +++ b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala @@ -23,7 +23,7 @@ import fs2.Stream import munit.CatsEffectSuite import org.http4s.Method._ import org.http4s.client.dsl.io._ -import org.http4s.multipart.Multipart +import org.http4s.multipart.Multiparts import org.http4s.multipart.Part import org.http4s.syntax.all._ import org.scalajs.dom.Event @@ -88,12 +88,17 @@ class FetchServiceWorkerSuite extends CatsEffectSuite { } test("POST a multipart body") { - val multipart = Multipart[IO](Vector(Part.formData[IO]("text", "This is text."))) - client - .expect[String](POST(multipart, baseUrl / "echo").withHeaders(multipart.headers)) - .map(_.contains("This is text.")) - .assert - }: @scala.annotation.nowarn + Multiparts.forSync[IO].flatMap { multiparts => + multiparts + .multipart(Vector(Part.formData[IO]("text", "This is text."))) + .flatMap { multipart => + client + .expect[String](POST(multipart, baseUrl / "echo").withHeaders(multipart.headers)) + .map(_.contains("This is text.")) + .assert + } + } + } GetRoutes.getPaths[IO].toList.foreach { case (path, expected) => From 5e38eed8d48094467ed067510d14620ab6605231 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Mon, 23 May 2022 16:45:48 +0000 Subject: [PATCH 37/52] Switch to testkit GetRoutes --- .../scala/org/http4s/dom/TestRoutes.scala | 32 ++----------------- .../http4s/dom/FetchServiceWorkerSuite.scala | 7 ++-- 2 files changed, 6 insertions(+), 33 deletions(-) diff --git a/tests/src/main/scala/org/http4s/dom/TestRoutes.scala b/tests/src/main/scala/org/http4s/dom/TestRoutes.scala index 2d628058..4413b69a 100644 --- a/tests/src/main/scala/org/http4s/dom/TestRoutes.scala +++ b/tests/src/main/scala/org/http4s/dom/TestRoutes.scala @@ -18,17 +18,14 @@ package org.http4s package dom import cats.effect._ -import cats.syntax.all._ -import fs2._ import org.http4s.Status._ -import org.http4s.client.testkit.testroutes -import scala.concurrent.duration._ +import org.http4s.client.testkit.testroutes.GetRoutes object TestRoutes { def routes: HttpRoutes[IO] = HttpRoutes.of { case request => val get = Some(request).filter(_.method == Method.GET).flatMap { r => - testroutes.GetRoutes.getPaths.get(s"/${r.uri.path.segments.last}") + GetRoutes.getPaths.get(s"/${r.uri.path.segments.last}") } val post = @@ -37,28 +34,3 @@ object TestRoutes { get.orElse(post).getOrElse(IO(Response[IO](NotFound))) } } - -object GetRoutes { - val SimplePath = "simple" - val ChunkedPath = "chunked" - val DelayedPath = "delayed" - val NoContentPath = "no-content" - val NotFoundPath = "not-found" - val EmptyNotFoundPath = "empty-not-found" - val InternalServerErrorPath = "internal-server-error" - - def getPaths[F[_]](implicit F: Temporal[F]): Map[String, F[Response[F]]] = - Map( - SimplePath -> Response[F](Ok).withEntity("simple path").pure[F], - ChunkedPath -> Response[F](Ok) - .withEntity(Stream.emits("chunk".toSeq.map(_.toString)).covary[F]) - .pure[F], - DelayedPath -> - F.sleep(1.second) *> - Response[F](Ok).withEntity("delayed path").pure[F], - NoContentPath -> Response[F](NoContent).pure[F], - NotFoundPath -> Response[F](NotFound).withEntity("not found").pure[F], - EmptyNotFoundPath -> Response[F](NotFound).pure[F], - InternalServerErrorPath -> Response[F](InternalServerError).pure[F] - ) -} diff --git a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala index a962b1fd..b3b36a4e 100644 --- a/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala +++ b/tests/src/test/scala/org/http4s/dom/FetchServiceWorkerSuite.scala @@ -23,6 +23,7 @@ import fs2.Stream import munit.CatsEffectSuite import org.http4s.Method._ import org.http4s.client.dsl.io._ +import org.http4s.client.testkit.testroutes.GetRoutes import org.http4s.multipart.Multiparts import org.http4s.multipart.Part import org.http4s.syntax.all._ @@ -60,7 +61,7 @@ class FetchServiceWorkerSuite extends CatsEffectSuite { } test("Repeat a simple request") { - val path = GetRoutes.SimplePath + val path = GetRoutes.SimplePath.tail def fetchBody = client.toKleisli(_.as[String]).local { (uri: Uri) => Request(uri = uri) } @@ -100,11 +101,11 @@ class FetchServiceWorkerSuite extends CatsEffectSuite { } } - GetRoutes.getPaths[IO].toList.foreach { + GetRoutes.getPaths.toList.foreach { case (path, expected) => test(s"Execute GET $path") { client - .run(GET(baseUrl / path)) + .run(GET(baseUrl / path.tail)) .use(resp => expected.flatMap(checkResponse(resp, _))) .assert } From 4b452525c8d25a6249535840de7fa31af8d6e751 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Mon, 23 May 2022 17:42:27 +0000 Subject: [PATCH 38/52] Setup Node.js 18 tests --- .github/workflows/ci.yml | 34 ++++++++----- build.sbt | 50 ++++++++++++++++--- project/JSEnv.scala | 1 + .../org/http4s/dom/NodeJSFetchSuite.scala | 25 ++++++++++ 4 files changed, 91 insertions(+), 19 deletions(-) create mode 100644 tests-nodejs/src/test/scala/org/http4s/dom/NodeJSFetchSuite.scala diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2502f178..8b2d85be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,12 +31,16 @@ jobs: os: [ubuntu-latest] scala: [2.12.15, 3.1.2, 2.13.8] java: [temurin@8] - browser: [Chrome, Firefox] + jsenv: [Chrome, Firefox, NodeJS] exclude: - scala: 2.12.15 - browser: Firefox + jsenv: Firefox + - scala: 2.12.15 + jsenv: NodeJS + - scala: 3.1.2 + jsenv: Firefox - scala: 3.1.2 - browser: Firefox + jsenv: NodeJS runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -72,41 +76,47 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + - name: Setup NodeJS v18 LTS + if: matrix.jsenv == 'NodeJS' + uses: actions/setup-node@v2 + with: + node-version: 18 + - name: Check that workflows are up to date - run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.browser }}'' ''project /'' githubWorkflowCheck' + run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' ''project /'' githubWorkflowCheck' - name: Check headers and formatting if: matrix.java == 'temurin@8' - run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.browser }}'' headerCheckAll scalafmtCheckAll ''project /'' scalafmtSbtCheck' + run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' headerCheckAll scalafmtCheckAll ''project /'' scalafmtSbtCheck' - name: Test - run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.browser }}'' test' + run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' test' - name: Check binary compatibility if: matrix.java == 'temurin@8' - run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.browser }}'' mimaReportBinaryIssues' + run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' mimaReportBinaryIssues' - name: Generate API documentation if: matrix.java == 'temurin@8' - run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.browser }}'' doc' + run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' doc' - name: Check unused compile dependencies if: matrix.java == 'temurin@8' - run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.browser }}'' unusedCompileDependenciesTest' + run: 'sbt ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' unusedCompileDependenciesTest' - name: Make target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/series/0.2') - run: mkdir -p target site/target tests/target dom/target jsdocs/target project/target + run: mkdir -p target site/target tests/target dom/target tests-nodejs/target jsdocs/target project/target - name: Compress target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/series/0.2') - run: tar cf targets.tar target site/target tests/target dom/target jsdocs/target project/target + run: tar cf targets.tar target site/target tests/target dom/target tests-nodejs/target jsdocs/target project/target - name: Upload target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/series/0.2') uses: actions/upload-artifact@v2 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.browser }} + name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.jsenv }} path: targets.tar publish: diff --git a/build.sbt b/build.sbt index 6ea82931..9359adf2 100644 --- a/build.sbt +++ b/build.sbt @@ -17,6 +17,7 @@ import org.openqa.selenium.WebDriver import org.openqa.selenium.chrome.ChromeOptions import org.openqa.selenium.firefox.FirefoxOptions +import org.scalajs.jsenv.nodejs.NodeJSEnv import org.scalajs.jsenv.selenium.SeleniumJSEnv import JSEnv._ @@ -35,15 +36,26 @@ ThisBuild / tlSitePublishBranch := Some("series/0.2") ThisBuild / crossScalaVersions := Seq("2.12.15", "3.1.2", "2.13.8") ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8")) -ThisBuild / githubWorkflowBuildMatrixAdditions += "browser" -> List("Chrome", "Firefox") -ThisBuild / githubWorkflowBuildSbtStepPreamble += s"set Global / useJSEnv := JSEnv.$${{ matrix.browser }}" + +val jsEnvs = List("Chrome", "Firefox", "NodeJS") +ThisBuild / githubWorkflowBuildMatrixAdditions += "jsenv" -> jsEnvs +ThisBuild / githubWorkflowBuildSbtStepPreamble += s"set Global / useJSEnv := JSEnv.$${{ matrix.jsenv }}" ThisBuild / githubWorkflowBuildMatrixExclusions ++= { for { scala <- (ThisBuild / crossScalaVersions).value.init - } yield MatrixExclude(Map("scala" -> scala, "browser" -> "Firefox")) + jsenv <- jsEnvs.tail + } yield MatrixExclude(Map("scala" -> scala, "jsenv" -> jsenv)) } -lazy val useJSEnv = settingKey[JSEnv]("Browser for running Scala.js tests") +ThisBuild / githubWorkflowBuildPreamble += + WorkflowStep.Use( + UseRef.Public("actions", "setup-node", "v2"), + name = Some("Setup NodeJS v18 LTS"), + params = Map("node-version" -> "18"), + cond = Some("matrix.jsenv == 'NodeJS'") + ) + +lazy val useJSEnv = settingKey[JSEnv]("JSEnv for running Scala.js tests") Global / useJSEnv := Chrome lazy val fileServicePort = settingKey[Int]("Port for static file server") @@ -96,6 +108,7 @@ ThisBuild / Test / jsEnv := { s"http://localhost:${fileServicePort.value}/target/selenium/") useJSEnv.value match { + case NodeJS => new NodeJSEnv() case Chrome => val options = new ChromeOptions() options.setHeadless(true) @@ -116,7 +129,7 @@ val munitVersion = "0.7.29" val munitCEVersion = "1.0.7" lazy val root = - project.in(file(".")).aggregate(dom, tests).enablePlugins(NoPublishPlugin) + project.in(file(".")).aggregate(dom, tests, nodeJSTests).enablePlugins(NoPublishPlugin) lazy val dom = project .in(file("dom")) @@ -136,10 +149,14 @@ lazy val tests = project .in(file("tests")) .settings( scalaJSUseMainModuleInitializer := true, - (Test / test) := (Test / test).dependsOn(Compile / fastOptJS).value, + Test / test := { + if (useJSEnv.value != JSEnv.NodeJS) + (Test / test).dependsOn(Compile / fastOptJS).value + else + () + }, buildInfoKeys := Seq[BuildInfoKey]( fileServicePort, - BuildInfoKey("runtime" -> useJSEnv.value.toString), BuildInfoKey( "workerDir" -> (Compile / fastLinkJS / scalaJSLinkerOutputDirectory) .value @@ -157,6 +174,25 @@ lazy val tests = project .dependsOn(dom) .enablePlugins(ScalaJSPlugin, BuildInfoPlugin, NoPublishPlugin) +lazy val nodeJSTests = project + .in(file("tests-nodejs")) + .settings( + Test / test := { + if (useJSEnv.value == JSEnv.NodeJS) + (Test / test).value + else + () + }, + libraryDependencies ++= Seq( + "org.http4s" %%% "http4s-client-testkit" % http4sVersion, + "org.scalameta" %%% "munit" % munitVersion % Test, + "org.typelevel" %%% "munit-cats-effect-3" % munitCEVersion % Test + ), + scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)) + ) + .dependsOn(dom) + .enablePlugins(ScalaJSPlugin, NoPublishPlugin) + lazy val jsdocs = project .dependsOn(dom) diff --git a/project/JSEnv.scala b/project/JSEnv.scala index d3b82871..d16337cd 100644 --- a/project/JSEnv.scala +++ b/project/JSEnv.scala @@ -16,6 +16,7 @@ sealed abstract class JSEnv object JSEnv { + case object NodeJS extends JSEnv case object Chrome extends JSEnv case object Firefox extends JSEnv } diff --git a/tests-nodejs/src/test/scala/org/http4s/dom/NodeJSFetchSuite.scala b/tests-nodejs/src/test/scala/org/http4s/dom/NodeJSFetchSuite.scala new file mode 100644 index 00000000..52007a93 --- /dev/null +++ b/tests-nodejs/src/test/scala/org/http4s/dom/NodeJSFetchSuite.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2021 http4s.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.http4s +package dom + +import cats.effect.IO +import org.http4s.client.testkit.ClientRouteTestBattery + +class NodeJSFetchSuite extends ClientRouteTestBattery("FetchClient") { + def clientResource = FetchClientBuilder[IO].resource +} From 97681016197c731023616a45574bb39d708e30ed Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Mon, 23 May 2022 17:48:17 +0000 Subject: [PATCH 39/52] Simplifying --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 9359adf2..caaee33f 100644 --- a/build.sbt +++ b/build.sbt @@ -150,7 +150,7 @@ lazy val tests = project .settings( scalaJSUseMainModuleInitializer := true, Test / test := { - if (useJSEnv.value != JSEnv.NodeJS) + if (useJSEnv.value != NodeJS) (Test / test).dependsOn(Compile / fastOptJS).value else () @@ -178,7 +178,7 @@ lazy val nodeJSTests = project .in(file("tests-nodejs")) .settings( Test / test := { - if (useJSEnv.value == JSEnv.NodeJS) + if (useJSEnv.value == NodeJS) (Test / test).value else () From 00b51cf45043e7e00304477046cb78d653abb074 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Mon, 23 May 2022 17:51:45 +0000 Subject: [PATCH 40/52] Use snapshot for testkit --- build.sbt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index caaee33f..71a667c7 100644 --- a/build.sbt +++ b/build.sbt @@ -174,6 +174,9 @@ lazy val tests = project .dependsOn(dom) .enablePlugins(ScalaJSPlugin, BuildInfoPlugin, NoPublishPlugin) +ThisBuild / resolvers += + "s01 snapshots".at("https://s01.oss.sonatype.org/content/repositories/snapshots/") + lazy val nodeJSTests = project .in(file("tests-nodejs")) .settings( @@ -184,7 +187,7 @@ lazy val nodeJSTests = project () }, libraryDependencies ++= Seq( - "org.http4s" %%% "http4s-client-testkit" % http4sVersion, + "org.http4s" %%% "http4s-client-testkit" % "0.23.11-506-d570136-SNAPSHOT", "org.scalameta" %%% "munit" % munitVersion % Test, "org.typelevel" %%% "munit-cats-effect-3" % munitCEVersion % Test ), From b970c75584e53302787628cb6dba7b4e50d01bc5 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Mon, 23 May 2022 17:55:33 +0000 Subject: [PATCH 41/52] Node 18 is not LTS --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 71a667c7..38a1bf12 100644 --- a/build.sbt +++ b/build.sbt @@ -50,7 +50,7 @@ ThisBuild / githubWorkflowBuildMatrixExclusions ++= { ThisBuild / githubWorkflowBuildPreamble += WorkflowStep.Use( UseRef.Public("actions", "setup-node", "v2"), - name = Some("Setup NodeJS v18 LTS"), + name = Some("Setup NodeJS v18"), params = Map("node-version" -> "18"), cond = Some("matrix.jsenv == 'NodeJS'") ) From 753a5b5b8ba56063a2d1c5e64d31fc163b7c6450 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Mon, 23 May 2022 18:15:15 +0000 Subject: [PATCH 42/52] Response body can be null on Node.js --- dom/src/main/scala/org/http4s/dom/FetchClient.scala | 4 +++- dom/src/main/scala/org/http4s/dom/package.scala | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dom/src/main/scala/org/http4s/dom/FetchClient.scala b/dom/src/main/scala/org/http4s/dom/FetchClient.scala index e2049fb6..b19c3303 100644 --- a/dom/src/main/scala/org/http4s/dom/FetchClient.scala +++ b/dom/src/main/scala/org/http4s/dom/FetchClient.scala @@ -33,6 +33,7 @@ import org.scalajs.dom.{Response => FetchResponse} import java.util.concurrent.TimeoutException import scala.concurrent.duration._ +import cats.data.OptionT private[dom] object FetchClient { @@ -86,7 +87,8 @@ private[dom] object FetchClient { } } { case (r, exitCase) => - closeReadableStream(r.body, exitCase) + // response.body can be null on Node.js e.g. for no-content responses + OptionT.fromOption(Option(r.body)).foreachF(closeReadableStream(_, exitCase)) } .evalMap(fromDomResponse[F]) diff --git a/dom/src/main/scala/org/http4s/dom/package.scala b/dom/src/main/scala/org/http4s/dom/package.scala index 0084d021..90ab3e8a 100644 --- a/dom/src/main/scala/org/http4s/dom/package.scala +++ b/dom/src/main/scala/org/http4s/dom/package.scala @@ -54,7 +54,8 @@ package object dom { Response[F]( status = status, headers = fromDomHeaders(response.headers), - body = fromReadableStream(response.body) + // response.body can be null on Node.js e.g. for no-content responses + body = Stream.fromOption(Option(response.body)).flatMap(fromReadableStream[F]) ) } From 789356cc6c6d9f360f49f4d6be849b44c94c9319 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Mon, 23 May 2022 18:17:42 +0000 Subject: [PATCH 43/52] Regenerate workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b2d85be..ffdb596e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,7 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - name: Setup NodeJS v18 LTS + - name: Setup NodeJS v18 if: matrix.jsenv == 'NodeJS' uses: actions/setup-node@v2 with: From f58d783c15b38256d5a50696f81d3448a845ac6f Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Mon, 23 May 2022 18:26:02 +0000 Subject: [PATCH 44/52] Remove comment about null bodies --- dom/src/main/scala/org/http4s/dom/FetchClient.scala | 1 - dom/src/main/scala/org/http4s/dom/package.scala | 1 - 2 files changed, 2 deletions(-) diff --git a/dom/src/main/scala/org/http4s/dom/FetchClient.scala b/dom/src/main/scala/org/http4s/dom/FetchClient.scala index b19c3303..16c8da2f 100644 --- a/dom/src/main/scala/org/http4s/dom/FetchClient.scala +++ b/dom/src/main/scala/org/http4s/dom/FetchClient.scala @@ -87,7 +87,6 @@ private[dom] object FetchClient { } } { case (r, exitCase) => - // response.body can be null on Node.js e.g. for no-content responses OptionT.fromOption(Option(r.body)).foreachF(closeReadableStream(_, exitCase)) } .evalMap(fromDomResponse[F]) diff --git a/dom/src/main/scala/org/http4s/dom/package.scala b/dom/src/main/scala/org/http4s/dom/package.scala index 90ab3e8a..832517f7 100644 --- a/dom/src/main/scala/org/http4s/dom/package.scala +++ b/dom/src/main/scala/org/http4s/dom/package.scala @@ -54,7 +54,6 @@ package object dom { Response[F]( status = status, headers = fromDomHeaders(response.headers), - // response.body can be null on Node.js e.g. for no-content responses body = Stream.fromOption(Option(response.body)).flatMap(fromReadableStream[F]) ) } From 482962cce7fa8346340e844c0cfa9071a9080fb9 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 24 May 2022 23:29:18 +0000 Subject: [PATCH 45/52] Bump to http4s 0.23.12, circe 0.14.2 --- build.sbt | 8 ++------ project/plugins.sbt | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index e0c7596e..0c03d974 100644 --- a/build.sbt +++ b/build.sbt @@ -109,16 +109,12 @@ ThisBuild / Test / jsEnv := { val catsEffectVersion = "3.3.12" val fs2Version = "3.2.7" -val http4sVersion = "0.23.11-506-d570136-SNAPSHOT" -// val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project +val http4sVersion = buildinfo.BuildInfo.http4sVersion // share version with build project val scalaJSDomVersion = "2.2.0" -val circeVersion = "0.15.0-M1" +val circeVersion = "0.14.2" val munitVersion = "0.7.29" val munitCEVersion = "1.0.7" -ThisBuild / resolvers += - "s01 snapshots".at("https://s01.oss.sonatype.org/content/repositories/snapshots/") - lazy val root = project.in(file(".")).aggregate(dom, tests).enablePlugins(NoPublishPlugin) diff --git a/project/plugins.sbt b/project/plugins.sbt index cac72e97..6cb0bc5f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,11 +1,11 @@ -val http4sVersion = "0.23.11" +val http4sVersion = "0.23.12" enablePlugins(BuildInfoPlugin) buildInfoKeys += "http4sVersion" -> http4sVersion libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1" libraryDependencies += "org.http4s" %% "http4s-dsl" % http4sVersion -libraryDependencies += "org.http4s" %% "http4s-blaze-server" % http4sVersion +libraryDependencies += "org.http4s" %% "http4s-blaze-server" % "0.23.11" addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.13.2") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") From 786c01b6e2941f3d1b8f2b615ec7eaa89d4f6c58 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 24 May 2022 23:43:03 +0000 Subject: [PATCH 46/52] Build cleanup --- build.sbt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index f493fcb7..799d204c 100644 --- a/build.sbt +++ b/build.sbt @@ -175,9 +175,6 @@ lazy val tests = project .dependsOn(dom) .enablePlugins(ScalaJSPlugin, BuildInfoPlugin, NoPublishPlugin) -ThisBuild / resolvers += - "s01 snapshots".at("https://s01.oss.sonatype.org/content/repositories/snapshots/") - lazy val nodeJSTests = project .in(file("tests-nodejs")) .settings( @@ -188,7 +185,7 @@ lazy val nodeJSTests = project () }, libraryDependencies ++= Seq( - "org.http4s" %%% "http4s-client-testkit" % "0.23.11-506-d570136-SNAPSHOT", + "org.http4s" %%% "http4s-client-testkit" % http4sVersion, "org.scalameta" %%% "munit" % munitVersion % Test, "org.typelevel" %%% "munit-cats-effect-3" % munitCEVersion % Test ), From 307a83da19bde3b13bd592d4602515de63596ca7 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 24 May 2022 23:52:37 +0000 Subject: [PATCH 47/52] Note Node.js support in docs --- docs/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/index.md b/docs/index.md index 0d70585e..354adfca 100644 --- a/docs/index.md +++ b/docs/index.md @@ -10,6 +10,8 @@ Features: 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! +It is also possible to use the `FetchClient` in Node.js v18+, which added [experimental support](https://nodejs.org/en/blog/announcements/v18-release-announce/#fetch-experimental) for `fetch`, although some browser-specific features may not be available. + ## Installation [![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) From 5ac906e9561d92a0dab2009c5388c8a88c983c2d Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 24 May 2022 23:53:08 +0000 Subject: [PATCH 48/52] Note Node.js support in readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 428ab218..583353ab 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ Features: 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! +It is also possible to use the `FetchClient` in Node.js v18+, which added [experimental support](https://nodejs.org/en/blog/announcements/v18-release-announce/#fetch-experimental) for `fetch`, although some browser-specific features may not be available. + ### Usage [![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) From 57a6489319dc53257d826d9acc0a7b5a9ff3cea8 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 24 May 2022 23:54:56 +0000 Subject: [PATCH 49/52] Publish site with fullOptJS --- build.sbt | 1 - 1 file changed, 1 deletion(-) diff --git a/build.sbt b/build.sbt index 0c03d974..b26e011d 100644 --- a/build.sbt +++ b/build.sbt @@ -181,7 +181,6 @@ lazy val docs = project "calico" -> url("https://armanbilge.github.io/calico/") ), mdocVariables ++= Map( - "js-opt" -> "fast", "HTTP4S_VERSION" -> http4sVersion, "CIRCE_VERSION" -> circeVersion ), From ec5cf4b4d14d5e814984c6f9047223c2b147c196 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Wed, 25 May 2022 00:04:51 +0000 Subject: [PATCH 50/52] organize imports --- dom/src/main/scala/org/http4s/dom/FetchClient.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom/src/main/scala/org/http4s/dom/FetchClient.scala b/dom/src/main/scala/org/http4s/dom/FetchClient.scala index 16c8da2f..5e12546f 100644 --- a/dom/src/main/scala/org/http4s/dom/FetchClient.scala +++ b/dom/src/main/scala/org/http4s/dom/FetchClient.scala @@ -17,6 +17,7 @@ package org.http4s package dom +import cats.data.OptionT import cats.effect.Async import cats.effect.Poll import cats.effect.Resource @@ -33,7 +34,6 @@ import org.scalajs.dom.{Response => FetchResponse} import java.util.concurrent.TimeoutException import scala.concurrent.duration._ -import cats.data.OptionT private[dom] object FetchClient { From 7390de5613eaaba5c31e62d928f35eddf25856f1 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 24 May 2022 17:42:12 -0700 Subject: [PATCH 51/52] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 583353ab..a1ba0993 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.1" +libraryDependencies += "org.http4s" %%% "http4s-dom" % "0.2.2" ``` From 66c3223d10d78189c42093a8d4ae7c73ede1395d Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 25 May 2022 06:53:32 +0200 Subject: [PATCH 52/52] Update http4s-blaze-server to 0.23.12 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 6cb0bc5f..4feb1d15 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,7 +5,7 @@ buildInfoKeys += "http4sVersion" -> http4sVersion libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1" libraryDependencies += "org.http4s" %% "http4s-dsl" % http4sVersion -libraryDependencies += "org.http4s" %% "http4s-blaze-server" % "0.23.11" +libraryDependencies += "org.http4s" %% "http4s-blaze-server" % "0.23.12" addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.13.2") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2")