single-page-express
Version:
📄 A client-side implementation of the Express route API.
2 lines • 21.5 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("singlePageExpress",[],t):"object"==typeof exports?exports.singlePageExpress=t():e.singlePageExpress=t()}(this,(()=>{return e={67:(e,t)=>{"use strict";t.YW=function(e,t={}){const{decode:n=decodeURIComponent,delimiter:s=o}=t,{regexp:a,keys:i}=p(e,t),l=i.map((e=>!1===n?r:"param"===e.type?n:e=>e.split(s).map(n)));return function(e){const t=a.exec(e);if(!t)return!1;const o=t[0],r=Object.create(null);for(let e=1;e<t.length;e++){if(void 0===t[e])continue;const o=i[e-1],n=l[e-1];r[o.name]=n(t[e])}return{path:o,params:r}}};const o="/",r=e=>e,n=/^[$_\p{ID_Start}]$/u,s=/^[$\u200c\u200d\p{ID_Continue}]$/u,a="https://git.new/pathToRegexpError",i={"{":"{","}":"}","(":"(",")":")","[":"[","]":"]","+":"+","?":"?","!":"!"};function l(e){return e.replace(/[.+*?^${}()[\]|/\\]/g,"\\$&")}class c{constructor(e){this.tokens=e}peek(){if(!this._peek){const e=this.tokens.next();this._peek=e.value}return this._peek}tryConsume(e){const t=this.peek();if(t.type===e)return this._peek=void 0,t.value}consume(e){const t=this.tryConsume(e);if(void 0!==t)return t;const{type:o,index:r}=this.peek();throw new TypeError(`Unexpected ${o} at ${r}, expected ${e}: ${a}`)}text(){let e,t="";for(;e=this.tryConsume("CHAR")||this.tryConsume("ESCAPED");)t+=e;return t}}class d{constructor(e){this.tokens=e}}function u(e,t={}){const{encodePath:o=r}=t,l=new c(function*(e){const t=[...e];let o=0;function r(){let e="";if(n.test(t[++o]))for(e+=t[o];s.test(t[++o]);)e+=t[o];else if('"'===t[o]){let r=o;for(;o<t.length;){if('"'===t[++o]){o++,r=0;break}e+="\\"===t[o]?t[++o]:t[o]}if(r)throw new TypeError(`Unterminated quote at ${r}: ${a}`)}if(!e)throw new TypeError(`Missing parameter name at ${o}: ${a}`);return e}for(;o<t.length;){const e=t[o],n=i[e];if(n)yield{type:n,index:o++,value:e};else if("\\"===e)yield{type:"ESCAPED",index:o++,value:t[o++]};else if(":"===e){const e=r();yield{type:"PARAM",index:o,value:e}}else if("*"===e){const e=r();yield{type:"WILDCARD",index:o,value:e}}else yield{type:"CHAR",index:o,value:t[o++]}}return{type:"END",index:o,value:""}}(e)),u=function e(t){const r=[];for(;;){const n=l.text();n&&r.push({type:"text",value:o(n)});const s=l.tryConsume("PARAM");if(s){r.push({type:"param",name:s});continue}const a=l.tryConsume("WILDCARD");if(a)r.push({type:"wildcard",name:a});else{if(!l.tryConsume("{"))return l.consume(t),r;r.push({type:"group",tokens:e("}")})}}}("END");return new d(u)}function p(e,t={}){const{delimiter:r=o,end:n=!0,sensitive:s=!1,trailing:a=!0}=t,i=[],c=[],p=s?"":"i",g=(Array.isArray(e)?e:[e]).map((e=>e instanceof d?e:u(e,t)));for(const{tokens:e}of g)for(const t of f(e,0,[])){const e=m(t,r,i);c.push(e)}let h=`^(?:${c.join("|")})`;return a&&(h+=`(?:${l(r)}$)?`),h+=n?"$":`(?=${l(r)}|$)`,{regexp:new RegExp(h,p),keys:i}}function*f(e,t,o){if(t===e.length)return yield o;const r=e[t];if("group"===r.type){const n=o.slice();for(const o of f(r.tokens,0,n))yield*f(e,t+1,o)}else o.push(r);yield*f(e,t+1,o)}function m(e,t,o){let r="",n="",s=!0;for(let i=0;i<e.length;i++){const c=e[i];if("text"!==c.type)if("param"!==c.type&&"wildcard"!==c.type);else{if(!s&&!n)throw new TypeError(`Missing text after "${c.name}": ${a}`);"param"===c.type?r+=`(${g(t,s?"":n)}+)`:r+="([\\s\\S]+)",o.push(c),n="",s=!1}else r+=l(c.value),n+=c.value,s||(s=c.value.includes(t))}return r}function g(e,t){return t.length<2?e.length<2?`[^${l(e+t)}]`:`(?:(?!${l(e)})[^${l(t)}])`:e.length<2?`(?:(?!${l(t)})[^${l(e)}])`:`(?:(?!${l(t)}|${l(e)})[\\s\\S])`}},297:e=>{e.exports=function e(o,r,n){r=r||[];var s,a=(n=n||{}).strict,i=!1!==n.end,l=n.sensitive?"":"i",c=!1!==n.lookahead,d=0,u=r.length,p=0,f=0,m=0,g="";if(o instanceof RegExp){for(;s=t.exec(o.source);)"\\"!==s[0][0]&&r.push({name:s[1]||f++,optional:!1,offset:s.index});return o}if(Array.isArray(o))return o=o.map((function(t){return e(t,r,n).source})),new RegExp(o.join("|"),l);if("string"!=typeof o)throw new TypeError("path must be a string, array of strings, or regular expression");for(o=o.replace(/\\.|(\/)?(\.)?:(\w+)(\(.*?\))?(\*)?(\?)?|[.*]|\/\(/g,(function(e,t,n,s,a,i,l,c){if("\\"===e[0])return g+=e,m+=2,e;if("."===e)return g+="\\.",d+=1,m+=1,"\\.";if(t||n?g="":g+=o.slice(m,c),m=c+e.length,"*"===e)return d+=3,"(.*)";if("/("===e)return g+="/",d+=2,"/(?:";t=t||"",n=n?"\\.":"",l=l||"",a=a?a.replace(/\\.|\*/,(function(e){return"*"===e?"(.*)":e})):g?"((?:(?!/|"+g+").)+?)":"([^/"+n+"]+?)",r.push({name:s,optional:!!l,offset:c+d});var u="(?:"+n+t+a+(i?"((?:[/"+n+"].+?)?)":"")+")"+l;return d+=u.length-e.length,u}));s=t.exec(o);)"\\"!==s[0][0]&&((u+p===r.length||r[u+p].offset>s.index)&&r.splice(u+p,0,{name:f++,optional:!1,offset:s.index}),p++);return o+=a?"":"/"===o[o.length-1]?"?":"/?",i?o+="$":"/"!==o[o.length-1]&&(o+=c?"(?=/|$)":"(?:/|$)"),new RegExp("^"+o,l)};var t=/\\.|\((?:\?<(.*?)>)?(?!\?)/g},524:(e,t,o)=>{const r=o(67).YW,n=o(297),s=new window.DOMParser;e.exports=function(e){const t={};let a;t.expressVersion=e.expressVersion,5!==t.expressVersion&&parseInt(t.expressVersion)<=4&&(t.expressVersion=4),t.expressVersion||(t.expressVersion=5),t.appVars={},t.templatingEngine=e.templatingEngine,t.templates=e.templates,t.templates||console.warn("single-page-express: no templates are loaded; as such the default render method will just print the template name and model to the console."),t.routes={},t.routeCallbacks={},t.defaultTarget=e.defaultTarget,t.defaultTargets=t.defaultTarget?[t.defaultTarget].concat(e.defaultTargets||[]):e.defaultTargets||[],t.defaultTargets.length||(t.defaultTargets=["body"]),t.beforeEveryRender=e.beforeEveryRender,t.updateDelay=e.updateDelay,t.afterEveryRender=e.afterEveryRender,t.postRenderCallbacks=e.postRenderCallbacks||{},t.topbarEnabled=!e.disableTopbar,t.topBarRoutes=e.topBarRoutes,(t.topbarEnabled||t.topBarRoutes)&&(t.topbar=o(663),t.topbar.config(e.topbarConfig||{barColors:{0:"rgba(0, 0, 0, .7)","1.0":"rgba(0, 0, 0, .7)"}})),t.alwaysScrollTop=e.alwaysScrollTop,t.urls={};const i=["checkout","copy","delete","get","head","lock","merge","mkactivity","mkcol","move","m-search","notify","options","patch","post","purge","put","report","search","subscribe","trace","unlock","unsubscribe"];function l(e,o,s,a){let c=o;a&&(c=(e,t)=>o(e,t,(()=>a(e,t)))),function(e,o,s){if("all"!==e){if("string"!=typeof o&&"function"==typeof o&&(s=o,o=this.route),t.appVars["case sensitive routing"]&&(o=o.toLowerCase()),!t.appVars["strict routing"]&&o.endsWith("/")&&"/"!==o&&(o=o.slice(0,-1)),!(o in t.routes)){let a;if(5===t.expressVersion)try{a=r(o)}catch(e){console.error(`single-page-express: failed to register the route '${o}' because it could not be parsed.`),o.includes("*")&&console.error("single-page-express: routes with '*' in them should be written like '*all' instead in Express 5+ syntax."),console.error(e)}else a=n(o);t.routes[`${e}#${o}`]={method:e,route:o,matcher:a},t.routeCallbacks[`${e}#${o}`]=s}}else i.forEach(((e,t)=>{l(t,e,o,s)}))}(e,s,c)}t.appVars["case sensitive routing"]=!1,t.appVars.env="production",t.appVars["query parser"]=!0,t.appVars["strict routing"]=!1,t.appVars["subdomain offset"]=2,t.locals={},t.mountpath="",t.mount=()=>{},t.all=(e,t,o)=>{l("all",e,t,o)},t.delete=(e,t,o)=>{l("delete",e,t,o)},t.disable=e=>{t.appVars[e]=!1},t.disabled=e=>!t.appVars[e],t.enable=e=>{t.appVars[e]=!0},t.enabled=e=>!!t.appVars[e],t.engine=()=>{},t.get=(e,o,r)=>r?l("get",e,o,r):t.appVars[o],t.listen=()=>{},i.forEach((e=>{t[e]||(t[e]=(t,o,r)=>l(e,t,o,r))})),t.param=()=>{},t.path=()=>{},t.post=(e,t,o)=>{l("post",e,t,o)},t.put=(e,t,o)=>{l("put",e,t,o)},t.route=e=>{const t={route:e};return i.forEach((o=>{t[o]=(t,r)=>{l(o,t,e,r)}})),t},t.set=(e,o)=>{t.appVars[e]=o},t.use=()=>{},t.triggerRoute=u;const c={};c.app=t,c.baseUrl="",c.fresh=!0,c.hostname=window.location.hostname,c.ip="127.0.0.1",c.ips=[],c.signedCookies={},c.stale=!1,c.xhr=!0,c.accepts=()=>{},c.acceptsCharsets=()=>{},c.acceptsEncodings=()=>{},c.acceptsLanguages=()=>{},c.get=()=>{},c.is=()=>{},c.param=()=>{},c.range=()=>{},c.singlePageExpress=!0;const d={};async function u(e){let o=e.route;const r=e.method?(""+e.method).toLowerCase():"get";let n,s=o.split("?")[0];t.appVars["case sensitive routing"]&&(s=s.toLowerCase()),!t.appVars["strict routing"]&&s.length>1&&s.endsWith("/")&&(s=s.slice(0,-1));for(const e in t.routes){const o=t.routes[e];if(o.method===r&&(5===t.expressVersion?o.data=o.matcher(s):o.data=o.matcher.exec(s),o.data)){n=o;break}}if(n){e.event?.preventDefault(),(t.topbarEnabled&&!t.topBarRoutes||t.topBarRoutes?.includes?.(n.route))&&t.topbar.show(),t.urls[window.location.pathname]={scrollX:window.scrollX,scrollY:window.scrollY,scrollingChildContainers:{}};for(const e of document.querySelectorAll("[id]"))(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)&&(t.urls[window.location.pathname].scrollingChildContainers[e.id]={scrollX:e.scrollLeft,scrollY:e.scrollTop});if("get"===r&&!e.skipHistory){const e={index:p.length};p.push(e),f=p.length-1,window.history.pushState(e,"",o)}const s={...c};(e.parseBody||e.body)&&(e.event?.target?(s.body=Object.fromEntries(new FormData(e.event.target).entries()),e.event.submitter&&(s.body[e.event.submitter.name]=e.event.submitter.value)):e.body?s.body=e.body:s.body={},t.expressVersion>4&&s.body&&0===Object.keys(s.body).length&&(s.body=void 0));const i=document.cookie.split("; ");if(s.cookies={},i.forEach((e=>{const[t,o]=e.split("=");s.cookies[decodeURIComponent(t)]=decodeURIComponent(o)})),s.method=r,s.originalUrl=o,5===t.expressVersion)s.params=n.data.params;else{s.params={};const e=n.route.match(/:([^/]+)/g)?.map((e=>e.substring(1)));if(e){const t=n.matcher.exec(n.data[0]);if(t)for(const[o,r]of e.entries())s.params[r]=t[o+1]}}const l=new URL(window.location.href);if(s.path=l.pathname,s.protocol=l.protocol,t.appVars["query parser"]){const e=o.split("?");o=e[0];const t=e.slice(1).join(", ");s.query=Object.fromEntries(new URLSearchParams(t).entries())}s.route=n.data,s.secure="https"===s.protocol||"https:"===s.protocol;const u=s.hostname.split(".").slice(0,-parseInt(t.appVars["subdomain offset"]));s.subdomains=u.reverse(),d.req=s,s.backButtonPressed=e.backButtonPressed,s.forwardButtonPressed=e.forwardButtonPressed;const m=document.querySelector("html");e.backButtonPressed?(m.classList.add("backButtonPressed"),m.classList.remove("forwardButtonPressed")):e.forwardButtonPressed?(m.classList.remove("backButtonPressed"),m.classList.add("forwardButtonPressed")):(m.classList.remove("backButtonPressed"),m.classList.remove("forwardButtonPressed")),await t.routeCallbacks[`${r}#${n.route}`](s,d);const g=()=>{if(!t.urls[o]||d.resetScroll||t.alwaysScrollTop)window.scrollTo(0,0),d.resetScroll&&(delete t.urls[o].scrollX,delete t.urls[o].scrollY,delete t.urls[o].scrollingChildContainers);else if(t.urls[o]){window.scrollTo(t.urls[o].scrollX||0,t.urls[o].scrollY||0);for(const e in t.urls[o].scrollingChildContainers)document.getElementById(e)&&document.getElementById(e).scrollTo(t.urls[o].scrollingChildContainers[e].scrollX||0,t.urls[o].scrollingChildContainers[e].scrollY||0)}d.resetScroll=null,(t.topbarEnabled&&!t.topBarRoutes||t.topBarRoutes?.includes?.(n.route))&&t.topbar.hide()};a?document.addEventListener("animationend",g):window.setTimeout(g,parseInt(d.updateDelay)||parseInt(t.updateDelay)||0)}}d.app=t,d.headersSent=!1,d.locals={},d.append=()=>d,d.attachment=()=>d,d.cookie=(e,o,r={})=>{const{domain:n,encode:s=encodeURIComponent,expires:a,httpOnly:i,maxAge:l,path:c="/",partitioned:d,priority:u,secure:p,signed:f,sameSite:m}=r;let g=`${s(e)}=${s(o)}`;a instanceof Date&&(g+=`; expires=${a.toUTCString()}`),l&&(g+=`; max-age=${l}`),n&&(g+=`; domain=${n}`),c&&(g+=`; path=${c}`),p&&(g+="; secure"),i&&(g+="; HttpOnly"),m&&(g+=`; SameSite=${m}`),d&&(g+="; Partitioned"),u&&(g+=`; Priority=${u}`),f&&"development"===t.appVars.env&&console.warn("Signed cookies are not supported in the browser context."),document.cookie=g},d.clearCookie=(e,t={})=>{const{domain:o,encode:r=encodeURIComponent,httpOnly:n,path:s="/",partitioned:a,priority:i,secure:l,signed:c,sameSite:d}=t,u=new Date(0).toUTCString();let p=`${r(e)}=; expires=${u}`;o&&(p+=`; domain=${o}`),s&&(p+=`; path=${s}`),l&&(p+="; secure"),n&&(p+="; HttpOnly"),d&&(p+=`; SameSite=${d}`),a&&(p+="; Partitioned"),i&&(p+=`; Priority=${i}`),c&&console.warn("Signed cookies are not supported in the frontend."),document.cookie=p},d.download=()=>d,d.end=()=>d,d.format=()=>d,d.get=()=>d,d.json=e=>(console.log(e),d),d.jsonp=()=>d,d.links=()=>d,d.location=()=>d,d.redirect=(e,t)=>(t||(t=e),u({route:t}),d),d.send=()=>d,d.sendFile=()=>d,d.sendStatus=()=>d,d.set=()=>d,d.status=()=>d,d.type=()=>d,d.vary=()=>d,c.res=d,t.render=function(o,r,n){r=r||{};const i=this.title,l=this.beforeRender,c=this.target,d=this.appendTargets,u=this.focus,p=this.removeMetaTags,f=this.removeStyleTags,m=this.removeLinkTags,g=this.removeScriptTags,h=this.removeBaseTags,y=this.removeTemplateTags,b=this.removeHeadTags,v=this.updateDelay,x=this.afterRender;this.title=null,this.beforeRender=null,this.target=null,this.focus=null,this.removeMetaTags=null,this.removeStyleTags=null,this.removeLinkTags=null,this.removeScriptTags=null,this.removeBaseTags=null,this.removeTemplateTags=null,this.removeHeadTags=null,this.updateDelay=null,this.afterRender=null;const w=()=>{t.postRenderCallbacks[o]&&("function"==typeof t.postRenderCallbacks[o]?t.postRenderCallbacks[o](r):console.error(`single-page-express: post-render callback for ${o} is not a function.`));for(const e in t.postRenderCallbacks)if(e.startsWith("*")){"function"==typeof t.postRenderCallbacks[e]?t.postRenderCallbacks[e](r):console.error(`single-page-express: post-render callback for ${e} is not a function.`);break}};if(e.renderMethod)e.renderMethod(o,r,n),w();else{let e;e||t.templates||(e="single-page-express: no templates are loaded.",console.log("template:",o),console.log("model:",r)),e||t?.templatingEngine.render&&"function"==typeof t?.templatingEngine?.render||(e="single-page-express: no template engine is loaded or the engine supplied does not have a `render` method; please use a templating engine that is compatible with Express",console.error(e)),e||t.templates[o]||(e=`single-page-express: attempted to render template which does not exist: ${o}`,console.error(e));let E="";if(!e){try{E=t.templatingEngine.render(o,r)}catch(t){const r=`single-page-express: error parsing post-rendered template: ${o}`;console.error(r),console.error(t.message),e=r+"\n"+t.message}if(!e){let T;try{T=s.parseFromString(E,"text/html")}catch(t){const r=`single-page-express: error parsing post-rendered template: ${o}`;console.error(r),console.error(t.message),e=r+"\n"+t.message}if(!e){let o;i?document.querySelector("title")&&(document.querySelector("title").innerHTML=i):T.querySelector("title")&&document.querySelector("title")&&(document.querySelector("title").innerHTML=T.querySelector("title").innerHTML),o=c?Array.isArray(c)?d?t.defaultTargets.concat(c):c:d?t.defaultTargets.concat([c]):[c]:t.defaultTargets;const s={model:r,markup:E,doc:T,targets:o};if(t.beforeEveryRender&&"function"==typeof t.beforeEveryRender&&t.beforeEveryRender(s),l&&"function"==typeof l&&l(s),p)for(const e of document.querySelectorAll("head meta"))e.remove();if(f)for(const e of document.querySelectorAll("head style"))e.remove();if(m)for(const e of document.querySelectorAll("head link"))e.remove();if(g)for(const e of document.querySelectorAll("head script"))e.remove();if(h)for(const e of document.querySelectorAll("head base"))e.remove();if(y)for(const e of document.querySelectorAll("head template"))e.remove();if(b)for(const e of document.querySelectorAll("head > :not(title)"))e.remove();for(const e of T.documentElement.attributes)document.documentElement.setAttribute(e.name,e.value);for(const e of T.head.attributes)document.head.setAttribute(e.name,e.value);const k=Array.from(document.head.children),C=Array.from(T.head.children),S=k.map((e=>e.outerHTML)),$=C.filter((e=>!S.includes(e.outerHTML))),R=$.filter((e=>"link"===e.tagName.toLowerCase())),A=[];for(const e of R)A.push(new Promise((t=>{e.addEventListener("load",(()=>t()))})));for(const e of $)if("SCRIPT"!==e.nodeName||document.querySelector(`script[src="${e.src}"]`)||document.querySelector(`script[src="${e.src.replace(window.location.origin,"")}"]`))document.head.appendChild(e);else{const t=document.createElement("script");t.src=e.src,t.type="text/javascript",t.async=!0,A.push(new Promise((e=>{t.onload=()=>e()}))),document.head.appendChild(t)}Promise.all(A).then((()=>{window.setTimeout((()=>{const r=()=>{for(const r of o){let n;if(document.querySelector(r)){n=document.querySelector(r);const e="BODY"===n.nodeName?"innerHTML":"outerHTML";T.querySelector(r)?n[e]=T.querySelector(r).outerHTML:T.body?n[e]=T.body.innerHTML:n[e]=T.innerHTML;const a=document.querySelector("[data-page-title]")||document.querySelector("h1[aria-label]")||document.querySelector("h1")||document.querySelector("title");if(!document.getElementById("singlePageExpressDefaultRenderMethodAriaLiveRegion")){const e=document.createElement("p");e.id="singlePageExpressDefaultRenderMethodAriaLiveRegion",e.setAttribute("aria-live","assertive"),e.setAttribute("aria-atomic","true"),e.style.position="absolute",e.style.top="-9999px",e.style.left="-9999px",e.style.width="1px",e.style.height="1px",e.style.overflow="hidden",e.style.border="0",e.style.margin="-1px",e.style.padding="0",e.style.clipPath="inset(50%)",e.style.whiteSpace="nowrap",document.body.appendChild(e)}document.getElementById("singlePageExpressDefaultRenderMethodAriaLiveRegion").textContent="",document.getElementById("singlePageExpressDefaultRenderMethodAriaLiveRegion").textContent=a.textContent;const i=["A","INPUT","TEXTAREA","SELECT","BUTTON","FIELDSET"];let l=document.querySelector(u)||document.body.querySelector("[autofocus]");if(l&&!l.closest('[inert], [aria-disabled], [aria-hidden="true"]')&&(l=null),l&&l!==document.activeElement)l.focus(),i.includes(l.tagName)||(l.style.outline="none");else{const e=document.querySelector(o[0]),t=e.getAttribute("tabindex");e.setAttribute("tabindex","-1"),e.focus({preventScroll:!0}),i.includes(e.tagName)||(e.style.outline="none"),null!==t&&e.setAttribute("tabindex",t)}t.afterEveryRender&&"function"==typeof t.afterEveryRender&&t.afterEveryRender(s),x&&"function"==typeof x&&x(s)}else{const t=`single-page-express: invalid target supplied: ${r}`;console.error(t),e=t}}n&&"function"==typeof n&&n(e,E),w()};document.startViewTransition?a=document.startViewTransition(r):r()}),parseInt(v)||parseInt(t.updateDelay)||0)}))}}}}},d.render=t.render,document.singlePageExpressEventListenerAdded||(document.addEventListener("click",(e=>{"A"===e.target.tagName&&e.target.href&&u({route:e.target.getAttribute("href"),event:e})})),document.addEventListener("submit",(e=>{e.target.getAttribute("action")&&u({route:e.target.getAttribute("action"),event:e,parseBody:!0,method:e.target.getAttribute("method")})}))),document.singlePageExpressEventListenerAdded=!0;const p=[];let f=-1;return window.singlePageExpressGlobalsInitialized||(window.singlePageExpressGlobalsInitialized=!0,window.addEventListener("popstate",(e=>{const t=e.state;if(!t)return;let o=!1,r=!1;const n=t.index;n<f?o=!0:n>f&&(r=!0),f=n,u({route:window.location.pathname,method:"get",skipHistory:!0,backButtonPressed:o,forwardButtonPressed:r})}))),t}},663:function(e,t,o){var r;(function(n,s){"use strict";function a(){i.width=n.innerWidth,i.height=5*f.barThickness;var e=i.getContext("2d");e.shadowBlur=f.shadowBlur,e.shadowColor=f.shadowColor;var t,o=e.createLinearGradient(0,0,i.width,0);for(t in f.barColors)o.addColorStop(t,f.barColors[t]);e.lineWidth=f.barThickness,e.beginPath(),e.moveTo(0,f.barThickness/2),e.lineTo(Math.ceil(l*i.width),f.barThickness/2),e.strokeStyle=o,e.stroke()}var i,l,c,d=null,u=null,p=null,f={autoRun:!0,barThickness:3,barColors:{0:"rgba(26, 188, 156, .9)",".25":"rgba(52, 152, 219, .9)",".50":"rgba(241, 196, 15, .9)",".75":"rgba(230, 126, 34, .9)","1.0":"rgba(211, 84, 0, .9)"},shadowBlur:10,shadowColor:"rgba(0, 0, 0, .6)",className:null},m={config:function(e){for(var t in e)f.hasOwnProperty(t)&&(f[t]=e[t])},show:function(e){var t,o;c||(e?p=p||setTimeout((()=>m.show()),e):(c=!0,null!==u&&n.cancelAnimationFrame(u),i||((o=(i=s.createElement("canvas")).style).position="fixed",o.top=o.left=o.right=o.margin=o.padding=0,o.zIndex=100001,o.display="none",f.className&&i.classList.add(f.className),t="resize",e=a,(o=n).addEventListener?o.addEventListener(t,e,!1):o.attachEvent?o.attachEvent("on"+t,e):o["on"+t]=e),i.parentElement||s.body.appendChild(i),i.style.opacity=1,i.style.display="block",m.progress(0),f.autoRun&&function e(){d=n.requestAnimationFrame(e),m.progress("+"+.05*Math.pow(1-Math.sqrt(l),2))}()))},progress:function(e){return void 0===e||("string"==typeof e&&(e=(0<=e.indexOf("+")||0<=e.indexOf("-")?l:0)+parseFloat(e)),l=1<e?1:e,a()),l},hide:function(){clearTimeout(p),p=null,c&&(c=!1,null!=d&&(n.cancelAnimationFrame(d),d=null),function e(){return 1<=m.progress("+.1")&&(i.style.opacity-=.05,i.style.opacity<=.05)?(i.style.display="none",void(u=null)):void(u=n.requestAnimationFrame(e))}())}};"object"==typeof e.exports?e.exports=m:void 0===(r=function(){return m}.call(t,o,t,e))||(e.exports=r)}).call(this,window,document)}},t={},function o(r){var n=t[r];if(void 0!==n)return n.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,o),s.exports}(524);var e,t}));
//# sourceMappingURL=single-page-express.min.js.map