Add htmax bundle; update package info

This commit is contained in:
danieljsummers committed 2026-06-13 17:37:10 -04:00
1 parent 62af36e833
commit 26d23de15d
7 files changed
+59 -13

No files matched your search

+4 -1
View File
@@ -3,11 +3,14 @@
module Giraffe.Htmx.Common
/// <summary>The version of htmx embedded in the package</summary>
let HtmxVersion = "4.0.0-alpha8"
let HtmxVersion = "4.0.0-beta4"
/// <summary>The path for the provided htmx script</summary>
let internal htmxLocalScript = $"/_content/Giraffe.Htmx.Common/htmx.min.js?ver={HtmxVersion}"
/// <summary>The path for the provided htmax script</summary>
let internal htmaxLocalScript = $"/_content/Giraffe.Htmx.Common/htmax.min.js?ver={HtmxVersion}"
/// <summary>Serialize a list of key/value pairs to JSON (very rudimentary)</summary>
/// <param name="pairs">The key/value pairs to be serialized to JSON</param>
/// <returns>A string with the key/value pairs serialized to JSON</returns>
+1
View File
@@ -0,0 +1 @@
var htmx=(()=>{class e{#e=null;#t=[];issue(e,t){return e.queueStrategy=t,this.#e?"replace"===t||"abort"!==t&&"abort"===this.#e.queueStrategy?(this.#t.forEach(e=>e.status="dropped"),this.#t=[],this.#e.request?.abort?.(),this.#e=e,!0):("queue all"===t?(this.#t.push(e),e.status="queued"):"drop"===t?e.status="dropped":"queue last"===t?(this.#t.forEach(e=>e.status="dropped"),this.#t=[e],e.status="queued"):0===this.#t.length&&"abort"!==t?(this.#t.push(e),e.status="queued"):e.status="dropped",!1):(this.#e=e,!0)}finish(){this.#e=null}next(){return this.#t.shift()}abort(){this.#e?.request?.abort?.()}more(){return this.#t?.length}}return new class{#r=new Map;#i="";#n=new Set;#s;#o=Function;#a=Object.getPrototypeOf(async function(){}).constructor;#l={createHTML:e=>e,createScript:e=>e};#c;#h="a,form";#u=["get","post","put","patch","delete"];#d;#m;#f;#p;constructor(){this.#g(),this.#x(),this.#c=this.#b("[hx-action],[hx-get],[hx-post],[hx-put],[hx-patch],[hx-delete]"),this.#d=(new XPathEvaluator).createExpression(`.//*[@*[${this.#y("hx-on").map(e=>`starts-with(name(), "${e}")`).join(" or ")}]]`),this.#s={attributeValue:this.#v.bind(this),parseTriggerSpecs:this.#w.bind(this),determineMethodAndAction:this.#E.bind(this),createRequestContext:this.#S.bind(this),collectFormData:this.#C.bind(this),getAttributeObject:this.#q.bind(this),insertContent:this.#A.bind(this),morph:this.#T.bind(this),isSoftMatch:this.#H.bind(this),initSecurity:(e,t,r)=>{e&&(this.#l=e),t&&(this.#o=t),r&&(this.#a=r)},onTrigger:this.#k.bind(this),htmxProp:this.#M.bind(this),triggerHtmxEvent:this.#N.bind(this),executeJavaScript:this.#_.bind(this)};let e=()=>{this.#I(),this.process(document.body)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):setTimeout(e)}#g(){this.version="4.0.0-beta4",this.config={logAll:!1,prefix:"data-hx-",transitions:!1,history:!0,mode:"same-origin",defaultSwap:"innerHTML",defaultFocusScroll:!1,indicatorClass:"htmx-indicator",requestClass:"htmx-request",includeIndicatorCSS:!0,defaultTimeout:6e4,extensions:"",morphIgnore:["data-htmx-powered"],morphScanLimit:10,noSwap:[204,304],implicitInheritance:!1,defaultSettleDelay:1};let e=document.querySelector('meta[name="htmx-config"]');e&&this.#L(e.content,this.config),this.#i=this.config.extensions}#x(){if(!1!==this.config.includeIndicatorCSS){let e=this.config.indicatorClass,t=this.config.requestClass,r=new CSSStyleSheet;r.replaceSync(`.${e}{opacity:0;visibility: hidden} .${t} .${e}, .${t}.${e}{opacity:1;visibility: visible;transition: opacity 200ms ease-in}`),document.adoptedStyleSheets=[...document.adoptedStyleSheets,r]}}registerExtension(e,t){return!(this.#i&&!this.#i.split(/,\s*/).includes(e))&&(!this.#n.has(e)&&(this.#n.add(e),t.init&&t.init(this.#s),void Object.entries(t).forEach(([e,t])=>{this.#r.get(e)?.push(t)||this.#r.set(e,[t])})))}#O(e){let t=this.config.prefix;return!e.closest||null!=e.closest("[hx-ignore]")||t&&null!=e.closest(`[${t}ignore]`)}#R(e,t){let r=this.config.prefix;return e.getAttribute(t)??(r?e.getAttribute(t.replace("hx-",r)):null)}#D(e,t){let r=this.config.prefix&&t.replace("hx-",this.config.prefix);return e.hasAttribute(t)?t:r&&e.hasAttribute(r)?r:null}#b(e){return this.#y(e).join(",")}#y(e){let t=[e];return this.config.prefix&&t.push(e.replaceAll("hx-",this.config.prefix)),t}#P(e,t){let r=[...e.querySelectorAll?.(t)??[]];return e.matches?.(t)&&r.unshift(e),r}#j(e){return"before"===e?"beforebegin":"after"===e?"afterend":"prepend"===e?"afterbegin":"append"===e?"beforeend":e}#V(e,t){let r=[];return this.#v(e,t,void 0,(e,t)=>{e?.split(/\s*[,:]\s*/).includes("this")&&r.push(t)}),r}#v(e,t,r,i){t=this.#F(t);let n=this.#F(":inherited"),s=this.#F(":append"),o=this.#R(e,t)??this.#R(e,t+n);if(null!=o)return i?i(o,e):o;let a=CSS.escape(this.config.implicitInheritance?t:t+n),l=CSS.escape(t+n+s),c=this.#b(`[${a}],[${l}]`),h=this.#D(e,t+s)??this.#D(e,t+n+s);if(h){let r=e.getAttribute(h),n=e.parentNode?.closest?.(c);if(i&&i(r,e),n){let e=this.#v(n,t,void 0,i);return e?(e+","+r).replace(/[{}]/g,""):r}return r}let u=e.parentNode?.closest?.(c);return u?(o=this.#v(u,t,void 0,i),!i&&o&&this.config.implicitInheritance&&this.#B(e,"htmx:after:implicitInheritance",{elt:e,name:t,parent:u}),o):r}#W(e){if(!e)return{};if("{"===e[0])return JSON.parse(e);return[...e.matchAll(/(?:"([^"]+)"|([^\s,:]+))(?:\s*:\s*(?:"([^"]*)"|'([^']*)'|<([^>]+)\/>|([^\s,]+)))?(?=\s|,|$)/g)].reduce((e,t)=>{let r=(t[1]??t[2]).split("."),i=(t[3]??t[4]??t[5]??t[6]??"true").trim();return"true"===i?i=!0:"false"===i?i=!1:/^\d+$/.test(i)&&(i=parseInt(i)),r.some(e=>this.#$(e))||(r.slice(0,-1).reduce((e,t)=>e[t]??={},e)[r.at(-1)]=i),e},{})}#$(e){return"#proto#"===e||"constructor"===e||"prototype"===e}#L(e,t){let r=this.#W(e);for(let e in r){if(this.#$(e))continue;let i=r[e];i&&"object"==typeof i&&!Array.isArray(i)&&t[e]?Object.assign(t[e],i):t[e]=i}return t}#w(e){return e.split(/,(?![^\[]*\])/).flatMap(e=>{let[,t,r]=e.match(/^\s*(\S+\[[^\]]*\]|\S+)\s*(.*?)\s*$/)??[];if(!t)return[];if(/\[[^\]Line truncated
+1 -1
View File
@@ -1 +1 @@
var htmx=(()=>{class e{#e=null;#t=[];issue(e,t){return e.queueStrategy=t,this.#e?"replace"===t||"abort"!==t&&"abort"===this.#e.queueStrategy?(this.#t.forEach(e=>e.status="dropped"),this.#t=[],this.#e.request?.abort?.(),this.#e=e,!0):("queue all"===t?(this.#t.push(e),e.status="queued"):"drop"===t?e.status="dropped":"queue last"===t?(this.#t.forEach(e=>e.status="dropped"),this.#t=[e],e.status="queued"):0===this.#t.length&&"abort"!==t?(this.#t.push(e),e.status="queued"):e.status="dropped",!1):(this.#e=e,!0)}finish(){this.#e=null}next(){return this.#t.shift()}abort(){this.#e?.request?.abort?.()}more(){return this.#t?.length}}return new class{#r=new Map;#i="";#s=new Set;#n;#a;#o="a,form";#l=["get","post","put","patch","delete"];#h;#u;#c;#d;constructor(){this.#f(),this.#m(),this.#a=`[${this.#p("hx-action")}],[${this.#p("hx-get")}],[${this.#p("hx-post")}],[${this.#p("hx-put")}],[${this.#p("hx-patch")}],[${this.#p("hx-delete")}]`,this.#h=(new XPathEvaluator).createExpression(`.//*[@*[ starts-with(name(), "${this.#p("hx-on")}")]]`),this.#n={attributeValue:this.#g.bind(this),parseTriggerSpecs:this.#b.bind(this),determineMethodAndAction:this.#x.bind(this),createRequestContext:this.#y.bind(this),collectFormData:this.#v.bind(this),getAttributeObject:this.#S.bind(this),insertContent:this.#E.bind(this),morph:this.#w.bind(this),isSoftMatch:this.#C.bind(this),onTrigger:this.#A.bind(this),htmxProp:this.#q.bind(this),triggerHtmxEvent:this.#T.bind(this)};let e=()=>{this.#M(),this.process(document.body)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):setTimeout(e)}#f(){this.version="4.0.0-alpha8",this.config={logAll:!1,prefix:"",transitions:!1,history:!0,mode:"same-origin",defaultSwap:"innerHTML",defaultFocusScroll:!1,indicatorClass:"htmx-indicator",requestClass:"htmx-request",includeIndicatorCSS:!0,defaultTimeout:6e4,extensions:"",morphIgnore:["data-htmx-powered"],morphScanLimit:10,noSwap:[204,304],implicitInheritance:!1,defaultSettleDelay:1};let e=document.querySelector('meta[name="htmx-config"]');e&&this.#N(e.content,this.config),this.#i=this.config.extensions}#m(){if(!1!==this.config.includeIndicatorCSS){let e="";this.config.inlineStyleNonce&&(e=` nonce="${this.config.inlineStyleNonce}"`);let t=this.config.indicatorClass,r=this.config.requestClass;document.head.insertAdjacentHTML("beforeend",`<style${e}>.${t}{opacity:0;visibility: hidden} .${r} .${t}, .${r}.${t}{opacity:1;visibility: visible;transition: opacity 200ms ease-in}</style>`)}}registerExtension(e,t){return!(this.#i&&!this.#i.split(/,\s*/).includes(e))&&(!this.#s.has(e)&&(this.#s.add(e),t.init&&t.init(this.#n),void Object.entries(t).forEach(([e,t])=>{this.#r.get(e)?.push(t)||this.#r.set(e,[t])})))}#H(e){return!e.closest||null!=e.closest(`[${this.#p("hx-ignore")}]`)}#p(e){return this.config.prefix?e.replace("hx-",this.config.prefix):e}#I(e,t){let r=[...e.querySelectorAll?.(t)??[]];return e.matches?.(t)&&r.unshift(e),r}#O(e){return"before"===e?"beforebegin":"after"===e?"afterend":"prepend"===e?"afterbegin":"append"===e?"beforeend":e}#L(e,t){let r=[];return this.#g(e,t,void 0,(e,t)=>{e?.split(/\s*,\s*/).includes("this")&&r.push(t)}),r}#g(e,t,r,i){let s=t,n=(t=this.#k(this.#p(t)))+this.#k(":append"),a=t+(this.config.implicitInheritance?"":this.#k(":inherited")),o=t+this.#k(":inherited:append");if(e.hasAttribute(t)){let r=e.getAttribute(t);return i?i(r,e):r}if(e.hasAttribute(a)){let t=e.getAttribute(a);return i?i(t,e):t}if(e.hasAttribute(n)||e.hasAttribute(o)){let t=e.getAttribute(n)||e.getAttribute(o),r=e.parentNode?.closest?.(`[${CSS.escape(a)}],[${CSS.escape(o)}]`);if(i&&i(t,e),r){let e=this.#g(r,s,void 0,i);return e?(e+","+t).replace(/[{}]/g,""):t}return t}let l=e.parentNode?.closest?.(`[${CSS.escape(a)}],[${CSS.escape(o)}]`);if(l){let r=this.#g(l,s,void 0,i);return!i&&r&&this.config.implicitInheritance&&this.#R(e,"htmx:after:implicitInheritance",{elt:e,name:t,parent:l}),r}return r}#j(e){if(!e)return{};if("{"===e[0])return JSON.parse(e);return[...e.matchAll(/(?:"([^"]+)"|([^\s,:]+))(?:\s*:\s*(?:"([^"]*)"|'([^']*)'|<([^>]+)\/>|([^\s,]+)))?(?=\s|,|$)/g)].reduce((e,t)=>{let r=(t[1]??t[2]).split("."),i=(t[3]??t[4]??t[5]??t[6]??"true").trim();return"true"===i?i=!0:"false"===i?i=!1:/^\d+$/.test(i)&&(i=parseInt(i)),r.some(e=>this.#V(e))||(r.slice(0,-1).reduce((e,t)=>e[t]??={},e)[r.at(-1)]=i),e},{})}#V(e){return"#proto#"===e||"constructor"===e||"prototype"===e}#N(e,t){let r=this.#j(e);for(let e in r){if(this.#V(e))continue;let i=r[e];i&&"object"==typeof i&&!Array.isArray(i)&&t[e]?Object.assign(t[e],i):t[e]=i}return t}#b(e){return e.split(",").map(e=>{let t=e.match(/^\s*(\S+\[[^\]]*\]|\S+)\s*(.*?)\s*$/);if(!t||!t[1])return null;if(t[1].includes("[")&&!t[1].includes("]"))throw"unterminated:"+t[1];let r=t[2]?this.#j(t[2]):{};return r.name=t[1],r}).filter(e=>e)}#x(e,t){if(this.#P(e))return this.#B(e,t);{let t=this.#g(e,"hx-method")||"GET",r=this.#g(e,"hx-action");if(!r)for(let i of this.#l){let s=this.#g(e,"hx-"+i);if(null!=s){r=s,t=i;break}}reLine truncated
var htmx=(()=>{class e{#e=null;#t=[];issue(e,t){return e.queueStrategy=t,this.#e?"replace"===t||"abort"!==t&&"abort"===this.#e.queueStrategy?(this.#t.forEach(e=>e.status="dropped"),this.#t=[],this.#e.request?.abort?.(),this.#e=e,!0):("queue all"===t?(this.#t.push(e),e.status="queued"):"drop"===t?e.status="dropped":"queue last"===t?(this.#t.forEach(e=>e.status="dropped"),this.#t=[e],e.status="queued"):0===this.#t.length&&"abort"!==t?(this.#t.push(e),e.status="queued"):e.status="dropped",!1):(this.#e=e,!0)}finish(){this.#e=null}next(){return this.#t.shift()}abort(){this.#e?.request?.abort?.()}more(){return this.#t?.length}}return new class{#r=new Map;#i="";#s=new Set;#n;#o=Function;#a=Object.getPrototypeOf(async function(){}).constructor;#l={createHTML:e=>e,createScript:e=>e};#h;#c="a,form";#u=["get","post","put","patch","delete"];#d;#f;#m;#p;constructor(){this.#g(),this.#x(),this.#h=this.#b("[hx-action],[hx-get],[hx-post],[hx-put],[hx-patch],[hx-delete]"),this.#d=(new XPathEvaluator).createExpression(`.//*[@*[${this.#y("hx-on").map(e=>`starts-with(name(), "${e}")`).join(" or ")}]]`),this.#n={attributeValue:this.#S.bind(this),parseTriggerSpecs:this.#v.bind(this),determineMethodAndAction:this.#E.bind(this),createRequestContext:this.#w.bind(this),collectFormData:this.#C.bind(this),getAttributeObject:this.#A.bind(this),insertContent:this.#q.bind(this),morph:this.#T.bind(this),isSoftMatch:this.#N.bind(this),initSecurity:(e,t,r)=>{e&&(this.#l=e),t&&(this.#o=t),r&&(this.#a=r)},onTrigger:this.#M.bind(this),htmxProp:this.#I.bind(this),triggerHtmxEvent:this.#H.bind(this),executeJavaScript:this.#O.bind(this)};let e=()=>{this.#L(),this.process(document.body)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):setTimeout(e)}#g(){this.version="4.0.0-beta4",this.config={logAll:!1,prefix:"data-hx-",transitions:!1,history:!0,mode:"same-origin",defaultSwap:"innerHTML",defaultFocusScroll:!1,indicatorClass:"htmx-indicator",requestClass:"htmx-request",includeIndicatorCSS:!0,defaultTimeout:6e4,extensions:"",morphIgnore:["data-htmx-powered"],morphScanLimit:10,noSwap:[204,304],implicitInheritance:!1,defaultSettleDelay:1};let e=document.querySelector('meta[name="htmx-config"]');e&&this.#P(e.content,this.config),this.#i=this.config.extensions}#x(){if(!1!==this.config.includeIndicatorCSS){let e=this.config.indicatorClass,t=this.config.requestClass,r=new CSSStyleSheet;r.replaceSync(`.${e}{opacity:0;visibility: hidden} .${t} .${e}, .${t}.${e}{opacity:1;visibility: visible;transition: opacity 200ms ease-in}`),document.adoptedStyleSheets=[...document.adoptedStyleSheets,r]}}registerExtension(e,t){return!(this.#i&&!this.#i.split(/,\s*/).includes(e))&&(!this.#s.has(e)&&(this.#s.add(e),t.init&&t.init(this.#n),void Object.entries(t).forEach(([e,t])=>{this.#r.get(e)?.push(t)||this.#r.set(e,[t])})))}#k(e){let t=this.config.prefix;return!e.closest||null!=e.closest("[hx-ignore]")||t&&null!=e.closest(`[${t}ignore]`)}#V(e,t){let r=this.config.prefix;return e.getAttribute(t)??(r?e.getAttribute(t.replace("hx-",r)):null)}#R(e,t){let r=this.config.prefix&&t.replace("hx-",this.config.prefix);return e.hasAttribute(t)?t:r&&e.hasAttribute(r)?r:null}#b(e){return this.#y(e).join(",")}#y(e){let t=[e];return this.config.prefix&&t.push(e.replaceAll("hx-",this.config.prefix)),t}#j(e,t){let r=[...e.querySelectorAll?.(t)??[]];return e.matches?.(t)&&r.unshift(e),r}#B(e){return"before"===e?"beforebegin":"after"===e?"afterend":"prepend"===e?"afterbegin":"append"===e?"beforeend":e}#F(e,t){let r=[];return this.#S(e,t,void 0,(e,t)=>{e?.split(/\s*[,:]\s*/).includes("this")&&r.push(t)}),r}#S(e,t,r,i){t=this.#$(t);let s=this.#$(":inherited"),n=this.#$(":append"),o=this.#V(e,t)??this.#V(e,t+s);if(null!=o)return i?i(o,e):o;let a=CSS.escape(this.config.implicitInheritance?t:t+s),l=CSS.escape(t+s+n),h=this.#b(`[${a}],[${l}]`),c=this.#R(e,t+n)??this.#R(e,t+s+n);if(c){let r=e.getAttribute(c),s=e.parentNode?.closest?.(h);if(i&&i(r,e),s){let e=this.#S(s,t,void 0,i);return e?(e+","+r).replace(/[{}]/g,""):r}return r}let u=e.parentNode?.closest?.(h);return u?(o=this.#S(u,t,void 0,i),!i&&o&&this.config.implicitInheritance&&this.#D(e,"htmx:after:implicitInheritance",{elt:e,name:t,parent:u}),o):r}#U(e){if(!e)return{};if("{"===e[0])return JSON.parse(e);return[...e.matchAll(/(?:"([^"]+)"|([^\s,:]+))(?:\s*:\s*(?:"([^"]*)"|'([^']*)'|<([^>]+)\/>|([^\s,]+)))?(?=\s|,|$)/g)].reduce((e,t)=>{let r=(t[1]??t[2]).split("."),i=(t[3]??t[4]??t[5]??t[6]??"true").trim();return"true"===i?i=!0:"false"===i?i=!1:/^\d+$/.test(i)&&(i=parseInt(i)),r.some(e=>this.#W(e))||(r.slice(0,-1).reduce((e,t)=>e[t]??={},e)[r.at(-1)]=i),e},{})}#W(e){return"#proto#"===e||"constructor"===e||"prototype"===e}#P(e,t){let r=this.#U(e);for(let e in r){if(this.#W(e))continue;let i=r[e];i&&"object"==typeof i&&!Array.isArray(i)&&t[e]?Object.assign(t[e],i):t[e]=i}return t}#v(e){return e.split(/,(?![^\[]*\])/).flatMap(e=>{let[,t,r]=e.match(/^\s*(\S+\[[^\]]*\]|\S+)\s*(.*?)\s*$/)??[];if(!t)return[];if(/\[[^\]Line truncated
+8 -4
View File
@@ -3,11 +3,15 @@
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<VersionPrefix>4.0.0</VersionPrefix>
<VersionSuffix>alpha8</VersionSuffix>
<VersionSuffix>beta4</VersionSuffix>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReleaseNotes>Update htmx 4 to alpha8
- [Common] Update provided htmx 4 to 4.0.0-alpha8
- [View Engine] Updated script tags to pull htmx 4.0.0-alpha8
<PackageReleaseNotes>Update htmx 4 to beta4
- [Common] Update provided htmx 4 to 4.0.0-beta4
- [Common] Add htmax bundle to provided version
- [Server] Update HX-Target header to return tag and ID (similar to HX-Source)
- [Server] Add support for HX-Request-Type header
- [View Engine] Add hx-status attribute
- [View Engine] Updated script tags to pull htmx 4.0.0-beta4, added "max" bundle links for local and CDN
See package and prior alpha release READMEs; v2 to v4 is not an update-and-forget-it release
</PackageReleaseNotes>
+1 -1
View File
@@ -6,7 +6,7 @@ open Giraffe.Htmx
/// Test to ensure the version was updated
let version =
test "HtmxVersion is correct" {
Expect.equal HtmxVersion "4.0.0-alpha8" "htmx version incorrect"
Expect.equal HtmxVersion "4.0.0-beta4" "htmx version incorrect"
}
/// Tests for the HxSwap module
+23 -2
View File
@@ -731,18 +731,39 @@ let script =
$"""<script src="/_content/Giraffe.Htmx.Common/htmx.min.js?ver={HtmxVersion}"></script>"""
"Local script tag is incorrect"
}
test "localMax succeeds" {
let html = RenderView.AsString.htmlNode Script.localMax
Expect.equal
html
$"""<script src="/_content/Giraffe.Htmx.Common/htmax.min.js?ver={HtmxVersion}"></script>"""
"Local script tag is incorrect"
}
test "cdnMinified succeeds" {
let html = RenderView.AsString.htmlNode Script.cdnMinified
Expect.equal
html
$"""<script src="https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmx.min.js" integrity="sha384-hUj4cz/Dd2p+Dq0r8A6TAMS1u7gu2bTyisk8xCQX3nodazPP+fRmcAWJrTh4Ycwb" crossorigin="anonymous"></script>"""
$"""<script src="https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmx.min.js" integrity="sha384-aWZK1NtOs/aWb/+YZdTM8q2JkWEshlMc9mgZ189numT9bwFhyAyYEoO4nO/2dTXt" crossorigin="anonymous"></script>"""
"CDN minified script tag is incorrect"
}
test "cdnUnminified succeeds" {
let html = RenderView.AsString.htmlNode Script.cdnUnminified
Expect.equal
html
$"""<script src="https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmx.js" integrity="sha384-CHKZYHwIgmpkwoWtoPaiFIiMxP1Up7yHcsZ2NeECzLxRTXCO0mqXlujZwdJgFsFC" crossorigin="anonymous"></script>"""
$"""<script src="https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmx.js" integrity="sha384-OFLRIZpuqI2wwFozxvDGcuF3TQ36ySMgp44WEthOiR4wFzRkhZbK72HFaBo2C3cx" crossorigin="anonymous"></script>"""
"CDN unminified script tag is incorrect"
}
test "cdnMaxMinified succeeds" {
let html = RenderView.AsString.htmlNode Script.cdnMaxMinified
Expect.equal
html
$"""<script src="https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmax.min.js" integrity="sha384-Qoqie5IRtOE79SDFFRSb/yKi+pkzpSnfjgwr1KksyP14OaHkLHar0KrLVxUwlsJF" crossorigin="anonymous"></script>"""
"CDN minified script tag is incorrect"
}
test "cdnMaxUnminified succeeds" {
let html = RenderView.AsString.htmlNode Script.cdnMaxUnminified
Expect.equal
html
$"""<script src="https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmax.js" integrity="sha384-gGi3Urue6ZkE4NrJCmXWIZkfNkrt1IrdP3fr0kb/v06GWg3V1RnD9Pg/Ul3qhtAK" crossorigin="anonymous"></script>"""
"CDN unminified script tag is incorrect"
}
]
+21 -4
View File
@@ -1011,18 +1011,35 @@ module Script =
/// <summary>Script tag to load the package-provided version of htmx</summary>
let local = script [ _src htmxLocalScript ] []
/// <summary>Script tag to load the package-provided version of the htmx-plus-extensions bundle</summary>
let localMax = script [ _src htmaxLocalScript ] []
/// <summary>Script tag to load the minified version from jsdelivr.net</summary>
/// <remarks>Ensure <c>cdn.jsdelivr.net</c> is in your CSP <c>script-src</c> list (if applicable)</remarks>
let cdnMinified =
script [ _src "https://cdn.jsdelivr.net/npm/htmx.org@4.0.0-alpha8/dist/htmx.min.js"
_integrity "sha384-hUj4cz/Dd2p+Dq0r8A6TAMS1u7gu2bTyisk8xCQX3nodazPP+fRmcAWJrTh4Ycwb"
script [ _src $"https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmx.min.js"
_integrity "sha384-aWZK1NtOs/aWb/+YZdTM8q2JkWEshlMc9mgZ189numT9bwFhyAyYEoO4nO/2dTXt"
_crossorigin "anonymous" ] []
/// <summary>Script tag to load the unminified version from jsdelivr.net</summary>
/// <remarks>Ensure <c>cdn.jsdelivr.net</c> is in your CSP <c>script-src</c> list (if applicable)</remarks>
let cdnUnminified =
script [ _src "https://cdn.jsdelivr.net/npm/htmx.org@4.0.0-alpha8/dist/htmx.js"
_integrity "sha384-CHKZYHwIgmpkwoWtoPaiFIiMxP1Up7yHcsZ2NeECzLxRTXCO0mqXlujZwdJgFsFC"
script [ _src $"https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmx.js"
_integrity "sha384-OFLRIZpuqI2wwFozxvDGcuF3TQ36ySMgp44WEthOiR4wFzRkhZbK72HFaBo2C3cx"
_crossorigin "anonymous" ] []
/// <summary>Script tag to load the minified htmx-plus-extensions bundle from jsdelivr.net</summary>
/// <remarks>Ensure <c>cdn.jsdelivr.net</c> is in your CSP <c>script-src</c> list (if applicable)</remarks>
let cdnMaxMinified =
script [ _src $"https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmax.min.js"
_integrity "sha384-Qoqie5IRtOE79SDFFRSb/yKi+pkzpSnfjgwr1KksyP14OaHkLHar0KrLVxUwlsJF"
_crossorigin "anonymous" ] []
/// <summary>Script tag to load the unminified htmx-plus-extensions bundle from jsdelivr.net</summary>
/// <remarks>Ensure <c>cdn.jsdelivr.net</c> is in your CSP <c>script-src</c> list (if applicable)</remarks>
let cdnMaxUnminified =
script [ _src $"https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmax.js"
_integrity "sha384-gGi3Urue6ZkE4NrJCmXWIZkfNkrt1IrdP3fr0kb/v06GWg3V1RnD9Pg/Ul3qhtAK"
_crossorigin "anonymous" ] []
/// <summary>Script tag to load the minified version from jsdelivr.net</summary>