@jhxdev/hono 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var O=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var He=Object.prototype.hasOwnProperty;var a=(e,o)=>O(e,"name",{value:o,configurable:!0});var be=(e,o)=>{for(var r in o)O(e,r,{get:o[r],enumerable:!0})},Se=(e,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of Re(o))!He.call(e,t)&&t!==r&&O(e,t,{get:()=>o[t],enumerable:!(n=ye(o,t))||n.enumerable});return e};var ve=e=>Se(O({},"__esModule",{value:!0}),e);var Le={};be(Le,{applyAttributes:()=>xe,attributesToString:()=>k,createJhx:()=>Me,createJhxComponent:()=>Ue,defaultConfig:()=>V,htmx:()=>j});module.exports=ve(Le);var E={onAbort:"hx-on--abort",onAfterOnLoad:"hx-on--after-on-load",onAfterProcessNode:"hx-on--after-process-node",onAfterRequest:"hx-on--after-request",onAfterSettle:"hx-on--after-settle",onAfterSwap:"hx-on--after-swap",onBeforeCleanupElement:"hx-on--before-cleanup-element",onBeforeOnLoad:"hx-on--before-on-load",onBeforeProcessNode:"hx-on--before-process-node",onBeforeRequest:"hx-on--before-request",onBeforeSwap:"hx-on--before-swap",onBeforeSend:"hx-on--before-send",onBeforeTransition:"hx-on--before-transition",onConfigRequest:"hx-on--config-request",onConfirm:"hx-on--confirm",onHistoryCacheError:"hx-on--history-cache-error",onHistoryCacheHit:"hx-on--history-cache-hit",onHistoryCacheMiss:"hx-on--history-cache-miss",onHistoryCacheMissLoadError:"hx-on--history-cache-miss-load-error",onHistoryCacheMissLoad:"hx-on--history-cache-miss-load",onHistoryRestore:"hx-on--history-restore",onBeforeHistorySave:"hx-on--before-history-save",onLoad:"hx-on--load",onNoSSESourceError:"hx-on--no-sse-source-error",onOnLoadError:"hx-on--on-load-error",onOobAfterSwap:"hx-on--oob-after-swap",onOobBeforeSwap:"hx-on--oob-before-swap",onOobErrorNoTarget:"hx-on--oob-error-no-target",onPrompt:"hx-on--prompt",onPushedIntoHistory:"hx-on--pushed-into-history",onReplacedInHistory:"hx-on--replaced-in-history",onResponseError:"hx-on--response-error",onSendAbort:"hx-on--send-abort",onSendError:"hx-on--send-error",onSseError:"hx-on--sse-error",onSseOpen:"hx-on--sse-open",onSwapError:"hx-on--swap-error",onTargetError:"hx-on--target-error",onTimeout:"hx-on--timeout",onValidateUrl:"hx-on--validate-url",onValidationValidate:"hx-on--validation-validate",onValidationFailed:"hx-on--validation-failed",onValidationHalted:"hx-on--validation-halted",onXhrAbort:"hx-on--xhr-abort",onXhrLoadend:"hx-on--xhr-loadend",onXhrLoadstart:"hx-on--xhr-loadstart",onXhrProgress:"hx-on--xhr-progress"};var z={get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch",pushUrl:"hx-push-url",select:"hx-select",selectOob:"hx-select-oob",swap:"hx-swap",swapOob:"hx-swap-oob",target:"hx-target",trigger:"hx-trigger",vals:"hx-vals",boost:"hx-boost",confirm:"hx-confirm",disable:"hx-disable",disabledElt:"hx-disabled-elt",disinherit:"hx-disinherit",encoding:"hx-encoding",ext:"hx-ext",headers:"hx-headers",history:"hx-history",historyElt:"hx-history-elt",include:"hx-include",indicator:"hx-indicator",inherit:"hx-inherit",params:"hx-params",preserve:"hx-preserve",prompt:"hx-prompt",replaceUrl:"hx-replace-url",request:"hx-request",sync:"hx-sync",validate:"hx-validate",vars:"hx-vars",...E};var G={added:"htmx-added",indicator:"htmx-indicator",request:"htmx-request",settling:"htmx-settling",swapping:"htmx-swapping"};var Y={addedClass:"hx-added",allowEval:!0,allowNestedOobSwaps:!0,allowScriptTags:!0,attributesToSettle:["class","style","width","height"],defaultFocusScroll:!1,defaultSettleDelay:20,defaultSwapDelay:0,defaultSwapStyle:"innerHTML",disableInheritance:!1,disableSelector:"[hx-disable], [data-hx-disable]",getCacheBusterParam:!1,globalViewTransitions:!1,historyCacheSize:10,historyEnabled:!0,historyRestoreAsHxRequest:!0,ignoreTitle:!1,includeIndicatorStyles:!0,indicatorClass:"hx-indicator",inlineScriptNonce:"",inlineStyleNonce:"",methodsThatUseUrlParams:["get","delete"],refreshOnHistoryMiss:!1,requestClass:"htmx-request",responseHandling:[{code:"204",swap:!1},{code:"[23]..",swap:!0},{code:"[45]..",swap:!1,error:!0}],scrollBehavior:"instant",scrollIntoViewOnBoost:!0,selfRequestsOnly:!0,settlingClass:"htmx-settling",swappingClass:"htmx-swapping",timeout:0,triggerSpecsCache:null,withCredentials:!1,wsBinaryType:"blob",wsReconnectDelay:"full-jitter"};var _={abort:"htmx:abort",afterOnLoad:"htmx:afterOnLoad",afterProcessNode:"htmx:afterProcessNode",afterRequest:"htmx:afterRequest",afterSettle:"htmx:afterSettle",afterSwap:"htmx:afterSwap",beforeCleanupElement:"htmx:beforeCleanupElement",beforeOnLoad:"htmx:beforeOnLoad",beforeProcessNode:"htmx:beforeProcessNode",beforeRequest:"htmx:beforeRequest",beforeSwap:"htmx:beforeSwap",beforeSend:"htmx:beforeSend",beforeTransition:"htmx:beforeTransition",configRequest:"htmx:configRequest",confirm:"htmx:confirm",historyCacheError:"htmx:historyCacheError",historyCacheHit:"htmx:historyCacheHit",historyCacheMiss:"htmx:historyCacheMiss",historyCacheMissLoadError:"htmx:historyCacheMissLoadError",historyCacheMissLoad:"htmx:historyCacheMissLoad",historyRestore:"htmx:historyRestore",beforeHistorySave:"htmx:beforeHistorySave",load:"htmx:load",noSSESourceError:"htmx:noSSESourceError",onLoadError:"htmx:onLoadError",oobAfterSwap:"htmx:oobAfterSwap",oobBeforeSwap:"htmx:oobBeforeSwap",oobErrorNoTarget:"htmx:oobErrorNoTarget",prompt:"htmx:prompt",pushedIntoHistory:"htmx:pushedIntoHistory",replacedInHistory:"htmx:replacedInHistory",responseError:"htmx:responseError",sendAbort:"htmx:sendAbort",sendError:"htmx:sendError",sseError:"htmx:sseError",sseOpen:"htmx:sseOpen",swapError:"htmx:swapError",targetError:"htmx:targetError",timeout:"htmx:timeout",validateUrl:"htmx:validateUrl",validationValidate:"htmx:validation:validate",validationFailed:"htmx:validation:failed",validationHalted:"htmx:validation:halted",xhrAbort:"htmx:xhr:abort",xhrLoadend:"htmx:xhr:loadend",xhrLoadstart:"htmx:xhr:loadstart",xhrProgress:"htmx:xhr:progress"};var K={headSupport:{name:"head-support",version:"2.0.5",npm:"htmx-ext-head-support",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-head-support@2.0.5",integrity:"sha384-cvMqHzjCJsOHgGuyB3sWXaUSv/Krm0BdzjuI1rtkjCbL1l1oHJx+cHyVRJhyuEz0"}]},htmx1Compat:{name:"htmx-1-compat",version:"2.0.2",npm:"htmx-ext-htmx-1-compat",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-htmx-1-compat@2.0.2",integrity:"sha384-lcvVWaNjF5zPPUeeWmC0OkJ2MLqoWLlkAabuGm+EuMSTfGo5WRyHrNaAp0cJr9Pg"}]},idiomorph:{name:"morph",version:"0.7.4",npm:"idiomorph",cdn:[{url:"https://unpkg.com/idiomorph@0.7.4/dist/idiomorph-ext.min.js",integrity:"sha384-SsScJKzATF/w6suEEdLbgYGsYFLzeKfOA6PY+/C5ZPxOSuA+ARquqtz/BZz9JWU8"}]},preload:{name:"preload",version:"2.1.2",npm:"htmx-ext-preload",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-preload@2.1.2",integrity:"sha384-PRIcY6hH1Y5784C76/Y8SqLyTanY9rnI3B8F3+hKZFNED55hsEqMJyqWhp95lgfk"}]},responseTargets:{name:"response-targets",version:"2.0.4",npm:"htmx-ext-response-targets",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-response-targets@2.0.4",integrity:"sha384-T41oglUPvXLGBVyRdZsVRxNWnOOqCynaPubjUVjxhsjFTKrFJGEMm3/0KGmNQ+Pg"}]},sse:{name:"sse",version:"2.2.4",npm:"htmx-ext-sse",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-sse@2.2.4",integrity:"sha384-A986SAtodyH8eg8x8irJnYUk7i9inVQqYigD6qZ9evobksGNIXfeFvDwLSHcp31N"}]},ws:{name:"ws",version:"2.0.4",npm:"htmx-ext-ws",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.4",integrity:"sha384-1RwI/nvUSrMRuNj7hX1+27J8XDdCoSLf0EjEyF69nacuWyiJYoQ/j39RT1mSnd2G"}]}};var Z={GET:"hx-get",POST:"hx-post",PUT:"hx-put",DELETE:"hx-delete",PATCH:"hx-patch",get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch"};var Q={boosted:"HX-Boosted",currentUrl:"HX-Current-URL",historyRestoreRequest:"HX-History-Restore-Request",prompt:"HX-Prompt",request:"HX-Request",target:"HX-Target",triggerName:"HX-Trigger-Name",trigger:"HX-Trigger"};var ee={location:"HX-Location",pushUrl:"HX-Push-URL",redirect:"HX-Redirect",refresh:"HX-Refresh",replaceUrl:"HX-Replace-URL",reswap:"HX-Reswap",retarget:"HX-Retarget",reselect:"HX-Reselect",trigger:"HX-Trigger",triggerAfterSettle:"HX-Trigger-After-Settle",triggerAfterSwap:"HX-Trigger-After-Swap"};var re={innerHTML:"innerHTML",outerHTML:"outerHTML",textContent:"textContent",beforeBegin:"beforebegin",afterBegin:"afterbegin",beforeEnd:"beforeend",afterEnd:"afterend",delete:"delete",none:"none"};var te={drop:"drop",abort:"abort",replace:"replace",queue:"queue",queueAll:"queue all",queueFirst:"queue first",queueLast:"queue last"};var j={attr:z,config:Y,css:G,event:_,eventAttr:E,ext:K,method:Z,res:ee,req:Q,swap:re,sync:te};var Je=a(e=>{let o=/^(?:async\s*)?function\*?\s*(?:[A-z0-9]+)?\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)\s*\{((?:[^}{]+|\{(?:[^}{]+|\{[^}{]*})*})*)}$/s,r=e.match(o);if(r&&r[2])return{fnType:"normal",fullMatch:r[0],paramStr:r[1]??"",bodyStr:`{ ${r[2].trim()} }`};let n=/^(?:async\s*)?(?:\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)|([^\s=()]+))\s*=>\s*(.*)$/s,t=e.match(n);if(t&&t[3]){let s=t[3].trim();return{fnType:"arrow",fullMatch:t[0],paramStr:t[1]??"",bodyStr:s.startsWith("{")&&(s.endsWith("}")||s.endsWith("};"))?s:`{ return ${s} }`}}return null},"matchFunctionString"),Ee=a(e=>{if(!e)return[];let o=[],r=0,n=0,t=0,s=0;for(let i=0;i<e.length;i++){let T=e[i];T==="("?r++:T===")"?r--:T==="{"?n++:T==="}"?n--:T==="["?t++:T==="]"?t--:T===","&&r===0&&n===0&&t===0&&(o.push(e.substring(s,i).trim()),s=i+1)}return o.push(e.substring(s).trim()),o.filter(Boolean)},"splitParams"),w=a(e=>{if(typeof e!="function"||typeof e?.toString!="function")return null;let o=e.toString(),r=Je(o);return r?{params:Ee(r.paramStr),body:r.bodyStr}:null},"extractFunction");var oe=a(e=>{let o={};if(!e||typeof e!="object")return o;for(let r in e){if(r in E||!r.startsWith("on"))continue;let n=e[r];if(!n)continue;let t=w(n);t&&(o[r.toLowerCase()]=`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`)}return o},"convertDomEventAttributes");var A=class e extends Error{static{a(this,"JhxErrorThrowable")}attribute;constructor(o,r){super(o),this.name="JhxError",this.attribute=r.attribute,r.stack&&(this.stack=r.stack),r.cause&&(this.cause=r.cause),Object.setPrototypeOf(this,e.prototype)}};var ne=a((e,o)=>typeof o=="string"?`${e}:${o}`:"window"in o?`${e}:window:${o.position}`:"selector"in o?`${e}:${o.selector}:${o.position}`:"","processScrollOrShow"),P=a(e=>{if(!e)return;if(typeof e=="string")return e;let o=[];return e.style&&o.push(String(e.style)),e.swap&&o.push(`swap:${e.swap}`),e.settle&&o.push(`settle:${e.settle}`),typeof e.transition=="boolean"&&o.push(`transition:${e.transition}`),e.scroll&&o.push(ne("scroll",e.scroll)),e.show&&o.push(ne("show",e.show)),e.ignoreTitle&&o.push("ignoreTitle:true"),typeof e.focusScroll=="boolean"&&o.push(`focus-scroll:${e.focusScroll}`),o.filter(Boolean).join(" ")},"toJhxSwapAttribute");var $=a(e=>{if(!e)return;let o=Array.isArray(e)?e:[e],r=!1,n=o.map(t=>{if(typeof t!="object")return t;if(t.inherit!==void 0){if(!t.inherit)return;r=!0;return}if(t.position==="this"||t.position==="next"||t.position==="previous")return t.position;let s=[];return typeof t?.position=="string"&&s.push(t.position),typeof t.selector=="string"&&s.push(t.selector),s.join(" ")});return r&&n.unshift("inherit"),n.filter(t=>!!t).join(", ")},"toJhxTargetAttribute");var we=a(e=>{if(e){if(typeof e=="object"){if(e.op==="this"||e.op==="document"||e.op==="window")return e.op;if(typeof e.selector=="string"&&typeof e.op=="string")return`${e.op} ${e.selector}`}return String(e)}},"toJhxFromAttribute"),se=a(e=>typeof e=="string"?e:(Array.isArray(e)?e:[e]).map(r=>{if(typeof r=="string")return r;if(typeof r=="object"){let n=`${r.event||""}${r.filter?`[${r.filter}]`:""}`,t=[];return r.once===!0&&t.push("once"),r.changed===!0&&t.push("changed"),r.consume===!0&&t.push("consume"),r.delay&&t.push(`delay:${r.delay}`),r.from&&t.push(`from:${we(r.from)}`),r.target&&t.push(`target:${$(r.target)}`),r.throttle&&t.push(`throttle:${r.throttle}`),r.queue&&t.push(`queue:${r.queue}`),n.concat(n?" ":"",t.join(" "))}return""}).filter(Boolean).join(", "),"toJhxTriggerAttribute");var Ce=["get","post","put","patch","delete","route"],ae=a((e,o)=>{let r={};if(!e||typeof e!="object")return r;let n=Ce.find(t=>!!e[t]);if(n)if(n==="route"){let t=e.method?.toLowerCase()||"get";r[`hx-${t}`]=String(e.route)}else r[`hx-${n}`]=String(e[n]);else e.method&&o.logger.warn("[jhx] The 'method' prop must be paired with a 'route' prop to generate a request attribute.");if(e.boost===!0&&(r["hx-boost"]="true"),e.confirm&&(r["hx-confirm"]=e.confirm),e.disable===!0&&(r["hx-disable"]="true"),e.disabledElt){let t=$(e.disabledElt);t&&(r["hx-disabled-elt"]=t)}if(e.disinherit&&(Array.isArray(e.disinherit)?r["hx-disinherit"]=e.disinherit.join(" "):r["hx-disinherit"]=e.disinherit),e.encoding&&(r["hx-encoding"]=e.encoding),e.ext){typeof e.ext=="string"&&(r["hx-ext"]=e.ext);let s=(Array.isArray(e.ext)?e.ext:[e.ext]).map(i=>typeof i=="object"?`${i?.name&&i.ignore===!0?"ignore:":""}${i?.name}`:i).filter(Boolean).join(",");s&&(r["hx-ext"]=s)}if(e.headers)if(typeof e.headers=="object")try{r["hx-headers"]=`${JSON.stringify(e.headers)}`}catch(t){throw o.logger.error("[jhx] Error while parsing the `hx-headers` object."),new A("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-headers",cause:t,stack:t instanceof Error&&typeof t.stack=="string"?t.stack:void 0})}else if(typeof e.headers=="function"){let t=w(e.headers);if(t){let s=`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`;r["hx-vals"]=`js:{...${s}}`}}else r["hx-headers"]=e.headers;if(e.history===!1&&(r["hx-history"]="false"),e.historyElt===!0&&(r["hx-history-elt"]="true"),e.indicator)if(typeof e.indicator=="object"){let t=e.indicator.inherit===!0?"inherit, ":"",s=e.indicator.closest===!0?"closest ":"";r["hx-indicator"]=`${t}${s}${e.indicator.selector}`}else r["hx-indicator"]=e.indicator;if(e.include){let t=$(e.include);t&&(r["hx-include"]=t)}if(e.inherit&&(Array.isArray(e.inherit)?r["hx-inherit"]=e.inherit.join(" "):r["hx-inherit"]=e.inherit),e.params&&(typeof e.params=="object"?e.params.include&&Array.isArray(e.params.include)?r["hx-params"]=`${e.params.include.join(",")}`:e.params.exclude&&Array.isArray(e.params.exclude)&&(r["hx-params"]=`not ${e.params.exclude.join(",")}`):r["hx-params"]=e.params),e.preserve===!0&&(r["hx-preserve"]="true"),e.prompt&&(r["hx-prompt"]=e.prompt),e.pushUrl&&(e.pushUrl===!0?r["hx-push-url"]="true":r["hx-push-url"]=e.pushUrl),(e.replaceUrl||e.replaceUrl===!1)&&(typeof e.replaceUrl=="boolean"?r["hx-replace-url"]=e.replaceUrl?"true":"false":r["hx-replace-url"]=e.replaceUrl),e.request)if(typeof e.request=="object")try{r["hx-request"]=`${JSON.stringify(e.request)}`}catch(t){throw new A("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-request",cause:t,stack:t instanceof Error&&typeof t.stack=="string"?t.stack:void 0})}else if(typeof e.request=="function"){let t=w(e.request);if(t){let i=`(({ timeout, credentials, noHeaders }) => ({ timeout, credentials, noHeaders }))(${`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`})`;r["hx-request"]=`js: ${i}`}}else r["hx-request"]=e.request;if(e.select&&(r["hx-select"]=e.select),e.selectOob)if(Array.isArray(e.selectOob))r["hx-select-oob"]=e.selectOob.map(t=>{if(typeof t=="string")return t;if(typeof t=="object"&&t.selector){let s=P(t.swap);return`${t.selector}${s?":"+s:""}`}return""}).filter(Boolean).join(",");else if(typeof e.selectOob=="object"){let t=P(e.selectOob.swap);r["hx-select-oob"]=`${e.selectOob.selector}${t?":"+t:""}`}else r["hx-select-oob"]=e.selectOob;if(e.swap){let t=P(e.swap);t&&(r["hx-swap"]=t)}if(e.swapOob)if(e.swapOob===!0)r["hx-swap-oob"]="true";else if(typeof e.swapOob=="object"){let t=P(e.swapOob.swap);t&&(r["hx-swap-oob"]=`${t}${e.swapOob.selector?":"+e.swapOob.selector:""}`)}else r["hx-swap-oob"]=e.swapOob;if(e.sync&&(typeof e.sync=="object"?e.sync.strategy&&e.sync.tag?r["hx-sync"]=`${e.sync.closest===!0?"closest ":""}${e.sync.tag}:${e.sync.strategy}`:e.sync.strategy&&(r["hx-sync"]=`this:${e.sync.strategy}`):r["hx-sync"]=e.sync),e.target){let t=$(e.target);t&&(r["hx-target"]=t)}if(e.trigger&&(r["hx-trigger"]=se(e.trigger)),e.validate===!0&&(r["hx-validate"]="true"),e.vars&&(o.logger.warn("[jhx] The `hx-vars` attribute has been deprecated because of XSS vulnerabilities. Recommended to use the `hx-vals` attribute."),r["hx-vars"]=e.vars),e.vals)if(typeof e.vals=="object")try{r["hx-vals"]=`${JSON.stringify(e.vals)}`}catch(t){throw new A("[jhx] Error while parsing 'hx-vals' object",{attribute:"hx-vals",cause:t,stack:t instanceof Error&&typeof t.stack=="string"?t.stack:void 0})}else if(typeof e.vals=="function"){let t=w(e.vals);if(t){let s=`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`;r["hx-vals"]=`js:{...${s}}`}}else r["hx-vals"]=e.vals;return r},"convertJhxAttributes");var ie=a(e=>{let o={};if(!e||typeof e!="object")return o;for(let r in E)if(Object.prototype.hasOwnProperty.call(e,r)){let n=E[r],t=e[r];if(!t)continue;let s=w(t);if(!s)continue;o[n]=`((${s.params.join(",")}) => ${s.body})(${s.params.join(",")})`}return o},"convertJhxEventAttributes");var je={'"':""","<":"<",">":">"},B=a(e=>String(e).replace(/["<>]/g,o=>je[o]??o),"escapeValue");var k=a((e,o=!0)=>Object.entries(e).map(([r,n])=>typeof n=="object"?`${r}="${JSON.stringify(n)}"`:`${r}="${typeof n=="string"&&o?B(n):n}"`).filter(Boolean).join(" "),"attributesToString");var M={logger:console,stringify:!1,escape:!0};var he=a(e=>{let o={};for(let[r,n]of Object.entries(e))o[r]=typeof n=="string"?B(n):n;return o},"escapeAttributes");function U(e,o){let r={...M,...o??{}},n={...ae(e,r),...ie(e),...oe(e)};return r.stringify===!0?k(n,!!r.escape):r.escape===!0?he(n):n}a(U,"jhx");var xe=a((e,o)=>{for(let[r,n]of Object.entries(o))typeof n=="object"?e.setAttribute(r,JSON.stringify(n)):e.setAttribute(r,String(n))},"applyAttributes");var H=class e extends Error{static{a(this,"JhxServerException")}type;info;method;route;cause;constructor(o,r){super(o),this.name="JhxServerError",this.type=r.type,this.info=r.info||r.cause?.message||o,this.method=r.method,this.route=r.route,this.stack=r.stack,this.cause=r.cause,Object.setPrototypeOf(this,e.prototype)}};var de=require("path");var C=a((e,o="")=>{let r=String(o).startsWith("/")?String(o):`/${o}`,n=e.trim();n=n.startsWith("/")?n:`/${n}`;let t;try{t=decodeURIComponent(n.startsWith(r)?n:`${r}/${n}`)}catch(i){throw new H("jhx: malformed endpoint",{type:"endpoint:malformed",info:i.message,route:n,cause:i})}let s=de.posix.normalize(t.startsWith("/")?t:`/${t}`);return s.length>1&&s.endsWith("/")&&(s=s.slice(0,-1)),{noSlash:s,withSlash:s==="/"?"/":`${s}/`}},"normalizeEndpoint");var L=a((e,o,r)=>{if(r||(r=new Map),!e)return r;for(let n of e){let t=n.method?.trim()?.toUpperCase()??"GET",{noSlash:s,withSlash:i}=C(n.route,o.prefix);if(o.trailingSlash==="no-slash"){let T=`${t}::${s}`;if(r.has(T))throw new H("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${s}'`,method:t,route:s});r.set(T,n.handler),o.onRegistered(t,s),o.debug&&o.logger.info(`[jhx] Added new route: ${t} ${s}`)}else if(o.trailingSlash==="slash"){let T=`${t}::${i}`;if(r.has(T))throw new H("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${s}'`,method:t,route:s});r.set(T,n.handler),o.onRegistered(t,i),o.debug&&o.logger.info(`[jhx] Added new route: ${t} ${i}`)}else{let T=`${t}::${s}`,g=`${t}::${i}`;if(r.has(T))throw new H("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${s}'`,method:t,route:s});if(r.has(g))throw new H("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${s}'`,method:t,route:s});r.set(T,n.handler),r.set(g,n.handler),o.onRegistered(t,s),o.debug&&o.logger.info(`[jhx] Added new route: ${t} ${s}`)}}return r},"addRoutesToMap");var W=require("react"),F=require("react-dom/server");var Ae=a((e,...o)=>(0,W.isValidElement)(e)?(0,F.renderToStaticMarkup)(e):e,"jsxToStatic"),$e=a((e,...o)=>(0,W.isValidElement)(e)?(0,F.renderToString)(e):e,"jsxToString"),qe=a((e,...o)=>e,"noRender"),le=a(e=>e?typeof e=="function"?e:e==="static"?Ae:e==="string"?$e:qe:null,"getRenderFunction");var Pe=["get","post","put","patch","delete","route"],ue=a(e=>{for(let o of Pe)if(o in e){let r=e[o];return o==="route"?{method:"GET",route:typeof r=="string"&&r.trim()||null}:{method:o.toUpperCase(),route:typeof r=="string"&&r.trim()||null}}return{method:"GET",route:null}},"getRouteFromProps");var me=require("crypto");var pe=a(e=>{if(typeof e?.toString!="function")throw new H("jhx: invalid route error",{type:"hash:invalid",info:"Cannot hash function without a 'toString' method"});return(0,me.createHash)("sha256").update(e.toString()).digest("hex").slice(0,12)},"hashFunction");var N=a(e=>{let o=[];if(!e)return o;for(let r of Array.isArray(e)?e:[e]){if(r.method&&r.method.trim()==="")throw new H("jhx: route validation error",{type:"route:invalid-method",info:`Invalid route method: '${r.method}'`,method:String(r.method)});if(!r.route||r.route?.trim()==="")throw new H("jhx: route validation error",{type:"route:invalid-path",info:`Invalid route endpoint: '${r.route}'`,method:r.method?.toUpperCase()??"GET",route:String(r.route)});if(!r.handler||typeof r.handler!="function")throw new H("jhx: route validation error",{type:"route:invalid-handler",info:`Invalid route handler for '${r.method?.toUpperCase()??"GET"} ${r.route}'`,method:r.method?.toUpperCase()??"GET",route:r.route});o.push({method:r.method?.toUpperCase()??"GET",route:r.route,handler:r.handler})}return o},"validateRoutes");var De=a(e=>e.startsWith("hx-")||e in j.attr||e in j.eventAttr||e==="route"||e==="method"||e==="handler","isJhxAttribute"),I=a(e=>a(function(r){let{jhxConfig:n,as:t,children:s,...i}=r,T=t??"div",g={};for(let[h,y]of Object.entries(i))De(h)||(g[h]=y);let x={...e(i,{...n,stringify:!1}),...g};return<T{...x}>{s}</T>},"JhxComponent"),"createJhxComponent");var fe=require("react"),ce=require("react-dom/server");var S={...M,contentType:"text/html",debug:!1,middleware:[],onRegistered:a(((e,o)=>{}),"onRegistered"),prefix:"/_jhx",render:a((e,...o)=>(0,fe.isValidElement)(e)?(0,ce.renderToString)(e):e,"render"),renderError:!0,renderMiddleware:!0,renderNotFound:!0,trailingSlash:"both"};var Te=a((e,o,r)=>{let n={contentType:e.contentType===!1?!1:e.contentType??S.contentType,debug:e.debug===S.debug,errorHandler:e.errorHandler,middleware:Array.isArray(e.middleware)?e.middleware:e.middleware?[e.middleware]:S.middleware,notFoundHandler:e.notFoundHandler?e.notFoundHandler:o,onRegistered:e.onRegistered??S.onRegistered,logger:e.logger??S.logger,prefix:e.prefix?C(e.prefix).noSlash:S.prefix,render:typeof e.render=="function"?e.render:le(e.render===void 0?"string":e.render),renderError:typeof e.renderError=="boolean"?e.renderError:S.renderError,renderMiddleware:typeof e.renderMiddleware=="boolean"?e.renderMiddleware:S.renderMiddleware,renderNotFound:typeof e.renderNotFound=="boolean"?e.renderNotFound:S.renderNotFound,stringify:typeof e.stringify=="boolean"?e.stringify:S.stringify,trailingSlash:e.trailingSlash??S.trailingSlash,instanceOptions:e.instanceOptions},t=e.routes?L(N(e.routes),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash}):new Map;r(n,t);function s(i,T){if(typeof i=="object"&&typeof i.handler=="function"){let{method:x,route:h}=ue(i),{noSlash:y,withSlash:b}=C(h||pe(i.handler),n.prefix);if(n.trailingSlash==="no-slash"){let v=`${x}::${y}`;t.has(v)||(n.debug&&n.logger.info(`[jhx] Added new route: ${x} ${y}`),t.set(v,i.handler),n.onRegistered(x,y)),i.method=x,i.route=y}else if(n.trailingSlash==="slash"){let v=`${x}::${b}`;t.has(v)||(n.debug&&n.logger.info(`[jhx] Added new route: ${x} ${b}`),t.set(v,i.handler),n.onRegistered(x,b)),i.method=x,i.route=b}else{let v=`${x}::${y}`,X=`${x}::${b}`;!t.has(v)&&!t.has(X)&&(n.debug&&n.logger.info(`[jhx] Added new route: ${x} ${y}`),t.set(v,i.handler),t.set(X,i.handler),n.onRegistered(x,y)),i.method=x,i.route=y}}let g=T?.stringify??n.stringify,R=i&&typeof i=="object"&&"handler"in i?(({handler:x,...h})=>h)(i):i;return g?U(R,{logger:T?.logger??n.logger,stringify:!0}):U(R,{logger:T?.logger??n.logger,stringify:!1})}return a(s,"jhx"),s.addRoute=i=>{L(N({method:i.method,route:i.route,handler:i.handler}),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},t)},s.addRoutes=i=>{L(N(i),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},t)},s.clearRoutes=()=>{let i=t.size;t.clear(),n.debug&&n.logger.info(`[jhx] Cleared ${i} route${i===1?"":"s"}`)},s.getRoute=(i,T)=>{let g=i.trim().toUpperCase(),{noSlash:R,withSlash:x}=C(T,n.prefix);if(n.trailingSlash==="no-slash"){let h=`${g}::${R}`,y=t.get(h);return y?{method:g,route:R,handler:y}:null}else if(n.trailingSlash==="slash"){let h=t.get(`${g}::${x}`);return h?{method:g,route:x,handler:h}:null}else{let h=t.get(`${g}::${R}`),y=t.get(`${g}::${x}`);if(!h&&!y)return null;let b=T.endsWith("/");return{method:g,route:b?y?x:R:h?R:x,handler:b?y??h:h??y}}},s.getRoutes=()=>Array.from(t.entries()).map(([i,T])=>{let[g,R]=i.split("::");return!g||!R?null:{method:g,route:R,handler:T}}).filter(i=>i!==null),s.hasRoute=(i,T)=>{let{noSlash:g,withSlash:R}=C(T,n.prefix);return t.has(`${i.toUpperCase()}::${g}`)||t.has(`${i.toUpperCase()}::${R}`)},s.removeRoute=(i,T)=>{let g=i.trim().toUpperCase(),{noSlash:R,withSlash:x}=C(T,n.prefix),h;return n.trailingSlash==="no-slash"?h=t.delete(`${g}::${R}`):n.trailingSlash==="slash"?h=t.delete(`${g}::${x}`):(h=t.delete(`${g}::${R}`),h=t.delete(`${g}::${x}`)||h),h&&n.debug?n.logger.info(`[jhx] Removed route: ${g} ${n.trailingSlash==="no-slash"?R:n.trailingSlash==="slash"?x:`${R} / ${x}`}`):!h&&n.debug&&n.logger.info(`[jhx] Cannot remove unknown route: ${g} ${n.trailingSlash==="no-slash"?R:n.trailingSlash==="slash"?x:`${R} / ${x}`}`),h},{jhx:s,JhxComponent:I(s)}},"createServerJhx");var Oe=a(e=>e?.finalized===!0,"isResponseSent"),q=a(e=>Oe(e),"isResponseHandled");var ge=require("node:stream");var Be=a(e=>e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Uint8ClampedArray||e instanceof BigUint64Array||typeof ArrayBuffer<"u"&&ArrayBuffer.isView(e)||typeof Buffer<"u"&&e instanceof Buffer,"isArrayBuffer"),ke=a(e=>e.split("-").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("-"),"capitalize"),D=a((e,o,r)=>{!e.res.headers.get(ke(o))&&!e.res.headers.get(o.toLowerCase())&&e.res.headers.set(o.toLowerCase(),r)},"ensureHeader"),J=a((e,o)=>o instanceof Response?o:o instanceof Blob?(D(e,"content-type",o.type),D(e,"content-length",String(o.size)),e.body(o)):o instanceof FormData?(D(e,"content-type","multipart/form-data"),new Response(o)):o instanceof ReadableStream||o instanceof ge.Stream||Be(o)?(D(e,"content-type","application/octet-stream"),e.body(o)):typeof o=="object"?(D(e,"content-type","application/json"),e.json(o)):e.body(o),"sendPayload");var V={...S,notFoundHandler:a(e=>e.text("",404),"notFoundHandler")};var Me=a((e,o={})=>Te(o,V.notFoundHandler,(r,n)=>{e.all(`${r.prefix}/*`,async t=>{let s=t.req.method,i=decodeURIComponent(t.req.path),T=n.get(`${s}::${i}`);if(r.contentType&&t.header("content-type",r.contentType),T){for(let x of r.middleware)try{let h=await x(t);if(q(t))return J(t,h);if(h!==void 0){let y=r.render&&r.renderMiddleware?await r.render(h,t):h;return J(t,y)}}catch(h){let y=h;if(r.debug&&r.logger.error(`[jhx] Middleware error from '${s} ${i}': ${y.message}`),r.errorHandler){t.status(500);let b=await r.errorHandler(y,t);if(q(t))return J(t,b);let v=r.render&&r.renderError?await r.render(b,t):b;return J(t,v)}throw new H("Unhandled middleware error",{type:"middleware:error",method:s,route:i,cause:y})}try{let x=await T(t);if(q(t))return J(t,x);let h=r.render?await r.render(x,t):x;return J(t,h)}catch(x){let h=x;if(r.debug&&r.logger.error(`[jhx] Route error from '${s} ${i}': ${h.message}`),r.errorHandler){t.status(500);let y=await r.errorHandler(h,t);if(q(t))return J(t,y);let b=r.render&&r.renderError?await r.render(y,t):y;return J(t,b)}throw new H("[jhx] Unhandled endpoint or rendering error",{type:"handler:error",method:s,route:i,cause:h})}}r.debug&&r.logger.info(`[jhx] Request to unknown route '${s} ${i}'`),t.status(404);let g=await r.notFoundHandler(t);if(q(t))return J(t,g);let R=r.render&&r.renderNotFound?await r.render(g,t):g;return J(t,R)})}),"createJhx");function Ue(e){return I(e)}a(Ue,"createJhxComponent");0&&(module.exports={applyAttributes,attributesToString,createJhx,createJhxComponent,defaultConfig,htmx});
|
|
1
|
+
"use strict";var k=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var ve=Object.prototype.hasOwnProperty;var a=(e,o)=>k(e,"name",{value:o,configurable:!0});var Je=(e,o)=>{for(var r in o)k(e,r,{get:o[r],enumerable:!0})},Ee=(e,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of Se(o))!ve.call(e,t)&&t!==r&&k(e,t,{get:()=>o[t],enumerable:!(n=He(o,t))||n.enumerable});return e};var we=e=>Ee(k({},"__esModule",{value:!0}),e);var Ie={};Je(Ie,{applyAttributes:()=>ue,attributesToString:()=>U,createJhx:()=>Ne,createJhxComponent:()=>Fe,defaultConfig:()=>G,htmx:()=>$});module.exports=we(Ie);var C={onAbort:"hx-on--abort",onAfterOnLoad:"hx-on--after-on-load",onAfterProcessNode:"hx-on--after-process-node",onAfterRequest:"hx-on--after-request",onAfterSettle:"hx-on--after-settle",onAfterSwap:"hx-on--after-swap",onBeforeCleanupElement:"hx-on--before-cleanup-element",onBeforeOnLoad:"hx-on--before-on-load",onBeforeProcessNode:"hx-on--before-process-node",onBeforeRequest:"hx-on--before-request",onBeforeSwap:"hx-on--before-swap",onBeforeSend:"hx-on--before-send",onBeforeTransition:"hx-on--before-transition",onConfigRequest:"hx-on--config-request",onConfirm:"hx-on--confirm",onHistoryCacheError:"hx-on--history-cache-error",onHistoryCacheHit:"hx-on--history-cache-hit",onHistoryCacheMiss:"hx-on--history-cache-miss",onHistoryCacheMissLoadError:"hx-on--history-cache-miss-load-error",onHistoryCacheMissLoad:"hx-on--history-cache-miss-load",onHistoryRestore:"hx-on--history-restore",onBeforeHistorySave:"hx-on--before-history-save",onLoad:"hx-on--load",onNoSSESourceError:"hx-on--no-sse-source-error",onOnLoadError:"hx-on--on-load-error",onOobAfterSwap:"hx-on--oob-after-swap",onOobBeforeSwap:"hx-on--oob-before-swap",onOobErrorNoTarget:"hx-on--oob-error-no-target",onPrompt:"hx-on--prompt",onPushedIntoHistory:"hx-on--pushed-into-history",onReplacedInHistory:"hx-on--replaced-in-history",onResponseError:"hx-on--response-error",onSendAbort:"hx-on--send-abort",onSendError:"hx-on--send-error",onSseError:"hx-on--sse-error",onSseOpen:"hx-on--sse-open",onSwapError:"hx-on--swap-error",onTargetError:"hx-on--target-error",onTimeout:"hx-on--timeout",onValidateUrl:"hx-on--validate-url",onValidationValidate:"hx-on--validation-validate",onValidationFailed:"hx-on--validation-failed",onValidationHalted:"hx-on--validation-halted",onXhrAbort:"hx-on--xhr-abort",onXhrLoadend:"hx-on--xhr-loadend",onXhrLoadstart:"hx-on--xhr-loadstart",onXhrProgress:"hx-on--xhr-progress"};var Y={get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch",pushUrl:"hx-push-url",select:"hx-select",selectOob:"hx-select-oob",swap:"hx-swap",swapOob:"hx-swap-oob",target:"hx-target",trigger:"hx-trigger",vals:"hx-vals",boost:"hx-boost",confirm:"hx-confirm",disable:"hx-disable",disabledElt:"hx-disabled-elt",disinherit:"hx-disinherit",encoding:"hx-encoding",ext:"hx-ext",headers:"hx-headers",history:"hx-history",historyElt:"hx-history-elt",include:"hx-include",indicator:"hx-indicator",inherit:"hx-inherit",params:"hx-params",preserve:"hx-preserve",prompt:"hx-prompt",replaceUrl:"hx-replace-url",request:"hx-request",sync:"hx-sync",validate:"hx-validate",vars:"hx-vars",...C};var _={added:"htmx-added",indicator:"htmx-indicator",request:"htmx-request",settling:"htmx-settling",swapping:"htmx-swapping"};var K={addedClass:"hx-added",allowEval:!0,allowNestedOobSwaps:!0,allowScriptTags:!0,attributesToSettle:["class","style","width","height"],defaultFocusScroll:!1,defaultSettleDelay:20,defaultSwapDelay:0,defaultSwapStyle:"innerHTML",disableInheritance:!1,disableSelector:"[hx-disable], [data-hx-disable]",getCacheBusterParam:!1,globalViewTransitions:!1,historyCacheSize:10,historyEnabled:!0,historyRestoreAsHxRequest:!0,ignoreTitle:!1,includeIndicatorStyles:!0,indicatorClass:"hx-indicator",inlineScriptNonce:"",inlineStyleNonce:"",methodsThatUseUrlParams:["get","delete"],refreshOnHistoryMiss:!1,requestClass:"htmx-request",responseHandling:[{code:"204",swap:!1},{code:"[23]..",swap:!0},{code:"[45]..",swap:!1,error:!0}],scrollBehavior:"instant",scrollIntoViewOnBoost:!0,selfRequestsOnly:!0,settlingClass:"htmx-settling",swappingClass:"htmx-swapping",timeout:0,triggerSpecsCache:null,withCredentials:!1,wsBinaryType:"blob",wsReconnectDelay:"full-jitter"};var Q={abort:"htmx:abort",afterOnLoad:"htmx:afterOnLoad",afterProcessNode:"htmx:afterProcessNode",afterRequest:"htmx:afterRequest",afterSettle:"htmx:afterSettle",afterSwap:"htmx:afterSwap",beforeCleanupElement:"htmx:beforeCleanupElement",beforeOnLoad:"htmx:beforeOnLoad",beforeProcessNode:"htmx:beforeProcessNode",beforeRequest:"htmx:beforeRequest",beforeSwap:"htmx:beforeSwap",beforeSend:"htmx:beforeSend",beforeTransition:"htmx:beforeTransition",configRequest:"htmx:configRequest",confirm:"htmx:confirm",historyCacheError:"htmx:historyCacheError",historyCacheHit:"htmx:historyCacheHit",historyCacheMiss:"htmx:historyCacheMiss",historyCacheMissLoadError:"htmx:historyCacheMissLoadError",historyCacheMissLoad:"htmx:historyCacheMissLoad",historyRestore:"htmx:historyRestore",beforeHistorySave:"htmx:beforeHistorySave",load:"htmx:load",noSSESourceError:"htmx:noSSESourceError",onLoadError:"htmx:onLoadError",oobAfterSwap:"htmx:oobAfterSwap",oobBeforeSwap:"htmx:oobBeforeSwap",oobErrorNoTarget:"htmx:oobErrorNoTarget",prompt:"htmx:prompt",pushedIntoHistory:"htmx:pushedIntoHistory",replacedInHistory:"htmx:replacedInHistory",responseError:"htmx:responseError",sendAbort:"htmx:sendAbort",sendError:"htmx:sendError",sseError:"htmx:sseError",sseOpen:"htmx:sseOpen",swapError:"htmx:swapError",targetError:"htmx:targetError",timeout:"htmx:timeout",validateUrl:"htmx:validateUrl",validationValidate:"htmx:validation:validate",validationFailed:"htmx:validation:failed",validationHalted:"htmx:validation:halted",xhrAbort:"htmx:xhr:abort",xhrLoadend:"htmx:xhr:loadend",xhrLoadstart:"htmx:xhr:loadstart",xhrProgress:"htmx:xhr:progress"};var Z={headSupport:{name:"head-support",version:"2.0.5",npm:"htmx-ext-head-support",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-head-support@2.0.5",integrity:"sha384-cvMqHzjCJsOHgGuyB3sWXaUSv/Krm0BdzjuI1rtkjCbL1l1oHJx+cHyVRJhyuEz0"}]},htmx1Compat:{name:"htmx-1-compat",version:"2.0.2",npm:"htmx-ext-htmx-1-compat",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-htmx-1-compat@2.0.2",integrity:"sha384-lcvVWaNjF5zPPUeeWmC0OkJ2MLqoWLlkAabuGm+EuMSTfGo5WRyHrNaAp0cJr9Pg"}]},idiomorph:{name:"morph",version:"0.7.4",npm:"idiomorph",cdn:[{url:"https://unpkg.com/idiomorph@0.7.4/dist/idiomorph-ext.min.js",integrity:"sha384-SsScJKzATF/w6suEEdLbgYGsYFLzeKfOA6PY+/C5ZPxOSuA+ARquqtz/BZz9JWU8"}]},preload:{name:"preload",version:"2.1.2",npm:"htmx-ext-preload",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-preload@2.1.2",integrity:"sha384-PRIcY6hH1Y5784C76/Y8SqLyTanY9rnI3B8F3+hKZFNED55hsEqMJyqWhp95lgfk"}]},responseTargets:{name:"response-targets",version:"2.0.4",npm:"htmx-ext-response-targets",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-response-targets@2.0.4",integrity:"sha384-T41oglUPvXLGBVyRdZsVRxNWnOOqCynaPubjUVjxhsjFTKrFJGEMm3/0KGmNQ+Pg"}]},sse:{name:"sse",version:"2.2.4",npm:"htmx-ext-sse",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-sse@2.2.4",integrity:"sha384-A986SAtodyH8eg8x8irJnYUk7i9inVQqYigD6qZ9evobksGNIXfeFvDwLSHcp31N"}]},ws:{name:"ws",version:"2.0.4",npm:"htmx-ext-ws",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.4",integrity:"sha384-1RwI/nvUSrMRuNj7hX1+27J8XDdCoSLf0EjEyF69nacuWyiJYoQ/j39RT1mSnd2G"}]}};var ee={GET:"hx-get",POST:"hx-post",PUT:"hx-put",DELETE:"hx-delete",PATCH:"hx-patch",get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch"};var re={boosted:"HX-Boosted",currentUrl:"HX-Current-URL",historyRestoreRequest:"HX-History-Restore-Request",prompt:"HX-Prompt",request:"HX-Request",target:"HX-Target",triggerName:"HX-Trigger-Name",trigger:"HX-Trigger"};var te={location:"HX-Location",pushUrl:"HX-Push-URL",redirect:"HX-Redirect",refresh:"HX-Refresh",replaceUrl:"HX-Replace-URL",reswap:"HX-Reswap",retarget:"HX-Retarget",reselect:"HX-Reselect",trigger:"HX-Trigger",triggerAfterSettle:"HX-Trigger-After-Settle",triggerAfterSwap:"HX-Trigger-After-Swap"};var oe={innerHTML:"innerHTML",outerHTML:"outerHTML",textContent:"textContent",beforeBegin:"beforebegin",afterBegin:"afterbegin",beforeEnd:"beforeend",afterEnd:"afterend",delete:"delete",none:"none"};var ne={drop:"drop",abort:"abort",replace:"replace",queue:"queue",queueAll:"queue all",queueFirst:"queue first",queueLast:"queue last"};var $={attr:Y,config:K,css:_,event:Q,eventAttr:C,ext:Z,method:ee,res:te,req:re,swap:oe,sync:ne};var se=a(e=>{let o=[],r=0;for(;r<e.length;){let n=e[r];if(n==="`"){let t=r;for(r++;r<e.length;)if(e[r]==="\\")r+=2;else if(e[r]==="`"){r++;break}else r++;o.push(e.slice(t,r));continue}if(n==='"'){r++;let t=[],i=!1;for(;r<e.length;)if(e[r]==="\\"){let T=e[r+1];t.push(e[r],T??""),r+=2}else if(e[r]==='"'){r++;break}else e[r]==="$"&&e[r+1]==="{"&&(i=!0),t.push(e[r]),r++;let s=t.join("");if(i){o.push("`");for(let T=0;T<s.length;T++)if(s[T]==="\\"){let g=s[T+1];g==='"'?(o.push('"'),T++):g==="`"?(o.push("\\`"),T++):(o.push(s[T],g??""),T++)}else s[T]==="`"?o.push("\\`"):o.push(s[T]);o.push("`")}else{o.push("'");for(let T=0;T<s.length;T++)if(s[T]==="\\"){let g=s[T+1];g==='"'?(o.push('"'),T++):g==="'"?(o.push("\\'"),T++):(o.push(s[T],g??""),T++)}else s[T]==="'"?o.push("\\'"):o.push(s[T]);o.push("'")}continue}if(n==="'"){let t=r;for(r++;r<e.length;)if(e[r]==="\\")r+=2;else if(e[r]==="'"){r++;break}else r++;o.push(e.slice(t,r));continue}if(n==="/"&&r>0){let t=e.slice(0,r).trimEnd().slice(-1);if(["=","(",",","[","!","&","|",":",";","{","}","?"].includes(t)){let s=r;r++;let T=!1;for(;r<e.length;)if(e[r]==="\\")r+=2;else if(e[r]==="[")T=!0,r++;else if(e[r]==="]")T=!1,r++;else if(e[r]==="/"&&!T){for(r++;r<e.length&&/[gimsuy]/.test(e[r]);)r++;break}else r++;o.push(e.slice(s,r));continue}}o.push(n),r++}return o.join("")},"normalizeStringQuotes");var Ce=a(e=>{let o=/^(?:async\s*)?function\*?\s*(?:[A-z0-9]+)?\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)\s*\{((?:[^}{]+|\{(?:[^}{]+|\{[^}{]*})*})*)}$/s,r=e.match(o);if(r&&r[2])return{fnType:"normal",fullMatch:r[0],paramStr:r[1]??"",bodyStr:`{ ${r[2].trim()} }`};let n=/^(?:async\s*)?(?:\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)|([^\s=()]+))\s*=>\s*(.*)$/s,t=e.match(n);if(t&&t[3]){let i=t[3].trim();return{fnType:"arrow",fullMatch:t[0],paramStr:t[1]??"",bodyStr:i.startsWith("{")&&(i.endsWith("}")||i.endsWith("};"))?i:`{ return ${i} }`}}return null},"matchFunctionString"),je=a(e=>{if(!e)return[];let o=[],r=0,n=0,t=0,i=0;for(let s=0;s<e.length;s++){let T=e[s];T==="("?r++:T===")"?r--:T==="{"?n++:T==="}"?n--:T==="["?t++:T==="]"?t--:T===","&&r===0&&n===0&&t===0&&(o.push(e.substring(i,s).trim()),i=s+1)}return o.push(e.substring(i).trim()),o.filter(Boolean)},"splitParams"),j=a(e=>{if(typeof e!="function"||typeof e?.toString!="function")return null;let o=e.toString().replaceAll("void 0","undefined"),r=Ce(o);return r?{params:je(r.paramStr),body:se(r.bodyStr)}:null},"extractFunction");var ie=a(e=>{let o={};if(!e||typeof e!="object")return o;for(let r in e){if(r in C||!r.startsWith("on"))continue;let n=e[r];if(!n)continue;let t=j(n);t&&(o[r.toLowerCase()]=`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`)}return o},"convertDomEventAttributes");var q=class e extends Error{static{a(this,"JhxErrorThrowable")}attribute;constructor(o,r){super(o),this.name="JhxError",this.attribute=r.attribute,r.stack&&(this.stack=r.stack),r.cause&&(this.cause=r.cause),Object.setPrototypeOf(this,e.prototype)}};var ae=a((e,o)=>typeof o=="string"?`${e}:${o}`:"window"in o?`${e}:window:${o.position}`:"selector"in o?`${e}:${o.selector}:${o.position}`:"","processScrollOrShow"),O=a(e=>{if(!e)return;if(typeof e=="string")return e;let o=[];return e.style&&o.push(String(e.style)),e.swap&&o.push(`swap:${e.swap}`),e.settle&&o.push(`settle:${e.settle}`),typeof e.transition=="boolean"&&o.push(`transition:${e.transition}`),e.scroll&&o.push(ae("scroll",e.scroll)),e.show&&o.push(ae("show",e.show)),e.ignoreTitle&&o.push("ignoreTitle:true"),typeof e.focusScroll=="boolean"&&o.push(`focus-scroll:${e.focusScroll}`),o.filter(Boolean).join(" ")},"toJhxSwapAttribute");var P=a(e=>{if(!e)return;let o=Array.isArray(e)?e:[e],r=!1,n=o.map(t=>{if(typeof t!="object")return t;if(t.inherit!==void 0){if(!t.inherit)return;r=!0;return}if(t.position==="this"||t.position==="next"||t.position==="previous")return t.position;let i=[];return typeof t?.position=="string"&&i.push(t.position),typeof t.selector=="string"&&i.push(t.selector),i.join(" ")});return r&&n.unshift("inherit"),n.filter(t=>!!t).join(", ")},"toJhxTargetAttribute");var Ae=a(e=>{if(e){if(typeof e=="object"){if(e.op==="this"||e.op==="document"||e.op==="window")return e.op;if(typeof e.selector=="string"&&typeof e.op=="string")return`${e.op} ${e.selector}`}return String(e)}},"toJhxFromAttribute"),he=a(e=>typeof e=="string"?e:(Array.isArray(e)?e:[e]).map(r=>{if(typeof r=="string")return r;if(typeof r=="object"){let n=`${r.event||""}${r.filter?`[${r.filter}]`:""}`,t=[];return r.once===!0&&t.push("once"),r.changed===!0&&t.push("changed"),r.consume===!0&&t.push("consume"),r.delay&&t.push(`delay:${r.delay}`),r.from&&t.push(`from:${Ae(r.from)}`),r.target&&t.push(`target:${P(r.target)}`),r.throttle&&t.push(`throttle:${r.throttle}`),r.queue&&t.push(`queue:${r.queue}`),n.concat(n?" ":"",t.join(" "))}return""}).filter(Boolean).join(", "),"toJhxTriggerAttribute");var $e=["get","post","put","patch","delete","route"],xe=a((e,o)=>{let r={};if(!e||typeof e!="object")return r;let n=$e.find(t=>!!e[t]);if(n)if(n==="route"){let t=e.method?.toLowerCase()||"get";r[`hx-${t}`]=String(e.route)}else r[`hx-${n}`]=String(e[n]);else e.method&&o.logger.warn("[jhx] The 'method' prop must be paired with a 'route' prop to generate a request attribute.");if(e.boost===!0&&(r["hx-boost"]="true"),e.confirm&&(r["hx-confirm"]=e.confirm),e.disable===!0&&(r["hx-disable"]="true"),e.disabledElt){let t=P(e.disabledElt);t&&(r["hx-disabled-elt"]=t)}if(e.disinherit&&(Array.isArray(e.disinherit)?r["hx-disinherit"]=e.disinherit.join(" "):r["hx-disinherit"]=e.disinherit),e.encoding&&(r["hx-encoding"]=e.encoding),e.ext){typeof e.ext=="string"&&(r["hx-ext"]=e.ext);let i=(Array.isArray(e.ext)?e.ext:[e.ext]).map(s=>typeof s=="object"?`${s?.name&&s.ignore===!0?"ignore:":""}${s?.name}`:s).filter(Boolean).join(",");i&&(r["hx-ext"]=i)}if(e.headers)if(typeof e.headers=="object")try{r["hx-headers"]=`${JSON.stringify(e.headers)}`}catch(t){throw o.logger.error("[jhx] Error while parsing the `hx-headers` object."),new q("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-headers",cause:t,stack:t instanceof Error&&typeof t.stack=="string"?t.stack:void 0})}else if(typeof e.headers=="function"){let t=j(e.headers);if(t){let i=`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`;r["hx-vals"]=`js:{...${i}}`}}else r["hx-headers"]=e.headers;if(e.history===!1&&(r["hx-history"]="false"),e.historyElt===!0&&(r["hx-history-elt"]="true"),e.indicator)if(typeof e.indicator=="object"){let t=e.indicator.inherit===!0?"inherit, ":"",i=e.indicator.closest===!0?"closest ":"";r["hx-indicator"]=`${t}${i}${e.indicator.selector}`}else r["hx-indicator"]=e.indicator;if(e.include){let t=P(e.include);t&&(r["hx-include"]=t)}if(e.inherit&&(Array.isArray(e.inherit)?r["hx-inherit"]=e.inherit.join(" "):r["hx-inherit"]=e.inherit),e.params&&(typeof e.params=="object"?e.params.include&&Array.isArray(e.params.include)?r["hx-params"]=`${e.params.include.join(",")}`:e.params.exclude&&Array.isArray(e.params.exclude)&&(r["hx-params"]=`not ${e.params.exclude.join(",")}`):r["hx-params"]=e.params),e.preserve===!0&&(r["hx-preserve"]="true"),e.prompt&&(r["hx-prompt"]=e.prompt),e.pushUrl&&(e.pushUrl===!0?r["hx-push-url"]="true":r["hx-push-url"]=e.pushUrl),(e.replaceUrl||e.replaceUrl===!1)&&(typeof e.replaceUrl=="boolean"?r["hx-replace-url"]=e.replaceUrl?"true":"false":r["hx-replace-url"]=e.replaceUrl),e.request)if(typeof e.request=="object")try{r["hx-request"]=`${JSON.stringify(e.request)}`}catch(t){throw new q("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-request",cause:t,stack:t instanceof Error&&typeof t.stack=="string"?t.stack:void 0})}else if(typeof e.request=="function"){let t=j(e.request);if(t){let s=`(({ timeout, credentials, noHeaders }) => ({ timeout, credentials, noHeaders }))(${`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`})`;r["hx-request"]=`js: ${s}`}}else r["hx-request"]=e.request;if(e.select&&(r["hx-select"]=e.select),e.selectOob)if(Array.isArray(e.selectOob))r["hx-select-oob"]=e.selectOob.map(t=>{if(typeof t=="string")return t;if(typeof t=="object"&&t.selector){let i=O(t.swap);return`${t.selector}${i?":"+i:""}`}return""}).filter(Boolean).join(",");else if(typeof e.selectOob=="object"){let t=O(e.selectOob.swap);r["hx-select-oob"]=`${e.selectOob.selector}${t?":"+t:""}`}else r["hx-select-oob"]=e.selectOob;if(e.swap){let t=O(e.swap);t&&(r["hx-swap"]=t)}if(e.swapOob)if(e.swapOob===!0)r["hx-swap-oob"]="true";else if(typeof e.swapOob=="object"){let t=O(e.swapOob.swap);t&&(r["hx-swap-oob"]=`${t}${e.swapOob.selector?":"+e.swapOob.selector:""}`)}else r["hx-swap-oob"]=e.swapOob;if(e.sync&&(typeof e.sync=="object"?e.sync.strategy&&e.sync.tag?r["hx-sync"]=`${e.sync.closest===!0?"closest ":""}${e.sync.tag}:${e.sync.strategy}`:e.sync.strategy&&(r["hx-sync"]=`this:${e.sync.strategy}`):r["hx-sync"]=e.sync),e.target){let t=P(e.target);t&&(r["hx-target"]=t)}if(e.trigger&&(r["hx-trigger"]=he(e.trigger)),e.validate===!0&&(r["hx-validate"]="true"),e.vars&&(o.logger.warn("[jhx] The `hx-vars` attribute has been deprecated because of XSS vulnerabilities. Recommended to use the `hx-vals` attribute."),r["hx-vars"]=e.vars),e.vals)if(typeof e.vals=="object")try{r["hx-vals"]=`${JSON.stringify(e.vals)}`}catch(t){throw new q("[jhx] Error while parsing 'hx-vals' object",{attribute:"hx-vals",cause:t,stack:t instanceof Error&&typeof t.stack=="string"?t.stack:void 0})}else if(typeof e.vals=="function"){let t=j(e.vals);if(t){let i=`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`;r["hx-vals"]=`js:{...${i}}`}}else r["hx-vals"]=e.vals;return r},"convertJhxAttributes");var le=a(e=>{let o={};if(!e||typeof e!="object")return o;for(let r in C)if(Object.prototype.hasOwnProperty.call(e,r)){let n=C[r],t=e[r];if(!t)continue;let i=j(t);if(!i)continue;o[n]=`((${i.params.join(",")}) => ${i.body})(${i.params.join(",")})`}return o},"convertJhxEventAttributes");var qe={'"':""","<":"<",">":">"},M=a(e=>String(e).replace(/["<>]/g,o=>qe[o]??o),"escapeValue");var U=a((e,o=!0)=>Object.entries(e).map(([r,n])=>typeof n=="object"?`${r}="${JSON.stringify(n)}"`:`${r}="${typeof n=="string"&&o?M(n):n}"`).filter(Boolean).join(" "),"attributesToString");var L={logger:console,stringify:!1,escape:!0};var de=a(e=>{let o={};for(let[r,n]of Object.entries(e))o[r]=typeof n=="string"?M(n):n;return o},"escapeAttributes");function N(e,o){let r={...L,...o??{}},n={...xe(e,r),...le(e),...ie(e)};return r.stringify===!0?U(n,!!r.escape):r.escape===!0?de(n):n}a(N,"jhx");var ue=a((e,o)=>{for(let[r,n]of Object.entries(o))typeof n=="object"?e.setAttribute(r,JSON.stringify(n)):e.setAttribute(r,String(n))},"applyAttributes");var S=class e extends Error{static{a(this,"JhxServerException")}type;info;method;route;cause;constructor(o,r){super(o),this.name="JhxServerError",this.type=r.type,this.info=r.info||r.cause?.message||o,this.method=r.method,this.route=r.route,this.stack=r.stack,this.cause=r.cause,Object.setPrototypeOf(this,e.prototype)}};var pe=require("path");var A=a((e,o="")=>{let r=String(o).startsWith("/")?String(o):`/${o}`,n=e.trim();n=n.startsWith("/")?n:`/${n}`;let t;try{t=decodeURIComponent(n.startsWith(r)?n:`${r}/${n}`)}catch(s){throw new S("jhx: malformed endpoint",{type:"endpoint:malformed",info:s.message,route:n,cause:s})}let i=pe.posix.normalize(t.startsWith("/")?t:`/${t}`);return i.length>1&&i.endsWith("/")&&(i=i.slice(0,-1)),{noSlash:i,withSlash:i==="/"?"/":`${i}/`}},"normalizeEndpoint");var F=a((e,o,r)=>{if(r||(r=new Map),!e)return r;for(let n of e){let t=n.method?.trim()?.toUpperCase()??"GET",{noSlash:i,withSlash:s}=A(n.route,o.prefix);if(o.trailingSlash==="no-slash"){let T=`${t}::${i}`;if(r.has(T))throw new S("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${i}'`,method:t,route:i});r.set(T,n.handler),o.onRegistered(t,i),o.debug&&o.logger.info(`[jhx] Added new route: ${t} ${i}`)}else if(o.trailingSlash==="slash"){let T=`${t}::${s}`;if(r.has(T))throw new S("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${i}'`,method:t,route:i});r.set(T,n.handler),o.onRegistered(t,s),o.debug&&o.logger.info(`[jhx] Added new route: ${t} ${s}`)}else{let T=`${t}::${i}`,g=`${t}::${s}`;if(r.has(T))throw new S("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${i}'`,method:t,route:i});if(r.has(g))throw new S("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${i}'`,method:t,route:i});r.set(T,n.handler),r.set(g,n.handler),o.onRegistered(t,i),o.debug&&o.logger.info(`[jhx] Added new route: ${t} ${i}`)}}return r},"addRoutesToMap");var z=require("react"),I=require("react-dom/server");var Pe=a((e,...o)=>(0,z.isValidElement)(e)?(0,I.renderToStaticMarkup)(e):e,"jsxToStatic"),De=a((e,...o)=>(0,z.isValidElement)(e)?(0,I.renderToString)(e):e,"jsxToString"),Oe=a((e,...o)=>e,"noRender"),fe=a(e=>e?typeof e=="function"?e:e==="static"?Pe:e==="string"?De:Oe:null,"getRenderFunction");var Be=["get","post","put","patch","delete","route"],me=a(e=>{for(let o of Be)if(o in e){let r=e[o];return o==="route"?{method:"GET",route:typeof r=="string"&&r.trim()||null}:{method:o.toUpperCase(),route:typeof r=="string"&&r.trim()||null}}return{method:"GET",route:null}},"getRouteFromProps");var ce=require("crypto");var Te=a(e=>{if(typeof e?.toString!="function")throw new S("jhx: invalid route error",{type:"hash:invalid",info:"Cannot hash function without a 'toString' method"});return(0,ce.createHash)("sha256").update(e.toString()).digest("hex").slice(0,12)},"hashFunction");var X=a(e=>{let o=[];if(!e)return o;for(let r of Array.isArray(e)?e:[e]){if(r.method&&r.method.trim()==="")throw new S("jhx: route validation error",{type:"route:invalid-method",info:`Invalid route method: '${r.method}'`,method:String(r.method)});if(!r.route||r.route?.trim()==="")throw new S("jhx: route validation error",{type:"route:invalid-path",info:`Invalid route endpoint: '${r.route}'`,method:r.method?.toUpperCase()??"GET",route:String(r.route)});if(!r.handler||typeof r.handler!="function")throw new S("jhx: route validation error",{type:"route:invalid-handler",info:`Invalid route handler for '${r.method?.toUpperCase()??"GET"} ${r.route}'`,method:r.method?.toUpperCase()??"GET",route:r.route});o.push({method:r.method?.toUpperCase()??"GET",route:r.route,handler:r.handler})}return o},"validateRoutes");var ke=a(e=>e.startsWith("hx-")||e in $.attr||e in $.eventAttr||e==="route"||e==="method"||e==="handler","isJhxAttribute"),W=a(e=>a(function(r){let{jhxConfig:n,as:t,children:i,...s}=r,T=t??"div",g={};for(let[y,b]of Object.entries(s))ke(y)||(g[y]=b);let R={...e(s,{...n,stringify:!1}),...g};return<T{...R}>{i}</T>},"JhxComponent"),"createJhxComponent");var ge=require("react"),ye=require("react-dom/server");var J={...L,contentType:"text/html",debug:!1,middleware:[],onRegistered:a(((e,o)=>{}),"onRegistered"),prefix:"/_jhx",render:a((e,...o)=>(0,ge.isValidElement)(e)?(0,ye.renderToString)(e):e,"render"),renderError:!0,renderMiddleware:!0,renderNotFound:!0,trailingSlash:"both"};var Re=a((e,o,r)=>{let n={contentType:e.contentType===!1?!1:e.contentType??J.contentType,debug:e.debug===J.debug,errorHandler:e.errorHandler,middleware:Array.isArray(e.middleware)?e.middleware:e.middleware?[e.middleware]:J.middleware,notFoundHandler:e.notFoundHandler?e.notFoundHandler:o,onRegistered:e.onRegistered??J.onRegistered,logger:e.logger??J.logger,prefix:e.prefix?A(e.prefix).noSlash:J.prefix,render:typeof e.render=="function"?e.render:fe(e.render===void 0?"string":e.render),renderError:typeof e.renderError=="boolean"?e.renderError:J.renderError,renderMiddleware:typeof e.renderMiddleware=="boolean"?e.renderMiddleware:J.renderMiddleware,renderNotFound:typeof e.renderNotFound=="boolean"?e.renderNotFound:J.renderNotFound,stringify:typeof e.stringify=="boolean"?e.stringify:J.stringify,trailingSlash:e.trailingSlash??J.trailingSlash,instanceOptions:e.instanceOptions},t=e.routes?F(X(e.routes),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash}):new Map;r(n,t);function i(s,T){if(typeof s=="object"&&typeof s.handler=="function"){let{method:R,route:y}=me(s),{noSlash:b,withSlash:v}=A(y||Te(s.handler),n.prefix);if(n.trailingSlash==="no-slash"){let E=`${R}::${b}`;t.has(E)||(n.debug&&n.logger.info(`[jhx] Added new route: ${R} ${b}`),t.set(E,s.handler),n.onRegistered(R,b)),s.method=R,s.route=b}else if(n.trailingSlash==="slash"){let E=`${R}::${v}`;t.has(E)||(n.debug&&n.logger.info(`[jhx] Added new route: ${R} ${v}`),t.set(E,s.handler),n.onRegistered(R,v)),s.method=R,s.route=v}else{let E=`${R}::${b}`,V=`${R}::${v}`;!t.has(E)&&!t.has(V)&&(n.debug&&n.logger.info(`[jhx] Added new route: ${R} ${b}`),t.set(E,s.handler),t.set(V,s.handler),n.onRegistered(R,b)),s.method=R,s.route=b}}let g=T?.stringify??n.stringify,H=s&&typeof s=="object"&&"handler"in s?(({handler:R,...y})=>y)(s):s;return g?N(H,{logger:T?.logger??n.logger,stringify:!0}):N(H,{logger:T?.logger??n.logger,stringify:!1})}return a(i,"jhx"),i.addRoute=s=>{F(X({method:s.method,route:s.route,handler:s.handler}),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},t)},i.addRoutes=s=>{F(X(s),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},t)},i.clearRoutes=()=>{let s=t.size;t.clear(),n.debug&&n.logger.info(`[jhx] Cleared ${s} route${s===1?"":"s"}`)},i.getRoute=(s,T)=>{let g=s.trim().toUpperCase(),{noSlash:H,withSlash:R}=A(T,n.prefix);if(n.trailingSlash==="no-slash"){let y=`${g}::${H}`,b=t.get(y);return b?{method:g,route:H,handler:b}:null}else if(n.trailingSlash==="slash"){let y=t.get(`${g}::${R}`);return y?{method:g,route:R,handler:y}:null}else{let y=t.get(`${g}::${H}`),b=t.get(`${g}::${R}`);if(!y&&!b)return null;let v=T.endsWith("/");return{method:g,route:v?b?R:H:y?H:R,handler:v?b??y:y??b}}},i.getRoutes=()=>Array.from(t.entries()).map(([s,T])=>{let[g,H]=s.split("::");return!g||!H?null:{method:g,route:H,handler:T}}).filter(s=>s!==null),i.hasRoute=(s,T)=>{let{noSlash:g,withSlash:H}=A(T,n.prefix);return t.has(`${s.toUpperCase()}::${g}`)||t.has(`${s.toUpperCase()}::${H}`)},i.removeRoute=(s,T)=>{let g=s.trim().toUpperCase(),{noSlash:H,withSlash:R}=A(T,n.prefix),y;return n.trailingSlash==="no-slash"?y=t.delete(`${g}::${H}`):n.trailingSlash==="slash"?y=t.delete(`${g}::${R}`):(y=t.delete(`${g}::${H}`),y=t.delete(`${g}::${R}`)||y),y&&n.debug?n.logger.info(`[jhx] Removed route: ${g} ${n.trailingSlash==="no-slash"?H:n.trailingSlash==="slash"?R:`${H} / ${R}`}`):!y&&n.debug&&n.logger.info(`[jhx] Cannot remove unknown route: ${g} ${n.trailingSlash==="no-slash"?H:n.trailingSlash==="slash"?R:`${H} / ${R}`}`),y},{jhx:i,JhxComponent:W(i)}},"createServerJhx");var Me=a(e=>e?.finalized===!0,"isResponseSent"),D=a(e=>Me(e),"isResponseHandled");var be=require("node:stream");var Ue=a(e=>e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Uint8ClampedArray||e instanceof BigUint64Array||typeof ArrayBuffer<"u"&&ArrayBuffer.isView(e)||typeof Buffer<"u"&&e instanceof Buffer,"isArrayBuffer"),Le=a(e=>e.split("-").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("-"),"capitalize"),B=a((e,o,r)=>{!e.res.headers.get(Le(o))&&!e.res.headers.get(o.toLowerCase())&&e.res.headers.set(o.toLowerCase(),r)},"ensureHeader"),w=a((e,o)=>o instanceof Response?o:o instanceof Blob?(B(e,"content-type",o.type),B(e,"content-length",String(o.size)),e.body(o)):o instanceof FormData?(B(e,"content-type","multipart/form-data"),new Response(o)):o instanceof ReadableStream||o instanceof be.Stream||Ue(o)?(B(e,"content-type","application/octet-stream"),e.body(o)):typeof o=="object"?(B(e,"content-type","application/json"),e.json(o)):e.body(o),"sendPayload");var G={...J,notFoundHandler:a(e=>e.text("",404),"notFoundHandler")};var Ne=a((e,o={})=>Re(o,G.notFoundHandler,(r,n)=>{e.all(`${r.prefix}/*`,async t=>{let i=t.req.method,s=decodeURIComponent(t.req.path),T=n.get(`${i}::${s}`);if(r.contentType&&t.header("content-type",r.contentType),T){for(let R of r.middleware)try{let y=await R(t);if(D(t))return w(t,y);if(y!==void 0){let b=r.render&&r.renderMiddleware?await r.render(y,t):y;return w(t,b)}}catch(y){let b=y;if(r.debug&&r.logger.error(`[jhx] Middleware error from '${i} ${s}': ${b.message}`),r.errorHandler){t.status(500);let v=await r.errorHandler(b,t);if(D(t))return w(t,v);let E=r.render&&r.renderError?await r.render(v,t):v;return w(t,E)}throw new S("Unhandled middleware error",{type:"middleware:error",method:i,route:s,cause:b})}try{let R=await T(t);if(D(t))return w(t,R);let y=r.render?await r.render(R,t):R;return w(t,y)}catch(R){let y=R;if(r.debug&&r.logger.error(`[jhx] Route error from '${i} ${s}': ${y.message}`),r.errorHandler){t.status(500);let b=await r.errorHandler(y,t);if(D(t))return w(t,b);let v=r.render&&r.renderError?await r.render(b,t):b;return w(t,v)}throw new S("[jhx] Unhandled endpoint or rendering error",{type:"handler:error",method:i,route:s,cause:y})}}r.debug&&r.logger.info(`[jhx] Request to unknown route '${i} ${s}'`),t.status(404);let g=await r.notFoundHandler(t);if(D(t))return w(t,g);let H=r.render&&r.renderNotFound?await r.render(g,t):g;return w(t,H)})}),"createJhx");function Fe(e){return W(e)}a(Fe,"createJhxComponent");0&&(module.exports={applyAttributes,attributesToString,createJhx,createJhxComponent,defaultConfig,htmx});
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var le=Object.defineProperty;var a=(e,o)=>le(e,"name",{value:o,configurable:!0});var E={onAbort:"hx-on--abort",onAfterOnLoad:"hx-on--after-on-load",onAfterProcessNode:"hx-on--after-process-node",onAfterRequest:"hx-on--after-request",onAfterSettle:"hx-on--after-settle",onAfterSwap:"hx-on--after-swap",onBeforeCleanupElement:"hx-on--before-cleanup-element",onBeforeOnLoad:"hx-on--before-on-load",onBeforeProcessNode:"hx-on--before-process-node",onBeforeRequest:"hx-on--before-request",onBeforeSwap:"hx-on--before-swap",onBeforeSend:"hx-on--before-send",onBeforeTransition:"hx-on--before-transition",onConfigRequest:"hx-on--config-request",onConfirm:"hx-on--confirm",onHistoryCacheError:"hx-on--history-cache-error",onHistoryCacheHit:"hx-on--history-cache-hit",onHistoryCacheMiss:"hx-on--history-cache-miss",onHistoryCacheMissLoadError:"hx-on--history-cache-miss-load-error",onHistoryCacheMissLoad:"hx-on--history-cache-miss-load",onHistoryRestore:"hx-on--history-restore",onBeforeHistorySave:"hx-on--before-history-save",onLoad:"hx-on--load",onNoSSESourceError:"hx-on--no-sse-source-error",onOnLoadError:"hx-on--on-load-error",onOobAfterSwap:"hx-on--oob-after-swap",onOobBeforeSwap:"hx-on--oob-before-swap",onOobErrorNoTarget:"hx-on--oob-error-no-target",onPrompt:"hx-on--prompt",onPushedIntoHistory:"hx-on--pushed-into-history",onReplacedInHistory:"hx-on--replaced-in-history",onResponseError:"hx-on--response-error",onSendAbort:"hx-on--send-abort",onSendError:"hx-on--send-error",onSseError:"hx-on--sse-error",onSseOpen:"hx-on--sse-open",onSwapError:"hx-on--swap-error",onTargetError:"hx-on--target-error",onTimeout:"hx-on--timeout",onValidateUrl:"hx-on--validate-url",onValidationValidate:"hx-on--validation-validate",onValidationFailed:"hx-on--validation-failed",onValidationHalted:"hx-on--validation-halted",onXhrAbort:"hx-on--xhr-abort",onXhrLoadend:"hx-on--xhr-loadend",onXhrLoadstart:"hx-on--xhr-loadstart",onXhrProgress:"hx-on--xhr-progress"};var I={get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch",pushUrl:"hx-push-url",select:"hx-select",selectOob:"hx-select-oob",swap:"hx-swap",swapOob:"hx-swap-oob",target:"hx-target",trigger:"hx-trigger",vals:"hx-vals",boost:"hx-boost",confirm:"hx-confirm",disable:"hx-disable",disabledElt:"hx-disabled-elt",disinherit:"hx-disinherit",encoding:"hx-encoding",ext:"hx-ext",headers:"hx-headers",history:"hx-history",historyElt:"hx-history-elt",include:"hx-include",indicator:"hx-indicator",inherit:"hx-inherit",params:"hx-params",preserve:"hx-preserve",prompt:"hx-prompt",replaceUrl:"hx-replace-url",request:"hx-request",sync:"hx-sync",validate:"hx-validate",vars:"hx-vars",...E};var X={added:"htmx-added",indicator:"htmx-indicator",request:"htmx-request",settling:"htmx-settling",swapping:"htmx-swapping"};var W={addedClass:"hx-added",allowEval:!0,allowNestedOobSwaps:!0,allowScriptTags:!0,attributesToSettle:["class","style","width","height"],defaultFocusScroll:!1,defaultSettleDelay:20,defaultSwapDelay:0,defaultSwapStyle:"innerHTML",disableInheritance:!1,disableSelector:"[hx-disable], [data-hx-disable]",getCacheBusterParam:!1,globalViewTransitions:!1,historyCacheSize:10,historyEnabled:!0,historyRestoreAsHxRequest:!0,ignoreTitle:!1,includeIndicatorStyles:!0,indicatorClass:"hx-indicator",inlineScriptNonce:"",inlineStyleNonce:"",methodsThatUseUrlParams:["get","delete"],refreshOnHistoryMiss:!1,requestClass:"htmx-request",responseHandling:[{code:"204",swap:!1},{code:"[23]..",swap:!0},{code:"[45]..",swap:!1,error:!0}],scrollBehavior:"instant",scrollIntoViewOnBoost:!0,selfRequestsOnly:!0,settlingClass:"htmx-settling",swappingClass:"htmx-swapping",timeout:0,triggerSpecsCache:null,withCredentials:!1,wsBinaryType:"blob",wsReconnectDelay:"full-jitter"};var V={abort:"htmx:abort",afterOnLoad:"htmx:afterOnLoad",afterProcessNode:"htmx:afterProcessNode",afterRequest:"htmx:afterRequest",afterSettle:"htmx:afterSettle",afterSwap:"htmx:afterSwap",beforeCleanupElement:"htmx:beforeCleanupElement",beforeOnLoad:"htmx:beforeOnLoad",beforeProcessNode:"htmx:beforeProcessNode",beforeRequest:"htmx:beforeRequest",beforeSwap:"htmx:beforeSwap",beforeSend:"htmx:beforeSend",beforeTransition:"htmx:beforeTransition",configRequest:"htmx:configRequest",confirm:"htmx:confirm",historyCacheError:"htmx:historyCacheError",historyCacheHit:"htmx:historyCacheHit",historyCacheMiss:"htmx:historyCacheMiss",historyCacheMissLoadError:"htmx:historyCacheMissLoadError",historyCacheMissLoad:"htmx:historyCacheMissLoad",historyRestore:"htmx:historyRestore",beforeHistorySave:"htmx:beforeHistorySave",load:"htmx:load",noSSESourceError:"htmx:noSSESourceError",onLoadError:"htmx:onLoadError",oobAfterSwap:"htmx:oobAfterSwap",oobBeforeSwap:"htmx:oobBeforeSwap",oobErrorNoTarget:"htmx:oobErrorNoTarget",prompt:"htmx:prompt",pushedIntoHistory:"htmx:pushedIntoHistory",replacedInHistory:"htmx:replacedInHistory",responseError:"htmx:responseError",sendAbort:"htmx:sendAbort",sendError:"htmx:sendError",sseError:"htmx:sseError",sseOpen:"htmx:sseOpen",swapError:"htmx:swapError",targetError:"htmx:targetError",timeout:"htmx:timeout",validateUrl:"htmx:validateUrl",validationValidate:"htmx:validation:validate",validationFailed:"htmx:validation:failed",validationHalted:"htmx:validation:halted",xhrAbort:"htmx:xhr:abort",xhrLoadend:"htmx:xhr:loadend",xhrLoadstart:"htmx:xhr:loadstart",xhrProgress:"htmx:xhr:progress"};var z={headSupport:{name:"head-support",version:"2.0.5",npm:"htmx-ext-head-support",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-head-support@2.0.5",integrity:"sha384-cvMqHzjCJsOHgGuyB3sWXaUSv/Krm0BdzjuI1rtkjCbL1l1oHJx+cHyVRJhyuEz0"}]},htmx1Compat:{name:"htmx-1-compat",version:"2.0.2",npm:"htmx-ext-htmx-1-compat",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-htmx-1-compat@2.0.2",integrity:"sha384-lcvVWaNjF5zPPUeeWmC0OkJ2MLqoWLlkAabuGm+EuMSTfGo5WRyHrNaAp0cJr9Pg"}]},idiomorph:{name:"morph",version:"0.7.4",npm:"idiomorph",cdn:[{url:"https://unpkg.com/idiomorph@0.7.4/dist/idiomorph-ext.min.js",integrity:"sha384-SsScJKzATF/w6suEEdLbgYGsYFLzeKfOA6PY+/C5ZPxOSuA+ARquqtz/BZz9JWU8"}]},preload:{name:"preload",version:"2.1.2",npm:"htmx-ext-preload",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-preload@2.1.2",integrity:"sha384-PRIcY6hH1Y5784C76/Y8SqLyTanY9rnI3B8F3+hKZFNED55hsEqMJyqWhp95lgfk"}]},responseTargets:{name:"response-targets",version:"2.0.4",npm:"htmx-ext-response-targets",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-response-targets@2.0.4",integrity:"sha384-T41oglUPvXLGBVyRdZsVRxNWnOOqCynaPubjUVjxhsjFTKrFJGEMm3/0KGmNQ+Pg"}]},sse:{name:"sse",version:"2.2.4",npm:"htmx-ext-sse",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-sse@2.2.4",integrity:"sha384-A986SAtodyH8eg8x8irJnYUk7i9inVQqYigD6qZ9evobksGNIXfeFvDwLSHcp31N"}]},ws:{name:"ws",version:"2.0.4",npm:"htmx-ext-ws",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.4",integrity:"sha384-1RwI/nvUSrMRuNj7hX1+27J8XDdCoSLf0EjEyF69nacuWyiJYoQ/j39RT1mSnd2G"}]}};var G={GET:"hx-get",POST:"hx-post",PUT:"hx-put",DELETE:"hx-delete",PATCH:"hx-patch",get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch"};var Y={boosted:"HX-Boosted",currentUrl:"HX-Current-URL",historyRestoreRequest:"HX-History-Restore-Request",prompt:"HX-Prompt",request:"HX-Request",target:"HX-Target",triggerName:"HX-Trigger-Name",trigger:"HX-Trigger"};var _={location:"HX-Location",pushUrl:"HX-Push-URL",redirect:"HX-Redirect",refresh:"HX-Refresh",replaceUrl:"HX-Replace-URL",reswap:"HX-Reswap",retarget:"HX-Retarget",reselect:"HX-Reselect",trigger:"HX-Trigger",triggerAfterSettle:"HX-Trigger-After-Settle",triggerAfterSwap:"HX-Trigger-After-Swap"};var K={innerHTML:"innerHTML",outerHTML:"outerHTML",textContent:"textContent",beforeBegin:"beforebegin",afterBegin:"afterbegin",beforeEnd:"beforeend",afterEnd:"afterend",delete:"delete",none:"none"};var Z={drop:"drop",abort:"abort",replace:"replace",queue:"queue",queueAll:"queue all",queueFirst:"queue first",queueLast:"queue last"};var q={attr:I,config:W,css:X,event:V,eventAttr:E,ext:z,method:G,res:_,req:Y,swap:K,sync:Z};var ue=a(e=>{let o=/^(?:async\s*)?function\*?\s*(?:[A-z0-9]+)?\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)\s*\{((?:[^}{]+|\{(?:[^}{]+|\{[^}{]*})*})*)}$/s,r=e.match(o);if(r&&r[2])return{fnType:"normal",fullMatch:r[0],paramStr:r[1]??"",bodyStr:`{ ${r[2].trim()} }`};let n=/^(?:async\s*)?(?:\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)|([^\s=()]+))\s*=>\s*(.*)$/s,t=e.match(n);if(t&&t[3]){let s=t[3].trim();return{fnType:"arrow",fullMatch:t[0],paramStr:t[1]??"",bodyStr:s.startsWith("{")&&(s.endsWith("}")||s.endsWith("};"))?s:`{ return ${s} }`}}return null},"matchFunctionString"),me=a(e=>{if(!e)return[];let o=[],r=0,n=0,t=0,s=0;for(let i=0;i<e.length;i++){let T=e[i];T==="("?r++:T===")"?r--:T==="{"?n++:T==="}"?n--:T==="["?t++:T==="]"?t--:T===","&&r===0&&n===0&&t===0&&(o.push(e.substring(s,i).trim()),s=i+1)}return o.push(e.substring(s).trim()),o.filter(Boolean)},"splitParams"),w=a(e=>{if(typeof e!="function"||typeof e?.toString!="function")return null;let o=e.toString(),r=ue(o);return r?{params:me(r.paramStr),body:r.bodyStr}:null},"extractFunction");var Q=a(e=>{let o={};if(!e||typeof e!="object")return o;for(let r in e){if(r in E||!r.startsWith("on"))continue;let n=e[r];if(!n)continue;let t=w(n);t&&(o[r.toLowerCase()]=`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`)}return o},"convertDomEventAttributes");var j=class e extends Error{static{a(this,"JhxErrorThrowable")}attribute;constructor(o,r){super(o),this.name="JhxError",this.attribute=r.attribute,r.stack&&(this.stack=r.stack),r.cause&&(this.cause=r.cause),Object.setPrototypeOf(this,e.prototype)}};var ee=a((e,o)=>typeof o=="string"?`${e}:${o}`:"window"in o?`${e}:window:${o.position}`:"selector"in o?`${e}:${o.selector}:${o.position}`:"","processScrollOrShow"),P=a(e=>{if(!e)return;if(typeof e=="string")return e;let o=[];return e.style&&o.push(String(e.style)),e.swap&&o.push(`swap:${e.swap}`),e.settle&&o.push(`settle:${e.settle}`),typeof e.transition=="boolean"&&o.push(`transition:${e.transition}`),e.scroll&&o.push(ee("scroll",e.scroll)),e.show&&o.push(ee("show",e.show)),e.ignoreTitle&&o.push("ignoreTitle:true"),typeof e.focusScroll=="boolean"&&o.push(`focus-scroll:${e.focusScroll}`),o.filter(Boolean).join(" ")},"toJhxSwapAttribute");var A=a(e=>{if(!e)return;let o=Array.isArray(e)?e:[e],r=!1,n=o.map(t=>{if(typeof t!="object")return t;if(t.inherit!==void 0){if(!t.inherit)return;r=!0;return}if(t.position==="this"||t.position==="next"||t.position==="previous")return t.position;let s=[];return typeof t?.position=="string"&&s.push(t.position),typeof t.selector=="string"&&s.push(t.selector),s.join(" ")});return r&&n.unshift("inherit"),n.filter(t=>!!t).join(", ")},"toJhxTargetAttribute");var pe=a(e=>{if(e){if(typeof e=="object"){if(e.op==="this"||e.op==="document"||e.op==="window")return e.op;if(typeof e.selector=="string"&&typeof e.op=="string")return`${e.op} ${e.selector}`}return String(e)}},"toJhxFromAttribute"),re=a(e=>typeof e=="string"?e:(Array.isArray(e)?e:[e]).map(r=>{if(typeof r=="string")return r;if(typeof r=="object"){let n=`${r.event||""}${r.filter?`[${r.filter}]`:""}`,t=[];return r.once===!0&&t.push("once"),r.changed===!0&&t.push("changed"),r.consume===!0&&t.push("consume"),r.delay&&t.push(`delay:${r.delay}`),r.from&&t.push(`from:${pe(r.from)}`),r.target&&t.push(`target:${A(r.target)}`),r.throttle&&t.push(`throttle:${r.throttle}`),r.queue&&t.push(`queue:${r.queue}`),n.concat(n?" ":"",t.join(" "))}return""}).filter(Boolean).join(", "),"toJhxTriggerAttribute");var fe=["get","post","put","patch","delete","route"],te=a((e,o)=>{let r={};if(!e||typeof e!="object")return r;let n=fe.find(t=>!!e[t]);if(n)if(n==="route"){let t=e.method?.toLowerCase()||"get";r[`hx-${t}`]=String(e.route)}else r[`hx-${n}`]=String(e[n]);else e.method&&o.logger.warn("[jhx] The 'method' prop must be paired with a 'route' prop to generate a request attribute.");if(e.boost===!0&&(r["hx-boost"]="true"),e.confirm&&(r["hx-confirm"]=e.confirm),e.disable===!0&&(r["hx-disable"]="true"),e.disabledElt){let t=A(e.disabledElt);t&&(r["hx-disabled-elt"]=t)}if(e.disinherit&&(Array.isArray(e.disinherit)?r["hx-disinherit"]=e.disinherit.join(" "):r["hx-disinherit"]=e.disinherit),e.encoding&&(r["hx-encoding"]=e.encoding),e.ext){typeof e.ext=="string"&&(r["hx-ext"]=e.ext);let s=(Array.isArray(e.ext)?e.ext:[e.ext]).map(i=>typeof i=="object"?`${i?.name&&i.ignore===!0?"ignore:":""}${i?.name}`:i).filter(Boolean).join(",");s&&(r["hx-ext"]=s)}if(e.headers)if(typeof e.headers=="object")try{r["hx-headers"]=`${JSON.stringify(e.headers)}`}catch(t){throw o.logger.error("[jhx] Error while parsing the `hx-headers` object."),new j("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-headers",cause:t,stack:t instanceof Error&&typeof t.stack=="string"?t.stack:void 0})}else if(typeof e.headers=="function"){let t=w(e.headers);if(t){let s=`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`;r["hx-vals"]=`js:{...${s}}`}}else r["hx-headers"]=e.headers;if(e.history===!1&&(r["hx-history"]="false"),e.historyElt===!0&&(r["hx-history-elt"]="true"),e.indicator)if(typeof e.indicator=="object"){let t=e.indicator.inherit===!0?"inherit, ":"",s=e.indicator.closest===!0?"closest ":"";r["hx-indicator"]=`${t}${s}${e.indicator.selector}`}else r["hx-indicator"]=e.indicator;if(e.include){let t=A(e.include);t&&(r["hx-include"]=t)}if(e.inherit&&(Array.isArray(e.inherit)?r["hx-inherit"]=e.inherit.join(" "):r["hx-inherit"]=e.inherit),e.params&&(typeof e.params=="object"?e.params.include&&Array.isArray(e.params.include)?r["hx-params"]=`${e.params.include.join(",")}`:e.params.exclude&&Array.isArray(e.params.exclude)&&(r["hx-params"]=`not ${e.params.exclude.join(",")}`):r["hx-params"]=e.params),e.preserve===!0&&(r["hx-preserve"]="true"),e.prompt&&(r["hx-prompt"]=e.prompt),e.pushUrl&&(e.pushUrl===!0?r["hx-push-url"]="true":r["hx-push-url"]=e.pushUrl),(e.replaceUrl||e.replaceUrl===!1)&&(typeof e.replaceUrl=="boolean"?r["hx-replace-url"]=e.replaceUrl?"true":"false":r["hx-replace-url"]=e.replaceUrl),e.request)if(typeof e.request=="object")try{r["hx-request"]=`${JSON.stringify(e.request)}`}catch(t){throw new j("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-request",cause:t,stack:t instanceof Error&&typeof t.stack=="string"?t.stack:void 0})}else if(typeof e.request=="function"){let t=w(e.request);if(t){let i=`(({ timeout, credentials, noHeaders }) => ({ timeout, credentials, noHeaders }))(${`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`})`;r["hx-request"]=`js: ${i}`}}else r["hx-request"]=e.request;if(e.select&&(r["hx-select"]=e.select),e.selectOob)if(Array.isArray(e.selectOob))r["hx-select-oob"]=e.selectOob.map(t=>{if(typeof t=="string")return t;if(typeof t=="object"&&t.selector){let s=P(t.swap);return`${t.selector}${s?":"+s:""}`}return""}).filter(Boolean).join(",");else if(typeof e.selectOob=="object"){let t=P(e.selectOob.swap);r["hx-select-oob"]=`${e.selectOob.selector}${t?":"+t:""}`}else r["hx-select-oob"]=e.selectOob;if(e.swap){let t=P(e.swap);t&&(r["hx-swap"]=t)}if(e.swapOob)if(e.swapOob===!0)r["hx-swap-oob"]="true";else if(typeof e.swapOob=="object"){let t=P(e.swapOob.swap);t&&(r["hx-swap-oob"]=`${t}${e.swapOob.selector?":"+e.swapOob.selector:""}`)}else r["hx-swap-oob"]=e.swapOob;if(e.sync&&(typeof e.sync=="object"?e.sync.strategy&&e.sync.tag?r["hx-sync"]=`${e.sync.closest===!0?"closest ":""}${e.sync.tag}:${e.sync.strategy}`:e.sync.strategy&&(r["hx-sync"]=`this:${e.sync.strategy}`):r["hx-sync"]=e.sync),e.target){let t=A(e.target);t&&(r["hx-target"]=t)}if(e.trigger&&(r["hx-trigger"]=re(e.trigger)),e.validate===!0&&(r["hx-validate"]="true"),e.vars&&(o.logger.warn("[jhx] The `hx-vars` attribute has been deprecated because of XSS vulnerabilities. Recommended to use the `hx-vals` attribute."),r["hx-vars"]=e.vars),e.vals)if(typeof e.vals=="object")try{r["hx-vals"]=`${JSON.stringify(e.vals)}`}catch(t){throw new j("[jhx] Error while parsing 'hx-vals' object",{attribute:"hx-vals",cause:t,stack:t instanceof Error&&typeof t.stack=="string"?t.stack:void 0})}else if(typeof e.vals=="function"){let t=w(e.vals);if(t){let s=`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`;r["hx-vals"]=`js:{...${s}}`}}else r["hx-vals"]=e.vals;return r},"convertJhxAttributes");var oe=a(e=>{let o={};if(!e||typeof e!="object")return o;for(let r in E)if(Object.prototype.hasOwnProperty.call(e,r)){let n=E[r],t=e[r];if(!t)continue;let s=w(t);if(!s)continue;o[n]=`((${s.params.join(",")}) => ${s.body})(${s.params.join(",")})`}return o},"convertJhxEventAttributes");var ce={'"':""","<":"<",">":">"},O=a(e=>String(e).replace(/["<>]/g,o=>ce[o]??o),"escapeValue");var N=a((e,o=!0)=>Object.entries(e).map(([r,n])=>typeof n=="object"?`${r}="${JSON.stringify(n)}"`:`${r}="${typeof n=="string"&&o?O(n):n}"`).filter(Boolean).join(" "),"attributesToString");var B={logger:console,stringify:!1,escape:!0};var ne=a(e=>{let o={};for(let[r,n]of Object.entries(e))o[r]=typeof n=="string"?O(n):n;return o},"escapeAttributes");function k(e,o){let r={...B,...o??{}},n={...te(e,r),...oe(e),...Q(e)};return r.stringify===!0?N(n,!!r.escape):r.escape===!0?ne(n):n}a(k,"jhx");var Te=a((e,o)=>{for(let[r,n]of Object.entries(o))typeof n=="object"?e.setAttribute(r,JSON.stringify(n)):e.setAttribute(r,String(n))},"applyAttributes");var H=class e extends Error{static{a(this,"JhxServerException")}type;info;method;route;cause;constructor(o,r){super(o),this.name="JhxServerError",this.type=r.type,this.info=r.info||r.cause?.message||o,this.method=r.method,this.route=r.route,this.stack=r.stack,this.cause=r.cause,Object.setPrototypeOf(this,e.prototype)}};import{posix as ge}from"path";var C=a((e,o="")=>{let r=String(o).startsWith("/")?String(o):`/${o}`,n=e.trim();n=n.startsWith("/")?n:`/${n}`;let t;try{t=decodeURIComponent(n.startsWith(r)?n:`${r}/${n}`)}catch(i){throw new H("jhx: malformed endpoint",{type:"endpoint:malformed",info:i.message,route:n,cause:i})}let s=ge.normalize(t.startsWith("/")?t:`/${t}`);return s.length>1&&s.endsWith("/")&&(s=s.slice(0,-1)),{noSlash:s,withSlash:s==="/"?"/":`${s}/`}},"normalizeEndpoint");var M=a((e,o,r)=>{if(r||(r=new Map),!e)return r;for(let n of e){let t=n.method?.trim()?.toUpperCase()??"GET",{noSlash:s,withSlash:i}=C(n.route,o.prefix);if(o.trailingSlash==="no-slash"){let T=`${t}::${s}`;if(r.has(T))throw new H("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${s}'`,method:t,route:s});r.set(T,n.handler),o.onRegistered(t,s),o.debug&&o.logger.info(`[jhx] Added new route: ${t} ${s}`)}else if(o.trailingSlash==="slash"){let T=`${t}::${i}`;if(r.has(T))throw new H("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${s}'`,method:t,route:s});r.set(T,n.handler),o.onRegistered(t,i),o.debug&&o.logger.info(`[jhx] Added new route: ${t} ${i}`)}else{let T=`${t}::${s}`,g=`${t}::${i}`;if(r.has(T))throw new H("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${s}'`,method:t,route:s});if(r.has(g))throw new H("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${s}'`,method:t,route:s});r.set(T,n.handler),r.set(g,n.handler),o.onRegistered(t,s),o.debug&&o.logger.info(`[jhx] Added new route: ${t} ${s}`)}}return r},"addRoutesToMap");import{isValidElement as se}from"react";import{renderToStaticMarkup as ye,renderToString as Re}from"react-dom/server";var He=a((e,...o)=>se(e)?ye(e):e,"jsxToStatic"),be=a((e,...o)=>se(e)?Re(e):e,"jsxToString"),Se=a((e,...o)=>e,"noRender"),ae=a(e=>e?typeof e=="function"?e:e==="static"?He:e==="string"?be:Se:null,"getRenderFunction");var ve=["get","post","put","patch","delete","route"],ie=a(e=>{for(let o of ve)if(o in e){let r=e[o];return o==="route"?{method:"GET",route:typeof r=="string"&&r.trim()||null}:{method:o.toUpperCase(),route:typeof r=="string"&&r.trim()||null}}return{method:"GET",route:null}},"getRouteFromProps");import{createHash as Je}from"crypto";var he=a(e=>{if(typeof e?.toString!="function")throw new H("jhx: invalid route error",{type:"hash:invalid",info:"Cannot hash function without a 'toString' method"});return Je("sha256").update(e.toString()).digest("hex").slice(0,12)},"hashFunction");var U=a(e=>{let o=[];if(!e)return o;for(let r of Array.isArray(e)?e:[e]){if(r.method&&r.method.trim()==="")throw new H("jhx: route validation error",{type:"route:invalid-method",info:`Invalid route method: '${r.method}'`,method:String(r.method)});if(!r.route||r.route?.trim()==="")throw new H("jhx: route validation error",{type:"route:invalid-path",info:`Invalid route endpoint: '${r.route}'`,method:r.method?.toUpperCase()??"GET",route:String(r.route)});if(!r.handler||typeof r.handler!="function")throw new H("jhx: route validation error",{type:"route:invalid-handler",info:`Invalid route handler for '${r.method?.toUpperCase()??"GET"} ${r.route}'`,method:r.method?.toUpperCase()??"GET",route:r.route});o.push({method:r.method?.toUpperCase()??"GET",route:r.route,handler:r.handler})}return o},"validateRoutes");var Ee=a(e=>e.startsWith("hx-")||e in q.attr||e in q.eventAttr||e==="route"||e==="method"||e==="handler","isJhxAttribute"),L=a(e=>a(function(r){let{jhxConfig:n,as:t,children:s,...i}=r,T=t??"div",g={};for(let[h,y]of Object.entries(i))Ee(h)||(g[h]=y);let x={...e(i,{...n,stringify:!1}),...g};return<T{...x}>{s}</T>},"JhxComponent"),"createJhxComponent");import{isValidElement as we}from"react";import{renderToString as Ce}from"react-dom/server";var S={...B,contentType:"text/html",debug:!1,middleware:[],onRegistered:a(((e,o)=>{}),"onRegistered"),prefix:"/_jhx",render:a((e,...o)=>we(e)?Ce(e):e,"render"),renderError:!0,renderMiddleware:!0,renderNotFound:!0,trailingSlash:"both"};var xe=a((e,o,r)=>{let n={contentType:e.contentType===!1?!1:e.contentType??S.contentType,debug:e.debug===S.debug,errorHandler:e.errorHandler,middleware:Array.isArray(e.middleware)?e.middleware:e.middleware?[e.middleware]:S.middleware,notFoundHandler:e.notFoundHandler?e.notFoundHandler:o,onRegistered:e.onRegistered??S.onRegistered,logger:e.logger??S.logger,prefix:e.prefix?C(e.prefix).noSlash:S.prefix,render:typeof e.render=="function"?e.render:ae(e.render===void 0?"string":e.render),renderError:typeof e.renderError=="boolean"?e.renderError:S.renderError,renderMiddleware:typeof e.renderMiddleware=="boolean"?e.renderMiddleware:S.renderMiddleware,renderNotFound:typeof e.renderNotFound=="boolean"?e.renderNotFound:S.renderNotFound,stringify:typeof e.stringify=="boolean"?e.stringify:S.stringify,trailingSlash:e.trailingSlash??S.trailingSlash,instanceOptions:e.instanceOptions},t=e.routes?M(U(e.routes),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash}):new Map;r(n,t);function s(i,T){if(typeof i=="object"&&typeof i.handler=="function"){let{method:x,route:h}=ie(i),{noSlash:y,withSlash:b}=C(h||he(i.handler),n.prefix);if(n.trailingSlash==="no-slash"){let v=`${x}::${y}`;t.has(v)||(n.debug&&n.logger.info(`[jhx] Added new route: ${x} ${y}`),t.set(v,i.handler),n.onRegistered(x,y)),i.method=x,i.route=y}else if(n.trailingSlash==="slash"){let v=`${x}::${b}`;t.has(v)||(n.debug&&n.logger.info(`[jhx] Added new route: ${x} ${b}`),t.set(v,i.handler),n.onRegistered(x,b)),i.method=x,i.route=b}else{let v=`${x}::${y}`,F=`${x}::${b}`;!t.has(v)&&!t.has(F)&&(n.debug&&n.logger.info(`[jhx] Added new route: ${x} ${y}`),t.set(v,i.handler),t.set(F,i.handler),n.onRegistered(x,y)),i.method=x,i.route=y}}let g=T?.stringify??n.stringify,R=i&&typeof i=="object"&&"handler"in i?(({handler:x,...h})=>h)(i):i;return g?k(R,{logger:T?.logger??n.logger,stringify:!0}):k(R,{logger:T?.logger??n.logger,stringify:!1})}return a(s,"jhx"),s.addRoute=i=>{M(U({method:i.method,route:i.route,handler:i.handler}),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},t)},s.addRoutes=i=>{M(U(i),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},t)},s.clearRoutes=()=>{let i=t.size;t.clear(),n.debug&&n.logger.info(`[jhx] Cleared ${i} route${i===1?"":"s"}`)},s.getRoute=(i,T)=>{let g=i.trim().toUpperCase(),{noSlash:R,withSlash:x}=C(T,n.prefix);if(n.trailingSlash==="no-slash"){let h=`${g}::${R}`,y=t.get(h);return y?{method:g,route:R,handler:y}:null}else if(n.trailingSlash==="slash"){let h=t.get(`${g}::${x}`);return h?{method:g,route:x,handler:h}:null}else{let h=t.get(`${g}::${R}`),y=t.get(`${g}::${x}`);if(!h&&!y)return null;let b=T.endsWith("/");return{method:g,route:b?y?x:R:h?R:x,handler:b?y??h:h??y}}},s.getRoutes=()=>Array.from(t.entries()).map(([i,T])=>{let[g,R]=i.split("::");return!g||!R?null:{method:g,route:R,handler:T}}).filter(i=>i!==null),s.hasRoute=(i,T)=>{let{noSlash:g,withSlash:R}=C(T,n.prefix);return t.has(`${i.toUpperCase()}::${g}`)||t.has(`${i.toUpperCase()}::${R}`)},s.removeRoute=(i,T)=>{let g=i.trim().toUpperCase(),{noSlash:R,withSlash:x}=C(T,n.prefix),h;return n.trailingSlash==="no-slash"?h=t.delete(`${g}::${R}`):n.trailingSlash==="slash"?h=t.delete(`${g}::${x}`):(h=t.delete(`${g}::${R}`),h=t.delete(`${g}::${x}`)||h),h&&n.debug?n.logger.info(`[jhx] Removed route: ${g} ${n.trailingSlash==="no-slash"?R:n.trailingSlash==="slash"?x:`${R} / ${x}`}`):!h&&n.debug&&n.logger.info(`[jhx] Cannot remove unknown route: ${g} ${n.trailingSlash==="no-slash"?R:n.trailingSlash==="slash"?x:`${R} / ${x}`}`),h},{jhx:s,JhxComponent:L(s)}},"createServerJhx");var je=a(e=>e?.finalized===!0,"isResponseSent"),$=a(e=>je(e),"isResponseHandled");import{Stream as Ae}from"node:stream";var $e=a(e=>e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Uint8ClampedArray||e instanceof BigUint64Array||typeof ArrayBuffer<"u"&&ArrayBuffer.isView(e)||typeof Buffer<"u"&&e instanceof Buffer,"isArrayBuffer"),qe=a(e=>e.split("-").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("-"),"capitalize"),D=a((e,o,r)=>{!e.res.headers.get(qe(o))&&!e.res.headers.get(o.toLowerCase())&&e.res.headers.set(o.toLowerCase(),r)},"ensureHeader"),J=a((e,o)=>o instanceof Response?o:o instanceof Blob?(D(e,"content-type",o.type),D(e,"content-length",String(o.size)),e.body(o)):o instanceof FormData?(D(e,"content-type","multipart/form-data"),new Response(o)):o instanceof ReadableStream||o instanceof Ae||$e(o)?(D(e,"content-type","application/octet-stream"),e.body(o)):typeof o=="object"?(D(e,"content-type","application/json"),e.json(o)):e.body(o),"sendPayload");var de={...S,notFoundHandler:a(e=>e.text("",404),"notFoundHandler")};var as=a((e,o={})=>xe(o,de.notFoundHandler,(r,n)=>{e.all(`${r.prefix}/*`,async t=>{let s=t.req.method,i=decodeURIComponent(t.req.path),T=n.get(`${s}::${i}`);if(r.contentType&&t.header("content-type",r.contentType),T){for(let x of r.middleware)try{let h=await x(t);if($(t))return J(t,h);if(h!==void 0){let y=r.render&&r.renderMiddleware?await r.render(h,t):h;return J(t,y)}}catch(h){let y=h;if(r.debug&&r.logger.error(`[jhx] Middleware error from '${s} ${i}': ${y.message}`),r.errorHandler){t.status(500);let b=await r.errorHandler(y,t);if($(t))return J(t,b);let v=r.render&&r.renderError?await r.render(b,t):b;return J(t,v)}throw new H("Unhandled middleware error",{type:"middleware:error",method:s,route:i,cause:y})}try{let x=await T(t);if($(t))return J(t,x);let h=r.render?await r.render(x,t):x;return J(t,h)}catch(x){let h=x;if(r.debug&&r.logger.error(`[jhx] Route error from '${s} ${i}': ${h.message}`),r.errorHandler){t.status(500);let y=await r.errorHandler(h,t);if($(t))return J(t,y);let b=r.render&&r.renderError?await r.render(y,t):y;return J(t,b)}throw new H("[jhx] Unhandled endpoint or rendering error",{type:"handler:error",method:s,route:i,cause:h})}}r.debug&&r.logger.info(`[jhx] Request to unknown route '${s} ${i}'`),t.status(404);let g=await r.notFoundHandler(t);if($(t))return J(t,g);let R=r.render&&r.renderNotFound?await r.render(g,t):g;return J(t,R)})}),"createJhx");function ds(e){return L(e)}a(ds,"createJhxComponent");export{Te as applyAttributes,N as attributesToString,as as createJhx,ds as createJhxComponent,de as defaultConfig,q as htmx};
|
|
1
|
+
var fe=Object.defineProperty;var a=(e,o)=>fe(e,"name",{value:o,configurable:!0});var C={onAbort:"hx-on--abort",onAfterOnLoad:"hx-on--after-on-load",onAfterProcessNode:"hx-on--after-process-node",onAfterRequest:"hx-on--after-request",onAfterSettle:"hx-on--after-settle",onAfterSwap:"hx-on--after-swap",onBeforeCleanupElement:"hx-on--before-cleanup-element",onBeforeOnLoad:"hx-on--before-on-load",onBeforeProcessNode:"hx-on--before-process-node",onBeforeRequest:"hx-on--before-request",onBeforeSwap:"hx-on--before-swap",onBeforeSend:"hx-on--before-send",onBeforeTransition:"hx-on--before-transition",onConfigRequest:"hx-on--config-request",onConfirm:"hx-on--confirm",onHistoryCacheError:"hx-on--history-cache-error",onHistoryCacheHit:"hx-on--history-cache-hit",onHistoryCacheMiss:"hx-on--history-cache-miss",onHistoryCacheMissLoadError:"hx-on--history-cache-miss-load-error",onHistoryCacheMissLoad:"hx-on--history-cache-miss-load",onHistoryRestore:"hx-on--history-restore",onBeforeHistorySave:"hx-on--before-history-save",onLoad:"hx-on--load",onNoSSESourceError:"hx-on--no-sse-source-error",onOnLoadError:"hx-on--on-load-error",onOobAfterSwap:"hx-on--oob-after-swap",onOobBeforeSwap:"hx-on--oob-before-swap",onOobErrorNoTarget:"hx-on--oob-error-no-target",onPrompt:"hx-on--prompt",onPushedIntoHistory:"hx-on--pushed-into-history",onReplacedInHistory:"hx-on--replaced-in-history",onResponseError:"hx-on--response-error",onSendAbort:"hx-on--send-abort",onSendError:"hx-on--send-error",onSseError:"hx-on--sse-error",onSseOpen:"hx-on--sse-open",onSwapError:"hx-on--swap-error",onTargetError:"hx-on--target-error",onTimeout:"hx-on--timeout",onValidateUrl:"hx-on--validate-url",onValidationValidate:"hx-on--validation-validate",onValidationFailed:"hx-on--validation-failed",onValidationHalted:"hx-on--validation-halted",onXhrAbort:"hx-on--xhr-abort",onXhrLoadend:"hx-on--xhr-loadend",onXhrLoadstart:"hx-on--xhr-loadstart",onXhrProgress:"hx-on--xhr-progress"};var W={get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch",pushUrl:"hx-push-url",select:"hx-select",selectOob:"hx-select-oob",swap:"hx-swap",swapOob:"hx-swap-oob",target:"hx-target",trigger:"hx-trigger",vals:"hx-vals",boost:"hx-boost",confirm:"hx-confirm",disable:"hx-disable",disabledElt:"hx-disabled-elt",disinherit:"hx-disinherit",encoding:"hx-encoding",ext:"hx-ext",headers:"hx-headers",history:"hx-history",historyElt:"hx-history-elt",include:"hx-include",indicator:"hx-indicator",inherit:"hx-inherit",params:"hx-params",preserve:"hx-preserve",prompt:"hx-prompt",replaceUrl:"hx-replace-url",request:"hx-request",sync:"hx-sync",validate:"hx-validate",vars:"hx-vars",...C};var V={added:"htmx-added",indicator:"htmx-indicator",request:"htmx-request",settling:"htmx-settling",swapping:"htmx-swapping"};var z={addedClass:"hx-added",allowEval:!0,allowNestedOobSwaps:!0,allowScriptTags:!0,attributesToSettle:["class","style","width","height"],defaultFocusScroll:!1,defaultSettleDelay:20,defaultSwapDelay:0,defaultSwapStyle:"innerHTML",disableInheritance:!1,disableSelector:"[hx-disable], [data-hx-disable]",getCacheBusterParam:!1,globalViewTransitions:!1,historyCacheSize:10,historyEnabled:!0,historyRestoreAsHxRequest:!0,ignoreTitle:!1,includeIndicatorStyles:!0,indicatorClass:"hx-indicator",inlineScriptNonce:"",inlineStyleNonce:"",methodsThatUseUrlParams:["get","delete"],refreshOnHistoryMiss:!1,requestClass:"htmx-request",responseHandling:[{code:"204",swap:!1},{code:"[23]..",swap:!0},{code:"[45]..",swap:!1,error:!0}],scrollBehavior:"instant",scrollIntoViewOnBoost:!0,selfRequestsOnly:!0,settlingClass:"htmx-settling",swappingClass:"htmx-swapping",timeout:0,triggerSpecsCache:null,withCredentials:!1,wsBinaryType:"blob",wsReconnectDelay:"full-jitter"};var G={abort:"htmx:abort",afterOnLoad:"htmx:afterOnLoad",afterProcessNode:"htmx:afterProcessNode",afterRequest:"htmx:afterRequest",afterSettle:"htmx:afterSettle",afterSwap:"htmx:afterSwap",beforeCleanupElement:"htmx:beforeCleanupElement",beforeOnLoad:"htmx:beforeOnLoad",beforeProcessNode:"htmx:beforeProcessNode",beforeRequest:"htmx:beforeRequest",beforeSwap:"htmx:beforeSwap",beforeSend:"htmx:beforeSend",beforeTransition:"htmx:beforeTransition",configRequest:"htmx:configRequest",confirm:"htmx:confirm",historyCacheError:"htmx:historyCacheError",historyCacheHit:"htmx:historyCacheHit",historyCacheMiss:"htmx:historyCacheMiss",historyCacheMissLoadError:"htmx:historyCacheMissLoadError",historyCacheMissLoad:"htmx:historyCacheMissLoad",historyRestore:"htmx:historyRestore",beforeHistorySave:"htmx:beforeHistorySave",load:"htmx:load",noSSESourceError:"htmx:noSSESourceError",onLoadError:"htmx:onLoadError",oobAfterSwap:"htmx:oobAfterSwap",oobBeforeSwap:"htmx:oobBeforeSwap",oobErrorNoTarget:"htmx:oobErrorNoTarget",prompt:"htmx:prompt",pushedIntoHistory:"htmx:pushedIntoHistory",replacedInHistory:"htmx:replacedInHistory",responseError:"htmx:responseError",sendAbort:"htmx:sendAbort",sendError:"htmx:sendError",sseError:"htmx:sseError",sseOpen:"htmx:sseOpen",swapError:"htmx:swapError",targetError:"htmx:targetError",timeout:"htmx:timeout",validateUrl:"htmx:validateUrl",validationValidate:"htmx:validation:validate",validationFailed:"htmx:validation:failed",validationHalted:"htmx:validation:halted",xhrAbort:"htmx:xhr:abort",xhrLoadend:"htmx:xhr:loadend",xhrLoadstart:"htmx:xhr:loadstart",xhrProgress:"htmx:xhr:progress"};var Y={headSupport:{name:"head-support",version:"2.0.5",npm:"htmx-ext-head-support",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-head-support@2.0.5",integrity:"sha384-cvMqHzjCJsOHgGuyB3sWXaUSv/Krm0BdzjuI1rtkjCbL1l1oHJx+cHyVRJhyuEz0"}]},htmx1Compat:{name:"htmx-1-compat",version:"2.0.2",npm:"htmx-ext-htmx-1-compat",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-htmx-1-compat@2.0.2",integrity:"sha384-lcvVWaNjF5zPPUeeWmC0OkJ2MLqoWLlkAabuGm+EuMSTfGo5WRyHrNaAp0cJr9Pg"}]},idiomorph:{name:"morph",version:"0.7.4",npm:"idiomorph",cdn:[{url:"https://unpkg.com/idiomorph@0.7.4/dist/idiomorph-ext.min.js",integrity:"sha384-SsScJKzATF/w6suEEdLbgYGsYFLzeKfOA6PY+/C5ZPxOSuA+ARquqtz/BZz9JWU8"}]},preload:{name:"preload",version:"2.1.2",npm:"htmx-ext-preload",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-preload@2.1.2",integrity:"sha384-PRIcY6hH1Y5784C76/Y8SqLyTanY9rnI3B8F3+hKZFNED55hsEqMJyqWhp95lgfk"}]},responseTargets:{name:"response-targets",version:"2.0.4",npm:"htmx-ext-response-targets",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-response-targets@2.0.4",integrity:"sha384-T41oglUPvXLGBVyRdZsVRxNWnOOqCynaPubjUVjxhsjFTKrFJGEMm3/0KGmNQ+Pg"}]},sse:{name:"sse",version:"2.2.4",npm:"htmx-ext-sse",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-sse@2.2.4",integrity:"sha384-A986SAtodyH8eg8x8irJnYUk7i9inVQqYigD6qZ9evobksGNIXfeFvDwLSHcp31N"}]},ws:{name:"ws",version:"2.0.4",npm:"htmx-ext-ws",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.4",integrity:"sha384-1RwI/nvUSrMRuNj7hX1+27J8XDdCoSLf0EjEyF69nacuWyiJYoQ/j39RT1mSnd2G"}]}};var _={GET:"hx-get",POST:"hx-post",PUT:"hx-put",DELETE:"hx-delete",PATCH:"hx-patch",get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch"};var K={boosted:"HX-Boosted",currentUrl:"HX-Current-URL",historyRestoreRequest:"HX-History-Restore-Request",prompt:"HX-Prompt",request:"HX-Request",target:"HX-Target",triggerName:"HX-Trigger-Name",trigger:"HX-Trigger"};var Q={location:"HX-Location",pushUrl:"HX-Push-URL",redirect:"HX-Redirect",refresh:"HX-Refresh",replaceUrl:"HX-Replace-URL",reswap:"HX-Reswap",retarget:"HX-Retarget",reselect:"HX-Reselect",trigger:"HX-Trigger",triggerAfterSettle:"HX-Trigger-After-Settle",triggerAfterSwap:"HX-Trigger-After-Swap"};var Z={innerHTML:"innerHTML",outerHTML:"outerHTML",textContent:"textContent",beforeBegin:"beforebegin",afterBegin:"afterbegin",beforeEnd:"beforeend",afterEnd:"afterend",delete:"delete",none:"none"};var ee={drop:"drop",abort:"abort",replace:"replace",queue:"queue",queueAll:"queue all",queueFirst:"queue first",queueLast:"queue last"};var D={attr:W,config:z,css:V,event:G,eventAttr:C,ext:Y,method:_,res:Q,req:K,swap:Z,sync:ee};var re=a(e=>{let o=[],r=0;for(;r<e.length;){let n=e[r];if(n==="`"){let t=r;for(r++;r<e.length;)if(e[r]==="\\")r+=2;else if(e[r]==="`"){r++;break}else r++;o.push(e.slice(t,r));continue}if(n==='"'){r++;let t=[],i=!1;for(;r<e.length;)if(e[r]==="\\"){let T=e[r+1];t.push(e[r],T??""),r+=2}else if(e[r]==='"'){r++;break}else e[r]==="$"&&e[r+1]==="{"&&(i=!0),t.push(e[r]),r++;let s=t.join("");if(i){o.push("`");for(let T=0;T<s.length;T++)if(s[T]==="\\"){let g=s[T+1];g==='"'?(o.push('"'),T++):g==="`"?(o.push("\\`"),T++):(o.push(s[T],g??""),T++)}else s[T]==="`"?o.push("\\`"):o.push(s[T]);o.push("`")}else{o.push("'");for(let T=0;T<s.length;T++)if(s[T]==="\\"){let g=s[T+1];g==='"'?(o.push('"'),T++):g==="'"?(o.push("\\'"),T++):(o.push(s[T],g??""),T++)}else s[T]==="'"?o.push("\\'"):o.push(s[T]);o.push("'")}continue}if(n==="'"){let t=r;for(r++;r<e.length;)if(e[r]==="\\")r+=2;else if(e[r]==="'"){r++;break}else r++;o.push(e.slice(t,r));continue}if(n==="/"&&r>0){let t=e.slice(0,r).trimEnd().slice(-1);if(["=","(",",","[","!","&","|",":",";","{","}","?"].includes(t)){let s=r;r++;let T=!1;for(;r<e.length;)if(e[r]==="\\")r+=2;else if(e[r]==="[")T=!0,r++;else if(e[r]==="]")T=!1,r++;else if(e[r]==="/"&&!T){for(r++;r<e.length&&/[gimsuy]/.test(e[r]);)r++;break}else r++;o.push(e.slice(s,r));continue}}o.push(n),r++}return o.join("")},"normalizeStringQuotes");var me=a(e=>{let o=/^(?:async\s*)?function\*?\s*(?:[A-z0-9]+)?\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)\s*\{((?:[^}{]+|\{(?:[^}{]+|\{[^}{]*})*})*)}$/s,r=e.match(o);if(r&&r[2])return{fnType:"normal",fullMatch:r[0],paramStr:r[1]??"",bodyStr:`{ ${r[2].trim()} }`};let n=/^(?:async\s*)?(?:\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)|([^\s=()]+))\s*=>\s*(.*)$/s,t=e.match(n);if(t&&t[3]){let i=t[3].trim();return{fnType:"arrow",fullMatch:t[0],paramStr:t[1]??"",bodyStr:i.startsWith("{")&&(i.endsWith("}")||i.endsWith("};"))?i:`{ return ${i} }`}}return null},"matchFunctionString"),ce=a(e=>{if(!e)return[];let o=[],r=0,n=0,t=0,i=0;for(let s=0;s<e.length;s++){let T=e[s];T==="("?r++:T===")"?r--:T==="{"?n++:T==="}"?n--:T==="["?t++:T==="]"?t--:T===","&&r===0&&n===0&&t===0&&(o.push(e.substring(i,s).trim()),i=s+1)}return o.push(e.substring(i).trim()),o.filter(Boolean)},"splitParams"),j=a(e=>{if(typeof e!="function"||typeof e?.toString!="function")return null;let o=e.toString().replaceAll("void 0","undefined"),r=me(o);return r?{params:ce(r.paramStr),body:re(r.bodyStr)}:null},"extractFunction");var te=a(e=>{let o={};if(!e||typeof e!="object")return o;for(let r in e){if(r in C||!r.startsWith("on"))continue;let n=e[r];if(!n)continue;let t=j(n);t&&(o[r.toLowerCase()]=`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`)}return o},"convertDomEventAttributes");var $=class e extends Error{static{a(this,"JhxErrorThrowable")}attribute;constructor(o,r){super(o),this.name="JhxError",this.attribute=r.attribute,r.stack&&(this.stack=r.stack),r.cause&&(this.cause=r.cause),Object.setPrototypeOf(this,e.prototype)}};var oe=a((e,o)=>typeof o=="string"?`${e}:${o}`:"window"in o?`${e}:window:${o.position}`:"selector"in o?`${e}:${o.selector}:${o.position}`:"","processScrollOrShow"),O=a(e=>{if(!e)return;if(typeof e=="string")return e;let o=[];return e.style&&o.push(String(e.style)),e.swap&&o.push(`swap:${e.swap}`),e.settle&&o.push(`settle:${e.settle}`),typeof e.transition=="boolean"&&o.push(`transition:${e.transition}`),e.scroll&&o.push(oe("scroll",e.scroll)),e.show&&o.push(oe("show",e.show)),e.ignoreTitle&&o.push("ignoreTitle:true"),typeof e.focusScroll=="boolean"&&o.push(`focus-scroll:${e.focusScroll}`),o.filter(Boolean).join(" ")},"toJhxSwapAttribute");var q=a(e=>{if(!e)return;let o=Array.isArray(e)?e:[e],r=!1,n=o.map(t=>{if(typeof t!="object")return t;if(t.inherit!==void 0){if(!t.inherit)return;r=!0;return}if(t.position==="this"||t.position==="next"||t.position==="previous")return t.position;let i=[];return typeof t?.position=="string"&&i.push(t.position),typeof t.selector=="string"&&i.push(t.selector),i.join(" ")});return r&&n.unshift("inherit"),n.filter(t=>!!t).join(", ")},"toJhxTargetAttribute");var Te=a(e=>{if(e){if(typeof e=="object"){if(e.op==="this"||e.op==="document"||e.op==="window")return e.op;if(typeof e.selector=="string"&&typeof e.op=="string")return`${e.op} ${e.selector}`}return String(e)}},"toJhxFromAttribute"),ne=a(e=>typeof e=="string"?e:(Array.isArray(e)?e:[e]).map(r=>{if(typeof r=="string")return r;if(typeof r=="object"){let n=`${r.event||""}${r.filter?`[${r.filter}]`:""}`,t=[];return r.once===!0&&t.push("once"),r.changed===!0&&t.push("changed"),r.consume===!0&&t.push("consume"),r.delay&&t.push(`delay:${r.delay}`),r.from&&t.push(`from:${Te(r.from)}`),r.target&&t.push(`target:${q(r.target)}`),r.throttle&&t.push(`throttle:${r.throttle}`),r.queue&&t.push(`queue:${r.queue}`),n.concat(n?" ":"",t.join(" "))}return""}).filter(Boolean).join(", "),"toJhxTriggerAttribute");var ge=["get","post","put","patch","delete","route"],se=a((e,o)=>{let r={};if(!e||typeof e!="object")return r;let n=ge.find(t=>!!e[t]);if(n)if(n==="route"){let t=e.method?.toLowerCase()||"get";r[`hx-${t}`]=String(e.route)}else r[`hx-${n}`]=String(e[n]);else e.method&&o.logger.warn("[jhx] The 'method' prop must be paired with a 'route' prop to generate a request attribute.");if(e.boost===!0&&(r["hx-boost"]="true"),e.confirm&&(r["hx-confirm"]=e.confirm),e.disable===!0&&(r["hx-disable"]="true"),e.disabledElt){let t=q(e.disabledElt);t&&(r["hx-disabled-elt"]=t)}if(e.disinherit&&(Array.isArray(e.disinherit)?r["hx-disinherit"]=e.disinherit.join(" "):r["hx-disinherit"]=e.disinherit),e.encoding&&(r["hx-encoding"]=e.encoding),e.ext){typeof e.ext=="string"&&(r["hx-ext"]=e.ext);let i=(Array.isArray(e.ext)?e.ext:[e.ext]).map(s=>typeof s=="object"?`${s?.name&&s.ignore===!0?"ignore:":""}${s?.name}`:s).filter(Boolean).join(",");i&&(r["hx-ext"]=i)}if(e.headers)if(typeof e.headers=="object")try{r["hx-headers"]=`${JSON.stringify(e.headers)}`}catch(t){throw o.logger.error("[jhx] Error while parsing the `hx-headers` object."),new $("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-headers",cause:t,stack:t instanceof Error&&typeof t.stack=="string"?t.stack:void 0})}else if(typeof e.headers=="function"){let t=j(e.headers);if(t){let i=`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`;r["hx-vals"]=`js:{...${i}}`}}else r["hx-headers"]=e.headers;if(e.history===!1&&(r["hx-history"]="false"),e.historyElt===!0&&(r["hx-history-elt"]="true"),e.indicator)if(typeof e.indicator=="object"){let t=e.indicator.inherit===!0?"inherit, ":"",i=e.indicator.closest===!0?"closest ":"";r["hx-indicator"]=`${t}${i}${e.indicator.selector}`}else r["hx-indicator"]=e.indicator;if(e.include){let t=q(e.include);t&&(r["hx-include"]=t)}if(e.inherit&&(Array.isArray(e.inherit)?r["hx-inherit"]=e.inherit.join(" "):r["hx-inherit"]=e.inherit),e.params&&(typeof e.params=="object"?e.params.include&&Array.isArray(e.params.include)?r["hx-params"]=`${e.params.include.join(",")}`:e.params.exclude&&Array.isArray(e.params.exclude)&&(r["hx-params"]=`not ${e.params.exclude.join(",")}`):r["hx-params"]=e.params),e.preserve===!0&&(r["hx-preserve"]="true"),e.prompt&&(r["hx-prompt"]=e.prompt),e.pushUrl&&(e.pushUrl===!0?r["hx-push-url"]="true":r["hx-push-url"]=e.pushUrl),(e.replaceUrl||e.replaceUrl===!1)&&(typeof e.replaceUrl=="boolean"?r["hx-replace-url"]=e.replaceUrl?"true":"false":r["hx-replace-url"]=e.replaceUrl),e.request)if(typeof e.request=="object")try{r["hx-request"]=`${JSON.stringify(e.request)}`}catch(t){throw new $("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-request",cause:t,stack:t instanceof Error&&typeof t.stack=="string"?t.stack:void 0})}else if(typeof e.request=="function"){let t=j(e.request);if(t){let s=`(({ timeout, credentials, noHeaders }) => ({ timeout, credentials, noHeaders }))(${`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`})`;r["hx-request"]=`js: ${s}`}}else r["hx-request"]=e.request;if(e.select&&(r["hx-select"]=e.select),e.selectOob)if(Array.isArray(e.selectOob))r["hx-select-oob"]=e.selectOob.map(t=>{if(typeof t=="string")return t;if(typeof t=="object"&&t.selector){let i=O(t.swap);return`${t.selector}${i?":"+i:""}`}return""}).filter(Boolean).join(",");else if(typeof e.selectOob=="object"){let t=O(e.selectOob.swap);r["hx-select-oob"]=`${e.selectOob.selector}${t?":"+t:""}`}else r["hx-select-oob"]=e.selectOob;if(e.swap){let t=O(e.swap);t&&(r["hx-swap"]=t)}if(e.swapOob)if(e.swapOob===!0)r["hx-swap-oob"]="true";else if(typeof e.swapOob=="object"){let t=O(e.swapOob.swap);t&&(r["hx-swap-oob"]=`${t}${e.swapOob.selector?":"+e.swapOob.selector:""}`)}else r["hx-swap-oob"]=e.swapOob;if(e.sync&&(typeof e.sync=="object"?e.sync.strategy&&e.sync.tag?r["hx-sync"]=`${e.sync.closest===!0?"closest ":""}${e.sync.tag}:${e.sync.strategy}`:e.sync.strategy&&(r["hx-sync"]=`this:${e.sync.strategy}`):r["hx-sync"]=e.sync),e.target){let t=q(e.target);t&&(r["hx-target"]=t)}if(e.trigger&&(r["hx-trigger"]=ne(e.trigger)),e.validate===!0&&(r["hx-validate"]="true"),e.vars&&(o.logger.warn("[jhx] The `hx-vars` attribute has been deprecated because of XSS vulnerabilities. Recommended to use the `hx-vals` attribute."),r["hx-vars"]=e.vars),e.vals)if(typeof e.vals=="object")try{r["hx-vals"]=`${JSON.stringify(e.vals)}`}catch(t){throw new $("[jhx] Error while parsing 'hx-vals' object",{attribute:"hx-vals",cause:t,stack:t instanceof Error&&typeof t.stack=="string"?t.stack:void 0})}else if(typeof e.vals=="function"){let t=j(e.vals);if(t){let i=`((${t.params.join(",")}) => ${t.body})(${t.params.join(",")})`;r["hx-vals"]=`js:{...${i}}`}}else r["hx-vals"]=e.vals;return r},"convertJhxAttributes");var ie=a(e=>{let o={};if(!e||typeof e!="object")return o;for(let r in C)if(Object.prototype.hasOwnProperty.call(e,r)){let n=C[r],t=e[r];if(!t)continue;let i=j(t);if(!i)continue;o[n]=`((${i.params.join(",")}) => ${i.body})(${i.params.join(",")})`}return o},"convertJhxEventAttributes");var ye={'"':""","<":"<",">":">"},k=a(e=>String(e).replace(/["<>]/g,o=>ye[o]??o),"escapeValue");var X=a((e,o=!0)=>Object.entries(e).map(([r,n])=>typeof n=="object"?`${r}="${JSON.stringify(n)}"`:`${r}="${typeof n=="string"&&o?k(n):n}"`).filter(Boolean).join(" "),"attributesToString");var M={logger:console,stringify:!1,escape:!0};var ae=a(e=>{let o={};for(let[r,n]of Object.entries(e))o[r]=typeof n=="string"?k(n):n;return o},"escapeAttributes");function U(e,o){let r={...M,...o??{}},n={...se(e,r),...ie(e),...te(e)};return r.stringify===!0?X(n,!!r.escape):r.escape===!0?ae(n):n}a(U,"jhx");var Re=a((e,o)=>{for(let[r,n]of Object.entries(o))typeof n=="object"?e.setAttribute(r,JSON.stringify(n)):e.setAttribute(r,String(n))},"applyAttributes");var S=class e extends Error{static{a(this,"JhxServerException")}type;info;method;route;cause;constructor(o,r){super(o),this.name="JhxServerError",this.type=r.type,this.info=r.info||r.cause?.message||o,this.method=r.method,this.route=r.route,this.stack=r.stack,this.cause=r.cause,Object.setPrototypeOf(this,e.prototype)}};import{posix as be}from"path";var A=a((e,o="")=>{let r=String(o).startsWith("/")?String(o):`/${o}`,n=e.trim();n=n.startsWith("/")?n:`/${n}`;let t;try{t=decodeURIComponent(n.startsWith(r)?n:`${r}/${n}`)}catch(s){throw new S("jhx: malformed endpoint",{type:"endpoint:malformed",info:s.message,route:n,cause:s})}let i=be.normalize(t.startsWith("/")?t:`/${t}`);return i.length>1&&i.endsWith("/")&&(i=i.slice(0,-1)),{noSlash:i,withSlash:i==="/"?"/":`${i}/`}},"normalizeEndpoint");var L=a((e,o,r)=>{if(r||(r=new Map),!e)return r;for(let n of e){let t=n.method?.trim()?.toUpperCase()??"GET",{noSlash:i,withSlash:s}=A(n.route,o.prefix);if(o.trailingSlash==="no-slash"){let T=`${t}::${i}`;if(r.has(T))throw new S("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${i}'`,method:t,route:i});r.set(T,n.handler),o.onRegistered(t,i),o.debug&&o.logger.info(`[jhx] Added new route: ${t} ${i}`)}else if(o.trailingSlash==="slash"){let T=`${t}::${s}`;if(r.has(T))throw new S("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${i}'`,method:t,route:i});r.set(T,n.handler),o.onRegistered(t,s),o.debug&&o.logger.info(`[jhx] Added new route: ${t} ${s}`)}else{let T=`${t}::${i}`,g=`${t}::${s}`;if(r.has(T))throw new S("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${i}'`,method:t,route:i});if(r.has(g))throw new S("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${t} '${i}'`,method:t,route:i});r.set(T,n.handler),r.set(g,n.handler),o.onRegistered(t,i),o.debug&&o.logger.info(`[jhx] Added new route: ${t} ${i}`)}}return r},"addRoutesToMap");import{isValidElement as he}from"react";import{renderToStaticMarkup as He,renderToString as Se}from"react-dom/server";var ve=a((e,...o)=>he(e)?He(e):e,"jsxToStatic"),Je=a((e,...o)=>he(e)?Se(e):e,"jsxToString"),Ee=a((e,...o)=>e,"noRender"),xe=a(e=>e?typeof e=="function"?e:e==="static"?ve:e==="string"?Je:Ee:null,"getRenderFunction");var we=["get","post","put","patch","delete","route"],le=a(e=>{for(let o of we)if(o in e){let r=e[o];return o==="route"?{method:"GET",route:typeof r=="string"&&r.trim()||null}:{method:o.toUpperCase(),route:typeof r=="string"&&r.trim()||null}}return{method:"GET",route:null}},"getRouteFromProps");import{createHash as Ce}from"crypto";var de=a(e=>{if(typeof e?.toString!="function")throw new S("jhx: invalid route error",{type:"hash:invalid",info:"Cannot hash function without a 'toString' method"});return Ce("sha256").update(e.toString()).digest("hex").slice(0,12)},"hashFunction");var N=a(e=>{let o=[];if(!e)return o;for(let r of Array.isArray(e)?e:[e]){if(r.method&&r.method.trim()==="")throw new S("jhx: route validation error",{type:"route:invalid-method",info:`Invalid route method: '${r.method}'`,method:String(r.method)});if(!r.route||r.route?.trim()==="")throw new S("jhx: route validation error",{type:"route:invalid-path",info:`Invalid route endpoint: '${r.route}'`,method:r.method?.toUpperCase()??"GET",route:String(r.route)});if(!r.handler||typeof r.handler!="function")throw new S("jhx: route validation error",{type:"route:invalid-handler",info:`Invalid route handler for '${r.method?.toUpperCase()??"GET"} ${r.route}'`,method:r.method?.toUpperCase()??"GET",route:r.route});o.push({method:r.method?.toUpperCase()??"GET",route:r.route,handler:r.handler})}return o},"validateRoutes");var je=a(e=>e.startsWith("hx-")||e in D.attr||e in D.eventAttr||e==="route"||e==="method"||e==="handler","isJhxAttribute"),F=a(e=>a(function(r){let{jhxConfig:n,as:t,children:i,...s}=r,T=t??"div",g={};for(let[y,b]of Object.entries(s))je(y)||(g[y]=b);let R={...e(s,{...n,stringify:!1}),...g};return<T{...R}>{i}</T>},"JhxComponent"),"createJhxComponent");import{isValidElement as Ae}from"react";import{renderToString as $e}from"react-dom/server";var J={...M,contentType:"text/html",debug:!1,middleware:[],onRegistered:a(((e,o)=>{}),"onRegistered"),prefix:"/_jhx",render:a((e,...o)=>Ae(e)?$e(e):e,"render"),renderError:!0,renderMiddleware:!0,renderNotFound:!0,trailingSlash:"both"};var ue=a((e,o,r)=>{let n={contentType:e.contentType===!1?!1:e.contentType??J.contentType,debug:e.debug===J.debug,errorHandler:e.errorHandler,middleware:Array.isArray(e.middleware)?e.middleware:e.middleware?[e.middleware]:J.middleware,notFoundHandler:e.notFoundHandler?e.notFoundHandler:o,onRegistered:e.onRegistered??J.onRegistered,logger:e.logger??J.logger,prefix:e.prefix?A(e.prefix).noSlash:J.prefix,render:typeof e.render=="function"?e.render:xe(e.render===void 0?"string":e.render),renderError:typeof e.renderError=="boolean"?e.renderError:J.renderError,renderMiddleware:typeof e.renderMiddleware=="boolean"?e.renderMiddleware:J.renderMiddleware,renderNotFound:typeof e.renderNotFound=="boolean"?e.renderNotFound:J.renderNotFound,stringify:typeof e.stringify=="boolean"?e.stringify:J.stringify,trailingSlash:e.trailingSlash??J.trailingSlash,instanceOptions:e.instanceOptions},t=e.routes?L(N(e.routes),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash}):new Map;r(n,t);function i(s,T){if(typeof s=="object"&&typeof s.handler=="function"){let{method:R,route:y}=le(s),{noSlash:b,withSlash:v}=A(y||de(s.handler),n.prefix);if(n.trailingSlash==="no-slash"){let E=`${R}::${b}`;t.has(E)||(n.debug&&n.logger.info(`[jhx] Added new route: ${R} ${b}`),t.set(E,s.handler),n.onRegistered(R,b)),s.method=R,s.route=b}else if(n.trailingSlash==="slash"){let E=`${R}::${v}`;t.has(E)||(n.debug&&n.logger.info(`[jhx] Added new route: ${R} ${v}`),t.set(E,s.handler),n.onRegistered(R,v)),s.method=R,s.route=v}else{let E=`${R}::${b}`,I=`${R}::${v}`;!t.has(E)&&!t.has(I)&&(n.debug&&n.logger.info(`[jhx] Added new route: ${R} ${b}`),t.set(E,s.handler),t.set(I,s.handler),n.onRegistered(R,b)),s.method=R,s.route=b}}let g=T?.stringify??n.stringify,H=s&&typeof s=="object"&&"handler"in s?(({handler:R,...y})=>y)(s):s;return g?U(H,{logger:T?.logger??n.logger,stringify:!0}):U(H,{logger:T?.logger??n.logger,stringify:!1})}return a(i,"jhx"),i.addRoute=s=>{L(N({method:s.method,route:s.route,handler:s.handler}),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},t)},i.addRoutes=s=>{L(N(s),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},t)},i.clearRoutes=()=>{let s=t.size;t.clear(),n.debug&&n.logger.info(`[jhx] Cleared ${s} route${s===1?"":"s"}`)},i.getRoute=(s,T)=>{let g=s.trim().toUpperCase(),{noSlash:H,withSlash:R}=A(T,n.prefix);if(n.trailingSlash==="no-slash"){let y=`${g}::${H}`,b=t.get(y);return b?{method:g,route:H,handler:b}:null}else if(n.trailingSlash==="slash"){let y=t.get(`${g}::${R}`);return y?{method:g,route:R,handler:y}:null}else{let y=t.get(`${g}::${H}`),b=t.get(`${g}::${R}`);if(!y&&!b)return null;let v=T.endsWith("/");return{method:g,route:v?b?R:H:y?H:R,handler:v?b??y:y??b}}},i.getRoutes=()=>Array.from(t.entries()).map(([s,T])=>{let[g,H]=s.split("::");return!g||!H?null:{method:g,route:H,handler:T}}).filter(s=>s!==null),i.hasRoute=(s,T)=>{let{noSlash:g,withSlash:H}=A(T,n.prefix);return t.has(`${s.toUpperCase()}::${g}`)||t.has(`${s.toUpperCase()}::${H}`)},i.removeRoute=(s,T)=>{let g=s.trim().toUpperCase(),{noSlash:H,withSlash:R}=A(T,n.prefix),y;return n.trailingSlash==="no-slash"?y=t.delete(`${g}::${H}`):n.trailingSlash==="slash"?y=t.delete(`${g}::${R}`):(y=t.delete(`${g}::${H}`),y=t.delete(`${g}::${R}`)||y),y&&n.debug?n.logger.info(`[jhx] Removed route: ${g} ${n.trailingSlash==="no-slash"?H:n.trailingSlash==="slash"?R:`${H} / ${R}`}`):!y&&n.debug&&n.logger.info(`[jhx] Cannot remove unknown route: ${g} ${n.trailingSlash==="no-slash"?H:n.trailingSlash==="slash"?R:`${H} / ${R}`}`),y},{jhx:i,JhxComponent:F(i)}},"createServerJhx");var qe=a(e=>e?.finalized===!0,"isResponseSent"),P=a(e=>qe(e),"isResponseHandled");import{Stream as Pe}from"node:stream";var De=a(e=>e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Uint8ClampedArray||e instanceof BigUint64Array||typeof ArrayBuffer<"u"&&ArrayBuffer.isView(e)||typeof Buffer<"u"&&e instanceof Buffer,"isArrayBuffer"),Oe=a(e=>e.split("-").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("-"),"capitalize"),B=a((e,o,r)=>{!e.res.headers.get(Oe(o))&&!e.res.headers.get(o.toLowerCase())&&e.res.headers.set(o.toLowerCase(),r)},"ensureHeader"),w=a((e,o)=>o instanceof Response?o:o instanceof Blob?(B(e,"content-type",o.type),B(e,"content-length",String(o.size)),e.body(o)):o instanceof FormData?(B(e,"content-type","multipart/form-data"),new Response(o)):o instanceof ReadableStream||o instanceof Pe||De(o)?(B(e,"content-type","application/octet-stream"),e.body(o)):typeof o=="object"?(B(e,"content-type","application/json"),e.json(o)):e.body(o),"sendPayload");var pe={...J,notFoundHandler:a(e=>e.text("",404),"notFoundHandler")};var us=a((e,o={})=>ue(o,pe.notFoundHandler,(r,n)=>{e.all(`${r.prefix}/*`,async t=>{let i=t.req.method,s=decodeURIComponent(t.req.path),T=n.get(`${i}::${s}`);if(r.contentType&&t.header("content-type",r.contentType),T){for(let R of r.middleware)try{let y=await R(t);if(P(t))return w(t,y);if(y!==void 0){let b=r.render&&r.renderMiddleware?await r.render(y,t):y;return w(t,b)}}catch(y){let b=y;if(r.debug&&r.logger.error(`[jhx] Middleware error from '${i} ${s}': ${b.message}`),r.errorHandler){t.status(500);let v=await r.errorHandler(b,t);if(P(t))return w(t,v);let E=r.render&&r.renderError?await r.render(v,t):v;return w(t,E)}throw new S("Unhandled middleware error",{type:"middleware:error",method:i,route:s,cause:b})}try{let R=await T(t);if(P(t))return w(t,R);let y=r.render?await r.render(R,t):R;return w(t,y)}catch(R){let y=R;if(r.debug&&r.logger.error(`[jhx] Route error from '${i} ${s}': ${y.message}`),r.errorHandler){t.status(500);let b=await r.errorHandler(y,t);if(P(t))return w(t,b);let v=r.render&&r.renderError?await r.render(b,t):b;return w(t,v)}throw new S("[jhx] Unhandled endpoint or rendering error",{type:"handler:error",method:i,route:s,cause:y})}}r.debug&&r.logger.info(`[jhx] Request to unknown route '${i} ${s}'`),t.status(404);let g=await r.notFoundHandler(t);if(P(t))return w(t,g);let H=r.render&&r.renderNotFound?await r.render(g,t):g;return w(t,H)})}),"createJhx");function cs(e){return F(e)}a(cs,"createJhxComponent");export{Re as applyAttributes,X as attributesToString,us as createJhx,cs as createJhxComponent,pe as defaultConfig,D as htmx};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jhxdev/hono",
|
|
3
3
|
"description": "HTMX helper with type-safe attribute mapping with inline Hono route declaration. Converts props into `hx-*` attributes for templating.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"author": "nick-hio",
|
|
6
6
|
"homepage": "https://github.com/nick-hio/jhx/tree/main/packages/hono#readme",
|
|
7
7
|
"repository": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"jhx": "^0.1.
|
|
45
|
+
"jhx": "^0.1.5"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"hono": "^4",
|