From 541384a92faa47b4bdadad21e00484983e1c730a Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Tue, 18 Jun 2024 19:16:10 -0400 Subject: [PATCH] htmx v2 - Drop `hx-sse` and `hx-ws` attributes - Drop explicit .NET 7 support - Update deps to latest versions --- src/Common/README.md | 2 +- src/Directory.Build.props | 5 ++--- src/Htmx/Giraffe.Htmx.fsproj | 2 +- src/Htmx/README.md | 6 +++--- src/Tests/Program.fs | 2 +- src/Tests/Tests.fsproj | 5 +++-- src/Tests/ViewEngine.fs | 11 ++--------- src/ViewEngine.Htmx/Htmx.fs | 16 +++++----------- src/ViewEngine.Htmx/README.md | 6 +++--- 9 files changed, 21 insertions(+), 34 deletions(-) diff --git a/src/Common/README.md b/src/Common/README.md index 12a8554..02ffab8 100644 --- a/src/Common/README.md +++ b/src/Common/README.md @@ -2,4 +2,4 @@ This package contains common code shared between [`Giraffe.Htmx`](https://www.nuget.org/packages/Giraffe.Htmx) and [`Giraffe.ViewEngine.Htmx`](https://www.nuget.org/packages/Giraffe.ViewEngine.Htmx), and will be automatically installed when you install either one. -**htmx version: 2.0.0-beta4** +**htmx version: 2.0.0** diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 750e0f4..b9374f7 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,10 +1,9 @@  - net6.0;net7.0;net8.0 + net6.0;net8.0 2.0.0 - beta4 - Update script tags to pull htmx 2.0.0-beta4; add SSE attributes + Update script tags to pull htmx 2.0.0; remove hx-sse and hx-ws attributes; drop explicit .NET 7 support danieljsummers Bit Badger Solutions https://git.bitbadger.solutions/bit-badger/Giraffe.Htmx diff --git a/src/Htmx/Giraffe.Htmx.fsproj b/src/Htmx/Giraffe.Htmx.fsproj index 085712e..4111b40 100644 --- a/src/Htmx/Giraffe.Htmx.fsproj +++ b/src/Htmx/Giraffe.Htmx.fsproj @@ -13,7 +13,7 @@ - + diff --git a/src/Htmx/README.md b/src/Htmx/README.md index 1a5d066..4947157 100644 --- a/src/Htmx/README.md +++ b/src/Htmx/README.md @@ -2,13 +2,13 @@ This package enables server-side support for [htmx](https://htmx.org) within [Giraffe](https://giraffe.wiki) and ASP.NET's `HttpContext`. -**htmx version: 2.0.0-beta4** +**htmx version: 2.0.0** -_Note that htmx 2.0 is a BETA release. The [migration guide](https://v2-0v2-0.htmx.org/migration-guide-htmx-1/) does not currently specify any request or response header changes. This means that, as of this release, there are no required code changes in moving to this major version._ +_Upgrading: the [migration guide](https://htmx.org/migration-guide-htmx-1/) does not currently specify any request or response header changes. This means that there are no required code changes in moving from v1.* to v2.*._ ### Setup -1. Install the package (must use `--Prerelease` flag). +1. Install the package. 2. Prior to using the request header extension properties or the header-setting `HttpHandler`s, `open Giraffe.Htmx`. ### Use diff --git a/src/Tests/Program.fs b/src/Tests/Program.fs index cc9fe1a..fba7983 100644 --- a/src/Tests/Program.fs +++ b/src/Tests/Program.fs @@ -3,4 +3,4 @@ open Expecto let allTests = testList "Giraffe" [ Common.allTests; Htmx.allTests; ViewEngine.allTests ] [] -let main args = runTestsWithArgs defaultConfig args allTests +let main args = runTestsWithCLIArgs [] args allTests diff --git a/src/Tests/Tests.fsproj b/src/Tests/Tests.fsproj index 70e0920..2eacc29 100644 --- a/src/Tests/Tests.fsproj +++ b/src/Tests/Tests.fsproj @@ -18,8 +18,9 @@ - - + + + diff --git a/src/Tests/ViewEngine.fs b/src/Tests/ViewEngine.fs index cfacdc1..840c2b1 100644 --- a/src/Tests/ViewEngine.fs +++ b/src/Tests/ViewEngine.fs @@ -781,10 +781,6 @@ let attributes = test "_hxSelectOob succeeds" { section [ _hxSelectOob "#oob" ] [] |> shouldRender """
""" } - test "_hxSse succeeds" { - footer [ _hxSse "connect:/my-events" ] [] - |> shouldRender """""" - } test "_hxSwap succeeds" { del [ _hxSwap "innerHTML" ] [] |> shouldRender """""" } @@ -808,9 +804,6 @@ let attributes = dt [ _hxVals """{ "extra": "values" }""" ] [] |> shouldRender """
""" } - test "_hxWs succeeds" { - ul [ _hxWs "connect:/web-socket" ] [] |> shouldRender """""" - } test "_sseSwap succeeds" { ul [ _sseSwap "sseMessageName" ] [] |> shouldRender """""" } @@ -826,14 +819,14 @@ let script = let html = RenderView.AsString.htmlNode Script.minified Expect.equal html - """""" + """""" "Minified script tag is incorrect" } test "unminified succeeds" { let html = RenderView.AsString.htmlNode Script.unminified Expect.equal html - """""" + """""" "Unminified script tag is incorrect" } ] diff --git a/src/ViewEngine.Htmx/Htmx.fs b/src/ViewEngine.Htmx/Htmx.fs index e76b6cf..8c8562a 100644 --- a/src/ViewEngine.Htmx/Htmx.fs +++ b/src/ViewEngine.Htmx/Htmx.fs @@ -408,9 +408,6 @@ module HtmxAttrs = /// Selects a subset of an out-of-band server response let _hxSelectOob = attr "hx-select-oob" - /// Establishes and listens to Server Sent Event (SSE) sources for events - let _hxSse = attr "hx-sse" - /// Controls how the response content is swapped into the DOM (e.g. 'outerHTML' or 'beforeEnd') let _hxSwap = attr "hx-swap" @@ -436,9 +433,6 @@ module HtmxAttrs = /// Adds to the parameters that will be submitted with the request let _hxVals = attr "hx-vals" - /// Establishes a WebSocket or sends information to one - let _hxWs = attr "hx-ws" - /// The name of the message to swap into the DOM. let _sseSwap = attr "sse-swap" @@ -446,19 +440,19 @@ module HtmxAttrs = let _sseConnect = attr "sse-connect" -/// Script tags to pull htmx into an web page +/// Script tags to pull htmx into a web page module Script = /// Script tag to load the minified version from unpkg.com let minified = - script [ _src "https://unpkg.com/htmx.org@2.0.0-beta4" - _integrity "sha384-QprZjU1JKuXu/TnlURCTYppToUjigoOZCrzQtRXAjHttxoV9gkqiizVeAwjeGy1f" + script [ _src "https://unpkg.com/htmx.org@2.0.0" + _integrity "sha384-wS5l5IKJBvK6sPTKa2WZ1js3d947pvWXbPJ1OmWfEuxLgeHcEbjUUA5i9V5ZkpCw" _crossorigin "anonymous" ] [] /// Script tag to load the unminified version from unpkg.com let unminified = - script [ _src "https://unpkg.com/htmx.org@2.0.0-beta4/dist/htmx.js" - _integrity "sha384-n/53Us+nZur0snldc6yl7W3paw5/sbtpXhImQJk9JZf0KQjzCP6lbBWmAtFsCSb9" + script [ _src "https://unpkg.com/htmx.org@2.0.0/dist/htmx.js" + _integrity "sha384-Xh+GLLi0SMFPwtHQjT72aPG19QvKB8grnyRbYBNIdHWc2NkCrz65jlU7YrzO6qRp" _crossorigin "anonymous" ] [] diff --git a/src/ViewEngine.Htmx/README.md b/src/ViewEngine.Htmx/README.md index b66467e..51ea7c0 100644 --- a/src/ViewEngine.Htmx/README.md +++ b/src/ViewEngine.Htmx/README.md @@ -2,13 +2,13 @@ This package enables [htmx](https://htmx.org) support within the [Giraffe](https://giraffe.wiki) view engine. -**htmx version: 2.0.0-beta4** +**htmx version: 2.0.0** -_Note that this is a BETA release of htmx 2.0; see [the migration guide](https://v2-0v2-0.htmx.org/migration-guide-htmx-1/) for changes_ +_Upgrading: see [the migration guide](https://htmx.org/migration-guide-htmx-1/) for changes_ ### Setup -1. Install the package (must use `--Prerelease` flag). +1. Install the package. 2. Prior to using the attribute or support modules, `open Giraffe.ViewEngine.Htmx`. ### Use