diff --git a/demo/js/animate.js b/demo/js/animate.js index 148a348..776dcf6 100644 --- a/demo/js/animate.js +++ b/demo/js/animate.js @@ -1 +1,2 @@ -var Q=Object.defineProperty;var R=Object.prototype.hasOwnProperty;var A=Object.getOwnPropertySymbols,O=Object.prototype.propertyIsEnumerable;var C=(i,t,e)=>t in i?Q(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,u=(i,t)=>{for(var e in t||(t={}))R.call(t,e)&&C(i,e,t[e]);if(A)for(var e of A(t))O.call(t,e)&&C(i,e,t[e]);return i};var S=(i,t)=>{var e={};for(var r in i)R.call(i,r)&&t.indexOf(r)<0&&(e[r]=i[r]);if(i!=null&&A)for(var r of A(i))t.indexOf(r)<0&&O.call(i,r)&&(e[r]=i[r]);return e};var p=class{constructor(t){this.map=new Map(t)}getMap(){return this.map}get(t){return this.map.get(t)}keys(){return Array.from(this.map.keys())}values(){return Array.from(this.map.values())}set(t,e){return this.map.set(t,e),this}add(t){let r=this.size;return this.set(r,t),this}get size(){return this.map.size}get length(){return this.map.size}last(t=1){let e=this.keys()[this.size-t];return this.get(e)}delete(t){return this.map.delete(t)}remove(t){return this.map.delete(t),this}clear(){return this.map.clear(),this}has(t){return this.map.has(t)}entries(){return this.map.entries()}forEach(t,e){return this.map.forEach(t,e),this}[Symbol.iterator](){return this.entries()}},E=(i,t,...e)=>{i.forEach(r=>{r[t](...e)})};var wt=new DOMParser;var D=({callback:i=()=>{},scope:t=null,name:e="event"})=>({callback:i,scope:t,name:e}),d=class extends p{constructor(t="event"){super();this.name=t}},v=class extends p{constructor(){super()}getEvent(t){let e=this.get(t);return e instanceof d?e:(this.set(t,new d(t)),this.get(t))}newListener(t,e,r){let n=this.getEvent(t);return n.add(D({name:t,callback:e,scope:r})),n}on(t,e,r){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,s,a=typeof t=="object"&&!Array.isArray(t),o=a?e:r;return a||(s=e),Object.keys(t).forEach(l=>{a?(n=l,s=t[l]):n=t[l],this.newListener(n,s,o)},this),this}removeListener(t,e,r){let n=this.get(t);if(n instanceof d&&e){let s=D({name:t,callback:e,scope:r});n.forEach((a,o)=>{if(a.callback===s.callback&&a.scope===s.scope)return n.remove(o)})}return n}off(t,e,r){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,s,a=typeof t=="object"&&!Array.isArray(t),o=a?e:r;return a||(s=e),Object.keys(t).forEach(l=>{a?(n=l,s=t[l]):n=t[l],typeof s=="function"?this.removeListener(n,s,o):this.remove(n)},this),this}emit(t,...e){return typeof t=="undefined"?this:(typeof t=="string"&&(t=t.trim().split(/\s/g)),t.forEach(r=>{let n=this.get(r);n instanceof d&&n.forEach(s=>{let{callback:a,scope:o}=s;a.apply(o,e)})},this),this)}clear(){return E(this,"clear"),super.clear(),this}};var rt=i=>typeof i=="string"?Array.from(document.querySelectorAll(i)):[i],nt=i=>[].concat(...i),K=i=>Array.isArray(i)?nt(i.map(K)):typeof i=="string"||i instanceof Node?rt(i):i instanceof NodeList||i instanceof HTMLCollection?Array.from(i):[],_=(i,t,e)=>typeof i=="function"?i.apply(e,t):i,U=(i,t,e)=>{let r,n,s={},a=Object.keys(i);for(let o=0,l=a.length;o/^(in|out)/.test(i)?st[i]:i,z={keyframes:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",autoplay:!0,duration:1e3,fillMode:"auto",direction:"normal",extend:{}},w=class{constructor(t={}){this.options={};this.targets=[];this.properties={};this.animations=new p;this.totalDuration=0;this.minDelay=0;this.computedOptions=new p;this.emitter=new v;var r;try{let e=t,{options:s}=e,a=S(e,["options"]),o=s instanceof w?s.getOptions():Array.isArray(s)?(r=s==null?void 0:s[0])==null?void 0:r.getOptions():s;this.options=Object.assign({},z,o,a),this.loop=this.loop.bind(this);let n=this.options,{loop:l,delay:q,speed:F,easing:T,endDelay:V,duration:G,direction:j,fillMode:$,onfinish:P,target:X,keyframes:B,autoplay:W,extend:Y}=n,J=S(n,["loop","delay","speed","easing","endDelay","duration","direction","fillMode","onfinish","target","keyframes","autoplay","extend"]);this.mainElement=document.createElement("div"),this.targets=K(X),this.properties=J;let M=[],f=this.targets.length,y;for(let h=0;h0||(y=U(y,[h,f,m],this));let k=c.delay+c.duration*c.iterations+c.endDelay;this.totalDuration{typeof P=="function"&&P.call(this,m,h,f,b),this.emit("finish",m,h,f,b)},this.computedOptions.set(b,c),this.animations.set(m,b),M.push(c.delay)}this.mainAnimation=this.mainElement.animate([{opacity:"0"},{opacity:"1"}],{duration:this.totalDuration,easing:"linear"}),this.minDelay=Math.min(...M),this.setSpeed(F),W?this.play():this.pause(),this.promise=this.newPromise(),this.mainAnimation.onfinish=()=>{this.emit("complete",this),this.stopLoop()}}catch(s){this.emit("error",s)}}newPromise(){return new Promise((t,e)=>{this.on("complete",()=>t([this])),this.on("error",r=>e(r))})}then(t,e){return t=t==null?void 0:t.bind(this),e=e==null?void 0:e.bind(this),this.promise.then(t,e),this}catch(t){return t=t==null?void 0:t.bind(this),this.promise.catch(t),this}finally(t){return t=t==null?void 0:t.bind(this),this.promise.finally(t),this}loop(){this.stopLoop(),this.emit("update",this.getProgress(),this),this.animationFrame=window.requestAnimationFrame(this.loop)}stopLoop(){window.cancelAnimationFrame(this.animationFrame)}all(t){return t(this.mainAnimation),this.animations.forEach(e=>t(e)),this}beginEvent(){if(this.getProgress()==0){let t=window.setTimeout(()=>{this.emit("begin",this),t=window.clearTimeout(t)},this.minDelay)}}play(){let t=this.getPlayState();return this.beginEvent(),this.all(e=>e.play()),this.emit("play",t,this),this.loop(),this}pause(){let t=this.getPlayState();return this.all(e=>e.pause()),this.emit("pause",t,this),this.stopLoop(),this.animationFrame=void 0,this}reset(){return this.setProgress(0),this.beginEvent(),this.options.autoplay?this.play():this.pause(),this}cancel(){return this.all(t=>t.cancel()),this.stopLoop(),this}finish(){return this.all(t=>t.finish()),this.stopLoop(),this}stop(){for(this.cancel(),this.animations.clear();this.targets.length;)this.targets.pop();this.mainElement=void 0,this.emit("stop")}getTargets(){return this.targets}getAnimation(t){return this.animations.get(t)}getTiming(t){var a,o,l;let e=t instanceof Animation?t:this.getAnimation(t),r=(a=this.computedOptions.get(e))!=null?a:{},n=(l=(o=e.effect)==null?void 0:o.getTiming())!=null?l:{},s=this.getOptions();return u(u(u(u({},z),s),n),r)}getTotalDuration(){return this.totalDuration}getCurrentTime(){return this.mainAnimation.currentTime}getProgress(){return this.getCurrentTime()/this.totalDuration*100}getSpeed(){return this.mainAnimation.playbackRate}getPlayState(){return this.mainAnimation.playState}getOptions(){return this.options}setCurrentTime(t){return this.all(e=>{e.currentTime=t}),this.emit("update",this.getProgress()),this}setProgress(t){let e=t/100*this.totalDuration;return this.setCurrentTime(e),this}setSpeed(t=1){return this.all(e=>{e.playbackRate=t}),this}on(t,e,r){return this.emitter.on(t,e,r!=null?r:this),this}off(t,e,r){return this.emitter.off(t,e,r!=null?r:this),this}emit(t,...e){return this.emitter.emit(t,...e),this}toJSON(){return this.getOptions()}get[Symbol.toStringTag](){return"Animate"}},g=(i={})=>new w(i);(()=>{let i=".css-selector-demo",t=g({target:`${i} .el`,transform:["translateX(0px)","translateX(250px)"],onfinish(r){r.style.transform="translateX(250px)"},duration:500,autoplay:!1});document.querySelector(i).addEventListener("click",()=>{t.reset(),t.play()})})();(()=>{let i=".dom-node-demo",t=document.querySelectorAll(`${i} .el`),e=g({target:t,transform:["translateX(0px)","translateX(250px)"],onfinish(n){n.style.transform="translateX(250px)"},duration:500,autoplay:!1});document.querySelector(i).addEventListener("click",()=>{e.reset(),e.play()})})();(()=>{let i=".array-demo",t=n=>`${i} .el-0${n}`,e=g({target:[`${i} .el-01`,t(2),t(3),t(4),t(5)],transform:["translateX(0px)","translateX(250px)"],onfinish(n){n.style.transform="translateX(250px)"},autoplay:!1});document.querySelector(i).addEventListener("click",()=>{e.reset(),e.play()})})();(()=>{let i=".css-properties-demo",t=g({target:`${i} .el`,backgroundColor:["#616aff","#fff"],left:["0px","240px"],borderRadius:["0%","50%"],onfinish(r){let{style:n}=r;n.backgroundColor="#fff",n.left="240px",n.borderRadius="50%"},easing:"in-out-quad",autoplay:!1});document.querySelector(i).addEventListener("click",()=>{t.reset(),t.play()})})();(()=>{let i=".css-transform-demo",t=g({target:`${i} .el`,transform:["translateX(0) scale(1) rotate(0)","translateX(250px) scale(2) rotate(1turn)"],onfinish(r){r.style.transform="translateX(250px) scale(2) rotate(1turn)"},easing:"in-out-quad",autoplay:!1});document.querySelector(i).addEventListener("click",()=>{t.reset(),t.play()})})();(()=>{let i=".svg-attributes-demo";var t=document.querySelector(`${i} path`);let e=g({target:t,strokeDashoffset:[4e3,0],loop:!0,direction:"alternate",easing:"in-out-expo",autoplay:!1});document.querySelector(i).addEventListener("click",()=>{e.getPlayState()==="running"?e.pause():e.play()}),e.on("update",()=>{console.log("Go")})})(); +var Q=Object.defineProperty;var O=Object.prototype.hasOwnProperty;var A=Object.getOwnPropertySymbols,R=Object.prototype.propertyIsEnumerable;var C=(i,t,e)=>t in i?Q(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,u=(i,t)=>{for(var e in t||(t={}))O.call(t,e)&&C(i,e,t[e]);if(A)for(var e of A(t))R.call(t,e)&&C(i,e,t[e]);return i};var S=(i,t)=>{var e={};for(var r in i)O.call(i,r)&&t.indexOf(r)<0&&(e[r]=i[r]);if(i!=null&&A)for(var r of A(i))t.indexOf(r)<0&&R.call(i,r)&&(e[r]=i[r]);return e};var p=class{constructor(t){this.map=new Map(t)}getMap(){return this.map}get(t){return this.map.get(t)}keys(){return Array.from(this.map.keys())}values(){return Array.from(this.map.values())}set(t,e){return this.map.set(t,e),this}add(t){let r=this.size;return this.set(r,t),this}get size(){return this.map.size}get length(){return this.map.size}last(t=1){let e=this.keys()[this.size-t];return this.get(e)}delete(t){return this.map.delete(t)}remove(t){return this.map.delete(t),this}clear(){return this.map.clear(),this}has(t){return this.map.has(t)}entries(){return this.map.entries()}forEach(t,e){return this.map.forEach(t,e),this}[Symbol.iterator](){return this.entries()}},E=(i,t,...e)=>{i.forEach(r=>{r[t](...e)})};var wt=new DOMParser;var D=({callback:i=()=>{},scope:t=null,name:e="event"})=>({callback:i,scope:t,name:e}),b=class extends p{constructor(t="event"){super();this.name=t}},v=class extends p{constructor(){super()}getEvent(t){let e=this.get(t);return e instanceof b?e:(this.set(t,new b(t)),this.get(t))}newListener(t,e,r){let n=this.getEvent(t);return n.add(D({name:t,callback:e,scope:r})),n}on(t,e,r){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,s,a=typeof t=="object"&&!Array.isArray(t),o=a?e:r;return a||(s=e),Object.keys(t).forEach(l=>{a?(n=l,s=t[l]):n=t[l],this.newListener(n,s,o)},this),this}removeListener(t,e,r){let n=this.get(t);if(n instanceof b&&e){let s=D({name:t,callback:e,scope:r});n.forEach((a,o)=>{if(a.callback===s.callback&&a.scope===s.scope)return n.remove(o)})}return n}off(t,e,r){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,s,a=typeof t=="object"&&!Array.isArray(t),o=a?e:r;return a||(s=e),Object.keys(t).forEach(l=>{a?(n=l,s=t[l]):n=t[l],typeof s=="function"?this.removeListener(n,s,o):this.remove(n)},this),this}emit(t,...e){return typeof t=="undefined"?this:(typeof t=="string"&&(t=t.trim().split(/\s/g)),t.forEach(r=>{let n=this.get(r);n instanceof b&&n.forEach(s=>{let{callback:a,scope:o}=s;a.apply(o,e)})},this),this)}clear(){return E(this,"clear"),super.clear(),this}};var rt=i=>typeof i=="string"?Array.from(document.querySelectorAll(i)):[i],nt=i=>[].concat(...i),K=i=>Array.isArray(i)?nt(i.map(K)):typeof i=="string"||i instanceof Node?rt(i):i instanceof NodeList||i instanceof HTMLCollection?Array.from(i):[],_=(i,t,e)=>typeof i=="function"?i.apply(e,t):i,U=(i,t,e)=>{let r,n,s={},a=Object.keys(i);for(let o=0,l=a.length;o/^(in|out)/.test(i)?st[i]:i,z={keyframes:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",autoplay:!0,duration:1e3,fillMode:"auto",direction:"normal",extend:{}},w=class{constructor(t={}){this.options={};this.targets=[];this.properties={};this.animations=new p;this.totalDuration=0;this.minDelay=0;this.computedOptions=new p;this.emitter=new v;var r;try{let e=t,{options:s}=e,a=S(e,["options"]),o=s instanceof w?s.getOptions():Array.isArray(s)?(r=s==null?void 0:s[0])==null?void 0:r.getOptions():s;this.options=Object.assign({},z,o,a),this.loop=this.loop.bind(this);let n=this.options,{loop:l,delay:q,speed:F,easing:T,endDelay:V,duration:j,direction:G,fillMode:$,onfinish:P,target:X,keyframes:B,autoplay:Y,extend:W}=n,J=S(n,["loop","delay","speed","easing","endDelay","duration","direction","fillMode","onfinish","target","keyframes","autoplay","extend"]);this.mainElement=document.createElement("div"),this.targets=K(X),this.properties=J;let M=[],f=this.targets.length,y;for(let h=0;h0||(y=U(y,[h,f,m],this));let k=c.delay+c.duration*c.iterations+c.endDelay;this.totalDuration{typeof P=="function"&&P.call(this,m,h,f,d),this.emit("finish",m,h,f,d)},this.computedOptions.set(d,c),this.animations.set(m,d),M.push(c.delay)}this.mainAnimation=this.mainElement.animate([{opacity:"0"},{opacity:"1"}],{duration:this.totalDuration,easing:"linear"}),this.minDelay=Math.min(...M),this.setSpeed(F),Y?this.play():this.pause(),this.promise=this.newPromise(),this.mainAnimation.onfinish=()=>{this.emit("complete",this),this.stopLoop()}}catch(s){this.emit("error",s)}}newPromise(){return new Promise((t,e)=>{this.on("complete",()=>t([this])),this.on("error",r=>e(r))})}then(t,e){return t=t==null?void 0:t.bind(this),e=e==null?void 0:e.bind(this),this.promise.then(t,e),this}catch(t){return t=t==null?void 0:t.bind(this),this.promise.catch(t),this}finally(t){return t=t==null?void 0:t.bind(this),this.promise.finally(t),this}loop(){this.stopLoop(),this.emit("update",this.getProgress(),this),this.animationFrame=window.requestAnimationFrame(this.loop)}stopLoop(){window.cancelAnimationFrame(this.animationFrame)}all(t){return t(this.mainAnimation,this.mainElement),this.animations.forEach(t),this}beginEvent(){if(this.getProgress()==0){let t=window.setTimeout(()=>{this.emit("begin",this),t=window.clearTimeout(t)},this.minDelay)}}play(){let t=this.getPlayState();return this.beginEvent(),this.all(e=>e.play()),this.emit("play",t,this),this.loop(),this}pause(){let t=this.getPlayState();return this.all(e=>e.pause()),this.emit("pause",t,this),this.stopLoop(),this.animationFrame=void 0,this}reset(){return this.setProgress(0),this.beginEvent(),this.options.autoplay?this.play():this.pause(),this}cancel(){return this.all(t=>t.cancel()),this.stopLoop(),this}finish(){return this.all(t=>t.finish()),this.stopLoop(),this}stop(){for(this.cancel(),this.animations.clear();this.targets.length;)this.targets.pop();this.mainElement=void 0,this.emit("stop")}getTargets(){return this.targets}getAnimation(t){return this.animations.get(t)}getTiming(t){var a,o,l;let e=t instanceof Animation?t:this.getAnimation(t),r=(a=this.computedOptions.get(e))!=null?a:{},n=(l=(o=e.effect)==null?void 0:o.getTiming())!=null?l:{},s=this.getOptions();return u(u(u(u({},z),s),n),r)}getTotalDuration(){return this.totalDuration}getCurrentTime(){return this.mainAnimation.currentTime}getProgress(){return this.getCurrentTime()/this.totalDuration*100}getSpeed(){return this.mainAnimation.playbackRate}getPlayState(){return this.mainAnimation.playState}getOptions(){return this.options}setCurrentTime(t){return this.all(e=>{e.currentTime=t}),this.emit("update",this.getProgress()),this}setProgress(t){let e=t/100*this.totalDuration;return this.setCurrentTime(e),this}setSpeed(t=1){return this.all(e=>{e.playbackRate=t}),this}on(t,e,r){return this.emitter.on(t,e,r!=null?r:this),this}off(t,e,r){return this.emitter.off(t,e,r!=null?r:this),this}emit(t,...e){return this.emitter.emit(t,...e),this}toJSON(){return this.getOptions()}get[Symbol.toStringTag](){return"Animate"}},g=(i={})=>new w(i);(()=>{let i=".css-selector-demo",t=g({target:`${i} .el`,transform:["translateX(0px)","translateX(250px)"],onfinish(r){r.style.transform="translateX(250px)"},duration:500,autoplay:!1});document.querySelector(i).addEventListener("click",()=>{t.reset(),t.play()})})();(()=>{let i=".dom-node-demo",t=document.querySelectorAll(`${i} .el`),e=g({target:t,transform:["translateX(0px)","translateX(250px)"],onfinish(n){n.style.transform="translateX(250px)"},duration:500,autoplay:!1});document.querySelector(i).addEventListener("click",()=>{e.reset(),e.play()})})();(()=>{let i=".array-demo",t=n=>`${i} .el-0${n}`,e=g({target:[`${i} .el-01`,t(2),t(3),t(4),t(5)],transform:["translateX(0px)","translateX(250px)"],onfinish(n){n.style.transform="translateX(250px)"},autoplay:!1});document.querySelector(i).addEventListener("click",()=>{e.reset(),e.play()})})();(()=>{let i=".css-properties-demo",t=g({target:`${i} .el`,backgroundColor:["#616aff","#fff"],left:["0px","240px"],borderRadius:["0%","50%"],onfinish(r){let{style:n}=r;n.backgroundColor="#fff",n.left="240px",n.borderRadius="50%"},easing:"in-out-quad",autoplay:!1});document.querySelector(i).addEventListener("click",()=>{t.reset(),t.play()})})();(()=>{let i=".css-transform-demo",t=g({target:`${i} .el`,transform:["translateX(0) scale(1) rotate(0)","translateX(250px) scale(2) rotate(1turn)"],onfinish(r){r.style.transform="translateX(250px) scale(2) rotate(1turn)"},easing:"in-out-quad",autoplay:!1});document.querySelector(i).addEventListener("click",()=>{t.reset(),t.play()})})();(()=>{let i=".svg-attributes-demo";var t=document.querySelector(`${i} path`);let e=g({target:t,strokeDashoffset:[4e3,0],loop:!0,direction:"alternate",easing:"in-out-expo",autoplay:!1});document.querySelector(i).addEventListener("click",()=>{e.getPlayState()==="running"?e.pause():e.play()}),e.on("update",()=>{console.log("Go")})})(); +//# sourceMappingURL=animate.js.map diff --git a/demo/js/animate.js.map b/demo/js/animate.js.map new file mode 100644 index 0000000..a3812b0 --- /dev/null +++ b/demo/js/animate.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["packages/manager/src/api.ts", "packages/native/src/page.ts", "packages/emitter/src/api.ts", "packages/animate/src/api.ts", "build/ts/animate.ts"], + "sourcesContent": ["/** Manages complex lists of named data, eg. A page can be stored in a list by of other pages with the url being how the page is stored in the list. Managers use Maps to store data */\nexport class Manager {\n\t/** The complex list of named data, to which the Manager controls */\n\tpublic map: Map;\n\tconstructor(value?: Array<[K, V]>) {\n\t\tthis.map = new Map(value);\n\t}\n\n\t/** Returns the Manager classes base Map */\n\tpublic getMap(): Map {\n\t\treturn this.map;\n\t}\n\n\t/** Get a value stored in the Manager */\n\tpublic get(key: K): V {\n\t\treturn this.map.get(key);\n\t}\n\n\t/** Returns the keys of all items stored in the Manager as an Array */\n\tpublic keys(): Array {\n\t\treturn Array.from(this.map.keys());\n\t}\n\n\t/** Returns the values of all items stored in the Manager as an Array */\n\tpublic values(): Array {\n\t\treturn Array.from(this.map.values());\n\t}\n\n\t/** Set a value to the Manager using a key */\n\tpublic set(key: K, value: V): Manager {\n\t\tthis.map.set(key, value);\n\t\treturn this;\n\t}\n\n\t/** Adds a value to Manager, and uses the current size of the Manager as it's key, it works best when all the key in the Manager are numbers */\n\tpublic add(value: V): Manager {\n\t\tlet size = this.size;\n\t\t// @ts-ignore\n\t\tlet num: K = size as K;\n\t\tthis.set(num, value);\n\t\treturn this;\n\t}\n\n\t/** Returns the total number of items stored in the Manager */\n\tpublic get size(): number {\n\t\treturn this.map.size;\n\t}\n\n\t/** An alias for size */\n\tpublic get length(): number {\n\t\treturn this.map.size;\n\t}\n\n\t/** Returns the last item in the Manager who's index is a certain distance from the last item in the Manager */\n\tpublic last(distance: number = 1): V | undefined {\n\t\tlet key = this.keys()[this.size - distance];\n\t\treturn this.get(key);\n\t}\n\n\t/** Removes a value stored in the Manager via a key, returns true if an element in the Map object existed and has been removed, or false if the element does not exist */\n\tpublic delete(key: K): boolean {\n\t\treturn this.map.delete(key);\n\t}\n\n\t/** Removes a value stored in the Manager via a key, returns the Manager class, allowing for chains */\n\tpublic remove(key: K): Manager {\n\t\tthis.map.delete(key);\n\t\treturn this;\n\t}\n\n\t/** Clear the Manager of all its contents */\n\tpublic clear(): Manager {\n\t\tthis.map.clear();\n\t\treturn this;\n\t}\n\n\t/** Checks if the Manager contains a certain key */\n\tpublic has(key: K): boolean {\n\t\treturn this.map.has(key);\n\t}\n\n\t/** Returns a new Iterator object that contains an array of [key, value] for each element in the Map object in insertion order. */\n\tpublic entries(): IterableIterator<[K, V]> {\n\t\treturn this.map.entries();\n\t}\n\n\t/** Iterates through the Managers contents, calling a callback function every iteration */\n\tpublic forEach(\n\t\tcallback: (value?: V, key?: K, map?: Map) => void,\n\t\tcontext?: object\n\t): Manager {\n\t\tthis.map.forEach(callback, context);\n\t\treturn this;\n\t}\n\n\t/** Allows for iteration via for..of, learn more: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators] */\n\tpublic [Symbol.iterator](): IterableIterator<[K, V]> {\n\t\treturn this.entries();\n\t}\n}\n\n/**\n * Calls the method of a certain name for all items that are currently installed\n */\nexport const methodCall = (manager: Manager, method: string, ...args: any): void => {\n\tmanager.forEach((item) => {\n\t\t// @ts-ignore\n\t\titem[method](...args);\n\t});\n};\n\n/**\n * Asynchronously calls the method of a certain name for all items that are currently installed, similar to methodCall\n */\nexport const asyncMethodCall = async (manager: Manager, method: string, ...args: any): Promise => {\n\tfor (let [, item] of manager) {\n\t\t// @ts-ignore\n\t\tawait item[method](...args);\n\t}\n};\n\nexport default Manager;\n", "import { Manager, ManagerItem, AdvancedManager } from \"./manager\";\nimport { equal, newURL } from \"./url\";\nimport { getConfig } from \"./config\";\nimport { Service } from \"./service\";\n\nexport interface IPage extends ManagerItem {\n dom: Document,\n wrapper: HTMLElement,\n title: string,\n head: Element,\n body: Element,\n url: URL,\n data: string,\n wrapperAttr: string,\n\n build(): any,\n install(): void,\n uninstall(): any,\n}\n\n/**\n * Parses strings to DOM\n */\nexport const PARSER: DOMParser = new DOMParser();\n\n/** A page represents the DOM elements that create each page */\nexport class Page extends ManagerItem implements IPage {\n /** Holds the DOM of the current page */\n public dom: Document;\n\n /** Holds the wrapper element to be swapped out of each Page */\n public wrapper: HTMLElement;\n\n /** Holds the title of each page */\n public title: string;\n\n /** Holds the head element of each page */\n public head: Element;\n\n /** Holds the body element of each page */\n public body: Element;\n\n /** The URL of the current page */\n public url: URL;\n\n /** The payload of a page request */\n public data: string;\n\n /** Attr that identifies the wrapper */\n public wrapperAttr: string;\n\n constructor(url: URL = newURL(), dom: string | Document = document) {\n super();\n this.url = url;\n\n if (typeof dom === \"string\") {\n this.data = dom;\n } else this.dom = dom || document;\n }\n\n /** Builds the page's dom, and sets the title, head, body, and wrapper properties of the Page class */\n public build() {\n if (!(this.dom instanceof Node)) {\n this.dom = PARSER.parseFromString(this.data, \"text/html\");\n }\n\n if (!(this.body instanceof Node)) {\n let { title, head, body } = this.dom;\n this.title = title;\n this.head = head;\n this.body = body;\n this.wrapper = this.body.querySelector(this.wrapperAttr);\n }\n }\n\n public install() {\n this.wrapperAttr = getConfig(this.config, \"wrapperAttr\");\n }\n\n public uninstall() {\n this.url = undefined;\n this.title = undefined;\n this.head = undefined;\n this.body = undefined;\n this.dom = undefined;\n this.wrapper = undefined;\n this.data = undefined;\n this.wrapperAttr = undefined;\n }\n}\n\nexport interface IPageManager extends Service {\n loading: Manager>,\n pages: AdvancedManager;\n\n install(): any,\n\n get(key): Page,\n add(value): PageManager,\n set(key, value): PageManager,\n remove(key): PageManager,\n has(key): boolean,\n clear(): PageManager,\n size: number,\n keys(): any[],\n\n load(_url: URL | string): Promise,\n request(url: string): Promise,\n}\n\n/** Controls which page to load */\nexport class PageManager extends Service implements IPageManager {\n /** Stores all fetch requests that are currently loading */\n public loading: Manager> = new Manager();\n\n pages: AdvancedManager;\n\n /** Instantiate pages, and add the current page to pages */\n install() {\n this.pages = new AdvancedManager(this.app);\n\n let URLString = newURL().pathname;\n this.set(URLString, new Page());\n URLString = undefined;\n }\n\n get(key) { return this.pages.get(key); }\n add(value) { this.pages.add(value); return this; }\n set(key, value) { this.pages.set(key, value); return this; }\n remove(key) { this.pages.remove(key); return this; }\n has(key) { return this.pages.has(key); }\n clear() { this.pages.clear(); return this; }\n get size() { return this.pages.size; }\n keys() { return this.pages.keys(); }\n\n /** Load from cache or by requesting URL via a fetch request, avoid requesting for the same thing twice by storing the fetch request in \"this.loading\" */\n public async load(_url: URL | string = newURL()): Promise {\n let url: URL = newURL(_url);\n let urlString: string = url.pathname;\n let page: Page, request: Promise;\n\n if (this.has(urlString)) {\n page = this.get(urlString);\n return Promise.resolve(page);\n }\n\n if (!this.loading.has(urlString)) {\n request = this.request(urlString);\n this.loading.set(urlString, request);\n } else request = this.loading.get(urlString);\n\n let response = await request;\n this.loading.remove(urlString);\n\n page = new Page(url, response);\n this.set(urlString, page);\n\n if (this.size > getConfig(this.config, \"maxPages\")) {\n let currentUrl = newURL();\n let keys = this.keys();\n let first = equal(currentUrl, keys[0]) ? keys[1] : keys[0];\n let page = this.get(first);\n page.unregister();\n page = undefined;\n keys = undefined;\n currentUrl = undefined;\n first = undefined;\n }\n\n return page;\n }\n\n /** Starts a fetch request */\n public async request(url: string): Promise {\n const headers = new Headers(getConfig(this.config, \"headers\"));\n const timeout = window.setTimeout(() => {\n window.clearTimeout(timeout);\n throw \"Request Timed Out!\";\n }, getConfig(this.config, \"timeout\"));\n\n try {\n let response = await fetch(url, {\n mode: 'same-origin',\n method: \"GET\",\n headers,\n cache: \"default\",\n credentials: \"same-origin\",\n });\n\n window.clearTimeout(timeout);\n if (response.status >= 200 && response.status < 300) {\n return await response.text();\n }\n\n const err = new Error(response.statusText || \"\" + response.status);\n throw err;\n } catch (err) {\n window.clearTimeout(timeout);\n throw err;\n }\n }\n}\n", "import { Manager, methodCall } from \"@okikio/manager\";\n\nexport type ListenerCallback = ((...args: any) => void);\nexport interface IListener {\n readonly callback: ListenerCallback;\n readonly scope: object;\n readonly name: string;\n}\n\n/** Represents a new event listener consisting of properties like: callback, scope, name */\nexport const newListener = ({\n callback = () => { },\n scope = null,\n name = \"event\",\n}: IListener): IListener => ({ callback, scope, name });\n\n/** Represents a new event */\nexport class Event extends Manager {\n /** The name of the event */\n public name: string;\n constructor(name: string = \"event\") {\n super();\n this.name = name;\n }\n}\n\nexport type EventInput = string | object | Array;\n\n/**\n * An Event Emitter\n * */\nexport class EventEmitter extends Manager {\n constructor() {\n super();\n }\n\n /** Gets event, if event doesn't exist create a new one */\n public getEvent(name: string): Event {\n let event = this.get(name);\n if (!(event instanceof Event)) {\n this.set(name, new Event(name));\n return this.get(name);\n }\n\n return event;\n }\n\n /** Creates a listener and adds it to an event */\n public newListener(\n name: string,\n callback: ListenerCallback,\n scope: object\n ): Event {\n let event = this.getEvent(name);\n event.add(newListener({ name, callback, scope }));\n return event;\n }\n\n /** Adds a listener to a given event */\n public on(\n events: EventInput,\n callback?: ListenerCallback | object,\n scope?: object\n ): EventEmitter {\n // If there is no event break\n if (typeof events == \"undefined\") return this;\n\n // Create a new event every space\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\n\n let _name: string;\n let _callback: ListenerCallback;\n let isObject = typeof events == \"object\" && !Array.isArray(events);\n\n let _scope: object = isObject ? callback : scope;\n if (!isObject) _callback = (callback as ListenerCallback);\n\n // Loop through the list of events\n Object.keys(events).forEach(key => {\n // Select the name of the event from the list\n // Remember events can be {String | Object | Array}\n\n // Check If events is an Object (JSON like Object, and not an Array)\n if (isObject) {\n _name = key;\n _callback = events[key];\n } else {\n _name = events[key];\n }\n\n this.newListener(_name, _callback, _scope);\n }, this);\n return this;\n }\n\n /** Removes a listener from an event */\n public removeListener(\n name: string,\n callback: ListenerCallback,\n scope: object\n ): Event {\n let event: Event = this.get(name);\n if (event instanceof Event && callback) {\n let listener = newListener({ name, callback, scope });\n\n event.forEach((value: IListener, i: number) => {\n if (\n value.callback === listener.callback &&\n value.scope === listener.scope\n ) {\n return event.remove(i);\n }\n });\n }\n\n return event;\n }\n\n /** Remove a listener from a given event, or just completely remove an event */\n public off(\n events: EventInput,\n callback?: ListenerCallback | object,\n scope?: object\n ): EventEmitter {\n // If there is no event break\n if (typeof events == \"undefined\") return this;\n\n // Create a new event every space\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\n\n let _name: string;\n let _callback: ListenerCallback;\n let isObject = typeof events == \"object\" && !Array.isArray(events);\n\n let _scope: object = isObject ? callback : scope;\n if (!isObject) _callback = (callback as ListenerCallback);\n\n // Loop through the list of events\n Object.keys(events).forEach(key => {\n // Select the name of the event from the list\n // Remember events can be {String | Object | Array}\n\n // Check If events is an Object (JSON like Object, and not an Array)\n if (isObject) {\n _name = key;\n _callback = events[key];\n } else {\n _name = events[key];\n }\n\n if (typeof _callback === \"function\") {\n this.removeListener(_name, _callback, _scope);\n } else this.remove(_name);\n }, this);\n return this;\n }\n\n /** Call all listeners within an event */\n public emit(\n events: string | Array,\n ...args: any\n ): EventEmitter {\n // If there is no event break\n if (typeof events == \"undefined\") return this;\n\n // Create a new event every space\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\n\n // Loop through the list of events\n events.forEach((event: string) => {\n let _event: Event = this.get(event);\n\n if (_event instanceof Event) {\n _event.forEach((listener: IListener) => {\n let { callback, scope } = listener;\n callback.apply(scope, args);\n });\n }\n }, this);\n return this;\n }\n\n /** Clears events and event listeners */\n public clear() {\n methodCall(this, \"clear\");\n super.clear();\n return this;\n }\n}\n\nexport default EventEmitter;\n", "import { EventEmitter, EventInput, ListenerCallback } from \"@okikio/emitter\";\nimport { Manager } from \"@okikio/manager\";\n\n// DOM\nexport type AnimationTarget = string | Node | NodeList | HTMLCollection | HTMLElement[] | AnimationTarget[];\nexport const getElements = (selector: string | Node): Node[] => {\n return typeof selector === \"string\" ? Array.from(document.querySelectorAll(selector as string)) : [selector];\n};\n\nconst flatten = (arr: AnimationTarget[]) => [].concat(...arr);\nexport const getTargets = (targets: AnimationTarget): Node[] => {\n if (Array.isArray(targets)) {\n return flatten((targets as AnimationTarget[]).map(getTargets));\n }\n if (typeof targets == \"string\" || targets instanceof Node)\n return getElements(targets);\n if (targets instanceof NodeList || targets instanceof HTMLCollection)\n return Array.from(targets);\n return [];\n};\n\n// VALUES\nexport type closureArgs = [number, number, HTMLElement];\nexport type closure = ((index?: number, total?: number, element?: HTMLElement) => (genericTypes[] | void)) | any;\nexport const computeValue = (value: closure, args: closureArgs, context: Animate) => {\n if (typeof value === \"function\") {\n return value.apply(context, args);\n } else { return value; }\n};\n\nexport const mapObject = (obj: object, args: closureArgs, options: Animate): any => {\n let key: string, value: any, result = {};\n let keys = Object.keys(obj);\n for (let i = 0, len = keys.length; i < len; i++) {\n key = keys[i];\n value = obj[key];\n result[key] = computeValue(value, args, options);\n }\n\n return result;\n};\n\n/** From: [https://easings.net] */\nexport const easings = {\n \"in\": \"ease-in\",\n \"out\": \"ease-out\",\n \"in-out\": \"ease-in-out\",\n\n // Sine\n \"in-sine\": \"cubic-bezier(0.47, 0, 0.745, 0.715)\",\n \"out-sine\": \"cubic-bezier(0.39, 0.575, 0.565, 1)\",\n \"in-out-sine\": \"cubic-bezier(0.445, 0.05, 0.55, 0.95)\",\n\n // Quad\n \"in-quad\": \"cubic-bezier(0.55, 0.085, 0.68, 0.53)\",\n \"out-quad\": \"cubic-bezier(0.25, 0.46, 0.45, 0.94)\",\n \"in-out-quad\": \"cubic-bezier(0.455, 0.03, 0.515, 0.955)\",\n\n // Cubic\n \"in-cubic\": \"cubic-bezier(0.55, 0.055, 0.675, 0.19)\",\n \"out-cubic\": \"cubic-bezier(0.215, 0.61, 0.355, 1)\",\n \"in-out-cubic\": \"cubic-bezier(0.645, 0.045, 0.355, 1)\",\n\n // Quart\n \"in-quart\": \"cubic-bezier(0.895, 0.03, 0.685, 0.22)\",\n \"out-quart\": \"cubic-bezier(0.165, 0.84, 0.44, 1)\",\n \"in-out-quart\": \"cubic-bezier(0.77, 0, 0.175, 1)\",\n\n // Quint\n \"in-quint\": \"cubic-bezier(0.755, 0.05, 0.855, 0.06)\",\n \"out-quint\": \"cubic-bezier(0.23, 1, 0.32, 1)\",\n \"in-out-quint\": \"cubic-bezier(0.86, 0, 0.07, 1)\",\n\n // Expo\n \"in-expo\": \"cubic-bezier(0.95, 0.05, 0.795, 0.035)\",\n \"out-expo\": \"cubic-bezier(0.19, 1, 0.22, 1)\",\n \"in-out-expo\": \"cubic-bezier(1, 0, 0, 1)\",\n\n // Circ\n \"in-circ\": \"cubic-bezier(0.6, 0.04, 0.98, 0.335)\",\n \"out-circ\": \"cubic-bezier(0.075, 0.82, 0.165, 1)\",\n \"in-out-circ\": \"cubic-bezier(0.785, 0.135, 0.15, 0.86)\",\n\n // Back\n \"in-back\": \"cubic-bezier(0.6, -0.28, 0.735, 0.045)\",\n \"out-back\": \"cubic-bezier(0.175, 0.885, 0.32, 1.275)\",\n \"in-out-back\": \"cubic-bezier(0.68, -0.55, 0.265, 1.55)\"\n};\n\nexport const getEase = (ease: string) => {\n return /^(in|out)/.test(ease) ? easings[ease] : ease;\n};\n\nexport type genericTypes = genericTypes[] | boolean | object | string | number | closure | null | undefined;\nexport interface AnimationOptions {\n target?: AnimationTarget,\n\n speed?: number,\n autoplay?: boolean,\n options?: AnimationOptions,\n delay?: number | closure,\n easing?: string | closure,\n endDelay?: number | closure,\n duration?: number | closure,\n keyframes?: Keyframe[] | object[] | closure,\n loop?: number | boolean | closure, // iterations: number,\n onfinish?: (element?: HTMLElement, index?: number, total?: number, animation?: Animation) => any,\n fillMode?: \"none\" | \"forwards\" | \"backwards\" | \"both\" | \"auto\" | closure,\n direction?: \"normal\" | \"reverse\" | \"alternate\" | \"alternate-reverse\" | closure,\n extend?: EffectTiming,\n [property: string]: genericTypes;\n};\n\nexport const DefaultAnimationOptions: AnimationOptions = {\n keyframes: [],\n\n loop: 1, // iterations: number,\n delay: 0,\n speed: 1,\n endDelay: 0,\n easing: \"ease\",\n autoplay: true,\n duration: 1000,\n fillMode: \"auto\",\n direction: \"normal\",\n extend: {}\n};\n\nexport type AnimationEvents = \"update\" | \"play\" | \"pause\" | \"start\" | \"begin\" | \"complete\" | \"finish\" | \"error\" | \"stop\";\n\n/** You can check it out here: https://codepen.io/okikio/pen/qBbdGaW?editors=0011 */\nexport class Animate {\n /**\n * Stores the options for the current animation\n */\n public options: AnimationOptions = {};\n\n /**\n * The Array of Elements to Animate\n */\n public targets: Node[] = [];\n\n /**\n * The properties to animate\n */\n public properties: object = {};\n\n /**\n * A Manager of Animations\n */\n public animations: Manager = new Manager();\n\n /**\n * The total duration of all Animation's\n */\n public totalDuration: number = 0;\n\n /**\n * The smallest delay out of all Animation's\n */\n public minDelay: number = 0;\n\n /**\n * The options for individual animations\n */\n public computedOptions: Manager = new Manager();\n\n /**\n * The Element the main animation uses\n */\n public mainElement: HTMLElement;\n\n /**\n * Stores an animation that runs on the total duration of the all other Animations, and as such it's the main Animation\n */\n public mainAnimation: Animation;\n\n /**\n * Stores request frame calls\n */\n public animationFrame: number;\n\n /**\n * An event emitter\n */\n public emitter: EventEmitter = new EventEmitter();\n\n /**\n * Returns a promise that is fulfilled when the mainAnimation is finished\n */\n public promise: Promise;\n constructor(options: AnimationOptions = {}) {\n try {\n let { options: animation, ...rest } = options;\n let oldOptions = animation instanceof Animate ? animation.getOptions() : (Array.isArray(animation) ? animation?.[0]?.getOptions() : animation);\n this.options = Object.assign({}, DefaultAnimationOptions, oldOptions, rest);\n this.loop = this.loop.bind(this);\n\n let {\n loop,\n delay,\n speed,\n easing,\n endDelay,\n duration,\n direction,\n fillMode,\n onfinish,\n target,\n keyframes,\n autoplay,\n extend,\n ...properties\n } = this.options;\n\n this.mainElement = document.createElement(\"div\");\n this.targets = getTargets(target);\n this.properties = properties;\n\n let delays = [];\n let len = this.targets.length;\n let animationKeyframe: Keyframe[] | PropertyIndexedKeyframes;\n for (let i = 0; i < len; i++) {\n let target = this.targets[i] as HTMLElement;\n let animationOptions: AnimationOptions = {\n easing: typeof easing == \"string\" ? getEase(easing) : easing,\n iterations: loop === true ? Infinity : (loop as number),\n direction,\n endDelay,\n duration,\n delay,\n fill: fillMode,\n ...extend\n };\n\n // Accept keyframes as a keyframes Object, or a method,\n // if there are no animations in the keyframes array,\n // uses css properties from the options object\n let arrKeyframes = computeValue((keyframes as Keyframe[]), [i, len, target], this);\n animationKeyframe = arrKeyframes.length ? arrKeyframes :\n (this.properties as PropertyIndexedKeyframes);\n\n // Allows the use of functions as the values, for both the keyframes and the animation object\n // It adds the capability of advanced stagger animation, similar to the anime js stagger functions\n animationOptions = mapObject(animationOptions, [i, len, target], this);\n if (!(arrKeyframes.length > 0))\n animationKeyframe = mapObject(animationKeyframe, [i, len, target], this);\n\n // Set the Animate classes duration to be the Animation with the largest totalDuration\n let tempDurations = animationOptions.delay +\n (animationOptions.duration * animationOptions.iterations) +\n animationOptions.endDelay;\n if (this.totalDuration < tempDurations) this.totalDuration = tempDurations;\n\n // Add animation to the Animations Set\n let animation = target.animate(animationKeyframe, animationOptions as KeyframeAnimationOptions);\n\n // Support for on finish\n animation.onfinish = () => {\n typeof onfinish == \"function\" && onfinish.call(this, target, i, len, animation);\n this.emit(\"finish\", target, i, len, animation);\n };\n\n // The calculated options for each individual option\n this.computedOptions.set(animation, animationOptions);\n this.animations.set(target, animation);\n delays.push(animationOptions.delay);\n }\n\n this.mainAnimation = this.mainElement.animate([\n { opacity: \"0\" },\n { opacity: \"1\" }\n ], {\n // Why waste performance on an animation no one can see?\n duration: this.totalDuration,\n easing: \"linear\"\n });\n\n this.minDelay = Math.min(...delays);\n this.setSpeed(speed);\n if (autoplay) this.play();\n else this.pause();\n\n this.promise = this.newPromise();\n this.mainAnimation.onfinish = () => {\n this.emit(\"complete\", this);\n this.stopLoop();\n };\n } catch (err) {\n this.emit(\"error\", err);\n }\n }\n\n /**\n * Returns a new Promise that is resolve when this.finish is called\n */\n public newPromise(): Promise {\n return new Promise((resolve, reject) => {\n /*\n Note that the `this` keyword is in an Array when it is resolved,\n this is due to Promises not wanting to resolve references,\n so, you can't resolve `this` directly, so, I chose to resolve `this` in an\n Array\n */\n this.on(\"complete\", () => resolve([this]));\n this.on(\"error\", err => reject(err));\n });\n }\n\n /**\n * Fulfills the this.promise Promise\n */\n public then(\n onFulfilled?: (value?: any) => any,\n onRejected?: (reason?: any) => any\n ): Animate {\n onFulfilled = onFulfilled?.bind(this);\n onRejected = onRejected?.bind(this);\n this.promise.then(onFulfilled, onRejected);\n return this;\n }\n\n /**\n * Catches error that occur in the this.promise Promise\n */\n public catch(onRejected: (reason?: any) => any): Animate {\n onRejected = onRejected?.bind(this);\n this.promise.catch(onRejected);\n return this;\n }\n\n /**\n * If you don't care if the this.promise Promise has either been rejected or resolved\n */\n public finally(onFinally: () => any): Animate {\n onFinally = onFinally?.bind(this);\n this.promise.finally(onFinally);\n return this;\n }\n\n /**\n * Represents an Animation Frame Loop\n */\n public loop(): void {\n this.stopLoop();\n this.emit(\"update\", this.getProgress(), this);\n this.animationFrame = window.requestAnimationFrame(this.loop);\n }\n\n /**\n * Cancels animation frame\n */\n public stopLoop() {\n window.cancelAnimationFrame(this.animationFrame);\n }\n\n /**\n * Calls a method that affects all animations including the mainAnimation; the method only allows the animation parameter\n */\n public all(method: (animation?: Animation, target?: HTMLElement) => void) {\n method(this.mainAnimation, this.mainElement);\n this.animations.forEach(method);\n return this;\n }\n\n /**\n * Register the begin event\n */\n protected beginEvent() {\n if (this.getProgress() == 0) {\n let timer: number | void = window.setTimeout(() => {\n this.emit(\"begin\", this);\n timer = window.clearTimeout(timer as number);\n }, this.minDelay);\n }\n }\n\n /**\n * Play Animation\n */\n public play(): Animate {\n let playstate = this.getPlayState();\n this.beginEvent();\n this.all(anim => anim.play());\n this.emit(\"play\", playstate, this);\n this.loop();\n return this;\n }\n\n /**\n * Pause Animation\n */\n public pause(): Animate {\n let playstate = this.getPlayState();\n this.all(anim => anim.pause());\n this.emit(\"pause\", playstate, this);\n this.stopLoop();\n this.animationFrame = undefined;\n return this;\n }\n\n /**\n * Reset all Animations\n */\n public reset() {\n this.setProgress(0);\n this.beginEvent();\n\n if (this.options.autoplay) this.play();\n else this.pause();\n return this;\n }\n\n /**\n * Cancels all Animations\n */\n public cancel() {\n this.all(anim => anim.cancel());\n this.stopLoop();\n return this;\n }\n\n /**\n * Force complete all Animations\n */\n public finish() {\n this.all(anim => anim.finish());\n this.stopLoop();\n return this;\n }\n\n /**\n * Cancels & Clears all Animations\n */\n public stop() {\n this.cancel();\n this.animations.clear();\n while (this.targets.length) this.targets.pop();\n this.mainElement = undefined;\n this.emit(\"stop\");\n }\n\n /**\n * Returns an Array of targets\n */\n public getTargets(): Node[] {\n return this.targets;\n }\n\n /**\n * Get a specific Animation from an Animate instance\n */\n public getAnimation(element: HTMLElement): Animation {\n return this.animations.get(element);\n }\n\n /**\n * Returns the timings of an Animation, given a target\n * E.g. { duration, endDelay, delay, iterations, iterationStart, direction, easing, fill, etc... }\n */\n public getTiming(target: HTMLElement | Animation): AnimationOptions & EffectTiming {\n let animation = target instanceof Animation ? target : this.getAnimation(target);\n let keyframeOptions = this.computedOptions.get(animation) ?? {};\n let timings = animation.effect?.getTiming() ?? {};\n let options = this.getOptions();\n\n return { ...DefaultAnimationOptions, ...options, ...timings, ...keyframeOptions };\n }\n\n /**\n * Returns the total duration of Animation\n */\n public getTotalDuration(): number {\n return this.totalDuration;\n }\n\n /**\n * Returns the current time of the Main Animation\n */\n public getCurrentTime(): number {\n return this.mainAnimation.currentTime;\n }\n\n /**\n * Returns the Animation progress as a fraction of the current time / duration * 100\n */\n public getProgress() {\n return (this.getCurrentTime() / this.totalDuration) * 100;\n }\n\n /**\n * Return the playback speed of the animation\n */\n public getSpeed(): number {\n return this.mainAnimation.playbackRate;\n }\n\n /**\n * Returns the current playing state\n */\n public getPlayState(): \"idle\" | \"running\" | \"paused\" | \"finished\" {\n return this.mainAnimation.playState;\n }\n\n /**\n * Get the options of an Animate instance\n */\n public getOptions(): AnimationOptions {\n return this.options;\n }\n\n /**\n * Set the current time of the Main Animation\n */\n public setCurrentTime(time: number): Animate {\n this.all(anim => { anim.currentTime = time; });\n this.emit(\"update\", this.getProgress());\n return this;\n }\n\n /**\n * Set the Animation progress as a value from 0 to 100\n */\n public setProgress(percent: number): Animate {\n let time = (percent / 100) * this.totalDuration;\n this.setCurrentTime(time);\n return this;\n }\n\n /**\n * Set the playback speed of an Animation\n */\n public setSpeed(speed: number = 1): Animate {\n this.all(anim => { anim.playbackRate = speed; });\n return this;\n }\n\n /**\n * Adds a listener for a given event\n */\n public on(events: AnimationEvents | EventInput, callback?: ListenerCallback, scope?: object): Animate {\n this.emitter.on(events, callback, scope ?? this);\n return this;\n }\n\n /**\n * Removes a listener from an event\n */\n public off(events: AnimationEvents | EventInput, callback?: ListenerCallback, scope?: object): Animate {\n this.emitter.off(events, callback, scope ?? this);\n return this;\n }\n\n /**\n * Call all listeners within an event\n */\n public emit(events: AnimationEvents | string | any[], ...args: any): Animate {\n this.emitter.emit(events, ...args);\n return this;\n }\n\n\n /** Returns the Animate options, as JSON */\n public toJSON(): AnimationOptions {\n return this.getOptions();\n }\n\n /**\n * The Symbol.toStringTag well-known symbol is a string valued property that is used\n * in the creation of the default string description of an object.\n * It is accessed internally by the Object.prototype.toString() method.\n */\n get [Symbol.toStringTag]() {\n return `Animate`;\n }\n}\n\n/** Creates a new Animate instance */\nexport const animate = (options: AnimationOptions = {}): Animate => {\n return new Animate(options);\n};\n\nexport class Timeline extends Animate {\n /**\n * A Manager of Animations\n */\n public animations: Manager = new Manager();\n constructor(options: AnimationOptions = {}) {\n super();\n try {\n let { options: animation, ...rest } = options;\n let oldOptions = animation instanceof Animate ? animation.getOptions() : (Array.isArray(animation) ? animation?.[0]?.getOptions() : animation);\n this.options = Object.assign({}, DefaultAnimationOptions, oldOptions, rest);\n this.loop = this.loop.bind(this);\n\n let {\n loop,\n delay,\n speed,\n easing,\n endDelay,\n duration,\n direction,\n fillMode,\n onfinish,\n target,\n keyframes,\n autoplay,\n extend,\n ...properties\n } = this.options;\n\n this.mainElement = document.createElement(\"div\");\n this.targets = getTargets(target);\n this.properties = properties;\n\n let delays = [];\n let len = this.targets.length;\n let animationKeyframe: Keyframe[] | PropertyIndexedKeyframes;\n for (let i = 0; i < len; i++) {\n let target = this.targets[i] as HTMLElement;\n let animationOptions: AnimationOptions = {\n easing: typeof easing == \"string\" ? getEase(easing) : easing,\n iterations: loop === true ? Infinity : (loop as number),\n direction,\n endDelay,\n duration,\n delay,\n fill: fillMode,\n ...extend\n };\n\n // Accept keyframes as a keyframes Object, or a method,\n // if there are no animations in the keyframes array,\n // uses css properties from the options object\n let arrKeyframes = computeValue((keyframes as Keyframe[]), [i, len, target], this);\n animationKeyframe = arrKeyframes.length ? arrKeyframes :\n (this.properties as PropertyIndexedKeyframes);\n\n // Allows the use of functions as the values, for both the keyframes and the animation object\n // It adds the capability of advanced stagger animation, similar to the anime js stagger functions\n animationOptions = mapObject(animationOptions, [i, len, target], this);\n if (!(arrKeyframes.length > 0))\n animationKeyframe = mapObject(animationKeyframe, [i, len, target], this);\n\n // Set the Animate classes duration to be the Animation with the largest totalDuration\n let tempDurations = animationOptions.delay +\n (animationOptions.duration * animationOptions.iterations) +\n animationOptions.endDelay;\n if (this.totalDuration < tempDurations) this.totalDuration = tempDurations;\n\n // Add animation to the Animations Set\n let animation = target.animate(animationKeyframe, animationOptions as KeyframeAnimationOptions);\n\n // Support for on finish\n animation.onfinish = () => {\n typeof onfinish == \"function\" && onfinish.call(this, target, i, len, animation);\n this.emit(\"finish\", target, i, len, animation);\n };\n\n // The calculated options for each individual option\n this.computedOptions.set(animation, animationOptions);\n this.animations.set(target, animation);\n delays.push(animationOptions.delay);\n }\n\n this.mainAnimation = this.mainElement.animate([\n { opacity: \"0\" },\n { opacity: \"1\" }\n ], {\n // Why waste performance on an animation no one can see?\n duration: this.totalDuration,\n easing: \"linear\"\n });\n\n this.minDelay = Math.min(...delays);\n this.setSpeed(speed);\n if (autoplay) this.play();\n else this.pause();\n\n this.promise = this.newPromise();\n this.mainAnimation.onfinish = () => {\n this.emit(\"complete\", this);\n this.stopLoop();\n };\n } catch (err) {\n this.emit(\"error\", err);\n }\n }\n public add(options: AnimationOptions) {\n return this;\n }\n}\n\nexport default animate;", "import { animate } from \"@okikio/native\";\n\n/* Target Section */\n// CSS Selector Demo\n(() => {\n let containerSel = \".css-selector-demo\";\n let anim = animate({\n target: `${containerSel} .el`,\n transform: [\"translateX(0px)\", \"translateX(250px)\"],\n onfinish(element) {\n element.style.transform = \"translateX(250px)\";\n },\n duration: 500,\n autoplay: false\n });\n\n let container = document.querySelector(containerSel);\n container.addEventListener(\"click\", () => {\n anim.reset();\n anim.play();\n });\n})();\n\n// DOM Node / Nodelist Demo\n(() => {\n let containerSel = \".dom-node-demo\";\n let DOMNodes = document.querySelectorAll(`${containerSel} .el`);\n let anim = animate({\n target: DOMNodes,\n transform: [\"translateX(0px)\", \"translateX(250px)\"],\n onfinish(element) {\n element.style.transform = \"translateX(250px)\";\n },\n duration: 500,\n autoplay: false\n });\n\n let container = document.querySelector(containerSel);\n container.addEventListener(\"click\", () => {\n anim.reset();\n anim.play();\n });\n})();\n\n\n// Array Demo\n(() => {\n let containerSel = \".array-demo\";\n let el = (num: number) => `${containerSel} .el-0${num}`;\n let anim = animate({\n target: [`${containerSel} .el-01`, el(2), el(3),\n // These two elements don't exist, so, @okikio/animate ignores theme\n el(4), el(5)],\n transform: [\"translateX(0px)\", \"translateX(250px)\"],\n onfinish(element) {\n element.style.transform = \"translateX(250px)\";\n },\n autoplay: false\n });\n\n let container = document.querySelector(containerSel);\n container.addEventListener(\"click\", () => {\n anim.reset();\n anim.play();\n });\n})();\n\n\n\n/* Properties Section */\n// CSS Properties Demo\n(() => {\n let containerSel = \".css-properties-demo\";\n let anim = animate({\n target: `${containerSel} .el`,\n backgroundColor: [\"#616aff\", \"#fff\"],\n left: [\"0px\", \"240px\"],\n borderRadius: ['0%', '50%'],\n onfinish(element) {\n let { style } = element;\n style.backgroundColor = \"#fff\";\n style.left = \"240px\";\n style.borderRadius = '50%';\n },\n easing: \"in-out-quad\",\n autoplay: false\n });\n\n let container = document.querySelector(containerSel);\n container.addEventListener(\"click\", () => {\n anim.reset();\n anim.play();\n });\n})();\n\n// CSS Transforms Demo\n(() => {\n let containerSel = \".css-transform-demo\";\n let anim = animate({\n target: `${containerSel} .el`,\n transform: [`translateX(0) scale(1) rotate(0)`, `translateX(250px) scale(2) rotate(1turn)`],\n onfinish(element) {\n element.style.transform = `translateX(250px) scale(2) rotate(1turn)`;\n },\n easing: \"in-out-quad\",\n autoplay: false\n });\n\n let container = document.querySelector(containerSel);\n container.addEventListener(\"click\", () => {\n anim.reset();\n anim.play();\n });\n})();\n\n\n// SVG Attributes Demo\n(() => {\n let containerSel = \".svg-attributes-demo\";\n var pathEl = document.querySelector(`${containerSel} path`);\n\n let anim = animate({\n target: pathEl,\n strokeDashoffset: [4000, 0],\n loop: true,\n direction: \"alternate\",\n easing: \"in-out-expo\",\n autoplay: false\n });\n\n let container = document.querySelector(containerSel);\n container.addEventListener(\"click\", () => {\n // anim.reset(); // You can't reset an infinitely looped animation\n if (anim.getPlayState() === \"running\") anim.pause();\n else anim.play();\n });\n\n anim.on(\"update\", () => {\n console.log(\"Go\")\n });\n})();\n"], + "mappings": "2fACO,WAAoB,CAG1B,YAAY,EAAuB,CAClC,KAAK,IAAM,GAAI,KAAI,GAIb,QAAoB,CAC1B,MAAO,MAAK,IAIN,IAAI,EAAW,CACrB,MAAO,MAAK,IAAI,IAAI,GAId,MAAiB,CACvB,MAAO,OAAM,KAAK,KAAK,IAAI,QAIrB,QAAmB,CACzB,MAAO,OAAM,KAAK,KAAK,IAAI,UAIrB,IAAI,EAAQ,EAAyB,CAC3C,YAAK,IAAI,IAAI,EAAK,GACX,KAID,IAAI,EAAyB,CAGnC,GAAI,GAFO,KAAK,KAGhB,YAAK,IAAI,EAAK,GACP,QAIG,OAAe,CACzB,MAAO,MAAK,IAAI,QAIN,SAAiB,CAC3B,MAAO,MAAK,IAAI,KAIV,KAAK,EAAmB,EAAkB,CAChD,GAAI,GAAM,KAAK,OAAO,KAAK,KAAO,GAClC,MAAO,MAAK,IAAI,GAIV,OAAO,EAAiB,CAC9B,MAAO,MAAK,IAAI,OAAO,GAIjB,OAAO,EAAuB,CACpC,YAAK,IAAI,OAAO,G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,GAAG,QACX,gBAAiB,CAAC,UAAW,QAC7B,KAAM,CAAC,MAAO,SACd,aAAc,CAAC,KAAM,OACrB,SAAS,EAAS,CACd,GAAI,CAAE,SAAU,EAChB,EAAM,gBAAkB,OACxB,EAAM,KAAO,QACb,EAAM,aAAe,OAEzB,OAAQ,cACR,SAAU,KAId,AADgB,SAAS,cAAc,GAC7B,iBAAiB,QAAS,IAAM,CACtC,EAAK,QACL,EAAK,aAKb,AAAC,KAAM,CACH,GAAI,GAAe,sBACf,EAAO,EAAQ,CACf,OAAQ,GAAG,QACX,UAAW,CAAC,mCAAoC,4CAChD,SAAS,EAAS,CACd,EAAQ,MAAM,UAAY,4CAE9B,OAAQ,cACR,SAAU,KAId,AADgB,SAAS,cAAc,GAC7B,iBAAiB,QAAS,IAAM,CACtC,EAAK,QACL,EAAK,aAMb,AAAC,KAAM,CACH,GAAI,GAAe,uBACnB,GAAI,GAAS,SAAS,cAAc,GAAG,UAEvC,GAAI,GAAO,EAAQ,CACf,OAAQ,EACR,iBAAkB,CAAC,IAAM,GACzB,KAAM,GACN,UAAW,YACX,OAAQ,cACR,SAAU,KAId,AADgB,SAAS,cAAc,GAC7B,iBAAiB,QAAS,IAAM,CAEtC,AAAI,EAAK,iBAAmB,UAAW,EAAK,QACvC,EAAK,SAGd,EAAK,GAAG,SAAU,IAAM,CACpB,QAAQ,IAAI", + "names": [] +} diff --git a/demo/js/main.js b/demo/js/main.js index e39cc78..a9815e7 100644 --- a/demo/js/main.js +++ b/demo/js/main.js @@ -1,2 +1,3 @@ -var vt=Object.defineProperty;var it=Object.prototype.hasOwnProperty;var C=Object.getOwnPropertySymbols,rt=Object.prototype.propertyIsEnumerable;var nt=(r,t,e)=>t in r?vt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,c=(r,t)=>{for(var e in t||(t={}))it.call(t,e)&&nt(r,e,t[e]);if(C)for(var e of C(t))rt.call(t,e)&&nt(r,e,t[e]);return r};var U=(r,t)=>{var e={};for(var i in r)it.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&C)for(var i of C(r))t.indexOf(i)<0&&rt.call(r,i)&&(e[i]=r[i]);return e};var xt={wrapperAttr:"wrapper",noAjaxLinkAttr:"no-ajax-link",noPrefetchAttr:"no-prefetch",headers:[["x-partial","true"]],preventSelfAttr:'prevent="self"',preventAllAttr:'prevent="all"',transitionAttr:"transition",blockAttr:"block",timeout:3e4},st=r=>Object.assign(c({},xt),r),St=(r,t,e=!0)=>{let{prefix:i}=r,n=`data${i?"-"+i:""}-${t}`;return e?`[${n}]`:n},h=(r,t,e=!0)=>{if(typeof t!="string")return r;let i=r[t];return typeof i=="string"?St(r,i,e):i};var d=class{constructor(t){this.map=new Map(t)}getMap(){return this.map}get(t){return this.map.get(t)}keys(){return Array.from(this.map.keys())}values(){return Array.from(this.map.values())}set(t,e){return this.map.set(t,e),this}add(t){let i=this.size;return this.set(i,t),this}get size(){return this.map.size}get length(){return this.map.size}last(t=1){let e=this.keys()[this.size-t];return this.get(e)}delete(t){return this.map.delete(t)}remove(t){return this.map.delete(t),this}clear(){return this.map.clear(),this}has(t){return this.map.has(t)}entries(){return this.map.entries()}forEach(t,e){return this.map.forEach(t,e),this}[Symbol.iterator](){return this.entries()}},v=(r,t,...e)=>{r.forEach(i=>{i[t](...e)})};var L=class{constructor(){}install(){}register(t,e){return this.manager=t,this.app=t.app,this.config=t.config,this.emitter=t.emitter,this.key=e,this.install(),this}uninstall(){}unregister(){this.uninstall(),this.manager.remove(this.key),this.key=void 0,this.manager=void 0,this.app=void 0,this.config=void 0,this.emitter=void 0}},P=class extends d{constructor(t){super();this.app=t,this.config=t.config,this.emitter=t.emitter}set(t,e){return super.set(t,e),e.register(this,t),this}};var u=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),E=r=>`${r.pathname}${r.hash}`;var at=r=>r.toString().replace(/(\/#.*|\/|#.*)$/,""),O=(r,t)=>{let e=u(r),i=u(t);return at(e)===at(i)};var b=class extends L{init(){}boot(){this.initEvents()}initEvents(){}stopEvents(){}stop(){this.stopEvents(),this.unregister()}},q=class extends P{constructor(t){super(t)}init(){return v(this,"init"),this}boot(){return v(this,"boot"),this}stop(){return v(this,"stop"),this}};var w=(r=window.scrollX,t=window.scrollY)=>({x:r,y:t}),N=(r={url:E(u()),index:0,transition:"default",data:{scroll:w(),trigger:"HistoryManager"}})=>r,V=class extends b{constructor(){super(...arguments);this.pointer=-1}init(){this.states=[];let t=N();this.add(t,"replace")}get(t){return this.states[t]}add(t,e="push"){let i=N(t),n=this.length;this.states.push(c({},i)),this.pointer=n;let s={index:this.pointer,states:[...this.states]};return Lt(e,i,s),this}remove(t){return t?this.states.splice(t,1):this.states.pop(),this.pointer--,this}replace(t){return this.states=t,this}set(t,e){return this.states[t]=e}get current(){return this.get(this.pointer)}get last(){return this.get(this.length-1)}get previous(){return this.pointer<1?null:this.get(this.pointer-1)}get length(){return this.states.length}},Lt=(r,t,e)=>{let i=E(u(t.url)),n=[e,"",i];if(window.history)switch(r){case"push":window.history.pushState.apply(window.history,n);break;case"replace":window.history.replaceState.apply(window.history,n);break}};var Pt=new DOMParser,j=class extends L{constructor(t=u(),e=document){super();this.url=t,typeof e=="string"?this.data=e:this.dom=e||document}build(){if(this.dom instanceof Node||(this.dom=Pt.parseFromString(this.data,"text/html")),!(this.body instanceof Node)){let{title:t,head:e,body:i}=this.dom;this.title=t,this.head=e,this.body=i,this.wrapper=this.body.querySelector(this.wrapperAttr)}}install(){this.wrapperAttr=h(this.config,"wrapperAttr")}uninstall(){this.url=void 0,this.title=void 0,this.head=void 0,this.body=void 0,this.dom=void 0,this.wrapper=void 0,this.data=void 0,this.wrapperAttr=void 0}},G=class extends b{constructor(){super(...arguments);this.loading=new d}install(){var e;this.pages=new P(this.app),this.maxPages=(e=this.config.maxPages)!=null?e:5;let t=u().pathname;this.set(t,new j),t=void 0}get(t){return this.pages.get(t)}add(t){return this.pages.add(t),this}set(t,e){return this.pages.set(t,e),this}remove(t){return this.pages.remove(t),this}has(t){return this.pages.has(t)}clear(){return this.pages.clear(),this}get size(){return this.pages.size}keys(){return this.pages.keys()}async load(t=u()){let e=u(t),i=e.pathname,n,s;if(this.has(i))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?s=this.loading.get(i):(s=this.request(i),this.loading.set(i,s));let o=await s;if(this.loading.remove(i),n=new j(e,o),this.set(i,n),this.size>this.maxPages){let l=u(),a=this.keys(),p=O(l,a[0])?a[1]:a[0],g=this.get(p);g.unregister(),g=void 0,a=void 0,l=void 0,p=void 0}return n}async request(t){let e=new Headers(h(this.config,"headers")),i=window.setTimeout(()=>{throw window.clearTimeout(i),"Request Timed Out!"},h(this.config,"timeout"));try{let n=await fetch(t,{mode:"same-origin",method:"GET",headers:e,cache:"default",credentials:"same-origin"});if(window.clearTimeout(i),n.status>=200&&n.status<300)return await n.text();throw new Error(n.statusText||""+n.status)}catch(n){throw window.clearTimeout(i),n}}};var ot=({callback:r=()=>{},scope:t=null,name:e="event"})=>({callback:r,scope:t,name:e}),M=class extends d{constructor(t="event"){super();this.name=t}},R=class extends d{constructor(){super()}getEvent(t){let e=this.get(t);return e instanceof M?e:(this.set(t,new M(t)),this.get(t))}newListener(t,e,i){let n=this.getEvent(t);return n.add(ot({name:t,callback:e,scope:i})),n}on(t,e,i){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,s,o=typeof t=="object"&&!Array.isArray(t),l=o?e:i;return o||(s=e),Object.keys(t).forEach(a=>{o?(n=a,s=t[a]):n=t[a],this.newListener(n,s,l)},this),this}removeListener(t,e,i){let n=this.get(t);if(n instanceof M&&e){let s=ot({name:t,callback:e,scope:i});n.forEach((o,l)=>{if(o.callback===s.callback&&o.scope===s.scope)return n.remove(l)})}return n}off(t,e,i){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,s,o=typeof t=="object"&&!Array.isArray(t),l=o?e:i;return o||(s=e),Object.keys(t).forEach(a=>{o?(n=a,s=t[a]):n=t[a],typeof s=="function"?this.removeListener(n,s,l):this.remove(n)},this),this}emit(t,...e){return typeof t=="undefined"?this:(typeof t=="string"&&(t=t.trim().split(/\s/g)),t.forEach(i=>{let n=this.get(i);n instanceof M&&n.forEach(s=>{let{callback:o,scope:l}=s;o.apply(l,e)})},this),this)}clear(){return v(this,"clear"),super.clear(),this}};var B=(r,t=window.location.hash)=>{try{let e=t[0]=="#"?t:u(t).hash;if(e.length>1){let i=document.getElementById(e.slice(1));if(i)return w(i.offsetLeft,i.offsetTop)}}catch(e){console.warn("[hashAction] error",e)}return r!=null?r:w(0,0)},Mt={name:"default",scrollable:!0,out({done:r}){r()},in({scroll:r,done:t}){window.scroll(r.x,r.y),t()}},X=class extends b{constructor(t){super();this._arg=t}install(){var e;super.install();let t=this._arg&&this._arg.length?this._arg:(e=h(this.config,"transitions"))!=null?e:[];t=[["default",Mt]].concat(t),this.transitions=new d(t)}get(t){return this.transitions.get(t)}set(t,e){return this.transitions.set(t,e),this}add(t){return this.transitions.add(t),this}has(t){return this.transitions.has(t)}async animate(t,e){let i=this.transitions.get(t),n=e.scroll,s=e.ignoreHashAction;if(!("wrapper"in e.oldPage)||!("wrapper"in e.newPage))throw`[Page] either oldPage or newPage aren't instances of the Page Class. - ${{newPage:e.newPage,oldPage:e.oldPage}}`;document.title=""+e.newPage.title;let o=e.oldPage.wrapper,l=e.newPage.wrapper;if(!(o instanceof Node)||!(l instanceof Node))throw`[Wrapper] the wrapper from the ${l instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${h(this.config,"wrapperAttr")}.`;return i.init&&(i==null||i.init(e)),this.emitter.emit("BEFORE_TRANSITION_OUT"),i.out&&await new Promise(a=>{let p=i.out.call(i,c(c({},e),{from:e.oldPage,trigger:e.trigger,done:a}));p==null||p.then(a)}),this.emitter.emit("AFTER_TRANSITION_OUT"),await new Promise(a=>{o.insertAdjacentElement("beforebegin",l),this.emitter.emit("CONTENT_INSERT"),!s&&!/back|popstate|forward/.test(e.trigger)&&(n=B(n)),a()}),await new Promise(a=>{o.remove(),o=void 0,l=void 0,this.emitter.emit("CONTENT_REPLACED"),a()}),this.emitter.emit("BEFORE_TRANSITION_IN"),i.in&&await new Promise(async a=>{let p=i.in.call(i,c(c({},e),{from:e.oldPage,to:e.newPage,trigger:e.trigger,scroll:n,done:a}));p==null||p.then(a)}),this.emitter.emit("AFTER_TRANSITION_IN"),i}};var $=class{constructor(t={}){this.register(t)}register(t={}){this.config=st(t),this.emitter=new R,this.services=new q(this);let e=(()=>{document.removeEventListener("DOMContentLoaded",e),window.removeEventListener("load",e),this.emitter.emit("READY ready")}).bind(this);return document.addEventListener("DOMContentLoaded",e),window.addEventListener("load",e),this}get(t){return this.services.get(t)}set(t,e){return this.services.set(t,e),this}add(t){return this.services.add(t),this}boot(){return this.services.init(),this.services.boot(),this}stop(){return this.services.stop(),this.emitter.clear(),this}on(t,e){return this.emitter.on(t,e,this),this}off(t,e){return this.emitter.off(t,e,this),this}emit(t,...e){return this.emitter.emit(t,...e),this}};var Y=class extends b{install(){var t,e,i,n,s,o;super.install(),this.ignoreURLs=(t=h(this.config,"ignoreURLs"))!=null?t:[],this.prefetchIgnore=(e=h(this.config,"prefetchIgnore"))!=null?e:!1,this.stopOnTransitioning=(i=h(this.config,"stopOnTransitioning"))!=null?i:!1,this.stickyScroll=(n=h(this.config,"stickyScroll"))!=null?n:!1,this.forceOnError=(s=h(this.config,"forceOnError"))!=null?s:!1,this.ignoreHashAction=(o=h(this.config,"ignoreHashAction"))!=null?o:!1}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){this.onHover=this.onHover.bind(this),this.onClick=this.onClick.bind(this),this.onStateChange=this.onStateChange.bind(this)}boot(){"scrollRestoration"in window.history&&(window.history.scrollRestoration="manual"),super.boot()}getTransitionName(t){if(!t||!t.getAttribute)return null;let e=t.getAttribute(h(this.config,"transitionAttr",!1));return typeof e=="string"?e:null}validLink(t,e,i){let n=!window.history.pushState,s=!t||!i,o=e.metaKey||e.ctrlKey||e.shiftKey||e.altKey,l=t.hasAttribute("target")&&t.target==="_blank",a=t.protocol!==location.protocol||t.hostname!==location.hostname,p=typeof t.getAttribute("download")=="string",g=t.matches(h(this.config,"preventSelfAttr")),A=Boolean(t.closest(h(this.config,"preventAllAttr"))),f=E(u())===E(u(i));return!(s||n||o||l||a||p||g||A||f)}getHref(t){return t&&t.tagName&&t.tagName.toLowerCase()==="a"&&typeof t.href=="string"?t.href:null}getLink(t){let e=t.target,i=this.getHref(e);for(;e&&!i;)e=e.parentNode,i=this.getHref(e);if(!(!e||!this.validLink(e,t,i)))return e}onClick(t){let e=this.getLink(t);if(!e)return;if(this.isTransitioning&&this.stopOnTransitioning){t.preventDefault(),t.stopPropagation();return}let i=this.getHref(e);this.emitter.emit("ANCHOR_CLICK CLICK",t),this.go({href:i,trigger:e,event:t})}getDirection(t){return Math.abs(t)>1?t>0?"forward":"back":t===0?"popstate":t>0?"back":"forward"}force(t){window.location.assign(t)}go({href:t,trigger:e="HistoryManager",event:i}){if(this.isTransitioning&&this.stopOnTransitioning||!(this.manager.has("TransitionManager")&&this.manager.has("HistoryManager")&&this.manager.has("PageManager"))){this.force(t);return}let n=this.manager.get("HistoryManager"),s=w(0,0),o=n.current,l=o.url;if(O(l,t))return;let a;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:p}=i,{index:g}=p,f=o.index-g,k=n.get(n.pointer);a=k.transition,s=k.data.scroll,n.replace(p.states),n.pointer=g,e=this.getDirection(f),this.emitter.emit(e==="back"?"POPSTATE_BACK":"POPSTATE_FORWARD",i)}else{a=this.getTransitionName(e),s=w();let p=N({url:t,transition:a,data:{scroll:s}});!this.stickyScroll&&(s=w(0,0)),n.add(p),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:l,href:t,trigger:e,transitionName:a,scroll:s})}async load({oldHref:t,href:e,trigger:i,transitionName:n="default",scroll:s={x:0,y:0}}){try{let o=this.manager.get("PageManager"),l,a;this.emitter.emit("NAVIGATION_START",{oldHref:t,href:e,trigger:i,transitionName:n});try{this.transitionStart(),a=await o.load(t),!(a.dom instanceof Element)&&a.build(),this.emitter.emit("PAGE_LOADING",{href:e,oldPage:a,trigger:i}),l=await o.load(e),await l.build(),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:l,oldPage:a,trigger:i})}catch(p){throw`[PJAX] page load error: ${p}`}try{let p=this.manager.get("TransitionManager");this.emitter.emit("TRANSITION_START",n);let g=await p.animate(p.has(n)?n:"default",{oldPage:a,newPage:l,trigger:i,scroll:s,ignoreHashAction:this.ignoreHashAction});g.scrollable||(!this.ignoreHashAction&&!/back|popstate|forward/.test(i)&&(s=B(s)),window.scroll(s.x,s.y)),this.emitter.emit("TRANSITION_END",{transition:g})}catch(p){throw`[PJAX] transition error: ${p}`}this.emitter.emit("NAVIGATION_END",{oldPage:a,newPage:l,trigger:i,transitionName:n})}catch(o){this.forceOnError?this.force(e):console.warn(o)}finally{this.transitionStop()}}ignoredURL({pathname:t}){return this.ignoreURLs.length&&this.ignoreURLs.some(e=>typeof e=="string"?e===t:e.exec(t)!==null)}onHover(t){let e=this.getLink(t);if(!e||!this.manager.has("PageManager"))return;let i=this.manager.get("PageManager"),n=u(this.getHref(e)),s=n.pathname;if(!(this.ignoredURL(n)||i.has(s))){this.emitter.emit("ANCHOR_HOVER HOVER",t);try{i.load(n)}catch(o){console.warn("[PJAX] prefetch error,",o)}}}onStateChange(t){this.go({href:window.location.href,trigger:"popstate",event:t})}initEvents(){this.prefetchIgnore!==!0&&(document.addEventListener("mouseover",this.onHover),document.addEventListener("touchstart",this.onHover)),document.addEventListener("click",this.onClick),window.addEventListener("popstate",this.onStateChange)}stopEvents(){this.prefetchIgnore!==!0&&(document.removeEventListener("mouseover",this.onHover),document.removeEventListener("touchstart",this.onHover)),document.removeEventListener("click",this.onClick),window.removeEventListener("popstate",this.onStateChange)}};var W=class extends b{constructor(t=[]){super();this.routes=new d;for(let e of t)this.add(e)}add({path:t,method:e}){let i=this.parse(t);return this.routes.set(i,e),this}parsePath(t){if(typeof t=="string")return new RegExp(t,"i");if(t instanceof RegExp||typeof t=="boolean")return t;throw"[Router] only regular expressions, strings and booleans are accepted as paths."}isPath(t){return typeof t=="string"||t instanceof RegExp||typeof t=="boolean"}parse(t){let e=t,i={from:/(.*)/g,to:/(.*)/g};if(this.isPath(t))i={from:!0,to:t};else if(this.isPath(e.from)&&this.isPath(e.to))i=e;else throw"[Router] path is neither a string, regular expression, or a { from, to } object.";let{from:n,to:s}=i;return{from:this.parsePath(n),to:this.parsePath(s)}}route(){if(this.manager.has("HistoryManager")){let t=this.manager.get("HistoryManager"),e=E(u((t.length>1?t.previous:t.current).url)),i=E(u());this.routes.forEach((n,s)=>{let o=s.from,l=s.to;if(typeof o=="boolean"&&typeof l=="boolean")throw`[Router] path ({ from: ${o}, to: ${l} }) is not valid, remember paths can only be strings, regular expressions, or a boolean; however, both the from and to paths cannot be both booleans.`;let a=o,p=l;o instanceof RegExp&&o.test(e)&&(a=o.exec(e)),l instanceof RegExp&&l.test(i)&&(p=l.exec(i)),(Array.isArray(p)&&Array.isArray(a)||Array.isArray(p)&&typeof a=="boolean"&&a||Array.isArray(a)&&typeof p=="boolean"&&p)&&n({from:a,to:p,path:{from:e,to:i}})})}else console.warn("[Route] HistoryManager is missing.")}initEvents(){this.emitter.on("READY",this.route,this),this.emitter.on("CONTENT_REPLACED",this.route,this)}stopEvents(){this.emitter.off("READY",this.route,this),this.emitter.off("CONTENT_REPLACED",this.route,this)}};var Rt=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],kt=r=>[].concat(...r),lt=r=>Array.isArray(r)?kt(r.map(lt)):typeof r=="string"||r instanceof Node?Rt(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],pt=(r,t,e)=>typeof r=="function"?r.apply(e,t):r,ct=(r,t,e)=>{let i,n,s={},o=Object.keys(r);for(let l=0,a=o.length;l/^(in|out)/.test(r)?Ht[r]:r,ut={keyframes:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",autoplay:!0,duration:1e3,fillMode:"auto",direction:"normal",extend:{}},D=class{constructor(t={}){this.options={};this.targets=[];this.properties={};this.animations=new d;this.totalDuration=0;this.minDelay=0;this.computedOptions=new d;this.emitter=new R;var i;try{let e=t,{options:s}=e,o=U(e,["options"]),l=s instanceof D?s.getOptions():Array.isArray(s)?(i=s==null?void 0:s[0])==null?void 0:i.getOptions():s;this.options=Object.assign({},ut,l,o),this.loop=this.loop.bind(this);let n=this.options,{loop:a,delay:p,speed:g,easing:A,endDelay:f,duration:k,direction:bt,fillMode:yt,onfinish:Z,target:Et,keyframes:At,autoplay:It,extend:wt}=n,Tt=U(n,["loop","delay","speed","easing","endDelay","duration","direction","fillMode","onfinish","target","keyframes","autoplay","extend"]);this.mainElement=document.createElement("div"),this.targets=lt(Et),this.properties=Tt;let tt=[],x=this.targets.length,H;for(let I=0;I0||(H=ct(H,[I,x,T],this));let et=y.delay+y.duration*y.iterations+y.endDelay;this.totalDuration{typeof Z=="function"&&Z.call(this,T,I,x,S),this.emit("finish",T,I,x,S)},this.computedOptions.set(S,y),this.animations.set(T,S),tt.push(y.delay)}this.mainAnimation=this.mainElement.animate([{opacity:"0"},{opacity:"1"}],{duration:this.totalDuration,easing:"linear"}),this.minDelay=Math.min(...tt),this.setSpeed(g),It?this.play():this.pause(),this.promise=this.newPromise(),this.mainAnimation.onfinish=()=>{this.emit("complete",this),this.stopLoop()}}catch(s){this.emit("error",s)}}newPromise(){return new Promise((t,e)=>{this.on("complete",()=>t([this])),this.on("error",i=>e(i))})}then(t,e){return t=t==null?void 0:t.bind(this),e=e==null?void 0:e.bind(this),this.promise.then(t,e),this}catch(t){return t=t==null?void 0:t.bind(this),this.promise.catch(t),this}finally(t){return t=t==null?void 0:t.bind(this),this.promise.finally(t),this}loop(){this.stopLoop(),this.emit("update",this.getProgress(),this),this.animationFrame=window.requestAnimationFrame(this.loop)}stopLoop(){window.cancelAnimationFrame(this.animationFrame)}all(t){return t(this.mainAnimation),this.animations.forEach(e=>t(e)),this}beginEvent(){if(this.getProgress()==0){let t=window.setTimeout(()=>{this.emit("begin",this),t=window.clearTimeout(t)},this.minDelay)}}play(){let t=this.getPlayState();return this.beginEvent(),this.all(e=>e.play()),this.emit("play",t,this),this.loop(),this}pause(){let t=this.getPlayState();return this.all(e=>e.pause()),this.emit("pause",t,this),this.stopLoop(),this.animationFrame=void 0,this}reset(){return this.setProgress(0),this.beginEvent(),this.options.autoplay?this.play():this.pause(),this}cancel(){return this.all(t=>t.cancel()),this.stopLoop(),this}finish(){return this.all(t=>t.finish()),this.stopLoop(),this}stop(){for(this.cancel(),this.animations.clear();this.targets.length;)this.targets.pop();this.mainElement=void 0,this.emit("stop")}getTargets(){return this.targets}getAnimation(t){return this.animations.get(t)}getTiming(t){var o,l,a;let e=t instanceof Animation?t:this.getAnimation(t),i=(o=this.computedOptions.get(e))!=null?o:{},n=(a=(l=e.effect)==null?void 0:l.getTiming())!=null?a:{},s=this.getOptions();return c(c(c(c({},ut),s),n),i)}getTotalDuration(){return this.totalDuration}getCurrentTime(){return this.mainAnimation.currentTime}getProgress(){return this.getCurrentTime()/this.totalDuration*100}getSpeed(){return this.mainAnimation.playbackRate}getPlayState(){return this.mainAnimation.playState}getOptions(){return this.options}setCurrentTime(t){return this.all(e=>{e.currentTime=t}),this.emit("update",this.getProgress()),this}setProgress(t){let e=t/100*this.totalDuration;return this.setCurrentTime(e),this}setSpeed(t=1){return this.all(e=>{e.playbackRate=t}),this}on(t,e,i){return this.emitter.on(t,e,i!=null?i:this),this}off(t,e,i){return this.emitter.off(t,e,i!=null?i:this),this}emit(t,...e){return this.emitter.emit(t,...e),this}toJSON(){return this.getOptions()}get[Symbol.toStringTag](){return"Animate"}},m=(r={})=>new D(r);var J=class extends b{constructor(){super(...arguments);this.minimalDuration=1e3}init(){super.init(),this.rootElement=document.getElementById("splashscreen"),this.rootElement&&(this.innerEl=this.rootElement.querySelector(".splashscreen-inner"),this.bgEl=this.rootElement.querySelector(".splashscreen-bg"),this.spinnerEl=[...this.rootElement.querySelectorAll(".spinner")]),this.rootElement.style.visibility="visible",this.rootElement.style.pointerEvents="auto"}boot(){this.rootElement&&this.hide()}async hide(){await new Promise(t=>{window.setTimeout(()=>{this.emitter.emit("BEFORE_SPLASHSCREEN_HIDE"),t()},this.minimalDuration)}),await new Promise(async t=>{m({target:this.innerEl,opacity:[1,0],autoplay:!0,duration:500,onfinish(e){e.style.opacity="0"}}).then(function(){this.stop()}),this.emitter.emit("START_SPLASHSCREEN_HIDE"),await this.show(),t()})}async show(){let[t]=await m({target:this.rootElement,transform:["translateY(0%)","translateY(100%)"],duration:1200,easing:"in-out-cubic"});this.emitter.emit("AFTER_SPLASHSCREEN_HIDE"),t.stop(),this.rootElement.style.transform="translateY(100%)",this.rootElement.style.visibility="hidden",this.rootElement.style.pointerEvents="none"}};var Q=class extends b{init(){super.init(),this.elements=[...document.querySelectorAll(".intro-animation")]}newPage(){this.init(),this.prepareToShow()}initEvents(){this.emitter.on("BEFORE_SPLASHSCREEN_HIDE",this.prepareToShow,this),this.emitter.on("CONTENT_REPLACED",this.newPage,this),this.emitter.on("START_SPLASHSCREEN_HIDE BEFORE_TRANSITION_IN",this.show,this)}stopEvents(){this.emitter.off("BEFORE_SPLASHSCREEN_HIDE",this.prepareToShow,this),this.emitter.off("CONTENT_REPLACED",this.newPage,this),this.emitter.off("START_SPLASHSCREEN_HIDE BEFORE_TRANSITION_IN",this.show,this)}stop(){requestAnimationFrame(()=>{for(let t of this.elements)t.style.transform="translateY(0px)",t.style.opacity="1"}),super.stop()}prepareToShow(){requestAnimationFrame(()=>{for(let t of this.elements)t.style.transform="translateY(200px)",t.style.opacity="0"})}async show(){let[t]=await m({target:this.elements,keyframes:[{transform:"translateY(200px)",opacity:0},{transform:"translateY(0px)",opacity:1}],delay(e){return 300*(e+1)},onfinish(e){requestAnimationFrame(()=>{e.style.transform="translateY(0px)",e.style.opacity="1"})},easing:"out-cubic",duration:650});return t.stop(),t}};var mt={name:"default",duration:500,scrollable:!0,out({from:r}){let{duration:t}=this,e=r.wrapper;return m({target:e,opacity:[1,0],duration:t}).on("finish",function(){this.stop()})},in({to:r,scroll:t}){let{duration:e}=this,i=r.wrapper;return window.scroll(t.x,t.y),m({target:i,opacity:[0,1],duration:e}).then(function(){this.stop()})}};var ht={name:"big",delay:200,durationPerAnimation:700,scrollable:!0,init(){this.mainElement=document.getElementById("big-transition"),this.spinnerElement=this.mainElement.querySelector(".spinner"),this.horizontalElements=[...this.mainElement.querySelector("#big-transition-horizontal").querySelectorAll("div")],this.maxLength=this.horizontalElements.length},out({from:r,scroll:t}){let{durationPerAnimation:e,delay:i}=this,n=r.wrapper;window.scroll(t.x,t.y);let s=Object.assign({},n.style);return new Promise(async o=>{this.mainElement.style.opacity="1",this.mainElement.style.visibility="visible",m({target:n,opacity:[1,0],duration:e,onfinish(f){f.style.opacity="0"}}).then(function(){this.stop()});let[a]=await m({target:this.horizontalElements,keyframes:[{transform:"scaleX(0)"},{transform:"scaleX(1)"}],delay(f){return i*(f+1)},onfinish(f){f.style.transform="scaleX(1)"},easing:"out-cubic",duration:500});n.style.opacity="1",Object.assign(n.style,s),this.spinnerElement.style.visibility="visible";let p=500,[g]=await m({target:this.spinnerElement,opacity:[0,1],duration:p,onfinish(f){f.style.opacity="1"}}),[A]=await m({options:g,opacity:[1,0],onfinish(f){f.style.opacity="0"},delay:1500});this.spinnerElement.style.visibility="hidden",g.stop(),A.stop(),o()})},in({to:r,scroll:t}){let{durationPerAnimation:e,delay:i}=this,n=r.wrapper;return window.scroll(t.x,t.y),new Promise(async s=>{let o=m({target:n,opacity:[0,1],duration:e}).then(()=>{o.stop()}),[l]=await m({target:this.horizontalElements,keyframes:[{transform:"scaleX(1)"},{transform:"scaleX(0)"}],delay(a){return i*(a+1)},onfinish(a){a.style.transform="scaleX(0)"},easing:"out-cubic",duration:500});this.mainElement.style.opacity="0",this.mainElement.style.visibility="hidden",l.stop(),s()})}};var _={name:"slide",duration:500,direction:"right",scrollable:!0,init(r){let t=r.trigger;t instanceof Node&&t.hasAttribute("data-direction")?this.direction=t.getAttribute("data-direction"):this.direction="right"},out({from:r}){let{duration:t,direction:e}=this,i=r.wrapper;return m({target:i,keyframes:[{transform:"translateX(0%)",opacity:1},{transform:`translateX(${e==="left"?"-":""}25%)`,opacity:0}],duration:t,easing:"in-quint"}).then(function(){this.stop()})},in({to:r,scroll:t}){let{duration:e}=this,i=r.wrapper;return window.scroll(t.x,t.y),m({target:i,keyframes:[{transform:`translateX(${this.direction==="right"?"-":""}25%)`,opacity:0},{transform:"translateX(0%)",opacity:1}],duration:e,easing:"out-quint"}).then(function(){this.stop()})}},gt=c(c({},_),{name:"slide-left",direction:"left"}),ft=c(c({},_),{name:"slide-right",direction:"right"});var dt,K,Ot,z=new $;z.add(new Q).add(dt=new J).set("HistoryManager",new V).set("PageManager",new G).set("TransitionManager",new X([["default",mt],["BigTransition",ht],["Slide",_],["SlideLeft",gt],["SlideRight",ft]])).set("router",K=new W).add(Ot=new Y);try{K=z.get("router");let r=document.querySelectorAll(".navbar .nav-link");for(let e of r){let i=e;K.add({path:i.getAttribute("data-path")||i.pathname,method(){i.classList.contains("active")||i.classList.add("active");for(let s of r)s!==i&&s.classList.remove("active")}})}let t;K.add({path:/(index|\/$)(\.html)?/,method(){t=m({target:".div",keyframes(a,p){return[{transform:"translateX(0px)",opacity:.1},{transform:"translateX(300px)",opacity:.2+(a+1)/p}]},fillMode:"both",easing:"out-cubic",duration(a){return(a+1)*500},loop:5,speed:1.5,direction:"alternate",delay(a){return(a+1)*500/2},autoplay:!1});let e=document.querySelector(".info"),i=e.textContent,n=i;t.on({begin(){e&&(n=i,e.textContent=n,e.style.color="initial")}}),t.on("complete",()=>{e&&(n="Done.",e.textContent=n,e.style.color="red",console.log(n))});let s=document.getElementById("scrub");s.addEventListener("input",a=>{var p=+a.target.value;t.setProgress(p),t.pause()});let o=document.querySelector(".progress");t.on("update",a=>{s.value=""+a,o&&(o.textContent=`${Math.round(a)}%`)}),s.addEventListener("change",()=>{if(Math.round(t.getProgress())>=100)return t.finish(),!1;t.play()});let l=document.querySelector(".playtoggle");l&&l.addEventListener("click",()=>{let a=t.getPlayState();a==="running"?t.pause():a==="finished"?t.reset():t.play(),console.log(a)})}}),z.on("AFTER_SPLASHSCREEN_HIDE",()=>{t==null||t.play()}),z.boot()}catch(r){dt.show(),console.warn("[App] boot failed,",r)} +var vt=Object.defineProperty;var it=Object.prototype.hasOwnProperty;var H=Object.getOwnPropertySymbols,rt=Object.prototype.propertyIsEnumerable;var nt=(r,t,e)=>t in r?vt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,c=(r,t)=>{for(var e in t||(t={}))it.call(t,e)&&nt(r,e,t[e]);if(H)for(var e of H(t))rt.call(t,e)&&nt(r,e,t[e]);return r};var U=(r,t)=>{var e={};for(var i in r)it.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&H)for(var i of H(r))t.indexOf(i)<0&&rt.call(r,i)&&(e[i]=r[i]);return e};var xt={wrapperAttr:"wrapper",noAjaxLinkAttr:"no-ajax-link",noPrefetchAttr:"no-prefetch",headers:[["x-partial","true"]],preventSelfAttr:'prevent="self"',preventAllAttr:'prevent="all"',transitionAttr:"transition",blockAttr:"block",timeout:3e4,maxPages:5},st=r=>Object.assign(c({},xt),r),St=(r,t,e=!0)=>{let{prefix:i}=r,n=`data${i?"-"+i:""}-${t}`;return e?`[${n}]`:n},h=(r,t,e=!0)=>{if(typeof t!="string")return r;let i=r[t];return typeof i=="string"?St(r,i,e):i};var d=class{constructor(t){this.map=new Map(t)}getMap(){return this.map}get(t){return this.map.get(t)}keys(){return Array.from(this.map.keys())}values(){return Array.from(this.map.values())}set(t,e){return this.map.set(t,e),this}add(t){let i=this.size;return this.set(i,t),this}get size(){return this.map.size}get length(){return this.map.size}last(t=1){let e=this.keys()[this.size-t];return this.get(e)}delete(t){return this.map.delete(t)}remove(t){return this.map.delete(t),this}clear(){return this.map.clear(),this}has(t){return this.map.has(t)}entries(){return this.map.entries()}forEach(t,e){return this.map.forEach(t,e),this}[Symbol.iterator](){return this.entries()}},v=(r,t,...e)=>{r.forEach(i=>{i[t](...e)})};var L=class{constructor(){}install(){}register(t,e){return this.manager=t,this.app=t.app,this.config=t.config,this.emitter=t.emitter,this.key=e,this.install(),this}uninstall(){}unregister(){this.uninstall(),this.manager.remove(this.key),this.key=void 0,this.manager=void 0,this.app=void 0,this.config=void 0,this.emitter=void 0}},P=class extends d{constructor(t){super();this.app=t,this.config=t.config,this.emitter=t.emitter}set(t,e){return super.set(t,e),e.register(this,t),this}};var m=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),E=r=>{let t=m(r);return`${t.pathname}${t.hash}`};var at=r=>m(r).toString().replace(/(\/#.*|\/|#.*)$/,""),C=(r,t)=>at(r)===at(t);var b=class extends L{init(){}boot(){this.initEvents()}initEvents(){}stopEvents(){}stop(){this.stopEvents(),this.unregister()}},q=class extends P{constructor(t){super(t)}init(){return v(this,"init"),this}boot(){return v(this,"boot"),this}stop(){return v(this,"stop"),this}};var w=(r=window.scrollX,t=window.scrollY)=>({x:r,y:t}),N=(r={url:E(m()),index:0,transition:"default",data:{scroll:w(),trigger:"HistoryManager"}})=>r,j=class extends b{constructor(){super(...arguments);this.pointer=-1}init(){this.states=[];let t=N();this.add(t,"replace")}get(t){return this.states[t]}add(t,e="push"){let i=N(t),n=this.length;this.states.push(c({},i)),this.pointer=n;let s={index:this.pointer,states:[...this.states]};return Lt(e,i,s),this}remove(t){return t?this.states.splice(t,1):this.states.pop(),this.pointer--,this}replace(t){return this.states=t,this}set(t,e){return this.states[t]=e}get current(){return this.get(this.pointer)}get last(){return this.get(this.length-1)}get previous(){return this.pointer<1?null:this.get(this.pointer-1)}get length(){return this.states.length}},Lt=(r,t,e)=>{let i=E(t.url),n=[e,"",i];if(window.history)switch(r){case"push":window.history.pushState.apply(window.history,n);break;case"replace":window.history.replaceState.apply(window.history,n);break}};var Pt=new DOMParser,V=class extends L{constructor(t=m(),e=document){super();this.url=t,typeof e=="string"?this.data=e:this.dom=e||document}build(){if(this.dom instanceof Node||(this.dom=Pt.parseFromString(this.data,"text/html")),!(this.body instanceof Node)){let{title:t,head:e,body:i}=this.dom;this.title=t,this.head=e,this.body=i,this.wrapper=this.body.querySelector(this.wrapperAttr)}}install(){this.wrapperAttr=h(this.config,"wrapperAttr")}uninstall(){this.url=void 0,this.title=void 0,this.head=void 0,this.body=void 0,this.dom=void 0,this.wrapper=void 0,this.data=void 0,this.wrapperAttr=void 0}},G=class extends b{constructor(){super(...arguments);this.loading=new d}install(){this.pages=new P(this.app);let t=m().pathname;this.set(t,new V),t=void 0}get(t){return this.pages.get(t)}add(t){return this.pages.add(t),this}set(t,e){return this.pages.set(t,e),this}remove(t){return this.pages.remove(t),this}has(t){return this.pages.has(t)}clear(){return this.pages.clear(),this}get size(){return this.pages.size}keys(){return this.pages.keys()}async load(t=m()){let e=m(t),i=e.pathname,n,s;if(this.has(i))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?s=this.loading.get(i):(s=this.request(i),this.loading.set(i,s));let o=await s;if(this.loading.remove(i),n=new V(e,o),this.set(i,n),this.size>h(this.config,"maxPages")){let l=m(),a=this.keys(),p=C(l,a[0])?a[1]:a[0],g=this.get(p);g.unregister(),g=void 0,a=void 0,l=void 0,p=void 0}return n}async request(t){let e=new Headers(h(this.config,"headers")),i=window.setTimeout(()=>{throw window.clearTimeout(i),"Request Timed Out!"},h(this.config,"timeout"));try{let n=await fetch(t,{mode:"same-origin",method:"GET",headers:e,cache:"default",credentials:"same-origin"});if(window.clearTimeout(i),n.status>=200&&n.status<300)return await n.text();throw new Error(n.statusText||""+n.status)}catch(n){throw window.clearTimeout(i),n}}};var ot=({callback:r=()=>{},scope:t=null,name:e="event"})=>({callback:r,scope:t,name:e}),M=class extends d{constructor(t="event"){super();this.name=t}},R=class extends d{constructor(){super()}getEvent(t){let e=this.get(t);return e instanceof M?e:(this.set(t,new M(t)),this.get(t))}newListener(t,e,i){let n=this.getEvent(t);return n.add(ot({name:t,callback:e,scope:i})),n}on(t,e,i){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,s,o=typeof t=="object"&&!Array.isArray(t),l=o?e:i;return o||(s=e),Object.keys(t).forEach(a=>{o?(n=a,s=t[a]):n=t[a],this.newListener(n,s,l)},this),this}removeListener(t,e,i){let n=this.get(t);if(n instanceof M&&e){let s=ot({name:t,callback:e,scope:i});n.forEach((o,l)=>{if(o.callback===s.callback&&o.scope===s.scope)return n.remove(l)})}return n}off(t,e,i){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,s,o=typeof t=="object"&&!Array.isArray(t),l=o?e:i;return o||(s=e),Object.keys(t).forEach(a=>{o?(n=a,s=t[a]):n=t[a],typeof s=="function"?this.removeListener(n,s,l):this.remove(n)},this),this}emit(t,...e){return typeof t=="undefined"?this:(typeof t=="string"&&(t=t.trim().split(/\s/g)),t.forEach(i=>{let n=this.get(i);n instanceof M&&n.forEach(s=>{let{callback:o,scope:l}=s;o.apply(l,e)})},this),this)}clear(){return v(this,"clear"),super.clear(),this}};var X=(r,t=window.location.hash)=>{try{let e=t[0]=="#"?t:m(t).hash;if(e.length>1){let i=document.getElementById(e.slice(1));if(i){let{left:n,top:s}=i.getBoundingClientRect(),o=window.pageXOffset,l=window.pageYOffset,a=n+o,p=s+l;return console.log(a,p),w(a,p)}}}catch(e){console.warn("[hashAction] error",e)}return r!=null?r:w(0,0)},Mt={name:"default",scrollable:!0,out({done:r}){r()},in({scroll:r,done:t}){window.scroll(r.x,r.y),t()}},B=class extends b{constructor(t){super();this._arg=t}install(){var e;super.install();let t=this._arg&&this._arg.length?this._arg:(e=h(this.config,"transitions"))!=null?e:[];t=[["default",Mt]].concat(t),this.transitions=new d(t)}get(t){return this.transitions.get(t)}set(t,e){return this.transitions.set(t,e),this}add(t){return this.transitions.add(t),this}has(t){return this.transitions.has(t)}async animate(t,e){let i=this.transitions.get(t),n=e.scroll,s=e.ignoreHashAction;if(!("wrapper"in e.oldPage)||!("wrapper"in e.newPage))throw`[Page] either oldPage or newPage aren't instances of the Page Class. + ${{newPage:e.newPage,oldPage:e.oldPage}}`;document.title=""+e.newPage.title;let o=e.oldPage.wrapper,l=e.newPage.wrapper;if(!(o instanceof Node)||!(l instanceof Node))throw`[Wrapper] the wrapper from the ${l instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${h(this.config,"wrapperAttr")}.`;return i.init&&(i==null||i.init(e)),this.emitter.emit("BEFORE_TRANSITION_OUT"),i.out&&await new Promise(a=>{let p=i.out.call(i,c(c({},e),{from:e.oldPage,trigger:e.trigger,done:a}));p==null||p.then(a)}),this.emitter.emit("AFTER_TRANSITION_OUT"),await new Promise(a=>{o.insertAdjacentElement("beforebegin",l),this.emitter.emit("CONTENT_INSERT"),!s&&!/back|popstate|forward/.test(e.trigger)&&(n=X(n)),a()}),await new Promise(a=>{o.remove(),o=void 0,l=void 0,this.emitter.emit("CONTENT_REPLACED"),a()}),this.emitter.emit("BEFORE_TRANSITION_IN"),i.in&&await new Promise(async a=>{let p=i.in.call(i,c(c({},e),{from:e.oldPage,to:e.newPage,trigger:e.trigger,scroll:n,done:a}));p==null||p.then(a)}),this.emitter.emit("AFTER_TRANSITION_IN"),i}};var $=class{constructor(t={}){this.register(t)}register(t={}){this.config=st(t),this.emitter=new R,this.services=new q(this);let e=(()=>{document.removeEventListener("DOMContentLoaded",e),window.removeEventListener("load",e),this.emitter.emit("READY ready")}).bind(this);return document.addEventListener("DOMContentLoaded",e),window.addEventListener("load",e),this}get(t){return this.services.get(t)}set(t,e){return this.services.set(t,e),this}add(t){return this.services.add(t),this}boot(){return this.services.init(),this.services.boot(),this}stop(){return this.services.stop(),this.emitter.clear(),this}on(t,e){return this.emitter.on(t,e,this),this}off(t,e){return this.emitter.off(t,e,this),this}emit(t,...e){return this.emitter.emit(t,...e),this}};var Y=class extends b{install(){var t,e,i,n,s,o;super.install(),this.ignoreURLs=(t=h(this.config,"ignoreURLs"))!=null?t:[],this.prefetchIgnore=(e=h(this.config,"prefetchIgnore"))!=null?e:!1,this.stopOnTransitioning=(i=h(this.config,"stopOnTransitioning"))!=null?i:!1,this.stickyScroll=(n=h(this.config,"stickyScroll"))!=null?n:!1,this.forceOnError=(s=h(this.config,"forceOnError"))!=null?s:!1,this.ignoreHashAction=(o=h(this.config,"ignoreHashAction"))!=null?o:!1}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){this.onHover=this.onHover.bind(this),this.onClick=this.onClick.bind(this),this.onStateChange=this.onStateChange.bind(this)}boot(){"scrollRestoration"in window.history&&(window.history.scrollRestoration="manual"),super.boot()}getTransitionName(t){if(!t||!t.getAttribute)return null;let e=t.getAttribute(h(this.config,"transitionAttr",!1));return typeof e=="string"?e:null}validLink(t,e,i){let n=!window.history.pushState,s=!t||!i,o=e.metaKey||e.ctrlKey||e.shiftKey||e.altKey,l=t.hasAttribute("target")&&t.target==="_blank",a=t.protocol!==location.protocol||t.hostname!==location.hostname,p=typeof t.getAttribute("download")=="string",g=t.matches(h(this.config,"preventSelfAttr")),A=Boolean(t.closest(h(this.config,"preventAllAttr"))),f=E(m())===E(m(i));return!(s||n||o||l||a||p||g||A||f)}getHref(t){return t&&t.tagName&&t.tagName.toLowerCase()==="a"&&typeof t.href=="string"?t.href:null}getLink(t){let e=t.target,i=this.getHref(e);for(;e&&!i;)e=e.parentNode,i=this.getHref(e);if(!(!e||!this.validLink(e,t,i)))return e}onClick(t){let e=this.getLink(t);if(!e)return;if(this.isTransitioning&&this.stopOnTransitioning){t.preventDefault(),t.stopPropagation();return}let i=this.getHref(e);this.emitter.emit("ANCHOR_CLICK CLICK",t),this.go({href:i,trigger:e,event:t})}getDirection(t){return Math.abs(t)>1?t>0?"forward":"back":t===0?"popstate":t>0?"back":"forward"}force(t){window.location.assign(t)}go({href:t,trigger:e="HistoryManager",event:i}){if(this.isTransitioning&&this.stopOnTransitioning||!(this.manager.has("TransitionManager")&&this.manager.has("HistoryManager")&&this.manager.has("PageManager"))){this.force(t);return}let n=this.manager.get("HistoryManager"),s=w(0,0),o=n.current,l=o.url;if(C(l,t))return;let a;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:p}=i,{index:g}=p,f=o.index-g;n.replace(p.states),n.pointer=g;let k=n.get(g);a=k.transition,s=k.data.scroll,e=this.getDirection(f),console.log(e=="forward"&&n),this.emitter.emit(e==="back"?"POPSTATE_BACK":"POPSTATE_FORWARD",i)}else{a=this.getTransitionName(e),s=w();let p=N({url:t,transition:a,data:{scroll:s}});!this.stickyScroll&&(s=w(0,0)),n.add(p),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:l,href:t,trigger:e,transitionName:a,scroll:s})}async load({oldHref:t,href:e,trigger:i,transitionName:n="default",scroll:s={x:0,y:0}}){try{let o=this.manager.get("PageManager"),l,a;this.emitter.emit("NAVIGATION_START",{oldHref:t,href:e,trigger:i,transitionName:n});try{this.transitionStart(),a=await o.load(t),!(a.dom instanceof Element)&&a.build(),this.emitter.emit("PAGE_LOADING",{href:e,oldPage:a,trigger:i}),l=await o.load(e),await l.build(),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:l,oldPage:a,trigger:i})}catch(p){console.warn(`[PJAX] Page load error: ${p}`)}try{let p=this.manager.get("TransitionManager");this.emitter.emit("TRANSITION_START",n);let g=await p.animate(p.has(n)?n:"default",{oldPage:a,newPage:l,trigger:i,scroll:s,ignoreHashAction:this.ignoreHashAction});g.scrollable||(!this.ignoreHashAction&&!/back|popstate|forward/.test(i)&&(s=X(s)),window.scroll(s.x,s.y)),this.emitter.emit("TRANSITION_END",{transition:g})}catch(p){console.warn(`[PJAX] Transition error: ${p}`)}this.emitter.emit("NAVIGATION_END",{oldPage:a,newPage:l,trigger:i,transitionName:n})}catch(o){this.forceOnError?this.force(e):console.warn(o)}finally{this.transitionStop()}}ignoredURL({pathname:t}){return this.ignoreURLs.length&&this.ignoreURLs.some(e=>typeof e=="string"?e===t:e.exec(t)!==null)}onHover(t){let e=this.getLink(t);if(!e||!this.manager.has("PageManager"))return;let i=this.manager.get("PageManager"),n=m(this.getHref(e)),s=n.pathname;if(!(this.ignoredURL(n)||i.has(s))){this.emitter.emit("ANCHOR_HOVER HOVER",t);try{i.load(n)}catch(o){console.warn("[PJAX] prefetch error,",o)}}}onStateChange(t){this.go({href:window.location.href,trigger:"popstate",event:t})}initEvents(){this.prefetchIgnore!==!0&&(document.addEventListener("mouseover",this.onHover),document.addEventListener("touchstart",this.onHover)),document.addEventListener("click",this.onClick),window.addEventListener("popstate",this.onStateChange)}stopEvents(){this.prefetchIgnore!==!0&&(document.removeEventListener("mouseover",this.onHover),document.removeEventListener("touchstart",this.onHover)),document.removeEventListener("click",this.onClick),window.removeEventListener("popstate",this.onStateChange)}};var W=class extends b{constructor(t=[]){super();this.routes=new d;for(let e of t)this.add(e)}add({path:t,method:e}){let i=this.parse(t);return this.routes.set(i,e),this}parsePath(t){if(typeof t=="string")return new RegExp(t,"i");if(t instanceof RegExp||typeof t=="boolean")return t;throw"[Router] only regular expressions, strings and booleans are accepted as paths."}isPath(t){return typeof t=="string"||t instanceof RegExp||typeof t=="boolean"}parse(t){let e=t,i={from:/(.*)/g,to:/(.*)/g};if(this.isPath(t))i={from:!0,to:t};else if(this.isPath(e.from)&&this.isPath(e.to))i=e;else throw"[Router] path is neither a string, regular expression, or a { from, to } object.";let{from:n,to:s}=i;return{from:this.parsePath(n),to:this.parsePath(s)}}route(){if(this.manager.has("HistoryManager")){let t=this.manager.get("HistoryManager"),e=E(m((t.length>1?t.previous:t.current).url)),i=E(m());this.routes.forEach((n,s)=>{let o=s.from,l=s.to;if(typeof o=="boolean"&&typeof l=="boolean")throw`[Router] path ({ from: ${o}, to: ${l} }) is not valid, remember paths can only be strings, regular expressions, or a boolean; however, both the from and to paths cannot be both booleans.`;let a=o,p=l;o instanceof RegExp&&o.test(e)&&(a=o.exec(e)),l instanceof RegExp&&l.test(i)&&(p=l.exec(i)),(Array.isArray(p)&&Array.isArray(a)||Array.isArray(p)&&typeof a=="boolean"&&a||Array.isArray(a)&&typeof p=="boolean"&&p)&&n({from:a,to:p,path:{from:e,to:i}})})}else console.warn("[Route] HistoryManager is missing.")}initEvents(){this.emitter.on("READY",this.route,this),this.emitter.on("CONTENT_REPLACED",this.route,this)}stopEvents(){this.emitter.off("READY",this.route,this),this.emitter.off("CONTENT_REPLACED",this.route,this)}};var Rt=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],kt=r=>[].concat(...r),lt=r=>Array.isArray(r)?kt(r.map(lt)):typeof r=="string"||r instanceof Node?Rt(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],pt=(r,t,e)=>typeof r=="function"?r.apply(e,t):r,ct=(r,t,e)=>{let i,n,s={},o=Object.keys(r);for(let l=0,a=o.length;l/^(in|out)/.test(r)?Ot[r]:r,ut={keyframes:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",autoplay:!0,duration:1e3,fillMode:"auto",direction:"normal",extend:{}},D=class{constructor(t={}){this.options={};this.targets=[];this.properties={};this.animations=new d;this.totalDuration=0;this.minDelay=0;this.computedOptions=new d;this.emitter=new R;var i;try{let e=t,{options:s}=e,o=U(e,["options"]),l=s instanceof D?s.getOptions():Array.isArray(s)?(i=s==null?void 0:s[0])==null?void 0:i.getOptions():s;this.options=Object.assign({},ut,l,o),this.loop=this.loop.bind(this);let n=this.options,{loop:a,delay:p,speed:g,easing:A,endDelay:f,duration:k,direction:bt,fillMode:yt,onfinish:Z,target:Et,keyframes:At,autoplay:It,extend:wt}=n,Tt=U(n,["loop","delay","speed","easing","endDelay","duration","direction","fillMode","onfinish","target","keyframes","autoplay","extend"]);this.mainElement=document.createElement("div"),this.targets=lt(Et),this.properties=Tt;let tt=[],x=this.targets.length,O;for(let I=0;I0||(O=ct(O,[I,x,T],this));let et=y.delay+y.duration*y.iterations+y.endDelay;this.totalDuration{typeof Z=="function"&&Z.call(this,T,I,x,S),this.emit("finish",T,I,x,S)},this.computedOptions.set(S,y),this.animations.set(T,S),tt.push(y.delay)}this.mainAnimation=this.mainElement.animate([{opacity:"0"},{opacity:"1"}],{duration:this.totalDuration,easing:"linear"}),this.minDelay=Math.min(...tt),this.setSpeed(g),It?this.play():this.pause(),this.promise=this.newPromise(),this.mainAnimation.onfinish=()=>{this.emit("complete",this),this.stopLoop()}}catch(s){this.emit("error",s)}}newPromise(){return new Promise((t,e)=>{this.on("complete",()=>t([this])),this.on("error",i=>e(i))})}then(t,e){return t=t==null?void 0:t.bind(this),e=e==null?void 0:e.bind(this),this.promise.then(t,e),this}catch(t){return t=t==null?void 0:t.bind(this),this.promise.catch(t),this}finally(t){return t=t==null?void 0:t.bind(this),this.promise.finally(t),this}loop(){this.stopLoop(),this.emit("update",this.getProgress(),this),this.animationFrame=window.requestAnimationFrame(this.loop)}stopLoop(){window.cancelAnimationFrame(this.animationFrame)}all(t){return t(this.mainAnimation,this.mainElement),this.animations.forEach(t),this}beginEvent(){if(this.getProgress()==0){let t=window.setTimeout(()=>{this.emit("begin",this),t=window.clearTimeout(t)},this.minDelay)}}play(){let t=this.getPlayState();return this.beginEvent(),this.all(e=>e.play()),this.emit("play",t,this),this.loop(),this}pause(){let t=this.getPlayState();return this.all(e=>e.pause()),this.emit("pause",t,this),this.stopLoop(),this.animationFrame=void 0,this}reset(){return this.setProgress(0),this.beginEvent(),this.options.autoplay?this.play():this.pause(),this}cancel(){return this.all(t=>t.cancel()),this.stopLoop(),this}finish(){return this.all(t=>t.finish()),this.stopLoop(),this}stop(){for(this.cancel(),this.animations.clear();this.targets.length;)this.targets.pop();this.mainElement=void 0,this.emit("stop")}getTargets(){return this.targets}getAnimation(t){return this.animations.get(t)}getTiming(t){var o,l,a;let e=t instanceof Animation?t:this.getAnimation(t),i=(o=this.computedOptions.get(e))!=null?o:{},n=(a=(l=e.effect)==null?void 0:l.getTiming())!=null?a:{},s=this.getOptions();return c(c(c(c({},ut),s),n),i)}getTotalDuration(){return this.totalDuration}getCurrentTime(){return this.mainAnimation.currentTime}getProgress(){return this.getCurrentTime()/this.totalDuration*100}getSpeed(){return this.mainAnimation.playbackRate}getPlayState(){return this.mainAnimation.playState}getOptions(){return this.options}setCurrentTime(t){return this.all(e=>{e.currentTime=t}),this.emit("update",this.getProgress()),this}setProgress(t){let e=t/100*this.totalDuration;return this.setCurrentTime(e),this}setSpeed(t=1){return this.all(e=>{e.playbackRate=t}),this}on(t,e,i){return this.emitter.on(t,e,i!=null?i:this),this}off(t,e,i){return this.emitter.off(t,e,i!=null?i:this),this}emit(t,...e){return this.emitter.emit(t,...e),this}toJSON(){return this.getOptions()}get[Symbol.toStringTag](){return"Animate"}},u=(r={})=>new D(r);var J=class extends b{constructor(){super(...arguments);this.minimalDuration=1e3}init(){super.init(),this.rootElement=document.getElementById("splashscreen"),this.rootElement&&(this.innerEl=this.rootElement.querySelector(".splashscreen-inner"),this.bgEl=this.rootElement.querySelector(".splashscreen-bg"),this.spinnerEl=[...this.rootElement.querySelectorAll(".spinner")]),this.rootElement.style.visibility="visible",this.rootElement.style.pointerEvents="auto"}boot(){this.rootElement&&this.hide()}async hide(){await new Promise(t=>{window.setTimeout(()=>{this.emitter.emit("BEFORE_SPLASHSCREEN_HIDE"),t()},this.minimalDuration)}),await new Promise(async t=>{u({target:this.innerEl,opacity:[1,0],autoplay:!0,duration:500,onfinish(e){e.style.opacity="0"}}).then(function(){this.stop()}),this.emitter.emit("START_SPLASHSCREEN_HIDE"),await this.show(),t()})}async show(){let[t]=await u({target:this.rootElement,transform:["translateY(0%)","translateY(100%)"],duration:1200,easing:"in-out-cubic"});this.emitter.emit("AFTER_SPLASHSCREEN_HIDE"),t.stop(),this.rootElement.style.transform="translateY(100%)",this.rootElement.style.visibility="hidden",this.rootElement.style.pointerEvents="none"}};var Q=class extends b{init(){super.init(),this.elements=[...document.querySelectorAll(".intro-animation")]}newPage(){this.init(),this.prepareToShow()}initEvents(){this.emitter.on("BEFORE_SPLASHSCREEN_HIDE",this.prepareToShow,this),this.emitter.on("CONTENT_REPLACED",this.newPage,this),this.emitter.on("START_SPLASHSCREEN_HIDE BEFORE_TRANSITION_IN",this.show,this)}stopEvents(){this.emitter.off("BEFORE_SPLASHSCREEN_HIDE",this.prepareToShow,this),this.emitter.off("CONTENT_REPLACED",this.newPage,this),this.emitter.off("START_SPLASHSCREEN_HIDE BEFORE_TRANSITION_IN",this.show,this)}stop(){requestAnimationFrame(()=>{for(let t of this.elements)t.style.transform="translateY(0px)",t.style.opacity="1"}),super.stop()}prepareToShow(){requestAnimationFrame(()=>{for(let t of this.elements)t.style.transform="translateY(200px)",t.style.opacity="0"})}async show(){let[t]=await u({target:this.elements,keyframes:[{transform:"translateY(200px)",opacity:0},{transform:"translateY(0px)",opacity:1}],delay(e){return 300*(e+1)},onfinish(e){requestAnimationFrame(()=>{e.style.transform="translateY(0px)",e.style.opacity="1"})},easing:"out-cubic",duration:650});return t.stop(),t}};var mt={name:"default",duration:500,scrollable:!0,out({from:r}){let{duration:t}=this,e=r.wrapper;return u({target:e,opacity:[1,0],duration:t}).on("finish",function(){this.stop()})},in({to:r,scroll:t}){let{duration:e}=this,i=r.wrapper;return window.scroll(t.x,t.y),u({target:i,opacity:[0,1],duration:e}).then(function(){this.stop()})}};var ht={name:"big",delay:200,durationPerAnimation:700,scrollable:!0,init(){this.mainElement=document.getElementById("big-transition"),this.spinnerElement=this.mainElement.querySelector(".spinner"),this.horizontalElements=[...this.mainElement.querySelector("#big-transition-horizontal").querySelectorAll("div")],this.maxLength=this.horizontalElements.length},out({from:r,scroll:t}){let{durationPerAnimation:e,delay:i}=this,n=r.wrapper;window.scroll(t.x,t.y);let s=Object.assign({},n.style);return new Promise(async o=>{this.mainElement.style.opacity="1",this.mainElement.style.visibility="visible",u({target:n,opacity:[1,0],duration:e,onfinish(f){f.style.opacity="0"}}).then(function(){this.stop()});let[a]=await u({target:this.horizontalElements,keyframes:[{transform:"scaleX(0)"},{transform:"scaleX(1)"}],delay(f){return i*(f+1)},onfinish(f){f.style.transform="scaleX(1)"},easing:"out-cubic",duration:500});n.style.opacity="1",Object.assign(n.style,s),this.spinnerElement.style.visibility="visible";let p=500,[g]=await u({target:this.spinnerElement,opacity:[0,1],duration:p,onfinish(f){f.style.opacity="1"}}),[A]=await u({options:g,opacity:[1,0],onfinish(f){f.style.opacity="0"},delay:1500});this.spinnerElement.style.visibility="hidden",g.stop(),A.stop(),o()})},in({to:r,scroll:t}){let{durationPerAnimation:e,delay:i}=this,n=r.wrapper;return window.scroll(t.x,t.y),new Promise(async s=>{let o=u({target:n,opacity:[0,1],duration:e}).then(()=>{o.stop()}),[l]=await u({target:this.horizontalElements,keyframes:[{transform:"scaleX(1)"},{transform:"scaleX(0)"}],delay(a){return i*(a+1)},onfinish(a){a.style.transform="scaleX(0)"},easing:"out-cubic",duration:500});this.mainElement.style.opacity="0",this.mainElement.style.visibility="hidden",l.stop(),s()})}};var _={name:"slide",duration:500,direction:"right",scrollable:!0,init(r){let t=r.trigger;t instanceof Node&&t.hasAttribute("data-direction")?this.direction=t.getAttribute("data-direction"):this.direction="right"},out({from:r}){let{duration:t,direction:e}=this,i=r.wrapper;return u({target:i,keyframes:[{transform:"translateX(0%)",opacity:1},{transform:`translateX(${e==="left"?"-":""}25%)`,opacity:0}],duration:t,easing:"in-quint"}).then(function(){this.stop()})},in({to:r,scroll:t}){let{duration:e}=this,i=r.wrapper;return window.scroll(t.x,t.y),u({target:i,keyframes:[{transform:`translateX(${this.direction==="right"?"-":""}25%)`,opacity:0},{transform:"translateX(0%)",opacity:1}],duration:e,easing:"out-quint"}).then(function(){this.stop()})}},gt=c(c({},_),{name:"slide-left",direction:"left",init(r){}}),ft=c(c({},_),{name:"slide-right",direction:"right",init(r){}});var dt,K,Ct,z=new $;z.add(new Q).add(dt=new J).set("HistoryManager",new j).set("PageManager",new G).set("TransitionManager",new B([["default",mt],["BigTransition",ht],["Slide",_],["SlideLeft",gt],["SlideRight",ft]])).set("router",K=new W).add(Ct=new Y);try{K=z.get("router");let r=document.querySelectorAll(".navbar .nav-link");for(let e of r){let i=e;K.add({path:i.getAttribute("data-path")||i.pathname,method(){i.classList.contains("active")||i.classList.add("active");for(let s of r)s!==i&&s.classList.remove("active")}})}let t;K.add({path:/(index|\/$)(\.html)?/,method(){t=u({target:".div",keyframes(a,p){return[{transform:"translateX(0px)",opacity:.1},{transform:"translateX(300px)",opacity:.2+(a+1)/p}]},fillMode:"both",easing:"out-cubic",duration(a){return(a+1)*500},loop:5,speed:1.5,direction:"alternate",delay(a){return(a+1)*500/2},autoplay:!1});let e=document.querySelector(".info"),i=e.textContent,n=i;t.on({begin(){e&&(n=i,e.textContent=n,e.style.color="initial")}}),t.on("complete",()=>{e&&(n="Done.",e.textContent=n,e.style.color="red",console.log(n))});let s=document.getElementById("scrub");s.addEventListener("input",a=>{var p=+a.target.value;t.setProgress(p),t.pause()});let o=document.querySelector(".progress");t.on("update",a=>{s.value=""+a,o&&(o.textContent=`${Math.round(a)}%`)}),s.addEventListener("change",()=>{if(Math.round(t.getProgress())>=100)return t.finish(),!1;t.play()});let l=document.querySelector(".playtoggle");l&&l.addEventListener("click",()=>{let a=t.getPlayState();a==="running"?t.pause():a==="finished"?t.reset():t.play(),console.log(a)})}}),z.on("AFTER_SPLASHSCREEN_HIDE",()=>{t==null||t.play()}),z.boot()}catch(r){dt.show(),console.warn("[App] boot failed,",r)} +//# sourceMappingURL=main.js.map diff --git a/demo/js/main.js.map b/demo/js/main.js.map new file mode 100644 index 0000000..d6cddef --- /dev/null +++ b/demo/js/main.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["packages/native/src/config.ts", "packages/manager/src/api.ts", "packages/native/src/manager.ts", "packages/native/src/url.ts", "packages/native/src/service.ts", "packages/native/src/history.ts", "packages/native/src/page.ts", "packages/emitter/src/api.ts", "packages/native/src/transition.ts", "packages/native/src/app.ts", "packages/native/src/pjax.ts", "packages/native/src/router.ts", "packages/animate/src/api.ts", "build/ts/services/Splashscreen.ts", "build/ts/services/IntroAnimation.ts", "build/ts/transitions/Fade.ts", "build/ts/transitions/BigTransition.ts", "build/ts/transitions/Slide.ts", "build/ts/main.ts"], + "sourcesContent": ["export interface ICONFIG {\n prefix?: string;\n wrapperAttr?: string;\n noAjaxLinkAttr?: string;\n noPrefetchAttr?: \"no-prefetch\";\n headers?: string[][];\n preventSelfAttr?: string;\n preventAllAttr?: string;\n transitionAttr?: string;\n blockAttr?: string;\n timeout?: number;\n maxPages?: number;\n [key: string]: any;\n}\n\nexport const CONFIG_DEFAULTS = {\n wrapperAttr: \"wrapper\",\n noAjaxLinkAttr: \"no-ajax-link\",\n noPrefetchAttr: \"no-prefetch\",\n headers: [\n [\"x-partial\", \"true\"]\n ],\n preventSelfAttr: `prevent=\"self\"`,\n preventAllAttr: `prevent=\"all\"`,\n transitionAttr: \"transition\",\n blockAttr: `block`,\n timeout: 30000,\n maxPages: 5\n};\n\nexport type ConfigKeys = keyof typeof CONFIG_DEFAULTS | string;\nexport const newConfig = (config: ICONFIG): ICONFIG => {\n return Object.assign({ ...CONFIG_DEFAULTS }, config);\n};\n\n/** Converts string into properly formatted data attributes */\nexport const toAttr = (config: ICONFIG, value: string, brackets: boolean = true): string => {\n let { prefix } = config;\n let attr = `data${prefix ? \"-\" + prefix : \"\"}-${value}`;\n return brackets ? `[${attr}]` : attr;\n};\n\n/** Selects config vars, and formats them for use, or simply returns the current configurations for the framework */\nexport const getConfig = (config: ICONFIG, value?: ConfigKeys, brackets: boolean = true): any => {\n if (typeof value !== \"string\")\n return config;\n\n let prop = config[value];\n if (typeof prop === \"string\")\n return toAttr(config, prop, brackets);\n return prop;\n};\n", "/** Manages complex lists of named data, eg. A page can be stored in a list by of other pages with the url being how the page is stored in the list. Managers use Maps to store data */\nexport class Manager {\n\t/** The complex list of named data, to which the Manager controls */\n\tpublic map: Map;\n\tconstructor(value?: Array<[K, V]>) {\n\t\tthis.map = new Map(value);\n\t}\n\n\t/** Returns the Manager classes base Map */\n\tpublic getMap(): Map {\n\t\treturn this.map;\n\t}\n\n\t/** Get a value stored in the Manager */\n\tpublic get(key: K): V {\n\t\treturn this.map.get(key);\n\t}\n\n\t/** Returns the keys of all items stored in the Manager as an Array */\n\tpublic keys(): Array {\n\t\treturn Array.from(this.map.keys());\n\t}\n\n\t/** Returns the values of all items stored in the Manager as an Array */\n\tpublic values(): Array {\n\t\treturn Array.from(this.map.values());\n\t}\n\n\t/** Set a value to the Manager using a key */\n\tpublic set(key: K, value: V): Manager {\n\t\tthis.map.set(key, value);\n\t\treturn this;\n\t}\n\n\t/** Adds a value to Manager, and uses the current size of the Manager as it's key, it works best when all the key in the Manager are numbers */\n\tpublic add(value: V): Manager {\n\t\tlet size = this.size;\n\t\t// @ts-ignore\n\t\tlet num: K = size as K;\n\t\tthis.set(num, value);\n\t\treturn this;\n\t}\n\n\t/** Returns the total number of items stored in the Manager */\n\tpublic get size(): number {\n\t\treturn this.map.size;\n\t}\n\n\t/** An alias for size */\n\tpublic get length(): number {\n\t\treturn this.map.size;\n\t}\n\n\t/** Returns the last item in the Manager who's index is a certain distance from the last item in the Manager */\n\tpublic last(distance: number = 1): V | undefined {\n\t\tlet key = this.keys()[this.size - distance];\n\t\treturn this.get(key);\n\t}\n\n\t/** Removes a value stored in the Manager via a key, returns true if an element in the Map object existed and has been removed, or false if the element does not exist */\n\tpublic delete(key: K): boolean {\n\t\treturn this.map.delete(key);\n\t}\n\n\t/** Removes a value stored in the Manager via a key, returns the Manager class, allowing for chains */\n\tpublic remove(key: K): Manager {\n\t\tthis.map.delete(key);\n\t\treturn this;\n\t}\n\n\t/** Clear the Manager of all its contents */\n\tpublic clear(): Manager {\n\t\tthis.map.clear();\n\t\treturn this;\n\t}\n\n\t/** Checks if the Manager contains a certain key */\n\tpublic has(key: K): boolean {\n\t\treturn this.map.has(key);\n\t}\n\n\t/** Returns a new Iterator object that contains an array of [key, value] for each element in the Map object in insertion order. */\n\tpublic entries(): IterableIterator<[K, V]> {\n\t\treturn this.map.entries();\n\t}\n\n\t/** Iterates through the Managers contents, calling a callback function every iteration */\n\tpublic forEach(\n\t\tcallback: (value?: V, key?: K, map?: Map) => void,\n\t\tcontext?: object\n\t): Manager {\n\t\tthis.map.forEach(callback, context);\n\t\treturn this;\n\t}\n\n\t/** Allows for iteration via for..of, learn more: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators] */\n\tpublic [Symbol.iterator](): IterableIterator<[K, V]> {\n\t\treturn this.entries();\n\t}\n}\n\n/**\n * Calls the method of a certain name for all items that are currently installed\n */\nexport const methodCall = (manager: Manager, method: string, ...args: any): void => {\n\tmanager.forEach((item) => {\n\t\t// @ts-ignore\n\t\titem[method](...args);\n\t});\n};\n\n/**\n * Asynchronously calls the method of a certain name for all items that are currently installed, similar to methodCall\n */\nexport const asyncMethodCall = async (manager: Manager, method: string, ...args: any): Promise => {\n\tfor (let [, item] of manager) {\n\t\t// @ts-ignore\n\t\tawait item[method](...args);\n\t}\n};\n\nexport default Manager;\n", "import { Manager, methodCall, asyncMethodCall } from \"@okikio/manager\";\nimport { ICONFIG } from \"./config\";\nimport { IApp } from \"./app\";\nimport { EventEmitter } from \"./emitter\";\n\nexport type IAdvancedManager = AdvancedManager;\n\n/** The base class for AdvancedManager items */\nexport class ManagerItem {\n /** The AdvancedManager the ManagerItem is attached to */\n public manager: IAdvancedManager;\n\n /** The App the ManagerItem is attached to */\n public app: IApp;\n\n /** The Config of the App the ManagerItem is attached to */\n public config: ICONFIG;\n\n /** The EventEmitter of the App the ManagerItem is attached to */\n public emitter: EventEmitter;\n\n /** The key to where ManagerItem is stored in an AdvancedManager */\n public key: any;\n\n constructor() { }\n\n /** Run after the Manager Item has been registered */\n public install(): any { }\n\n /** Register the current Manager Item's manager */\n public register(manager: IAdvancedManager, key: any): ManagerItem {\n this.manager = manager;\n this.app = manager.app;\n this.config = manager.config;\n this.emitter = manager.emitter;\n this.key = key;\n this.install();\n return this;\n }\n\n /** Run before the ManagerItem has been unregistered */\n public uninstall(): any { }\n\n /** Basically removes a ManagerItem, in order to recover the ManagerItem, it needs to be re-added to an AdvancedManager */\n public unregister() {\n this.uninstall();\n\n this.manager.remove(this.key);\n this.key = undefined;\n this.manager = undefined;\n this.app = undefined;\n this.config = undefined;\n this.emitter = undefined;\n }\n}\n\n/** A tweak to the Manager class that makes it self aware of the App class it's instantiated in */\nexport class AdvancedManager extends Manager {\n /** The App the AdvancedManager is attached to */\n public app: IApp;\n\n /** The Config of the App the AdvancedManager is attached to */\n public config: ICONFIG;\n\n /** The EventEmitter of the App the AdvancedManager is attached to */\n public emitter: EventEmitter;\n\n /** Register App details */\n constructor(app: IApp) {\n super();\n this.app = app;\n this.config = app.config;\n this.emitter = app.emitter;\n }\n\n /** Add a ManagerItem to AdvancedManager at a specified key */\n public set(key: K, value: V) {\n super.set(key, value);\n value.register(this, key);\n return this;\n }\n}\n\nexport { Manager, methodCall, asyncMethodCall };\n", "export const newURL = (url: string | URL | Location = window.location.href): URL => {\n return url instanceof URL ? url : new URL(url as unknown as string, window.location.origin);\n};\n\n/** Returns the pathname with the hash at the end */\nexport const getHashedPath = (url: URL | string): string => {\n let _url = newURL(url);\n return `${_url.pathname}${_url.hash}`;\n};\n\n/** Returns the actual hash without the hashtag */\nexport const getHash = (url: URL | string): string => newURL(url).hash.slice(1);\n\n/** Removes the hash from the full URL for a clean URL string */\nexport const clean = (url: URL | string): string => newURL(url).toString().replace(/(\\/#.*|\\/|#.*)$/, '');\n\n/** Compares two URLs to each other */\nexport const equal = (a: URL | string, b: URL | string): boolean => (clean(a) === clean(b));\n\n", "import { AdvancedManager, ManagerItem, methodCall } from \"./manager\";\nimport { IApp } from \"./app\";\n\n/** Controls specific kinds of actions that require JS */\nexport class Service extends ManagerItem {\n\t/** Called before the start of a Service, represents a constructor of sorts */\n\tpublic init(...args: any): any;\n\tpublic init(): any { }\n\n\t/** Called on start of Service */\n\tpublic boot(...args: any): any;\n\tpublic boot(): any {\n\t\tthis.initEvents();\n\t}\n\n\t/** Initialize events */\n\tpublic initEvents(): void { }\n\n\t/** Stop events */\n\tpublic stopEvents(): void { }\n\n\t/** Stop services */\n\tpublic stop(): void {\n\t\tthis.stopEvents();\n\t\tthis.unregister();\n\t}\n}\n\n/** The Service Manager controls the lifecycle of all Services in an App */\nexport class ServiceManager extends AdvancedManager {\n\tconstructor(app: IApp) {\n\t\tsuper(app);\n\t}\n\n\t/** Call the init method for all Services */\n\tpublic init(): ServiceManager {\n\t\tmethodCall(this, \"init\");\n\t\treturn this;\n\t}\n\n\t/** Call the boot method for all Services */\n\tpublic boot(): ServiceManager {\n\t\tmethodCall(this, \"boot\");\n\t\treturn this;\n\t}\n\n\t/** Call the stop method for all Services */\n\tpublic stop(): ServiceManager {\n\t\tmethodCall(this, \"stop\");\n\t\treturn this;\n\t}\n}\n", "import { Service } from \"./service\";\nimport { getHashedPath, newURL } from \"./url\";\n\nexport type Trigger = HTMLAnchorElement | \"HistoryManager\" | \"popstate\" | \"back\" | \"forward\";\nexport interface ICoords {\n\treadonly x: number;\n\treadonly y: number;\n}\n\nexport interface IStateData {\n\tscroll: ICoords;\n\t[key: string]: any;\n}\n\nexport interface IState {\n\turl: string;\n\tindex?: number;\n\ttransition: string;\n\tdata: IStateData;\n}\n\nexport interface IHistoryItem {\n\tindex: number;\n\tstates: IState[];\n}\n\nexport interface IHistoryManager extends Service {\n\tstates: IState[],\n\tpointer: number,\n\n\tinit(): any,\n\tget(index: number): IState,\n\tadd(value?: IState, historyAction?: \"replace\" | \"push\"): HistoryManager,\n\tremove(index?: number): HistoryManager,\n\treplace(newStates: IState[]): HistoryManager,\n\tset(i: number, state: IState): IState,\n\tcurrent: IState,\n\tlast: IState,\n\tprevious: IState | null,\n\tlength: number,\n}\n\n/** A quick snapshot of page scroll coordinates */\nexport const newCoords = (x: number = window.scrollX, y: number = window.scrollY): ICoords => ({ x, y });\n\n/** Creates a state; a state represents the current status of the page consisting of properties like: url, transition, and data */\nexport const newState = (state: IState = {\n\turl: getHashedPath(newURL()),\n\tindex: 0,\n\ttransition: \"default\",\n\tdata: {\n\t\tscroll: newCoords(),\n\t\ttrigger: \"HistoryManager\"\n\t}\n}): IState => (state);\n\n/** Keeps a record of the history of the App; it stores only the states of Pages */\nexport class HistoryManager extends Service implements IHistoryManager {\n\tpublic states: IState[];\n\tpublic pointer = -1;\n\n\t/** Initializes the states array, and replace the history pushState data with the states array */\n\tinit() {\n\t\tthis.states = [];\n\n\t\tlet state = newState();\n\t\tthis.add(state, \"replace\");\n\t}\n\n\t/** Get a state based on it's index */\n\tpublic get(index: number) {\n\t\treturn this.states[index];\n\t}\n\n\t/** Add a state to HistoryManager and change the history pushState data based on the historyAction specified */\n\tpublic add(value?: IState, historyAction: \"replace\" | \"push\" = \"push\"): HistoryManager {\n\t\tlet state = newState(value);\n\t\tlet len = this.length;\n\t\tthis.states.push({ ...state });\n\t\tthis.pointer = len;\n\n\t\tlet item: IHistoryItem = {\n\t\t\tindex: this.pointer,\n\t\t\tstates: [...this.states]\n\t\t};\n\t\tchangeState(historyAction, state, item);\n\t\treturn this;\n\t}\n\n\tpublic remove(index?: number) {\n\t\tif (index) {\n\t\t\tthis.states.splice(index, 1);\n\t\t} else {\n\t\t\tthis.states.pop();\n\t\t}\n\n\t\tthis.pointer--;\n\t\treturn this;\n\t}\n\n\t/** Replaces the states array with another states array, this is later used when going back and forward in page history */\n\tpublic replace(newStates: IState[]) {\n\t\tthis.states = newStates;\n\t\treturn this;\n\t}\n\n\t/** Set state by index. */\n\tpublic set(i: number, state: IState) {\n\t\treturn (this.states[i] = state);\n\t}\n\n\t/** Get the current state */\n\tget current(): IState {\n\t\treturn this.get(this.pointer);\n\t}\n\n\t/** Get the last state (top of the history stack). */\n\tget last(): IState {\n\t\treturn this.get(this.length - 1);\n\t}\n\n\t/** Get the previous state. */\n\tget previous(): IState | null {\n\t\treturn this.pointer < 1 ? null : this.get(this.pointer - 1);\n\t}\n\n\tget length() {\n\t\treturn this.states.length;\n\t}\n}\n\n/** Either push or replace history state */\nexport const changeState = (action: \"push\" | \"replace\", state: IState, item: object) => {\n\tlet href = getHashedPath(state.url);\n\tlet args = [item, \"\", href];\n\tif (window.history) {\n\t\tswitch (action) {\n\t\t\tcase \"push\":\n\t\t\t\twindow.history.pushState.apply(window.history, args);\n\t\t\t\tbreak;\n\t\t\tcase \"replace\":\n\t\t\t\twindow.history.replaceState.apply(window.history, args);\n\t\t\t\tbreak;\n\t\t}\n\t}\n};\n", "import { Manager, ManagerItem, AdvancedManager } from \"./manager\";\nimport { equal, newURL } from \"./url\";\nimport { getConfig } from \"./config\";\nimport { Service } from \"./service\";\n\nexport interface IPage extends ManagerItem {\n dom: Document,\n wrapper: HTMLElement,\n title: string,\n head: Element,\n body: Element,\n url: URL,\n data: string,\n wrapperAttr: string,\n\n build(): any,\n install(): void,\n uninstall(): any,\n}\n\n/**\n * Parses strings to DOM\n */\nexport const PARSER: DOMParser = new DOMParser();\n\n/** A page represents the DOM elements that create each page */\nexport class Page extends ManagerItem implements IPage {\n /** Holds the DOM of the current page */\n public dom: Document;\n\n /** Holds the wrapper element to be swapped out of each Page */\n public wrapper: HTMLElement;\n\n /** Holds the title of each page */\n public title: string;\n\n /** Holds the head element of each page */\n public head: Element;\n\n /** Holds the body element of each page */\n public body: Element;\n\n /** The URL of the current page */\n public url: URL;\n\n /** The payload of a page request */\n public data: string;\n\n /** Attr that identifies the wrapper */\n public wrapperAttr: string;\n\n constructor(url: URL = newURL(), dom: string | Document = document) {\n super();\n this.url = url;\n\n if (typeof dom === \"string\") {\n this.data = dom;\n } else this.dom = dom || document;\n }\n\n /** Builds the page's dom, and sets the title, head, body, and wrapper properties of the Page class */\n public build() {\n if (!(this.dom instanceof Node)) {\n this.dom = PARSER.parseFromString(this.data, \"text/html\");\n }\n\n if (!(this.body instanceof Node)) {\n let { title, head, body } = this.dom;\n this.title = title;\n this.head = head;\n this.body = body;\n this.wrapper = this.body.querySelector(this.wrapperAttr);\n }\n }\n\n public install() {\n this.wrapperAttr = getConfig(this.config, \"wrapperAttr\");\n }\n\n public uninstall() {\n this.url = undefined;\n this.title = undefined;\n this.head = undefined;\n this.body = undefined;\n this.dom = undefined;\n this.wrapper = undefined;\n this.data = undefined;\n this.wrapperAttr = undefined;\n }\n}\n\nexport interface IPageManager extends Service {\n loading: Manager>,\n pages: AdvancedManager;\n\n install(): any,\n\n get(key): Page,\n add(value): PageManager,\n set(key, value): PageManager,\n remove(key): PageManager,\n has(key): boolean,\n clear(): PageManager,\n size: number,\n keys(): any[],\n\n load(_url: URL | string): Promise,\n request(url: string): Promise,\n}\n\n/** Controls which page to load */\nexport class PageManager extends Service implements IPageManager {\n /** Stores all fetch requests that are currently loading */\n public loading: Manager> = new Manager();\n\n pages: AdvancedManager;\n\n /** Instantiate pages, and add the current page to pages */\n install() {\n this.pages = new AdvancedManager(this.app);\n\n let URLString = newURL().pathname;\n this.set(URLString, new Page());\n URLString = undefined;\n }\n\n get(key) { return this.pages.get(key); }\n add(value) { this.pages.add(value); return this; }\n set(key, value) { this.pages.set(key, value); return this; }\n remove(key) { this.pages.remove(key); return this; }\n has(key) { return this.pages.has(key); }\n clear() { this.pages.clear(); return this; }\n get size() { return this.pages.size; }\n keys() { return this.pages.keys(); }\n\n /** Load from cache or by requesting URL via a fetch request, avoid requesting for the same thing twice by storing the fetch request in \"this.loading\" */\n public async load(_url: URL | string = newURL()): Promise {\n let url: URL = newURL(_url);\n let urlString: string = url.pathname;\n let page: Page, request: Promise;\n\n if (this.has(urlString)) {\n page = this.get(urlString);\n return Promise.resolve(page);\n }\n\n if (!this.loading.has(urlString)) {\n request = this.request(urlString);\n this.loading.set(urlString, request);\n } else request = this.loading.get(urlString);\n\n let response = await request;\n this.loading.remove(urlString);\n\n page = new Page(url, response);\n this.set(urlString, page);\n\n if (this.size > getConfig(this.config, \"maxPages\")) {\n let currentUrl = newURL();\n let keys = this.keys();\n let first = equal(currentUrl, keys[0]) ? keys[1] : keys[0];\n let page = this.get(first);\n page.unregister();\n page = undefined;\n keys = undefined;\n currentUrl = undefined;\n first = undefined;\n }\n\n return page;\n }\n\n /** Starts a fetch request */\n public async request(url: string): Promise {\n const headers = new Headers(getConfig(this.config, \"headers\"));\n const timeout = window.setTimeout(() => {\n window.clearTimeout(timeout);\n throw \"Request Timed Out!\";\n }, getConfig(this.config, \"timeout\"));\n\n try {\n let response = await fetch(url, {\n mode: 'same-origin',\n method: \"GET\",\n headers,\n cache: \"default\",\n credentials: \"same-origin\",\n });\n\n window.clearTimeout(timeout);\n if (response.status >= 200 && response.status < 300) {\n return await response.text();\n }\n\n const err = new Error(response.statusText || \"\" + response.status);\n throw err;\n } catch (err) {\n window.clearTimeout(timeout);\n throw err;\n }\n }\n}\n", "import { Manager, methodCall } from \"@okikio/manager\";\n\nexport type ListenerCallback = ((...args: any) => void);\nexport interface IListener {\n readonly callback: ListenerCallback;\n readonly scope: object;\n readonly name: string;\n}\n\n/** Represents a new event listener consisting of properties like: callback, scope, name */\nexport const newListener = ({\n callback = () => { },\n scope = null,\n name = \"event\",\n}: IListener): IListener => ({ callback, scope, name });\n\n/** Represents a new event */\nexport class Event extends Manager {\n /** The name of the event */\n public name: string;\n constructor(name: string = \"event\") {\n super();\n this.name = name;\n }\n}\n\nexport type EventInput = string | object | Array;\n\n/**\n * An Event Emitter\n * */\nexport class EventEmitter extends Manager {\n constructor() {\n super();\n }\n\n /** Gets event, if event doesn't exist create a new one */\n public getEvent(name: string): Event {\n let event = this.get(name);\n if (!(event instanceof Event)) {\n this.set(name, new Event(name));\n return this.get(name);\n }\n\n return event;\n }\n\n /** Creates a listener and adds it to an event */\n public newListener(\n name: string,\n callback: ListenerCallback,\n scope: object\n ): Event {\n let event = this.getEvent(name);\n event.add(newListener({ name, callback, scope }));\n return event;\n }\n\n /** Adds a listener to a given event */\n public on(\n events: EventInput,\n callback?: ListenerCallback | object,\n scope?: object\n ): EventEmitter {\n // If there is no event break\n if (typeof events == \"undefined\") return this;\n\n // Create a new event every space\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\n\n let _name: string;\n let _callback: ListenerCallback;\n let isObject = typeof events == \"object\" && !Array.isArray(events);\n\n let _scope: object = isObject ? callback : scope;\n if (!isObject) _callback = (callback as ListenerCallback);\n\n // Loop through the list of events\n Object.keys(events).forEach(key => {\n // Select the name of the event from the list\n // Remember events can be {String | Object | Array}\n\n // Check If events is an Object (JSON like Object, and not an Array)\n if (isObject) {\n _name = key;\n _callback = events[key];\n } else {\n _name = events[key];\n }\n\n this.newListener(_name, _callback, _scope);\n }, this);\n return this;\n }\n\n /** Removes a listener from an event */\n public removeListener(\n name: string,\n callback: ListenerCallback,\n scope: object\n ): Event {\n let event: Event = this.get(name);\n if (event instanceof Event && callback) {\n let listener = newListener({ name, callback, scope });\n\n event.forEach((value: IListener, i: number) => {\n if (\n value.callback === listener.callback &&\n value.scope === listener.scope\n ) {\n return event.remove(i);\n }\n });\n }\n\n return event;\n }\n\n /** Remove a listener from a given event, or just completely remove an event */\n public off(\n events: EventInput,\n callback?: ListenerCallback | object,\n scope?: object\n ): EventEmitter {\n // If there is no event break\n if (typeof events == \"undefined\") return this;\n\n // Create a new event every space\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\n\n let _name: string;\n let _callback: ListenerCallback;\n let isObject = typeof events == \"object\" && !Array.isArray(events);\n\n let _scope: object = isObject ? callback : scope;\n if (!isObject) _callback = (callback as ListenerCallback);\n\n // Loop through the list of events\n Object.keys(events).forEach(key => {\n // Select the name of the event from the list\n // Remember events can be {String | Object | Array}\n\n // Check If events is an Object (JSON like Object, and not an Array)\n if (isObject) {\n _name = key;\n _callback = events[key];\n } else {\n _name = events[key];\n }\n\n if (typeof _callback === \"function\") {\n this.removeListener(_name, _callback, _scope);\n } else this.remove(_name);\n }, this);\n return this;\n }\n\n /** Call all listeners within an event */\n public emit(\n events: string | Array,\n ...args: any\n ): EventEmitter {\n // If there is no event break\n if (typeof events == \"undefined\") return this;\n\n // Create a new event every space\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\n\n // Loop through the list of events\n events.forEach((event: string) => {\n let _event: Event = this.get(event);\n\n if (_event instanceof Event) {\n _event.forEach((listener: IListener) => {\n let { callback, scope } = listener;\n callback.apply(scope, args);\n });\n }\n }, this);\n return this;\n }\n\n /** Clears events and event listeners */\n public clear() {\n methodCall(this, \"clear\");\n super.clear();\n return this;\n }\n}\n\nexport default EventEmitter;\n", "import { Manager } from \"./manager\";\nimport { ICoords, newCoords, Trigger } from \"./history\";\nimport { IPage } from \"./page\";\nimport { getConfig } from \"./config\";\nimport { Service } from \"./service\";\nimport { newURL } from \"./url\";\n\n/**\n * The async function type, allows for smooth transition between Promises\n */\nexport type asyncFn = (err?: any, value?: any) => void;\nexport interface ITransition {\n oldPage?: IPage;\n newPage?: IPage;\n trigger?: Trigger;\n scroll?: { x: number; y: number };\n scrollable?: boolean;\n in: (data: ITransitionData) => any;\n out: (data: ITransitionData) => any;\n [key: string]: any;\n}\nexport interface ITransitionData {\n from?: IPage;\n to?: IPage;\n trigger?: Trigger;\n scroll?: ICoords;\n done: asyncFn;\n}\nexport interface ITransitionManager extends Service {\n transitions: Manager,\n\n get(key: string): ITransition,\n set(key: string, value: ITransition): TransitionManager,\n add(value: ITransition): TransitionManager,\n has(key: string): boolean,\n\n boot(): any,\n animate(name: string, data: any): Promise,\n}\n\n/** Auto scrolls to an elements position if the element has an hash */\nexport const hashAction = (coords?: ICoords, hash: string = window.location.hash) => {\n try {\n let _hash = hash[0] == \"#\" ? hash : newURL(hash).hash;\n if (_hash.length > 1) {\n let el = document.getElementById(_hash.slice(1));\n if (el) {\n let { left, top } = el.getBoundingClientRect();\n let scrollLeft = window.pageXOffset;\n let scrollTop = window.pageYOffset;\n let x = left + scrollLeft;\n let y = top + scrollTop;\n\n console.log(x, y);\n return newCoords(x, y);\n }\n }\n } catch (e) {\n console.warn(\"[hashAction] error\", e);\n }\n\n return coords ?? newCoords(0, 0);\n};\n\n// The Default Transition\nconst Default: ITransition = {\n name: \"default\",\n scrollable: true,\n\n out({ done }: ITransitionData) {\n done();\n },\n in({ scroll, done }: ITransitionData) {\n window.scroll(scroll.x, scroll.y);\n done();\n }\n};\n\n/** Controls which Transition between pages to use */\nexport class TransitionManager extends Service implements ITransitionManager {\n transitions: Manager;\n private _arg: Array<[string, ITransition]>;\n constructor(transitions?: Array<[string, ITransition]>) {\n super();\n this._arg = transitions;\n }\n\n /** On Service install set Config */\n public install() {\n super.install();\n\n let transitions = this._arg && this._arg.length ? this._arg : (getConfig(this.config, \"transitions\") ?? []);\n\n // Manager like Maps use the most recent [key, value] Array it knows, replacing the default transition\n // With any other transitions called [\"default\", ...]\n transitions = [[\"default\", Default]].concat(transitions);\n this.transitions = new Manager(transitions);\n }\n\n get(key: string) { return this.transitions.get(key); }\n set(key: string, value: ITransition) { this.transitions.set(key, value); return this; }\n add(value: ITransition) { this.transitions.add(value); return this; }\n has(key: string) { return this.transitions.has(key); }\n\n /** Starts a transition */\n public async animate(name: string, data: any): Promise {\n let transition: ITransition = this.transitions.get(name);\n let scroll = data.scroll;\n let ignoreHashAction = data.ignoreHashAction;\n if (!(\"wrapper\" in data.oldPage) || !(\"wrapper\" in data.newPage))\n throw `[Page] either oldPage or newPage aren't instances of the Page Class.\\n ${{\n newPage: data.newPage,\n oldPage: data.oldPage,\n }}`;\n\n // Replace the title\n document.title = `` + data.newPage.title;\n\n let fromWrapper = data.oldPage.wrapper;\n let toWrapper = data.newPage.wrapper;\n\n if (!(fromWrapper instanceof Node) || !(toWrapper instanceof Node))\n throw `[Wrapper] the wrapper from the ${!(toWrapper instanceof Node) ? \"next\" : \"current\"\n } page cannot be found. The wrapper must be an element that has the attribute ${getConfig(this.config,\n \"wrapperAttr\"\n )}.`;\n\n // Give the Transition all the background data it may require\n transition.init && transition?.init(data);\n\n this.emitter.emit(\"BEFORE_TRANSITION_OUT\");\n\n // Start the out point of the Transition\n if (transition.out) {\n await new Promise((done) => {\n let outMethod: Promise = transition.out.call(transition, {\n ...data,\n from: data.oldPage,\n trigger: data.trigger,\n done,\n });\n\n outMethod?.then(done);\n });\n }\n\n this.emitter.emit(\"AFTER_TRANSITION_OUT\");\n\n // Add the new wrapper before the old one\n await new Promise((done) => {\n fromWrapper.insertAdjacentElement(\"beforebegin\", toWrapper);\n this.emitter.emit(\"CONTENT_INSERT\");\n\n if (!ignoreHashAction && !/back|popstate|forward/.test(data.trigger as string)) {\n scroll = hashAction(scroll);\n }\n done();\n });\n\n // Replace the old wrapper with the new one\n await new Promise((done) => {\n fromWrapper.remove();\n fromWrapper = undefined;\n toWrapper = undefined;\n this.emitter.emit(\"CONTENT_REPLACED\");\n done();\n });\n\n this.emitter.emit(\"BEFORE_TRANSITION_IN\");\n\n // Start the in point of the Transition (only the in method has access to the hashAction's scroll position)\n if (transition.in) {\n await new Promise(async (done) => {\n let inMethod: Promise = transition.in.call(transition, {\n ...data,\n from: data.oldPage,\n to: data.newPage,\n trigger: data.trigger,\n scroll,\n done,\n });\n\n inMethod?.then(done);\n });\n }\n\n this.emitter.emit(\"AFTER_TRANSITION_IN\");\n return transition;\n }\n}\n", "import { EventEmitter, ListenerCallback, EventInput } from \"./emitter\";\nimport { ServiceManager, Service } from \"./service\";\nimport { newConfig, ICONFIG } from \"./config\";\n\nexport interface IApp {\n services: ServiceManager,\n emitter: EventEmitter,\n config: ICONFIG,\n register(config: ICONFIG): App,\n get(key: string): Service,\n set(key: string, service: Service): App,\n add(value: Service): App,\n boot(): App,\n stop(): App,\n on(events: EventInput, callback?: ListenerCallback): App,\n off(events: EventInput, callback?: ListenerCallback): App,\n emit(events: string | any[], ...args: any): App,\n}\n\n/** The App class starts the entire process, it controls all managers and all services */\nexport class App implements IApp {\n /** An instance of the ServiceManager */\n public services: ServiceManager;\n\n /** An instance of an EventEmitter */\n public emitter: EventEmitter;\n\n /** The current Configuration's for the App */\n public config: ICONFIG;\n constructor(config: object = {}) {\n this.register(config);\n }\n\n /** Create new instances of the ServiceManager, EventEmitter and the configurations */\n public register(config: ICONFIG = {}): App {\n this.config = newConfig(config);\n this.emitter = new EventEmitter();\n this.services = new ServiceManager(this);\n\n let handler = (() => {\n document.removeEventListener(\"DOMContentLoaded\", handler);\n window.removeEventListener(\"load\", handler);\n this.emitter.emit(\"READY ready\");\n }).bind(this);\n\n document.addEventListener(\"DOMContentLoaded\", handler);\n window.addEventListener(\"load\", handler);\n return this;\n }\n\n /** Shortcuts to adding, setting, and getting Services */\n public get(key: string): Service {\n return this.services.get(key);\n }\n\n public set(key: string, value: Service): App {\n this.services.set(key, value);\n return this;\n }\n\n public add(value: Service): App {\n this.services.add(value);\n return this;\n }\n\n /** Initialize and boot all Services */\n public boot(): App {\n this.services.init();\n this.services.boot();\n return this;\n }\n\n /** Stops all Services and clears the even emitter of all events and listeners */\n public stop(): App {\n this.services.stop();\n this.emitter.clear();\n return this;\n }\n\n /** Shortcuts to the App EventEmitter on, off, and emit methods */\n public on(events: EventInput, callback?: ListenerCallback): App {\n this.emitter.on(events, callback, this);\n return this;\n }\n\n public off(events: EventInput, callback?: ListenerCallback): App {\n this.emitter.off(events, callback, this);\n return this;\n }\n\n public emit(events: string | any[], ...args: any): App {\n this.emitter.emit(events, ...args);\n return this;\n }\n}\n", "import { newState, Trigger, newCoords, IHistoryItem, IHistoryManager } from \"./history\";\nimport { Service } from \"./service\";\nimport { IPage, IPageManager } from \"./page\";\nimport { newURL, getHashedPath, equal } from \"./url\";\nimport { getConfig } from \"./config\";\nimport { hashAction, ITransitionManager } from \"./transition\";\n\nexport type LinkEvent = MouseEvent | TouchEvent;\nexport type StateEvent = LinkEvent | PopStateEvent;\nexport type IgnoreURLsList = Array;\n/**\n * Creates a barbajs like PJAX Service, for the native framework\n * Based on barbajs and StartingBlocks\n */\nexport class PJAX extends Service {\n /** URLs to ignore when prefetching */\n public ignoreURLs: IgnoreURLsList;\n\n /** Whether or not to disable prefetching */\n public prefetchIgnore: boolean;\n\n /** Current state of transitions */\n public isTransitioning: boolean;\n\n /** Ignore extra clicks of an anchor element if a transition has already started */\n public stopOnTransitioning: boolean;\n\n /** On page change (excluding popstate events) keep current scroll position */\n public stickyScroll: boolean;\n\n /** Force load a page if an error occurs */\n public forceOnError: boolean;\n\n /** Ignore hash action if set to true */\n public ignoreHashAction: boolean;\n\n public install() {\n super.install();\n\n this.ignoreURLs = getConfig(this.config, \"ignoreURLs\") ?? [];\n this.prefetchIgnore = getConfig(this.config, \"prefetchIgnore\") ?? false;\n this.stopOnTransitioning = getConfig(this.config, \"stopOnTransitioning\") ?? false;\n this.stickyScroll = getConfig(this.config, \"stickyScroll\") ?? false;\n this.forceOnError = getConfig(this.config, \"forceOnError\") ?? false;\n this.ignoreHashAction = getConfig(this.config, \"ignoreHashAction\") ?? false\n }\n\n /** Sets the transition state to either true or false */\n public transitionStart() {\n this.isTransitioning = true;\n }\n\n public transitionStop() {\n this.isTransitioning = false;\n }\n\n public init() {\n /**\n * Bind the event listeners to the PJAX class\n *\n * @memberof PJAX\n */\n this.onHover = this.onHover.bind(this);\n this.onClick = this.onClick.bind(this);\n this.onStateChange = this.onStateChange.bind(this);\n }\n\n /** Starts the PJAX Service */\n public boot() {\n if (\"scrollRestoration\" in window.history) {\n // Back off, browser, I got this...\n window.history.scrollRestoration = \"manual\";\n }\n\n super.boot();\n }\n\n /** Gets the transition to use for a certain anchor */\n public getTransitionName(el: HTMLAnchorElement): string | null {\n if (!el || !el.getAttribute) return null;\n let transitionAttr = el.getAttribute(\n getConfig(this.config, \"transitionAttr\", false)\n );\n\n if (typeof transitionAttr === \"string\") return transitionAttr;\n return null;\n }\n\n /** Checks to see if the anchor is valid */\n public validLink(\n el: HTMLAnchorElement,\n event: LinkEvent | KeyboardEvent,\n href: string\n ): boolean {\n let pushStateSupport = !window.history.pushState;\n let exists = !el || !href;\n let eventMutate =\n (event as KeyboardEvent).metaKey ||\n (event as KeyboardEvent).ctrlKey ||\n (event as KeyboardEvent).shiftKey ||\n (event as KeyboardEvent).altKey;\n let newTab =\n el.hasAttribute(\"target\") &&\n (el as HTMLAnchorElement).target === \"_blank\";\n let crossOrigin =\n (el as HTMLAnchorElement).protocol !== location.protocol ||\n (el as HTMLAnchorElement).hostname !== location.hostname;\n let download = typeof el.getAttribute(\"download\") === \"string\";\n let preventSelf = el.matches(getConfig(this.config, \"preventSelfAttr\"));\n let preventAll = Boolean(\n el.closest(getConfig(this.config, \"preventAllAttr\"))\n );\n let sameURL = getHashedPath(newURL()) === getHashedPath(newURL(href));\n return !(\n exists ||\n pushStateSupport ||\n eventMutate ||\n newTab ||\n crossOrigin ||\n download ||\n preventSelf ||\n preventAll ||\n sameURL\n );\n }\n\n /** Returns the href of an Anchor element */\n public getHref(el: HTMLAnchorElement): string | null {\n if (\n el &&\n el.tagName &&\n el.tagName.toLowerCase() === \"a\" &&\n typeof el.href === \"string\"\n )\n return el.href;\n return null;\n }\n\n /** Check if event target is a valid anchor with an href, if so, return the anchor */\n public getLink(event: LinkEvent): HTMLAnchorElement {\n let el = event.target as HTMLAnchorElement;\n let href: string = this.getHref(el);\n\n while (el && !href) {\n el = (el as HTMLElement).parentNode as HTMLAnchorElement;\n href = this.getHref(el);\n }\n\n // Check for a valid link\n if (!el || !this.validLink(el, event, href)) return;\n return el;\n }\n\n /** When an element is clicked, get valid anchor element, go for a transition */\n public onClick(event: LinkEvent) {\n let el = this.getLink(event);\n if (!el) return;\n\n if (this.isTransitioning && this.stopOnTransitioning) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n let href = this.getHref(el);\n this.emitter.emit(\"ANCHOR_CLICK CLICK\", event);\n this.go({ href, trigger: el, event });\n }\n\n /** Returns the direction of the State change as a String, either the Back button or the Forward button */\n public getDirection(value: number): Trigger {\n if (Math.abs(value) > 1) {\n // Ex 6-0 > 0 -> forward, 0-6 < 0 -> back\n return value > 0 ? \"forward\" : \"back\";\n } else {\n if (value === 0) {\n return \"popstate\";\n } else {\n // Ex 6-5 > 0 -> back, 5-6 < 0 -> forward\n return value > 0 ? \"back\" : \"forward\";\n }\n }\n }\n\n /** Force a page to go to a certain URL */\n public force(href: string): void {\n window.location.assign(href);\n }\n\n /**\n * If transition is running force load page.\n * Stop if currentURL is the same as new url.\n * On state change, change the current state history, to reflect the direction of said state change\n * Load page and page transition.\n */\n public go({\n href,\n trigger = \"HistoryManager\",\n event,\n }: {\n href: string;\n trigger?: Trigger;\n event?: StateEvent;\n }): Promise {\n // If transition is already running and the go method is called again, force load page\n if (this.isTransitioning && this.stopOnTransitioning ||\n !(this.manager.has(\"TransitionManager\") &&\n this.manager.has(\"HistoryManager\") &&\n this.manager.has(\"PageManager\"))) {\n this.force(href);\n return;\n }\n\n const history = this.manager.get(\"HistoryManager\") as IHistoryManager;\n let scroll = newCoords(0, 0);\n let currentState = history.current;\n let currentURL = currentState.url;\n if (equal(currentURL, href)) {\n return;\n }\n\n let transitionName: string;\n if (event && (event as PopStateEvent).state) {\n this.emitter.emit(\"POPSTATE\", event);\n\n // If popstate, get back/forward direction.\n let { state }: { state: IHistoryItem } = event as PopStateEvent;\n let { index } = state;\n let currentIndex = currentState.index;\n let difference = currentIndex - index;\n\n history.replace(state.states);\n history.pointer = index;\n\n let _state = history.get(index);\n transitionName = _state.transition;\n scroll = _state.data.scroll;\n\n trigger = this.getDirection(difference);\n console.log(trigger == \"forward\" && history)\n\n // Based on the direction of the state change either remove or add a state\n this.emitter.emit(trigger === \"back\" ? `POPSTATE_BACK` : `POPSTATE_FORWARD`, event);\n } else {\n // Add new state\n transitionName = this.getTransitionName(trigger as HTMLAnchorElement);\n\n scroll = newCoords();\n let state = newState({\n url: href,\n transition: transitionName,\n data: { scroll },\n });\n\n !this.stickyScroll && (scroll = newCoords(0, 0));\n\n history.add(state);\n this.emitter.emit(\"HISTORY_NEW_ITEM\", event);\n }\n\n if (event) {\n event.stopPropagation();\n event.preventDefault();\n }\n\n this.emitter.emit(\"GO\", event);\n return this.load({\n oldHref: currentURL,\n href,\n trigger,\n transitionName,\n scroll,\n });\n }\n\n /** Load the new Page as well as a Transition; starts the Transition */\n public async load({\n oldHref,\n href,\n trigger,\n transitionName = \"default\",\n scroll = { x: 0, y: 0 },\n }: {\n oldHref: string;\n href: string;\n trigger: Trigger;\n transitionName?: string;\n scroll: { x: number; y: number };\n }): Promise {\n try {\n const pages = this.manager.get(\"PageManager\") as IPageManager;\n let newPage: IPage, oldPage: IPage;\n this.emitter.emit(\"NAVIGATION_START\", {\n oldHref,\n href,\n trigger,\n transitionName,\n });\n\n // Load & Build both the old and new pages\n try {\n this.transitionStart();\n oldPage = await pages.load(oldHref);\n !(oldPage.dom instanceof Element) && oldPage.build();\n\n this.emitter.emit(\"PAGE_LOADING\", { href, oldPage, trigger });\n newPage = await pages.load(href);\n await newPage.build();\n this.emitter.emit(\"PAGE_LOAD_COMPLETE\", {\n newPage,\n oldPage,\n trigger,\n });\n } catch (err) {\n console.warn(`[PJAX] Page load error: ${err}`);\n }\n\n // Transition Between Pages\n try {\n const TransitionManager = this.manager.get(\"TransitionManager\") as ITransitionManager;\n this.emitter.emit(\"TRANSITION_START\", transitionName);\n\n let transition = await TransitionManager.animate(TransitionManager.has(transitionName) ? transitionName : \"default\", {\n oldPage,\n newPage,\n trigger,\n scroll,\n ignoreHashAction: this.ignoreHashAction\n });\n\n if (!transition.scrollable) {\n if (!this.ignoreHashAction && !/back|popstate|forward/.test(trigger as string)) scroll = hashAction(scroll);\n window.scroll(scroll.x, scroll.y);\n }\n\n this.emitter.emit(\"TRANSITION_END\", { transition });\n } catch (err) {\n console.warn(`[PJAX] Transition error: ${err}`);\n }\n\n // Navigation is over\n this.emitter.emit(\"NAVIGATION_END\", {\n oldPage,\n newPage,\n trigger,\n transitionName,\n });\n } catch (err) {\n if (this.forceOnError) this.force(href);\n else console.warn(err);\n } finally {\n this.transitionStop(); // Sets isTransitioning to false\n }\n }\n\n /** Check to see if the URL is to be ignored, uses either RegExp of Strings to check */\n public ignoredURL({ pathname }: URL): boolean {\n return (\n this.ignoreURLs.length &&\n this.ignoreURLs.some((url) => {\n return typeof url === \"string\"\n ? url === pathname\n : (url as RegExp).exec(pathname) !== null;\n })\n );\n }\n\n /** When you hover over an anchor, prefetch the event target's href */\n public onHover(event: LinkEvent): Promise {\n let el = this.getLink(event);\n if (!el || !this.manager.has(\"PageManager\")) return;\n\n const pages = this.manager.get(\"PageManager\") as IPageManager;\n let url = newURL(this.getHref(el));\n let urlString: string = url.pathname;\n\n // If Url is ignored or already in cache, don't do any think\n if (this.ignoredURL(url) || pages.has(urlString)) return;\n this.emitter.emit(\"ANCHOR_HOVER HOVER\", event);\n\n try {\n pages.load(url);\n } catch (err) {\n console.warn(\"[PJAX] prefetch error,\", err);\n }\n }\n\n /** When History state changes, get url from State, go for a Transition. */\n public onStateChange(event: PopStateEvent): void {\n this.go({ href: window.location.href, trigger: \"popstate\", event });\n }\n\n /** Initialize DOM Events */\n public initEvents() {\n if (this.prefetchIgnore !== true) {\n document.addEventListener(\"mouseover\", this.onHover);\n document.addEventListener(\"touchstart\", this.onHover);\n }\n\n document.addEventListener(\"click\", this.onClick);\n window.addEventListener(\"popstate\", this.onStateChange);\n }\n\n /** Stop DOM Events */\n public stopEvents() {\n if (this.prefetchIgnore !== true) {\n document.removeEventListener(\"mouseover\", this.onHover);\n document.removeEventListener(\"touchstart\", this.onHover);\n }\n\n document.removeEventListener(\"click\", this.onClick);\n window.removeEventListener(\"popstate\", this.onStateChange);\n }\n}\n", "import { Service } from \"./service\";\nimport { Manager } from \"./manager\";\nimport { newURL, getHashedPath } from \"./url\";\nimport { IHistoryManager } from \"./history\";\n\nexport type RouteMethod = (...args: any) => any;\nexport type RouteStyle = string | RegExp | boolean;\nexport interface IRouteToFrom {\n to: RouteStyle,\n from: RouteStyle\n}\nexport type RoutePath = IRouteToFrom | RouteStyle;\nexport interface IRoute {\n path: RoutePath,\n method: RouteMethod\n}\n\n/** Controls what happens when certain url paths match a set of criteria */\nexport class Router extends Service {\n /** List of routes */\n protected routes: Manager;\n constructor(routes: IRoute[] = []) {\n super();\n this.routes = new Manager();\n for (let route of routes) {\n this.add(route);\n }\n }\n\n /** Add a new route to watch for */\n public add({ path, method }: IRoute): Router {\n let key = this.parse(path);\n this.routes.set(key, method);\n return this;\n }\n\n /** Convert strings into path match functions */\n public parsePath(path: RouteStyle): RegExp | boolean {\n if (typeof path === \"string\") return new RegExp(path, \"i\");\n else if (path instanceof RegExp || typeof path === \"boolean\")\n return path;\n throw \"[Router] only regular expressions, strings and booleans are accepted as paths.\";\n }\n\n /** Determines if a strings counts has a path */\n public isPath(input: RouteStyle): boolean {\n return (\n typeof input === \"string\" ||\n input instanceof RegExp ||\n typeof input === \"boolean\"\n );\n }\n\n /** Parse the multiple different formats for paths, into a { from, to } object */\n public parse(input: RoutePath): IRouteToFrom {\n let route = input as IRouteToFrom;\n let toFromPath: IRouteToFrom = {\n from: /(.*)/g,\n to: /(.*)/g,\n };\n\n if (this.isPath(input as RouteStyle))\n toFromPath = {\n from: true,\n to: input as RouteStyle,\n };\n else if (this.isPath(route.from) && this.isPath(route.to as RouteStyle))\n toFromPath = route;\n else\n throw \"[Router] path is neither a string, regular expression, or a { from, to } object.\";\n\n let { from, to } = toFromPath;\n return {\n from: this.parsePath(from),\n to: this.parsePath(to),\n };\n }\n\n /** Test if route paths are true, if so run their methods */\n public route() {\n if (this.manager.has(\"HistoryManager\")) {\n let history = this.manager.get(\"HistoryManager\") as IHistoryManager;\n let from: string = getHashedPath(newURL((history.length > 1 ? history.previous : history.current).url));\n let to: string = getHashedPath(newURL());\n\n this.routes.forEach((method: RouteMethod, path: IRouteToFrom) => {\n let fromRegExp = path.from as RegExp | boolean;\n let toRegExp = path.to as RegExp | boolean;\n\n if (\n typeof fromRegExp === \"boolean\" &&\n typeof toRegExp === \"boolean\"\n ) {\n throw `[Router] path ({ from: ${fromRegExp}, to: ${toRegExp} }) is not valid, remember paths can only be strings, regular expressions, or a boolean; however, both the from and to paths cannot be both booleans.`;\n }\n\n let fromParam: RegExpExecArray | RegExp | boolean = fromRegExp;\n let toParam: RegExpExecArray | RegExp | boolean = toRegExp;\n\n if (fromRegExp instanceof RegExp && fromRegExp.test(from))\n fromParam = fromRegExp.exec(from);\n if (toRegExp instanceof RegExp && toRegExp.test(to))\n toParam = toRegExp.exec(to);\n\n if (\n (Array.isArray(toParam) && Array.isArray(fromParam)) ||\n (Array.isArray(toParam) &&\n typeof fromParam == \"boolean\" &&\n fromParam) ||\n (Array.isArray(fromParam) &&\n typeof toParam == \"boolean\" &&\n toParam)\n )\n method({ from: fromParam, to: toParam, path: { from, to } });\n });\n } else {\n console.warn(\"[Route] HistoryManager is missing.\");\n }\n }\n\n /** Add listeners for PJAX Events */\n public initEvents() {\n this.emitter.on(\"READY\", this.route, this);\n this.emitter.on(\"CONTENT_REPLACED\", this.route, this);\n }\n\n /** Remove listeners for PJAX Events */\n public stopEvents() {\n this.emitter.off(\"READY\", this.route, this);\n this.emitter.off(\"CONTENT_REPLACED\", this.route, this);\n }\n}\n", "import { EventEmitter, EventInput, ListenerCallback } from \"@okikio/emitter\";\nimport { Manager } from \"@okikio/manager\";\n\n// DOM\nexport type AnimationTarget = string | Node | NodeList | HTMLCollection | HTMLElement[] | AnimationTarget[];\nexport const getElements = (selector: string | Node): Node[] => {\n return typeof selector === \"string\" ? Array.from(document.querySelectorAll(selector as string)) : [selector];\n};\n\nconst flatten = (arr: AnimationTarget[]) => [].concat(...arr);\nexport const getTargets = (targets: AnimationTarget): Node[] => {\n if (Array.isArray(targets)) {\n return flatten((targets as AnimationTarget[]).map(getTargets));\n }\n if (typeof targets == \"string\" || targets instanceof Node)\n return getElements(targets);\n if (targets instanceof NodeList || targets instanceof HTMLCollection)\n return Array.from(targets);\n return [];\n};\n\n// VALUES\nexport type closureArgs = [number, number, HTMLElement];\nexport type closure = ((index?: number, total?: number, element?: HTMLElement) => (genericTypes[] | void)) | any;\nexport const computeValue = (value: closure, args: closureArgs, context: Animate) => {\n if (typeof value === \"function\") {\n return value.apply(context, args);\n } else { return value; }\n};\n\nexport const mapObject = (obj: object, args: closureArgs, options: Animate): any => {\n let key: string, value: any, result = {};\n let keys = Object.keys(obj);\n for (let i = 0, len = keys.length; i < len; i++) {\n key = keys[i];\n value = obj[key];\n result[key] = computeValue(value, args, options);\n }\n\n return result;\n};\n\n/** From: [https://easings.net] */\nexport const easings = {\n \"in\": \"ease-in\",\n \"out\": \"ease-out\",\n \"in-out\": \"ease-in-out\",\n\n // Sine\n \"in-sine\": \"cubic-bezier(0.47, 0, 0.745, 0.715)\",\n \"out-sine\": \"cubic-bezier(0.39, 0.575, 0.565, 1)\",\n \"in-out-sine\": \"cubic-bezier(0.445, 0.05, 0.55, 0.95)\",\n\n // Quad\n \"in-quad\": \"cubic-bezier(0.55, 0.085, 0.68, 0.53)\",\n \"out-quad\": \"cubic-bezier(0.25, 0.46, 0.45, 0.94)\",\n \"in-out-quad\": \"cubic-bezier(0.455, 0.03, 0.515, 0.955)\",\n\n // Cubic\n \"in-cubic\": \"cubic-bezier(0.55, 0.055, 0.675, 0.19)\",\n \"out-cubic\": \"cubic-bezier(0.215, 0.61, 0.355, 1)\",\n \"in-out-cubic\": \"cubic-bezier(0.645, 0.045, 0.355, 1)\",\n\n // Quart\n \"in-quart\": \"cubic-bezier(0.895, 0.03, 0.685, 0.22)\",\n \"out-quart\": \"cubic-bezier(0.165, 0.84, 0.44, 1)\",\n \"in-out-quart\": \"cubic-bezier(0.77, 0, 0.175, 1)\",\n\n // Quint\n \"in-quint\": \"cubic-bezier(0.755, 0.05, 0.855, 0.06)\",\n \"out-quint\": \"cubic-bezier(0.23, 1, 0.32, 1)\",\n \"in-out-quint\": \"cubic-bezier(0.86, 0, 0.07, 1)\",\n\n // Expo\n \"in-expo\": \"cubic-bezier(0.95, 0.05, 0.795, 0.035)\",\n \"out-expo\": \"cubic-bezier(0.19, 1, 0.22, 1)\",\n \"in-out-expo\": \"cubic-bezier(1, 0, 0, 1)\",\n\n // Circ\n \"in-circ\": \"cubic-bezier(0.6, 0.04, 0.98, 0.335)\",\n \"out-circ\": \"cubic-bezier(0.075, 0.82, 0.165, 1)\",\n \"in-out-circ\": \"cubic-bezier(0.785, 0.135, 0.15, 0.86)\",\n\n // Back\n \"in-back\": \"cubic-bezier(0.6, -0.28, 0.735, 0.045)\",\n \"out-back\": \"cubic-bezier(0.175, 0.885, 0.32, 1.275)\",\n \"in-out-back\": \"cubic-bezier(0.68, -0.55, 0.265, 1.55)\"\n};\n\nexport const getEase = (ease: string) => {\n return /^(in|out)/.test(ease) ? easings[ease] : ease;\n};\n\nexport type genericTypes = genericTypes[] | boolean | object | string | number | closure | null | undefined;\nexport interface AnimationOptions {\n target?: AnimationTarget,\n\n speed?: number,\n autoplay?: boolean,\n options?: AnimationOptions,\n delay?: number | closure,\n easing?: string | closure,\n endDelay?: number | closure,\n duration?: number | closure,\n keyframes?: Keyframe[] | object[] | closure,\n loop?: number | boolean | closure, // iterations: number,\n onfinish?: (element?: HTMLElement, index?: number, total?: number, animation?: Animation) => any,\n fillMode?: \"none\" | \"forwards\" | \"backwards\" | \"both\" | \"auto\" | closure,\n direction?: \"normal\" | \"reverse\" | \"alternate\" | \"alternate-reverse\" | closure,\n extend?: EffectTiming,\n [property: string]: genericTypes;\n};\n\nexport const DefaultAnimationOptions: AnimationOptions = {\n keyframes: [],\n\n loop: 1, // iterations: number,\n delay: 0,\n speed: 1,\n endDelay: 0,\n easing: \"ease\",\n autoplay: true,\n duration: 1000,\n fillMode: \"auto\",\n direction: \"normal\",\n extend: {}\n};\n\nexport type AnimationEvents = \"update\" | \"play\" | \"pause\" | \"start\" | \"begin\" | \"complete\" | \"finish\" | \"error\" | \"stop\";\n\n/** You can check it out here: https://codepen.io/okikio/pen/qBbdGaW?editors=0011 */\nexport class Animate {\n /**\n * Stores the options for the current animation\n */\n public options: AnimationOptions = {};\n\n /**\n * The Array of Elements to Animate\n */\n public targets: Node[] = [];\n\n /**\n * The properties to animate\n */\n public properties: object = {};\n\n /**\n * A Manager of Animations\n */\n public animations: Manager = new Manager();\n\n /**\n * The total duration of all Animation's\n */\n public totalDuration: number = 0;\n\n /**\n * The smallest delay out of all Animation's\n */\n public minDelay: number = 0;\n\n /**\n * The options for individual animations\n */\n public computedOptions: Manager = new Manager();\n\n /**\n * The Element the main animation uses\n */\n public mainElement: HTMLElement;\n\n /**\n * Stores an animation that runs on the total duration of the all other Animations, and as such it's the main Animation\n */\n public mainAnimation: Animation;\n\n /**\n * Stores request frame calls\n */\n public animationFrame: number;\n\n /**\n * An event emitter\n */\n public emitter: EventEmitter = new EventEmitter();\n\n /**\n * Returns a promise that is fulfilled when the mainAnimation is finished\n */\n public promise: Promise;\n constructor(options: AnimationOptions = {}) {\n try {\n let { options: animation, ...rest } = options;\n let oldOptions = animation instanceof Animate ? animation.getOptions() : (Array.isArray(animation) ? animation?.[0]?.getOptions() : animation);\n this.options = Object.assign({}, DefaultAnimationOptions, oldOptions, rest);\n this.loop = this.loop.bind(this);\n\n let {\n loop,\n delay,\n speed,\n easing,\n endDelay,\n duration,\n direction,\n fillMode,\n onfinish,\n target,\n keyframes,\n autoplay,\n extend,\n ...properties\n } = this.options;\n\n this.mainElement = document.createElement(\"div\");\n this.targets = getTargets(target);\n this.properties = properties;\n\n let delays = [];\n let len = this.targets.length;\n let animationKeyframe: Keyframe[] | PropertyIndexedKeyframes;\n for (let i = 0; i < len; i++) {\n let target = this.targets[i] as HTMLElement;\n let animationOptions: AnimationOptions = {\n easing: typeof easing == \"string\" ? getEase(easing) : easing,\n iterations: loop === true ? Infinity : (loop as number),\n direction,\n endDelay,\n duration,\n delay,\n fill: fillMode,\n ...extend\n };\n\n // Accept keyframes as a keyframes Object, or a method,\n // if there are no animations in the keyframes array,\n // uses css properties from the options object\n let arrKeyframes = computeValue((keyframes as Keyframe[]), [i, len, target], this);\n animationKeyframe = arrKeyframes.length ? arrKeyframes :\n (this.properties as PropertyIndexedKeyframes);\n\n // Allows the use of functions as the values, for both the keyframes and the animation object\n // It adds the capability of advanced stagger animation, similar to the anime js stagger functions\n animationOptions = mapObject(animationOptions, [i, len, target], this);\n if (!(arrKeyframes.length > 0))\n animationKeyframe = mapObject(animationKeyframe, [i, len, target], this);\n\n // Set the Animate classes duration to be the Animation with the largest totalDuration\n let tempDurations = animationOptions.delay +\n (animationOptions.duration * animationOptions.iterations) +\n animationOptions.endDelay;\n if (this.totalDuration < tempDurations) this.totalDuration = tempDurations;\n\n // Add animation to the Animations Set\n let animation = target.animate(animationKeyframe, animationOptions as KeyframeAnimationOptions);\n\n // Support for on finish\n animation.onfinish = () => {\n typeof onfinish == \"function\" && onfinish.call(this, target, i, len, animation);\n this.emit(\"finish\", target, i, len, animation);\n };\n\n // The calculated options for each individual option\n this.computedOptions.set(animation, animationOptions);\n this.animations.set(target, animation);\n delays.push(animationOptions.delay);\n }\n\n this.mainAnimation = this.mainElement.animate([\n { opacity: \"0\" },\n { opacity: \"1\" }\n ], {\n // Why waste performance on an animation no one can see?\n duration: this.totalDuration,\n easing: \"linear\"\n });\n\n this.minDelay = Math.min(...delays);\n this.setSpeed(speed);\n if (autoplay) this.play();\n else this.pause();\n\n this.promise = this.newPromise();\n this.mainAnimation.onfinish = () => {\n this.emit(\"complete\", this);\n this.stopLoop();\n };\n } catch (err) {\n this.emit(\"error\", err);\n }\n }\n\n /**\n * Returns a new Promise that is resolve when this.finish is called\n */\n public newPromise(): Promise {\n return new Promise((resolve, reject) => {\n /*\n Note that the `this` keyword is in an Array when it is resolved,\n this is due to Promises not wanting to resolve references,\n so, you can't resolve `this` directly, so, I chose to resolve `this` in an\n Array\n */\n this.on(\"complete\", () => resolve([this]));\n this.on(\"error\", err => reject(err));\n });\n }\n\n /**\n * Fulfills the this.promise Promise\n */\n public then(\n onFulfilled?: (value?: any) => any,\n onRejected?: (reason?: any) => any\n ): Animate {\n onFulfilled = onFulfilled?.bind(this);\n onRejected = onRejected?.bind(this);\n this.promise.then(onFulfilled, onRejected);\n return this;\n }\n\n /**\n * Catches error that occur in the this.promise Promise\n */\n public catch(onRejected: (reason?: any) => any): Animate {\n onRejected = onRejected?.bind(this);\n this.promise.catch(onRejected);\n return this;\n }\n\n /**\n * If you don't care if the this.promise Promise has either been rejected or resolved\n */\n public finally(onFinally: () => any): Animate {\n onFinally = onFinally?.bind(this);\n this.promise.finally(onFinally);\n return this;\n }\n\n /**\n * Represents an Animation Frame Loop\n */\n public loop(): void {\n this.stopLoop();\n this.emit(\"update\", this.getProgress(), this);\n this.animationFrame = window.requestAnimationFrame(this.loop);\n }\n\n /**\n * Cancels animation frame\n */\n public stopLoop() {\n window.cancelAnimationFrame(this.animationFrame);\n }\n\n /**\n * Calls a method that affects all animations including the mainAnimation; the method only allows the animation parameter\n */\n public all(method: (animation?: Animation, target?: HTMLElement) => void) {\n method(this.mainAnimation, this.mainElement);\n this.animations.forEach(method);\n return this;\n }\n\n /**\n * Register the begin event\n */\n protected beginEvent() {\n if (this.getProgress() == 0) {\n let timer: number | void = window.setTimeout(() => {\n this.emit(\"begin\", this);\n timer = window.clearTimeout(timer as number);\n }, this.minDelay);\n }\n }\n\n /**\n * Play Animation\n */\n public play(): Animate {\n let playstate = this.getPlayState();\n this.beginEvent();\n this.all(anim => anim.play());\n this.emit(\"play\", playstate, this);\n this.loop();\n return this;\n }\n\n /**\n * Pause Animation\n */\n public pause(): Animate {\n let playstate = this.getPlayState();\n this.all(anim => anim.pause());\n this.emit(\"pause\", playstate, this);\n this.stopLoop();\n this.animationFrame = undefined;\n return this;\n }\n\n /**\n * Reset all Animations\n */\n public reset() {\n this.setProgress(0);\n this.beginEvent();\n\n if (this.options.autoplay) this.play();\n else this.pause();\n return this;\n }\n\n /**\n * Cancels all Animations\n */\n public cancel() {\n this.all(anim => anim.cancel());\n this.stopLoop();\n return this;\n }\n\n /**\n * Force complete all Animations\n */\n public finish() {\n this.all(anim => anim.finish());\n this.stopLoop();\n return this;\n }\n\n /**\n * Cancels & Clears all Animations\n */\n public stop() {\n this.cancel();\n this.animations.clear();\n while (this.targets.length) this.targets.pop();\n this.mainElement = undefined;\n this.emit(\"stop\");\n }\n\n /**\n * Returns an Array of targets\n */\n public getTargets(): Node[] {\n return this.targets;\n }\n\n /**\n * Get a specific Animation from an Animate instance\n */\n public getAnimation(element: HTMLElement): Animation {\n return this.animations.get(element);\n }\n\n /**\n * Returns the timings of an Animation, given a target\n * E.g. { duration, endDelay, delay, iterations, iterationStart, direction, easing, fill, etc... }\n */\n public getTiming(target: HTMLElement | Animation): AnimationOptions & EffectTiming {\n let animation = target instanceof Animation ? target : this.getAnimation(target);\n let keyframeOptions = this.computedOptions.get(animation) ?? {};\n let timings = animation.effect?.getTiming() ?? {};\n let options = this.getOptions();\n\n return { ...DefaultAnimationOptions, ...options, ...timings, ...keyframeOptions };\n }\n\n /**\n * Returns the total duration of Animation\n */\n public getTotalDuration(): number {\n return this.totalDuration;\n }\n\n /**\n * Returns the current time of the Main Animation\n */\n public getCurrentTime(): number {\n return this.mainAnimation.currentTime;\n }\n\n /**\n * Returns the Animation progress as a fraction of the current time / duration * 100\n */\n public getProgress() {\n return (this.getCurrentTime() / this.totalDuration) * 100;\n }\n\n /**\n * Return the playback speed of the animation\n */\n public getSpeed(): number {\n return this.mainAnimation.playbackRate;\n }\n\n /**\n * Returns the current playing state\n */\n public getPlayState(): \"idle\" | \"running\" | \"paused\" | \"finished\" {\n return this.mainAnimation.playState;\n }\n\n /**\n * Get the options of an Animate instance\n */\n public getOptions(): AnimationOptions {\n return this.options;\n }\n\n /**\n * Set the current time of the Main Animation\n */\n public setCurrentTime(time: number): Animate {\n this.all(anim => { anim.currentTime = time; });\n this.emit(\"update\", this.getProgress());\n return this;\n }\n\n /**\n * Set the Animation progress as a value from 0 to 100\n */\n public setProgress(percent: number): Animate {\n let time = (percent / 100) * this.totalDuration;\n this.setCurrentTime(time);\n return this;\n }\n\n /**\n * Set the playback speed of an Animation\n */\n public setSpeed(speed: number = 1): Animate {\n this.all(anim => { anim.playbackRate = speed; });\n return this;\n }\n\n /**\n * Adds a listener for a given event\n */\n public on(events: AnimationEvents | EventInput, callback?: ListenerCallback, scope?: object): Animate {\n this.emitter.on(events, callback, scope ?? this);\n return this;\n }\n\n /**\n * Removes a listener from an event\n */\n public off(events: AnimationEvents | EventInput, callback?: ListenerCallback, scope?: object): Animate {\n this.emitter.off(events, callback, scope ?? this);\n return this;\n }\n\n /**\n * Call all listeners within an event\n */\n public emit(events: AnimationEvents | string | any[], ...args: any): Animate {\n this.emitter.emit(events, ...args);\n return this;\n }\n\n\n /** Returns the Animate options, as JSON */\n public toJSON(): AnimationOptions {\n return this.getOptions();\n }\n\n /**\n * The Symbol.toStringTag well-known symbol is a string valued property that is used\n * in the creation of the default string description of an object.\n * It is accessed internally by the Object.prototype.toString() method.\n */\n get [Symbol.toStringTag]() {\n return `Animate`;\n }\n}\n\n/** Creates a new Animate instance */\nexport const animate = (options: AnimationOptions = {}): Animate => {\n return new Animate(options);\n};\n\nexport class Timeline extends Animate {\n /**\n * A Manager of Animations\n */\n public animations: Manager = new Manager();\n constructor(options: AnimationOptions = {}) {\n super();\n try {\n let { options: animation, ...rest } = options;\n let oldOptions = animation instanceof Animate ? animation.getOptions() : (Array.isArray(animation) ? animation?.[0]?.getOptions() : animation);\n this.options = Object.assign({}, DefaultAnimationOptions, oldOptions, rest);\n this.loop = this.loop.bind(this);\n\n let {\n loop,\n delay,\n speed,\n easing,\n endDelay,\n duration,\n direction,\n fillMode,\n onfinish,\n target,\n keyframes,\n autoplay,\n extend,\n ...properties\n } = this.options;\n\n this.mainElement = document.createElement(\"div\");\n this.targets = getTargets(target);\n this.properties = properties;\n\n let delays = [];\n let len = this.targets.length;\n let animationKeyframe: Keyframe[] | PropertyIndexedKeyframes;\n for (let i = 0; i < len; i++) {\n let target = this.targets[i] as HTMLElement;\n let animationOptions: AnimationOptions = {\n easing: typeof easing == \"string\" ? getEase(easing) : easing,\n iterations: loop === true ? Infinity : (loop as number),\n direction,\n endDelay,\n duration,\n delay,\n fill: fillMode,\n ...extend\n };\n\n // Accept keyframes as a keyframes Object, or a method,\n // if there are no animations in the keyframes array,\n // uses css properties from the options object\n let arrKeyframes = computeValue((keyframes as Keyframe[]), [i, len, target], this);\n animationKeyframe = arrKeyframes.length ? arrKeyframes :\n (this.properties as PropertyIndexedKeyframes);\n\n // Allows the use of functions as the values, for both the keyframes and the animation object\n // It adds the capability of advanced stagger animation, similar to the anime js stagger functions\n animationOptions = mapObject(animationOptions, [i, len, target], this);\n if (!(arrKeyframes.length > 0))\n animationKeyframe = mapObject(animationKeyframe, [i, len, target], this);\n\n // Set the Animate classes duration to be the Animation with the largest totalDuration\n let tempDurations = animationOptions.delay +\n (animationOptions.duration * animationOptions.iterations) +\n animationOptions.endDelay;\n if (this.totalDuration < tempDurations) this.totalDuration = tempDurations;\n\n // Add animation to the Animations Set\n let animation = target.animate(animationKeyframe, animationOptions as KeyframeAnimationOptions);\n\n // Support for on finish\n animation.onfinish = () => {\n typeof onfinish == \"function\" && onfinish.call(this, target, i, len, animation);\n this.emit(\"finish\", target, i, len, animation);\n };\n\n // The calculated options for each individual option\n this.computedOptions.set(animation, animationOptions);\n this.animations.set(target, animation);\n delays.push(animationOptions.delay);\n }\n\n this.mainAnimation = this.mainElement.animate([\n { opacity: \"0\" },\n { opacity: \"1\" }\n ], {\n // Why waste performance on an animation no one can see?\n duration: this.totalDuration,\n easing: \"linear\"\n });\n\n this.minDelay = Math.min(...delays);\n this.setSpeed(speed);\n if (autoplay) this.play();\n else this.pause();\n\n this.promise = this.newPromise();\n this.mainAnimation.onfinish = () => {\n this.emit(\"complete\", this);\n this.stopLoop();\n };\n } catch (err) {\n this.emit(\"error\", err);\n }\n }\n public add(options: AnimationOptions) {\n return this;\n }\n}\n\nexport default animate;", "import { Service, animate } from \"../../../packages/native/src/api\";\n\nexport class Splashscreen extends Service {\n public rootElement: HTMLElement;\n public innerEl: HTMLElement;\n public bgEl: HTMLElement;\n public minimalDuration: number = 1000; // ms\n spinnerEl: Element[];\n\n public init() {\n super.init();\n\n // Elements\n this.rootElement = document.getElementById('splashscreen');\n if (this.rootElement) {\n this.innerEl = this.rootElement.querySelector('.splashscreen-inner');\n this.bgEl = this.rootElement.querySelector('.splashscreen-bg');\n this.spinnerEl = [...this.rootElement.querySelectorAll('.spinner')];\n }\n\n this.rootElement.style.visibility = \"visible\";\n this.rootElement.style.pointerEvents = \"auto\";\n }\n\n public boot() {\n if (this.rootElement) {\n this.hide();\n }\n }\n\n public async hide() {\n await new Promise(resolve => {\n window.setTimeout(() => {\n this.emitter.emit(\"BEFORE_SPLASHSCREEN_HIDE\");\n resolve();\n }, this.minimalDuration);\n });\n\n await new Promise(async resolve => {\n animate({\n target: this.innerEl,\n opacity: [1, 0],\n autoplay: true,\n duration: 500,\n onfinish(el) {\n el.style.opacity = \"0\";\n }\n }).then(function () {\n this.stop();\n });\n\n this.emitter.emit(\"START_SPLASHSCREEN_HIDE\");\n await this.show();\n resolve();\n });\n }\n\n public async show() {\n let [anim] = await animate({\n target: this.rootElement,\n transform: [\"translateY(0%)\", \"translateY(100%)\"],\n duration: 1200,\n easing: \"in-out-cubic\" // in-out-cubic\n });\n this.emitter.emit(\"AFTER_SPLASHSCREEN_HIDE\");\n anim.stop();\n\n this.rootElement.style.transform = \"translateY(100%)\";\n this.rootElement.style.visibility = \"hidden\";\n this.rootElement.style.pointerEvents = \"none\";\n }\n}\n", "import { Service, animate } from \"../../../packages/native/src/api\";\n\nexport class IntroAnimation extends Service {\n public elements: Array;\n public rootElement: HTMLElement;\n\n public init() {\n super.init();\n\n // Elements\n this.elements = [...document.querySelectorAll('.intro-animation')];\n }\n\n public newPage() {\n this.init();\n this.prepareToShow();\n }\n\n public initEvents() {\n this.emitter.on(\"BEFORE_SPLASHSCREEN_HIDE\", this.prepareToShow, this);\n this.emitter.on(\"CONTENT_REPLACED\", this.newPage, this);\n this.emitter.on(\"START_SPLASHSCREEN_HIDE BEFORE_TRANSITION_IN\", this.show, this);\n }\n\n public stopEvents() {\n this.emitter.off(\"BEFORE_SPLASHSCREEN_HIDE\", this.prepareToShow, this);\n this.emitter.off(\"CONTENT_REPLACED\", this.newPage, this);\n this.emitter.off(\"START_SPLASHSCREEN_HIDE BEFORE_TRANSITION_IN\", this.show, this);\n }\n\n public stop() {\n requestAnimationFrame(() => {\n for (let el of this.elements) {\n (el as HTMLElement).style.transform = \"translateY(0px)\";\n (el as HTMLElement).style.opacity = '1';\n }\n });\n\n super.stop();\n }\n\n public prepareToShow() {\n requestAnimationFrame(() => {\n for (let el of this.elements) {\n (el as HTMLElement).style.transform = \"translateY(200px)\";\n (el as HTMLElement).style.opacity = '0';\n }\n });\n }\n\n public async show() {\n let [anim] = await animate({\n target: (this.elements as HTMLElement[]),\n keyframes: [\n { transform: \"translateY(200px)\", opacity: 0 },\n { transform: \"translateY(0px)\", opacity: 1 },\n ],\n // @ts-ignore\n delay(i: number) {\n return 300 * (i + 1);\n },\n onfinish(el: { style: { transform: string; opacity: string; }; }) {\n requestAnimationFrame(() => {\n el.style.transform = \"translateY(0px)\";\n el.style.opacity = \"1\";\n });\n },\n easing: \"out-cubic\",\n duration: 650\n });\n anim.stop();\n return anim;\n }\n}\n", "import { ITransition, ITransitionData, animate } from \"../../../packages/native/src/api\";\n\n//== Transition\nexport const Fade: ITransition = {\n name: \"default\",\n duration: 500,\n scrollable: true,\n\n out({ from }: ITransitionData) {\n let { duration } = this;\n let fromWrapper = from.wrapper;\n return animate({\n target: fromWrapper,\n opacity: [1, 0],\n duration,\n }).on(\"finish\", function () {\n this.stop();\n });\n },\n\n in({ to, scroll }: ITransitionData) {\n let { duration } = this;\n let toWrapper = to.wrapper;\n\n window.scroll(scroll.x, scroll.y);\n return animate({\n target: toWrapper,\n opacity: [0, 1],\n duration\n }).then(function () {\n this.stop();\n });\n }\n};\n", "import { ITransition, ITransitionData, animate } from \"../../../packages/native/src/api\";\n\n//== Transitions\nexport const BigTransition: ITransition = {\n name: \"big\",\n delay: 200,\n durationPerAnimation: 700,\n scrollable: true,\n\n init() {\n this.mainElement = document.getElementById('big-transition');\n this.spinnerElement = this.mainElement.querySelector('.spinner');\n this.horizontalElements = [...this.mainElement.querySelector('#big-transition-horizontal').querySelectorAll('div')];\n this.maxLength = this.horizontalElements.length;\n },\n\n out({ from, scroll }: ITransitionData) {\n let { durationPerAnimation: duration, delay } = this;\n let fromWrapper = from.wrapper;\n\n window.scroll(scroll.x, scroll.y);\n let wrapperStyle = Object.assign({}, fromWrapper.style);\n return new Promise(async resolve => {\n this.mainElement.style.opacity = \"1\";\n this.mainElement.style.visibility = \"visible\";\n let anim1 = animate({\n target: fromWrapper,\n opacity: [1, 0],\n duration,\n onfinish(el: { style: { opacity: string; }; }) {\n el.style.opacity = '0';\n }\n });\n\n anim1.then(function () { this.stop(); });\n\n let [anim2] = await animate({\n target: this.horizontalElements,\n keyframes: [\n { transform: \"scaleX(0)\" },\n { transform: \"scaleX(1)\" },\n ],\n // @ts-ignore\n delay(i: number) {\n return delay * (i + 1);\n },\n onfinish(el: { style: { transform: string; }; }) {\n el.style.transform = `scaleX(1)`;\n },\n easing: \"out-cubic\",\n duration: 500\n });\n\n fromWrapper.style.opacity = '1';\n Object.assign(fromWrapper.style, wrapperStyle);\n this.spinnerElement.style.visibility = \"visible\";\n\n let loaderDuration = 500;\n let [anim3] = await animate({\n target: this.spinnerElement,\n opacity: [0, 1],\n duration: loaderDuration,\n onfinish(el: { style: { opacity: string; }; }) {\n el.style.opacity = `1`;\n },\n });\n\n let [anim4] = await animate({\n options: anim3,\n opacity: [1, 0],\n onfinish(el: { style: { opacity: string; }; }) {\n el.style.opacity = `0`;\n },\n delay: 1500\n });\n this.spinnerElement.style.visibility = \"hidden\";\n // anim2.stop() // -> anim2.stop() Breaks the Animation\n anim3.stop();\n anim4.stop();\n resolve();\n });\n },\n\n in({ to, scroll }: ITransitionData) {\n let { durationPerAnimation: duration, delay } = this;\n let toWrapper = to.wrapper;\n\n window.scroll(scroll.x, scroll.y);\n return new Promise(async resolve => {\n let anim1 = animate({\n target: toWrapper,\n opacity: [0, 1],\n duration\n }).then(() => {\n anim1.stop();\n });\n\n let [anim2] = await animate({\n target: this.horizontalElements,\n keyframes: [\n { transform: \"scaleX(1)\" },\n { transform: \"scaleX(0)\" },\n ],\n // @ts-ignore\n delay(i: number) {\n return delay * (i + 1);\n },\n onfinish(el: { style: { transform: string; }; }) {\n el.style.transform = `scaleX(0)`;\n },\n easing: \"out-cubic\",\n duration: 500\n });\n\n this.mainElement.style.opacity = \"0\";\n this.mainElement.style.visibility = \"hidden\";\n anim2.stop();\n resolve();\n });\n }\n}\n", "import { ITransition, ITransitionData, animate } from \"../../../packages/native/src/api\";\n\n//== Transitions\nexport const Slide: ITransition = {\n name: \"slide\",\n duration: 500,\n direction: \"right\",\n scrollable: true,\n\n init(data: ITransition) {\n let trigger = (data.trigger as HTMLElement);\n if (trigger instanceof Node && trigger.hasAttribute(\"data-direction\")) {\n this.direction = trigger.getAttribute(\"data-direction\");\n } else {\n this.direction = \"right\";\n }\n },\n\n out({ from }: ITransitionData) {\n let { duration, direction } = this;\n let fromWrapper = from.wrapper;\n\n return animate({\n target: fromWrapper,\n keyframes: [\n { transform: \"translateX(0%)\", opacity: 1 },\n { transform: `translateX(${direction === \"left\" ? \"-\" : \"\"}25%)`, opacity: 0 },\n ],\n duration,\n easing: \"in-quint\"\n }).then(function () {\n this.stop();\n });\n },\n\n in({ to, scroll }: ITransitionData) {\n let { duration } = this;\n let toWrapper = to.wrapper;\n\n window.scroll(scroll.x, scroll.y);\n return animate({\n target: toWrapper,\n keyframes: [\n { transform: `translateX(${this.direction === \"right\" ? \"-\" : \"\"}25%)`, opacity: 0 },\n { transform: \"translateX(0%)\", opacity: 1 },\n ],\n duration,\n easing: \"out-quint\"\n }).then(function () {\n this.stop();\n });\n }\n};\n\nexport const SlideLeft: ITransition = {\n ...Slide,\n\n name: \"slide-left\",\n direction: \"left\",\n init(data: ITransition) { }\n};\n\nexport const SlideRight: ITransition = {\n ...Slide,\n\n name: \"slide-right\",\n direction: \"right\",\n init(data: ITransition) { }\n};\n", "import { PJAX, App, TransitionManager, Router, HistoryManager, PageManager, animate, Animate } from \"@okikio/native\";\n\nimport { Splashscreen } from \"./services/Splashscreen\";\nimport { IntroAnimation } from \"./services/IntroAnimation\";\n\nimport { Fade } from \"./transitions/Fade\";\nimport { BigTransition } from \"./transitions/BigTransition\";\nimport { Slide, SlideLeft, SlideRight } from \"./transitions/Slide\";\n\nlet splashscreen: Splashscreen;\nlet router: Router, pjax: PJAX;\nconst app: App = new App();\napp\n .add(new IntroAnimation())\n .add(splashscreen = new Splashscreen())\n .set(\"HistoryManager\", new HistoryManager())\n .set(\"PageManager\", new PageManager())\n .set(\"TransitionManager\", new TransitionManager([\n [\"default\", Fade],\n [\"BigTransition\", BigTransition],\n [\"Slide\", Slide],\n [\"SlideLeft\", SlideLeft],\n [\"SlideRight\", SlideRight]\n ]))\n .set(\"router\", router = new Router())\n .add(pjax = new PJAX());\n\ntry {\n router = app.get(\"router\") as Router;\n\n // This isn't nessceary, but it changes the nav link in focus depending on the page\n let navLink = document.querySelectorAll(\".navbar .nav-link\");\n for (let item of navLink) {\n let navItem = (item as HTMLAnchorElement);\n router.add({\n path: navItem.getAttribute(\"data-path\") || navItem.pathname,\n method() {\n let isActive = navItem.classList.contains(\"active\");\n if (!isActive) navItem.classList.add(\"active\");\n for (let nav of navLink) {\n if (nav !== navItem)\n nav.classList.remove(\"active\");\n }\n }\n });\n }\n\n let anim: Animate;\n router.add({\n path: /(index|\\/$)(\\.html)?/,\n method() {\n anim = animate({\n target: \".div\",\n keyframes(index, total) {\n return [\n { transform: \"translateX(0px)\", opacity: 0.1 },\n { transform: \"translateX(300px)\", opacity: 0.2 + ((index + 1) / total) }\n ]\n },\n\n /* You can uncomment this out, and comment the keyframes options above and still get the same animation */\n // transform: [\"translateX(0px)\", \"translateX(300px)\"],\n // opacity(index, total, element) {\n // return [0, ((index + 1) / total)];\n // },\n\n // It is best to use the onfinish() method, but in this situation fillMode works best\n fillMode: \"both\",\n // onfinish(element, index, total) {\n // element.style.opacity = `${((index + 1) / total)}`;\n // element.style.transform = \"translateX(300px)\";\n // },\n\n easing: \"out-cubic\",\n duration(index: number) {\n return (index + 1) * 500;\n },\n loop: 5,\n speed: 1.5,\n direction: \"alternate\",\n delay(index: number) {\n return ((index + 1) * 500) / 2;\n },\n autoplay: false\n });\n\n let el: HTMLElement = document.querySelector(\".info\");\n let backupInfo = el.textContent;\n let info = backupInfo;\n anim.on({\n begin() {\n if (el) {\n info = backupInfo;\n el.textContent = info;\n el.style.color = \"initial\";\n }\n }\n })\n anim.on(\"complete\", () => {\n if (el) {\n info = \"Done.\";\n el.textContent = info;\n el.style.color = \"red\";\n\n console.log(info);\n }\n });\n\n let scrub = document.getElementById('scrub') as HTMLInputElement;\n scrub.addEventListener('input', e => {\n var percent = +(e.target as HTMLInputElement).value;\n anim.setProgress(percent);\n anim.pause();\n });\n\n let progressSpan = document.querySelector(\".progress\");\n anim.on(\"update\", progress => {\n scrub.value = `` + progress;\n progressSpan && (progressSpan.textContent = `${Math.round(progress)}%`);\n });\n\n scrub.addEventListener('change', () => {\n if (Math.round(anim.getProgress()) >= 100) {\n anim.finish();\n return false;\n }\n anim.play();\n });\n\n\n let playtoggle = document.querySelector(\".playtoggle\");\n if (playtoggle) {\n playtoggle.addEventListener(\"click\", () => {\n let state = anim.getPlayState();\n if (state === \"running\") anim.pause();\n else if (state === \"finished\") anim.reset();\n else anim.play();\n console.log(state);\n });\n }\n }\n });\n\n app.on(\"AFTER_SPLASHSCREEN_HIDE\", () => {\n anim?.play();\n });\n\n app.boot();\n} catch (err) {\n splashscreen.show();\n console.warn(\"[App] boot failed,\", err);\n}\n"], + "mappings": "sgBAeO,GAAM,IAAkB,CAC3B,YAAa,UACb,eAAgB,eAChB,eAAgB,cAChB,QAAS,CACL,CAAC,YAAa,SAElB,gBAAiB,iBACj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AK,GAAG,SAAU,GAAY,CAC1B,EAAM,MAAQ,GAAK,EACnB,GAAiB,GAAa,YAAc,GAAG,KAAK,MAAM,SAG9D,EAAM,iBAAiB,SAAU,IAAM,CACnC,GAAI,KAAK,MAAM,EAAK,gBAAkB,IAClC,SAAK,SACE,GAEX,EAAK,SAIT,GAAI,GAAa,SAAS,cAAc,eACxC,AAAI,GACA,EAAW,iBAAiB,QAAS,IAAM,CACvC,GAAI,GAAQ,EAAK,eACjB,AAAI,IAAU,UAAW,EAAK,QACzB,AAAI,IAAU,WAAY,EAAK,QAC/B,EAAK,OACV,QAAQ,IAAI,QAM5B,EAAI,GAAG,0BAA2B,IAAM,CACpC,WAAM,SAGV,EAAI,aACC,EAAP,CACE,GAAa,OACb,QAAQ,KAAK,qBAAsB", + "names": [] +} diff --git a/packages/animate/src/api.ts b/packages/animate/src/api.ts index 1898955..57aa9e6 100644 --- a/packages/animate/src/api.ts +++ b/packages/animate/src/api.ts @@ -357,9 +357,9 @@ export class Animate { /** * Calls a method that affects all animations including the mainAnimation; the method only allows the animation parameter */ - public all(method: (animation: Animation) => void) { - method(this.mainAnimation); - this.animations.forEach(animation => method(animation)); + public all(method: (animation?: Animation, target?: HTMLElement) => void) { + method(this.mainAnimation, this.mainElement); + this.animations.forEach(method); return this; } @@ -580,4 +580,116 @@ export const animate = (options: AnimationOptions = {}): Animate => { return new Animate(options); }; +export class Timeline extends Animate { + /** + * A Manager of Animations + */ + public animations: Manager = new Manager(); + constructor(options: AnimationOptions = {}) { + super(); + try { + let { options: animation, ...rest } = options; + let oldOptions = animation instanceof Animate ? animation.getOptions() : (Array.isArray(animation) ? animation?.[0]?.getOptions() : animation); + this.options = Object.assign({}, DefaultAnimationOptions, oldOptions, rest); + this.loop = this.loop.bind(this); + + let { + loop, + delay, + speed, + easing, + endDelay, + duration, + direction, + fillMode, + onfinish, + target, + keyframes, + autoplay, + extend, + ...properties + } = this.options; + + this.mainElement = document.createElement("div"); + this.targets = getTargets(target); + this.properties = properties; + + let delays = []; + let len = this.targets.length; + let animationKeyframe: Keyframe[] | PropertyIndexedKeyframes; + for (let i = 0; i < len; i++) { + let target = this.targets[i] as HTMLElement; + let animationOptions: AnimationOptions = { + easing: typeof easing == "string" ? getEase(easing) : easing, + iterations: loop === true ? Infinity : (loop as number), + direction, + endDelay, + duration, + delay, + fill: fillMode, + ...extend + }; + + // Accept keyframes as a keyframes Object, or a method, + // if there are no animations in the keyframes array, + // uses css properties from the options object + let arrKeyframes = computeValue((keyframes as Keyframe[]), [i, len, target], this); + animationKeyframe = arrKeyframes.length ? arrKeyframes : + (this.properties as PropertyIndexedKeyframes); + + // Allows the use of functions as the values, for both the keyframes and the animation object + // It adds the capability of advanced stagger animation, similar to the anime js stagger functions + animationOptions = mapObject(animationOptions, [i, len, target], this); + if (!(arrKeyframes.length > 0)) + animationKeyframe = mapObject(animationKeyframe, [i, len, target], this); + + // Set the Animate classes duration to be the Animation with the largest totalDuration + let tempDurations = animationOptions.delay + + (animationOptions.duration * animationOptions.iterations) + + animationOptions.endDelay; + if (this.totalDuration < tempDurations) this.totalDuration = tempDurations; + + // Add animation to the Animations Set + let animation = target.animate(animationKeyframe, animationOptions as KeyframeAnimationOptions); + + // Support for on finish + animation.onfinish = () => { + typeof onfinish == "function" && onfinish.call(this, target, i, len, animation); + this.emit("finish", target, i, len, animation); + }; + + // The calculated options for each individual option + this.computedOptions.set(animation, animationOptions); + this.animations.set(target, animation); + delays.push(animationOptions.delay); + } + + this.mainAnimation = this.mainElement.animate([ + { opacity: "0" }, + { opacity: "1" } + ], { + // Why waste performance on an animation no one can see? + duration: this.totalDuration, + easing: "linear" + }); + + this.minDelay = Math.min(...delays); + this.setSpeed(speed); + if (autoplay) this.play(); + else this.pause(); + + this.promise = this.newPromise(); + this.mainAnimation.onfinish = () => { + this.emit("complete", this); + this.stopLoop(); + }; + } catch (err) { + this.emit("error", err); + } + } + public add(options: AnimationOptions) { + return this; + } +} + export default animate; \ No newline at end of file