diff --git a/CHANGELOG.md b/CHANGELOG.md
index f46e954..b04e43e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+## [4.4.1] - 2024-08-05
+
+### Fixed
+
+- Prevent empty string from being passed to getElementById() when the route does not have own templateId by @Aramics #40
+
## [4.4.0] - 2024-07-10
### Added
@@ -357,3 +363,4 @@ It's mostly backward compatible but need a few tweaks:
[4.3.1]: https://github.com/pinecone-router/router/compare/4.3.0..4.3.1
[4.3.2]: https://github.com/pinecone-router/router/compare/4.3.1..4.3.2
[4.4.0]: https://github.com/pinecone-router/router/compare/4.3.2..4.4.0
+[4.4.1]: https://github.com/pinecone-router/router/compare/4.4.0..4.4.1
diff --git a/README.md b/README.md
index 9b4e204..f08d86e 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/pinecone-router/router?color=%2337C8AB&label=version&sort=semver)](https://github.com/pinecone-router/router/tree/4.4.0)
-[![npm bundle size](https://img.shields.io/bundlephobia/minzip/pinecone-router?color=37C8AB)](https://bundlephobia.com/result?p=pinecone-router@4.4.0)
+[![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/pinecone-router/router?color=%2337C8AB&label=version&sort=semver)](https://github.com/pinecone-router/router/tree/4.4.)
+[![npm bundle size](https://img.shields.io/bundlephobia/minzip/pinecone-router?color=37C8AB)](https://bundlephobia.com/result?p=pinecone-router@4.4.1)
[![Downloads from JSDelivr](https://data.jsdelivr.com/v1/package/npm/pinecone-router/badge?style=rounded)](https://www.jsdelivr.com/package/npm/pinecone-router)
[![npm](https://img.shields.io/npm/dm/pinecone-router?color=37C8AB&label=npm&logo=npm&logoColor=37C8AB)](https://npmjs.com/package/pinecone-router)
[![Changelog](https://img.shields.io/badge/change-log-%2337C8AB)](/CHANGELOG.md)
diff --git a/dist/router.esm.js b/dist/router.esm.js
index 0ab2c56..9cdd024 100644
--- a/dist/router.esm.js
+++ b/dist/router.esm.js
@@ -1,2 +1,2 @@
-var M=class{params={};path;handlers=[];constructor(o,f={}){this.path=o,Object.keys(f).forEach(u=>{this[u]=f[u]}),f.template&&(this.programmaticTemplate=!0)}template="";templateTargetId="";programmaticTemplate=!1;handlersDone=!1;cancelHandlers},C=M;function L(i){return i.replace(/(^\/+|\/+$)/g,"").split("/")}function k(i,o){let f=/(?:\?([^#]*))?(#.*)?$/,u=i.match(f),w={},_;if(u&&u[1]){let d=u[1].split("&");for(let x=0;xr.path==e)!=null)throw new Error("Pinecone Router: route already exist");return this.routes.push(new C(e,n))-1},remove(e){this.routes=this.routes.filter(n=>n.path!=e)},loadStart:new Event("pinecone-start"),loadEnd:new Event("pinecone-end")});window.PineconeRouter=o;var f={},u={};let w=new Set;var _={};let P=(e,n,r=!1)=>(f[n]&&!r?f[n].then(t=>e.innerHTML=t):f[n]=fetch(n).then(t=>t.ok?t.text():(D(t.statusText),null)).then(t=>t==null?(u[n]=null,f[n]=null,null):(u[n]=t,e.innerHTML=t,t)),f[n]),m=(e,n,r)=>{if(w.has(n))return;w.add(n);let t=e.content.cloneNode(!0).firstElementChild;t&&(i.addScopeToNode(t,{},e),i.mutateDom(()=>{r!=null?r.appendChild(t):e.after(t),i.initTree(t)}),e._x_PineconeRouter_CurrentTemplate=t,e._x_PineconeRouter_undoTemplate=()=>{t.remove(),delete e._x_PineconeRouter_CurrentTemplate},i.nextTick(()=>w.delete(n)))};function E(e){e._x_PineconeRouter_undoTemplate&&(e._x_PineconeRouter_undoTemplate(),delete e._x_PineconeRouter_undoTemplate)}function d(e,n,r,t){if(e._x_PineconeRouter_CurrentTemplate)return e._x_PineconeRouter_CurrentTemplate;e.content.firstElementChild?(m(e,n,t),l()):r&&(u[r]?(e.innerHTML=u[r],m(e,n,t),l()):_[r]?_[r].then(()=>m(e,n,t)):P(e,r).then(()=>m(e,n,t)).finally(()=>l()))}let x=()=>{document.dispatchEvent(o.loadStart)},l=()=>{document.dispatchEvent(o.loadEnd)},y=e=>!o.settings.hash&&o.settings.basePath!="/"?o.settings.basePath+e:e,R=e=>o.routes.findIndex(n=>n.path==e);i.directive("route",(e,{expression:n,modifiers:r},{effect:t,cleanup:s})=>{let a=n;if(T("onBeforeRouteProcessed",e,a),a.indexOf("#")>-1)throw new Error("Pinecone Router: A route's path may not have a hash character.");let c=I(r,"target",null)??window.PineconeRouter.settings.templateTargetId,h=document.getElementById(c);if(c&&!h)throw new Error("Pinecone Router: Can't find an element with the suplied target ID: "+c);let p=null;a!="notfound"&&(a=y(a),p=o.add(a));let v=o.routes[p]??o.notfound;e._x_PineconeRouter_route=a,e.content.firstElementChild!=null&&i.nextTick(()=>{t(()=>{v.handlersDone&&o.context.route==a?d(e,n,null,h):E(e)})}),s(()=>{e._x_PineconeRouter_undoTemplate&&e._x_PineconeRouter_undoTemplate(),o.remove(a),delete e._x_PineconeRouter_route}),T("onAfterRouteProcessed",e,a)}),i.directive("handler",(e,{expression:n},{evaluate:r,cleanup:t})=>{if(!e._x_PineconeRouter_route)throw new Error("Pinecone Router: x-handler must be set on the same element as x-route.");let s;!(n.startsWith("[")&&n.endsWith("]"))&&!(n.startsWith("Array(")&&n.endsWith(")"))&&(n=`[${n}]`);let a=r(n);if(typeof a=="object")s=a;else throw new Error(`Pinecone Router: Invalid handler type: ${typeof a}.`);for(let p=0;p{h.handlers=[],h.handlersDone=!0,h.cancelHandlers=!1})}),i.directive("template",(e,{modifiers:n,expression:r},{Alpine:t,effect:s,cleanup:a})=>{if(!e._x_PineconeRouter_route)throw new Error("Pinecone Router: x-template must be used on the same element as x-route.");if(e.content.firstElementChild!=null)throw new Error("Pinecone Router: x-template cannot be used alongside an inline template (template element should not have a child).");let c=r,h=I(n,"target",null)??window.PineconeRouter.settings.templateTargetId,p=document.getElementById(h);if(h&&!p)throw new Error("Pinecone Router: Can't find an element with the suplied target ID: "+h);n.includes("preload")&&(_[c]=P(e,c).finally(()=>{_[c]=null,l()}));let v=e._x_PineconeRouter_route,H=v=="notfound"?o.notfound:o.routes[R(v)];H.template=c,t.nextTick(()=>{s(()=>{H.handlersDone&&o.context.route==H.path?d(e,r,c,p):E(e)})}),a(()=>{e._x_PineconeRouter_undoTemplate&&e._x_PineconeRouter_undoTemplate()})}),i.$router=o.context,i.magic("router",()=>o.context),document.addEventListener("alpine:initialized",()=>{T("init"),o.settings.hash==!1?g(location.pathname,!1,!0):g(location.hash.substring(1),!1,!0)}),window.addEventListener("popstate",()=>{o.settings.hash?window.location.hash!=""&&g(window.location.hash.substring(1),!0):g(window.location.pathname,!0)}),b();function b(){function e(n){if(!n||!n.getAttribute)return;let r=n.getAttribute("href"),t=n.getAttribute("target");if(!(!r||!r.match(/^\//g)||t&&!t.match(/^_?self$/i)))return typeof r!="string"&&r.url&&(r=r.url),r}window.document.body.addEventListener("click",function(n){if(n.ctrlKey||n.metaKey||n.altKey||n.shiftKey||n.button||n.defaultPrevented)return;let r=o.routes[R(o.context.route)]??o.notfound;r.handlersDone||(r.cancelHandlers=!0,l());let t=n.target;do if(t.localName==="a"&&t.getAttribute("href")){if(window.PineconeRouter.settings.interceptLinks==!1&&!t.hasAttribute("x-link")||t.hasAttribute("data-native")||t.hasAttribute("native"))return;let s=e(t);s&&(g(s),n.stopImmediatePropagation&&n.stopImmediatePropagation(),n.stopPropagation&&n.stopPropagation(),n.preventDefault());break}while(t=t.parentNode)})}async function g(e,n=!1,r=!1){e||(e="/"),o.context.path=e,o.settings.hash||(o.settings.basePath!="/"&&!e.startsWith(o.settings.basePath)&&(e=o.settings.basePath+e),e==o.settings.basePath&&!e.endsWith("/")&&(e+="/"));let t=o.routes.find(a=>{let c=k(e,a.path);return a.params=c!=!1?c:{},c!=!1})??o.notfound;t.handlersDone=!t.handlers.length,(t.handlers.length||t.template)&&x();let s=$(t.path,e,t.params);if(o.context=s,T("onBeforeHandlersExecuted",t,e,r)=="stop"){l();return}if(!n){let a="";if(o.settings.hash?(a="#",a+=window.location.search+e):a=e+window.location.search+window.location.hash,!r)history.pushState({path:a},"",a);else if(o.settings.hash&&e=="/")return o.context=s,g("/",!1,!1)}if(t&&t.handlers.length){if(t.cancelHandlers=!1,!await W(t.handlers,s)){l();return}t.handlersDone=!0,t.template||l()}if(t.template&&t.programmaticTemplate){let a=document.getElementById(t.templateTargetId)??document.getElementById(o.settings.templateTargetId);u[t.template]?(a.innerHTML=u[t.template],l()):P(a,t.template).then(()=>{l()})}T("onHandlersExecuted",t,e,r)}function $(e,n,r){return{route:e,path:n,params:r,query:window.location.search.substring(1),hash:window.location.hash.substring(1),redirect(t){return g(t),"stop"},navigate(t){g(t)}}}function I(e,n,r){if(e.indexOf(n)===-1)return r;let t=e[e.indexOf(n)+1];if(!t)return r;if(n==="target"){let s=t.match(/([a-z0-9_-]+)/);if(s)return s[1]}return t}async function W(e,n){for(let r=0;r{this[u]=f[u]}),f.template&&(this.programmaticTemplate=!0)}template="";templateTargetId="";programmaticTemplate=!1;handlersDone=!1;cancelHandlers},M=I;function L(i){return i.replace(/(^\/+|\/+$)/g,"").split("/")}function k(i,o){let f=/(?:\?([^#]*))?(#.*)?$/,u=i.match(f),w={},_;if(u&&u[1]){let d=u[1].split("&");for(let x=0;xr.path==e)!=null)throw new Error("Pinecone Router: route already exist");return this.routes.push(new M(e,n))-1},remove(e){this.routes=this.routes.filter(n=>n.path!=e)},loadStart:new Event("pinecone-start"),loadEnd:new Event("pinecone-end")});window.PineconeRouter=o;var f={},u={};let w=new Set;var _={};let P=(e,n,r=!1)=>(f[n]&&!r?f[n].then(t=>e.innerHTML=t):f[n]=fetch(n).then(t=>t.ok?t.text():(D(t.statusText),null)).then(t=>t==null?(u[n]=null,f[n]=null,null):(u[n]=t,e.innerHTML=t,t)),f[n]),m=(e,n,r)=>{if(w.has(n))return;w.add(n);let t=e.content.cloneNode(!0).firstElementChild;t&&(i.addScopeToNode(t,{},e),i.mutateDom(()=>{r!=null?r.appendChild(t):e.after(t),i.initTree(t)}),e._x_PineconeRouter_CurrentTemplate=t,e._x_PineconeRouter_undoTemplate=()=>{t.remove(),delete e._x_PineconeRouter_CurrentTemplate},i.nextTick(()=>w.delete(n)))};function E(e){e._x_PineconeRouter_undoTemplate&&(e._x_PineconeRouter_undoTemplate(),delete e._x_PineconeRouter_undoTemplate)}function d(e,n,r,t){if(e._x_PineconeRouter_CurrentTemplate)return e._x_PineconeRouter_CurrentTemplate;e.content.firstElementChild?(m(e,n,t),l()):r&&(u[r]?(e.innerHTML=u[r],m(e,n,t),l()):_[r]?_[r].then(()=>m(e,n,t)):P(e,r).then(()=>m(e,n,t)).finally(()=>l()))}let x=()=>{document.dispatchEvent(o.loadStart)},l=()=>{document.dispatchEvent(o.loadEnd)},y=e=>!o.settings.hash&&o.settings.basePath!="/"?o.settings.basePath+e:e,R=e=>o.routes.findIndex(n=>n.path==e);i.directive("route",(e,{expression:n,modifiers:r},{effect:t,cleanup:s})=>{let a=n;if(T("onBeforeRouteProcessed",e,a),a.indexOf("#")>-1)throw new Error("Pinecone Router: A route's path may not have a hash character.");let c=C(r,"target",null)??window.PineconeRouter.settings.templateTargetId,h=document.getElementById(c);if(c&&!h)throw new Error("Pinecone Router: Can't find an element with the suplied target ID: "+c);let p=null;a!="notfound"&&(a=y(a),p=o.add(a));let v=o.routes[p]??o.notfound;e._x_PineconeRouter_route=a,e.content.firstElementChild!=null&&i.nextTick(()=>{t(()=>{v.handlersDone&&o.context.route==a?d(e,n,null,h):E(e)})}),s(()=>{e._x_PineconeRouter_undoTemplate&&e._x_PineconeRouter_undoTemplate(),o.remove(a),delete e._x_PineconeRouter_route}),T("onAfterRouteProcessed",e,a)}),i.directive("handler",(e,{expression:n},{evaluate:r,cleanup:t})=>{if(!e._x_PineconeRouter_route)throw new Error("Pinecone Router: x-handler must be set on the same element as x-route.");let s;!(n.startsWith("[")&&n.endsWith("]"))&&!(n.startsWith("Array(")&&n.endsWith(")"))&&(n=`[${n}]`);let a=r(n);if(typeof a=="object")s=a;else throw new Error(`Pinecone Router: Invalid handler type: ${typeof a}.`);for(let p=0;p{h.handlers=[],h.handlersDone=!0,h.cancelHandlers=!1})}),i.directive("template",(e,{modifiers:n,expression:r},{Alpine:t,effect:s,cleanup:a})=>{if(!e._x_PineconeRouter_route)throw new Error("Pinecone Router: x-template must be used on the same element as x-route.");if(e.content.firstElementChild!=null)throw new Error("Pinecone Router: x-template cannot be used alongside an inline template (template element should not have a child).");let c=r,h=C(n,"target",null)??window.PineconeRouter.settings.templateTargetId,p=document.getElementById(h);if(h&&!p)throw new Error("Pinecone Router: Can't find an element with the suplied target ID: "+h);n.includes("preload")&&(_[c]=P(e,c).finally(()=>{_[c]=null,l()}));let v=e._x_PineconeRouter_route,H=v=="notfound"?o.notfound:o.routes[R(v)];H.template=c,t.nextTick(()=>{s(()=>{H.handlersDone&&o.context.route==H.path?d(e,r,c,p):E(e)})}),a(()=>{e._x_PineconeRouter_undoTemplate&&e._x_PineconeRouter_undoTemplate()})}),i.$router=o.context,i.magic("router",()=>o.context),document.addEventListener("alpine:initialized",()=>{T("init"),o.settings.hash==!1?g(location.pathname,!1,!0):g(location.hash.substring(1),!1,!0)}),window.addEventListener("popstate",()=>{o.settings.hash?window.location.hash!=""&&g(window.location.hash.substring(1),!0):g(window.location.pathname,!0)}),b();function b(){function e(n){if(!n||!n.getAttribute)return;let r=n.getAttribute("href"),t=n.getAttribute("target");if(!(!r||!r.match(/^\//g)||t&&!t.match(/^_?self$/i)))return typeof r!="string"&&r.url&&(r=r.url),r}window.document.body.addEventListener("click",function(n){if(n.ctrlKey||n.metaKey||n.altKey||n.shiftKey||n.button||n.defaultPrevented)return;let r=o.routes[R(o.context.route)]??o.notfound;r.handlersDone||(r.cancelHandlers=!0,l());let t=n.target;do if(t.localName==="a"&&t.getAttribute("href")){if(window.PineconeRouter.settings.interceptLinks==!1&&!t.hasAttribute("x-link")||t.hasAttribute("data-native")||t.hasAttribute("native"))return;let s=e(t);s&&(g(s),n.stopImmediatePropagation&&n.stopImmediatePropagation(),n.stopPropagation&&n.stopPropagation(),n.preventDefault());break}while(t=t.parentNode)})}async function g(e,n=!1,r=!1){e||(e="/"),o.context.path=e,o.settings.hash||(o.settings.basePath!="/"&&!e.startsWith(o.settings.basePath)&&(e=o.settings.basePath+e),e==o.settings.basePath&&!e.endsWith("/")&&(e+="/"));let t=o.routes.find(a=>{let c=k(e,a.path);return a.params=c!=!1?c:{},c!=!1})??o.notfound;t.handlersDone=!t.handlers.length,(t.handlers.length||t.template)&&x();let s=$(t.path,e,t.params);if(o.context=s,T("onBeforeHandlersExecuted",t,e,r)=="stop"){l();return}if(!n){let a="";if(o.settings.hash?(a="#",a+=window.location.search+e):a=e+window.location.search+window.location.hash,!r)history.pushState({path:a},"",a);else if(o.settings.hash&&e=="/")return o.context=s,g("/",!1,!1)}if(t&&t.handlers.length){if(t.cancelHandlers=!1,!await W(t.handlers,s)){l();return}t.handlersDone=!0,t.template||l()}if(t.template&&t.programmaticTemplate){let a=t.templateTargetId?document.getElementById(t.templateTargetId):document.getElementById(o.settings.templateTargetId);u[t.template]?(a.innerHTML=u[t.template],l()):P(a,t.template).then(()=>{l()})}T("onHandlersExecuted",t,e,r)}function $(e,n,r){return{route:e,path:n,params:r,query:window.location.search.substring(1),hash:window.location.hash.substring(1),redirect(t){return g(t),"stop"},navigate(t){g(t)}}}function C(e,n,r){if(e.indexOf(n)===-1)return r;let t=e[e.indexOf(n)+1];if(!t)return r;if(n==="target"){let s=t.match(/([a-z0-9_-]+)/);if(s)return s[1]}return t}async function W(e,n){for(let r=0;r {\n\t\t\tthis[opt] = options[opt]\n\t\t})\n\t\tif (options.template) {\n\t\t\tthis.programmaticTemplate = true\n\t\t}\n\t}\n\ttemplate: string = ''\n\ttemplateTargetId: string = ''\n\tprogrammaticTemplate: boolean = false\n\thandlersDone: boolean = false\n\tcancelHandlers: boolean\n}\n\nexport default Route\n", "/**\n * taken from preact-router\n * https://github.com/preactjs/preact-router\n * @param url url to segmentize\n * @returns\n */\nfunction segmentize(url: string): string[] {\n\treturn url.replace(/(^\\/+|\\/+$)/g, '').split('/')\n}\n\n/**\n * check if a path match with this route\n * taken from preact-router\n * https://github.com/preactjs/preact-router\n * @param path {string}\n * @param routePath {string}\n * @returns {false|object}\n */\nexport function match(url: string, routePath: string): false | object {\n\tlet reg = /(?:\\?([^#]*))?(#.*)?$/,\n\t\tc = url.match(reg),\n\t\tmatches: any = {},\n\t\tret\n\tif (c && c[1]) {\n\t\tlet p = c[1].split('&')\n\t\tfor (let i = 0; i < p.length; i++) {\n\t\t\tlet r = p[i].split('=')\n\t\t\tmatches[decodeURIComponent(r[0])] = decodeURIComponent(\n\t\t\t\tr.slice(1).join('=')\n\t\t\t)\n\t\t}\n\t}\n\tlet urlSeg = segmentize(url.replace(reg, '')),\n\t\troute: string[] = segmentize(routePath || ''),\n\t\tmax = Math.max(urlSeg.length, route.length)\n\tfor (let i = 0; i < max; i++) {\n\t\tif (route[i] && route[i].charAt(0) === ':') {\n\t\t\tlet param: string = route[i].replace(/(^:|[+*?]+$)/g, ''),\n\t\t\t\tflags: string = (route[i].match(/[+*?]+$/) || {}).toString()[0],\n\t\t\t\tplus = ~flags.indexOf('+'),\n\t\t\t\tstar = ~flags.indexOf('*'),\n\t\t\t\tval = urlSeg[i] || ''\n\t\t\tif (!val && !star && (flags.indexOf('?') < 0 || plus)) {\n\t\t\t\tret = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tmatches[param] = decodeURIComponent(val)\n\t\t\tif (plus || star) {\n\t\t\t\tmatches[param] = urlSeg\n\t\t\t\t\t.slice(i)\n\t\t\t\t\t.map(decodeURIComponent)\n\t\t\t\t\t.join('/')\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else if (route[i] !== urlSeg[i]) {\n\t\t\tret = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif (ret === false) return false\n\treturn matches\n}\n\n/**\n * Call a function on all middlewares loaded, if any.\n * @param {string} func middleware function to call.\n * @param {any} args arguments to pass to the function.\n * @returns {boolean} false if the middleware function return false, i.e. it want to stop execution of the function and return.\n */\nexport function middleware(func: string, ...args: any): string | undefined {\n\tif (!window.PineconeRouterMiddlewares) return\n\tfor (const i in window.PineconeRouterMiddlewares) {\n\t\tlet plugin: any = window.PineconeRouterMiddlewares[i]\n\t\tif (plugin[func] == null) return\n\t\tlet ret = plugin[func](...args)\n\t\t// the return of the function will only be 'stop'\n\t\t// if the middleware request stopping the navigate function.\n\t\tif (ret == 'stop') return 'stop'\n\t}\n}\n\nexport function fetchError(error: string) {\n\tdocument.dispatchEvent(\n\t\tnew CustomEvent('fetch-error', { detail: error })\n\t)\n}", "import Route from './route'\nimport type { Settings, Context, Middleware, Handler } from './types'\nimport { fetchError, match, middleware } from './utils'\n\n\ndeclare global {\n\tinterface Window {\n\t\tPineconeRouter: {\n\t\t\tversion: string\n\t\t\tname: string\n\t\t\tsettings: Settings\n\t\t\tnotfound: Route\n\t\t\troutes: Route[]\n\t\t\tcontext: Context\n\t\t\tloadStart: Event\n\t\t\tloadEnd: Event\n\t\t\tadd: (path: string, options?: {}) => number\n\t\t\tremove: (path: string) => void\n\t\t}\n\t\tPineconeRouterMiddlewares: Array\n\t}\n\tinterface HTMLTemplateElement {\n\t\t_x_PineconeRouter_undoTemplate: Function\n\t\t_x_PineconeRouter_CurrentTemplate: Element\n\t\t_x_PineconeRouter_route: string\n\t}\n}\n\nexport default function (Alpine) {\n\n\tconst PineconeRouter = Alpine.reactive({\n\t\tversion: '4.4.0',\n\t\tname: 'pinecone-router',\n\n\t\tsettings: {\n\t\t\thash: false,\n\t\t\tbasePath: '/',\n\t\t\ttemplateTargetId: null,\n\t\t\tinterceptLinks: true\n\t\t},\n\n\t\t/**\n\t\t * @description The handler for 404 pages, can be overwritten by a notfound route\n\t\t */\n\t\tnotfound: new Route('notfound'),\n\n\t\t/**\n\t\t * @type Route[]\n\t\t * @summary array of routes instantiated from the Route class.\n\t\t */\n\t\troutes: [],\n\n\t\t/**\n\t\t * @type {Context}\n\t\t * @summary The context object for current path.\n\t\t */\n\t\tcontext: {\n\t\t\troute: '',\n\t\t\tpath: '',\n\t\t\tparams: {},\n\t\t\tquery: window.location.search.substring(1),\n\t\t\thash: window.location.hash.substring(1),\n\t\t\tredirect(path) {\n\t\t\t\tnavigate(path)\n\t\t\t\treturn 'stop'\n\t\t\t},\n\t\t\tnavigate(path) {\n\t\t\t\tnavigate(path)\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Add a new route\n\t\t */\n\t\tadd(path: string, options?: {}) {\n\t\t\t// check if the route was registered on the same router.\n\t\t\tif (this.routes.find((r: Route) => r.path == path) != null) {\n\t\t\t\tthrow new Error('Pinecone Router: route already exist')\n\t\t\t}\n\n\t\t\treturn this.routes.push(new Route(path, options)) - 1\n\t\t},\n\t\t/**\n\t\t * Remove a route\n\t\t */\n\t\tremove(path: string) {\n\t\t\tthis.routes = this.routes.filter((r: Route) => r.path != path)\n\t\t},\n\t\t/**\n\t\t * @event pinecone-start\n\t\t * @summary be dispatched to the window after before page start loading.\n\t\t */\n\t\tloadStart: new Event('pinecone-start'),\n\n\t\t/**\n\t\t * @event pinecone-end\n\t\t * @summary will be dispatched to the window after the views are fetched\n\t\t */\n\t\tloadEnd: new Event('pinecone-end'),\n\t})\n\n\twindow.PineconeRouter = PineconeRouter\n\n\tvar loadingTemplates: { [key: string]: Promise } = {}\n\tvar cachedTemplates: { [key: string]: string } = {}\n\tconst inMakeProgress = new Set()\n\tvar preloadingTemplates: { [key: string]: Promise } = {}\n\n\tconst load = (el: HTMLTemplateElement | HTMLElement, url: string, programmaticRoute: boolean = false) => {\n\t\tif (loadingTemplates[url] && !programmaticRoute) {\n\t\t\tloadingTemplates[url].then(html => el.innerHTML = html)\n\t\t} else {\n\t\t\tloadingTemplates[url] = fetch(url).then(r => {\n\t\t\t\tif (!r.ok) {\n\t\t\t\t\tfetchError(r.statusText);\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\treturn r.text()\n\t\t\t}).then(html => {\n\t\t\t\tif (html == null) {\n\t\t\t\t\tcachedTemplates[url] = null;\n\t\t\t\t\tloadingTemplates[url] = null\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tcachedTemplates[url] = html\n\t\t\t\tel.innerHTML = html\n\t\t\t\treturn html\n\t\t\t})\n\t\t}\n\t\treturn loadingTemplates[url]\n\t}\n\n\tconst make = (el: HTMLTemplateElement, expression: string, targetEl?: HTMLElement) => {\n\t\tif (inMakeProgress.has(expression)) return\n\t\tinMakeProgress.add(expression)\n\n\t\tconst clone = (el.content.cloneNode(true) as HTMLElement).firstElementChild\n\n\t\tif (!clone) return\n\n\t\tAlpine.addScopeToNode(clone, {}, el)\n\n\t\tAlpine.mutateDom(() => {\n\t\t\tif (targetEl != null) {\n\t\t\t\ttargetEl.appendChild(clone)\n\t\t\t} else\n\t\t\t\tel.after(clone)\n\t\t\tAlpine.initTree(clone)\n\t\t})\n\n\t\tel._x_PineconeRouter_CurrentTemplate = clone\n\n\t\tel._x_PineconeRouter_undoTemplate = () => {\n\t\t\tclone.remove()\n\n\t\t\tdelete el._x_PineconeRouter_CurrentTemplate\n\t\t}\n\n\t\tAlpine.nextTick(() => inMakeProgress.delete(expression))\n\t}\n\n\tfunction hide(el: HTMLTemplateElement) {\n\t\tif (el._x_PineconeRouter_undoTemplate) {\n\t\t\tel._x_PineconeRouter_undoTemplate()\n\t\t\tdelete el._x_PineconeRouter_undoTemplate\n\t\t}\n\t}\n\n\tfunction show(el: HTMLTemplateElement, expression: string, url?: string, targetEl?: HTMLElement) {\n\t\tif (el._x_PineconeRouter_CurrentTemplate) return el._x_PineconeRouter_CurrentTemplate\n\t\tif (el.content.firstElementChild) {\n\t\t\tmake(el, expression, targetEl)\n\t\t\tendLoading()\n\t\t} else if (url) {\n\t\t\t// Since during loading, the content is automatically put inside the template\n\t\t\t// This first case will only happen if the content of the template was cleared somehow\n\t\t\t// Likely manually\n\t\t\tif (cachedTemplates[url]) {\n\n\t\t\t\tel.innerHTML = cachedTemplates[url]\n\t\t\t\tmake(el, expression, targetEl)\n\t\t\t\tendLoading()\n\t\t\t} else {\n\t\t\t\t// This second case is that it didn't finish loading\n\t\t\t\tif (preloadingTemplates[url]) {\n\t\t\t\t\tpreloadingTemplates[url].then(() => make(el, expression, targetEl))\n\t\t\t\t} else {\n\t\t\t\t\tload(el, url).then(() => make(el, expression, targetEl)).finally(() => endLoading())\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst startLoading = () => {\n\t\tdocument.dispatchEvent(PineconeRouter.loadStart)\n\t}\n\n\tconst endLoading = () => {\n\t\tdocument.dispatchEvent(PineconeRouter.loadEnd)\n\t}\n\n\tconst addBasePath = (path) => {\n\t\tif (!PineconeRouter.settings.hash && PineconeRouter.settings.basePath != '/') {\n\t\t\treturn PineconeRouter.settings.basePath + path\n\t\t} return path\n\t}\n\n\tconst findRouteIndex = (path) => {\n\t\treturn PineconeRouter.routes.findIndex(\n\t\t\t(r) => r.path == path\n\t\t)\n\t}\n\n\tAlpine.directive(\n\t\t'route',\n\t\t(el: HTMLTemplateElement, { expression, modifiers }, { effect, cleanup }) => {\n\t\t\tlet path = expression\n\n\t\t\tmiddleware('onBeforeRouteProcessed', el, path)\n\n\t\t\tif (path.indexOf('#') > -1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Pinecone Router: A route's path may not have a hash character.`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tlet target = modifierValue(modifiers, 'target', null) ?? window.PineconeRouter.settings.templateTargetId\n\t\t\tlet targetEl = document.getElementById(target)\n\t\t\tif (target && !targetEl)\n\t\t\t\tthrow new Error(\"Pinecone Router: Can't find an element with the suplied target ID: \" + target + \"\")\n\n\t\t\tlet routeIndex = null\n\n\t\t\tif (path != 'notfound') {\n\t\t\t\t// if specified add the basePath\n\t\t\t\tpath = addBasePath(path)\n\t\t\t\t// register the new route if possible\n\t\t\t\trouteIndex = PineconeRouter.add(path)\n\t\t\t}\n\n\t\t\tlet route = PineconeRouter.routes[routeIndex] ?? PineconeRouter.notfound\n\n\t\t\t// set the path in the element so it is used by other directives\n\t\t\tel._x_PineconeRouter_route = path\n\n\t\t\tif (el.content.firstElementChild != null) {\n\t\t\t\tAlpine.nextTick(() => {\n\t\t\t\t\teffect(() => {\n\t\t\t\t\t\tlet found = route.handlersDone && PineconeRouter.context.route == path\n\t\t\t\t\t\tfound ? show(el, expression, null, targetEl) : hide(el)\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tcleanup(() => {\n\t\t\t\tel._x_PineconeRouter_undoTemplate && el._x_PineconeRouter_undoTemplate();\n\t\t\t\tPineconeRouter.remove(path);\n\t\t\t\tdelete el._x_PineconeRouter_route\n\t\t\t})\n\n\t\t\tmiddleware('onAfterRouteProcessed', el, path)\n\n\n\t\t}\n\t)\n\n\tAlpine.directive(\n\t\t'handler',\n\t\t(\n\t\t\tel,\n\t\t\t{ expression },\n\t\t\t{ evaluate, cleanup }\n\t\t) => {\n\t\t\tif (!el._x_PineconeRouter_route) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Pinecone Router: x-handler must be set on the same element as x-route.`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tlet handlers\n\n\t\t\t// check if the handlers expression is an array\n\t\t\t// if not make it one\n\t\t\tif (\n\t\t\t\t!(expression.startsWith('[') && expression.endsWith(']')) &&\n\t\t\t\t!(expression.startsWith('Array(') && expression.endsWith(')'))\n\t\t\t) {\n\t\t\t\texpression = `[${expression}]`\n\t\t\t}\n\n\t\t\tlet evaluatedExpression = evaluate(expression)\n\n\t\t\tif (typeof evaluatedExpression == 'object')\n\t\t\t\thandlers = evaluatedExpression\n\t\t\telse {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Pinecone Router: Invalid handler type: ${typeof evaluatedExpression}.`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// add `this` context for handlers inside an Alpine.component\n\t\t\tfor (let index = 0; index < handlers.length; index++) {\n\t\t\t\thandlers[index] = handlers[index].bind(Alpine.$data(el))\n\t\t\t}\n\n\t\t\t// add handlers to the route\n\t\t\tlet path = el._x_PineconeRouter_route\n\t\t\tlet route = path == 'notfound' ? PineconeRouter.notfound : PineconeRouter.routes[findRouteIndex(path)];\n\t\t\troute.handlers = handlers\n\n\t\t\tcleanup(() => {\n\t\t\t\troute.handlers = []\n\t\t\t\troute.handlersDone = true\n\t\t\t\troute.cancelHandlers = false\n\t\t\t})\n\t\t}\n\t)\n\n\tAlpine.directive(\n\t\t'template',\n\t\t(el: HTMLTemplateElement, { modifiers, expression }, { Alpine, effect, cleanup }) => {\n\n\t\t\tif (!el._x_PineconeRouter_route) throw new Error(\"Pinecone Router: x-template must be used on the same element as x-route.\")\n\n\t\t\tif (el.content.firstElementChild != null) throw new Error(\"Pinecone Router: x-template cannot be used alongside an inline template (template element should not have a child).\")\n\n\t\t\tlet url: string = expression\n\n\t\t\tlet target = modifierValue(modifiers, 'target', null) ?? window.PineconeRouter.settings.templateTargetId\n\t\t\tlet targetEl = document.getElementById(target)\n\n\t\t\tif (target && !targetEl)\n\t\t\t\tthrow new Error(\"Pinecone Router: Can't find an element with the suplied target ID: \" + target + \"\")\n\n\t\t\tif (modifiers.includes(\"preload\")) {\n\t\t\t\tpreloadingTemplates[url] = load(el, url).finally(() => {\n\t\t\t\t\tpreloadingTemplates[url] = null;\n\t\t\t\t\tendLoading()\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// add template to the route\n\t\t\tlet path = el._x_PineconeRouter_route\n\t\t\tlet route = path == 'notfound' ? PineconeRouter.notfound : PineconeRouter.routes[findRouteIndex(path)];\n\t\t\troute.template = url\n\n\n\t\t\tAlpine.nextTick(() => {\n\t\t\t\teffect(() => {\n\t\t\t\t\tlet found = route.handlersDone && PineconeRouter.context.route == route.path\n\t\t\t\t\tfound ? show(el, expression, url, targetEl) : hide(el)\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tcleanup(() => {\n\t\t\t\tel._x_PineconeRouter_undoTemplate && el._x_PineconeRouter_undoTemplate();\n\t\t\t})\n\n\t\t}\n\t)\n\n\tAlpine.$router = PineconeRouter.context\n\tAlpine.magic('router', () => PineconeRouter.context)\n\n\tdocument.addEventListener('alpine:initialized', () => {\n\t\tmiddleware('init')\n\t\t// virtually navigate the path on the first page load\n\t\t// this will register the path in history and sets the pathvariable\n\t\t// navigate(window.location.pathname, false, true)\n\t\tif (PineconeRouter.settings.hash == false) {\n\t\t\t// navigate to the current page to handle it\n\t\t\t// ONLY if we not using hash routing for the default router\n\t\t\tnavigate(location.pathname, false, true)\n\t\t} else {\n\t\t\tnavigate(location.hash.substring(1), false, true)\n\t\t}\n\t})\n\n\t// handle navigation events not emitted by links, for example, back button.\n\twindow.addEventListener('popstate', () => {\n\t\tif (PineconeRouter.settings.hash) {\n\t\t\tif (window.location.hash != '') {\n\t\t\t\tnavigate(window.location.hash.substring(1), true)\n\t\t\t}\n\t\t} else {\n\t\t\tnavigate(window.location.pathname, true)\n\t\t}\n\t})\n\n\t// intercept click event in links\n\tinterceptLinks()\n\n\t/**\n\t * @description Add a handler to click events on all valid links\n\t */\n\tfunction interceptLinks() {\n\t\tfunction validateLink(node) {\n\t\t\t// only valid elements\n\t\t\tif (!node || !node.getAttribute) return;\n\n\t\t\tlet href = node.getAttribute('href'),\n\t\t\t\ttarget = node.getAttribute('target');\n\n\t\t\t// ignore links with targets and non-path URLs\n\t\t\tif (!href || !href.match(/^\\//g) || (target && !target.match(/^_?self$/i)))\n\t\t\t\treturn;\n\n\t\t\tif (typeof href !== 'string' && href.url) {\n\t\t\t\thref = href.url;\n\t\t\t}\n\t\t\treturn href\n\n\t\t}\n\t\twindow.document.body.addEventListener(\n\t\t\t'click',\n\t\t\tfunction (e: any) {\n\t\t\t\tif (e.ctrlKey || e.metaKey || e.altKey || e.shiftKey || e.button || e.defaultPrevented) return;\n\n\n\t\t\t\tlet currentRoute = PineconeRouter.routes[findRouteIndex(PineconeRouter.context.route)] ?? PineconeRouter.notfound\n\n\t\t\t\t// stop handlers in progress before navigating to the next page\n\t\t\t\tif (!currentRoute.handlersDone) {\n\t\t\t\t\tcurrentRoute.cancelHandlers = true\n\t\t\t\t\tendLoading()\n\t\t\t\t}\n\n\t\t\t\tlet node = e.target;\n\n\t\t\t\tdo {\n\t\t\t\t\tif (node.localName === 'a' && node.getAttribute('href')) {\n\t\t\t\t\t\tif (window.PineconeRouter.settings.interceptLinks == false && !node.hasAttribute('x-link')) return\n\t\t\t\t\t\tif (node.hasAttribute('data-native') || node.hasAttribute('native')) return;\n\t\t\t\t\t\tlet href = validateLink(node)\n\t\t\t\t\t\tif (href) {\n\t\t\t\t\t\t\tnavigate(href)\n\t\t\t\t\t\t\tif (e.stopImmediatePropagation) e.stopImmediatePropagation();\n\t\t\t\t\t\t\tif (e.stopPropagation) e.stopPropagation();\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} while ((node = node.parentNode));\n\t\t\t}\n\t\t)\n\t}\n\n\t/**\n\t * Go to the specified path without reloading\n\t * @param {string} path the path with no hash even if using hash routing\n\t * @param {boolean} fromPopState this will be set to true if called from window.onpopstate event\n\t * @param {boolean} firstLoad this will be set to true if this is the first page loaded, also from page reload\n\t */\n\tasync function navigate(path, fromPopState = false, firstLoad = false) {\n\t\tif (!path) path = '/'\n\t\tPineconeRouter.context.path = path\n\n\t\t// only add basePath if it was set\n\t\t// if not using hash routing\n\t\t// and if it wasn't added already\n\t\tif (!PineconeRouter.settings.hash) {\n\t\t\tif (\n\t\t\t\tPineconeRouter.settings.basePath != '/' &&\n\t\t\t\t!path.startsWith(PineconeRouter.settings.basePath)\n\t\t\t) {\n\t\t\t\tpath = PineconeRouter.settings.basePath + path\n\t\t\t}\n\t\t\tif (\n\t\t\t\tpath == PineconeRouter.settings.basePath &&\n\t\t\t\t!path.endsWith('/')\n\t\t\t) {\n\t\t\t\tpath += '/'\n\t\t\t}\n\t\t}\n\n\t\tconst route: Route = PineconeRouter.routes.find(\n\t\t\t(route: Route) => {\n\t\t\t\tlet m = match(path, route.path)\n\t\t\t\troute.params = m != false ? m : {}\n\t\t\t\treturn m != false\n\t\t\t}\n\t\t) ?? PineconeRouter.notfound\n\n\t\t// if the route has handlres, it will mark them unhandled\n\t\t// this is so templates wont render till then.\n\t\troute.handlersDone = !route.handlers.length\n\n\t\tif (route.handlers.length || route.template) {\n\t\t\tstartLoading()\n\t\t}\n\n\t\tlet context = buildContext(route.path, path, route.params)\n\n\t\tPineconeRouter.context = context\n\n\t\t// the middleware may return 'stop' to stop execution of this function\n\t\tif (\n\t\t\tmiddleware('onBeforeHandlersExecuted', route, path, firstLoad) == 'stop'\n\t\t) {\n\t\t\tendLoading()\n\t\t\treturn\n\t\t}\n\n\n\t\t// do not call pushstate from popstate event https://stackoverflow.com/a/50830905\n\t\tif (!fromPopState) {\n\t\t\tlet fullPath = ''\n\t\t\tif (PineconeRouter.settings.hash) {\n\t\t\t\tfullPath = '#'\n\t\t\t\tfullPath += window.location.search + path\n\t\t\t} else {\n\t\t\t\tfullPath = path + window.location.search + window.location.hash\n\t\t\t}\n\t\t\t// don't create duplicate history entry on first page load\n\t\t\tif (!firstLoad) history.pushState({ path: fullPath }, '', fullPath)\n\t\t\telse {\n\t\t\t\tif (PineconeRouter.settings.hash) {\n\t\t\t\t\tif (path == '/') {\n\t\t\t\t\t\tPineconeRouter.context = context\n\t\t\t\t\t\treturn navigate('/', false, false)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\t(route && route.handlers.length)\n\t\t) {\n\t\t\troute.cancelHandlers = false\n\t\t\tlet ok = await handle(route.handlers, context)\n\t\t\tif (!ok) {\n\t\t\t\tendLoading()\n\t\t\t\treturn\n\t\t\t}\n\t\t\troute.handlersDone = true\n\t\t\tif (!route.template) endLoading()\n\t\t}\n\n\n\t\t// show templates added programmatically\n\t\tif (route.template && route.programmaticTemplate) {\n\t\t\tlet target = document.getElementById(route.templateTargetId) ?? document.getElementById(PineconeRouter.settings.templateTargetId)\n\t\t\tif (cachedTemplates[route.template]) {\n\t\t\t\ttarget.innerHTML = cachedTemplates[route.template]\n\t\t\t\tendLoading()\n\t\t\t}\n\t\t\telse {\n\t\t\t\tload(target, route.template).then(() => {\n\t\t\t\t\tendLoading()\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\n\t\tmiddleware('onHandlersExecuted', route, path, firstLoad)\n\t}\n\n\tfunction buildContext(route: string, path: string, params: {}): Context {\n\t\treturn {\n\t\t\troute: route,\n\t\t\tpath: path,\n\t\t\tparams: params,\n\t\t\tquery: window.location.search.substring(1), // query w/out leading '?'\n\t\t\thash: window.location.hash.substring(1), // hash without leading '#'\n\t\t\tredirect(path) {\n\t\t\t\tnavigate(path)\n\t\t\t\treturn 'stop'\n\t\t\t},\n\t\t\tnavigate(path) {\n\t\t\t\tnavigate(path)\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction modifierValue(modifiers, key, fallback) {\n\t\t// If the modifier isn't present, use the default.\n\t\tif (modifiers.indexOf(key) === -1) return fallback\n\n\t\t// If it IS present, grab the value after it\n\t\tconst rawValue = modifiers[modifiers.indexOf(key) + 1]\n\n\t\tif (!rawValue) return fallback\n\n\t\tif (key === 'target') {\n\t\t\tlet match = rawValue.match(/([a-z0-9_-]+)/)\n\t\t\tif (match) return match[1]\n\t\t}\n\t\treturn rawValue\n\t}\n\t/**\n\t * execute the handlers of routes that are given passing them the context.\n\t */\n\tasync function handle(handlers, context) {\n\t\tfor (let i = 0; i < handlers.length; i++) {\n\t\t\tif (typeof handlers[i] == 'function') {\n\t\t\t\t// stop if the handlers were canceled for example the user clicked a link\n\t\t\t\tlet route = PineconeRouter.routes[findRouteIndex(context.route)] ?? PineconeRouter.notfound\n\t\t\t\tif (route.cancelHandlers) {\n\t\t\t\t\troute.cancelHandlers = false\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tlet result\n\t\t\t\tif (handlers[i].constructor.name === 'AsyncFunction')\n\t\t\t\t\tresult = await handlers[i](context)\n\t\t\t\telse\n\t\t\t\t\tresult = handlers[i](context)\n\t\t\t\t// if the handler redirected, return\n\t\t\t\tif (result == 'stop') return false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n}\n\n", "import magic from '../src/index.js'\n\nexport default magic\n"],
- "mappings": "AAEA,IAAMA,EAAN,KAAY,CACX,OAAiC,CAAC,EAClC,KACA,SAAsB,CAAC,EACvB,YAAYC,EAAcC,EAAkC,CAAC,EAAG,CAC/D,KAAK,KAAOD,EACZ,OAAO,KAAKC,CAAO,EAAE,QAASC,GAAQ,CACrC,KAAKA,CAAG,EAAID,EAAQC,CAAG,CACxB,CAAC,EACGD,EAAQ,WACX,KAAK,qBAAuB,GAE9B,CACA,SAAmB,GACnB,iBAA2B,GAC3B,qBAAgC,GAChC,aAAwB,GACxB,cACD,EAEOE,EAAQJ,EChBf,SAASK,EAAWC,EAAuB,CAC1C,OAAOA,EAAI,QAAQ,eAAgB,EAAE,EAAE,MAAM,GAAG,CACjD,CAUO,SAASC,EAAMD,EAAaE,EAAmC,CACrE,IAAIC,EAAM,wBACTC,EAAIJ,EAAI,MAAMG,CAAG,EACjBE,EAAe,CAAC,EAChBC,EACD,GAAIF,GAAKA,EAAE,CAAC,EAAG,CACd,IAAIG,EAAIH,EAAE,CAAC,EAAE,MAAM,GAAG,EACtB,QAASI,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAAK,CAClC,IAAIC,EAAIF,EAAEC,CAAC,EAAE,MAAM,GAAG,EACtBH,EAAQ,mBAAmBI,EAAE,CAAC,CAAC,CAAC,EAAI,mBACnCA,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,CACpB,CACD,CACD,CACA,IAAIC,EAASX,EAAWC,EAAI,QAAQG,EAAK,EAAE,CAAC,EAC3CQ,EAAkBZ,EAAWG,GAAa,EAAE,EAC5CU,EAAM,KAAK,IAAIF,EAAO,OAAQC,EAAM,MAAM,EAC3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AAO,UAAU,CAAC,EACzC,KAAM,OAAO,SAAS,KAAK,UAAU,CAAC,EACtC,SAASlD,EAAM,CACd,OAAAC,EAASD,CAAI,EACN,MACR,EACA,SAASA,EAAM,CACdC,EAASD,CAAI,CACd,CACD,CACD,CAEA,SAAS6B,EAAcL,EAAW2B,EAAKC,EAAU,CAEhD,GAAI5B,EAAU,QAAQ2B,CAAG,IAAM,GAAI,OAAOC,EAG1C,IAAMC,EAAW7B,EAAUA,EAAU,QAAQ2B,CAAG,EAAI,CAAC,EAErD,GAAI,CAACE,EAAU,OAAOD,EAEtB,GAAID,IAAQ,SAAU,CACrB,IAAIN,EAAQQ,EAAS,MAAM,eAAe,EAC1C,GAAIR,EAAO,OAAOA,EAAM,CAAC,CAC1B,CACA,OAAOQ,CACR,CAIA,eAAeJ,EAAOhB,EAAUa,EAAS,CACxC,QAASQ,EAAI,EAAGA,EAAIrB,EAAS,OAAQqB,IACpC,GAAI,OAAOrB,EAASqB,CAAC,GAAK,WAAY,CAErC,IAAIvB,EAAQjC,EAAe,OAAOyB,EAAeuB,EAAQ,KAAK,CAAC,GAAKhD,EAAe,SACnF,GAAIiC,EAAM,eACT,OAAAA,EAAM,eAAiB,GAChB,GAER,IAAIwB,EAMJ,GALItB,EAASqB,CAAC,EAAE,YAAY,OAAS,gBACpCC,EAAS,MAAMtB,EAASqB,CAAC,EAAER,CAAO,EAElCS,EAAStB,EAASqB,CAAC,EAAER,CAAO,EAEzBS,GAAU,OAAQ,MAAO,EAC9B,CAED,MAAO,EACR,CACD,CClmBA,IAAOC,EAAQC",
+ "sourcesContent": ["import type { Handler } from './types'\n\nclass Route {\n\tparams: { [key: string]: any } = {}\n\tpath: string\n\thandlers: Handler[] = []\n\tconstructor(path: string, options: { [key: string]: any } = {}) {\n\t\tthis.path = path\n\t\tObject.keys(options).forEach((opt) => {\n\t\t\tthis[opt] = options[opt]\n\t\t})\n\t\tif (options.template) {\n\t\t\tthis.programmaticTemplate = true\n\t\t}\n\t}\n\ttemplate: string = ''\n\ttemplateTargetId: string = ''\n\tprogrammaticTemplate: boolean = false\n\thandlersDone: boolean = false\n\tcancelHandlers: boolean\n}\n\nexport default Route\n", "/**\n * taken from preact-router\n * https://github.com/preactjs/preact-router\n * @param url url to segmentize\n * @returns\n */\nfunction segmentize(url: string): string[] {\n\treturn url.replace(/(^\\/+|\\/+$)/g, '').split('/')\n}\n\n/**\n * check if a path match with this route\n * taken from preact-router\n * https://github.com/preactjs/preact-router\n * @param path {string}\n * @param routePath {string}\n * @returns {false|object}\n */\nexport function match(url: string, routePath: string): false | object {\n\tlet reg = /(?:\\?([^#]*))?(#.*)?$/,\n\t\tc = url.match(reg),\n\t\tmatches: any = {},\n\t\tret\n\tif (c && c[1]) {\n\t\tlet p = c[1].split('&')\n\t\tfor (let i = 0; i < p.length; i++) {\n\t\t\tlet r = p[i].split('=')\n\t\t\tmatches[decodeURIComponent(r[0])] = decodeURIComponent(\n\t\t\t\tr.slice(1).join('=')\n\t\t\t)\n\t\t}\n\t}\n\tlet urlSeg = segmentize(url.replace(reg, '')),\n\t\troute: string[] = segmentize(routePath || ''),\n\t\tmax = Math.max(urlSeg.length, route.length)\n\tfor (let i = 0; i < max; i++) {\n\t\tif (route[i] && route[i].charAt(0) === ':') {\n\t\t\tlet param: string = route[i].replace(/(^:|[+*?]+$)/g, ''),\n\t\t\t\tflags: string = (route[i].match(/[+*?]+$/) || {}).toString()[0],\n\t\t\t\tplus = ~flags.indexOf('+'),\n\t\t\t\tstar = ~flags.indexOf('*'),\n\t\t\t\tval = urlSeg[i] || ''\n\t\t\tif (!val && !star && (flags.indexOf('?') < 0 || plus)) {\n\t\t\t\tret = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tmatches[param] = decodeURIComponent(val)\n\t\t\tif (plus || star) {\n\t\t\t\tmatches[param] = urlSeg\n\t\t\t\t\t.slice(i)\n\t\t\t\t\t.map(decodeURIComponent)\n\t\t\t\t\t.join('/')\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else if (route[i] !== urlSeg[i]) {\n\t\t\tret = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif (ret === false) return false\n\treturn matches\n}\n\n/**\n * Call a function on all middlewares loaded, if any.\n * @param {string} func middleware function to call.\n * @param {any} args arguments to pass to the function.\n * @returns {boolean} false if the middleware function return false, i.e. it want to stop execution of the function and return.\n */\nexport function middleware(func: string, ...args: any): string | undefined {\n\tif (!window.PineconeRouterMiddlewares) return\n\tfor (const i in window.PineconeRouterMiddlewares) {\n\t\tlet plugin: any = window.PineconeRouterMiddlewares[i]\n\t\tif (plugin[func] == null) return\n\t\tlet ret = plugin[func](...args)\n\t\t// the return of the function will only be 'stop'\n\t\t// if the middleware request stopping the navigate function.\n\t\tif (ret == 'stop') return 'stop'\n\t}\n}\n\nexport function fetchError(error: string) {\n\tdocument.dispatchEvent(\n\t\tnew CustomEvent('fetch-error', { detail: error })\n\t)\n}", "import Route from './route'\nimport type { Settings, Context, Middleware, Handler } from './types'\nimport { fetchError, match, middleware } from './utils'\n\n\ndeclare global {\n\tinterface Window {\n\t\tPineconeRouter: {\n\t\t\tversion: string\n\t\t\tname: string\n\t\t\tsettings: Settings\n\t\t\tnotfound: Route\n\t\t\troutes: Route[]\n\t\t\tcontext: Context\n\t\t\tloadStart: Event\n\t\t\tloadEnd: Event\n\t\t\tadd: (path: string, options?: {}) => number\n\t\t\tremove: (path: string) => void\n\t\t}\n\t\tPineconeRouterMiddlewares: Array\n\t}\n\tinterface HTMLTemplateElement {\n\t\t_x_PineconeRouter_undoTemplate: Function\n\t\t_x_PineconeRouter_CurrentTemplate: Element\n\t\t_x_PineconeRouter_route: string\n\t}\n}\n\nexport default function (Alpine) {\n\n\tconst PineconeRouter = Alpine.reactive({\n\t\tversion: '4.4.1',\n\t\tname: 'pinecone-router',\n\n\t\tsettings: {\n\t\t\thash: false,\n\t\t\tbasePath: '/',\n\t\t\ttemplateTargetId: null,\n\t\t\tinterceptLinks: true\n\t\t},\n\n\t\t/**\n\t\t * @description The handler for 404 pages, can be overwritten by a notfound route\n\t\t */\n\t\tnotfound: new Route('notfound'),\n\n\t\t/**\n\t\t * @type Route[]\n\t\t * @summary array of routes instantiated from the Route class.\n\t\t */\n\t\troutes: [],\n\n\t\t/**\n\t\t * @type {Context}\n\t\t * @summary The context object for current path.\n\t\t */\n\t\tcontext: {\n\t\t\troute: '',\n\t\t\tpath: '',\n\t\t\tparams: {},\n\t\t\tquery: window.location.search.substring(1),\n\t\t\thash: window.location.hash.substring(1),\n\t\t\tredirect(path) {\n\t\t\t\tnavigate(path)\n\t\t\t\treturn 'stop'\n\t\t\t},\n\t\t\tnavigate(path) {\n\t\t\t\tnavigate(path)\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Add a new route\n\t\t */\n\t\tadd(path: string, options?: {}) {\n\t\t\t// check if the route was registered on the same router.\n\t\t\tif (this.routes.find((r: Route) => r.path == path) != null) {\n\t\t\t\tthrow new Error('Pinecone Router: route already exist')\n\t\t\t}\n\n\t\t\treturn this.routes.push(new Route(path, options)) - 1\n\t\t},\n\t\t/**\n\t\t * Remove a route\n\t\t */\n\t\tremove(path: string) {\n\t\t\tthis.routes = this.routes.filter((r: Route) => r.path != path)\n\t\t},\n\t\t/**\n\t\t * @event pinecone-start\n\t\t * @summary be dispatched to the window after before page start loading.\n\t\t */\n\t\tloadStart: new Event('pinecone-start'),\n\n\t\t/**\n\t\t * @event pinecone-end\n\t\t * @summary will be dispatched to the window after the views are fetched\n\t\t */\n\t\tloadEnd: new Event('pinecone-end'),\n\t})\n\n\twindow.PineconeRouter = PineconeRouter\n\n\tvar loadingTemplates: { [key: string]: Promise } = {}\n\tvar cachedTemplates: { [key: string]: string } = {}\n\tconst inMakeProgress = new Set()\n\tvar preloadingTemplates: { [key: string]: Promise } = {}\n\n\tconst load = (el: HTMLTemplateElement | HTMLElement, url: string, programmaticRoute: boolean = false) => {\n\t\tif (loadingTemplates[url] && !programmaticRoute) {\n\t\t\tloadingTemplates[url].then(html => el.innerHTML = html)\n\t\t} else {\n\t\t\tloadingTemplates[url] = fetch(url).then(r => {\n\t\t\t\tif (!r.ok) {\n\t\t\t\t\tfetchError(r.statusText);\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\treturn r.text()\n\t\t\t}).then(html => {\n\t\t\t\tif (html == null) {\n\t\t\t\t\tcachedTemplates[url] = null;\n\t\t\t\t\tloadingTemplates[url] = null\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tcachedTemplates[url] = html\n\t\t\t\tel.innerHTML = html\n\t\t\t\treturn html\n\t\t\t})\n\t\t}\n\t\treturn loadingTemplates[url]\n\t}\n\n\tconst make = (el: HTMLTemplateElement, expression: string, targetEl?: HTMLElement) => {\n\t\tif (inMakeProgress.has(expression)) return\n\t\tinMakeProgress.add(expression)\n\n\t\tconst clone = (el.content.cloneNode(true) as HTMLElement).firstElementChild\n\n\t\tif (!clone) return\n\n\t\tAlpine.addScopeToNode(clone, {}, el)\n\n\t\tAlpine.mutateDom(() => {\n\t\t\tif (targetEl != null) {\n\t\t\t\ttargetEl.appendChild(clone)\n\t\t\t} else\n\t\t\t\tel.after(clone)\n\t\t\tAlpine.initTree(clone)\n\t\t})\n\n\t\tel._x_PineconeRouter_CurrentTemplate = clone\n\n\t\tel._x_PineconeRouter_undoTemplate = () => {\n\t\t\tclone.remove()\n\n\t\t\tdelete el._x_PineconeRouter_CurrentTemplate\n\t\t}\n\n\t\tAlpine.nextTick(() => inMakeProgress.delete(expression))\n\t}\n\n\tfunction hide(el: HTMLTemplateElement) {\n\t\tif (el._x_PineconeRouter_undoTemplate) {\n\t\t\tel._x_PineconeRouter_undoTemplate()\n\t\t\tdelete el._x_PineconeRouter_undoTemplate\n\t\t}\n\t}\n\n\tfunction show(el: HTMLTemplateElement, expression: string, url?: string, targetEl?: HTMLElement) {\n\t\tif (el._x_PineconeRouter_CurrentTemplate) return el._x_PineconeRouter_CurrentTemplate\n\t\tif (el.content.firstElementChild) {\n\t\t\tmake(el, expression, targetEl)\n\t\t\tendLoading()\n\t\t} else if (url) {\n\t\t\t// Since during loading, the content is automatically put inside the template\n\t\t\t// This first case will only happen if the content of the template was cleared somehow\n\t\t\t// Likely manually\n\t\t\tif (cachedTemplates[url]) {\n\n\t\t\t\tel.innerHTML = cachedTemplates[url]\n\t\t\t\tmake(el, expression, targetEl)\n\t\t\t\tendLoading()\n\t\t\t} else {\n\t\t\t\t// This second case is that it didn't finish loading\n\t\t\t\tif (preloadingTemplates[url]) {\n\t\t\t\t\tpreloadingTemplates[url].then(() => make(el, expression, targetEl))\n\t\t\t\t} else {\n\t\t\t\t\tload(el, url).then(() => make(el, expression, targetEl)).finally(() => endLoading())\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst startLoading = () => {\n\t\tdocument.dispatchEvent(PineconeRouter.loadStart)\n\t}\n\n\tconst endLoading = () => {\n\t\tdocument.dispatchEvent(PineconeRouter.loadEnd)\n\t}\n\n\tconst addBasePath = (path) => {\n\t\tif (!PineconeRouter.settings.hash && PineconeRouter.settings.basePath != '/') {\n\t\t\treturn PineconeRouter.settings.basePath + path\n\t\t} return path\n\t}\n\n\tconst findRouteIndex = (path) => {\n\t\treturn PineconeRouter.routes.findIndex(\n\t\t\t(r) => r.path == path\n\t\t)\n\t}\n\n\tAlpine.directive(\n\t\t'route',\n\t\t(el: HTMLTemplateElement, { expression, modifiers }, { effect, cleanup }) => {\n\t\t\tlet path = expression\n\n\t\t\tmiddleware('onBeforeRouteProcessed', el, path)\n\n\t\t\tif (path.indexOf('#') > -1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Pinecone Router: A route's path may not have a hash character.`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tlet target = modifierValue(modifiers, 'target', null) ?? window.PineconeRouter.settings.templateTargetId\n\t\t\tlet targetEl = document.getElementById(target)\n\t\t\tif (target && !targetEl)\n\t\t\t\tthrow new Error(\"Pinecone Router: Can't find an element with the suplied target ID: \" + target + \"\")\n\n\t\t\tlet routeIndex = null\n\n\t\t\tif (path != 'notfound') {\n\t\t\t\t// if specified add the basePath\n\t\t\t\tpath = addBasePath(path)\n\t\t\t\t// register the new route if possible\n\t\t\t\trouteIndex = PineconeRouter.add(path)\n\t\t\t}\n\n\t\t\tlet route = PineconeRouter.routes[routeIndex] ?? PineconeRouter.notfound\n\n\t\t\t// set the path in the element so it is used by other directives\n\t\t\tel._x_PineconeRouter_route = path\n\n\t\t\tif (el.content.firstElementChild != null) {\n\t\t\t\tAlpine.nextTick(() => {\n\t\t\t\t\teffect(() => {\n\t\t\t\t\t\tlet found = route.handlersDone && PineconeRouter.context.route == path\n\t\t\t\t\t\tfound ? show(el, expression, null, targetEl) : hide(el)\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tcleanup(() => {\n\t\t\t\tel._x_PineconeRouter_undoTemplate && el._x_PineconeRouter_undoTemplate();\n\t\t\t\tPineconeRouter.remove(path);\n\t\t\t\tdelete el._x_PineconeRouter_route\n\t\t\t})\n\n\t\t\tmiddleware('onAfterRouteProcessed', el, path)\n\n\n\t\t}\n\t)\n\n\tAlpine.directive(\n\t\t'handler',\n\t\t(\n\t\t\tel,\n\t\t\t{ expression },\n\t\t\t{ evaluate, cleanup }\n\t\t) => {\n\t\t\tif (!el._x_PineconeRouter_route) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Pinecone Router: x-handler must be set on the same element as x-route.`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tlet handlers\n\n\t\t\t// check if the handlers expression is an array\n\t\t\t// if not make it one\n\t\t\tif (\n\t\t\t\t!(expression.startsWith('[') && expression.endsWith(']')) &&\n\t\t\t\t!(expression.startsWith('Array(') && expression.endsWith(')'))\n\t\t\t) {\n\t\t\t\texpression = `[${expression}]`\n\t\t\t}\n\n\t\t\tlet evaluatedExpression = evaluate(expression)\n\n\t\t\tif (typeof evaluatedExpression == 'object')\n\t\t\t\thandlers = evaluatedExpression\n\t\t\telse {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Pinecone Router: Invalid handler type: ${typeof evaluatedExpression}.`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// add `this` context for handlers inside an Alpine.component\n\t\t\tfor (let index = 0; index < handlers.length; index++) {\n\t\t\t\thandlers[index] = handlers[index].bind(Alpine.$data(el))\n\t\t\t}\n\n\t\t\t// add handlers to the route\n\t\t\tlet path = el._x_PineconeRouter_route\n\t\t\tlet route = path == 'notfound' ? PineconeRouter.notfound : PineconeRouter.routes[findRouteIndex(path)];\n\t\t\troute.handlers = handlers\n\n\t\t\tcleanup(() => {\n\t\t\t\troute.handlers = []\n\t\t\t\troute.handlersDone = true\n\t\t\t\troute.cancelHandlers = false\n\t\t\t})\n\t\t}\n\t)\n\n\tAlpine.directive(\n\t\t'template',\n\t\t(el: HTMLTemplateElement, { modifiers, expression }, { Alpine, effect, cleanup }) => {\n\n\t\t\tif (!el._x_PineconeRouter_route) throw new Error(\"Pinecone Router: x-template must be used on the same element as x-route.\")\n\n\t\t\tif (el.content.firstElementChild != null) throw new Error(\"Pinecone Router: x-template cannot be used alongside an inline template (template element should not have a child).\")\n\n\t\t\tlet url: string = expression\n\n\t\t\tlet target = modifierValue(modifiers, 'target', null) ?? window.PineconeRouter.settings.templateTargetId\n\t\t\tlet targetEl = document.getElementById(target)\n\n\t\t\tif (target && !targetEl)\n\t\t\t\tthrow new Error(\"Pinecone Router: Can't find an element with the suplied target ID: \" + target + \"\")\n\n\t\t\tif (modifiers.includes(\"preload\")) {\n\t\t\t\tpreloadingTemplates[url] = load(el, url).finally(() => {\n\t\t\t\t\tpreloadingTemplates[url] = null;\n\t\t\t\t\tendLoading()\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// add template to the route\n\t\t\tlet path = el._x_PineconeRouter_route\n\t\t\tlet route = path == 'notfound' ? PineconeRouter.notfound : PineconeRouter.routes[findRouteIndex(path)];\n\t\t\troute.template = url\n\n\n\t\t\tAlpine.nextTick(() => {\n\t\t\t\teffect(() => {\n\t\t\t\t\tlet found = route.handlersDone && PineconeRouter.context.route == route.path\n\t\t\t\t\tfound ? show(el, expression, url, targetEl) : hide(el)\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tcleanup(() => {\n\t\t\t\tel._x_PineconeRouter_undoTemplate && el._x_PineconeRouter_undoTemplate();\n\t\t\t})\n\n\t\t}\n\t)\n\n\tAlpine.$router = PineconeRouter.context\n\tAlpine.magic('router', () => PineconeRouter.context)\n\n\tdocument.addEventListener('alpine:initialized', () => {\n\t\tmiddleware('init')\n\t\t// virtually navigate the path on the first page load\n\t\t// this will register the path in history and sets the pathvariable\n\t\t// navigate(window.location.pathname, false, true)\n\t\tif (PineconeRouter.settings.hash == false) {\n\t\t\t// navigate to the current page to handle it\n\t\t\t// ONLY if we not using hash routing for the default router\n\t\t\tnavigate(location.pathname, false, true)\n\t\t} else {\n\t\t\tnavigate(location.hash.substring(1), false, true)\n\t\t}\n\t})\n\n\t// handle navigation events not emitted by links, for example, back button.\n\twindow.addEventListener('popstate', () => {\n\t\tif (PineconeRouter.settings.hash) {\n\t\t\tif (window.location.hash != '') {\n\t\t\t\tnavigate(window.location.hash.substring(1), true)\n\t\t\t}\n\t\t} else {\n\t\t\tnavigate(window.location.pathname, true)\n\t\t}\n\t})\n\n\t// intercept click event in links\n\tinterceptLinks()\n\n\t/**\n\t * @description Add a handler to click events on all valid links\n\t */\n\tfunction interceptLinks() {\n\t\tfunction validateLink(node) {\n\t\t\t// only valid elements\n\t\t\tif (!node || !node.getAttribute) return;\n\n\t\t\tlet href = node.getAttribute('href'),\n\t\t\t\ttarget = node.getAttribute('target');\n\n\t\t\t// ignore links with targets and non-path URLs\n\t\t\tif (!href || !href.match(/^\\//g) || (target && !target.match(/^_?self$/i)))\n\t\t\t\treturn;\n\n\t\t\tif (typeof href !== 'string' && href.url) {\n\t\t\t\thref = href.url;\n\t\t\t}\n\t\t\treturn href\n\n\t\t}\n\t\twindow.document.body.addEventListener(\n\t\t\t'click',\n\t\t\tfunction (e: any) {\n\t\t\t\tif (e.ctrlKey || e.metaKey || e.altKey || e.shiftKey || e.button || e.defaultPrevented) return;\n\n\n\t\t\t\tlet currentRoute = PineconeRouter.routes[findRouteIndex(PineconeRouter.context.route)] ?? PineconeRouter.notfound\n\n\t\t\t\t// stop handlers in progress before navigating to the next page\n\t\t\t\tif (!currentRoute.handlersDone) {\n\t\t\t\t\tcurrentRoute.cancelHandlers = true\n\t\t\t\t\tendLoading()\n\t\t\t\t}\n\n\t\t\t\tlet node = e.target;\n\n\t\t\t\tdo {\n\t\t\t\t\tif (node.localName === 'a' && node.getAttribute('href')) {\n\t\t\t\t\t\tif (window.PineconeRouter.settings.interceptLinks == false && !node.hasAttribute('x-link')) return\n\t\t\t\t\t\tif (node.hasAttribute('data-native') || node.hasAttribute('native')) return;\n\t\t\t\t\t\tlet href = validateLink(node)\n\t\t\t\t\t\tif (href) {\n\t\t\t\t\t\t\tnavigate(href)\n\t\t\t\t\t\t\tif (e.stopImmediatePropagation) e.stopImmediatePropagation();\n\t\t\t\t\t\t\tif (e.stopPropagation) e.stopPropagation();\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} while ((node = node.parentNode));\n\t\t\t}\n\t\t)\n\t}\n\n\t/**\n\t * Go to the specified path without reloading\n\t * @param {string} path the path with no hash even if using hash routing\n\t * @param {boolean} fromPopState this will be set to true if called from window.onpopstate event\n\t * @param {boolean} firstLoad this will be set to true if this is the first page loaded, also from page reload\n\t */\n\tasync function navigate(path, fromPopState = false, firstLoad = false) {\n\t\tif (!path) path = '/'\n\t\tPineconeRouter.context.path = path\n\n\t\t// only add basePath if it was set\n\t\t// if not using hash routing\n\t\t// and if it wasn't added already\n\t\tif (!PineconeRouter.settings.hash) {\n\t\t\tif (\n\t\t\t\tPineconeRouter.settings.basePath != '/' &&\n\t\t\t\t!path.startsWith(PineconeRouter.settings.basePath)\n\t\t\t) {\n\t\t\t\tpath = PineconeRouter.settings.basePath + path\n\t\t\t}\n\t\t\tif (\n\t\t\t\tpath == PineconeRouter.settings.basePath &&\n\t\t\t\t!path.endsWith('/')\n\t\t\t) {\n\t\t\t\tpath += '/'\n\t\t\t}\n\t\t}\n\n\t\tconst route: Route = PineconeRouter.routes.find(\n\t\t\t(route: Route) => {\n\t\t\t\tlet m = match(path, route.path)\n\t\t\t\troute.params = m != false ? m : {}\n\t\t\t\treturn m != false\n\t\t\t}\n\t\t) ?? PineconeRouter.notfound\n\n\t\t// if the route has handlres, it will mark them unhandled\n\t\t// this is so templates wont render till then.\n\t\troute.handlersDone = !route.handlers.length\n\n\t\tif (route.handlers.length || route.template) {\n\t\t\tstartLoading()\n\t\t}\n\n\t\tlet context = buildContext(route.path, path, route.params)\n\n\t\tPineconeRouter.context = context\n\n\t\t// the middleware may return 'stop' to stop execution of this function\n\t\tif (\n\t\t\tmiddleware('onBeforeHandlersExecuted', route, path, firstLoad) == 'stop'\n\t\t) {\n\t\t\tendLoading()\n\t\t\treturn\n\t\t}\n\n\n\t\t// do not call pushstate from popstate event https://stackoverflow.com/a/50830905\n\t\tif (!fromPopState) {\n\t\t\tlet fullPath = ''\n\t\t\tif (PineconeRouter.settings.hash) {\n\t\t\t\tfullPath = '#'\n\t\t\t\tfullPath += window.location.search + path\n\t\t\t} else {\n\t\t\t\tfullPath = path + window.location.search + window.location.hash\n\t\t\t}\n\t\t\t// don't create duplicate history entry on first page load\n\t\t\tif (!firstLoad) history.pushState({ path: fullPath }, '', fullPath)\n\t\t\telse {\n\t\t\t\tif (PineconeRouter.settings.hash) {\n\t\t\t\t\tif (path == '/') {\n\t\t\t\t\t\tPineconeRouter.context = context\n\t\t\t\t\t\treturn navigate('/', false, false)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\t(route && route.handlers.length)\n\t\t) {\n\t\t\troute.cancelHandlers = false\n\t\t\tlet ok = await handle(route.handlers, context)\n\t\t\tif (!ok) {\n\t\t\t\tendLoading()\n\t\t\t\treturn\n\t\t\t}\n\t\t\troute.handlersDone = true\n\t\t\tif (!route.template) endLoading()\n\t\t}\n\n\n\t\t// show templates added programmatically\n\t\tif (route.template && route.programmaticTemplate) {\n\t\t\tlet target = route.templateTargetId ? document.getElementById(route.templateTargetId) : document.getElementById(PineconeRouter.settings.templateTargetId);\n\t\t\tif (cachedTemplates[route.template]) {\n\t\t\t\ttarget.innerHTML = cachedTemplates[route.template]\n\t\t\t\tendLoading()\n\t\t\t}\n\t\t\telse {\n\t\t\t\tload(target, route.template).then(() => {\n\t\t\t\t\tendLoading()\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\n\t\tmiddleware('onHandlersExecuted', route, path, firstLoad)\n\t}\n\n\tfunction buildContext(route: string, path: string, params: {}): Context {\n\t\treturn {\n\t\t\troute: route,\n\t\t\tpath: path,\n\t\t\tparams: params,\n\t\t\tquery: window.location.search.substring(1), // query w/out leading '?'\n\t\t\thash: window.location.hash.substring(1), // hash without leading '#'\n\t\t\tredirect(path) {\n\t\t\t\tnavigate(path)\n\t\t\t\treturn 'stop'\n\t\t\t},\n\t\t\tnavigate(path) {\n\t\t\t\tnavigate(path)\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction modifierValue(modifiers, key, fallback) {\n\t\t// If the modifier isn't present, use the default.\n\t\tif (modifiers.indexOf(key) === -1) return fallback\n\n\t\t// If it IS present, grab the value after it\n\t\tconst rawValue = modifiers[modifiers.indexOf(key) + 1]\n\n\t\tif (!rawValue) return fallback\n\n\t\tif (key === 'target') {\n\t\t\tlet match = rawValue.match(/([a-z0-9_-]+)/)\n\t\t\tif (match) return match[1]\n\t\t}\n\t\treturn rawValue\n\t}\n\t/**\n\t * execute the handlers of routes that are given passing them the context.\n\t */\n\tasync function handle(handlers, context) {\n\t\tfor (let i = 0; i < handlers.length; i++) {\n\t\t\tif (typeof handlers[i] == 'function') {\n\t\t\t\t// stop if the handlers were canceled for example the user clicked a link\n\t\t\t\tlet route = PineconeRouter.routes[findRouteIndex(context.route)] ?? PineconeRouter.notfound\n\t\t\t\tif (route.cancelHandlers) {\n\t\t\t\t\troute.cancelHandlers = false\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tlet result\n\t\t\t\tif (handlers[i].constructor.name === 'AsyncFunction')\n\t\t\t\t\tresult = await handlers[i](context)\n\t\t\t\telse\n\t\t\t\t\tresult = handlers[i](context)\n\t\t\t\t// if the handler redirected, return\n\t\t\t\tif (result == 'stop') return false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n}\n\n", "import magic from '../src/index.js'\n\nexport default magic\n"],
+ "mappings": "AAEA,IAAMA,EAAN,KAAY,CACX,OAAiC,CAAC,EAClC,KACA,SAAsB,CAAC,EACvB,YAAYC,EAAcC,EAAkC,CAAC,EAAG,CAC/D,KAAK,KAAOD,EACZ,OAAO,KAAKC,CAAO,EAAE,QAASC,GAAQ,CACrC,KAAKA,CAAG,EAAID,EAAQC,CAAG,CACxB,CAAC,EACGD,EAAQ,WACX,KAAK,qBAAuB,GAE9B,CACA,SAAmB,GACnB,iBAA2B,GAC3B,qBAAgC,GAChC,aAAwB,GACxB,cACD,EAEOE,EAAQJ,EChBf,SAASK,EAAWC,EAAuB,CAC1C,OAAOA,EAAI,QAAQ,eAAgB,EAAE,EAAE,MAAM,GAAG,CACjD,CAUO,SAASC,EAAMD,EAAaE,EAAmC,CACrE,IAAIC,EAAM,wBACTC,EAAIJ,EAAI,MAAMG,CAAG,EACjBE,EAAe,CAAC,EAChBC,EACD,GAAIF,GAAKA,EAAE,CAAC,EAAG,CACd,IAAIG,EAAIH,EAAE,CAAC,EAAE,MAAM,GAAG,EACtB,QAASI,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAAK,CAClC,IAAIC,EAAIF,EAAEC,CAAC,EAAE,MAAM,GAAG,EACtBH,EAAQ,mBAAmBI,EAAE,CAAC,CAAC,CAAC,EAAI,mBACnCA,EAAE,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AAK,IAAM,CACvCX,EAAW,CACZ,CAAC,CAEH,CAGAO,EAAW,qBAAsBI,EAAO/B,EAAM2C,CAAS,CACxD,CAEA,SAASI,EAAahB,EAAe/B,EAAckD,EAAqB,CACvE,MAAO,CACN,MAAOnB,EACP,KAAM/B,EACN,OAAQkD,EACR,MAAO,OAAO,SAAS,OAAO,UAAU,CAAC,EACzC,KAAM,OAAO,SAAS,KAAK,UAAU,CAAC,EACtC,SAASlD,EAAM,CACd,OAAAC,EAASD,CAAI,EACN,MACR,EACA,SAASA,EAAM,CACdC,EAASD,CAAI,CACd,CACD,CACD,CAEA,SAAS6B,EAAcL,EAAW2B,EAAKC,EAAU,CAEhD,GAAI5B,EAAU,QAAQ2B,CAAG,IAAM,GAAI,OAAOC,EAG1C,IAAMC,EAAW7B,EAAUA,EAAU,QAAQ2B,CAAG,EAAI,CAAC,EAErD,GAAI,CAACE,EAAU,OAAOD,EAEtB,GAAID,IAAQ,SAAU,CACrB,IAAIN,EAAQQ,EAAS,MAAM,eAAe,EAC1C,GAAIR,EAAO,OAAOA,EAAM,CAAC,CAC1B,CACA,OAAOQ,CACR,CAIA,eAAeJ,EAAOhB,EAAUa,EAAS,CACxC,QAASQ,EAAI,EAAGA,EAAIrB,EAAS,OAAQqB,IACpC,GAAI,OAAOrB,EAASqB,CAAC,GAAK,WAAY,CAErC,IAAIvB,EAAQjC,EAAe,OAAOyB,EAAeuB,EAAQ,KAAK,CAAC,GAAKhD,EAAe,SACnF,GAAIiC,EAAM,eACT,OAAAA,EAAM,eAAiB,GAChB,GAER,IAAIwB,EAMJ,GALItB,EAASqB,CAAC,EAAE,YAAY,OAAS,gBACpCC,EAAS,MAAMtB,EAASqB,CAAC,EAAER,CAAO,EAElCS,EAAStB,EAASqB,CAAC,EAAER,CAAO,EAEzBS,GAAU,OAAQ,MAAO,EAC9B,CAED,MAAO,EACR,CACD,CClmBA,IAAOC,EAAQC",
"names": ["Route", "path", "options", "opt", "route_default", "segmentize", "url", "match", "routePath", "reg", "c", "matches", "ret", "p", "i", "r", "urlSeg", "route", "max", "param", "flags", "plus", "star", "val", "middleware", "func", "args", "plugin", "fetchError", "error", "src_default", "Alpine", "PineconeRouter", "route_default", "path", "navigate", "options", "r", "loadingTemplates", "cachedTemplates", "inMakeProgress", "preloadingTemplates", "load", "el", "url", "programmaticRoute", "html", "fetchError", "make", "expression", "targetEl", "clone", "hide", "show", "endLoading", "startLoading", "addBasePath", "findRouteIndex", "modifiers", "effect", "cleanup", "middleware", "target", "modifierValue", "routeIndex", "route", "evaluate", "handlers", "evaluatedExpression", "index", "interceptLinks", "validateLink", "node", "href", "e", "currentRoute", "fromPopState", "firstLoad", "m", "match", "context", "buildContext", "fullPath", "handle", "params", "key", "fallback", "rawValue", "i", "result", "module_default", "src_default"]
}
diff --git a/dist/router.min.js b/dist/router.min.js
index 16d40b7..5d754b3 100644
--- a/dist/router.min.js
+++ b/dist/router.min.js
@@ -1,2 +1,2 @@
-(()=>{var L=class{params={};path;handlers=[];constructor(o,f={}){this.path=o,Object.keys(f).forEach(u=>{this[u]=f[u]}),f.template&&(this.programmaticTemplate=!0)}template="";templateTargetId="";programmaticTemplate=!1;handlersDone=!1;cancelHandlers},M=L;function I(a){return a.replace(/(^\/+|\/+$)/g,"").split("/")}function k(a,o){let f=/(?:\?([^#]*))?(#.*)?$/,u=a.match(f),w={},_;if(u&&u[1]){let d=u[1].split("&");for(let R=0;Rr.path==e)!=null)throw new Error("Pinecone Router: route already exist");return this.routes.push(new M(e,n))-1},remove(e){this.routes=this.routes.filter(n=>n.path!=e)},loadStart:new Event("pinecone-start"),loadEnd:new Event("pinecone-end")});window.PineconeRouter=o;var f={},u={};let w=new Set;var _={};let P=(e,n,r=!1)=>(f[n]&&!r?f[n].then(t=>e.innerHTML=t):f[n]=fetch(n).then(t=>t.ok?t.text():(D(t.statusText),null)).then(t=>t==null?(u[n]=null,f[n]=null,null):(u[n]=t,e.innerHTML=t,t)),f[n]),m=(e,n,r)=>{if(w.has(n))return;w.add(n);let t=e.content.cloneNode(!0).firstElementChild;t&&(a.addScopeToNode(t,{},e),a.mutateDom(()=>{r!=null?r.appendChild(t):e.after(t),a.initTree(t)}),e._x_PineconeRouter_CurrentTemplate=t,e._x_PineconeRouter_undoTemplate=()=>{t.remove(),delete e._x_PineconeRouter_CurrentTemplate},a.nextTick(()=>w.delete(n)))};function E(e){e._x_PineconeRouter_undoTemplate&&(e._x_PineconeRouter_undoTemplate(),delete e._x_PineconeRouter_undoTemplate)}function d(e,n,r,t){if(e._x_PineconeRouter_CurrentTemplate)return e._x_PineconeRouter_CurrentTemplate;e.content.firstElementChild?(m(e,n,t),l()):r&&(u[r]?(e.innerHTML=u[r],m(e,n,t),l()):_[r]?_[r].then(()=>m(e,n,t)):P(e,r).then(()=>m(e,n,t)).finally(()=>l()))}let R=()=>{document.dispatchEvent(o.loadStart)},l=()=>{document.dispatchEvent(o.loadEnd)},y=e=>!o.settings.hash&&o.settings.basePath!="/"?o.settings.basePath+e:e,x=e=>o.routes.findIndex(n=>n.path==e);a.directive("route",(e,{expression:n,modifiers:r},{effect:t,cleanup:s})=>{let i=n;if(T("onBeforeRouteProcessed",e,i),i.indexOf("#")>-1)throw new Error("Pinecone Router: A route's path may not have a hash character.");let c=C(r,"target",null)??window.PineconeRouter.settings.templateTargetId,h=document.getElementById(c);if(c&&!h)throw new Error("Pinecone Router: Can't find an element with the suplied target ID: "+c);let p=null;i!="notfound"&&(i=y(i),p=o.add(i));let v=o.routes[p]??o.notfound;e._x_PineconeRouter_route=i,e.content.firstElementChild!=null&&a.nextTick(()=>{t(()=>{v.handlersDone&&o.context.route==i?d(e,n,null,h):E(e)})}),s(()=>{e._x_PineconeRouter_undoTemplate&&e._x_PineconeRouter_undoTemplate(),o.remove(i),delete e._x_PineconeRouter_route}),T("onAfterRouteProcessed",e,i)}),a.directive("handler",(e,{expression:n},{evaluate:r,cleanup:t})=>{if(!e._x_PineconeRouter_route)throw new Error("Pinecone Router: x-handler must be set on the same element as x-route.");let s;!(n.startsWith("[")&&n.endsWith("]"))&&!(n.startsWith("Array(")&&n.endsWith(")"))&&(n=`[${n}]`);let i=r(n);if(typeof i=="object")s=i;else throw new Error(`Pinecone Router: Invalid handler type: ${typeof i}.`);for(let p=0;p{h.handlers=[],h.handlersDone=!0,h.cancelHandlers=!1})}),a.directive("template",(e,{modifiers:n,expression:r},{Alpine:t,effect:s,cleanup:i})=>{if(!e._x_PineconeRouter_route)throw new Error("Pinecone Router: x-template must be used on the same element as x-route.");if(e.content.firstElementChild!=null)throw new Error("Pinecone Router: x-template cannot be used alongside an inline template (template element should not have a child).");let c=r,h=C(n,"target",null)??window.PineconeRouter.settings.templateTargetId,p=document.getElementById(h);if(h&&!p)throw new Error("Pinecone Router: Can't find an element with the suplied target ID: "+h);n.includes("preload")&&(_[c]=P(e,c).finally(()=>{_[c]=null,l()}));let v=e._x_PineconeRouter_route,H=v=="notfound"?o.notfound:o.routes[x(v)];H.template=c,t.nextTick(()=>{s(()=>{H.handlersDone&&o.context.route==H.path?d(e,r,c,p):E(e)})}),i(()=>{e._x_PineconeRouter_undoTemplate&&e._x_PineconeRouter_undoTemplate()})}),a.$router=o.context,a.magic("router",()=>o.context),document.addEventListener("alpine:initialized",()=>{T("init"),o.settings.hash==!1?g(location.pathname,!1,!0):g(location.hash.substring(1),!1,!0)}),window.addEventListener("popstate",()=>{o.settings.hash?window.location.hash!=""&&g(window.location.hash.substring(1),!0):g(window.location.pathname,!0)}),b();function b(){function e(n){if(!n||!n.getAttribute)return;let r=n.getAttribute("href"),t=n.getAttribute("target");if(!(!r||!r.match(/^\//g)||t&&!t.match(/^_?self$/i)))return typeof r!="string"&&r.url&&(r=r.url),r}window.document.body.addEventListener("click",function(n){if(n.ctrlKey||n.metaKey||n.altKey||n.shiftKey||n.button||n.defaultPrevented)return;let r=o.routes[x(o.context.route)]??o.notfound;r.handlersDone||(r.cancelHandlers=!0,l());let t=n.target;do if(t.localName==="a"&&t.getAttribute("href")){if(window.PineconeRouter.settings.interceptLinks==!1&&!t.hasAttribute("x-link")||t.hasAttribute("data-native")||t.hasAttribute("native"))return;let s=e(t);s&&(g(s),n.stopImmediatePropagation&&n.stopImmediatePropagation(),n.stopPropagation&&n.stopPropagation(),n.preventDefault());break}while(t=t.parentNode)})}async function g(e,n=!1,r=!1){e||(e="/"),o.context.path=e,o.settings.hash||(o.settings.basePath!="/"&&!e.startsWith(o.settings.basePath)&&(e=o.settings.basePath+e),e==o.settings.basePath&&!e.endsWith("/")&&(e+="/"));let t=o.routes.find(i=>{let c=k(e,i.path);return i.params=c!=!1?c:{},c!=!1})??o.notfound;t.handlersDone=!t.handlers.length,(t.handlers.length||t.template)&&R();let s=$(t.path,e,t.params);if(o.context=s,T("onBeforeHandlersExecuted",t,e,r)=="stop"){l();return}if(!n){let i="";if(o.settings.hash?(i="#",i+=window.location.search+e):i=e+window.location.search+window.location.hash,!r)history.pushState({path:i},"",i);else if(o.settings.hash&&e=="/")return o.context=s,g("/",!1,!1)}if(t&&t.handlers.length){if(t.cancelHandlers=!1,!await W(t.handlers,s)){l();return}t.handlersDone=!0,t.template||l()}if(t.template&&t.programmaticTemplate){let i=document.getElementById(t.templateTargetId)??document.getElementById(o.settings.templateTargetId);u[t.template]?(i.innerHTML=u[t.template],l()):P(i,t.template).then(()=>{l()})}T("onHandlersExecuted",t,e,r)}function $(e,n,r){return{route:e,path:n,params:r,query:window.location.search.substring(1),hash:window.location.hash.substring(1),redirect(t){return g(t),"stop"},navigate(t){g(t)}}}function C(e,n,r){if(e.indexOf(n)===-1)return r;let t=e[e.indexOf(n)+1];if(!t)return r;if(n==="target"){let s=t.match(/([a-z0-9_-]+)/);if(s)return s[1]}return t}async function W(e,n){for(let r=0;r{window.Alpine.plugin(S)});})();
+(()=>{var I=class{params={};path;handlers=[];constructor(o,f={}){this.path=o,Object.keys(f).forEach(u=>{this[u]=f[u]}),f.template&&(this.programmaticTemplate=!0)}template="";templateTargetId="";programmaticTemplate=!1;handlersDone=!1;cancelHandlers},L=I;function C(a){return a.replace(/(^\/+|\/+$)/g,"").split("/")}function k(a,o){let f=/(?:\?([^#]*))?(#.*)?$/,u=a.match(f),w={},_;if(u&&u[1]){let d=u[1].split("&");for(let R=0;Rr.path==e)!=null)throw new Error("Pinecone Router: route already exist");return this.routes.push(new L(e,n))-1},remove(e){this.routes=this.routes.filter(n=>n.path!=e)},loadStart:new Event("pinecone-start"),loadEnd:new Event("pinecone-end")});window.PineconeRouter=o;var f={},u={};let w=new Set;var _={};let P=(e,n,r=!1)=>(f[n]&&!r?f[n].then(t=>e.innerHTML=t):f[n]=fetch(n).then(t=>t.ok?t.text():(D(t.statusText),null)).then(t=>t==null?(u[n]=null,f[n]=null,null):(u[n]=t,e.innerHTML=t,t)),f[n]),m=(e,n,r)=>{if(w.has(n))return;w.add(n);let t=e.content.cloneNode(!0).firstElementChild;t&&(a.addScopeToNode(t,{},e),a.mutateDom(()=>{r!=null?r.appendChild(t):e.after(t),a.initTree(t)}),e._x_PineconeRouter_CurrentTemplate=t,e._x_PineconeRouter_undoTemplate=()=>{t.remove(),delete e._x_PineconeRouter_CurrentTemplate},a.nextTick(()=>w.delete(n)))};function E(e){e._x_PineconeRouter_undoTemplate&&(e._x_PineconeRouter_undoTemplate(),delete e._x_PineconeRouter_undoTemplate)}function d(e,n,r,t){if(e._x_PineconeRouter_CurrentTemplate)return e._x_PineconeRouter_CurrentTemplate;e.content.firstElementChild?(m(e,n,t),l()):r&&(u[r]?(e.innerHTML=u[r],m(e,n,t),l()):_[r]?_[r].then(()=>m(e,n,t)):P(e,r).then(()=>m(e,n,t)).finally(()=>l()))}let R=()=>{document.dispatchEvent(o.loadStart)},l=()=>{document.dispatchEvent(o.loadEnd)},y=e=>!o.settings.hash&&o.settings.basePath!="/"?o.settings.basePath+e:e,T=e=>o.routes.findIndex(n=>n.path==e);a.directive("route",(e,{expression:n,modifiers:r},{effect:t,cleanup:s})=>{let i=n;if(x("onBeforeRouteProcessed",e,i),i.indexOf("#")>-1)throw new Error("Pinecone Router: A route's path may not have a hash character.");let c=M(r,"target",null)??window.PineconeRouter.settings.templateTargetId,h=document.getElementById(c);if(c&&!h)throw new Error("Pinecone Router: Can't find an element with the suplied target ID: "+c);let p=null;i!="notfound"&&(i=y(i),p=o.add(i));let v=o.routes[p]??o.notfound;e._x_PineconeRouter_route=i,e.content.firstElementChild!=null&&a.nextTick(()=>{t(()=>{v.handlersDone&&o.context.route==i?d(e,n,null,h):E(e)})}),s(()=>{e._x_PineconeRouter_undoTemplate&&e._x_PineconeRouter_undoTemplate(),o.remove(i),delete e._x_PineconeRouter_route}),x("onAfterRouteProcessed",e,i)}),a.directive("handler",(e,{expression:n},{evaluate:r,cleanup:t})=>{if(!e._x_PineconeRouter_route)throw new Error("Pinecone Router: x-handler must be set on the same element as x-route.");let s;!(n.startsWith("[")&&n.endsWith("]"))&&!(n.startsWith("Array(")&&n.endsWith(")"))&&(n=`[${n}]`);let i=r(n);if(typeof i=="object")s=i;else throw new Error(`Pinecone Router: Invalid handler type: ${typeof i}.`);for(let p=0;p{h.handlers=[],h.handlersDone=!0,h.cancelHandlers=!1})}),a.directive("template",(e,{modifiers:n,expression:r},{Alpine:t,effect:s,cleanup:i})=>{if(!e._x_PineconeRouter_route)throw new Error("Pinecone Router: x-template must be used on the same element as x-route.");if(e.content.firstElementChild!=null)throw new Error("Pinecone Router: x-template cannot be used alongside an inline template (template element should not have a child).");let c=r,h=M(n,"target",null)??window.PineconeRouter.settings.templateTargetId,p=document.getElementById(h);if(h&&!p)throw new Error("Pinecone Router: Can't find an element with the suplied target ID: "+h);n.includes("preload")&&(_[c]=P(e,c).finally(()=>{_[c]=null,l()}));let v=e._x_PineconeRouter_route,H=v=="notfound"?o.notfound:o.routes[T(v)];H.template=c,t.nextTick(()=>{s(()=>{H.handlersDone&&o.context.route==H.path?d(e,r,c,p):E(e)})}),i(()=>{e._x_PineconeRouter_undoTemplate&&e._x_PineconeRouter_undoTemplate()})}),a.$router=o.context,a.magic("router",()=>o.context),document.addEventListener("alpine:initialized",()=>{x("init"),o.settings.hash==!1?g(location.pathname,!1,!0):g(location.hash.substring(1),!1,!0)}),window.addEventListener("popstate",()=>{o.settings.hash?window.location.hash!=""&&g(window.location.hash.substring(1),!0):g(window.location.pathname,!0)}),b();function b(){function e(n){if(!n||!n.getAttribute)return;let r=n.getAttribute("href"),t=n.getAttribute("target");if(!(!r||!r.match(/^\//g)||t&&!t.match(/^_?self$/i)))return typeof r!="string"&&r.url&&(r=r.url),r}window.document.body.addEventListener("click",function(n){if(n.ctrlKey||n.metaKey||n.altKey||n.shiftKey||n.button||n.defaultPrevented)return;let r=o.routes[T(o.context.route)]??o.notfound;r.handlersDone||(r.cancelHandlers=!0,l());let t=n.target;do if(t.localName==="a"&&t.getAttribute("href")){if(window.PineconeRouter.settings.interceptLinks==!1&&!t.hasAttribute("x-link")||t.hasAttribute("data-native")||t.hasAttribute("native"))return;let s=e(t);s&&(g(s),n.stopImmediatePropagation&&n.stopImmediatePropagation(),n.stopPropagation&&n.stopPropagation(),n.preventDefault());break}while(t=t.parentNode)})}async function g(e,n=!1,r=!1){e||(e="/"),o.context.path=e,o.settings.hash||(o.settings.basePath!="/"&&!e.startsWith(o.settings.basePath)&&(e=o.settings.basePath+e),e==o.settings.basePath&&!e.endsWith("/")&&(e+="/"));let t=o.routes.find(i=>{let c=k(e,i.path);return i.params=c!=!1?c:{},c!=!1})??o.notfound;t.handlersDone=!t.handlers.length,(t.handlers.length||t.template)&&R();let s=$(t.path,e,t.params);if(o.context=s,x("onBeforeHandlersExecuted",t,e,r)=="stop"){l();return}if(!n){let i="";if(o.settings.hash?(i="#",i+=window.location.search+e):i=e+window.location.search+window.location.hash,!r)history.pushState({path:i},"",i);else if(o.settings.hash&&e=="/")return o.context=s,g("/",!1,!1)}if(t&&t.handlers.length){if(t.cancelHandlers=!1,!await W(t.handlers,s)){l();return}t.handlersDone=!0,t.template||l()}if(t.template&&t.programmaticTemplate){let i=t.templateTargetId?document.getElementById(t.templateTargetId):document.getElementById(o.settings.templateTargetId);u[t.template]?(i.innerHTML=u[t.template],l()):P(i,t.template).then(()=>{l()})}x("onHandlersExecuted",t,e,r)}function $(e,n,r){return{route:e,path:n,params:r,query:window.location.search.substring(1),hash:window.location.hash.substring(1),redirect(t){return g(t),"stop"},navigate(t){g(t)}}}function M(e,n,r){if(e.indexOf(n)===-1)return r;let t=e[e.indexOf(n)+1];if(!t)return r;if(n==="target"){let s=t.match(/([a-z0-9_-]+)/);if(s)return s[1]}return t}async function W(e,n){for(let r=0;r{window.Alpine.plugin(S)});})();
//# sourceMappingURL=router.min.js.map
diff --git a/dist/router.min.js.map b/dist/router.min.js.map
index 03009ce..94b6e9c 100644
--- a/dist/router.min.js.map
+++ b/dist/router.min.js.map
@@ -1,7 +1,7 @@
{
"version": 3,
"sources": ["../src/route.ts", "../src/utils.ts", "../src/index.ts", "../builds/cdn.js"],
- "sourcesContent": ["import type { Handler } from './types'\n\nclass Route {\n\tparams: { [key: string]: any } = {}\n\tpath: string\n\thandlers: Handler[] = []\n\tconstructor(path: string, options: { [key: string]: any } = {}) {\n\t\tthis.path = path\n\t\tObject.keys(options).forEach((opt) => {\n\t\t\tthis[opt] = options[opt]\n\t\t})\n\t\tif (options.template) {\n\t\t\tthis.programmaticTemplate = true\n\t\t}\n\t}\n\ttemplate: string = ''\n\ttemplateTargetId: string = ''\n\tprogrammaticTemplate: boolean = false\n\thandlersDone: boolean = false\n\tcancelHandlers: boolean\n}\n\nexport default Route\n", "/**\n * taken from preact-router\n * https://github.com/preactjs/preact-router\n * @param url url to segmentize\n * @returns\n */\nfunction segmentize(url: string): string[] {\n\treturn url.replace(/(^\\/+|\\/+$)/g, '').split('/')\n}\n\n/**\n * check if a path match with this route\n * taken from preact-router\n * https://github.com/preactjs/preact-router\n * @param path {string}\n * @param routePath {string}\n * @returns {false|object}\n */\nexport function match(url: string, routePath: string): false | object {\n\tlet reg = /(?:\\?([^#]*))?(#.*)?$/,\n\t\tc = url.match(reg),\n\t\tmatches: any = {},\n\t\tret\n\tif (c && c[1]) {\n\t\tlet p = c[1].split('&')\n\t\tfor (let i = 0; i < p.length; i++) {\n\t\t\tlet r = p[i].split('=')\n\t\t\tmatches[decodeURIComponent(r[0])] = decodeURIComponent(\n\t\t\t\tr.slice(1).join('=')\n\t\t\t)\n\t\t}\n\t}\n\tlet urlSeg = segmentize(url.replace(reg, '')),\n\t\troute: string[] = segmentize(routePath || ''),\n\t\tmax = Math.max(urlSeg.length, route.length)\n\tfor (let i = 0; i < max; i++) {\n\t\tif (route[i] && route[i].charAt(0) === ':') {\n\t\t\tlet param: string = route[i].replace(/(^:|[+*?]+$)/g, ''),\n\t\t\t\tflags: string = (route[i].match(/[+*?]+$/) || {}).toString()[0],\n\t\t\t\tplus = ~flags.indexOf('+'),\n\t\t\t\tstar = ~flags.indexOf('*'),\n\t\t\t\tval = urlSeg[i] || ''\n\t\t\tif (!val && !star && (flags.indexOf('?') < 0 || plus)) {\n\t\t\t\tret = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tmatches[param] = decodeURIComponent(val)\n\t\t\tif (plus || star) {\n\t\t\t\tmatches[param] = urlSeg\n\t\t\t\t\t.slice(i)\n\t\t\t\t\t.map(decodeURIComponent)\n\t\t\t\t\t.join('/')\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else if (route[i] !== urlSeg[i]) {\n\t\t\tret = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif (ret === false) return false\n\treturn matches\n}\n\n/**\n * Call a function on all middlewares loaded, if any.\n * @param {string} func middleware function to call.\n * @param {any} args arguments to pass to the function.\n * @returns {boolean} false if the middleware function return false, i.e. it want to stop execution of the function and return.\n */\nexport function middleware(func: string, ...args: any): string | undefined {\n\tif (!window.PineconeRouterMiddlewares) return\n\tfor (const i in window.PineconeRouterMiddlewares) {\n\t\tlet plugin: any = window.PineconeRouterMiddlewares[i]\n\t\tif (plugin[func] == null) return\n\t\tlet ret = plugin[func](...args)\n\t\t// the return of the function will only be 'stop'\n\t\t// if the middleware request stopping the navigate function.\n\t\tif (ret == 'stop') return 'stop'\n\t}\n}\n\nexport function fetchError(error: string) {\n\tdocument.dispatchEvent(\n\t\tnew CustomEvent('fetch-error', { detail: error })\n\t)\n}", "import Route from './route'\nimport type { Settings, Context, Middleware, Handler } from './types'\nimport { fetchError, match, middleware } from './utils'\n\n\ndeclare global {\n\tinterface Window {\n\t\tPineconeRouter: {\n\t\t\tversion: string\n\t\t\tname: string\n\t\t\tsettings: Settings\n\t\t\tnotfound: Route\n\t\t\troutes: Route[]\n\t\t\tcontext: Context\n\t\t\tloadStart: Event\n\t\t\tloadEnd: Event\n\t\t\tadd: (path: string, options?: {}) => number\n\t\t\tremove: (path: string) => void\n\t\t}\n\t\tPineconeRouterMiddlewares: Array\n\t}\n\tinterface HTMLTemplateElement {\n\t\t_x_PineconeRouter_undoTemplate: Function\n\t\t_x_PineconeRouter_CurrentTemplate: Element\n\t\t_x_PineconeRouter_route: string\n\t}\n}\n\nexport default function (Alpine) {\n\n\tconst PineconeRouter = Alpine.reactive({\n\t\tversion: '4.4.0',\n\t\tname: 'pinecone-router',\n\n\t\tsettings: {\n\t\t\thash: false,\n\t\t\tbasePath: '/',\n\t\t\ttemplateTargetId: null,\n\t\t\tinterceptLinks: true\n\t\t},\n\n\t\t/**\n\t\t * @description The handler for 404 pages, can be overwritten by a notfound route\n\t\t */\n\t\tnotfound: new Route('notfound'),\n\n\t\t/**\n\t\t * @type Route[]\n\t\t * @summary array of routes instantiated from the Route class.\n\t\t */\n\t\troutes: [],\n\n\t\t/**\n\t\t * @type {Context}\n\t\t * @summary The context object for current path.\n\t\t */\n\t\tcontext: {\n\t\t\troute: '',\n\t\t\tpath: '',\n\t\t\tparams: {},\n\t\t\tquery: window.location.search.substring(1),\n\t\t\thash: window.location.hash.substring(1),\n\t\t\tredirect(path) {\n\t\t\t\tnavigate(path)\n\t\t\t\treturn 'stop'\n\t\t\t},\n\t\t\tnavigate(path) {\n\t\t\t\tnavigate(path)\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Add a new route\n\t\t */\n\t\tadd(path: string, options?: {}) {\n\t\t\t// check if the route was registered on the same router.\n\t\t\tif (this.routes.find((r: Route) => r.path == path) != null) {\n\t\t\t\tthrow new Error('Pinecone Router: route already exist')\n\t\t\t}\n\n\t\t\treturn this.routes.push(new Route(path, options)) - 1\n\t\t},\n\t\t/**\n\t\t * Remove a route\n\t\t */\n\t\tremove(path: string) {\n\t\t\tthis.routes = this.routes.filter((r: Route) => r.path != path)\n\t\t},\n\t\t/**\n\t\t * @event pinecone-start\n\t\t * @summary be dispatched to the window after before page start loading.\n\t\t */\n\t\tloadStart: new Event('pinecone-start'),\n\n\t\t/**\n\t\t * @event pinecone-end\n\t\t * @summary will be dispatched to the window after the views are fetched\n\t\t */\n\t\tloadEnd: new Event('pinecone-end'),\n\t})\n\n\twindow.PineconeRouter = PineconeRouter\n\n\tvar loadingTemplates: { [key: string]: Promise } = {}\n\tvar cachedTemplates: { [key: string]: string } = {}\n\tconst inMakeProgress = new Set()\n\tvar preloadingTemplates: { [key: string]: Promise } = {}\n\n\tconst load = (el: HTMLTemplateElement | HTMLElement, url: string, programmaticRoute: boolean = false) => {\n\t\tif (loadingTemplates[url] && !programmaticRoute) {\n\t\t\tloadingTemplates[url].then(html => el.innerHTML = html)\n\t\t} else {\n\t\t\tloadingTemplates[url] = fetch(url).then(r => {\n\t\t\t\tif (!r.ok) {\n\t\t\t\t\tfetchError(r.statusText);\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\treturn r.text()\n\t\t\t}).then(html => {\n\t\t\t\tif (html == null) {\n\t\t\t\t\tcachedTemplates[url] = null;\n\t\t\t\t\tloadingTemplates[url] = null\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tcachedTemplates[url] = html\n\t\t\t\tel.innerHTML = html\n\t\t\t\treturn html\n\t\t\t})\n\t\t}\n\t\treturn loadingTemplates[url]\n\t}\n\n\tconst make = (el: HTMLTemplateElement, expression: string, targetEl?: HTMLElement) => {\n\t\tif (inMakeProgress.has(expression)) return\n\t\tinMakeProgress.add(expression)\n\n\t\tconst clone = (el.content.cloneNode(true) as HTMLElement).firstElementChild\n\n\t\tif (!clone) return\n\n\t\tAlpine.addScopeToNode(clone, {}, el)\n\n\t\tAlpine.mutateDom(() => {\n\t\t\tif (targetEl != null) {\n\t\t\t\ttargetEl.appendChild(clone)\n\t\t\t} else\n\t\t\t\tel.after(clone)\n\t\t\tAlpine.initTree(clone)\n\t\t})\n\n\t\tel._x_PineconeRouter_CurrentTemplate = clone\n\n\t\tel._x_PineconeRouter_undoTemplate = () => {\n\t\t\tclone.remove()\n\n\t\t\tdelete el._x_PineconeRouter_CurrentTemplate\n\t\t}\n\n\t\tAlpine.nextTick(() => inMakeProgress.delete(expression))\n\t}\n\n\tfunction hide(el: HTMLTemplateElement) {\n\t\tif (el._x_PineconeRouter_undoTemplate) {\n\t\t\tel._x_PineconeRouter_undoTemplate()\n\t\t\tdelete el._x_PineconeRouter_undoTemplate\n\t\t}\n\t}\n\n\tfunction show(el: HTMLTemplateElement, expression: string, url?: string, targetEl?: HTMLElement) {\n\t\tif (el._x_PineconeRouter_CurrentTemplate) return el._x_PineconeRouter_CurrentTemplate\n\t\tif (el.content.firstElementChild) {\n\t\t\tmake(el, expression, targetEl)\n\t\t\tendLoading()\n\t\t} else if (url) {\n\t\t\t// Since during loading, the content is automatically put inside the template\n\t\t\t// This first case will only happen if the content of the template was cleared somehow\n\t\t\t// Likely manually\n\t\t\tif (cachedTemplates[url]) {\n\n\t\t\t\tel.innerHTML = cachedTemplates[url]\n\t\t\t\tmake(el, expression, targetEl)\n\t\t\t\tendLoading()\n\t\t\t} else {\n\t\t\t\t// This second case is that it didn't finish loading\n\t\t\t\tif (preloadingTemplates[url]) {\n\t\t\t\t\tpreloadingTemplates[url].then(() => make(el, expression, targetEl))\n\t\t\t\t} else {\n\t\t\t\t\tload(el, url).then(() => make(el, expression, targetEl)).finally(() => endLoading())\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst startLoading = () => {\n\t\tdocument.dispatchEvent(PineconeRouter.loadStart)\n\t}\n\n\tconst endLoading = () => {\n\t\tdocument.dispatchEvent(PineconeRouter.loadEnd)\n\t}\n\n\tconst addBasePath = (path) => {\n\t\tif (!PineconeRouter.settings.hash && PineconeRouter.settings.basePath != '/') {\n\t\t\treturn PineconeRouter.settings.basePath + path\n\t\t} return path\n\t}\n\n\tconst findRouteIndex = (path) => {\n\t\treturn PineconeRouter.routes.findIndex(\n\t\t\t(r) => r.path == path\n\t\t)\n\t}\n\n\tAlpine.directive(\n\t\t'route',\n\t\t(el: HTMLTemplateElement, { expression, modifiers }, { effect, cleanup }) => {\n\t\t\tlet path = expression\n\n\t\t\tmiddleware('onBeforeRouteProcessed', el, path)\n\n\t\t\tif (path.indexOf('#') > -1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Pinecone Router: A route's path may not have a hash character.`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tlet target = modifierValue(modifiers, 'target', null) ?? window.PineconeRouter.settings.templateTargetId\n\t\t\tlet targetEl = document.getElementById(target)\n\t\t\tif (target && !targetEl)\n\t\t\t\tthrow new Error(\"Pinecone Router: Can't find an element with the suplied target ID: \" + target + \"\")\n\n\t\t\tlet routeIndex = null\n\n\t\t\tif (path != 'notfound') {\n\t\t\t\t// if specified add the basePath\n\t\t\t\tpath = addBasePath(path)\n\t\t\t\t// register the new route if possible\n\t\t\t\trouteIndex = PineconeRouter.add(path)\n\t\t\t}\n\n\t\t\tlet route = PineconeRouter.routes[routeIndex] ?? PineconeRouter.notfound\n\n\t\t\t// set the path in the element so it is used by other directives\n\t\t\tel._x_PineconeRouter_route = path\n\n\t\t\tif (el.content.firstElementChild != null) {\n\t\t\t\tAlpine.nextTick(() => {\n\t\t\t\t\teffect(() => {\n\t\t\t\t\t\tlet found = route.handlersDone && PineconeRouter.context.route == path\n\t\t\t\t\t\tfound ? show(el, expression, null, targetEl) : hide(el)\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tcleanup(() => {\n\t\t\t\tel._x_PineconeRouter_undoTemplate && el._x_PineconeRouter_undoTemplate();\n\t\t\t\tPineconeRouter.remove(path);\n\t\t\t\tdelete el._x_PineconeRouter_route\n\t\t\t})\n\n\t\t\tmiddleware('onAfterRouteProcessed', el, path)\n\n\n\t\t}\n\t)\n\n\tAlpine.directive(\n\t\t'handler',\n\t\t(\n\t\t\tel,\n\t\t\t{ expression },\n\t\t\t{ evaluate, cleanup }\n\t\t) => {\n\t\t\tif (!el._x_PineconeRouter_route) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Pinecone Router: x-handler must be set on the same element as x-route.`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tlet handlers\n\n\t\t\t// check if the handlers expression is an array\n\t\t\t// if not make it one\n\t\t\tif (\n\t\t\t\t!(expression.startsWith('[') && expression.endsWith(']')) &&\n\t\t\t\t!(expression.startsWith('Array(') && expression.endsWith(')'))\n\t\t\t) {\n\t\t\t\texpression = `[${expression}]`\n\t\t\t}\n\n\t\t\tlet evaluatedExpression = evaluate(expression)\n\n\t\t\tif (typeof evaluatedExpression == 'object')\n\t\t\t\thandlers = evaluatedExpression\n\t\t\telse {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Pinecone Router: Invalid handler type: ${typeof evaluatedExpression}.`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// add `this` context for handlers inside an Alpine.component\n\t\t\tfor (let index = 0; index < handlers.length; index++) {\n\t\t\t\thandlers[index] = handlers[index].bind(Alpine.$data(el))\n\t\t\t}\n\n\t\t\t// add handlers to the route\n\t\t\tlet path = el._x_PineconeRouter_route\n\t\t\tlet route = path == 'notfound' ? PineconeRouter.notfound : PineconeRouter.routes[findRouteIndex(path)];\n\t\t\troute.handlers = handlers\n\n\t\t\tcleanup(() => {\n\t\t\t\troute.handlers = []\n\t\t\t\troute.handlersDone = true\n\t\t\t\troute.cancelHandlers = false\n\t\t\t})\n\t\t}\n\t)\n\n\tAlpine.directive(\n\t\t'template',\n\t\t(el: HTMLTemplateElement, { modifiers, expression }, { Alpine, effect, cleanup }) => {\n\n\t\t\tif (!el._x_PineconeRouter_route) throw new Error(\"Pinecone Router: x-template must be used on the same element as x-route.\")\n\n\t\t\tif (el.content.firstElementChild != null) throw new Error(\"Pinecone Router: x-template cannot be used alongside an inline template (template element should not have a child).\")\n\n\t\t\tlet url: string = expression\n\n\t\t\tlet target = modifierValue(modifiers, 'target', null) ?? window.PineconeRouter.settings.templateTargetId\n\t\t\tlet targetEl = document.getElementById(target)\n\n\t\t\tif (target && !targetEl)\n\t\t\t\tthrow new Error(\"Pinecone Router: Can't find an element with the suplied target ID: \" + target + \"\")\n\n\t\t\tif (modifiers.includes(\"preload\")) {\n\t\t\t\tpreloadingTemplates[url] = load(el, url).finally(() => {\n\t\t\t\t\tpreloadingTemplates[url] = null;\n\t\t\t\t\tendLoading()\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// add template to the route\n\t\t\tlet path = el._x_PineconeRouter_route\n\t\t\tlet route = path == 'notfound' ? PineconeRouter.notfound : PineconeRouter.routes[findRouteIndex(path)];\n\t\t\troute.template = url\n\n\n\t\t\tAlpine.nextTick(() => {\n\t\t\t\teffect(() => {\n\t\t\t\t\tlet found = route.handlersDone && PineconeRouter.context.route == route.path\n\t\t\t\t\tfound ? show(el, expression, url, targetEl) : hide(el)\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tcleanup(() => {\n\t\t\t\tel._x_PineconeRouter_undoTemplate && el._x_PineconeRouter_undoTemplate();\n\t\t\t})\n\n\t\t}\n\t)\n\n\tAlpine.$router = PineconeRouter.context\n\tAlpine.magic('router', () => PineconeRouter.context)\n\n\tdocument.addEventListener('alpine:initialized', () => {\n\t\tmiddleware('init')\n\t\t// virtually navigate the path on the first page load\n\t\t// this will register the path in history and sets the pathvariable\n\t\t// navigate(window.location.pathname, false, true)\n\t\tif (PineconeRouter.settings.hash == false) {\n\t\t\t// navigate to the current page to handle it\n\t\t\t// ONLY if we not using hash routing for the default router\n\t\t\tnavigate(location.pathname, false, true)\n\t\t} else {\n\t\t\tnavigate(location.hash.substring(1), false, true)\n\t\t}\n\t})\n\n\t// handle navigation events not emitted by links, for example, back button.\n\twindow.addEventListener('popstate', () => {\n\t\tif (PineconeRouter.settings.hash) {\n\t\t\tif (window.location.hash != '') {\n\t\t\t\tnavigate(window.location.hash.substring(1), true)\n\t\t\t}\n\t\t} else {\n\t\t\tnavigate(window.location.pathname, true)\n\t\t}\n\t})\n\n\t// intercept click event in links\n\tinterceptLinks()\n\n\t/**\n\t * @description Add a handler to click events on all valid links\n\t */\n\tfunction interceptLinks() {\n\t\tfunction validateLink(node) {\n\t\t\t// only valid elements\n\t\t\tif (!node || !node.getAttribute) return;\n\n\t\t\tlet href = node.getAttribute('href'),\n\t\t\t\ttarget = node.getAttribute('target');\n\n\t\t\t// ignore links with targets and non-path URLs\n\t\t\tif (!href || !href.match(/^\\//g) || (target && !target.match(/^_?self$/i)))\n\t\t\t\treturn;\n\n\t\t\tif (typeof href !== 'string' && href.url) {\n\t\t\t\thref = href.url;\n\t\t\t}\n\t\t\treturn href\n\n\t\t}\n\t\twindow.document.body.addEventListener(\n\t\t\t'click',\n\t\t\tfunction (e: any) {\n\t\t\t\tif (e.ctrlKey || e.metaKey || e.altKey || e.shiftKey || e.button || e.defaultPrevented) return;\n\n\n\t\t\t\tlet currentRoute = PineconeRouter.routes[findRouteIndex(PineconeRouter.context.route)] ?? PineconeRouter.notfound\n\n\t\t\t\t// stop handlers in progress before navigating to the next page\n\t\t\t\tif (!currentRoute.handlersDone) {\n\t\t\t\t\tcurrentRoute.cancelHandlers = true\n\t\t\t\t\tendLoading()\n\t\t\t\t}\n\n\t\t\t\tlet node = e.target;\n\n\t\t\t\tdo {\n\t\t\t\t\tif (node.localName === 'a' && node.getAttribute('href')) {\n\t\t\t\t\t\tif (window.PineconeRouter.settings.interceptLinks == false && !node.hasAttribute('x-link')) return\n\t\t\t\t\t\tif (node.hasAttribute('data-native') || node.hasAttribute('native')) return;\n\t\t\t\t\t\tlet href = validateLink(node)\n\t\t\t\t\t\tif (href) {\n\t\t\t\t\t\t\tnavigate(href)\n\t\t\t\t\t\t\tif (e.stopImmediatePropagation) e.stopImmediatePropagation();\n\t\t\t\t\t\t\tif (e.stopPropagation) e.stopPropagation();\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} while ((node = node.parentNode));\n\t\t\t}\n\t\t)\n\t}\n\n\t/**\n\t * Go to the specified path without reloading\n\t * @param {string} path the path with no hash even if using hash routing\n\t * @param {boolean} fromPopState this will be set to true if called from window.onpopstate event\n\t * @param {boolean} firstLoad this will be set to true if this is the first page loaded, also from page reload\n\t */\n\tasync function navigate(path, fromPopState = false, firstLoad = false) {\n\t\tif (!path) path = '/'\n\t\tPineconeRouter.context.path = path\n\n\t\t// only add basePath if it was set\n\t\t// if not using hash routing\n\t\t// and if it wasn't added already\n\t\tif (!PineconeRouter.settings.hash) {\n\t\t\tif (\n\t\t\t\tPineconeRouter.settings.basePath != '/' &&\n\t\t\t\t!path.startsWith(PineconeRouter.settings.basePath)\n\t\t\t) {\n\t\t\t\tpath = PineconeRouter.settings.basePath + path\n\t\t\t}\n\t\t\tif (\n\t\t\t\tpath == PineconeRouter.settings.basePath &&\n\t\t\t\t!path.endsWith('/')\n\t\t\t) {\n\t\t\t\tpath += '/'\n\t\t\t}\n\t\t}\n\n\t\tconst route: Route = PineconeRouter.routes.find(\n\t\t\t(route: Route) => {\n\t\t\t\tlet m = match(path, route.path)\n\t\t\t\troute.params = m != false ? m : {}\n\t\t\t\treturn m != false\n\t\t\t}\n\t\t) ?? PineconeRouter.notfound\n\n\t\t// if the route has handlres, it will mark them unhandled\n\t\t// this is so templates wont render till then.\n\t\troute.handlersDone = !route.handlers.length\n\n\t\tif (route.handlers.length || route.template) {\n\t\t\tstartLoading()\n\t\t}\n\n\t\tlet context = buildContext(route.path, path, route.params)\n\n\t\tPineconeRouter.context = context\n\n\t\t// the middleware may return 'stop' to stop execution of this function\n\t\tif (\n\t\t\tmiddleware('onBeforeHandlersExecuted', route, path, firstLoad) == 'stop'\n\t\t) {\n\t\t\tendLoading()\n\t\t\treturn\n\t\t}\n\n\n\t\t// do not call pushstate from popstate event https://stackoverflow.com/a/50830905\n\t\tif (!fromPopState) {\n\t\t\tlet fullPath = ''\n\t\t\tif (PineconeRouter.settings.hash) {\n\t\t\t\tfullPath = '#'\n\t\t\t\tfullPath += window.location.search + path\n\t\t\t} else {\n\t\t\t\tfullPath = path + window.location.search + window.location.hash\n\t\t\t}\n\t\t\t// don't create duplicate history entry on first page load\n\t\t\tif (!firstLoad) history.pushState({ path: fullPath }, '', fullPath)\n\t\t\telse {\n\t\t\t\tif (PineconeRouter.settings.hash) {\n\t\t\t\t\tif (path == '/') {\n\t\t\t\t\t\tPineconeRouter.context = context\n\t\t\t\t\t\treturn navigate('/', false, false)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\t(route && route.handlers.length)\n\t\t) {\n\t\t\troute.cancelHandlers = false\n\t\t\tlet ok = await handle(route.handlers, context)\n\t\t\tif (!ok) {\n\t\t\t\tendLoading()\n\t\t\t\treturn\n\t\t\t}\n\t\t\troute.handlersDone = true\n\t\t\tif (!route.template) endLoading()\n\t\t}\n\n\n\t\t// show templates added programmatically\n\t\tif (route.template && route.programmaticTemplate) {\n\t\t\tlet target = document.getElementById(route.templateTargetId) ?? document.getElementById(PineconeRouter.settings.templateTargetId)\n\t\t\tif (cachedTemplates[route.template]) {\n\t\t\t\ttarget.innerHTML = cachedTemplates[route.template]\n\t\t\t\tendLoading()\n\t\t\t}\n\t\t\telse {\n\t\t\t\tload(target, route.template).then(() => {\n\t\t\t\t\tendLoading()\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\n\t\tmiddleware('onHandlersExecuted', route, path, firstLoad)\n\t}\n\n\tfunction buildContext(route: string, path: string, params: {}): Context {\n\t\treturn {\n\t\t\troute: route,\n\t\t\tpath: path,\n\t\t\tparams: params,\n\t\t\tquery: window.location.search.substring(1), // query w/out leading '?'\n\t\t\thash: window.location.hash.substring(1), // hash without leading '#'\n\t\t\tredirect(path) {\n\t\t\t\tnavigate(path)\n\t\t\t\treturn 'stop'\n\t\t\t},\n\t\t\tnavigate(path) {\n\t\t\t\tnavigate(path)\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction modifierValue(modifiers, key, fallback) {\n\t\t// If the modifier isn't present, use the default.\n\t\tif (modifiers.indexOf(key) === -1) return fallback\n\n\t\t// If it IS present, grab the value after it\n\t\tconst rawValue = modifiers[modifiers.indexOf(key) + 1]\n\n\t\tif (!rawValue) return fallback\n\n\t\tif (key === 'target') {\n\t\t\tlet match = rawValue.match(/([a-z0-9_-]+)/)\n\t\t\tif (match) return match[1]\n\t\t}\n\t\treturn rawValue\n\t}\n\t/**\n\t * execute the handlers of routes that are given passing them the context.\n\t */\n\tasync function handle(handlers, context) {\n\t\tfor (let i = 0; i < handlers.length; i++) {\n\t\t\tif (typeof handlers[i] == 'function') {\n\t\t\t\t// stop if the handlers were canceled for example the user clicked a link\n\t\t\t\tlet route = PineconeRouter.routes[findRouteIndex(context.route)] ?? PineconeRouter.notfound\n\t\t\t\tif (route.cancelHandlers) {\n\t\t\t\t\troute.cancelHandlers = false\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tlet result\n\t\t\t\tif (handlers[i].constructor.name === 'AsyncFunction')\n\t\t\t\t\tresult = await handlers[i](context)\n\t\t\t\telse\n\t\t\t\t\tresult = handlers[i](context)\n\t\t\t\t// if the handler redirected, return\n\t\t\t\tif (result == 'stop') return false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n}\n\n", "import magic from '../src/index.js'\n\ndocument.addEventListener('alpine:init', () => {\n window.Al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C,EAAU,CAEhD,GAAI5B,EAAU,QAAQ2B,CAAG,IAAM,GAAI,OAAOC,EAG1C,IAAMC,EAAW7B,EAAUA,EAAU,QAAQ2B,CAAG,EAAI,CAAC,EAErD,GAAI,CAACE,EAAU,OAAOD,EAEtB,GAAID,IAAQ,SAAU,CACrB,IAAIN,EAAQQ,EAAS,MAAM,eAAe,EAC1C,GAAIR,EAAO,OAAOA,EAAM,CAAC,CAC1B,CACA,OAAOQ,CACR,CAIA,eAAeJ,EAAOhB,EAAUa,EAAS,CACxC,QAASQ,EAAI,EAAGA,EAAIrB,EAAS,OAAQqB,IACpC,GAAI,OAAOrB,EAASqB,CAAC,GAAK,WAAY,CAErC,IAAIvB,EAAQjC,EAAe,OAAOyB,EAAeuB,EAAQ,KAAK,CAAC,GAAKhD,EAAe,SACnF,GAAIiC,EAAM,eACT,OAAAA,EAAM,eAAiB,GAChB,GAER,IAAIwB,EAMJ,GALItB,EAASqB,CAAC,EAAE,YAAY,OAAS,gBACpCC,EAAS,MAAMtB,EAASqB,CAAC,EAAER,CAAO,EAElCS,EAAStB,EAASqB,CAAC,EAAER,CAAO,EAEzBS,GAAU,OAAQ,MAAO,EAC9B,CAED,MAAO,EACR,CACD,CClmBA,SAAS,iBAAiB,cAAe,IAAM,CAC7C,OAAO,OAAO,OAAOC,CAAK,CAC5B,CAAC",
+ "sourcesContent": ["import type { Handler } from './types'\n\nclass Route {\n\tparams: { [key: string]: any } = {}\n\tpath: string\n\thandlers: Handler[] = []\n\tconstructor(path: string, options: { [key: string]: any } = {}) {\n\t\tthis.path = path\n\t\tObject.keys(options).forEach((opt) => {\n\t\t\tthis[opt] = options[opt]\n\t\t})\n\t\tif (options.template) {\n\t\t\tthis.programmaticTemplate = true\n\t\t}\n\t}\n\ttemplate: string = ''\n\ttemplateTargetId: string = ''\n\tprogrammaticTemplate: boolean = false\n\thandlersDone: boolean = false\n\tcancelHandlers: boolean\n}\n\nexport default Route\n", "/**\n * taken from preact-router\n * https://github.com/preactjs/preact-router\n * @param url url to segmentize\n * @returns\n */\nfunction segmentize(url: string): string[] {\n\treturn url.replace(/(^\\/+|\\/+$)/g, '').split('/')\n}\n\n/**\n * check if a path match with this route\n * taken from preact-router\n * https://github.com/preactjs/preact-router\n * @param path {string}\n * @param routePath {string}\n * @returns {false|object}\n */\nexport function match(url: string, routePath: string): false | object {\n\tlet reg = /(?:\\?([^#]*))?(#.*)?$/,\n\t\tc = url.match(reg),\n\t\tmatches: any = {},\n\t\tret\n\tif (c && c[1]) {\n\t\tlet p = c[1].split('&')\n\t\tfor (let i = 0; i < p.length; i++) {\n\t\t\tlet r = p[i].split('=')\n\t\t\tmatches[decodeURIComponent(r[0])] = decodeURIComponent(\n\t\t\t\tr.slice(1).join('=')\n\t\t\t)\n\t\t}\n\t}\n\tlet urlSeg = segmentize(url.replace(reg, '')),\n\t\troute: string[] = segmentize(routePath || ''),\n\t\tmax = Math.max(urlSeg.length, route.length)\n\tfor (let i = 0; i < max; i++) {\n\t\tif (route[i] && route[i].charAt(0) === ':') {\n\t\t\tlet param: string = route[i].replace(/(^:|[+*?]+$)/g, ''),\n\t\t\t\tflags: string = (route[i].match(/[+*?]+$/) || {}).toString()[0],\n\t\t\t\tplus = ~flags.indexOf('+'),\n\t\t\t\tstar = ~flags.indexOf('*'),\n\t\t\t\tval = urlSeg[i] || ''\n\t\t\tif (!val && !star && (flags.indexOf('?') < 0 || plus)) {\n\t\t\t\tret = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tmatches[param] = decodeURIComponent(val)\n\t\t\tif (plus || star) {\n\t\t\t\tmatches[param] = urlSeg\n\t\t\t\t\t.slice(i)\n\t\t\t\t\t.map(decodeURIComponent)\n\t\t\t\t\t.join('/')\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else if (route[i] !== urlSeg[i]) {\n\t\t\tret = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif (ret === false) return false\n\treturn matches\n}\n\n/**\n * Call a function on all middlewares loaded, if any.\n * @param {string} func middleware function to call.\n * @param {any} args arguments to pass to the function.\n * @returns {boolean} false if the middleware function return false, i.e. it want to stop execution of the function and return.\n */\nexport function middleware(func: string, ...args: any): string | undefined {\n\tif (!window.PineconeRouterMiddlewares) return\n\tfor (const i in window.PineconeRouterMiddlewares) {\n\t\tlet plugin: any = window.PineconeRouterMiddlewares[i]\n\t\tif (plugin[func] == null) return\n\t\tlet ret = plugin[func](...args)\n\t\t// the return of the function will only be 'stop'\n\t\t// if the middleware request stopping the navigate function.\n\t\tif (ret == 'stop') return 'stop'\n\t}\n}\n\nexport function fetchError(error: string) {\n\tdocument.dispatchEvent(\n\t\tnew CustomEvent('fetch-error', { detail: error })\n\t)\n}", "import Route from './route'\nimport type { Settings, Context, Middleware, Handler } from './types'\nimport { fetchError, match, middleware } from './utils'\n\n\ndeclare global {\n\tinterface Window {\n\t\tPineconeRouter: {\n\t\t\tversion: string\n\t\t\tname: string\n\t\t\tsettings: Settings\n\t\t\tnotfound: Route\n\t\t\troutes: Route[]\n\t\t\tcontext: Context\n\t\t\tloadStart: Event\n\t\t\tloadEnd: Event\n\t\t\tadd: (path: string, options?: {}) => number\n\t\t\tremove: (path: string) => void\n\t\t}\n\t\tPineconeRouterMiddlewares: Array\n\t}\n\tinterface HTMLTemplateElement {\n\t\t_x_PineconeRouter_undoTemplate: Function\n\t\t_x_PineconeRouter_CurrentTemplate: Element\n\t\t_x_PineconeRouter_route: string\n\t}\n}\n\nexport default function (Alpine) {\n\n\tconst PineconeRouter = Alpine.reactive({\n\t\tversion: '4.4.1',\n\t\tname: 'pinecone-router',\n\n\t\tsettings: {\n\t\t\thash: false,\n\t\t\tbasePath: '/',\n\t\t\ttemplateTargetId: null,\n\t\t\tinterceptLinks: true\n\t\t},\n\n\t\t/**\n\t\t * @description The handler for 404 pages, can be overwritten by a notfound route\n\t\t */\n\t\tnotfound: new Route('notfound'),\n\n\t\t/**\n\t\t * @type Route[]\n\t\t * @summary array of routes instantiated from the Route class.\n\t\t */\n\t\troutes: [],\n\n\t\t/**\n\t\t * @type {Context}\n\t\t * @summary The context object for current path.\n\t\t */\n\t\tcontext: {\n\t\t\troute: '',\n\t\t\tpath: '',\n\t\t\tparams: {},\n\t\t\tquery: window.location.search.substring(1),\n\t\t\thash: window.location.hash.substring(1),\n\t\t\tredirect(path) {\n\t\t\t\tnavigate(path)\n\t\t\t\treturn 'stop'\n\t\t\t},\n\t\t\tnavigate(path) {\n\t\t\t\tnavigate(path)\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Add a new route\n\t\t */\n\t\tadd(path: string, options?: {}) {\n\t\t\t// check if the route was registered on the same router.\n\t\t\tif (this.routes.find((r: Route) => r.path == path) != null) {\n\t\t\t\tthrow new Error('Pinecone Router: route already exist')\n\t\t\t}\n\n\t\t\treturn this.routes.push(new Route(path, options)) - 1\n\t\t},\n\t\t/**\n\t\t * Remove a route\n\t\t */\n\t\tremove(path: string) {\n\t\t\tthis.routes = this.routes.filter((r: Route) => r.path != path)\n\t\t},\n\t\t/**\n\t\t * @event pinecone-start\n\t\t * @summary be dispatched to the window after before page start loading.\n\t\t */\n\t\tloadStart: new Event('pinecone-start'),\n\n\t\t/**\n\t\t * @event pinecone-end\n\t\t * @summary will be dispatched to the window after the views are fetched\n\t\t */\n\t\tloadEnd: new Event('pinecone-end'),\n\t})\n\n\twindow.PineconeRouter = PineconeRouter\n\n\tvar loadingTemplates: { [key: string]: Promise } = {}\n\tvar cachedTemplates: { [key: string]: string } = {}\n\tconst inMakeProgress = new Set()\n\tvar preloadingTemplates: { [key: string]: Promise } = {}\n\n\tconst load = (el: HTMLTemplateElement | HTMLElement, url: string, programmaticRoute: boolean = false) => {\n\t\tif (loadingTemplates[url] && !programmaticRoute) {\n\t\t\tloadingTemplates[url].then(html => el.innerHTML = html)\n\t\t} else {\n\t\t\tloadingTemplates[url] = fetch(url).then(r => {\n\t\t\t\tif (!r.ok) {\n\t\t\t\t\tfetchError(r.statusText);\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t\treturn r.text()\n\t\t\t}).then(html => {\n\t\t\t\tif (html == null) {\n\t\t\t\t\tcachedTemplates[url] = null;\n\t\t\t\t\tloadingTemplates[url] = null\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tcachedTemplates[url] = html\n\t\t\t\tel.innerHTML = html\n\t\t\t\treturn html\n\t\t\t})\n\t\t}\n\t\treturn loadingTemplates[url]\n\t}\n\n\tconst make = (el: HTMLTemplateElement, expression: string, targetEl?: HTMLElement) => {\n\t\tif (inMakeProgress.has(expression)) return\n\t\tinMakeProgress.add(expression)\n\n\t\tconst clone = (el.content.cloneNode(true) as HTMLElement).firstElementChild\n\n\t\tif (!clone) return\n\n\t\tAlpine.addScopeToNode(clone, {}, el)\n\n\t\tAlpine.mutateDom(() => {\n\t\t\tif (targetEl != null) {\n\t\t\t\ttargetEl.appendChild(clone)\n\t\t\t} else\n\t\t\t\tel.after(clone)\n\t\t\tAlpine.initTree(clone)\n\t\t})\n\n\t\tel._x_PineconeRouter_CurrentTemplate = clone\n\n\t\tel._x_PineconeRouter_undoTemplate = () => {\n\t\t\tclone.remove()\n\n\t\t\tdelete el._x_PineconeRouter_CurrentTemplate\n\t\t}\n\n\t\tAlpine.nextTick(() => inMakeProgress.delete(expression))\n\t}\n\n\tfunction hide(el: HTMLTemplateElement) {\n\t\tif (el._x_PineconeRouter_undoTemplate) {\n\t\t\tel._x_PineconeRouter_undoTemplate()\n\t\t\tdelete el._x_PineconeRouter_undoTemplate\n\t\t}\n\t}\n\n\tfunction show(el: HTMLTemplateElement, expression: string, url?: string, targetEl?: HTMLElement) {\n\t\tif (el._x_PineconeRouter_CurrentTemplate) return el._x_PineconeRouter_CurrentTemplate\n\t\tif (el.content.firstElementChild) {\n\t\t\tmake(el, expression, targetEl)\n\t\t\tendLoading()\n\t\t} else if (url) {\n\t\t\t// Since during loading, the content is automatically put inside the template\n\t\t\t// This first case will only happen if the content of the template was cleared somehow\n\t\t\t// Likely manually\n\t\t\tif (cachedTemplates[url]) {\n\n\t\t\t\tel.innerHTML = cachedTemplates[url]\n\t\t\t\tmake(el, expression, targetEl)\n\t\t\t\tendLoading()\n\t\t\t} else {\n\t\t\t\t// This second case is that it didn't finish loading\n\t\t\t\tif (preloadingTemplates[url]) {\n\t\t\t\t\tpreloadingTemplates[url].then(() => make(el, expression, targetEl))\n\t\t\t\t} else {\n\t\t\t\t\tload(el, url).then(() => make(el, expression, targetEl)).finally(() => endLoading())\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst startLoading = () => {\n\t\tdocument.dispatchEvent(PineconeRouter.loadStart)\n\t}\n\n\tconst endLoading = () => {\n\t\tdocument.dispatchEvent(PineconeRouter.loadEnd)\n\t}\n\n\tconst addBasePath = (path) => {\n\t\tif (!PineconeRouter.settings.hash && PineconeRouter.settings.basePath != '/') {\n\t\t\treturn PineconeRouter.settings.basePath + path\n\t\t} return path\n\t}\n\n\tconst findRouteIndex = (path) => {\n\t\treturn PineconeRouter.routes.findIndex(\n\t\t\t(r) => r.path == path\n\t\t)\n\t}\n\n\tAlpine.directive(\n\t\t'route',\n\t\t(el: HTMLTemplateElement, { expression, modifiers }, { effect, cleanup }) => {\n\t\t\tlet path = expression\n\n\t\t\tmiddleware('onBeforeRouteProcessed', el, path)\n\n\t\t\tif (path.indexOf('#') > -1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Pinecone Router: A route's path may not have a hash character.`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tlet target = modifierValue(modifiers, 'target', null) ?? window.PineconeRouter.settings.templateTargetId\n\t\t\tlet targetEl = document.getElementById(target)\n\t\t\tif (target && !targetEl)\n\t\t\t\tthrow new Error(\"Pinecone Router: Can't find an element with the suplied target ID: \" + target + \"\")\n\n\t\t\tlet routeIndex = null\n\n\t\t\tif (path != 'notfound') {\n\t\t\t\t// if specified add the basePath\n\t\t\t\tpath = addBasePath(path)\n\t\t\t\t// register the new route if possible\n\t\t\t\trouteIndex = PineconeRouter.add(path)\n\t\t\t}\n\n\t\t\tlet route = PineconeRouter.routes[routeIndex] ?? PineconeRouter.notfound\n\n\t\t\t// set the path in the element so it is used by other directives\n\t\t\tel._x_PineconeRouter_route = path\n\n\t\t\tif (el.content.firstElementChild != null) {\n\t\t\t\tAlpine.nextTick(() => {\n\t\t\t\t\teffect(() => {\n\t\t\t\t\t\tlet found = route.handlersDone && PineconeRouter.context.route == path\n\t\t\t\t\t\tfound ? show(el, expression, null, targetEl) : hide(el)\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tcleanup(() => {\n\t\t\t\tel._x_PineconeRouter_undoTemplate && el._x_PineconeRouter_undoTemplate();\n\t\t\t\tPineconeRouter.remove(path);\n\t\t\t\tdelete el._x_PineconeRouter_route\n\t\t\t})\n\n\t\t\tmiddleware('onAfterRouteProcessed', el, path)\n\n\n\t\t}\n\t)\n\n\tAlpine.directive(\n\t\t'handler',\n\t\t(\n\t\t\tel,\n\t\t\t{ expression },\n\t\t\t{ evaluate, cleanup }\n\t\t) => {\n\t\t\tif (!el._x_PineconeRouter_route) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Pinecone Router: x-handler must be set on the same element as x-route.`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tlet handlers\n\n\t\t\t// check if the handlers expression is an array\n\t\t\t// if not make it one\n\t\t\tif (\n\t\t\t\t!(expression.startsWith('[') && expression.endsWith(']')) &&\n\t\t\t\t!(expression.startsWith('Array(') && expression.endsWith(')'))\n\t\t\t) {\n\t\t\t\texpression = `[${expression}]`\n\t\t\t}\n\n\t\t\tlet evaluatedExpression = evaluate(expression)\n\n\t\t\tif (typeof evaluatedExpression == 'object')\n\t\t\t\thandlers = evaluatedExpression\n\t\t\telse {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Pinecone Router: Invalid handler type: ${typeof evaluatedExpression}.`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// add `this` context for handlers inside an Alpine.component\n\t\t\tfor (let index = 0; index < handlers.length; index++) {\n\t\t\t\thandlers[index] = handlers[index].bind(Alpine.$data(el))\n\t\t\t}\n\n\t\t\t// add handlers to the route\n\t\t\tlet path = el._x_PineconeRouter_route\n\t\t\tlet route = path == 'notfound' ? PineconeRouter.notfound : PineconeRouter.routes[findRouteIndex(path)];\n\t\t\troute.handlers = handlers\n\n\t\t\tcleanup(() => {\n\t\t\t\troute.handlers = []\n\t\t\t\troute.handlersDone = true\n\t\t\t\troute.cancelHandlers = false\n\t\t\t})\n\t\t}\n\t)\n\n\tAlpine.directive(\n\t\t'template',\n\t\t(el: HTMLTemplateElement, { modifiers, expression }, { Alpine, effect, cleanup }) => {\n\n\t\t\tif (!el._x_PineconeRouter_route) throw new Error(\"Pinecone Router: x-template must be used on the same element as x-route.\")\n\n\t\t\tif (el.content.firstElementChild != null) throw new Error(\"Pinecone Router: x-template cannot be used alongside an inline template (template element should not have a child).\")\n\n\t\t\tlet url: string = expression\n\n\t\t\tlet target = modifierValue(modifiers, 'target', null) ?? window.PineconeRouter.settings.templateTargetId\n\t\t\tlet targetEl = document.getElementById(target)\n\n\t\t\tif (target && !targetEl)\n\t\t\t\tthrow new Error(\"Pinecone Router: Can't find an element with the suplied target ID: \" + target + \"\")\n\n\t\t\tif (modifiers.includes(\"preload\")) {\n\t\t\t\tpreloadingTemplates[url] = load(el, url).finally(() => {\n\t\t\t\t\tpreloadingTemplates[url] = null;\n\t\t\t\t\tendLoading()\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// add template to the route\n\t\t\tlet path = el._x_PineconeRouter_route\n\t\t\tlet route = path == 'notfound' ? PineconeRouter.notfound : PineconeRouter.routes[findRouteIndex(path)];\n\t\t\troute.template = url\n\n\n\t\t\tAlpine.nextTick(() => {\n\t\t\t\teffect(() => {\n\t\t\t\t\tlet found = route.handlersDone && PineconeRouter.context.route == route.path\n\t\t\t\t\tfound ? show(el, expression, url, targetEl) : hide(el)\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tcleanup(() => {\n\t\t\t\tel._x_PineconeRouter_undoTemplate && el._x_PineconeRouter_undoTemplate();\n\t\t\t})\n\n\t\t}\n\t)\n\n\tAlpine.$router = PineconeRouter.context\n\tAlpine.magic('router', () => PineconeRouter.context)\n\n\tdocument.addEventListener('alpine:initialized', () => {\n\t\tmiddleware('init')\n\t\t// virtually navigate the path on the first page load\n\t\t// this will register the path in history and sets the pathvariable\n\t\t// navigate(window.location.pathname, false, true)\n\t\tif (PineconeRouter.settings.hash == false) {\n\t\t\t// navigate to the current page to handle it\n\t\t\t// ONLY if we not using hash routing for the default router\n\t\t\tnavigate(location.pathname, false, true)\n\t\t} else {\n\t\t\tnavigate(location.hash.substring(1), false, true)\n\t\t}\n\t})\n\n\t// handle navigation events not emitted by links, for example, back button.\n\twindow.addEventListener('popstate', () => {\n\t\tif (PineconeRouter.settings.hash) {\n\t\t\tif (window.location.hash != '') {\n\t\t\t\tnavigate(window.location.hash.substring(1), true)\n\t\t\t}\n\t\t} else {\n\t\t\tnavigate(window.location.pathname, true)\n\t\t}\n\t})\n\n\t// intercept click event in links\n\tinterceptLinks()\n\n\t/**\n\t * @description Add a handler to click events on all valid links\n\t */\n\tfunction interceptLinks() {\n\t\tfunction validateLink(node) {\n\t\t\t// only valid elements\n\t\t\tif (!node || !node.getAttribute) return;\n\n\t\t\tlet href = node.getAttribute('href'),\n\t\t\t\ttarget = node.getAttribute('target');\n\n\t\t\t// ignore links with targets and non-path URLs\n\t\t\tif (!href || !href.match(/^\\//g) || (target && !target.match(/^_?self$/i)))\n\t\t\t\treturn;\n\n\t\t\tif (typeof href !== 'string' && href.url) {\n\t\t\t\thref = href.url;\n\t\t\t}\n\t\t\treturn href\n\n\t\t}\n\t\twindow.document.body.addEventListener(\n\t\t\t'click',\n\t\t\tfunction (e: any) {\n\t\t\t\tif (e.ctrlKey || e.metaKey || e.altKey || e.shiftKey || e.button || e.defaultPrevented) return;\n\n\n\t\t\t\tlet currentRoute = PineconeRouter.routes[findRouteIndex(PineconeRouter.context.route)] ?? PineconeRouter.notfound\n\n\t\t\t\t// stop handlers in progress before navigating to the next page\n\t\t\t\tif (!currentRoute.handlersDone) {\n\t\t\t\t\tcurrentRoute.cancelHandlers = true\n\t\t\t\t\tendLoading()\n\t\t\t\t}\n\n\t\t\t\tlet node = e.target;\n\n\t\t\t\tdo {\n\t\t\t\t\tif (node.localName === 'a' && node.getAttribute('href')) {\n\t\t\t\t\t\tif (window.PineconeRouter.settings.interceptLinks == false && !node.hasAttribute('x-link')) return\n\t\t\t\t\t\tif (node.hasAttribute('data-native') || node.hasAttribute('native')) return;\n\t\t\t\t\t\tlet href = validateLink(node)\n\t\t\t\t\t\tif (href) {\n\t\t\t\t\t\t\tnavigate(href)\n\t\t\t\t\t\t\tif (e.stopImmediatePropagation) e.stopImmediatePropagation();\n\t\t\t\t\t\t\tif (e.stopPropagation) e.stopPropagation();\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} while ((node = node.parentNode));\n\t\t\t}\n\t\t)\n\t}\n\n\t/**\n\t * Go to the specified path without reloading\n\t * @param {string} path the path with no hash even if using hash routing\n\t * @param {boolean} fromPopState this will be set to true if called from window.onpopstate event\n\t * @param {boolean} firstLoad this will be set to true if this is the first page loaded, also from page reload\n\t */\n\tasync function navigate(path, fromPopState = false, firstLoad = false) {\n\t\tif (!path) path = '/'\n\t\tPineconeRouter.context.path = path\n\n\t\t// only add basePath if it was set\n\t\t// if not using hash routing\n\t\t// and if it wasn't added already\n\t\tif (!PineconeRouter.settings.hash) {\n\t\t\tif (\n\t\t\t\tPineconeRouter.settings.basePath != '/' &&\n\t\t\t\t!path.startsWith(PineconeRouter.settings.basePath)\n\t\t\t) {\n\t\t\t\tpath = PineconeRouter.settings.basePath + path\n\t\t\t}\n\t\t\tif (\n\t\t\t\tpath == PineconeRouter.settings.basePath &&\n\t\t\t\t!path.endsWith('/')\n\t\t\t) {\n\t\t\t\tpath += '/'\n\t\t\t}\n\t\t}\n\n\t\tconst route: Route = PineconeRouter.routes.find(\n\t\t\t(route: Route) => {\n\t\t\t\tlet m = match(path, route.path)\n\t\t\t\troute.params = m != false ? m : {}\n\t\t\t\treturn m != false\n\t\t\t}\n\t\t) ?? PineconeRouter.notfound\n\n\t\t// if the route has handlres, it will mark them unhandled\n\t\t// this is so templates wont render till then.\n\t\troute.handlersDone = !route.handlers.length\n\n\t\tif (route.handlers.length || route.template) {\n\t\t\tstartLoading()\n\t\t}\n\n\t\tlet context = buildContext(route.path, path, route.params)\n\n\t\tPineconeRouter.context = context\n\n\t\t// the middleware may return 'stop' to stop execution of this function\n\t\tif (\n\t\t\tmiddleware('onBeforeHandlersExecuted', route, path, firstLoad) == 'stop'\n\t\t) {\n\t\t\tendLoading()\n\t\t\treturn\n\t\t}\n\n\n\t\t// do not call pushstate from popstate event https://stackoverflow.com/a/50830905\n\t\tif (!fromPopState) {\n\t\t\tlet fullPath = ''\n\t\t\tif (PineconeRouter.settings.hash) {\n\t\t\t\tfullPath = '#'\n\t\t\t\tfullPath += window.location.search + path\n\t\t\t} else {\n\t\t\t\tfullPath = path + window.location.search + window.location.hash\n\t\t\t}\n\t\t\t// don't create duplicate history entry on first page load\n\t\t\tif (!firstLoad) history.pushState({ path: fullPath }, '', fullPath)\n\t\t\telse {\n\t\t\t\tif (PineconeRouter.settings.hash) {\n\t\t\t\t\tif (path == '/') {\n\t\t\t\t\t\tPineconeRouter.context = context\n\t\t\t\t\t\treturn navigate('/', false, false)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\t(route && route.handlers.length)\n\t\t) {\n\t\t\troute.cancelHandlers = false\n\t\t\tlet ok = await handle(route.handlers, context)\n\t\t\tif (!ok) {\n\t\t\t\tendLoading()\n\t\t\t\treturn\n\t\t\t}\n\t\t\troute.handlersDone = true\n\t\t\tif (!route.template) endLoading()\n\t\t}\n\n\n\t\t// show templates added programmatically\n\t\tif (route.template && route.programmaticTemplate) {\n\t\t\tlet target = route.templateTargetId ? document.getElementById(route.templateTargetId) : document.getElementById(PineconeRouter.settings.templateTargetId);\n\t\t\tif (cachedTemplates[route.template]) {\n\t\t\t\ttarget.innerHTML = cachedTemplates[route.template]\n\t\t\t\tendLoading()\n\t\t\t}\n\t\t\telse {\n\t\t\t\tload(target, route.template).then(() => {\n\t\t\t\t\tendLoading()\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\n\t\tmiddleware('onHandlersExecuted', route, path, firstLoad)\n\t}\n\n\tfunction buildContext(route: string, path: string, params: {}): Context {\n\t\treturn {\n\t\t\troute: route,\n\t\t\tpath: path,\n\t\t\tparams: params,\n\t\t\tquery: window.location.search.substring(1), // query w/out leading '?'\n\t\t\thash: window.location.hash.substring(1), // hash without leading '#'\n\t\t\tredirect(path) {\n\t\t\t\tnavigate(path)\n\t\t\t\treturn 'stop'\n\t\t\t},\n\t\t\tnavigate(path) {\n\t\t\t\tnavigate(path)\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction modifierValue(modifiers, key, fallback) {\n\t\t// If the modifier isn't present, use the default.\n\t\tif (modifiers.indexOf(key) === -1) return fallback\n\n\t\t// If it IS present, grab the value after it\n\t\tconst rawValue = modifiers[modifiers.indexOf(key) + 1]\n\n\t\tif (!rawValue) return fallback\n\n\t\tif (key === 'target') {\n\t\t\tlet match = rawValue.match(/([a-z0-9_-]+)/)\n\t\t\tif (match) return match[1]\n\t\t}\n\t\treturn rawValue\n\t}\n\t/**\n\t * execute the handlers of routes that are given passing them the context.\n\t */\n\tasync function handle(handlers, context) {\n\t\tfor (let i = 0; i < handlers.length; i++) {\n\t\t\tif (typeof handlers[i] == 'function') {\n\t\t\t\t// stop if the handlers were canceled for example the user clicked a link\n\t\t\t\tlet route = PineconeRouter.routes[findRouteIndex(context.route)] ?? PineconeRouter.notfound\n\t\t\t\tif (route.cancelHandlers) {\n\t\t\t\t\troute.cancelHandlers = false\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tlet result\n\t\t\t\tif (handlers[i].constructor.name === 'AsyncFunction')\n\t\t\t\t\tresult = await handlers[i](context)\n\t\t\t\telse\n\t\t\t\t\tresult = handlers[i](context)\n\t\t\t\t// if the handler redirected, return\n\t\t\t\tif (result == 'stop') return false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n}\n\n", "import magic from '../src/index.js'\n\ndocument.addEventListener('alpine:init', () => {\n window.Alpine.plugin(magic)\n})\n"],
+ "mappings": "MAEA,IAAMA,EAAN,KAAY,CACX,OAAiC,CAAC,EAClC,KACA,SAAsB,CAAC,EACvB,YAAYC,EAAcC,EAAkC,CAAC,EAAG,CAC/D,KAAK,KAAOD,EACZ,OAAO,KAAKC,CAAO,EAAE,QAASC,GAAQ,CACrC,KAAKA,CAAG,EAAID,EAAQC,CAAG,CACxB,CAAC,EACGD,EAAQ,WACX,KAAK,qBAAuB,GAE9B,CACA,SAAmB,GACnB,iBAA2B,GAC3B,qBAAgC,GAChC,aAAwB,GACxB,cACD,EAEOE,EAAQJ,EChBf,SAASK,EAAWC,EAAuB,CAC1C,OAAOA,EAAI,QAAQ,eAAgB,EAAE,EAAE,MAAM,GAAG,CACjD,CAUO,SAASC,EAAMD,EAAaE,EAAmC,CACrE,IAAIC,EAAM,wBACTC,EAAIJ,EAAI,MAAMG,CAAG,EACjBE,EAAe,CAAC,EAChBC,EACD,GAAIF,GAAKA,EAAE,CAAC,EAAG,CACd,IAAIG,EAAIH,EAAE,CAAC,EAAE,MAAM,GAAG,EACtB,QAASI,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAAK,CAClC,IAAIC,EAAIF,EAAEC,CAAC,EAAE,MAAM,GAAG,EACtBH,EAAQ,mBAAmBI,EAAE,CAAC,CAAC,CAAC,EAAI,mBACnCA,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,CACpB,CACD,CACD,CACA,IAAIC,EAASX,EAAWC,EAAI,QAAQG,EAAK,EAAE,CA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,SAASI,EAAahB,EAAe/B,EAAckD,EAAqB,CACvE,MAAO,CACN,MAAOnB,EACP,KAAM/B,EACN,OAAQkD,EACR,MAAO,OAAO,SAAS,OAAO,UAAU,CAAC,EACzC,KAAM,OAAO,SAAS,KAAK,UAAU,CAAC,EACtC,SAASlD,EAAM,CACd,OAAAC,EAASD,CAAI,EACN,MACR,EACA,SAASA,EAAM,CACdC,EAASD,CAAI,CACd,CACD,CACD,CAEA,SAAS6B,EAAcL,EAAW2B,EAAKC,EAAU,CAEhD,GAAI5B,EAAU,QAAQ2B,CAAG,IAAM,GAAI,OAAOC,EAG1C,IAAMC,EAAW7B,EAAUA,EAAU,QAAQ2B,CAAG,EAAI,CAAC,EAErD,GAAI,CAACE,EAAU,OAAOD,EAEtB,GAAID,IAAQ,SAAU,CACrB,IAAIN,EAAQQ,EAAS,MAAM,eAAe,EAC1C,GAAIR,EAAO,OAAOA,EAAM,CAAC,CAC1B,CACA,OAAOQ,CACR,CAIA,eAAeJ,EAAOhB,EAAUa,EAAS,CACxC,QAASQ,EAAI,EAAGA,EAAIrB,EAAS,OAAQqB,IACpC,GAAI,OAAOrB,EAASqB,CAAC,GAAK,WAAY,CAErC,IAAIvB,EAAQjC,EAAe,OAAOyB,EAAeuB,EAAQ,KAAK,CAAC,GAAKhD,EAAe,SACnF,GAAIiC,EAAM,eACT,OAAAA,EAAM,eAAiB,GAChB,GAER,IAAIwB,EAMJ,GALItB,EAASqB,CAAC,EAAE,YAAY,OAAS,gBACpCC,EAAS,MAAMtB,EAASqB,CAAC,EAAER,CAAO,EAElCS,EAAStB,EAASqB,CAAC,EAAER,CAAO,EAEzBS,GAAU,OAAQ,MAAO,EAC9B,CAED,MAAO,EACR,CACD,CClmBA,SAAS,iBAAiB,cAAe,IAAM,CAC7C,OAAO,OAAO,OAAOC,CAAK,CAC5B,CAAC",
"names": ["Route", "path", "options", "opt", "route_default", "segmentize", "url", "match", "routePath", "reg", "c", "matches", "ret", "p", "i", "r", "urlSeg", "route", "max", "param", "flags", "plus", "star", "val", "middleware", "func", "args", "plugin", "fetchError", "error", "src_default", "Alpine", "PineconeRouter", "route_default", "path", "navigate", "options", "r", "loadingTemplates", "cachedTemplates", "inMakeProgress", "preloadingTemplates", "load", "el", "url", "programmaticRoute", "html", "fetchError", "make", "expression", "targetEl", "clone", "hide", "show", "endLoading", "startLoading", "addBasePath", "findRouteIndex", "modifiers", "effect", "cleanup", "middleware", "target", "modifierValue", "routeIndex", "route", "evaluate", "handlers", "evaluatedExpression", "index", "interceptLinks", "validateLink", "node", "href", "e", "currentRoute", "fromPopState", "firstLoad", "m", "match", "context", "buildContext", "fullPath", "handle", "params", "key", "fallback", "rawValue", "i", "result", "src_default"]
}
diff --git a/package.json b/package.json
index 7a3ef01..a727c61 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"description": "The extendable client-side router for Alpine.js.",
"license": "MIT",
"author": "Rafik El Hadi Houari ",
- "version": "4.4.0",
+ "version": "4.4.1",
"repository": {
"type": "git",
"url": "https://github.com/pinecone-router/router"
diff --git a/src/index.ts b/src/index.ts
index ea447da..13f41d4 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -29,7 +29,7 @@ declare global {
export default function (Alpine) {
const PineconeRouter = Alpine.reactive({
- version: '4.4.0',
+ version: '4.4.1',
name: 'pinecone-router',
settings: {